@sema-agent/core 7.67.2 → 7.68.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 (505) hide show
  1. package/CHANGELOG.md +1533 -0
  2. package/README.md +18 -9
  3. package/README.zh-CN.md +16 -8
  4. package/dist/agents/agent-definition.d.ts +1 -1
  5. package/dist/agents/agent-definition.js +4 -1
  6. package/dist/agents/cascade.d.ts +2 -2
  7. package/dist/agents/cascade.js +3 -1
  8. package/dist/agents/cumulative-stats.d.ts +2 -1
  9. package/dist/agents/cumulative-stats.js +4 -1
  10. package/dist/agents/list-agents-tool.d.ts +30 -0
  11. package/dist/agents/list-agents-tool.js +45 -3
  12. package/dist/agents/peer-admission.d.ts +2 -2
  13. package/dist/agents/peer-session-drain.d.ts +2 -0
  14. package/dist/agents/peer-session-drain.js +1 -0
  15. package/dist/agents/repair-loop.js +3 -1
  16. package/dist/agents/retain-ledger.d.ts +61 -8
  17. package/dist/agents/retain-ledger.js +25 -3
  18. package/dist/agents/roster-store.d.ts +4 -2
  19. package/dist/agents/send-message-tool.d.ts +1 -1
  20. package/dist/agents/send-message-tool.js +20 -15
  21. package/dist/agents/subagent-steps.js +2 -10
  22. package/dist/agents/subagent.d.ts +3 -0
  23. package/dist/agents/subagent.js +106 -76
  24. package/dist/agents/tool-filter.d.ts +20 -11
  25. package/dist/agents/tool-filter.js +8 -4
  26. package/dist/agents/verify.d.ts +3 -1
  27. package/dist/agents/verify.js +2 -0
  28. package/dist/brain/anthropic.js +4 -4
  29. package/dist/brain/errors.d.ts +20 -0
  30. package/dist/brain/errors.js +114 -0
  31. package/dist/brain/open-responses.js +3 -1
  32. package/dist/brain/openai.js +3 -1
  33. package/dist/brain/provider-message.d.ts +5 -3
  34. package/dist/brain/provider-message.js +35 -8
  35. package/dist/brain/reasoning-request.d.ts +73 -19
  36. package/dist/brain/reasoning-request.js +164 -72
  37. package/dist/brain/reasoning-stamp.d.ts +26 -0
  38. package/dist/brain/reasoning-stamp.js +10 -0
  39. package/dist/brain/reasoning.d.ts +95 -162
  40. package/dist/brain/reasoning.js +31 -86
  41. package/dist/brain/route-adjudicator.d.ts +9 -7
  42. package/dist/brain/route-adjudicator.js +12 -10
  43. package/dist/brain/status-sink.d.ts +19 -64
  44. package/dist/brain/status-sink.js +5 -21
  45. package/dist/brain/stream-engine.d.ts +11 -2
  46. package/dist/brain/stream-engine.js +10 -0
  47. package/dist/core/a2a.d.ts +17 -5
  48. package/dist/core/a2a.js +11 -3
  49. package/dist/core/allow-entry.d.ts +35 -15
  50. package/dist/core/allow-entry.js +47 -60
  51. package/dist/core/ask-headline.d.ts +68 -0
  52. package/dist/core/ask-headline.js +23 -0
  53. package/dist/core/ask-origin.d.ts +36 -8
  54. package/dist/core/ask-origin.js +17 -10
  55. package/dist/core/ask-question.d.ts +34 -7
  56. package/dist/core/ask-question.js +10 -1
  57. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  58. package/dist/core/ask-unresolvable-notice.js +9 -3
  59. package/dist/core/auto-strip.d.ts +53 -0
  60. package/dist/core/auto-strip.js +76 -0
  61. package/dist/core/background-agent-store.d.ts +45 -5
  62. package/dist/core/background-agent-store.js +69 -15
  63. package/dist/core/background-shell.d.ts +2 -2
  64. package/dist/core/caller-text.js +2 -2
  65. package/dist/core/canonical-json.d.ts +13 -0
  66. package/dist/core/canonical-json.js +7 -0
  67. package/dist/core/checkpoint-features.d.ts +66 -20
  68. package/dist/core/checkpoint-features.js +12 -1
  69. package/dist/core/checkpoint-generation.d.ts +1 -1
  70. package/dist/core/checkpoint-queries.d.ts +1 -1
  71. package/dist/core/checkpoint-queries.js +4 -1
  72. package/dist/core/checkpoint-requirements.d.ts +25 -1
  73. package/dist/core/checkpoint-requirements.js +5 -1
  74. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  75. package/dist/core/checkpoint-row-verdict.js +4 -0
  76. package/dist/core/checkpoint-store.d.ts +66 -38
  77. package/dist/core/checkpoint-store.js +15 -6
  78. package/dist/core/child-clamp-seats.d.ts +6 -0
  79. package/dist/core/child-clamp-seats.js +1 -0
  80. package/dist/core/config-refusal-codes.d.ts +1 -1
  81. package/dist/core/config-refusal-codes.js +1 -0
  82. package/dist/core/delegation-frames.d.ts +9 -12
  83. package/dist/core/delegation-frames.js +9 -8
  84. package/dist/core/engine-capabilities.d.ts +21 -8
  85. package/dist/core/engine-capabilities.js +1 -1
  86. package/dist/core/engine-notice.d.ts +147 -34
  87. package/dist/core/engine-notice.js +27 -16
  88. package/dist/core/engine-storage-backend.d.ts +2 -1
  89. package/dist/core/env-budget.js +3 -3
  90. package/dist/core/env-knob-announce.d.ts +10 -10
  91. package/dist/core/env-knob-announce.js +3 -6
  92. package/dist/core/file-history-store.d.ts +29 -4
  93. package/dist/core/file-history-store.js +13 -0
  94. package/dist/core/frame-settlement.d.ts +2 -1
  95. package/dist/core/gate-fold.js +1 -1
  96. package/dist/core/gate-lanes.js +56 -49
  97. package/dist/core/governance-codes.d.ts +39 -3
  98. package/dist/core/governance-codes.js +61 -3
  99. package/dist/core/hooks.d.ts +29 -11
  100. package/dist/core/hooks.js +5 -2
  101. package/dist/core/human-input-projection.js +3 -3
  102. package/dist/core/input-author.d.ts +17 -3
  103. package/dist/core/input-author.js +15 -3
  104. package/dist/core/leg-identity.d.ts +10 -28
  105. package/dist/core/leg-identity.js +1 -21
  106. package/dist/core/lsp.d.ts +18 -13
  107. package/dist/core/lsp.js +30 -22
  108. package/dist/core/mailbox-store.d.ts +1 -1
  109. package/dist/core/mailbox-store.js +4 -4
  110. package/dist/core/mcp-connection-pool.d.ts +93 -4
  111. package/dist/core/mcp-connection-pool.js +104 -1
  112. package/dist/core/mcp-failure.d.ts +38 -12
  113. package/dist/core/mcp-failure.js +9 -13
  114. package/dist/core/mcp-probe.d.ts +4 -3
  115. package/dist/core/mcp-server-link.d.ts +4 -2
  116. package/dist/core/mcp-server-link.js +4 -5
  117. package/dist/core/mcp-server-spec.d.ts +3 -3
  118. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  119. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  120. package/dist/core/mcp.d.ts +40 -6
  121. package/dist/core/mcp.js +39 -13
  122. package/dist/core/memory-engine/content-origin.js +2 -2
  123. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  124. package/dist/core/memory-engine/control-objects.js +2 -10
  125. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  126. package/dist/core/memory-engine/dual-root.js +3 -0
  127. package/dist/core/memory-engine/engine.d.ts +6 -4
  128. package/dist/core/memory-engine/engine.js +32 -29
  129. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  130. package/dist/core/memory-engine/file-backend.js +21 -31
  131. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  132. package/dist/core/memory-engine/frontmatter.js +4 -0
  133. package/dist/core/memory-engine/layout.d.ts +114 -20
  134. package/dist/core/memory-engine/layout.js +340 -22
  135. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  136. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  137. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  138. package/dist/core/memory-engine/sync-client.js +4 -5
  139. package/dist/core/model-fallbacks.d.ts +5 -1
  140. package/dist/core/model-fallbacks.js +3 -3
  141. package/dist/core/model-receipt.d.ts +2 -1
  142. package/dist/core/model-receipt.js +12 -1
  143. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  144. package/dist/core/mods/kernel/dispatch.js +14 -6
  145. package/dist/core/mods/kernel/events.d.ts +8 -5
  146. package/dist/core/mods/kernel/events.js +2 -2
  147. package/dist/core/mods/kernel/index.d.ts +1 -1
  148. package/dist/core/mods/kernel/registration.d.ts +9 -0
  149. package/dist/core/mods/package.js +1 -1
  150. package/dist/core/mods/session-append.d.ts +4 -2
  151. package/dist/core/mods/session-append.js +3 -0
  152. package/dist/core/mods/stations.d.ts +7 -11
  153. package/dist/core/mods/stations.js +4 -7
  154. package/dist/core/mods/tool-call.d.ts +10 -8
  155. package/dist/core/mods/tool-call.js +15 -18
  156. package/dist/core/mounted-mcp.d.ts +0 -4
  157. package/dist/core/mounted-mcp.js +1 -1
  158. package/dist/core/park-noun.d.ts +24 -0
  159. package/dist/core/park-noun.js +21 -0
  160. package/dist/core/park-resumability.d.ts +60 -0
  161. package/dist/core/park-resumability.js +30 -0
  162. package/dist/core/permission-rule-provider.d.ts +24 -2
  163. package/dist/core/permission-rule-provider.js +11 -8
  164. package/dist/core/permission-rule-store.d.ts +8 -1
  165. package/dist/core/permission-rule-store.js +2 -3
  166. package/dist/core/permission-rules.d.ts +2 -1
  167. package/dist/core/permission-rules.js +8 -4
  168. package/dist/core/persisted-rule-arms.d.ts +3 -0
  169. package/dist/core/persisted-rule-arms.js +2 -1
  170. package/dist/core/present-plan-tool.d.ts +47 -3
  171. package/dist/core/present-plan-tool.js +62 -4
  172. package/dist/core/principal-name.d.ts +1 -1
  173. package/dist/core/principal-name.js +5 -5
  174. package/dist/core/process-identity.js +10 -5
  175. package/dist/core/protocol-http-auth.d.ts +30 -9
  176. package/dist/core/protocol-http-auth.js +113 -59
  177. package/dist/core/read-only-shell.js +9 -5
  178. package/dist/core/redaction-marks.d.ts +4 -26
  179. package/dist/core/redaction-marks.js +9 -21
  180. package/dist/core/remote-env.d.ts +43 -16
  181. package/dist/core/remote-env.js +1 -1
  182. package/dist/core/request-copy-projection.d.ts +1 -1
  183. package/dist/core/request-copy-projection.js +40 -50
  184. package/dist/core/resume-config-judge.js +1 -1
  185. package/dist/core/resume-startup-cause.d.ts +35 -18
  186. package/dist/core/resume-startup-cause.js +13 -10
  187. package/dist/core/retention.d.ts +167 -25
  188. package/dist/core/retention.js +100 -20
  189. package/dist/core/roles.d.ts +6 -0
  190. package/dist/core/roles.js +11 -5
  191. package/dist/core/rule-lane-reads.d.ts +3 -0
  192. package/dist/core/rule-lane-reads.js +5 -1
  193. package/dist/core/rule-store-fault.d.ts +70 -0
  194. package/dist/core/rule-store-fault.js +102 -0
  195. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  196. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  197. package/dist/core/runner/announce-once-ledger.js +24 -2
  198. package/dist/core/runner/assemble-result.d.ts +6 -0
  199. package/dist/core/runner/assemble-result.js +1 -1
  200. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  201. package/dist/core/runner/auto-strip-notice.js +59 -0
  202. package/dist/core/runner/branch-window.d.ts +3 -0
  203. package/dist/core/runner/branch-window.js +37 -0
  204. package/dist/core/runner/caller-roster.d.ts +8 -3
  205. package/dist/core/runner/capability-withheld-seat.js +3 -9
  206. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  207. package/dist/core/runner/clock-and-limits.js +30 -0
  208. package/dist/core/runner/contracts.d.ts +58 -35
  209. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  210. package/dist/core/runner/credential-refusal-seat.js +47 -0
  211. package/dist/core/runner/cross-boundary-lane.js +6 -4
  212. package/dist/core/runner/decide-continuation.js +1 -1
  213. package/dist/core/runner/file-history-restore.d.ts +53 -2
  214. package/dist/core/runner/file-history-restore.js +29 -10
  215. package/dist/core/runner/forward-sink.d.ts +14 -1
  216. package/dist/core/runner/forward-sink.js +14 -12
  217. package/dist/core/runner/gate-exit.d.ts +8 -7
  218. package/dist/core/runner/gate-exit.js +13 -13
  219. package/dist/core/runner/git-status-frame.js +2 -4
  220. package/dist/core/runner/initial-run-state.js +1 -1
  221. package/dist/core/runner/main-call-account.d.ts +3 -1
  222. package/dist/core/runner/main-call-account.js +5 -3
  223. package/dist/core/runner/mcp-redial.d.ts +2 -5
  224. package/dist/core/runner/mcp-redial.js +2 -2
  225. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  226. package/dist/core/runner/nested-memory-content.js +73 -13
  227. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  228. package/dist/core/runner/nested-memory-lane.js +152 -76
  229. package/dist/core/runner/park-commit.js +3 -1
  230. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  231. package/dist/core/runner/permission-rule-lanes.js +29 -3
  232. package/dist/core/runner/person-path-rows.d.ts +3 -11
  233. package/dist/core/runner/person-path-rows.js +21 -24
  234. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  235. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  236. package/dist/core/runner/prepare-artifact.js +20 -14
  237. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  238. package/dist/core/runner/prepare-ask-lane.js +6 -5
  239. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  240. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  241. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  242. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  243. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  244. package/dist/core/runner/prepare-config-doors.js +58 -41
  245. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  246. package/dist/core/runner/prepare-context-lane.js +3 -5
  247. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  248. package/dist/core/runner/prepare-defer-classify.js +1 -1
  249. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  250. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  251. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  252. package/dist/core/runner/prepare-file-history.js +117 -46
  253. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  254. package/dist/core/runner/prepare-gate-stations.js +6 -5
  255. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  256. package/dist/core/runner/prepare-hands-readface.js +8 -4
  257. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  258. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  259. package/dist/core/runner/prepare-listings.d.ts +1 -1
  260. package/dist/core/runner/prepare-listings.js +1 -1
  261. package/dist/core/runner/prepare-memory.js +2 -2
  262. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  263. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  264. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  265. package/dist/core/runner/prepare-park-ask.js +7 -9
  266. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  267. package/dist/core/runner/prepare-policy-chain.js +18 -13
  268. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  269. package/dist/core/runner/prepare-project-context.js +5 -3
  270. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  271. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  272. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  273. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  274. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  275. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  276. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  277. package/dist/core/runner/prepare-run-refs.js +8 -7
  278. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  279. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  280. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  281. package/dist/core/runner/prepare-task.js +66 -53
  282. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  283. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  284. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  285. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  286. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  287. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  288. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  289. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  290. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  291. package/dist/core/runner/restore-seat.d.ts +41 -0
  292. package/dist/core/runner/restore-seat.js +38 -0
  293. package/dist/core/runner/resume-admission.js +1 -1
  294. package/dist/core/runner/resume-apply.js +4 -3
  295. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  296. package/dist/core/runner/resume-internals-and-config.js +2 -1
  297. package/dist/core/runner/resume-preflight.js +2 -1
  298. package/dist/core/runner/rewind-files.js +22 -6
  299. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  300. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  301. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  302. package/dist/core/runner/run-brain-sinks.js +6 -6
  303. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  304. package/dist/core/runner/run-git-lane.d.ts +2 -0
  305. package/dist/core/runner/run-git-lane.js +2 -1
  306. package/dist/core/runner/run-harness-handlers.js +5 -4
  307. package/dist/core/runner/run-identity-wiring.js +20 -12
  308. package/dist/core/runner/run-leg.js +31 -72
  309. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  310. package/dist/core/runner/run-notification-lane.js +2 -4
  311. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  312. package/dist/core/runner/run-reasoning-seat.js +13 -18
  313. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  314. package/dist/core/runner/run-terminal-adoption.js +4 -8
  315. package/dist/core/runner/run-turn-boundary.js +6 -3
  316. package/dist/core/runner/runtask.d.ts +9 -4
  317. package/dist/core/runner/runtask.js +29 -22
  318. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  319. package/dist/core/runner/shell-env-withheld.js +2 -7
  320. package/dist/core/runner/side-call-account.d.ts +5 -6
  321. package/dist/core/runner/side-call-account.js +2 -2
  322. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  323. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  324. package/dist/core/runner/stream-settle-backstop.js +4 -6
  325. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  326. package/dist/core/runner/stream-steer-verb.js +4 -4
  327. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  328. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  329. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  330. package/dist/core/runner/teardown-bounded.js +7 -0
  331. package/dist/core/runner/terminal-account.js +41 -13
  332. package/dist/core/runner/terminal-projection.d.ts +1 -5
  333. package/dist/core/runner/tool-end-body.d.ts +9 -3
  334. package/dist/core/runner/tool-end-body.js +6 -3
  335. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  336. package/dist/core/runner/tool-output-projection.js +10 -14
  337. package/dist/core/runner/turn-attachments.d.ts +3 -2
  338. package/dist/core/runner/turn-attachments.js +12 -5
  339. package/dist/core/runner-deps.d.ts +6 -6
  340. package/dist/core/runtime-caps.d.ts +2 -1
  341. package/dist/core/secret-env.d.ts +20 -3
  342. package/dist/core/secret-env.js +13 -15
  343. package/dist/core/session-checkout.d.ts +115 -15
  344. package/dist/core/session-checkout.js +435 -136
  345. package/dist/core/session-policy-store.js +21 -3
  346. package/dist/core/session-reconcile.js +1 -0
  347. package/dist/core/session-store.js +2 -0
  348. package/dist/core/session.d.ts +11 -1
  349. package/dist/core/shell-run-candidates.d.ts +1 -0
  350. package/dist/core/shell-run-candidates.js +1 -1
  351. package/dist/core/shutdown-debug.d.ts +6 -5
  352. package/dist/core/shutdown-debug.js +5 -1
  353. package/dist/core/skill-grant.js +4 -1
  354. package/dist/core/skills-directory.js +5 -3
  355. package/dist/core/spec-contract.d.ts +1 -1
  356. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  357. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  358. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  359. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  360. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  361. package/dist/core/task-event.d.ts +48 -27
  362. package/dist/core/task-notification.d.ts +15 -9
  363. package/dist/core/task-notification.js +12 -0
  364. package/dist/core/task-registry-agent.d.ts +24 -22
  365. package/dist/core/task-registry-agent.js +65 -46
  366. package/dist/core/task-registry-shared.d.ts +17 -5
  367. package/dist/core/task-registry.d.ts +17 -6
  368. package/dist/core/task-registry.js +6 -1
  369. package/dist/core/task-result.d.ts +71 -25
  370. package/dist/core/task-spec-members.d.ts +0 -1
  371. package/dist/core/task-spec-members.js +1 -1
  372. package/dist/core/task-spec.d.ts +60 -52
  373. package/dist/core/task-stream.d.ts +45 -12
  374. package/dist/core/terminal-cause.d.ts +45 -8
  375. package/dist/core/terminal-cause.js +5 -0
  376. package/dist/core/tool-card-bound.d.ts +32 -0
  377. package/dist/core/tool-card-bound.js +33 -0
  378. package/dist/core/tool-catalog-entries.d.ts +9 -0
  379. package/dist/core/tool-catalog-entries.js +48 -0
  380. package/dist/core/tool-errors.d.ts +4 -3
  381. package/dist/core/tool-face.d.ts +3 -3
  382. package/dist/core/tool-mount-facts.d.ts +3 -2
  383. package/dist/core/tool-mount-facts.js +1 -1
  384. package/dist/core/tool-mount-static.js +7 -5
  385. package/dist/core/tool-policy.d.ts +21 -19
  386. package/dist/core/tool-policy.js +5 -6
  387. package/dist/core/tool-registry.d.ts +3 -1
  388. package/dist/core/tool-registry.js +15 -1
  389. package/dist/core/tool-result-store.d.ts +9 -3
  390. package/dist/core/tool-result-store.js +14 -1
  391. package/dist/core/tool-roster.d.ts +6 -0
  392. package/dist/core/tool-roster.js +18 -0
  393. package/dist/core/tool-spec.d.ts +17 -8
  394. package/dist/core/trace.d.ts +35 -31
  395. package/dist/core/types.d.ts +2 -2
  396. package/dist/core/untrusted-egress.d.ts +19 -7
  397. package/dist/core/untrusted-egress.js +26 -7
  398. package/dist/core/untrusted-text.d.ts +6 -18
  399. package/dist/core/untrusted-text.js +11 -4
  400. package/dist/core/user-attachment.d.ts +9 -6
  401. package/dist/core/user-attachment.js +12 -10
  402. package/dist/core/user-row-origin.d.ts +44 -25
  403. package/dist/core/user-row-origin.js +30 -20
  404. package/dist/core/wiring-manifest.d.ts +26 -7
  405. package/dist/core/wiring-manifest.js +14 -11
  406. package/dist/core/workspace-snapshot.d.ts +3 -1
  407. package/dist/core/workspace-snapshot.js +1 -0
  408. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  409. package/dist/engine/execution-env/node-execution-env.js +127 -67
  410. package/dist/engine/harness/agent-harness.d.ts +4 -5
  411. package/dist/engine/harness/agent-harness.js +2 -7
  412. package/dist/engine/harness/types.d.ts +51 -19
  413. package/dist/engine/harness/types.js +28 -1
  414. package/dist/engine/llm/types.d.ts +26 -14
  415. package/dist/engine/llm/types.js +2 -2
  416. package/dist/engine/loop/agent-loop.d.ts +2 -2
  417. package/dist/engine/loop/agent-loop.js +51 -275
  418. package/dist/engine/loop/types.d.ts +0 -18
  419. package/dist/engine/session/import-validate.d.ts +3 -0
  420. package/dist/engine/session/import-validate.js +34 -2
  421. package/dist/engine/session/repo-utils.d.ts +42 -4
  422. package/dist/engine/session/repo-utils.js +33 -5
  423. package/dist/engine/session/session.d.ts +41 -14
  424. package/dist/engine/session/session.js +96 -25
  425. package/dist/index.d.ts +21 -16
  426. package/dist/index.js +16 -10
  427. package/dist/orchestration/run-spec.d.ts +1 -1
  428. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  429. package/dist/orchestration/run-workflow-tool.js +15 -19
  430. package/dist/orchestration/workflow-governance.js +13 -21
  431. package/dist/orchestration/workflow-observe.d.ts +4 -3
  432. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  433. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  434. package/dist/orchestration/workflow-record-artifact.js +32 -0
  435. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  436. package/dist/orchestration/workflow-script-store.js +20 -1
  437. package/dist/orchestration/workflow-types.d.ts +33 -3
  438. package/dist/orchestration/workflow.d.ts +24 -14
  439. package/dist/orchestration/workflow.js +52 -23
  440. package/dist/prompt-assembly/artifact.js +4 -8
  441. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  442. package/dist/prompt-assembly/catalog/engine.js +30 -0
  443. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  444. package/dist/prompt-assembly/catalog/index.js +2 -2
  445. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  446. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  447. package/dist/prompt-assembly/epoch.js +6 -8
  448. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  449. package/dist/stores/file/background-agent-store.js +5 -6
  450. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  451. package/dist/stores/file/checkpoint-store.js +7 -3
  452. package/dist/stores/file/file-history-store.d.ts +8 -0
  453. package/dist/stores/file/file-history-store.js +72 -0
  454. package/dist/stores/file/fs-atomic.js +17 -12
  455. package/dist/stores/file/index.js +11 -5
  456. package/dist/stores/file/mailbox-store.js +13 -4
  457. package/dist/stores/file/permission-rule-store.js +14 -13
  458. package/dist/stores/file/shared-ledger.d.ts +4 -0
  459. package/dist/stores/file/shared-ledger.js +4 -0
  460. package/dist/stores/file/task-list-store.js +12 -3
  461. package/dist/stores/file/workflow-run-store.js +1 -0
  462. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  463. package/dist/tools/fs/bash-program-position.js +1 -1
  464. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  465. package/dist/tools/fs/bound-open.d.ts +97 -0
  466. package/dist/tools/fs/bound-open.js +103 -0
  467. package/dist/tools/fs/containment-face.d.ts +2 -2
  468. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  469. package/dist/tools/fs/fs-pdf.js +31 -23
  470. package/dist/tools/fs/fs-read.d.ts +24 -17
  471. package/dist/tools/fs/fs-read.js +84 -53
  472. package/dist/tools/fs/fs-shared.d.ts +14 -12
  473. package/dist/tools/fs/fs-shared.js +5 -4
  474. package/dist/tools/fs/fs-write.d.ts +2 -2
  475. package/dist/tools/fs/fs-write.js +20 -12
  476. package/dist/tools/fs/index.d.ts +4 -4
  477. package/dist/tools/fs/index.js +2 -2
  478. package/dist/tools/fs/notebook.d.ts +1 -1
  479. package/dist/tools/fs/pdf.d.ts +12 -3
  480. package/dist/tools/fs/pdf.js +22 -9
  481. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  482. package/dist/tools/fs/read-deny-home.js +8 -11
  483. package/dist/tools/fs/safety.d.ts +3 -2
  484. package/dist/tools/fs/shell-read-check.js +10 -9
  485. package/dist/tools/monitor.d.ts +6 -5
  486. package/dist/tools/task-list.d.ts +16 -6
  487. package/dist/tools/task-list.js +4 -0
  488. package/dist/tools/web.d.ts +9 -1
  489. package/dist/tools/web.js +8 -3
  490. package/dist/tools/worktree.d.ts +7 -5
  491. package/dist/tools/worktree.js +4 -3
  492. package/package.json +4 -3
  493. package/test/export-surface.snapshot.json +93 -7
  494. package/wire-changes/core-stores-sql@7.67.3.json +39 -0
  495. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  496. package/wire-changes/core@7.67.3.json +65 -0
  497. package/wire-changes/core@7.68.0.json +4257 -0
  498. package/wire-changes/mods-kernel@7.67.3.json +39 -0
  499. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  500. package/wire-changes/primitives@7.67.3.json +39 -0
  501. package/wire-changes/primitives@7.68.0.json +253 -0
  502. package/wire-changes/wiki-gate@7.67.3.json +39 -0
  503. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  504. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  505. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -1,16 +1,15 @@
1
1
  import { describeRejectedValue } from "../core/tool-search-setting.js";
2
2
  import { createHash } from "node:crypto";
3
3
  import { BrainError } from "./errors.js";
4
- import { reportCredentialOriginRefusal } from "./status-sink.js";
4
+ import { reportCredentialRefusal } from "./status-sink.js";
5
5
  import { receiptRefusal, receiveOwnProperties } from "../core/own-property-receipt.js";
6
6
  import { credentialHeaderValues, holdOwnCredentialValues, isBlankCredential, isCredentialHeaderName, isSchemedCredentialHeader } from "../core/secret-env.js";
7
7
  import { deliverEngineNotice } from "../core/engine-notice.js";
8
8
  import { uuidv7 } from "../engine/session/uuid.js";
9
- import { REDACTION_MARKS, WITHHELD_VALUE_MARK } from "../core/redaction-marks.js";
10
- import { CREDENTIAL_VOCABULARY } from "@sema-agent/primitives";
9
+ import { CREDENTIAL_VOCABULARY, REDACTION_MARKS, isRedactionMark } from "@sema-agent/primitives";
11
10
  import { PROTOCOL_PLAINTEXT_CREDENTIALS_CODE, crossesNetworkInClear } from "../core/protocol-http-auth.js";
12
- const REDACTED_VALUE = WITHHELD_VALUE_MARK;
13
- const REDACTED_CREDENTIALS = REDACTION_MARKS.credentials;
11
+ const REDACTED_VALUE = REDACTION_MARKS.bare;
12
+ const REDACTED_USERINFO = REDACTION_MARKS.userinfo;
14
13
  function servableParse(raw) {
15
14
  let u;
16
15
  try {
@@ -92,7 +91,7 @@ export function displayUrlOf(url) {
92
91
  const cut = key.search(/[?#]/);
93
92
  const head = cut === -1 ? key : key.slice(0, cut);
94
93
  const at = head.lastIndexOf("@");
95
- const shown = at === -1 ? head : `${REDACTED_VALUE}@${head.slice(at + 1)}`;
94
+ const shown = at === -1 ? head : `${REDACTED_USERINFO}@${head.slice(at + 1)}`;
96
95
  return cut === -1 ? shown : `${shown}${key[cut]}${REDACTED_VALUE}`;
97
96
  }
98
97
  const read = readQuery(u.search);
@@ -148,7 +147,7 @@ function judgeRequestRoot(url, seat) {
148
147
  `outage, so it would be retried for the whole backoff ladder instead of refused here.`);
149
148
  }
150
149
  if (parsed.username !== "" || parsed.password !== "") {
151
- throw new BrainError("invalid_request", `${seat} carries credentials in its authority (${parsed.protocol}//${REDACTED_CREDENTIALS}@${parsed.host}${parsed.pathname}) — ` +
150
+ throw new BrainError("invalid_request", `${seat} carries credentials in its authority (${parsed.protocol}//${REDACTED_USERINFO}@${parsed.host}${parsed.pathname}) — ` +
152
151
  `a request cannot be built from a URL with userinfo, so every call through this brain would fail: put the ` +
153
152
  `credential on the apiKey knob or an auth header and leave the URL bare`);
154
153
  }
@@ -190,7 +189,7 @@ const AUTHORITY_USERINFO = (() => {
190
189
  return new RegExp(row.match.source, row.match.flags);
191
190
  })();
192
191
  export function stripUrlCredentials(text) {
193
- return text.replace(AUTHORITY_USERINFO, `$1${REDACTED_CREDENTIALS}@`);
192
+ return text.replace(AUTHORITY_USERINFO, (match, scheme, userinfo) => isRedactionMark(userinfo.slice(0, -1)) ? match : `${scheme}${REDACTED_USERINFO}@`);
194
193
  }
195
194
  export function resolveRequestRoot(modelBaseUrl, configBaseUrl, laneDefault = "") {
196
195
  return resolveRequestRootOf(modelBaseUrl, configBaseUrl, laneDefault).root;
@@ -439,9 +438,12 @@ export function routeRefusalText(verdict) {
439
438
  return `${verdict.code}: ${verdict.detail.fixHint}`;
440
439
  }
441
440
  export function routeRefusalError(verdict) {
442
- const { modelId, boundOrigin, requestOrigin } = verdict.detail;
441
+ const { modelId, boundOrigin, requestOrigin, requestBaseUrl, configBaseUrl } = verdict.detail;
443
442
  if (verdict.code === "route.credential_origin_mismatch" && boundOrigin !== undefined && requestOrigin !== undefined) {
444
- reportCredentialOriginRefusal({ modelId, boundOrigin, requestOrigin });
443
+ reportCredentialRefusal({ code: verdict.code, modelId, boundOrigin, requestOrigin });
444
+ }
445
+ else if (verdict.code === "route.credential_mismatch") {
446
+ reportCredentialRefusal({ code: verdict.code, modelId, requestBaseUrl, configBaseUrl: configBaseUrl ?? "" });
445
447
  }
446
448
  return new BrainError("invalid_request", routeRefusalText(verdict));
447
449
  }
@@ -1,5 +1,4 @@
1
1
  import type { BrainRetryErrClass, BrainStatus, BrainStatusSeat } from "../core/types.js";
2
- import type { ReasoningWireFacts } from "./reasoning.js";
3
2
  import type { CapabilityDeclaration, ModelCapability } from "./model-capability.js";
4
3
  /** Run `fn` with a per-task brain-status sink in scope. ALS propagates it through the async brain calls
5
4
  * inside `fn` (the harness's prompt → brain.stream → connect/retry loop), so {@link emitBrainStatus}
@@ -85,59 +84,6 @@ export type BrainTelemetry = {
85
84
  export declare function runWithBrainTelemetry<T>(emit: (t: BrainTelemetry) => void, fn: () => Promise<T>): Promise<T>;
86
85
  /** Report a brain-layer fallback/telemetry event to the active per-task sink, if any. */
87
86
  export declare function emitBrainTelemetry(t: BrainTelemetry): void;
88
- /**
89
- * Run `fn` with a per-task REASONING-WIRE-FACTS sink in scope — the THIRD brain→runner ALS channel,
90
- * same decoupling contract as its two siblings (no brain-interface field, no per-call option, no-op
91
- * outside the scope, an emit must never change a call's outcome).
92
- *
93
- * What it carries and WHY it is a channel rather than a runner-side computation: the reporting
94
- * resolver's cap-wins arm ({@link import("./reasoning.js").budgetCapSkipsThinking}) needs facts that
95
- * belong to ONE outgoing request — the output cap that actually reached the wire and whether it was a
96
- * HARD bound. The runner's per-leg eager mint cannot know them without re-deriving the adapter's own
97
- * cap precedence chain (engine override > caller `options.maxTokens` > `model.maxTokens` >
98
- * brain-construction default) — a SECOND source of truth that a deployment's own brain, a
99
- * construction-time default or a per-attempt engine override would silently desync. So the MINTER
100
- * reports the facts it judged — the law `SSERequest.outputCapTokens` already states for the overflow
101
- * recovery ("what the adapter actually put on the wire") — and the resolver stays one predicate.
102
- *
103
- * REVOKED ON SETTLEMENT, unlike its two siblings, because this sink WRITES to a seat later read into
104
- * a returned value instead of pushing an advisory frame. `AsyncLocalStorage.run` does not revoke the
105
- * store from async resources created inside `fn`: a brain call the engine ABANDONED (the guardrail's
106
- * whole purpose) keeps the scope alive in its own continuation and can call `observe` long after the
107
- * task settled — mutating a resolution whose `TaskResult` was already assembled and handed back. The
108
- * scope therefore carries a liveness flag cleared when `fn`'s promise settles, which is also the
109
- * "freeze before result assembly" boundary: assembly runs after the brain-driving call resolves, so
110
- * a report that could still land is exactly one that arrives before the freeze.
111
- *
112
- * Passing a NO-OP `observe` is the documented way to SHIELD a nested internal brain call (compaction
113
- * summary, side query): it installs a fresh innermost scope for the duration, so the inner call's
114
- * reports are swallowed instead of restating the outer leg's posture — the same shape the status sink
115
- * uses for the same reason ("background/internal brain calls are not surfaced").
116
- */
117
- export declare function runWithReasoningWireFacts<T>(observe: (f: ReasoningWireFacts) => void, fn: () => Promise<T>): Promise<T>;
118
- /**
119
- * Report the reasoning wire facts of the request the engine has SELECTED to send, to the active
120
- * per-task sink, if any.
121
- *
122
- * Call it from the adapter's `onCommitted` hook, never from `buildRequest`: the context-overflow
123
- * recovery builds candidate requests speculatively and may decline them, and a declined candidate's
124
- * facts would otherwise be reported against a request that was never sent (the exact hazard
125
- * `onCommitted` exists for).
126
- *
127
- * Precisely what that buys, since the hook's own summary ("becomes the one that is sent") is a shade
128
- * stronger than its position: the engine calls it immediately after choosing a request and BEFORE the
129
- * attempt loop's abort check and `doFetch`, so a call aborted before its first connect can still have
130
- * reported. The distinction that matters here is nonetheless the one the hook does guarantee — a
131
- * DECLINED candidate never reports, so the facts always belong to the request the adapter's decision
132
- * was made about. The residual (a selected-but-never-connected request on an aborting leg) describes
133
- * the posture that leg was about to run under, and is not worth moving a hook three adapters share
134
- * their own diagnostics attribution on.
135
- *
136
- * Fire-and-forget and swallow-guarded like its siblings — an observability fact must never turn a
137
- * settled brain call into a failure — and inert once its scope has settled (see
138
- * {@link runWithReasoningWireFacts}).
139
- */
140
- export declare function reportReasoningWireFacts(facts: ReasoningWireFacts): void;
141
87
  /** What a request that is about to be sent had stripped from its model's `extraBody`: the wire adapter's `api`, the catalog id
142
88
  * the request was sent as, and the stripped key NAMES (never a value), in `extraBody`'s order. */
143
89
  export interface ExtraBodyDroppedReport {
@@ -146,7 +92,7 @@ export interface ExtraBodyDroppedReport {
146
92
  keys: readonly string[];
147
93
  }
148
94
  /**
149
- * Run `fn` with a per-run extraBody-strip sink in scope — the FOURTH brain→runner ALS channel, same decoupling contract as
95
+ * Run `fn` with a per-run extraBody-strip sink in scope — the THIRD brain→runner ALS channel, same decoupling contract as
150
96
  * its siblings (no brain-interface field, no per-call option, no-op outside the scope, a report never changes a call's
151
97
  * outcome). Unlike them it spans the WHOLE leg (the Runner scopes it around everything the leg does, the end-of-task
152
98
  * compaction included), is NOT shielded around the leg's internal calls (the compaction summary, a side query fired from a
@@ -158,24 +104,33 @@ export declare function runWithExtraBodyDropped<T>(observe: (r: ExtraBodyDropped
158
104
  /** Report the strip of the request the engine has SELECTED to send, to the active per-run sink, if any (called at the
159
105
  * engine's commit points, never from `buildRequest`, which is also built speculatively). */
160
106
  export declare function reportExtraBodyDropped(report: ExtraBodyDroppedReport): void;
161
- /** A request refused because the per-model credential it would carry is bound to another origin: the catalog id it was
162
- * for and the two origins, each in its DISPLAY spelling. Never a value, never a digest of one. */
163
- export interface CredentialOriginRefusalReport {
107
+ /** A request refused at the gate because the credential it would carry does not belong to the root it was going to, one member
108
+ * per refusal code, each naming the catalog id it was for and the roots in their DISPLAY spelling (never a value, never a digest
109
+ * of one): `route.credential_origin_mismatch` — a per-model credential bound to another origin (that origin and the request's);
110
+ * `route.credential_mismatch` — the deployment credential paired with another root (the request's root and the declared root,
111
+ * empty when the brain declares none). */
112
+ export type CredentialRefusalReport = {
113
+ code: "route.credential_origin_mismatch";
164
114
  modelId: string;
165
115
  boundOrigin: string;
166
116
  requestOrigin: string;
167
- }
117
+ } | {
118
+ code: "route.credential_mismatch";
119
+ modelId: string;
120
+ requestBaseUrl: string;
121
+ configBaseUrl: string;
122
+ };
168
123
  /**
169
- * Run `fn` with a per-run credential-origin refusal sink in scope — the FIFTH brain→runner ALS channel, with the fourth's
124
+ * Run `fn` with a per-run credential refusal sink in scope — the FOURTH brain→runner ALS channel, with the third's
170
125
  * shape and for its reasons: the WHOLE leg (a refused compaction summary, side query or classifier call is refused for the
171
126
  * same reason as a turn), not shielded around the leg's internal calls, not revoked on settlement, no-op outside the scope.
172
127
  * The refusal is already decided when it is reported.
173
128
  */
174
- export declare function runWithCredentialOriginRefusals<T>(observe: (r: CredentialOriginRefusalReport) => void, fn: () => Promise<T>): Promise<T>;
175
- /** Report a credential-origin refusal to the active per-run sink, if any (called by the request gate's refusal,
129
+ export declare function runWithCredentialRefusals<T>(observe: (r: CredentialRefusalReport) => void, fn: () => Promise<T>): Promise<T>;
130
+ /** Report a credential refusal to the active per-run sink, if any (called by the request gate's refusal,
176
131
  * `routeRefusalError`; a judgment that only advises reports nothing). The
177
132
  * observer is the Runner's own seat, whose one delivery is the guarded `deliverEngineNotice` — nothing is swallowed here. */
178
- export declare function reportCredentialOriginRefusal(report: CredentialOriginRefusalReport): void;
133
+ export declare function reportCredentialRefusal(report: CredentialRefusalReport): void;
179
134
  /** A request that withheld a capability from the model it was sent to: the model, the capability, the model's declaration
180
135
  * that withheld it (`capabilityOf`), and how many blocks it replaced. */
181
136
  export interface CapabilityWithheldReport {
@@ -185,7 +140,7 @@ export interface CapabilityWithheldReport {
185
140
  count: number;
186
141
  }
187
142
  /**
188
- * Run `fn` with a per-run withheld-capability sink in scope — the SIXTH brain→runner ALS channel, with the fourth's shape
143
+ * Run `fn` with a per-run withheld-capability sink in scope — the FIFTH brain→runner ALS channel, with the third's shape
189
144
  * and for its reasons: the WHOLE leg (the end-of-task compaction runs after the leg's prompt, and a child leg running
190
145
  * inside its parent's tool call must report to its own leg, not to the scope it inherited), not shielded around the leg's
191
146
  * internal calls, not revoked on settlement, no-op outside the scope.
@@ -47,22 +47,6 @@ export function emitBrainTelemetry(t) {
47
47
  catch {
48
48
  }
49
49
  }
50
- const reasoningFactsSinkStore = new AsyncLocalStorage();
51
- export function runWithReasoningWireFacts(observe, fn) {
52
- const scope = { observe, live: true };
53
- return reasoningFactsSinkStore.run(scope, fn).finally(() => {
54
- scope.live = false;
55
- });
56
- }
57
- export function reportReasoningWireFacts(facts) {
58
- try {
59
- const sink = reasoningFactsSinkStore.getStore();
60
- if (sink?.live === true)
61
- sink.observe(facts);
62
- }
63
- catch {
64
- }
65
- }
66
50
  const extraBodyDroppedSinkStore = new AsyncLocalStorage();
67
51
  export function runWithExtraBodyDropped(observe, fn) {
68
52
  return extraBodyDroppedSinkStore.run({ observe }, fn);
@@ -74,12 +58,12 @@ export function reportExtraBodyDropped(report) {
74
58
  catch {
75
59
  }
76
60
  }
77
- const credentialOriginRefusalSinkStore = new AsyncLocalStorage();
78
- export function runWithCredentialOriginRefusals(observe, fn) {
79
- return credentialOriginRefusalSinkStore.run({ observe }, fn);
61
+ const credentialRefusalSinkStore = new AsyncLocalStorage();
62
+ export function runWithCredentialRefusals(observe, fn) {
63
+ return credentialRefusalSinkStore.run({ observe }, fn);
80
64
  }
81
- export function reportCredentialOriginRefusal(report) {
82
- credentialOriginRefusalSinkStore.getStore()?.observe(report);
65
+ export function reportCredentialRefusal(report) {
66
+ credentialRefusalSinkStore.getStore()?.observe(report);
83
67
  }
84
68
  const capabilityWithheldSinkStore = new AsyncLocalStorage();
85
69
  export function runWithCapabilityWithheld(observe, fn) {
@@ -2,6 +2,7 @@ import { type AssistantMessage, type Model, type Usage, createAssistantMessageEv
2
2
  import type { BrainRetryErrClass } from "../core/types.js";
3
3
  import type { AssertAllKeysHandled } from "../core/ask-origin.js";
4
4
  import { type RequestRoute } from "./request-route.js";
5
+ import { type RequestReasoning } from "./reasoning-stamp.js";
5
6
  import { type ProviderDialect } from "./provider-dialect.js";
6
7
  import { type BrainTimeoutConfig } from "./timeout.js";
7
8
  /**
@@ -158,6 +159,13 @@ export interface SSERequest {
158
159
  * than on each failure. Absent = the adapter states none.
159
160
  */
160
161
  route?: RequestRoute;
162
+ /**
163
+ * The tier this request was built for and what its thinking keys say (the wire applier's `carried`), when it was built with
164
+ * a tier. The engine stamps the committed request's reasoning, with the `Model` it was handed, on the call's terminal
165
+ * message — the success it streamed and a failure the engine itself ends it with alike — so the message carries the
166
+ * answer of the request that produced it ({@link import("./reasoning-stamp.js").reasoningStampOf}). Absent = nothing to stamp.
167
+ */
168
+ reasoning?: RequestReasoning;
161
169
  /**
162
170
  * Called by the engine once, if and only if THIS request becomes the one that is sent.
163
171
  *
@@ -236,8 +244,9 @@ export interface StreamParser {
236
244
  * - `hasSubstantiveText` — non-blank answer text (or a streamed refusal) has been emitted → tier A
237
245
  * (partial finalize) territory.
238
246
  * - `hasCompletedToolCall` — at least one tool call CLOSED successfully (a `toolcall_end` was
239
- * emitted, so an in-stream executor may already be running it) → tier A; also the retry-safety
240
- * assertion (§0.5-4): a re-send is FORBIDDEN once this is true (double execution).
247
+ * emitted: consumers have already been told of the call) → tier A; also the retry-safety
248
+ * assertion (§0.5-4): a re-send is FORBIDDEN once this is true (it would replace a response whose completed
249
+ * call consumers have already seen).
241
250
  * - `hasOnlyThinking` — thinking streamed but nothing substantive (no non-blank text, no completed
242
251
  * tool call) → tier B (seal + whole-turn retry). A dangling tool-call accumulation alongside the
243
252
  * thinking does not veto this (nothing was admitted; the retry's snapshot replacement drops it).
@@ -4,6 +4,7 @@ import { FLOOR_OUTPUT_TOKENS, parseContextOverflow, planOutputCapAdjustment } fr
4
4
  import { abortLikeName, BrainError, brainErrorCodeOf, classifyFetchThrow, classifyHttp, describeNetworkError, isProviderEchoShape, namesTheFailure, proxyTunnelRefusedSentence, readConnectFailure, readProviderErrorCode, readProviderRequestId, refusedTheRequest, thrownBrainFailure } from "./errors.js";
5
5
  import { stripUrlCredentials } from "./route-adjudicator.js";
6
6
  import { admittedRequestRoute } from "./request-route.js";
7
+ import { stampReasoning } from "./reasoning-stamp.js";
7
8
  import { isTransientStatus, isProviderCondition, isProviderConditionSource, judgeHttpFailure, PROVIDER_CONDITION_TRAITS, resolveProviderDialect, } from "./provider-dialect.js";
8
9
  import { FAST_MAX_BACKOFF_MS, providerWaitHint, retryBackoffMs } from "./retry.js";
9
10
  import { bindBrainStatusEmitter, emitBrainStatus, emitBrainTelemetry, reportExtraBodyDropped } from "./status-sink.js";
@@ -293,6 +294,14 @@ export function runStreamingBrain(args) {
293
294
  const { model, doFetch, signal, config, httpLabel, buildRequest, makeParser, stallTimeouts } = args;
294
295
  const callRetryCap = args.maxRetries !== undefined && Number.isFinite(args.maxRetries) && args.maxRetries >= 0 ? Math.floor(args.maxRetries) : Infinity;
295
296
  const out = createAssistantMessageEventStream();
297
+ let reasoningSeen;
298
+ const pushEvent = out.push.bind(out);
299
+ out.push = (event) => {
300
+ const terminal = event.type === "done" ? event.message : event.type === "error" ? event.error : undefined;
301
+ if (terminal !== undefined && reasoningSeen !== undefined)
302
+ stampReasoning(terminal, { model, ...reasoningSeen });
303
+ pushEvent(event);
304
+ };
296
305
  let cleanup;
297
306
  let announcedRetry = false;
298
307
  let announcedWait = false;
@@ -398,6 +407,7 @@ export function runStreamingBrain(args) {
398
407
  reportRequestStrip(model, r);
399
408
  routeSeen = admittedRequestRoute(r.route);
400
409
  declaredSeen = r.declared;
410
+ reasoningSeen = r.reasoning;
401
411
  };
402
412
  commit(req);
403
413
  const dialect = resolveProviderDialect(req.url, model.api);
@@ -90,14 +90,19 @@ export interface MaterializedA2a {
90
90
  * `cause` when there is one. A peer whose card does not offer one has no entry. The Runner forwards these to
91
91
  * `onError(phase:"a2a")`. */
92
92
  warnings: Error[];
93
- /** One entry per DECLARED peer, in declaration order, ready or failed — the declaration as this materialization read it once. */
93
+ /** One entry per declared peer that was DIALED, in declaration order, ready or failed — the declaration as this materialization read it
94
+ * once. A run's materialization asks the leg's dial predicate first: a peer it kept from the dial (the run's tool valve leaves nothing of
95
+ * it) is declared and has no entry. The library entrance {@link materializeA2aTools} passes no dial predicate, so for a library caller this is
96
+ * one entry per declared peer. */
94
97
  statuses: A2aPeerStatus[];
95
- /** Re-read one peer's card (or every declared peer) and re-derive its tools. Unlike the MCP refresh
98
+ /** Re-read one peer's card (or every dialed peer) and re-derive its tools. Unlike the MCP refresh
96
99
  * this dials nothing new — every A2A call is a fresh request anyway — so a peer whose card or network
97
100
  * failed at prepare time can genuinely recover here. The DECLARATION is not re-read: a refresh works
98
101
  * from the copy this materialization took and judged — the members too (`headers`, `allowSkills`,
99
102
  * `toolAxes` are copied, not shared) — so a declaration refused then is refused again and a caller
100
- * rewriting its object afterwards, by replacing a member or by editing one in place, changes nothing. */
103
+ * rewriting its object afterwards, by replacing a member or by editing one in place, changes nothing.
104
+ * A peer the dial predicate kept from the dial is not contacted by a refresh: the all-peers form leaves it out, and naming it answers
105
+ * `failed` with the reason and sends nothing (this status vocabulary has no `not_connected`, the word the MCP refresh answers). */
101
106
  refresh: (peer?: string) => Promise<A2aRefreshResult[]>;
102
107
  /**
103
108
  * Task teardown. There is no socket to close (every call is its own request), so what this owns is the
@@ -125,5 +130,12 @@ revocations?: ProtocolRevocationLedger & {
125
130
  onProbeFailure?: (error: unknown) => void;
126
131
  }): Promise<MaterializedA2a>;
127
132
  /** The runner's materialization of one leg's peers (not index-exported): the seat as the runner received it, and the leg's ONE revocation
128
- * probe — the one its MCP materialization asks too (a broken ledger is told once per leg). */
129
- export declare function materializeLegA2aTools(revocations: RevocationProbe | undefined, specs: readonly A2aServerSpec[], principal: string | undefined, signal: AbortSignal | undefined, hostFloor: HostFloor | undefined, peerSeat: PeerSeat | undefined, onCredentialEchoed: ((peer: string, where: CredentialEchoSite) => void) | undefined): Promise<MaterializedA2a>;
133
+ * probe — the one its MCP materialization asks too (a broken ledger is told once per leg). `dialable` is an engine-internal parameter, NOT a
134
+ * host seat: today only the Runner passes it, with the leg's one server-level reading of the tool valve (`serverReached`, under the A2A
135
+ * prefix) — a pure predicate that answers a boolean and does not throw — asked of each declared peer before anything is sent to it. A peer
136
+ * it answers `false` for stays declared and is not contacted (no card request, no status row, no tool). Absent ⇒ every declared peer is
137
+ * dialed. It has no guard against a throwing or non-boolean answer (the MCP materialization's `dialable` is host-suppliable and has one);
138
+ * a form opened to a host needs that guard and a refusal code of its own. */
139
+ export declare function materializeLegA2aTools(revocations: RevocationProbe | undefined, specs: readonly A2aServerSpec[], principal: string | undefined, signal: AbortSignal | undefined, hostFloor: HostFloor | undefined, peerSeat: PeerSeat | undefined, onCredentialEchoed: ((peer: string, where: CredentialEchoSite) => void) | undefined, dialable?: (spec: {
140
+ readonly name: string;
141
+ }) => boolean): Promise<MaterializedA2a>;
package/dist/core/a2a.js CHANGED
@@ -759,7 +759,7 @@ function asPeerWarning(spec, err) {
759
759
  export async function materializeA2aTools(specs, principal, signal, hostFloor, given, onCredentialEchoed, revocations) {
760
760
  return materializeLegA2aTools(libraryRevocationProbe(revocations, "materializeA2aTools revocations"), specs, principal, signal, hostFloor, receivePeerSeat(given, "materializeA2aTools peerSeat"), onCredentialEchoed);
761
761
  }
762
- export async function materializeLegA2aTools(revocations, specs, principal, signal, hostFloor, peerSeat, onCredentialEchoed) {
762
+ export async function materializeLegA2aTools(revocations, specs, principal, signal, hostFloor, peerSeat, onCredentialEchoed, dialable) {
763
763
  const peers = specs.map((spec, index) => declaredPeerOf(spec, index));
764
764
  if (peers.length > 0) {
765
765
  const collision = findNamespacePrefixCollision(A2A_NAMESPACE, peers.map((p) => p.spec.name));
@@ -778,11 +778,15 @@ export async function materializeLegA2aTools(revocations, specs, principal, sign
778
778
  const warnings = [];
779
779
  const statuses = [];
780
780
  const announceEcho = echoAnnouncer(onCredentialEchoed);
781
- const settled = await Promise.allSettled(peers.map((peer) => materializePeer(peer, principal, lifecycle, signal, hostFloor, peerSeat, announceEcho, revocations)));
781
+ const dialed = peers.map((peer) => dialable === undefined || dialable(peer.spec));
782
+ const undialed = new Set(peers.filter((_, i) => !dialed[i]));
783
+ const settled = await Promise.allSettled(peers.map((peer, i) => (dialed[i] ? materializePeer(peer, principal, lifecycle, signal, hostFloor, peerSeat, announceEcho, revocations) : Promise.resolve(null))));
782
784
  for (let i = 0; i < peers.length; i++) {
783
785
  const spec = peers[i].spec;
784
786
  const outcome = settled[i];
785
787
  if (outcome.status === "fulfilled") {
788
+ if (outcome.value === null)
789
+ continue;
786
790
  tools.push(...outcome.value.tools);
787
791
  toolAxes.push(...outcome.value.axes);
788
792
  statuses.push(outcome.value.status);
@@ -800,7 +804,7 @@ export async function materializeLegA2aTools(revocations, specs, principal, sign
800
804
  statuses,
801
805
  refresh: async (peer) => {
802
806
  const prefixOf = (name) => mintNamespacePrefix(A2A_NAMESPACE, name);
803
- const targets = peer !== undefined ? peers.filter((p) => p.spec.name === peer) : peers;
807
+ const targets = peer !== undefined ? peers.filter((p) => p.spec.name === peer) : peers.filter((p) => !undialed.has(p));
804
808
  if (peer !== undefined && targets.length === 0) {
805
809
  return [{ peer, prefix: prefixOf(peer), status: "failed", toolCount: 0, added: [], removed: [], error: "no peer of that name is declared for this task" }];
806
810
  }
@@ -812,6 +816,10 @@ export async function materializeLegA2aTools(revocations, specs, principal, sign
812
816
  results.push({ peer: spec.name, prefix, status: "disposed", toolCount: 0, added: [], removed: [] });
813
817
  continue;
814
818
  }
819
+ if (undialed.has(target)) {
820
+ results.push({ peer: spec.name, prefix, status: "failed", toolCount: 0, added: [], removed: [], error: "this peer was not dialed for this task (the run's tool valve leaves nothing of it) — the refresh did not contact it" });
821
+ continue;
822
+ }
815
823
  const previous = statuses.find((s) => s.name === spec.name)?.toolNames ?? [];
816
824
  try {
817
825
  const fresh = await materializePeer(target, principal, lifecycle, signal, hostFloor, peerSeat, announceEcho, revocations);
@@ -3,7 +3,8 @@ import { type RuleToolNameVerdict } from "./tool-name-aliases.js";
3
3
  import type { ToolCallRequest, ToolIdentity } from "./tool-policy.js";
4
4
  import { type AllowRuleMember, type AllowRuleShadow } from "./allow-rule-shadow.js";
5
5
  import { type AdmissionPosture, type PathRuleBases, type PersistedRule } from "./permission-rule-model.js";
6
- import { type AskClass, type AssertAllKeysHandled, type PermissionMode, type PersistedRuleMandate } from "./ask-origin.js";
6
+ import { type AutoStripReason, type AutoStripRowReason } from "./auto-strip.js";
7
+ import { type AskClass, type AskOrigin, type AssertAllKeysHandled, type PermissionMode, type PersistedRuleMandate } from "./ask-origin.js";
7
8
  import { type ToolNameListReading } from "./tool-name-list.js";
8
9
  import { type EngineNotice } from "./engine-notice.js";
9
10
  /** Why an entry grants (or refuses) nothing — the closed set the start-of-run notice names, for every list. `tool_name`: the
@@ -127,25 +128,32 @@ export declare function compileAllowList(entries: readonly string[], behavior: "
127
128
  }>;
128
129
  inert: AllowEntryInert[];
129
130
  };
130
- /** The programs whose open allow rule the reference implementation drops in auto mode — its interpreter / launcher table
131
- * plus the shells and the run-anything builtins. A program that only reaches the network is not here. */
132
- export declare const AUTO_STRIPPED_PROGRAMS: readonly ["python", "python3", "python2", "node", "deno", "tsx", "ruby", "perl", "php", "lua", "npx", "bunx", "npm run", "yarn run", "pnpm run", "bun run", "bash", "sh", "ssh", "zsh", "fish", "eval", "exec", "env", "xargs", "sudo"];
133
131
  /**
134
- * Does auto mode strip this allow entry for this call (see the module doc)? Read for every rule-shaped member — a list
135
- * entry, and a person's stored row through {@link autoStrippedRule}; a hook's allow is not an entry and is never stripped.
136
- * A stripped entry takes no part in the match (the reference removes it before matching), so it neither clears nor is
137
- * disclosed. `allShell`: the leg declared `TaskSpec.classifyAllShell` — every shell command rule stands down, whatever it
138
- * names, and no entry of any kind clears a call that answers to the shell (the reference suspends every shell allow rule
139
- * under that setting without reading its content; a path rule a shell-face tool's declared target reaches is one here).
132
+ * Does auto mode strip this allow entry for this call, and why (the one judgment, `auto-strip.ts`)? Read for every rule-shaped
133
+ * member — a list entry, and a person's stored row through {@link autoStrippedRule}; a hook's allow is not an entry and is never
134
+ * stripped. A stripped entry takes no part in the match (the reference removes it before matching), so it neither clears nor is
135
+ * disclosed as a match. The call's one fact the judgment reads: does it answer to the shell under any of its names. `undefined` ⇒ kept.
140
136
  */
137
+ export declare function autoStripReasonOf(compiled: CompiledAllowEntry, call: ToolCallRequest | undefined, allShell: boolean): AutoStripReason | undefined;
138
+ /** Is the entry stripped for the call ({@link autoStripReasonOf} answers a reason)? */
141
139
  export declare function autoStripped(compiled: CompiledAllowEntry, call: ToolCallRequest | undefined, allShell: boolean): boolean;
142
140
  /** THE strip as every allow member reads it, per call: only in `auto`, and then {@link autoStripped} under the leg's
143
141
  * `classifyAllShell` declaration. The one place the mode is compared for the strip. */
144
142
  export declare function strippedInAuto(compiled: CompiledAllowEntry, call: ToolCallRequest | undefined, mode: PermissionMode | undefined, allShell: boolean): boolean;
145
- /** {@link strippedInAuto} over a person's stored ALLOW row, read as its list twin ({@link entryOfRow}): a row is stripped exactly when
146
- * the entry spelling the same rule is (a deny / ask row never is; a row no grammar reads has no twin and is not stripped here — the
147
- * lane reads no allow it cannot parse). */
143
+ /** {@link autoStripReasonOf} over a person's stored ALLOW row in `mode`, read as its list twin ({@link entryOfRow}): a row is stripped
144
+ * exactly when the entry spelling the same rule is (a deny / ask row never is; a row no grammar reads has no twin and is not stripped
145
+ * here — the lane reads no allow it cannot parse). `undefined` ⇒ kept. */
146
+ export declare function autoStripReasonOfRow(rule: PersistedRule, call: ToolCallRequest, mode: PermissionMode | undefined, allShell: boolean): AutoStripReason | undefined;
147
+ /** Is the stored row stripped for the call ({@link autoStripReasonOfRow} answers a reason)? */
148
148
  export declare function autoStrippedRule(rule: PersistedRule, call: ToolCallRequest, mode: PermissionMode | undefined, allShell: boolean): boolean;
149
+ /**
150
+ * The strip's reading of an allow-list entry judged WITHOUT a run — the reading a rule read face carries (`readFaceAutoStrip`): the
151
+ * entry read in the allow direction by the one reader ({@link readRuleEntry}; one that reads as nothing has no reading), no call (so
152
+ * a tool that answers to the shell under another name is not seen) and no leg declaration (so `classify_all_shell` is never the
153
+ * answer). `undefined` ⇒ auto mode uses the entry as written for a call of its own tool. A host marks a rule a person wrote (a
154
+ * settings `permissions.allow` entry) with it; a stored row carries the same reading as `EffectivePermissionRule.autoStrip`.
155
+ */
156
+ export declare function allowEntryAutoStrip(entry: string): AutoStripRowReason | undefined;
149
157
  /** Does the leg's spec declare that every shell entry is the classifier's in `auto` — the one reading of
150
158
  * `TaskSpec.classifyAllShell` (its value is screened at the door: present ⇒ a boolean). */
151
159
  export declare function classifiesAllShell(spec: {
@@ -170,6 +178,13 @@ export interface AllowEntryJudgeContext {
170
178
  readonly liveCwd: () => string | undefined;
171
179
  readonly anchors: PathRuleBases;
172
180
  readonly classifyAllShell?: boolean;
181
+ /** Hears each entry of the list the strip took from a call that entry speaks for ({@link allowingRows}): the entry as written,
182
+ * the reason, the skill whose list held it (a skill's lane), and the call. Absent ⇒ nobody is told. */
183
+ readonly onAutoStripped?: (stripped: {
184
+ readonly entry: string;
185
+ readonly reason: AutoStripReason;
186
+ readonly skill?: string;
187
+ }, call: ToolCallRequest) => void;
173
188
  }
174
189
  /** Which of the call's names a list's NAME rows (a whole tool, a covering spelling) read: every name it answers to — a person's,
175
190
  * a skill's or a session's list (the name written reaches the tool that answers to it, the reference's proxy expansion) — or the
@@ -201,8 +216,9 @@ export declare function wholeToolEntryOf<R extends AllowEntryRow>(rows: readonly
201
216
  * under the list's `names` ({@link ListNameReach}).
202
217
  */
203
218
  export declare function judgeAllowEntries<R extends AllowEntryRow>(rows: readonly R[], req: ToolCallRequest, behavior: "allow" | "deny", ctx: AllowEntryJudgeContext, posture?: AdmissionPosture, names?: ListNameReach): readonly R[] | undefined;
204
- /** The allow rows of a list, as the allow layer reads them in `mode`: the strip applied BEFORE the match (in `auto`). */
205
- export declare function allowingRows<R extends AllowEntryRow>(rows: readonly R[], req: ToolCallRequest, mode: PermissionMode | undefined, allShell: boolean): readonly R[];
219
+ /** The allow rows of a list, as the allow layer reads them in `mode`: the strip applied BEFORE the match (in `auto`). `told` hears
220
+ * each stripped row the call's judgment would have read (under the list's `names`), with its reason. */
221
+ export declare function allowingRows<R extends AllowEntryRow>(rows: readonly R[], req: ToolCallRequest, mode: PermissionMode | undefined, allShell: boolean, told?: (row: R, reason: AutoStripReason) => void, names?: ListNameReach): readonly R[];
206
222
  /** The two sources {@link AllowEntryTable} holds (a skill's list is the skill table's). */
207
223
  export type AllowEntrySource = "request" | "deployment";
208
224
  /**
@@ -382,6 +398,8 @@ export type ShadowReasonTableCoversEveryClass = AssertAllKeysHandled<Exclude<Ask
382
398
  */
383
399
  export declare function allowRuleShadowSentence(shadows: readonly AllowRuleShadow[], ask: {
384
400
  askClass?: AskClass;
401
+ origin?: AskOrigin;
402
+ ruleUnreadable?: unknown;
385
403
  mandate?: PersistedRuleMandate;
386
404
  authoredBy?: "deployment";
387
405
  probeReason?: string;
@@ -400,6 +418,8 @@ export declare function cardDisclosureOf(decision: {
400
418
  message?: string;
401
419
  allowRuleShadowed?: unknown;
402
420
  askClass?: AskClass;
421
+ origin?: AskOrigin;
422
+ ruleUnreadable?: unknown;
403
423
  mandate?: PersistedRuleMandate;
404
424
  authoredBy?: "deployment";
405
425
  probeReason?: string;