@sema-agent/server 7.134.0 → 7.136.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 (550) hide show
  1. package/MIGRATION.md +197 -1
  2. package/USAGE.md +147 -42
  3. package/deploy/sema-up/README.md +1 -1
  4. package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
  5. package/deploy/sema-up/chart/values.yaml +1 -1
  6. package/dist/adoption/plan.d.ts +1 -1
  7. package/dist/approval-ask-audit-store.d.ts +24 -24
  8. package/dist/approval-ask-machine.d.ts +2 -2
  9. package/dist/approval-card.d.ts +122 -154
  10. package/dist/approval-card.js +50 -51
  11. package/dist/approval-content-kind.d.ts +23 -5
  12. package/dist/approval-content-kind.js +8 -1
  13. package/dist/approval-deny-reasons.d.ts +1 -1
  14. package/dist/approval-gate-currency.d.ts +22 -3
  15. package/dist/approval-gate-currency.js +44 -18
  16. package/dist/approval-hmac.d.ts +7 -7
  17. package/dist/approval-policy-settlement.d.ts +2 -2
  18. package/dist/approval-reconciler.d.ts +3 -3
  19. package/dist/approval.d.ts +8 -8
  20. package/dist/approval.js +4 -2
  21. package/dist/auth-bridge.d.ts +35 -6
  22. package/dist/auth-bridge.js +20 -3
  23. package/dist/auto-mode-face.d.ts +4 -4
  24. package/dist/background-session-reap.d.ts +2 -2
  25. package/dist/bake-runner/main.d.ts +2 -2
  26. package/dist/bake-runner/runner.d.ts +4 -4
  27. package/dist/bench/s1/live-deps.d.ts +1 -1
  28. package/dist/bench/s1/run-firm.d.ts +1 -1
  29. package/dist/boot/budget-tracing.d.ts +1 -2
  30. package/dist/boot/budget-tracing.js +2 -2
  31. package/dist/boot/coordinators.d.ts +2 -2
  32. package/dist/boot/coordinators.js +2 -2
  33. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  34. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  35. package/dist/boot/engine-lease.d.ts +5 -5
  36. package/dist/boot/execution-env.d.ts +16 -15
  37. package/dist/boot/execution-env.js +19 -21
  38. package/dist/boot/fatal-exit.d.ts +2 -2
  39. package/dist/boot/late-binds.d.ts +1 -1
  40. package/dist/boot/leader.d.ts +1 -1
  41. package/dist/boot/memory-boundary.d.ts +2 -2
  42. package/dist/boot/memory-consolidation.d.ts +15 -15
  43. package/dist/boot/org-memory.js +1 -1
  44. package/dist/boot/parked-revive-gate.d.ts +3 -3
  45. package/dist/boot/parked-revive-gate.js +3 -2
  46. package/dist/boot/reapers.d.ts +4 -4
  47. package/dist/boot/resolve-spec.d.ts +1 -1
  48. package/dist/boot/resolve-spec.js +36 -29
  49. package/dist/boot/runner-deps.d.ts +11 -11
  50. package/dist/boot/runner-deps.js +7 -4
  51. package/dist/boot/session-faces.d.ts +3 -3
  52. package/dist/boot/session-faces.js +11 -30
  53. package/dist/boot/shutdown.d.ts +5 -5
  54. package/dist/boot/side-query-lane.d.ts +2 -2
  55. package/dist/boot/stage-04-stores.d.ts +1 -1
  56. package/dist/boot/stage-05-execution-env.d.ts +1 -1
  57. package/dist/boot/stage-05-execution-env.js +4 -4
  58. package/dist/boot/stage-06-runners.d.ts +1 -1
  59. package/dist/boot/stage-06-runners.js +0 -2
  60. package/dist/boot/stage-07-capability-layer.d.ts +1 -1
  61. package/dist/boot/stage-08-reapers.d.ts +1 -1
  62. package/dist/boot/stage-09-leader.d.ts +1 -1
  63. package/dist/boot/stage-10-http-server.d.ts +1 -1
  64. package/dist/boot/stores.js +4 -4
  65. package/dist/boot/web-admin.d.ts +17 -17
  66. package/dist/boot/web-admin.js +15 -27
  67. package/dist/boot/workflow-orchestration.js +2 -9
  68. package/dist/brain.d.ts +11 -11
  69. package/dist/brain.js +12 -3
  70. package/dist/budget.d.ts +7 -7
  71. package/dist/budget.js +4 -0
  72. package/dist/capabilities/approvals-push.d.ts +4 -4
  73. package/dist/capabilities/builtin-tools.d.ts +5 -5
  74. package/dist/capabilities/center-plugins.d.ts +5 -5
  75. package/dist/capabilities/center-plugins.js +1 -1
  76. package/dist/capabilities/center-prompts.d.ts +1 -1
  77. package/dist/capabilities/center-wiring.d.ts +1 -1
  78. package/dist/capabilities/composite-members.d.ts +1 -1
  79. package/dist/capabilities/execution-lane.d.ts +5 -5
  80. package/dist/capabilities/execution-lane.js +2 -2
  81. package/dist/capabilities/hands-lane.d.ts +5 -5
  82. package/dist/capabilities/mcp-probe.d.ts +11 -7
  83. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  84. package/dist/capabilities/sandbox-file-send.js +0 -7
  85. package/dist/capabilities/scenarios.d.ts +28 -10
  86. package/dist/capabilities/scenarios.js +15 -5
  87. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  88. package/dist/capabilities/skills.d.ts +31 -12
  89. package/dist/capabilities/skills.js +23 -17
  90. package/dist/capabilities/tool-defer.d.ts +1 -1
  91. package/dist/capability-facts.d.ts +29 -32
  92. package/dist/capability-facts.js +17 -21
  93. package/dist/center-config-tier.d.ts +1 -1
  94. package/dist/center-credential.d.ts +22 -8
  95. package/dist/center-credential.js +18 -3
  96. package/dist/checkpoint-identity.d.ts +5 -0
  97. package/dist/checkpoint-identity.js +14 -0
  98. package/dist/config-catalog.d.ts +12 -12
  99. package/dist/config-catalog.js +12 -10
  100. package/dist/config-d-migration.js +1 -1
  101. package/dist/config-invariants.d.ts +5 -5
  102. package/dist/config-invariants.js +11 -2
  103. package/dist/config-lkg.d.ts +1 -39
  104. package/dist/config-lkg.js +1 -83
  105. package/dist/config-provider.d.ts +13 -13
  106. package/dist/config-provider.js +2 -1
  107. package/dist/config-types.d.ts +95 -87
  108. package/dist/config.d.ts +26 -24
  109. package/dist/config.js +38 -18
  110. package/dist/cross-session-settings.d.ts +1 -1
  111. package/dist/delegated-session-owner.d.ts +16 -13
  112. package/dist/delegated-session-owner.js +9 -10
  113. package/dist/deployment-governance.d.ts +16 -16
  114. package/dist/deployment-shape.d.ts +127 -0
  115. package/dist/deployment-shape.js +72 -0
  116. package/dist/device-store.d.ts +1 -1
  117. package/dist/device-ws-hub.d.ts +1 -1
  118. package/dist/egress-redirect.d.ts +1 -1
  119. package/dist/elicitation.d.ts +8 -7
  120. package/dist/elicitation.js +9 -8
  121. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  122. package/dist/env-facts.d.ts +10 -9
  123. package/dist/env-facts.js +1 -1
  124. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  125. package/dist/exec-bounds.d.ts +2 -2
  126. package/dist/execution-lane-caps.d.ts +31 -43
  127. package/dist/execution-lane-caps.js +0 -13
  128. package/dist/file-history-capture.d.ts +9 -9
  129. package/dist/file-history-disclosure.d.ts +25 -11
  130. package/dist/file-history-disclosure.js +25 -14
  131. package/dist/fleet/drain-entry.d.ts +2 -2
  132. package/dist/fleet/fleet-bus.d.ts +22 -14
  133. package/dist/fleet/fleet-bus.js +5 -5
  134. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  135. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  136. package/dist/fleet-client.d.ts +45 -14
  137. package/dist/fleet-client.js +24 -4
  138. package/dist/fleet-lease.d.ts +23 -19
  139. package/dist/fleet-lease.js +31 -23
  140. package/dist/governance-http-status.d.ts +2 -2
  141. package/dist/hooks/hook-llm.d.ts +7 -7
  142. package/dist/hooks/hook-llm.js +14 -8
  143. package/dist/hooks/hook-runner.d.ts +58 -31
  144. package/dist/hooks/hook-runner.js +37 -19
  145. package/dist/host-decision.d.ts +5 -5
  146. package/dist/host-lsp-manager.d.ts +5 -5
  147. package/dist/hosted-posture.d.ts +23 -13
  148. package/dist/hosted-posture.js +4 -9
  149. package/dist/http/admission.d.ts +2 -2
  150. package/dist/http/admission.js +20 -5
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +2 -1
  153. package/dist/http/checkpoint-ctx.d.ts +62 -17
  154. package/dist/http/checkpoint-ctx.js +78 -35
  155. package/dist/http/dispatch.d.ts +3 -3
  156. package/dist/http/dispatch.js +9 -9
  157. package/dist/http/durable-run-leg.js +4 -3
  158. package/dist/http/idempotency.d.ts +2 -2
  159. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  160. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  161. package/dist/http/owner-access.d.ts +4 -6
  162. package/dist/http/owner-access.js +1 -1
  163. package/dist/http/principal-gate.d.ts +7 -7
  164. package/dist/http/principal-gate.js +3 -2
  165. package/dist/http/readiness.d.ts +1 -1
  166. package/dist/http/request-guards.d.ts +4 -4
  167. package/dist/http/request-guards.js +2 -1
  168. package/dist/http/resume-ctx-read.d.ts +9 -23
  169. package/dist/http/resume-ctx-read.js +2 -3
  170. package/dist/http/resume-legs.d.ts +3 -3
  171. package/dist/http/resume-legs.js +11 -8
  172. package/dist/http/route-ctx.d.ts +29 -29
  173. package/dist/http/route-table.d.ts +9 -9
  174. package/dist/http/routes/agents-roster.d.ts +1 -1
  175. package/dist/http/routes/approvals-assistant.d.ts +5 -7
  176. package/dist/http/routes/approvals-assistant.js +101 -26
  177. package/dist/http/routes/background.d.ts +3 -3
  178. package/dist/http/routes/background.js +2 -2
  179. package/dist/http/routes/capabilities.d.ts +1 -1
  180. package/dist/http/routes/capabilities.js +16 -8
  181. package/dist/http/routes/config-catalog.d.ts +1 -1
  182. package/dist/http/routes/devices.d.ts +1 -1
  183. package/dist/http/routes/diagnostics.d.ts +3 -3
  184. package/dist/http/routes/fleet.d.ts +1 -1
  185. package/dist/http/routes/fleet.js +2 -1
  186. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  187. package/dist/http/routes/mcp-reconnect.js +3 -3
  188. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  189. package/dist/http/routes/notify-wake.d.ts +1 -1
  190. package/dist/http/routes/notify-wake.js +2 -2
  191. package/dist/http/routes/rules.d.ts +1 -1
  192. package/dist/http/routes/runs.js +23 -11
  193. package/dist/http/routes/session-sync.d.ts +1 -1
  194. package/dist/http/routes/session-sync.js +97 -46
  195. package/dist/http/routes/sessions-list.js +1 -1
  196. package/dist/http/routes/sessions.js +43 -53
  197. package/dist/http/routes/tasks.d.ts +1 -1
  198. package/dist/http/routes/trace-usage.d.ts +1 -1
  199. package/dist/http/routes/workflows.d.ts +3 -0
  200. package/dist/http/routes/workflows.js +31 -28
  201. package/dist/http/send.d.ts +5 -5
  202. package/dist/http/server.d.ts +34 -34
  203. package/dist/http/session-inherit-env.d.ts +3 -3
  204. package/dist/http/sse-lifecycle.d.ts +1 -1
  205. package/dist/http/sse-log.d.ts +2 -2
  206. package/dist/http/submit-ctx.js +1 -1
  207. package/dist/http/sync-submit-body.d.ts +1 -1
  208. package/dist/http/verify-rounds.d.ts +1 -1
  209. package/dist/http/wire-types.d.ts +33 -24
  210. package/dist/index.d.ts +1 -0
  211. package/dist/index.js +1 -0
  212. package/dist/instruction-source-notice.d.ts +2 -2
  213. package/dist/key-resolver.d.ts +3 -3
  214. package/dist/lane-home-probe.d.ts +1 -1
  215. package/dist/leader/diffout.d.ts +1 -1
  216. package/dist/leader/diffup.d.ts +2 -2
  217. package/dist/leader/endpoint.d.ts +1 -1
  218. package/dist/leader/fanout.d.ts +1 -1
  219. package/dist/leader/leader.d.ts +4 -4
  220. package/dist/leader/merge.d.ts +3 -3
  221. package/dist/leader/repair-wire.d.ts +1 -1
  222. package/dist/leader/wire.d.ts +6 -6
  223. package/dist/list-entry-display.d.ts +1 -1
  224. package/dist/lsp-evict.d.ts +1 -1
  225. package/dist/mcp-assertion-header.d.ts +1 -1
  226. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  227. package/dist/memory-operator-faces.d.ts +1 -1
  228. package/dist/memory-posture.js +4 -2
  229. package/dist/memory-project-layer.d.ts +1 -1
  230. package/dist/memory-scope.d.ts +19 -19
  231. package/dist/memory-store-refusal.d.ts +4 -4
  232. package/dist/model-entry-headers.d.ts +2 -2
  233. package/dist/model-entry-refusal.d.ts +17 -17
  234. package/dist/model-provider.d.ts +10 -10
  235. package/dist/model-reach-scope.d.ts +1 -1
  236. package/dist/model-route-endpoint.d.ts +6 -6
  237. package/dist/model-route-gap.d.ts +49 -4
  238. package/dist/model-route-gap.js +34 -1
  239. package/dist/model-route-url.d.ts +5 -5
  240. package/dist/model-select.d.ts +15 -6
  241. package/dist/model-select.js +5 -0
  242. package/dist/model-unreachable-notice.d.ts +3 -3
  243. package/dist/namespaced-rule-name.d.ts +15 -5
  244. package/dist/namespaced-rule-name.js +3 -2
  245. package/dist/object-store-buckets.d.ts +13 -0
  246. package/dist/object-store-buckets.js +3 -0
  247. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  248. package/dist/observability/cost-taxonomy.d.ts +1 -1
  249. package/dist/observability/err-text.d.ts +1 -1
  250. package/dist/observability/fail-open.d.ts +17 -13
  251. package/dist/observability/fail-open.js +17 -13
  252. package/dist/observability/metrics.d.ts +3 -3
  253. package/dist/observability/metrics.js +1 -1
  254. package/dist/observability/principal-context.d.ts +4 -1
  255. package/dist/observability/principal-context.js +6 -1
  256. package/dist/observability/run-terminal.d.ts +36 -36
  257. package/dist/observability/secret-env-scrub.d.ts +3 -3
  258. package/dist/observability/tool-trace.d.ts +1 -1
  259. package/dist/operator-ask.d.ts +4 -4
  260. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  261. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  262. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  263. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  264. package/dist/orchestration/workflow-notify-journal.js +17 -0
  265. package/dist/outbound-dispatcher.d.ts +4 -4
  266. package/dist/parent-watch.d.ts +4 -4
  267. package/dist/parked-decide.d.ts +20 -18
  268. package/dist/parked-decide.js +31 -11
  269. package/dist/parked-revive-surface.d.ts +7 -7
  270. package/dist/parked-revive-surface.js +2 -3
  271. package/dist/peer-directory.d.ts +5 -4
  272. package/dist/peer-directory.js +6 -6
  273. package/dist/permission-rule-list.d.ts +10 -1
  274. package/dist/permission-rule-list.js +7 -5
  275. package/dist/permission-rule-vocab.d.ts +2 -2
  276. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  277. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  278. package/dist/plugins/approval-ask-store-file.js +6 -3
  279. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  280. package/dist/plugins/approval-ask-store-memory.js +11 -7
  281. package/dist/plugins/approval-ask-store-sql.d.ts +42 -15
  282. package/dist/plugins/approval-ask-store-sql.js +21 -5
  283. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  284. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  285. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  286. package/dist/plugins/background-shell-support.d.ts +2 -2
  287. package/dist/plugins/blob-backend.d.ts +1 -1
  288. package/dist/plugins/blob-backend.js +2 -1
  289. package/dist/plugins/caching-session-store.d.ts +23 -32
  290. package/dist/plugins/caching-session-store.js +5 -17
  291. package/dist/plugins/checkpoint-index-columns.d.ts +130 -0
  292. package/dist/plugins/checkpoint-index-columns.js +90 -0
  293. package/dist/plugins/checkpoint-store-sql.d.ts +71 -69
  294. package/dist/plugins/checkpoint-store-sql.js +109 -127
  295. package/dist/plugins/device-store-sql.d.ts +7 -6
  296. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  297. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  298. package/dist/plugins/file-history-store-sql.d.ts +15 -7
  299. package/dist/plugins/file-history-store-sql.js +55 -36
  300. package/dist/plugins/file-run-store.d.ts +8 -8
  301. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  302. package/dist/plugins/fork-routing-session-store.js +1 -1
  303. package/dist/plugins/host-platform.d.ts +10 -10
  304. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  305. package/dist/plugins/image-index-sql.d.ts +1 -1
  306. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  307. package/dist/plugins/local-checkpoint-store.d.ts +10 -10
  308. package/dist/plugins/local-checkpoint-store.js +7 -7
  309. package/dist/plugins/local-session-store.d.ts +34 -38
  310. package/dist/plugins/local-session-store.js +20 -39
  311. package/dist/plugins/local-session-window.d.ts +1 -1
  312. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  313. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  314. package/dist/plugins/memory-run-store.d.ts +4 -4
  315. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  316. package/dist/plugins/one-time-migrations.d.ts +73 -54
  317. package/dist/plugins/one-time-migrations.js +131 -134
  318. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  319. package/dist/plugins/park-commit-watch.d.ts +3 -3
  320. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  321. package/dist/plugins/permission-rule-store-file.js +12 -19
  322. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  323. package/dist/plugins/permission-rule-store-sql.js +67 -24
  324. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  325. package/dist/plugins/pg-pool.d.ts +2 -2
  326. package/dist/plugins/pg-pool.js +5 -2
  327. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  328. package/dist/plugins/pg-session-storage.d.ts +8 -20
  329. package/dist/plugins/pg-session-storage.js +14 -27
  330. package/dist/plugins/remote-env-adb.d.ts +10 -10
  331. package/dist/plugins/remote-env-device.d.ts +10 -9
  332. package/dist/plugins/remote-env-device.js +6 -2
  333. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  334. package/dist/plugins/remote-env-host.d.ts +16 -16
  335. package/dist/plugins/remote-env-k8s.d.ts +26 -13
  336. package/dist/plugins/remote-env-k8s.js +24 -7
  337. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  338. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  339. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  340. package/dist/plugins/remote-scratchpad.js +0 -4
  341. package/dist/plugins/remote-shell.d.ts +6 -6
  342. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  343. package/dist/plugins/retention-store-sql.d.ts +4 -4
  344. package/dist/plugins/roster-store-sql.d.ts +1 -1
  345. package/dist/plugins/run-store-sql.d.ts +8 -8
  346. package/dist/plugins/s3-answer.d.ts +15 -0
  347. package/dist/plugins/s3-answer.js +5 -0
  348. package/dist/plugins/schema-consistency.d.ts +2 -2
  349. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  350. package/dist/plugins/schema-indexes.d.ts +1 -1
  351. package/dist/plugins/schema-live-columns.d.ts +1 -1
  352. package/dist/plugins/session-event-payload.d.ts +4 -4
  353. package/dist/plugins/session-fork.d.ts +34 -0
  354. package/dist/plugins/session-fork.js +29 -0
  355. package/dist/plugins/session-ownership.js +1 -1
  356. package/dist/plugins/session-placement.d.ts +1 -1
  357. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  358. package/dist/plugins/session-store.d.ts +2 -2
  359. package/dist/plugins/session-store.js +2 -2
  360. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  361. package/dist/plugins/snapshot-bucket-presence.d.ts +39 -4
  362. package/dist/plugins/snapshot-bucket-presence.js +35 -7
  363. package/dist/plugins/sql-driver.d.ts +8 -8
  364. package/dist/plugins/sql-errors.d.ts +40 -1
  365. package/dist/plugins/sql-errors.js +49 -1
  366. package/dist/plugins/sql-json-column.d.ts +21 -21
  367. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  368. package/dist/plugins/store-backend.d.ts +17 -16
  369. package/dist/plugins/store-backend.js +3 -3
  370. package/dist/plugins/store-contracts.d.ts +21 -21
  371. package/dist/plugins/store-fault.d.ts +4 -0
  372. package/dist/plugins/store-fault.js +8 -0
  373. package/dist/plugins/task-attachment-store.d.ts +2 -2
  374. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  375. package/dist/plugins/tidb-pool.d.ts +2 -2
  376. package/dist/plugins/tidb-pool.js +10 -3
  377. package/dist/plugins/tidb-session-store.d.ts +16 -26
  378. package/dist/plugins/tidb-session-store.js +15 -27
  379. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  380. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  381. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  382. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  383. package/dist/plugins/web-search.d.ts +19 -5
  384. package/dist/plugins/web-search.js +20 -5
  385. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  386. package/dist/plugins/workflow-journal-payload.js +32 -0
  387. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  388. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  389. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  390. package/dist/posture-source.d.ts +11 -11
  391. package/dist/principal-jwt.d.ts +6 -6
  392. package/dist/project-identity.d.ts +3 -3
  393. package/dist/project-memory.d.ts +4 -4
  394. package/dist/read-face-posture.d.ts +7 -7
  395. package/dist/request-declaration-refusal.d.ts +94 -0
  396. package/dist/request-declaration-refusal.js +78 -0
  397. package/dist/request-image-urls.d.ts +6 -0
  398. package/dist/request-image-urls.js +27 -0
  399. package/dist/request-key-closure.d.ts +6 -1
  400. package/dist/request-key-closure.js +5 -2
  401. package/dist/request-value-closure.d.ts +15 -8
  402. package/dist/request-value-closure.js +2 -0
  403. package/dist/router/route-orchestration.d.ts +11 -16
  404. package/dist/router/route-orchestration.js +2 -12
  405. package/dist/rule-entry-list.d.ts +8 -7
  406. package/dist/rule-entry-list.js +2 -9
  407. package/dist/rules-consent.d.ts +6 -6
  408. package/dist/rules-consent.js +2 -0
  409. package/dist/run-cancel-context.d.ts +5 -5
  410. package/dist/run-local.d.ts +10 -10
  411. package/dist/runs.d.ts +13 -11
  412. package/dist/runs.js +15 -1
  413. package/dist/runtime-caps-resolver.d.ts +6 -6
  414. package/dist/runtime-caps-resolver.js +1 -1
  415. package/dist/runtime-governance.d.ts +9 -9
  416. package/dist/sandbox-pkg-source.d.ts +17 -12
  417. package/dist/sandbox-pkg-source.js +14 -9
  418. package/dist/sealed-key.d.ts +22 -3
  419. package/dist/sealed-key.js +47 -4
  420. package/dist/security.d.ts +23 -26
  421. package/dist/security.js +12 -9
  422. package/dist/server-secret-env.d.ts +10 -10
  423. package/dist/session-children-retire.d.ts +1 -1
  424. package/dist/session-error-wire.d.ts +7 -7
  425. package/dist/session-incarnation.d.ts +65 -37
  426. package/dist/session-incarnation.js +30 -12
  427. package/dist/session-policy-wire.d.ts +27 -5
  428. package/dist/session-policy-wire.js +15 -1
  429. package/dist/session-records-skipped-notice.d.ts +1 -1
  430. package/dist/session-row.d.ts +3 -17
  431. package/dist/session-row.js +4 -0
  432. package/dist/session-sync-kernel.d.ts +4 -4
  433. package/dist/session-sync.d.ts +61 -6
  434. package/dist/session-sync.js +55 -10
  435. package/dist/session-titler.d.ts +7 -6
  436. package/dist/session-titler.js +8 -13
  437. package/dist/session-watch.d.ts +3 -3
  438. package/dist/session-watch.js +4 -4
  439. package/dist/sighup-idle.d.ts +2 -2
  440. package/dist/spec-fields.d.ts +4 -4
  441. package/dist/sql-engine-posture.d.ts +3 -3
  442. package/dist/store-posture.d.ts +2 -2
  443. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  444. package/dist/task-a2a.d.ts +52 -79
  445. package/dist/task-a2a.js +224 -62
  446. package/dist/task-cwd.d.ts +7 -88
  447. package/dist/task-cwd.js +2 -15
  448. package/dist/task-mcp.d.ts +13 -17
  449. package/dist/task-mcp.js +29 -49
  450. package/dist/task-settings.d.ts +30 -18
  451. package/dist/task-settings.js +33 -3
  452. package/dist/task-workflow.d.ts +0 -24
  453. package/dist/task-workflow.js +2 -1
  454. package/dist/terminal.d.ts +5 -5
  455. package/dist/tighten-only-seats.d.ts +7 -6
  456. package/dist/tighten-only-seats.js +1 -1
  457. package/dist/tool-approval.d.ts +166 -207
  458. package/dist/tool-approval.js +61 -61
  459. package/dist/tool-rule-names.d.ts +2 -2
  460. package/dist/trace/core-keyset-guard.d.ts +13 -8
  461. package/dist/trace/engine-notice-wire.d.ts +5 -5
  462. package/dist/trace/engine-notice-wire.js +1 -0
  463. package/dist/trace/exit-seat.d.ts +31 -4
  464. package/dist/trace/exit-seat.js +69 -67
  465. package/dist/trace/ledger-events.d.ts +3 -3
  466. package/dist/trace/ledger-sink.d.ts +1 -1
  467. package/dist/trace/model-segment.d.ts +3 -3
  468. package/dist/trace/project.d.ts +47 -45
  469. package/dist/trace/project.js +33 -1
  470. package/dist/trace/redact.d.ts +61 -31
  471. package/dist/trace/redact.js +394 -153
  472. package/dist/trace/self-minted-wire.d.ts +302 -14
  473. package/dist/trace/self-minted-wire.js +87 -0
  474. package/dist/trace/sema-provenance.d.ts +1 -1
  475. package/dist/trace/task-notification-facets.d.ts +4 -4
  476. package/dist/trace/wire-projection-faces.d.ts +3 -3
  477. package/dist/trace/wire-projection-faces.js +1 -1
  478. package/dist/unattended-permission-mode.d.ts +5 -5
  479. package/dist/url-credential-refusal.d.ts +52 -0
  480. package/dist/url-credential-refusal.js +14 -0
  481. package/dist/url-refusal.d.ts +16 -3
  482. package/dist/url-refusal.js +15 -2
  483. package/dist/usage-analytics.d.ts +2 -2
  484. package/dist/user-input-ledger.d.ts +23 -23
  485. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  486. package/dist/web-admin-client/apply-effective.js +2 -1
  487. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  488. package/dist/web-admin-client/center-request.d.ts +2 -2
  489. package/dist/web-admin-client/facade.d.ts +5 -5
  490. package/dist/web-admin-client/facade.js +1 -1
  491. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  492. package/dist/web-admin-client/http-client.d.ts +4 -4
  493. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  494. package/dist/web-admin-client/pull-state.d.ts +1 -1
  495. package/dist/web-admin-client/read-face.d.ts +2 -2
  496. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  497. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  498. package/dist/web-admin-client/skills-mcp.d.ts +28 -3
  499. package/dist/web-admin-client/skills-mcp.js +29 -1
  500. package/dist/web-admin-client/types.d.ts +16 -9
  501. package/dist/workspace-space.d.ts +32 -3
  502. package/dist/workspace-space.js +26 -0
  503. package/dist/write-protection.d.ts +2 -2
  504. package/package.json +5 -3
  505. package/scripts/drain-check-local.mjs +4 -2
  506. package/scripts/drain-check.mysql.sql +6 -2
  507. package/scripts/drain-check.pg.sql +6 -2
  508. package/skills/loop.md +1 -1
  509. package/skills/schedule.md +1 -1
  510. package/wire-changes/server@7.104.0.json +134 -0
  511. package/wire-changes/server@7.105.0.json +53 -0
  512. package/wire-changes/server@7.106.0.json +475 -0
  513. package/wire-changes/server@7.107.0.json +64 -0
  514. package/wire-changes/server@7.108.0.json +153 -0
  515. package/wire-changes/server@7.109.0.json +46 -0
  516. package/wire-changes/server@7.110.0.json +90 -0
  517. package/wire-changes/server@7.111.0.json +86 -0
  518. package/wire-changes/server@7.112.0.json +60 -0
  519. package/wire-changes/server@7.113.0.json +26 -0
  520. package/wire-changes/server@7.114.0.json +26 -0
  521. package/wire-changes/server@7.115.0.json +97 -0
  522. package/wire-changes/server@7.116.0.json +218 -0
  523. package/wire-changes/server@7.116.1.json +26 -0
  524. package/wire-changes/server@7.117.0.json +65 -0
  525. package/wire-changes/server@7.118.0.json +129 -0
  526. package/wire-changes/server@7.119.0.json +65 -0
  527. package/wire-changes/server@7.120.0.json +89 -0
  528. package/wire-changes/server@7.121.0.json +219 -0
  529. package/wire-changes/server@7.122.0.json +54 -0
  530. package/wire-changes/server@7.123.0.json +26 -0
  531. package/wire-changes/server@7.124.0.json +336 -0
  532. package/wire-changes/server@7.124.1.json +26 -0
  533. package/wire-changes/server@7.125.0.json +111 -0
  534. package/wire-changes/server@7.126.0.json +285 -0
  535. package/wire-changes/server@7.127.0.json +77 -0
  536. package/wire-changes/server@7.127.1.json +26 -0
  537. package/wire-changes/server@7.127.2.json +53 -0
  538. package/wire-changes/server@7.128.0.json +26 -0
  539. package/wire-changes/server@7.129.0.json +106 -0
  540. package/wire-changes/server@7.129.1.json +26 -0
  541. package/wire-changes/server@7.130.0.json +26 -0
  542. package/wire-changes/server@7.131.0.json +118 -0
  543. package/wire-changes/server@7.132.0.json +226 -0
  544. package/wire-changes/server@7.133.0.json +1155 -0
  545. package/wire-changes/server@7.134.0.json +107 -0
  546. package/wire-changes/server@7.135.0.json +174 -0
  547. package/wire-changes/server@7.136.0.json +448 -0
  548. package/dist/http/run-declared-families.d.ts +0 -16
  549. package/dist/http/run-declared-families.js +0 -12
  550. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -2,12 +2,13 @@ import { once } from "node:events";
2
2
  import { randomBytes, createHash } from "node:crypto";
3
3
  import { sessionLogDigest, sessionLogDigestsComparable, StreamingImportValidator, validateFileHistoryExport } from "@sema-agent/core";
4
4
  import { StringDecoder } from "node:string_decoder";
5
- import { exportSessionManifest, fileHistoryImportFace, replayFileHistory, replayPolicyRecords, wipeSessionAttendants } from "../../session-sync.js";
5
+ import { FileHistoryUnreadableError, blobGetterOf, exportSessionManifest, exportedFileHistory, fileHistoryImportFace, replayFileHistory, replayPolicyRecords, wipeSessionAttendants } from "../../session-sync.js";
6
6
  import * as facts from "../../capability-facts.js";
7
7
  import { classifySyncRelationshipByIds, SyncConflictError } from "../../session-sync-kernel.js";
8
8
  import { isUuidShape, legacyUnownedSessionOk, sessionOwnerCellOf } from "../../security.js";
9
9
  import { sendJson, sendError, sendSessionError, sendSessionPolicyError, logRequestError, msg } from "../send.js";
10
10
  import { buildDisplaySafeUrl } from "../../trace/redact.js";
11
+ import { storeFaultClassOf } from "../../plugins/store-fault.js";
11
12
  import { fleetViewOf, gatedPrincipal, explicitOperatorOk, sendUnauthorized, sessionCallerOf } from "../principal-gate.js";
12
13
  const SYNC_BLOB_MAX_BYTES = 64 * 1024 * 1024;
13
14
  const SYNC_NDJSON_LINE_MAX_BYTES = 8 * 1024 * 1024;
@@ -16,6 +17,7 @@ import { SHA256_HEX_RE } from "../../digest-form.js";
16
17
  import { assertNever, SESSION_NOT_FOUND_MESSAGE } from "../route-ctx.js";
17
18
  import { readSessionRulesRecords, describeSessionRulesRecordProblem } from "../../session-policy-wire.js";
18
19
  import { readSessionPinned, readSessionTitle } from "../../session-row.js";
20
+ import { sessionFaceOfHead } from "../../session-incarnation.js";
19
21
  export function createSessionSyncLocal() {
20
22
  const pendingStagings = new Map();
21
23
  const importLeases = new Map();
@@ -55,8 +57,8 @@ export async function handleSessionSync(req, res, match, ctx) {
55
57
  return;
56
58
  }
57
59
  const judgeSessionGate = async () => {
58
- const face = await sessionStorage.sessionFaceOf(sessionId);
59
- const mayTouch = face !== undefined && (scope.fleetWide || face.owner === scope.gateOwner || legacyUnownedSessionOk(deps.config.requirePrincipal, sessionCallerOf(req, deps), await sessionOwnerCellOf(sessionStorage, sessionId, face.owner)));
60
+ const face = sessionFaceOfHead(sessionId, await sessionStorage.headOf(sessionId));
61
+ const mayTouch = face !== undefined && (scope.fleetWide || face.owner === scope.gateOwner || legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(sessionStorage, sessionId, face.owner)));
60
62
  return { face, mayPull: mayTouch, mayPush: face === undefined || mayTouch };
61
63
  };
62
64
  const gate = await judgeSessionGate();
@@ -82,6 +84,11 @@ export async function handleSessionSync(req, res, match, ctx) {
82
84
  return true;
83
85
  return face !== undefined && (await sessionStorage.patchSessionMeta(sessionId, row, face)) !== undefined;
84
86
  };
87
+ const canReplayHistory = fileHistoryImportFace(historyStore) !== undefined;
88
+ const replayHistory = async (envelope, allowReplace) => {
89
+ const r = await replayFileHistory(historyStore, sessionId, envelope, blobGetterOf(historyStore), { allowReplace });
90
+ return r.ok ? undefined : r;
91
+ };
85
92
  if (match.decl.id === "session-sync-manifest") {
86
93
  if (!pullGateOk())
87
94
  return;
@@ -90,7 +97,7 @@ export async function handleSessionSync(req, res, match, ctx) {
90
97
  out = await exportSessionManifest(sessionId, backend, historyStore);
91
98
  }
92
99
  catch (e) {
93
- if (sendSessionPolicyError(res, e))
100
+ if (sendSessionPolicyError(res, e) || sendPullUnreadable(req, res, deps.logger, e))
94
101
  return;
95
102
  throw e;
96
103
  }
@@ -114,7 +121,15 @@ export async function handleSessionSync(req, res, match, ctx) {
114
121
  }
115
122
  afterSeq = n;
116
123
  }
117
- const it = await sessionStorage.exportEntriesStream(sessionId, afterSeq === undefined ? undefined : { afterSeq });
124
+ let it;
125
+ try {
126
+ it = await sessionStorage.exportEntriesStream(sessionId, afterSeq === undefined ? undefined : { afterSeq });
127
+ }
128
+ catch (e) {
129
+ if (sendPullUnreadable(req, res, deps.logger, e))
130
+ return;
131
+ throw e;
132
+ }
118
133
  if (it === null) {
119
134
  sendSessionAbsent();
120
135
  return;
@@ -156,13 +171,29 @@ export async function handleSessionSync(req, res, match, ctx) {
156
171
  return;
157
172
  }
158
173
  const fs = blobs.historyStore;
159
- const envelope = typeof fs.exportHistory === "function" ? await fs.exportHistory(sessionId) : null;
160
- const referenced = envelope !== null && envelope !== undefined && envelope.tracked.some((t) => t.versions.some((v) => v.blobHash === hash));
174
+ let envelope;
175
+ try {
176
+ envelope = await exportedFileHistory(fs, sessionId);
177
+ }
178
+ catch (e) {
179
+ if (sendPullUnreadable(req, res, deps.logger, e))
180
+ return;
181
+ throw e;
182
+ }
183
+ const referenced = envelope !== null && envelope.tracked.some((t) => t.versions.some((v) => v.blobHash === hash));
161
184
  if (!referenced) {
162
185
  sendError(res, 404, "not_found.blob", "blob not found");
163
186
  return;
164
187
  }
165
- const bytes = await fs.getBlob(hash);
188
+ let bytes;
189
+ try {
190
+ bytes = await fs.getBlob(hash);
191
+ }
192
+ catch (e) {
193
+ if (sendPullUnreadable(req, res, deps.logger, e))
194
+ return;
195
+ throw e;
196
+ }
166
197
  if (!bytes) {
167
198
  sendError(res, 404, "not_found.blob", "blob not found");
168
199
  return;
@@ -275,6 +306,17 @@ export async function handleSessionSync(req, res, match, ctx) {
275
306
  sendError(res, 409, "conflict", "sync conflict", { relation: relA });
276
307
  return;
277
308
  }
309
+ if (fileHistory !== null) {
310
+ const distinct = new Set();
311
+ for (const t of fileHistory.tracked)
312
+ for (const v of t.versions)
313
+ if (v.blobHash !== null)
314
+ distinct.add(v.blobHash);
315
+ if (await firstMissingBlob(facts.sessionSyncFileHistory(deps), [...distinct]) !== undefined) {
316
+ sendMissingBlob(res);
317
+ return;
318
+ }
319
+ }
278
320
  let payloadVerified = false;
279
321
  let digestSaysDiffer = false;
280
322
  if (relA.relation === "identical" && srcLogDigest !== undefined) {
@@ -290,8 +332,7 @@ export async function handleSessionSync(req, res, match, ctx) {
290
332
  digestSaysDiffer = true;
291
333
  }
292
334
  if (relA.relation === "identical" && !digestSaysDiffer) {
293
- const blobFaces = facts.sessionSyncFileHistory(deps);
294
- if (fileHistory !== null && blobFaces.available && fileHistoryImportFace(blobFaces.historyStore)) {
335
+ if (fileHistory !== null && canReplayHistory) {
295
336
  if (resolution === "overwrite-dst") {
296
337
  const activeNow = await deps.runStore?.getActiveTaskId(sessionId);
297
338
  if (activeNow) {
@@ -299,11 +340,9 @@ export async function handleSessionSync(req, res, match, ctx) {
299
340
  return;
300
341
  }
301
342
  }
302
- const getBlobA = (h) => blobFaces.historyStore.getBlob(h);
303
- const r = await replayFileHistory(blobFaces.historyStore, sessionId, fileHistory, getBlobA, { allowReplace: resolution === "overwrite-dst" });
304
- const failCode = r.ok ? undefined : r.error.code === "not_found" ? "missing_blob" : r.error.code;
305
- if (!r.ok) {
306
- sendError(res, 422, failCode, `file history import failed (${r.error.code})`);
343
+ const failed = await replayHistory(fileHistory, resolution === "overwrite-dst");
344
+ if (failed !== undefined) {
345
+ sendFileHistoryReplayFailure(res, failed);
307
346
  return;
308
347
  }
309
348
  }
@@ -356,31 +395,6 @@ export async function handleSessionSync(req, res, match, ctx) {
356
395
  return;
357
396
  }
358
397
  }
359
- const fss = historyStore;
360
- if (fileHistory !== null && fileHistoryImportFace(fss) !== undefined) {
361
- const distinct = new Set();
362
- for (const t of fileHistory.tracked)
363
- for (const v of t.versions)
364
- if (v.blobHash !== null)
365
- distinct.add(v.blobHash);
366
- const all = [...distinct];
367
- if (typeof fss.hasBlobs === "function") {
368
- const present = await fss.hasBlobs(all);
369
- const missing = all.find((h) => !present.has(h));
370
- if (missing !== undefined) {
371
- sendError(res, 422, "missing_blob", "missing blob; PUT all referenced blobs before import");
372
- return;
373
- }
374
- }
375
- else if (typeof fss.getBlob === "function") {
376
- for (const hash of all) {
377
- if (!(await fss.getBlob(hash))) {
378
- sendError(res, 422, "missing_blob", "missing blob; PUT all referenced blobs before import");
379
- return;
380
- }
381
- }
382
- }
383
- }
384
398
  const importingPrincipal = scope.fleetWide ? (owner ?? null) : scope.gateOwner;
385
399
  const operatorOk = explicitOperatorOk(gatedPrincipal(req, deps.config), deps.config);
386
400
  const token = randomBytes(8).toString("hex");
@@ -409,7 +423,6 @@ export async function handleSessionSync(req, res, match, ctx) {
409
423
  sendError(res, 404, "not_found.staging", "staging not found");
410
424
  return;
411
425
  }
412
- const getBlob = (h) => historyStore.getBlob ? historyStore.getBlob(h) : Promise.resolve(undefined);
413
426
  const validator = new StreamingImportValidator();
414
427
  let lineBuf = "";
415
428
  let pendingBatch = [];
@@ -515,11 +528,10 @@ export async function handleSessionSync(req, res, match, ctx) {
515
528
  if (pending.resolution === "overwrite-dst" && (committed.relation === "fork" || committed.relation === "stale")) {
516
529
  await wipeSessionAttendants({ fileHistoryStore: historyStore, sessionPolicyStore: deps.sessionPolicyStore, resumeAnchorStore: deps.resumeAnchorStore }, sessionId);
517
530
  }
518
- if (pending.fileHistory !== null && fileHistoryImportFace(historyStore)) {
519
- const r = await replayFileHistory(historyStore, sessionId, pending.fileHistory, getBlob, { allowReplace: pending.resolution === "overwrite-dst" });
520
- const failCode = r.ok ? undefined : r.error.code === "not_found" ? "missing_blob" : r.error.code;
521
- if (!r.ok) {
522
- sendError(res, 422, failCode, `file history import failed (${r.error.code})`);
531
+ if (pending.fileHistory !== null && canReplayHistory) {
532
+ const failed = await replayHistory(pending.fileHistory, pending.resolution === "overwrite-dst");
533
+ if (failed !== undefined) {
534
+ sendFileHistoryReplayFailure(res, failed);
523
535
  cleanupStaging(stagingId);
524
536
  return;
525
537
  }
@@ -574,6 +586,45 @@ export async function handleSessionSync(req, res, match, ctx) {
574
586
  }
575
587
  }
576
588
  }
589
+ function sendPullUnreadable(req, res, logger, e) {
590
+ if (e instanceof FileHistoryUnreadableError) {
591
+ const permanence = e.failure.permanence;
592
+ const advice = permanence === "transient" ? "the history store judged the fault transient: retry later" : permanence === "terminal" ? "the history store judged the fault permanent: retrying will not help until the store is repaired" : "the history store did not judge whether retrying can help";
593
+ sendError(res, 503, "state.file_history_unreadable", `this session's file history cannot be read whole (${e.failure.code}), so nothing was exported — ${advice}`, permanence === undefined ? undefined : { permanence });
594
+ return true;
595
+ }
596
+ if (storeFaultClassOf(e) !== "connection")
597
+ return false;
598
+ logRequestError(logger, req, e);
599
+ sendError(res, 503, "state.file_history_unreadable", "this session's stored state could not be read right now (the store connection failed), so nothing was exported — retry later", { permanence: "transient" });
600
+ return true;
601
+ }
602
+ function sendMissingBlob(res) {
603
+ sendError(res, 422, "missing_blob", "missing blob; PUT all referenced blobs before import");
604
+ }
605
+ function sendFileHistoryReplayFailure(res, failure) {
606
+ if (failure.missingBlob !== undefined) {
607
+ sendMissingBlob(res);
608
+ return;
609
+ }
610
+ const { code, permanence } = failure.error;
611
+ sendError(res, 422, code, `file history import failed (${code})`, permanence === undefined ? undefined : { permanence });
612
+ }
613
+ async function firstMissingBlob(blobFaces, referenced) {
614
+ if (referenced.length === 0)
615
+ return undefined;
616
+ if (!blobFaces.available)
617
+ return referenced[0];
618
+ const store = blobFaces.historyStore;
619
+ if (typeof store.hasBlobs === "function") {
620
+ const present = await store.hasBlobs([...referenced]);
621
+ return referenced.find((h) => !present.has(h));
622
+ }
623
+ for (const hash of referenced)
624
+ if (!(await store.getBlob(hash)))
625
+ return hash;
626
+ return undefined;
627
+ }
577
628
  function sendSessionSyncUnavailable(res, why) {
578
629
  switch (why) {
579
630
  case "store_backend_absent":
@@ -20,7 +20,7 @@ export async function handleSessionsList(req, res, match, ctx) {
20
20
  return;
21
21
  }
22
22
  const lister = listing.lister;
23
- const includeUnowned = !fleetWide && legacyUnownedAmnestyOpen(deps.config.requirePrincipal, gateOwner);
23
+ const includeUnowned = !fleetWide && legacyUnownedAmnestyOpen(deps.config, gateOwner);
24
24
  await handleSessionList(res, lister, new URLSearchParams(match.search), gateOwner, includeUnowned);
25
25
  return;
26
26
  }
@@ -10,6 +10,7 @@ import { MAX_SETTINGS_OUTPUT_STYLE_CHARS, MAX_SETTINGS_ENV_VARS, MAX_SETTINGS_EN
10
10
  import { readWritableSessionPermissionRules } from "../../session-policy-wire.js";
11
11
  import { sendJson, sendError, sendSessionError, sendSessionPolicyError, sseHeaders, httpErrorBody } from "../send.js";
12
12
  import { fleetViewOf, gatedPrincipal, explicitOperatorOk, sessionCallerOf, sessionOwnerReadable, sendPrincipalRefusal, sendUnauthorized } from "../principal-gate.js";
13
+ import { headReadOf, leafOfAdmittedHead, 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";
@@ -73,9 +74,9 @@ export async function handleSessions(req, res, match, ctx) {
73
74
  const { deps } = ctx;
74
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 = leafOfAdmittedHead(head);
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,8 @@ 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 readHead = (id) => evFact.sessionStorage.headOf(id);
294
+ const readOwner = async (id) => (await readHead(id))?.owner;
308
295
  const watch = evFact.watch;
309
296
  const evSession = safeDecode(match.params.sessionId);
310
297
  if (evSession === null) {
@@ -340,13 +327,13 @@ export async function handleSessions(req, res, match, ctx) {
340
327
  return;
341
328
  }
342
329
  sse.sseOwnerLookups++;
343
- const cellP = ownerOf(evSession).then((o) => (o === undefined ? undefined : sessionOwnerCellOf(evFact.sessionStorage, evSession, o)));
344
- void cellP.catch(() => undefined).then(() => { sse.sseOwnerLookups--; });
330
+ const admissionP = readHead(evSession).then(async (head) => (head === undefined ? undefined : { head, cell: await sessionOwnerCellOf(evFact.sessionStorage, evSession, head.owner) }));
331
+ void admissionP.catch(() => undefined).then(() => { sse.sseOwnerLookups--; });
345
332
  let stallTimer;
346
- let cell;
333
+ let admission;
347
334
  try {
348
- cell = await Promise.race([
349
- cellP,
335
+ admission = await Promise.race([
336
+ admissionP,
350
337
  new Promise((r) => { stallTimer = setTimeout(() => r("__stall__"), stallBound); stallTimer.unref?.(); }),
351
338
  ]);
352
339
  }
@@ -356,22 +343,23 @@ export async function handleSessions(req, res, match, ctx) {
356
343
  }
357
344
  if (closed)
358
345
  return;
359
- if (cell === "__stall__") {
346
+ if (admission === "__stall__") {
360
347
  cleanup();
361
348
  res.setHeader("retry-after", "5");
362
349
  sendError(res, 503, "state.sse_owner_lookup_stalled", "session-events owner lookup stalled — retry");
363
350
  return;
364
351
  }
365
- if (cell === undefined) {
352
+ if (admission === undefined) {
366
353
  cleanup();
367
354
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
368
355
  return;
369
356
  }
370
- if (!sessionOwnerOk(req, res, cell)) {
357
+ if (!sessionOwnerOk(req, res, admission.cell)) {
371
358
  cleanup();
372
359
  return;
373
360
  }
374
- const owner = cell.owner;
361
+ leafOfAdmittedHead(admission.head);
362
+ const owner = admission.cell.owner;
375
363
  const q = new URLSearchParams(match.search);
376
364
  const lastLeafId = q.get("lastLeafId");
377
365
  let first = true;
@@ -470,7 +458,7 @@ export async function handleSessions(req, res, match, ctx) {
470
458
  }
471
459
  ownerCheckPending = true;
472
460
  ownerCheckStartedAt = Date.now();
473
- void ownerOf(evSession).then((o) => {
461
+ void readOwner(evSession).then((o) => {
474
462
  ownerCheckPending = false;
475
463
  if (!closed && o !== owner)
476
464
  onEnd();
@@ -670,13 +658,15 @@ export async function handleSessions(req, res, match, ctx) {
670
658
  }
671
659
  const store = rowFact.sessionStorage;
672
660
  const sessionId = match.params.sessionId;
673
- const face = await store.sessionFaceOf(sessionId);
674
- if (face === undefined) {
661
+ const head = await store.headOf(sessionId);
662
+ if (head === undefined) {
675
663
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
676
664
  return;
677
665
  }
666
+ const face = sessionFaceOfHead(sessionId, head);
678
667
  if (!sessionOwnerOk(req, res, await sessionOwnerCellOf(store, sessionId, face.owner)))
679
668
  return;
669
+ leafOfAdmittedHead(head);
680
670
  const read = readSessionRowPatch(await readJson(req));
681
671
  if ("problem" in read) {
682
672
  sendError(res, 400, read.problem.code, read.problem.message);
@@ -698,7 +688,7 @@ export async function handleSessions(req, res, match, ctx) {
698
688
  return;
699
689
  }
700
690
  const fork = forkFact.sessionStorage.fork.bind(forkFact.sessionStorage);
701
- const ownerOf = forkFact.sessionStorage.ownerOf.bind(forkFact.sessionStorage);
691
+ const readOwner = async (id) => (await forkFact.sessionStorage.headOf(id))?.owner;
702
692
  const scope = fleetViewOf(req, deps, "write");
703
693
  if (!scope.fleetWide && scope.gateOwner === null) {
704
694
  sendUnauthorized(res, "identity");
@@ -709,12 +699,12 @@ export async function handleSessions(req, res, match, ctx) {
709
699
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
710
700
  return;
711
701
  }
712
- const owner = await ownerOf(sourceId);
702
+ const owner = await readOwner(sourceId);
713
703
  if (owner === undefined) {
714
704
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
715
705
  return;
716
706
  }
717
- if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config.requirePrincipal, sessionCallerOf(req, deps), await sessionOwnerCellOf(forkFact.sessionStorage, sourceId, owner))) {
707
+ if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(forkFact.sessionStorage, sourceId, owner))) {
718
708
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
719
709
  return;
720
710
  }
@@ -736,7 +726,7 @@ export async function handleSessions(req, res, match, ctx) {
736
726
  return;
737
727
  }
738
728
  const purge = deleteFact.purge;
739
- const ownerOf = deleteFact.sessionStorage.ownerOf.bind(deleteFact.sessionStorage);
729
+ const readOwner = async (id) => (await deleteFact.sessionStorage.headOf(id))?.owner;
740
730
  const scope = fleetViewOf(req, deps, "write");
741
731
  if (!scope.fleetWide && scope.gateOwner === null) {
742
732
  sendUnauthorized(res, "identity");
@@ -747,12 +737,12 @@ export async function handleSessions(req, res, match, ctx) {
747
737
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
748
738
  return;
749
739
  }
750
- const owner = await ownerOf(sessionId);
740
+ const owner = await readOwner(sessionId);
751
741
  if (owner === undefined) {
752
742
  sendJson(res, 200, { deleted: false });
753
743
  return;
754
744
  }
755
- if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config.requirePrincipal, sessionCallerOf(req, deps), await sessionOwnerCellOf(deleteFact.sessionStorage, sessionId, owner))) {
745
+ if (!scope.fleetWide && owner !== scope.gateOwner && !legacyUnownedSessionOk(deps.config, sessionCallerOf(req, deps), await sessionOwnerCellOf(deleteFact.sessionStorage, sessionId, owner))) {
756
746
  sendJson(res, 200, { deleted: false });
757
747
  return;
758
748
  }
@@ -782,7 +772,7 @@ export async function handleSessions(req, res, match, ctx) {
782
772
  return;
783
773
  }
784
774
  const store = policyFact.policyStore;
785
- const ownerOf = policyFact.sessionStorage.ownerOf.bind(policyFact.sessionStorage);
775
+ const readOwner = async (id) => (await policyFact.sessionStorage.headOf(id))?.owner;
786
776
  const principal = gatedPrincipal(req, deps.config);
787
777
  if (deps.config.requirePrincipal && principal === undefined) {
788
778
  sendUnauthorized(res, "identity");
@@ -793,7 +783,7 @@ export async function handleSessions(req, res, match, ctx) {
793
783
  sendError(res, 400, "request.id_invalid", "invalid session id (must be a canonical uuid)");
794
784
  return;
795
785
  }
796
- const owner = await ownerOf(sessionId);
786
+ const owner = await readOwner(sessionId);
797
787
  if (owner === undefined) {
798
788
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
799
789
  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 的同一条前段)。
@@ -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
  */
@@ -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 },