@sema-agent/server 7.145.0 → 7.147.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 +876 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +374 -99
  5. package/deploy/facts/CHANGES.json +25 -0
  6. package/deploy/facts/README.md +57 -0
  7. package/deploy/facts/lanes.json +61 -0
  8. package/deploy/facts/lanes.schema.json +57 -0
  9. package/deploy/facts/sandbox-rbac.json +113 -0
  10. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  11. package/deploy/facts/sealed-key.json +9 -0
  12. package/deploy/facts/sealed-key.schema.json +52 -0
  13. package/deploy/sema-up/README.md +2 -2
  14. package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
  15. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  16. package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
  17. package/deploy/sema-up/chart/templates/server.yaml +9 -4
  18. package/deploy/sema-up/chart/values.yaml +8 -1
  19. package/deploy/sema-up/cluster-up.sh +2 -1
  20. package/deploy/sema-up/lib/flagshape.sh +4 -0
  21. package/deploy/sema-up/lib/lanes.json +2 -5
  22. package/deploy/sema-up/sema-up.sh +12 -9
  23. package/deploy/sema-up/stack/compose.yaml +5 -4
  24. package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
  25. package/dist/adoption/import-limits.d.ts +6 -0
  26. package/dist/adoption/import-limits.js +7 -0
  27. package/dist/adoption/import.d.ts +62 -0
  28. package/dist/adoption/import.js +107 -0
  29. package/dist/adoption/wire.d.ts +52 -0
  30. package/dist/adoption/wire.js +9 -0
  31. package/dist/approval-ask-machine.d.ts +2 -2
  32. package/dist/approval-card.d.ts +7 -16
  33. package/dist/approval-card.js +0 -4
  34. package/dist/approval-gate-currency.d.ts +1 -1
  35. package/dist/approval-gate-currency.js +1 -1
  36. package/dist/approval-reconciler.d.ts +1 -1
  37. package/dist/approval.d.ts +3 -3
  38. package/dist/audit.js +2 -2
  39. package/dist/bench/s1/live-deps.js +3 -1
  40. package/dist/boot/crash-last.js +2 -1
  41. package/dist/boot/deployment-mods.d.ts +11 -1
  42. package/dist/boot/deployment-mods.js +15 -2
  43. package/dist/boot/device-lane.js +7 -5
  44. package/dist/boot/engine-lease.d.ts +195 -22
  45. package/dist/boot/engine-lease.js +146 -20
  46. package/dist/boot/execution-env.d.ts +5 -0
  47. package/dist/boot/execution-env.js +57 -33
  48. package/dist/boot/execution-lane.d.ts +37 -9
  49. package/dist/boot/execution-lane.js +74 -20
  50. package/dist/boot/exit-boundary.d.ts +50 -0
  51. package/dist/boot/exit-boundary.js +32 -0
  52. package/dist/boot/exit-last.d.ts +20 -4
  53. package/dist/boot/exit-last.js +23 -5
  54. package/dist/boot/governance-seams.d.ts +2 -2
  55. package/dist/boot/governance-seams.js +1 -0
  56. package/dist/boot/leader.js +1 -1
  57. package/dist/boot/memory-boundary.d.ts +11 -11
  58. package/dist/boot/memory-boundary.js +3 -3
  59. package/dist/boot/memory-consolidation.d.ts +42 -41
  60. package/dist/boot/memory-consolidation.js +26 -28
  61. package/dist/boot/org-memory.js +3 -2
  62. package/dist/boot/parked-revive-gate.d.ts +1 -1
  63. package/dist/boot/parked-revive-gate.js +1 -1
  64. package/dist/boot/reapers.d.ts +12 -4
  65. package/dist/boot/reapers.js +40 -16
  66. package/dist/boot/resolve-spec.d.ts +2 -0
  67. package/dist/boot/resolve-spec.js +126 -123
  68. package/dist/boot/retention-lane.d.ts +4 -42
  69. package/dist/boot/runner-deps.js +1 -1
  70. package/dist/boot/session-faces.d.ts +1 -0
  71. package/dist/boot/session-faces.js +11 -3
  72. package/dist/boot/shutdown.js +27 -9
  73. package/dist/boot/stage-01-config.d.ts +1 -1
  74. package/dist/boot/stage-01-config.js +7 -3
  75. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
  76. package/dist/boot/stage-02-web-admin-pull.js +10 -8
  77. package/dist/boot/stage-03-store-backend.d.ts +2 -1
  78. package/dist/boot/stage-03-store-backend.js +2 -2
  79. package/dist/boot/stage-04-stores.d.ts +2 -1
  80. package/dist/boot/stage-05-execution-env.d.ts +4 -1
  81. package/dist/boot/stage-05-execution-env.js +6 -6
  82. package/dist/boot/stage-06-runners.d.ts +5 -2
  83. package/dist/boot/stage-06-runners.js +12 -13
  84. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  85. package/dist/boot/stage-07-capability-layer.js +7 -7
  86. package/dist/boot/stage-08-reapers.d.ts +5 -2
  87. package/dist/boot/stage-08-reapers.js +3 -3
  88. package/dist/boot/stage-09-leader.d.ts +6 -2
  89. package/dist/boot/stage-10-http-server.d.ts +6 -2
  90. package/dist/boot/stage-10-http-server.js +5 -3
  91. package/dist/boot/stores.d.ts +10 -0
  92. package/dist/boot/stores.js +53 -26
  93. package/dist/boot/web-admin.js +3 -3
  94. package/dist/boot/workflow-orchestration.d.ts +1 -1
  95. package/dist/boot/workflow-orchestration.js +2 -1
  96. package/dist/capabilities/center-plugins.d.ts +2 -0
  97. package/dist/capabilities/center-plugins.js +6 -2
  98. package/dist/capabilities/composite-members.d.ts +4 -1
  99. package/dist/capabilities/composite-members.js +4 -1
  100. package/dist/capabilities/execution-lane.d.ts +7 -7
  101. package/dist/capabilities/execution-lane.js +2 -2
  102. package/dist/capabilities/hands-lane.d.ts +1 -1
  103. package/dist/capabilities/scenarios.d.ts +34 -20
  104. package/dist/capabilities/scenarios.js +13 -9
  105. package/dist/capabilities/settings-contract.d.ts +29 -0
  106. package/dist/capabilities/settings-contract.js +14 -0
  107. package/dist/capabilities/skills.d.ts +5 -5
  108. package/dist/capability-facts.d.ts +56 -1
  109. package/dist/capability-facts.js +59 -8
  110. package/dist/center-credential-renewer.js +3 -2
  111. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  112. package/dist/config-catalog.js +19 -9
  113. package/dist/config-invariants.d.ts +18 -3
  114. package/dist/config-invariants.js +36 -19
  115. package/dist/config-lkg.d.ts +1 -1
  116. package/dist/config-lkg.js +5 -6
  117. package/dist/config-provider.d.ts +2 -2
  118. package/dist/config-provider.js +2 -0
  119. package/dist/config-types.d.ts +228 -185
  120. package/dist/config.d.ts +74 -6
  121. package/dist/config.js +146 -64
  122. package/dist/degenerate-instrument.js +1 -1
  123. package/dist/deleted-session-ids.d.ts +19 -0
  124. package/dist/deleted-session-ids.js +26 -0
  125. package/dist/deploy-facts.d.ts +155 -0
  126. package/dist/deploy-facts.js +95 -0
  127. package/dist/deployment-shape.d.ts +21 -12
  128. package/dist/deployment-shape.js +24 -6
  129. package/dist/device-ws-hub.d.ts +48 -3
  130. package/dist/device-ws-hub.js +48 -2
  131. package/dist/env-facts.d.ts +7 -5
  132. package/dist/env-facts.js +10 -6
  133. package/dist/error-code-family.d.ts +35 -0
  134. package/dist/error-code-family.js +26 -0
  135. package/dist/execution-config-root.d.ts +5 -5
  136. package/dist/execution-config-root.js +5 -5
  137. package/dist/execution-env-purpose.d.ts +14 -0
  138. package/dist/execution-env-purpose.js +29 -0
  139. package/dist/execution-lane-caps.d.ts +49 -86
  140. package/dist/execution-lane-caps.js +52 -62
  141. package/dist/execution-placement.d.ts +18 -2
  142. package/dist/execution-placement.js +19 -0
  143. package/dist/file-history-disclosure.d.ts +2 -2
  144. package/dist/fleet/drain-entry.d.ts +46 -3
  145. package/dist/fleet/drain-entry.js +6 -0
  146. package/dist/fleet/fleet-bus.d.ts +2 -1
  147. package/dist/fleet/serving-lease.js +3 -4
  148. package/dist/history-anchor.d.ts +22 -0
  149. package/dist/history-anchor.js +14 -0
  150. package/dist/hooks/branch-transcript.d.ts +1 -1
  151. package/dist/hooks/branch-transcript.js +1 -0
  152. package/dist/hooks/classic-stations.d.ts +25 -8
  153. package/dist/hooks/classic-stations.js +29 -3
  154. package/dist/hooks/command-spawn.d.ts +1 -4
  155. package/dist/hooks/command-spawn.js +0 -11
  156. package/dist/hooks/hook-runner.d.ts +85 -24
  157. package/dist/hooks/hook-runner.js +326 -109
  158. package/dist/hooks/hook-source.d.ts +14 -2
  159. package/dist/hooks/hook-source.js +8 -0
  160. package/dist/http/active-run-conflict.d.ts +1 -1
  161. package/dist/http/active-run-conflict.js +1 -1
  162. package/dist/http/admission.js +11 -1
  163. package/dist/http/approval-sweeps.d.ts +2 -5
  164. package/dist/http/approval-sweeps.js +3 -2
  165. package/dist/http/checkpoint-ctx.d.ts +76 -71
  166. package/dist/http/checkpoint-ctx.js +40 -40
  167. package/dist/http/claim-latency.d.ts +10 -0
  168. package/dist/http/claim-latency.js +12 -0
  169. package/dist/http/dispatch.js +19 -3
  170. package/dist/http/durable-run-leg.d.ts +5 -0
  171. package/dist/http/durable-run-leg.js +3 -1
  172. package/dist/http/execution-context.d.ts +7 -1
  173. package/dist/http/execution-context.js +13 -0
  174. package/dist/http/health-self-report.d.ts +6 -2
  175. package/dist/http/health-self-report.js +3 -2
  176. package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
  177. package/dist/http/memory-compliance-failure-reply.js +5 -15
  178. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  179. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  180. package/dist/http/memory-store-refusal-reply.d.ts +3 -3
  181. package/dist/http/memory-store-refusal-reply.js +3 -0
  182. package/dist/http/owner-access.d.ts +11 -0
  183. package/dist/http/owner-access.js +7 -4
  184. package/dist/http/principal-gate.d.ts +28 -16
  185. package/dist/http/principal-gate.js +10 -19
  186. package/dist/http/request-guards.d.ts +2 -2
  187. package/dist/http/request-guards.js +5 -5
  188. package/dist/http/resume-legs.d.ts +29 -10
  189. package/dist/http/resume-legs.js +94 -56
  190. package/dist/http/rewind-files-reply.d.ts +34 -0
  191. package/dist/http/rewind-files-reply.js +36 -0
  192. package/dist/http/route-ctx.d.ts +43 -26
  193. package/dist/http/route-table.js +4 -0
  194. package/dist/http/routes/adoption.d.ts +11 -0
  195. package/dist/http/routes/adoption.js +80 -6
  196. package/dist/http/routes/agents-roster.js +1 -0
  197. package/dist/http/routes/approvals-assistant.js +7 -26
  198. package/dist/http/routes/background.js +1 -0
  199. package/dist/http/routes/capabilities.js +12 -3
  200. package/dist/http/routes/devices.js +1 -1
  201. package/dist/http/routes/diagnostics.d.ts +9 -14
  202. package/dist/http/routes/diagnostics.js +10 -20
  203. package/dist/http/routes/engine.d.ts +31 -0
  204. package/dist/http/routes/engine.js +81 -0
  205. package/dist/http/routes/memory-bundle.js +3 -0
  206. package/dist/http/routes/memory-consolidation.js +3 -5
  207. package/dist/http/routes/memory-origin.d.ts +2 -2
  208. package/dist/http/routes/memory-origin.js +2 -4
  209. package/dist/http/routes/memory-policy.js +5 -1
  210. package/dist/http/routes/notify-wake.js +2 -1
  211. package/dist/http/routes/observability.js +3 -6
  212. package/dist/http/routes/projects.d.ts +70 -0
  213. package/dist/http/routes/projects.js +86 -0
  214. package/dist/http/routes/rules.js +30 -2
  215. package/dist/http/routes/runs.js +15 -11
  216. package/dist/http/routes/session-sync.js +39 -35
  217. package/dist/http/routes/sessions-list.d.ts +1 -1
  218. package/dist/http/routes/sessions.d.ts +7 -1
  219. package/dist/http/routes/sessions.js +108 -2
  220. package/dist/http/routes/tasks.js +32 -8
  221. package/dist/http/routes/trace-usage.js +1 -1
  222. package/dist/http/run-concurrency-cap.d.ts +86 -0
  223. package/dist/http/run-concurrency-cap.js +54 -0
  224. package/dist/http/server.d.ts +31 -14
  225. package/dist/http/server.js +29 -3
  226. package/dist/http/stored-body-replay.d.ts +12 -7
  227. package/dist/http/stored-body-replay.js +28 -5
  228. package/dist/http/wire-types.d.ts +27 -13
  229. package/dist/index.d.ts +2 -2
  230. package/dist/index.js +1 -1
  231. package/dist/instruction-source-notice.d.ts +1 -1
  232. package/dist/json-body-limit.d.ts +8 -0
  233. package/dist/json-body-limit.js +2 -0
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/local-data-root.d.ts +2 -2
  236. package/dist/memory-embedder-reembed.d.ts +38 -0
  237. package/dist/memory-embedder-reembed.js +20 -0
  238. package/dist/memory-incident-sink.d.ts +0 -28
  239. package/dist/memory-incident-sink.js +5 -0
  240. package/dist/memory-operator-faces.d.ts +9 -4
  241. package/dist/memory-scope-stores.d.ts +9 -7
  242. package/dist/memory-scope-stores.js +3 -14
  243. package/dist/memory-scope.d.ts +38 -2
  244. package/dist/memory-scope.js +33 -2
  245. package/dist/memory-store-refusal.d.ts +17 -4
  246. package/dist/memory-store-refusal.js +1 -1
  247. package/dist/memory-sync-client.d.ts +2 -0
  248. package/dist/memory-sync-client.js +13 -11
  249. package/dist/memory-sync.js +1 -1
  250. package/dist/model-compat.d.ts +35 -21
  251. package/dist/model-compat.js +49 -21
  252. package/dist/model-entry-refusal.d.ts +11 -1
  253. package/dist/model-entry-refusal.js +7 -0
  254. package/dist/namespaced-rule-name.d.ts +18 -1
  255. package/dist/namespaced-rule-name.js +12 -0
  256. package/dist/net-address.d.ts +53 -0
  257. package/dist/net-address.js +111 -0
  258. package/dist/observability/fail-open.d.ts +29 -17
  259. package/dist/observability/fail-open.js +29 -17
  260. package/dist/observability/metrics.d.ts +2 -0
  261. package/dist/observability/metrics.js +2 -0
  262. package/dist/observability/secret-env-scrub.d.ts +30 -4
  263. package/dist/observability/secret-env-scrub.js +15 -3
  264. package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
  265. package/dist/orchestration/workflow-agent-session-index.js +1 -6
  266. package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
  267. package/dist/orchestration/workflow-completion-inbox.js +63 -45
  268. package/dist/orchestration/workflow-notify-journal.js +2 -3
  269. package/dist/org-delivery-gate.js +1 -1
  270. package/dist/org-memory-admission.d.ts +5 -2
  271. package/dist/org-memory-admission.js +25 -10
  272. package/dist/parked-decide.d.ts +33 -26
  273. package/dist/parked-decide.js +36 -44
  274. package/dist/peer-directory.d.ts +6 -12
  275. package/dist/peer-directory.js +5 -1
  276. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  277. package/dist/plugins/approval-ask-store-file.js +37 -4
  278. package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
  279. package/dist/plugins/approval-ask-store-memory.js +11 -2
  280. package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
  281. package/dist/plugins/approval-ask-store-sql.js +3 -1
  282. package/dist/plugins/blob-backend.d.ts +38 -195
  283. package/dist/plugins/blob-backend.js +33 -229
  284. package/dist/plugins/caching-session-store.d.ts +12 -5
  285. package/dist/plugins/caching-session-store.js +3 -0
  286. package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
  287. package/dist/plugins/checkpoint-index-columns.js +3 -2
  288. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  289. package/dist/plugins/checkpoint-store-face.js +152 -0
  290. package/dist/plugins/device-store-sql.d.ts +2 -2
  291. package/dist/plugins/device-store-sql.js +5 -10
  292. package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
  293. package/dist/plugins/execution-lane-rename-m40.js +10 -0
  294. package/dist/plugins/execution-placement-sql.d.ts +63 -88
  295. package/dist/plugins/execution-placement-sql.js +94 -54
  296. package/dist/plugins/file-run-store.d.ts +26 -18
  297. package/dist/plugins/file-run-store.js +64 -75
  298. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  299. package/dist/plugins/fork-routing-session-store.js +2 -2
  300. package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
  301. package/dist/plugins/imported-layer-root-retirement.js +4 -8
  302. package/dist/plugins/inbox-payload-column.d.ts +14 -0
  303. package/dist/plugins/inbox-payload-column.js +13 -0
  304. package/dist/plugins/local-checkpoint-store.d.ts +7 -2
  305. package/dist/plugins/local-checkpoint-store.js +13 -8
  306. package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
  307. package/dist/plugins/local-data-dir-modes-m39.js +182 -0
  308. package/dist/plugins/local-engine-high-water.d.ts +11 -0
  309. package/dist/plugins/local-engine-high-water.js +59 -0
  310. package/dist/plugins/local-session-store.d.ts +119 -30
  311. package/dist/plugins/local-session-store.js +156 -53
  312. package/dist/plugins/local-task-attachment-store.d.ts +2 -0
  313. package/dist/plugins/local-task-attachment-store.js +10 -11
  314. package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
  315. package/dist/plugins/memory-embedder-fingerprint.js +52 -12
  316. package/dist/plugins/memory-embedder.d.ts +1 -1
  317. package/dist/plugins/memory-embedder.js +2 -2
  318. package/dist/plugins/memory-engine-pg.d.ts +30 -6
  319. package/dist/plugins/memory-engine-pg.js +96 -214
  320. package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
  321. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  322. package/dist/plugins/memory-engine-tidb.d.ts +38 -9
  323. package/dist/plugins/memory-engine-tidb.js +99 -230
  324. package/dist/plugins/memory-key-guards.d.ts +1 -1
  325. package/dist/plugins/memory-origin-law.d.ts +3 -3
  326. package/dist/plugins/one-time-migrations.d.ts +169 -83
  327. package/dist/plugins/one-time-migrations.js +295 -235
  328. package/dist/plugins/owner-only-file-mode.d.ts +29 -0
  329. package/dist/plugins/owner-only-file-mode.js +141 -0
  330. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  331. package/dist/plugins/permission-rule-store-file.js +20 -1
  332. package/dist/plugins/pg-pool.d.ts +2 -1
  333. package/dist/plugins/pg-pool.js +12 -5
  334. package/dist/plugins/release-version.d.ts +20 -0
  335. package/dist/plugins/release-version.js +28 -0
  336. package/dist/plugins/remote-env-adb.d.ts +20 -4
  337. package/dist/plugins/remote-env-adb.js +39 -11
  338. package/dist/plugins/remote-env-e2b.d.ts +12 -3
  339. package/dist/plugins/remote-env-e2b.js +6 -4
  340. package/dist/plugins/remote-env-host.d.ts +9 -1
  341. package/dist/plugins/remote-env-host.js +6 -5
  342. package/dist/plugins/remote-env-k8s.d.ts +5 -2
  343. package/dist/plugins/remote-env-k8s.js +15 -4
  344. package/dist/plugins/remote-env-local-docker.d.ts +4 -1
  345. package/dist/plugins/remote-env-local-docker.js +3 -3
  346. package/dist/plugins/remote-env-ssh.d.ts +8 -2
  347. package/dist/plugins/remote-env-ssh.js +26 -24
  348. package/dist/plugins/remote-shell.d.ts +59 -30
  349. package/dist/plugins/remote-shell.js +175 -62
  350. package/dist/plugins/retention-declaration.d.ts +37 -0
  351. package/dist/plugins/retention-declaration.js +9 -0
  352. package/dist/plugins/retention-deployment.d.ts +126 -0
  353. package/dist/plugins/retention-deployment.js +88 -0
  354. package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
  355. package/dist/plugins/retention-lane-store-sql.js +103 -1
  356. package/dist/plugins/retention-sql.d.ts +29 -0
  357. package/dist/plugins/retention-sql.js +8 -0
  358. package/dist/plugins/run-store-sql.js +2 -2
  359. package/dist/plugins/schema-consistency.d.ts +0 -6
  360. package/dist/plugins/schema-consistency.js +1 -2
  361. package/dist/plugins/schema-ensure-legs.d.ts +1 -1
  362. package/dist/plugins/schema-ensure-legs.js +13 -3
  363. package/dist/plugins/session-ext-table.d.ts +74 -0
  364. package/dist/plugins/session-ext-table.js +121 -0
  365. package/dist/plugins/session-fork.d.ts +31 -9
  366. package/dist/plugins/session-fork.js +3 -2
  367. package/dist/plugins/session-placement.d.ts +4 -2
  368. package/dist/plugins/session-row-sql.d.ts +8 -7
  369. package/dist/plugins/session-row-sql.js +15 -7
  370. package/dist/plugins/session-store-sql.d.ts +131 -0
  371. package/dist/plugins/session-store-sql.js +298 -0
  372. package/dist/plugins/session-workspace-cell.d.ts +2 -2
  373. package/dist/plugins/session-workspace-cell.js +2 -2
  374. package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
  375. package/dist/plugins/shared-memory-store-sql.js +13 -13
  376. package/dist/plugins/snapshot-bucket-presence.js +1 -1
  377. package/dist/plugins/sql-driver.d.ts +23 -7
  378. package/dist/plugins/sql-driver.js +41 -8
  379. package/dist/plugins/sql-errors.d.ts +5 -2
  380. package/dist/plugins/sql-errors.js +4 -0
  381. package/dist/plugins/sql-json-column.d.ts +5 -1
  382. package/dist/plugins/store-backend.d.ts +46 -16
  383. package/dist/plugins/store-backend.js +192 -69
  384. package/dist/plugins/store-contracts.d.ts +10 -13
  385. package/dist/plugins/store-contracts.js +1 -9
  386. package/dist/plugins/store-sweep.d.ts +63 -0
  387. package/dist/plugins/store-sweep.js +48 -0
  388. package/dist/plugins/task-attachment-store.d.ts +6 -8
  389. package/dist/plugins/task-attachment-store.js +15 -10
  390. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  391. package/dist/plugins/text-column-capacity.d.ts +21 -0
  392. package/dist/plugins/text-column-capacity.js +5 -0
  393. package/dist/plugins/tidb-pool.d.ts +3 -2
  394. package/dist/plugins/tidb-pool.js +20 -32
  395. package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
  396. package/dist/prompt-screen.d.ts +6 -9
  397. package/dist/prompt-screen.js +2 -5
  398. package/dist/read-face-posture.d.ts +6 -6
  399. package/dist/read-face-posture.js +2 -2
  400. package/dist/request-value-closure.d.ts +5 -5
  401. package/dist/request-value-closure.js +1 -1
  402. package/dist/rules-consent.d.ts +48 -27
  403. package/dist/rules-consent.js +147 -23
  404. package/dist/run-cancel-context.d.ts +4 -1
  405. package/dist/run-cancel-context.js +2 -1
  406. package/dist/run-local.js +17 -13
  407. package/dist/runs.d.ts +48 -30
  408. package/dist/runs.js +27 -17
  409. package/dist/runtime-caps-resolver.d.ts +15 -8
  410. package/dist/runtime-caps-resolver.js +14 -10
  411. package/dist/sandbox-egress-policy.js +6 -11
  412. package/dist/sandbox-rbac-rules.d.ts +88 -0
  413. package/dist/sandbox-rbac-rules.js +80 -0
  414. package/dist/sealed-key-layout.d.ts +16 -0
  415. package/dist/sealed-key-layout.js +3 -0
  416. package/dist/sealed-key.js +8 -6
  417. package/dist/security.d.ts +43 -9
  418. package/dist/security.js +9 -2
  419. package/dist/sema-config-dir.js +2 -2
  420. package/dist/server-secret-env.d.ts +2 -0
  421. package/dist/service-version.d.ts +2 -1
  422. package/dist/service-version.js +2 -2
  423. package/dist/session-error-wire.d.ts +1 -1
  424. package/dist/session-incarnation.d.ts +8 -5
  425. package/dist/session-notify-door.d.ts +5 -3
  426. package/dist/session-resident-background.d.ts +110 -0
  427. package/dist/session-resident-background.js +88 -0
  428. package/dist/session-row.d.ts +1 -1
  429. package/dist/session-sync-kernel.d.ts +53 -14
  430. package/dist/session-sync-kernel.js +70 -1
  431. package/dist/session-sync.d.ts +5 -3
  432. package/dist/session-workspace.d.ts +12 -2
  433. package/dist/session-workspace.js +6 -0
  434. package/dist/sighup-idle.d.ts +9 -7
  435. package/dist/sighup-idle.js +4 -5
  436. package/dist/spec-fields.d.ts +16 -0
  437. package/dist/spec-fields.js +7 -0
  438. package/dist/store-posture.d.ts +2 -1
  439. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  440. package/dist/stored-request-env-credentials-m38.js +8 -0
  441. package/dist/stored-request-hooks-m20.d.ts +3 -2
  442. package/dist/stored-request-hooks-m20.js +19 -14
  443. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  444. package/dist/stores-sql/blob-index-sql.d.ts +148 -0
  445. package/dist/stores-sql/blob-index-sql.js +154 -0
  446. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
  447. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
  448. package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
  449. package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
  450. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  451. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  452. package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
  453. package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
  454. package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
  455. package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
  456. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  457. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  458. package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
  459. package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
  460. package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
  461. package/dist/stores-sql/session-write-hooks.d.ts +59 -0
  462. package/dist/stores-sql/session-write-hooks.js +2 -0
  463. package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
  464. package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
  465. package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
  466. package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
  467. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
  468. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  469. package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
  470. package/dist/stores-sql/windowed-session-storage.js +61 -0
  471. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  472. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  473. package/dist/task-a2a.d.ts +7 -1
  474. package/dist/task-a2a.js +15 -14
  475. package/dist/task-cwd.d.ts +11 -3
  476. package/dist/task-cwd.js +17 -1
  477. package/dist/task-mcp.d.ts +10 -2
  478. package/dist/task-mcp.js +13 -16
  479. package/dist/task-settings.d.ts +68 -8
  480. package/dist/task-settings.js +63 -6
  481. package/dist/tool-approval.d.ts +23 -10
  482. package/dist/tool-approval.js +10 -6
  483. package/dist/trace/core-keyset-guard.d.ts +17 -10
  484. package/dist/trace/engine-notice-wire.d.ts +1 -1
  485. package/dist/trace/engine-notice-wire.js +4 -0
  486. package/dist/trace/exit-seat.d.ts +29 -1
  487. package/dist/trace/exit-seat.js +4 -0
  488. package/dist/trace/project.d.ts +33 -16
  489. package/dist/trace/project.js +21 -9
  490. package/dist/trace/redact.d.ts +13 -2
  491. package/dist/trace/redact.js +347 -78
  492. package/dist/trace/self-minted-wire.d.ts +587 -16
  493. package/dist/trace/self-minted-wire.js +215 -9
  494. package/dist/trace/sema-provenance.d.ts +45 -41
  495. package/dist/trace/sema-provenance.js +81 -10
  496. package/dist/trace/task-notification-facets.d.ts +70 -2
  497. package/dist/trace/task-notification-facets.js +71 -1
  498. package/dist/trace/wire-projection-faces.d.ts +39 -3
  499. package/dist/trace/wire-projection-faces.js +27 -2
  500. package/dist/unread-request-members.d.ts +66 -0
  501. package/dist/unread-request-members.js +41 -0
  502. package/dist/usage-analytics.d.ts +4 -0
  503. package/dist/user-input-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/apply-effective.js +22 -26
  505. package/dist/web-admin-client/candidate-gate.d.ts +35 -3
  506. package/dist/web-admin-client/candidate-gate.js +53 -5
  507. package/dist/web-admin-client/center-request.d.ts +4 -1
  508. package/dist/web-admin-client/center-request.js +2 -1
  509. package/dist/web-admin-client/effective-keys.js +0 -1
  510. package/dist/web-admin-client/facade.d.ts +1 -1
  511. package/dist/web-admin-client/http-client.d.ts +1 -0
  512. package/dist/web-admin-client/http-client.js +17 -9
  513. package/dist/web-admin-client/restart-signal.js +5 -2
  514. package/dist/web-admin-client/skills-mcp.d.ts +20 -6
  515. package/dist/web-admin-client/skills-mcp.js +26 -21
  516. package/dist/web-admin-client/types.d.ts +34 -49
  517. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
  518. package/package.json +22 -13
  519. package/scripts/drain-check-local.mjs +8 -55
  520. package/scripts/drain-check.mysql.sql +3 -40
  521. package/scripts/drain-check.pg.sql +3 -40
  522. package/skills/update-config.md +1 -1
  523. package/wire-changes/server@7.146.0.json +3221 -0
  524. package/wire-changes/server@7.147.0.json +813 -0
  525. package/dist/approval-batch-census.d.ts +0 -27
  526. package/dist/approval-batch-census.js +0 -27
@@ -1,6 +1,6 @@
1
- import { type ExecutionLane, type RemoteExecProvider } from "../execution-lane-caps.js";
1
+ import { type ExecutionLane } from "../execution-lane-caps.js";
2
2
  export interface ExecutionLaneCapability {
3
- /** 本部署的执行车道词(闭集 = {@link ExecutionLane} 八词;`REMOTE_EXEC` 未设 ⇒ `"in-process"`,见头注 [ref] 段)。 */
3
+ /** 本部署的执行车道词(闭集 = {@link ExecutionLane} 八词;合成之后恒是部署声明的那一条;无手 = 声明的 `"none"`,见头注)。 */
4
4
  readonly provider: ExecutionLane;
5
5
  /** 工具跑的那台机器就是本进程这台吗(= server 盘上的绝对路径对模型的工具有没有意义)。
6
6
  * 属主 = 部署形表行 `toolsOnThisHost`,与 `skills[].baseDir` 的铸点同一行。 */
@@ -11,13 +11,13 @@ export interface ExecutionLaneCapability {
11
11
  }
12
12
  /**
13
13
  * 部署席 → 消费端窄投影。形照 `projectWebSearchCapability` / `projectSqlEngineCapability`:
14
- * 不碰 config.ts(只从车道表模块取词与归一读口,那是叶),于是本模块是叶。
14
+ * 不碰 config.ts(只从车道表模块取能力位,那是叶),于是本模块是叶。
15
15
  *
16
- * 🔴 本处**不写**任何缺席折词([ref] 门 D):缺席归一只在 {@link executionLaneOf} 一处。
16
+ * 🔴 本处**不写**任何缺席折词([ref] 门 D):入参是已合成的配置,车道必在(没有声明的部署在合成步拒启)。
17
17
  */
18
18
  export declare function projectExecutionLaneCapability(config: {
19
- readonly remoteExec?: {
20
- readonly provider: RemoteExecProvider;
21
- } | undefined;
19
+ readonly remoteExec: {
20
+ readonly provider: ExecutionLane;
21
+ };
22
22
  }): ExecutionLaneCapability;
23
23
  //# sourceMappingURL=execution-lane.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { DEPLOYMENT_SHAPE_PREDICATES } from "../deployment-shape.js";
2
- import { executionLaneOf, laneIsolated, laneWiresExecutionEnv } from "../execution-lane-caps.js";
2
+ import { laneIsolated, laneWiresExecutionEnv } from "../execution-lane-caps.js";
3
3
  export function projectExecutionLaneCapability(config) {
4
- const lane = executionLaneOf(config.remoteExec?.provider);
4
+ const lane = config.remoteExec.provider;
5
5
  const handsWired = laneWiresExecutionEnv(lane);
6
6
  return {
7
7
  provider: lane,
@@ -42,7 +42,7 @@ export declare function pickHandsRunner(hands: ScenarioHands, pair: HandsRunnerP
42
42
  /**
43
43
  * 一个场景在一台部署上起的 run **有没有工作区** —— core prepare 的 `handsEnabled`(`ownedEnv || deps.executionEnv`)在本仓的镜像,**唯一一只判官**。
44
44
  * 两个条件缺一不可:场景挂手({@link pickHandsRunner} 选有手 Runner,即带 `executionEnvFactory` 的那只)∧ 这台部署的执行车道有手
45
- * (`execution-lane-caps.ts` 的 `laneWiresExecutionEnv`:`in-process` 车道整台没有 factory)。引擎对 `userAttachments` 里 `path` 条目的拒
45
+ * (`execution-lane-caps.ts` 的 `laneWiresExecutionEnv`:`none` 车道整台没有 factory)。引擎对 `userAttachments` 里 `path` 条目的拒
46
46
  * (`config.user_attachment_invalid`「this run has no workspace」)与场景详情读面的 `attachmentSupplies` 都落在这一只的答案上。
47
47
  * **穷举 switch**:`ScenarioHands` 加词而此处不表态 = 编译红(与 {@link pickHandsRunner} 同一条纪律)。
48
48
  */
@@ -73,10 +73,9 @@ export declare function buildExcludeToolsSeat(scenarioExcludes: readonly string[
73
73
  */
74
74
  export interface ScenarioContext {
75
75
  /**
76
- * 本请求的会话 id。属主 = `boot/resolve-spec.ts` 的 `auth.sessionId`(authorizer 解析 + 归属校验
77
- * 过的那一只),**绝不是 `body.sessionId`** —— 后者是调用方自报串,拿它当会话级设施的分区键
78
- * 等于让一个租户读另一个租户的清单(同 spec 组装处那条「sessionId comes from `auth`, NEVER the
79
- * body」的逐字纪律)。
76
+ * 本请求的会话 id。属主 = `boot/resolve-spec.ts` 的 `root`(= `opts.execution.root`:authorizer 解析 + 归属校验
77
+ * 过的那一只,续跑 = checkpoint 的会话),**绝不是 `body.sessionId`** —— 后者是调用方自报串,拿它当会话级设施的分区键
78
+ * 等于让一个租户读另一个租户的清单(同 spec 组装处那条「根来自执行上下文,绝不来自请求体」的逐字纪律)。
80
79
  *
81
80
  * 缺席 = 这条调用形本来就没有会话(`parked-revive-surface.ts` 对不交座的行、boot 期那一次 Agent 工具探针、
82
81
  * `builtinScenarioDetails` 的工具名探针)。此时会话级设施退化为 per-call 实例 —— 不为它发明
@@ -105,7 +104,7 @@ export interface ScenarioDeps {
105
104
  * could exfil via an arbitrary public URL; the SSRF floor only blocks internal). Single-user TOC keeps WebFetch. */
106
105
  requirePrincipal?: boolean;
107
106
  /**
108
- * [ref]:这台部署的执行车道**有没有手**(`laneWiresExecutionEnv`;`REMOTE_EXEC` 未设 = `in-process` = 没有)。场景详情读面据它与场景自己的 `hands` 表态一起答
107
+ * [ref]:这台部署的执行车道**有没有手**(`laneWiresExecutionEnv`;声明 `REMOTE_EXEC=none` = 没有)。场景详情读面据它与场景自己的 `hands` 表态一起答
109
108
  * 「这个场景的 run 有没有工作区」({@link runHasWorkspace}),进而给出附件可受理供给集。**缺席按没有手读**(宁少说不多说:不广告一个会撞 400 的 `path`)。
110
109
  */
111
110
  handsLane?: boolean;
@@ -157,8 +156,8 @@ export interface ScenarioDeps {
157
156
  }) => Promise<void>;
158
157
  /**
159
158
  * **Runner 之外的后台子代完成**交给哪里 —— 按委派树根见证({@link ScenarioContext.delegationRoot})造委派工具挂载期的 `background.notify`。
160
- * 停驻赎回腿的复活、操作员 `handle.resume` 都不是哪一次 run 内的调用,没有调用车道;引擎只在能解出一只完成 sink(调用 ?? 挂载)时才起后台续跑,
161
- * 解不出 ⇒ 拒(`revive.no_background`)。sink = 委派树根会话的会话通知门(`session-notify-door.ts` 的 `createBackgroundCompletionRelay`;律与地址、
159
+ * 操作员 `handle.resume` 与停驻落在别的进程的停驻赎回腿复活都不是哪一次 run 内的调用,本进程也没有它们欠账的车道;引擎只在能解出一只完成 sink
160
+ * (调用 ?? 停驻车道 ?? 挂载)时才起后台续跑,解不出 ⇒ 拒(`revive.no_background`)。本进程持有停驻的赎回(core 7.63.0)完成回停驻车道,不调这只 sink。sink = 委派树根会话的会话通知门(`session-notify-door.ts` 的 `createBackgroundCompletionRelay`;律与地址、
162
161
  * 竞态、条目形都写在那里)。Runner 之内的调用照旧走调用车道,这只 sink 不被调。缺席(没有门的装配:run-local)⇒ 不接 ——
163
162
  * 不接一只空 sink(接了 = 引擎起续跑、完成没人收)。
164
163
  */
@@ -350,6 +349,16 @@ export interface ScenarioRuling {
350
349
  /** 纯场景名集合(principal/组名不上 wire);空 = 该 principal 无任何指派 = 无治理。 */
351
350
  allowlist: string[];
352
351
  }
352
+ /**
353
+ * 一次中心裁定读数(`principalCaps.scenarioRuling` / `peekScenarioRuling` 的答)—— **三态,各恰一条出路**({@link gateScenarioRequest} 逐态判):
354
+ * · {@link ScenarioRuling} —— 中心答了治理两键 ⇒ 按它执法(指派为缺省、白名单限点名);
355
+ * · `undefined`(**缺席**)—— 这一问没有中心可问,或中心答了但不管场景:部署没接中心(无中心 / 干跑 / `run-local` / 嵌入方不给)、
356
+ * 匿名运行(无 principal,零中心往返)、旧中心不发治理两键 ⇒ 无治理,请求名或部署缺省;
357
+ * · `"unavailable"`(**故障**)—— 部署接了中心、请求带 principal,而这一问答不出来:不可达 / 超时 / 答复读不出(非 2xx、体判坏、
358
+ * 回声不符、在飞期间凭据身份换了)/ 治理两键形不对 ⇒ 该 run 拒。这位主体此刻的指派与白名单不可知:缺省链可能比他的指派更宽,点名也判不了白名单。
359
+ * 缺席与故障的界画在「有没有中心可问」:读数的客户端只在部署接了中心时存在,没接中心的部署走不到故障态。
360
+ */
361
+ export type ScenarioRulingRead = ScenarioRuling | "unavailable" | undefined;
353
362
  /**
354
363
  * 一个场景名的**来源**(闭集:新增一词 ⇒ {@link danglingScenarioRefusal} 的穷尽 switch 编译红)。
355
364
  * · `ruling` —— 中心按主体指派的场景(`ScenarioRuling.scenario`);
@@ -373,17 +382,21 @@ export declare function danglingScenarioRefusal(name: string, source: ScenarioNa
373
382
  /**
374
383
  * resolveSpec 的执法入口(指派为默认、body.scenario 可换但限 allowlist)。返回本请求的
375
384
  * **在册**生效场景名 —— 返回值一定在 `known` 里:下游直接按它取场景,没有「未知名 → default」的回退臂。
385
+ * 读数 `ruling` 三态各一条出路({@link ScenarioRulingRead}),判序:
386
+ *
387
+ * 1. body.scenario 显式给出而不在册 ⇒ typed 400 `scenario_unknown`(调用方的错;词表面先于治理面,不等中心)。
388
+ * 2. 读数 `"unavailable"`(中心配了却答不出)⇒ 503 `state.scenario_assignment_unavailable`(体 `permanence: "transient"`:这一拍答不出,
389
+ * 不是准入策略 —— 续跑腿据它不折成 409 `resume_blocked_by_policy`,见 `http/checkpoint-ctx.ts` 的 `resumeAssemblyRefusalAnswer`),点名与不点名同拒 ——
390
+ * 这位主体的指派与白名单此刻不可知,缺省链不能替他答,点名也判不了白名单。运维日志一行 `scenario_assignment_unavailable`(`principal`;
391
+ * 取数失败本身由主体客户端的 `onError` 另记一行)。
392
+ * 3. body.scenario 显式给出(在册):白名单非空且集外 ⇒ typed 400 `scenario_not_allowed`(附 allowlist —— 机器码归 wire、人话归壳 / web);
393
+ * 集内,或白名单为空(缺席 / 中心答了「无指派」)⇒ 用户主动切换赢。
394
+ * 4. body.scenario 未给:ruling 胜者 ⇒ 指派为默认;无胜者(缺席 / `scenario: null`)⇒ defaultScenario。链上的名字不在册 ⇒ 503
395
+ * `state.scenario_assignment_unknown`(部署的错 / 中心的错,不是调用方的错),**不**折 default({@link danglingScenarioRefusal})。
376
396
  *
377
- * - body.scenario 显式给出:不在册 ⇒ typed 400 `scenario_unknown`(调用方的错);allowlist 非空且集外 ⇒ typed 拒绝
378
- * (400 `scenario_not_allowed`,附 allowlist ——机器码归 wire、人话归壳/web);集内 ⇒ 用户主动切换赢。allowlist 为空
379
- * (无 ruling / 该 principal 三层皆无指派 / caps 面故障)⇒ 无治理约束,现状放行(与「null 落兜底链」同一语义:分配面未覆盖 =
380
- * 不收紧,恒不比没有治理时更宽;caps 故障不把用户锁死在 default——场景切换不是权限放大面,fail-open
381
- * 到现状,与 workflows 面的 fail-closed 是刻意的 posture 差异,见 runtime-caps-resolver)。
382
- * - body.scenario 未给:ruling 胜者 ⇒ 指派为默认;无胜者 ⇒ defaultScenario 现状链。链上的名字不在册 ⇒ 503
383
- * `state.scenario_assignment_unknown`(部署的错 / 中心的错,不是调用方的错),**不**折 default
384
- * ({@link danglingScenarioRefusal})。`principal` 只进那一行运维日志,不参与判定。
397
+ * `principal` 只进运维日志,不参与判定。
385
398
  */
386
- export declare function gateScenarioRequest(ruling: ScenarioRuling | undefined, bodyScenario: unknown, defaultScenario: string, known: readonly string[], logger?: Logger, principal?: string): string;
399
+ export declare function gateScenarioRequest(ruling: ScenarioRulingRead, bodyScenario: unknown, defaultScenario: string, known: readonly string[], logger?: Logger, principal?: string): string;
387
400
  /**
388
401
  * 一条请求的场景名过门 —— {@link gateScenarioRequest} 的**唯一一处实参装配**。
389
402
  *
@@ -395,7 +408,8 @@ export declare function gateScenarioRequest(ruling: ScenarioRuling | undefined,
395
408
  *
396
409
  * 契约:`(principal, requested) => 在册的场景名`(返回值一定在册;被拒 ⇒ 抛 {@link gateScenarioRequest} 的那几只 typed 错,
397
410
  * 读口不改写)。`requested` 非串(缺席)⇒ 门走指派链(ruling 胜者,否则部署缺省),与 run 时同一读法。
398
- * `principalCaps` 缺席(无中心 / 干跑 / 嵌入方 / `run-local`)⇒ 无 ruling,门退回「请求名或部署缺省」那条现状链。
411
+ * `principalCaps` 缺席(无中心 / 干跑 / 嵌入方 / `run-local`)⇒ 读数恒缺席,门走「请求名或部署缺省」那条链;
412
+ * 在场 ⇒ 它的读数三态({@link ScenarioRulingRead})原样交门,故障态由门拒。
399
413
  */
400
414
  export interface ScenarioGateSources {
401
415
  readonly config: {
@@ -404,8 +418,8 @@ export interface ScenarioGateSources {
404
418
  /** 场景表(活引用):词表按调用时的自有键取,与表同生同灭。 */
405
419
  readonly scenarios: Readonly<Record<string, unknown>>;
406
420
  readonly principalCaps: {
407
- scenarioRuling(principal: string | undefined): Promise<ScenarioRuling | undefined>;
408
- peekScenarioRuling(principal: string | undefined): Promise<ScenarioRuling | undefined>;
421
+ scenarioRuling(principal: string | undefined): Promise<ScenarioRulingRead>;
422
+ peekScenarioRuling(principal: string | undefined): Promise<ScenarioRulingRead>;
409
423
  } | undefined;
410
424
  readonly logger?: Logger;
411
425
  }
@@ -413,7 +427,7 @@ export type ScenarioGate = (principal: string | undefined, requested: unknown) =
413
427
  /**
414
428
  * 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `peekRuntimeCaps` 是同一对:
415
429
  * · `enforce` —— 任务提交腿:中心裁定走执法腿,center 硬失败铸下的 fail-closed 降级项两腿都认;
416
- * · `peek` —— 读面(`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份 fail-open 判决,但硬失败铸的降级项只对读面自己算数,
430
+ * · `peek` —— 读面(`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份读数(中心答不出 ⇒ 读面同拒),但硬失败铸的降级项只对读面自己算数,
417
431
  * 不替这个主体的真提交留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面不许成为别人被拒的原因)。
418
432
  */
419
433
  export type ScenarioGateLeg = "enforce" | "peek";
@@ -285,6 +285,7 @@ export function buildRunSkills(args, logger) {
285
285
  logger?.warn("user_skills_dropped", { reason: "name reserved by scenario (or duplicate)", names: dropped });
286
286
  return { specs, roster };
287
287
  }
288
+ const SCENARIO_ASSIGNMENT_UNAVAILABLE_REFUSAL = "this principal's scenario assignment could not be read — the configuration center did not answer (unreachable, timed out, or an unreadable reply), so no scenario was assigned and nothing ran — retry once the center answers again (the operator restores the link from this deployment to its configuration center)";
288
289
  function registeredScenariosClause(known) {
289
290
  return `this deployment's scenarios are: ${known.join(", ")}`;
290
291
  }
@@ -303,22 +304,25 @@ export function danglingScenarioRefusal(name, source, known) {
303
304
  }
304
305
  }
305
306
  export function gateScenarioRequest(ruling, bodyScenario, defaultScenario, known, logger, principal) {
307
+ if (typeof bodyScenario === "string" && !known.includes(bodyScenario)) {
308
+ throw new HttpError(400, `unknown scenario "${bodyScenario}" — ${registeredScenariosClause(known)}`, {
309
+ code: "scenario_unknown",
310
+ extra: { known: [...known] },
311
+ });
312
+ }
313
+ if (ruling === "unavailable") {
314
+ logger?.warn("scenario_assignment_unavailable", principal !== undefined ? { principal } : {});
315
+ throw createCodedHttpError(503, "state.scenario_assignment_unavailable", SCENARIO_ASSIGNMENT_UNAVAILABLE_REFUSAL, { permanence: "transient" });
316
+ }
306
317
  if (typeof bodyScenario === "string") {
307
- const requested = bodyScenario;
308
- if (!known.includes(requested)) {
309
- throw new HttpError(400, `unknown scenario "${bodyScenario}" — ${registeredScenariosClause(known)}`, {
310
- code: "scenario_unknown",
311
- extra: { known: [...known] },
312
- });
313
- }
314
318
  const allowed = ruling?.allowlist ?? [];
315
- if (allowed.length > 0 && !allowed.includes(requested)) {
319
+ if (allowed.length > 0 && !allowed.includes(bodyScenario)) {
316
320
  throw new HttpError(400, `scenario "${bodyScenario}" is not in this principal's assigned allowlist`, {
317
321
  code: "scenario_not_allowed",
318
322
  extra: { allowlist: allowed },
319
323
  });
320
324
  }
321
- return requested;
325
+ return bodyScenario;
322
326
  }
323
327
  const [name, source] = ruling?.scenario != null ? [ruling.scenario, "ruling"] : [defaultScenario, "deployment"];
324
328
  const refusal = danglingScenarioRefusal(name, source, known);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `GET /v1/capabilities` 的 `settingsContract` 位 —— **本服务内嵌的设置契约是哪一版、它的读者对每一型 hook 条目携带哪些字段**(版本位:恒在场,不随部署形变)。
3
+ *
4
+ * ## 病
5
+ * 一个键会不会被本服务的读者当契约外键剥掉(续跑重放腿)/ 在新提交面 400(键闭集门),今天消费方只能靠自己维护的「哪一版服务端认哪些键」代际表猜 ——
6
+ * 契约包一升版(例:19.0.0 起 command 条目承运 `args` / `onFailure`、http 条目承运 `onFailure`),那张表就漂。答案的真源在读者这一侧,所以由读者说。
7
+ *
8
+ * ## 形
9
+ * `{ version: string, hookEntryFields: { command | prompt | agent | http | mcp_tool: string[] } }`:
10
+ * · `version` —— 已装 `@sema-agent/settings-schema` 的 package.json 版本号,读口唯一(`web-admin-client/center-request.ts` 的 {@link SETTINGS_SCHEMA_VERSION},对中心协商的 major 也由它派生);
11
+ * · `hookEntryFields` —— 契约条目字段表按型的投影,**只投键名,不投取值类**;列序 = 契约分类器装上的条目的键序(判别位 `type` 不在列里)。
12
+ * 值源 = 契约包导出的字段表 {@link HOOK_ENTRY_FIELDS}(深冻结;本仓零镜像)—— 本模块不手抄、不另持。
13
+ * 「读者携带 ≠ 本服务执行」:本服务只跑 command / http / prompt / agent 四型(`mcp_tool` 整份拒,见 `hooks/hook-runner.ts` 的 `HOOK_ENTRY_TYPE_RUNS`),
14
+ * 列里也有本服务如实带、不执行的键(command 的 `rewakeMessage` / `rewakeSummary` / `cloud`、http 的 `cloud`、prompt 的 `continueOnBlock`);
15
+ * hooks 整只是否被采纳看 `taskSettings.hooks`;本位只答「契约面上这一型有哪些字段」。
16
+ */
17
+ import { type HookEntryFields, type HookEntryType } from "@sema-agent/settings-schema/hooks";
18
+ /** 一型的契约字段名(导出字段表那一行的键;判别位 `type` 不在表里)。 */
19
+ export type HookContractEntryField<T extends HookEntryType> = Extract<keyof HookEntryFields[T], string>;
20
+ /** 能力位 `settingsContract` 的形。 */
21
+ export interface SettingsContractCapability {
22
+ readonly version: string;
23
+ readonly hookEntryFields: {
24
+ readonly [T in HookEntryType]: readonly HookContractEntryField<T>[];
25
+ };
26
+ }
27
+ /** 能力位的值(纯数据;进程内不变,装载时投影一次)。列的顺序随导出表的型序。 */
28
+ export declare const SETTINGS_CONTRACT_CAPABILITY: SettingsContractCapability;
29
+ //# sourceMappingURL=settings-contract.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { HOOK_ENTRY_FIELDS } from "@sema-agent/settings-schema/hooks";
2
+ import { SETTINGS_SCHEMA_VERSION } from "../web-admin-client/center-request.js";
3
+ const columnOf = (type) => Object.keys(HOOK_ENTRY_FIELDS[type]);
4
+ export const SETTINGS_CONTRACT_CAPABILITY = {
5
+ version: SETTINGS_SCHEMA_VERSION,
6
+ hookEntryFields: {
7
+ command: columnOf("command"),
8
+ prompt: columnOf("prompt"),
9
+ agent: columnOf("agent"),
10
+ http: columnOf("http"),
11
+ mcp_tool: columnOf("mcp_tool"),
12
+ },
13
+ };
14
+ //# sourceMappingURL=settings-contract.js.map
@@ -1,5 +1,5 @@
1
1
  import type { SkillSpec } from "@sema-agent/core";
2
- import type { RemoteExecProvider } from "../execution-lane-caps.js";
2
+ import type { ExecutionLane } from "../execution-lane-caps.js";
3
3
  import { type Logger } from "../observability/logger.js";
4
4
  /**
5
5
  * Built-in skills baked into the image, loaded ONCE at startup (no per-task disk IO). A skill is a
@@ -79,13 +79,13 @@ export declare function loadSkills(dir: string, opts: LoadSkillsOptions): Loaded
79
79
  * 各写一遍 `loadSkills(config.skillsDir, { toolsShareThisFilesystem: <车道判据>(config) })`,测试只能
80
80
  * 直传布尔去证 `loadSkills`(`baked-skills.test.ts`),证不到「config → 装配腿 → baseDir」这一段;收成一只
81
81
  * 之后,联合格从 config 走到 `baseDir`(`test/capabilities-http.test.ts` [ref] 段)证的就是两处装配点本人。
82
- * 判据属主:部署形表行 `toolsOnThisHost`([ref];[ref] 起 in-process ⇒ 假 ⇒ 目录形技能不带 `baseDir`)。
82
+ * 判据属主:部署形表行 `toolsOnThisHost`([ref];无手车道 `none` ⇒ 假 ⇒ 目录形技能不带 `baseDir`)。
83
83
  */
84
84
  export declare function loadDeploymentSkills(config: {
85
85
  readonly skillsDir: string;
86
- readonly remoteExec?: {
87
- readonly provider: RemoteExecProvider;
88
- } | undefined;
86
+ readonly remoteExec: {
87
+ readonly provider: ExecutionLane;
88
+ };
89
89
  }, logger?: Logger): LoadedSkill[];
90
90
  /** 一个技能范围交进 `TaskSpec` 的技能(场景工厂的 `skills`)。范围从哪来见 `scenarios.ts` 的 `BUILTIN_SCENARIO_SKILL_SCOPE`(center 场景 = 它自己的名字)。 */
91
91
  export declare function skillsForScenario(loaded: readonly LoadedSkill[], scope: string): SkillSpec[];
@@ -25,6 +25,8 @@ import type { ServiceBlobExchange, ServiceFileHistoryStore } from "./plugins/sto
25
25
  import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
26
26
  import { type WorkspaceSyncCapability } from "./workspace-space.js";
27
27
  import type { WorkspaceCacheCapability } from "./workspace-cache.js";
28
+ import type { ResumeAnchorStore } from "./plugins/store-backend.js";
29
+ import type { EngineHandoverDoor } from "./boot/engine-lease.js";
28
30
  /** why 闭集:词 → 给运维看的一句义(诊断 / 测试读它;wire 上的拒句由各门自写)。 */
29
31
  export declare const CAPABILITY_FACT_WHY: {
30
32
  readonly run_store_absent: "no durable run store is wired (DB_BACKEND=mysql|pg|local)";
@@ -43,6 +45,11 @@ export declare const CAPABILITY_FACT_WHY: {
43
45
  readonly session_policy_store_absent: "no session policy store is wired";
44
46
  readonly store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)";
45
47
  readonly file_history_store_absent: "no file-history store is wired";
48
+ readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)";
49
+ readonly execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind";
50
+ readonly workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from";
51
+ readonly session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance";
52
+ readonly file_history_preview_absent: "the file-history store implements no diffStats preview (the SQL backends)";
46
53
  readonly session_export_absent: "the session store has no entry export faces (exportEntries / exportEntriesStream)";
47
54
  readonly session_import_staging_absent: "the session store has no staged-import face (beginImportStaging)";
48
55
  readonly policy_purge_absent: "the session policy store has no deleteBySession purge verb";
@@ -80,6 +87,7 @@ export declare const CAPABILITY_FACT_WHY: {
80
87
  readonly read_root_grant_posture_refused: "this is not a single-user host-lane deployment (REMOTE_EXEC=host without REQUIRE_PRINCIPAL), the only posture that honors a read-directory grant";
81
88
  readonly background_agent_store_absent: "no background-agent store is wired";
82
89
  readonly sendfile_ledger_absent: "no SendUserFile ledger is wired";
90
+ readonly project_registry_absent: "no project registry is served here: projects are published only by the configuration center (settings-schema does not read the projects domain from the local config.d), and no center configuration is applied (SEMA_WEB_ADMIN_URL unset, or SEMA_WEB_ADMIN_DRY_RUN on)";
83
91
  readonly workflow_engine_absent: "the workflow engine is not available on this worker";
84
92
  readonly entitlement_resolver_absent: "self-orchestration is on for a multi-tenant worker with no per-principal entitlement source";
85
93
  readonly workflow_run_store_absent: "no workflow run store is wired (SELF_ORCHESTRATION_ENABLED)";
@@ -91,6 +99,8 @@ export declare const CAPABILITY_FACT_WHY: {
91
99
  readonly workspace_snapshot_store_absent: "no workspace snapshot store is configured (MINIO_ENDPOINT / MINIO_ACCESS_KEY / MINIO_SECRET_KEY)";
92
100
  readonly workspace_cache_off: "the build-cache volume per workspace space is off (WORKSPACE_CACHE=off, the default)";
93
101
  readonly deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)";
102
+ readonly engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)";
103
+ readonly engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)";
94
104
  };
95
105
  export type CapabilityFactWhy = keyof typeof CAPABILITY_FACT_WHY;
96
106
  /** 不可用臂。 */
@@ -198,6 +208,29 @@ export declare function sessionSyncFileHistory(d: Pick<Deps, "backend" | "sessio
198
208
  historyStore: ServiceFileHistoryStore;
199
209
  blobExchange: ServiceBlobExchange;
200
210
  }>;
211
+ type RewindFilesWhy = "file_history_store_absent" | "session_head_face_absent" | "resume_anchor_store_absent" | "execution_lane_handless" | "workspace_rebuilt_per_task" | "session_store_shared";
212
+ /**
213
+ * run 外的「只恢复代码」口(`POST /v1/sessions/:id/rewind-files`,[ref])这台部署**解不解得出** —— 能力位 `sessionRewindFiles` 与该口的 501 读这一只。
214
+ * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(引擎 `Runner.rewindFiles` 读的同一只;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、不摘店,
215
+ * 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店(`to` 手柄经它翻成 entry id,`history-anchor.ts`)∧ 执行车道有手
216
+ * (无手车道上引擎恒拒 `rewind.files_env_unsupported`:没有工作区可回退 —— 位说有而口恒拒不许发生)∧ 即时回退的工作区活过一次执行(部署形表行 `rewindableWorkspace`;
217
+ * 否则恢复的结果到不了下一次执行)∧ 会话店由本进程独占(local 后端:数据根被一个活进程锁住 ⇒ 引擎的进程内会话锁就是全局互斥;
218
+ * SQL 后端被多副本共用,而 run 外回退还没有一只跨副本的持久认领 —— 「先查认领再交引擎」只是检查不是互斥,所以在共享店上位为假、口 501,不留「检查即放行」)。
219
+ * 动词本身是引擎 `Runner` 的必有成员(型上必在),不是一格。
220
+ * 见证 = 判过在场的三只设施;路由在拒臂之后只读见证。
221
+ */
222
+ export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
223
+ historyStore: ServiceFileHistoryStore;
224
+ anchors: ResumeAnchorStore;
225
+ sessionStorage: HeadReadingSessionStore;
226
+ }>;
227
+ /**
228
+ * 同一口的 `dryRun` **带不带改动统计** —— 能力位 `sessionRewindFilesPreview`。= 立即回退可用 ∧ 店实现了 core 契约的可选座 `diffStats`
229
+ * (引擎在 `dryRun` 上读的就是这一座:缺座 ⇒ 应答 `preview: null`)。逐后端如实:core 的文件店有,SQL 双生没有(那一座要的逐文件预览判官
230
+ * `previewFileDelta` 不在 core 包根导出面上,本仓不另写一份 —— 等 core 导出它,SQL 店补这一座、本位随之转真,路由零改)。本位为假**不是**口不收 `dryRun`:口照收,答 `preview: null`
231
+ * (「这台给不出统计」≠「什么都不会变」);所以本事实没有 501 拒点,只有能力位读它。
232
+ */
233
+ export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
201
234
  /** 持久审批底座(checkpoint 店)在场 —— `/v1/approvals/*` 与 `/v1/assistant/*` 整条车道、会话 wake 都站在它上面。 */
202
235
  export declare function checkpointPark(d: Pick<Deps, "checkpointStore">): Fact<"checkpoint_store_absent", {
203
236
  checkpointStore: Store<"checkpointStore">;
@@ -267,6 +300,14 @@ export declare function imagePool(d: Pick<Deps, "imageIndex">): Fact<"image_inde
267
300
  export declare function agentRoster(d: Pick<Deps, "backgroundAgentStore">): Fact<"background_agent_store_absent", {
268
301
  store: Store<"backgroundAgentStore">;
269
302
  }>;
303
+ /**
304
+ * 项目登记簿在不在(`GET /v1/projects*` 的 501 与 `capabilities.projects` 同读)。登记簿只由配置中心下发(settings-schema 的本地读取集不收
305
+ * `projects` 域)⇒ 在场 ⟺ 中心腿在应用配置(配了中心 ∧ 非 dry-run)。这条判据住在 `centerEntitlementSourceWired`(同一件事:中心的配置
306
+ * 在这台部署上生效),这里读它,不写第二份条件。见证 = 登记簿那张表(`config.projects`,applyEffective 就地换代,引用恒定)。
307
+ */
308
+ export declare function projectRegistry(d: Pick<Deps, "config">): Fact<"project_registry_absent", {
309
+ registry: ServiceConfig["projects"];
310
+ }>;
270
311
  export declare function sendFileLedger(d: Pick<Deps, "sendFileLedger">): Fact<"sendfile_ledger_absent", {
271
312
  ledger: Store<"sendFileLedger">;
272
313
  }>;
@@ -302,6 +343,11 @@ export declare function sessionMemorySync(d: Pick<Deps, "memorySyncLeg" | "runSt
302
343
  export declare function principalInboxDelivery(d: Pick<Deps, "orgDeliveryGate">): Fact<"org_delivery_gate_absent", {
303
344
  gate: Store<"orgDeliveryGate">;
304
345
  }>;
346
+ /** [ref]([ref] v3):附着租约的交接车道在场且腿还在观察 —— `POST /v1/engine/handover` · `POST /v1/engine/attach` 的 501 与能力位 `engine.handover`
347
+ * 同读这一只。交接门只在「租约腿已装配 ∧ 非多租户」时进盒子(`boot/shutdown.ts`);腿停了(停机中)⇒ 门还在但不再观察。 */
348
+ export declare function engineHandover(d: Pick<Deps, "drainState">): Fact<"engine_handover_lane_absent" | "engine_lease_stopped", {
349
+ door: EngineHandoverDoor;
350
+ }>;
305
351
  /** 这台部署有运维名册(名单非空 ∨ 单用户声明 `OPERATOR_SINGLE_USER`;唯一读法 `operatorRosterPresent`)。没有时 `explicitOperatorOk` 对任何身份恒假
306
352
  * ⇒ 这一族的口对谁都打不通 = 部署不可用(不是鉴权拒)。
307
353
  *
@@ -316,6 +362,15 @@ type AdoptionCapableBackend = Store<"backend"> & {
316
362
  export declare function adoption(d: Pick<Deps, "config" | "backend">): Fact<"operator_principals_empty" | "adoption_store_absent", {
317
363
  backend: AdoptionCapableBackend;
318
364
  }>;
365
+ type AdoptionImportSessionStore = WithMethods<OwnerAwareSessionStore, "beginImportStaging">;
366
+ /**
367
+ * 收编批量导入(`POST /v1/adoption/:id/sessions`)与能力位 `adoptionImport` 的部署半:收编日志 ∧ 会话店的暂存导入面(派生 id 那一格占没占由提交的属主判答,不另要头读面)。
368
+ * **不判运维名册**:这扇门不是 operator 面 —— 调用者是那条收编行的源主体本人(名单空了,已收编的行照样在)。
369
+ */
370
+ export declare function adoptionSessionImport(d: Pick<Deps, "backend" | "sessionStorage">): Fact<"adoption_store_absent" | "session_import_staging_absent", {
371
+ backend: AdoptionCapableBackend;
372
+ sessionStorage: AdoptionImportSessionStore;
373
+ }>;
319
374
  export declare function memoryBundle(d: Pick<Deps, "config" | "memoryBundleExport" | "memoryBundleImport">): Fact<"operator_principals_empty" | "memory_bundle_faces_absent", {
320
375
  exportScopes: Store<"memoryBundleExport">;
321
376
  importBundle: Store<"memoryBundleImport">;
@@ -334,7 +389,7 @@ export declare function memoryOptOutGrant(d: Pick<Deps, "config" | "memoryOptOut
334
389
  store: Store<"memoryOptOutGrant">;
335
390
  }>;
336
391
  type QueryableOutcomeSink = WithMethods<Store<"outcomeSink">, "summary">;
337
- /** 可查询的 outcome 账面 ∧(单用户 ∨ operator 名单非空)—— 单用户形唯一的用户就是 operator,这一口不判名单。 */
392
+ /** 有运维名册(`operatorLane`)∧ 可查询的 outcome 账面。operator 族同序:先判名册、再判设施;部署形不进判据(单用户形要当运维显式声明)。 */
338
393
  export declare function outcomeLedger(d: Pick<Deps, "config" | "outcomeSink">): Fact<"operator_principals_empty" | "outcome_ledger_unqueryable", {
339
394
  sink: QueryableOutcomeSink;
340
395
  }>;
@@ -4,9 +4,11 @@ import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
4
4
  import { presentedApprovalFrameFamily, resolveStreamApprovalGate } from "./tool-approval.js";
5
5
  import { selfOrchestrationDenial } from "./task-workflow.js";
6
6
  import { centerEntitlementSourceWired } from "./runtime-caps-resolver.js";
7
+ import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
7
8
  import { blobExchangeOf, overwriteWipeIncapable } from "./session-sync.js";
8
9
  import { WORKSPACE_PERSIST_DEFAULT, WORKSPACE_SNAPSHOT_KEEP_DEFAULT, workspaceSnapshotTimeoutOf } from "./workspace-space.js";
9
10
  import { headReadOf } from "./session-incarnation.js";
11
+ import { laneWiresExecutionEnv } from "./execution-lane-caps.js";
10
12
  export const CAPABILITY_FACT_WHY = {
11
13
  run_store_absent: "no durable run store is wired (DB_BACKEND=mysql|pg|local)",
12
14
  subagent_registry_absent: "the sub-agent steer registry is not wired",
@@ -24,6 +26,11 @@ export const CAPABILITY_FACT_WHY = {
24
26
  session_policy_store_absent: "no session policy store is wired",
25
27
  store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)",
26
28
  file_history_store_absent: "no file-history store is wired",
29
+ resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)",
30
+ execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind",
31
+ workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from",
32
+ session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance",
33
+ file_history_preview_absent: "the file-history store implements no diffStats preview (the SQL backends)",
27
34
  session_export_absent: "the session store has no entry export faces (exportEntries / exportEntriesStream)",
28
35
  session_import_staging_absent: "the session store has no staged-import face (beginImportStaging)",
29
36
  policy_purge_absent: "the session policy store has no deleteBySession purge verb",
@@ -61,6 +68,7 @@ export const CAPABILITY_FACT_WHY = {
61
68
  read_root_grant_posture_refused: "this is not a single-user host-lane deployment (REMOTE_EXEC=host without REQUIRE_PRINCIPAL), the only posture that honors a read-directory grant",
62
69
  background_agent_store_absent: "no background-agent store is wired",
63
70
  sendfile_ledger_absent: "no SendUserFile ledger is wired",
71
+ project_registry_absent: `no project registry is served here: projects are published only by the configuration center (settings-schema does not read the projects domain from the local config.d), and no center configuration is applied (${WEB_ADMIN_ENV.url} unset, or ${WEB_ADMIN_ENV.dryRun} on)`,
64
72
  workflow_engine_absent: "the workflow engine is not available on this worker",
65
73
  entitlement_resolver_absent: "self-orchestration is on for a multi-tenant worker with no per-principal entitlement source",
66
74
  workflow_run_store_absent: "no workflow run store is wired (SELF_ORCHESTRATION_ENABLED)",
@@ -72,6 +80,8 @@ export const CAPABILITY_FACT_WHY = {
72
80
  workspace_snapshot_store_absent: "no workspace snapshot store is configured (MINIO_ENDPOINT / MINIO_ACCESS_KEY / MINIO_SECRET_KEY)",
73
81
  workspace_cache_off: "the build-cache volume per workspace space is off (WORKSPACE_CACHE=off, the default)",
74
82
  deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)",
83
+ engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)",
84
+ engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)",
75
85
  };
76
86
  const no = (why) => ({ available: false, why });
77
87
  const yes = (w) => ({ available: true, ...w });
@@ -193,6 +203,28 @@ export function sessionSyncFileHistory(d) {
193
203
  const blobExchange = blobExchangeOf(sync.historyStore);
194
204
  return blobExchange !== undefined ? yes({ historyStore: sync.historyStore, blobExchange }) : no("blob_exchange_absent");
195
205
  }
206
+ export function sessionRewindFiles(d) {
207
+ if (d.fileHistoryStore === undefined)
208
+ return no("file_history_store_absent");
209
+ const owned = sessionOwnership(d);
210
+ if (!owned.available)
211
+ return owned;
212
+ if (d.resumeAnchorStore === undefined)
213
+ return no("resume_anchor_store_absent");
214
+ if (!laneWiresExecutionEnv(d.config.remoteExec.provider))
215
+ return no("execution_lane_handless");
216
+ if (!DEPLOYMENT_SHAPE_PREDICATES.rewindableWorkspace.holds(d.config))
217
+ return no("workspace_rebuilt_per_task");
218
+ if (d.backend?.kind !== "local")
219
+ return no("session_store_shared");
220
+ return yes({ historyStore: d.fileHistoryStore, anchors: d.resumeAnchorStore, sessionStorage: owned.sessionStorage });
221
+ }
222
+ export function sessionRewindFilesPreview(d) {
223
+ const rewind = sessionRewindFiles(d);
224
+ if (!rewind.available)
225
+ return rewind;
226
+ return rewind.historyStore.diffStats !== undefined ? YES : no("file_history_preview_absent");
227
+ }
196
228
  export function checkpointPark(d) {
197
229
  return d.checkpointStore !== undefined ? yes({ checkpointStore: d.checkpointStore }) : no("checkpoint_store_absent");
198
230
  }
@@ -279,6 +311,9 @@ export function imagePool(d) {
279
311
  export function agentRoster(d) {
280
312
  return d.backgroundAgentStore !== undefined ? yes({ store: d.backgroundAgentStore }) : no("background_agent_store_absent");
281
313
  }
314
+ export function projectRegistry(d) {
315
+ return centerEntitlementSourceWired(d.config) ? yes({ registry: d.config.projects }) : no("project_registry_absent");
316
+ }
282
317
  export function sendFileLedger(d) {
283
318
  return d.sendFileLedger !== undefined ? yes({ ledger: d.sendFileLedger }) : no("sendfile_ledger_absent");
284
319
  }
@@ -312,15 +347,33 @@ export function sessionMemorySync(d) {
312
347
  export function principalInboxDelivery(d) {
313
348
  return d.orgDeliveryGate !== undefined ? yes({ gate: d.orgDeliveryGate }) : no("org_delivery_gate_absent");
314
349
  }
350
+ export function engineHandover(d) {
351
+ const door = d.drainState?.engineHandover;
352
+ if (door === undefined)
353
+ return no("engine_handover_lane_absent");
354
+ return door.observing ? yes({ door }) : no("engine_lease_stopped");
355
+ }
315
356
  export function operatorLane(d) {
316
357
  return operatorRosterPresent(d.config) ? YES : no("operator_principals_empty");
317
358
  }
359
+ function adoptionLogStore(d) {
360
+ const b = d.backend;
361
+ return b !== undefined && typeof b.adoptionLog === "function" ? yes({ backend: b }) : no("adoption_store_absent");
362
+ }
318
363
  export function adoption(d) {
319
364
  const lane = operatorLane(d);
320
365
  if (!lane.available)
321
366
  return lane;
322
- const b = d.backend;
323
- return b !== undefined && typeof b.adoptionLog === "function" ? yes({ backend: b }) : no("adoption_store_absent");
367
+ return adoptionLogStore(d);
368
+ }
369
+ export function adoptionSessionImport(d) {
370
+ const log = adoptionLogStore(d);
371
+ if (!log.available)
372
+ return log;
373
+ const s = d.sessionStorage;
374
+ if (s?.beginImportStaging === undefined)
375
+ return no("session_import_staging_absent");
376
+ return yes({ backend: log.backend, sessionStorage: s });
324
377
  }
325
378
  export function memoryBundle(d) {
326
379
  const lane = operatorLane(d);
@@ -355,11 +408,9 @@ export function memoryOptOutGrant(d) {
355
408
  return d.memoryOptOutGrant !== undefined ? yes({ store: d.memoryOptOutGrant }) : no("memory_optout_grant_absent");
356
409
  }
357
410
  export function outcomeLedger(d) {
358
- if (d.config.requirePrincipal === true) {
359
- const lane = operatorLane(d);
360
- if (!lane.available)
361
- return lane;
362
- }
411
+ const lane = operatorLane(d);
412
+ if (!lane.available)
413
+ return lane;
363
414
  const sink = d.outcomeSink;
364
415
  return sink?.summary !== undefined ? yes({ sink: sink }) : no("outcome_ledger_unqueryable");
365
416
  }
@@ -438,7 +489,7 @@ export function hostScheduler(c) {
438
489
  return no("scheduler_disabled");
439
490
  if (c.requirePrincipal === true)
440
491
  return no("multi_tenant_deployment");
441
- if (c.remoteExec?.provider !== "host")
492
+ if (c.remoteExec.provider !== "host")
442
493
  return no("not_host_lane");
443
494
  return YES;
444
495
  }
@@ -4,6 +4,7 @@ import { basename, dirname, join } from "node:path";
4
4
  import { WEB_ADMIN_ENV, WebAdminCredentialEnvelope, parseWebAdminCredentialFile } from "@sema-agent/settings-schema";
5
5
  import { ACCESS_TOKEN_TTL_SECONDS, OAuthErrorResponse, TokenGrantResponse } from "@sema-agent/settings-schema/api/auth";
6
6
  import { CENTER_PULL_TIMEOUT_MS, CenterRedirectRefusedError, centerTokenRefresh } from "./web-admin-client/center-request.js";
7
+ import { OWNER_ONLY_FILE_MODE } from "./plugins/owner-only-file-mode.js";
7
8
  export const CENTER_CREDENTIAL_RENEW_LEAD_KEY = "CENTER_CREDENTIAL_RENEW_LEAD_MS";
8
9
  export const CENTER_CREDENTIAL_RENEW_LEAD_DEFAULT_MS = 5 * 60_000;
9
10
  export const CENTER_CREDENTIAL_RENEW_LEAD_MIN_MS = CENTER_PULL_TIMEOUT_MS;
@@ -51,10 +52,10 @@ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
51
52
  const tmpResiduePattern = (path) => new RegExp(`^\\.${escapeRegExp(basename(path))}\\.\\d+\\.[0-9a-f]{${TMP_RANDOM_BYTES * 2}}\\.tmp$`);
52
53
  function prepareTmp(path, envelope, discard, onCleanupFailure) {
53
54
  const tmp = join(dirname(path), tmpNameFor(path));
54
- const fd = openSync(tmp, "wx", 0o600);
55
+ const fd = openSync(tmp, "wx", OWNER_ONLY_FILE_MODE);
55
56
  let written = false;
56
57
  try {
57
- fchmodSync(fd, 0o600);
58
+ fchmodSync(fd, OWNER_ONLY_FILE_MODE);
58
59
  writeFileSync(fd, `${JSON.stringify(envelope)}\n`, "utf8");
59
60
  fsyncSync(fd);
60
61
  written = true;
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { type CheckpointCtxSealer } from "./http/checkpoint-ctx.js";
16
16
  import { type OneTimeMigrationWindow } from "./plugins/one-time-migrations.js";
17
- import type { CheckpointCtxRowsRewriter } from "./plugins/checkpoint-store-sql.js";
17
+ import type { CheckpointCtxRowsRewriter } from "./plugins/checkpoint-store-face.js";
18
18
  /** M28 一次起服的读数(起服 info 行逐键打出;测试按它断言)。`window: "closed"` ⇒ 一行都没读(其余全 0)。 */
19
19
  export interface CheckpointCtxSealM28Report {
20
20
  readonly window: "open" | "closed";