@sema-agent/server 7.145.0 → 7.147.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 (526) hide show
  1. package/MIGRATION.md +876 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/USAGE.md +374 -99
  5. package/deploy/facts/CHANGES.json +25 -0
  6. package/deploy/facts/README.md +57 -0
  7. package/deploy/facts/lanes.json +61 -0
  8. package/deploy/facts/lanes.schema.json +57 -0
  9. package/deploy/facts/sandbox-rbac.json +113 -0
  10. package/deploy/facts/sandbox-rbac.schema.json +74 -0
  11. package/deploy/facts/sealed-key.json +9 -0
  12. package/deploy/facts/sealed-key.schema.json +52 -0
  13. package/deploy/sema-up/README.md +2 -2
  14. package/deploy/sema-up/chart/templates/_helpers.tpl +41 -0
  15. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +47 -7
  16. package/deploy/sema-up/chart/templates/server-v4pro.yaml +9 -4
  17. package/deploy/sema-up/chart/templates/server.yaml +9 -4
  18. package/deploy/sema-up/chart/values.yaml +8 -1
  19. package/deploy/sema-up/cluster-up.sh +2 -1
  20. package/deploy/sema-up/lib/flagshape.sh +4 -0
  21. package/deploy/sema-up/lib/lanes.json +2 -5
  22. package/deploy/sema-up/sema-up.sh +12 -9
  23. package/deploy/sema-up/stack/compose.yaml +5 -4
  24. package/deploy/sema-up/stack/sema-stack-cluster.yaml +34 -17
  25. package/dist/adoption/import-limits.d.ts +6 -0
  26. package/dist/adoption/import-limits.js +7 -0
  27. package/dist/adoption/import.d.ts +62 -0
  28. package/dist/adoption/import.js +107 -0
  29. package/dist/adoption/wire.d.ts +52 -0
  30. package/dist/adoption/wire.js +9 -0
  31. package/dist/approval-ask-machine.d.ts +2 -2
  32. package/dist/approval-card.d.ts +7 -16
  33. package/dist/approval-card.js +0 -4
  34. package/dist/approval-gate-currency.d.ts +1 -1
  35. package/dist/approval-gate-currency.js +1 -1
  36. package/dist/approval-reconciler.d.ts +1 -1
  37. package/dist/approval.d.ts +3 -3
  38. package/dist/audit.js +2 -2
  39. package/dist/bench/s1/live-deps.js +3 -1
  40. package/dist/boot/crash-last.js +2 -1
  41. package/dist/boot/deployment-mods.d.ts +11 -1
  42. package/dist/boot/deployment-mods.js +15 -2
  43. package/dist/boot/device-lane.js +7 -5
  44. package/dist/boot/engine-lease.d.ts +195 -22
  45. package/dist/boot/engine-lease.js +146 -20
  46. package/dist/boot/execution-env.d.ts +5 -0
  47. package/dist/boot/execution-env.js +57 -33
  48. package/dist/boot/execution-lane.d.ts +37 -9
  49. package/dist/boot/execution-lane.js +74 -20
  50. package/dist/boot/exit-boundary.d.ts +50 -0
  51. package/dist/boot/exit-boundary.js +32 -0
  52. package/dist/boot/exit-last.d.ts +20 -4
  53. package/dist/boot/exit-last.js +23 -5
  54. package/dist/boot/governance-seams.d.ts +2 -2
  55. package/dist/boot/governance-seams.js +1 -0
  56. package/dist/boot/leader.js +1 -1
  57. package/dist/boot/memory-boundary.d.ts +11 -11
  58. package/dist/boot/memory-boundary.js +3 -3
  59. package/dist/boot/memory-consolidation.d.ts +42 -41
  60. package/dist/boot/memory-consolidation.js +26 -28
  61. package/dist/boot/org-memory.js +3 -2
  62. package/dist/boot/parked-revive-gate.d.ts +1 -1
  63. package/dist/boot/parked-revive-gate.js +1 -1
  64. package/dist/boot/reapers.d.ts +12 -4
  65. package/dist/boot/reapers.js +40 -16
  66. package/dist/boot/resolve-spec.d.ts +2 -0
  67. package/dist/boot/resolve-spec.js +126 -123
  68. package/dist/boot/retention-lane.d.ts +4 -42
  69. package/dist/boot/runner-deps.js +1 -1
  70. package/dist/boot/session-faces.d.ts +1 -0
  71. package/dist/boot/session-faces.js +11 -3
  72. package/dist/boot/shutdown.js +27 -9
  73. package/dist/boot/stage-01-config.d.ts +1 -1
  74. package/dist/boot/stage-01-config.js +7 -3
  75. package/dist/boot/stage-02-web-admin-pull.d.ts +1 -1
  76. package/dist/boot/stage-02-web-admin-pull.js +10 -8
  77. package/dist/boot/stage-03-store-backend.d.ts +2 -1
  78. package/dist/boot/stage-03-store-backend.js +2 -2
  79. package/dist/boot/stage-04-stores.d.ts +2 -1
  80. package/dist/boot/stage-05-execution-env.d.ts +4 -1
  81. package/dist/boot/stage-05-execution-env.js +6 -6
  82. package/dist/boot/stage-06-runners.d.ts +5 -2
  83. package/dist/boot/stage-06-runners.js +12 -13
  84. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  85. package/dist/boot/stage-07-capability-layer.js +7 -7
  86. package/dist/boot/stage-08-reapers.d.ts +5 -2
  87. package/dist/boot/stage-08-reapers.js +3 -3
  88. package/dist/boot/stage-09-leader.d.ts +6 -2
  89. package/dist/boot/stage-10-http-server.d.ts +6 -2
  90. package/dist/boot/stage-10-http-server.js +5 -3
  91. package/dist/boot/stores.d.ts +10 -0
  92. package/dist/boot/stores.js +53 -26
  93. package/dist/boot/web-admin.js +3 -3
  94. package/dist/boot/workflow-orchestration.d.ts +1 -1
  95. package/dist/boot/workflow-orchestration.js +2 -1
  96. package/dist/capabilities/center-plugins.d.ts +2 -0
  97. package/dist/capabilities/center-plugins.js +6 -2
  98. package/dist/capabilities/composite-members.d.ts +4 -1
  99. package/dist/capabilities/composite-members.js +4 -1
  100. package/dist/capabilities/execution-lane.d.ts +7 -7
  101. package/dist/capabilities/execution-lane.js +2 -2
  102. package/dist/capabilities/hands-lane.d.ts +1 -1
  103. package/dist/capabilities/scenarios.d.ts +34 -20
  104. package/dist/capabilities/scenarios.js +13 -9
  105. package/dist/capabilities/settings-contract.d.ts +29 -0
  106. package/dist/capabilities/settings-contract.js +14 -0
  107. package/dist/capabilities/skills.d.ts +5 -5
  108. package/dist/capability-facts.d.ts +56 -1
  109. package/dist/capability-facts.js +59 -8
  110. package/dist/center-credential-renewer.js +3 -2
  111. package/dist/checkpoint-ctx-seal-m28.d.ts +1 -1
  112. package/dist/config-catalog.js +19 -9
  113. package/dist/config-invariants.d.ts +18 -3
  114. package/dist/config-invariants.js +36 -19
  115. package/dist/config-lkg.d.ts +1 -1
  116. package/dist/config-lkg.js +5 -6
  117. package/dist/config-provider.d.ts +2 -2
  118. package/dist/config-provider.js +2 -0
  119. package/dist/config-types.d.ts +228 -185
  120. package/dist/config.d.ts +74 -6
  121. package/dist/config.js +146 -64
  122. package/dist/degenerate-instrument.js +1 -1
  123. package/dist/deleted-session-ids.d.ts +19 -0
  124. package/dist/deleted-session-ids.js +26 -0
  125. package/dist/deploy-facts.d.ts +155 -0
  126. package/dist/deploy-facts.js +95 -0
  127. package/dist/deployment-shape.d.ts +21 -12
  128. package/dist/deployment-shape.js +24 -6
  129. package/dist/device-ws-hub.d.ts +48 -3
  130. package/dist/device-ws-hub.js +48 -2
  131. package/dist/env-facts.d.ts +7 -5
  132. package/dist/env-facts.js +10 -6
  133. package/dist/error-code-family.d.ts +35 -0
  134. package/dist/error-code-family.js +26 -0
  135. package/dist/execution-config-root.d.ts +5 -5
  136. package/dist/execution-config-root.js +5 -5
  137. package/dist/execution-env-purpose.d.ts +14 -0
  138. package/dist/execution-env-purpose.js +29 -0
  139. package/dist/execution-lane-caps.d.ts +49 -86
  140. package/dist/execution-lane-caps.js +52 -62
  141. package/dist/execution-placement.d.ts +18 -2
  142. package/dist/execution-placement.js +19 -0
  143. package/dist/file-history-disclosure.d.ts +2 -2
  144. package/dist/fleet/drain-entry.d.ts +46 -3
  145. package/dist/fleet/drain-entry.js +6 -0
  146. package/dist/fleet/fleet-bus.d.ts +2 -1
  147. package/dist/fleet/serving-lease.js +3 -4
  148. package/dist/history-anchor.d.ts +22 -0
  149. package/dist/history-anchor.js +14 -0
  150. package/dist/hooks/branch-transcript.d.ts +1 -1
  151. package/dist/hooks/branch-transcript.js +1 -0
  152. package/dist/hooks/classic-stations.d.ts +25 -8
  153. package/dist/hooks/classic-stations.js +29 -3
  154. package/dist/hooks/command-spawn.d.ts +1 -4
  155. package/dist/hooks/command-spawn.js +0 -11
  156. package/dist/hooks/hook-runner.d.ts +85 -24
  157. package/dist/hooks/hook-runner.js +326 -109
  158. package/dist/hooks/hook-source.d.ts +14 -2
  159. package/dist/hooks/hook-source.js +8 -0
  160. package/dist/http/active-run-conflict.d.ts +1 -1
  161. package/dist/http/active-run-conflict.js +1 -1
  162. package/dist/http/admission.js +11 -1
  163. package/dist/http/approval-sweeps.d.ts +2 -5
  164. package/dist/http/approval-sweeps.js +3 -2
  165. package/dist/http/checkpoint-ctx.d.ts +76 -71
  166. package/dist/http/checkpoint-ctx.js +40 -40
  167. package/dist/http/claim-latency.d.ts +10 -0
  168. package/dist/http/claim-latency.js +12 -0
  169. package/dist/http/dispatch.js +19 -3
  170. package/dist/http/durable-run-leg.d.ts +5 -0
  171. package/dist/http/durable-run-leg.js +3 -1
  172. package/dist/http/execution-context.d.ts +7 -1
  173. package/dist/http/execution-context.js +13 -0
  174. package/dist/http/health-self-report.d.ts +6 -2
  175. package/dist/http/health-self-report.js +3 -2
  176. package/dist/http/memory-compliance-failure-reply.d.ts +2 -2
  177. package/dist/http/memory-compliance-failure-reply.js +5 -15
  178. package/dist/http/memory-control-plane-corrupt-reply.d.ts +25 -0
  179. package/dist/http/memory-control-plane-corrupt-reply.js +19 -0
  180. package/dist/http/memory-store-refusal-reply.d.ts +3 -3
  181. package/dist/http/memory-store-refusal-reply.js +3 -0
  182. package/dist/http/owner-access.d.ts +11 -0
  183. package/dist/http/owner-access.js +7 -4
  184. package/dist/http/principal-gate.d.ts +28 -16
  185. package/dist/http/principal-gate.js +10 -19
  186. package/dist/http/request-guards.d.ts +2 -2
  187. package/dist/http/request-guards.js +5 -5
  188. package/dist/http/resume-legs.d.ts +29 -10
  189. package/dist/http/resume-legs.js +94 -56
  190. package/dist/http/rewind-files-reply.d.ts +34 -0
  191. package/dist/http/rewind-files-reply.js +36 -0
  192. package/dist/http/route-ctx.d.ts +43 -26
  193. package/dist/http/route-table.js +4 -0
  194. package/dist/http/routes/adoption.d.ts +11 -0
  195. package/dist/http/routes/adoption.js +80 -6
  196. package/dist/http/routes/agents-roster.js +1 -0
  197. package/dist/http/routes/approvals-assistant.js +7 -26
  198. package/dist/http/routes/background.js +1 -0
  199. package/dist/http/routes/capabilities.js +12 -3
  200. package/dist/http/routes/devices.js +1 -1
  201. package/dist/http/routes/diagnostics.d.ts +9 -14
  202. package/dist/http/routes/diagnostics.js +10 -20
  203. package/dist/http/routes/engine.d.ts +31 -0
  204. package/dist/http/routes/engine.js +81 -0
  205. package/dist/http/routes/memory-bundle.js +3 -0
  206. package/dist/http/routes/memory-consolidation.js +3 -5
  207. package/dist/http/routes/memory-origin.d.ts +2 -2
  208. package/dist/http/routes/memory-origin.js +2 -4
  209. package/dist/http/routes/memory-policy.js +5 -1
  210. package/dist/http/routes/notify-wake.js +2 -1
  211. package/dist/http/routes/observability.js +3 -6
  212. package/dist/http/routes/projects.d.ts +70 -0
  213. package/dist/http/routes/projects.js +86 -0
  214. package/dist/http/routes/rules.js +30 -2
  215. package/dist/http/routes/runs.js +15 -11
  216. package/dist/http/routes/session-sync.js +39 -35
  217. package/dist/http/routes/sessions-list.d.ts +1 -1
  218. package/dist/http/routes/sessions.d.ts +7 -1
  219. package/dist/http/routes/sessions.js +108 -2
  220. package/dist/http/routes/tasks.js +32 -8
  221. package/dist/http/routes/trace-usage.js +1 -1
  222. package/dist/http/run-concurrency-cap.d.ts +86 -0
  223. package/dist/http/run-concurrency-cap.js +54 -0
  224. package/dist/http/server.d.ts +31 -14
  225. package/dist/http/server.js +29 -3
  226. package/dist/http/stored-body-replay.d.ts +12 -7
  227. package/dist/http/stored-body-replay.js +28 -5
  228. package/dist/http/wire-types.d.ts +27 -13
  229. package/dist/index.d.ts +2 -2
  230. package/dist/index.js +1 -1
  231. package/dist/instruction-source-notice.d.ts +1 -1
  232. package/dist/json-body-limit.d.ts +8 -0
  233. package/dist/json-body-limit.js +2 -0
  234. package/dist/leader/diffout.d.ts +1 -1
  235. package/dist/local-data-root.d.ts +2 -2
  236. package/dist/memory-embedder-reembed.d.ts +38 -0
  237. package/dist/memory-embedder-reembed.js +20 -0
  238. package/dist/memory-incident-sink.d.ts +0 -28
  239. package/dist/memory-incident-sink.js +5 -0
  240. package/dist/memory-operator-faces.d.ts +9 -4
  241. package/dist/memory-scope-stores.d.ts +9 -7
  242. package/dist/memory-scope-stores.js +3 -14
  243. package/dist/memory-scope.d.ts +38 -2
  244. package/dist/memory-scope.js +33 -2
  245. package/dist/memory-store-refusal.d.ts +17 -4
  246. package/dist/memory-store-refusal.js +1 -1
  247. package/dist/memory-sync-client.d.ts +2 -0
  248. package/dist/memory-sync-client.js +13 -11
  249. package/dist/memory-sync.js +1 -1
  250. package/dist/model-compat.d.ts +35 -21
  251. package/dist/model-compat.js +49 -21
  252. package/dist/model-entry-refusal.d.ts +11 -1
  253. package/dist/model-entry-refusal.js +7 -0
  254. package/dist/namespaced-rule-name.d.ts +18 -1
  255. package/dist/namespaced-rule-name.js +12 -0
  256. package/dist/net-address.d.ts +53 -0
  257. package/dist/net-address.js +111 -0
  258. package/dist/observability/fail-open.d.ts +29 -17
  259. package/dist/observability/fail-open.js +29 -17
  260. package/dist/observability/metrics.d.ts +2 -0
  261. package/dist/observability/metrics.js +2 -0
  262. package/dist/observability/secret-env-scrub.d.ts +30 -4
  263. package/dist/observability/secret-env-scrub.js +15 -3
  264. package/dist/orchestration/workflow-agent-session-index.d.ts +7 -12
  265. package/dist/orchestration/workflow-agent-session-index.js +1 -6
  266. package/dist/orchestration/workflow-completion-inbox.d.ts +26 -6
  267. package/dist/orchestration/workflow-completion-inbox.js +63 -45
  268. package/dist/orchestration/workflow-notify-journal.js +2 -3
  269. package/dist/org-delivery-gate.js +1 -1
  270. package/dist/org-memory-admission.d.ts +5 -2
  271. package/dist/org-memory-admission.js +25 -10
  272. package/dist/parked-decide.d.ts +33 -26
  273. package/dist/parked-decide.js +36 -44
  274. package/dist/peer-directory.d.ts +6 -12
  275. package/dist/peer-directory.js +5 -1
  276. package/dist/plugins/approval-ask-store-file.d.ts +10 -2
  277. package/dist/plugins/approval-ask-store-file.js +37 -4
  278. package/dist/plugins/approval-ask-store-memory.d.ts +5 -3
  279. package/dist/plugins/approval-ask-store-memory.js +11 -2
  280. package/dist/plugins/approval-ask-store-sql.d.ts +3 -0
  281. package/dist/plugins/approval-ask-store-sql.js +3 -1
  282. package/dist/plugins/blob-backend.d.ts +38 -195
  283. package/dist/plugins/blob-backend.js +33 -229
  284. package/dist/plugins/caching-session-store.d.ts +12 -5
  285. package/dist/plugins/caching-session-store.js +3 -0
  286. package/dist/plugins/checkpoint-index-columns.d.ts +1 -1
  287. package/dist/plugins/checkpoint-index-columns.js +3 -2
  288. package/dist/plugins/checkpoint-store-face.d.ts +426 -0
  289. package/dist/plugins/checkpoint-store-face.js +152 -0
  290. package/dist/plugins/device-store-sql.d.ts +2 -2
  291. package/dist/plugins/device-store-sql.js +5 -10
  292. package/dist/plugins/execution-lane-rename-m40.d.ts +20 -0
  293. package/dist/plugins/execution-lane-rename-m40.js +10 -0
  294. package/dist/plugins/execution-placement-sql.d.ts +63 -88
  295. package/dist/plugins/execution-placement-sql.js +94 -54
  296. package/dist/plugins/file-run-store.d.ts +26 -18
  297. package/dist/plugins/file-run-store.js +64 -75
  298. package/dist/plugins/fork-routing-session-store.d.ts +6 -2
  299. package/dist/plugins/fork-routing-session-store.js +2 -2
  300. package/dist/plugins/imported-layer-root-retirement.d.ts +22 -11
  301. package/dist/plugins/imported-layer-root-retirement.js +4 -8
  302. package/dist/plugins/inbox-payload-column.d.ts +14 -0
  303. package/dist/plugins/inbox-payload-column.js +13 -0
  304. package/dist/plugins/local-checkpoint-store.d.ts +7 -2
  305. package/dist/plugins/local-checkpoint-store.js +13 -8
  306. package/dist/plugins/local-data-dir-modes-m39.d.ts +48 -0
  307. package/dist/plugins/local-data-dir-modes-m39.js +182 -0
  308. package/dist/plugins/local-engine-high-water.d.ts +11 -0
  309. package/dist/plugins/local-engine-high-water.js +59 -0
  310. package/dist/plugins/local-session-store.d.ts +119 -30
  311. package/dist/plugins/local-session-store.js +156 -53
  312. package/dist/plugins/local-task-attachment-store.d.ts +2 -0
  313. package/dist/plugins/local-task-attachment-store.js +10 -11
  314. package/dist/plugins/memory-embedder-fingerprint.d.ts +33 -10
  315. package/dist/plugins/memory-embedder-fingerprint.js +52 -12
  316. package/dist/plugins/memory-embedder.d.ts +1 -1
  317. package/dist/plugins/memory-embedder.js +2 -2
  318. package/dist/plugins/memory-engine-pg.d.ts +30 -6
  319. package/dist/plugins/memory-engine-pg.js +96 -214
  320. package/dist/plugins/memory-engine-sql-apply.d.ts +130 -0
  321. package/dist/plugins/memory-engine-sql-apply.js +358 -0
  322. package/dist/plugins/memory-engine-tidb.d.ts +38 -9
  323. package/dist/plugins/memory-engine-tidb.js +99 -230
  324. package/dist/plugins/memory-key-guards.d.ts +1 -1
  325. package/dist/plugins/memory-origin-law.d.ts +3 -3
  326. package/dist/plugins/one-time-migrations.d.ts +169 -83
  327. package/dist/plugins/one-time-migrations.js +295 -235
  328. package/dist/plugins/owner-only-file-mode.d.ts +29 -0
  329. package/dist/plugins/owner-only-file-mode.js +141 -0
  330. package/dist/plugins/permission-rule-store-file.d.ts +17 -3
  331. package/dist/plugins/permission-rule-store-file.js +20 -1
  332. package/dist/plugins/pg-pool.d.ts +2 -1
  333. package/dist/plugins/pg-pool.js +12 -5
  334. package/dist/plugins/release-version.d.ts +20 -0
  335. package/dist/plugins/release-version.js +28 -0
  336. package/dist/plugins/remote-env-adb.d.ts +20 -4
  337. package/dist/plugins/remote-env-adb.js +39 -11
  338. package/dist/plugins/remote-env-e2b.d.ts +12 -3
  339. package/dist/plugins/remote-env-e2b.js +6 -4
  340. package/dist/plugins/remote-env-host.d.ts +9 -1
  341. package/dist/plugins/remote-env-host.js +6 -5
  342. package/dist/plugins/remote-env-k8s.d.ts +5 -2
  343. package/dist/plugins/remote-env-k8s.js +15 -4
  344. package/dist/plugins/remote-env-local-docker.d.ts +4 -1
  345. package/dist/plugins/remote-env-local-docker.js +3 -3
  346. package/dist/plugins/remote-env-ssh.d.ts +8 -2
  347. package/dist/plugins/remote-env-ssh.js +26 -24
  348. package/dist/plugins/remote-shell.d.ts +59 -30
  349. package/dist/plugins/remote-shell.js +175 -62
  350. package/dist/plugins/retention-declaration.d.ts +37 -0
  351. package/dist/plugins/retention-declaration.js +9 -0
  352. package/dist/plugins/retention-deployment.d.ts +126 -0
  353. package/dist/plugins/retention-deployment.js +88 -0
  354. package/dist/plugins/retention-lane-store-sql.d.ts +74 -4
  355. package/dist/plugins/retention-lane-store-sql.js +103 -1
  356. package/dist/plugins/retention-sql.d.ts +29 -0
  357. package/dist/plugins/retention-sql.js +8 -0
  358. package/dist/plugins/run-store-sql.js +2 -2
  359. package/dist/plugins/schema-consistency.d.ts +0 -6
  360. package/dist/plugins/schema-consistency.js +1 -2
  361. package/dist/plugins/schema-ensure-legs.d.ts +1 -1
  362. package/dist/plugins/schema-ensure-legs.js +13 -3
  363. package/dist/plugins/session-ext-table.d.ts +74 -0
  364. package/dist/plugins/session-ext-table.js +121 -0
  365. package/dist/plugins/session-fork.d.ts +31 -9
  366. package/dist/plugins/session-fork.js +3 -2
  367. package/dist/plugins/session-placement.d.ts +4 -2
  368. package/dist/plugins/session-row-sql.d.ts +8 -7
  369. package/dist/plugins/session-row-sql.js +15 -7
  370. package/dist/plugins/session-store-sql.d.ts +131 -0
  371. package/dist/plugins/session-store-sql.js +298 -0
  372. package/dist/plugins/session-workspace-cell.d.ts +2 -2
  373. package/dist/plugins/session-workspace-cell.js +2 -2
  374. package/dist/plugins/shared-memory-store-sql.d.ts +10 -0
  375. package/dist/plugins/shared-memory-store-sql.js +13 -13
  376. package/dist/plugins/snapshot-bucket-presence.js +1 -1
  377. package/dist/plugins/sql-driver.d.ts +23 -7
  378. package/dist/plugins/sql-driver.js +41 -8
  379. package/dist/plugins/sql-errors.d.ts +5 -2
  380. package/dist/plugins/sql-errors.js +4 -0
  381. package/dist/plugins/sql-json-column.d.ts +5 -1
  382. package/dist/plugins/store-backend.d.ts +46 -16
  383. package/dist/plugins/store-backend.js +192 -69
  384. package/dist/plugins/store-contracts.d.ts +10 -13
  385. package/dist/plugins/store-contracts.js +1 -9
  386. package/dist/plugins/store-sweep.d.ts +63 -0
  387. package/dist/plugins/store-sweep.js +48 -0
  388. package/dist/plugins/task-attachment-store.d.ts +6 -8
  389. package/dist/plugins/task-attachment-store.js +15 -10
  390. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  391. package/dist/plugins/text-column-capacity.d.ts +21 -0
  392. package/dist/plugins/text-column-capacity.js +5 -0
  393. package/dist/plugins/tidb-pool.d.ts +3 -2
  394. package/dist/plugins/tidb-pool.js +20 -32
  395. package/dist/plugins/user-input-ledger-sql.d.ts +1 -1
  396. package/dist/prompt-screen.d.ts +6 -9
  397. package/dist/prompt-screen.js +2 -5
  398. package/dist/read-face-posture.d.ts +6 -6
  399. package/dist/read-face-posture.js +2 -2
  400. package/dist/request-value-closure.d.ts +5 -5
  401. package/dist/request-value-closure.js +1 -1
  402. package/dist/rules-consent.d.ts +48 -27
  403. package/dist/rules-consent.js +147 -23
  404. package/dist/run-cancel-context.d.ts +4 -1
  405. package/dist/run-cancel-context.js +2 -1
  406. package/dist/run-local.js +17 -13
  407. package/dist/runs.d.ts +48 -30
  408. package/dist/runs.js +27 -17
  409. package/dist/runtime-caps-resolver.d.ts +15 -8
  410. package/dist/runtime-caps-resolver.js +14 -10
  411. package/dist/sandbox-egress-policy.js +6 -11
  412. package/dist/sandbox-rbac-rules.d.ts +88 -0
  413. package/dist/sandbox-rbac-rules.js +80 -0
  414. package/dist/sealed-key-layout.d.ts +16 -0
  415. package/dist/sealed-key-layout.js +3 -0
  416. package/dist/sealed-key.js +8 -6
  417. package/dist/security.d.ts +43 -9
  418. package/dist/security.js +9 -2
  419. package/dist/sema-config-dir.js +2 -2
  420. package/dist/server-secret-env.d.ts +2 -0
  421. package/dist/service-version.d.ts +2 -1
  422. package/dist/service-version.js +2 -2
  423. package/dist/session-error-wire.d.ts +1 -1
  424. package/dist/session-incarnation.d.ts +8 -5
  425. package/dist/session-notify-door.d.ts +5 -3
  426. package/dist/session-resident-background.d.ts +110 -0
  427. package/dist/session-resident-background.js +88 -0
  428. package/dist/session-row.d.ts +1 -1
  429. package/dist/session-sync-kernel.d.ts +53 -14
  430. package/dist/session-sync-kernel.js +70 -1
  431. package/dist/session-sync.d.ts +5 -3
  432. package/dist/session-workspace.d.ts +12 -2
  433. package/dist/session-workspace.js +6 -0
  434. package/dist/sighup-idle.d.ts +9 -7
  435. package/dist/sighup-idle.js +4 -5
  436. package/dist/spec-fields.d.ts +16 -0
  437. package/dist/spec-fields.js +7 -0
  438. package/dist/store-posture.d.ts +2 -1
  439. package/dist/stored-request-env-credentials-m38.d.ts +3 -0
  440. package/dist/stored-request-env-credentials-m38.js +8 -0
  441. package/dist/stored-request-hooks-m20.d.ts +3 -2
  442. package/dist/stored-request-hooks-m20.js +19 -14
  443. package/dist/stored-request-prompt-profile-m30.d.ts +1 -1
  444. package/dist/stores-sql/blob-index-sql.d.ts +148 -0
  445. package/dist/stores-sql/blob-index-sql.js +154 -0
  446. package/dist/{plugins → stores-sql}/checkpoint-store-sql.d.ts +14 -428
  447. package/dist/{plugins → stores-sql}/checkpoint-store-sql.js +43 -220
  448. package/dist/{plugins → stores-sql}/file-history-store-sql.d.ts +23 -11
  449. package/dist/{plugins → stores-sql}/file-history-store-sql.js +23 -18
  450. package/dist/{plugins → stores-sql}/mailbox-store-sql.d.ts +2 -2
  451. package/dist/{plugins → stores-sql}/mailbox-store-sql.js +4 -4
  452. package/dist/{plugins → stores-sql}/pg-session-storage.d.ts +27 -67
  453. package/dist/{plugins → stores-sql}/pg-session-storage.js +82 -207
  454. package/dist/{plugins → stores-sql}/retention-store-sql.d.ts +123 -217
  455. package/dist/{plugins → stores-sql}/retention-store-sql.js +66 -190
  456. package/dist/{plugins → stores-sql}/roster-store-sql.d.ts +2 -2
  457. package/dist/{plugins → stores-sql}/roster-store-sql.js +1 -1
  458. package/dist/{plugins → stores-sql}/session-event-payload.d.ts +1 -1
  459. package/dist/{plugins → stores-sql}/session-event-payload.js +1 -1
  460. package/dist/stores-sql/session-policy-store-sql.d.ts +1 -1
  461. package/dist/stores-sql/session-write-hooks.d.ts +59 -0
  462. package/dist/stores-sql/session-write-hooks.js +2 -0
  463. package/dist/{plugins → stores-sql}/tidb-session-storage.d.ts +10 -11
  464. package/dist/{plugins → stores-sql}/tidb-session-storage.js +10 -21
  465. package/dist/{plugins → stores-sql}/tidb-session-store.d.ts +35 -112
  466. package/dist/{plugins → stores-sql}/tidb-session-store.js +73 -169
  467. package/dist/{plugins → stores-sql}/tool-result-store-sql.d.ts +3 -3
  468. package/dist/{plugins → stores-sql}/tool-result-store-sql.js +6 -6
  469. package/dist/stores-sql/windowed-session-storage.d.ts +56 -0
  470. package/dist/stores-sql/windowed-session-storage.js +61 -0
  471. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.d.ts +7 -12
  472. package/dist/{plugins → stores-sql}/workflow-journal-store-sql.js +3 -8
  473. package/dist/task-a2a.d.ts +7 -1
  474. package/dist/task-a2a.js +15 -14
  475. package/dist/task-cwd.d.ts +11 -3
  476. package/dist/task-cwd.js +17 -1
  477. package/dist/task-mcp.d.ts +10 -2
  478. package/dist/task-mcp.js +13 -16
  479. package/dist/task-settings.d.ts +68 -8
  480. package/dist/task-settings.js +63 -6
  481. package/dist/tool-approval.d.ts +23 -10
  482. package/dist/tool-approval.js +10 -6
  483. package/dist/trace/core-keyset-guard.d.ts +17 -10
  484. package/dist/trace/engine-notice-wire.d.ts +1 -1
  485. package/dist/trace/engine-notice-wire.js +4 -0
  486. package/dist/trace/exit-seat.d.ts +29 -1
  487. package/dist/trace/exit-seat.js +4 -0
  488. package/dist/trace/project.d.ts +33 -16
  489. package/dist/trace/project.js +21 -9
  490. package/dist/trace/redact.d.ts +13 -2
  491. package/dist/trace/redact.js +347 -78
  492. package/dist/trace/self-minted-wire.d.ts +587 -16
  493. package/dist/trace/self-minted-wire.js +215 -9
  494. package/dist/trace/sema-provenance.d.ts +45 -41
  495. package/dist/trace/sema-provenance.js +81 -10
  496. package/dist/trace/task-notification-facets.d.ts +70 -2
  497. package/dist/trace/task-notification-facets.js +71 -1
  498. package/dist/trace/wire-projection-faces.d.ts +39 -3
  499. package/dist/trace/wire-projection-faces.js +27 -2
  500. package/dist/unread-request-members.d.ts +66 -0
  501. package/dist/unread-request-members.js +41 -0
  502. package/dist/usage-analytics.d.ts +4 -0
  503. package/dist/user-input-ledger.d.ts +2 -2
  504. package/dist/web-admin-client/apply-effective.js +22 -26
  505. package/dist/web-admin-client/candidate-gate.d.ts +35 -3
  506. package/dist/web-admin-client/candidate-gate.js +53 -5
  507. package/dist/web-admin-client/center-request.d.ts +4 -1
  508. package/dist/web-admin-client/center-request.js +2 -1
  509. package/dist/web-admin-client/effective-keys.js +0 -1
  510. package/dist/web-admin-client/facade.d.ts +1 -1
  511. package/dist/web-admin-client/http-client.d.ts +1 -0
  512. package/dist/web-admin-client/http-client.js +17 -9
  513. package/dist/web-admin-client/restart-signal.js +5 -2
  514. package/dist/web-admin-client/skills-mcp.d.ts +20 -6
  515. package/dist/web-admin-client/skills-mcp.js +26 -21
  516. package/dist/web-admin-client/types.d.ts +34 -49
  517. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +2 -2
  518. package/package.json +22 -13
  519. package/scripts/drain-check-local.mjs +8 -55
  520. package/scripts/drain-check.mysql.sql +3 -40
  521. package/scripts/drain-check.pg.sql +3 -40
  522. package/skills/update-config.md +1 -1
  523. package/wire-changes/server@7.146.0.json +3221 -0
  524. package/wire-changes/server@7.147.0.json +813 -0
  525. package/dist/approval-batch-census.d.ts +0 -27
  526. package/dist/approval-batch-census.js +0 -27
@@ -19,7 +19,7 @@ import type { HostDecision } from "../host-decision.js";
19
19
  import type { EntryProblem } from "../entry-problems.js";
20
20
  import type { SessionOwnerCell } from "../security.js";
21
21
  import type { SessionNotifyDoor } from "../session-notify-door.js";
22
- import type { TaskStream, TaskSpec, TaskResult, QuestionAnswer, Checkpoint, CheckpointToken, ResumeOutcome, RunInternals, Runner, EngineNotice } from "@sema-agent/core";
22
+ import type { TaskStream, TaskSpec, TaskResult, QuestionAnswer, Checkpoint, CheckpointToken, ResumeOutcome, RunInternals, Runner, EngineNotice, PendingSteerInput } from "@sema-agent/core";
23
23
  import type { FlatServiceDeps, RequestAuth } from "./server.js";
24
24
  import type { TaskRequestBody, DecideBinding } from "./wire-types.js";
25
25
  import type { IdempotencyCache, SubmitOutcome } from "./idempotency.js";
@@ -36,6 +36,7 @@ import type { PeerLease } from "../peer-seat.js";
36
36
  import type { RootedTaskSpec } from "./execution-context.js";
37
37
  import type { GateCommitment, GateSettlementEvidence } from "../gate-settlement.js";
38
38
  import type { ResumeRestatement } from "./resume-restatement.js";
39
+ import type { RememberLaneCannotRecord } from "../parked-decide.js";
39
40
  /** 跨域可变状态 = lens1 §C2 实测的那 8 条「运行期登记簿」,一个对象。
40
41
  * [ref]:`cancelledViaVerb`(按 taskId 键控的「这次是取消动词」旁表)删除 —— 中止成因改挂在每条腿自己的
41
42
  * {@link RunAbort} 句柄上(`inflightRuns` 的值),同寿同删,不再有一张与腿不同寿的旁表。 */
@@ -79,6 +80,12 @@ export interface RouteHelpers {
79
80
  ownerLeaseDenied(res: ServerResponse, owner: string | undefined): Promise<boolean>;
80
81
  /** [ref]-T1:治理窗 pre-admission(异步 202 车道的唯一 429 出路;key 公式与 core 单源)。 */
81
82
  usageWindowDenied(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
83
+ /**
84
+ * 在飞 run 并发帽的提交门准入(`RUN_MAX_CONCURRENT*`,缺省关;判据、席位与拒的形全文在 `http/run-concurrency-cap.ts`):放行 ⇒ 席位(登记那一拍与 `finally` 放);
85
+ * 超帽 ⇒ 已应答 429 + `Retry-After`、回 `undefined`。只挂**新提交**门(`createDurableRun` / `POST /v1/tasks` / `POST /v1/tasks/stream`),
86
+ * 排在幂等重放与 `usageWindowDenied` 之后、任何建行 / 认领 / SSE 头之前。
87
+ */
88
+ admitRun(req: IncomingMessage, res: ServerResponse): import("./run-concurrency-cap.js").RunSlot | undefined;
82
89
  safeDecode(seg: string): string | null;
83
90
  /** run 面的属主门(谓词 `runOwnerReadable`;非属主 ⇒ 404 `not_found.run` + 长文,与 run 读口的 unknown 臂同码同串,[ref])。 */
84
91
  runOwnerOk(req: IncomingMessage, res: ServerResponse, owner: string | null): boolean;
@@ -191,17 +198,10 @@ export interface CheckpointCtx {
191
198
  * 传原 ctx / 其展开 ⇒ 标随行。缺席 = 不是无人值守腿(HTTP 提交腿;7.106.0 前落盘的行 —— 那时这些腿不铸模式,checkpoint 里也没有)。
192
199
  */
193
200
  unattendedLeg?: true;
194
- /**
195
- * 体里 `settings.permissions.allow` 的**读法记号**(闭集只有当前读法一词 `"allow_layer"`):在场 = 这一行是当前读法下写下的、体里带非空 `allow`,
196
- * 它按「交给引擎的 allow 层」写、也按它读。**服务端写、不来自请求体**(与 {@link unattendedLeg} 同为 `body` 的兄弟键)。
197
- * 缺席(≤7.114.0,名单时代)或旧词 `"statement"`(7.115.0–7.116.x,表态时代)而体里带非空 `allow` ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts` 顶注)。
198
- * 写点只有 `buildCheckpointCtx`(同模块;新的持久化写);续跑腿的写回传原 ctx / 其展开 ⇒ 记号随行。体里没有 `allow` 的行不写它。
199
- */
200
- permissionsAllowReading?: import("./checkpoint-ctx.js").PermissionsAllowReading;
201
201
  /**
202
202
  * 体里**模式词的读法记号**(闭集只有当前一词 `"entry_word"`):在场 = 这一行体的顶层 `permissionMode` 是这条 run 模式词唯一的源(提交入口盖过运维
203
203
  * `AUTONOMY=plan` 的地板;`plan_review` 写回改它),续跑照它读。**服务端写、不来自请求体**。缺席(7.121.x 及以前写下的行 —— 那时运维的 plan 由治理层每段重钳)
204
- * 而本部署此刻有入口地板、体的词被地板钳会变 ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts` 顶注第三问)。
204
+ * 而本部署此刻有入口地板、体的词被地板钳会变 ⇒ 续跑腿响亮拒、行字节不动(规则与删除条件的属主 = `http/checkpoint-ctx.ts` 顶注「模式词问」)。
205
205
  * 写点两个(写模式词的人盖记号,同模块):`buildCheckpointCtx`(每一次新的持久化写都写)与 `withPermissionModeRewritten`(`plan_review` 改词的写回);
206
206
  * 不改词的续跑腿写回传原 ctx ⇒ 记号随行。
207
207
  */
@@ -210,8 +210,10 @@ export interface CheckpointCtx {
210
210
  * 🔴 [ref] —— **写这份上下文的服务版本**(`package.json` 的 `version`),**服务端写、不来自请求体**(与 {@link unattendedLeg} 同为 `body` 的兄弟键)。
211
211
  * 写点两个:`buildCheckpointCtx`(每一次新的持久化写)与续跑腿的写回({@link DriveResumeArgs.resumeCtx} 的唯一写点,CAS 赢点盖本进程的版本 —— 接下来写下一张停车行的就是它)。
212
212
  * 读者:`checkpoint.unsupported_version` 的 409 体 —— 原样带出 `writerVersion`,与本引擎的 `readerVersion` 并列(运维据此知道该回哪一版去决);
213
- * 两键唯一铸法 `checkpoint-ctx.ts` `buildCheckpointVersionKeys`,本码每个铸点同调。它是**上下文**,不是拒因:成因与码都不读它。
214
- * 缺席 = 本版之前写下的行(不回填):那一码的体不带两键,如实不猜。不是一次性迁移 —— 这一格是常设的事实位,没有删除条件。
213
+ * 两键唯一铸法 `checkpoint-ctx.ts` `buildCheckpointVersionKeys`,本码每个铸点同调。
214
+ * 另一个读者(唯一的拒因读者):存体重放判据的 allow 读法问(`checkpoint-ctx.ts` 顶注)—— 体里带非空 `settings.permissions.allow` 而本格证不出 ≥ 7.117.0 ⇒ 拒。
215
+ * 所以写点守一条律:盖本格的写只在本进程按当前读法读过这份体之后(新提交;或已过存体重放判据的续跑写回),在判据之前盖 = 把旧行洗成新行。
216
+ * 缺席 = 7.124.0 之前写下的行(不回填):那一码的体不带两键,如实不猜;allow 读法问把它读作「证不出」。不是一次性迁移 —— 这一格是常设的事实位,没有删除条件。
215
217
  */
216
218
  writerVersion?: string;
217
219
  /**
@@ -420,6 +422,7 @@ export interface PreparedPlanReview {
420
422
  readonly sessionId: string;
421
423
  readonly token: CheckpointToken;
422
424
  readonly cp: Checkpoint;
425
+ /** 这条决断唯一的一次 ctx 读,**已盖过**续跑请求的重述键(缺席 = 存量体原样):存体预判判的、驱动段重建与写回读的都是这一份。 */
423
426
  readonly ctx: CheckpointCtx;
424
427
  }
425
428
  /** 提交/续跑「腿」= 跨域共享的**有状态**长流程(不像 {@link RouteHelpers} 那样只依赖 deps/config:它们要写
@@ -458,14 +461,8 @@ export interface RouteLegs {
458
461
  /** 这次决定落在哪一个动作上:调用方点名它看到的那一对(`boundCallId` + `boundInputHash`);缺任一 ⇒ 400 `decide_requires_binding`
459
462
  * (判在门型守卫之后,判官 `decidedActionOf`)。本函数从不拿当前停驻行补。 */
460
463
  binding: DecideBinding,
461
- /** [ref] codex R4(验真后修):remember 豁免的 grant 挂点。**工具名不再由路由自己读**(那是与本函数
462
- * 载入行分歧的第三次 scope-less 读,三读分歧下会给他人工具落豁免=提权)——由本函数把**已属主校验的
463
- * 载入 cp** 的可记工具名(`rememberableToolName`,非 tool_approval / AskUserQuestion / legacy null / [ref] 强制卡 ⇒ `null`
464
- * = 无可记)一并回传,路由只对这个逐字落店。`overrideSessionId` = parked 腿的 root/host 会话 grant 锚。 */
465
- onResumeCommitted?: (grant: {
466
- overrideSessionId?: string;
467
- rememberableToolName: string | null;
468
- }) => Promise<void>,
464
+ /** 这次决定带着「本会话放行」请求({@link RememberSessionRequest})⇒ 本函数是它的**唯一铸点**,结局的 `rememberApplied` 是它的答({@link ResumeCheckpointOutcome})。 */
465
+ remember?: RememberSessionRequest,
469
466
  /** [ref]:透传给 {@link DriveResumeArgs.acceptEarly}(200 受理语义)。HTTP `/decide` 腿传 `true`;
470
467
  * 内部 D-D SLA deny-sweep 不传 —— 它没有在等响应的人,提前受理对它零收益而少一条同步失败面。 */
471
468
  acceptEarly?: boolean,
@@ -476,7 +473,7 @@ export interface RouteLegs {
476
473
  explicitOperator: boolean;
477
474
  },
478
475
  /** 续跑请求的重述键(`mcpServers` / `a2aPeers`),门读出并判过的那一份;缺席 = 冻结读法。语义属主 = `resume-restatement.ts` 顶注。 */
479
- restatement?: ResumeRestatement): Promise<ResumeLegOutcome>;
476
+ restatement?: ResumeRestatement): Promise<ResumeCheckpointOutcome>;
480
477
  /** 全 resume 家族的共同下半场(lease admission + 写 run log + fleet 发布)。 */
481
478
  driveResumeIntoRunLog(args: DriveResumeArgs): Promise<ResumeLegOutcome>;
482
479
  /** assistant 抢占腿的复位(gate-kind 守卫 + 行级属主复核 + 驱动)。 */
@@ -492,7 +489,9 @@ export interface RouteLegs {
492
489
  /** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参)。 */
493
490
  restatement?: ResumeRestatement): Promise<ResumeLegOutcome>;
494
491
  /** notify-wake 域:唤醒一条 parked checkpoint。 */
495
- resumeWake(sessionId: string, message: string | undefined, caller: string | undefined, req: IncomingMessage | undefined,
492
+ resumeWake(sessionId: string,
493
+ /** 续跑首轮那段话连同框架位,由文本出处在铸点定好(HTTP `/wake` 正文 ⇒ `trusted: false`);语义属主 = `resume-legs.ts` 同名形参顶注。 */
494
+ message: PendingSteerInput | undefined, caller: string | undefined, req: IncomingMessage | undefined,
496
495
  /** [ref] 件 S-1:透传给 {@link DriveResumeArgs.acceptEarly}(200 受理语义)。HTTP `/wake` 腿传 `true`
497
496
  * —— 本腿走 `mintFreshRun`,受理体里的 `taskId` 因此是**新铸的**那个(壳的 poll 锚)。 */
498
497
  acceptEarly?: boolean,
@@ -521,7 +520,9 @@ export interface RouteLegs {
521
520
  explicitOperator: boolean;
522
521
  },
523
522
  /** [ref]:决断方看到的那道门(决断体的 `checkpointId`);不是当前门 ⇒ `409 approval_stale`(`approval_stale` 律,语义属主 = `resume-legs.ts` 的同名形参顶注)。 */
524
- sighting?: GateSighting): Promise<{
523
+ sighting?: GateSighting,
524
+ /** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参):盖在这一次 ctx 读上,存体预判按盖过的体判。 */
525
+ restatement?: ResumeRestatement): Promise<{
525
526
  readonly ok: false;
526
527
  readonly answer: {
527
528
  status: number;
@@ -539,9 +540,7 @@ export interface RouteLegs {
539
540
  acceptEarly?: boolean,
540
541
  /** [ref]:批准之后这条会话继续用的 permission mode(闭集 `PLAN_APPROVE_PERMISSION_MODES_AFTER`;只在把计划带出 plan 的决定
541
542
  * —— `approve` / `edit` —— 上有意义,缺席 ⇒ `"default"`)。语义与判据的唯一属主 = `resume-legs.ts` 的同名形参顶注。 */
542
- permissionModeAfter?: PlanApprovePermissionModeAfter,
543
- /** 续跑请求的重述键(同 {@link RouteLegs.resumeCheckpoint} 末参)。 */
544
- restatement?: ResumeRestatement): Promise<ResumeLegOutcome>;
543
+ permissionModeAfter?: PlanApprovePermissionModeAfter): Promise<ResumeLegOutcome>;
545
544
  /** 会话通知门(`POST /v1/sessions/:id/notify` 与 Runner 之外的后台子代完成共用的那一只;活流登记簿是本服务的,门随服务建一次)。 */
546
545
  sessionNotify: SessionNotifyDoor;
547
546
  }
@@ -693,7 +692,7 @@ interface RouteDeclIdentity {
693
692
  readonly methods: readonly RouteMethod[];
694
693
  /**
695
694
  * 「这条 GET 开的是一条**只读订阅**」—— 一条 SSE 读面(推送队列 / 账本 tail),它看着别人干活,自己不是活([ref])。
696
- * 在场 ⇒ 分派器不把它记进在飞(`drainState.inflight()`:排空等的、`/health` 报的、SIGHUP 空闲窗与附着租约读的那一只),只记进附着
695
+ * 在场 ⇒ 分派器不把它记进在飞(`http` 项:`/health.inflight` 报的总数与排空等的、SIGHUP 空闲窗与附着租约读的阻断集都从它起算),只记进附着
697
696
  * (`attachedStreams()`:壳还挂在这只引擎上);排空进入那一拍(以及硬停起点)由分派器发一帧 `draining` 终帧后关掉它
698
697
  * (`drainState.endSubscriptions`)。闭集 = 八条 GET SSE 读面,逐行理由见各行注;**唯一**一条「在飞腿的流」`POST /v1/tasks/stream`
699
698
  * 不带它 —— 那条流就是 sync 腿本身(关流 = 断连语义),照旧算在飞。漏标一条订阅的方向是**多算在飞**(排空多等),不是少等。
@@ -739,6 +738,24 @@ export interface ResumeLegOutcome {
739
738
  status: number;
740
739
  body: object;
741
740
  }
741
+ /**
742
+ * 「本会话不再询问」的请求 —— **两扇门同一只**:`/decide` 体上的 `remember:"session"`、应答口(`POST /v1/tool-approvals/:id/respond`)命中停驻行的
743
+ * `allow_session`。铸点只有一只:{@link RouteLegs.resumeCheckpoint} —— 可记与否从**已属主校验的载入停驻行**判(`standingAnswerDurablyRecordable`,
744
+ * 与运维队列行的 `rememberRefused` 同一只判据)、锚由车道定(任务级 = 这个会话;bg 停驻子代 = 行的 root/host 会话)、落豁免店**只在**这次决定
745
+ * 被证明已结清之后(`decisionCommittedOf`)、`rememberApplied` = 落没落(店抛 ⇒ `false` + warn,这次的放行不回滚)。门自己不写店、不判可记。
746
+ * 两口唯一的差 = `laneCannotRecord`(记不住的车道上怎么答;闭集与理由的属主 = `parked-decide.ts` 的 {@link RememberLaneCannotRecord})。
747
+ */
748
+ export interface RememberSessionRequest {
749
+ /** 豁免行的签发人(`grantedBy`)= 门已验的身份(`/decide` 的决断方 / 应答口的调用方);匿名开放部署 ⇒ `null`。 */
750
+ readonly grantedBy: string | null;
751
+ readonly laneCannotRecord: RememberLaneCannotRecord;
752
+ }
753
+ /** {@link RouteLegs.resumeCheckpoint} 的结局 = 腿的应答 + 带了「本会话放行」请求时铸点的答(`rememberApplied`:落没落)。键只在证得出提交的两条车道
754
+ * (bg 停驻子代赎回 / 任务级续跑)的结清点上铸;其余出口(拒 / workflow 投递 / 抛)键缺席 ⇒ 门读作「没记住」(`=== true`)。
755
+ * 这一位是进程内的结局位,不进 `body` —— 由门决定挂不挂到回执上(两扇门都只挂在这次真做了授予判定的回执上;幂等回放不挂)。 */
756
+ export type ResumeCheckpointOutcome = ResumeLegOutcome & {
757
+ readonly rememberApplied?: boolean;
758
+ };
742
759
  /**
743
760
  * **「决定/续跑已受理」那一枚 200 收据的单一铸点**([ref])。
744
761
  *
@@ -4,6 +4,7 @@ import { handleDiagnostics, DIAGNOSTICS_ROUTES } from "./routes/diagnostics.js";
4
4
  import { handleAdoption, ADOPTION_ROUTES } from "./routes/adoption.js";
5
5
  import { handleRetention, RETENTION_ROUTES } from "./routes/retention-ops.js";
6
6
  import { handleAdminDrain, ADMIN_DRAIN_ROUTES } from "./routes/admin-drain.js";
7
+ import { handleEngine, ENGINE_ROUTES } from "./routes/engine.js";
7
8
  import { handleDevices, DEVICES_ROUTES } from "./routes/devices.js";
8
9
  import { handleAdminConfigRefresh, ADMIN_CONFIG_REFRESH_ROUTES } from "./routes/admin-config-refresh.js";
9
10
  import { handleConfigCatalog, CONFIG_CATALOG_ROUTES } from "./routes/config-catalog.js";
@@ -18,6 +19,7 @@ import { handlePrincipalInbox, PRINCIPAL_INBOX_ROUTES } from "./routes/principal
18
19
  import { handleRules, RULES_ROUTES } from "./routes/rules.js";
19
20
  import { handleSessionsList, SESSIONS_LIST_ROUTES } from "./routes/sessions-list.js";
20
21
  import { handleAgentRoster, AGENT_ROSTER_ROUTES } from "./routes/agents-roster.js";
22
+ import { handleProjects, PROJECTS_ROUTES } from "./routes/projects.js";
21
23
  import { handleSessions, SESSIONS_ROUTES } from "./routes/sessions.js";
22
24
  import { handleSessionSync, SESSION_SYNC_ROUTES } from "./routes/session-sync.js";
23
25
  import { handleAttachments, ATTACHMENTS_ROUTES } from "./routes/attachments.js";
@@ -65,6 +67,7 @@ export const ROUTES = [
65
67
  row({ handler: handleAdoption, decls: ADOPTION_ROUTES, position: "post-credential", label: "adoption" }),
66
68
  row({ handler: handleRetention, decls: RETENTION_ROUTES, position: "post-credential", label: "retention" }),
67
69
  row({ handler: handleAdminDrain, decls: ADMIN_DRAIN_ROUTES, position: "post-credential", label: "admin-drain" }),
70
+ row({ handler: handleEngine, decls: ENGINE_ROUTES, position: "post-credential", label: "engine" }),
68
71
  row({ handler: handleDevices, decls: DEVICES_ROUTES, position: "post-credential", label: "devices" }),
69
72
  row({ handler: handleAdminConfigRefresh, decls: ADMIN_CONFIG_REFRESH_ROUTES, position: "post-credential", label: "admin-config-refresh" }),
70
73
  row({ handler: handleConfigCatalog, decls: CONFIG_CATALOG_ROUTES, position: "post-credential", label: "config-catalog" }),
@@ -79,6 +82,7 @@ export const ROUTES = [
79
82
  row({ handler: handlePrincipalInbox, decls: PRINCIPAL_INBOX_ROUTES, position: "post-credential", label: "principal-inbox" }),
80
83
  row({ handler: handleSessionsList, decls: SESSIONS_LIST_ROUTES, position: "post-credential", label: "sessions-list" }),
81
84
  row({ handler: handleAgentRoster, decls: AGENT_ROSTER_ROUTES, position: "post-credential", label: "agent-roster" }),
85
+ row({ handler: handleProjects, decls: PROJECTS_ROUTES, position: "post-credential", label: "projects" }),
82
86
  row({ handler: handleSessions, decls: SESSIONS_ROUTES, position: "post-credential", label: "sessions" }),
83
87
  row({ handler: handleSessionSync, decls: SESSION_SYNC_ROUTES, position: "post-credential", label: "session-sync" }),
84
88
  row({ handler: handleAttachments, decls: ATTACHMENTS_ROUTES, position: "post-credential", label: "attachments" }),
@@ -18,6 +18,11 @@
18
18
  * 一次落库,此后原样回放)。并发同参 POST 由 `adoption_log.from_principal` 的 UNIQUE 仲裁:恰一行落库,
19
19
  * 两条连接拿到同一个 adoptionId、同一份回执。
20
20
  *
21
+ * ── 第二条车道:源主体的批量导入 `POST /v1/adoption/:id/sessions` ─────────────────────────────────────────────
22
+ * 不是 operator 面:调用者是那条收编行的**源主体本人**(逐字;operator 不能代),把本地会话导进目的主体名下。门序 = 身份(401)→ 设施(501)→
23
+ * 行(404 `not_found.adoption`)→ 源主体(403 `auth.adoption_source_only`,不降级成 404:无行与不匹配同形是一种查不出根因的二义)→ 收编态
24
+ * (409 `adoption.not_adopted`)→ 体形(400)→ 条数帽(400)→ 逐元素(200 + 结局数组)。判断全在 `adoption/import.ts`,本模块只下发。
25
+ *
21
26
  * 分层:本模块不值 import `server.ts`(那条边闭合运行时装载环),只 `import type`。
22
27
  */
23
28
  import type { IncomingMessage, ServerResponse } from "node:http";
@@ -33,6 +38,12 @@ export declare const ADOPTION_ROUTES: readonly [{
33
38
  readonly pattern: RegExp;
34
39
  readonly label: "/v1/adoption/:id";
35
40
  readonly methods: readonly ["GET"];
41
+ }, {
42
+ readonly id: "adoption-sessions-import";
43
+ readonly pattern: RegExp;
44
+ readonly label: "/v1/adoption/:id/sessions";
45
+ readonly credentialGated: readonly ["POST"];
46
+ readonly methods: readonly ["POST"];
36
47
  }];
37
48
  /** 本域可分派行的 `id` 闭集 —— handler 的 `switch` 按它判穷尽(漏一口 = 编译红)。 */
38
49
  export type AdoptionRouteId = RouteIdsOf<typeof ADOPTION_ROUTES>;
@@ -1,6 +1,8 @@
1
1
  import { createAdoptionRunner } from "../../adoption/runner.js";
2
2
  import { AdoptionRequestSchema } from "../../adoption/wire.js";
3
3
  import { checkAdoptionPrincipalShape, checkAdoptionWidths } from "../../adoption/plan.js";
4
+ import { judgeAdoptionImportBinding, readAdoptionImportBody, runAdoptionImport } from "../../adoption/import.js";
5
+ import { limitRefusal } from "../../limit-refusal.js";
4
6
  import { sendJson, sendError } from "../send.js";
5
7
  import { gatedPrincipal, explicitOperatorOk, sendOperatorPrincipalsRequired, sendPrincipalRefusal } from "../principal-gate.js";
6
8
  import { assertNever } from "../route-ctx.js";
@@ -39,7 +41,21 @@ function sendOutcome(res, out) {
39
41
  function assertNoRejectCodeLeft(unhandled) {
40
42
  throw new Error(`adoption: unhandled reject code ${JSON.stringify(unhandled)} — the wire contract's closed set and this switch have drifted apart`);
41
43
  }
44
+ function sendAdoptionStoreRequired(res) {
45
+ sendError(res, 501, "capability.adoption_store_required", "adoption requires a SQL store backend (DB_BACKEND=mysql|pg)");
46
+ }
42
47
  export async function handleAdoption(req, res, match, ctx) {
48
+ switch (match.decl.id) {
49
+ case "adoption-submit":
50
+ case "adoption-detail":
51
+ return operatorLane(req, res, match.decl.id, match.params, ctx);
52
+ case "adoption-sessions-import":
53
+ return sourceLane(req, res, match.params, ctx);
54
+ default:
55
+ return assertNever(match.decl.id);
56
+ }
57
+ }
58
+ async function operatorLane(req, res, id, params, ctx) {
43
59
  const { deps } = ctx;
44
60
  const { readJson } = ctx.helpers;
45
61
  const principal = gatedPrincipal(req, deps.config);
@@ -59,7 +75,7 @@ export async function handleAdoption(req, res, match, ctx) {
59
75
  if (!fact.available) {
60
76
  switch (fact.why) {
61
77
  case "adoption_store_absent":
62
- sendError(res, 501, "capability.adoption_store_required", "adoption requires a SQL store backend (DB_BACKEND=mysql|pg)");
78
+ sendAdoptionStoreRequired(res);
63
79
  return;
64
80
  case "operator_principals_empty":
65
81
  sendOperatorPrincipalsRequired(res);
@@ -70,14 +86,14 @@ export async function handleAdoption(req, res, match, ctx) {
70
86
  }
71
87
  const store = fact.backend.adoptionLog();
72
88
  const runner = createAdoptionRunner({ store, dialect: deps.backend?.kind === "pg" ? "pg" : "mysql", now: Date.now, logger: deps.logger });
73
- switch (match.decl.id) {
89
+ switch (id) {
74
90
  case "adoption-detail": {
75
- const id = ctx.helpers.safeDecode(match.params.id);
76
- if (id === null) {
91
+ const adoptionId = ctx.helpers.safeDecode(params.id);
92
+ if (adoptionId === null) {
77
93
  sendError(res, 400, "request.id_invalid", "invalid adoption id");
78
94
  return;
79
95
  }
80
- const out = await runner.get(id);
96
+ const out = await runner.get(adoptionId);
81
97
  if (!out) {
82
98
  sendError(res, 404, "not_found.adoption", "adoption not found");
83
99
  return;
@@ -112,11 +128,69 @@ export async function handleAdoption(req, res, match, ctx) {
112
128
  return;
113
129
  }
114
130
  default:
115
- return assertNever(match.decl.id);
131
+ return assertNever(id);
132
+ }
133
+ }
134
+ async function sourceLane(req, res, params, ctx) {
135
+ const { deps } = ctx;
136
+ if (ctx.helpers.rateLimited(req, res))
137
+ return;
138
+ const principal = gatedPrincipal(req, deps.config);
139
+ if (principal === undefined) {
140
+ sendPrincipalRefusal(res, req, deps.config);
141
+ return;
142
+ }
143
+ const face = facts.adoptionSessionImport(deps);
144
+ if (!face.available) {
145
+ switch (face.why) {
146
+ case "adoption_store_absent":
147
+ sendAdoptionStoreRequired(res);
148
+ return;
149
+ case "session_import_staging_absent":
150
+ sendError(res, 501, "capability.session_store_required", "importing sessions requires a durable session store (DB_BACKEND=mysql|pg|local)");
151
+ return;
152
+ default:
153
+ return assertNever(face.why);
154
+ }
155
+ }
156
+ const adoptionId = ctx.helpers.safeDecode(params.id);
157
+ if (adoptionId === null) {
158
+ sendError(res, 400, "request.id_invalid", "invalid adoption id");
159
+ return;
160
+ }
161
+ const binding = judgeAdoptionImportBinding(await face.backend.adoptionLog().getById(adoptionId), principal);
162
+ switch (binding.kind) {
163
+ case "absent":
164
+ sendError(res, 404, "not_found.adoption", "adoption not found");
165
+ return;
166
+ case "not_source":
167
+ sendError(res, 403, "auth.adoption_source_only", "only this adoption's source principal may import sessions into it (verbatim; an operator cannot import on its behalf)");
168
+ return;
169
+ case "not_adopted":
170
+ sendError(res, 409, "adoption.not_adopted", "this adoption has not completed (it is still in flight, or it was rejected); sessions can be imported once the operator's adoption reaches status adopted");
171
+ return;
172
+ case "bound":
173
+ break;
174
+ default:
175
+ return assertNever(binding);
176
+ }
177
+ const sessions = readAdoptionImportBody(await ctx.helpers.readJson(req));
178
+ if (sessions === undefined) {
179
+ sendError(res, 400, "request.body_shape", "invalid import body — expected exactly {sessions: [...]} (the destination is the adoption's; the body cannot name one)");
180
+ return;
181
+ }
182
+ const cap = deps.config.adoptionImportMaxSessions;
183
+ if (sessions.length > cap) {
184
+ const refusal = limitRefusal("sessions", "entries", sessions.length, cap, { tail: "split the batch (the current cap is capabilities.adoptionImport.maxSessions), or have the operator raise ADOPTION_IMPORT_MAX_SESSIONS" });
185
+ sendError(res, 400, "request.field_invalid", refusal.message, refusal.facts);
186
+ return;
116
187
  }
188
+ const results = await runAdoptionImport({ adoptionId: binding.adoptionId, toPrincipal: binding.toPrincipal, maxSessionBytes: deps.config.adoptionImportMaxSessionBytes, sessionStorage: face.sessionStorage }, sessions);
189
+ sendJson(res, 200, { results });
117
190
  }
118
191
  export const ADOPTION_ROUTES = [
119
192
  { id: "adoption-submit", path: "/v1/adoption", credentialGated: ["POST"], methods: ["POST"] },
120
193
  { id: "adoption-detail", pattern: /^\/v1\/adoption\/(?<id>[^/]+)$/, label: "/v1/adoption/:id", methods: ["GET"] },
194
+ { id: "adoption-sessions-import", pattern: /^\/v1\/adoption\/(?<id>[^/]+)\/sessions$/, label: "/v1/adoption/:id/sessions", credentialGated: ["POST"], methods: ["POST"] },
121
195
  ];
122
196
  //# sourceMappingURL=adoption.js.map
@@ -20,6 +20,7 @@ const ROSTER_KEY_DISPOSITION = {
20
20
  parentSessionId: "strip",
21
21
  rootSessionId: "strip",
22
22
  usage: "strip",
23
+ requestedBy: "strip",
23
24
  };
24
25
  void ROSTER_KEY_DISPOSITION;
25
26
  export function rosterAgentId(row) {
@@ -3,7 +3,8 @@ import { skillCardFacts } from "../../approval-card.js";
3
3
  import { hostDecisionFacts, readDecider, retiredDecisionKeyFacts, DECIDED_BY_NOT_IN_PROOF } from "../../host-decision.js";
4
4
  import { sameExecutionRecord } from "@sema-agent/core";
5
5
  import { findParkedAgentForCheckpoint } from "../../parked-decide.js";
6
- import { DECIDED_REPLAY_SCAN_CAP, approvalPayloadFingerprint } from "../../plugins/checkpoint-store-sql.js";
6
+ import { DECIDED_REPLAY_SCAN_CAP } from "../../plugins/checkpoint-store-face.js";
7
+ import { approvalPayloadFingerprint } from "../../plugins/approval-payload-fingerprint.js";
7
8
  import { carriesDeploymentListQuestion, standingAnswerDurablyRecordable } from "../../tool-approval.js";
8
9
  import { APPROVAL_GATE_KINDS } from "../../approval-content-kind.js";
9
10
  import { isParkedRunStatus } from "../../plugins/store-contracts.js";
@@ -31,7 +32,7 @@ import { recordFailOpen } from "../../observability/fail-open.js";
31
32
  import { MAX_CHECKPOINT_ID_CHARS, durableRowIdentity } from "../../checkpoint-identity.js";
32
33
  import { MAX_KEY_ECHO, keyClosureClause, scanKeyClosure } from "../../request-key-closure.js";
33
34
  import { fieldConflictFacts } from "../../field-conflict.js";
34
- import { buildSettlementEvidence, decisionCommittedOf } from "../../gate-settlement.js";
35
+ import { buildSettlementEvidence } from "../../gate-settlement.js";
35
36
  import { seatText } from "../../trace/exit-seat.js";
36
37
  import { approvalQueueKindOfDoorId } from "../../approval-queue-kind.js";
37
38
  import { defaultPeerInboundFace, parsePeerInboundId, peerBoxScope } from "../../peer-inbound-face.js";
@@ -700,7 +701,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
700
701
  sendError(res, 404, "not_found.run", "task not found");
701
702
  return;
702
703
  }
703
- const plan = await preparePlanReview(run.sessionId, { taskId, principalPresent: principal !== undefined }, { principal: deciderPrincipal, explicitOperator }, sighting);
704
+ const plan = await preparePlanReview(run.sessionId, { taskId, principalPresent: principal !== undefined }, { principal: deciderPrincipal, explicitOperator }, sighting, restated.restatement);
704
705
  if (!plan.ok) {
705
706
  sendResumeOutcome(res, plan.answer, deps.logger);
706
707
  return;
@@ -724,7 +725,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
724
725
  return;
725
726
  }
726
727
  }
727
- const out = await drivePlanReview(plan.prepared, decision, decision === "edit" ? body.editedPlan : undefined, typeof body.reason === "string" ? body.reason : undefined, hostDecisionFacts(decidedByReading.decider, deciderPrincipal), req, true, isPlanApprovePermissionModeAfter(body.permissionModeAfter) ? body.permissionModeAfter : undefined, restated.restatement);
728
+ const out = await drivePlanReview(plan.prepared, decision, decision === "edit" ? body.editedPlan : undefined, typeof body.reason === "string" ? body.reason : undefined, hostDecisionFacts(decidedByReading.decider, deciderPrincipal), req, true, isPlanApprovePermissionModeAfter(body.permissionModeAfter) ? body.permissionModeAfter : undefined);
728
729
  sendResumeOutcome(res, out, deps.logger);
729
730
  return;
730
731
  }
@@ -892,27 +893,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
892
893
  return;
893
894
  }
894
895
  }
895
- let rememberApplied = false;
896
- let pendingGrant;
897
- const grantOnCommit = remember && deps.approvalExemptionStore
898
- ? async (grant) => {
899
- const canonical = grant.rememberableToolName;
900
- if (!canonical)
901
- return;
902
- pendingGrant = { sessionId: grant.overrideSessionId ?? sessionId, toolName: canonical };
903
- }
904
- : undefined;
905
- const out = await resumeCheckpoint(sessionId, decision, body.reason ?? undefined, hostDecisionFacts(decider, deciderPrincipal), req, answer, binding, grantOnCommit, true, { principal: deciderPrincipal, explicitOperator }, restated.restatement);
906
- if (pendingGrant !== undefined && decisionCommittedOf(out) && deps.approvalExemptionStore) {
907
- try {
908
- await deps.approvalExemptionStore.grant(pendingGrant.sessionId, pendingGrant.toolName, deciderPrincipal ?? null);
909
- rememberApplied = true;
910
- deps.logger?.info?.("approval_exemption_granted", { sessionId: pendingGrant.sessionId, toolName: pendingGrant.toolName, grantedBy: deciderPrincipal ?? null });
911
- }
912
- catch (e) {
913
- deps.logger?.warn?.("approval_exemption_grant_failed", { sessionId: pendingGrant.sessionId, toolName: pendingGrant.toolName, error: String(e).slice(0, 200) });
914
- }
915
- }
896
+ const out = await resumeCheckpoint(sessionId, decision, body.reason ?? undefined, hostDecisionFacts(decider, deciderPrincipal), req, answer, binding, remember ? { grantedBy: deciderPrincipal ?? null, laneCannotRecord: "refuse" } : undefined, true, { principal: deciderPrincipal, explicitOperator }, restated.restatement);
916
897
  const replay = await decideIdempotentReplay(cs, {
917
898
  sessionId,
918
899
  out,
@@ -932,7 +913,7 @@ export async function handleApprovalsAssistant(req, res, match, ctx) {
932
913
  sendResumeOutcome(res, replay, deps.logger);
933
914
  return;
934
915
  }
935
- sendResumeOutcome(res, out, deps.logger, remember && deps.approvalExemptionStore ? { rememberApplied } : undefined);
916
+ sendResumeOutcome(res, out, deps.logger, remember ? { rememberApplied: out.rememberApplied === true } : undefined);
936
917
  return;
937
918
  }
938
919
  }
@@ -23,6 +23,7 @@ const ROW_KEY_DISPOSITION = {
23
23
  toolUseId: "strip",
24
24
  updatedAt: "strip",
25
25
  sessionId: "keep",
26
+ requestedBy: "strip",
26
27
  };
27
28
  void ROW_KEY_DISPOSITION;
28
29
  function projectRow(r) {
@@ -25,6 +25,7 @@ import { projectWriteProtectionCapability } from "../../write-protection.js";
25
25
  import { projectStoreCapability } from "../../store-posture.js";
26
26
  import { projectWebSearchCapability } from "../../plugins/web-search.js";
27
27
  import { projectExecutionLaneCapability } from "../../capabilities/execution-lane.js";
28
+ import { SETTINGS_CONTRACT_CAPABILITY } from "../../capabilities/settings-contract.js";
28
29
  import { judgeSandboxGitPlane, sandboxGitPlanePremisesOf } from "../../sandbox-git-plane.js";
29
30
  import { MCP_ASSERTION_HEADER_SENT, MCP_REQUEST_TRANSPORT_KINDS } from "../../mcp-assertion-header.js";
30
31
  import { gateCompositeMembers } from "../../capabilities/composite-members.js";
@@ -35,6 +36,7 @@ import * as facts from "../../capability-facts.js";
35
36
  import { judgeAutoModeArming } from "../../auto-mode-face.js";
36
37
  import { coercePermissionModeStrict, PERMISSION_MODE_WORDS, taskHooksHonored } from "../../task-settings.js";
37
38
  import { gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
39
+ import { readAdoptionImportCapability } from "../../adoption/import.js";
38
40
  import { headReadOf } from "../../session-incarnation.js";
39
41
  import { callerTrust } from "../caller-trust.js";
40
42
  import { sessionRulesNamespaceFormsHonored } from "../../session-policy-wire.js";
@@ -95,10 +97,10 @@ export async function handleCapabilities(req, res, match, ctx) {
95
97
  ? {
96
98
  enabled: true,
97
99
  protocolVersion: DEVICE_PROTOCOL_VERSION,
98
- maxInflightPerDevice: deps.config.remoteExec?.provider === "device" ? (deps.config.remoteExec.maxInflightPerDevice ?? 4) : 4,
100
+ maxInflightPerDevice: deps.config.remoteExec.provider === "device" ? (deps.config.remoteExec.maxInflightPerDevice ?? 4) : 4,
99
101
  wsPath: DEVICE_WS_PATH,
100
102
  management: facts.deviceManagement(deps).available,
101
- ...(deps.config.remoteExec?.provider === "device" && deps.config.remoteExec.relay.kind === "url" ? { relayUrl: deps.config.remoteExec.relay.url } : {}),
103
+ ...(deps.config.remoteExec.provider === "device" && deps.config.remoteExec.relay.kind === "url" ? { relayUrl: deps.config.remoteExec.relay.url } : {}),
102
104
  }
103
105
  : false,
104
106
  sessionEvents: facts.sessionEventStream(deps).available,
@@ -121,6 +123,7 @@ export async function handleCapabilities(req, res, match, ctx) {
121
123
  sharedMemory: facts.sharedMemoryRead(deps).available,
122
124
  principalInboxDelivery: facts.principalInboxDelivery(deps).available,
123
125
  adoption: facts.adoption(deps).available,
126
+ adoptionImport: await readAdoptionImportCapability(facts.adoptionSessionImport(deps), gatedPrincipal(req, deps.config), deps.config),
124
127
  memoryBundle: facts.memoryBundle(deps).available,
125
128
  memoryCompliance: facts.memoryCompliance(deps).available,
126
129
  memoryOrigin: facts.memoryOrigin(deps).available,
@@ -147,8 +150,9 @@ export async function handleCapabilities(req, res, match, ctx) {
147
150
  scratchpadDir: true,
148
151
  subagentSteer: facts.subagentSteer(deps).available,
149
152
  subagentResume: facts.subagentSteer(deps).available,
150
- taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), httpHookAllowlists: taskHooksHonored(deps.config), tightenOnlySeats: true, approvalFrameFamilies: true },
153
+ taskSettings: { permissions: true, permissionMode: true, model: true, outputStyle: true, env: DEPLOYMENT_SHAPE_PREDICATES.callerCwd.holds(deps.config), hooks: taskHooksHonored(deps.config), pluginHooks: taskHooksHonored(deps.config), managedHookGroups: taskHooksHonored(deps.config), httpHookAllowlists: taskHooksHonored(deps.config), tightenOnlySeats: true, approvalFrameFamilies: true, autoCompactEnabled: true },
151
154
  settings: { permissions: { allowGrant: true, allowLayer: true, layers: true, layeredAllow: true, callerTrust: callerTrust(req, deps.config).trust } },
155
+ settingsContract: SETTINGS_CONTRACT_CAPABILITY,
152
156
  permissionModeAuto: {
153
157
  accepted: true,
154
158
  classifierSeat: deps.autoModeFace?.seatMounted === true,
@@ -187,6 +191,7 @@ export async function handleCapabilities(req, res, match, ctx) {
187
191
  mcpProbe: true,
188
192
  mcpAssertionHeaderSent: MCP_ASSERTION_HEADER_SENT,
189
193
  mcpTransportKinds: [...MCP_REQUEST_TRANSPORT_KINDS],
194
+ engine: { handover: facts.engineHandover(deps).available },
190
195
  mcpElicitation: facts.elicitation(deps).available,
191
196
  askUserQuestion: facts.askUserQuestion(deps).available,
192
197
  toolApproval: facts.toolApproval(deps).available,
@@ -201,6 +206,7 @@ export async function handleCapabilities(req, res, match, ctx) {
201
206
  sessionReadRedaction: true,
202
207
  sideQuery: true,
203
208
  agentRoster: facts.agentRoster(deps).available,
209
+ projects: facts.projectRegistry(deps).available,
204
210
  retention: retentionAdvertisement(deps.config),
205
211
  peerLane: Boolean(deps.peerDirectory),
206
212
  sessionList: facts.sessionList(deps).available,
@@ -214,6 +220,8 @@ export async function handleCapabilities(req, res, match, ctx) {
214
220
  rewindFiles: Boolean(deps.fileHistoryStore),
215
221
  restoreFiles: Boolean(deps.fileHistoryStore),
216
222
  rewindFilesTo: Boolean(deps.fileHistoryStore && deps.resumeAnchorStore && headReadOf(deps.sessionStorage)),
223
+ sessionRewindFiles: facts.sessionRewindFiles(deps).available,
224
+ sessionRewindFilesPreview: facts.sessionRewindFilesPreview(deps).available,
217
225
  fileHistoryCapture: fileHistoryCaptureOf(deps.fileHistoryStore, deps.config.fileHistoryCapture),
218
226
  scheduler: facts.hostScheduler(deps.config).available,
219
227
  sessionSync: facts.sessionSync(deps).available,
@@ -295,6 +303,7 @@ export async function handleCapabilities(req, res, match, ctx) {
295
303
  ...(m.maxTokens ? { maxOutputTokens: m.maxTokens } : {}),
296
304
  ...((levels) => (levels !== undefined ? { supportedEffortLevels: [...levels] } : {}))(reasoningEffortLevelsOf(m)),
297
305
  ...(m.compat !== undefined ? { compat: m.compat } : {}),
306
+ ...(m.thinkingLevelMap !== undefined ? { thinkingLevelMap: m.thinkingLevelMap } : {}),
298
307
  ...mentionBit(name),
299
308
  routePairing: routePairingOf(deps, name, m),
300
309
  }));
@@ -163,7 +163,7 @@ export async function handleDevices(req, res, match, ctx) {
163
163
  }
164
164
  if ((await readClosedBody(req, res, readJson, [])) === null)
165
165
  return;
166
- const ttlSeconds = (deps.config.remoteExec?.provider === "device" ? deps.config.remoteExec.enrollTokenTtlSec : undefined) ?? DEFAULT_ENROLL_TOKEN_TTL_SEC;
166
+ const ttlSeconds = (deps.config.remoteExec.provider === "device" ? deps.config.remoteExec.enrollTokenTtlSec : undefined) ?? DEFAULT_ENROLL_TOKEN_TTL_SEC;
167
167
  const issued = await enrollment.issueEnrollToken({ target: domain, createdBy: domain.subject, ttlSeconds });
168
168
  if (!issued.ok) {
169
169
  sendDeviceRejection(res, issued.reject);
@@ -13,6 +13,7 @@ import { type PostureKnobReading, type PostureSource } from "../../posture-sourc
13
13
  import type { IncomingMessage, ServerResponse } from "node:http";
14
14
  import type { WiringManifest } from "@sema-agent/core";
15
15
  import { type StreamApprovalGate, type StreamApprovalGateInput } from "../../tool-approval.js";
16
+ import { verifiedIdentitySource } from "../principal-gate.js";
16
17
  import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
17
18
  /** 流内审批门的读数形:上场即 `"active"`,否则是那**四**个合取项里**第一个**不满足的原因词
18
19
  * (与 `resolveStreamApprovalGate` 同一闭集,词表**取型**自它 ⇒ 增删 reason 在此处自动跟随/编译红;
@@ -82,23 +83,17 @@ export declare function assertStaticWiringConsistent(facts: StaticWiringFacts, l
82
83
  warn: (msg: string, meta?: Record<string, unknown>) => void;
83
84
  } | undefined): StaticWiringAudit;
84
85
  /**
85
- * [ref]③ clay 裁 (b)(2026-08-12,core [ref]④ + cli [ref]① 双背书):**零凭证 turnkey 形**的
86
- * loopback 来源门判据(单一属主,端点与测试同吃)。
86
+ * 诊断面的**远程来源门**(单一属主,端点与测试同吃;[ref]③ clay 裁 (b) 的那只门,7.63.0 起按身份判):远程请求后面没有
87
+ * **验过的身份**(`verifiedIdentitySource`:service 凭据 / 鉴权桥登录令牌 / 直连门签名令牌)⇒ 拒;本机(loopback)照读。
87
88
  *
88
- * 只在「operator 名单空 ∧ 非多租户 ∧ 全局 service-credential 门也不在场(没配 SERVICE_AUTH_TOKEN /
89
- * AUTH_TOKENS)」的部署形上判——那正是全局门整个不设、诊断端点此前无认证可读的形。诊断面泄的是装配
90
- * 拓扑(store 接线/能力位/治理姿态),对误暴露公网端口的 turnkey 机器构成侦察面。(b) 对本机自用零摩擦
91
- * (壳缺省钉 BIND_HOST=127.0.0.1,local curl 照常),对远程侦察 fail-closed;配了 token 的部署远程读
92
- * 走认证(全局门),不进本臂。
89
+ * 名单里的名字、单用户声明放进来的「每个调用方」,都只在这次请求带可验身份时才是身份 —— 没有凭据可验的部署上,主体头是谁都能写的
90
+ * 字符串,端口误暴露到公网就是侦察面(装配拓扑 / 治理姿态 / 写保护名表)。配了 service 凭据的部署上,到得了这里的请求都过了全局凭据门、
91
+ * 必然带着验过的身份,本判不咬;不要求静态凭据在场(鉴权桥的登录令牌就是身份)。
93
92
  *
94
- * 判源=TCP 对端地址(`req.socket.remoteAddress`),**非任何头**——XFF 类头在无反代的 turnkey 形上本就
95
- * 是自造面;有反代的部署必然配 token(反代后 remoteAddress 恒 loopback,门自然放行,语义仍对:该形的
96
- * 边界由反代+token 承担)。`remoteAddress` 缺席(socket 已断等边缘)⇒ 判拒(fail-closed,安全轴方向)。
93
+ * 判源 = TCP 对端地址(`req.socket.remoteAddress`),**非任何头**(XFF 类头在无反代形上是自造面;有反代的部署必然配凭据)。
94
+ * `remoteAddress` 缺席(socket 已断等边缘)⇒ 判拒(fail-closed)。
97
95
  */
98
- export declare function zeroCredentialLoopbackDenied(remoteAddress: string | undefined, config: {
99
- authToken?: string;
100
- authTokens?: Record<string, string>;
101
- }): boolean;
96
+ export declare function remoteWithoutVerifiedIdentity(req: IncomingMessage, config: Parameters<typeof verifiedIdentitySource>[1]): boolean;
102
97
  export declare function handleDiagnostics(req: IncomingMessage, res: ServerResponse, match: RouteMatch<DiagnosticsRouteId>, ctx: RouteCtx): Promise<void>;
103
98
  export declare const DIAGNOSTICS_ROUTES: readonly [{
104
99
  readonly id: "diagnostics-wiring";
@@ -95,32 +95,22 @@ export function assertStaticWiringConsistent(facts, logger) {
95
95
  }
96
96
  return audit;
97
97
  }
98
- export function zeroCredentialLoopbackDenied(remoteAddress, config) {
99
- const anyServiceAuth = Boolean(config.authToken) || Object.keys(config.authTokens ?? {}).length > 0;
100
- if (anyServiceAuth)
101
- return false;
102
- return !isLoopbackAddress(remoteAddress);
98
+ export function remoteWithoutVerifiedIdentity(req, config) {
99
+ return !isLoopbackAddress(req.socket.remoteAddress) && verifiedIdentitySource(req, config) === undefined;
103
100
  }
104
101
  export async function handleDiagnostics(req, res, match, ctx) {
105
102
  const { deps } = ctx;
106
103
  switch (match.decl.id) {
107
104
  case "diagnostics-wiring": {
108
- if (deps.config.operatorPrincipals.length > 0 || deps.config.requirePrincipal) {
109
- if (!facts.operatorLane(deps).available) {
110
- sendOperatorPrincipalsRequired(res);
111
- return;
112
- }
113
- const principal = gatedPrincipal(req, deps.config);
114
- if (!explicitOperatorOk(principal, deps.config)) {
115
- sendError(res, 403, "auth.operator_only", "wiring diagnostics are operator-only on a multi-tenant worker");
116
- return;
117
- }
118
- if (!isLoopbackAddress(req.socket.remoteAddress) && verifiedIdentitySource(req, deps.config) === undefined) {
119
- sendError(res, 403, "auth.loopback_only", "wiring diagnostics on a zero-credential deployment are readable from loopback only — configure SERVICE_AUTH_TOKEN to read remotely");
120
- return;
121
- }
105
+ if (!facts.operatorLane(deps).available) {
106
+ sendOperatorPrincipalsRequired(res);
107
+ return;
108
+ }
109
+ if (!explicitOperatorOk(gatedPrincipal(req, deps.config), deps.config)) {
110
+ sendError(res, 403, "auth.operator_only", "wiring diagnostics are operator-only");
111
+ return;
122
112
  }
123
- else if (zeroCredentialLoopbackDenied(req.socket.remoteAddress, deps.config)) {
113
+ if (remoteWithoutVerifiedIdentity(req, deps.config)) {
124
114
  sendError(res, 403, "auth.loopback_only", "wiring diagnostics on a zero-credential deployment are readable from loopback only — configure SERVICE_AUTH_TOKEN to read remotely");
125
115
  return;
126
116
  }