@sema-agent/core 7.72.0 → 7.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -404,9 +404,11 @@ export function createOpenAIBrain(given = {}) {
404
404
  let lastDegenCheckReasoning = 0;
405
405
  const detectRep = config.detectRepetition !== false;
406
406
  let emittedTextStart = false;
407
- let emittedThinkingStart = false;
408
- let thinkingClosed = false;
409
407
  let textIndex = 0;
408
+ let nextIndex = 0;
409
+ const segments = [];
410
+ let segmentOpen = false;
411
+ let thinkingIndex = 0;
410
412
  const toolAccum = new Map();
411
413
  const responseIds = responseToolCallIds();
412
414
  let finishReason = null;
@@ -422,25 +424,26 @@ export function createOpenAIBrain(given = {}) {
422
424
  malformedFrames++;
423
425
  malformedSample ??= ctrl.providerWords(data).slice(0, 160);
424
426
  };
425
- const thinkingBlock = { type: "thinking", thinking: "" };
427
+ let thinkingBlock = { type: "thinking", thinking: "" };
426
428
  const textBlock = { type: "text", text: "" };
427
429
  const pushReasoningDelta = (delta) => {
428
430
  if (!delta)
429
431
  return;
430
432
  ctrl.sawContentToken();
431
- if (thinkingClosed)
432
- return;
433
- if (!emittedThinkingStart) {
434
- emittedThinkingStart = true;
433
+ if (!segmentOpen) {
434
+ segmentOpen = true;
435
+ thinkingIndex = nextIndex++;
436
+ thinkingBlock = { type: "thinking", thinking: "" };
437
+ lastDegenCheckReasoning = 0;
435
438
  partial.content = [thinkingBlock];
436
- out.push({ type: "thinking_start", contentIndex: 0, partial: { ...partial } });
439
+ out.push({ type: "thinking_start", contentIndex: thinkingIndex, partial: { ...partial } });
437
440
  }
438
441
  accumReasoning += delta;
439
- thinkingBlock.thinking = accumReasoning;
440
- out.push({ type: "thinking_delta", contentIndex: 0, delta, partial: { ...partial } });
441
- if (detectRep && !degenerate && accumReasoning.length - lastDegenCheckReasoning >= 64) {
442
- lastDegenCheckReasoning = accumReasoning.length;
443
- if (rep.poll(accumReasoning)) {
442
+ thinkingBlock.thinking += delta;
443
+ out.push({ type: "thinking_delta", contentIndex: thinkingIndex, delta, partial: { ...partial } });
444
+ if (detectRep && !degenerate && thinkingBlock.thinking.length - lastDegenCheckReasoning >= 64) {
445
+ lastDegenCheckReasoning = thinkingBlock.thinking.length;
446
+ if (rep.poll(thinkingBlock.thinking)) {
444
447
  degenerate = true;
445
448
  degenFace = "reasoning";
446
449
  ctrl.cancel();
@@ -448,22 +451,27 @@ export function createOpenAIBrain(given = {}) {
448
451
  }
449
452
  };
450
453
  const closeThinking = () => {
451
- if (emittedThinkingStart && !thinkingClosed) {
452
- thinkingClosed = true;
453
- out.push({ type: "thinking_end", contentIndex: 0, content: accumReasoning, partial: { ...partial } });
454
- }
454
+ if (!segmentOpen)
455
+ return false;
456
+ segmentOpen = false;
457
+ segments.push(thinkingBlock.thinking);
458
+ out.push({ type: "thinking_end", contentIndex: thinkingIndex, content: thinkingBlock.thinking, partial: { ...partial } });
459
+ return true;
455
460
  };
456
461
  const pushTextDelta = (delta) => {
457
462
  if (!delta)
458
463
  return;
459
464
  ctrl.sawContentToken();
465
+ const segmentClosed = closeThinking();
460
466
  if (!emittedTextStart) {
461
- closeThinking();
462
467
  emittedTextStart = true;
463
- textIndex = emittedThinkingStart ? 1 : 0;
468
+ textIndex = nextIndex++;
464
469
  partial.content = [textBlock];
465
470
  out.push({ type: "text_start", contentIndex: textIndex, partial: { ...partial } });
466
471
  }
472
+ else if (segmentClosed) {
473
+ partial.content = [textBlock];
474
+ }
467
475
  accumText += delta;
468
476
  textBlock.text = accumText;
469
477
  out.push({ type: "text_delta", contentIndex: textIndex, delta, partial: { ...partial } });
@@ -522,7 +530,7 @@ export function createOpenAIBrain(given = {}) {
522
530
  usageRaw = chunk.usage;
523
531
  if (chunk.usageUnreadable)
524
532
  usageUnreadable = true;
525
- noteResponseModel(partial, chunk.model, model.id);
533
+ noteResponseModel(partial, chunk.model, model.id, ctrl.providerWords);
526
534
  const choice = chunk.choice;
527
535
  if (terminalFrameSeen()) {
528
536
  if (choice !== undefined && choice.finish !== null && choice.finish !== finishReason)
@@ -586,8 +594,8 @@ export function createOpenAIBrain(given = {}) {
586
594
  out.push({ type: "text_end", contentIndex: textIndex, content: textFace, partial: { ...partial } });
587
595
  }
588
596
  const finalContent = [];
589
- if (accumReasoning)
590
- finalContent.push({ type: "thinking", thinking: accumReasoning });
597
+ const thinkingBlocks = segments.map((thinking) => ({ type: "thinking", thinking }));
598
+ finalContent.push(...thinkingBlocks);
591
599
  if (textFace)
592
600
  finalContent.push({ type: "text", text: textFace });
593
601
  const toolCalls = [];
@@ -618,8 +626,7 @@ export function createOpenAIBrain(given = {}) {
618
626
  const repaired = repairTextToolCalls(textFace, names);
619
627
  if (repaired.toolCalls.length > 0) {
620
628
  finalContent.length = 0;
621
- if (accumReasoning)
622
- finalContent.push({ type: "thinking", thinking: accumReasoning });
629
+ finalContent.push(...thinkingBlocks);
623
630
  if (repaired.cleanedText)
624
631
  finalContent.push({ type: "text", text: repaired.cleanedText });
625
632
  for (const repairedCall of repaired.toolCalls) {
@@ -1,4 +1,5 @@
1
1
  import type { Model, PerModelAuth } from "../internal/llm.js";
2
+ import type { AssertAllKeysHandled } from "../core/ask-origin.js";
2
3
  import type { RouteAdjudication, RouteCredential, RoutePairingConfig, RoutePairingPosture, RouteRefusalCode } from "../internal/llm.js";
3
4
  import type { Brain, EngineNotice } from "../core/types.js";
4
5
  import { BrainError } from "./errors.js";
@@ -226,16 +227,33 @@ export interface JudgedRefusal {
226
227
  ok: false;
227
228
  }>;
228
229
  }
230
+ /** Whether a route judgment's answer is a Promise (any object whose `then`, read once, is a function): a judgment answers
231
+ * synchronously, so a Promise is no verdict, and its own settlement belongs to nobody — it must not become an unhandled
232
+ * rejection. That very `then` is handed two empty reactions, called with the answer as `this` (a throw of the call is absorbed
233
+ * too). A plain answer is not touched beyond that one read; a `then` that will not read (a strict Proxy whose `get` throws) shows
234
+ * no `then`, so the answer is no Promise and is read by the `ok` it gives — as 7.73.0 read an answer whose members read the same at
235
+ * every read; reading `then` before `ok` is new (`KL-4241-d` (9)). */
236
+ export declare function settleUnread(answer: unknown): boolean;
237
+ /** What a sentence says for a model whose `id` will not read (an accessor that throws, a revoked proxy). */
238
+ export declare const UNREADABLE_MODEL_ID = "<unreadable model id>";
239
+ /** A model's id for a sentence about it: one guarded read; an id that will not read is said as {@link UNREADABLE_MODEL_ID}. */
240
+ export declare function sayableModelId(model: {
241
+ readonly id: string;
242
+ }): string;
229
243
  /**
230
244
  * THE reading of a route judgment's answer — every seat that asks the deployment Brain's `adjudicateRoute` reads the answer here,
231
245
  * once (the model lane before each hop, a derived seat's pre-flight): `undefined` when the route goes ahead — the judgment
232
246
  * admitted it (`ok: true`) or gave none (`undefined`: no judgment) — else the route as refused. `ok: false` is a refusal, read
233
247
  * member by member; ANY other answer is a judgment that failed ({@link ROUTE_JUDGMENT_FAILED}, the sentence saying how): it
234
- * threw, answered a Promise (a route judgment answers synchronously — a pending answer is no answer, and reading it as one would
235
- * admit every route it was asked about), answered a value that is not a verdict, or a verdict whose members would not read.
236
- * Never throws. `ask` is the call (so its throw is read here); `modelId` names the judged model in the sentence.
248
+ * threw, answered a Promise, whatever `ok` it carries (a route judgment answers synchronously — a pending answer is no answer, and
249
+ * reading it as one would admit every route it was asked about; its settlement is absorbed, {@link settleUnread}), answered a value that is not a verdict, or a verdict whose members would not read.
250
+ * Never throws. `ask` is the call (so its throw is read here); `judged` is the judged model, whose id names it in the sentence —
251
+ * read once, only when there is a refusal to say (a route that goes ahead costs no read of the model), and said as
252
+ * {@link UNREADABLE_MODEL_ID} when it will not read ({@link sayableModelId}).
237
253
  */
238
- export declare function readRouteJudgment(ask: () => unknown, modelId: string): JudgedRefusal | undefined;
254
+ export declare function readRouteJudgment(ask: () => unknown, judged: {
255
+ readonly id: string;
256
+ }): JudgedRefusal | undefined;
239
257
  /**
240
258
  * THE request gate of a first-party brain — the seat that binds a credential where it is first SENT (the table's other
241
259
  * writer is the host's explicit rebind, {@link rebindCredentialOrigin}, which sets a credential's origin by the host's
@@ -373,6 +391,13 @@ export declare function rebindCredentialOrigin(model: Pick<Model, "id" | "baseUr
373
391
  * not ride — the header half of the keyless door the blank key is ({@link keyCarriedBy}).
374
392
  */
375
393
  export declare function applyRouteCredentialHeaders(merged: Record<string, string>, credential: RouteCredential): void;
394
+ /**
395
+ * THE one reading of "a credential header whose value is blank is no credential and does not ride" ({@link isBlankCredential}):
396
+ * every header of `headers` whose name is a credential header ({@link isCredentialHeaderName}) and whose value is blank is deleted
397
+ * from it. Read by {@link applyRouteCredentialHeaders} on a request's merged bag, and by a judge that answers for the same bag
398
+ * before a request is built (`anthropicCredentialHeadersOf`). A credential header's value is a string.
399
+ */
400
+ export declare function dropBlankCredentialHeaders(headers: Record<string, string>): void;
376
401
  /** A brain's construction config, received ONCE by the engine's receipt law for caller objects
377
402
  * ({@link receiveOwnProperties}: a plain object, every own member read once): the request gate and the pre-flight
378
403
  * judge both read this frozen copy, so a config object mutated after construction moves neither and the two cannot
@@ -405,6 +430,10 @@ export declare function createBrainRouteJudge(config: {
405
430
  * built, so a value that is not a boolean is refused at construction rather than at the first request. */
406
431
  requireCredential?: boolean;
407
432
  }): (model: Model, perModelAuth?: PerModelAuth) => RouteAdjudication;
433
+ /** The words of {@link RoutePairingStatus}, spelled (the release manifest and a host's table read them): fenced both ways to the type below, so neither can gain a word the other lacks. */
434
+ export declare const ROUTE_PAIRING_STATUSES: readonly ["ok:per-model", "ok:paired", "ok:keyless", "broken:credential_mismatch", "broken:credential_missing", "broken:credential_origin_mismatch", "broken:credential_answer_conflict", "broken:protocol_plaintext_credentials", "broken:model_unavailable", "unknown"];
435
+ export type RoutePairingStatusesAllListed = AssertAllKeysHandled<Exclude<RoutePairingStatus, (typeof ROUTE_PAIRING_STATUSES)[number]>>;
436
+ export type RoutePairingStatusesAllWords = AssertAllKeysHandled<Exclude<(typeof ROUTE_PAIRING_STATUSES)[number], RoutePairingStatus>>;
408
437
  /**
409
438
  * Per-entry pairing status — the read-face predicate a roster/diagnostic surface annotates entries
410
439
  * with, so a torn pair is visible at configuration time instead of on the first real request.
@@ -9,7 +9,7 @@ import { deliverEngineNotice } from "../core/engine-notice.js";
9
9
  import { uuidv7 } from "../engine/session/uuid.js";
10
10
  import { CREDENTIAL_VOCABULARY, REDACTION_MARKS, isRedactionMark } from "@sema-agent/primitives";
11
11
  import { PROTOCOL_PLAINTEXT_CREDENTIALS_CODE, crossesNetworkInClear } from "../core/protocol-http-auth.js";
12
- import { thrownText } from "../core/thrown-value.js";
12
+ import { readMemberOrUnreadable, thrownText, UNREADABLE } from "../core/thrown-value.js";
13
13
  import { headerBagOnce } from "./request-params.js";
14
14
  const REDACTED_VALUE = REDACTION_MARKS.bare;
15
15
  const REDACTED_USERINFO = REDACTION_MARKS.userinfo;
@@ -553,8 +553,32 @@ const BOUND_BY_WORDS = { declaration: true, table: true, generation: true };
553
553
  function boundByOf(value) {
554
554
  return typeof value === "string" && Object.hasOwn(BOUND_BY_WORDS, value) ? value : undefined;
555
555
  }
556
- export function readRouteJudgment(ask, modelId) {
557
- const failed = (how) => ({ code: ROUTE_JUDGMENT_FAILED, fixHint: `the deployment Brain's route judgment for "${modelId}" ${how}` });
556
+ export function settleUnread(answer) {
557
+ if (typeof answer !== "object" || answer === null)
558
+ return false;
559
+ let then;
560
+ try {
561
+ then = answer.then;
562
+ }
563
+ catch {
564
+ return false;
565
+ }
566
+ if (typeof then !== "function")
567
+ return false;
568
+ Promise.resolve()
569
+ .then(() => Reflect.apply(then, answer, [() => undefined, () => undefined]))
570
+ .catch(() => undefined);
571
+ return true;
572
+ }
573
+ export const UNREADABLE_MODEL_ID = "<unreadable model id>";
574
+ export function sayableModelId(model) {
575
+ const id = readMemberOrUnreadable(model, "id");
576
+ return id === UNREADABLE ? UNREADABLE_MODEL_ID : id;
577
+ }
578
+ export function readRouteJudgment(ask, judged) {
579
+ let said;
580
+ const modelIdOf = () => (said ??= sayableModelId(judged));
581
+ const failed = (how) => ({ code: ROUTE_JUDGMENT_FAILED, fixHint: `the deployment Brain's route judgment for "${modelIdOf()}" ${how}` });
558
582
  let answer;
559
583
  try {
560
584
  answer = ask();
@@ -565,15 +589,13 @@ export function readRouteJudgment(ask, modelId) {
565
589
  if (answer === undefined)
566
590
  return undefined;
567
591
  try {
592
+ if (settleUnread(answer)) {
593
+ return failed("answered a Promise — a route judgment must answer synchronously (a verdict, or undefined for no judgment); nothing was sent");
594
+ }
568
595
  const ok = typeof answer === "object" && answer !== null ? answer.ok : undefined;
569
596
  if (ok === true)
570
597
  return undefined;
571
598
  if (ok !== false) {
572
- const then = typeof answer === "object" && answer !== null ? answer.then : undefined;
573
- if (typeof then === "function") {
574
- Promise.resolve(answer).catch(() => undefined);
575
- return failed("answered a Promise — a route judgment must answer synchronously (a verdict, or undefined for no judgment); nothing was sent");
576
- }
577
599
  return failed(`answered ${describeRejectedValue(answer)}${ok === undefined ? "" : ` whose ok is ${describeRejectedValue(ok)}`} — not a verdict (ok true or false) nor undefined; nothing was sent`);
578
600
  }
579
601
  const code = answer.code;
@@ -592,7 +614,7 @@ export function readRouteJudgment(ask, modelId) {
592
614
  const verdict = {
593
615
  ok: false,
594
616
  code,
595
- detail: { modelId: typeof named === "string" ? named : modelId, ...roots, ...(boundBy !== undefined ? { boundBy } : {}), fixHint },
617
+ detail: { modelId: typeof named === "string" ? named : modelIdOf(), ...roots, ...(boundBy !== undefined ? { boundBy } : {}), fixHint },
596
618
  };
597
619
  return { code, fixHint, verdict };
598
620
  }
@@ -785,9 +807,12 @@ export function applyRouteCredentialHeaders(merged, credential) {
785
807
  }
786
808
  Object.assign(merged, resolvedCredentialFacts.get(credential)?.headers);
787
809
  }
788
- for (const [k, value] of Object.entries(merged)) {
810
+ dropBlankCredentialHeaders(merged);
811
+ }
812
+ export function dropBlankCredentialHeaders(headers) {
813
+ for (const [k, value] of Object.entries(headers)) {
789
814
  if (isCredentialHeaderName(k) && isBlankCredential(value))
790
- delete merged[k];
815
+ delete headers[k];
791
816
  }
792
817
  }
793
818
  export function brainConfigSnapshot(given, subject) {
@@ -822,6 +847,18 @@ export function createBrainRouteJudge(config) {
822
847
  return adjudicateModelRoute(routed, credential, { baseUrl: config.baseUrl, laneDefault: config.laneDefault, requireCredential });
823
848
  };
824
849
  }
850
+ export const ROUTE_PAIRING_STATUSES = Object.freeze([
851
+ "ok:per-model",
852
+ "ok:paired",
853
+ "ok:keyless",
854
+ "broken:credential_mismatch",
855
+ "broken:credential_missing",
856
+ "broken:credential_origin_mismatch",
857
+ "broken:credential_answer_conflict",
858
+ "broken:protocol_plaintext_credentials",
859
+ "broken:model_unavailable",
860
+ "unknown",
861
+ ]);
825
862
  const BROKEN_PAIRING_STATUS = {
826
863
  "route.credential_mismatch": "broken:credential_mismatch",
827
864
  "route.credential_missing": "broken:credential_missing",
@@ -908,7 +945,7 @@ export async function adjudicateDerivedRoute(args) {
908
945
  clearTimeout(timer);
909
946
  }
910
947
  }
911
- return readRouteJudgment(() => judge(args.model, auth), args.model.id);
948
+ return readRouteJudgment(() => judge(args.model, auth), args.model);
912
949
  }
913
950
  export function sameRouteIdentity(a, b) {
914
951
  return a.id === b.id && routeKeyOf(a.baseUrl) === routeKeyOf(b.baseUrl);