@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
@@ -26,6 +26,7 @@
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 SafeText } from "./exit-seat.js";
29
30
  import { type SemaProvenanceInput } from "./sema-provenance.js";
30
31
  import type { LedgerEventType } from "./ledger-events.js";
31
32
  import type { InstructionsSegment } from "../instruction-selection.js";
@@ -81,6 +82,13 @@ export declare function attachModelUsage<T extends TaskResult>(result: T, ctx: {
81
82
  * · **键在场但值坏**(NaN / 字符串 / null)= 数据损坏,写了键的 producer 是在声称自己知道 ⇒ 维持既有
82
83
  * 折叠(按 0 计,不传染,已知量不受损),否则一条陈年坏行就能把整个模型的成本抹成"未知"。
83
84
  * 下游补偿件早已就位:usage-analytics 的 numOf + `estimated` 标记(缺数值键 ⇒ 总量偏低并诚实标注)。 */
85
+ /** **trace 帧数据的出口形**(RH-1 第一期):`Slots` 里列出的自由文本位只收 {@link SafeText}(出口座铸的),其余键照旧开放 ——
86
+ * 裸 `string` 写进这些位是 tsc 红;整只帧数据**只读**(交出去之后按键改写 —— 含动态键 `frame[k] = raw` —— 也是 tsc 红)。
87
+ * 对既有的 `Record<string, unknown>` 读者可赋值(零调用点改动)。类型层管不到的两形如实记:`any` 值、以及把一只 `Record<string, unknown>`
88
+ * 展开进字面量 / `Object.assign` 事后改写(TypeScript 不拿索引签名去对可选位、也不查 `Object.assign` 的目标)—— 品牌推到汇(SSE 写口 / 账本 append)是第三期。 */
89
+ type FrameData<Slots extends object> = Readonly<Slots> & {
90
+ readonly [key: string]: unknown;
91
+ };
84
92
  export declare function aggregateModelUsage(events: RunEvent[]): Record<string, ModelUsageDelta> | undefined;
85
93
  export type TraceBlock = {
86
94
  type: "thinking";
@@ -113,11 +121,7 @@ export type TraceBlock = {
113
121
  parentToolCallId?: string;
114
122
  } | {
115
123
  type: "prompt-assembled";
116
- constitution: string;
117
- totalChars: number;
118
- blocks: unknown;
119
- sections?: unknown;
120
- tools?: unknown;
124
+ readonly [member: string]: unknown;
121
125
  };
122
126
  /**
123
127
  * 🔴 **模型自由文本账本行(`text` / `reasoning`)的唯一载荷铸点**(B-106 / S-268,7.75.1)。
@@ -377,7 +381,11 @@ export declare function taskProgressEventData(ev: {
377
381
  workflowAgentLabel?: string;
378
382
  seq?: number;
379
383
  model?: string;
380
- }): Record<string, unknown>;
384
+ }): FrameData<{
385
+ name?: SafeText;
386
+ currentAction?: SafeText;
387
+ workflowAgentLabel?: SafeText;
388
+ }>;
381
389
  /**
382
390
  * The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
383
391
  * 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
@@ -418,7 +426,10 @@ export declare function taskStartedEventData(ev: {
418
426
  startedAt: number;
419
427
  eventId?: string;
420
428
  parentToolCallId?: string;
421
- }): Record<string, unknown>;
429
+ }): FrameData<{
430
+ name?: SafeText;
431
+ workflowAgentLabel?: SafeText;
432
+ }>;
422
433
  /** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
423
434
  * LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
424
435
  * attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
@@ -496,7 +507,28 @@ export declare function taskNotificationEventData(ev: {
496
507
  * **事件顶层**键,不是 {@link TaskNotificationPayload} 的键,所以只有把整只 core 事件交给本投影的腿
497
508
  * 拿得到它;只拿到载荷的 park-drain 腿结构上没有这一位。 */
498
509
  priority?: SystemInjectionPriority;
499
- }): Record<string, unknown>;
510
+ }): FrameData<{
511
+ summary: SafeText;
512
+ result?: SafeText;
513
+ output_file?: SafeText;
514
+ source?: SafeText;
515
+ diagnostics?: SafeText;
516
+ error?: SafeText;
517
+ lines?: SafeText[];
518
+ recentSteps?: Array<{
519
+ tool: string;
520
+ target: SafeText;
521
+ outcome: SafeText;
522
+ }>;
523
+ editedFiles?: Array<{
524
+ path: SafeText;
525
+ edits: number;
526
+ }>;
527
+ agentMessage?: {
528
+ from: string;
529
+ body: SafeText;
530
+ };
531
+ }>;
500
532
  /** The `compacted` payload — EXPLICIT WHITELIST shared by all three legs (bg runs.ts + resume append + the sync
501
533
  * live SSE frame; the 1.72 task_progress lesson: never `{...ev}`). trigger/tokensBefore (MF-18) verbatim;
502
534
  * `preserved_segment.firstKeptEntryId` verbatim (a core-mint entryId, the shell's compaction-divider anchor);
@@ -523,7 +555,16 @@ export declare function diagnosticsEventData(ev: {
523
555
  isNew: boolean;
524
556
  eventId?: string;
525
557
  parentToolCallId?: string;
526
- }): Record<string, unknown>;
558
+ }): FrameData<{
559
+ files: Array<{
560
+ uri: SafeText;
561
+ diagnostics: Array<FrameData<{
562
+ message: SafeText;
563
+ code?: SafeText | number;
564
+ source?: SafeText;
565
+ }>>;
566
+ }>;
567
+ }>;
527
568
  /** The `steering_injected` payload([ref]/[ref] 裁定透传;core `TaskEvent` 联合臂 `type: "steering_injected"`,
528
569
  * shell 渲染源 = CC 的系统提醒条:core 在 turn 之间给模型注入一条系统提示[todo 提醒/文件变化/日期跨天/
529
570
  * 技能列表变化…]时随手抛的展示投影,一附件一帧)。EXPLICIT WHITELIST(source=封闭枚举 verbatim;
@@ -534,7 +575,9 @@ export declare function steeringInjectedEventData(ev: {
534
575
  preview: string;
535
576
  eventId?: string;
536
577
  parentToolCallId?: string;
537
- }): Record<string, unknown>;
578
+ }): FrameData<{
579
+ preview: SafeText;
580
+ }>;
538
581
  /** `compaction_outcome`(core 2.5.0 [ref]②:压缩非 compacted 结局——manual /compact 的 mooted/failed
539
582
  * 两条真路)。[ref]A-2/C-2:此前它是**唯一**不走共享 builder、只在 live 腿 res.write 内联挑键的
540
583
  * 内容帧 ⇒ 两条 durable 腿零 case、回放即消失、三方普查各自失明。收进共享白名单 builder,三腿同源。
@@ -543,6 +586,23 @@ export declare function compactionOutcomeEventData(ev: {
543
586
  outcome?: unknown;
544
587
  trigger?: unknown;
545
588
  reason?: unknown;
589
+ pass?: unknown;
590
+ eventId?: unknown;
591
+ parentToolCallId?: unknown;
592
+ }): FrameData<{
593
+ reason?: SafeText;
594
+ }>;
595
+ /**
596
+ * `compaction_started`(S-1732,core 7.53.0 #2008)—— 一次压缩 pass 在提交点(触发闸过了、切点在、`preCompact` 没拦)宣告开始,先于摘要调用:
597
+ * 一次在供应方重试表里等很久的摘要(core 实测 503 × 11、173 s)从此在流上不是静默的。**原样投影**:`{ trigger, pass, startedAt }` + 身份两键,
598
+ * 不自铸相位、不铸 run / session id(那是流的,不是帧的键)。三键都是引擎铸的闭形值:`trigger` 闭集词(`auto` / `manual` / `forced`,与结束帧同一张词表)、
599
+ * `pass` 不透明 id(结束这次 pass 的那一帧 —— `compacted` 或 `compaction_outcome` —— 带同一个 `pass`)、`startedAt` 引擎时钟 epoch 毫秒 ⇒ 不脱敏、逐字;
600
+ * 形不合即缺席(与 {@link compactionOutcomeEventData} 同款守卫,不编值)。三条消费腿(live 帧、两条 durable 腿)共用这一只。
601
+ */
602
+ export declare function compactionStartedEventData(ev: {
603
+ trigger?: unknown;
604
+ pass?: unknown;
605
+ startedAt?: unknown;
546
606
  eventId?: unknown;
547
607
  parentToolCallId?: unknown;
548
608
  }): Record<string, unknown>;
@@ -556,7 +616,9 @@ export declare function workspaceChangedEventData(ev: {
556
616
  cwd: string;
557
617
  eventId?: string;
558
618
  parentToolCallId?: string;
559
- }): Record<string, unknown>;
619
+ }): FrameData<{
620
+ cwd: SafeText;
621
+ }>;
560
622
  /**
561
623
  * `wiring_manifest`(core 5.14.0 [ref] 新 `TaskEvent` 臂)—— 每条腿(root/child/resume)在 prepare
562
624
  * 时自证「我到底接了什么线」的清单帧。
@@ -791,8 +853,8 @@ export declare function wiringManifestEventData(ev: {
791
853
  * 代价是 operator 看不到历史腿的 governance 段 —— 治理四布尔是部署形事实(不随 leg 漂),静态自检面
792
854
  * (`GET /v1/diagnostics/wiring`)随时给出当前真值。
793
855
  *
794
- * 准入判据是 `explicitOperatorOk`(**不是** `isOperator`):空 `OPERATOR_PRINCIPALS` 必须是「没有人是
795
- * operator」,不能是「所有人都是」—— 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。
856
+ * 准入判据是 `explicitOperatorOk`(「谁是 operator」的唯一读法):空 `OPERATOR_PRINCIPALS` 是「没有人是 operator」,不是「所有人都是」——
857
+ * 后者会让一个没配 operator 名单的部署把治理面发给每一个订阅者。单用户形显式声明 `OPERATOR_SINGLE_USER=true` 时它的每个调用方都是。
796
858
  *
797
859
  * `configFingerprint` 只在本构造器里透传:它是 `sha256(canonicalize(manifest 去 leg/去两个 provenance))`
798
860
  * 前 16 hex,**无盐**且输入含整个 governance 段,而 governance 只有 4 个布尔 ⇒ 16 种组合。租户手里已有其余
@@ -806,7 +868,7 @@ export declare function wiringManifestEventData(ev: {
806
868
  * `core-keyset-guard.ts` ⑥b `WiringSectionExcluded`)。**present-iff 武装**:
807
869
  * · 整段缺席 ⇒ **未武装**,不铸键、不计数(正面事实,不是「未知」,更不是 `{onRecommendation:false}`);
808
870
  * · 在场且 `onRecommendation === true` ⇒ 逐字铸出(core 的在场形只有这一个,构造期门已拒掉「武装但跑不起来」);
809
- * · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `hooks` 同一条
871
+ * · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `mods` 同一条
810
872
  * 族规:「在场但读不出 ⇒ 计一次并丢弃」;**不**自造第三态,词表/形的属主在 core)。
811
873
  * 🔴 代价如实登记,与 `writeProtection` 那一格逐字同源:wire 上「读不出」与「真未武装」是**同一个形**,
812
874
  * 分得开它们的只有 `server.trace.projection-input-malformed` 这只计数 —— 而这一格比那一格更该说清楚,
@@ -874,7 +936,16 @@ export declare function humanInputEventData(ev: {
874
936
  attachments?: unknown;
875
937
  eventId?: unknown;
876
938
  parentToolCallId?: unknown;
877
- }): Record<string, unknown>;
939
+ }): FrameData<{
940
+ issuer?: SafeText;
941
+ actor?: FrameData<{
942
+ id?: SafeText;
943
+ issuer?: SafeText;
944
+ }>;
945
+ attachments?: Array<FrameData<{
946
+ label?: SafeText;
947
+ }>>;
948
+ }>;
878
949
  /** S4 (SILENT-FALLBACK P0-a): the durable `brain_status` observation row, shared by the bg + resume append
879
950
  * sites. core marks the live `status` frame EPHEMERAL (never replayed by core on resume) — this row is the
880
951
  * SERVICE's own observation record (why a turn stalled: rate_limited/retrying/reconnecting/circuit_open, and
@@ -896,7 +967,9 @@ export declare function brainStatusEventData(ev: {
896
967
  providerConditionSource?: string;
897
968
  eventId?: string;
898
969
  parentToolCallId?: string;
899
- }): Record<string, unknown>;
970
+ }): FrameData<{
971
+ detail?: SafeText;
972
+ }>;
900
973
  export declare function compactedEventData(ev: {
901
974
  eventId?: string;
902
975
  parentToolCallId?: string;
@@ -932,7 +1005,15 @@ export declare function compactedEventData(ev: {
932
1005
  persistMs?: number;
933
1006
  ptlRetries?: number;
934
1007
  };
935
- }): Record<string, unknown>;
1008
+ /** S-1732(core 7.53.0 #2008):这次落地的压缩 pass 的 id —— 与它的 `compaction_started` 帧同一个值(引擎在每次落地上都设;型上可选)。逐字。 */
1009
+ pass?: string;
1010
+ }): FrameData<{
1011
+ attachedFiles?: Array<{
1012
+ path: SafeText;
1013
+ chars: number;
1014
+ truncated: boolean;
1015
+ }>;
1016
+ }>;
936
1017
  export interface TraceTurn {
937
1018
  /** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
938
1019
  seq: number;
@@ -3,6 +3,8 @@ 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";
7
+ import { sanitizeWireText } from "./engine-notice-wire.js";
6
8
  import { projectToolOutput, projectToolStructured } from "./tool-output-media.js";
7
9
  import { injectionTierOrAbsent } from "./injection-tier.js";
8
10
  import { semaProvenanceOrAbsent } from "./sema-provenance.js";
@@ -269,14 +271,14 @@ export function taskProgressEventData(ev) {
269
271
  ...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
270
272
  ...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
271
273
  ...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
272
- ...(ev.name ? { name: redactSecrets(ev.name) } : {}),
274
+ ...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
273
275
  ...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
274
276
  ...(typeof ev.model === "string" && ev.model.length > 0 ? { model: ev.model } : {}),
275
277
  ...(ev.status !== undefined ? { status: ev.status } : {}),
276
278
  ...(ev.usage ? { usage: ev.usage } : {}),
277
- ...(ev.currentAction ? { currentAction: redactSecrets(ev.currentAction) } : {}),
279
+ ...(ev.currentAction ? { currentAction: seatText("trace-frame-text", ev.currentAction) } : {}),
278
280
  ...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
279
- ...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
281
+ ...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
280
282
  ...identityFields(ev),
281
283
  };
282
284
  }
@@ -287,11 +289,11 @@ export function taskStartedEventData(ev) {
287
289
  ...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
288
290
  ...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
289
291
  ...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
290
- ...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
292
+ ...(ev.workflowAgentLabel ? { workflowAgentLabel: seatText("trace-frame-text", ev.workflowAgentLabel) } : {}),
291
293
  ...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
292
294
  ...(ev.parentSessionId ? { parentSessionId: ev.parentSessionId } : {}),
293
295
  ...(ev.rootSessionId ? { rootSessionId: ev.rootSessionId } : {}),
294
- ...(ev.name ? { name: redactSecrets(ev.name) } : {}),
296
+ ...(ev.name ? { name: seatText("trace-frame-text", ev.name) } : {}),
295
297
  ...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
296
298
  ...(ev.agentType ? { agentType: ev.agentType } : {}),
297
299
  model: ev.model,
@@ -309,10 +311,10 @@ export function taskNotificationEventData(ev) {
309
311
  ...(n.toolUseId !== undefined ? { toolUseId: n.toolUseId } : {}),
310
312
  status: n.status,
311
313
  ...(n.seq !== undefined ? { seq: n.seq } : {}),
312
- ...(n.lines !== undefined ? { lines: n.lines.map((l) => redactSecrets(l)) } : {}),
314
+ ...(n.lines !== undefined ? { lines: n.lines.map((l) => seatText("trace-frame-text", l)) } : {}),
313
315
  ...(n.stoppedBy !== undefined ? { stoppedBy: n.stoppedBy } : {}),
314
316
  ...(n.completionId !== undefined ? { completionId: n.completionId } : {}),
315
- ...(n.error !== undefined ? { error: redactSecrets(n.error) } : {}),
317
+ ...(n.error !== undefined ? { error: seatText("trace-frame-text", n.error) } : {}),
316
318
  ...(n.errorCode !== undefined ? { errorCode: n.errorCode } : {}),
317
319
  ...(n.apiFailure !== undefined
318
320
  ? {
@@ -322,20 +324,20 @@ export function taskNotificationEventData(ev) {
322
324
  },
323
325
  }
324
326
  : {}),
325
- ...(n.source !== undefined ? { source: redactSecrets(n.source) } : {}),
327
+ ...(n.source !== undefined ? { source: seatText("trace-frame-text", n.source) } : {}),
326
328
  ...(n.exitCode !== undefined ? { exitCode: n.exitCode } : {}),
327
329
  ...(n.partial !== undefined ? { partial: n.partial } : {}),
328
- ...(n.diagnostics !== undefined ? { diagnostics: redactSecrets(n.diagnostics) } : {}),
330
+ ...(n.diagnostics !== undefined ? { diagnostics: seatText("trace-frame-text", n.diagnostics) } : {}),
329
331
  ...(n.recentSteps !== undefined
330
- ? { 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) })) }
331
333
  : {}),
332
- ...(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 })) } : {}),
333
335
  ...(n.resumable !== undefined ? { resumable: n.resumable } : {}),
334
- summary: redactSecrets(n.summary),
335
- ...(n.result !== undefined ? { result: redactSecrets(n.result) } : {}),
336
- ...(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) } : {}),
337
339
  ...(n.usage !== undefined ? { usage: n.usage } : {}),
338
- ...(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) } } : {}),
339
341
  ...(() => {
340
342
  if (n._sema_provenance === undefined)
341
343
  return {};
@@ -354,13 +356,13 @@ export function taskNotificationEventData(ev) {
354
356
  export function diagnosticsEventData(ev) {
355
357
  return {
356
358
  files: (Array.isArray(ev.files) ? ev.files : []).map((f) => ({
357
- uri: redactSecrets(String(f.uri)),
359
+ uri: seatText("trace-frame-text", String(f.uri)),
358
360
  diagnostics: (Array.isArray(f.diagnostics) ? f.diagnostics : []).map((d) => ({
359
- message: redactSecrets(String(d.message)),
361
+ message: seatText("trace-frame-text", String(d.message)),
360
362
  ...(d.severity !== undefined ? { severity: d.severity } : {}),
361
363
  ...(d.range !== undefined ? { range: d.range } : {}),
362
- ...(d.code !== undefined ? { code: typeof d.code === "number" ? d.code : redactSecrets(String(d.code)) } : {}),
363
- ...(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)) } : {}),
364
366
  })),
365
367
  })),
366
368
  isNew: ev.isNew === true,
@@ -370,7 +372,7 @@ export function diagnosticsEventData(ev) {
370
372
  export function steeringInjectedEventData(ev) {
371
373
  return {
372
374
  source: String(ev.source),
373
- preview: redactSecrets(String(ev.preview)),
375
+ preview: seatText("trace-frame-text", String(ev.preview)),
374
376
  ...identityFields(ev),
375
377
  };
376
378
  }
@@ -379,13 +381,23 @@ export function compactionOutcomeEventData(ev) {
379
381
  return {
380
382
  ...(s(ev.outcome) !== undefined ? { outcome: s(ev.outcome) } : {}),
381
383
  ...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
382
- ...(ev.reason !== undefined ? { reason: redactSecrets(String(ev.reason)) } : {}),
384
+ ...(ev.reason !== undefined ? { reason: seatText("trace-frame-text", String(ev.reason)) } : {}),
385
+ ...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
386
+ ...identityFields(ev),
387
+ };
388
+ }
389
+ export function compactionStartedEventData(ev) {
390
+ const s = (v) => (typeof v === "string" ? v : undefined);
391
+ return {
392
+ ...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
393
+ ...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
394
+ ...(typeof ev.startedAt === "number" && Number.isFinite(ev.startedAt) ? { startedAt: ev.startedAt } : {}),
383
395
  ...identityFields(ev),
384
396
  };
385
397
  }
386
398
  export function workspaceChangedEventData(ev) {
387
399
  return {
388
- cwd: redactSecrets(String(ev.cwd)).slice(0, 300),
400
+ cwd: seatText("trace-frame-line", String(ev.cwd)),
389
401
  ...identityFields(ev),
390
402
  };
391
403
  }
@@ -513,26 +525,55 @@ export function wiringManifestEventData(ev, instructions) {
513
525
  })();
514
526
  const toolsIn = m.tools;
515
527
  const tools = toolsIn === undefined ? undefined : Value.Check(ToolRoster, toolsIn) ? toolsIn : (recordFailOpen("server.trace.tool-roster-malformed", "wiring_manifest.tools did not fit core ToolRoster"), undefined);
516
- const hooksIn = m.hooks;
517
- const hooks = (() => {
518
- if (hooksIn === undefined)
528
+ const strList = (v) => (Array.isArray(v) && v.every((x) => typeof x === "string") ? [...v] : undefined);
529
+ const registrantText = (v) => {
530
+ const t = str(v);
531
+ return t === undefined ? undefined : sanitizeWireText(t);
532
+ };
533
+ const modsIn = m.mods;
534
+ const mods = (() => {
535
+ if (modsIn === undefined)
519
536
  return undefined;
520
- if (!Array.isArray(hooksIn))
521
- return dropProjectedFace("wiring_manifest.hooks is not an array");
537
+ if (!Array.isArray(modsIn))
538
+ return dropProjectedFace("wiring_manifest.mods is not an array");
522
539
  const rows = [];
523
- for (const raw of hooksIn) {
540
+ for (const raw of modsIn) {
524
541
  const e = sec(raw);
525
- if (e === undefined) {
526
- dropProjectedFace("wiring_manifest.hooks[] row is not an object");
542
+ const name = registrantText(e?.name);
543
+ const seat = str(e?.seat);
544
+ const tier = str(e?.tier);
545
+ if (e === undefined || name === undefined || seat === undefined || tier === undefined) {
546
+ dropProjectedFace("wiring_manifest.mods[] row is missing name/seat/tier");
547
+ continue;
548
+ }
549
+ const refusedBy = registrantText(e.refusedBy);
550
+ const reason = registrantText(e.reason);
551
+ if (refusedBy !== undefined && reason !== undefined) {
552
+ rows.push({ name, seat, tier, refusedBy, reason });
527
553
  continue;
528
554
  }
529
- const family = str(e.family);
530
- const owner = str(e.owner);
531
- if (family === undefined || owner === undefined) {
532
- dropProjectedFace("wiring_manifest.hooks[] row is missing family/owner");
555
+ const events = strList(e.events);
556
+ if (events === undefined) {
557
+ dropProjectedFace("wiring_manifest.mods[] row is neither a mounted nor a refused record");
533
558
  continue;
534
559
  }
535
- rows.push({ family, owner, ...(e.observational === true ? { observational: true } : {}) });
560
+ const observe = e.observe === undefined ? undefined : (strList(e.observe) ?? dropProjectedFace("wiring_manifest.mods[].observe is not a list of strings"));
561
+ const skipped = e.skipped === undefined
562
+ ? undefined
563
+ : Array.isArray(e.skipped)
564
+ ? e.skipped.flatMap((x) => {
565
+ const k = sec(x);
566
+ const registration = registrantText(k?.registration);
567
+ const cause = registrantText(k?.cause);
568
+ const why = registrantText(k?.reason);
569
+ if (registration === undefined || cause === undefined || why === undefined) {
570
+ dropProjectedFace("wiring_manifest.mods[].skipped[] element is missing registration/cause/reason");
571
+ return [];
572
+ }
573
+ return [{ registration, cause, reason: why }];
574
+ })
575
+ : dropProjectedFace("wiring_manifest.mods[].skipped is not an array");
576
+ rows.push({ name, seat, tier, events, ...(observe !== undefined ? { observe } : {}), ...(skipped !== undefined && skipped.length > 0 ? { skipped } : {}) });
536
577
  }
537
578
  return rows.length > 0 ? rows : undefined;
538
579
  })();
@@ -589,11 +630,23 @@ export function wiringManifestEventData(ev, instructions) {
589
630
  return dropProjectedFace("wiring_manifest.fileHistory is not a non-empty string");
590
631
  return word;
591
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
+ })();
592
644
  return {
593
645
  ...(num(m.schemaVersion) !== undefined ? { schemaVersion: m.schemaVersion } : {}),
594
646
  ...(str(legIn.kind) !== undefined ? { leg: { kind: legIn.kind } } : {}),
595
647
  ...(teamRole !== undefined ? { teamRole } : {}),
596
648
  ...(fileHistory !== undefined ? { fileHistory } : {}),
649
+ ...(permissionMode !== undefined ? { permissionMode } : {}),
597
650
  ...(ask !== undefined ? { ask } : {}),
598
651
  ...(question !== undefined ? { question } : {}),
599
652
  ...(str(interactionIn.posture) !== undefined ? { interaction: { posture: interactionIn.posture } } : {}),
@@ -606,7 +659,7 @@ export function wiringManifestEventData(ev, instructions) {
606
659
  ...(autoMode !== undefined ? { autoMode } : {}),
607
660
  ...(tools !== undefined ? { tools } : {}),
608
661
  ...(mcp !== undefined ? { mcp } : {}),
609
- ...(hooks !== undefined ? { hooks } : {}),
662
+ ...(mods !== undefined ? { mods } : {}),
610
663
  ...(lsp !== undefined ? { lsp } : {}),
611
664
  ...(hands !== undefined ? { hands } : {}),
612
665
  ...(writeProtection !== undefined ? { writeProtection } : {}),
@@ -672,13 +725,13 @@ export function humanInputEventData(ev) {
672
725
  ...(typeof m.ordinal === "number" && Number.isFinite(m.ordinal) ? { ordinal: m.ordinal } : {}),
673
726
  ...(str(m.kind) !== undefined ? { kind: m.kind } : {}),
674
727
  ...(str(m.outcome) !== undefined ? { outcome: m.outcome } : {}),
675
- ...(str(m.label) !== undefined ? { label: redactSecrets(String(m.label)) } : {}),
728
+ ...(str(m.label) !== undefined ? { label: seatText("trace-frame-text", String(m.label)) } : {}),
676
729
  }))
677
730
  : undefined;
678
731
  const actor = {
679
- ...(str(a.id) !== undefined ? { id: redactSecrets(String(a.id)) } : {}),
732
+ ...(str(a.id) !== undefined ? { id: seatText("trace-frame-text", String(a.id)) } : {}),
680
733
  ...(typeof a.hostAsserted === "boolean" ? { hostAsserted: a.hostAsserted } : {}),
681
- ...(str(a.issuer) !== undefined ? { issuer: redactSecrets(String(a.issuer)) } : {}),
734
+ ...(str(a.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(a.issuer)) } : {}),
682
735
  };
683
736
  return {
684
737
  ...(str(ev.inputId) !== undefined ? { inputId: ev.inputId } : {}),
@@ -686,7 +739,7 @@ export function humanInputEventData(ev) {
686
739
  ...(str(ev.carrier) !== undefined ? { carrier: ev.carrier } : {}),
687
740
  ...(str(ev.source) !== undefined ? { source: ev.source } : {}),
688
741
  ...(str(ev.delivery) !== undefined ? { delivery: ev.delivery } : {}),
689
- ...(str(ev.issuer) !== undefined ? { issuer: redactSecrets(String(ev.issuer)) } : {}),
742
+ ...(str(ev.issuer) !== undefined ? { issuer: seatText("trace-frame-text", String(ev.issuer)) } : {}),
690
743
  ...(Object.keys(actor).length > 0 ? { actor } : {}),
691
744
  ...(str(ev.entryId) !== undefined ? { entryId: ev.entryId } : {}),
692
745
  ...(attachments !== undefined ? { attachments } : {}),
@@ -697,7 +750,7 @@ export function brainStatusEventData(ev) {
697
750
  const num = (v) => typeof v === "number" && Number.isFinite(v);
698
751
  return {
699
752
  phase: String(ev.phase),
700
- ...(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) } : {}),
701
754
  ...(num(ev.retryInSec) ? { retryInSec: ev.retryInSec } : {}),
702
755
  ...(num(ev.attempt) ? { attempt: ev.attempt } : {}),
703
756
  ...(num(ev.maxRetries) ? { maxRetries: ev.maxRetries } : {}),
@@ -737,7 +790,7 @@ export function compactedEventData(ev) {
737
790
  const files = ev.attachedFiles
738
791
  .filter((f) => typeof f === "object" && f !== null && typeof f.path === "string"
739
792
  && num(f.chars) !== undefined && typeof f.truncated === "boolean")
740
- .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 }));
741
794
  return files.length > 0 ? { attachedFiles: files } : {};
742
795
  })(),
743
796
  ...(ev.modelFallback === true ? { modelFallback: true } : {}),
@@ -758,6 +811,7 @@ export function compactedEventData(ev) {
758
811
  })(),
759
812
  ...(num(ev.durationMs) !== undefined ? { durationMs: num(ev.durationMs) } : {}),
760
813
  ...(phaseDurations !== undefined ? { phaseDurations } : {}),
814
+ ...(typeof ev.pass === "string" ? { pass: ev.pass } : {}),
761
815
  };
762
816
  }
763
817
  export function contextUsageEventData(ev) {
@@ -880,14 +934,7 @@ export function projectEvents(events, opts = {}) {
880
934
  }
881
935
  case "prompt_assembled":
882
936
  firstTs ??= ev.ts;
883
- blocks.push({
884
- type: "prompt-assembled",
885
- constitution: String(d.constitution ?? ""),
886
- totalChars: Number(d.totalChars ?? 0),
887
- blocks: d.blocks,
888
- ...(d.sections !== undefined ? { sections: d.sections } : {}),
889
- ...(d.tools !== undefined ? { tools: d.tools } : {}),
890
- });
937
+ blocks.push({ ...d, type: "prompt-assembled" });
891
938
  break;
892
939
  case "turn_end":
893
940
  flushTurn(ev.seq, ev.ts, toContractTokens(d.usage, d.usageMissing));
@@ -966,6 +1013,7 @@ function mapTraceEventInner(type, seq, data) {
966
1013
  return { event: "error", data: { type: "error", errorCode: "WORKER_DOWN", message: redactErrorMessage(String(data.errorMessage ?? "run failed")) ?? "run failed" } };
967
1014
  case "context_usage":
968
1015
  case "compaction_outcome":
1016
+ case "compaction_started":
969
1017
  case "wiring_manifest":
970
1018
  case "human_input":
971
1019
  case "tool_roster_delta":
@@ -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