@sema-agent/server 7.132.0 → 7.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. package/MIGRATION.md +353 -0
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +7 -6
  4. package/USAGE.md +301 -64
  5. package/deploy/sema-up/README.md +35 -1
  6. package/deploy/sema-up/chart/Chart.yaml +1 -1
  7. package/deploy/sema-up/chart/templates/NOTES.txt +15 -0
  8. package/deploy/sema-up/chart/templates/_helpers.tpl +129 -0
  9. package/deploy/sema-up/chart/templates/sealed-key.yaml +24 -0
  10. package/deploy/sema-up/chart/templates/server-v4pro.yaml +19 -2
  11. package/deploy/sema-up/chart/templates/server.yaml +19 -2
  12. package/deploy/sema-up/chart/values-full-single.yaml +5 -1
  13. package/deploy/sema-up/chart/values.yaml +34 -0
  14. package/deploy/sema-up/stack/compose.yaml +3 -0
  15. package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
  16. package/dist/adoption/plan.d.ts +3 -2
  17. package/dist/adoption/plan.js +7 -5
  18. package/dist/adoption/runner.js +3 -10
  19. package/dist/adoption/sql.d.ts +3 -2
  20. package/dist/adoption/sql.js +3 -5
  21. package/dist/adoption/wire.d.ts +4 -1
  22. package/dist/adoption/wire.js +1 -0
  23. package/dist/approval-ask-audit-store.d.ts +32 -14
  24. package/dist/approval-ask-audit-store.js +272 -74
  25. package/dist/approval-ask-machine.d.ts +15 -0
  26. package/dist/approval-ask-machine.js +6 -0
  27. package/dist/approval-ask-retention.d.ts +136 -0
  28. package/dist/approval-ask-retention.js +102 -0
  29. package/dist/approval-card.d.ts +83 -23
  30. package/dist/approval-card.js +45 -15
  31. package/dist/approval-content-kind.d.ts +5 -2
  32. package/dist/approval-content-kind.js +16 -3
  33. package/dist/approval-deny-reasons.d.ts +1 -1
  34. package/dist/approval-gate-currency.d.ts +72 -0
  35. package/dist/approval-gate-currency.js +94 -0
  36. package/dist/approval.d.ts +15 -0
  37. package/dist/approval.js +55 -17
  38. package/dist/audit.d.ts +27 -10
  39. package/dist/audit.js +12 -16
  40. package/dist/bake-runner/main.js +3 -2
  41. package/dist/boot/coordinators.d.ts +6 -1
  42. package/dist/boot/coordinators.js +6 -3
  43. package/dist/boot/deferred-sandbox-path-env.js +1 -1
  44. package/dist/boot/execution-env.js +9 -7
  45. package/dist/boot/execution-lane.js +11 -0
  46. package/dist/boot/leader.d.ts +2 -0
  47. package/dist/boot/leader.js +4 -1
  48. package/dist/boot/memory-boundary.js +2 -2
  49. package/dist/boot/memory-consolidation.d.ts +5 -4
  50. package/dist/boot/memory-consolidation.js +7 -6
  51. package/dist/boot/org-delivery.d.ts +28 -0
  52. package/dist/boot/org-delivery.js +20 -0
  53. package/dist/boot/read-deny-anchor-audit.js +2 -2
  54. package/dist/boot/reapers.d.ts +3 -0
  55. package/dist/boot/reapers.js +21 -1
  56. package/dist/boot/resolve-spec.d.ts +3 -0
  57. package/dist/boot/resolve-spec.js +60 -81
  58. package/dist/boot/runner-deps.d.ts +18 -5
  59. package/dist/boot/runner-deps.js +10 -0
  60. package/dist/boot/session-faces.d.ts +1 -0
  61. package/dist/boot/session-faces.js +4 -2
  62. package/dist/boot/stage-02-web-admin-pull.js +4 -1
  63. package/dist/boot/stage-06-runners.d.ts +6 -3
  64. package/dist/boot/stage-06-runners.js +20 -4
  65. package/dist/boot/stage-07-capability-layer.d.ts +4 -1
  66. package/dist/boot/stage-07-capability-layer.js +24 -3
  67. package/dist/boot/stage-08-reapers.d.ts +4 -1
  68. package/dist/boot/stage-08-reapers.js +2 -2
  69. package/dist/boot/stage-09-leader.d.ts +5 -1
  70. package/dist/boot/stage-09-leader.js +2 -2
  71. package/dist/boot/stage-10-http-server.d.ts +5 -1
  72. package/dist/boot/stage-10-http-server.js +6 -6
  73. package/dist/boot/stores.d.ts +8 -0
  74. package/dist/boot/stores.js +10 -14
  75. package/dist/boot/web-admin.d.ts +10 -0
  76. package/dist/boot/web-admin.js +162 -65
  77. package/dist/boot/workflow-orchestration.d.ts +2 -0
  78. package/dist/boot/workflow-orchestration.js +2 -1
  79. package/dist/brain.js +8 -3
  80. package/dist/breaker-key.d.ts +6 -0
  81. package/dist/breaker-key.js +29 -0
  82. package/dist/budget.js +5 -1
  83. package/dist/caller-text-echo.d.ts +11 -6
  84. package/dist/caller-text-echo.js +10 -12
  85. package/dist/canonical-json.d.ts +2 -41
  86. package/dist/canonical-json.js +2 -13
  87. package/dist/capabilities/center-plugins.d.ts +7 -0
  88. package/dist/capabilities/center-plugins.js +1 -1
  89. package/dist/capabilities/composite-members.d.ts +1 -1
  90. package/dist/capabilities/composite-members.js +1 -1
  91. package/dist/capabilities/execution-lane.js +2 -2
  92. package/dist/capabilities/hands-lane.d.ts +21 -0
  93. package/dist/capabilities/hands-lane.js +10 -0
  94. package/dist/capabilities/mcp-probe.d.ts +36 -4
  95. package/dist/capabilities/mcp-probe.js +29 -6
  96. package/dist/capabilities/scenarios.d.ts +63 -7
  97. package/dist/capabilities/scenarios.js +39 -7
  98. package/dist/capability-facts.d.ts +36 -4
  99. package/dist/capability-facts.js +30 -4
  100. package/dist/center-config-tier.d.ts +69 -0
  101. package/dist/center-config-tier.js +42 -0
  102. package/dist/checkpoint-ctx-seal-m28.d.ts +42 -0
  103. package/dist/checkpoint-ctx-seal-m28.js +19 -0
  104. package/dist/checkpoint-identity.d.ts +16 -0
  105. package/dist/checkpoint-identity.js +19 -0
  106. package/dist/config-catalog.d.ts +17 -10
  107. package/dist/config-catalog.js +43 -28
  108. package/dist/config-d-migration.d.ts +3 -1
  109. package/dist/config-d-migration.js +2 -2
  110. package/dist/config-dir-trust.d.ts +114 -0
  111. package/dist/config-dir-trust.js +388 -0
  112. package/dist/config-invariants.d.ts +18 -5
  113. package/dist/config-invariants.js +35 -3
  114. package/dist/config-provider.d.ts +6 -1
  115. package/dist/config-provider.js +6 -2
  116. package/dist/config-types.d.ts +71 -14
  117. package/dist/config-types.js +8 -0
  118. package/dist/config.d.ts +13 -0
  119. package/dist/config.js +121 -59
  120. package/dist/delegated-session-owner.d.ts +185 -0
  121. package/dist/delegated-session-owner.js +119 -0
  122. package/dist/device-protocol.d.ts +5 -3
  123. package/dist/device-protocol.js +1 -1
  124. package/dist/device-ws-hub.js +21 -2
  125. package/dist/device-ws-protocol.d.ts +70 -6
  126. package/dist/device-ws-protocol.js +50 -23
  127. package/dist/elicitation.js +3 -2
  128. package/dist/entry-problems.d.ts +34 -0
  129. package/dist/entry-problems.js +14 -0
  130. package/dist/execution-lane-caps.d.ts +49 -10
  131. package/dist/execution-lane-caps.js +43 -4
  132. package/dist/field-conflict.d.ts +44 -0
  133. package/dist/field-conflict.js +21 -0
  134. package/dist/file-history-disclosure.d.ts +34 -5
  135. package/dist/file-history-disclosure.js +2 -2
  136. package/dist/fleet/fleet-bus.d.ts +84 -6
  137. package/dist/fleet/fleet-bus.js +42 -9
  138. package/dist/hooks/classic-stations.d.ts +10 -5
  139. package/dist/hooks/classic-stations.js +4 -4
  140. package/dist/hooks/command-spawn.d.ts +57 -0
  141. package/dist/hooks/command-spawn.js +139 -0
  142. package/dist/hooks/hook-llm.js +2 -2
  143. package/dist/hooks/hook-runner.d.ts +127 -25
  144. package/dist/hooks/hook-runner.js +668 -287
  145. package/dist/hooks/hook-source.d.ts +44 -0
  146. package/dist/hooks/hook-source.js +40 -0
  147. package/dist/http/active-run-conflict.d.ts +5 -13
  148. package/dist/http/active-run-conflict.js +17 -27
  149. package/dist/http/admission.js +111 -60
  150. package/dist/http/approval-sweeps.js +58 -19
  151. package/dist/http/caller-trust.d.ts +77 -0
  152. package/dist/http/caller-trust.js +143 -0
  153. package/dist/http/checkpoint-ctx.d.ts +173 -18
  154. package/dist/http/checkpoint-ctx.js +171 -12
  155. package/dist/http/claimed-run.d.ts +4 -3
  156. package/dist/http/device-placement.d.ts +2 -4
  157. package/dist/http/device-placement.js +2 -1
  158. package/dist/http/dispatch.js +13 -7
  159. package/dist/http/durable-run-leg.d.ts +4 -32
  160. package/dist/http/durable-run-leg.js +37 -12
  161. package/dist/http/idempotency.d.ts +2 -2
  162. package/dist/http/idempotency.js +2 -2
  163. package/dist/http/owner-access.d.ts +56 -0
  164. package/dist/http/owner-access.js +42 -0
  165. package/dist/http/principal-gate.d.ts +78 -27
  166. package/dist/http/principal-gate.js +64 -14
  167. package/dist/http/readiness.d.ts +11 -5
  168. package/dist/http/readiness.js +10 -3
  169. package/dist/http/refusal-body.d.ts +12 -0
  170. package/dist/http/refusal-body.js +11 -0
  171. package/dist/http/request-guards.d.ts +16 -32
  172. package/dist/http/request-guards.js +31 -30
  173. package/dist/http/resume-ctx-read.d.ts +50 -6
  174. package/dist/http/resume-ctx-read.js +33 -7
  175. package/dist/http/resume-legs.d.ts +5 -5
  176. package/dist/http/resume-legs.js +163 -91
  177. package/dist/http/retired-service-deps.d.ts +43 -0
  178. package/dist/http/retired-service-deps.js +18 -0
  179. package/dist/http/route-ctx.d.ts +44 -37
  180. package/dist/http/route-ctx.js +4 -0
  181. package/dist/http/route-table.js +2 -0
  182. package/dist/http/routes/a2a-serve.js +3 -4
  183. package/dist/http/routes/admin-config-refresh.js +1 -1
  184. package/dist/http/routes/admin-drain.js +1 -1
  185. package/dist/http/routes/admin-memory-optout.js +5 -1
  186. package/dist/http/routes/adoption.js +2 -9
  187. package/dist/http/routes/agents-roster.js +2 -3
  188. package/dist/http/routes/approvals-assistant.js +91 -56
  189. package/dist/http/routes/background.js +3 -2
  190. package/dist/http/routes/capabilities.js +20 -4
  191. package/dist/http/routes/config-catalog.d.ts +3 -3
  192. package/dist/http/routes/config-catalog.js +1 -1
  193. package/dist/http/routes/devices.js +3 -17
  194. package/dist/http/routes/diagnostics.d.ts +3 -3
  195. package/dist/http/routes/diagnostics.js +6 -2
  196. package/dist/http/routes/fleet.js +4 -4
  197. package/dist/http/routes/images.js +6 -7
  198. package/dist/http/routes/leader.js +1 -8
  199. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  200. package/dist/http/routes/mcp-reconnect.js +3 -2
  201. package/dist/http/routes/memory-bundle.js +1 -1
  202. package/dist/http/routes/memory-compliance.js +1 -1
  203. package/dist/http/routes/memory-consolidation.js +1 -1
  204. package/dist/http/routes/memory-origin.d.ts +1 -1
  205. package/dist/http/routes/memory-origin.js +1 -1
  206. package/dist/http/routes/memory-policy.d.ts +1 -1
  207. package/dist/http/routes/memory-policy.js +3 -2
  208. package/dist/http/routes/notify-wake.js +8 -21
  209. package/dist/http/routes/observability.js +2 -2
  210. package/dist/http/routes/principal-inbox.d.ts +39 -0
  211. package/dist/http/routes/principal-inbox.js +76 -0
  212. package/dist/http/routes/retention-ops.js +2 -9
  213. package/dist/http/routes/rules.js +9 -22
  214. package/dist/http/routes/runs.d.ts +5 -0
  215. package/dist/http/routes/runs.js +63 -115
  216. package/dist/http/routes/session-sync.d.ts +3 -2
  217. package/dist/http/routes/session-sync.js +53 -48
  218. package/dist/http/routes/sessions-list.d.ts +1 -1
  219. package/dist/http/routes/sessions-list.js +3 -4
  220. package/dist/http/routes/sessions.js +33 -43
  221. package/dist/http/routes/side-query.js +6 -4
  222. package/dist/http/routes/tasks.js +71 -30
  223. package/dist/http/routes/trace-usage.js +7 -9
  224. package/dist/http/routes/workflows.d.ts +351 -0
  225. package/dist/http/routes/workflows.js +153 -119
  226. package/dist/http/run-declared-families.d.ts +16 -0
  227. package/dist/http/run-declared-families.js +12 -0
  228. package/dist/http/send.d.ts +24 -3
  229. package/dist/http/send.js +14 -2
  230. package/dist/http/server.d.ts +23 -18
  231. package/dist/http/server.js +20 -15
  232. package/dist/http/stored-body-replay.js +17 -4
  233. package/dist/http/submit-ctx.d.ts +4 -3
  234. package/dist/http/submit-ctx.js +23 -6
  235. package/dist/http/submit-replay.d.ts +4 -3
  236. package/dist/http/submit-replay.js +5 -4
  237. package/dist/http/wire-types.d.ts +17 -10
  238. package/dist/index.d.ts +3 -1
  239. package/dist/index.js +1 -1
  240. package/dist/lane-home-probe.d.ts +78 -9
  241. package/dist/lane-home-probe.js +78 -12
  242. package/dist/leader/endpoint.d.ts +4 -1
  243. package/dist/leader/endpoint.js +11 -10
  244. package/dist/leader/wire.d.ts +4 -0
  245. package/dist/leader/wire.js +8 -7
  246. package/dist/limit-refusal.d.ts +17 -5
  247. package/dist/limit-refusal.js +4 -1
  248. package/dist/main.js +1 -1
  249. package/dist/mcp-assertion-header.d.ts +31 -10
  250. package/dist/mcp-assertion-header.js +10 -3
  251. package/dist/memory-origin-fence.js +2 -2
  252. package/dist/memory-project-layer.d.ts +37 -0
  253. package/dist/memory-project-layer.js +46 -0
  254. package/dist/memory-scope.d.ts +23 -16
  255. package/dist/memory-scope.js +24 -8
  256. package/dist/memory-sync-client.d.ts +27 -13
  257. package/dist/memory-sync-client.js +107 -18
  258. package/dist/model-compat.d.ts +1 -1
  259. package/dist/model-entry-refusal.d.ts +9 -1
  260. package/dist/model-entry-refusal.js +6 -1
  261. package/dist/model-plane-face.d.ts +51 -0
  262. package/dist/model-plane-face.js +24 -0
  263. package/dist/model-provider.d.ts +5 -0
  264. package/dist/model-provider.js +4 -2
  265. package/dist/model-route-endpoint.d.ts +8 -11
  266. package/dist/model-route-endpoint.js +4 -7
  267. package/dist/model-route-env.d.ts +22 -0
  268. package/dist/model-route-env.js +2 -0
  269. package/dist/model-route-gap.d.ts +60 -30
  270. package/dist/model-route-gap.js +21 -15
  271. package/dist/observability/corrupt-read-seat.d.ts +7 -0
  272. package/dist/observability/corrupt-read-seat.js +9 -0
  273. package/dist/observability/err-text.d.ts +6 -0
  274. package/dist/observability/err-text.js +18 -4
  275. package/dist/observability/fail-open.d.ts +35 -9
  276. package/dist/observability/fail-open.js +35 -9
  277. package/dist/observability/metrics.js +1 -0
  278. package/dist/observability/prompt-manifest.d.ts +22 -25
  279. package/dist/observability/prompt-manifest.js +54 -50
  280. package/dist/observability/tool-trace.js +9 -10
  281. package/dist/operator-ask.d.ts +10 -0
  282. package/dist/operator-ask.js +3 -0
  283. package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
  284. package/dist/orchestration/workflow-agent-session-index.js +9 -13
  285. package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
  286. package/dist/orchestration/workflow-completion-inbox.js +13 -0
  287. package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
  288. package/dist/orchestration/workflow-notify-journal.js +27 -34
  289. package/dist/orchestration/workflow-park-decision.d.ts +89 -0
  290. package/dist/orchestration/workflow-park-decision.js +119 -0
  291. package/dist/org-delivery-gate.d.ts +81 -0
  292. package/dist/org-delivery-gate.js +59 -0
  293. package/dist/panel-tool-names.d.ts +23 -0
  294. package/dist/panel-tool-names.js +8 -0
  295. package/dist/parked-decide.d.ts +43 -11
  296. package/dist/parked-decide.js +100 -51
  297. package/dist/parked-revive-surface.d.ts +9 -2
  298. package/dist/parked-revive-surface.js +11 -8
  299. package/dist/permission-rule-list.d.ts +1 -1
  300. package/dist/permission-rule-list.js +2 -2
  301. package/dist/permission-rule-vocab.d.ts +1 -23
  302. package/dist/permission-rule-vocab.js +0 -13
  303. package/dist/plugins/approval-ask-store-file.d.ts +16 -1
  304. package/dist/plugins/approval-ask-store-file.js +21 -0
  305. package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
  306. package/dist/plugins/approval-ask-store-memory.js +34 -2
  307. package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
  308. package/dist/plugins/approval-ask-store-sql.js +37 -1
  309. package/dist/plugins/approval-payload-fingerprint.d.ts +14 -6
  310. package/dist/plugins/approval-payload-fingerprint.js +1 -1
  311. package/dist/plugins/blob-backend.d.ts +38 -25
  312. package/dist/plugins/blob-backend.js +29 -19
  313. package/dist/plugins/breaker-state-sql.d.ts +2 -2
  314. package/dist/plugins/breaker-state-sql.js +4 -4
  315. package/dist/plugins/caching-session-store.d.ts +4 -1
  316. package/dist/plugins/caching-session-store.js +7 -3
  317. package/dist/plugins/checkpoint-store-sql.d.ts +36 -1
  318. package/dist/plugins/checkpoint-store-sql.js +65 -3
  319. package/dist/plugins/file-history-store-sql.d.ts +5 -2
  320. package/dist/plugins/file-history-store-sql.js +3 -1
  321. package/dist/plugins/file-run-store.d.ts +5 -13
  322. package/dist/plugins/file-run-store.js +9 -0
  323. package/dist/plugins/fork-routing-session-store.d.ts +9 -1
  324. package/dist/plugins/fork-routing-session-store.js +12 -1
  325. package/dist/plugins/host-platform.d.ts +2 -0
  326. package/dist/plugins/host-platform.js +2 -1
  327. package/dist/plugins/local-checkpoint-store.d.ts +15 -2
  328. package/dist/plugins/local-checkpoint-store.js +32 -1
  329. package/dist/plugins/local-session-store.d.ts +13 -10
  330. package/dist/plugins/local-session-store.js +23 -14
  331. package/dist/plugins/local-session-window.d.ts +45 -0
  332. package/dist/plugins/local-session-window.js +38 -0
  333. package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
  334. package/dist/plugins/mailbox-store-sql.d.ts +30 -48
  335. package/dist/plugins/mailbox-store-sql.js +77 -52
  336. package/dist/plugins/memory-embedder-fingerprint.js +2 -1
  337. package/dist/plugins/memory-run-store.d.ts +5 -13
  338. package/dist/plugins/memory-run-store.js +8 -0
  339. package/dist/plugins/one-time-migrations.d.ts +121 -5
  340. package/dist/plugins/one-time-migrations.js +332 -8
  341. package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
  342. package/dist/plugins/org-delivery-quota-store.js +228 -0
  343. package/dist/plugins/permission-rule-store-file.js +10 -6
  344. package/dist/plugins/permission-rule-store-sql.js +8 -8
  345. package/dist/plugins/pg-pool.js +39 -7
  346. package/dist/plugins/pg-session-storage.d.ts +18 -5
  347. package/dist/plugins/pg-session-storage.js +68 -23
  348. package/dist/plugins/remote-env-adb.d.ts +6 -12
  349. package/dist/plugins/remote-env-adb.js +12 -2
  350. package/dist/plugins/remote-env-device.d.ts +14 -7
  351. package/dist/plugins/remote-env-device.js +23 -15
  352. package/dist/plugins/remote-env-k8s.d.ts +8 -12
  353. package/dist/plugins/remote-env-k8s.js +23 -5
  354. package/dist/plugins/remote-env-local-docker.d.ts +10 -15
  355. package/dist/plugins/remote-env-local-docker.js +12 -9
  356. package/dist/plugins/remote-env-ssh.d.ts +10 -16
  357. package/dist/plugins/remote-env-ssh.js +17 -11
  358. package/dist/plugins/run-store-sql.d.ts +16 -14
  359. package/dist/plugins/run-store-sql.js +22 -2
  360. package/dist/plugins/schema-indexes.js +2 -0
  361. package/dist/plugins/send-user-file.js +2 -2
  362. package/dist/plugins/session-epoch-anchor.d.ts +32 -6
  363. package/dist/plugins/session-epoch-anchor.js +2 -3
  364. package/dist/plugins/session-ownership.d.ts +11 -0
  365. package/dist/plugins/session-ownership.js +11 -0
  366. package/dist/plugins/session-placement.d.ts +12 -14
  367. package/dist/plugins/session-placement.js +2 -15
  368. package/dist/plugins/session-store.d.ts +18 -8
  369. package/dist/plugins/session-store.js +15 -4
  370. package/dist/plugins/sql-driver.d.ts +74 -11
  371. package/dist/plugins/sql-driver.js +210 -12
  372. package/dist/plugins/sql-errors.d.ts +23 -0
  373. package/dist/plugins/sql-errors.js +21 -0
  374. package/dist/plugins/store-backend.d.ts +36 -1
  375. package/dist/plugins/store-backend.js +40 -14
  376. package/dist/plugins/store-contracts.d.ts +42 -0
  377. package/dist/plugins/store-contracts.js +1 -0
  378. package/dist/plugins/tidb-pool.d.ts +6 -1
  379. package/dist/plugins/tidb-pool.js +44 -10
  380. package/dist/plugins/tidb-session-storage.d.ts +3 -2
  381. package/dist/plugins/tidb-session-storage.js +2 -2
  382. package/dist/plugins/tidb-session-store.d.ts +25 -5
  383. package/dist/plugins/tidb-session-store.js +67 -21
  384. package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
  385. package/dist/plugins/workflow-journal-store-sql.js +19 -6
  386. package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
  387. package/dist/plugins/workflow-run-store-sql.js +50 -9
  388. package/dist/posture-source.d.ts +18 -10
  389. package/dist/posture-source.js +4 -1
  390. package/dist/project-identity.d.ts +45 -6
  391. package/dist/project-identity.js +162 -8
  392. package/dist/project-layer-key.d.ts +28 -0
  393. package/dist/project-layer-key.js +29 -0
  394. package/dist/question.js +3 -2
  395. package/dist/read-deny-entry.d.ts +25 -0
  396. package/dist/read-deny-entry.js +12 -0
  397. package/dist/read-face-posture.d.ts +37 -11
  398. package/dist/read-face-posture.js +32 -3
  399. package/dist/request-key-closure.d.ts +7 -0
  400. package/dist/request-key-closure.js +9 -1
  401. package/dist/request-tool-axes.d.ts +12 -0
  402. package/dist/request-tool-axes.js +20 -0
  403. package/dist/request-value-closure.d.ts +5 -0
  404. package/dist/request-value-closure.js +11 -3
  405. package/dist/rule-entry-list.d.ts +26 -2
  406. package/dist/rule-entry-list.js +72 -12
  407. package/dist/rules-consent.js +3 -4
  408. package/dist/run-acceptance.d.ts +19 -3
  409. package/dist/run-acceptance.js +13 -1
  410. package/dist/run-local.js +37 -6
  411. package/dist/runs.d.ts +12 -10
  412. package/dist/runs.js +25 -6
  413. package/dist/runtime-caps-resolver.d.ts +16 -6
  414. package/dist/runtime-caps-resolver.js +18 -5
  415. package/dist/sandbox-pkg-source.d.ts +19 -1
  416. package/dist/sandbox-pkg-source.js +29 -7
  417. package/dist/sealed-key.d.ts +32 -0
  418. package/dist/sealed-key.js +55 -1
  419. package/dist/security.d.ts +95 -15
  420. package/dist/security.js +52 -9
  421. package/dist/session-error-wire.d.ts +31 -7
  422. package/dist/session-error-wire.js +9 -2
  423. package/dist/session-sync-kernel.d.ts +37 -10
  424. package/dist/session-sync-kernel.js +10 -0
  425. package/dist/session-titled-frame.d.ts +33 -0
  426. package/dist/session-titled-frame.js +4 -0
  427. package/dist/session-titler.d.ts +9 -1
  428. package/dist/session-titler.js +15 -4
  429. package/dist/spec-fields.js +21 -2
  430. package/dist/sql-engine-posture.d.ts +3 -1
  431. package/dist/task-a2a.js +4 -3
  432. package/dist/task-cwd.d.ts +1 -1
  433. package/dist/task-mcp.d.ts +5 -5
  434. package/dist/task-mcp.js +27 -74
  435. package/dist/task-settings.d.ts +93 -88
  436. package/dist/task-settings.js +71 -63
  437. package/dist/text-bidi.d.ts +0 -4
  438. package/dist/text-bidi.js +1 -3
  439. package/dist/tighten-only-seats.d.ts +150 -0
  440. package/dist/tighten-only-seats.js +196 -0
  441. package/dist/tool-approval.d.ts +451 -136
  442. package/dist/tool-approval.js +733 -256
  443. package/dist/tool-rule-names.d.ts +6 -0
  444. package/dist/trace/core-keyset-guard.d.ts +108 -25
  445. package/dist/trace/exit-seat.d.ts +40 -0
  446. package/dist/trace/exit-seat.js +130 -0
  447. package/dist/trace/ledger-events.d.ts +6 -3
  448. package/dist/trace/project.d.ts +98 -13
  449. package/dist/trace/project.js +57 -32
  450. package/dist/trace/projection-table.d.ts +100 -0
  451. package/dist/trace/projection-table.js +130 -0
  452. package/dist/trace/redact.d.ts +57 -0
  453. package/dist/trace/redact.js +962 -168
  454. package/dist/trace/self-minted-wire.d.ts +349 -1
  455. package/dist/trace/self-minted-wire.js +118 -1
  456. package/dist/trace/wire-projection-faces.d.ts +304 -2
  457. package/dist/trace/wire-projection-faces.js +160 -13
  458. package/dist/url-refusal.js +2 -0
  459. package/dist/web-admin-client/apply-effective.d.ts +12 -0
  460. package/dist/web-admin-client/apply-effective.js +56 -5
  461. package/dist/web-admin-client/facade.d.ts +1 -1
  462. package/dist/web-admin-client/facade.js +1 -1
  463. package/dist/web-admin-client/read-face.js +5 -9
  464. package/dist/web-admin-client/skills-mcp.d.ts +1 -1
  465. package/dist/web-admin-client/skills-mcp.js +6 -8
  466. package/dist/web-admin-client/types.d.ts +1 -1
  467. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
  468. package/package.json +8 -4
  469. package/scripts/drain-check-local.mjs +34 -2
  470. package/scripts/drain-check.mysql.sql +20 -2
  471. package/scripts/drain-check.pg.sql +20 -2
  472. package/dist/mcp-tool-faces.d.ts +0 -69
  473. package/dist/mcp-tool-faces.js +0 -106
@@ -26,6 +26,8 @@
26
26
  import type { GateOutcome, McpDelivered, TaskResult, SystemInjectionPriority } from "@sema-agent/core";
27
27
  import type { RunEvent, RunRecord } from "../plugins/store-contracts.js";
28
28
  import type { ModelUsageDelta, ModelUsageTracker, PromptManifestRecord } from "../budget.js";
29
+ import type { RunCompanionRecord } from "../observability/prompt-manifest.js";
30
+ import { type SafeText } from "./exit-seat.js";
29
31
  import { type SemaProvenanceInput } from "./sema-provenance.js";
30
32
  import type { LedgerEventType } from "./ledger-events.js";
31
33
  import type { InstructionsSegment } from "../instruction-selection.js";
@@ -50,7 +52,7 @@ export declare function appendModelUsageDelta(append: AppendFn, modelUsage: Mode
50
52
  * (one Map.get), so callers fire it liberally. */
51
53
  export declare function appendPromptManifest(append: AppendFn, tracker: {
52
54
  drain(taskId: string): PromptManifestRecord[] | undefined;
53
- drainConfig?(taskId: string): Array<Record<string, unknown>> | undefined;
55
+ drainCompanions?(taskId: string): RunCompanionRecord[] | undefined;
54
56
  } | undefined, taskId: string): Promise<void>;
55
57
  /** E8: at a TERMINAL done — flush the final delta, then SUM all `model_usage` events (every process leg) into the
56
58
  * result's `stats.modelUsage` echo. Returns the result unchanged when no usage was tracked (shell soft-degrades). */
@@ -81,6 +83,13 @@ export declare function attachModelUsage<T extends TaskResult>(result: T, ctx: {
81
83
  * · **键在场但值坏**(NaN / 字符串 / null)= 数据损坏,写了键的 producer 是在声称自己知道 ⇒ 维持既有
82
84
  * 折叠(按 0 计,不传染,已知量不受损),否则一条陈年坏行就能把整个模型的成本抹成"未知"。
83
85
  * 下游补偿件早已就位:usage-analytics 的 numOf + `estimated` 标记(缺数值键 ⇒ 总量偏低并诚实标注)。 */
86
+ /** **trace 帧数据的出口形**(RH-1 第一期):`Slots` 里列出的自由文本位只收 {@link SafeText}(出口座铸的),其余键照旧开放 ——
87
+ * 裸 `string` 写进这些位是 tsc 红;整只帧数据**只读**(交出去之后按键改写 —— 含动态键 `frame[k] = raw` —— 也是 tsc 红)。
88
+ * 对既有的 `Record<string, unknown>` 读者可赋值(零调用点改动)。类型层管不到的两形如实记:`any` 值、以及把一只 `Record<string, unknown>`
89
+ * 展开进字面量 / `Object.assign` 事后改写(TypeScript 不拿索引签名去对可选位、也不查 `Object.assign` 的目标)—— 品牌推到汇(SSE 写口 / 账本 append)是第三期。 */
90
+ type FrameData<Slots extends object> = Readonly<Slots> & {
91
+ readonly [key: string]: unknown;
92
+ };
84
93
  export declare function aggregateModelUsage(events: RunEvent[]): Record<string, ModelUsageDelta> | undefined;
85
94
  export type TraceBlock = {
86
95
  type: "thinking";
@@ -373,7 +382,11 @@ export declare function taskProgressEventData(ev: {
373
382
  workflowAgentLabel?: string;
374
383
  seq?: number;
375
384
  model?: string;
376
- }): Record<string, unknown>;
385
+ }): FrameData<{
386
+ name?: SafeText;
387
+ currentAction?: SafeText;
388
+ workflowAgentLabel?: SafeText;
389
+ }>;
377
390
  /**
378
391
  * The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
379
392
  * 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
@@ -414,7 +427,10 @@ export declare function taskStartedEventData(ev: {
414
427
  startedAt: number;
415
428
  eventId?: string;
416
429
  parentToolCallId?: string;
417
- }): Record<string, unknown>;
430
+ }): FrameData<{
431
+ name?: SafeText;
432
+ workflowAgentLabel?: SafeText;
433
+ }>;
418
434
  /** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
419
435
  * LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
420
436
  * attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
@@ -492,7 +508,28 @@ export declare function taskNotificationEventData(ev: {
492
508
  * **事件顶层**键,不是 {@link TaskNotificationPayload} 的键,所以只有把整只 core 事件交给本投影的腿
493
509
  * 拿得到它;只拿到载荷的 park-drain 腿结构上没有这一位。 */
494
510
  priority?: SystemInjectionPriority;
495
- }): Record<string, unknown>;
511
+ }): FrameData<{
512
+ summary: SafeText;
513
+ result?: SafeText;
514
+ output_file?: SafeText;
515
+ source?: SafeText;
516
+ diagnostics?: SafeText;
517
+ error?: SafeText;
518
+ lines?: SafeText[];
519
+ recentSteps?: Array<{
520
+ tool: string;
521
+ target: SafeText;
522
+ outcome: SafeText;
523
+ }>;
524
+ editedFiles?: Array<{
525
+ path: SafeText;
526
+ edits: number;
527
+ }>;
528
+ agentMessage?: {
529
+ from: string;
530
+ body: SafeText;
531
+ };
532
+ }>;
496
533
  /** The `compacted` payload — EXPLICIT WHITELIST shared by all three legs (bg runs.ts + resume append + the sync
497
534
  * live SSE frame; the 1.72 task_progress lesson: never `{...ev}`). trigger/tokensBefore (MF-18) verbatim;
498
535
  * `preserved_segment.firstKeptEntryId` verbatim (a core-mint entryId, the shell's compaction-divider anchor);
@@ -519,7 +556,16 @@ export declare function diagnosticsEventData(ev: {
519
556
  isNew: boolean;
520
557
  eventId?: string;
521
558
  parentToolCallId?: string;
522
- }): Record<string, unknown>;
559
+ }): FrameData<{
560
+ files: Array<{
561
+ uri: SafeText;
562
+ diagnostics: Array<FrameData<{
563
+ message: SafeText;
564
+ code?: SafeText | number;
565
+ source?: SafeText;
566
+ }>>;
567
+ }>;
568
+ }>;
523
569
  /** The `steering_injected` payload([ref]/[ref] 裁定透传;core `TaskEvent` 联合臂 `type: "steering_injected"`,
524
570
  * shell 渲染源 = CC 的系统提醒条:core 在 turn 之间给模型注入一条系统提示[todo 提醒/文件变化/日期跨天/
525
571
  * 技能列表变化…]时随手抛的展示投影,一附件一帧)。EXPLICIT WHITELIST(source=封闭枚举 verbatim;
@@ -530,7 +576,9 @@ export declare function steeringInjectedEventData(ev: {
530
576
  preview: string;
531
577
  eventId?: string;
532
578
  parentToolCallId?: string;
533
- }): Record<string, unknown>;
579
+ }): FrameData<{
580
+ preview: SafeText;
581
+ }>;
534
582
  /** `compaction_outcome`(core 2.5.0 [ref]②:压缩非 compacted 结局——manual /compact 的 mooted/failed
535
583
  * 两条真路)。[ref]A-2/C-2:此前它是**唯一**不走共享 builder、只在 live 腿 res.write 内联挑键的
536
584
  * 内容帧 ⇒ 两条 durable 腿零 case、回放即消失、三方普查各自失明。收进共享白名单 builder,三腿同源。
@@ -542,7 +590,9 @@ export declare function compactionOutcomeEventData(ev: {
542
590
  pass?: unknown;
543
591
  eventId?: unknown;
544
592
  parentToolCallId?: unknown;
545
- }): Record<string, unknown>;
593
+ }): FrameData<{
594
+ reason?: SafeText;
595
+ }>;
546
596
  /**
547
597
  * `compaction_started`(S-1732,core 7.53.0 #2008)—— 一次压缩 pass 在提交点(触发闸过了、切点在、`preCompact` 没拦)宣告开始,先于摘要调用:
548
598
  * 一次在供应方重试表里等很久的摘要(core 实测 503 × 11、173 s)从此在流上不是静默的。**原样投影**:`{ trigger, pass, startedAt }` + 身份两键,
@@ -567,7 +617,9 @@ export declare function workspaceChangedEventData(ev: {
567
617
  cwd: string;
568
618
  eventId?: string;
569
619
  parentToolCallId?: string;
570
- }): Record<string, unknown>;
620
+ }): FrameData<{
621
+ cwd: SafeText;
622
+ }>;
571
623
  /**
572
624
  * `wiring_manifest`(core 5.14.0 [ref] 新 `TaskEvent` 臂)—— 每条腿(root/child/resume)在 prepare
573
625
  * 时自证「我到底接了什么线」的清单帧。
@@ -802,8 +854,8 @@ export declare function wiringManifestEventData(ev: {
802
854
  * 代价是 operator 看不到历史腿的 governance 段 —— 治理四布尔是部署形事实(不随 leg 漂),静态自检面
803
855
  * (`GET /v1/diagnostics/wiring`)随时给出当前真值。
804
856
  *
805
- * 准入判据是 `explicitOperatorOk`(**不是** `isOperator`):空 `OPERATOR_PRINCIPALS` 必须是「没有人是
806
- * operator」,不能是「所有人都是」—— 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。
857
+ * 准入判据是 `explicitOperatorOk`(「谁是 operator」的唯一读法):空 `OPERATOR_PRINCIPALS` 是「没有人是 operator」,不是「所有人都是」——
858
+ * 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。单用户形显式声明 `OPERATOR_SINGLE_USER=true` 时它的每个调用方都是。
807
859
  *
808
860
  * `configFingerprint` 只在本构造器里透传:它是 `sha256(canonicalize(manifest 去 leg/去两个 provenance))`
809
861
  * 前 16 hex,**无盐**且输入含整个 governance 段,而 governance 只有 4 个布尔 ⇒ 16 种组合。租户手里已有其余
@@ -885,7 +937,16 @@ export declare function humanInputEventData(ev: {
885
937
  attachments?: unknown;
886
938
  eventId?: unknown;
887
939
  parentToolCallId?: unknown;
888
- }): Record<string, unknown>;
940
+ }): FrameData<{
941
+ issuer?: SafeText;
942
+ actor?: FrameData<{
943
+ id?: SafeText;
944
+ issuer?: SafeText;
945
+ }>;
946
+ attachments?: Array<FrameData<{
947
+ label?: SafeText;
948
+ }>>;
949
+ }>;
889
950
  /** S4 (SILENT-FALLBACK P0-a): the durable `brain_status` observation row, shared by the bg + resume append
890
951
  * sites. core marks the live `status` frame EPHEMERAL (never replayed by core on resume) — this row is the
891
952
  * SERVICE's own observation record (why a turn stalled: rate_limited/retrying/reconnecting/circuit_open, and
@@ -907,7 +968,9 @@ export declare function brainStatusEventData(ev: {
907
968
  providerConditionSource?: string;
908
969
  eventId?: string;
909
970
  parentToolCallId?: string;
910
- }): Record<string, unknown>;
971
+ }): FrameData<{
972
+ detail?: SafeText;
973
+ }>;
911
974
  export declare function compactedEventData(ev: {
912
975
  eventId?: string;
913
976
  parentToolCallId?: string;
@@ -945,7 +1008,13 @@ export declare function compactedEventData(ev: {
945
1008
  };
946
1009
  /** S-1732(core 7.53.0 #2008):这次落地的压缩 pass 的 id —— 与它的 `compaction_started` 帧同一个值(引擎在每次落地上都设;型上可选)。逐字。 */
947
1010
  pass?: string;
948
- }): Record<string, unknown>;
1011
+ }): FrameData<{
1012
+ attachedFiles?: Array<{
1013
+ path: SafeText;
1014
+ chars: number;
1015
+ truncated: boolean;
1016
+ }>;
1017
+ }>;
949
1018
  export interface TraceTurn {
950
1019
  /** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
951
1020
  seq: number;
@@ -1015,6 +1084,22 @@ export declare function contextUsageEventData(ev: {
1015
1084
  * 与结果面的孪生 `TaskResult.responseModel` 同一只闸 —— 同一个名字在两张脸上不许两种待遇。非串 / 空串同样不铸键(空串在
1016
1085
  * 那条谓词的长度下界之外;core 的读律 `providerReportedModel` 对空串也答「没报」)。
1017
1086
  */
1087
+ /**
1088
+ * 🔴 core 7.54.0 [ref] O9b S1 —— 设备车道发射闸的 `permission.cross_boundary_taint` 帧 → 耐久行 `cross_boundary_taint`(`GET /v1/runs/:id/events` 账本回放同名交出;
1089
+ * trace SSE `GET /v1/tasks/:id/stream` 上是 `cross-boundary-taint` 帧,按存下的行原样交出)。帧只在**执行于目标设备的树**上发(武装腿 prepare / 续跑腿 resume 各一帧,离目标读第一次放进树时 observed 一帧),
1090
+ * 宿主车道零帧 ⇒ 本行在宿主车道上永不出现。纯元数据(core 逐字「Metadata only」):树的污染位(`taint`,core `CROSS_BOUNDARY_TAINT_BITS` 的子集)、
1091
+ * 树是否受治理(`governed`)、阶段(`phase`)、腿的 `runId`,observed 时那一只调用(`toolName` / `toolCallId`)。
1092
+ * 信封(`kind` / `version` / `taskId` / `ts`)不上行:行自带 seq / ts,run 就是 taskId(与清单行同一条律;登记表 `cross_boundary_taint` 行)。
1093
+ * 值:`taint` 交一份数组副本(只收串);`toolName` / `toolCallId` 在场才铸。词按开集串过境(属主是引擎的闭集;本仓不判词表)。
1094
+ */
1095
+ export declare function crossBoundaryTaintEventData(ev: {
1096
+ runId?: unknown;
1097
+ phase?: unknown;
1098
+ taint?: unknown;
1099
+ governed?: unknown;
1100
+ toolName?: unknown;
1101
+ toolCallId?: unknown;
1102
+ }): Record<string, unknown>;
1018
1103
  export declare function turnEndEventData(ev: {
1019
1104
  usage?: unknown;
1020
1105
  usageMissing?: true;
@@ -3,6 +3,7 @@ import { MCP_DELIVERY_VERDICTS, MCP_LIVENESS_STATES, screenGateOutcome, TEAM_ROL
3
3
  import { Value } from "typebox/value";
4
4
  import { recordFailOpen } from "../observability/fail-open.js";
5
5
  import { redactSecrets, redactDeep } from "./redact.js";
6
+ import { seatText } from "./exit-seat.js";
6
7
  import { sanitizeWireText } from "./engine-notice-wire.js";
7
8
  import { projectToolOutput, projectToolStructured } from "./tool-output-media.js";
8
9
  import { injectionTierOrAbsent } from "./injection-tier.js";
@@ -23,10 +24,10 @@ export async function appendPromptManifest(append, tracker, taskId) {
23
24
  if (records)
24
25
  for (const m of records)
25
26
  await append("prompt_assembled", m);
26
- const cfgs = tracker?.drainConfig?.(taskId);
27
- if (cfgs)
28
- for (const cfg of cfgs)
29
- await append("config_assembled", cfg);
27
+ const companions = tracker?.drainCompanions?.(taskId);
28
+ if (companions)
29
+ for (const c of companions)
30
+ await append(c.type, c.data);
30
31
  }
31
32
  export async function attachModelUsage(result, ctx) {
32
33
  if (!ctx.modelUsage)
@@ -270,14 +271,14 @@ export function taskProgressEventData(ev) {
270
271
  ...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
271
272
  ...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
272
273
  ...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
273
- ...(ev.name ? { name: redactSecrets(ev.name) } : {}),
274
+ ...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
274
275
  ...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
275
276
  ...(typeof ev.model === "string" && ev.model.length > 0 ? { model: ev.model } : {}),
276
277
  ...(ev.status !== undefined ? { status: ev.status } : {}),
277
278
  ...(ev.usage ? { usage: ev.usage } : {}),
278
- ...(ev.currentAction ? { currentAction: redactSecrets(ev.currentAction) } : {}),
279
+ ...(ev.currentAction ? { currentAction: seatText("trace-frame-text", ev.currentAction) } : {}),
279
280
  ...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
280
- ...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
281
+ ...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
281
282
  ...identityFields(ev),
282
283
  };
283
284
  }
@@ -288,11 +289,11 @@ export function taskStartedEventData(ev) {
288
289
  ...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
289
290
  ...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
290
291
  ...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
291
- ...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
292
+ ...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
292
293
  ...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
293
294
  ...(ev.parentSessionId ? { parentSessionId: ev.parentSessionId } : {}),
294
295
  ...(ev.rootSessionId ? { rootSessionId: ev.rootSessionId } : {}),
295
- ...(ev.name ? { name: redactSecrets(ev.name) } : {}),
296
+ ...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
296
297
  ...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
297
298
  ...(ev.agentType ? { agentType: ev.agentType } : {}),
298
299
  model: ev.model,
@@ -310,10 +311,10 @@ export function taskNotificationEventData(ev) {
310
311
  ...(n.toolUseId !== undefined ? { toolUseId: n.toolUseId } : {}),
311
312
  status: n.status,
312
313
  ...(n.seq !== undefined ? { seq: n.seq } : {}),
313
- ...(n.lines !== undefined ? { lines: n.lines.map((l) => redactSecrets(l)) } : {}),
314
+ ...(n.lines !== undefined ? { lines: n.lines.map((l) => seatText("trace-frame-text", l)) } : {}),
314
315
  ...(n.stoppedBy !== undefined ? { stoppedBy: n.stoppedBy } : {}),
315
316
  ...(n.completionId !== undefined ? { completionId: n.completionId } : {}),
316
- ...(n.error !== undefined ? { error: redactSecrets(n.error) } : {}),
317
+ ...(n.error !== undefined ? { error: seatText("trace-frame-text", n.error) } : {}),
317
318
  ...(n.errorCode !== undefined ? { errorCode: n.errorCode } : {}),
318
319
  ...(n.apiFailure !== undefined
319
320
  ? {
@@ -323,20 +324,20 @@ export function taskNotificationEventData(ev) {
323
324
  },
324
325
  }
325
326
  : {}),
326
- ...(n.source !== undefined ? { source: redactSecrets(n.source) } : {}),
327
+ ...(n.source !== undefined ? { source: seatText("trace-frame-text", n.source) } : {}),
327
328
  ...(n.exitCode !== undefined ? { exitCode: n.exitCode } : {}),
328
329
  ...(n.partial !== undefined ? { partial: n.partial } : {}),
329
- ...(n.diagnostics !== undefined ? { diagnostics: redactSecrets(n.diagnostics) } : {}),
330
+ ...(n.diagnostics !== undefined ? { diagnostics: seatText("trace-frame-text", n.diagnostics) } : {}),
330
331
  ...(n.recentSteps !== undefined
331
- ? { recentSteps: n.recentSteps.map((s) => ({ tool: s.tool, target: redactSecrets(s.target), outcome: redactSecrets(s.outcome) })) }
332
+ ? { recentSteps: n.recentSteps.map((s) => ({ tool: s.tool, target: seatText("trace-frame-text", s.target), outcome: seatText("trace-frame-text", s.outcome) })) }
332
333
  : {}),
333
- ...(n.editedFiles !== undefined ? { editedFiles: n.editedFiles.map((f) => ({ path: redactSecrets(f.path), edits: f.edits })) } : {}),
334
+ ...(n.editedFiles !== undefined ? { editedFiles: n.editedFiles.map((f) => ({ path: seatText("trace-frame-text", f.path), edits: f.edits })) } : {}),
334
335
  ...(n.resumable !== undefined ? { resumable: n.resumable } : {}),
335
- summary: redactSecrets(n.summary),
336
- ...(n.result !== undefined ? { result: redactSecrets(n.result) } : {}),
337
- ...(n.output_file !== undefined ? { output_file: redactSecrets(n.output_file) } : {}),
336
+ summary: seatText("trace-frame-text", n.summary),
337
+ ...(n.result !== undefined ? { result: seatText("trace-frame-text", n.result) } : {}),
338
+ ...(n.output_file !== undefined ? { output_file: seatText("trace-frame-text", n.output_file) } : {}),
338
339
  ...(n.usage !== undefined ? { usage: n.usage } : {}),
339
- ...(n.agentMessage !== undefined ? { agentMessage: { from: n.agentMessage.from, body: redactSecrets(n.agentMessage.body) } } : {}),
340
+ ...(n.agentMessage !== undefined ? { agentMessage: { from: n.agentMessage.from, body: seatText("trace-frame-text", n.agentMessage.body) } } : {}),
340
341
  ...(() => {
341
342
  if (n._sema_provenance === undefined)
342
343
  return {};
@@ -355,13 +356,13 @@ export function taskNotificationEventData(ev) {
355
356
  export function diagnosticsEventData(ev) {
356
357
  return {
357
358
  files: (Array.isArray(ev.files) ? ev.files : []).map((f) => ({
358
- uri: redactSecrets(String(f.uri)),
359
+ uri: seatText("trace-frame-text", String(f.uri)),
359
360
  diagnostics: (Array.isArray(f.diagnostics) ? f.diagnostics : []).map((d) => ({
360
- message: redactSecrets(String(d.message)),
361
+ message: seatText("trace-frame-text", String(d.message)),
361
362
  ...(d.severity !== undefined ? { severity: d.severity } : {}),
362
363
  ...(d.range !== undefined ? { range: d.range } : {}),
363
- ...(d.code !== undefined ? { code: typeof d.code === "number" ? d.code : redactSecrets(String(d.code)) } : {}),
364
- ...(d.source !== undefined ? { source: redactSecrets(String(d.source)) } : {}),
364
+ ...(d.code !== undefined ? { code: typeof d.code === "number" ? d.code : seatText("trace-frame-text", String(d.code)) } : {}),
365
+ ...(d.source !== undefined ? { source: seatText("trace-frame-text", String(d.source)) } : {}),
365
366
  })),
366
367
  })),
367
368
  isNew: ev.isNew === true,
@@ -371,7 +372,7 @@ export function diagnosticsEventData(ev) {
371
372
  export function steeringInjectedEventData(ev) {
372
373
  return {
373
374
  source: String(ev.source),
374
- preview: redactSecrets(String(ev.preview)),
375
+ preview: seatText("trace-frame-text", String(ev.preview)),
375
376
  ...identityFields(ev),
376
377
  };
377
378
  }
@@ -380,7 +381,7 @@ export function compactionOutcomeEventData(ev) {
380
381
  return {
381
382
  ...(s(ev.outcome) !== undefined ? { outcome: s(ev.outcome) } : {}),
382
383
  ...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
383
- ...(ev.reason !== undefined ? { reason: redactSecrets(String(ev.reason)) } : {}),
384
+ ...(ev.reason !== undefined ? { reason: seatText("trace-frame-text", String(ev.reason)) } : {}),
384
385
  ...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
385
386
  ...identityFields(ev),
386
387
  };
@@ -396,7 +397,7 @@ export function compactionStartedEventData(ev) {
396
397
  }
397
398
  export function workspaceChangedEventData(ev) {
398
399
  return {
399
- cwd: redactSecrets(String(ev.cwd)).slice(0, 300),
400
+ cwd: seatText("trace-frame-line", String(ev.cwd)),
400
401
  ...identityFields(ev),
401
402
  };
402
403
  }
@@ -629,11 +630,23 @@ export function wiringManifestEventData(ev, instructions) {
629
630
  return dropProjectedFace("wiring_manifest.fileHistory is not a non-empty string");
630
631
  return word;
631
632
  })();
633
+ const permissionMode = (() => {
634
+ if (m.permissionMode === undefined)
635
+ return undefined;
636
+ const seg = sec(m.permissionMode);
637
+ const effective = str(seg?.effective);
638
+ const requested = seg?.requested === undefined ? undefined : str(seg.requested);
639
+ const foldedBy = seg?.foldedBy === undefined ? undefined : str(seg.foldedBy);
640
+ if (effective === undefined || (seg?.requested !== undefined && requested === undefined) || (seg?.foldedBy !== undefined && foldedBy === undefined))
641
+ return dropProjectedFace("wiring_manifest.permissionMode is not a receipt shape (effective a non-empty string, requested / foldedBy absent or non-empty strings)");
642
+ return { ...(requested !== undefined ? { requested } : {}), effective, ...(foldedBy !== undefined ? { foldedBy } : {}) };
643
+ })();
632
644
  return {
633
645
  ...(num(m.schemaVersion) !== undefined ? { schemaVersion: m.schemaVersion } : {}),
634
646
  ...(str(legIn.kind) !== undefined ? { leg: { kind: legIn.kind } } : {}),
635
647
  ...(teamRole !== undefined ? { teamRole } : {}),
636
648
  ...(fileHistory !== undefined ? { fileHistory } : {}),
649
+ ...(permissionMode !== undefined ? { permissionMode } : {}),
637
650
  ...(ask !== undefined ? { ask } : {}),
638
651
  ...(question !== undefined ? { question } : {}),
639
652
  ...(str(interactionIn.posture) !== undefined ? { interaction: { posture: interactionIn.posture } } : {}),
@@ -712,13 +725,13 @@ export function humanInputEventData(ev) {
712
725
  ...(typeof m.ordinal === "number" && Number.isFinite(m.ordinal) ? { ordinal: m.ordinal } : {}),
713
726
  ...(str(m.kind) !== undefined ? { kind: m.kind } : {}),
714
727
  ...(str(m.outcome) !== undefined ? { outcome: m.outcome } : {}),
715
- ...(str(m.label) !== undefined ? { label: redactSecrets(String(m.label)) } : {}),
728
+ ...(str(m.label) !== undefined ? { label: seatText("trace-frame-text", String(m.label)) } : {}),
716
729
  }))
717
730
  : undefined;
718
731
  const actor = {
719
- ...(str(a.id) !== undefined ? { id: redactSecrets(String(a.id)) } : {}),
732
+ ...(str(a.id) !== undefined ? { id: seatText("trace-frame-text", String(a.id)) } : {}),
720
733
  ...(typeof a.hostAsserted === "boolean" ? { hostAsserted: a.hostAsserted } : {}),
721
- ...(str(a.issuer) !== undefined ? { issuer: redactSecrets(String(a.issuer)) } : {}),
734
+ ...(str(a.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(a.issuer)) } : {}),
722
735
  };
723
736
  return {
724
737
  ...(str(ev.inputId) !== undefined ? { inputId: ev.inputId } : {}),
@@ -726,7 +739,7 @@ export function humanInputEventData(ev) {
726
739
  ...(str(ev.carrier) !== undefined ? { carrier: ev.carrier } : {}),
727
740
  ...(str(ev.source) !== undefined ? { source: ev.source } : {}),
728
741
  ...(str(ev.delivery) !== undefined ? { delivery: ev.delivery } : {}),
729
- ...(str(ev.issuer) !== undefined ? { issuer: redactSecrets(String(ev.issuer)) } : {}),
742
+ ...(str(ev.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(ev.issuer)) } : {}),
730
743
  ...(Object.keys(actor).length > 0 ? { actor } : {}),
731
744
  ...(str(ev.entryId) !== undefined ? { entryId: ev.entryId } : {}),
732
745
  ...(attachments !== undefined ? { attachments } : {}),
@@ -737,7 +750,7 @@ export function brainStatusEventData(ev) {
737
750
  const num = (v) => typeof v === "number" && Number.isFinite(v);
738
751
  return {
739
752
  phase: String(ev.phase),
740
- ...(typeof ev.detail === "string" && ev.detail.length > 0 ? { detail: redactSecrets(ev.detail).slice(0, 300) } : {}),
753
+ ...(typeof ev.detail === "string" && ev.detail.length > 0 ? { detail: seatText("trace-frame-line", ev.detail) } : {}),
741
754
  ...(num(ev.retryInSec) ? { retryInSec: ev.retryInSec } : {}),
742
755
  ...(num(ev.attempt) ? { attempt: ev.attempt } : {}),
743
756
  ...(num(ev.maxRetries) ? { maxRetries: ev.maxRetries } : {}),
@@ -777,7 +790,7 @@ export function compactedEventData(ev) {
777
790
  const files = ev.attachedFiles
778
791
  .filter((f) => typeof f === "object" && f !== null && typeof f.path === "string"
779
792
  && num(f.chars) !== undefined && typeof f.truncated === "boolean")
780
- .map((f) => ({ path: redactSecrets(f.path), chars: f.chars, truncated: f.truncated }));
793
+ .map((f) => ({ path: seatText("trace-frame-text", f.path), chars: f.chars, truncated: f.truncated }));
781
794
  return files.length > 0 ? { attachedFiles: files } : {};
782
795
  })(),
783
796
  ...(ev.modelFallback === true ? { modelFallback: true } : {}),
@@ -833,6 +846,16 @@ function contextUsageSectionsField(sections) {
833
846
  }
834
847
  return out.length > 0 ? { sections: out } : {};
835
848
  }
849
+ export function crossBoundaryTaintEventData(ev) {
850
+ return {
851
+ ...(typeof ev.runId === "string" ? { runId: ev.runId } : {}),
852
+ ...(typeof ev.phase === "string" ? { phase: ev.phase } : {}),
853
+ ...(Array.isArray(ev.taint) ? { taint: ev.taint.filter((b) => typeof b === "string") } : {}),
854
+ ...(typeof ev.governed === "boolean" ? { governed: ev.governed } : {}),
855
+ ...(typeof ev.toolName === "string" ? { toolName: ev.toolName } : {}),
856
+ ...(typeof ev.toolCallId === "string" ? { toolCallId: ev.toolCallId } : {}),
857
+ };
858
+ }
836
859
  export function turnEndEventData(ev) {
837
860
  return {
838
861
  ...(ev.usage ? { usage: ev.usage } : {}),
@@ -991,6 +1014,8 @@ function mapTraceEventInner(type, seq, data) {
991
1014
  }
992
1015
  case "prompt_assembled":
993
1016
  return { event: "prompt-assembled", data: { seq, ...data } };
1017
+ case "cross_boundary_taint":
1018
+ return { event: "cross-boundary-taint", data: { seq, ...data } };
994
1019
  case "done":
995
1020
  return { event: "done", data: { seq } };
996
1021
  case "suspended":
@@ -0,0 +1,100 @@
1
+ /**
2
+ * **投影处置表**:一个 core 类型在一张出口面上的样子,只由一张表回答。
3
+ *
4
+ * ## 一条规则
5
+ * 表对该类型的**每一个键**给四词之一,表外键 = tsc 红(`satisfies DispositionTable<T, …>`):
6
+ * · `"forward"` —— 原值出门(只配叶值:原语或原语列表);`{ forward: 读法 }` = 读法认得才出门(读不出 ⇒ 键缺席并计一次),值不改;
7
+ * · `"strip"` —— 本面不出现;
8
+ * · `{ redact: 入口 }` —— 原值经**点名的既有脱敏入口**出门(词就是那只导出的名字,本模块不另铸脱敏逻辑);
9
+ * · `{ nested: 子表 }` —— 成员级子表;对象逐成员、列表逐元素(列表必须写 `rows`:`"each"` = 每个元素,或一只**只做选取 / 排序**的函数
10
+ * —— 运行期按身份核它交回的元素都来自原列表,值仍逐个过子表,带不出表外值);`admit` = 整只对象的读法。
11
+ * 本仓**自铸**的键(core 没有的派生事实)以 `{ mint: (src, root) => 值 }` 写在表里它的出口位次上 —— 它不是处置词,类型上不许与 core 键同名。
12
+ * ⚠️ 铸键读到的是**原值**(要从原值算计数 / 时长 / 展示词):它只许回派生事实,不许把原值或其片段回出去 —— 这是表里唯一一处
13
+ * 表本身拦不住、要靠复审看的地方。
14
+ * 值形限制写在类型上(整只值形一起判,不按联合分配):叶值(联合每一臂都是原语 / 原语列表)才能 `forward`,文本才能 `redact`,
15
+ * `nested` 不收各臂键不同的联合(`keyof` 只给交集,某一臂独有的键会悄悄没有处置),core 写成 `unknown` / `any` 的值只能 `strip`;
16
+ * **一格只许一词** —— 类型上把其余词的键写成 `never`(展开也混不进第二个词),运行期再核一次,两词同在 ⇒ 响亮抛。
17
+ * 投影函数是表的解释器 {@link projectByTable};`core-keyset-guard.ts` 读表({@link TableCoreKeys})—— 门与投影只有一个写者。
18
+ *
19
+ * ## 三条读法(所有表同一条)
20
+ * · **缺席即缺席**:源值 `undefined` ⇒ 键缺席(不补 `[]` / `false` / 默认值);
21
+ * · **表序 = 出口序**:表字面量按出口顺序写,铸键按位插 ⇒ 输出的键序就是表的键序;
22
+ * · **在场却读不出 ⇒ 计一次并丢**(`dropProjectedFace`,F 类;缺席从不计数):读法拒、`redact` 位不是文本、嵌套位不是对象、
23
+ * 写了 `rows` 的位不是列表、列表元素不是对象 —— 那一格丢,其余照投,不抛、不 500。表里出现解释器不认识的词(只可能经运行期旁路造出)⇒ 响亮抛。
24
+ *
25
+ * ## 凭据
26
+ * `redact` 管「**可能含**凭据的文本」;「**本身是**凭据的值」(赎回令牌)写 `strip`。core 打了品牌的凭据型(`CheckpointToken`)上,
27
+ * 类型层写不出 `forward`。
28
+ */
29
+ import type { CheckpointToken } from "@sema-agent/core";
30
+ /** `redact` 可点名的既有脱敏入口(闭集;一词 = 一只既有导出的名字,解释器原样调用)。 */
31
+ export type RedactEntry = "redactSecrets" | "redactErrorMessage";
32
+ /** 窄读:认得 ⇒ `true`(原值出门),认不得 ⇒ 键缺席并计一次。只判不改。 */
33
+ export type Admit = (raw: unknown) => boolean;
34
+ /** 列表位怎么带:`"each"` = 每个元素;函数 = 选取 / 排序(只许交回原列表里的元素 —— 运行期按身份核,交回别的就响亮抛)。 */
35
+ type RowsOf<E, R> = "each" | ((list: readonly E[], root: R) => readonly E[]);
36
+ /** 一格只许一词:对象形的处置把其余词的键写成 `never` —— 多余属性检查之外,经展开 / 赋值也写不进第二个词。 */
37
+ type DispositionKey = "forward" | "redact" | "nested" | "rows" | "admit" | "mint";
38
+ type Only<K extends DispositionKey, T> = T & {
39
+ readonly [P in Exclude<DispositionKey, K>]?: never;
40
+ };
41
+ /** 不透明值(core 型写成 `unknown` / `any`):本仓写不出它的成员表,也说不出它是不是文本 ⇒ 只能 `strip`。 */
42
+ type IsOpaque<V> = unknown extends V ? true : false;
43
+ /** 叶值:联合的**每一臂**都是原语,或元素每一臂都是原语的列表(不透明元素不算)。 */
44
+ type LeafMember<M> = M extends readonly (infer E)[] ? (unknown extends E ? false : [Extract<E, object>] extends [never] ? true : false) : M extends object ? false : true;
45
+ type IsLeaf<V> = false extends LeafMember<NonNullable<V>> ? false : true;
46
+ /** 联合的任一臂(或列表元素的任一臂)是 core 的品牌凭据。 */
47
+ type TokenMember<M> = M extends readonly (infer E)[] ? ([Extract<E, CheckpointToken>] extends [never] ? false : true) : [Extract<M, CheckpointToken>] extends [never] ? false : true;
48
+ type HoldsToken<V> = true extends TokenMember<NonNullable<V>> ? true : false;
49
+ /** 判别联合的各臂键并集;`nested` 只收「各臂键相同」的对象型 —— 否则 `keyof` 只给交集,只在某一臂上的键会悄悄没有处置。 */
50
+ type ArmKeys<E> = E extends unknown ? keyof E : never;
51
+ type NestedTarget<E> = [ArmKeys<E>] extends [keyof E] ? true : false;
52
+ /** 值形决定可写哪几个词:叶值才能 `forward`(对象 / 对象列表的成员必须逐个处置),文本才能 `redact`,对象 / 对象列表才能 `nested`
53
+ * (列表必须写 `rows`、对象不许写),品牌凭据写不出 `forward`,不透明值只能 `strip`。判断都**不按联合分配**:整只值形一起判。 */
54
+ type NestedOf<V, R> = [
55
+ NonNullable<V>
56
+ ] extends [readonly (infer E)[]] ? [E] extends [object] ? NestedTarget<E> extends true ? Only<"nested" | "rows" | "admit", {
57
+ readonly nested: CoreTable<E, R>;
58
+ readonly rows: RowsOf<E, R>;
59
+ readonly admit?: Admit;
60
+ }> : never : never : [NonNullable<V>] extends [object] ? NestedTarget<NonNullable<V>> extends true ? Only<"nested" | "admit", {
61
+ readonly nested: CoreTable<NonNullable<V>, R>;
62
+ readonly admit?: Admit;
63
+ }> : never : never;
64
+ type ForwardOf<V> = IsLeaf<V> extends true ? (HoldsToken<V> extends true ? never : "forward" | Only<"forward", {
65
+ readonly forward: Admit;
66
+ }>) : never;
67
+ /** 一个 core 键在一张面上的处置(四词;`R` = 铸键能读到的根)。 */
68
+ export type Disposition<V, R> = IsOpaque<V> extends true ? "strip" : ForwardOf<V> | "strip" | (NonNullable<V> extends string ? Only<"redact", {
69
+ readonly redact: RedactEntry;
70
+ }> : never) | NestedOf<V, R>;
71
+ /** 本仓铸键:core 没有的派生事实,值 = `mint(源, 根)`,`undefined` ⇒ 缺席。 */
72
+ export type Mint<T, R> = Only<"mint", {
73
+ readonly mint: (src: T, root: R) => unknown;
74
+ }>;
75
+ /** `T` 的全量处置(每个键恰一词;可选键也必须写)。 */
76
+ export type CoreTable<T, R> = {
77
+ readonly [K in keyof T]-?: Disposition<T[K], R>;
78
+ };
79
+ /**
80
+ * 一张处置表的类型:`T` 的全量处置 + 名为 `M` 的铸键。`M` 与 `keyof T` 相交 ⇒ 整张表型变成错误标记(两个写者抢一个键)。
81
+ * 用法:`export const X_DISPOSITIONS = { … } as const satisfies DispositionTable<T, R, "铸键A" | "铸键B">`。
82
+ */
83
+ export type DispositionTable<T, R = T, M extends string = never> = [Extract<M, keyof T>] extends [never] ? CoreTable<T, R> & {
84
+ readonly [K in M]: Mint<T, R>;
85
+ } : {
86
+ readonly __mintCollidesWithCoreKey: Extract<M, keyof T>;
87
+ };
88
+ /** 表里处置 core 键的那些键(铸键除外)—— `core-keyset-guard.ts` 读这个。 */
89
+ export type TableCoreKeys<Tbl> = {
90
+ [K in keyof Tbl]-?: Tbl[K] extends {
91
+ readonly mint: unknown;
92
+ } ? never : K;
93
+ }[keyof Tbl];
94
+ /**
95
+ * 按表投影一个值。`face` = 计数 / 报错里的面名(`<面>.<键路径>`);`root` = 铸键与 `rows` 读到的根(面的顶层值)。
96
+ * 纯数据进、纯数据出;不改入参。
97
+ */
98
+ export declare function projectByTable<T extends object, R>(face: string, table: CoreTable<T, R>, value: T, root: R): Record<string, unknown>;
99
+ export {};
100
+ //# sourceMappingURL=projection-table.d.ts.map