@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
@@ -195,6 +195,13 @@ export declare function skillListingBudgetFractionOk(v: unknown): v is number;
195
195
  /** {@link skillListingBudgetFractionOk} 的孪生(`int().positive()`;`isSafeInteger` 而不是 `isInteger` 的
196
196
  * 理由见那里)。 */
197
197
  export declare function skillListingMaxDescOk(v: unknown): v is number;
198
+ /**
199
+ * `settings.autoCompactEnabled`(CC 2.1.309 settings 同名键,`cli309.js:252692` 的 settings 声明:布尔,「上下文装满时自动压缩对话」)的值域判据 —— **只收布尔**。
200
+ * 与上面两只谓词同姿势:FRESH 提交面的 400 门(`http/admission.ts`)问「合不合法」,RESUME 宽容层({@link parseTaskSettings})问「收不收下」,
201
+ * 这两句话是同一个问题的正反面,只写在这一处(`"false"` / `0` / `null` 这类假值形都不是布尔:不读成「开」也不读成「关」)。
202
+ * server 侧零加工:`true` / `false` 逐字交给引擎的自动压缩座 `TaskSpec.compaction.autoCompact`(`spec-fields.ts` 的 `compactionSpecFragment`),缺席 ⇒ 整键不写,默认值的属主是引擎。
203
+ */
204
+ export declare function autoCompactEnabledOk(v: unknown): v is boolean;
198
205
  /** The validated, service-trusted subset of `SemaSettings` we project onto the spec. `env` is parsed only to REPORT
199
206
  * it as received-but-deferred when off the host lane (never silently dropped); a MALFORMED `hooks` likewise reports
200
207
  * deferred (submit 路径另有 400 fail-loud),valid `hooks` 进 applied shape(hook-runner 阶段一)。 */
@@ -233,7 +240,7 @@ export interface ParsedTaskSettings {
233
240
  ultracode?: boolean;
234
241
  /** hooks hook-runner(阶段一):经 `parseHooksConfig`(契约包分类器 + 服务侧上限 + 本仓会跑的条目类型)判过的 hooks 配置。像 shellEnv 一样
235
242
  * 这里只 PARSE;应用点(main.ts resolveSpec)按单用户闸(`requirePrincipal !== true`)决定翻不翻成
236
- * 任务座 `TaskSpec.mods` 上的一张注册 `settings.hooks`——多租户 lane 收到只警告忽略(hook 命令跑在 worker host = class ② 能力授予)。 */
243
+ * 任务座 `TaskSpec.mods` 上的车道注册(非托管 `settings.hooks`,有托管组时另一张 `settings.hooks.managed`)——多租户 lane 收到只警告忽略(hook 命令跑在 worker host = class ② 能力授予)。 */
237
244
  hooks?: RunnableHooksConfig;
238
245
  /** [ref](7.77.0)—— CC settings 同名键:上下文窗口里**留给技能清单**的比例((0,1];CC 默认 0.01 = 1%)。
239
246
  * 超预算时引擎把描述裁短、再不够退成 name-only(`cli259.js` 的清单渲染算法),**从不**拒掉一条技能 ——
@@ -242,6 +249,10 @@ export interface ParsedTaskSettings {
242
249
  skillListingBudgetFraction?: number;
243
250
  /** 同族第二键:每条技能描述在清单里的字符帽(正整数;CC 默认 1536)。超出由引擎**截断**,不是拒。 */
244
251
  skillListingMaxDescChars?: number;
252
+ /** `settings.autoCompactEnabled`(CC 2.1.309 settings 同名键,布尔):这条 run 的自动压缩开关。逐字交给引擎的自动压缩座 `TaskSpec.compaction.autoCompact`
253
+ * (写点 = `boot/resolve-spec.ts` 经 `spec-fields.ts` 的 `compactionSpecFragment`,与顶层 `compaction.clampTolerance` 同一只映射)。
254
+ * `false` 是有意义的值(不是「没设」),所以 {@link parseTaskSettings} 把它收下、`settings` 因它在场。缺席 ⇒ 整键不写。 */
255
+ autoCompactEnabled?: boolean;
245
256
  /** [ref] —— 「只收紧」座位族(`tighten-only-seats.ts` 的四座:读拒模式 / 写保护名的加法 / 合规额外禁项 / 永不自动放行名单)的归一值,**一个键**而不是四个散字段:
246
257
  * wire 位置由座位表说(三座在 `settings` 顶层,`neverAuto` 在 `settings.permissions`),解析后与位置无关。空数组 ≡ 缺席(不铸键)。
247
258
  * 去处:三座经 {@link applyTaskSettings} 落 core 任务层席;`neverAuto` 经 {@link deriveSettingsPolicy} 落请求叶策略。 */
@@ -263,9 +274,11 @@ export interface ParseTaskSettingsResult {
263
274
  readonly stripped: readonly string[];
264
275
  };
265
276
  }
266
- /** `parseTaskSettings` 的可选座:续跑重放腿才有的重读座(一次性迁移 M20;新提交腿与不问 hooks 的读者不递)。 */
277
+ /** `parseTaskSettings` 的可选座:续跑重放腿才有的重读座(一次性迁移 M20;新提交腿与不问 hooks 的读者不递)与调用方已读(并已判)的 `settings.env` 那一份。 */
267
278
  export interface ParseTaskSettingsSeats {
268
279
  readonly storedHooksReread?: StoredHooksRereadM20;
280
+ /** {@link readSettingsEnv} 的一次读数(`resolveSpec` 两腿恒递:凭据判据判的就是这一份,解析层不再读第二次;续跑腿 M38 剥过键的是剥后那一份)。缺席 ⇒ 解析层自己读一次(不交子进程的读者)。 */
281
+ readonly settingsEnv?: SettingsEnvLayer;
269
282
  }
270
283
  /** Cap on `outputStyle` length — it lands in the system prompt, so it shares the `MAX_SYSTEM_PROMPT_CHARS` (16384)
271
284
  * posture (an uncapped prompt body is a per-turn token-cost hole; cross review). Exported so the HTTP layer
@@ -275,6 +288,42 @@ export declare const MAX_SETTINGS_OUTPUT_STYLE_CHARS = 16384;
275
288
  export declare const MAX_SETTINGS_ENV_VARS = 256;
276
289
  export declare const MAX_SETTINGS_ENV_VALUE_CHARS = 32768;
277
290
  export declare const MAX_SETTINGS_ENV_KEY_CHARS = 256;
291
+ /** 一条 `settings.env` 条目被判成凭据的根据(闭集;wire 字段 `entries[].match` 的全部词):`name` = 名字是本进程的凭据变量名;`value_shape` = 值是秘密形。两者都中按 `name` 报。 */
292
+ export declare const SETTINGS_ENV_CREDENTIAL_MATCHES: readonly ["name", "value_shape"];
293
+ export type SettingsEnvCredentialMatch = (typeof SETTINGS_ENV_CREDENTIAL_MATCHES)[number];
294
+ /** 拒体的机读位(原样进 wire 错误体 / `HttpError.extra`):`field` 恒为 `settings.env`;`entries` 按体内序列出每一条命中,键名过调用方串的唯一回显口径,值从不进来。 */
295
+ export interface SettingsEnvCredentialFields {
296
+ readonly field: "settings.env";
297
+ readonly entries: readonly {
298
+ readonly key: string;
299
+ readonly match: SettingsEnvCredentialMatch;
300
+ }[];
301
+ }
302
+ /** 一次裁决的产物:wire 文案 + 机读位 + 命中条目的**原键**(`keys`:不出门,只给续跑腿的一次性迁移按键剥)。 */
303
+ export interface SettingsEnvCredentialIssue {
304
+ readonly message: string;
305
+ readonly fields: SettingsEnvCredentialFields;
306
+ readonly keys: readonly string[];
307
+ }
308
+ /** `settings.env` 的一次读数:`sent` = 调用方送了这个键(不是缺席 / `null`);`reaching` = 会交到子进程的那几条({@link cleanEnvMap};形不对 / 没有一条够格 ⇒ `undefined`;一次性迁移 M38 剥空的是 `{}`,见 {@link withoutKeys})。 */
309
+ export interface SettingsEnvLayer {
310
+ readonly sent: boolean;
311
+ readonly reaching: Readonly<Record<string, string>> | undefined;
312
+ /** 送来的值里有读者不交出去的东西({@link settingsEnvUnreadable}:不是对象 / 过帽 / 有成员读不出;空记录不算)—— 解析层据它报 `deferred: ["env"]`。 */
313
+ readonly unreadable: boolean;
314
+ }
315
+ /** `settings.env` 的**唯一**读法:`settings` 不是对象 ⇒ 没送;否则 `env` 只取一次,形判与收取都对这一次的值做。判据、解析层与续跑腿的剥键都吃这一份。 */
316
+ export declare function readSettingsEnv(settings: unknown): SettingsEnvLayer;
317
+ /**
318
+ * `settings.env` 里凭据条目的**唯一**判据(纯函数;律见上方段头)。`reaching` = {@link readSettingsEnv} 读出的那一份(会交到子进程的条目;非串值、超帽的键 / 值本来就到不了子进程;
319
+ * 缺席 / 形不对 ⇒ `undefined` ⇒ 不判,形归受理门的形判)。`credentialNames` = 本进程的凭据变量名(调用方递 `serverCredentialValueSources(config.modelApiKeyEnv)`)。没有命中 ⇒ `null`。
320
+ */
321
+ export declare function settingsEnvCredentialIssue(reaching: Readonly<Record<string, string>> | undefined, credentialNames: readonly string[]): SettingsEnvCredentialIssue | null;
322
+ /**
323
+ * 一次性迁移 M38(窗口见 `plugins/one-time-migrations.ts` 登记表):从读到的那一份里去掉判据点名的原键,交回剥后的一份。**剥空 = 空表**(调用方送了这一块,剥完什么都不剩):
324
+ * 解析层把它当作这次请求的环境层原样交出,`resolveSpec` 登记它 —— 覆盖这条会话上一条登记;若读成「缺席」,会话注册表按「缺席 = 留着上一条」把上一条(可能正是被剥的那个名字)留给 shell。
325
+ */
326
+ export declare function withoutKeys(layer: SettingsEnvLayer, keys: readonly string[]): SettingsEnvLayer;
278
327
  /** 三桶(闭集;判据按此序逐桶判)。 */
279
328
  export declare const SETTINGS_PERMISSION_BUCKETS: readonly ["allow", "deny", "ask"];
280
329
  export type SettingsPermissionBucket = (typeof SETTINGS_PERMISSION_BUCKETS)[number];
@@ -305,27 +354,35 @@ export interface SettingsPermissionBucketIssue {
305
354
  */
306
355
  export declare function settingsPermissionBucketIssue(perms: unknown): SettingsPermissionBucketIssue | null;
307
356
  /** 本 service 真正**消费**的 `settings` 顶层键 —— 闭集。每一个都有消费点:
308
- * `env`/`hooks`/`model`/`outputStyle`/`permissions`/`ultracode` 与两个 `skillListing*` 在
357
+ * `autoCompactEnabled`/`env`/`hooks`/`model`/`outputStyle`/`permissions`/`ultracode` 与两个 `skillListing*` 在
309
358
  * {@link parseTaskSettings};`webSearch` 在 `capabilities/scenarios.ts`(判决 `judgeRequestWebSearch`,单用户闸;形错在受理面 400,[ref])。
310
359
  * 加键必须同时加消费点,否则就是往闭集里塞一个新的静默丢。
311
360
  *
312
361
  * 🔴 `readDenyPatterns` / `writeProtectedExtra` / `complianceAdditionalDenies` 与 `permissions.neverAuto`([ref])= **「只收紧」座位族**:消费点 = `tighten-only-seats.ts`
313
362
  * 的座位表(位置、条目律、去处都由那张表说),读入在 {@link parseTaskSettings},投影在 {@link applyTaskSettings} / {@link deriveSettingsPolicy}。这四个键不是 CC settings 键
314
- * (sdk 的 `SemaSettings` 尚未声明 —— 对账门 `test/task-settings-sdk-key-parity.test.ts` 的「server 先于 sdk」登记表记着它们)。
363
+ * (sdk 的 `SemaSettings` 已声明这四个键 —— 对账门 `test/task-settings-sdk-key-parity.test.ts` 逐键咬 server 与 sdk 两面一致)。
315
364
  *
316
365
  * 🔴 `approvalFrameFamilies`([ref])= 这条 run 的客户端**声明**渲染得了哪些审批开卡帧族 —— 不进引擎,不是 CC settings 键。消费点 = 三条执行腿的审批装配
317
366
  * (`tool-approval.ts` 的唯一读者 `declaredApprovalFrameFamilies` → `resolveApprovalLeg`),判官 `approvalFrameFamiliesIssue`(fresh 受理 400 与宽容读者同一只)。
318
- * `parseTaskSettings` 刻意不读它(它管的是落到 `TaskSpec` 的设置)。sdk 型面待声明(对账门的「server 先于 sdk」登记表记着)。
367
+ * `parseTaskSettings` 刻意不读它(它管的是落到 `TaskSpec` 的设置)。sdk 型面已声明(同一只对账门咬)。
319
368
  *
320
369
  * 🔴 两个 `skillListing*`([ref],7.77.0)= **CC settings 同名键**,值域抄 CC 的 schema 声明
321
370
  * (`skillListingBudgetFraction` 是 `gt(0).lte(1)`、`skillListingMaxDescChars` 是 `int().positive()`);
322
371
  * 消费点 = 本文件的 parse + `boot/resolve-spec.ts` 的 `TaskSpec` 透传。语义(预算怎么花、描述怎么裁、
323
372
  * 溢出怎么退成 name-only)整个归引擎,本仓一个字节都不渲染,也**不复刻默认值**——缺席即整键不写。
324
373
  *
374
+ * 🔴 `autoCompactEnabled` = **CC settings 同名键**(2.1.309 的 settings 声明,布尔):这条 run 的自动压缩开关,值域只收布尔({@link autoCompactEnabledOk},两层同问这一只);
375
+ * 消费点 = 本文件的 parse + `boot/resolve-spec.ts` 经 `spec-fields.ts` 的 `compactionSpecFragment` 逐字交给引擎的自动压缩座 `TaskSpec.compaction.autoCompact`(与顶层 `compaction.clampTolerance` 同一只映射、同一个对象)。
376
+ * 关掉的是引擎**自起**的三条道(窗阈值那一遍、prompt-too-long 恢复那一遍、任务尾摘要):守卫链先清旧工具结果、再按尾部裁剪 → 仍装不下则服务商的「prompt too long」拒原样成为
377
+ * 这条 run 的失败终局(不摘要、不重试);怎么终局整个归引擎,本仓不复刻、不夹紧。调用方要的那一遍(`POST /v1/runs/:id/compact`)归引擎的另一只座 `manualCompact`,
378
+ * 本服务不写它 ⇒ 关了自动压缩,手动 `/compact` 照样能跑(与参照实现的 `autoCompactEnabled` 同读)。壳的环境变量 `DISABLE_AUTO_COMPACT` / `DISABLE_COMPACT`
379
+ * 不在本服务的读法里:环境变量是壳进程的事 —— 壳把两者都折成 `autoCompactEnabled: false` 再发;`DISABLE_COMPACT` 多出的「手动也关」由壳自己不发 `/compact` 动词实现
380
+ * (本服务不另读 `settings.env` 里的同名变量 —— 那是 shell 子进程的环境,不是引擎的开关)。
381
+ *
325
382
  * 🔴 `allowedHttpHookUrls` / `httpHookAllowedEnvVars` = **CC settings 同名键**(契约包的 http hook 两张名单,键表属主 = 契约包 `HTTP_HOOK_ALLOWLIST_KEYS`):
326
383
  * 消费点 = {@link parseTaskSettings} 把它们原样收成一层({@link requestHttpHookAllowlistLayer})→ `boot/resolve-spec.ts` 交给 hooks 注册 → `hooks/hook-runner.ts` 的 http 腿
327
384
  * 在拨出之前问契约包判官。受理面只判键名(本门),不判值:名单的读法只有判官那一只(坏形由判官答 `malformed`、拦)。 */
328
- export declare const TASK_SETTINGS_KEYS: readonly ["allowedHttpHookUrls", "approvalFrameFamilies", "complianceAdditionalDenies", "env", "hooks", "httpHookAllowedEnvVars", "model", "outputStyle", "permissions", "readDenyPatterns", "skillListingBudgetFraction", "skillListingMaxDescChars", "ultracode", "webSearch", "writeProtectedExtra"];
385
+ export declare const TASK_SETTINGS_KEYS: readonly ["allowedHttpHookUrls", "approvalFrameFamilies", "autoCompactEnabled", "complianceAdditionalDenies", "env", "hooks", "httpHookAllowedEnvVars", "model", "outputStyle", "permissions", "readDenyPatterns", "skillListingBudgetFraction", "skillListingMaxDescChars", "ultracode", "webSearch", "writeProtectedExtra"];
329
386
  /** 本 service 消费的 `settings.permissions` 子键 —— 闭集(值形校验另有既有门,本门只判键名)。 */
330
387
  export declare const TASK_SETTINGS_PERMISSION_KEYS: readonly ["allow", "ask", "defaultMode", "deny", "disableAutoMode", "neverAuto"];
331
388
  /** CC/SDK 合约里合法、本 service **不接线**的顶层键。词表外的 CC 键落 `unknown` —— 两列都是 400,标签只影响
@@ -361,11 +418,14 @@ export declare function taskSettingsKeyIssue(raw: unknown): KeyClosureIssue | nu
361
418
  * 一只匹配组 / 一个条目上**读者不携带**的键 ⇒ 返回拒体(调用方 400 `request.body_shape`);全部携带 ⇒ `null`。
362
419
  *
363
420
  * 词表 = **读者自己的答案**:`config` 是同一份 `raw` 经 {@link parseHooksConfig} 受理的产物,一只组 / 一个条目受理的键 = 可跑形在同一坐标上那只对象的键
364
- * (契约分类器携带的字段 + 本仓 wire 键:组的 `source`、command 条目的 `plugin` / `args`)。本函数不另立键表 —— 契约给某一型加字段、分类器开始携带它,这里随之受理;
421
+ * (契约分类器携带的字段 + 本仓 wire 键:组的 `source`、command 条目的 `plugin`)。本函数不另立键表 —— 契约给某一型加字段、分类器开始携带它,这里随之受理
422
+ * (契约包 19.0.0 承运 command 的 `args` / `onFailure` 与 http 的 `onFailure`、20.0.0 承运 command 的 `rewakeMessage` / `rewakeSummary` / `cloud`、http 的 `cloud`、
423
+ * prompt 的 `continueOnBlock` 时,这里一行未改就受理了它们 —— 受理 = 读者携带;后四键本服务如实带、不执行,能力位与契约附录明写);
365
424
  * 受理 ⇒ 分类器答 `loaded` ⇒ 组与条目的下标与原值逐位对齐。值为 `undefined` 的键与缺席同读(读者同一口径)。坐标经 {@link hooksCoordinate}(契约包出门形 + 回显口径;凭据形键段不原样回显)。
366
425
  *
367
426
  * 判据边界(与另两个实例同):只判**键名**(值形归读者);拒只在 FRESH 提交面 —— 续跑重放走 {@link parseTaskSettings},读者照旧剥掉它不携带的键,存量体按受理时的读法重放(4xx 打在重放腿上会砖死停驻任务)。
368
- * 为什么必须拒:一只被剥掉的键对调用方读作「生效了」—— 守卫条目上的 `onFailure: "block"` 被剥掉,守卫起不来时照放行;`plugin` / `args` 写在 http 条目上被剥掉,写的人以为插件上下文在。
427
+ * 为什么必须拒:一只被剥掉的键对调用方读作「生效了」—— `plugin` 写在 http 条目上被剥掉,写的人以为插件上下文在;`args` 写在 http 条目上被剥掉,写的人以为不过 shell;
428
+ * `onFailure: "block"` 写在 prompt 条目上被剥掉(契约只在 command / http 上承运),写的人以为守卫起不来时失效关闭。
369
429
  */
370
430
  export declare function hooksKeyIssue(raw: unknown, config: RunnableHooksConfig): KeyClosureIssue | null;
371
431
  /**
@@ -8,7 +8,8 @@ import { limitRefusal } from "./limit-refusal.js";
8
8
  import { tightenGoverned } from "./governance-overrides.js";
9
9
  import { MAX_KEY_ECHO, keyClosureClause, scanKeyClosure } from "./request-key-closure.js";
10
10
  import { hooksCoordinate, parseHooksConfig } from "./hooks/hook-runner.js";
11
- import { HTTP_HOOK_ALLOWLIST_KEYS, SETTINGS_SOURCES } from "@sema-agent/settings-schema";
11
+ import { HTTP_HOOK_ALLOWLIST_KEYS, SETTINGS_SOURCES, containsSecretToken } from "@sema-agent/settings-schema";
12
+ import { echoCallerText } from "./caller-text-echo.js";
12
13
  import { heldRuleName } from "./tool-rule-names.js";
13
14
  import { policyAskStandingAnswerFacts, standingAnswerDurablyRecordable } from "./tool-approval.js";
14
15
  import { createRequestNeverAutoPolicy } from "./approval.js";
@@ -70,10 +71,24 @@ export function skillListingBudgetFractionOk(v) {
70
71
  export function skillListingMaxDescOk(v) {
71
72
  return typeof v === "number" && Number.isSafeInteger(v) && v > 0;
72
73
  }
74
+ export function autoCompactEnabledOk(v) {
75
+ return typeof v === "boolean";
76
+ }
73
77
  export const MAX_SETTINGS_OUTPUT_STYLE_CHARS = 16_384;
74
78
  export const MAX_SETTINGS_ENV_VARS = 256;
75
79
  export const MAX_SETTINGS_ENV_VALUE_CHARS = 32_768;
76
80
  export const MAX_SETTINGS_ENV_KEY_CHARS = 256;
81
+ function settingsEnvMemberReadable(k, val) {
82
+ return k.length > 0 && k.length <= MAX_SETTINGS_ENV_KEY_CHARS && typeof val === "string" && val.length <= MAX_SETTINGS_ENV_VALUE_CHARS;
83
+ }
84
+ function settingsEnvUnreadable(v) {
85
+ if (v === undefined || v === null)
86
+ return false;
87
+ if (typeof v !== "object" || Array.isArray(v))
88
+ return true;
89
+ const entries = Object.entries(v);
90
+ return entries.length > MAX_SETTINGS_ENV_VARS || entries.some(([k, val]) => !settingsEnvMemberReadable(k, val));
91
+ }
77
92
  function cleanEnvMap(v) {
78
93
  if (v === null || typeof v !== "object" || Array.isArray(v))
79
94
  return undefined;
@@ -84,13 +99,51 @@ function cleanEnvMap(v) {
84
99
  if (n >= MAX_SETTINGS_ENV_VARS || seen >= MAX_SETTINGS_ENV_VARS * 8)
85
100
  break;
86
101
  seen++;
87
- if (typeof k === "string" && k.length > 0 && k.length <= MAX_SETTINGS_ENV_KEY_CHARS && typeof val === "string" && val.length <= MAX_SETTINGS_ENV_VALUE_CHARS) {
102
+ if (settingsEnvMemberReadable(k, val)) {
88
103
  out[k] = val;
89
104
  n++;
90
105
  }
91
106
  }
92
107
  return n > 0 ? out : undefined;
93
108
  }
109
+ export const SETTINGS_ENV_CREDENTIAL_MATCHES = ["name", "value_shape"];
110
+ export function readSettingsEnv(settings) {
111
+ if (settings === null || typeof settings !== "object" || Array.isArray(settings))
112
+ return { sent: false, reaching: undefined, unreadable: false };
113
+ const env = settings.env;
114
+ return { sent: env !== undefined && env !== null, reaching: cleanEnvMap(env), unreadable: settingsEnvUnreadable(env) };
115
+ }
116
+ const MAX_CREDENTIAL_KEYS_NAMED = 8;
117
+ const MATCH_PHRASE = { name: "a credential variable of this engine", value_shape: "a value shaped like a secret" };
118
+ export function settingsEnvCredentialIssue(reaching, credentialNames) {
119
+ if (reaching === undefined)
120
+ return null;
121
+ const names = new Set(credentialNames.map((n) => n.toUpperCase()));
122
+ const hits = [];
123
+ for (const [key, value] of Object.entries(reaching)) {
124
+ if (names.has(key.toUpperCase()))
125
+ hits.push({ key, match: "name" });
126
+ else if (containsSecretToken(value))
127
+ hits.push({ key, match: "value_shape" });
128
+ }
129
+ if (hits.length === 0)
130
+ return null;
131
+ const entries = hits.map((h) => ({ key: echoCallerText(h.key, { maxChars: MAX_SETTINGS_ENV_KEY_CHARS }), match: h.match }));
132
+ const named = entries.slice(0, MAX_CREDENTIAL_KEYS_NAMED).map((e) => `${e.key} (${MATCH_PHRASE[e.match]})`);
133
+ const more = entries.length > MAX_CREDENTIAL_KEYS_NAMED ? `, and ${entries.length - MAX_CREDENTIAL_KEYS_NAMED} more` : "";
134
+ return {
135
+ message: `settings.env carries credentials: ${named.join(", ")}${more}. A credential reaches the engine only through the environment its process starts from, never through a request's settings.env — ` +
136
+ "that block comes from a settings file the model can read, and the request hands it to the session's shell and hooks. Move these out of settings.env into the engine's environment " +
137
+ "(a sema shell that keeps credentials in its credentials.env file does this; upgrade a shell that still writes them into settings.json). " +
138
+ "If an entry is not a credential: rename a variable that matched by name, or keep a value that matched by shape out of settings.env the same way (the shape scan is deliberately coarse)",
139
+ fields: { field: "settings.env", entries },
140
+ keys: hits.map((h) => h.key),
141
+ };
142
+ }
143
+ export function withoutKeys(layer, keys) {
144
+ const drop = new Set(keys);
145
+ return { sent: layer.sent, reaching: Object.fromEntries(Object.entries(layer.reaching ?? {}).filter(([k]) => !drop.has(k))), unreadable: layer.unreadable };
146
+ }
94
147
  export const SETTINGS_PERMISSION_BUCKETS = ["allow", "deny", "ask"];
95
148
  export const SETTINGS_PERMISSION_BUCKET_REFUSALS = ["over_cap", "bad_entry"];
96
149
  const BUCKET_ENTRY_RULE = { allow: "allow_layer", deny: "rule_policy", ask: "rule_policy" };
@@ -163,7 +216,7 @@ export function settingsPermissionBucketIssue(perms) {
163
216
  function acceptedRuleList(v) {
164
217
  return Array.isArray(v) && v.length > 0 ? v.slice() : undefined;
165
218
  }
166
- export const TASK_SETTINGS_KEYS = ["allowedHttpHookUrls", "approvalFrameFamilies", "complianceAdditionalDenies", "env", "hooks", "httpHookAllowedEnvVars", "model", "outputStyle", "permissions", "readDenyPatterns", "skillListingBudgetFraction", "skillListingMaxDescChars", "ultracode", "webSearch", "writeProtectedExtra"];
219
+ export const TASK_SETTINGS_KEYS = ["allowedHttpHookUrls", "approvalFrameFamilies", "autoCompactEnabled", "complianceAdditionalDenies", "env", "hooks", "httpHookAllowedEnvVars", "model", "outputStyle", "permissions", "readDenyPatterns", "skillListingBudgetFraction", "skillListingMaxDescChars", "ultracode", "webSearch", "writeProtectedExtra"];
167
220
  export const TASK_SETTINGS_PERMISSION_KEYS = ["allow", "ask", "defaultMode", "deny", "disableAutoMode", "neverAuto"];
168
221
  export const TASK_SETTINGS_UNSUPPORTED_KEYS = ["apiKeyHelper", "crossSessionInbound", "dialogExpiry", "sandbox", "statusLine"];
169
222
  export const TASK_SETTINGS_UNSUPPORTED_PERMISSION_KEYS = ["additionalDirectories", "disableBypassPermissionsMode"];
@@ -265,8 +318,9 @@ export function parseTaskSettings(raw, seats = {}) {
265
318
  deferred.push("hooks");
266
319
  }
267
320
  }
268
- const shellEnv = cleanEnvMap(s.env);
269
- if (s.env !== undefined && s.env !== null && shellEnv === undefined)
321
+ const envLayer = seats.settingsEnv ?? readSettingsEnv(s);
322
+ const shellEnv = envLayer.reaching;
323
+ if (envLayer.unreadable)
270
324
  deferred.push("env");
271
325
  const out = {};
272
326
  const perms = s.permissions;
@@ -311,6 +365,9 @@ export function parseTaskSettings(raw, seats = {}) {
311
365
  const maxDesc = s.skillListingMaxDescChars;
312
366
  if (skillListingMaxDescOk(maxDesc))
313
367
  out.skillListingMaxDescChars = maxDesc;
368
+ const autoCompact = s.autoCompactEnabled;
369
+ if (autoCompactEnabledOk(autoCompact))
370
+ out.autoCompactEnabled = autoCompact;
314
371
  const tightenSeats = readTightenOnlySeats(raw);
315
372
  for (const name of tightenSeats.rejected)
316
373
  deferred.push(tightenOnlySeatDeferredName(name));
@@ -401,7 +458,7 @@ export function rulePolicyBucketsRefusal(permissions, bases) {
401
458
  if (names.length === 0)
402
459
  continue;
403
460
  const declared = declaredFor(root);
404
- const judged = judgeUnmatchableToolNames(`permissions.${bucket}`, names, { consumer: "rule-policy", behavior: bucket, ...(declared !== undefined ? { pathBases: declared } : {}) });
461
+ const judged = judgeUnmatchableToolNames(`permissions.${bucket}`, names, { consumer: "rule-policy", behavior: bucket, noticeSeat: "engine", ...(declared !== undefined ? { pathBases: declared } : {}) });
405
462
  if (judged === undefined)
406
463
  continue;
407
464
  first ??= { bucket, message: judged.message };
@@ -145,6 +145,9 @@ export interface ParkedAskRedeemRequest {
145
145
  decider: ApprovalDecider;
146
146
  /** [ref] ctrl+g 编辑放行的实参整体替换(approve 才有意义)。 */
147
147
  updatedInput?: unknown;
148
+ /** 卡上点的是 `allow_session` ⇒ `"session"`:与 `/decide` 体上的 `remember:"session"` 是**同一只**「本会话放行」请求,交同一个铸点
149
+ * (续跑腿 `resumeCheckpoint`;可记与否从同一条停驻行判、落同一只豁免店、只在结清之后落)。缺席 = 只放行这一次的那两个词。 */
150
+ remember?: "session";
148
151
  /** 发起本次 respond 的**已验证**调用方(live 腿 `gatedPrincipal` 的那一把)。席在赎回之前拿它与
149
152
  * **checkpoint 当下的 scope** 对一次(codex R1-[high] 一:收编改写身份之后,任何缓存的属主判据都
150
153
  * 过期;门必须贴在当下的持久事实上)。 */
@@ -153,11 +156,15 @@ export interface ParkedAskRedeemRequest {
153
156
  * 缺席 ⇒ 那条腿按「无请求」形处置(它自己的成文语义,本席不替它决定)。 */
154
157
  httpReq?: IncomingMessage;
155
158
  }
156
- /** [ref]:赎回席(装配层注入;缺席 ⇒ PARKED 臂逐字回落修前 404)。回的是赎回腿的原始 HTTP 结果面。 */
157
- export type ParkedAskRedeem = (req: ParkedAskRedeemRequest) => Promise<{
159
+ /** [ref]:赎回席的结局 = 赎回腿的原始 HTTP 结果面 + 请求带了 `remember` 时铸点的真答(`rememberApplied`:落没落;不进 `body` —— 首次受理的回执挂它,
160
+ * 受理回执(幂等回放的那一份)不存它)。 */
161
+ export interface ParkedAskRedeemResult {
158
162
  status: number;
159
163
  body: Record<string, unknown>;
160
- }>;
164
+ rememberApplied?: boolean;
165
+ }
166
+ /** [ref]:赎回席(装配层注入;缺席 ⇒ PARKED 臂逐字回落修前 404)。 */
167
+ export type ParkedAskRedeem = (req: ParkedAskRedeemRequest) => Promise<ParkedAskRedeemResult>;
161
168
  /**
162
169
  * 一张门被引擎**重开**过的停驻卡([ref]):决过之后,续跑腿在被批准的动作开跑之前失败,引擎把同一张门(同一把 token)翻回待决。
163
170
  * `reason` = core 记在行上的重开因由词原样(闭集 `REOPEN_REASONS`:`env_failed` 同一个决议经耐久回决口(`decidePath`)再交一次即可续跑 —— 本副本还留着首次受理回执时(缺省 1 小时内、未被容量帽逐出)应答口回放那张回执、不驱续跑;`tool_unavailable` / `constraint_rejected` 要重新决;`config_refused` 改好部署配置后再交原决议,或重新决);
@@ -611,8 +618,8 @@ export interface ToolApprovalFrame {
611
618
  * `redactSecrets` 后截长一次算定)。形不合 / 空表 ⇒ 不铸键。
612
619
  *
613
620
  * 耐久路(park 行)的对偶是 `gate.riskDescriptor.allowRuleShadowed`(整体透传,两条 durable 读面在读边界对条目补 `redactSecrets`,
614
- * 叶表属主 `observability/run-terminal.ts` 的 `redactRiskDescriptor`)。升级前停驻的行带旧键 `shadowedRule`,起服一次性迁移改写
615
- * (`plugins/one-time-migrations.ts` 登记表)。
621
+ * 叶表属主 `observability/run-terminal.ts` 的 `redactRiskDescriptor`)。引擎 7.41.x 停驻的行带旧键 `shadowedRule`:不在这一位上(那一格只经脱敏叶表
622
+ * 「认不得的键按内容脱敏」一条原样显示)。
616
623
  */
617
624
  allowRuleShadowed?: AllowRuleShadowProjection[];
618
625
  /**
@@ -1291,8 +1298,9 @@ export declare function approvalPreambleReplays(input: Omit<ApprovalLegInput, "n
1291
1298
  /** 一条 **DECIDED 行**能交还给引擎的全部形(`AskOutcome` 减掉 park 路由那一臂 —— 一条有决议的行
1292
1299
  * 从定义上不是「投递面拿走了它」)。{@link ToolApprovalCoordinator.notifyExternalDecision} 收的就是它。 */
1293
1300
  export type DecidedAskOutcome = Exclude<AskOutcome, "unavailable">;
1294
- /** 铸点的入参形 = 行上与**这条决议本身**有关的三格。整行(`AskRow`)与 claim 败方读数都满足。 */
1295
- type DecidedRowFacts = Pick<AskRow, "decision" | "settledBy" | "decidedVia"> & {
1301
+ /** 铸点的入参形 = 行上与**这条决议本身**有关的四格。整行(`AskRow`)与 claim 败方读数都满足。
1302
+ * `decisionNote` 与 `settledBy` / `decidedVia` 同律**必填**(可空)—— 可选会让一个漏挑这一列的投影静默编译过,而漏挑的后果正是把带说明的拒交成裸拒。 */
1303
+ type DecidedRowFacts = Pick<AskRow, "decision" | "settledBy" | "decidedVia" | "decisionNote"> & {
1296
1304
  updatedInput?: unknown;
1297
1305
  };
1298
1306
  /**
@@ -1303,12 +1311,17 @@ type DecidedRowFacts = Pick<AskRow, "decision" | "settledBy" | "decidedVia"> & {
1303
1311
  * 重放 / 兄弟广播 / 歧义提交恢复三条路上全都退化成裸 `false`,而裸 `false` 在 core 那边逐字是
1304
1312
  * 「**一个人**拒绝了」。手抄投影全面下线([ref]):消费点交行,形由这里铸。
1305
1313
  *
1306
- * 三条读法,每条的属主注在别处,这里只落笔:
1314
+ * 四条读法,每条的属主注在别处,这里只落笔:
1307
1315
  * · **方向** —— `decision !== "approve"` 即拒(列的二值由店的 CAS 保证);
1308
1316
  * · **编辑载荷**([ref])—— `updatedInput` 键缺席 = 没带编辑 ⇒ 裸 `true`;在场(**含 `null`**)= 编辑的
1309
1317
  * 字面值 ⇒ 对象臂(语义三态的唯一属主 = `AskRow.updatedInput` 顶注);
1310
1318
  * · **结算来源**([ref])—— 行上非 null 即宿主自报的那个词(`null` = 人决,与「不铸这个键」同义;
1311
- * 语义属主 = `AskRow.settledBy` 顶注)。
1319
+ * 语义属主 = `AskRow.settledBy` 顶注);
1320
+ * · **拒因**([ref] 的行派生半场)—— 拒行上**非空**的 `decisionNote` 铸成 `reason`(与应答口 `shapeDeny` 同键同形:core 以带说明的人拒句
1321
+ * 把它交给模型,围栏 `delimitUntrusted` 与长度上限 `REVIEWER_NOTE_MAX_BODY` 全在 core,本仓只透传不预判;空串按 core 契约的缺席读,不铸只装了
1322
+ * 空值的对象臂)。**allow 行的说明恒不铸**:core 对 allow 行的 `reason` 恒销毁,说明只走审计面(行的 `decisionNote` 列)。
1323
+ * 此前这一格不在铸点里 ⇒ 耐久决断口 / 重放 / 兄弟广播 / claim 败方 / 歧义提交恢复 / 悬挂轮询六条行派生的路,都把带说明的拒交成裸 `false`
1324
+ * (core 读作「一个人拒了、没说怎么办」:STOP 句 + 本轮收住),而同一段说明经应答口到达却带着 `reason` 进模型 —— 一扇门两种去向。
1312
1325
  *
1313
1326
  * 🔴 [ref]:来源位**两向都读**。决定体的出处位 `decidedBy:"policy"` 在 allow 与 deny 上都会落列(引擎 7.39.0 起铸
1314
1327
  * `policy_allowed`),所以 approve 行带来源位是一条合法的行,它的每条读回路径交还 `{allow:true, settledBy:"policy", updatedInput?}`
@@ -1421,7 +1434,7 @@ export declare class ToolApprovalCoordinator {
1421
1434
  * ask 的 `sessionId` 咨询一次——「这次授权是在**哪里**点的」在授权发生时捕获,不在回决时再猜。
1422
1435
  * 回 `undefined` = 该部署形上 run 的 workspace root 不可知(远程沙箱/多租户等)⇒ 不铸 scope,落
1423
1436
  * core 的 global 缺省(= 现行为,恒不更宽;也绝不错铸一个坐标系不对的 root)。装配见 main.ts:
1424
- * registry cwd(host lane 显式注册的 launch dir)?? in-process 单用户形的 `process.cwd()`。 */
1437
+ * registry cwd(host lane 显式注册的 launch dir)?? 无手(`none`)单用户形的 `process.cwd()`。 */
1425
1438
  private readonly ruleScopeRootFor;
1426
1439
  /** [ref]:停驻行迟到决议的受理回执表(键 = 行的键 `askId`,插入序 = 逐出序)。语义与有界理由见
1427
1440
  * {@link ParkRedemption} 顶注。 */
@@ -512,7 +512,8 @@ export function outcomeOfDecidedRow(row) {
512
512
  const allow = row.decision === "approve";
513
513
  const source = row.settledBy !== null ? { settledBy: row.settledBy, ...(row.decidedVia !== null ? { decidedVia: row.decidedVia } : {}) } : {};
514
514
  const edit = allow && row.updatedInput !== undefined ? { updatedInput: row.updatedInput } : {};
515
- return row.settledBy === null && !("updatedInput" in edit) ? allow : { allow, ...edit, ...source };
515
+ const denyReason = !allow && row.decisionNote ? { reason: row.decisionNote } : {};
516
+ return row.settledBy === null && !("updatedInput" in edit) && !("reason" in denyReason) ? allow : { allow, ...edit, ...denyReason, ...source };
516
517
  }
517
518
  function settleArgsOfDecided(outcome) {
518
519
  if (typeof outcome === "boolean")
@@ -521,6 +522,7 @@ function settleArgsOfDecided(outcome) {
521
522
  allowed: outcome.allow,
522
523
  ...(outcome.updatedInput !== undefined ? { updatedInput: outcome.updatedInput } : {}),
523
524
  ...(outcome.settledBy !== undefined ? { source: { settledBy: outcome.settledBy, ...(outcome.decidedVia !== undefined ? { decidedVia: outcome.decidedVia } : {}) } } : {}),
525
+ ...(!outcome.allow && outcome.reason !== undefined ? { denyReason: outcome.reason } : {}),
524
526
  };
525
527
  }
526
528
  function verdictOfDecided(args) {
@@ -529,6 +531,7 @@ function verdictOfDecided(args) {
529
531
  allowed: args.allowed,
530
532
  ...(args.updatedInput !== undefined ? { updatedInput: args.updatedInput } : {}),
531
533
  ...(args.source !== undefined ? { hostSource: args.source } : {}),
534
+ ...(args.denyReason !== undefined ? { denyReason: args.denyReason } : {}),
532
535
  };
533
536
  }
534
537
  function settleArgsOf(outcome) {
@@ -2478,7 +2481,6 @@ export class ToolApprovalCoordinator {
2478
2481
  askId: row.askId,
2479
2482
  idempotent: true,
2480
2483
  ...decided,
2481
- ...(parsed.value === "allow_session" ? { rememberApplied: false } : {}),
2482
2484
  ...noteRecordedReceipt(parsed.note, noteLandedOnRow(parsed.note, row.decisionNote)),
2483
2485
  ...this.lateRuleRefusal(parsed),
2484
2486
  },
@@ -2519,6 +2521,7 @@ export class ToolApprovalCoordinator {
2519
2521
  ...(parsed.note !== undefined ? { note: parsed.note } : {}),
2520
2522
  decider: parsed.decider,
2521
2523
  ...(parsed.updatedInput !== undefined && parsed.value !== "deny" ? { updatedInput: parsed.updatedInput } : {}),
2524
+ ...(parsed.value === "allow_session" ? { remember: "session" } : {}),
2522
2525
  ...(principal !== undefined ? { principal } : {}),
2523
2526
  ...(httpReq !== undefined ? { httpReq } : {}),
2524
2527
  });
@@ -2555,7 +2558,7 @@ export class ToolApprovalCoordinator {
2555
2558
  approvalId: id,
2556
2559
  askId: row.askId,
2557
2560
  accepted: "parked_redeemed",
2558
- ...(parsed.value === "allow_session" ? { rememberApplied: false } : {}),
2561
+ ...(parsed.value === "allow_session" ? { rememberApplied: out.rememberApplied === true } : {}),
2559
2562
  ...(rule?.body ?? {}),
2560
2563
  },
2561
2564
  };
@@ -2667,7 +2670,6 @@ export class ToolApprovalCoordinator {
2667
2670
  accepted: "parked_redeemed",
2668
2671
  idempotent: true,
2669
2672
  decision: receipt.decision === "approve" ? "allow" : "deny",
2670
- ...(parsed.value === "allow_session" ? { rememberApplied: false } : {}),
2671
2673
  ...(rule ?? {}),
2672
2674
  },
2673
2675
  };
@@ -2840,14 +2842,16 @@ export class ToolApprovalCoordinator {
2840
2842
  this.allowAllSessions.add(sessionAllowKey(judgedOwner, entry.sessionId, sessionAllowCategory(entry.toolName), entry.grantBinding));
2841
2843
  }
2842
2844
  const allowed = parsed.value !== "deny";
2843
- const settleArgs = opts?.settleOutcome !== undefined ? settleArgsOfDecided(opts.settleOutcome) : { allowed, updatedInput: parsed.updatedInput, source: liveHostSource(parsed.decider) };
2845
+ const settleArgs = opts?.settleOutcome !== undefined
2846
+ ? settleArgsOfDecided(opts.settleOutcome)
2847
+ : { allowed, updatedInput: parsed.updatedInput, source: liveHostSource(parsed.decider), ...(!allowed && parsed.note !== undefined ? { denyReason: parsed.note } : {}) };
2844
2848
  const readRootGrant = opts?.settleOutcome === undefined || opts.settleOutcomeIsThisRequest === true ? parsed.readRootGrant : undefined;
2845
2849
  entry.settle({
2846
2850
  by: "human",
2847
2851
  allowed: settleArgs.allowed,
2848
2852
  updatedInput: settleArgs.updatedInput,
2849
2853
  ...(settleArgs.source !== undefined ? { hostSource: settleArgs.source } : {}),
2850
- ...(!settleArgs.allowed && parsed.note !== undefined ? { denyReason: parsed.note } : {}),
2854
+ ...(settleArgs.denyReason !== undefined ? { denyReason: settleArgs.denyReason } : {}),
2851
2855
  ...(readRootGrant !== undefined ? { readRootGrant } : {}),
2852
2856
  });
2853
2857
  const updatedInputDelivered = opts?.updatedInputDelivered ?? true;
@@ -20,6 +20,7 @@
20
20
  import type { TaskNotificationPayload, SemaProvenance, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, PendingAction, TaskEvent, TraceEvent, MailboxMessage, MailboxAppendMessage, TaskSpec, TaskResult, SideQueryResult, WiringManifest, PermissionModeReceipt, GateOutcome, GateDisposition, Settlement, PausedCause, TerminalCause, CheckpointGate, CheckpointToken, VerificationResult, CascadeRunResult, WorkflowRun, ReadRootGrantCandidate, McpReconnectResult, McpServerStatus, NodeLspManagerOptions, RunnerDeps, SessionMemoryStatus, DeploymentSessionMemoryStatus, PromptManifestIdentity, PromptIdentityLayers, PromptManifestSelectors, PromptManifestSection, PromptChainLink, SupersededOverlay, ToolDisclosureManifest } from "@sema-agent/core";
21
21
  import type { ToolApprovalFrame } from "../tool-approval.js";
22
22
  import type { TableCoreKeys } from "./projection-table.js";
23
+ import type { ProjectRegistration } from "@sema-agent/settings-schema";
23
24
  import type { PauseSeat } from "../terminal.js";
24
25
  /** 编译期断言:T 必须收敛到 never(有残余键 = tsc 红)。
25
26
  * 🔴 **导出**([ref] U1/U2):本仓「词表闭集,未处置成员=编译红」的钉法只许有**一个**形 ——
@@ -27,12 +28,12 @@ import type { PauseSeat } from "../terminal.js";
27
28
  * `type X<T extends never> = T`(抄一份就是第二个写者,两处哪天分岔谁都发现不了)。
28
29
  * 本文件只有类型、不产 JS,所以被 `import type` 引用不新增任何运行期边。 */
29
30
  export type AssertAllKeysHandled<T extends never> = T;
30
- type NotificationProjected = "task_id" | "task_type" | "toolUseId" | "status" | "summary" | "result" | "output_file" | "usage" | "sessionId" | "seq" | "lines" | "stoppedBy" | "source" | "exitCode" | "partial" | "diagnostics" | "recentSteps" | "editedFiles" | "resumable" | "completionId" | "error" | "errorCode" | "apiFailure" | "agentMessage" | "_sema_provenance" | "spawnName" | "handback" | "compaction" | "resupplied" | "attempt";
31
+ type NotificationProjected = "task_id" | "task_type" | "toolUseId" | "status" | "summary" | "result" | "output_file" | "usage" | "sessionId" | "seq" | "lines" | "stoppedBy" | "source" | "exitCode" | "partial" | "diagnostics" | "recentSteps" | "editedFiles" | "resumable" | "completionId" | "error" | "errorCode" | "apiFailure" | "agentMessage" | "_sema_provenance" | "spawnName" | "handback" | "compaction" | "resupplied" | "attempt" | "crossSessionMessage" | "crossSessionNotice" | "inboxNotice";
31
32
  type NotificationExcluded = (typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES)["task_notification"]["excluded"][number];
32
33
  type _GuardNotification = AssertAllKeysHandled<Exclude<keyof TaskNotificationPayload, NotificationProjected | NotificationExcluded>>;
33
34
  type _GuardNotificationReverse = AssertAllKeysHandled<Exclude<NotificationProjected | NotificationExcluded, keyof TaskNotificationPayload>>;
34
- type ProvenanceProjected = "kind" | "from" | "taskId" | "seq" | "agentType";
35
- type ProvenanceExcluded = "peerMeta";
35
+ type ProvenanceProjected = "kind" | "from" | "taskId" | "seq" | "agentType" | "peerMeta";
36
+ type ProvenanceExcluded = (typeof import("./wire-projection-faces.js").WIRE_PROJECTION_FACES)["task_notification_provenance"]["excluded"][number];
36
37
  type _GuardProvenance = AssertAllKeysHandled<Exclude<keyof SemaProvenance, ProvenanceProjected | ProvenanceExcluded>>;
37
38
  type _GuardProvenanceReverse = AssertAllKeysHandled<Exclude<ProvenanceProjected | ProvenanceExcluded, keyof SemaProvenance>>;
38
39
  type AgentMessageProjected = "from" | "body";
@@ -231,7 +232,7 @@ type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjec
231
232
  type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
232
233
  type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptLean" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies" | "projectId";
233
234
  /** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
234
- export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel" | "runOrigin" | "planFile" | "classifyAllShell";
235
+ export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel" | "runOrigin" | "planFile" | "classifyAllShell" | "workspace";
235
236
  type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
236
237
  type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
237
238
  type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction" | "resultEntryIds" | "placementRoot";
@@ -434,11 +435,12 @@ type _CoverWordsCheck = AssertAllKeysHandled<Exclude<CoveringWords<{
434
435
  note: string;
435
436
  }[], _CoverProbeWords>>>;
436
437
  type SessionMemoryStatusSourceKey = keyof SessionMemoryStatus | keyof DeploymentSessionMemoryStatus;
437
- type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "foldedCount" | "optOutSource" | "lastCaptureAt";
438
- type SessionMemoryStatusExcluded = "writeHome" | "planes";
439
- type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<SessionMemoryStatusSourceKey, SessionMemoryStatusProjected | SessionMemoryStatusExcluded>>;
440
- type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded, SessionMemoryStatusSourceKey>>;
441
- type _GuardSessionMemoryStatusDeploymentReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected, keyof DeploymentSessionMemoryStatus>>;
438
+ type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "foldedCount" | "optOutSource" | "lastCaptureAt" | "writeHome" | "planes";
439
+ /** 其中部署对象顶层也答的那些(引擎折好的五键 + 引擎择一的 `writeHome`;`planes` 是逐店明细本身)。 */
440
+ type SessionMemoryStatusDeploymentTop = Exclude<SessionMemoryStatusProjected, "planes">;
441
+ type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<SessionMemoryStatusSourceKey, SessionMemoryStatusProjected>>;
442
+ type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected, SessionMemoryStatusSourceKey>>;
443
+ type _GuardSessionMemoryStatusDeploymentReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusDeploymentTop, keyof DeploymentSessionMemoryStatus>>;
442
444
  type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut" | "account";
443
445
  type SideQueryResultStripped = never;
444
446
  type _GuardSideQueryResult = AssertAllKeysHandled<Exclude<keyof SideQueryResult, SideQueryResultForwarded | SideQueryResultStripped>>;
@@ -453,7 +455,7 @@ type GateOutcomeProjected = "disposition" | "settlement" | "origin";
453
455
  type _GuardGateOutcome = AssertAllKeysHandled<Exclude<keyof GateOutcome, GateOutcomeProjected>>;
454
456
  type _GuardGateOutcomeReverse = AssertAllKeysHandled<Exclude<GateOutcomeProjected, keyof GateOutcome>>;
455
457
  type GateDispositionKeys = GateDisposition extends infer D ? (D extends object ? keyof D : never) : never;
456
- type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes" | "extension";
458
+ type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes" | "extension" | "echoed";
457
459
  type _GuardGateDisposition = AssertAllKeysHandled<Exclude<GateDispositionKeys, GateDispositionProjected>>;
458
460
  type _GuardGateDispositionReverse = AssertAllKeysHandled<Exclude<GateDispositionProjected, GateDispositionKeys>>;
459
461
  type SettlementProjected = "kind" | "who" | "when" | "note";
@@ -521,6 +523,9 @@ type WorkspaceChangedArm = Extract<TaskEvent, {
521
523
  }>;
522
524
  type _GuardSessionWorkspace = AssertAllKeysHandled<Exclude<keyof WorkspaceChangedArm, TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>>>;
523
525
  type _GuardSessionWorkspaceReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>, keyof WorkspaceChangedArm>>;
526
+ type ProjectRegistryTables = typeof import("../http/routes/projects.js");
527
+ type _GuardProjectRow = AssertAllKeysHandled<Exclude<keyof ProjectRegistration, TableCoreKeys<ProjectRegistryTables["PROJECT_ROW_DISPOSITIONS"]>>>;
528
+ type _GuardProjectRowReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<ProjectRegistryTables["PROJECT_ROW_DISPOSITIONS"]>, keyof ProjectRegistration>>;
524
529
  export type CoreKeysetGuards = [
525
530
  _GuardNotification,
526
531
  _GuardTerminalArm,
@@ -667,6 +672,8 @@ export type CoreKeysetGuards = [
667
672
  _GuardLedgerRunnerDepsReverse,
668
673
  _GuardSessionWorkspace,
669
674
  _GuardSessionWorkspaceReverse,
675
+ _GuardProjectRow,
676
+ _GuardProjectRowReverse,
670
677
  _GuardTokenSeats,
671
678
  _GuardTokenSeatsReverse,
672
679
  _GuardGateSeats,
@@ -16,7 +16,7 @@
16
16
  * 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
17
17
  * 刚立,立完就在下一次加码时自己咬住了)。
18
18
  */
19
- export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.lineage_rerooted", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded", "context.media_removed", "mcp.authorization_required", "classifier.seat_rate_limited", "context.tool_schema_removed"];
19
+ export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.lineage_rerooted", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded", "context.media_removed", "mcp.authorization_required", "classifier.seat_rate_limited", "context.tool_schema_removed", "memory.harvest_refused", "memory.harvest_conflict", "config.legacy_tool_name"];
20
20
  export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
21
21
  /** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
22
22
  export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
@@ -51,6 +51,9 @@ export const ENGINE_NOTICE_WIRE_CODES = [
51
51
  "mcp.authorization_required",
52
52
  "classifier.seat_rate_limited",
53
53
  "context.tool_schema_removed",
54
+ "memory.harvest_refused",
55
+ "memory.harvest_conflict",
56
+ "config.legacy_tool_name",
54
57
  ];
55
58
  const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
56
59
  export function isEngineNoticeWireCode(code) {
@@ -114,6 +117,7 @@ export const RULE_TEXT_DETAIL_FIELDS = {
114
117
  "permission.allowed_tool_not_granted": { array: "entries", field: "entry" },
115
118
  "permission.rule_row_dropped": { array: "rows", field: "rule" },
116
119
  "config.session_rules_earlier_grammar": { array: "entries", field: "entry" },
120
+ "config.legacy_tool_name": { array: "entries", field: "entry" },
117
121
  };
118
122
  export function redactNoticeMessage(message) {
119
123
  return redactSecrets(String(message));