import type { HostedLifecycleTerminalState } from "./lifecycle.js"; import type { StreamSnapshot } from "../streaming/lifecycle/types.js"; /** Error shape for hosted terminal. */ export interface HostedTerminalError { code: string; message: string; } /** State for hosted response finalization. */ export interface HostedResponseFinalizationState { persistedMessage: TMessage; finalizedMessage: TMessage; fallbackChunks: readonly TChunk[]; hasIncompleteToolParts: boolean; metadata?: HostedLifecycleTerminalState["metadata"]; } /** State for hosted detached finalization. */ export interface HostedDetachedFinalizationState { hasContent: boolean; fallbackChunks: readonly TChunk[]; hasIncompleteToolParts: boolean; } /** Options accepted by finalize hosted response. */ export interface FinalizeHostedResponseOptions { isAborted: boolean; getFinalStep: () => Promise; buildState: (finalStep: unknown) => Promise> | HostedResponseFinalizationState; shouldFailEmptyMessage: (input: { isAborted: boolean; message: TMessage; }) => boolean; resolveEmptyTerminalError: (input: { finalStep: unknown; streamError?: unknown | null; }) => HostedTerminalError | Promise; appendFallbackChunk: (chunk: TChunk) => Promise | void; flushMirror: () => Promise | void; dispatchTerminalState: (state: HostedLifecycleTerminalState) => Promise | void; resolveTerminalState: (input: { isAborted: boolean; hasIncompleteToolParts: boolean; }) => HostedLifecycleTerminalState; cleanup: () => Promise | void; streamError?: unknown | null; } /** Options accepted by finalize hosted detached. */ export interface FinalizeHostedDetachedOptions { isAborted: boolean; mirroredDurableOutput: boolean; getFinalStep: () => Promise; buildState: (finalStep: unknown) => Promise> | HostedDetachedFinalizationState; resolveEmptyTerminalError: (input: { finalStep: unknown; streamError?: unknown | null; }) => HostedTerminalError | Promise; appendFallbackChunk: (chunk: TChunk) => Promise | void; flushMirror: () => Promise | void; dispatchTerminalState: (state: HostedLifecycleTerminalState) => Promise | void; resolveTerminalState: (input: { isAborted: boolean; hasIncompleteToolParts: boolean; }) => HostedLifecycleTerminalState; cleanup: () => Promise | void; streamError?: unknown | null; } /** * Read a known step finish reason from a hosted final step, or null. * * Returns every finish reason that marks a completed provider step, * including "tool-calls", which signals a tool handoff rather than run * completion. Unknown reasons and malformed steps read as null. */ export declare function readHostedFinishReason(finalStep: unknown): StreamSnapshot["finishReason"]; /** Response payload for finalize hosted. */ export declare function finalizeHostedResponse(options: FinalizeHostedResponseOptions): Promise; /** Finalize hosted detached helper. */ export declare function finalizeHostedDetached(options: FinalizeHostedDetachedOptions): Promise; //# sourceMappingURL=stream-finalization.d.ts.map