import type { ThinkingLevel as AiThinkingLevel } from "@earendil-works/pi-ai"; import type { AgentSession, ContextUsage } from "@earendil-works/pi-coding-agent"; export type SessionThinkingLevel = "off" | AiThinkingLevel; export type SubagentHarness = "pi" | "claude" | "codex"; export type SubagentBackend = "in-process" | "herdr" | "claude-sdk" | "codex-app-server"; export type ReasoningEffort = SessionThinkingLevel; export type SubagentToolPolicy = "pi-allowlist" | "native-broad-authority"; export type SubagentStatus = | "starting" | "running" | "waiting for feedback" | "completed" | "failed" | "stopped" | "interrupted"; export type FeedbackRequest = { id: string; question: string; context?: string; requestedAt: number; resolve: (feedback: string) => void; cancel: (reason: string) => void; }; export type FeedbackRequestDetails = { requestId: string; subagentId: string; status: "answered" | "cancelled"; }; export type StartSubagentDetails = { subagentId?: string; name?: string; role?: string; harness?: SubagentHarness; resolvedModel?: string; nativeRuntimeVersion?: string; toolPolicy?: SubagentToolPolicy; toolPolicyDiagnostic?: string; cwd?: string; task?: string; status: SubagentStatus | "error"; command?: string; availableRoles?: string[]; activity?: string; elapsed?: string; result?: string; error?: string; }; export type SubagentControlDetails = { action: "stop" | "reply"; status: "stopped" | "replied" | "noop" | "error"; subagentId?: string; name?: string; cwd?: string; subagentStatus?: SubagentStatus; activity?: string; elapsed?: string; message?: string; error?: string; }; export type RoleModelSpec = { provider: string; modelId: string; label: string; }; export type SubagentRole = { name: string; description: string; tools: string[]; model?: RoleModelSpec; thinking?: SessionThinkingLevel; systemPrompt: string; filePath: string; source: "built-in" | "user"; overridden?: boolean; autoExit?: boolean; output?: string; }; export type SubagentRoleOverride = { model?: string; thinking?: string; tools?: string[] | string; }; export type NativeHarnessSettings = { executable?: string; model: string; reasoningEffort: ReasoningEffort; }; export type SubagentSettings = { agentOverrides?: Record; maxConcurrent?: number; idleTimeoutMinutes?: number; openInHerdr?: boolean; harnesses?: Partial, Partial>>; }; export type SubagentLimits = { maxConcurrent: number; idleTimeoutMs: number; }; export type StatusMessageOptions = { deliverAs?: "steer" | "followUp" | "nextTurn"; triggerTurn?: boolean; display?: boolean; }; export type SubagentRoleDiagnostic = { level: "warning" | "error"; message: string; filePath?: string; }; export type SubagentRoleLoadResult = { roles: SubagentRole[]; diagnostics: SubagentRoleDiagnostic[]; limits: SubagentLimits; openInHerdr: boolean; harnesses: Record, NativeHarnessSettings>; }; export type ParsedStartArgs = { name: string; task: string; instructions?: string; role?: SubagentRole; cwd?: string; harness?: SubagentHarness; model?: string; reasoningEffort?: ReasoningEffort; notifyOnStart?: boolean; notifyOnCompletion?: boolean; reportCompletionToMain?: boolean; completionGroupId?: string; }; export type SubagentRecord = { id: string; parentSessionId: string; harness: SubagentHarness; name: string; task: string; instructions?: string; cwd: string; role?: SubagentRole; status: SubagentStatus; startedAt: number; lastActivityAt: number; finishedAt?: number; activity: string; result?: string; error?: string; session?: AgentSession; unsubscribe?: () => void; contextUsage?: ContextUsage; pendingFeedback?: FeedbackRequest; feedbackSerial: number; toolCalls: Map< string, { name: string; startedAt: number; status: "running" | "done" | "failed" } >; completion?: Promise; notifyOnCompletion: boolean; reportCompletionToMain: boolean; completionGroupId?: string; backend?: SubagentBackend; requestedModel?: string; requestedReasoningEffort?: ReasoningEffort; resolvedModel?: string; nativeRuntimeVersion?: string; nativeExecutable?: string; nativeSessionId?: string; toolPolicy?: SubagentToolPolicy; launchToken?: string; herdrSessionName?: string; herdrWorkspaceId?: string; herdrTabId?: string; herdrPaneId?: string; runDirectory?: string; childSessionPath?: string; dispatchState?: "pending" | "dispatched"; terminalState?: "completed" | "failed" | "stopped" | "interrupted"; externalDiagnostics?: string[]; coordinationSequence?: number; externalLaunchAbort?: AbortController; };