@sema-agent/server 7.132.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 (402) hide show
  1. package/MIGRATION.md +266 -0
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +7 -6
  4. package/USAGE.md +174 -55
  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 +79 -19
  24. package/dist/approval-card.js +44 -13
  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 +27 -10
  29. package/dist/audit.js +12 -16
  30. package/dist/bake-runner/main.js +3 -2
  31. package/dist/boot/deferred-sandbox-path-env.js +1 -1
  32. package/dist/boot/execution-env.js +9 -7
  33. package/dist/boot/execution-lane.js +11 -0
  34. package/dist/boot/leader.js +2 -0
  35. package/dist/boot/memory-boundary.js +2 -2
  36. package/dist/boot/memory-consolidation.d.ts +5 -4
  37. package/dist/boot/memory-consolidation.js +7 -6
  38. package/dist/boot/org-delivery.d.ts +28 -0
  39. package/dist/boot/org-delivery.js +20 -0
  40. package/dist/boot/reapers.d.ts +3 -0
  41. package/dist/boot/reapers.js +21 -1
  42. package/dist/boot/resolve-spec.d.ts +3 -0
  43. package/dist/boot/resolve-spec.js +60 -81
  44. package/dist/boot/runner-deps.js +1 -0
  45. package/dist/boot/session-faces.d.ts +1 -0
  46. package/dist/boot/session-faces.js +4 -2
  47. package/dist/boot/stage-02-web-admin-pull.js +4 -1
  48. package/dist/boot/stage-06-runners.d.ts +2 -0
  49. package/dist/boot/stage-06-runners.js +6 -3
  50. package/dist/boot/stage-07-capability-layer.d.ts +2 -0
  51. package/dist/boot/stage-07-capability-layer.js +24 -3
  52. package/dist/boot/stage-08-reapers.d.ts +2 -0
  53. package/dist/boot/stage-08-reapers.js +2 -2
  54. package/dist/boot/stage-09-leader.d.ts +3 -0
  55. package/dist/boot/stage-10-http-server.d.ts +3 -0
  56. package/dist/boot/stage-10-http-server.js +5 -6
  57. package/dist/boot/stores.js +2 -2
  58. package/dist/boot/web-admin.d.ts +4 -0
  59. package/dist/boot/web-admin.js +151 -63
  60. package/dist/boot/workflow-orchestration.d.ts +2 -0
  61. package/dist/boot/workflow-orchestration.js +2 -1
  62. package/dist/brain.js +8 -3
  63. package/dist/breaker-key.d.ts +6 -0
  64. package/dist/breaker-key.js +29 -0
  65. package/dist/caller-text-echo.d.ts +9 -6
  66. package/dist/caller-text-echo.js +8 -11
  67. package/dist/capabilities/center-plugins.d.ts +7 -0
  68. package/dist/capabilities/center-plugins.js +1 -1
  69. package/dist/capabilities/composite-members.d.ts +1 -1
  70. package/dist/capabilities/composite-members.js +1 -1
  71. package/dist/capabilities/execution-lane.js +2 -2
  72. package/dist/capabilities/hands-lane.d.ts +21 -0
  73. package/dist/capabilities/hands-lane.js +10 -0
  74. package/dist/capabilities/mcp-probe.d.ts +36 -4
  75. package/dist/capabilities/mcp-probe.js +27 -4
  76. package/dist/capabilities/scenarios.d.ts +63 -7
  77. package/dist/capabilities/scenarios.js +39 -7
  78. package/dist/capability-facts.d.ts +34 -4
  79. package/dist/capability-facts.js +28 -2
  80. package/dist/center-config-tier.d.ts +69 -0
  81. package/dist/center-config-tier.js +42 -0
  82. package/dist/checkpoint-identity.d.ts +16 -0
  83. package/dist/checkpoint-identity.js +19 -0
  84. package/dist/config-catalog.d.ts +17 -10
  85. package/dist/config-catalog.js +43 -28
  86. package/dist/config-d-migration.d.ts +3 -1
  87. package/dist/config-d-migration.js +2 -2
  88. package/dist/config-dir-trust.d.ts +114 -0
  89. package/dist/config-dir-trust.js +388 -0
  90. package/dist/config-invariants.d.ts +18 -5
  91. package/dist/config-invariants.js +35 -3
  92. package/dist/config-provider.d.ts +6 -1
  93. package/dist/config-provider.js +6 -2
  94. package/dist/config-types.d.ts +71 -14
  95. package/dist/config-types.js +8 -0
  96. package/dist/config.d.ts +13 -0
  97. package/dist/config.js +121 -59
  98. package/dist/delegated-session-owner.d.ts +185 -0
  99. package/dist/delegated-session-owner.js +119 -0
  100. package/dist/device-protocol.d.ts +5 -3
  101. package/dist/device-protocol.js +1 -1
  102. package/dist/device-ws-hub.js +21 -2
  103. package/dist/device-ws-protocol.d.ts +70 -6
  104. package/dist/device-ws-protocol.js +50 -23
  105. package/dist/elicitation.js +3 -2
  106. package/dist/entry-problems.d.ts +34 -0
  107. package/dist/entry-problems.js +14 -0
  108. package/dist/execution-lane-caps.d.ts +49 -10
  109. package/dist/execution-lane-caps.js +43 -4
  110. package/dist/field-conflict.d.ts +43 -0
  111. package/dist/field-conflict.js +20 -0
  112. package/dist/fleet/fleet-bus.d.ts +80 -6
  113. package/dist/fleet/fleet-bus.js +41 -9
  114. package/dist/hooks/classic-stations.d.ts +10 -5
  115. package/dist/hooks/classic-stations.js +4 -4
  116. package/dist/hooks/command-spawn.d.ts +57 -0
  117. package/dist/hooks/command-spawn.js +139 -0
  118. package/dist/hooks/hook-llm.js +2 -2
  119. package/dist/hooks/hook-runner.d.ts +127 -25
  120. package/dist/hooks/hook-runner.js +668 -287
  121. package/dist/hooks/hook-source.d.ts +44 -0
  122. package/dist/hooks/hook-source.js +40 -0
  123. package/dist/http/active-run-conflict.d.ts +5 -13
  124. package/dist/http/active-run-conflict.js +17 -27
  125. package/dist/http/admission.js +103 -60
  126. package/dist/http/approval-sweeps.js +55 -18
  127. package/dist/http/caller-trust.d.ts +77 -0
  128. package/dist/http/caller-trust.js +143 -0
  129. package/dist/http/checkpoint-ctx.d.ts +16 -16
  130. package/dist/http/checkpoint-ctx.js +13 -10
  131. package/dist/http/claimed-run.d.ts +4 -3
  132. package/dist/http/device-placement.d.ts +2 -4
  133. package/dist/http/device-placement.js +2 -1
  134. package/dist/http/dispatch.js +10 -4
  135. package/dist/http/durable-run-leg.d.ts +4 -32
  136. package/dist/http/durable-run-leg.js +34 -10
  137. package/dist/http/owner-access.d.ts +56 -0
  138. package/dist/http/owner-access.js +42 -0
  139. package/dist/http/principal-gate.d.ts +48 -23
  140. package/dist/http/principal-gate.js +39 -12
  141. package/dist/http/readiness.d.ts +11 -5
  142. package/dist/http/readiness.js +10 -3
  143. package/dist/http/request-guards.d.ts +16 -23
  144. package/dist/http/request-guards.js +30 -15
  145. package/dist/http/resume-ctx-read.d.ts +2 -5
  146. package/dist/http/resume-ctx-read.js +7 -4
  147. package/dist/http/resume-legs.d.ts +3 -4
  148. package/dist/http/resume-legs.js +126 -69
  149. package/dist/http/retired-service-deps.d.ts +43 -0
  150. package/dist/http/retired-service-deps.js +18 -0
  151. package/dist/http/route-ctx.d.ts +44 -28
  152. package/dist/http/route-ctx.js +4 -0
  153. package/dist/http/route-table.js +2 -0
  154. package/dist/http/routes/a2a-serve.js +3 -4
  155. package/dist/http/routes/admin-config-refresh.js +1 -1
  156. package/dist/http/routes/admin-drain.js +1 -1
  157. package/dist/http/routes/admin-memory-optout.js +5 -1
  158. package/dist/http/routes/adoption.js +2 -9
  159. package/dist/http/routes/approvals-assistant.js +49 -48
  160. package/dist/http/routes/background.js +3 -2
  161. package/dist/http/routes/capabilities.js +20 -4
  162. package/dist/http/routes/config-catalog.d.ts +3 -3
  163. package/dist/http/routes/config-catalog.js +1 -1
  164. package/dist/http/routes/devices.js +3 -17
  165. package/dist/http/routes/diagnostics.js +5 -1
  166. package/dist/http/routes/images.js +6 -7
  167. package/dist/http/routes/leader.js +1 -8
  168. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  169. package/dist/http/routes/mcp-reconnect.js +3 -2
  170. package/dist/http/routes/memory-bundle.js +1 -1
  171. package/dist/http/routes/memory-compliance.js +1 -1
  172. package/dist/http/routes/memory-consolidation.js +1 -1
  173. package/dist/http/routes/memory-origin.js +1 -1
  174. package/dist/http/routes/memory-policy.d.ts +1 -1
  175. package/dist/http/routes/memory-policy.js +3 -2
  176. package/dist/http/routes/notify-wake.js +8 -21
  177. package/dist/http/routes/observability.js +2 -2
  178. package/dist/http/routes/principal-inbox.d.ts +39 -0
  179. package/dist/http/routes/principal-inbox.js +76 -0
  180. package/dist/http/routes/retention-ops.js +2 -9
  181. package/dist/http/routes/rules.js +5 -18
  182. package/dist/http/routes/runs.d.ts +5 -0
  183. package/dist/http/routes/runs.js +33 -106
  184. package/dist/http/routes/session-sync.js +15 -28
  185. package/dist/http/routes/sessions.js +30 -40
  186. package/dist/http/routes/side-query.js +6 -4
  187. package/dist/http/routes/tasks.js +50 -14
  188. package/dist/http/routes/workflows.d.ts +351 -0
  189. package/dist/http/routes/workflows.js +153 -119
  190. package/dist/http/send.d.ts +24 -3
  191. package/dist/http/send.js +14 -2
  192. package/dist/http/server.d.ts +17 -18
  193. package/dist/http/server.js +15 -13
  194. package/dist/http/stored-body-replay.js +17 -4
  195. package/dist/http/submit-ctx.js +4 -3
  196. package/dist/http/submit-replay.d.ts +4 -3
  197. package/dist/http/submit-replay.js +5 -4
  198. package/dist/http/wire-types.d.ts +10 -7
  199. package/dist/index.d.ts +1 -1
  200. package/dist/index.js +0 -1
  201. package/dist/lane-home-probe.d.ts +78 -9
  202. package/dist/lane-home-probe.js +78 -12
  203. package/dist/leader/endpoint.d.ts +4 -1
  204. package/dist/leader/endpoint.js +11 -10
  205. package/dist/limit-refusal.d.ts +17 -5
  206. package/dist/limit-refusal.js +4 -1
  207. package/dist/mcp-assertion-header.d.ts +31 -10
  208. package/dist/mcp-assertion-header.js +10 -3
  209. package/dist/mcp-tool-faces.js +1 -3
  210. package/dist/memory-project-layer.d.ts +37 -0
  211. package/dist/memory-project-layer.js +46 -0
  212. package/dist/memory-scope.d.ts +23 -16
  213. package/dist/memory-scope.js +24 -8
  214. package/dist/memory-sync-client.d.ts +27 -13
  215. package/dist/memory-sync-client.js +107 -18
  216. package/dist/model-entry-refusal.d.ts +9 -1
  217. package/dist/model-entry-refusal.js +6 -1
  218. package/dist/model-plane-face.d.ts +51 -0
  219. package/dist/model-plane-face.js +24 -0
  220. package/dist/model-provider.d.ts +5 -0
  221. package/dist/model-provider.js +4 -2
  222. package/dist/model-route-endpoint.d.ts +8 -11
  223. package/dist/model-route-endpoint.js +4 -7
  224. package/dist/model-route-env.d.ts +22 -0
  225. package/dist/model-route-env.js +2 -0
  226. package/dist/model-route-gap.d.ts +60 -30
  227. package/dist/model-route-gap.js +21 -15
  228. package/dist/observability/corrupt-read-seat.d.ts +7 -0
  229. package/dist/observability/corrupt-read-seat.js +9 -0
  230. package/dist/observability/err-text.d.ts +6 -0
  231. package/dist/observability/err-text.js +18 -4
  232. package/dist/observability/fail-open.d.ts +35 -9
  233. package/dist/observability/fail-open.js +35 -9
  234. package/dist/observability/metrics.js +1 -0
  235. package/dist/observability/prompt-manifest.d.ts +3 -17
  236. package/dist/observability/prompt-manifest.js +45 -42
  237. package/dist/observability/tool-trace.js +9 -9
  238. package/dist/operator-ask.d.ts +10 -0
  239. package/dist/operator-ask.js +3 -0
  240. package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
  241. package/dist/orchestration/workflow-agent-session-index.js +9 -13
  242. package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
  243. package/dist/orchestration/workflow-completion-inbox.js +13 -0
  244. package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
  245. package/dist/orchestration/workflow-notify-journal.js +27 -34
  246. package/dist/orchestration/workflow-park-decision.d.ts +89 -0
  247. package/dist/orchestration/workflow-park-decision.js +118 -0
  248. package/dist/org-delivery-gate.d.ts +81 -0
  249. package/dist/org-delivery-gate.js +59 -0
  250. package/dist/panel-tool-names.d.ts +23 -0
  251. package/dist/panel-tool-names.js +8 -0
  252. package/dist/parked-decide.d.ts +39 -6
  253. package/dist/parked-decide.js +98 -51
  254. package/dist/parked-revive-surface.d.ts +9 -2
  255. package/dist/parked-revive-surface.js +11 -8
  256. package/dist/permission-rule-list.d.ts +1 -1
  257. package/dist/permission-rule-list.js +2 -2
  258. package/dist/plugins/approval-ask-store-file.d.ts +16 -1
  259. package/dist/plugins/approval-ask-store-file.js +21 -0
  260. package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
  261. package/dist/plugins/approval-ask-store-memory.js +34 -2
  262. package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
  263. package/dist/plugins/approval-ask-store-sql.js +37 -1
  264. package/dist/plugins/blob-backend.d.ts +38 -25
  265. package/dist/plugins/blob-backend.js +29 -19
  266. package/dist/plugins/breaker-state-sql.d.ts +2 -2
  267. package/dist/plugins/breaker-state-sql.js +4 -4
  268. package/dist/plugins/caching-session-store.d.ts +3 -0
  269. package/dist/plugins/caching-session-store.js +3 -0
  270. package/dist/plugins/checkpoint-store-sql.d.ts +14 -0
  271. package/dist/plugins/checkpoint-store-sql.js +20 -2
  272. package/dist/plugins/file-history-store-sql.d.ts +5 -2
  273. package/dist/plugins/file-history-store-sql.js +3 -1
  274. package/dist/plugins/file-run-store.d.ts +5 -13
  275. package/dist/plugins/file-run-store.js +9 -0
  276. package/dist/plugins/fork-routing-session-store.d.ts +9 -1
  277. package/dist/plugins/fork-routing-session-store.js +12 -1
  278. package/dist/plugins/host-platform.d.ts +2 -0
  279. package/dist/plugins/host-platform.js +2 -1
  280. package/dist/plugins/local-checkpoint-store.d.ts +2 -0
  281. package/dist/plugins/local-checkpoint-store.js +6 -1
  282. package/dist/plugins/local-session-store.d.ts +1 -1
  283. package/dist/plugins/local-session-window.d.ts +39 -0
  284. package/dist/plugins/local-session-window.js +54 -0
  285. package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
  286. package/dist/plugins/mailbox-store-sql.d.ts +30 -48
  287. package/dist/plugins/mailbox-store-sql.js +77 -52
  288. package/dist/plugins/memory-embedder-fingerprint.js +2 -1
  289. package/dist/plugins/memory-run-store.d.ts +5 -13
  290. package/dist/plugins/memory-run-store.js +8 -0
  291. package/dist/plugins/one-time-migrations.d.ts +110 -5
  292. package/dist/plugins/one-time-migrations.js +320 -8
  293. package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
  294. package/dist/plugins/org-delivery-quota-store.js +228 -0
  295. package/dist/plugins/pg-pool.js +39 -7
  296. package/dist/plugins/pg-session-storage.d.ts +17 -4
  297. package/dist/plugins/pg-session-storage.js +29 -6
  298. package/dist/plugins/remote-env-adb.d.ts +6 -12
  299. package/dist/plugins/remote-env-adb.js +12 -2
  300. package/dist/plugins/remote-env-k8s.d.ts +8 -12
  301. package/dist/plugins/remote-env-k8s.js +23 -5
  302. package/dist/plugins/remote-env-local-docker.d.ts +10 -15
  303. package/dist/plugins/remote-env-local-docker.js +12 -9
  304. package/dist/plugins/remote-env-ssh.d.ts +10 -16
  305. package/dist/plugins/remote-env-ssh.js +17 -11
  306. package/dist/plugins/run-store-sql.d.ts +16 -14
  307. package/dist/plugins/run-store-sql.js +22 -2
  308. package/dist/plugins/schema-indexes.js +2 -0
  309. package/dist/plugins/send-user-file.js +2 -2
  310. package/dist/plugins/session-epoch-anchor.d.ts +32 -6
  311. package/dist/plugins/session-epoch-anchor.js +2 -3
  312. package/dist/plugins/session-store.d.ts +18 -8
  313. package/dist/plugins/session-store.js +15 -4
  314. package/dist/plugins/sql-driver.d.ts +74 -11
  315. package/dist/plugins/sql-driver.js +210 -12
  316. package/dist/plugins/sql-errors.d.ts +23 -0
  317. package/dist/plugins/sql-errors.js +21 -0
  318. package/dist/plugins/store-backend.d.ts +36 -1
  319. package/dist/plugins/store-backend.js +40 -14
  320. package/dist/plugins/store-contracts.d.ts +42 -0
  321. package/dist/plugins/store-contracts.js +1 -0
  322. package/dist/plugins/tidb-pool.d.ts +6 -1
  323. package/dist/plugins/tidb-pool.js +44 -10
  324. package/dist/plugins/tidb-session-storage.d.ts +3 -2
  325. package/dist/plugins/tidb-session-storage.js +2 -2
  326. package/dist/plugins/tidb-session-store.d.ts +24 -4
  327. package/dist/plugins/tidb-session-store.js +28 -4
  328. package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
  329. package/dist/plugins/workflow-journal-store-sql.js +19 -6
  330. package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
  331. package/dist/plugins/workflow-run-store-sql.js +50 -9
  332. package/dist/posture-source.d.ts +18 -10
  333. package/dist/posture-source.js +4 -1
  334. package/dist/project-identity.d.ts +45 -6
  335. package/dist/project-identity.js +162 -8
  336. package/dist/project-layer-key.d.ts +28 -0
  337. package/dist/project-layer-key.js +29 -0
  338. package/dist/question.js +3 -2
  339. package/dist/read-deny-entry.d.ts +25 -0
  340. package/dist/read-deny-entry.js +12 -0
  341. package/dist/read-face-posture.d.ts +37 -11
  342. package/dist/read-face-posture.js +32 -3
  343. package/dist/request-key-closure.d.ts +7 -0
  344. package/dist/request-key-closure.js +9 -1
  345. package/dist/request-value-closure.d.ts +5 -0
  346. package/dist/request-value-closure.js +11 -3
  347. package/dist/rule-entry-list.d.ts +26 -2
  348. package/dist/rule-entry-list.js +72 -12
  349. package/dist/rules-consent.js +3 -4
  350. package/dist/run-acceptance.d.ts +19 -3
  351. package/dist/run-acceptance.js +13 -1
  352. package/dist/run-local.js +36 -6
  353. package/dist/runs.d.ts +10 -9
  354. package/dist/runs.js +21 -3
  355. package/dist/runtime-caps-resolver.d.ts +16 -6
  356. package/dist/runtime-caps-resolver.js +18 -5
  357. package/dist/sandbox-pkg-source.d.ts +19 -1
  358. package/dist/sandbox-pkg-source.js +29 -7
  359. package/dist/security.d.ts +87 -9
  360. package/dist/security.js +52 -9
  361. package/dist/session-error-wire.d.ts +19 -2
  362. package/dist/session-error-wire.js +5 -1
  363. package/dist/session-titled-frame.d.ts +33 -0
  364. package/dist/session-titled-frame.js +4 -0
  365. package/dist/session-titler.d.ts +9 -1
  366. package/dist/session-titler.js +15 -4
  367. package/dist/spec-fields.js +21 -2
  368. package/dist/sql-engine-posture.d.ts +3 -1
  369. package/dist/task-cwd.d.ts +1 -1
  370. package/dist/task-mcp.d.ts +3 -3
  371. package/dist/task-mcp.js +7 -66
  372. package/dist/task-settings.d.ts +89 -88
  373. package/dist/task-settings.js +71 -63
  374. package/dist/text-bidi.d.ts +0 -4
  375. package/dist/text-bidi.js +1 -3
  376. package/dist/tighten-only-seats.d.ts +150 -0
  377. package/dist/tighten-only-seats.js +196 -0
  378. package/dist/tool-approval.d.ts +303 -87
  379. package/dist/tool-approval.js +623 -239
  380. package/dist/trace/core-keyset-guard.d.ts +104 -22
  381. package/dist/trace/exit-seat.d.ts +28 -0
  382. package/dist/trace/exit-seat.js +76 -0
  383. package/dist/trace/ledger-events.d.ts +3 -2
  384. package/dist/trace/project.d.ts +80 -12
  385. package/dist/trace/project.js +41 -28
  386. package/dist/trace/projection-table.d.ts +100 -0
  387. package/dist/trace/projection-table.js +130 -0
  388. package/dist/trace/redact.d.ts +54 -0
  389. package/dist/trace/redact.js +778 -152
  390. package/dist/trace/self-minted-wire.d.ts +345 -1
  391. package/dist/trace/self-minted-wire.js +117 -1
  392. package/dist/trace/wire-projection-faces.d.ts +298 -2
  393. package/dist/trace/wire-projection-faces.js +154 -13
  394. package/dist/url-refusal.js +2 -0
  395. package/dist/web-admin-client/apply-effective.d.ts +12 -0
  396. package/dist/web-admin-client/apply-effective.js +56 -5
  397. package/dist/web-admin-client/facade.d.ts +1 -1
  398. package/dist/web-admin-client/facade.js +1 -1
  399. package/dist/web-admin-client/read-face.js +5 -9
  400. package/dist/web-admin-client/skills-mcp.js +4 -5
  401. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +57 -9
  402. package/package.json +7 -3
@@ -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";
@@ -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 } : {}),
@@ -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
@@ -0,0 +1,130 @@
1
+ import { redactErrorMessage } from "../observability/run-terminal.js";
2
+ import { dropProjectedFace } from "./projection-drop.js";
3
+ import { redactSecrets } from "./redact.js";
4
+ export function projectByTable(face, table, value, root) {
5
+ return projectNode(face, table, value, root);
6
+ }
7
+ const isRecord = (v) => typeof v === "object" && v !== null;
8
+ const DISPOSITION_KEYS = ["mint", "forward", "redact", "nested", "rows", "admit"];
9
+ function projectNode(path, table, value, root) {
10
+ const out = {};
11
+ for (const [key, entry] of Object.entries(table)) {
12
+ const at = `${path}.${key}`;
13
+ if (entry === "strip")
14
+ continue;
15
+ if (entry === "forward") {
16
+ const raw = Reflect.get(value, key);
17
+ if (raw !== undefined)
18
+ out[key] = raw;
19
+ continue;
20
+ }
21
+ if (!isRecord(entry))
22
+ throw unknownWord(at, entry);
23
+ const present = DISPOSITION_KEYS.filter((k) => Object.hasOwn(entry, k));
24
+ const words = present.filter((k) => k !== "rows" && k !== "admit");
25
+ if (words.length === 0)
26
+ throw unknownWord(at, entry);
27
+ if (words.length > 1 || (words[0] !== "nested" && present.length > 1)) {
28
+ throw new Error(`projection_table: ${at} carries more than one disposition (${present.join(", ")}) — one cell, one word`);
29
+ }
30
+ if (words[0] === "mint") {
31
+ if (typeof entry.mint !== "function")
32
+ throw unknownWord(at, entry);
33
+ const minted = entry.mint(value, root);
34
+ if (minted !== undefined)
35
+ out[key] = minted;
36
+ continue;
37
+ }
38
+ const raw = Reflect.get(value, key);
39
+ if (raw === undefined)
40
+ continue;
41
+ if (words[0] === "forward") {
42
+ if (typeof entry.forward !== "function")
43
+ throw unknownWord(at, entry);
44
+ if (entry.forward(raw) === true)
45
+ out[key] = raw;
46
+ else
47
+ drop(at, "is present but its narrow read rejects it");
48
+ continue;
49
+ }
50
+ if (words[0] === "redact") {
51
+ if (typeof entry.redact !== "string")
52
+ throw unknownWord(at, entry);
53
+ const redacted = redactWith(entry.redact, raw, at);
54
+ if (redacted !== undefined)
55
+ out[key] = redacted;
56
+ continue;
57
+ }
58
+ const projected = projectNested(at, entry, raw, root);
59
+ if (projected !== undefined)
60
+ out[key] = projected;
61
+ }
62
+ return out;
63
+ }
64
+ function projectNested(at, entry, raw, root) {
65
+ const sub = entry.nested;
66
+ if (!isRecord(sub))
67
+ throw unknownWord(at, entry);
68
+ if (entry.admit !== undefined && typeof entry.admit !== "function")
69
+ throw unknownWord(at, entry);
70
+ if (typeof entry.admit === "function" && entry.admit(raw) !== true) {
71
+ return drop(at, "is present but its narrow read rejects it");
72
+ }
73
+ const rows = entry.rows;
74
+ if (rows === undefined) {
75
+ if (!isRecord(raw) || Array.isArray(raw))
76
+ return drop(at, "is present but not an object");
77
+ return projectNode(at, sub, raw, root);
78
+ }
79
+ if (!Array.isArray(raw))
80
+ return drop(at, "is present but not a list");
81
+ let carried;
82
+ if (rows === "each")
83
+ carried = raw;
84
+ else if (typeof rows === "function") {
85
+ const selected = rows(raw, root);
86
+ if (!Array.isArray(selected))
87
+ throw new Error(`projection_table: ${at} rows selector returned a non-list`);
88
+ const pool = new Set(raw);
89
+ if (selected.some((element) => !pool.has(element))) {
90
+ throw new Error(`projection_table: ${at} rows selector returned an element that is not in the list — rows may only select / reorder`);
91
+ }
92
+ carried = selected;
93
+ }
94
+ else
95
+ throw unknownWord(at, entry);
96
+ const out = [];
97
+ for (const element of carried) {
98
+ if (isRecord(element) && !Array.isArray(element))
99
+ out.push(projectNode(`${at}[]`, sub, element, root));
100
+ else
101
+ drop(`${at}[]`, "element is present but not an object");
102
+ }
103
+ return out;
104
+ }
105
+ function redactWith(word, raw, at) {
106
+ const entry = word;
107
+ const asText = (scrub) => (typeof raw === "string" ? scrub(raw) : drop(at, "is present but not text"));
108
+ switch (entry) {
109
+ case "redactSecrets":
110
+ return asText(redactSecrets);
111
+ case "redactErrorMessage":
112
+ return asText(redactErrorMessage);
113
+ default: {
114
+ const unhandled = entry;
115
+ throw unknownWord(at, { redact: unhandled });
116
+ }
117
+ }
118
+ }
119
+ function drop(at, why) {
120
+ return dropProjectedFace("projection_table." + at + " " + why);
121
+ }
122
+ function unknownWord(at, entry) {
123
+ const shown = typeof entry === "string"
124
+ ? JSON.stringify(entry)
125
+ : isRecord(entry)
126
+ ? `{${Object.entries(entry).map(([k, v]) => `${k}:${typeof v === "string" ? v : typeof v}`).join(",")}}`
127
+ : String(entry);
128
+ return new Error(`projection_table: ${at} carries a disposition the interpreter does not know: ${shown}`);
129
+ }
130
+ //# sourceMappingURL=projection-table.js.map
@@ -29,10 +29,30 @@ export declare function armPoolBudgetForTest(): {
29
29
  armCount: number;
30
30
  boundaryArmCount: number;
31
31
  forensicLevels: number;
32
+ forensicRuns: number;
33
+ forensicSkips: number;
34
+ urlSegmentRuns: number;
35
+ urlSegmentReplays: number;
32
36
  ssh2ScanBytes: number;
33
37
  mappedUnits: number;
34
38
  };
35
39
  export declare function resetArmPoolBudgetForTest(): void;
40
+ /**
41
+ * 🔴 **脱敏的两个档 —— 「这段文本是自由文本,还是一个结构有界的单元」**(S-526,闭集两词)。
42
+ *
43
+ * · `"free-text"`:CoT / 日志 / 任意字节。臂**全员**在场,读数就是 {@link redactSecrets} 的对外语义。
44
+ * · `"bounded-unit"`:一个 URL 路径段、一个 query 键名或值 —— 边界由**结构**给(WHATWG 已经把界告诉我们了)。
45
+ * 这一档**去掉词法关键字臂**:它们的判别力来自自由文本的语法,而单元里没有那种语法(见
46
+ * {@link unitCarriesCredential} 顶注的病理)。值形臂与结构锚臂两族都**留在档里** —— 判别力分别是
47
+ * 「前缀 + 值形」与一条**字面结构锚**(`-----BEGIN` / `://u:p@` / JSON 秘密字段名)。
48
+ * ⚠️ **只有值形臂那一族在单元里真的开火**(异源复审 270 形实测纠错):结构锚臂**留着但恒空转** —— 锚里的
49
+ * 空格 / `:` / `@` / `"` / `{` 不属于**任何**臂的值字符类,{@link boundedUnitView} 的补位会把它们逐个换掉,
50
+ * 锚在每一份视图里都被摧毁。把结构锚臂一并踢出本档,270 形读数**零差**。留着它们是因为「谁的判别力依赖
51
+ * 自由文本语法」这条**判据**上它们本就不该被排除(踢掉是另一条理由),不是因为它们在这里还起作用。
52
+ *
53
+ * 闭集:加一个档而不在 {@link armPool} 的档表里处置 ⇒ **编译**红。
54
+ */
55
+ type RedactionScope = "free-text" | "bounded-unit";
36
56
  /** 本模块会写进文本的全部替换 token(`«…»` 字面),从三张表现算 —— 表改这里自动跟,不另抄一份。
37
57
  * 🔴 **S-223 v2 修复轮起它只剩一个语义:闭形闭集的加载期校验**。运行期「这一段是不是一枚记号」已经由
38
58
  * {@link credentialSpans} 的闭**形**那一支一处答完({@link opaqueUnitEnd}),按闭**集**再认一遍的
@@ -44,6 +64,23 @@ declare const DISPLAY_SAFE_URL_TOKEN = "\u00ABredacted:url\u00BB";
44
64
  /** S-776:出网代理 URL 的回显尺(`outbound-dispatcher.ts` `displayProxyUrl`)形不干净时整只用**同一枚**占位 —— 单独一行导出,
45
65
  * 上面那行字面量保持 `const NAME = "…";` 形(`test/api-notice-text-freeze.test.ts` §6 的冻结扫描按这一形认替换 token)。 */
46
66
  export { DISPLAY_SAFE_URL_TOKEN };
67
+ /**
68
+ * 🔴 **取证相的重扫模式(测试座,S-375)** —— 生产恒 `"incremental"`;`"full"` 是**参照语义** = 「没有可复用的上一次执行」:
69
+ * 每级五条取证臂整段重跑、URL 臂每段重扫,既不读足迹也不回放(池把每一级的脏区间当作「未知」交下去,与级 0 同一个读法)。
70
+ * 证据表的建法(级 0 记号档 + 逐级折入)与收敛判据(脏区间为空)两种模式是同一条,所以两种模式只差「复用与否」这一位 ——
71
+ * 增量重扫的全部正确性主张只有一句:**任何输入上两种模式输出逐字相同**(`test/forensic-incremental-rescan.test.ts` 并跑比对;
72
+ * 折入本身与整表重建的对拍是那个测试文件里的一份测试本地参照)。
73
+ */
74
+ export type ForensicRescanMode = "incremental" | "full";
75
+ export declare function setForensicRescanModeForTest(mode: ForensicRescanMode): void;
76
+ /** 测试座:折入函数的数组形(`prev` 须是合法的已并表:升序、两两不交不相接)。 */
77
+ export declare function credentialSpansFoldForTest(prev: ReadonlyArray<readonly [number, number]>, add: ReadonlyArray<readonly [number, number]>): {
78
+ next: Array<[number, number]>;
79
+ dirty: Array<[number, number]>;
80
+ };
81
+ /** 🧪 结构读数(与 {@link ppkScanBytesForTest} 同一条技法):本扫描器读过的单元数,线性钉用。 */
82
+ export declare function anchoredScanUnitsForTest(): number;
83
+ export declare function resetAnchoredScanUnitsForTest(): void;
47
84
  /** 测试可见(S-265 真值表的两半):结构段里**表行只作声明、实现是手写扫描器**的臂 —— 声明正则的**新拷贝**
48
85
  * (`lastIndex` 不与模块内那一枚共享)+ 扫描器在一份原文上产的候选跨度 `[起, 止)`。臂名是闭集 ⇒ 穷尽 `switch`
49
86
  * (少一个 `case` = 缺返回 = 编译红)。 */
@@ -125,6 +162,23 @@ export declare function redactionSpansForTest(text: string, opts?: {
125
162
  readonly end: number;
126
163
  }>;
127
164
  };
165
+ /**
166
+ * 🔴 **出口座的提案口**(S-485 / RH-1 第一期;座 = `src/trace/exit-seat.ts` 的 `seatText`)。
167
+ *
168
+ * 同一只 {@link runRedaction}、同一遍扫描、同一次观察者计数(`observe` 与 {@link redactSecrets} 的缺省同口 —— 座上的一次脱敏就是一次
169
+ * 主扫),交出**原文坐标**上的跨度与各自的替换串:臂认什么、档里有哪些臂,仍然只由本模块答。座拿它做**一次区间合并 + 一次渲染**
170
+ * (合并律与渲染律住在座里,本模块不拼第二份产物给座)。
171
+ *
172
+ * 第一期交的是池解完重叠之后的那一份(升序、两两不交);第二期改交未解重叠的原始候选,池内并集律 {@link resolveSpanOverlaps} 与
173
+ * {@link applySpans} 随之删除 —— 那时本口是自由文本脱敏的唯一出口。
174
+ */
175
+ export type RedactionSpan = {
176
+ readonly start: number;
177
+ readonly end: number;
178
+ readonly repl: string;
179
+ };
180
+ export type { RedactionScope };
181
+ export declare function proposeRedactionSpans(text: string, scope: RedactionScope): readonly RedactionSpan[];
128
182
  /**
129
183
  * 🔴 环 + 深度预算(2026-07-25 补)。原实现是纯递归、**既不记已访问节点也不限深度**,而它的调用位置是
130
184
  * **最不可信的边界**:`toolStart`/`toolEnd` 把工具的 `args`/`output`/`structured` 直接喂进来。后果两条: