import * as fs from "fs"; import type { Message } from "../types/index.js"; import { Container } from "../utils/container.js"; import { type SubagentInstance } from "./subagentManager.js"; import type { PermissionMode } from "../types/permissions.js"; export interface ForkedAgentEntry { id: string; instance: SubagentInstance; logPath: string; logStream?: fs.WriteStream; status: "running" | "completed" | "failed"; } export interface ForkedAgentManagerCallbacks { onForkedAgentStatusChange?: (entries: ForkedAgentEntry[]) => void; } export declare class ForkedAgentManager { private container; private activeForks; private inFlightPromises; private callbacks; constructor(container: Container, options?: { callbacks?: ForkedAgentManagerCallbacks; }); private get subagentManager(); /** * Creates a forked subagent with conversation history and executes it asynchronously (fire-and-forget). * Does NOT interact with BackgroundTaskManager. */ forkAndExecute(subagentType: string, messages: Message[], parameters: { description: string; allowedTools?: string[]; model?: string; permissionModeOverride?: PermissionMode; maxTurns?: number; }, prompt: string): Promise; private executeFork; /** * Abort a running forked agent. */ stop(id: string): boolean; /** * Stop all running forked agents, wait for in-flight executions to settle, and clear the map. */ cleanup(): Promise; /** * Returns list of active forked agents. */ getActiveForks(): ForkedAgentEntry[]; private notifyChange; }