@sema-agent/server 7.150.0 → 7.152.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 (514) hide show
  1. package/MIGRATION.md +451 -0
  2. package/README.md +15 -3
  3. package/README.zh-CN.md +10 -2
  4. package/USAGE.md +144 -87
  5. package/deploy/sema-up/README.md +11 -4
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
  9. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
  10. package/deploy/sema-up/chart/templates/server.yaml +5 -3
  11. package/deploy/sema-up/chart/values-full-single.yaml +3 -1
  12. package/deploy/sema-up/chart/values.yaml +8 -1
  13. package/deploy/sema-up/cluster-up.sh +7 -6
  14. package/deploy/sema-up/kube-up.sh +6 -6
  15. package/deploy/sema-up/lib/flagshape.sh +36 -8
  16. package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
  17. package/deploy/sema-up/lib/helm-values-kube.py +2 -0
  18. package/deploy/sema-up/machines.example.yaml +3 -1
  19. package/deploy/sema-up/sema-up.sh +22 -16
  20. package/dist/adoption/import.js +3 -3
  21. package/dist/approval-ask-audit-store.d.ts +1 -1
  22. package/dist/approval-ask-machine.d.ts +4 -10
  23. package/dist/approval-ask-retention.d.ts +1 -1
  24. package/dist/approval-card.d.ts +12 -14
  25. package/dist/approval-gate-currency.d.ts +9 -9
  26. package/dist/approval-gate-currency.js +3 -4
  27. package/dist/approval-hmac.d.ts +17 -1
  28. package/dist/approval-hmac.js +7 -1
  29. package/dist/approval-queue-kind.d.ts +1 -1
  30. package/dist/approval.d.ts +2 -2
  31. package/dist/approval.js +2 -2
  32. package/dist/auth-bridge.d.ts +20 -0
  33. package/dist/auth-bridge.js +9 -0
  34. package/dist/background-session-reap.d.ts +1 -1
  35. package/dist/bake-runner/main.d.ts +4 -2
  36. package/dist/bind-host.d.ts +3 -6
  37. package/dist/bind-host.js +4 -7
  38. package/dist/boot/budget-tracing.js +1 -1
  39. package/dist/boot/coordinators.d.ts +1 -1
  40. package/dist/boot/coordinators.js +9 -10
  41. package/dist/boot/device-lane.js +2 -0
  42. package/dist/boot/engine-lease.d.ts +5 -0
  43. package/dist/boot/engine-lease.js +1 -0
  44. package/dist/boot/execution-env.d.ts +9 -14
  45. package/dist/boot/execution-env.js +85 -22
  46. package/dist/boot/execution-lane.js +32 -5
  47. package/dist/boot/late-binds.d.ts +8 -4
  48. package/dist/boot/late-binds.js +7 -1
  49. package/dist/boot/leader.d.ts +31 -30
  50. package/dist/boot/leader.js +38 -28
  51. package/dist/boot/leg-path-adjudication.d.ts +40 -0
  52. package/dist/boot/leg-path-adjudication.js +18 -0
  53. package/dist/boot/memory-consolidation.d.ts +3 -2
  54. package/dist/boot/memory-consolidation.js +6 -6
  55. package/dist/boot/parked-revive-gate.js +3 -15
  56. package/dist/boot/reapers.d.ts +6 -1
  57. package/dist/boot/reapers.js +13 -2
  58. package/dist/boot/resolve-spec.d.ts +3 -3
  59. package/dist/boot/resolve-spec.js +43 -48
  60. package/dist/boot/runner-deps.d.ts +46 -35
  61. package/dist/boot/runner-deps.js +94 -91
  62. package/dist/boot/session-age-out.d.ts +36 -0
  63. package/dist/boot/session-age-out.js +101 -0
  64. package/dist/boot/session-faces.d.ts +5 -14
  65. package/dist/boot/session-faces.js +9 -5
  66. package/dist/boot/shutdown.d.ts +6 -0
  67. package/dist/boot/shutdown.js +10 -4
  68. package/dist/boot/stage-01-config.js +2 -0
  69. package/dist/boot/stage-02-web-admin-pull.js +4 -5
  70. package/dist/boot/stage-05-execution-env.d.ts +5 -3
  71. package/dist/boot/stage-05-execution-env.js +3 -2
  72. package/dist/boot/stage-06-runners.d.ts +9 -4
  73. package/dist/boot/stage-06-runners.js +24 -9
  74. package/dist/boot/stage-07-capability-layer.d.ts +8 -4
  75. package/dist/boot/stage-07-capability-layer.js +3 -2
  76. package/dist/boot/stage-08-reapers.d.ts +8 -4
  77. package/dist/boot/stage-08-reapers.js +4 -2
  78. package/dist/boot/stage-09-leader.d.ts +12 -5
  79. package/dist/boot/stage-09-leader.js +14 -5
  80. package/dist/boot/stage-10-http-server.d.ts +19 -5
  81. package/dist/boot/stage-10-http-server.js +14 -21
  82. package/dist/boot/stores.js +7 -4
  83. package/dist/boot/web-admin.js +5 -8
  84. package/dist/boot/workflow-orchestration.d.ts +7 -2
  85. package/dist/boot/workflow-orchestration.js +24 -7
  86. package/dist/bounded-rotation.d.ts +29 -0
  87. package/dist/bounded-rotation.js +24 -0
  88. package/dist/capabilities/approvals-push.d.ts +3 -3
  89. package/dist/capabilities/scenarios.d.ts +28 -13
  90. package/dist/capabilities/scenarios.js +2 -2
  91. package/dist/capability-facts.d.ts +43 -32
  92. package/dist/capability-facts.js +45 -51
  93. package/dist/card-rule-offers.d.ts +32 -0
  94. package/dist/card-rule-offers.js +130 -0
  95. package/dist/center-credential.d.ts +25 -6
  96. package/dist/center-credential.js +25 -5
  97. package/dist/config-catalog.d.ts +26 -7
  98. package/dist/config-catalog.js +26 -22
  99. package/dist/config-dir-trust.js +4 -2
  100. package/dist/config-invariants.d.ts +20 -8
  101. package/dist/config-invariants.js +55 -12
  102. package/dist/config-lkg.d.ts +5 -19
  103. package/dist/config-lkg.js +8 -62
  104. package/dist/config-provider.d.ts +1 -1
  105. package/dist/config-root-migration.d.ts +2 -2
  106. package/dist/config-types.d.ts +38 -42
  107. package/dist/config.d.ts +58 -7
  108. package/dist/config.js +90 -40
  109. package/dist/control-socket.d.ts +51 -0
  110. package/dist/control-socket.js +115 -0
  111. package/dist/deployment-governance.d.ts +2 -1
  112. package/dist/deployment-shape.d.ts +9 -1
  113. package/dist/deployment-shape.js +2 -1
  114. package/dist/device-protocol.d.ts +5 -4
  115. package/dist/device-protocol.js +1 -1
  116. package/dist/device-ws-hub.d.ts +7 -0
  117. package/dist/device-ws-hub.js +10 -3
  118. package/dist/device-ws-protocol.d.ts +63 -10
  119. package/dist/device-ws-protocol.js +56 -25
  120. package/dist/elicitation.js +2 -2
  121. package/dist/engine-identity.d.ts +19 -7
  122. package/dist/engine-identity.js +10 -2
  123. package/dist/entry-mode-clamp-notice.d.ts +2 -1
  124. package/dist/entry-problems.d.ts +40 -3
  125. package/dist/entry-problems.js +3 -1
  126. package/dist/execution-env-refusal.d.ts +29 -0
  127. package/dist/execution-env-refusal.js +8 -0
  128. package/dist/execution-lane-caps.d.ts +3 -1
  129. package/dist/field-conflict.d.ts +1 -1
  130. package/dist/file-history-capture.d.ts +11 -4
  131. package/dist/file-history-capture.js +9 -6
  132. package/dist/file-history-disclosure.d.ts +7 -5
  133. package/dist/file-history-disclosure.js +7 -5
  134. package/dist/fleet/drain-entry.d.ts +4 -0
  135. package/dist/fleet/engine-signal.d.ts +12 -29
  136. package/dist/fleet/engine-signal.js +1 -7
  137. package/dist/fleet-client.js +2 -5
  138. package/dist/gate-settlement.d.ts +1 -8
  139. package/dist/gate-settlement.js +0 -4
  140. package/dist/history-anchor.js +1 -1
  141. package/dist/hitl-delivery.d.ts +2 -3
  142. package/dist/hitl-delivery.js +0 -2
  143. package/dist/hooks/hook-llm.js +4 -2
  144. package/dist/hooks/hook-runner.d.ts +3 -2
  145. package/dist/hooks/hook-runner.js +18 -3
  146. package/dist/host-decision.d.ts +11 -11
  147. package/dist/host-lsp-manager.d.ts +2 -2
  148. package/dist/http/active-run-conflict.d.ts +35 -2
  149. package/dist/http/active-run-conflict.js +48 -19
  150. package/dist/http/admission.js +17 -2
  151. package/dist/http/approval-sweeps.d.ts +1 -1
  152. package/dist/http/approval-sweeps.js +10 -7
  153. package/dist/http/checkpoint-ctx.d.ts +4 -0
  154. package/dist/http/checkpoint-ctx.js +2 -0
  155. package/dist/http/dispatch.d.ts +8 -3
  156. package/dist/http/dispatch.js +59 -32
  157. package/dist/http/durable-run-leg.js +16 -17
  158. package/dist/http/health-reader.d.ts +16 -9
  159. package/dist/http/health-reader.js +2 -1
  160. package/dist/http/health-self-report.d.ts +9 -1
  161. package/dist/http/health-self-report.js +3 -1
  162. package/dist/http/owner-access.d.ts +33 -14
  163. package/dist/http/owner-access.js +40 -10
  164. package/dist/http/principal-gate.d.ts +49 -21
  165. package/dist/http/principal-gate.js +61 -11
  166. package/dist/http/request-channel.d.ts +23 -0
  167. package/dist/http/request-channel.js +9 -0
  168. package/dist/http/request-guards.js +17 -2
  169. package/dist/http/resume-ctx-read.js +42 -3
  170. package/dist/http/resume-legs.d.ts +4 -3
  171. package/dist/http/resume-legs.js +367 -117
  172. package/dist/http/route-ctx.d.ts +91 -15
  173. package/dist/http/route-ctx.js +17 -0
  174. package/dist/http/route-table.d.ts +5 -1
  175. package/dist/http/route-table.js +4 -0
  176. package/dist/http/routes/admin-config-refresh.js +3 -3
  177. package/dist/http/routes/admin-drain.d.ts +3 -0
  178. package/dist/http/routes/admin-drain.js +7 -7
  179. package/dist/http/routes/admin-memory-optout.d.ts +1 -1
  180. package/dist/http/routes/admin-memory-optout.js +3 -3
  181. package/dist/http/routes/adoption.js +3 -5
  182. package/dist/http/routes/agents-roster.js +2 -3
  183. package/dist/http/routes/approvals-assistant.d.ts +2 -1
  184. package/dist/http/routes/approvals-assistant.js +99 -51
  185. package/dist/http/routes/background.d.ts +3 -3
  186. package/dist/http/routes/capabilities.d.ts +4 -0
  187. package/dist/http/routes/capabilities.js +38 -10
  188. package/dist/http/routes/config-catalog.js +2 -2
  189. package/dist/http/routes/devices.js +1 -1
  190. package/dist/http/routes/diagnostics.d.ts +3 -3
  191. package/dist/http/routes/diagnostics.js +19 -7
  192. package/dist/http/routes/fleet.js +10 -8
  193. package/dist/http/routes/images.js +10 -10
  194. package/dist/http/routes/memory-bundle.js +3 -3
  195. package/dist/http/routes/memory-compliance.js +3 -3
  196. package/dist/http/routes/memory-consolidation.js +2 -2
  197. package/dist/http/routes/memory-origin.js +3 -3
  198. package/dist/http/routes/memory-policy.js +2 -2
  199. package/dist/http/routes/observability.js +3 -3
  200. package/dist/http/routes/projects.d.ts +3 -2
  201. package/dist/http/routes/projects.js +4 -5
  202. package/dist/http/routes/retention-ops.js +3 -3
  203. package/dist/http/routes/rules.js +5 -5
  204. package/dist/http/routes/run-permission-mode.d.ts +2 -1
  205. package/dist/http/routes/run-permission-mode.js +2 -2
  206. package/dist/http/routes/runs.d.ts +4 -9
  207. package/dist/http/routes/runs.js +171 -65
  208. package/dist/http/routes/session-sync.d.ts +22 -9
  209. package/dist/http/routes/session-sync.js +204 -107
  210. package/dist/http/routes/sessions-list.js +13 -7
  211. package/dist/http/routes/sessions.js +30 -15
  212. package/dist/http/routes/tasks.js +46 -41
  213. package/dist/http/routes/trace-usage.js +2 -2
  214. package/dist/http/routes/workflows.js +1 -1
  215. package/dist/http/server.d.ts +30 -30
  216. package/dist/http/server.js +16 -4
  217. package/dist/http/submit-ctx.d.ts +1 -1
  218. package/dist/http/submit-ctx.js +7 -4
  219. package/dist/http/wire-types.d.ts +14 -4
  220. package/dist/human-facing-args.d.ts +33 -0
  221. package/dist/human-facing-args.js +33 -0
  222. package/dist/identity-source.d.ts +20 -3
  223. package/dist/identity-source.js +14 -0
  224. package/dist/index.d.ts +5 -1
  225. package/dist/k8s-api-credentials.d.ts +29 -0
  226. package/dist/k8s-api-credentials.js +25 -0
  227. package/dist/lane-home-probe.d.ts +3 -7
  228. package/dist/lane-home-probe.js +2 -2
  229. package/dist/leader/diffup.d.ts +19 -0
  230. package/dist/leader/diffup.js +7 -0
  231. package/dist/leader/leader.d.ts +116 -11
  232. package/dist/leader/leader.js +69 -5
  233. package/dist/leader/repair-wire.js +2 -2
  234. package/dist/leader/run-entry.d.ts +2 -1
  235. package/dist/leader/run-entry.js +1 -1
  236. package/dist/leader/wire.d.ts +42 -132
  237. package/dist/leader/wire.js +81 -67
  238. package/dist/leg-facts.d.ts +13 -5
  239. package/dist/leg-facts.js +2 -1
  240. package/dist/memory-scope.d.ts +23 -11
  241. package/dist/memory-scope.js +18 -6
  242. package/dist/memory-sync-client.d.ts +30 -2
  243. package/dist/memory-sync-client.js +16 -9
  244. package/dist/model-entry-headers.d.ts +9 -10
  245. package/dist/model-entry-headers.js +0 -4
  246. package/dist/model-entry-refusal.d.ts +7 -4
  247. package/dist/model-entry-refusal.js +11 -5
  248. package/dist/model-plane-face.d.ts +1 -1
  249. package/dist/model-plane-face.js +3 -1
  250. package/dist/model-route-endpoint.d.ts +13 -7
  251. package/dist/model-route-endpoint.js +14 -11
  252. package/dist/model-select.d.ts +22 -0
  253. package/dist/model-select.js +9 -0
  254. package/dist/model-unreachable-notice.d.ts +11 -0
  255. package/dist/model-unreachable-notice.js +4 -4
  256. package/dist/object-store-buckets.d.ts +640 -6
  257. package/dist/object-store-buckets.js +166 -0
  258. package/dist/observability/err-text.d.ts +7 -0
  259. package/dist/observability/err-text.js +5 -0
  260. package/dist/observability/fail-open.d.ts +25 -17
  261. package/dist/observability/fail-open.js +25 -17
  262. package/dist/observability/logger.js +3 -1
  263. package/dist/observability/metrics.js +1 -0
  264. package/dist/operator-roster.d.ts +68 -0
  265. package/dist/operator-roster.js +32 -0
  266. package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
  267. package/dist/orchestration/workflow-notify-journal.js +12 -1
  268. package/dist/orchestration/workflow-park-decision.d.ts +70 -18
  269. package/dist/orchestration/workflow-park-decision.js +49 -10
  270. package/dist/orchestration/workflow-park-holder.d.ts +65 -0
  271. package/dist/orchestration/workflow-park-holder.js +98 -0
  272. package/dist/orchestration/workflow-record-fence.d.ts +36 -0
  273. package/dist/orchestration/workflow-record-fence.js +42 -0
  274. package/dist/outbound-dispatcher.d.ts +71 -8
  275. package/dist/outbound-dispatcher.js +48 -7
  276. package/dist/owner-faces.d.ts +2 -2
  277. package/dist/parked-decide.d.ts +106 -55
  278. package/dist/parked-decide.js +153 -117
  279. package/dist/peer-directory.d.ts +2 -2
  280. package/dist/peer-inbound-face.d.ts +2 -6
  281. package/dist/peer-inbound-face.js +0 -3
  282. package/dist/permission-mode-admission.d.ts +74 -5
  283. package/dist/permission-mode-admission.js +56 -3
  284. package/dist/plugins/adoption-log-sql.d.ts +3 -1
  285. package/dist/plugins/adoption-log-sql.js +7 -1
  286. package/dist/plugins/approval-ask-store-file.d.ts +14 -2
  287. package/dist/plugins/approval-ask-store-file.js +11 -0
  288. package/dist/plugins/approval-ask-store-memory.d.ts +10 -1
  289. package/dist/plugins/approval-ask-store-memory.js +35 -10
  290. package/dist/plugins/approval-ask-store-sql.d.ts +69 -4
  291. package/dist/plugins/approval-ask-store-sql.js +45 -5
  292. package/dist/plugins/approval-exemption-store.js +3 -0
  293. package/dist/plugins/approval-nonce-store.js +2 -0
  294. package/dist/plugins/blob-backend.d.ts +83 -7
  295. package/dist/plugins/blob-backend.js +57 -6
  296. package/dist/plugins/breaker-state-sql.js +2 -0
  297. package/dist/plugins/caching-session-store.d.ts +9 -15
  298. package/dist/plugins/caching-session-store.js +6 -0
  299. package/dist/plugins/checkpoint-index-columns.d.ts +20 -16
  300. package/dist/plugins/checkpoint-index-columns.js +3 -6
  301. package/dist/plugins/checkpoint-store-face.d.ts +119 -61
  302. package/dist/plugins/checkpoint-store-face.js +134 -55
  303. package/dist/plugins/device-store-sql.js +6 -0
  304. package/dist/plugins/error-origin.d.ts +18 -0
  305. package/dist/plugins/error-origin.js +10 -0
  306. package/dist/plugins/execution-placement-sql.js +6 -6
  307. package/dist/plugins/image-bake-store-sql.js +6 -0
  308. package/dist/plugins/image-index-sql.js +4 -0
  309. package/dist/plugins/landed-attendants.d.ts +212 -0
  310. package/dist/plugins/landed-attendants.js +161 -0
  311. package/dist/plugins/leader-run-store-sql.js +4 -0
  312. package/dist/plugins/local-checkpoint-store.d.ts +13 -3
  313. package/dist/plugins/local-checkpoint-store.js +38 -49
  314. package/dist/plugins/local-session-live-reference.d.ts +40 -0
  315. package/dist/plugins/local-session-live-reference.js +39 -0
  316. package/dist/plugins/local-session-store.d.ts +71 -33
  317. package/dist/plugins/local-session-store.js +129 -27
  318. package/dist/plugins/memory-engine-pg.js +4 -0
  319. package/dist/plugins/memory-engine-sql-apply.js +5 -2
  320. package/dist/plugins/memory-engine-tidb.js +4 -0
  321. package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
  322. package/dist/plugins/memory-sync-store-pg.js +5 -0
  323. package/dist/plugins/memory-sync-store-tidb.js +5 -0
  324. package/dist/plugins/one-time-migrations.d.ts +104 -80
  325. package/dist/plugins/one-time-migrations.js +226 -132
  326. package/dist/plugins/org-delivery-quota-store.js +4 -1
  327. package/dist/plugins/outcome-ledger-sql.js +2 -0
  328. package/dist/plugins/permission-rule-store-sql.js +11 -4
  329. package/dist/plugins/pg-cost-quota.js +4 -0
  330. package/dist/plugins/pg-pool.js +35 -10
  331. package/dist/plugins/pg-rate-limiter.js +2 -0
  332. package/dist/plugins/posix-shell-fs.d.ts +6 -1
  333. package/dist/plugins/posix-shell-fs.js +4 -1
  334. package/dist/plugins/remote-env-adb.d.ts +19 -15
  335. package/dist/plugins/remote-env-adb.js +41 -15
  336. package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
  337. package/dist/plugins/remote-env-connect-seat.js +72 -0
  338. package/dist/plugins/remote-env-device.d.ts +22 -5
  339. package/dist/plugins/remote-env-device.js +106 -8
  340. package/dist/plugins/remote-env-e2b.d.ts +15 -6
  341. package/dist/plugins/remote-env-e2b.js +42 -32
  342. package/dist/plugins/remote-env-file-error.js +6 -2
  343. package/dist/plugins/remote-env-host.d.ts +46 -10
  344. package/dist/plugins/remote-env-host.js +124 -52
  345. package/dist/plugins/remote-env-k8s.d.ts +109 -41
  346. package/dist/plugins/remote-env-k8s.js +160 -54
  347. package/dist/plugins/remote-env-local-docker.d.ts +13 -8
  348. package/dist/plugins/remote-env-local-docker.js +34 -41
  349. package/dist/plugins/remote-env-ssh.d.ts +18 -12
  350. package/dist/plugins/remote-env-ssh.js +60 -59
  351. package/dist/plugins/remote-shell.d.ts +98 -1
  352. package/dist/plugins/remote-shell.js +218 -0
  353. package/dist/plugins/replica-registration.d.ts +1 -1
  354. package/dist/plugins/replica-registration.js +1 -1
  355. package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
  356. package/dist/plugins/resume-anchor-store-sql.js +12 -5
  357. package/dist/plugins/retention-lane-store-sql.js +4 -0
  358. package/dist/plugins/retention-sql.d.ts +20 -2
  359. package/dist/plugins/retention-sql.js +11 -0
  360. package/dist/plugins/run-store-sql.d.ts +21 -2
  361. package/dist/plugins/run-store-sql.js +31 -7
  362. package/dist/plugins/s3-presign.d.ts +23 -0
  363. package/dist/plugins/s3-presign.js +37 -3
  364. package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
  365. package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
  366. package/dist/plugins/scheduler-support.d.ts +2 -2
  367. package/dist/plugins/scheduler-support.js +0 -3
  368. package/dist/plugins/schema-consistency.d.ts +4 -2
  369. package/dist/plugins/schema-consistency.js +19 -2
  370. package/dist/plugins/schema-indexes.js +2 -0
  371. package/dist/plugins/send-file-ledger.d.ts +2 -2
  372. package/dist/plugins/send-file-ledger.js +5 -2
  373. package/dist/plugins/send-user-file.d.ts +3 -4
  374. package/dist/plugins/send-user-file.js +56 -52
  375. package/dist/plugins/serving-requirement.d.ts +26 -7
  376. package/dist/plugins/serving-requirement.js +11 -4
  377. package/dist/plugins/session-birth.d.ts +6 -2
  378. package/dist/plugins/session-blob-claim-token.d.ts +15 -0
  379. package/dist/plugins/session-blob-claim-token.js +20 -0
  380. package/dist/plugins/session-blob-namespace.d.ts +46 -0
  381. package/dist/plugins/session-blob-namespace.js +116 -0
  382. package/dist/plugins/session-capture-record-store-sql.js +2 -0
  383. package/dist/plugins/session-ext-table.d.ts +14 -1
  384. package/dist/plugins/session-ext-table.js +5 -1
  385. package/dist/plugins/session-row-sql.d.ts +49 -2
  386. package/dist/plugins/session-row-sql.js +56 -13
  387. package/dist/plugins/session-store-sql.d.ts +34 -18
  388. package/dist/plugins/session-store-sql.js +98 -17
  389. package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
  390. package/dist/plugins/shared-memory-store-sql.js +6 -2
  391. package/dist/plugins/snapshot-bucket-presence.d.ts +25 -2
  392. package/dist/plugins/snapshot-bucket-presence.js +8 -2
  393. package/dist/plugins/sql-driver.d.ts +2 -1
  394. package/dist/plugins/sql-driver.js +18 -3
  395. package/dist/plugins/sql-errors.d.ts +11 -6
  396. package/dist/plugins/sql-errors.js +5 -6
  397. package/dist/plugins/sql-json-column.d.ts +1 -1
  398. package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
  399. package/dist/plugins/stop-then-start-sentence.js +14 -10
  400. package/dist/plugins/stop-then-start.d.ts +109 -0
  401. package/dist/plugins/stop-then-start.js +104 -0
  402. package/dist/plugins/store-backend.d.ts +84 -15
  403. package/dist/plugins/store-backend.js +236 -72
  404. package/dist/plugins/store-boundary.d.ts +57 -0
  405. package/dist/plugins/store-boundary.js +139 -0
  406. package/dist/plugins/store-contracts.d.ts +17 -0
  407. package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
  408. package/dist/plugins/store-fault-sentence-m53.js +25 -0
  409. package/dist/plugins/store-fault.d.ts +26 -7
  410. package/dist/plugins/store-fault.js +18 -2
  411. package/dist/plugins/task-attachment-store.d.ts +2 -1
  412. package/dist/plugins/task-attachment-store.js +14 -1
  413. package/dist/plugins/task-list-store-sql.d.ts +2 -2
  414. package/dist/plugins/task-list-store-sql.js +10 -8
  415. package/dist/plugins/tidb-cost-quota.js +4 -0
  416. package/dist/plugins/tidb-pool.js +21 -25
  417. package/dist/plugins/tidb-rate-limiter.js +4 -0
  418. package/dist/plugins/user-input-ledger-sql.js +4 -0
  419. package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
  420. package/dist/plugins/workflow-run-store-sql.js +64 -4
  421. package/dist/plugins/workspace-custody.d.ts +4 -3
  422. package/dist/plugins/workspace-fill.d.ts +4 -7
  423. package/dist/plugins/workspace-fill.js +2 -1
  424. package/dist/plugins/write-behind-counter.js +5 -0
  425. package/dist/project-context.d.ts +0 -2
  426. package/dist/project-context.js +4 -8
  427. package/dist/project-registry.d.ts +46 -0
  428. package/dist/project-registry.js +44 -0
  429. package/dist/question.d.ts +2 -1
  430. package/dist/question.js +5 -13
  431. package/dist/request-form.d.ts +6 -1
  432. package/dist/request-form.js +4 -1
  433. package/dist/request-key-closure.js +1 -1
  434. package/dist/request-value-closure.d.ts +4 -0
  435. package/dist/request-value-closure.js +10 -0
  436. package/dist/rule-issue-reading.d.ts +1 -1
  437. package/dist/rules-consent.d.ts +1 -1
  438. package/dist/run-acceptance.d.ts +3 -2
  439. package/dist/run-acceptance.js +4 -6
  440. package/dist/run-local.js +9 -9
  441. package/dist/runs.d.ts +54 -16
  442. package/dist/runs.js +67 -13
  443. package/dist/runtime-governance.d.ts +5 -4
  444. package/dist/security.d.ts +30 -32
  445. package/dist/security.js +41 -7
  446. package/dist/sema-config-dir.d.ts +2 -1
  447. package/dist/server-secret-env.d.ts +12 -10
  448. package/dist/server-secret-env.js +24 -15
  449. package/dist/session-bindings.d.ts +82 -0
  450. package/dist/session-bindings.js +18 -0
  451. package/dist/session-children-retire.d.ts +2 -2
  452. package/dist/session-children-retire.js +2 -6
  453. package/dist/session-deletion.d.ts +16 -1
  454. package/dist/session-error-wire.d.ts +3 -3
  455. package/dist/session-error-wire.js +3 -3
  456. package/dist/session-incarnation.d.ts +10 -0
  457. package/dist/session-incarnation.js +10 -1
  458. package/dist/session-kind.d.ts +57 -0
  459. package/dist/session-kind.js +22 -0
  460. package/dist/session-row.d.ts +21 -1
  461. package/dist/session-row.js +7 -1
  462. package/dist/session-sync-kernel.d.ts +24 -14
  463. package/dist/session-sync-kernel.js +3 -6
  464. package/dist/session-sync.d.ts +25 -103
  465. package/dist/session-sync.js +14 -76
  466. package/dist/session-titler.d.ts +10 -3
  467. package/dist/session-titler.js +19 -6
  468. package/dist/ssh-host-key.d.ts +5 -0
  469. package/dist/ssh-host-key.js +3 -0
  470. package/dist/stores-sql/blob-index-sql.d.ts +30 -9
  471. package/dist/stores-sql/blob-index-sql.js +40 -21
  472. package/dist/stores-sql/checkpoint-store-sql.d.ts +54 -27
  473. package/dist/stores-sql/checkpoint-store-sql.js +70 -146
  474. package/dist/stores-sql/file-history-store-sql.d.ts +113 -15
  475. package/dist/stores-sql/file-history-store-sql.js +205 -95
  476. package/dist/stores-sql/pg-session-storage.d.ts +34 -7
  477. package/dist/stores-sql/pg-session-storage.js +37 -13
  478. package/dist/stores-sql/retention-store-sql.d.ts +1 -9
  479. package/dist/stores-sql/retention-store-sql.js +5 -19
  480. package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
  481. package/dist/stores-sql/session-policy-store-sql.js +61 -44
  482. package/dist/stores-sql/session-write-hooks.d.ts +11 -0
  483. package/dist/stores-sql/tidb-session-store.d.ts +58 -7
  484. package/dist/stores-sql/tidb-session-store.js +37 -13
  485. package/dist/submission-exit.d.ts +3 -2
  486. package/dist/submission-exit.js +9 -1
  487. package/dist/task-cwd.d.ts +2 -2
  488. package/dist/task-settings.d.ts +7 -5
  489. package/dist/task-settings.js +3 -3
  490. package/dist/terminal.d.ts +33 -2
  491. package/dist/terminal.js +139 -9
  492. package/dist/tool-approval.d.ts +465 -507
  493. package/dist/tool-approval.js +606 -1222
  494. package/dist/trace/core-keyset-guard.d.ts +1 -1
  495. package/dist/trace/ledger-events.d.ts +3 -3
  496. package/dist/trace/project.d.ts +2 -3
  497. package/dist/trace/redact.js +3 -2
  498. package/dist/trace/self-minted-wire.d.ts +571 -178
  499. package/dist/trace/self-minted-wire.js +189 -56
  500. package/dist/web-admin-client/apply-effective.js +2 -2
  501. package/dist/web-admin-client/read-warnings.d.ts +2 -2
  502. package/dist/web-admin-client/read-warnings.js +1 -1
  503. package/dist/web-admin-client/types.d.ts +1 -1
  504. package/dist/workspace-space.d.ts +10 -4
  505. package/dist/workspace-space.js +4 -1
  506. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +79 -28
  507. package/package.json +7 -3
  508. package/scripts/embed-minimal.mjs +3 -3
  509. package/wire-changes/server@7.151.0.json +762 -0
  510. package/wire-changes/server@7.152.0.json +900 -0
  511. package/dist/config-d-migration.d.ts +0 -37
  512. package/dist/config-d-migration.js +0 -60
  513. package/dist/http/session-inherit-env.d.ts +0 -36
  514. package/dist/http/session-inherit-env.js +0 -6
@@ -40,7 +40,7 @@ export declare function persistSubmitCtx(store: SubmitCtxStore, deps: {
40
40
  * 提交腿写续跑输入的入口(三个调用点同调这一只):体与标记按受理座提交时交出的那一份定(见文件头「体里的目标按哪一份写」),只写这一笔。
41
41
  * 写不进的处置与答复 = {@link persistSubmitCtx}(本函数只定体、不另判)。
42
42
  */
43
- export declare function persistSubmissionCtx(store: SubmitCtxStore, deps: Parameters<typeof persistSubmitCtx>[1], claim: Parameters<typeof persistSubmitCtx>[2], prepared: Pick<PreparedTaskSubmission, "body" | "auth" | "verify" | "acceptance" | "bodyFromScreenedCtx"> & Partial<Pick<PreparedTaskSubmission, "legFacts">> & {
43
+ export declare function persistSubmissionCtx(store: SubmitCtxStore, deps: Parameters<typeof persistSubmitCtx>[1], claim: Parameters<typeof persistSubmitCtx>[2], prepared: Pick<PreparedTaskSubmission, "body" | "auth" | "verify" | "acceptance" | "bodyFromScreenedCtx" | "bodyPermissionModeWrite"> & Partial<Pick<PreparedTaskSubmission, "legFacts">> & {
44
44
  readonly spec: Pick<PreparedTaskSubmission["spec"], "sessionId" | "model">;
45
45
  }): Promise<SubmitCtxRefusal | typeof SUBMIT_CTX_CLAIM_LOST | undefined>;
46
46
  //# sourceMappingURL=submit-ctx.d.ts.map
@@ -7,6 +7,7 @@ import { limitFactsUnmeasured } from "../limit-refusal.js";
7
7
  import { serviceVersion } from "../service-version.js";
8
8
  import { recordFailOpen } from "../observability/fail-open.js";
9
9
  import { DEFAULT_MODEL_REF } from "../model-select.js";
10
+ import { submissionPermissionModeWrite } from "../permission-mode-admission.js";
10
11
  const WITHHELD_OBJECTIVE = "";
11
12
  export function objectiveWithheldIn(ctx) {
12
13
  return ctx.promptScreened === true;
@@ -29,11 +30,11 @@ function unsealableRefusal(e) {
29
30
  function rowTooLargeRefusal(tooLarge) {
30
31
  switch (tooLarge.wall) {
31
32
  case "row":
32
- return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's single-row limit (TiDB performance.txn-entry-size-limit)`, facts: limitFactsUnmeasured("body", "bytes") }) };
33
+ return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's single-row limit (TiDB performance.txn-entry-size-limit)`, facts: limitFactsUnmeasured("body", "bytes") }) };
33
34
  case "statement":
34
- return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's max_allowed_packet`, facts: limitFactsUnmeasured("body", "bytes") }) };
35
+ return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's max_allowed_packet`, facts: limitFactsUnmeasured("body", "bytes") }) };
35
36
  case "value":
36
- return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value (${tooLarge.dbMessage}) — nothing was run; shrink the inline images / userAttachments`, facts: limitFactsUnmeasured("body", "bytes") }) };
37
+ return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value — nothing was run; shrink the inline images / userAttachments`, facts: limitFactsUnmeasured("body", "bytes") }) };
37
38
  default: {
38
39
  const unhandled = tooLarge.wall;
39
40
  throw new Error(`row-too-large refusal without an HTTP answer: ${String(unhandled)}`);
@@ -62,7 +63,7 @@ export async function persistSubmitCtx(store, deps, claim, sessionId, fields) {
62
63
  }
63
64
  if (tooLarge === undefined)
64
65
  throw err;
65
- deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall, db: tooLarge.dbMessage });
66
+ deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall });
66
67
  return rowTooLargeRefusal(tooLarge);
67
68
  }
68
69
  return landed === "claim_released" ? SUBMIT_CTX_CLAIM_LOST : undefined;
@@ -77,7 +78,9 @@ export async function persistSubmissionCtx(store, deps, claim, prepared) {
77
78
  memoryScope: prepared.auth?.memoryScope,
78
79
  ...(screened || prepared.bodyFromScreenedCtx === true ? { promptScreened: true } : {}),
79
80
  ...(prepared.legFacts?.projectContext !== undefined ? { projectContext: prepared.legFacts.projectContext } : {}),
81
+ ...(prepared.legFacts?.memorySeed !== undefined ? { memorySeed: prepared.legFacts.memorySeed } : {}),
80
82
  writerVersion: serviceVersion(),
83
+ permissionModeWrite: prepared.bodyPermissionModeWrite !== undefined ? prepared.bodyPermissionModeWrite.stored : submissionPermissionModeWrite(prepared.body),
81
84
  });
82
85
  }
83
86
  //# sourceMappingURL=submit-ctx.js.map
@@ -41,6 +41,14 @@ export interface TaskRequestAttachments {
41
41
  export interface TaskRequestBody {
42
42
  objective: string;
43
43
  sessionId?: string;
44
+ /**
45
+ * 这一次提交建的会话是哪一**种**(闭集一词 `"sidechain"` = 客户端放置的子代对话;缺席 = 顶层对话;律在 `session-kind.ts`)。
46
+ * 只在**建这只会话的那一笔**写下(不带 `sessionId` / 带一只还不存在的 id),此后终身不改:带键提交到一只既有的会话 ⇒ 种类相等照常、不等 409
47
+ * `conflict.session_kind_mismatch`(会话一字节不变,体上机读位 `sessionKind` = 行上的词,顶层行缺席);不带键 = 不声明(续轮不必重发)。
48
+ * 词表外 ⇒ 400 `request.field_invalid`;部署记不了种类(能力位 `sessionKinds` 为空)⇒ 400 `request.precondition_unmet`,都在任何写之前。
49
+ * 续跑腿不读不判(键随存体留着)。
50
+ */
51
+ sessionKind?: "sidechain";
44
52
  /** Which deployment SCENARIO assembles this task's tools/prompt/skills (the keys of the worker's scenario
45
53
  * table — e.g. "default"/"code"/"code-review"/"scan"/"cowork"). An INTENT bounded by the deployment's own table AND,
46
54
  * on a governed worker, by the principal's center-resolved allowlist: an unknown name is a typed 400
@@ -240,7 +248,9 @@ export interface TaskRequestBody {
240
248
  * (unknown ⇒ 404 `rewind_files_to.unknown_event`). Honored ONLY when `resumeAt` is ABSENT (the two modes are mutually
241
249
  * exclusive). Requires the anchor map + a FileHistoryStore + the session store's head read (capability
242
250
  * `rewindFilesTo`). Its out-of-run twin — no run, no model call — is `POST /v1/sessions/:id/rewind-files` with the same
243
- * handle in `to` (capability `sessionRewindFiles`). */
251
+ * handle in `to` (capability `sessionRewindFiles`). Not accepted together with `cascade: true` — the ladder's rungs
252
+ * run on sessions the engine mints, so there is no history of this session to restore from ⇒ 400 `request.field_conflict`
253
+ * (`reason: "cascade_verify"`, `fields: ["rewindFilesTo", "cascade"]`) at admission, before any side effect. */
244
254
  rewindFilesTo?: string;
245
255
  /** [ref](core 7.31.0 [ref] `TaskSpec.fileHistory`)—— 请求级的**文件历史关断词**,唯一词 `"disabled"`(core 的拼法,
246
256
  * 与 `checkpointStore` 同;没有 `"enabled"` —— 缺席就是「部署说了算」的唯一形,声明只能单向收紧)。`"disabled"` ⇒
@@ -449,9 +459,9 @@ export interface TaskRequestBody {
449
459
  * authorizer(core `PROJECT_ID_REGEX`,不合形状=422 typed `invalid_project_id`)。**大小写不敏感收、
450
460
  * 归一小写用**([ref]/[ref]:词法与 core 的格式单源对齐,带 /i;收下后折小写再派生 scope/查表 ——
451
461
  * 同一个 id 的两种大小写写法落同一只记忆盘)。多租户 DB 记忆面下它把派生
452
- * scope 从 user 盘切到项目盘(`proj:<tenant>/<projectId>`)并以 config.projects[projectId].defaultScopes
453
- * 作 memory.scopes 种子;单用户部署忽略派生(memoryScopeFor 不变),仅 defaultScopes 种子生效。
454
- * Rides the persisted body onto resume legs(与 memoryWrite 同姿势)。
462
+ * scope 从 user 盘切到项目盘(`proj:<tenant>/<projectId>`);它对提交者**可见**时(`project-registry.ts`,与 `GET /v1/projects/:id` 同一只判)
463
+ * 那只登记的 defaultScopes 作 memory.scopes 种子(看不见 / 未登记 ⇒ 无种子,同答);单用户部署忽略派生(memoryScopeFor 不变),仅种子生效。
464
+ * Rides the persisted body onto resume legs(与 memoryWrite 同姿势)—— 种子不随体:续跑腿只认提交腿冻结的种子(`CheckpointCtx.memorySeed`,以冻结的观者重判)。
455
465
  * 7.150.0 起它(或会话行上声明过的项目)也选这条 run **继承的项目上下文**(`project-context.ts`;能力位 `projectInheritance`):登记对提交者可见且带内容证明 ⇒
456
466
  * 项目简报进系统提示追加折叠的中段、射程内第一条 folder 填缺席的 `cwd`;判一次、随 run 冻结。项目继承来的成员参与的拒,`fields` 以本键为坐标。 */
457
467
  projectId?: string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 给人看的调用入参 —— **唯一一份读法**。三处读者同调这一只函数:活卡的 `args`(`tool-approval.ts` 的卡帧 / `card_json` / 续跑拒体的 `acceptableForm`)、
3
+ * 停驻行的 `input`(`plugins/checkpoint-store-face.ts` 的 `boundedToolInput`:两孪生都在读时从停驻快照的待决动作投影,不存第二份)、问帧的 `questions`(`question.ts`)。
4
+ *
5
+ * 律(一条):**脱敏 → 序列化 → 按 UTF-8 字节量 → 对一个常量判;卡的种类决定超了怎样。**
6
+ * · 入参**就是**人要决的东西(问:题干与选项;计划:要批的计划正文)⇒ 整份给出、从不折叠。折掉它,人能做的只剩拒答 —— 那就不该把 run 停在他面前;
7
+ * 同一份字节(模型原调用的那一份)本就随 `tool_start.args` 不封顶地进了同一条流与账本,在这里封顶挡不住它,只制造「活面不给看、停驻行给折叠」两种盲。
8
+ * · 其余动作卡 ⇒ 超常量即折叠(活卡 `argsOmitted`、停驻行 `{ truncated: true, bytes }`):盲批的安全答是「不」,动作卡的保留部分在兄弟格上
9
+ * (卡的 `message`、停驻行的 `riskDescriptor.summary` / `touchedPaths`),帽买到的是队列列举 / 流 upsert / `card_json` 少一份大拷贝。
10
+ * · 无卡(引擎没铸卡词:更早的停驻行 / 非审批门;集外词在读点已读作无卡)⇒ 按动作折(有界是 fail-safe 方向)。
11
+ * 序列化不出(BigInt / 抛错的 `toJSON`;环在脱敏遍历里已被断开成 `[circular]`)⇒ 折叠、`bytes: null` —— 没有可给的整份,问 / 计划卡同此。
12
+ *
13
+ * 卡是哪一张只有引擎铸的 `approvalCard` 一个事实源(`approval-content-kind.ts` 的律:不从工具名回推):活卡读 `AskRequest.approvalCard`,停驻行读门上那一格
14
+ * (SQL 孪生 = `approval_card` / `gate_kind` 两列,LOCAL 孪生 = 门本身,同一只 `parkedApprovalCard`);调用方读定后交进来,本模块不读卡。
15
+ * 如实:这是一只函数、三处调用、同一判定,不是「一次判定先于所有落点」—— 各面在自己的时刻对自己手里的那份入参判,同一份入参在各面答同一个结局。
16
+ */
17
+ import type { ToolApprovalCard } from "@sema-agent/core";
18
+ /**
19
+ * 动作卡入参给人看的上限:脱敏后 JSON 的 **UTF-8 字节数**。取值:本版之前停驻行的帽是 8192 个 UTF-16 单元,一个单元至多 3 个 UTF-8 字节(`\uXXXX` 转义 6 单元 6 字节)
20
+ * ⇒ 那一帽下整份的入参最坏 24576 字节 < 本值 —— 停驻行、活卡、问三面相对上一版零收窄。
21
+ */
22
+ export declare const HUMAN_FACING_ARGS_BYTES = 32768;
23
+ /** 一份入参给人看的结局:整份(脱敏后的值)或折叠(`bytes` = 脱敏后 JSON 的 UTF-8 字节数;序列化不出 ⇒ `null`)。纯数据。 */
24
+ export type HumanFacingArgs = {
25
+ readonly kind: "whole";
26
+ readonly value: unknown;
27
+ } | {
28
+ readonly kind: "omitted";
29
+ readonly bytes: number | null;
30
+ };
31
+ /** 见模块头注的律。`card` = 调用方读定的卡(无卡 ⇒ `undefined`)。 */
32
+ export declare function humanFacingArgs(args: unknown, card: ToolApprovalCard | undefined): HumanFacingArgs;
33
+ //# sourceMappingURL=human-facing-args.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { redactDeep } from "./trace/redact.js";
2
+ export const HUMAN_FACING_ARGS_BYTES = 32768;
3
+ const ARGS_ARE_THE_DECISION = {
4
+ question: true,
5
+ plan: true,
6
+ "file-edit": false,
7
+ "file-write": false,
8
+ "notebook-edit": false,
9
+ shell: false,
10
+ fetch: false,
11
+ skill: false,
12
+ workflow: false,
13
+ generic: false,
14
+ "computer-access": false,
15
+ "computer-control": false,
16
+ };
17
+ export function humanFacingArgs(args, card) {
18
+ const redacted = redactDeep(args);
19
+ let text;
20
+ try {
21
+ text = JSON.stringify(redacted);
22
+ }
23
+ catch {
24
+ return { kind: "omitted", bytes: null };
25
+ }
26
+ if (text === undefined)
27
+ return { kind: "omitted", bytes: null };
28
+ if (card !== undefined && ARGS_ARE_THE_DECISION[card])
29
+ return { kind: "whole", value: redacted };
30
+ const bytes = Buffer.byteLength(text, "utf8");
31
+ return bytes > HUMAN_FACING_ARGS_BYTES ? { kind: "omitted", bytes } : { kind: "whole", value: redacted };
32
+ }
33
+ //# sourceMappingURL=human-facing-args.js.map
@@ -2,7 +2,7 @@
2
2
  * **身份来源闭集 + run 行身份元组** —— 叶子模块(零依赖):凭据门(`http/principal-gate.ts`)、run 店契约(`plugins/store-contracts.ts`)、
3
3
  * 三只 run 店与 leader run 店(`plugins/leader-run-store-sql.ts`)、中央建表语句(`plugins/tidb-pool.ts` / `plugins/pg-pool.ts`)与 `/health` 自报位读同一份。
4
4
  *
5
- * ## 律(三句;全仓只在这里写一次)
5
+ * ## 律(五条;全仓只在这里写一次)
6
6
  * 1. **一张表、一个次序**:{@link IDENTITY_SOURCES} 的序 = 凭据门的判定次序(`verifiedIdentitySource` 答表里第一个验得过的词)= `/health.auth.kinds` 的出现序。
7
7
  * 出示了部署的 service 凭据就是 `service_token` —— 哪怕同一枚 Bearer 也被鉴权桥验成登录令牌、哪怕运维给这枚凭据起的系统名叫 `sso`;
8
8
  * 验不过 service 凭据而鉴权桥挂了身份 ⇒ `sso`;都没有而直连门 principal 令牌验过 ⇒ `direct_door_jwt`。
@@ -15,6 +15,10 @@
15
15
  * 4. **令牌声明装不进它的列就不记**(不截断:截断 = 两个不同的值折成一个):`sso` 臂从验过的令牌铸元组时,某一格装不进它的列宽({@link RUN_IDENTITY_CLAIM_COLUMNS})
16
16
  * ⇒ 那一格「未记录」—— 可空的格(化身号)记 `null`;必填的格(scope)装不下就铸不出合形元组 ⇒ 无元组。两格结果不同来自元组的型,不是两条规则:
17
17
  * 同一只判({@link runIdentityClaimOverflow})、同一行告警 `run_identity_claim_unrecorded { claim, chars, max }`(凭据门的铸点发;只名与长度,不带值)。
18
+ * 5. **凭据门认哪几类来源,一列答**({@link passesCredentialGate}):service 凭据与鉴权桥验过的登录令牌过门,直连门 principal 令牌不过(它只证审批决定者是谁)。
19
+ * 两道门读这同一列、各问各的事:全局凭据门(401)只在部署配了 service 凭据时武装({@link hasServiceAuth});fail-closed 写门(503:计费提交 / bake / 改写门 /
20
+ * 破坏性会话写 / 停驻赎回开新腿)恒武装,问的是**这次请求**带没带过门的凭据,`ALLOW_UNAUTHED_WRITES` 是它唯一的逃生口 —— 写门不读任何部署级布尔:
21
+ * 部署接没接过门的来源,落在「这次请求验不验得出」里(没接 ⇒ 没有一次请求验得出 ⇒ 照拒)。
18
22
  *
19
23
  * 化身号 `principalInc`:令牌 `sub_inc` 声明原样(契约包 `VerifiedIdentity.principalInc`)。来源链只有一条 —— 验证器读出 → 注入边界再判形(`auth-bridge.ts` 的
20
24
  * `admitBridgeIdentity`)→ 入口预认证挂 request-local(`security.ts` 的 `setSsoPrincipalInc`)→ 凭据门 `admitRunIdentity` 的 `sso` 臂铸进元组(律 4)→ 建行原样写入。
@@ -46,9 +50,22 @@ export declare function authBridgeIssuerOf(config: Pick<IdentitySourceConfig, "a
46
50
  readonly issuer: string;
47
51
  readonly source: "explicit" | "fallback";
48
52
  } | undefined;
49
- /** 「这台部署配了任何一把 service 凭证吗」—— fail-closed 写门族的真值源,也是身份来源 `service_token` 接没接线的那一句。**单一属主**:全局凭据门(`http/dispatch.ts`)、
50
- * 停驻行的赎回席(`http/approval-sweeps.ts`)、记忆整理阀门的启动期告警(`boot/stage-06-runners.ts`)、以及 {@link configuredIdentitySources} 读同一句(手抄迟早只改一处,而这条判据决定的是「无凭证部署上写口开不开」)。 */
53
+ /**
54
+ * 「这台部署配了任何一把 service 凭证吗」—— 身份来源 `service_token` 接没接线的那一句,也是**全局凭据门的武装谓词**(配了 ⇒ 门后各口不带过门凭据就 401;
55
+ * 没配 ⇒ 门不武装,写门照样只认过门的凭据,见文件头律 5)。**单一属主**(手抄迟早只改一处):全局凭据门的武装(`http/dispatch.ts`)、门前读路谓词与 `/health` 读者档
56
+ * (同文件 `readCredentialOk` / `healthReaderOf`,问的都是「门武装没有」)、监听收窄与两条单用户边界不变量(`bind-host.ts` 的 `bindMustNarrow`,`config-invariants.ts`)、
57
+ * 多租无 fleet 凭据的启动期告警(`boot/stage-07-capability-layer.ts`)、以及 {@link configuredIdentitySources} 读同一句。**不是**写门的判据(写门问请求,律 5)。
58
+ */
51
59
  export declare function hasServiceAuth(config: Pick<IdentitySourceConfig, "authToken" | "authTokens">): boolean;
60
+ /** 凭据门认的那几类来源(律 5;{@link passesCredentialGate} 收窄到它)。 */
61
+ export type CredentialGateSource = Extract<IdentitySource, "service_token" | "sso">;
62
+ /**
63
+ * 🔴 **律 5 的那一列:这一类来源过不过凭据门**(缺席 = 这次请求没有验过的来源 ⇒ 不过)。service 凭据是部署发的凭据;鉴权桥验过的登录令牌由本部署信任的签发方签、
64
+ * 主体就是令牌里的那一位(主体头盖不过它);直连门 principal 令牌只证审批决定者是谁,从来不替代凭据。穷举:加一个来源不接这里 ⇒ 编译红。
65
+ * 读者:全局凭据门的 401 与 fail-closed 写门的 503(`http/dispatch.ts`,读同一次 `verifiedIdentitySource` 的答案)、停驻赎回席(`http/approval-sweeps.ts`)、
66
+ * 以及它在部署上的投影 —— 部署形表行 `credentialGateSource`(`deployment-shape.ts`;请求面不读那一行,写门问的是请求)。
67
+ */
68
+ export declare function passesCredentialGate(kind: IdentitySource | undefined): kind is CredentialGateSource;
52
69
  /**
53
70
  * 🔴 **「这台部署能回哪几个身份来源」的唯一读法**({@link IDENTITY_SOURCES} 里配置接了线的那几个词,序同表)。读者:部署形表的 `identity` 轴
54
71
  * (`deployment-shape.ts`,「有没有身份边界」那一行由它答)、`/health.auth`(自报位,`http/health-self-report.ts`)、server-as-peer 受众门(`http/server.ts`)。
@@ -23,6 +23,20 @@ function identitySourceConfigured(kind, config) {
23
23
  }
24
24
  }
25
25
  }
26
+ export function passesCredentialGate(kind) {
27
+ switch (kind) {
28
+ case "service_token":
29
+ case "sso":
30
+ return true;
31
+ case "direct_door_jwt":
32
+ case undefined:
33
+ return false;
34
+ default: {
35
+ const unknownKind = kind;
36
+ throw new Error(`identity sources: unknown identity source ${String(unknownKind)}`);
37
+ }
38
+ }
39
+ }
26
40
  export function configuredIdentitySources(config) {
27
41
  return IDENTITY_SOURCES.filter((k) => identitySourceConfigured(k, config));
28
42
  }
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { RateLimiter, type RateDecision } from "./observability/rate-limit.js";
20
20
  export { GiteaClient, GitHubClient, createRepoClient, GIT_API_KINDS, isGitApiKind, repoToolsFor, parseRepo, type GitApiKind, type RepoCoords, type RepoReadClient } from "./capabilities/repo-tools.js";
21
21
  export { nowTool } from "./capabilities/builtin-tools.js";
22
22
  export { loadSkills, skillsForScenario, type LoadedSkill } from "./capabilities/skills.js";
23
- export { buildScenarios, selectScenario, createScenarioGate, type Scenario, type ScenarioBundle, type ScenarioContext, type ScenarioDeps, type ScenarioGate, type ScenarioGateLeg, type ScenarioGateSources, type ScenarioRequest, } from "./capabilities/scenarios.js";
23
+ export { buildScenarios, selectScenario, createScenarioGate, type Scenario, type ScenarioBundle, type ScenarioChoice, type ScenarioContext, type ScenarioDeps, type ScenarioGate, type ScenarioGateLeg, type ScenarioGateSources, type ScenarioRequest, type ScenarioSource, } from "./capabilities/scenarios.js";
24
24
  export { createTaskListLane, taskListKeyFor, MAX_TASK_LIST_SESSIONS, type TaskListLane, type TaskListLaneBackend, type TaskListLaneOpts } from "./boot/task-list-lane.js";
25
25
  export { ensureTiDBTaskListSchema, ensurePgTaskListSchema } from "./plugins/task-list-store-sql.js";
26
26
  export { createAuthorizer, principalFrom, HttpError, type AuthContext, type OwnerAwareSessionStore, } from "./security.js";
@@ -41,5 +41,9 @@ export { judgeServedModelRoute, type ServedModelRouteView, type ServedModelRoute
41
41
  export type { UserInputLedgerStore, UserInputAcceptance, NewUserInputAcceptance, OpenScanCursor, OpenScanPage, SettleHow, WriterGoneEvidence } from "./user-input-ledger.js";
42
42
  export type { OrgDeliveryQuotaStore, OrgDeliveryQuotaPolicy, OrgDeliveryQuotaVerdict } from "./plugins/org-delivery-quota-store.js";
43
43
  export type { ServerOrgDeliveryGate, ServerOrgDeliveryOutcome } from "./org-delivery-gate.js";
44
+ export type { LandedAttendantSeat, LandedAnchor, FileHistoryReplayResult, FileHistoryReplayFailure } from "./plugins/landed-attendants.js";
45
+ export type { LandedOutcome } from "./session-row.js";
46
+ export type { SessionFace } from "./session-incarnation.js";
47
+ export type { BlobGetter } from "./session-sync.js";
44
48
  export { APPROVAL_GATE_KINDS, type ApprovalGateKind } from "./approval-content-kind.js";
45
49
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * k8s 车道的**集群 API 凭据**:缺什么、怎么说、说给谁(纯叶:零值依赖,零 IO)。
3
+ *
4
+ * ## 法
5
+ * 车道声明了(`REMOTE_EXEC=k8s`)而控制面凭据没有 ⇒ 车道上每一条命令都起不来(`shell_unavailable`),而 run 照常 `completed` —— 这是**起服前就知道**的事,
6
+ * 不许走到 run 才说(同一件事实一个出口)。判「凭据在不在」只有一只判官(`plugins/remote-env-k8s.ts` 的 `resolveK8sApiAccess`:显式配置 ∨ in-cluster 服务账号,
7
+ * 适配器每次请求前读的 `creds()` 与下面三处说法读同一只),它答三个事实之一({@link K8sApiCredentialFact});本模块只管每个事实的**一句话**与三处说法:
8
+ * · 起服拒({@link k8sCredentialsMissingBootSentence} + {@link K8sApiCredentialsMissingError},机器码 `config.k8s_api_credentials_missing`):凭据缺 ⇒ 不起;
9
+ * · 运行期拒({@link k8sCredentialsMissingRunSentence} / {@link k8sCredentialsRejectedRunSentence}):起服之后凭据缺(服务账号文件没了)或被集群 401 拒 ⇒
10
+ * 每条 run 的环境铸造前拒,码 `env.sandbox_refused`(`execution-env-refusal.ts`)。
11
+ * 两条出路只写一次({@link EXITS}),三句共用:给凭据,或改车道。
12
+ */
13
+ /** 判官的三个事实:缺集群 API 地址 / 缺 API 令牌 / 缺 CA(且没声明实验室 TLS)。 */
14
+ export type K8sApiCredentialFact = "api_url" | "token" | "ca";
15
+ /** 一个缺失事实的一句话。 */
16
+ export declare function describeMissingK8sCredential(fact: K8sApiCredentialFact): string;
17
+ /** 起服拒的拒句:点名「REMOTE_EXEC=k8s 需要集群 API 凭据」、缺的那一件、后果与两条出路。 */
18
+ export declare function k8sCredentialsMissingBootSentence(fact: K8sApiCredentialFact): string;
19
+ /** 运行期拒(凭据在起服之后读不到):句里不再说「拒启」,说这条 run 被拒。 */
20
+ export declare function k8sCredentialsMissingRunSentence(fact: K8sApiCredentialFact): string;
21
+ /** 运行期拒(集群 API 以 401 拒了车道的凭据)。 */
22
+ export declare function k8sCredentialsRejectedRunSentence(): string;
23
+ /** 起服拒的机器码(`boot/fatal-exit.ts` 把带码异常写成 `<名> [<码>]: …` 标题;`config.*` 族与 `config.store_not_durable` 同形)。 */
24
+ export declare const K8S_API_CREDENTIALS_MISSING_CODE = "config.k8s_api_credentials_missing";
25
+ /** 起服因 k8s 车道声明而集群 API 凭据缺而拒启时的抛出物。 */
26
+ export declare class K8sApiCredentialsMissingError extends Error {
27
+ readonly code = "config.k8s_api_credentials_missing";
28
+ }
29
+ //# sourceMappingURL=k8s-api-credentials.d.ts.map
@@ -0,0 +1,25 @@
1
+ const MISSING_WHAT = {
2
+ api_url: "no cluster API address is set (K8S_API_URL) and the process is not running in a cluster (no KUBERNETES_SERVICE_HOST)",
3
+ token: "no API token is set (K8S_TOKEN) and the mounted service-account token cannot be read",
4
+ ca: "no CA certificate is set (K8S_CA_CERT_B64) and the mounted service-account CA cannot be read, and K8S_INSECURE_TLS is not true",
5
+ };
6
+ export function describeMissingK8sCredential(fact) {
7
+ return MISSING_WHAT[fact];
8
+ }
9
+ const EXITS = "Either give the server the cluster API credentials (K8S_API_URL + K8S_TOKEN, plus K8S_CA_CERT_B64 or K8S_INSECURE_TLS=true for a lab; or run the server in a pod that mounts a service account) " +
10
+ "or declare an execution lane that needs no cluster (REMOTE_EXEC=none, or another lane).";
11
+ export function k8sCredentialsMissingBootSentence(fact) {
12
+ return (`REMOTE_EXEC=k8s needs cluster API credentials, but ${MISSING_WHAT[fact]} — refusing to start rather than serving a lane on which every sandbox command ` +
13
+ `fails (shell_unavailable) while every run still finishes as completed. ${EXITS}`);
14
+ }
15
+ export function k8sCredentialsMissingRunSentence(fact) {
16
+ return `this run is refused: the k8s execution lane needs cluster API credentials, but ${MISSING_WHAT[fact]}. ${EXITS}`;
17
+ }
18
+ export function k8sCredentialsRejectedRunSentence() {
19
+ return `this run is refused: the cluster API rejected the k8s lane's credentials (HTTP 401) — a revoked or expired token, or an API address of another cluster. ${EXITS}`;
20
+ }
21
+ export const K8S_API_CREDENTIALS_MISSING_CODE = "config.k8s_api_credentials_missing";
22
+ export class K8sApiCredentialsMissingError extends Error {
23
+ code = K8S_API_CREDENTIALS_MISSING_CODE;
24
+ }
25
+ //# sourceMappingURL=k8s-api-credentials.js.map
@@ -23,6 +23,7 @@
23
23
  * 读不了家目录的车道(device:设备协议没有读数)不持座 —— 声明就是座,起服披露「来自声明、未实测」(`execution-lane-caps.ts` `buildLaneHomeBootNote`)。
24
24
  * 规则基与 422 门在下单那一刻就要家目录,而那一刻执行环境还没开 —— 它们只读主张(`executionLaneHomeDir`);环境开起来时主张被证,证不了的环境不开。
25
25
  */
26
+ import { type ExecutionEnvRefusalCode } from "./execution-env-refusal.js";
26
27
  /** 探针答案的行首标记:登录脚本 / profile 往 stdout 打的横幅不会被读成家目录 —— 只认带这个标记的那一行(恰一条,见 `markedHome`)。 */
27
28
  export declare const LANE_HOME_PROBE_MARKER = "sema-lane-home=";
28
29
  /**
@@ -72,14 +73,9 @@ export type LanePathFlavor = "posix" | "win32";
72
73
  */
73
74
  export declare function judgeLaneHome(lane: string, claim: LaneHomeClaim, probe: LaneHomeProbe, paths?: LanePathFlavor): LaneHomeVerdict;
74
75
  /**
75
- * 本仓自铸的**执行环境拒码**闭集(`env.*` 族;今天一员)—— 一只执行环境在交给引擎之前就被拒时,工厂抛出的错带的 `code`。引擎在准备期原样再抛、不建环境,
76
- * run 的 `failed` 终局原样承运码与句;同步提交腿按零工作拒落档(`runs.ts` 的 `EXECUTION_ENV_REFUSAL_HTTP_STATUS`,按本闭集键控:加一员而档没跟 ⇒ tsc 红)。
77
- * · `env.home_unconfirmed` —— 家目录主张证不了({@link judgeLaneHome} 的三形拒句:读不出 / 不是绝对路径 / 与实测不一致)。三形一个码:出路都在部署
78
- * (声明、环境里的 `HOME`,或会话 `settings.env` 里的 `HOME`),消费端不按形分岔;是哪一形、怎么改,句子里说。
76
+ * 家目录拒的带码错误:句 = 判官的拒句原文,码 = `env.home_unconfirmed`(本仓 `env.*` 族的一员,闭集属主 `execution-env-refusal.ts`)。读数在铸环境时就到手的车道(host)
77
+ * 构造时抛它,工厂原样抛出;读数要环境起来才有的车道在建连时以同一码答(建连座的拒因表 `home_unconfirmed`)。
79
78
  */
80
- export declare const EXECUTION_ENV_REFUSAL_CODES: readonly ["env.home_unconfirmed"];
81
- export type ExecutionEnvRefusalCode = (typeof EXECUTION_ENV_REFUSAL_CODES)[number];
82
- /** 家目录拒的带码错误:句 = 判官的拒句原文,码 = `env.home_unconfirmed`。读数在铸环境时就到手的车道(host)构造时抛它,工厂原样抛出。 */
83
79
  export declare function laneHomeRefusal(verdict: NonNullable<LaneHomeVerdict>): Error & {
84
80
  readonly code: Extract<ExecutionEnvRefusalCode, "env.home_unconfirmed">;
85
81
  };
@@ -1,3 +1,4 @@
1
+ import { executionEnvRefusalError } from "./execution-env-refusal.js";
1
2
  export const LANE_HOME_PROBE_MARKER = "sema-lane-home=";
2
3
  export const LANE_HOME_PROBE_COMMAND = `printf '\\n${LANE_HOME_PROBE_MARKER}%s\\n' "$HOME"`;
3
4
  const SHOWN_MAX = 256;
@@ -61,9 +62,8 @@ export function judgeLaneHome(lane, claim, probe, paths = "posix") {
61
62
  answered: true,
62
63
  };
63
64
  }
64
- export const EXECUTION_ENV_REFUSAL_CODES = ["env.home_unconfirmed"];
65
65
  export function laneHomeRefusal(verdict) {
66
- return Object.assign(new Error(verdict.refusal), { code: "env.home_unconfirmed" });
66
+ return executionEnvRefusalError("env.home_unconfirmed", verdict.refusal);
67
67
  }
68
68
  export const LANE_HOME_UNDECLARED_EVENT = "execution_lane_home_undeclared";
69
69
  const HOME_ABSENT_COST = "the engine cannot place its home-anchored read-deny rows, so every contents-disclosing recursive read (grep -r, rg, git grep, tar c, …) asks a person on the full shell — " +
@@ -15,6 +15,25 @@
15
15
  * pullDiff stays as the compat path for static (leader-owned) envs — M2 降兼容.
16
16
  */
17
17
  import { type PullDiffResult } from "./diffout.js";
18
+ /** The leader's diff-out store (`MINIO_BUCKET` + the shared `MINIO_*` endpoint and key; `boot/leader.ts` `buildLeaderObjectStore`). */
19
+ export interface LeaderDiffStore {
20
+ endpoint: string;
21
+ bucket: string;
22
+ accessKey: string;
23
+ secretKey: string;
24
+ region?: string;
25
+ }
26
+ /**
27
+ * One worker's diff-out object and its two URLs — the ONE place the key is spelled (`leader-diff/<run>/<workerId>.patch`; one object per worker per
28
+ * leader run, a repair re-run overwrites): the PUT the worker env's upload script sends (`leader-diff/patch:PUT`, the sandbox) and the GET the
29
+ * leader fetches it with on the control plane (`leader-diff/patch:GET`, the server). `workerId` is validateSubtasks-clean (`[A-Za-z0-9._-]+`) ⇒
30
+ * safe as a key segment (the presigner backstop-rejects traversal anyway). `ttlSec` = the worker's deadline plus slack (`leaderResourceConfig`).
31
+ */
32
+ export declare function buildLeaderDiffUrls(s3: LeaderDiffStore, workerId: string, ttlSec: number): {
33
+ readonly key: string;
34
+ readonly putUrl: string;
35
+ readonly getUrl: string;
36
+ };
18
37
  /** The staged upload script. `repoDir`/`workDir` are deployment config; `baseSha` is interpolated into a
19
38
  * shell line, so it is re-validated HERE (fail-closed) — callers should already have applied diffout's
20
39
  * safeRev rules, but this function is the last line before the shell. The patch is written OUTSIDE the repo
@@ -1,6 +1,13 @@
1
1
  import { safeRev, DEFAULT_MAX_DIFF_BYTES } from "./diffout.js";
2
2
  import { OBJECT_STORE_IO_TIMEOUT_MS } from "../plugins/blob-backend.js";
3
3
  import { createEgressFetch } from "../egress-redirect.js";
4
+ import { presignS3Url } from "../plugins/s3-presign.js";
5
+ import { LEADER_DIFF_PREFIX } from "../object-store-buckets.js";
6
+ export function buildLeaderDiffUrls(s3, workerId, ttlSec) {
7
+ const key = `${LEADER_DIFF_PREFIX}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}/${workerId}.patch`;
8
+ const base = { endpoint: s3.endpoint, bucket: s3.bucket, accessKey: s3.accessKey, secretKey: s3.secretKey, ...(s3.region ? { region: s3.region } : {}), key, expiresSec: ttlSec };
9
+ return { key, putUrl: presignS3Url({ ...base, op: "leader-diff/patch:PUT", method: "PUT" }), getUrl: presignS3Url({ ...base, op: "leader-diff/patch:GET", method: "GET" }) };
10
+ }
4
11
  export function buildUploadScript(p) {
5
12
  if (!safeRev(p.baseSha))
6
13
  throw new Error(`buildUploadScript: unsafe baseSha ${JSON.stringify(p.baseSha)}`);
@@ -15,8 +15,10 @@
15
15
  import { type RunnerLike, type WorkerReport } from "./fanout.js";
16
16
  import { type ExecStreamLike } from "./diffout.js";
17
17
  import { type MergeDeps, type MergeResult } from "./merge.js";
18
- import { type PermissionMode, type TaskSpec, type VerifyConfig, type CheckpointToken, type TerminalCause, type ToolSpec, type RepairTerminal, type OracleTier, type RepairResult } from "@sema-agent/core";
18
+ import { type PermissionMode, type ToolPolicy, type TaskSpec, type VerifyConfig, type CheckpointToken, type TerminalCause, type ToolSpec, type RepairTerminal, type OracleTier, type RepairResult } from "@sema-agent/core";
19
19
  import { type UnattendedLegSpec } from "../unattended-permission-mode.js";
20
+ import type { CheckpointStoreFull } from "../plugins/store-backend.js";
21
+ import type { CheckpointCtxSealer } from "../http/checkpoint-ctx.js";
20
22
  /** [ref] Slice 6: drive a worker's resource-suspend auto-resume to a terminal (or bound) state. Exported
21
23
  * for unit tests. Loops `resume(token, slice)` WHILE the result's terminal cause is a park on a
22
24
  * `resource_limit` gate. Exits on: a terminal cause that is not a park, a park on any OTHER gate
@@ -70,19 +72,122 @@ export interface ProvisionedWorker {
70
72
  * (`runtime-governance.ts` `entryPermissionMode`)得出的入口词(`run-entry.ts` `leaderRunEntry`);地板缺席 ⇒ `{}`。leader 请求不带调用方的模式词,所以入口词就是地板本身(与 run-local 同)。
71
73
  * 本 run 铸的每一条 spec 经 {@link withLeaderLeg} 从这一份取词;worker 的续跑体由它展开(`{ ...entry, objective }`)⇒ 首跑、续跑、修复腿同一个词。
72
74
  * 入口词是 `plan` 的 run 进不了这条车道(`run-entry.ts` `leaderEntryRefusal`:worker 会话没有计划审阅通道)—— 受理口与出生处同判,到不了 worker。
73
- * 热改 `AUTONOMY` 只影响之后起的 leader run:在飞的 run 保持它出生时盖下的这一份。
75
+ * 热改 `AUTONOMY` 只影响之后起的 leader run:在飞的 run(含它后来 provision 的 worker,与经 HTTP 续跑腿赎回的停驻 worker —— 续跑口对带无人值守标的行照写下的体重放,
76
+ * `http/resume-legs.ts` `replayCtxOf`)保持它出生时盖下的这一份。
74
77
  */
75
78
  export interface LeaderRunEntry {
76
79
  readonly permissionMode?: PermissionMode;
77
80
  }
78
81
  /**
79
- * leader 车道铸 spec 的**唯一**合并口:spec 的词钳在入口体的词之下(`runtime-governance.ts` `entryPermissionMode(spec 的词, 入口词)` —— 与受理门同一只函数;
80
- * 写进 spec 的值就是它的 `effective`),再交给无人值守腿的合并口(`withUnattendedLeg` 的 `default` 钳在那个词之下)。入口体无词 ⇒ spec 原物交给
81
- * `withUnattendedLeg`,与不经本口逐字同。本车道的 spec 今天自己不带模式词(子任务体只有 objective,其余并进的键是预算 / 审批 / 身份)⇒ 入口词在场时写下的就是它;
82
- * 将来带了词,比入口词松的折回入口词、比它紧的留着 —— 与一条提交体过受理门同一个答案,不另写「写」的规则。五个出生点(worker 首跑的工厂 / 静态两条车道、
83
- * 集成修复、模块门修复、单代理修复环)都调它、不直调 `withUnattendedLeg`(`test/leader-entry-floor.test.ts` 按语法树数调用点):「这条腿的词从哪来」只有入口体一个答案。
82
+ * 一条 leader run 的**出生上下文**:run 出生那一拍定下、本 run 铸的每一条腿都从它取 —— 入口体({@link LeaderRunEntry})、提交者的身份格
83
+ * (`engine-identity.ts` `taskSpecIdentityOf` 的产物,出生时读一次 ALS)、部署治理折叠(装配处闭包活 config 交进来,leader 自己不读 config)。
84
84
  */
85
- export declare function withLeaderLeg<S extends Partial<TaskSpec>>(spec: S, entry: LeaderRunEntry): S & UnattendedLegSpec;
85
+ export interface LeaderBirth {
86
+ readonly entry: LeaderRunEntry;
87
+ /** 提交者的身份格(匿名 ⇒ `{}`:键缺席,与提交腿同一读法)。中心按主体的收紧位、治理窗的锅都按它解。 */
88
+ readonly identity: {
89
+ readonly principal?: string;
90
+ };
91
+ /**
92
+ * 部署治理折叠(`runtime-governance.ts` `applyRuntimeGovernance`,与 `resolveSpec` / 停驻赎回腿同一属主):运维 `AUTONOMY` / `commandPolicy` /
93
+ * `MANUAL_MODE_SHELL_GATE` / 守卫集 tighten-only 盖到 spec 上。`legSessionId` = 这条腿的**槽键**(沙盒车道上守卫按它在槽表里取那台真沙盒):
94
+ * 跑在 worker 执行器上的腿(首跑、模块门修复、单代理修复环)= worker 自己的会话号;集成修复腿 = 它那一轮的会话号(`leader/wire.ts` 按同一个键登记)。
95
+ */
96
+ readonly govern: (spec: TaskSpec, legSessionId: string) => TaskSpec;
97
+ /**
98
+ * 审批基线(`deployment-governance.ts` `createApprovalBaselinePolicy` 的两臂,装配处闭包活 config —— 名单热换对之后出生的腿生效)。出生口按这条腿的
99
+ * {@link LeaderLegDurability} 取一臂:耐久腿 `durable`(问答门 + 三张名单,问由停驻服);不耐久腿 `live`(三张名单,问由这条腿的活席服 —— 即无人值守层:
100
+ * 答得了的按类答,答不了的交回引擎的缺席路,这条腿没有停驻设施 ⇒ 拒)。
101
+ */
102
+ readonly baseline: (seat: "durable" | "live") => ToolPolicy;
103
+ /**
104
+ * 这条腿的 per-model 凭据席(`TaskSpec.getApiKeyAndHeaders`)—— 装配处铸(`boot/leader.ts` 的 `createLeaderLegAuth`:与任务面同一只活引用、与 side-query /
105
+ * WebFetch 摘要面同一只席工厂);leader 自己不碰钥链。**每只执行器出生时调一次**(出生口 {@link withLeaderLeg} 对执行器与腿同拍出生的腿调;planner 路由在它的
106
+ * Runner 构造那一拍调):解钥的那一代在这一拍定下,与这只执行器构造时收下的模型目录同代(目录与钥匙表由中心成对换代 ⇒ 在飞的腿不会把新家的钥发到它目录里的旧家)。
107
+ * 跑在已出生执行器上的腿不再调它,沿用那只执行器的席({@link LeaderLegExecutor})。
108
+ * `upstream` = spec 自带的席:每次调用先问它,它没意见才按模型解(不覆盖)。声明了钥匙却拿不到 ⇒ 席抛(与任务面同一只毒丸),那次调用整体失败,绝不回落网关钥。
109
+ */
110
+ readonly auth: (upstream: TaskSpec["getApiKeyAndHeaders"]) => NonNullable<TaskSpec["getApiKeyAndHeaders"]>;
111
+ }
112
+ /**
113
+ * leader worker 审批停驻行的 scope(唯一属主;保留标识见 `principal-shape.ts` 的 `RESERVED_PRINCIPALS`)。出生口给耐久腿的 `durableApproval` 与
114
+ * 取消时的残留过期(`wire.ts` `createLeaderParkExpirer`)读这同一只。
115
+ */
116
+ export declare const LEADER_APPROVAL_SCOPE = "_leader";
117
+ /** 部署的停驻设施(`LeaderWireConfig.durable` 函数席每次产出的一份;键在场 ⟺ 部署接了停驻店)。 */
118
+ export interface LeaderDurableSeat {
119
+ readonly checkpointStore: CheckpointStoreFull;
120
+ /** [ref]:写 worker 续跑上下文的封口(`ServiceDeps.checkpointCtxSealing` 同一只;规则属主 `http/checkpoint-ctx.ts` 末段「凭据位密封」)。
121
+ * worker 的续跑体只有入口词 + 子任务 objective、不带凭据位 ⇒ 实际不封任何值,但写 ctx 的每一笔都经同一只封口(没有不封的第二种写法)。 */
122
+ readonly ctxSealer: CheckpointCtxSealer | undefined;
123
+ readonly ttlMs?: number;
124
+ }
125
+ /**
126
+ * 出生点陈述的这条腿的事实 ——「停驻决完之后,谁接着做这条腿的工作」:
127
+ * · `replay` —— worker 首跑:留续跑体,决完之后由一条单独的续跑 run(HTTP 续跑腿,照写下的体重放)接着做。`resumeCtx` = 续跑上下文那一笔的结局:
128
+ * `landed` = 写进了出生点递给这条腿的停驻店(`park`);`lost` = 写了、店抛了;`unwritten` = 出生点没递停驻设施 ⇒ 不写。递不递由出生点按车道定:
129
+ * 工厂车道 = 部署接了停驻店即递(环境由 worker 自己的 Runner 经工厂铸,停驻时引擎把可恢复的环境句柄写进检查点,续跑腿经部署工厂按句柄接回同一工作区);
130
+ * 静态车道 = {@link staticLaneWorkerPark}(上一发布版的条件,不按本律)。
131
+ * · `in_run` —— 这条腿的续接是本 run 内存里的那一轮(集成修复、模块门修复、单代理修复环):一条单独续跑的 run 交不回去。
132
+ */
133
+ export type LeaderLegFacts = {
134
+ readonly continuation: "replay";
135
+ readonly resumeCtx: "landed";
136
+ readonly park: LeaderDurableSeat;
137
+ } | {
138
+ readonly continuation: "replay";
139
+ readonly resumeCtx: "lost" | "unwritten";
140
+ } | {
141
+ readonly continuation: "in_run";
142
+ };
143
+ /** 一条腿的耐久事实({@link leaderLegDurability} 的产物)。`transient.why` 是给运维的那一句(资源分片停驻不生效的告警原因读它)。 */
144
+ export type LeaderLegDurability = {
145
+ readonly kind: "durable";
146
+ readonly park: LeaderDurableSeat;
147
+ } | {
148
+ readonly kind: "transient";
149
+ readonly why: string;
150
+ };
151
+ /**
152
+ * **一条 leader 腿的耐久事实 —— 唯一读者**。耐久 ⇔ 这条腿由单独的续跑 run 接续 ∧ 它的续跑上下文真落进了出生点递给它的停驻店(没落 ⇒ 停出来的卡
153
+ * 决的时候重建不了这条腿 ⇒ 不耐久)。四个调用点:worker 首跑(工厂 / 静态两条车道共一次)、集成修复、模块门修复、单代理修复环;出生口({@link withLeaderLeg})
154
+ * 按它盖审批基线与停驻设施,worker 首跑按它保温续跑上下文、开资源分片停驻。主车道没有握在手里的环境(它的每一只环境都由工厂铸,环境能不能停驻由引擎读),
155
+ * 所以「递不递停驻设施」这一问只在本车道有。
156
+ */
157
+ export declare function leaderLegDurability(leg: LeaderLegFacts): LeaderLegDurability;
158
+ /**
159
+ * 静态车道 worker 递不递停驻设施 —— **上一发布版的条件原样**:部署接了停驻店 ∧ 任一审批名单在场(每只 worker 现读)。只此一处,worker 首跑的出生点调它一次。
160
+ * 不按 {@link leaderLegDurability} 的律(工厂车道「店在即递」)判:这条车道上两种停驻的续接路不同 —— 资源分片停驻由 leader 在进程内同一只执行器上续(续得上);
161
+ * 审批停驻的赎回走 HTTP 续跑腿、经部署工厂另铸执行环境(worker 的沙盒握在 leader 手里,检查点里没有它的句柄 ⇒ 续不上)。引擎今天只有「给不给停驻店」一个开关,
162
+ * 两种停驻拆不开:照「店在即递」会比上一版多出几种部署形停出决完落新执行环境的卡,照「续不上就不递」又关掉上一版就工作的资源分片停驻 ⇒ 沿用上一版的条件。
163
+ * 已知缺陷(上一版同形,随包文书同句披露):名单在 × 店在时审批问停驻,决完的续跑落在新执行环境上。引擎提供「宿主声明本腿审批停驻不可续」的声明位后,
164
+ * 本条件退役、静态车道并回本读者的律(店在即递 + 声明审批停驻不可续:资源分片照停,审批问不走停驻)。
165
+ */
166
+ export declare function staticLaneWorkerPark(park: LeaderDurableSeat | undefined, approvalListInForce: boolean): LeaderDurableSeat | undefined;
167
+ /**
168
+ * 这条腿跑在哪只执行器上 —— **凭据代随执行器**:执行器构造时把模型目录收成私有副本,这条腿的钥取同一代(否则中心换代之后,新一代的钥会配上旧一代目录里的端点)。
169
+ * · `fresh` —— 执行器与这条腿同拍出生(worker 首跑的工厂 / 静态两条车道、集成修复):出生口此刻从出生上下文取一只席({@link LeaderBirth.auth},折 spec 自带的那一只);
170
+ * · `reuses` —— 腿跑在一只已经出生的 worker 执行器上(模块门修复、单代理修复环):沿用那只 worker 首跑 spec 上的席(它经出生口 `fresh` 出生,已折过子任务自带的席),不再取一代。
171
+ */
172
+ export type LeaderLegExecutor = {
173
+ readonly kind: "fresh";
174
+ } | {
175
+ readonly kind: "reuses";
176
+ readonly worker: Pick<ProvisionedWorker, "spec">;
177
+ };
178
+ /** 出生口收的这条腿:槽键(见 {@link LeaderBirth.govern})+ 耐久事实(见 {@link leaderLegDurability})+ 执行器(凭据代,见 {@link LeaderLegExecutor})。 */
179
+ export interface LeaderLeg {
180
+ readonly slotKey: string;
181
+ readonly durability: LeaderLegDurability;
182
+ readonly executor: LeaderLegExecutor;
183
+ }
184
+ /**
185
+ * leader 车道铸 spec 的**唯一**出生口。顺序即语义:身份格 + 凭据席(随执行器的那一代,{@link LeaderLegExecutor})+ 审批基线与停驻设施(按这条腿的耐久事实)→ 部署治理折叠(同属主,tighten-only 叠在基线上)→
186
+ * 入口词(spec 的词钳在入口体的词之下,`runtime-governance.ts` `entryPermissionMode` —— 与受理门同一只函数)→ 无人值守腿(`withUnattendedLeg` 头注要求它在
187
+ * 治理折叠**之后**)。首跑、修复腿与停驻后的续跑腿(续跑腿经 `resolveSpec` 折同一只治理)因此同一读法。五个出生点(worker 首跑的工厂 / 静态两条车道、
188
+ * 集成修复、模块门修复、单代理修复环)都调它、不直调 `withUnattendedLeg`、不各自盖身份或基线(`test/leader-entry-floor.test.ts` 按语法树数调用点)。
189
+ */
190
+ export declare function withLeaderLeg(spec: TaskSpec, birth: LeaderBirth, leg: LeaderLeg): TaskSpec & UnattendedLegSpec;
86
191
  export interface LeaderDeps {
87
192
  /**
88
193
  * 本 run 的中止信号(取消口 / 陈旧裁决;HTTP 驱动腿恒给,`endpoint.ts` 的 `drive`)。与 core `TaskSpec.signal` 同一约定:缺席 = 不可外部取消(单测 / bench 形)。
@@ -90,9 +195,9 @@ export interface LeaderDeps {
90
195
  * 不再起任何新的计费工作;在跑的腿经 spec 的同一根信号中止(fan-out 共享信号 / 修复腿 / 单代理修复环);合并在 push 咽喉前再核一次(`merge.ts`)。
91
196
  */
92
197
  signal?: AbortSignal;
93
- /** 本 run 的入口体({@link LeaderRunEntry}:运维地板在 run 出生时盖一次)。必填:没有地板的装配写 `{}` —— 缺席不是「没有地板」的合法拼法。
94
- * 模块门修复与单代理修复环这两个出生点从这里取词(经 {@link withLeaderLeg})。 */
95
- entry: LeaderRunEntry;
198
+ /** 本 run 的出生上下文({@link LeaderBirth}:入口体 + 身份格 + 治理折叠,run 出生时定一次)。必填:没有地板的装配写 `entry: {}` —— 缺席不是「没有地板」的合法拼法。
199
+ * 模块门修复与单代理修复环这两个出生点从这里出生(经 {@link withLeaderLeg})。 */
200
+ birth: LeaderBirth;
96
201
  /** Plan a task into N disjoint-file sub-tasks (MVP: simple/hand-authored; adaptive replan = scale). */
97
202
  plan: (task: string) => Promise<SubtaskSpec[]>;
98
203
  /** Provision a leader-owned worker (its env seeded with base at `branch` + an env-bound runner). */