/**
 * The task INPUT surface: `TaskSpec` — everything a caller hands `runTask` — plus the two shapes that
 * exist only as one of its fields (`ImageInput`, `StaleToolResultOffloadOptions`). The limits live
 * beside it in `task-limits.ts`; the terminal record it produces in `task-result.ts`. Layer 0
 * vocabulary; `types.ts` re-exports the three, so no consumer's import changes.
 */
import type { PermissionMode } from "./ask-origin.js";
import type { TSchema } from "typebox";
import type { ThinkingLevel } from "../internal/harness.js";
import type { ActorAssertion, Model, ResilienceOptions } from "../internal/llm.js";
import type { AgentDefinition, SkillSpec } from "./agent-definition.js";
import type { A2aServerSpec, McpServerSpec } from "./mcp-server-spec.js";
import type { ModelRef, ModelRole, ModelRoles } from "./model-seat.js";
import type { TaskLimits } from "./task-limits.js";
import type { ToolSpec } from "./tool-spec.js";
import type { WorkspaceDeclaration } from "./session-checkout.js";
import type { TaskSandboxSettings } from "./command-sandbox.js";
import type { ProjectSeat } from "./project-seat.js";
/** design/169-F — knobs for the opt-in stale tool-result offload (see
 *  `TaskSpec.compaction.staleToolResultOffload`, where the semantics are documented). */
export interface StaleToolResultOffloadOptions {
    /** How many most-recent results PER TOOL NAME stay verbatim in the request. Default 3. */
    keepRecentPerTool?: number;
    /** Minimum chars a replacement must save (raw text − pointer text) to happen. Default 2000. */
    minSavingsChars?: number;
}
/** An image attached to the task's user message: either inline base64 or a URL to fetch. */
export type ImageInput = {
    /** Base64-encoded image bytes (no data: prefix). */
    data: string;
    /** MIME type, e.g. "image/png" / "image/jpeg". */
    mimeType: string;
} | {
    /** URL the runner will fetch and inline as base64 before sending to the model. */
    url: string;
};
/**
 * One file the user attached to the objective, by WHO HOLDS ITS BYTES (never by what kind of file it is — the engine
 * finds that out and reports it):
 *  - `{ path, lines? }` — a file or directory the engine can reach in its workspace: the engine reads it through the
 *    Read tool's own read and admission (read-deny table, roots, the run's deny rules), as if the model had read it,
 *    minus the questions — the user's declaration is the answer to an ordinary ask; a read some layer would put to a
 *    person other than the asker (an organization rule, a deployment-authored or real-approval ask) is not attached.
 *    `lines` reads a line range (1-based, `end` inclusive).
 *  - `{ name, text, startLine? }` — text the host holds (a local file a remote engine cannot reach, an unsaved buffer):
 *    delivered as given, line-numbered from `startLine` (default 1). It opens nothing an objective could not carry,
 *    and records no read state.
 *  - `{ name, image: { data, mimeType } }` — an image file the host holds (base64), admitted like an image the Read tool
 *    serves.
 * Each attachment reaches the model as its own message right after the objective, marked as the engine's: two
 * marked sentences around the data, the name or path only in the data. See `USER_ATTACHMENT_SEAT` for the limits.
 */
export type UserAttachment = {
    readonly path: string;
    readonly lines?: {
        readonly start: number;
        readonly end?: number;
    };
} | {
    readonly name: string;
    readonly text: string;
    readonly startLine?: number;
} | {
    readonly name: string;
    readonly image: {
        readonly data: string;
        readonly mimeType: string;
    };
};
/**
 * The instruction-file family of a directory ({@link TaskSpec.instructionFamily}) — what the engine loads for each directory between the
 * task root and a file the run accessed. Names only: the engine joins each to the directory, reads it through the hands under the Read
 * tool's admission (a file the model could not Read is not loaded, and the user is told), and holds no list of names of its own. The deployment's own naming convention fills it.
 *
 *  - `files` — the file names each level is read for, relative and `/`-separated (`CLAUDE.md`, `.claude/CLAUDE.md`, …).
 *  - `localFiles` — the user's private names (`CLAUDE.local.md`), the law of `files`: read at each level whichever family is active — after the level's names below the task root, after its rules directories at a root's own level — and never counted by `alternate`'s condition; its frames say the text is user-private, its includes go as any file's.
 *  - `rulesDirs` — the directories each level is listed under (recursively, `.md` files), every one, in the order written (the names' law of `files`; the retired `rulesDir` is refused, `config.spec_retired_key`):
 *    a rule whose frontmatter names `paths:` is loaded when the accessed path matches one (relative to that level), a rule without is loaded with its level, the task root's included;
 *    a rule file that really lies (links followed) outside both the root it was found under and the task root is not read (unless `externalIncludes` approves it).
 *  - `alternate` — a second family (`files`, `rulesDirs`): `when: "absent"` reads it only where the task root holds no member of `files` (judged once per leg), `"also"` reads it beside `files`.
 *  - `includes` — follow a file's `@path` includes, each read only where it really lies (links followed) inside the root the including file is read under or the task root (unless `externalIncludes` approves it), to a depth of {@link NESTED_MEMORY_LANE}'s limit.
 *  - `externalIncludes` — the project's approvals of instruction files outside those roots, one per file: the absolute paths approved, each a value of the engine's own `instructions.withheld` notice (`outside_its_root`) sent back as it came — its `detail.target` (where the file really lies: the approval is bound to that file) or its `detail.path` (the path the lane found it by: the approval is bound to the path, and a link later pointed at another file outside takes it there). Three host states, two engine readings: a list = the host holds the person's approval of these files; `false` = the host holds the person's explicit "no"; absent = the host says nothing (its record cannot be read, or an older host). The engine reads `false`, an empty list and absent the same way — nothing approved, the reading without the member (a found file outside is not read and the person is told) — because it can only fail closed. A file the lane finds by itself (a rules directory's, an include's) that really lies outside the root it was found under and the task root is approved when its key is the key a listed path resolves to — both through the engine's one resolution (links followed, the volume's own spelling): any spelling of that file approves it, a path that names another file (or none) approves nothing, and the file stays withheld and told (once per (path, reason, target) per session; send its `detail.target`). Approved, it is no longer withheld as `outside_its_root`: it is judged as the model's own Read of it (the read face's roots, the read rules and the admission still apply: a file those refuse is told as `outside_roots` / `rule_denied` / …) and the include depth bound is unchanged; a file the list does not approve is read as without the member. `true` is refused (no approval covers every file), as is anything else not `false` or a list, an entry that is not a string, and an entry of up to 4096 characters that is not an absolute path in the family its spelling names (`isAbsoluteForFamily`: a relative path, `~/`, empty) or holds a NUL (every value the engine itself tells is taken: a `..` segment, a posix name holding a backslash); past its shape, the entries after the first 32 (`NESTED_MEMORY_LANE.limits.maxApprovedPaths`) and an entry over 4096 characters (`maxApprovedPathChars`; whatever it holds — it is not read) are not read as approvals, and the operator is told once. The HOST sets it per request, from the person's own answers: the engine keeps no approval of its own. The family is read when a request is prepared, so an approval takes effect from the NEXT request (a new run) — never mid-run; a run that was told `outside_its_root` keeps its reading until it ends. It has no effect where the family holds no `includes` and no rules directory (the approval is the user's, the family the deployment's: the two are independent, not contradictory).
 *  - `additionalDirectories` — `true` also reads each {@link TaskSpec.additionalDirectories} entry as a further root: its own level on every leg as the task root's is (after it), for `files` and `rulesDirs` — no level below it, no `alternate`, and a rule with `paths:` there only for an accessed path below the task root. Omitted / `false` ⇒ not read (the reference's default; its opt-in `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD`).
 *  - `hostRules` — instruction texts the HOST holds and the hands cannot read (`level`: `user` the user's own, `managed` the organization's, `project` a directory above the task root's, `local` a private one there), each the text as on disk: read as a file's text is (frontmatter and comments dropped, includes from a text whose `name` is an absolute path, judged by `isAbsoluteHostPath` — anything else is a label whose includes are told, never followed), delivered on every load ahead of the task root's members on every leg (one with no hands included), or — `rule: true` with frontmatter `paths:` — when an accessed path matches; one the host stops supplying is withdrawn once. Only a value of the wrong shape refuses: past the first 20, a repeated name, a name over 4096 characters, a text over the read bound or a name that resolves to a file the lane holds (a member, a file one includes) is not delivered, and told. The retired `paths` member is refused (`config.spec_retired_key`).
 *
 * A file is loaded once and again only when it changed or left the model's view (a compaction, a trim). Every value is judged at the door: a bad one refuses the task (`config.invalid_argument`), never folds to a default.
 */
export interface InstructionFamilyDeclaration {
    readonly files?: readonly string[];
    readonly rulesDirs?: readonly string[];
    readonly alternate?: {
        readonly files: readonly string[];
        readonly rulesDirs?: readonly string[];
        readonly when: "absent" | "also";
    };
    readonly localFiles?: readonly string[];
    readonly includes?: boolean;
    readonly additionalDirectories?: boolean;
    readonly externalIncludes?: false | readonly string[];
    readonly hostRules?: ReadonlyArray<{
        readonly level: import("./runner/nested-memory-lane.js").HostTextLevel;
        readonly name: string;
        readonly text: string;
        readonly rule?: boolean;
    }>;
}
/** A single self-contained task with its full configuration. */
/** The shell-gate FLOOR vocabulary — {@link TaskSpec.shellGate}'s value set, the word the engine persists on a
 *  shell-gated ask (`RiskDescriptor.shellGateDoctrine`) and carries down a delegation chain. One value: `"always"`
 *  (every shell command is confirmed, under every permission mode — an operator's mandate). The shape tier itself
 *  is installed on every full shell regardless; what a permission mode does with the resulting ask is the gate's
 *  arbitration, never a doctrine word. */
export type ShellGateDoctrine = "always";
/** {@link TaskSpec.wake}'s value set: what a wake leg opens on. One value: `"parked_notifications"` — the task notifications
 *  parked for this session's occupant while it sat idle (the durable box's included). */
export declare const TASK_WAKE_SOURCES: readonly ["parked_notifications"];
export type TaskWakeSource = (typeof TASK_WAKE_SOURCES)[number];
/** A task's durable-park opt-in ({@link TaskSpec.durableApproval}'s object state). */
export interface DurableApprovalOptIn {
    /** Multi-tenant isolation key, forced into the checkpoint + `resolve`/`reap` WHERE. Required. */
    scope: string;
    /** Optional awaiting-human TTL (ms). Past it a reaper CAS-expires the checkpoint (≈ deny). Absent, or a finite number >= 0 — any other
     *  value (NaN, Infinity, a negative, a string) is refused at the task door (`config.invalid_argument`, `detail.field` `durableApproval.ttlMs`),
     *  the judge `resourceSuspend`'s numbers are judged by. */
    ttlMs?: number;
}
export interface TaskSpec {
    taskId?: string;
    /** The instruction / latest user message for this turn. */
    objective: string;
    /**
     * A **wake leg**: the leg brings no input of its own and opens on what the session already holds for it —
     * `"parked_notifications"`, the task notifications parked for this session's occupant while it sat idle (the durable box's
     * included), each handed to the model once, as the frame it is (one `<task-notification>` block per frame; the host writes no
     * copy of it). A leg opens on exactly one input: an instruction ({@link objective}), a resumed row (a checkpoint resume), or
     * this. So a wake leg carries no instruction (`objective` blank), no `images` and no `userAttachments`, and is never a resume;
     * a blank objective is never read as a wake — the leg names it. When nothing is handed over at turn open (nothing was parked,
     * or the session's receiving station consumed it all) the run ends `config.nothing_to_wake` before any model request.
     *
     * Lives and dies with the session ({@link sessionId}): a run handed a new session of its own has nothing parked.
     */
    wake?: TaskWakeSource;
    /**
     * Authenticated **end-user principal** this task runs on behalf of (design/62) — an opaque identity string
     * (user id, email, tenant-scoped subject) the **trusted caller** sets at task creation. The Runner holds it
     * for the whole run and injects it into MCP requests for any server with a `principalHeader`
     * ({@link McpServerSpec}), enabling per-user RBAC in the MCP server. Delegated child tasks (sub-agent / team /
     * fan-out) inherit it.
     *
     * 🔴 **Trust contract (design/53 — authority stays in the control plane):** this is a control-plane value,
     * **NOT model/worker input.** Set it only from the authenticated task-submission context; it is not exposed
     * as a tool argument and the model cannot read or change it (a worker filling its own principal = a privilege
     * circumvention). Treat it as write-once for the run. The MCP server MUST trust this header only on the Runner's
     * authenticated/TLS channel and default to deny/public when it is absent — never default-admin.
     *
     * 🔴🔴 **This is the GOVERNANCE key.** Per-principal entitlements are resolved off this value:
     * {@link RunnerDeps.runtimeCapsResolver}`(spec.principal)` decides `allowWorkflows` (and thus whether
     * self-orchestration / `RunWorkflow` is permitted). So a caller MUST set `spec.principal` to a
     * **cryptographically VERIFIED** identity — **never a raw, spoofable request header**. A deployment that holds
     * both an unverified header value AND a verified one (e.g. a "direct-door" path) MUST pass the VERIFIED one
     * here: keying a gate on a spoofable principal is a multi-tenant governance BYPASS (a caller-declared header would
     * inherit another tenant's entitlements). Core cannot verify identity itself (no crypto context) — it trusts
     * this value by contract; getting it wrong is a privilege-escalation hole, not a core bug.
     */
    principal?: string;
    /**
     * The ISOLATION SCOPE this task's working state is keyed under, when it is not the {@link principal} — an opaque name the
     * **trusted caller** sets beside the principal (the same trust contract: a control-plane value, never model / worker input). One
     * person working in several separated scopes is ONE principal and several isolation scopes.
     *
     * The principal stays the person: governance windows, outbound identity (MCP principal header, A2A identity), entitlements
     * (`runtimeCapsResolver`, compliance posture), rule ownership, memory admission and attribution read it. The isolation scope keys
     * the state that belongs to one scope of that person's work: the task registry domain this run's registry-facing tools mount in,
     * the offloaded tool-result namespace, the durable-suspend checkpoint scope (its last rung), the scheduler's session-leg fallback
     * and durable key, the delegation tree's domain, and the MCP connection a run tree shares. Every one of those reads it through ONE
     * accessor: this member, else the principal — so a task that leaves it unset (or sets the empty string, absence wearing clothes,
     * the principal's own discipline) keys every one of them exactly as before.
     *
     * Judged by the principal's own name rule (absent, or a name — at most 256 UTF-16 units; a provided value that names nothing is refused
     * `config.invalid_argument`). Delegated children inherit it like the principal. When it is set, `durableApproval.scope` and
     * `resourceSuspend.scope` must equal it (a different value would file one scope's parked rows under another) — refused
     * `config.invalid_argument` otherwise. A parked row whose isolation scope differs from its principal records it
     * ({@link import("./checkpoint-store.js").Checkpoint.isolationScope}); a resume that names a different one is refused
     * (`resume.isolation_scope_mismatch`), one that names none inherits the recorded one.
     *
     * The engine never parses either value: a host that receives a person and a scope on separate inputs splits them into these two
     * members once, at its own entrance.
     */
    isolationScope?: string;
    /**
     * design/171 §6.4 — WHO opened this turn (the thread's first-post author in a shared session):
     * the CANONICAL attribution seat for the objective. Rendered as the speaker envelope on the first
     * user message (single projection point) and persisted as `UserMessage.actor`; absent = anonymous
     * (every single-user host — the model-facing bytes are then unchanged).
     *
     * Attribution ONLY, never authority: permission/approval/scope decisions key on
     * {@link TaskSpec.principal}, never on this (the normative clause on {@link ActorAssertion}).
     * Relationship to `clientContext.userEmail`: that field keeps its environment-facts role (an
     * UNVERIFIED display string in the env block) and carries no attribution duty — this seat is the
     * honest one, because `hostAsserted` states whether the identity was ingress-derived.
     */
    actor?: ActorAssertion;
    /**
     * What started this task, when the host says so ({@link import("./run-origin.js").RunOrigin}): `"scheduled"` = the
     * deployment's scheduler (cron, heartbeat, delayed wake-up, stored routine) fired an intent stored earlier — nobody submitted
     * it just now. Absent = the host said nothing (never read as "a person sent it"). Attribution only, exactly like
     * {@link actor}: no permission, approval, mode or scope decision reads it, and it never enters the model's context.
     *
     * It is the word of the objective, the input that opens the task's first leg: that leg's `wiring_manifest` reports it
     * (`leg.runOrigin`), the objective's `human_input` frame and its message carry it, and a checkpoint the leg parks records it
     * (`CheckpointSummary.runOrigin`). A resumed leg continues the row's word unless a wake opens it (with the newest input the
     * wake hands over, which states its own); a resume config carries NO word — any value is refused, before the claim. A
     * delegated child does not inherit it. A value outside the set is refused at the door (`config.run_origin_invalid`).
     *
     * 🔴 Trust contract: set it ONLY at the deployment's own scheduler fire path — never copy it from a request body, or any
     * caller can mark its run as scheduled and the audit face reads the claim as the host's. The engine cannot verify it.
     */
    runOrigin?: import("./run-origin.js").RunOrigin;
    /**
     * design/173 §3/§8.3 — the caller's DECLARED interaction posture for this run. `"interactive"`
     * asserts a live human is reachable and makes prepare REFUSE the leg (fail-loud
     * `config.interaction_posture`) when the assembly cannot deliver on it: it requires the resolved
     * permission-ask seat to be a live approver callback (`ask.effective === "human_reachable"` — a
     * blanket allow/deny, an approver the deployment declared a policy (`asPolicyApprover`) or an absent
     * seat fails the door) AND a content-question channel (a resolved
     * `onQuestion` face, OR the engine's own `stripped_bg_lane` legs — core's deliberate strip of a
     * long-lived child's per-request face is correct design, not a configuration lie, so those legs
     * are exempt). The park lane is deliberately NOT required (interactive-without-park is a
     * legitimate light deployment — a synchronous CLI/local UI). `"headless"` declares the opposite
     * and checks nothing (a batch deployment carrying an onAsk for audit is legal). Absent = no check, bytes unchanged.
     *
     * Seat resolution is THREE-leg: `spec.interactionPosture ?? <the spawning run's resolved posture>
     * ?? deps.interactionPosture` — a Runner serving both an interactive session and cron/batch legs
     * declares at deps level and overrides per spec, while a delegated child inherits the posture its
     * SPAWNER resolved (carried on trusted engine internals, never copied onto the child's spec). The
     * middle leg is load-bearing: without it a root that overrode a deps-level "interactive" with
     * "headless" spawned children that fell back to the deps default and were refused at their own door.
     * TRUST BOUNDARY (§8.3): only the HOST-authored spec carries this (spec is the deployment-face
     * input in this library's trust model); the engine never copies it onto the child specs it
     * constructs (a child's lane is the engine's decision — the strip flag is its expression), and a
     * RESUME leg re-resolves posture from the CURRENT deps/taskConfig — never from the checkpoint.
     * This door is an HONESTY gate, not a security gate.
     *
     * Runtime side (design/173 §8.2): under `"interactive"` BOTH no-answer arms of a WIRED question
     * channel harden into coded tool failures instead of the silent synthetic self-answer continuation —
     * a channel that THROWS returns `question.human_channel_failed`, and one that honestly reports nobody
     * reachable returns `question.human_unavailable`. See {@link interactiveQuestionFallback} for the
     * explicit opt-out, which covers both arms.
     */
    interactionPosture?: "interactive" | "headless";
    /**
     * The run's declaration that NOBODY on it can be asked to approve a call — read by the approval seat's one resolution
     * ({@link import("./wiring-manifest.js").resolveAskSeat}). `"none"`: a person's approver callback the spec or the deployment
     * wires is not this run's approver (never called; the manifest reports `ask.form: "declared_none"`); with the deployment's park
     * facility armed an ask parks for a person to answer later (`park_only`), without one it is refused as nobody's — except on a workflow member whose seat resolves to `declared_none`, whose permission asks nobody on its chain answers (irreversible, or held by `forceDurableGate`, included) never park and settle as with no park lane, its questions and resource yields still parking ({@link import("./wiring-manifest.js").approvalParkWithheldOf}). It
     * approves and releases nothing; a blanket `"allow"` / `"deny"` seat stays a policy, and so does an approver the deployment
     * declared a policy (`asPolicyApprover`: kept and asked, `ask.form: "policy_callback"`); under `dontAsk` the mode refuses
     * first. Absent = today's reading. Not checkpointed (a resumed leg holds it only when its taskConfig supplies it again);
     * children inherit it (the clamp seats). `interactionPosture: "interactive"` beside it is refused
     * (`config.interaction_posture`); a value outside the closed set too (`config.approval_reach_invalid`). Independent of
     * {@link interactiveTools} — a content question still goes to `onQuestion`.
     */
    approvalReach?: import("./wiring-manifest.js").ApprovalReach;
    /**
     * design/173 §8.2 — the EXPLICIT knob (default off) letting a posture-`"interactive"` run
     * CONTINUE with the synthetic self-answer instruction after all on BOTH hardened question arms
     * (the disclosure card + onError leg still fire). Without it those arms return the coded
     * `question.human_channel_failed` (channel threw) / `question.human_unavailable` (channel reported
     * nobody reachable) tool errors. Meaningless (ignored) outside posture `"interactive"` — headless
     * runs already continue.
     */
    interactiveQuestionFallback?: boolean;
    /** Optional images attached to this turn's user message (model must support vision). */
    images?: ImageInput[];
    /**
     * Files the user attached to this objective ({@link UserAttachment}): at most 20, delivered after the
     * UserPromptSubmit hook lets the objective through (a hook that blocks it reads nothing), each as its own
     * engine-minted message right after the objective. A path entry needs a workspace (hands on). A malformed entry,
     * a text entry over the Read limit (100 000 rendered characters), an image the API would not accept, a path entry
     * on a run without a workspace, or any entry on a durable resume leg is refused at the door:
     * `config.user_attachment_invalid`, the message opening with the field path (`TaskSpec.userAttachments[2].text: …`).
     * A file the engine may not read is not refused: its message says it was not attached and why, and the
     * `human_input` event's `attachments[]` reports each outcome.
     */
    userAttachments?: readonly UserAttachment[];
    /** Reuse an existing in-memory session for chat continuity; omit to start fresh. */
    sessionId?: string;
    /**
     * The leg's project — ONE seat ({@link ProjectSeat}): `id` (the project UUID, the `.sema/project` id) with the texts people wrote for it
     * (`name`, `description`, `instructions`, `files`), handed as one value. Screened at the spec's read by `screenProjectSeat` (a fresh run and a
     * resume's screen before its claim alike): a malformed seat ⇒ `config.invalid_argument` (the sentence opens with the field path,
     * `TaskSpec.project.<member>`); an `id` that is no UUID ⇒ `config.project_id_invalid`. The retired `projectId` is refused (`config.spec_retired_key`).
     * The id is decided once at prepare: a valid marker decides and `id` must EQUAL it (`config.project_identity_mismatch`); without a marker `id` IS the
     * identity; an unreadable marker refuses (`config.memory_project_marker` / `config.memory_project_marker_nested`). Every new leg (resume, wake, delegated
     * child, fork) is judged afresh from the seat handed to it: a resume from its config's; a woken agent is handed its WAKER's as a default (a retained agent's spawn
     * seat is not kept; no seat on the waker ⇒ none handed); a delegated child that declares none takes its parent leg's seat as a default (never compared
     * with the child's own marker, which decides when present). The texts belong to the id: a leg's seat is its own declaration whole, else the handed
     * seat whole when the verdict's id is that seat's id, else the verdict's id alone. Absent ⇒ the leg states no project text. Host duty: anything
     * else chosen by project for a leg (a `proj:` memory write key) is picked at the same moment from the same value as this seat's `id`. Read the verdict from
     * `wiring_manifest.manifest.project` (every prepared leg, including legs with no workspace snapshot) or `workspace_changed.project` (absent on legs
     * that emit no `workspace_changed` frame); a marker that could not be read arrives as `wiring_manifest.manifest.projectMarkerUnreadable` (`{ reason, markerPath? }`,
     * never present beside `project` — leave stored project rows untouched on it). Limits: only prepared legs emit a manifest (a refused leg has no manifest;
     * refusal detail rides `terminal.detail`), and a delegated child's manifest rides the child's own stream, never forwarded onto the parent's. Under `scopeContract: "v2"`, `proj:` / `userproj:`
     * write keys are checked against this verdict (`config.memory_project_identity`; mount dirs stay marker-only). Coded details ride `terminal.detail = { kind: "coded", detail }`
     * (`PROJECT_IDENTITY_REFUSAL_KINDS`): `{ kind: "mismatch", declared, marker, markerPath }`, `{ kind: "marker_unreadable", markerPath?, reason }`
     * (`PROJECT_MARKER_UNREADABLE_REASONS`: `"io_error"` | `"unparseable"` | `"not_uuid"` | `"nested"` carry `markerPath` for a marker at the task root itself, not above it; `"repo_root_unreadable"` omits it),
     * `{ kind: "write_project_mismatch", writeScope, writeProjectId, verdictProjectId, verdictSource }`, `{ kind: "write_without_verdict", writeScope, writeProjectId }`.
     */
    project?: ProjectSeat;
    /**
     * The session's workspace. The session's first leg turns it into the session's checkout, an immutable record every later leg
     * is judged against. A later leg (a resumed leg's config included) may OMIT it — the session's own declaration stands, the
     * leg runs in the session's tree as if it had sent it — or send the SAME declaration; `null` is a leg that wants NO tree (it
     * runs at the task root the host gave it, reports no checkout, and leaves the record as it is). A declaration that differs is
     * refused.
     *  - `isolation: "worktree"`: the session works in its OWN managed trees, one per repository a listed root is in (`roots`,
     *    absent ⇒ the task root), minted together on the first leg — all or none — at `<repository root>/.sema/worktrees/<name>`
     *    on branch `sema/<name>` (`name` absent ⇒ derived from the session id; `baseRef`: `"fresh"` default, or `"head"`). Every
     *    declared root of an isolated repository (the task root, an `additionalDirectories` / `additionalReadDirectories` entry,
     *    listed or not) stands at its place in that tree on every leg, a delegated child's included; the base checkouts are
     *    outside the leg's write roots. The trees outlive every leg and env; `releaseSessionCheckout` removes them.
     *  - `sources`: the commit the session's code starts from, per repository (`{ root, remote, sha, ref? }`): checked on the
     *    first leg (the checkout at that root must be at `sha`; an isolated repository's tree is minted at it).
     * Refusals, each before the leg starts: a malformed declaration ⇒ `config.session_workspace_invalid` (also: a writable root
     * in no tree that holds an isolated base checkout, a listed directory that is no `additionalDirectories` entry, a `baseRef`
     * that starts no tree, a remote carrying a credential); a declaration that differs from the first leg's, appears on a
     * session that already began without one (its log holds a turn or a compaction), or a listed root no longer in an isolated repository ⇒
     * `config.session_workspace_changed`; a tree cannot be made ⇒ `workspace.isolation_unavailable` (the root and the reason
     * named, `probeWorktreeCapability` judges the same); a checkout not at the declared commit ⇒ `workspace.source_mismatch`; the
     * record cannot be read ⇒ `workspace.checkout_unavailable`; a tree is gone ⇒ `workspace.checkout_missing` (never run in a
     * base checkout instead). A fork does not inherit the checkout. Every leg's `workspace_changed` frame carries it
     * (`session`), except a `null` leg's, and says where each additional root stands (`directories`).
     */
    workspace?: WorkspaceDeclaration | null;
    /**
     * design/114 Phase3 — with `sessionId` set, REQUIRE that session to already exist: if it is gone (e.g. a
     * non-durable store lost it across a restart, or a typo'd id), the run FAILS LOUD (`resume.session_not_found`)
     * instead of silently creating a fresh empty session and running with NO warm context. Use this for a
     * reuse-style warm-resume (`runTask({sessionId, requireExistingSession: true})`) so "looks warm, actually
     * fresh" can never happen. (The `fork`-first path via `warmResume` is already fail-loud without this flag.)
     * Ignored when `sessionId` is absent. Default `false` = today's create-on-miss behavior.
     */
    requireExistingSession?: boolean;
    /**
     * Per-request semantics — this SUBMISSION is one-shot:
     * no later turn exists in which an async background notification could land (the archetypal case is a
     * headless `sema -p` invocation, whose process exits once this turn ends). Per-request rather than
     * per-connection/per-process on purpose: "does this particular submission expect to be steered/continued"
     * is a property of the submission, not of the channel it arrived on — a persistent connection can still
     * mix interactive and one-shot submissions, which a connection-level flag could not express.
     *
     * What the engine does with it: the run's ending waits for the loop-type background tasks it launched (agents,
     * continued agents, workflows) — their terminal frames are owed to the run's lane and arrive as later turns,
     * bounded by the walltime and the wait's own ceiling ({@link TaskLimits.oneShotWaitCeilingMs}, default 600 s) — and does not wait for process-type ones (a background command,
     * a Monitor watch), whose receipts carry one sentence saying so. Default `false`/absent = interactive (unchanged).
     * A deployment MAY thread it into other one-shot-sensitive decisions of its own.
     *
     * INHERITED down the delegation tree (only the `true` value, off the trusted
     * {@link ToolExecuteContext.oneShot} seat): the property being described — "the process this
     * submission runs in exits when the turn ends" — is a fact about the whole run tree, not about one
     * level of it. A delegated child of a one-shot submission that launched its own background workflow
     * was told to end its turn and wait for a notification that could not arrive, which is the exact
     * lost-results shape this flag exists to prevent.
     */
    oneShot?: boolean;
    /**
     * design/112 C1/C5 — CLIENT-supplied USER facts (distinct from execution-env/container facts). In TOB the
     * worker container runs UTC and has no idea who the user is or where they are; the client/REPL/gateway knows.
     * It threads these so the `# Environment` block localizes "today" to the user's zone (else it annotates UTC)
     * and names who the agent acts for. All optional; absent ⇒ current behavior (UTC date, no user line). This is
     * the USER half of the env block — the WORKSPACE half (cwd/git/platform/shell) is probed THROUGH the
     * ExecutionEnv (the container), never from here.
     */
    clientContext?: {
        /** IANA time zone of the user (e.g. `Asia/Tokyo`) — localizes the env block's date. Invalid zones fall back
         *  to UTC (date AND annotation) rather than mislabeling — see `isValidTimeZone`. */
        timeZone?: string;
        /** The user's identity (e.g. email) — surfaced in the env block so the agent knows who it acts for. */
        userEmail?: string;
    };
    /**
     * design/99 §E18 (resume-at) — BRANCH the session at this prior entry BEFORE the turn: replay root→here,
     * then run the new `objective` as the next turn (the shell's "rewind to this message, ask differently").
     * Requires `sessionId`. **The id is a core `SessionTreeEntry.id`** — a persisted session-entry id — **NOT a
     * live {@link TaskEventIdentity.eventId}** (eventIds are never persisted; a deployment that holds eventIds
     * owns the eventId→entryId map). Any entry of the session (`resume_at.not_found` otherwise; a branch `leaf` entry reads as the entry it moved to, one that moved to the empty branch refuses `resume_at.empty_branch`), so a
     * `TaskResult.continuesFrom` value is one (capability `task.continues_from`). Where it lands, a run continued from there must append nothing before it takes
     * its input in: a tool call with no result after it on the branch up to the new leaf (an assistant message with a call, a tool result whose batch is not
     * complete) refuses `resume_at.open_tool_call`. Non-destructive: recorded as a branch `leaf` entry, so prior leaves stay in the tree (re-resume any time).
     * Mutually exclusive with a durable `runner.resume(...)` (the Runner rejects both at once). Every refusal writes nothing.
     * On a store that loads only a bounded window of the log, it must hold the whole branch the new leaf continues (its path read reaches a root, or the latest
     * compaction on it keeps from an entry on it), either {@link resumeAtMode}; else `resume_at.outside_window`, nothing written by the attempt that refuses (never a run from the window's floor on).
     * `"at"` keeps the attachment frames under the entry it continues from (a person's attachments, the instruction files a load delivered, a compaction's
     * restore): the leaf is the last of them, read through the store's `SessionStorage.getChildren` when it has it, else among the entries the handle
     * loaded — a handle that does not hold that entry on a store without it refuses the same code (never a run without them).
     */
    resumeAt?: string;
    /**
     * design/99 §E18 — how {@link resumeAt} positions the new branch relative to the resolved entry.
     *
     * - `"at"` (default, and the behavior when this field is omitted): branch AT the entry — **inclusive**.
     *   The target message stays in the replayed context as the leaf; the new `objective` is the next turn
     *   after it. This is the "keep that message, continue differently from it" shape.
     * - `"before"`: branch BEFORE the entry — **exclusive**. The leaf becomes the target's PARENT
     *   (`entry.parentId`). The target message and its whole subtree are OFF the new branch (still in the
     *   tree — non-destructive, re-resume any time).
     *
     * 🔴 Consumer guidance: a UI that truncates its transcript EXCLUSIVELY — CC-style rewind, where the
     * selected user message is REMOVED from the transcript and refilled into the input box — MUST send
     * `"before"`. With `"at"` the removed message silently remains the model's leaf, so the model keeps
     * answering a message the user no longer sees (transcript and model context split).
     *
     * `"before"`-specific target rules (the one landing judgment `Runner.rewindConversation` meets too):
     * - The target must be a person's words: a user message that is no attachment frame and that the engine did not write (an interruption
     *   marker, a queued note, a source this engine does not read: `resume_at.before_target_not_user`; a row with no source member, written
     *   before rows stated one, is a person's) — the exclusive-rewind product shape, and the one target whose parent is a settled replay point
     *   (the prior turn's end, or the session's pin). Its parent, the new leaf, is held to `"at"`'s rule (`resume_at.open_tool_call` when a
     *   call above it has no result there).
     * - The landing is the target's parent — the session's FIRST message too: a session the Runner built holds
     *   its prompt pin above its first message, so "before" it lands on the pin, the log keeps one root and the
     *   next turn is sent only the new objective. Only a target with no parent (the log's physical root: an older
     *   or imported log, a session forked from a store that loads only a window) is refused,
     *   `resume_at.before_root_unsupported` — a branch there would append a second root (start a NEW session).
     *
     * File-history interaction (design/381): with {@link restoreFiles}, the `"before"` file anchor is the
     * target's OWN entry id — history boundaries are keyed by the entry of the person's input that opened a turn and mean
     * "file state when that turn began", so B(target) IS the before-state. A target with no boundary of its own (a steer /
     * follow-up entry, an engine entry such as a task notification, a turn that recorded no history, a mixed-epoch session) refuses at prepare
     * (`rewind_snapshot.unresolvable`) with the files untouched: an earlier boundary would also revert edits
     * the conversation keeps, so the anchor never falls back to an ancestor and never crosses into an earlier turn.
     * Fail-loud: setting this without {@link resumeAt}, or an unknown mode value, rejects at prepare.
     */
    resumeAtMode?: "at" | "before";
    /**
     * Which model to run on. If omitted, resolved from the `modelRole` (default `"default"`) against
     * `roles` / `RunnerDeps.roles`. Either `model` or a resolvable role must be available.
     */
    model?: ModelRef;
    /** Which role to resolve when `model` is omitted. Default `"default"`. */
    modelRole?: ModelRole;
    /** Per-task/scenario role→model overrides (merged over `RunnerDeps.roles`, task wins). */
    roles?: ModelRoles;
    /** The ADVISOR model (CC's `advisorModel` setting): any ref {@link model} takes. Present ⇒ prepare judges it against this leg's own model (`advisorAttachVerdict`) and, when it attaches, mounts the no-argument `advisor` tool; a value that is neither a string nor a Model refuses prepare (`config.advisor_model_invalid`) unless `RunnerDeps.advisorTool` is `"disabled"`, which ignores it unread. Rides the parent spec seat: a child inherits it and judges it against its own model. */
    advisorModel?: ModelRef;
    /** Thinking level. If omitted, a default from the resolved role's `RoleSpec.thinking` applies. */
    thinking?: ThinkingLevel;
    /**
     * Fast mode — the provider's faster output tier for the SAME model (`speed: "fast"` plus its beta on the Anthropic Messages
     * wire), asked for on this leg's main-loop requests and its child legs'. Served only where the request's model declares it
     * (`Model.fastMode: true`); elsewhere the request goes at standard speed and the session hears why once
     * (`model.capability_downgraded`). When the provider pushes back on a fast request the engine re-sends it at standard speed
     * and pauses fast mode for the session (`model.fast_mode_changed`). The reading — `{ state, reason?, cooldown? }` — rides
     * `wiring_manifest.fastMode`, `TaskResult.fastMode` and `TaskStream.setFastMode`'s receipt. Absent / `false` ⇒ standard
     * speed. A non-boolean is refused (`config.invalid_argument`). Engine word: `task.fast_mode`.
     */
    fastMode?: boolean;
    /** This task's role text: it replaces the role base `promptRole` selects; the task names its role base first, above its role's preset (`RoleSpec`).
     *  Text carrying a locked section verbatim (an already-assembled prompt) is refused by name (`prompt.assembled_role_refused`). */
    systemPrompt?: string;
    /** The role base `core/role.base` selects — `"general"`, `"code"`, `"coordinator"`, `"cowork"` (rendered from the mounted tools and the
     *  working directory) — and the run's host role; `systemPrompt` replaces it. A task naming neither takes its role's preset (`RoleSpec.promptRole` /
     *  `systemPrompt`) whole; an explicit `"general"` ends that chain (a delegated non-fork child reads it as the `subagent` variant). Not inherited.
     *  Outside the closed set (`HOST_ROLES`, `isHostRole`) ⇒ refused at prepare. */
    promptRole?: import("../prompt-assembly/catalog/schema.js").HostRole;
    /** `"minimal"` leaves the core-behavior band out; the locked sections (mode sections in play among them) and
     *  `appendSystemPrompt` stay. Absent ⇒ standard. Rides the parent spec seat to every engine-built child (a clamp-table
     *  row: no child authors the standard form back). A value outside the closed set is refused at prepare. */
    promptForm?: "minimal";
    /** The deployment's binding (a scenario name): a prompt selector value, read by every overlay's `when.binding` (center, deploy and task alike); rides the parent spec seat; out of grammar (non-blank, ≤ 128 Unicode code points — `PROMPT_BINDING_MAX_CHARS`, counted `[...s].length`, not UTF-16 units) ⇒ `config.prompt_selector_invalid`. */
    promptBinding?: string;
    /** The catalog rendering this run reads: `"zh-Hans"` ⇒ every catalog message it receives (prompt sections, the environment
     *  block, the engine's own texts) in Simplified Chinese; absent ⇒ the catalog's text, byte for byte. Chooses no variant, sets no
     *  reply language; `selectors.locale`; rides the parent spec seat; any other value ⇒ `config.prompt_selector_invalid`. */
    promptLocale?: "zh-Hans";
    /**
     * APPEND a caller block to the assembled system prompt, keeping the engine's base + harness/safety blocks
     * (unlike `systemPrompt`, which REPLACES the role base).
     * The lightweight user/scenario-extension seam (≈ CC `--append-system-prompt`): add task-specific rules,
     * domain context, or a persona tweak without losing the neutral base, cyber/url safety, harness context, or
     * memory discipline. CALLER-TRUSTED (same trust level as `systemPrompt`/`skills` — NOT user input). Composed
     * as a STABLE block (prepare-time) at the END of the stable prefix, before the volatile `<user_memory>` tail,
     * so it never breaks prefix-cache friendliness. Composes WITH `systemPrompt` (appended after it).
     */
    appendSystemPrompt?: string;
    /**
     * The OUTPUT STYLE the deployment's shell has active, declared so the engine can state it to the model in its
     * own marked reminder: `"<name> output style is active. <turnReminder>"` (the reference implementation's
     * per-turn reminder sentence; absent `turnReminder` ⇒ its default "Remember to follow the specific guidelines
     * for this style."). The style's guidelines themselves are not carried here — they go in `systemPrompt` /
     * `appendSystemPrompt`; this seat is the per-turn statement that the style is in force, which a reminder the
     * shell splices into the objective cannot be (unmarked reminder-shaped text is data). Declare it only for a
     * non-default style; there is no client-trusted reminder seat behind it — the engine renders the sentence.
     *
     * Cadence: the first turn of every leg (a resumed leg's continuation included) and every continuing turn
     * boundary — the reference attaches it at every attachment cycle, with no window. Echoed as
     * `steering_injected` with source `output_style`.
     *
     * Refused at prepare (`config.output_style_invalid`), never ignored: a value that is not an object of exactly
     * these two members; a `name` that is not a string, is empty, or is longer than 256 characters
     * (`OUTPUT_STYLE_NAME_MAX`, the reference implementation's own bound — it drops the reminder past it); a
     * `turnReminder` that is present but not a non-empty string.
     */
    outputStyle?: {
        name: string;
        turnReminder?: string;
    };
    /** The person's REPLY language (a free name or code, e.g. `"Japanese"`, `"ja"`), stated to the model in the reference's `# Language`
     *  reminder on the leg's first request whenever it differs from what the model was told since the latest compaction; dropping it
     *  states the cleared sentence; a compaction inside the leg restates it. Never in the system prompt; sets no `promptLocale` (that
     *  seat renders the engine's own texts) and neither is read from the other. Rides the parent spec seat; stated on a root leg and
     *  a named teammate, never on an ordinary delegated child. Not a string, blank, or over 256 characters ⇒ `config.language_invalid`. */
    language?: string;
    /**
     * Enable long-term memory for this task. **design/138 S4 (BREAKING): requires `RunnerDeps.memoryBackend`**
     * (the injection-first memory engine — materialize → file ops → harvest). With a backend configured the
     * task gets the `# Memory` instruction + fenced derived index and works memory through its
     * ordinary file tools. WITHOUT a backend this field is INERT: the task runs memory-less and one warning is
     * emitted via `onError` (phase `"config"`).
     *
     * **design/84 Seam A** — single opaque scope → an **ordered, opaque scope list + a single writeScope**.
     * The engine only does read-side **layered injection** (one `<user_memory>` block, a `<scope …>` subsection
     * per scope, ordered by priority — the LAST scope is highest-priority and lands at the prompt TAIL) and
     * write-side **single-point routing** (remember/consolidation only ever write `writeScope`; the model never
     * picks a layer). Scope strings stay OPAQUE — the client/profile derives them (TOC: managed/user/project/
     * agent/local; TOB: tenant hierarchy). The fields are normalized to one canonical shape
     * ({@link import("./memory.js").normalizeMemorySpec}) — `writeScope` defaults to the LAST scope — so the
     * consumer side reads one array with zero narrowing.
     *
     * Cache discipline (§5, implemented in prepare-task): the scopes are injected in list order, so the
     * caller places STABLE layers (managed/user/org — rarely change) FIRST (cacheable prefix) and VOLATILE
     * layers (project/agent/local) LAST (only the tail re-computes). The stable prefix is byte-stable.
     *
     * ONE form (RB-479-B②): `scopes` is the only spelling of the read layering. The singular `scope`
     * field was removed, and a spec still carrying it is REFUSED at normalization
     * (`config.memory_scope_spelling`) rather than read as "no scopes" — a silent memory-off task is the
     * one outcome this field must never produce by accident.
     *
     * The accepted shape is {@link import("./memory.js").MemorySpecInput} (the SAME type
     * {@link import("./memory.js").normalizeMemorySpec} consumes) — DESIGN-2 (council): typed by import rather
     * than re-declared inline so the input contract and its normalizer can never silently diverge. Per-field
     * semantics: `scopes` = ordered opaque layering (STABLE first / VOLATILE last; last = highest priority);
     * `writeScope` = the single layer all writes land in (default = last scope; explicit `null` = read-only —
     * no `remember` tool, consolidation off); `enabled` = master switch (default true).
     */
    memory?: import("./memory.js").MemorySpecInput;
    /**
     * design/100 §E12 — after the task COMPLETES, run ONE extra opt-in LLM pass to propose "next prompts" the
     * user might send (the shell's follow-up suggestions). OFF/omitted = zero extra LLM calls, behavior unchanged.
     * Fire-and-forget (never blocks the result); the suggestions are surfaced via {@link TaskStream.suggestions}
     * and the (budget-excluded) cost via {@link TaskStats.suggestions}. `count` default 3, `role` default
     * `"summarize"` (a cheap tier → falls back to the task model). The output is UNTRUSTED model text for the
     * shell UI ONLY — never re-feed it to a model.
     */
    suggestNextPrompts?: boolean | {
        count?: number;
        role?: ModelRole;
    };
    /**
     * The per-run OFF SWITCH for file history (`"disabled"`, the only word; `checkpointStore`'s spelling). Omitted ⇒
     * the deployment (`RunnerDeps.fileHistoryStore` / `fileHistoryCapture`) decides. `"disabled"` ⇒ this run makes no history-store call: no first-touch record
     * (the edit proceeds), no turn boundary, no fork carry, no liveness advisory; a restore request ({@link restoreFiles}
     * / {@link rewindFilesTo}) refuses `rewind.capture_disabled` (the store may be wired; the request turned it off).
     * The manifest reports `fileHistory: "disabled"`. Children inherit it (parent spec seat; a retained child woken by
     * such a run, for that cycle); no word turns it back on below. Any other value refuses (`rewind.invalid_spec`).
     */
    fileHistory?: "disabled";
    /** The per-run OFF SWITCH for the project's instruction files (`"disabled"`, the only word; {@link fileHistory}'s spelling): it
     *  silences {@link instructionFamily} — the declaration is still screened (a bad value refuses), then nothing is stat'ed or read at
     *  any level. Omitted ⇒ a declared family is read. Unaffected: the engine's own git-status lane and the memory engine (its index
     *  seed included). The manifest reports `"disabled"` (`"absent"`: no family declared). Children inherit it (parent spec seat, a
     *  revived cycle included); no word turns it back on below. Any other value refuses prepare, and a resume's screen before its
     *  claim, `config.invalid_argument`. */
    projectMemory?: "disabled";
    /**
     * The instruction-file family ({@link InstructionFamilyDeclaration}): the engine reads it at every level of the task root,
     * through the hands, under the Read tool's own admission — the root's own level on every leg (the session's instructions,
     * frames of origin `project_instructions`, the leg's first request first), and when the model reads or writes a file below the
     * root, the family of each directory between the root and that file and the rules whose paths match it (frames of origin
     * `nested_memory`, on the next request); with its `additionalDirectories: true`, each additional working directory's own level as
     * the root's is. A delivered file edited since is sent whole again; removed or emptied, it is withdrawn
     * once. Absent, or under {@link projectMemory} `"disabled"` (screened, then silent) ⇒ nothing is stat'ed or read. Children inherit
     * it (the parent spec seat): omitted ⇒ the parent's; `projectMemory: "disabled"` silences it; the child's own declaration stands.
     */
    instructionFamily?: InstructionFamilyDeclaration;
    /**
     * design/381 (DV-9) — the RESTORE half of file rewind: when this task uses {@link resumeAt} to branch at
     * a prior entry, ALSO converge the working tree's **agent-edited files** (the tracked set — files this
     * session touched through Edit/Write/NotebookEdit; nothing else is ever visible to the history, so a
     * user's parallel work is structurally untouchable) to the history boundary of that entry (pairs with
     * E18: branch the session + restore the tracked files). SCOPE = THIS session: a delegated
     * subagent runs under its own session and its edits land in its own history scope, so a parent
     * rewind does not converge files only a subagent touched (the retired whole-tree restore did —
     * a design/381 narrowing, disclosed here). Requires `RunnerDeps.fileHistoryStore`.
     * Fail-loud: setting this without {@link resumeAt} rejects at prepare (`rewind.invalid_spec`) — a
     * restore with no anchor is a contradiction, not a default.
     *
     * There is NO capture request anymore: first-touch tracking is ON whenever a `RunnerDeps.fileHistoryStore`
     * is wired, `RunnerDeps.fileHistoryCapture` is not `"off"`, and no {@link fileHistory} off switch is set (per-edited-file backups are near-zero cost — no tree walk,
     * no size gate). The retired `rewindFiles` key is refused by name at prepare (`config.spec_retired_key`) in
     * both of its old senses; the restore sense is THIS field.
     */
    restoreFiles?: boolean;
    /**
     * design/381 (DV-15) — opt-in tolerance for a PARTIAL file restore: when the {@link restoreFiles} /
     * {@link rewindFilesTo} convergence ends with ≥1 per-file refusal or failure (the others applied),
     * the default is a loud terminal failure carrying the per-file ledger (`rewind.restore_failed`) —
     * a silent continue would run the agent on a mixed-epoch tree without anyone knowing. Setting this
     * `true` keeps the run going instead and discloses the same ledger as a `restore_partial` note on
     * {@link TaskResult.rewindNotes} (the reference UI's "skipped files" seat in library form). The
     * documented recovery either way: re-run the same restore — it is per-file idempotent and converges.
     */
    acceptPartialRestore?: boolean;
    /**
     * The directory this session's OLDER file versions were recorded under (an engine before 7.68.2 recorded no place): without
     * it they are refused `place_unrecorded`; with it they are judged as recorded there, by the one place comparison (another
     * directory ⇒ not written: left as it is outside this root, `recorded_elsewhere` inside it). An absolute path, in the run's environment
     * — or the word `"rewind_root"`: they were recorded under this rewind's own root (the root the engine joins the session's keys on: a
     * session that works in a tree of its own, that tree), which the host states without knowing or spelling the path; the engine reads it
     * as that root where the restore runs. Only on a run that restores files, else `rewind.invalid_spec`. A host states it when it knows
     * where every earlier turn ran. `Runner.rewindFiles` takes it too (capability word `file_history.unplaced_recorded_under`).
     */
    unplacedHistoryRecordedUnder?: string;
    /**
     * design/101 §E19 R8 + design/381 (CC Rewind `code`-only mode) — converge the tracked set (see
     * {@link restoreFiles} for what that is and is not) to the history boundary of this prior entryId
     * WITHOUT forking the conversation (no {@link resumeAt} leaf-branch). This is CC's "Restore code"
     * mode (vs "Restore code and conversation" = {@link resumeAt}+{@link restoreFiles}, and "Restore
     * conversation" = {@link resumeAt} alone). Legal ONLY when {@link resumeAt} is ABSENT — handing
     * BOTH anchors is refused loud (`rewind.conflicting_targets`): two file targets is a
     * contradiction, and silently preferring one is the silent-swallow family this seam refuses; a
     * target with no history boundary, or that is not an entry of this session's own log, fails loud (`rewind_snapshot.unresolvable`). Requires
     * `RunnerDeps.fileHistoryStore`. The session leaf is untouched — the next turn continues the
     * CURRENT conversation, only the files moved.
     *
     * A same-process child THE AGENT TOOL SPAWNED FRESH (the legs that are handed a lineage — see
     * `ToolExecuteContext.fileHistoryLineage` for the exact set, and for the legs that are not) which
     * shares its root session's tree records its edits into the ROOT session's history, so a rewind
     * that should cover those edits is the root session's action; a restore request on such a child run
     * is refused loud (`rewind.child_scope_unsupported`) rather than converging a scope that holds none
     * of its edits. A delegated child that was handed NO lineage — a revival, a workflow/team member —
     * keeps its own scope: its edits are outside this target's reach, and its own restore request is an ordinary one.
     */
    rewindFilesTo?: string;
    /**
     * Native tools available to this task.
     *
     * NAME OCCUPANCY IS A DECLARATION: a caller tool that takes a built-in's reserved wire name
     * shadows that built-in (the hands band name-shadows caller tools the other way around only for
     * its own mount), and the engine reads the occupancy itself as the caller declaring it will serve
     * that CHANNEL — most concretely, a tool named `Write` on this roster counts as the memory write
     * channel, so the `# Memory` write instruction (and its index read-seed) is supplied whenever a
     * `Write` is mounted and not excluded, whatever the tool's `execute` actually does (the engine
     * cannot read execute semantics; the NAME is the only judgeable fact). A shadowing mount is also
     * surfaced to the operator as a config-phase warning. Protocol tools (MCP/A2A) can never collide
     * here: their wire names are namespaced (`mcp__<server>__…`) and a caller name containing `__`
     * is rejected at prepare.
     *
     * Mount point: the roster (with `defer`/`excludeTools`/`deferTools`) lives on this PER-TASK spec —
     * the Runner constructor's deps carry no tool roster. Plain-JS callers beware: an unrecognized key
     * passed to the constructor is dropped by ordinary object semantics (TypeScript callers get an
     * excess-property error), so a roster placed there never mounts and its `defer` flags never apply.
     */
    tools?: ToolSpec[];
    /**
     * The run's tool ALLOWLIST — the availability selector (true unmount, NOT a permission gate): when set, the run may use only the
     * tools it names, out of everything the engine would otherwise mount for it (the caller's tools, the hands, the engine's own
     * tools, MCP and A2A tools, scenario and leg tools); the rest never reach `tools[]`. Omitted ⇒ the default set (a delegated
     * child: whatever its parent could use). `[]` ⇒ no tools. An entry `"*"` ⇒ no allowlist on this layer (still bounded by the
     * ceiling a spawning run handed down — a child's `"*"` never widens its parent).
     *
     * Entries are read like {@link excludeTools}: a wire name or an alias it declares, `mcp__srv` / `mcp__srv__*` for every tool
     * of a server (including tools it lists later), a glob over the tool segment. The engine resolves the list against its OWN
     * roster at prepare — a host passes the names it was given. A spelling no tool name can have, `mcp__*` / `mcp__*__*` (an allowed
     * list names no peer by them), or an entry that is not a string is REFUSED at prepare (`config.tool_face_control`); a name no tool answers to is kept and told once (`onError`, phase
     * `"config"`). The same compiled selector is applied on every later roster change (an MCP refresh or re-dial, the
     * deferred-search lane). Deferral is reached through ToolSearch, so a list that leaves it out defers nothing.
     *
     * A tool a leg relies on (a delegated child's ReportBlocked, a teammate's SendMessage, a goal iteration's DeclareDone, an
     * observer's report tool, a run's structured-output tool — the catalog's protocol column) is not an allowlist's to name, nor
     * {@link excludeAllTools}'s to take out; a denylist that reaches one on such a leg is refused at prepare.
     */
    allowTools?: string[];
    /**
     * per-scenario tool ROSTER removal (true unmount, NOT a permission gate): the tools this list names are removed from the
     * mounted tool set AFTER assembly — their schemas never reach `tools[]` (unlike a policy deny, which gates calls but still
     * ships the schema bytes every request — measured at zero token savings). The DENY half of the run's tool selector, read
     * exactly as a sub-agent's denied tools are: a wire name or an alias it declares; `Tool(content)` names the whole `Tool`;
     * `mcp__srv` / `mcp__srv__*` / a glob over the tool segment for a server's tools, `mcp__*` / `mcp__*__*` for every MCP tool
     * (including tools a server lists later). A spelling no tool name can have, `"*"`, or an entry that is not a string is REFUSED at prepare; a name
     * no tool answers to is kept (it hides a tool of that name mounted later) and told once. A deny wins over {@link allowTools}.
     * ⚠️ A list that reaches a tool this kind of leg relies on (see {@link allowTools}) is refused; excluding a host-requested
     * structural tool (the structured-output tool) can still strand the task — the caller owns that risk.
     */
    excludeTools?: string[];
    /**
     * design/388 §2.2 ⑥ — unmount the WHOLE tool face: the leg's own allowlist names nothing (whatever {@link allowTools} says), so
     * it mounts no hands, scaffolds, caller, MCP, A2A or skill tool and keeps only the tools its kind relies on, as `allowTools: []`
     * keeps them: a run with an {@link outputSchema} delivers `structuredOutput`, a goal iteration keeps DeclareDone, and a leg that
     * relies on none reads `entries: []` and sends no tools; `runWithVerification`'s verifier carries it. Not `excludeTools: ["*"]`
     * (a legal caller name). `excludeTools` beside it is redundant, not an error; one reaching a relied-on tool is refused as without it. Absent and `false` leave the face mounted; a value that is not a boolean (the string `"true"`, a number, `null`, an object) is REFUSED at prepare (`config.tool_face_control`, `detail.reason` `not_a_boolean`), never read as "off".
     */
    excludeAllTools?: true;
    /**
     * Per-request DEFERRED disclosure for ALREADY-MOUNTED tools (built-ins
     * included — `ToolSpec.defer` only covers caller specs): wire names listed here ship as
     * lightweight placeholders (name + one-line hint, schema bytes OFF the cache prefix) and are
     * activated on demand via the injected ToolSearch (design/36 materialization — prefix untouched).
     * This list is LITERAL — an intentional deferral, deferred on every request regardless of the
     * deferral gate ({@link RunnerDeps.deferMode}) and not counted toward its threshold.
     * "Default-on but not exposed" = the deployment lists the tool here on requests where no
     * activation source fired (e.g. Workflow unless the user said "workflow"/"ultracode"); omitting
     * the name on a later request mounts it fully (activation = not deferring). Unknown names are
     * ignored. Names also in `excludeTools` are excluded (exclusion wins — nothing to defer).
     */
    deferTools?: string[];
    /**
     * design/168 (P3) — how a deferred tool's ACTIVATION reaches the provider-facing tools block.
     * `"swap"` (default, prior behavior): ToolSearch activation swaps the placeholder for the full
     * schema via setTools — the tools block changes mid-run, which invalidates the provider prompt
     * cache for everything after it (tools serialize FIRST in the cache hierarchy). `"static"`: the
     * tools block stays byte-identical for the whole run — placeholders never swap; the full schema
     * reaches the model only through the ToolSearch result text (the existing delta-as-tool-result
     * carrier), and argument validation against the REAL schema is unchanged (engine-side). Genuine
     * roster changes (an MCP refresh adding/removing names) still propagate on either setting.
     *
     * DEFAULT `"swap"` (rolled back 2026-08-06 after a brief default-`"static"` window). `"static"` is
     * a STRICT EXPLICIT OPT-IN, and the condition to opt in is a property of the whole serving route,
     * not of one model: every model the run can reach — the prepare-time model, every model on its
     * catalog `fallbacks` chain, and any near-budget model hand-off — must be able to
     * emit arguments it read from RESULT TEXT while the advertised wire schema stays empty. A model
     * served with CONSTRAINED DECODING cannot: its sampler is bound by the advertised
     * `{"type":"object","properties":{}}`. On the mainstream implementations — the ones that compile a
     * grammar from the declared `properties` — that admits exactly one argument object, `{}`, so the
     * engine's corrective rejection can never be acted on and the run burns turns instead of
     * converging. (A decoder that instead reads the schema by strict draft semantics would treat the
     * absent `additionalProperties` as permissive and let other keys through; the model still has no
     * schema to form them FROM, so the best case there is guessing, not converging.) A protocol dialect
     * is no guarantee either (an Anthropic-shaped endpoint may serve a constrained-decoding model),
     * which is why the opt-in is the deployment's declaration that it verified the route, fallback
     * targets included, rather than anything core can infer.
     *
     * Interlock with {@link TaskSpec.deferSelfResolve}: `"static"` requires the direct-call lane — a
     * never-swapped placeholder with the lane disabled would make every deferred tool permanently
     * uncallable. Explicitly pairing `"static"` with `deferSelfResolve: false` is refused at prepare
     * (`config.tool_materialize_unreachable`); a `"static"` arriving from the env channel degrades to
     * `"swap"` on such a task instead. A value outside the closed set refuses loudly
     * (`config.tool_materialize_invalid`) — a typo must not silently select the opposite arm.
     */
    toolMaterializeStrategy?: "swap" | "static";
    /**
     * The inline-pin counterpart of {@link deferTools} (same wire-name addressing, opposite
     * direction): names listed here are NEVER deferred — not by
     * `ToolSpec.defer`, not by the MCP constant-defer arm (besides the server's own
     * `_meta["anthropic/alwaysLoad"]` declaration this list is the only channel that keeps a chosen
     * MCP tool's full schema inlined), not by `deferTools`, not by the deferral gate under any `deferMode`. Unknown names
     * are ignored (the valve only subtracts). Names also in `excludeTools` stay excluded (exclusion
     * wins — an unmounted tool has no schema to keep inline).
     */
    alwaysLoadTools?: string[];
    /**
     * design/277 — per-task restore valve for the tool-registration MODEL GATE. The gate trims
     * default-mounted scaffold entries (tagged via {@link ToolSpec.modelGate}) from the roster when
     * the task's resolved model id matches the gate table — this valve opts the task (and its whole
     * delegation tree — the selector inherits down like `excludeTools`) back in:
     *  · an ARRAY of wire names — naming ANY tagged tool restores that tool's WHOLE class for this
     *    task (CC parity: opting into any member of the family restores the family). Judged against
     *    the full stamp set, so a name that `excludeTools` also lists still works as a class
     *    SELECTOR — while the exclusion itself still wins for that name (exclusion is the final
     *    valve; no restore channel resurrects an excluded name). Unknown names are inert (a
     *    center-distributed list may be a superset), same posture as `excludeTools`.
     *  · literal `true` — every gate class restored for this task (the shortest "this task wants
     *    all its scaffolding" spelling for center-distributed specs).
     * A malformed value refuses at prepare (`config.tool_model_gate_invalid`, #123) — garbage must
     * not silently read as "restore nothing" in the trimming direction. Absent = the gate's verdict
     * stands. Explicit composition needs no valve: a hand-mounted (untagged) tool is never gated.
     */
    restoreGatedTools?: string[] | true;
    /**
     * Whether a schema-VALID call on a still-deferred tool runs the real tool directly
     * (activating it as a side effect). Default `true`, matching the upstream posture where the
     * defer gate is shape validation, not activation state (a deferred tool called with correct
     * arguments succeeds; activation only controls whether the model has SEEN the schema). Set
     * `false` to restore the strict posture: every call on an un-activated placeholder is rejected
     * with the ToolSearch teaching message regardless of argument shape. Governance is unaffected
     * either way — policy/effect/irreversibility gates key on the tool NAME maps and run upstream of any execute.
     */
    deferSelfResolve?: boolean;
    /**
     * The task's one switch on the prompt's shape: `true` adds the `lean_prompt` trait to the model's declared traits
     * (`Model.promptTraits`), `false` removes it (the long, classic shape of the system sections and tool descriptions),
     * absent leaves the model's answer. It moves no other trait — a model-family trait stays the model's. PRESENTATION
     * only (section wording, tool descriptions), never tool behavior or policy. Inherited by delegated children (and
     * workflow agents) unless their spec writes it; a value that is not a boolean refuses the task
     * (`config.prompt_selector_invalid`).
     */
    promptLean?: boolean;
    /**
     * core half — PER-TASK custom sub-agents. Same shape as the boot injection point
     * ({@link RunnerDeps.agents} / `SubagentToolOptions.agents`): full {@link AgentDefinition} objects
     * (the shell resolves agent files / frontmatter into this shape; `model` is the already-resolved
     * real model ref passed through — core carries no model-word vocabulary). When set (non-empty),
     * `prepareTask` REBUILDS the mounted delegation tool (via {@link ToolSpec.withAgents}) so its roster
     * is the UNION of the boot roster and these definitions — a same-name per-task definition WINS over
     * the boot one. Validation contract (the reference's shape — an agent's tool list filters by name,
     * and a name nothing answers never fails the run): both lists are judged once, here and for the
     * delegation tool's own lists alike; a `denyTools` entry is read as the reference reads it
     * (`Tool(content)` hides the whole `Tool`, with a host notice); an entry that is another spelling of a tool the child is handed (a tool of the pool the delegation tool declares, or the engine's catalog: a case twin, a retired name with a successor: `"near_miss"`, while that pool can be listed) is REJECTED at task start (`config.agent.unknown_tool`);
     * an entry whose spelling no tool name can have (`"Bash("`) is told once (`onError` and a `user` notice) and a delegation to that definition is refused (same code, `detail.reason: "grammar"`); an entry naming a tool that does
     * not exist (a server this deployment does not declare, a misspelt name) is kept as written
     * — it denies, or admits, a tool of that name if one is mounted later — and told to the host once
     * via `RunnerDeps.onError` phase `"config"` (zero model-facing warning); and
     * providing this field with NO delegation tool mounted is rejected too
     * (`config.agents.no_delegation_tool`) — never a silent no-op. POLICY-NEUTRAL: a
     * roster listing only; the 1.294 tighten-only parent-policy inheritance is applied at spawn time,
     * downstream of this list, so a per-task agent can never widen what deployment/parent policy allows.
     * Omitted/empty ⇒ byte-identical prior behavior.
     */
    agents?: AgentDefinition[];
    /** Gate tool calls before they run (allow/deny/approval). Overrides `RunnerDeps.toolPolicy`. */
    toolPolicy?: import("./tool-policy.js").ToolPolicy;
    /**
     * #93 (F-012 L3) — the OVERRIDE seat for the durable resume-edit re-adjudication policy: the policy
     * an approver's `updatedInput` EDIT is re-checked against before a resumed pending call executes
     * (and, at park-mint time, the policy a store-codec-moved projection is re-adjudicated by). ABSENT
     * falls back to the caller policy (`toolPolicy ?? RunnerDeps.toolPolicy`) — never to a silent skip:
     * the pre-#93 shape skipped the whole recheck for deployments with no caller policy, which let a
     * fidelity-projection-moved value land unadjudicated. Supply this only to make the resume-edit
     * boundary STRICTER/different from the live caller policy; it never widens (the frozen ancestor
     * projections and the deny-narrowing layers still apply regardless).
     */
    basePolicyForResumeEdit?: import("./tool-policy.js").ToolPolicy;
    /** How `ask` decisions resolve for this task (headless auto-deny by default). Overrides `RunnerDeps.onAsk` when present.
     *  A person's callback here is set aside when the run declares {@link approvalReach} `"none"`; an approver the deployment marked
     *  as its approval policy (`asPolicyApprover`) and a blanket `"allow"` / `"deny"` are kept. */
    onAsk?: import("./tool-policy.js").OnAsk;
    /** Content-ask seam (design/64 §5): routes an AskUserQuestion tool call to a real human/UI. When set, the
     *  AskUserQuestion tool is mounted (one of the delivery faces in the criterion — see
     *  {@link interactiveTools}). Overrides `RunnerDeps.onQuestion`. Distinct from `onAsk` (permission). */
    onQuestion?: import("./ask-question.js").OnQuestion;
    /** LSP code-intelligence seam (design/64 §13.1): when set, the `lsp` tool is mounted on a leg with hands and routed to
     *  this manager. Overrides `RunnerDeps.lspManager`. Neither seat set, or no hands ⇒ the engine mounts no `lsp` tool (the model uses grep/read_file). */
    lspManager?: import("./lsp.js").LspServerManager;
    /**
     * design/121: after the agent edits a file, NEW language-server diagnostics are
     * injected into the model (`<new-diagnostics>` context message, 10/file · 30 total · 4000-char cap)
     * and emitted as a structured `diagnostics` event for the shell. **Default ON** whenever the
     * preconditions hold — an LSP manager with a diagnostics registry is wired AND the roster has
     * write-capable fs tools (CC's same gate); zero cost/behavior change otherwise. `false` opts out.
     */
    lspDiagnostics?: boolean;
    /** The task seat of the mods bus — `user` tier only, beside `RunnerDeps.mods` (never instead); INTEGRATION §10. Its
     *  registrations hang handlers on the `classic.*` events the engine's stations raise (tool pre/post/failure/batch,
     *  prompt submit, stop, compaction, permission denied). A delegated child dispatches its parent's task seat as its own
     *  (the parent spec seat fills an unset one). */
    mods?: readonly import("./mods/classic-events.js").EngineModRegistration[];
    /**
     * The session's SELF-REPORTED presence for the peer directory (`agent` = what it is, `intent` = what
     * it is doing; each ≤ 120 chars). The engine never writes a directory row: the same object goes out
     * on the leg's `wiring_manifest` so a host copies it into the row it writes, and `ListAgents` renders
     * it on other sessions' listings prefixed `self:`. Labels only — never read by any judgment.
     */
    peerPresence?: import("../agents/peer-directory.js").PeerPresence;
    /**
     * design/45 **durable suspend-on-approval** (F4). When set AND a `CheckpointStore` is wired
     * (`checkpointStore` here or on `RunnerDeps`), a tool-policy `ask` **can suspend durably**: when no LIVE
     * approver is present, or a control-plane `forceDurableGate` mandates it, the ask is **persisted as a
     * checkpoint** and the task ends `status:"suspended"` + `checkpointToken` — resume later with
     * `runner.resume(token, outcome)`. With a live approver, the ask resolves synchronously in-stream FIRST
     * (same turn, no checkpoint) — this option is the durable FALLBACK for when no live approver can answer,
     * not an "always park" mandate. It is the cross-process / long / headless version of the `onAsk` gate.
     * **opt-in, default-off**: unset → the synchronous `onAsk`-only path (a headless ask then auto-denies).
     * A nested orchestrator stops at such a pause and hands it back (`mapNestedSuspend` in `src/agents/suspend-guard.ts` states how it continues).
     *
     * **Precedence vs a live `onAsk`:** "live approver" means a FUNCTION-valued `spec.onAsk ?? deps.onAsk`.
     * With one wired, BOTH plain and SAFETY asks (egress/irreversibility tightens) resolve through it
     * in-stream — same turn, no checkpoint, the gate recorded in `humanReview.gates` — and this option acts
     * as the no-approver fallback. The durable park keeps priority only when: (a) there is no function seat
     * (absent, or a blanket `"allow"`/`"deny"` string mode — a policy setting is not a reachable human);
     * (b) a control-plane `forceDurableGate` entitlement is in force (on a delegated leg only where its lane holds its parks — elsewhere the leg parks no ask and refuses every one, `config.durable_gate_unavailable`); (c) the live face already answered
     * `"unavailable"` for this ask; or (d) the call is marked inherited-unavailable by an ancestor. A workflow member whose seat resolves to `declared_none` ({@link approvalReach}) parks no permission ask under any of these; its inherited opt-in still holds its questions and resource yields.
     *
     * **`false` — the host cannot resume this run's decision parks.** Three states, one question ("this leg's decision parks"): an
     * object opts in, absence says nothing (a `forceDurableGate` entitlement may still synthesize an opt-in), and `false` declares that
     * nobody can resume a parked approval of this run. Then no decision park is minted (a permission ask, a question, a plan review): a
     * live approver answers in-stream, else the ask is refused with its way out — under a `forceDurableGate` entitlement it is refused
     * `config.durable_gate_unavailable` / `leg_not_resumable`, never answered live; the plan-mode tool pair mounts only as on a store-less leg (ExitPlanMode only under `interactiveTools: true`); resource
     * parks (budget / turns / a scheduler's yield / a usage window / an env lifetime) are untouched. It travels to every child the run
     * spawns (a tighten-only seat), and a resource row the leg parks records it: a resume whose config states no `durableApproval`
     * keeps it, and only a config that states an opt-in object lifts it. Declare it where no road leads back to a parked approval
     * (a one-shot call with no approval channel; a lane whose resume runs elsewhere); a run with a live approver, or a background lane
     * that can park, has no need of it (`INTEGRATION-CORE.md`, "Declaring durableApproval: false").
     */
    durableApproval?: DurableApprovalOptIn | false;
    /**
     * design/74: opt into resource-slice suspend. When a resource limit (maxTurns / budget / walltime) is hit
     * AND the task is eligible (a `checkpointStore` + a remote, suspendable `executionEnvFactory` env), suspend
     * as a resumable `resource_limit` checkpoint instead of failing (the "失败≠没做完" third state) — resume
     * continues the run with the next slice's allowance. `scope` is the multi-tenant isolation key (like
     * `durableApproval.scope`). Absent ⇒ a limit hit still FAILS (backward compatible). Independent of
     * `durableApproval` (a run can have one, both, or neither).
     *
     * It answers ONE question — when the task's OWN axes (budget / turns / walltime) run out, suspend or fail? —
     * and nothing else: the external causes (a scheduler's yield {@link preemptSignal}, a usage window, an env
     * lifetime) suspend on the infrastructure alone, with or without this opt-in. When it is set, its `scope`,
     * `ttlMs` and `maxSlices` still shape every resource-limit row this task mints, external ones included.
     */
    resourceSuspend?: {
        /** Multi-tenant isolation key, forced into the checkpoint + `resolve`/`reap` WHERE. Required. */
        scope: string;
        /**
         * design/74 Slice 4: the task's TOTAL $ budget (USD) across the whole resume→re-suspend chain — the
         * human's allocation, distinct from `limits.maxCostUsd` (the per-SLICE window). Each slice may spend
         * `min(limits.maxCostUsd, total − alreadySpent)`; the ledger (carried on the checkpoint) accumulates
         * spend so a resume can't refresh the budget. `undefined` ⇒ no $ ceiling on the whole task (each slice
         * is bounded only by its own window). Set ONLY on the FIRST slice; later slices read the frozen total
         * from the ledger.
         */
        totalBudgetUsd?: number;
        /**
         * design/164 (the TOKEN sibling of `totalBudgetUsd`, replacing the retired walltime total): the task's
         * TOTAL token allocation across the whole resume→re-suspend chain — distinct from `limits.maxTokens`
         * (the per-SLICE window). Each slice may spend `min(limits.maxTokens, total − alreadySpent)`; spend
         * accumulates on the ledger's `spentTokens`, so a resume can't refresh the allocation. An EXHAUSTED
         * resume (0 remaining) fails fast without running a model turn. `undefined` ⇒ no token ceiling on the
         * whole task. Set ONLY on the FIRST slice; later slices read the frozen total from the ledger.
         */
        totalTokens?: number;
        /**
         * design/74 (HIGH-1): max resource SLICES (resume legs) before the run fails with
         * `"suspend.loop"`. The resource-slice analogue of `maxSuspends`, but counted on the ledger's
         * `sliceCount` and INDEPENDENT of the restart-loop `maxSuspends`: a legitimate long resource run must
         * not be capped by the (low) restart-loop safety, and restart-loop suspends must not consume the slice
         * allowance (the bug: both shared one `suspendCount` + `maxSuspends`). The cross-slice allocations
         * (`totalTokens` / `totalBudgetUsd`) are the PRIMARY bound; this is a backstop against a
         * zero-progress slice loop. **Unset ⇒ no slice ceiling** (design/164 default retirement): a driver
         * that resumes a task which makes no progress will loop until an allocation binds, so a host driving
         * resumes unattended should set this.
         */
        maxSlices?: number;
        /**
         * design/74 (HIGH-2): retention TTL (ms) stamped onto the resource checkpoint's `deadline`
         * so the durable reaper can GC an orphaned (never-resumed) resource suspend. WITHOUT it the checkpoint
         * has no `deadline`, both reapers filter on `deadline`, and the `pending` row (+ in-memory pin) leaks
         * forever. Default `DEFAULT_RESOURCE_TTL_MS` (30 days, the spec `RESOURCE_SUSPEND_TTL_SEC`). A legitimate
         * resume happens long before this; the deadline only reaps abandonment.
         */
        ttlMs?: number;
    };
    /**
     * design/80 Seam #2 (external preempt/yield): the SCHEDULER raises this `AbortSignal` to PREEMPT this task —
     * a graceful, RESUMABLE durable yield (free resources for a higher-priority task), NOT an abort (abort kills
     * the run and loses its state). When raised, the task durably suspends at the next CLEAN turn boundary as a
     * `resource_limit` checkpoint with reason `"preempt"` (the SAME mechanism as a budget/turns/walltime resource
     * suspend — only the trigger differs), and is resumed later via `runner.resume(token, {gate:"resource_limit",
     * decision:"continue"}, …)` exactly like any resource-limit resume (continue the work, no decision).
     *
     * **Eligibility = the infrastructure, nothing else** (the same family as an env lifetime or a usage window —
     * a yield is an external cause, not an allowance the task chose): a `checkpointStore` is wired, tool results
     * are durable, and the per-task env (if any) is in a suspend target. No `resourceSuspend` opt-in is needed
     * (when one is set, its `scope` / `ttlMs` / `maxSlices` shape the row). The leg's readiness is reported up
     * front on the effective wiring manifest (`suspendLane`). If the yield cannot be honoured — the
     * infrastructure is not ready, or the suspend was refused without writing anything — the run CONTINUES (a
     * yield is a request, not a stop; `signal` / TaskStop are the stop) and says so once on `RunnerDeps.onError`
     * (`phase: "config"`) plus the `preempt.ignored` trace frame. The request is answered once per leg. The
     * three refusals that stop the run themselves (the slice cap, a paused VM that could not be restored, a
     * write whose outcome is unknown) still stop it.
     *
     * **Re-supply on resume:** like `resourceSuspend`/`durableApproval`, this is part of the resume task config —
     * a long task that is resumed may need re-preemption, so supply a FRESH `preemptSignal` (a new
     * `AbortController.signal`) in the resume `taskConfig` to make the resumed leg preempt-able again.
     */
    preemptSignal?: AbortSignal;
    /**
     * design/131 — per-task resilience overrides, INTENT-ONLY (no decorator
     * topology on the spec; the deployment's brain stack stays the single owner). For bench/eval or
     * critical tasks that need the provider's TRUE failure shape instead of a silent fallback:
     *  - `allowDegrade:false` — the model lane does not walk the requested model's `fallbacks` chain for
     *    this task (failure passes through).
     *  - `allowFailover:false` — cross-gateway failover is off (only the primary brain is tried).
     *  - `bypassBreaker:true` — an open circuit breaker's fast-fail is waived for THIS task; outcomes
     *    are still recorded (shared observation undiminished). Operator-facing — deployments SHOULD
     *    NOT expose this to wire users directly (it defeats provider protection).
     * All absent ⇒ exactly today's behavior. Threaded per-call as `StreamOptions.resilience`; the
     * engine's model lane and the first-party failover/breaker decorators honor it, custom brains may
     * ignore it.
     */
    resilience?: ResilienceOptions;
    /**
     * design/132 — final-verification gate (OPT-IN: `true` enables). When a task is about to end
     * NATURALLY (inside budget) and this run made at least one non-`read` tool call, the engine
     * injects a reminder to re-verify the final deliverable through its REAL entry point
     * (execute it directly; don't trust earlier self-tests or shell redirections) before finishing.
     * Oracle-grounding upgrade (docs/DESIGN-ORACLE-GROUNDING-GATE-2026-07-10.md §3.A): if the run's
     * tool-call record carried a deterministic verifiable-structure signal (raw-byte read /
     * structural parse / digest-reconciliation word-faces in shell commands — never a semantic scan
     * of closing text) and the model ends AGAIN without headroom concerns, ONE grounding re-entry
     * reminder is injected; total injections are hard-capped at 2, then the run always ends. A
     * submitted structured output and the maxTurns-1 boundary always pass through un-gated.
     * Evidence: TB full-run autopsy — the biggest shell-gap bucket (7-8 tasks) finished convinced by
     * their own fake self-check; prompt discipline alone (1.242) had a low landing rate. Opt-in
     * because the evidence is from UNATTENDED long-task legs; consumers default it OFF and expose an
     * explicit opt-in (ruled 2026-08-04). Interactive deployments choose per scenario. Read-only /
     * Q&A runs never trigger it. Telemetry: `stats.mechanisms.finalVerifyInjections`.
     */
    finalVerification?: boolean;
    /**
     * design/72 §2.2 (B): max times this task may durably suspend before the run fails with
     * `"suspend.loop"` instead of minting another checkpoint. Caps a resume/restart loop (a model that
     * re-issues the gated/egress call every resume, re-suspending forever). Counted across resume chains.
     * Default 5 (loose — a real human-approval flow re-suspends rarely, so 5 separates a normal resume from a
     * pathological loop; a deployment that genuinely needs more sets this). Overrides `RunnerDeps.maxSuspends`.
     */
    maxSuspends?: number;
    /**
     * Per-task {@link import("./checkpoint-store.js").CheckpointStore} for durable suspend/resume
     * (design/45). Overrides `RunnerDeps.checkpointStore`. Needed (with `durableApproval`) to suspend.
     *
     * THREE-VALUED (ruled 2026-08-04):
     *   · `undefined` — inherit `RunnerDeps.checkpointStore` (the historic shape, unchanged);
     *   · a store     — this run's store, overriding the deployment's;
     *   · `"disabled"` — this run explicitly has NO store, even on a deployment that wired one (`null` is refused loudly).
     *
     * The `"disabled"` arm is the per-run OFF SWITCH for the whole durable machine, meant for a run a MACHINE
     * started rather than a person (a notification redelivery, a maintenance sweep). Such a run must
     * never reach `status:"suspended"`, because the checkpoint it would mint has no operator who will
     * ever come back and resolve it — a permanently pending row plus a permanently pinned session.
     *
     * It works BY CONSTRUCTION rather than by a new rule: all four legs into `suspended` — the approval
     * park, the design/74 resource-slice pause, the design/164 platform pause (`env_lifetime` /
     * `usage_window`), and the design/80 `plan_review` pause — are already gated on a store being
     * present, so removing the store removes all four at once and the run falls into the ALREADY-TESTED
     * no-store deployment semantics: a policy `ask` resolves at a live `onAsk` when one is wired and
     * otherwise fail-closed denies; a resource/platform limit is a loud terminal (`limits.*_exceeded` /
     * `env.lifetime_expired` / `usage.window_exhausted`, still carrying `retryAfterMs`); the
     * interactive plan/question tools are not mounted (no delivery face exists). Nothing about it is a
     * second set of rules to keep in sync with the first.
     *
     * Consequence worth stating, because this field used to answer only "WHICH store": on a store-null
     * run a scheduler's yield ({@link preemptSignal}) cannot be honoured — there is no suspend to yield
     * into, so the run keeps going and says so once (`onError`, the `preempt.ignored` trace frame).
     *
     * Delegated children inherit it: the sync / background / fork spawn lanes copy the `"disabled"` word
     * into every child spec (same discipline as `principal`), so a store-less run's whole tree stays store-less.
     * The engine is the word's second setter: every fork child runs with it whatever its parent resolved (nothing resumes a fork), and so does every leg the fork spawns.
     *
     * The off switch is the WORD `"disabled"`, never `null`: a string is not nullish, so the ordinary
     * `spec ?? deps` coalesce is the whole resolution rule and no reader has to remember a special
     * null test (the retired `null` spelling is refused loudly at the first read, with the word to write).
     */
    checkpointStore?: import("./checkpoint-store.js").CheckpointStore | "disabled";
    /**
     * Restrict the injected "hand" band (design/44) to its effect:read tools for this task — read_file /
     * grep / glob (+ `bash_readonly` when a shell is available); edit_file / write_file / `bash` are not
     * mounted. This is the verifier read-only boundary (§6): an falsification-style verifier inspects but must not
     * modify the project. No effect unless an `executionEnv` is injected. Default false.
     */
    handsReadOnly?: boolean;
    /**
     * Narrow THIS leg's own hands to the read-only band ({@link handsReadOnly}'s reading: no Write / Edit / NotebookEdit,
     * the read-only shell in place of the full one) WITHOUT handing the narrowing to its children: an agent this leg spawns
     * gets exactly the hands it would get were this absent — the clamp the leg was handed, the tool selector's ceiling and
     * the host's own grant still bound it, and nothing is added (after a park and resume, where a seat opened the face; the known limits name the rest). For a leg that directs others and must not edit itself
     * (the manager recipe) while its workers keep the hands the deployment gives them. `true` or absent; any other value is
     * refused. Not a tighten-only seat: it does not travel, and a workflow script cannot declare it.
     */
    ownHandsReadOnly?: true;
    /**
     * Declare that this run carries a MEMBER LEDGER (`TaskResult.runLedger`): one row per member the run dispatched (its
     * background agents, workflow runs, peer tasks and synchronous agents) with the engine's own reading of how each ended, the run's
     * coverage and how many rows no accepted check points at, and a headline the engine computes from them. On such a run —
     * and only there — the engine also mounts the `SendUserMessage` report tool (unless the host declares its own of that
     * name), adds an `<actions>` section to its workers' completion notifications, records the ledger in the session log at
     * every delivery, runs the launch check at prepare, and gives the run one more turn when a one-shot ending's wait reaches
     * its ceiling; the workers it dispatches get no tool that starts agents (`ToolSpec.startsAgents`). A run that does not declare it is unchanged in every byte. `true` or absent; any other value is refused.
     */
    runLedger?: true; /** The manager approves its workers' plain cards (wiki `core/manager-approves`): `true` or absent, only beside `runLedger: true` (or {@link team}, which declares the ledger) on the same spec; never carried to a worker's spec. Absent ⇒ unchanged in every byte. */
    managerApproves?: true; /** Run a SAVED TEAM by its name (a `<name>.team.json` of `RunnerDeps.workflowCatalog`), read in the leg's prepare from the catalog its Workflow tool reads, asked with the same coordinates (session, scope, principal, working directory) (team-run.ts): the name must be a team it lists now (the workers the file names are not judged); the run then runs on the manager recipe's seats (`MANAGER_RECIPE`: {@link promptRole}, {@link ownHandsReadOnly}, {@link runLedger}, {@link appendSystemPrompt} = the duties, then the team's own prompt), none of which the spec may state beside it, and its ledger names the team (`RunLedger.team`). Anything else is refused (`config.invalid_argument`): a seat stated beside it, a bad name or no catalog at the entry, before the leg is prepared; a name the catalog does not list as a team in prepare. Absent ⇒ unchanged in every byte. */
    team?: string;
    /**
     * Whether this run can persist a user's "remember X" somewhere durable — the deployment's own
     * statement, overriding the runner's inference. The runner mounts a read-only-memory disclosure
     * (the model must decline to "remember" instead of receipting a save that never happens) when the
     * session provably cannot persist; provability is inferred from KNOWN store paths only (a mounted
     * file-write tool or a write-capable shell). A caller tool that persists through its own closure
     * (a custom memory writer) is invisible to that inference and would be contradicted by the
     * disclosure — set `true` to declare the channel and suppress it. Set `false` to force the
     * disclosure even when write-capable tools mount (e.g. they cannot reach any durable store);
     * a forced `false` also replaces the `# Memory` write instruction itself and drops the
     * preference-writing discipline and index seed that serve it.
     * Default: inferred. The inference also treats a REMOTE execution env's hand band as unable to
     * reach the host-side memory root (sandbox filesystem); a deployment whose remote env shares a
     * mount with the memory root declares `true` — on such a remote, `true` also restores the
     * `# Memory` write instruction when a Write tool mounts (a declared-capable session must be told
     * the path, not left silent). If your persistence channel is NOT the file face, do not mount a
     * tool named `Write` alongside the declaration, or keep the default and teach your own channel.
     * Delegation: a DECLARED value crosses the delegation boundary (sync / background / fork spawns and
     * the retained-resume snapshot alike). An explicit `false` is a FLOOR — a chosen
     * {@link AgentDefinition.memoryPersistenceCapable} `true` cannot loosen it (the disclosure is
     * about the deployment's storage, which no agent selection changes); an explicit `true` is a
     * DEFAULT the chosen definition may narrow back to `false`; absent = absent downstream too — each
     * child runs its own inference over its own roster. A retained child woken by a DIFFERENT run
     * additionally folds the waker's declared `false` on top of the spawn snapshot (tighten-only,
     * like the other resume clamps).
     * KNOWN GAP (registered, a whole-clamp-family shape — `handsReadOnly`/`interactiveTools` share
     * it): a TIER-3 durable revival rebuilds the child from the REVIVER's context (the durable row
     * records lookup keys, never a serialized spec), so the spawn-time declaration does not survive
     * that lane — the reviver's own declaration governs. The workflow lane forwards it like the Task
     * lane does (`applyParentSpecSeat` at the `agent()` launch site).
     */
    memoryPersistenceCapable?: boolean;
    /**
     * design/119 (CC --add-dir parity): extra directories the FILE tools may access in addition to the
     * containment root — each is canonicalized into the containment allowlist and listed in the
     * `# Environment` block so the model knows they're available. Same defense-in-depth caveat as the
     * root: this bounds the file tools, not `bash` (OS-level containment is the env's job).
     */
    additionalDirectories?: string[];
    /**
     * Interactive read-boundary whitelist (ruled 2026-08-05, both-arms ruling, arm A): extra directories
     * the READ faces may access — and nothing else. Joins the containment allowlist of the read-only
     * tools (read_file / grep / glob / repo_map / `bash_readonly`) and the shell read station's
     * boundary (so a provably read-only command like `head <dir>/settings.json` auto-allows instead
     * of asking on every call), but is NEVER admitted by the write faces (edit_file / write_file /
     * notebook_edit refuse these paths exactly as before). Use `additionalDirectories` when the task
     * should also write there. Same canonicalization and fail-closed skip rules as
     * `additionalDirectories`. Typical use: a deployment's own user-config directory in an interactive
     * assembly, where a read-classifying shell gate would otherwise consult the approver for every config read.
     */
    additionalReadDirectories?: string[];
    /**
     * design/199 件B / #4800 — TASK-layer ADDITIONS to the sensitive-path deny set
     * ({@link import("../tools/fs/read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}). Judged on BOTH the read
     * faces (Read/Grep/Glob/RepoMap, their traversals, the compaction attachment reader, and the shell READ
     * STATION under every mode — full shell `Bash`/`Monitor` and `bash_readonly` alike) AND the write faces
     * (`Write`/`Edit`/`NotebookEdit`/`SaveToolResult` at the gate's file write station; on the shell, the write
     * targets a command spells as literal operands): a matching read or write is REFUSED (`deniedBy: "read_boundary"`
     * at the gate, zero approval cards, zero classifier calls) in every permission mode and both containment faces.
     * The shell station is not containment: shell-made paths, hard links and mounts of the same bytes, a rename in an
     * earlier call are not covered — their floor is the execution environment's containment (wiki page
     * protected-removals-and-reads). Built-in tiers stay read-only (their write side is the write-protection table).
     * Add-only at the task layer: entries here UNION with the active built-ins and the deployment's {@link RunnerDeps.readDenyPatterns};
     * `[]` ≡ absent; nothing here removes a built-in — the deployment's built-in configuration does ({@link RunnerDeps.readDenyBuiltinTiers} /
     * {@link RunnerDeps.readDenyBuiltinExclude}; for the Read tool alone, the row it lets a request release: {@link readDenyBuiltinExclude}). An
     * unconfigured deployment judges {@link import("../tools/fs/read-deny.js").READ_DENY_DEFAULT_TIERS}. Bad entry shapes refuse loudly at prepare (#123). */
    readDenyPatterns?: readonly import("../tools/fs/read-deny.js").ReadDenyEntry[];
    /** Built-in read deny rows this request releases for the structured Read tool on its leg; each must be granted by `RunnerDeps.readDenyBuiltinRequestExcludable` (else `config.invalid_argument` at the door). The Read tool reads the file (keys in it reach the record); the shell, the search tools and the attachment carriers still refuse it; a structured change of it needs a person in every mode, refused with nobody to ask. Not carried to children, continuations or parked seeds. */
    readDenyBuiltinExclude?: readonly string[];
    /**
     * TASK-layer rows ADDED to the write-protection table ({@link readDenyPatterns}' law): the run's table is the deployment's
     * ({@link RunnerDeps.writeProtectedPaths}) UNION these; `[]` ≡ absent; no task-layer value removes a deployment row. A
     * covered write is the judge's mandated ask (`write_protection`), as for a deployment row. Bad shapes refuse at prepare
     * (`config.invalid_argument`); rides every engine-built child spec add-only.
     */
    writeProtectedAdditions?: readonly import("./write-protect.js").WriteProtectedEntry[];
    /** The CALLER's configuration roots, for a host on an engine it did not start (absolute existing directories; absent ⇒ the
     *  deployment's root alone): add-only beside {@link RunnerDeps.agentConfigDir}, the `~/.sema/…` read deny rows and the write
     *  table's `.sema` rows are placed below each. Bad ⇒ `config.agent_config_dir_invalid`. Rides children and parked rows. */
    agentConfigDirs?: readonly string[];
    /** The CALLER's homes, for an engine running under another home (absolute existing directories): the home-anchored read
     *  deny rows are also placed below each, add-only; nothing else reads the list. Bad ⇒ `config.agent_home_dir_invalid`. */
    agentHomeDirs?: readonly string[];
    /**
     * TASK-layer denies ADDED to the compliance posture ({@link readDenyPatterns}' law): the run's deny set is the deployment's
     * ({@link RunnerDeps.compliancePostureResolver}) UNION these; `[]` ≡ absent; nothing here removes a deployment deny. A hit
     * is refused exactly as a deployment deny is. Members outside the closed capability set refuse at prepare
     * (`config.invalid_argument`) — never a silently dropped deny; rides every engine-built child spec add-only.
     */
    complianceAdditionalDenies?: readonly import("./compliance.js").ComplianceCapability[];
    /**
     * design/199 件A — the TASK layer's read-face containment declaration
     * ({@link import("../tools/fs/containment-face.js").ContainmentFace}). "roots" pins this task (and, via the
     * tighten-only clamp, its whole delegation subtree) to the historical containment; "open" lifts
     * the roots judgment for the structured read faces — refused loudly under org governance (the
     * task layer only tightens there; the deployment opens via {@link RunnerDeps.readFace}) and
     * beside `handsReadOnly: true` (the verifier containment is load-bearing). Absent ⇒ the
     * deployment seat, then the engine default ("roots" — D-1b: an upgrade never opens implicitly).
     * Bad values refuse loudly (#123). Never affects the write faces — that is {@link writeFace}, a
     * separate seat with its own default.
     */
    readFace?: import("../tools/fs/containment-face.js").ContainmentFace;
    /**
     * The TASK layer's WRITE-face containment declaration
     * ({@link import("../tools/fs/containment-face.js").ContainmentFace}) — the read seat's twin,
     * resolved through the SAME order (`resolveContainmentFace`, one body, one set of rows). "roots"
     * pins this task (and, via the tighten-only clamp, its whole delegation subtree) to the historical
     * write fence; "open" lifts the roots judgment for the structured WRITE faces (`edit_file` /
     * `write_file` / `notebook_edit`) — refused loudly under org governance (the task layer only
     * tightens there; the deployment opens via {@link RunnerDeps.writeFace}) and beside
     * `handsReadOnly: true` (that mount carries no write faces at all). Absent ⇒ the deployment seat,
     * then the engine default ("roots" — an upgrade never opens implicitly). Bad values refuse loudly.
     *
     * What "open" does NOT change: the write-side sensitive-path policy, the blocked-device gate, the
     * UNC out-of-set refusal, the read-before-edit requirement and the deployment's approval policy. Seat
     * independence is owned by `fs.containment_face.seat_independence` ({@link import("../tools/fs/containment-face.js").resolveContainmentFace}).
     */
    writeFace?: import("../tools/fs/containment-face.js").ContainmentFace;
    /**
     * design/80 D-B — opt in to PLAN MODE: mount the first-party `present_plan` tool (CC `ExitPlanMode` parity).
     * The model calls it from plan mode (`permissionMode: "plan"`, the model's `EnterPlanMode`, a `setPermissionMode("plan")` steer) to present a plan; the
     * engine then pauses with a durable `plan_review` checkpoint (`status:"needs_review"`) so a human approves/edits/rejects before any action — called outside plan mode, it answers with an error result and nothing pauses. Typically paired with
     * `handsReadOnly:true` (research read-only until the plan is approved, then the resume drops it). Default
     * false — when unset the tool is NOT mounted, NOT disclosed, and a `ToolReturn.requestReview` is ignored, so
     * a non-plan-mode task is byte-identical. Needs a `checkpointStore` wired to actually pause (else a
     * `requestReview` is a no-op). The tool is a thin composition over the general `requestReview` primitive.
     */
    enablePlanMode?: boolean;
    /**
     * The absolute path of THIS session's plan file in the leg's execution environment (the reference's `<plans dir>/<slug>.md`).
     * Where the plan lives is one fact: declared, the plan is that file — admitted by the advertised-writable seat (its third
     * advertiser), so the file tools' root fence (write + read) and every mode's write gate admit it without a question, the
     * write-protection table does not demote it, `ExitPlanMode` takes no `plan` and reads it, and the planning frames name it;
     * absent, the plan is `ExitPlanMode`'s `plan` argument and no plan file exists (byte-identical to a run before this seat).
     * The fence and write gates admit the path and anything beneath it until #2746 (KL-1503-a); the table exempts exactly the
     * file; siblings, a link swapped in later and every deny row stay as they were. The host creates the file's directory
     * before the run. Refused with `config.plan_file_invalid` (the run never starts): not an absolute string in lexical normal
     * form that the model can be told verbatim; a link, directory or other non-file leaf; a parent that is not a directory;
     * hands absent or read-only; a key holding a fence root. Not inherited by a delegated child, a fork or a workflow step.
     */
    planFile?: string;
    /**
     * Interactive-tool mounting override (AskUserQuestion / ExitPlanMode /
     * EnterPlanMode share one `isEnabled` gate — in non-interactive mode without an SDK permission-prompt
     * tool the tool is NOT offered at all, so the model never asks into the void). sema's automatic
     * criterion (this knob unset): a human-facing tool mounts only when the deployment has SOME face that
     * can deliver it to a person —
     *   · `AskUserQuestion`: a live `onQuestion` (spec ?? deps), OR a durable park consumer = a wired
     *     `checkpointStore` AND (`durableApproval` opted in OR a `forceDurableGate` entitlement on a root leg) — the
     *     approval-center posture (≅ CC's SDK permission-prompt-tool exception).
     *   · `present_plan` (within `enablePlanMode`): a wired `checkpointStore` — the `plan_review` park's
     *     only consumer (without one the pause is a silent no-op the model mistakes for a delivered plan).
     * Neither face ⇒ not mounted, not disclosed (a bare headless run must not park on a question nobody
     * will answer and then be projected as an empty success). Override: `true` ⇒ always mount (the
     * deployment consumes asks some other way; `enter_plan_mode` still requires a `checkpointStore` —
     * without one its read-only latch would be inescapable); `false` ⇒ never mount (hard headless);
     * unset ⇒ the automatic criterion. `enablePlanMode` stays the plan family's opt-in — this knob never
     * mounts plan tools on its own.
     */
    interactiveTools?: boolean;
    /**
     * design/110 / design/136 §2.1.a (⚠️ BREAKING semantics change) — the per-task FORK governance gate for
     * `Agent(subagent_type:"fork")` (the standalone `Fork` tool was retired; the capability lives in the Agent
     * tool's `subagent_type` value domain — CC-exact shape). The fork spawns a child that INHERITS this
     * conversation's full context (vs the clean-context delegation) and shares the prompt-cache prefix.
     *
     * OPT-OUT default (flipped from the pre-136 opt-IN): `undefined`/`true` = fork is AVAILABLE, bounded by the
     * session capability (`hasSessionFork` durable store + a session id + not inside a fork — honest refusal
     * otherwise); an EXPLICIT `false` = fork is DENIED for this task with the honest `fork.disabled` result
     * (never a silent downgrade); `RuntimeCaps.allowFork` denies it per principal.
     */
    enableFork?: boolean;
    /**
     * The OPERATOR's shell floor: `"always"` ⇒ every `bash` / `Monitor` command is a confirmed ask (an
     * `operator_forced` ask — kept under `bypassPermissions`, refused by `dontAsk` like every ask; a standing allow rule never
     * clears it). Absent ⇒ no floor: the shape tier the engine installs on every full shell (a provably read-only
     * single command runs, everything else asks) is arbitrated by the task's {@link permissionMode}. The retired
     * values `"off"` / `"classify"` are refused at the door (`config.shell_gate_value_retired`): the tier is no longer a
     * doctrine a caller chooses, and the read boundary is judged on every shell call under every mode. A positive
     * per-tool mark keeps its seat (an explicit `irreversibility:"always"` is never downgraded). No effect under
     * `handsReadOnly` or with no execution env. Re-supplied on resume like `toolPolicy` (a checkpoint carries the
     * chain's floor). Delegation: the floor travels the inherited-gate lane; a child cannot lift it.
     */
    shellGate?: ShellGateDoctrine;
    /**
     * The task's PERMISSION MODE — the ONE key that says how the engine answers a surviving ask (six words,
     * {@link import("./ask-origin.js").PERMISSION_MODES}; spelled as the wire spells it). ROOT task absent ⇒
     * `"default"`; an engine-spawned CHILD absent ⇒ its parent's effective mode (a child's own declaration is
     * adopted only where the reference implementation's rank table admits it under the parent's — a folded
     * declaration is disclosed on `wiring_manifest.permissionMode.foldedBy: "inherited_ceiling"` and announced,
     * never silent). A value outside the set is refused at the door (`config.permission_mode_invalid`).
     *
     * What the mode DOES is one table and one predicate ({@link import("./ask-origin.js").MODE_ARBITRATION},
     * {@link import("./ask-origin.js").arbitrateByMode}) read after every rule, tighten and classifier station:
     * `bypassPermissions` releases every ask but the immune classes (an explicit ask rule, a hook's ask, the
     * question tool, an unverifiable recursive delete, an org rule, an operator's forced confirmation, unreadable
     * governance, the classifier's denial-limit fallback) and discloses each release; `dontAsk` refuses every ask
     * but a hook's own (no rule or safety check also asked); `auto` arms the classifier (`RunnerDeps.autoMode` present and
     * `RuntimeCaps.autoMode` not `false`, else folded to `default` and announced); `plan` reads only and mounts the
     * plan pair; `acceptEdits` writes inside the root without asking; `default` asks. The mode also installs its own
     * seats ({@link import("./mode-policy.js").modePolicyOf}).
     *
     * `bypassPermissions` is a REQUEST: it takes effect only where the deployment does not deny it
     * ({@link RuntimeCaps.bypassPermissions} not `false`); a denied request runs in `default`, announced
     * (`config.permission_mode_unavailable`). A running leg changes mode through `TaskStream.setPermissionMode`.
     * Persists on the checkpoint's data half (`CheckpointState.inheritedGate.permissionMode`), re-judged on every leg.
     */
    permissionMode?: PermissionMode;
    /**
     * In `auto` mode, let no shell allow entry clear a call — the classifier judges it (the reference's
     * `autoMode.classifyAllShell`). `true` ⇒ while the mode is `auto` (read per call), the whole shell tool, a name that reaches
     * it and every `Bash(…)` rule whatever it names stand down — in stored rules, a skill's `allowed-tools`, {@link allowedTools}
     * and the deployment's list alike. Absent / `false` ⇒ only the entries that hand over arbitrary code stand down. Narrows only;
     * outside `auto`, and for deny / ask rules, a hook's allow, non-shell entries and a read-only command, nothing changes. Which settings planes may set it is the host's
     * reading (the reference: user, flag and managed settings, never a repository's own); the host sends its allow lists
     * unchanged beside it. Tighten-only: `tightenTaskSpec` keeps a baseline's `true`, an engine-built child inherits it. A
     * present non-boolean refuses the run (`config.invalid_argument`).
     */
    classifyAllShell?: boolean;
    /**
     * Refuse reads outside this task's directories, in every permission mode, without asking (the reference's
     * `permissions.blockReadsOutsideWorkingDirectories`). `true` ⇒ the file read tools (Read, Grep, Glob, RepoMap, LSP — images,
     * PDFs and notebooks through Read) and the Artifact tool's local read refuse a target outside the task's directories at the
     * gate, before any question (`tool_end.gate.disposition.deniedBy: "read_boundary"`, card `path_not_in_root`); so do they every
     * read the tool would refuse itself (a deny row, a target it cannot resolve). The directories are the DECLARED ones — the
     * leg's own read roots (the task root, the write location, `additionalDirectories`, `additionalReadDirectories`, the
     * directories the host advertises as writable) — never a person's `Read(//dir/**)` allow rows (either partition), and no
     * directory is granted mid-run (no card offers one). A shell read outside them stays the question it is
     * (the read-only shell's refusal included), against the same directories. Absent / `false` ⇒ today's behaviour, byte for
     * byte. A task-layer `readFace: "open"` beside it refuses the run (`config.read_face_read_block_conflict`); a deployment
     * `readFace: "open"` is clamped to "roots" on such a leg, announced once per notice sink
     * (`config.read_face_deployment_clamped`, `detail.cause: "read_block"`). Which settings planes may set it is the host's
     * reading (the reference: any settings source that says `true` wins); the engine never persists it beyond the run's own park
     * row (`CheckpointState.readBlock`, which a resume keeps). Tighten-only: `tightenTaskSpec` keeps a baseline's `true`, every
     * child the engine builds inherits it. A present non-boolean refuses the run (`config.invalid_argument`).
     */
    blockReadsOutsideRoots?: boolean;
    /** Task-scoped MCP servers, materialized into tools then disposed. */
    mcp?: McpServerSpec[];
    /** Task-scoped A2A peers (remote agents), whose advertised skills mount as `a2a__<peer>__<skill>`
     *  tools for this task. Every mounted skill is an external write by default — see {@link A2aServerSpec}. */
    a2a?: A2aServerSpec[];
    /**
     * Task-scoped skills (object form). Two first-party halves (design/71 黑盒#5 fix; [c209-C] R2 C8
     * delivery reality): a `<skills>` disclosure block listing name+description (deterministic order,
     * capped) delivered as a `<system-reminder>` on the FIRST user turn — plus boundary drift deltas —
     * NOT part of the stable system prompt (design/C moved it off the cached prefix), and an
     * injected `skill` tool (effect:read) that returns the skill's FULL content as a tool result —
     * no invoke-time truncation (CC parity; the only doors are a 1MB per-skill load gate at spec
     * assembly, which REJECTS an oversized skill whole with a config-phase error, and the
     * compaction-time invoked-skill retention caps). Duplicate names: first wins. The name
     * `skill` becomes reserved when this field is non-empty (`config.reserved_tool_name`).
     *
     * Skill content is CALLER-trusted — same trust level as `systemPrompt`. Callers forwarding
     * end-user-authored skills are responsible for vetting them: a skill IS instructions by design.
     */
    skills?: SkillSpec[];
    /**
     * The skills THIS run's human input invoked by name (a shell that parsed `/name` from the person's line), by
     * {@link SkillSpec.name}. Each one's {@link SkillSpec.allowedTools} / {@link SkillSpec.disallowedTools} take effect
     * at the start of the run with no `Skill` call and no card — the person's own invocation is the statement — and last
     * for this run (a steer does not end them; the next runTask starts without them), like a grant the model's activation wrote. Delivering the skill's body
     * stays the caller's business (this key carries names only). Every name must be one of this run's {@link skills};
     * anything else refuses the run before it starts (`config.user_invoked_skill_unknown`), never dropped. Present only
     * when the person actually invoked one; a mid-turn invocation (one riding a steer) grants nothing.
     */
    userInvokedSkills?: string[];
    /**
     * This run's ALLOW RULES — the reference implementation's `allowedTools` (its `--allowedTools` list): each entry, in the
     * rule grammar a skill's `allowed-tools` reads ({@link SkillSpec.allowedTools}), is a standing yes for this run. A
     * whole tool name (`Write`, `Bash`), a protocol namespace (`mcp__srv`, `mcp__srv__*`), a shell command rule
     * (`Bash(git:*)`, `Bash(npm test)`) or a Read directory (`Read(//srv/data/**)`) clears the question the permission
     * layers raise for a call it covers — read in the allow layer beside a person's stored rules, a skill's list and the
     * deployment's {@link import("./runner-deps.js").RunnerDeps.allowedTools}, under the same predicate: deny and ask rules
     * still win, and a question no allow rule clears (a mandated, governance, hook or plan question) is still put to a person,
     * with the entry disclosed on the card. In `auto` mode an entry that hands over arbitrary code (the whole shell, an
     * interpreter or launcher prefix) is left to the classifier — every shell entry, under {@link classifyAllShell}.
     *
     * Lives for this run — the steers it takes in included; a delegated child holds the entries until it ends; a resumed leg
     * holds them only when its spec supplies them again (they are not written into a checkpoint). An entry this grammar
     * reads as nothing (`*`, `mcp__*` / `mcp__*__*`, a write-path or domain pattern) grants nothing and is announced at the start of the
     * run (`config.entries_not_applied`, kind `allow_entry_inert`); the entries beside a `*` keep their own reading (it is one entry that grants nothing, not a list that does). A value that is not a list of
     * strings refuses the run before it starts (`config.invalid_permission_rules`, with its issues).
     *
     * A member may carry its rule SET's anchors, `{ rule, pathBases }` ({@link AllowListEntry} — the seat and the reading of a deny /
     * ask set's `pathBases`: a user layer's `/x` allow reaches `<config>/x`); one that is not exactly that refuses the run.
     */
    allowedTools?: readonly import("./allow-entry.js").AllowListEntry[];
    /**
     * Fraction of the model's context window the `<skills>` listing may spend. Absent ⇒ `0.01` (1%).
     * Domain `(0, 1]`; anything else — including `0`, a string, `NaN` — REFUSES at the door with
     * `config.skill_listing_budget_invalid` rather than folding back to the default.
     *
     * The budget is `(contextTokens ?? contextWindow ?? 200 000) × 4 × fraction`, in UTF-8 bytes, and the
     * listing degrades inside it: every skill stays listed, the lower-priority ones (declaration order)
     * lose their descriptions first. Raising this is opting in to a higher per-turn context cost.
     *
     * Enforced as declared (`@contract skills.listing_budget_enforced_as_declared`): the listing frames are
     * intact-class turn attachments the delivery lane never clips, so the resolved budget has no ceiling
     * above it — a fraction that asks for more gets more (a 1 000 000-token window at the default 0.01 is
     * 40 000 bytes). The same fraction is EACH listing attachment's budget: the agent-type roster frame
     * folds into `window × 4 × fraction` too (every type stays listed, the last-declared lose their detail
     * first; `agents.listing_truncated` reports it).
     *
     * ⚠️ A model declaring a window SMALLER than 200 000 tokens now gets a proportionally smaller listing
     * budget than the flat 8 000 bytes that preceded this seat.
     */
    skillListingBudgetFraction?: number;
    /**
     * Per-skill description cap inside the `<skills>` listing, in code units, ellipsis included. Absent ⇒
     * `1536`. Must be a positive integer; anything else REFUSES with
     * `config.skill_listing_budget_invalid`. A description longer than the cap is truncated to exactly
     * this many units; lowering it is how a deployment fits more skills' descriptions inside one budget.
     */
    skillListingMaxDescChars?: number;
    /**
     * design/129 — lifetime scope for BACKGROUND children (Agent/Fork `run_in_background`). Default `"task"`:
     * the parent runTask's terminal reaps them (design/115 — no orphans burning tokens; turn-end killed
     * frame). `"session"`: children OUTLIVE the turn (CC Backgrounded semantics) — registered under the
     * SESSION owner (a later turn's TaskStop and the host poll reach it), skipped by the parent-teardown reap, and given NO engine
     * default wall-clock ceiling (design/164: a task-level ceiling is stated by the caller or absent). It is collected by the host
     * calling `TaskRegistry.reapSessionBackground(sessionId, scope)` from its session release/sweep, and — for a child gone SILENT —
     * `TaskRegistry.reapStaleSessionBackgroundAgents(staleMs)`, which collects by stall, not by age, at a threshold the caller
     * chooses (the engine ships no default), and not while the child holds a call at its gate for an approver. `TaskRegistry.countRunningSessionBackgroundAgents()` reads how many are in flight.
     * CALLER-trusted (systemPrompt tier): never a model-facing parameter, never on the governed workflow
     * whitelist — a child's lifetime crossing the turn boundary is an isolation-contract surface.
     */
    backgroundScope?: "task" | "session";
    /**
     * The command sandbox this task requires: the reference's `sandbox` settings under their own key names
     * ({@link TaskSandboxSettings}; `enabled: true` puts it in force). In force, every command the model's shell tools
     * start runs inside the OS sandbox of the environment it runs on — the boundary is these settings' filesystem and
     * network lists plus the task's write roots, the run's read-deny table beside them — or is not started. An environment
     * that keeps no command sandbox (`capabilities.commandSandbox`) refuses the run at prepare
     * (`config.command_sandbox_unavailable`), unless `failIfUnavailable` is `false`, which announces it under the same code
     * and runs the commands unsandboxed. A value that is not the settings' shape, a key they do not carry (the two merge-time
     * keys included), or a path that is neither absolute nor `~/` refuses the run (`config.sandbox_settings_invalid`, naming
     * the key). A delegated child runs under its parent's requirement as a floor (`mergeChildSandbox`).
     * DEPLOYMENT-trusted: the members that would loosen it are the host's to admit from its settings sources; never a
     * model-facing parameter.
     */
    sandbox?: TaskSandboxSettings;
    /**
     * A1 — structured SANDBOX facts for the `# Environment` block, so the agent knows what
     * toolchains the environment already carries (no blind reinstall), which package source installs go
     * through, and whether the network is reachable at all (egress=none ⇒ don't burn budget on downloads).
     * DEPLOYMENT-trusted (systemPrompt tier — the deployment knows its own sandbox binding): rendered
     * sanitized+bounded by prepare-task; never a model-facing parameter, never on the governed workflow
     * whitelist. All fields optional; absent ⇒ block unchanged.
     */
    envFacts?: {
        /** The bound sandbox image profile (e.g. `dev-mobile`). */
        profile?: string;
        /** Toolchains/capabilities the image carries (e.g. `android-sdk`, `gradle`). Rendered bounded. */
        capabilities?: readonly string[];
        /** Which package-source lane installs go through (e.g. `cn` | `global` | `custom`). */
        pkgSource?: string;
        /** Outbound-network posture. `none` renders an explicit "downloads will fail" caveat. */
        egress?: "none" | "allowlist" | "full";
        /** Session-specific scratch directory for temporary files (CC Scratchpad parity, 1.257.3): when set,
         *  the environment block instructs the model to use this dir instead of `/tmp` — prevents parallel
         *  tasks trampling each other's temp files and project-dir pollution. Unset ⇒ no section rendered. */
        scratchpadDir?: string;
        /**
         * B-half — PER-LANE resume-continuity facts, rendered ONLY on a durable-resume leg so
         * the model reasons honestly about what survived the suspension. DEPLOYMENT-supplied per its own lane
         * capability (a VM snapshot lane preserves processes; an ssh park-only workspace usually keeps /tmp;
         * a rebuilt container loses both) — core hardcodes NO lane table and renders NOTHING when a field is
         * absent (an unstated fact must not become a confident sentence; a blanket "lost" wording would
         * misinform the model on lanes where the state genuinely persists). All fields optional.
         */
        resumeFacts?: {
            /** Whether processes started before the suspension are still running after resume. */
            processes?: "preserved" | "lost";
            /** Whether out-of-workspace temp state (e.g. `/tmp`) survived the suspension. */
            scratch?: "preserved" | "lost";
            /** Free-form lane-specific caveat (sanitized + bounded at render). */
            note?: string;
        };
    };
    /**
     * design/164 — the SINGLE task-limit surface. Every budget axis lives here (the former top-level
     * `maxTokens` / `maxCostUsd` / `budgetStreamCancel` / `degrade` were folded in), and **every axis is
     * DEFAULT-EMPTY**: a task with no `limits` runs with no engine-imposed turn / token / cost / wall-clock ceiling at all.
     *
     * Consequence, stated plainly (ruled 2026-08-04): a zero-config runaway has NO task-level backstop.
     * What still binds is the ENGINEERING GUARDRAIL family — {@link TaskLimits.brainCallGuardrailMs} (a
     * brain call that never settles), the stall watchdogs, and the deployment's own usage governance. Those
     * answer "did the system hang", never "how much may this task spend"; the second question is the
     * caller's to answer, by setting a limit here.
     */
    limits?: TaskLimits;
    /**
     * Config-catalog override declarations (ruled 2026-07-19, anti-chaos contract): a HOST that
     * overrides a recommended knob at its own layer (env cap, adapter flag, harness default) declares
     * it here — key + value + REASON — so the override rides the `config.assembled` trace with
     * provenance `host-declared` instead of being invisible to forensics. Advisory observability
     * metadata only: declarations never change an effective value (set the real field for that).
     * See `describeConfigCatalog()` for the recommended scale.
     */
    configOverrides?: ReadonlyArray<import("../config/catalog.js").ConfigOverrideDeclaration>;
    /**
     * Subagent viewing pane (dogfood finding 2026-07-03): widen the opt-in display sink
     * (`RunInternals.onForwardEvent`) from `task_progress`-only to a SUBAGENT's live CONTENT events
     * (`text_delta` / `text_end` (#447) / `reasoning_delta` / `reasoning_end` / `tool_start` / `tool_end`), so a UI can render a delegated
     * child's transcript live. Default OFF (progress-only, prior behavior). The child stream is still
     * NEVER merged into the parent's model context — this is purely a render channel; forwarded events
     * carry `parentToolCallId` (attribution) and the same UNTRUSTED-RAW contract as the main stream's
     * `tool_start.args`/`tool_end.output` (consumer MUST redact — design/99 §E1). Single-level: each
     * delegation level opts in for ITS direct children.
     */
    forwardSubagentEvents?: boolean;
    /**
     * design/122 D1 — RETAIN sync sub-agent sessions after they settle so an operator can RESUME (revive) a
     * finished child with a new prompt via {@link import("../agents/subagent.js").SubagentSteerHandle}'s
     * `resume` verb (CC `dfe` resumeAgentBackground parity). Default OFF = prior behavior byte-for-byte:
     * child sessions are throwaway (released eagerly after the delegation returns).
     *
     * ON (`true` or a config object): each SYNC delegation spawned while the deployment's
     * `RunInternals.onSubagentSpawn` sink is wired (the handle-emitting path — without a handle there is no
     * resume capability, so retaining would be a pure leak) pre-mints the child's sessionId, PINS it against
     * the store's idle sweep, and SKIPS the eager release. The session is retained in a parent-run-scoped
     * ledger until `ttlMs` after settle (default 30 min), eviction past `max` retained children (default 16),
     * or the PARENT run reaching a terminal state — whichever comes first; then it is unpinned + explicitly
     * released (throwaway semantics restored — a retained session never dangles to the store's 7-day TTL).
     * `run_in_background` children are OUT OF SCOPE (no handle, no retain — r1-M3; the bg lane's resume needs
     * durable support and is a separate item). Resume is reachable only while the parent run lives (the
     * ledger is run-scoped, not a durable registry).
     */
    retainSubagentSessions?: boolean | {
        ttlMs?: number;
        max?: number;
    };
    /**
     * Keep BACKGROUND PROCESSES this task started (background bash shells / monitored processes) ALIVE
     * after the task reaches a terminal state, instead of the default run-teardown reap. Default `false`
     * = current behavior byte-for-byte: the teardown settles this run's shell-lane children and disposes
     * the env's background shells.
     *
     * `true` = the "deliver a living service" contract (the task's deliverable is a running daemon that
     * must survive for a later probe/consumer): the run teardown neither kills nor disposes this task's
     * background processes. Semantics are BEST-EFFORT "do not actively kill":
     * - **OR-composed with the env-level opt-in** (e.g. `NodeExecutionEnv({ retainBackgroundProcesses })`):
     *   either being `true` retains. The env-level lane is the stronger form — it also spools child stdio
     *   to files at SPAWN time, so retained processes survive the host process exiting; a spec-level
     *   retain keeps processes alive past the task, but their stdio may still be tied to host pipes.
     * - A per-task ISOLATED owned env (container/VM) still destroys its processes with the env teardown —
     *   retention there would be illusory, so the teardown keeps its honest killed receipts instead.
     * - win32: best-effort "no active kill" only; without detached process groups, process-tree survival
     *   past the host is a platform boundary (some children may still exit with it).
     * - Automatic reaps leave a retained process alone: the run-teardown sweep (settle + dispose), the
     *   session-release reap, and the exit-boundary hard face under `includeRetained: false`. What still ends
     *   it: the TaskStop tool, its per-shell background timeout (while the host runs), env destruction, and the
     *   hard face under `includeRetained: true`. The row carries the lane it was launched under (a later run's
     *   declaration does not re-label a session-resident row) — see docs/background-process-lifetime.md.
     * - NOT inherited by delegated child tasks: each child's own spec decides for the child's own
     *   background processes.
     */
    retainBackgroundProcesses?: boolean;
    /**
     * **Structured output** (1.41): constrain the task's FINAL result to this JSON schema (a typebox
     * object schema). Injects a built-in `StructuredOutput` tool whose parameters ARE this schema; the model
     * calls it to finish, the validated object is surfaced as `TaskResult.structuredOutput`, and the task
     * ends. Provider-agnostic (it's just a tool). If the model can't produce a valid object within a few
     * tries the task fails with `errorCode="output.invalid"`. While this is set, a caller tool named
     * `StructuredOutput` is rejected (reserved). The model may still answer in prose (then `structuredOutput`
     * is undefined) or call `ReportBlocked`. Cast the result with `Static<typeof yourSchema>`.
     */
    outputSchema?: TSchema;
    /**
     * How many times the model may **retry** a rejected `StructuredOutput` call before the task fails with
     * `errorCode="output.invalid"` (only meaningful when {@link outputSchema} is set). `0` = fail on the
     * first invalid submit (no in-loop retry); the caller decides whether to re-run. Default `2`
     * (3 total attempts). Clamped to a non-negative integer. This bounds only the *in-task* retry of a
     * malformed object — it is not an auto-fixer; pair it with a caller-side retry on `output.invalid`.
     */
    outputRetries?: number;
    /** Best-effort fire-and-forget trace sink (task/turn/brain/tool). Overrides `RunnerDeps.tracer`. */
    tracer?: import("./trace.js").TracerHook;
    /** Per-task override of the large-tool-result offload threshold (chars); see `RunnerDeps.toolResultThresholdChars`. */
    toolResultThresholdChars?: number;
    /**
     * Override auto-compaction thresholds for this task's session. Compaction (LLM summary, persisted
     * to the session) is judged before a request, in two places sharing these settings: before each request that follows a
     * turn boundary (design/64 §25 (A) — the long-single-task case) and before a run's first request (the between-task case).
     * Defaults: both seats on (`autoCompact` / `manualCompact` below), reserveTokens 16384 (else `contextSettings[word].reserveTokens`; a value stated here is the author), keepRecentTokens 0 (design/169-C; 20000 was the
     * pre-169 default). A zero budget is NOT "no verbatim tail": the cut-point search has a
     * structural floor under the budget, so the default already leaves the last exchange verbatim
     * after the summary (a trailing tool-result batch keeps its emitting assistant with it) — the
     * same one-group posture CC's reactive compaction ships. Set `keepRecentTokens` explicitly only
     * to keep a WIDER tail than that. Repaired
     * automatically when
     * pathological for the model's window: threshold ≤ 0, keepRecent ≥ threshold, or a threshold above
     * the clearStale point (0.7×window — the prefix-cache "death band", design/64 §26.4) is clamped
     * down to it. The clamp applies to explicit values too (the clearStale point is not configurable,
     * so a threshold above it cannot express consistent intent); explicit values below all three
     * bounds are never overridden (see `sanitizeCompactionSettings`).
     * `instructions` is appended to the summarization prompt — use it to guarantee critical
     * facts survive (e.g. "preserve verbatim any codes, IDs, names, and explicit user instructions").
     * design/145 §4 hygiene (every instructions channel, incl. a `TaskStream.compact({instructions})`
     * per-call override and a preCompact hook's additions): break-out tags (`</system-reminder>`) and
     * fence sentinels are defused, and the text is capped at 2048 code points; clean text under the
     * cap passes through byte-identical.
     * `instructions` rides every summarization request a pass sends (one per pass: the kept tail starts
     * at a group's opening, so no turn is split and no separate turn-prefix request exists).
     * The automatic pass is judged before a request, never after one: before a run's first request, and before each request
     * that follows a turn boundary — a run past its answer is not compacted, the session's next run compacts at its start.
     * `withinTask: false` keeps the run-start judgment but disables the ROUTINE within-task
     * (turn-boundary) trigger — the escape hatch for the §25 (A) control-flow change; the system
     * prompt then stops claiming ROUTINE mid-task summarization (§6.3 honesty). It does NOT silence
     * the recovery-class forced lanes (design/374 slice 3): a prompt-too-long recovery or the guard
     * chain's arm B may still legitimately compact WITHIN the task — error/pressure recovery is not
     * a routine boundary pass, so a within-task compaction under this flag is contract-conforming.
     * `attachWorkingFiles` (LONGRUN-2; **default ON since 2026-07-03** — the reference hard-codes its
     * post-compact file restore, and LONGRUN-2 measured ≈2.3 extra read round-trips per compaction
     * without it): after each compaction, re-read the task's most recently READ files (CC
     * readFileState semantics; else modified-by-recency) the summary leaves out of view, with the Read tool's
     * read, into attachment frames after the summary (`maxFiles` default 3, `maxCharsPerFile` default 16k chars
     * of the file's own text, a total cap ~15% of the window in the file contents the frames send, line numbers
     * included; a file over either is named, never sent in part). The `compacted` wire event lists the files whose contents were delivered as `attachedFiles`
     * (shell renders CC's post-compact Read cards). `false` opts out; an object customizes caps;
     * no-op when the task has no execution env (no hands, nothing to re-read).
     */
    compaction?: {
        /** The passes the engine starts by itself (the lanes: {@link compactionEnabled}); `false` switches them off. Absent ⇒
         *  `RunnerDeps.contextSettings[word].autoCompact`, else on. A non-boolean refuses the run (`config.invalid_argument`). */
        autoCompact?: boolean;
        /** The passes a caller asks for; `false` answers each `"disabled"`, no summary call. Absent ⇒ the deployment's
         *  `manualCompact`, else on. The retired `enabled` (both at once) is refused by name (`config.spec_retired_key`). */
        manualCompact?: boolean;
        withinTask?: boolean;
        reserveTokens?: number;
        keepRecentTokens?: number;
        instructions?: string;
        attachWorkingFiles?: boolean | {
            maxFiles?: number;
            maxCharsPerFile?: number;
        };
        /**
         * design/169-F (lightweight-clear posture) — OPT-IN stale
         * tool-result offload, a projection-layer clear below full compaction: in the REQUEST sent to
         * the model, same-tool results older than the most recent `keepRecentPerTool` are replaced by a
         * short pointer ("offloaded … saved to persisted output ref …", readable back via the
         * `read_tool_result` tool) once the replacement saves ≥ `minSavingsChars` chars. The on-disk /
         * session transcript is NEVER rewritten (append-only + projection is this repo's constitution);
         * only the outgoing request projection changes. Replacement decisions are BYTE-STABLE across
         * turns by construction (a result is replaced exactly when ≥ keepRecentPerTool newer same-tool
         * results exist — monotone, so a decision never reverses — and the pointer text is a pure
         * function of the result), so provider prompt-cache prefixes are never churned by re-decisions.
         * `undefined` (default) = completely off, requests byte-identical to pre-169 behavior. Requires
         * the tool-result offload store (on by default; a deployment that disabled offloading via
         * `toolResultThresholdChars: 0` gets one onError config warning and the knob stays inert).
         * Field defaults when the object is present: keepRecentPerTool 3, minSavingsChars 2000.
         * Values must be non-negative integers — anything else (negative, fractional, non-finite) fails
         * loudly at prepare (`code: "config.stale_tool_result_offload_invalid"`, no silent re-default).
         */
        staleToolResultOffload?: StaleToolResultOffloadOptions;
    };
    /**
     * design/133 §R3 — turn-boundary attachment producers (CC `getContextAttachments` parity), OPT-IN
     * with one carve-out: [c209-C] the LISTING FAMILY (`agentListing`/`skillsListing`) is DEFAULT-ON —
     * the agent roster and skills listing were evicted from the tool descriptions / system prompt
     * (cache-prefix immunity, design/C), so the reminder frame is their ONLY model-facing carrier and
     * an opt-in default would leave the static pointer sentences ("Available agent types are listed in
     * <system-reminder> messages…") pointing at reminders that never arrive. Explicit `false` still
     * opts out (config warning when the corresponding face is mounted). Every OTHER member keeps the
     * design/132 default-face judgment (B2/H2): the evidence for those reminders comes from UNATTENDED
     * long-task legs (weak-model drift safety net — CC's own trigger counts proved unreproducible: the
     * observed CC runs never mounted TodoWrite), so long-run deployments turn them on and
     * interactive deployments stay byte-identical until a behavior leg proves them neutral. At most ONE
     * coalesced `<system-reminder>` steer per clean turn boundary, lowest lane: finalize/deadline-nudge/
     * diagnostics at the same boundary — and the design/130 P2 / design/132 end-game latches — all
     * suppress it. The listing family ALSO delivers its initial full frames on the FIRST user turn
     * (prompt-adjacent) — that first-frame delivery is part of the first
     * message, not a boundary steer, so none of the boundary gates apply to it.
     *
     *  - `todoReminder`: CC 10/10 cadence — when TodoWrite (or the task tools; both mounted ⇒ the
     *    task family wins, CC isTodoV2) hasn't been used for 10 assistant turns, re-surface the list
     *    (thin projection; an all-completed list is cleared, never regurgitated). No tools mounted ⇒
     *    permanently silent.
     *  - `changedFiles`: stat of ≤20 (or `maxFiles`) most-recently-READ files at a turn boundary and a
     *    leg's first request (fresh run, resumed leg); a file whose mtime moved past the recorded read time
     *    (+2s epsilon) is listed (path-only v1, "do not blindly revert — re-read"). OFF ⇒ zero stat calls.
     *    Self-edits are immune (write-back refreshes the read stamp); mtime skew on exotic fs remains a documented false-positive source.
     *  - `backgroundTasks` (G1 通告层 — CC /compact parity): after a compaction LANDS, the
     *    next boundary announces this run's still pending/running background tasks (task registry
     *    snapshot: id/description/status, CC three-state copy). ONE-SHOT per compaction — never
     *    per-boundary nagging; no compaction ⇒ permanently silent.
     *  - `toolsDelta` (G1 — CC deferred-tools boundary notice): when design/36 `tool_search`
     *    materializes deferred tools mid-task (setTools + fingerprint refresh), the next boundary
     *    announces the NEWLY available names once. Already-active and resume-reseeded tools are never
     *    (re)announced; no deferred tools ⇒ permanently silent.
     *  - `agentListing` (G1 续批 — CC `agent_listing_delta` parity; [c209-C] DEFAULT-ON, see above):
     *    when a delegation tool built by `createSubagentTool` is mounted, the FIRST user turn carries
     *    the full agent-type roster ("Available agent types for the Agent tool:"; + the
     *    concurrency note when more than one type; + the Q4 "Models available for the 'model'
     *    parameter:" tail when a catalog is mounted). Boundaries announce only roster drift
     *    (adds/removals — static in practice; the delta lane serves dynamic-registration deployments
     *    and cross-leg drift). A durable resume leg is seeded as already-announced from the
     *    checkpoint's `announcedListings` name-set (drift since suspend IS delta-announced), falling
     *    back to a transcript probe for older checkpoints — never replayed when already delivered.
     *  - `skillsListing` ([c209-C], DEFAULT-ON, mechanism-family sibling of `agentListing` — no CC
     *    delta anchor, registered in cc-divergences): the FIRST user turn carries the full `<skills>`
     *    disclosure block (the exact render that used to sit in the stable system prompt — folded
     *    byte-exact into the listing budget, `skillListingBudgetFraction` × the window, with
     *    name-only overflow); boundaries announce only skill-set drift. Resume seeding mirrors
     *    `agentListing`.
     *  - `mcpInstructions` (G1 续批 — CC `mcp_instructions_delta` parity): the INITIAL server
     *    instructions stay in the stable system prompt (`# MCP Server Instructions`, design/64 §17.3 —
     *    deliberate CC deviation: CC injects them as reminders, sema's stable-prompt carrier is
     *    prefix-cache-correct). This member announces only DELTAS: a mid-task disconnect of an
     *    instruction-bearing server ("The following MCP servers have disconnected…"), and
     *    the add lane for a future dynamic-connect face. Added instruction text is UNTRUSTED server
     *    text → fenced with `delimitUntrusted` (deliberate CC deviation: CC injects it raw).
     *
     * The read-only planning posture is not a member: the engine states it whenever the leg's mode is `plan`
     * (with its restatement cadence and its exit frame), as it states the bypass and auto postures. A spec still
     * carrying the retired `planModeReminder` key is refused at prepare (`config.spec_retired_key`).
     *
     * Telemetry: `steering_injected` (source `todo_reminder`/`task_reminder`/`changed_files`/
     * `output_style`/`background_tasks`/`tools_delta`/`agent_listing`/`skills_listing`/
     * `mcp_instructions`) + `stats.mechanisms.attachmentsInjected` (first-frame listing deliveries
     * emit the same echo frames and count too — source-accurate observability for the shell).
     */
    attachments?: {
        todoReminder?: true;
        /**
         * task #51 口径③ — kill-switch parity (both reminder
         * producers consume it as `if (r2o() === "off") return []`). `"off"` silences the
         * todo/task reminder lane even when `todoReminder` is wired on (the other attachment producers are
         * untouched — CC's nudge gate is lane-scoped); any other value (or absence) = CC `"baseline"`.
         * CC resolves this from env `CLAUDE_CODE_TODO_REMINDER_MODE` / the `tengu_soft_slate_nudge` gate;
         * sema keeps env resolution at the deployment shell — core reads no env.
         */
        todoReminderMode?: "baseline" | "off";
        /**
         * `tool_search_usage_reminder`: the
         * REVERSE nudge for delayed tool disclosure. When tools are deferred (design/36), a model that has
         * gone N turns without calling `ToolSearch` and still has unloaded schemas is told they exist and
         * how to load them, so "this capability does not exist, I will build a workaround" stops being the
         * silent failure mode of the mechanism.
         *
         * Activation (all four, CC-exact): opted in here; the task actually HAS deferred tools; at least one
         * is still undiscovered; and BOTH windows are open — ≥15 cadence units since the last `ToolSearch`
         * call AND since the last such reminder (`TOOL_SEARCH_REMINDER_CONFIG`, CC's shipped 15/10 defaults).
         * MUTUALLY EXCLUSIVE with the todo/task reminder in the same boundary (CC `task_reminder_same_turn`):
         * at most one work-hygiene nudge per boundary. Opt-in, default OFF like every other 133 member —
         * CC's own mount is likewise config-gated (`cXi()` null ⇒ the lane is never registered).
         */
        toolSearchReminder?: true;
        changedFiles?: true | {
            maxFiles?: number;
        };
        /**
         * SR-3 (the `budget_usd` lane): the
         * progressive $-budget readout `USD budget: $used/$total; $remaining remaining` (fixed
         * template). CC-exact activation: live ONLY while the task carries an effective cost ceiling
         * (`maxCostUsd`, or a resource-slice ledger remaining — CC `options.maxBudgetUsd`); no ceiling ⇒
         * permanently silent even when opted in. CC-exact cadence: NO threshold ladder and NO throttle —
         * CC mounts it on every attachment cycle whose task carries a ceiling (RB-311: CC puts
         * it in the SHARED producer group, so a SUBAGENT with its own ceiling sees it too — the `!agentId`
         * flag gates the main-agent-exclusive group next to it, not this lane), so
         * sema emits one line at every collected clean turn boundary; the "progression" is the numbers
         * advancing with spend. Recorded deviation (continuation gate): CC attaches at request assembly
         * and can never EXTEND a run, while a sema boundary steer revives an idle harness — so this lane
         * only rides boundaries whose turn resolved ≥1 tool call (a next request is already guaranteed);
         * a text-only final turn is never dragged past its natural end. Numbers ride the enforcement
         * coordinate (`stats.costMicroUsd` vs the effective ceiling, ÷1e6 → USD) so the readout never
         * disagrees with `limits.max_cost_exceeded`.
         * NOTE: this deliberately relaxes the design/74 "no budget language reaches the model" default —
         * that judgment shaped the DEFAULT-OFF posture; an opted-in deployment chooses CC parity.
         */
        budgetUsd?: true;
        /**
         * `total_tokens_reminder`:
         * the TOKEN twin of {@link budgetUsd}. One line per collected boundary,
         * `<total_tokens>N tokens left</total_tokens>`.
         *
         * Activation, CC-exact in shape and BYOM-honest in substance: opted in here AND — for the two
         * COUNTDOWN arms — the task carries a token ceiling (`limits.maxTokens`, or a resource-slice
         * allocation's remainder). No ceiling ⇒ permanently silent, because core does not know and will not
         * guess your model's context window: the number it publishes is the one it already ENFORCES
         * (`stats.tokens` against that ceiling), so the readout can never disagree with an eventual
         * `limits.max_tokens_exceeded`. The two CONSTANT arms (`infinite` / `fixed`) read no measurement at
         * all and need no ceiling.
         *
         * Cadence, CC-exact: no threshold ladder and no throttle — every collected boundary carries it, and
         * the "progression" is the numbers advancing with spend. Recorded deviation (shared with
         * {@link budgetUsd}, and for the same reason): the lane only rides boundaries whose turn resolved
         * ≥1 tool call, so a boundary steer never EXTENDS a run that reached its natural end.
         *
         * DEFAULT ON since design/374 slice 4 (ruled 2026-08-28) — boolean, not `true`: explicit
         * `false` is the opt-out, the {@link backgroundTasks} / listing-family contract rather than the
         * `true`-only 133 form. BREAKING for a deployment that declares a token ceiling: pre-flip it saw
         * no `<total_tokens>` frame without opting in, and a probe pinning that absence reds.
         *
         * WHY THIS LANE AND NOT {@link budgetUsd}. The reference ships the readout on by default (its own
         * settings schema reads "Defaults to padded-countdown"), which is the fact that reopened the
         * 2026-07-30 registration; the design/74 "no budget language reaches the model" default is
         * relaxed here for the same reason CC relaxed it. The BYOM honesty objection does not survive
         * either: core estimates nothing, publishes only the ceiling it already ENFORCES, and a task
         * that declares no token ceiling never fires the countdown arms at all — so the flip is
         * observable exactly in the deployments that asked for a ceiling. That property is EXACT, not
         * approximate: CC's two CONSTANT arms (`fixed`/`infinite`) publish a number with no ceiling
         * behind it, so the DEFAULT deliberately does not reach them — they stay behind an explicit
         * `true` here (see the runner's lane gate). The $ twin keeps its opt-in
         * default: CC has no equivalent default-on posture for it.
         */
        totalTokensReminder?: boolean;
        /**
         * Which arm of the readout, the reference's closed set (`off` / `infinite` / `fixed` /
         * `countdown` / `padded-countdown`); absent ⇒ CC's own default `"padded-countdown"`.
         *
         *  - `countdown` — remaining = ceiling − spend, raw.
         *  - `padded-countdown` — the same, through a monotone floor, so the number NEVER JUMPS BACK
         *    within one engine leg (CC's per-agent smoothing floor; ONE `runTask` invocation is the
         *    epoch). A durable-resume leg is a NEW epoch by design: the slice window, the spend
         *    coordinate and the floor all restart, so the resumed leg's readout RE-ANCHORS to its own
         *    real remaining — which may sit above the prior leg's last readout (the fresh slice window
         *    is a genuine new allowance; CC's own re-anchor arm counts a new task epoch down from the
         *    full budget again). Carrying the floor across legs would publish "0 tokens left" against a
         *    window the run genuinely still holds — a frozen falsehood, deliberately not done.
         *  - `off` — silences the lane while leaving it wired, for a deployment that resolves the mode from
         *    its own env/settings the way CC does (core reads no env).
         *  - `infinite` / `fixed` — CC's two constant arms: the literal `Infinite`, and the constant
         *    5000000. They publish no measurement (that is what they are for) and need no ceiling.
         *
         * A value outside the set is REFUSED at prepare (`config.attachment_invalid`), never folded to the
         * default — a near-miss spelling must not silently publish a different readout than the one asked for.
         */
        totalTokensReminderMode?: "off" | "infinite" | "fixed" | "countdown" | "padded-countdown";
        /** The silent-turn reminder: when the model has gone several requests without a word to the person (five since the last
         *  reminder, at most three in one stretch; or, on a model whose traits hold `timed_silent_turn_reminder`, a minute of
         *  silence), the next turn boundary reminds it to keep them updated. Only for a model whose prompt traits hold
         *  `silent_turn_reminder`, only on a top-level leg (never a delegated child). DEFAULT ON — boolean: `false` is the opt-out,
         *  a non-boolean is refused at the task's door (`config.invalid_argument`). */
        silentTurnReminder?: boolean;
        /** The elapsed-time reminder: the boundary bundle (a continuation boundary no person's input opens) tells the model how long
         *  it has been since the person last spoke (`Elapsed time so far: 3m 07s`; the session's clock, read by its child legs too,
         *  restarted only by the person's own input on a top-level leg). Only for a model whose prompt traits hold
         *  `elapsed_time_reminder`. DEFAULT ON — same boolean contract as {@link silentTurnReminder}. */
        elapsedTimeReminder?: boolean;
        /** Post-compact background-task restatement — DEFAULT ON since 5.12.0 (boolean, not `true`:
         *  explicit `false` is the opt-out; same contract as the listing family below). CC hard-codes
         *  this behavior, and the opt-in default left every non-shell host (server-driven runs) with a
         *  window where the model had no context evidence of an in-flight task after a compaction —
         *  duplicate spawns / premature turn ends (board case, ruled 2026-08-04). BREAKING: pre-5.12.0
         *  the default was off — a probe pinning "no background_tasks frame without opt-in" reds. */
        backgroundTasks?: boolean;
        toolsDelta?: true;
        /** The notice that a declared MCP server did not connect: its tools are unavailable for this session when the session remembers
         *  the failure (it waited out the startup bound; not dialed again unless its declaration changes or the host has it reconnected),
         *  for now otherwise (the next message tries again). Rides the leg's first request (a fresh leg's first user message, a resumed leg's continuation),
         *  once per session per server and error. DEFAULT ON — boolean: `false` is the opt-out, a non-boolean is refused at the
         *  task's door (`config.invalid_argument`). BREAKING: the notice used to ride {@link toolsDelta}, and only a turn boundary. */
        mcpUnavailable?: boolean;
        /** [c209-C] listing family — DEFAULT ON (boolean, not `true`: explicit `false` is the opt-out;
         *  see the family carve-out note above). BREAKING (B-3): pre-[c209-C] the default was off. */
        agentListing?: boolean;
        /** [c209-C] listing family — DEFAULT ON (same contract as `agentListing`). */
        skillsListing?: boolean;
        mcpInstructions?: true;
    };
    /**
     * Inject a built-in `ReportBlocked` tool the agent can call when it cannot finish
     * (missing info, permission, ambiguity). When called, the task ends with status "blocked". Default: true.
     */
    enableBlockedReport?: boolean;
    /**
     * **LLM self-orchestration** (design/98, S8). Allow THIS task's model to AUTHOR + RUN its own workflow
     * (a deterministic JS orchestration script) via the `run_workflow` tool. Default `false`.
     *
     * 🔴 REQUIRES a deployment-provided HARD sandbox AND a governance baseline:
     * `RunnerDeps.workflowScriptRunner.safeForUntrustedScripts === true` (an isolated-vm / separate-process
     * runner — the Node `vm` dev runner is NOT a security boundary) AND `RunnerDeps.workflowGovernanceBaseline`
     * (the deployment-trusted governance every spawned sub-agent inherits, tighten-only). With EITHER missing
     * the tool is NOT mounted and the orchestration prompt is NOT injected (FAIL-CLOSED) — core never runs an
     * LLM-authored script in the dev `vm`, and never lets a script-spawned agent run with no governed baseline.
     *
     * Recommended ONLY for strong models; weak models default-off (force-enableable, but the hard-sandbox +
     * baseline bar still applies — the gate is the deployment's sandbox/governance, NOT the model id). NOT
     * enforced by model id.
     */
    selfOrchestration?: boolean;
    /**
     * Per-model auth: the api key (and optional headers) for the `Model` a request will carry, asked by every lane of the task and
     * of the runs it starts. The Runner takes this function where it receives it (its birth: the catalog in force then; its children
     * keep that birth). Across a later catalog swap, an answer that names no `credentialOrigin`, for an entry of a catalog the seat knows that is not unchanged
     * member for member in that catalog and the one in force, goes only where its key is already bound, else is refused before anything is sent (`route.credential_origin_mismatch`,
     * `boundBy: "generation"`; host-side shapes the engine is not told about: INTEGRATION-CORE §1.10b). `credentialOrigin` names the origin of the entry the key was READ
     * FOR, spelled as that entry's `baseUrl` (absolute http(s), folded to scheme, host and port; an echo of the handed entry declares
     * nothing): a request going elsewhere is refused, an admitted one binds the key there. Absent ⇒ the table's; unservable ⇒ `config.invalid_argument`.
     */
    getApiKeyAndHeaders?: (model: Model) => Promise<{
        apiKey: string;
        headers?: Record<string, string>;
        credentialOrigin?: string;
    } | undefined>;
    /**
     * External cancellation. When it aborts, the task aborts (the brain request is cancelled and any
     * pending tool-policy gate releases). Pass a parent tool's `ToolExecuteContext.signal` here so a
     * nested `runTask` stops the instant the parent does instead of running to its own `limits.maxWalltimeMs`.
     * The run holds nothing on it once it has ended: the host need not abort it after the run, and may keep one
     * signal for many runs.
     */
    signal?: AbortSignal;
}
