import type { DeliveryContext } from "../utils/delivery-context.types.js"; import type { SubagentRunOutcome } from "./subagent-announce-output.js"; import type { SubagentLifecycleEndedReason } from "./subagent-lifecycle-events.js"; import type { SpawnSubagentMode } from "./subagent-spawn.types.js"; export type PendingFinalDeliveryPayload = { requesterSessionKey: string; requesterOrigin?: DeliveryContext; requesterDisplayKey: string; childSessionKey: string; childRunId: string; task: string; label?: string; startedAt?: number; endedAt?: number; outcome?: SubagentRunOutcome; expectsCompletionMessage?: boolean; spawnMode?: SpawnSubagentMode; frozenResultText?: string | null; fallbackFrozenResultText?: string | null; wakeOnDescendantSettle?: boolean; }; export type SubagentRunRecord = { runId: string; childSessionKey: string; controllerSessionKey?: string; requesterSessionKey: string; requesterOrigin?: DeliveryContext; requesterDisplayKey: string; task: string; cleanup: "delete" | "keep"; label?: string; model?: string; agentDir?: string; workspaceDir?: string; runTimeoutSeconds?: number; spawnMode?: SpawnSubagentMode; createdAt: number; startedAt?: number; sessionStartedAt?: number; accumulatedRuntimeMs?: number; endedAt?: number; outcome?: SubagentRunOutcome; archiveAtMs?: number; cleanupCompletedAt?: number; cleanupHandled?: boolean; suppressAnnounceReason?: "steer-restart" | "killed"; expectsCompletionMessage?: boolean; announceRetryCount?: number; lastAnnounceRetryAt?: number; lastAnnounceDeliveryError?: string; endedReason?: SubagentLifecycleEndedReason; pauseReason?: "sessions_yield"; wakeOnDescendantSettle?: boolean; frozenResultText?: string | null; frozenResultCapturedAt?: number; fallbackFrozenResultText?: string | null; fallbackFrozenResultCapturedAt?: number; /** Set after the subagent_ended hook has been emitted successfully once. */ endedHookEmittedAt?: number; /** Durable marker that final user delivery still needs a retry/resume pass. */ pendingFinalDelivery?: boolean; pendingFinalDeliveryCreatedAt?: number; pendingFinalDeliveryLastAttemptAt?: number; pendingFinalDeliveryAttemptCount?: number; pendingFinalDeliveryLastError?: string | null; pendingFinalDeliveryPayload?: PendingFinalDeliveryPayload; completionAnnouncedAt?: number; attachmentsDir?: string; attachmentsRootDir?: string; retainAttachmentsOnKeep?: boolean; };