@sema-agent/server 7.132.0 → 7.133.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 (402) hide show
  1. package/MIGRATION.md +266 -0
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +7 -6
  4. package/USAGE.md +174 -55
  5. package/deploy/sema-up/README.md +19 -1
  6. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
  7. package/deploy/sema-up/chart/templates/server.yaml +5 -2
  8. package/deploy/sema-up/stack/compose.yaml +3 -0
  9. package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
  10. package/dist/adoption/plan.d.ts +3 -2
  11. package/dist/adoption/plan.js +7 -5
  12. package/dist/adoption/runner.js +3 -10
  13. package/dist/adoption/sql.d.ts +3 -2
  14. package/dist/adoption/sql.js +3 -5
  15. package/dist/adoption/wire.d.ts +4 -1
  16. package/dist/adoption/wire.js +1 -0
  17. package/dist/approval-ask-audit-store.d.ts +31 -13
  18. package/dist/approval-ask-audit-store.js +272 -74
  19. package/dist/approval-ask-machine.d.ts +15 -0
  20. package/dist/approval-ask-machine.js +6 -0
  21. package/dist/approval-ask-retention.d.ts +136 -0
  22. package/dist/approval-ask-retention.js +102 -0
  23. package/dist/approval-card.d.ts +79 -19
  24. package/dist/approval-card.js +44 -13
  25. package/dist/approval-deny-reasons.d.ts +1 -1
  26. package/dist/approval.d.ts +9 -0
  27. package/dist/approval.js +24 -3
  28. package/dist/audit.d.ts +27 -10
  29. package/dist/audit.js +12 -16
  30. package/dist/bake-runner/main.js +3 -2
  31. package/dist/boot/deferred-sandbox-path-env.js +1 -1
  32. package/dist/boot/execution-env.js +9 -7
  33. package/dist/boot/execution-lane.js +11 -0
  34. package/dist/boot/leader.js +2 -0
  35. package/dist/boot/memory-boundary.js +2 -2
  36. package/dist/boot/memory-consolidation.d.ts +5 -4
  37. package/dist/boot/memory-consolidation.js +7 -6
  38. package/dist/boot/org-delivery.d.ts +28 -0
  39. package/dist/boot/org-delivery.js +20 -0
  40. package/dist/boot/reapers.d.ts +3 -0
  41. package/dist/boot/reapers.js +21 -1
  42. package/dist/boot/resolve-spec.d.ts +3 -0
  43. package/dist/boot/resolve-spec.js +60 -81
  44. package/dist/boot/runner-deps.js +1 -0
  45. package/dist/boot/session-faces.d.ts +1 -0
  46. package/dist/boot/session-faces.js +4 -2
  47. package/dist/boot/stage-02-web-admin-pull.js +4 -1
  48. package/dist/boot/stage-06-runners.d.ts +2 -0
  49. package/dist/boot/stage-06-runners.js +6 -3
  50. package/dist/boot/stage-07-capability-layer.d.ts +2 -0
  51. package/dist/boot/stage-07-capability-layer.js +24 -3
  52. package/dist/boot/stage-08-reapers.d.ts +2 -0
  53. package/dist/boot/stage-08-reapers.js +2 -2
  54. package/dist/boot/stage-09-leader.d.ts +3 -0
  55. package/dist/boot/stage-10-http-server.d.ts +3 -0
  56. package/dist/boot/stage-10-http-server.js +5 -6
  57. package/dist/boot/stores.js +2 -2
  58. package/dist/boot/web-admin.d.ts +4 -0
  59. package/dist/boot/web-admin.js +151 -63
  60. package/dist/boot/workflow-orchestration.d.ts +2 -0
  61. package/dist/boot/workflow-orchestration.js +2 -1
  62. package/dist/brain.js +8 -3
  63. package/dist/breaker-key.d.ts +6 -0
  64. package/dist/breaker-key.js +29 -0
  65. package/dist/caller-text-echo.d.ts +9 -6
  66. package/dist/caller-text-echo.js +8 -11
  67. package/dist/capabilities/center-plugins.d.ts +7 -0
  68. package/dist/capabilities/center-plugins.js +1 -1
  69. package/dist/capabilities/composite-members.d.ts +1 -1
  70. package/dist/capabilities/composite-members.js +1 -1
  71. package/dist/capabilities/execution-lane.js +2 -2
  72. package/dist/capabilities/hands-lane.d.ts +21 -0
  73. package/dist/capabilities/hands-lane.js +10 -0
  74. package/dist/capabilities/mcp-probe.d.ts +36 -4
  75. package/dist/capabilities/mcp-probe.js +27 -4
  76. package/dist/capabilities/scenarios.d.ts +63 -7
  77. package/dist/capabilities/scenarios.js +39 -7
  78. package/dist/capability-facts.d.ts +34 -4
  79. package/dist/capability-facts.js +28 -2
  80. package/dist/center-config-tier.d.ts +69 -0
  81. package/dist/center-config-tier.js +42 -0
  82. package/dist/checkpoint-identity.d.ts +16 -0
  83. package/dist/checkpoint-identity.js +19 -0
  84. package/dist/config-catalog.d.ts +17 -10
  85. package/dist/config-catalog.js +43 -28
  86. package/dist/config-d-migration.d.ts +3 -1
  87. package/dist/config-d-migration.js +2 -2
  88. package/dist/config-dir-trust.d.ts +114 -0
  89. package/dist/config-dir-trust.js +388 -0
  90. package/dist/config-invariants.d.ts +18 -5
  91. package/dist/config-invariants.js +35 -3
  92. package/dist/config-provider.d.ts +6 -1
  93. package/dist/config-provider.js +6 -2
  94. package/dist/config-types.d.ts +71 -14
  95. package/dist/config-types.js +8 -0
  96. package/dist/config.d.ts +13 -0
  97. package/dist/config.js +121 -59
  98. package/dist/delegated-session-owner.d.ts +185 -0
  99. package/dist/delegated-session-owner.js +119 -0
  100. package/dist/device-protocol.d.ts +5 -3
  101. package/dist/device-protocol.js +1 -1
  102. package/dist/device-ws-hub.js +21 -2
  103. package/dist/device-ws-protocol.d.ts +70 -6
  104. package/dist/device-ws-protocol.js +50 -23
  105. package/dist/elicitation.js +3 -2
  106. package/dist/entry-problems.d.ts +34 -0
  107. package/dist/entry-problems.js +14 -0
  108. package/dist/execution-lane-caps.d.ts +49 -10
  109. package/dist/execution-lane-caps.js +43 -4
  110. package/dist/field-conflict.d.ts +43 -0
  111. package/dist/field-conflict.js +20 -0
  112. package/dist/fleet/fleet-bus.d.ts +80 -6
  113. package/dist/fleet/fleet-bus.js +41 -9
  114. package/dist/hooks/classic-stations.d.ts +10 -5
  115. package/dist/hooks/classic-stations.js +4 -4
  116. package/dist/hooks/command-spawn.d.ts +57 -0
  117. package/dist/hooks/command-spawn.js +139 -0
  118. package/dist/hooks/hook-llm.js +2 -2
  119. package/dist/hooks/hook-runner.d.ts +127 -25
  120. package/dist/hooks/hook-runner.js +668 -287
  121. package/dist/hooks/hook-source.d.ts +44 -0
  122. package/dist/hooks/hook-source.js +40 -0
  123. package/dist/http/active-run-conflict.d.ts +5 -13
  124. package/dist/http/active-run-conflict.js +17 -27
  125. package/dist/http/admission.js +103 -60
  126. package/dist/http/approval-sweeps.js +55 -18
  127. package/dist/http/caller-trust.d.ts +77 -0
  128. package/dist/http/caller-trust.js +143 -0
  129. package/dist/http/checkpoint-ctx.d.ts +16 -16
  130. package/dist/http/checkpoint-ctx.js +13 -10
  131. package/dist/http/claimed-run.d.ts +4 -3
  132. package/dist/http/device-placement.d.ts +2 -4
  133. package/dist/http/device-placement.js +2 -1
  134. package/dist/http/dispatch.js +10 -4
  135. package/dist/http/durable-run-leg.d.ts +4 -32
  136. package/dist/http/durable-run-leg.js +34 -10
  137. package/dist/http/owner-access.d.ts +56 -0
  138. package/dist/http/owner-access.js +42 -0
  139. package/dist/http/principal-gate.d.ts +48 -23
  140. package/dist/http/principal-gate.js +39 -12
  141. package/dist/http/readiness.d.ts +11 -5
  142. package/dist/http/readiness.js +10 -3
  143. package/dist/http/request-guards.d.ts +16 -23
  144. package/dist/http/request-guards.js +30 -15
  145. package/dist/http/resume-ctx-read.d.ts +2 -5
  146. package/dist/http/resume-ctx-read.js +7 -4
  147. package/dist/http/resume-legs.d.ts +3 -4
  148. package/dist/http/resume-legs.js +126 -69
  149. package/dist/http/retired-service-deps.d.ts +43 -0
  150. package/dist/http/retired-service-deps.js +18 -0
  151. package/dist/http/route-ctx.d.ts +44 -28
  152. package/dist/http/route-ctx.js +4 -0
  153. package/dist/http/route-table.js +2 -0
  154. package/dist/http/routes/a2a-serve.js +3 -4
  155. package/dist/http/routes/admin-config-refresh.js +1 -1
  156. package/dist/http/routes/admin-drain.js +1 -1
  157. package/dist/http/routes/admin-memory-optout.js +5 -1
  158. package/dist/http/routes/adoption.js +2 -9
  159. package/dist/http/routes/approvals-assistant.js +49 -48
  160. package/dist/http/routes/background.js +3 -2
  161. package/dist/http/routes/capabilities.js +20 -4
  162. package/dist/http/routes/config-catalog.d.ts +3 -3
  163. package/dist/http/routes/config-catalog.js +1 -1
  164. package/dist/http/routes/devices.js +3 -17
  165. package/dist/http/routes/diagnostics.js +5 -1
  166. package/dist/http/routes/images.js +6 -7
  167. package/dist/http/routes/leader.js +1 -8
  168. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  169. package/dist/http/routes/mcp-reconnect.js +3 -2
  170. package/dist/http/routes/memory-bundle.js +1 -1
  171. package/dist/http/routes/memory-compliance.js +1 -1
  172. package/dist/http/routes/memory-consolidation.js +1 -1
  173. package/dist/http/routes/memory-origin.js +1 -1
  174. package/dist/http/routes/memory-policy.d.ts +1 -1
  175. package/dist/http/routes/memory-policy.js +3 -2
  176. package/dist/http/routes/notify-wake.js +8 -21
  177. package/dist/http/routes/observability.js +2 -2
  178. package/dist/http/routes/principal-inbox.d.ts +39 -0
  179. package/dist/http/routes/principal-inbox.js +76 -0
  180. package/dist/http/routes/retention-ops.js +2 -9
  181. package/dist/http/routes/rules.js +5 -18
  182. package/dist/http/routes/runs.d.ts +5 -0
  183. package/dist/http/routes/runs.js +33 -106
  184. package/dist/http/routes/session-sync.js +15 -28
  185. package/dist/http/routes/sessions.js +30 -40
  186. package/dist/http/routes/side-query.js +6 -4
  187. package/dist/http/routes/tasks.js +50 -14
  188. package/dist/http/routes/workflows.d.ts +351 -0
  189. package/dist/http/routes/workflows.js +153 -119
  190. package/dist/http/send.d.ts +24 -3
  191. package/dist/http/send.js +14 -2
  192. package/dist/http/server.d.ts +17 -18
  193. package/dist/http/server.js +15 -13
  194. package/dist/http/stored-body-replay.js +17 -4
  195. package/dist/http/submit-ctx.js +4 -3
  196. package/dist/http/submit-replay.d.ts +4 -3
  197. package/dist/http/submit-replay.js +5 -4
  198. package/dist/http/wire-types.d.ts +10 -7
  199. package/dist/index.d.ts +1 -1
  200. package/dist/index.js +0 -1
  201. package/dist/lane-home-probe.d.ts +78 -9
  202. package/dist/lane-home-probe.js +78 -12
  203. package/dist/leader/endpoint.d.ts +4 -1
  204. package/dist/leader/endpoint.js +11 -10
  205. package/dist/limit-refusal.d.ts +17 -5
  206. package/dist/limit-refusal.js +4 -1
  207. package/dist/mcp-assertion-header.d.ts +31 -10
  208. package/dist/mcp-assertion-header.js +10 -3
  209. package/dist/mcp-tool-faces.js +1 -3
  210. package/dist/memory-project-layer.d.ts +37 -0
  211. package/dist/memory-project-layer.js +46 -0
  212. package/dist/memory-scope.d.ts +23 -16
  213. package/dist/memory-scope.js +24 -8
  214. package/dist/memory-sync-client.d.ts +27 -13
  215. package/dist/memory-sync-client.js +107 -18
  216. package/dist/model-entry-refusal.d.ts +9 -1
  217. package/dist/model-entry-refusal.js +6 -1
  218. package/dist/model-plane-face.d.ts +51 -0
  219. package/dist/model-plane-face.js +24 -0
  220. package/dist/model-provider.d.ts +5 -0
  221. package/dist/model-provider.js +4 -2
  222. package/dist/model-route-endpoint.d.ts +8 -11
  223. package/dist/model-route-endpoint.js +4 -7
  224. package/dist/model-route-env.d.ts +22 -0
  225. package/dist/model-route-env.js +2 -0
  226. package/dist/model-route-gap.d.ts +60 -30
  227. package/dist/model-route-gap.js +21 -15
  228. package/dist/observability/corrupt-read-seat.d.ts +7 -0
  229. package/dist/observability/corrupt-read-seat.js +9 -0
  230. package/dist/observability/err-text.d.ts +6 -0
  231. package/dist/observability/err-text.js +18 -4
  232. package/dist/observability/fail-open.d.ts +35 -9
  233. package/dist/observability/fail-open.js +35 -9
  234. package/dist/observability/metrics.js +1 -0
  235. package/dist/observability/prompt-manifest.d.ts +3 -17
  236. package/dist/observability/prompt-manifest.js +45 -42
  237. package/dist/observability/tool-trace.js +9 -9
  238. package/dist/operator-ask.d.ts +10 -0
  239. package/dist/operator-ask.js +3 -0
  240. package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
  241. package/dist/orchestration/workflow-agent-session-index.js +9 -13
  242. package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
  243. package/dist/orchestration/workflow-completion-inbox.js +13 -0
  244. package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
  245. package/dist/orchestration/workflow-notify-journal.js +27 -34
  246. package/dist/orchestration/workflow-park-decision.d.ts +89 -0
  247. package/dist/orchestration/workflow-park-decision.js +118 -0
  248. package/dist/org-delivery-gate.d.ts +81 -0
  249. package/dist/org-delivery-gate.js +59 -0
  250. package/dist/panel-tool-names.d.ts +23 -0
  251. package/dist/panel-tool-names.js +8 -0
  252. package/dist/parked-decide.d.ts +39 -6
  253. package/dist/parked-decide.js +98 -51
  254. package/dist/parked-revive-surface.d.ts +9 -2
  255. package/dist/parked-revive-surface.js +11 -8
  256. package/dist/permission-rule-list.d.ts +1 -1
  257. package/dist/permission-rule-list.js +2 -2
  258. package/dist/plugins/approval-ask-store-file.d.ts +16 -1
  259. package/dist/plugins/approval-ask-store-file.js +21 -0
  260. package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
  261. package/dist/plugins/approval-ask-store-memory.js +34 -2
  262. package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
  263. package/dist/plugins/approval-ask-store-sql.js +37 -1
  264. package/dist/plugins/blob-backend.d.ts +38 -25
  265. package/dist/plugins/blob-backend.js +29 -19
  266. package/dist/plugins/breaker-state-sql.d.ts +2 -2
  267. package/dist/plugins/breaker-state-sql.js +4 -4
  268. package/dist/plugins/caching-session-store.d.ts +3 -0
  269. package/dist/plugins/caching-session-store.js +3 -0
  270. package/dist/plugins/checkpoint-store-sql.d.ts +14 -0
  271. package/dist/plugins/checkpoint-store-sql.js +20 -2
  272. package/dist/plugins/file-history-store-sql.d.ts +5 -2
  273. package/dist/plugins/file-history-store-sql.js +3 -1
  274. package/dist/plugins/file-run-store.d.ts +5 -13
  275. package/dist/plugins/file-run-store.js +9 -0
  276. package/dist/plugins/fork-routing-session-store.d.ts +9 -1
  277. package/dist/plugins/fork-routing-session-store.js +12 -1
  278. package/dist/plugins/host-platform.d.ts +2 -0
  279. package/dist/plugins/host-platform.js +2 -1
  280. package/dist/plugins/local-checkpoint-store.d.ts +2 -0
  281. package/dist/plugins/local-checkpoint-store.js +6 -1
  282. package/dist/plugins/local-session-store.d.ts +1 -1
  283. package/dist/plugins/local-session-window.d.ts +39 -0
  284. package/dist/plugins/local-session-window.js +54 -0
  285. package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
  286. package/dist/plugins/mailbox-store-sql.d.ts +30 -48
  287. package/dist/plugins/mailbox-store-sql.js +77 -52
  288. package/dist/plugins/memory-embedder-fingerprint.js +2 -1
  289. package/dist/plugins/memory-run-store.d.ts +5 -13
  290. package/dist/plugins/memory-run-store.js +8 -0
  291. package/dist/plugins/one-time-migrations.d.ts +110 -5
  292. package/dist/plugins/one-time-migrations.js +320 -8
  293. package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
  294. package/dist/plugins/org-delivery-quota-store.js +228 -0
  295. package/dist/plugins/pg-pool.js +39 -7
  296. package/dist/plugins/pg-session-storage.d.ts +17 -4
  297. package/dist/plugins/pg-session-storage.js +29 -6
  298. package/dist/plugins/remote-env-adb.d.ts +6 -12
  299. package/dist/plugins/remote-env-adb.js +12 -2
  300. package/dist/plugins/remote-env-k8s.d.ts +8 -12
  301. package/dist/plugins/remote-env-k8s.js +23 -5
  302. package/dist/plugins/remote-env-local-docker.d.ts +10 -15
  303. package/dist/plugins/remote-env-local-docker.js +12 -9
  304. package/dist/plugins/remote-env-ssh.d.ts +10 -16
  305. package/dist/plugins/remote-env-ssh.js +17 -11
  306. package/dist/plugins/run-store-sql.d.ts +16 -14
  307. package/dist/plugins/run-store-sql.js +22 -2
  308. package/dist/plugins/schema-indexes.js +2 -0
  309. package/dist/plugins/send-user-file.js +2 -2
  310. package/dist/plugins/session-epoch-anchor.d.ts +32 -6
  311. package/dist/plugins/session-epoch-anchor.js +2 -3
  312. package/dist/plugins/session-store.d.ts +18 -8
  313. package/dist/plugins/session-store.js +15 -4
  314. package/dist/plugins/sql-driver.d.ts +74 -11
  315. package/dist/plugins/sql-driver.js +210 -12
  316. package/dist/plugins/sql-errors.d.ts +23 -0
  317. package/dist/plugins/sql-errors.js +21 -0
  318. package/dist/plugins/store-backend.d.ts +36 -1
  319. package/dist/plugins/store-backend.js +40 -14
  320. package/dist/plugins/store-contracts.d.ts +42 -0
  321. package/dist/plugins/store-contracts.js +1 -0
  322. package/dist/plugins/tidb-pool.d.ts +6 -1
  323. package/dist/plugins/tidb-pool.js +44 -10
  324. package/dist/plugins/tidb-session-storage.d.ts +3 -2
  325. package/dist/plugins/tidb-session-storage.js +2 -2
  326. package/dist/plugins/tidb-session-store.d.ts +24 -4
  327. package/dist/plugins/tidb-session-store.js +28 -4
  328. package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
  329. package/dist/plugins/workflow-journal-store-sql.js +19 -6
  330. package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
  331. package/dist/plugins/workflow-run-store-sql.js +50 -9
  332. package/dist/posture-source.d.ts +18 -10
  333. package/dist/posture-source.js +4 -1
  334. package/dist/project-identity.d.ts +45 -6
  335. package/dist/project-identity.js +162 -8
  336. package/dist/project-layer-key.d.ts +28 -0
  337. package/dist/project-layer-key.js +29 -0
  338. package/dist/question.js +3 -2
  339. package/dist/read-deny-entry.d.ts +25 -0
  340. package/dist/read-deny-entry.js +12 -0
  341. package/dist/read-face-posture.d.ts +37 -11
  342. package/dist/read-face-posture.js +32 -3
  343. package/dist/request-key-closure.d.ts +7 -0
  344. package/dist/request-key-closure.js +9 -1
  345. package/dist/request-value-closure.d.ts +5 -0
  346. package/dist/request-value-closure.js +11 -3
  347. package/dist/rule-entry-list.d.ts +26 -2
  348. package/dist/rule-entry-list.js +72 -12
  349. package/dist/rules-consent.js +3 -4
  350. package/dist/run-acceptance.d.ts +19 -3
  351. package/dist/run-acceptance.js +13 -1
  352. package/dist/run-local.js +36 -6
  353. package/dist/runs.d.ts +10 -9
  354. package/dist/runs.js +21 -3
  355. package/dist/runtime-caps-resolver.d.ts +16 -6
  356. package/dist/runtime-caps-resolver.js +18 -5
  357. package/dist/sandbox-pkg-source.d.ts +19 -1
  358. package/dist/sandbox-pkg-source.js +29 -7
  359. package/dist/security.d.ts +87 -9
  360. package/dist/security.js +52 -9
  361. package/dist/session-error-wire.d.ts +19 -2
  362. package/dist/session-error-wire.js +5 -1
  363. package/dist/session-titled-frame.d.ts +33 -0
  364. package/dist/session-titled-frame.js +4 -0
  365. package/dist/session-titler.d.ts +9 -1
  366. package/dist/session-titler.js +15 -4
  367. package/dist/spec-fields.js +21 -2
  368. package/dist/sql-engine-posture.d.ts +3 -1
  369. package/dist/task-cwd.d.ts +1 -1
  370. package/dist/task-mcp.d.ts +3 -3
  371. package/dist/task-mcp.js +7 -66
  372. package/dist/task-settings.d.ts +89 -88
  373. package/dist/task-settings.js +71 -63
  374. package/dist/text-bidi.d.ts +0 -4
  375. package/dist/text-bidi.js +1 -3
  376. package/dist/tighten-only-seats.d.ts +150 -0
  377. package/dist/tighten-only-seats.js +196 -0
  378. package/dist/tool-approval.d.ts +303 -87
  379. package/dist/tool-approval.js +623 -239
  380. package/dist/trace/core-keyset-guard.d.ts +104 -22
  381. package/dist/trace/exit-seat.d.ts +28 -0
  382. package/dist/trace/exit-seat.js +76 -0
  383. package/dist/trace/ledger-events.d.ts +3 -2
  384. package/dist/trace/project.d.ts +80 -12
  385. package/dist/trace/project.js +41 -28
  386. package/dist/trace/projection-table.d.ts +100 -0
  387. package/dist/trace/projection-table.js +130 -0
  388. package/dist/trace/redact.d.ts +54 -0
  389. package/dist/trace/redact.js +778 -152
  390. package/dist/trace/self-minted-wire.d.ts +345 -1
  391. package/dist/trace/self-minted-wire.js +117 -1
  392. package/dist/trace/wire-projection-faces.d.ts +298 -2
  393. package/dist/trace/wire-projection-faces.js +154 -13
  394. package/dist/url-refusal.js +2 -0
  395. package/dist/web-admin-client/apply-effective.d.ts +12 -0
  396. package/dist/web-admin-client/apply-effective.js +56 -5
  397. package/dist/web-admin-client/facade.d.ts +1 -1
  398. package/dist/web-admin-client/facade.js +1 -1
  399. package/dist/web-admin-client/read-face.js +5 -9
  400. package/dist/web-admin-client/skills-mcp.js +4 -5
  401. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
  402. package/package.json +7 -3
@@ -17,6 +17,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
17
17
  }>) | undefined;
18
18
  webAdminJwtVerifier: import("../auth-bridge.js").WebAdminJwtVerifier | undefined;
19
19
  sessionAudit: ((sessionId: string, opts?: import("../audit.js").SessionAuditReadOpts) => Promise<{
20
+ agent?: import("../audit.js").SessionAgent | undefined;
20
21
  owner: string | null;
21
22
  sessionId: string;
22
23
  createdAt: string;
@@ -101,6 +102,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
101
102
  workflowCompletionInbox: import("../orchestration/workflow-completion-inbox.js").WorkflowCompletionInbox | undefined;
102
103
  workflowJournalStore: import("../plugins/store-backend.js").ServiceWorkflowJournalStore | undefined;
103
104
  workflowModelAllowlistSnapshot: readonly string[];
105
+ workflowParkDecisions: import("../orchestration/workflow-park-decision.js").WorkflowParkDecisionStore | undefined;
104
106
  workflowNotifyGate: import("../orchestration/workflow-notify-journal.js").WorkflowNotifyGate | undefined;
105
107
  workflowNotifyJournal: import("../orchestration/workflow-notify-journal.js").WorkflowNotifyJournalStore | undefined;
106
108
  workflowRecoverOpts: {
@@ -110,6 +112,7 @@ export declare function runStage10(ctx: Awaited<ReturnType<typeof runStage09>>):
110
112
  };
111
113
  workflowRunStore: import("../orchestration/workflow-notify-journal.js").JournalingWorkflowRunStore | undefined;
112
114
  workflowsCapable: boolean;
115
+ orgDeliveryGate: import("@sema-agent/core").OrgDeliveryGate | undefined;
113
116
  deploymentMods: readonly import("@sema-agent/core").ModRegistration<import("@sema-agent/core").EngineDollar>[];
114
117
  deviceLane: import("./device-lane.js").DeviceLane | undefined;
115
118
  dropSessionScoped: (sid: string) => void;
@@ -9,7 +9,6 @@ import { createHttpServer } from "../http/server.js";
9
9
  import { exportMemoryScope } from "../memory-export.js";
10
10
  import { performMemorySync } from "../memory-sync.js";
11
11
  import { backgroundAgentOutput, taskHandleOutput, taskHandleStop } from "../runs.js";
12
- import { sqlBlobCapOf } from "../plugins/blob-backend.js";
13
12
  import { createStoreLiveProbe } from "../store-live-probe.js";
14
13
  import { counterStoreLabel } from "../plugins/store-backend.js";
15
14
  import { sessionStoreLabelOf } from "../store-posture.js";
@@ -30,7 +29,7 @@ import { bindServerLateSeats } from "./late-binds.js";
30
29
  import { serviceVersion } from "../service-version.js";
31
30
  import { buildDisplaySafeUrl } from "../trace/redact.js";
32
31
  export async function runStage10(ctx) {
33
- const { approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, parkCommits, config, webAdmin, consolidationValve, costQuota, deviceLane, drainState, durableEnabled, elicitation, fenceSessionOwner, fileHistoryStore, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, localRoot, logger, lspManager, mcpRevocations, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportBackend, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekResolver, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionPolicyStore, sessionTitler, sessionWatchRegistry, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable } = ctx;
32
+ const { approvalAskAudit, approvalExemptionStore, approvalNonceStore, authorize, backend, backgroundAgentStore, brain, breakerState, centerRuntimeCapsResolver, checkpointStore, parkCommits, config, webAdmin, consolidationValve, costQuota, deviceLane, drainState, durableEnabled, elicitation, fenceSessionOwner, fileHistoryStore, fleetBus, fleetLease, fleetUsage, governanceSeams, handslessRunner, hookAgent, hookLlm, hookWakeBus, imageBakes, imageIndex, instanceId, instrumentDegenerate, leaderEndpoint, localRoot, logger, lspManager, mcpRevocations, memoryBundleFaces, memoryComplianceFaces, memoryConsolidationFaces, memoryEngine, memoryExportBackend, memoryOptOutGrantStore, memoryOriginFaces, memoryPosture, memorySyncCursors, memorySyncRunner, metrics, modelUsageTracker, orgMemoryAdmission, otelExporter, outcomeSink, ownerAware, parkedReviveInheritedGate, parkedReviveSurface, perSessionCwd, perTaskImage, planCacheProbe, pricing, principalCaps, promptManifestTracker, purgeSession, question, rateLimiter, reaper, webAdminJwtVerifier, resumeAnchorStore, retentionLaneStarted, retentionLaneStore, ruleConsent, runStore, runner, runnerDeps, runtimeCapsPeekResolver, scenarioDetails, scenarios, selectEnvTool, sendFileLedger, sendUserFileEmitter, sendUserFileToolSpec, sessionAudit, sessionEnvSelection, sessionMemoryStatusFace, sessionPolicyStore, sessionTitler, sessionWatchRegistry, setSessionCwd, setSessionInheritEnv, setSessionShellEnv, sharedMemoryStore, sideQueryAccounting, sqlEngine, sqlWorkflowRunStore, staticWiring, storePosture, subRunner, subagentSteerRegistry, taskAttachmentStore, taskLimitCaps, taskTimeoutSec, toolApproval, toolResultStore, usageWindowStore, userInputLedger, webSearchProvider, workflowAgentRegistry, workflowAgentSessionIndex, workflowParkDecisions, workflowCompletionInbox, workflowJournalStore, workflowModelAllowlistSnapshot, workflowNotifyGate, workflowNotifyJournal, workflowRecoverOpts, workflowRunStore, workflowsCapable, orgDeliveryGate } = ctx;
34
33
  const stores = {
35
34
  runStore,
36
35
  resumeAnchorStore: resumeAnchorStore ? resumeAnchorStore : undefined,
@@ -47,6 +46,7 @@ export async function runStage10(ctx) {
47
46
  peerDirectory: runnerDeps.peerDirectory,
48
47
  workflowRunStore: workflowRunStore ? workflowRunStore : undefined,
49
48
  workflowAgentSessionIndex: workflowAgentSessionIndex ? workflowAgentSessionIndex : undefined,
49
+ workflowParkDecisions: workflowParkDecisions ? workflowParkDecisions : undefined,
50
50
  workflowJournalStore: workflowJournalStore ? workflowJournalStore : undefined,
51
51
  imageIndex,
52
52
  imageBakes,
@@ -99,6 +99,7 @@ export async function runStage10(ctx) {
99
99
  memoryConsolidation: memoryConsolidationFaces,
100
100
  memoryOptOutGrant: memoryOptOutGrantStore,
101
101
  orgMemoryDirectory: orgMemoryAdmission.directory,
102
+ orgDeliveryGate,
102
103
  sharedMemoryStore: sharedMemoryStore ? sharedMemoryStore : undefined,
103
104
  sessionMirrorRuling: principalCaps
104
105
  ? async (p) => (await principalCaps.executionRuling(p))?.sessionMirror
@@ -177,6 +178,7 @@ export async function runStage10(ctx) {
177
178
  restartState: () => webAdmin.restartState(),
178
179
  configApplyState: () => webAdmin.configApplyState(),
179
180
  centerCredentialState: () => webAdmin.centerCredentialState(),
181
+ centerIdentityNoticeState: () => webAdmin.centerIdentityNoticeState(),
180
182
  modelRefusalsState: () => webAdmin.modelRefusalsState(),
181
183
  candidateRejectionState: () => webAdmin.candidateRejectionState(),
182
184
  configHandoffState: () => webAdmin.configHandoffState(),
@@ -191,9 +193,6 @@ export async function runStage10(ctx) {
191
193
  storeLiveState: storeLiveProbe ? () => storeLiveProbe.state() : undefined,
192
194
  };
193
195
  const knobs = {
194
- snapshotBlobSqlCap: sqlEngine !== undefined && !config.snapshotBlobStore
195
- ? () => sqlBlobCapOf(config.snapshotBlobSqlMaxBytes, sqlEngine)
196
- : undefined,
197
196
  sessionEventsMaxConnections: sessionWatchRegistry ? posIntEnv(process.env.SESSION_EVENTS_MAX_CONNS, 256, 100_000) : undefined,
198
197
  };
199
198
  const resolveSpec = createResolveSpec({
@@ -201,7 +200,7 @@ export async function runStage10(ctx) {
201
200
  getKeyResolver: () => webAdmin.getKeyResolver(),
202
201
  taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner,
203
202
  hookLlm, hookAgent, fleetBus, hookWakeBus, resumeAnchorStore, ownerAware, taskLimitCaps, taskTimeoutSec,
204
- selectEnvTool, sendUserFileToolSpec, memoryEngine, durableEnabled, approvalExemptionStore,
203
+ selectEnvTool, sendUserFileToolSpec, memoryEngine, memorySyncRunner, durableEnabled, approvalExemptionStore,
205
204
  checkpointStore, imageIndex, perTaskImage,
206
205
  sessionEnvSelection,
207
206
  lockedKeys: governanceSeams.lockedKeys,
@@ -377,7 +377,7 @@ export async function openStores(ctx) {
377
377
  ...(config.memorySync.maxPushEntries !== undefined ? { maxPushEntries: config.memorySync.maxPushEntries } : {}),
378
378
  ...(config.memorySync.maxPullEntries !== undefined ? { maxPullEntries: config.memorySync.maxPullEntries } : {}),
379
379
  });
380
- logger.info("memory_sync_enabled", { url: buildDisplaySafeUrl(config.memorySync.url), scope: config.memorySync.scope, cursorPath: memorySyncRunner.cursorPath });
380
+ logger.info("memory_sync_enabled", { url: buildDisplaySafeUrl(config.memorySync.url), scope: config.memorySync.scope, cursorPath: memorySyncRunner.cursorPathFor(config.memorySync.scope) });
381
381
  memorySyncRunner.trigger("boot");
382
382
  }
383
383
  else {
@@ -436,7 +436,7 @@ export async function openStores(ctx) {
436
436
  const breakerState = backend?.breaker && config.resilience.circuitBreaker
437
437
  ? backend
438
438
  .breaker((streak) => {
439
- metrics.setGauge("counter_flush_fail_streak", streak, { table: "circuit_breaker", kind: "write_through" });
439
+ metrics.setGauge("counter_flush_fail_streak", streak, { table: "breaker_state", kind: "write_through" });
440
440
  if (streak > 0)
441
441
  metrics.inc("breaker_writethrough_failed_total", { backend: backend.kind });
442
442
  if (streak === 3)
@@ -4,6 +4,7 @@ import { buildPricing } from "../budget.js";
4
4
  import { type Scenario, type ScenarioDeps, type ScenarioDetail } from "../capabilities/scenarios.js";
5
5
  import type { LoadedSkill } from "../capabilities/skills.js";
6
6
  import { type ServiceConfig } from "../config.js";
7
+ import { type CenterIdentityNotice } from "../center-config-tier.js";
7
8
  import { type CenterCredentialHealthView } from "../center-credential-renewer.js";
8
9
  import { type ModelKeyRef } from "../key-resolver.js";
9
10
  import type { Logger } from "../observability/logger.js";
@@ -83,6 +84,9 @@ export interface WebAdminRuntime {
83
84
  stopRefreshLoop(): void;
84
85
  /** S-698:`/health.centerCredential` 的取值口 —— 凭证来源的健康态 + 续签器状态;都健康 / 没有中心 ⇒ `undefined`(键缺席)。 */
85
86
  centerCredentialState(): CenterCredentialHealthView | undefined;
87
+ /** S-667:`/health.centerIdentityNotice` 的取值口 —— 中心凭证换人后的**最近一条**通告(`center_identity_demoted` 已降到无中心配置档 / `center_identity_landed`
88
+ * 新身份的配置已换上;码、冻结句与状态机见 `center-config-tier.ts`)。从未换过人 / 没有中心 ⇒ `undefined`(键缺席)。值形就是 wire 形 `{ code, message, at }`。 */
89
+ centerIdentityNoticeState(): CenterIdentityNotice | undefined;
86
90
  /** [ref](core 5.50 [ref]):mid-turn MCP 撤销台账读口,喂 `RunnerDeps.mcpRevocations` 席。
87
91
  * **取走即声明接线**——调用本方法后,restart 信号的 mcp 片对纯删除向豁免(台账即时承接);
88
92
  * 不取 ⇒ 旧 restart 语义逐字保留(fail-closed)。 */
@@ -11,14 +11,17 @@ import { applyCenterPlugins } from "../capabilities/center-plugins.js";
11
11
  import { applyCenterArtifact, centerSourceOnError, withPromptArtifactBackfill } from "../capabilities/center-prompts.js";
12
12
  import { centerScenarios, centerScenarioDetails } from "../capabilities/scenarios.js";
13
13
  import { isRosterGateArmed } from "../config.js";
14
+ import { toolsRunOnThisHost } from "../task-cwd.js";
14
15
  import { defaultLkgPath, defaultSkillCacheDir, saveLkg, loadLkg, legacyV1LkgPath, migrateV1Lkg } from "../config-lkg.js";
15
16
  import { answerStillCurrent, centerStateBin, credentialIdentityNow, judgeCenterCredentialAtBoot } from "../center-credential.js";
17
+ import { createCenterConfigTier } from "../center-config-tier.js";
16
18
  import { buildCenterCredentialHealthView, createCenterCredentialRenewer } from "../center-credential-renewer.js";
17
19
  import { centerManagedConfigKeys } from "../web-admin-client/apply-effective.js";
18
20
  import { createConfigProvider, raceBootFetch, serviceConfigSourceKind, BOOT_FETCH_DEFERRED } from "../config-provider.js";
21
+ import { ConfigDirUntrustedError } from "../config-dir-trust.js";
19
22
  import { createKeyResolver } from "../key-resolver.js";
20
23
  import { buildSealedKeyPublicFace, ensureSealedKeyStore, reportExecutionPublicKey } from "../sealed-key.js";
21
- import { applyEffective, applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, mutateInPlace, logEffectiveDiff, applySkillsManifest, resolveMcpServers, resolveA2aPeers, restartReasons, modelPlaneChanged, withModelPlaneOf, fullyLandedForLkg, fetchPromptArtifact } from "../web-admin-client/facade.js";
24
+ import { applyEffective, applyCenterReadFace, buildReadFaceBaseline, buildReadFaceSwapCandidate, restoreReadFaceBaseline, mutateInPlace, logEffectiveDiff, applySkillsManifest, resolveMcpServers, resolveA2aPeers, restartReasons, modelPlaneChanged, withModelPlaneOf, fullyLandedForLkg, NO_CENTER_EFFECTIVE, isNoCenterEffective, fetchPromptArtifact } from "../web-admin-client/facade.js";
22
25
  import { buildConfigHandoff, buildRestartSignal, configHandoffMissing } from "../fleet/engine-signal.js";
23
26
  import { createMcpRevocationLedger, enabledMcpEntries } from "../web-admin-client/mcp-revocation.js";
24
27
  import { buildUnreadConfigFileFields, buildUnreadConfigKeyFields } from "../web-admin-client/read-warnings.js";
@@ -26,6 +29,7 @@ import { CONFIG_DOMAIN_INVALID_NOTE, buildCandidateRejectedFields, candidateReje
26
29
  import { SHA256_HEX_RE } from "../digest-form.js";
27
30
  import { BOOT_REJUDGE_OF_REFUSED_GROUP, createConfigApplyLedger, modelPlaneCommitted, refusedGroups } from "../web-admin-client/apply-ledger.js";
28
31
  import { announceReadDenyRows, buildDeploymentPostureSeats } from "./runner-deps.js";
32
+ import { echoCallerText } from "../caller-text-echo.js";
29
33
  function lkgReadNote(scope) {
30
34
  switch (scope) {
31
35
  case "whole":
@@ -86,6 +90,21 @@ export async function createWebAdminRuntime(ctx) {
86
90
  ? createCenterCredentialRenewer({ source: cc.credential, centerUrl: cc.baseUrl, leadMs: config.centerCredentialRenewLeadMs, logger })
87
91
  : undefined;
88
92
  const currentIdentity = () => (cc === undefined ? undefined : credentialIdentityNow(cc.credential));
93
+ const tier = createCenterConfigTier();
94
+ const announceTier = (n) => {
95
+ switch (n.code) {
96
+ case "center_identity_demoted":
97
+ logger.warn(n.code, { at: n.at, message: n.message, ...(n.retained !== undefined ? { retained: n.retained } : {}), note: "the credential identity changed: the previous account's center configuration is dropped (every center-supplied hot face is back on its env base, the center prompt layer is withdrawn, the Runners run the env model table) and a pull for the new identity is under way; skills / MCP / A2A / scenarios are baked at boot and stay the previous account's until a restart (see /health.restart)" });
98
+ return;
99
+ case "center_identity_landed":
100
+ logger.info(n.code, { at: n.at, message: n.message });
101
+ return;
102
+ default: {
103
+ const unknownCode = n.code;
104
+ throw new Error(`announceTier: unknown notice code ${JSON.stringify(unknownCode)}`);
105
+ }
106
+ }
107
+ };
89
108
  const candidateIdentity = new WeakMap();
90
109
  const candidateIdentityOf = (eff) => candidateIdentity.get(eff);
91
110
  const validatorIdentity = new Map();
@@ -133,6 +152,7 @@ export async function createWebAdminRuntime(ctx) {
133
152
  ...(config.configProvider ? { provider: config.configProvider } : {}),
134
153
  ...(cc ? { webAdmin: { baseUrl: cc.baseUrl, credential: cc.credential, worker: cc.worker, dryRun: cc.dryRun } } : {}),
135
154
  localDir: localRoot,
155
+ localOwnerUid: config.configLocalOwnerUid,
136
156
  ...(config.configLkgEnabled ? { skillBodyCacheDir: defaultSkillCacheDir(config) } : {}),
137
157
  })
138
158
  : undefined;
@@ -301,6 +321,10 @@ export async function createWebAdminRuntime(ctx) {
301
321
  if (configProvider && !cc?.dryRun)
302
322
  await rebasePromptState(promptStateIdentity, "boot");
303
323
  const adoptCenterPrompts = async (eff, prompts, phase) => {
324
+ if (isNoCenterEffective(eff)) {
325
+ await rebasePromptState(undefined, phase);
326
+ return;
327
+ }
304
328
  const adoptedIdentity = candidateIdentityOf(eff);
305
329
  if (adoptedIdentity !== undefined && adoptedIdentity !== promptStateIdentity) {
306
330
  await rebasePromptState(adoptedIdentity, phase);
@@ -348,14 +372,20 @@ export async function createWebAdminRuntime(ctx) {
348
372
  return ledger;
349
373
  };
350
374
  const noteHandoff = (next) => {
351
- const applied = next.applied ?? handoff.applied;
375
+ const applied = next.noneApplied === true ? undefined : (next.applied ?? handoff.applied);
352
376
  const durable = next.durable ?? handoff.durable;
353
377
  handoff = { ...(applied !== undefined ? { applied } : {}), ...(durable !== undefined ? { durable } : {}) };
354
378
  latchHandoff();
355
379
  };
356
- const markApplied = (gen, version) => {
357
- applyLedger.applied(gen, version);
358
- noteHandoff({ applied: version });
380
+ const markApplied = (gen, eff) => {
381
+ applyLedger.applied(gen, eff.version);
382
+ if (isNoCenterEffective(eff))
383
+ noteHandoff({ noneApplied: true });
384
+ else
385
+ noteHandoff({ applied: eff.version });
386
+ const landed = tier.committed(candidateIdentityOf(eff));
387
+ if (landed !== undefined)
388
+ announceTier(landed);
359
389
  };
360
390
  let lkgBooted = false;
361
391
  let bootLkgCandidate;
@@ -480,7 +510,7 @@ export async function createWebAdminRuntime(ctx) {
480
510
  const lkgIdentity = candidateIdentityOf(lkgR.effective);
481
511
  if (lkgSurvivesRestart && lkgIdentity !== undefined)
482
512
  noteHandoff({ durable: { version: lkgR.effective.version, identity: lkgIdentity } });
483
- markApplied(lkgGen, lkgR.effective.version);
513
+ markApplied(lkgGen, lkgR.effective);
484
514
  await adoptCenterPrompts(lkgR.effective, lkgR.prompts, "boot-lkg");
485
515
  const lkgPlane = modelPlaneCommitted(lkgReport);
486
516
  if (lkgPlane)
@@ -585,7 +615,7 @@ export async function createWebAdminRuntime(ctx) {
585
615
  recordApply(rep);
586
616
  },
587
617
  });
588
- markApplied(bootGen, r.effective.version);
618
+ markApplied(bootGen, r.effective);
589
619
  const bootClean = fullyLandedForLkg(r, bootReport);
590
620
  if (bootClean)
591
621
  ccEtag = r.etag;
@@ -622,11 +652,13 @@ export async function createWebAdminRuntime(ctx) {
622
652
  }
623
653
  }
624
654
  catch (err) {
655
+ if (err instanceof ConfigDirUntrustedError)
656
+ throw err;
625
657
  if (bootApplyPhase)
626
658
  logger.warn("config_apply_refused", { source: configProvider.kind, err: String(err), note: "the pulled candidate failed to apply at boot — falling back to the LKG / env; this is not a reachability failure" });
627
659
  else
628
660
  logger.warn("config_source_unreachable_using_env", { source: configProvider.kind, err: String(err) });
629
- await bootFallBackWhole(`${bootApplyPhase ? "boot apply refused" : "boot fetch failed"}: ${String(err).slice(0, 120)}`);
661
+ await bootFallBackWhole(`${bootApplyPhase ? "boot apply refused" : "boot fetch failed"}: ${echoCallerText(String(err), { maxChars: 120 })}`);
630
662
  }
631
663
  if (!dryRun && cc !== undefined && currentIdentity() !== promptStateIdentity)
632
664
  await rebasePromptState(currentIdentity(), "boot-end");
@@ -669,6 +701,7 @@ export async function createWebAdminRuntime(ctx) {
669
701
  announceReadDenyRows(config, logger);
670
702
  };
671
703
  let ccTimer;
704
+ let unwatchCredential;
672
705
  return {
673
706
  providerKind: configProvider?.kind,
674
707
  sealedKeyPublic: sealedKeys === undefined ? undefined : buildSealedKeyPublicFace(sealedKeys),
@@ -707,6 +740,7 @@ export async function createWebAdminRuntime(ctx) {
707
740
  const pluginOut = await applyCenterPlugins(skills, effective, {
708
741
  cacheRoot: join(config.localDataRoot ?? join(homedir(), ".ai-agent"), "plugin-cache"),
709
742
  allowHosts: config.pluginsAllowHosts,
743
+ toolsShareThisFilesystem: toolsRunOnThisHost(config),
710
744
  logger,
711
745
  }).catch((err) => {
712
746
  logger.warn("center_plugins_apply_failed", { error: err instanceof Error ? err.message : String(err) });
@@ -839,6 +873,69 @@ export async function createWebAdminRuntime(ctx) {
839
873
  if (configProvider) {
840
874
  const ccRef = config.webAdmin;
841
875
  let refreshInFlight = false;
876
+ let followUp = false;
877
+ let ownRead = false;
878
+ const commitHot = async (c) => {
879
+ const { eff, prompts, gen, phase } = c;
880
+ const noCenter = isNoCenterEffective(eff);
881
+ const planeChanged = noCenter || modelPlaneChanged(appliedPlaneEff, eff);
882
+ let report;
883
+ const committed = applyEffective(config, eff, logger, {
884
+ leg: "hot",
885
+ checkpointStorePresent,
886
+ sealedKeys,
887
+ generation: gen,
888
+ report: (rep) => {
889
+ report = rep;
890
+ recordApply(rep);
891
+ },
892
+ ...(planeChanged ? { swapPlane: swapRunnerDeps } : {}),
893
+ });
894
+ if (!committed)
895
+ return { committed: false, report, planeCommitted: false };
896
+ mutateInPlace(pricing, buildPricing(config.models));
897
+ keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
898
+ limitSync?.sync();
899
+ ceilingVerdict?.judge();
900
+ if (phase !== "boot-deferred")
901
+ mcpRevocations.applyEnabledEntries(enabledMcpEntries(eff.mcp));
902
+ applyLiveReadFace(eff, swapRunnerDeps, phase);
903
+ markApplied(gen, eff);
904
+ const planeCommitted = modelPlaneCommitted(report);
905
+ if (planeCommitted)
906
+ appliedPlaneEff = noCenter ? undefined : eff;
907
+ planeDeferredNoHandoff = undefined;
908
+ await adoptCenterPrompts(eff, prompts, phase);
909
+ if (planeCommitted)
910
+ markRosterLanded(eff);
911
+ if (tier.drifted(currentIdentity()))
912
+ requestTick();
913
+ return { committed: true, report, planeCommitted };
914
+ };
915
+ const demoteToNoCenter = async (awaiting) => {
916
+ const gen = reserveArrivalGeneration();
917
+ applyLedger.seenTarget(gen, NO_CENTER_EFFECTIVE.version);
918
+ const hot = await commitHot({ eff: NO_CENTER_EFFECTIVE, prompts: undefined, gen, phase: "no-center" });
919
+ if (!hot.committed) {
920
+ throw new Error("the no-center tier was refused (the Runners did not accept the env model table) — the previous account's center configuration is still in force; retried next tick");
921
+ }
922
+ if (hot.report !== undefined && !hot.report.fullyApplied) {
923
+ logger.warn("center_identity_demotion_partial", { groups: refusedGroups(hot.report).map((g) => g.group), note: "a group of the no-center tier was refused — that group keeps its previous values (loud; the env base for that group could not be applied)" });
924
+ }
925
+ noteCandidateVerdict(gen, undefined);
926
+ latestEffective = undefined;
927
+ ccEtag = undefined;
928
+ announceTier(tier.demote(awaiting, hot.report !== undefined ? refusedGroups(hot.report).map((g) => g.group) : []));
929
+ };
930
+ const reconcileCenterIdentity = async (identity) => {
931
+ if (identity === undefined || !tier.drifted(identity))
932
+ return;
933
+ if (tier.isDemoted()) {
934
+ tier.retarget(identity);
935
+ return;
936
+ }
937
+ await demoteToNoCenter(identity);
938
+ };
842
939
  const refreshTick = async (arrival) => {
843
940
  if (refreshInFlight)
844
941
  return "ok";
@@ -850,6 +947,15 @@ export async function createWebAdminRuntime(ctx) {
850
947
  const refreshTickRan = async (arrival) => {
851
948
  refreshInFlight = true;
852
949
  try {
950
+ let ownIdentity;
951
+ ownRead = true;
952
+ try {
953
+ ownIdentity = currentIdentity();
954
+ }
955
+ finally {
956
+ ownRead = false;
957
+ }
958
+ await reconcileCenterIdentity(ownIdentity);
853
959
  await retryPendingCatalog("refresh-retry");
854
960
  if (planeDeferredNoHandoff) {
855
961
  metrics.inc("models_tiers_plane_deferred_stuck_total");
@@ -875,6 +981,7 @@ export async function createWebAdminRuntime(ctx) {
875
981
  }
876
982
  }
877
983
  if (r) {
984
+ await reconcileCenterIdentity(candidateIdentityOf(r.effective));
878
985
  const tickGen = arrival !== undefined ? useArrivalGeneration(r.effective.version, arrival.ordinal) : generationOf(r.effective.version);
879
986
  applyLedger.seenTarget(tickGen, r.effective.version);
880
987
  const verdict = judgeConfigCandidate(r);
@@ -889,35 +996,10 @@ export async function createWebAdminRuntime(ctx) {
889
996
  ccEtag = r.etag;
890
997
  }
891
998
  else {
892
- const planeChanged = modelPlaneChanged(appliedPlaneEff, r.effective);
893
- let applyReport;
894
- const committed = applyEffective(config, r.effective, logger, {
895
- leg: "hot",
896
- checkpointStorePresent,
897
- sealedKeys,
898
- generation: tickGen,
899
- report: (rep) => {
900
- applyReport = rep;
901
- recordApply(rep);
902
- },
903
- ...(planeChanged ? { swapPlane: swapRunnerDeps } : {}),
904
- });
905
- if (!committed)
999
+ const hot = await commitHot({ eff: r.effective, prompts: verdict.prompts, gen: tickGen, phase: "refresh" });
1000
+ if (!hot.committed)
906
1001
  return "ok";
907
- mutateInPlace(pricing, buildPricing(config.models));
908
- keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
909
- limitSync?.sync();
910
- ceilingVerdict?.judge();
911
- mcpRevocations.applyEnabledEntries(enabledMcpEntries(r.effective.mcp));
912
- applyLiveReadFace(r.effective, swapRunnerDeps, "refresh");
913
- markApplied(tickGen, r.effective.version);
914
- const tickPlane = modelPlaneCommitted(applyReport);
915
- if (tickPlane)
916
- appliedPlaneEff = r.effective;
917
- planeDeferredNoHandoff = undefined;
918
- await adoptCenterPrompts(r.effective, verdict.prompts, "refresh");
919
- if (tickPlane)
920
- markRosterLanded(r.effective);
1002
+ const applyReport = hot.report;
921
1003
  if (!fullyLandedForLkg(r, applyReport)) {
922
1004
  ccEtag = undefined;
923
1005
  const refused = applyReport ? refusedGroups(applyReport) : [];
@@ -962,13 +1044,39 @@ export async function createWebAdminRuntime(ctx) {
962
1044
  return inFlight;
963
1045
  const p = refreshTick(arrival).finally(() => {
964
1046
  inFlight = undefined;
1047
+ afterLane();
965
1048
  });
966
1049
  inFlight = p;
967
1050
  return p;
968
1051
  };
1052
+ const requestTick = () => {
1053
+ if (ccTimer === undefined || ownRead)
1054
+ return;
1055
+ if (inFlight !== undefined || refreshInFlight) {
1056
+ followUp = true;
1057
+ return;
1058
+ }
1059
+ queueMicrotask(() => void runTick());
1060
+ };
1061
+ const afterLane = () => {
1062
+ if (!followUp)
1063
+ return;
1064
+ followUp = false;
1065
+ if (tier.drifted(currentIdentity()))
1066
+ requestTick();
1067
+ };
1068
+ unwatchCredential =
1069
+ ccRef !== undefined && !ccRef.dryRun && configProvider.kind === "remote"
1070
+ ? ccRef.credential.onRead((read) => {
1071
+ if (tier.drifted(read.identity))
1072
+ requestTick();
1073
+ })
1074
+ : undefined;
969
1075
  manualRefresh = runTick;
970
1076
  ccTimer = setInterval(() => void runTick(), 60_000);
971
1077
  ccTimer.unref?.();
1078
+ if (tier.drifted(currentIdentity()))
1079
+ requestTick();
972
1080
  const deferredBootApply = async (r, arrivalGen) => {
973
1081
  if (!r)
974
1082
  return;
@@ -985,6 +1093,7 @@ export async function createWebAdminRuntime(ctx) {
985
1093
  }
986
1094
  finally {
987
1095
  refreshInFlight = false;
1096
+ afterLane();
988
1097
  }
989
1098
  };
990
1099
  const deferredBootApplyInner = async (r, lateGen) => {
@@ -1001,34 +1110,10 @@ export async function createWebAdminRuntime(ctx) {
1001
1110
  ccEtag = r.etag;
1002
1111
  return;
1003
1112
  }
1004
- const planeChangedLate = modelPlaneChanged(appliedPlaneEff, r.effective);
1005
- let applyReportLate;
1006
- const committedLate = applyEffective(config, r.effective, logger, {
1007
- leg: "hot",
1008
- checkpointStorePresent,
1009
- sealedKeys,
1010
- generation: lateGen,
1011
- report: (rep) => {
1012
- applyReportLate = rep;
1013
- recordApply(rep);
1014
- },
1015
- ...(planeChangedLate ? { swapPlane: swapRunnerDeps } : {}),
1016
- });
1017
- if (!committedLate)
1113
+ const hotLate = await commitHot({ eff: r.effective, prompts: lateVerdict.prompts, gen: lateGen, phase: "boot-deferred" });
1114
+ if (!hotLate.committed)
1018
1115
  return;
1019
- mutateInPlace(pricing, buildPricing(config.models));
1020
- keyResolver = createKeyResolver(config.modelApiKeyEnv, process.env, config.modelApiKeys);
1021
- limitSync?.sync();
1022
- ceilingVerdict?.judge();
1023
- applyLiveReadFace(r.effective, swapRunnerDeps, "boot-deferred");
1024
- markApplied(lateGen, r.effective.version);
1025
- const latePlane = modelPlaneCommitted(applyReportLate);
1026
- if (latePlane)
1027
- appliedPlaneEff = r.effective;
1028
- planeDeferredNoHandoff = undefined;
1029
- await adoptCenterPrompts(r.effective, lateVerdict.prompts, "boot-deferred");
1030
- if (latePlane)
1031
- markRosterLanded(r.effective);
1116
+ const applyReportLate = hotLate.report;
1032
1117
  if (!fullyLandedForLkg(r, applyReportLate)) {
1033
1118
  ccEtag = undefined;
1034
1119
  const refusedLate = applyReportLate ? refusedGroups(applyReportLate) : [];
@@ -1069,10 +1154,13 @@ export async function createWebAdminRuntime(ctx) {
1069
1154
  ccTimer = undefined;
1070
1155
  }
1071
1156
  credentialRenewer?.stop();
1157
+ unwatchCredential?.();
1158
+ unwatchCredential = undefined;
1072
1159
  },
1073
1160
  centerCredentialState() {
1074
1161
  return cc === undefined ? undefined : buildCenterCredentialHealthView(cc.credential.health(), credentialRenewer);
1075
1162
  },
1163
+ centerIdentityNoticeState: () => tier.notice(),
1076
1164
  };
1077
1165
  }
1078
1166
  //# sourceMappingURL=web-admin.js.map
@@ -15,6 +15,7 @@ import { type WorkflowRun, type WorkflowRunStore } from "@sema-agent/core";
15
15
  import type { ServiceConfig } from "../config.js";
16
16
  import { FleetEventBus } from "../fleet/fleet-bus.js";
17
17
  import { type WorkflowAgentSessionIndex } from "../orchestration/workflow-agent-session-index.js";
18
+ import type { WorkflowParkDecisionStore } from "../orchestration/workflow-park-decision.js";
18
19
  import type { Logger } from "../observability/logger.js";
19
20
  import type { Metrics } from "../observability/metrics.js";
20
21
  import { type WorkflowCompletionInbox } from "../orchestration/workflow-completion-inbox.js";
@@ -49,5 +50,6 @@ export declare function createWorkflowOrchestration(ctx: WorkflowOrchestrationCt
49
50
  publishTerminalFleetRow?: (id: string, run: WorkflowRun) => void;
50
51
  };
51
52
  workflowAgentSessionIndex: WorkflowAgentSessionIndex | undefined;
53
+ workflowParkDecisions: WorkflowParkDecisionStore | undefined;
52
54
  };
53
55
  //# sourceMappingURL=workflow-orchestration.d.ts.map
@@ -66,6 +66,7 @@ export function createWorkflowOrchestration(ctx) {
66
66
  ? backend.workflowAgentSessionIndex()
67
67
  : new LocalWorkflowAgentSessionIndex(join(config.localDataRoot ?? localRoot, "workflows"), undefined))
68
68
  : undefined;
69
+ const workflowParkDecisions = config.selfOrchestrationEnabled && backend !== undefined && (sqlWorkflowRunStore !== undefined || backend.kind === "local") ? backend.workflowParkDecisions?.() : undefined;
69
70
  const workflowRunStore = baseWorkflowRunStore
70
71
  ? new JournalingWorkflowRunStore(baseWorkflowRunStore, workflowNotifyGate, fleetBus, workflowAgentSessionIndex)
71
72
  : undefined;
@@ -82,7 +83,7 @@ export function createWorkflowOrchestration(ctx) {
82
83
  return {
83
84
  sqlWorkflowRunStore, workflowNotifyJournal, workflowCompletionInbox, deliverWorkflowCompletion,
84
85
  workflowNotifyGate, fleetBus, workflowRunStore, workflowJournalStore, outcomeSink,
85
- workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex,
86
+ workflowAgentRegistry, subagentSteerRegistry, workflowRecoverOpts, workflowAgentSessionIndex, workflowParkDecisions,
86
87
  };
87
88
  }
88
89
  //# sourceMappingURL=workflow-orchestration.js.map
package/dist/brain.js CHANGED
@@ -9,6 +9,7 @@ import { openaiRouteBaseUrl } from "./model-route-endpoint.js";
9
9
  import { catalogEntryFingerprint } from "./web-admin-client/restart-signal.js";
10
10
  import { buildDisplaySafeRefusal, buildDisplaySafeUrl } from "./trace/redact.js";
11
11
  import { createModelReachBrain } from "./model-unreachable-notice.js";
12
+ import { breakerKeyOf, routeDigestOf } from "./breaker-key.js";
12
13
  function isOffDeploymentRoot(baseUrl, config) {
13
14
  if (!baseUrl)
14
15
  return false;
@@ -20,6 +21,9 @@ function isOffDeploymentRoot(baseUrl, config) {
20
21
  function deploymentGatewayRoots(config) {
21
22
  return config.gatewayBaseUrl !== undefined ? [config.gatewayBaseUrl, ...config.gatewayFallbackUrls] : [];
22
23
  }
24
+ function breakerRoutesOf(config, r) {
25
+ return r.circuitBreaker ? deploymentGatewayRoots(config).slice(0, -1) : [];
26
+ }
23
27
  function deploymentGatewayKey(config) {
24
28
  return config.gatewayBaseUrl !== undefined ? config.gatewayApiKey : undefined;
25
29
  }
@@ -53,6 +57,7 @@ export function createBrainAssembly(config, deps = {}) {
53
57
  ? { maxRetries: FAST_FAIL_MAX_RETRIES }
54
58
  : {};
55
59
  const routes = deploymentGatewayRoots(config);
60
+ const breakerRoutes = breakerRoutesOf(config, r);
56
61
  const openaiBrains = routes.map((baseUrl, i) => {
57
62
  const gatewayKey = deploymentGatewayKey(config);
58
63
  const brain = constructRouteBrain(i === 0 ? "gateway route" : `gateway fallback route[${i - 1}]`, [baseUrl], () => createOpenAIBrain({
@@ -62,13 +67,12 @@ export function createBrainAssembly(config, deps = {}) {
62
67
  fetchImpl,
63
68
  ...timeouts,
64
69
  }));
65
- const isLast = i === routes.length - 1;
66
- return r.circuitBreaker && !isLast
70
+ return i < breakerRoutes.length
67
71
  ? createCircuitBreakerBrain(brain, {
68
72
  failureThreshold: r.failureThreshold,
69
73
  cooldownMs: r.cooldownMs,
70
74
  state: breakerState,
71
- key: (m) => `${m.provider ?? "openai"}:${m.id}@${baseUrl}`,
75
+ key: (m) => breakerKeyOf(m, baseUrl),
72
76
  })
73
77
  : brain;
74
78
  });
@@ -206,6 +210,7 @@ export function brainSummary(config) {
206
210
  idleTimeoutMs: r.idleTimeoutMs,
207
211
  circuitBreaker: breakerActive,
208
212
  circuitBreakerRequested: r.circuitBreaker,
213
+ circuitBreakerRoutes: breakerRoutesOf(config, r).map((u) => ({ route: buildDisplaySafeUrl(u), digest: routeDigestOf(u) })),
209
214
  gatewayRetryCap: config.gatewayMaxRetries !== undefined
210
215
  ? `env:${config.gatewayMaxRetries}`
211
216
  : hasFailover || r.circuitBreaker || config.degrade?.reactive
@@ -0,0 +1,6 @@
1
+ import { type Model } from "@sema-agent/core";
2
+ /** 一条路由的身份摘要(键的路由段;启动日志把它与该路由的展示串并排印出,运维据此把错误文本 / 表行对回路由)。 */
3
+ export declare function routeDigestOf(baseUrl: string): string;
4
+ /** 断路器键:`<头段>@<路由摘要>`,头段 = `<provider>:<model id>`(放不下列宽预算时见 {@link boundedHead})。provider 缺席按 `openai`(与 core 默认键同一个前半)。恒 ≤ 190 字节。 */
5
+ export declare function breakerKeyOf(model: Pick<Model, "provider" | "id">, baseUrl: string): string;
6
+ //# sourceMappingURL=breaker-key.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { createHash } from "node:crypto";
2
+ import { routeKeyOf } from "@sema-agent/core";
3
+ const ROUTE_DIGEST_HEX = 24;
4
+ const BREAKER_KEY_MAX_BYTES = 190;
5
+ const HEAD_MAX_BYTES = BREAKER_KEY_MAX_BYTES - 1 - ROUTE_DIGEST_HEX;
6
+ const HEAD_DIGEST_HEX = 16;
7
+ const sha256Hex = (text) => createHash("sha256").update(text, "utf8").digest("hex");
8
+ export function routeDigestOf(baseUrl) {
9
+ return sha256Hex(routeKeyOf(baseUrl)).slice(0, ROUTE_DIGEST_HEX);
10
+ }
11
+ export function breakerKeyOf(model, baseUrl) {
12
+ return `${boundedHead(`${model.provider ?? "openai"}:${model.id}`)}@${routeDigestOf(baseUrl)}`;
13
+ }
14
+ function boundedHead(head) {
15
+ if (Buffer.byteLength(head, "utf8") <= HEAD_MAX_BYTES)
16
+ return head;
17
+ const tail = `~${sha256Hex(head).slice(0, HEAD_DIGEST_HEX)}`;
18
+ let prefix = "";
19
+ let used = 0;
20
+ for (const ch of head) {
21
+ const n = Buffer.byteLength(ch, "utf8");
22
+ if (used + n > HEAD_MAX_BYTES - tail.length)
23
+ break;
24
+ prefix += ch;
25
+ used += n;
26
+ }
27
+ return `${prefix}${tail}`;
28
+ }
29
+ //# sourceMappingURL=breaker-key.js.map
@@ -10,11 +10,14 @@ export declare function echoCallerText(text: string, opts?: EchoCallerTextOption
10
10
  /** 句子里点名一个值的写法:{@link echoCallerText} 外加一对双引号。 */
11
11
  export declare function quotedCallerText(text: string): string;
12
12
  /**
13
- * 一个**判不过**的申报名(MCP server / A2A 对端的 `name`)在拒句 / 告警元数据里的回显:非串只说种类、空串说 `empty`,否则按本口径的引号形
14
- * 外加送来的原长度(运维要的是「我那个名字长了多少」,不是一屏乱码)。判据本身不在这里:「能不能用」只有契约包的 `isUsableWireName` 一只
15
- * (请求腿 / 声明腿同读),本函数只管回显 —— 回显清洗是消费方按自己的腿定的(契约包的判官模块头注同此分工)。
13
+ * 数据截断(**不是**回显):前 `max` 字 + `…(总长)`;不超则原样。给喂回模型 / 交给 hook 的**数据**用 —— 读的一方(模型、hook 作者)看得出被截、截掉多少。
14
+ * 不剥控制与双向字符:数据要原样(exit 2 的多行 stderr 保行)。写进日志字段 / 回到人面前的串**不用**它,用 {@link echoCallerText}。
16
15
  */
17
- export declare function describeBadWireName(v: unknown): string;
18
- /** 一个词表外的 `contentOrigin` 值在拒句 / 告警元数据里的回显:串 ⇒ 本口径的引号形;非串 ⇒ 只说种类。判据是契约包的 `isContentOriginWord`(不在这里)。 */
19
- export declare function describeBadContentOrigin(v: unknown): string;
16
+ export declare function clipDataText(s: string, max: number): string;
17
+ /**
18
+ * 硬帽:前 `max` 字,什么也不加;不超则原样,缺席(`undefined`)透传。给带 schema `.max()` 的 wire 字段用(审批卡:整只 ask 不能因为一个 200 KB 的字段落不了库)——
19
+ * 截断记号会让串超过 schema 的上限,所以这里没有记号;也不剥控制与双向字符(卡上的串是要被人审的那一串,清洗会让「看到的」与「将执行的」不是同一个东西)。
20
+ */
21
+ export declare function capText(s: string, max: number): string;
22
+ export declare function capText(s: string | undefined, max: number): string | undefined;
20
23
  //# sourceMappingURL=caller-text-echo.d.ts.map