import type { ChatMessageMetadata, ChatUiMessageChunk } from "../../chat/protocol.js"; import { type ChildRunExecutionResult, type ChildRunExecutionSnapshot, type ChildRunExecutionUsage } from "../child-run/execution-snapshot.js"; import { type ChildRunResultMode } from "../child-run/result-summary.js"; import { type HostedChildExecutionLogEntry } from "./child-execution-logging.js"; import type { HostedChildPendingToolCallState, HostedChildPendingToolLifecycleCloseReason } from "./child-pending-tool-lifecycle.js"; import type { ForkPart, ForkRuntimeStreamResult } from "../streaming/fork-runtime-stream.js"; /** State for hosted child fork stream handling. */ export interface HostedChildForkStreamHandlingState { activeToolCallId: string | null; finalText: string; shouldSeparateNextTextBlock: boolean; } /** Public API contract for hosted child fork stream logger. */ export interface HostedChildForkStreamLogger { debug?: (message: string, metadata?: Record) => void; info?: (message: string, metadata?: Record) => void; warn?: (message: string, metadata?: Record) => void; } /** Public API contract for hosted child fork pending tool lifecycle. */ export interface HostedChildForkPendingToolLifecycle { emitToolInputStartIfNeeded: (toolCallId: string, toolName: string) => Promise | void; upsertPendingToolCall: (toolCallId: string, state: HostedChildPendingToolCallState) => void; deletePendingToolCall: (toolCallId: string) => void; closePendingToolCalls: (reason: HostedChildPendingToolLifecycleCloseReason) => Promise | void; } /** Input payload for hosted child fork stream trace. */ export interface HostedChildForkStreamTraceInput { conversationId?: string; parentRunId?: string; partType: ForkPart["type"]; } /** Input payload for execute hosted child fork stream. */ export interface ExecuteHostedChildForkStreamInput { streamResult: ForkRuntimeStreamResult; abortSignal?: AbortSignal; abortForkStream: (error: Error) => void; conversationId?: string; parentRunId?: string; description: string; kind: string; durableRunMirror: boolean; durableMessageId: string | null; durableReasoningMessageId: string | null; durableMirrorState: { reasoningStarted: boolean; textStarted: boolean; }; appendDurableMirrorChunk: (chunk: ChatUiMessageChunk) => Promise; closeDurableMirrorReasoning: () => Promise; closeDurableMirrorText: () => Promise; markDurableStepStarted: () => void; durableMirrorHasEmittedProgress: () => boolean; pendingToolLifecycle: HostedChildForkPendingToolLifecycle; toolCalls: Array<{ toolName: string; toolCallId: string; input?: unknown; }>; toolResults: Array<{ toolName: string; toolCallId: string; input: unknown; output: unknown; }>; streamState: { finalText: string; }; usage?: ChildRunExecutionUsage; maxSteps: number; resultMode?: ChildRunResultMode; startTime: number; finalizationTimeoutMs: number; onSettled?: (snapshot: ChildRunExecutionSnapshot) => void | Promise; idleTimeoutMs: number; activeToolTimeoutMs: number; postToolIdleTimeoutMs: number; logger?: HostedChildForkStreamLogger; writeLog?: (entry: HostedChildExecutionLogEntry) => void; tracePart?: (input: HostedChildForkStreamTraceInput) => void | Promise; } /** Input payload for handle hosted child fork failure. */ export interface HandleHostedChildForkFailureInput { error: unknown; description: string; kind: string; finalText: string; toolCalls: Array<{ toolName: string; toolCallId: string; input?: unknown; }>; toolResults: Array<{ toolName: string; toolCallId: string; input: unknown; output: unknown; }>; usage?: ChildRunExecutionUsage; startTime: number; onSettled?: (snapshot: ChildRunExecutionSnapshot) => void | Promise; shouldRethrowError?: (error: unknown) => boolean; writeLog?: (entry: HostedChildExecutionLogEntry) => void; } /** Finalize hosted child fork completion helper. */ export declare function finalizeHostedChildForkCompletion(input: { streamResult: ForkRuntimeStreamResult; finalText: string; description: string; kind: string; maxSteps: number; toolCalls: Array<{ toolName: string; toolCallId: string; input?: unknown; }>; toolResults: Array<{ toolName: string; toolCallId: string; input: unknown; output: unknown; }>; usage?: ChildRunExecutionUsage; resultMode?: ChildRunResultMode; startTime: number; durableMessageId: string | null; durableMirrorHasEmittedProgress: boolean; appendDurableMirrorChunk: (chunk: ChatUiMessageChunk) => Promise; finalizationTimeoutMs: number; onSettled?: (snapshot: ChildRunExecutionSnapshot) => void | Promise; logger?: HostedChildForkStreamLogger; writeLog?: (entry: HostedChildExecutionLogEntry) => void; }): Promise; /** Process a hosted child fork failure. */ export declare function handleHostedChildForkFailure(input: HandleHostedChildForkFailureInput): Promise; /** Process a hosted child fork stream part. */ export declare function handleHostedChildForkStreamPart(input: { part: ForkPart; conversationId?: string; description: string; durableMessageId: string | null; durableReasoningMessageId: string | null; durableMirrorState: { reasoningStarted: boolean; textStarted: boolean; }; appendDurableMirrorChunk: (chunk: ChatUiMessageChunk) => Promise; closeDurableMirrorReasoning: () => Promise; closeDurableMirrorText: () => Promise; pendingToolLifecycle: HostedChildForkPendingToolLifecycle; toolCalls: Array<{ toolName: string; toolCallId: string; input?: unknown; }>; toolResults: Array<{ toolName: string; toolCallId: string; input: unknown; output: unknown; }>; state: HostedChildForkStreamHandlingState; logger?: HostedChildForkStreamLogger; }): Promise; /** Execute hosted child fork stream. */ export declare function executeHostedChildForkStream(input: ExecuteHostedChildForkStreamInput): Promise; //# sourceMappingURL=child-fork-stream-execution.d.ts.map