@sema-agent/server 7.147.0 → 7.148.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 (725) hide show
  1. package/MIGRATION.md +1039 -24
  2. package/README.md +20 -7
  3. package/README.zh-CN.md +14 -8
  4. package/USAGE.md +380 -163
  5. package/deploy/sema-up/README.md +16 -5
  6. package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
  7. package/deploy/sema-up/chart/templates/_helpers.tpl +20 -4
  8. package/deploy/sema-up/chart/values.yaml +3 -2
  9. package/deploy/sema-up/cluster-up.sh +74 -176
  10. package/deploy/sema-up/kube-up.sh +29 -49
  11. package/deploy/sema-up/lib/chart-run.sh +23 -0
  12. package/deploy/sema-up/lib/dataroot.sh +3 -3
  13. package/deploy/sema-up/lib/health.sh +62 -13
  14. package/deploy/sema-up/lib/helm-values-cluster.py +18 -0
  15. package/deploy/sema-up/lib/helm-values-kube.py +35 -0
  16. package/deploy/sema-up/lib/regcred.py +8 -0
  17. package/deploy/sema-up/lib/remote/helm-install.sh +3 -0
  18. package/deploy/sema-up/lib/remote/image-import.sh +6 -0
  19. package/deploy/sema-up/lib/remote/machine-precheck.sh +11 -0
  20. package/deploy/sema-up/lib/remote/region-probe.sh +3 -0
  21. package/deploy/sema-up/lib/remote/stack-ready.sh +26 -0
  22. package/deploy/sema-up/lib/remote/vxlan-guard.sh +8 -0
  23. package/deploy/sema-up/lib/render-stack.py +17 -0
  24. package/deploy/sema-up/lib/shell-text.sh +87 -0
  25. package/deploy/sema-up/lib/usage-flags.txt +10 -0
  26. package/deploy/sema-up/lib/usage-head.txt +1 -0
  27. package/deploy/sema-up/lib/usage-tail.txt +13 -0
  28. package/deploy/sema-up/preflight.sh +10 -8
  29. package/deploy/sema-up/sema-up.sh +14 -39
  30. package/deploy/sema-up/smoke.sh +7 -6
  31. package/deploy/sema-up/stack/compose.dataroot.yaml +3 -0
  32. package/deploy/sema-up/stack/compose.yaml +13 -1
  33. package/deploy/sema-up/stack/sema-stack-cluster.yaml +21 -0
  34. package/dist/adoption/plan.d.ts +24 -0
  35. package/dist/adoption/plan.js +53 -1
  36. package/dist/adoption/runner.d.ts +10 -1
  37. package/dist/adoption/runner.js +36 -16
  38. package/dist/adoption/wire.d.ts +3 -3
  39. package/dist/approval-card.d.ts +28 -30
  40. package/dist/approval-gate-currency.js +3 -2
  41. package/dist/approval-reconciler.d.ts +4 -13
  42. package/dist/approval-reconciler.js +2 -2
  43. package/dist/approval.d.ts +13 -11
  44. package/dist/approval.js +3 -3
  45. package/dist/audit.d.ts +10 -3
  46. package/dist/audit.js +15 -7
  47. package/dist/auth-bridge.d.ts +0 -14
  48. package/dist/auth-bridge.js +0 -7
  49. package/dist/auto-mode-face.d.ts +10 -7
  50. package/dist/auto-mode-face.js +7 -4
  51. package/dist/background-agent-name.d.ts +19 -1
  52. package/dist/background-agent-name.js +12 -2
  53. package/dist/background-session-reap.d.ts +1 -1
  54. package/dist/bake-runner/main.js +9 -6
  55. package/dist/bench/s1/arms.js +6 -5
  56. package/dist/bench/s1/live-deps.js +5 -2
  57. package/dist/bench/s1/run-firm.js +6 -5
  58. package/dist/bind-host.d.ts +25 -0
  59. package/dist/bind-host.js +25 -0
  60. package/dist/boot/adoption.d.ts +3 -0
  61. package/dist/boot/adoption.js +1 -0
  62. package/dist/boot/deployment-mods.d.ts +1 -1
  63. package/dist/boot/execution-env.d.ts +17 -7
  64. package/dist/boot/execution-env.js +37 -31
  65. package/dist/boot/exit-boundary.d.ts +2 -2
  66. package/dist/boot/exit-boundary.js +6 -5
  67. package/dist/boot/fatal-exit.d.ts +3 -5
  68. package/dist/boot/fatal-exit.js +2 -2
  69. package/dist/boot/leader.d.ts +15 -0
  70. package/dist/boot/leader.js +17 -15
  71. package/dist/boot/memory-consolidation.d.ts +37 -29
  72. package/dist/boot/memory-consolidation.js +11 -5
  73. package/dist/boot/org-memory.js +1 -1
  74. package/dist/boot/parked-revive-gate.js +2 -2
  75. package/dist/boot/reapers.d.ts +4 -3
  76. package/dist/boot/reapers.js +19 -16
  77. package/dist/boot/resolve-spec.d.ts +5 -3
  78. package/dist/boot/resolve-spec.js +55 -67
  79. package/dist/boot/retention-lane.d.ts +4 -4
  80. package/dist/boot/retention-lane.js +2 -2
  81. package/dist/boot/runner-deps.d.ts +28 -7
  82. package/dist/boot/runner-deps.js +11 -4
  83. package/dist/boot/runtime-caps.d.ts +2 -2
  84. package/dist/boot/runtime-caps.js +16 -2
  85. package/dist/boot/session-faces.d.ts +16 -7
  86. package/dist/boot/session-faces.js +114 -94
  87. package/dist/boot/shutdown.d.ts +5 -4
  88. package/dist/boot/shutdown.js +6 -4
  89. package/dist/boot/stage-01-config.js +9 -1
  90. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -0
  91. package/dist/boot/stage-02-web-admin-pull.js +6 -1
  92. package/dist/boot/stage-03-store-backend.d.ts +3 -0
  93. package/dist/boot/stage-03-store-backend.js +4 -3
  94. package/dist/boot/stage-04-stores.d.ts +2 -0
  95. package/dist/boot/stage-04-stores.js +2 -2
  96. package/dist/boot/stage-05-execution-env.d.ts +7 -3
  97. package/dist/boot/stage-05-execution-env.js +2 -2
  98. package/dist/boot/stage-06-runners.d.ts +10 -12
  99. package/dist/boot/stage-06-runners.js +23 -15
  100. package/dist/boot/stage-07-capability-layer.d.ts +11 -8
  101. package/dist/boot/stage-07-capability-layer.js +5 -3
  102. package/dist/boot/stage-08-reapers.d.ts +11 -8
  103. package/dist/boot/stage-08-reapers.js +3 -3
  104. package/dist/boot/stage-09-leader.d.ts +12 -15
  105. package/dist/boot/stage-09-leader.js +12 -4
  106. package/dist/boot/stage-10-http-server.d.ts +12 -15
  107. package/dist/boot/stage-10-http-server.js +7 -4
  108. package/dist/boot/store-evidence.d.ts +20 -0
  109. package/dist/boot/store-evidence.js +13 -0
  110. package/dist/boot/stores.d.ts +3 -0
  111. package/dist/boot/stores.js +21 -10
  112. package/dist/boot/task-list-lane.d.ts +4 -4
  113. package/dist/boot/web-admin.d.ts +4 -2
  114. package/dist/boot/web-admin.js +55 -35
  115. package/dist/boot/webfetch-summarize-lane.d.ts +1 -1
  116. package/dist/boot-reclaim.d.ts +3 -1
  117. package/dist/boot-reclaim.js +1 -1
  118. package/dist/brain.d.ts +7 -18
  119. package/dist/brain.js +5 -17
  120. package/dist/budget.js +6 -6
  121. package/dist/capabilities/center-plugins.d.ts +7 -1
  122. package/dist/capabilities/center-plugins.js +32 -10
  123. package/dist/capabilities/center-wiring.js +1 -1
  124. package/dist/capabilities/composite-members.d.ts +2 -2
  125. package/dist/capabilities/composite-members.js +2 -2
  126. package/dist/capabilities/repo-tools.d.ts +2 -0
  127. package/dist/capabilities/repo-tools.js +14 -12
  128. package/dist/capabilities/scenarios.d.ts +6 -15
  129. package/dist/capabilities/scenarios.js +11 -16
  130. package/dist/capabilities/skills.d.ts +1 -1
  131. package/dist/capabilities/tool-defer.d.ts +1 -1
  132. package/dist/capability-facts.d.ts +38 -11
  133. package/dist/capability-facts.js +47 -8
  134. package/dist/card-void.d.ts +4 -4
  135. package/dist/card-void.js +1 -1
  136. package/dist/center-credential-renewer.d.ts +6 -2
  137. package/dist/center-credential-renewer.js +7 -3
  138. package/dist/config-catalog.d.ts +16 -1
  139. package/dist/config-catalog.js +62 -56
  140. package/dist/config-dir-trust.d.ts +37 -4
  141. package/dist/config-dir-trust.js +88 -44
  142. package/dist/config-invariants.d.ts +42 -3
  143. package/dist/config-invariants.js +69 -5
  144. package/dist/config-lkg.d.ts +23 -1
  145. package/dist/config-lkg.js +17 -3
  146. package/dist/config-provider.d.ts +9 -9
  147. package/dist/config-provider.js +25 -110
  148. package/dist/config-pull-failure.d.ts +50 -0
  149. package/dist/config-pull-failure.js +48 -0
  150. package/dist/config-types.d.ts +26 -17
  151. package/dist/config.d.ts +8 -16
  152. package/dist/config.js +113 -47
  153. package/dist/delegated-session-owner.d.ts +1 -1
  154. package/dist/deleted-session-ids.d.ts +3 -2
  155. package/dist/deployment-governance.d.ts +3 -3
  156. package/dist/deployment-shape.d.ts +30 -4
  157. package/dist/deployment-shape.js +7 -0
  158. package/dist/egress-redirect.d.ts +25 -7
  159. package/dist/egress-redirect.js +20 -2
  160. package/dist/elicitation.d.ts +6 -5
  161. package/dist/elicitation.js +23 -22
  162. package/dist/engine-identity.d.ts +28 -0
  163. package/dist/engine-identity.js +10 -0
  164. package/dist/entry-problems.d.ts +5 -7
  165. package/dist/entry-problems.js +1 -1
  166. package/dist/env-facts.js +2 -1
  167. package/dist/env-witness.d.ts +7 -0
  168. package/dist/env-witness.js +16 -0
  169. package/dist/execution-lane-caps.d.ts +5 -18
  170. package/dist/execution-lane-caps.js +0 -22
  171. package/dist/execution-placement.d.ts +58 -18
  172. package/dist/execution-placement.js +41 -2
  173. package/dist/field-conflict.d.ts +7 -11
  174. package/dist/field-conflict.js +3 -3
  175. package/dist/file-history-capture.d.ts +3 -3
  176. package/dist/file-history-disclosure.js +1 -0
  177. package/dist/fleet/fleet-bus.d.ts +21 -3
  178. package/dist/fleet/fleet-bus.js +35 -25
  179. package/dist/fleet/fleet-reconciler.js +2 -2
  180. package/dist/fleet/serving-lease.js +3 -3
  181. package/dist/fleet-client.js +3 -3
  182. package/dist/fleet-lease.d.ts +0 -1
  183. package/dist/fleet-lease.js +4 -5
  184. package/dist/history-anchor.d.ts +23 -3
  185. package/dist/history-anchor.js +24 -4
  186. package/dist/hitl-delivery.d.ts +90 -0
  187. package/dist/hitl-delivery.js +98 -0
  188. package/dist/hooks/classic-stations.d.ts +8 -11
  189. package/dist/hooks/classic-stations.js +0 -7
  190. package/dist/hooks/hook-llm.d.ts +5 -1
  191. package/dist/hooks/hook-llm.js +24 -15
  192. package/dist/hooks/hook-runner.d.ts +67 -57
  193. package/dist/hooks/hook-runner.js +260 -186
  194. package/dist/host-lsp-manager.d.ts +22 -8
  195. package/dist/host-lsp-manager.js +4 -1
  196. package/dist/http/active-run-conflict.d.ts +2 -43
  197. package/dist/http/active-run-conflict.js +3 -7
  198. package/dist/http/admission.d.ts +4 -18
  199. package/dist/http/admission.js +75 -78
  200. package/dist/http/approval-sweeps.d.ts +3 -3
  201. package/dist/http/approval-sweeps.js +54 -30
  202. package/dist/http/caller-trust.d.ts +8 -10
  203. package/dist/http/caller-trust.js +1 -2
  204. package/dist/http/claim-heartbeat.d.ts +49 -0
  205. package/dist/http/claim-heartbeat.js +46 -0
  206. package/dist/http/claimed-run.d.ts +4 -3
  207. package/dist/http/dispatch.d.ts +8 -1
  208. package/dist/http/dispatch.js +76 -30
  209. package/dist/http/durable-run-leg.d.ts +3 -3
  210. package/dist/http/durable-run-leg.js +17 -12
  211. package/dist/http/execution-context.d.ts +17 -43
  212. package/dist/http/execution-context.js +7 -5
  213. package/dist/http/health-reader.d.ts +36 -0
  214. package/dist/http/health-reader.js +21 -0
  215. package/dist/http/health-self-report.d.ts +9 -9
  216. package/dist/http/health-self-report.js +4 -4
  217. package/dist/http/idempotency.d.ts +9 -5
  218. package/dist/http/idempotency.js +4 -4
  219. package/dist/http/memory-compliance-failure-reply.d.ts +15 -16
  220. package/dist/http/memory-compliance-failure-reply.js +4 -2
  221. package/dist/http/memory-face-fault-reply.d.ts +67 -0
  222. package/dist/http/memory-face-fault-reply.js +71 -0
  223. package/dist/http/memory-store-refusal-reply.d.ts +1 -1
  224. package/dist/http/memory-store-refusal-reply.js +3 -0
  225. package/dist/http/owner-access.d.ts +391 -67
  226. package/dist/http/owner-access.js +371 -35
  227. package/dist/http/principal-gate.d.ts +24 -81
  228. package/dist/http/principal-gate.js +24 -68
  229. package/dist/http/refusal-body.d.ts +35 -2
  230. package/dist/http/refusal-body.js +34 -0
  231. package/dist/http/request-guards.d.ts +9 -13
  232. package/dist/http/request-guards.js +34 -68
  233. package/dist/http/resume-composition.d.ts +37 -0
  234. package/dist/http/resume-composition.js +18 -0
  235. package/dist/http/resume-ctx-read.d.ts +35 -12
  236. package/dist/http/resume-ctx-read.js +25 -6
  237. package/dist/http/resume-legs.d.ts +21 -18
  238. package/dist/http/resume-legs.js +189 -129
  239. package/dist/http/retired-skill-manifest.d.ts +1 -1
  240. package/dist/http/route-ctx.d.ts +25 -32
  241. package/dist/http/routes/a2a-serve.d.ts +43 -5
  242. package/dist/http/routes/a2a-serve.js +58 -37
  243. package/dist/http/routes/admin-config-refresh.js +2 -2
  244. package/dist/http/routes/admin-drain.js +2 -2
  245. package/dist/http/routes/admin-memory-optout.js +4 -3
  246. package/dist/http/routes/adoption.d.ts +3 -0
  247. package/dist/http/routes/adoption.js +17 -10
  248. package/dist/http/routes/agents-roster.js +13 -7
  249. package/dist/http/routes/approvals-assistant.js +70 -65
  250. package/dist/http/routes/attachments.js +2 -2
  251. package/dist/http/routes/background.d.ts +3 -3
  252. package/dist/http/routes/background.js +9 -17
  253. package/dist/http/routes/capabilities.js +15 -18
  254. package/dist/http/routes/config-catalog.js +2 -2
  255. package/dist/http/routes/devices.d.ts +3 -3
  256. package/dist/http/routes/devices.js +4 -4
  257. package/dist/http/routes/diagnostics.d.ts +27 -3
  258. package/dist/http/routes/diagnostics.js +27 -21
  259. package/dist/http/routes/engine.js +2 -2
  260. package/dist/http/routes/fleet.js +5 -3
  261. package/dist/http/routes/images.js +10 -6
  262. package/dist/http/routes/leader.d.ts +7 -2
  263. package/dist/http/routes/leader.js +12 -3
  264. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  265. package/dist/http/routes/mcp-reconnect.js +7 -15
  266. package/dist/http/routes/memory-bundle.js +4 -7
  267. package/dist/http/routes/memory-compliance.js +4 -4
  268. package/dist/http/routes/memory-consolidation.js +6 -9
  269. package/dist/http/routes/memory-origin.d.ts +2 -0
  270. package/dist/http/routes/memory-origin.js +7 -8
  271. package/dist/http/routes/memory-policy.js +17 -12
  272. package/dist/http/routes/notify-wake.js +10 -19
  273. package/dist/http/routes/observability.js +3 -3
  274. package/dist/http/routes/principal-inbox.d.ts +1 -1
  275. package/dist/http/routes/principal-inbox.js +2 -2
  276. package/dist/http/routes/projects.d.ts +1 -1
  277. package/dist/http/routes/projects.js +3 -2
  278. package/dist/http/routes/retention-ops.js +6 -9
  279. package/dist/http/routes/rules.js +20 -5
  280. package/dist/http/routes/run-memory-capture.d.ts +2 -2
  281. package/dist/http/routes/run-memory-capture.js +6 -12
  282. package/dist/http/routes/run-permission-mode.d.ts +2 -2
  283. package/dist/http/routes/run-permission-mode.js +10 -17
  284. package/dist/http/routes/runs.js +146 -231
  285. package/dist/http/routes/session-memory-sync.d.ts +2 -2
  286. package/dist/http/routes/session-memory-sync.js +7 -13
  287. package/dist/http/routes/session-sync.d.ts +4 -2
  288. package/dist/http/routes/session-sync.js +21 -20
  289. package/dist/http/routes/sessions-list.d.ts +3 -3
  290. package/dist/http/routes/sessions-list.js +9 -9
  291. package/dist/http/routes/sessions.js +87 -124
  292. package/dist/http/routes/shared-memory.js +6 -6
  293. package/dist/http/routes/side-query.js +2 -2
  294. package/dist/http/routes/tasks.js +136 -120
  295. package/dist/http/routes/trace-usage.d.ts +0 -12
  296. package/dist/http/routes/trace-usage.js +40 -46
  297. package/dist/http/routes/workflows.d.ts +39 -4
  298. package/dist/http/routes/workflows.js +42 -14
  299. package/dist/http/run-concurrency-cap.d.ts +20 -12
  300. package/dist/http/run-concurrency-cap.js +39 -26
  301. package/dist/http/run-read-face.d.ts +3 -5
  302. package/dist/http/run-read-face.js +8 -13
  303. package/dist/http/send.d.ts +12 -3
  304. package/dist/http/send.js +42 -6
  305. package/dist/http/server.d.ts +39 -40
  306. package/dist/http/server.js +36 -11
  307. package/dist/http/sse-log.d.ts +17 -10
  308. package/dist/http/sse-log.js +7 -7
  309. package/dist/http/stored-body-replay.d.ts +12 -0
  310. package/dist/http/stored-body-replay.js +2 -2
  311. package/dist/http/submit-ctx.d.ts +16 -8
  312. package/dist/http/submit-ctx.js +6 -2
  313. package/dist/http/submit-replay.d.ts +19 -6
  314. package/dist/http/submit-replay.js +18 -6
  315. package/dist/http/sync-submit-body.d.ts +3 -4
  316. package/dist/http/sync-submit-body.js +4 -5
  317. package/dist/http/wire-types.d.ts +4 -3
  318. package/dist/identity-source.d.ts +36 -5
  319. package/dist/identity-source.js +27 -0
  320. package/dist/index.d.ts +1 -0
  321. package/dist/index.js +1 -0
  322. package/dist/key-resolver.d.ts +32 -0
  323. package/dist/key-resolver.js +23 -9
  324. package/dist/leader/diffup.js +2 -1
  325. package/dist/leader/endpoint.d.ts +26 -5
  326. package/dist/leader/endpoint.js +154 -14
  327. package/dist/leader/fanout.d.ts +3 -0
  328. package/dist/leader/fanout.js +78 -63
  329. package/dist/leader/leader.d.ts +16 -0
  330. package/dist/leader/leader.js +43 -3
  331. package/dist/leader/merge.d.ts +9 -1
  332. package/dist/leader/merge.js +16 -1
  333. package/dist/leader/repair-wire.js +1 -1
  334. package/dist/leader/wire.d.ts +36 -3
  335. package/dist/leader/wire.js +59 -18
  336. package/dist/lsp-evict.d.ts +6 -4
  337. package/dist/lsp-evict.js +2 -3
  338. package/dist/memory-operator-faces.d.ts +5 -4
  339. package/dist/memory-operator-faces.js +1 -1
  340. package/dist/memory-scope.d.ts +29 -2
  341. package/dist/memory-scope.js +64 -15
  342. package/dist/memory-store-refusal.d.ts +5 -2
  343. package/dist/memory-sync-client.d.ts +3 -2
  344. package/dist/memory-sync-client.js +6 -3
  345. package/dist/model-compat.d.ts +17 -8
  346. package/dist/model-compat.js +6 -2
  347. package/dist/model-context-window.d.ts +18 -0
  348. package/dist/model-context-window.js +2 -0
  349. package/dist/model-entry-headers.d.ts +46 -4
  350. package/dist/model-entry-headers.js +2 -2
  351. package/dist/model-entry-refusal.d.ts +35 -16
  352. package/dist/model-entry-refusal.js +40 -27
  353. package/dist/model-plane-face.d.ts +19 -11
  354. package/dist/model-plane-face.js +9 -1
  355. package/dist/model-plane-probe.d.ts +2 -0
  356. package/dist/model-plane-probe.js +17 -0
  357. package/dist/model-provider.d.ts +3 -3
  358. package/dist/model-route-endpoint.d.ts +9 -5
  359. package/dist/model-route-endpoint.js +29 -7
  360. package/dist/model-select.d.ts +16 -0
  361. package/dist/model-select.js +4 -0
  362. package/dist/mountinfo.d.ts +37 -0
  363. package/dist/mountinfo.js +47 -0
  364. package/dist/namespaced-rule-name.d.ts +23 -14
  365. package/dist/namespaced-rule-name.js +8 -11
  366. package/dist/net-address.d.ts +1 -1
  367. package/dist/observability/corrupt-read-seat.d.ts +4 -4
  368. package/dist/observability/corrupt-read-seat.js +5 -3
  369. package/dist/observability/fail-open.d.ts +58 -38
  370. package/dist/observability/fail-open.js +60 -38
  371. package/dist/observability/logger.d.ts +22 -1
  372. package/dist/observability/logger.js +89 -12
  373. package/dist/observability/metrics.js +3 -4
  374. package/dist/observability/otel-exporter.js +2 -1
  375. package/dist/observability/principal-context.d.ts +14 -7
  376. package/dist/observability/principal-context.js +8 -3
  377. package/dist/observability/run-terminal.d.ts +7 -1
  378. package/dist/observability/run-terminal.js +5 -2
  379. package/dist/orchestration/hardened-vm-runner.d.ts +1 -0
  380. package/dist/orchestration/hardened-vm-runner.js +11 -5
  381. package/dist/orchestration/hardened-vm-worker-runner.d.ts +0 -14
  382. package/dist/orchestration/hardened-vm-worker-runner.js +5 -0
  383. package/dist/orchestration/hardened-vm-worker.js +2 -1
  384. package/dist/orchestration/workflow-completion-inbox.d.ts +3 -3
  385. package/dist/orchestration/workflow-completion-inbox.js +3 -2
  386. package/dist/org-delivery-gate.d.ts +5 -4
  387. package/dist/org-delivery-gate.js +7 -6
  388. package/dist/outbound-dispatcher.d.ts +1 -1
  389. package/dist/outbound-dispatcher.js +6 -12
  390. package/dist/owner-brands.d.ts +81 -0
  391. package/dist/owner-brands.js +42 -0
  392. package/dist/owner-faces.d.ts +531 -0
  393. package/dist/owner-faces.js +126 -0
  394. package/dist/parked-decide.d.ts +67 -5
  395. package/dist/parked-decide.js +127 -5
  396. package/dist/parked-revive-surface.d.ts +14 -4
  397. package/dist/parked-revive-surface.js +5 -4
  398. package/dist/peer-directory.d.ts +6 -8
  399. package/dist/peer-directory.js +3 -2
  400. package/dist/permission-rule-vocab.d.ts +53 -8
  401. package/dist/permission-rule-vocab.js +30 -2
  402. package/dist/plugins/adoption-log-sql.d.ts +0 -22
  403. package/dist/plugins/adoption-log-sql.js +5 -3
  404. package/dist/plugins/approval-ask-retired-delete-by-task-m50.d.ts +7 -0
  405. package/dist/plugins/approval-ask-retired-delete-by-task-m50.js +17 -0
  406. package/dist/plugins/approval-ask-store-file.d.ts +18 -7
  407. package/dist/plugins/approval-ask-store-file.js +37 -14
  408. package/dist/plugins/approval-ask-store-memory.d.ts +12 -4
  409. package/dist/plugins/approval-ask-store-memory.js +24 -10
  410. package/dist/plugins/approval-ask-store-sql.d.ts +39 -20
  411. package/dist/plugins/approval-ask-store-sql.js +41 -10
  412. package/dist/plugins/approval-exemption-skill-m46.d.ts +20 -0
  413. package/dist/plugins/approval-exemption-skill-m46.js +25 -0
  414. package/dist/plugins/approval-exemption-store.d.ts +6 -1
  415. package/dist/plugins/approval-exemption-store.js +14 -0
  416. package/dist/plugins/approval-nonce-store.d.ts +39 -12
  417. package/dist/plugins/approval-nonce-store.js +72 -23
  418. package/dist/plugins/blob-backend.d.ts +2 -0
  419. package/dist/plugins/blob-backend.js +9 -6
  420. package/dist/plugins/caching-session-store.d.ts +13 -1
  421. package/dist/plugins/caching-session-store.js +43 -4
  422. package/dist/plugins/checkpoint-index-columns.d.ts +32 -5
  423. package/dist/plugins/checkpoint-index-columns.js +36 -1
  424. package/dist/plugins/checkpoint-store-face.d.ts +83 -10
  425. package/dist/plugins/checkpoint-store-face.js +18 -1
  426. package/dist/plugins/device-store-sql.js +1 -0
  427. package/dist/plugins/ensure-index.d.ts +13 -1
  428. package/dist/plugins/ensure-index.js +154 -21
  429. package/dist/plugins/ensure-schema-lock-policy.d.ts +0 -15
  430. package/dist/plugins/ensure-schema-lock-policy.js +3 -2
  431. package/dist/plugins/file-run-store.d.ts +63 -23
  432. package/dist/plugins/file-run-store.js +138 -83
  433. package/dist/plugins/host-platform.d.ts +24 -3
  434. package/dist/plugins/host-platform.js +15 -1
  435. package/dist/plugins/image-bake-store-sql.js +2 -0
  436. package/dist/plugins/imported-layer-root-retirement.d.ts +2 -2
  437. package/dist/plugins/k8s-pod-reaper.d.ts +1 -3
  438. package/dist/plugins/k8s-pod-reaper.js +0 -1
  439. package/dist/plugins/leader-run-store-sql.d.ts +22 -0
  440. package/dist/plugins/leader-run-store-sql.js +34 -4
  441. package/dist/plugins/local-checkpoint-store.d.ts +58 -23
  442. package/dist/plugins/local-checkpoint-store.js +195 -76
  443. package/dist/plugins/local-data-dir-modes-m39.js +2 -1
  444. package/dist/plugins/local-docker-capacity.d.ts +93 -0
  445. package/dist/plugins/local-docker-capacity.js +194 -0
  446. package/dist/plugins/local-docker-reaper.d.ts +92 -0
  447. package/dist/plugins/local-docker-reaper.js +102 -0
  448. package/dist/plugins/local-engine-high-water.d.ts +4 -2
  449. package/dist/plugins/local-engine-high-water.js +4 -1
  450. package/dist/plugins/local-session-store.d.ts +358 -125
  451. package/dist/plugins/local-session-store.js +824 -251
  452. package/dist/plugins/local-session-window.d.ts +3 -2
  453. package/dist/plugins/local-session-window.js +3 -2
  454. package/dist/plugins/local-sidecar-quarantine.js +3 -2
  455. package/dist/plugins/local-task-attachment-store.d.ts +18 -1
  456. package/dist/plugins/local-task-attachment-store.js +22 -1
  457. package/dist/plugins/memory-embedder.js +9 -7
  458. package/dist/plugins/memory-engine-pg.d.ts +3 -2
  459. package/dist/plugins/memory-engine-pg.js +14 -5
  460. package/dist/plugins/memory-engine-sql-apply.d.ts +8 -4
  461. package/dist/plugins/memory-engine-sql-apply.js +6 -8
  462. package/dist/plugins/memory-engine-tidb.d.ts +4 -2
  463. package/dist/plugins/memory-engine-tidb.js +11 -2
  464. package/dist/plugins/memory-optout-grant-store-sql.d.ts +1 -1
  465. package/dist/plugins/memory-optout-grant-store-sql.js +3 -3
  466. package/dist/plugins/memory-run-store.d.ts +39 -27
  467. package/dist/plugins/memory-run-store.js +72 -70
  468. package/dist/plugins/one-time-migration-marker.d.ts +10 -0
  469. package/dist/plugins/one-time-migration-marker.js +7 -0
  470. package/dist/plugins/one-time-migrations.d.ts +186 -45
  471. package/dist/plugins/one-time-migrations.js +442 -119
  472. package/dist/plugins/org-delivery-quota-store.js +2 -1
  473. package/dist/plugins/permission-rule-store-file.d.ts +3 -3
  474. package/dist/plugins/permission-rule-store-sql.d.ts +4 -63
  475. package/dist/plugins/permission-rule-store-sql.js +6 -86
  476. package/dist/plugins/pg-pool.d.ts +1 -31
  477. package/dist/plugins/pg-pool.js +16 -7
  478. package/dist/plugins/remote-env-e2b.d.ts +7 -25
  479. package/dist/plugins/remote-env-e2b.js +34 -25
  480. package/dist/plugins/remote-env-host.d.ts +2 -9
  481. package/dist/plugins/remote-env-host.js +34 -22
  482. package/dist/plugins/remote-env-k8s.d.ts +40 -45
  483. package/dist/plugins/remote-env-k8s.js +107 -58
  484. package/dist/plugins/remote-env-local-docker.d.ts +148 -14
  485. package/dist/plugins/remote-env-local-docker.js +367 -72
  486. package/dist/plugins/remote-scratchpad.js +4 -0
  487. package/dist/plugins/retention-deployment.d.ts +49 -17
  488. package/dist/plugins/retention-deployment.js +39 -8
  489. package/dist/plugins/run-preview-m45.d.ts +11 -0
  490. package/dist/plugins/run-preview-m45.js +19 -0
  491. package/dist/plugins/run-store-sql.d.ts +56 -68
  492. package/dist/plugins/run-store-sql.js +127 -116
  493. package/dist/plugins/s3-answer.d.ts +2 -1
  494. package/dist/plugins/sandbox-reaper.d.ts +26 -0
  495. package/dist/plugins/sandbox-reaper.js +2 -0
  496. package/dist/plugins/scenario-prefix-switch-m42.d.ts +54 -0
  497. package/dist/plugins/scenario-prefix-switch-m42.js +55 -0
  498. package/dist/plugins/scheduler-support.d.ts +16 -1
  499. package/dist/plugins/scheduler-support.js +22 -2
  500. package/dist/plugins/schema-consistency.d.ts +42 -9
  501. package/dist/plugins/schema-consistency.js +212 -11
  502. package/dist/plugins/schema-drift-sentence.d.ts +4 -1
  503. package/dist/plugins/schema-drift-sentence.js +4 -4
  504. package/dist/plugins/schema-ensure-legs.d.ts +9 -0
  505. package/dist/plugins/schema-ensure-legs.js +1 -1
  506. package/dist/plugins/schema-indexes.js +3 -0
  507. package/dist/plugins/schema-live-columns.d.ts +14 -5
  508. package/dist/plugins/schema-live-columns.js +10 -10
  509. package/dist/plugins/send-user-file.js +2 -1
  510. package/dist/plugins/session-birth.d.ts +37 -0
  511. package/dist/plugins/session-birth.js +38 -0
  512. package/dist/plugins/session-epoch-anchor.d.ts +40 -12
  513. package/dist/plugins/session-epoch-anchor.js +33 -11
  514. package/dist/plugins/session-ext-table.d.ts +27 -3
  515. package/dist/plugins/session-ext-table.js +19 -6
  516. package/dist/plugins/session-fork.d.ts +15 -1
  517. package/dist/plugins/session-fork.js +3 -0
  518. package/dist/plugins/session-ownership.d.ts +1 -1
  519. package/dist/plugins/session-placement.d.ts +22 -16
  520. package/dist/plugins/session-placement.js +15 -12
  521. package/dist/plugins/session-row-sql.d.ts +12 -0
  522. package/dist/plugins/session-row-sql.js +3 -3
  523. package/dist/plugins/session-run-rollup.d.ts +29 -0
  524. package/dist/plugins/session-run-rollup.js +40 -0
  525. package/dist/plugins/session-store-sql.d.ts +38 -12
  526. package/dist/plugins/session-store-sql.js +130 -30
  527. package/dist/plugins/session-withdraw-sql.d.ts +36 -0
  528. package/dist/plugins/session-withdraw-sql.js +42 -0
  529. package/dist/plugins/shared-memory-store-sql.d.ts +0 -69
  530. package/dist/plugins/shared-memory-store-sql.js +2 -1
  531. package/dist/plugins/shell-sentinel-owner-m48.d.ts +20 -0
  532. package/dist/plugins/shell-sentinel-owner-m48.js +3 -0
  533. package/dist/plugins/snapshot-bucket-presence.d.ts +2 -1
  534. package/dist/plugins/sql-driver.d.ts +1 -1
  535. package/dist/plugins/sql-driver.js +2 -1
  536. package/dist/plugins/sql-errors.d.ts +32 -5
  537. package/dist/plugins/sql-errors.js +55 -7
  538. package/dist/plugins/sql-json-column.d.ts +8 -7
  539. package/dist/plugins/sql-json-column.js +10 -6
  540. package/dist/plugins/store-backend.d.ts +84 -15
  541. package/dist/plugins/store-backend.js +186 -55
  542. package/dist/plugins/store-contracts.d.ts +90 -30
  543. package/dist/plugins/store-contracts.js +22 -1
  544. package/dist/plugins/store-fault.d.ts +28 -2
  545. package/dist/plugins/store-fault.js +20 -2
  546. package/dist/plugins/task-attachment-store.d.ts +15 -3
  547. package/dist/plugins/task-attachment-store.js +22 -9
  548. package/dist/plugins/tidb-pool.js +23 -8
  549. package/dist/plugins/web-search.js +5 -3
  550. package/dist/plugins/workflow-run-store-sql.d.ts +6 -1
  551. package/dist/plugins/workflow-run-store-sql.js +11 -5
  552. package/dist/principal-jwt.d.ts +4 -4
  553. package/dist/principal-jwt.js +20 -5
  554. package/dist/principal-shape.d.ts +41 -0
  555. package/dist/principal-shape.js +19 -0
  556. package/dist/question.d.ts +13 -23
  557. package/dist/question.js +21 -39
  558. package/dist/request-declaration-refusal.d.ts +35 -12
  559. package/dist/request-declaration-refusal.js +21 -9
  560. package/dist/request-form.d.ts +58 -0
  561. package/dist/request-form.js +72 -0
  562. package/dist/request-image-urls.d.ts +8 -2
  563. package/dist/request-image-urls.js +2 -1
  564. package/dist/request-images.d.ts +20 -0
  565. package/dist/request-images.js +59 -0
  566. package/dist/request-key-closure.d.ts +6 -7
  567. package/dist/request-key-closure.js +15 -2
  568. package/dist/resource-suspend.d.ts +7 -16
  569. package/dist/resource-suspend.js +1 -1
  570. package/dist/retired-name-host-notice.d.ts +21 -0
  571. package/dist/retired-name-host-notice.js +12 -0
  572. package/dist/rule-entry-list.d.ts +2 -2
  573. package/dist/rule-entry-list.js +3 -4
  574. package/dist/rule-issue-reading.d.ts +58 -0
  575. package/dist/rule-issue-reading.js +14 -0
  576. package/dist/rules-consent.d.ts +5 -3
  577. package/dist/rules-consent.js +1 -0
  578. package/dist/run-acceptance.d.ts +3 -1
  579. package/dist/run-acceptance.js +3 -0
  580. package/dist/run-local.d.ts +14 -6
  581. package/dist/run-local.js +92 -80
  582. package/dist/run-stale-default.d.ts +7 -0
  583. package/dist/run-stale-default.js +2 -0
  584. package/dist/runs.d.ts +26 -15
  585. package/dist/runs.js +39 -27
  586. package/dist/runtime-caps-resolver.d.ts +21 -6
  587. package/dist/runtime-caps-resolver.js +17 -4
  588. package/dist/runtime-governance.d.ts +2 -2
  589. package/dist/runtime-governance.js +5 -3
  590. package/dist/sealed-key-layout.d.ts +12 -5
  591. package/dist/sealed-key-layout.js +5 -0
  592. package/dist/sealed-key.d.ts +12 -2
  593. package/dist/sealed-key.js +115 -27
  594. package/dist/security.d.ts +128 -158
  595. package/dist/security.js +163 -59
  596. package/dist/sema-config-dir.d.ts +20 -0
  597. package/dist/sema-config-dir.js +25 -0
  598. package/dist/server-secret-env.d.ts +21 -5
  599. package/dist/server-secret-env.js +14 -4
  600. package/dist/session-children-retire.d.ts +7 -5
  601. package/dist/session-children-retire.js +7 -2
  602. package/dist/session-deletion.d.ts +88 -0
  603. package/dist/session-deletion.js +8 -0
  604. package/dist/session-erase.d.ts +145 -0
  605. package/dist/session-erase.js +115 -0
  606. package/dist/session-error-wire.d.ts +5 -5
  607. package/dist/session-error-wire.js +1 -1
  608. package/dist/session-incarnation.d.ts +52 -5
  609. package/dist/session-incarnation.js +19 -2
  610. package/dist/session-policy-wire.d.ts +6 -3
  611. package/dist/session-policy-wire.js +11 -1
  612. package/dist/session-resident-background.d.ts +0 -71
  613. package/dist/session-resident-background.js +4 -3
  614. package/dist/session-row.d.ts +2 -1
  615. package/dist/session-rules-seat.d.ts +12 -0
  616. package/dist/session-rules-seat.js +19 -0
  617. package/dist/session-titler.d.ts +7 -15
  618. package/dist/session-titler.js +1 -1
  619. package/dist/spec-fields.d.ts +57 -3
  620. package/dist/spec-fields.js +72 -51
  621. package/dist/store-posture.d.ts +136 -20
  622. package/dist/store-posture.js +188 -3
  623. package/dist/stored-request-hooks-m20.js +2 -2
  624. package/dist/stores-sql/background-agent-store-sql.d.ts +11 -2
  625. package/dist/stores-sql/background-agent-store-sql.js +73 -20
  626. package/dist/stores-sql/checkpoint-store-sql.d.ts +33 -28
  627. package/dist/stores-sql/checkpoint-store-sql.js +75 -44
  628. package/dist/stores-sql/mailbox-store-sql.d.ts +7 -4
  629. package/dist/stores-sql/mailbox-store-sql.js +31 -32
  630. package/dist/stores-sql/pg-session-storage.d.ts +7 -5
  631. package/dist/stores-sql/pg-session-storage.js +54 -46
  632. package/dist/stores-sql/retention-store-sql.d.ts +87 -19
  633. package/dist/stores-sql/retention-store-sql.js +92 -27
  634. package/dist/stores-sql/session-policy-store-sql.d.ts +32 -10
  635. package/dist/stores-sql/session-policy-store-sql.js +44 -36
  636. package/dist/stores-sql/session-write-hooks.d.ts +12 -6
  637. package/dist/stores-sql/tidb-session-storage.d.ts +4 -4
  638. package/dist/stores-sql/tidb-session-storage.js +13 -8
  639. package/dist/stores-sql/tidb-session-store.d.ts +36 -17
  640. package/dist/stores-sql/tidb-session-store.js +69 -39
  641. package/dist/stores-sql/windowed-session-storage.d.ts +5 -0
  642. package/dist/stores-sql/windowed-session-storage.js +9 -0
  643. package/dist/submission-exit.d.ts +50 -0
  644. package/dist/submission-exit.js +108 -0
  645. package/dist/task-a2a.d.ts +1 -1
  646. package/dist/task-a2a.js +3 -3
  647. package/dist/task-cwd.d.ts +20 -0
  648. package/dist/task-cwd.js +8 -0
  649. package/dist/task-mcp.d.ts +1 -1
  650. package/dist/task-mcp.js +3 -3
  651. package/dist/task-settings.d.ts +14 -10
  652. package/dist/task-settings.js +18 -7
  653. package/dist/terminal.d.ts +25 -43
  654. package/dist/terminal.js +31 -11
  655. package/dist/tool-approval.d.ts +131 -129
  656. package/dist/tool-approval.js +189 -193
  657. package/dist/trace/core-keyset-guard.d.ts +13 -6
  658. package/dist/trace/core-vocab-wire.d.ts +95 -0
  659. package/dist/trace/core-vocab-wire.js +15 -0
  660. package/dist/trace/exit-seat.d.ts +30 -4
  661. package/dist/trace/exit-seat.js +40 -36
  662. package/dist/trace/extension-call-face.d.ts +3 -2
  663. package/dist/trace/extension-call-face.js +3 -1
  664. package/dist/trace/ledger-events.d.ts +4 -7
  665. package/dist/trace/ledger-sink.d.ts +1 -30
  666. package/dist/trace/ledger-sink.js +0 -11
  667. package/dist/trace/model-segment.d.ts +5 -5
  668. package/dist/trace/model-segment.js +5 -5
  669. package/dist/trace/project.d.ts +55 -42
  670. package/dist/trace/project.js +52 -19
  671. package/dist/trace/redact.d.ts +123 -27
  672. package/dist/trace/redact.js +880 -260
  673. package/dist/trace/self-minted-wire.d.ts +487 -19
  674. package/dist/trace/self-minted-wire.js +172 -23
  675. package/dist/trace/wire-projection-faces.d.ts +5 -6
  676. package/dist/trace/wire-projection-faces.js +2 -2
  677. package/dist/upstream-body.d.ts +23 -0
  678. package/dist/upstream-body.js +16 -0
  679. package/dist/url-refusal.d.ts +3 -3
  680. package/dist/url-refusal.js +11 -4
  681. package/dist/user-authored-text.d.ts +1 -1
  682. package/dist/user-input-ledger.d.ts +7 -8
  683. package/dist/user-input-ledger.js +1 -1
  684. package/dist/web-admin-client/apply-effective.d.ts +6 -3
  685. package/dist/web-admin-client/apply-effective.js +13 -16
  686. package/dist/web-admin-client/apply-ledger.d.ts +16 -7
  687. package/dist/web-admin-client/apply-ledger.js +5 -2
  688. package/dist/web-admin-client/center-request.d.ts +2 -2
  689. package/dist/web-admin-client/center-request.js +15 -15
  690. package/dist/web-admin-client/effective-keys.d.ts +1 -1
  691. package/dist/web-admin-client/effective-keys.js +1 -1
  692. package/dist/web-admin-client/entry-metadata.d.ts +8 -0
  693. package/dist/web-admin-client/entry-metadata.js +13 -0
  694. package/dist/web-admin-client/http-client.d.ts +1 -1
  695. package/dist/web-admin-client/http-client.js +23 -4
  696. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  697. package/dist/web-admin-client/mcp-revocation.js +2 -1
  698. package/dist/web-admin-client/read-warnings.d.ts +1 -0
  699. package/dist/web-admin-client/read-warnings.js +1 -0
  700. package/dist/web-admin-client/restart-signal.js +8 -4
  701. package/dist/web-admin-client/skills-mcp.d.ts +2 -2
  702. package/dist/web-admin-client/types.d.ts +1 -2
  703. package/dist/workspace-space.d.ts +3 -2
  704. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +4 -4
  705. package/package.json +6 -3
  706. package/scripts/drain-check-local.mjs +118 -147
  707. package/scripts/drain-check.mysql.sql +22 -2
  708. package/scripts/drain-check.pg.sql +22 -2
  709. package/wire-changes/server@7.148.0.json +1517 -0
  710. package/dist/http/memory-control-plane-corrupt-reply.d.ts +0 -25
  711. package/dist/http/memory-control-plane-corrupt-reply.js +0 -19
  712. package/dist/http/memory-layer-reply.d.ts +0 -30
  713. package/dist/http/memory-layer-reply.js +0 -24
  714. package/dist/lsp/e2b-bridge.d.ts +0 -57
  715. package/dist/lsp/e2b-bridge.js +0 -139
  716. package/dist/lsp/e2b-manager.d.ts +0 -93
  717. package/dist/lsp/e2b-manager.js +0 -178
  718. package/dist/lsp/lsp-frames.d.ts +0 -14
  719. package/dist/lsp/lsp-frames.js +0 -25
  720. package/dist/lsp/manager.d.ts +0 -129
  721. package/dist/lsp/manager.js +0 -127
  722. package/dist/lsp/types.d.ts +0 -12
  723. package/dist/lsp/types.js +0 -2
  724. package/dist/lsp/ws-transport.d.ts +0 -40
  725. package/dist/lsp/ws-transport.js +0 -210
@@ -27,6 +27,7 @@ export declare function createRepoClient(kind: GitApiKind, baseUrl: string, toke
27
27
  export declare class GiteaClient implements RepoReadClient {
28
28
  private readonly baseUrl;
29
29
  private readonly token?;
30
+ /** 出站出口:Git host 回重定向 ⇒ 拒(`token` 凭据头只去被判过的那个根),不是静默跟随。 */
30
31
  private readonly fetchImpl;
31
32
  constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch);
32
33
  private api;
@@ -51,6 +52,7 @@ export declare class GiteaClient implements RepoReadClient {
51
52
  export declare class GitHubClient implements RepoReadClient {
52
53
  private readonly baseUrl;
53
54
  private readonly token?;
55
+ /** 出站出口:Git host 回重定向 ⇒ 拒(Bearer 凭据只去被判过的那个根),不是静默跟随。 */
54
56
  private readonly fetchImpl;
55
57
  constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch);
56
58
  private api;
@@ -13,6 +13,8 @@ export function parseRepo(input) {
13
13
  const MAX_FILE_BYTES = 96 * 1024;
14
14
  const MAX_TREE_ENTRIES = 2000;
15
15
  const REQUEST_TIMEOUT_MS = 15_000;
16
+ import { createEgressFetch } from "../egress-redirect.js";
17
+ import { readUpstreamJson } from "../upstream-body.js";
16
18
  export { GIT_API_KINDS, isGitApiKind } from "../git-api-kind.js";
17
19
  const RepoInfoWire = z.looseObject({ default_branch: z.string().optional() });
18
20
  const TreeWire = z.looseObject({
@@ -32,7 +34,7 @@ function pathSegmentsRejectingTraversal(path) {
32
34
  }
33
35
  return segments;
34
36
  }
35
- export function createRepoClient(kind, baseUrl, token, fetchImpl = fetch) {
37
+ export function createRepoClient(kind, baseUrl, token, fetchImpl) {
36
38
  switch (kind) {
37
39
  case "gitea":
38
40
  return new GiteaClient(baseUrl, token, fetchImpl);
@@ -48,10 +50,10 @@ export class GiteaClient {
48
50
  baseUrl;
49
51
  token;
50
52
  fetchImpl;
51
- constructor(baseUrl, token, fetchImpl = fetch) {
53
+ constructor(baseUrl, token, fetchImpl) {
52
54
  this.baseUrl = baseUrl;
53
55
  this.token = token;
54
- this.fetchImpl = fetchImpl;
56
+ this.fetchImpl = createEgressFetch("declare the final address as GIT_API_BASEURL", fetchImpl);
55
57
  }
56
58
  async api(path, accept = "application/json") {
57
59
  const headers = { accept };
@@ -66,12 +68,12 @@ export class GiteaClient {
66
68
  return res;
67
69
  }
68
70
  async defaultBranch({ owner, repo }) {
69
- const info = RepoInfoWire.parse(await (await this.api(`/repos/${owner}/${repo}`)).json());
71
+ const info = RepoInfoWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}`)));
70
72
  return info.default_branch || "main";
71
73
  }
72
74
  async tree(coords, ref) {
73
75
  const { owner, repo } = coords;
74
- const body = TreeWire.parse(await (await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=true&per_page=${MAX_TREE_ENTRIES}`)).json());
76
+ const body = TreeWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=true&per_page=${MAX_TREE_ENTRIES}`)));
75
77
  const paths = (body.tree ?? []).filter((e) => e.type === "blob").map((e) => e.path);
76
78
  return body.truncated
77
79
  ? [...paths, `…[truncated, tree has more than ${MAX_TREE_ENTRIES} entries]`]
@@ -80,7 +82,7 @@ export class GiteaClient {
80
82
  async readFile(coords, path, ref) {
81
83
  const { owner, repo } = coords;
82
84
  const segments = pathSegmentsRejectingTraversal(path);
83
- const body = ContentsWire.parse(await (await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)).json());
85
+ const body = ContentsWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)));
84
86
  if (body.type !== "file" || body.content == null)
85
87
  throw new Error(`not a file: ${path}`);
86
88
  const text = body.encoding === "base64" ? Buffer.from(body.content, "base64").toString("utf8") : body.content;
@@ -99,10 +101,10 @@ export class GitHubClient {
99
101
  baseUrl;
100
102
  token;
101
103
  fetchImpl;
102
- constructor(baseUrl, token, fetchImpl = fetch) {
104
+ constructor(baseUrl, token, fetchImpl) {
103
105
  this.baseUrl = baseUrl;
104
106
  this.token = token;
105
- this.fetchImpl = fetchImpl;
107
+ this.fetchImpl = createEgressFetch("declare the final address as GIT_API_BASEURL", fetchImpl);
106
108
  }
107
109
  async api(path, accept = "application/vnd.github+json") {
108
110
  const headers = { accept, "x-github-api-version": "2022-11-28" };
@@ -117,12 +119,12 @@ export class GitHubClient {
117
119
  return res;
118
120
  }
119
121
  async defaultBranch({ owner, repo }) {
120
- const info = RepoInfoWire.parse(await (await this.api(`/repos/${owner}/${repo}`)).json());
122
+ const info = RepoInfoWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}`)));
121
123
  return info.default_branch || "main";
122
124
  }
123
125
  async tree(coords, ref) {
124
126
  const { owner, repo } = coords;
125
- const body = TreeWire.parse(await (await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=1`)).json());
127
+ const body = TreeWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/git/trees/${encodeURIComponent(ref)}?recursive=1`)));
126
128
  const paths = (body.tree ?? []).filter((e) => e.type === "blob").map((e) => e.path);
127
129
  if (paths.length > MAX_TREE_ENTRIES) {
128
130
  return [...paths.slice(0, MAX_TREE_ENTRIES), `…[truncated, tree has more than ${MAX_TREE_ENTRIES} entries]`];
@@ -134,7 +136,7 @@ export class GitHubClient {
134
136
  async readFile(coords, path, ref) {
135
137
  const { owner, repo } = coords;
136
138
  const segments = pathSegmentsRejectingTraversal(path);
137
- const body = ContentsWire.parse(await (await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)).json());
139
+ const body = ContentsWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/contents/${segments.map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`)));
138
140
  if (body.type !== "file" || body.content == null)
139
141
  throw new Error(`not a file: ${path}`);
140
142
  if (body.encoding === "none") {
@@ -147,7 +149,7 @@ export class GitHubClient {
147
149
  }
148
150
  async pullDiff(coords, index) {
149
151
  const { owner, repo } = coords;
150
- const meta = PullMetaWire.parse(await (await this.api(`/repos/${owner}/${repo}/pulls/${index}`)).json());
152
+ const meta = PullMetaWire.parse(await readUpstreamJson(await this.api(`/repos/${owner}/${repo}/pulls/${index}`)));
151
153
  const res = await this.api(`/repos/${owner}/${repo}/pulls/${index}`, "application/vnd.github.v3.diff");
152
154
  let text = await res.text();
153
155
  const filesInDiff = (text.match(/^diff --git /gm) ?? []).length;
@@ -260,18 +260,6 @@ export declare const BUILTIN_SCENARIO_HANDS: {
260
260
  readonly scan: "none";
261
261
  readonly cowork: "full";
262
262
  };
263
- /**
264
- * [ref]:内建场景的**技能范围**(技能 `scenarios` 标签按哪个名字匹配)—— **全仓唯一声明处**:各场景工厂交进 `TaskSpec` 的技能与场景卡上的技能清单都按这张表取范围,
265
- * 再过同一只过滤(`skills.ts` 的 `skillsInScope`),两边因此恒为同一组技能。按 {@link BuiltinScenarioName} 键控 ⇒ 加 / 删一个内建场景而这里没跟 = 编译红。
266
- * `code` 的范围是 `default`:它与 default 共用一只工厂(工具 / 技能面恒等由构造保证),打了 `scenarios: code` 的技能不进 code 的 run。center 场景的范围是它自己的名字。
267
- */
268
- export declare const BUILTIN_SCENARIO_SKILL_SCOPE: {
269
- readonly code: "default";
270
- readonly default: "default";
271
- readonly "code-review": "code-review";
272
- readonly scan: "scan";
273
- readonly cowork: "cowork";
274
- };
275
263
  /**
276
264
  * `branded` = 这台部署是不是品牌部署 —— 部署座挂品牌行读的同一只判官(`brand-identity.ts` `isBrandedDeployment`)交进来;没有默认值:每个调用点说出这件事实。
277
265
  * 品牌部署上,品牌行 `when.binding` 那张表里的场景(`BRAND_IDENTITY_SCENARIOS`)的 `promptSummary` 点名 Sema 产品身份 —— 读面说的就是模型收到的。
@@ -309,7 +297,6 @@ export type ScenarioAvailability = {
309
297
  export declare function scenarioAvailability(deps: Pick<ScenarioDeps, "repoClient">, toolset: string): ScenarioAvailability;
310
298
  /** 拒绝文案的唯一属主:闭集穷举 switch(新增原因词不在这里表态即编译红)。 */
311
299
  export declare function scenarioUnavailableMessage(reason: ScenarioUnavailableReason, scenarioLabel: string): string;
312
- export declare const SCENARIO_NAME_RE: RegExp;
313
300
  /**
314
301
  * Build the center-declared scenario overlay. Invalid specs are SKIPPED with a warning (never fail
315
302
  * boot — same posture as skills/teams); valid ones become scenarios keyed by name, ready to be merged
@@ -423,9 +410,13 @@ export interface ScenarioGateSources {
423
410
  } | undefined;
424
411
  readonly logger?: Logger;
425
412
  }
426
- export type ScenarioGate = (principal: string | undefined, requested: unknown) => Promise<string>;
413
+ export interface ScenarioGate {
414
+ (principal: string | undefined, requested: unknown): Promise<string>;
415
+ /** 在册词表 —— 门判「在不在册」读的**同一张**场景表的自有键(活读,不抄快照)。请求的场景头在分派层判在册读它(读面没有体,不过整只门)。 */
416
+ readonly known: () => readonly string[];
417
+ }
427
418
  /**
428
- * 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `peekRuntimeCaps` 是同一对:
419
+ * 门问中心裁定走哪条腿(闭集;新增一词 ⇒ 下面的穷尽 `switch` 编译红)—— 与 `resolveRuntimeCaps` / `peekRuntimeCapsReading` 是同一对:
429
420
  * · `enforce` —— 任务提交腿:中心裁定走执法腿,center 硬失败铸下的 fail-closed 降级项两腿都认;
430
421
  * · `peek` —— 读面(`GET /v1/capabilities/mcp` 状态面、`GET /v1/sessions/:id/mcp` / `…/a2a` 两张会话面板):只读腿,同一只缓存 / 同一条抓取 / 同一份读数(中心答不出 ⇒ 读面同拒),但硬失败铸的降级项只对读面自己算数,
431
422
  * 不替这个主体的真提交留下 `{allowWorkflows:false, allowFork:false, autoMode:false}` 的短窗 deny(读面不许成为别人被拒的原因)。
@@ -7,6 +7,7 @@ import { createWebSearchBackend, judgeRequestWebSearch } from "../plugins/web-se
7
7
  import { scenarioSkillEntries, skillsForScenario } from "./skills.js";
8
8
  import { OFFICE_EXCLUDED_TOOL_NAMES, runHasWorkspace } from "./hands-lane.js";
9
9
  import { BRAND_IDENTITY_SCENARIOS } from "./brand-identity.js";
10
+ import { SCENARIO_NAME_RE } from "../owner-brands.js";
10
11
  export function buildPromptSeats(scenarioName, prompt, callerSystemPrompt) {
11
12
  const parts = [prompt?.roleText, callerSystemPrompt].filter((t) => typeof t === "string" && t.length > 0);
12
13
  const systemPrompt = parts.length > 0 ? parts.join("\n\n") : callerSystemPrompt;
@@ -69,7 +70,7 @@ export function buildScenarios(deps) {
69
70
  }).filter((t) => t.name !== WEB_FETCH_TOOL_NAME || deps.requirePrincipal !== true),
70
71
  ],
71
72
  hands: BUILTIN_SCENARIO_HANDS.default,
72
- skills: skillsForScenario(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE.default),
73
+ skills: skillsForScenario(deps.skills, "default"),
73
74
  };
74
75
  };
75
76
  return {
@@ -77,7 +78,7 @@ export function buildScenarios(deps) {
77
78
  code: (req, principal, ctx) => ({
78
79
  ...defaultScenario(req, principal, ctx),
79
80
  hands: BUILTIN_SCENARIO_HANDS.code,
80
- skills: skillsForScenario(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE.code),
81
+ skills: skillsForScenario(deps.skills, "code"),
81
82
  prompt: { role: "code" },
82
83
  }),
83
84
  "code-review": (req) => codeReview(deps, req),
@@ -89,13 +90,13 @@ export function buildScenarios(deps) {
89
90
  return {
90
91
  tools: [...repoToolsFor(repoClient, parseRepo(req.repo)), nowTool()],
91
92
  hands: BUILTIN_SCENARIO_HANDS.scan,
92
- skills: skillsForScenario(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE.scan),
93
+ skills: skillsForScenario(deps.skills, "scan"),
93
94
  };
94
95
  },
95
96
  cowork: (req, principal, ctx) => ({
96
97
  ...defaultScenario(req, principal, ctx),
97
98
  hands: BUILTIN_SCENARIO_HANDS.cowork,
98
- skills: skillsForScenario(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE.cowork),
99
+ skills: skillsForScenario(deps.skills, "cowork"),
99
100
  excludeTools: OFFICE_EXCLUDED_TOOL_NAMES,
100
101
  prompt: { role: "cowork" },
101
102
  }),
@@ -125,13 +126,6 @@ export const BUILTIN_SCENARIO_HANDS = {
125
126
  scan: "none",
126
127
  cowork: "full",
127
128
  };
128
- export const BUILTIN_SCENARIO_SKILL_SCOPE = {
129
- code: "default",
130
- default: "default",
131
- "code-review": "code-review",
132
- scan: "scan",
133
- cowork: "cowork",
134
- };
135
129
  export function builtinScenarioDetails(scenarios, deps, branded) {
136
130
  const probe = (name, req, principal, fallback) => {
137
131
  try {
@@ -146,7 +140,7 @@ export function builtinScenarioDetails(scenarios, deps, branded) {
146
140
  name, source: "builtin", builtin: true, summary, toolset, tools, promptSummary, enabled: true,
147
141
  ...availabilityFields(deps, toolset),
148
142
  attachmentSupplies: attachmentSuppliesFor(BUILTIN_SCENARIO_HANDS[name], deps.handsLane === true),
149
- skills: scenarioSkillEntries(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE[name]),
143
+ skills: scenarioSkillEntries(deps.skills, name),
150
144
  });
151
145
  const brandedScenario = (name) => branded && BRAND_IDENTITY_SCENARIOS.includes(name);
152
146
  const details = {
@@ -220,7 +214,6 @@ function requireRepoClient(deps, scenarioLabel) {
220
214
  ? `${scenarioLabel} scenario has no repo client although the availability owner reports it available (wiring defect)`
221
215
  : scenarioUnavailableMessage(verdict.reason, scenarioLabel));
222
216
  }
223
- export const SCENARIO_NAME_RE = /^[a-z][a-z0-9-]{1,31}$/;
224
217
  export function centerScenarios(deps, specs, builtinNames, logger) {
225
218
  const overlay = {};
226
219
  const shadows = [];
@@ -254,7 +247,7 @@ function codeReview(deps, req) {
254
247
  }
255
248
  const coords = parseRepo(req.repo);
256
249
  const repoTools = repoToolsFor(repoClient, coords);
257
- const skills = skillsForScenario(deps.skills, BUILTIN_SCENARIO_SKILL_SCOPE["code-review"]);
250
+ const skills = skillsForScenario(deps.skills, "code-review");
258
251
  const hands = BUILTIN_SCENARIO_HANDS["code-review"];
259
252
  return { tools: [...repoTools, nowTool()], hands, skills, prompt: { roleText: REVIEWER_ROLE_TEXT } };
260
253
  }
@@ -328,7 +321,7 @@ export function gateScenarioRequest(ruling, bodyScenario, defaultScenario, known
328
321
  const refusal = danglingScenarioRefusal(name, source, known);
329
322
  if (refusal !== undefined) {
330
323
  logger?.warn("scenario_assignment_unknown", { scenario: name, source, ...(principal !== undefined ? { principal } : {}) });
331
- throw createCodedHttpError(503, "state.scenario_assignment_unknown", refusal, { detail: { scenario: name, source } });
324
+ throw createCodedHttpError(503, "state.scenario_assignment_unknown", refusal, { scenario: name, source });
332
325
  }
333
326
  return name;
334
327
  }
@@ -345,6 +338,8 @@ export function createScenarioGate(sources, leg) {
345
338
  }
346
339
  }
347
340
  };
348
- return async (principal, requested) => gateScenarioRequest(await rulingOf(principal), requested, sources.config.defaultScenario, Object.keys(sources.scenarios), sources.logger, principal);
341
+ const known = () => Object.keys(sources.scenarios);
342
+ const gate = async (principal, requested) => gateScenarioRequest(await rulingOf(principal), requested, sources.config.defaultScenario, known(), sources.logger, principal);
343
+ return Object.assign(gate, { known });
349
344
  }
350
345
  //# sourceMappingURL=scenarios.js.map
@@ -87,7 +87,7 @@ export declare function loadDeploymentSkills(config: {
87
87
  readonly provider: ExecutionLane;
88
88
  };
89
89
  }, logger?: Logger): LoadedSkill[];
90
- /** 一个技能范围交进 `TaskSpec` 的技能(场景工厂的 `skills`)。范围从哪来见 `scenarios.ts` 的 `BUILTIN_SCENARIO_SKILL_SCOPE`(center 场景 = 它自己的名字)。 */
90
+ /** 一个技能范围交进 `TaskSpec` 的技能(场景工厂的 `skills`)。**技能范围 = 场景名**,内建与 center 声明的场景一律如此、一处读法(没有范围表):各工厂与场景卡直传自己的场景名。 */
91
91
  export declare function skillsForScenario(loaded: readonly LoadedSkill[], scope: string): SkillSpec[];
92
92
  /**
93
93
  * 技能清单的一条 —— **一张形,两个面**:场景卡(`GET /v1/capabilities/scenarios/:name` 的 `skills[]`,[ref])与 run 级名册
@@ -12,7 +12,7 @@
12
12
  * - 🔴 **候选 ≠ 延迟**(core 7.15.0 [ref] 的行为面收窄,本仓两条真后果见下):候选集整体受**一道**
13
13
  * 阈值门,全或无 —— 候选的内联字节(name+description+schema)≥ `floor(上下文 token × 10%) × 3`
14
14
  * 才延迟,否则**全内联且不挂 `ToolSearch`**。远端协议铸名因此**不再无条件占位**:本仓缺省窗
15
- * (`MODEL_CONTEXT_WINDOW=262144`)下阈值 = 78 642 字符,一个中小 MCP 名册够不着 ⇒ 首请求带全 schema。
15
+ * (`ASSUMED_CONTEXT_WINDOW`,今天 262144 token)下阈值 = 78 642 字符,一个中小 MCP 名册够不着 ⇒ 首请求带全 schema。
16
16
  * 唯一不受门的是调用方的 `TaskSpec.deferTools` 字面名单(按字面恒延迟、不计量)。
17
17
  * - `RunnerDeps.deferMode:"auto"` 不是第二道门,而是把候选集**拓宽**到全部 caller spec 后走同一道门 ——
18
18
  * 在本仓缺省场景下那会连 Agent 与 Task 四件一起卷进候选(与 CC 姿态相反),所以我们**刻意不开**;
@@ -25,7 +25,8 @@ import type { ServiceBlobExchange, ServiceFileHistoryStore } from "./plugins/sto
25
25
  import { resolveStreamApprovalGate, type ApprovalFrameFamily } from "./tool-approval.js";
26
26
  import { type WorkspaceSyncCapability } from "./workspace-space.js";
27
27
  import type { WorkspaceCacheCapability } from "./workspace-cache.js";
28
- import type { ResumeAnchorStore } from "./plugins/store-backend.js";
28
+ import { type HeadRead } from "./session-incarnation.js";
29
+ import type { HistoryAnchorReaders } from "./history-anchor.js";
29
30
  import type { EngineHandoverDoor } from "./boot/engine-lease.js";
30
31
  /** why 闭集:词 → 给运维看的一句义(诊断 / 测试读它;wire 上的拒句由各门自写)。 */
31
32
  export declare const CAPABILITY_FACT_WHY: {
@@ -38,14 +39,14 @@ export declare const CAPABILITY_FACT_WHY: {
38
39
  readonly checkpoint_store_absent: "no durable checkpoint store is wired (DURABLE_APPROVAL)";
39
40
  readonly session_audit_absent: "no session audit view is wired (needs a durable session store)";
40
41
  readonly session_watch_absent: "the session watch registry is not wired";
41
- readonly session_lister_absent: "no session enumerator is wired (session store or run store listSessions)";
42
+ readonly session_lister_absent: "no session enumerator is wired (the session store has no listSessions)";
42
43
  readonly session_fork_face_absent: "the session store has no fork face";
43
44
  readonly session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)";
44
45
  readonly session_purge_absent: "no session purge coordinator is wired";
45
46
  readonly session_policy_store_absent: "no session policy store is wired";
46
47
  readonly store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)";
47
48
  readonly file_history_store_absent: "no file-history store is wired";
48
- readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)";
49
+ readonly resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through, with the run store an unknown handle is checked against — both come from the store backend)";
49
50
  readonly execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind";
50
51
  readonly workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from";
51
52
  readonly session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance";
@@ -101,6 +102,8 @@ export declare const CAPABILITY_FACT_WHY: {
101
102
  readonly deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)";
102
103
  readonly engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)";
103
104
  readonly engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)";
105
+ readonly auto_background_off: "AUTO_BACKGROUND_ON_TIMEOUT=false: a foreground command that outruns its own timeout is killed";
106
+ readonly lane_cannot_adopt_running_command: "the execution lane's environment cannot move a running command to the background (only the single-user host lane with HOST_BG_ENABLED on, k8s and e2b can), so a command that outruns its timeout is killed whatever AUTO_BACKGROUND_ON_TIMEOUT says";
104
107
  };
105
108
  export type CapabilityFactWhy = keyof typeof CAPABILITY_FACT_WHY;
106
109
  /** 不可用臂。 */
@@ -170,8 +173,8 @@ export declare function sessionEventStream(d: Pick<Deps, "sessionWatch" | "sessi
170
173
  sessionStorage: HeadReadingSessionStore;
171
174
  }>;
172
175
  type SessionLister = NonNullable<OwnerAwareSessionStore["listSessions"]>;
173
- /** 会话枚举面:session 店的 `listSessions`,否则老形 run 店聚合。见证 = 已绑好宿主的那一只。 */
174
- export declare function sessionList(d: Pick<Deps, "sessionStorage" | "runStore">): Fact<"session_lister_absent", {
176
+ /** 会话枚举面:会话店的 `listSessions` —— 唯一的会话 lister(run 店不列会话:只有 run 行、没有会话行的面答不了「有哪些会话」)。见证 = 已绑好宿主的那一只。 */
177
+ export declare function sessionList(d: Pick<Deps, "sessionStorage">): Fact<"session_lister_absent", {
175
178
  lister: SessionLister;
176
179
  }>;
177
180
  export declare function sessionFork(d: Pick<Deps, "sessionStorage">): Fact<"session_fork_face_absent" | "session_head_face_absent", {
@@ -183,9 +186,17 @@ export declare function sessionFork(d: Pick<Deps, "sessionStorage">): Fact<"sess
183
186
  export declare function sessionPatch(d: Pick<Deps, "sessionStorage">): Fact<"session_row_faces_absent", {
184
187
  sessionStorage: WithMethods<OwnerAwareSessionStore, "headOf" | "writeSessionRowCells">;
185
188
  }>;
189
+ /** 删除门读的会话店视图:按 id 读 = 删除门那一只头读,行格的 placement 问询 = 店自己的那一只。门照旧由属主存取器读头(`admitSessionById`),读的就是这一只。 */
190
+ type DeletionGateStore = Pick<OwnerAwareSessionStore, "placementOf"> & {
191
+ readonly headOf: HeadRead;
192
+ };
193
+ /**
194
+ * 会话删除面(purge 协调器 ∧ 删除门的头读)。见证 = 协调器 + 删除门的店视图 {@link DeletionGateStore}:按 id 读是 `deletionHeadReadOf`(local 店删到一半的行也答得出属主,
195
+ * 开始删它的那位重发收得完;别的店 = `headOf`)—— 与协调器围栏读同一只。
196
+ */
186
197
  export declare function sessionDelete(d: Pick<Deps, "purgeSession" | "sessionStorage">): Fact<"session_purge_absent" | "session_head_face_absent", {
187
198
  purge: Store<"purgeSession">;
188
- sessionStorage: HeadReadingSessionStore;
199
+ gateStore: DeletionGateStore;
189
200
  }>;
190
201
  export declare function sessionPolicy(d: Pick<Deps, "sessionPolicyStore" | "sessionStorage">): Fact<"session_policy_store_absent" | "session_head_face_absent", {
191
202
  policyStore: Store<"sessionPolicyStore">;
@@ -212,16 +223,17 @@ type RewindFilesWhy = "file_history_store_absent" | "session_head_face_absent" |
212
223
  /**
213
224
  * run 外的「只恢复代码」口(`POST /v1/sessions/:id/rewind-files`,[ref])这台部署**解不解得出** —— 能力位 `sessionRewindFiles` 与该口的 501 读这一只。
214
225
  * 四格缺一不可,每格都是那一口真要用的设施:文件历史店(引擎 `Runner.rewindFiles` 读的同一只;旋钮 `FILE_HISTORY_CAPTURE` 只关捕获、不摘店,
215
- * 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店(`to` 手柄经它翻成 entry id,`history-anchor.ts`)∧ 执行车道有手
226
+ * 所以与它无关 —— 已存边界照常可回退)∧ 会话头读(属主门 + 坏档判据)∧ 锚店与 run 店(`to` 手柄经锚店翻成 entry id,未知手柄的 404 成因半句读 run 店,
227
+ * `history-anchor.ts`;两只同出存储后端,所以是同一格)∧ 执行车道有手
216
228
  * (无手车道上引擎恒拒 `rewind.files_env_unsupported`:没有工作区可回退 —— 位说有而口恒拒不许发生)∧ 即时回退的工作区活过一次执行(部署形表行 `rewindableWorkspace`;
217
229
  * 否则恢复的结果到不了下一次执行)∧ 会话店由本进程独占(local 后端:数据根被一个活进程锁住 ⇒ 引擎的进程内会话锁就是全局互斥;
218
230
  * SQL 后端被多副本共用,而 run 外回退还没有一只跨副本的持久认领 —— 「先查认领再交引擎」只是检查不是互斥,所以在共享店上位为假、口 501,不留「检查即放行」)。
219
231
  * 动词本身是引擎 `Runner` 的必有成员(型上必在),不是一格。
220
- * 见证 = 判过在场的三只设施;路由在拒臂之后只读见证。
232
+ * 见证 = 判过在场的设施(历史店 · 手柄翻译的两只读店 · 会话店);路由在拒臂之后只读见证。
221
233
  */
222
- export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
234
+ export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy, {
223
235
  historyStore: ServiceFileHistoryStore;
224
- anchors: ResumeAnchorStore;
236
+ anchors: HistoryAnchorReaders;
225
237
  sessionStorage: HeadReadingSessionStore;
226
238
  }>;
227
239
  /**
@@ -230,7 +242,7 @@ export declare function sessionRewindFiles(d: Pick<Deps, "fileHistoryStore" | "r
230
242
  * `previewFileDelta` 不在 core 包根导出面上,本仓不另写一份 —— 等 core 导出它,SQL 店补这一座、本位随之转真,路由零改)。本位为假**不是**口不收 `dryRun`:口照收,答 `preview: null`
231
243
  * (「这台给不出统计」≠「什么都不会变」);所以本事实没有 501 拒点,只有能力位读它。
232
244
  */
233
- export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
245
+ export declare function sessionRewindFilesPreview(d: Pick<Deps, "fileHistoryStore" | "resumeAnchorStore" | "runStore" | "sessionStorage" | "config" | "backend">): Fact<RewindFilesWhy | "file_history_preview_absent">;
234
246
  /** 持久审批底座(checkpoint 店)在场 —— `/v1/approvals/*` 与 `/v1/assistant/*` 整条车道、会话 wake 都站在它上面。 */
235
247
  export declare function checkpointPark(d: Pick<Deps, "checkpointStore">): Fact<"checkpoint_store_absent", {
236
248
  checkpointStore: Store<"checkpointStore">;
@@ -459,6 +471,21 @@ export declare function deploymentModPackages(d: Pick<Deps, "deploymentModPackag
459
471
  }>;
460
472
  /** 自唤醒调度器挂在宿主 env 上:`SCHEDULER_ENABLED` ∧ 单用户 ∧ host 车道。装配(`boot/execution-env.ts`)与能力位同调。 */
461
473
  export declare function hostScheduler(c: Pick<ServiceConfig, "schedulerEnabled" | "requirePrincipal" | "remoteExec">): Fact<"scheduler_disabled" | "multi_tenant_deployment" | "not_host_lane">;
474
+ /**
475
+ * 前台命令超时转后台(`AUTO_BACKGROUND_ON_TIMEOUT`)在这台部署上生不生效:旋钮开 ∧ 本车道的执行环境能把**运行中的**命令领养成后台任务。
476
+ * 「能领养」就是执行环境的 `backgroundCapabilities.supportsDetach`,三只声明它的适配器(host / k8s / e2b)上它与后台 shell 的 `supported` 是同一个值 ——
477
+ * 所以按能力表的 `backgroundShell` 一位读:`supported`(k8s / e2b)⇒ 能;`single-user-only`(只有 host 一行)⇒ 单用户且 host 后台 shell 开关开着才能 ——
478
+ * 开关是第二参 `hostBackgroundShellOn`,调用方交 `hostBackgroundShellEnabled()`(`HOST_BG_ENABLED`;host 适配器的能力位读同一只;本模块零 I/O,不自己读 env)。
479
+ * 对账钉 `test/auto-background-on-timeout.test.ts` 逐车道拿装配出的真执行环境的 `supportsDetach` 与本事实对拍。
480
+ * 旋钮先判:关着的部署不论车道都答 `auto_background_off`(运维旋钮无条件,不支持的车道不拒启,只如实报)。
481
+ * `/health.autoBackgroundOnTimeout` 投它的三词({@link autoBackgroundOnTimeoutWord})。
482
+ */
483
+ export declare function autoBackgroundOnTimeout(c: Pick<ServiceConfig, "autoBackgroundOnTimeout" | "requirePrincipal" | "remoteExec">, hostBackgroundShellOn: boolean): Fact<"auto_background_off" | "lane_cannot_adopt_running_command">;
484
+ /** `/health.autoBackgroundOnTimeout` 的三词闭集(顺序无语义):`armed` = 生效 · `off` = 部署关了 · `unsupported` = 旋钮开着,但本车道不能把运行中的命令转后台。 */
485
+ export declare const AUTO_BACKGROUND_ON_TIMEOUT_WORDS: readonly ["armed", "off", "unsupported"];
486
+ export type AutoBackgroundOnTimeoutWord = (typeof AUTO_BACKGROUND_ON_TIMEOUT_WORDS)[number];
487
+ /** 事实 → 三词(穷举:事实多一个 why 而这里不接 = 编译红)。 */
488
+ export declare function autoBackgroundOnTimeoutWord(f: ReturnType<typeof autoBackgroundOnTimeout>): AutoBackgroundOnTimeoutWord;
462
489
  /** 引擎能力词的事实(core `ENGINE_CAPABILITIES` 每词一只谓词,值 = 本进程的事实;`/v1/capabilities` 以顶层布尔键展开它们)—— 住在
463
490
  * `capabilities/engine-capabilities.ts`,这里只是把它纳入「能力位只投影事实」的同一张读面,静态门认 `facts.engineCapabilityBits()` 这一只展开。 */
464
491
  export { engineCapabilityBits } from "./capabilities/engine-capabilities.js";
@@ -7,8 +7,8 @@ import { centerEntitlementSourceWired } from "./runtime-caps-resolver.js";
7
7
  import { WEB_ADMIN_ENV } from "@sema-agent/settings-schema";
8
8
  import { blobExchangeOf, overwriteWipeIncapable } from "./session-sync.js";
9
9
  import { WORKSPACE_PERSIST_DEFAULT, WORKSPACE_SNAPSHOT_KEEP_DEFAULT, workspaceSnapshotTimeoutOf } from "./workspace-space.js";
10
- import { headReadOf } from "./session-incarnation.js";
11
- import { laneWiresExecutionEnv } from "./execution-lane-caps.js";
10
+ import { deletionHeadReadOf, headReadOf } from "./session-incarnation.js";
11
+ import { executionLaneCaps, laneWiresExecutionEnv } from "./execution-lane-caps.js";
12
12
  export const CAPABILITY_FACT_WHY = {
13
13
  run_store_absent: "no durable run store is wired (DB_BACKEND=mysql|pg|local)",
14
14
  subagent_registry_absent: "the sub-agent steer registry is not wired",
@@ -19,14 +19,14 @@ export const CAPABILITY_FACT_WHY = {
19
19
  checkpoint_store_absent: "no durable checkpoint store is wired (DURABLE_APPROVAL)",
20
20
  session_audit_absent: "no session audit view is wired (needs a durable session store)",
21
21
  session_watch_absent: "the session watch registry is not wired",
22
- session_lister_absent: "no session enumerator is wired (session store or run store listSessions)",
22
+ session_lister_absent: "no session enumerator is wired (the session store has no listSessions)",
23
23
  session_fork_face_absent: "the session store has no fork face",
24
24
  session_row_faces_absent: "the session store has no session-row faces (headOf / sessionSummaryOf / writeSessionRowCells)",
25
25
  session_purge_absent: "no session purge coordinator is wired",
26
26
  session_policy_store_absent: "no session policy store is wired",
27
27
  store_backend_absent: "no store backend is wired (DB_BACKEND=memory, multi-tenant bare boot, or half-configured SQL)",
28
28
  file_history_store_absent: "no file-history store is wired",
29
- resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through)",
29
+ resume_anchor_store_absent: "no rewind anchor map is wired (the handle → session-entry map a rewind target is read through, with the run store an unknown handle is checked against — both come from the store backend)",
30
30
  execution_lane_handless: "the execution lane mounts no execution environment (REMOTE_EXEC=none), so a session has no working tree to rewind",
31
31
  workspace_rebuilt_per_task: "each task's workspace is rebuilt when the task starts on this deployment (a fresh directory, container or sandbox, or a restore from the workspace snapshot store that a rewind cannot yet take part in), so a rewind would not land in the tree the next task starts from",
32
32
  session_store_shared: "the session store is shared by several server instances (DB_BACKEND=mysql|pg) and no durable claim spans an out-of-run rewind yet, so a rewind could interleave with a run or another rewind started on another instance",
@@ -82,6 +82,8 @@ export const CAPABILITY_FACT_WHY = {
82
82
  deployment_mod_packages_absent: "no operator-declared mod package was loaded at boot (MODS_ROOT / MODS_PACKAGES)",
83
83
  engine_handover_lane_absent: "the attachment lease has no handover lane here: the lease is not armed (neither ENGINE_AUTO_EXIT nor SEMA_PARENT_PID), or the deployment is multi-tenant (REQUIRE_PRINCIPAL=true)",
84
84
  engine_lease_stopped: "the attachment lease has stopped observing (this engine is shutting down)",
85
+ auto_background_off: "AUTO_BACKGROUND_ON_TIMEOUT=false: a foreground command that outruns its own timeout is killed",
86
+ lane_cannot_adopt_running_command: "the execution lane's environment cannot move a running command to the background (only the single-user host lane with HOST_BG_ENABLED on, k8s and e2b can), so a command that outruns its timeout is killed whatever AUTO_BACKGROUND_ON_TIMEOUT says",
85
87
  };
86
88
  const no = (why) => ({ available: false, why });
87
89
  const yes = (w) => ({ available: true, ...w });
@@ -147,7 +149,7 @@ export function sessionEventStream(d) {
147
149
  return yes({ watch: d.sessionWatch, sessionStorage: owned.sessionStorage });
148
150
  }
149
151
  export function sessionList(d) {
150
- const lister = d.sessionStorage?.listSessions?.bind(d.sessionStorage) ?? d.runStore?.listSessions?.bind(d.runStore);
152
+ const lister = d.sessionStorage?.listSessions?.bind(d.sessionStorage);
151
153
  return lister !== undefined ? yes({ lister }) : no("session_lister_absent");
152
154
  }
153
155
  export function sessionFork(d) {
@@ -170,7 +172,12 @@ export function sessionDelete(d) {
170
172
  const owned = sessionOwnership(d);
171
173
  if (!owned.available)
172
174
  return owned;
173
- return yes({ purge: d.purgeSession, sessionStorage: owned.sessionStorage });
175
+ const store = owned.sessionStorage;
176
+ const headOf = deletionHeadReadOf(store);
177
+ if (headOf === undefined)
178
+ return no("session_head_face_absent");
179
+ const placementOf = store.placementOf?.bind(store);
180
+ return yes({ purge: d.purgeSession, gateStore: { headOf, ...(placementOf !== undefined ? { placementOf } : {}) } });
174
181
  }
175
182
  export function sessionPolicy(d) {
176
183
  if (d.sessionPolicyStore === undefined)
@@ -209,7 +216,7 @@ export function sessionRewindFiles(d) {
209
216
  const owned = sessionOwnership(d);
210
217
  if (!owned.available)
211
218
  return owned;
212
- if (d.resumeAnchorStore === undefined)
219
+ if (d.resumeAnchorStore === undefined || d.runStore === undefined)
213
220
  return no("resume_anchor_store_absent");
214
221
  if (!laneWiresExecutionEnv(d.config.remoteExec.provider))
215
222
  return no("execution_lane_handless");
@@ -217,7 +224,7 @@ export function sessionRewindFiles(d) {
217
224
  return no("workspace_rebuilt_per_task");
218
225
  if (d.backend?.kind !== "local")
219
226
  return no("session_store_shared");
220
- return yes({ historyStore: d.fileHistoryStore, anchors: d.resumeAnchorStore, sessionStorage: owned.sessionStorage });
227
+ return yes({ historyStore: d.fileHistoryStore, anchors: { anchors: d.resumeAnchorStore, runs: d.runStore }, sessionStorage: owned.sessionStorage });
221
228
  }
222
229
  export function sessionRewindFilesPreview(d) {
223
230
  const rewind = sessionRewindFiles(d);
@@ -493,5 +500,37 @@ export function hostScheduler(c) {
493
500
  return no("not_host_lane");
494
501
  return YES;
495
502
  }
503
+ export function autoBackgroundOnTimeout(c, hostBackgroundShellOn) {
504
+ if (c.autoBackgroundOnTimeout !== true)
505
+ return no("auto_background_off");
506
+ const cap = executionLaneCaps(c.remoteExec.provider).backgroundShell;
507
+ switch (cap) {
508
+ case "unsupported":
509
+ return no("lane_cannot_adopt_running_command");
510
+ case "supported":
511
+ return YES;
512
+ case "single-user-only":
513
+ return c.requirePrincipal !== true && hostBackgroundShellOn ? YES : no("lane_cannot_adopt_running_command");
514
+ default: {
515
+ const unknownCap = cap;
516
+ throw new Error(`auto-background fact: unknown lane capability ${String(unknownCap)}`);
517
+ }
518
+ }
519
+ }
520
+ export const AUTO_BACKGROUND_ON_TIMEOUT_WORDS = ["armed", "off", "unsupported"];
521
+ export function autoBackgroundOnTimeoutWord(f) {
522
+ if (f.available)
523
+ return "armed";
524
+ switch (f.why) {
525
+ case "auto_background_off":
526
+ return "off";
527
+ case "lane_cannot_adopt_running_command":
528
+ return "unsupported";
529
+ default: {
530
+ const unknownWhy = f.why;
531
+ throw new Error(`auto-background word: unknown why ${String(unknownWhy)}`);
532
+ }
533
+ }
534
+ }
496
535
  export { engineCapabilityBits } from "./capabilities/engine-capabilities.js";
497
536
  //# sourceMappingURL=capability-facts.js.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * **结算时作废一张本 run 自己会话上的、本服务兑现不了的卡** —— 读卡 → 卡仍 pending ∧ 卡在调用方说的那只会话上 ⇒
2
+ * **结算时作废一张归本 run 会话的、本服务兑现不了的卡** —— 读卡 → 卡仍 pending ∧ 卡归调用方说的那只会话(归属列,`hostSessionOf`)⇒
3
3
  * 按卡**自己的** scope 走 checkpoint 店的 `expire`(与引擎的本进程仲裁器、续跑的 resolve 同一只 CAS,恰一个赢家)。不新增任何持久态。
4
4
  *
5
5
  * 规则只有一条:**本服务兑现不了的卡不留在待决面上**。产地 = 停驻没落定就以失败收场的腿(`runs.ts` 的 `voidHeldParkCard`:后台腿与
@@ -13,16 +13,16 @@
13
13
  */
14
14
  import type { CheckpointToken } from "@sema-agent/core";
15
15
  import { type FailOpenTag } from "./observability/fail-open.js";
16
- /** 结算点手里那只 checkpoint 店的两个动词:读卡(取它自己的 scope / 会话 / 状态)→ 按卡自己的 scope CAS 作废。 */
16
+ /** 结算点手里那只 checkpoint 店的三个动词:读卡(取它自己的 scope / 状态)、读它归在哪只会话上 → 按卡自己的 scope CAS 作废。 */
17
17
  export interface CardVoidPort {
18
18
  get(token: CheckpointToken): Promise<{
19
19
  readonly scope?: string;
20
- readonly sessionId?: string;
21
20
  readonly status?: string;
22
21
  } | null>;
22
+ hostSessionOfCard(token: CheckpointToken): Promise<string | null | undefined>;
23
23
  expire(token: CheckpointToken, scope: string): Promise<boolean>;
24
24
  }
25
- /** 要作废的那一张:停驻带回的凭据 + 它应在的会话(对不上就不动它 —— 只作废**这一张**)。 */
25
+ /** 要作废的那一张:停驻带回的凭据 + 它应归的会话(本 run 的会话;对不上就不动它 —— 只作废**这一张**)。 */
26
26
  export interface CardRef {
27
27
  readonly token: CheckpointToken;
28
28
  readonly sessionId: string | undefined;
package/dist/card-void.js CHANGED
@@ -10,7 +10,7 @@ export async function voidPendingCard(card, cards, tag, at) {
10
10
  const live = await cards.get(card.token);
11
11
  if (live === null || live.status !== "pending")
12
12
  return;
13
- if (card.sessionId === undefined || live.sessionId !== card.sessionId || typeof live.scope !== "string") {
13
+ if (card.sessionId === undefined || (await cards.hostSessionOfCard(card.token)) !== card.sessionId || typeof live.scope !== "string") {
14
14
  miss("card_mismatch");
15
15
  return;
16
16
  }
@@ -38,8 +38,12 @@ export interface CenterCredentialRenewer {
38
38
  renewal(): CenterCredentialRenewal;
39
39
  /** 最近一次读到的信封的访问令牌到期时刻(epoch ms;最近一次取值不是信封 ⇒ undefined)。 */
40
40
  sessionExpiresAt(): number | undefined;
41
- /** 退订 + 停定时器(幂等;在飞的那一次照常落地 —— 它的结果对壳同样有用)。 */
42
- stop(): void;
41
+ /**
42
+ * 退订 + 停定时器(幂等),此后不再发起续签;返回的 promise 在**已经发出**的那一次续签落定之后才 settle(新信封落盘,或按失败落定 —— 从不 reject;
43
+ * 没有在飞的 ⇒ 立即 settle)。进程出口(起服前探针、停机)等它:中心一旦答应了续签,旧 refresh token 就作废了,换来的新信封没落盘就退出 ⇒
44
+ * 下一次起服手里只剩一只被消费的令牌。续签请求本身有界(`CENTER_PULL_TIMEOUT_MS`),所以这一等有界。
45
+ */
46
+ stop(): Promise<void>;
43
47
  }
44
48
  /** `/health.centerCredential` 的 wire 形(免鉴权面:只有闭集词、时刻与计数 —— 不带路径、不带 reason 原句、不带令牌)。 */
45
49
  export interface CenterCredentialHealthView {
@@ -5,6 +5,7 @@ import { WEB_ADMIN_ENV, WebAdminCredentialEnvelope, parseWebAdminCredentialFile
5
5
  import { ACCESS_TOKEN_TTL_SECONDS, OAuthErrorResponse, TokenGrantResponse } from "@sema-agent/settings-schema/api/auth";
6
6
  import { CENTER_PULL_TIMEOUT_MS, CenterRedirectRefusedError, centerTokenRefresh } from "./web-admin-client/center-request.js";
7
7
  import { OWNER_ONLY_FILE_MODE } from "./plugins/owner-only-file-mode.js";
8
+ import { readUpstreamJson } from "./upstream-body.js";
8
9
  export const CENTER_CREDENTIAL_RENEW_LEAD_KEY = "CENTER_CREDENTIAL_RENEW_LEAD_MS";
9
10
  export const CENTER_CREDENTIAL_RENEW_LEAD_DEFAULT_MS = 5 * 60_000;
10
11
  export const CENTER_CREDENTIAL_RENEW_LEAD_MIN_MS = CENTER_PULL_TIMEOUT_MS;
@@ -92,6 +93,7 @@ export function createCenterCredentialRenewer(deps) {
92
93
  let subject;
93
94
  let held;
94
95
  let inFlight = false;
96
+ let current;
95
97
  let stopped = false;
96
98
  const stranded = new Set();
97
99
  let cleanupWarned = false;
@@ -291,13 +293,13 @@ export function createCenterCredentialRenewer(deps) {
291
293
  return;
292
294
  }
293
295
  if (res.status !== 200) {
294
- const oauth = OAuthErrorResponse.safeParse(await res.json().catch(() => undefined));
296
+ const oauth = OAuthErrorResponse.safeParse(await readUpstreamJson(res).catch(() => undefined));
295
297
  const oauthError = oauth.success ? oauth.data.error : undefined;
296
298
  judgeRefusal(usedDigest, res.status === 400 && oauthError === "invalid_grant" ? "invalid_grant" : "rejected", { status: res.status, ...(oauthError !== undefined ? { oauthError } : {}) });
297
299
  return;
298
300
  }
299
301
  const issuedAt = now();
300
- const grant = TokenGrantResponse.safeParse(await res.json().catch(() => undefined));
302
+ const grant = TokenGrantResponse.safeParse(await readUpstreamJson(res).catch(() => undefined));
301
303
  if (!grant.success || !Number.isFinite(grant.data.expires_in) || grant.data.expires_in <= 0) {
302
304
  judgeRefusal(usedDigest, "malformed_grant", { status: res.status });
303
305
  return;
@@ -324,7 +326,7 @@ export function createCenterCredentialRenewer(deps) {
324
326
  if (held === undefined && (expiresAt - t > leadMs || t < quietUntil))
325
327
  return;
326
328
  inFlight = true;
327
- void renewOnce()
329
+ current = renewOnce()
328
330
  .catch((err) => {
329
331
  const error = { error: err instanceof Error ? err.message : String(err) };
330
332
  if (held !== undefined && subject !== undefined) {
@@ -336,6 +338,7 @@ export function createCenterCredentialRenewer(deps) {
336
338
  })
337
339
  .finally(() => {
338
340
  inFlight = false;
341
+ current = undefined;
339
342
  });
340
343
  };
341
344
  const unsubscribe = source.onRead((read) => {
@@ -358,6 +361,7 @@ export function createCenterCredentialRenewer(deps) {
358
361
  if (timer !== undefined)
359
362
  clearInterval(timer);
360
363
  unsubscribe();
364
+ return current ?? Promise.resolve();
361
365
  },
362
366
  };
363
367
  }