@sema-agent/server 7.131.0 → 7.133.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 (509) hide show
  1. package/MIGRATION.md +575 -0
  2. package/README.md +12 -9
  3. package/README.zh-CN.md +9 -6
  4. package/USAGE.md +326 -98
  5. package/deploy/sema-up/README.md +19 -1
  6. package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
  7. package/deploy/sema-up/chart/templates/server.yaml +5 -2
  8. package/deploy/sema-up/stack/compose.yaml +3 -0
  9. package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
  10. package/dist/adoption/plan.d.ts +3 -2
  11. package/dist/adoption/plan.js +7 -5
  12. package/dist/adoption/runner.js +3 -10
  13. package/dist/adoption/sql.d.ts +3 -2
  14. package/dist/adoption/sql.js +3 -5
  15. package/dist/adoption/wire.d.ts +4 -1
  16. package/dist/adoption/wire.js +1 -0
  17. package/dist/approval-ask-audit-store.d.ts +31 -13
  18. package/dist/approval-ask-audit-store.js +272 -74
  19. package/dist/approval-ask-machine.d.ts +15 -0
  20. package/dist/approval-ask-machine.js +6 -0
  21. package/dist/approval-ask-retention.d.ts +136 -0
  22. package/dist/approval-ask-retention.js +102 -0
  23. package/dist/approval-card.d.ts +82 -20
  24. package/dist/approval-card.js +46 -16
  25. package/dist/approval-deny-reasons.d.ts +1 -1
  26. package/dist/approval.d.ts +9 -0
  27. package/dist/approval.js +24 -3
  28. package/dist/audit.d.ts +33 -19
  29. package/dist/audit.js +12 -16
  30. package/dist/auth-bridge.d.ts +4 -0
  31. package/dist/auth-bridge.js +10 -11
  32. package/dist/bake-runner/main.js +3 -2
  33. package/dist/boot/deferred-sandbox-path-env.js +1 -1
  34. package/dist/boot/deployment-mods.d.ts +31 -0
  35. package/dist/boot/deployment-mods.js +26 -0
  36. package/dist/boot/execution-env.d.ts +1 -1
  37. package/dist/boot/execution-env.js +27 -12
  38. package/dist/boot/execution-lane.js +11 -0
  39. package/dist/boot/leader.js +2 -0
  40. package/dist/boot/memory-boundary.d.ts +2 -2
  41. package/dist/boot/memory-boundary.js +2 -2
  42. package/dist/boot/memory-consolidation.d.ts +5 -4
  43. package/dist/boot/memory-consolidation.js +7 -6
  44. package/dist/boot/org-delivery.d.ts +28 -0
  45. package/dist/boot/org-delivery.js +20 -0
  46. package/dist/boot/read-deny-anchor-audit.d.ts +17 -0
  47. package/dist/boot/read-deny-anchor-audit.js +36 -0
  48. package/dist/boot/reapers.d.ts +3 -0
  49. package/dist/boot/reapers.js +21 -1
  50. package/dist/boot/resolve-spec.d.ts +4 -5
  51. package/dist/boot/resolve-spec.js +74 -123
  52. package/dist/boot/runner-deps.d.ts +19 -8
  53. package/dist/boot/runner-deps.js +15 -2
  54. package/dist/boot/session-faces.d.ts +2 -7
  55. package/dist/boot/session-faces.js +4 -2
  56. package/dist/boot/stage-02-web-admin-pull.js +4 -1
  57. package/dist/boot/stage-03-store-backend.d.ts +1 -1
  58. package/dist/boot/stage-03-store-backend.js +2 -2
  59. package/dist/boot/stage-04-stores.d.ts +1 -1
  60. package/dist/boot/stage-05-execution-env.d.ts +4 -4
  61. package/dist/boot/stage-05-execution-env.js +7 -10
  62. package/dist/boot/stage-06-runners.d.ts +4 -2
  63. package/dist/boot/stage-06-runners.js +11 -7
  64. package/dist/boot/stage-07-capability-layer.d.ts +4 -2
  65. package/dist/boot/stage-07-capability-layer.js +27 -6
  66. package/dist/boot/stage-08-reapers.d.ts +4 -2
  67. package/dist/boot/stage-08-reapers.js +2 -2
  68. package/dist/boot/stage-09-leader.d.ts +6 -9
  69. package/dist/boot/stage-10-http-server.d.ts +6 -9
  70. package/dist/boot/stage-10-http-server.js +7 -9
  71. package/dist/boot/stores.d.ts +1 -1
  72. package/dist/boot/stores.js +7 -8
  73. package/dist/boot/web-admin.d.ts +4 -3
  74. package/dist/boot/web-admin.js +186 -98
  75. package/dist/boot/workflow-orchestration.d.ts +2 -0
  76. package/dist/boot/workflow-orchestration.js +2 -1
  77. package/dist/brain.js +25 -25
  78. package/dist/breaker-key.d.ts +6 -0
  79. package/dist/breaker-key.js +29 -0
  80. package/dist/budget.js +5 -4
  81. package/dist/caller-text-echo.d.ts +23 -0
  82. package/dist/caller-text-echo.js +21 -0
  83. package/dist/capabilities/brand-identity.d.ts +26 -0
  84. package/dist/capabilities/brand-identity.js +27 -0
  85. package/dist/capabilities/center-plugins.d.ts +7 -0
  86. package/dist/capabilities/center-plugins.js +1 -1
  87. package/dist/capabilities/center-prompts.d.ts +32 -59
  88. package/dist/capabilities/center-prompts.js +18 -32
  89. package/dist/capabilities/composite-members.d.ts +1 -1
  90. package/dist/capabilities/composite-members.js +1 -1
  91. package/dist/capabilities/engine-capabilities.js +2 -1
  92. package/dist/capabilities/execution-lane.js +2 -2
  93. package/dist/capabilities/hands-lane.d.ts +30 -6
  94. package/dist/capabilities/hands-lane.js +11 -1
  95. package/dist/capabilities/mcp-probe.d.ts +48 -3
  96. package/dist/capabilities/mcp-probe.js +47 -135
  97. package/dist/capabilities/scenarios.d.ts +95 -45
  98. package/dist/capabilities/scenarios.js +53 -38
  99. package/dist/capabilities/skills.d.ts +19 -4
  100. package/dist/capabilities/skills.js +30 -10
  101. package/dist/capability-facts.d.ts +34 -4
  102. package/dist/capability-facts.js +28 -2
  103. package/dist/center-config-tier.d.ts +69 -0
  104. package/dist/center-config-tier.js +42 -0
  105. package/dist/checkpoint-identity.d.ts +16 -0
  106. package/dist/checkpoint-identity.js +19 -0
  107. package/dist/config-catalog.d.ts +17 -10
  108. package/dist/config-catalog.js +47 -32
  109. package/dist/config-d-migration.d.ts +3 -1
  110. package/dist/config-d-migration.js +2 -2
  111. package/dist/config-dir-trust.d.ts +114 -0
  112. package/dist/config-dir-trust.js +388 -0
  113. package/dist/config-invariants.d.ts +18 -5
  114. package/dist/config-invariants.js +35 -3
  115. package/dist/config-lkg.d.ts +9 -9
  116. package/dist/config-lkg.js +20 -4
  117. package/dist/config-provider.d.ts +9 -2
  118. package/dist/config-provider.js +18 -6
  119. package/dist/config-types.d.ts +75 -20
  120. package/dist/config-types.js +8 -0
  121. package/dist/config.d.ts +13 -0
  122. package/dist/config.js +137 -62
  123. package/dist/delegated-session-owner.d.ts +185 -0
  124. package/dist/delegated-session-owner.js +119 -0
  125. package/dist/device-protocol.d.ts +5 -3
  126. package/dist/device-protocol.js +1 -1
  127. package/dist/device-ws-hub.js +21 -2
  128. package/dist/device-ws-protocol.d.ts +70 -6
  129. package/dist/device-ws-protocol.js +50 -22
  130. package/dist/elicitation.js +3 -2
  131. package/dist/entry-problems.d.ts +34 -0
  132. package/dist/entry-problems.js +14 -0
  133. package/dist/env-name-allowlist-knobs.d.ts +12 -2
  134. package/dist/env-name-allowlist-knobs.js +5 -4
  135. package/dist/exec-bounds.d.ts +15 -3
  136. package/dist/exec-bounds.js +4 -0
  137. package/dist/execution-lane-caps.d.ts +56 -10
  138. package/dist/execution-lane-caps.js +50 -0
  139. package/dist/field-conflict.d.ts +43 -0
  140. package/dist/field-conflict.js +20 -0
  141. package/dist/fleet/fleet-bus.d.ts +80 -6
  142. package/dist/fleet/fleet-bus.js +41 -9
  143. package/dist/hooks/classic-stations.d.ts +91 -0
  144. package/dist/hooks/classic-stations.js +27 -0
  145. package/dist/hooks/command-spawn.d.ts +57 -0
  146. package/dist/hooks/command-spawn.js +139 -0
  147. package/dist/hooks/hook-llm.d.ts +8 -5
  148. package/dist/hooks/hook-llm.js +79 -36
  149. package/dist/hooks/hook-runner.d.ts +349 -95
  150. package/dist/hooks/hook-runner.js +855 -568
  151. package/dist/hooks/hook-source.d.ts +44 -0
  152. package/dist/hooks/hook-source.js +40 -0
  153. package/dist/http/active-run-conflict.d.ts +5 -13
  154. package/dist/http/active-run-conflict.js +17 -27
  155. package/dist/http/admission.d.ts +8 -2
  156. package/dist/http/admission.js +188 -101
  157. package/dist/http/approval-sweeps.js +99 -21
  158. package/dist/http/caller-trust.d.ts +77 -0
  159. package/dist/http/caller-trust.js +143 -0
  160. package/dist/http/checkpoint-ctx.d.ts +41 -24
  161. package/dist/http/checkpoint-ctx.js +23 -16
  162. package/dist/http/claimed-run.d.ts +14 -0
  163. package/dist/http/claimed-run.js +15 -0
  164. package/dist/http/device-placement.d.ts +2 -4
  165. package/dist/http/device-placement.js +7 -11
  166. package/dist/http/dispatch.d.ts +0 -4
  167. package/dist/http/dispatch.js +15 -13
  168. package/dist/http/durable-run-leg.d.ts +6 -33
  169. package/dist/http/durable-run-leg.js +36 -10
  170. package/dist/http/health-self-report.d.ts +7 -5
  171. package/dist/http/health-self-report.js +4 -18
  172. package/dist/http/owner-access.d.ts +56 -0
  173. package/dist/http/owner-access.js +42 -0
  174. package/dist/http/principal-gate.d.ts +70 -28
  175. package/dist/http/principal-gate.js +61 -15
  176. package/dist/http/readiness.d.ts +11 -5
  177. package/dist/http/readiness.js +10 -3
  178. package/dist/http/refusal-body.d.ts +21 -0
  179. package/dist/http/refusal-body.js +4 -0
  180. package/dist/http/request-guards.d.ts +43 -23
  181. package/dist/http/request-guards.js +53 -17
  182. package/dist/http/resume-ctx-read.d.ts +2 -5
  183. package/dist/http/resume-ctx-read.js +7 -4
  184. package/dist/http/resume-legs.d.ts +28 -4
  185. package/dist/http/resume-legs.js +169 -91
  186. package/dist/http/retired-service-deps.d.ts +43 -0
  187. package/dist/http/retired-service-deps.js +18 -0
  188. package/dist/http/route-ctx.d.ts +44 -28
  189. package/dist/http/route-ctx.js +4 -0
  190. package/dist/http/route-table.js +2 -0
  191. package/dist/http/routes/a2a-serve.js +3 -4
  192. package/dist/http/routes/admin-config-refresh.js +1 -1
  193. package/dist/http/routes/admin-drain.js +1 -1
  194. package/dist/http/routes/admin-memory-optout.js +5 -1
  195. package/dist/http/routes/adoption.js +2 -9
  196. package/dist/http/routes/approvals-assistant.js +49 -48
  197. package/dist/http/routes/background.js +3 -2
  198. package/dist/http/routes/capabilities.js +21 -5
  199. package/dist/http/routes/config-catalog.d.ts +3 -3
  200. package/dist/http/routes/config-catalog.js +1 -1
  201. package/dist/http/routes/devices.js +3 -17
  202. package/dist/http/routes/diagnostics.js +6 -2
  203. package/dist/http/routes/images.js +6 -7
  204. package/dist/http/routes/leader.js +1 -8
  205. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  206. package/dist/http/routes/mcp-reconnect.js +3 -2
  207. package/dist/http/routes/memory-bundle.js +1 -1
  208. package/dist/http/routes/memory-compliance.js +1 -1
  209. package/dist/http/routes/memory-consolidation.js +1 -1
  210. package/dist/http/routes/memory-origin.js +1 -1
  211. package/dist/http/routes/memory-policy.d.ts +1 -1
  212. package/dist/http/routes/memory-policy.js +3 -2
  213. package/dist/http/routes/notify-wake.js +8 -21
  214. package/dist/http/routes/observability.js +2 -2
  215. package/dist/http/routes/principal-inbox.d.ts +39 -0
  216. package/dist/http/routes/principal-inbox.js +76 -0
  217. package/dist/http/routes/retention-ops.js +2 -9
  218. package/dist/http/routes/rules.js +5 -18
  219. package/dist/http/routes/runs.d.ts +5 -0
  220. package/dist/http/routes/runs.js +34 -107
  221. package/dist/http/routes/session-sync.js +15 -26
  222. package/dist/http/routes/sessions.js +30 -40
  223. package/dist/http/routes/shared-memory.js +2 -13
  224. package/dist/http/routes/side-query.js +8 -7
  225. package/dist/http/routes/tasks.js +67 -21
  226. package/dist/http/routes/workflows.d.ts +351 -0
  227. package/dist/http/routes/workflows.js +153 -119
  228. package/dist/http/send.d.ts +33 -10
  229. package/dist/http/send.js +21 -4
  230. package/dist/http/server.d.ts +27 -18
  231. package/dist/http/server.js +34 -6
  232. package/dist/http/stored-body-replay.js +17 -4
  233. package/dist/http/submit-ctx.d.ts +25 -0
  234. package/dist/http/submit-ctx.js +40 -0
  235. package/dist/http/submit-replay.d.ts +4 -3
  236. package/dist/http/submit-replay.js +5 -4
  237. package/dist/http/wire-types.d.ts +11 -8
  238. package/dist/index.d.ts +2 -2
  239. package/dist/index.js +1 -2
  240. package/dist/lane-home-probe.d.ts +112 -0
  241. package/dist/lane-home-probe.js +101 -0
  242. package/dist/leader/endpoint.d.ts +4 -1
  243. package/dist/leader/endpoint.js +11 -10
  244. package/dist/limit-refusal.d.ts +59 -0
  245. package/dist/limit-refusal.js +15 -0
  246. package/dist/main.js +1 -1
  247. package/dist/mcp-assertion-header.d.ts +32 -19
  248. package/dist/mcp-assertion-header.js +10 -9
  249. package/dist/mcp-tool-faces.d.ts +5 -0
  250. package/dist/mcp-tool-faces.js +6 -4
  251. package/dist/memory-project-layer.d.ts +37 -0
  252. package/dist/memory-project-layer.js +46 -0
  253. package/dist/memory-scope.d.ts +24 -17
  254. package/dist/memory-scope.js +24 -8
  255. package/dist/memory-sync-client.d.ts +27 -13
  256. package/dist/memory-sync-client.js +107 -18
  257. package/dist/model-entry-refusal.d.ts +9 -1
  258. package/dist/model-entry-refusal.js +6 -1
  259. package/dist/model-plane-face.d.ts +51 -0
  260. package/dist/model-plane-face.js +24 -0
  261. package/dist/model-provider.d.ts +44 -12
  262. package/dist/model-provider.js +21 -2
  263. package/dist/model-route-endpoint.d.ts +9 -12
  264. package/dist/model-route-endpoint.js +8 -11
  265. package/dist/model-route-env.d.ts +22 -0
  266. package/dist/model-route-env.js +2 -0
  267. package/dist/model-route-gap.d.ts +60 -30
  268. package/dist/model-route-gap.js +21 -15
  269. package/dist/observability/corrupt-read-seat.d.ts +7 -0
  270. package/dist/observability/corrupt-read-seat.js +9 -0
  271. package/dist/observability/cost-taxonomy.d.ts +7 -7
  272. package/dist/observability/err-text.d.ts +6 -0
  273. package/dist/observability/err-text.js +18 -4
  274. package/dist/observability/fail-open.d.ts +76 -14
  275. package/dist/observability/fail-open.js +76 -14
  276. package/dist/observability/metrics.js +4 -1
  277. package/dist/observability/prompt-manifest.d.ts +33 -82
  278. package/dist/observability/prompt-manifest.js +122 -17
  279. package/dist/observability/run-terminal.js +14 -6
  280. package/dist/observability/secret-env-scrub.d.ts +13 -1
  281. package/dist/observability/secret-env-scrub.js +13 -1
  282. package/dist/observability/tool-trace.d.ts +16 -21
  283. package/dist/observability/tool-trace.js +58 -49
  284. package/dist/operator-ask.d.ts +10 -0
  285. package/dist/operator-ask.js +3 -0
  286. package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
  287. package/dist/orchestration/workflow-agent-session-index.js +9 -13
  288. package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
  289. package/dist/orchestration/workflow-completion-inbox.js +13 -0
  290. package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
  291. package/dist/orchestration/workflow-notify-journal.js +27 -34
  292. package/dist/orchestration/workflow-park-decision.d.ts +89 -0
  293. package/dist/orchestration/workflow-park-decision.js +118 -0
  294. package/dist/org-delivery-gate.d.ts +81 -0
  295. package/dist/org-delivery-gate.js +59 -0
  296. package/dist/panel-tool-names.d.ts +23 -0
  297. package/dist/panel-tool-names.js +8 -0
  298. package/dist/parked-decide.d.ts +39 -6
  299. package/dist/parked-decide.js +98 -51
  300. package/dist/parked-revive-surface.d.ts +9 -2
  301. package/dist/parked-revive-surface.js +11 -8
  302. package/dist/per-task-image.d.ts +7 -1
  303. package/dist/per-task-image.js +3 -3
  304. package/dist/permission-rule-list.d.ts +1 -1
  305. package/dist/permission-rule-list.js +2 -2
  306. package/dist/plain-string-record.d.ts +25 -0
  307. package/dist/plain-string-record.js +32 -0
  308. package/dist/plugins/approval-ask-store-file.d.ts +16 -1
  309. package/dist/plugins/approval-ask-store-file.js +21 -0
  310. package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
  311. package/dist/plugins/approval-ask-store-memory.js +34 -2
  312. package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
  313. package/dist/plugins/approval-ask-store-sql.js +37 -1
  314. package/dist/plugins/blob-backend.d.ts +83 -15
  315. package/dist/plugins/blob-backend.js +68 -15
  316. package/dist/plugins/breaker-state-sql.d.ts +2 -2
  317. package/dist/plugins/breaker-state-sql.js +4 -4
  318. package/dist/plugins/caching-session-store.d.ts +3 -0
  319. package/dist/plugins/caching-session-store.js +3 -0
  320. package/dist/plugins/checkpoint-store-sql.d.ts +28 -4
  321. package/dist/plugins/checkpoint-store-sql.js +59 -28
  322. package/dist/plugins/file-history-store-sql.d.ts +5 -2
  323. package/dist/plugins/file-history-store-sql.js +3 -1
  324. package/dist/plugins/file-run-store.d.ts +5 -13
  325. package/dist/plugins/file-run-store.js +9 -0
  326. package/dist/plugins/fork-routing-session-store.d.ts +9 -1
  327. package/dist/plugins/fork-routing-session-store.js +12 -1
  328. package/dist/plugins/host-platform.d.ts +2 -0
  329. package/dist/plugins/host-platform.js +2 -1
  330. package/dist/plugins/k8s-bg-scripts.d.ts +11 -0
  331. package/dist/plugins/k8s-bg-scripts.js +22 -0
  332. package/dist/plugins/local-checkpoint-store.d.ts +2 -0
  333. package/dist/plugins/local-checkpoint-store.js +11 -3
  334. package/dist/plugins/local-session-store.d.ts +1 -1
  335. package/dist/plugins/local-session-store.js +1 -1
  336. package/dist/plugins/local-session-window.d.ts +39 -0
  337. package/dist/plugins/local-session-window.js +54 -0
  338. package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
  339. package/dist/plugins/mailbox-store-sql.d.ts +30 -48
  340. package/dist/plugins/mailbox-store-sql.js +77 -52
  341. package/dist/plugins/memory-embedder-fingerprint.js +2 -1
  342. package/dist/plugins/memory-run-store.d.ts +5 -13
  343. package/dist/plugins/memory-run-store.js +8 -0
  344. package/dist/plugins/one-time-migrations.d.ts +245 -93
  345. package/dist/plugins/one-time-migrations.js +668 -207
  346. package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
  347. package/dist/plugins/org-delivery-quota-store.js +228 -0
  348. package/dist/plugins/permission-rule-store-sql.d.ts +13 -7
  349. package/dist/plugins/permission-rule-store-sql.js +4 -18
  350. package/dist/plugins/pg-pool.js +39 -7
  351. package/dist/plugins/pg-session-storage.d.ts +20 -8
  352. package/dist/plugins/pg-session-storage.js +34 -21
  353. package/dist/plugins/remote-env-adb.d.ts +12 -12
  354. package/dist/plugins/remote-env-adb.js +21 -6
  355. package/dist/plugins/remote-env-device.js +3 -0
  356. package/dist/plugins/remote-env-e2b.d.ts +1 -1
  357. package/dist/plugins/remote-env-e2b.js +21 -9
  358. package/dist/plugins/remote-env-host.d.ts +9 -9
  359. package/dist/plugins/remote-env-host.js +10 -32
  360. package/dist/plugins/remote-env-k8s.d.ts +103 -38
  361. package/dist/plugins/remote-env-k8s.js +288 -95
  362. package/dist/plugins/remote-env-local-docker.d.ts +27 -13
  363. package/dist/plugins/remote-env-local-docker.js +82 -11
  364. package/dist/plugins/remote-env-ssh.d.ts +21 -12
  365. package/dist/plugins/remote-env-ssh.js +117 -5
  366. package/dist/plugins/remote-shell.d.ts +0 -1
  367. package/dist/plugins/remote-shell.js +1 -2
  368. package/dist/plugins/retention-store-sql.js +6 -2
  369. package/dist/plugins/run-store-sql.d.ts +16 -14
  370. package/dist/plugins/run-store-sql.js +22 -2
  371. package/dist/plugins/schema-consistency.d.ts +54 -0
  372. package/dist/plugins/schema-consistency.js +52 -0
  373. package/dist/plugins/schema-indexes.js +2 -0
  374. package/dist/plugins/send-user-file.js +2 -2
  375. package/dist/plugins/session-epoch-anchor.d.ts +39 -0
  376. package/dist/plugins/session-epoch-anchor.js +22 -0
  377. package/dist/plugins/session-store.d.ts +18 -8
  378. package/dist/plugins/session-store.js +15 -4
  379. package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
  380. package/dist/plugins/shared-memory-store-sql.js +5 -16
  381. package/dist/plugins/sql-driver.d.ts +205 -1
  382. package/dist/plugins/sql-driver.js +325 -13
  383. package/dist/plugins/sql-errors.d.ts +64 -0
  384. package/dist/plugins/sql-errors.js +57 -0
  385. package/dist/plugins/store-backend.d.ts +36 -1
  386. package/dist/plugins/store-backend.js +42 -15
  387. package/dist/plugins/store-contracts.d.ts +42 -0
  388. package/dist/plugins/store-contracts.js +1 -0
  389. package/dist/plugins/tidb-pool.d.ts +6 -1
  390. package/dist/plugins/tidb-pool.js +44 -10
  391. package/dist/plugins/tidb-session-storage.d.ts +8 -11
  392. package/dist/plugins/tidb-session-storage.js +6 -16
  393. package/dist/plugins/tidb-session-store.d.ts +24 -4
  394. package/dist/plugins/tidb-session-store.js +29 -5
  395. package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
  396. package/dist/plugins/workflow-journal-store-sql.js +19 -6
  397. package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
  398. package/dist/plugins/workflow-run-store-sql.js +50 -9
  399. package/dist/posture-source.d.ts +18 -10
  400. package/dist/posture-source.js +4 -1
  401. package/dist/project-identity.d.ts +45 -6
  402. package/dist/project-identity.js +162 -8
  403. package/dist/project-layer-key.d.ts +28 -0
  404. package/dist/project-layer-key.js +29 -0
  405. package/dist/prompts-domain-validate.d.ts +17 -61
  406. package/dist/prompts-domain-validate.js +9 -119
  407. package/dist/question.js +3 -2
  408. package/dist/read-deny-entry.d.ts +25 -0
  409. package/dist/read-deny-entry.js +12 -0
  410. package/dist/read-face-posture.d.ts +37 -11
  411. package/dist/read-face-posture.js +32 -3
  412. package/dist/request-key-closure.d.ts +9 -2
  413. package/dist/request-key-closure.js +11 -5
  414. package/dist/request-value-closure.d.ts +5 -0
  415. package/dist/request-value-closure.js +11 -3
  416. package/dist/rule-entry-list.d.ts +38 -11
  417. package/dist/rule-entry-list.js +106 -30
  418. package/dist/rules-consent.js +3 -4
  419. package/dist/run-acceptance.d.ts +19 -3
  420. package/dist/run-acceptance.js +13 -1
  421. package/dist/run-local.js +54 -24
  422. package/dist/runs.d.ts +15 -8
  423. package/dist/runs.js +35 -1
  424. package/dist/runtime-caps-resolver.d.ts +16 -6
  425. package/dist/runtime-caps-resolver.js +18 -5
  426. package/dist/sandbox-pkg-source.d.ts +19 -1
  427. package/dist/sandbox-pkg-source.js +29 -7
  428. package/dist/security.d.ts +87 -9
  429. package/dist/security.js +52 -9
  430. package/dist/server-secret-env.d.ts +44 -18
  431. package/dist/server-secret-env.js +49 -8
  432. package/dist/session-error-wire.d.ts +19 -2
  433. package/dist/session-error-wire.js +5 -1
  434. package/dist/session-incarnation.d.ts +15 -5
  435. package/dist/session-incarnation.js +16 -9
  436. package/dist/session-titled-frame.d.ts +33 -0
  437. package/dist/session-titled-frame.js +4 -0
  438. package/dist/session-titler.d.ts +9 -1
  439. package/dist/session-titler.js +27 -6
  440. package/dist/spec-fields.d.ts +28 -16
  441. package/dist/spec-fields.js +66 -54
  442. package/dist/sql-engine-posture.d.ts +31 -4
  443. package/dist/sql-engine-posture.js +36 -1
  444. package/dist/stored-request-tool-axes-m19.d.ts +19 -4
  445. package/dist/stored-request-tool-axes-m19.js +30 -2
  446. package/dist/task-a2a.d.ts +9 -1
  447. package/dist/task-a2a.js +73 -47
  448. package/dist/task-cwd.d.ts +1 -1
  449. package/dist/task-mcp.d.ts +46 -58
  450. package/dist/task-mcp.js +82 -107
  451. package/dist/task-settings.d.ts +95 -108
  452. package/dist/task-settings.js +77 -98
  453. package/dist/text-bidi.d.ts +1 -48
  454. package/dist/text-bidi.js +3 -5
  455. package/dist/tighten-only-seats.d.ts +150 -0
  456. package/dist/tighten-only-seats.js +196 -0
  457. package/dist/tool-approval.d.ts +304 -88
  458. package/dist/tool-approval.js +623 -239
  459. package/dist/trace/core-keyset-guard.d.ts +122 -20
  460. package/dist/trace/engine-notice-wire.d.ts +11 -3
  461. package/dist/trace/engine-notice-wire.js +8 -1
  462. package/dist/trace/exit-seat.d.ts +28 -0
  463. package/dist/trace/exit-seat.js +76 -0
  464. package/dist/trace/ledger-events.d.ts +6 -3
  465. package/dist/trace/ledger-sink.js +4 -1
  466. package/dist/trace/model-segment.js +1 -1
  467. package/dist/trace/project.d.ts +98 -17
  468. package/dist/trace/project.js +98 -50
  469. package/dist/trace/projection-table.d.ts +100 -0
  470. package/dist/trace/projection-table.js +130 -0
  471. package/dist/trace/redact.d.ts +54 -0
  472. package/dist/trace/redact.js +778 -152
  473. package/dist/trace/self-minted-wire.d.ts +345 -1
  474. package/dist/trace/self-minted-wire.js +117 -1
  475. package/dist/trace/wire-projection-faces.d.ts +377 -3
  476. package/dist/trace/wire-projection-faces.js +164 -1
  477. package/dist/url-refusal.js +2 -0
  478. package/dist/web-admin-client/apply-effective.d.ts +12 -0
  479. package/dist/web-admin-client/apply-effective.js +56 -5
  480. package/dist/web-admin-client/candidate-gate.d.ts +6 -6
  481. package/dist/web-admin-client/candidate-gate.js +3 -3
  482. package/dist/web-admin-client/facade.d.ts +1 -1
  483. package/dist/web-admin-client/facade.js +1 -1
  484. package/dist/web-admin-client/http-client.js +0 -6
  485. package/dist/web-admin-client/read-face.js +5 -9
  486. package/dist/web-admin-client/read-warnings.d.ts +13 -0
  487. package/dist/web-admin-client/read-warnings.js +10 -0
  488. package/dist/web-admin-client/skills-mcp.d.ts +3 -0
  489. package/dist/web-admin-client/skills-mcp.js +11 -9
  490. package/dist/web-admin-client/types.d.ts +2 -3
  491. package/dist/workspace-cache.d.ts +35 -0
  492. package/dist/workspace-cache.js +36 -0
  493. package/dist/workspace-space.d.ts +3 -2
  494. package/dist/workspace-space.js +2 -0
  495. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +65 -10
  496. package/package.json +8 -4
  497. package/scripts/drain-check-local.mjs +34 -1
  498. package/scripts/drain-check.mysql.sql +30 -2
  499. package/scripts/drain-check.pg.sql +29 -2
  500. package/dist/capabilities/memory-notice.d.ts +0 -138
  501. package/dist/capabilities/memory-notice.js +0 -64
  502. package/dist/capabilities/prompt.d.ts +0 -17
  503. package/dist/capabilities/prompt.js +0 -6
  504. package/dist/mcp-content-origin.d.ts +0 -34
  505. package/dist/mcp-content-origin.js +0 -10
  506. package/dist/tool-axis-words.d.ts +0 -27
  507. package/dist/tool-axis-words.js +0 -9
  508. package/dist/wire-name-bound.d.ts +0 -14
  509. package/dist/wire-name-bound.js +0 -13
@@ -1,5 +1,4 @@
1
- import { type MemoryBackend, type RunnerDeps } from "@sema-agent/core";
2
- import type { PromptsDomainFaces } from "../prompts-domain-validate.js";
1
+ import { type MemoryBackend } from "@sema-agent/core";
3
2
  import { SessionEnvironmentSelection, selectEnvironmentTool } from "../capabilities/select-environment-tool.js";
4
3
  import { sendUserFileTool } from "../capabilities/send-user-file-tool.js";
5
4
  import { selectScenario } from "../capabilities/scenarios.js";
@@ -17,6 +16,7 @@ import type { StoreBackend } from "../plugins/store-backend.js";
17
16
  import { type TaskAttachmentStore } from "../plugins/task-attachment-store.js";
18
17
  import { type createPrincipalEntitlementsClient } from "../runtime-caps-resolver.js";
19
18
  import { type OwnerAwareSessionStore } from "../security.js";
19
+ import type { MemorySyncRunner } from "../memory-sync-client.js";
20
20
  import type { RunnerDepsOnAsk } from "./runner-deps.js";
21
21
  type PrincipalCaps = ReturnType<typeof createPrincipalEntitlementsClient>;
22
22
  /** `resolveSpec` 原先从 `main()` 闭包里拿到的全部 boot 局部量。 */
@@ -28,8 +28,6 @@ export interface ResolveSpecCtx {
28
28
  scenarios: Record<string, ReturnType<typeof selectScenario>>;
29
29
  principalCaps: PrincipalCaps | undefined;
30
30
  centerRuntimeCapsResolver: PrincipalCaps["resolveRuntimeCaps"] | undefined;
31
- /** 活引用(adoptCenterPrompts 每次采用换引用)—— 见文件头「位置即契约」。 */
32
- getCenterPrompts: () => PromptsDomainFaces | undefined;
33
31
  /** 活引用(registry 热应用换引用)—— 见文件头「位置即契约」。 */
34
32
  getKeyResolver: () => ReturnType<typeof createKeyResolver>;
35
33
  taskAttachmentStore: TaskAttachmentStore | undefined;
@@ -59,6 +57,8 @@ export interface ResolveSpecCtx {
59
57
  backend: MemoryBackend;
60
58
  root: string;
61
59
  } | undefined;
60
+ /** S-640:记忆同步腿(开 `MEMORY_SYNC_*` 且记忆引擎接线时在场)—— 项目层准备一步把本任务的项目层交给它跟踪(`memory-project-layer.ts`)。 */
61
+ memorySyncRunner: MemorySyncRunner | undefined;
62
62
  durableEnabled: boolean;
63
63
  /** [ref] ([ref] 案二):活体 AskUserQuestion 面(QuestionCoordinator 的判决探针切面)。在场(=
64
64
  * ASK_QUESTION_ENABLED)时 durable question 门按活流上下文分腿、spec 不再 stamp QUESTION_AWAITS_RESUME
@@ -77,7 +77,6 @@ export interface ResolveSpecCtx {
77
77
  approverSeat: RunnerDepsOnAsk | undefined;
78
78
  approvalExemptionStore: ReturnType<StoreBackend["approvalExemption"]> | undefined;
79
79
  checkpointStore: ReturnType<NonNullable<StoreBackend["checkpoint"]>> | undefined;
80
- deploymentHooks: NonNullable<RunnerDeps["hooks"]>;
81
80
  imageIndex: ReturnType<NonNullable<StoreBackend["imageIndex"]>> | undefined;
82
81
  perTaskImage: PerTaskImageRegistry;
83
82
  sessionEnvSelection: SessionEnvironmentSelection;
@@ -1,25 +1,23 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { NodeExecutionEnv, QUESTION_AWAITS_RESUME, WRITE_EXEMPT_DIR_COVERS_ROOT_CODE, deriveAskEffective, expandTiers, modePolicyOf, resolveAskSeamForm } from "@sema-agent/core";
3
+ import { NodeExecutionEnv, QUESTION_AWAITS_RESUME, deriveAskEffective, expandTiers, modePolicyOf, resolveAskSeamForm } from "@sema-agent/core";
4
4
  import { cappedCeiling } from "../budget.js";
5
5
  import { recordFailOpen } from "../observability/fail-open.js";
6
- import { centerPromptProvider, centerIdentityAssembled } from "../capabilities/center-prompts.js";
7
6
  import { SessionEnvironmentSelection, selectEnvironmentTool } from "../capabilities/select-environment-tool.js";
8
7
  import { sendUserFileTool } from "../capabilities/send-user-file-tool.js";
9
- import { createScenarioGate, mergeUserSkills, selectScenario } from "../capabilities/scenarios.js";
8
+ import { buildExcludeToolsSeat, buildPromptSeats, createScenarioGate, mergeUserSkills, selectScenario } from "../capabilities/scenarios.js";
10
9
  import { stampHandsLane, toolPolicyForHands } from "../capabilities/hands-lane.js";
11
- import { buildNoticeLaneFacts, noPersistentMemoryNotice, withNoPersistentMemoryNotice } from "../capabilities/memory-notice.js";
12
10
  import { applyLongtailDefer } from "../capabilities/tool-defer.js";
13
11
  import { assertGuardPatternsUsable, buildApprovalGrantNotice, buildOnlySensitiveBaselineWarning, createApprovalBaselinePolicy, createDeploymentGovernanceInputs } from "../deployment-governance.js";
14
12
  import { createDeploymentListExemption, gateIntentUnserviceableReason, singleUserAutoAcceptBaselineApplies } from "../approval.js";
15
13
  import { acceptShellScratchpadDir, buildEnvFacts, egressForRemoteExec, ensureScratchpadDir, resumeFactsForLane, scratchpadCoveringTaskRoot } from "../env-facts.js";
16
14
  import { FleetEventBus } from "../fleet/fleet-bus.js";
17
- import { composeHooks, createTaskHooks } from "../hooks/hook-runner.js";
15
+ import { createSettingsHooksRegistration, settingsHooksBudgetMs } from "../hooks/hook-runner.js";
18
16
  import { HOST_POSTURE_REFUSED_CODE, taskInheritEnvRefusal, taskWriteFaceRefusal } from "../hosted-posture.js";
19
17
  import { headerStr } from "../http/principal-gate.js";
20
18
  import { explicitOperatorOk } from "../http/server.js";
21
19
  import { isAtMentionable, matchCatalogModel, modelSupportsImages, refusedCatalogEntry, resolveTaskModel, selectableCatalog, terminalCatalogName } from "../model-select.js";
22
- import { modelUnavailableMessage } from "../model-entry-refusal.js";
20
+ import { echoModelRef, modelUnavailableMessage } from "../model-entry-refusal.js";
23
21
  import { PerTaskImageRegistry, resolveSandboxImageRef } from "../per-task-image.js";
24
22
  import { isRemoteScratchpadLane, remoteScratchpadDirFor } from "../plugins/remote-scratchpad.js";
25
23
  import { bindAttachmentsForTask } from "../plugins/task-attachment-store.js";
@@ -29,7 +27,9 @@ import { tightenGoverned } from "../governance-overrides.js";
29
27
  import { gateExecutionLane } from "../runtime-caps-resolver.js";
30
28
  import { applyRuntimeGovernance } from "../runtime-governance.js";
31
29
  import { HttpError, createCodedHttpError, encodeCheckpointScope } from "../security.js";
32
- import { memoryProjectKeyFor, memorySpecForRequest } from "../memory-scope.js";
30
+ import { sessionFaceReadOf } from "../session-incarnation.js";
31
+ import { memorySpecForRequest } from "../memory-scope.js";
32
+ import { createMemoryProjectLayers } from "../memory-project-layer.js";
33
33
  import { inheritEnvFieldIssue, singleMemberOffFieldIssue } from "../request-value-closure.js";
34
34
  import { a2aForScenario, mcpForScenario } from "../web-admin-client/facade.js";
35
35
  import { normalizeAttachments, normalizeResilience, normalizeResumeAtMode, normalizeSuggestNextPrompts, promptProfileFromBody, resolveTaskLimits, retainBackgroundProcessesFromBody, taskAgentsSpecFragment, toolMaterializeStrategyFromBody, allowToolsSpecFragment, toolNameListFromBody } from "../spec-fields.js";
@@ -39,18 +39,21 @@ import { assertRequestA2aUnlocked, resolveRequestA2a } from "../task-a2a.js";
39
39
  import { assertRequestMcpEntries, assertRequestMcpUnlocked, resolveRequestMcp } from "../task-mcp.js";
40
40
  import { storedToolAxesRereadM19 } from "../stored-request-tool-axes-m19.js";
41
41
  import { storedHooksRereadM20 } from "../stored-request-hooks-m20.js";
42
- import { MAX_SETTINGS_OUTPUT_STYLE_CHARS, REQUEST_SETTINGS_REFUSAL_PREFIX, acceptAppendSystemPrompt, applyTaskSettings, effectivePermissionMode, effectiveThinking, hasConstitutionAnchors, parseTaskSettings, taskHooksHonored, providerDropsAppend, settingsPermissionBucketIssue, withPermissionMode } from "../task-settings.js";
42
+ import { MAX_SETTINGS_OUTPUT_STYLE_CHARS, REQUEST_SETTINGS_REFUSAL_PREFIX, SETTINGS_RULE_REFUSAL_CODE, SettingsRuleRefusalError, acceptAppendSystemPrompt, applyTaskSettings, createWorkflowAskPolicy, effectivePermissionMode, effectiveThinking, parseTaskSettings, taskHooksHonored, settingsPermissionBucketIssue } from "../task-settings.js";
43
+ import { tightenOnlySeatIssue } from "../tighten-only-seats.js";
44
+ import { entryProblemsFacts } from "../entry-problems.js";
43
45
  import { inertToolListEntryOf } from "../rule-entry-list.js";
44
46
  import { TENANCY_WALL_CLOCK_BASE_SEC, enableForkFromBody, normalizeRetainSubagentSessions, selfOrchestrationFromBody } from "../task-workflow.js";
45
47
  import { redactSecrets } from "../trace/redact.js";
46
48
  import { DeferredSandboxPathEnv, isSandboxPathAdjudicationLane, sandboxPathEnvSlots } from "./deferred-sandbox-path-env.js";
47
- import { executionLaneCaps, executionLaneHomeDir, executionLaneOf } from "../execution-lane-caps.js";
49
+ import { executionLaneHomeDir, executionLaneOf, laneWiresExecutionEnv } from "../execution-lane-caps.js";
48
50
  import { effectiveMemoryPersistenceCapable } from "./memory-boundary.js";
49
51
  import { withUnattendedLeg } from "../unattended-permission-mode.js";
50
- import { memoryFaceMounted } from "../memory-scope.js";
52
+ import { fieldConflictFacts } from "../field-conflict.js";
51
53
  export function createResolveSpec(ctx) {
52
- const { config, logger, metrics, localRoot, scenarios, principalCaps, centerRuntimeCapsResolver, getCenterPrompts, getKeyResolver, taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner, hookLlm, hookAgent, fleetBus, hookWakeBus, resumeAnchorStore, ownerAware, taskLimitCaps, taskTimeoutSec, selectEnvTool, sendUserFileToolSpec, memoryEngine, durableEnabled, approvalExemptionStore, checkpointStore, deploymentHooks, imageIndex, perTaskImage, sessionEnvSelection, liveQuestionFace, approverSeat, lockedKeys, } = ctx;
54
+ const { config, logger, metrics, localRoot, scenarios, principalCaps, centerRuntimeCapsResolver, getKeyResolver, taskAttachmentStore, perSessionCwd, setSessionCwd, setSessionShellEnv, fenceSessionOwner, hookLlm, hookAgent, fleetBus, hookWakeBus, resumeAnchorStore, ownerAware, taskLimitCaps, taskTimeoutSec, selectEnvTool, sendUserFileToolSpec, memoryEngine, memorySyncRunner, durableEnabled, approvalExemptionStore, checkpointStore, imageIndex, perTaskImage, sessionEnvSelection, liveQuestionFace, approverSeat, lockedKeys, } = ctx;
53
55
  const scenarioGate = createScenarioGate({ config, scenarios, principalCaps, logger }, "enforce");
56
+ const readSessionFace = sessionFaceReadOf(ownerAware);
54
57
  assertGuardPatternsUsable(config);
55
58
  const onlySensitiveBaseline = buildOnlySensitiveBaselineWarning(config, {
56
59
  approvalSeat: durableEnabled ? "durable" : "absent",
@@ -62,6 +65,7 @@ export function createResolveSpec(ctx) {
62
65
  const sessionCwd = auth?.sessionId ? effectiveHostWorkspace(perSessionCwd.get(auth.sessionId), {}) : undefined;
63
66
  return sessionCwd ?? (config.remoteExec === undefined ? process.cwd() : undefined);
64
67
  };
68
+ const memoryProjectLayers = createMemoryProjectLayers({ backend: memoryEngine?.backend, syncRunner: memorySyncRunner, log: logger });
65
69
  if (onlySensitiveBaseline)
66
70
  logger.warn(onlySensitiveBaseline.event, onlySensitiveBaseline.fields);
67
71
  const approvalGrantNotice = buildApprovalGrantNotice(config);
@@ -84,7 +88,7 @@ export function createResolveSpec(ctx) {
84
88
  cwdHonored: cwdHonored(config),
85
89
  });
86
90
  if (conflict) {
87
- throw new HttpError(400, `cwd "${conflict.cwd.asSpelled}" is inside this session's scratchpad "${conflict.scratchpadDir.asSpelled}" — the scratchpad is the fs-write gate's EXEMPT directory, so a task rooted there would auto-approve every write under its own root and the engine refuses to build the gate at all (config.write_exempt_dir_covers_root). Point cwd at the project directory instead (or send no cwd and let the session keep the one it has): this session registers the cwd you send, so a task that happens not to mount the write gate would still leave every LATER task on this session rooted in the exemption. A workflow that really is meant to write without prompts says so with a knob that means it (a permission mode, an open write face) and still keeps its root outside the scratchpad — those knobs do not lift this refusal, because the conflict is between two fields of this request, not a permission level.`, { code: "request.field_conflict", extra: { cwd: conflict.cwd, scratchpadDir: conflict.scratchpadDir } });
91
+ throw new HttpError(400, `cwd "${conflict.cwd.asSpelled}" is inside this session's scratchpad "${conflict.scratchpadDir.asSpelled}" — the scratchpad is the fs-write gate's EXEMPT directory, so a task rooted there would auto-approve every write under its own root and the engine refuses to build the gate at all (config.write_exempt_dir_covers_root). Point cwd at the project directory instead (or send no cwd and let the session keep the one it has): this session registers the cwd you send, so a task that happens not to mount the write gate would still leave every LATER task on this session rooted in the exemption. A workflow that really is meant to write without prompts says so with a knob that means it (a permission mode, an open write face) and still keeps its root outside the scratchpad — those knobs do not lift this refusal, because the conflict is between two fields of this request, not a permission level.`, { code: "request.field_conflict", extra: { ...fieldConflictFacts("scratchpad_root", body.scratchpadDir === conflict.scratchpadDir.asSpelled ? ["cwd", "scratchpadDir"] : ["cwd"]), cwd: conflict.cwd, scratchpadDir: conflict.scratchpadDir } });
88
92
  }
89
93
  }
90
94
  const offFieldIssue = singleMemberOffFieldIssue(body);
@@ -112,6 +116,11 @@ export function createResolveSpec(ctx) {
112
116
  if (bucketIssue)
113
117
  throw new HttpError(400, bucketIssue.message, { code: "request.field_invalid", extra: bucketIssue.fields });
114
118
  }
119
+ {
120
+ const seatIssue = tightenOnlySeatIssue(body.settings);
121
+ if (seatIssue)
122
+ throw new HttpError(400, seatIssue.message, { code: "request.field_invalid", extra: seatIssue.fields });
123
+ }
115
124
  {
116
125
  const replay = opts?.leg === "resume";
117
126
  const inertList = inertToolListEntryOf(body, replay ? ["deny"] : undefined);
@@ -139,8 +148,9 @@ export function createResolveSpec(ctx) {
139
148
  }
140
149
  const lane = bindSettingsCwdEnvAndModel(body, auth, gated, opts);
141
150
  const anchors = await resolveHistoryAnchors(body, auth);
142
- const spec = assembleSpecLiteral(body, auth, req, opts, { ...gated, ...lane, ...anchors }, effMode);
143
- const folded = await foldGovernanceAndSettings(body, auth, spec, gated, effMode);
151
+ const projectKey = memoryEngine ? await memoryProjectLayers.prepare(config, auth?.memoryScope, realTaskRootOf(auth)) : undefined;
152
+ const spec = assembleSpecLiteral(body, auth, req, opts, { ...gated, ...lane, ...anchors, projectKey }, effMode);
153
+ const folded = await foldGovernanceAndSettings(body, auth, spec, gated);
144
154
  const final = await applyImageFactsAndRouting(body, auth, folded.governed, {
145
155
  scenarioName: gated.scenarioName,
146
156
  scratchpadDir: folded.scratchpadDir,
@@ -152,20 +162,10 @@ export function createResolveSpec(ctx) {
152
162
  const gateScenarioAndAppend = async (body, auth, opts) => {
153
163
  const scenarioName = await scenarioGate(auth?.principal, body.scenario);
154
164
  gateExecutionLane(await principalCaps?.executionRuling(auth?.principal), executionLaneOf(config.remoteExec?.provider), logger);
155
- const cap = selectScenario(scenarios, scenarioName)(body, auth?.principal, auth?.sessionId !== undefined ? { sessionId: auth.sessionId } : {});
156
- const centerDecls = getCenterPrompts()?.declarations;
157
- const appendLessPack = centerDecls
158
- ? centerIdentityAssembled(centerDecls, scenarioName, hasConstitutionAnchors)
159
- : providerDropsAppend(cap.promptProvider, typeof body.systemPrompt === "string" ? body.systemPrompt : undefined);
160
- const acceptedAppend = acceptAppendSystemPrompt(body.appendSystemPrompt, (detail) => logger.warn("append_system_prompt_dropped", { detail, sessionId: auth?.sessionId ?? null }), appendLessPack);
165
+ const cap = selectScenario(scenarios, scenarioName)(body, auth?.principal, auth?.sessionId !== undefined ? { sessionId: auth.sessionId, delegationRoot: { sessionId: auth.sessionId, incarnation: (await readSessionFace?.(auth.sessionId))?.incarnation ?? null } } : {});
166
+ const acceptedAppend = acceptAppendSystemPrompt(body.appendSystemPrompt, (detail) => logger.warn("append_system_prompt_dropped", { detail, sessionId: auth?.sessionId ?? null }));
161
167
  const objective = typeof body.objective === "string" ? body.objective : "";
162
168
  const parsedSettings = parseTaskSettings(body.settings, opts?.leg === "fresh" || !taskHooksHonored(config) ? {} : { storedHooksReread: storedHooksRereadM20(new Date().toISOString().slice(0, 10)) });
163
- if (opts?.leg === "fresh" && appendLessPack) {
164
- const riderPresent = typeof body.appendSystemPrompt === "string" && body.appendSystemPrompt.length > 0;
165
- if (riderPresent || parsedSettings.settings?.outputStyle) {
166
- throw new HttpError(400, `${riderPresent ? "appendSystemPrompt" : "settings.outputStyle"} is not supported when the effective prompt is already assembled (constitution anchors in systemPrompt, or a center assembled-identity pack for this scenario): the assembler's pass-through path cannot mount the append slot — fold it into the assembled prompt instead`);
167
- }
168
- }
169
169
  if (parsedSettings.deferred.length > 0) {
170
170
  logger.warn("task_settings_deferred", { fields: parsedSettings.deferred, sessionId: auth?.sessionId ?? null });
171
171
  }
@@ -212,7 +212,7 @@ export function createResolveSpec(ctx) {
212
212
  }
213
213
  }
214
214
  }
215
- return { scenarioName, cap, hands: cap.hands, centerDecls, appendLessPack, acceptedAppend, objective, parsedSettings, attachmentNotice };
215
+ return { scenarioName, cap, hands: cap.hands, acceptedAppend, objective, parsedSettings, attachmentNotice };
216
216
  };
217
217
  const bindSettingsCwdEnvAndModel = (body, auth, gated, opts) => {
218
218
  const { objective, parsedSettings } = gated;
@@ -250,7 +250,7 @@ export function createResolveSpec(ctx) {
250
250
  logger.warn("task_hooks_ignored", { honored: false, sessionId: auth?.sessionId ?? null });
251
251
  return undefined;
252
252
  }
253
- return createTaskHooks(hc, {
253
+ return createSettingsHooksRegistration(hc, {
254
254
  logger,
255
255
  sessionId: auth?.sessionId ?? "",
256
256
  cwd: (auth?.sessionId ? perSessionCwd.get(auth.sessionId) : undefined) ?? process.cwd(),
@@ -270,7 +270,7 @@ export function createResolveSpec(ctx) {
270
270
  : false,
271
271
  }
272
272
  : {}),
273
- });
273
+ }, settingsHooksBudgetMs(config));
274
274
  })();
275
275
  const rawAddDirs = body.additionalDirectories;
276
276
  const additionalDirectories = cwdHonored(config) ? parseAdditionalDirectories(rawAddDirs) : undefined;
@@ -287,22 +287,22 @@ export function createResolveSpec(ctx) {
287
287
  if (picked.unavailable !== undefined) {
288
288
  const { requested, name, refusal, source } = picked.unavailable;
289
289
  if (opts?.leg === "fresh") {
290
- throw new HttpError(400, modelUnavailableMessage(source === "mention" ? "@-mention" : "model", requested.slice(0, 120), name, refusal), { code: "request.model_unavailable" });
290
+ throw new HttpError(400, modelUnavailableMessage(source === "mention" ? "@-mention" : "model", requested, name, refusal), { code: "request.model_unavailable" });
291
291
  }
292
292
  metrics.inc("task_model_unavailable_fallback_total");
293
- logger.warn("task_model_unavailable_fallback", { requested: requested.slice(0, 120), name, code: refusal.code, source, fallback: picked.model, sessionId: auth?.sessionId ?? null });
293
+ logger.warn("task_model_unavailable_fallback", { requested: echoModelRef(requested), name, code: refusal.code, source, fallback: picked.model, sessionId: auth?.sessionId ?? null });
294
294
  }
295
295
  if (picked.notAllowed !== undefined) {
296
296
  const { requested, resolved, source } = picked.notAllowed;
297
297
  if (opts?.leg === "fresh") {
298
- throw new HttpError(400, `model "${requested.slice(0, 120)}" is not @-mentionable on this deployment (it resolves to catalog model "${resolved}") — which models can be @-mentioned is configured by the operator (models.atMention)`, { code: "request.model_not_allowed" });
298
+ throw new HttpError(400, `model "${echoModelRef(requested)}" is not @-mentionable on this deployment (it resolves to catalog model "${resolved}") — which models can be @-mentioned is configured by the operator (models.atMention)`, { code: "request.model_not_allowed" });
299
299
  }
300
300
  metrics.inc("task_model_not_allowlisted_resume_total");
301
- logger.warn("task_model_not_allowlisted_resume", { requested: requested.slice(0, 120), resolved, source, sessionId: auth?.sessionId ?? null, note: "resumed leg keeps running the model it was started on — the allowlist gates fresh picks only" });
301
+ logger.warn("task_model_not_allowlisted_resume", { requested: echoModelRef(requested), resolved, source, sessionId: auth?.sessionId ?? null, note: "resumed leg keeps running the model it was started on — the allowlist gates fresh picks only" });
302
302
  }
303
303
  if (picked.unknownExplicit !== undefined) {
304
304
  metrics.inc("task_model_unknown_fallback_total");
305
- logger.warn("task_model_unknown_fallback", { requested: picked.unknownExplicit.slice(0, 120), fallback: picked.model, sessionId: auth?.sessionId ?? null });
305
+ logger.warn("task_model_unknown_fallback", { requested: echoModelRef(picked.unknownExplicit), fallback: picked.model, sessionId: auth?.sessionId ?? null });
306
306
  }
307
307
  if (Array.isArray(body.images) && body.images.length > 0 && !modelSupportsImages(wireCatalog[picked.model])) {
308
308
  metrics.inc("images_omitted_total", { model: picked.model });
@@ -351,10 +351,11 @@ export function createResolveSpec(ctx) {
351
351
  return deriveAskEffective(askForm.form, "unresolved") === "human_reachable";
352
352
  };
353
353
  const assembleSpecLiteral = (body, auth, req, opts, parts, effMode) => {
354
- const { scenarioName, cap, hands, centerDecls, acceptedAppend, parsedSettings, attachmentNotice, taskHooks, additionalDirectories, additionalReadDirectories, wireCatalog, picked, resumeAtEntryId, rewindFilesToEntryId, s4DefaultScopes, } = parts;
354
+ const { scenarioName, cap, hands, acceptedAppend, parsedSettings, attachmentNotice, taskHooks, additionalDirectories, additionalReadDirectories, wireCatalog, picked, resumeAtEntryId, rewindFilesToEntryId, s4DefaultScopes, projectKey, } = parts;
355
+ const storedToolAxes = opts?.leg === "fresh" ? undefined : storedToolAxesRereadM19(new Date().toISOString().slice(0, 10));
355
356
  const spec = {
356
357
  objective: attachmentNotice ? `${picked.cleanedObjective}\n\n${attachmentNotice}` : picked.cleanedObjective,
357
- systemPrompt: typeof body.systemPrompt === "string" ? body.systemPrompt : undefined,
358
+ ...buildPromptSeats(scenarioName, cap.prompt, typeof body.systemPrompt === "string" ? body.systemPrompt : undefined),
358
359
  appendSystemPrompt: acceptedAppend,
359
360
  ...(body.outputStyle !== undefined ? { outputStyle: body.outputStyle } : {}),
360
361
  sessionId: auth?.sessionId,
@@ -392,7 +393,7 @@ export function createResolveSpec(ctx) {
392
393
  ? { retainBackgroundProcesses: true }
393
394
  : {}),
394
395
  ...(body.excludeAllTools === true ? { excludeAllTools: true } : {}),
395
- ...(() => { const v = toolNameListFromBody(body.excludeTools); return v ? { excludeTools: v } : {}; })(),
396
+ ...buildExcludeToolsSeat(cap.excludeTools, toolNameListFromBody(body.excludeTools)),
396
397
  ...allowToolsSpecFragment(body.allowTools),
397
398
  ...(() => { const v = toolNameListFromBody(body.deferTools); return v ? { deferTools: v } : {}; })(),
398
399
  ...(() => { const v = promptProfileFromBody(body.promptProfile); return v ? { promptProfile: v } : {}; })(),
@@ -401,10 +402,10 @@ export function createResolveSpec(ctx) {
401
402
  ...(declaresInteractivePosture(body, req, opts) ? { interactionPosture: "interactive" } : {}),
402
403
  ...(body.approvalReach !== undefined ? { approvalReach: body.approvalReach } : {}),
403
404
  ...(typeof body.oneShot === "boolean" ? { oneShot: body.oneShot } : {}),
404
- resilience: normalizeResilience(body.resilience, explicitOperatorOk(auth?.principal, config.operatorPrincipals)),
405
+ resilience: normalizeResilience(body.resilience, explicitOperatorOk(auth?.principal, config)),
405
406
  finalVerification: cap.finalVerification === true || body.finalVerification === true ? true : undefined,
406
407
  attachments: normalizeAttachments(body.attachments),
407
- ...(taskHooks ? { hooks: composeHooks(deploymentHooks, taskHooks) } : {}),
408
+ ...(taskHooks ? { mods: [taskHooks] } : {}),
408
409
  model: picked.model,
409
410
  ...((() => {
410
411
  if (typeof body.compactionModel !== "string" || body.compactionModel.length === 0)
@@ -412,23 +413,23 @@ export function createResolveSpec(ctx) {
412
413
  const cm = matchCatalogModel(body.compactionModel, wireCatalog, config.modelRefusals);
413
414
  const refusedCm = cm === undefined ? refusedCatalogEntry(body.compactionModel, config.modelRefusals) : undefined;
414
415
  if (refusedCm !== undefined && opts?.leg === "fresh") {
415
- throw new HttpError(400, modelUnavailableMessage("compactionModel", body.compactionModel.slice(0, 120), refusedCm.name, refusedCm.refusal), { code: "request.model_unavailable" });
416
+ throw new HttpError(400, modelUnavailableMessage("compactionModel", body.compactionModel, refusedCm.name, refusedCm.refusal), { code: "request.model_unavailable" });
416
417
  }
417
418
  if (cm === undefined) {
418
419
  if (opts?.leg === "fresh") {
419
- throw new HttpError(400, `unknown compactionModel "${body.compactionModel.slice(0, 120)}" — not in the configured catalog (name, tier word, or id; a catalog refresh may have removed it mid-request)`);
420
+ throw new HttpError(400, `unknown compactionModel "${echoModelRef(body.compactionModel)}" — not in the configured catalog (name, tier word, or id; a catalog refresh may have removed it mid-request)`);
420
421
  }
421
422
  metrics.inc("task_model_unknown_fallback_total");
422
- logger.warn("compaction_model_unknown_fallback", { requested: body.compactionModel.slice(0, 120), sessionId: auth?.sessionId ?? null });
423
+ logger.warn("compaction_model_unknown_fallback", { requested: echoModelRef(body.compactionModel), sessionId: auth?.sessionId ?? null });
423
424
  return {};
424
425
  }
425
426
  if (!isAtMentionable(cm, wireCatalog, config.atMention, config.modelRefusals)) {
426
427
  const terminal = terminalCatalogName(cm, wireCatalog, config.modelRefusals) ?? cm;
427
428
  if (opts?.leg === "fresh") {
428
- throw new HttpError(400, `compactionModel "${body.compactionModel.slice(0, 120)}" is not @-mentionable on this deployment (it resolves to catalog model "${terminal}") — which models can be @-mentioned is configured by the operator (models.atMention)`, { code: "request.model_not_allowed" });
429
+ throw new HttpError(400, `compactionModel "${echoModelRef(body.compactionModel)}" is not @-mentionable on this deployment (it resolves to catalog model "${terminal}") — which models can be @-mentioned is configured by the operator (models.atMention)`, { code: "request.model_not_allowed" });
429
430
  }
430
431
  metrics.inc("task_model_not_allowlisted_resume_total");
431
- logger.warn("task_model_not_allowlisted_resume", { requested: body.compactionModel.slice(0, 120), resolved: terminal, source: "compaction", sessionId: auth?.sessionId ?? null, note: "resumed leg keeps the compaction model it was started with — the allowlist gates fresh picks only" });
432
+ logger.warn("task_model_not_allowlisted_resume", { requested: echoModelRef(body.compactionModel), resolved: terminal, source: "compaction", sessionId: auth?.sessionId ?? null, note: "resumed leg keeps the compaction model it was started with — the allowlist gates fresh picks only" });
432
433
  }
433
434
  return { compactionModel: cm };
434
435
  })()),
@@ -471,7 +472,7 @@ export function createResolveSpec(ctx) {
471
472
  })(),
472
473
  ...(config.requirePrincipal !== true ? { backgroundScope: "session" } : {}),
473
474
  memory: memoryEngine
474
- ? memorySpecForRequest(auth?.memoryScope, memoryProjectKeyFor(config, auth?.memoryScope, realTaskRootOf(auth)), body.memoryWrite, s4DefaultScopes, { multiTenant: config.requirePrincipal === true }, { memory: body.memory, memoryCapture: body.memoryCapture })
475
+ ? memorySpecForRequest(auth?.memoryScope, projectKey, body.memoryWrite, s4DefaultScopes, { multiTenant: config.requirePrincipal === true }, { memory: body.memory, memoryCapture: body.memoryCapture })
475
476
  : undefined,
476
477
  ...((v) => (v !== undefined ? { memoryPersistenceCapable: v } : {}))(effectiveMemoryPersistenceCapable(config)),
477
478
  tools: ((base) => {
@@ -483,9 +484,8 @@ export function createResolveSpec(ctx) {
483
484
  ...(() => { const v = toolNameListFromBody(body.userInvokedSkills); return v ? { userInvokedSkills: v } : {}; })(),
484
485
  ...(parsedSettings.settings?.skillListingBudgetFraction !== undefined ? { skillListingBudgetFraction: parsedSettings.settings.skillListingBudgetFraction } : {}),
485
486
  ...(parsedSettings.settings?.skillListingMaxDescChars !== undefined ? { skillListingMaxDescChars: parsedSettings.settings.skillListingMaxDescChars } : {}),
486
- mcp: resolveRequestMcp(mcpForScenario(config.mcpServers, scenarioName), body.mcpServers, config, logger, opts?.onNotice !== undefined ? { sessionId: auth?.sessionId, emit: opts.onNotice } : undefined, opts?.leg === "fresh" ? undefined : storedToolAxesRereadM19(new Date().toISOString().slice(0, 10))),
487
- a2a: resolveRequestA2a(a2aForScenario(config.a2aPeers, scenarioName), body.a2aPeers, config, logger),
488
- promptProvider: centerDecls ? centerPromptProvider(centerDecls, scenarioName) : cap.promptProvider,
487
+ mcp: resolveRequestMcp(mcpForScenario(config.mcpServers, scenarioName), body.mcpServers, config, logger, opts?.onNotice !== undefined ? { sessionId: auth?.sessionId, emit: opts.onNotice } : undefined, storedToolAxes),
488
+ a2a: resolveRequestA2a(a2aForScenario(config.a2aPeers, scenarioName), body.a2aPeers, config, logger, opts?.leg === "fresh" ? "fresh" : "resume", storedToolAxes),
489
489
  toolPolicy: toolPolicyForHands(hands, durableEnabled
490
490
  ? createApprovalBaselinePolicy(config, {
491
491
  kind: "durable",
@@ -518,8 +518,8 @@ export function createResolveSpec(ctx) {
518
518
  };
519
519
  return spec;
520
520
  };
521
- const foldGovernanceAndSettings = async (body, auth, spec, gated, effMode) => {
522
- const { appendLessPack, acceptedAppend, parsedSettings } = gated;
521
+ const foldGovernanceAndSettings = async (body, auth, spec, gated) => {
522
+ const { acceptedAppend, parsedSettings } = gated;
523
523
  const hostSemanticsLane = !isSandboxPathAdjudicationLane(config.remoteExec?.provider);
524
524
  const laneHomeBase = () => {
525
525
  const home = executionLaneHomeDir(config);
@@ -546,12 +546,7 @@ export function createResolveSpec(ctx) {
546
546
  };
547
547
  const governedBase = applyRuntimeGovernance(spec, createDeploymentGovernanceInputs(config, pathAdjudication));
548
548
  let governed = governedBase;
549
- let effectiveSettings = effMode ? withPermissionMode(parsedSettings.settings, effMode) : parsedSettings.settings;
550
- if (appendLessPack && effectiveSettings?.outputStyle) {
551
- logger.warn("output_style_dropped", { detail: "the effective prompt pack cannot mount the append slot (already-assembled systemPrompt or center assembled-identity declaration)", sessionId: auth?.sessionId ?? null });
552
- const { outputStyle: _dropped, ...rest } = effectiveSettings;
553
- effectiveSettings = Object.keys(rest).length > 0 ? rest : undefined;
554
- }
549
+ let effectiveSettings = parsedSettings.settings;
555
550
  if (effectiveSettings?.outputStyle && acceptedAppend && acceptedAppend.length + 2 + effectiveSettings.outputStyle.length > MAX_SETTINGS_OUTPUT_STYLE_CHARS) {
556
551
  logger.warn("output_style_dropped", { detail: `combined append carriers exceed the ${MAX_SETTINGS_OUTPUT_STYLE_CHARS} cap (rider ${acceptedAppend.length} + style ${effectiveSettings.outputStyle.length}) — style dropped (pre-cap stored body on a resume leg?)`, sessionId: auth?.sessionId ?? null });
557
552
  const { outputStyle: _dropped2, ...rest2 } = effectiveSettings;
@@ -567,74 +562,30 @@ export function createResolveSpec(ctx) {
567
562
  ? await ensureScratchpadDir(config.localDataRoot ?? localRoot, auth.sessionId, (msg, meta) => logger.warn(msg, { ...(meta ?? {}), sessionId: auth.sessionId }))
568
563
  : undefined);
569
564
  if (effectiveSettings) {
570
- const gateCommon = {
571
- ...(approvalExemptionStore && auth?.sessionId
572
- ? {
573
- isExempt: async (toolName) => {
574
- const hit = await approvalExemptionStore.has(auth.sessionId, toolName);
575
- if (hit)
576
- logger.info("fs_write_gate_exempted", { toolName, sessionId: auth.sessionId });
577
- return hit;
578
- },
579
- }
580
- : {}),
565
+ const ruleBases = {
566
+ ...(pathAdjudication.taskRoot !== undefined ? { taskRoot: pathAdjudication.taskRoot } : {}),
567
+ ...(pathAdjudication.taskHome !== undefined ? { taskHome: pathAdjudication.taskHome } : {}),
581
568
  };
582
- const fsWriteGate = hostSemanticsLane
583
- ? {
584
- env: pathAdjudication.env,
585
- ...(pathAdjudication.cwd !== undefined ? { cwd: pathAdjudication.cwd } : {}),
586
- ...(pathAdjudication.taskRoot !== undefined ? { taskRoot: pathAdjudication.taskRoot } : {}),
587
- ...(pathAdjudication.taskHome !== undefined ? { taskHome: pathAdjudication.taskHome } : {}),
588
- ...(scratchpadDir ? { scratchpadDir } : {}),
589
- ...gateCommon,
590
- }
591
- :
592
- (() => {
593
- const sandboxScratchpadDir = isRemoteScratchpadLane(config.remoteExec?.provider) ? remoteScratchpadDirFor(auth?.sessionId) : undefined;
594
- return {
595
- env: pathAdjudication.env,
596
- ...(pathAdjudication.taskHome !== undefined ? { taskHome: pathAdjudication.taskHome } : {}),
597
- ...gateCommon,
598
- ...(sandboxScratchpadDir ? { scratchpadDir: sandboxScratchpadDir } : {}),
599
- ...(gateCommon.isExempt
600
- ? {
601
- isExempt: (toolName, canonicalPath) => canonicalPath.startsWith("/") ? gateCommon.isExempt(toolName) : false,
602
- }
603
- : {}),
604
- };
605
- })();
606
- const workflowGate = approvalExemptionStore && auth?.sessionId
607
- ? {
608
- isExempt: async (toolName) => {
609
- const hit = await approvalExemptionStore.has(auth.sessionId, toolName);
610
- if (hit)
611
- logger.info("workflow_gate_exempted", { toolName, sessionId: auth.sessionId });
612
- return hit;
613
- },
614
- }
615
- : undefined;
616
569
  try {
617
- governed = applyTaskSettings(governedBase, effectiveSettings, fsWriteGate, workflowGate);
570
+ governed = applyTaskSettings(governedBase, effectiveSettings, ruleBases);
618
571
  }
619
572
  catch (e) {
620
- if (e.code === WRITE_EXEMPT_DIR_COVERS_ROOT_CODE) {
621
- throw new HttpError(400, e.message, {
622
- code: "request.field_conflict",
623
- ...(e.detail !== undefined ? { extra: { writeExemptDirCoversRoot: e.detail } } : {}),
624
- });
625
- }
573
+ if (e instanceof SettingsRuleRefusalError)
574
+ throw new HttpError(422, `${REQUEST_SETTINGS_REFUSAL_PREFIX}${e.message}`, { code: SETTINGS_RULE_REFUSAL_CODE, extra: { ...entryProblemsFacts(e.problems) } });
626
575
  throw new HttpError(422, `${REQUEST_SETTINGS_REFUSAL_PREFIX}${e.message}`);
627
576
  }
628
577
  }
629
- const notice = noPersistentMemoryNotice({
630
- memoryFaceMounted: memoryFaceMounted(governed.memory),
631
- declaredCapable: effectiveMemoryPersistenceCapable(config),
632
- hands: gated.hands,
633
- handsReadOnly: governed.handsReadOnly === true,
634
- ...buildNoticeLaneFacts(executionLaneOf(config.remoteExec?.provider)),
635
- });
636
- if (notice !== "silent") {
637
- governed = { ...governed, promptProvider: withNoPersistentMemoryNotice(governed.promptProvider, notice) };
578
+ if (governed.selfOrchestration === true) {
579
+ governed = tightenGoverned(governed, {
580
+ toolPolicy: createWorkflowAskPolicy(approvalExemptionStore && auth?.sessionId
581
+ ? async (toolName) => {
582
+ const hit = await approvalExemptionStore.has(auth.sessionId, toolName);
583
+ if (hit)
584
+ logger.info("workflow_gate_exempted", { toolName, sessionId: auth.sessionId });
585
+ return hit;
586
+ }
587
+ : undefined),
588
+ });
638
589
  }
639
590
  return { governed, scratchpadDir, hostSemanticsLane };
640
591
  };
@@ -645,13 +596,13 @@ export function createResolveSpec(ctx) {
645
596
  let resolvedImageCaps;
646
597
  if (taskImageProfile !== undefined) {
647
598
  if (config.remoteExec?.provider !== "k8s") {
648
- throw new HttpError(400, "sandboxImageProfile is only supported on the k8s sandbox backend");
599
+ throw createCodedHttpError(501, "capability.k8s_lane_required", "sandboxImageProfile is only supported on the k8s sandbox backend");
649
600
  }
650
601
  if (!imageIndex) {
651
- throw new HttpError(400, "sandboxImageProfile requires the image index (web-admin backend not configured)");
602
+ throw createCodedHttpError(501, "capability.image_index_required", "sandboxImageProfile requires the sandbox-image-pool, which needs a SQL store backend (DB_BACKEND=mysql|pg) — this deployment's store wires no image index");
652
603
  }
653
604
  if (!auth?.sessionId) {
654
- throw new HttpError(400, "sandboxImageProfile requires a resolved session");
605
+ throw createCodedHttpError(400, "request.precondition_unmet", "sandboxImageProfile requires a resolved session");
655
606
  }
656
607
  const capsNeeded = Array.isArray(body.capabilitiesNeeded)
657
608
  ? body.capabilitiesNeeded.filter((c) => typeof c === "string")
@@ -659,11 +610,11 @@ export function createResolveSpec(ctx) {
659
610
  const resolved = await resolveSandboxImageRef({
660
611
  profile: taskImageProfile,
661
612
  ...(capsNeeded && capsNeeded.length > 0 ? { capabilitiesNeeded: capsNeeded } : {}),
662
- viewer: { operator: explicitOperatorOk(auth.principal, config.operatorPrincipals), tenantId: auth.principal ?? null },
613
+ viewer: { operator: explicitOperatorOk(auth.principal, config), tenantId: auth.principal ?? null },
663
614
  index: imageIndex,
664
615
  });
665
616
  if (!resolved.ok)
666
- throw new HttpError(resolved.status, resolved.message);
617
+ throw createCodedHttpError(resolved.status, resolved.errorCode, resolved.message);
667
618
  perTaskImage.set(auth.sessionId, resolved.ref);
668
619
  resolvedImageCaps = resolved.capabilities;
669
620
  }
@@ -690,7 +641,7 @@ export function createResolveSpec(ctx) {
690
641
  const isolatedExecEnv = isIsolatedExecEnv(config.remoteExec?.provider, config.remoteExec?.provider === "k8s" ? config.remoteExec.runtimeClass : undefined);
691
642
  const decision = routeServiceTask({
692
643
  isolatedExecEnv,
693
- hasExecutionEnv: executionLaneCaps(executionLaneOf(config.remoteExec?.provider)).coreRemoteExecutionEnv === "supported",
644
+ hasExecutionEnv: laneWiresExecutionEnv(executionLaneOf(config.remoteExec?.provider)),
694
645
  ...(config.autonomy ? { autonomy: config.autonomy } : {}),
695
646
  });
696
647
  logger.info("orchestration_routed", { mode: decision.mode, reason: decision.reason, sessionId: auth?.sessionId ?? null });
@@ -56,13 +56,16 @@ import type { MailboxRecipientLifecycle } from "../plugins/mailbox-recipient-lif
56
56
  export type RunnerDepsOnAsk = (req: Parameters<ToolApprovalCoordinator["ask"]>[0], signal?: AbortSignal) => Promise<AskOutcome>;
57
57
  export declare function createRunnerDepsOnAsk(toolApproval: ToolApprovalCoordinator | undefined): RunnerDepsOnAsk | undefined;
58
58
  /** [ref] 件⑤:core `onError(phase:"config")` 的 `classification` 已知词表。⚠️ core d.ts(`RunnerDeps.onError` 注)只登记了
59
- * prompt-cache 相的五词,config 相的词**只在 dist js 出现**(7.35.0 亲扫 dist 下全部 js 的 `phase: "config"` 发射点:四词——
60
- * `interaction-posture-refused`(prepare-config-doors)/ `memory-tools-not-mounted` / `shared-memory-not-mounted`
61
- * (prepare-defer-classify / prepare-project-context)/ `sandbox-admission-unavailable`(prepare-policy-chain));
59
+ * prompt-cache 相的五词,config 相的词**只在 dist js 出现**,发射点有两种写法:字面量(`classification: "<词>"`)与经变量 / 表行发射
60
+ * (`classification: <变量>` 取自同文件的字面量初值,或 `classification: <表>.classification` 取自同文件的表行)。7.52.0 亲扫六词 ——
61
+ * `interaction-posture-refused`(prepare-config-doors,字面量)/ `sandbox-admission-unavailable`(prepare-policy-chain,字面量)/
62
+ * `memory-tools-not-mounted` / `shared-memory-not-mounted`(core 7.52.0 起一只铸点 `announceMemoryNotMounted`,词在
63
+ * announce-once-ledger 的表行)/ `file-history-no-store` / `file-history-no-env`(prepare-file-history 的 `livenessArm` 变量,core 7.30 起
64
+ * 就在 —— 只认字面量的旧扫描看不见它们,两词一直被标 `classificationKnown:false`、指标折 `unknown`,本版随扫描改读两种写法一并收进表)。
62
65
  * S-877:第五词 `shell-gate-off` 随 core 7.34.0 的 off 车道一起退役(引擎侧零发射点),同批删 —— 它唯一的本仓消费者
63
66
  * (「本 session 显式 bypass ⇒ 降级 info」那条回查腿与 `boot/session-shell-gate-registry.ts` 登记簿)一并删干净。所以这是「按实现亲读」的开集快照,不是 core 类型闭集——词表外的值原样进日志并标
64
67
  * `classificationKnown:false`(指标标签折 `unknown`),不吞不编;与安装包的锁步由 test/boot-runner-deps-shared-base.test.ts
65
- * 的 dist 扫描格钉住(core 加词/收进 d.ts 那天先红)。 */
68
+ * 的 dist 扫描格钉住(两种发射写法都读;读不出词的经变量发射点本身红;core 加词/收进 d.ts 那天先红)。 */
66
69
  export declare const CONFIG_ADVISORY_CLASSIFICATIONS: ReadonlySet<string>;
67
70
  /** S-386:core 的 [ref] 前缀缓存**断裂**探测器交给宿主的根因**闭集**,以及每个词的日志级别。
68
71
  * 闭集**不抄词**:词源直接取 core 公开导出的 `CacheBreakFinding["cause"]`(`@sema-agent/core` 根导出,
@@ -218,14 +221,15 @@ export interface RunnerDepsCtx {
218
221
  * 的「差异键」注释块逐条列了 sessionStore / checkpointStore / 四个座位,**都没提 hands**
219
222
  * —— 也就是说它不是一次有理由的分歧,是漏配(与本函数头注记的 [ref]§三族A 同一个病族)。
220
223
  * 由**调用方**给值(而不是在基座里按 `config` 现算):两条腿的判据本就不同(HTTP 腿按
221
- * `configProvider === "local"` 分 branded/非 branded,run-local 恒是 Sema 本地形),
224
+ * 品牌判官 `isBrandedDeployment`(`capabilities/brand-identity.ts`)分 branded/非 branded,run-local 恒是 Sema 本地形),
222
225
  * 各自算一次、传进来一次,两只 Runner 自动同源。
223
226
  */
224
227
  hands: RunnerDeps["hands"];
225
228
  executionEnvFactory: RunnerDeps["executionEnvFactory"];
226
229
  lspManager: RunnerDeps["lspManager"];
227
230
  fleetBus: FleetEventBus;
228
- deploymentHooks: NonNullable<RunnerDeps["hooks"]>;
231
+ /** 部署座的 mods 注册(stage-05 `createDeploymentMods` 铸、起服自证过)—— 共享基座 ⇒ 主 / handless / hookAgent / sub 每一只 Runner 同一份。 */
232
+ deploymentMods: NonNullable<RunnerDeps["mods"]>;
229
233
  workflowRunStore: WorkflowRunStore | undefined;
230
234
  workflowJournalStore: ServiceWorkflowJournalStore | undefined;
231
235
  workflowAgentRegistry: WorkflowAgentRegistry | undefined;
@@ -237,7 +241,7 @@ export interface RunnerDepsCtx {
237
241
  }
238
242
  /** [ref] A10 留档发现②:main runner `RunnerDeps` 与 main.ts subRunner 字面量之间此前手工重复
239
243
  * 的 ~15 个键,类型标注见 {@link createSharedRunnerDeps} 头注。 */
240
- export type SharedRunnerDeps = Pick<RunnerDeps, "brain" | "readFace" | "readDenyPatterns" | "readDenyBuiltinTiers" | "readDenyBuiltinExclude" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "delegationEntryCaps" | "crossSessionInbound" | "crossSessionDialogExpiry" | "writeProtectedPaths" | "memoryEngineDir" | "allowedTools" | "models" | "roles" | "tiers" | "pricing" | "tracer" | "promptSource" | "executionEnvFactory" | "lspManager" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "hooks" | "toolResultStore" | "checkpointStore" | "hands" | "sessionPolicyStore" | "usageWindows" | "usageWindowStore" | "memoryScopeAdmission" | "deploymentMemoryScopes" | "sharedMemoryStores" | "compliancePostureResolver" | "lockedConfig" | "retentionPolicy" | "onNotice" | "mcpRevocations">;
244
+ export type SharedRunnerDeps = Pick<RunnerDeps, "brain" | "readFace" | "readDenyPatterns" | "readDenyBuiltinTiers" | "readDenyBuiltinExclude" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "delegationEntryCaps" | "crossSessionInbound" | "crossSessionDialogExpiry" | "writeProtectedPaths" | "memoryEngineDir" | "allowedTools" | "models" | "roles" | "tiers" | "pricing" | "tracer" | "promptSource" | "executionEnvFactory" | "lspManager" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "mods" | "toolResultStore" | "checkpointStore" | "hands" | "sessionPolicyStore" | "usageWindows" | "usageWindowStore" | "memoryScopeAdmission" | "deploymentMemoryScopes" | "sharedMemoryStores" | "compliancePostureResolver" | "lockedConfig" | "retentionPolicy" | "onNotice" | "mcpRevocations">;
241
245
  /**
242
246
  * [ref] A10 留档发现②(review 2026-07-29,[ref]§三族A 同源修补的延续):main runner 的
243
247
  * `RunnerDeps` 字面量(下方 `createRunnerDeps`)与 `main.ts` 里 subRunner 的 `new Runner({...})`
@@ -264,7 +268,7 @@ export type SharedRunnerDeps = Pick<RunnerDeps, "brain" | "readFace" | "readDeny
264
268
  * 属性,比再抽一层共享基座更强的同源保证),不重复收纳进这里。
265
269
  */
266
270
  /** 基座真实消费的窄面(Pick)——subRunner 调用点(main.ts)只需凑这 13 个字段,不必造全量 ctx。 */
267
- export type SharedRunnerDepsCtx = Pick<RunnerDepsCtx, "config" | "brain" | "pricing" | "tracer" | "promptSource" | "executionEnvFactory" | "lspManager" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "deploymentHooks" | "toolResultStore" | "checkpointStore" | "sessionPolicyStore" | "hands" | "usageWindowStore" | "orgMemoryAdmission" | "sharedMemoryStores" | "logger" | "governanceSeams" | "mcpRevocations" | "metrics" | "engineDataRoot">;
271
+ export type SharedRunnerDepsCtx = Pick<RunnerDepsCtx, "config" | "brain" | "pricing" | "tracer" | "promptSource" | "executionEnvFactory" | "lspManager" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "deploymentMods" | "toolResultStore" | "checkpointStore" | "sessionPolicyStore" | "hands" | "usageWindowStore" | "orgMemoryAdmission" | "sharedMemoryStores" | "logger" | "governanceSeams" | "mcpRevocations" | "metrics" | "engineDataRoot">;
268
272
  /** 转发席只需要 `inc` —— 刻意窄到这一个动词,免得把整只 Metrics 拖进这条纯转发腿。 */
269
273
  export interface EngineNoticeMetricsSeat {
270
274
  inc: (name: string, labels?: Record<string, string>) => void;
@@ -317,6 +321,13 @@ export type DeploymentPostureSeats = Pick<RunnerDeps, "readFace" | "readDenyPatt
317
321
  * + LKG 覆写路径(`readDenyPatterns` 席并入它派生的读拒行,`lkgReadDenyRows`)。 */
318
322
  export type DeploymentPostureConfig = Pick<ServiceConfig, Exclude<keyof DeploymentPostureSeats, "allowedTools"> | "approvalGrant" | "configLkgPath">;
319
323
  export declare function buildDeploymentPostureSeats(config: DeploymentPostureConfig): DeploymentPostureSeats;
324
+ /**
325
+ * 部署读拒行**进场**的唯一告知点(非锚定行一行 `read_deny_unanchored_rows`;判据与行形在 `read-deny-anchor-audit.ts`)。律:**一份读拒行的值第一次装进 Runner 席时点名一次** ——
326
+ * 三条入口都经这里:server 起服与 run-local 经 {@link createSharedRunnerDeps}(server 的主 / 子 Runner 各展开一次共享基座、同一份 config ⇒ 只说一次),中心热换在换席成功之后
327
+ * (`boot/web-admin.ts` `applyLiveReadFace`;换席抛 ⇒ config 回滚、不到这里)。值没变 ⇒ 不重复说(只改 face 的热换、同一 config 的第二只 Runner);值变了(热换 A → B → A)⇒ 每次都说。
328
+ * 喂的是 `config.readDenyPatterns`(运维 ∪ 中心 read-face 的行),不是座席族并入 LKG 派生行之后的那一份 —— 派生行是根锚。绝不抛(纯诊断面)。
329
+ */
330
+ export declare function announceReadDenyRows(config: Pick<ServiceConfig, "readDenyPatterns">, logger: Pick<Logger, "warn">): void;
320
331
  export declare function createSharedRunnerDeps(ctx: SharedRunnerDepsCtx): SharedRunnerDeps;
321
332
  export declare function createRunnerDeps(ctx: RunnerDepsCtx): RunnerDeps;
322
333
  //# sourceMappingURL=runner-deps.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { createFileWorkflowScriptStore } from "@sema-agent/core";
2
2
  import { join } from "node:path";
3
3
  import { lkgReadDenyRows } from "../config-lkg.js";
4
+ import { auditReadDenyAnchoring } from "./read-deny-anchor-audit.js";
4
5
  import { fleetBackgroundChildPublisher, FleetEventBus } from "../fleet/fleet-bus.js";
5
6
  import { createMemoryEngineIncidentSink } from "../memory-incident-sink.js";
6
7
  import { assertAutoConsolidationWirable } from "./memory-consolidation.js";
@@ -24,6 +25,8 @@ export function createRunnerDepsOnAsk(toolApproval) {
24
25
  return (req, signal) => toolApproval.ask(req, signal);
25
26
  }
26
27
  export const CONFIG_ADVISORY_CLASSIFICATIONS = new Set([
28
+ "file-history-no-env",
29
+ "file-history-no-store",
27
30
  "interaction-posture-refused",
28
31
  "memory-tools-not-mounted",
29
32
  "sandbox-admission-unavailable",
@@ -76,7 +79,16 @@ export function buildDeploymentPostureSeats(config) {
76
79
  };
77
80
  return seats;
78
81
  }
82
+ const announcedReadDenyRows = new WeakMap();
83
+ export function announceReadDenyRows(config, logger) {
84
+ const key = JSON.stringify(config.readDenyPatterns ?? null);
85
+ if (announcedReadDenyRows.get(config) === key)
86
+ return;
87
+ announcedReadDenyRows.set(config, key);
88
+ auditReadDenyAnchoring({ rows: config.readDenyPatterns, logger });
89
+ }
79
90
  export function createSharedRunnerDeps(ctx) {
91
+ announceReadDenyRows(ctx.config, ctx.logger);
80
92
  const shared = {
81
93
  brain: ctx.brain,
82
94
  onNotice: createEngineNoticeForwarder(ctx.logger, defaultEngineNoticeRouter, ctx.metrics),
@@ -92,7 +104,7 @@ export function createSharedRunnerDeps(ctx) {
92
104
  backgroundAgentStore: ctx.backgroundAgentStore ? ctx.backgroundAgentStore : undefined,
93
105
  mailboxStore: ctx.mailboxStore ? ctx.mailboxStore : undefined,
94
106
  rosterStore: ctx.rosterStore ? ctx.rosterStore : undefined,
95
- hooks: ctx.deploymentHooks,
107
+ mods: ctx.deploymentMods,
96
108
  hands: ctx.hands,
97
109
  toolResultStore: ctx.toolResultStore,
98
110
  checkpointStore: ctx.checkpointStore ? ctx.checkpointStore : undefined,
@@ -168,6 +180,7 @@ export function createRunnerDeps(ctx) {
168
180
  logger,
169
181
  })
170
182
  : undefined,
183
+ principalInboxConsumer: config.principalInboxAssistant !== undefined ? { assistant: config.principalInboxAssistant } : undefined,
171
184
  onTaskOutcome: outcomeSink
172
185
  ? (o) => {
173
186
  metrics.inc("task_outcomes_total", { status: o.status, green: String(o.oracle?.green ?? "unknown") });
@@ -226,7 +239,7 @@ export function createRunnerDeps(ctx) {
226
239
  return;
227
240
  }
228
241
  if (ctx.phase === "prompt-constitution") {
229
- logger.warn("prompt_provider_needs_upgrade", { sessionId: ctx.sessionId, info: String(err) });
242
+ logger.warn("prompt_composition_warning", { sessionId: ctx.sessionId, info: String(err) });
230
243
  return;
231
244
  }
232
245
  if (ctx.phase === "rewind") {