@sema-agent/core 7.54.1 → 7.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (621) hide show
  1. package/CHANGELOG.md +950 -0
  2. package/dist/agents/agent-transcript-tool.js +2 -1
  3. package/dist/agents/builtin-agents.d.ts +12 -14
  4. package/dist/agents/cascade.js +1 -1
  5. package/dist/agents/cc-peer-directory.d.ts +36 -0
  6. package/dist/agents/cc-peer-directory.js +139 -0
  7. package/dist/agents/cc-peer-wire.d.ts +105 -0
  8. package/dist/agents/cc-peer-wire.js +98 -0
  9. package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
  10. package/dist/agents/cc-uds-peer-channel.js +457 -0
  11. package/dist/agents/child-model-seat.d.ts +0 -11
  12. package/dist/agents/child-model-seat.js +0 -3
  13. package/dist/agents/cross-session-envelope.d.ts +4 -1
  14. package/dist/agents/cross-session-envelope.js +8 -1
  15. package/dist/agents/cross-session-judge.d.ts +2 -2
  16. package/dist/agents/list-agents-tool.d.ts +3 -1
  17. package/dist/agents/list-agents-tool.js +9 -8
  18. package/dist/agents/observer.d.ts +4 -5
  19. package/dist/agents/observer.js +2 -1
  20. package/dist/agents/peer-admission.d.ts +6 -0
  21. package/dist/agents/peer-admission.js +4 -1
  22. package/dist/agents/peer-directory.d.ts +65 -13
  23. package/dist/agents/peer-directory.js +90 -25
  24. package/dist/agents/peer-notices.d.ts +1 -1
  25. package/dist/agents/peer-session-drain.d.ts +3 -1
  26. package/dist/agents/peer-session-drain.js +3 -2
  27. package/dist/agents/read-inbox-tool.js +2 -1
  28. package/dist/agents/repair-loop.js +2 -2
  29. package/dist/agents/retain-ledger.d.ts +1 -1
  30. package/dist/agents/roster-store.d.ts +1 -1
  31. package/dist/agents/send-message-tool.d.ts +10 -0
  32. package/dist/agents/send-message-tool.js +37 -8
  33. package/dist/agents/subagent.d.ts +39 -82
  34. package/dist/agents/subagent.js +109 -106
  35. package/dist/agents/tool-filter.d.ts +31 -46
  36. package/dist/agents/tool-filter.js +13 -33
  37. package/dist/agents/verify.d.ts +6 -5
  38. package/dist/agents/verify.js +3 -3
  39. package/dist/brain/anthropic.js +43 -81
  40. package/dist/brain/errors.d.ts +15 -0
  41. package/dist/brain/errors.js +10 -0
  42. package/dist/brain/media-degrade.d.ts +18 -7
  43. package/dist/brain/media-degrade.js +13 -2
  44. package/dist/brain/model-capability.d.ts +37 -0
  45. package/dist/brain/model-capability.js +34 -0
  46. package/dist/brain/model-presets.d.ts +6 -12
  47. package/dist/brain/model-presets.js +1 -6
  48. package/dist/brain/open-responses.js +27 -35
  49. package/dist/brain/openai.js +30 -98
  50. package/dist/brain/provider-dialect.d.ts +39 -3
  51. package/dist/brain/provider-dialect.js +28 -0
  52. package/dist/brain/reasoning-request.d.ts +96 -0
  53. package/dist/brain/reasoning-request.js +174 -0
  54. package/dist/brain/reasoning.d.ts +12 -12
  55. package/dist/brain/reasoning.js +4 -3
  56. package/dist/brain/request-params.d.ts +62 -9
  57. package/dist/brain/request-params.js +42 -7
  58. package/dist/brain/retry.d.ts +1 -1
  59. package/dist/brain/route-adjudicator.d.ts +15 -0
  60. package/dist/brain/route-adjudicator.js +15 -0
  61. package/dist/brain/status-sink.d.ts +20 -0
  62. package/dist/brain/status-sink.js +7 -0
  63. package/dist/brain/stream-engine.js +6 -5
  64. package/dist/brain/stream-shared.d.ts +1 -1
  65. package/dist/core/a2a.d.ts +2 -1
  66. package/dist/core/a2a.js +19 -13
  67. package/dist/core/advisor-verdict.d.ts +120 -0
  68. package/dist/core/advisor-verdict.js +92 -0
  69. package/dist/core/agent-definition.d.ts +17 -8
  70. package/dist/core/allow-entry.d.ts +69 -36
  71. package/dist/core/allow-entry.js +81 -52
  72. package/dist/core/allow-rule-shadow.d.ts +10 -3
  73. package/dist/core/approval-object.d.ts +2 -1
  74. package/dist/core/approval-object.js +6 -6
  75. package/dist/core/ask-origin.d.ts +127 -29
  76. package/dist/core/ask-origin.js +87 -25
  77. package/dist/core/ask-question.d.ts +51 -8
  78. package/dist/core/ask-question.js +12 -7
  79. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  80. package/dist/core/ask-unresolvable-notice.js +16 -2
  81. package/dist/core/auto-compaction.d.ts +11 -8
  82. package/dist/core/auto-compaction.js +4 -2
  83. package/dist/core/auto-mode-arming.d.ts +2 -2
  84. package/dist/core/auto-mode-defaults.d.ts +8 -8
  85. package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
  86. package/dist/core/auto-mode-prompt.d.ts +1 -1
  87. package/dist/core/auto-mode.d.ts +17 -9
  88. package/dist/core/auto-mode.js +9 -6
  89. package/dist/core/background-agent-store.d.ts +3 -3
  90. package/dist/core/canonical-json.d.ts +1 -1
  91. package/dist/core/canonical-json.js +2 -2
  92. package/dist/core/checkpoint-generation.d.ts +53 -0
  93. package/dist/core/checkpoint-generation.js +35 -0
  94. package/dist/core/checkpoint-queries.d.ts +180 -0
  95. package/dist/core/checkpoint-queries.js +272 -0
  96. package/dist/core/checkpoint-requirements.d.ts +19 -4
  97. package/dist/core/checkpoint-requirements.js +8 -14
  98. package/dist/core/checkpoint-store.d.ts +165 -72
  99. package/dist/core/checkpoint-store.js +79 -82
  100. package/dist/core/child-clamp-seats.d.ts +6 -0
  101. package/dist/core/child-clamp-seats.js +3 -16
  102. package/dist/core/compliance.d.ts +2 -2
  103. package/dist/core/context-edit.d.ts +6 -7
  104. package/dist/core/cross-boundary-taint.d.ts +11 -4
  105. package/dist/core/cross-boundary-taint.js +3 -3
  106. package/dist/core/decision-receipt.d.ts +37 -3
  107. package/dist/core/decision-receipt.js +19 -19
  108. package/dist/core/delegation-not-started.d.ts +6 -0
  109. package/dist/core/delegation-not-started.js +17 -0
  110. package/dist/core/effective-path-target.d.ts +1 -1
  111. package/dist/core/engine-attestation.d.ts +93 -0
  112. package/dist/core/engine-attestation.js +70 -0
  113. package/dist/core/engine-capabilities.d.ts +4 -1
  114. package/dist/core/engine-capabilities.js +1 -1
  115. package/dist/core/engine-notice.d.ts +45 -12
  116. package/dist/core/exec-output-tail.d.ts +1 -1
  117. package/dist/core/file-history-retention.d.ts +1 -1
  118. package/dist/core/file-history-store.d.ts +147 -21
  119. package/dist/core/file-history-store.js +58 -32
  120. package/dist/core/gate-fold.d.ts +1 -1
  121. package/dist/core/gate-fold.js +24 -11
  122. package/dist/core/gate-lanes.js +81 -68
  123. package/dist/core/gate-outcome.d.ts +40 -6
  124. package/dist/core/gate-outcome.js +56 -0
  125. package/dist/core/governance-codes.d.ts +17 -3
  126. package/dist/core/governance-codes.js +16 -0
  127. package/dist/core/hands-band.d.ts +1 -1
  128. package/dist/core/hooks.d.ts +21 -20
  129. package/dist/core/hooks.js +3 -1
  130. package/dist/core/host-floor.d.ts +128 -0
  131. package/dist/core/host-floor.js +206 -0
  132. package/dist/core/host-target.d.ts +84 -0
  133. package/dist/core/host-target.js +92 -0
  134. package/dist/core/image-downsample.d.ts +1 -1
  135. package/dist/core/lsp-diagnostics.d.ts +4 -4
  136. package/dist/core/lsp.d.ts +3 -3
  137. package/dist/core/mailbox-store.d.ts +4 -0
  138. package/dist/core/mcp-connection-pool.d.ts +18 -2
  139. package/dist/core/mcp-connection-pool.js +53 -6
  140. package/dist/core/mcp-failure.d.ts +23 -4
  141. package/dist/core/mcp-failure.js +26 -11
  142. package/dist/core/mcp-listing-drift.d.ts +10 -0
  143. package/dist/core/mcp-listing-drift.js +6 -0
  144. package/dist/core/mcp-server-link.d.ts +173 -0
  145. package/dist/core/mcp-server-link.js +127 -0
  146. package/dist/core/mcp-server-spec.d.ts +4 -2
  147. package/dist/core/mcp-session-end.d.ts +26 -0
  148. package/dist/core/mcp-session-end.js +29 -0
  149. package/dist/core/mcp-startup-request.d.ts +17 -0
  150. package/dist/core/mcp-startup-request.js +17 -0
  151. package/dist/core/mcp.d.ts +17 -13
  152. package/dist/core/mcp.js +240 -189
  153. package/dist/core/media-byte-cap.d.ts +1 -1
  154. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  155. package/dist/core/memory-engine/engine.d.ts +9 -9
  156. package/dist/core/memory-engine/engine.js +4 -4
  157. package/dist/core/memory-engine/layout.d.ts +60 -8
  158. package/dist/core/memory-engine/layout.js +65 -6
  159. package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
  160. package/dist/core/memory-engine/tools.js +4 -1
  161. package/dist/core/mode-policy.d.ts +1 -1
  162. package/dist/core/model-seat.d.ts +10 -3
  163. package/dist/core/mods/classic-events.d.ts +67 -0
  164. package/dist/core/mods/classic-events.js +1 -0
  165. package/dist/core/mods/dollar.d.ts +13 -0
  166. package/dist/core/mods/extension-call.d.ts +31 -0
  167. package/dist/core/mods/extension-call.js +43 -0
  168. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  169. package/dist/core/mods/kernel/dispatch.js +140 -69
  170. package/dist/core/mods/kernel/events.d.ts +47 -11
  171. package/dist/core/mods/kernel/events.js +66 -42
  172. package/dist/core/mods/kernel/index.d.ts +4 -4
  173. package/dist/core/mods/kernel/index.js +2 -2
  174. package/dist/core/mods/kernel/receive.d.ts +39 -5
  175. package/dist/core/mods/kernel/receive.js +290 -17
  176. package/dist/core/mods/kernel/registration.d.ts +33 -2
  177. package/dist/core/mods/kernel/registration.js +6 -7
  178. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  179. package/dist/core/mods/kernel/site-rules.js +24 -42
  180. package/dist/core/mods/spec-seats.d.ts +69 -0
  181. package/dist/core/mods/spec-seats.js +114 -0
  182. package/dist/core/mods/stations.d.ts +28 -8
  183. package/dist/core/mods/stations.js +29 -13
  184. package/dist/core/mods/tool-call.d.ts +79 -0
  185. package/dist/core/mods/tool-call.js +152 -0
  186. package/dist/core/namespaced-rule-name.d.ts +44 -24
  187. package/dist/core/namespaced-rule-name.js +50 -43
  188. package/dist/core/output-style.d.ts +1 -1
  189. package/dist/core/param-rule-reach.d.ts +15 -0
  190. package/dist/core/param-rule-reach.js +30 -0
  191. package/dist/core/parent-spec-seat.d.ts +13 -1
  192. package/dist/core/parent-spec-seat.js +6 -0
  193. package/dist/core/park-selfcheck.js +1 -0
  194. package/dist/core/pause-registry.d.ts +16 -5
  195. package/dist/core/pause-registry.js +6 -2
  196. package/dist/core/peer-channel.d.ts +70 -0
  197. package/dist/core/peer-channel.js +1 -0
  198. package/dist/core/permission-rule-consent.d.ts +30 -5
  199. package/dist/core/permission-rule-consent.js +147 -50
  200. package/dist/core/permission-rule-model.d.ts +245 -65
  201. package/dist/core/permission-rule-model.js +421 -107
  202. package/dist/core/permission-rule-org.d.ts +6 -2
  203. package/dist/core/permission-rule-org.js +7 -3
  204. package/dist/core/permission-rule-provider.d.ts +6 -2
  205. package/dist/core/permission-rule-provider.js +41 -11
  206. package/dist/core/permission-rule-store.d.ts +22 -26
  207. package/dist/core/permission-rule-store.js +12 -6
  208. package/dist/core/permission-rule-sync.d.ts +11 -2
  209. package/dist/core/permission-rule-sync.js +11 -3
  210. package/dist/core/permission-rule-syntax.d.ts +5 -4
  211. package/dist/core/permission-rule-syntax.js +2 -2
  212. package/dist/core/permission-rules.d.ts +53 -15
  213. package/dist/core/permission-rules.js +125 -100
  214. package/dist/core/persisted-rule-arms.d.ts +6 -4
  215. package/dist/core/persisted-rule-arms.js +10 -12
  216. package/dist/core/present-plan-tool.js +3 -1
  217. package/dist/core/principal-name.d.ts +20 -0
  218. package/dist/core/principal-name.js +22 -0
  219. package/dist/core/prompt-section-seat.js +4 -6
  220. package/dist/core/protocol-http-auth.d.ts +26 -5
  221. package/dist/core/protocol-http-auth.js +137 -4
  222. package/dist/core/protocol-naming.d.ts +2 -2
  223. package/dist/core/read-only-shell-table.d.ts +1 -1
  224. package/dist/core/read-only-shell.d.ts +1 -1
  225. package/dist/core/retired-keys.d.ts +16 -0
  226. package/dist/core/retired-keys.js +16 -4
  227. package/dist/core/rewrite-rejudge.d.ts +60 -0
  228. package/dist/core/rewrite-rejudge.js +36 -0
  229. package/dist/core/roles.d.ts +34 -3
  230. package/dist/core/roles.js +66 -53
  231. package/dist/core/rule-lane-reads.d.ts +20 -15
  232. package/dist/core/rule-lane-reads.js +45 -17
  233. package/dist/core/rule-offer-read.d.ts +53 -0
  234. package/dist/core/rule-offer-read.js +146 -0
  235. package/dist/core/rule-owner.d.ts +46 -0
  236. package/dist/core/rule-owner.js +29 -0
  237. package/dist/core/runner/advisor-instructions.d.ts +70 -0
  238. package/dist/core/runner/advisor-instructions.js +61 -0
  239. package/dist/core/runner/advisor-tool.d.ts +33 -0
  240. package/dist/core/runner/advisor-tool.js +112 -0
  241. package/dist/core/runner/announce-once-ledger.d.ts +18 -26
  242. package/dist/core/runner/announce-once-ledger.js +19 -46
  243. package/dist/core/runner/approval-feedback.js +6 -3
  244. package/dist/core/runner/assemble-result.d.ts +2 -1
  245. package/dist/core/runner/assemble-result.js +1 -1
  246. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  247. package/dist/core/runner/caller-roster.d.ts +21 -2
  248. package/dist/core/runner/caller-roster.js +38 -0
  249. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  250. package/dist/core/runner/capability-withheld-seat.js +24 -0
  251. package/dist/core/runner/classifier-ladder.d.ts +33 -13
  252. package/dist/core/runner/classifier-ladder.js +15 -14
  253. package/dist/core/runner/compaction-restate.d.ts +10 -6
  254. package/dist/core/runner/compaction-restate.js +9 -3
  255. package/dist/core/runner/construction-doors.js +3 -0
  256. package/dist/core/runner/contracts.d.ts +40 -33
  257. package/dist/core/runner/conversation-segment.d.ts +28 -0
  258. package/dist/core/runner/conversation-segment.js +42 -0
  259. package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
  260. package/dist/core/runner/cross-boundary-lane.js +58 -34
  261. package/dist/core/runner/decide-continuation.d.ts +7 -4
  262. package/dist/core/runner/decide-continuation.js +2 -2
  263. package/dist/core/runner/denial-limit-arms.d.ts +4 -4
  264. package/dist/core/runner/denial-limit-arms.js +1 -1
  265. package/dist/core/runner/derived-route-fallback.d.ts +24 -24
  266. package/dist/core/runner/derived-route-fallback.js +9 -7
  267. package/dist/core/runner/file-history-request.d.ts +18 -0
  268. package/dist/core/runner/file-history-request.js +21 -13
  269. package/dist/core/runner/file-history-restore.d.ts +45 -0
  270. package/dist/core/runner/file-history-restore.js +46 -0
  271. package/dist/core/runner/gate-exit.d.ts +9 -3
  272. package/dist/core/runner/gate-exit.js +11 -5
  273. package/dist/core/runner/image.d.ts +7 -17
  274. package/dist/core/runner/image.js +9 -60
  275. package/dist/core/runner/initial-run-state.js +1 -1
  276. package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
  277. package/dist/core/runner/permission-rule-lanes.js +38 -15
  278. package/dist/core/runner/person-path-rows.d.ts +12 -9
  279. package/dist/core/runner/person-path-rows.js +19 -8
  280. package/dist/core/runner/prepare-advisor.d.ts +63 -0
  281. package/dist/core/runner/prepare-advisor.js +77 -0
  282. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  283. package/dist/core/runner/prepare-ask-lane.js +5 -2
  284. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  285. package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
  286. package/dist/core/runner/prepare-config-doors.d.ts +31 -38
  287. package/dist/core/runner/prepare-config-doors.js +57 -34
  288. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  289. package/dist/core/runner/prepare-defer-classify.js +7 -8
  290. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  291. package/dist/core/runner/prepare-delegation-surface.js +1 -1
  292. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  293. package/dist/core/runner/prepare-file-history.js +41 -73
  294. package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
  295. package/dist/core/runner/prepare-gate-stations.js +12 -8
  296. package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
  297. package/dist/core/runner/prepare-hands-readface.js +15 -14
  298. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
  299. package/dist/core/runner/prepare-inherited-gate.js +8 -6
  300. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  301. package/dist/core/runner/prepare-park-ask.js +12 -12
  302. package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
  303. package/dist/core/runner/prepare-policy-chain.js +68 -81
  304. package/dist/core/runner/prepare-project-context.d.ts +5 -2
  305. package/dist/core/runner/prepare-project-context.js +6 -3
  306. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  307. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  308. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  309. package/dist/core/runner/prepare-prompt-inputs.js +4 -6
  310. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  311. package/dist/core/runner/prepare-protocol-tools.js +5 -4
  312. package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
  313. package/dist/core/runner/prepare-safety-scan.js +8 -23
  314. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  315. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  316. package/dist/core/runner/prepare-task.d.ts +1 -1
  317. package/dist/core/runner/prepare-task.js +41 -35
  318. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
  319. package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
  320. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  321. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  322. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
  323. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  324. package/dist/core/runner/resume-admission.js +1 -1
  325. package/dist/core/runner/resume-apply.js +11 -12
  326. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  327. package/dist/core/runner/resume-claim.d.ts +4 -2
  328. package/dist/core/runner/resume-claim.js +15 -8
  329. package/dist/core/runner/resume-policy-outcome.js +1 -1
  330. package/dist/core/runner/retired-runner-deps.js +2 -1
  331. package/dist/core/runner/rewind-files.d.ts +15 -0
  332. package/dist/core/runner/rewind-files.js +132 -0
  333. package/dist/core/runner/run-attachment-seats.js +2 -2
  334. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  335. package/dist/core/runner/run-brain-sinks.js +4 -2
  336. package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
  337. package/dist/core/runner/run-compaction-machinery.js +2 -12
  338. package/dist/core/runner/run-git-lane.d.ts +1 -0
  339. package/dist/core/runner/run-harness-handlers.js +14 -7
  340. package/dist/core/runner/run-leg.d.ts +1 -1
  341. package/dist/core/runner/run-leg.js +43 -18
  342. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  343. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  344. package/dist/core/runner/run-turn-boundary.d.ts +1 -0
  345. package/dist/core/runner/run-turn-boundary.js +15 -22
  346. package/dist/core/runner/runtask.d.ts +3 -0
  347. package/dist/core/runner/runtask.js +8 -9
  348. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  349. package/dist/core/runner/session-read-file-states.js +28 -0
  350. package/dist/core/runner/session-rule-policy.d.ts +22 -21
  351. package/dist/core/runner/session-rule-policy.js +17 -31
  352. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  353. package/dist/core/runner/shell-env-withheld.js +51 -0
  354. package/dist/core/runner/side-call-account.d.ts +32 -8
  355. package/dist/core/runner/side-call-account.js +23 -1
  356. package/dist/core/runner/skills-seat.js +6 -2
  357. package/dist/core/runner/stream-settle-backstop.js +1 -1
  358. package/dist/core/runner/strict-output-schema.d.ts +1 -1
  359. package/dist/core/runner/sub-agent-deny-lists.js +4 -6
  360. package/dist/core/runner/synthetic-tools.d.ts +16 -13
  361. package/dist/core/runner/synthetic-tools.js +8 -3
  362. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  363. package/dist/core/runner/tool-disclosure.js +3 -4
  364. package/dist/core/runner/tool-end-body.d.ts +1 -1
  365. package/dist/core/runner/tool-end-body.js +10 -9
  366. package/dist/core/runner/tool-face-overlay.d.ts +2 -1
  367. package/dist/core/runner/tool-face-overlay.js +17 -1
  368. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  369. package/dist/core/runner/tool-not-executed.js +11 -0
  370. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  371. package/dist/core/runner/tool-occurrence.js +7 -0
  372. package/dist/core/runner/tool-progress-lane.d.ts +2 -2
  373. package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
  374. package/dist/core/runner/turn-attachments.d.ts +91 -80
  375. package/dist/core/runner/turn-attachments.js +62 -37
  376. package/dist/core/runner-deps.d.ts +42 -42
  377. package/dist/core/runtime-caps.d.ts +4 -4
  378. package/dist/core/safety-axis-vocab.d.ts +6 -4
  379. package/dist/core/safety-axis-vocab.js +6 -5
  380. package/dist/core/safety-merge-corpus.js +26 -2
  381. package/dist/core/same-plain-value.d.ts +40 -0
  382. package/dist/core/same-plain-value.js +49 -0
  383. package/dist/core/scheduler.d.ts +1 -1
  384. package/dist/core/secret-env.d.ts +26 -3
  385. package/dist/core/secret-env.js +44 -8
  386. package/dist/core/select-model.js +3 -3
  387. package/dist/core/sensitive-path-policy.d.ts +1 -1
  388. package/dist/core/sensitive-path-policy.js +1 -1
  389. package/dist/core/session-policy-store.d.ts +102 -35
  390. package/dist/core/session-policy-store.js +210 -48
  391. package/dist/core/session-reconcile.d.ts +2 -2
  392. package/dist/core/session-store.d.ts +106 -37
  393. package/dist/core/session-store.js +165 -91
  394. package/dist/core/session.d.ts +101 -57
  395. package/dist/core/session.js +53 -0
  396. package/dist/core/shared-memory/tools.js +3 -1
  397. package/dist/core/shared-memory/types.d.ts +1 -1
  398. package/dist/core/shell-read-silence.d.ts +11 -12
  399. package/dist/core/shell-read-silence.js +9 -5
  400. package/dist/core/shell-run-candidates.js +3 -1
  401. package/dist/core/shell-wrapper-projection.js +1 -1
  402. package/dist/core/shell-wrapper-table.d.ts +14 -7
  403. package/dist/core/shell-wrapper-table.js +5 -4
  404. package/dist/core/side-query.d.ts +10 -0
  405. package/dist/core/side-query.js +15 -1
  406. package/dist/core/skill-grant.d.ts +7 -2
  407. package/dist/core/skill-grant.js +5 -0
  408. package/dist/core/skills-directory.js +6 -2
  409. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  410. package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
  411. package/dist/core/store-contracts/file-history-store-contract.js +74 -4
  412. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  413. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  414. package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
  415. package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
  416. package/dist/core/store-contracts/session-repo-contract.js +176 -0
  417. package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
  418. package/dist/core/store-contracts/session-store-contract.js +361 -51
  419. package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
  420. package/dist/core/stub-env.d.ts +2 -0
  421. package/dist/core/stub-env.js +1 -0
  422. package/dist/core/surrogate-safe-slice.d.ts +3 -3
  423. package/dist/core/synthetic-read-verdict.js +3 -3
  424. package/dist/core/task-event.d.ts +42 -8
  425. package/dist/core/task-notification.d.ts +19 -15
  426. package/dist/core/task-registry-agent.d.ts +4 -4
  427. package/dist/core/task-registry-shared.d.ts +4 -4
  428. package/dist/core/task-registry-shared.js +1 -0
  429. package/dist/core/task-registry.d.ts +13 -4
  430. package/dist/core/task-registry.js +14 -2
  431. package/dist/core/task-result.d.ts +21 -3
  432. package/dist/core/task-spec.d.ts +69 -64
  433. package/dist/core/task-stream.d.ts +6 -6
  434. package/dist/core/task-tool-shape.d.ts +4 -4
  435. package/dist/core/tighten-task-spec.d.ts +1 -1
  436. package/dist/core/tighten-task-spec.js +2 -1
  437. package/dist/core/tool-catalog-entries.d.ts +36 -2
  438. package/dist/core/tool-catalog-entries.js +69 -43
  439. package/dist/core/tool-check-reading.d.ts +11 -0
  440. package/dist/core/tool-check-reading.js +11 -6
  441. package/dist/core/tool-conformance.js +1 -0
  442. package/dist/core/tool-errors.d.ts +2 -2
  443. package/dist/core/tool-face-reader.js +5 -3
  444. package/dist/core/tool-face.d.ts +21 -2
  445. package/dist/core/tool-face.js +1 -1
  446. package/dist/core/tool-model-gate.d.ts +5 -5
  447. package/dist/core/tool-name-aliases.d.ts +29 -8
  448. package/dist/core/tool-name-aliases.js +22 -4
  449. package/dist/core/tool-name-readings.d.ts +10 -43
  450. package/dist/core/tool-name-readings.js +2 -11
  451. package/dist/core/tool-policy.d.ts +85 -196
  452. package/dist/core/tool-policy.js +150 -175
  453. package/dist/core/tool-registry.d.ts +14 -7
  454. package/dist/core/tool-registry.js +17 -7
  455. package/dist/core/tool-result-store.js +5 -1
  456. package/dist/core/tool-roster.d.ts +57 -33
  457. package/dist/core/tool-roster.js +56 -68
  458. package/dist/core/tool-spec-members.js +8 -3
  459. package/dist/core/tool-spec.d.ts +53 -31
  460. package/dist/core/tools.js +51 -10
  461. package/dist/core/trace.d.ts +6 -2
  462. package/dist/core/types.d.ts +1 -1
  463. package/dist/core/untrusted-egress.d.ts +1 -1
  464. package/dist/core/untrusted-text.d.ts +1 -1
  465. package/dist/core/user-attachment.d.ts +8 -1
  466. package/dist/core/user-attachment.js +64 -4
  467. package/dist/core/warm-resume.d.ts +1 -1
  468. package/dist/core/wiring-manifest.d.ts +58 -0
  469. package/dist/core/wiring-manifest.js +14 -5
  470. package/dist/core/workflow-journal-store.d.ts +62 -0
  471. package/dist/core/workflow-journal-store.js +78 -2
  472. package/dist/core/workflow-run-store.d.ts +6 -0
  473. package/dist/core/workflow-run-store.js +2 -0
  474. package/dist/engine/compaction/compaction.d.ts +9 -9
  475. package/dist/engine/compaction/compaction.js +3 -2
  476. package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
  477. package/dist/engine/execution-env/node-execution-env.js +54 -24
  478. package/dist/engine/harness/agent-harness.d.ts +39 -9
  479. package/dist/engine/harness/agent-harness.js +87 -33
  480. package/dist/engine/harness/types.d.ts +58 -9
  481. package/dist/engine/harness/types.js +12 -1
  482. package/dist/engine/llm/types.d.ts +36 -19
  483. package/dist/engine/llm/validation.d.ts +4 -1
  484. package/dist/engine/llm/validation.js +13 -1
  485. package/dist/engine/loop/agent-loop.d.ts +23 -1
  486. package/dist/engine/loop/agent-loop.js +26 -34
  487. package/dist/engine/loop/types.d.ts +31 -19
  488. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  489. package/dist/engine/session/memory-repo.d.ts +18 -12
  490. package/dist/engine/session/memory-repo.js +24 -9
  491. package/dist/engine/session/parent-chain-guard.d.ts +3 -2
  492. package/dist/engine/session/parent-chain-guard.js +1 -1
  493. package/dist/engine/session/repo-utils.d.ts +32 -3
  494. package/dist/engine/session/repo-utils.js +50 -5
  495. package/dist/index.d.ts +47 -23
  496. package/dist/index.js +35 -17
  497. package/dist/internal/harness-types.d.ts +1 -1
  498. package/dist/internal/harness.d.ts +3 -3
  499. package/dist/internal/harness.js +2 -2
  500. package/dist/internal/llm.d.ts +2 -2
  501. package/dist/internal/llm.js +1 -1
  502. package/dist/orchestration/goal.js +2 -2
  503. package/dist/orchestration/run-workflow-tool.d.ts +8 -6
  504. package/dist/orchestration/run-workflow-tool.js +10 -6
  505. package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
  506. package/dist/orchestration/workflow-types.d.ts +18 -0
  507. package/dist/orchestration/workflow-types.js +6 -0
  508. package/dist/orchestration/workflow.d.ts +5 -13
  509. package/dist/orchestration/workflow.js +57 -49
  510. package/dist/prompt-assembly/artifact.d.ts +2 -2
  511. package/dist/prompt-assembly/artifact.js +5 -3
  512. package/dist/prompt-assembly/assemble.d.ts +3 -2
  513. package/dist/prompt-assembly/assemble.js +1 -1
  514. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  515. package/dist/prompt-assembly/catalog/schema.js +34 -2
  516. package/dist/prompt-assembly/catalog/sections.js +0 -1
  517. package/dist/prompt-assembly/composer.d.ts +3 -1
  518. package/dist/prompt-assembly/composer.js +1 -1
  519. package/dist/prompt-assembly/event-registry.js +2 -0
  520. package/dist/prompt-assembly/overlay.js +3 -3
  521. package/dist/prompt-assembly/renderers.d.ts +1 -1
  522. package/dist/prompt-assembly/renderers.js +0 -3
  523. package/dist/prompt-assembly/role-base.d.ts +15 -0
  524. package/dist/prompt-assembly/role-base.js +9 -0
  525. package/dist/prompt-assembly/select.d.ts +39 -14
  526. package/dist/prompt-assembly/select.js +47 -16
  527. package/dist/prompt-assembly/sugar.d.ts +17 -11
  528. package/dist/prompt-assembly/sugar.js +8 -3
  529. package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
  530. package/dist/prompt-assembly/tool-catalog.js +117 -4
  531. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  532. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  533. package/dist/prompt-assembly/types.d.ts +0 -7
  534. package/dist/prompts/default.d.ts +14 -14
  535. package/dist/scenarios/full-body.d.ts +15 -15
  536. package/dist/scenarios/full-body.js +4 -3
  537. package/dist/shell/lex.js +10 -1
  538. package/dist/stores/file/adoption/adopt.d.ts +4 -3
  539. package/dist/stores/file/adoption/adopt.js +27 -33
  540. package/dist/stores/file/adoption/marker.d.ts +6 -13
  541. package/dist/stores/file/adoption/marker.js +9 -17
  542. package/dist/stores/file/checkpoint-store.d.ts +24 -0
  543. package/dist/stores/file/checkpoint-store.js +45 -7
  544. package/dist/stores/file/file-history-store.d.ts +20 -19
  545. package/dist/stores/file/file-history-store.js +157 -141
  546. package/dist/stores/file/fs-atomic.d.ts +15 -0
  547. package/dist/stores/file/fs-atomic.js +89 -14
  548. package/dist/stores/file/index.d.ts +1 -1
  549. package/dist/stores/file/index.js +2 -1
  550. package/dist/stores/file/mailbox-store.d.ts +3 -0
  551. package/dist/stores/file/mailbox-store.js +3 -1
  552. package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
  553. package/dist/stores/file/permission-rule-adopt.js +18 -18
  554. package/dist/stores/file/permission-rule-store.d.ts +18 -2
  555. package/dist/stores/file/permission-rule-store.js +31 -18
  556. package/dist/stores/file/session-policy-store.d.ts +3 -3
  557. package/dist/stores/file/session-store.d.ts +54 -16
  558. package/dist/stores/file/session-store.js +114 -85
  559. package/dist/stores/file/workflow-journal-store.d.ts +10 -4
  560. package/dist/stores/file/workflow-journal-store.js +28 -13
  561. package/dist/tools/artifact/artifact-text.d.ts +1 -1
  562. package/dist/tools/artifact/artifact-tool.js +5 -3
  563. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  564. package/dist/tools/fs/bash-program-position.js +56 -9
  565. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
  566. package/dist/tools/fs/fs-bash.d.ts +2 -2
  567. package/dist/tools/fs/fs-bash.js +8 -6
  568. package/dist/tools/fs/fs-glob.d.ts +86 -0
  569. package/dist/tools/fs/fs-glob.js +226 -0
  570. package/dist/tools/fs/fs-read.js +14 -14
  571. package/dist/tools/fs/fs-search-tools.js +7 -7
  572. package/dist/tools/fs/fs-shared.d.ts +8 -8
  573. package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
  574. package/dist/tools/fs/notebook.d.ts +2 -2
  575. package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
  576. package/dist/tools/fs/pattern-kill-guard.js +397 -0
  577. package/dist/tools/fs/pdf.d.ts +9 -6
  578. package/dist/tools/fs/pdf.js +3 -3
  579. package/dist/tools/fs/program-read-model.d.ts +57 -7
  580. package/dist/tools/fs/program-read-model.js +11 -1
  581. package/dist/tools/fs/program-read-model.rows.js +78 -21
  582. package/dist/tools/fs/read-deny-home.js +3 -2
  583. package/dist/tools/fs/read-deny.d.ts +29 -7
  584. package/dist/tools/fs/read-deny.js +63 -22
  585. package/dist/tools/fs/removal-targets.d.ts +18 -8
  586. package/dist/tools/fs/removal-targets.js +47 -20
  587. package/dist/tools/fs/safety.d.ts +9 -9
  588. package/dist/tools/fs/search.d.ts +16 -6
  589. package/dist/tools/fs/search.js +20 -26
  590. package/dist/tools/fs/shell-read-argv.js +89 -12
  591. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  592. package/dist/tools/fs/shell-read-bindings.js +41 -0
  593. package/dist/tools/fs/shell-read-check.js +12 -20
  594. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  595. package/dist/tools/fs/shell-read-environment.js +3 -2
  596. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  597. package/dist/tools/fs/shell-read-establish.js +19 -20
  598. package/dist/tools/fs/shell-read-judge.d.ts +4 -0
  599. package/dist/tools/fs/shell-read-judge.js +5 -2
  600. package/dist/tools/fs/shell-read-plan.js +24 -16
  601. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  602. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  603. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  604. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  605. package/dist/tools/fs/shell-reentry-text.js +40 -2
  606. package/dist/tools/loop-tick.d.ts +2 -2
  607. package/dist/tools/scheduler-tools.js +5 -1
  608. package/dist/tools/task-list.d.ts +7 -7
  609. package/dist/tools/task-list.js +5 -1
  610. package/dist/tools/todo.js +65 -64
  611. package/dist/tools/web.d.ts +20 -15
  612. package/dist/tools/web.js +55 -69
  613. package/dist/tools/worktree.d.ts +3 -3
  614. package/dist/tools/worktree.js +3 -1
  615. package/package.json +1 -1
  616. package/test/export-surface.snapshot.json +5894 -5638
  617. package/wire-changes/core@7.55.0.json +3318 -0
  618. package/wire-changes/core@7.56.0.json +3891 -0
  619. package/wire-changes/mods-kernel@7.56.0.json +303 -0
  620. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
  621. package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
@@ -2,12 +2,13 @@ export { StoredSession } from "../internal/harness.js";
2
2
  export type { Session } from "../internal/harness.js";
3
3
  export { InMemorySessionRepo, InMemorySessionStorage, uuidv7, validateEntriesForImport, StreamingImportValidator, } from "../internal/harness.js";
4
4
  export { BaseSessionStorage, leafIdAfterEntry, } from "../internal/harness.js";
5
- export type { SessionStorage, SessionRepo, SessionMetadata, SessionTreeEntry, } from "../internal/harness.js";
5
+ export type { SessionStorage, SessionRepo, SessionRow, SessionMetadata, SessionTreeEntry, } from "../internal/harness.js";
6
6
  export { SessionError } from "../internal/harness.js";
7
7
  export type { SessionWriteOptions } from "../internal/harness.js";
8
8
  import type { Session } from "../internal/harness.js";
9
- import type { SessionTreeEntry } from "../internal/harness.js";
9
+ import type { SessionHead, SessionTreeEntry } from "../internal/harness.js";
10
10
  export type { SessionPlacementRecord } from "../internal/harness.js";
11
+ export type { SessionHead } from "../internal/harness.js";
11
12
  /** True when `err` is a session optimistic-lock conflict (a concurrent writer won the branch leaf). Both
12
13
  * halves read what a HOST `SessionStorage` threw, so both are guarded — unreadable is not a conflict,
13
14
  * never a raise inside the classify-and-rethrow guard. The class test is KEPT: widening the verdict to
@@ -54,7 +55,7 @@ export interface AcquiredSession {
54
55
  }
55
56
  /**
56
57
  * A lightweight, read-only projection of one session for a `/resume` list (shell K-5 — re-attach without an
57
- * N+1 walk). Returned in bulk by {@link SessionStore.list}, newest-first by `lastActiveAt` by convention.
58
+ * N+1 walk). Returned in pages by {@link SessionStore.list}, newest-first by `(lastActiveAt, sessionId)`.
58
59
  * `lastTaskId` is the engine's term for what the service/wire surfaces as the session's **`lastRunId`** — the
59
60
  * most recent task run on this session, so a shell re-attaches in ONE hop.
60
61
  *
@@ -71,7 +72,10 @@ export interface SessionStoreSummary {
71
72
  /** When the session was created ({@link SessionMetadata.createdAt}, ISO string); absent when the backend's
72
73
  * cache view doesn't carry it. */
73
74
  createdAt?: string;
74
- /** Epoch ms the session was last acquired / touched / ran — the newest-first sort key for "recent sessions". */
75
+ /** Epoch ms of the session's newest activity the store RECORDS — its writes and its {@link SessionStore.touch}es (the Runner touches
76
+ * a session as each run ends) — the newest-first sort key for "recent sessions". Recorded, never what one process saw: a restart,
77
+ * another replica or a dropped cache reads the same time, and only a later activity moves it. An acquire that writes nothing is not
78
+ * activity. */
75
79
  lastActiveAt: number;
76
80
  /** The most recent task run on this session (core's `taskId`; the service projects it as `lastRunId`).
77
81
  * Absent until a task has run on the session (recorded via {@link SessionStore.noteTaskRun}). */
@@ -105,6 +109,54 @@ export interface SessionStoreSummary {
105
109
  * predate the fork. The durable source of truth is the repo's persisted metadata. */
106
110
  forkedFrom?: string;
107
111
  }
112
+ /** The page bounds of {@link SessionStore.list}: a query without `limit` reads `default` rows; an explicit `limit` is an integer in
113
+ * 1..`max`. */
114
+ export declare const SESSION_LIST_LIMITS: Readonly<{
115
+ readonly default: 50;
116
+ readonly max: 1000;
117
+ }>;
118
+ /**
119
+ * What {@link SessionStore.list} is asked for. No query, or `{}`, is the unfiltered list — every owner's rows, unowned ones included —
120
+ * read from its first page, at most {@link SESSION_LIST_LIMITS}`.default` rows; a caller that wants every row pages with `after`.
121
+ * A store may define extension filters of its own (members beside these, e.g. a text search); a filter applies before the page is
122
+ * cut, so `after` and `limit` page the filtered list. A store refuses a member it does not read — an unread filter would list rows the
123
+ * caller asked to exclude.
124
+ */
125
+ export interface SessionListQuery {
126
+ /** Only the rows this owner owns (exact match; a principal name, so a blank string is refused, never an owner of its own). Absent = no owner filter. */
127
+ owner?: string;
128
+ /** With `owner`: the unowned rows (owner `null`) too. A member of the owner filter only — given without `owner` it is refused, so a
129
+ * query that lost its owner never widens into every owner's list. */
130
+ includeUnowned?: boolean;
131
+ /** The keyset cursor — the `lastActiveAt` and `sessionId` of the last row of the previous page: only rows after it in the list's
132
+ * order are read (a smaller `lastActiveAt`, or the same one with a smaller `sessionId`). */
133
+ after?: {
134
+ lastActiveAt: number;
135
+ sessionId: string;
136
+ };
137
+ /** At most this many rows, an integer in 1..{@link SESSION_LIST_LIMITS}`.max`; absent = the default. Ask for one more than a page
138
+ * shows to learn whether another page exists. */
139
+ limit?: number;
140
+ }
141
+ /** {@link readSessionListQuery}'s answer: the query's members as read, the defaults filled in. */
142
+ export interface SessionListQueryReading {
143
+ readonly owner?: string;
144
+ readonly includeUnowned: boolean;
145
+ readonly after?: {
146
+ readonly lastActiveAt: number;
147
+ readonly sessionId: string;
148
+ };
149
+ readonly limit: number;
150
+ /** The values of the extension members the reading store declared and the query carries. */
151
+ readonly extensions: Readonly<Record<string, unknown>>;
152
+ }
153
+ /**
154
+ * The one reading of a {@link SessionListQuery}, for every store that implements {@link SessionStore.list}: `raw` read by the
155
+ * engine's receipt law (a plain object, each member read once), each member judged, the default limit filled in. `extensions` names
156
+ * the extension members the calling store reads (none for a store without extension filters); any other member is refused. A bad
157
+ * value is refused, never mapped to a default: `config.invalid_argument`.
158
+ */
159
+ export declare function readSessionListQuery(raw: unknown, extensions?: readonly string[]): SessionListQueryReading;
108
160
  /**
109
161
  * The session lifecycle/caching layer the {@link Runner} depends on.
110
162
  *
@@ -113,8 +165,12 @@ export interface SessionStoreSummary {
113
165
  * a session from the persisted event log so any stateless runner instance can resume it.
114
166
  *
115
167
  * Implementations must be safe under concurrent `acquire` of the same id (return one session).
168
+ *
169
+ * `S` / `Q` are the store's list projection and query: a backend whose list carries more per row (or filters by more) extends
170
+ * {@link SessionStoreSummary} / {@link SessionListQuery} and implements `SessionStore<Its summary, Its query>` — still assignable
171
+ * wherever a `SessionStore` is taken.
116
172
  */
117
- export interface SessionStore {
173
+ export interface SessionStore<S extends SessionStoreSummary = SessionStoreSummary, Q extends SessionListQuery = SessionListQuery> {
118
174
  /**
119
175
  * design/173 §2.3 — durability declaration (see
120
176
  * {@link import("./checkpoint-store.js").StoreDurability}): whether sessions this store accepts
@@ -141,7 +197,7 @@ export interface SessionStore {
141
197
  * Declaring this commits the store to the placement obligations:
142
198
  * 1. a placed session enjoys the declared durability (`acquire(id, {requireExisting:true})`
143
199
  * reaches it after a restart when `"durable"`);
144
- * 2. placed sessions do NOT appear on host enumeration faces (`list()` and every deployment
200
+ * 2. placed sessions do NOT appear on host enumeration faces (`list` and every deployment
145
201
  * listing path — restart-stable);
146
202
  * 3. acquire semantics for sessions WITHOUT a placement are byte-unchanged;
147
203
  * 4. `release(placedId)` is a REAL deletion (durable history included) — the joint reap's
@@ -170,7 +226,8 @@ export interface SessionStore {
170
226
  requireExisting?: boolean;
171
227
  placement?: SessionPlacement;
172
228
  }): Promise<AcquiredSession>;
173
- /** Mark a session recently active (resets idle TTL where applicable). May be async for durable stores. */
229
+ /** Mark a session recently active: resets the idle TTL where applicable, and is activity the {@link list} order records. May be
230
+ * async for durable stores. */
174
231
  touch(sessionId: string): void | Promise<void>;
175
232
  /** Drop a session from the live set (e.g. a throwaway task). Durable history may be retained by the backend. */
176
233
  release(sessionId: string): Promise<void>;
@@ -214,12 +271,16 @@ export interface SessionStore {
214
271
  */
215
272
  noteTaskRun?(sessionId: string, taskId: string, runId?: string): void | Promise<void>;
216
273
  /**
217
- * Enumerate known sessions as lightweight {@link SessionStoreSummary} projections (newest-first by
218
- * `lastActiveAt`) so a shell's `/resume` lists sessions + their last run in ONE call. **Optional**: the
219
- * in-memory `TtlSessionStore` lists its live cache; a durable backend lists persisted sessions. A store
220
- * that cannot enumerate omits this (the shell then has no session-list affordance — honest degrade).
274
+ * One page of the store's sessions as lightweight {@link SessionStoreSummary} projections, so a shell's `/resume` lists sessions +
275
+ * their last run in ONE call: every session ROW the store holds — what a restart still finds, not only what this process has
276
+ * cached — that the query admits, newest-first by `(lastActiveAt, sessionId)` (both descending; equal times order by id), at most
277
+ * `limit` rows after the `after` cursor (see {@link SessionListQuery}; read it with {@link readSessionListQuery}, whose refusals are
278
+ * this face's). Placed sessions are never listed (placement obligation 2). Reading the list is not activity, and a row's time only
279
+ * moves forward, so paging with `after` never reads a row twice — a row written or touched between two pages moves ahead of the
280
+ * cursor, where later pages do not read it (a fresh first page shows it). **Optional**: a store that cannot enumerate omits this (the
281
+ * shell then has no session-list affordance — honest degrade).
221
282
  */
222
- list?(): Promise<SessionStoreSummary[]>;
283
+ list?(query?: Q): Promise<S[]>;
223
284
  /**
224
285
  * Subagent transcript persistence — enumerate the PLACED partition (the input to the joint reap's
225
286
  * partition leg: sessions whose owning agent row is gone are the orphan shape it collects).
@@ -243,59 +304,42 @@ export interface SessionStore {
243
304
  * an in-memory repo forks IN-PROCESS yet loses the copy on restart, while a durable repo (file/pg) makes the
244
305
  * fork survive restart/replica. **Capability presence ≠ durability** — a cross-replica consumer (design/114
245
306
  * warm-resume) MUST wire a durable repo; core cannot verify durability, only fail-loud on a missing source at
246
- * fork time (returns `null`). `owner` (if given) scopes the new session for multi-tenant stores, and a store that
247
- * also implements {@link register} MUST make the fork's ownership row agree with it — a fork COPIES the source's
248
- * history, so the copy must never be weaker than the original: with no `owner` argument the fork inherits the
249
- * SOURCE's row (a source with no row mints none, keeping the authorizer's claim branch intact). An EXPLICIT
250
- * `owner: null` follows the same inheritance, deliberately: "anonymous" on a copy of an OWNED source would
251
- * make that history claimable by anyone — a downgrade this face exists to prevent — so `null` only takes
252
- * effect when the source itself is unowned/anonymous. MUST copy the COMMITTED leaf (an in-flight
253
- * uncommitted turn of an active source is not included — a fork is a snapshot at the fork point).
307
+ * fork time (returns `null`). The fork is a new row whose owner cell is recorded in the write that creates it — a fork
308
+ * COPIES the source's history, so the copy is never weaker than the original: with no `owner` argument, or an
309
+ * EXPLICIT `null`, the fork records the SOURCE row's owner ("anonymous" on a copy of an OWNED source would admit
310
+ * every principal to that history — a downgrade this face exists to prevent); an owner string (a principal name — a blank
311
+ * string is refused, with no row left behind) records that owner.
312
+ * MUST copy the COMMITTED leaf (an in-flight uncommitted turn of an active source is not included — a fork is a
313
+ * snapshot at the fork point).
254
314
  */
255
315
  fork?(sourceId: string, owner?: string | null): Promise<string | null>;
256
316
  /**
257
- * Session-ownership capability face (multi-tenant admission — the deployment's authorizer probes for
258
- * BOTH methods and runs its owner gate only when they exist; a store without them forces the
259
- * deployment into its fail-closed arm, refusing caller-supplied session ids under multi-tenancy).
317
+ * The row's {@link SessionHead} for `sessionId` — owner, occupant and active leaf — in ONE read of the row, never assembled from
318
+ * separate reads (a delete and re-create of the id between two reads would pair one generation's owner with the next one's
319
+ * occupant). `undefined` = no row for this id. A rejection is a read fault, not an answer.
260
320
  *
261
- * `ownerOf` is THREE-state and the states must never collapse:
262
- * - `undefined` — the session has NO ownership row (unknown id): the authorizer claims it for the
263
- * calling principal (or 404s under require-existing).
264
- * - `null` — the session EXISTS and is anonymous (unowned): admitted (single-tenant/dev sharing).
265
- * - `string` — owned: a different principal is refused.
266
- * Collapsing `undefined` into `null` breaks the gate in both directions at once (an unknown id
267
- * reads as an admissible anonymous session; an anonymous session reads as claimable).
321
+ * The BY-ID read, for a reader that did not acquire the session (hosts, a deployment's authorizer). A store that has it hands out,
322
+ * from `acquire`, only a session of the occupant it names — a cached view of an occupant the row no longer holds (the row deleted,
323
+ * or deleted and created again, through another writer — on the File lane a writer in another process too) is not served — so its `incarnation` and the acquired session's metadata agree (the kit pins both); a run's own memory seat reads the session it ACQUIRED instead, never this lookup. The owner is a cell of the row: `null` = anonymous (admitted to every principal) — a row created
324
+ * with no owner (`acquire` names none), or a row written before the cell existed; a principal name = owned (a cell holding a blank string
325
+ * names nobody and is a read fault, never an owner). A placed row carries the owner its placing write recorded: the bundled stores'
326
+ * placing write names none (`acquire`'s options and {@link SessionPlacement} carry no principal), so their placed rows read `null`; a
327
+ * store's own placing write may record a principal (e.g. a delegation tree's owner), and a reader takes the row's owner as it reads. **Optional**: absent ⇒ no by-id read,
328
+ * and a deployment's authorizer, which needs this and {@link register} together, takes its fail-closed arm.
268
329
  */
269
- ownerOf?(sessionId: string): Promise<string | null | undefined>;
330
+ headOf?(sessionId: string): Promise<SessionHead | undefined>;
270
331
  /**
271
- * Idempotent ownership upsert, FIRST-WRITE-WINS and atomic: the first registered owner is kept,
272
- * later calls neither overwrite nor throw. Deliberately makes NO authorization decision — the
273
- * caller re-reads {@link ownerOf} after registering and judges there (which is exactly why the
274
- * first-write-wins read-back must be atomic: a concurrent loser has to SEE the winner's owner on
275
- * re-read, or it silently attaches to the winner's session). In-memory synchronous writes satisfy
276
- * this trivially; durable implementations need a real uniqueness guarantee, not read-then-write.
277
- * The ownership row must never expire BEFORE its session (a live session reading as `undefined`
278
- * would be re-claimable by anyone); same-lifetime or longer both satisfy the contract — so a store that
279
- * deletes the row when it deletes the history must gate that on the history delete having SUCCEEDED.
280
- * An implementation must never store a value that {@link ownerOf} reads back as `undefined` (a row that
281
- * EXISTS yet reads as "no row" is permanently claimable and never ownable): a FIRST write whose `owner` is
282
- * neither a string nor `null` is refused loudly instead — the no-overwrite-no-throw rule above governs
283
- * LATER calls, which stay silent no-ops whatever they carry.
332
+ * The owner write of the ownership pair ({@link headOf} + this). On an id with NO row it creates the row — an ordinary row, no
333
+ * placement — recording `owner` in the creating write, first-write-wins and atomic: of two concurrent first registers, both
334
+ * callers' re-reads see the same winner (durable implementations need a real uniqueness guarantee, not read-then-write). On an id
335
+ * whose row EXISTS it does nothing, whatever it carries — an owned row, an anonymous row, a row `acquire` created (which
336
+ * records `null`), or a placed row (the owner its placing write recorded) stays as it is: a row's owner is recorded by the write that
337
+ * creates it and `register` never changes it; there is no claiming of an existing row. A FIRST write whose `owner` is neither a principal
338
+ * name (a string with a visible character, no control or separator character, and no format character but a joiner) nor `null` is refused loudly and leaves no row; a later call stays a silent no-op
339
+ * whatever it carries. Deliberately makes NO
340
+ * authorization decision — the caller re-reads {@link headOf} and judges there. The owner lives and dies with its row.
284
341
  */
285
342
  register?(sessionId: string, owner: string | null): Promise<void>;
286
- /**
287
- * WHICH occupant holds `sessionId` now: the session row's {@link SessionMetadata.incarnation} cell,
288
- * minted by the repo when the row came into existence and stable for the row's whole life (restarts,
289
- * cache eviction, replicas). `undefined` = UNKNOWN — no row for this id, or a row written before the
290
- * cell existed; a reader treats unknown as "cannot tell occupants apart", never as a different one.
291
- * A rejection is a read fault, not an answer.
292
- *
293
- * The BY-ID read, for a reader that did not acquire the session (hosts; this read and the metadata of
294
- * a session `acquire` hands back must agree — the incarnation kit pins both). A run's own memory seat
295
- * reads the session it ACQUIRED instead, never a second lookup: the cached view `acquire` returns and
296
- * a by-id read can answer two different rows. **Optional**: absent ⇒ no by-id read.
297
- */
298
- incarnationOf?(sessionId: string): Promise<string | undefined>;
299
343
  /** Number of live/cached sessions (best-effort). */
300
344
  readonly size: number;
301
345
  /** Release resources (timers, connections). Best-effort; must not throw. */
@@ -4,9 +4,62 @@ export { BaseSessionStorage, leafIdAfterEntry, } from "../internal/harness.js";
4
4
  export { SessionError } from "../internal/harness.js";
5
5
  import { SessionError } from "../internal/harness.js";
6
6
  import { readMember, thrownIs } from "./thrown-value.js";
7
+ import { receiptRefusal, receiveOwnProperties } from "./own-property-receipt.js";
8
+ import { principalNameFault, principalNameOf } from "./principal-name.js";
7
9
  export function isSessionConflict(err) {
8
10
  return thrownIs(err, SessionError) && readMember(err, "code") === "conflict";
9
11
  }
12
+ export const SESSION_LIST_LIMITS = Object.freeze({ default: 50, max: 1000 });
13
+ const LIST_QUERY_MEMBERS = ["owner", "includeUnowned", "after", "limit"];
14
+ export function readSessionListQuery(raw, extensions = []) {
15
+ if (raw === undefined)
16
+ return { includeUnowned: false, limit: SESSION_LIST_LIMITS.default, extensions: {} };
17
+ if (typeof raw !== "object" || raw === null)
18
+ throw receiptRefusal(`SessionStore.list: the query must be an object, got ${raw === null ? "null" : typeof raw}`);
19
+ const got = receiveOwnProperties(raw, { subject: "SessionListQuery", unit: "member", moment: "at SessionStore.list" });
20
+ const extended = {};
21
+ for (const name of Object.keys(got)) {
22
+ if (LIST_QUERY_MEMBERS.includes(name))
23
+ continue;
24
+ if (!extensions.includes(name))
25
+ throw receiptRefusal(`SessionStore.list: this store does not filter by "${name}" — refused rather than listing the rows that filter would exclude`);
26
+ extended[name] = got[name];
27
+ }
28
+ const { owner: ownerGiven, includeUnowned, after, limit } = got;
29
+ const owner = ownerGiven === undefined ? undefined : principalNameOf(ownerGiven);
30
+ if (ownerGiven !== undefined && owner === undefined) {
31
+ throw receiptRefusal(`SessionListQuery.owner must be a principal name (a string with a visible character, no control or separator character, and no format character but a joiner) when present, got ${principalNameFault(ownerGiven)}`);
32
+ }
33
+ if (includeUnowned !== undefined && typeof includeUnowned !== "boolean")
34
+ throw receiptRefusal(`SessionListQuery.includeUnowned must be a boolean when present, got ${typeof includeUnowned}`);
35
+ if (includeUnowned !== undefined && owner === undefined)
36
+ throw receiptRefusal("SessionListQuery.includeUnowned is a member of the owner filter and was given without owner — refused rather than read as every owner's list");
37
+ if (limit !== undefined && !(typeof limit === "number" && Number.isSafeInteger(limit) && limit >= 1 && limit <= SESSION_LIST_LIMITS.max)) {
38
+ throw receiptRefusal(`SessionListQuery.limit must be an integer in 1..${SESSION_LIST_LIMITS.max} when present`);
39
+ }
40
+ return {
41
+ ...(owner !== undefined ? { owner } : {}),
42
+ includeUnowned: includeUnowned === true,
43
+ ...(after !== undefined ? { after: readListCursor(after) } : {}),
44
+ limit: limit ?? SESSION_LIST_LIMITS.default,
45
+ extensions: extended,
46
+ };
47
+ }
48
+ function readListCursor(raw) {
49
+ if (typeof raw !== "object" || raw === null)
50
+ throw receiptRefusal(`SessionListQuery.after must be an object when present, got ${raw === null ? "null" : typeof raw}`);
51
+ const got = receiveOwnProperties(raw, { subject: "SessionListQuery.after", unit: "member", moment: "at SessionStore.list" });
52
+ for (const name of Object.keys(got)) {
53
+ if (name !== "lastActiveAt" && name !== "sessionId")
54
+ throw receiptRefusal(`SessionListQuery.after carries "${name}" — a cursor is a lastActiveAt and a sessionId`);
55
+ }
56
+ const { lastActiveAt, sessionId } = got;
57
+ if (typeof lastActiveAt !== "number" || !Number.isFinite(lastActiveAt))
58
+ throw receiptRefusal("SessionListQuery.after.lastActiveAt must be a finite number");
59
+ if (typeof sessionId !== "string")
60
+ throw receiptRefusal(`SessionListQuery.after.sessionId must be a string, got ${typeof sessionId}`);
61
+ return { lastActiveAt, sessionId };
62
+ }
10
63
  export function hasSessionFork(store) {
11
64
  return typeof store.fork === "function";
12
65
  }
@@ -2,7 +2,7 @@ import { Type } from "typebox";
2
2
  import { errorResult } from "../tools.js";
3
3
  import { CONNECTING_MESSAGE, GENERIC_FAILURE_MESSAGE, NO_STORES_MESSAGE, SHARED_STORE_FRAME, UNAVAILABLE_MESSAGE, datePrefixOf, echoUntrusted, foldReaderError, listPrefixArgument, normalizeEntries, normalizeMemoryPath, normalizeReadValue, normalizeSnapshot, pageDocuments, relativePathRefusal, sanitizeSharedContent, validateDocumentPath, validatePathPrefix, } from "./normalize.js";
4
4
  import { SHARED_MEMORY_LIST_PAGE_SIZE, SHARED_MEMORY_LIST_TOOL_NAME, SHARED_MEMORY_READ_CAP_BYTES, SHARED_MEMORY_READ_TOOL_NAME, } from "./types.js";
5
- import { toolFace } from "../tool-catalog-entries.js";
5
+ import { mountRuleFace, toolFace } from "../tool-catalog-entries.js";
6
6
  const LIST_HINT = "List shared memory stores and their documents — check here before telling the user you do not have something.";
7
7
  const LIST_DESCRIPTION = [
8
8
  LIST_HINT,
@@ -127,6 +127,7 @@ export function createSharedMemoryTools(opts) {
127
127
  const listTool = {
128
128
  name: SHARED_MEMORY_LIST_TOOL_NAME,
129
129
  ...toolFace("memory-list"),
130
+ ruleFace: mountRuleFace("memory-list"),
130
131
  description: LIST_DESCRIPTION,
131
132
  defer: true,
132
133
  parameters: Type.Object({
@@ -258,6 +259,7 @@ export function createSharedMemoryTools(opts) {
258
259
  const readTool = {
259
260
  name: SHARED_MEMORY_READ_TOOL_NAME,
260
261
  ...toolFace("memory-read"),
262
+ ruleFace: mountRuleFace("memory-read"),
261
263
  description: READ_DESCRIPTION,
262
264
  defer: true,
263
265
  parameters: Type.Object({
@@ -2,7 +2,7 @@
2
2
  * design/177 — the SHARED memory-store seam (connected team/deployment memory libraries the model may
3
3
  * BROWSE and READ through two tools) and its model-facing constants.
4
4
  *
5
- * Upstream anchor: CC 2.1.223's `memory_list` / `memory_read` pair, whose defining property was READ/WRITE
5
+ * Upstream anchor: the reference's `memory_list` / `memory_read` pair, whose defining property was READ/WRITE
6
6
  * ASYMMETRY (no model-side write channel); CC no longer has that shape — 2.1.296 also mounts `yd` (cli296.js:242348) "memory_write" — and sema keeps the 223 one (KL-878): write governance is an
7
7
  * environment concern, and the tool face's entire participation in it is truthfully reporting each
8
8
  * store's `writable` bit. sema keeps that structure and pushes the whole credential/consent half onto
@@ -1,7 +1,7 @@
1
1
  import type { ShellReadVerdict } from "../tools/fs/shell-read-check.js";
2
2
  import { type ShellReadDisposition } from "../tools/fs/shell-read-judge.js";
3
3
  import type { GatePass } from "./runner/gate-exit.js";
4
- import type { AskGuard } from "./tool-policy.js";
4
+ import type { PermissionResult } from "./tool-policy.js";
5
5
  /** One station answer, received and read: what a reader acts on (`kind`) and the answer it acts on (`verdict` — the engine's own
6
6
  * copy, received once). `unbelieved`: the station's answer was not received or contradicted its own finding, and `verdict` is the
7
7
  * engine's refusal of it (its sentence names the station's words only where they are words of the closed sets — nothing a station
@@ -35,17 +35,16 @@ export interface StationAnswerCall {
35
35
  * ({@link silencedBy}).
36
36
  */
37
37
  export declare function readStationAnswer(answer: ShellReadVerdict, call: StationAnswerCall): StationAnswerReading;
38
- /** Whose silence a station's answer carries, each its own class on the question it keeps or mints: unread rows are a rule that could
39
- * not be read (the rule lane's class); the finding `unanswered` is, unless rows are unread, the environment's silence — shell text the
40
- * engine cannot read (a guard) — and the marks only pick whose. Either is a question only a person answers; `probe` follows the finding. */
41
- export declare function silencedBy(verdict: ShellReadVerdict, d: {
42
- readonly guards?: readonly AskGuard[];
43
- readonly ruleUnreadable?: unknown;
44
- }): {
45
- ruleUnreadable?: "persisted_rows";
46
- guards?: readonly AskGuard[];
47
- requiresRealApproval?: true;
48
- };
38
+ /** The ask `d` with the silence a station's answer carries, each its own class on the question it keeps or mints: unread rows are a
39
+ * rule that could not be read (the rule lane's class); the finding `unanswered` is, unless rows are unread, the environment's silence —
40
+ * shell text the engine cannot read (a guard, attested on the ask's record for `call` beside the guards it already carries) — and the
41
+ * marks only pick whose. Either is a question only a person answers; `probe` follows the finding. No silence ⇒ `d` itself. */
42
+ export declare function silencedBy<D extends Extract<PermissionResult, {
43
+ action: "ask";
44
+ }>>(d: D, verdict: ShellReadVerdict, call: {
45
+ readonly toolCallId: string;
46
+ readonly toolName: string;
47
+ }): D;
49
48
  /** The station's SILENCE ({@link readStationAnswer}), applied once, before any disposition arm: a station — a host-mounted one
50
49
  * included — may spell `vouch`, `mandated` or `ordinary` beside it, and no word vouches for what nobody judged. A deny stands; an
51
50
  * ask keeps its words and gains the silence's class; an allow becomes the silence's question (`ask.message`), one only a person
@@ -3,6 +3,7 @@ import { dispositionsOfRow, SHELL_READ_FINDINGS } from "../tools/fs/shell-read-j
3
3
  import { receiveContract } from "./decision-receipt.js";
4
4
  import { egressThrownText } from "./untrusted-egress.js";
5
5
  import { receive } from "./mods/kernel/receive.js";
6
+ import { attest, attestationOf } from "./engine-attestation.js";
6
7
  const DISPOSITIONS = ["refuse", "mandated", "ordinary", "vouch"];
7
8
  const MEMBER_KINDS = {
8
9
  disposition: "word",
@@ -71,21 +72,24 @@ export function readStationAnswer(answer, call) {
71
72
  call.report?.(new Error(`shell read station answered out of its contract for tool "${call.toolName}"${call.toolCallId !== undefined ? ` (toolCallId ${call.toolCallId})` : ""} — ${sentence}`));
72
73
  return { kind: "refuse", verdict: { disposition: "refuse", finding: "none", sentence }, unbelieved: true };
73
74
  }
74
- export function silencedBy(verdict, d) {
75
+ export function silencedBy(d, verdict, call) {
75
76
  const environment = verdict.environmentSilent === true || (verdict.finding === "unanswered" && verdict.rowsUnread !== true);
77
+ if (!environment && verdict.rowsUnread !== true)
78
+ return d;
76
79
  const rows = verdict.rowsUnread === true && d.ruleUnreadable === undefined ? { ruleUnreadable: "persisted_rows" } : {};
77
- const guards = environment && d.guards?.includes("unverifiable_shell_text") !== true ? { guards: [...(d.guards ?? []), "unverifiable_shell_text"] } : {};
78
- return environment || verdict.rowsUnread === true ? { ...rows, ...guards, requiresRealApproval: true } : {};
80
+ const out = { ...d, ...rows, requiresRealApproval: true };
81
+ const held = attestationOf(d, call)?.guards ?? [];
82
+ return environment && !held.includes("unverifiable_shell_text") ? attest(out, call, { guards: [...held, "unverifiable_shell_text"] }) : out;
79
83
  }
80
84
  export function applyUnansweredSilence(pass, verdict, ask) {
81
85
  if (verdict.details !== undefined)
82
86
  pass.shellReadDetails = verdict.details;
83
87
  if (pass.decision.action === "ask") {
84
- pass.decision = { ...pass.decision, ...silencedBy(verdict, pass.decision) };
88
+ pass.decision = silencedBy(pass.decision, verdict, pass.req);
85
89
  return;
86
90
  }
87
91
  if (pass.decision.action !== "allow")
88
92
  return;
89
- pass.decision = { action: "ask", message: ask.message, decisionReason: "safety", ...silencedBy(verdict, {}), ...(ask.account !== undefined ? { probeReason: ask.account } : {}) };
93
+ pass.decision = silencedBy({ action: "ask", message: ask.message, decisionReason: "safety", ...(ask.account !== undefined ? { probeReason: ask.account } : {}) }, verdict, pass.req);
90
94
  pass.tightenedBy = ask.tightenedBy;
91
95
  }
@@ -276,7 +276,7 @@ function unwrap(words) {
276
276
  if (row.viaShell === true)
277
277
  return `\`${name}\` evaluates its operands as shell input this reader does not read`;
278
278
  if (row.executes !== undefined) {
279
- const hit = words.slice(1).find((w) => w.expands !== false || row.executes.includes(w.text));
279
+ const hit = words.slice(1).find((w) => w.expands !== false || row.executes.some((x) => w.text === x || (x.length === 2 && /^-[^-]/.test(w.text) && w.text.includes(x[1]))));
280
280
  return hit === undefined ? words : hit.expands !== false ? `an expansion where \`${name}\` reads its arguments` : `\`${name} ${hit.text}\` runs a command this reader does not read`;
281
281
  }
282
282
  const valueFlags = new Set(row.valueFlags);
@@ -394,6 +394,8 @@ function unwrap(words) {
394
394
  if (r !== true)
395
395
  return r;
396
396
  i++;
397
+ if (durationTaken && positionalTaken)
398
+ break;
397
399
  }
398
400
  if (i >= words.length)
399
401
  return words;
@@ -30,7 +30,7 @@ const runsCommand = (spec) => spec.effect === "executes" || spec.value?.kind ===
30
30
  function projectRow(row) {
31
31
  const sorted = (xs) => [...new Set(xs)].sort();
32
32
  const all = spellings(row);
33
- const viaShell = row.reentry?.kind === "shell" || row.launcher?.shellText !== undefined || row.body === "first-operand" || row.body === "assignment-values" || (row.operands?.rest?.kind === "program-text" && row.operands.rest.language === "arithmetic");
33
+ const viaShell = (row.reentry?.kind === "shell" && row.reentry.text !== "history") || row.launcher?.shellText !== undefined || row.body === "first-operand" || row.body === "assignment-values" || (row.operands?.rest?.kind === "program-text" && row.operands.rest.language === "arithmetic");
34
34
  if (row.launcher === undefined) {
35
35
  if (viaShell)
36
36
  return { valueFlags: [], flags: [], commandString: [], viaShell: true };
@@ -181,6 +181,12 @@ export declare const SHELL_WRAPPER_TABLE: {
181
181
  readonly commandString: readonly [];
182
182
  readonly viaShell: true;
183
183
  };
184
+ readonly fc: {
185
+ readonly valueFlags: readonly [];
186
+ readonly flags: readonly [];
187
+ readonly commandString: readonly [];
188
+ readonly executes: readonly ["-e", "-s"];
189
+ };
184
190
  readonly source: {
185
191
  readonly valueFlags: readonly [];
186
192
  readonly flags: readonly [];
@@ -289,14 +295,14 @@ export declare const SHELL_WRAPPER_TABLE: {
289
295
  readonly viaShell: true;
290
296
  };
291
297
  readonly chroot: {
292
- readonly valueFlags: readonly [];
293
- readonly flags: readonly [];
298
+ readonly valueFlags: readonly ["--groups", "--userspec", "-G", "-g", "-u"];
299
+ readonly flags: readonly ["--help", "--skip-chdir", "--version"];
294
300
  readonly commandString: readonly [];
295
301
  readonly positional: RegExp;
296
302
  };
297
303
  readonly setpriv: {
298
- readonly valueFlags: readonly [];
299
- readonly flags: readonly [];
304
+ readonly valueFlags: readonly ["--ambient-caps", "--apparmor-profile", "--bounding-set", "--egid", "--euid", "--groups", "--inh-caps", "--pdeathsig", "--regid", "--reuid", "--rgid", "--ruid", "--securebits", "--selinux-label"];
305
+ readonly flags: readonly ["--clear-groups", "--dump", "--help", "--init-groups", "--keep-groups", "--nnp", "--no-new-privs", "--reset-env", "--version", "-V", "-d", "-h"];
300
306
  readonly commandString: readonly [];
301
307
  };
302
308
  readonly numactl: {
@@ -305,8 +311,9 @@ export declare const SHELL_WRAPPER_TABLE: {
305
311
  readonly commandString: readonly [];
306
312
  };
307
313
  readonly prlimit: {
308
- readonly valueFlags: readonly [];
309
- readonly flags: readonly [];
314
+ readonly valueFlags: readonly ["--output", "--pid", "-o", "-p"];
315
+ readonly flags: readonly ["--as", "--core", "--cpu", "--data", "--fsize", "--help", "--locks", "--memlock", "--msgqueue", "--nice", "--nofile", "--noheadings", "--nproc", "--raw", "--rss", "--rtprio", "--rttime", "--sigpending", "--stack", "--verbose", "--version", "-V", "-h"];
316
+ readonly attached: readonly ["-c", "-d", "-e", "-f", "-i", "-l", "-m", "-n", "-q", "-r", "-s", "-t", "-u", "-v", "-x", "-y"];
310
317
  readonly commandString: readonly [];
311
318
  };
312
319
  readonly "systemd-run": {
@@ -316,7 +323,7 @@ export declare const SHELL_WRAPPER_TABLE: {
316
323
  };
317
324
  readonly valgrind: {
318
325
  readonly valueFlags: readonly [];
319
- readonly flags: readonly [];
326
+ readonly flags: readonly ["--alignment", "--allow-mismatched-debuginfo", "--avg-transtab-entry-size", "--cachegrind-out-file", "--callgrind-out-file", "--child-silent-after-fork", "--default-suppressions", "--demangle", "--dhat-out-file", "--dsymutil", "--error-exitcode", "--error-limit", "--error-markers", "--errors-for-leak-kinds", "--exit-on-first-error", "--expensive-definedness-checks", "--fair-sched", "--free-fill", "--freelist-big-blocks", "--freelist-vol", "--fullpath-after", "--gen-suppressions", "--help", "--help-debug", "--help-dyn-options", "--ignore-range-below-sp", "--ignore-ranges", "--input-fd", "--keep-debuginfo", "--keep-stacktraces", "--kernel-variant", "--leak-check", "--leak-check-heuristics", "--leak-resolution", "--log-fd", "--log-file", "--main-stacksize", "--malloc-fill", "--massif-out-file", "--max-stackframe", "--max-threads", "--merge-recursive-frames", "--num-callers", "--num-transtab-sectors", "--partial-loads-ok", "--quiet", "--read-inline-info", "--read-var-info", "--redzone-size", "--resync-filter", "--run-cxx-freeres", "--run-libc-freeres", "--show-below-main", "--show-emwarns", "--show-error-list", "--show-leak-kinds", "--show-mismatched-frees", "--show-possibly-lost", "--show-reachable", "--sigill-diagnostics", "--sim-hints", "--smc-check", "--soname-synonyms", "--suppressions", "--time-stamp", "--tool", "--trace-children", "--trace-children-skip", "--trace-children-skip-by-arg", "--track-fds", "--track-origins", "--undef-value-errors", "--unw-stack-scan-frames", "--unw-stack-scan-thresh", "--valgrind-stacksize", "--verbose", "--version", "--vgdb", "--vgdb-error", "--vgdb-poll", "--vgdb-shadow-registers", "--vgdb-stop-at", "--workaround-gcc296-bugs", "--xml", "--xml-fd", "--xml-file", "--xml-user-comment", "--xtree-leak", "--xtree-leak-file", "--xtree-memory", "--xtree-memory-file", "-h", "-q", "-s", "-v"];
320
327
  readonly commandString: readonly [];
321
328
  };
322
329
  readonly firejail: {
@@ -27,6 +27,7 @@ export const SHELL_WRAPPER_TABLE = {
27
27
  unshare: { valueFlags: ["--boottime", "--map-group", "--map-user", "--monotonic", "--propagation", "--root", "--setgid", "--setgroups", "--setuid", "--wd", "-G", "-R", "-S", "-w"], flags: ["--cgroup", "--fork", "--help", "--ipc", "--keep-caps", "--kill-child", "--map-current-user", "--map-root-user", "--mount", "--mount-proc", "--net", "--pid", "--time", "--user", "--uts", "--version", "-C", "-T", "-U", "-c", "-f", "-i", "-m", "-n", "-p", "-r", "-u"], commandString: [] },
28
28
  nsenter: { valueFlags: ["--setgid", "--setuid", "--target", "-G", "-S", "-t"], flags: ["--all", "--cgroup", "--help", "--ipc", "--mount", "--net", "--no-fork", "--pid", "--preserve-credentials", "--root", "--time", "--user", "--uts", "--version", "--wd", "-C", "-F", "-T", "-U", "-Z", "-a", "-i", "-m", "-n", "-p", "-u"], attached: ["-r", "-w"], commandString: [] },
29
29
  eval: { valueFlags: [], flags: [], commandString: [], viaShell: true },
30
+ fc: { valueFlags: [], flags: [], commandString: [], executes: ["-e", "-s"] },
30
31
  source: { valueFlags: [], flags: [], commandString: [], viaShell: true },
31
32
  ".": { valueFlags: [], flags: [], commandString: [], viaShell: true },
32
33
  trap: { valueFlags: [], flags: [], commandString: [], viaShell: true },
@@ -45,12 +46,12 @@ export const SHELL_WRAPPER_TABLE = {
45
46
  busybox: { valueFlags: [], flags: [], commandString: [] },
46
47
  su: { valueFlags: ["--group", "--shell", "--supp-group", "--whitelist-environment", "-G", "-g", "-s", "-w"], flags: ["--fast", "--help", "--login", "--no-pty", "--preserve-environment", "--pty", "--version", "-P", "-T", "-V", "-f", "-h", "-l", "-m", "-p"], commandString: ["--command", "--session-command", "-c"], viaShell: true },
47
48
  runuser: { valueFlags: ["--group", "--shell", "--supp-group", "--user", "--whitelist-environment", "-G", "-g", "-s", "-u", "-w"], flags: ["--fast", "--help", "--login", "--no-pty", "--preserve-environment", "--pty", "--version", "-P", "-T", "-V", "-f", "-h", "-l", "-m", "-p"], commandString: ["--command", "--session-command", "-c"], viaShell: true },
48
- chroot: { valueFlags: [], flags: [], commandString: [], positional: /^/ },
49
- setpriv: { valueFlags: [], flags: [], commandString: [] },
49
+ chroot: { valueFlags: ["--groups", "--userspec", "-G", "-g", "-u"], flags: ["--help", "--skip-chdir", "--version"], commandString: [], positional: /^/ },
50
+ setpriv: { valueFlags: ["--ambient-caps", "--apparmor-profile", "--bounding-set", "--egid", "--euid", "--groups", "--inh-caps", "--pdeathsig", "--regid", "--reuid", "--rgid", "--ruid", "--securebits", "--selinux-label"], flags: ["--clear-groups", "--dump", "--help", "--init-groups", "--keep-groups", "--nnp", "--no-new-privs", "--reset-env", "--version", "-V", "-d", "-h"], commandString: [] },
50
51
  numactl: { valueFlags: [], flags: [], commandString: [] },
51
- prlimit: { valueFlags: [], flags: [], commandString: [] },
52
+ prlimit: { valueFlags: ["--output", "--pid", "-o", "-p"], flags: ["--as", "--core", "--cpu", "--data", "--fsize", "--help", "--locks", "--memlock", "--msgqueue", "--nice", "--nofile", "--noheadings", "--nproc", "--raw", "--rss", "--rtprio", "--rttime", "--sigpending", "--stack", "--verbose", "--version", "-V", "-h"], attached: ["-c", "-d", "-e", "-f", "-i", "-l", "-m", "-n", "-q", "-r", "-s", "-t", "-u", "-v", "-x", "-y"], commandString: [] },
52
53
  "systemd-run": { valueFlags: [], flags: [], commandString: [] },
53
- valgrind: { valueFlags: [], flags: [], commandString: [] },
54
+ valgrind: { valueFlags: [], flags: ["--alignment", "--allow-mismatched-debuginfo", "--avg-transtab-entry-size", "--cachegrind-out-file", "--callgrind-out-file", "--child-silent-after-fork", "--default-suppressions", "--demangle", "--dhat-out-file", "--dsymutil", "--error-exitcode", "--error-limit", "--error-markers", "--errors-for-leak-kinds", "--exit-on-first-error", "--expensive-definedness-checks", "--fair-sched", "--free-fill", "--freelist-big-blocks", "--freelist-vol", "--fullpath-after", "--gen-suppressions", "--help", "--help-debug", "--help-dyn-options", "--ignore-range-below-sp", "--ignore-ranges", "--input-fd", "--keep-debuginfo", "--keep-stacktraces", "--kernel-variant", "--leak-check", "--leak-check-heuristics", "--leak-resolution", "--log-fd", "--log-file", "--main-stacksize", "--malloc-fill", "--massif-out-file", "--max-stackframe", "--max-threads", "--merge-recursive-frames", "--num-callers", "--num-transtab-sectors", "--partial-loads-ok", "--quiet", "--read-inline-info", "--read-var-info", "--redzone-size", "--resync-filter", "--run-cxx-freeres", "--run-libc-freeres", "--show-below-main", "--show-emwarns", "--show-error-list", "--show-leak-kinds", "--show-mismatched-frees", "--show-possibly-lost", "--show-reachable", "--sigill-diagnostics", "--sim-hints", "--smc-check", "--soname-synonyms", "--suppressions", "--time-stamp", "--tool", "--trace-children", "--trace-children-skip", "--trace-children-skip-by-arg", "--track-fds", "--track-origins", "--undef-value-errors", "--unw-stack-scan-frames", "--unw-stack-scan-thresh", "--valgrind-stacksize", "--verbose", "--version", "--vgdb", "--vgdb-error", "--vgdb-poll", "--vgdb-shadow-registers", "--vgdb-stop-at", "--workaround-gcc296-bugs", "--xml", "--xml-fd", "--xml-file", "--xml-user-comment", "--xtree-leak", "--xtree-leak-file", "--xtree-memory", "--xtree-memory-file", "-h", "-q", "-s", "-v"], commandString: [] },
54
55
  firejail: { valueFlags: [], flags: [], commandString: [] },
55
56
  bwrap: { valueFlags: [], flags: [], commandString: [] },
56
57
  ash: { valueFlags: [], flags: [], commandString: [], viaShell: true },
@@ -1,6 +1,7 @@
1
1
  import type { AssistantMessage, StopReason, Tool, ToolResultMessage, Usage, UserMessage } from "../internal/llm.js";
2
2
  import type { Brain, Model, ModelRef, ModelRole, ModelRoles, TaskSpec, ThinkingLevel } from "./types.js";
3
3
  import { type DegradationInfo } from "../brain/degrading.js";
4
+ import { type BrainErrorCode } from "../brain/errors.js";
4
5
  /** A tool DEFINITION exposed to the model in a side query (never executed by the engine). */
5
6
  export interface SideQueryToolDef {
6
7
  name: string;
@@ -117,6 +118,15 @@ export interface SideQueryResult {
117
118
  * RETURNS the honest failure instead of throwing: utility callers uniformly need "no answer +
118
119
  * why", and a throw would lose usage/model attribution for the failed attempt. */
119
120
  errorMessage?: string;
121
+ /** The brain code of a failed query (`stopReason:"error"`), lifted from {@link errorMessage}'s `[code]` prefix by the one
122
+ * shared parser; absent when the message names none (an engine-minted shell, a custom brain). */
123
+ errorCode?: BrainErrorCode;
124
+ /** The STRUCTURAL failure kind the reply carried (`AssistantMessage.errorKind`), forwarded as is: `input_too_long` (the
125
+ * provider refused the request as over its window), `length_empty`, `degenerate`. Absent when the reply carried none. */
126
+ errorKind?: AssistantMessage["errorKind"];
127
+ /** `true` when the failure was a provider refusal its minter RULED OUT as input-too-long (`AssistantMessage.inputTooLongRuledOut`),
128
+ * forwarded as is. Absent otherwise. */
129
+ inputTooLongRuledOut?: true;
120
130
  }
121
131
  /** Dependencies the Runner passes through (a strict subset of RunnerDeps — no session/tool machinery). */
122
132
  export interface SideQueryDeps {