@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
package/dist/config.js CHANGED
@@ -3,7 +3,7 @@ import { DEFAULT_AT_MENTION, DEFAULT_MODEL_REF, mintCapabilityKeys } from "./mod
3
3
  import { homedir } from "node:os";
4
4
  import { isAbsolute, join, posix as posixPath } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- import { compileAllowList, inheritEnvPolicyProblem, BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, CROSS_SESSION_INBOUND_SETTINGS, CROSS_SESSION_DIALOG_EXPIRY_VALUES, compileReadDeny, resolveReadDenyBuiltins, isModelPriced, PROTOCOL_TABLE, RECOMMENDED_SENSITIVE_PATTERNS, judgeRuleToolName, resolveFileHistoryRetention, resolveLockedKeys, validatePermissionRules, WRITE_PROTECTED_DEFAULT_TABLE, resolveWriteProtectedTable, principalInboxConsumerOf, carriesCredential } from "@sema-agent/core";
6
+ import { compileAllowList, inheritEnvPolicyProblem, BUILTIN_COMPLIANCE_DENIES, COMPLIANCE_CAPABILITIES, CROSS_SESSION_INBOUND_SETTINGS, CROSS_SESSION_DIALOG_EXPIRY_VALUES, compileReadDeny, resolveReadDenyBuiltins, isModelPriced, PROTOCOL_TABLE, RECOMMENDED_SENSITIVE_PATTERNS, judgeRuleToolName, resolveFileHistoryRetention, resolveLockedKeys, validatePermissionRules, WRITE_PROTECTED_DEFAULT_TABLE, resolveWriteProtectedTable, principalInboxConsumerOf, carriesCredential, isReplicableScope, resolveBashTimeoutCaps } from "@sema-agent/core";
7
7
  import { ROSTER_PRIMARY_ROLES, ROSTER_CHEAP_ROLES, WEB_ADMIN_ENV, retiredEnvRefusal, stripControlAndBidi } from "@sema-agent/settings-schema";
8
8
  import { parseApprovalHmacKeys, parsePrincipalJwks } from "./auth-keys.js";
9
9
  import { DEFAULT_ELICITATION_THROTTLE } from "./elicitation.js";
@@ -11,11 +11,13 @@ import { buildRuleListJudgeOptions } from "./permission-rule-list.js";
11
11
  import { isV2ScopeKey, memoryReplicationCoverage, replicatesProjectLayersOf } from "./memory-scope.js";
12
12
  import { memorySyncPeerOf } from "./memory-sync-client.js";
13
13
  import { buildMemorySyncIdentityBootRefusal, declaredMemorySyncIdentityFlaw } from "./memory-sync-identity.js";
14
+ import { formatEmbedderIdentityToken, formatReembedAssignment, parseEmbedderIdentityToken } from "./memory-embedder-reembed.js";
14
15
  import { assertProjectLayerOwnable } from "./project-identity.js";
15
16
  import { projectLayerOwnerOf } from "./project-layer-key.js";
16
17
  import { DEFAULT_QUESTION_THROTTLE } from "./question.js";
17
18
  import { GIT_API_KINDS, isGitApiKind } from "./git-api-kind.js";
18
19
  import { CONFIG_PROVIDER_WORDS, RETENTION_MODES, MEMORY_CONSOLIDATION_MIN_INTERVAL_SEC, RESILIENCE_DEFAULTS, TASK_WRITE_FACE_ESCALATIONS, MAX_TIMER_DELAY_MS, AUTO_MODE_CLASSIFIER_TIMEOUT_BOUNDS, DRAIN_GRACE_FLOOR_MS, DRAIN_SECOND_SIGNAL_MIN_GAP_BOUNDS, DRAIN_SECOND_SIGNAL_MIN_GAP_DEFAULT_MS, FIRST_BYTE_TIMEOUT_BOUNDS, FLEET_LEASE_OUTAGE_MAX_DEFAULT_MS, fleetScopeOf, DEVICE_DELIVERY_TIMEOUT_BOUNDS, DEVICE_EXEC_TIMEOUT_BOUNDS, inWholeNumberBounds, wholeNumberBoundsRule } from "./config-types.js";
20
+ import { parseTrustedProxyCidr } from "./net-address.js";
19
21
  import { DEVICE_HELLO_ACK_BOUNDS } from "./device-ws-protocol.js";
20
22
  import { FLEET_ADVERTISE_ADDRESS_ENV, FLEET_GENERATION_ENV, FLEET_SCOPE_ENV, SERVING_LEASE_TTL_FLOOR_MS, isCanonicalGeneration } from "@sema-agent/settings-schema/fleet";
21
23
  import { ScopeId } from "@sema-agent/settings-schema/api/scopes";
@@ -23,11 +25,10 @@ import { centerLaneConfigured, pathBaseUrlRefusal } from "./web-admin-client/cen
23
25
  import { resolveLocalDataRoot } from "./local-data-root.js";
24
26
  import { buildWriteProtectionPosture } from "./write-protection.js";
25
27
  import { normalizeSshFingerprint } from "./ssh-host-key.js";
26
- import { buildReadFacePostureNotice, settleDerivedReadFace } from "./read-face-posture.js";
27
28
  import { THINKING_LEVELS, THINKING_FORMATS, buildModelCompat, isThinkingFormat, isThinkingTier } from "./model-compat.js";
28
29
  import {} from "./posture-source.js";
29
30
  import { COST_QUOTA_WINDOW_SEC_RANGE, costQuotaWindowSecInRange } from "./observability/cost-quota.js";
30
- import { NAME_TABLE_BEHAVIOR, TOOL_NAME_ROSTER, describeUnmatchableRuleName, ruleEntryToolName, unmatchableRuleNameOf } from "./namespaced-rule-name.js";
31
+ import { NAME_TABLE_BEHAVIOR, TOOL_NAME_ROSTER, describeUnmatchableRuleName, isRetiredWithoutSuccessor, retiredWithoutSuccessorEntries, ruleEntryToolName, unmatchableRuleNameOf } from "./namespaced-rule-name.js";
31
32
  import { bakeOperatorPrincipalsRefusal, bakeRunnerCredentialRefusal, centerIdentityRefusal, halfOpenDirectDoorRefusal, leaderDurableStoreRefusal, operatorPrincipalsRequiredRefusal, operatorSingleUserRefusal, remoteConfigProviderUrlRefusal, retentionLaneRefusal, workflowParkDecisionDomainRefusal } from "./config-invariants.js";
32
33
  import { declaredSemaConfigDir } from "./sema-config-dir.js";
33
34
  import { lkgPathOverrideOf } from "./config-lkg.js";
@@ -38,7 +39,7 @@ import { SANDBOX_IPV6_DEFAULT, SANDBOX_IPV6_WORDS } from "./sandbox-egress-polic
38
39
  import { WORKSPACE_CACHE_DEFAULT, WORKSPACE_CACHE_MOUNT_DEFAULT, WORKSPACE_CACHE_MOUNT_RESERVED, WORKSPACE_CACHE_SIZE_DEFAULT, WORKSPACE_CACHE_WORDS, isK8sQuantity, mountsOverlap, reservedMountCollision } from "./workspace-cache.js";
39
40
  import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
40
41
  import { sandboxForwardedEnvOf } from "./execution-config-root.js";
41
- import { SANDBOX_READ_FLOOR_DEFAULT, SANDBOX_READ_FLOOR_WORDS, executionLaneOf, executionLaneRequiredRefusal, laneMissingEnv, readDeclaredLaneTable } from "./execution-lane-caps.js";
42
+ import { SANDBOX_READ_FLOOR_DEFAULT, SANDBOX_READ_FLOOR_WORDS, laneMissingEnv, readDeclaredLaneTable } from "./execution-lane-caps.js";
42
43
  import { MEMORY_ENGINE_BACKENDS, SESSION_BACKENDS, STORE_BACKENDS } from "@sema-agent/settings-schema/execution-lanes";
43
44
  import { AUTONOMY_MODES } from "./runtime-governance.js";
44
45
  import { MAX_NAMED_INERT_ENTRIES, allowLayerEntryCountIssue, describeInertRuleEntries, inertRuleEntriesOf, inertRuleEntryGuidance, ruleEntryListShapeOk } from "./rule-entry-list.js";
@@ -59,6 +60,7 @@ import { allowlistedEnv } from "./server-secret-env.js";
59
60
  import { ENV_NAME_ALLOWLIST_KNOBS, ENV_NAME_ALLOWLIST_KNOB_NAMES, describeAllowlistPostures } from "./env-name-allowlist-knobs.js";
60
61
  import { APPROVAL_ASK_RETENTION_DEFAULT_MS, APPROVAL_ASK_RETENTION_FLOOR_MS } from "./approval-ask-retention.js";
61
62
  import { parseModsDeclaration } from "./mods-declaration.js";
63
+ import { ADOPTION_IMPORT_MAX_SESSIONS_DEFAULT, ADOPTION_IMPORT_MAX_SESSIONS_FLOOR, ADOPTION_IMPORT_MAX_SESSION_BYTES_CEILING, ADOPTION_IMPORT_MAX_SESSION_BYTES_DEFAULT, ADOPTION_IMPORT_MAX_SESSION_BYTES_FLOOR } from "./adoption/import-limits.js";
62
64
  import { buildDeclaredEngineWithoutCoordinatesRefusal, missingSqlCoordinateKeys } from "./sql-engine-coordinates.js";
63
65
  export { RETENTION_MODES, MEMORY_CONSOLIDATION_MIN_INTERVAL_SEC } from "./config-types.js";
64
66
  function csv(name) {
@@ -190,14 +192,6 @@ const CONFIG_NOTICES = [];
190
192
  export function drainConfigNotices() {
191
193
  return CONFIG_NOTICES.splice(0, CONFIG_NOTICES.length);
192
194
  }
193
- let EXEC_LANE_NOTICE;
194
- function buildExecLaneNotice(remoteExec) {
195
- const lane = executionLaneOf(remoteExec?.provider);
196
- return {
197
- lane,
198
- source: lane === "in-process" ? "default-unset" : DEPLOYMENT_SHAPE_PREDICATES.singleMachineDefaultLane.holds({ remoteExec }) ? "default-local-provider" : "explicit-env",
199
- };
200
- }
201
195
  const ENV_VALUE_ECHO_CHARS = 120;
202
196
  export function parseConfigProvider() {
203
197
  const raw = process.env.CONFIG_PROVIDER;
@@ -206,7 +200,7 @@ export function parseConfigProvider() {
206
200
  const word = CONFIG_PROVIDER_WORDS.find((w) => w === raw);
207
201
  if (word === undefined) {
208
202
  throw new Error(`env CONFIG_PROVIDER="${echoCallerText(raw, { maxChars: ENV_VALUE_ECHO_CHARS })}" must be one of: ${CONFIG_PROVIDER_WORDS.join(", ")} — or leave it unset (then ${WEB_ADMIN_ENV.url}, if set, selects the center as the config source; otherwise this worker is env-only). ` +
209
- `The word is matched exactly (no trimming, no case folding). Refusing to boot rather than guessing: the config source, the execution-lane default and the local config root all key on this one word.`);
203
+ `The word is matched exactly (no trimming, no case folding). Refusing to boot rather than guessing: the config source and the local config root both key on this one word.`);
210
204
  }
211
205
  return word;
212
206
  }
@@ -252,10 +246,6 @@ export function logConfigDiagnostics(logger) {
252
246
  }
253
247
  }
254
248
  }
255
- const laneNotice = EXEC_LANE_NOTICE;
256
- EXEC_LANE_NOTICE = undefined;
257
- if (laneNotice && logger.info)
258
- logger.info("exec_lane_selected", { lane: laneNotice.lane, source: laneNotice.source });
259
249
  if (logger.debug) {
260
250
  for (const k of configKnobTable()) {
261
251
  logger.debug("config_knob_polarity", {
@@ -274,6 +264,11 @@ function clampEnvWithWarn(name, fallback, min, max = Number.POSITIVE_INFINITY) {
274
264
  CONFIG_WARNINGS.push({ env: name, raw: env(name, fallback), used: String(used), kind: "clamped" });
275
265
  return used;
276
266
  }
267
+ function countEnvClamped(name, fallback, min, max = Number.POSITIVE_INFINITY) {
268
+ if (!Number.isInteger(numEnv(name, String(fallback))))
269
+ throw new Error(`env ${name}=${env(name, String(fallback))} must be a whole number (it is a count)`);
270
+ return clampEnvWithWarn(name, String(fallback), min, max);
271
+ }
277
272
  function numEnvOr(name, fallback) {
278
273
  const raw = process.env[name];
279
274
  if (raw === undefined || raw === "")
@@ -400,8 +395,21 @@ function parseDeviceRelayUrlEnv(raw) {
400
395
  }
401
396
  return { kind: "url", url: raw };
402
397
  }
398
+ export function entryDeclarableRemoteExec(lane) {
399
+ switch (lane) {
400
+ case "host":
401
+ return {
402
+ provider: "host",
403
+ ...(process.env.HOST_WORKSPACE_BASE ? { workspaceBase: process.env.HOST_WORKSPACE_BASE } : {}),
404
+ ...((n) => (n !== undefined ? { commandTimeoutMs: n } : {}))(optNumEnvStrict("HOST_COMMAND_TIMEOUT_MS")),
405
+ };
406
+ case "none":
407
+ return { provider: "none" };
408
+ }
409
+ }
410
+ const envNamesNoLane = (raw) => raw === undefined || raw === "";
403
411
  function declaredExecutionLane(raw) {
404
- if (raw === undefined || raw === "")
412
+ if (envNamesNoLane(raw))
405
413
  return undefined;
406
414
  const table = readDeclaredLaneTable(raw);
407
415
  if ("refusal" in table)
@@ -415,7 +423,7 @@ function declaredExecutionLane(raw) {
415
423
  const missing = laneMissingEnv(lane, process.env);
416
424
  if (missing.length > 0) {
417
425
  throw new Error(`REMOTE_EXEC=${lane} but required env ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} unset, empty or whitespace-only — it counts as absent: ` +
418
- `refusing to start rather than silently downgrading to the host/in-process lane (#157; set ${missing.length === 1 ? "it" : "them"}, or unset REMOTE_EXEC if you meant no sandbox lane).`);
426
+ `refusing to start rather than silently running on another lane (#157; set ${missing.length === 1 ? "it" : "them"}, or declare REMOTE_EXEC=none if the agent's tools need no execution environment).`);
419
427
  }
420
428
  return lane;
421
429
  }
@@ -439,6 +447,19 @@ function parseDevicePreAuthPerRemoteEnv() {
439
447
  }
440
448
  return n;
441
449
  }
450
+ function parseDeviceTrustedProxyCidrsEnv(raw) {
451
+ if (raw === undefined || raw === "")
452
+ return undefined;
453
+ const items = raw.split(",").map((item) => item.replace(/^[ \t]+|[ \t]+$/g, ""));
454
+ return items.map((item, i) => {
455
+ const r = parseTrustedProxyCidr(item);
456
+ if (r.ok)
457
+ return r.text;
458
+ throw new Error(`env DEVICE_TRUSTED_PROXY_CIDRS item ${i + 1} of ${items.length} (${JSON.stringify(item)}) ${r.flaw}. ` +
459
+ `This list names the reverse proxies whose X-Forwarded-For the device pre-auth cap trusts — list only your own proxies, comma-separated ` +
460
+ `(e.g. 10.0.0.0/8,fd00::/8); unset it to read no proxy header at all (the cap is then keyed on the socket peer).`);
461
+ });
462
+ }
442
463
  function parseFileHistoryRetention() {
443
464
  const raw = process.env.FILE_HISTORY_RETENTION_KEEP;
444
465
  if (raw === undefined || raw === "")
@@ -543,9 +564,9 @@ function ownCredentialNameProblem(name, channel) {
543
564
  }
544
565
  const NAMES_IN_FORCE = {
545
566
  LSP_ENV_ALLOW: (c) => c.lspEnvAllow,
546
- E2B_SANDBOX_ENV: (c) => (c.remoteExec?.provider === "e2b" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
547
- K8S_SANDBOX_ENV: (c) => (c.remoteExec?.provider === "k8s" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
548
- DOCKER_SANDBOX_ENV: (c) => (c.remoteExec?.provider === "local-docker" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
567
+ E2B_SANDBOX_ENV: (c) => (c.remoteExec.provider === "e2b" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
568
+ K8S_SANDBOX_ENV: (c) => (c.remoteExec.provider === "k8s" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
569
+ DOCKER_SANDBOX_ENV: (c) => (c.remoteExec.provider === "local-docker" ? Object.keys(sandboxForwardedEnvOf(c)) : []),
549
570
  };
550
571
  const SERVER_ENV_NAME_ALLOWLIST_KNOBS = Object.keys(NAMES_IN_FORCE);
551
572
  export function sandboxEnvNamesInForce(seats) {
@@ -1040,16 +1061,17 @@ function parseModelDomain() {
1040
1061
  }
1041
1062
  const extraBody = buildExtraBody();
1042
1063
  const thinkingDefault = parseDefaultThinking(process.env.MODEL_DEFAULT_THINKING);
1043
- const envCompatDeclared = buildModelCompat({
1064
+ const envApi = provider === "anthropic" ? "anthropic-messages" : "openai-completions";
1065
+ const envCompatDeclared = buildModelCompat("openai-completions", {
1044
1066
  reasoningEffortLevels: parseReasoningEffortLevels(csv("MODEL_REASONING_EFFORT_LEVELS")),
1045
1067
  thinkingFormat: parseThinkingFormat(process.env.MODEL_THINKING_FORMAT),
1046
1068
  });
1047
- const envCompat = provider === "anthropic" ? undefined : envCompatDeclared;
1069
+ const envCompat = envApi === "openai-completions" ? envCompatDeclared : undefined;
1048
1070
  const modelCapability = { reasoning: parseBoolWord("MODEL_REASONING", process.env.MODEL_REASONING), vision: parseBoolWord("MODEL_VISION", process.env.MODEL_VISION) };
1049
1071
  const model = {
1050
1072
  id: modelId,
1051
1073
  name: modelId,
1052
- api: provider === "anthropic" ? "anthropic-messages" : "openai-completions",
1074
+ api: envApi,
1053
1075
  provider,
1054
1076
  baseUrl: "",
1055
1077
  ...mintCapabilityKeys(modelCapability),
@@ -1292,7 +1314,8 @@ function findUnmatchableToolNames(names, opts) {
1292
1314
  }
1293
1315
  }
1294
1316
  const subject = opts.consumer === "tool-name-table" ? name : ruleEntryToolName(name);
1295
- const verdict = unmatchableRuleNameOf(subject, opts.behavior);
1317
+ const judged = unmatchableRuleNameOf(subject, opts.behavior);
1318
+ const verdict = opts.noticeSeat !== undefined && isRetiredWithoutSuccessor(judged) ? undefined : judged;
1296
1319
  if (verdict?.kind === "retired") {
1297
1320
  out.push({ name, guidance: describeUnmatchableRuleName(verdict, subject), reason: verdict.kind });
1298
1321
  continue;
@@ -1405,9 +1428,21 @@ function parseApprovalDomain(ctx) {
1405
1428
  const dgHmacKeys = parseApprovalHmacKeys(process.env.APPROVAL_HMAC_KEYS, announceKeySetRejection("APPROVAL_HMAC_KEYS"));
1406
1429
  const durableApproval = postureOn("DURABLE_APPROVAL", infraReady);
1407
1430
  const rejectUnmatchableToolNames = (envName, names) => {
1408
- const unmatchable = unmatchableToolNamesRefusal(envName, names, { consumer: "tool-name-table", behavior: NAME_TABLE_BEHAVIOR });
1431
+ const unmatchable = unmatchableToolNamesRefusal(envName, names, { consumer: "tool-name-table", behavior: NAME_TABLE_BEHAVIOR, noticeSeat: "server" });
1409
1432
  if (unmatchable !== undefined)
1410
1433
  throw new Error(unmatchable.message);
1434
+ const skipped = retiredWithoutSuccessorEntries(names, NAME_TABLE_BEHAVIOR);
1435
+ if (skipped.length > 0) {
1436
+ CONFIG_NOTICES.push({
1437
+ level: "warn",
1438
+ event: "approval_list_legacy_tool_name",
1439
+ fields: {
1440
+ env: envName,
1441
+ entries: JSON.stringify(skipped.map((s) => s.entry)),
1442
+ note: `${skipped.map((s) => `${displayListEntry(s.entry)} (${s.guidance})`).join("; ")} — ${skipped.length === 1 ? "a tool name" : "tool names"} the engine retired with no successor: ${skipped.length === 1 ? "it reaches" : "they reach"} no tool this server knows, so ${skipped.length === 1 ? "the entry guards" : "the entries guard"} nothing (kept as written: a tool of that exact name mounted by an embedder is still matched) and the server starts. Remove ${skipped.length === 1 ? "it" : "them"} from ${envName} if written for the retired tool.`,
1443
+ },
1444
+ });
1445
+ }
1411
1446
  return names;
1412
1447
  };
1413
1448
  return {
@@ -1590,19 +1625,30 @@ function parentPidEnv() {
1590
1625
  return { parentPid: n };
1591
1626
  }
1592
1627
  const ENGINE_LINGER_FLOOR_MS = 1_000;
1628
+ const ENGINE_HANDOVER_LINGER_FLOOR_MS = 60_000;
1593
1629
  const ENGINE_LINGER_CEIL_MS = 24 * 60 * 60 * 1_000;
1594
- function lingerMsEnv(name, raw, defaultMs, disableHint) {
1630
+ function engineWindowZeroSentence(zero) {
1631
+ switch (zero.kind) {
1632
+ case "refused":
1633
+ return `There is no "disable" value here — ${zero.disableHint}`;
1634
+ case "noGrace":
1635
+ return `the literal "0" is the one value below the floor accepted here — ${zero.offHint}`;
1636
+ }
1637
+ }
1638
+ function lingerMsEnv(name, raw, defaultMs, floorMs, zero) {
1595
1639
  if (raw === undefined || raw.trim() === "")
1596
1640
  return defaultMs;
1641
+ if (zero.kind === "noGrace" && raw.trim() === "0")
1642
+ return 0;
1597
1643
  const n = parseNumOrFail(name, raw);
1598
- if (!Number.isSafeInteger(n) || n < ENGINE_LINGER_FLOOR_MS || n > ENGINE_LINGER_CEIL_MS) {
1644
+ if (!Number.isSafeInteger(n) || n < floorMs || n > ENGINE_LINGER_CEIL_MS) {
1599
1645
  throw new Error(`env ${name}="${raw}" must be an INTEGER number of MILLISECONDS in ` +
1600
- `[${ENGINE_LINGER_FLOOR_MS}, ${ENGINE_LINGER_CEIL_MS}] (1s … 24h) — it is how long ` +
1646
+ `[${floorMs}, ${ENGINE_LINGER_CEIL_MS}] (${floorMs / 1_000}s … 24h) — it is how long ` +
1601
1647
  `"nobody attached, no run in flight, no HTTP touch" must hold CONTINUOUSLY before the engine self-exits. ` +
1602
1648
  `A value like "60" is the seconds-for-milliseconds slip: a 60ms window kills the engine inside a shell's own ` +
1603
1649
  `restart gap. A value like "1e100" passes a naive "is it a positive integer" check but the elapsed clock can ` +
1604
1650
  `NEVER reach it, which silently turns self-exit off while looking configured. ` +
1605
- `There is no "disable" value here — ${disableHint}`);
1651
+ engineWindowZeroSentence(zero));
1606
1652
  }
1607
1653
  return n;
1608
1654
  }
@@ -1628,6 +1674,7 @@ function parseMemoryEmbedder(ctx) {
1628
1674
  const dimRaw = process.env.MEMORY_EMBEDDER_DIM || undefined;
1629
1675
  const apiKey = process.env.MEMORY_EMBEDDER_API_KEY || undefined;
1630
1676
  const timeoutRaw = process.env.MEMORY_EMBEDDER_TIMEOUT_MS || undefined;
1677
+ const reembedRaw = process.env.MEMORY_EMBEDDER_REEMBED || undefined;
1631
1678
  const trio = [
1632
1679
  ["MEMORY_EMBEDDER_ENDPOINT", endpoint],
1633
1680
  ["MEMORY_EMBEDDER_MODEL", model],
@@ -1635,8 +1682,11 @@ function parseMemoryEmbedder(ctx) {
1635
1682
  ];
1636
1683
  const missing = trio.filter(([, v]) => v === undefined).map(([name]) => name);
1637
1684
  if (missing.length === 3) {
1638
- if (timeoutRaw !== undefined || apiKey !== undefined) {
1639
- throw new Error(`MEMORY_EMBEDDER_TIMEOUT_MS/MEMORY_EMBEDDER_API_KEY are set but the embedder itself is not configured — refusing to start half-configured (set MEMORY_EMBEDDER_ENDPOINT, MEMORY_EMBEDDER_MODEL and MEMORY_EMBEDDER_DIM to enable the memory vector plane, or unset the other MEMORY_EMBEDDER_* keys)`);
1685
+ const dependents = [["MEMORY_EMBEDDER_TIMEOUT_MS", timeoutRaw], ["MEMORY_EMBEDDER_API_KEY", apiKey], ["MEMORY_EMBEDDER_REEMBED", reembedRaw]]
1686
+ .filter(([, v]) => v !== undefined)
1687
+ .map(([name]) => name);
1688
+ if (dependents.length > 0) {
1689
+ throw new Error(`${dependents.join("/")} ${dependents.length === 1 ? "is" : "are"} set but the embedder itself is not configured — refusing to start half-configured (set MEMORY_EMBEDDER_ENDPOINT, MEMORY_EMBEDDER_MODEL and MEMORY_EMBEDDER_DIM to enable the memory vector plane, or unset the other MEMORY_EMBEDDER_* keys)`);
1640
1690
  }
1641
1691
  return undefined;
1642
1692
  }
@@ -1659,12 +1709,26 @@ function parseMemoryEmbedder(ctx) {
1659
1709
  if (!ctx.memoryEngineEnabled) {
1660
1710
  throw new Error("MEMORY_EMBEDDER_* is set but MEMORY_ENGINE=off — the memory engine is not wired at all, so the embedder would never be called; unset one of the two (#228)");
1661
1711
  }
1712
+ if (reembedRaw !== undefined) {
1713
+ const configured = formatEmbedderIdentityToken({ model, dimensions });
1714
+ const confirmed = parseEmbedderIdentityToken(reembedRaw);
1715
+ if (confirmed === undefined) {
1716
+ throw new Error(`MEMORY_EMBEDDER_REEMBED=${JSON.stringify(reembedRaw.length > 200 ? `${reembedRaw.slice(0, 200)}…` : reembedRaw)} is not a re-embed confirmation — the value must name the embedder identity being confirmed as <model>/<dimensions> ` +
1717
+ `(for this configuration: ${formatReembedAssignment({ model, dimensions })}). It confirms that the memory vector column may be cleared and re-embedded into that identity when the recorded identity does not match; ` +
1718
+ "an on/off value is refused because it would also confirm the NEXT model change. Fix the value or unset it.");
1719
+ }
1720
+ if (confirmed.model !== model || confirmed.dimensions !== dimensions) {
1721
+ throw new Error(`MEMORY_EMBEDDER_REEMBED=${formatEmbedderIdentityToken(confirmed)} confirms re-embedding into a different identity than the configured embedder ${configured} ` +
1722
+ `(MEMORY_EMBEDDER_MODEL / MEMORY_EMBEDDER_DIM) — a stale confirmation never clears vectors for another model. Set ${formatReembedAssignment({ model, dimensions })} to confirm this change, or unset it.`);
1723
+ }
1724
+ }
1662
1725
  return {
1663
1726
  endpoint,
1664
1727
  model,
1665
1728
  dimensions,
1666
1729
  timeoutMs: numEnvBounded("MEMORY_EMBEDDER_TIMEOUT_MS", "30000", 1000, 300_000),
1667
1730
  ...(apiKey !== undefined ? { apiKey } : {}),
1731
+ ...(reembedRaw !== undefined ? { reembedConfirmed: true } : {}),
1668
1732
  };
1669
1733
  }
1670
1734
  function parseMemoryConsolidationDriver() {
@@ -1757,6 +1821,10 @@ function parseMemoryDomain(ctx) {
1757
1821
  if (scope === undefined) {
1758
1822
  throw new Error("MEMORY_SYNC_URL is set but no sync scope is derivable (memory engine off or multi-tenant without an explicit scope) — set MEMORY_SYNC_SCOPE, or run the single-user file memory engine with a typed MEMORY_SCOPE (e.g. user:<tenant>) so it provides one");
1759
1823
  }
1824
+ if (!isReplicableScope(scope)) {
1825
+ throw new Error(`${memorySyncScopeRaw !== undefined ? "MEMORY_SYNC_SCOPE" : "MEMORY_SCOPE"} names a userlocal: memory layer as the sync layer — that layer family never leaves the store it is written in ` +
1826
+ "(the engine refuses to sync it before any read or request), so this sync leg would fail every round. Set MEMORY_SYNC_SCOPE to a layer that may be replicated, or unset MEMORY_SYNC_URL.");
1827
+ }
1760
1828
  if (carriesCredential(scope)) {
1761
1829
  throw new Error(`${memorySyncScopeRaw !== undefined ? "MEMORY_SYNC_SCOPE" : "MEMORY_SCOPE"} (the memory sync layer's name) holds a credential-shaped part — the layer name travels verbatim in every sync request path and report, so it is refused, never cleaned: rename the layer`);
1762
1830
  }
@@ -1915,6 +1983,7 @@ function parseAuthDomain(ctx) {
1915
1983
  ...parseGovernanceDeclarations(),
1916
1984
  operatorPrincipals: csv("OPERATOR_PRINCIPALS"),
1917
1985
  operatorSingleUser: boolEnv("OPERATOR_SINGLE_USER", false),
1986
+ serviceTokenActsForDeployment: boolEnv("SERVICE_TOKEN_ACTS_FOR_DEPLOYMENT", true),
1918
1987
  configCatalogEnabled: boolEnv("CONFIG_CATALOG_ENABLED", true),
1919
1988
  principalJwtPubkeys,
1920
1989
  principalJwtIss,
@@ -1923,8 +1992,14 @@ function parseAuthDomain(ctx) {
1923
1992
  principalJwtMaxTtlSec,
1924
1993
  };
1925
1994
  }
1995
+ export const BG_AGENT_SILENCE_FLOOR_MS = 10 * 60_000;
1996
+ export function backgroundAgentStallFloorMs(f) {
1997
+ const personWaitMs = Math.max(f.streamApproval.windowMs, f.streamApproval.unreachedTtlMs, (f.questionThrottle ?? DEFAULT_QUESTION_THROTTLE).ttlMs, f.mcpElicitation.throttle.ttlMs);
1998
+ return Math.max(BG_AGENT_SILENCE_FLOOR_MS, personWaitMs + f.commandCeilingMs);
1999
+ }
1926
2000
  function parseOrchestrationDomain(ctx) {
1927
2001
  const { postureOn, singleUserTurnkey } = ctx;
2002
+ const backgroundAgentStallFloor = backgroundAgentStallFloorMs({ ...ctx.personGates, commandCeilingMs: resolveBashTimeoutCaps().maxMs });
1928
2003
  const workflowSizeGuidelineRaw = process.env.WORKFLOW_SIZE_GUIDELINE;
1929
2004
  if (workflowSizeGuidelineRaw !== undefined && !["small", "medium", "large", "unrestricted"].includes(workflowSizeGuidelineRaw)) {
1930
2005
  throw new Error(`WORKFLOW_SIZE_GUIDELINE must be small|medium|large|unrestricted, got "${workflowSizeGuidelineRaw}"`);
@@ -1947,7 +2022,6 @@ function parseOrchestrationDomain(ctx) {
1947
2022
  ? { readFace: enumEnv("READ_FACE", "roots", ["open", "roots"]), readFaceSource: "env" }
1948
2023
  : { readFaceSource: "engine-default" };
1949
2024
  return {
1950
- requireExecutionLane: boolEnv("REQUIRE_EXECUTION_LANE", false),
1951
2025
  ...readFaceFacts,
1952
2026
  ...optionalEnumKey("taskWriteFaceEscalation", "TASK_WRITE_FACE_ESCALATION", process.env.TASK_WRITE_FACE_ESCALATION, TASK_WRITE_FACE_ESCALATIONS),
1953
2027
  ...(process.env.READ_DENY_PATTERNS !== undefined ? { readDenyPatterns: parseReadDenyPatternsEnv(process.env.READ_DENY_PATTERNS) } : {}),
@@ -2028,12 +2102,8 @@ function parseOrchestrationDomain(ctx) {
2028
2102
  ...(process.env.ADB_MOUNT_PATH ? { mountPath: process.env.ADB_MOUNT_PATH } : {}),
2029
2103
  }
2030
2104
  :
2031
- declaredLane === "host"
2032
- ? {
2033
- provider: "host",
2034
- ...(process.env.HOST_WORKSPACE_BASE ? { workspaceBase: process.env.HOST_WORKSPACE_BASE } : {}),
2035
- ...((n) => (n !== undefined ? { commandTimeoutMs: n } : {}))(optNumEnvStrict("HOST_COMMAND_TIMEOUT_MS")),
2036
- }
2105
+ declaredLane === "host" || declaredLane === "none"
2106
+ ? entryDeclarableRemoteExec(declaredLane)
2037
2107
  :
2038
2108
  declaredLane === "local-docker" && process.env.DOCKER_IMAGE
2039
2109
  ? {
@@ -2062,13 +2132,12 @@ function parseOrchestrationDomain(ctx) {
2062
2132
  ...((n) => (n !== undefined ? { maxInflightPerDevice: n } : {}))(parseDeviceBoundedIntEnv("DEVICE_MAX_INFLIGHT_PER_DEVICE", process.env.DEVICE_MAX_INFLIGHT_PER_DEVICE, DEVICE_HELLO_ACK_BOUNDS.maxInflight)),
2063
2133
  ...((n) => (n !== undefined ? { maxPreAuthPerRemote: n } : {}))(parseDevicePreAuthPerRemoteEnv()),
2064
2134
  ...((n) => (n !== undefined ? { enrollTokenTtlSec: n } : {}))(parseDeviceEnrollTokenTtlEnv()),
2135
+ ...((n) => (n !== undefined ? { trustedProxyCidrs: n } : {}))(parseDeviceTrustedProxyCidrsEnv(process.env.DEVICE_TRUSTED_PROXY_CIDRS)),
2065
2136
  relay: parseDeviceRelayUrlEnv(process.env.DEVICE_RELAY_URL),
2066
2137
  ...(process.env.DEVICE_SUPERSEDE ? { supersede: enumEnv("DEVICE_SUPERSEDE", "stale_only", ["stale_only", "deny"]) } : {}),
2067
2138
  }
2068
2139
  :
2069
- ctx.configProvider === "local"
2070
- ? { provider: "host", singleMachineDefault: true }
2071
- : undefined,
2140
+ undefined,
2072
2141
  worktreeIsolation: boolEnv("WORKTREE_ISOLATION_ENABLED", false) && process.env.WORKTREE_REPO_ROOT
2073
2142
  ? {
2074
2143
  repoRoot: process.env.WORKTREE_REPO_ROOT,
@@ -2099,7 +2168,8 @@ function parseOrchestrationDomain(ctx) {
2099
2168
  workflowRunRetentionMs: clampEnvWithWarn("WORKFLOW_RUN_RETENTION_MS", String(30 * 24 * 60 * 60 * 1000), 60_000),
2100
2169
  ...(usageWindows ? { usageWindows } : {}),
2101
2170
  backgroundAgentRetentionMs: clampEnvWithWarn("BG_AGENT_RETENTION_MS", String(7 * 24 * 60 * 60 * 1000), 60_000),
2102
- backgroundAgentStaleRunningMs: clampEnvWithWarn("BG_AGENT_STALE_RUNNING_MS", String(15 * 60_000), 10 * 60_000),
2171
+ backgroundAgentStaleRunningMs: clampEnvWithWarn("BG_AGENT_STALE_RUNNING_MS", String(15 * 60_000), BG_AGENT_SILENCE_FLOOR_MS),
2172
+ backgroundAgentStallMs: clampEnvWithWarn("BG_AGENT_STALL_MS", String(backgroundAgentStallFloor), backgroundAgentStallFloor),
2103
2173
  backgroundAgentParkClaimStaleMs: clampEnvWithWarn("BG_AGENT_PARK_CLAIM_STALE_MS", String(60 * 60_000), 60_000),
2104
2174
  rosterRetentionMs: clampEnvWithWarn("ROSTER_RETENTION_MS", String(30 * 24 * 60 * 60 * 1000), 60_000),
2105
2175
  leaderRunStaleMs: clampEnvWithWarn("LEADER_RUN_STALE_MS", String(26 * 60 * 60 * 1000), 60_000),
@@ -2158,6 +2228,8 @@ function parseLimitsHttpDomain() {
2158
2228
  ? { attachmentMimeAllowlist: csv("ATTACHMENT_MIME_ALLOWLIST").map((s) => s.toLowerCase()) }
2159
2229
  : {}),
2160
2230
  attachmentUnboundTtlMs: clampEnvWithWarn("ATTACHMENT_UNBOUND_TTL_MS", String(24 * 3600 * 1000), LIMITS_HTTP_FLOORS.attachmentUnboundTtlMs),
2231
+ adoptionImportMaxSessions: countEnvClamped("ADOPTION_IMPORT_MAX_SESSIONS", ADOPTION_IMPORT_MAX_SESSIONS_DEFAULT, ADOPTION_IMPORT_MAX_SESSIONS_FLOOR),
2232
+ adoptionImportMaxSessionBytes: countEnvClamped("ADOPTION_IMPORT_MAX_SESSION_BYTES", ADOPTION_IMPORT_MAX_SESSION_BYTES_DEFAULT, ADOPTION_IMPORT_MAX_SESSION_BYTES_FLOOR, ADOPTION_IMPORT_MAX_SESSION_BYTES_CEILING),
2161
2233
  infraCostRates: {
2162
2234
  toolCallMicroUsd: clampEnvWithWarn("INFRA_COST_TOOL_CALL", "0", 0),
2163
2235
  sandboxSecMicroUsd: clampEnvWithWarn("INFRA_COST_SANDBOX_SEC", "0", 0),
@@ -2173,9 +2245,23 @@ function parseLimitsHttpDomain() {
2173
2245
  sighupIdleGraceMs: clampEnvWithWarn("SIGHUP_IDLE_GRACE_MS", String(120_000), 5_000),
2174
2246
  ...parentPidEnv(),
2175
2247
  engineAutoExit: boolEnv("ENGINE_AUTO_EXIT", false),
2176
- engineLingerMs: lingerMsEnv("ENGINE_LINGER_MS", process.env.ENGINE_LINGER_MS, 60_000, "set ENGINE_AUTO_EXIT=false to turn self-exit off entirely."),
2177
- engineOrphanLingerMs: lingerMsEnv("ENGINE_ORPHAN_LINGER_MS", process.env.ENGINE_ORPHAN_LINGER_MS, 2_000, "this window only applies once the SEMA_PARENT_PID process is gone — unset SEMA_PARENT_PID to stop watching the parent at all."),
2248
+ engineLingerMs: lingerMsEnv("ENGINE_LINGER_MS", process.env.ENGINE_LINGER_MS, 60_000, ENGINE_LINGER_FLOOR_MS, { kind: "refused", disableHint: "set ENGINE_AUTO_EXIT=false to turn self-exit off entirely." }),
2249
+ engineOrphanLingerMs: lingerMsEnv("ENGINE_ORPHAN_LINGER_MS", process.env.ENGINE_ORPHAN_LINGER_MS, 2_000, ENGINE_LINGER_FLOOR_MS, {
2250
+ kind: "refused",
2251
+ disableHint: "this window only applies once the SEMA_PARENT_PID process is gone — unset SEMA_PARENT_PID to stop watching the parent at all.",
2252
+ }),
2253
+ engineFirstAttachMs: lingerMsEnv("ENGINE_FIRST_ATTACH_MS", process.env.ENGINE_FIRST_ATTACH_MS, 180_000, ENGINE_LINGER_FLOOR_MS, {
2254
+ kind: "noGrace",
2255
+ offHint: "it means no extra grace before the first non-probe request (the window is then ENGINE_LINGER_MS, as before this knob existed); " +
2256
+ "set ENGINE_AUTO_EXIT=false to turn self-exit off entirely.",
2257
+ }),
2258
+ engineHandoverLingerMs: lingerMsEnv("ENGINE_HANDOVER_LINGER_MS", process.env.ENGINE_HANDOVER_LINGER_MS, 1_800_000, ENGINE_HANDOVER_LINGER_FLOOR_MS, {
2259
+ kind: "refused",
2260
+ disableHint: "this window only applies after a shell hands the engine over (POST /v1/engine/handover) — a shell that never does so never uses it; set ENGINE_AUTO_EXIT=false and unset SEMA_PARENT_PID to turn self-exit off entirely.",
2261
+ }),
2178
2262
  rateLimitPerMin: numEnv("RATE_LIMIT_RPM", "0"),
2263
+ runMaxConcurrent: nonNegativeIntEnv("RUN_MAX_CONCURRENT", "在飞 run 全局并发帽"),
2264
+ runMaxConcurrentPerPrincipal: nonNegativeIntEnv("RUN_MAX_CONCURRENT_PER_PRINCIPAL", "按主体在飞 run 并发帽"),
2179
2265
  maxTaskCostUsd: numEnv("MAX_TASK_COST_USD", "0"),
2180
2266
  maxTaskTokens: numEnv("MAX_TASK_TOKENS", "0"),
2181
2267
  maxPrincipalCostUsd: numEnv("MAX_PRINCIPAL_COST_USD", "0"),
@@ -2484,15 +2570,15 @@ const MEMORY_GROUP_KEYS = [
2484
2570
  const AUTH_GROUP_KEYS = [
2485
2571
  "authToken", "authTokens", "allowUnauthedWrites", "corsOrigins", "principalHeader", "requirePrincipal", "autonomy",
2486
2572
  "commandPolicy", "compliancePosture", "lockedConfigKeys", "retentionPolicy", "retentionSweep",
2487
- "operatorPrincipals", "operatorSingleUser", "configCatalogEnabled", "principalJwtPubkeys", "principalJwtIss", "principalJwtAud",
2573
+ "operatorPrincipals", "operatorSingleUser", "serviceTokenActsForDeployment", "configCatalogEnabled", "principalJwtPubkeys", "principalJwtIss", "principalJwtAud",
2488
2574
  "principalJwtMaxTtlSec", "authBridgeIssuer", "bindHost", "bindHostSource",
2489
2575
  ];
2490
2576
  const ORCHESTRATION_GROUP_KEYS = [
2491
- "sandboxGit", "remoteExec", "remoteExecHomeDir", "requireExecutionLane", "worktreeIsolation", "leaderEnabled", "leaderFanoutEnabled", "routerEnabled", "selfOrchestrationEnabled",
2577
+ "sandboxGit", "remoteExec", "remoteExecHomeDir", "worktreeIsolation", "leaderEnabled", "leaderFanoutEnabled", "routerEnabled", "selfOrchestrationEnabled",
2492
2578
  "selfOrchestrationModels", "selfOrchestrationWorkerIsolation", "forkEnabled", "experimentalObserverAgents",
2493
2579
  "schedulerEnabled", "schedulerSessionWakeup", "schedulerSessionLifetime", "schedulerStorePath", "planModeEnabled", "hooksTimeoutMs", "workflowRunStoreBackend",
2494
2580
  "workflowOrphanGraceMs", "workflowJournalRetentionMs", "workflowRunRetentionMs", "usageWindows", "workflowAgentsReadOnly",
2495
- "workflowSizeGuideline", "backgroundAgentRetentionMs", "backgroundAgentStaleRunningMs",
2581
+ "workflowSizeGuideline", "backgroundAgentRetentionMs", "backgroundAgentStaleRunningMs", "backgroundAgentStallMs",
2496
2582
  "backgroundAgentParkClaimStaleMs", "delegationEntryCaps", "rosterRetentionMs", "leaderRunStaleMs", "scratchpadSweepTtlMs", "sandboxPkgSource", "sandboxPkgSourceCustom",
2497
2583
  "sessionAutoTitle", "sessionAutoTitleSource", "selectEnvironmentTool", "envFactsEnabled", "toolDeferLongtail", "lspEnabled", "lspHostEnabled", "lspEnvAllow",
2498
2584
  "imageBakes", "readFace", "readFaceSource", "taskWriteFaceEscalation", "readDenyPatterns", "readDenyBuiltinTiers", "readDenyBuiltinExclude", "readDenyFloorRequired", "sandboxReadFloor",
@@ -2501,8 +2587,9 @@ const ORCHESTRATION_GROUP_KEYS = [
2501
2587
  const LIMITS_HTTP_GROUP_KEYS = [
2502
2588
  "port", "attachmentOrphanGraceMs", "workspaceFileMaxBytes", "attachmentMaxBytes", "attachmentMimeAllowlist",
2503
2589
  "attachmentUnboundTtlMs", "infraCostRates", "drainGraceMs", "drainSecondSignalMinGapMs", "sighupIdleGraceMs", "parentPid",
2504
- "engineAutoExit", "engineLingerMs", "engineOrphanLingerMs",
2505
- "rateLimitPerMin", "maxTaskCostUsd",
2590
+ "engineAutoExit", "engineLingerMs", "engineOrphanLingerMs", "engineFirstAttachMs", "engineHandoverLingerMs",
2591
+ "rateLimitPerMin", "runMaxConcurrent", "runMaxConcurrentPerPrincipal", "maxTaskCostUsd",
2592
+ "adoptionImportMaxSessions", "adoptionImportMaxSessionBytes",
2506
2593
  "maxTaskTokens", "maxPrincipalCostUsd", "costQuotaWindowSec", "reapIntervalSec", "runStaleSec", "toolResultTtlSec",
2507
2594
  ];
2508
2595
  const OBSERVABILITY_GROUP_KEYS = ["metricsToken", "traceToken", "toolTrace", "traceThinking", "logLevel", "otel"];
@@ -2545,6 +2632,9 @@ export function attachConfigGroups(flat) {
2545
2632
  }
2546
2633
  return flat;
2547
2634
  }
2635
+ function attachLoadedConfigGroups(flat) {
2636
+ return attachConfigGroups(flat);
2637
+ }
2548
2638
  function k8sWorkspaceStore() {
2549
2639
  const workspacePersist = enumEnv("WORKSPACE_PERSIST", WORKSPACE_PERSIST_DEFAULT, WORKSPACE_PERSIST_WORDS);
2550
2640
  const workspaceSnapshotKeep = numEnvBounded("WORKSPACE_SNAPSHOT_KEEP", String(WORKSPACE_SNAPSHOT_KEEP_DEFAULT), WORKSPACE_SNAPSHOT_KEEP_RANGE.min, WORKSPACE_SNAPSHOT_KEEP_RANGE.max);
@@ -2615,7 +2705,6 @@ function k8sWorkspaceCache() {
2615
2705
  return { mount, size };
2616
2706
  }
2617
2707
  export function loadConfig() {
2618
- EXEC_LANE_NOTICE = undefined;
2619
2708
  rejectRetiredEnvs();
2620
2709
  CONFIG_WARNINGS.length = 0;
2621
2710
  CONFIG_NOTICES.length = 0;
@@ -2635,11 +2724,7 @@ export function loadConfig() {
2635
2724
  const approval = parseApprovalDomain({ postureOn, singleUserTurnkey, infraReady: durableStoreReady });
2636
2725
  const memory = parseMemoryDomain({ requirePrincipal });
2637
2726
  const auth = parseAuthDomain({ requirePrincipal });
2638
- const orchestration = parseOrchestrationDomain({ postureOn, singleUserTurnkey, configProvider });
2639
- settleDerivedReadFace(orchestration, singleUserTurnkey);
2640
- const readFaceNotice = buildReadFacePostureNotice(orchestration);
2641
- if (readFaceNotice !== undefined)
2642
- CONFIG_NOTICES.push({ level: "info", ...readFaceNotice });
2727
+ const orchestration = parseOrchestrationDomain({ postureOn, singleUserTurnkey, personGates: approval });
2643
2728
  const limitsHttp = parseLimitsHttpDomain();
2644
2729
  const observability = parseObservabilityDomain();
2645
2730
  const integrations = parseIntegrationsDomain({ requirePrincipal, configProvider });
@@ -2701,12 +2786,7 @@ export function loadConfig() {
2701
2786
  if (parkDecisionDomainRefusal !== undefined) {
2702
2787
  throw new Error(parkDecisionDomainRefusal);
2703
2788
  }
2704
- const laneRequiredRefusal = executionLaneRequiredRefusal(orchestration);
2705
- if (laneRequiredRefusal !== undefined) {
2706
- throw new Error(laneRequiredRefusal);
2707
- }
2708
- EXEC_LANE_NOTICE = buildExecLaneNotice(orchestration.remoteExec);
2709
- return attachConfigGroups({
2789
+ return attachLoadedConfigGroups({
2710
2790
  ...store,
2711
2791
  ...modelPlane,
2712
2792
  ...approval,
@@ -2729,7 +2809,9 @@ export function parseCapEnv(name, raw) {
2729
2809
  return { value: n };
2730
2810
  }
2731
2811
  export function splitLocalRoots(a) {
2732
- const configRoot = a.configLocalDir ?? a.agentDataDir ?? join(a.home, ".ai-agent");
2812
+ if (a.configLocalDir !== undefined)
2813
+ return undefined;
2814
+ const configRoot = a.agentDataDir ?? join(a.home, ".ai-agent");
2733
2815
  if (!a.localDataRoot || a.localDataRoot === configRoot)
2734
2816
  return undefined;
2735
2817
  return { dataRoot: a.localDataRoot, configRoot };
@@ -1,6 +1,6 @@
1
1
  import { failureCodeOf } from "./terminal.js";
2
2
  import { StoredSession } from "@sema-agent/core";
3
- import { TiDBSessionStorage } from "./plugins/tidb-session-storage.js";
3
+ import { TiDBSessionStorage } from "./stores-sql/tidb-session-storage.js";
4
4
  const SUBSTANTIVE_CHARS = 200;
5
5
  const REP_WINDOW = 8192;
6
6
  const MIN_REPEATS = 3;
@@ -0,0 +1,19 @@
1
+ import type { DeploymentShapeInput } from "./deployment-shape.js";
2
+ /** 表的条数上限(一条约百字节量级)。引擎的会话暂存自己按会话数有上限(超了整会话驱逐最旧);本表的上限比它宽得多。 */
3
+ export declare const DELETED_SESSION_ID_CAP = 50000;
4
+ /**
5
+ * **铸点**(唯一):本进程的在线删除协调器在删除会话本体之前记一笔 —— 围栏先立,id 才空出来。删除随后失败也无害:
6
+ * 这一笔只拒「别的属主」,而会话还在时别的属主本来就用不了它。
7
+ * 同一只 id 再删一次:这一次的删前属主对已记的每一位都等价(同一只等价律判)⇒ 收进集合(前几位一位不丢 —— 等价律有方向、不传递,只记最新一位会让
8
+ * 「哨兵删 → 无主重登再删 → `default` 用」绕过「哨兵 ≢ `default`」);对某一位不等价 ⇒ 记成「谁都不是」。后一次删除从不覆盖前一位(前一位的暂存仍可能在本进程)。
9
+ * `deployment` = 部署形(等价律的窄互认臂读它;调用方递 `ServiceConfig` 整份)。
10
+ */
11
+ export declare function retireSessionId(sessionId: string, owner: string | null, deployment: DeploymentShapeInput<"principal">): void;
12
+ /**
13
+ * **读点**(唯一;执行上下文解析器 `http/execution-context.ts` 步 ① 调):这只 id 在本进程被删过、而删前的属主不是 `owner` ⇒ `true`(解析器拒)。
14
+ * `owner` = 这条执行要服务的属主(根会话行上那一读的住客);`undefined` = 判不出 ⇒ 删过就为真(fail-closed)。
15
+ * 同一位 = 对**每一位**删前属主,会话属主等价律 `sameSessionOwner(deployment, 删前属主, owner)` 都成立(删前属主是行上记下的那一格,本次住客是这一次的调用方);
16
+ * 被互不等价的属主各删过一次的 id 对谁都为真。
17
+ */
18
+ export declare function sessionIdRetiredFor(sessionId: string, owner: string | null | undefined, deployment: DeploymentShapeInput<"principal">): boolean;
19
+ //# sourceMappingURL=deleted-session-ids.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { recordFailOpen } from "./observability/fail-open.js";
2
+ import { sameSessionOwner } from "./security.js";
3
+ export const DELETED_SESSION_ID_CAP = 50_000;
4
+ const DELETED_UNDER_SEVERAL = Symbol("deleted under several owners");
5
+ const formerOwners = new Map();
6
+ export function retireSessionId(sessionId, owner, deployment) {
7
+ const prior = formerOwners.get(sessionId);
8
+ const recorded = prior === undefined ? [owner] : sessionIdRetiredFor(sessionId, owner, deployment) ? DELETED_UNDER_SEVERAL : prior === DELETED_UNDER_SEVERAL || prior.includes(owner) ? prior : [...prior, owner];
9
+ formerOwners.delete(sessionId);
10
+ formerOwners.set(sessionId, recorded);
11
+ if (formerOwners.size <= DELETED_SESSION_ID_CAP)
12
+ return;
13
+ const oldest = formerOwners.keys().next().value;
14
+ if (oldest !== undefined)
15
+ formerOwners.delete(oldest);
16
+ recordFailOpen("server.session-id-tombstone.evicted", `cap=${DELETED_SESSION_ID_CAP}`);
17
+ }
18
+ export function sessionIdRetiredFor(sessionId, owner, deployment) {
19
+ const former = formerOwners.get(sessionId);
20
+ if (former === undefined)
21
+ return false;
22
+ if (owner === undefined || former === DELETED_UNDER_SEVERAL)
23
+ return true;
24
+ return !former.every((f) => sameSessionOwner(deployment, f, owner));
25
+ }
26
+ //# sourceMappingURL=deleted-session-ids.js.map