@sema-agent/core 7.61.0 → 7.63.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 (298) hide show
  1. package/CHANGELOG.md +840 -0
  2. package/dist/agents/cascade.d.ts +11 -3
  3. package/dist/agents/cascade.js +1 -1
  4. package/dist/agents/peer-held-queue.d.ts +27 -4
  5. package/dist/agents/peer-held-queue.js +81 -36
  6. package/dist/agents/peer-session-drain.js +13 -3
  7. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  8. package/dist/agents/subagent-transcript-placement.js +14 -0
  9. package/dist/agents/subagent.d.ts +6 -1
  10. package/dist/agents/subagent.js +143 -58
  11. package/dist/agents/suspend-guard.d.ts +38 -16
  12. package/dist/agents/suspend-guard.js +9 -4
  13. package/dist/agents/verify.js +4 -3
  14. package/dist/brain/route-adjudicator.js +9 -4
  15. package/dist/core/approval-object.js +1 -1
  16. package/dist/core/arg-summary.js +1 -1
  17. package/dist/core/ask-question.d.ts +2 -2
  18. package/dist/core/canonical-json.d.ts +23 -13
  19. package/dist/core/canonical-json.js +4 -4
  20. package/dist/core/checkpoint-features.d.ts +722 -0
  21. package/dist/core/checkpoint-features.js +98 -0
  22. package/dist/core/checkpoint-queries.d.ts +47 -4
  23. package/dist/core/checkpoint-queries.js +36 -16
  24. package/dist/core/checkpoint-requirements.d.ts +12 -5
  25. package/dist/core/checkpoint-requirements.js +11 -5
  26. package/dist/core/checkpoint-row-verdict.d.ts +110 -0
  27. package/dist/core/checkpoint-row-verdict.js +245 -0
  28. package/dist/core/checkpoint-store.d.ts +76 -753
  29. package/dist/core/checkpoint-store.js +83 -144
  30. package/dist/core/compliance.d.ts +6 -2
  31. package/dist/core/compliance.js +3 -3
  32. package/dist/core/engine-attestation.d.ts +1 -1
  33. package/dist/core/engine-notice.d.ts +38 -7
  34. package/dist/core/engine-notice.js +9 -2
  35. package/dist/core/gate-fold.js +2 -2
  36. package/dist/core/git-worktree-env.d.ts +62 -3
  37. package/dist/core/git-worktree-env.js +91 -30
  38. package/dist/core/governance-codes.d.ts +9 -3
  39. package/dist/core/governance-codes.js +16 -3
  40. package/dist/core/hooks.d.ts +13 -0
  41. package/dist/core/human-input-projection.d.ts +1 -0
  42. package/dist/core/human-input-projection.js +3 -0
  43. package/dist/core/image-admission.d.ts +1 -1
  44. package/dist/core/locked-config.d.ts +2 -2
  45. package/dist/core/mcp-host-seat.js +6 -1
  46. package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
  47. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  48. package/dist/core/memory-engine/consolidation.d.ts +73 -10
  49. package/dist/core/memory-engine/consolidation.js +167 -11
  50. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  51. package/dist/core/memory-engine/data-plane.js +11 -6
  52. package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
  53. package/dist/core/memory-engine/delegation-settlement.js +53 -59
  54. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  55. package/dist/core/memory-engine/dual-root.js +9 -5
  56. package/dist/core/memory-engine/engine.d.ts +98 -35
  57. package/dist/core/memory-engine/engine.js +477 -380
  58. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  59. package/dist/core/memory-engine/entry-scan.js +3 -0
  60. package/dist/core/memory-engine/file-backend.d.ts +29 -3
  61. package/dist/core/memory-engine/file-backend.js +66 -35
  62. package/dist/core/memory-engine/index.d.ts +7 -7
  63. package/dist/core/memory-engine/index.js +6 -6
  64. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  65. package/dist/core/memory-engine/landing-admission.js +3 -3
  66. package/dist/core/memory-engine/layout.d.ts +121 -45
  67. package/dist/core/memory-engine/layout.js +252 -102
  68. package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
  69. package/dist/core/memory-engine/memory-backend-contract.js +320 -0
  70. package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
  71. package/dist/core/memory-engine/memory-deployment.js +26 -12
  72. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  73. package/dist/core/memory-engine/scope-contract.js +68 -19
  74. package/dist/core/memory-engine/session-write-home.d.ts +3 -1
  75. package/dist/core/memory-engine/session-write-home.js +1 -1
  76. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  77. package/dist/core/memory-engine/sync-client.js +7 -0
  78. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  79. package/dist/core/memory-engine/sync-report.js +6 -2
  80. package/dist/core/memory-engine/tools.d.ts +2 -2
  81. package/dist/core/memory-engine/tools.js +10 -10
  82. package/dist/core/memory-engine/types.d.ts +118 -19
  83. package/dist/core/memory-engine/types.js +1 -0
  84. package/dist/core/memory-vector.d.ts +1 -1
  85. package/dist/core/memory.d.ts +10 -10
  86. package/dist/core/memory.js +15 -6
  87. package/dist/core/mode-policy.js +1 -1
  88. package/dist/core/mods/classic-events.d.ts +9 -1
  89. package/dist/core/mods/dollar.d.ts +32 -1
  90. package/dist/core/mods/dollar.js +13 -1
  91. package/dist/core/mods/kernel/events.d.ts +11 -3
  92. package/dist/core/mods/kernel/events.js +13 -10
  93. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  94. package/dist/core/mods/lifecycle-stations.js +44 -9
  95. package/dist/core/mods/session-append.d.ts +4 -1
  96. package/dist/core/mods/session-append.js +7 -0
  97. package/dist/core/mods/session-receive.js +12 -15
  98. package/dist/core/mods/stations.d.ts +70 -6
  99. package/dist/core/mods/stations.js +144 -1
  100. package/dist/core/own-property-receipt.d.ts +7 -0
  101. package/dist/core/own-property-receipt.js +3 -0
  102. package/dist/core/park-selfcheck.js +2 -2
  103. package/dist/core/pause-registry.d.ts +2 -0
  104. package/dist/core/pause-registry.js +3 -0
  105. package/dist/core/permission-rule-consent.d.ts +10 -3
  106. package/dist/core/permission-rule-consent.js +37 -24
  107. package/dist/core/permission-rule-store.d.ts +35 -1
  108. package/dist/core/permission-rule-store.js +27 -8
  109. package/dist/core/read-only-shell.js +3 -2
  110. package/dist/core/read-root-candidate.js +1 -1
  111. package/dist/core/redaction-marks.d.ts +8 -0
  112. package/dist/core/redaction-marks.js +6 -0
  113. package/dist/core/remote-env.d.ts +12 -1
  114. package/dist/core/remote-env.js +3 -0
  115. package/dist/core/resume-startup-cause.d.ts +5 -4
  116. package/dist/core/runner/child-tree.d.ts +29 -3
  117. package/dist/core/runner/child-tree.js +39 -16
  118. package/dist/core/runner/compact-session.js +5 -2
  119. package/dist/core/runner/contracts.d.ts +36 -17
  120. package/dist/core/runner/delegation-owner.d.ts +43 -0
  121. package/dist/core/runner/delegation-owner.js +59 -0
  122. package/dist/core/runner/gate-exit.js +2 -2
  123. package/dist/core/runner/inherited-ask-grants.js +1 -1
  124. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  125. package/dist/core/runner/lineage-reroot-view.js +108 -0
  126. package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
  127. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  128. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  129. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  130. package/dist/core/runner/permission-rule-lanes.d.ts +2 -1
  131. package/dist/core/runner/permission-rule-lanes.js +2 -2
  132. package/dist/core/runner/person-path-rows.d.ts +23 -3
  133. package/dist/core/runner/person-path-rows.js +31 -4
  134. package/dist/core/runner/placement-fence.d.ts +12 -0
  135. package/dist/core/runner/placement-fence.js +20 -6
  136. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  137. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  138. package/dist/core/runner/prepare-ask-lane.js +2 -2
  139. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
  140. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  141. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  142. package/dist/core/runner/prepare-config-doors.js +3 -4
  143. package/dist/core/runner/prepare-execution-env.js +17 -6
  144. package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
  145. package/dist/core/runner/prepare-hands-readface.js +32 -10
  146. package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
  147. package/dist/core/runner/prepare-inherited-gate.js +14 -6
  148. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  149. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  150. package/dist/core/runner/prepare-memory.d.ts +3 -2
  151. package/dist/core/runner/prepare-memory.js +28 -20
  152. package/dist/core/runner/prepare-park-ask.js +4 -3
  153. package/dist/core/runner/prepare-task.js +22 -16
  154. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  155. package/dist/core/runner/resume-admission.d.ts +3 -3
  156. package/dist/core/runner/resume-admission.js +6 -3
  157. package/dist/core/runner/resume-apply.d.ts +4 -0
  158. package/dist/core/runner/resume-apply.js +11 -4
  159. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  160. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  161. package/dist/core/runner/run-git-lane.d.ts +2 -0
  162. package/dist/core/runner/run-git-lane.js +4 -1
  163. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  164. package/dist/core/runner/run-harness-handlers.js +3 -2
  165. package/dist/core/runner/run-leg.js +25 -8
  166. package/dist/core/runner/run-settle-and-teardown.js +6 -4
  167. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  168. package/dist/core/runner/run-turn-boundary.js +7 -4
  169. package/dist/core/runner/runtask.js +6 -6
  170. package/dist/core/runner/steering-preview.d.ts +9 -0
  171. package/dist/core/runner/steering-preview.js +5 -0
  172. package/dist/core/runner/stream-steer-verb.js +8 -0
  173. package/dist/core/runner/terminal-account.js +1 -1
  174. package/dist/core/runner/tool-face-overlay.js +2 -0
  175. package/dist/core/runner/turn-attachments.d.ts +5 -0
  176. package/dist/core/runner/turn-attachments.js +1 -1
  177. package/dist/core/runner-deps.d.ts +8 -4
  178. package/dist/core/secret-env.d.ts +9 -6
  179. package/dist/core/secret-env.js +41 -22
  180. package/dist/core/session-checkout.d.ts +108 -0
  181. package/dist/core/session-checkout.js +485 -0
  182. package/dist/core/session-store.d.ts +13 -5
  183. package/dist/core/session-store.js +28 -4
  184. package/dist/core/session.d.ts +29 -5
  185. package/dist/core/session.js +3 -0
  186. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
  187. package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
  188. package/dist/core/store-contracts/session-store-contract.js +61 -8
  189. package/dist/core/task-event.d.ts +28 -1
  190. package/dist/core/task-notification.d.ts +9 -1
  191. package/dist/core/task-notification.js +8 -1
  192. package/dist/core/task-registry-agent.d.ts +40 -8
  193. package/dist/core/task-registry-agent.js +57 -24
  194. package/dist/core/task-registry-shared.d.ts +33 -11
  195. package/dist/core/task-registry-workflow.js +4 -3
  196. package/dist/core/task-registry.d.ts +27 -10
  197. package/dist/core/task-registry.js +19 -13
  198. package/dist/core/task-result.d.ts +5 -5
  199. package/dist/core/task-spec-members.js +1 -1
  200. package/dist/core/task-spec.d.ts +21 -1
  201. package/dist/core/terminal-cause.d.ts +6 -6
  202. package/dist/core/tool-face.d.ts +6 -2
  203. package/dist/core/tool-face.js +1 -1
  204. package/dist/core/tool-policy.d.ts +16 -13
  205. package/dist/core/tool-policy.js +11 -10
  206. package/dist/core/tool-roster.d.ts +4 -4
  207. package/dist/core/tool-spec.d.ts +42 -19
  208. package/dist/core/types.d.ts +2 -2
  209. package/dist/core/types.js +1 -1
  210. package/dist/core/untrusted-egress.d.ts +15 -4
  211. package/dist/core/untrusted-egress.js +23 -22
  212. package/dist/core/workspace-snapshot.d.ts +3 -1
  213. package/dist/core/workspace-snapshot.js +1 -0
  214. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  215. package/dist/engine/execution-env/node-execution-env.js +12 -5
  216. package/dist/engine/harness/types.d.ts +77 -1
  217. package/dist/engine/harness/types.js +108 -0
  218. package/dist/engine/session/import-validate.js +6 -1
  219. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  220. package/dist/engine/session/parent-chain-guard.js +1 -1
  221. package/dist/engine/session/path-to-root.d.ts +18 -3
  222. package/dist/engine/session/path-to-root.js +15 -1
  223. package/dist/engine/session/repo-utils.d.ts +12 -1
  224. package/dist/engine/session/repo-utils.js +41 -0
  225. package/dist/engine/session/session.d.ts +24 -1
  226. package/dist/engine/session/session.js +46 -2
  227. package/dist/engine/session/storage-base.d.ts +20 -0
  228. package/dist/engine/session/storage-base.js +28 -9
  229. package/dist/index.d.ts +16 -12
  230. package/dist/index.js +11 -8
  231. package/dist/internal/harness-types.d.ts +1 -1
  232. package/dist/internal/harness.d.ts +4 -3
  233. package/dist/internal/harness.js +3 -2
  234. package/dist/orchestration/run-workflow-tool.d.ts +7 -1
  235. package/dist/orchestration/run-workflow-tool.js +28 -11
  236. package/dist/orchestration/workflow-governance.d.ts +1 -1
  237. package/dist/orchestration/workflow.d.ts +6 -0
  238. package/dist/orchestration/workflow.js +5 -8
  239. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  240. package/dist/stores/file/checkpoint-store.js +7 -6
  241. package/dist/stores/file/fs-atomic.d.ts +0 -22
  242. package/dist/stores/file/fs-atomic.js +0 -17
  243. package/dist/stores/file/index.d.ts +2 -9
  244. package/dist/stores/file/index.js +2 -4
  245. package/dist/stores/file/session-store.d.ts +13 -7
  246. package/dist/stores/file/session-store.js +42 -18
  247. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  248. package/dist/tools/fs/bash-program-position.js +10 -10
  249. package/dist/tools/fs/program-read-model.d.ts +34 -10
  250. package/dist/tools/fs/program-read-model.js +37 -7
  251. package/dist/tools/fs/program-read-model.rows.js +13 -2
  252. package/dist/tools/fs/read-deny.d.ts +13 -1
  253. package/dist/tools/fs/read-deny.js +10 -2
  254. package/dist/tools/fs/removal-targets.js +5 -5
  255. package/dist/tools/fs/safety.d.ts +2 -0
  256. package/dist/tools/fs/safety.js +1 -1
  257. package/dist/tools/fs/shell-read-argv.d.ts +11 -2
  258. package/dist/tools/fs/shell-read-argv.js +45 -29
  259. package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
  260. package/dist/tools/fs/shell-read-bindings.js +153 -69
  261. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  262. package/dist/tools/fs/shell-read-brace.js +79 -0
  263. package/dist/tools/fs/shell-read-check.js +29 -11
  264. package/dist/tools/fs/shell-read-establish.js +43 -22
  265. package/dist/tools/fs/shell-read-functions.js +2 -2
  266. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  267. package/dist/tools/fs/shell-read-judge.js +3 -3
  268. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  269. package/dist/tools/fs/shell-read-object-path.js +119 -0
  270. package/dist/tools/fs/shell-read-plan.d.ts +18 -0
  271. package/dist/tools/fs/shell-read-plan.js +217 -104
  272. package/dist/tools/fs/shell-read-start.d.ts +76 -13
  273. package/dist/tools/fs/shell-read-start.js +97 -17
  274. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  275. package/dist/tools/fs/shell-read-word.js +9 -5
  276. package/dist/tools/fs/shell-read-workdir.d.ts +54 -14
  277. package/dist/tools/fs/shell-read-workdir.js +103 -19
  278. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  279. package/dist/tools/worktree.d.ts +3 -2
  280. package/dist/tools/worktree.js +7 -35
  281. package/package.json +3 -2
  282. package/test/export-surface.snapshot.json +93 -43
  283. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  284. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  285. package/wire-changes/core@7.62.0.json +2181 -0
  286. package/wire-changes/core@7.63.0.json +3523 -0
  287. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  288. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  289. package/wire-changes/primitives@7.62.0.json +30 -0
  290. package/wire-changes/primitives@7.63.0.json +445 -0
  291. package/dist/core/consolidate-scope.d.ts +0 -93
  292. package/dist/core/consolidate-scope.js +0 -98
  293. package/dist/core/credential-vocabulary.d.ts +0 -176
  294. package/dist/core/credential-vocabulary.js +0 -190
  295. package/dist/core/redaction-passes.d.ts +0 -82
  296. package/dist/core/redaction-passes.js +0 -377
  297. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  298. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -38,8 +38,12 @@ export type ToolMountTag = (typeof TOOL_MOUNT_TAGS)[number];
38
38
  import type { AssertAllKeysHandled } from "./ask-origin.js";
39
39
  /** The closed set of specialised approval cards a shell may pre-select from a render hint. The hint is a
40
40
  * PRE-FILTER: the shell owns each card's input schema and validates the call's full args before
41
- * mounting the card (design/388 §2.5 boundary ①). */
42
- export declare const TOOL_APPROVAL_CARDS: readonly ["file-edit", "file-write", "notebook-edit", "shell", "fetch", "skill", "workflow", "plan", "question", "generic"];
41
+ * mounting the card (design/388 §2.5 boundary ①).
42
+ *
43
+ * `computer-access` (the call carries `apps`, the list asked for) and `computer-control` (the call carries nothing the
44
+ * card needs) are the two consent cards of a tool that hands the model the user's screen; a caller or an MCP overlay may
45
+ * declare either. What each grants is per connection: `docs/sdk/04-tools-and-mcp.md` states the lifetime. */
46
+ export declare const TOOL_APPROVAL_CARDS: readonly ["file-edit", "file-write", "notebook-edit", "shell", "fetch", "skill", "workflow", "plan", "question", "generic", "computer-access", "computer-control"];
43
47
  export type ToolApprovalCard = (typeof TOOL_APPROVAL_CARDS)[number];
44
48
  /** Membership in the closed set — the one screen a stored or declared card word passes before it is read. */
45
49
  export declare function isToolApprovalCard(word: unknown): word is ToolApprovalCard;
@@ -1,6 +1,6 @@
1
1
  export const TOOL_FAMILIES = Object.freeze(["shell", "file-read", "file-write", "search", "web", "delegate", "plan", "scaffold", "memory", "protocol", "other"]);
2
2
  export const TOOL_MOUNT_TAGS = Object.freeze(["hands", "backgroundTasks", "workflow", "delegation", "hostInternals", "peerLane", "scheduler", "memory", "scenario", "always", "optional"]);
3
- export const TOOL_APPROVAL_CARDS = Object.freeze(["file-edit", "file-write", "notebook-edit", "shell", "fetch", "skill", "workflow", "plan", "question", "generic"]);
3
+ export const TOOL_APPROVAL_CARDS = Object.freeze(["file-edit", "file-write", "notebook-edit", "shell", "fetch", "skill", "workflow", "plan", "question", "generic", "computer-access", "computer-control"]);
4
4
  export function isToolApprovalCard(word) {
5
5
  return typeof word === "string" && TOOL_APPROVAL_CARDS.includes(word);
6
6
  }
@@ -564,11 +564,13 @@ export interface AskRuleEvidence {
564
564
  }
565
565
  /** The human/model-readable text of a decision. */
566
566
  export declare function decisionText(d: PermissionResult): string | undefined;
567
- /** Does a license (a record's `inputDigest`) cover the bytes that `runs`? The ONE judge — the gate's ledger keeps a settlement for
568
- * the bytes it licensed by it, and the unstated question asks whether an answer was given for these bytes by it. A license for
569
- * bytes covers what the tool reads them as ({@link argsReadFrom}: the one recorded step a reading took to `runs`). Compared by
570
- * the EXACT digest only: bytes outside the bindable domain have none and are covered by no license. */
571
- export declare function licenseCovers(licensed: string | undefined, runs: unknown): boolean;
567
+ /** Does a license (a record's `inputDigest`, a park row's `boundInputHash`) cover the call of `tool` over the bytes that `runs`? The
568
+ * ONE judge — the gate's ledger keeps a settlement for the bytes it licensed by it, and the unstated question asks whether an
569
+ * answer was given for these bytes by it. A license binds the tool and the bytes together ({@link exactBoundInputHashOf}), so a
570
+ * license for one tool covers no call of another. A license for bytes covers what the tool reads them as ({@link argsReadFrom}:
571
+ * the one recorded step a reading took to `runs`). Compared by the EXACT digest only: bytes outside the bindable domain have
572
+ * none and are covered by no license. */
573
+ export declare function licenseCovers(licensed: string | undefined, tool: string, runs: unknown): boolean;
572
574
  /**
573
575
  * THE judge of whether an approval can be bound to arguments, and the arguments it binds — asked wherever an approval is about to
574
576
  * be asked or adopted, and nowhere else: the ask resolver (its no-approver arm too) and the approval policy before anyone is asked,
@@ -665,7 +667,8 @@ export type ToolIdentity = Pick<ToolCallRequest, "toolName" | "face">;
665
667
  export type WholeToolRefusal = (tool: ToolIdentity) => boolean;
666
668
  /** The judge of a policy with no whole-tool deny rule. */
667
669
  export declare const REFUSES_NO_WHOLE_TOOL: WholeToolRefusal;
668
- /** The id a whole-tool judge's read carries — no call of the leg, so every rule reader takes a read of its own for it. */
670
+ /** The id a whole-tool judge's read of the session rules carries — no call of the leg, so that reader takes a read of its own
671
+ * for it (the person's rules are read for a request through `PersonPathRows.forRequest`). */
669
672
  export declare const TOOL_TABLE_VIEW_READ = "tool-table-view";
670
673
  /**
671
674
  * The members a policy carries beside `check` — one table for every seat that carries them: {@link wrapToolPolicy} reads
@@ -1297,14 +1300,14 @@ export interface AskRequest {
1297
1300
  * bidi bit's two faces can.
1298
1301
  */
1299
1302
  readonly previewWithheld?: "oversize" | "unavailable";
1300
- /** Canonical digest of {@link args} as presented in THIS ask, computed by the engine's one
1301
- * `boundInputHashOf` — the same digest a durable park binds its checkpoint to, so an aggregating
1303
+ /** Canonical digest of the call's tool ({@link toolName}) and {@link args} as presented in THIS ask, computed by the engine's
1304
+ * one call binding (`exactBoundInputHashOf`) — the same digest a durable park binds its checkpoint to, so an aggregating
1302
1305
  * approver can reconcile a synchronous ask row against a parked checkpoint row for the same call
1303
- * by `(toolCallId, hash)` equality. RECONCILIATION metadata only, never adjudication input: it
1304
- * repeats for two asks over identical args, and an `updatedInput` edit round re-mints it over the
1305
- * edited args. Filled at the `resolveAsk` chokepoint (present for every wired-approver call, so a
1306
- * mint site added later is covered by construction); optional on the type because a deployment may
1307
- * invoke its approver function directly. */
1306
+ * by `(toolCallId, hash)` equality, and two calls of different tools over identical args under one id do not reconcile.
1307
+ * RECONCILIATION metadata only, never adjudication input: it repeats for two asks of one tool over identical args, and an
1308
+ * `updatedInput` edit round re-mints it over the edited args. Filled at the `resolveAsk` chokepoint (present for every
1309
+ * wired-approver call, so a mint site added later is covered by construction); optional on the type because a deployment
1310
+ * may invoke its approver function directly. */
1308
1311
  readonly boundInputHash?: string;
1309
1312
  /** A call to the engine's `Skill` tool: the hash of {@link boundGrants} — the digest a parked approval of the same card is judged by, so a live card reconciles against its parked row by `(toolCallId, boundGrantDigest)` and an answer is remembered by "this tool + this binding". Present exactly on that call (whoever asked, however the question was worded); every other card carries {@link boundGrantAbsence} instead; `message` renders the same lists narrowed to what releases in the leg's mode. Reconciliation metadata, never adjudication input. */
1310
1313
  readonly boundGrantDigest?: string;
@@ -16,7 +16,7 @@ import { readOnlyShellVerdict } from "./read-only-shell.js";
16
16
  import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, withGateTimeout } from "./gate-bounded-await.js";
17
17
  import { protectivePathTargetOf, shellFaceToolNames } from "./tool-registry.js";
18
18
  import { heldBy } from "./tool-name-readings.js";
19
- import { bindableValueOf, boundInputHashOf, describeBindingFault, exactBoundInputHashOf } from "./canonical-json.js";
19
+ import { bindableValueOf, describeBindingFault, exactBoundInputHashOf } from "./canonical-json.js";
20
20
  import { delimitUntrusted, inlineUntrusted, REVIEWER_NOTE_MAX_BODY } from "./untrusted-text.js";
21
21
  import { describeRejectedValue } from "./tool-search-setting.js";
22
22
  import { egressText, egressThrownText } from "./untrusted-egress.js";
@@ -98,8 +98,8 @@ export const ASK_EVIDENCE_ABSENCE_VALUES = ["not_wired", "not_adjudicated", "una
98
98
  export function decisionText(d) {
99
99
  return d.message;
100
100
  }
101
- export function licenseCovers(licensed, runs) {
102
- return licensed !== undefined && (licensed === exactBoundInputHashOf(runs) || licensed === exactBoundInputHashOf(argsReadFrom(runs)));
101
+ export function licenseCovers(licensed, tool, runs) {
102
+ return licensed !== undefined && (licensed === exactBoundInputHashOf(tool, runs) || licensed === exactBoundInputHashOf(tool, argsReadFrom(runs)));
103
103
  }
104
104
  export function bindableArgsOf(toolName, args) {
105
105
  const bound = bindableValueOf(args);
@@ -118,7 +118,7 @@ export function bindingRefusalOf(toolName, args, fault) {
118
118
  }
119
119
  export function answeredFor(d, call, runs) {
120
120
  const record = attestationOf(d, call);
121
- return record?.settlement !== undefined && licenseCovers(record.inputDigest, runs);
121
+ return record?.settlement !== undefined && licenseCovers(record.inputDigest, call.toolName, runs);
122
122
  }
123
123
  export const REFUSES_NO_WHOLE_TOOL = () => false;
124
124
  export const TOOL_TABLE_VIEW_READ = "tool-table-view";
@@ -499,9 +499,9 @@ export function createApprovalPolicy(opts) {
499
499
  if (!bound.ok)
500
500
  return attestOver(undefined)({ action: "deny", message: bound.refusal }, settledByNobody("presentation_failed"), bound.refusal);
501
501
  const shown = { value: structuredClone(bound.value) };
502
- const askedDigest = exactBoundInputHashOf(shown.value);
502
+ const askedDigest = exactBoundInputHashOf(req.toolName, shown.value);
503
503
  const attest = attestOver(askedDigest);
504
- const heldWhileWaiting = () => licenseCovers(askedDigest, req.args);
504
+ const heldWhileWaiting = () => licenseCovers(askedDigest, req.toolName, req.args);
505
505
  const changedWhilePending = () => attest({
506
506
  action: "deny",
507
507
  message: `the arguments of "${req.toolName}" changed while its approval was pending — denied fail-closed ` +
@@ -1131,11 +1131,11 @@ export function carriesBidiControls(value, limits) {
1131
1131
  }
1132
1132
  }
1133
1133
  export async function resolveAsk(req, onAsk, signal, onLateSettlement) {
1134
- const askedDigest = exactBoundInputHashOf(req.args);
1134
+ const askedDigest = exactBoundInputHashOf(req.toolName, req.args);
1135
1135
  const { settlement, bindingRefusal, ...r } = await resolveAskArms(req, onAsk, signal, onLateSettlement);
1136
1136
  if (settlement === undefined)
1137
1137
  return r;
1138
- const licensedDigest = r.action === "allow" && r.updatedInput !== undefined ? exactBoundInputHashOf(r.updatedInput) : r.presentedInput !== undefined ? exactBoundInputHashOf(r.presentedInput) : askedDigest;
1138
+ const licensedDigest = r.action === "allow" && r.updatedInput !== undefined ? exactBoundInputHashOf(req.toolName, r.updatedInput) : r.presentedInput !== undefined ? exactBoundInputHashOf(req.toolName, r.presentedInput) : askedDigest;
1139
1139
  return attest(r, req, { settlement, ...(req.origin !== undefined ? { origin: req.origin } : {}), ...(req.classes !== undefined ? { classes: req.classes } : {}), ...(licensedDigest !== undefined ? { inputDigest: licensedDigest } : {}), ...(bindingRefusal !== undefined ? { bindingRefusal } : {}) });
1140
1140
  }
1141
1141
  function raceAskWaitAgainstSignal(wait, signal) {
@@ -1290,11 +1290,12 @@ async function resolveAskArms(req, onAsk, signal, onLateSettlement) {
1290
1290
  let ok;
1291
1291
  try {
1292
1292
  const approverView = { value: structuredClone(presented.value) };
1293
+ const reconciliationHash = exactBoundInputHashOf(req.toolName, presented.value);
1293
1294
  const bidi = carriesBidiControls(presented.value) || carriesBidiControls(req.preview);
1294
- const { hasBidiControls: _carried, ...bare } = req;
1295
+ const { hasBidiControls: _carried, boundInputHash: _claimed, ...bare } = req;
1295
1296
  const wait = Promise.resolve(onAsk({
1296
1297
  ...bare,
1297
- boundInputHash: boundInputHashOf(presented.value),
1298
+ ...(reconciliationHash !== undefined ? { boundInputHash: reconciliationHash } : {}),
1298
1299
  args: approverView.value,
1299
1300
  ...(bidi ? { hasBidiControls: true } : {}),
1300
1301
  ...(offered !== undefined ? { readRootCandidate: { ...offered } } : {}),
@@ -9,7 +9,7 @@ export declare const ToolRosterRenderHints: Type.TObject<{
9
9
  activity: Type.TOptional<Type.TString>;
10
10
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
11
11
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
12
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
12
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
13
13
  }>;
14
14
  export declare const ToolRosterEntry: Type.TObject<{
15
15
  name: Type.TString;
@@ -85,7 +85,7 @@ export declare const ToolRosterEntry: Type.TObject<{
85
85
  activity: Type.TOptional<Type.TString>;
86
86
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
87
87
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
88
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
88
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
89
89
  }>>;
90
90
  /** The ONE mount condition that fired for this instance. */
91
91
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -170,7 +170,7 @@ export declare const ToolRoster: Type.TObject<{
170
170
  activity: Type.TOptional<Type.TString>;
171
171
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
172
172
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
173
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
173
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
174
174
  }>>;
175
175
  /** The ONE mount condition that fired for this instance. */
176
176
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -263,7 +263,7 @@ export declare const ToolRosterDelta: Type.TObject<{
263
263
  activity: Type.TOptional<Type.TString>;
264
264
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
265
265
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
266
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
266
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
267
267
  }>>;
268
268
  /** The ONE mount condition that fired for this instance. */
269
269
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -16,6 +16,7 @@ import type { TaskSpec } from "./task-spec.js";
16
16
  import type { BackgroundChildEvent } from "./delegation-frames.js";
17
17
  import type { ModelRef } from "./model-seat.js";
18
18
  import type { ToolFamily, ToolHostTarget, ToolPathTarget, ToolRenderHints, ToolRuleFace } from "./tool-face.js";
19
+ import type { MemoryGovernanceDocs } from "./memory-engine/types.js";
19
20
  /**
20
21
  * Side-effect class of a tool. Used by wake/resume reconciliation: when a call was interrupted
21
22
  * before its result was recorded, the outcome is unknown, so core must decide whether re-doing it
@@ -672,6 +673,14 @@ export interface NestedUsageAccum {
672
673
  * carry knownness alongside the number it qualifies. */
673
674
  anyUnpriced: boolean;
674
675
  }
676
+ /** {@link ToolExecuteContext.delegationSettlement}'s answer: where a delegation's settlement rows are kept (the WRITE
677
+ * plane's governance store), that plane's control-plane directory (the pollution marker and the hold custody files a
678
+ * settled delegation's effects reach), and the session whose rows they are. */
679
+ export interface DelegationSettlementSeat {
680
+ readonly governance: MemoryGovernanceDocs;
681
+ readonly controlDir: string;
682
+ readonly sessionId: string;
683
+ }
675
684
  export interface ToolExecuteContext {
676
685
  toolCallId: string;
677
686
  signal?: AbortSignal;
@@ -700,6 +709,10 @@ export interface ToolExecuteContext {
700
709
  * fixed point `ctx.rootSessionId ?? ctx.sessionId` at every spawn). Absent for a top-level run
701
710
  * (its OWN sessionId is the root). */
702
711
  rootSessionId?: string;
712
+ /** The run's delegation tree owner seat (`RunInternals.delegationOwner`, Runner-filled): a delegation tool reads the tree's owner
713
+ * through it for the rows it creates for a child (a placed transcript, a fork, a park's durable row) and threads it into a spawned
714
+ * child's internals by reference — never into a revival's. */
715
+ delegationOwner?: import("./runner/delegation-owner.js").DelegationOwnerSeat;
703
716
  /** design/380 O1② (C12) — the spawning run's EXPLICIT placement fixed point
704
717
  * (`RunInternals.placementRoot`), present only when its internals carried one (cascade rungs /
705
718
  * verification legs after the first, or a caller-declared root). A delegation tool threads it
@@ -813,18 +826,31 @@ export interface ToolExecuteContext {
813
826
  * session backing, the child run fails LOUD ("refusing a silent fresh run") instead of silently
814
827
  * running an empty session under the forked id. Split-runner deployments must share session backing
815
828
  * (same store instance or same durable backend) for fork to complete.
816
- */
817
- hostSessionFork?: () => Promise<{
829
+ *
830
+ * The one argument is the store's own fork placement ({@link import("./session.js").SessionStore.fork}'s `opts`): a background
831
+ * fork's delegation tuple, laid down by the branch's creating write. It names no owner and no source — those stay bound here. It
832
+ * is handed on only when the host store declares the partition (the store creating the branch is the one that opts in); otherwise
833
+ * the branch is an ordinary fork.
834
+ */
835
+ hostSessionFork?: (opts?: {
836
+ placement?: Omit<import("./session.js").SessionPlacement, "owner">;
837
+ }) => Promise<{
818
838
  sessionId: string;
819
839
  release: () => Promise<void>;
820
840
  } | null>;
821
841
  /**
822
- * The RUNNING task's effective working root (worktree-aware), Runner-filled — read-only context a
823
- * delegation tool threads into its child's trusted internals so the child's env can inherit the
824
- * parent's cwd (CC parity: a Task sub-agent works in the main session's directory). Undefined when
825
- * the tool runs outside a Runner task.
842
+ * The RUNNING task's WRITE LOCATION (worktree-aware: the EnterWorktree tree while one is active, the task root otherwise —
843
+ * `currentCheckoutOf`, read at the call), Runner-filled — read-only context a delegation tool threads into its child's
844
+ * trusted internals so the child's env can inherit where the parent works (CC parity: a Task sub-agent works in the main
845
+ * session's directory). Undefined when the tool runs outside a Runner task.
826
846
  */
827
847
  parentCwd?: string;
848
+ /**
849
+ * The RUNNING task's own task root, Runner-filled beside {@link parentCwd}: the checkout a delegated child placed in "the
850
+ * caller's tree" would be writing into, whichever tree the caller has switched to inside it — what the child's placement
851
+ * judgment compares against (`RunInternals.callerRoot`). Absent on a ctx a caller outside the Runner built: its root is then where it works ({@link parentCwd}).
852
+ */
853
+ callerRoot?: string;
828
854
  /**
829
855
  * The RUNNING task's own placement target (Runner-filled, read-only, never a model argument): what its execution
830
856
  * environment reported as its workspace settled. A delegation tool hands it, as is, to every agent it spawns or wakes
@@ -1222,19 +1248,16 @@ export interface ToolExecuteContext {
1222
1248
  */
1223
1249
  delegationProvenanceForChildren?: () => import("./memory-engine/delegation-provenance.js").DelegationContentSafety | undefined;
1224
1250
  /**
1225
- * design/336 §3.3 — the delegation-settlement account's coordinates (the WRITE plane's memory
1226
- * control dir + this session's id), Runner-filled when the run mounts a memory session under
1227
- * `memoryProvenance: "carry"`. A delegation tool's BACKGROUND lane writes its launch write-ahead
1228
- * (pending row BEFORE registration and invoke) and its terminal settle through these — as pure
1229
- * data, because the terminal observation can run after this task leg returned and must rebuild
1230
- * its write handle from the coordinates alone. Undefined ⇒ no settlement account (memory-less
1231
- * run, or `"off"`): the background lane launches without rows, the pre-336 accepted-cost shape.
1232
- * Same trust posture as {@link delegationProvenanceForChildren}: never a model/tool argument.
1233
- */
1234
- delegationSettlement?: () => {
1235
- controlDir: string;
1236
- sessionId: string;
1237
- } | undefined;
1251
+ * design/336 §3.3 — the delegation-settlement account's coordinates (the WRITE plane's governance
1252
+ * store + its memory control dir + this session's id), Runner-filled when the run mounts a memory
1253
+ * session under `memoryProvenance: "carry"`. A delegation tool's BACKGROUND lane writes its launch
1254
+ * write-ahead (pending row BEFORE registration and invoke) and its terminal settle through these —
1255
+ * never through a live engine or session, because the terminal observation can run after this task
1256
+ * leg returned. Undefined ⇒ no settlement account (memory-less run, or `"off"`): the background lane
1257
+ * launches without rows, the pre-336 accepted-cost shape. Same trust posture as
1258
+ * {@link delegationProvenanceForChildren}: never a model/tool argument.
1259
+ */
1260
+ delegationSettlement?: () => DelegationSettlementSeat | undefined;
1238
1261
  /**
1239
1262
  * RB-201 FO-3 (form-one audit) — the auto-mode classifier decider ARMED
1240
1263
  * for THIS task (auto-mode intent ∧ `RunnerDeps.autoMode` present ∧ `RuntimeCaps.autoMode !== false`
@@ -15,7 +15,7 @@ export type { ModelRef, ModelRole, RoleSpec, ModelRoles, Brain } from "./model-s
15
15
  export { MODEL_ROLES } from "./model-seat.js";
16
16
  export type { StaleToolResultOffloadOptions, ImageInput, TaskSpec, ShellGateDoctrine, UserAttachment } from "./task-spec.js";
17
17
  export type { PermissionMode } from "./ask-origin.js";
18
- export type { ToolEffect, ToolContentOrigin, ReversibilityVerdict, ReadRootGrantCandidate, ToolSpec, ToolReturn, NestedUsage, NestedUsageAccum, ToolExecuteContext } from "./tool-spec.js";
18
+ export type { ToolEffect, ToolContentOrigin, ReversibilityVerdict, ReadRootGrantCandidate, ToolSpec, ToolReturn, NestedUsage, NestedUsageAccum, ToolExecuteContext, DelegationSettlementSeat } from "./tool-spec.js";
19
19
  export type { BeforeWriteRequest, BeforeWriteResult, BeforeWriteHook, TrackEditRequest, TrackEditResult, TrackFileEditHook, FileEditedNotice, FileEditedHook, HandsBandOptions } from "./hands-band.js";
20
20
  export type { AgentDefinition, SkillSpec } from "./agent-definition.js";
21
21
  export type { McpServerSpec, A2aServerSpec, McpElicitRequest, McpElicitResponse, OnElicit, McpRevocationLedger, McpMountIdentity, McpTransportKind, DeclarationFault, DeclarationPathRule, DeclarationRead, ToolAxesRead, ToolAxesSurface } from "./mcp-server-spec.js";
@@ -31,5 +31,5 @@ export type { BackgroundChildEvent, BackgroundChildRow, DelegationLifecycleEvent
31
31
  export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
32
32
  export type { ProjectMemoryLoad, ResumePreflightInfo, ResumePreflightVerdict, RunnerDeps } from "./runner-deps.js";
33
33
  export type { ApprovalCarryRefusal, EngineNotice, HeldUserInputs, OwedInputIds, OwedUserInputAccount, UserInputUndrainedCause } from "./engine-notice.js";
34
- export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
34
+ export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, setDefaultEngineNoticeSeat, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
35
35
  export type { AgentTool, Model, StreamFn, ThinkingLevel, ToolInputValidationContext, ToolInputVerdict };
@@ -2,4 +2,4 @@ export { MODEL_ROLES } from "./model-seat.js";
2
2
  export { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, MCP_TRANSPORT_KINDS, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, dataKind, declarationFaultOf, declarationPath, declarerWord, perToolEmptyName, perToolEntryRefusal, readMcpToolAxes, readToolAxes, receiveDeclaration, receivePerToolDeclaration, toolAxesRefusal, transportKindOf } from "./mcp-server-spec.js";
3
3
  export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
4
4
  export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
5
- export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
5
+ export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, setDefaultEngineNoticeSeat, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
@@ -1,6 +1,16 @@
1
- import { type RedactionReport } from "./redaction-passes.js";
2
- export type { RedactionFinding, RedactionReport, RedactionConfidence, RedactionSource, SummarizableFinding, } from "./redaction-passes.js";
3
- export { summarizeRedactions } from "./redaction-passes.js";
1
+ import { type RedactionReport, type SummarizableFinding } from "@sema-agent/primitives";
2
+ export type { RedactionFinding, RedactionReport, RedactionConfidence, RedactionSource, SummarizableFinding } from "@sema-agent/primitives";
3
+ /** Render findings as ONE human-readable line, e.g. `"3 redactions: prefixed-token (high) x1, url (medium) x1, fs-path (low)
4
+ * x1"`, so an upper layer can declare to its consumer how much was removed and how confidently.
5
+ *
6
+ * PURE, and deliberately only that: it reads the array, returns a string, and injects nothing anywhere. Attaching this
7
+ * line to an output is the caller's decision — a redaction pipeline that silently appended prose to the very text it was
8
+ * asked to bound would break both the size contract (`boundedString`) and the byte-invariance the whole channel is built
9
+ * on.
10
+ *
11
+ * Grouping is by kind AND confidence together: collapsing on kind alone would report whichever confidence happened to
12
+ * arrive first for the rest of that group, a silent mis-statement of how sure the removals were. */
13
+ export declare function summarizeRedactions(findings: readonly SummarizableFinding[]): string;
4
14
  /**
5
15
  * Every exit that redacts — into a model's context, a host's event or error lane, a log line, a person's screen — does it
6
16
  * with ONE pass, its tier's, and nothing else redacts: a text through {@link egressText}, a thrown value's text through
@@ -27,7 +37,8 @@ declare const EGRESS_TIER: unique symbol;
27
37
  export type Egress<T extends EgressTier> = string & {
28
38
  readonly [EGRESS_TIER]: T;
29
39
  };
30
- /** Tier `tier`'s one pass over a text. */
40
+ /** Tier `tier`'s one pass over a text. A report's `preexistingMarkers` counts the engine's own marks ({@link REDACTION_MARKS})
41
+ * already in the text. */
31
42
  export declare function egressText<T extends EgressTier>(tier: T, text: string, report?: RedactionReport): Egress<T>;
32
43
  /** The text a thrown value reads as (`thrownText`), through tier `tier`'s pass: the one form a thrown value's words take
33
44
  * on their way out of the engine. */
@@ -1,34 +1,35 @@
1
1
  import { types } from "node:util";
2
+ import { isSensitiveRecordKey, renderSecrets, URL_OF_ANY_SCHEME } from "@sema-agent/primitives";
2
3
  import { delimitUntrusted, inlineUntrusted, neutralizeForFence } from "./untrusted-text.js";
3
- import { egressPasses, runRedactionPasses } from "./redaction-passes.js";
4
- import { REDACTION_MARK, REDACTION_MARKS, redactionMarkerSpans } from "./redaction-marks.js";
5
- import { CREDENTIAL_VOCABULARY, egressPassGroups, isSensitiveRecordKey, URI_SCHEME_SOURCE } from "./credential-vocabulary.js";
4
+ import { REDACTION_MARK, REDACTION_MARKS, REDACTION_NOTATION, redactionMarkerSpans } from "./redaction-marks.js";
6
5
  import { isErrorLike, readMember, thrownText } from "./thrown-value.js";
7
6
  import { sliceHeadSafe } from "./surrogate-safe-slice.js";
8
- export { summarizeRedactions } from "./redaction-passes.js";
9
- const URL_OF_ANY_PROTOCOL = new RegExp(String.raw `${URI_SCHEME_SOURCE}:\/\/[^\s"'\`]+`, "gi");
10
- const BARE_USERNAME_MAX_LEN = 20;
11
- function redactUserinfo(scheme, userinfoWithAt) {
12
- const userinfo = userinfoWithAt.slice(0, -1);
13
- if (CREDENTIAL_VOCABULARY.policy.urlUserinfo === "whole" || userinfo.includes("@"))
14
- return `${scheme}${REDACTION_MARKS.credentials}@`;
15
- const colonIdx = userinfo.indexOf(":");
16
- if (colonIdx === -1) {
17
- return userinfo.length >= BARE_USERNAME_MAX_LEN ? `${scheme}${REDACTION_MARKS.credentials}@` : `${scheme}${userinfo}@`;
7
+ export function summarizeRedactions(findings) {
8
+ if (findings.length === 0)
9
+ return "no redactions";
10
+ const counts = new Map();
11
+ for (const f of findings) {
12
+ const label = `${f.kind} (${f.confidence})`;
13
+ counts.set(label, (counts.get(label) ?? 0) + 1);
18
14
  }
19
- return `${scheme}${userinfo.slice(0, colonIdx)}:${REDACTION_MARKS.credentials}@`;
15
+ const parts = [...counts].map(([label, n]) => `${label} x${n}`);
16
+ return `${findings.length} redaction${findings.length === 1 ? "" : "s"}: ${parts.join(", ")}`;
20
17
  }
21
- const SECRET_TIER_PASSES = egressPasses(egressPassGroups(CREDENTIAL_VOCABULARY), {
22
- "url-credentials": (_m, scheme, userinfo) => redactUserinfo(scheme, userinfo),
18
+ const EGRESS_POLICY = Object.freeze({
19
+ grade: "wide",
20
+ readings: Object.freeze([Object.freeze({ kind: "raw" }), Object.freeze({ kind: "format-free" })]),
21
+ urlUserinfo: "keep-username",
22
+ onUnresolvedReading: "secret",
23
23
  });
24
- const HOST_LEAK_PASSES = [
25
- ...SECRET_TIER_PASSES,
26
- { kind: "url", confidence: "medium", marker: REDACTION_MARKS.url, source: "untrusted-egress", re: URL_OF_ANY_PROTOCOL, replace: REDACTION_MARKS.url },
24
+ const HOST_LEAK_PASSES = Object.freeze([
25
+ { kind: "url", confidence: "medium", marker: REDACTION_MARKS.url, source: "untrusted-egress", re: new RegExp(URL_OF_ANY_SCHEME.source, URL_OF_ANY_SCHEME.flags), replace: REDACTION_MARKS.url },
27
26
  { kind: "fs-path", confidence: "low", marker: REDACTION_MARKS.path, source: "untrusted-egress", re: /(?:\/[A-Za-z0-9_.-]+){2,}/g, replace: REDACTION_MARKS.path },
28
- ];
29
- const TIER_PASSES = { "same-principal": SECRET_TIER_PASSES, human: HOST_LEAK_PASSES };
27
+ ]);
28
+ const TIER_PASSES = { "same-principal": Object.freeze([]), human: HOST_LEAK_PASSES };
30
29
  export function egressText(tier, text, report) {
31
- return runRedactionPasses(text, TIER_PASSES[tier], report);
30
+ if (report !== undefined && report.preexistingMarkers === undefined)
31
+ report.preexistingMarkers = redactionMarkerSpans(text).length;
32
+ return renderSecrets(text, EGRESS_POLICY, REDACTION_NOTATION, { passes: TIER_PASSES[tier], report });
32
33
  }
33
34
  export function egressThrownText(tier, err) {
34
35
  return egressText(tier, thrownText(err));
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * The seat sends the leg-start snapshot when the leg binds its sink, and afterwards a frame only when the snapshot's digest
6
6
  * differs from the last frame it sent — the digest is the snapshot's canonical JSON, so every member the projection carries
7
- * takes part in the comparison with no second list to keep in step. The fixed members (root, project, remote) are leg
7
+ * takes part in the comparison with no second list to keep in step. The fixed members (root, session, project, remote) are leg
8
8
  * facts handed in at prepare; the two live ones are read off the leg's own seats at each observation (the tracked cwd, the
9
9
  * active EnterWorktree switch), never copied.
10
10
  */
@@ -29,6 +29,8 @@ export interface WorkspaceFacts {
29
29
  };
30
30
  /** The leg's project verdict (`resolveSessionProject`); absent ⇒ the leg has no project identity. */
31
31
  readonly project?: SessionProject;
32
+ /** The session's checkout as the frame reports it (`sessionFrameOf`); absent ⇒ the session declared no workspace. */
33
+ readonly session?: WorkspaceSnapshot["session"];
32
34
  /** The leg's one remoteness reading (the restore phase's, the same value `ResolvedWorkspace.remote` carries). */
33
35
  readonly remote: boolean;
34
36
  }
@@ -5,6 +5,7 @@ export function workspaceSnapshotOf(facts) {
5
5
  cwd: facts.cwdRef?.current ?? facts.root,
6
6
  root: facts.root,
7
7
  ...(active !== undefined ? { entered: { dir: active.worktreeDir, ...(active.entered === true ? { byPath: true } : {}) } } : {}),
8
+ ...(facts.session !== undefined ? { session: facts.session } : {}),
8
9
  ...(facts.project !== undefined ? { project: { id: facts.project.id, source: facts.project.source } } : {}),
9
10
  remote: facts.remote,
10
11
  };
@@ -96,6 +96,9 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
96
96
  /** `ExecutionEnv.cdPath` = the `CDPATH` the shell child receives, read LIVE off the same merge each exec gets (never the
97
97
  * engine process's own environment): its entries, `[]` when the child gets none. Residual: a per-exec `env.CDPATH`. */
98
98
  get cdPath(): readonly string[];
99
+ /** `ExecutionEnv.receivedEnvNames` = the names of the same merge each exec gets, read LIVE; `[]` when no child would be spawned
100
+ * at all. Residual: a per-exec `env` adding one. */
101
+ get receivedEnvNames(): readonly string[];
99
102
  /** `ExecutionEnv.withheldEnv` = what the same merge withholds from the shell child (an entry `shellEnv` re-supplies is
100
103
  * no loss), read LIVE; `[]` when no child would be spawned at all. Residual: a per-exec `env` re-supplying one. */
101
104
  get withheldEnv(): readonly SecretEnvFinding[];
@@ -1,5 +1,5 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { randomUUID } from "node:crypto";
2
+ import { createHash, randomUUID } from "node:crypto";
3
3
  import { closeSync, constants, createReadStream, mkdtempSync, openSync, readSync, rmSync, statSync, truncateSync, unlinkSync } from "node:fs";
4
4
  import { access, appendFile, lstat, mkdir, mkdtemp, open, readdir, readFile, readlink, rename, rm, stat, unlink, writeFile, } from "node:fs/promises";
5
5
  import { tmpdir } from "node:os";
@@ -196,25 +196,29 @@ function isFsSupportError(error) {
196
196
  }
197
197
  const RENAME_FALLBACK_CODES = new Set(["EXDEV", "EPERM", "EEXIST", "EBUSY"]);
198
198
  const NAME_MAX_BYTES = 255;
199
+ const STAGING_NAME_DIGEST_HEX = 12;
200
+ const STAGING_CUT_AT_BYTES = NAME_MAX_BYTES - 3;
199
201
  const STAGING_SUFFIX = /\.tmp\.(\d+)\.[0-9a-f]{12}$/;
200
202
  function stagingSuffix(pid) {
201
203
  return `.tmp.${pid}.${randomUUID().replace(/-/g, "").slice(0, 12)}`;
202
204
  }
203
205
  function stagingNameOf(name, suffix) {
204
206
  const nameBytes = Buffer.byteLength(name, "utf8");
205
- const room = NAME_MAX_BYTES - Buffer.byteLength(suffix, "utf8");
206
- if (nameBytes <= room || nameBytes > NAME_MAX_BYTES)
207
+ const suffixBytes = Buffer.byteLength(suffix, "utf8");
208
+ if (nameBytes + suffixBytes < STAGING_CUT_AT_BYTES || nameBytes > NAME_MAX_BYTES)
207
209
  return `${name}${suffix}`;
210
+ const mark = `~${createHash("sha256").update(name, "utf8").digest("hex").slice(0, STAGING_NAME_DIGEST_HEX)}`;
211
+ const keep = NAME_MAX_BYTES - suffixBytes - Buffer.byteLength(mark, "utf8");
208
212
  let kept = "";
209
213
  let used = 0;
210
214
  for (const char of name) {
211
215
  const bytes = Buffer.byteLength(char, "utf8");
212
- if (used + bytes > room)
216
+ if (used + bytes > keep)
213
217
  break;
214
218
  kept += char;
215
219
  used += bytes;
216
220
  }
217
- return `${kept}${suffix}`;
221
+ return `${kept}${mark}${suffix}`;
218
222
  }
219
223
  function stagingSiblingOf(target) {
220
224
  const suffix = stagingSuffix(process.pid);
@@ -473,6 +477,9 @@ export class NodeExecutionEnv {
473
477
  const value = this.childEnvForRead()?.CDPATH;
474
478
  return value === undefined || value === "" ? [] : value.split(":");
475
479
  }
480
+ get receivedEnvNames() {
481
+ return Object.entries(this.childEnvForRead() ?? {}).flatMap(([name, value]) => (value === undefined ? [] : [name]));
482
+ }
476
483
  get withheldEnv() {
477
484
  let withheld = [];
478
485
  this.childEnvForRead((f) => (withheld = f));