@sema-agent/core 7.48.0 → 7.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/CHANGELOG.md +418 -0
  2. package/README.md +2 -2
  3. package/dist/agents/cascade.d.ts +2 -5
  4. package/dist/agents/child-failure.d.ts +20 -0
  5. package/dist/agents/child-failure.js +28 -0
  6. package/dist/agents/cross-session-ref.d.ts +11 -3
  7. package/dist/agents/cross-session-ref.js +6 -0
  8. package/dist/agents/cumulative-stats.d.ts +12 -15
  9. package/dist/agents/cumulative-stats.js +1 -1
  10. package/dist/agents/extra-tool-names.js +1 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +17 -13
  12. package/dist/agents/inherited-tool-pool.js +4 -3
  13. package/dist/agents/peer-session-drain.d.ts +3 -2
  14. package/dist/agents/peer-session-drain.js +5 -4
  15. package/dist/agents/send-message-tool.js +2 -9
  16. package/dist/agents/subagent.d.ts +10 -29
  17. package/dist/agents/subagent.js +65 -53
  18. package/dist/agents/suspend-guard.d.ts +1 -1
  19. package/dist/agents/tool-filter.d.ts +76 -65
  20. package/dist/agents/tool-filter.js +122 -92
  21. package/dist/agents/verify.d.ts +4 -7
  22. package/dist/agents/verify.js +6 -7
  23. package/dist/bench/metrics.d.ts +1 -2
  24. package/dist/brain/anthropic.js +133 -79
  25. package/dist/brain/errors.d.ts +53 -6
  26. package/dist/brain/errors.js +22 -2
  27. package/dist/brain/input-too-long.d.ts +40 -19
  28. package/dist/brain/input-too-long.js +3 -16
  29. package/dist/brain/open-responses.js +19 -10
  30. package/dist/brain/openai.js +123 -32
  31. package/dist/brain/provider-dialect.d.ts +214 -0
  32. package/dist/brain/provider-dialect.js +186 -0
  33. package/dist/brain/request-params.d.ts +27 -8
  34. package/dist/brain/request-params.js +7 -12
  35. package/dist/brain/request-route.d.ts +84 -0
  36. package/dist/brain/request-route.js +41 -0
  37. package/dist/brain/retry.d.ts +8 -0
  38. package/dist/brain/retry.js +10 -4
  39. package/dist/brain/route-adjudicator.d.ts +7 -0
  40. package/dist/brain/route-adjudicator.js +5 -1
  41. package/dist/brain/status-sink.d.ts +20 -0
  42. package/dist/brain/status-sink.js +11 -0
  43. package/dist/brain/stream-engine.d.ts +52 -1
  44. package/dist/brain/stream-engine.js +81 -24
  45. package/dist/brain/stream-shared.d.ts +57 -11
  46. package/dist/brain/stream-shared.js +28 -2
  47. package/dist/core/a2a.d.ts +1 -0
  48. package/dist/core/agent-config-dir.js +3 -2
  49. package/dist/core/allow-entry.d.ts +21 -12
  50. package/dist/core/allow-entry.js +38 -31
  51. package/dist/core/arg-summary.d.ts +17 -24
  52. package/dist/core/arg-summary.js +169 -68
  53. package/dist/core/ask-origin.d.ts +42 -24
  54. package/dist/core/ask-origin.js +18 -13
  55. package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
  56. package/dist/core/auto-mode-prompt-assets.js +1 -1
  57. package/dist/core/auto-mode-prompt.d.ts +11 -1
  58. package/dist/core/auto-mode-prompt.js +13 -10
  59. package/dist/core/auto-mode-rebuild.d.ts +7 -0
  60. package/dist/core/auto-mode-rebuild.js +4 -1
  61. package/dist/core/canonical-json.d.ts +3 -0
  62. package/dist/core/canonical-json.js +2 -1
  63. package/dist/core/checkpoint-requirements.d.ts +892 -0
  64. package/dist/core/checkpoint-requirements.js +333 -0
  65. package/dist/core/checkpoint-store.d.ts +94 -65
  66. package/dist/core/checkpoint-store.js +14 -26
  67. package/dist/core/child-clamp-seats.d.ts +228 -69
  68. package/dist/core/child-clamp-seats.js +211 -17
  69. package/dist/core/classifier-unavailable-arm.d.ts +5 -1
  70. package/dist/core/classifier-unavailable-arm.js +3 -3
  71. package/dist/core/compliance.d.ts +3 -0
  72. package/dist/core/compliance.js +9 -4
  73. package/dist/core/credential-vocabulary.d.ts +140 -0
  74. package/dist/core/credential-vocabulary.js +131 -0
  75. package/dist/core/decision-receipt.js +1 -1
  76. package/dist/core/effective-path-target.d.ts +73 -16
  77. package/dist/core/effective-path-target.js +63 -33
  78. package/dist/core/engine-notice.d.ts +32 -7
  79. package/dist/core/file-history-store.js +2 -2
  80. package/dist/core/fs-write-gate-policy.d.ts +4 -0
  81. package/dist/core/fs-write-gate-policy.js +22 -5
  82. package/dist/core/gate-bounded-await.d.ts +28 -13
  83. package/dist/core/gate-bounded-await.js +41 -4
  84. package/dist/core/gate-fold.d.ts +1 -1
  85. package/dist/core/gate-fold.js +24 -25
  86. package/dist/core/gate-lanes.js +16 -15
  87. package/dist/core/gate-outcome.d.ts +20 -5
  88. package/dist/core/gate-outcome.js +5 -0
  89. package/dist/core/governance-codes.d.ts +11 -4
  90. package/dist/core/governance-codes.js +14 -3
  91. package/dist/core/hooks.d.ts +4 -0
  92. package/dist/core/locked-config.d.ts +8 -0
  93. package/dist/core/locked-config.js +14 -2
  94. package/dist/core/lsp.js +3 -5
  95. package/dist/core/mailbox-store.d.ts +3 -4
  96. package/dist/core/mcp-connection-pool.d.ts +75 -0
  97. package/dist/core/mcp-connection-pool.js +128 -0
  98. package/dist/core/mcp-failure.d.ts +2 -1
  99. package/dist/core/mcp-failure.js +13 -2
  100. package/dist/core/mcp.d.ts +4 -0
  101. package/dist/core/mcp.js +70 -43
  102. package/dist/core/memory-engine/content-origin.js +2 -14
  103. package/dist/core/memory-engine/engine.d.ts +32 -22
  104. package/dist/core/memory-engine/engine.js +103 -55
  105. package/dist/core/memory-engine/file-backend.d.ts +13 -30
  106. package/dist/core/memory-engine/file-backend.js +37 -252
  107. package/dist/core/memory-engine/index.d.ts +1 -1
  108. package/dist/core/memory-engine/index.js +1 -1
  109. package/dist/core/memory-engine/layout.d.ts +139 -9
  110. package/dist/core/memory-engine/layout.js +350 -7
  111. package/dist/core/memory-engine/scope-contract.d.ts +10 -0
  112. package/dist/core/memory-engine/scope-contract.js +8 -0
  113. package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
  114. package/dist/core/memory-engine/session-incarnation.js +5 -2
  115. package/dist/core/memory-engine/types.d.ts +10 -1
  116. package/dist/core/memory.js +5 -17
  117. package/dist/core/model-seat.d.ts +4 -4
  118. package/dist/core/model-seat.js +1 -1
  119. package/dist/core/mounted-mcp.d.ts +57 -0
  120. package/dist/core/mounted-mcp.js +19 -0
  121. package/dist/core/namespaced-rule-name.d.ts +29 -0
  122. package/dist/core/namespaced-rule-name.js +52 -0
  123. package/dist/core/park-selfcheck.d.ts +1 -1
  124. package/dist/core/park-selfcheck.js +16 -6
  125. package/dist/core/path-guard-rows.d.ts +99 -0
  126. package/dist/core/path-guard-rows.js +45 -0
  127. package/dist/core/path-identity.d.ts +22 -16
  128. package/dist/core/path-identity.js +10 -10
  129. package/dist/core/path-rule-binding.d.ts +2 -1
  130. package/dist/core/path-rule-binding.js +3 -1
  131. package/dist/core/pause-registry.d.ts +16 -2
  132. package/dist/core/pause-registry.js +6 -0
  133. package/dist/core/permission-rule-consent.js +0 -7
  134. package/dist/core/permission-rule-model.d.ts +68 -24
  135. package/dist/core/permission-rule-model.js +105 -24
  136. package/dist/core/permission-rule-store.js +2 -2
  137. package/dist/core/permission-rules.d.ts +3 -30
  138. package/dist/core/permission-rules.js +4 -54
  139. package/dist/core/read-root-candidate.d.ts +1 -3
  140. package/dist/core/read-root-candidate.js +4 -15
  141. package/dist/core/real-approval.d.ts +4 -3
  142. package/dist/core/retired-keys.d.ts +13 -0
  143. package/dist/core/retired-keys.js +14 -0
  144. package/dist/core/roles.d.ts +2 -3
  145. package/dist/core/roles.js +15 -6
  146. package/dist/core/runner/assemble-result.d.ts +0 -7
  147. package/dist/core/runner/assemble-result.js +19 -31
  148. package/dist/core/runner/caller-roster.d.ts +78 -0
  149. package/dist/core/runner/caller-roster.js +219 -0
  150. package/dist/core/runner/checkpoint-scope.d.ts +16 -16
  151. package/dist/core/runner/checkpoint-scope.js +2 -2
  152. package/dist/core/runner/child-tree.js +2 -2
  153. package/dist/core/runner/contracts.d.ts +68 -35
  154. package/dist/core/runner/decide-continuation.d.ts +51 -3
  155. package/dist/core/runner/decide-continuation.js +76 -21
  156. package/dist/core/runner/denial-limit-arms.d.ts +17 -5
  157. package/dist/core/runner/denial-limit-arms.js +11 -9
  158. package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
  159. package/dist/core/runner/extra-body-dropped-seat.js +22 -0
  160. package/dist/core/runner/finish-reason-seat.d.ts +9 -0
  161. package/dist/core/runner/finish-reason-seat.js +40 -0
  162. package/dist/core/runner/gate-exit.d.ts +44 -32
  163. package/dist/core/runner/gate-exit.js +112 -25
  164. package/dist/core/runner/inherited-ask-grants.js +6 -4
  165. package/dist/core/runner/mcp-redial.d.ts +3 -3
  166. package/dist/core/runner/mcp-redial.js +3 -4
  167. package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
  168. package/dist/core/runner/permission-rule-lanes.js +5 -4
  169. package/dist/core/runner/prepare-artifact.d.ts +4 -0
  170. package/dist/core/runner/prepare-artifact.js +2 -1
  171. package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
  172. package/dist/core/runner/prepare-ask-lane.js +12 -6
  173. package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
  174. package/dist/core/runner/prepare-boundary-parks.js +4 -7
  175. package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
  176. package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
  177. package/dist/core/runner/prepare-config-doors.d.ts +9 -9
  178. package/dist/core/runner/prepare-config-doors.js +10 -5
  179. package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
  180. package/dist/core/runner/prepare-defer-classify.js +5 -3
  181. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  182. package/dist/core/runner/prepare-delegation-surface.js +3 -3
  183. package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
  184. package/dist/core/runner/prepare-gate-stations.js +9 -7
  185. package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
  186. package/dist/core/runner/prepare-hands-readface.js +7 -7
  187. package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
  188. package/dist/core/runner/prepare-inherited-gate.js +14 -15
  189. package/dist/core/runner/prepare-listings.d.ts +7 -24
  190. package/dist/core/runner/prepare-listings.js +4 -5
  191. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
  192. package/dist/core/runner/prepare-memory-engine-session.js +4 -3
  193. package/dist/core/runner/prepare-memory.d.ts +6 -0
  194. package/dist/core/runner/prepare-memory.js +13 -13
  195. package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
  196. package/dist/core/runner/prepare-offload-wrappers.js +3 -3
  197. package/dist/core/runner/prepare-park-ask.d.ts +7 -8
  198. package/dist/core/runner/prepare-park-ask.js +17 -10
  199. package/dist/core/runner/prepare-policy-chain.js +24 -44
  200. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  201. package/dist/core/runner/prepare-project-context.js +3 -4
  202. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
  203. package/dist/core/runner/prepare-protocol-tools.js +3 -4
  204. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  205. package/dist/core/runner/prepare-run-refs.js +2 -1
  206. package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
  207. package/dist/core/runner/prepare-safety-scan.js +1 -2
  208. package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
  209. package/dist/core/runner/prepare-suspend-saga.js +28 -12
  210. package/dist/core/runner/prepare-task.d.ts +1 -1
  211. package/dist/core/runner/prepare-task.js +67 -56
  212. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
  213. package/dist/core/runner/prepare-wiring-manifest.js +5 -8
  214. package/dist/core/runner/resume-apply.js +7 -14
  215. package/dist/core/runner/resume-checkpoint-screen.js +11 -4
  216. package/dist/core/runner/resume-internals-and-config.js +2 -2
  217. package/dist/core/runner/resume-policy-outcome.js +5 -32
  218. package/dist/core/runner/resume-review-outcome.js +4 -1
  219. package/dist/core/runner/retired-runner-deps.d.ts +6 -0
  220. package/dist/core/runner/retired-runner-deps.js +10 -1
  221. package/dist/core/runner/run-brain-sinks.d.ts +4 -0
  222. package/dist/core/runner/run-brain-sinks.js +5 -2
  223. package/dist/core/runner/run-harness-handlers.js +27 -34
  224. package/dist/core/runner/run-leg.d.ts +0 -2
  225. package/dist/core/runner/run-leg.js +32 -33
  226. package/dist/core/runner/run-terminal-adoption.js +4 -3
  227. package/dist/core/runner/runtask.js +8 -8
  228. package/dist/core/runner/session-rule-policy.js +5 -5
  229. package/dist/core/runner/stream-settle-backstop.js +7 -4
  230. package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
  231. package/dist/core/runner/sub-agent-deny-lists.js +111 -80
  232. package/dist/core/runner/terminal-account.d.ts +48 -0
  233. package/dist/core/runner/terminal-account.js +186 -0
  234. package/dist/core/runner/tool-end-body.d.ts +54 -17
  235. package/dist/core/runner/tool-end-body.js +27 -2
  236. package/dist/core/runner/tool-face-overlay.d.ts +3 -1
  237. package/dist/core/runner/tool-face-overlay.js +6 -4
  238. package/dist/core/runner/tool-occurrence.d.ts +106 -0
  239. package/dist/core/runner/tool-occurrence.js +123 -0
  240. package/dist/core/runner/tool-progress-lane.d.ts +16 -8
  241. package/dist/core/runner/tool-progress-lane.js +25 -34
  242. package/dist/core/runner/turn-attachments.d.ts +1 -1
  243. package/dist/core/runner/write-protection-station.d.ts +21 -9
  244. package/dist/core/runner/write-protection-station.js +20 -17
  245. package/dist/core/runner-deps.d.ts +12 -22
  246. package/dist/core/secret-env.d.ts +16 -5
  247. package/dist/core/secret-env.js +23 -63
  248. package/dist/core/sensitive-path-policy.d.ts +19 -18
  249. package/dist/core/sensitive-path-policy.js +73 -49
  250. package/dist/core/session-reconcile.d.ts +3 -0
  251. package/dist/core/session-reconcile.js +5 -4
  252. package/dist/core/session-store.d.ts +5 -0
  253. package/dist/core/session-store.js +12 -0
  254. package/dist/core/session.d.ts +13 -0
  255. package/dist/core/shared-memory/normalize.d.ts +17 -4
  256. package/dist/core/shared-memory/normalize.js +7 -7
  257. package/dist/core/shell-lexer.js +5 -4
  258. package/dist/core/skill-grant.js +1 -1
  259. package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
  260. package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
  261. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
  262. package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
  263. package/dist/core/stub-env.d.ts +2 -0
  264. package/dist/core/stub-env.js +1 -0
  265. package/dist/core/synthetic-read-verdict.js +2 -2
  266. package/dist/core/task-event.d.ts +59 -5
  267. package/dist/core/task-result.d.ts +1 -1
  268. package/dist/core/task-spec.d.ts +42 -9
  269. package/dist/core/terminal-cause.d.ts +94 -11
  270. package/dist/core/tighten-task-spec.d.ts +5 -4
  271. package/dist/core/tighten-task-spec.js +20 -25
  272. package/dist/core/tool-catalog-entries.d.ts +5 -7
  273. package/dist/core/tool-catalog-entries.js +14 -15
  274. package/dist/core/tool-face.d.ts +47 -0
  275. package/dist/core/tool-face.js +5 -0
  276. package/dist/core/tool-model-gate.d.ts +5 -5
  277. package/dist/core/tool-name-aliases.d.ts +26 -2
  278. package/dist/core/tool-name-aliases.js +13 -0
  279. package/dist/core/tool-name-list.d.ts +30 -0
  280. package/dist/core/tool-name-list.js +55 -0
  281. package/dist/core/tool-name-readings.d.ts +1 -9
  282. package/dist/core/tool-name-readings.js +1 -3
  283. package/dist/core/tool-policy.d.ts +195 -85
  284. package/dist/core/tool-policy.js +165 -380
  285. package/dist/core/tool-registry.d.ts +44 -1
  286. package/dist/core/tool-registry.js +26 -0
  287. package/dist/core/tool-roster.d.ts +19 -1
  288. package/dist/core/tool-roster.js +21 -2
  289. package/dist/core/tool-spec-members.d.ts +45 -0
  290. package/dist/core/tool-spec-members.js +169 -0
  291. package/dist/core/tool-spec.d.ts +46 -8
  292. package/dist/core/tools.d.ts +6 -2
  293. package/dist/core/tools.js +8 -4
  294. package/dist/core/untrusted-egress.js +29 -26
  295. package/dist/core/untrusted-text.d.ts +13 -10
  296. package/dist/core/untrusted-text.js +6 -44
  297. package/dist/core/workflow-journal-store.d.ts +4 -1
  298. package/dist/core/write-protect.d.ts +65 -29
  299. package/dist/core/write-protect.js +235 -177
  300. package/dist/engine/compaction/compaction.d.ts +2 -2
  301. package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
  302. package/dist/engine/execution-env/node-execution-env.js +16 -38
  303. package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
  304. package/dist/engine/execution-env/symlink-chain.js +32 -0
  305. package/dist/engine/harness/types.d.ts +7 -0
  306. package/dist/engine/llm/tool-turns.d.ts +3 -0
  307. package/dist/engine/llm/tool-turns.js +1 -0
  308. package/dist/engine/llm/types.d.ts +59 -23
  309. package/dist/engine/loop/agent-loop.js +16 -2
  310. package/dist/engine/session/memory-repo.js +11 -3
  311. package/dist/engine/session/repo-utils.d.ts +8 -0
  312. package/dist/engine/session/repo-utils.js +13 -0
  313. package/dist/index.d.ts +20 -23
  314. package/dist/index.js +17 -20
  315. package/dist/internal/harness.d.ts +1 -1
  316. package/dist/internal/harness.js +1 -1
  317. package/dist/internal/llm.d.ts +2 -2
  318. package/dist/internal/llm.js +1 -1
  319. package/dist/orchestration/governance-baseline-validity.js +1 -1
  320. package/dist/orchestration/run-spec.js +3 -3
  321. package/dist/orchestration/run-workflow-tool.d.ts +16 -35
  322. package/dist/orchestration/run-workflow-tool.js +38 -78
  323. package/dist/orchestration/workflow-governance.d.ts +21 -25
  324. package/dist/orchestration/workflow-governance.js +38 -78
  325. package/dist/orchestration/workflow-primitives.d.ts +7 -22
  326. package/dist/orchestration/workflow-primitives.js +5 -12
  327. package/dist/orchestration/workflow-types.d.ts +1 -1
  328. package/dist/orchestration/workflow.d.ts +61 -11
  329. package/dist/orchestration/workflow.js +189 -117
  330. package/dist/scenarios/full-body.d.ts +1 -1
  331. package/dist/shell/lex.d.ts +0 -21
  332. package/dist/shell/lex.js +250 -68
  333. package/dist/shell/shell-words.d.ts +35 -0
  334. package/dist/shell/shell-words.js +65 -0
  335. package/dist/stores/file/checkpoint-store.d.ts +5 -5
  336. package/dist/stores/file/checkpoint-store.js +5 -2
  337. package/dist/stores/file/index.d.ts +0 -8
  338. package/dist/stores/file/index.js +0 -12
  339. package/dist/stores/file/session-store.d.ts +3 -0
  340. package/dist/stores/file/session-store.js +44 -19
  341. package/dist/tools/artifact/artifact-tool.js +2 -0
  342. package/dist/tools/fs/bash-program-position.d.ts +10 -3
  343. package/dist/tools/fs/bash-program-position.js +21 -9
  344. package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
  345. package/dist/tools/fs/bash-readonly-classifier.js +8 -7
  346. package/dist/tools/fs/containment-face.d.ts +4 -0
  347. package/dist/tools/fs/containment-face.js +3 -0
  348. package/dist/tools/fs/fs-shared.d.ts +10 -0
  349. package/dist/tools/fs/fs-shared.js +18 -0
  350. package/dist/tools/fs/fs-write.js +4 -2
  351. package/dist/tools/fs/index.d.ts +1 -1
  352. package/dist/tools/fs/program-read-model.d.ts +39 -18
  353. package/dist/tools/fs/program-read-model.js +29 -19
  354. package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
  355. package/dist/tools/fs/program-read-model.rows.js +5 -5
  356. package/dist/tools/fs/read-deny-home.d.ts +33 -47
  357. package/dist/tools/fs/read-deny-home.js +35 -49
  358. package/dist/tools/fs/read-deny.d.ts +23 -22
  359. package/dist/tools/fs/read-deny.js +114 -89
  360. package/dist/tools/fs/removal-targets.d.ts +56 -23
  361. package/dist/tools/fs/removal-targets.js +65 -87
  362. package/dist/tools/fs/safety.d.ts +29 -22
  363. package/dist/tools/fs/safety.js +17 -11
  364. package/dist/tools/fs/search.js +10 -8
  365. package/dist/tools/fs/shell-read-argv.js +1 -1
  366. package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
  367. package/dist/tools/fs/shell-read-bindings.js +324 -86
  368. package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
  369. package/dist/tools/fs/shell-read-builtins.js +43 -0
  370. package/dist/tools/fs/shell-read-check.d.ts +15 -1
  371. package/dist/tools/fs/shell-read-check.js +51 -42
  372. package/dist/tools/fs/shell-read-establish.js +6 -6
  373. package/dist/tools/fs/shell-read-functions.d.ts +22 -0
  374. package/dist/tools/fs/shell-read-functions.js +29 -0
  375. package/dist/tools/fs/shell-read-judge.d.ts +48 -18
  376. package/dist/tools/fs/shell-read-judge.js +33 -4
  377. package/dist/tools/fs/shell-read-plan.d.ts +12 -6
  378. package/dist/tools/fs/shell-read-plan.js +118 -113
  379. package/dist/tools/fs/shell-read-start.d.ts +29 -6
  380. package/dist/tools/fs/shell-read-start.js +16 -9
  381. package/dist/tools/fs/shell-read-word.js +4 -0
  382. package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
  383. package/dist/tools/fs/shell-read-workdir.js +281 -0
  384. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
  385. package/dist/tools/fs/shell-read-write-targets.js +14 -5
  386. package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
  387. package/dist/tools/fs/shell-reentry-text.js +3 -11
  388. package/dist/tools/task-list.d.ts +1 -2
  389. package/dist/tools/web.js +1 -1
  390. package/package.json +4 -1
  391. package/test/export-surface.snapshot.json +107 -143
  392. package/wire-changes/core@7.49.0.json +4765 -0
  393. package/dist/agents/teacher.d.ts +0 -159
  394. package/dist/agents/teacher.js +0 -577
  395. package/dist/agents/team.d.ts +0 -226
  396. package/dist/agents/team.js +0 -257
  397. package/dist/core/strategy-store.d.ts +0 -238
  398. package/dist/core/strategy-store.js +0 -253
  399. package/dist/orchestration/builtin-workflows.d.ts +0 -133
  400. package/dist/orchestration/builtin-workflows.js +0 -159
  401. package/dist/scenarios/env.d.ts +0 -40
  402. package/dist/scenarios/env.js +0 -39
  403. package/dist/scenarios/scenario-registry.d.ts +0 -110
  404. package/dist/scenarios/scenario-registry.js +0 -140
  405. package/dist/scenarios/teacher-quickstart.d.ts +0 -40
  406. package/dist/scenarios/teacher-quickstart.js +0 -12
  407. package/dist/stores/cc/lockfile.d.ts +0 -10
  408. package/dist/stores/cc/lockfile.js +0 -98
  409. package/dist/stores/cc/mailbox-store.d.ts +0 -20
  410. package/dist/stores/cc/mailbox-store.js +0 -255
  411. package/dist/stores/cc/roster-adapter.d.ts +0 -12
  412. package/dist/stores/cc/roster-adapter.js +0 -117
  413. package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
  414. package/dist/stores/cc/sidecar-transcript.js +0 -264
  415. package/dist/stores/cc/task-list-store.d.ts +0 -2
  416. package/dist/stores/cc/task-list-store.js +0 -125
  417. package/dist/stores/file/strategy-store.d.ts +0 -97
  418. package/dist/stores/file/strategy-store.js +0 -341
@@ -3,9 +3,10 @@ import { STREAM_TORN_WARNING } from "./stream-shared.js";
3
3
  import { FLOOR_OUTPUT_TOKENS, parseContextOverflow, planOutputCapAdjustment } from "./context-overflow.js";
4
4
  import { abortLikeName, BrainError, brainErrorCodeOf, classifyFetchThrow, classifyHttp, describeNetworkError, isProviderEchoShape, namesTheFailure, proxyTunnelRefusedSentence, readConnectFailure, readProviderErrorCode, readProviderRequestId, refusedTheRequest } from "./errors.js";
5
5
  import { stripUrlCredentials } from "./route-adjudicator.js";
6
- import { classifyInputTooLong } from "./input-too-long.js";
6
+ import { admittedRequestRoute } from "./request-route.js";
7
+ import { isTransientStatus, isProviderCondition, isProviderConditionSource, judgeHttpFailure, PROVIDER_CONDITION_TRAITS, resolveProviderDialect, } from "./provider-dialect.js";
7
8
  import { FAST_MAX_BACKOFF_MS, providerWaitHint, retryBackoffMs } from "./retry.js";
8
- import { bindBrainStatusEmitter, emitBrainStatus, emitBrainTelemetry } from "./status-sink.js";
9
+ import { bindBrainStatusEmitter, emitBrainStatus, emitBrainTelemetry, reportExtraBodyDropped } from "./status-sink.js";
9
10
  import { createAttemptController, firstByteWindow, refuseRetiredTimeoutKnobs, resolveFirstByteRetries, resolveWatchdogMs, STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS, STALL_IDLE_MS, } from "./timeout.js";
10
11
  import { readMember, thrownText } from "../core/thrown-value.js";
11
12
  import { redactSecrets } from "../core/untrusted-egress.js";
@@ -204,6 +205,10 @@ const EMPTY_USAGE = {
204
205
  totalTokens: 0,
205
206
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
206
207
  };
208
+ function reportRequestStrip(model, req) {
209
+ if (req.extraBodyDropped !== undefined && req.extraBodyDropped.length > 0)
210
+ reportExtraBodyDropped({ api: model.api, modelId: model.id, keys: req.extraBodyDropped });
211
+ }
207
212
  function emptyAssistant(model) {
208
213
  return {
209
214
  role: "assistant",
@@ -250,9 +255,20 @@ async function sleepAnnouncingRetry(totalMs, signal, frame) {
250
255
  return;
251
256
  }
252
257
  }
258
+ const RETRY_PHASE_OF_ERR_CLASS = {
259
+ connect_refused: "reconnecting",
260
+ transport: "reconnecting",
261
+ stall: "reconnecting",
262
+ rate_limit: "rate_limited",
263
+ server: "retrying",
264
+ http: "retrying",
265
+ output_cap: "retrying",
266
+ };
267
+ Object.freeze(RETRY_PHASE_OF_ERR_CLASS);
268
+ const TRANSPORT_RETRY_DETAIL = "connection lost, reconnecting";
253
269
  function retryAnnouncement(failure) {
254
270
  if (failure.kind !== "stalled")
255
- return { errClass: "transport", detail: "connection lost, reconnecting" };
271
+ return { errClass: "transport", detail: TRANSPORT_RETRY_DETAIL };
256
272
  const knob = failure.allowanceMs !== undefined && failure.allowanceMs > 0
257
273
  ? `${failure.knob} ${failure.timeoutMs - failure.allowanceMs} + ${failure.allowanceMs} upload allowance`
258
274
  : failure.knob;
@@ -276,6 +292,8 @@ export function runStreamingBrain(args) {
276
292
  let terminalRetryDetail = "recovered after retrying";
277
293
  let requestIdSeen;
278
294
  let attemptPartial;
295
+ let attemptOutput;
296
+ let routeSeen;
279
297
  void run()
280
298
  .catch((err) => {
281
299
  const aborted = signal?.aborted === true || isAbortError(err);
@@ -289,6 +307,11 @@ export function runStreamingBrain(args) {
289
307
  ? "cancelled while waiting for the first token"
290
308
  : "the first-token wait ended in failure";
291
309
  const errorMsg = emptyAssistant(model);
310
+ const kept = aborted ? undefined : attemptOutput;
311
+ if (kept !== undefined) {
312
+ errorMsg.content = kept.content;
313
+ errorMsg.usage = kept.usage;
314
+ }
292
315
  errorMsg.stopReason = aborted ? "aborted" : "error";
293
316
  errorMsg.errorMessage = thrownText(err);
294
317
  if (!aborted && brainErrorCodeOf(err) !== undefined) {
@@ -296,6 +319,8 @@ export function runStreamingBrain(args) {
296
319
  errorMsg.errorKind = "input_too_long";
297
320
  else if (readMember(err, "inputTooLongRuledOut") === true)
298
321
  errorMsg.inputTooLongRuledOut = true;
322
+ if (readMember(err, "errorBodyIncomplete") === true)
323
+ errorMsg.errorBodyIncomplete = true;
299
324
  if (readMember(err, "apiError") === true) {
300
325
  errorMsg.isApiErrorMessage = true;
301
326
  const status = readMember(err, "status");
@@ -304,12 +329,24 @@ export function runStreamingBrain(args) {
304
329
  errorMsg.apiErrorStatus = statusNum;
305
330
  if (requestIdSeen !== undefined)
306
331
  errorMsg.requestId = requestIdSeen;
332
+ if (routeSeen !== undefined)
333
+ errorMsg.apiErrorRoute = routeSeen;
307
334
  const providerCode = readMember(err, "providerCode");
308
- if (refusedTheRequest(statusNum) && typeof providerCode === "string" && isProviderEchoShape(providerCode))
335
+ if ((statusNum === undefined || refusedTheRequest(statusNum)) && typeof providerCode === "string" && isProviderEchoShape(providerCode))
309
336
  errorMsg.apiErrorCode = providerCode;
337
+ const condition = readMember(err, "providerCondition");
338
+ const source = readMember(err, "providerConditionSource");
339
+ if (isProviderCondition(condition) && isProviderConditionSource(source)) {
340
+ errorMsg.providerCondition = condition;
341
+ errorMsg.providerConditionSource = source;
342
+ const resetAtMs = readMember(err, "providerResetAtMs");
343
+ if (typeof resetAtMs === "number" && Number.isFinite(resetAtMs))
344
+ errorMsg.providerResetAtMs = resetAtMs;
345
+ }
310
346
  }
311
347
  }
312
- errorMsg.usageMissing = true;
348
+ if (kept === undefined || kept.usageMissing === true)
349
+ errorMsg.usageMissing = true;
313
350
  const seenResponseModel = attemptPartial?.responseModel;
314
351
  if (seenResponseModel !== undefined)
315
352
  errorMsg.responseModel = seenResponseModel;
@@ -328,7 +365,13 @@ export function runStreamingBrain(args) {
328
365
  return out;
329
366
  async function run() {
330
367
  let req = buildRequest();
331
- req.onCommitted?.();
368
+ const commit = (r) => {
369
+ r.onCommitted?.();
370
+ reportRequestStrip(model, r);
371
+ routeSeen = admittedRequestRoute(r.route);
372
+ };
373
+ commit(req);
374
+ const dialect = resolveProviderDialect(req.url, model.api);
332
375
  let maxOutputTokensOverride;
333
376
  const maxRetries = Math.min(resolveMaxRetries(config.maxRetries), callRetryCap);
334
377
  const baseDelay = config.retryDelayMs ?? 500;
@@ -399,6 +442,7 @@ export function runStreamingBrain(args) {
399
442
  let firstByteStall;
400
443
  requestIdSeen = undefined;
401
444
  attemptPartial = undefined;
445
+ attemptOutput = undefined;
402
446
  const stalledAtFirstByte = () => {
403
447
  firstByteWindowsWaited.push(window.windowMs);
404
448
  return {
@@ -462,7 +506,7 @@ export function runStreamingBrain(args) {
462
506
  cc.abort();
463
507
  cc.dispose();
464
508
  await sleepAnnouncingRetry(delayMs, signal, (remainingMs) => ({
465
- phase: "reconnecting",
509
+ phase: RETRY_PHASE_OF_ERR_CLASS[announcement.errClass],
466
510
  detail: announcement.detail,
467
511
  retryInSec: Math.ceil(remainingMs / 1000),
468
512
  retryInMs: remainingMs,
@@ -472,11 +516,11 @@ export function runStreamingBrain(args) {
472
516
  }));
473
517
  continue;
474
518
  }
475
- let overflowBody;
519
+ let errorBody;
476
520
  let overflowDeclineNote = "";
477
521
  if (r !== undefined && r.status === 400) {
478
522
  const read = await readErrorBody(r, signal);
479
- overflowBody = read.text;
523
+ errorBody = read;
480
524
  const report = read.endedNormally ? parseContextOverflow(r.status, read.text) : undefined;
481
525
  if (report !== undefined) {
482
526
  const plan = planOutputCapAdjustment(report, [maxOutputTokensOverride, req.outputCapTokens]);
@@ -499,11 +543,11 @@ export function runStreamingBrain(args) {
499
543
  const previousCap = plan.current;
500
544
  maxOutputTokensOverride = plan.maxOutputTokens;
501
545
  req = rebuilt;
502
- req.onCommitted?.();
546
+ commit(req);
503
547
  emitBrainTelemetry({ kind: "retry", attempt: attempt + 1, phase: "connect", errClass: "output_cap", nextDelayMs: 0 });
504
548
  announcedRetry = true;
505
549
  emitBrainStatus({
506
- phase: "retrying",
550
+ phase: RETRY_PHASE_OF_ERR_CLASS.output_cap,
507
551
  detail: `output limit lowered from ${previousCap} to ${plan.maxOutputTokens} tokens, retrying`,
508
552
  attempt: attempt + 1,
509
553
  maxRetries,
@@ -528,9 +572,12 @@ export function runStreamingBrain(args) {
528
572
  }
529
573
  }
530
574
  }
531
- const retryableByStatus = netErr !== undefined ||
532
- (r !== undefined && (r.status >= 500 || r.status === 429 || r.status === 408 || r.status === 409));
533
- const retryable = shouldRetryHeaderVerdict(r) ?? retryableByStatus;
575
+ if (r !== undefined && errorBody === undefined && namesTheFailure(r.status) && !isTransientStatus(r.status))
576
+ errorBody = await readErrorBody(r, signal);
577
+ const judge = () => r !== undefined && namesTheFailure(r.status) ? judgeHttpFailure({ dialect, status: r.status, headers: r.headers, body: errorBody }) : undefined;
578
+ const verdict = judge();
579
+ const retryableByCondition = netErr !== undefined || (verdict !== undefined && PROVIDER_CONDITION_TRAITS[verdict.condition].retryable);
580
+ const retryable = shouldRetryHeaderVerdict(r) ?? retryableByCondition;
534
581
  const connectReading = netErr !== undefined ? readConnectFailure(netErr) : undefined;
535
582
  const deterministicConnect = connectReading?.verdict === "deterministic";
536
583
  const fastLane = deterministicConnect && deterministicLaneActive;
@@ -552,20 +599,20 @@ export function runStreamingBrain(args) {
552
599
  const truncationNote = waitHint?.rawMs !== undefined
553
600
  ? ` (the requested wait was longer than the cap; honoring ${Math.ceil(waitHint.ms / 1000)}s instead of ${Math.ceil(waitHint.rawMs / 1000)}s)`
554
601
  : "";
555
- const statusPhase = r?.status === 429 ? "rate_limited" : netErr !== undefined ? "reconnecting" : "retrying";
556
602
  const refusedSubject = connectReading?.proxyRefusal !== undefined ? "proxy refused the tunnel" : "no endpoint answering";
557
- const reconnectDetail = errClass !== "connect_refused" ? "connection lost, reconnecting" : fastLane ? `${refusedSubject}, retrying briefly` : `${refusedSubject}, retrying`;
603
+ const reconnectDetail = errClass !== "connect_refused" ? TRANSPORT_RETRY_DETAIL : fastLane ? `${refusedSubject}, retrying briefly` : `${refusedSubject}, retrying`;
558
604
  emitBrainTelemetry({ kind: "retry", attempt: attempt + 1, phase: "connect", errClass, nextDelayMs: delayMs });
559
605
  announcedRetry = true;
560
606
  discardResponseBody(r);
561
607
  cc.abort();
562
608
  cc.dispose();
563
609
  const retryStatus = namesTheFailure(r?.status) ? r.status : undefined;
610
+ const phase = RETRY_PHASE_OF_ERR_CLASS[errClass];
564
611
  await sleepAnnouncingRetry(delayMs, signal, (remainingMs) => ({
565
- phase: statusPhase,
566
- detail: statusPhase === "rate_limited"
612
+ phase,
613
+ detail: phase === "rate_limited"
567
614
  ? `rate limited, backing off${truncationNote}`
568
- : statusPhase === "reconnecting"
615
+ : phase === "reconnecting"
569
616
  ? reconnectDetail
570
617
  : `transient error, retrying${truncationNote}`,
571
618
  retryInSec: Math.ceil(remainingMs / 1000),
@@ -574,6 +621,7 @@ export function runStreamingBrain(args) {
574
621
  maxRetries: laneMaxRetries,
575
622
  errClass,
576
623
  ...(retryStatus !== undefined ? { errorStatus: retryStatus } : {}),
624
+ ...(verdict !== undefined ? { providerCondition: verdict.condition, providerConditionSource: verdict.source } : {}),
577
625
  }));
578
626
  attempt++;
579
627
  continue;
@@ -583,14 +631,19 @@ export function runStreamingBrain(args) {
583
631
  const proxyRefusal = connectReading?.proxyRefusal;
584
632
  throw new BrainError("network", proxyRefusal === undefined ? chain : `${proxyTunnelRefusedSentence(proxyRefusal.status)} — ${chain}`, undefined, { apiError: true });
585
633
  }
586
- const detail = overflowBody ?? (r ? (await readErrorBody(r, signal)).text : "");
634
+ if (r !== undefined && errorBody === undefined)
635
+ errorBody = await readErrorBody(r, signal);
636
+ const terminalVerdict = judge();
637
+ const detail = errorBody?.text ?? "";
587
638
  const status = r?.status ?? 0;
588
- const itl = classifyInputTooLong(status, detail);
589
- const providerCode = refusedTheRequest(status) ? readProviderErrorCode(detail) : undefined;
639
+ const itl = terminalVerdict?.inputTooLong ?? "no";
640
+ const providerCode = refusedTheRequest(status) ? readProviderErrorCode(errorBody) : undefined;
590
641
  throw new BrainError(classifyHttp(status), `${httpLabel} HTTP ${status || "ERR"}: ${detail.slice(0, 500)}${overflowDeclineNote}`, status, {
591
642
  apiError: true,
592
643
  ...(itl === "yes" ? { inputTooLong: true } : itl === "no" ? { inputTooLongRuledOut: true } : {}),
593
644
  ...(providerCode !== undefined ? { providerCode } : {}),
645
+ ...(terminalVerdict !== undefined ? { verdict: { condition: terminalVerdict.condition, source: terminalVerdict.source, ...(terminalVerdict.resetAtMs !== undefined ? { resetAtMs: terminalVerdict.resetAtMs } : {}) } } : {}),
646
+ ...(errorBody !== undefined && !errorBody.endedNormally ? { errorBodyIncomplete: true } : {}),
594
647
  });
595
648
  }
596
649
  finally {
@@ -673,6 +726,10 @@ export function runStreamingBrain(args) {
673
726
  partial,
674
727
  sawContentToken,
675
728
  cancel: () => void reader.cancel().catch(() => undefined),
729
+ dialect,
730
+ keepOutput: (output) => {
731
+ attemptOutput = output;
732
+ },
676
733
  });
677
734
  const INBAND_OVERLOAD_WARNING = "API overloaded mid-response. The response above may be incomplete.";
678
735
  const onLineOverloadTierA = (line) => {
@@ -780,7 +837,7 @@ export function runStreamingBrain(args) {
780
837
  emitBrainTelemetry({ kind: "retry", attempt: thinkingRetries, phase: "midstream", errClass: announcement.errClass, nextDelayMs: delayMs });
781
838
  announcedRetry = true;
782
839
  await sleepAnnouncingRetry(delayMs, signal, (remainingMs) => ({
783
- phase: "reconnecting",
840
+ phase: RETRY_PHASE_OF_ERR_CLASS[announcement.errClass],
784
841
  detail: announcement.detail,
785
842
  retryInSec: Math.ceil(remainingMs / 1000),
786
843
  retryInMs: remainingMs,
@@ -797,7 +854,7 @@ export function runStreamingBrain(args) {
797
854
  emitBrainTelemetry({ kind: "retry", attempt, phase: "midstream", errClass: announcement.errClass, nextDelayMs: delayMs });
798
855
  announcedRetry = true;
799
856
  await sleepAnnouncingRetry(delayMs, signal, (remainingMs) => ({
800
- phase: "reconnecting",
857
+ phase: RETRY_PHASE_OF_ERR_CLASS[announcement.errClass],
801
858
  detail: announcement.detail,
802
859
  retryInSec: Math.ceil(remainingMs / 1000),
803
860
  retryInMs: remainingMs,
@@ -1,5 +1,5 @@
1
1
  import { type RepetitionEvent } from "./repetition.js";
2
- import { type AssistantMessage, type StreamDropCause } from "../internal/llm.js";
2
+ import { type AssistantMessage, type ModelOutputInvalid, type StreamDropCause } from "../internal/llm.js";
3
3
  /**
4
4
  * design/157 A10 — stream-parser pieces that the anthropic and openai SSE lanes carried BYTE-IDENTICALLY
5
5
  * (verified by diff at 1469481: a 16-line repetition-telemetry closure). Provider-agnostic policy, so it
@@ -14,21 +14,51 @@ import { type AssistantMessage, type StreamDropCause } from "../internal/llm.js"
14
14
  *
15
15
  * Internal module: not re-exported from `src/index.ts`.
16
16
  */
17
+ /** The CC-verbatim warning stamped beside `partialFinalized` when a stream ended before its close — by the
18
+ * mid-stream promotion (the body threw) and by the parsers' own finalize (content arrived, no finish frame). */
19
+ export declare const STREAM_TORN_WARNING = "Connection closed mid-response. The response above may be incomplete.";
20
+ /** A provider word as a stream-end seat carries it: the word in the provider echo shape, else `?` — the fact that a
21
+ * word arrived survives, bytes outside the shape do not (the echo discipline: dropped, never rewritten). */
22
+ export declare function echoFoldedWord(raw: string): string;
23
+ /**
24
+ * The record of what arrived after a stream's first terminal statement — the one ordering rule both wire parsers
25
+ * apply: the first ending (a finish / stop reason, a message stop, an in-band error) decides the turn; after it the
26
+ * turn is frozen, only the usage trailer is read, and every later ending or content frame is refused and counted
27
+ * here. Rides `AssistantMessage.streamEndIgnored` (the first refused frame's kind and word, how many came); the
28
+ * Runner announces it (`route.stream_end_ignored`).
29
+ */
30
+ export declare function createStreamEndLedger(): {
31
+ note(statement: StreamEndStatement, word: string): void;
32
+ readonly ignored: AssistantMessage["streamEndIgnored"];
33
+ };
34
+ type StreamEndStatement = NonNullable<AssistantMessage["streamEndIgnored"]>["statement"];
17
35
  /**
18
- * REF-B1 — turn a streamed tool call's accumulated argument bytes into its arguments object, FAIL-CLOSED.
36
+ * REF-B1 — turn a streamed tool call's accumulated argument bytes into its arguments object, FAIL-CLOSED. The ONE
37
+ * judge of a streamed call's arguments: a call runs only with arguments that are a complete JSON object.
19
38
  *
20
- * - no bytes (`""`) → `{}`: genuinely a no-argument call (the provider's frame carried no arguments);
21
- * - valid JSON **object** → that object;
39
+ * - valid JSON **object** → that object (a complete `{}` included);
40
+ * - no bytes (`""`) → `{}` when the wire closed the call — the provider's frame carried no arguments, a no-argument
41
+ * call; `undefined` when it did not — the stream stopped before the call's first argument byte arrived, and nothing
42
+ * says it was a no-argument call rather than a cut one;
22
43
  * - anything else (truncated/invalid JSON, or a top-level string/array/number/null) → `undefined`.
23
44
  *
45
+ * `closed` is the lane's evidence that the wire ended THIS call, with no default (a lane that does not state it does
46
+ * not compile): the call's own close frame, or a stream end that says the model finished its turn (not the output-cap
47
+ * stop, not no stop at all). Another call opening is no evidence — a gateway may open several calls before any
48
+ * argument byte arrives. One reading in the three lanes; each lane states which of these it has.
49
+ *
24
50
  * bug-hunt #6 (kept from finalize): a non-object must never reach `tool.execute` / the MCP wire. `undefined`
25
51
  * means "do not emit a `toolcall_end` for this call"; callers must NOT cache that outcome — finalize retries
26
52
  * the parse against the complete accumulation.
27
53
  */
28
- /** The CC-verbatim warning stamped beside `partialFinalized` when a stream ended before its close — by the
29
- * mid-stream promotion (the body threw) and by the parsers' own finalize (content arrived, no finish frame). */
30
- export declare const STREAM_TORN_WARNING = "Connection closed mid-response. The response above may be incomplete.";
31
- export declare function parseStreamedToolArgs(json: string): Record<string, unknown> | undefined;
54
+ export declare function parseStreamedToolArgs(json: string, closed: boolean): Record<string, unknown> | undefined;
55
+ /**
56
+ * The cause of a call slot that never received its NAME — the other component of a call, judged by the same evidence as
57
+ * its arguments ({@link parseStreamedToolArgs}'s `closed`): a slot the wire closed has no name because none was sent
58
+ * (`unnamed`); a slot nothing closed was cut before its name arrived (`truncated`). A call is whole only with both parts;
59
+ * a missing part on an unclosed call is a cut call, whichever part is missing.
60
+ */
61
+ export declare function nameMissingCause(closed: boolean): "unnamed" | "truncated";
32
62
  /** One drop note of a turn: what was dropped, how many, and the sentence the model reads. */
33
63
  export interface TurnNote {
34
64
  readonly cause: StreamDropCause;
@@ -51,12 +81,27 @@ export declare function placeTurnNotes(message: Pick<AssistantMessage, "diagnost
51
81
  * without its stop frame names the transport instead; any other stop adds nothing (naming the cap there sent a reader
52
82
  * after a budget that was never reached). One rule for the lanes that carry the clause.
53
83
  */
54
- export declare function truncationCauseClause(facts: {
84
+ export declare function truncationCauseClause(facts: TurnCapFacts & {
85
+ terminalFrameSeen: boolean;
86
+ }): string;
87
+ /** One turn's output-cap facts as the lane holds them — the record {@link truncationCauseClause} words and
88
+ * {@link modelOutputInvalidOf} carries: the lane's cap stop, the provider's output count (as reported), the cap the
89
+ * committed request carried. */
90
+ export interface TurnCapFacts {
55
91
  capStop: boolean;
56
92
  outputTokens: number | undefined;
57
93
  capTokens: number | undefined;
58
- terminalFrameSeen: boolean;
59
- }): string;
94
+ }
95
+ /**
96
+ * The structured account of a turn that FAILED for its dropped tool calls (`AssistantMessage.modelOutputInvalid`) —
97
+ * the lane calls it on the arm whose message is the dropped-calls sentence. `cause` is `truncated` when any call's
98
+ * arguments were cut (the sentence's first part), else `unnamed`; `outputLimit` rides with `truncated`, read off the
99
+ * same {@link TurnCapFacts} the sentence's cap clause reads. One rule for the three lanes.
100
+ */
101
+ export declare function modelOutputInvalidOf(drops: {
102
+ truncated: number;
103
+ unnamed: number;
104
+ }, cap: TurnCapFacts): ModelOutputInvalid | undefined;
60
105
  /** Repetition telemetry for ONE stream — the cut event plus the allowance-spared hits. */
61
106
  export interface RepetitionPoll {
62
107
  /** Inspect the accumulated text; returns whether it is degenerate (the caller trips its own cut). */
@@ -82,3 +127,4 @@ export declare function createRepetitionPoll(): RepetitionPoll;
82
127
  export declare function noteResponseModel(partial: {
83
128
  responseModel?: string;
84
129
  }, reported: unknown, requestedId: string): void;
130
+ export {};
@@ -3,9 +3,23 @@ import { inspectDegenerate } from "./repetition.js";
3
3
  import { emitBrainTelemetry } from "./status-sink.js";
4
4
  import { stampStreamDrops } from "../internal/llm.js";
5
5
  export const STREAM_TORN_WARNING = "Connection closed mid-response. The response above may be incomplete.";
6
- export function parseStreamedToolArgs(json) {
6
+ export function echoFoldedWord(raw) {
7
+ return isProviderEchoShape(raw) ? raw : "?";
8
+ }
9
+ export function createStreamEndLedger() {
10
+ let ignored;
11
+ return {
12
+ note(statement, word) {
13
+ ignored = ignored === undefined ? { statement, word: echoFoldedWord(word), frames: 1 } : { ...ignored, frames: ignored.frames + 1 };
14
+ },
15
+ get ignored() {
16
+ return ignored;
17
+ },
18
+ };
19
+ }
20
+ export function parseStreamedToolArgs(json, closed) {
7
21
  if (!json)
8
- return {};
22
+ return closed ? {} : undefined;
9
23
  let parsed;
10
24
  try {
11
25
  parsed = JSON.parse(json);
@@ -17,6 +31,9 @@ export function parseStreamedToolArgs(json) {
17
31
  return undefined;
18
32
  return parsed;
19
33
  }
34
+ export function nameMissingCause(closed) {
35
+ return closed ? "unnamed" : "truncated";
36
+ }
20
37
  export function placeTurnNotes(message, content, notes) {
21
38
  if (notes.length === 0)
22
39
  return;
@@ -31,6 +48,15 @@ export function truncationCauseClause(facts) {
31
48
  }
32
49
  return terminalFrameSeen ? "" : "; the stream ended before its stop frame — the connection closed mid-response";
33
50
  }
51
+ const countOf = (v) => (typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : undefined);
52
+ export function modelOutputInvalidOf(drops, cap) {
53
+ if (drops.truncated > 0) {
54
+ const outputTokens = countOf(cap.outputTokens);
55
+ const capTokens = countOf(cap.capTokens);
56
+ return { cause: "truncated", outputLimit: { capStop: cap.capStop, ...(outputTokens !== undefined ? { outputTokens } : {}), ...(capTokens !== undefined ? { capTokens } : {}) } };
57
+ }
58
+ return drops.unnamed > 0 ? { cause: "unnamed" } : undefined;
59
+ }
34
60
  export function createRepetitionPoll() {
35
61
  let repCut;
36
62
  const repSpared = new Map();
@@ -66,6 +66,7 @@ export interface MaterializedA2a {
66
66
  /** One entry per peer that could not be materialized and was SKIPPED (fail-open, design/29): the task
67
67
  * runs with the healthy peers' tools. The Runner forwards these to `onError(phase:"a2a")`. */
68
68
  warnings: Error[];
69
+ /** One entry per DECLARED peer, in declaration order, ready or failed — the declaration as this materialization read it once. */
69
70
  statuses: A2aPeerStatus[];
70
71
  /** Re-read one peer's card (or every declared peer) and re-derive its tools. Unlike the MCP refresh
71
72
  * this dials nothing new — every A2A call is a fresh request anyway — so a peer that failed at
@@ -1,5 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
- import { isAbsolutePathForm, normalizeAbsPathLexically } from "../tools/fs/safety.js";
2
+ import { normalizeAbsPathLexically } from "../tools/fs/safety.js";
3
+ import { validatePath } from "./effective-path-target.js";
3
4
  export const AGENT_CONFIG_DIR_SEGMENT = ".sema";
4
5
  export const AGENT_CONFIG_DIR_INVALID_CODE = "config.agent_config_dir_invalid";
5
6
  export function agentConfigDirTail(run, caseSensitive = false) {
@@ -33,7 +34,7 @@ export function checkedAgentConfigDir(value, seat) {
33
34
  throw invalidAgentConfigDir(seat, value, `is a ${value === null ? "null" : typeof value}, not a string`);
34
35
  if (value.length === 0)
35
36
  throw invalidAgentConfigDir(seat, value, "is an empty string");
36
- if (!isAbsolutePathForm(value))
37
+ if (validatePath(value, { intent: "validate-coordinate" }) === undefined)
37
38
  throw invalidAgentConfigDir(seat, value, "is not an absolute path");
38
39
  let isDirectory;
39
40
  try {
@@ -3,12 +3,12 @@ import type { ToolCallRequest } from "./tool-policy.js";
3
3
  import { type AllowRuleMember, type AllowRuleShadow } from "./allow-rule-shadow.js";
4
4
  import { type PathRuleBases, type PersistedRule } from "./permission-rule-model.js";
5
5
  import { type AskClass, type AssertAllKeysHandled, type PermissionMode, type PersistedRuleMandate } from "./ask-origin.js";
6
- import { type ToolNameListReading } from "../agents/tool-filter.js";
6
+ import { type ToolNameListReading } from "./tool-name-list.js";
7
7
  import { type EngineNotice } from "./engine-notice.js";
8
8
  /** Why an entry grants (or refuses) nothing — the closed set the start-of-run notice names, for every list. `tool_name`: the
9
9
  * entry's tool name is one the name judgment reads as stale against the run's roster (`verdict` says which); `near_miss`: the
10
10
  * run mounts no tool of that exact name but mounts one that differs only by case (`currentName` is its spelling). */
11
- export declare const ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "path_pattern", "domain", "content_unsupported", "grammar", "tool_name", "near_miss"];
11
+ export declare const ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "content_unsupported", "grammar", "tool_name", "near_miss"];
12
12
  export type AllowEntryInertReason = (typeof ALLOW_ENTRY_INERT_REASONS)[number];
13
13
  /** The facts beside a reason: for `tool_name` / `near_miss` the judgment's word and the spelling to write instead when there is
14
14
  * one; for a list member that is not a string (`grammar`) the TYPE of the value (`a number`, `null`, `an object`…) — `entry` then
@@ -35,8 +35,9 @@ export type AllowEntryInert = {
35
35
  readonly entry: string;
36
36
  readonly reason: AllowEntryInertReason;
37
37
  } & AllowEntryInertDetail;
38
- /** One entry the grammar reads (kind closed): a whole non-shell tool; a protocol namespace; the whole shell tool; a shell
39
- * command rule; the Read directory form; a deny-side path pattern (a skill's `disallowed-tools`). */
38
+ /** One entry the grammar reads (kind closed): a whole non-shell tool; a protocol namespace; the whole shell tool; and one
39
+ * kind per rule grammar (`ruleToolGrammarOf`) — a shell command rule, a path rule, a name rule, a host rule — each the row
40
+ * the persisted grammar parses, its `behavior` the list's direction. */
40
41
  export type CompiledAllowEntry = {
41
42
  readonly kind: "tool";
42
43
  readonly name: string;
@@ -50,10 +51,13 @@ export type CompiledAllowEntry = {
50
51
  readonly kind: "command";
51
52
  readonly rule: PersistedRule;
52
53
  } | {
53
- readonly kind: "read_dir";
54
+ readonly kind: "path";
54
55
  readonly rule: PersistedRule;
55
56
  } | {
56
- readonly kind: "path";
57
+ readonly kind: "name";
58
+ readonly rule: PersistedRule;
59
+ } | {
60
+ readonly kind: "domain";
57
61
  readonly rule: PersistedRule;
58
62
  };
59
63
  /**
@@ -104,11 +108,13 @@ export interface AllowEntryJudgeContext {
104
108
  readonly anchors: PathRuleBases;
105
109
  }
106
110
  /**
107
- * The ONE list matcher, both directions — the rows that speak for the call, or undefined. ALLOW: the first name row that
108
- * reaches the call, else the command rows' coverage (the persisted allow matcher — the whole command, or each segment
109
- * covered by a row or read-only by itself), else the Read directory rows. DENY: a name row, a command row whose program run
110
- * the call performs (the wide tightening reading; a call that cannot be read against the row is refused too), or a path row
111
- * the call's target reaches.
111
+ * The ONE list matcher, both directions — the rows that speak for the call, or undefined. A tool-name row first (the first
112
+ * that reaches the call); then the content rows, each family by the predicate the stored rows of that grammar meet:
113
+ * COMMAND — allow: the persisted allow matcher's coverage (the whole command, or each segment covered by a row or read-only
114
+ * by itself); deny: a row whose program run the call performs (the wide tightening reading; a call that cannot be read
115
+ * against the row is refused too). PATH — the persisted path adjudication (allow: the narrow reading, every view of the
116
+ * target inside what the row names; deny: any view reaching it). NAME / DOMAIN — the one predicate of each (the name the
117
+ * call names, the host it fetches).
112
118
  */
113
119
  export declare function judgeAllowEntries<R extends AllowEntryRow>(rows: readonly R[], req: ToolCallRequest, behavior: "allow" | "deny", ctx: AllowEntryJudgeContext): readonly R[] | undefined;
114
120
  /** The allow rows of a list, as the allow layer reads them in `mode`: the strip applied BEFORE the match (in `auto`). */
@@ -157,6 +163,8 @@ export declare class AllowEntryTable {
157
163
  seed(entries: readonly string[], roster?: ReadonlySet<string>): readonly AllowEntryInert[];
158
164
  /** The entries held, as written (a copy) — what a delegated child is handed. */
159
165
  entries(): readonly string[];
166
+ /** Does the table hold a path row — must the leg read each call's target views for it? */
167
+ holdsPathRows(): boolean;
160
168
  /** The lane over this table, bound to the leg's call facts. */
161
169
  lane(ctx: AllowEntryJudgeContext): AllowEntryLane;
162
170
  }
@@ -209,6 +217,7 @@ declare const SHADOW_REASON: {
209
217
  readonly ancestor: "the task that delegated this one owns this question";
210
218
  readonly dangerous_delete: "this removal targets a protected location (the filesystem root, a top-level directory, a home directory, or a workspace directory or one of its ancestors) — it is cleared by confirming this call, never by an allow rule";
211
219
  readonly unverifiable_delete: "this removal could not be verified safe — it is cleared by confirming this call, never by an allow rule";
220
+ readonly unverifiable_shell_text: "the text this shell will run cannot be read by the engine — it is cleared by confirming this call, never by an allow rule";
212
221
  readonly transcript_write: "this write targets the session transcript — it is cleared by confirming this call, never by an allow rule";
213
222
  readonly org_rule: "an organization policy rule requires approval for this call";
214
223
  readonly governance_unavailable: "this deployment is org-governed and cannot currently read its organization policy";
@@ -219,7 +228,7 @@ declare const SHADOW_REASON: {
219
228
  readonly requires_user_interaction: "this tool's server declares that a call must be put to a person";
220
229
  readonly operator_forced: "this call arrived already marked as requiring confirmation (an earlier layer of this run, or the task that delegated it, judged it so) — it is cleared by confirming this call, never by a standing allow rule";
221
230
  readonly shell_floor: string;
222
- readonly write_protection_unresolved: string;
231
+ readonly target_unresolved: string;
223
232
  readonly probe: string;
224
233
  readonly write_protection: string;
225
234
  readonly tool_marks_mcp: string;