@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
@@ -5,16 +5,20 @@ export declare const DEVICE_WS_PATH = "/v1/device/ws";
5
5
  * 本 server 铸/认的协议**修订号**(wire 上的 `protocolVersion`)。
6
6
  *
7
7
  * 规则(真源 = 协议文档 `docs/DEVICE-EXECUTOR-PROTOCOL.md` §2.1「Protocol revisions」段,此处只转述):加帧 / 加字段 = additive 不升号;
8
- * 其余变更一律升号并在增量表加一行,已发布的行不改 —— **server 受理的闭集(executor → server 方向,今天 = 结局 `errorCode` 词集)加词 = 升号**,
9
- * **语义变更(server 下发的帧意思变了)= 升号**。修订号是 executor 在发 hello 之前唯一能读到的「这台 server 受理什么、发来的帧是什么意思」的事实
10
- * (challenge 帧带它),所以 server 受理的词集必须是修订号的函数({@link DEVICE_OUTCOME_ERROR_CODES_BY_REVISION},协议文档同名表),不另发第二份列表;
11
- * 闭集变了而修订号没变 = 同一个修订号两种受理集(7.132.0 给结局码加 `liveness_no_output` 时没抬号,7.136.0 补到 2)。类型锁:抬了号而表没有这一行 ⇒ 编译红。
8
+ * 其余变更一律升号并在增量表加一行,已发布的行不改 —— **指令两向的闭集加词 = 升号**:server 受理的结局 `errorCode` 词集(executor → server)
9
+ * 与 server 下发的指令 kind 集(server → executor),各一张按修订号分行的表({@link DEVICE_OUTCOME_ERROR_CODES_BY_REVISION} /
10
+ * {@link DEVICE_INSTRUCTION_KINDS_BY_REVISION},同一组行键;协议文档是同一张修订号表的两栏);**语义变更(server 下发的帧意思变了)= 升号**。
11
+ * 修订号是 executor 在发 hello 之前唯一能读到的「这台 server 受理什么、会发来什么、发来的帧是什么意思」的事实(challenge 帧带它),所以两个闭集
12
+ * 都必须是修订号的函数,不另发第二份列表;闭集变了而修订号没变 = 同一个修订号两种集合(7.132.0 给结局码加 `liveness_no_output` 时没抬号,7.136.0 补到 2)。
13
+ * 下发方向的读法:汇聚端只认**这条连接协商的修订号**那一份 kind 集({@link asInstructionKindAt}),高于它的 kind 与认不出的词同读 —— 恒不下发。
14
+ * 类型锁:抬了号而任一张表没有这一行 ⇒ 编译红。
12
15
  */
13
16
  export declare const DEVICE_PROTOCOL_VERSION: DeviceProtocolRevision;
14
17
  /**
15
18
  * 受理下沿:低于它 ⇒ `helloReject: protocol_version_unsupported`(带 `minProtocolVersion` 与一句 {@link deviceProtocolRevisionRefusal},响亮拒,不静默降级,[ref])。
16
19
  * 兼容窗 = [MIN, 当前]。律(协议文档 §2.1 规则句):升号的变更旧修订的 executor 守不住 ⇒ 同一版把下沿抬到那一修订号 —— 旧 executor 在 hello 被拒一次,
17
20
  * 而不是逐调用失败。今天 = 5:修订号 5 起路径只锚不折(下沿理由见 {@link DEVICE_FLOOR_CHANGE}),写给修订号 ≤ 4 的 executor 认的是折过的路径。
21
+ * 修订号 6(kind 集加 `openBound`)不抬下沿:那个 kind 只派给协商修订号 ≥ 6 的连接,修订号 5 的 executor 收不到它 ⇒ 守得住。
18
22
  * 这是**本 server** 的受理下沿,不是 executor 协商时的下界(executor 一侧修订号是累积的:实现了 5 的照样能按 4 服务老 server)。
19
23
  */
20
24
  export declare const DEVICE_MIN_PROTOCOL_VERSION: DeviceProtocolRevision;
@@ -71,11 +75,44 @@ export type DeviceCancelState = (typeof DEVICE_CANCEL_STATES)[number];
71
75
  */
72
76
  export declare const DEVICE_INSTRUCTION_STATES: readonly ["queued", "dispatch_committed", "terminal", "terminal_never_started"];
73
77
  export type DeviceInstructionState = (typeof DEVICE_INSTRUCTION_STATES)[number];
74
- /** 指令 kind ↔ core 的 FileSystem+Shell 面 1:1(§5.1;双端穷举 switch)。 */
75
- export declare const DEVICE_INSTRUCTION_KINDS: readonly ["exec", "execStream", "readTextFile", "readTextLines", "readBinaryFile", "writeFile", "writeFileExclusive", "writeFileGuarded", "appendFile", "fileInfo", "listDir", "canonicalPath", "exists", "readLink", "createDir", "remove", "createTempDir", "createTempFile", "statBatch"];
76
- export type DeviceInstructionKind = (typeof DEVICE_INSTRUCTION_KINDS)[number];
77
- /** 认得就收窄,认不出就 null(**不猜**:未知 kind 恒不下发,fail-closed 方向)。 */
78
- export declare function asInstructionKind(v: string): DeviceInstructionKind | null;
78
+ /**
79
+ * 指令 kind ↔ core 的 FileSystem+Shell 面 1:1(§5.1;双端穷举 switch)—— **按修订号分行的增量表,是这个闭集唯一的一份来源**(与结局码同一条律):
80
+ * 修订号 N 的 kind 集 = 行 ≤ N 的并、按行序({@link deviceInstructionKindsAt}),{@link DEVICE_INSTRUCTION_KINDS} 是当前修订号的那一份(派生)。
81
+ * 汇聚端对一条连接只认它协商的修订号那一份({@link asInstructionKindAt}):executor 在 `hello.supports` 里声明了一个高于自己修订号的 kind,与声明了
82
+ * 一个认不出的词同读 —— 不进声明集、恒不下发。已发布修订号的行不许改(测试冻结了每个修订号的集合哈希);加 kind = 抬 {@link DEVICE_PROTOCOL_VERSION} + 加一行。
83
+ * 行键与 {@link DEVICE_OUTCOME_ERROR_CODES_BY_REVISION} 同一组(`satisfies` 锁:少一行 / 多一行 ⇒ 编译红)。
84
+ */
85
+ export declare const DEVICE_INSTRUCTION_KINDS_BY_REVISION: {
86
+ readonly 1: readonly ["exec", "execStream", "readTextFile", "readTextLines", "readBinaryFile", "writeFile", "writeFileExclusive", "writeFileGuarded", "appendFile", "fileInfo", "listDir", "canonicalPath", "exists", "readLink", "createDir", "remove", "createTempDir", "createTempFile", "statBatch"];
87
+ readonly 2: readonly [];
88
+ readonly 3: readonly [];
89
+ readonly 4: readonly [];
90
+ readonly 5: readonly [];
91
+ /**
92
+ * 7.151.0:绑定读 —— 判过的那只对象就是读到的那只。协议没有跨指令的句柄,所以 `BoundFileObject` 的每一答是一条指令
93
+ * ({@link DeviceInstructionArgsByKind}`.openBound.op` 四选一):执行器在本机打开这条路径(叶链接不跟)、核对这只打开的对象此刻就在这条路径上
94
+ * (且 `identity` / `kind` 在场时等于它们)、经这一次打开作答、关掉。executor 必须实现才答得出 ⇒ 加词抬号;只派给协商修订号 ≥ 6 的连接,
95
+ * 修订号 5 的 executor 收不到它(受理下沿不动)。presence-typed(同 `writeFileGuarded` / `readLink`):执行器在 `hello.supports` 声明才装这一面;
96
+ * 没声明 ⇒ 这一面缺席(引擎不绑定读,附件不附),**不许**用 `fileInfo` + `readBinaryFile` 仿真。
97
+ */
98
+ readonly 6: readonly ["openBound"];
99
+ };
100
+ export type DeviceInstructionKind = (typeof DEVICE_INSTRUCTION_KINDS_BY_REVISION)[DeviceProtocolRevision][number];
101
+ /**
102
+ * 协议修订号 `revision` 下发的指令 kind 全集(行 ≤ revision 的并,按行序 —— 协议文档 §3.1 的表同序)。executor 按**自己声明的修订号**取这一份,
103
+ * 决定 `hello.supports` 里能声明哪些 kind。不是本包认得的修订号 ⇒ 抛 `RangeError`(不静默给空集或全集)。
104
+ */
105
+ export declare function deviceInstructionKindsAt(revision: number): readonly DeviceInstructionKind[];
106
+ /** 当前修订号下发的 kind 全集(派生自增量表;§3.1 的表就是它)。 */
107
+ export declare const DEVICE_INSTRUCTION_KINDS: readonly DeviceInstructionKind[];
108
+ /** `openBound` 指令的四个答(一个 `BoundFileObject` 成员一个;`open` 是开答)。 */
109
+ export declare const DEVICE_BOUND_READ_OPS: readonly ["open", "size", "readBytes", "list"];
110
+ export type DeviceBoundReadOp = (typeof DEVICE_BOUND_READ_OPS)[number];
111
+ /**
112
+ * 认词 **按协商修订号**:`v` 在修订号 `revision` 的 kind 集里就收窄,不在就 null(**不猜**:高于协商修订号的 kind 与认不出的词同读,恒不下发,fail-closed 方向)。
113
+ * 不是本包认得的修订号 ⇒ 抛 `RangeError`(汇聚端在 hello 的版本窗之后才调它,窗外到不了这里;到了就是响亮的缺陷,不静默给全集)。
114
+ */
115
+ export declare function asInstructionKindAt(v: string, revision: number): DeviceInstructionKind | null;
79
116
  /**
80
117
  * 结果帧的错误码闭集 = core 的 `FileErrorCode ∪ ExecutionErrorCode`(§5.1「error code 全闭集」:
81
118
  * 未知值映射为协议错误而非透传 string)—— **按修订号分行的增量表,是这个闭集唯一的一份来源**:
@@ -88,6 +125,7 @@ export declare const DEVICE_OUTCOME_ERROR_CODES_BY_REVISION: {
88
125
  readonly 3: readonly ["name_too_long"];
89
126
  readonly 4: readonly ["symlink_loop"];
90
127
  readonly 5: readonly [];
128
+ readonly 6: readonly [];
91
129
  };
92
130
  /** 本包认得的协议修订号(= 增量表的行键)。 */
93
131
  export type DeviceProtocolRevision = keyof typeof DEVICE_OUTCOME_ERROR_CODES_BY_REVISION;
@@ -151,7 +189,9 @@ export type DeviceInstructionOutcome = {
151
189
  } | {
152
190
  ok: true;
153
191
  kind: "read";
154
- } | {
192
+ }
193
+ /** `identity` 是 additive 扩键(`openBound` 开答:被打开对象的 `<dev>:<inode>`,之后每一答的对拍凭据)。 */
194
+ | {
155
195
  ok: true;
156
196
  kind: "stat";
157
197
  info?: WireFileInfo;
@@ -159,6 +199,7 @@ export type DeviceInstructionOutcome = {
159
199
  existsValue?: boolean;
160
200
  canonicalPath?: string;
161
201
  linkTarget?: string | null;
202
+ identity?: string;
162
203
  }
163
204
  /** 写面的**落盘对象收据**(§4.3.1 / core `WriteReceipt`)。`created` 是 additive 扩键(车A-4):
164
205
  * core 的收据形要求它,缺席 = adapter 只能猜「是新建还是覆盖」,而猜出来的收据就是假收据。 */
@@ -255,6 +296,18 @@ export interface DeviceInstructionArgsByKind {
255
296
  statBatch: {
256
297
  paths: string[];
257
298
  };
299
+ /**
300
+ * 绑定读的一答。`op`:`open` ⇒ `stat` 结局带 `identity` 与 `info`(`kind` 只许 `file` / `dir`);`size` ⇒ `stat` 带 `info`(`size` = 此刻大小);
301
+ * `readBytes` ⇒ `read` 结局 + `data` 片(大小 > `max` ⇒ `invalid`,一个字节不读);`list` ⇒ `stat` 带 `entries`(经这只打开的目录列,链接不跟)。
302
+ * `identity` / `kind` 在场(开答之后的三答)⇒ 这一次打开的对象须与它们都相等,否则 `precondition_failed`;开后不在这条路径上同拒。
303
+ */
304
+ openBound: {
305
+ path: string;
306
+ op: DeviceBoundReadOp;
307
+ identity?: string;
308
+ kind?: "file" | "directory";
309
+ max?: number;
310
+ };
258
311
  }
259
312
  export type DeviceChallengeFrame = {
260
313
  t: "challenge";
@@ -1,7 +1,7 @@
1
1
  import { createPublicKey, randomBytes, randomInt, verify as edVerify } from "node:crypto";
2
2
  import { MAX_TIMER_DELAY_MS, inWholeNumberBounds, wholeNumberBoundsRule } from "./config-types.js";
3
3
  export const DEVICE_WS_PATH = "/v1/device/ws";
4
- export const DEVICE_PROTOCOL_VERSION = 5;
4
+ export const DEVICE_PROTOCOL_VERSION = 6;
5
5
  export const DEVICE_MIN_PROTOCOL_VERSION = 5;
6
6
  const DEVICE_FLOOR_CHANGE = 'since server 7.150.0 every path an instruction carries (args.path, args.paths, cwd) arrives unfolded, with "." / ".." / empty segments kept for the device\'s filesystem to resolve';
7
7
  export function deviceProtocolRevisionRefusal(declared) {
@@ -24,30 +24,54 @@ export const DEVICE_GOODBYE_REASONS = ["shutdown", "sleep", "user_stop"];
24
24
  export const DEVICE_CHUNK_KINDS = ["stdout", "stderr", "data", "exit"];
25
25
  export const DEVICE_CANCEL_STATES = ["not_started", "killed"];
26
26
  export const DEVICE_INSTRUCTION_STATES = ["queued", "dispatch_committed", "terminal", "terminal_never_started"];
27
- export const DEVICE_INSTRUCTION_KINDS = [
28
- "exec",
29
- "execStream",
30
- "readTextFile",
31
- "readTextLines",
32
- "readBinaryFile",
33
- "writeFile",
34
- "writeFileExclusive",
35
- "writeFileGuarded",
36
- "appendFile",
37
- "fileInfo",
38
- "listDir",
39
- "canonicalPath",
40
- "exists",
41
- "readLink",
42
- "createDir",
43
- "remove",
44
- "createTempDir",
45
- "createTempFile",
46
- "statBatch",
47
- ];
48
- const INSTRUCTION_KIND_SET = new Set(DEVICE_INSTRUCTION_KINDS);
49
- export function asInstructionKind(v) {
50
- return INSTRUCTION_KIND_SET.has(v) ? v : null;
27
+ export const DEVICE_INSTRUCTION_KINDS_BY_REVISION = {
28
+ 1: [
29
+ "exec",
30
+ "execStream",
31
+ "readTextFile",
32
+ "readTextLines",
33
+ "readBinaryFile",
34
+ "writeFile",
35
+ "writeFileExclusive",
36
+ "writeFileGuarded",
37
+ "appendFile",
38
+ "fileInfo",
39
+ "listDir",
40
+ "canonicalPath",
41
+ "exists",
42
+ "readLink",
43
+ "createDir",
44
+ "remove",
45
+ "createTempDir",
46
+ "createTempFile",
47
+ "statBatch",
48
+ ],
49
+ 2: [],
50
+ 3: [],
51
+ 4: [],
52
+ 5: [],
53
+ 6: ["openBound"],
54
+ };
55
+ export function deviceInstructionKindsAt(revision) {
56
+ if (!Number.isInteger(revision) || revision < 1 || revision > DEVICE_PROTOCOL_VERSION) {
57
+ throw new RangeError(`device-ws: no instruction-kind set for protocol revision ${String(revision)} (this package knows revisions 1..${DEVICE_PROTOCOL_VERSION})`);
58
+ }
59
+ const out = [];
60
+ for (const [rev, kinds] of Object.entries(DEVICE_INSTRUCTION_KINDS_BY_REVISION)) {
61
+ if (Number(rev) <= revision)
62
+ out.push(...kinds);
63
+ }
64
+ return out;
65
+ }
66
+ export const DEVICE_INSTRUCTION_KINDS = deviceInstructionKindsAt(DEVICE_PROTOCOL_VERSION);
67
+ export const DEVICE_BOUND_READ_OPS = ["open", "size", "readBytes", "list"];
68
+ const INSTRUCTION_KIND_SETS = new Map(Object.keys(DEVICE_INSTRUCTION_KINDS_BY_REVISION).map((rev) => [Number(rev), new Set(deviceInstructionKindsAt(Number(rev)))]));
69
+ export function asInstructionKindAt(v, revision) {
70
+ const kinds = INSTRUCTION_KIND_SETS.get(revision);
71
+ if (kinds === undefined) {
72
+ throw new RangeError(`device-ws: no instruction-kind set for protocol revision ${String(revision)} (this package knows revisions 1..${DEVICE_PROTOCOL_VERSION})`);
73
+ }
74
+ return kinds.has(v) ? v : null;
51
75
  }
52
76
  export const DEVICE_OUTCOME_ERROR_CODES_BY_REVISION = {
53
77
  1: [
@@ -75,6 +99,7 @@ export const DEVICE_OUTCOME_ERROR_CODES_BY_REVISION = {
75
99
  3: ["name_too_long"],
76
100
  4: ["symlink_loop"],
77
101
  5: [],
102
+ 6: [],
78
103
  };
79
104
  export function deviceOutcomeErrorCodesAt(revision) {
80
105
  if (!Number.isInteger(revision) || revision < 1 || revision > DEVICE_PROTOCOL_VERSION) {
@@ -232,6 +257,12 @@ function parseOutcome(v) {
232
257
  return null;
233
258
  out.linkTarget = v.linkTarget;
234
259
  }
260
+ if (v.identity !== undefined) {
261
+ const id = str(v.identity);
262
+ if (id === null)
263
+ return null;
264
+ out.identity = id;
265
+ }
235
266
  return out;
236
267
  }
237
268
  case "write": {
@@ -6,7 +6,7 @@ import { refusalBody } from "./http/refusal-body.js";
6
6
  import { keyAdmits, ownerCellOf, recoveredSubject } from "./owner-faces.js";
7
7
  import { createHitlOpenRace } from "./hitl-delivery.js";
8
8
  const MAX_ELICIT_MESSAGE_CHARS = 4096;
9
- const MAX_ELICIT_SCHEMA_BYTES = 8192;
9
+ const MAX_ELICIT_SCHEMA_CHARS = 8192;
10
10
  const RELEASE_ACTION = { refused: "decline", unanswered: "cancel" };
11
11
  export const DEFAULT_ELICITATION_THROTTLE = {
12
12
  maxConcurrentPerRun: 2,
@@ -42,7 +42,7 @@ function boundSchema(schema) {
42
42
  return undefined;
43
43
  const redacted = redactDeep(schema);
44
44
  try {
45
- if (JSON.stringify(redacted).length > MAX_ELICIT_SCHEMA_BYTES)
45
+ if (JSON.stringify(redacted).length > MAX_ELICIT_SCHEMA_CHARS)
46
46
  return undefined;
47
47
  }
48
48
  catch {
@@ -5,9 +5,11 @@
5
5
  * 与本仓的人面汇点同轴);`isolationScope` = **带场景的主体**(只在请求带了场景时有;引擎按它分登记域 / offload 租界 / 后台登记 / peer 目录 / 工作流 scope,
6
6
  * 引擎的读法是「隔离格缺席 ⇒ 读 `principal`」)。没带场景的请求只有 `principal`,与今天逐字节同。检查点的分区走本仓自己供的 `scope` 格。
7
7
  *
8
- * 今天的引擎还没有隔离格:{@link taskSpecIdentityOf} 是**唯一的落点**,今天只写 `principal`;隔离格到货后改那一行(钉在 `test/scenario-subject.test.ts`)。
9
- * 落点之前引擎自己按 `spec.principal` 分的那几面按人分(同一个人的各场景在那几面互见)—— 本仓镜像这几面的读口(工作流读面、后台登记簿的停止标记、
10
- * leader 子任务的 spec)同读 {@link taskSpecIdentityOf},读到的就是引擎写下的那一个值,不各写一份。
8
+ * 今天的引擎还没有隔离格:{@link taskSpecIdentityOf} 是**唯一的落点**,今天只写 `principal`;隔离格到货后改那一行(钉在 `test/scenario-subject.test.ts`),
9
+ * {@link engineScopeOf} 同一提交换读(钉在 `test/workflow-scope-core-parity.test.ts`)。
10
+ * 落点之前引擎自己按 `spec.principal` 分的那几面按人分(同一个人的各场景在那几面互见)。本仓读这几面(工作流行的 `scope` 列、后台登记簿与它的停止标记、
11
+ * 会话信箱盒与被扣来信的队列、名册)时「一只主体 ⇒ 那一格 scope」只有一只换算 {@link engineScopeOf},读到的就是引擎写下的那一个值,不各写一份;
12
+ * leader 子任务与提交腿的 spec 同经落点 {@link taskSpecIdentityOf}。
11
13
  */
12
14
  import { type Person, type Subject, type SubjectParts } from "./owner-brands.js";
13
15
  /** 引擎交界的身份(本仓的类型;二元)。 */
@@ -20,15 +22,25 @@ export interface EngineIdentity {
20
22
  export declare function specIdentityOf(parts: SubjectParts | undefined): EngineIdentity;
21
23
  /**
22
24
  * 落进 `TaskSpec` 的身份格(**唯一落点**)。今天的引擎没有隔离格 ⇒ 只写 `principal`,`isolationScope` 在这里不落(引擎按人分它自己的那几面);
23
- * 引擎的隔离格到货 ⇒ 这里加一格,别处不动。
25
+ * 引擎的隔离格到货 ⇒ 这里加一格,同一提交里 {@link engineScopeOf} 改读 core 的 `isolationScopeOf`(身份格闭集型在那里编译红,逼读法表态),别处不动。
24
26
  */
25
27
  export declare function taskSpecIdentityOf(parts: SubjectParts | undefined): {
26
28
  readonly principal?: string;
27
29
  };
28
30
  /**
29
- * 引擎按身份分的那几面落下的 **scope**(core 写侧 `spec.principal ?? "default"` 的同一条读法;工作流行的 `scope` 列就是它):一只主体 ⇒ 落点 {@link taskSpecIdentityOf}
30
- * 写下的人;匿名 ⇒ 单机形的租户键 `"default"`(`owner-faces.ts` 的 `LEGACY_UNOWNED_AMNESTY_TENANT`)。读者只在属主存取器(`http/owner-access.ts`):工作流按 id 的门
31
- * (调用方一侧按它换成引擎身份再与行的 scope 比)与工作流列表的属主过滤同读这一只;承认之后 journal / 流按承认的那一行的 scope 读。
31
+ * 🔴 **一只主体在引擎按身份分的那几面上的 scope —— 唯一一只换算**(工作流行的 `scope` 列 / 后台登记簿 / 会话信箱盒与被扣来信的队列 / 停止标记 / 名册:
32
+ * 引擎写下它们时用的那一个值)。规则 = core 写侧那一条,落在本仓交给引擎的身份格({@link taskSpecIdentityOf})上 ⇒ {@link scopeOfLanded}:
33
+ * · core 7.66.0(本仓钉的版本):工作流行 `scope` = `ctx.principal ?? 挂载 scope`(`createRunWorkflowTool` 的 `execute` 里的 `taskScope`;`startWorkflow` 缺席落
34
+ * `"default"`)—— `ctx.principal` 是 Runner 填的 `spec.principal`;挂载 scope 与后台登记簿 / 被扣来信队列同一个量,即 Runner 准备任务时算的任务 scope
35
+ * `registryScope ?? spec.principal ?? "default"`(同一个值挂进 `run_workflow`、交给信箱排空腿开 held 队列)。本仓不供 `registryScope` ⇒ 各面同值 = 落下的
36
+ * `principal`,匿名 = `"default"`。
37
+ * · core 的下一形([ref] 隔离格随 7.68.0 到货;[ref] 同版根导出 `callScopeOf` / `isolationScopeOf`):`callScopeOf(ctx, 挂载) = ctx.isolationScope ?? 挂载.scope`,
38
+ * Runner 把 `ctx.isolationScope` 填成 `isolationScopeOf(spec) = spec.isolationScope || spec.principal`;落点只写 `principal` 时两形同值。
39
+ * **随 core [ref] 到货换读、退本读法**:提货车让落点写出隔离格的同一提交里,这里改读 core 根导出的 `isolationScopeOf`(落下的身份格 ⇒ `?? "default"`),
40
+ * {@link scopeOfLanded} 退役 —— 落点多一格而读法没表态 = 编译红(身份格闭集,见它)。真 core 对拍钉:`test/workflow-scope-core-parity.test.ts`。
41
+ * 工作流行「归谁」只在属主存取器经它判(`http/owner-access.ts` 的 `workflowScopeOf`:列表 / 按 id / 舰队流同读)。
32
42
  */
33
43
  export declare function engineScopeOf(subject: Subject | undefined): string;
44
+ /** 一只**持久的**属主串(会话 / run 行的属主列、续跑腿交来的属主、请求鉴权句柄的纯串主体)在那几面上的 scope:先过内部恢复管线,再经 {@link engineScopeOf};无主 ⇒ 匿名那一格。 */
45
+ export declare function engineScopeOfOwner(owner: string | null | undefined): string;
34
46
  //# sourceMappingURL=engine-identity.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { partsOf } from "./owner-brands.js";
2
- import { LEGACY_UNOWNED_AMNESTY_TENANT } from "./owner-faces.js";
2
+ import { LEGACY_UNOWNED_AMNESTY_TENANT, recoveredSubject } from "./owner-faces.js";
3
3
  export function specIdentityOf(parts) {
4
4
  if (parts === undefined)
5
5
  return { principal: undefined };
@@ -10,6 +10,14 @@ export function taskSpecIdentityOf(parts) {
10
10
  return principal === undefined ? {} : { principal };
11
11
  }
12
12
  export function engineScopeOf(subject) {
13
- return taskSpecIdentityOf(subject === undefined ? undefined : partsOf(subject)).principal ?? LEGACY_UNOWNED_AMNESTY_TENANT;
13
+ return scopeOfLanded(taskSpecIdentityOf(subject === undefined ? undefined : partsOf(subject)));
14
+ }
15
+ export function engineScopeOfOwner(owner) {
16
+ return engineScopeOf(recoveredSubject(owner));
17
+ }
18
+ function scopeOfLanded(landed) {
19
+ const { principal, ...unread } = landed;
20
+ unread;
21
+ return principal ?? LEGACY_UNOWNED_AMNESTY_TENANT;
14
22
  }
15
23
  //# sourceMappingURL=engine-identity.js.map
@@ -10,7 +10,8 @@
10
10
  * ## 铸点(唯一)
11
11
  * {@link buildEntryModeClampNotice} 是本码**唯一**的铸点;调用点只有一处:`http/admission.ts` 的 `prepareSpec`(提交入口,盖章之后、装配
12
12
  * 之后 —— 那时会话 id 才定)。一次提交一次 ⇒ 一条 run 至多一帧(core 码册的去重单位「once per run」)。读的是盖章那一次求值的读数
13
- * (`EntryPermissionMode`),不另判一遍「折没折」。续跑腿不铸:它们重放的是已盖过章的存储体,折叠只发生过一次。
13
+ * (`EntryPermissionMode`),不另判一遍「折没折」。续跑腿不铸:续跑口按**现**地板钳存储体的词时(`permission-mode-admission.ts` `stampReplayEntryMode`),
14
+ * 那一腿的生效词由它的 `wiring_manifest.permissionMode` 说(引擎收到的就是钳过的词);本码只说受理门那一折(per run 一帧)。
14
15
  * 装配期铸、腿开口那一拍投(`PreparedTaskSubmission.engineNotices` → `registerEngineNoticeLeg` 的 `pending`)—— 与请求腿 MCP 丢弃同一条投递路,
15
16
  * 白名单 / 归属 / 消毒 / 隔离一个不绕。
16
17
  *
@@ -1,14 +1,51 @@
1
+ /**
2
+ * **条目问题的机读位** —— 请求体里的工具名清单 / 规则表有坏条目时,拒体(提交口 400 · 设置规则 422 · 续跑重放 409)与受理应答(`warnings`)说「哪几条、为什么」的**唯一一只形**,一处铸。
3
+ *
4
+ * 形(拒体机读位的版式律:事实在拒体根上,`problems[]` 每项的领域结构原样):
5
+ * 拒体 `{ error, errorCode, field, problems: EntryProblem[], total }`
6
+ * 应答 `{ …, warnings: EntryProblem[] }`(受理了、没拒,只告;只在有话说时在场)
7
+ * 一条问题 `{ code, field, entry, reason }`:
8
+ * · `code` = 这一条所在的那张清单**被拒时**拒体会带的码(技能清单 `request.field_invalid`;子代定义的 `denyTools` / `allowTools` `config.agent.unknown_tool`;根 run 的
9
+ * `excludeTools` / `allowTools` `config.tool_face_control`;设置规则桶 `request.unprocessable`)—— 一条问题就是「一只迷你拒绝」;
10
+ * · `field` = 这一条所在清单的**体内坐标**(`agents[0].denyTools`、`excludeTools`、`settings.permissions.deny`;不带条目下标);
11
+ * · `entry` = 条目的脱敏原值({@link redactListEntry}:不加引号、不转义,认出的凭据换记号);
12
+ * · `reason` = 为什么这一条什么也不是,闭词:引擎条目读法的原因词原样(`near_miss` / `tool_name` / `grammar` / `content_unsupported` / `wildcard_all` / `namespace_wildcard`),
13
+ * 规则编译器那一面的判词(引擎名字判官的 `retired` / `unmintable_segment` / `unprefixed_namespace`、引擎规则文法的 `invalid.*` · `unsupported.*` 码原样),
14
+ * 契约包层准入的判词(`below_trust_floor`),与本仓自己的三词({@link SERVER_ENTRY_PROBLEM_REASONS})。铸点的实参型是这几张表的并({@link EntryProblemReason}):
15
+ * 写一个哪张表都没有的词 = tsc 红(本仓自己的词只能从闭集取)。
16
+ * · 拒体的 `error` 句子**不变**:码与句子仍是「先撞上的那一张清单」的(第一条问题的码与坐标 = 体的 `errorCode` 与顶层 `field`),机读位另把**这一遍判下来的全部问题**一次列全 ——
17
+ * 单条问题的体 = 列表长 1,不是另一种形。
18
+ * · `total` = 这一遍判下来的问题总数;`problems` 至多 {@link MAX_ENTRY_PROBLEMS} 条(按扫描序截,每张清单自己的条数帽另在先:超帽的清单整只拒、不逐条读,不进本列表)。
19
+ * `total > problems.length` ⇒ 被截过。拒体恒有 `total`,缺席的「被截与否」不靠数条数猜。
20
+ *
21
+ * 为什么机读位只有这一个铸点:壳要按条提示、不解析句子(句子给人读,`error` 文案冻结但不是协议);一个面一个自己的键表就是 [ref] / [ref] 之后又一种形。
22
+ */
23
+ import type { AllowEntryInertReason, PermissionRuleIssue } from "@sema-agent/core";
24
+ import type { LayerAdmissionVerdict } from "@sema-agent/settings-schema";
25
+ import type { UnmatchableRuleName } from "./namespaced-rule-name.js";
1
26
  /** `problems` 的条数上限(= 一张清单的条数帽 `MAX_ALLOW_LAYER_ENTRIES` 的数;数在这里写死一次,`rule-entry-list.ts` 的帽改了不应拖着机读位走 —— 两者是两个界)。 */
2
27
  export declare const MAX_ENTRY_PROBLEMS = 1000;
3
28
  /**
4
29
  * 本仓自己铸的 `reason` 词(闭集;其余 `reason` 是引擎的词原样 —— 见文件头):
5
30
  * · `not_in_roster` —— 受理应答 `warnings` 的词:放行侧选择器清单里的这个名字不在名册(引擎目录 ∪ 本仓自铸工具 ∪ 本请求挂的调用方工具)、也不是协议命名空间名(懒挂载),引擎照旧受理、之后只告运维;
6
- * · `home_unresolvable` —— 设置规则 422 的词:`~/` 形路径规则而本部署解不出执行环境的家目录。
31
+ * · `home_unresolvable` —— 设置规则 422 的词:`~/` 形路径规则而本部署解不出执行环境的家目录;
32
+ * · `cc_rule_form` —— 名表消费者(按**整串工具名**比对的那几张表:`settings.permissions.neverAuto`,以及运维 / 中心的审批名单)里的带括号条目:这张表只比整名,
33
+ * `Bash(ls)` 永远匹配不到任何活工具。判据是本仓这几张表的比对方式,不是引擎的读法(引擎的 allow 层对同一条另有判词,读的是另一张表)⇒ 本仓的词。
7
34
  */
8
- export declare const SERVER_ENTRY_PROBLEM_REASONS: readonly ["not_in_roster", "home_unresolvable"];
35
+ export declare const SERVER_ENTRY_PROBLEM_REASONS: readonly ["not_in_roster", "home_unresolvable", "cc_rule_form"];
9
36
  export type ServerEntryProblemReason = (typeof SERVER_ENTRY_PROBLEM_REASONS)[number];
10
37
  /** 「读得出、却不在名册」的告知词({@link SERVER_ENTRY_PROBLEM_REASONS} 的第一员):`warnings` 里它之外的词都是引擎的条目读法读成空的原因词。 */
11
38
  export declare const NOT_IN_ROSTER: ServerEntryProblemReason;
39
+ /** 「执行环境的家目录 / 配置根读不出」的拒词(设置规则 422;两个铸点同读这一只)。 */
40
+ export declare const HOME_UNRESOLVABLE: ServerEntryProblemReason;
41
+ /** 「名表消费者里的带括号条目」的拒词(`config.ts` 的名表判据是唯一铸点)。 */
42
+ export declare const CC_RULE_FORM: ServerEntryProblemReason;
43
+ /**
44
+ * 一条问题的 `reason` 可以是哪些词 —— 铸点实参的型(wire 上的 `reason` 仍按开集读:引擎的词表随引擎版本增减):
45
+ * 本仓自铸的三词 ∪ 引擎条目读法的原因词 ∪ 引擎名字判官的判词 ∪ 引擎规则文法的码 ∪ 契约包层准入的 `below_trust_floor`。
46
+ * 哪张表都没有的词在铸点 tsc 红 —— 「自铸了闭集外的词」不可能静默上 wire。
47
+ */
48
+ export type EntryProblemReason = ServerEntryProblemReason | AllowEntryInertReason | UnmatchableRuleName["kind"] | PermissionRuleIssue["code"] | Extract<LayerAdmissionVerdict, "below_trust_floor">;
12
49
  /** 一条问题(wire 形)。 */
13
50
  export interface EntryProblem {
14
51
  readonly code: string;
@@ -17,7 +54,7 @@ export interface EntryProblem {
17
54
  readonly reason: string;
18
55
  }
19
56
  /** 铸一条问题:`entry` 收**原串**,这里过脱敏(调用方没有「忘了脱敏」的可能)。 */
20
- export declare function entryProblem(code: string, field: string, rawEntry: string, reason: string): EntryProblem;
57
+ export declare function entryProblem(code: string, field: string, rawEntry: string, reason: EntryProblemReason): EntryProblem;
21
58
  /** 拒体上的机读位(原样摊在拒体根上:`HttpError.extra` / `refusalBody` 的 `facts`)。型别名而不是接口 —— 要能直接当 `Record<string, unknown>` 用。 */
22
59
  export type EntryProblemsFacts = {
23
60
  readonly field: string;
@@ -1,7 +1,9 @@
1
1
  import { redactListEntry } from "./list-entry-display.js";
2
2
  export const MAX_ENTRY_PROBLEMS = 1_000;
3
- export const SERVER_ENTRY_PROBLEM_REASONS = ["not_in_roster", "home_unresolvable"];
3
+ export const SERVER_ENTRY_PROBLEM_REASONS = ["not_in_roster", "home_unresolvable", "cc_rule_form"];
4
4
  export const NOT_IN_ROSTER = "not_in_roster";
5
+ export const HOME_UNRESOLVABLE = "home_unresolvable";
6
+ export const CC_RULE_FORM = "cc_rule_form";
5
7
  export function entryProblem(code, field, rawEntry, reason) {
6
8
  return { code, field, entry: redactListEntry(rawEntry), reason };
7
9
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 本仓自铸的**执行环境拒码**闭集(`env.*` 族)的唯一属主(纯叶:零值依赖)。
3
+ *
4
+ * 一族一句:**这只执行环境没开,而且再问也是同一个答** —— 部署状态(或会话数据)与这条 run 冲突,原样重试不改判,出路在部署。两处产出、同一族:
5
+ * · 工厂在铸环境之前拒(host 车道:读数在构造时就到手,`lane-home-probe.ts` 的 `laneHomeRefusal`;k8s 车道:每条 run 铸环境前读一次集群 API 凭据,
6
+ * `boot/execution-env.ts` 的 `createK8sRunEnvFactory`),都经 {@link executionEnvRefusalError} 铸带码的错,引擎在准备期原样再抛、run 以它失败;
7
+ * · 远端车道在建连时答的**立定拒**(这只环境此后每一次建连都答同一个拒,适配器记住它):码由 `plugins/remote-env-connect-seat.ts` 的拒因表从事实词拼出
8
+ * —— 那张表是远端车道拼本族码的唯一入口,立定 ⇔ 码在引擎可重试表之外 ⇔ 记住。
9
+ * 同步提交腿按零工作拒落档(`runs.ts` 的 `EXECUTION_ENV_REFUSAL_HTTP_STATUS`,按本闭集键控:加一员而档没跟 ⇒ tsc 红)。
10
+ * · `env.home_unconfirmed` —— 家目录主张证不了(`judgeLaneHome` 的三形拒句:读不出 / 不是绝对路径 / 与实测不一致;远端车道只在环境**答了**的两形上记住它)。
11
+ * 三形一个码:出路都在部署(声明、环境里的 `HOME`,或会话 `settings.env` 里的 `HOME`),消费端不按形分岔;是哪一形、怎么改,句子里说。
12
+ * · `env.snapshot_bucket_missing` —— k8s 车道的工作区快照桶不在(对象存储对 `latest` 或归档的读答 `404 NoSuchBucket`):建桶,或把
13
+ * `WORKSPACE_SNAPSHOT_BUCKET` 指向已有的桶,或 `WORKSPACE_PERSIST=off`。
14
+ * · `env.occupant_missing` —— k8s 车道读这条 run 的会话住客:会话行在、却不带住客令牌(存储数据缺陷,重发不改判):给行补令牌或删会话,或关掉要它的旋钮。
15
+ * · `env.sandbox_refused` —— 隔离车道(k8s / e2b / local-docker)替这条 run 建的沙箱被立定地拒:集群在准入时拒了 pod、成员凭据中继建不起来、
16
+ * 快照归档在桶里却取不回、工作区的填充(会话附件 / 项目包种子)放不进且换一台机器也是同一个答、k8s 车道的集群 API 凭据起服之后读不到或被集群 401 拒
17
+ * (`k8s-api-credentials.ts`:凭据起服时就缺是起服拒 `config.k8s_api_credentials_missing`,到不了 run)。是哪一件、怎么改,句子里说。
18
+ * · `env.host_key_rejected` —— ssh 车道:目标机出示的主机密钥过不了部署钉的判(`SSH_HOST_FINGERPRINT` / `SSH_KNOWN_HOSTS`:指纹不符、条目换了钥、被吊销、没有条目)。
19
+ * 改钉或查明对面为什么换了钥;同一配置同一主机每次同答。
20
+ */
21
+ export declare const EXECUTION_ENV_REFUSAL_CODES: readonly ["env.home_unconfirmed", "env.snapshot_bucket_missing", "env.occupant_missing", "env.sandbox_refused", "env.host_key_rejected"];
22
+ export type ExecutionEnvRefusalCode = (typeof EXECUTION_ENV_REFUSAL_CODES)[number];
23
+ /** 本族的带码错(唯一铸点):句 = 拒句原文,`code` = 闭集里的一员;工厂原样抛出,引擎在准备期再抛,run 的失败终局原样承运码与句。 */
24
+ export declare function executionEnvRefusalError<C extends ExecutionEnvRefusalCode>(code: C, message: string): Error & {
25
+ readonly code: C;
26
+ };
27
+ /** 这个码是不是本族的一员(按闭集,不按前缀:引擎自己的 `env.lifetime_expired` 同前缀而不是本族)。 */
28
+ export declare function isExecutionEnvRefusalCode(code: unknown): code is ExecutionEnvRefusalCode;
29
+ //# sourceMappingURL=execution-env-refusal.d.ts.map
@@ -0,0 +1,8 @@
1
+ export const EXECUTION_ENV_REFUSAL_CODES = ["env.home_unconfirmed", "env.snapshot_bucket_missing", "env.occupant_missing", "env.sandbox_refused", "env.host_key_rejected"];
2
+ export function executionEnvRefusalError(code, message) {
3
+ return Object.assign(new Error(message), { code });
4
+ }
5
+ export function isExecutionEnvRefusalCode(code) {
6
+ return typeof code === "string" && EXECUTION_ENV_REFUSAL_CODES.includes(code);
7
+ }
8
+ //# sourceMappingURL=execution-env-refusal.js.map
@@ -184,7 +184,7 @@ export declare function deployedExecutionLanes(config: Pick<ServiceConfigFlat, "
184
184
  * 读者问的都是这一句,**同一只函数**,不许各写一份 `=== "host"`:
185
185
  * ① 部署形表行 `toolsOnThisHost`(`deployment-shape.ts`)—— wire `executionLane.toolsOnThisHost` + 出厂自扫技能与中心 plugin 技能的 `baseDir`;
186
186
  * ② 部署形表行 `callerOwnsWorkerDisk`(本列 ∧ 单主)—— SendUserFile 本机腿(「无手不挂」)、调用方宿主路径(附加目录 / 项目上下文)、指令文件探针、
187
- * 本机语言服务器(`createLspManager`;这类车道的适配器必须绑得住读 `openBound`,对拍钉 `test/host-env-open-bound.test.ts`);
187
+ * 本机语言服务器(`createLspManager`;「绑得住读」`openBound` 不是本列的事,是每条有手车道的结构前提,见 {@link laneWiresExecutionEnv});
188
188
  * ③ `approval.ts` 的 `buildNoResponderBootWarns` —— 写门的 ask 只在「有手写本机盘」时才会发生(它手里已有车道词,直接读本列)。
189
189
  */
190
190
  export declare function handsOnWorkerFilePlane(lane: ExecutionLane): boolean;
@@ -230,6 +230,8 @@ export declare function laneIsolated(lane: ExecutionLane): boolean;
230
230
  * 这条车道**有没有手**(块 `io`:文件与 shell 两面真到达目标;`none` 的桩块 false)的唯一布尔口。读者四处:路由的「有没有执行环境」(`boot/resolve-spec.ts`)、
231
231
  * wire `executionLane.isolated` 的在场判据(`capabilities/execution-lane.ts`)、场景详情的附件供给集(`boot/stage-07-capability-layer.ts` 把它填进
232
232
  * `ScenarioDeps.handsLane`:「这一 run 有没有工作区」的车道半场)、起服家目录那一行({@link buildLaneHomeBootNote})—— 同读这一只。
233
+ * 有手车道的结构前提:适配器有绑定读面(`openBound`;设备的面 presence-typed,执行器声明了才装)—— 「能不能绑定读」的源是适配器对象本身,
234
+ * 本列不另存一位(对拍钉 `test/host-env-open-bound.test.ts` P3;本版唯一缓装 = ssh,同文件 `HELD_THIS_VERSION`,翻回条件钉在那里)。
233
235
  */
234
236
  export declare function laneWiresExecutionEnv(lane: ExecutionLane): boolean;
235
237
  /** 一条**已登记**的分叉:表写的是目标态,今天的判别式还答别的。 */
@@ -7,7 +7,7 @@ export type FieldConflictReason = (typeof FIELD_CONFLICT_REASONS)[number];
7
7
  * 动态下标的坐标用模板字面量型(`agents[1].skills`)。
8
8
  */
9
9
  export interface FieldConflictCoordinates {
10
- readonly cascade_verify: "verify" | "cascade" | "sandboxImageProfile" | "resumeAt" | "suggestNextPrompts";
10
+ readonly cascade_verify: "verify" | "cascade" | "sandboxImageProfile" | "resumeAt" | "rewindFilesTo" | "suggestNextPrompts";
11
11
  readonly image_profile: "capabilitiesNeeded" | "sandboxImageProfile";
12
12
  readonly resume_anchor: "resumeAtMode" | "resumeAt";
13
13
  readonly system_prompt_fold: "appendSystemPrompt" | "projectId" | "settings.outputStyle";
@@ -52,21 +52,28 @@ export interface FileHistoryAssembly {
52
52
  /** 擦除脸:在场 ⟺ 后端在(与旋钮无关;是 {@link store} 的删除类动词视图)。 */
53
53
  readonly erasure: FileHistoryErasureFace | undefined;
54
54
  }
55
- /** 装配:「这台部署有没有文件历史店」的唯一判定。旋钮不在这里 —— 它只关捕获,不摘店([ref])。 */
55
+ /** 「这台部署有没有文件历史店」的唯一判定:店是后端恒交的那一只(`StoreBackend.fileHistory()`,落定席位写的同一只)⇒ 店在 ⟺ 后端在。旋钮不在这里 ——
56
+ * 它只关捕获,不摘店([ref])。只问「在不在」的读者(能力位)读这一只,不必取店。 */
57
+ export declare function fileHistoryWired(backend: StoreBackend | undefined): backend is StoreBackend;
58
+ /** 装配:取那只店(判定 = {@link fileHistoryWired})。起服装配(引擎的还原族 / 擦除脸)与服务面要店的读者(同步族、rewind 口)都经这里取,手里有后端 ⇒ 型上就有店。 */
59
+ export declare function assembleFileHistory(backend: StoreBackend): {
60
+ readonly store: ServiceFileHistoryStore;
61
+ readonly erasure: FileHistoryErasureFace;
62
+ };
56
63
  export declare function assembleFileHistory(backend: StoreBackend | undefined): FileHistoryAssembly;
57
64
  /**
58
- * 「捕不捕」的**唯一**判定(纯函数):能力词。`store` = 装配出来的店(在不在),`knob` = 部署旋钮 `FILE_HISTORY_CAPTURE`
65
+ * 「捕不捕」的**唯一**判定(纯函数):能力词。`wired` = 店在不在({@link fileHistoryWired} 的答 / 装配出来的店在不在),`knob` = 部署旋钮 `FILE_HISTORY_CAPTURE`
59
66
  * (`config.fileHistoryCapture`)。从**装配结果**派生,不照旋钮字面回声:后端本来就没有这只店的部署同样是 `off`。
60
67
  *
61
68
  * 与 `restoreFiles` 分叉([ref] 当时写下的分叉条件,自 [ref] 成真):本词答「这台部署捕不捕、能不能按 run 关掉」,
62
69
  * `restoreFiles` 答「这台部署能不能还原」—— 旋钮关的部署本词 `off` 而 `restoreFiles` 仍为真。
63
70
  */
64
- export declare function fileHistoryCaptureOf(store: object | undefined, knob: boolean): FileHistoryCapture;
71
+ export declare function fileHistoryCaptureOf(wired: boolean, knob: boolean): FileHistoryCapture;
65
72
  /**
66
73
  * core 的部署捕获位 `RunnerDeps.fileHistoryCapture`,由 {@link fileHistoryCaptureOf} 派生(同一组输入、同一只判定)。
67
74
  * 形照 `execution-lane-caps.ts` 的穷举 switch(无 default 臂):能力词加一个而这里不加臂 ⇒ 编译红 —— 加臂的那一刻就是
68
75
  * 决定「这一词下 core 的捕获位怎么递」的地方。没有店 ⇒ 恒 `undefined`(core 对「off 但没店」拒 prepare)。
69
76
  */
70
- export declare function coreFileHistoryCaptureSeat(store: object | undefined, knob: boolean): RunnerDeps["fileHistoryCapture"];
77
+ export declare function coreFileHistoryCaptureSeat(wired: boolean, knob: boolean): RunnerDeps["fileHistoryCapture"];
71
78
  export {};
72
79
  //# sourceMappingURL=file-history-capture.d.ts.map
@@ -3,19 +3,22 @@ const FILE_HISTORY_CAPTURE_WORD_SET = {
3
3
  "on-optional": true,
4
4
  };
5
5
  export const FILE_HISTORY_CAPTURE_WORDS = Object.keys(FILE_HISTORY_CAPTURE_WORD_SET);
6
+ export function fileHistoryWired(backend) {
7
+ return backend !== undefined;
8
+ }
6
9
  export function assembleFileHistory(backend) {
7
- if (backend === undefined)
10
+ if (!fileHistoryWired(backend))
8
11
  return { store: undefined, erasure: undefined };
9
12
  const physical = backend.fileHistory();
10
13
  return { store: physical, erasure: physical };
11
14
  }
12
- export function fileHistoryCaptureOf(store, knob) {
13
- return store !== undefined && knob ? "on-optional" : "off";
15
+ export function fileHistoryCaptureOf(wired, knob) {
16
+ return wired && knob ? "on-optional" : "off";
14
17
  }
15
- export function coreFileHistoryCaptureSeat(store, knob) {
16
- if (store === undefined)
18
+ export function coreFileHistoryCaptureSeat(wired, knob) {
19
+ if (!wired)
17
20
  return undefined;
18
- const word = fileHistoryCaptureOf(store, knob);
21
+ const word = fileHistoryCaptureOf(wired, knob);
19
22
  switch (word) {
20
23
  case "off":
21
24
  return "off";
@@ -50,16 +50,18 @@ export interface CaughtFailure {
50
50
  readonly fault: Pick<FileHistoryError, "permanence">;
51
51
  }
52
52
  /**
53
- * 把一个 caught error 折成店侧的散文 + 判断,**并**在它是一枚 typed 永久失败时留痕。
53
+ * 把一个 caught error 折成店侧的散文 + 判断,**并**在它是一枚 typed 永久失败时留痕。**先读店边界**(`storeBoundaryFault`,`site` = 折点所在的店方法):
54
+ * 文件历史店把失败**返回**成值(不抛),值里的文本取自这里 —— 驱动错(以及词法外的码:工作区 fs 的 `ENOENT` / `EACCES`、对象存储的码)在这里换成边界形
55
+ * (类别句 + 原码尾注,原句进运维日志 `at=store` 一行),返回值里不再带库的原话。
54
56
  *
55
- * `text` = 散文形:带 typed `code` 的前缀一个括号词(`(blob_too_large_for_sql) blob of … exceeds …`),
56
- * 不带的**逐字**是原 message(transient 失败的文案因此与本批之前一字不差)。
57
+ * `text` = 散文形:带本仓词法内 `code` 的(typed 失败:`blob_too_large_for_sql` 一类)前缀一个括号词(`(blob_too_large_for_sql) blob of … exceeds …`),
58
+ * 其余逐字是(过了边界的)message —— 边界句自带 `[original code: <码>]` 尾注,不再前缀第二遍码。
57
59
  * `fault` = 判断形(core 7.55.0 `FileHistoryError.permanence`):永久码表里的码 ⇒ `{ permanence: "terminal" }`;连接类故障 ⇒ `{ permanence: "transient" }`
58
60
  * (什么都不改稍后再试可能成);部署错配类故障 ⇒ `{ permanence: "terminal" }`(修表 / 授权之前重试注定失败);其余 ⇒ `{}`(店不知道 —— 认不出的驱动 / 库错是不是会自己好,不归本店判)。
59
- * 永久码先于分类判(一只错不会两个都是);分类词只读判官 `storeFaultClassOf`,本文件不写码。
61
+ * 永久码先于分类判(一只错不会两个都是);分类词只读判官 `storeFaultClassOf`(边界形带着它在原错上判的词),本文件不写码。
60
62
  * 副作用 = 机器形:码取自错误对象,逐次计数 + 每进程每码一条 warn。观测绝不抛。
61
63
  */
62
- export declare function foldCaughtFailure(err: unknown): CaughtFailure;
64
+ export declare function foldCaughtFailure(err: unknown, site: string): CaughtFailure;
63
65
  /** 装配层把 logger/metrics 接上(main.ts,与 `installFailOpenRecorder` 同一处)。 */
64
66
  export declare function installFileHistoryFailureRecorder(deps: Sink): void;
65
67
  /** 本进程逐码累计(测试/诊断读面)。 */
@@ -1,5 +1,6 @@
1
1
  import { FILE_HISTORY_ERROR_CODES, FileHistoryStoreError } from "@sema-agent/core";
2
2
  import { storeFaultClassOf } from "./plugins/store-fault.js";
3
+ import { outwardFailureCode, storeBoundaryFault } from "./terminal.js";
3
4
  const PERMANENT_STORE_FAILURE_CODES = {
4
5
  blob_too_large_for_sql: {
5
6
  note: "a blob is larger than this deployment's SQL snapshot-blob cap — the same file will fail every turn until the deployment changes",
@@ -30,16 +31,17 @@ function drainToMetrics() {
30
31
  }
31
32
  }
32
33
  }
33
- export function foldCaughtFailure(err) {
34
- const message = err instanceof Error ? err.message : String(err);
35
- const code = err?.code;
36
- const typedCode = typeof code === "string" && code !== "" ? code : undefined;
34
+ export function foldCaughtFailure(err, site) {
35
+ const seen = storeBoundaryFault(err, site);
36
+ const message = seen instanceof Error ? seen.message : String(seen);
37
+ const code = seen?.code;
38
+ const typedCode = typeof code === "string" && code !== "" && outwardFailureCode(code) === code ? code : undefined;
37
39
  const permanentCode = typedCode !== undefined && isPermanentCode(typedCode) ? typedCode : undefined;
38
40
  if (permanentCode !== undefined)
39
41
  recordPermanent(permanentCode, message);
40
42
  return {
41
43
  text: typedCode !== undefined ? `(${typedCode}) ${message}` : message,
42
- fault: permanentCode !== undefined ? { permanence: "terminal" } : faultOfClass(storeFaultClassOf(err)),
44
+ fault: permanentCode !== undefined ? { permanence: "terminal" } : faultOfClass(storeFaultClassOf(seen)),
43
45
  };
44
46
  }
45
47
  function faultOfClass(cls) {