@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
@@ -52,13 +52,13 @@ export declare function deriveDecisionDoorKeyTable(family: DecisionDoorFamily, r
52
52
  * 被两句话抢答)。
53
53
  *
54
54
  * 🔴 **重放不额外过门**,也不需要:`/decide` 的幂等回放(`decideIdempotentReplay`)重放的是**同一次请求的同一份
55
- * 体**、走同一条路由同一道门;plan_review 的反重放是一次性 nonce(S-280),守的也是同一份现写的字节;而续跑重建
55
+ * 体**、走同一条路由同一道门;plan_review 的反重放是一次性 nonce([ref]),守的也是同一份现写的字节;而续跑重建
56
56
  * 读的是盘上的体、走 `resolveSpec` 的宽容层 ⇒ 4xx 砖不到任何存量挂起的任务。**门只站在人(或客户端)现写的
57
57
  * 那份字节上**(与 tasks 面「RESUME 重放不过门」同一条律)。
58
58
  */
59
59
  export declare function decisionBodyKeyIssue(door: DecisionDoorId, raw: unknown, table?: DecisionDoorKeyTable): KeyClosureIssue | null;
60
60
  /**
61
- * S-342 —— 「空串的理由 = 没有理由 = 这是一次**裸拒**」。这条语义只适用于**本仓自铸**的那一个域。
61
+ * [ref] —— 「空串的理由 = 没有理由 = 这是一次**裸拒**」。这条语义只适用于**本仓自铸**的那一个域。
62
62
  *
63
63
  * ## 三个域,三个属主(这才是归一:每个域的读法只写一次,而不是三处各挑一种写法)
64
64
  * `body.reason` 在这条路由上会被读三次,而它们的属主**不是同一个**:
@@ -99,7 +99,7 @@ export type QuestionAnswerCheck = {
99
99
  * Structural check for an operator-supplied QuestionAnswer (durable ask resume, TC-5.4). Strict on the
100
100
  * load-bearing shape — `answers[]` non-empty, each `{header: string, selected: string[], note?: string}` —
101
101
  * so a typo'd payload fails the request instead of resuming the task with an answer the tool can't use.
102
- * S-452 起**同时闭键**:词表外的键(拼错 / 未来键 / `__proto__`)拒不丢。
102
+ * [ref] 起**同时闭键**:词表外的键(拼错 / 未来键 / `__proto__`)拒不丢。
103
103
  */
104
104
  export declare function checkQuestionAnswer(v: unknown): QuestionAnswerCheck;
105
105
  /** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
@@ -128,7 +128,7 @@ export declare function handleApprovalsAssistant(req: IncomingMessage, res: Serv
128
128
  export type PendingProjectionDeployment = GovernancePosture & Pick<GateIntentView, "approvalRequire" | "approvalDeny" | "approvalNeverAuto">;
129
129
  export declare function streamApprovals(req: IncomingMessage, res: ServerResponse, cs: Pick<CheckpointStoreFull, "listPending">,
130
130
  /**
131
- * 🔴 S-454:**第二条 diff 源** —— `GET /v1/approvals` 的 `livePending` 那**同一只**读函数
131
+ * 🔴 [ref]:**第二条 diff 源** —— `GET /v1/approvals` 的 `livePending` 那**同一只**读函数
132
132
  * (`Pick` 而不是另立接口:同源是结构事实,不是两处各写一份的约定)。
133
133
  *
134
134
  * 为什么必须同源:消费方(client-core `hitl/approvalsFeed`)对 stream 上任一非 heartbeat 事件的
@@ -136,7 +136,7 @@ export declare function streamApprovals(req: IncomingMessage, res: ServerRespons
136
136
  * 一条只在拉面存在的行则永远等不到催人事件。
137
137
  *
138
138
  * `undefined` = 本部署无 live 审批面(`TOOL_APPROVAL_ENABLED=false` ⇒ 协调器未装配)⇒ 本源整个
139
- * 缺席,流的字节与 S-454 之前逐字相同(能力缺席 = 零变化,不是空数组)。**位置在 `pollMs` 之前**
139
+ * 缺席,流的字节与 [ref] 之前逐字相同(能力缺席 = 零变化,不是空数组)。**位置在 `pollMs` 之前**
140
140
  * 与 `governance` 同一条理由:`pollMs` 只有测试传,而本参数是每个生产调用点都必须表态的那一个。
141
141
  */
142
142
  live: Pick<ToolApprovalCoordinator, "listLivePending"> | undefined, scope: string | undefined,
@@ -2,7 +2,8 @@ import { screenedGate } from "../../trace/project.js";
2
2
  import { hostDecisionFacts, readDecidedBy, retiredDecisionKeyFacts, DECIDED_BY_NOT_IN_PROOF, DECIDED_BY_OUTSIDE_CLOSED_SET } from "../../host-decision.js";
3
3
  import { sameExecutionRecord } from "@sema-agent/core";
4
4
  import { DECIDED_REPLAY_SCAN_CAP, approvalPayloadFingerprint } from "../../plugins/checkpoint-store-sql.js";
5
- import { APPROVAL_GATE_KINDS, carriesDeploymentListQuestion, standingAnswerDurablyRecordable } from "../../tool-approval.js";
5
+ import { carriesDeploymentListQuestion, standingAnswerDurablyRecordable } from "../../tool-approval.js";
6
+ import { APPROVAL_GATE_KINDS } from "../../approval-content-kind.js";
6
7
  import { isParkedRunStatus } from "../../plugins/store-contracts.js";
7
8
  import { principalFrom, decodeCheckpointScope, ownerOfCheckpointScope, CHECKPOINT_PUBLIC_SCOPE, PRINCIPAL_TOKEN_HEADER, APPROVAL_MAC_HEADER, APPROVAL_MAC_KID_HEADER } from "../../security.js";
8
9
  import { editedPlanBinding, isWellFormedUnicode, verifyDirectDoorProof } from "../../principal-jwt.js";
@@ -14,7 +15,7 @@ import { redactRiskDescriptor } from "../../observability/run-terminal.js";
14
15
  import { buildRunName } from "../../fleet/fleet-bus.js";
15
16
  import { sleep } from "../sse-log.js";
16
17
  import { bindSseLifecycle } from "../sse-lifecycle.js";
17
- import { sendJson, sendError, sseHeaders, SSE_MAX_STREAM_MS, SSE_HEARTBEAT_IDLE_MS } from "../send.js";
18
+ import { sendJson, sendError, sseHeaders, logRequestError, SSE_MAX_STREAM_MS, SSE_HEARTBEAT_IDLE_MS } from "../send.js";
18
19
  import { gatedPrincipal, explicitOperatorOk, sendPrincipalRefusal, sessionCallerOf } from "../principal-gate.js";
19
20
  import { readOwnedRun, readOwnedSession } from "../owner-access.js";
20
21
  import { governanceOriginOf } from "../../runtime-governance.js";
@@ -23,17 +24,17 @@ import { callGrantBindingOf, questionGrantBindingOf } from "../../standing-answe
23
24
  import { sendResumeOutcome } from "../route-ctx.js";
24
25
  import { assertNever } from "../route-ctx.js";
25
26
  import * as facts from "../../capability-facts.js";
26
- import { readResumeCtx } from "../resume-ctx-read.js";
27
+ import { KEEP_SEALED, readResumeCtx } from "../resume-ctx-read.js";
27
28
  import { StoreCorruptError } from "../../plugins/sql-json-column.js";
28
29
  import { recordFailOpen } from "../../observability/fail-open.js";
29
30
  import { durableRowIdentity } from "../../checkpoint-identity.js";
30
31
  import { MAX_KEY_ECHO, keyClosureClause, scanKeyClosure } from "../../request-key-closure.js";
31
32
  import { fieldConflictFacts } from "../../field-conflict.js";
32
33
  const DECIDE_BODY_DECLARED_KEYS = [
33
- "answer", "boundCallId", "boundInputHash", "checkpointToken", "decidedBy", "decision", "reason", "remember", "updatedInput",
34
+ "answer", "boundCallId", "boundInputHash", "checkpointToken", "decidedBy", "decision", "feedback", "reason", "remember", "updatedInput",
34
35
  ];
35
36
  const DECIDE_PROOF_COVERED_KEYS = ["answer", "boundCallId", "boundInputHash", "decision", "reason"];
36
- const DECIDE_NOT_IN_PROOF_KEYS = ["checkpointToken", "decidedBy", "remember", "updatedInput"];
37
+ const DECIDE_NOT_IN_PROOF_KEYS = ["checkpointToken", "decidedBy", "feedback", "remember", "updatedInput"];
37
38
  const PLAN_REVIEW_BODY_DECLARED_KEYS = [
38
39
  "boundCallId", "decidedBy", "decision", "editedPlan", "permissionModeAfter", "reason",
39
40
  ];
@@ -285,8 +286,16 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
285
286
  const scope = operator
286
287
  ? (new URLSearchParams(match.search).get("owner") ?? undefined)
287
288
  : ownScope;
289
+ let durableRows;
290
+ try {
291
+ durableRows = await cs.listPending(scope);
292
+ }
293
+ catch (err) {
294
+ sendApprovalsReadFailure(req, res, deps.logger, err);
295
+ return;
296
+ }
288
297
  sendJson(res, 200, {
289
- pending: (await cs.listPending(scope)).map((r) => projectPendingForWire(r, deps.config)),
298
+ pending: durableRows.map((r) => projectPendingForWire(r, deps.config)),
290
299
  serverNowMs: Date.now(),
291
300
  ...(deps.toolApproval ? { livePending: deps.toolApproval.listLivePending(scope) } : {}),
292
301
  ...(deps.approvalAskAudit ? { crashConverged: deps.approvalAskAudit.listCrashConverged(scope) } : {}),
@@ -340,12 +349,21 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
340
349
  if (match.decl.id === "assistant-inbox") {
341
350
  const ownerParam = new URLSearchParams(match.search).get("owner") || undefined;
342
351
  const scope = operator && ownerParam ? ownerParam : ownScope;
343
- const summaries = await cs.listByScope(scope);
352
+ let summaries;
353
+ try {
354
+ summaries = await cs.listByScope(scope);
355
+ }
356
+ catch (err) {
357
+ sendApprovalsReadFailure(req, res, deps.logger, err);
358
+ return;
359
+ }
344
360
  const inbox = (await Promise.all(summaries.map(async (s) => {
345
- const ctxRead = await readResumeCtx(cs.getCtx(s.sessionId));
361
+ const ctxRead = await readResumeCtx(cs.getCtx(s.sessionId), KEEP_SEALED);
346
362
  if (ctxRead.kind === "corrupt")
347
363
  recordFailOpen("server.assistant-inbox.objective-ctx-corrupt", ctxRead.where);
348
- const objective = ctxRead.kind === "ok" ? (ctxRead.ctx.body?.objective ?? null) : null;
364
+ const storedBody = ctxRead.kind === "ok" ? ctxRead.ctx.body : undefined;
365
+ const storedObjective = typeof storedBody === "object" && storedBody !== null ? storedBody.objective : undefined;
366
+ const objective = typeof storedObjective === "string" ? storedObjective : null;
349
367
  const input = s.toolInput != null ? redactedPreview(s.toolInput) : null;
350
368
  return {
351
369
  sessionId: s.sessionId,
@@ -383,7 +401,14 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
383
401
  return;
384
402
  }
385
403
  const runStore = ledger.runStore;
386
- const summaries = await cs.listByScope(scope);
404
+ let summaries;
405
+ try {
406
+ summaries = await cs.listByScope(scope);
407
+ }
408
+ catch (err) {
409
+ sendApprovalsReadFailure(req, res, deps.logger, err);
410
+ return;
411
+ }
387
412
  const byGate = new Map(summaries.map((s) => [s.sessionId, s]));
388
413
  const runs = await runStore.listRuns({ owner: ownerOfCheckpointScope(scope), limit: 100 });
389
414
  const tasks = runs
@@ -655,7 +680,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
655
680
  const body = (await readJson(req));
656
681
  const decision = body?.decision === "approve" ? "approve" : body?.decision === "deny" ? "deny" : undefined;
657
682
  if (!decision) {
658
- sendError(res, 400, "request.body_shape", "body must be { decision: 'approve' | 'deny', reason?, answer?, checkpointToken?, boundCallId?, boundInputHash?, updatedInput?, remember?, decidedBy? }", retiredDecisionKeyFacts(body)?.extra);
683
+ sendError(res, 400, "request.body_shape", "body must be { decision: 'approve' | 'deny', reason?, answer?, checkpointToken?, boundCallId?, boundInputHash?, updatedInput?, remember?, decidedBy?, feedback? }", retiredDecisionKeyFacts(body)?.extra);
659
684
  return;
660
685
  }
661
686
  {
@@ -719,6 +744,10 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
719
744
  return;
720
745
  }
721
746
  }
747
+ if (body.feedback !== undefined && typeof body.feedback !== "string") {
748
+ sendError(res, 400, "request.field_invalid", "feedback must be a string (the words the approving person wrote on the card; omit the key when there are none)");
749
+ return;
750
+ }
722
751
  if (deps.config.directDoorActive && body.updatedInput !== undefined) {
723
752
  sendError(res, 400, "updated_input_not_in_proof", "updatedInput is not supported on a direct-door worker (not covered by the decision proof)");
724
753
  return;
@@ -727,6 +756,10 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
727
756
  sendError(res, 400, "checkpoint_token_not_in_proof", "checkpointToken is not supported on a direct-door worker (not covered by the decision proof); bind the decision with boundCallId and boundInputHash instead");
728
757
  return;
729
758
  }
759
+ if (deps.config.directDoorActive && body.feedback !== undefined) {
760
+ sendError(res, 400, "feedback_not_in_proof", "feedback is not supported on a direct-door worker (not covered by the decision proof)");
761
+ return;
762
+ }
730
763
  const decidedByReading = readDecidedBy(body.decidedBy, deps.config.directDoorActive);
731
764
  switch (decidedByReading.kind) {
732
765
  case "not_in_proof":
@@ -743,11 +776,20 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
743
776
  }
744
777
  }
745
778
  const decidedBy = decidedByReading.decidedBy;
779
+ if (body.feedback !== undefined && decision !== "approve") {
780
+ sendError(res, 400, "request.field_conflict", "feedback is only valid with decision 'approve' — the words of a denial are its reason", fieldConflictFacts("approval_feedback", ["feedback", "decision"]));
781
+ return;
782
+ }
783
+ if (body.feedback !== undefined && decidedBy !== "person") {
784
+ sendError(res, 400, "request.field_conflict", "feedback is only valid on a person's decision — the agent reads it as the user's own words, which a policy decision cannot carry", fieldConflictFacts("approval_feedback", ["feedback", "decidedBy"]));
785
+ return;
786
+ }
746
787
  const binding = {
747
788
  checkpointToken: body.checkpointToken,
748
789
  boundCallId: body.boundCallId,
749
790
  boundInputHash: body.boundInputHash,
750
791
  updatedInput: body.updatedInput,
792
+ ...(typeof body.feedback === "string" ? { feedback: body.feedback } : {}),
751
793
  };
752
794
  let deciderPrincipal = principal;
753
795
  if (deps.config.directDoorActive) {
@@ -811,6 +853,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
811
853
  ...(decision === "approve" && binding.updatedInput !== undefined ? { updatedInput: binding.updatedInput } : {}),
812
854
  ...(answer !== undefined ? { answer } : {}),
813
855
  ...((r) => (r !== undefined ? { reason: r } : {}))(decisionReasonOf(body)),
856
+ ...(binding.feedback !== undefined ? { feedback: binding.feedback } : {}),
814
857
  },
815
858
  deciderPrincipal,
816
859
  explicitOperator,
@@ -827,6 +870,25 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
827
870
  return assertNever(match.decl.id);
828
871
  }
829
872
  const APPROVALS_STREAM_POLL_MS = 3000;
873
+ function approvalsReadFailureOf(err) {
874
+ return err instanceof StoreCorruptError ? "approvals.read_corrupt" : "approvals.read_unavailable";
875
+ }
876
+ function sendApprovalsReadFailure(req, res, logger, err) {
877
+ logRequestError(logger, req, err);
878
+ const failure = approvalsReadFailureOf(err);
879
+ switch (failure) {
880
+ case "approvals.read_corrupt":
881
+ sendError(res, 500, "approvals.read_corrupt", "a stored approval row cannot be read - retrying this request will fail the same way until an operator repairs or removes the row");
882
+ return;
883
+ case "approvals.read_unavailable":
884
+ sendError(res, 503, "approvals.read_unavailable", "the approvals queue could not be read right now - retry this request; until a read succeeds, this answer does not mean nothing is pending");
885
+ return;
886
+ default: {
887
+ const unhandled = failure;
888
+ throw new Error(`approvals read failure word without an answer: ${String(unhandled)}`);
889
+ }
890
+ }
891
+ }
830
892
  function redactPendingDisclosures(row) {
831
893
  const rd = row.riskDescriptor;
832
894
  if (rd === null || rd === undefined)
@@ -898,13 +960,25 @@ export async function streamApprovals(req, res, cs, live, scope, governance, pol
898
960
  snapshot = { pending, livePending: live ? live.listLivePending(scope) : [] };
899
961
  }
900
962
  catch (err) {
901
- if (err instanceof StoreCorruptError) {
902
- if (!res.writableEnded)
903
- res.write(`event: error\ndata: ${JSON.stringify({ type: "error", errorCode: "approvals.read_corrupt", message: "a stored approval row cannot be read - this stream is closing, and reconnecting will fail the same way until an operator repairs or removes the row" })}\n\n`);
904
- break;
963
+ const failure = approvalsReadFailureOf(err);
964
+ let endStream = false;
965
+ switch (failure) {
966
+ case "approvals.read_corrupt":
967
+ if (!res.writableEnded)
968
+ res.write(`event: error\ndata: ${JSON.stringify({ type: "error", errorCode: "approvals.read_corrupt", message: "a stored approval row cannot be read - this stream is closing, and reconnecting will fail the same way until an operator repairs or removes the row" })}\n\n`);
969
+ endStream = true;
970
+ break;
971
+ case "approvals.read_unavailable":
972
+ if (!res.writableEnded)
973
+ res.write(`event: error\ndata: ${JSON.stringify({ type: "error", errorCode: "approvals.read_unavailable", message: "the approvals queue could not be read - this stream stays open and retries on its next poll; until a read succeeds, silence here does not mean nothing is pending" })}\n\n`);
974
+ break;
975
+ default: {
976
+ const unhandled = failure;
977
+ throw new Error(`approvals read failure word without a stream answer: ${String(unhandled)}`);
978
+ }
905
979
  }
906
- if (!res.writableEnded)
907
- res.write(`event: error\ndata: ${JSON.stringify({ type: "error", errorCode: "approvals.read_unavailable", message: "the approvals queue could not be read - this stream stays open and retries on its next poll; until a read succeeds, silence here does not mean nothing is pending" })}\n\n`);
980
+ if (endStream)
981
+ break;
908
982
  }
909
983
  if (snapshot !== undefined) {
910
984
  durableLane.tick(snapshot.pending);
@@ -1,11 +1,11 @@
1
1
  /**
2
- * S-745(core 7.32.0 #1107 的 server 半场;wire 形 [ref] / [ref] / [ref] 定)—— **会话后台任务的两只读口**:
2
+ * [ref](core 7.32.0 [ref] 的 server 半场;wire 形 [ref] / [ref] / [ref] 定)—— **会话后台任务的两只读口**:
3
3
  *
4
4
  * `GET /v1/sessions/:id/background` → 200 `{ rows: [{ id, description?, type, status, createdAt, sessionScoped, retained? }] }`
5
5
  * `POST /v1/sessions/:id/background/stop` body `{ includeRetained: boolean }` → 200 `{ receipts: [{ id, outcome }] }`
6
6
  *
7
- * 消费方:cli L-694 ①(删前核登记)/ L-686(退出三选一:「Exit and stop tasks」= `includeRetained:true`,`sema kill` =
8
- * `includeRetained:false`,两臂都等受据再退)/ client-core CC-194 B 半(对账谓词)。老 server 404 ⇒ 壳只出 Stay / 退出两臂。
7
+ * 消费方:cli [ref] ①(删前核登记)/ [ref](退出三选一:「Exit and stop tasks」= `includeRetained:true`,`sema kill` =
8
+ * `includeRetained:false`,两臂都等受据再退)/ client-core [ref] B 半(对账谓词)。老 server 404 ⇒ 壳只出 Stay / 退出两臂。
9
9
  *
10
10
  * ── 读口:逐字投 core `list()` 行 ─────────────────────────────────────────────────────────────────
11
11
  * 读的是**进程内**注册表(`defaultTaskRegistry.list`),访问元组 = 会话自己的 `{ owner: sid, sessionId: sid, scope }`
@@ -60,10 +60,10 @@ export async function handleBackground(req, res, match, ctx) {
60
60
  }
61
61
  const owned = facts.sessionOwnership(deps);
62
62
  if (!owned.available) {
63
- sendError(res, 501, "capability.session_ownership_required", "the session background faces require the session-ownership face (sessionStorage.ownerOf)");
63
+ sendError(res, 501, "capability.session_ownership_required", "the session background faces require the session-ownership face (sessionStorage.headOf)");
64
64
  return;
65
65
  }
66
- const owner = await owned.sessionStorage.ownerOf(sessionId);
66
+ const owner = (await owned.sessionStorage.headOf(sessionId))?.owner;
67
67
  if (owner === undefined) {
68
68
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
69
69
  return;
@@ -13,7 +13,7 @@ import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
13
13
  * 的语义原样 =「本域已应答」;走到函数尾才是「没匹配上」,置 `miss.fell` 交回装配器继续下一个域。
14
14
  * 跨域的东西(deps / 助手 / 单域状态 / 每请求量)一律在首行解构出来,于是下面每一行都逐字不变。 */
15
15
  /**
16
- * S-481 —— 本域独占的运行期状态(每 `createHttpServer` 实例一份)。**模块级不行**:测试里一个进程建几十台
16
+ * [ref] —— 本域独占的运行期状态(每 `createHttpServer` 实例一份)。**模块级不行**:测试里一个进程建几十台
17
17
  * server,一张模块级缓存会把 A 台的探测读数发给 B 台,一只模块级限速窗会让第二台起来就被第一台的计数挡住。
18
18
  */
19
19
  export interface CapabilitiesLocal {
@@ -1,12 +1,12 @@
1
1
  import { PERMISSION_MODES, USER_ATTACHMENT_SEAT, expandTiers, reasoningEffortLevelsOf, routePairingStatus } from "@sema-agent/core";
2
- import { modelImageInput, modelReasoningDecl, isAtMentionable, selectableCatalog } from "../../model-select.js";
2
+ import { modelImageInput, modelReasoningDecl, isAtMentionable, selectableAliasNames, selectableCatalog } from "../../model-select.js";
3
3
  import { buildDroppedEntriesWire } from "../../web-admin-client/read-warnings.js";
4
4
  import { buildCandidateRejectedWire } from "../../web-admin-client/candidate-gate.js";
5
5
  import { buildModelPlaneFace } from "../../model-plane-face.js";
6
6
  import { isRosterGateArmed } from "../../config.js";
7
7
  import { modelKeyPoisonOf, resolveModelApiKey } from "../../key-resolver.js";
8
8
  import { projectSealedKeyCapability } from "../../sealed-key.js";
9
- import { cwdHonored, deviceCwdHonored } from "../../task-cwd.js";
9
+ import { DEPLOYMENT_SHAPE_PREDICATES } from "../../deployment-shape.js";
10
10
  import { taskWriteFaceRefusal } from "../../hosted-posture.js";
11
11
  import { leaderEntryRefusal, leaderRunEntry } from "../../leader/run-entry.js";
12
12
  import { autonomyKeepsOpenWriteFace, autonomyModeFloor } from "../../runtime-governance.js";
@@ -32,7 +32,9 @@ import * as facts from "../../capability-facts.js";
32
32
  import { judgeAutoModeArming } from "../../auto-mode-face.js";
33
33
  import { coercePermissionModeStrict, PERMISSION_MODE_WORDS, taskHooksHonored } from "../../task-settings.js";
34
34
  import { gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
35
+ import { headReadOf } from "../../session-incarnation.js";
35
36
  import { callerTrust } from "../caller-trust.js";
37
+ import { sessionRulesNamespaceFormsHonored } from "../../session-policy-wire.js";
36
38
  function routePairingOf(deps, name, m) {
37
39
  if (modelKeyPoisonOf(name, deps.config.modelApiKeyEnv ?? {}, process.env, deps.config.modelApiKeys ?? {}) !== undefined)
38
40
  return "unknown";
@@ -131,7 +133,7 @@ export async function handleCapabilities(req, res, match, ctx) {
131
133
  scratchpadDir: true,
132
134
  subagentSteer: facts.subagentSteer(deps).available,
133
135
  subagentResume: facts.subagentSteer(deps).available,
134
- taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: cwdHonored(deps.config) || deviceCwdHonored(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), tightenOnlySeats: true },
136
+ taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), tightenOnlySeats: true, approvalFrameFamilies: true },
135
137
  settings: { permissions: { allowGrant: true, allowLayer: true, callerTrust: callerTrust(req, deps.config).trust } },
136
138
  permissionModeAuto: {
137
139
  accepted: true,
@@ -143,6 +145,7 @@ export async function handleCapabilities(req, res, match, ctx) {
143
145
  writeProtection: projectWriteProtectionCapability(deps.writeProtection),
144
146
  appendSystemPrompt: true,
145
147
  outputStyle: true,
148
+ projectMemory: true,
146
149
  compactionModel: true,
147
150
  subagentOutput: facts.subagentOutput(deps).available,
148
151
  subagentStream: facts.subagentOutput(deps).available,
@@ -154,9 +157,10 @@ export async function handleCapabilities(req, res, match, ctx) {
154
157
  disableSkills: true,
155
158
  userInvokedSkills: true,
156
159
  skillToolLists: true,
160
+ scenarioSkills: true,
157
161
  userAttachments: USER_ATTACHMENT_SEAT,
158
- projectContext: cwdHonored(deps.config),
159
- callerCwd: cwdHonored(deps.config) || deviceCwdHonored(deps.config),
162
+ projectContext: DEPLOYMENT_SHAPE_PREDICATES.callerOwnsWorkerDisk.holds(deps.config),
163
+ callerCwd: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config),
160
164
  taskWriteFaceOpen: taskWriteFaceRefusal(deps.config) === undefined && autonomyKeepsOpenWriteFace(deps.config.autonomy),
161
165
  executionLane: projectExecutionLaneCapability(deps.config),
162
166
  mcpInjection: facts.mcpInjection(deps).available,
@@ -186,12 +190,13 @@ export async function handleCapabilities(req, res, match, ctx) {
186
190
  sessionSearch: facts.sessionList(deps).available,
187
191
  sessionFork: facts.sessionFork(deps).available,
188
192
  sessionDelete: facts.sessionDelete(deps).available,
189
- resumeAt: Boolean(deps.resumeAnchorStore && deps.sessionStorage?.getLeafId),
193
+ resumeAt: Boolean(deps.resumeAnchorStore && headReadOf(deps.sessionStorage)),
190
194
  promptSuggestions: true,
191
195
  sessionPolicy: facts.sessionPolicy(deps).available,
196
+ sessionRulesNamespaceForms: sessionRulesNamespaceFormsHonored(),
192
197
  rewindFiles: Boolean(deps.fileHistoryStore),
193
198
  restoreFiles: Boolean(deps.fileHistoryStore),
194
- rewindFilesTo: Boolean(deps.fileHistoryStore && deps.resumeAnchorStore && deps.sessionStorage?.getLeafId),
199
+ rewindFilesTo: Boolean(deps.fileHistoryStore && deps.resumeAnchorStore && headReadOf(deps.sessionStorage)),
195
200
  fileHistoryCapture: fileHistoryCaptureOf(deps.fileHistoryStore, deps.config.fileHistoryCapture),
196
201
  scheduler: facts.hostScheduler(deps.config).available,
197
202
  sessionSync: facts.sessionSync(deps).available,
@@ -258,6 +263,7 @@ export async function handleCapabilities(req, res, match, ctx) {
258
263
  case "models": {
259
264
  const atCatalog = selectableCatalog(deps.config.models, deps.config.tiers, deps.config.modelRefusals);
260
265
  const atMention = deps.config.atMention;
266
+ const mentionBit = (name) => (atMention.mode !== "all" ? { atMentionable: isAtMentionable(name, atCatalog, atMention, deps.config.modelRefusals) } : {});
261
267
  const models = Object.entries(deps.config.models)
262
268
  .filter(([name]) => name !== "default")
263
269
  .map(([name, m]) => ({
@@ -270,7 +276,7 @@ export async function handleCapabilities(req, res, match, ctx) {
270
276
  ...(m.maxTokens ? { maxOutputTokens: m.maxTokens } : {}),
271
277
  ...((levels) => (levels !== undefined ? { supportedEffortLevels: [...levels] } : {}))(reasoningEffortLevelsOf(m)),
272
278
  ...(m.compat !== undefined ? { compat: m.compat } : {}),
273
- ...(atMention.mode !== "all" ? { atMentionable: isAtMentionable(name, atCatalog, atMention, deps.config.modelRefusals) } : {}),
279
+ ...mentionBit(name),
274
280
  routePairing: routePairingOf(deps, name, m),
275
281
  }));
276
282
  const nonAlias = Object.entries(deps.config.models).filter(([n]) => n !== "default");
@@ -287,6 +293,7 @@ export async function handleCapabilities(req, res, match, ctx) {
287
293
  candidateRejection,
288
294
  modelRefusals: deps.modelRefusalsState?.(),
289
295
  }),
296
+ aliases: selectableAliasNames(deps.config.models, atCatalog, deps.config.modelRefusals).map((name) => ({ name, ...mentionBit(name) })),
290
297
  });
291
298
  return;
292
299
  }
@@ -301,6 +308,7 @@ function sendMcpProbeRefusal(res, ctx, refusal, outcome, retryAfterSec) {
301
308
  res.setHeader("retry-after", String(retryAfterSec));
302
309
  sendError(res, status, refusal.errorCode, refusal.message, {
303
310
  ...(refusal.unknownKeys !== undefined ? { unknownKeys: refusal.unknownKeys } : {}),
311
+ ...(refusal.facts ?? {}),
304
312
  ...(retryAfterSec !== undefined ? { retryAfterSec } : {}),
305
313
  });
306
314
  }
@@ -10,7 +10,7 @@
10
10
  * 刻意不吃 drain / roster-pending 两道 503(排障读面在停机窗里恰恰要打得通)。
11
11
  *
12
12
  * 🔴 鉴权 = `explicitOperatorOk`(「谁是 operator」的唯一读法:空名单 = 谁都不是)—— 设计稿 §0.5 点名禁「空名单 = 人人都是」的 fail-open 读法
13
- * (S-1050 起整只删):本面是部署事实外泄口(env 在场性 / 后端形态 / 限额值)。单用户形只在部署方显式声明 `OPERATOR_SINGLE_USER=true`
13
+ * ([ref] 起整只删):本面是部署事实外泄口(env 在场性 / 后端形态 / 限额值)。单用户形只在部署方显式声明 `OPERATOR_SINGLE_USER=true`
14
14
  * (每个调用方都是运维)时对调用方开。
15
15
  *
16
16
  * 🔴 旋钮 `CONFIG_CATALOG_ENABLED=false` / operator 名单空 ⇒ 501(事实 `configCatalog`,与能力位同一只函数):
@@ -34,7 +34,7 @@
34
34
  * 才构成一个 device 域;缺 tenant claim 的凭据(纯 principal 头 / 静态 token 直连)**判不出域** ⇒
35
35
  * 非 operator 一律响亮 403(fail-closed + loud,[ref]:静默空列表是假健康)——基线稿对 enrollment 的
36
36
  * 同向裁定是「缺 tenant/global scope 明确拒注册」。enrollment/管理端点与**首绑写协议**都从
37
- * 这同一个函数取域(S-470 起它住在 `http/device-placement.ts` —— 提交腿也要用,放在路由域里是层序倒挂),
37
+ * 这同一个函数取域([ref] 起它住在 `http/device-placement.ts` —— 提交腿也要用,放在路由域里是层序倒挂),
38
38
  * 不得手抄第二份派生。
39
39
  *
40
40
  * ── 反枚举 404 的单一铸造点 ──────────────────────────────────────────────────────────────────────
@@ -16,13 +16,13 @@ import { type StreamApprovalGate, type StreamApprovalGateInput } from "../../too
16
16
  import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
17
17
  /** 流内审批门的读数形:上场即 `"active"`,否则是那**四**个合取项里**第一个**不满足的原因词
18
18
  * (与 `resolveStreamApprovalGate` 同一闭集,词表**取型**自它 ⇒ 增删 reason 在此处自动跟随/编译红;
19
- * S-384 删掉第 5 项「账必须持久」时本行数字漏改过一次,**数字是手抄的那一半**)。 */
19
+ * [ref] 删掉第 5 项「账必须持久」时本行数字漏改过一次,**数字是手抄的那一半**)。 */
20
20
  export type StreamApprovalGateReading = "active" | Extract<StreamApprovalGate, {
21
21
  active: false;
22
22
  }>["reason"];
23
23
  /** server 自己的装配谓词读数(core 的静态半场之外的那一半:本仓在这台 worker 上做出的判断)。
24
24
  *
25
- * 🔴 S-178:三个 **posture 家族**旋钮改报 `{value, source, note}`(与 S-167 的 `readFace` 同一张四词表、
25
+ * 🔴 [ref]:三个 **posture 家族**旋钮改报 `{value, source, note}`(与 [ref] 的 `readFace` 同一张四词表、
26
26
  * 同一只 note 函数)。裸布尔答不出裁定的补偿项要求的那句话 —— 单机形升级后 `durableApproval` 缺席即
27
27
  * ON、审批窗缺席即 24h,运维必须在一个读面上看得见「这是 posture 派生的」以及「怎么钉回」。
28
28
  * `streamApproval` 那一格是**门读数**(另一根轴:这条腿现在通不通),不是旋钮,故形不变。 */
@@ -43,10 +43,10 @@ export interface ServerWiringGateInput {
43
43
  streamApprovalEnabled: boolean;
44
44
  /** 谓词自己的入参类型(结构形,不 import store 依赖树)—— 取型而非重述,两处不可能漂。 */
45
45
  backend: StreamApprovalGateInput["backend"];
46
- /** 在场性即事实;本面不取实例,故 `unknown` 足够(取窄型会把整棵 store 类型树拖进诊断域)。 */
47
- checkpointStore: unknown;
46
+ /** 谓词自己的入参类型(只收店的形,工厂方法过不了 tsc)—— 取型而非重述,与 `backend` 同理;在场性即事实,本面不读实例的内容。 */
47
+ checkpointStore: StreamApprovalGateInput["checkpointStore"];
48
48
  durableApproval: boolean;
49
- /** S-178:三个 posture 旋钮的**来源**,取自 config 上与值同处写的那一格(不在这里重判)。 */
49
+ /** [ref]:三个 posture 旋钮的**来源**,取自 config 上与值同处写的那一格(不在这里重判)。 */
50
50
  durableApprovalSource: PostureSource;
51
51
  streamAskWindowMs: number;
52
52
  streamAskWindowMsSource: PostureSource;
@@ -68,7 +68,7 @@ export interface StaticWiringAudit {
68
68
  export interface StaticWiringFacts {
69
69
  /** core `describeStaticWiring(deps, specTemplate)` 的产物。 */
70
70
  manifest: WiringManifest;
71
- /** 我方喂给 `resolveStreamApprovalGate` 的 `parkFacility` 实参(= checkpoint 店在场 ∧ DURABLE_APPROVAL)。 */
71
+ /** 我方喂给 `resolveStreamApprovalGate` 的 `checkpointStore` 实参的在场性(= checkpoint 店在场 ∧ DURABLE_APPROVAL)。 */
72
72
  parkFacility: boolean;
73
73
  /** store backend 的种类;`undefined` = env-only worker(无 backend)。 */
74
74
  backendKind: "mysql" | "pg" | "local" | undefined;
@@ -12,7 +12,7 @@ export function buildServerWiringGates(input) {
12
12
  toolApprovalEnabled: input.toolApprovalEnabled,
13
13
  streamApprovalEnabled: input.streamApprovalEnabled,
14
14
  backend: input.backend,
15
- parkFacility: input.checkpointStore !== undefined,
15
+ checkpointStore: input.checkpointStore,
16
16
  });
17
17
  const noCenterArm = (knob) => `this knob has no web-admin arm on this deployment — it is set by ${knob} on this machine, or derived from the deployment posture`;
18
18
  const noLaneArm = (knob) => `this knob has no execution-lane default — ${knob} does not depend on which execution lane this deployment runs`;
@@ -2,7 +2,7 @@
2
2
  * [ref] A9 域模块 —— MF-Fleet 实时舰队流。
3
3
  *
4
4
  * 路由:`GET /v1/fleet/stream`(SSE PUSH:连上先快照,之后每条 per-row delta)。跑在服务凭据门**之前**的
5
- * 读路谓词段(S-672:先过 `dispatch.ts` 的 `readCredentialOk`「服务凭据 ∨ 已验 principal」,再按 principal 自门,
5
+ * 读路谓词段([ref]:先过 `dispatch.ts` 的 `readCredentialOk`「服务凭据 ∨ 已验 principal」,再按 principal 自门,
6
6
  * 与 workflow 只读路由同段)。本域零可变状态。
7
7
  */
8
8
  import type { IncomingMessage, ServerResponse } from "node:http";
@@ -2,12 +2,11 @@ import { hookNoticeWire } from "../../fleet/fleet-bus.js";
2
2
  import { FLEET_SNAPSHOT_TERMINAL_MAX_ROWS, isTerminalWorkflowRowStatus, recentTerminalWorkflowRows } from "../../fleet/fleet-terminal-window.js";
3
3
  import { taskNotificationFoldKey } from "../../orchestration/workflow-completion-inbox.js";
4
4
  import { sendJson, sendError, sseHeaders } from "../send.js";
5
- import { gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
5
+ import { fleetViewOf, gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
6
6
  import { assertNever } from "../route-ctx.js";
7
7
  import * as facts from "../../capability-facts.js";
8
8
  export async function handleFleet(req, res, match, ctx) {
9
9
  const { deps } = ctx;
10
- const { sessionOwnerScope } = ctx.helpers;
11
10
  switch (match.decl.id) {
12
11
  case "fleet-stream": {
13
12
  const fleet = facts.fleetStream(deps);
@@ -15,7 +14,7 @@ export async function handleFleet(req, res, match, ctx) {
15
14
  sendError(res, 501, "capability.self_orchestration_required", "fleet stream requires self-orchestration / fleet wiring");
16
15
  return;
17
16
  }
18
- const { fleetWide } = sessionOwnerScope(req);
17
+ const { fleetWide } = fleetViewOf(req, deps, "read");
19
18
  const principal = gatedPrincipal(req, deps.config);
20
19
  if (deps.config.requirePrincipal && !principal && !fleetWide) {
21
20
  sendPrincipalRefusal(res, req, deps.config);
@@ -77,7 +76,7 @@ function streamFleet(req, res, bus, callerScope, callerSession = null, completio
77
76
  return rest;
78
77
  };
79
78
  const SCOPED_WORKFLOW_KEY_DISPOSITION = {
80
- id: "keep", status: "keep", doneCount: "keep", totalCount: "keep", failedCount: "keep",
79
+ id: "keep", status: "keep", errorCode: "keep", parked: "keep", doneCount: "keep", totalCount: "keep", failedCount: "keep",
81
80
  startedCount: "keep", elapsedMs: "keep", tokens: "keep",
82
81
  name: "rewrite", scope: "strip", sessionId: "strip",
83
82
  description: "scrub",
@@ -90,6 +89,8 @@ function streamFleet(req, res, bus, callerScope, callerSession = null, completio
90
89
  id: rest.id,
91
90
  status: rest.status,
92
91
  name: "(unattributed)",
92
+ ...(rest.errorCode !== undefined ? { errorCode: rest.errorCode } : {}),
93
+ ...(rest.parked !== undefined ? { parked: rest.parked } : {}),
93
94
  ...(rest.doneCount !== undefined ? { doneCount: rest.doneCount } : {}),
94
95
  ...(rest.totalCount !== undefined ? { totalCount: rest.totalCount } : {}),
95
96
  ...(rest.failedCount !== undefined ? { failedCount: rest.failedCount } : {}),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * S-381(core 7.22.0 [ref] 的 server 半场;提货单 [ref] ⓪ @server 第 3 条 / 判据帖 [ref] G1)——
2
+ * [ref](core 7.22.0 [ref] 的 server 半场;提货单 [ref] ⓪ @server 第 3 条 / 判据帖 [ref] G1)——
3
3
  * **会话内 MCP re-dial** 的 wire 面:
4
4
  *
5
5
  * `POST /v1/sessions/:id/mcp/reconnect` body `{ server: string }`
@@ -30,13 +30,13 @@
30
30
  * 消费端**不许**解析它。名册**按 `tools` 的在场性**投成 `toolNames`(present-iff),**不按 `outcome`**。
31
31
  *
32
32
  * ── 查找与拒绝形(与 steer / capture-optout **同一只**,不新造)───────────────────────────────────
33
- * 路径是 session,动词挂在 **run 句柄**上 ⇒ 会话属主门(`sessionStorage.ownerOf`,未知与他人**同码同串**
33
+ * 路径是 session,动词挂在 **run 句柄**上 ⇒ 会话属主门(`sessionStorage.headOf(id)?.owner`,未知与他人**同码同串**
34
34
  * 404 无 oracle,与 `POST /v1/sessions/:id/notify` 逐字同形)→ `getActiveTaskId` 取本会话的活 run →
35
35
  * `steerableRuns` 取本副本活流。非 live 的四臂一码 409 `steering.not_running`,判据取词表属主
36
- * (`isParkedRunStatus` / `isTerminalRunStatus`)与 `runProvenElsewhere`(手抄已收编成一只谓词,S-430 起同住 `plugins/store-contracts.ts`)。
36
+ * (`isParkedRunStatus` / `isTerminalRunStatus`)与 `runProvenElsewhere`(手抄已收编成一只谓词,[ref] 起同住 `plugins/store-contracts.ts`)。
37
37
  * 显式 operator 可重拨任何租户的会话(监督动作,与 notify / steer 同臂;「谁是 operator」的唯一读法 `explicitOperatorOk`)。
38
38
  *
39
- * ── 应答期限(S-431)────────────────────────────────────────────────────────────────────────────
39
+ * ── 应答期限([ref])────────────────────────────────────────────────────────────────────────────
40
40
  * 修前这一口对 `live.reconnectMcpServer(server)` 是裸 `await`:server 侧没有期限,上界只来自 core 自己的启动期钟
41
41
  * (env `MCP_TIMEOUT`,未设落 SDK 缺省 60s;拨号之前还有一次不在那条钟里的旧连接 `close()`),一台拨不通 / 半开的远端能把这一口
42
42
  * HTTP 请求挂很久。现在与 `GET /v1/sessions/:id/mcp` 面板读**同一只**数 `MCP_DIAL_DEADLINE_MS`(`../mcp-dial-deadline.ts`),
@@ -65,8 +65,8 @@ export async function handleMcpReconnect(req, res, match, ctx) {
65
65
  case "run_store_absent":
66
66
  sendError(res, 501, "capability.run_store_required", "async runs require a durable run store (DB_BACKEND=mysql|pg|local)");
67
67
  return;
68
- case "session_owner_face_absent":
69
- sendError(res, 501, "capability.session_ownership_required", "the MCP re-dial verb requires the session-ownership face (sessionStorage.ownerOf)");
68
+ case "session_head_face_absent":
69
+ sendError(res, 501, "capability.session_ownership_required", "the MCP re-dial verb requires the session-ownership face (sessionStorage.headOf)");
70
70
  return;
71
71
  default:
72
72
  return assertNever(fact.why);
@@ -89,7 +89,7 @@ export async function handleMcpReconnect(req, res, match, ctx) {
89
89
  sendError(res, 400, "request.path_malformed", "session id segment is not valid percent-encoding");
90
90
  return;
91
91
  }
92
- const owner = await sessionStorage.ownerOf(sessionId);
92
+ const owner = (await sessionStorage.headOf(sessionId))?.owner;
93
93
  if (owner === undefined) {
94
94
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
95
95
  return;
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * ── 缺席形(D4):**501**,与能力位同一只事实 ─────────────────────────────────────────────────────
13
13
  * 两口恒挂载;域头调事实 `memoryConsolidation`(`src/capability-facts.ts`,`capabilities.memoryConsolidationDriver` 读的是同一只):
14
- * · 阀门关(`MEMORY_CONSOLIDATION_DRIVER=off`,或 S-824 出厂缺省派生成关 —— 未设而整理座落主模型)⇒ 501
14
+ * · 阀门关(`MEMORY_CONSOLIDATION_DRIVER=off`,或 [ref] 出厂缺省派生成关 —— 未设而整理座落主模型)⇒ 501
15
15
  * `feature.memory_consolidation_disabled`。旋钮关是一句运维表态,不是部署能力缺失 —— 「去开旋钮」由 `feature.*` 这一族码
16
16
  * 与拒句承担(同仓旋钮关的既有答法),不靠状态码:HTTP 上「这台部署上不可用」只有 501 一种答。
17
17
  * · operator 名单空 ⇒ 501 `capability.operator_principals_required`(对谁都打不通 = 部署不可用,先于授权答)。
@@ -114,7 +114,7 @@ export declare function buildClearanceRowWire(r: OriginClearanceRow): {
114
114
  baseRev: string;
115
115
  origin: {
116
116
  at: number;
117
- cause?: "static" | "unattributed" | "observed" | "derived" | undefined;
117
+ cause?: "static" | "observed" | "unattributed" | "derived" | undefined;
118
118
  taint: "external";
119
119
  };
120
120
  };
@@ -15,7 +15,7 @@ import { type RouteCtx, type RouteMatch, type RouteIdsOf } from "../route-ctx.js
15
15
  * `NOTIFY_WAKE_ROUTES`)。历史:2026-07-31 的缝合审查出这两件事**曾经不同步** —— 匹配形写死在本文件的
16
16
  * 判路代码里、`isBillableSubmitPath` 的名单写在 `server.ts` 里,wake 从来没进过名单,于是同一条
17
17
  * `driveResumeIntoRunLog` 模型腿从 `/v1/assistant/tasks/:id/resume` 进来受三道提交门管、从 wake 进来
18
- * 一道都不受。S-146 让两件事变成同一行的两列,再想漏就得把一行拆成两处才做得到。
18
+ * 一道都不受。[ref] 让两件事变成同一行的两列,再想漏就得把一行拆成两处才做得到。
19
19
  */
20
20
  export declare function handleNotifyWake(req: IncomingMessage, res: ServerResponse, match: RouteMatch<NotifyWakeRouteId>, ctx: RouteCtx): Promise<void>;
21
21
  export declare const NOTIFY_WAKE_ROUTES: readonly [{
@@ -54,10 +54,10 @@ export async function handleNotifyWake(req, res, match, ctx) {
54
54
  }
55
55
  const owned = facts.sessionOwnership(deps);
56
56
  if (!owned.available) {
57
- sendError(res, 501, "capability.session_ownership_required", "external notify requires the session-ownership face (sessionStorage.ownerOf)");
57
+ sendError(res, 501, "capability.session_ownership_required", "external notify requires the session-ownership face (sessionStorage.headOf)");
58
58
  return;
59
59
  }
60
- const notifyOwner = await owned.sessionStorage.ownerOf(notifySession);
60
+ const notifyOwner = (await owned.sessionStorage.headOf(notifySession))?.owner;
61
61
  if (notifyOwner === undefined) {
62
62
  sendError(res, 404, "not_found.session", SESSION_NOT_FOUND_MESSAGE);
63
63
  return;