/** * First-Class Mission Request (2.3.0). * * The immutable declared work contract needed to launch a mission. It is * executor-independent and provider-independent: a request does not mention a * process, a CLI, or a transport. A child mission knows its parent through * explicit structured identity (`parentMissionId` + derived `depth`), never * through PID, prompt text, or ephemeral process state. */ import type { VerificationSpec } from "../reliability/types.js"; /** * Execution mode. Provider/executor-independent. These values intentionally * align with the subagent configuration layer (`SubagentExecutionMode`) without * importing that layer: the domain primitive must not depend on agent config. */ export type MissionExecutionMode = "observe" | "plan" | "execute"; export interface MissionAcceptanceCriterion { /** Stable criterion id, unique within the request. */ id: string; description: string; /** * Deterministic verification for this criterion. When present the criterion * can be satisfied only by authoritative evidence (Reliability Kernel). * When absent the criterion is descriptive and cannot yet be mapped to a * MissionRuntime contract (mapping is rejected explicitly, never fabricated). */ verification?: VerificationSpec; } export interface MissionWorkspaceScope { /** Absolute working directory that bounds the mission. */ cwd: string; /** Optional explicit allowed relative paths (defense in depth). */ allowedPaths?: readonly string[]; } export interface MissionBudget { maxModelTurns?: number; maxToolCalls?: number; maxWallTimeMs?: number; maxInputTokens?: number; maxOutputTokens?: number; maxCostUsd?: number; maxAffectedFiles?: number; } export interface MissionModelPolicy { provider: string; model: string; } export type MissionWorkspaceAccess = "READ_ONLY" | "WRITE"; export type MissionOrchestrationNodeKind = "DIRECT" | "CHILD" | "SYNTHESIS" | "REVIEW" | "VERIFICATION"; export type MissionOrchestrationNodeRequirement = "REQUIRED" | "OPTIONAL" | "VERIFICATION_GATING"; /** Durable provenance for a mission materialized from an orchestration plan. */ export interface MissionOrchestrationMetadata { orchestrationId: string; planRevision: number; nodeId: string; role: string; nodeKind: MissionOrchestrationNodeKind; requirement: MissionOrchestrationNodeRequirement; workspaceAccess: MissionWorkspaceAccess; independenceReason?: string; /** Scheduler-facing dependency criticality derived from the plan DAG. */ dependencyCriticality?: number; priority?: number; verification?: boolean; } /** * Typed parent orchestration execution contract. * * Present only on a mission that OWNS an orchestration plan it must drive to * completion (the parent side; `orchestration` above is the child side). It * is executor-independent and provider-independent, like the rest of the * request: it names the plan identity and the child execution authority, * never a process, a port instance, or a PID. The durable request names the * authority; the runtime (orchestration layer) resolves the name to an * `OrchestrationChildExecutionPort` instance. */ export interface MissionOrchestrationExecution { /** Identity of the orchestration plan this mission owns and must execute. */ orchestrationId: string; /** * Stable identity of the child execution authority for this orchestration. * Required: a parent orchestration execution without a named child * execution authority is rejected, never defaulted. */ childExecutionAuthority: string; } export interface MissionRequest { /** Stable canonical mission identity. Never derived from PID. */ readonly missionId: string; /** Explicit structured parent identity; absent only for a root mission. */ readonly parentMissionId?: string; /** Structural recursion depth: 0 for root, parentDepth + 1 for a child. */ readonly depth: number; /** Declared objective (work contract). */ readonly objective: string; /** Canonical agent/role policy reference (e.g. "worker", "cavecrew-builder"). */ readonly agent: string; readonly executionMode: MissionExecutionMode; /** Acceptance criteria. Required for a governed mission. */ readonly acceptanceCriteria: readonly MissionAcceptanceCriterion[]; readonly workspaceScope?: MissionWorkspaceScope; readonly budget?: MissionBudget; readonly capabilities?: readonly string[]; readonly modelPolicy?: MissionModelPolicy; /** * Optional idempotency/deduplication identity. When present it is a stable * caller-supplied key independent of the generated `missionId`. */ readonly idempotencyKey?: string; /** * Durable child AgentSession identity. Allocated BEFORE external execution * and immutable for the life of the mission. A delegated child mission binds * to exactly one AgentSession; explicit resume restores this exact session * rather than allocating a replacement. Never PID-derived. */ readonly childSessionId?: string; /** * Inherited operational constraints (parent + user policy). Durable so an * interrupted + resumed child retains its guardrails without reconstructing * them from prompt prose. */ readonly constraints?: readonly string[]; /** Immutable reference/context package for the mission. */ readonly context?: Readonly>; /** Orchestration metadata for a child mission; execution remains owned by Mission/Scheduler. */ readonly orchestration?: MissionOrchestrationMetadata; /** * Typed parent orchestration execution contract. Present only on a mission * that owns an orchestration plan it must drive; names the plan identity * and the child execution authority. Absent for children and for missions * without orchestration. */ readonly orchestrationExecution?: MissionOrchestrationExecution; readonly createdAtMs: number; } export interface CreateMissionRequestInput { missionId?: string; /** Parent identity used to derive `parentMissionId` and `depth` structurally. */ parent?: { missionId: string; depth: number; }; objective: string; agent: string; executionMode: MissionExecutionMode; acceptanceCriteria: readonly MissionAcceptanceCriterion[]; workspaceScope?: MissionWorkspaceScope; budget?: MissionBudget; capabilities?: readonly string[]; modelPolicy?: MissionModelPolicy; idempotencyKey?: string; childSessionId?: string; constraints?: readonly string[]; context?: Readonly>; orchestration?: MissionOrchestrationMetadata; orchestrationExecution?: MissionOrchestrationExecution; /** Timestamp override for deterministic construction (defaults to now). */ now?: number; } /** * Build a canonical MissionRequest. If no `missionId` is supplied a stable * UUID-based id is generated (never PID-derived). Depth is derived from the * parent's depth so parenthood cannot be forged independently of depth. */ export declare function createMissionRequest(input: CreateMissionRequestInput): MissionRequest; /** Stable canonical mission id. UUID-based, never PID-derived. */ export declare function newMissionId(): string; /** Stable durable child AgentSession id. UUID-based, never PID-derived. */ export declare function newChildSessionId(): string; /** A child session id is an opaque path-safe identity (used as a session header id). */ export declare function isSafeChildSessionId(value: string): boolean; export type MissionRequestValidationError = "MISSING_MISSION_ID" | "UNTRIMMED_MISSION_ID" | "NEGATIVE_DEPTH" | "PARENT_WITHOUT_DEPTH" | "ROOT_DEPTH_MISMATCH" | "MISSING_OBJECTIVE" | "MISSING_AGENT" | "INVALID_EXECUTION_MODE" | "DUPLICATE_CRITERION_ID" | "UNSAFE_CHILD_SESSION_ID" | "INVALID_CONSTRAINTS" | "INVALID_ORCHESTRATION_METADATA" | "INVALID_ORCHESTRATION_EXECUTION"; export type MissionRequestValidationResult = { valid: true; request: MissionRequest; } | { valid: false; errors: MissionRequestValidationError[]; }; /** * Validate a MissionRequest against the domain invariants. Rejects malformed * requests explicitly; never derives identity from anything except structured * fields. */ export declare function validateMissionRequest(request: MissionRequest): MissionRequestValidationResult; //# sourceMappingURL=mission-request.d.ts.map