/** * In-process execution for subagents. * * Runs each subagent on the main thread and forwards AgentEvents for progress tracking. */ import type { AgentTelemetryConfig, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import { ModelRegistry } from "../config/model-registry"; import type { PromptTemplate } from "../config/prompt-templates"; import { Settings } from "../config/settings"; import type { Skill } from "../extensibility/skills"; import type { HindsightSessionState } from "../hindsight/state"; import type { LocalProtocolOptions } from "../internal-urls"; import type { MCPManager } from "../mcp/manager"; import type { ArtifactManager } from "../session/artifacts"; import type { AuthStorage } from "../session/auth-storage"; import type { ContextFileEntry } from "../tools"; import type { EventBus } from "../utils/event-bus"; import type { WorkspaceTree } from "../workspace-tree"; import { type AgentDefinition, type AgentProgress, type ReviewFinding, type SingleResult } from "./types"; /** Options for subagent execution */ export interface ExecutorOptions { cwd: string; worktree?: string; agent: AgentDefinition; task: string; assignment?: string; context?: string; description?: string; index: number; id: string; modelOverride?: string | string[]; /** * Active model selector of the parent session, used as an auth-aware fallback * if the resolved subagent model has no working credentials. See #985. */ parentActiveModelPattern?: string; thinkingLevel?: ThinkingLevel; outputSchema?: unknown; /** Parent task recursion depth (0 = top-level, 1 = first child, etc.) */ taskDepth?: number; enableLsp?: boolean; signal?: AbortSignal; onProgress?: (progress: AgentProgress) => void; sessionFile?: string | null; persistArtifacts?: boolean; artifactsDir?: string; /** Path to parent conversation context file */ contextFile?: string; eventBus?: EventBus; contextFiles?: ContextFileEntry[]; skills?: Skill[]; promptTemplates?: PromptTemplate[]; workspaceTree?: WorkspaceTree; mcpManager?: MCPManager; authStorage?: AuthStorage; modelRegistry?: ModelRegistry; settings?: Settings; /** Override local:// protocol options so subagent shares parent's local:// root */ localProtocolOptions?: LocalProtocolOptions; /** * Parent session's ArtifactManager. Subagent adopts it so artifact IDs are * unique across the whole agent tree and all artifacts land in the parent's * artifacts directory (no per-subagent subdir). */ parentArtifactManager?: ArtifactManager; parentHindsightSessionState?: HindsightSessionState; /** * Parent agent's OpenTelemetry configuration. When defined, the subagent's * loop is started with the same tracer/hooks but its own agent identity * stamped, so its `invoke_agent` / `chat` / `execute_tool` spans appear as * a sub-tree under the parent's active `execute_tool task` span. A * `handoff` span is emitted on dispatch to mark the parent → subagent * transition explicitly. */ parentTelemetry?: AgentTelemetryConfig; } export interface YieldItem { data?: unknown; status?: "success" | "aborted"; error?: string; } interface FinalizeSubprocessOutputArgs { rawOutput: string; exitCode: number; stderr: string; doneAborted: boolean; signalAborted: boolean; yieldItems?: YieldItem[]; reportFindings?: ReviewFinding[]; outputSchema: unknown; } interface FinalizeSubprocessOutputResult { rawOutput: string; exitCode: number; stderr: string; abortedViaYield: boolean; hasYield: boolean; } export declare const SUBAGENT_WARNING_NULL_YIELD = "SYSTEM WARNING: Subagent called yield with null data."; export declare const SUBAGENT_WARNING_MISSING_YIELD = "SYSTEM WARNING: Subagent exited without calling yield tool after 3 reminders."; export declare function finalizeSubprocessOutput(args: FinalizeSubprocessOutputArgs): FinalizeSubprocessOutputResult; /** * Run a single agent in-process. */ export declare function runSubprocess(options: ExecutorOptions): Promise; export {};