@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
package/dist/runs.js CHANGED
@@ -141,8 +141,22 @@ export function zeroWorkRefusalFacts(terminal, admissionReadings = []) {
141
141
  const c = cause;
142
142
  return c.kind === "coded" && c.detail !== undefined ? { detail: c.detail } : {};
143
143
  }
144
+ const RETRY_CLASS_WORDS = { transient: true, terminal: true };
145
+ function engineRetryClassOf(terminal) {
146
+ if (terminal.kind !== "failed")
147
+ return undefined;
148
+ const cause = terminal.detail;
149
+ if (cause === null || typeof cause !== "object")
150
+ return undefined;
151
+ const c = cause;
152
+ if (c.kind !== "coded" || c.detail === null || typeof c.detail !== "object")
153
+ return undefined;
154
+ const word = c.detail.permanence;
155
+ return typeof word === "string" && Object.hasOwn(RETRY_CLASS_WORDS, word) ? word : undefined;
156
+ }
144
157
  export async function releaseKeyIfZeroWorkRefusal(runStore, taskId, result) {
145
- if (syncRefusalHttpStatus(result) !== undefined)
158
+ const zeroWork = result.stats.turns === 0 && result.stats.tokens === 0;
159
+ if (syncRefusalHttpStatus(result) !== undefined || (zeroWork && engineRetryClassOf(result.terminal) === "transient"))
146
160
  await runStore.releaseIdemKey(taskId);
147
161
  }
148
162
  export function createPromptCommitReader() {
@@ -271,12 +285,13 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
271
285
  windowMarginMs: approval?.windowMarginMs ?? 0,
272
286
  ...(typeof spec.limits?.maxWalltimeMs === "number" ? { legWalltimeMs: spec.limits.maxWalltimeMs } : {}),
273
287
  nowMonotonicMs: performance.now(),
288
+ declaredFamilies: approval?.declaredFamilies ?? new Set(),
274
289
  });
275
290
  const legDeadlineMonotonic = approvalLeg.legDeadlineMonotonic;
276
291
  if (approval) {
277
292
  const coordinator = approval.coordinator;
278
- spec.onAsk = approvalLeg.windowZero
279
- ? coordinator.boundUnattendedAsk({ owner: elicitOwner ?? owner, taskId, ...(spec.sessionId ? { sessionId: spec.sessionId } : {}) })
293
+ spec.onAsk = approvalLeg.unattended
294
+ ? coordinator.boundUnattendedAsk({ owner: elicitOwner ?? owner, taskId, ...(spec.sessionId ? { sessionId: spec.sessionId } : {}) }, approvalLeg.unattended)
280
295
  : coordinator.boundAsk({
281
296
  owner: elicitOwner ?? owner,
282
297
  taskId,
@@ -504,7 +519,7 @@ export async function runInBackground(runner, spec, runStore, taskId, metrics, p
504
519
  const withQuestion = () => question
505
520
  ? question.runWithContext({ taskId, owner: elicitOwner ?? owner, emit: questionEmit, abortSignal: cancelCtrl.signal }, withElicit)
506
521
  : withElicit();
507
- const withApproval = () => approval && approvalLeg.active && !approvalLeg.windowZero
522
+ const withApproval = () => approval && approvalLeg.active && approvalLeg.unattended === undefined
508
523
  ? approval.coordinator.runWithContext({
509
524
  taskId,
510
525
  owner: elicitOwner ?? owner,
@@ -27,7 +27,7 @@
27
27
  * 显式 opt-in 极性,且 [ref] 起本侧传的是三态 org deny 位,见 toCoreRuntimeCaps 头注)
28
28
  * · `bypassPermissions` — `dist/core/mode-policy.js` 的模式折叠(请求 `bypassPermissions` ∧ 本位 `=== false` ⇒ 这条腿跑在
29
29
  * `default`、发 `config.permission_mode_unavailable{by:"operator_deny"}`、回执 `foldedBy:"operator_deny"`);
30
- * deny 形,缺席 = 不阻。S-900 D2 起由 center 的 `allowBypassPermissions` 写(此前本仓零写点)
30
+ * deny 形,缺席 = 不阻。[ref] D2 起由 center 的 `allowBypassPermissions` 写(此前本仓零写点)
31
31
  * · `allowMemoryOptOut` — prepare-memory.js `resolveCaptureEntitlementFresh`(+prepare-task.js
32
32
  * 的 value/faulted 投影);**极性反转,但只在 `open` 姿态下**——判决全表在
33
33
  * `dist/core/runner/memory-capture-optout.js` 的 `adjudicateCaptureOptOut`,按
@@ -38,7 +38,7 @@
38
38
  * (拒由分「answered false」与「verdict absent / resolver fault」两句)
39
39
  * · `"capture-required"`:4-12 **完全不看本 verdict**(逐字「resolver-independent」),恒拒
40
40
  * center 的键里只有 `allowUltracode` 被 DROP(下文);center 的其余每一键都在 {@link toCoreRuntimeCaps} 的处置表里,
41
- * settings-schema 加一键而这里没处置 ⇒ tsc 红(S-900 D2 之前 `allowBypassPermissions` / `allowAutoMode` 两键就是这样被静默丢掉的)。
41
+ * settings-schema 加一键而这里没处置 ⇒ tsc 红([ref] D2 之前 `allowBypassPermissions` / `allowAutoMode` 两键就是这样被静默丢掉的)。
42
42
  *
43
43
  * It pulls the PER-PRINCIPAL entitlement from center's `GET /api/config/effective?principal=` (via
44
44
  * {@link fetchPrincipalCaps}). center has ALREADY pre-resolved the tighten-only intersection (fleet defaults ∩
@@ -55,7 +55,7 @@
55
55
  * ⚠️ [ref]① 纠失实:这段曾写作「降级为 `{ allowWorkflows: false }`」,与真码不符 —— 真铸点在本文件
56
56
  * `load()` 的 catch 臂(搜 `Caps face FAIL CLOSED`),逐字是上行那几键:`allowFork` 自提货批就在,
57
57
  * `autoMode` 由 [ref] / core [ref] 同车加入(org deny 位不能因一次抖动在 denyTtl 窗内抬起),`bypassPermissions`
58
- * 由 S-900 D2 加入(同一条律:center 可能已经拒了的 bypass 不能因一次抖动放出来;core 自己的 resolver-throw 降级臂
58
+ * 由 [ref] D2 加入(同一条律:center 可能已经拒了的 bypass 不能因一次抖动放出来;core 自己的 resolver-throw 降级臂
59
59
  * 铸的也是这四位拒,`dist/core/runner/prepare-caps-and-workflow.js`)。
60
60
  * 🔒 **四只放大位以外的那三键刻意不铸**:`forceDurableGate` 同上(强挂人在环会搞死无人值守的 run);
61
61
  * `allowObservers` 是 `=== true` opt-in,缺席已等于关;`allowMemoryOptOut` 是隐私轴的 FAULT-TRANSIT 契约
@@ -70,7 +70,7 @@
70
70
  * also carries `allowUltracode` (a shell/UX reasoning-tier cap the engine has no primitive for), which we DROP —
71
71
  * this seam feeds the ENGINE, and `allowUltracode` is enforced at the service settings-resolution layer, not here.
72
72
  * center's two MODE kill-switches are NOT dropped: `allowBypassPermissions:false` ⇒ `bypassPermissions:false`,
73
- * `allowAutoMode:false` ⇒ the same auto deny bit `autoMode:false` writes (S-900 D2 — a mode's every refusal is an engine
73
+ * `allowAutoMode:false` ⇒ the same auto deny bit `autoMode:false` writes ([ref] D2 — a mode's every refusal is an engine
74
74
  * deny bit; the engine folds, announces and reports it on `wiring_manifest.permissionMode`).
75
75
  */
76
76
  import type { RuntimeCaps } from "@sema-agent/core";
@@ -83,7 +83,7 @@ import { type Logger } from "./observability/logger.js";
83
83
  /** test-only: reset the once-per-process trace so each test observes a fresh "first hit". */
84
84
  export declare function resetExecutionLaneDefaultTraceForTest(): void;
85
85
  export interface EntitlementsResolverOpts {
86
- /** S-651:中心端点(基址 + 凭证**来源**;每次抓取取一次值,不持有启动快照)。 */
86
+ /** [ref]:中心端点(基址 + 凭证**来源**;每次抓取取一次值,不持有启动快照)。 */
87
87
  center: CenterEndpoint;
88
88
  /** This worker's name (`SEMA_WEB_ADMIN_WORKER`), passed as `?worker=` so a worker-scoped `wpt_<self>` token can
89
89
  * resolve its OWN worker's principal caps (caps-only); harmless on a full token (the caps value
@@ -126,7 +126,7 @@ export interface EntitlementsResolverOpts {
126
126
  * 镜像)。core 武装式 = `spec.permissionMode === "auto" ∧ deps.autoMode !== undefined ∧ runtimeCaps?.autoMode !== false`(core 7.34.0 起;此前意图座是退役的 `autoModeRequested`)
127
127
  * ——「用户开 + org 拒」极性(此前是 `=== true` 的「org 授予」极性,无 center 的本地部署零授予路径 ⇒ auto 永不
128
128
  * 武装,真实用户诊断的病根)。
129
- * ([ref]① 的历史:npm 7.2.0 不含 [ref]、是旧「org 授予」极性,本仓曾用安装包探针分臂;S-877 / core 7.34.0 起引擎只剩
129
+ * ([ref]① 的历史:npm 7.2.0 不含 [ref]、是旧「org 授予」极性,本仓曾用安装包探针分臂;[ref] / core 7.34.0 起引擎只剩
130
130
  * 上面这一种极性,探针随 7.106.0 退役 —— 本仓精确钉的 core 恒是它。)
131
131
  * 所以**缺键=不写键**在这条轴上是行为承重的:补一个 false 就是替 org 说了一句它没说的 deny。[ref]B-6a:registry-core 0.13.0 已把 autoMode 收进 EntitlementRuntimeCaps——类型直读。 */
132
132
  export declare function toCoreRuntimeCaps(ent: EntitlementRuntimeCaps | null | undefined): RuntimeCaps | undefined;
@@ -64,13 +64,13 @@ export declare function validateCommandRules(rules: CommandRule[]): string[];
64
64
  * Either way the result only ever ADDS asks/denies — composed onto the baseline via `combinePolicies`
65
65
  * (deny-wins) by {@link applyRuntimeGovernance}, so it is tighten-only.
66
66
  *
67
- * 🔴 **S-958:返回叶,不在这里折**(改名自 `compileCommandPolicy`,修前返回 blocklist 形里 `combinePolicies(coarseDeny, askList)` 的
67
+ * 🔴 **[ref]:返回叶,不在这里折**(改名自 `compileCommandPolicy`,修前返回 blocklist 形里 `combinePolicies(coarseDeny, askList)` 的
68
68
  * 一只折叠)。复合命令(`a && b`、管道、`;`)上两只叶都按「解析不了 ⇒ 问」问 ⇒ 那只折叠带出 `foldedAskClasses`,而治理层随后要给每只
69
- * ask 盖部署出身 —— 盖在折叠的输出上就是展开一只 core 担保过身份的对象(core #1266 7.39.0 按名拒)。叶交出去,由
69
+ * ask 盖部署出身 —— 盖在折叠的输出上就是展开一只 core 担保过身份的对象(core [ref] 7.39.0 按名拒)。叶交出去,由
70
70
  * {@link applyRuntimeGovernance} 逐叶盖位、折**一次**:本函数不知道出身这件事,治理层只有一个折叠点。 (Assumes commands are pre-validated by
71
71
  * {@link validateCommandRules}; an un-matchable command here is simply inert, never a parse error.)
72
72
  *
73
- * 🔴 **S-496:词表外的 `decision` 折 `deny`,不折 `ask`。** {@link validateCommandRules} 的头注写下的那条
73
+ * 🔴 **[ref]:词表外的 `decision` 折 `deny`,不折 `ask`。** {@link validateCommandRules} 的头注写下的那条
74
74
  * 后果(「域外的 `decision` 穿过本函数的三元链落到 ASK,静默把一条 intended deny 弱化掉」)此前只靠
75
75
  * **调用方记得先校验**挡着 —— 而本函数在 `resolve-spec` 里是逐请求现调的,`config.commandPolicy` 的来路
76
76
  * (center hot apply / 本地 `config.d/governance.json` / LKG / 测试直塞)不止一条。现在闭集在本函数**内部**
@@ -213,7 +213,7 @@ export interface GovernancePosture {
213
213
  * ⚠️ 残留(双向失真的窄在场向 + 根治路径)与「只收窄」的那一个裁决读者,都登记在
214
214
  * {@link governanceMandatesShellGateAlways} 的顶注,别在这里复述。
215
215
  *
216
- * 🔴 **形状档的 ask 刻意不标**(S-877 起它不再是一个档位词:core 7.34.0 把形状档装在**每一种模式**的全权 shell 上,
216
+ * 🔴 **形状档的 ask 刻意不标**([ref] 起它不再是一个档位词:core 7.34.0 把形状档装在**每一种模式**的全权 shell 上,
217
217
  * 行上的 `shellGateDoctrine` 只在运维地板 `"always"` 铸门时出现):形状档的一次 shell ask 出自引擎自己的判断,
218
218
  * 也可能叠着 `APPROVAL_REQUIRE` 这类别的门,行上无从分辨 —— 与活卡腿同一条「宁缺毋假」纪律。
219
219
  *
@@ -230,7 +230,7 @@ export interface GovernancePosture {
230
230
  * (checkpoint → ask)今天**没有读口**:两条 list 读口都硬过滤 `state='STREAM_PENDING'`,而 park 完的行是
231
231
  * `PARKED`;唯一精确的连接键是 ask 行上的 `gate_token`,要按它反查得给店加一个新读口(SQL 面 = 双库集成
232
232
  * 门)。派生 `deriveAskId(...)` 也不行:它吃 `legKey`(= 上一腿 resume token 的摘要)、`parentToolCallId` 与这一问的
233
- * 类集(S-944);前两维从 checkpoint 行推不出来,类集在 park 行上老行缺席、续跑不补 —— 二腿/子代/老行形上会算出一个
233
+ * 类集([ref]);前两维从 checkpoint 行推不出来,类集在 park 行上老行缺席、续跑不补 —— 二腿/子代/老行形上会算出一个
234
234
  * **错**的 id —— 在「等的谁」这条通道上,错 id 比缺席坏得多(`http/active-run-conflict.ts` 的 `resumeEntryForGate` 的 default 臂是同一条纪律)。故诚实缺席。
235
235
  */
236
236
  export declare function governanceOriginOf(gate: {
@@ -253,14 +253,14 @@ export declare function governanceOriginOf(gate: {
253
253
  * (task-settings deriveSettingsPolicy 的 default/auto/acceptEdits 三臂)让一个**部署级 tighten-only 旋钮
254
254
  * 的生死由客户端表态在场性决定**:body 无 settings/permissionMode(cli print/headless 腿按设计不 stamp)
255
255
  * ⇒ 旋钮静默失效(clay 实机 Monitor 案「门根本没铸」);bypassPermissions 一句话掀掉部署闸;非 host lane
256
- * fsWriteGate wiring 不建 ⇒ 沙箱 lane 全失效。governance 层与 autonomy 同拍施加后三者全闭。S-877 起地板只有
256
+ * fsWriteGate wiring 不建 ⇒ 沙箱 lane 全失效。governance 层与 autonomy 同拍施加后三者全闭。[ref] 起地板只有
257
257
  * `"always"` 一个词,合成退化成在场性(两个来源同词),不再有秩比较。
258
258
  *
259
259
  * [ref]([ref] issue #29,**邻仓 test AI 的 46 格真机矩阵**实证——不是本仓的钉,别到本仓文件里数 46;
260
260
  * 本仓的类级门是 test/operator-knob-client-posture-matrix.test.ts 的 旋钮×表态×lane 矩阵):
261
261
  * `SENSITIVE_WRITE_PATTERNS` 是 [ref] 那次搬家漏下的兄弟旋钮——同一个病灶原样复发在 sensitive-path
262
262
  * DENY 腿上(唯一合成点在 deriveSettingsPolicy 的 fsWriteGate 闭包,bypassPermissions/键缺席/settings
263
- * 整缺席三形整条腿不建)。同方修:调用方(resolve-spec)把 operator 守卫集预铸成 `sensitivePathLayers`(叶;S-958 起不再是
263
+ * 整缺席三形整条腿不建)。同方修:调用方(resolve-spec)把 operator 守卫集预铸成 `sensitivePathLayers`(叶;[ref] 起不再是
264
264
  * 一只预折的策略,见下段)从这里**无条件施加**——它只在守卫段上产 deny(core 语义 deny/"safety"),对其余目标返回的是
265
265
  * `action:"allow"`(**不是**「无意见」这种第三态:core 的 ToolPolicy 没有弃权值。它在
266
266
  * `combinePolicies` 的 deny/ask 优先折叠里不构成一票,所以在**折叠语境**下等价于弃权;若日后有人把
@@ -269,7 +269,7 @@ export declare function governanceOriginOf(gate: {
269
269
  * 只组合不构造:裁决 env 的 lane 分形(host 真 fs / 沙箱 deferred 代理)是 resolve-spec 的属主知识,
270
270
  * governance 层不重复它。
271
271
  *
272
- * 🔴 **S-958(core #1266 7.39.0)—— 治理层只有一个折叠点**:两种输入都交**叶**(`compileCommandPolicyLayers` 的那几只、
272
+ * 🔴 **[ref](core [ref] 7.39.0)—— 治理层只有一个折叠点**:两种输入都交**叶**(`compileCommandPolicyLayers` 的那几只、
273
273
  * `sensitivePathLayers` 的那几只),本函数对每一片叶各盖一次部署出身(`createDeploymentAuthoredPolicy`),再交 core
274
274
  * `combinePolicies` 折一次;折叠是最外层,输出经标记观察器原物交回。修前是「先折、再在折叠输出上展开盖位」——折叠带出
275
275
  * `foldedAskClasses` 时交给 core 的是副本,7.39.0 起按名拒(工具不跑、无卡)。
@@ -278,7 +278,7 @@ export declare function applyRuntimeGovernance(base: TaskSpec, governance: {
278
278
  autonomy?: Autonomy;
279
279
  commandPolicy?: CommandRule[];
280
280
  manualModeShellGate?: ShellGateDoctrine;
281
- /** 守卫集的**叶**(`deployment-governance.ts` `createDeploymentGovernanceInputs` 预铸;S-958 起是叶的列表,不是一只预折的策略)。
281
+ /** 守卫集的**叶**(`deployment-governance.ts` `createDeploymentGovernanceInputs` 预铸;[ref] 起是叶的列表,不是一只预折的策略)。
282
282
  * 空列表与缺席同义。 */
283
283
  sensitivePathLayers?: readonly ToolPolicy[];
284
284
  /** [ref]/[ref] `governanceForced` 的标记表(缺省 = **当前 run 腿的 ALS 表**,见
@@ -1,29 +1,4 @@
1
- /**
2
- * RFC B5/B4 抽象点② (sema-internal server/docs/design/ENV-SELECT-AND-REGION-SOURCE.md): the deployment-region package-source →
3
- * sandbox env derivation. ENV-FIRST: pod/sandbox env OVERRIDES the image's baked `ENV` (k8s container env wins
4
- * over image config and is visible to every exec'd process; e2b sandboxEnv likewise) — so the env-overridable
5
- * ecosystem pieces (pip/uv/npm/corepack/go/rustup/flutter/playwright/nuget) switch region on EXISTING images,
6
- * no rebake needed. Only the file-bound pieces (apt sources, /etc/gemrc, composer global config, cargo
7
- * config.toml) still need the in-image `pkg-source.sh` hook (rebaked images; bake prep chowns those files).
8
- *
9
- * Profiles:
10
- * cn → inject only the SEMA_PKG_SOURCE marker (the pool's images bake the CN set as their defaults).
11
- * global → official endpoints for every env-overridable ecosystem (overrides the baked CN ENV values).
12
- * custom → SEMA_* explicit URLs (from the service process env) forwarded verbatim + mapped onto the same
13
- * ecosystem variables where a mapping is unambiguous (apt has no env form — hook-only).
14
- *
15
- * The marker `SEMA_PKG_SOURCE` always rides along: the image's pkg-source.sh hook (pod-start / profile.d)
16
- * materializes the file-bound pieces from it; images without the hook simply ignore it.
17
- *
18
- * ## One law: no URL that rides into the model-visible sandbox env carries userinfo
19
- * Everything this module derives lands in the env of every sandbox process — including the ones the model drives
20
- * (`env`, `printenv`) — so `https://user:pass@mirror/…` among the `custom` addresses would hand the deployment's
21
- * package-source credential to the model. {@link customPkgSourceFromEnv} is the ONE reader of the six addresses and the
22
- * one place that judges them: the shared URL-shape judge (`httpUrlFlaws`, the same one MEMORY_EMBEDDER_ENDPOINT /
23
- * A2A_SERVE_URL answer to) says no ⇒ it throws, startup refuses. Never stripped, never rewritten, never forwarded
24
- * quietly. The request face has no package-source address key at all (deployment face only).
25
- */
26
- import { type HttpUrlFlaw } from "@sema-agent/settings-schema";
1
+ import { type UrlCredential } from "./url-credential.js";
27
2
  /** Explicit URLs for `custom` (RFC B: 极端情况出口). Read from the service process env (operator-trusted). */
28
3
  export interface CustomPkgSource {
29
4
  aptMirror?: string;
@@ -38,15 +13,18 @@ export interface CustomPkgSource {
38
13
  * profile (unset = byte-identical sandbox — the B5 backward-compat contract).
39
14
  */
40
15
  export declare function derivePkgSourceEnv(profile: string | undefined, custom?: CustomPkgSource): Record<string, string>;
16
+ /** 一只地址的毛病:形判不出(不是层级式 http(s) URL,或含反斜杠 —— 本座位律),或带凭据(共用判官的一处命中)。 */
17
+ export type PkgSourceAddressProblem = "not-http-url" | UrlCredential;
41
18
  /**
42
- * The refusal sentence for one address (pure data): the shared judge's rule words + the value's origin only
43
- * ({@link buildHttpUrlRefusal}), then why it matters here and the two ways out. No byte of the credential can reach it.
19
+ * The refusal sentence for one address (pure data): the shared judges' rule sentence + the value's origin only
20
+ * ({@link buildHttpUrlRefusal} / {@link buildUrlCredentialRefusal}), then why it matters here and the two ways out. No byte of the credential can reach it.
44
21
  */
45
- export declare function buildCustomPkgSourceRefusal(envName: string, raw: string, flaws: readonly HttpUrlFlaw[]): string;
22
+ export declare function buildCustomPkgSourceRefusal(envName: string, raw: string, problem: PkgSourceAddressProblem): string;
46
23
  /**
47
24
  * Read the `custom` explicit-URL set from the service process env (operator-trusted deployment config) — the ONE reader and
48
- * the ONE judge of those six addresses (see the module header). An address the shared judge refuses (userinfo, or a shape
49
- * that is not a parseable http(s) URL) throws {@link buildCustomPkgSourceRefusal}; empty / unset = not set.
25
+ * the ONE judge of those six addresses (see the module header). An address the shared judges refuse (a shape that is not a
26
+ * parseable http(s) URL, or a credential: userinfo / a credential-named parameter) throws {@link buildCustomPkgSourceRefusal};
27
+ * empty / unset = not set.
50
28
  */
51
29
  export declare function customPkgSourceFromEnv(env?: NodeJS.ProcessEnv): CustomPkgSource;
52
30
  //# sourceMappingURL=sandbox-pkg-source.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { httpUrlFlaws } from "@sema-agent/settings-schema";
2
- import { buildHttpUrlRefusal } from "./url-refusal.js";
2
+ import { buildHttpUrlRefusal, buildUrlCredentialRefusal } from "./url-refusal.js";
3
+ import { findUrlCredential } from "./url-credential.js";
3
4
  const GLOBAL_ENV = {
4
5
  PIP_INDEX_URL: "https://pypi.org/simple",
5
6
  UV_DEFAULT_INDEX: "https://pypi.org/simple",
@@ -45,14 +46,17 @@ export function derivePkgSourceEnv(profile, custom) {
45
46
  return { SEMA_PKG_SOURCE: profile };
46
47
  }
47
48
  }
48
- export function buildCustomPkgSourceRefusal(envName, raw, flaws) {
49
- return (`${buildHttpUrlRefusal(envName, raw, flaws)} — with SANDBOX_PKG_SOURCE=custom this address is written verbatim into the environment of every sandbox ` +
50
- `(e2b VM / k8s pod), where any process the model can run reads it back with \`env\`; an address that carries userinfo, or whose shape cannot be judged ` +
49
+ export function buildCustomPkgSourceRefusal(envName, raw, problem) {
50
+ const head = problem === "not-http-url" ? buildHttpUrlRefusal(envName, raw, ["not-http-url"]) : buildUrlCredentialRefusal(envName, raw, problem);
51
+ const drop = problem !== "not-http-url" && problem.reason === "url_credential_param" ? `drop the "${problem.name}" parameter` : "drop the userinfo";
52
+ return (`${head} — with SANDBOX_PKG_SOURCE=custom this address is written verbatim into the environment of every sandbox ` +
53
+ `(e2b VM / k8s pod), where any process the model can run reads it back with \`env\`; an address that carries a credential (userinfo, or a query / fragment ` +
54
+ `parameter named like one — the names the service's log redactor treats as credentials), or whose shape cannot be judged ` +
51
55
  `credential-free (not http(s)://host[:port][/path], or containing a backslash — the URL standard reads it as "/", package managers do not), would hand ` +
52
56
  `the deployment's package-source credential to the model, so the server refuses to start rather than forward or rewrite it. ` +
53
57
  `Way out: (1) set ${envName} to the credential-free address and give the package manager its credential through its own channel — a token variable ` +
54
58
  `named in the lane's name list (E2B_SANDBOX_ENV / K8S_SANDBOX_ENV; naming it accepts that every process in the sandbox, the model included, can read it) ` +
55
- `or a credential file baked into the sandbox image; (2) if the source needs no authentication, drop the userinfo.`);
59
+ `or a credential file baked into the sandbox image; (2) if the source needs no authentication, ${drop}.`);
56
60
  }
57
61
  export function customPkgSourceFromEnv(env = process.env) {
58
62
  const addresses = {
@@ -68,9 +72,11 @@ export function customPkgSourceFromEnv(env = process.env) {
68
72
  const [name, raw] = addresses[field];
69
73
  if (!raw)
70
74
  continue;
71
- const flaws = raw.includes("\\") ? ["not-http-url"] : httpUrlFlaws(raw, ["userinfo"]);
72
- if (flaws.length > 0)
73
- throw new Error(buildCustomPkgSourceRefusal(name, raw, flaws));
75
+ if (raw.includes("\\") || httpUrlFlaws(raw, []).length > 0)
76
+ throw new Error(buildCustomPkgSourceRefusal(name, raw, "not-http-url"));
77
+ const credential = findUrlCredential(raw);
78
+ if (credential !== undefined)
79
+ throw new Error(buildCustomPkgSourceRefusal(name, raw, credential));
74
80
  out[field] = raw;
75
81
  }
76
82
  return out;
@@ -1,4 +1,5 @@
1
1
  import type { Logger } from "./observability/logger.js";
2
+ import { type CheckpointCtxSealing } from "./http/checkpoint-ctx.js";
2
3
  /** Algorithm tag — MUST equal registry-core's `SEALED_BOX_ALG` (v1 sole value; a different alg on
3
4
  * the wire is a loud per-model rejection in applyEffective, never a guess). */
4
5
  export declare const SEALED_KEY_ALG = "libsodium-sealedbox-x25519";
@@ -14,7 +15,7 @@ export interface SealedKeyOpener {
14
15
  open(ciphertextB64: string, publicKeyId: string): string;
15
16
  }
16
17
  /**
17
- * S-737 —— the store's **discovery-safe face**: ONLY the newest public key. This is what the HTTP layer is handed
18
+ * [ref] —— the store's **discovery-safe face**: ONLY the newest public key. This is what the HTTP layer is handed
18
19
  * (`ServiceDeps.sealedKeyPublic` → `GET /v1/capabilities` `sealedKey`) — never the whole store — so private-key
19
20
  * material, the custody path and the held-id list are structurally unreachable from that layer (not merely
20
21
  * "not read"). Built from a live store by {@link buildSealedKeyPublicFace}, which copies out `latest` alone.
@@ -36,7 +37,7 @@ export interface SealedKeyStore extends SealedKeyOpener, SealedKeyPublicFace {
36
37
  * reachable through it, whatever the caller later casts it to). Plain data ⇒ `build*`. */
37
38
  export declare function buildSealedKeyPublicFace(store: SealedKeyPublicFace): SealedKeyPublicFace;
38
39
  /**
39
- * S-737 —— the `GET /v1/capabilities` `sealedKey` segment: exactly three keys — the algorithm (the pinned v1
40
+ * [ref] —— the `GET /v1/capabilities` `sealedKey` segment: exactly three keys — the algorithm (the pinned v1
40
41
  * {@link SEALED_KEY_ALG}, never a hand-copied literal), the id to write into `sealedApiKey.publicKeyId`, and the
41
42
  * base64 X25519 public key to `crypto_box_seal` against. `createdAt` is deliberately NOT projected (it answers
42
43
  * nothing a sealer needs; the wire keeps to the three keys the contract names).
@@ -61,6 +62,36 @@ export declare function deriveKeyId(publicKeyRaw: Uint8Array): string;
61
62
  * zero loadable keys AND generation failed).
62
63
  */
63
64
  export declare function ensureSealedKeyStore(dir: string, logger?: Logger): Promise<SealedKeyStore>;
65
+ declare const checkpointCtxKeyStoreBrand: unique symbol;
66
+ /**
67
+ * 停驻行封签那一域的保管店(品牌型):读口与 {@link SealedKeyStore} 同形,型不同 —— {@link createCheckpointCtxSealing} 只收它,模型钥匙那只店交进去是 tsc 错
68
+ * (「两域并成一对钥匙」那条路在型面上关掉,不靠注释)。唯一铸点 = {@link ensureCheckpointCtxSealing} 建店处(经 {@link mintCheckpointCtxKeyStore});
69
+ * 品牌断言的普查在 `test/owner-gate-single-owner.test.ts` ⑤b。
70
+ */
71
+ export type CheckpointCtxKeyStore = SealedKeyStore & {
72
+ readonly [checkpointCtxKeyStoreBrand]: true;
73
+ };
74
+ /**
75
+ * 停驻行封签器的**生产工厂**(起服 web-admin 运行时与嵌入方同调这一只):在 `sealedKeyDir`(`<数据根>/sealed-key`)之下的 {@link CHECKPOINT_CTX_KEY_SUBDIR}
76
+ * 建这一域自己的保管店(同一只 {@link ensureSealedKeyStore}:目录 0700、钥匙文件 0600、空目录生成一把、读不了的文件跳过不删),再交 {@link createCheckpointCtxSealing}。
77
+ * 钥匙只在这里读进内存(起服一次):进程运行中补进目录的钥匙文件要重启才认。
78
+ * 抛 = 这一域没有封签器(目录建不了 / 改不了权限,或钥匙文件公私不配对);调用方当「没有封签器」处置。
79
+ */
80
+ export declare function ensureCheckpointCtxSealing(sealedKeyDir: string, logger?: Logger): Promise<CheckpointCtxSealing>;
81
+ /**
82
+ * 停驻行凭据的**封签器**([ref];形与规则的属主 = `http/checkpoint-ctx.ts` 末段「凭据位密封」)—— 从**这一域自己的**保管店派生(生产 = {@link ensureCheckpointCtxSealing};
83
+ * 入参型 {@link CheckpointCtxKeyStore}:模型钥匙那只店进不来),信封是:封进密文的明文是 `JSON.stringify([CHECKPOINT_CTX_SEAL_ALG, sessionId, value])`。
84
+ * · **封**:对着保管店**最新**那把公钥 `crypto_box_seal`(只用公钥);封签记下那把钥匙的 id。
85
+ * · **开**:按封签上的 id **精确**选私钥(保管店的 `open`,不逐把试),再判信封:三元数组、首元是本信封的词、第二元是**这一行的会话 id**,交回第三元(封进去的 JSON 值,任何类型) ——
86
+ * 任何一条不成立 ⇒ 抛。域隔离由钥匙给(两域两对钥匙:模型钥匙的密文放进停驻行凭据位 ⇒ 这一域不持有那把钥匙;反过来停驻行的封签放进 `sealedApiKey` ⇒ 模型钥匙店不持有),
87
+ * 信封再给**行绑定**(别的会话那一行的封签搬过来开不开)与格式词 —— 持有本对象的那一层(HTTP 续跑腿)拿到的是「只开停驻行封签」的口;
88
+ * 私钥本身、保管目录、持有 id 列表照旧够不着(只多一个 `holds(id)`:开之前判「这把钥匙在不在本副本」,`key_not_held` 与 `unopenable` 分开报)。
89
+ * · 错误句不带明文:信封解析失败只报「不是停驻行封签」(`JSON.parse` 的报错会嵌入输入片段 —— 那里可能是一只模型钥匙),保管店的错误句只说哪把钥匙 / 哪种失败。
90
+ * 前置条件:`store` 来自 {@link ensureSealedKeyStore}(它已等过 libsodium 就绪);没就绪 ⇒ 当场响亮抛,不造一只封不了的对象。
91
+ * **自检**:交出之前对最新那把钥匙封一只探针、再开回来 —— 开不回来(保管档里公私钥不配对:长度都对,装载照收)⇒ 当场抛。封得进、开不出的封签器比没有更坏:
92
+ * 起服的一次性迁移 M28 会用它把还读得懂的明文行换成谁都开不开的密文。调用方(web-admin 运行时)把这一抛当「没有封签器」处置 ⇒ 耐久审批在场的部署起服拒。
93
+ */
94
+ export declare function createCheckpointCtxSealing(store: CheckpointCtxKeyStore): CheckpointCtxSealing;
64
95
  /**
65
96
  * Best-effort public-key registration with the web-admin (`POST /api/config/execution-keys`).
66
97
  *
@@ -86,4 +117,5 @@ export declare function reportExecutionPublicKey(opts: {
86
117
  /** Test seam. */
87
118
  fetchImpl?: typeof fetch;
88
119
  }): Promise<void>;
120
+ export {};
89
121
  //# sourceMappingURL=sealed-key.d.ts.map
@@ -6,6 +6,7 @@ import { buildDisplaySafeUrl } from "./trace/redact.js";
6
6
  import { createCenterCredentialSource } from "./center-credential.js";
7
7
  import { centerFetch } from "./web-admin-client/center-request.js";
8
8
  import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
9
+ import { CHECKPOINT_CTX_SEAL_ALG } from "./http/checkpoint-ctx.js";
9
10
  export const SEALED_KEY_ALG = "libsodium-sealedbox-x25519";
10
11
  const SEAL_OVERHEAD_BYTES = 48;
11
12
  const BASE64_STRICT = /^[A-Za-z0-9+/]+={0,2}$/;
@@ -70,7 +71,7 @@ export async function ensureSealedKeyStore(dir, logger) {
70
71
  await writeFile(path, JSON.stringify(record, null, 2) + "\n", { mode: 0o600 });
71
72
  await chmod(path, 0o600);
72
73
  keys.set(record.publicKeyId, { publicKey: kp.publicKey, privateKey: kp.privateKey, publicKeyB64, createdAt: record.createdAt });
73
- logger?.info("sealed_key_generated", { publicKeyId: record.publicKeyId, publicKey: publicKeyB64, dir, note: "new X25519 sealed-box keypair — register the PUBLIC key with the registry (see sealed_key_public_key)" });
74
+ logger?.info("sealed_key_generated", { publicKeyId: record.publicKeyId, publicKey: publicKeyB64, dir, note: "new X25519 sealed-box keypair in this directory — the private key exists only here: keep the directory across restarts and identical on every replica that has to open what it sealed, and back it up as a private key" });
74
75
  }
75
76
  const latestEntry = [...keys.entries()].sort((a, b) => (a[1].createdAt < b[1].createdAt ? 1 : a[1].createdAt > b[1].createdAt ? -1 : a[0] < b[0] ? -1 : 1))[0];
76
77
  return {
@@ -88,6 +89,59 @@ export async function ensureSealedKeyStore(dir, logger) {
88
89
  },
89
90
  };
90
91
  }
92
+ const CHECKPOINT_CTX_KEY_SUBDIR = "checkpoint-ctx-keys";
93
+ function mintCheckpointCtxKeyStore(store) {
94
+ return store;
95
+ }
96
+ export async function ensureCheckpointCtxSealing(sealedKeyDir, logger) {
97
+ return createCheckpointCtxSealing(mintCheckpointCtxKeyStore(await ensureSealedKeyStore(join(sealedKeyDir, CHECKPOINT_CTX_KEY_SUBDIR), logger)));
98
+ }
99
+ export function createCheckpointCtxSealing(store) {
100
+ const sodium = _sodium;
101
+ if (typeof sodium.crypto_box_seal !== "function")
102
+ throw new Error("createCheckpointCtxSealing: libsodium is not initialized — build the store with ensureSealedKeyStore() first");
103
+ const { publicKeyId } = store.latest;
104
+ const publicKey = b64ToBytes(store.latest.publicKey, "publicKey");
105
+ const sealing = createUncheckedCheckpointCtxSealing(store, publicKeyId, publicKey);
106
+ const probeSession = "sealed-key-self-test";
107
+ let roundTrip;
108
+ try {
109
+ roundTrip = sealing.open(sealing.seal(probeSession, probeSession), probeSession);
110
+ }
111
+ catch {
112
+ roundTrip = undefined;
113
+ }
114
+ if (roundTrip !== probeSession) {
115
+ throw new Error(`createCheckpointCtxSealing: self-test failed — a value sealed against the newest public key (publicKeyId "${publicKeyId}") does not open with the private key held under that id; the key file's public and private halves do not belong together. Refusing to hand out a sealer whose seals nobody can open`);
116
+ }
117
+ return sealing;
118
+ }
119
+ function createUncheckedCheckpointCtxSealing(store, publicKeyId, publicKey) {
120
+ const sodium = _sodium;
121
+ return {
122
+ seal: (value, sessionId) => ({
123
+ alg: CHECKPOINT_CTX_SEAL_ALG,
124
+ publicKeyId,
125
+ sealed: Buffer.from(sodium.crypto_box_seal(sodium.from_string(JSON.stringify([CHECKPOINT_CTX_SEAL_ALG, sessionId, value])), publicKey)).toString("base64"),
126
+ }),
127
+ holds: (id) => store.has(id),
128
+ open: (sealed, sessionId) => {
129
+ const plaintext = store.open(sealed.sealed, sealed.publicKeyId);
130
+ let envelope;
131
+ try {
132
+ envelope = JSON.parse(plaintext);
133
+ }
134
+ catch {
135
+ throw new Error("sealed value is not a checkpoint-context seal");
136
+ }
137
+ if (!Array.isArray(envelope) || envelope.length !== 3 || envelope[0] !== CHECKPOINT_CTX_SEAL_ALG)
138
+ throw new Error("sealed value is not a checkpoint-context seal");
139
+ if (envelope[1] !== sessionId)
140
+ throw new Error("sealed value was sealed for a different session's resume context");
141
+ return envelope[2];
142
+ },
143
+ };
144
+ }
91
145
  export async function reportExecutionPublicKey(opts) {
92
146
  const { baseUrl, adminToken, key, notes, logger } = opts;
93
147
  const manual = (why) => {
@@ -1,9 +1,10 @@
1
1
  import type { IncomingMessage } from "node:http";
2
2
  import { type SessionPlacementRecord, type SessionStore, type SessionTreeEntry } from "@sema-agent/core";
3
3
  import type { ServiceConfig } from "./config-types.js";
4
+ import { type DeploymentShapeInput } from "./deployment-shape.js";
4
5
  import type { TaskRequestBody } from "./http/wire-types.js";
5
6
  import type { StagingHandle } from "./session-sync-kernel.js";
6
- import type { SessionFace, SessionFaceReader } from "./session-incarnation.js";
7
+ import { type SessionFace } from "./session-incarnation.js";
7
8
  import type { SessionRowPatch } from "./session-row.js";
8
9
  import { type OwnerlessClaim } from "./delegated-session-owner.js";
9
10
  /** One row of the session-list projection (CC /resume picker) — the durable session abstraction's enumeration
@@ -19,7 +20,7 @@ export interface SessionListItem {
19
20
  /** K-5c (shell §K): the latest run's task_id — the shell's one-hop live-tail re-attach anchor on resume. */
20
21
  lastRunId: string | null;
21
22
  /** [ref]([ref]/[ref]):the LATEST run's **engine run id**(`TaskResult.runId`)when known —— OMIT-when-absent,
22
- * 恒不铸 null。所有 lister(SQL 双生、local 会话店 —— 它的 run 店是必填位)从 latest run 的 `result` JSON 提取(终局与 park 时写、认领续跑即清空 —— S-173
23
+ * 恒不铸 null。所有 lister(SQL 双生、local 会话店 —— 它的 run 店是必填位)从 latest run 的 `result` JSON 提取(终局与 park 时写、认领续跑即清空 —— [ref]
23
24
  * ⇒ 在跑 latest 键诚实缺席)。
24
25
  * 读法一致:缺席 = 「此行无已知 engine runId」,禁读成其它含义。⚠️ 与 `lastRunId`(= latest run 的 **task_id**)
25
26
  * 是两条身份轴,命名对齐 core `SessionStoreSummary.lastTaskRunId`。wire:additive 键零投影透传
@@ -42,7 +43,7 @@ export interface SessionListItem {
42
43
  * 而 `DELETE /v1/sessions/:id`(删整条会话)不在其中 —— 同一风险形、爆炸半径**更大**,却没门。
43
44
  *
44
45
  * 风险形逐字同源(守卫自己的注释):「无 service token + 未开 `ALLOW_UNAUTHED_WRITES`」这一形下
45
- * `sessionOwnerScopeForWrite` 判 fleet-wide ⇒ 集群内**任意**调用方可对**任意** session 动手。
46
+ * fleet 写档(`http/principal-gate.ts` 的 `fleetViewOf`,dev-open 臂)判 fleet-wide ⇒ 集群内**任意**调用方可对**任意** session 动手。
46
47
  * policy 腿担心的是「forged principal 能 tighten/DoS 一个会话的工具」;DELETE 直接把会话删掉。
47
48
  *
48
49
  * ⇒ 枚举改**族判定**:新增一条破坏性会话路由时自动落进门内,不必记得回来加白名单。
@@ -55,7 +56,7 @@ export declare function isDestructiveSessionWrite(method: string, url: string):
55
56
  declare const principalBrand: unique symbol;
56
57
  declare const durableOwnerKeyBrand: unique symbol;
57
58
  /**
58
- * 🔴 **两个 owner 不是同一个东西**(S-487 RH-3,类型事实):
59
+ * 🔴 **两个 owner 不是同一个东西**([ref] RH-3,类型事实):
59
60
  * · {@link Principal} —— **这次请求**验过的调用方身份。铸点闭集:`http/principal-gate.ts` 的 `gatedPrincipal`(验身份的那一只),以及属主存取器
60
61
  * (`http/owner-access.ts`)里一只「上游已验」的适配口(调用方身份经一只纯串结构转手过来的腿 —— 第二期随那只结构带品牌而删);
61
62
  * · {@link DurableOwnerKey} —— **行上 / 存储键里**落下的属主(run 行、会话行的 `owner` 列)。铸点闭集:属主存取器读行处与 {@link sessionOwnerCellOf}。
@@ -73,7 +74,7 @@ export declare function mintPrincipal(verified: string): Principal;
73
74
  /** {@link DurableOwnerKey} 的铸造口(只在铸点闭集里调,见上)。 */
74
75
  export declare function mintDurableOwnerKey(persisted: string): DurableOwnerKey;
75
76
  /**
76
- * 会话行属主门读的那一格(S-1770):有主的行只有属主;**无主的行**另带「它是不是委派子代的 placed 行」(店的 `placementOf` 答,{@link sessionOwnerCellOf} 读;
77
+ * 会话行属主门读的那一格([ref]):有主的行只有属主;**无主的行**另带「它是不是委派子代的 placed 行」(店的 `placementOf` 答,{@link sessionOwnerCellOf} 读;
77
78
  * 不实现 placement 的店没有 placed 行)。`placed` 只在无主时存在 —— 有主的行属主门不看它。
78
79
  */
79
80
  export type SessionOwnerCell = {
@@ -89,7 +90,7 @@ export interface SessionCaller {
89
90
  readonly fleet: boolean;
90
91
  }
91
92
  /**
92
- * 🔴 **会话行属主门上「无主行放行」臂的唯一判据**(S-1770 读面律;会话面谓词 `sessionOwnerReadable`、fork / 删除的存量互认臂 {@link legacyUnownedSessionOk}、
93
+ * 🔴 **会话行属主门上「无主行放行」臂的唯一判据**([ref] 读面律;会话面谓词 `sessionOwnerReadable`、fork / 删除 / 同步族的存量互认臂 {@link legacyUnownedSessionOk}、
93
94
  * 审批豁免面、notify 面的无主臂都经它,不各写一份):
94
95
  * · 无主的**普通**会话行 ⇒ 成立(各臂照它自己的其余条件);
95
96
  * · 无主的 **placed** 行(委派子代:属主 = 委派树根的属主,`delegated-session-owner.ts`)⇒ 只对 **fleet 调用方**成立({@link SessionCaller}:dev-open 部署上的任何调用方,
@@ -114,7 +115,7 @@ export declare const LEGACY_UNOWNED_AMNESTY_TENANT = "default";
114
115
  * fleet 面与 run 读面天然连续,面1/面2 零施工)。
115
116
  *
116
117
  * 🔒 **三条件缺一不放行**(与第一臂同源,不是兼容臂):
117
- * ① 单机形 `!requirePrincipal` —— 多租部署本臂**死路**(header 必到、键必具名);
118
+ * ① 单机形(部署形表行 `multiTenant` 不成立)—— 多租部署本臂**死路**(header 必到、键必具名);
118
119
  * ② 存量行恰为无主 `owner === null`、且不是委派子代的 placed 行(无主臂的唯一判据 {@link ownerlessRowOpen})—— 任何具名 owner 的行不受影响;
119
120
  * ③ 调用方恰为 `default` 主 —— 非 default 的具名主对无主行仍走原门(404 / deleted:false)。
120
121
  * 反向风险有界:①限定的单机形本就单用户,把无主行判给 default 主不产生跨租外泄。
@@ -122,7 +123,12 @@ export declare const LEGACY_UNOWNED_AMNESTY_TENANT = "default";
122
123
  * 🪦 墓碑注(与第一臂同源):这是两个表示法之间的**过渡承接**。存量随会话生命周期消亡后,本臂
123
124
  * 连同 {@link LEGACY_UNOWNED_AMNESTY_TENANT} 与几处调用点可**整删**,不留兼容层。
124
125
  *
125
- * ── 逐面判过、**刻意不放行**的三处(免得后人当遗漏再补一次)────────────────────────────────
126
+ * ── 同步族(`…/sync/*`:拉取 / 推送 / 开导入 / 导入第二阶段)──────────────────────────────────
127
+ * 同步族四口自 7.134.0 同走本臂(表态见 7.134.0 发车帖;三条件不变):属主门是 `http/routes/session-sync.ts` 的一只布尔 `mayTouch`,与 fork / 删除同一只谓词、同一对读法
128
+ * (`sessionCallerOf` + `sessionOwnerCellOf`),不另立判据。这一族带破坏性的 import 腿,但单用户形下 `default` 是唯一用户,与已走本臂的删除同级,没有新增跨租风险;
129
+ * 多租形、非 `default` 主体、无主的 placed 行仍与不存在的会话同码同体。暂存句柄的归属不因本臂放宽(非 fleet 调用方只推自己开的暂存,fleet 调用方照旧可推任何一张)。
130
+ *
131
+ * ── 逐面判过、**刻意不放行**的两处(免得后人当遗漏再补一次)────────────────────────────────
126
132
  * · `runOwnerOk` 三读面(head / audit 单读 / events):`owner === null` 那一支**本来就放行**
127
133
  * (判据是 `owner !== null && principal !== owner`),不需要本臂。[ref] 帖文里「单读 404」一句
128
134
  * 经亲读实现行**不成立**,已加现状钉(session-head-probe.test.ts)锁住这个事实。
@@ -131,31 +137,32 @@ export declare const LEGACY_UNOWNED_AMNESTY_TENANT = "default";
131
137
  * 这把键,替它读写规则只能**猜**一个 principal(猜错 = 200 说已生效,其实没有哪条 run 读它)。已经存下的规则不受影响:
132
138
  * 它们存在当初那个属主的键下,那个 principal 的 run 照读照生效(7.119.0 前 local 后端重启即把属主忘掉,于是那些规则
133
139
  * 在跑、却读不到也删不掉 —— 修在属主落盘,不在放宽本门)。放宽它等于制造一条 fail-open,不在本臂辖域。
134
- * · `…/sync/*`(PULL/PUSH/import):PULL 虽是只读、形同 workspace,但这一族**带一条破坏性 import 腿**
135
- * (`isDestructiveSessionWrite` 明列),而 [ref]/[ref] 裁的是会话**读面与生命周期**四门。放宽一个
136
- * 写面族超出裁定射程 —— 要做另立一次表态,不在本臂里顺手带过。
137
140
  *
138
- * @param requirePrincipal `config.requirePrincipal`(条件①)
141
+ * @param deployment 部署形(条件①;读表行 `multiTenant`)
139
142
  * @param caller 调用方(条件③ 读它验过的主体;fleet-wide 面不经本臂)
140
- * @param cell 存量行那一格(条件②:无主,且经无主臂的唯一判据 {@link ownerlessRowOpen} —— 无主的委派子代 placed 行不在本臂,S-1770)
143
+ * @param cell 存量行那一格(条件②:无主,且经无主臂的唯一判据 {@link ownerlessRowOpen} —— 无主的委派子代 placed 行不在本臂,[ref])
141
144
  */
142
- export declare function legacyUnownedSessionOk(requirePrincipal: boolean, caller: SessionCaller, cell: SessionOwnerCell): boolean;
145
+ export declare function legacyUnownedSessionOk(deployment: DeploymentShapeInput<"principal">, caller: SessionCaller, cell: SessionOwnerCell): boolean;
143
146
  /**
144
147
  * {@link legacyUnownedSessionOk} 的**条件①③**半支 —— 只判「这个部署形 × 这个调用方」是否落在窄臂辖域内。
145
148
  *
146
149
  * 🔴 单独存在的唯一理由是**列表面**:`GET /v1/sessions` 的第三条件(`owner === null`)不在 JS 里判,
147
150
  * 它是 store 侧 `owner = ? OR owner IS NULL` 这一句 SQL 谓词 —— 三条件仍然齐,只是第三条件由 SQL 承载
148
151
  * (`listSessions({ owner, includeUnowned })` 的 `includeUnowned` 位即本函数的返回值)。
149
- * 单实体读/写点(fork/delete/workspace)**一律**用三条件齐的 {@link legacyUnownedSessionOk},不要用本函数。
152
+ * 单实体读/写点(fork/delete/同步族/workspace)**一律**用三条件齐的 {@link legacyUnownedSessionOk},不要用本函数。
153
+ */
154
+ export declare function legacyUnownedAmnestyOpen(deployment: DeploymentShapeInput<"principal">, gateOwner: string | null): boolean;
155
+ /**
156
+ * 本仓会话店的面 = core `SessionStore` + 本仓的行面(登记 / 列表 / 换装 / 同步……)。
157
+ * 🔴 **按 id 读一行只有一只**:core 的 `headOf(id)`(`{ owner, incarnation, leafId }`,同一行一次读;core 7.55.0 [ref] S2)。
158
+ * 属主 = `headOf(id)?.owner`、住客 = 头的 `incarnation`(比较用 core `compareOccupants`,拿令牌去写用 `sessionFaceOfHead`)、叶子 = 头的 `leafId`
159
+ * —— 此前本面另有五只按 id 读(`ownerOf` / `incarnationOf` / `sessionFaceOf` / `getHead` / `getLeafId`),全部退役;规则在 `src/session-incarnation.ts` 头注,
160
+ * 「店有没有这只读」只判 `headReadOf` 一处。
150
161
  */
151
- export declare function legacyUnownedAmnestyOpen(requirePrincipal: boolean, gateOwner: string | null): boolean;
152
162
  export type OwnerAwareSessionStore = SessionStore & {
153
- ownerOf?: (sessionId: string) => Promise<string | null | undefined>;
154
- /** S-790 / S-506([ref] §2)—— 属主 + **化身**一次读(`undefined` = 无此会话;行在而化身为空 ⇒ 响亮拒)。规则的唯一属主
155
- * 是 `src/session-incarnation.ts`。只关心属主的消费点照旧读 `ownerOf`;判「这还是不是同一位住客」的读它。 */
156
- sessionFaceOf?: SessionFaceReader;
163
+ /** 属主登记(core `SessionStore.register` 的契约:对没有行的 id 建行并记下属主,首写赢;对已有的行什么都不做)。读回走 `headOf`。 */
157
164
  register?: (sessionId: string, owner: string | null) => Promise<void>;
158
- /** S-1770 委派继承律的**认领口** —— 只在记录委派树的店上(SQL 两店,只命中 placed 行;local 店没有):判断时读到的那一位住客仍是无主的 placed 行 ⇒ 写 `owner`,
165
+ /** [ref] 委派继承律的**认领口** —— 只在记录委派树的店上(SQL 两店,只命中 placed 行;local 店没有):判断时读到的那一位住客仍是无主的 placed 行 ⇒ 写 `owner`,
159
166
  * 返回是否写成(只 CAS 子行自己)。唯一调用方 = 停驻挂点的 `settleDelegatedOwner`(`delegated-session-owner.ts`;M23 走同一句 SQL);规则写在那个模块。 */
160
167
  claimOwnerless?: OwnerlessClaim;
161
168
  /** [ref] placed 分区的元组读口(店的既有读口,一行 PK 读;`undefined` = 普通会话或无此行)。店不交它 = 不实现 placement = 没有 placed 行(local 店)。两个读者:
@@ -182,23 +189,15 @@ export type OwnerAwareSessionStore = SessionStore & {
182
189
  sessionSummaryOf?: (sessionId: string) => Promise<SessionListItem | undefined>;
183
190
  /** The session row's writable bits (`title` / `pinned`) — the ONLY writer of a user-set title or pin (`title: null` clears it back
184
191
  * to the automatic title; the auto-titler's `setTitleIfNull` fills a NULL title only; the law of the two writers is written in
185
- * `session-row.ts`). **Written on the occupant the caller verified, and only on it**: `face` is the {@link sessionFaceOf} read
192
+ * `session-row.ts`). **Written on the occupant the caller verified, and only on it**: `face` is the live occupant (`sessionFaceOfHead` over the `headOf` read)
186
193
  * the caller's gate judged; the write and the read-back are both conditioned on that occupant's incarnation (the same law as
187
194
  * the parked decide leg's two reads, `session-incarnation.ts`). Answers that occupant's list row after the write
188
195
  * ({@link sessionSummaryOf}'s projection); `undefined` = no list row for that occupant (deleted, re-registered by anyone in the
189
196
  * meantime, or a placed session) — nothing was written. A failed write throws. */
190
197
  patchSessionMeta?: (sessionId: string, patch: SessionRowPatch, face: SessionFace) => Promise<SessionListItem | undefined>;
191
- /** E17 — fork a session's whole history to a NEW session owned by `owner`; null if the source is unknown. */
198
+ /** E17 — fork a session's whole history to a NEW session; null if the source is unknown. The fork row records `owner` when it is a
199
+ * string, else (`null`) the SOURCE row's owner — a copy of an owned history is never anonymous (core `SessionStore.fork`, 7.55.0 S2). */
192
200
  fork?: (sourceId: string, owner: string | null) => Promise<string | null>;
193
- /** E18 — the session's current leaf `SessionTreeEntry.id` (a cache-bypassing single read), so the resume-at
194
- * turn-capture can pair it with the turn's message eventId. null when the session has no leaf / does not exist. */
195
- getLeafId?: (sessionId: string) => Promise<string | null>;
196
- /** [ref] 六轮复审:owner+leafId 单行原子快照(SSE watch 探针租户围栏读;两独立读在 delete/reclaim
197
- * 缝里可拼出混世代组合)。undefined=无此会话。 */
198
- getHead?: (sessionId: string) => Promise<{
199
- owner: string | null;
200
- leafId: string | null;
201
- } | undefined>;
202
201
  /** E21 — purge a session's conversation history (session_meta/session_event); idempotent (false if absent).
203
202
  * `owner` is the single-DB-fleet null-safe SQL owner guard on `session_meta.owner` (defense-in-depth — the
204
203
  * route already owner-gates; this pins the DELETE to the authenticated tenant so even a buggy gate can't purge