import type { GovernanceService } from "../governance/service.js"; import { type DurableMissionRecord, type DurableMissionStore } from "../mission-domain/durable-store.js"; import type { LocalSubagentRuntime } from "../shared-inference/runtime.js"; import { type ParentOrchestrationExecution, type ParentOrchestrationExecutionOptions } from "./parent-execution.js"; import type { OrchestrationStore } from "./types.js"; import { type OrchestrationChildExecutionPort, type OrchestrationJoinResult, type OrchestrationPlan, type OrchestrationPlanner, type OrchestrationPlanProposal, type OrchestrationProposalInput, type OrchestrationStatus, type OrchestrationValidationResult } from "./types.js"; export interface OrchestratorOptions { store: OrchestrationStore; missions: DurableMissionStore; logicalRuntime?: LocalSubagentRuntime; sessionDir?: string; now?: () => number; orchestrationIdFactory?: () => string; maxDepth?: number; maxChildrenPerNode?: number; maxTotalLogicalAgents?: number; maxReplans?: number; /** * Explicit operator agent names accepted by plan validation on top of the * canonical subagent registry. Takes precedence over any roster a planner * exposes through `allowedAgents()`. */ operatorAgents?: readonly string[]; /** * Planner for the automatic start/preview path. Default: * `createQwenPlanner()` (the local Qwen planner). Inject a mocked planner * or a planner with a deterministic stream seam in tests. */ planner?: OrchestrationPlanner; /** * Child execution authority port. It is exposed through the * `childExecutionPort` seam and reused by automatic execution when no * explicit execution port is supplied. */ childExecutionPort?: OrchestrationChildExecutionPort; governance?: GovernanceService; } export interface CreateOrchestrationOptions { parentMissionId: string; proposal: OrchestrationPlanProposal; parentDepth?: number; rationale?: string; /** Per-call operator agent set; overrides the service-level option. */ operatorAgents?: readonly string[]; } export interface OrchestrationPreview { plan?: OrchestrationPlan; validation: OrchestrationValidationResult; issues: unknown[]; } export interface OrchestrationReconcileResult { status: OrchestrationStatus; materializedMissionIds: string[]; unblockedNodeIds: string[]; } /** Result of an automatic start: the created plan plus the materialization. */ export interface AutomaticStartResult extends OrchestrationReconcileResult { plan: OrchestrationPlan; } /** * Options for `startAutomatic`. `childExecutionAuthority` names the child * execution authority that will drive the created plan: when present, the * parent mission's durable request is updated (atomically) to carry the * `orchestrationExecution` contract BEFORE the result is returned. When * absent the status quo holds: children are materialized but no parent * execution contract is persisted. */ export interface StartAutomaticOptions { /** * Named child execution authority persisted on the parent's durable * request as `orchestrationExecution.childExecutionAuthority`. Verified, * never defaulted: an empty/whitespace name is rejected. */ childExecutionAuthority?: string; } export interface AutomaticExecuteOptions extends StartAutomaticOptions { /** Existing parent execution stack. When omitted, `executionOptions` builds one. */ execution?: ParentOrchestrationExecution; /** Production factory inputs used when `execution` is omitted. */ executionOptions?: Omit; /** Coordinator resume options, including an optional cancellation signal. */ resumeOptions?: { signal?: AbortSignal; }; } export declare class OrchestratorService { private readonly _store; private readonly _missions; private readonly _runtime?; private readonly _sessionDir?; private readonly _now; private readonly _idFactory; private readonly _operatorAgents?; private readonly _planner?; private readonly _childExecutionPort?; private readonly _governance?; private readonly _limits; constructor(options: OrchestratorOptions); /** * Access seam for the child execution authority port. * * Returns the port configured for this orchestrator, when present. The * parent lifecycle executor — never materialization — owns child launch. */ get childExecutionPort(): OrchestrationChildExecutionPort | undefined; /** * Resolve the effective operator agent set for plan validation: an * explicit per-call override, then the service-level option, then the * roster exposed by the planner (when any). The canonical subagent * registry remains the primary authority in all cases. */ private effectiveOperatorAgents; preview(input: CreateOrchestrationOptions): Promise; create(input: CreateOrchestrationOptions): Promise; createFromPlanner(input: OrchestrationProposalInput, planner: OrchestrationPlanner): Promise; /** * Automatic orchestration start. Loads the parent mission's objective and * constraints, asks the planner (default: `createQwenPlanner()`) to * propose a plan with bounded replans, creates it, and materializes the * ready child nodes. Children are never launched here; execution remains * owned by Mission/Scheduler. The explicit proposal API (`preview` / * `create`) remains the operator's debug override. * * When `options.childExecutionAuthority` is provided, the parent mission's * durable request is atomically updated (DurableMissionStore `mutate`) to * carry the `orchestrationExecution` contract naming this plan and that * authority, BEFORE the result is returned. The returned plan is reloaded * after materialization so it reflects persisted node state. */ startAutomatic(parentMissionId: string, options?: StartAutomaticOptions): Promise; /** * Plan, materialize, and explicitly resume the durable parent mission through * the existing coordinator. The parent request contract is attached before * `resume`, and no execution stack is constructed unless requested. */ startAutomaticAndExecute(parentMissionId: string, options: AutomaticExecuteOptions): Promise; /** * Persist the parent orchestration execution contract on the parent * mission's durable request: atomically (DurableMissionStore `mutate`) * update `request.orchestrationExecution` to name `orchestrationId` and * `childExecutionAuthority`. * * Verified, never defaulted, never overwritten: * - `CHILD_EXECUTION_AUTHORITY_REQUIRED` — empty/whitespace authority * - `PARENT_MISSION_NOT_FOUND` / `PARENT_MISSION_CORRUPT` * - `PARENT_ALREADY_OWNS_ORCHESTRATION` — the parent already carries a * DIFFERENT contract (re-attaching the identical contract is * idempotent and writes nothing) * - `PARENT_MISSION_TERMINAL` — a terminal parent cannot own an * executable orchestration * * The contract is declarative: this writes no plan state and never * launches anything. The parent lifecycle executor resolves the named * authority later, at execution time. */ attachOrchestrationExecution(parentMissionId: string, orchestrationId: string, childExecutionAuthority: string): Promise; /** * Automatic orchestration preview. A single bounded planner probe (no * replans, nothing persisted) reporting the plan `startAutomatic` would * create for the parent mission. */ previewAutomatic(parentMissionId: string): Promise; private buildPlan; materializeReady(orchestrationId: string): Promise; private materializeReadyDocument; private materializeNode; private planState; reconcile(orchestrationId: string): Promise; status(orchestrationId: string): Promise; private statusFromDocument; join(orchestrationId: string): Promise; cancel(orchestrationId: string): Promise; private saveDocument; private loadDocument; private loadMission; private loadOptionalMission; } //# sourceMappingURL=orchestrator.d.ts.map