/** * In-Process Mission Executor (2.16.0). * * The real, in-process executor for the first-class mission contract. Where * `ProcessMissionExecutor` is the transitional adapter that drives a spawned * CLI, this executor drives a mission through the normal `createAgentSession()` * session path: a real agent session with a real model (e.g. the local Qwen * operator model), real tools, and the normal session stream. No child * process, no PID: the mission's structured identity (`missionId` + * `childSessionId`) is the only identity involved. * * Contract (same invariants as the rest of the domain): * - A clean completion is NEVER classified SUCCEEDED without a verifier. * Without one it is PARTIAL ("execution completed but unverified"). * - The handle exposes `executionId` and `cancel`, never an AgentSession. * - `cancel` is idempotent and aborts the underlying session. * * Real-path configuration mirrors `QwenPlannerAdapter` (cwd/agentDir/auth/ * registry/stream seams). The model is resolved from * `MissionRequest.modelPolicy` — verified, never defaulted: a mission without * a model policy, or whose policy is not registered, is a hard error. Tools * follow the execution mode (`execute` → coding tools, otherwise read-only * tools) and are narrowed by `MissionRequest.capabilities` when present. * * A `runner` seam replaces the whole session path for deterministic tests, * mirroring the `harness` seam of `ProcessMissionExecutor`. */ import type { StreamFn } from "@apholdings/jensen-agent-core"; import { AuthStorage } from "../auth-storage.js"; import type { GovernanceService } from "../governance/service.js"; import { ModelRegistry } from "../model-registry.js"; import { SessionManager } from "../session-manager.js"; import type { MissionExecutor, MissionLaunchOptions } from "./mission-executor.js"; import { type MissionHandle } from "./mission-handle.js"; import { type MissionRequest } from "./mission-request.js"; import { type ExecutorOutcome, type MissionResult } from "./mission-result.js"; /** * Plain-data outcome of one in-process session run. Mirrors * `ExecutorOutcome` (no session object leaks) and adds presentation text and * the session-level error message. */ export interface InProcessMissionOutcome extends ExecutorOutcome { /** Final assistant text (presentation only, never the authority). */ outputText?: string; /** Session-level error message when the run failed. */ sessionError?: string; } /** * Executes one mission in-process and resolves to its plain-data outcome. * The default runner drives a real agent session; tests may inject a * deterministic runner. */ export type InProcessMissionRunner = (request: MissionRequest, signal?: AbortSignal, executionId?: string, correlation?: { assignmentId?: string; sessionId?: string; }) => Promise; export interface InProcessMissionVerifierInput { request: MissionRequest; outcome: InProcessMissionOutcome; } export interface InProcessMissionVerification { verified: boolean; summary?: string; criterionIds?: string[]; } /** Optional verifier that may promote a clean completion to verified SUCCEEDED. */ export type InProcessMissionVerifier = (input: InProcessMissionVerifierInput) => Promise; /** * Deterministic execution prompt for a mission: identity, objective, * constraints, and acceptance criteria. Never PID- or process-derived. */ export declare function buildInProcessMissionPrompt(request: MissionRequest): string; /** * Build the default runner: real agent session over the normal * `createAgentSession()` path. The model comes from `MissionRequest.modelPolicy` * (verified, never defaulted); the session is bound to the mission's durable * `childSessionId` when present (explicit resume restores that exact session). */ export declare function createInProcessMissionRunner(options: { cwd?: string; agentDir?: string; authStorage?: AuthStorage; modelRegistry?: ModelRegistry; sessionDir?: string; /** Existing durable session resolved by the worker for this child. */ sessionManager?: SessionManager; streamFn?: StreamFn; /** Durable Governance observer for actual model transitions. */ governance?: GovernanceService; }): InProcessMissionRunner; export interface InProcessMissionExecutorOptions { executorId?: string; /** Deterministic seam replacing the whole session path (mirrors the process executor's harness). */ runner?: InProcessMissionRunner; /** Optional verifier that may promote a clean completion to SUCCEEDED. */ verifier?: InProcessMissionVerifier; /** Execution id factory (default: UUID). Never a process id. */ executionIdFactory?: (request: MissionRequest) => string; /** Working directory default for the real session path. Default: process.cwd() */ cwd?: string; /** Global config directory for the real session path. Default: getAgentDir() */ agentDir?: string; /** Auth storage for the real session path. Default: AuthStorage.create(agentDir/auth.json) */ authStorage?: AuthStorage; /** Model registry for the real session path. Default: new ModelRegistry(authStorage, agentDir/models.json) */ modelRegistry?: ModelRegistry; /** Session dir for durable child sessions. Default: defaultChildSessionDir(agentDir) */ sessionDir?: string; /** Existing durable session resolved by the worker for this child. */ sessionManager?: SessionManager; /** Stream seam for the real session path (default: normal provider stream). */ streamFn?: StreamFn; } export declare class InProcessMissionExecutor implements MissionExecutor { readonly executorId: string; private readonly _runner; private readonly _verifier?; private readonly _executionIdFactory; private readonly _active; constructor(options?: InProcessMissionExecutorOptions); launch(request: MissionRequest, options?: MissionLaunchOptions): Promise; awaitResult(handle: MissionHandle): Promise; cancel(handle: MissionHandle, reason?: string): Promise; private _run; private _cancelActive; private _classify; } /** Build an `InProcessMissionExecutor`. */ export declare function createInProcessMissionExecutor(options?: InProcessMissionExecutorOptions): InProcessMissionExecutor; //# sourceMappingURL=in-process-mission-executor.d.ts.map