import { type ChildRunExecutionResult, type ChildRunExecutionSnapshot } from "../child-run/execution-snapshot.js"; /** State for hosted child lifecycle terminal. */ export interface HostedChildLifecycleTerminalState { status: "completed" | "failed" | "cancelled"; usage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number; }; terminalErrorCode?: string | null; terminalErrorMessage?: string | null; } export interface HostedChildLifecycleCompletedState extends Omit { status: "completed"; } /** Public API contract for hosted child lifecycle adapter. */ export interface HostedChildLifecycleAdapter { pending?: () => Promise | void; running?: () => Promise | void; completed?: (terminalState: HostedChildLifecycleTerminalState) => Promise | void; failed?: (terminalState: HostedChildLifecycleTerminalState) => Promise | void; cancelled?: (terminalState: HostedChildLifecycleTerminalState) => Promise | void; } export interface HostedChildLifecycleErrorState extends Omit { status: "failed" | "cancelled"; } /** Options accepted by hosted child lifecycle runner. */ export interface HostedChildLifecycleRunnerOptions { adapter: HostedChildLifecycleAdapter; execute: () => Promise | TResult; resolveCompletedState?: (result: TResult) => Promise | HostedChildLifecycleCompletedState; resolveErrorState: (error: unknown) => Promise | HostedChildLifecycleErrorState; onLifecycleError?: (error: unknown) => Promise | void; } /** Result returned from hosted child lifecycle run. */ export type HostedChildLifecycleRunResult = { status: "completed"; result: TResult; terminalState: HostedChildLifecycleTerminalState; } | { status: "failed" | "cancelled"; error: unknown; terminalState: HostedChildLifecycleTerminalState; }; /** Result returned from hosted child execution lifecycle. */ export type HostedChildExecutionLifecycleResult = { status: "completed"; result: TLocalResult; snapshot: ChildRunExecutionSnapshot; terminalState: HostedChildLifecycleTerminalState; } | { status: "failed" | "cancelled"; error: unknown; terminalState: HostedChildLifecycleTerminalState; }; /** Should skip hosted child terminal persistence helper. */ export declare function shouldSkipHostedChildTerminalPersistence(terminalState: Pick): boolean; /** Options accepted by hosted child execution lifecycle. */ export interface HostedChildExecutionLifecycleOptions { adapter: HostedChildLifecycleAdapter; executionFailedCode: string; abortSignal?: AbortSignal | undefined; execute: () => Promise | TLocalResult; getExecutionSnapshot: () => ChildRunExecutionSnapshot | null; onLifecycleError?: (error: unknown) => Promise | void; skipTerminalPersistence?: (terminalState: HostedChildLifecycleTerminalState) => boolean; } /** * Terminal error code for a child whose work finished but whose terminal state * could not be persisted. Distinct from an execution failure code on purpose: * the child produced its result, the run record did not survive it. */ export declare const HOSTED_CHILD_FINALIZATION_FAILED_CODE = "CHILD_FINALIZATION_FAILED"; /** Run hosted child lifecycle. */ export declare function runHostedChildLifecycle(options: HostedChildLifecycleRunnerOptions): Promise>; /** Run hosted child execution lifecycle. */ export declare function runHostedChildExecutionLifecycle(options: HostedChildExecutionLifecycleOptions): Promise>; //# sourceMappingURL=child-lifecycle.d.ts.map