import type { AgentRecord } from './manager.js'; import type { ConversationMessageSnapshot } from '../../core/conversation.js'; /** Structured reason code for why a child terminated abnormally. */ export type ChildFailureReasonCode = 'max_turns' | 'circuit_breaker' | 'watchdog_timeout' | 'budget_exhausted' | 'claim_unverified' | 'api_error' | 'killed' | 'interrupted' | 'error'; export interface ChildFailureEnvelope { readonly agentId: string; /** The lifecycle phase the child was in when it terminated (best-effort, honest). */ readonly phase: string; readonly reason: { readonly code: ChildFailureReasonCode; /** The child record's own error text, never invented. */ readonly message: string; }; readonly partialOutputs: { /** The child's last committed assistant output (record.fullOutput), if any. */ readonly lastOutput?: string | undefined; /** A short, role-tagged summary of the last transcript messages, if available. */ readonly transcriptTail?: readonly string[] | undefined; /** How many turns the child completed before terminating, when known. */ readonly turnsCompleted?: number | undefined; /** Honest note, set when the child produced nothing before it died. */ readonly note?: string | undefined; }; } /** True when a record is in a terminal state that warrants a failure envelope. */ export declare function isChildFailureTerminal(record: Pick): boolean; /** Classify the structured reason from the record's own fields (status/terminationKind/error). */ export declare function classifyChildFailureReason(record: Pick): ChildFailureReasonCode; /** Best-effort, honest lifecycle phase label from what the record records. */ export declare function describeChildPhase(record: Pick): string; /** * Assemble the failure envelope from the child's record plus (optionally) a * transcript-tail snapshot the caller fetched from the AgentManager. Everything * here is drawn from real recorded state, nothing is fabricated. */ export declare function buildChildFailureEnvelope(record: AgentRecord, opts?: { readonly transcriptTail?: readonly ConversationMessageSnapshot[] | undefined; }): ChildFailureEnvelope; //# sourceMappingURL=child-failure-envelope.d.ts.map