import type { ChannelAskSnapshot, ChannelAskSubmission, ChannelAskSubmissionResult, ChannelInteractionSink } from "@mono-agent/agent-contracts"; /** * Interaction bridge: the app-owned loopback HTTP surface that lets tool child * processes (adapter-send-tools, project MCP servers) interact with the human * behind a channel conversation while a tool call is in flight. * * Two capabilities share it: * - Blocking `AskUser`: POST /v1/asks registers one structured prompt, the * channel presents it, and the tool long-polls until every question is answered. * - Tool progress: POST /v1/progress fans out to the channel sink's postStatus * (e.g. a Telegram status message edited in place). * * The registry is in-memory by design: on an app restart pending asks vanish and * the user's later reply simply arrives as a normal next turn (multi-turn * degradation), which the AskUser tool description tells the model to expect. */ export interface InteractionBridgeOptions { readonly host?: string; /** TCP port; 0 picks an ephemeral port. Default {@link DEFAULT_INTERACTION_BRIDGE_PORT}. */ readonly port?: number; /** Default + upper bound for a single ask's wait (ms). Default 10 minutes. */ readonly askTimeoutMs?: number; /** Injectable wall clock for deterministic interaction-history timestamps. */ readonly now?: () => Date; /** Record one already-delivered adapter message in its destination history. */ readonly recordDeliveryHistory?: (input: { readonly conversationId: string; readonly text: string; readonly idempotencyKey: string; }) => Promise<{ readonly recorded: boolean; readonly code?: string; }>; readonly logger?: { warn?: (message: string, metadata?: Record) => void; debug?: (message: string, metadata?: Record) => void; }; } export interface InteractionBridgeHandle { readonly url: string; readonly token: string; registerSink(channelId: string, sink: ChannelInteractionSink): void; getPendingAsk(conversationId: string): ChannelAskSnapshot | undefined; getAsk(interactionId: string): ChannelAskSnapshot | undefined; submitAskAnswers(input: ChannelAskSubmission): Promise; /** Fail every pending ask on the conversation (user cancelled the run). */ cancelAsks(conversationId: string): void; /** Master bridge environment for app-owned ask-tool children only. */ env(): Record; /** Issue a bearer that can only post progress for this exact producing run. */ issueProgressCapability(input: { readonly runId: string; readonly conversationId: string; }): { readonly url: string; readonly token: string; release(): void; }; /** Issue a bearer limited to destination-history recording for one adapter-send run. */ issueDeliveryHistoryCapability(input: { readonly runId: string; readonly producerConversationId: string; readonly allowedChannels: readonly ("slack" | "telegram")[]; }): { readonly url: string; readonly token: string; release(): void; }; /** Add this run's answered/expired blocking asks to its durable assistant history text. */ enrichAssistantHistory(input: { readonly runId: string; readonly conversationId: string; readonly assistantText: string; }): string; /** Discard all interaction-history state owned by a completed run. */ releaseRun(input: { readonly runId: string; readonly conversationId: string; }): void; stop(): Promise; } /** Default port 0 = ephemeral: consumers get the URL via env, so a fixed port only invites collisions. */ export declare const DEFAULT_INTERACTION_BRIDGE_PORT = 0; export declare const DEFAULT_ASK_USER_TIMEOUT_MS = 600000; /** Render a loopback bridge origin, including bracketed IPv6 literals. */ export declare function formatInteractionBridgeUrl(host: string, port?: number): string; /** Resolved `interaction` config block (JSON `interaction` key + env overrides). */ export interface InteractionSettings { /** True when the operator explicitly configured the block (JSON or env). */ readonly configured: boolean; readonly host: string; readonly port: number; readonly askTimeoutMs: number; readonly progressEnabled: boolean; } /** * Load the app-level `interaction` block from `mono-agent.config.json` with env * overrides (`MONO_AGENT_INTERACTION_BRIDGE_HOST/PORT`, * `MONO_AGENT_ASK_USER_TIMEOUT_MS`, `MONO_AGENT_PROGRESS_ENABLED`). Tolerant of * a missing file/block: returns unconfigured defaults. */ export declare function loadInteractionSettings(input: { readonly env: Record; readonly configPath: string; }): Promise; export declare function startInteractionBridge(options?: InteractionBridgeOptions): Promise; //# sourceMappingURL=interaction-bridge.d.ts.map