import type { ChatUiMessage } from "../../chat/types.js"; import type { MirroredToolChunkState } from "../streaming/mirrored-tool-chunk-state.js"; import type { HostedChatExecutionLifecycleAdapter } from "./chat-execution-lifecycle-types.js"; type HostedChatFinalizationLogger = { error: (message: string, metadata?: Record) => void; }; export type HostedChatFinalizationCommon = { streamResult: { steps: PromiseLike; }; lifecycleAdapter: HostedChatExecutionLifecycleAdapter; mirroredToolChunkState: MirroredToolChunkState; capturedMessageId: string | null; incompleteToolCallsPartErrorText: string; cleanup: () => Promise; logger?: HostedChatFinalizationLogger; streamError?: unknown | null; }; export type FinalizeHostedChatRunInput = HostedChatFinalizationCommon & ({ kind: "response"; responseMessage: ChatUiMessage; isAborted: boolean; } | { kind: "detached"; isAborted: boolean; mirroredDurableOutput: boolean; }); /** * True once the durable run mirror has been told by the API that the run is already * terminal (veryfront-issue-inbox#743). Deleting a project cancels its in-flight * runs before the cascade removes them, so the append that follows is rejected with * `Cannot append external events to a terminal run` and the row is gone moments * later. Completing such a run can only fail, so finalization is skipped. * * This deliberately keys on the one narrow reason and no other: every other mirror * stop leaves a live run that still has to be completed. */ export declare function isDurableRunKnownTerminal(lifecycleAdapter: HostedChatExecutionLifecycleAdapter): boolean; export declare function finalizeHostedChatRun(input: FinalizeHostedChatRunInput): Promise; export {}; //# sourceMappingURL=hosted-chat-finalization.d.ts.map