@sema-agent/server 7.133.0 → 7.135.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 (526) hide show
  1. package/MIGRATION.md +221 -0
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +2 -2
  4. package/USAGE.md +222 -36
  5. package/deploy/sema-up/README.md +16 -0
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
  9. package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
  10. package/deploy/sema-up/chart/templates/server-v4pro.yaml +14 -0
  11. package/deploy/sema-up/chart/templates/server.yaml +14 -0
  12. package/deploy/sema-up/chart/values-full-single.yaml +5 -1
  13. package/deploy/sema-up/chart/values.yaml +34 -0
  14. package/dist/adoption/plan.d.ts +1 -1
  15. package/dist/approval-ask-audit-store.d.ts +25 -25
  16. package/dist/approval-ask-machine.d.ts +2 -2
  17. package/dist/approval-card.d.ts +66 -154
  18. package/dist/approval-card.js +33 -52
  19. package/dist/approval-content-kind.d.ts +26 -6
  20. package/dist/approval-content-kind.js +23 -3
  21. package/dist/approval-deny-reasons.d.ts +1 -1
  22. package/dist/approval-gate-currency.d.ts +91 -0
  23. package/dist/approval-gate-currency.js +120 -0
  24. package/dist/approval-hmac.d.ts +7 -7
  25. package/dist/approval-policy-settlement.d.ts +2 -2
  26. package/dist/approval-reconciler.d.ts +3 -3
  27. package/dist/approval.d.ts +14 -8
  28. package/dist/approval.js +35 -16
  29. package/dist/auth-bridge.d.ts +1 -1
  30. package/dist/auto-mode-face.d.ts +4 -4
  31. package/dist/background-session-reap.d.ts +2 -2
  32. package/dist/bake-runner/main.d.ts +2 -2
  33. package/dist/bake-runner/runner.d.ts +4 -4
  34. package/dist/bench/s1/live-deps.d.ts +1 -1
  35. package/dist/bench/s1/run-firm.d.ts +1 -1
  36. package/dist/boot/coordinators.d.ts +7 -2
  37. package/dist/boot/coordinators.js +8 -5
  38. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  39. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  40. package/dist/boot/engine-lease.d.ts +5 -5
  41. package/dist/boot/execution-env.d.ts +16 -15
  42. package/dist/boot/execution-env.js +19 -21
  43. package/dist/boot/fatal-exit.d.ts +2 -2
  44. package/dist/boot/late-binds.d.ts +1 -1
  45. package/dist/boot/leader.d.ts +2 -0
  46. package/dist/boot/leader.js +2 -1
  47. package/dist/boot/memory-boundary.d.ts +2 -2
  48. package/dist/boot/memory-consolidation.d.ts +15 -15
  49. package/dist/boot/parked-revive-gate.d.ts +3 -3
  50. package/dist/boot/parked-revive-gate.js +3 -2
  51. package/dist/boot/read-deny-anchor-audit.js +2 -2
  52. package/dist/boot/reapers.d.ts +4 -4
  53. package/dist/boot/resolve-spec.d.ts +1 -1
  54. package/dist/boot/resolve-spec.js +28 -24
  55. package/dist/boot/runner-deps.d.ts +29 -16
  56. package/dist/boot/runner-deps.js +12 -2
  57. package/dist/boot/session-faces.d.ts +3 -3
  58. package/dist/boot/session-faces.js +11 -30
  59. package/dist/boot/shutdown.d.ts +5 -5
  60. package/dist/boot/side-query-lane.d.ts +2 -2
  61. package/dist/boot/stage-05-execution-env.js +4 -4
  62. package/dist/boot/stage-06-runners.d.ts +4 -3
  63. package/dist/boot/stage-06-runners.js +15 -4
  64. package/dist/boot/stage-07-capability-layer.d.ts +2 -1
  65. package/dist/boot/stage-08-reapers.d.ts +2 -1
  66. package/dist/boot/stage-09-leader.d.ts +2 -1
  67. package/dist/boot/stage-09-leader.js +2 -2
  68. package/dist/boot/stage-10-http-server.d.ts +2 -1
  69. package/dist/boot/stage-10-http-server.js +2 -1
  70. package/dist/boot/stores.d.ts +8 -0
  71. package/dist/boot/stores.js +10 -13
  72. package/dist/boot/web-admin.d.ts +21 -15
  73. package/dist/boot/web-admin.js +16 -12
  74. package/dist/boot/workflow-orchestration.js +2 -9
  75. package/dist/brain.d.ts +11 -11
  76. package/dist/budget.d.ts +4 -4
  77. package/dist/budget.js +5 -1
  78. package/dist/caller-text-echo.d.ts +2 -0
  79. package/dist/caller-text-echo.js +2 -1
  80. package/dist/canonical-json.d.ts +2 -41
  81. package/dist/canonical-json.js +2 -13
  82. package/dist/capabilities/approvals-push.d.ts +4 -4
  83. package/dist/capabilities/builtin-tools.d.ts +5 -5
  84. package/dist/capabilities/center-plugins.d.ts +5 -5
  85. package/dist/capabilities/center-plugins.js +1 -1
  86. package/dist/capabilities/center-prompts.d.ts +1 -1
  87. package/dist/capabilities/center-wiring.d.ts +1 -1
  88. package/dist/capabilities/composite-members.d.ts +2 -2
  89. package/dist/capabilities/composite-members.js +1 -1
  90. package/dist/capabilities/execution-lane.d.ts +5 -5
  91. package/dist/capabilities/execution-lane.js +2 -2
  92. package/dist/capabilities/hands-lane.d.ts +5 -5
  93. package/dist/capabilities/mcp-probe.d.ts +10 -7
  94. package/dist/capabilities/mcp-probe.js +2 -2
  95. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  96. package/dist/capabilities/sandbox-file-send.js +0 -7
  97. package/dist/capabilities/scenarios.d.ts +28 -10
  98. package/dist/capabilities/scenarios.js +15 -5
  99. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  100. package/dist/capabilities/skills.d.ts +31 -12
  101. package/dist/capabilities/skills.js +23 -17
  102. package/dist/capabilities/tool-defer.d.ts +1 -1
  103. package/dist/capability-facts.d.ts +27 -24
  104. package/dist/capability-facts.js +18 -20
  105. package/dist/center-config-tier.d.ts +1 -1
  106. package/dist/center-credential.d.ts +4 -4
  107. package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
  108. package/dist/checkpoint-ctx-seal-m28.js +19 -0
  109. package/dist/checkpoint-identity.d.ts +5 -0
  110. package/dist/checkpoint-identity.js +14 -0
  111. package/dist/config-catalog.d.ts +12 -12
  112. package/dist/config-invariants.d.ts +4 -4
  113. package/dist/config-invariants.js +3 -2
  114. package/dist/config-lkg.d.ts +1 -1
  115. package/dist/config-provider.d.ts +13 -13
  116. package/dist/config-provider.js +2 -1
  117. package/dist/config-types.d.ts +83 -83
  118. package/dist/config.d.ts +26 -24
  119. package/dist/config.js +12 -10
  120. package/dist/cross-session-settings.d.ts +1 -1
  121. package/dist/delegated-session-owner.d.ts +16 -13
  122. package/dist/delegated-session-owner.js +9 -10
  123. package/dist/deployment-governance.d.ts +16 -16
  124. package/dist/deployment-shape.d.ts +127 -0
  125. package/dist/deployment-shape.js +72 -0
  126. package/dist/device-store.d.ts +1 -1
  127. package/dist/device-ws-hub.d.ts +1 -1
  128. package/dist/egress-redirect.d.ts +1 -1
  129. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  130. package/dist/env-facts.d.ts +10 -9
  131. package/dist/env-facts.js +1 -1
  132. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  133. package/dist/exec-bounds.d.ts +2 -2
  134. package/dist/execution-lane-caps.d.ts +31 -43
  135. package/dist/execution-lane-caps.js +0 -13
  136. package/dist/field-conflict.d.ts +2 -1
  137. package/dist/field-conflict.js +1 -0
  138. package/dist/file-history-capture.d.ts +9 -9
  139. package/dist/file-history-disclosure.d.ts +50 -9
  140. package/dist/file-history-disclosure.js +8 -13
  141. package/dist/fleet/drain-entry.d.ts +2 -2
  142. package/dist/fleet/fleet-bus.d.ts +26 -14
  143. package/dist/fleet/fleet-bus.js +6 -5
  144. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  145. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  146. package/dist/fleet-client.d.ts +13 -13
  147. package/dist/fleet-lease.d.ts +16 -16
  148. package/dist/governance-http-status.d.ts +2 -2
  149. package/dist/hooks/hook-llm.d.ts +7 -7
  150. package/dist/hooks/hook-runner.d.ts +57 -30
  151. package/dist/hooks/hook-runner.js +38 -20
  152. package/dist/host-decision.d.ts +5 -5
  153. package/dist/host-lsp-manager.d.ts +5 -5
  154. package/dist/hosted-posture.d.ts +23 -13
  155. package/dist/hosted-posture.js +4 -9
  156. package/dist/http/admission.d.ts +2 -2
  157. package/dist/http/admission.js +28 -5
  158. package/dist/http/approval-sweeps.d.ts +1 -1
  159. package/dist/http/approval-sweeps.js +5 -2
  160. package/dist/http/checkpoint-ctx.d.ts +183 -2
  161. package/dist/http/checkpoint-ctx.js +197 -2
  162. package/dist/http/dispatch.d.ts +3 -3
  163. package/dist/http/dispatch.js +3 -3
  164. package/dist/http/durable-run-leg.js +7 -5
  165. package/dist/http/idempotency.d.ts +4 -4
  166. package/dist/http/idempotency.js +2 -2
  167. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  168. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  169. package/dist/http/owner-access.d.ts +4 -6
  170. package/dist/http/owner-access.js +1 -1
  171. package/dist/http/principal-gate.d.ts +39 -13
  172. package/dist/http/principal-gate.js +30 -6
  173. package/dist/http/readiness.d.ts +1 -1
  174. package/dist/http/refusal-body.d.ts +12 -0
  175. package/dist/http/refusal-body.js +11 -0
  176. package/dist/http/request-guards.d.ts +4 -13
  177. package/dist/http/request-guards.js +4 -17
  178. package/dist/http/resume-ctx-read.d.ts +53 -6
  179. package/dist/http/resume-ctx-read.js +26 -3
  180. package/dist/http/resume-legs.d.ts +5 -4
  181. package/dist/http/resume-legs.js +47 -29
  182. package/dist/http/route-ctx.d.ts +29 -38
  183. package/dist/http/route-table.d.ts +9 -9
  184. package/dist/http/routes/agents-roster.d.ts +1 -1
  185. package/dist/http/routes/agents-roster.js +2 -3
  186. package/dist/http/routes/approvals-assistant.d.ts +5 -5
  187. package/dist/http/routes/approvals-assistant.js +91 -17
  188. package/dist/http/routes/background.d.ts +3 -3
  189. package/dist/http/routes/background.js +2 -2
  190. package/dist/http/routes/capabilities.d.ts +1 -1
  191. package/dist/http/routes/capabilities.js +16 -8
  192. package/dist/http/routes/config-catalog.d.ts +1 -1
  193. package/dist/http/routes/devices.d.ts +1 -1
  194. package/dist/http/routes/diagnostics.d.ts +6 -6
  195. package/dist/http/routes/diagnostics.js +1 -1
  196. package/dist/http/routes/fleet.d.ts +1 -1
  197. package/dist/http/routes/fleet.js +5 -4
  198. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  199. package/dist/http/routes/mcp-reconnect.js +3 -3
  200. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  201. package/dist/http/routes/memory-origin.d.ts +1 -1
  202. package/dist/http/routes/notify-wake.d.ts +1 -1
  203. package/dist/http/routes/notify-wake.js +2 -2
  204. package/dist/http/routes/rules.d.ts +1 -1
  205. package/dist/http/routes/rules.js +4 -4
  206. package/dist/http/routes/runs.js +44 -11
  207. package/dist/http/routes/session-sync.d.ts +3 -2
  208. package/dist/http/routes/session-sync.js +109 -62
  209. package/dist/http/routes/sessions-list.d.ts +1 -1
  210. package/dist/http/routes/sessions-list.js +4 -5
  211. package/dist/http/routes/sessions.js +34 -48
  212. package/dist/http/routes/tasks.d.ts +1 -1
  213. package/dist/http/routes/tasks.js +21 -16
  214. package/dist/http/routes/trace-usage.d.ts +1 -1
  215. package/dist/http/routes/trace-usage.js +7 -9
  216. package/dist/http/routes/workflows.d.ts +3 -0
  217. package/dist/http/routes/workflows.js +31 -28
  218. package/dist/http/send.d.ts +5 -5
  219. package/dist/http/server.d.ts +39 -33
  220. package/dist/http/server.js +5 -2
  221. package/dist/http/session-inherit-env.d.ts +3 -3
  222. package/dist/http/sse-lifecycle.d.ts +1 -1
  223. package/dist/http/sse-log.d.ts +2 -2
  224. package/dist/http/submit-ctx.d.ts +4 -3
  225. package/dist/http/submit-ctx.js +19 -3
  226. package/dist/http/sync-submit-body.d.ts +1 -1
  227. package/dist/http/verify-rounds.d.ts +1 -1
  228. package/dist/http/wire-types.d.ts +35 -24
  229. package/dist/index.d.ts +2 -0
  230. package/dist/index.js +1 -0
  231. package/dist/instruction-source-notice.d.ts +2 -2
  232. package/dist/key-resolver.d.ts +3 -3
  233. package/dist/lane-home-probe.d.ts +1 -1
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/leader/diffup.d.ts +2 -2
  236. package/dist/leader/endpoint.d.ts +1 -1
  237. package/dist/leader/fanout.d.ts +1 -1
  238. package/dist/leader/leader.d.ts +4 -4
  239. package/dist/leader/merge.d.ts +3 -3
  240. package/dist/leader/repair-wire.d.ts +1 -1
  241. package/dist/leader/wire.d.ts +9 -5
  242. package/dist/leader/wire.js +8 -7
  243. package/dist/list-entry-display.d.ts +1 -1
  244. package/dist/lsp-evict.d.ts +1 -1
  245. package/dist/main.js +1 -1
  246. package/dist/mcp-assertion-header.d.ts +1 -1
  247. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  248. package/dist/memory-operator-faces.d.ts +1 -1
  249. package/dist/memory-origin-fence.js +2 -2
  250. package/dist/memory-posture.js +4 -2
  251. package/dist/memory-project-layer.d.ts +1 -1
  252. package/dist/memory-scope.d.ts +19 -19
  253. package/dist/memory-store-refusal.d.ts +4 -4
  254. package/dist/model-compat.d.ts +1 -1
  255. package/dist/model-entry-headers.d.ts +2 -2
  256. package/dist/model-entry-refusal.d.ts +17 -17
  257. package/dist/model-provider.d.ts +10 -10
  258. package/dist/model-reach-scope.d.ts +1 -1
  259. package/dist/model-route-endpoint.d.ts +6 -6
  260. package/dist/model-route-url.d.ts +5 -5
  261. package/dist/model-select.d.ts +15 -6
  262. package/dist/model-select.js +5 -0
  263. package/dist/model-unreachable-notice.d.ts +3 -3
  264. package/dist/namespaced-rule-name.d.ts +15 -5
  265. package/dist/namespaced-rule-name.js +3 -2
  266. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  267. package/dist/observability/cost-taxonomy.d.ts +1 -1
  268. package/dist/observability/err-text.d.ts +1 -1
  269. package/dist/observability/fail-open.d.ts +12 -8
  270. package/dist/observability/fail-open.js +12 -8
  271. package/dist/observability/metrics.d.ts +3 -3
  272. package/dist/observability/prompt-manifest.d.ts +19 -8
  273. package/dist/observability/prompt-manifest.js +9 -8
  274. package/dist/observability/run-terminal.d.ts +36 -36
  275. package/dist/observability/secret-env-scrub.d.ts +3 -3
  276. package/dist/observability/tool-trace.d.ts +1 -1
  277. package/dist/observability/tool-trace.js +8 -9
  278. package/dist/operator-ask.d.ts +4 -4
  279. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  280. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  281. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  282. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  283. package/dist/orchestration/workflow-notify-journal.js +17 -0
  284. package/dist/orchestration/workflow-park-decision.d.ts +1 -1
  285. package/dist/orchestration/workflow-park-decision.js +1 -0
  286. package/dist/outbound-dispatcher.d.ts +4 -4
  287. package/dist/parent-watch.d.ts +4 -4
  288. package/dist/parked-decide.d.ts +20 -20
  289. package/dist/parked-decide.js +8 -5
  290. package/dist/parked-revive-surface.d.ts +7 -7
  291. package/dist/parked-revive-surface.js +2 -3
  292. package/dist/peer-directory.d.ts +3 -3
  293. package/dist/peer-directory.js +1 -1
  294. package/dist/permission-rule-list.d.ts +10 -1
  295. package/dist/permission-rule-list.js +7 -5
  296. package/dist/permission-rule-vocab.d.ts +3 -25
  297. package/dist/permission-rule-vocab.js +0 -13
  298. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  299. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  300. package/dist/plugins/approval-ask-store-file.js +6 -3
  301. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  302. package/dist/plugins/approval-ask-store-memory.js +11 -7
  303. package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
  304. package/dist/plugins/approval-ask-store-sql.js +18 -5
  305. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  306. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  307. package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
  308. package/dist/plugins/approval-payload-fingerprint.js +1 -1
  309. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  310. package/dist/plugins/background-shell-support.d.ts +2 -2
  311. package/dist/plugins/blob-backend.d.ts +1 -1
  312. package/dist/plugins/caching-session-store.d.ts +24 -33
  313. package/dist/plugins/caching-session-store.js +8 -19
  314. package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
  315. package/dist/plugins/checkpoint-index-columns.js +62 -0
  316. package/dist/plugins/checkpoint-store-sql.d.ts +66 -67
  317. package/dist/plugins/checkpoint-store-sql.js +100 -103
  318. package/dist/plugins/device-store-sql.d.ts +7 -6
  319. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  320. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  321. package/dist/plugins/file-history-store-sql.d.ts +9 -7
  322. package/dist/plugins/file-history-store-sql.js +27 -15
  323. package/dist/plugins/file-run-store.d.ts +8 -8
  324. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  325. package/dist/plugins/fork-routing-session-store.js +1 -1
  326. package/dist/plugins/host-platform.d.ts +10 -10
  327. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  328. package/dist/plugins/image-index-sql.d.ts +1 -1
  329. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  330. package/dist/plugins/local-checkpoint-store.d.ts +23 -12
  331. package/dist/plugins/local-checkpoint-store.js +29 -4
  332. package/dist/plugins/local-session-store.d.ts +44 -45
  333. package/dist/plugins/local-session-store.js +42 -52
  334. package/dist/plugins/local-session-window.d.ts +12 -6
  335. package/dist/plugins/local-session-window.js +1 -17
  336. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  337. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  338. package/dist/plugins/memory-run-store.d.ts +4 -4
  339. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  340. package/dist/plugins/one-time-migrations.d.ts +76 -39
  341. package/dist/plugins/one-time-migrations.js +127 -34
  342. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  343. package/dist/plugins/park-commit-watch.d.ts +3 -3
  344. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  345. package/dist/plugins/permission-rule-store-file.js +16 -19
  346. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  347. package/dist/plugins/permission-rule-store-sql.js +74 -31
  348. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  349. package/dist/plugins/pg-pool.d.ts +2 -2
  350. package/dist/plugins/pg-pool.js +5 -2
  351. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  352. package/dist/plugins/pg-session-storage.d.ts +9 -21
  353. package/dist/plugins/pg-session-storage.js +51 -42
  354. package/dist/plugins/remote-env-adb.d.ts +10 -10
  355. package/dist/plugins/remote-env-device.d.ts +22 -14
  356. package/dist/plugins/remote-env-device.js +28 -16
  357. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  358. package/dist/plugins/remote-env-host.d.ts +16 -16
  359. package/dist/plugins/remote-env-k8s.d.ts +8 -8
  360. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  361. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  362. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  363. package/dist/plugins/remote-scratchpad.js +0 -4
  364. package/dist/plugins/remote-shell.d.ts +6 -6
  365. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  366. package/dist/plugins/retention-store-sql.d.ts +4 -4
  367. package/dist/plugins/roster-store-sql.d.ts +1 -1
  368. package/dist/plugins/run-store-sql.d.ts +8 -8
  369. package/dist/plugins/schema-consistency.d.ts +2 -2
  370. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  371. package/dist/plugins/schema-indexes.d.ts +1 -1
  372. package/dist/plugins/schema-live-columns.d.ts +1 -1
  373. package/dist/plugins/session-event-payload.d.ts +4 -4
  374. package/dist/plugins/session-fork.d.ts +34 -0
  375. package/dist/plugins/session-fork.js +29 -0
  376. package/dist/plugins/session-ownership.d.ts +11 -0
  377. package/dist/plugins/session-ownership.js +11 -0
  378. package/dist/plugins/session-placement.d.ts +12 -14
  379. package/dist/plugins/session-placement.js +2 -15
  380. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  381. package/dist/plugins/session-store.d.ts +2 -2
  382. package/dist/plugins/session-store.js +2 -2
  383. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  384. package/dist/plugins/sql-driver.d.ts +8 -8
  385. package/dist/plugins/sql-errors.d.ts +1 -1
  386. package/dist/plugins/sql-json-column.d.ts +21 -21
  387. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  388. package/dist/plugins/store-backend.d.ts +17 -16
  389. package/dist/plugins/store-backend.js +3 -3
  390. package/dist/plugins/store-contracts.d.ts +21 -21
  391. package/dist/plugins/task-attachment-store.d.ts +2 -2
  392. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  393. package/dist/plugins/tidb-pool.d.ts +2 -2
  394. package/dist/plugins/tidb-pool.js +9 -2
  395. package/dist/plugins/tidb-session-store.d.ts +17 -27
  396. package/dist/plugins/tidb-session-store.js +52 -42
  397. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  398. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  399. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  400. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  401. package/dist/plugins/web-search.d.ts +19 -5
  402. package/dist/plugins/web-search.js +19 -4
  403. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  404. package/dist/plugins/workflow-journal-payload.js +32 -0
  405. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  406. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  407. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  408. package/dist/posture-source.d.ts +11 -11
  409. package/dist/principal-jwt.d.ts +6 -6
  410. package/dist/project-identity.d.ts +3 -3
  411. package/dist/project-memory.d.ts +4 -4
  412. package/dist/read-face-posture.d.ts +7 -7
  413. package/dist/request-key-closure.d.ts +1 -1
  414. package/dist/request-key-closure.js +1 -1
  415. package/dist/request-tool-axes.d.ts +12 -0
  416. package/dist/request-tool-axes.js +20 -0
  417. package/dist/request-value-closure.d.ts +15 -8
  418. package/dist/request-value-closure.js +2 -0
  419. package/dist/router/route-orchestration.d.ts +11 -16
  420. package/dist/router/route-orchestration.js +2 -12
  421. package/dist/rule-entry-list.d.ts +8 -7
  422. package/dist/rule-entry-list.js +2 -9
  423. package/dist/rules-consent.d.ts +6 -6
  424. package/dist/rules-consent.js +2 -0
  425. package/dist/run-cancel-context.d.ts +5 -5
  426. package/dist/run-local.d.ts +10 -10
  427. package/dist/run-local.js +1 -0
  428. package/dist/runs.d.ts +15 -12
  429. package/dist/runs.js +19 -4
  430. package/dist/runtime-caps-resolver.d.ts +6 -6
  431. package/dist/runtime-governance.d.ts +9 -9
  432. package/dist/sandbox-pkg-source.d.ts +9 -31
  433. package/dist/sandbox-pkg-source.js +14 -8
  434. package/dist/sealed-key.d.ts +34 -2
  435. package/dist/sealed-key.js +55 -1
  436. package/dist/security.d.ts +31 -32
  437. package/dist/security.js +12 -9
  438. package/dist/server-secret-env.d.ts +10 -10
  439. package/dist/session-children-retire.d.ts +1 -1
  440. package/dist/session-error-wire.d.ts +19 -12
  441. package/dist/session-error-wire.js +4 -1
  442. package/dist/session-incarnation.d.ts +52 -35
  443. package/dist/session-incarnation.js +23 -8
  444. package/dist/session-policy-wire.d.ts +27 -5
  445. package/dist/session-policy-wire.js +15 -1
  446. package/dist/session-records-skipped-notice.d.ts +1 -1
  447. package/dist/session-sync-kernel.d.ts +38 -11
  448. package/dist/session-sync-kernel.js +10 -0
  449. package/dist/session-sync.d.ts +49 -6
  450. package/dist/session-sync.js +52 -10
  451. package/dist/session-titler.d.ts +7 -6
  452. package/dist/session-titler.js +8 -13
  453. package/dist/session-watch.d.ts +3 -3
  454. package/dist/session-watch.js +4 -4
  455. package/dist/sighup-idle.d.ts +2 -2
  456. package/dist/spec-fields.d.ts +4 -4
  457. package/dist/sql-engine-posture.d.ts +3 -3
  458. package/dist/store-posture.d.ts +2 -2
  459. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  460. package/dist/task-a2a.d.ts +3 -1
  461. package/dist/task-a2a.js +38 -5
  462. package/dist/task-cwd.d.ts +7 -88
  463. package/dist/task-cwd.js +2 -15
  464. package/dist/task-mcp.d.ts +14 -10
  465. package/dist/task-mcp.js +39 -12
  466. package/dist/task-settings.d.ts +34 -18
  467. package/dist/task-settings.js +34 -4
  468. package/dist/task-workflow.d.ts +0 -24
  469. package/dist/task-workflow.js +2 -1
  470. package/dist/terminal.d.ts +5 -5
  471. package/dist/tighten-only-seats.d.ts +7 -6
  472. package/dist/tighten-only-seats.js +1 -1
  473. package/dist/tool-approval.d.ts +273 -228
  474. package/dist/tool-approval.js +125 -47
  475. package/dist/tool-rule-names.d.ts +7 -1
  476. package/dist/trace/core-keyset-guard.d.ts +15 -9
  477. package/dist/trace/engine-notice-wire.d.ts +5 -5
  478. package/dist/trace/engine-notice-wire.js +1 -0
  479. package/dist/trace/exit-seat.d.ts +40 -1
  480. package/dist/trace/exit-seat.js +46 -14
  481. package/dist/trace/ledger-events.d.ts +6 -4
  482. package/dist/trace/ledger-sink.d.ts +1 -1
  483. package/dist/trace/model-segment.d.ts +3 -3
  484. package/dist/trace/project.d.ts +65 -46
  485. package/dist/trace/project.js +49 -5
  486. package/dist/trace/redact.d.ts +44 -27
  487. package/dist/trace/redact.js +343 -73
  488. package/dist/trace/self-minted-wire.d.ts +39 -14
  489. package/dist/trace/self-minted-wire.js +9 -0
  490. package/dist/trace/sema-provenance.d.ts +1 -1
  491. package/dist/trace/task-notification-facets.d.ts +4 -4
  492. package/dist/trace/wire-projection-faces.d.ts +9 -3
  493. package/dist/trace/wire-projection-faces.js +7 -1
  494. package/dist/unattended-permission-mode.d.ts +5 -5
  495. package/dist/url-credential.d.ts +52 -0
  496. package/dist/url-credential.js +49 -0
  497. package/dist/url-refusal.d.ts +6 -2
  498. package/dist/url-refusal.js +8 -1
  499. package/dist/usage-analytics.d.ts +2 -2
  500. package/dist/user-input-ledger.d.ts +23 -23
  501. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  502. package/dist/web-admin-client/apply-effective.js +2 -1
  503. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/center-request.d.ts +2 -2
  505. package/dist/web-admin-client/facade.d.ts +5 -5
  506. package/dist/web-admin-client/facade.js +1 -1
  507. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  508. package/dist/web-admin-client/http-client.d.ts +4 -4
  509. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  510. package/dist/web-admin-client/pull-state.d.ts +1 -1
  511. package/dist/web-admin-client/read-face.d.ts +2 -2
  512. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  513. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  514. package/dist/web-admin-client/skills-mcp.d.ts +29 -4
  515. package/dist/web-admin-client/skills-mcp.js +31 -4
  516. package/dist/web-admin-client/types.d.ts +17 -10
  517. package/dist/workspace-space.d.ts +5 -3
  518. package/dist/write-protection.d.ts +2 -2
  519. package/package.json +4 -3
  520. package/scripts/drain-check-local.mjs +35 -2
  521. package/scripts/drain-check.mysql.sql +22 -2
  522. package/scripts/drain-check.pg.sql +22 -2
  523. package/skills/loop.md +1 -1
  524. package/dist/mcp-tool-faces.d.ts +0 -69
  525. package/dist/mcp-tool-faces.js +0 -104
  526. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -9,7 +9,8 @@ import { sentMemoryComplianceFailure } from "../memory-compliance-failure-reply.
9
9
  import { MAX_SETTINGS_OUTPUT_STYLE_CHARS, MAX_SETTINGS_ENV_VARS, MAX_SETTINGS_ENV_KEY_CHARS, MAX_SETTINGS_ENV_VALUE_CHARS } from "../../task-settings.js";
10
10
  import { readWritableSessionPermissionRules } from "../../session-policy-wire.js";
11
11
  import { sendJson, sendError, sendSessionError, sendSessionPolicyError, sseHeaders, httpErrorBody } from "../send.js";
12
- import { gatedPrincipal, explicitOperatorOk, sessionCallerOf, sessionOwnerReadable, sendPrincipalRefusal, sendUnauthorized } from "../principal-gate.js";
12
+ import { fleetViewOf, gatedPrincipal, explicitOperatorOk, sessionCallerOf, sessionOwnerReadable, sendPrincipalRefusal, sendUnauthorized } from "../principal-gate.js";
13
+ import { headReadOf, sessionFaceOfHead } from "../../session-incarnation.js";
13
14
  import { runRowReadableOnSessionFace } from "../owner-access.js";
14
15
  import { assertNever, SESSION_NOT_FOUND_MESSAGE } from "../route-ctx.js";
15
16
  import * as facts from "../../capability-facts.js";
@@ -71,11 +72,11 @@ async function readLastLegMcp(deps, sessionId, caller) {
71
72
  }
72
73
  export async function handleSessions(req, res, match, ctx) {
73
74
  const { deps } = ctx;
74
- const { readJson, safeDecode, sessionOwnerOk, sessionOwnerScopeForWrite } = ctx.helpers;
75
+ const { readJson, safeDecode, sessionOwnerOk } = ctx.helpers;
75
76
  const readOwnedSessionView = async (sessionAudit, sessionId, readOpts) => {
76
- const ownerOf = deps.sessionStorage?.ownerOf?.bind(deps.sessionStorage);
77
- if (ownerOf !== undefined) {
78
- const owner = await ownerOf(sessionId);
77
+ const headOf = headReadOf(deps.sessionStorage);
78
+ if (headOf !== undefined) {
79
+ const owner = (await headOf(sessionId))?.owner;
79
80
  if (owner === undefined) {
80
81
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
81
82
  return undefined;
@@ -88,7 +89,7 @@ export async function handleSessions(req, res, match, ctx) {
88
89
  audit = await sessionAudit(sessionId, readOpts);
89
90
  }
90
91
  catch (e) {
91
- if (ownerOf !== undefined)
92
+ if (headOf !== undefined)
92
93
  throw e;
93
94
  throw new Error(`session view read failed before ownership could be established: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
94
95
  }
@@ -168,9 +169,11 @@ export async function handleSessions(req, res, match, ctx) {
168
169
  if (mcpStatusCache.size > 1024)
169
170
  mcpStatusCache.clear();
170
171
  const panel = (async () => {
171
- const matP = materializeMcpTools(specs, principal, undefined, undefined, undefined, deps.mcpRevocations);
172
+ const stopDial = new AbortController();
173
+ const matP = materializeMcpTools(specs, principal, undefined, undefined, undefined, deps.mcpRevocations, undefined, undefined, undefined, stopDial.signal);
172
174
  const mat = await raceDeadline(matP, MCP_DIAL_DEADLINE_MS).catch(() => null);
173
175
  if (!mat) {
176
+ stopDial.abort();
174
177
  void matP.then((m) => m?.dispose().catch(() => undefined)).catch(() => undefined);
175
178
  return { servers: [], asOf: new Date().toISOString(), degraded: true };
176
179
  }
@@ -187,7 +190,7 @@ export async function handleSessions(req, res, match, ctx) {
187
190
  };
188
191
  }
189
192
  finally {
190
- await mat.dispose().catch(() => undefined);
193
+ void mat.dispose().catch(() => undefined);
191
194
  }
192
195
  })();
193
196
  mcpStatusCache.set(cacheKey, { at: Date.now(), panel });
@@ -252,9 +255,8 @@ export async function handleSessions(req, res, match, ctx) {
252
255
  }
253
256
  {
254
257
  if (match.decl.id === "session-head") {
255
- const getLeafId = deps.sessionStorage?.getLeafId?.bind(deps.sessionStorage);
256
- const ownerOf = deps.sessionStorage?.ownerOf?.bind(deps.sessionStorage);
257
- if (!getLeafId || !ownerOf) {
258
+ const headOf = headReadOf(deps.sessionStorage);
259
+ if (!headOf) {
258
260
  sendError(res, 501, "capability.session_store_required", "session head probe requires a durable session store (DB_BACKEND=mysql|pg|local)");
259
261
  return;
260
262
  }
@@ -263,30 +265,14 @@ export async function handleSessions(req, res, match, ctx) {
263
265
  sendError(res, 400, "request.path_malformed", "session id segment is not valid percent-encoding");
264
266
  return;
265
267
  }
266
- const getHead = deps.sessionStorage?.getHead?.bind(deps.sessionStorage);
267
- let owner;
268
- let leafId;
269
- if (getHead) {
270
- const head = await getHead(headSession);
271
- if (head === undefined) {
272
- sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
273
- return;
274
- }
275
- owner = head.owner;
276
- if (!sessionOwnerOk(req, res, await sessionOwnerCellOf(deps.sessionStorage, headSession, owner ?? null)))
277
- return;
278
- leafId = head.leafId;
279
- }
280
- else {
281
- owner = await ownerOf(headSession);
282
- if (owner === undefined) {
283
- sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
284
- return;
285
- }
286
- if (!sessionOwnerOk(req, res, await sessionOwnerCellOf(deps.sessionStorage, headSession, owner ?? null)))
287
- return;
288
- leafId = await getLeafId(headSession);
268
+ const head = await headOf(headSession);
269
+ if (head === undefined) {
270
+ sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
271
+ return;
289
272
  }
273
+ if (!sessionOwnerOk(req, res, await sessionOwnerCellOf(deps.sessionStorage, headSession, head.owner)))
274
+ return;
275
+ const leafId = head.leafId;
290
276
  const etag = `"${leafId ?? "empty"}"`;
291
277
  if (req.headers["if-none-match"] === etag) {
292
278
  res.writeHead(304, { etag }).end();
@@ -304,7 +290,7 @@ export async function handleSessions(req, res, match, ctx) {
304
290
  sendError(res, 501, "capability.session_store_required", "session events require a durable session store (DB_BACKEND=mysql|pg|local)");
305
291
  return;
306
292
  }
307
- const ownerOf = evFact.sessionStorage.ownerOf.bind(evFact.sessionStorage);
293
+ const readOwner = async (id) => (await evFact.sessionStorage.headOf(id))?.owner;
308
294
  const watch = evFact.watch;
309
295
  const evSession = safeDecode(match.params.sessionId);
310
296
  if (evSession === null) {
@@ -340,7 +326,7 @@ export async function handleSessions(req, res, match, ctx) {
340
326
  return;
341
327
  }
342
328
  sse.sseOwnerLookups++;
343
- const cellP = ownerOf(evSession).then((o) => (o === undefined ? undefined : sessionOwnerCellOf(evFact.sessionStorage, evSession, o)));
329
+ const cellP = readOwner(evSession).then((o) => (o === undefined ? undefined : sessionOwnerCellOf(evFact.sessionStorage, evSession, o)));
344
330
  void cellP.catch(() => undefined).then(() => { sse.sseOwnerLookups--; });
345
331
  let stallTimer;
346
332
  let cell;
@@ -470,7 +456,7 @@ export async function handleSessions(req, res, match, ctx) {
470
456
  }
471
457
  ownerCheckPending = true;
472
458
  ownerCheckStartedAt = Date.now();
473
- void ownerOf(evSession).then((o) => {
459
+ void readOwner(evSession).then((o) => {
474
460
  ownerCheckPending = false;
475
461
  if (!closed && o !== owner)
476
462
  onEnd();
@@ -670,7 +656,7 @@ export async function handleSessions(req, res, match, ctx) {
670
656
  }
671
657
  const store = rowFact.sessionStorage;
672
658
  const sessionId = match.params.sessionId;
673
- const face = await store.sessionFaceOf(sessionId);
659
+ const face = sessionFaceOfHead(sessionId, await store.headOf(sessionId));
674
660
  if (face === undefined) {
675
661
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
676
662
  return;
@@ -698,8 +684,8 @@ export async function handleSessions(req, res, match, ctx) {
698
684
  return;
699
685
  }
700
686
  const fork = forkFact.sessionStorage.fork.bind(forkFact.sessionStorage);
701
- const ownerOf = forkFact.sessionStorage.ownerOf.bind(forkFact.sessionStorage);
702
- const scope = sessionOwnerScopeForWrite(req);
687
+ const readOwner = async (id) => (await forkFact.sessionStorage.headOf(id))?.owner;
688
+ const scope = fleetViewOf(req, deps, "write");
703
689
  if (!scope.fleetWide && scope.gateOwner === null) {
704
690
  sendUnauthorized(res, "identity");
705
691
  return;
@@ -709,12 +695,12 @@ export async function handleSessions(req, res, match, ctx) {
709
695
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
710
696
  return;
711
697
  }
712
- const owner = await ownerOf(sourceId);
698
+ const owner = await readOwner(sourceId);
713
699
  if (owner === undefined) {
714
700
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
715
701
  return;
716
702
  }
717
- if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config.requirePrincipal, sessionCallerOf(req, deps), await sessionOwnerCellOf(forkFact.sessionStorage, sourceId, owner))) {
703
+ if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(forkFact.sessionStorage, sourceId, owner))) {
718
704
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
719
705
  return;
720
706
  }
@@ -736,8 +722,8 @@ export async function handleSessions(req, res, match, ctx) {
736
722
  return;
737
723
  }
738
724
  const purge = deleteFact.purge;
739
- const ownerOf = deleteFact.sessionStorage.ownerOf.bind(deleteFact.sessionStorage);
740
- const scope = sessionOwnerScopeForWrite(req);
725
+ const readOwner = async (id) => (await deleteFact.sessionStorage.headOf(id))?.owner;
726
+ const scope = fleetViewOf(req, deps, "write");
741
727
  if (!scope.fleetWide && scope.gateOwner === null) {
742
728
  sendUnauthorized(res, "identity");
743
729
  return;
@@ -747,12 +733,12 @@ export async function handleSessions(req, res, match, ctx) {
747
733
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
748
734
  return;
749
735
  }
750
- const owner = await ownerOf(sessionId);
736
+ const owner = await readOwner(sessionId);
751
737
  if (owner === undefined) {
752
738
  sendJson(res, 200, { deleted: false });
753
739
  return;
754
740
  }
755
- if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config.requirePrincipal, sessionCallerOf(req, deps), await sessionOwnerCellOf(deleteFact.sessionStorage, sessionId, owner))) {
741
+ if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(deleteFact.sessionStorage, sessionId, owner))) {
756
742
  sendJson(res, 200, { deleted: false });
757
743
  return;
758
744
  }
@@ -782,7 +768,7 @@ export async function handleSessions(req, res, match, ctx) {
782
768
  return;
783
769
  }
784
770
  const store = policyFact.policyStore;
785
- const ownerOf = policyFact.sessionStorage.ownerOf.bind(policyFact.sessionStorage);
771
+ const readOwner = async (id) => (await policyFact.sessionStorage.headOf(id))?.owner;
786
772
  const principal = gatedPrincipal(req, deps.config);
787
773
  if (deps.config.requirePrincipal && principal === undefined) {
788
774
  sendUnauthorized(res, "identity");
@@ -793,7 +779,7 @@ export async function handleSessions(req, res, match, ctx) {
793
779
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
794
780
  return;
795
781
  }
796
- const owner = await ownerOf(sessionId);
782
+ const owner = await readOwner(sessionId);
797
783
  if (owner === undefined) {
798
784
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
799
785
  return;
@@ -12,7 +12,7 @@
12
12
  * · `runSyncSubmitLeg` —— 同步腿(原 128 行匿名体);
13
13
  * · 同步腿内 `verifyLeg` / `cascadeLeg` / `plainLeg` —— 三条模型驱动腿,判别顺序与短路语义逐字不变。
14
14
  * 提名**只改名字不改行为**:闭包捕获的自由变量、语句顺序、settle/registry 生命周期注释全部随代码原样迁移。
15
- * (S-947 起「这次是不是被 server 中止、为什么」读每腿自己的中止句柄 `RunAbort`,不再有按 taskId 键控的
15
+ * ([ref] 起「这次是不是被 server 中止、为什么」读每腿自己的中止句柄 `RunAbort`,不再有按 taskId 键控的
16
16
  * `cancelledViaVerb` 旁表与它「身份守卫内先取后删」的取值时点。)
17
17
  *
18
18
  * 与 runs 域共用 `ctx.legs.prepareSpec`(读体/校验/建 spec 的同一条前段)。
@@ -21,7 +21,7 @@ import { replayOfExistingRun } from "../submit-replay.js";
21
21
  import { httpErrorCode, sendJson, sendError, sseHeaders } from "../send.js";
22
22
  import { collectSsePreamble } from "../sse-log.js";
23
23
  import { buildApprovalPreamble, buildApprovalPreambleSseFrames } from "../../approval-card.js";
24
- import { createApprovalCardEmitter, resolveApprovalLeg, resolveStreamApprovalGate } from "../../tool-approval.js";
24
+ import { approvalPreambleReplays, createApprovalCardEmitter, declaredApprovalFrameFamilies, resolveApprovalLeg, resolveStreamApprovalGate } from "../../tool-approval.js";
25
25
  import { buildActiveRunConflict, isActiveRunConflictBody, toDoneFrameResult } from "../active-run-conflict.js";
26
26
  import { commitPlacement, devicePlacementErrorBody } from "../device-placement.js";
27
27
  import { commitSessionInheritEnv } from "../session-inherit-env.js";
@@ -150,6 +150,18 @@ export async function handleTasks(req, res, match, ctx) {
150
150
  const prepared = await prepareSpec(req, res, keyedBody, undefined, { liveStream });
151
151
  if (!prepared)
152
152
  return;
153
+ const declaredFamilies = declaredApprovalFrameFamilies(prepared.body.settings);
154
+ const approvalLegInput = (streamApprovalOn) => {
155
+ const legWalltimeMs = typeof prepared.spec.limits?.maxWalltimeMs === "number" ? prepared.spec.limits.maxWalltimeMs : undefined;
156
+ return {
157
+ streamApprovalOn,
158
+ windowMs: deps.config.streamApproval?.windowMs,
159
+ windowMarginMs: deps.config.streamAskWindowMarginMs,
160
+ ...(legWalltimeMs !== undefined ? { legWalltimeMs } : {}),
161
+ declaredFamilies,
162
+ };
163
+ };
164
+ const assembleApprovalLeg = (streamApprovalOn) => resolveApprovalLeg({ ...approvalLegInput(streamApprovalOn), nowMonotonicMs: performance.now() });
153
165
  const principal = prepared.auth?.principal;
154
166
  const wiringOperatorFace = explicitOperatorOk(gatedPrincipal(req, deps.config), deps.config);
155
167
  let wiringReceipt;
@@ -215,9 +227,9 @@ export async function handleTasks(req, res, match, ctx) {
215
227
  toolApprovalEnabled: Boolean(deps.toolApproval),
216
228
  streamApprovalEnabled: deps.config.streamApproval?.enabled === true,
217
229
  backend: deps.backend,
218
- parkFacility: deps.checkpointStore !== undefined,
230
+ checkpointStore: deps.checkpointStore,
219
231
  });
220
- const replaySessionId = replayGate.active ? prepared.spec.sessionId : undefined;
232
+ const replaySessionId = approvalPreambleReplays(approvalLegInput(replayGate.active)) ? prepared.spec.sessionId : undefined;
221
233
  const presentedOnConnection = new Set();
222
234
  const presentedCompleted = new Set();
223
235
  const admitPresentedComplete = (askId) => {
@@ -663,18 +675,11 @@ export async function handleTasks(req, res, match, ctx) {
663
675
  toolApprovalEnabled: Boolean(deps.toolApproval),
664
676
  streamApprovalEnabled: deps.config.streamApproval?.enabled === true,
665
677
  backend: deps.backend,
666
- parkFacility: deps.checkpointStore !== undefined,
678
+ checkpointStore: deps.checkpointStore,
667
679
  }).active;
668
- const legWalltimeMs = typeof prepared.spec.limits?.maxWalltimeMs === "number" ? prepared.spec.limits.maxWalltimeMs : undefined;
669
- const approvalLeg = resolveApprovalLeg({
670
- streamApprovalOn,
671
- windowMs: deps.config.streamApproval?.windowMs,
672
- windowMarginMs: deps.config.streamAskWindowMarginMs,
673
- ...(legWalltimeMs !== undefined ? { legWalltimeMs } : {}),
674
- nowMonotonicMs: performance.now(),
675
- });
680
+ const approvalLeg = assembleApprovalLeg(streamApprovalOn);
676
681
  const legDeadlineMonotonic = approvalLeg.legDeadlineMonotonic;
677
- const windowZero = approvalLeg.windowZero;
682
+ const unattended = approvalLeg.unattended;
678
683
  const emitCard = createApprovalCardEmitter({
679
684
  ...(ledgerSink
680
685
  ? {
@@ -696,7 +701,7 @@ export async function handleTasks(req, res, match, ctx) {
696
701
  if (!res.writableEnded && !res.destroyed)
697
702
  emitAsk(frame);
698
703
  };
699
- const approvalCtx = deps.toolApproval && !windowZero
704
+ const approvalCtx = deps.toolApproval && unattended === undefined
700
705
  ? {
701
706
  taskId: askTaskId,
702
707
  owner: askOwner,
@@ -714,8 +719,8 @@ export async function handleTasks(req, res, match, ctx) {
714
719
  : undefined;
715
720
  if (deps.toolApproval) {
716
721
  const toolApproval = deps.toolApproval;
717
- prepared.spec.onAsk = windowZero
718
- ? toolApproval.boundUnattendedAsk({ owner: askOwner, taskId: askTaskId, ...(prepared.spec.sessionId ? { sessionId: prepared.spec.sessionId } : {}) })
722
+ prepared.spec.onAsk = unattended
723
+ ? toolApproval.boundUnattendedAsk({ owner: askOwner, taskId: askTaskId, ...(prepared.spec.sessionId ? { sessionId: prepared.spec.sessionId } : {}) }, unattended)
719
724
  : toolApproval.boundAsk({
720
725
  owner: askOwner,
721
726
  taskId: askTaskId,
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * ⚠️ 三块都跑在全局 service-credential 门**之前**(与 /metrics 同款待遇)——只读 traceToken 单凭据的调用方
8
8
  * (registry 中继的姿势)在全局门会被 401,挂门后=门内 traceToken 支持成死代码(1.148 a2 实机抓获)。
9
- * S-672(7.105.0):门前不等于不设防 —— 本域坐在读路谓词段,先过 `dispatch.ts` 的 `readCredentialOk`
9
+ * [ref](7.105.0):门前不等于不设防 —— 本域坐在读路谓词段,先过 `dispatch.ts` 的 `readCredentialOk`
10
10
  * (部署配了 service 凭据时要「service token / traceToken / 已验 principal」之一),块内这几道门在它之后。
11
11
  * 因此本域在 `handle()` 里的位置就是契约的一部分:必须留在鉴权门上方,顺序不可与其他域对调。本域零可变状态。
12
12
  */
@@ -6,16 +6,16 @@ import { sleep } from "../sse-log.js";
6
6
  import { bindSseLifecycle } from "../sse-lifecycle.js";
7
7
  import { sendJson, sendError, sseHeaders, SSE_MAX_STREAM_MS, SSE_HEARTBEAT_IDLE_MS } from "../send.js";
8
8
  import { filterFingerprint } from "../cursor-fingerprint.js";
9
- import { gatedPrincipal, sendUnauthorized } from "../principal-gate.js";
9
+ import { fleetViewOf, sendUnauthorized } from "../principal-gate.js";
10
10
  import { assertNever } from "../route-ctx.js";
11
11
  import * as facts from "../../capability-facts.js";
12
12
  const TOOL_RESULT_LIMIT_CAP = 262_144;
13
13
  const TOOL_RESULT_OFFSET_CAP = 2_147_483_646;
14
14
  export async function handleTraceUsage(req, res, match, ctx) {
15
15
  const { deps } = ctx;
16
- const { isFleetWide, safeDecode } = ctx.helpers;
16
+ const { safeDecode } = ctx.helpers;
17
17
  if (match.decl.id === "tasks-source-summary") {
18
- if (!isFleetWide(req)) {
18
+ if (!fleetViewOf(req, deps, "read").fleetWide) {
19
19
  sendUnauthorized(res, "operator");
20
20
  return;
21
21
  }
@@ -35,8 +35,7 @@ export async function handleTraceUsage(req, res, match, ctx) {
35
35
  match.decl.id === "task-trace-stream" ||
36
36
  match.decl.id === "task-trace-artifacts" ||
37
37
  match.decl.id === "task-tool-result") {
38
- const fleetWide = isFleetWide(req);
39
- const gateOwner = fleetWide ? null : (gatedPrincipal(req, deps.config) || null);
38
+ const { fleetWide, gateOwner } = fleetViewOf(req, deps, "read");
40
39
  if (!fleetWide && gateOwner === null) {
41
40
  sendUnauthorized(res, "identity");
42
41
  return;
@@ -89,9 +88,8 @@ export async function handleTraceUsage(req, res, match, ctx) {
89
88
  return;
90
89
  }
91
90
  const runStore = runs.runStore;
92
- const fleetWide = isFleetWide(req);
93
- const jwtOwner = fleetWide ? undefined : gatedPrincipal(req, deps.config);
94
- if (!fleetWide && !jwtOwner) {
91
+ const { fleetWide, gateOwner } = fleetViewOf(req, deps, "read");
92
+ if (!fleetWide && gateOwner === null) {
95
93
  sendUnauthorized(res, "identity");
96
94
  return;
97
95
  }
@@ -109,7 +107,7 @@ export async function handleTraceUsage(req, res, match, ctx) {
109
107
  sendError(res, 400, "request.query_invalid", "invalid from/to (ISO-8601 or epoch-ms; from < to)");
110
108
  return;
111
109
  }
112
- const owner = jwtOwner ?? (q.get("principal") ?? undefined);
110
+ const owner = gateOwner ?? (q.get("principal") ?? undefined);
113
111
  try {
114
112
  const scan = await runStore.usageScan(from, to, owner !== undefined ? { owner } : undefined);
115
113
  const base = { from: new Date(from).toISOString(), to: new Date(to).toISOString(), ...(scan.truncated ? { truncated: true } : {}) };
@@ -175,6 +175,9 @@ export declare const WORKFLOW_RUN_DISPOSITIONS: {
175
175
  readonly id: "forward";
176
176
  readonly scope: "forward";
177
177
  readonly status: "forward";
178
+ readonly parked: {
179
+ readonly mint: (run: WorkflowRun) => true | undefined;
180
+ };
178
181
  readonly name: {
179
182
  readonly redact: "redactSecrets";
180
183
  };
@@ -1,9 +1,8 @@
1
1
  import { persistedPlaneOf } from "../../terminal.js";
2
2
  import { z } from "zod";
3
- import { getWorkflowRun, subscribeWorkflow, deriveAgentDisplayStatus, callKeyOrdinal } from "@sema-agent/core";
3
+ import { getWorkflowRun, subscribeWorkflow, deriveAgentDisplayStatus, callKeyOrdinal, runParkedOf, JOURNAL_INCOMPATIBLE_ERROR_CODE, WorkflowJournalIncompatibleError } from "@sema-agent/core";
4
4
  import { redactSteerIn, STEER_IN_MAX_CHARS, STEER_IN_MAX_REQUEST_CHARS } from "../../orchestration/workflow-agent-steer.js";
5
- import { journalEntryOfBody, journalEntryPayload, journalRowPayloadOf, readJournalRowBody } from "../../orchestration/workflow-journal-entry.js";
6
- import { decodeJsonColumn } from "../../plugins/sql-json-column.js";
5
+ import { journalEntryOfCell, journalEntryPayload, journalRowPayloadOf } from "../../plugins/workflow-journal-payload.js";
7
6
  import { redactSecrets } from "../../trace/redact.js";
8
7
  import { createHash } from "node:crypto";
9
8
  import { redactHead } from "../../observability/run-terminal.js";
@@ -72,8 +71,8 @@ export async function handleWorkflows(req, res, match, ctx) {
72
71
  if (journalStore === undefined)
73
72
  throw new Error("workflow-journal reached without the workflowsJournal journal witness");
74
73
  const jq = new URLSearchParams(match.search);
75
- const jLimit = Math.min(50, Math.max(1, Number(jq.get("limit") ?? 20) || 20));
76
- const jOffset = Math.max(0, Number(jq.get("offset") ?? 0) || 0);
74
+ const jLimit = Math.min(50, Math.max(1, Math.trunc(Number(jq.get("limit") ?? 20)) || 20));
75
+ const jOffset = Math.max(0, Math.trunc(Number(jq.get("offset") ?? 0)) || 0);
77
76
  const MAX_ROW_BYTES = 64 * 1024;
78
77
  const firstLine = (t) => (t ? redactHead(t.split("\n")[0], 300) : undefined);
79
78
  const MAX_RESULT_CHARS = 2000;
@@ -114,31 +113,34 @@ export async function handleWorkflows(req, res, match, ctx) {
114
113
  };
115
114
  const js = journalStore;
116
115
  let projected;
117
- if (js.loadPage) {
118
- const page = await js.loadPage(wfId, scope, { offset: jOffset, limit: jLimit, maxResultBytes: MAX_ROW_BYTES });
119
- projected = page.map((row) => {
120
- if (row.resultJson === null) {
121
- return oversizeStub(row.callKey, row.resultBytes);
122
- }
123
- try {
124
- const { payload, parked } = journalEntryPayload(journalEntryOfBody(row.callKey, decodeJsonColumn(row.resultJson, readJournalRowBody, `workflow_journal.result for entry ${row.callKey}`)));
116
+ try {
117
+ if (js.loadPage) {
118
+ const page = await js.loadPage(wfId, scope, { offset: jOffset, limit: jLimit, maxResultBytes: MAX_ROW_BYTES });
119
+ projected = page.map((row) => {
120
+ if (row.resultJson === null) {
121
+ return oversizeStub(row.callKey, row.resultBytes);
122
+ }
123
+ const { payload, parked } = journalEntryPayload(journalEntryOfCell(wfId, row.callKey, row.resultJson, `workflow_journal.result for entry ${row.callKey}`));
125
124
  return projectEntry(row.callKey, payload, parked);
126
- }
127
- catch {
128
- return oversizeStub(row.callKey, row.resultBytes);
129
- }
130
- });
125
+ });
126
+ }
127
+ else {
128
+ const entries = await journalStore.load(wfId, scope);
129
+ projected = entries
130
+ .sort((a, b) => callKeyOrdinal(a.callKey) - callKeyOrdinal(b.callKey))
131
+ .slice(jOffset, jOffset + jLimit)
132
+ .map((en) => {
133
+ const { payload, parked } = journalEntryPayload(en);
134
+ const bytes = Buffer.byteLength(journalRowPayloadOf(en));
135
+ return bytes > MAX_ROW_BYTES ? oversizeStub(en.callKey, bytes) : projectEntry(en.callKey, payload, parked);
136
+ });
137
+ }
131
138
  }
132
- else {
133
- const entries = await journalStore.load(wfId, scope);
134
- projected = entries
135
- .sort((a, b) => callKeyOrdinal(a.callKey) - callKeyOrdinal(b.callKey))
136
- .slice(jOffset, jOffset + jLimit)
137
- .map((en) => {
138
- const { payload, parked } = journalEntryPayload(en);
139
- const bytes = Buffer.byteLength(journalRowPayloadOf(en));
140
- return bytes > MAX_ROW_BYTES ? oversizeStub(en.callKey, bytes) : projectEntry(en.callKey, payload, parked);
141
- });
139
+ catch (e) {
140
+ if (!(e instanceof WorkflowJournalIncompatibleError))
141
+ throw e;
142
+ sendError(res, 500, JOURNAL_INCOMPATIBLE_ERROR_CODE, `this run's journal holds a record the engine cannot read (entry #${e.ordinal}): the journal cannot be listed or resumed until that record is repaired from a kept copy — do not delete it (a missing entry makes a resume run that step again)`, { ordinal: e.ordinal });
143
+ return;
142
144
  }
143
145
  sendJson(res, 200, { runId: wfId, entries: projected, ...(projected.length === jLimit ? { nextOffset: jOffset + jLimit } : {}) });
144
146
  return;
@@ -366,6 +368,7 @@ export const WORKFLOW_RUN_DISPOSITIONS = {
366
368
  id: "forward",
367
369
  scope: "forward",
368
370
  status: "forward",
371
+ parked: { mint: (run) => (runParkedOf({ status: run.status, agents: [...rowsOf(run.agents)] }) ? true : undefined) },
369
372
  name: { redact: "redactSecrets" },
370
373
  description: { redact: "redactSecrets" },
371
374
  stats: { nested: WORKFLOW_RUN_STATS_DISPOSITIONS },
@@ -51,7 +51,7 @@ export declare const SSE_MAX_STREAM_MS: number;
51
51
  */
52
52
  export declare const SSE_HEARTBEAT_IDLE_MS = 15000;
53
53
  /**
54
- * S-1281 —— 服务端**主动**收一条已开的 SSE 流:一帧 `event: error`(帧形与流帽那一帧同一套 `{type:"error", errorCode, message}`,
54
+ * [ref] —— 服务端**主动**收一条已开的 SSE 流:一帧 `event: error`(帧形与流帽那一帧同一套 `{type:"error", errorCode, message}`,
55
55
  * 消费端按既有「服务端收流 ⇒ 重连」协议处置,SDK 的流读口把它当一帧事件交出再重连)后 `end()`。
56
56
  *
57
57
  * 收流的是分派器,不是流自己的泵:泵此刻可能正停在一次 await 上,醒来还会写一帧。Node 上 `end()` 之后、`close` 之前的那一写会发一个
@@ -102,25 +102,25 @@ export declare function httpErrorBody(e: HttpError): RefusalBody;
102
102
  /** 整面拒:状态 = `e.status`,体 = {@link httpErrorBody}。手里拿着一只 `HttpError` 的路由站点一律调它。 */
103
103
  export declare function sendHttpError(res: ServerResponse, e: HttpError): void;
104
104
  /**
105
- * 🔴 B1 / S-535 —— `SessionPolicyError` → 应答,经 {@link sessionPolicyErrorHttp} 那**一只**映射
105
+ * 🔴 B1 / [ref] —— `SessionPolicyError` → 应答,经 {@link sessionPolicyErrorHttp} 那**一只**映射
106
106
  * (`src/session-policy-wire.ts`)。回 `true` = 已应答,调用点 `return`。
107
107
  *
108
108
  * 为什么是一只共享腿而不是每个站点一句 `instanceof`:映射本身早就收成一处了,而**咨询它的站点**只有两条
109
109
  * **写**腿 —— 偏偏 core 7.25.0 那个新词 `corrupt` 是在**读**上抛出来的(店读不出它自己写的那一行:
110
- * S-529 的两道读回拒 + C1 的体形拒)。于是 `GET /v1/sessions/:id/policy` 与 2c 的 manifest 导出腿把它交给了
110
+ * [ref] 的两道读回拒 + C1 的体形拒)。于是 `GET /v1/sessions/:id/policy` 与 2c 的 manifest 导出腿把它交给了
111
111
  * 域外通用臂 ⇒ `500 internal.error "internal error"`:码丢,连带**修复路径**也丢(同一行 `PUT` 却答
112
112
  * `500 corrupt` 并点名那一列)。一只腿之后,新站点只会忘记调它,不会再各自发明一份映射。
113
113
  */
114
114
  export declare function sendSessionPolicyError(res: ServerResponse, e: unknown, sentencePrefix?: string): boolean;
115
115
  /**
116
- * S-612 —— core `SessionError` → 应答,经 {@link sessionErrorHttp} 那**一只**映射(`src/session-error-wire.ts`)。
116
+ * [ref] —— core `SessionError` → 应答,经 {@link sessionErrorHttp} 那**一只**映射(`src/session-error-wire.ts`)。
117
117
  * 回 `true` = 已应答,调用点 `return`;`false` = 不是 `SessionError`,或这个词在这一面上是登记过的留白(站点的既有
118
118
  * 处置照旧 —— 通常是继续上抛到全局兜底)。
119
119
  *
120
120
  * 句子:属主给了固定句就发它(import 面 `invalid_session` / `placement_refused` 两句),否则发 core 的原句过既有脱敏(`redactErrorMessage`:
121
121
  * 不抛、有上限)。core 的 `corrupt_session` 原句只点名会话 id 与跳过计数(「Session <id> is unreadable: its log has no
122
122
  * meta header (N of M records skipped as corrupt)」),SQL 两店的原句点名 `<表>.<列>` 与行号 —— 两者都不含盘上路径
123
- * (路径只进运维面:`server.session-repo.corrupt-record-skipped` 的探针行,S-990;SQL 两店走各自的拒绝句)。
123
+ * (路径只进运维面:`server.session-repo.corrupt-record-skipped` 的探针行,[ref];SQL 两店走各自的拒绝句)。
124
124
  */
125
125
  export declare function sendSessionError(res: ServerResponse, e: unknown, face: SessionErrorFace): boolean;
126
126
  export declare function msg(e: unknown): string;