aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
85 lines • 3.31 kB
TypeScript
import type { A2AClient } from './client.js';
import type { HitlDeliveryAdapter, HitlPromptEnvelope } from './hitl.js';
import type { JsonValue } from './types.js';
export interface HitlAuditEntry {
/** ISO 8601 timestamp at the moment the decision was finalized. */
decided_at: string;
/** Operator identity (delivery adapter's view — CLI uses $USER, etc.). */
operator: string;
/** Delivery channel name ('cli', 'slack', 'web', ...). */
channel: string;
prompt_id: string;
task_id?: string;
context_id?: string;
outcome: 'responded' | 'invalid' | 'expired' | 'aborted' | 'send_failed';
/** Operator's response payload — present only on `outcome === 'responded'`. */
response?: JsonValue;
/** Failure detail — present on non-success outcomes. */
error?: string;
/** How long the operator took (ms). */
duration_ms: number;
}
export interface HitlAuditLog {
/** Persist one decision. Implementations may async-flush to disk. */
append(entry: HitlAuditEntry): Promise<void> | void;
}
/** Default audit log — writes to stderr as JSONL. Replace with a file/HTTP sink in production. */
export declare class StderrHitlAuditLog implements HitlAuditLog {
append(entry: HitlAuditEntry): void;
}
/**
* Validate `response` against the JSON Schema in `envelope.response_schema`.
* Uses Ajv when available (transitive dep); falls back to the structural
* validator in `hitl.ts` otherwise.
*/
export declare function validateResponseAgainstSchema(envelope: HitlPromptEnvelope, response: JsonValue): {
ok: true;
} | {
ok: false;
errors: string[];
};
export interface DriveHitlOptions {
client: A2AClient;
taskId: string;
adapter: HitlDeliveryAdapter;
auditLog?: HitlAuditLog;
/**
* Cap the number of retries when the executor rejects a response with
* 422 `hitl_response_invalid`. Default: 3. After this many failed
* attempts the driver records an `invalid` audit entry and surfaces
* the last error to the caller.
*/
maxRevalidationRetries?: number;
/**
* Optional override for generating reply messageIds (defaults to
* `crypto.randomUUID()`).
*/
messageIdFactory?: () => string;
/** Stop after this many resolved prompts (test convenience). */
maxPrompts?: number;
/** Outer cancellation signal — closes the SSE subscription on abort. */
signal?: AbortSignal;
}
/**
* Subscribe to a task's SSE stream and drive HITL prompts to completion
* via the supplied adapter. Resolves when the stream closes (task reaches
* a terminal state) or when `maxPrompts` is reached.
*/
export declare function driveHitlPromptsForTask(opts: DriveHitlOptions): Promise<void>;
/**
* Drive a single prompt-response cycle. Exposed for callers that want
* to bypass the SSE stream (e.g. when an envelope arrives via the push-
* notification webhook receiver in #1256).
*/
export declare function driveOnePrompt(opts: {
envelope: HitlPromptEnvelope;
client: Pick<A2AClient, 'sendMessage'>;
adapter: HitlDeliveryAdapter;
auditLog: HitlAuditLog;
taskId?: string;
contextId?: string;
deadline?: string;
maxRetries?: number;
messageIdFactory?: () => string;
}): Promise<void>;
//# sourceMappingURL=hitl-driver.d.ts.map