/** * types.ts — Type definitions for the subagent system. */ import type { ThinkingLevel } from "@earendil-works/pi-agent-core"; import type { AgentSession } from "@earendil-works/pi-coding-agent"; export type { ThinkingLevel } from "@earendil-works/pi-agent-core"; /** Agent type: any user-defined string name. */ export type SubagentType = string; /** Memory scope for persistent agent memory. */ export type MemoryScope = "user" | "project" | "local"; /** Isolation mode for agent execution. */ export type IsolationMode = "worktree"; /** Unified agent configuration — used for both default and user-defined agents. */ export interface AgentConfig { name: string; displayName?: string; description: string; builtinToolNames?: string[]; /** Tool denylist — these tools are removed even if `builtinToolNames` or extensions include them. */ disallowedTools?: string[]; /** true = inherit all, string[] = only listed, false = none */ extensions: true | string[] | false; /** true = inherit all, string[] = only listed, false = none */ skills: true | string[] | false; model?: string; thinking?: ThinkingLevel; maxTurns?: number; systemPrompt: string; promptMode: "replace" | "append"; /** Default for spawn context. undefined = caller decides. */ context?: AgentContextMode; /** Default for spawn: run in background. undefined = caller decides. */ runInBackground?: boolean; /** Default for spawn: no extension tools. undefined = caller decides. */ isolated?: boolean; /** Persistent memory scope — agents with memory get a persistent directory and MEMORY.md */ memory?: MemoryScope; /** Isolation mode — "worktree" runs the agent in a temporary git worktree */ isolation?: IsolationMode; /** Request caveman prompt application through the caveman extension RPC. */ caveman?: boolean; /** Non-fatal frontmatter warnings found while loading this agent. */ frontmatterWarnings?: string[]; /** false = agent is hidden from the registry */ enabled?: boolean; /** Where this agent was loaded from */ source?: "default" | "project" | "global"; } export type JoinMode = "async" | "group" | "smart"; export type RunnerBackend = "in-process" | "herdr"; export type AgentContextMode = "fresh" | "fork"; export interface AgentRecord { id: string; type: SubagentType; description: string; status: "queued" | "running" | "completed" | "steered" | "aborted" | "stopped" | "error"; result?: string; error?: string; /** Short resolved model name for live status display. */ modelName?: string; /** Effective thinking level for live status display. */ thinkingLevel?: ThinkingLevel; runnerBackend?: RunnerBackend; toolUses: number; startedAt: number; completedAt?: number; session?: AgentSession; abortController?: AbortController; promise?: Promise; groupId?: string; joinMode?: JoinMode; /** Set when result was already consumed via get_subagent_result — suppresses completion notification. */ resultConsumed?: boolean; /** Steering messages queued before the session was ready. */ pendingSteers?: string[]; /** Worktree info if the agent is running in an isolated worktree. */ worktree?: { path: string; branch: string; }; /** Worktree cleanup result after agent completion. */ worktreeResult?: { hasChanges: boolean; branch?: string; }; /** Notable run tags, shown in UI/lifecycle metadata. */ tags?: string[]; /** Non-fatal warnings produced while preparing or running the agent. */ warnings?: string[]; /** The tool_use_id from the original Agent tool call. */ toolCallId?: string; /** Path to the streaming output transcript file. */ outputFile?: string; /** Parsed Herdr JSONL transcript metadata for out-of-process runs. */ herdrTranscript?: { entries: string[]; warnings?: string[]; }; /** Cleanup function for the output file stream subscription. */ outputCleanup?: () => void; } /** Details attached to custom notification messages for visual rendering. */ export interface NotificationDetails { id: string; description: string; status: string; toolUses: number; turnCount: number; maxTurns?: number; totalTokens: number; durationMs: number; outputFile?: string; error?: string; resultPreview: string; /** Notable run tags, shown in UI metadata. */ tags?: string[]; /** Non-fatal warnings produced while preparing or running the agent. */ warnings?: string[]; /** Additional agents in a group notification. */ others?: NotificationDetails[]; } export interface EnvInfo { isGitRepo: boolean; branch: string; platform: string; }