@sema-agent/core 7.72.0 → 7.74.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 (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -0,0 +1,96 @@
1
+ import { isAbsoluteHostPath } from "@sema-agent/primitives";
2
+ export const PROJECT_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3
+ export const PROJECT_SEAT_NAME_MAX = 256;
4
+ export const PROJECT_SEAT_FILES_MAX = 100;
5
+ const SEAT_MEMBERS = ["id", "name", "description", "instructions", "files"];
6
+ const TEXT_MEMBERS = ["name", "description", "instructions"];
7
+ const shown = (v) => {
8
+ if (typeof v === "string")
9
+ return JSON.stringify(v.length > 48 ? `${v.slice(0, 48)}…` : v);
10
+ if (v === null)
11
+ return "null";
12
+ if (Array.isArray(v))
13
+ return "an array";
14
+ return typeof v === "object" ? "an object" : typeof v === "function" ? "a function" : String(v);
15
+ };
16
+ export function screenProjectSeat(value, at = "TaskSpec.project") {
17
+ try {
18
+ return screenRead(value, at);
19
+ }
20
+ catch {
21
+ return refusal(at, "could not be read: its read threw — a seat whose read throws is refused rather than read as absent");
22
+ }
23
+ }
24
+ function refusal(field, why, code = "config.invalid_argument") {
25
+ return { ok: false, code, field, message: `${field}: ${why} — the leg is refused rather than run under a project it was not given.` };
26
+ }
27
+ function screenRead(value, at) {
28
+ if (value === undefined)
29
+ return { ok: true };
30
+ const refuse = refusal;
31
+ const proto = value === null || typeof value !== "object" || Array.isArray(value) ? undefined : Object.getPrototypeOf(value);
32
+ if (proto === undefined || (proto !== null && Object.getPrototypeOf(proto) !== null)) {
33
+ return refuse(at, `must be a plain object { id, name?, description?, instructions?, files? } (got ${shown(value)})`);
34
+ }
35
+ const own = Reflect.ownKeys(value);
36
+ const stray = own.find((k) => typeof k !== "string" || !SEAT_MEMBERS.includes(k));
37
+ if (stray !== undefined)
38
+ return refuse(`${at}.${String(stray)}`, `is no member of a project seat (its members are ${SEAT_MEMBERS.join(", ")})`);
39
+ const read = {};
40
+ for (const k of own) {
41
+ const d = Object.getOwnPropertyDescriptor(value, k);
42
+ if (d === undefined || !("value" in d))
43
+ return refuse(`${at}.${k}`, "must be a plain data member, not an accessor");
44
+ if (d.value !== undefined)
45
+ read[k] = d.value;
46
+ }
47
+ const id = read["id"];
48
+ if (id === undefined)
49
+ return refuse(`${at}.id`, "is required — a seat names its project");
50
+ if (typeof id !== "string" || !PROJECT_ID_REGEX.test(id)) {
51
+ return refuse(`${at}.id`, `must be a project UUID (the id a \`.sema/project\` marker carries), got ${shown(id)}`, "config.project_id_invalid");
52
+ }
53
+ for (const k of TEXT_MEMBERS) {
54
+ const v = read[k];
55
+ if (v === undefined)
56
+ continue;
57
+ if (typeof v !== "string")
58
+ return refuse(`${at}.${k}`, `must be a string (got ${shown(v)}); leave it out to say none`);
59
+ if (v.trim() === "")
60
+ return refuse(`${at}.${k}`, "is empty or only whitespace; leave it out to say none");
61
+ }
62
+ const name = read["name"];
63
+ if (name !== undefined && /[\r\n]/.test(name))
64
+ return refuse(`${at}.name`, "is one line — it carries a line break");
65
+ if (name !== undefined && name.length > PROJECT_SEAT_NAME_MAX)
66
+ return refuse(`${at}.name`, `is at most ${PROJECT_SEAT_NAME_MAX} characters (got ${name.length})`);
67
+ const given = read["files"];
68
+ let files;
69
+ if (given !== undefined) {
70
+ if (!Array.isArray(given))
71
+ return refuse(`${at}.files`, `must be a list of absolute host paths (got ${shown(given)})`);
72
+ const length = given.length;
73
+ if (length > PROJECT_SEAT_FILES_MAX)
74
+ return refuse(`${at}.files`, `holds at most ${PROJECT_SEAT_FILES_MAX} entries (got ${length})`);
75
+ const entries = Array.from({ length }, (_, i) => given[i]);
76
+ const bad = entries.findIndex((p) => !isAbsoluteHostPath(p));
77
+ if (bad >= 0)
78
+ return refuse(`${at}.files[${bad}]`, `must be an absolute host path (got ${shown(entries[bad])})`);
79
+ files = entries;
80
+ }
81
+ const seat = Object.freeze({
82
+ id,
83
+ ...Object.fromEntries(TEXT_MEMBERS.filter((k) => read[k] !== undefined).map((k) => [k, read[k]])),
84
+ ...(files !== undefined ? { files: Object.freeze(files) } : {}),
85
+ });
86
+ return { ok: true, seat };
87
+ }
88
+ const REFUSED = Symbol("refused project seat");
89
+ export function captureProjectSeat(value, at) {
90
+ const screened = screenProjectSeat(value, at);
91
+ return screened.ok ? screened.seat : Object.freeze({ [REFUSED]: screened });
92
+ }
93
+ export function handedProjectSeat(captured) {
94
+ const refused = captured?.[REFUSED];
95
+ return refused ?? { ok: true, ...(captured !== undefined ? { seat: captured } : {}) };
96
+ }
@@ -244,8 +244,9 @@ export declare function foreignLine(text: string, maxLen?: number, reading?: For
244
244
  * these words does their remote-words reading not carry", for a reader that carries the same words in another spelling and must carry
245
245
  * no less: the regions its echo pass withholds and the spans its vocabulary pass then withholds in those marked words
246
246
  * ({@link egressCredentialReading}: the label a rendering keeps is not in the span), read back through the marks (a span that touches a
247
- * mark reaches the whole region the mark stands for). Where the marked words cannot be read back (see {@link writtenRegions}), the whole
248
- * text; and checked against the reading's own output: where the text outside the spans does not stand in it as written
247
+ * mark reaches the whole region the mark stands for); the regions are the merge's own account of what it wrote ({@link mergeWithheldSpans}),
248
+ * and where a mark the text already held meets what is taken (see {@link writtenRegions}), the answer is the whole text; and checked against
249
+ * the reading's own output: where the text outside the spans does not stand in it as written
249
250
  * ({@link carriesTheRest}), the spans missed a removal, and the answer is the whole text.
250
251
  */
251
252
  export declare function remoteWordsSpans(text: string, declared: readonly string[], found?: FoundElsewhere): Array<readonly [number, number]>;
@@ -1,5 +1,5 @@
1
1
  import { boundedForeignReading, egressCredentialFinds, egressCredentialReading, egressText, oneLineFinds, wholeForeignReading } from "./untrusted-egress.js";
2
- import { CREDENTIAL_MIN_CHARS, crossesNetworkInClear, isRedactionMark, isSensitiveRecordKey, REDACTION_MARKS, renderWithheld } from "@sema-agent/primitives";
2
+ import { CREDENTIAL_MIN_CHARS, crossesNetworkInClear, isRedactionMark, isSensitiveRecordKey, mergeWithheldSpans, REDACTION_MARKS, renderWithheld } from "@sema-agent/primitives";
3
3
  import { foldPlaces, foldToOneLine, INLINE_TRUNCATION_MARK, inlineUntrusted, LABEL_MAX, withoutUnrenderable } from "./untrusted-text.js";
4
4
  import { callerText } from "./caller-text.js";
5
5
  import { PRINCIPAL_NAME_SPELLING, readPrincipal } from "./principal-name.js";
@@ -481,8 +481,8 @@ function echoTaken(text, declared, found) {
481
481
  }
482
482
  export function remoteWordsSpans(text, declared, found = NOTHING_FOUND) {
483
483
  const taken = echoTaken(text, declared, found);
484
- const marked = renderWithheld(text, taken);
485
- const regions = writtenRegions(text, taken, marked);
484
+ const { text: marked, regions: merged, dropped } = mergeWithheldSpans(text, taken);
485
+ const regions = writtenRegions(taken, merged, dropped);
486
486
  if (regions === undefined)
487
487
  return [[0, text.length]];
488
488
  const reading = egressCredentialReading(marked);
@@ -539,22 +539,30 @@ function mergedRanges(ranges) {
539
539
  }
540
540
  return merged;
541
541
  }
542
- function writtenRegions(text, spans, marked) {
543
- const regions = [];
544
- let kept = 0;
545
- let at = 0;
546
- for (const [start, end] of mergedRanges(spans.map(({ start, end }) => [start, end]))) {
547
- if (!marked.startsWith(text.slice(kept, start), at))
548
- return undefined;
549
- at += start - kept;
550
- const member = MARK_MEMBERS.find((m) => marked.startsWith(m, at));
551
- if (member === undefined)
552
- return undefined;
553
- regions.push({ start, end, length: member.length });
554
- at += member.length;
555
- kept = end;
542
+ function writtenRegions(spans, merged, dropped) {
543
+ const marks = dropped.map((i) => spans[i]).sort((a, b) => a.start - b.start || a.end - b.end);
544
+ const inside = merged.map(() => []);
545
+ const standing = new Map();
546
+ let r = 0;
547
+ for (const s of marks) {
548
+ while (r < merged.length && merged[r].end < s.end)
549
+ r++;
550
+ const region = merged[r];
551
+ if (region !== undefined && region.start <= s.start && s.end <= region.end)
552
+ inside[r].push(s);
553
+ else
554
+ standing.set(`${s.start}:${s.end}`, s);
556
555
  }
557
- return marked.length - at === text.length - kept && marked.endsWith(text.slice(kept)) ? regions : undefined;
556
+ if (merged.some((region, k) => coveredLength([...region.spans.map((i) => spans[i]), ...inside[k]]) < region.end - region.start))
557
+ return undefined;
558
+ const regions = [...merged.map(({ start, end, mark }) => ({ start, end, length: mark.length })), ...[...standing.values()].map(({ start, end }) => ({ start, end, length: end - start }))].sort((a, b) => a.start - b.start || a.end - b.end);
559
+ for (let i = 1; i < regions.length; i++)
560
+ if (regions[i].start <= regions[i - 1].end)
561
+ return undefined;
562
+ return regions;
563
+ }
564
+ function coveredLength(spans) {
565
+ return mergedRanges(spans.map(({ start, end }) => [start, end])).reduce((n, [start, end]) => n + end - start, 0);
558
566
  }
559
567
  function cookieMembers(text) {
560
568
  const members = [];
@@ -589,7 +589,7 @@ export interface RemoteExecutionEnv extends ExecutionEnv {
589
589
  * Why the engine asks an {@link ExecutionEnvFactory} for an env ({@link ExecutionEnvFactoryContext.purpose}):
590
590
  * · `"run"` — a leg's own env (one per leg, destroyed when the leg ends); every leg, a delegated child's included;
591
591
  * · `"rewind_files"` — `Runner.rewindFiles`, out of any run; writes only the session's tracked files;
592
- * · `"read_changes"` — reading what a session changed, out of any run; writes nothing.
592
+ * · `"read_changes"` — read-only readings outside any run (`Runner.readSessionChanges`, `Runner.previewInstructions`); writes nothing.
593
593
  */
594
594
  export type ExecutionEnvPurpose = "run" | "rewind_files" | "read_changes";
595
595
  /** The closed set of {@link ExecutionEnvPurpose} words, frozen. */
@@ -608,9 +608,9 @@ export interface ExecutionEnvFactoryContext {
608
608
  /**
609
609
  * Why the engine asks for this env — always present. `"run"`: a leg's own env (one per leg, destroyed when the leg ends) —
610
610
  * the meaning every factory call had before this member; every leg, a delegated child's included. `"rewind_files"`:
611
- * `Runner.rewindFiles`, out of any run; writes only the session's tracked files. `"read_changes"`: reading what a session
612
- * changed, out of any run; writes nothing — asked only of a factory the deployment declares answers it
613
- * (`RunnerDeps.executionEnvFactoryHonorsReadChanges`).
611
+ * `Runner.rewindFiles`, out of any run; writes only the session's tracked files. `"read_changes"`: read-only readings
612
+ * outside any run (`Runner.readSessionChanges`, `Runner.previewInstructions`); writes nothing — asked only of a factory the
613
+ * deployment declares answers it (`RunnerDeps.executionEnvFactoryHonorsReadChanges`).
614
614
  *
615
615
  * For a purpose other than `"run"` a factory ATTACHES to the workspace the session's runs use (the same directory / host /
616
616
  * device) and never mints one — or refuses: a refusal coded {@link ENV_PURPOSE_UNSUPPORTED} when it does not serve the
@@ -0,0 +1,42 @@
1
+ /** The field path the sentences open with. */
2
+ export declare const RETAIN_SEAT_FIELD = "TaskSpec.retainSubagentSessions";
3
+ /** The option as the engine reads it once it is on: `true` (the defaults) or a frozen record of the members the caller gave. */
4
+ export type RetainSeat = true | {
5
+ readonly ttlMs?: number;
6
+ readonly max?: number;
7
+ };
8
+ /** The screen's answer: the seat (absent ⇔ the option is off), or the refusal — its code, the field path it is about, and the sentence
9
+ * (opening with that path, saying the kind of the value and never the value). Never thrown. */
10
+ export type RetainSeatScreen = {
11
+ readonly ok: true;
12
+ readonly seat?: RetainSeat;
13
+ } | {
14
+ readonly ok: false;
15
+ readonly code: "config.invalid_argument";
16
+ readonly field: string;
17
+ readonly message: string;
18
+ };
19
+ type RetainSeatRefusal = Extract<RetainSeatScreen, {
20
+ ok: false;
21
+ }>;
22
+ /**
23
+ * Judge the retain option. `undefined` and `false` are off (no seat); `true` is on with the defaults; a plain record is on, and its
24
+ * members are the only keys `ttlMs` and `max` — each present member (not `undefined`) a whole number of at least 1 — and the seat is a
25
+ * frozen copy holding exactly the members given. Refused, each `config.invalid_argument` with its field path: `null`, a string, a number
26
+ * or an array as the option; a key the option does not take; a record that is not plain (a class instance, a Proxy); a member whose
27
+ * read throws (the sentence says it could not be read, never what it threw); and a member that is `null`, not a number, not finite, a
28
+ * fraction or below 1. Each member is read once, off the record's captured descriptors, and the answer is a copy of what was read, so the
29
+ * caller's record is never read again. `at` is the field path of the option for the sentences.
30
+ */
31
+ export declare function screenRetainSeat(value: unknown, at?: string): RetainSeatScreen;
32
+ /** The refusal as the error a door throws: the code, and `detail.field` naming the field. */
33
+ export declare function retainSeatError(refusal: RetainSeatRefusal): Error & {
34
+ code: "config.invalid_argument";
35
+ detail: {
36
+ field: string;
37
+ };
38
+ };
39
+ /** The screen as a ledger's constructor takes it: the seat to build from (`true` or the frozen record), or the refusal thrown. A value that
40
+ * asks for no retention (`false`, absent) is refused too — a ledger is made only for an opt-in. */
41
+ export declare function retainSeatToBuild(value: unknown): RetainSeat;
42
+ export {};
@@ -0,0 +1,76 @@
1
+ import { types } from "node:util";
2
+ import { optionKeys, receiveMembers } from "./own-property-receipt.js";
3
+ export const RETAIN_SEAT_FIELD = "TaskSpec.retainSubagentSessions";
4
+ const RETAIN_SEAT_MEMBERS = optionKeys()({ ttlMs: 0, max: 0 });
5
+ const refuse = (field, why) => ({
6
+ ok: false,
7
+ code: "config.invalid_argument",
8
+ field,
9
+ message: `${field}: ${why} — the run is refused rather than retained under a setting nobody chose.`,
10
+ });
11
+ function kindOf(v) {
12
+ if (v === null)
13
+ return "null";
14
+ if (types.isProxy(v))
15
+ return "a Proxy";
16
+ if (Array.isArray(v))
17
+ return "an array";
18
+ if (typeof v === "number") {
19
+ if (!Number.isFinite(v))
20
+ return "a number that is not finite";
21
+ if (!Number.isInteger(v))
22
+ return "a number that is not a whole number";
23
+ return v > Number.MAX_SAFE_INTEGER ? "a whole number above that" : "a whole number below 1";
24
+ }
25
+ if (typeof v === "object")
26
+ return "an object";
27
+ return `${/^[aeiou]/.test(typeof v) ? "an" : "a"} ${typeof v}`;
28
+ }
29
+ export function screenRetainSeat(value, at = RETAIN_SEAT_FIELD) {
30
+ try {
31
+ return screenRead(value, at);
32
+ }
33
+ catch {
34
+ return refuse(at, "could not be read: reading it threw — a value whose read throws is refused rather than read as off");
35
+ }
36
+ }
37
+ function screenRead(value, at) {
38
+ if (value === undefined || value === false)
39
+ return { ok: true };
40
+ if (value === true)
41
+ return { ok: true, seat: true };
42
+ if (value === null || typeof value !== "object" || (!types.isProxy(value) && Array.isArray(value))) {
43
+ return refuse(at, `must be \`true\`, \`false\` or a record { ttlMs?, max? } (got ${kindOf(value)})`);
44
+ }
45
+ let record;
46
+ try {
47
+ record = receiveMembers(value, { subject: at, unit: "member", moment: "when the run's spec is read" }, RETAIN_SEAT_MEMBERS);
48
+ }
49
+ catch (e) {
50
+ if (!(e instanceof Error) || !("code" in e) || e.code !== "config.invalid_argument")
51
+ throw e;
52
+ const member = "member" in e ? e.member : undefined;
53
+ return { ok: false, code: "config.invalid_argument", field: typeof member === "string" ? `${at}.${member}` : at, message: e.message };
54
+ }
55
+ const seat = {};
56
+ for (const key of ["ttlMs", "max"]) {
57
+ const v = Reflect.get(record, key);
58
+ if (v === undefined)
59
+ continue;
60
+ if (typeof v !== "number" || !Number.isSafeInteger(v) || v < 1)
61
+ return refuse(`${at}.${key}`, `must be a whole number from 1 to ${Number.MAX_SAFE_INTEGER} (got ${kindOf(v)})`);
62
+ seat[key] = v;
63
+ }
64
+ return { ok: true, seat: Object.freeze(seat) };
65
+ }
66
+ export function retainSeatError(refusal) {
67
+ return Object.assign(new Error(refusal.message), { code: refusal.code, detail: { field: refusal.field } });
68
+ }
69
+ export function retainSeatToBuild(value) {
70
+ const screened = screenRetainSeat(value);
71
+ if (!screened.ok)
72
+ throw retainSeatError(screened);
73
+ if (screened.seat === undefined)
74
+ throw retainSeatError(refuse(RETAIN_SEAT_FIELD, "asks for no retention, and a retain ledger is made only for `true` or a record"));
75
+ return screened.seat;
76
+ }
@@ -36,6 +36,7 @@ export const RETIRED_TASK_SPEC_KEYS = Object.freeze({
36
36
  promptProfile: 'the prompt\'s shape is the `lean_prompt` trait now — write `promptLean: false` for the long (classic) shape, `promptLean: true` (or nothing, on a model that declares `lean_prompt`) for the lean one',
37
37
  rewindFiles: "capture needs no request (first-touch tracking is on whenever `RunnerDeps.fileHistoryStore` is wired and neither `RunnerDeps.fileHistoryCapture` nor `TaskSpec.fileHistory` turns it off); to restore files with the conversation write `resumeAt` + `restoreFiles: true`, for a code-only restore `rewindFilesTo` — drop the key",
38
38
  compactionModel: SUMMARY_ON_MAIN_MODEL,
39
+ projectId: "a leg's project is one seat now — write `project: { id }` (the same UUID, as `TaskSpec.project.id`); the project's texts (`name`, `description`, `instructions`, `files`) ride that seat beside it",
39
40
  });
40
41
  export const RETIRED_SKILLS_SEAT_KEYS = Object.freeze({
41
42
  "skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The rewind verbs' refusals that happen before any work — the request or the session refused, nothing written: the closed set a host
3
+ * maps to a 4xx by family. Not in it: `rewind.restore_failed` (the restore itself failed — before writing, e.g. an unreadable
4
+ * session row, or after touching the disk where it may be partial; its `detail.permanence` says whether a retry can help) and the two rewind notices (`rewind.boundary_unrecorded`, `rewind.file_left_as_is`:
5
+ * notice codes, in ENGINE_NOTICE_CODES).
6
+ */
7
+ export declare const REWIND_REFUSAL_CODES: readonly ["rewind.invalid_spec", "rewind.conflicting_targets", "rewind.store_unconfigured", "rewind.capture_disabled", "rewind.files_env_unsupported", "rewind.session_busy", "rewind.session_parked", "rewind.target_off_branch", "rewind.unseen_later_turn", "rewind.child_scope_unsupported"];
8
+ export type RewindRefusalCode = (typeof REWIND_REFUSAL_CODES)[number];
@@ -0,0 +1,12 @@
1
+ export const REWIND_REFUSAL_CODES = Object.freeze([
2
+ "rewind.invalid_spec",
3
+ "rewind.conflicting_targets",
4
+ "rewind.store_unconfigured",
5
+ "rewind.capture_disabled",
6
+ "rewind.files_env_unsupported",
7
+ "rewind.session_busy",
8
+ "rewind.session_parked",
9
+ "rewind.target_off_branch",
10
+ "rewind.unseen_later_turn",
11
+ "rewind.child_scope_unsupported",
12
+ ]);
@@ -194,13 +194,13 @@ export declare function screenRoleMap(roles: ModelRoles | undefined, field: "Run
194
194
  export declare const ROLE_SEAT_STAND_IN_CAUSES: readonly ["unknown_model_ref", "tier_unbound"];
195
195
  export type RoleSeatStandInCause = (typeof ROLE_SEAT_STAND_IN_CAUSES)[number];
196
196
  /** A role seat whose word the catalog does not hold: the role, the seat as the refusal names it, the word written there, why it is not held,
197
- * and whether the role's OWN tier default is absent in that catalog too (then the walk's tier step supplies this role nothing either). */
197
+ * and whether the role's OWN tier default is bound in that catalog (the walk's tier step then supplies this role a model: {@link roleTierModel}). */
198
198
  export interface UnheldRoleSeat {
199
199
  role: ModelRole;
200
200
  seat: string;
201
201
  word: string;
202
202
  cause: RoleSeatStandInCause;
203
- ownTierAbsent: boolean;
203
+ ownTierBound: boolean;
204
204
  }
205
205
  /**
206
206
  * The ONE test of "this seat names a word the deployment's catalog does not declare": the word a role entry writes — the string
@@ -508,8 +508,22 @@ function partsModel(parts, models, seat = "a role seat") {
508
508
  return undefined;
509
509
  }
510
510
  export const ROLE_SEAT_STAND_IN_CAUSES = Object.freeze(["unknown_model_ref", "tier_unbound"]);
511
+ function ownTierBoundOf(role, models) {
512
+ const tier = ROLE_TIER_DEFAULTS[role];
513
+ if (tier === undefined)
514
+ return false;
515
+ try {
516
+ if (!tiersActive(models))
517
+ return false;
518
+ const entry = catalogEntry(tier, models);
519
+ return typeof entry === "object" && entry !== null;
520
+ }
521
+ catch {
522
+ return false;
523
+ }
524
+ }
511
525
  function unheldSeatOf(role, seat, word, models) {
512
- return { role, seat, word, cause: isFixedTierWord(word) && tiersActive(models) ? "tier_unbound" : "unknown_model_ref", ownTierAbsent: absentTierDefault(role, models) !== undefined };
526
+ return { role, seat, word, cause: isFixedTierWord(word) && tiersActive(models) ? "tier_unbound" : "unknown_model_ref", ownTierBound: ownTierBoundOf(role, models) };
513
527
  }
514
528
  export function unheldSeatWord(spec, models) {
515
529
  const named = typeof spec === "string" ? spec : isBindingObject(spec) && !("id" in spec && "api" in spec) ? spec.model : undefined;
@@ -9,7 +9,7 @@ import { type RuleOffer } from "./permission-rule-model.js";
9
9
  * Why a stored rule-offer value, or one element of it, is not read:
10
10
  * · `not_an_array` — the value itself (present, and not a list): no element is read;
11
11
  * · `unknown_word` — a closed-set member holds a word this engine does not know: the offer `kind`, a batch member's
12
- * `kind`, a `match` (a newer minter, or another writer);
12
+ * `kind`, a `match`, a `cautions` word (a newer minter, or another writer);
13
13
  * · `malformed` — not an object, a member missing or of the wrong type, a batch with no members, an uncovered count
14
14
  * that is not a non-negative safe integer.
15
15
  * The first defect in reading order names the element's problem.
@@ -1,4 +1,4 @@
1
- import { PERSISTED_RULE_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_KINDS, UNCOVERED_SEGMENT_REASONS, isAddStamp, } from "./permission-rule-model.js";
1
+ import { PERSISTED_RULE_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_CAUTIONS, RULE_OFFER_KINDS, UNCOVERED_SEGMENT_REASONS, isAddStamp, } from "./permission-rule-model.js";
2
2
  import { isPlainRecord } from "./checkpoint-store.js";
3
3
  const OFFER_MATCHES = PERSISTED_RULE_MATCHES.filter((m) => m !== "call");
4
4
  export const RULE_OFFER_SHAPE_PROBLEMS = Object.freeze(["not_an_array", "unknown_word", "malformed"]);
@@ -46,7 +46,10 @@ function readOfferElement(value) {
46
46
  const peerFingerprint = Object.hasOwn(value, "peerFingerprint") ? value.peerFingerprint : undefined;
47
47
  if (peerFingerprint !== undefined && !isAddStamp(peerFingerprint))
48
48
  return MALFORMED;
49
- return { offer: { kind: "single", rule, match, command, ...(peerFingerprint !== undefined ? { peerFingerprint } : {}) } };
49
+ const cautions = cautionsOf(value);
50
+ if ("problem" in cautions)
51
+ return cautions;
52
+ return { offer: { kind: "single", rule, match, command, ...(peerFingerprint !== undefined ? { peerFingerprint } : {}), ...cautions.seat } };
50
53
  }
51
54
  case "batch":
52
55
  return readBatch(value);
@@ -87,8 +90,13 @@ function readBatchMember(value) {
87
90
  if (typeof kind !== "string")
88
91
  return kind;
89
92
  switch (kind) {
90
- case "command":
91
- return commandMember(value.rule, value.match, value.command, value.segment);
93
+ case "command": {
94
+ const read = commandMember(value.rule, value.match, value.command, value.segment);
95
+ if ("problem" in read)
96
+ return read;
97
+ const cautions = cautionsOf(value);
98
+ return "problem" in cautions ? cautions : { member: { ...read.member, ...cautions.seat } };
99
+ }
92
100
  case "directoryRead": {
93
101
  const rule = value.rule;
94
102
  const directory = value.directory;
@@ -113,6 +121,26 @@ function commandMember(rule, rawMatch, command, segment) {
113
121
  return MALFORMED;
114
122
  return { member: { kind: "command", rule, match, command, segment } };
115
123
  }
124
+ function cautionsOf(value) {
125
+ const raw = Object.hasOwn(value, "cautions") ? value.cautions : undefined;
126
+ if (raw === undefined)
127
+ return { seat: {} };
128
+ if (!Array.isArray(raw))
129
+ return MALFORMED;
130
+ const words = [];
131
+ let unknown = false;
132
+ const length = raw.length;
133
+ for (let i = 0; i < length; i++) {
134
+ const word = wordOf(raw[i], RULE_OFFER_CAUTIONS);
135
+ if (typeof word === "string")
136
+ words.push(word);
137
+ else if (word === MALFORMED)
138
+ return MALFORMED;
139
+ else
140
+ unknown = true;
141
+ }
142
+ return unknown ? UNKNOWN_WORD : { seat: { cautions: words } };
143
+ }
116
144
  function detailRowsOf(detail, count) {
117
145
  if (!Array.isArray(detail))
118
146
  return undefined;
@@ -49,16 +49,18 @@ export declare function ruleStoreFaultReasonOf(err: unknown): RuleStoreFaultReas
49
49
  export declare function ruleStoreSourcesWord(sources: readonly RuleStoreSource[]): string;
50
50
  /**
51
51
  * The run's `permission.rule_store_unavailable` sentence (audience: the person): which partition, why, what it costs meanwhile, and
52
- * what to repair. No path, no permission mode: it is told only where the mode puts such a call to a person
53
- * (`rule-store-unreadable-notice.ts`), so until a read succeeds every call asks a person.
52
+ * what to repair. No path. `relaxedMode` names the leg's mode when it answers the class unasked (so the cost clause states only what
53
+ * that mode does — the unread rules by themselves do not make the engine ask, under `auto` the classifier judges such a call, retained
54
+ * deny/ask rows still apply, and a deny rule saved since may not be in force); `undefined` otherwise (every call asks a person until a
55
+ * read succeeds).
54
56
  */
55
- export declare function ruleStoreUnreadableNoticeSentence(at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined): string;
57
+ export declare function ruleStoreUnreadableNoticeSentence(at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined, relaxedMode: string | undefined): string;
56
58
  /**
57
59
  * The `permission.rule_store_unreadable_relaxed` sentence (audience: the operator): the same partition, cause and repair, where the leg's
58
- * permission mode answers the class of the unread rules with nobody asked — so the person is told nothing and no deny or ask row of the
59
- * unread rules stops a call beyond the rows of the last read that succeeded. (Another class on a call may still put it to a person.) With
60
- * `rows`, the fact is that many rows of the rules whose rule itself could not be read: the calls they may reach are released alike, while
61
- * every other row applies as read.
60
+ * permission mode answers the class of the unread rules with nobody asked — the person is told by their own notice, and until a read
61
+ * succeeds only the deny and ask rows of the last read that succeeded apply (under `auto` the classifier judges such a call, and a
62
+ * no-ruling result or a retained ask row may still put it to a person). With `rows`, the fact is that many rows of the rules whose rule
63
+ * itself could not be read: the calls they may reach are released alike, while every other row applies as read.
62
64
  */
63
65
  export declare function ruleStoreUnreadableRelaxedSentence(mode: string, at: "prepare" | "call", faults: readonly RuleStoreFault[] | undefined, rows?: number): string;
64
66
  /**
@@ -63,10 +63,14 @@ function waysOut(faults) {
63
63
  return [...new Set([...acts, ...logs])].join(" ");
64
64
  }
65
65
  const UNSAID = Object.freeze([Object.freeze({ sources: Object.freeze([]), reason: "unclassified" })]);
66
- export function ruleStoreUnreadableNoticeSentence(at, faults) {
66
+ export function ruleStoreUnreadableNoticeSentence(at, faults, relaxedMode) {
67
67
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
68
68
  const fixes = waysOut(faults !== undefined && faults.length > 0 ? faults : UNSAID);
69
- return `Your saved permission rules${head} could not be read ${at === "prepare" ? "when this run started" : "for a call on this run"}: ${clause}. Until a read of them succeeds, none of their allow rows (Read directory rows included) applies, while the deny and ask rows most recently read from them this run still apply — a deny row you removed since that read keeps refusing until then. While they cannot be read, every call is asked about rather than allowed, whatever its tool (rules nobody can read may name any), until a read of them succeeds. ${fixes} Every later check reads them again.`;
69
+ const modeNote = relaxedMode === "auto" ? " (the classifier judges such a call)" : "";
70
+ const cost = relaxedMode !== undefined
71
+ ? `Under this run's permission mode (${relaxedMode}), the unread rules by themselves do not make the engine ask${modeNote}: until a read of them succeeds, only the deny and ask rows most recently read from them this run apply (none, if no read has succeeded) — a deny rule you saved since may not be in force.`
72
+ : "Until a read of them succeeds, none of their allow rows (Read directory rows included) applies, while the deny and ask rows most recently read from them this run still apply — a deny row you removed since that read keeps refusing until then. While they cannot be read, every call is asked about rather than allowed, whatever its tool (rules nobody can read may name any), until a read of them succeeds.";
73
+ return `Your saved permission rules${head} could not be read ${at === "prepare" ? "when this run started" : "for a call on this run"}: ${clause}. ${cost} ${fixes} Every later check reads them again.`;
70
74
  }
71
75
  export function ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows) {
72
76
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
@@ -74,7 +78,8 @@ export function ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows) {
74
78
  if (rows !== undefined) {
75
79
  return `${rows} deny or ask row${rows === 1 ? "" : "s"} of the person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"} (the rule itself — its tool, its text or its behavior — is not plain data): ${clause}. Under the run's permission mode (${mode}) the calls ${rows === 1 ? "it" : "they"} may reach are released with nobody asked, unless a readable deny refuses them or a readable ask row asks; every other row applies as read. ${fixes}`;
76
80
  }
77
- return `The person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"}: ${clause}. Under the run's permission mode (${mode}) the unread rules alone put no call to a person, so the person is not told: until a read of them succeeds, only the deny and ask rows of the last read that succeeded apply (none, if no read has). ${fixes}`;
81
+ const modeNote = mode === "auto" ? " (the classifier judges such a call)" : "";
82
+ return `The person's saved permission rules${head} could not be read ${at === "prepare" ? "when a run started" : "for a call of a run"}: ${clause}. Under the run's permission mode (${mode}) the unread rules by themselves do not make the engine ask${modeNote} (the person is told by their own notice): until a read of them succeeds, only the deny and ask rows of the last read that succeeded apply (none, if no read has) — a deny rule saved since may not be in force. ${fixes}`;
78
83
  }
79
84
  export function ruleStoreUnreadableAskSentence(faults) {
80
85
  const { head, clause } = faultsClause(faults !== undefined && faults.length > 0 ? faults : UNSAID);
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The bindings of a run's member ledger book (`TaskSpec.runLedger`) that need the prepared leg: the holder's rows of the members the
3
+ * task dispatched (read at each snapshot), and the run's own tool calls (the evidence a check may cite, heard as each one starts and
4
+ * finishes). Bound once, right after prepare, by the lane that minted the book.
5
+ *
6
+ * A MEMBER is a background agent or workflow run whose registry row names this task as the one that dispatched it (`parentTaskId`,
7
+ * written at registration by the agent tool and the workflow tool alike) — one key for both kinds, whatever owner the row registered
8
+ * under (a session-scoped spawn registers under the session) and whatever else the session's reach holds (another task's spawns).
9
+ * How it stands is that row's: whether it runs, how it ended (the ending its holder minted, else the one its status word names —
10
+ * `outcomeOfLegacyRow`, the one table), a workflow run's own members (the run's member ledger, as the registry keeps it).
11
+ *
12
+ * The holder read is this process's task registry. A durable background-agent or workflow-run store is not read: a member whose row
13
+ * only such a store holds (a resume in another process) is one the holder no longer hands back — the book counts it unreadable and
14
+ * the coverage is incomplete (`docs/KNOWN-LIMITS.md`, KL-4459-b).
15
+ */
16
+ import { type TaskListRow } from "./task-registry.js";
17
+ import { type RunEndCause } from "./member-outcome.js";
18
+ import type { RunLedgerBook, RunLedgerRegistryRow } from "./run-ledger.js";
19
+ /** What the binding reads off the prepared leg: its task id (the book's), its run id, its registry access, its session, and its
20
+ * harness's event stream. */
21
+ export interface RunLedgerLeg {
22
+ readonly taskId: string;
23
+ readonly runId: string;
24
+ readonly registryAccess: {
25
+ readonly owner: string;
26
+ readonly scope: string;
27
+ };
28
+ readonly sessionId: string;
29
+ readonly harness: {
30
+ subscribe(listener: (event: {
31
+ readonly type: string;
32
+ readonly toolCallId?: string;
33
+ }) => void): () => void;
34
+ };
35
+ }
36
+ /** The task's member rows as its holder hands them (see the module head): every row of the reach that names the task as its
37
+ * parent, read as one set (no display cap — other tasks' rows in the reach never push a member out). The reach is the leg's own,
38
+ * its tree root's occupant included (`occupant`, the one its registry-facing tools act for): a worker an earlier occupant of a recycled
39
+ * session id started is no member, as it is no task of that leg. */
40
+ export declare function ledgerRegistryRows(access: {
41
+ readonly owner: string;
42
+ readonly scope: string;
43
+ }, sessionId: string, taskId: string, occupant?: string): RunLedgerRegistryRow[];
44
+ /** One member by its id — the same rule, read with no listing at all (a frame's row, however many rows the reach holds). */
45
+ export declare function ledgerMemberRow(access: {
46
+ readonly owner: string;
47
+ readonly scope: string;
48
+ }, sessionId: string, taskId: string, memberId: string, occupant?: string): RunLedgerRegistryRow | undefined;
49
+ /** One registry row as a snapshot reads it: running while its status says so; else the ending its holder minted (a background
50
+ * agent's), else the one its status word names ({@link outcomeOfLegacyRow}) — a parked row's is `parked`. A workflow row carries
51
+ * its run's own member ledger once the run settled. */
52
+ export declare function ledgerRegistryRowOf(r: TaskListRow, name?: string): RunLedgerRegistryRow;
53
+ /** The run-end reap of the run's task-scoped background agents (the teardown's own selection: `skipSessionScoped`), run ahead of a
54
+ * member ledger's last word (r3.1 R1.3: the last word is read after the reap, nothing simulated): the person's-stop mark first when
55
+ * a person stopped the run's work, then the reap with what ended the run, then — when it stopped any — a bounded wait until none
56
+ * of the agents this sweep selects remain running (ignoring monitors, background shells and session-scoped rows). The wait counts
57
+ * the task-scoped agents currently running under this owner, so an agent started by the same owner after the stop pass can hold the
58
+ * last snapshot up to the two-second bound. The teardown's own reap after it finds nothing left to take. */
59
+ export declare function reapTaskAgentsBeforeLastWord(access: {
60
+ readonly owner: string;
61
+ readonly scope: string;
62
+ }, source: "user" | "parent", runEnd: RunEndCause | undefined): Promise<void>;
63
+ /** Bind the book to the prepared leg — see the module head. The book's task is the leg's: a book minted for another task id is an
64
+ * engine fault, refused here rather than read as a ledger of nobody's members. `occupant`: the occupant of the leg's tree root the
65
+ * leg acts for (absent = none read: every row admits it, as on every registry face). */
66
+ export declare function bindRunLedgerBook(book: RunLedgerBook, prepared: RunLedgerLeg, occupant?: string): void;