import type { Agent } from '../core/agent.js'; import type { AgentFactory } from '../coordination/agent-subagent-runner.js'; import type { DispatchClassifier } from '../coordination/dispatcher.js'; import type { EventBus } from '../kernel/events.js'; import type { Logger } from '../types/logger.js'; import type { JournalEntry } from '../storage/goal-store.js'; import type { Compactor } from '../types/compactor.js'; import { DefaultMultiAgentCoordinator } from '../coordination/multi-agent-coordinator.js'; export type ParallelEngineState = 'idle' | 'running' | 'stopped'; export type ParallelIterationStage = { phase: 'idle'; } | { phase: 'decompose'; } | { phase: 'fanout'; slots: number; } | { phase: 'await'; taskIds: string[]; } | { phase: 'aggregate'; successCount: number; total: number; goalComplete: boolean; } | { phase: 'sleep'; ms: number; } | { phase: 'stopped'; } | { phase: 'error'; message: string; }; export interface ParallelEternalOptions { /** The coordinating agent — NOT a subagent. Owns container/tools/providers. */ agent: Agent; /** Project root (used for goal.json path). */ projectRoot: string; /** * Override the resolved goal.json path. Defaults to * `goalFilePath(projectRoot)` — the canonical per-project goal file under * `~/.wrongstack/projects//`, shared with `/goal` and the TUI. * Primarily for tests that want an isolated goal file under a temp dir. */ goalPath?: string | undefined; /** * Number of parallel subagent slots per tick. * Default: 4. Range 1–16; values >8 are for high-throughput machines. */ parallelSlots?: number | undefined; /** Per-subagent default timeout in ms. Default: 300_000 (5 min). */ iterationTimeoutMs?: number | undefined; onIteration?: (((entry: JournalEntry) => void)) | undefined; onError?: (err: Error | undefined, iteration: number) => void; /** Per-tick phase notifications for live UI/status updates. */ onStage?: (((stage: ParallelIterationStage) => void)) | undefined; gitStatusReader?: ((() => Promise)) | undefined; now?: ((() => Date)) | undefined; compactor?: Compactor | undefined; compactEveryNIterations?: number | undefined; aggressiveCompactRatio?: number | undefined; maxContextTokens?: number | undefined; /** Override the default agent factory (uses main agent if not provided). */ subagentFactory?: AgentFactory | undefined; /** * Route each decomposed slot task to the best-fit catalog agent via the * smart dispatcher (heuristic keyword scoring). When enabled (default), each * slot spawns in-role — the role's budget tier applies and a persona line is * injected into the task — instead of as a faceless generic worker. Set * false to keep the legacy generic spawn. */ dispatch?: boolean | undefined; /** * Optional LLM fallback for ambiguous tasks. Passed straight to * `dispatchAgent`; when omitted, routing is pure heuristic (instant, no * provider call — preferred for a continuously-ticking autonomous loop). */ dispatchClassifier?: DispatchClassifier | undefined; /** Optional EventBus for emitting storage.* observability events from goal I/O. */ events?: EventBus | undefined; /** Logger for structured errors. Falls back to console.error when omitted. */ logger?: Logger | undefined; } /** * Sense → Decide → Fan-out (4–8 parallel agents) → Aggregate → Loop. * * Each tick: * 1. Sense — load goal, todos, git status * 2. Decide — decompose goal into N parallel sub-tasks * 3. Fan-out — spawn N subagents simultaneously, await all * 4. Aggregate — write journal, update todos, check [GOAL_COMPLETE] * 5. Loop — continue until stop() or mission complete * * Uses DefaultMultiAgentCoordinator + AgentSubagentRunner for subagent lifecycle. */ export declare class ParallelEternalEngine { private readonly opts; private state; private stopRequested; private iterationsSinceCompact; private iterations; private consecutiveFailures; private readonly goalPath; private readonly slots; private readonly timeoutMs; private coordinator; private agentFactory; private readonly dispatchEnabled; private readonly dispatchClassifier?; constructor(opts: ParallelEternalOptions); /** * Emit a structured error. Uses the configured Logger when available; * falls back to console.error(JSON) so events are never silently dropped. */ private logError; /** * Load the goal file with structured logging for parse/schema warnings. */ private loadGoal; get currentState(): ParallelEngineState; /** * Get the underlying coordinator for stats/monitoring. */ getCoordinator(): DefaultMultiAgentCoordinator | null; stop(): void; prime(): Promise; run(): Promise; /** * Execute one tick: decompose → fan-out → aggregate → compact. * Called by the REPL in its main loop (REPL drives, engine is stateless per tick). */ runOneIteration(): Promise; private fanOut; private decomposeGoal; private readGitStatus; private brainstormSubtasks; private maybeCompact; private appendIterationEntry; private appendFailure; private persistState; } //# sourceMappingURL=parallel-eternal-engine.d.ts.map