@sema-agent/core 7.67.3 → 7.68.1

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 (501) hide show
  1. package/CHANGELOG.md +1537 -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/open-responses.js +3 -1
  30. package/dist/brain/openai.js +3 -1
  31. package/dist/brain/reasoning-request.d.ts +73 -19
  32. package/dist/brain/reasoning-request.js +164 -72
  33. package/dist/brain/reasoning-stamp.d.ts +26 -0
  34. package/dist/brain/reasoning-stamp.js +10 -0
  35. package/dist/brain/reasoning.d.ts +95 -162
  36. package/dist/brain/reasoning.js +31 -86
  37. package/dist/brain/route-adjudicator.d.ts +9 -7
  38. package/dist/brain/route-adjudicator.js +12 -10
  39. package/dist/brain/status-sink.d.ts +19 -64
  40. package/dist/brain/status-sink.js +5 -21
  41. package/dist/brain/stream-engine.d.ts +11 -2
  42. package/dist/brain/stream-engine.js +10 -0
  43. package/dist/core/a2a.d.ts +17 -5
  44. package/dist/core/a2a.js +11 -3
  45. package/dist/core/allow-entry.d.ts +35 -15
  46. package/dist/core/allow-entry.js +47 -60
  47. package/dist/core/ask-headline.d.ts +68 -0
  48. package/dist/core/ask-headline.js +23 -0
  49. package/dist/core/ask-origin.d.ts +36 -8
  50. package/dist/core/ask-origin.js +17 -10
  51. package/dist/core/ask-question.d.ts +34 -7
  52. package/dist/core/ask-question.js +10 -1
  53. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  54. package/dist/core/ask-unresolvable-notice.js +9 -3
  55. package/dist/core/auto-strip.d.ts +53 -0
  56. package/dist/core/auto-strip.js +76 -0
  57. package/dist/core/background-agent-store.d.ts +45 -5
  58. package/dist/core/background-agent-store.js +69 -15
  59. package/dist/core/background-shell.d.ts +2 -2
  60. package/dist/core/caller-text.js +2 -2
  61. package/dist/core/canonical-json.d.ts +13 -0
  62. package/dist/core/canonical-json.js +7 -0
  63. package/dist/core/checkpoint-features.d.ts +66 -20
  64. package/dist/core/checkpoint-features.js +12 -1
  65. package/dist/core/checkpoint-generation.d.ts +1 -1
  66. package/dist/core/checkpoint-queries.d.ts +1 -1
  67. package/dist/core/checkpoint-queries.js +4 -1
  68. package/dist/core/checkpoint-requirements.d.ts +45 -2
  69. package/dist/core/checkpoint-requirements.js +16 -6
  70. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  71. package/dist/core/checkpoint-row-verdict.js +4 -0
  72. package/dist/core/checkpoint-store.d.ts +66 -38
  73. package/dist/core/checkpoint-store.js +15 -6
  74. package/dist/core/child-clamp-seats.d.ts +6 -0
  75. package/dist/core/child-clamp-seats.js +1 -0
  76. package/dist/core/config-refusal-codes.d.ts +1 -1
  77. package/dist/core/config-refusal-codes.js +1 -0
  78. package/dist/core/delegation-frames.d.ts +9 -12
  79. package/dist/core/delegation-frames.js +9 -8
  80. package/dist/core/engine-capabilities.d.ts +21 -8
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +147 -34
  83. package/dist/core/engine-notice.js +27 -16
  84. package/dist/core/engine-storage-backend.d.ts +2 -1
  85. package/dist/core/env-budget.js +3 -3
  86. package/dist/core/env-knob-announce.d.ts +10 -10
  87. package/dist/core/env-knob-announce.js +3 -6
  88. package/dist/core/file-history-store.d.ts +29 -4
  89. package/dist/core/file-history-store.js +13 -0
  90. package/dist/core/frame-settlement.d.ts +2 -1
  91. package/dist/core/gate-fold.js +1 -1
  92. package/dist/core/gate-lanes.js +56 -49
  93. package/dist/core/governance-codes.d.ts +39 -3
  94. package/dist/core/governance-codes.js +61 -3
  95. package/dist/core/hooks.d.ts +29 -11
  96. package/dist/core/hooks.js +5 -2
  97. package/dist/core/human-input-projection.js +3 -3
  98. package/dist/core/input-author.d.ts +17 -3
  99. package/dist/core/input-author.js +15 -3
  100. package/dist/core/leg-identity.d.ts +10 -28
  101. package/dist/core/leg-identity.js +1 -21
  102. package/dist/core/lsp.d.ts +18 -13
  103. package/dist/core/lsp.js +30 -22
  104. package/dist/core/mailbox-store.d.ts +1 -1
  105. package/dist/core/mailbox-store.js +4 -4
  106. package/dist/core/mcp-connection-pool.d.ts +93 -4
  107. package/dist/core/mcp-connection-pool.js +104 -1
  108. package/dist/core/mcp-failure.d.ts +38 -12
  109. package/dist/core/mcp-failure.js +9 -13
  110. package/dist/core/mcp-probe.d.ts +4 -3
  111. package/dist/core/mcp-server-link.d.ts +4 -2
  112. package/dist/core/mcp-server-link.js +4 -5
  113. package/dist/core/mcp-server-spec.d.ts +3 -3
  114. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  115. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  116. package/dist/core/mcp.d.ts +40 -6
  117. package/dist/core/mcp.js +39 -13
  118. package/dist/core/memory-engine/content-origin.js +2 -2
  119. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  120. package/dist/core/memory-engine/control-objects.js +2 -10
  121. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  122. package/dist/core/memory-engine/dual-root.js +3 -0
  123. package/dist/core/memory-engine/engine.d.ts +6 -4
  124. package/dist/core/memory-engine/engine.js +32 -29
  125. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  126. package/dist/core/memory-engine/file-backend.js +21 -31
  127. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  128. package/dist/core/memory-engine/frontmatter.js +4 -0
  129. package/dist/core/memory-engine/layout.d.ts +114 -20
  130. package/dist/core/memory-engine/layout.js +340 -22
  131. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  132. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  133. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  134. package/dist/core/memory-engine/sync-client.js +4 -5
  135. package/dist/core/model-fallbacks.d.ts +5 -1
  136. package/dist/core/model-fallbacks.js +3 -3
  137. package/dist/core/model-receipt.d.ts +2 -1
  138. package/dist/core/model-receipt.js +12 -1
  139. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  140. package/dist/core/mods/kernel/dispatch.js +14 -6
  141. package/dist/core/mods/kernel/events.d.ts +8 -5
  142. package/dist/core/mods/kernel/events.js +2 -2
  143. package/dist/core/mods/kernel/index.d.ts +1 -1
  144. package/dist/core/mods/kernel/registration.d.ts +9 -0
  145. package/dist/core/mods/package.js +1 -1
  146. package/dist/core/mods/session-append.d.ts +4 -2
  147. package/dist/core/mods/session-append.js +3 -0
  148. package/dist/core/mods/stations.d.ts +7 -11
  149. package/dist/core/mods/stations.js +4 -7
  150. package/dist/core/mods/tool-call.d.ts +10 -8
  151. package/dist/core/mods/tool-call.js +15 -18
  152. package/dist/core/mounted-mcp.d.ts +0 -4
  153. package/dist/core/mounted-mcp.js +1 -1
  154. package/dist/core/park-noun.d.ts +24 -0
  155. package/dist/core/park-noun.js +21 -0
  156. package/dist/core/park-resumability.d.ts +60 -0
  157. package/dist/core/park-resumability.js +30 -0
  158. package/dist/core/permission-rule-provider.d.ts +24 -2
  159. package/dist/core/permission-rule-provider.js +11 -8
  160. package/dist/core/permission-rule-store.d.ts +8 -1
  161. package/dist/core/permission-rule-store.js +2 -3
  162. package/dist/core/permission-rules.d.ts +2 -1
  163. package/dist/core/permission-rules.js +8 -4
  164. package/dist/core/persisted-rule-arms.d.ts +3 -0
  165. package/dist/core/persisted-rule-arms.js +2 -1
  166. package/dist/core/present-plan-tool.d.ts +47 -3
  167. package/dist/core/present-plan-tool.js +62 -4
  168. package/dist/core/principal-name.d.ts +1 -1
  169. package/dist/core/principal-name.js +5 -5
  170. package/dist/core/process-identity.js +10 -5
  171. package/dist/core/protocol-http-auth.d.ts +20 -14
  172. package/dist/core/protocol-http-auth.js +70 -50
  173. package/dist/core/read-only-shell.js +9 -5
  174. package/dist/core/redaction-marks.d.ts +4 -26
  175. package/dist/core/redaction-marks.js +9 -21
  176. package/dist/core/remote-env.d.ts +43 -16
  177. package/dist/core/remote-env.js +1 -1
  178. package/dist/core/request-copy-projection.d.ts +1 -1
  179. package/dist/core/request-copy-projection.js +40 -50
  180. package/dist/core/resume-config-judge.js +1 -1
  181. package/dist/core/resume-startup-cause.d.ts +35 -18
  182. package/dist/core/resume-startup-cause.js +13 -10
  183. package/dist/core/retention.d.ts +167 -25
  184. package/dist/core/retention.js +100 -20
  185. package/dist/core/roles.d.ts +6 -0
  186. package/dist/core/roles.js +11 -5
  187. package/dist/core/rule-lane-reads.d.ts +3 -0
  188. package/dist/core/rule-lane-reads.js +5 -1
  189. package/dist/core/rule-store-fault.d.ts +70 -0
  190. package/dist/core/rule-store-fault.js +102 -0
  191. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  192. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  193. package/dist/core/runner/announce-once-ledger.js +24 -2
  194. package/dist/core/runner/assemble-result.d.ts +6 -0
  195. package/dist/core/runner/assemble-result.js +1 -1
  196. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  197. package/dist/core/runner/auto-strip-notice.js +59 -0
  198. package/dist/core/runner/branch-window.d.ts +3 -0
  199. package/dist/core/runner/branch-window.js +37 -0
  200. package/dist/core/runner/caller-roster.d.ts +8 -3
  201. package/dist/core/runner/capability-withheld-seat.js +3 -9
  202. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  203. package/dist/core/runner/clock-and-limits.js +30 -0
  204. package/dist/core/runner/contracts.d.ts +58 -35
  205. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  206. package/dist/core/runner/credential-refusal-seat.js +47 -0
  207. package/dist/core/runner/cross-boundary-lane.js +6 -4
  208. package/dist/core/runner/decide-continuation.js +1 -1
  209. package/dist/core/runner/file-history-restore.d.ts +53 -2
  210. package/dist/core/runner/file-history-restore.js +29 -10
  211. package/dist/core/runner/forward-sink.d.ts +14 -1
  212. package/dist/core/runner/forward-sink.js +14 -12
  213. package/dist/core/runner/gate-exit.d.ts +8 -7
  214. package/dist/core/runner/gate-exit.js +13 -13
  215. package/dist/core/runner/git-status-frame.js +2 -4
  216. package/dist/core/runner/initial-run-state.js +1 -1
  217. package/dist/core/runner/main-call-account.d.ts +3 -1
  218. package/dist/core/runner/main-call-account.js +5 -3
  219. package/dist/core/runner/mcp-redial.d.ts +2 -5
  220. package/dist/core/runner/mcp-redial.js +2 -2
  221. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  222. package/dist/core/runner/nested-memory-content.js +73 -13
  223. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  224. package/dist/core/runner/nested-memory-lane.js +152 -76
  225. package/dist/core/runner/park-commit.js +3 -1
  226. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  227. package/dist/core/runner/permission-rule-lanes.js +29 -3
  228. package/dist/core/runner/person-path-rows.d.ts +3 -11
  229. package/dist/core/runner/person-path-rows.js +21 -24
  230. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  231. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  232. package/dist/core/runner/prepare-artifact.js +20 -14
  233. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  234. package/dist/core/runner/prepare-ask-lane.js +6 -5
  235. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  236. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  237. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  238. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  239. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  240. package/dist/core/runner/prepare-config-doors.js +58 -41
  241. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  242. package/dist/core/runner/prepare-context-lane.js +3 -5
  243. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  244. package/dist/core/runner/prepare-defer-classify.js +1 -1
  245. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  246. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  247. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  248. package/dist/core/runner/prepare-file-history.js +117 -46
  249. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  250. package/dist/core/runner/prepare-gate-stations.js +6 -5
  251. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  252. package/dist/core/runner/prepare-hands-readface.js +8 -4
  253. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  254. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  255. package/dist/core/runner/prepare-listings.d.ts +1 -1
  256. package/dist/core/runner/prepare-listings.js +1 -1
  257. package/dist/core/runner/prepare-memory.js +2 -2
  258. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  259. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  260. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  261. package/dist/core/runner/prepare-park-ask.js +7 -9
  262. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  263. package/dist/core/runner/prepare-policy-chain.js +18 -13
  264. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  265. package/dist/core/runner/prepare-project-context.js +5 -3
  266. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  267. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  268. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  269. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  270. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  271. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  272. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  273. package/dist/core/runner/prepare-run-refs.js +8 -7
  274. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  275. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  276. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  277. package/dist/core/runner/prepare-task.js +66 -53
  278. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  279. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  280. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  281. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  282. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  283. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  284. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  285. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  286. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  287. package/dist/core/runner/restore-seat.d.ts +41 -0
  288. package/dist/core/runner/restore-seat.js +38 -0
  289. package/dist/core/runner/resume-admission.js +1 -1
  290. package/dist/core/runner/resume-apply.js +4 -3
  291. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  292. package/dist/core/runner/resume-internals-and-config.js +2 -1
  293. package/dist/core/runner/resume-preflight.js +2 -1
  294. package/dist/core/runner/rewind-files.js +22 -6
  295. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  296. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  297. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  298. package/dist/core/runner/run-brain-sinks.js +6 -6
  299. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  300. package/dist/core/runner/run-git-lane.d.ts +2 -0
  301. package/dist/core/runner/run-git-lane.js +2 -1
  302. package/dist/core/runner/run-harness-handlers.js +5 -4
  303. package/dist/core/runner/run-identity-wiring.js +20 -12
  304. package/dist/core/runner/run-leg.js +31 -72
  305. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  306. package/dist/core/runner/run-notification-lane.js +2 -4
  307. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  308. package/dist/core/runner/run-reasoning-seat.js +13 -18
  309. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  310. package/dist/core/runner/run-terminal-adoption.js +4 -8
  311. package/dist/core/runner/run-turn-boundary.js +6 -3
  312. package/dist/core/runner/runtask.d.ts +9 -4
  313. package/dist/core/runner/runtask.js +29 -22
  314. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  315. package/dist/core/runner/shell-env-withheld.js +2 -7
  316. package/dist/core/runner/side-call-account.d.ts +5 -6
  317. package/dist/core/runner/side-call-account.js +2 -2
  318. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  319. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  320. package/dist/core/runner/stream-settle-backstop.js +4 -6
  321. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  322. package/dist/core/runner/stream-steer-verb.js +4 -4
  323. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  324. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  325. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  326. package/dist/core/runner/teardown-bounded.js +7 -0
  327. package/dist/core/runner/terminal-account.js +41 -13
  328. package/dist/core/runner/terminal-projection.d.ts +1 -5
  329. package/dist/core/runner/tool-end-body.d.ts +9 -3
  330. package/dist/core/runner/tool-end-body.js +6 -3
  331. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  332. package/dist/core/runner/tool-output-projection.js +10 -14
  333. package/dist/core/runner/turn-attachments.d.ts +3 -2
  334. package/dist/core/runner/turn-attachments.js +12 -5
  335. package/dist/core/runner-deps.d.ts +6 -6
  336. package/dist/core/runtime-caps.d.ts +2 -1
  337. package/dist/core/secret-env.d.ts +20 -3
  338. package/dist/core/secret-env.js +13 -15
  339. package/dist/core/session-checkout.d.ts +115 -15
  340. package/dist/core/session-checkout.js +435 -136
  341. package/dist/core/session-policy-store.js +21 -3
  342. package/dist/core/session-reconcile.js +1 -0
  343. package/dist/core/session-store.js +2 -0
  344. package/dist/core/session.d.ts +11 -1
  345. package/dist/core/shell-run-candidates.d.ts +1 -0
  346. package/dist/core/shell-run-candidates.js +1 -1
  347. package/dist/core/shutdown-debug.d.ts +6 -5
  348. package/dist/core/shutdown-debug.js +5 -1
  349. package/dist/core/skill-grant.js +4 -1
  350. package/dist/core/skills-directory.js +5 -3
  351. package/dist/core/spec-contract.d.ts +1 -1
  352. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  353. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  354. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  355. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  356. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  357. package/dist/core/task-event.d.ts +48 -27
  358. package/dist/core/task-notification.d.ts +15 -9
  359. package/dist/core/task-notification.js +12 -0
  360. package/dist/core/task-registry-agent.d.ts +24 -22
  361. package/dist/core/task-registry-agent.js +65 -46
  362. package/dist/core/task-registry-shared.d.ts +17 -5
  363. package/dist/core/task-registry.d.ts +17 -6
  364. package/dist/core/task-registry.js +6 -1
  365. package/dist/core/task-result.d.ts +71 -25
  366. package/dist/core/task-spec-members.d.ts +0 -1
  367. package/dist/core/task-spec-members.js +1 -1
  368. package/dist/core/task-spec.d.ts +60 -52
  369. package/dist/core/task-stream.d.ts +45 -12
  370. package/dist/core/terminal-cause.d.ts +45 -8
  371. package/dist/core/terminal-cause.js +5 -0
  372. package/dist/core/tool-card-bound.d.ts +32 -0
  373. package/dist/core/tool-card-bound.js +33 -0
  374. package/dist/core/tool-catalog-entries.d.ts +9 -0
  375. package/dist/core/tool-catalog-entries.js +48 -0
  376. package/dist/core/tool-errors.d.ts +4 -3
  377. package/dist/core/tool-face.d.ts +3 -3
  378. package/dist/core/tool-mount-facts.d.ts +3 -2
  379. package/dist/core/tool-mount-facts.js +1 -1
  380. package/dist/core/tool-mount-static.js +7 -5
  381. package/dist/core/tool-policy.d.ts +21 -19
  382. package/dist/core/tool-policy.js +5 -6
  383. package/dist/core/tool-registry.d.ts +3 -1
  384. package/dist/core/tool-registry.js +15 -1
  385. package/dist/core/tool-result-store.d.ts +9 -3
  386. package/dist/core/tool-result-store.js +14 -1
  387. package/dist/core/tool-roster.d.ts +18 -0
  388. package/dist/core/tool-roster.js +30 -1
  389. package/dist/core/tool-spec.d.ts +17 -8
  390. package/dist/core/trace.d.ts +35 -31
  391. package/dist/core/types.d.ts +2 -2
  392. package/dist/core/untrusted-egress.d.ts +10 -9
  393. package/dist/core/untrusted-egress.js +9 -9
  394. package/dist/core/untrusted-text.d.ts +0 -18
  395. package/dist/core/untrusted-text.js +7 -3
  396. package/dist/core/user-attachment.d.ts +9 -6
  397. package/dist/core/user-attachment.js +12 -10
  398. package/dist/core/user-row-origin.d.ts +44 -25
  399. package/dist/core/user-row-origin.js +30 -20
  400. package/dist/core/wiring-manifest.d.ts +26 -7
  401. package/dist/core/wiring-manifest.js +14 -11
  402. package/dist/core/workspace-snapshot.d.ts +3 -1
  403. package/dist/core/workspace-snapshot.js +1 -0
  404. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  405. package/dist/engine/execution-env/node-execution-env.js +127 -67
  406. package/dist/engine/harness/agent-harness.d.ts +4 -5
  407. package/dist/engine/harness/agent-harness.js +2 -7
  408. package/dist/engine/harness/types.d.ts +51 -19
  409. package/dist/engine/harness/types.js +28 -1
  410. package/dist/engine/llm/types.d.ts +26 -14
  411. package/dist/engine/llm/types.js +2 -2
  412. package/dist/engine/loop/agent-loop.d.ts +2 -2
  413. package/dist/engine/loop/agent-loop.js +51 -275
  414. package/dist/engine/loop/types.d.ts +0 -18
  415. package/dist/engine/session/import-validate.d.ts +3 -0
  416. package/dist/engine/session/import-validate.js +34 -2
  417. package/dist/engine/session/repo-utils.d.ts +42 -4
  418. package/dist/engine/session/repo-utils.js +33 -5
  419. package/dist/engine/session/session.d.ts +41 -14
  420. package/dist/engine/session/session.js +96 -25
  421. package/dist/index.d.ts +21 -16
  422. package/dist/index.js +16 -10
  423. package/dist/orchestration/run-spec.d.ts +1 -1
  424. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  425. package/dist/orchestration/run-workflow-tool.js +15 -19
  426. package/dist/orchestration/workflow-governance.js +13 -21
  427. package/dist/orchestration/workflow-observe.d.ts +4 -3
  428. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  429. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  430. package/dist/orchestration/workflow-record-artifact.js +32 -0
  431. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  432. package/dist/orchestration/workflow-script-store.js +20 -1
  433. package/dist/orchestration/workflow-types.d.ts +33 -3
  434. package/dist/orchestration/workflow.d.ts +24 -14
  435. package/dist/orchestration/workflow.js +52 -23
  436. package/dist/prompt-assembly/artifact.js +4 -8
  437. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  438. package/dist/prompt-assembly/catalog/engine.js +30 -0
  439. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  440. package/dist/prompt-assembly/catalog/index.js +2 -2
  441. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  442. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  443. package/dist/prompt-assembly/epoch.js +6 -8
  444. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  445. package/dist/stores/file/background-agent-store.js +5 -6
  446. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  447. package/dist/stores/file/checkpoint-store.js +7 -3
  448. package/dist/stores/file/file-history-store.d.ts +8 -0
  449. package/dist/stores/file/file-history-store.js +72 -0
  450. package/dist/stores/file/fs-atomic.js +17 -12
  451. package/dist/stores/file/index.js +11 -5
  452. package/dist/stores/file/mailbox-store.js +13 -4
  453. package/dist/stores/file/permission-rule-store.js +14 -13
  454. package/dist/stores/file/shared-ledger.d.ts +4 -0
  455. package/dist/stores/file/shared-ledger.js +4 -0
  456. package/dist/stores/file/task-list-store.js +12 -3
  457. package/dist/stores/file/workflow-run-store.js +1 -0
  458. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  459. package/dist/tools/fs/bash-program-position.js +1 -1
  460. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  461. package/dist/tools/fs/bound-open.d.ts +97 -0
  462. package/dist/tools/fs/bound-open.js +103 -0
  463. package/dist/tools/fs/containment-face.d.ts +2 -2
  464. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  465. package/dist/tools/fs/fs-pdf.js +31 -23
  466. package/dist/tools/fs/fs-read.d.ts +24 -17
  467. package/dist/tools/fs/fs-read.js +84 -53
  468. package/dist/tools/fs/fs-shared.d.ts +14 -12
  469. package/dist/tools/fs/fs-shared.js +5 -4
  470. package/dist/tools/fs/fs-write.d.ts +2 -2
  471. package/dist/tools/fs/fs-write.js +20 -12
  472. package/dist/tools/fs/index.d.ts +4 -4
  473. package/dist/tools/fs/index.js +2 -2
  474. package/dist/tools/fs/notebook.d.ts +1 -1
  475. package/dist/tools/fs/pdf.d.ts +12 -3
  476. package/dist/tools/fs/pdf.js +22 -9
  477. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  478. package/dist/tools/fs/read-deny-home.js +8 -11
  479. package/dist/tools/fs/safety.d.ts +3 -2
  480. package/dist/tools/fs/shell-read-check.js +10 -9
  481. package/dist/tools/monitor.d.ts +6 -5
  482. package/dist/tools/task-list.d.ts +16 -6
  483. package/dist/tools/task-list.js +4 -0
  484. package/dist/tools/web.d.ts +9 -1
  485. package/dist/tools/web.js +8 -3
  486. package/dist/tools/worktree.d.ts +7 -5
  487. package/dist/tools/worktree.js +4 -3
  488. package/package.json +4 -3
  489. package/test/export-surface.snapshot.json +93 -7
  490. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  491. package/wire-changes/core-stores-sql@7.68.1.json +39 -0
  492. package/wire-changes/core@7.68.0.json +4257 -0
  493. package/wire-changes/core@7.68.1.json +95 -0
  494. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  495. package/wire-changes/mods-kernel@7.68.1.json +39 -0
  496. package/wire-changes/primitives@7.68.0.json +253 -0
  497. package/wire-changes/primitives@7.68.1.json +39 -0
  498. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  499. package/wire-changes/wiki-gate@7.68.1.json +39 -0
  500. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  501. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -1,5 +1,6 @@
1
1
  import { DENIED_BY_MAY_ECHO, screenGateOutcome, SETTLEMENT_IS_REFUSAL } from "../gate-outcome.js";
2
2
  import { ASK_CLASSES, askFaceOf, classifyAsk, headlessApprovalRemedy, unresolvedAskDenialMessage, unresolvedAskQuestionOf } from "../ask-origin.js";
3
+ import { NOT_RESUMABLE_CARRY_ON, notResumableWayOut } from "../park-resumability.js";
3
4
  import { wireOf } from "../tool-name-readings.js";
4
5
  import { isProtectedWrite } from "../tool-registry.js";
5
6
  import { attestationOf, decisionText, foldHookAsk, licenseCovers } from "../tool-policy.js";
@@ -163,7 +164,7 @@ export function createSettlementLedger(call) {
163
164
  },
164
165
  };
165
166
  }
166
- export function cloneObserverInput(input) {
167
+ function cloneObserverInput(input) {
167
168
  try {
168
169
  return structuredClone(input);
169
170
  }
@@ -175,6 +176,10 @@ export function cloneObserverInput(input) {
175
176
  return input;
176
177
  }
177
178
  }
179
+ export function permissionDeniedOf(refusal) {
180
+ const { toolName, finalInput, toolCallId, reason, gate, identity, permissionMode } = refusal;
181
+ return { toolName, input: cloneObserverInput(finalInput), toolCallId, reason, gate, ...(identity !== undefined ? { identity } : {}), ...(permissionMode !== undefined ? { permissionMode } : {}) };
182
+ }
178
183
  const RECORD_RECEIPT = Object.freeze({ accessors: "refuse", depth: MAX_DEPTH, others: "refuse", contain: true, isProxy: (v) => types.isProxy(v) });
179
184
  export function frozenInputSnapshot(input) {
180
185
  const received = receive(input, RECORD_RECEIPT);
@@ -265,7 +270,7 @@ export async function engineFailClosedExit(pass, reason, extension) {
265
270
  const { input, toolName, toolCallId, notifyPermissionDenied } = pass;
266
271
  const gate = directDeny("hook", extension);
267
272
  const finalInput = frozenInputSnapshot(pass.currentInput);
268
- await notifyPermissionDenied({ toolName, input: cloneObserverInput(finalInput), toolCallId, reason, gate, ...(input.identity !== undefined ? { identity: input.identity } : {}) });
273
+ await notifyPermissionDenied(permissionDeniedOf({ toolName, finalInput, toolCallId, reason, gate, identity: input.identity }));
269
274
  return { block: true, reason: formatHookFeedback(reason, input.reminderMark), gate, finalInput, preToolContext: pass.preToolContext };
270
275
  }
271
276
  export const unownedArgsMessage = (subject, reason) => `${subject} could not be taken into the gate's own copy (${reason}) — denied fail-closed`;
@@ -325,24 +330,19 @@ export async function exitGate(pass) {
325
330
  const tableSeat = unresolvable !== undefined ? askUnresolvableRemedySeat(unresolvable) : undefined;
326
331
  const remedySeat = tableSeat === "absent" && input.askSeatForm === "declared_none" && pass.askClassification?.classes.has("content_question") !== true ? "declared_none" : tableSeat === "unavailable" && input.askSeatForm === "policy_callback" ? "policy" : tableSeat;
327
332
  const bindingRefusal = attestationOf(pass.decision, { toolCallId, toolName })?.bindingRefusal;
328
- const headless = bindingRefusal !== undefined ? undefined : remedySeat !== undefined ? headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat: remedySeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}) }) : undefined;
333
+ const wayOut = input.notResumable !== undefined ? notResumableWayOut(input.notResumable.source, input.notResumable.mandated, pass.askClassification?.classes.has("content_question") === true ? "answer" : "approval") : undefined;
334
+ const headless = bindingRefusal !== undefined ? undefined : remedySeat !== undefined ? headlessApprovalRemedy({ mode: input.permissionMode?.(), classification: foldCause !== undefined ? ancestorUnresolvedClassification(pass.req) : pass.askClassification, approverSeat: remedySeat, coveredWrite: isProtectedWrite(pass.req), ...(pass.shellUnplacedOptions !== undefined ? { unplacedOptions: pass.shellUnplacedOptions } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}) }) : undefined;
329
335
  const remedy = headless?.sentence;
330
336
  const base = parkFailedBase(decisionText(pass.decision) ?? `tool "${toolName}" denied by policy`, toolName, unresolvable, pass.parkFailed !== undefined);
331
- const denyReason = withParkFailureCause(`${base}${remedy !== undefined ? ` — ${remedy}` : ""}`, pass.parkFailed, unresolvable !== undefined);
337
+ const tail = remedy !== undefined ? ` — ${remedy}` : unresolvable !== undefined && wayOut !== undefined && bindingRefusal === undefined ? `. To go on: ${wayOut}. ${NOT_RESUMABLE_CARRY_ON}` : "";
338
+ const denyReason = withParkFailureCause(`${tail.startsWith(".") ? base.replace(/\.$/, "") : base}${tail}`, pass.parkFailed, unresolvable !== undefined);
332
339
  if (unresolvable !== undefined) {
333
340
  const cause = unresolvable;
334
341
  const noticeRemedy = bindingRefusal ?? remedy;
335
- pass.notifier.notify(() => input.onAskUnresolvable?.({ toolName, toolCallId, cause, parkLaneExisted: pass.suspendAsk !== undefined, ...(noticeRemedy !== undefined ? { remedy: noticeRemedy } : {}), ...(headless !== undefined ? { remedies: headless.remedies } : {}) }), "toolGate.onAskUnresolvable");
342
+ pass.notifier.notify(() => input.onAskUnresolvable?.({ toolName, toolCallId, cause, parkLaneExisted: pass.suspendAsk !== undefined, ...(noticeRemedy !== undefined ? { remedy: noticeRemedy } : {}), ...(headless !== undefined ? { remedies: headless.remedies } : {}), ...(wayOut !== undefined ? { notResumableWayOut: wayOut } : {}) }), "toolGate.onAskUnresolvable");
336
343
  }
337
344
  const finalInput = frozenInputSnapshot(pass.currentInput);
338
- await notifyPermissionDenied({
339
- toolName,
340
- input: cloneObserverInput(finalInput),
341
- toolCallId,
342
- reason: denyReason,
343
- gate,
344
- ...(input.identity !== undefined ? { identity: input.identity } : {}),
345
- });
345
+ await notifyPermissionDenied(permissionDeniedOf({ toolName, finalInput, toolCallId, reason: denyReason, gate, identity: input.identity }));
346
346
  return {
347
347
  block: true,
348
348
  reason: formatHookFeedback(denyReason, input.reminderMark),
@@ -1,4 +1,4 @@
1
- import { createHash } from "node:crypto";
1
+ import { textContentHashOf } from "../canonical-json.js";
2
2
  import { GIT_SNAPSHOT_CC_PREAMBLE, buildGitSnapshot } from "../../prompts/default.js";
3
3
  import { inlineUntrusted } from "../untrusted-text.js";
4
4
  import { openSystemReminder } from "../reminder-mint.js";
@@ -44,9 +44,7 @@ export function renderGitStatusFrameBody(outcome) {
44
44
  }
45
45
  }
46
46
  export function hashGitStatusFrame(kind, body, canonicalRoot) {
47
- return `sha256:${createHash("sha256")
48
- .update(`${GIT_STATUS_FRAME_FORMAT_VERSION}\u0000${canonicalRoot}\u0000${kind}\u0000${body}`)
49
- .digest("hex")}`;
47
+ return textContentHashOf(`${GIT_STATUS_FRAME_FORMAT_VERSION}\u0000${canonicalRoot}\u0000${kind}\u0000${body}`);
50
48
  }
51
49
  export function resolveGitStatusFrame(outcome, canonicalRoot, degradedMaterial) {
52
50
  const body = renderGitStatusFrameBody(outcome);
@@ -2,7 +2,7 @@ export function createRunState() {
2
2
  return {
3
3
  telemetry: { requestedModel: undefined, cacheFamily: "input-excludes-cached", pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: true, unpricedSpend: false, tracer: undefined, taskId: "", runId: "", taskStart: 0, taskStartMonotonic: 0, cacheBreakReported: false },
4
4
  degrade: { degradeToModel: undefined, degraded: undefined, budgetSwitched: false, outputErrorStreak: 0, outputInvalid: false, recordDegraded: () => { }, priceOf: () => ({ pricing: { inputPer1M: 0, outputPer1M: 0 }, pricingConfigured: false, cacheFamily: "input-excludes-cached" }), fallbackSeat: { observe: () => { } } },
5
- limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined },
5
+ limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined, walltimeCrossedMs: undefined, budgetOverAtTurnCap: undefined },
6
6
  budget: { remainingMicroUsd: undefined, maxCostMicroUsd: undefined, remainingTokens: undefined, maxTokensWindow: undefined, overBudget: () => undefined, streamCancel: false, callOutputChars: 0, lastStreamBudgetCheck: 0, projectedOverBudget: () => undefined },
7
7
  turn: { callStartAt: undefined, firstTokenAt: undefined, turnUsage: undefined, turnUsageMissing: false, turnCacheMarks: {}, turnStopReason: undefined, turnResponseModel: undefined, toolBatch: [] },
8
8
  counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, compactionPasses: 0, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
@@ -24,8 +24,10 @@ export interface BookedCall {
24
24
  * more than one call). Integer micro-USD, summed per call, so a mid-task model or price change is accounted correctly.
25
25
  * `usageMissing` = the call's usage is a lower bound (the caller marks the turn and the leg; the cache account leaves the main
26
26
  * lane out of the hit rate). A cache member the call did not report marks the turn's frame as it marks the leg's stats.
27
+ * `apiMs` is the call's API wall time: from the engine's issue stamp (the row's `callStartedAt`) to the row's own `ts`, 0 where the call has
28
+ * no stamp (a hop a walk left behind, a call beside the loop); it is summed into the turn's and the leg's `apiDurationMs` here, beside the tokens.
27
29
  */
28
- export declare function bookMainCall(rs: RunState, stats: Stats, model: Model, usage: Usage, usageMissing: boolean): BookedCall;
30
+ export declare function bookMainCall(rs: RunState, stats: Stats, model: Model, usage: Usage, usageMissing: boolean, apiMs: number): BookedCall;
29
31
  /** Carry one booking's cache marks onto the upcoming `turn_end` (the harness-handlers lane also calls it for a turn that booked no
30
32
  * call at all). */
31
33
  export declare function noteTurnCacheMarks(rs: RunState, marks: CacheMemberMarks): void;
@@ -1,7 +1,7 @@
1
1
  import { emitTrace } from "../trace.js";
2
2
  import { bookCacheOperands, cacheTraceMembersOf } from "./cache-hit-account.js";
3
3
  import { usageCostMicroUsd } from "./usage-accounting.js";
4
- export function bookMainCall(rs, stats, model, usage, usageMissing) {
4
+ export function bookMainCall(rs, stats, model, usage, usageMissing, apiMs) {
5
5
  const price = rs.degrade.priceOf(model);
6
6
  const { totalInputTokens: turnTotal, uncachedInputTokens: turnUncached, costMicroUsd: turnCostMicroUsd } = usageCostMicroUsd(price.cacheFamily, usage, price.pricing);
7
7
  if (!price.pricingConfigured)
@@ -14,14 +14,16 @@ export function bookMainCall(rs, stats, model, usage, usageMissing) {
14
14
  stats.cacheWriteTokensLong += usage.cacheWriteLong ?? 0;
15
15
  stats.outputTokens += usage.output || 0;
16
16
  stats.costMicroUsd += turnCostMicroUsd;
17
+ stats.apiDurationMs = (stats.apiDurationMs ?? 0) + apiMs;
17
18
  const marks = bookCacheOperands(stats, "main", { family: price.cacheFamily, usage }, usageMissing, turnTotal);
18
- rs.turn.turnUsage ??= { inputTokens: 0, totalInputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, costMicroUsd: 0 };
19
+ rs.turn.turnUsage ??= { inputTokens: 0, totalInputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, costMicroUsd: 0, apiDurationMs: 0 };
19
20
  rs.turn.turnUsage.inputTokens += turnUncached;
20
21
  rs.turn.turnUsage.totalInputTokens += turnTotal;
21
22
  rs.turn.turnUsage.outputTokens += usage.output || 0;
22
23
  rs.turn.turnUsage.cacheReadTokens += usage.cacheRead ?? 0;
23
24
  rs.turn.turnUsage.cacheWriteTokens += usage.cacheWrite ?? 0;
24
25
  rs.turn.turnUsage.costMicroUsd += turnCostMicroUsd;
26
+ rs.turn.turnUsage.apiDurationMs += apiMs;
25
27
  noteTurnCacheMarks(rs, marks);
26
28
  return { turnTotal, turnUncached, turnCostMicroUsd, priced: price.pricingConfigured };
27
29
  }
@@ -39,7 +41,7 @@ export function bookLeftHops(rs, stats, reading) {
39
41
  rs.turn.turnUsageMissing = true;
40
42
  stats.usageMissing = true;
41
43
  }
42
- const billed = bookMainCall(rs, stats, attempt.model, attempt.usage, attempt.usageMissing === true);
44
+ const billed = bookMainCall(rs, stats, attempt.model, attempt.usage, attempt.usageMissing === true, 0);
43
45
  emitTrace(rs.telemetry.tracer, () => ({
44
46
  kind: "brain.call", version: 1, taskId: rs.telemetry.taskId, model: attempt.model.id, provider: attempt.model.provider, turn: stats.turns + 1,
45
47
  promptTokens: billed.turnUncached, totalInputTokens: billed.turnTotal, completionTokens: attempt.usage.output || 0,
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { AgentTool } from "../../internal/harness.js";
17
17
  import type { McpDroppedTool, McpReconnectResult, MaterializedMcp, McpToolAxis } from "../mcp.js";
18
- import type { RunnerDeps, TaskSpec, ToolEffect } from "../types.js";
18
+ import type { RunnerDeps, ToolEffect } from "../types.js";
19
19
  import type { IrreversibilityTier, ToolFaceSnapshot } from "./contracts.js";
20
20
  import type { RosterBuilder, ToolRosterDeltaSeat } from "../tool-roster.js";
21
21
  import type { McpInstructionsEntry } from "../prompt-section-seat.js";
@@ -34,10 +34,7 @@ export interface McpRosterDelta {
34
34
  /** The seats a roster application writes through. Every one of them is borrowed from the phase that
35
35
  * minted it — this module owns nothing. */
36
36
  export interface McpRosterApplyInput {
37
- /** borrowed-readonly — the run's spec; only `excludeAllTools` is read: the valve's whole-face switch decides what a live roster
38
- * change may mount, beside the selector (`valveLeaves`). */
39
- spec: Pick<TaskSpec, "excludeAllTools">;
40
- /** borrowed-readonly — the frozen tool face; its selector keeps a tool the leg may not use from ever
37
+ /** borrowed-readonly — the frozen tool face; its selector (the whole-face switch inside it) keeps a tool the leg may not use from ever
41
38
  * being mounted by a face the model or a host can trigger. */
42
39
  toolFaceSnapshot: Pick<ToolFaceSnapshot, "selector">;
43
40
  /** borrowed-readonly — the per-server face overlay (the phase's `withFaces`). */
@@ -20,10 +20,10 @@ function settleInstructions(lane, delta, taught) {
20
20
  tellInstructions(lane, delta.instructions);
21
21
  }
22
22
  export function applyMcpRosterDelta(input, delta) {
23
- const { spec, toolFaceSnapshot, withFaces, remoteToolOffload, foldProtocolAxes, toolEffects, axisExplicitNegatives, roster } = input;
23
+ const { toolFaceSnapshot, withFaces, remoteToolOffload, foldProtocolAxes, toolEffects, axisExplicitNegatives, roster } = input;
24
24
  const domainNow = () => toolNamesOfServer(roster.tools.map((t) => t.name), delta.server);
25
25
  const before = domainNow();
26
- const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
26
+ const leaves = valveLeaves(toolFaceSnapshot.selector);
27
27
  const pushable = delta.tools.filter(leaves);
28
28
  const valveExcluded = delta.tools.filter((t) => !leaves(t)).map((t) => t.name);
29
29
  const clearDomain = (m) => {
@@ -10,10 +10,16 @@ export declare const INSTRUCTION_FILE_MAX_BYTES: number;
10
10
  /** One file's cap: max(40 000, window × 0.05 × characters per token, to the nearest whole character). */
11
11
  export declare function instructionFileCap(contextWindow: number, charsPerToken: number): number;
12
12
  /** A file as the lane shows it. `content` is the text after the frontmatter and the comments; `globs` is present only on a
13
- * file whose frontmatter names paths it applies to; `includes` are the include paths as written (relative ones unresolved). */
13
+ * file whose frontmatter names paths it applies to; `noLimit` is present (true) when the frontmatter names `paths:` and
14
+ * nothing in it limits the file — the key is there and reads as no glob (nothing under it, an empty list, only `**`, a value
15
+ * that is not a string, a mapping); `spansLines` is present (true) when one glob of it was written over several lines — globs
16
+ * on lines of their own with no comma between them read as one text, which matches no file; `includes` are the include paths
17
+ * as written (relative ones unresolved). */
14
18
  export interface InstructionText {
15
19
  readonly content: string;
16
20
  readonly globs?: readonly string[];
21
+ readonly noLimit?: true;
22
+ readonly spansLines?: true;
17
23
  readonly includes: readonly string[];
18
24
  }
19
25
  /** Read one instruction file's text (already in the decoded coordinate). `withIncludes`: extract the `@` include paths. */
@@ -10,10 +10,16 @@ export function instructionFileCap(contextWindow, charsPerToken) {
10
10
  return Math.max(INSTRUCTION_FILE_MIN_CHARS, Math.round(window * INSTRUCTION_FILE_WINDOW_SHARE * charsPerToken));
11
11
  }
12
12
  export function processInstructionText(text, withIncludes) {
13
- const { body, paths } = splitFrontmatter(text);
13
+ const { body, paths, spansLines } = splitFrontmatter(text);
14
14
  const globs = paths === undefined ? undefined : ruleGlobsOf(paths);
15
15
  const content = body.includes("<!--") ? stripBlockComments(body) : body;
16
- return { content, ...(globs !== undefined ? { globs } : {}), includes: withIncludes && content.includes("@") ? includePathsOf(content) : [] };
16
+ return {
17
+ content,
18
+ ...(globs !== undefined ? { globs } : {}),
19
+ ...(paths !== undefined && globs === undefined ? { noLimit: true } : {}),
20
+ ...(spansLines === true && globs !== undefined ? { spansLines: true } : {}),
21
+ includes: withIncludes && content.includes("@") ? includePathsOf(content) : [],
22
+ };
17
23
  }
18
24
  function splitFrontmatter(text) {
19
25
  const lines = text.split("\n");
@@ -23,25 +29,79 @@ function splitFrontmatter(text) {
23
29
  if (end < 0)
24
30
  return { body: text };
25
31
  const body = lines.slice(end + 1).join("\n");
26
- const block = lines.slice(1, end);
32
+ const block = lines.slice(1, end).map((l) => (l.endsWith("\r") ? l.slice(0, -1) : l));
27
33
  const at = block.findIndex((l) => /^paths[ \t]*:/.test(l));
28
34
  if (at < 0)
29
35
  return { body };
30
- const rest = unquote(block[at].replace(/^paths[ \t]*:/, "").trim());
36
+ const value = pathsValueOf(block[at].replace(/^paths[ \t]*:/, "").trim(), block.slice(at + 1));
37
+ return { body, paths: value.values, ...(value.spansLines === true ? { spansLines: true } : {}) };
38
+ }
39
+ const spansLinesOf = (lines) => (splitTopLevel(lines.join("\n")).some((p) => p.includes("\n")) ? { spansLines: true } : {});
40
+ function pathsValueOf(raw, below) {
41
+ const rest = unquote(raw);
31
42
  if (rest.startsWith("[") && rest.endsWith("]"))
32
- return { body, paths: splitTopLevel(rest.slice(1, -1)).map(unquote) };
33
- if (rest !== "")
34
- return { body, paths: [rest] };
35
- const items = [];
36
- for (const l of block.slice(at + 1)) {
37
- const m = /^[ \t]+-[ \t]+(.*)$/.exec(l);
38
- if (m === null)
43
+ return { values: splitTopLevel(rest.slice(1, -1)).flatMap(globText) };
44
+ const header = /^([|>])(?:([1-9])[+-]?|[+-]([1-9])?)?$/.exec(raw);
45
+ if (header !== null) {
46
+ const lines = blockScalarLines(below, Number(header[2] ?? header[3] ?? 0));
47
+ const text = lines.join("\n");
48
+ return { values: [header[1] === ">" ? text.replace(/([^\n])\n(?=[^\n ])/g, "$1 ") : text], ...spansLinesOf(lines) };
49
+ }
50
+ if (rest !== raw)
51
+ return { values: globText(raw) };
52
+ const blank = (l) => /^[ \t]*(?:#.*)?$/.test(l);
53
+ const first = below.find((l) => !blank(l));
54
+ if (raw === "" && first !== undefined && /^[ \t]*-(?:[ \t]|$)/.test(first)) {
55
+ const items = [];
56
+ for (const l of below) {
57
+ if (blank(l))
58
+ continue;
59
+ const m = /^[ \t]*-(?:[ \t]+(.*))?$/.exec(l);
60
+ if (m === null)
61
+ break;
62
+ items.push(...globText((m[1] ?? "").trim()));
63
+ }
64
+ return { values: items };
65
+ }
66
+ const folded = raw === "" ? [] : [raw];
67
+ for (const l of below) {
68
+ if (l.trim() === "")
69
+ continue;
70
+ if (/^[ \t]*#/.test(l)) {
71
+ if (folded.length > 0)
72
+ break;
73
+ continue;
74
+ }
75
+ if (!/^[ \t]/.test(l))
76
+ break;
77
+ folded.push(l.trim());
78
+ }
79
+ const value = folded.join(" ");
80
+ return /:(?:[ \t]|$)/.test(value) ? { values: [] } : { values: globText(value), ...spansLinesOf(folded) };
81
+ }
82
+ function blockScalarLines(below, explicitIndent) {
83
+ let indent = explicitIndent;
84
+ const lines = [];
85
+ for (const l of below) {
86
+ if (l.trim() === "") {
87
+ lines.push("");
88
+ continue;
89
+ }
90
+ const n = l.length - l.trimStart().length;
91
+ if (indent === 0)
92
+ indent = n;
93
+ if (n === 0 || n < indent)
39
94
  break;
40
- items.push(unquote(m[1].trim()));
95
+ lines.push(l.slice(indent));
41
96
  }
42
- return { body, paths: items };
97
+ return lines;
43
98
  }
44
99
  const unquote = (s) => (s.length >= 2 && ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) ? s.slice(1, -1) : s);
100
+ const PLAIN_NON_STRING = /^(?:~|null|Null|NULL|true|True|TRUE|false|False|FALSE|[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|0x[0-9a-fA-F]+|0o[0-7]+|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;
101
+ const globText = (raw) => {
102
+ const text = unquote(raw);
103
+ return text === raw && PLAIN_NON_STRING.test(raw) ? [] : [text];
104
+ };
45
105
  function splitTopLevel(s) {
46
106
  const out = [];
47
107
  let depth = 0;
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * The INSTRUCTION-FILE LANE — the one reader of the family the deployment declared (`TaskSpec.instructionFamily`)
3
3
  * at every level of the task root: the root's own level (the session's instructions, the reference's user context) and the
4
- * directories a run accesses below it (the reference's `nested_memory`). What is owed rides the next request as attachment
5
- * frames — origin `project_instructions` for the root's level, `nested_memory` for a level below it and for a rule the
6
- * deployment holds (the user-attachment seat's frame, delivery record and settlement).
4
+ * directories a run accesses below it (the reference's `nested_memory`). Under the declaration's `additionalDirectories`
5
+ * opt-in, each additional working directory the request declared is a further ROOT: its own level is read as the task
6
+ * root's is (the reference's additional-directory loop), for the declaration's first family — no level below it and no
7
+ * second family. What is owed rides the next request as attachment frames — origin `project_instructions` for a root's own
8
+ * level, `nested_memory` for a level below the task root and for a rule the deployment holds (the user-attachment seat's
9
+ * frame, delivery record and settlement).
7
10
  *
8
- * ONE LAW. A family member F of a level D is OWED exactly when (i) D is the task root, or the read state holds an entry
9
- * below D that an access recorded (not this lane's own, not a context seed); (ii) the read state holds no entry of F at
11
+ * ONE LAW. A family member F of a level D is OWED exactly when (i) D is a root, or the read state holds an entry below D
12
+ * (and below the task root) that an access recorded (not this lane's own, not a context seed); (ii) the read state holds no entry of F at
10
13
  * F's current contents; (iii) F passes the Read tool's admission. The law is a function of the read state; a load looks at
11
14
  * the root's level every time, and at a level below it when an entry under that level changed since the last load (an
12
15
  * access, a retirement) — so a member below the root that changes while nothing under its directory does is found at the
@@ -18,11 +21,17 @@
18
21
  * longer applies, and its receipt deletes the entry while it is still this lane's own (the transcript's replay reads the
19
22
  * withdrawal the same way). The delivered entries of a level are what is checked, not the members a listing finds.
20
23
  *
21
- * Bounds: a load makes at most {@link NESTED_MEMORY_PROBES_PER_LOAD} probes (a stat, a read, a listing) and carries at most
22
- * three files' cap of frames; what is left waits for the next load, the root's level first. A file the model could not
23
- * Read is not loaded, and the user is told once per session (`instructions.withheld`); a file that cannot be read is said
24
+ * Bounds: a load makes at most {@link NESTED_MEMORY_PROBES_PER_LOAD} probes (a stat, a read, a listing) times the roots it
25
+ * reads (pooled) and carries at most three files' cap of frames; what is left waits for the next load in the levels' order
26
+ * (each root's own level in root order — the task root's, then each additional root's in declaration order — then the
27
+ * levels below the task root; a file two levels name is read under the first), and a rule or a rules directory the lane has
28
+ * already asked about waits behind the waiting ones of its level (a root's rule directory larger than one load's probes is
29
+ * read whole across loads). A file the model could not Read is not loaded, and the user is told once per session
30
+ * (`instructions.withheld`); a file that cannot be read is said
24
31
  * to the operator once per session. The reference: Claude Code 2.1.316's session loader `vHo` (cli316.js:270117)
25
- * c27352 (the same local reader as the tools: the delegate slot `D_e` has no writer), the triggers (Read L272461 c20127,
32
+ * c27352 (the same local reader as the tools: the delegate slot `D_e` has no writer), its additional-directory loop c30240
33
+ * (after the working directory's chain; `QQ` c24020 is empty unless opted in; the rules there `conditionalRule: false`,
34
+ * kept by c23650; no second family), the triggers (Read L272461 c20127,
26
35
  * Write L270129 c22955, Edit L273001 c4841), the producer `XCn` / `_Cn` L272682 c19910 – c22950, the directory chain `pet`
27
36
  * L272682 c19311, the family `_zr` / `I_e` L270117 c34536 – c35427, the entry stamp `ZGr` L272461 c1348.
28
37
  */
@@ -34,7 +43,7 @@ import type { ToolCallFace } from "../tool-policy.js";
34
43
  import { type InstructionLayer, type MintedAttachmentFrame } from "../user-attachment.js";
35
44
  import type { ReminderDisclosureCounts } from "../reminder-disclosure.js";
36
45
  import type { TaskSpec } from "../task-spec.js";
37
- import type { RunnerDeps, TaskEvent, TaskEventIdentity } from "../types.js";
46
+ import type { EngineNotice, RunnerDeps, TaskEvent, TaskEventIdentity } from "../types.js";
38
47
  import type { WiringManifest } from "../wiring-manifest.js";
39
48
  import type { Prepared } from "./contracts.js";
40
49
  /** At most this many names in `files` (and in `alternate.files`). */
@@ -43,7 +52,8 @@ export declare const NESTED_MEMORY_MAX_NAMES = 8;
43
52
  export declare const NESTED_MEMORY_NAME_MAX = 255;
44
53
  /** At most this many `hostRules`. */
45
54
  export declare const NESTED_MEMORY_MAX_HOST_RULES = 20;
46
- /** The probes one load makes at most (a stat, a read, a directory listing each count one). */
55
+ /** The probes one load makes at most, times the number of roots it reads (a stat, a read, a directory listing each count
56
+ * one; the allowances are pooled): a further root's own level — looked at on every load — brings its own share. */
47
57
  export declare const NESTED_MEMORY_PROBES_PER_LOAD = 32;
48
58
  /** One load's frames, at most this many files' cap (the frames counted whole: sentences, labels and data). */
49
59
  export declare const NESTED_MEMORY_FRAME_BUDGET_FILES = 3;
@@ -57,10 +67,14 @@ export declare const INSTRUCTIONS_WITHHELD = "instructions.withheld";
57
67
  /** Why an instruction file was not loaded — the notice's `detail.reason`. */
58
68
  export declare const INSTRUCTIONS_WITHHELD_REASONS: readonly ["rule_denied", "outside_roots", "approval_required", "admission_unknown", "target_moved"];
59
69
  export type InstructionsWithheldReason = (typeof INSTRUCTIONS_WITHHELD_REASONS)[number];
70
+ /** The notice a run prepared with no instruction family declared is the first, for its notice receiver, to say. */
71
+ export declare const INSTRUCTIONS_FAMILY_UNDECLARED = "instructions.family_undeclared";
72
+ /** The operator's sentence for that absence: what no run reads, and the one thing that makes them read it. */
73
+ export declare function instructionsFamilyUndeclaredNotice(sessionId: string): EngineNotice;
60
74
  /**
61
75
  * The lane's capability descriptor — what a host reads to decide whether to declare the family here and stop loading
62
- * instruction files itself: the declaration's seat, the frames' origins (a level below the root; the root's own level),
63
- * the echo and the notice it raises, its limits.
76
+ * instruction files itself: the declaration's seat, the frames' origins (a level below the root; a root's own level — the
77
+ * task root's, an additional directory's under the opt-in), the echo and the notice it raises, its limits.
64
78
  */
65
79
  export declare const NESTED_MEMORY_LANE: Readonly<{
66
80
  declaration: "TaskSpec.instructionFamily";
@@ -86,6 +100,7 @@ export interface ScreenedNestedMemory {
86
100
  readonly when: "absent" | "also";
87
101
  };
88
102
  readonly includes: boolean;
103
+ readonly additionalDirectories: boolean;
89
104
  readonly hostRules: ReadonlyArray<{
90
105
  readonly level: "user" | "managed" | "project";
91
106
  readonly name: string;
@@ -106,7 +121,9 @@ export declare function screenNestedMemory(spec: Pick<TaskSpec, "instructionFami
106
121
  /** What the lane reads with: the hands' environment and reader, the run's served-read judge (every ask held: nobody asked
107
122
  * for this file, so it is shown only where the model's own `Read` of it would be served with nobody asked) and the face
108
123
  * the run's roster gives `Read` (read at each judgment; none ⇒ the model could not read the file itself), the live read
109
- * state, the canonical task root; the prepared leg (read at each load) for the model and the records. */
124
+ * state, the canonical task root and the additional working directories the request declared (each its declared spelling
125
+ * and the one canonical form the hands resolved it to, in declaration order; read as roots only under the declaration's
126
+ * opt-in); the prepared leg (read at each load) for the model and the records. */
110
127
  export interface NestedMemoryLaneSeat {
111
128
  readonly declaration: ScreenedNestedMemory;
112
129
  readonly env: ExecutionEnv;
@@ -115,12 +132,19 @@ export interface NestedMemoryLaneSeat {
115
132
  readonly readFace: () => ToolCallFace | undefined;
116
133
  readonly state: ReadFileState;
117
134
  readonly root: string;
135
+ readonly additionalRoots?: ReadonlyArray<DeclaredRoot>;
118
136
  readonly signal: AbortSignal;
119
137
  readonly mark: string | undefined;
120
138
  readonly counts: ReminderDisclosureCounts | undefined;
121
139
  readonly deps: Pick<RunnerDeps, "onNotice" | "onError">;
122
140
  readonly leg: () => Pick<Prepared, "harness" | "session" | "sessionId" | "runId" | "announcedListingsRef" | "frameReceipts" | "hookIdentity"> | undefined;
123
141
  }
142
+ /** An additional working directory as the request declared it (`TaskSpec.additionalDirectories`, the spelling) and as the
143
+ * hands resolved it (the canonical form the file tools' fence holds). */
144
+ export interface DeclaredRoot {
145
+ readonly directory: string;
146
+ readonly canonical: string;
147
+ }
124
148
  /** Told each delivered frame at its receipt: the file's key (a deployment rule's name), the layer it belongs to, and
125
149
  * whether the frame withdrew a file delivered earlier. */
126
150
  export type InstructionEcho = (label: string, layer: InstructionLayer, withdrawn: boolean) => void;
@@ -139,7 +163,7 @@ export declare function instructionEchoTo(queue: {
139
163
  }): InstructionEcho;
140
164
  /**
141
165
  * The instruction files' COMPACTION arm: a landed compaction retired the entries of the frames it summarized away, so the
142
- * task root's level (owed on every load) and every level whose access the kept tail still holds owe again. One load, its
166
+ * roots' own levels (owed on every load) and every level whose access the kept tail still holds owe again. One load, its
143
167
  * frames written to the transcript as engine messages before any reader of the new baseline (the next request first), each
144
168
  * committed on its own append — what one could not write stays owed for the next load. Never throws.
145
169
  */
@@ -167,10 +191,11 @@ export interface NestedMemoryLane {
167
191
  readonly triggers?: readonly string[];
168
192
  readonly echo: InstructionEcho;
169
193
  }): Promise<NestedMemoryLoad | undefined>;
170
- /** The task root's members the conversation holds (a read-state entry) or a load has on its way, relative to the task
171
- * root, `/`-separated — the declared names first, in declaration order, then the rules by path. */
172
- rootSelected(): string[];
173
- /** Is this key a member of the declared family — at the task root's level, or at any level — read off the declaration
194
+ /** Each root's members the conversation holds (a read-state entry) or a load has on its way, relative to that root,
195
+ * `/`-separated — the declared names first, in declaration order, then the rules by path: the task root's
196
+ * (`selected`) and, under the opt-in, each additional root's in declaration order (the wiring manifest's member). */
197
+ selected(): NonNullable<WiringManifest["instructions"]>;
198
+ /** Is this key a member of the declared family — at a root's own level, or at any level — read off the declaration
174
199
  * and the path alone (a member's name, or a markdown file under a rules directory), whoever wrote its entry? */
175
200
  isMember(key: string, at: "root" | "any"): boolean;
176
201
  }