@sema-agent/core 7.57.0 → 7.59.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 (399) hide show
  1. package/CHANGELOG.md +1161 -0
  2. package/README.md +6 -4
  3. package/dist/agents/cc-peer-directory.js +8 -8
  4. package/dist/agents/child-model-seat.d.ts +4 -2
  5. package/dist/agents/child-model-seat.js +5 -3
  6. package/dist/agents/peer-directory.d.ts +9 -0
  7. package/dist/agents/peer-directory.js +6 -2
  8. package/dist/agents/send-message-tool.js +21 -12
  9. package/dist/agents/subagent-steps.js +2 -4
  10. package/dist/agents/subagent.js +33 -34
  11. package/dist/brain/anthropic.js +161 -45
  12. package/dist/brain/errors.d.ts +9 -3
  13. package/dist/brain/errors.js +7 -1
  14. package/dist/brain/failover.js +2 -1
  15. package/dist/brain/open-responses.js +3 -3
  16. package/dist/brain/openai.js +103 -53
  17. package/dist/brain/provider-dialect.d.ts +11 -0
  18. package/dist/brain/provider-dialect.js +5 -2
  19. package/dist/brain/reasoning-request.js +5 -4
  20. package/dist/brain/reasoning.d.ts +19 -0
  21. package/dist/brain/reasoning.js +17 -2
  22. package/dist/brain/request-route.d.ts +4 -1
  23. package/dist/brain/request-route.js +4 -1
  24. package/dist/brain/route-adjudicator.d.ts +84 -18
  25. package/dist/brain/route-adjudicator.js +89 -22
  26. package/dist/brain/route-conformance.js +1 -1
  27. package/dist/brain/stream-engine.js +84 -49
  28. package/dist/brain/stream-shared.d.ts +30 -0
  29. package/dist/brain/stream-shared.js +34 -1
  30. package/dist/brain/timeout.d.ts +62 -5
  31. package/dist/brain/timeout.js +93 -6
  32. package/dist/core/a2a.d.ts +2 -1
  33. package/dist/core/a2a.js +23 -10
  34. package/dist/core/account-row.d.ts +61 -0
  35. package/dist/core/account-row.js +51 -0
  36. package/dist/core/advisor-verdict.d.ts +2 -1
  37. package/dist/core/advisor-verdict.js +1 -1
  38. package/dist/core/allow-entry.d.ts +20 -7
  39. package/dist/core/allow-entry.js +18 -9
  40. package/dist/core/approval-object.d.ts +29 -15
  41. package/dist/core/approval-object.js +47 -19
  42. package/dist/core/ask-origin.d.ts +21 -2
  43. package/dist/core/ask-origin.js +5 -1
  44. package/dist/core/auto-compaction.d.ts +4 -0
  45. package/dist/core/auto-compaction.js +2 -2
  46. package/dist/core/auto-mode-directive.d.ts +29 -5
  47. package/dist/core/auto-mode-directive.js +38 -8
  48. package/dist/core/background-agent-store.d.ts +16 -3
  49. package/dist/core/checkpoint-requirements.d.ts +19 -1
  50. package/dist/core/checkpoint-requirements.js +5 -1
  51. package/dist/core/checkpoint-store.d.ts +85 -23
  52. package/dist/core/checkpoint-store.js +31 -9
  53. package/dist/core/child-clamp-seats.d.ts +29 -0
  54. package/dist/core/child-clamp-seats.js +56 -1
  55. package/dist/core/compliance.d.ts +2 -2
  56. package/dist/core/compliance.js +1 -1
  57. package/dist/core/effective-path-target.d.ts +8 -2
  58. package/dist/core/effective-path-target.js +8 -3
  59. package/dist/core/engine-notice.d.ts +99 -9
  60. package/dist/core/engine-notice.js +19 -5
  61. package/dist/core/fs-write-gate-policy.d.ts +4 -2
  62. package/dist/core/fs-write-gate-policy.js +7 -3
  63. package/dist/core/gate-fold.js +7 -4
  64. package/dist/core/gate-lanes.js +19 -6
  65. package/dist/core/gate-outcome.d.ts +32 -3
  66. package/dist/core/gate-outcome.js +19 -1
  67. package/dist/core/git-worktree-env.d.ts +53 -11
  68. package/dist/core/git-worktree-env.js +96 -12
  69. package/dist/core/governance-codes.d.ts +9 -1
  70. package/dist/core/governance-codes.js +13 -0
  71. package/dist/core/hooks.d.ts +35 -4
  72. package/dist/core/hooks.js +17 -11
  73. package/dist/core/human-input-projection.d.ts +1 -0
  74. package/dist/core/human-input-projection.js +3 -0
  75. package/dist/core/image-admission.d.ts +6 -5
  76. package/dist/core/image-admission.js +18 -14
  77. package/dist/core/locked-config.d.ts +20 -3
  78. package/dist/core/locked-config.js +40 -3
  79. package/dist/core/mailbox-store.d.ts +45 -1
  80. package/dist/core/mailbox-store.js +53 -9
  81. package/dist/core/mcp-call-meta.d.ts +66 -0
  82. package/dist/core/mcp-call-meta.js +103 -0
  83. package/dist/core/mcp-connection-pool.d.ts +3 -1
  84. package/dist/core/mcp-connection-pool.js +3 -1
  85. package/dist/core/mcp-failure.d.ts +117 -15
  86. package/dist/core/mcp-failure.js +71 -3
  87. package/dist/core/mcp-probe.d.ts +4 -0
  88. package/dist/core/mcp-probe.js +1 -1
  89. package/dist/core/mcp-server-link.d.ts +27 -3
  90. package/dist/core/mcp-server-link.js +25 -1
  91. package/dist/core/mcp-server-spec.d.ts +46 -18
  92. package/dist/core/mcp-server-spec.js +1 -18
  93. package/dist/core/mcp.d.ts +16 -20
  94. package/dist/core/mcp.js +112 -55
  95. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  96. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  97. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  98. package/dist/core/memory-engine/consolidation.js +1 -0
  99. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  100. package/dist/core/memory-engine/distiller.js +2 -2
  101. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  102. package/dist/core/memory-engine/dual-root.js +44 -1
  103. package/dist/core/memory-engine/engine.d.ts +67 -14
  104. package/dist/core/memory-engine/engine.js +384 -212
  105. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  106. package/dist/core/memory-engine/export-bundle.js +23 -4
  107. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  108. package/dist/core/memory-engine/file-backend.js +290 -117
  109. package/dist/core/memory-engine/index.d.ts +1 -1
  110. package/dist/core/memory-engine/layout.d.ts +59 -11
  111. package/dist/core/memory-engine/layout.js +190 -40
  112. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  113. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  114. package/dist/core/memory-engine/scope-contract.d.ts +45 -4
  115. package/dist/core/memory-engine/scope-contract.js +80 -11
  116. package/dist/core/memory-engine/sync-client.d.ts +9 -1
  117. package/dist/core/memory-engine/sync-client.js +31 -8
  118. package/dist/core/memory-engine/sync.d.ts +5 -0
  119. package/dist/core/memory-engine/types.d.ts +6 -0
  120. package/dist/core/mode-policy.d.ts +8 -5
  121. package/dist/core/mode-policy.js +5 -4
  122. package/dist/core/mods/classic-events.d.ts +5 -1
  123. package/dist/core/mods/host.js +1 -1
  124. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  125. package/dist/core/mods/kernel/dispatch.js +12 -9
  126. package/dist/core/mods/kernel/events.d.ts +6 -1
  127. package/dist/core/mods/kernel/events.js +2 -2
  128. package/dist/core/mods/kernel/registration.d.ts +9 -1
  129. package/dist/core/mods/kernel/registration.js +3 -0
  130. package/dist/core/mods/kernel/site-rules.d.ts +3 -0
  131. package/dist/core/mods/kernel/site-rules.js +10 -0
  132. package/dist/core/mods/package.d.ts +23 -0
  133. package/dist/core/mods/package.js +118 -0
  134. package/dist/core/mods/stations.d.ts +33 -12
  135. package/dist/core/mods/stations.js +45 -11
  136. package/dist/core/mods/tool-call.d.ts +5 -1
  137. package/dist/core/mods/tool-call.js +13 -4
  138. package/dist/core/parent-spec-seat.d.ts +8 -3
  139. package/dist/core/parent-spec-seat.js +2 -0
  140. package/dist/core/park-selfcheck.js +6 -0
  141. package/dist/core/path-guard-rows.d.ts +20 -0
  142. package/dist/core/path-guard-rows.js +11 -0
  143. package/dist/core/peer-seat.d.ts +248 -0
  144. package/dist/core/peer-seat.js +439 -0
  145. package/dist/core/permission-rule-consent.js +10 -4
  146. package/dist/core/permission-rule-model.d.ts +16 -0
  147. package/dist/core/permission-rule-model.js +1 -1
  148. package/dist/core/present-plan-tool.d.ts +20 -3
  149. package/dist/core/present-plan-tool.js +48 -4
  150. package/dist/core/protocol-http-auth.d.ts +40 -29
  151. package/dist/core/protocol-http-auth.js +30 -32
  152. package/dist/core/redaction-marks.d.ts +16 -0
  153. package/dist/core/redaction-marks.js +16 -0
  154. package/dist/core/redaction-passes.js +8 -9
  155. package/dist/core/resume-startup-cause.js +1 -0
  156. package/dist/core/retention.d.ts +41 -15
  157. package/dist/core/retention.js +59 -12
  158. package/dist/core/rewrite-rejudge.d.ts +38 -0
  159. package/dist/core/rewrite-rejudge.js +42 -2
  160. package/dist/core/roles.d.ts +34 -2
  161. package/dist/core/roles.js +43 -4
  162. package/dist/core/run-origin.d.ts +40 -0
  163. package/dist/core/run-origin.js +37 -0
  164. package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
  165. package/dist/core/runner/advertised-writable-dirs.js +126 -0
  166. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  167. package/dist/core/runner/announce-once-ledger.js +4 -2
  168. package/dist/core/runner/call-hook-stations.js +2 -2
  169. package/dist/core/runner/compaction-restate.d.ts +15 -6
  170. package/dist/core/runner/compaction-restate.js +28 -2
  171. package/dist/core/runner/contracts.d.ts +33 -21
  172. package/dist/core/runner/credential-origin-seat.js +4 -3
  173. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  174. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  175. package/dist/core/runner/decide-continuation.d.ts +2 -2
  176. package/dist/core/runner/gate-exit.d.ts +30 -8
  177. package/dist/core/runner/gate-exit.js +15 -8
  178. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  179. package/dist/core/runner/image-removed-seat.js +19 -0
  180. package/dist/core/runner/inline-image.js +1 -1
  181. package/dist/core/runner/memory-consolidation-driver.js +3 -3
  182. package/dist/core/runner/park-commit.d.ts +1 -1
  183. package/dist/core/runner/park-commit.js +3 -0
  184. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  185. package/dist/core/runner/prepare-ask-lane.js +2 -1
  186. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  187. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
  188. package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
  189. package/dist/core/runner/prepare-config-doors.d.ts +8 -5
  190. package/dist/core/runner/prepare-config-doors.js +14 -10
  191. package/dist/core/runner/prepare-context-lane.js +2 -0
  192. package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
  193. package/dist/core/runner/prepare-delegation-surface.js +16 -18
  194. package/dist/core/runner/prepare-gate-stations.js +1 -1
  195. package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
  196. package/dist/core/runner/prepare-hands-readface.js +9 -1
  197. package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
  198. package/dist/core/runner/prepare-inherited-gate.js +14 -27
  199. package/dist/core/runner/prepare-memory.d.ts +3 -0
  200. package/dist/core/runner/prepare-memory.js +26 -37
  201. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  202. package/dist/core/runner/prepare-park-ask.js +2 -1
  203. package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
  204. package/dist/core/runner/prepare-policy-chain.js +18 -15
  205. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  206. package/dist/core/runner/prepare-project-context.js +2 -2
  207. package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
  208. package/dist/core/runner/prepare-prompt-inputs.js +8 -19
  209. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  210. package/dist/core/runner/prepare-protocol-tools.js +11 -3
  211. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  212. package/dist/core/runner/prepare-run-refs.js +4 -1
  213. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  214. package/dist/core/runner/prepare-suspend-saga.js +2 -1
  215. package/dist/core/runner/prepare-task.js +28 -13
  216. package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
  217. package/dist/core/runner/prepare-wiring-manifest.js +4 -3
  218. package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
  219. package/dist/core/runner/prepare-workspace-restore.js +4 -4
  220. package/dist/core/runner/reply-pricing.d.ts +30 -0
  221. package/dist/core/runner/reply-pricing.js +19 -0
  222. package/dist/core/runner/resume-admission.js +5 -3
  223. package/dist/core/runner/resume-apply.js +6 -1
  224. package/dist/core/runner/resume-checkpoint-screen.js +2 -0
  225. package/dist/core/runner/resume-policy-outcome.js +5 -5
  226. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  227. package/dist/core/runner/role-seat-defaulted.js +40 -0
  228. package/dist/core/runner/run-brain-sinks.js +2 -0
  229. package/dist/core/runner/run-harness-handlers.d.ts +3 -4
  230. package/dist/core/runner/run-harness-handlers.js +1 -8
  231. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  232. package/dist/core/runner/run-identity-wiring.js +6 -4
  233. package/dist/core/runner/run-leg.d.ts +2 -0
  234. package/dist/core/runner/run-leg.js +42 -29
  235. package/dist/core/runner/run-notification-lane.js +3 -0
  236. package/dist/core/runner/run-stop-and-final-verify.js +2 -2
  237. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  238. package/dist/core/runner/run-terminal-adoption.js +9 -3
  239. package/dist/core/runner/run-turn-boundary.js +77 -70
  240. package/dist/core/runner/runtask.d.ts +1 -1
  241. package/dist/core/runner/runtask.js +2 -2
  242. package/dist/core/runner/side-call-account.d.ts +1 -1
  243. package/dist/core/runner/side-call-account.js +3 -18
  244. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  245. package/dist/core/runner/sub-agent-deny-lists.js +10 -0
  246. package/dist/core/runner/terminal-account.js +3 -3
  247. package/dist/core/runner/tool-end-body.js +2 -1
  248. package/dist/core/runner/tool-occurrence.d.ts +5 -2
  249. package/dist/core/runner/tool-occurrence.js +4 -3
  250. package/dist/core/runner/turn-attachments.d.ts +26 -22
  251. package/dist/core/runner/turn-attachments.js +24 -26
  252. package/dist/core/runner/write-protection-station.d.ts +8 -2
  253. package/dist/core/runner/write-protection-station.js +2 -0
  254. package/dist/core/runner-deps.d.ts +3 -3
  255. package/dist/core/secret-env.d.ts +32 -2
  256. package/dist/core/secret-env.js +65 -3
  257. package/dist/core/sensitive-path-policy.js +9 -10
  258. package/dist/core/session-log-transfer.d.ts +24 -0
  259. package/dist/core/session-log-transfer.js +166 -0
  260. package/dist/core/session-policy-store.d.ts +3 -1
  261. package/dist/core/session-policy-store.js +13 -9
  262. package/dist/core/session-store.d.ts +86 -24
  263. package/dist/core/session-store.js +162 -24
  264. package/dist/core/session.d.ts +92 -1
  265. package/dist/core/shell-read-silence.js +1 -0
  266. package/dist/core/side-query.d.ts +11 -1
  267. package/dist/core/side-query.js +9 -0
  268. package/dist/core/skill-grant-binding.d.ts +31 -2
  269. package/dist/core/skill-grant-binding.js +31 -1
  270. package/dist/core/skill-grant.d.ts +8 -5
  271. package/dist/core/skill-grant.js +6 -6
  272. package/dist/core/steer-replay.d.ts +4 -2
  273. package/dist/core/steer-replay.js +2 -1
  274. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
  276. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  277. package/dist/core/store-contracts/session-repo-contract.js +112 -5
  278. package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
  279. package/dist/core/store-contracts/session-store-contract.js +236 -2
  280. package/dist/core/synthetic-read-verdict.js +2 -1
  281. package/dist/core/task-event.d.ts +92 -8
  282. package/dist/core/task-notification.js +16 -10
  283. package/dist/core/task-registry-agent.js +1 -0
  284. package/dist/core/task-registry-shared.d.ts +7 -1
  285. package/dist/core/task-spec.d.ts +49 -1
  286. package/dist/core/task-stream.d.ts +2 -1
  287. package/dist/core/terminal-cause.d.ts +11 -1
  288. package/dist/core/tool-catalog-entries.js +1 -0
  289. package/dist/core/tool-check-reading.d.ts +1 -0
  290. package/dist/core/tool-check-reading.js +3 -3
  291. package/dist/core/tool-policy.d.ts +16 -0
  292. package/dist/core/tool-result-store.d.ts +17 -10
  293. package/dist/core/tool-result-store.js +3 -1
  294. package/dist/core/tool-roster.d.ts +112 -5
  295. package/dist/core/tool-roster.js +42 -1
  296. package/dist/core/tool-spec.d.ts +3 -1
  297. package/dist/core/types.d.ts +3 -3
  298. package/dist/core/types.js +1 -1
  299. package/dist/core/untrusted-egress.d.ts +0 -2
  300. package/dist/core/untrusted-egress.js +10 -14
  301. package/dist/core/user-attachment.js +1 -1
  302. package/dist/core/wiring-manifest.d.ts +18 -6
  303. package/dist/core/wiring-manifest.js +4 -3
  304. package/dist/core/workspace-snapshot.d.ts +44 -0
  305. package/dist/core/workspace-snapshot.js +34 -0
  306. package/dist/core/write-protect.d.ts +43 -3
  307. package/dist/core/write-protect.js +43 -16
  308. package/dist/engine/compaction/compaction.js +29 -3
  309. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  310. package/dist/engine/execution-env/node-execution-env.js +24 -23
  311. package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
  312. package/dist/engine/harness/agent-harness.d.ts +30 -2
  313. package/dist/engine/harness/agent-harness.js +43 -12
  314. package/dist/engine/harness/messages.d.ts +3 -1
  315. package/dist/engine/harness/messages.js +3 -2
  316. package/dist/engine/harness/types.d.ts +56 -7
  317. package/dist/engine/harness/types.js +5 -1
  318. package/dist/engine/llm/rejected-images.d.ts +46 -0
  319. package/dist/engine/llm/rejected-images.js +54 -0
  320. package/dist/engine/llm/tool-turns.d.ts +2 -1
  321. package/dist/engine/llm/types.d.ts +30 -10
  322. package/dist/engine/llm/types.js +1 -1
  323. package/dist/engine/loop/agent-loop.d.ts +8 -0
  324. package/dist/engine/loop/agent-loop.js +52 -15
  325. package/dist/engine/loop/types.d.ts +3 -1
  326. package/dist/engine/session/import-validate.js +3 -0
  327. package/dist/engine/session/memory-repo.d.ts +17 -9
  328. package/dist/engine/session/memory-repo.js +44 -34
  329. package/dist/engine/session/path-to-root.d.ts +38 -0
  330. package/dist/engine/session/path-to-root.js +39 -0
  331. package/dist/engine/session/repo-utils.d.ts +22 -4
  332. package/dist/engine/session/repo-utils.js +49 -1
  333. package/dist/engine/session/storage-base.d.ts +10 -1
  334. package/dist/engine/session/storage-base.js +11 -22
  335. package/dist/index.d.ts +29 -16
  336. package/dist/index.js +21 -11
  337. package/dist/internal/harness-types.d.ts +2 -2
  338. package/dist/internal/harness.d.ts +3 -2
  339. package/dist/internal/harness.js +2 -2
  340. package/dist/internal/llm.d.ts +1 -0
  341. package/dist/orchestration/workflow-observe.d.ts +17 -1
  342. package/dist/orchestration/workflow-observe.js +20 -0
  343. package/dist/orchestration/workflow-types.d.ts +32 -7
  344. package/dist/orchestration/workflow.js +739 -489
  345. package/dist/shell/counting-pass.d.ts +50 -0
  346. package/dist/shell/counting-pass.js +502 -0
  347. package/dist/shell/lex.d.ts +4 -2
  348. package/dist/shell/lex.js +93 -34
  349. package/dist/shell/shell-words.d.ts +1 -1
  350. package/dist/shell/shell-words.js +7 -6
  351. package/dist/stores/file/index.d.ts +4 -1
  352. package/dist/stores/file/index.js +4 -1
  353. package/dist/stores/file/mailbox-store.js +6 -10
  354. package/dist/stores/file/session-store.d.ts +15 -8
  355. package/dist/stores/file/session-store.js +28 -13
  356. package/dist/tools/fs/fs-bash.d.ts +6 -0
  357. package/dist/tools/fs/fs-bash.js +6 -3
  358. package/dist/tools/fs/fs-write.d.ts +6 -3
  359. package/dist/tools/fs/fs-write.js +8 -7
  360. package/dist/tools/fs/index.d.ts +3 -0
  361. package/dist/tools/fs/index.js +7 -3
  362. package/dist/tools/fs/program-read-model.d.ts +13 -0
  363. package/dist/tools/fs/program-read-model.js +15 -0
  364. package/dist/tools/fs/program-read-model.rows.js +1 -1
  365. package/dist/tools/fs/read-deny.d.ts +13 -10
  366. package/dist/tools/fs/read-deny.js +25 -5
  367. package/dist/tools/fs/read-floor.d.ts +19 -0
  368. package/dist/tools/fs/read-floor.js +23 -0
  369. package/dist/tools/fs/safety.js +40 -8
  370. package/dist/tools/fs/search.js +6 -24
  371. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  372. package/dist/tools/fs/shell-read-check.js +61 -16
  373. package/dist/tools/fs/shell-read-establish.js +2 -1
  374. package/dist/tools/fs/shell-read-identity.js +1 -1
  375. package/dist/tools/fs/shell-read-judge.d.ts +26 -9
  376. package/dist/tools/fs/shell-read-judge.js +10 -6
  377. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  378. package/dist/tools/fs/shell-read-plan.js +22 -15
  379. package/dist/tools/fs/shell-read-start.js +1 -0
  380. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  381. package/dist/tools/fs/shell-reentry-text.js +25 -3
  382. package/dist/tools/monitor.d.ts +4 -0
  383. package/dist/tools/monitor.js +2 -0
  384. package/dist/tools/worktree.d.ts +42 -15
  385. package/dist/tools/worktree.js +60 -32
  386. package/package.json +5 -2
  387. package/test/export-surface.snapshot.json +149 -1
  388. package/wire-changes/core-stores-sql@7.58.0.json +29 -0
  389. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  390. package/wire-changes/core@7.58.0.json +2188 -0
  391. package/wire-changes/core@7.59.0.json +2459 -0
  392. package/wire-changes/mods-kernel@7.58.0.json +81 -0
  393. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  394. package/wire-changes/primitives@7.58.0.json +29 -0
  395. package/wire-changes/primitives@7.59.0.json +29 -0
  396. package/dist/primitives/credential-ref.d.ts +0 -89
  397. package/dist/primitives/credential-ref.js +0 -125
  398. package/dist/primitives/index.d.ts +0 -2
  399. package/dist/primitives/index.js +0 -1
@@ -1,6 +1,7 @@
1
1
  import type { ParsedScopeKey } from "./scope-contract.js";
2
- import type { HarvestReport } from "./types.js";
2
+ import type { HarvestReport, MemoryBackend } from "./types.js";
3
3
  import type { MemoryInjection } from "./engine.js";
4
+ import { type MemoryPartitionIncidentSink } from "./layout.js";
4
5
  /** The personal plane's shared mount under the config root (ALL projects, one home — the plane is
5
6
  * keyed by scope, not by repo: `user:alice` is the same disk from every checkout). */
6
7
  export declare function derivePersonalMemoryDir(configRoot: string): string;
@@ -20,6 +21,54 @@ export interface ScopePlanes {
20
21
  /** Classify a v2 session's scopes into planes. writeScope routes by its OWN key kind (it need not
21
22
  * be listed in scopes — normalizeMemorySpec contract). */
22
23
  export declare function classifyScopePlanes(scopes: readonly string[], writeScope: string | null): ScopePlanes;
24
+ /** The session's planes, or `undefined` when it is not under the v2 contract — then every key is
25
+ * opaque and the one plane is the project plane (the deployment's backend as configured). */
26
+ export declare function scopePlanesOf(scopes: readonly string[], writeScope: string | null, scopeContract: "v2" | undefined): ScopePlanes | undefined;
27
+ /** The directory a backend is pinned to (a File store: its directory IS the storage), or
28
+ * `undefined` for a backend without one (a DB store: sessions copy out of it). */
29
+ export declare function directoryPinOf(backend: MemoryBackend): string | undefined;
30
+ /** The backend that holds a plane's entries. The project plane is the deployment's backend; the
31
+ * personal plane shares a backend without a directory (the scope column partitions it) and gets
32
+ * its OWN File store on the personal mount when the deployment's backend is directory-pinned. */
33
+ export declare function memoryPlaneStore(plane: "project" | "personal", backend: MemoryBackend, engineRoot: string, onIncident?: MemoryPartitionIncidentSink): MemoryBackend;
34
+ /** One scope's store, as {@link resolveMemoryScopeStore} answers it. */
35
+ export interface MemoryScopeStore {
36
+ /** The plane that carries the scope. */
37
+ readonly plane: "project" | "personal";
38
+ /** The store holding the scope's committed entries — the backend a session over this scope
39
+ * materializes from and harvests into. */
40
+ readonly backend: MemoryBackend;
41
+ }
42
+ export interface MemoryScopeStoreInput {
43
+ /** The scope key as a session's `TaskSpec.memory` spells it — read through the Runner's own
44
+ * normalization (surrounding whitespace trimmed; under v2 the scope contract's parse). */
45
+ scope: string;
46
+ /** The session's `TaskSpec.memory.scopeContract`. A required key (checked at run time too):
47
+ * absence of the opt-in is written as `undefined`, never left out, because it moves a typed key
48
+ * to the other plane. */
49
+ scopeContract: "v2" | undefined;
50
+ /** The deployment's backend — the instance given as `RunnerDeps.memoryBackend`. */
51
+ backend: MemoryBackend;
52
+ /** The value given as `RunnerDeps.memoryEngineDir`; a required key (`undefined` written out reads
53
+ * the Runner's same fallback, a left-out key is refused — it would silently pick that fallback). */
54
+ memoryEngineDir: string | undefined;
55
+ /** Sink for incidents of a store this call constructs (the personal File store). */
56
+ onIncident?: MemoryPartitionIncidentSink;
57
+ }
58
+ /**
59
+ * The store that carries `scope` — the same plane classification and the same per-plane backend
60
+ * the Runner's session assembly uses. The session assembly (prepare-memory) and a host's sync
61
+ * executor read this one resolution; a change to the rule is made here only. A host leg that reads
62
+ * or writes a scope's entries outside a session (sync, operator faces, adoption) takes the store
63
+ * from here; the deployment's backend is the answer only for the project plane. Bad input is
64
+ * refused with `config.memory_scope_key`: a blank or non-string key, a contract other than `"v2"` /
65
+ * `undefined`, a left-out `scopeContract` or `memoryEngineDir` key, an engine dir that is not a
66
+ * non-empty string, and under v2 a typed key the scope contract cannot read.
67
+ * On a directory-pinned deployment a personal-plane answer is a File store opened over the
68
+ * personal mount (opening creates the mount's directories and finishes an interrupted transaction,
69
+ * as a session's opening does); resolve once per scope and keep it.
70
+ */
71
+ export declare function resolveMemoryScopeStore(input: MemoryScopeStoreInput): MemoryScopeStore;
23
72
  /** True when the classified session needs the dual-root assembly at all. */
24
73
  export declare function needsDualRoots(planes: ScopePlanes): boolean;
25
74
  /** Convenience for the placement gate: the parsed keys that stay on the PROJECT plane. */
@@ -1,5 +1,8 @@
1
1
  import { isCentralAuthorityScope, parseScopeKey } from "./scope-contract.js";
2
- import { CONTROL_PLANE_DIR } from "./layout.js";
2
+ import { CONTROL_PLANE_DIR, resolveMemoryEngineRoot } from "./layout.js";
3
+ import { FileMemoryEngineBackend } from "./file-backend.js";
4
+ import { thrownText } from "../thrown-value.js";
5
+ import { normalizeMemorySpec } from "../memory.js";
3
6
  import { join } from "node:path";
4
7
  export function derivePersonalMemoryDir(configRoot) {
5
8
  return join(configRoot, "personal", "memory");
@@ -16,6 +19,46 @@ export function classifyScopePlanes(scopes, writeScope) {
16
19
  const writePlane = writeScope === null ? null : isCentralAuthorityScope(parseScopeKey(writeScope)) ? "personal" : "project";
17
20
  return { project, personal, writePlane };
18
21
  }
22
+ export function scopePlanesOf(scopes, writeScope, scopeContract) {
23
+ return scopeContract === "v2" ? classifyScopePlanes(scopes, writeScope) : undefined;
24
+ }
25
+ export function directoryPinOf(backend) {
26
+ const pinned = backend.directoryRoot;
27
+ return typeof pinned === "string" && pinned !== "" ? pinned : undefined;
28
+ }
29
+ export function memoryPlaneStore(plane, backend, engineRoot, onIncident) {
30
+ if (plane === "project" || directoryPinOf(backend) === undefined)
31
+ return backend;
32
+ return new FileMemoryEngineBackend(derivePersonalMemoryDir(engineRoot), { controlDir: derivePersonalControlDir(engineRoot), ...(onIncident !== undefined ? { onIncident } : {}) });
33
+ }
34
+ export function resolveMemoryScopeStore(input) {
35
+ const { scope, scopeContract, memoryEngineDir } = input;
36
+ for (const key of ["scopeContract", "memoryEngineDir"]) {
37
+ if (!Object.prototype.hasOwnProperty.call(input, key))
38
+ refuseScopeStoreInput(`${key} is a required key (write undefined to state its absence)`, undefined);
39
+ }
40
+ if (scopeContract !== undefined && scopeContract !== "v2")
41
+ refuseScopeStoreInput(`scopeContract must be "v2" or undefined`, scopeContract);
42
+ if (memoryEngineDir !== undefined && (typeof memoryEngineDir !== "string" || memoryEngineDir === ""))
43
+ refuseScopeStoreInput("memoryEngineDir must be a non-empty string or undefined", memoryEngineDir);
44
+ let spec;
45
+ try {
46
+ spec = normalizeMemorySpec({ scopes: [scope], writeScope: scope, ...(scopeContract === "v2" ? { scopeContract } : {}) });
47
+ }
48
+ catch (err) {
49
+ refuseScopeStoreInput(`the scope contract cannot read the key: ${thrownText(err)}`, scope, err);
50
+ }
51
+ if (spec === undefined || spec.writeScope === null)
52
+ refuseScopeStoreInput("scope must be a non-empty key", scope);
53
+ const plane = scopePlanesOf(spec.scopes, spec.writeScope, spec.scopeContract)?.writePlane ?? "project";
54
+ return { plane, backend: memoryPlaneStore(plane, input.backend, resolveMemoryEngineRoot(memoryEngineDir), input.onIncident) };
55
+ }
56
+ function refuseScopeStoreInput(what, v, cause) {
57
+ const got = typeof v === "string" ? JSON.stringify(v.length > 64 ? `${v.slice(0, 64)}…` : v) : v === null ? "null" : typeof v;
58
+ const e = new Error(`resolveMemoryScopeStore: ${what} (got ${got}) — refusing to guess which store was meant.`, cause !== undefined ? { cause } : undefined);
59
+ e.code = "config.memory_scope_key";
60
+ throw e;
61
+ }
19
62
  export function needsDualRoots(planes) {
20
63
  const projectActive = planes.project.length > 0 || planes.writePlane === "project";
21
64
  const personalActive = planes.personal.length > 0 || planes.writePlane === "personal";
@@ -964,6 +964,43 @@ export declare class MemoryEngine {
964
964
  * would recurse through the very lane that just failed.
965
965
  */
966
966
  private discloseAnnounceFailure;
967
+ /**
968
+ * The one router of a model-face memory notice: a line is filed under the scope it reports on, so
969
+ * only a session mounting that scope ever reads it (`MemoryAnnouncement.scope`). A line that names
970
+ * no single scope — `scope` absent — reaches no model face: it goes to the host's incident sink
971
+ * (`memory.announcement_withheld`), and nowhere else. Fail-open like every enqueue site.
972
+ */
973
+ private announce;
974
+ /** The operator half of {@link announce}: a notice no single scope owns, said to the host only. */
975
+ private withholdAnnouncement;
976
+ /** Lines grouped by the scope they report on; `undefined` collects the lines no single scope owns. */
977
+ private announceByScope;
978
+ /**
979
+ * The one path → scope reading of the notice router: the scope among `candidates` whose store home
980
+ * (`<memoryDir>/<label>`, canonical) holds `absPath`, or `undefined` when none does — a registry
981
+ * that cannot be read places the path under no scope, and the line goes to the operator.
982
+ */
983
+ private scopeOwningPath;
984
+ /** A notice path relative to the plane root (`handle.memoryDir`) → the scope that owns it, among the
985
+ * scopes the session may read notices about: the materialized file's own scope when the handle
986
+ * recorded one, else {@link scopeOwningPath} over the session's notice scopes. The derived index is
987
+ * named by its bare file name on a report (it is the write home's index), so that name is the write
988
+ * scope's. */
989
+ private scopeOfPlaneRel;
990
+ /** Model-face notices whose scope is resolved after the call that raised them (the challenge lanes:
991
+ * their sync callers hold an entry id, and only the store knows its scope). One chain, in order;
992
+ * {@link settleAnnouncementWork} bounds how long a mount waits for it. */
993
+ private announcementWork;
994
+ /** The warnings of a report that are NOT about the write home, each with the scope it is about
995
+ * (`undefined` for a sentence about several scopes or the whole store — the host's). Every other
996
+ * warning of a report is the write scope's. Read once, by the harvest tail's notice filing. */
997
+ private readonly layerWarningScopes;
998
+ /** Push a warning that is not the write home's onto the report, recording the scope it is about. */
999
+ private warnScoped;
1000
+ /** Wait — bounded — for the notices still being attributed, so the next session's first injection
1001
+ * reads them. A wait that runs out is said on the incident sink (the notices land when the work
1002
+ * settles; nothing is dropped and nothing waits forever). */
1003
+ private settleAnnouncementWork;
967
1004
  /**
968
1005
  * Record retrieval hits (entries a memory tool actually RETURNED to the model) into this engine's
969
1006
  * control-plane retrieved account. Fire-and-forget by contract: a broken sidecar must never
@@ -1112,6 +1149,12 @@ export declare class MemoryEngine {
1112
1149
  * generation only — the announcement is a model-visible face, so no name/description/free reason
1113
1150
  * rides it; content stays on the host audit face). Failures are disclosed, never thrown past. */
1114
1151
  private challengeAndAnnounce;
1152
+ /** The challenge notices, filed under each entry's own scope. The ledger append above is the fact and
1153
+ * stays synchronous; the scope comes from the committed store (side-effect-free read), so the filing
1154
+ * is chained work a mount waits for ({@link settleAnnouncementWork}). An id the store no longer
1155
+ * holds has no scope to file under — said to the host only. A failed attribution is disclosed, never
1156
+ * swallowed. */
1157
+ private announceChallenged;
1115
1158
  /** design/180 §10 — one disclosure per PROCESS per engine, not one per append: the size is a
1116
1159
  * standing property of the account, and repeating it on every challenge is the spam that gets
1117
1160
  * advisories muted (the same argument the durable-park disclosures are built on). */
@@ -1168,15 +1211,19 @@ export declare class MemoryEngine {
1168
1211
  * best-effort set (shadow-only rows invisible), execution is per-id CAS'd delete patches
1169
1212
  * (conflicts reported, replay converges), and the attestation carries
1170
1213
  * `evidenceCapability: "none"` + `custodyState: "capability-absent"` throughout — a silent
1171
- * downgrade is the forbidden shape. Residual enumeration is unavailable on the degraded lane
1172
- * (no quarantine face): its `quarantineHits`/`quarantineOpaque` answer empty/zero as
1173
- * "unenumerable", never as a verified absence. Applied deletes close their lineage rows (the
1174
- * same space hygiene the organic tombstone path takes).
1214
+ * downgrade is the forbidden shape. The read faces show this lane no carrier beyond the deleted
1215
+ * entries, so every store carrier class answers `unverified` (and `replay: "unsupported"`): the
1216
+ * degraded lane never answers `complete`. Applied deletes close their lineage rows (the same
1217
+ * space hygiene the organic tombstone path takes).
1218
+ *
1219
+ * Authorization: `input.expectedScopes` (the import's seat; contract on its JSDoc). A grant-bearing
1220
+ * call over an evidence face whose backend does not declare `judgesErasureScopes: true` is refused
1221
+ * here, before the face runs; the degraded lane runs the same predicate below.
1175
1222
  *
1176
1223
  * BOTH lanes finish with the derived-index sweep ({@link sweepErasedIndexLines}): the erased
1177
1224
  * entries' MEMORY.md pointer lines — name + description, the model-visible distillation — are
1178
- * cleared from disk in the same call, and a sweep failure is disclosed on
1179
- * `residuals.indexUncleared`, never silently absorbed into a clean residual set.
1225
+ * cleared from disk in the same call; the `indexLine` carrier answers what it removed, and a
1226
+ * sweep failure keeps it `unverified` (the request `partial`), never a clean residual set.
1180
1227
  */
1181
1228
  eraseMemoryEntries(input: EraseMemoryEntriesInput): Promise<MemoryErasureAttestation>;
1182
1229
  private eraseMemoryEntriesCore;
@@ -1190,13 +1237,11 @@ export declare class MemoryEngine {
1190
1237
  * compliance erasure cannot count on — so the erase itself clears the pointer lines.
1191
1238
  *
1192
1239
  * LINE-TARGETED, never a full rebuild (no session handle exists here; prose/headers and every
1193
- * unrelated line stay verbatim): a line is dropped iff its link target resolves to an erased
1194
- * row's BOUND projection path. Failures are DISCLOSED on the attestation's
1195
- * `residuals.indexUncleared` seat, never silent (坏值响亮度): a non-file at the index path, a
1196
- * non-ENOENT read failure, or a refused write leaves the path listed — the caller archiving the
1197
- * attestation knows the model-visible index may still name the erased entry. Honest bounds,
1198
- * stated: an UNBOUND erased row has no projection address to match (its dangling line — if a
1199
- * model ever wrote one — falls to the rebuild's orphan clearing); a session handle minted
1240
+ * unrelated line stay verbatim): a line is dropped iff its link target resolves to a projection
1241
+ * path the request deleted (`owed.paths`). Failures are DISCLOSED, never silent (坏值响亮度): a
1242
+ * non-file at the index path, a non-ENOENT read failure, or a refused write keeps the
1243
+ * attestation's `indexLine` carrier `unverified` and the evidence lane's record standing (a
1244
+ * replay sweeps again). Honest bounds, stated: a session handle minted
1200
1245
  * BEFORE the erase still carries its materialize-time index text (a handle is a snapshot; the
1201
1246
  * next materialize re-derives); a REPO-INGESTED entry's index line targets the repo source file
1202
1247
  * (recorded at materialize), which is not derivable from the deleted row — that line is a
@@ -1207,6 +1252,13 @@ export declare class MemoryEngine {
1207
1252
  * not a channel this sweep adds).
1208
1253
  */
1209
1254
  private sweepErasedIndexLines;
1255
+ /** The line-targeted half of {@link sweepErasedIndexLines}: drop every MEMORY.md line, in every
1256
+ * registered scope home and the caller's, whose link target resolves to one of `erasedPaths`. */
1257
+ private dropIndexLinesNaming;
1258
+ /** The index residue an attestation could not carry (its copy could not be made — a hostile
1259
+ * accessor on a third-party face's object): disclosed on the durable announcement queue and the
1260
+ * incident sink instead. */
1261
+ private discloseUncarriedIndexResidue;
1210
1262
  /**
1211
1263
  * design/178 v2-a §1.3 — the per-entry provenance ANSWER (host audit API; see
1212
1264
  * {@link EntryProvenanceAccount} for the field law). The read is held to the three audit axes:
@@ -1246,7 +1298,8 @@ export declare class MemoryEngine {
1246
1298
  * (`memory.import_rejected`): integrity (fixed section-hash key set, per-entry content-rev
1247
1299
  * recomputation, batch-unique ids/event ids), structure (the governance section is REQUIRED —
1248
1300
  * there is no entries-only escape hatch), and — when `opts.expectedScopes` is present (a service
1249
- * endpoint pins its principal's grant set here) — the scope authorization envelope. Everything
1301
+ * endpoint pins its principal's grant set here; `eraseMemoryEntries` takes the same seat; a bad
1302
+ * set is `config.memory_import_request`) — the scope authorization envelope. Everything
1250
1303
  * after validation runs inside the backend's import composite: the synthetic latch (imported ids
1251
1304
  * stay withheld from every model-visible read face until governance fully lands), the five
1252
1305
  * import judgments IN-LOCK, entry landing through the one transaction skeleton, the governance