import { type AgentMessage, type Conversation, type Executor } from "./protocol.js"; import type { TerminalControlRef } from "./terminal-agent-adapter.js"; import type { RecordedTerminalZeroInputAbort, TerminalDispatchAcceptance } from "./terminal-dispatch-application.js"; import type { terminalSubmissionReplayReceipt } from "./terminal-dispatch-receipt.js"; type ReplayReceipt = ReturnType; export type TerminalSendAgentAcceptance = "proven" | "unproven"; export type TerminalSendManagementMode = "managed" | "unmanaged"; export type TerminalSendObservationMode = "managed_monitor" | "terminal_watch" | "none"; export interface TerminalSendResultCapabilities { callback: boolean; interaction_notify: boolean; interaction_respond: boolean; } export interface TerminalSendResultContract { terminal_input_dispatched: boolean; agent_acceptance: TerminalSendAgentAcceptance; management_mode: TerminalSendManagementMode; observation_mode: TerminalSendObservationMode; capabilities: TerminalSendResultCapabilities; /** Compatibility value used by 0.12.x readers. */ legacy_management_mode: "managed" | "unmanaged_fallback"; } export interface NormalizedTerminalSendResultContract extends TerminalSendResultContract { /** Compatibility alias: true only when Enter dispatch is proven. */ delivered: boolean; } /** Keep transport, native acceptance, management, and observation orthogonal. */ export declare function terminalSendResultContract(input: Readonly<{ terminalInputDispatched: boolean; agentAcceptance: TerminalSendAgentAcceptance; managementMode: TerminalSendManagementMode; observationMode: TerminalSendObservationMode; callbackAvailable: boolean; interactionNotificationAvailable?: boolean; interactionResponseAvailable?: boolean; }>): TerminalSendResultContract; /** * Compatibility predicate for the one legacy `delivered` fact. Text * injection is terminal input, but delivery is not complete until Enter has * durable proof. Older presenters encoded post-Enter rejection/uncertainty as * `delivered: false`, so retain those stronger receipt facts while excluding * retry refusals which explicitly sent no input. */ export declare function terminalSendEnterDispatched(value: unknown): boolean; /** Normalize Send output from an older CLI without weakening error policy. */ export declare function normalizedTerminalSendResultContract(value: Readonly>): NormalizedTerminalSendResultContract; export interface TerminalDispatchPresentationContext { message: AgentMessage; executor: Executor; terminalControl: TerminalControlRef; } export interface TerminalDispatchPresentationPorts { write(value: Record): void; budget(conversation: Conversation): unknown; nextAction(input: Readonly<{ conversationId: string; sessionId: string; turnId: string; source: "terminal_control"; callbackExpected: boolean; }>): unknown; summarize(value: unknown): unknown; } export interface OpenClawYieldNextActionInput { conversationId: string; sessionId: string; turnId: string; source: "terminal_control"; callbackExpected: boolean; } export declare function openClawYieldNextAction({ conversationId, sessionId, turnId, source, callbackExpected }: OpenClawYieldNextActionInput): { action: "yield"; reason: string; source: "terminal_control"; conversation_id: string; session_id: string; turn_id: string; callback_expected: boolean; do_not: string; expected_callback: string; }; export declare function presentTerminalDispatchReplay(input: Readonly<{ owner: Conversation; receipt: ReplayReceipt; accepted: boolean; acceptanceInvalid: boolean; receiptConversationId: string; receiptMessageId: string; callbackExpected: boolean; userExplicit?: Readonly<{ terminalId: string; messageId: string; }>; }>, context: TerminalDispatchPresentationContext, ports: TerminalDispatchPresentationPorts): void; export declare function presentTerminalZeroInputAbort(failure: RecordedTerminalZeroInputAbort, context: TerminalDispatchPresentationContext, ports: TerminalDispatchPresentationPorts, monitorPid?: number | null): void; export declare function presentTerminalIdentityFailure(conversation: Conversation, reason: string, context: TerminalDispatchPresentationContext, ports: TerminalDispatchPresentationPorts, monitorPid?: number | null): void; export declare function presentTerminalUncertain(input: Readonly<{ conversation: Conversation; stalledConversationIds: readonly string[]; textInjected: boolean; enterDispatched: boolean; monitorPid?: number | null; }>, context: TerminalDispatchPresentationContext, ports: TerminalDispatchPresentationPorts): void; export declare function presentTerminalCompleted(input: Readonly<{ conversation: Conversation; acceptance?: TerminalDispatchAcceptance; monitorPid?: number | null; bookkeepingWarning?: string; }>, context: TerminalDispatchPresentationContext, ports: TerminalDispatchPresentationPorts): void; export {};