@sema-agent/core 7.67.3 → 7.68.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 (496) hide show
  1. package/CHANGELOG.md +1516 -0
  2. package/README.md +18 -9
  3. package/README.zh-CN.md +16 -8
  4. package/dist/agents/agent-definition.d.ts +1 -1
  5. package/dist/agents/agent-definition.js +4 -1
  6. package/dist/agents/cascade.d.ts +2 -2
  7. package/dist/agents/cascade.js +3 -1
  8. package/dist/agents/cumulative-stats.d.ts +2 -1
  9. package/dist/agents/cumulative-stats.js +4 -1
  10. package/dist/agents/list-agents-tool.d.ts +30 -0
  11. package/dist/agents/list-agents-tool.js +45 -3
  12. package/dist/agents/peer-admission.d.ts +2 -2
  13. package/dist/agents/peer-session-drain.d.ts +2 -0
  14. package/dist/agents/peer-session-drain.js +1 -0
  15. package/dist/agents/repair-loop.js +3 -1
  16. package/dist/agents/retain-ledger.d.ts +61 -8
  17. package/dist/agents/retain-ledger.js +25 -3
  18. package/dist/agents/roster-store.d.ts +4 -2
  19. package/dist/agents/send-message-tool.d.ts +1 -1
  20. package/dist/agents/send-message-tool.js +20 -15
  21. package/dist/agents/subagent-steps.js +2 -10
  22. package/dist/agents/subagent.d.ts +3 -0
  23. package/dist/agents/subagent.js +106 -76
  24. package/dist/agents/tool-filter.d.ts +20 -11
  25. package/dist/agents/tool-filter.js +8 -4
  26. package/dist/agents/verify.d.ts +3 -1
  27. package/dist/agents/verify.js +2 -0
  28. package/dist/brain/anthropic.js +4 -4
  29. package/dist/brain/open-responses.js +3 -1
  30. package/dist/brain/openai.js +3 -1
  31. package/dist/brain/reasoning-request.d.ts +73 -19
  32. package/dist/brain/reasoning-request.js +164 -72
  33. package/dist/brain/reasoning-stamp.d.ts +26 -0
  34. package/dist/brain/reasoning-stamp.js +10 -0
  35. package/dist/brain/reasoning.d.ts +95 -162
  36. package/dist/brain/reasoning.js +31 -86
  37. package/dist/brain/route-adjudicator.d.ts +9 -7
  38. package/dist/brain/route-adjudicator.js +12 -10
  39. package/dist/brain/status-sink.d.ts +19 -64
  40. package/dist/brain/status-sink.js +5 -21
  41. package/dist/brain/stream-engine.d.ts +11 -2
  42. package/dist/brain/stream-engine.js +10 -0
  43. package/dist/core/a2a.d.ts +17 -5
  44. package/dist/core/a2a.js +11 -3
  45. package/dist/core/allow-entry.d.ts +35 -15
  46. package/dist/core/allow-entry.js +47 -60
  47. package/dist/core/ask-headline.d.ts +68 -0
  48. package/dist/core/ask-headline.js +23 -0
  49. package/dist/core/ask-origin.d.ts +36 -8
  50. package/dist/core/ask-origin.js +17 -10
  51. package/dist/core/ask-question.d.ts +34 -7
  52. package/dist/core/ask-question.js +10 -1
  53. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  54. package/dist/core/ask-unresolvable-notice.js +9 -3
  55. package/dist/core/auto-strip.d.ts +53 -0
  56. package/dist/core/auto-strip.js +76 -0
  57. package/dist/core/background-agent-store.d.ts +45 -5
  58. package/dist/core/background-agent-store.js +69 -15
  59. package/dist/core/background-shell.d.ts +2 -2
  60. package/dist/core/caller-text.js +2 -2
  61. package/dist/core/canonical-json.d.ts +13 -0
  62. package/dist/core/canonical-json.js +7 -0
  63. package/dist/core/checkpoint-features.d.ts +66 -20
  64. package/dist/core/checkpoint-features.js +12 -1
  65. package/dist/core/checkpoint-generation.d.ts +1 -1
  66. package/dist/core/checkpoint-queries.d.ts +1 -1
  67. package/dist/core/checkpoint-queries.js +4 -1
  68. package/dist/core/checkpoint-requirements.d.ts +25 -1
  69. package/dist/core/checkpoint-requirements.js +5 -1
  70. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  71. package/dist/core/checkpoint-row-verdict.js +4 -0
  72. package/dist/core/checkpoint-store.d.ts +66 -38
  73. package/dist/core/checkpoint-store.js +15 -6
  74. package/dist/core/child-clamp-seats.d.ts +6 -0
  75. package/dist/core/child-clamp-seats.js +1 -0
  76. package/dist/core/config-refusal-codes.d.ts +1 -1
  77. package/dist/core/config-refusal-codes.js +1 -0
  78. package/dist/core/delegation-frames.d.ts +9 -12
  79. package/dist/core/delegation-frames.js +9 -8
  80. package/dist/core/engine-capabilities.d.ts +21 -8
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +147 -34
  83. package/dist/core/engine-notice.js +27 -16
  84. package/dist/core/engine-storage-backend.d.ts +2 -1
  85. package/dist/core/env-budget.js +3 -3
  86. package/dist/core/env-knob-announce.d.ts +10 -10
  87. package/dist/core/env-knob-announce.js +3 -6
  88. package/dist/core/file-history-store.d.ts +29 -4
  89. package/dist/core/file-history-store.js +13 -0
  90. package/dist/core/frame-settlement.d.ts +2 -1
  91. package/dist/core/gate-fold.js +1 -1
  92. package/dist/core/gate-lanes.js +56 -49
  93. package/dist/core/governance-codes.d.ts +39 -3
  94. package/dist/core/governance-codes.js +61 -3
  95. package/dist/core/hooks.d.ts +29 -11
  96. package/dist/core/hooks.js +5 -2
  97. package/dist/core/human-input-projection.js +3 -3
  98. package/dist/core/input-author.d.ts +17 -3
  99. package/dist/core/input-author.js +15 -3
  100. package/dist/core/leg-identity.d.ts +10 -28
  101. package/dist/core/leg-identity.js +1 -21
  102. package/dist/core/lsp.d.ts +18 -13
  103. package/dist/core/lsp.js +30 -22
  104. package/dist/core/mailbox-store.d.ts +1 -1
  105. package/dist/core/mailbox-store.js +4 -4
  106. package/dist/core/mcp-connection-pool.d.ts +93 -4
  107. package/dist/core/mcp-connection-pool.js +104 -1
  108. package/dist/core/mcp-failure.d.ts +38 -12
  109. package/dist/core/mcp-failure.js +9 -13
  110. package/dist/core/mcp-probe.d.ts +4 -3
  111. package/dist/core/mcp-server-link.d.ts +4 -2
  112. package/dist/core/mcp-server-link.js +4 -5
  113. package/dist/core/mcp-server-spec.d.ts +3 -3
  114. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  115. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  116. package/dist/core/mcp.d.ts +40 -6
  117. package/dist/core/mcp.js +39 -13
  118. package/dist/core/memory-engine/content-origin.js +2 -2
  119. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  120. package/dist/core/memory-engine/control-objects.js +2 -10
  121. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  122. package/dist/core/memory-engine/dual-root.js +3 -0
  123. package/dist/core/memory-engine/engine.d.ts +6 -4
  124. package/dist/core/memory-engine/engine.js +32 -29
  125. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  126. package/dist/core/memory-engine/file-backend.js +21 -31
  127. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  128. package/dist/core/memory-engine/frontmatter.js +4 -0
  129. package/dist/core/memory-engine/layout.d.ts +114 -20
  130. package/dist/core/memory-engine/layout.js +340 -22
  131. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  132. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  133. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  134. package/dist/core/memory-engine/sync-client.js +4 -5
  135. package/dist/core/model-fallbacks.d.ts +5 -1
  136. package/dist/core/model-fallbacks.js +3 -3
  137. package/dist/core/model-receipt.d.ts +2 -1
  138. package/dist/core/model-receipt.js +12 -1
  139. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  140. package/dist/core/mods/kernel/dispatch.js +14 -6
  141. package/dist/core/mods/kernel/events.d.ts +8 -5
  142. package/dist/core/mods/kernel/events.js +2 -2
  143. package/dist/core/mods/kernel/index.d.ts +1 -1
  144. package/dist/core/mods/kernel/registration.d.ts +9 -0
  145. package/dist/core/mods/package.js +1 -1
  146. package/dist/core/mods/session-append.d.ts +4 -2
  147. package/dist/core/mods/session-append.js +3 -0
  148. package/dist/core/mods/stations.d.ts +7 -11
  149. package/dist/core/mods/stations.js +4 -7
  150. package/dist/core/mods/tool-call.d.ts +10 -8
  151. package/dist/core/mods/tool-call.js +15 -18
  152. package/dist/core/mounted-mcp.d.ts +0 -4
  153. package/dist/core/mounted-mcp.js +1 -1
  154. package/dist/core/park-noun.d.ts +24 -0
  155. package/dist/core/park-noun.js +21 -0
  156. package/dist/core/park-resumability.d.ts +60 -0
  157. package/dist/core/park-resumability.js +30 -0
  158. package/dist/core/permission-rule-provider.d.ts +24 -2
  159. package/dist/core/permission-rule-provider.js +11 -8
  160. package/dist/core/permission-rule-store.d.ts +8 -1
  161. package/dist/core/permission-rule-store.js +2 -3
  162. package/dist/core/permission-rules.d.ts +2 -1
  163. package/dist/core/permission-rules.js +8 -4
  164. package/dist/core/persisted-rule-arms.d.ts +3 -0
  165. package/dist/core/persisted-rule-arms.js +2 -1
  166. package/dist/core/present-plan-tool.d.ts +47 -3
  167. package/dist/core/present-plan-tool.js +62 -4
  168. package/dist/core/principal-name.d.ts +1 -1
  169. package/dist/core/principal-name.js +5 -5
  170. package/dist/core/process-identity.js +10 -5
  171. package/dist/core/protocol-http-auth.d.ts +20 -14
  172. package/dist/core/protocol-http-auth.js +70 -50
  173. package/dist/core/read-only-shell.js +9 -5
  174. package/dist/core/redaction-marks.d.ts +4 -26
  175. package/dist/core/redaction-marks.js +9 -21
  176. package/dist/core/remote-env.d.ts +43 -16
  177. package/dist/core/remote-env.js +1 -1
  178. package/dist/core/request-copy-projection.d.ts +1 -1
  179. package/dist/core/request-copy-projection.js +40 -50
  180. package/dist/core/resume-config-judge.js +1 -1
  181. package/dist/core/resume-startup-cause.d.ts +35 -18
  182. package/dist/core/resume-startup-cause.js +13 -10
  183. package/dist/core/retention.d.ts +167 -25
  184. package/dist/core/retention.js +100 -20
  185. package/dist/core/roles.d.ts +6 -0
  186. package/dist/core/roles.js +11 -5
  187. package/dist/core/rule-lane-reads.d.ts +3 -0
  188. package/dist/core/rule-lane-reads.js +5 -1
  189. package/dist/core/rule-store-fault.d.ts +70 -0
  190. package/dist/core/rule-store-fault.js +102 -0
  191. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  192. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  193. package/dist/core/runner/announce-once-ledger.js +24 -2
  194. package/dist/core/runner/assemble-result.d.ts +6 -0
  195. package/dist/core/runner/assemble-result.js +1 -1
  196. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  197. package/dist/core/runner/auto-strip-notice.js +59 -0
  198. package/dist/core/runner/branch-window.d.ts +3 -0
  199. package/dist/core/runner/branch-window.js +37 -0
  200. package/dist/core/runner/caller-roster.d.ts +8 -3
  201. package/dist/core/runner/capability-withheld-seat.js +3 -9
  202. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  203. package/dist/core/runner/clock-and-limits.js +30 -0
  204. package/dist/core/runner/contracts.d.ts +58 -35
  205. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  206. package/dist/core/runner/credential-refusal-seat.js +47 -0
  207. package/dist/core/runner/cross-boundary-lane.js +6 -4
  208. package/dist/core/runner/decide-continuation.js +1 -1
  209. package/dist/core/runner/file-history-restore.d.ts +53 -2
  210. package/dist/core/runner/file-history-restore.js +29 -10
  211. package/dist/core/runner/forward-sink.d.ts +14 -1
  212. package/dist/core/runner/forward-sink.js +14 -12
  213. package/dist/core/runner/gate-exit.d.ts +8 -7
  214. package/dist/core/runner/gate-exit.js +13 -13
  215. package/dist/core/runner/git-status-frame.js +2 -4
  216. package/dist/core/runner/initial-run-state.js +1 -1
  217. package/dist/core/runner/main-call-account.d.ts +3 -1
  218. package/dist/core/runner/main-call-account.js +5 -3
  219. package/dist/core/runner/mcp-redial.d.ts +2 -5
  220. package/dist/core/runner/mcp-redial.js +2 -2
  221. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  222. package/dist/core/runner/nested-memory-content.js +73 -13
  223. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  224. package/dist/core/runner/nested-memory-lane.js +152 -76
  225. package/dist/core/runner/park-commit.js +3 -1
  226. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  227. package/dist/core/runner/permission-rule-lanes.js +29 -3
  228. package/dist/core/runner/person-path-rows.d.ts +3 -11
  229. package/dist/core/runner/person-path-rows.js +21 -24
  230. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  231. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  232. package/dist/core/runner/prepare-artifact.js +20 -14
  233. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  234. package/dist/core/runner/prepare-ask-lane.js +6 -5
  235. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  236. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  237. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  238. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  239. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  240. package/dist/core/runner/prepare-config-doors.js +58 -41
  241. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  242. package/dist/core/runner/prepare-context-lane.js +3 -5
  243. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  244. package/dist/core/runner/prepare-defer-classify.js +1 -1
  245. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  246. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  247. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  248. package/dist/core/runner/prepare-file-history.js +117 -46
  249. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  250. package/dist/core/runner/prepare-gate-stations.js +6 -5
  251. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  252. package/dist/core/runner/prepare-hands-readface.js +8 -4
  253. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  254. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  255. package/dist/core/runner/prepare-listings.d.ts +1 -1
  256. package/dist/core/runner/prepare-listings.js +1 -1
  257. package/dist/core/runner/prepare-memory.js +2 -2
  258. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  259. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  260. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  261. package/dist/core/runner/prepare-park-ask.js +7 -9
  262. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  263. package/dist/core/runner/prepare-policy-chain.js +18 -13
  264. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  265. package/dist/core/runner/prepare-project-context.js +5 -3
  266. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  267. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  268. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  269. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  270. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  271. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  272. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  273. package/dist/core/runner/prepare-run-refs.js +8 -7
  274. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  275. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  276. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  277. package/dist/core/runner/prepare-task.js +66 -53
  278. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  279. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  280. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  281. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  282. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  283. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  284. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  285. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  286. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  287. package/dist/core/runner/restore-seat.d.ts +41 -0
  288. package/dist/core/runner/restore-seat.js +38 -0
  289. package/dist/core/runner/resume-admission.js +1 -1
  290. package/dist/core/runner/resume-apply.js +4 -3
  291. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  292. package/dist/core/runner/resume-internals-and-config.js +2 -1
  293. package/dist/core/runner/resume-preflight.js +2 -1
  294. package/dist/core/runner/rewind-files.js +22 -6
  295. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  296. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  297. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  298. package/dist/core/runner/run-brain-sinks.js +6 -6
  299. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  300. package/dist/core/runner/run-git-lane.d.ts +2 -0
  301. package/dist/core/runner/run-git-lane.js +2 -1
  302. package/dist/core/runner/run-harness-handlers.js +5 -4
  303. package/dist/core/runner/run-identity-wiring.js +20 -12
  304. package/dist/core/runner/run-leg.js +31 -72
  305. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  306. package/dist/core/runner/run-notification-lane.js +2 -4
  307. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  308. package/dist/core/runner/run-reasoning-seat.js +13 -18
  309. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  310. package/dist/core/runner/run-terminal-adoption.js +4 -8
  311. package/dist/core/runner/run-turn-boundary.js +6 -3
  312. package/dist/core/runner/runtask.d.ts +9 -4
  313. package/dist/core/runner/runtask.js +29 -22
  314. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  315. package/dist/core/runner/shell-env-withheld.js +2 -7
  316. package/dist/core/runner/side-call-account.d.ts +5 -6
  317. package/dist/core/runner/side-call-account.js +2 -2
  318. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  319. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  320. package/dist/core/runner/stream-settle-backstop.js +4 -6
  321. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  322. package/dist/core/runner/stream-steer-verb.js +4 -4
  323. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  324. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  325. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  326. package/dist/core/runner/teardown-bounded.js +7 -0
  327. package/dist/core/runner/terminal-account.js +41 -13
  328. package/dist/core/runner/terminal-projection.d.ts +1 -5
  329. package/dist/core/runner/tool-end-body.d.ts +9 -3
  330. package/dist/core/runner/tool-end-body.js +6 -3
  331. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  332. package/dist/core/runner/tool-output-projection.js +10 -14
  333. package/dist/core/runner/turn-attachments.d.ts +3 -2
  334. package/dist/core/runner/turn-attachments.js +12 -5
  335. package/dist/core/runner-deps.d.ts +6 -6
  336. package/dist/core/runtime-caps.d.ts +2 -1
  337. package/dist/core/secret-env.d.ts +20 -3
  338. package/dist/core/secret-env.js +13 -15
  339. package/dist/core/session-checkout.d.ts +115 -15
  340. package/dist/core/session-checkout.js +435 -136
  341. package/dist/core/session-policy-store.js +21 -3
  342. package/dist/core/session-reconcile.js +1 -0
  343. package/dist/core/session-store.js +2 -0
  344. package/dist/core/session.d.ts +11 -1
  345. package/dist/core/shell-run-candidates.d.ts +1 -0
  346. package/dist/core/shell-run-candidates.js +1 -1
  347. package/dist/core/shutdown-debug.d.ts +6 -5
  348. package/dist/core/shutdown-debug.js +5 -1
  349. package/dist/core/skill-grant.js +4 -1
  350. package/dist/core/skills-directory.js +5 -3
  351. package/dist/core/spec-contract.d.ts +1 -1
  352. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  353. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  354. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  355. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  356. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  357. package/dist/core/task-event.d.ts +48 -27
  358. package/dist/core/task-notification.d.ts +15 -9
  359. package/dist/core/task-notification.js +12 -0
  360. package/dist/core/task-registry-agent.d.ts +24 -22
  361. package/dist/core/task-registry-agent.js +65 -46
  362. package/dist/core/task-registry-shared.d.ts +17 -5
  363. package/dist/core/task-registry.d.ts +17 -6
  364. package/dist/core/task-registry.js +6 -1
  365. package/dist/core/task-result.d.ts +71 -25
  366. package/dist/core/task-spec-members.d.ts +0 -1
  367. package/dist/core/task-spec-members.js +1 -1
  368. package/dist/core/task-spec.d.ts +60 -52
  369. package/dist/core/task-stream.d.ts +45 -12
  370. package/dist/core/terminal-cause.d.ts +45 -8
  371. package/dist/core/terminal-cause.js +5 -0
  372. package/dist/core/tool-card-bound.d.ts +32 -0
  373. package/dist/core/tool-card-bound.js +33 -0
  374. package/dist/core/tool-catalog-entries.d.ts +9 -0
  375. package/dist/core/tool-catalog-entries.js +48 -0
  376. package/dist/core/tool-errors.d.ts +4 -3
  377. package/dist/core/tool-face.d.ts +3 -3
  378. package/dist/core/tool-mount-facts.d.ts +3 -2
  379. package/dist/core/tool-mount-facts.js +1 -1
  380. package/dist/core/tool-mount-static.js +7 -5
  381. package/dist/core/tool-policy.d.ts +21 -19
  382. package/dist/core/tool-policy.js +5 -6
  383. package/dist/core/tool-registry.d.ts +3 -1
  384. package/dist/core/tool-registry.js +15 -1
  385. package/dist/core/tool-result-store.d.ts +9 -3
  386. package/dist/core/tool-result-store.js +14 -1
  387. package/dist/core/tool-roster.d.ts +6 -0
  388. package/dist/core/tool-roster.js +18 -0
  389. package/dist/core/tool-spec.d.ts +17 -8
  390. package/dist/core/trace.d.ts +35 -31
  391. package/dist/core/types.d.ts +2 -2
  392. package/dist/core/untrusted-egress.d.ts +10 -9
  393. package/dist/core/untrusted-egress.js +9 -9
  394. package/dist/core/untrusted-text.d.ts +0 -18
  395. package/dist/core/untrusted-text.js +7 -3
  396. package/dist/core/user-attachment.d.ts +9 -6
  397. package/dist/core/user-attachment.js +12 -10
  398. package/dist/core/user-row-origin.d.ts +44 -25
  399. package/dist/core/user-row-origin.js +30 -20
  400. package/dist/core/wiring-manifest.d.ts +26 -7
  401. package/dist/core/wiring-manifest.js +14 -11
  402. package/dist/core/workspace-snapshot.d.ts +3 -1
  403. package/dist/core/workspace-snapshot.js +1 -0
  404. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  405. package/dist/engine/execution-env/node-execution-env.js +127 -67
  406. package/dist/engine/harness/agent-harness.d.ts +4 -5
  407. package/dist/engine/harness/agent-harness.js +2 -7
  408. package/dist/engine/harness/types.d.ts +51 -19
  409. package/dist/engine/harness/types.js +28 -1
  410. package/dist/engine/llm/types.d.ts +26 -14
  411. package/dist/engine/llm/types.js +2 -2
  412. package/dist/engine/loop/agent-loop.d.ts +2 -2
  413. package/dist/engine/loop/agent-loop.js +51 -275
  414. package/dist/engine/loop/types.d.ts +0 -18
  415. package/dist/engine/session/import-validate.d.ts +3 -0
  416. package/dist/engine/session/import-validate.js +34 -2
  417. package/dist/engine/session/repo-utils.d.ts +42 -4
  418. package/dist/engine/session/repo-utils.js +33 -5
  419. package/dist/engine/session/session.d.ts +41 -14
  420. package/dist/engine/session/session.js +96 -25
  421. package/dist/index.d.ts +21 -16
  422. package/dist/index.js +16 -10
  423. package/dist/orchestration/run-spec.d.ts +1 -1
  424. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  425. package/dist/orchestration/run-workflow-tool.js +15 -19
  426. package/dist/orchestration/workflow-governance.js +13 -21
  427. package/dist/orchestration/workflow-observe.d.ts +4 -3
  428. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  429. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  430. package/dist/orchestration/workflow-record-artifact.js +32 -0
  431. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  432. package/dist/orchestration/workflow-script-store.js +20 -1
  433. package/dist/orchestration/workflow-types.d.ts +33 -3
  434. package/dist/orchestration/workflow.d.ts +24 -14
  435. package/dist/orchestration/workflow.js +52 -23
  436. package/dist/prompt-assembly/artifact.js +4 -8
  437. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  438. package/dist/prompt-assembly/catalog/engine.js +30 -0
  439. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  440. package/dist/prompt-assembly/catalog/index.js +2 -2
  441. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  442. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  443. package/dist/prompt-assembly/epoch.js +6 -8
  444. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  445. package/dist/stores/file/background-agent-store.js +5 -6
  446. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  447. package/dist/stores/file/checkpoint-store.js +7 -3
  448. package/dist/stores/file/file-history-store.d.ts +8 -0
  449. package/dist/stores/file/file-history-store.js +72 -0
  450. package/dist/stores/file/fs-atomic.js +17 -12
  451. package/dist/stores/file/index.js +11 -5
  452. package/dist/stores/file/mailbox-store.js +13 -4
  453. package/dist/stores/file/permission-rule-store.js +14 -13
  454. package/dist/stores/file/shared-ledger.d.ts +4 -0
  455. package/dist/stores/file/shared-ledger.js +4 -0
  456. package/dist/stores/file/task-list-store.js +12 -3
  457. package/dist/stores/file/workflow-run-store.js +1 -0
  458. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  459. package/dist/tools/fs/bash-program-position.js +1 -1
  460. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  461. package/dist/tools/fs/bound-open.d.ts +97 -0
  462. package/dist/tools/fs/bound-open.js +103 -0
  463. package/dist/tools/fs/containment-face.d.ts +2 -2
  464. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  465. package/dist/tools/fs/fs-pdf.js +31 -23
  466. package/dist/tools/fs/fs-read.d.ts +24 -17
  467. package/dist/tools/fs/fs-read.js +84 -53
  468. package/dist/tools/fs/fs-shared.d.ts +14 -12
  469. package/dist/tools/fs/fs-shared.js +5 -4
  470. package/dist/tools/fs/fs-write.d.ts +2 -2
  471. package/dist/tools/fs/fs-write.js +20 -12
  472. package/dist/tools/fs/index.d.ts +4 -4
  473. package/dist/tools/fs/index.js +2 -2
  474. package/dist/tools/fs/notebook.d.ts +1 -1
  475. package/dist/tools/fs/pdf.d.ts +12 -3
  476. package/dist/tools/fs/pdf.js +22 -9
  477. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  478. package/dist/tools/fs/read-deny-home.js +8 -11
  479. package/dist/tools/fs/safety.d.ts +3 -2
  480. package/dist/tools/fs/shell-read-check.js +10 -9
  481. package/dist/tools/monitor.d.ts +6 -5
  482. package/dist/tools/task-list.d.ts +16 -6
  483. package/dist/tools/task-list.js +4 -0
  484. package/dist/tools/web.d.ts +9 -1
  485. package/dist/tools/web.js +8 -3
  486. package/dist/tools/worktree.d.ts +7 -5
  487. package/dist/tools/worktree.js +4 -3
  488. package/package.json +4 -3
  489. package/test/export-surface.snapshot.json +93 -7
  490. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  491. package/wire-changes/core@7.68.0.json +4257 -0
  492. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  493. package/wire-changes/primitives@7.68.0.json +253 -0
  494. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  495. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  496. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -1,5 +1,7 @@
1
1
  import type { EngineStorageBackend } from "./engine-storage-backend.js";
2
2
  import type { WorkflowRunStore } from "./workflow-run-store.js";
3
+ import type { WorkflowScriptStore } from "../orchestration/workflow-script-store.js";
4
+ import type { TaskListStore } from "../tools/task-list.js";
3
5
  /** A store's retention declaration: `"managed"` = this store's rows are deleted on schedule by the
4
6
  * deployment; `"none"` = nothing deletes them on schedule. Absent ⇒ read fail-closed as `"none"`. */
5
7
  export type RetentionDeclaration = "managed" | "none";
@@ -41,8 +43,9 @@ export interface RetentionPolicy {
41
43
  * - **tombstoned**: deletions leave tombstones so replicas/backups converge instead of resurrecting;
42
44
  * - **audited**: every destructive call is recorded append-only. The IDENTITY of that record —
43
45
  * which occurrence, which of the three operations, at what wall clock — belongs to the side that
44
- * WRITES the row, not to the receipt: an implementation records it in the same transaction as the
45
- * deletion (recording after the delete would leave an unwitnessed delete on a crash), and it is
46
+ * WRITES the row, not to the receipt: an implementation makes it durable no later than the rows it
47
+ * witnesses are gone (for a session, as its deletion record: {@link ManagedRetentionCapability.deleteExpiredSessions};
48
+ * recording after the delete would leave an unwitnessed delete on a crash), and it is
46
49
  * the only side that knows its own op, sweep round, and policy generation. The receipt below is
47
50
  * therefore the CALL's three counts, deliberately not an audit row. Where the deletion and the
48
51
  * sweep's context live on two sides — a SQL backend writes the deletion, the deployment holds the op —
@@ -64,9 +67,18 @@ export interface ManagedRetentionCapability {
64
67
  }): Promise<RetentionReceipt>;
65
68
  /** Lineage-aware transcript/session deletion: a session tree is deleted only when no live
66
69
  * reference still points into it — the table's legs name each one (`liveReference`) — and the
67
- * references are re-checked inside the deletion transaction, never assumed from a prior scan; an
70
+ * references are re-checked as below, never assumed from a prior scan; an
68
71
  * exempt row of {@link RETENTION_CASCADE} is never deleted with one. What one session's deletion
69
- * erases, and in which order, is {@link RETENTION_CASCADE}'s session-tree legs. */
72
+ * erases, and in which order, is {@link RETENTION_CASCADE}'s session-tree legs.
73
+ *
74
+ * @contract retention.session_deletion_recorded_first — one session's deletion is witnessed no later than it happens, and a
75
+ * crash part-way through it is finished by a replay. Under an exclusion on the session that every write able to point into it takes too (a fork of it, a
76
+ * background agent of it, a checkpoint it parks), the executor re-checks the session's live references and, with none standing,
77
+ * runs the legs in {@link RETENTION_SESSION_TREE_STEPS}' order under a deletion record — its intent (the domain, the session,
78
+ * the call's cutoff), its audit row and its tombstones: no row the record witnesses is gone while the record is not yet written
79
+ * and synced, and the record is marked done after the session row's leg. A record not marked done keeps its session's exclusion
80
+ * across a crash: the executor's next start replays it from the first step before any other write takes that exclusion, and a
81
+ * replay is idempotent — a row already gone counts 0, and the record's audit row and tombstones are not written again. */
70
82
  deleteExpiredSessions(input: {
71
83
  domain: string;
72
84
  cutoffMs: number;
@@ -83,10 +95,14 @@ export interface ManagedRetentionCapability {
83
95
  /** The executor operation a cascade leg belongs to: `"checkpoints"` = `expireCheckpoints`, `"session-trees"` =
84
96
  * `deleteExpiredSessions`, `"orphan-tool-results"` = `deleteOrphanToolResults`. */
85
97
  export type RetentionCascadeDomain = "checkpoints" | "session-trees" | "orphan-tool-results";
86
- /** The stores {@link RETENTION_CASCADE} covers, by seat name: every store member of {@link EngineStorageBackend} and the
87
- * workflow-run store a deployment constructs itself. */
98
+ /** The stores {@link RETENTION_CASCADE} covers, by seat name: every store member of {@link EngineStorageBackend}, and the three a
99
+ * deployment constructs and hands the engine itself — the workflow-run store, the workflow script store
100
+ * (`RunnerDeps.workflowScriptStore`), and the task list it mounts under the session's id (`task_list.partition_is_root_session`;
101
+ * a deployment that mounts one list per root session binds this seat to that session's list). */
88
102
  export type RetentionCascadeStores = Omit<EngineStorageBackend, "retention" | "dispose"> & {
89
103
  readonly workflowRunStore: WorkflowRunStore;
104
+ readonly workflowScriptStore: WorkflowScriptStore;
105
+ readonly taskListStore: TaskListStore;
90
106
  };
91
107
  /** One leg of a store's row: the store method a domain's operation calls on it. */
92
108
  export interface RetentionCascadeLeg<S = {
@@ -104,6 +120,12 @@ export interface RetentionCascadeLeg<S = {
104
120
  readonly fence?: Extract<keyof S, string>;
105
121
  /** What, on this leg's side, still points into the session and keeps its tree from being deleted by the executor. */
106
122
  readonly liveReference?: string;
123
+ /** What the leg leaves of the session's bytes in its store on purpose, and why — never session content (absent ⇒ it leaves none). */
124
+ readonly keeps?: string;
125
+ /** The store's method that takes this leg's place for a session whose head cannot be read (`SessionStore.deleteUnreadable`'s
126
+ * deletion — an operator's, where no owner guard can hold); absent ⇒ the leg runs as it is for that session too. A store that does
127
+ * not carry the method refuses that session's deletion before its first destructive call ({@link RETENTION_CASCADE}). */
128
+ readonly unreadable?: Extract<keyof S, string>;
107
129
  }
108
130
  /** A row's fork column: how a fork of the session carries the rows (`"at-fork"` — copied when the fork is made;
109
131
  * `"first-prepare"` — carried on the fork's first prepare, keyed on `SessionMetadata.forkedFrom`; `"not-carried"` — the
@@ -125,26 +147,32 @@ export type RetentionCascadeRow<S = {
125
147
  readonly fork: RetentionCascadeFork;
126
148
  };
127
149
  /**
128
- * @contract retention.cascade_table — what deleting a session erases, as one table: every store the engine persists in has exactly one
129
- * row (typed complete against {@link RetentionCascadeStores}), and so has each governance record the memory engine's control plane
130
- * keeps beside them. A store's row is either the legs that erase its rows or an exemption naming why its rows are not session
131
- * data; a leg names its executor domain (every leg belongs to exactly one of the three, and each domain has a leg), its verb, what
132
- * the verb selects, for a session-tree leg its step, and what on its side still points into the session (`liveReference`). A
133
- * governance record's row (`heldBy: "memory-control-plane"`) is always an exemption: the pollution markers, the capture opt-out
134
- * records and the harvest lineage ledger are facts about content that exists, so deleting one with its session makes a one-way
135
- * record revocable. Every row has a fork column: whether a fork of the session carries the rows when it is made, on its first
136
- * prepare, or not at all, and why. A session tree is erased child sessions first; within one session every leg's fence runs
137
- * before the first step, then the steps ascend and the session row's leg is last — a leg that fails leaves the row, so a retry
138
- * runs the cascade again from its first step and converges. A leg that finds what it erases through another store's rows runs
139
- * before that store's leg (the journals before the runs, the background agents' boxes before their rows, the forks' file-history
140
- * carry before the session's history), so a retry still finds them. A workflow run
141
- * started in a deleted session goes with it, journal included: a later resume of that run from another session is refused
150
+ * @contract retention.cascade_table — what deleting a session erases, as one table: every store seat has exactly one row (typed
151
+ * complete against {@link RetentionCascadeStores}), and so has each governance document and each control-object kind the memory
152
+ * engine's governance store keeps beside them (typed complete against both closed sets). A store's row is either the legs that erase its rows or an exemption naming why its rows are not session data; a leg names
153
+ * its executor domain (every leg belongs to exactly one of the three, and each domain has a leg), its verb, what the verb selects,
154
+ * for a session-tree leg its step, what on its side still points into the session (`liveReference`), what it leaves of the session's
155
+ * bytes on purpose and why (`keeps` — never session content), and the verb that takes its place for a session whose head cannot be
156
+ * read (`unreadable`). A governance record's row (`heldBy: "memory-control-plane"`) is always an exemption, naming the content it
157
+ * is a fact about — a memory entry, a contribution, a held write, an import, a session's standing pollution mark or capture opt-out
158
+ * — which outlives the session, so deleting the record with its session would make a one-way record revocable. Every row has a fork column: whether a fork of the session
159
+ * carries the rows when it is made, on its first prepare, or not at all, and why. A session tree is erased child sessions first;
160
+ * within one session every leg's fence runs before the first step, then the steps ascend and the session row's leg is last — a leg
161
+ * that fails leaves the row, so a retry runs the cascade again from its first step and converges. A leg that finds what it erases
162
+ * through another store's rows runs before that store's leg (the journals and scripts before the runs, the background agents' boxes
163
+ * before their rows, the forks' file-history carry before the session's history), so a retry still finds them. A session whose head
164
+ * cannot be read is deleted by the same legs, each leg that names an `unreadable` verb calling it instead — an operator's act, since
165
+ * no owner guard can hold for a row that names no owner: `SessionStore.deleteUnreadable` is that session's row leg as
166
+ * `SessionStore.delete` is a readable one's, and neither alone deletes more than the row and its log. Those verbs are optional store
167
+ * members, so such a deletion first checks that every store whose leg names one carries it: a store without it refuses the deletion
168
+ * there, before the first destructive call, naming the store and the verb — nothing is deleted, nothing is left half-deleted. A workflow run started in a deleted
169
+ * session goes with it, journal and script included: a later resume of that run from another session is refused
142
170
  * `workflow.park_truth_unreadable` with `detail.reason: "record_missing"`, the word an absent prior record already answers. The run
143
- * store is what indexes runs by session, so a deployment that wires a journal store without one leaves its journals out of reach.
171
+ * store is what indexes runs by session, so a deployment that wires a journal or script store without one leaves them out of reach.
144
172
  * A host's coordinator is checked against the table by {@link import("./store-contracts/session-deletion-cascade-contract.js").sessionDeletionCascadeContract}.
145
173
  */
146
174
  export declare const RETENTION_CASCADE: {
147
- "session-pollution": {
175
+ lineage: {
148
176
  exempt: string;
149
177
  heldBy: "memory-control-plane";
150
178
  fork: {
@@ -152,7 +180,7 @@ export declare const RETENTION_CASCADE: {
152
180
  why: string;
153
181
  };
154
182
  };
155
- "session-capture-optout": {
183
+ challenges: {
156
184
  exempt: string;
157
185
  heldBy: "memory-control-plane";
158
186
  fork: {
@@ -160,7 +188,87 @@ export declare const RETENTION_CASCADE: {
160
188
  why: string;
161
189
  };
162
190
  };
163
- "lineage.json": {
191
+ settlements: {
192
+ exempt: string;
193
+ heldBy: "memory-control-plane";
194
+ fork: {
195
+ carry: "not-carried";
196
+ why: string;
197
+ };
198
+ };
199
+ "session-accounts": {
200
+ exempt: string;
201
+ heldBy: "memory-control-plane";
202
+ fork: {
203
+ carry: "not-carried";
204
+ why: string;
205
+ };
206
+ };
207
+ announcements: {
208
+ exempt: string;
209
+ heldBy: "memory-control-plane";
210
+ fork: {
211
+ carry: "not-carried";
212
+ why: string;
213
+ };
214
+ };
215
+ holds: {
216
+ exempt: string;
217
+ heldBy: "memory-control-plane";
218
+ fork: {
219
+ carry: "not-carried";
220
+ why: string;
221
+ };
222
+ };
223
+ "origin-clearances": {
224
+ exempt: string;
225
+ heldBy: "memory-control-plane";
226
+ fork: {
227
+ carry: "not-carried";
228
+ why: string;
229
+ };
230
+ };
231
+ pollution: {
232
+ exempt: string;
233
+ heldBy: "memory-control-plane";
234
+ fork: {
235
+ carry: "not-carried";
236
+ why: string;
237
+ };
238
+ };
239
+ "import-receipt": {
240
+ exempt: string;
241
+ heldBy: "memory-control-plane";
242
+ fork: {
243
+ carry: "not-carried";
244
+ why: string;
245
+ };
246
+ };
247
+ quarantine: {
248
+ exempt: string;
249
+ heldBy: "memory-control-plane";
250
+ fork: {
251
+ carry: "not-carried";
252
+ why: string;
253
+ };
254
+ };
255
+ hold: {
256
+ exempt: string;
257
+ heldBy: "memory-control-plane";
258
+ fork: {
259
+ carry: "not-carried";
260
+ why: string;
261
+ };
262
+ };
263
+ "clearance-custody": {
264
+ exempt: string;
265
+ heldBy: "memory-control-plane";
266
+ fork: {
267
+ carry: "not-carried";
268
+ why: string;
269
+ };
270
+ };
271
+ capture: {
164
272
  exempt: string;
165
273
  heldBy: "memory-control-plane";
166
274
  fork: {
@@ -181,6 +289,19 @@ export declare const RETENTION_CASCADE: {
181
289
  why: string;
182
290
  };
183
291
  };
292
+ workflowScriptStore: {
293
+ legs: {
294
+ domain: "session-trees";
295
+ step: number;
296
+ verb: "deleteRun";
297
+ selects: string;
298
+ liveReference: string;
299
+ }[];
300
+ fork: {
301
+ carry: "not-carried";
302
+ why: string;
303
+ };
304
+ };
184
305
  workflowRunStore: {
185
306
  legs: {
186
307
  domain: "session-trees";
@@ -224,6 +345,7 @@ export declare const RETENTION_CASCADE: {
224
345
  domain: "session-trees";
225
346
  step: number;
226
347
  verb: "deleteSessionCheckpoints";
348
+ unreadable: "deleteUnreadableSessionCheckpoints";
227
349
  selects: string;
228
350
  liveReference: string;
229
351
  } | {
@@ -231,6 +353,7 @@ export declare const RETENTION_CASCADE: {
231
353
  verb: "reap";
232
354
  selects: string;
233
355
  step?: undefined;
356
+ unreadable?: undefined;
234
357
  liveReference?: undefined;
235
358
  })[];
236
359
  fork: {
@@ -261,6 +384,7 @@ export declare const RETENTION_CASCADE: {
261
384
  step: number;
262
385
  verb: "deleteBySession";
263
386
  selects: string;
387
+ keeps: string;
264
388
  }[];
265
389
  fork: {
266
390
  carry: "not-carried";
@@ -273,10 +397,12 @@ export declare const RETENTION_CASCADE: {
273
397
  step: number;
274
398
  verb: "adoptScope";
275
399
  selects: string;
400
+ unreadable?: undefined;
276
401
  } | {
277
402
  domain: "session-trees";
278
403
  step: number;
279
404
  verb: "deleteBySession";
405
+ unreadable: "deleteUnreadableSessionHistory";
280
406
  selects: string;
281
407
  })[];
282
408
  fork: {
@@ -290,6 +416,7 @@ export declare const RETENTION_CASCADE: {
290
416
  step: number;
291
417
  verb: "drop";
292
418
  selects: string;
419
+ keeps: string;
293
420
  fence?: undefined;
294
421
  } | {
295
422
  domain: "session-trees";
@@ -297,12 +424,25 @@ export declare const RETENTION_CASCADE: {
297
424
  verb: "drop";
298
425
  fence: "retireRecipient";
299
426
  selects: string;
427
+ keeps: string;
300
428
  })[];
301
429
  fork: {
302
430
  carry: "not-carried";
303
431
  why: string;
304
432
  };
305
433
  };
434
+ taskListStore: {
435
+ legs: {
436
+ domain: "session-trees";
437
+ step: number;
438
+ verb: "drop";
439
+ selects: string;
440
+ }[];
441
+ fork: {
442
+ carry: "not-carried";
443
+ why: string;
444
+ };
445
+ };
306
446
  /**
307
447
  * @contract retention.image_bytes_live_in_the_session_store — a transcript's image bytes have one holder, the engine's session store:
308
448
  * they ride the session's log entries, so the session row's leg deletes them. A host that keeps a transcript of its own keeps a
@@ -313,6 +453,7 @@ export declare const RETENTION_CASCADE: {
313
453
  domain: "session-trees";
314
454
  step: number;
315
455
  verb: "delete";
456
+ unreadable: "deleteUnreadable";
316
457
  selects: string;
317
458
  liveReference: string;
318
459
  } | {
@@ -320,6 +461,7 @@ export declare const RETENTION_CASCADE: {
320
461
  verb: "unpin";
321
462
  selects: string;
322
463
  step?: undefined;
464
+ unreadable?: undefined;
323
465
  liveReference?: undefined;
324
466
  })[];
325
467
  fork: {
@@ -343,7 +485,7 @@ export declare const RETENTION_SESSION_TREE_STEPS: readonly (RetentionCascadeLeg
343
485
  * The three counts one destructive retention call produced. NOT an audit row and deliberately
344
486
  * identity-free (see the capability's `audited` clause): a scheduler that needs to tell two
345
487
  * same-shaped calls apart reads its store's audit records, which the implementation writes with its
346
- * own occurrence id, operation, and timestamp inside the deleting transaction. Adding those here
488
+ * own occurrence id, operation, and timestamp, durable no later than the deletion it witnesses. Adding those here
347
489
  * would ask a return value to know its own call context.
348
490
  */
349
491
  export interface RetentionReceipt {
@@ -17,58 +17,88 @@ function deepFreeze(value) {
17
17
  }
18
18
  return value;
19
19
  }
20
+ const DROPPED_BOX_KEEPS = "in the file twin, the box's file stays, empty, under the box's handle (a session's box handle names the session's id): no record is left, and a process that still holds the box replays it empty";
20
21
  const STORE_ROWS = {
21
22
  workflowJournalStore: {
22
23
  legs: [{ domain: "session-trees", step: 1, verb: "deleteRun", selects: "the journal of each terminal workflow run the session started, found through the run store's listByScope session filter while the run rows still exist", liveReference: "a running workflow run the session started" }],
23
24
  fork: { carry: "not-carried", why: "a run's journal stays keyed by the run the session started; a fork, like any other session, resumes that run only while the source's rows exist" },
24
25
  },
26
+ workflowScriptStore: {
27
+ legs: [{ domain: "session-trees", step: 2, verb: "deleteRun", selects: "the script persisted for each terminal workflow run the session started, in the run's scope, found through the run store's listByScope session filter while the run rows still exist; the saved-name registry is no run's and is not touched", liveReference: "a running workflow run the session started" }],
28
+ fork: { carry: "not-carried", why: "a run's script stays keyed by the run the session started; a fork, like any other session, reads it only while the source's rows exist" },
29
+ },
25
30
  workflowRunStore: {
26
- legs: [{ domain: "session-trees", step: 2, verb: "deleteBySession", selects: "the session's terminal workflow runs in its scope; answers the run ids it deleted", liveReference: "a running workflow run the session started" }],
31
+ legs: [{ domain: "session-trees", step: 3, verb: "deleteBySession", selects: "the session's terminal workflow runs in its scope; answers the run ids it deleted", liveReference: "a running workflow run the session started" }],
27
32
  fork: { carry: "not-carried", why: "a run row stays keyed by the session that started it; a fork starts with none of its own" },
28
33
  },
29
34
  backgroundAgentStore: {
30
- legs: [{ domain: "session-trees", step: 4, verb: "delete", selects: "each terminal row listBySession names for the session", liveReference: "a running or parked background agent of the session" }],
35
+ legs: [{ domain: "session-trees", step: 5, verb: "delete", selects: "each terminal row listBySession names for the session", liveReference: "a running or parked background agent of the session" }],
31
36
  fork: { carry: "not-carried", why: "a background agent works for the session that started it; a fork starts with none" },
32
37
  },
33
38
  rosterStore: {
34
- legs: [{ domain: "session-trees", step: 5, verb: "releaseAgent", selects: "every agent whose roster entry names the session as its session" }],
35
- fork: { carry: "not-carried", why: "a roster entry names the session its agent was registered for; a fork registers its own" },
39
+ legs: [{ domain: "session-trees", step: 6, verb: "releaseAgent", selects: "every agent whose roster entry names the session as its session or as its root session (the host session of the tree the agent was spawned under — the only session a plain background agent's entry names)" }],
40
+ fork: { carry: "not-carried", why: "a roster entry names the session its agent was registered for, and the root of the tree it was spawned under; a fork registers its own" },
36
41
  },
37
42
  checkpointStore: {
38
43
  legs: [
39
- { domain: "session-trees", step: 6, verb: "deleteSessionCheckpoints", selects: "the session's checkpoint rows in any status, guarded by the session row's owner (so it runs while the row exists)", liveReference: "a pending checkpoint of the session" },
44
+ { domain: "session-trees", step: 7, verb: "deleteSessionCheckpoints", unreadable: "deleteUnreadableSessionCheckpoints", selects: "the session's checkpoint rows in any status, guarded by the session row's owner (so it runs while the row exists); for a session whose head cannot be read, the same rows, admitted by that refused read", liveReference: "a pending checkpoint of the session" },
40
45
  { domain: "checkpoints", verb: "reap", selects: "the scope's pending rows whose deadline is before the call's cutoff, flipped to expired (no row is deleted)" },
41
46
  ],
42
47
  fork: { carry: "not-carried", why: "a checkpoint is a pause of the session that parked; a fork starts with none pending" },
43
48
  },
44
49
  toolResultStore: {
45
50
  legs: [
46
- { domain: "session-trees", step: 7, verb: "deleteBySession", selects: "the entries whose owner record names the session — offloaded text and the bytes a tool result kept alike" },
51
+ { domain: "session-trees", step: 8, verb: "deleteBySession", selects: "the entries whose owner record names the session — offloaded text and the bytes a tool result kept alike" },
47
52
  { domain: "orphan-tool-results", verb: "deleteUnattributable", selects: "the entries stored with no owner record, older than the call's cutoff" },
48
53
  ],
49
54
  fork: { carry: "not-carried", why: "the fork's copied log keeps the source's refs, not the entries: once the source's session-tree legs ran, the fork keeps each offloaded result's preview, never the full output" },
50
55
  },
51
56
  sessionPolicyStore: {
52
- legs: [{ domain: "session-trees", step: 8, verb: "deleteBySession", selects: "the session's permission rules" }],
57
+ legs: [
58
+ {
59
+ domain: "session-trees",
60
+ step: 9,
61
+ verb: "deleteBySession",
62
+ selects: "the session's permission rules",
63
+ keeps: "each of the session's keys' high-water mark — the largest rev the key carried and its generation, filed under the session id and principal it is keyed by, no rule (session_policy.rev_survives_delete): a later write on the key stamps above every rev it carried and starts a new generation, so a tighten-only write cannot slip under a floor a reader already enforced",
64
+ },
65
+ ],
53
66
  fork: { carry: "not-carried", why: "no seat copies a session's rules into its fork; the fork's rules start empty" },
54
67
  },
55
68
  fileHistoryStore: {
56
69
  legs: [
57
- { domain: "session-trees", step: 9, verb: "adoptScope", selects: "for each fork of the session (a session row whose forkedFrom names it), the session's history scope adopted into the fork's — `conflict` (already carried, or grown its own) counts as done, any other failure fails the leg, so the session's history is never deleted under a fork that has not received it" },
58
- { domain: "session-trees", step: 10, verb: "deleteBySession", selects: "the session's whole history scope (the scope is the session id): boundaries, version records, pristine baselines, and the blobs no other scope references" },
70
+ { domain: "session-trees", step: 10, verb: "adoptScope", selects: "for each fork of the session whose row records the source occupant it was cut from (a session row whose forkedFrom names the session, with a forkedFromIncarnation) and whose source address fileHistoryScopeOf(forkedFrom, forkedFromIncarnation) is a scope step 11 deletes, that scope adopted into the fork's own (fileHistoryScopeOf(fork id, fork incarnation)) — `conflict` (already carried, or grown its own) counts as done, any other failure fails the leg, so the session's history is never deleted under a fork that has not received it; a fork row recording no source occupant is not carried into, and nothing is carried from a session whose row fileHistoryScopeOf refuses; for a session whose head cannot be read every scope under its id is deleted, so each fork recording a source occupant is carried from the address its own row records" },
71
+ { domain: "session-trees", step: 11, verb: "deleteBySession", unreadable: "deleteUnreadableSessionHistory", selects: "the session's whole history scope, fileHistoryScopeOf(session id, the row's incarnation read by headOf) and no other (a row the function refuses has none: nothing is deleted for it): boundaries, version records, pristine baselines, and the blobs no other scope references; for a session whose head cannot be read (its incarnation cannot be read, so its address cannot be named), every scope the store holds under the session id, each read back by readFileHistoryScope — the bare id and each occupant's address, never an id the session id is a prefix of" },
59
72
  ],
60
- fork: { carry: "first-prepare", why: "the engine adopts the source's scope into the fork's on the fork's first prepare; a deletion runs that carry first (step 9), so a fork that has not prepared yet keeps its pre-fork history" },
73
+ fork: { carry: "first-prepare", why: "the engine adopts the source's scope (the address the fork row records) into the fork's on the fork's first prepare; a deletion runs that carry first (its step precedes the history's), so a fork that has not prepared yet keeps its pre-fork history" },
61
74
  },
62
75
  mailboxStore: {
63
76
  legs: [
64
- { domain: "session-trees", step: 3, verb: "drop", selects: "the box of each terminal background-agent row backgroundAgentStore.listBySession names for the session (the row's scope and handle), found through those rows while they still exist" },
65
- { domain: "session-trees", step: 11, verb: "drop", fence: "retireRecipient", selects: "the session's box (its peer session handle) in the session owner's scope; the fence is the optional retireRecipient pair's — run first, it refuses deliveries from then on, and a store without the pair (the bundled two) keeps no recipient lifecycle and has its box dropped" },
77
+ {
78
+ domain: "session-trees",
79
+ step: 4,
80
+ verb: "drop",
81
+ selects: "the box of each terminal background-agent row backgroundAgentStore.listBySession names for the session (the row's scope and handle), found through those rows while they still exist",
82
+ keeps: DROPPED_BOX_KEEPS,
83
+ },
84
+ {
85
+ domain: "session-trees",
86
+ step: 12,
87
+ verb: "drop",
88
+ fence: "retireRecipient",
89
+ selects: "the session's box (its peer session handle) in the session owner's scope; the fence is the optional retireRecipient pair's — run first, it refuses deliveries from then on, and a store without the pair (the bundled two) keeps no recipient lifecycle and has its box dropped",
90
+ keeps: DROPPED_BOX_KEEPS,
91
+ },
66
92
  ],
67
93
  fork: { carry: "not-carried", why: "a box belongs to the handle it was opened for; a fork gets its own" },
68
94
  },
95
+ taskListStore: {
96
+ legs: [{ domain: "session-trees", step: 13, verb: "drop", selects: "the whole list mounted under the session's id — every entry and its id high-water (task_list.partition_is_root_session: a delegation tree's root session; a child of a tree, or a session of a deployment that mounts one list per team, has none under its id)" }],
97
+ fork: { carry: "not-carried", why: "a list is mounted under its tree's root session; a fork is a session of its own and starts with its own list" },
98
+ },
69
99
  sessionStore: {
70
100
  legs: [
71
- { domain: "session-trees", step: 12, verb: "delete", selects: "the session's row and its whole log (a placed subagent row is its agent row's joint reap: release after a winning delete)", liveReference: "a fork of the session (a session row whose forkedFrom names it)" },
101
+ { domain: "session-trees", step: 14, verb: "delete", unreadable: "deleteUnreadable", selects: "the session's row and its whole log (a placed subagent row is its agent row's joint reap: release after a winning delete); for a session whose head cannot be read, the row and its log as that refused read finds them, placed or not", liveReference: "a fork of the session (a session row whose forkedFrom names it)" },
72
102
  { domain: "checkpoints", verb: "unpin", selects: "the session each expired checkpoint pinned" },
73
103
  ],
74
104
  fork: { carry: "at-fork", why: "the fork copies the session's log (whole, or up to the fork point) and its row cells when it is made; deleting the source leaves the copy" },
@@ -79,20 +109,70 @@ const STORE_ROWS = {
79
109
  },
80
110
  };
81
111
  const GOVERNANCE_ROWS = {
82
- "session-pollution": {
112
+ lineage: {
113
+ exempt: "the harvest lineage ledger: which sessions contributed each memory entry, one ledger per control plane, read by the sweeps that trace a memory back to its sessions",
114
+ heldBy: "memory-control-plane",
115
+ fork: { carry: "not-carried", why: "one ledger per control plane, not per session: a fork's harvests add contributions under the fork's id" },
116
+ },
117
+ challenges: {
118
+ exempt: "the challenge ledger: per memory entry, the challenge generations opened and resolved on it (an automatic one names the polluted session that raised it) — a fact about an entry that exists, read by every later retrieval of it",
119
+ heldBy: "memory-control-plane",
120
+ fork: { carry: "not-carried", why: "keyed by memory entry, not by session: a fork's pollution raises challenges of its own" },
121
+ },
122
+ settlements: {
123
+ exempt: "the delegation-settlement ledger: each delegation a session launched and how it settled — the record by which a later external settlement challenges that session's committed memory contributions, so it lasts as long as they do",
124
+ heldBy: "memory-control-plane",
125
+ fork: { carry: "not-carried", why: "a delegation is the launching session's; a fork's launches write rows of their own" },
126
+ },
127
+ "session-accounts": {
128
+ exempt: "the session-account ledger: the memory scope a session wrote, the process that held its leg, and the residue it left unattributed — an account still open marks that residue for every other session's harvest, which a deletion must not lift; a closed one keeps the scope, the process fingerprint, the times and the names of the memory files it left unattributed (no session content), and the ledger has no verb that removes it",
129
+ heldBy: "memory-control-plane",
130
+ fork: { carry: "not-carried", why: "an account is opened by the session's own materialize; a fork's opens its own" },
131
+ },
132
+ announcements: {
133
+ exempt: "the memory announcement queue: notices about a memory scope, filed under the scope and drained by the next session that mounts it, bounded per scope — the producing session, where one is named, labels the notice; the notice is about the memory",
134
+ heldBy: "memory-control-plane",
135
+ fork: { carry: "not-carried", why: "filed per scope, not per session: whichever session mounts the scope next drains it" },
136
+ },
137
+ holds: {
138
+ exempt: "the instruction-hold ledger: memory writes a harvest held until the writer's delegations settle, each naming its writer as the author lineage records on release — memory content pending, which the ledger releases or disposes",
139
+ heldBy: "memory-control-plane",
140
+ fork: { carry: "not-carried", why: "a hold is the writing session's harvest's; a fork's harvests hold their own writes" },
141
+ },
142
+ "origin-clearances": {
143
+ exempt: "the origin-clearance account: per memory entry, which host request cleared its origin marker, why and when — an audit kept beside the entry, keyed by entry, whose rows outlive even the entry's erasure (that erasure takes their custody text, not the record of who vouched)",
144
+ heldBy: "memory-control-plane",
145
+ fork: { carry: "not-carried", why: "keyed by memory entry, not by session" },
146
+ },
147
+ pollution: {
83
148
  exempt: "the pollution markers: a session's record that its content carried untrusted or injected material — a fact about content that exists, not session data",
84
149
  heldBy: "memory-control-plane",
85
150
  fork: { carry: "not-carried", why: "read for the session id it names; a fork's harvest reads the fork's own marker" },
86
151
  },
87
- "session-capture-optout": {
88
- exempt: "the capture opt-out records: a person's standing withdrawal of a session from memory capture — a fact about content that exists, not session data",
152
+ "import-receipt": {
153
+ exempt: "a bundle import's completion receipt, one per bundle hash — a fact about an import into memory, no session's",
89
154
  heldBy: "memory-control-plane",
90
- fork: { carry: "not-carried", why: "the fork reads its source's record through SessionMetadata.forkedFrom at prepare and on every harvest, so the source's standing opt-out governs the copied transcript; nothing is copied" },
155
+ fork: { carry: "not-carried", why: "keyed by bundle hash, not by session" },
91
156
  },
92
- "lineage.json": {
93
- exempt: "the harvest lineage ledger: which sessions contributed each memory entry, one ledger per control plane, read by the sweeps that trace a memory back to its sessions",
157
+ quarantine: {
158
+ exempt: "memory bytes a gate refused (or a hold's disposal moved aside), kept under the quarantine's own name — evidence about memory content, which the gate's notices and the operator read",
94
159
  heldBy: "memory-control-plane",
95
- fork: { carry: "not-carried", why: "one ledger per control plane, not per session: a fork's harvests add contributions under the fork's id" },
160
+ fork: { carry: "not-carried", why: "named by the quarantine, not by a session" },
161
+ },
162
+ hold: {
163
+ exempt: "a held memory write's captured bytes, named by its hold-ledger row — memory content pending, released into memory or moved to quarantine with that row",
164
+ heldBy: "memory-control-plane",
165
+ fork: { carry: "not-carried", why: "named by its hold, not by a session" },
166
+ },
167
+ "clearance-custody": {
168
+ exempt: "an origin clearance's custody: the cleared memory entry's full text, kept beside the account row that names it, so a clearance a crash interrupted can still be resumed — deleted by the entry's erasure, which is the memory's to run",
169
+ heldBy: "memory-control-plane",
170
+ fork: { carry: "not-carried", why: "named by its clearance, not by a session" },
171
+ },
172
+ capture: {
173
+ exempt: "the capture opt-out records: a person's standing withdrawal of a session from memory capture — a fact about content that exists, not session data",
174
+ heldBy: "memory-control-plane",
175
+ fork: { carry: "not-carried", why: "the fork reads its source's record through SessionMetadata.forkedFrom at prepare and on every harvest, so the source's standing opt-out governs the copied transcript; nothing is copied" },
96
176
  },
97
177
  };
98
178
  export const RETENTION_CASCADE = deepFreeze({ ...STORE_ROWS, ...GOVERNANCE_ROWS });
@@ -206,6 +206,12 @@ export interface ResolvedRole {
206
206
  promptRole?: HostRole;
207
207
  systemPrompt?: string;
208
208
  }
209
+ /**
210
+ * The task's requested role word — `modelRole`, `"default"` when absent — judged against the vocabulary ({@link assertKnownRole}): the
211
+ * door the chain head reads it through, and the one a resume's screen calls before its claim (the config alone decides it; no catalog,
212
+ * no role map is read). Only an absent role defaults; a `null` written there is a word the vocabulary does not hold.
213
+ */
214
+ export declare function screenModelRole(word: unknown): ModelRole;
209
215
  /**
210
216
  * The requested role's role-base statement as the task path reads it — the chain-head role over the merged maps, its
211
217
  * word and its text whole (the role-base decision's second source, `src/prompt-assembly/role-base.ts`); `undefined` ⇒
@@ -1,3 +1,4 @@
1
+ import { judgeThinkingLevel } from "../brain/reasoning.js";
1
2
  import { selectModel } from "./select-model.js";
2
3
  import { namesRoleBase } from "../prompt-assembly/role-base.js";
3
4
  import { readPromptRole } from "../prompt-assembly/select.js";
@@ -383,7 +384,7 @@ function specParts(s, seat = "a role seat") {
383
384
  return { model: s };
384
385
  }
385
386
  const cfg = s;
386
- return { model: cfg.model, select: cfg.select, thinking: cfg.thinking, promptRole: readPromptRole(`${seat}.promptRole`, cfg.promptRole), systemPrompt: cfg.systemPrompt };
387
+ return { model: cfg.model, select: cfg.select, thinking: judgeThinkingLevel(cfg.thinking, `${seat}.thinking`), promptRole: readPromptRole(`${seat}.promptRole`, cfg.promptRole), systemPrompt: cfg.systemPrompt };
387
388
  }
388
389
  export function roleSpecNamesModel(spec) {
389
390
  const parts = specParts(receiveRoleSpec(spec, "a role seat"));
@@ -506,9 +507,13 @@ export function roleFallbackChain(role) {
506
507
  function thinkingOf(explicit, role, model) {
507
508
  return explicit ?? role ?? model.defaultThinking;
508
509
  }
509
- function chainHead(spec, deps) {
510
- const start = spec.modelRole === undefined ? "default" : spec.modelRole;
510
+ export function screenModelRole(word) {
511
+ const start = word === undefined ? "default" : word;
511
512
  assertKnownRole(start, "modelRole");
513
+ return start;
514
+ }
515
+ function chainHead(spec, deps) {
516
+ const start = screenModelRole(spec.modelRole);
512
517
  const merged = mergeRoles(deps.roles, spec.roles);
513
518
  return { start, merged, startParts: specParts(merged[start], `roles.${start}`) };
514
519
  }
@@ -518,13 +523,14 @@ export function presetRoleBaseOf(spec, deps) {
518
523
  }
519
524
  export function resolveTaskModel(spec, deps) {
520
525
  const { start, merged, startParts } = chainHead(spec, deps);
526
+ const explicitThinking = judgeThinkingLevel(spec.thinking, "TaskSpec.thinking");
521
527
  const written = spec.model;
522
528
  if (written !== undefined) {
523
529
  const model = resolveModel(written, deps.models, "TaskSpec.model");
524
530
  return {
525
531
  model,
526
532
  modelRef: typeof written === "string" ? written : model,
527
- thinking: thinkingOf(spec.thinking, startParts.thinking, model),
533
+ thinking: thinkingOf(explicitThinking, startParts.thinking, model),
528
534
  promptRole: startParts.promptRole,
529
535
  systemPrompt: startParts.systemPrompt,
530
536
  };
@@ -539,7 +545,7 @@ export function resolveTaskModel(spec, deps) {
539
545
  const model = fromParts ?? roleTierModel(role, deps.models);
540
546
  if (model) {
541
547
  const modelRef = fromParts !== undefined ? (parts.model ?? model) : (ROLE_TIER_DEFAULTS[role] ?? model);
542
- return { model, modelRef, thinking: thinkingOf(spec.thinking, parts.thinking, model), promptRole: startPromptRole, systemPrompt: startSystemPrompt };
548
+ return { model, modelRef, thinking: thinkingOf(explicitThinking, parts.thinking, model), promptRole: startPromptRole, systemPrompt: startSystemPrompt };
543
549
  }
544
550
  }
545
551
  if (firstUnheld !== undefined)
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import type { ToolCallRequest } from "./tool-policy.js";
9
9
  import type { OrgGateVerdict, PersistedRuleAnswer, PersistedRuleHit } from "./hooks.js";
10
+ import { type RuleStoreFault } from "./rule-store-fault.js";
10
11
  /**
11
12
  * design/252 review r3 — read a foreign {@link OrgGateVerdict} the way the personal-rule answer is read:
12
13
  * OWN DATA properties only, never the prototype chain, never an accessor.
@@ -57,6 +58,7 @@ export declare function normalizePersistedRuleHit(hit: PersistedRuleAnswer): {
57
58
  hit?: PersistedRuleHit;
58
59
  unreadable?: true;
59
60
  reason?: string;
61
+ faults?: readonly RuleStoreFault[];
60
62
  coverage?: readonly import("./permission-rule-model.js").SegmentCoverage[];
61
63
  };
62
64
  /**
@@ -85,5 +87,6 @@ export declare function readPersistedRuleLane(lane: {
85
87
  hit?: PersistedRuleHit;
86
88
  unreadable?: true;
87
89
  reason?: string;
90
+ faults?: readonly RuleStoreFault[];
88
91
  coverage?: readonly import("./permission-rule-model.js").SegmentCoverage[];
89
92
  }>;