UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

387 lines (386 loc) • 33.2 kB
import { type BeforeWriteHook, type CwdRef, type PathRuleDenyRow, type ContainmentFace } from "../../tools/fs/index.js"; import { type ReadFileState } from "../../tools/fs/safety.js"; import { type JudgedPathRow } from "../../tools/fs/read-deny.js"; import { type PathTablesFacade, type PersonPathRows, type ReadRootsSeat } from "./person-path-rows.js"; import { type HeadLeads } from "../path-rule-binding.js"; import { type ShellReadAdmission, type ShellReadCheck, type ShellReadLandings } from "../../tools/fs/shell-read-check.js"; import { type ReadFloorRows, type ReadFloorSeat } from "../../tools/fs/read-floor.js"; import type { CommandSandboxSeat } from "../command-sandbox.js"; import type { JudgedReadsSeat } from "../../tools/fs/judged-reads.js"; import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js"; import { type SeenFiles } from "../existing-target.js"; import type { RunnerDeps, ShellGateDoctrine, TaskSpec } from "../types.js"; import type { NoticeTold } from "../engine-notice.js"; import { type Model } from "../../internal/llm.js"; import type { AgentHarness, AgentTool, ExecutionEnv, WorkspaceState } from "../../internal/harness.js"; import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js"; import type { DeclaredRoot } from "./nested-memory-lane.js"; import { type ArtifactStoreRef, type GrantReadRoot } from "./read-root-grant.js"; import type { StoredSession } from "../session.js"; import type { CarriedFaces, IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js"; import type { ToolOccurrenceTable } from "./tool-occurrence.js"; import { RosterBuilder } from "../tool-roster.js"; import { type PermissionMode } from "../ask-origin.js"; /** Test seam (mirrors `__resetMalformedNoticeSeatAnnouncement`): never called by production code. * Deliberately asymmetric — it resets only the console latch: the WeakSet arm needs no seam * because a test resets it by minting a fresh sink function (identity IS the ledger key), while * the console arm's key is the process itself, which only this seam can refresh. Moved WITH the * phase; prepare-task.ts keeps a re-export so the existing import sites stand. */ export declare function __resetReadFaceClampAnnouncement(): void; export interface PrepareHandsReadFaceInput { /** borrowed-readonly — the leg's judged-read port seat: which tools read through the port (`ported`); absent ⇒ none does. */ judgedReadsSeat?: JudgedReadsSeat; /** owned (value) — `ownedEnv !== undefined || deps.executionEnv !== undefined`, computed in the * driver: the phase's own branch condition (hands mount vs the hands-less resolver arm). */ handsEnabled: boolean; /** borrowed-readonly — the leg's own session's told record (`LegNotice.told`): the byte floor's notice is told once per session. */ told?: NoticeTold; /** borrowed-readonly — the run's command sandbox seat (`command-sandbox.ts`), handed to the band's shell faces; absent when * the run requires no sandbox. */ commandSandbox?: CommandSandboxSeat; /** borrowed-readonly — the leg's declared places (`leg-caller-places.ts`, minted once by the driver): the configuration roots * and the caller's homes the run's read deny table is placed at. */ callerPlaces: import("./leg-caller-places.js").LegCallerPlaces; /** borrowed-readonly (the ownership-ref PROTOCOL stays with the driver — D-8 案① posture, same * as B-4): the effective env (`ownedEnv ?? deps.executionEnv ?? stub`). This phase drives it * (canonicalPath/joinPath/writeFileExclusive probe/instanceof screens) and closes tool bands * over it, but NEVER rebinds or destroys it. */ executionEnv: ExecutionEnv; /** borrowed-readonly — the leg's one reading of its start for model text when `mounted` (else undefined): the shell tools take it. */ modelShell: import("../model-shell.js").MountedModelShell | undefined; /** borrowed-readonly — B-4's settled root (T6 FINAL semantics); the containment root every face * in this phase canonicalizes from. */ taskRootFinal: string; /** borrowed-readonly — the same root, resolved to the spelling the fence compares with, by the ONE * resolver at the driver's root receiving point ({@link import("./task-root-canonical.js").resolveTaskRootCanonical}): * taken as an input, never re-canonicalized here, so the fence and the root notice cannot disagree. */ taskRootCanonical: string; /** borrowed-readonly — the leg's ONE write-location reader (prepare-task's `currentCheckoutOf` over the worktree seat): the * primary WRITE root of the structured write tools and of the shell's write targets, read per call — it is the task root * until EnterWorktree switches it, and moves back on ExitWorktree. The READ roots read it too, and only when it left the task * root: a managed tree hangs at the REPOSITORY root (#2738), so for a task rooted below that root the tree lies outside it. */ writeLocation: () => string; /** borrowed-readonly — B-4's checkpoint-path rebaser (T7): identity unless a divergent restore * armed it; applied to the readFileState seed keys and the handsCwd seed. */ rebaseRestoredPath: (p: string) => string; /** borrowed-readonly — the durable-resume seat this phase reads: `seed` only (readFileState / * handsCwd / readFace section). Presence also gates the leg forks (T11: a resume's entries are the seed's alone, the * transcript only registers the files it shows read; the workspace_state rung is skipped; the face fold goes stricter-wins). */ resume: Pick<PrepareResume, "seed"> | undefined; /** borrowed-readonly — the acquired session (B-3 output), as a Pick (相 API 规则件 R-4: receiver * preserved): `getWorkspaceState` feeds the continuation rung; `buildContext` feeds * the transcript replay; `getStorage`/`getEntry` feed the seat-anchor verification (one * leaf read per prepare + a bounded parent walk on the inherit leg only) and the log's completeness reading. */ session: Pick<StoredSession, "getWorkspaceState" | "buildContext" | "getStorage" | "getEntry">; /** borrowed-readonly — the acquired session's id, for error/notice tags and the band's session * registration. */ sessionId: string; /** borrowed-readonly — the session the person's session-scope permission rules are read and written at (the read-root grant's landing). */ ruleSessionId: string; /** borrowed-readonly — the occupant the band's registry-facing tools act for (`OccupantMount.occupant`, read at call time). */ legOccupant: () => string | undefined; /** borrowed-readonly — this run's id, carried on the byte-floor notice (once per run). */ runId: string; /** borrowed-readonly — the host task id: trace frames + the band's task-registry owner. */ hostTaskId: string; /** borrowed-readonly — the registry scope (`internals?.registryScope ?? isolationScopeOf(spec) ?? * "default"`, computed in the driver); the band's task-registry scope. */ taskScope: string; /** borrowed-readonly — the leg's own deny-table rows: the face-keyed path deny rules of the leg's caller policy and of every * ancestor's, each bound where it was installed (`toolPolicyPathRules`); the person's join them per read ({@link personRows}). */ denyRuleRows: readonly PathRuleDenyRow[]; /** borrowed-readonly — the leg's own read-face ask rows: the `Read(<path>)` ask rules of the same policies, bound the same way — * the shell read boundary's ask member beside the person's ({@link import("../../tools/fs/shell-read-judge.js").ShellReadBoundary.readRuleRows}). */ readAskRuleRows: readonly JudgedPathRow[]; /** borrowed-readonly — the leg's own write-face ask rows: the `Edit(<path>)` ask rules of the same policies, bound the same way — * the shell read boundary's write-face member beside the person's ({@link import("../../tools/fs/shell-read-judge.js").ShellReadBoundary.writeAskRows}); * one the chain cannot anchor (`unanchored`) is no member, and is said where a mode that counts it first reads the rows. */ writeAskRuleRows: readonly (JudgedPathRow & { readonly unanchored?: readonly string[]; })[]; /** borrowed-readonly — the run's one reader of the person's rules: the run's tables are compiled here over it. */ personRows: PersonPathRows; /** borrowed-readonly — the leg's one resolution of where rule heads lead (the rows' twins, the same the gate's lanes read). */ headLeads: HeadLeads; /** borrowed-readonly — the ONE judgment a shell command's write targets meet for the mode's file-command placement: the * leg's write judgment over the write-protection table and the chain's guarded write rows (read per judgment — it is * compiled at the manifest phase, before any gate is mounted). Absent ⇒ none (a standalone phase drive). */ writeTargetJudge?: () => ShellReadBoundary["writeTargetJudge"]; /** borrowed-readonly — the leg's mode seat, read LIVE by the write face ({@link writeFaceReader}): its mode's face * is the resolver's row 3′ on every write. */ permissionMode: { readonly current: PermissionMode; }; /** borrowed-readonly — the D-6 spec-time full-shell reachability precomputation; an input to the * face resolver on BOTH arms (the driver's post-exclusion roster assertion pins it to the * mounted truth — that assertion is driver-side, after this phase). */ fullShellReachable: boolean; /** borrowed-readonly — the operator's shell FLOOR (`"always"`: the spec's, or the chain's), or undefined (no floor: * the shape tier installs on its own and the permission mode arbitrates its asks). */ effectiveShellGate: ShellGateDoctrine | undefined; /** borrowed-readonly — B-1's frozen task-start face snapshot; only `.exclude` is read here (the * Monitor-mount honesty bit for the gh rate-limit hint). */ toolFaceSnapshot: ToolFaceSnapshot; /** borrowed-readonly — B-1's resolved main model; read ONLY for its pdf capability profile * (the Read tool's document-degradation fork). */ model: Model; /** borrowed-readonly — the task-spec seats this phase reads, as a Pick over the SAME spec object * (R-4). `tools` feeds only the band shadow check; `envFacts` only the advertised scratchpad; `planFile` only the * advertised session plan file; `retainBackgroundProcesses` only the band's retain lane (Bash's lifetime sentence + row stamp). */ spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "ownHandsReadOnly" | "blockReadsOutsideRoots" | "readDenyPatterns" | "readDenyBuiltinExclude" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">; /** borrowed-readonly — the deployment seats this phase reads, as a Pick over the SAME deps * object (R-4: `deps.onError?.()` keeps its receiver; a new deps read must widen this Pick). * `readDenyBuiltinTiers`/`readDenyBuiltinExclude` are SNAPSHOTTED before the first await that * precedes the toolkit compile (the caller retains these arrays by reference). */ deps: Pick<RunnerDeps, "onError" | "onNotice" | "tracer" | "readDenyPatterns" | "readDenyBuiltinTiers" | "readDenyBuiltinExclude" | "readDenyFloorRequired" | "readDenyBuiltinRequestExcludable" | "readFace" | "writeFace" | "permissionRuleStore" | "hands" | "imageProcessor">; /** borrowed-readonly — the trusted spawn-side seats the band forwards: the finished-command * notification lane, the mid-flight detach hub, and the Runner's per-session * read-state seats and their restore channel (absent on a standalone prepare ⇒ the transcript-replay rung * covers alone, and no restore is owed a check — the channel is the Runner's). */ internals: Pick<RunInternals, "onTaskNotification" | "detachHub" | "sessionReadStates"> | undefined; /** borrowed-mutable — the harness seat, read LIVE by the band's queued-human-input predicate and its turn-cut question * (the shell's auto-backgrounding leg asks both mid-command). Late-bound: the band is built here, the harness later. */ harnessRef: { current?: AgentHarness; }; /** borrowed-readonly — the effective delegation facts: a turn cut moves an armed command aside on a top-level leg only. */ delegation: { isDelegatedChild: boolean; }; /** borrowed-readonly — the leg's context-room seat (context-room.ts), handed to the band's one file reader for Read's `allow_large`. */ contextRoom?: import("./context-room.js").ContextRoomSeat; /** borrowed-mutable — the tool-progress lane's cell, read LIVE by the band's progress seat; same * late-binding contract as {@link harnessRef}. Unbound ⇒ every tick through it is a silent no-op. */ toolProgressRef: { current?: ToolProgressLane; }; /** borrowed-readonly — the leg's refusal seat (the shell tools note a command's `env.` code) */ envRefusal: Pick<import("./restore-seat.js").EnvRefusalSeat, "note">; /** borrowed-mutable — the leg's occurrence table; writer here: the shell read station's refused-admission callback. */ toolOccurrences: ToolOccurrenceTable; /** borrowed-readonly — the memory write gate the memory phase minted (it runs BEFORE this phase: the memory root * must be known before the toolkit compiles), composed into the band's beforeWrite below; undefined for a * memory-less run (every write passes the engine half). */ memoryWriteGate: BeforeWriteHook | undefined; /** borrowed-readonly — the run's offload store (`undefined` when offload is off): with a byte arm, the write half mounts SaveToolResult over it. */ offloadStore?: import("../../tools/fs/fs-write.js").KeptBytesReader; /** borrowed-mutable — the advertised-writable-directory seat (see its module header for the one * rule). Present on the hands leg only (a fence exists). The memory phase, which runs BEFORE this one, * has already admitted its write root through it; this phase admits the deployment's scratchpad and * folds `roots` into the write-capable containment allowlist before the toolkit compiles. */ advertisedWritableDirs?: AdvertisedWritableDirs; /** borrowed-readonly — the driver's per-tool offload wrapper (posture + policy); the * band rides through it exactly as caller/MCP tools do. */ firstPartyOffload: (tool: AgentTool) => AgentTool; /** borrowed-mutable — the SHARED mount array (§4.4: later refs alias it; identity is the * contract, never map/copy). This phase pushes the hands band IN PLACE (after caller tools / * built-ins / MCP / A2A, before the background-task mounts — T22 order). Mutation owners after * this phase: P11 background/Monitor/worktree pushes, the driver's excludeTools splice, the * refresh seam's runtime splice/push. The array is builder-private: this phase `mountAll`s the band. */ roster: RosterBuilder; /** borrowed-readonly HERE (census divergence #5 vs the design row): this phase only reads * `.has("Bash")`/`.has("Monitor")` for the provenance bits — its mutation owners are B-2/P8/P9 * (+refresh seam)/P11/P22, per the B-2 Result's mutation-owner table. */ egressTools: ReadonlySet<string>; /** borrowed-mutable — the shellGate fold's tier write-back (`.get` for the provenance bit, * monotonic `.set` — tighten-only). Same object B-2 returned; owner table lives on the B-2 * Result. */ irreversibilityTier: IrreversibilityTier; /** borrowed-mutable — the shellGate fold `.add`s Bash/Monitor here. Same-object contract as * above. */ irreversibleTools: Set<string>; /** borrowed-mutable — the shape tier's probe installs (`.set`, only where the shell seat * owns the tier). Same-object contract as above. */ reversibilityProbes: ReversibilityProbes; /** borrowed-readonly — the run's reminder provenance mark (minted/adopted * by the driver's adoption ladder); threaded into the hands band so the fs-side engine mints * (the Read dedup/offset/empty reminders, the gh rate-limit hint) stamp the same mark the * system-prompt declaration names. */ reminderMark: string; /** borrowed-mutable — the leg's disclosure trigger counters; the hands * band's Read/notebook/PDF trailer outlets bump keys on it at tool-execute time (the driver owns * the object and folds it into result stats). */ reminderDisclosureCounts: import("../reminder-disclosure.js").ReminderDisclosureCounts; /** borrowed-mutable — where the band hands out the leg's one file reader (the Read tool's), for the leg's other * carriers of a file (attachment frames): written once at mount, left empty when hands do not mount. */ modelFileReaderSeat?: { current?: import("../../tools/fs/fs-read.js").ModelFileReader; }; /** borrowed-readonly — where the band's Edit / Write read the run's read-first waiver at each call (filled once the run's * served-read judge exists, for a model that does not declare `read_before_edit`; empty otherwise). */ readFirstWaiver?: import("../../tools/fs/fs-write.js").ReadFirstWaiverSeat; /** borrowed-readonly — the first-touch history hook prepare built (present iff the run records file history into a * wired store and mounts a real fs env); threaded to the write band's trackFileEdit seat. */ trackFileEdit?: import("../types.js").TrackFileEditHook; /** borrowed-readonly — the mutation lane's LANDED observation seat (the accumulator behind * `TaskResult.editedFiles`); threaded to the write band's onFileEdited seat. Unlike * `trackFileEdit` it does NOT depend on a wired history store: it observes what this run's hands * did, so it is present on every run that mounts the band. */ onFileEdited?: import("../types.js").FileEditedHook; } /** The phase's outputs (相 API 规则件 four-class form) — ALL settled before the return; the driver * binds them as fresh consts (R-5) except the inverted-closure trio and the two shellGated bits, * which write back into the driver's pre-existing `let`s (D-3 hold / driver-owned seats — see the * module header). */ export interface PrepareHandsReadFaceResult { /** owned — the per-task read-before-write state, exposed for the suspend closure's checkpoint * serialization (§15.2 net-add #8) and the compaction faces. Undefined ⇔ hands-less. The MAP * keeps being mutated by tool executes / compaction at run time — object identity carried. */ readFileStateForCheckpoint: ReadFileState | undefined; /** owned — parity-204 (CC seededFromContext): seeds the files whose text this leg put in the system-prompt lane * through the SAME resolveKey containment as a real Read. CREATED here; CALLED by the driver's memory-seed block * (T10 — the forever-cross-phase edge; this module does not claim the * call order). Undefined on a hands-less task (nothing to seed). Reads the phase-local * `resolvedReadFace` call-time — settled before this function returns. A file declared without `content` (the * prompt's account of it is not its whole current text) is seeded with nothing; it is held in {@link seenFiles}. */ seedContextFiles: ((files: ReadonlyArray<{ path: string; content?: string; }>) => Promise<void>) | undefined; /** owned — the leg's startup seed table, filled by {@link seedContextFiles}: canonical key → the whole-file content * hash this leg's system prompt holds. The request's copy projection reads it (a whole attachment frame of a seeded, * unchanged file is carried as the "already in your context" sentence; a Read of it is its contents); no other leg's * seed is in it. Empty on a hands-less task. */ seededCopies: ReadonlyMap<string, string>; /** owned — the files this leg knows the model has seen though no read entry may stand for them (`SeenFiles`): every file * {@link seedContextFiles} was handed, seeded or not; the reads and changes the transcript rebuild found no record for * (all files, when it cannot place one); the files a rewind's restore dropped the entry of. None is a file the model never * read. The write tools' read-first waiver reads it (`readFirstWaiverOf`), nothing else. Empty on a hands-less task. */ seenFiles: SeenFiles; /** owned — the per-task logical cwd ref (observable `cd`), minted when a real * writable shell mounts. The driver stamps it into checkpoints, threads it into worktree tools * and gate cwd reads; tools mutate `.current` at run time. Undefined when no shell / readOnly. */ handsCwdRef: CwdRef | undefined; /** owned — the settle-side snapshot base (what the cwd/worktree refs were RESTORED * to), so runtask's settle write diffs against it. The driver's G4 worktree mount writes * `.restoredWorktreeDir` after this phase — object identity carried. */ workspaceStateSettle: { rootCanonical: string; restoredHandsCwd?: string; restoredWorktreeDir?: string; baselineUnknown?: boolean; } | undefined; /** owned — the branch-nearest `workspace_state` entry, fetched ONCE here and shared * with the driver's worktree seed (the G4 mount reads `.activeWorktree` through it). */ wsSnapshot: WorkspaceState | undefined; /** owned — the wsSnapshot path rebaser (identity when no snapshot / same root); the G4 worktree * seed applies it to the snapshot's worktree paths. */ rebaseWsPath: (p: string) => string; /** owned — real shell + write hands + background-capable env: gates the driver's * TaskStop/Monitor/SendMessage mounts (P11) and the Monitor arm of the shellGate fold here. */ backgroundTaskToolsActive: boolean; /** owned — this run's READ STATIONS as the one gate input (`ToolGateInput.shellReadCheck`): the shell's (ONE judgment of * where a shell command reads, for every shell face this leg mounts, under every mode and floor) and the file tools' * (an out-of-root Read / Grep / Glob target is a question) and the file write tools' (a target their fence refuses is refused). * ⇔ hands with a real shell, or hands with an approval face, or the write half. */ shellReadCheck: ShellReadCheck | undefined; /** owned — the file read station's judged-read port per call (`ToolExecuteContext.judgedReads`); absent ⇔ no file read station. */ judgedReadsOf: ((toolCallId: string) => readonly import("../judged-read.js").JudgedRead[] | undefined) | undefined; /** owned — the shell read station is mounted (⇔ a real shell): the wiring manifest's cell. */ shellReadStationArmed: boolean; /** owned — the same station's pre-spawn ADMISSION, published for the P11 face that spawns a shell command * and mounts LATER than the band (`Monitor`): the SAME function the band's shell faces got. ⇔ a real shell. */ shellReadAdmission: ShellReadAdmission | undefined; /** owned — the byte floor's seat over the run's read-deny tables (read-floor.ts): every start the run makes reads its floor * through it, at the start — a call's own pinned table, else the run's base table. ⇔ the run compiled tables (hands). */ runReadFloor: ReadFloorSeat | undefined; /** owned — the same station's landings of a judged call (`ShellReadStation.landings`): the park binds them, the resumed leg's execution station compares. ⇔ a real shell. */ shellReadLandings: ShellReadLandings | undefined; /** owned — the file read station's admission (`FileReadStation.admitted`) the band's read tools got, for the read tools mounted later (LSP). */ readAdmission: ((toolCallId: string | undefined, canonicalKey: string) => boolean) | undefined; /** owned (value) — the leg's one resolution of `TaskSpec.blockReadsOutsideRoots` (`readBlockOf`, both branches); every reader takes it. */ readBlock: boolean; /** owned — the file read station on the run's newest tables where {@link readBlock} mounts it as a refusal (`onNewestRead`). */ readBlockJudge: ShellReadCheck | undefined; /** owned — the remedy this leg's read faces name when they refuse outside their roots (`readBlockLeg`); the driver hands it on. */ outsideReadRemedy: string | undefined; /** write-back (D-3 hold) — the run's RESOLVED read face where hands mount; undefined ⇔ no hands * (the hands-less value lives in `handsLessResolvedFace`). The driver assigns this onto its * outer `let` for the call-time closures (ctx enrichment / checkpoint mint / envFacts). */ resolvedReadFace: ContainmentFace | undefined; /** write-back — the run's WRITE face in force where hands mount, read per call ({@link writeFaceReader}); undefined ⇔ * no hands (the hands-less reader is `handsLessResolvedWriteFace`). The read seat's twin, resolved by the SAME order on * its OWN seats — the two never read each other. */ resolvedWriteFace: WriteFaceSeat | undefined; /** write-back — the hands-LESS legs' write face in force (the posture is a property of the RUN, not the mount): the * delegation carriers and the checkpoint mint read it on every leg. */ handsLessResolvedWriteFace: WriteFaceSeat | undefined; /** write-back — a leg that narrowed only its OWN hands (`TaskSpec.ownHandsReadOnly`): the two faces its children are handed, * resolved without that narrowing ({@link carriedFacesOf}); absent on every other leg (its children are handed its own faces). */ carriedFaces: CarriedFaces | undefined; /** write-back (D-3 hold) — the NORMALIZED deny-set additions in force (deployment ∪ task ∪ * resume-seed; zero-builtin compile — the persisted/carrier form, never the judged union's * post-dedup remainder). Driver assigns onto its outer `let`. */ readDenyAdditionsNormalized: ReadonlyArray<{ pattern: string; caseSensitive: boolean; }>; /** owned — the built-in deny TIERS this leg MATERIALLY activated, off the same snapshot the compile * judged with; empty ⇒ none. Relayed to the wiring manifest, never re-derived from `deps` there. */ readDenyBuiltinTiersActive: readonly string[]; /** owned — the byte floor's latch over EVERY table this leg compiles (`judgeReadFloorKept`): the prepare's first one and each * one the person's rows bring later. `current` holds the rows of an unkept judgment (`latchReadFloor`: the one with the most caller rows) once any of them holds rows on an environment that does not keep the floor, and never turns back to `false`. Read, never re-derived: by the wiring manifest when it is derived (`readDenyFloor`, the leg's * wiring as it started) and by the result when it is assembled (`TaskResult.readDenyFloor`, the leg's record over its life). `judged`: a table was, and the leg's end reads the fact off both. */ readFloorUnkept: { readonly current: ReadFloorRows | false; readonly judged: boolean; }; /** write-back (D-3 hold) — the hands-LESS legs' resolved face (the read posture is a * property of the RUN, not the mount). Driver assigns onto its outer `let`. */ handsLessResolvedFace: ContainmentFace | undefined; /** owned — the canonicalized write-capable extra roots (additionalDirectories + the advertised * scratchpad), deduped; the driver's envFacts advertisement and attachment readers share the * ARRAY identity. Settled here (no mutation after return). */ additionalRootsCanonical: string[]; /** owned — the extra roots a COMMAND may write (shell write targets, the command sandbox's list): {@link additionalRootsCanonical} * less a directory its advertiser's own gate refuses writes into (`AdvertisedWritableDirs.commandRoots`). `[]` hands-less. */ commandWriteRootsCanonical: readonly string[]; /** owned — the entries the SPEC declared through `additionalDirectories` and nothing else, each its spelling and the canonical form above, * in declaration order (an entry that could not be resolved is not here): the instruction-file lane's additional roots — a person-declared * working directory can be one, ground the model itself may write (the scratchpad, the memory root, the plan file) cannot. `[]` hands-less. */ declaredAdditionalRoots: readonly DeclaredRoot[]; /** owned — the read-only arm of the fence widening (2026-08-05 both-arms ruling); same identity * contract as above, and the run's LIVE read-root set: {@link grantReadRoot} is its one writer after prepare, * and every read face reads it per call (never a copy). */ additionalReadRootsCanonical: string[]; /** owned — widen {@link additionalReadRootsCanonical} by one granted candidate (an approver's in-flight * `readRootGrant`); undefined ⇔ hands-less (no read face to widen). */ grantReadRoot: GrantReadRoot | undefined; /** owned — the store cell {@link grantReadRoot} judges against; the driver threads it to its one writer, the Artifact phase. */ artifactStoreRef: ArtifactStoreRef | undefined; /** owned — the canonical containment root, published so the compaction's kept-tail path * normalizer resolves the way the hands tools do. Undefined ⇔ hands-less. */ attachmentRootCanonical: string | undefined; /** owned — the run's read deny table ({@link pathTables}' facade: the run's latest, `forCall` a call's own). Undefined ⇔ * hands-less (its consumers only exist with hands). */ readDenyMatcher: PathTablesFacade["readDeny"] | undefined; /** owned — the read face's root set per judgment: write roots, read roots with grants, the person's read directories. */ readRoots: ReadRootsSeat; /** owned — the run's path tables ({@link PathTablesFacade}); undefined ⇔ hands-less. */ pathTables: PathTablesFacade | undefined; /** owned — the shell-seat PROVENANCE set: the shell-running tools whose tier the engine's shell seat (read * boundary + shape tier + shellGate floor) is the SOLE POSITIVE source of — no explicit deployment mark on that name. * The one seat every consumer reads (risk grading, the gate's tighten attribution, the persisted-rule mandate * boundary): `shellGatedTools.has(toolName)`. Minted here, never grown afterwards; empty when the seat fold * did not run (no real writable shell). */ shellGatedTools: ReadonlySet<string>; /** borrowed-readonly — the ENV-HAND tool names: the leg's roster ledger's live set (`ToolMountLedger.envHands`), the mount * rows' `envHand` column over the rows this leg judged mounted — the fs/bash band here, then the driver's own env mounts * (Monitor, the worktree pair, the scheduler, LSP, Artifact) as they are judged. Consumed by the O9a external-content-target * fold, the command sandbox's plan and the sandbox-boundary station: membership is what the leg mounted, never a table of * names read apart from the leg's judgments (the wake/resume reconciliation table lists TaskStop, which is orchestration, * and misses Monitor/worktree, which are hands — both directions wrong for these consumers). */ envHandToolNames: ReadonlySet<string>; /** owned — the settle-time SEAT SEAL: re-anchors the session seat to the * task's OWN last-committed entry (see {@link import("./session-read-file-states.js").SessionReadFileStates.reanchor}). The driver calls * it once at the run's settle (every terminal, suspend included), under the session lock, passing * the last entryId ITS OWN run committed (the message_committed lane) — never a re-read of the * shared session leaf, which a concurrent writer on another Runner could have moved onto a branch * this task's reads were never on. No commits observed ⇒ no-op (the adopt-time anchor * stands). Synchronous, never throws. Undefined ⇔ hands-less / no seat channel. */ sealReadStateSeat: ((ownCommittedTailEntryId: string | undefined) => void) | undefined; } export declare function resolveHandsLessReadFace(input: PrepareHandsReadFaceInput): PrepareHandsReadFaceResult; /** The hands-MOUNT branch — the async half of the phase (see the module header for the contract). * The driver awaits this ONLY on the hands leg (`handsEnabled === true`); the hands-less leg goes * through the synchronous {@link resolveHandsLessReadFace} instead. Two seams, one boolean * dispatch — no `Promise`-identity guard (r3). */ export declare function prepareHandsMount(input: PrepareHandsReadFaceInput): Promise<PrepareHandsReadFaceResult>;