@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,85 +1,35 @@
1
- /** The whitelisted projection of core's `prompt.assembled` trace event ([ref]② web observability slice A:
2
- * the manifest reaches the durable run event log + turns/stream). Built FIELD-BY-FIELD at record time
3
- * (never a spread — the 1.72 task_progress lesson: a future core field must not ride the durable wire raw).
4
- * Carries ONLY ids/digests/counts by core's manifest contract (no prompt bodies; hashes are core-salted) —
5
- * so the projection legs have zero redact burden. */
6
- export interface PromptManifestRecord {
7
- constitution: string;
8
- blocks: Array<{
9
- id: string;
10
- chars: number;
11
- hash: string;
12
- }>;
13
- /** `contentHash`(core 1.315 [ref]①):operator 声明 section 的**非盐化**对账锚(core 已对 text 校验
14
- * 后透传)——盐化 `hash` 恒在旁;端到端对账链(center 发布→manifest)经本投影,必须透传不可吞。 */
15
- sections?: Array<{
16
- id: string;
17
- slot: string;
18
- carrier: string;
19
- cadence: string;
20
- cacheClass: string;
21
- chars: number;
22
- hash: string;
23
- contentHash?: string;
24
- }>;
25
- tools?: Array<{
26
- wireName: string;
27
- aliases: string[];
28
- contractId: string;
29
- implementationRevision: string;
30
- cardId: string;
31
- shapeDigest: string;
32
- wireSchemaDigest: string;
33
- }>;
34
- /** core 5.15.0([ref]):deferred 披露策略自证三键(诊断值,零内容)。缺席=core <5.15 或无 deferred。 */
35
- toolDisclosure?: {
36
- deferredTools: number;
37
- strategy: string;
38
- source: string;
39
- };
40
- totalChars: number;
41
- }
42
- /** Whitelist one `prompt.assembled` trace event into a {@link PromptManifestRecord} (v1 face required,
43
- * v2 `sections`/`tools` additive — absent stays absent). */
44
- export declare function promptManifestRecordOf(e: {
45
- constitution: string;
46
- blocks: Array<{
47
- id: string;
48
- chars: number;
49
- hash: string;
50
- }>;
51
- sections?: Array<{
52
- id: string;
53
- slot: string;
54
- carrier: string;
55
- cadence: string;
56
- cacheClass: string;
57
- chars: number;
58
- hash: string;
59
- contentHash?: string;
60
- }>;
61
- tools?: Array<{
62
- wireName: string;
63
- aliases: string[];
64
- contractId: string;
65
- implementationRevision: string;
66
- cardId: string;
67
- shapeDigest: string;
68
- wireSchemaDigest: string;
69
- }>;
70
- /** core 5.15.0([ref],[ref] 提货②):deferred 工具的披露策略自证——{deferredTools(数), strategy
71
- * ("static"|"swap"), source(四值:`spec` / `env` / `default` / `degraded_no_direct_lane`)}。
72
- * 诊断三键(数 + 两闭集词,零内容)。词表属主是 core(`core/trace.d.ts` 的 `source` 联合),本仓宽收
73
- * ⇒ 词错不会红,所以照抄时务必对表:`degraded_no_direct_lane` = 直呼车道联锁把 `static` 请求收窄成
74
- * `swap` 的那一格,正是运维最需要认出来的一格(本注上一版把它写成了不存在的 `api-default`,下游看板
75
- * 照抄就会把真实的 degraded 读成未知词)。 */
76
- toolDisclosure?: {
77
- deferredTools: number;
78
- strategy: string;
79
- source: string;
80
- };
81
- totalChars: number;
82
- }): PromptManifestRecord;
1
+ import type { TraceEvent } from "@sema-agent/core";
2
+ import { WIRE_PROJECTION_FACES } from "../trace/wire-projection-faces.js";
3
+ /**
4
+ * 引擎的清单帧 `prompt.assembled`(引擎 7.52.0 起 `version: 3`):这条腿的提示**是哪一份**(`identity` + 它的选择器值 `selectors`)、
5
+ * 由哪些块与段组成、每一段的文本从哪里来(`chain`,被取代的 overlay 另在 `superseded`)。只有 id / 尺寸 / 摘要,没有提示正文。
6
+ */
7
+ export type PromptAssembledEvent = Extract<TraceEvent, {
8
+ kind: "prompt.assembled";
9
+ }>;
10
+ /** 帧上**不上行**的键。唯一一簿在 `trace/wire-projection-faces.ts` 的 `prompt_manifest` 行(逐键理由在那里);这里只做类型查询。 */
11
+ type NotOnTheRow = (typeof WIRE_PROJECTION_FACES)["prompt_manifest"]["excluded"][number];
12
+ /** 引擎的型,**词读成开集串**:投影判形,不判词表(档名、激活方式、来源类、渲染器……每一张词表的属主都是引擎,新词原样过境)。 */
13
+ type OpenWords<T> = T extends string ? string : T extends readonly (infer U)[] ? OpenWords<U>[] : T extends object ? {
14
+ [K in keyof T]: OpenWords<T[K]>;
15
+ } : T;
16
+ /**
17
+ * 耐久 `prompt_assembled` 行(turns 的 `prompt-assembled` 块与 trace SSE 的同名帧按它原样交出)= **引擎帧减不上行的键**,
18
+ * 由引擎的型派生,本仓不另写成员表。每个成员都可能缺席:引擎型里可选的成员缺席即缺席;在场却读不出的成员被丢并计数。
19
+ */
20
+ export type PromptManifestRecord = {
21
+ [K in Exclude<keyof PromptAssembledEvent, NotOnTheRow>]?: OpenWords<PromptAssembledEvent[K]>;
22
+ };
23
+ /** 投影器的入参:引擎帧的键,值一律当未知读 —— 逐层判形在投影器里做,第三方 producer / 坏世代的帧走同一道门。 */
24
+ export type PromptManifestInput = {
25
+ readonly [K in keyof PromptAssembledEvent]?: unknown;
26
+ };
27
+ /**
28
+ * 把一帧 `prompt.assembled` 读成耐久行(记录时白名单:tracer 同步、无 IO,未来的引擎键不随帧上行)。
29
+ * 规则一句:**只挑登记表声明的键,逐层判形;在场却读不出 ⇒ 计一次 `server.trace.projection-input-malformed` 并丢;缺席从不计数**。
30
+ * 词原样过境(不判词表);`identity` 是这条腿的提示身份的唯一读法 —— 本仓不另铸第二种(v2 的 `constitution` 随引擎退役)。
31
+ */
32
+ export declare function promptManifestRecordOf(e: PromptManifestInput): PromptManifestRecord;
83
33
  /**
84
34
  * [ref]② per-task prompt-manifest accumulator — the `ModelUsageTracker`(budget.ts)pattern: the
85
35
  * `prompt.assembled` tracer hook is SYNC/no-IO, so it cannot persist; it RECORDS here (registered
@@ -126,4 +76,5 @@ export declare class PromptManifestTracker {
126
76
  * a stale leg's teardown after a fast re-register is a no-op (the new leg owns it now). */
127
77
  clear(taskId: string, lease: number): void;
128
78
  }
79
+ export {};
129
80
  //# sourceMappingURL=prompt-manifest.d.ts.map
@@ -1,22 +1,127 @@
1
- export function promptManifestRecordOf(e) {
2
- return {
3
- constitution: String(e.constitution),
4
- blocks: (Array.isArray(e.blocks) ? e.blocks : []).map((b) => ({ id: String(b.id), chars: b.chars, hash: String(b.hash) })),
5
- ...(Array.isArray(e.sections)
6
- ? { sections: e.sections.map((s) => ({ id: String(s.id), slot: String(s.slot), carrier: String(s.carrier), cadence: String(s.cadence), cacheClass: String(s.cacheClass), chars: s.chars, hash: String(s.hash), ...(typeof s.contentHash === "string" ? { contentHash: s.contentHash } : {}) })) }
7
- : {}),
8
- ...(Array.isArray(e.tools)
9
- ? { tools: e.tools.map((t) => ({ wireName: String(t.wireName), aliases: (Array.isArray(t.aliases) ? t.aliases : []).map(String), contractId: String(t.contractId), implementationRevision: String(t.implementationRevision), cardId: String(t.cardId), shapeDigest: String(t.shapeDigest), wireSchemaDigest: String(t.wireSchemaDigest) })) }
10
- : {}),
11
- ...(typeof e.toolDisclosure === "object" && e.toolDisclosure !== null &&
12
- typeof e.toolDisclosure.deferredTools === "number" && Number.isFinite(e.toolDisclosure.deferredTools) &&
13
- typeof e.toolDisclosure.strategy === "string" && e.toolDisclosure.strategy.length > 0 &&
14
- typeof e.toolDisclosure.source === "string" && e.toolDisclosure.source.length > 0
15
- ? { toolDisclosure: { deferredTools: e.toolDisclosure.deferredTools, strategy: e.toolDisclosure.strategy, source: e.toolDisclosure.source } }
16
- : {}),
17
- totalChars: e.totalChars,
1
+ import { dropProjectedFace } from "../trace/projection-drop.js";
2
+ import { WIRE_PROJECTION_FACES } from "../trace/wire-projection-faces.js";
3
+ const ABSENT = Symbol("absent");
4
+ const text = (v) => (typeof v === "string" ? v : undefined);
5
+ const finite = (v) => (typeof v === "number" && Number.isFinite(v) ? v : undefined);
6
+ const flag = (v) => (typeof v === "boolean" ? v : undefined);
7
+ const onlyTrue = (v) => (v === true ? true : undefined);
8
+ const plainObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : undefined;
9
+ function optional(read) {
10
+ return (v) => (v === undefined ? ABSENT : read(v));
11
+ }
12
+ function objectOf(cells) {
13
+ return (v) => {
14
+ const o = plainObject(v);
15
+ if (o === undefined)
16
+ return undefined;
17
+ const out = {};
18
+ for (const [key, read] of cells) {
19
+ const r = read(o[key]);
20
+ if (r === undefined)
21
+ return undefined;
22
+ if (r !== ABSENT)
23
+ out[key] = r;
24
+ }
25
+ return out;
26
+ };
27
+ }
28
+ function listOf(read) {
29
+ return (v) => {
30
+ if (!Array.isArray(v))
31
+ return undefined;
32
+ const out = [];
33
+ for (const x of v) {
34
+ const r = read(x);
35
+ if (r === undefined)
36
+ return undefined;
37
+ out.push(r);
38
+ }
39
+ return out;
40
+ };
41
+ }
42
+ function entriesOf(read) {
43
+ return (v) => {
44
+ const o = plainObject(v);
45
+ if (o === undefined)
46
+ return undefined;
47
+ const out = [];
48
+ for (const [k, x] of Object.entries(o)) {
49
+ const r = read(x);
50
+ if (r === undefined)
51
+ return undefined;
52
+ out.push([k, r]);
53
+ }
54
+ return Object.fromEntries(out);
55
+ };
56
+ }
57
+ function drop(member, why) {
58
+ return dropProjectedFace("prompt_assembled." + member + " " + why);
59
+ }
60
+ function rowsOf(member, read) {
61
+ return (v) => {
62
+ if (!Array.isArray(v))
63
+ return undefined;
64
+ const out = [];
65
+ for (const x of v) {
66
+ const r = read(x);
67
+ if (r === undefined)
68
+ drop(`${member}[]`, "element does not read as the engine's type");
69
+ else
70
+ out.push(r);
71
+ }
72
+ return v.length > 0 && out.length === 0 ? ABSENT : out;
18
73
  };
19
74
  }
75
+ const FACES = WIRE_PROJECTION_FACES;
76
+ function exhausted(shape) {
77
+ throw new Error("清单行声明里有不认得的值形:" + JSON.stringify(shape));
78
+ }
79
+ function readerOfShape(shape, member, building) {
80
+ switch (shape.is) {
81
+ case "text":
82
+ return text;
83
+ case "count":
84
+ return finite;
85
+ case "flag":
86
+ return flag;
87
+ case "true":
88
+ return onlyTrue;
89
+ case "object":
90
+ return objectOf(cellsOfFace(shape.face, building));
91
+ case "list":
92
+ return listOf(readerOfShape(shape.of, member, building));
93
+ case "rows":
94
+ return rowsOf(member, readerOfShape(shape.of, member, building));
95
+ case "entries":
96
+ return entriesOf(readerOfShape(shape.of, member, building));
97
+ default:
98
+ return exhausted(shape);
99
+ }
100
+ }
101
+ function cellsOfFace(face, building) {
102
+ if (building.includes(face))
103
+ throw new Error("清单行声明成环:" + [...building, face].join(" → "));
104
+ const keys = FACES[face]?.keys;
105
+ if (keys === undefined)
106
+ throw new Error("清单行声明引用了没有 keys 的面:" + face);
107
+ return Object.entries(keys).map(([key, declared]) => {
108
+ const read = readerOfShape(declared, key, [...building, face]);
109
+ return [key, declared.optional === true ? optional(read) : read];
110
+ });
111
+ }
112
+ const ROW = cellsOfFace("prompt_manifest", []);
113
+ export function promptManifestRecordOf(e) {
114
+ const frame = e;
115
+ const out = {};
116
+ for (const [member, read] of ROW) {
117
+ const r = read(frame[member]);
118
+ if (r === undefined)
119
+ drop(member, "does not read as the engine's type");
120
+ else if (r !== ABSENT)
121
+ out[member] = r;
122
+ }
123
+ return out;
124
+ }
20
125
  export function configAssembledRecordOf(e) {
21
126
  const rec = {
22
127
  catalogVersion: e.catalogVersion,
@@ -206,19 +206,20 @@ function redactStringLeaves(node, depth = 0) {
206
206
  }
207
207
  return out ?? node;
208
208
  }
209
+ const OFF_ARM_MEMBER_TREATMENT = "free-text-tree";
210
+ const redactDetailMember = (v) => redactStringLeaves(v, 1);
209
211
  function shapeTerminalFailureDetail(detail) {
210
212
  if (detail === null || typeof detail !== "object" || Array.isArray(detail))
211
213
  return detail;
212
214
  const d = detail;
213
215
  const kind = d.kind;
214
- const table = typeof kind === "string" && Object.hasOwn(TERMINAL_FAILURE_DETAIL_TREATMENT, kind) ? TERMINAL_FAILURE_DETAIL_TREATMENT[kind] : undefined;
215
- if (table === undefined)
216
- return redactStringLeaves(d);
216
+ const arm = typeof kind === "string" && Object.hasOwn(TERMINAL_FAILURE_DETAIL_TREATMENT, kind) ? TERMINAL_FAILURE_DETAIL_TREATMENT[kind] : {};
217
217
  let out;
218
- for (const [key, treatment] of Object.entries(table)) {
218
+ for (const key of Object.keys(d)) {
219
219
  const v = d[key];
220
220
  if (v === undefined)
221
221
  continue;
222
+ const treatment = Object.hasOwn(arm, key) ? arm[key] : OFF_ARM_MEMBER_TREATMENT;
222
223
  switch (treatment) {
223
224
  case "verbatim":
224
225
  case "provider-join-key":
@@ -228,7 +229,7 @@ function shapeTerminalFailureDetail(detail) {
228
229
  delete (out ??= { ...d })[key];
229
230
  break;
230
231
  case "free-text-tree": {
231
- const nv = redactStringLeaves(v);
232
+ const nv = redactDetailMember(v);
232
233
  if (nv !== v)
233
234
  (out ??= { ...d })[key] = nv;
234
235
  break;
@@ -251,10 +252,11 @@ function shapeTerminalBlockedDetail(detail) {
251
252
  return detail;
252
253
  const d = detail;
253
254
  let out;
254
- for (const [key, treatment] of Object.entries(TERMINAL_BLOCKED_DETAIL_TREATMENT)) {
255
+ for (const key of Object.keys(d)) {
255
256
  const v = d[key];
256
257
  if (v === undefined)
257
258
  continue;
259
+ const treatment = Object.hasOwn(TERMINAL_BLOCKED_DETAIL_TREATMENT, key) ? TERMINAL_BLOCKED_DETAIL_TREATMENT[key] : OFF_ARM_MEMBER_TREATMENT;
258
260
  switch (treatment) {
259
261
  case "verbatim":
260
262
  break;
@@ -265,6 +267,12 @@ function shapeTerminalBlockedDetail(detail) {
265
267
  (out ??= { ...d })[key] = next;
266
268
  }
267
269
  break;
270
+ case "free-text-tree": {
271
+ const nv = redactDetailMember(v);
272
+ if (nv !== v)
273
+ (out ??= { ...d })[key] = nv;
274
+ break;
275
+ }
268
276
  default: {
269
277
  const unhandled = treatment;
270
278
  throw new Error(`unhandled blocked-detail treatment: ${String(unhandled)}`);
@@ -49,10 +49,22 @@ export interface SecretEnvScrubSiteSpec {
49
49
  }
50
50
  /** 登记过的剥除现场。闭集:未登记的 site 传不进 {@link recordSecretEnvScrub}(编译期拒,同 FAIL_OPEN_TAGS 纪律)。 */
51
51
  export declare const SECRET_ENV_SCRUB_SITES: {
52
- readonly "server.remote-env-host.inherit-scrub": {
52
+ readonly "server.remote-env-host.spawn-env": {
53
53
  readonly note: "模型可驱动的 host shell 继承 env(`inheritEnv` 三词任一,缺省 `\"scrub\"`;`\"all\"` 词下扣的只有本服务自己的凭据名)——这条腿上的一次泄漏等于把编排器的脑钥/仓库令牌交给模型选的命令";
54
54
  readonly remedy: null;
55
55
  };
56
+ readonly "server.remote-env-local-docker.spawn-env": {
57
+ readonly note: "local-docker 车道交给宿主 `docker` CLI 的 env(它拉起的凭据助手 / CLI 插件同读)—— 继承词 `\"all\"`,扣的只有本服务自己的凭据;一次泄漏等于把本服务凭据交给宿主上的第三方助手";
58
+ readonly remedy: null;
59
+ };
60
+ readonly "server.remote-env-adb.spawn-env": {
61
+ readonly note: "adb 车道交给宿主 `adb` CLI 的 env(首次调用起的常驻 adb server 继承同一份并一直活着)—— 继承词 `\"all\"`,扣的只有本服务自己的凭据;一次泄漏等于把本服务凭据留在一只常驻进程的环境里";
62
+ readonly remedy: null;
63
+ };
64
+ readonly "server.hooks.spawn-env": {
65
+ readonly note: "settings hooks 的命令腿(请求带来的命令跑在宿主上)的 env —— 严格名单(`PATH` / `HOME` / 终端 / locale 等十二名)经引擎组合,名单外一律不交;请求显式给的 `settings.env` 另叠在上面";
66
+ readonly remedy: null;
67
+ };
56
68
  readonly "server.project-memory.git-subprocess": {
57
69
  readonly note: "project-memory 读仓叙事时的 git 子进程 env —— 仓内的钩子/凭证助手会以本进程身份运行";
58
70
  readonly remedy: null;
@@ -1,10 +1,22 @@
1
1
  import { summarizeRedactions } from "@sema-agent/core";
2
2
  import { describeAllowlistPostures } from "../env-name-allowlist-knobs.js";
3
3
  export const SECRET_ENV_SCRUB_SITES = {
4
- "server.remote-env-host.inherit-scrub": {
4
+ "server.remote-env-host.spawn-env": {
5
5
  note: "模型可驱动的 host shell 继承 env(`inheritEnv` 三词任一,缺省 `\"scrub\"`;`\"all\"` 词下扣的只有本服务自己的凭据名)——这条腿上的一次泄漏等于把编排器的脑钥/仓库令牌交给模型选的命令",
6
6
  remedy: null,
7
7
  },
8
+ "server.remote-env-local-docker.spawn-env": {
9
+ note: "local-docker 车道交给宿主 `docker` CLI 的 env(它拉起的凭据助手 / CLI 插件同读)—— 继承词 `\"all\"`,扣的只有本服务自己的凭据;一次泄漏等于把本服务凭据交给宿主上的第三方助手",
10
+ remedy: null,
11
+ },
12
+ "server.remote-env-adb.spawn-env": {
13
+ note: "adb 车道交给宿主 `adb` CLI 的 env(首次调用起的常驻 adb server 继承同一份并一直活着)—— 继承词 `\"all\"`,扣的只有本服务自己的凭据;一次泄漏等于把本服务凭据留在一只常驻进程的环境里",
14
+ remedy: null,
15
+ },
16
+ "server.hooks.spawn-env": {
17
+ note: "settings hooks 的命令腿(请求带来的命令跑在宿主上)的 env —— 严格名单(`PATH` / `HOME` / 终端 / locale 等十二名)经引擎组合,名单外一律不交;请求显式给的 `settings.env` 另叠在上面",
18
+ remedy: null,
19
+ },
8
20
  "server.project-memory.git-subprocess": {
9
21
  note: "project-memory 读仓叙事时的 git 子进程 env —— 仓内的钩子/凭证助手会以本进程身份运行",
10
22
  remedy: null,
@@ -1,15 +1,18 @@
1
- import { type Hooks } from "@sema-agent/core";
1
+ import { type EngineDollar, type ModRegistration } from "@sema-agent/core";
2
2
  import type { Logger } from "./logger.js";
3
3
  import type { Metrics } from "./metrics.js";
4
+ /** 两张部署注册的名字 —— wire 可见(`wiring_manifest.mods[].name`);名字中性、稳定、不含部署信息。 */
5
+ export declare const PERMISSION_DENIED_METER_REGISTRATION = "server.permission-denied-meter";
6
+ export declare const TOOL_TRACE_REGISTRATION = "server.tool-trace";
4
7
  /**
5
8
  * ALWAYS-ON gate-deny meter (goal B4, 2026-07-08): `permission_denied_total{deniedBy}` — how often the
6
9
  * adjudicate chain DENIES a tool call, by the LAYER whose verdict is the deny. Deliberately SEPARATE from
7
10
  * {@link createToolTracer}: the tracer is a default-OFF diagnostic (TOOL_TRACE=true), but deny frequency is an
8
11
  * operational/security signal that must reach /metrics on every deployment — a spike in `deniedBy="policy"`
9
12
  * means a task keeps asking for something the operator forbids; `deniedBy="org"` is the organization layer
10
- * refusing, the one class an operator most wants to see on its own. main.ts composes this UNDER the tracer via
11
- * composeHooks (both are void observers on the permissionDenied slot, which composeHooks double-runs
12
- * deployment-first).
13
+ * refusing, the one class an operator most wants to see on its own. It is the deployment seat's first registration
14
+ * (`createDeploymentMods`, `boot/deployment-mods.ts`): an observer on `classic.PermissionDenied`, run before the tracer's observer on the same
15
+ * event (the engine runs observers by tier, then deployment before task, then each seat's own order).
13
16
  *
14
17
  * 🔴 BREAKING(server 7.64.0,core 7.6.0 提货):标签名 `source` → `deniedBy`,词表从七词
15
18
  * (`policy/hook/safety/shellGate/planMode/classifier/org`)换成八词
@@ -46,7 +49,7 @@ import type { Metrics } from "./metrics.js";
46
49
  * · **计数总量方向**:新座只在「分类器那一轮没有裁决」时在场(`<block>yes` 的真裁决恒缺席),与旧座的
47
50
  * 「分类器停摆」同向;多出来的那一格是 `parse_error`,它也确实是「分类器没正常工作」的一种。
48
51
  */
49
- export declare function createPermissionDeniedMeter(metrics: Pick<Metrics, "inc">): Hooks;
52
+ export declare function createPermissionDeniedMeter(metrics: Pick<Metrics, "inc">): ModRegistration<EngineDollar>;
50
53
  /**
51
54
  * prove-before-scale stopgap ([ref]): a no-op observer hook that logs every tool call (pre + post)
52
55
  * to the worker log — INCLUDING resumed legs that `GET /v1/runs/:id/events` does NOT surface (the
@@ -59,21 +62,13 @@ export declare function createPermissionDeniedMeter(metrics: Pick<Metrics, "inc"
59
62
  * the full sequence: a repeated `write_file path=X contentLen=Y` across resumes ⇒ restart-loop;
60
63
  * write X → write Y → bash ⇒ iteration.
61
64
  *
62
- * Pure observation: every hook returns `undefined`, so it never rewrites args, never gates, never alters
63
- * the result (and per core's hooks invariant a hook's `allow` can't bypass the policy gate anyway).
64
- *
65
- * 🔴 core 5.20.0 起这条「纯观察」性质必须**声明**出来(`preToolUseObservational`),不能只写在注释里:
66
- * core 5.19.0 的委派折叠按「PreToolUse 席位在不在」把父的 screening 面折进子代的祖先约束链——它分不出
67
- * 诊断 tracer 与真裁决者。后果是**这个默认关的诊断旋钮**一开,该部署所有 hook-wired 父的 parked 子代
68
- * checkpoint 就记 `parentConstraintCount=2`,而跨副本赎回腿(`boot/parked-revive-gate.ts`)恒供 1 ⇒
69
- * core pre-CAS 响亮拒、行永久 pending(层数 park 时写死,事后关旋钮/重批/回滚都不改)。
70
- * 声明之后该面不铸链条目,count 回到 1,病路消灭。
71
- * ⛔ 打这个标的前提是**真的一条裁决都不出**:core 对声明了却返回判词的面是「拒绝采纳 + onError 告警」
72
- * (classification `observational-hook-verdict-ignored`),即判词被静默丢弃——把标打到会裁决的面上比原
73
- * 缺陷更坏。本文件三个 pre/post 回调恒返 `undefined`,`permissionDenied` 本就是 void 观察槽。
74
- * 📎 连带的**可观测**变化(不是回归):core 的「可写工具面无 effect-aware 门」启动告警此前把本 tracer
75
- * 算作一道门而被抑制;声明之后它不再算,于是「没配任何 policy 层 + 开着 TOOL_TRACE」的部署升级后会
76
- * 多出那行告警。方向正确——tracer 从来没有门住任何东西,原先的抑制本身就是一次静默 fail-open。
65
+ * Pure observation: every handler is an observer (`{ observe: true }`, via {@link observeClassic}) — a detached copy of
66
+ * the event, outside the chain, its answer never adopted — so it never rewrites args, never gates, never alters the result.
67
+ * Being an observer is also what keeps it out of a delegated child's inherited constraint: the engine mints a screening
68
+ * entry only from a chain that JUDGES, so turning this diagnostic switch on adds no `parentConstraintCount` to a parked
69
+ * child of a hook-wired parent (the cross-replica revive leg, `boot/parked-revive-gate.ts`, supplies the caller policy only).
70
+ * 📎 Not a gate either for the engine's "writable tool face without an effect-aware gate" startup warning: a deployment with
71
+ * no policy layer and `TOOL_TRACE` on still gets that warning — the tracer never gated anything.
77
72
  */
78
- export declare function createToolTracer(logger: Logger): Hooks;
73
+ export declare function createToolTracer(logger: Logger): ModRegistration<EngineDollar>;
79
74
  //# sourceMappingURL=tool-trace.d.ts.map
@@ -1,85 +1,94 @@
1
1
  import { isClassifierDenyCause, isDeniedBy } from "@sema-agent/core";
2
+ import { observeClassic } from "../hooks/classic-stations.js";
2
3
  import { redactSecrets } from "../trace/redact.js";
4
+ import { echoCallerText } from "../caller-text-echo.js";
5
+ export const PERMISSION_DENIED_METER_REGISTRATION = "server.permission-denied-meter";
6
+ export const TOOL_TRACE_REGISTRATION = "server.tool-trace";
3
7
  function deniedByLabel(gate) {
4
8
  const d = gate.disposition;
5
9
  return d.kind === "denied" && isDeniedBy(d.deniedBy) ? d.deniedBy : "other";
6
10
  }
7
11
  export function createPermissionDeniedMeter(metrics) {
8
12
  return {
9
- permissionDenied(payload) {
10
- metrics.inc("permission_denied_total", { deniedBy: deniedByLabel(payload.gate) });
11
- const disposition = payload.gate?.disposition;
12
- const cause = disposition?.kind === "denied" ? disposition.cause : undefined;
13
- if (cause !== undefined) {
14
- metrics.inc("auto_mode_classifier_deny_cause_total", { cause: isClassifierDenyCause(cause) ? cause : "other" });
15
- }
13
+ name: PERMISSION_DENIED_METER_REGISTRATION,
14
+ tier: "prepend",
15
+ uses: { events: ["classic.PermissionDenied"], calls: [] },
16
+ register(on) {
17
+ observeClassic(on, "classic.PermissionDenied", (payload) => {
18
+ metrics.inc("permission_denied_total", { deniedBy: deniedByLabel(payload.gate) });
19
+ const disposition = payload.gate?.disposition;
20
+ const cause = disposition?.kind === "denied" ? disposition.cause : undefined;
21
+ if (cause !== undefined) {
22
+ metrics.inc("auto_mode_classifier_deny_cause_total", { cause: isClassifierDenyCause(cause) ? cause : "other" });
23
+ }
24
+ });
16
25
  },
17
26
  };
18
27
  }
19
28
  export function createToolTracer(logger) {
20
29
  return {
21
- preToolUseObservational: true,
22
- preToolUse(toolName, input, ctx) {
23
- logger.info("tool_trace", { phase: "pre", id: ctx.toolCallId, tool: toolName, arg: summarize(input) });
24
- return undefined;
25
- },
26
- postToolUse(toolName, _input, output, ctx) {
27
- logger.info("tool_trace", {
28
- phase: "post",
29
- id: ctx.toolCallId,
30
- tool: toolName,
31
- isError: output.isError,
32
- out: textOf(output.content),
30
+ name: TOOL_TRACE_REGISTRATION,
31
+ tier: "prepend",
32
+ uses: { events: ["classic.PreToolUse", "classic.PostToolUse", "classic.PostToolUseFailure", "classic.PermissionDenied"], calls: [] },
33
+ register(on) {
34
+ observeClassic(on, "classic.PreToolUse", (e) => {
35
+ logger.info("tool_trace", { phase: "pre", id: e.tool_use_id, tool: e.tool, arg: summarize(e.input) });
33
36
  });
34
- return undefined;
35
- },
36
- postToolUseFailure(toolName, _input, failure, ctx) {
37
- logger.info("tool_trace", {
38
- phase: "post",
39
- id: ctx.toolCallId,
40
- tool: toolName,
41
- isError: true,
42
- isInterrupt: failure.isInterrupt,
43
- ...(failure.durationMs !== undefined ? { durationMs: failure.durationMs } : {}),
44
- out: clip(redactSecrets(failure.error), 200),
37
+ observeClassic(on, "classic.PostToolUse", (e) => {
38
+ logger.info("tool_trace", {
39
+ phase: "post",
40
+ id: e.tool_use_id,
41
+ tool: e.tool,
42
+ isError: e.output.isError,
43
+ out: textOf(e.output.content),
44
+ });
45
45
  });
46
- return undefined;
47
- },
48
- permissionDenied(payload) {
49
- logger.info("tool_trace", {
50
- phase: "denied",
51
- id: payload.toolCallId,
52
- tool: payload.toolName,
53
- deniedBy: deniedByLabel(payload.gate),
54
- ...(payload.gate.origin === undefined ? {} : { origin: payload.gate.origin }),
55
- ...(payload.gate.settlement === undefined ? {} : { settlement: payload.gate.settlement.kind }),
56
- reason: clip(redactSecrets(payload.reason), 200),
57
- arg: summarize(payload.input),
46
+ observeClassic(on, "classic.PostToolUseFailure", (e) => {
47
+ logger.info("tool_trace", {
48
+ phase: "post",
49
+ id: e.tool_use_id,
50
+ tool: e.tool,
51
+ isError: true,
52
+ isInterrupt: e.failure.isInterrupt,
53
+ ...(e.failure.durationMs !== undefined ? { durationMs: e.failure.durationMs } : {}),
54
+ out: echoCallerText(redactSecrets(e.failure.error), { maxChars: TRACE_OUT_ECHO_CHARS }),
55
+ });
56
+ });
57
+ observeClassic(on, "classic.PermissionDenied", (payload) => {
58
+ logger.info("tool_trace", {
59
+ phase: "denied",
60
+ id: payload.toolCallId,
61
+ tool: payload.toolName,
62
+ deniedBy: deniedByLabel(payload.gate),
63
+ ...(payload.gate.origin === undefined ? {} : { origin: payload.gate.origin }),
64
+ ...(payload.gate.settlement === undefined ? {} : { settlement: payload.gate.settlement.kind }),
65
+ reason: echoCallerText(redactSecrets(payload.reason), { maxChars: TRACE_OUT_ECHO_CHARS }),
66
+ arg: summarize(payload.input),
67
+ });
58
68
  });
59
69
  },
60
70
  };
61
71
  }
72
+ const TRACE_ARG_ECHO_CHARS = 120;
73
+ const TRACE_OUT_ECHO_CHARS = 200;
62
74
  function summarize(input) {
63
75
  if (!input || typeof input !== "object")
64
- return { v: clip(String(input), 120) };
76
+ return { v: echoCallerText(redactSecrets(String(input)), { maxChars: TRACE_ARG_ECHO_CHARS }) };
65
77
  const o = input;
66
78
  const s = {};
67
79
  for (const k of ["path", "file_path", "command", "cmd", "pattern", "glob", "old_string", "new_string"]) {
68
80
  if (typeof o[k] === "string")
69
- s[k] = clip(redactSecrets(o[k]), 120);
81
+ s[k] = echoCallerText(redactSecrets(o[k]), { maxChars: TRACE_ARG_ECHO_CHARS });
70
82
  }
71
83
  if (typeof o.content === "string")
72
84
  s.contentLen = o.content.length;
73
- return Object.keys(s).length ? s : { keys: Object.keys(o) };
85
+ return Object.keys(s).length ? s : { keys: Object.keys(o).map((k) => echoCallerText(k, { maxChars: TRACE_ARG_ECHO_CHARS })) };
74
86
  }
75
87
  function textOf(content) {
76
88
  const text = content
77
89
  .map((c) => (c && typeof c === "object" && typeof c.text === "string" ? c.text : ""))
78
90
  .join("")
79
91
  .trim();
80
- return clip(redactSecrets(text), 200);
81
- }
82
- function clip(s, n) {
83
- return s.length > n ? `${s.slice(0, n)}…(${s.length})` : s;
92
+ return echoCallerText(redactSecrets(text), { maxChars: TRACE_OUT_ECHO_CHARS });
84
93
  }
85
94
  //# sourceMappingURL=tool-trace.js.map
@@ -66,6 +66,16 @@ export declare function operatorAsk(rule: string, message: string): OperatorAskR
66
66
  * 名单卡要带「本会话放行」,而强制卡上没有。「恒问人」两类盖出身 ⇒ core 读 `operator_forced`、盖 `mandated`,站着的答案在哪一层都退不掉它们。
67
67
  */
68
68
  export declare function operatorAlwaysHumanAsk(rule: string, message: string): OperatorAskResult;
69
+ /**
70
+ * 🔴 **S-1351 —— 请求写下的「恒问人」**(`settings.permissions.neverAuto`):在 {@link operatorAsk} 之上再盖 `requiresRealApproval: true`(core 的治理位 ——
71
+ * 「只有判断能清它」:空白的 `onAsk: "allow"`、任何站着的答案(持久规则、会话授权)、auto 分类器都清不掉,只有**这一次**的真人应答能答),不盖部署出身。
72
+ *
73
+ * 为什么不盖 `authoredBy: "deployment"`:出身位说的是「部署自己的治理层写的」,请求里的声明不是部署写的 —— 盖了就是在审计面冒名。`requiresRealApproval` 是 core 明文开给
74
+ * 策略自报的位(顶注:自报只会把**自己的** ask 退出自动裁决,方向是收紧、冒报安全),它把这一问推进「只有判断能清」的那一门(`ruleClearanceOf` 的治理门),
75
+ * 效果与部署的 `APPROVAL_NEVER_AUTO` 同级 —— 每个权限模式词下的仲裁读数逐位相同(`test/tighten-only-seats-assembly.test.ts` 逐词钉住)。
76
+ * 出处串(`rule` 写 `settings.permissions.neverAuto(<命中的名>)`,不写成 `APPROVAL_NEVER_AUTO(…)`)进 `matchedAskRule`:引擎闸内部消费、不上卡(同部署那一条),审计 / 单测读它区分来源。
77
+ */
78
+ export declare function requestAlwaysHumanAsk(rule: string, message: string): OperatorAskResult;
69
79
  /**
70
80
  * 🔴 **S-958 —— 治理层的叶策略包装**:`leaf` 产的每一只 ask 盖部署出身(经 {@link withDeploymentAuthorship}),allow / deny 原物交回;
71
81
  * 成员(`projection` / `pathRules` / `writeTargetGuard` / `nameSets`)经 core `wrapToolPolicy` 随行(契约「包装至少拒内层所拒」:
@@ -5,6 +5,9 @@ export function operatorAsk(rule, message) {
5
5
  export function operatorAlwaysHumanAsk(rule, message) {
6
6
  return withDeploymentAuthorship(operatorAsk(rule, message));
7
7
  }
8
+ export function requestAlwaysHumanAsk(rule, message) {
9
+ return { ...operatorAsk(rule, message), requiresRealApproval: true };
10
+ }
8
11
  function withDeploymentAuthorship(ask) {
9
12
  return { ...ask, authoredBy: "deployment" };
10
13
  }