import { ACodeRuntime } from "./runtime.js"; import type { ACodeRuntimeConfig } from "./types.js"; import { SubAgentStore } from "./sub-agent-store.js"; import type { SubAgentContextSnapshot, SubAgentEvent, SubAgentStatus, SubAgentType } from "./sub-agent-types.js"; export interface SubAgentCompletionNotification { subId: string; subagentType: SubAgentType; description: string; status: SubAgentStatus; output: string; error?: string; durationMs?: number; } export type SubAgentRecheckFn = (output: string, turn: number) => Promise<{ done: boolean; continueMessage?: string; }>; export interface SubAgentSpawnOptions { parentAgentId: string; parentSessionId: string; subagentType: SubAgentType; description: string; prompt: string; workingDirectory: string; parentConfig: ACodeRuntimeConfig; allowedTools?: string[]; silent?: boolean; } export interface SubAgentEntry { subId: string; parentAgentId: string; parentSessionId: string; subagentType: SubAgentType; description: string; prompt: string; status: SubAgentStatus; result?: string; errorMessage?: string; startedAt: number; endedAt?: number; durationMs?: number; runtime: ACodeRuntime; abortController: AbortController; contextSnapshot: SubAgentContextSnapshot; availableTools: string[]; allocatedTools?: string[]; completionResolve?: (result: { output: string; error?: string; }) => void; completionReject?: (err: any) => void; completionPromise?: Promise<{ output: string; error?: string; }>; silent?: boolean; awaited?: boolean; } export interface SubAgentManagerOptions { store: SubAgentStore; maxConcurrent?: number; } type EventSubscriber = (event: SubAgentEvent) => void; export declare class SubAgentManager { private readonly store; private readonly maxConcurrent; private readonly subAgents; private readonly parentToSubs; private readonly subscribers; private cleanupTimer; private readonly completionQueue; private completionWaiterResolve; private readonly pendingPersists; constructor(opts: SubAgentManagerOptions); spawn(opts: SubAgentSpawnOptions): Promise; start(subId: string): Promise; startWithRecheck(subId: string, recheck: SubAgentRecheckFn, maxRetries?: number): Promise; awaitCompletion(subIds: string[], timeoutMs?: number): Promise>; private runEntryToCompletion; private runEntryToCompletionWithRecheck; runToCompletion(subId: string): Promise<{ output: string; error?: string; }>; abort(subId: string): Promise; getSubAgent(subId: string): SubAgentEntry | undefined; listByParent(parentAgentId: string): SubAgentEntry[]; listActiveByParent(parentAgentId: string): SubAgentEntry[]; takeCompletedSubAgents(): SubAgentCompletionNotification[]; waitForAnyCompletion(): { promise: Promise; cancel: () => void; }; subscribe(subId: string, cb: EventSubscriber): () => void; dispose(): Promise; private persistFinalStatus; flushPendingPersists(): Promise; private enqueueCompletion; private countByStatus; private addToParentMap; private removeFromParentMap; private cleanupCompletedEntries; private recoverZombieEntries; private recoverZombie; private findRecordInStore; private handleRuntimeEvent; private emitEvent; private toRecord; getContextSnapshot(subId: string): SubAgentContextSnapshot | undefined; } export {};