@sema-agent/core 7.55.0 → 7.56.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 (418) hide show
  1. package/CHANGELOG.md +513 -0
  2. package/dist/agents/cascade.js +1 -1
  3. package/dist/agents/cc-peer-directory.js +1 -0
  4. package/dist/agents/child-model-seat.d.ts +0 -11
  5. package/dist/agents/child-model-seat.js +0 -3
  6. package/dist/agents/list-agents-tool.d.ts +3 -1
  7. package/dist/agents/list-agents-tool.js +7 -7
  8. package/dist/agents/peer-directory.d.ts +22 -4
  9. package/dist/agents/peer-directory.js +24 -2
  10. package/dist/agents/peer-session-drain.js +2 -2
  11. package/dist/agents/repair-loop.js +2 -2
  12. package/dist/agents/send-message-tool.js +4 -4
  13. package/dist/agents/subagent.d.ts +6 -4
  14. package/dist/agents/subagent.js +64 -60
  15. package/dist/agents/tool-filter.d.ts +7 -5
  16. package/dist/agents/tool-filter.js +12 -9
  17. package/dist/agents/verify.d.ts +3 -2
  18. package/dist/agents/verify.js +3 -3
  19. package/dist/brain/anthropic.js +30 -73
  20. package/dist/brain/media-degrade.d.ts +18 -7
  21. package/dist/brain/media-degrade.js +13 -2
  22. package/dist/brain/model-capability.d.ts +37 -0
  23. package/dist/brain/model-capability.js +34 -0
  24. package/dist/brain/model-presets.d.ts +2 -8
  25. package/dist/brain/model-presets.js +1 -6
  26. package/dist/brain/open-responses.js +13 -26
  27. package/dist/brain/openai.js +14 -87
  28. package/dist/brain/reasoning-request.d.ts +96 -0
  29. package/dist/brain/reasoning-request.js +174 -0
  30. package/dist/brain/reasoning.d.ts +11 -11
  31. package/dist/brain/reasoning.js +4 -3
  32. package/dist/brain/request-params.d.ts +7 -4
  33. package/dist/brain/request-params.js +7 -4
  34. package/dist/brain/status-sink.d.ts +20 -0
  35. package/dist/brain/status-sink.js +7 -0
  36. package/dist/core/a2a.d.ts +2 -1
  37. package/dist/core/a2a.js +19 -13
  38. package/dist/core/agent-definition.d.ts +10 -0
  39. package/dist/core/allow-entry.d.ts +20 -13
  40. package/dist/core/allow-entry.js +26 -22
  41. package/dist/core/allow-rule-shadow.d.ts +3 -3
  42. package/dist/core/ask-origin.d.ts +64 -18
  43. package/dist/core/ask-origin.js +63 -23
  44. package/dist/core/ask-question.d.ts +51 -8
  45. package/dist/core/ask-question.js +3 -4
  46. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  47. package/dist/core/ask-unresolvable-notice.js +16 -2
  48. package/dist/core/checkpoint-generation.d.ts +53 -0
  49. package/dist/core/checkpoint-generation.js +35 -0
  50. package/dist/core/checkpoint-queries.d.ts +180 -0
  51. package/dist/core/checkpoint-queries.js +272 -0
  52. package/dist/core/checkpoint-requirements.d.ts +13 -1
  53. package/dist/core/checkpoint-requirements.js +4 -0
  54. package/dist/core/checkpoint-store.d.ts +88 -24
  55. package/dist/core/checkpoint-store.js +24 -9
  56. package/dist/core/cross-boundary-taint.d.ts +6 -5
  57. package/dist/core/cross-boundary-taint.js +1 -3
  58. package/dist/core/decision-receipt.d.ts +37 -3
  59. package/dist/core/decision-receipt.js +17 -17
  60. package/dist/core/delegation-not-started.d.ts +6 -0
  61. package/dist/core/delegation-not-started.js +17 -0
  62. package/dist/core/engine-attestation.d.ts +93 -0
  63. package/dist/core/engine-attestation.js +70 -0
  64. package/dist/core/engine-capabilities.d.ts +4 -1
  65. package/dist/core/engine-capabilities.js +1 -1
  66. package/dist/core/engine-notice.d.ts +30 -11
  67. package/dist/core/file-history-store.d.ts +90 -14
  68. package/dist/core/file-history-store.js +23 -15
  69. package/dist/core/gate-fold.d.ts +1 -1
  70. package/dist/core/gate-fold.js +22 -10
  71. package/dist/core/gate-lanes.js +73 -64
  72. package/dist/core/gate-outcome.d.ts +26 -5
  73. package/dist/core/gate-outcome.js +26 -0
  74. package/dist/core/governance-codes.d.ts +5 -1
  75. package/dist/core/governance-codes.js +6 -0
  76. package/dist/core/hooks.d.ts +17 -16
  77. package/dist/core/hooks.js +3 -1
  78. package/dist/core/host-floor.d.ts +128 -0
  79. package/dist/core/host-floor.js +206 -0
  80. package/dist/core/host-target.d.ts +38 -3
  81. package/dist/core/host-target.js +38 -5
  82. package/dist/core/mcp.d.ts +5 -1
  83. package/dist/core/mcp.js +67 -41
  84. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  85. package/dist/core/memory-engine/engine.js +4 -4
  86. package/dist/core/memory-engine/layout.d.ts +60 -8
  87. package/dist/core/memory-engine/layout.js +65 -6
  88. package/dist/core/model-seat.d.ts +10 -3
  89. package/dist/core/mods/classic-events.d.ts +67 -0
  90. package/dist/core/mods/classic-events.js +1 -0
  91. package/dist/core/mods/dollar.d.ts +13 -0
  92. package/dist/core/mods/extension-call.d.ts +31 -0
  93. package/dist/core/mods/extension-call.js +43 -0
  94. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  95. package/dist/core/mods/kernel/dispatch.js +140 -69
  96. package/dist/core/mods/kernel/events.d.ts +47 -11
  97. package/dist/core/mods/kernel/events.js +66 -42
  98. package/dist/core/mods/kernel/index.d.ts +4 -4
  99. package/dist/core/mods/kernel/index.js +2 -2
  100. package/dist/core/mods/kernel/receive.d.ts +39 -5
  101. package/dist/core/mods/kernel/receive.js +290 -17
  102. package/dist/core/mods/kernel/registration.d.ts +33 -2
  103. package/dist/core/mods/kernel/registration.js +6 -7
  104. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  105. package/dist/core/mods/kernel/site-rules.js +24 -42
  106. package/dist/core/mods/spec-seats.d.ts +69 -0
  107. package/dist/core/mods/spec-seats.js +114 -0
  108. package/dist/core/mods/stations.d.ts +28 -8
  109. package/dist/core/mods/stations.js +29 -13
  110. package/dist/core/mods/tool-call.d.ts +79 -0
  111. package/dist/core/mods/tool-call.js +152 -0
  112. package/dist/core/namespaced-rule-name.d.ts +32 -38
  113. package/dist/core/namespaced-rule-name.js +29 -36
  114. package/dist/core/parent-spec-seat.d.ts +6 -1
  115. package/dist/core/parent-spec-seat.js +2 -0
  116. package/dist/core/park-selfcheck.js +1 -0
  117. package/dist/core/permission-rule-consent.d.ts +19 -0
  118. package/dist/core/permission-rule-consent.js +116 -26
  119. package/dist/core/permission-rule-model.d.ts +14 -3
  120. package/dist/core/permission-rule-model.js +39 -24
  121. package/dist/core/permission-rule-org.d.ts +6 -2
  122. package/dist/core/permission-rule-org.js +7 -3
  123. package/dist/core/permission-rule-provider.d.ts +5 -2
  124. package/dist/core/permission-rule-provider.js +41 -11
  125. package/dist/core/permission-rule-store.d.ts +3 -2
  126. package/dist/core/permission-rule-store.js +11 -2
  127. package/dist/core/permission-rule-sync.js +3 -2
  128. package/dist/core/permission-rule-syntax.d.ts +5 -4
  129. package/dist/core/permission-rule-syntax.js +2 -2
  130. package/dist/core/permission-rules.d.ts +4 -4
  131. package/dist/core/permission-rules.js +11 -20
  132. package/dist/core/persisted-rule-arms.d.ts +2 -2
  133. package/dist/core/persisted-rule-arms.js +10 -12
  134. package/dist/core/principal-name.d.ts +20 -0
  135. package/dist/core/principal-name.js +22 -0
  136. package/dist/core/prompt-section-seat.js +4 -6
  137. package/dist/core/protocol-http-auth.d.ts +26 -5
  138. package/dist/core/protocol-http-auth.js +137 -4
  139. package/dist/core/retired-keys.d.ts +16 -0
  140. package/dist/core/retired-keys.js +16 -4
  141. package/dist/core/rewrite-rejudge.d.ts +60 -0
  142. package/dist/core/rewrite-rejudge.js +36 -0
  143. package/dist/core/roles.d.ts +28 -1
  144. package/dist/core/roles.js +31 -19
  145. package/dist/core/rule-lane-reads.d.ts +20 -15
  146. package/dist/core/rule-lane-reads.js +45 -17
  147. package/dist/core/rule-owner.d.ts +3 -3
  148. package/dist/core/rule-owner.js +3 -2
  149. package/dist/core/runner/announce-once-ledger.d.ts +14 -0
  150. package/dist/core/runner/announce-once-ledger.js +5 -0
  151. package/dist/core/runner/assemble-result.d.ts +1 -0
  152. package/dist/core/runner/assemble-result.js +1 -1
  153. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  154. package/dist/core/runner/caller-roster.d.ts +16 -4
  155. package/dist/core/runner/caller-roster.js +33 -6
  156. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  157. package/dist/core/runner/capability-withheld-seat.js +24 -0
  158. package/dist/core/runner/classifier-ladder.d.ts +7 -9
  159. package/dist/core/runner/classifier-ladder.js +3 -3
  160. package/dist/core/runner/construction-doors.js +3 -0
  161. package/dist/core/runner/contracts.d.ts +28 -25
  162. package/dist/core/runner/cross-boundary-lane.d.ts +17 -13
  163. package/dist/core/runner/cross-boundary-lane.js +40 -27
  164. package/dist/core/runner/denial-limit-arms.d.ts +2 -2
  165. package/dist/core/runner/denial-limit-arms.js +1 -1
  166. package/dist/core/runner/file-history-request.d.ts +18 -0
  167. package/dist/core/runner/file-history-request.js +21 -13
  168. package/dist/core/runner/file-history-restore.d.ts +45 -0
  169. package/dist/core/runner/file-history-restore.js +46 -0
  170. package/dist/core/runner/gate-exit.d.ts +3 -3
  171. package/dist/core/runner/gate-exit.js +4 -3
  172. package/dist/core/runner/image.d.ts +7 -17
  173. package/dist/core/runner/image.js +9 -60
  174. package/dist/core/runner/permission-rule-lanes.d.ts +4 -4
  175. package/dist/core/runner/permission-rule-lanes.js +26 -10
  176. package/dist/core/runner/person-path-rows.d.ts +12 -9
  177. package/dist/core/runner/person-path-rows.js +18 -7
  178. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  179. package/dist/core/runner/prepare-ask-lane.js +5 -2
  180. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  181. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  182. package/dist/core/runner/prepare-config-doors.d.ts +29 -38
  183. package/dist/core/runner/prepare-config-doors.js +42 -25
  184. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  185. package/dist/core/runner/prepare-defer-classify.js +7 -8
  186. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  187. package/dist/core/runner/prepare-file-history.js +7 -39
  188. package/dist/core/runner/prepare-gate-stations.d.ts +1 -1
  189. package/dist/core/runner/prepare-gate-stations.js +10 -1
  190. package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
  191. package/dist/core/runner/prepare-hands-readface.js +15 -14
  192. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  193. package/dist/core/runner/prepare-inherited-gate.js +5 -3
  194. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  195. package/dist/core/runner/prepare-park-ask.js +5 -5
  196. package/dist/core/runner/prepare-policy-chain.d.ts +6 -3
  197. package/dist/core/runner/prepare-policy-chain.js +65 -72
  198. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  199. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  200. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  201. package/dist/core/runner/prepare-prompt-inputs.js +3 -5
  202. package/dist/core/runner/prepare-protocol-tools.d.ts +2 -0
  203. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  204. package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
  205. package/dist/core/runner/prepare-safety-scan.js +0 -17
  206. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  207. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  208. package/dist/core/runner/prepare-task.d.ts +1 -1
  209. package/dist/core/runner/prepare-task.js +29 -20
  210. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
  211. package/dist/core/runner/prepare-tool-disclosure-mount.js +20 -16
  212. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  213. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  214. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -2
  215. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  216. package/dist/core/runner/resume-admission.js +1 -1
  217. package/dist/core/runner/resume-apply.js +11 -12
  218. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  219. package/dist/core/runner/resume-claim.d.ts +4 -2
  220. package/dist/core/runner/resume-claim.js +15 -8
  221. package/dist/core/runner/retired-runner-deps.js +1 -0
  222. package/dist/core/runner/rewind-files.d.ts +15 -0
  223. package/dist/core/runner/rewind-files.js +132 -0
  224. package/dist/core/runner/run-attachment-seats.js +2 -1
  225. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  226. package/dist/core/runner/run-brain-sinks.js +4 -2
  227. package/dist/core/runner/run-harness-handlers.js +12 -4
  228. package/dist/core/runner/run-leg.d.ts +1 -1
  229. package/dist/core/runner/run-leg.js +30 -18
  230. package/dist/core/runner/run-settle-and-teardown.js +2 -1
  231. package/dist/core/runner/run-turn-boundary.js +1 -10
  232. package/dist/core/runner/runtask.d.ts +3 -0
  233. package/dist/core/runner/runtask.js +8 -9
  234. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  235. package/dist/core/runner/session-read-file-states.js +28 -0
  236. package/dist/core/runner/session-rule-policy.js +4 -3
  237. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  238. package/dist/core/runner/shell-env-withheld.js +51 -0
  239. package/dist/core/runner/skills-seat.js +6 -2
  240. package/dist/core/runner/stream-settle-backstop.js +1 -1
  241. package/dist/core/runner/sub-agent-deny-lists.js +4 -7
  242. package/dist/core/runner/synthetic-tools.d.ts +6 -0
  243. package/dist/core/runner/synthetic-tools.js +4 -1
  244. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  245. package/dist/core/runner/tool-disclosure.js +1 -3
  246. package/dist/core/runner/tool-end-body.d.ts +1 -1
  247. package/dist/core/runner/tool-end-body.js +10 -9
  248. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  249. package/dist/core/runner/tool-not-executed.js +11 -0
  250. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  251. package/dist/core/runner/tool-occurrence.js +7 -0
  252. package/dist/core/runner/turn-attachments.d.ts +33 -15
  253. package/dist/core/runner/turn-attachments.js +62 -37
  254. package/dist/core/runner-deps.d.ts +5 -5
  255. package/dist/core/safety-axis-vocab.d.ts +6 -4
  256. package/dist/core/safety-axis-vocab.js +6 -5
  257. package/dist/core/safety-merge-corpus.js +11 -3
  258. package/dist/core/secret-env.d.ts +26 -3
  259. package/dist/core/secret-env.js +44 -8
  260. package/dist/core/select-model.js +3 -3
  261. package/dist/core/session-policy-store.d.ts +27 -15
  262. package/dist/core/session-policy-store.js +156 -36
  263. package/dist/core/session-store.d.ts +29 -10
  264. package/dist/core/session-store.js +51 -19
  265. package/dist/core/session.d.ts +82 -16
  266. package/dist/core/session.js +53 -0
  267. package/dist/core/shell-read-silence.d.ts +11 -12
  268. package/dist/core/shell-read-silence.js +9 -5
  269. package/dist/core/shell-run-candidates.js +3 -1
  270. package/dist/core/shell-wrapper-projection.js +1 -1
  271. package/dist/core/shell-wrapper-table.d.ts +14 -7
  272. package/dist/core/shell-wrapper-table.js +5 -4
  273. package/dist/core/side-query.js +10 -1
  274. package/dist/core/skill-grant.d.ts +7 -2
  275. package/dist/core/skill-grant.js +5 -0
  276. package/dist/core/skills-directory.js +6 -2
  277. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  278. package/dist/core/store-contracts/checkpoint-store-contract.js +140 -2
  279. package/dist/core/store-contracts/file-history-store-contract.js +31 -1
  280. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  281. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  282. package/dist/core/store-contracts/session-repo-contract.js +51 -0
  283. package/dist/core/store-contracts/session-store-contract.d.ts +2 -1
  284. package/dist/core/store-contracts/session-store-contract.js +150 -14
  285. package/dist/core/stub-env.d.ts +2 -0
  286. package/dist/core/stub-env.js +1 -0
  287. package/dist/core/synthetic-read-verdict.js +3 -3
  288. package/dist/core/task-event.d.ts +32 -4
  289. package/dist/core/task-notification.d.ts +16 -12
  290. package/dist/core/task-registry.d.ts +9 -0
  291. package/dist/core/task-registry.js +11 -1
  292. package/dist/core/task-result.d.ts +18 -0
  293. package/dist/core/task-spec.d.ts +18 -13
  294. package/dist/core/tighten-task-spec.js +2 -1
  295. package/dist/core/tool-catalog-entries.d.ts +17 -0
  296. package/dist/core/tool-catalog-entries.js +13 -2
  297. package/dist/core/tool-check-reading.d.ts +11 -0
  298. package/dist/core/tool-check-reading.js +11 -6
  299. package/dist/core/tool-model-gate.d.ts +2 -2
  300. package/dist/core/tool-name-aliases.d.ts +16 -16
  301. package/dist/core/tool-name-aliases.js +13 -19
  302. package/dist/core/tool-name-readings.d.ts +5 -35
  303. package/dist/core/tool-name-readings.js +1 -9
  304. package/dist/core/tool-policy.d.ts +68 -198
  305. package/dist/core/tool-policy.js +149 -198
  306. package/dist/core/tool-result-store.js +3 -0
  307. package/dist/core/tool-roster.d.ts +14 -19
  308. package/dist/core/tool-roster.js +11 -44
  309. package/dist/core/tool-spec-members.js +7 -2
  310. package/dist/core/tool-spec.d.ts +19 -11
  311. package/dist/core/tools.js +49 -9
  312. package/dist/core/trace.d.ts +2 -2
  313. package/dist/core/types.d.ts +1 -1
  314. package/dist/core/user-attachment.d.ts +8 -1
  315. package/dist/core/user-attachment.js +64 -4
  316. package/dist/core/wiring-manifest.d.ts +9 -0
  317. package/dist/core/wiring-manifest.js +1 -0
  318. package/dist/core/workflow-journal-store.js +1 -1
  319. package/dist/engine/compaction/compaction.js +3 -2
  320. package/dist/engine/execution-env/node-execution-env.d.ts +7 -3
  321. package/dist/engine/execution-env/node-execution-env.js +11 -2
  322. package/dist/engine/harness/agent-harness.d.ts +25 -1
  323. package/dist/engine/harness/agent-harness.js +54 -7
  324. package/dist/engine/harness/types.d.ts +29 -2
  325. package/dist/engine/llm/types.d.ts +28 -11
  326. package/dist/engine/loop/agent-loop.d.ts +22 -0
  327. package/dist/engine/loop/agent-loop.js +16 -26
  328. package/dist/engine/loop/types.d.ts +16 -6
  329. package/dist/engine/session/memory-repo.d.ts +9 -2
  330. package/dist/engine/session/memory-repo.js +11 -1
  331. package/dist/engine/session/repo-utils.d.ts +6 -5
  332. package/dist/engine/session/repo-utils.js +14 -6
  333. package/dist/index.d.ts +22 -10
  334. package/dist/index.js +15 -7
  335. package/dist/internal/harness-types.d.ts +1 -1
  336. package/dist/internal/llm.d.ts +1 -1
  337. package/dist/orchestration/run-workflow-tool.d.ts +6 -4
  338. package/dist/orchestration/run-workflow-tool.js +5 -3
  339. package/dist/orchestration/workflow.d.ts +3 -0
  340. package/dist/orchestration/workflow.js +36 -18
  341. package/dist/prompt-assembly/artifact.d.ts +2 -2
  342. package/dist/prompt-assembly/artifact.js +5 -3
  343. package/dist/prompt-assembly/assemble.d.ts +3 -2
  344. package/dist/prompt-assembly/assemble.js +1 -1
  345. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  346. package/dist/prompt-assembly/catalog/schema.js +34 -2
  347. package/dist/prompt-assembly/catalog/sections.js +0 -1
  348. package/dist/prompt-assembly/composer.d.ts +3 -1
  349. package/dist/prompt-assembly/composer.js +1 -1
  350. package/dist/prompt-assembly/event-registry.js +1 -0
  351. package/dist/prompt-assembly/overlay.js +3 -3
  352. package/dist/prompt-assembly/renderers.d.ts +1 -1
  353. package/dist/prompt-assembly/renderers.js +0 -3
  354. package/dist/prompt-assembly/role-base.d.ts +15 -0
  355. package/dist/prompt-assembly/role-base.js +9 -0
  356. package/dist/prompt-assembly/select.d.ts +39 -14
  357. package/dist/prompt-assembly/select.js +47 -16
  358. package/dist/prompt-assembly/sugar.d.ts +17 -11
  359. package/dist/prompt-assembly/sugar.js +8 -3
  360. package/dist/prompt-assembly/tool-catalog.d.ts +37 -3
  361. package/dist/prompt-assembly/tool-catalog.js +114 -4
  362. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  363. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  364. package/dist/prompt-assembly/types.d.ts +0 -7
  365. package/dist/scenarios/full-body.d.ts +11 -11
  366. package/dist/scenarios/full-body.js +4 -3
  367. package/dist/shell/lex.js +10 -1
  368. package/dist/stores/file/adoption/adopt.js +4 -3
  369. package/dist/stores/file/adoption/marker.js +3 -2
  370. package/dist/stores/file/checkpoint-store.d.ts +21 -0
  371. package/dist/stores/file/checkpoint-store.js +38 -6
  372. package/dist/stores/file/file-history-store.js +6 -7
  373. package/dist/stores/file/index.js +2 -1
  374. package/dist/stores/file/permission-rule-adopt.js +4 -3
  375. package/dist/stores/file/permission-rule-store.js +11 -5
  376. package/dist/stores/file/session-store.d.ts +29 -6
  377. package/dist/stores/file/session-store.js +42 -50
  378. package/dist/tools/artifact/artifact-tool.js +3 -2
  379. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  380. package/dist/tools/fs/bash-program-position.js +56 -9
  381. package/dist/tools/fs/fs-bash.js +5 -5
  382. package/dist/tools/fs/fs-glob.d.ts +86 -0
  383. package/dist/tools/fs/fs-glob.js +226 -0
  384. package/dist/tools/fs/fs-read.js +14 -14
  385. package/dist/tools/fs/fs-search-tools.js +7 -7
  386. package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
  387. package/dist/tools/fs/pattern-kill-guard.js +397 -0
  388. package/dist/tools/fs/pdf.d.ts +9 -6
  389. package/dist/tools/fs/pdf.js +3 -3
  390. package/dist/tools/fs/program-read-model.d.ts +57 -7
  391. package/dist/tools/fs/program-read-model.js +11 -1
  392. package/dist/tools/fs/program-read-model.rows.js +78 -21
  393. package/dist/tools/fs/read-deny-home.js +3 -2
  394. package/dist/tools/fs/removal-targets.d.ts +17 -7
  395. package/dist/tools/fs/removal-targets.js +47 -20
  396. package/dist/tools/fs/search.d.ts +10 -0
  397. package/dist/tools/fs/search.js +20 -26
  398. package/dist/tools/fs/shell-read-argv.js +89 -12
  399. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  400. package/dist/tools/fs/shell-read-bindings.js +41 -0
  401. package/dist/tools/fs/shell-read-check.js +6 -19
  402. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  403. package/dist/tools/fs/shell-read-environment.js +3 -2
  404. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  405. package/dist/tools/fs/shell-read-establish.js +19 -20
  406. package/dist/tools/fs/shell-read-plan.js +24 -16
  407. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  408. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  409. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  410. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  411. package/dist/tools/fs/shell-reentry-text.js +40 -2
  412. package/dist/tools/todo.js +63 -63
  413. package/dist/tools/web.d.ts +19 -14
  414. package/dist/tools/web.js +38 -55
  415. package/package.json +1 -1
  416. package/test/export-surface.snapshot.json +143 -5
  417. package/wire-changes/core@7.56.0.json +3891 -0
  418. package/wire-changes/mods-kernel@7.56.0.json +303 -0
@@ -1,4 +1,6 @@
1
1
  import { selectModel } from "./select-model.js";
2
+ import { namesRoleBase } from "../prompt-assembly/role-base.js";
3
+ import { readPromptRole } from "../prompt-assembly/select.js";
2
4
  import { MODEL_ROLES } from "./types.js";
3
5
  export { MODEL_ROLES } from "./types.js";
4
6
  function catalogModel(ref, models) {
@@ -180,7 +182,7 @@ function specParts(s, seat = "a role seat") {
180
182
  return { model: s };
181
183
  }
182
184
  const cfg = s;
183
- return { model: cfg.model, select: cfg.select, thinking: cfg.thinking, systemPrompt: cfg.systemPrompt };
185
+ return { model: cfg.model, select: cfg.select, thinking: cfg.thinking, promptRole: readPromptRole(`${seat}.promptRole`, cfg.promptRole), systemPrompt: cfg.systemPrompt };
184
186
  }
185
187
  export function roleSpecNamesModel(spec) {
186
188
  const parts = specParts(spec);
@@ -203,11 +205,13 @@ function mergeRoleSpec(base, over) {
203
205
  if (!b)
204
206
  return over;
205
207
  const overHasSource = o.model !== undefined || o.select !== undefined;
208
+ const roleBase = namesRoleBase(o) ? o : b;
206
209
  return {
207
210
  model: overHasSource ? o.model : b.model,
208
211
  select: overHasSource ? o.select : b.select,
209
212
  thinking: o.thinking ?? b.thinking,
210
- systemPrompt: o.systemPrompt ?? b.systemPrompt,
213
+ promptRole: roleBase.promptRole,
214
+ systemPrompt: roleBase.systemPrompt,
211
215
  };
212
216
  }
213
217
  function assertKnownRole(word, field, ofKey = false) {
@@ -216,19 +220,19 @@ function assertKnownRole(word, field, ofKey = false) {
216
220
  const shown = typeof word === "string" ? JSON.stringify(word).slice(0, 80) : `<${word === null ? "null" : typeof word}>`;
217
221
  throw modelBindingRefusal(field, "unknown_role_word", `${ofKey ? `${field} key` : field} names the model role ${shown}, which is not one of ${MODEL_ROLES.join(" / ")} — a word outside the vocabulary binds nothing and resolves nothing; bind the model on one of these roles, or name it on TaskSpec.model`);
218
222
  }
219
- function mergeRoles(base, over) {
220
- for (const key of Object.keys(base ?? {}))
221
- assertKnownRole(key, "RunnerDeps.roles", true);
222
- for (const key of Object.keys(over ?? {}))
223
- assertKnownRole(key, "TaskSpec.roles", true);
224
- for (const roles of [base, over]) {
225
- for (const [key, value] of Object.entries(roles ?? {})) {
226
- const seat = `roles.${key}`;
227
- const named = specParts(value, seat).model;
228
- if (named !== undefined)
229
- assertModelBindingShape(named, roleModelSeat(named, seat), ROLE_BINDS);
230
- }
223
+ export function screenRoleMap(roles, field) {
224
+ for (const key of Object.keys(roles ?? {}))
225
+ assertKnownRole(key, field, true);
226
+ for (const [key, value] of Object.entries(roles ?? {})) {
227
+ const seat = `roles.${key}`;
228
+ const named = specParts(value, seat).model;
229
+ if (named !== undefined)
230
+ assertModelBindingShape(named, roleModelSeat(named, seat), ROLE_BINDS);
231
231
  }
232
+ }
233
+ function mergeRoles(base, over) {
234
+ screenRoleMap(base, "RunnerDeps.roles");
235
+ screenRoleMap(over, "TaskSpec.roles");
232
236
  const out = { ...base };
233
237
  for (const role of Object.keys(over ?? {})) {
234
238
  out[role] = mergeRoleSpec(base?.[role], over?.[role]);
@@ -249,27 +253,35 @@ function partsModel(parts, models, seat = "a role seat") {
249
253
  }
250
254
  return undefined;
251
255
  }
252
- export function resolveTaskModel(spec, deps) {
256
+ function chainHead(spec, deps) {
253
257
  const start = spec.modelRole === undefined ? "default" : spec.modelRole;
254
258
  assertKnownRole(start, "modelRole");
259
+ const merged = mergeRoles(deps.roles, spec.roles);
260
+ return { start, merged, startParts: specParts(merged[start], `roles.${start}`) };
261
+ }
262
+ export function presetRoleBaseOf(spec, deps) {
263
+ const { promptRole, systemPrompt } = chainHead(spec, deps).startParts;
264
+ return namesRoleBase({ promptRole, systemPrompt }) ? { ...(promptRole !== undefined ? { promptRole } : {}), ...(systemPrompt !== undefined ? { systemPrompt } : {}) } : undefined;
265
+ }
266
+ export function resolveTaskModel(spec, deps) {
267
+ const { start, merged, startParts } = chainHead(spec, deps);
255
268
  if (spec.model !== undefined) {
256
- const startParts = specParts(mergeRoles(deps.roles, spec.roles)[start], `roles.${start}`);
257
269
  return {
258
270
  model: resolveModel(spec.model, deps.models, "TaskSpec.model"),
259
271
  modelRef: spec.model,
260
272
  thinking: spec.thinking ?? startParts.thinking,
273
+ promptRole: startParts.promptRole,
261
274
  systemPrompt: startParts.systemPrompt,
262
275
  };
263
276
  }
264
- const merged = mergeRoles(deps.roles, spec.roles);
265
- const startSystemPrompt = specParts(merged[start], `roles.${start}`).systemPrompt;
277
+ const { promptRole: startPromptRole, systemPrompt: startSystemPrompt } = startParts;
266
278
  for (const role of [start, ...FALLBACK[start]]) {
267
279
  const parts = specParts(merged[role], `roles.${role}`);
268
280
  const fromParts = partsModel(parts, deps.models, `roles.${role}`);
269
281
  const model = fromParts ?? roleTierModel(role, deps.models);
270
282
  if (model) {
271
283
  const modelRef = fromParts !== undefined ? (parts.model ?? model) : (ROLE_TIER_DEFAULTS[role] ?? model);
272
- return { model, modelRef, thinking: spec.thinking ?? parts.thinking, systemPrompt: startSystemPrompt };
284
+ return { model, modelRef, thinking: spec.thinking ?? parts.thinking, promptRole: startPromptRole, systemPrompt: startSystemPrompt };
273
285
  }
274
286
  }
275
287
  throw new Error(`No model for role "${start}": set TaskSpec.model, or configure RunnerDeps.roles / TaskSpec.roles["${start}"] (or a "default" role). A "select" RoleSpec also fails here if no catalog model matches.`);
@@ -34,16 +34,20 @@ export declare function normalizeOrgGateVerdict(answer: unknown, unreadable: str
34
34
  /**
35
35
  * Normalize the accepted {@link ToolGateInput.persistedRules} answers into one reading.
36
36
  *
37
- * `{}` = a clean negative (no rule admits this call). `{ unreadable: true }` = the lane could not read
38
- * its source. `{ hit }` = a match, whose `rules` is the non-empty coverage set (design/375). An answer
39
- * outside every accepted shape — a number, `null`, an object with neither `rules` nor `unreadable`, an
40
- * EMPTY `rules` array, the retired pre-375 `{ rule, dots? }` single-rule object — is read as a clean
41
- * negative rather than a match: this is a LOOSENING seam, so an answer nobody can name degrades toward
42
- * asking, never toward an allow built on it. All-or-nothing across the set's TEXTS for the same
43
- * reason: a set with one unreadable member is a different (smaller) claim than the lane made, and a
44
- * decision must not stand on a claim nobody made — one bad member drops the whole answer to the clean
45
- * negative. Per-member DOTS stay individually optional (identity lost ⇒ `"not_reported"`, exactly the
46
- * single-rule contract).
37
+ * Four readings, and the lane's own words pick them. `{}` = the lane SAID no rule speaks: the `undefined` answer
38
+ * (the store was read and holds nothing for this call) or a coverage answer (design/375 §5.2②, whose decision
39
+ * meaning is "no rule"). `{ hit }` = a match: a `behavior` of the closed set and a NON-EMPTY `rules` whose members each
40
+ * carry a text (design/375). `{ unreadable: true }` = the lane said it could not read its source (the store form).
41
+ * `{ unreadable: true, reason }` = the lane could not read the call against its rows (its own call form), OR the lane
42
+ * answered something this seam cannot read — `null`, a string or number, an object that is none of the shapes above, a
43
+ * `behavior` outside the closed set or absent, `rules` absent / not an array / empty, a member that is not a record or
44
+ * whose `rule` is not a string, a carrier that is not a plain object. The last arm is the one that matters: an answer the
45
+ * lane gave and nobody can read may be a DENY or an ASK row that did not survive the seam, and reading it as "no rule"
46
+ * would let the person's standing "never run this" fail silently — so it is read as the unreadable word (a
47
+ * real-approval ask no mode releases; headless, a refusal), the same word the org lane's unreadable answer takes.
48
+ * All-or-nothing across the set for the same reason: a set with one unreadable member is a different (smaller) claim than
49
+ * the lane made, and a decision must not stand on a claim nobody made. Per-member DOTS stay individually optional
50
+ * (identity lost ⇒ `"not_reported"`, exactly the single-rule contract).
47
51
  *
48
52
  * The hit's dots are COPIED, not aliased. The array travels onto an ask that may sit in front of a
49
53
  * person for a long time; a lane that retains and mutates its own array would otherwise change what the
@@ -68,11 +72,12 @@ export declare function readOrgRuleLane(org: {
68
72
  }, req: ToolCallRequest, signal: AbortSignal | undefined, timeoutMs?: number): Promise<OrgGateVerdict>;
69
73
  /**
70
74
  * The persisted-rule lane's one read for one call — every consumer's (the live gate, the synthetic-Read
71
- * judge), normalized once. A lane that throws, hangs past the dependency timeout, or answers something
72
- * unreadable is a lane that could not answer: a row nobody could read may forbid the call, so for the DECISION it
73
- * fails closed (`applyPersistedTightening` reads `{ unreadable }` without a reason as the store form: a real-approval
74
- * ask), and for the RECORD it is `"unavailable"`. A call the lane could not read against the rows (`reason`) fails
75
- * closed in the arms the same way, as the call form. Absent lane ⇒ the clean negative.
75
+ * judge), normalized once. A lane that throws or hangs past the dependency timeout is a lane that could not answer: a row
76
+ * nobody could read may forbid the call, so for the DECISION it fails closed (`applyPersistedTightening` reads `{ unreadable }`
77
+ * without a reason as the store form: a real-approval ask), and for the RECORD it is `"unavailable"`. A lane that ANSWERS
78
+ * something this seam cannot read, and a call the lane could not read against the rows, are `unreadable` with a `reason`
79
+ * (the normalizer's words, naming the field): they fail closed in the arms the same way, as the call form. Absent lane,
80
+ * or the lane's own `undefined` ⇒ the clean negative.
76
81
  */
77
82
  export declare function readPersistedRuleLane(lane: {
78
83
  adjudicate: (req: ToolCallRequest) => PersistedRuleAnswer | Promise<PersistedRuleAnswer>;
@@ -1,6 +1,6 @@
1
1
  import { describeThrown } from "./tool-policy.js";
2
2
  import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "./permission-rule-org.js";
3
- import { isRuleBehavior } from "./permission-rule-model.js";
3
+ import { isRuleBehavior, RULE_BEHAVIORS } from "./permission-rule-model.js";
4
4
  function isPlainOwnRecord(x) {
5
5
  try {
6
6
  if (x === null || typeof x !== "object" || Array.isArray(x))
@@ -21,6 +21,15 @@ function ownDataValue(obj, key) {
21
21
  return undefined;
22
22
  }
23
23
  }
24
+ function bearsOwn(obj, key) {
25
+ try {
26
+ const d = Object.getOwnPropertyDescriptor(obj, key);
27
+ return d !== undefined && (!("value" in d) || d.value !== undefined);
28
+ }
29
+ catch {
30
+ return true;
31
+ }
32
+ }
24
33
  export function normalizeOrgGateVerdict(answer, unreadable) {
25
34
  const clean = (v) => Object.assign(Object.create(null), v);
26
35
  const readable = (x) => {
@@ -94,16 +103,24 @@ function copiedUsableDots(dots) {
94
103
  const usable = copied?.every((d) => typeof d.actor === "string" && typeof d.counter === "number" && Number.isFinite(d.counter)) === true && copied.length > 0;
95
104
  return usable ? { dots: copied } : {};
96
105
  }
106
+ function unreadableAnswer(where) {
107
+ return { unreadable: true, reason: `the host's persisted-rule lane, persistedRules.adjudicate, answered what this gate cannot read: ${where}` };
108
+ }
97
109
  export function normalizePersistedRuleHit(hit) {
98
- if (!isPlainOwnRecord(hit))
110
+ if (hit === undefined)
99
111
  return {};
112
+ if (!isPlainOwnRecord(hit))
113
+ return unreadableAnswer(hit === null ? "the answer is `null` — a lane with no rule for the call answers `undefined`" : "the answer is not a plain object");
100
114
  if (ownDataValue(hit, "unreadable") === true) {
101
115
  const reason = ownDataValue(hit, "reason");
102
116
  return typeof reason === "string" ? { unreadable: true, reason } : { unreadable: true };
103
117
  }
104
118
  const rulesRaw = ownDataValue(hit, "rules");
105
- if (rulesRaw === undefined) {
119
+ const behavior = ownDataValue(hit, "behavior");
120
+ if (!bearsOwn(hit, "rules") && !bearsOwn(hit, "behavior") && !bearsOwn(hit, "unreadable")) {
106
121
  const coverageRaw = ownDataValue(hit, "segmentCoverage");
122
+ if (coverageRaw === undefined)
123
+ return unreadableAnswer("it names no `behavior`, no `rules`, no `unreadable` report and no `segmentCoverage` table");
107
124
  let rows;
108
125
  try {
109
126
  if (Array.isArray(coverageRaw)) {
@@ -120,27 +137,38 @@ export function normalizePersistedRuleHit(hit) {
120
137
  }
121
138
  return rows !== undefined && rows.length > 0 ? { coverage: rows.map((r) => ({ segment: r.segment, covered: r.covered })) } : {};
122
139
  }
123
- let members;
140
+ if (!isRuleBehavior(behavior))
141
+ return unreadableAnswer(`\`behavior\` is not one of ${RULE_BEHAVIORS.join(" / ")}`);
142
+ const members = [];
143
+ let problem;
124
144
  try {
125
- if (Array.isArray(rulesRaw)) {
126
- const walked = [];
127
- for (let i = 0; i < rulesRaw.length; i++) {
145
+ const count = Array.isArray(rulesRaw) ? rulesRaw.length : undefined;
146
+ if (!Array.isArray(rulesRaw))
147
+ problem = rulesRaw === undefined ? "`rules` is absent or not an own data property" : "`rules` is not an array";
148
+ else if (count === 0)
149
+ problem = "`rules` is empty — a hit names at least one rule";
150
+ else if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0)
151
+ problem = "`rules` has no readable length";
152
+ else {
153
+ for (let i = 0; i < count && problem === undefined; i++) {
128
154
  const m = rulesRaw[i];
129
- walked.push(isPlainOwnRecord(m) ? { rule: ownDataValue(m, "rule"), dots: ownDataValue(m, "dots") } : { rule: undefined, dots: undefined });
155
+ if (!isPlainOwnRecord(m))
156
+ problem = `\`rules[${i}]\` is not a plain object`;
157
+ else {
158
+ const rule = ownDataValue(m, "rule");
159
+ if (typeof rule !== "string")
160
+ problem = `\`rules[${i}].rule\` is not a string`;
161
+ else
162
+ members.push({ rule, dots: ownDataValue(m, "dots") });
163
+ }
130
164
  }
131
- members = walked;
132
165
  }
133
166
  }
134
167
  catch {
135
- members = undefined;
168
+ problem = "`rules` could not be read (a throwing element or a revoked proxy)";
136
169
  }
137
- if (members === undefined || members.length === 0)
138
- return {};
139
- if (!members.every((m) => typeof m.rule === "string"))
140
- return {};
141
- const behavior = ownDataValue(hit, "behavior");
142
- if (!isRuleBehavior(behavior))
143
- return {};
170
+ if (problem !== undefined)
171
+ return unreadableAnswer(problem);
144
172
  const denial = behavior === "deny" ? copiedDenial(ownDataValue(hit, "denial"), members.map((m) => m.rule)) : undefined;
145
173
  return { hit: { behavior, rules: members.map((m) => ({ rule: m.rule, ...copiedUsableDots(m.dots) })), ...(denial !== undefined ? { denial } : {}) } };
146
174
  }
@@ -5,8 +5,8 @@
5
5
  * The faces that read an owner out of data — the two adoption markers read back from disk, the two adoption entries'
6
6
  * source, a stored approval record's identity and the consent entries' `owner` option — read it through
7
7
  * {@link readRuleOwner}, so the source an adoption entry writes into its marker is one that marker's reader reads back.
8
- * Its one run-time import is the import-free record judge — the root adoption marker reader, which every file store
9
- * loads, depends on this module and is kept free of the rule store's own imports.
8
+ * Its run-time imports are the two import-free judges — the record judge and the principal-name judge — because the root
9
+ * adoption marker reader, which every file store loads, depends on this module and is kept free of the rule store's own imports.
10
10
  */
11
11
  import type { AssertAllKeysHandled } from "./ask-origin.js";
12
12
  /**
@@ -36,7 +36,7 @@ export declare function sameRuleOwner(a: RuleOwner, b: RuleOwner): boolean;
36
36
  /**
37
37
  * Read an owner from a value the engine did not just build, or `undefined` when it is not one: not a plain record (an
38
38
  * object whose prototype is `Object.prototype` or none, so no member comes from a prototype it was given), a `kind`
39
- * outside {@link RULE_OWNER_KINDS}, or a `principal` arm whose name is not a string with a non-whitespace character (an
39
+ * outside {@link RULE_OWNER_KINDS}, or a `principal` arm whose name is not a principal name ({@link principalNameOf}: an
40
40
  * identity-less bucket is the `local-owner` kind, never a blank name). Fail-closed: a caller treats `undefined` as
41
41
  * "owns nothing" or refuses — never as either arm. The answer is a fresh object holding only the members the type
42
42
  * declares; `kind` and `principal` are each read once.
@@ -1,4 +1,5 @@
1
1
  import { isPlainRecord } from "./mods/kernel/receive.js";
2
+ import { principalNameOf } from "./principal-name.js";
2
3
  export const RULE_OWNER_KINDS = Object.freeze(["principal", "local-owner"]);
3
4
  export function sameRuleOwner(a, b) {
4
5
  return a.kind === "principal" ? b.kind === "principal" && a.principal === b.principal : b.kind === "local-owner";
@@ -14,8 +15,8 @@ export function readRuleOwner(raw) {
14
15
  case "local-owner":
15
16
  return { kind: "local-owner" };
16
17
  case "principal": {
17
- const principal = raw.principal;
18
- return typeof principal === "string" && principal.trim() !== "" ? { kind: "principal", principal } : undefined;
18
+ const principal = principalNameOf(raw.principal);
19
+ return principal === undefined ? undefined : { kind: "principal", principal };
19
20
  }
20
21
  default: {
21
22
  const unhandled = word;
@@ -68,6 +68,20 @@ export declare function flushOwedAnnouncedSnapshot(prepared: {
68
68
  announcedListingsRef: AnnouncedListingSnapshotInput;
69
69
  session: Pick<AnnounceOnceSession, "appendAnnouncedListing">;
70
70
  }): Promise<void>;
71
+ /**
72
+ * The one commit of a delivered `mcp_unavailable` frame — the receipt of the message that carried it (a leg's first request), run
73
+ * inside the `message_end` walk: the delivered pairs leave the pending list and join the session's told-failure record, whose
74
+ * snapshot write is parked for the next serialization point. The next prepare on the session announces only what the record lacks.
75
+ */
76
+ export declare function settleMcpUnavailable(prepared: {
77
+ readonly mcpUnavailable?: {
78
+ pending: AnnouncedMcpFailure[];
79
+ };
80
+ readonly announcedListingsRef: AnnouncedListingSnapshotInput;
81
+ readonly frameReceipts: {
82
+ listingSnapshotOwed: boolean;
83
+ };
84
+ }, delivered: ReadonlyArray<AnnouncedMcpFailure>): void;
71
85
  /** The run-local ledger — see the module header for the two commit disciplines it serves. */
72
86
  export interface AnnounceOnceLedger {
73
87
  /** The nearest announced snapshot on the branch as read at prepare (undefined = pre-entry
@@ -47,6 +47,11 @@ export async function flushOwedAnnouncedSnapshot(prepared) {
47
47
  return;
48
48
  await prepared.session.appendAnnouncedListing(prepared.announcedListingsRef).catch(() => undefined);
49
49
  }
50
+ export function settleMcpUnavailable(prepared, delivered) {
51
+ prepared.mcpUnavailable?.pending.splice(0, delivered.length);
52
+ prepared.announcedListingsRef.mcpFailed = [...(prepared.announcedListingsRef.mcpFailed ?? []), ...delivered];
53
+ prepared.frameReceipts.listingSnapshotOwed = true;
54
+ }
50
55
  export async function loadAnnounceOnceLedger(session, checkpointMirror, onError) {
51
56
  let recovered = true;
52
57
  const entry = await session.getAnnouncedListing().catch(() => {
@@ -148,6 +148,7 @@ export interface ResultFlags {
148
148
  * ended for its own reason first) leaves this empty: the original terminal stands and the seat is
149
149
  * NOT signed (the settle lane mints `task.halt_unconsumed` for it). */
150
150
  haltConsumption?: HaltConsumption;
151
+ answerEntryIds?: readonly string[];
151
152
  /** Call ids of answered-but-never-collected questions, echoed on
152
153
  * `TaskResult.strandedHumanAnswers`. Pure pass-through; empty/absent ⇒ the field is omitted. The
153
154
  * optional `onError` alert is NOT the disclosure — this mandatory result face is. */
@@ -178,5 +178,5 @@ export function assembleResult(spec, sessionId, final, stats, flags) {
178
178
  if (flags.unpricedSpend)
179
179
  delete publicStats.costMicroUsd;
180
180
  const stampHaltedByUser = haltConsumed(flags.haltConsumption);
181
- return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
181
+ return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, terminal, ...(flags.model !== undefined ? { model: flags.model } : {}), ...(responseModel !== undefined ? { responseModel } : {}), result: result.trim(), ...(flags.answerEntryIds !== undefined ? { resultEntryIds: [...flags.answerEntryIds] } : {}), salvagedOutput, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.editedFiles !== undefined && flags.editedFiles.length > 0 ? { editedFiles: flags.editedFiles } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveWriteFace !== undefined ? { effectiveWriteFace: flags.effectiveWriteFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), ...(flags.compaction !== undefined ? { compaction: flags.compaction } : {}), stats: publicStats };
182
182
  }
@@ -89,8 +89,9 @@ export interface ApprovedCallScreenInput {
89
89
  * the call (the decide is the upper bound; the screen can only narrow): a deny, a failed or cancelled screening, or a
90
90
  * refused answer refuses the call in the live gate's own sentences; an ask is the question the decide already answered —
91
91
  * unless it demands a person and the decide was the deployment's policy (the one predicate every resume station holds a
92
- * decide against); a rewrite is what executes when the decide carried none of its own (the person's bytes are the upper
93
- * bound); context rides the result. Undefined when no handler hangs on `classic.PreToolUse`.
92
+ * decide against); a rewrite comes back as the args — what executes when the decide carried no edit, a refusal of the edit
93
+ * when it did (a person's bytes are the ceiling, rewrite-rejudge.ts); context rides the result. Undefined when no handler hangs
94
+ * on `classic.PreToolUse`.
94
95
  */
95
96
  export declare function createApprovedCallScreen(input: ApprovedCallScreenInput): ApprovedCallScreen | undefined;
96
97
  /**
@@ -12,7 +12,8 @@
12
12
  * (string and symbol keys — what the mount's spread carries) plus every ToolSpec member name read through an ordinary
13
13
  * property read (how the phases read a declaration — non-enumerable, inherited or Proxy-answered included), each read once;
14
14
  * every declaration value is deep-copied and frozen by the one copier. A primitive is immutable and stays as read. A
15
- * read that throws refuses the run at the snapshot. Whether the ToolSpec arm can build the entry ({@link specArmCanConstruct})
15
+ * read that throws refuses the run at the snapshot, and so does an entry that carries a retired ToolSpec member under any
16
+ * reading of the key ({@link refuseRetiredMember}: the entry is asked once, before any face is minted). Whether the ToolSpec arm can build the entry ({@link specArmCanConstruct})
16
17
  * is asked of the entry once, there, and recorded on its face ({@link specArmCanBuild}); the mount refuses an entry it
17
18
  * cannot build from that record, so an `execute` that grows on the caller's object later is never read. The mount calls a
18
19
  * spec face's `execute` with the caller's own object as `this` ({@link callerEntryOrigin}). A `defineTool` product's face is
@@ -57,16 +58,27 @@ export declare function callerEntryOrigin(entry: object): object;
57
58
  /** Can the mount's ToolSpec arm build this roster entry? Only the verdict recorded at the snapshot answers: an object that
58
59
  * is no face of this snapshot, a primitive, a product's face, is not built from. */
59
60
  export declare function specArmCanBuild(entry: RosterFace): boolean;
60
- /** A `TaskSpec.tools` spec declaring an engine contract (a `core.` id) its catalog did not mint for it — the id written by hand — refused where the
61
- * declaration enters. An engine definition under any declared name carries the minted object; a host can forge the string, never the object. */
61
+ /** A roster entry claiming an engine contract its catalog did not mint for it — the id written by hand, on a spec or on a product — refused where the
62
+ * declaration enters. */
62
63
  export declare function callerEngineContractProblem(face: RosterFace): {
63
64
  code: ToolDeclarationCode;
64
65
  message: string;
65
66
  } | undefined;
67
+ /** The retired-key door for one roster entry, asked of the LIVE entry once, before any member is copied: the key is present
68
+ * iff ordinary property lookup answers a defined value ({@link retiredKeyOf} — an own enumerable member, a non-enumerable
69
+ * one, a prototype's getter, a Proxy's trap alike), and a present one refuses the run by name with the sentence and code
70
+ * the factory gives the same key on a `defineTool` spec (`config.deps_retired_key`). A lookup that throws is an entry whose
71
+ * members cannot be read, refused as such. No face is ever minted from an entry that carries a retired member, so no later
72
+ * phase has a key table of its own to consult for one. Every live object that is about to become a face meets it first:
73
+ * {@link rosterFaceOf} asks it of each entry, and the per-task agents rebuild asks it of the object `withAgents` returned
74
+ * before the stamp copy-back spreads that object (a spread drops a prototype's and a non-enumerable member). A value that
75
+ * is no object holds no member. */
76
+ export declare function refuseRetiredMember(entry: unknown, index: number): void;
66
77
  /** One entry of the roster, and the ONLY place a {@link RosterFace} is minted. Every object entry (a function included) becomes a frozen face, so no entry the snapshot holds is a
67
78
  * live object: a primitive is immutable and stays as read; a `defineTool` product's face names the product for its sealed
68
79
  * rebind; an entry the ToolSpec arm cannot build gets a face too, and the mount refuses it from the verdict recorded here —
69
- * an `execute` or a mark that grows on the caller's object afterwards is never read. A read that throws refuses the run. */
80
+ * an `execute` or a mark that grows on the caller's object afterwards is never read. An entry carrying a retired member is
81
+ * refused first ({@link refuseRetiredMember}). A read that throws refuses the run. */
70
82
  export declare function rosterFaceOf(t: unknown, index: number): RosterFace;
71
83
  /** The mount's arm for a roster entry that is the face of a `defineTool` product: the exact product object is rebound to
72
84
  * the run's ctx through the factory's sealed seat, compared with its face ({@link refuseProductDrift}), and the tool the
@@ -1,7 +1,8 @@
1
1
  import { TOOL_SPEC_MEMBERS, frozenExtra, frozenMember, newCopyState } from "../tool-spec-members.js";
2
+ import { RETIRED_TOOL_SPEC_KEYS, retiredKeyOf, retiredKeyRefusal } from "../retired-keys.js";
2
3
  import { isDefineToolProduct, rebindDefineToolCtx } from "../tools.js";
3
4
  import { isCatalogContract } from "../tool-catalog-entries.js";
4
- import { contractOriginOf } from "../../prompt-assembly/tool-catalog.js";
5
+ import { attachedContractOf, computeShapeDigest, contractOriginOf, isEngineDescriptor } from "../../prompt-assembly/tool-catalog.js";
5
6
  function specArmCanConstruct(t) {
6
7
  if (typeof t !== "object" || t === null)
7
8
  return false;
@@ -19,6 +20,8 @@ function faceKeys(t) {
19
20
  const keys = new Set(Reflect.ownKeys(t).filter((k) => Object.getOwnPropertyDescriptor(t, k)?.enumerable === true));
20
21
  for (const name of TOOL_SPEC_MEMBERS)
21
22
  keys.add(name);
23
+ for (const name of Object.keys(RETIRED_TOOL_SPEC_KEYS))
24
+ keys.delete(name);
22
25
  return [...keys];
23
26
  }
24
27
  const BUILDABLE = new WeakSet();
@@ -45,16 +48,42 @@ function refuseUnreadableEntry(index, entry, cause) {
45
48
  e.code = "config.tool_mount_denied";
46
49
  throw e;
47
50
  }
48
- const CATALOG_CONTRACT_FACES = new WeakSet();
51
+ function unmintedEngineClaim(face) {
52
+ const declared = face.contract?.contractId;
53
+ if (typeof declared === "string" && contractOriginOf(declared) === "core" && !isCatalogContract(face.contract))
54
+ return declared;
55
+ const carried = attachedContractOf(face);
56
+ if (carried === undefined || carried === null || typeof carried !== "object")
57
+ return undefined;
58
+ const id = carried.contractId;
59
+ if (carried.origin !== "core" && !(typeof id === "string" && contractOriginOf(id) === "core"))
60
+ return undefined;
61
+ const describesFace = isEngineDescriptor(carried) && carried.wireName === face.name && carried.shapeDigest === computeShapeDigest(face.parameters);
62
+ return describesFace ? undefined : String(id);
63
+ }
49
64
  export function callerEngineContractProblem(face) {
50
- const id = face.contract?.contractId;
51
- if (typeof id !== "string" || contractOriginOf(id) !== "core" || CATALOG_CONTRACT_FACES.has(face))
65
+ const id = unmintedEngineClaim(face);
66
+ if (id === undefined)
52
67
  return undefined;
53
68
  return { code: "config.tool_face_invalid", message: `tool ${JSON.stringify(String(face.name).slice(0, 40))} declares the engine contract ${JSON.stringify(id.slice(0, 64))}, which no engine definition minted for it — a contract id under \`core.\` belongs to the engine's own definitions; declare an id of your own, or none` };
54
69
  }
70
+ export function refuseRetiredMember(entry, index) {
71
+ if ((typeof entry !== "object" && typeof entry !== "function") || entry === null)
72
+ return;
73
+ let hit;
74
+ try {
75
+ hit = retiredKeyOf(entry, RETIRED_TOOL_SPEC_KEYS);
76
+ }
77
+ catch (cause) {
78
+ return refuseEntry(index, entry, cause);
79
+ }
80
+ if (hit !== undefined)
81
+ throw retiredKeyRefusal(hit, "ToolSpec");
82
+ }
55
83
  export function rosterFaceOf(t, index) {
56
84
  if ((typeof t !== "object" && typeof t !== "function") || t === null)
57
85
  return t;
86
+ refuseRetiredMember(t, index);
58
87
  try {
59
88
  const product = isDefineToolProduct(t) ? t : undefined;
60
89
  const buildable = product === undefined && specArmCanConstruct(t);
@@ -67,8 +96,6 @@ export function rosterFaceOf(t, index) {
67
96
  if (value === undefined && !own)
68
97
  continue;
69
98
  let kept;
70
- if (key === "contract" && isCatalogContract(value))
71
- CATALOG_CONTRACT_FACES.add(face);
72
99
  if (typeof key === "string" && IS_MEMBER.has(key))
73
100
  kept = frozenMember(key, value, ledger);
74
101
  else {
@@ -0,0 +1,5 @@
1
+ import type { Prepared } from "./contracts.js";
2
+ import type { NoticeSeatInput } from "./notice-seat-input.js";
3
+ /** The session's announced record and the leg's receipt ledger (the parked write). */
4
+ export type CapabilityWithheldRecord = Pick<Prepared, "announcedListingsRef" | "frameReceipts">;
5
+ export declare function createCapabilityWithheldScope(ids: NoticeSeatInput, announced: CapabilityWithheldRecord): <T>(fn: () => Promise<T>) => Promise<T>;
@@ -0,0 +1,24 @@
1
+ import { runWithCapabilityWithheld } from "../../brain/status-sink.js";
2
+ import { deliverEngineNotice } from "../engine-notice.js";
3
+ import { announceDigest, withAnnounceDigests } from "./announce-once-ledger.js";
4
+ const CAPABILITY_DOWNGRADED = "model.capability_downgraded";
5
+ export function createCapabilityWithheldScope(ids, announced) {
6
+ const announce = (report) => {
7
+ const digest = announceDigest(CAPABILITY_DOWNGRADED, `${report.modelId}\n${report.capability}`);
8
+ const record = announced.announcedListingsRef;
9
+ if (record.advisories?.includes(digest) === true)
10
+ return;
11
+ const why = report.cause === "declared_off"
12
+ ? `its catalog entry declares no image input (Model.input has no "image")`
13
+ : `its catalog entry does not declare image input, and images are not sent to an entry that does not`;
14
+ deliverEngineNotice(ids.onNotice, {
15
+ code: CAPABILITY_DOWNGRADED,
16
+ message: `Images in this conversation are not being sent to model "${report.modelId}": ${why}, so each image reaches the model as a one-line placeholder. ` +
17
+ `If the model reads images, declare it (input: ["text","image"]); otherwise switch to a model that reads images. Said once per conversation for this model.`,
18
+ detail: { model: report.modelId, capability: report.capability, status: report.cause, sessionId: ids.sessionId, runId: ids.runId },
19
+ });
20
+ record.advisories = withAnnounceDigests(record.advisories, [digest]);
21
+ announced.frameReceipts.listingSnapshotOwed = true;
22
+ };
23
+ return (fn) => runWithCapabilityWithheld(announce, fn);
24
+ }
@@ -179,14 +179,11 @@ export interface ClassifierUnavailableStation {
179
179
  budgetMs?: number;
180
180
  }
181
181
  /**
182
- * The classifier's REASONING SEAT, read off the model a classification is actually asked on — ONE predicate:
183
- * does the wire SPELL off ({@link thinkingOffSpelled})? Yes ⇒ `off` + the verdict-sized cap (the request pays
184
- * for the answer alone); no ⇒ `low` + the verdict cap + the low allowance (a model whose thinking the wire
185
- * cannot turn off is asked for the least it can grade, in the room that costs — spell off,
186
- * or leave thinking to the provider and pay 2048). A model that declares no reasoning at all is on the `low`
187
- * seat too: its wire carries nothing either way, so the request is the gateway's default, and a default-on
188
- * gateway thinks — the arm that used to read it as "never thinks" is the one the field report was about.
189
- * PER RUNG, not once per arming: the second rung is a different model with its own wire.
182
+ * The classifier's REASONING SEATS, read off the model a classification is actually asked on. The tier is the shared
183
+ * verdict ({@link lowestReasoningSeat}); the cap is the classifier's own: `off` carries the verdict-sized cap (the
184
+ * request pays for the answer alone), `low` carries the verdict cap plus the low allowance (spell off, or leave
185
+ * thinking to the provider and pay 2048). PER RUNG, not once per arming: the second rung is a different model with
186
+ * its own wire.
190
187
  *
191
188
  * The THINK seat is the RE-ASK seat ({@link classifierReplyAsksAgain}): a first attempt that produced no
192
189
  * verdict is asked once more with thinking allowed the room of CC's stage-2 classifier (8192) — an unknown
@@ -212,7 +209,8 @@ export type ClassifierSeatRequest = typeof CLASSIFIER_OFF_SEAT | typeof CLASSIFI
212
209
  * bound the engine can vouch for: a gateway may exclude reasoning tokens from `max_tokens` (a vLLM-fronted
213
210
  * Qwen gateway answered a cap of 128 with 938 output tokens and `stop`), so an over-long think is cut by the
214
211
  * round-trip timeout (`unavailable` / `timeout`), not by the cap (`parse_error` on an empty reply), and the
215
- * two are attested as the two different facts they are.
212
+ * two are attested as the two different facts they are. The seat's tier is not the classifier's to decide: it reads
213
+ * {@link lowestReasoningSeat}, and only the cap is its own.
216
214
  */
217
215
  export declare function classifierRungSeat(model: Model): typeof CLASSIFIER_OFF_SEAT | typeof CLASSIFIER_LOW_SEAT;
218
216
  /**
@@ -1,5 +1,5 @@
1
1
  import { sameRouteIdentity } from "../../brain/route-adjudicator.js";
2
- import { thinkingOffSpelled } from "../../brain/reasoning.js";
2
+ import { lowestReasoningSeat } from "../../brain/reasoning-request.js";
3
3
  import { AUTO_MODE_CLASSIFIER_CONTRACT_BROKEN_AFTER, AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS, AUTO_MODE_CLASSIFIER_MAX_TOKENS, AUTO_MODE_CLASSIFIER_THINK_BUDGET_TOKENS } from "../auto-mode-defaults.js";
4
4
  import { autoModeClassifierFallbackOf, parseAutoModeResponse } from "../auto-mode.js";
5
5
  import { classifierUnavailableDispositionOf } from "../classifier-unavailable-arm.js";
@@ -80,7 +80,7 @@ export function announceClassifierRoleDefaulted(args) {
80
80
  const { seat } = args;
81
81
  if (seat.defaulted === undefined)
82
82
  return;
83
- const spelled = thinkingOffSpelled(seat.model);
83
+ const spelled = lowestReasoningSeat(seat.model) === "off";
84
84
  deliverEngineNotice(args.onNotice, {
85
85
  code: "classifier.role_defaulted",
86
86
  message: `no classifier role names a model — "${seat.model.id}" classifies this run (${seat.defaulted}); ` +
@@ -195,7 +195,7 @@ export const CLASSIFIER_OFF_SEAT = { reasoning: "off", maxTokens: AUTO_MODE_CLAS
195
195
  export const CLASSIFIER_LOW_SEAT = { reasoning: "low", maxTokens: AUTO_MODE_CLASSIFIER_MAX_TOKENS + AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS };
196
196
  export const CLASSIFIER_THINK_SEAT = { reasoning: "low", maxTokens: AUTO_MODE_CLASSIFIER_MAX_TOKENS + AUTO_MODE_CLASSIFIER_THINK_BUDGET_TOKENS };
197
197
  export function classifierRungSeat(model) {
198
- return thinkingOffSpelled(model) ? CLASSIFIER_OFF_SEAT : CLASSIFIER_LOW_SEAT;
198
+ return lowestReasoningSeat(model) === "off" ? CLASSIFIER_OFF_SEAT : CLASSIFIER_LOW_SEAT;
199
199
  }
200
200
  export const CLASSIFIER_ATTEMPT_SUFFIX = {
201
201
  first: '\nErr on the side of blocking. Your ENTIRE response MUST begin with <block>. Do NOT output any analysis, reasoning, or commentary before <block>. No "Looking at..." or similar preamble.',
@@ -3,6 +3,7 @@ import { checkedMediaByteCap } from "../media-byte-cap.js";
3
3
  import { receiptRefusal, receiveOwnProperties, refuseProxy } from "../own-property-receipt.js";
4
4
  import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
5
5
  import { copyReadDenySeat, READ_DENY_DEPLOYMENT_SEATS } from "../read-face-seats.js";
6
+ import { receiveHostFloor } from "../host-floor.js";
6
7
  import { holdOwnCredentialValues } from "../secret-env.js";
7
8
  export function retainRunnerDeps(deps) {
8
9
  const words = { subject: "RunnerDeps", unit: "seat", moment: "at new Runner" };
@@ -15,6 +16,8 @@ export function retainRunnerDeps(deps) {
15
16
  if (Object.hasOwn(retained, seat))
16
17
  Object.defineProperty(retained, seat, { value: copyReadDenySeat(Reflect.get(retained, seat)), enumerable: true, writable: true, configurable: true });
17
18
  }
19
+ if (Object.hasOwn(retained, "hostFloor"))
20
+ Object.defineProperty(retained, "hostFloor", { value: receiveHostFloor(Reflect.get(retained, "hostFloor")), enumerable: true, writable: true, configurable: true });
18
21
  let consolidationKey;
19
22
  try {
20
23
  const chat = retained.memoryConsolidationDriver?.chat;