@sema-agent/core 5.65.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/agents/subagent.d.ts +2 -2
  3. package/dist/agents/subagent.js +11 -0
  4. package/dist/agents/verify.d.ts +1 -1
  5. package/dist/brain/anthropic.js +1 -1
  6. package/dist/brain/errors.d.ts +29 -0
  7. package/dist/brain/errors.js +20 -0
  8. package/dist/brain/open-responses.js +2 -2
  9. package/dist/brain/route-adjudicator.d.ts +8 -1
  10. package/dist/brain/route-adjudicator.js +1 -0
  11. package/dist/brain/status-sink.js +12 -1
  12. package/dist/brain/stream-engine.js +17 -6
  13. package/dist/core/auto-compaction.d.ts +26 -0
  14. package/dist/core/auto-compaction.js +7 -2
  15. package/dist/core/auto-mode-arming.d.ts +138 -0
  16. package/dist/core/auto-mode-arming.js +181 -0
  17. package/dist/core/auto-mode-defaults.d.ts +13 -0
  18. package/dist/core/auto-mode-defaults.js +5 -0
  19. package/dist/core/auto-mode-prompt.d.ts +14 -3
  20. package/dist/core/auto-mode-prompt.js +10 -7
  21. package/dist/core/auto-mode-rebuild.d.ts +75 -0
  22. package/dist/core/auto-mode-rebuild.js +41 -0
  23. package/dist/core/auto-mode.d.ts +15 -0
  24. package/dist/core/auto-mode.js +4 -2
  25. package/dist/core/checkpoint-store.d.ts +18 -0
  26. package/dist/core/context-edit.d.ts +47 -5
  27. package/dist/core/context-guard.d.ts +1 -1
  28. package/dist/core/file-history-retention.d.ts +106 -0
  29. package/dist/core/file-history-retention.js +36 -0
  30. package/dist/core/file-history-store.d.ts +768 -0
  31. package/dist/core/file-history-store.js +880 -0
  32. package/dist/core/governance-codes.d.ts +2 -1
  33. package/dist/core/governance-codes.js +14 -0
  34. package/dist/core/hooks.d.ts +39 -7
  35. package/dist/core/hooks.js +38 -21
  36. package/dist/core/lsp.d.ts +2 -2
  37. package/dist/core/mcp.d.ts +29 -7
  38. package/dist/core/memory-engine/consolidation-driver.d.ts +11 -0
  39. package/dist/core/memory-engine/consolidation-driver.js +71 -4
  40. package/dist/core/memory-engine/consolidation.d.ts +25 -2
  41. package/dist/core/memory-engine/consolidation.js +4 -1
  42. package/dist/core/memory-engine/distiller.d.ts +84 -1
  43. package/dist/core/memory-engine/distiller.js +68 -0
  44. package/dist/core/memory-engine/dual-root.js +3 -0
  45. package/dist/core/memory-engine/engine.d.ts +328 -15
  46. package/dist/core/memory-engine/engine.js +355 -29
  47. package/dist/core/memory-engine/file-backend.d.ts +30 -0
  48. package/dist/core/memory-engine/file-backend.js +14 -13
  49. package/dist/core/memory-engine/frontmatter.d.ts +22 -1
  50. package/dist/core/memory-engine/frontmatter.js +3 -0
  51. package/dist/core/memory-engine/header-hints.d.ts +5 -0
  52. package/dist/core/memory-engine/index.d.ts +5 -4
  53. package/dist/core/memory-engine/index.js +5 -4
  54. package/dist/core/memory-engine/layout.d.ts +88 -2
  55. package/dist/core/memory-engine/layout.js +112 -3
  56. package/dist/core/memory-engine/provenance-wording.d.ts +7 -0
  57. package/dist/core/memory-engine/provenance-wording.js +3 -0
  58. package/dist/core/memory-engine/tools.d.ts +89 -8
  59. package/dist/core/memory-engine/tools.js +263 -22
  60. package/dist/core/memory-engine/types.d.ts +64 -1
  61. package/dist/core/memory-recall.d.ts +6 -0
  62. package/dist/core/memory.d.ts +27 -1
  63. package/dist/core/memory.js +16 -2
  64. package/dist/core/permission-rule-consent.d.ts +20 -0
  65. package/dist/core/permission-rule-consent.js +12 -3
  66. package/dist/core/permission-rule-model.d.ts +67 -7
  67. package/dist/core/permission-rule-model.js +53 -7
  68. package/dist/core/permission-rule-store.js +15 -10
  69. package/dist/core/permission-rule-sync.js +15 -11
  70. package/dist/core/retention-policy.d.ts +9 -0
  71. package/dist/core/retention-policy.js +5 -2
  72. package/dist/core/retention.d.ts +13 -2
  73. package/dist/core/runner/assemble-result.d.ts +19 -1
  74. package/dist/core/runner/assemble-result.js +17 -2
  75. package/dist/core/runner/compaction-call-options.d.ts +93 -0
  76. package/dist/core/runner/compaction-call-options.js +3 -0
  77. package/dist/core/runner/memory-capture-optout.d.ts +80 -0
  78. package/dist/core/runner/memory-capture-optout.js +53 -0
  79. package/dist/core/runner/prepare-config-doors.d.ts +5 -0
  80. package/dist/core/runner/prepare-config-doors.js +16 -0
  81. package/dist/core/runner/prepare-hands-readface.d.ts +110 -5
  82. package/dist/core/runner/prepare-hands-readface.js +99 -7
  83. package/dist/core/runner/prepare-memory.d.ts +88 -0
  84. package/dist/core/runner/prepare-memory.js +305 -24
  85. package/dist/core/runner/prepare-task.d.ts +141 -1
  86. package/dist/core/runner/prepare-task.js +443 -79
  87. package/dist/core/runner/runtask.d.ts +9 -20
  88. package/dist/core/runner/runtask.js +133 -96
  89. package/dist/core/runner/session-file-state-replay.d.ts +18 -10
  90. package/dist/core/runner/session-file-state-replay.js +52 -1
  91. package/dist/core/runner/tool-disclosure.js +2 -1
  92. package/dist/core/runner/turn-attachments.d.ts +22 -12
  93. package/dist/core/session-store.d.ts +1 -1
  94. package/dist/core/session-store.js +6 -1
  95. package/dist/core/session.d.ts +34 -1
  96. package/dist/core/store-contracts/file-history-store-contract.d.ts +3 -0
  97. package/dist/core/store-contracts/file-history-store-contract.js +720 -0
  98. package/dist/core/task-registry-shared.js +11 -1
  99. package/dist/core/tool-errors.js +1 -0
  100. package/dist/core/tool-policy.d.ts +172 -1
  101. package/dist/core/tool-policy.js +32 -1
  102. package/dist/core/tool-result-store.js +2 -1
  103. package/dist/core/trace.d.ts +24 -0
  104. package/dist/core/types.d.ts +784 -89
  105. package/dist/core/types.js +4 -3
  106. package/dist/core/untrusted-text.d.ts +1 -1
  107. package/dist/core/untrusted-text.js +8 -0
  108. package/dist/core/workflow-run-store-contract.js +6 -2
  109. package/dist/core/workflow-run-store.d.ts +4 -1
  110. package/dist/engine/compaction/compaction.d.ts +88 -10
  111. package/dist/engine/compaction/compaction.js +109 -30
  112. package/dist/engine/execution-env/node-execution-env.d.ts +9 -1
  113. package/dist/engine/execution-env/node-execution-env.js +28 -0
  114. package/dist/engine/harness/agent-harness.d.ts +52 -1
  115. package/dist/engine/harness/agent-harness.js +36 -1
  116. package/dist/engine/harness/types.d.ts +26 -1
  117. package/dist/engine/llm/types.d.ts +50 -4
  118. package/dist/engine/loop/agent-loop.d.ts +5 -1
  119. package/dist/engine/loop/agent-loop.js +25 -0
  120. package/dist/engine/loop/types.d.ts +19 -0
  121. package/dist/engine/lsp/node-lsp-manager.d.ts +1 -1
  122. package/dist/engine/session/session.js +1 -1
  123. package/dist/index.d.ts +18 -8
  124. package/dist/index.js +14 -6
  125. package/dist/orchestration/run-workflow-tool.d.ts +20 -2
  126. package/dist/orchestration/run-workflow-tool.js +22 -3
  127. package/dist/orchestration/workflow-governance.d.ts +59 -1
  128. package/dist/orchestration/workflow-governance.js +61 -8
  129. package/dist/orchestration/workflow-meta.d.ts +4 -2
  130. package/dist/orchestration/workflow-primitives.js +56 -13
  131. package/dist/orchestration/workflow-types.d.ts +78 -2
  132. package/dist/orchestration/workflow.d.ts +20 -0
  133. package/dist/orchestration/workflow.js +163 -14
  134. package/dist/prompt-assembly/event-registry.js +1 -1
  135. package/dist/prompts/default.d.ts +7 -7
  136. package/dist/stores/file/file-history-store.d.ts +368 -0
  137. package/dist/stores/file/file-history-store.js +1248 -0
  138. package/dist/stores/file/index.d.ts +22 -13
  139. package/dist/stores/file/index.js +4 -4
  140. package/dist/stores/file/permission-rule-store.js +1 -0
  141. package/dist/stores/file/strategy-store.d.ts +3 -3
  142. package/dist/tools/fs/bash-readonly-classifier.d.ts +87 -3
  143. package/dist/tools/fs/bash-readonly-classifier.js +106 -4
  144. package/dist/tools/fs/fs-bash.js +9 -5
  145. package/dist/tools/fs/fs-shared.d.ts +52 -1
  146. package/dist/tools/fs/fs-shared.js +14 -0
  147. package/dist/tools/fs/fs-write.d.ts +5 -5
  148. package/dist/tools/fs/fs-write.js +71 -14
  149. package/dist/tools/fs/index.d.ts +6 -1
  150. package/dist/tools/fs/index.js +1 -1
  151. package/dist/tools/web.js +2 -1
  152. package/package.json +5 -1
  153. package/test/export-surface.snapshot.json +155 -23
  154. package/dist/core/file-snapshot-store.d.ts +0 -165
  155. package/dist/core/file-snapshot-store.js +0 -259
  156. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +0 -13
  157. package/dist/core/store-contracts/file-snapshot-store-contract.js +0 -134
  158. package/dist/stores/file/file-snapshot-store.d.ts +0 -58
  159. package/dist/stores/file/file-snapshot-store.js +0 -353
@@ -2,6 +2,7 @@ import { AgentHarness, type ThinkingLevel } from "../../internal/harness.js";
2
2
  import type { Model } from "../../internal/llm.js";
3
3
  import { type CompactionForkContext } from "../auto-compaction.js";
4
4
  import { type AutoModeDecider } from "../auto-mode.js";
5
+ import { type AutoModeArmingRecipe } from "../auto-mode-arming.js";
5
6
  import { type MaterializedMcp } from "../mcp.js";
6
7
  import { type MaterializedA2a } from "../a2a.js";
7
8
  import type { HarvestReport, MemorySessionHandle } from "../memory-engine/types.js";
@@ -17,6 +18,7 @@ import { CacheBreakDetector, type ToolFingerprintInput } from "../cache-break-de
17
18
  import { type BrainCallGuardrailRef } from "../../brain/timeout.js";
18
19
  import { type OutputRef, type BlockedRef, type SkillListingEntry } from "./synthetic-tools.js";
19
20
  import type { MemoryEngine } from "../memory-engine/engine.js";
21
+ import { type SessionReadFileStates } from "./prepare-hands-readface.js";
20
22
  import { type GitStatusLaneRef } from "./git-status-frame.js";
21
23
  import { type ToolManifestRow } from "../../prompt-assembly/tool-catalog.js";
22
24
  import type { ToolDisclosureManifest } from "../trace.js";
@@ -190,6 +192,20 @@ export type GuardChainOutcome = {
190
192
  * verbatim (arm-B adoption / the r8 dead-turn stand-down).
191
193
  */
192
194
  export declare function runGuardChain(args: GuardChainArgs): Promise<GuardChainOutcome>;
195
+ /**
196
+ * design/381 — the run's turn-start file-history BOUNDARY seat. `begin(entryId)` starts the capture
197
+ * for the turn's own initial entry (first-wins: exactly one boundary per turn incarnation, DV-4);
198
+ * `settle()` awaits the in-flight capture's settle and is the caller's LEASE CLOSE (awaited before
199
+ * the first tool executes) as well as the finish-tail durability await. The capture is bounded by a
200
+ * 30s timeout whose abort FENCES the attempt (the store's `boundaryPublishVerdict` guarantees a
201
+ * timed-out capture never publishes); failure is disclosed via onError(phase:"rewind") and NEVER
202
+ * blocks the turn — a turn whose capture failed simply has no boundary (the reference behaves the
203
+ * same), and there is no mid-turn re-capture (the store's spent lease refuses it with zero reads).
204
+ */
205
+ export interface FileHistoryBoundarySeat {
206
+ begin(entryId: string): void;
207
+ settle(): Promise<void>;
208
+ }
193
209
  export interface Prepared {
194
210
  harness: AgentHarness;
195
211
  /** The CONCRETE built-in session (engine-internal: prepare constructs/acquires `StoredSession` itself,
@@ -197,6 +213,26 @@ export interface Prepared {
197
213
  * the `Session` contract instead. */
198
214
  session: StoredSession;
199
215
  sessionId: string;
216
+ /**
217
+ * #499 — THIS INVOCATION's own identity, minted once at the top of {@link prepareTask} and never
218
+ * rewritten. The third id of the trio, and the only one the engine owns outright:
219
+ * - `spec.taskId` — the HOST's task identity (absent whenever the host names nothing);
220
+ * - `sessionId` — the CONVERSATION's identity (shared by every run that continues it);
221
+ * - `runId` — THIS call of the engine.
222
+ *
223
+ * The gap it closes: the repo-wide `spec.taskId ?? sessionId` spelling answers the same value for
224
+ * two runs of one session whenever the host supplies no task id, so every per-run account keyed on
225
+ * it FOLDED two runs into one row (two runs each losing one steer read as one run losing one).
226
+ * A per-run account must key on this; a per-TASK fact (trace `taskId`, the host's own correlation
227
+ * handle) must keep the task spelling — the two are different questions and the station sweep
228
+ * judged each one.
229
+ *
230
+ * Minted here (never at the Runner's stream entry) so that a standalone `prepareTask` exercise gets
231
+ * a real id too, and so the mint has exactly one site. A leg whose prepare THROWS never returns a
232
+ * `Prepared` at all — but the id still reaches its caller through the `runIdSink` carrier, because
233
+ * prepare emits run-scoped disclosures of its own and each must have a terminal that names it.
234
+ */
235
+ runId: string;
200
236
  /** design/319 (A ticket) — the session's reminder provenance mark this run mints under (adopted
201
237
  * through the prepare adoption ladder: checkpoint seed → trusted fork channel → session entry →
202
238
  * fresh mint). Every engine-authored `<system-reminder>` open tag in the run carries it, and the
@@ -276,6 +312,10 @@ export interface Prepared {
276
312
  /** RB-430-a: prepare-time rewind disclosures (conversation-only branch / no snapshot backend / no file
277
313
  * env), echoed verbatim onto `TaskResult.rewindNotes`. Present only when there is something to say. */
278
314
  rewindNotes?: NonNullable<TaskResult["rewindNotes"]>;
315
+ /** design/381 — the run's turn-start boundary seat (present iff a fileHistoryStore is wired and
316
+ * the run mounts a real fs env). runtask calls begin() at the first committed user entry and
317
+ * awaits settle() at the lease close + the finish tail. */
318
+ fileHistoryBoundary?: FileHistoryBoundarySeat;
279
319
  /** #240 (design/199 v1.1) + #242 — the run's RESOLVED read face for the result observation seat
280
320
  * (`TaskResult.effectiveReadFace`): `carrierReadFace()`'s value at prepare completion — the hands
281
321
  * block's single resolution, or the hands-less legs' resolver run (live spec-time facts, with the
@@ -308,6 +348,12 @@ export interface Prepared {
308
348
  restoredWorktreeDir?: string;
309
349
  baselineUnknown?: boolean;
310
350
  };
351
+ /** #483 codex r2+r3 — the settle-time session-seat SEAL (see prepare-hands-readface): re-anchors
352
+ * the per-session read-state seat to the entry id THIS run last committed (its own
353
+ * message_committed tail — provenance, never a shared-leaf re-read). The driver calls it once at
354
+ * the run's settle, every terminal (suspend included), under the session lock; undefined argument
355
+ * (no commits) is a no-op. Synchronous, never throws. Absent ⇔ hands-less / no seat channel. */
356
+ sealReadStateSeat?: (ownCommittedTailEntryId: string | undefined) => void;
311
357
  /** design/99 §E6 — the DENY-NARROWING layers (session rules + skill scope, deny-only). Re-checked on RESUME
312
358
  * before an approved pending tool executes, so a rule tightened during the suspend still applies. */
313
359
  denyNarrowingPolicy?: ToolPolicy;
@@ -491,6 +537,25 @@ export interface Prepared {
491
537
  /** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)). */
492
538
  inject: () => import("../memory-engine/engine.js").MemoryInjection;
493
539
  harvest: (phase?: "checkpoint" | "terminal") => Promise<HarvestReport | undefined>;
540
+ /**
541
+ * design/383 §2.1 — the session's capture opt-out face (the `TaskStream.optOutMemoryCapture`
542
+ * verb's target; host-API only — no tool face reads it, §2.6). `flip` re-adjudicates the
543
+ * entitlement at call time (fresh caps resolve), mints the one-way record, runs the §2.3
544
+ * boundary sweep, and delivers the effectiveness notice; its typed refusals are the
545
+ * `memory.capture_optout_*` family. `optedOut` is the live state read (declared / standing /
546
+ * flipped) — a GENUINE-record read: a store fault answers false here and TRUE on
547
+ * `indeterminate` instead (rescan post-6.0.0-RC — the fault must reach the delegation floor
548
+ * as its own third state, never as either boolean; an irreversible record is never minted off
549
+ * an unreadable state, and an outage must not spawn un-floored children). Present whenever
550
+ * the memory session mounted.
551
+ */
552
+ captureOptOut?: {
553
+ optedOut: () => boolean;
554
+ indeterminate: () => boolean;
555
+ flip: (reason?: string) => Promise<{
556
+ outcome: "created" | "existed";
557
+ }>;
558
+ };
494
559
  /**
495
560
  * design/178 §3 — the session's ONE-WAY pollution face. `markPolluted` fires when an
496
561
  * external-content-class tool is invoked (the prepare-time tool wrap below is the caller);
@@ -803,6 +868,22 @@ export interface Prepared {
803
868
  path: string;
804
869
  contentHash: string | null;
805
870
  }>;
871
+ /** #500 — the RAW instruction-file text this leg's `loadProjectMemory` returned
872
+ * (`ProjectMemoryLoad.content`), for the compaction lanes' `contextInstructionFiles` seat.
873
+ *
874
+ * Which bytes, exactly: the string prepare-task hands `composeMemoryBlock(projectMem, "project")`
875
+ * — pre-compose, unfenced, straight from the host seam. The two neighbours are deliberately NOT
876
+ * candidates: the assembled `memoryBlock` carries the memory ENGINE's layers (bytes the model
877
+ * itself authored in-band this session through the memory tools) and the seat's contract is
878
+ * host/systemPrompt tier; the COMPOSED project block would arrive at a mint that neutralizes the
879
+ * whole authority family, `user_memory`/`scope` included, so the engine would rewrite the tags of
880
+ * its own composition. Raw text in, one fence at the mint.
881
+ *
882
+ * Present only when the deployment wired the loader AND it answered non-blank — the same
883
+ * predicate that composes the project layer, so the summarizer's copy and the main prompt's copy
884
+ * can never disagree about whether this deployment HAS instruction files. Absent ⇒ every
885
+ * compaction lane omits the key entirely. */
886
+ projectInstructionContent?: string;
806
887
  /** The `workflow_size_guideline_change` lane's seam, the {@link dateChange} shape one lane over:
807
888
  * `legGuideline` = the RESOLVED guideline this leg's Workflow tool card was built with (the card is
808
889
  * a per-mount snapshot, so it never re-renders mid-leg — the model learns a retune from the tail
@@ -1165,6 +1246,16 @@ export interface InheritedGate {
1165
1246
  */
1166
1247
  autoMode?: {
1167
1248
  decider: AutoModeDecider;
1249
+ /**
1250
+ * #503 — the SERIALIZABLE criteria half of this classifier (assembly inputs + knobs + the
1251
+ * deployment's settings epoch), present when the arming deployment opted in
1252
+ * (`RunnerDeps.autoMode.persistArming`). A durable park records it on the chain entry so a
1253
+ * CROSS-PROCESS redemption can rebuild an equivalent decider over its own model leg instead of
1254
+ * answering `unavailable` forever; the constraint-chain digest binds it, so a resume re-supplies
1255
+ * exactly what the row carries. It never affects THIS process's decisions — the live `decider` is
1256
+ * the one every gate consults, here and on every descendant.
1257
+ */
1258
+ arming?: AutoModeArmingRecipe;
1168
1259
  };
1169
1260
  /**
1170
1261
  * Set ONLY on an entry whose `policy` is the folded form of an ancestor's PreToolUse screening face
@@ -1469,6 +1560,41 @@ export interface RunInternals {
1469
1560
  /** design/147 S2a — the spawning run's sessionId (paired with parentTaskId; see
1470
1561
  * ToolExecuteContext.parentSessionId). */
1471
1562
  parentSessionId?: string;
1563
+ /**
1564
+ * design/383 §2.5 — the memory-capture opt-out FLOOR: TRUE ⇔ the spawning session was under an
1565
+ * opt-out when this child spawned. The child then runs opted-out itself (its prepare mints its
1566
+ * own one-way record, reason naming the floor) — NOT re-adjudicated against the child's
1567
+ * entitlement (the floor is the parent's already-granted opt-out tightening the tree; a
1568
+ * re-adjudication that could answer "no" would be a loosening door). Trusted internals channel
1569
+ * on purpose (the parentInteractionPosture law): never a child-spec field, so no chosen
1570
+ * AgentDefinition and no spec surgery can shed it; rides `internalsSnapshot`, so retained
1571
+ * revivals keep it. Grandchildren inherit through each generation's own live seat (an opted-out
1572
+ * child forwards TRUE to its children in turn — monotone by construction).
1573
+ */
1574
+ memoryCaptureFloor?: true;
1575
+ /**
1576
+ * design/383 §2.5 (rescan post-6.0.0-RC) — the floor's THIRD state: the spawning session's
1577
+ * capture state was INDETERMINATE at spawn (its record store faulted at the getter read).
1578
+ * Neither boolean is honest there — no floor runs a possibly-recorded lineage captured, a coined
1579
+ * floor mints an IRREVERSIBLE record off an unreadable state — so the lane carries the fault
1580
+ * itself and the child's prepare resolves it against the live record query (found ⇒ floor;
1581
+ * still faulting ⇒ the child runs indeterminate — mechanical restrictions, no mint; readable
1582
+ * and clean ⇒ clean). Same trusted-channel law as {@link memoryCaptureFloor}; mutually
1583
+ * exclusive with it at the spawn site (the floor wins when the state IS known).
1584
+ */
1585
+ memoryCaptureFloorIndeterminate?: true;
1586
+ /** design/383 §2.5 — the spawning session's write-plane control dir (the coordinate its capture
1587
+ * opt-out record is keyed under), so a child on a DIFFERENT memory plane can still run the
1588
+ * record-query leg against the parent's own carrier. Trusted chain, rides internalsSnapshot. */
1589
+ memoryCaptureQueryDir?: string;
1590
+ /** design/383 §2.5 (codex round 3) — the ancestor chain's capture coordinates (root first, one
1591
+ * row per generation, appended by each spawner's ctx seat). The child's harvest closures walk
1592
+ * every row, so a mid-run flip ANYWHERE up the tree suppresses every in-flight descendant.
1593
+ * Trusted chain; rides internalsSnapshot. */
1594
+ memoryCaptureAncestors?: ReadonlyArray<{
1595
+ sessionId: string;
1596
+ controlDir?: string;
1597
+ }>;
1472
1598
  /**
1473
1599
  * The FLEET-task kind of this run, declared by the lane that spawned it and stamped onto every
1474
1600
  * `task_progress` tick the run mints (`TaskEvent`'s `taskType`). A consumer merging progress ticks
@@ -1582,6 +1708,14 @@ export interface RunInternals {
1582
1708
  /** design/116 detach: the run-local per-tool-call detach hub. runtask creates it and exposes
1583
1709
  * `TaskStream.detach(toolCallId)`; the hands Bash tool threads `signalFor(toolCallId)` into env.exec. */
1584
1710
  detachHub?: import("../tool-detach.js").ToolDetachHub;
1711
+ /**
1712
+ * #483 rung-1 — the Runner's per-session read-file-state seats (CC parity: readFileState is
1713
+ * session-scoped). Always set by the Runner's own prepare call (overriding any caller value, like
1714
+ * the peer refs beside it); absent on a standalone prepareTask, where the transcript-replay rung
1715
+ * covers alone. A CACHE, never an authority — see {@link SessionReadFileStates}. Trusted internals
1716
+ * channel, same posture as every other field here.
1717
+ */
1718
+ sessionReadStates?: SessionReadFileStates;
1585
1719
  onTaskNotification?: (notification: TaskNotificationPayload,
1586
1720
  /** Injection tier (design/373 — the ladder is LIVE): "next" = the running turn's next boundary
1587
1721
  * (arrival order, consecutive frames batch); "later" = the run's would-otherwise-stop seat
@@ -1783,4 +1917,10 @@ export declare function prepareTask(spec: TaskSpec, deps: RunnerDeps, sessions:
1783
1917
  /** design/98 §3.1 (S8c): a TRUSTED self-reference to the Runner, passed by the Runner itself (never a
1784
1918
  * TaskSpec field) so the `run_workflow` tool can execute child tasks via `runner.runTask`. Undefined when
1785
1919
  * prepareTask is exercised standalone (then run_workflow is simply not mounted). */
1786
- runnerSelf?: Runner): Promise<Prepared>;
1920
+ runnerSelf?: Runner,
1921
+ /** #499 — carrier for the id minted below, so a prepare that THROWS still lets its caller name the
1922
+ * run (prepare emits run-scoped notices of its own; each needs a terminal that names it). Same seat
1923
+ * shape the Runner uses for the generated taskId/sessionId. */
1924
+ runIdSink?: {
1925
+ runId?: string;
1926
+ }): Promise<Prepared>;