/** * Mission Conductor (#1546). * * A Mission is the cross-stack dynamic-orchestration primitive (naming per * #1536): one durable, audited conductor fans worker cycles out across * *heterogeneous* agentic stacks (Claude ↔ Codex ↔ …) and aggregates results. * In-stack primitives (Claude's Workflow tool, Codex `/goal`) are the in-stack * WORKERS a Mission dispatches to — not substitutes for the conductor. * * This builds on the proven substrate (no new transport): * - `routeMission()` (agent-router.ts) selects an executor by `ExecutorFilter`. * - executors advertise their stack via the `runtime:` capability * (slice-1 convention; see agent-router cross-stack test). * - StackAdapter (stack-adapters.ts) maps a worker cycle onto a stack's * native primitive and supplies the `runtime:` token to filter on. * * RETAINED-OWNERSHIP INVARIANT (non-negotiable, #1537 ADR, cross-stack): * the conductor owns the bookkeeping — activity log, best-output selection, * cost tracking, crash-resilient checkpoint/resume — IDENTICALLY regardless of * which stack each worker ran on. The native primitive drives worker mechanism * only; it never owns gates, durability, or provenance. * * @implements #1546 */ import type { ExecutorRegistration } from './executor-registry.js'; import { StackAdapterRegistry } from './stack-adapters.js'; /** A single worker cycle within a Mission — runs on exactly one stack. */ export interface WorkerCycle { id: string; /** Which stack runs this worker (resolved to a `runtime:` filter). */ runtime: string; /** The worker task the dispatched executor drives via its native primitive. */ prompt: string; /** Additional capabilities the executor must advertise (beyond the runtime). */ requiredCapabilities?: string[]; /** Long-running workers require the `resumable` capability (per ADR §3). */ longRunning?: boolean; } /** A Mission: a goal + measurable completion criterion + worker cycles. */ export interface MissionPlan { missionId: string; goal: string; /** Measurable completion criterion (per the vague-discretion rule). */ completionCriterion: string; cycles: WorkerCycle[]; } /** Outcome of dispatching one worker cycle. */ export interface CycleResult { cycleId: string; runtime: string; primitive: string; executorId?: string; /** True when an executor advertising the cycle's runtime was selected. */ routed: boolean; reason: string; output?: string; /** Runtime-agnostic cost units (e.g. output tokens) for cross-stack aggregation. */ cost: number; } /** * Conductor-side ledger. The retained-ownership invariant means every field * here is populated the same way regardless of which stack ran each worker. */ export interface MissionLedger { missionId: string; goal: string; completionCriterion: string; /** Append-only audit trail (one line per conductor decision/observation). */ activityLog: string[]; cycles: CycleResult[]; /** Cross-stack cost aggregation. */ totalCost: number; /** Best-output selection (REF-015) across the cycles that produced output. */ bestOutput?: { cycleId: string; runtime: string; output: string; score: number; }; /** Crash-resilient checkpoint: which cycles completed vs. remain. */ checkpoint: { completed: string[]; pending: string[]; failed: string[]; }; /** Distinct stacks a worker actually ran on. */ runtimesUsed: string[]; } /** * Runs a single dispatched worker on its selected executor. The real seam to * `aiwg serve`'s dispatch-router + WS event stream plugs in here; tests inject * a fake. The default planner marks the cycle as routed-but-not-executed so the * conductor is honest about what is wired vs. pending the live transport. */ export type RunWorker = (cycle: WorkerCycle, executor: ExecutorRegistration, invocation: { runtimeCapability: string; primitive: string; describe: string; }) => { output?: string; cost?: number; } | Promise<{ output?: string; cost?: number; }>; /** Scores a worker output for best-output selection. Default: output length. */ export type ScoreOutput = (result: CycleResult) => number; export interface ConductorOptions { adapters?: StackAdapterRegistry; /** Worker execution seam (default: plan-only, no execution). */ runWorker?: RunWorker; /** Best-output scorer (default: output length). */ scoreOutput?: ScoreOutput; /** Resume from a prior ledger's checkpoint (skip already-completed cycles). */ resumeFrom?: MissionLedger; } /** * The cross-stack Mission conductor. Decomposes a Mission into worker cycles, * dispatches each to an executor of the chosen runtime via `routeMission`, and * retains all bookkeeping conductor-side regardless of stack. */ export declare class MissionConductor { private adapters; private runWorker; private scoreOutput; constructor(opts?: ConductorOptions); /** * Conduct a Mission across the given executor pool. Returns the ledger. * `resumeFrom` (if given) skips cycles already marked completed — the * crash-resilient resume path; their prior results are carried forward. */ conduct(plan: MissionPlan, pool: ExecutorRegistration[], resumeFrom?: MissionLedger): Promise; } //# sourceMappingURL=mission-conductor.d.ts.map