@sema-agent/core 7.70.0 → 7.71.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 (434) hide show
  1. package/CHANGELOG.md +728 -0
  2. package/dist/agents/agent-transcript-tool.js +43 -19
  3. package/dist/agents/inherited-tool-pool.d.ts +5 -1
  4. package/dist/agents/inherited-tool-pool.js +6 -0
  5. package/dist/agents/retain-ledger.js +2 -0
  6. package/dist/agents/send-message-tool.d.ts +12 -1
  7. package/dist/agents/send-message-tool.js +47 -9
  8. package/dist/agents/subagent.js +31 -10
  9. package/dist/agents/tool-filter.js +1 -2
  10. package/dist/agents/verify.js +13 -2
  11. package/dist/agents/yield-adoption.js +11 -1
  12. package/dist/brain/claude-model-id.d.ts +11 -0
  13. package/dist/brain/claude-model-id.js +3 -1
  14. package/dist/config/catalog.js +10 -1
  15. package/dist/config/defaults.d.ts +3 -0
  16. package/dist/config/defaults.js +1 -0
  17. package/dist/core/allow-entry.js +1 -2
  18. package/dist/core/ask-origin.d.ts +55 -21
  19. package/dist/core/ask-origin.js +19 -11
  20. package/dist/core/ask-question.d.ts +4 -7
  21. package/dist/core/ask-question.js +2 -4
  22. package/dist/core/ask-unresolvable-notice.d.ts +17 -3
  23. package/dist/core/ask-unresolvable-notice.js +18 -4
  24. package/dist/core/attachment-source.d.ts +1 -1
  25. package/dist/core/attachment-source.js +2 -0
  26. package/dist/core/auto-compaction.d.ts +14 -4
  27. package/dist/core/auto-compaction.js +3 -2
  28. package/dist/core/auto-strip.js +2 -0
  29. package/dist/core/caller-text.d.ts +2 -33
  30. package/dist/core/caller-text.js +2 -23
  31. package/dist/core/caller-tool-name.js +1 -2
  32. package/dist/core/canonical-json.d.ts +9 -0
  33. package/dist/core/canonical-json.js +6 -0
  34. package/dist/core/checkpoint-features.d.ts +43 -80
  35. package/dist/core/checkpoint-features.js +10 -20
  36. package/dist/core/checkpoint-generation.d.ts +89 -19
  37. package/dist/core/checkpoint-generation.js +89 -14
  38. package/dist/core/checkpoint-queries.d.ts +95 -15
  39. package/dist/core/checkpoint-queries.js +108 -7
  40. package/dist/core/checkpoint-rekey.d.ts +2 -1
  41. package/dist/core/checkpoint-rekey.js +2 -2
  42. package/dist/core/checkpoint-requirements.d.ts +7 -6
  43. package/dist/core/checkpoint-requirements.js +2 -5
  44. package/dist/core/checkpoint-row-verdict.d.ts +3 -4
  45. package/dist/core/checkpoint-row-verdict.js +20 -41
  46. package/dist/core/checkpoint-store.d.ts +65 -41
  47. package/dist/core/checkpoint-store.js +28 -14
  48. package/dist/core/command-sandbox.d.ts +5 -3
  49. package/dist/core/command-sandbox.js +17 -9
  50. package/dist/core/config-refusal-codes.d.ts +1 -1
  51. package/dist/core/config-refusal-codes.js +1 -0
  52. package/dist/core/declaration-words.d.ts +2 -1
  53. package/dist/core/declaration-words.js +13 -2
  54. package/dist/core/effective-path-target.d.ts +23 -0
  55. package/dist/core/effective-path-target.js +15 -1
  56. package/dist/core/engine-attestation.d.ts +5 -1
  57. package/dist/core/engine-attestation.js +1 -0
  58. package/dist/core/engine-capabilities.d.ts +14 -9
  59. package/dist/core/engine-capabilities.js +1 -1
  60. package/dist/core/engine-notice.d.ts +62 -32
  61. package/dist/core/engine-version.js +1 -1
  62. package/dist/core/entries-not-applied.d.ts +1 -1
  63. package/dist/core/entries-not-applied.js +1 -0
  64. package/dist/core/file-history-store.d.ts +95 -11
  65. package/dist/core/file-history-store.js +117 -19
  66. package/dist/core/gate-fold.js +13 -7
  67. package/dist/core/gate-lanes.js +9 -9
  68. package/dist/core/governance-codes.d.ts +56 -7
  69. package/dist/core/governance-codes.js +105 -7
  70. package/dist/core/grant-holder.d.ts +53 -0
  71. package/dist/core/grant-holder.js +80 -0
  72. package/dist/core/hooks.d.ts +7 -3
  73. package/dist/core/hooks.js +2 -2
  74. package/dist/core/locked-config.d.ts +7 -1
  75. package/dist/core/locked-config.js +9 -2
  76. package/dist/core/mcp-call-meta.d.ts +52 -7
  77. package/dist/core/mcp-call-meta.js +21 -2
  78. package/dist/core/mcp-host-read.d.ts +1 -1
  79. package/dist/core/mcp-server-spec.d.ts +18 -0
  80. package/dist/core/mcp-server-spec.js +1 -0
  81. package/dist/core/mcp.js +2 -2
  82. package/dist/core/member-outcome.d.ts +22 -1
  83. package/dist/core/member-outcome.js +18 -6
  84. package/dist/core/memory-engine/delegation-settlement.js +5 -5
  85. package/dist/core/memory-engine/engine.js +19 -19
  86. package/dist/core/memory-engine/file-backend.d.ts +7 -2
  87. package/dist/core/memory-engine/file-backend.js +14 -12
  88. package/dist/core/memory-engine/frontmatter.js +1 -1
  89. package/dist/core/memory-engine/index.d.ts +1 -0
  90. package/dist/core/memory-engine/index.js +1 -0
  91. package/dist/core/memory-engine/layout.d.ts +34 -9
  92. package/dist/core/memory-engine/layout.js +36 -19
  93. package/dist/core/memory-engine/memory-deployment.js +8 -8
  94. package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
  95. package/dist/core/memory-engine/mount-failed-notice.js +5 -2
  96. package/dist/core/mode-policy.d.ts +5 -0
  97. package/dist/core/mode-policy.js +6 -0
  98. package/dist/core/mods/host.d.ts +2 -1
  99. package/dist/core/mods/host.js +7 -6
  100. package/dist/core/mods/kernel/index.d.ts +1 -1
  101. package/dist/core/mods/kernel/index.js +1 -1
  102. package/dist/core/mods/kernel/registration.d.ts +5 -2
  103. package/dist/core/mods/kernel/registration.js +19 -3
  104. package/dist/core/mods/package.d.ts +12 -1
  105. package/dist/core/mods/package.js +36 -9
  106. package/dist/core/mods/stations.d.ts +7 -1
  107. package/dist/core/mods/stations.js +17 -3
  108. package/dist/core/mods/teammate-stations.d.ts +4 -1
  109. package/dist/core/mods/teammate-stations.js +1 -1
  110. package/dist/core/native-signal.d.ts +13 -0
  111. package/dist/core/native-signal.js +18 -0
  112. package/dist/core/park-resumability.d.ts +16 -14
  113. package/dist/core/park-resumability.js +9 -4
  114. package/dist/core/path-rule-binding.js +1 -1
  115. package/dist/core/permission-rule-model.d.ts +11 -5
  116. package/dist/core/permission-rule-model.js +5 -3
  117. package/dist/core/permission-rule-org.js +1 -1
  118. package/dist/core/permission-rule-provider.d.ts +5 -1
  119. package/dist/core/permission-rule-provider.js +6 -1
  120. package/dist/core/permission-rule-session.d.ts +35 -5
  121. package/dist/core/permission-rule-session.js +32 -1
  122. package/dist/core/permission-rule-store.d.ts +5 -1
  123. package/dist/core/permission-rule-store.js +28 -5
  124. package/dist/core/permission-rules.d.ts +2 -2
  125. package/dist/core/permission-rules.js +2 -3
  126. package/dist/core/principal-name.d.ts +12 -0
  127. package/dist/core/principal-name.js +6 -2
  128. package/dist/core/read-root-grant-screen.d.ts +7 -6
  129. package/dist/core/read-root-grant-screen.js +7 -8
  130. package/dist/core/remote-env.d.ts +42 -8
  131. package/dist/core/resume-config-judge.js +1 -1
  132. package/dist/core/resume-startup-cause.d.ts +19 -4
  133. package/dist/core/resume-startup-cause.js +25 -6
  134. package/dist/core/rewind-conversation.d.ts +4 -0
  135. package/dist/core/rewrite-rejudge.d.ts +9 -1
  136. package/dist/core/rewrite-rejudge.js +11 -1
  137. package/dist/core/rule-offer-read.js +3 -2
  138. package/dist/core/runner/assemble-result.d.ts +21 -11
  139. package/dist/core/runner/assemble-result.js +24 -4
  140. package/dist/core/runner/boundary-reminders.d.ts +104 -0
  141. package/dist/core/runner/boundary-reminders.js +108 -0
  142. package/dist/core/runner/branch-writeback.d.ts +21 -7
  143. package/dist/core/runner/branch-writeback.js +44 -6
  144. package/dist/core/runner/command-sandbox-frame.js +2 -1
  145. package/dist/core/runner/compact-session.js +11 -4
  146. package/dist/core/runner/constraint-layers.d.ts +24 -5
  147. package/dist/core/runner/constraint-layers.js +21 -2
  148. package/dist/core/runner/continuation-gate.js +3 -1
  149. package/dist/core/runner/contracts.d.ts +83 -13
  150. package/dist/core/runner/cross-boundary-lane.js +2 -1
  151. package/dist/core/runner/delegation-owner.d.ts +246 -45
  152. package/dist/core/runner/delegation-owner.js +237 -63
  153. package/dist/core/runner/expire-settle.d.ts +17 -0
  154. package/dist/core/runner/expire-settle.js +8 -2
  155. package/dist/core/runner/file-history-request.d.ts +4 -3
  156. package/dist/core/runner/file-history-request.js +4 -1
  157. package/dist/core/runner/file-history-restore.d.ts +11 -3
  158. package/dist/core/runner/file-history-restore.js +11 -3
  159. package/dist/core/runner/gate-exit.d.ts +22 -1
  160. package/dist/core/runner/gate-exit.js +12 -14
  161. package/dist/core/runner/nested-memory-content.js +1 -1
  162. package/dist/core/runner/nested-memory-lane.d.ts +10 -2
  163. package/dist/core/runner/nested-memory-lane.js +29 -8
  164. package/dist/core/runner/own-model-money-door.d.ts +13 -0
  165. package/dist/core/runner/own-model-money-door.js +17 -0
  166. package/dist/core/runner/park-commit.d.ts +4 -2
  167. package/dist/core/runner/park-commit.js +2 -1
  168. package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
  169. package/dist/core/runner/permission-rule-lanes.js +7 -0
  170. package/dist/core/runner/person-path-rows.js +1 -1
  171. package/dist/core/runner/placement-fence.d.ts +8 -2
  172. package/dist/core/runner/placement-fence.js +8 -3
  173. package/dist/core/runner/policy-throw.d.ts +3 -2
  174. package/dist/core/runner/policy-throw.js +2 -2
  175. package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
  176. package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
  177. package/dist/core/runner/prepare-artifact.d.ts +14 -1
  178. package/dist/core/runner/prepare-artifact.js +7 -2
  179. package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
  180. package/dist/core/runner/prepare-ask-lane.js +14 -5
  181. package/dist/core/runner/prepare-boundary-parks.js +5 -4
  182. package/dist/core/runner/prepare-config-doors.d.ts +9 -4
  183. package/dist/core/runner/prepare-config-doors.js +25 -8
  184. package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
  185. package/dist/core/runner/prepare-defer-classify.js +6 -6
  186. package/dist/core/runner/prepare-execution-env.d.ts +4 -1
  187. package/dist/core/runner/prepare-execution-env.js +8 -3
  188. package/dist/core/runner/prepare-file-history.d.ts +26 -0
  189. package/dist/core/runner/prepare-file-history.js +15 -1
  190. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
  191. package/dist/core/runner/prepare-inherited-gate.js +9 -2
  192. package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
  193. package/dist/core/runner/prepare-park-ask.js +8 -5
  194. package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
  195. package/dist/core/runner/prepare-policy-chain.js +18 -7
  196. package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
  197. package/dist/core/runner/prepare-prompt-assembly.js +4 -3
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
  199. package/dist/core/runner/prepare-suspend-saga.js +19 -5
  200. package/dist/core/runner/prepare-task.d.ts +2 -5
  201. package/dist/core/runner/prepare-task.js +71 -26
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -5
  203. package/dist/core/runner/prepare-workspace-restore.js +59 -28
  204. package/dist/core/runner/read-root-grant.d.ts +1 -0
  205. package/dist/core/runner/read-root-grant.js +1 -2
  206. package/dist/core/runner/resume-admission.d.ts +3 -0
  207. package/dist/core/runner/resume-admission.js +6 -4
  208. package/dist/core/runner/resume-apply.js +7 -5
  209. package/dist/core/runner/resume-claim.d.ts +2 -2
  210. package/dist/core/runner/resume-claim.js +4 -4
  211. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  212. package/dist/core/runner/resume-policy-outcome.js +6 -4
  213. package/dist/core/runner/resume-preflight.d.ts +3 -0
  214. package/dist/core/runner/resume-preflight.js +10 -3
  215. package/dist/core/runner/rewind-conversation.js +11 -4
  216. package/dist/core/runner/rewind-files.js +29 -14
  217. package/dist/core/runner/rewind-outcome.d.ts +27 -0
  218. package/dist/core/runner/rewind-outcome.js +14 -0
  219. package/dist/core/runner/run-attachment-seats.js +2 -1
  220. package/dist/core/runner/run-clock-and-content.js +2 -0
  221. package/dist/core/runner/run-identity-wiring.js +2 -0
  222. package/dist/core/runner/run-leg.js +11 -1
  223. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  224. package/dist/core/runner/run-notification-lane.js +2 -2
  225. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
  226. package/dist/core/runner/run-settle-and-teardown.js +52 -40
  227. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  228. package/dist/core/runner/run-stop-and-final-verify.js +5 -4
  229. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  230. package/dist/core/runner/run-terminal-adoption.js +3 -3
  231. package/dist/core/runner/run-turn-boundary.js +7 -0
  232. package/dist/core/runner/runtask.d.ts +7 -4
  233. package/dist/core/runner/runtask.js +18 -9
  234. package/dist/core/runner/session-call-grant-station.d.ts +64 -0
  235. package/dist/core/runner/session-call-grant-station.js +119 -0
  236. package/dist/core/runner/session-file-state-replay.js +2 -2
  237. package/dist/core/runner/session-prompt-seats.d.ts +95 -0
  238. package/dist/core/runner/session-prompt-seats.js +62 -0
  239. package/dist/core/runner/session-rule-policy.js +1 -1
  240. package/dist/core/runner/session-write-ledger.d.ts +8 -0
  241. package/dist/core/runner/session-write-ledger.js +16 -0
  242. package/dist/core/runner/side-call-account.js +5 -1
  243. package/dist/core/runner/stop-tail-notice.d.ts +7 -0
  244. package/dist/core/runner/stop-tail-notice.js +23 -8
  245. package/dist/core/runner/stream-reap.js +4 -2
  246. package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
  247. package/dist/core/runner/stream-settle-backstop.js +17 -18
  248. package/dist/core/runner/terminal-account.js +17 -8
  249. package/dist/core/runner/terminal-projection.d.ts +3 -2
  250. package/dist/core/runner/terminal-projection.js +1 -1
  251. package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
  252. package/dist/core/runner/tool-turn-repair-seat.js +12 -7
  253. package/dist/core/runner/turn-attachments.d.ts +22 -1
  254. package/dist/core/runner/turn-attachments.js +20 -3
  255. package/dist/core/runner-deps.d.ts +6 -2
  256. package/dist/core/secret-env.d.ts +26 -6
  257. package/dist/core/secret-env.js +6 -6
  258. package/dist/core/session-call-grant-screen.d.ts +58 -0
  259. package/dist/core/session-call-grant-screen.js +18 -0
  260. package/dist/core/session-call-grant.d.ts +93 -0
  261. package/dist/core/session-call-grant.js +524 -0
  262. package/dist/core/session-checkout.d.ts +3 -0
  263. package/dist/core/session-checkout.js +8 -3
  264. package/dist/core/session-policy-store.d.ts +14 -0
  265. package/dist/core/session-policy-store.js +16 -2
  266. package/dist/core/session-store.d.ts +18 -1
  267. package/dist/core/session-store.js +20 -4
  268. package/dist/core/session.d.ts +36 -4
  269. package/dist/core/shared-artifact-reads.d.ts +93 -0
  270. package/dist/core/shared-artifact-reads.js +94 -0
  271. package/dist/core/skill-grant.js +1 -1
  272. package/dist/core/skills-directory.d.ts +9 -45
  273. package/dist/core/skills-directory.js +9 -722
  274. package/dist/core/spend-account.js +3 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
  276. package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
  277. package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
  278. package/dist/core/store-contracts/file-history-store-contract.js +62 -2
  279. package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
  280. package/dist/core/store-contracts/grant-fixture.js +84 -0
  281. package/dist/core/store-contracts/session-repo-contract.js +18 -0
  282. package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
  283. package/dist/core/store-contracts/session-store-contract.js +211 -2
  284. package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
  285. package/dist/core/suspend-lane-reasons.d.ts +13 -0
  286. package/dist/core/suspend-lane-reasons.js +5 -0
  287. package/dist/core/synthetic-read-verdict.d.ts +5 -3
  288. package/dist/core/synthetic-read-verdict.js +1 -1
  289. package/dist/core/task-limits.d.ts +15 -0
  290. package/dist/core/task-notification.d.ts +33 -7
  291. package/dist/core/task-notification.js +34 -9
  292. package/dist/core/task-registry-agent.d.ts +1 -1
  293. package/dist/core/task-registry-agent.js +18 -7
  294. package/dist/core/task-registry-shared.d.ts +29 -4
  295. package/dist/core/task-registry-shared.js +7 -0
  296. package/dist/core/task-registry.d.ts +21 -1
  297. package/dist/core/task-registry.js +36 -9
  298. package/dist/core/task-result.d.ts +55 -1
  299. package/dist/core/task-spec.d.ts +17 -3
  300. package/dist/core/terminal-cause.d.ts +68 -5
  301. package/dist/core/tool-catalog-entries.js +1 -1
  302. package/dist/core/tool-check-reading.js +2 -1
  303. package/dist/core/tool-errors.js +1 -0
  304. package/dist/core/tool-list-grammar.d.ts +0 -47
  305. package/dist/core/tool-list-grammar.js +1 -75
  306. package/dist/core/tool-model-gate.d.ts +7 -11
  307. package/dist/core/tool-model-gate.js +5 -8
  308. package/dist/core/tool-name-aliases.js +2 -3
  309. package/dist/core/tool-name-readings.d.ts +4 -0
  310. package/dist/core/tool-name-readings.js +1 -0
  311. package/dist/core/tool-policy.d.ts +46 -4
  312. package/dist/core/tool-policy.js +47 -18
  313. package/dist/core/tool-result-store.d.ts +0 -24
  314. package/dist/core/tool-result-store.js +1 -36
  315. package/dist/core/tool-spec.d.ts +8 -4
  316. package/dist/core/untrusted-egress.js +2 -2
  317. package/dist/core/untrusted-text.d.ts +8 -0
  318. package/dist/core/untrusted-text.js +14 -0
  319. package/dist/core/user-attachment.d.ts +16 -1
  320. package/dist/core/user-attachment.js +42 -18
  321. package/dist/core/wiring-manifest.d.ts +4 -9
  322. package/dist/core/wiring-manifest.js +1 -1
  323. package/dist/core/workflow-journal-store.d.ts +55 -8
  324. package/dist/core/workflow-journal-store.js +34 -10
  325. package/dist/core/workflow-run-store-contract.js +56 -1
  326. package/dist/core/workflow-run-store.d.ts +43 -19
  327. package/dist/core/workflow-run-store.js +17 -2
  328. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  329. package/dist/engine/execution-env/node-execution-env.js +4 -0
  330. package/dist/engine/harness/agent-harness.d.ts +10 -5
  331. package/dist/engine/harness/agent-harness.js +12 -4
  332. package/dist/engine/harness/types.d.ts +18 -0
  333. package/dist/engine/llm/tool-turns.d.ts +1 -1
  334. package/dist/engine/llm/types.d.ts +5 -4
  335. package/dist/engine/session/memory-repo.d.ts +15 -3
  336. package/dist/engine/session/memory-repo.js +21 -3
  337. package/dist/engine/session/memory-storage.d.ts +5 -0
  338. package/dist/engine/session/memory-storage.js +8 -3
  339. package/dist/engine/session/repo-utils.d.ts +9 -0
  340. package/dist/engine/session/repo-utils.js +14 -0
  341. package/dist/engine/session/storage-base.d.ts +20 -7
  342. package/dist/engine/session/storage-base.js +13 -1
  343. package/dist/index.d.ts +37 -19
  344. package/dist/index.js +30 -15
  345. package/dist/internal/harness.d.ts +1 -1
  346. package/dist/internal/harness.js +1 -1
  347. package/dist/orchestration/run-workflow-tool.d.ts +13 -1
  348. package/dist/orchestration/run-workflow-tool.js +101 -32
  349. package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
  350. package/dist/orchestration/workflow-park-adoption.js +588 -323
  351. package/dist/orchestration/workflow-tree-id.d.ts +66 -0
  352. package/dist/orchestration/workflow-tree-id.js +66 -0
  353. package/dist/orchestration/workflow-types.d.ts +90 -11
  354. package/dist/orchestration/workflow-types.js +10 -1
  355. package/dist/orchestration/workflow.d.ts +30 -4
  356. package/dist/orchestration/workflow.js +424 -114
  357. package/dist/prompt-assembly/catalog/constitution.js +5 -1
  358. package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
  359. package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
  360. package/dist/prompt-assembly/catalog/environment.js +2 -2
  361. package/dist/prompt-assembly/catalog/events.d.ts +16 -0
  362. package/dist/prompt-assembly/catalog/events.js +2 -0
  363. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
  364. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
  365. package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
  366. package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
  367. package/dist/prompt-assembly/catalog/schema.js +2 -0
  368. package/dist/prompt-assembly/catalog/sections.js +3 -14
  369. package/dist/prompt-assembly/event-registry.js +2 -0
  370. package/dist/prompt-assembly/select.js +1 -0
  371. package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
  372. package/dist/prompt-assembly/tool-catalog.js +21 -7
  373. package/dist/prompt-assembly/types.d.ts +3 -0
  374. package/dist/prompts/default.d.ts +4 -1
  375. package/dist/prompts/default.js +6 -0
  376. package/dist/stores/file/checkpoint-store.d.ts +11 -10
  377. package/dist/stores/file/checkpoint-store.js +36 -10
  378. package/dist/stores/file/file-history-store.d.ts +6 -0
  379. package/dist/stores/file/file-history-store.js +21 -4
  380. package/dist/stores/file/fs-atomic.d.ts +1 -1
  381. package/dist/stores/file/index.d.ts +14 -4
  382. package/dist/stores/file/index.js +21 -5
  383. package/dist/stores/file/process-anchor.d.ts +9 -1
  384. package/dist/stores/file/session-policy-store.js +2 -17
  385. package/dist/stores/file/session-store.d.ts +27 -0
  386. package/dist/stores/file/session-store.js +81 -9
  387. package/dist/stores/file/workflow-journal-store.d.ts +14 -4
  388. package/dist/stores/file/workflow-journal-store.js +32 -24
  389. package/dist/stores/file/workflow-run-store.d.ts +15 -4
  390. package/dist/stores/file/workflow-run-store.js +76 -0
  391. package/dist/tools/artifact/artifact-tool.d.ts +10 -3
  392. package/dist/tools/artifact/artifact-tool.js +16 -1
  393. package/dist/tools/fs/bash-program-position.d.ts +10 -4
  394. package/dist/tools/fs/bash-program-position.js +11 -8
  395. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
  396. package/dist/tools/fs/bash-readonly-classifier.js +9 -2
  397. package/dist/tools/fs/find-actions.d.ts +30 -16
  398. package/dist/tools/fs/find-actions.js +272 -19
  399. package/dist/tools/fs/fs-bash.js +8 -5
  400. package/dist/tools/fs/fs-shared.d.ts +0 -29
  401. package/dist/tools/fs/fs-shared.js +0 -5
  402. package/dist/tools/fs/fs-write.js +2 -1
  403. package/dist/tools/fs/read-deny.d.ts +6 -1
  404. package/dist/tools/fs/read-deny.js +6 -1
  405. package/dist/tools/fs/read-floor.d.ts +6 -0
  406. package/dist/tools/fs/read-floor.js +5 -1
  407. package/dist/tools/fs/removal-actions.d.ts +43 -0
  408. package/dist/tools/fs/removal-actions.js +25 -0
  409. package/dist/tools/fs/removal-targets.d.ts +2 -21
  410. package/dist/tools/fs/removal-targets.js +2 -3
  411. package/dist/tools/fs/safety.d.ts +37 -1
  412. package/dist/tools/fs/safety.js +52 -0
  413. package/dist/tools/fs/shell-climb.d.ts +46 -0
  414. package/dist/tools/fs/shell-climb.js +79 -0
  415. package/dist/tools/fs/shell-read-check.js +47 -19
  416. package/dist/tools/fs/shell-read-establish.js +36 -22
  417. package/dist/tools/fs/shell-read-judge.d.ts +10 -2
  418. package/dist/tools/fs/shell-read-judge.js +4 -4
  419. package/dist/tools/fs/shell-read-plan.d.ts +3 -0
  420. package/dist/tools/fs/shell-read-plan.js +1 -1
  421. package/dist/tools/fs/shell-read-workdir.js +3 -2
  422. package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
  423. package/dist/tools/fs/shell-read-write-targets.js +3 -0
  424. package/package.json +2 -2
  425. package/test/export-surface.snapshot.json +169 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core@7.71.0.json +5827 -0
  428. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  429. package/wire-changes/primitives@7.71.0.json +473 -0
  430. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  431. package/dist/core/frontmatter-fence.d.ts +0 -10
  432. package/dist/core/frontmatter-fence.js +0 -6
  433. package/dist/core/permission-rule-syntax.d.ts +0 -46
  434. package/dist/core/permission-rule-syntax.js +0 -52
@@ -4,23 +4,22 @@ import { isSyntheticApiErrorMessage } from "../../internal/harness.js";
4
4
  import { derivedRouteFallsBack } from "./derived-route-fallback.js";
5
5
  import { isDegenerateCutMessage } from "../../brain/terminal-cause.js";
6
6
  import { hasBackgroundShell, sweepRunBoundaryBackgroundShells } from "../background-shell.js";
7
- import { resolveCheckpointStore } from "../checkpoint-store.js";
8
- import { compensateUnstarted, reopenReasonOf, resumeAgainMayCure, unstartedFailureOf, unstartedRowSentence } from "../resume-startup-cause.js";
7
+ import { compensateUnstarted, reopenReasonOf, resumeAgainMayCure, rowKeepsWhatItsRetryNeeds, unstartedFailureOf, unstartedRowSentence } from "../resume-startup-cause.js";
9
8
  import { classicEventBase, legNoticeTaskId, observeClassic } from "../mods/stations.js";
10
9
  import { raiseCompletedTurn, raiseSessionEnd } from "../mods/lifecycle-stations.js";
11
10
  import { priceTableOf } from "../pricing.js";
12
11
  import { hasDestroy, isIsolated } from "../remote-env.js";
13
12
  import { resolveTaskModel } from "../roles.js";
14
- import { defaultTaskRegistry } from "../task-registry.js";
13
+ import { abortBackgroundAgentsAtRunEnd, defaultTaskRegistry } from "../task-registry.js";
15
14
  import { emitTrace } from "../trace.js";
16
15
  import { deliverEngineNotice, parentLegIds, settleOwedUserInput } from "../types.js";
17
16
  import { assembleResult } from "./assemble-result.js";
18
- import { discloseUnconsumedEndings } from "./halt-attribution.js";
17
+ import { discloseUnconsumedEndings, haltConsumed } from "./halt-attribution.js";
19
18
  import { forwardSafely } from "./forward-sink.js";
20
19
  import { completedPastLimitNotice, limitCrossedOf, TIMER_LATENESS_REPORT_MS } from "./clock-and-limits.js";
21
20
  import { verdictRefusedNotice } from "./verdict-refusal.js";
22
- import { interruptUnconsumedNotice, stopTailWaitedFor } from "./stop-tail-notice.js";
23
- import { oneShotEndingBook } from "../task-notification.js";
21
+ import { interruptUnconsumedNotice, stopTailWaitedFor, waitCeilingReachedNotice } from "./stop-tail-notice.js";
22
+ import { oneShotEndingBook, oneShotWaitCeilingOf } from "../task-notification.js";
24
23
  import { resumeDecisionWasNegative } from "./decide-continuation.js";
25
24
  import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
26
25
  import { generatePromptSuggestions } from "./prompt-suggestions.js";
@@ -37,6 +36,7 @@ import { projectRequestCopies } from "../request-copy-projection.js";
37
36
  export async function runSettleAndTeardown(input) {
38
37
  const { spec, queue, prepared, resume, internals, rs, stats, ident, loopLatch, timeout, ownCommittedTailRef, legWrites, emitDelegationLifecycle, taskIdRef, manualCompactRef, drainManualCompact, final, threw, abortedLive, userInterruptedLive, answerSettled, strandedHumanAnswers, reasoningResolution, deliveryObligations, compactionBreaker, owedUserInput, setResult, onSuggestions, onSuspend, runner, sessions, display } = input;
39
38
  const bound = settleBound(), writeOwedSessionRecords = legEndRecords(prepared, rs, runner, bound);
39
+ let rowAnswer;
40
40
  try {
41
41
  const shown = display?.settled();
42
42
  if (shown !== undefined)
@@ -91,6 +91,7 @@ export async function runSettleAndTeardown(input) {
91
91
  model: prepared.model.id,
92
92
  unpricedSpend: rs.telemetry.unpricedSpend,
93
93
  rewindNotes: prepared.rewindNotes,
94
+ ...(prepared.rewindOutcome !== undefined ? { rewindOutcome: prepared.rewindOutcome } : {}),
94
95
  editedFiles: prepared.editedFilesSnapshot(),
95
96
  haltedOnUserRejection: prepared.batchHaltRef.current !== undefined,
96
97
  haltConsumption: prepared.harness.haltConsumption(),
@@ -100,12 +101,8 @@ export async function runSettleAndTeardown(input) {
100
101
  strandedHumanAnswers,
101
102
  refusedAsks: prepared.refusedAsks, refusalRecords: prepared.verdictLedger.recordsOf, verdictLastEndRefused: prepared.verdictLedger.lastEndRefused(),
102
103
  remoteEnvFailures: prepared.remoteEnvFailures,
103
- effectiveReadFace: prepared.effectiveReadFace,
104
- effectiveWriteFace: prepared.effectiveWriteFace,
105
- effectiveReadDenyPatterns: prepared.effectiveReadDenyPatterns,
104
+ posture: prepared,
106
105
  readDenyFloorUnkept: prepared.readFloorUnkept.current,
107
- effectiveAgentConfigDirs: prepared.callerPlaces?.configRoots.carried,
108
- effectiveAgentHomeDirs: prepared.callerPlaces?.homes.carried,
109
106
  effectiveMemoryScopes: prepared.effectiveMemoryScopes,
110
107
  placementRoot: prepared.placementRoot,
111
108
  effectiveReasoning: reasoningResolution.current,
@@ -122,16 +119,24 @@ export async function runSettleAndTeardown(input) {
122
119
  budgetAxis: rs.limits.budgetAxis,
123
120
  blockedReason: prepared.blockedRef.reason,
124
121
  blockedDetail: prepared.blockedRef.detail,
125
- conflict: prepared.conflictRef.hit,
122
+ writeRefusal: prepared.writeRefusal.word,
126
123
  coreOverBudget: prepared.requestCoreRef.terminalCode === "irreducible_core_over_budget",
127
124
  outputInvalid: rs.degrade.outputInvalid,
128
125
  loopTerminal: prepared.loopTerminalRef.reason,
129
126
  suspendLoop: prepared.suspendLoopRef.hit,
130
127
  ...(prepared.pausedRef.current !== undefined ? { paused: prepared.pausedRef.current.cause } : {}),
131
128
  });
129
+ const endingBook = oneShotEndingBook(spec.oneShot, deliveryObligations);
130
+ const waitStoppedAtCeiling = endingBook?.stoppedWaitingAtCeiling === true;
131
+ const endingReach = { read: { ...prepared.registryAccess, sessionId: prepared.sessionId }, owner: prepared.registryAccess };
132
+ if (waitStoppedAtCeiling) {
133
+ const leftOwed = stopTailWaitedFor(endingBook, endingReach);
134
+ if (leftOwed.length > 0)
135
+ deliverEngineNotice(runner.deps.onNotice, waitCeilingReachedNotice(leftOwed, oneShotWaitCeilingOf(spec.limits), { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }));
136
+ }
132
137
  if (abortedLive && answerSettled && result.terminal.kind === "completed") {
133
- const origin = userInterruptedLive ? "interrupt" : timeout.fired ? "walltime" : rs.limits.turnsExceeded ? "turns" : rs.limits.budgetHit !== undefined ? "budget" : "signal";
134
- const waitedFor = stopTailWaitedFor(oneShotEndingBook(spec.oneShot, deliveryObligations), { read: { ...prepared.registryAccess, sessionId: prepared.sessionId }, owner: prepared.registryAccess });
138
+ const origin = runEndCauseOf({ ceiling: false, abortedLive, userInterrupted: userInterruptedLive, userHalted: false, walltime: timeout.fired, turns: rs.limits.turnsExceeded, spendStopped: rs.limits.budgetHit !== undefined });
139
+ const waitedFor = stopTailWaitedFor(waitStoppedAtCeiling ? undefined : endingBook, endingReach);
135
140
  deliverEngineNotice(runner.deps.onNotice, interruptUnconsumedNotice(waitedFor, origin, { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }));
136
141
  }
137
142
  if (result.limitCrossed !== undefined && result.terminal.kind === "completed")
@@ -147,6 +152,7 @@ export async function runSettleAndTeardown(input) {
147
152
  !(resumeDecisionWasNegative(resume) && resume.decisionDelivered === true)) {
148
153
  const failure = result.terminal.kind === "failed" ? unstartedFailureOf(result.terminal.code, result.terminal.detail, sessions) : unstartedFailureOf(undefined, undefined, sessions);
149
154
  const row = await compensateUnstarted(resume.reopenUnstarted, reopenReasonOf(failure.cause), resume.claimedRowPending);
155
+ rowAnswer = row.kind;
150
156
  rowReturned = row.kind === "reopened";
151
157
  amendTerminal(result, rowReturned ? "resume.reopened_unstarted" : "resume.reopen_failed_unstarted", row.kind, (m) => `${m ?? "the resume leg did not complete"} — ${unstartedRowSentence(row, resume.cp, failure)}`, resumeAgainMayCure(failure.cause));
152
158
  }
@@ -204,21 +210,20 @@ export async function runSettleAndTeardown(input) {
204
210
  result.degraded = rs.degrade.degraded;
205
211
  if (prepared.outputRef.set)
206
212
  result.structuredOutput = prepared.outputRef.value;
207
- const committedToken = prepared.pausedRef.current?.cause.token;
208
- const committedScope = prepared.pausedRef.current?.scope;
209
- if (committedToken !== undefined) {
210
- const store = resolveCheckpointStore(spec, runner.deps);
211
- if (store && committedScope !== undefined) {
212
- onSuspend({
213
- env: prepared.ownedEnv,
214
- token: committedToken,
215
- scope: committedScope,
216
- store,
217
- sessionId: prepared.sessionId,
218
- });
219
- }
213
+ const committed = prepared.pausedRef.current;
214
+ const committedToken = committed?.cause.token;
215
+ if (committed !== undefined) {
216
+ const { store, holder } = committed.writes;
217
+ onSuspend({
218
+ env: prepared.ownedEnv,
219
+ token: committed.cause.token,
220
+ scope: committed.scope,
221
+ store,
222
+ ...(holder !== undefined ? { holder } : {}),
223
+ sessionId: prepared.sessionId,
224
+ });
220
225
  }
221
- if (resume && committedToken === undefined) {
226
+ if (resume && committedToken === undefined && !rowKeepsWhatItsRetryNeeds(rowAnswer)) {
222
227
  await settleTeardownLeg(() => sessions.unpin?.(resume.cp.sessionId), "sessions.unpin (resumed-terminal leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
223
228
  }
224
229
  if (prepared.memoryEngineSession) {
@@ -265,7 +270,7 @@ export async function runSettleAndTeardown(input) {
265
270
  sessionId: prepared.sessionId,
266
271
  report: (e) => runner.deps.onError?.(e, { phase: "degraded", sessionId: prepared.sessionId }),
267
272
  });
268
- setResult(result);
273
+ setResult(result, rowAnswer);
269
274
  if (emitsChildRowFrames(prepared.hookIdentity) && result.terminal.kind !== "paused") {
270
275
  const terminalTick = {
271
276
  type: "task_progress",
@@ -300,10 +305,11 @@ export async function runSettleAndTeardown(input) {
300
305
  finally {
301
306
  settleOwedUserInput(owedUserInput, !prepared.suspendProgressRef.executedApproved, { taskId: prepared.taskId, sessionId: prepared.sessionId, runId: prepared.runId, parent: parentLegIds(internals) }, runner.deps.onNotice);
302
307
  await writeOwedSessionRecords();
303
- const ownedEnvDying = prepared.ownedEnv !== undefined &&
304
- hasDestroy(prepared.ownedEnv) &&
305
- isIsolated(prepared.ownedEnv) &&
306
- prepared.pausedRef.current === undefined;
308
+ const runEnd = prepared.pausedRef.current !== undefined
309
+ ? undefined
310
+ : runEndCauseOf({ ceiling: oneShotEndingBook(spec.oneShot, deliveryObligations)?.stoppedWaitingAtCeiling === true, abortedLive, userInterrupted: userInterruptedLive, userHalted: haltConsumed(prepared.harness.haltConsumption()), walltime: timeout.fired, turns: rs.limits.turnsExceeded, spendStopped: rs.limits.budgetHit !== undefined });
311
+ const envGoing = envDestroyedAtTeardown(prepared, resume?.cp.state.workspaceHandle !== undefined && rowKeepsWhatItsRetryNeeds(rowAnswer));
312
+ const ownedEnvDying = envGoing !== undefined && isIsolated(envGoing);
307
313
  await settleTeardownLeg(() => defaultTaskRegistry.settleKilledForOwner({ ...prepared.registryAccess, sessionId: prepared.sessionId }, {
308
314
  source: abortedLive &&
309
315
  !answerSettled &&
@@ -327,13 +333,13 @@ export async function runSettleAndTeardown(input) {
327
333
  }
328
334
  }
329
335
  defaultTaskRegistry.clearBackgroundForOwner(prepared.registryAccess);
330
- defaultTaskRegistry.abortBackgroundAgentsForOwner(prepared.registryAccess, { skipSessionScoped: true });
336
+ abortBackgroundAgentsAtRunEnd(defaultTaskRegistry, prepared.registryAccess, { skipSessionScoped: true }, runEnd);
331
337
  prepared.spend.close();
332
338
  if (prepared.subagentRetain) {
333
339
  await settleTeardownLeg(() => prepared.subagentRetain.disposeAll("parent_run_ended"), "subagentRetain.disposeAll", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
334
340
  }
335
341
  const envBound = settleBound();
336
- const destroying = envDestroyedAtTeardown(prepared) !== undefined;
342
+ const destroying = envGoing !== undefined;
337
343
  if (prepared.workspaceSync !== undefined && prepared.pausedRef.current === undefined) {
338
344
  try {
339
345
  await prepared.workspaceSync.legEnded(destroying, envBound(destroying ? 2 : 1));
@@ -342,7 +348,7 @@ export async function runSettleAndTeardown(input) {
342
348
  runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId });
343
349
  }
344
350
  }
345
- await settleTeardownLeg(() => teardownOwnedEnv(prepared, runner), "teardownOwnedEnv", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }), envBound(1));
351
+ await settleTeardownLeg(() => teardownOwnedEnv(envGoing, prepared, runner), "teardownOwnedEnv", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }), envBound(1));
346
352
  }
347
353
  return {};
348
354
  }
@@ -454,8 +460,7 @@ async function suggestNextPrompts(spec, prepared, result, runner, telemetry) {
454
460
  clearTimeout(timer);
455
461
  }
456
462
  }
457
- async function teardownOwnedEnv(prepared, runner) {
458
- const env = envDestroyedAtTeardown(prepared);
463
+ async function teardownOwnedEnv(env, prepared, runner) {
459
464
  if (env !== undefined) {
460
465
  try {
461
466
  await env.destroy();
@@ -465,7 +470,14 @@ async function teardownOwnedEnv(prepared, runner) {
465
470
  }
466
471
  }
467
472
  }
468
- function envDestroyedAtTeardown(prepared) {
473
+ function runEndCauseOf(f) {
474
+ if (f.ceiling)
475
+ return "one_shot_ceiling";
476
+ if (!f.abortedLive)
477
+ return f.userHalted ? "interrupt" : "turn_end";
478
+ return f.userInterrupted ? "interrupt" : f.walltime ? "walltime" : f.turns ? "turns" : f.spendStopped ? "budget" : "signal";
479
+ }
480
+ function envDestroyedAtTeardown(prepared, keptForRow) {
469
481
  const env = prepared.ownedEnv;
470
- return env !== undefined && hasDestroy(env) && prepared.pausedRef.current === undefined ? env : undefined;
482
+ return env !== undefined && hasDestroy(env) && prepared.pausedRef.current === undefined && !keptForRow ? env : undefined;
471
483
  }
@@ -3,6 +3,7 @@ import { type DeliveryObligations } from "../task-notification.js";
3
3
  import type { TaskEvent, TaskSpec } from "../types.js";
4
4
  import type { Stats } from "./assemble-result.js";
5
5
  import type { InstallingPhaseResult, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
6
+ import type { CallerStopGate } from "./caller-stop-gate.js";
6
7
  /** A final-verification frame: the mark, then the message in the run's reading, inside the engine's marked shell (no
7
8
  * newline after the open tag — the counter's probe reads the open tag and the mark as one run). */
8
9
  export declare function finalVerificationFrame(which: "nudge" | "reentry", prepared: Pick<Prepared, "reminderMark" | "engineText">): string;
@@ -30,6 +31,9 @@ export interface RunStopAndFinalVerifyInput {
30
31
  /** borrowed-readonly — the terminal frames this leg's lane is still owed (the notification lane's book): a one-shot
31
32
  * submission's ending waits on it. */
32
33
  deliveryObligations: DeliveryObligations;
34
+ /** borrowed-readonly — the run's caller-stop gate the three stop verbs trip: a halt that arrives while the one-shot ending waits
35
+ * (no turn is in flight for it to cut) ends the wait, as an interrupt's abort does. */
36
+ callerStop: CallerStopGate;
33
37
  /** borrowed-readonly — the Runner's deployment deps, read LIVE (`hooks` at resolution, `onError` in the gate). */
34
38
  runner: RunnerDepsSeat;
35
39
  }
@@ -7,7 +7,7 @@ import { judgeStopFamily, stopFamilyBlockText, stopFamilyContextText, stopFamily
7
7
  import { heldInProgress } from "../../tools/task-list.js";
8
8
  import { steeringPreview } from "./steering-preview.js";
9
9
  import { taskAxisCrossed } from "./clock-and-limits.js";
10
- import { oneShotEndingBook } from "../task-notification.js";
10
+ import { oneShotEndingBook, oneShotWaitCeilingOf } from "../task-notification.js";
11
11
  import { FINAL_VERIFICATION_MARK } from "./clock-and-limits.js";
12
12
  export function finalVerificationFrame(which, prepared) {
13
13
  const body = prepared.engineText(which === "nudge" ? "core/event.final-verification" : "core/event.final-verification.reentry");
@@ -15,7 +15,7 @@ export function finalVerificationFrame(which, prepared) {
15
15
  }
16
16
  const STOP_HOOK_BLOCK_CAP = 8;
17
17
  export function runStopAndFinalVerify(input) {
18
- const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, runner } = input;
18
+ const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, callerStop, runner } = input;
19
19
  const stopEvent = legEventsOf(prepared.hookIdentity).stop;
20
20
  const stopArmed = prepared.modBus.hasHandlers(stopEvent);
21
21
  const teammateArmed = prepared.hookIdentity.isDelegatedChild && prepared.hookIdentity.spawnName !== undefined && (prepared.modBus.hasHandlers("classic.TaskCompleted") || prepared.modBus.hasHandlers("classic.TeammateIdle"));
@@ -45,8 +45,9 @@ export function runStopAndFinalVerify(input) {
45
45
  if (ending())
46
46
  return [];
47
47
  const pushedBack = stopArmed || teammateArmed || finalVerificationOn ? await pushBack() : [];
48
- if (pushedBack.length === 0)
49
- await owed?.waitOut(prepared.abortController.signal, () => !ending() && prepared.harness.pendingInjectionCount() === 0, (wake) => prepared.harness.subscribe((e) => void (e.type === "queue_update" && wake())));
48
+ const waitEnd = pushedBack.length === 0 ? await owed?.waitOut(AbortSignal.any([prepared.abortController.signal, callerStop.signal]), () => !ending() && prepared.harness.pendingInjectionCount() === 0, (wake) => prepared.harness.subscribe((e) => void (e.type === "queue_update" && wake())), oneShotWaitCeilingOf(spec.limits)) : undefined;
49
+ if (waitEnd === "signal")
50
+ prepared.harness.consumeStopAtEnding();
50
51
  return pushedBack;
51
52
  });
52
53
  async function pushBack() {
@@ -61,7 +61,7 @@ export interface RunTerminalAdoptionInput<R> {
61
61
  abortedLive: boolean;
62
62
  /** borrowed-readonly — the leg's snapshot of `loopLatch.userInterrupted` (gates the interruption marker). */
63
63
  userInterruptedLive: boolean;
64
- /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`, `checkpointStore`, `onNotice`, `mediaBudgetBase64Chars`); the one home of why it is
64
+ /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`, `onNotice`, `mediaBudgetBase64Chars`); the one home of why it is
65
65
  * a seat and not a captured object is {@link RunnerDepsSeat}. */
66
66
  runner: RunnerDepsSeat;
67
67
  /** borrowed-readonly — the session store: `finish`'s teardown legs touch the leg's session through it. */
@@ -90,10 +90,10 @@ export async function runTerminalAdoption(input) {
90
90
  const carriedContinuationInputIds = [];
91
91
  let carriedApproval = 0;
92
92
  let approvalRefusal;
93
- if (committedPause !== undefined && runner.deps.checkpointStore !== undefined) {
93
+ if (committedPause !== undefined) {
94
94
  const parkToken = committedPause.cause.token;
95
95
  const parkScope = committedPause.scope;
96
- const store = runner.deps.checkpointStore;
96
+ const { store, holder } = committedPause.writes;
97
97
  const carried = [];
98
98
  const owed = [
99
99
  ...prepared.undeliveredContinuationRef.current.parkedSteers.map((frame) => {
@@ -104,7 +104,7 @@ export async function runTerminalAdoption(input) {
104
104
  ];
105
105
  for (const { input, live, approval } of owed) {
106
106
  try {
107
- if (!(await raceTeardownLeg(() => store.setPendingSteer(parkToken, parkScope, input), "checkpointStore.setPendingSteer (parked-input migration leg)")))
107
+ if (!(await raceTeardownLeg(() => (holder !== undefined ? store.setPendingSteer(parkToken, parkScope, input, { holder }) : store.setPendingSteer(parkToken, parkScope, input)), "checkpointStore.setPendingSteer (parked-input migration leg)")))
108
108
  break;
109
109
  if (live !== undefined)
110
110
  carried.push(live);
@@ -9,6 +9,7 @@ import { answerSettled } from "./assemble-result.js";
9
9
  import { composeBundle } from "../attachment-source.js";
10
10
  import { instructionEchoTo } from "./nested-memory-lane.js";
11
11
  import { ATTACHMENT_BYTE_CAP, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, changedFilesNoticeIn, clipToBytes, collectDateChange, collectDueAttachments, commitAgentListing, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame, renderMcpInstructionsDelta, selectMcpDroppedBatch, renderSkillsListingFrame } from "./turn-attachments.js";
12
+ import { boundaryReminderInputs } from "./boundary-reminders.js";
12
13
  import { announceWhenCarried, scanChangedFiles } from "./changed-files-scan.js";
13
14
  import { announceListingTruncation } from "../skill-listing-budget.js";
14
15
  import { buildWorkingFileAttachments, centerAdoptionOption, emitInputTruncated, forkContextOption, legCompactionSettings, legContextOverlayOption } from "./compaction-call-options.js";
@@ -309,6 +310,8 @@ export function createTurnBoundary(input) {
309
310
  const offeredListing = !agentListingOwed ? undefined : seatHears({ bus: prepared.modBus }, "agent.offer") ? await offeredAgentListing({ bus: prepared.modBus }, prepared.agentListing, prepared.abortController.signal) : prepared.agentListing;
310
311
  const skillsListingDue = rs.attach.skillsListingOn && prepared.skillsListing !== undefined && !frameCarried(prepared.frameReceipts, "skills_listing");
311
312
  const listingBudget = prepared.skillsListing?.budget ?? prepared.agentListing?.budget;
313
+ const reminderLane = prepared.runTimeReminders.lane;
314
+ const { silentTurn, elapsedMs } = await boundaryReminderInputs({ ...prepared.runTimeReminders, carried, rows: async () => (await prepared.session.buildContext()).messages });
312
315
  due.push(...collectDueAttachments(rs.attach.attachState, {
313
316
  engineText: prepared.engineText,
314
317
  turn: stats.turns,
@@ -325,6 +328,8 @@ export function createTurnBoundary(input) {
325
328
  ...(rs.attach.attachmentsCfg?.totalTokensReminderMode !== undefined
326
329
  ? { totalTokensReminderMode: rs.attach.attachmentsCfg.totalTokensReminderMode }
327
330
  : {}),
331
+ silentTurnReminder: reminderLane.silentTurn,
332
+ elapsedTimeReminder: elapsedMs !== undefined,
328
333
  backgroundTasks: backgroundTasksOn,
329
334
  toolsDelta: toolsDeltaOn,
330
335
  agentListing: rs.attach.agentListingOn,
@@ -332,6 +337,8 @@ export function createTurnBoundary(input) {
332
337
  mcpInstructions: mcpInstructionsOn,
333
338
  },
334
339
  ...(prepared.outputStyleFrame !== undefined && !frameCarried(prepared.frameReceipts, "output_style") ? { outputStyle: prepared.outputStyleFrame } : {}),
340
+ ...(silentTurn !== undefined ? { silentTurn } : {}),
341
+ ...(elapsedMs !== undefined ? { elapsedMs } : {}),
335
342
  ...(undiscoveredTools !== undefined && undiscoveredTools.length > 0
336
343
  ? { undiscoveredTools, deferDirectCall: prepared.deferDirectCall }
337
344
  : {}),
@@ -38,6 +38,8 @@ export declare class Runner implements RunnerSelfSeat {
38
38
  private readonly sessionModeSeats;
39
39
  /** What each session learned about fast mode in this process (cooldown, refusals, the latched beta) — see {@link SessionFastModeSeats}. */
40
40
  private readonly sessionFastModeSeats;
41
+ /** What each session's prompt holds in this process (the elapsed-time clock) — see {@link SessionPromptSeats}. */
42
+ private readonly sessionPromptSeats;
41
43
  /** The MCP pools of the process's session trees — one table every Runner reads: one pool per tree root's address, remembering a failed connection attempt ({@link processSessionMcpPools}). */
42
44
  private readonly sessionMcpPools;
43
45
  /** This Runner's view of the session route (frames parked between legs, the live lanes a frame is routed to): the state is the table of {@link sessions} ×
@@ -59,10 +61,11 @@ export declare class Runner implements RunnerSelfSeat {
59
61
  * "only the expire WINNER destroys the paused env", and the terminal resume-preflight arm
60
62
  * (resumeStream) can now BE that winner — without this registry the losing stream-side
61
63
  * reapSuspended returned early and the paused env this process holds leaked forever. Registered
62
- * when a suspend publishes its reap handle; retired when the stream's own reap runs, when a
63
- * resume wins the resolve CAS (the restore path owns the env from there — a later reopen keeps
64
- * the ORIGINAL stream's closure as the reaping owner, deliberately), and when the terminal arm
65
- * wins. Bounded by live suspended streams (the closures hold the same handles). */
64
+ * when a suspend publishes its reap handle; retired when the stream's own reap runs, when the
65
+ * resumed leg settles and its row is not coming back (a row its compensation brought back, or
66
+ * may have, keeps it — the ORIGINAL stream's closure stays the reaping owner, deliberately; the
67
+ * leg's other resources read the same answer), and when the terminal arm wins. Bounded by live
68
+ * suspended streams (the closures hold the same handles). */
66
69
  private readonly suspendedEnvReaps;
67
70
  /** SAME-RUNNER claims for {@link suspendedEnvReaps}, one PER ATTEMPT: a token is held from the moment an
68
71
  * in-process actor ATTEMPTS its settling CAS (the terminal preflight's or the void verb's expire; a resume's
@@ -21,13 +21,14 @@ import { announceReadDenySwap, catalogGenerationOf, noteCatalogSwap, screenSwapp
21
21
  import { runSideQueryAsking } from "../side-query.js";
22
22
  import { PushQueue } from "../push-queue.js";
23
23
  import { TtlSessionStore } from "../session-store.js";
24
- import { claimedRowPendingOf, compensateUnstarted, unstartedRowSentence } from "../resume-startup-cause.js";
24
+ import { claimedRowPendingOf, compensateUnstarted, rowKeepsWhatItsRetryNeeds, unstartedRowSentence } from "../resume-startup-cause.js";
25
25
  import { parkNounOf, resumeCancelledSentence } from "../park-noun.js";
26
26
  import { prepareTask } from "./prepare-task.js";
27
27
  import { effectiveDelegationFacts } from "./task-start-doors.js";
28
28
  import { SessionReadFileStates } from "./session-read-file-states.js";
29
29
  import { SessionModeSeats } from "./session-mode-seats.js";
30
30
  import { SessionFastModeSeats } from "./fast-mode-seat.js";
31
+ import { SessionPromptSeats } from "./session-prompt-seats.js";
31
32
  import { forgetSessionMcpFailure, processSessionMcpPools } from "../mcp-connection-pool.js";
32
33
  import { RunnerSharedToolResultStore } from "../tool-result-store.js";
33
34
  import { PAUSE_REGISTRY } from "../pause-registry.js";
@@ -45,6 +46,7 @@ import { answerFaceForRedeemedCall } from "./decide-continuation.js";
45
46
  import { createTurnBoundary } from "./run-turn-boundary.js";
46
47
  import { createHarnessHandlers } from "./run-harness-handlers.js";
47
48
  import { resumeAdmission } from "./resume-admission.js";
49
+ import { revivalRootPolicyUnrestatedNotice } from "./constraint-layers.js";
48
50
  import { resumeReviewOutcome } from "./resume-review-outcome.js";
49
51
  import { resumePolicyOutcome } from "./resume-policy-outcome.js";
50
52
  import { resumeCheckpointScreen } from "./resume-checkpoint-screen.js";
@@ -86,6 +88,7 @@ import { runRecoveryLanes } from "./run-recovery-lanes.js";
86
88
  import { runGitLane } from "./run-git-lane.js";
87
89
  import { deploymentCanRerootChild } from "./child-tree.js";
88
90
  import { rewindSessionFiles } from "./rewind-files.js";
91
+ import { rewindOutcomeOf } from "./rewind-outcome.js";
89
92
  import { readSessionChanges } from "./read-session-changes.js";
90
93
  import { compactIdleSession } from "./compact-session.js";
91
94
  import { rewindSessionConversation } from "./rewind-conversation.js";
@@ -107,6 +110,7 @@ export class Runner {
107
110
  sessionReadStates = new SessionReadFileStates();
108
111
  sessionModeSeats = new SessionModeSeats();
109
112
  sessionFastModeSeats = new SessionFastModeSeats();
113
+ sessionPromptSeats = new SessionPromptSeats();
110
114
  sessionMcpPools = processSessionMcpPools();
111
115
  pendingSessionNotifications;
112
116
  parentConstraintRegistry = new Map();
@@ -336,7 +340,8 @@ export class Runner {
336
340
  w.resolve(outcome);
337
341
  };
338
342
  const runStartedAt = Date.now();
339
- const taskIdRef = { current: legTaskIdOf(spec, restoreRowTaskId(internals, resume?.cp.state.rowTaskId), undefined), sessionId: spec.sessionId, intake: { committed: false }, ...(judgedOwnerSeat(spec, internals) !== undefined ? { rowVerified: false } : {}) };
343
+ const rewind = rewindOutcomeOf(spec);
344
+ const taskIdRef = { current: legTaskIdOf(spec, restoreRowTaskId(internals, resume?.cp.state.rowTaskId), undefined), sessionId: spec.sessionId, intake: { committed: false }, ...(judgedOwnerSeat(internals) !== undefined ? { rowVerified: false } : {}), ...(rewind !== undefined ? { rewind } : {}) };
340
345
  let held = resumeHold === undefined ? undefined : { sessionId: resumeHold.sessionId, taken: Promise.resolve() };
341
346
  let releaseLock = resumeHold?.release;
342
347
  const holdSessionLock = (sessionId) => {
@@ -363,13 +368,13 @@ export class Runner {
363
368
  holdSessionLock: namedSessionId ? undefined : holdSessionLock,
364
369
  legWrites,
365
370
  runEnd,
366
- setResult: (r) => {
371
+ setResult: (r, row) => {
367
372
  resultValue = r;
368
373
  const pcs = internals?.inheritedGate?.parentConstraints;
369
374
  if (resume !== undefined)
370
375
  this.locallyClaimedTokens.close(resume.cp.token);
371
376
  const rToken = r.terminal.kind === "paused" ? r.terminal.token : undefined;
372
- if (resume !== undefined && rToken !== resume.cp.token) {
377
+ if (resume !== undefined && rToken !== resume.cp.token && !rowKeepsWhatItsRetryNeeds(row)) {
373
378
  this.parentConstraintRegistry.delete(resume.cp.token);
374
379
  this.suspendedEnvReaps.delete(resume.cp.token);
375
380
  }
@@ -470,7 +475,7 @@ export class Runner {
470
475
  const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, runEnd, resume, internals, notifyRef, promptSubmitRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
471
476
  return runNotificationLane({
472
477
  spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, runEnd, promptSubmitRef,
473
- runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, sessionFastModeSeats: this.sessionFastModeSeats, sessionMcpPools: this.sessionMcpPools, pendingSessionNotifications: this.pendingSessionNotifications,
478
+ runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, sessionFastModeSeats: this.sessionFastModeSeats, sessionPromptSeats: this.sessionPromptSeats, sessionMcpPools: this.sessionMcpPools, pendingSessionNotifications: this.pendingSessionNotifications,
474
479
  prepareTask,
475
480
  next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations }) => {
476
481
  const { runSourceTaskId, parentToolCallId, ident, emitDelegationLifecycle, loopLatch, stats, internalsNotifier, undrainedUserAtEnd, userInputLostAtEnd, offerLegFrame } = runIdentityWiring({
@@ -540,7 +545,7 @@ export class Runner {
540
545
  },
541
546
  });
542
547
  const { compactionBrain, withinTaskCompaction, compactionBreaker } = runCompactionMachinery({ spec, prepared, rs, stats, noteUnevaluablePriceTable, runner: this.depsSeat });
543
- runStopAndFinalVerify({ spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, runner: this.depsSeat });
548
+ runStopAndFinalVerify({ spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, callerStop: loopLatch.callerStop, runner: this.depsSeat });
544
549
  const legSync = prepared.workspaceSync;
545
550
  prepared.harness.setTurnWatch(legSync !== undefined ? { opened: legSync.turnOpened, ended: legSync.turnEnded } : undefined);
546
551
  runRecoveryLanes({ spec, prepared, queue, rs, ident, compactionBrain, compactionBreaker, callerStop: loopLatch.callerStop, runner: this.depsSeat });
@@ -634,7 +639,7 @@ export class Runner {
634
639
  });
635
640
  }
636
641
  async resumeLadder(token, outcome, admitted) {
637
- const { config, internals, store, cp, outcomeGate, resumeSignal, wakeMessage, chainRefusal } = admitted;
642
+ const { config, internals, store, cp, outcomeGate, resumeSignal, wakeMessage, chainRefusal, rootLayerUnrestated } = admitted;
638
643
  const readGeneration = checkpointRevOf(cp);
639
644
  const { plainReviewOutcome, plainParkOutcome } = resumeReviewOutcome({ cp, outcome, outcomeGate, wakeMessage });
640
645
  const { plainPolicyOutcome: capturedPolicyOutcome, redeemedAnswer } = resumePolicyOutcome({ cp, outcome, config, runner: this.depsSeat });
@@ -653,13 +658,17 @@ export class Runner {
653
658
  plainPolicyOutcome: capturedPolicyOutcome, plainReviewOutcome, plainParkOutcome,
654
659
  runner: this.depsSeat, effectiveDelegationFacts,
655
660
  next: ({ wakeHookContext, wakeMessage: wakeDelivered, wakeRewrittenBy, legMods, plainPolicyOutcome, outcomeForStore }) => resumePreflight({
656
- token, cp, resumeSignal, recheckGovernanceWindow, store, runner: this.depsSeat,
661
+ token, cp, resumeSignal, recheckGovernanceWindow, store, holder: internals?.holder, runner: this.depsSeat,
657
662
  locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
658
663
  next: () => resumeClaim({
659
664
  token, cp, store, outcomeForStore, holder: internals?.holder,
660
665
  locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
661
666
  onDestroyError: (err, sessionId) => this.depsSeat.deps.onError?.(err, { phase: "config", sessionId }),
662
- next: () => this.resumeHandoff({ token, cp, readGeneration, store, config, internals, resumeInternals, plainPolicyOutcome, redeemedAnswer, outcomeForStore, wakeMessage: wakeDelivered, wakeRewrittenBy, wakeHookContext, legMods, resumeSignal, hold }),
667
+ next: () => {
668
+ if (rootLayerUnrestated)
669
+ deliverEngineNotice(this.deps.onNotice, revivalRootPolicyUnrestatedNotice(cp.sessionId));
670
+ return this.resumeHandoff({ token, cp, readGeneration, store, config, internals, resumeInternals, plainPolicyOutcome, redeemedAnswer, outcomeForStore, wakeMessage: wakeDelivered, wakeRewrittenBy, wakeHookContext, legMods, resumeSignal, hold });
671
+ },
663
672
  }),
664
673
  }),
665
674
  });
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The run's station for the session call grant (`session-call-grant.ts`): it mints the card's option and, when a person takes it,
3
+ * writes the one session row and announces what happened. Only the synchronous ask station calls it — the run that asks is the
4
+ * run that writes, under the same predicate as a session-long read grant (`PersonPathRows.sessionRowOwner`: the run reads its
5
+ * session rules back and the owner's store already holds its writer; a grant never takes the writer for itself).
6
+ *
7
+ * The row is written straight to the session partition through the store's one writer (the scope routes it there): the consent it
8
+ * stands on is the person's answer to the card itself, which the resolver attested (a person, an allow, no edit, the card's own
9
+ * option); `redemption.recordId` names that card (`card:<toolCallId>`), and the notice carries the same call id.
10
+ */
11
+ import { type RunnerDeps } from "../types.js";
12
+ import type { RuleOwner } from "../rule-owner.js";
13
+ import { type PermissionRuleStoreProvider } from "../permission-rule-provider.js";
14
+ import type { ToolCallRequest } from "../tool-policy.js";
15
+ import type { createRuleOffersOf } from "./permission-rule-lanes.js";
16
+ import { type CallBindingSeat, type CallGrantBinding } from "../session-call-grant.js";
17
+ import type { SessionCallGrantOffer, SessionCallGrantScreen } from "../session-call-grant-screen.js";
18
+ /**
19
+ * The door of the option, read off the SAME ladder as the card's rule offers ({@link createRuleOffersOf}): the option exists exactly
20
+ * where a standing rule could clear this shell card's question — the offer factory either offers a rule or names `lane_cannot_speak`
21
+ * (every other word is a door that keeps every rule off the card, a mandated question first) — and the call is no sandbox escape and
22
+ * no inside peer's question (each cleared only by a grant of its own kind). One ladder, so the two options cannot disagree about
23
+ * which questions a standing yes may retire.
24
+ */
25
+ export declare function createCallGrantDoorOf(offersOf: ReturnType<typeof createRuleOffersOf>): (call: Pick<ToolCallRequest, "toolName" | "face">, args: unknown, ask: Parameters<typeof offersOf>[2]) => boolean;
26
+ type SettleAt = {
27
+ toolName: string;
28
+ toolCallId: string;
29
+ checkpointId: string;
30
+ sessionId: string;
31
+ runId: string;
32
+ taskId: string;
33
+ onNotice: RunnerDeps["onNotice"];
34
+ signal?: AbortSignal;
35
+ };
36
+ /**
37
+ * A station that offers no option (an inherited ask's, or a run that keeps no session partition) settles the member the same
38
+ * way, so a key sent to it is told as at the synchronous station: whatever the resolver read is announced as rejected —
39
+ * `no_offer` for a key the resolver could not match to an option (this card had none).
40
+ */
41
+ export declare function settleUnofferedSessionCallGrant(screen: SessionCallGrantScreen | undefined, at: SettleAt): undefined;
42
+ /** What the station holds between minting an option and reading the answer: the binding the option was minted from. */
43
+ export interface MintedCallGrant {
44
+ readonly offer: SessionCallGrantOffer;
45
+ readonly binding: CallGrantBinding;
46
+ }
47
+ export interface SessionCallGrantStation {
48
+ /** The option for this card, or `undefined` (the run keeps no session rules now, or the call is not bindable). Bounded like the
49
+ * gate's other awaits; a reading that fails or runs past the bound offers nothing. */
50
+ mint(command: unknown, signal: AbortSignal | undefined): Promise<MintedCallGrant | undefined>;
51
+ /** Act on the resolver's screen of the answer: write the row for `granted`, announce every outcome. */
52
+ /** `checkpointId`: the card's own id (`AskRequest.checkpointId`), which both notices carry so a surface joins them to the card. */
53
+ settle(screen: SessionCallGrantScreen | undefined, minted: MintedCallGrant | undefined, at: SettleAt): Promise<void> | undefined;
54
+ }
55
+ export declare function sessionCallGrantStation(cfg: {
56
+ provider: PermissionRuleStoreProvider;
57
+ sessionId: string;
58
+ /** The run's one predicate: the owner a session row is written as, now — else absent (no option, nothing written). */
59
+ sessionRowOwner: () => RuleOwner | undefined;
60
+ /** The environment, live working directory and workspace roots one reading takes, read per call. */
61
+ seat: () => CallBindingSeat;
62
+ now?: () => number;
63
+ }): SessionCallGrantStation;
64
+ export {};