@sema-agent/core 7.71.1 → 7.73.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 (348) hide show
  1. package/CHANGELOG.md +500 -0
  2. package/dist/agents/cross-session-ref.d.ts +2 -2
  3. package/dist/agents/cross-session-ref.js +7 -2
  4. package/dist/agents/inherited-tool-pool.d.ts +30 -2
  5. package/dist/agents/inherited-tool-pool.js +53 -7
  6. package/dist/agents/parked-resume-drive.d.ts +10 -0
  7. package/dist/agents/parked-resume-drive.js +9 -0
  8. package/dist/agents/retain-ledger.d.ts +3 -0
  9. package/dist/agents/send-message-tool.js +7 -2
  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 +47 -12
  16. package/dist/agents/verify.js +23 -7
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.js +14 -9
  19. package/dist/brain/open-responses.js +4 -5
  20. package/dist/brain/openai.js +30 -23
  21. package/dist/brain/stream-engine.js +159 -151
  22. package/dist/core/a2a.d.ts +24 -3
  23. package/dist/core/a2a.js +27 -8
  24. package/dist/core/actions-digest.d.ts +43 -0
  25. package/dist/core/actions-digest.js +22 -0
  26. package/dist/core/agent-state.d.ts +28 -7
  27. package/dist/core/agent-state.js +19 -6
  28. package/dist/core/allow-entry.js +3 -3
  29. package/dist/core/approval-object.d.ts +7 -3
  30. package/dist/core/approval-object.js +30 -9
  31. package/dist/core/auto-mode.d.ts +7 -9
  32. package/dist/core/auto-mode.js +114 -8
  33. package/dist/core/checkpoint-features.d.ts +16 -5
  34. package/dist/core/checkpoint-features.js +35 -6
  35. package/dist/core/checkpoint-rekey.d.ts +1 -1
  36. package/dist/core/checkpoint-rekey.js +6 -1
  37. package/dist/core/checkpoint-requirements.d.ts +23 -3
  38. package/dist/core/checkpoint-requirements.js +5 -1
  39. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  40. package/dist/core/checkpoint-row-verdict.js +10 -4
  41. package/dist/core/checkpoint-store.d.ts +24 -2
  42. package/dist/core/checkpoint-store.js +1 -0
  43. package/dist/core/child-clamp-seats.d.ts +15 -0
  44. package/dist/core/child-clamp-seats.js +15 -0
  45. package/dist/core/delegation-frames.d.ts +1 -0
  46. package/dist/core/delegation-frames.js +1 -1
  47. package/dist/core/effective-path-target.d.ts +19 -0
  48. package/dist/core/effective-path-target.js +95 -38
  49. package/dist/core/engine-capabilities.d.ts +5 -1
  50. package/dist/core/engine-capabilities.js +1 -1
  51. package/dist/core/engine-notice.d.ts +34 -23
  52. package/dist/core/engine-version.js +1 -1
  53. package/dist/core/entries-not-applied.d.ts +19 -7
  54. package/dist/core/entries-not-applied.js +33 -1
  55. package/dist/core/file-history-store.d.ts +15 -4
  56. package/dist/core/file-history-store.js +53 -23
  57. package/dist/core/gate-fold.js +3 -1
  58. package/dist/core/governance-codes.d.ts +10 -1
  59. package/dist/core/governance-codes.js +17 -5
  60. package/dist/core/hooks.d.ts +3 -0
  61. package/dist/core/hooks.js +1 -0
  62. package/dist/core/host-instance.d.ts +23 -0
  63. package/dist/core/host-instance.js +69 -0
  64. package/dist/core/instruction-preview.d.ts +63 -0
  65. package/dist/core/instruction-preview.js +406 -0
  66. package/dist/core/judged-read.d.ts +57 -0
  67. package/dist/core/judged-read.js +1 -0
  68. package/dist/core/leg-budget.d.ts +26 -0
  69. package/dist/core/leg-budget.js +9 -0
  70. package/dist/core/leg-identity.d.ts +51 -1
  71. package/dist/core/leg-identity.js +45 -2
  72. package/dist/core/manager-launch-check.d.ts +48 -0
  73. package/dist/core/manager-launch-check.js +64 -0
  74. package/dist/core/mcp-call-meta.d.ts +2 -2
  75. package/dist/core/mcp-host-seat.d.ts +5 -0
  76. package/dist/core/mcp-host-seat.js +7 -1
  77. package/dist/core/mcp-injection-drop.d.ts +20 -10
  78. package/dist/core/mcp-injection-drop.js +9 -3
  79. package/dist/core/mcp-server-spec.d.ts +2 -1
  80. package/dist/core/mcp.js +3 -1
  81. package/dist/core/member-outcome.d.ts +3 -2
  82. package/dist/core/member-outcome.js +1 -1
  83. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  84. package/dist/core/memory-engine/deletion-record.js +96 -0
  85. package/dist/core/memory-engine/engine.js +24 -16
  86. package/dist/core/memory-engine/file-backend.js +7 -5
  87. package/dist/core/memory-engine/index.d.ts +1 -1
  88. package/dist/core/memory-engine/index.js +1 -1
  89. package/dist/core/memory-engine/layout.js +6 -4
  90. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  91. package/dist/core/memory-engine/projection-ledger.js +1 -1
  92. package/dist/core/memory-engine/scope-contract.d.ts +69 -11
  93. package/dist/core/memory-engine/scope-contract.js +99 -34
  94. package/dist/core/memory-engine/sync-client.js +26 -6
  95. package/dist/core/memory-engine/sync.d.ts +20 -2
  96. package/dist/core/memory-engine/sync.js +18 -17
  97. package/dist/core/mode-policy.d.ts +21 -6
  98. package/dist/core/mode-policy.js +15 -6
  99. package/dist/core/mounted-mcp.d.ts +7 -2
  100. package/dist/core/mounted-mcp.js +10 -1
  101. package/dist/core/own-property-receipt.js +11 -4
  102. package/dist/core/param-rule-reach.d.ts +8 -3
  103. package/dist/core/param-rule-reach.js +9 -1
  104. package/dist/core/parent-spec-seat.d.ts +13 -1
  105. package/dist/core/parent-spec-seat.js +18 -0
  106. package/dist/core/peer-registration.d.ts +52 -0
  107. package/dist/core/peer-registration.js +37 -0
  108. package/dist/core/peer-seat.d.ts +3 -1
  109. package/dist/core/peer-seat.js +3 -3
  110. package/dist/core/peer-task-store.d.ts +365 -0
  111. package/dist/core/peer-task-store.js +682 -0
  112. package/dist/core/permission-rule-consent.js +6 -11
  113. package/dist/core/permission-rule-model.d.ts +27 -0
  114. package/dist/core/permission-rule-model.js +34 -6
  115. package/dist/core/permission-rule-provider.d.ts +35 -33
  116. package/dist/core/permission-rule-provider.js +38 -295
  117. package/dist/core/permission-rule-store.d.ts +181 -8
  118. package/dist/core/permission-rule-store.js +420 -17
  119. package/dist/core/permission-rule-sync.js +15 -1
  120. package/dist/core/project-seat.d.ts +55 -0
  121. package/dist/core/project-seat.js +96 -0
  122. package/dist/core/protocol-http-auth.d.ts +3 -2
  123. package/dist/core/protocol-http-auth.js +26 -18
  124. package/dist/core/remote-env.d.ts +4 -4
  125. package/dist/core/retired-keys.js +1 -0
  126. package/dist/core/rule-offer-read.d.ts +1 -1
  127. package/dist/core/rule-offer-read.js +32 -4
  128. package/dist/core/run-ledger-seat.d.ts +66 -0
  129. package/dist/core/run-ledger-seat.js +70 -0
  130. package/dist/core/run-ledger.d.ts +332 -0
  131. package/dist/core/run-ledger.js +550 -0
  132. package/dist/core/runner/chain-mismatch.d.ts +32 -0
  133. package/dist/core/runner/chain-mismatch.js +29 -0
  134. package/dist/core/runner/changes-history.d.ts +1 -0
  135. package/dist/core/runner/changes-history.js +2 -2
  136. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  137. package/dist/core/runner/checkpoint-scope.js +12 -4
  138. package/dist/core/runner/construction-doors.js +6 -0
  139. package/dist/core/runner/contracts.d.ts +22 -3
  140. package/dist/core/runner/delegation-owner.d.ts +30 -0
  141. package/dist/core/runner/delegation-owner.js +20 -4
  142. package/dist/core/runner/file-history-restore.d.ts +3 -1
  143. package/dist/core/runner/file-history-restore.js +9 -6
  144. package/dist/core/runner/finish-reason-seat.js +4 -2
  145. package/dist/core/runner/leg-frame.js +3 -0
  146. package/dist/core/runner/loaded-skills.d.ts +2 -0
  147. package/dist/core/runner/loaded-skills.js +10 -0
  148. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  149. package/dist/core/runner/nested-memory-lane.js +91 -30
  150. package/dist/core/runner/person-path-rows.d.ts +23 -20
  151. package/dist/core/runner/person-path-rows.js +82 -18
  152. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  153. package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
  154. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  155. package/dist/core/runner/prepare-config-doors.js +5 -3
  156. package/dist/core/runner/prepare-context-lane.js +1 -0
  157. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  158. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  159. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  160. package/dist/core/runner/prepare-file-history.js +1 -1
  161. package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
  162. package/dist/core/runner/prepare-hands-readface.js +36 -22
  163. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
  164. package/dist/core/runner/prepare-inherited-gate.js +14 -6
  165. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
  166. package/dist/core/runner/prepare-memory-engine-session.js +2 -2
  167. package/dist/core/runner/prepare-memory.js +3 -15
  168. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  169. package/dist/core/runner/prepare-project-context.js +3 -7
  170. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
  171. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  172. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  173. package/dist/core/runner/prepare-run-refs.js +3 -2
  174. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  175. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  176. package/dist/core/runner/prepare-task.js +50 -37
  177. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  178. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  179. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
  180. package/dist/core/runner/prepare-wiring-manifest.js +8 -4
  181. package/dist/core/runner/read-session-changes.js +1 -1
  182. package/dist/core/runner/resume-apply.js +11 -5
  183. package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
  184. package/dist/core/runner/resume-checkpoint-screen.js +7 -6
  185. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  186. package/dist/core/runner/resume-review-outcome.js +24 -1
  187. package/dist/core/runner/rewind-files.js +3 -2
  188. package/dist/core/runner/run-harness-handlers.js +3 -0
  189. package/dist/core/runner/run-identity-wiring.js +3 -2
  190. package/dist/core/runner/run-leg.js +9 -2
  191. package/dist/core/runner/run-notification-lane.js +20 -1
  192. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  193. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  194. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  195. package/dist/core/runner/runtask.d.ts +6 -2
  196. package/dist/core/runner/runtask.js +21 -9
  197. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  198. package/dist/core/runner/shell-env-withheld.js +1 -2
  199. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  200. package/dist/core/runner/stop-tail-notice.js +9 -2
  201. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  202. package/dist/core/runner/stream-settle-backstop.js +1 -0
  203. package/dist/core/runner/task-start-doors.js +6 -3
  204. package/dist/core/runner/terminal-account.d.ts +10 -1
  205. package/dist/core/runner/terminal-account.js +23 -3
  206. package/dist/core/runner/tool-face-overlay.d.ts +2 -11
  207. package/dist/core/runner/tool-face-overlay.js +39 -0
  208. package/dist/core/runner/trim-stretch.js +7 -2
  209. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  210. package/dist/core/runner-deps.d.ts +13 -10
  211. package/dist/core/scheduler.d.ts +47 -7
  212. package/dist/core/scheduler.js +19 -7
  213. package/dist/core/secret-env.d.ts +60 -37
  214. package/dist/core/secret-env.js +45 -48
  215. package/dist/core/sensitive-path-policy.js +14 -7
  216. package/dist/core/session-checkout.d.ts +3 -0
  217. package/dist/core/session-checkout.js +1 -0
  218. package/dist/core/session-store.d.ts +12 -6
  219. package/dist/core/session-store.js +26 -6
  220. package/dist/core/session.d.ts +31 -8
  221. package/dist/core/shell-read-silence.js +1 -0
  222. package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
  223. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  224. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  225. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  226. package/dist/core/store-contracts/session-store-contract.js +87 -3
  227. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  228. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  229. package/dist/core/task-event.d.ts +11 -3
  230. package/dist/core/task-notification.d.ts +97 -10
  231. package/dist/core/task-notification.js +129 -5
  232. package/dist/core/task-registry-shared.d.ts +12 -1
  233. package/dist/core/task-registry-shared.js +3 -1
  234. package/dist/core/task-registry-workflow.d.ts +1 -1
  235. package/dist/core/task-registry-workflow.js +9 -1
  236. package/dist/core/task-registry.d.ts +39 -2
  237. package/dist/core/task-registry.js +76 -12
  238. package/dist/core/task-result.d.ts +13 -0
  239. package/dist/core/task-spec-members.d.ts +3 -1
  240. package/dist/core/task-spec-members.js +11 -3
  241. package/dist/core/task-spec.d.ts +57 -23
  242. package/dist/core/tool-catalog-entries.js +4 -0
  243. package/dist/core/tool-face-reader.js +1 -1
  244. package/dist/core/tool-face.d.ts +7 -0
  245. package/dist/core/tool-face.js +1 -0
  246. package/dist/core/tool-mount-facts.d.ts +5 -3
  247. package/dist/core/tool-mount-facts.js +4 -3
  248. package/dist/core/tool-mount-plan.d.ts +7 -3
  249. package/dist/core/tool-mount-plan.js +11 -5
  250. package/dist/core/tool-mount-static.d.ts +2 -2
  251. package/dist/core/tool-mount-static.js +28 -14
  252. package/dist/core/tool-registry.d.ts +33 -1
  253. package/dist/core/tool-registry.js +33 -0
  254. package/dist/core/tool-result-store.d.ts +19 -2
  255. package/dist/core/tool-result-store.js +51 -2
  256. package/dist/core/tool-roster.d.ts +16 -0
  257. package/dist/core/tool-roster.js +6 -0
  258. package/dist/core/tool-spec.d.ts +13 -4
  259. package/dist/core/tools.d.ts +6 -0
  260. package/dist/core/tools.js +1 -1
  261. package/dist/core/user-attachment.d.ts +5 -1
  262. package/dist/core/user-attachment.js +14 -7
  263. package/dist/core/wiring-manifest.d.ts +89 -29
  264. package/dist/core/wiring-manifest.js +44 -4
  265. package/dist/core/workflow-journal-store.d.ts +53 -10
  266. package/dist/core/workflow-journal-store.js +27 -4
  267. package/dist/core/workflow-run-store-contract.js +16 -0
  268. package/dist/core/workflow-run-store.d.ts +9 -7
  269. package/dist/core/workflow-run-store.js +4 -1
  270. package/dist/engine/execution-env/node-execution-env.js +3 -1
  271. package/dist/engine/harness/messages.d.ts +1 -1
  272. package/dist/engine/harness/messages.js +2 -1
  273. package/dist/engine/harness/types.d.ts +24 -1
  274. package/dist/engine/harness/types.js +10 -0
  275. package/dist/engine/llm/types.d.ts +5 -7
  276. package/dist/engine/loop/types.d.ts +2 -0
  277. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  278. package/dist/engine/session/import-validate.js +6 -1
  279. package/dist/engine/session/session.d.ts +15 -2
  280. package/dist/engine/session/session.js +35 -5
  281. package/dist/index.d.ts +27 -12
  282. package/dist/index.js +20 -8
  283. package/dist/orchestration/run-workflow-tool.js +40 -32
  284. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  285. package/dist/orchestration/workflow-park-adoption.js +47 -12
  286. package/dist/orchestration/workflow-stop.d.ts +128 -0
  287. package/dist/orchestration/workflow-stop.js +156 -0
  288. package/dist/orchestration/workflow.d.ts +30 -6
  289. package/dist/orchestration/workflow.js +117 -54
  290. package/dist/prompts/manager-recipe.d.ts +18 -0
  291. package/dist/prompts/manager-recipe.js +24 -0
  292. package/dist/stores/file/adoption/marker.d.ts +2 -27
  293. package/dist/stores/file/adoption/marker.js +12 -0
  294. package/dist/stores/file/index.d.ts +1 -1
  295. package/dist/stores/file/index.js +1 -1
  296. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  297. package/dist/stores/file/permission-rule-store.js +0 -1
  298. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  299. package/dist/stores/file/workflow-journal-store.js +93 -5
  300. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  301. package/dist/tools/artifact/artifact-tool.js +11 -6
  302. package/dist/tools/fs/file-read-check.d.ts +45 -11
  303. package/dist/tools/fs/file-read-check.js +200 -57
  304. package/dist/tools/fs/file-write-check.js +9 -3
  305. package/dist/tools/fs/index.d.ts +8 -7
  306. package/dist/tools/fs/index.js +4 -4
  307. package/dist/tools/fs/judged-reads.d.ts +51 -0
  308. package/dist/tools/fs/judged-reads.js +68 -0
  309. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  310. package/dist/tools/fs/read-deny-home.js +5 -5
  311. package/dist/tools/fs/read-deny.d.ts +33 -8
  312. package/dist/tools/fs/read-deny.js +114 -25
  313. package/dist/tools/fs/safety.d.ts +12 -1
  314. package/dist/tools/fs/safety.js +16 -3
  315. package/dist/tools/fs/shell-read-check.d.ts +25 -5
  316. package/dist/tools/fs/shell-read-check.js +100 -15
  317. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  318. package/dist/tools/fs/shell-read-establish.js +34 -14
  319. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  320. package/dist/tools/fs/shell-read-judge.js +26 -7
  321. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  322. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  323. package/dist/tools/scheduler-store-move.d.ts +74 -0
  324. package/dist/tools/scheduler-store-move.js +103 -0
  325. package/dist/tools/scheduler-tools.d.ts +43 -29
  326. package/dist/tools/scheduler-tools.js +161 -118
  327. package/package.json +2 -2
  328. package/test/export-surface.snapshot.json +173 -3
  329. package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
  330. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  331. package/wire-changes/answers/core@7.72.0.json +84 -0
  332. package/wire-changes/answers/core@7.73.0.json +216 -0
  333. package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
  334. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  335. package/wire-changes/answers/primitives@7.72.0.json +6 -0
  336. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  337. package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
  338. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  339. package/wire-changes/core-stores-sql@7.72.0.json +215 -0
  340. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  341. package/wire-changes/core@7.72.0.json +2426 -0
  342. package/wire-changes/core@7.73.0.json +6480 -0
  343. package/wire-changes/mods-kernel@7.72.0.json +147 -0
  344. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  345. package/wire-changes/primitives@7.72.0.json +143 -0
  346. package/wire-changes/primitives@7.73.0.json +227 -0
  347. package/wire-changes/wiki-gate@7.72.0.json +145 -0
  348. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -27,8 +27,10 @@ function fatesSaid(waitedFor) {
27
27
  .join("; ");
28
28
  }
29
29
  const counted = (n) => `${n} background task${n === 1 ? "" : "s"}`;
30
- export function interruptUnconsumedNotice(waitedFor, origin, ids) {
31
- const tail = "the answer stands as the result, the run ends completed, and no interruption marker or limit code records the stop.";
30
+ export function interruptUnconsumedNotice(waitedFor, origin, ids, crossedAxis) {
31
+ const tail = crossedAxis !== undefined
32
+ ? `the answer stands as the result and the run ends completed; no interruption marker records the stop, and the result records the ${crossedAxis} limit it ended past.`
33
+ : "the answer stands as the result, the run ends completed, and no interruption marker or limit code records the stop.";
32
34
  if (waitedFor.length === 0) {
33
35
  return { code: "task.interrupt_unconsumed", message: `a stop arrived after the run had already given its answer: nothing was cut or stopped by it — ${tail}`, detail: { ...ids, origin, waitedFor: [] } };
34
36
  }
@@ -39,6 +41,11 @@ export function interruptUnconsumedNotice(waitedFor, origin, ids) {
39
41
  detail: { ...ids, origin, waitedFor: waitedFor.map((t) => ({ ...t })) },
40
42
  };
41
43
  }
44
+ export function ceilingTurnNote(waitedFor, ceilingMs) {
45
+ const left = waitedFor.length > 0 ? ` ${counted(waitedFor.length)} you started ${waitedFor.length === 1 ? "has" : "have"} not finished (${fatesSaid(waitedFor)}).` : "";
46
+ return (`[Engine note] The wait for the work you dispatched reached its ceiling (${ceilingMs} ms), so this run ends after this turn.${left} ` +
47
+ "Nothing from them reaches your result. Tell the person what is missing — call SendUserMessage with the gap and what it means for your conclusions — then end.");
48
+ }
42
49
  export function waitCeilingReachedNotice(waitedFor, ceilingMs, ids) {
43
50
  return {
44
51
  code: "task.wait_ceiling_reached",
@@ -1,3 +1,4 @@
1
+ export { failedPreRunResult } from "./terminal-account.js";
1
2
  import type { CheckpointToken } from "../checkpoint-store.js";
2
3
  import type { PushQueue } from "../push-queue.js";
3
4
  import type { SessionStore } from "../session.js";
@@ -1,4 +1,5 @@
1
1
  import { thrownFailureOf } from "./terminal-account.js";
2
+ export { failedPreRunResult } from "./terminal-account.js";
2
3
  import { compensateUnstarted, reopenReasonOf, resumeAgainMayCure, rowKeepsWhatItsRetryNeeds, unstartedFailureOf, unstartedRowSentence } from "../resume-startup-cause.js";
3
4
  import { resumeDecisionWasNegative } from "./decide-continuation.js";
4
5
  import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
@@ -21,7 +21,8 @@ import { enterConfigDoor, LIVE_OVER_ROW, resolveSeatValue } from "../config-refu
21
21
  import { envOfAssembly, workspaceOfAssembly } from "./prepare-execution-env.js";
22
22
  import { compileReadDeny, readDenyBuiltinConfigOf } from "../../tools/fs/read-deny.js";
23
23
  import { readDenyFloorRefusal } from "../../tools/fs/read-floor.js";
24
- import { unionAddOnly } from "../child-clamp-seats.js";
24
+ import { unionAddOnly, withOwnLegHands } from "../child-clamp-seats.js";
25
+ import { assertRunLedgerDeclaration } from "../run-ledger.js";
25
26
  import { prepareSafetyScan } from "./prepare-safety-scan.js";
26
27
  import { boundOwnToolLists, boundToolListsJudgment, judgeHostToolCeiling, ownListsWhereOf, readToolSelector, refuseNonListToolCeiling } from "./sub-agent-deny-lists.js";
27
28
  import { legRetiredNameView, selectorLayerUnderView } from "../tool-name-aliases.js";
@@ -64,13 +65,16 @@ export function taskStartDoors(input) {
64
65
  const languageDeclared = enterConfigDoor("taskConfig", () => screenLanguageSeat(spec.language));
65
66
  const allowedTools = enterConfigDoor("taskConfig", () => screenAllowedToolsValue(spec.allowedTools, "TaskSpec.allowedTools"));
66
67
  const userAttachmentsSeat = enterConfigDoor("taskConfig", () => screenUserAttachments(spec.userAttachments, { resumeLeg: resume !== undefined }));
68
+ const delegation = effectiveDelegationFacts(internals, resume?.seed.isDelegatedChild);
67
69
  const declaredModeAtDoor = (() => {
68
- const requested = modeRequestAfterResume(permissionModeSeat, recordedModeSeed(resume?.seed.inheritedGate), resume?.outcome);
69
70
  const live = internals?.inheritedGate?.permissionModeCeiling;
70
71
  const ceiling = live !== undefined ? (live.observed ?? live.current) : internals?.inheritedGate?.permissionMode;
72
+ const requested = modeRequestAfterResume(permissionModeSeat, recordedModeSeed(resume?.seed.inheritedGate), resume?.outcome, delegation.isDelegatedChild && ceiling === undefined ? true : undefined);
71
73
  return ceiling === undefined ? (requested ?? "default") : clampPermissionMode(requested, ceiling).effective;
72
74
  })();
73
75
  spec = withModeSeats(spec, declaredModeAtDoor);
76
+ enterConfigDoor("taskConfig", () => assertRunLedgerDeclaration(spec.runLedger));
77
+ spec = enterConfigDoor("taskConfig", () => withOwnLegHands(spec));
74
78
  const planFile = spec.planFile;
75
79
  enterConfigDoor("taskConfig", () => checkedPlanFileShape(planFile));
76
80
  const scanned = spec;
@@ -80,7 +84,6 @@ export function taskStartDoors(input) {
80
84
  const { toolFaceLists } = doors;
81
85
  const ownListsRecord = resolveSeatValue(internals?.ownToolLists, () => resume?.seed.ownToolLists, LIVE_OVER_ROW);
82
86
  const ownToolLists = enterConfigDoor(ownListsRecord.input, () => boundOwnToolLists(ownListsRecord.value, toolFaceLists));
83
- const delegation = effectiveDelegationFacts(internals, resume?.seed.isDelegatedChild);
84
87
  const approvalParkNotResumable = approvalParkNotResumableOf({ engineLaneLeg: engineLaneLegOf(internals), parkLaneHeld: internals?.parkLaneHeld === true, hostDeclaredNotResumable: doors.hostApprovalParksNotResumable });
85
88
  const notResumableSays = notResumableSaysOf(approvalParkNotResumable, doors.hostApprovalParksNotResumable);
86
89
  const overlay = enterConfigDoor("deps", () => contextOverlayFor(deps.contextSettings, doors.resolvedRole.modelRef, deps));
@@ -8,7 +8,7 @@
8
8
  import { type AssistantMessage, type ModelOutputInvalid } from "../../internal/llm.js";
9
9
  import type { LoopTerminalReason } from "../../internal/harness-types.js";
10
10
  import { type RequestRoute } from "../../brain/request-route.js";
11
- import type { TerminalCause } from "../types.js";
11
+ import type { TaskResult, TerminalCause } from "../types.js";
12
12
  import { type TerminalFailureDetail } from "../terminal-cause.js";
13
13
  type ProviderRejected = Extract<TerminalFailureDetail, {
14
14
  kind: "provider_rejected";
@@ -35,6 +35,10 @@ export declare function requestRouteOfMessage(final: AssistantMessage): RequestR
35
35
  * account); `outputLimit` only beside `truncated`, only with a boolean `capStop`, its counts only as non-negative
36
36
  * integers — an unreadable limit leaves the cause standing without it. */
37
37
  export declare function modelOutputInvalidOfMessage(final: AssistantMessage): ModelOutputInvalid | undefined;
38
+ /** Admit one string value for a `coded` failure detail (and any wire mirror of its string members, e.g.
39
+ * `WiringManifest.projectMarkerUnreadable.markerPath`): drops strings over {@link CODED_DETAIL_STRING} (`undefined`)
40
+ * and replaces any string that {@link carriesCredential} with {@link CREDENTIAL_LEAF}; otherwise returns `text` verbatim. */
41
+ export declare function codedDetailStringOf(text: string): string | undefined;
38
42
  /**
39
43
  * Extract a machine-readable code from a thrown error (e.g. `SessionError.code`, a Node error code).
40
44
  * Walks the `cause` chain because the harness wraps lower-level errors (e.g. a `SessionError("conflict")`
@@ -52,6 +56,11 @@ export declare function thrownFailureOf(err: unknown, text: string): {
52
56
  message: string;
53
57
  detail?: TerminalFailureDetail;
54
58
  };
59
+ /** A `failed` TaskResult for a throw that occurred before a Runner leg could start (e.g. the one-shot `runTask(spec, deps)`
60
+ * when `new Runner(deps)` refuses deployment deps): carries the same coded terminal account (`thrownFailureOf`),
61
+ * intake (`{ committed: false }`), unsettled continuation, and zero/usageMissing stats as the stream settle backstop,
62
+ * without invoking any throwing getter on `spec`. */
63
+ export declare function failedPreRunResult(err: unknown, spec: unknown): TaskResult;
55
64
  /** The completion's one account, read off the final message: it ended on a provider word the brain does not read (the
56
65
  * turn was kept and the run announced the word — stated in the echo shape the brain carried it in), or its answer stopped
57
66
  * arriving before the provider ended it and what arrived was kept. A cut stream has no ending word, so the two never meet. */
@@ -4,7 +4,7 @@ import { admittedProviderMessage } from "../../brain/provider-message.js";
4
4
  import { isProviderCondition, isProviderConditionSource } from "../../brain/provider-dialect.js";
5
5
  import { admittedRequestRoute } from "../../brain/request-route.js";
6
6
  import { REFUSED_REQUEST_PARTS } from "../terminal-cause.js";
7
- import { readMember } from "../thrown-value.js";
7
+ import { readMember, thrownText } from "../thrown-value.js";
8
8
  import { egressText } from "../untrusted-egress.js";
9
9
  import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
10
10
  import { isSensitiveRecordKey, REDACTION_MARKS } from "@sema-agent/primitives";
@@ -69,6 +69,11 @@ const INDEX_KEY_RE = /^(?:0|[1-9][0-9]*)$/;
69
69
  function carriesCredential(text) {
70
70
  return looksLikeCredentialValue(text) || egressText("same-principal", text) !== text;
71
71
  }
72
+ export function codedDetailStringOf(text) {
73
+ if (text.length > CODED_DETAIL_STRING)
74
+ return undefined;
75
+ return carriesCredential(text) ? CREDENTIAL_LEAF : text;
76
+ }
72
77
  const NAME_CHARS = 128;
73
78
  function namesCredential(name) {
74
79
  return name.length <= NAME_CHARS && (isSensitiveName(name) || isSensitiveRecordKey(name));
@@ -91,11 +96,11 @@ function leafOf(keyContext, read, depth, budget) {
91
96
  if (value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))
92
97
  return charge(budget, 0) ? value : undefined;
93
98
  if (typeof value === "string") {
94
- if (value.length > CODED_DETAIL_STRING) {
99
+ const shown = codedDetailStringOf(value);
100
+ if (shown === undefined) {
95
101
  budget.cuts++;
96
102
  return undefined;
97
103
  }
98
- const shown = carriesCredential(value) ? CREDENTIAL_LEAF : value;
99
104
  return charge(budget, shown.length) ? shown : undefined;
100
105
  }
101
106
  if (typeof value !== "object")
@@ -246,6 +251,21 @@ export function thrownFailureOf(err, text) {
246
251
  const detail = codedFailureDetailOf(coded.code, coded.link);
247
252
  return { code: coded.code, message, ...(detail !== undefined ? { detail } : {}) };
248
253
  }
254
+ export function failedPreRunResult(err, spec) {
255
+ const { code, message, detail } = thrownFailureOf(err, thrownText(err));
256
+ const specTaskId = readMember(spec, "taskId");
257
+ const specSessionId = readMember(spec, "sessionId");
258
+ return {
259
+ taskId: typeof specTaskId === "string" && specTaskId.length > 0 ? specTaskId : "unknown",
260
+ sessionId: typeof specSessionId === "string" && specSessionId.length > 0 ? specSessionId : "unknown",
261
+ terminal: { kind: "failed", ...(code !== undefined ? { code } : {}), message, ...(detail !== undefined ? { detail } : {}) },
262
+ result: "",
263
+ resultEntryIds: [],
264
+ intake: { committed: false },
265
+ continuesFrom: { none: "unsettled" },
266
+ stats: { turns: 0, tokens: 0, toolCalls: 0, cachedTokens: 0, costMicroUsd: 0, usageMissing: true },
267
+ };
268
+ }
249
269
  export function completedTerminalOf(final) {
250
270
  const finishReasonUnknown = readMember(final, "finishReasonUnknown");
251
271
  if (typeof finishReasonUnknown === "string" && isProviderEchoShape(finishReasonUnknown))
@@ -6,8 +6,8 @@
6
6
  * face declares at most one of the two); an
7
7
  * `approvalCard` must find the keys the card needs; a `ruleFace` may only name scalar keys; `family`
8
8
  * must be a member of the closed set; every `resultCards` entry must live under the tool's own card namespace.
9
- * A failing overlay does NOT mount — the tool mounts BARE (no
10
- * face) and the leg announces `config.tool_face_invalid` once per tool; a `toolFaces` key naming a
9
+ * A failing overlay does NOT mount, and neither does its tool (mounted bare it would drop the protection the overlay declares) —
10
+ * the leg announces `config.tool_face_invalid` once per tool; a `toolFaces` key naming a
11
11
  * tool the listing does not carry announces `config.tool_face_undeclared` once per name. Never a
12
12
  * silent partial application: an overlay is one declaration, applied whole or not at all.
13
13
  *
@@ -31,15 +31,6 @@ export interface FaceTool {
31
31
  }
32
32
  /** Why an overlay is refused — a closed reason list, each a distinct declaration mistake. */
33
33
  export declare function toolFaceProblem(face: McpToolFace, schema: AgentTool["parameters"], tool?: FaceTool): string | undefined;
34
- /**
35
- * The one judge of a face. With the tool's materialized `schema` it is {@link toolFaceProblem}: the declaration against the
36
- * schema it rides on. With no schema it is the same judge over the DECLARATION ALONE (`readToolFaces`, `core/tool-face-reader.ts`): every
37
- * check that needs the schema's keys (a path target's `param` / `patternParam`, an approval card's required keys, the names a summary or a
38
- * rule face lists) waits for the listing; the closed words, the bounds and the cross-member rules do not need it and are the same
39
- * checks, in the same order, with the same sentences. A face this judges is a well-typed one (the reader types it first). A tool that
40
- * holds its card namespace (`tool.cardId`) has its `resultCards` held to it here too, so a caller's face and a server's face are
41
- * judged by this one function, not by a rule beside it.
42
- */
43
34
  export declare function faceProblem(face: McpToolFace, schema: AgentTool["parameters"] | undefined, tool?: FaceTool): string | undefined;
44
35
  export interface ApplyToolFacesInput {
45
36
  /** The materialized tools of ONE server (namespaced names). */
@@ -22,6 +22,24 @@ export const APPROVAL_CARD_REQUIRED_KEYS = Object.freeze({
22
22
  export function toolFaceProblem(face, schema, tool) {
23
23
  return faceProblem(face, schema, tool);
24
24
  }
25
+ function schemaPropertyOf(schema, name) {
26
+ const props = schema?.properties;
27
+ return props !== null && typeof props === "object" && Object.hasOwn(props, name) ? props[name] : undefined;
28
+ }
29
+ function schemaTakesOnlyStrings(node) {
30
+ if (node === null || typeof node !== "object")
31
+ return false;
32
+ const s = node;
33
+ const t = s["type"];
34
+ const listOnly = (v, each) => Array.isArray(v) && v.length > 0 && v.every(each);
35
+ return (t === "string" ||
36
+ listOnly(t, (x) => x === "string") ||
37
+ (Array.isArray(s["allOf"]) && s["allOf"].some(schemaTakesOnlyStrings)) ||
38
+ listOnly(s["anyOf"], schemaTakesOnlyStrings) ||
39
+ listOnly(s["oneOf"], schemaTakesOnlyStrings) ||
40
+ typeof s["const"] === "string" ||
41
+ listOnly(s["enum"], (e) => typeof e === "string"));
42
+ }
25
43
  export function faceProblem(face, schema, tool) {
26
44
  const bound = schema === undefined ? undefined : inputKeysOf(schema);
27
45
  const top = bound === undefined ? undefined : new Set(bound.keys.map((k) => k.name));
@@ -59,6 +77,27 @@ export function faceProblem(face, schema, tool) {
59
77
  if (absent !== "base")
60
78
  return `pathTarget.patternParam is declared but pathTarget.absent is ${JSON.stringify(absent ?? "none")} — the pattern base is only ever read for an absent slot, so this declaration would be inert`;
61
79
  }
80
+ const each = face.pathTarget.each;
81
+ if (each !== undefined && typeof each !== "boolean")
82
+ return `pathTarget.each is ${typeof each}, not a boolean (true, or absent)`;
83
+ if (each === true && face.pathTarget.access !== "read")
84
+ return `pathTarget.each needs pathTarget.access "read" — a slot that names several targets is a read's; a write names one file`;
85
+ const slotType = bound?.keys.find((k) => k.name === face.pathTarget.param)?.type;
86
+ if (each === true && slotType !== undefined && slotType !== "array" && slotType !== "mixed")
87
+ return `pathTarget.each is declared but the schema types pathTarget.param as ${slotType}: a slot that names several targets takes a string or a list of strings`;
88
+ if (each !== true && face.pathTarget.access === "read" && schema !== undefined) {
89
+ for (const name of [face.pathTarget.param, ...(face.pathTarget.aliases ?? [])]) {
90
+ const node = schemaPropertyOf(schema, name);
91
+ if (node === undefined || schemaTakesOnlyStrings(node))
92
+ continue;
93
+ const t = bound?.keys.find((k) => k.name === name)?.type;
94
+ if (t === "array")
95
+ return `pathTarget ${callerText(name)} is a list in the tool's schema but pathTarget.each is not declared: the slot would never be read as a target — declare each: true to have every element judged`;
96
+ if (t === "mixed")
97
+ return `pathTarget ${callerText(name)} may carry a value that is not a string in the tool's schema (a union, an untyped slot, or a form this door does not read as strings only) but pathTarget.each is not declared — a read target that names one file takes a string: type it a string, or declare each: true for a string or a list of strings`;
98
+ return `pathTarget ${callerText(name)} is typed ${t ?? "something other than a string"} in the tool's schema, but a read target names a file by a string — type it a string`;
99
+ }
100
+ }
62
101
  const long = overlong("pathTarget.param", [face.pathTarget.param]) ??
63
102
  overlong("pathTarget.aliases", face.pathTarget.aliases ?? []) ??
64
103
  overlong("pathTarget.patternParam", patternParam === undefined ? [] : [patternParam]);
@@ -2,14 +2,19 @@ import { CONTEXT_TRIM_NOTICE, roomShortfallOf } from "../context-guard.js";
2
2
  import { messageRole } from "../message-utils.js";
3
3
  import { isPersonsWordsRow } from "../user-row-origin.js";
4
4
  import { createMessagesOmittedSeat } from "./messages-omitted-seat.js";
5
+ function rowKeyOf(row) {
6
+ if (row === undefined)
7
+ return "";
8
+ const own = row;
9
+ return messageRole(row) === "compactionSummary" && typeof own.entryId === "string" ? `compactionSummary#${own.entryId}` : `${messageRole(row)}:${String(own.timestamp)}`;
10
+ }
5
11
  export function createTrimStretch(ids) {
6
12
  const announce = createMessagesOmittedSeat(ids);
7
13
  let start;
8
14
  let head;
9
15
  return {
10
16
  begin(view) {
11
- const first = view[0];
12
- const key = first !== undefined ? `${messageRole(first)}:${String(first.timestamp)}` : "";
17
+ const key = rowKeyOf(view[0]);
13
18
  if (head !== undefined && key !== head) {
14
19
  start = undefined;
15
20
  announce(0);
@@ -3,7 +3,8 @@
3
3
  * (`EffectivePermissionRules.unreadableRows`), as the run's readers judge them. A row whose identity read stands in the read's rules as
4
4
  * written (`as_read`): these readers pass it by. A row whose identity did not read stands at its strictest reading over the calls it may
5
5
  * reach — the partition's own failure law, scoped to the row (a call it reaches in its scope takes the answer a call takes while a
6
- * partition cannot be read; a row reaching every call makes every path check that is no call refuse).
6
+ * partition cannot be read; a row reaching every call in its scope makes every path check that is no call refuse — the scope first, by
7
+ * {@link unreadableRowsInScope}, for every reader).
7
8
  */
8
9
  import type { EffectivePermissionRules } from "../permission-rule-provider.js";
9
10
  import { type ScopeRootIdentity } from "../permission-rule-model.js";
@@ -68,6 +68,9 @@ export interface RunnerDeps {
68
68
  /** The deployment's Brain; every engine read of it goes through the model lane (`brain/model-lane.ts`), which walks a catalog
69
69
  * entry's `Model.fallbacks` chain on this same Brain and passes any other request straight through. */
70
70
  brain: Brain;
71
+ /** Deployment-declared host process identity (`{ instanceId, startedAt }`, epoch ms), projected frozen onto `WiringManifest.host`
72
+ * on both static and effective halves iff declared; refused (`config.invalid_argument`) when malformed; out of `configFingerprint` and `swapDeps`. */
73
+ host?: import("./host-instance.js").HostInstanceDeclaration;
71
74
  /** Catalog used to resolve string ModelRefs to Model objects; its door (`new Runner` / `swapDeps`) also resolves each entry's
72
75
  * `fallbacks` words over it (`config.model_fallback_invalid` on a bad chain). */
73
76
  models?: Record<string, Model>;
@@ -154,13 +157,13 @@ export interface RunnerDeps {
154
157
  */
155
158
  hands?: HandsBandOptions;
156
159
  /**
157
- * design/199 件B — DEPLOYMENT-layer ADDITIONS to the built-in sensitive-path READ deny set
160
+ * design/199 件B / #4800 — DEPLOYMENT-layer ADDITIONS to the sensitive-path deny set
158
161
  * ({@link import("../tools/fs/read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}); see
159
- * {@link TaskSpec.readDenyPatterns} for the judged surfaces. INDEPENDENT of the built-in switch. Add-only on
160
- * THIS seat: unions with the active built-ins and any task-layer additions, and `[]` ≡ absent — narrowing the built-in
161
- * set is the sibling knobs' job ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude},
162
- * #245 revision of D-4), not a replacement escape hatch here. Bad entry shapes refuse loudly at
163
- * prepare (#123).
162
+ * {@link TaskSpec.readDenyPatterns} for the judged surfaces and the shell's reach: reads and writes both, while
163
+ * built-in tiers stay read-only and pair with the write-protection table. Add-only on THIS seat: unions with the
164
+ * active built-ins and any task-layer additions, and `[]` ≡ absent — narrowing the built-in set is the sibling
165
+ * knobs' job ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude}, #245 revision of D-4), not a
166
+ * replacement escape hatch here. Bad entry shapes refuse loudly at prepare (#123).
164
167
  */
165
168
  readDenyPatterns?: readonly import("../tools/fs/read-deny.js").ReadDenyEntry[];
166
169
  /**
@@ -1329,10 +1332,10 @@ export interface RunnerDeps {
1329
1332
  * deployment wires the factory.
1330
1333
  */
1331
1334
  executionEnvFactory?: import("./remote-env.js").ExecutionEnvFactory;
1332
- /** Whether `executionEnvFactory` answers purpose `"read_changes"` (attaches or throws `env.purpose_unsupported`; mints and
1333
- * writes nothing). Absent / `false` ⇒ never asked for it, and no static `executionEnv` stands in: reading what a session
1334
- * changed has no hands for the working tree. A Runner with no factory ignores the value (a deployment spreads one set of keys
1335
- * into every Runner, some with only a static env); a non-boolean is refused at construction (`config.invalid_argument`). */
1335
+ /** Whether `executionEnvFactory` answers purpose `"read_changes"` (read-only readings outside a run — `Runner.readSessionChanges`,
1336
+ * `Runner.previewInstructions`: attaches or throws `env.purpose_unsupported`; mints and writes nothing). Absent / `false` ⇒ never
1337
+ * asked for it, and no static `executionEnv` stands in: those out-of-run reads have no hands for the working tree. A Runner with no
1338
+ * factory ignores the value; a non-boolean is refused at construction (`config.invalid_argument`). */
1336
1339
  executionEnvFactoryHonorsReadChanges?: boolean;
1337
1340
  /**
1338
1341
  * Containment root for the file tools (design/44 §4 invariant 7): every path must resolve within it, else the tool rejects
@@ -84,12 +84,13 @@ export interface ScheduledIntent {
84
84
  */
85
85
  export interface SchedulerContext {
86
86
  /**
87
- * 越界隔离键(cancel/list 只能操作同 scope 排的)。由 Runner 填,且**按被操作 intent 的 lifetime 分叉**
88
- * (ruled 2026-08-03):`lifetime:"session"` 的意图用会话链(sessionId ?? 隔离格 ?? taskId ?? 匿名工作区,`sessionLaneScopeOf`);
89
- * durable 意图用跨会话稳定身份(`scopeKeyOf`:隔离格,缺则匿名工作区 `ANONYMOUS_SCOPE`)——否则 durable job 会被钉死在排它的那个会话里,
90
- * 后续会话 cancel/list 一律 `not_found`(任务照常触发却再也删不掉)。backend 侧无需分辨腿别:照旧只按
91
- * 收到的 `scope` 隔离即可;**同一 daemon 上两类键共存**,一次 `list` 只回本 scope 的行(工具壳自己并两腿)。
92
- * ⚠️ 部署面:本分叉之前写下的 durable 行仍带旧的会话键,一次性重铸键归 backend 半场,engine 不做迁移。
87
+ * 越界隔离键(cancel/list 只能操作同 scope 排的)= lane 名 + `:` + 主人,由引擎铸(`schedulerLanesOf`):session lane
88
+ * `session:<sessionId>`(会话层任务与唤醒条目);durable lane `durable:<隔离格>`(`scopeKeyOf`:隔离格,缺则匿名工作区,即
89
+ * `durable:default`)——耐久任务活过排它的会话,后续会话照样列得出、停得掉。lane 名不含 `:`,两条 lane 的键永不相等:
90
+ * 某人的主体名恰是另一会话的号时,双方互不可见。backend 侧无需分辨 lane:照旧只按收到的 `scope` 隔离,把它当不透明的串。
91
+ * 7.72.0 之前写下的行是裸键(只有主人):后端用 `migrateSchedulerStore` 把它们放到 lane 键下 —— 整店迁一次(与 `scopeKeys: "lane"`
92
+ * 同一次写落下),或保留盘上形、每次读时在端口换算;回滚用 `rollbackSchedulerStore`;后端没声明 `scopeKeys: "lane"` 时引擎不对它说话
93
+ * (两条路与读时换算的义务见 {@link SchedulerCapability.schedulerCapabilities.scopeKeys})。
93
94
  */
94
95
  scope: string;
95
96
  /** 排程者身份;daemon 触发时原样传给 runTask(防权限抬升)。 */
@@ -192,6 +193,23 @@ export interface SchedulerCapability {
192
193
  * accept refuses the scheduler tools' mount (`config.invalid_argument`). Immutable for the backend's lifetime, like the bits above.
193
194
  */
194
195
  readonly timeZone?: string;
196
+ /**
197
+ * Which keys this backend takes and answers at its port: `"lane"` = the backend takes and answers lane keys at its verbs
198
+ * ({@link SchedulerContext.scope}, `session:<id>` / `durable:<scope>`, 7.72.0 — every row it lists, cancels or fires is filed, as the
199
+ * engine sees it, under exactly one lane key; how the backend keeps its rows is its own business); `"bare"` = it answers keys as a
200
+ * release before 7.72.0 filed them. The engine speaks to a backend only in lane keys, so only `"lane"` mounts the scheduler tools and
201
+ * is read by the host readers — absent, `"bare"` or any other value mounts nothing (the operator is told, `config.scheduler_store_unmoved`,
202
+ * when the seam is otherwise mounted) and the readers answer `unsupported`, before the backend is asked. A backend gets there either by moving its store once (`migrateSchedulerStore`,
203
+ * writing `moved` and the declaration in one write) or by keeping bare keys stored and placing each row at the port on every read with
204
+ * the same function, which answers each row with one lane key or one refusal and nothing more. Such a backend must: hand it the whole store
205
+ * on each read (it sees a shared lane key only among the rows of one call); keep every refused row out of every verb — listed, cancelled,
206
+ * fired — and report it to the operator; store each row written through the port so that it reads back under the lane key it was written
207
+ * with (the intent's `lifetime` / `mode` as written and the key's lane as `lane`; a durable row under its owner as its stored key; a
208
+ * session row with its `sessionId`, under one bare key for every row of that session lane); and declare `"lane"` as its own
209
+ * constant — it then never meets the readers' refusal or the notice, which name the store move. Immutable for the backend's lifetime,
210
+ * like the bits above.
211
+ */
212
+ readonly scopeKeys?: SchedulerScopeKeys;
195
213
  };
196
214
  /**
197
215
  * 持久化一个未来意图。`intent` = 模型可控(无身份);`ctx` = Runner-held 可信上下文(principal/scope/...)。返回不透明
@@ -210,7 +228,29 @@ export interface SchedulerCapability {
210
228
  /** 列**本 scope** 已排意图(self-discovery + 防重复排)。范围 = `ctx.scope`,非全局。 */
211
229
  list(ctx: SchedulerContext): Promise<Result<ScheduledTaskSummary[], SchedulerError>>;
212
230
  }
231
+ /** The two key forms a scheduler backend declares at its port ({@link SchedulerCapability.schedulerCapabilities.scopeKeys}). */
232
+ export type SchedulerScopeKeys = "lane" | "bare";
233
+ /** Whether a scheduler declaration says the backend answers lane keys at its port — the one reading of {@link SchedulerScopeKeys} the engine acts on. */
234
+ export declare function declaresLaneKeys(capabilities: unknown): boolean;
235
+ /** A declared `scopeKeys` as an account names it: a word of {@link SchedulerScopeKeys} as written, any other value as the refusal describer
236
+ * writes it (a host's string is never echoed). */
237
+ export declare function describeScopeKeys(value: unknown): string;
238
+ /**
239
+ * One reading of an env's scheduler declaration — `schedulerCapabilities` read once, the seam's methods judged once: `"none"` (no seam, or
240
+ * one that does not declare `supported: true`), `"unmoved"` (it does, but does not declare `scopeKeys: "lane"`) or `"mounted"`. A leg reads
241
+ * it once and hands the reading to every judge of its own (the mount facts, the tools, the notice), so a backend whose declaration is a getter
242
+ * is asked once per leg and the leg never acts on two answers.
243
+ */
244
+ export type SchedulerReading = {
245
+ readonly kind: "none";
246
+ } | {
247
+ readonly kind: "unmoved" | "mounted";
248
+ readonly seam: ExecutionEnv & SchedulerCapability;
249
+ readonly capabilities: SchedulerCapability["schedulerCapabilities"];
250
+ };
251
+ export declare function readSchedulerDeclaration(env: ExecutionEnv): SchedulerReading;
213
252
  /**
214
- * 结构 + 语义检测:`env` 是否暴露 scheduler 能力且声明 `supported:true`。挂载门控用此(对齐 `hasBackgroundShell`)。
253
+ * 结构 + 语义检测:`env` 是否暴露 scheduler 能力、声明 `supported:true`,且声明端口收发 lane 键(`scopeKeys: "lane"`)。挂载门控用此
254
+ * (对齐 `hasBackgroundShell`);一条腿的准备读的是 {@link readSchedulerDeclaration} 的同一个读数。
215
255
  */
216
256
  export declare function hasScheduler(env: ExecutionEnv): env is ExecutionEnv & SchedulerCapability;
@@ -1,3 +1,4 @@
1
+ import { describeRejectedValue } from "./tool-search-setting.js";
1
2
  export class SchedulerError extends Error {
2
3
  code;
3
4
  cause;
@@ -8,12 +9,23 @@ export class SchedulerError extends Error {
8
9
  this.name = "SchedulerError";
9
10
  }
10
11
  }
11
- export function hasScheduler(env) {
12
+ const SCOPE_KEYS = ["lane", "bare"];
13
+ export function declaresLaneKeys(capabilities) {
14
+ return typeof capabilities === "object" && capabilities !== null && capabilities.scopeKeys === "lane";
15
+ }
16
+ export function describeScopeKeys(value) {
17
+ return SCOPE_KEYS.includes(value) ? value : describeRejectedValue(value);
18
+ }
19
+ export function readSchedulerDeclaration(env) {
12
20
  const e = env;
13
- return (typeof e.schedule === "function" &&
14
- typeof e.cancel === "function" &&
15
- typeof e.list === "function" &&
16
- typeof e.schedulerCapabilities === "object" &&
17
- e.schedulerCapabilities !== null &&
18
- e.schedulerCapabilities.supported === true);
21
+ if (typeof e.schedule !== "function" || typeof e.cancel !== "function" || typeof e.list !== "function")
22
+ return { kind: "none" };
23
+ const capabilities = e.schedulerCapabilities;
24
+ if (typeof capabilities !== "object" || capabilities === null || capabilities.supported !== true)
25
+ return { kind: "none" };
26
+ const held = capabilities;
27
+ return { kind: declaresLaneKeys(held) ? "mounted" : "unmoved", seam: env, capabilities: held };
28
+ }
29
+ export function hasScheduler(env) {
30
+ return readSchedulerDeclaration(env).kind === "mounted";
19
31
  }