import type { ChildRunExecutionResult, ChildRunExecutionSnapshot } from "../child-run/execution-snapshot.js"; import { type ChildRunResultMode, type ChildRunResultSummary } from "../child-run/result-summary.js"; import { type ConversationRunTargets } from "../conversation/durable.js"; import { type AgentTraceAttributes, buildInvokeAgentTraceAttributes } from "./trace-attributes.js"; import { createConversationChildLifecycleAdapter } from "../conversation/hosted-lifecycle.js"; import type { InvokeAgentChildRunProgressEvent } from "../child-run/invoke-agent-child-runs.js"; import { bootstrapHostedChildRun } from "./child-bootstrap.js"; import { runHostedChildExecutionLifecycle, shouldSkipHostedChildTerminalPersistence } from "./child-lifecycle.js"; import { type HostedChildRunIdentifiers, type HostedChildTerminalStatus } from "./child-status.js"; import { type HostedChildForkToolInput, type HostedChildInvocationContext } from "./child-tool-input.js"; import { type HostedProjectReferenceResolver } from "./project-reference-resolver.js"; import { type HostedRunEventWriterCapability } from "./child-run-event-writer-token.js"; /** Sanitized failure raised when setup-failure finalization itself cannot be persisted. */ export declare class HostedChildRunFinalizationError extends Error { constructor(); } /** Options accepted by hosted durable child execution. */ export type HostedDurableChildExecutionOptions = { durableChildRun?: HostedChildRunIdentifiers; }; /** Result returned from hosted durable child invoke. */ export type HostedDurableChildInvokeResult = { ok: boolean; status: "completed" | "failed"; text?: string; error?: string; summary?: ChildRunResultSummary; steps?: number; toolCalls?: ChildRunExecutionSnapshot["toolCalls"]; toolResults?: ChildRunExecutionSnapshot["toolResults"]; usage?: ChildRunExecutionSnapshot["usage"]; durationMs?: ChildRunExecutionSnapshot["durationMs"]; childConversationId?: string | null; childRunId?: string | null; childMessageId?: string | null; sourceTargetKind?: ConversationRunTargets["sourceTargetKind"]; runtimeTargetKind?: ConversationRunTargets["runtimeTargetKind"]; terminalErrorCode: string | null; terminalErrorMessage: string | null; }; /** * Published contract for the `invoke_agent` tool result this module writes. * * Split by status rather than flattened: a `completed` envelope must carry the * child identifiers, because a consumer reading it back has no other way to * locate the child run. A terminal envelope may omit them, since a setup failure * can happen before the child exists. Flattening the two would let a completed * result lose an identifier while conformance tests stayed green. * * Deliberately permissive about extra run telemetry it does not name: this pins * the fields consumers depend on, and closing the shape would make any additive * change here a cross-repo deploy-order problem. * See veryfront/veryfront-issue-inbox#423. */ export declare const getHostedDurableChildInvokeResultSchema: () => import("../../internal-agents/schema.js").Schema<({ ok: boolean; terminalErrorCode: string | null; terminalErrorMessage: string | null; } & { text?: string | undefined; error?: string | undefined; summary?: ({ text: string; } & {} & Record) | undefined; steps?: number | undefined; toolCalls?: unknown[] | undefined; toolResults?: unknown[] | undefined; usage?: Record | undefined; durationMs?: number | undefined; sourceTargetKind?: string | null | undefined; runtimeTargetKind?: string | null | undefined; } & { status: "completed"; childConversationId: string; childRunId: string; childMessageId: string; } & Record) | ({ ok: boolean; terminalErrorCode: string | null; terminalErrorMessage: string | null; } & { text?: string | undefined; error?: string | undefined; summary?: ({ text: string; } & {} & Record) | undefined; steps?: number | undefined; toolCalls?: unknown[] | undefined; toolResults?: unknown[] | undefined; usage?: Record | undefined; durationMs?: number | undefined; sourceTargetKind?: string | null | undefined; runtimeTargetKind?: string | null | undefined; } & { status: "failed"; childConversationId: string | null | undefined; childRunId: string | null | undefined; childMessageId: string | null | undefined; } & Record)>; /** Input payload for build hosted durable child invoke failure result. */ export type BuildHostedDurableChildInvokeFailureResultInput = { terminalErrorCode: string; terminalErrorMessage: string; targets?: ConversationRunTargets; childConversationId?: string | null; childRunId?: string | null; childMessageId?: string | null; }; /** Public API contract for hosted durable child success. */ export type HostedDurableChildSuccess = { result: TLocalResult; snapshot: ChildRunExecutionSnapshot; identifiers: HostedChildRunIdentifiers; targets: ConversationRunTargets; }; /** Options accepted when building hosted durable child invoke success results. */ export type HostedDurableChildInvokeSuccessResultOptions = { resultMode?: ChildRunResultMode; }; /** Public API contract for hosted durable child terminal failure. */ export type HostedDurableChildTerminalFailure = { status: HostedChildTerminalStatus; identifiers: HostedChildRunIdentifiers; targets: ConversationRunTargets; terminalErrorCode: string; terminalErrorMessage: string; }; /** Public API contract for hosted durable child setup failure. */ export type HostedDurableChildSetupFailure = { targets: ConversationRunTargets; childConversationId: string | null; childRunId: string | null; childMessageId: string | null; terminalErrorCode: string; terminalErrorMessage: string; }; /** Input payload for hosted durable child invoke trace. */ export type HostedDurableChildInvokeTraceInput = Parameters[0]; /** Public API contract for hosted durable child invoke trace base. */ export type HostedDurableChildInvokeTraceBase = Pick; /** Public API contract for hosted durable child invoke trace overrides. */ export type HostedDurableChildInvokeTraceOverrides = Partial>; /** Public API contract for hosted durable child invoke trace recorder. */ export type HostedDurableChildInvokeTraceRecorder = ReturnType; /** Public API contract for hosted local child invoke trace recorder. */ export type HostedLocalChildInvokeTraceRecorder = { recordLocalResult(result: TLocalResult): TLocalResult; recordLocalFailure(errorMessage: string): void; }; /** Input payload for execute hosted local child invoke. */ export type ExecuteHostedLocalChildInvokeInput = { forkInput: Pick; abortSignal?: AbortSignal; traceRecorder: HostedLocalChildInvokeTraceRecorder; execute: () => Promise | ChildRunExecutionResult; getExecutionSnapshot?: () => ChildRunExecutionSnapshot | null; resultMode?: ChildRunResultMode; isAbortError?: (error: unknown) => boolean; }; /** Result returned from build hosted durable child invoke failure. */ export declare function buildHostedDurableChildInvokeFailureResult(input: BuildHostedDurableChildInvokeFailureResultInput): HostedDurableChildInvokeResult; /** Result returned from build hosted durable child invoke terminal failure. */ export declare function buildHostedDurableChildInvokeTerminalFailureResult(input: HostedDurableChildTerminalFailure): HostedDurableChildInvokeResult; /** Result returned from build hosted durable child invoke success. */ export declare function buildHostedDurableChildInvokeSuccessResult(input: HostedDurableChildSuccess, options?: HostedDurableChildInvokeSuccessResultOptions): HostedDurableChildInvokeResult; /** Create hosted durable child invoke trace recorder. */ export declare function createHostedDurableChildInvokeTraceRecorder(input: { traceBase: HostedDurableChildInvokeTraceBase; setTraceAttributes: (attributes: AgentTraceAttributes) => void; executionFailedCode: string; }): { annotate: (overrides?: HostedDurableChildInvokeTraceOverrides) => void; recordLocalResult(result: TLocalResult): TLocalResult; recordLocalFailure(errorMessage: string): void; recordSetupFailure(failure: HostedDurableChildSetupFailure): HostedDurableChildInvokeResult; recordTerminalFailure(failure: HostedDurableChildTerminalFailure): HostedDurableChildInvokeResult; recordSuccess(success: HostedDurableChildSuccess, options?: HostedDurableChildInvokeSuccessResultOptions): HostedDurableChildInvokeResult; }; /** Execute hosted local child invoke. */ export declare function executeHostedLocalChildInvoke(input: ExecuteHostedLocalChildInvokeInput): Promise; /** Context for hosted durable child bootstrap. */ export type HostedDurableChildBootstrapContext = { parentConversationId: string; parentRunId: string; parentMessageId: string; targets: ConversationRunTargets; resolvedModel: string; provider: string; }; /** Public API contract for hosted durable child bootstrap callbacks. */ export type HostedDurableChildBootstrapCallbacks = { runBootstrap?: (operation: () => Promise) => Promise; onBootstrapStart?: (input: HostedDurableChildBootstrapContext) => Promise | void; onBootstrapComplete?: (input: HostedDurableChildBootstrapContext & { identifiers: HostedChildRunIdentifiers; }) => Promise | void; onBootstrapError?: (input: { error: unknown; parentConversationId: string; toolCallId: string; }) => Promise | void; }; /** Public API contract for hosted durable child runtime dependencies. */ export type HostedDurableChildRuntimeDependencies = { bootstrapChildRun?: typeof bootstrapHostedChildRun; createLifecycleAdapter?: typeof createConversationChildLifecycleAdapter; runLifecycle?: typeof runHostedChildExecutionLifecycle; shouldSkipTerminalPersistence?: typeof shouldSkipHostedChildTerminalPersistence; }; /** * Input for bootstrapping and executing a hosted durable child fork. * `runEventWriterCapability` carries exact-parent authority; this helper mints * the exact-child capability only after the child run is persisted. */ export type ExecuteHostedDurableChildForkInput = { authToken: string; apiUrl: string; /** Opaque exact-parent authority used only to mint this invocation's child writer. */ runEventWriterCapability?: HostedRunEventWriterCapability; forkInput: HostedChildForkToolInput; executionOptions: { toolCallId: string; abortSignal?: AbortSignal; }; childAgentId: string; runProjectId?: string | null; parentConversationId?: string; parentRunId?: string; parentMessageId?: string; trustedInvocationContext?: HostedChildInvocationContext; getProjectId: () => string | null | undefined; getRuntimeTargetKind?: () => ConversationRunTargets["runtimeTargetKind"] | undefined; getRuntimeTargetEnvironmentId?: () => string | null | undefined; getBranchId?: () => string | null | undefined; getContextModel?: () => string | undefined; resolveProjectReference?: HostedProjectReferenceResolver; defaultModel: string; resolveModelId: (model: string) => string; resolveProvider: (modelId: string) => string; onRequestedProjectId?: (projectId: string, projectSlug?: string) => Promise | void; publishParentRunEvents?: (events: InvokeAgentChildRunProgressEvent[]) => Promise | void; contextUnavailableMessage: string; setupFailedCode: string; executionFailedCode: string; executeLocal: (options?: HostedDurableChildExecutionOptions) => Promise | TLocalResult; getExecutionSnapshot: () => ChildRunExecutionSnapshot | null; buildContextUnavailableResult: (message: string) => TResult; buildSetupFailureResult: (failure: HostedDurableChildSetupFailure) => TResult; buildTerminalFailureResult: (failure: HostedDurableChildTerminalFailure) => TResult; buildSuccessResult: (success: HostedDurableChildSuccess) => TResult; onLifecycleError?: (error: unknown) => Promise | void; onLifecycleFinalized?: (input: { identifiers: HostedChildRunIdentifiers; status: "completed"; }) => Promise | void; bootstrap?: HostedDurableChildBootstrapCallbacks; runtime?: HostedDurableChildRuntimeDependencies; }; /** Execute hosted durable child fork. */ export declare function executeHostedDurableChildFork(input: ExecuteHostedDurableChildForkInput): Promise; //# sourceMappingURL=durable-child-fork-execution.d.ts.map