@sema-agent/server 7.132.0 → 7.134.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 (473) hide show
  1. package/MIGRATION.md +353 -0
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +7 -6
  4. package/USAGE.md +301 -64
  5. package/deploy/sema-up/README.md +35 -1
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
  9. package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
  10. package/deploy/sema-up/chart/templates/server-v4pro.yaml +19 -2
  11. package/deploy/sema-up/chart/templates/server.yaml +19 -2
  12. package/deploy/sema-up/chart/values-full-single.yaml +5 -1
  13. package/deploy/sema-up/chart/values.yaml +34 -0
  14. package/deploy/sema-up/stack/compose.yaml +3 -0
  15. package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
  16. package/dist/adoption/plan.d.ts +3 -2
  17. package/dist/adoption/plan.js +7 -5
  18. package/dist/adoption/runner.js +3 -10
  19. package/dist/adoption/sql.d.ts +3 -2
  20. package/dist/adoption/sql.js +3 -5
  21. package/dist/adoption/wire.d.ts +4 -1
  22. package/dist/adoption/wire.js +1 -0
  23. package/dist/approval-ask-audit-store.d.ts +32 -14
  24. package/dist/approval-ask-audit-store.js +272 -74
  25. package/dist/approval-ask-machine.d.ts +15 -0
  26. package/dist/approval-ask-machine.js +6 -0
  27. package/dist/approval-ask-retention.d.ts +136 -0
  28. package/dist/approval-ask-retention.js +102 -0
  29. package/dist/approval-card.d.ts +83 -23
  30. package/dist/approval-card.js +45 -15
  31. package/dist/approval-content-kind.d.ts +5 -2
  32. package/dist/approval-content-kind.js +16 -3
  33. package/dist/approval-deny-reasons.d.ts +1 -1
  34. package/dist/approval-gate-currency.d.ts +72 -0
  35. package/dist/approval-gate-currency.js +94 -0
  36. package/dist/approval.d.ts +15 -0
  37. package/dist/approval.js +55 -17
  38. package/dist/audit.d.ts +27 -10
  39. package/dist/audit.js +12 -16
  40. package/dist/bake-runner/main.js +3 -2
  41. package/dist/boot/coordinators.d.ts +6 -1
  42. package/dist/boot/coordinators.js +6 -3
  43. package/dist/boot/deferred-sandbox-path-env.js +1 -1
  44. package/dist/boot/execution-env.js +9 -7
  45. package/dist/boot/execution-lane.js +11 -0
  46. package/dist/boot/leader.d.ts +2 -0
  47. package/dist/boot/leader.js +4 -1
  48. package/dist/boot/memory-boundary.js +2 -2
  49. package/dist/boot/memory-consolidation.d.ts +5 -4
  50. package/dist/boot/memory-consolidation.js +7 -6
  51. package/dist/boot/org-delivery.d.ts +28 -0
  52. package/dist/boot/org-delivery.js +20 -0
  53. package/dist/boot/read-deny-anchor-audit.js +2 -2
  54. package/dist/boot/reapers.d.ts +3 -0
  55. package/dist/boot/reapers.js +21 -1
  56. package/dist/boot/resolve-spec.d.ts +3 -0
  57. package/dist/boot/resolve-spec.js +60 -81
  58. package/dist/boot/runner-deps.d.ts +18 -5
  59. package/dist/boot/runner-deps.js +10 -0
  60. package/dist/boot/session-faces.d.ts +1 -0
  61. package/dist/boot/session-faces.js +4 -2
  62. package/dist/boot/stage-02-web-admin-pull.js +4 -1
  63. package/dist/boot/stage-06-runners.d.ts +6 -3
  64. package/dist/boot/stage-06-runners.js +20 -4
  65. package/dist/boot/stage-07-capability-layer.d.ts +4 -1
  66. package/dist/boot/stage-07-capability-layer.js +24 -3
  67. package/dist/boot/stage-08-reapers.d.ts +4 -1
  68. package/dist/boot/stage-08-reapers.js +2 -2
  69. package/dist/boot/stage-09-leader.d.ts +5 -1
  70. package/dist/boot/stage-09-leader.js +2 -2
  71. package/dist/boot/stage-10-http-server.d.ts +5 -1
  72. package/dist/boot/stage-10-http-server.js +6 -6
  73. package/dist/boot/stores.d.ts +8 -0
  74. package/dist/boot/stores.js +10 -14
  75. package/dist/boot/web-admin.d.ts +10 -0
  76. package/dist/boot/web-admin.js +162 -65
  77. package/dist/boot/workflow-orchestration.d.ts +2 -0
  78. package/dist/boot/workflow-orchestration.js +2 -1
  79. package/dist/brain.js +8 -3
  80. package/dist/breaker-key.d.ts +6 -0
  81. package/dist/breaker-key.js +29 -0
  82. package/dist/budget.js +5 -1
  83. package/dist/caller-text-echo.d.ts +11 -6
  84. package/dist/caller-text-echo.js +10 -12
  85. package/dist/canonical-json.d.ts +2 -41
  86. package/dist/canonical-json.js +2 -13
  87. package/dist/capabilities/center-plugins.d.ts +7 -0
  88. package/dist/capabilities/center-plugins.js +1 -1
  89. package/dist/capabilities/composite-members.d.ts +1 -1
  90. package/dist/capabilities/composite-members.js +1 -1
  91. package/dist/capabilities/execution-lane.js +2 -2
  92. package/dist/capabilities/hands-lane.d.ts +21 -0
  93. package/dist/capabilities/hands-lane.js +10 -0
  94. package/dist/capabilities/mcp-probe.d.ts +36 -4
  95. package/dist/capabilities/mcp-probe.js +29 -6
  96. package/dist/capabilities/scenarios.d.ts +63 -7
  97. package/dist/capabilities/scenarios.js +39 -7
  98. package/dist/capability-facts.d.ts +36 -4
  99. package/dist/capability-facts.js +30 -4
  100. package/dist/center-config-tier.d.ts +69 -0
  101. package/dist/center-config-tier.js +42 -0
  102. package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
  103. package/dist/checkpoint-ctx-seal-m28.js +19 -0
  104. package/dist/checkpoint-identity.d.ts +16 -0
  105. package/dist/checkpoint-identity.js +19 -0
  106. package/dist/config-catalog.d.ts +17 -10
  107. package/dist/config-catalog.js +43 -28
  108. package/dist/config-d-migration.d.ts +3 -1
  109. package/dist/config-d-migration.js +2 -2
  110. package/dist/config-dir-trust.d.ts +114 -0
  111. package/dist/config-dir-trust.js +388 -0
  112. package/dist/config-invariants.d.ts +18 -5
  113. package/dist/config-invariants.js +35 -3
  114. package/dist/config-provider.d.ts +6 -1
  115. package/dist/config-provider.js +6 -2
  116. package/dist/config-types.d.ts +71 -14
  117. package/dist/config-types.js +8 -0
  118. package/dist/config.d.ts +13 -0
  119. package/dist/config.js +121 -59
  120. package/dist/delegated-session-owner.d.ts +185 -0
  121. package/dist/delegated-session-owner.js +119 -0
  122. package/dist/device-protocol.d.ts +5 -3
  123. package/dist/device-protocol.js +1 -1
  124. package/dist/device-ws-hub.js +21 -2
  125. package/dist/device-ws-protocol.d.ts +70 -6
  126. package/dist/device-ws-protocol.js +50 -23
  127. package/dist/elicitation.js +3 -2
  128. package/dist/entry-problems.d.ts +34 -0
  129. package/dist/entry-problems.js +14 -0
  130. package/dist/execution-lane-caps.d.ts +49 -10
  131. package/dist/execution-lane-caps.js +43 -4
  132. package/dist/field-conflict.d.ts +44 -0
  133. package/dist/field-conflict.js +21 -0
  134. package/dist/file-history-disclosure.d.ts +34 -5
  135. package/dist/file-history-disclosure.js +2 -2
  136. package/dist/fleet/fleet-bus.d.ts +84 -6
  137. package/dist/fleet/fleet-bus.js +42 -9
  138. package/dist/hooks/classic-stations.d.ts +10 -5
  139. package/dist/hooks/classic-stations.js +4 -4
  140. package/dist/hooks/command-spawn.d.ts +57 -0
  141. package/dist/hooks/command-spawn.js +139 -0
  142. package/dist/hooks/hook-llm.js +2 -2
  143. package/dist/hooks/hook-runner.d.ts +127 -25
  144. package/dist/hooks/hook-runner.js +668 -287
  145. package/dist/hooks/hook-source.d.ts +44 -0
  146. package/dist/hooks/hook-source.js +40 -0
  147. package/dist/http/active-run-conflict.d.ts +5 -13
  148. package/dist/http/active-run-conflict.js +17 -27
  149. package/dist/http/admission.js +111 -60
  150. package/dist/http/approval-sweeps.js +58 -19
  151. package/dist/http/caller-trust.d.ts +77 -0
  152. package/dist/http/caller-trust.js +143 -0
  153. package/dist/http/checkpoint-ctx.d.ts +173 -18
  154. package/dist/http/checkpoint-ctx.js +171 -12
  155. package/dist/http/claimed-run.d.ts +4 -3
  156. package/dist/http/device-placement.d.ts +2 -4
  157. package/dist/http/device-placement.js +2 -1
  158. package/dist/http/dispatch.js +13 -7
  159. package/dist/http/durable-run-leg.d.ts +4 -32
  160. package/dist/http/durable-run-leg.js +37 -12
  161. package/dist/http/idempotency.d.ts +2 -2
  162. package/dist/http/idempotency.js +2 -2
  163. package/dist/http/owner-access.d.ts +56 -0
  164. package/dist/http/owner-access.js +42 -0
  165. package/dist/http/principal-gate.d.ts +78 -27
  166. package/dist/http/principal-gate.js +64 -14
  167. package/dist/http/readiness.d.ts +11 -5
  168. package/dist/http/readiness.js +10 -3
  169. package/dist/http/refusal-body.d.ts +12 -0
  170. package/dist/http/refusal-body.js +11 -0
  171. package/dist/http/request-guards.d.ts +16 -32
  172. package/dist/http/request-guards.js +31 -30
  173. package/dist/http/resume-ctx-read.d.ts +50 -6
  174. package/dist/http/resume-ctx-read.js +33 -7
  175. package/dist/http/resume-legs.d.ts +5 -5
  176. package/dist/http/resume-legs.js +163 -91
  177. package/dist/http/retired-service-deps.d.ts +43 -0
  178. package/dist/http/retired-service-deps.js +18 -0
  179. package/dist/http/route-ctx.d.ts +44 -37
  180. package/dist/http/route-ctx.js +4 -0
  181. package/dist/http/route-table.js +2 -0
  182. package/dist/http/routes/a2a-serve.js +3 -4
  183. package/dist/http/routes/admin-config-refresh.js +1 -1
  184. package/dist/http/routes/admin-drain.js +1 -1
  185. package/dist/http/routes/admin-memory-optout.js +5 -1
  186. package/dist/http/routes/adoption.js +2 -9
  187. package/dist/http/routes/agents-roster.js +2 -3
  188. package/dist/http/routes/approvals-assistant.js +91 -56
  189. package/dist/http/routes/background.js +3 -2
  190. package/dist/http/routes/capabilities.js +20 -4
  191. package/dist/http/routes/config-catalog.d.ts +3 -3
  192. package/dist/http/routes/config-catalog.js +1 -1
  193. package/dist/http/routes/devices.js +3 -17
  194. package/dist/http/routes/diagnostics.d.ts +3 -3
  195. package/dist/http/routes/diagnostics.js +6 -2
  196. package/dist/http/routes/fleet.js +4 -4
  197. package/dist/http/routes/images.js +6 -7
  198. package/dist/http/routes/leader.js +1 -8
  199. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  200. package/dist/http/routes/mcp-reconnect.js +3 -2
  201. package/dist/http/routes/memory-bundle.js +1 -1
  202. package/dist/http/routes/memory-compliance.js +1 -1
  203. package/dist/http/routes/memory-consolidation.js +1 -1
  204. package/dist/http/routes/memory-origin.d.ts +1 -1
  205. package/dist/http/routes/memory-origin.js +1 -1
  206. package/dist/http/routes/memory-policy.d.ts +1 -1
  207. package/dist/http/routes/memory-policy.js +3 -2
  208. package/dist/http/routes/notify-wake.js +8 -21
  209. package/dist/http/routes/observability.js +2 -2
  210. package/dist/http/routes/principal-inbox.d.ts +39 -0
  211. package/dist/http/routes/principal-inbox.js +76 -0
  212. package/dist/http/routes/retention-ops.js +2 -9
  213. package/dist/http/routes/rules.js +9 -22
  214. package/dist/http/routes/runs.d.ts +5 -0
  215. package/dist/http/routes/runs.js +63 -115
  216. package/dist/http/routes/session-sync.d.ts +3 -2
  217. package/dist/http/routes/session-sync.js +53 -48
  218. package/dist/http/routes/sessions-list.d.ts +1 -1
  219. package/dist/http/routes/sessions-list.js +3 -4
  220. package/dist/http/routes/sessions.js +33 -43
  221. package/dist/http/routes/side-query.js +6 -4
  222. package/dist/http/routes/tasks.js +71 -30
  223. package/dist/http/routes/trace-usage.js +7 -9
  224. package/dist/http/routes/workflows.d.ts +351 -0
  225. package/dist/http/routes/workflows.js +153 -119
  226. package/dist/http/run-declared-families.d.ts +16 -0
  227. package/dist/http/run-declared-families.js +12 -0
  228. package/dist/http/send.d.ts +24 -3
  229. package/dist/http/send.js +14 -2
  230. package/dist/http/server.d.ts +23 -18
  231. package/dist/http/server.js +20 -15
  232. package/dist/http/stored-body-replay.js +17 -4
  233. package/dist/http/submit-ctx.d.ts +4 -3
  234. package/dist/http/submit-ctx.js +23 -6
  235. package/dist/http/submit-replay.d.ts +4 -3
  236. package/dist/http/submit-replay.js +5 -4
  237. package/dist/http/wire-types.d.ts +17 -10
  238. package/dist/index.d.ts +3 -1
  239. package/dist/index.js +1 -1
  240. package/dist/lane-home-probe.d.ts +78 -9
  241. package/dist/lane-home-probe.js +78 -12
  242. package/dist/leader/endpoint.d.ts +4 -1
  243. package/dist/leader/endpoint.js +11 -10
  244. package/dist/leader/wire.d.ts +4 -0
  245. package/dist/leader/wire.js +8 -7
  246. package/dist/limit-refusal.d.ts +17 -5
  247. package/dist/limit-refusal.js +4 -1
  248. package/dist/main.js +1 -1
  249. package/dist/mcp-assertion-header.d.ts +31 -10
  250. package/dist/mcp-assertion-header.js +10 -3
  251. package/dist/memory-origin-fence.js +2 -2
  252. package/dist/memory-project-layer.d.ts +37 -0
  253. package/dist/memory-project-layer.js +46 -0
  254. package/dist/memory-scope.d.ts +23 -16
  255. package/dist/memory-scope.js +24 -8
  256. package/dist/memory-sync-client.d.ts +27 -13
  257. package/dist/memory-sync-client.js +107 -18
  258. package/dist/model-compat.d.ts +1 -1
  259. package/dist/model-entry-refusal.d.ts +9 -1
  260. package/dist/model-entry-refusal.js +6 -1
  261. package/dist/model-plane-face.d.ts +51 -0
  262. package/dist/model-plane-face.js +24 -0
  263. package/dist/model-provider.d.ts +5 -0
  264. package/dist/model-provider.js +4 -2
  265. package/dist/model-route-endpoint.d.ts +8 -11
  266. package/dist/model-route-endpoint.js +4 -7
  267. package/dist/model-route-env.d.ts +22 -0
  268. package/dist/model-route-env.js +2 -0
  269. package/dist/model-route-gap.d.ts +60 -30
  270. package/dist/model-route-gap.js +21 -15
  271. package/dist/observability/corrupt-read-seat.d.ts +7 -0
  272. package/dist/observability/corrupt-read-seat.js +9 -0
  273. package/dist/observability/err-text.d.ts +6 -0
  274. package/dist/observability/err-text.js +18 -4
  275. package/dist/observability/fail-open.d.ts +35 -9
  276. package/dist/observability/fail-open.js +35 -9
  277. package/dist/observability/metrics.js +1 -0
  278. package/dist/observability/prompt-manifest.d.ts +22 -25
  279. package/dist/observability/prompt-manifest.js +54 -50
  280. package/dist/observability/tool-trace.js +9 -10
  281. package/dist/operator-ask.d.ts +10 -0
  282. package/dist/operator-ask.js +3 -0
  283. package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
  284. package/dist/orchestration/workflow-agent-session-index.js +9 -13
  285. package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
  286. package/dist/orchestration/workflow-completion-inbox.js +13 -0
  287. package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
  288. package/dist/orchestration/workflow-notify-journal.js +27 -34
  289. package/dist/orchestration/workflow-park-decision.d.ts +89 -0
  290. package/dist/orchestration/workflow-park-decision.js +119 -0
  291. package/dist/org-delivery-gate.d.ts +81 -0
  292. package/dist/org-delivery-gate.js +59 -0
  293. package/dist/panel-tool-names.d.ts +23 -0
  294. package/dist/panel-tool-names.js +8 -0
  295. package/dist/parked-decide.d.ts +43 -11
  296. package/dist/parked-decide.js +100 -51
  297. package/dist/parked-revive-surface.d.ts +9 -2
  298. package/dist/parked-revive-surface.js +11 -8
  299. package/dist/permission-rule-list.d.ts +1 -1
  300. package/dist/permission-rule-list.js +2 -2
  301. package/dist/permission-rule-vocab.d.ts +1 -23
  302. package/dist/permission-rule-vocab.js +0 -13
  303. package/dist/plugins/approval-ask-store-file.d.ts +16 -1
  304. package/dist/plugins/approval-ask-store-file.js +21 -0
  305. package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
  306. package/dist/plugins/approval-ask-store-memory.js +34 -2
  307. package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
  308. package/dist/plugins/approval-ask-store-sql.js +37 -1
  309. package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
  310. package/dist/plugins/approval-payload-fingerprint.js +1 -1
  311. package/dist/plugins/blob-backend.d.ts +38 -25
  312. package/dist/plugins/blob-backend.js +29 -19
  313. package/dist/plugins/breaker-state-sql.d.ts +2 -2
  314. package/dist/plugins/breaker-state-sql.js +4 -4
  315. package/dist/plugins/caching-session-store.d.ts +4 -1
  316. package/dist/plugins/caching-session-store.js +7 -3
  317. package/dist/plugins/checkpoint-store-sql.d.ts +36 -1
  318. package/dist/plugins/checkpoint-store-sql.js +65 -3
  319. package/dist/plugins/file-history-store-sql.d.ts +5 -2
  320. package/dist/plugins/file-history-store-sql.js +3 -1
  321. package/dist/plugins/file-run-store.d.ts +5 -13
  322. package/dist/plugins/file-run-store.js +9 -0
  323. package/dist/plugins/fork-routing-session-store.d.ts +9 -1
  324. package/dist/plugins/fork-routing-session-store.js +12 -1
  325. package/dist/plugins/host-platform.d.ts +2 -0
  326. package/dist/plugins/host-platform.js +2 -1
  327. package/dist/plugins/local-checkpoint-store.d.ts +15 -2
  328. package/dist/plugins/local-checkpoint-store.js +32 -1
  329. package/dist/plugins/local-session-store.d.ts +13 -10
  330. package/dist/plugins/local-session-store.js +23 -14
  331. package/dist/plugins/local-session-window.d.ts +45 -0
  332. package/dist/plugins/local-session-window.js +38 -0
  333. package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
  334. package/dist/plugins/mailbox-store-sql.d.ts +30 -48
  335. package/dist/plugins/mailbox-store-sql.js +77 -52
  336. package/dist/plugins/memory-embedder-fingerprint.js +2 -1
  337. package/dist/plugins/memory-run-store.d.ts +5 -13
  338. package/dist/plugins/memory-run-store.js +8 -0
  339. package/dist/plugins/one-time-migrations.d.ts +121 -5
  340. package/dist/plugins/one-time-migrations.js +332 -8
  341. package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
  342. package/dist/plugins/org-delivery-quota-store.js +228 -0
  343. package/dist/plugins/permission-rule-store-file.js +10 -6
  344. package/dist/plugins/permission-rule-store-sql.js +8 -8
  345. package/dist/plugins/pg-pool.js +39 -7
  346. package/dist/plugins/pg-session-storage.d.ts +18 -5
  347. package/dist/plugins/pg-session-storage.js +68 -23
  348. package/dist/plugins/remote-env-adb.d.ts +6 -12
  349. package/dist/plugins/remote-env-adb.js +12 -2
  350. package/dist/plugins/remote-env-device.d.ts +14 -7
  351. package/dist/plugins/remote-env-device.js +23 -15
  352. package/dist/plugins/remote-env-k8s.d.ts +8 -12
  353. package/dist/plugins/remote-env-k8s.js +23 -5
  354. package/dist/plugins/remote-env-local-docker.d.ts +10 -15
  355. package/dist/plugins/remote-env-local-docker.js +12 -9
  356. package/dist/plugins/remote-env-ssh.d.ts +10 -16
  357. package/dist/plugins/remote-env-ssh.js +17 -11
  358. package/dist/plugins/run-store-sql.d.ts +16 -14
  359. package/dist/plugins/run-store-sql.js +22 -2
  360. package/dist/plugins/schema-indexes.js +2 -0
  361. package/dist/plugins/send-user-file.js +2 -2
  362. package/dist/plugins/session-epoch-anchor.d.ts +32 -6
  363. package/dist/plugins/session-epoch-anchor.js +2 -3
  364. package/dist/plugins/session-ownership.d.ts +11 -0
  365. package/dist/plugins/session-ownership.js +11 -0
  366. package/dist/plugins/session-placement.d.ts +12 -14
  367. package/dist/plugins/session-placement.js +2 -15
  368. package/dist/plugins/session-store.d.ts +18 -8
  369. package/dist/plugins/session-store.js +15 -4
  370. package/dist/plugins/sql-driver.d.ts +74 -11
  371. package/dist/plugins/sql-driver.js +210 -12
  372. package/dist/plugins/sql-errors.d.ts +23 -0
  373. package/dist/plugins/sql-errors.js +21 -0
  374. package/dist/plugins/store-backend.d.ts +36 -1
  375. package/dist/plugins/store-backend.js +40 -14
  376. package/dist/plugins/store-contracts.d.ts +42 -0
  377. package/dist/plugins/store-contracts.js +1 -0
  378. package/dist/plugins/tidb-pool.d.ts +6 -1
  379. package/dist/plugins/tidb-pool.js +44 -10
  380. package/dist/plugins/tidb-session-storage.d.ts +3 -2
  381. package/dist/plugins/tidb-session-storage.js +2 -2
  382. package/dist/plugins/tidb-session-store.d.ts +25 -5
  383. package/dist/plugins/tidb-session-store.js +67 -21
  384. package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
  385. package/dist/plugins/workflow-journal-store-sql.js +19 -6
  386. package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
  387. package/dist/plugins/workflow-run-store-sql.js +50 -9
  388. package/dist/posture-source.d.ts +18 -10
  389. package/dist/posture-source.js +4 -1
  390. package/dist/project-identity.d.ts +45 -6
  391. package/dist/project-identity.js +162 -8
  392. package/dist/project-layer-key.d.ts +28 -0
  393. package/dist/project-layer-key.js +29 -0
  394. package/dist/question.js +3 -2
  395. package/dist/read-deny-entry.d.ts +25 -0
  396. package/dist/read-deny-entry.js +12 -0
  397. package/dist/read-face-posture.d.ts +37 -11
  398. package/dist/read-face-posture.js +32 -3
  399. package/dist/request-key-closure.d.ts +7 -0
  400. package/dist/request-key-closure.js +9 -1
  401. package/dist/request-tool-axes.d.ts +12 -0
  402. package/dist/request-tool-axes.js +20 -0
  403. package/dist/request-value-closure.d.ts +5 -0
  404. package/dist/request-value-closure.js +11 -3
  405. package/dist/rule-entry-list.d.ts +26 -2
  406. package/dist/rule-entry-list.js +72 -12
  407. package/dist/rules-consent.js +3 -4
  408. package/dist/run-acceptance.d.ts +19 -3
  409. package/dist/run-acceptance.js +13 -1
  410. package/dist/run-local.js +37 -6
  411. package/dist/runs.d.ts +12 -10
  412. package/dist/runs.js +25 -6
  413. package/dist/runtime-caps-resolver.d.ts +16 -6
  414. package/dist/runtime-caps-resolver.js +18 -5
  415. package/dist/sandbox-pkg-source.d.ts +19 -1
  416. package/dist/sandbox-pkg-source.js +29 -7
  417. package/dist/sealed-key.d.ts +32 -0
  418. package/dist/sealed-key.js +55 -1
  419. package/dist/security.d.ts +95 -15
  420. package/dist/security.js +52 -9
  421. package/dist/session-error-wire.d.ts +31 -7
  422. package/dist/session-error-wire.js +9 -2
  423. package/dist/session-sync-kernel.d.ts +37 -10
  424. package/dist/session-sync-kernel.js +10 -0
  425. package/dist/session-titled-frame.d.ts +33 -0
  426. package/dist/session-titled-frame.js +4 -0
  427. package/dist/session-titler.d.ts +9 -1
  428. package/dist/session-titler.js +15 -4
  429. package/dist/spec-fields.js +21 -2
  430. package/dist/sql-engine-posture.d.ts +3 -1
  431. package/dist/task-a2a.js +4 -3
  432. package/dist/task-cwd.d.ts +1 -1
  433. package/dist/task-mcp.d.ts +5 -5
  434. package/dist/task-mcp.js +27 -74
  435. package/dist/task-settings.d.ts +93 -88
  436. package/dist/task-settings.js +71 -63
  437. package/dist/text-bidi.d.ts +0 -4
  438. package/dist/text-bidi.js +1 -3
  439. package/dist/tighten-only-seats.d.ts +150 -0
  440. package/dist/tighten-only-seats.js +196 -0
  441. package/dist/tool-approval.d.ts +451 -136
  442. package/dist/tool-approval.js +733 -256
  443. package/dist/tool-rule-names.d.ts +6 -0
  444. package/dist/trace/core-keyset-guard.d.ts +108 -25
  445. package/dist/trace/exit-seat.d.ts +40 -0
  446. package/dist/trace/exit-seat.js +130 -0
  447. package/dist/trace/ledger-events.d.ts +6 -3
  448. package/dist/trace/project.d.ts +98 -13
  449. package/dist/trace/project.js +57 -32
  450. package/dist/trace/projection-table.d.ts +100 -0
  451. package/dist/trace/projection-table.js +130 -0
  452. package/dist/trace/redact.d.ts +57 -0
  453. package/dist/trace/redact.js +962 -168
  454. package/dist/trace/self-minted-wire.d.ts +349 -1
  455. package/dist/trace/self-minted-wire.js +118 -1
  456. package/dist/trace/wire-projection-faces.d.ts +304 -2
  457. package/dist/trace/wire-projection-faces.js +160 -13
  458. package/dist/url-refusal.js +2 -0
  459. package/dist/web-admin-client/apply-effective.d.ts +12 -0
  460. package/dist/web-admin-client/apply-effective.js +56 -5
  461. package/dist/web-admin-client/facade.d.ts +1 -1
  462. package/dist/web-admin-client/facade.js +1 -1
  463. package/dist/web-admin-client/read-face.js +5 -9
  464. package/dist/web-admin-client/skills-mcp.d.ts +1 -1
  465. package/dist/web-admin-client/skills-mcp.js +6 -8
  466. package/dist/web-admin-client/types.d.ts +1 -1
  467. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
  468. package/package.json +8 -4
  469. package/scripts/drain-check-local.mjs +34 -2
  470. package/scripts/drain-check.mysql.sql +20 -2
  471. package/scripts/drain-check.pg.sql +20 -2
  472. package/dist/mcp-tool-faces.d.ts +0 -69
  473. package/dist/mcp-tool-faces.js +0 -106
@@ -1,4 +1,5 @@
1
1
  import { redactHead } from "../observability/run-terminal.js";
2
+ const errText = (e) => redactHead(e instanceof Error ? e.message : String(e), 2000);
2
3
  import { findParkOrigin } from "../parked-decide.js";
3
4
  import { decodeCheckpointScope } from "../security.js";
4
5
  import { hostDecisionFacts } from "../host-decision.js";
@@ -8,7 +9,9 @@ import { gatedPrincipal, hasServiceAuth } from "./principal-gate.js";
8
9
  import { costQuotaRefusalOf } from "./request-guards.js";
9
10
  import { admissionRefusalOf, readinessOf } from "./readiness.js";
10
11
  import { readResumeCtx } from "./resume-ctx-read.js";
12
+ import { isResumeBlockedByPolicy } from "./checkpoint-ctx.js";
11
13
  import { storedBodyReplayRefusal } from "./stored-body-replay.js";
14
+ import { refusalBody } from "./refusal-body.js";
12
15
  const BLOCKED_SCALAR_KEYS = ["errorCode", "blockedBy", "field", "reason", "count", "cap", "index"];
13
16
  function blockedScalars(body) {
14
17
  const out = {};
@@ -70,7 +73,7 @@ export function createApprovalSweeps(ctx) {
70
73
  catch (e) {
71
74
  deps.metrics?.inc("deny_sweep_list_failed_total");
72
75
  deps.logger?.warn?.("deny_sweep_list_failed", {
73
- err: redactHead(e instanceof Error ? e.message : String(e), 2000),
76
+ err: errText(e),
74
77
  note: "the SLA deny-sweep could not read the expired approvals this tick, so nothing was denied and nothing was skipped; the rows stay suspended and are read again next tick (the terminal backstop still reaps them)",
75
78
  });
76
79
  return;
@@ -80,36 +83,62 @@ export function createApprovalSweeps(ctx) {
80
83
  let token;
81
84
  try {
82
85
  token = (await cs.findPendingTokenBySession(sessionId, undefined, { gateKinds: APPROVAL_GATE_KINDS })) ?? undefined;
83
- if (!parkSources || !token)
84
- return { token, parked: false };
86
+ if (!token)
87
+ return { token, parked: false, rev: undefined };
85
88
  const cp = await cs.get(token);
86
89
  if (!cp)
87
- return { token, parked: false };
90
+ return { token, parked: false, rev: undefined };
91
+ const rev = cp.rev ?? 0;
92
+ if (!parkSources)
93
+ return { token, parked: false, rev };
88
94
  const origin = await findParkOrigin({
89
95
  ...(deps.backgroundAgentStore !== undefined ? { agentStore: deps.backgroundAgentStore } : {}),
90
96
  ...(deps.workflowAgentSessionIndex !== undefined && deps.workflowRunStore !== undefined
91
97
  ? { workflowIndex: deps.workflowAgentSessionIndex, workflowRunStore: deps.workflowRunStore }
92
98
  : {}),
93
99
  }, { token, scope: cp.scope, sessionId: cp.sessionId });
94
- return { token, parked: origin !== undefined };
100
+ return { token, parked: origin !== undefined, rev };
95
101
  }
96
102
  catch {
97
- return { token, parked: false };
103
+ return { token, parked: false, rev: undefined };
98
104
  }
99
105
  };
100
106
  const storedBodyUnservable = async (sessionId) => {
101
- const read = await readResumeCtx(cs.getCtx(sessionId));
107
+ const read = await readResumeCtx(cs.getCtx(sessionId), { sessionId, opener: deps.checkpointCtxSealing });
102
108
  if (read.kind === "corrupt")
103
109
  return undefined;
110
+ if (read.kind === "unsealable")
111
+ return undefined;
104
112
  if (read.kind === "absent")
105
113
  return undefined;
106
114
  return storedBodyReplayRefusal(read.ctx, deps.config);
107
115
  };
116
+ const expirePolicyBlockedCard = async (cardToken, observedRev, sessionId, body) => {
117
+ let won;
118
+ try {
119
+ const cp = await cs.get(cardToken);
120
+ if (!cp)
121
+ return;
122
+ if (cp.status !== "pending" || (cp.rev ?? 0) !== observedRev) {
123
+ deps.logger?.warn?.("deny_sweep_policy_blocked_expire_skipped", { sessionId, skipReason: cp.status !== "pending" ? "not_pending" : "card_changed", ...blockedScalars(body) });
124
+ return;
125
+ }
126
+ won = await cs.expire(cardToken, cp.scope);
127
+ }
128
+ catch (e) {
129
+ deps.logger?.warn?.("deny_sweep_policy_blocked_expire_failed", { sessionId, err: errText(e) });
130
+ return;
131
+ }
132
+ blockedWarned.delete(cardToken);
133
+ if (won)
134
+ deps.metrics?.inc("deny_sweep_policy_blocked_expired_total");
135
+ deps.logger?.warn?.("deny_sweep_policy_blocked_expired", { sessionId, won, ...blockedScalars(body) });
136
+ };
108
137
  let parkedSkipped = 0;
109
138
  const replaySkipped = [];
110
139
  const seenCards = new Set();
111
140
  for (const { sessionId } of expired) {
112
- const { token: cardToken, parked } = await cardOf(sessionId);
141
+ const { token: cardToken, parked, rev: cardRev } = await cardOf(sessionId);
113
142
  if (cardToken !== undefined)
114
143
  seenCards.add(cardToken);
115
144
  if (parked) {
@@ -121,12 +150,22 @@ export function createApprovalSweeps(ctx) {
121
150
  replaySkipped.push({ sessionId, kind: unservable.kind });
122
151
  continue;
123
152
  }
124
- await resumeCheckpoint(sessionId, "deny", "approval SLA expired — auto-denied", { decidedBy: "sla_timeout" }).then((r) => {
125
- if (r.status >= 400)
126
- noteResumeBlocked(cardToken, sessionId, r.status, r.body);
127
- else if (cardToken !== undefined)
153
+ let out;
154
+ try {
155
+ out = await resumeCheckpoint(sessionId, "deny", "approval SLA expired — auto-denied", { decidedBy: "sla_timeout" });
156
+ }
157
+ catch (e) {
158
+ deps.logger?.warn?.("deny_sweep_resume_failed", { sessionId, err: errText(e) });
159
+ continue;
160
+ }
161
+ if (out.status < 400) {
162
+ if (cardToken !== undefined)
128
163
  blockedWarned.delete(cardToken);
129
- }, (e) => deps.logger?.warn?.("deny_sweep_resume_failed", { sessionId, err: redactHead(e instanceof Error ? e.message : String(e), 2000) }));
164
+ continue;
165
+ }
166
+ noteResumeBlocked(cardToken, sessionId, out.status, out.body);
167
+ if (isResumeBlockedByPolicy(out) && cardToken !== undefined && cardRev !== undefined)
168
+ await expirePolicyBlockedCard(cardToken, cardRev, sessionId, out.body);
130
169
  }
131
170
  for (const token of [...blockedWarned.keys()])
132
171
  if (!seenCards.has(token))
@@ -144,10 +183,10 @@ export function createApprovalSweeps(ctx) {
144
183
  async function redeemParkedAsk(req) {
145
184
  const cs = deps.checkpointStore;
146
185
  if (!cs) {
147
- return { status: 404, body: { error: "approval not found", errorCode: "not_found.approval" } };
186
+ return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
148
187
  }
149
188
  if (!hasServiceAuth(deps.config) && !deps.config.allowUnauthedWrites) {
150
- return { status: 503, body: { error: "this worker requires a service auth token (set SERVICE_AUTH_TOKEN) before accepting task submissions", errorCode: "auth.service_token_required" } };
189
+ return { status: 503, body: refusalBody({ errorCode: "auth.service_token_required", message: "this worker requires a service auth token (set SERVICE_AUTH_TOKEN) before accepting task submissions" }) };
151
190
  }
152
191
  const refusal = admissionRefusalOf(readinessOf(deps), deps.servingLease?.(), "hitl-answer");
153
192
  if (refusal !== undefined)
@@ -169,17 +208,17 @@ export function createApprovalSweeps(ctx) {
169
208
  catch (e) {
170
209
  if (!(await mayDiscloseRowError(cs, req.gateToken, { principal: req.principal, explicitOperator: false }))) {
171
210
  deps.logger?.warn?.("parked_late_decision_unreadable_row_withheld", { askId: req.askId });
172
- return { status: 404, body: { error: "approval not found", errorCode: "not_found.approval" } };
211
+ return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
173
212
  }
174
- return { status: 409, body: { error: e instanceof Error ? e.message : String(e), errorCode: "conflict.checkpoint_unreadable" } };
213
+ return { status: 409, body: refusalBody({ errorCode: "conflict.checkpoint_unreadable", message: e instanceof Error ? e.message : String(e) }) };
175
214
  }
176
215
  if (!cp) {
177
- return { status: 404, body: { error: "approval not found", errorCode: "not_found.approval" } };
216
+ return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
178
217
  }
179
218
  const cpPrincipal = decodeCheckpointScope(cp.scope);
180
219
  if (cpPrincipal !== undefined && cpPrincipal !== req.principal) {
181
220
  deps.logger?.warn?.("parked_late_decision_scope_mismatch", { askId: req.askId });
182
- return { status: 404, body: { error: "approval not found", errorCode: "not_found.approval" } };
221
+ return { status: 404, body: refusalBody({ errorCode: "not_found.approval", message: "approval not found" }) };
183
222
  }
184
223
  const binding = {
185
224
  checkpointToken: req.gateToken,
@@ -0,0 +1,77 @@
1
+ /**
2
+ * **调用方信任档** —— 一份请求里「不经人答就生效」的规则表按谁的档准入:全仓唯一一张表({@link callerTrust})、唯一一只准入判({@link requestTrustRefusal})。
3
+ *
4
+ * ## 律
5
+ * 契约(settings-schema `SAFETY_MERGE_SPEC.permissions` 的成员阶梯)按**层的信任档**准入每个成员:`allow` 放宽免问面(`loosen`),要 `global`;`deny` / `ask` 只收紧,
6
+ * 文件层最低档 `local` 就收。wire 上没有层 —— 提交体是合并后的扁平结果,层只在合并端(cli 本地)存在;自报一个层 / 作者位不可验(引擎侧已拒立这种位)。所以本服务
7
+ * 的「层」= **这次请求验过的凭据**:档只由部署形 + 身份来源 + 登录令牌的 scope 角色推,调用方说什么都不改档。
8
+ *
9
+ * · 单用户 turnkey(`requirePrincipal !== true`,本仓 posture 判别式同一只)⇒ `global`:一台机一位超管;
10
+ * · 多租 · 部署的 service 凭据 ⇒ `global`:部署自己的凭据是运维档(契约给「启动方自己的行为」—— `SETTINGS_SOURCE_CONTRACT.flagSettings` —— 的档),持它的前端为自己转发的内容负责;
11
+ * 出示的 Bearer 就是 service 凭据时,哪怕它同时也被鉴权桥验成登录令牌,也按 service 凭据读(与凭据门派 `source` 同序:`dispatch.ts` 先认 service 凭据);
12
+ * · 多租 · 中心登录令牌,scope 角色 ≥ 契约 `domainWriteRole("governance")` ⇒ `global`:能写 scope 治理域(autonomy / commandPolicy / approvalRequire,全组织的免问面)
13
+ * 的角色,放宽自己这一 run 是它的子集;门槛读契约,不手抄角色词;
14
+ * · 多租 · 其余(登录令牌角色低于它 / 不带 / 认不出;直连门 principal 令牌只证身份不证角色;没有验过的凭据)⇒ `project`:契约给非运维档作者的仓控来源的档,
15
+ * 收紧成员照收、放宽成员不收 —— 没有可验的角色就落到这里(fail-closed)。
16
+ *
17
+ * **判的是哪些表**:请求体上不经人答就生效的规则表 —— `settings.permissions` 的每个成员桶(逐 `membersOf("permissions")`),以及请求**按名点用**(`userInvokedSkills`)的
18
+ * 自带技能的两只清单(引擎 `seedSkillGrants`:人点的名就是表态,不出 `Skill` 卡 ⇒ `allowedTools` 是 `allow` 成员的孪生、`disallowedTools` 是 `deny` 的孪生,键 → 成员一张表
19
+ * {@link SKILL_LIST_MEMBER})。没点用的自带技能不判:它的清单要经 `Skill` 卡上的人点头才生效 —— 那正是契约给低于门槛的放宽指定的同意出口。
20
+ * 准入只经契约导出:桶非空且 `!isAtLeast(档, memberAdmission(…).minTrust)` ⇒ 不准入;不按方向开特例(契约的层准入同样先判 floor)。
21
+ * 不准入 ⇒ 受理口 400,体与条目问题同形(`entry-problems.ts`:`field` + `detail.problems` + `total`),原因词 = 契约 `LAYER_ADMISSION_VERDICTS` 的 `below_trust_floor`,
22
+ * 另带 `detail.callerTrust`(这次请求的档)。响亮拒而不是静默丢:契约要求低于门槛的放宽不得静默吞,出路是同意(答卡)或运维的 allow 表。
23
+ *
24
+ * 读者(都读同一次求值,不各算一份):提交受理口(`admission.ts` `prepareSpec`,三提交面共用)与能力位 `settings.permissions.callerTrust`(`routes/capabilities.ts`)。
25
+ * 续跑腿不读本档:存储体在自己的受理口按当时的档准入过。
26
+ */
27
+ import type { IncomingMessage } from "node:http";
28
+ import { type MinTrust, type SafetyMergeMember, type UserRole } from "@sema-agent/settings-schema";
29
+ import type { SkillSpec } from "@sema-agent/core";
30
+ import type { ServiceConfig } from "../config-types.js";
31
+ import { type EntryProblem } from "../entry-problems.js";
32
+ import type { ParsedTaskSettings } from "../task-settings.js";
33
+ /**
34
+ * 档是**怎么**推出来的(闭集;拒句按它说出路)。加一个词 ⇒ {@link basisClause} 的穷举 switch 编译红。
35
+ * · `single_user` —— 单用户 turnkey;
36
+ * · `service_credential` —— 多租 · 部署的 service 凭据;
37
+ * · `sign_in_role` —— 多租 · 登录令牌带契约阶梯里的角色(够不够档看 `trust`);
38
+ * · `sign_in_role_unrecognized` —— 多租 · 登录令牌不带角色,或角色不在契约阶梯里;
39
+ * · `identity_without_role` —— 多租 · 直连门 principal 令牌(只证身份);
40
+ * · `unverified` —— 多租 · 没有验过的凭据。
41
+ */
42
+ export type CallerTrustBasis = "single_user" | "service_credential" | "sign_in_role" | "sign_in_role_unrecognized" | "identity_without_role" | "unverified";
43
+ /** 一次求值的读数。`role` 只在 `basis === "sign_in_role"` 时在场(契约阶梯里的词)。 */
44
+ export interface CallerTrust {
45
+ readonly trust: MinTrust;
46
+ readonly basis: CallerTrustBasis;
47
+ readonly role?: UserRole;
48
+ }
49
+ /** 档表(唯一一张)。规则全文见文件头。 */
50
+ export declare function callerTrust(req: IncomingMessage, config: ServiceConfig): CallerTrust;
51
+ /** 请求 `settings.permissions` 的成员桶 —— 按**契约的成员型**取:契约加成员而本仓的请求桶没有它 ⇒ 这里编译红(本仓必须先决定那只桶怎么上 wire)。 */
52
+ type RequestPermissionMembers = Pick<NonNullable<ParsedTaskSettings["permissions"]>, SafetyMergeMember<"permissions">>;
53
+ /** 准入判的输入:解析后的请求桶(`parseTaskSettings` 的读数 = `applyTaskSettings` 投进引擎的那一份)+ 请求自带技能 + 按名点用的技能名(两者受理门已判过形)。 */
54
+ export interface RequestRuleTables {
55
+ readonly permissions: RequestPermissionMembers | undefined;
56
+ readonly skills: readonly Pick<SkillSpec, "name" | "allowedTools" | "disallowedTools">[] | undefined;
57
+ readonly userInvokedSkills: readonly string[] | undefined;
58
+ }
59
+ /** 受理口拒体:句子 + 机读位(原样进 `sendError` 的 facts)。 */
60
+ export interface RequestTrustRefusal {
61
+ readonly message: string;
62
+ readonly facts: {
63
+ readonly field: string;
64
+ readonly detail: {
65
+ readonly problems: readonly EntryProblem[];
66
+ readonly total: number;
67
+ readonly callerTrust: MinTrust;
68
+ };
69
+ };
70
+ }
71
+ /**
72
+ * 请求里不经人答就生效的规则表的成员级准入(唯一一只判)。全部准入 ⇒ `undefined`;否则句子说扫描序里**第一张**不准入的表(坐标、档、floor、出路),
73
+ * 机读位把这一遍判下来的**全部**条目一次列全。空表什么也不改,不算。
74
+ */
75
+ export declare function requestTrustRefusal(tables: RequestRuleTables, reading: CallerTrust): RequestTrustRefusal | undefined;
76
+ export {};
77
+ //# sourceMappingURL=caller-trust.d.ts.map
@@ -0,0 +1,143 @@
1
+ import { domainWriteRole, isAtLeast, isRole, memberAdmission, membersOf, roleAtLeast, USER_ROLES, } from "@sema-agent/settings-schema";
2
+ import { entryProblem, entryProblemsFacts } from "../entry-problems.js";
3
+ import { ssoVerifiedRole } from "../security.js";
4
+ import { systemFor, verifiedIdentitySource } from "./principal-gate.js";
5
+ export function callerTrust(req, config) {
6
+ if (config.requirePrincipal !== true)
7
+ return { trust: "global", basis: "single_user" };
8
+ const source = verifiedIdentitySource(req, config);
9
+ switch (source) {
10
+ case "service_token":
11
+ return { trust: "global", basis: "service_credential" };
12
+ case "sso": {
13
+ if (systemFor(req, config) !== undefined)
14
+ return { trust: "global", basis: "service_credential" };
15
+ const role = ssoVerifiedRole(req);
16
+ if (role === undefined || !isRole(role))
17
+ return { trust: "project", basis: "sign_in_role_unrecognized" };
18
+ return { trust: roleAtLeast(role, domainWriteRole("governance")) ? "global" : "project", basis: "sign_in_role", role };
19
+ }
20
+ case "direct_door_jwt":
21
+ return { trust: "project", basis: "identity_without_role" };
22
+ case undefined:
23
+ return { trust: "project", basis: "unverified" };
24
+ default: {
25
+ const unknownSource = source;
26
+ throw new Error(`callerTrust: identity source ${String(unknownSource)} has no trust row`);
27
+ }
28
+ }
29
+ }
30
+ const TRUST_REFUSAL_CODE = "request.field_invalid";
31
+ const BELOW_TRUST_FLOOR = "below_trust_floor";
32
+ const SKILL_LIST_MEMBER = { allowedTools: "allow", disallowedTools: "deny" };
33
+ function effectiveRuleTables(t) {
34
+ const out = [];
35
+ if (t.permissions !== undefined) {
36
+ for (const member of membersOf("permissions")) {
37
+ const entries = t.permissions[member];
38
+ if (entries !== undefined)
39
+ out.push({ member, field: `settings.permissions.${member}`, entries, source: "settings" });
40
+ }
41
+ }
42
+ if (t.skills !== undefined && t.userInvokedSkills !== undefined) {
43
+ const named = new Set();
44
+ for (const name of t.userInvokedSkills) {
45
+ if (named.has(name))
46
+ continue;
47
+ named.add(name);
48
+ const at = t.skills.findIndex((skill) => skill.name === name);
49
+ const skill = t.skills[at];
50
+ if (skill === undefined)
51
+ continue;
52
+ for (const key of ["allowedTools", "disallowedTools"]) {
53
+ const entries = skill[key];
54
+ if (entries !== undefined)
55
+ out.push({ member: SKILL_LIST_MEMBER[key], field: `skills[${at}].${key}`, entries, source: "invoked_skill" });
56
+ }
57
+ }
58
+ }
59
+ return out;
60
+ }
61
+ export function requestTrustRefusal(tables, reading) {
62
+ const problems = [];
63
+ let first;
64
+ for (const table of effectiveRuleTables(tables)) {
65
+ if (table.entries.length === 0)
66
+ continue;
67
+ const admission = memberAdmission("permissions", table.member);
68
+ if (isAtLeast(reading.trust, admission.minTrust))
69
+ continue;
70
+ first ??= { table, minTrust: admission.minTrust, loosens: directionLoosens(admission.direction) };
71
+ for (const entry of table.entries)
72
+ problems.push(entryProblem(TRUST_REFUSAL_CODE, table.field, entry, BELOW_TRUST_FLOOR));
73
+ }
74
+ if (first === undefined)
75
+ return undefined;
76
+ const facts = entryProblemsFacts(problems);
77
+ return {
78
+ message: `${first.table.field} needs trust "${first.minTrust}" (${whatItDoes(first.table.source, first.loosens)}) and this request is admitted at "${reading.trust}": ${basisClause(reading)}. Below that trust these rules are not applied — ${outletOf(first.table.source, first.loosens)}.`,
79
+ facts: { field: facts.field, detail: { ...facts.detail, callerTrust: reading.trust } },
80
+ };
81
+ }
82
+ function whatItDoes(source, loosens) {
83
+ const effect = loosens ? "lets matching calls run without a person being asked" : "changes which calls are asked or refused";
84
+ switch (source) {
85
+ case "settings":
86
+ return `it ${effect}`;
87
+ case "invoked_skill":
88
+ return `the request invokes this skill by name, so the list applies with no approval card and ${effect}`;
89
+ default: {
90
+ const unknownSource = source;
91
+ throw new Error(`requestTrustRefusal: rule table source ${String(unknownSource)} unknown`);
92
+ }
93
+ }
94
+ }
95
+ function outletOf(source, loosens) {
96
+ if (!loosens)
97
+ return "remove them, or ask the operator to set them deployment-wide";
98
+ switch (source) {
99
+ case "settings":
100
+ return "remove them and answer the approval questions as they come, or ask the operator to put them in APPROVAL_GRANT";
101
+ case "invoked_skill":
102
+ return "drop the skill from userInvokedSkills (the model can still activate it behind its approval card), remove the list, or ask the operator to put the rules in APPROVAL_GRANT";
103
+ default: {
104
+ const unknownSource = source;
105
+ throw new Error(`requestTrustRefusal: rule table source ${String(unknownSource)} unknown`);
106
+ }
107
+ }
108
+ }
109
+ function directionLoosens(direction) {
110
+ switch (direction) {
111
+ case "loosen":
112
+ return true;
113
+ case "tighten":
114
+ return false;
115
+ default: {
116
+ const unknownDirection = direction;
117
+ throw new Error(`requestTrustRefusal: member direction ${String(unknownDirection)} unknown`);
118
+ }
119
+ }
120
+ }
121
+ function basisClause(reading) {
122
+ const governanceRole = domainWriteRole("governance");
123
+ const reach = `the deployment's service credential, or a registry sign-in token whose role in its active scope is "${governanceRole}" or higher (the role that may write the scope's governance), is admitted at "global"`;
124
+ switch (reading.basis) {
125
+ case "single_user":
126
+ return `this single-user deployment admits every caller at "global"`;
127
+ case "service_credential":
128
+ return `the deployment's service credential is admitted at "global"`;
129
+ case "sign_in_role":
130
+ return `the registry sign-in token's role in its active scope is "${reading.role ?? ""}" — ${reach}; a scope admin can raise the role`;
131
+ case "sign_in_role_unrecognized":
132
+ return `the registry sign-in token carries no role this deployment recognizes (${USER_ROLES.join(" < ")}) — ${reach}`;
133
+ case "identity_without_role":
134
+ return `a direct-door principal token proves who the caller is, not a role — ${reach}`;
135
+ case "unverified":
136
+ return `the request carries no credential this deployment verifies — ${reach}`;
137
+ default: {
138
+ const unknownBasis = reading.basis;
139
+ throw new Error(`requestTrustRefusal: trust basis ${String(unknownBasis)} unknown`);
140
+ }
141
+ }
142
+ }
143
+ //# sourceMappingURL=caller-trust.js.map
@@ -39,6 +39,10 @@
39
39
  * `resolveSpec` 本身留作真正的拒点(提交腿 400;续跑腿在到它之前已被本判据答掉)。再开第六个问点必须调这两只,不许各判各的 —— 此前铸卡前只判了
40
40
  * allow 记号,工具名清单那一问漏在外面,卡铸出来了、`/wake` 恒 409([ref] 合并复审两腿同报)。
41
41
  *
42
+ * ## 凭据位密封(7.134.0;常设规则,不是迁移)
43
+ * 体里请求面凭据位上的值在 ctx 里只以封签存在 —— 写:{@link buildCheckpointCtx} / {@link sealCheckpointCtx} 一只封口;读:续跑上下文读口里一只开口
44
+ * {@link openCheckpointCtx};开不开 ⇒ `409 conflict.checkpoint_ctx_unsealable`。规则全文在本文件末段「凭据位密封」的头注。
45
+ *
42
46
  * ## 何时删(一次性迁移,不是长期双读)
43
47
  * 本判据、拒臂、记号写点与 `CheckpointCtx.permissionsAllowReading` 一起删,删除条件与窗登记在 `plugins/one-time-migrations.ts` 的
44
48
  * 一次性迁移登记表(本条那一行):所有旧读法下停驻的行都已结束或被收割(停驻行的终局 = 落盘起 `TERMINAL_BACKSTOP_MS`,见
@@ -73,14 +77,16 @@ export declare function bodyCarriesAllowList(body: TaskRequestBody): boolean;
73
77
  * 调用方是「本进程刚按当前读法读过这份体」的写点:fresh 提交(受理门按当前读法读过 `allow`),或已经过了续跑拒臂的重放腿
74
78
  * (`startFreshHostTurn` 把宿主的存量体交给 `POST /v1/runs` 同一条链 —— 它在那之前调过 `resolveResumeSpecOrBlocked`,没记号却带 `allow` 的体到不了这里)。
75
79
  * 续跑腿的**写回**不经本函数:**不改词**的写回传读进来的 ctx(记号随行,不重新判 —— 在写回口重新判会把一条没记号的旧行「洗」成新行);
76
- * **改词**的写回(只有 `plan_review` 的批准 / 编辑)经 {@link withPermissionModeRewritten}。
80
+ * **改词**的写回(只有 `plan_review` 的批准 / 编辑)经 {@link withPermissionModeRewritten}。两种写回落盘之前都过同一只封口 {@link sealCheckpointCtx}。
81
+ *
82
+ * `sealer` / `sessionId`:凭据位密封的两件(本文件末段)—— `sessionId` 是这一行的会话(绑进封签);`sealer` 必传,缺席也要说出来(`undefined`)。
77
83
  */
78
84
  export declare function buildCheckpointCtx(fields: {
79
85
  body: TaskRequestBody;
80
86
  memoryScope?: string | undefined;
81
87
  unattendedLeg?: true;
82
88
  writerVersion: string;
83
- }): CheckpointCtx;
89
+ }, sealer: CheckpointCtxSealer | undefined, sessionId: string): SealedCheckpointCtx;
84
90
  /**
85
91
  * 模式词的**第二个写者** —— `plan_review` 的批准 / 编辑把这条 run 的体词从 `plan` 写成批准的档(`resume-legs.ts` `drivePlanReview`,调用点只有那一处;
86
92
  * `test/allow-list-reading-park-refusal.test.ts` 枚举调用点,多一处即红)。与 {@link buildCheckpointCtx} **同一条规则**:按当前读法写下的词,盖当前读法记号。
@@ -101,15 +107,9 @@ export declare function permissionModeReadingStated(ctx: CheckpointCtx): boolean
101
107
  /**
102
108
  * 第三问的拒答复 —— 码与落点同 allow 记号那一问(`checkpoint.unsupported_version`,409;卡仍 pending 时体上的 `retriable:true` 由 {@link resumeRefusalWithCard} 追加,本铸点不带)。
103
109
  * 句子说原因(更早的版本在每次续跑重钳运维的 AUTONOMY、没把它记进任务;本版只在提交时记一次 ⇒ 续跑会按任务提交时的原词跑)与两条出路。
104
- * 🔴 形是给冻结门看的:`status: <三位数>, body: { error: "<整句双引号字面>", errorCode: "<码>"`,中间只许有空白。
110
+ * 🔴 形是给冻结门看的:`status: <三位数>, body: refusalBody({ errorCode: "<码>", message: "<整句双引号字面>"`,中间只许有空白。
105
111
  */
106
- export declare function permissionModeReadingRefusal(): {
107
- status: number;
108
- body: {
109
- error: string;
110
- errorCode: string;
111
- };
112
- };
112
+ export declare function permissionModeReadingRefusal(): ResumeRefusalAnswer;
113
113
  /**
114
114
  * 本行能否被按当前读法重放:体里 `allow` 在生效而行上的记号不是当前这一个词 ⇒ **不能**(`true` = 拒)。
115
115
  * 记号缺席、是旧词(`"statement"`)或认不得(手改 / 将来的写者)⇒ 同样拒:只有当前这个词是「按当前读法写下」的证据。
@@ -122,15 +122,9 @@ export declare function allowListReadingEraOf(ctx: CheckpointCtx): AllowListRead
122
122
  * 拒在认领之前,所以没有 `taskId`(行没抢到就不造键)。句子按这一行是哪一代写的分两句(闭集穷举,加一代 ⇒ 编译红):说原因(这条任务停在哪种读法上、
123
123
  * 照当前读法续跑会放宽什么)与出路(作为新任务重提,仍停驻的先取消)。
124
124
  *
125
- * 🔴 形是给冻结门看的(`api-error-text-freeze` 的 resume 家族收集器):`status: <三位数>, body: { error: "<整句双引号字面>", errorCode: "<码>"`,中间只许有空白。
125
+ * 🔴 形是给冻结门看的(`api-error-text-freeze` 的 resume 家族收集器):`status: <三位数>, body: refusalBody({ errorCode: "<码>", message: "<整句双引号字面>"`,中间只许有空白。
126
126
  */
127
- export declare function allowListReadingRefusal(era: AllowListReadingEra): {
128
- status: number;
129
- body: {
130
- error: string;
131
- errorCode: string;
132
- };
133
- };
127
+ export declare function allowListReadingRefusal(era: AllowListReadingEra): ResumeRefusalAnswer;
134
128
  /**
135
129
  * 一条停驻行的持久化体在本版上**不能**重放时,是哪一条规则拒的(闭集;加一条 ⇒ {@link storedBodyReplayAnswer} 的 switch 编译红)。
136
130
  * 答 `checkpoint.unsupported_version` 的两臂随带这一行的写者版本(续跑上下文的 `writerVersion`,缺席 = 本版之前写下的行)—— 那一码的两版本键由它铸({@link buildCheckpointVersionKeys})。
@@ -172,11 +166,23 @@ export interface ResumeRefusalAnswer {
172
166
  * `blockedBy` = 内层的码,句子 = 前缀 + 内层的句子,内层的机读事实原样随体。{@link storedBodyReplayAnswer} 的工具名清单那一臂与
173
167
  * `resume-legs.ts` 的折叠口都调它 —— 句子与码只在这里写一次(冻结门 `api-error-text-freeze` 的模板骨架表锚这一处)。
174
168
  *
169
+ * 🔴 **句尾点名出口**:这一拒不消费卡(卡仍 pending、run 行留停驻),被挡在一张 deny 不掉的卡前面的调用方需要知道怎么收场 ——
170
+ * `POST /v1/runs/:id/cancel` 对停驻的 run 直接结算(CAS 过期该卡再终局 run 行,不跑模型轮)。句子写「若仍停驻」而不是随卡有无换话:有卡 / 无卡(终态 run 的 steer 在铸唤醒卡之前拒)
171
+ * 两种处境除 `retriable` 外逐字同体(同判同答),与另两类存量体拒(allow 读法 / 模式词读法)句子里的出口是同一个端点、同一种写法。
172
+ *
175
173
  * 本铸点**不带** `retriable`:那是调用点的事实(有没有一张待批卡仍在等),由 {@link resumeRefusalWithCard} 一处追加 —— 续跑入口(卡仍 pending、run 行留 `suspended`)
176
174
  * 带 `retriable:true`,终态 run 的 steer 在铸唤醒卡之前拒(没有卡)不带。键集 = `errorCode` · `error` · `blockedBy` · (`field` · `reason` · 其余 `extra`,有才在)
177
175
  * · (`retriable`,卡在才在)。
178
176
  */
179
177
  export declare function resumeBlockedByPolicyAnswer(inner: Refusal): ResumeRefusalAnswer;
178
+ /**
179
+ * 一次续跑的答复是不是 {@link resumeBlockedByPolicyAnswer} 铸的那一只(409 `resume_blocked_by_policy`)—— SLA 拒扫腿据此区分「同一份字节在本版永远被拒」与别的 ≥400
180
+ * (后者可能是瞬时的,照旧逐拍重试)。码的写端与读端住在同一个模块,读端不在别处第二次手拼这个字面。
181
+ */
182
+ export declare function isResumeBlockedByPolicy(answer: {
183
+ readonly status: number;
184
+ readonly body: unknown;
185
+ }): boolean;
180
186
  /**
181
187
  * 🔴 **三类续跑拒体上 `retriable` 的唯一写点**(本服务重放存量体前的拒、准入策略折叠、引擎拒的续跑):卡仍 pending(`cardPending`)⇒ 体尾追加 `retriable: true`;
182
188
  * 否则体原样(键缺席)。这三类拒上规则一条:`retriable` 在场 ⇔ 有一张待批卡仍在等、run 行留 `suspended`(**不是**「原样重试会成功」—— 契约附录 A.1 注那一个意思)。
@@ -208,4 +214,153 @@ export declare function storedBodyReplayLogFields(refusal: StoredBodyReplayRefus
208
214
  * 没有默认值:每个调用点必须说出这件事实。
209
215
  */
210
216
  export declare function storedBodyReplayAnswer(refusal: StoredBodyReplayRefusal, readerVersion: string, cardPending: boolean): ResumeRefusalAnswer;
217
+ /**
218
+ * 🔴 **停驻行里请求面凭据的落盘形 —— 一条规则**:提交体里**凭据位**({@link CHECKPOINT_CTX_CREDENTIAL_SLOTS},闭集)上的每一个值,在 `checkpoint_ctx`
219
+ * (local 店的 `<数据根>/checkpoint-ctx/<会话>.json` / SQL 店的 `checkpoint_ctx.ctx` 列)里只以**封签**({@link SealedCheckpointValue})存在。
220
+ * · **写**:一只封口 {@link sealCheckpointCtx}。新的持久化写经 {@link buildCheckpointCtx}(它的唯一产物形就是封好的 {@link StoredCheckpointCtx}),
221
+ * 续跑腿的写回(`resume-legs.ts` 的 `commitResumeCtx`:读进来的 ctx 在内存里是开封形)经它本身;一次性迁移 M28 对存量行用同一只走法
222
+ * ({@link sealStoredCheckpointCtxM28})。凭据位上的**每一个值都封,不分类型**(串、数字、`null`、对象 —— 包括调用方自己送来的封签形对象):
223
+ * 封签里装的是那个 JSON 值本身,开封逐字还原。字典位上的容器本身不是字典(串 / 数组 / `null` / 封签形对象)⇒ 整只容器当一个值封。
224
+ * 于是落盘形里凭据位上**只有本封口铸的封签**,没有哪个值能「原样存下、续跑时被开成别的东西」(调用方送一只封签形对象 ⇒ 存的是再封一层,
225
+ * 开出来还是那只对象 —— 与新提交腿看到的同一个值)。没有封签器而有值要封 ⇒ 抛 {@link CheckpointCtxUnsealableError}(`no_key_store`,调用方在写之前拒)。
226
+ * · **读法记号**(与本文件另两只记号同一条「写的人盖章」):封口铸出的每一份落盘形都带 `credentialSeal: CHECKPOINT_CTX_SEAL_ALG` —— 这一行的凭据位
227
+ * **全部**由本封口封过。没有记号的行是 7.134.0 之前的写者写下的:那时没有任何写者封值,所以它凭据位上的封签形对象只可能是调用方原样送来的,不是封签。
228
+ * 记号只在落盘形上(开口交出的开封形里没有它;写回再封时重新盖)。
229
+ * · **读**:一只开口 {@link openCheckpointCtx},唯一调用方 = 续跑上下文唯一读口 `resume-ctx-read.ts` 的 `readResumeCtx`(读出的 ctx 在任何消费者
230
+ * 看到之前已开封)。行带当前记号:凭据位上封签 ⇒ 开(开不开 ⇒ 拒);带 `sealed` 键却不是本闭集的封签形(含将来的 `alg`)⇒ 拒 `unrecognized_seal`;
231
+ * 其余任何值 ⇒ 拒 `plaintext`。行没有记号 ⇒ 凭据位上**任何**值(含封签形对象)⇒ 拒 `plaintext`(更早版本写下、M28 还没扫到);记号认不得(将来的格式)⇒
232
+ * 凭据位上任何值 ⇒ 拒 `unrecognized_seal`。凭据位上没有值的行不论记号照常开。
233
+ * **拒** = 读口第四态 `unsealable`(`field` = 哪一个凭据位,`reason` ∈ {@link CHECKPOINT_CTX_UNSEALABLE_REASONS}),各续跑入口答
234
+ * `409 conflict.checkpoint_ctx_unsealable`(`resume-ctx-read.ts` 的 `resumeCtxUnsealableAnswer`)。**没有**明文回落臂、**没有**静默丢键臂。
235
+ * · **装配**:`checkpointStore` 在场而封签器缺席 ⇒ 拒启({@link CHECKPOINT_CTX_SEALING_REQUIRED};`createHttpServer` 与起服第 6 段同一句)。
236
+ *
237
+ * **一个域一对钥匙**:停驻行封签用这一域自己的保管店(`<数据根>/sealed-key/checkpoint-ctx-keys/`,生产工厂 `sealed-key.ts` `ensureCheckpointCtxSealing`),
238
+ * 与模型钥匙(`ModelEntry.sealedApiKey`)的那对钥匙不共用 —— 模型钥匙的密文放进凭据位、停驻行的封签放进 `sealedApiKey`,两边都是「不持有那把钥匙」;
239
+ * 封签再把**会话 id 绑进密文**(信封 = `[alg, sessionId, value]`):别的会话那一行的封签搬过来开不开 —— 读口不是这台副本任何一把钥匙的解密预言机。
240
+ *
241
+ * 本模块的零值依赖纪律照旧:封签器 / 开封器是调用方递进来的接口(实现在 `sealed-key.ts`,它依赖 libsodium,不进本模块的闭包)。
242
+ */
243
+ export declare const CHECKPOINT_CTX_SEAL_ALG = "checkpoint-ctx-sealedbox-v1";
244
+ /** 停驻行里一只凭据值的**封签**(闭集形:恰这三键、三值皆串、`alg` 只有 {@link CHECKPOINT_CTX_SEAL_ALG} 一个词)。与明文不可混淆:明文是串,封签是对象。 */
245
+ export interface SealedCheckpointValue {
246
+ readonly alg: typeof CHECKPOINT_CTX_SEAL_ALG;
247
+ /** 封它的那把公钥的 id(开封按它**精确**选私钥,不逐把试)。 */
248
+ readonly publicKeyId: string;
249
+ /** `crypto_box_seal` 密文的标准 base64。 */
250
+ readonly sealed: string;
251
+ }
252
+ /** 封口(只会封):把凭据位上的一个 JSON 值(任何类型)封进 `sessionId` 那一行。抛 = 封不了(调用方当写失败处置)。 */
253
+ export interface CheckpointCtxSealer {
254
+ seal(value: unknown, sessionId: string): SealedCheckpointValue;
255
+ }
256
+ /** 开口:`holds` = 这台副本有没有 `publicKeyId` 那把私钥;`open` 抛 = 开不开(密文坏 / 不是 `sessionId` 那一行封的 / 不是停驻行信封);返回封进去的那个 JSON 值。
257
+ * 🔴 `open` 的返回值是活凭据:只进内存,不进日志、不落盘(再落盘必经 {@link sealCheckpointCtx})。 */
258
+ export interface CheckpointCtxOpener {
259
+ holds(publicKeyId: string): boolean;
260
+ open(sealed: SealedCheckpointValue, sessionId: string): unknown;
261
+ }
262
+ /** 封签器 = 封口 + 开口(生产工厂 `sealed-key.ts` `ensureCheckpointCtxSealing`;`ServiceDeps.checkpointCtxSealing` 的型)。 */
263
+ export interface CheckpointCtxSealing extends CheckpointCtxSealer, CheckpointCtxOpener {
264
+ }
265
+ /**
266
+ * **凭据位闭集**(提交体里值为凭据的位置)。路径段 `*` = 那一格容器的**每一个成员**:数组的每一项、字典的每一个值(一只走法,不分容器种类 —— 字典成员的点名形
267
+ * `field` 是 `.<键>`,数组是 `[<下标>]`)。`map` = 那一格是串值字典,**每一个值**都是凭据(不分哪一键);`value` = 那一格本身是凭据。
268
+ * 入表判据(一条):请求面上**为承载凭据而设**的字段 —— 静态请求头(MCP http 传输、A2A 对端〔引擎型注:「e.g. an auth bearer」〕、http hook 条目)、
269
+ * 交给子进程的 env(MCP stdio 传输、任务 shell 的 `settings.env`)、请求自带的搜索后端钥匙。http hook 的头与另两种静态头同判:契约包的条目形是
270
+ * `headers: Record<string, string>`、受理面(`parseHooksConfig`)只判条数与字数、`interpolateHookEnvVars` 只换 `$NAME` 引用而字面值原样上 wire ——
271
+ * 头值可以就是字面的 `Authorization: Bearer …`。hooks 的形 = 事件名 → 匹配组数组 → 组的 `hooks` 数组 → 条目;只有 `type:"http"` 的条目有 `headers`,
272
+ * 别的条目在那一段缺席、走法照常不往下走。**不入表**:命令行 / URL / 工具实参之类自由文本(不是凭据字段;它们里有没有秘密不是本层能判的)。
273
+ * 加一位 = 加一行,读写两侧与一次性迁移 M28 共用 {@link mapCredentialSlots} 一只走法,自动覆盖。
274
+ */
275
+ export declare const CHECKPOINT_CTX_CREDENTIAL_SLOTS: readonly [{
276
+ readonly path: readonly ["mcpServers", "*", "transport", "headers"];
277
+ readonly holds: "map";
278
+ }, {
279
+ readonly path: readonly ["mcpServers", "*", "transport", "env"];
280
+ readonly holds: "map";
281
+ }, {
282
+ readonly path: readonly ["a2aPeers", "*", "headers"];
283
+ readonly holds: "map";
284
+ }, {
285
+ readonly path: readonly ["settings", "env"];
286
+ readonly holds: "map";
287
+ }, {
288
+ readonly path: readonly ["settings", "webSearch", "apiKey"];
289
+ readonly holds: "value";
290
+ }, {
291
+ readonly path: readonly ["settings", "hooks", "*", "*", "hooks", "*", "headers"];
292
+ readonly holds: "map";
293
+ }];
294
+ /** 开不开 / 封不了的成因(闭集):`no_key_store` = 这台副本没有封签器(没有保管店);`key_not_held` = 封它的那把钥匙不在这台副本的保管店里
295
+ * (多副本不共享 `<数据根>/sealed-key/`,或保管目录被换过);`unopenable` = 钥匙在、开不开(密文坏 / 不是这一行封的 / 不是停驻行信封);
296
+ * `plaintext` = 凭据位上是明文(更早版本的写者);`unrecognized_seal` = 带 `sealed` 键却不是本闭集的封签形(含将来的 `alg`)。 */
297
+ export declare const CHECKPOINT_CTX_UNSEALABLE_REASONS: readonly ["no_key_store", "key_not_held", "unopenable", "plaintext", "unrecognized_seal"];
298
+ export type CheckpointCtxUnsealableReason = (typeof CHECKPOINT_CTX_UNSEALABLE_REASONS)[number];
299
+ /** 封不了 / 开不开的那一格:`field` = 凭据位在提交体里的路径(如 `mcpServers[0].transport.headers.Authorization`、
300
+ * `settings.hooks.PreToolUse[0].hooks[0].headers.Authorization`;键名不是秘密,值从不进来)。 */
301
+ export declare class CheckpointCtxUnsealableError extends Error {
302
+ readonly field: string;
303
+ readonly reason: CheckpointCtxUnsealableReason;
304
+ constructor(field: string, reason: CheckpointCtxUnsealableReason);
305
+ }
306
+ /**
307
+ * 停驻行的**落盘形**:凭据位上是封签,不是 {@link TaskRequestBody} 型面说的串 —— 所以体在型面上只是「一只对象」,读它的唯一合法方式是 {@link openCheckpointCtx}
308
+ * (经续跑上下文读口)。产物只有两只铸点:{@link buildCheckpointCtx} 与 {@link sealCheckpointCtx}。
309
+ */
310
+ export type StoredCheckpointCtx = Omit<CheckpointCtx, "body"> & {
311
+ readonly body: {
312
+ readonly [key: string]: unknown;
313
+ };
314
+ readonly credentialSeal?: typeof CHECKPOINT_CTX_SEAL_ALG;
315
+ };
316
+ declare const sealedCheckpointCtxBrand: unique symbol;
317
+ /**
318
+ * **封口铸出的**落盘形(品牌型):店的写口(`putCtx`)与一次性迁移 M28 的行改写只收它 ⇒ 「写 ctx 只有封口一个写入面」由型面守,
319
+ * 不再靠逐个数调用点(把开封形 / 裸对象直接交给写口 = 当场 tsc 红)。铸点闭集(都在本模块,都经 {@link mintSealedCheckpointCtx}):
320
+ * {@link sealCheckpointCtx}(新的持久化写经 {@link buildCheckpointCtx} 到它;续跑腿的写回)与 {@link sealStoredCheckpointCtxM28}。零运行期变化。
321
+ */
322
+ export type SealedCheckpointCtx = StoredCheckpointCtx & {
323
+ readonly [sealedCheckpointCtxBrand]: true;
324
+ };
325
+ /** 装配期拒启的那一句(`createHttpServer` 与起服第 6 段同调;一句、一个出口)。 */
326
+ export declare const CHECKPOINT_CTX_SEALING_REQUIRED = "a durable checkpoint store is wired but checkpointCtxSealing is not: suspended tasks keep the request's credentials (MCP / A2A headers and env values, settings.env, settings.webSearch.apiKey, http hook headers) in their resume context, and they are stored sealed or not at all \u2014 give the service a sealed-key store for them (this service builds it under <data root>/sealed-key/checkpoint-ctx-keys/ at boot; a failure there is the earlier checkpoint_ctx_sealing_unavailable warning \u2014 make that directory creatable and chmod-able by the service, or repair or remove a key file there whose public and private halves do not belong together), or, when embedding, pass checkpointCtxSealing: await ensureCheckpointCtxSealing(sealedKeyDir); refusing to start rather than write credentials in plaintext";
327
+ /** 封签形的判官(恰三键、三值皆串、`alg` 是本闭集那一个词)。 */
328
+ export declare function isSealedCheckpointValue(v: unknown): v is SealedCheckpointValue;
329
+ /**
330
+ * **封口**(写的一侧唯一的一只):内存里的开封形 ctx ⇒ 落盘形。`sealer` 必传(缺席也要说出来:`undefined` = 这台副本没有保管店 ⇒ 体里有凭据就抛
331
+ * {@link CheckpointCtxUnsealableError} `no_key_store`,调用方在写之前拒;体里没有凭据 ⇒ 没有要封的东西,照常)。`sessionId` = 这一行的会话(绑进封签)。
332
+ * 调用方:{@link buildCheckpointCtx}(新的持久化写)与续跑腿的写回(`resume-legs.ts` `commitResumeCtx`)。
333
+ */
334
+ export declare function sealCheckpointCtx(ctx: CheckpointCtx, sealer: CheckpointCtxSealer | undefined, sessionId: string): SealedCheckpointCtx;
335
+ /** {@link openCheckpointCtx} 的结局:开封形 ctx,或第一处开不开的凭据位。 */
336
+ export type OpenedCheckpointCtx = {
337
+ readonly kind: "ok";
338
+ readonly ctx: CheckpointCtx;
339
+ } | {
340
+ readonly kind: "unsealable";
341
+ readonly field: string;
342
+ readonly reason: CheckpointCtxUnsealableReason;
343
+ };
344
+ /**
345
+ * **开口**(读的一侧唯一的一只;唯一调用方 = 续跑上下文读口 `readResumeCtx`):落盘形 ⇒ 开封形。`opener` 缺席 = 这台副本没有保管店(体里有封签就
346
+ * `no_key_store`;没有凭据的行照常开)。判词见本段头注。
347
+ */
348
+ export declare function openCheckpointCtx(stored: StoredCheckpointCtx, opener: CheckpointCtxOpener | undefined, sessionId: string): OpenedCheckpointCtx;
349
+ /**
350
+ * 一份落盘 ctx(持久化 JSON,不信型面)的凭据位上**第一只封签**的点名(`field`,形同拒句里的那一位;键名不是秘密,值从不出来)—— 没有 ⇒ `undefined`。
351
+ * 走法 = 封口 / 开口 / M28 共用的那一只 {@link mapCredentialSlots},判形 = {@link isSealedCheckpointValue};不开封、不看记号(只问「凭据位上有没有封签」)。
352
+ * 唯一读者:随包排空检查脚本的 `sealed-credentials-rollback` 判据(经编译产物取):7.133.x 读不懂封签、续跑时把这些凭据位当没有 ⇒ 回滚之前先把这样的停驻行决掉或取消。
353
+ */
354
+ export declare function sealedCredentialFieldOf(stored: unknown): string | undefined;
355
+ /**
356
+ * 🔴 **一次性迁移 M28 的行改写**(窗与删法见 `plugins/one-time-migrations.ts` 登记表 M28;编排 = `checkpoint-ctx-seal-m28.ts`):一行存量 ctx
357
+ * (持久化 JSON,不信型面)**没有读法记号**(= 7.134.0 之前的写者写下的)⇒ 凭据位上的**每一个值**(含调用方原样送来的封签形对象)用同一只封口封好、盖记号 ——
358
+ * 与写侧 {@link sealCheckpointCtx} 同一条规则。带记号的行(本版写下的,或本条已改写过的)、记号认不得的行 ⇒ `undefined`(不写:第二跑零命中;认不得的留给读口拒);
359
+ * 凭据位上没有值 ⇒ `undefined`(不写);体不是对象 ⇒ `undefined`(读口自己的形判接住)。其余位(另两只记号、写者版本、非凭据字段)原样。
360
+ */
361
+ export declare function sealStoredCheckpointCtxM28(stored: object, sealer: CheckpointCtxSealer, sessionId: string): {
362
+ readonly ctx: SealedCheckpointCtx;
363
+ readonly valuesSealed: number;
364
+ } | undefined;
365
+ export {};
211
366
  //# sourceMappingURL=checkpoint-ctx.d.ts.map