export interface SubagentUsage { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number; turns: number; } export interface SubagentTimelineItem { kind: "status" | "tool" | "assistant" | "error"; phase?: "start" | "end"; text: string; at?: number; isError?: boolean; } export interface SubagentToolError { tool: string; message: string; } export interface ActiveSubagentConfig { name?: string; model?: string; effort?: string; description?: string; source?: "user" | "project"; filePath?: string; tools?: string[]; extensionTools?: string[]; skills?: string[]; } export interface SubagentRunDetails { version: 1; jobId?: string; background?: boolean; /** Stable id for crash recovery; "subagent__". */ runId?: string; /** Directory under the agent home state/subagents/ holding this run's persisted state. */ artifactsDir?: string; /** SDK session file path; needed to re-open the conversation on resume. */ sessionFile?: string; /** System prompt snapshot captured at run start; replayed on resume to avoid rule drift across vera upgrades. */ systemPromptSnapshot?: string; phase: "running" | "done" | "error"; agent?: ActiveSubagentConfig; task: string; cwd: string; model?: string; startedAt: number; endedAt?: number; durationMs?: number; /** Final text captured directly from the streaming agent_end event. */ finalText: string; /** Text salvaged from message history when streaming did not deliver a final text. */ salvagedFinalText?: string; /** Whether the streaming agent_end event was received (i.e., the LLM round completed cleanly). */ streamingCompleted?: boolean; /** Bounded raw child session messages captured for debugging empty final output. */ rawSessionOutput?: string; liveText?: string; lastEvent?: string; error?: string; /** Bounded summary of failed tool calls observed inside the child session. */ toolErrors: SubagentToolError[]; usage: SubagentUsage; timeline: SubagentTimelineItem[]; } export interface BackgroundJobSnapshot { jobId: string; status: "queued" | "running" | "done" | "error" | "aborted"; createdAt: number; updatedAt: number; details: SubagentRunDetails; } export interface ResumableSubagentRun { runId: string; phase: string; agent?: string; startedAt?: number; isStale?: boolean; } export interface SubagentStatusDetails { queued: number; running: number; finished: number; jobs: BackgroundJobSnapshot[]; resumable?: ResumableSubagentRun[]; } export interface SubagentCancelDetails { canceled: BackgroundJobSnapshot[]; alreadyFinished: BackgroundJobSnapshot[]; notFound: string[]; } export interface SubagentNotificationDetails { jobId: string; status: "done" | "error" | "aborted"; result: SubagentRunDetails; }