@sema-agent/server 7.134.0 → 7.135.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 (458) hide show
  1. package/MIGRATION.md +134 -0
  2. package/USAGE.md +98 -30
  3. package/dist/adoption/plan.d.ts +1 -1
  4. package/dist/approval-ask-audit-store.d.ts +24 -24
  5. package/dist/approval-ask-machine.d.ts +2 -2
  6. package/dist/approval-card.d.ts +62 -150
  7. package/dist/approval-card.js +33 -51
  8. package/dist/approval-content-kind.d.ts +22 -5
  9. package/dist/approval-content-kind.js +8 -1
  10. package/dist/approval-deny-reasons.d.ts +1 -1
  11. package/dist/approval-gate-currency.d.ts +22 -3
  12. package/dist/approval-gate-currency.js +44 -18
  13. package/dist/approval-hmac.d.ts +7 -7
  14. package/dist/approval-policy-settlement.d.ts +2 -2
  15. package/dist/approval-reconciler.d.ts +3 -3
  16. package/dist/approval.d.ts +8 -8
  17. package/dist/approval.js +4 -2
  18. package/dist/auth-bridge.d.ts +1 -1
  19. package/dist/auto-mode-face.d.ts +4 -4
  20. package/dist/background-session-reap.d.ts +2 -2
  21. package/dist/bake-runner/main.d.ts +2 -2
  22. package/dist/bake-runner/runner.d.ts +4 -4
  23. package/dist/bench/s1/live-deps.d.ts +1 -1
  24. package/dist/bench/s1/run-firm.d.ts +1 -1
  25. package/dist/boot/coordinators.d.ts +2 -2
  26. package/dist/boot/coordinators.js +2 -2
  27. package/dist/boot/deferred-sandbox-path-env.d.ts +0 -6
  28. package/dist/boot/deferred-sandbox-path-env.js +0 -5
  29. package/dist/boot/engine-lease.d.ts +5 -5
  30. package/dist/boot/execution-env.d.ts +16 -15
  31. package/dist/boot/execution-env.js +19 -21
  32. package/dist/boot/fatal-exit.d.ts +2 -2
  33. package/dist/boot/late-binds.d.ts +1 -1
  34. package/dist/boot/leader.d.ts +1 -1
  35. package/dist/boot/memory-boundary.d.ts +2 -2
  36. package/dist/boot/memory-consolidation.d.ts +15 -15
  37. package/dist/boot/parked-revive-gate.d.ts +3 -3
  38. package/dist/boot/parked-revive-gate.js +3 -2
  39. package/dist/boot/reapers.d.ts +4 -4
  40. package/dist/boot/resolve-spec.d.ts +1 -1
  41. package/dist/boot/resolve-spec.js +28 -24
  42. package/dist/boot/runner-deps.d.ts +11 -11
  43. package/dist/boot/runner-deps.js +3 -2
  44. package/dist/boot/session-faces.d.ts +3 -3
  45. package/dist/boot/session-faces.js +11 -30
  46. package/dist/boot/shutdown.d.ts +5 -5
  47. package/dist/boot/side-query-lane.d.ts +2 -2
  48. package/dist/boot/stage-05-execution-env.js +4 -4
  49. package/dist/boot/stage-06-runners.js +0 -2
  50. package/dist/boot/stores.js +2 -1
  51. package/dist/boot/web-admin.d.ts +17 -17
  52. package/dist/boot/web-admin.js +5 -10
  53. package/dist/boot/workflow-orchestration.js +2 -9
  54. package/dist/brain.d.ts +11 -11
  55. package/dist/budget.d.ts +4 -4
  56. package/dist/capabilities/approvals-push.d.ts +4 -4
  57. package/dist/capabilities/builtin-tools.d.ts +5 -5
  58. package/dist/capabilities/center-plugins.d.ts +5 -5
  59. package/dist/capabilities/center-plugins.js +1 -1
  60. package/dist/capabilities/center-prompts.d.ts +1 -1
  61. package/dist/capabilities/center-wiring.d.ts +1 -1
  62. package/dist/capabilities/composite-members.d.ts +1 -1
  63. package/dist/capabilities/execution-lane.d.ts +5 -5
  64. package/dist/capabilities/execution-lane.js +2 -2
  65. package/dist/capabilities/hands-lane.d.ts +5 -5
  66. package/dist/capabilities/mcp-probe.d.ts +10 -7
  67. package/dist/capabilities/sandbox-file-send.d.ts +1 -18
  68. package/dist/capabilities/sandbox-file-send.js +0 -7
  69. package/dist/capabilities/scenarios.d.ts +28 -10
  70. package/dist/capabilities/scenarios.js +15 -5
  71. package/dist/capabilities/send-user-file-tool.d.ts +1 -1
  72. package/dist/capabilities/skills.d.ts +31 -12
  73. package/dist/capabilities/skills.js +23 -17
  74. package/dist/capabilities/tool-defer.d.ts +1 -1
  75. package/dist/capability-facts.d.ts +26 -25
  76. package/dist/capability-facts.js +14 -16
  77. package/dist/center-config-tier.d.ts +1 -1
  78. package/dist/center-credential.d.ts +4 -4
  79. package/dist/checkpoint-identity.d.ts +5 -0
  80. package/dist/checkpoint-identity.js +14 -0
  81. package/dist/config-catalog.d.ts +12 -12
  82. package/dist/config-invariants.d.ts +4 -4
  83. package/dist/config-invariants.js +3 -2
  84. package/dist/config-lkg.d.ts +1 -1
  85. package/dist/config-provider.d.ts +13 -13
  86. package/dist/config-provider.js +2 -1
  87. package/dist/config-types.d.ts +83 -83
  88. package/dist/config.d.ts +26 -24
  89. package/dist/config.js +12 -10
  90. package/dist/cross-session-settings.d.ts +1 -1
  91. package/dist/delegated-session-owner.d.ts +16 -13
  92. package/dist/delegated-session-owner.js +9 -10
  93. package/dist/deployment-governance.d.ts +16 -16
  94. package/dist/deployment-shape.d.ts +127 -0
  95. package/dist/deployment-shape.js +72 -0
  96. package/dist/device-store.d.ts +1 -1
  97. package/dist/device-ws-hub.d.ts +1 -1
  98. package/dist/egress-redirect.d.ts +1 -1
  99. package/dist/entry-mode-clamp-notice.d.ts +2 -2
  100. package/dist/env-facts.d.ts +10 -9
  101. package/dist/env-facts.js +1 -1
  102. package/dist/env-name-allowlist-knobs.d.ts +5 -5
  103. package/dist/exec-bounds.d.ts +2 -2
  104. package/dist/execution-lane-caps.d.ts +31 -43
  105. package/dist/execution-lane-caps.js +0 -13
  106. package/dist/file-history-capture.d.ts +9 -9
  107. package/dist/file-history-disclosure.d.ts +23 -11
  108. package/dist/file-history-disclosure.js +7 -12
  109. package/dist/fleet/drain-entry.d.ts +2 -2
  110. package/dist/fleet/fleet-bus.d.ts +22 -14
  111. package/dist/fleet/fleet-bus.js +5 -5
  112. package/dist/fleet/fleet-reconciler.d.ts +9 -9
  113. package/dist/fleet/subagent-tail-bus.d.ts +4 -4
  114. package/dist/fleet-client.d.ts +13 -13
  115. package/dist/fleet-lease.d.ts +16 -16
  116. package/dist/governance-http-status.d.ts +2 -2
  117. package/dist/hooks/hook-llm.d.ts +7 -7
  118. package/dist/hooks/hook-runner.d.ts +57 -30
  119. package/dist/hooks/hook-runner.js +36 -18
  120. package/dist/host-decision.d.ts +5 -5
  121. package/dist/host-lsp-manager.d.ts +5 -5
  122. package/dist/hosted-posture.d.ts +23 -13
  123. package/dist/hosted-posture.js +4 -9
  124. package/dist/http/admission.d.ts +2 -2
  125. package/dist/http/admission.js +20 -5
  126. package/dist/http/approval-sweeps.d.ts +1 -1
  127. package/dist/http/approval-sweeps.js +2 -1
  128. package/dist/http/checkpoint-ctx.d.ts +39 -13
  129. package/dist/http/checkpoint-ctx.js +74 -35
  130. package/dist/http/dispatch.d.ts +3 -3
  131. package/dist/http/durable-run-leg.js +4 -3
  132. package/dist/http/idempotency.d.ts +2 -2
  133. package/dist/http/mcp-dial-deadline.d.ts +7 -5
  134. package/dist/http/memory-compliance-failure-reply.d.ts +4 -4
  135. package/dist/http/owner-access.d.ts +4 -6
  136. package/dist/http/owner-access.js +1 -1
  137. package/dist/http/principal-gate.d.ts +7 -7
  138. package/dist/http/principal-gate.js +3 -2
  139. package/dist/http/readiness.d.ts +1 -1
  140. package/dist/http/request-guards.d.ts +4 -4
  141. package/dist/http/request-guards.js +2 -1
  142. package/dist/http/resume-ctx-read.d.ts +7 -7
  143. package/dist/http/resume-ctx-read.js +1 -1
  144. package/dist/http/resume-legs.d.ts +3 -3
  145. package/dist/http/resume-legs.js +11 -8
  146. package/dist/http/route-ctx.d.ts +29 -29
  147. package/dist/http/route-table.d.ts +9 -9
  148. package/dist/http/routes/agents-roster.d.ts +1 -1
  149. package/dist/http/routes/approvals-assistant.d.ts +5 -5
  150. package/dist/http/routes/approvals-assistant.js +55 -15
  151. package/dist/http/routes/background.d.ts +3 -3
  152. package/dist/http/routes/background.js +2 -2
  153. package/dist/http/routes/capabilities.d.ts +1 -1
  154. package/dist/http/routes/capabilities.js +16 -8
  155. package/dist/http/routes/config-catalog.d.ts +1 -1
  156. package/dist/http/routes/devices.d.ts +1 -1
  157. package/dist/http/routes/diagnostics.d.ts +3 -3
  158. package/dist/http/routes/fleet.d.ts +1 -1
  159. package/dist/http/routes/fleet.js +2 -1
  160. package/dist/http/routes/mcp-reconnect.d.ts +4 -4
  161. package/dist/http/routes/mcp-reconnect.js +3 -3
  162. package/dist/http/routes/memory-consolidation.d.ts +1 -1
  163. package/dist/http/routes/notify-wake.d.ts +1 -1
  164. package/dist/http/routes/notify-wake.js +2 -2
  165. package/dist/http/routes/rules.d.ts +1 -1
  166. package/dist/http/routes/runs.js +22 -10
  167. package/dist/http/routes/session-sync.d.ts +1 -1
  168. package/dist/http/routes/session-sync.js +73 -44
  169. package/dist/http/routes/sessions-list.js +1 -1
  170. package/dist/http/routes/sessions.js +30 -44
  171. package/dist/http/routes/tasks.d.ts +1 -1
  172. package/dist/http/routes/trace-usage.d.ts +1 -1
  173. package/dist/http/routes/workflows.d.ts +3 -0
  174. package/dist/http/routes/workflows.js +31 -28
  175. package/dist/http/send.d.ts +5 -5
  176. package/dist/http/server.d.ts +34 -34
  177. package/dist/http/session-inherit-env.d.ts +3 -3
  178. package/dist/http/sse-lifecycle.d.ts +1 -1
  179. package/dist/http/sse-log.d.ts +2 -2
  180. package/dist/http/submit-ctx.js +1 -1
  181. package/dist/http/sync-submit-body.d.ts +1 -1
  182. package/dist/http/verify-rounds.d.ts +1 -1
  183. package/dist/http/wire-types.d.ts +28 -21
  184. package/dist/instruction-source-notice.d.ts +2 -2
  185. package/dist/key-resolver.d.ts +3 -3
  186. package/dist/lane-home-probe.d.ts +1 -1
  187. package/dist/leader/diffout.d.ts +1 -1
  188. package/dist/leader/diffup.d.ts +2 -2
  189. package/dist/leader/endpoint.d.ts +1 -1
  190. package/dist/leader/fanout.d.ts +1 -1
  191. package/dist/leader/leader.d.ts +4 -4
  192. package/dist/leader/merge.d.ts +3 -3
  193. package/dist/leader/repair-wire.d.ts +1 -1
  194. package/dist/leader/wire.d.ts +6 -6
  195. package/dist/list-entry-display.d.ts +1 -1
  196. package/dist/lsp-evict.d.ts +1 -1
  197. package/dist/mcp-assertion-header.d.ts +1 -1
  198. package/dist/memory-layer-legacy-lock.d.ts +1 -1
  199. package/dist/memory-operator-faces.d.ts +1 -1
  200. package/dist/memory-posture.js +4 -2
  201. package/dist/memory-project-layer.d.ts +1 -1
  202. package/dist/memory-scope.d.ts +19 -19
  203. package/dist/memory-store-refusal.d.ts +4 -4
  204. package/dist/model-entry-headers.d.ts +2 -2
  205. package/dist/model-entry-refusal.d.ts +17 -17
  206. package/dist/model-provider.d.ts +10 -10
  207. package/dist/model-reach-scope.d.ts +1 -1
  208. package/dist/model-route-endpoint.d.ts +6 -6
  209. package/dist/model-route-url.d.ts +5 -5
  210. package/dist/model-select.d.ts +15 -6
  211. package/dist/model-select.js +5 -0
  212. package/dist/model-unreachable-notice.d.ts +3 -3
  213. package/dist/namespaced-rule-name.d.ts +15 -5
  214. package/dist/namespaced-rule-name.js +3 -2
  215. package/dist/observability/corrupt-read-seat.d.ts +9 -9
  216. package/dist/observability/cost-taxonomy.d.ts +1 -1
  217. package/dist/observability/err-text.d.ts +1 -1
  218. package/dist/observability/fail-open.d.ts +12 -8
  219. package/dist/observability/fail-open.js +12 -8
  220. package/dist/observability/metrics.d.ts +3 -3
  221. package/dist/observability/run-terminal.d.ts +36 -36
  222. package/dist/observability/secret-env-scrub.d.ts +3 -3
  223. package/dist/observability/tool-trace.d.ts +1 -1
  224. package/dist/operator-ask.d.ts +4 -4
  225. package/dist/orchestration/workflow-agent-session-index.d.ts +3 -3
  226. package/dist/orchestration/workflow-completion-inbox.d.ts +20 -5
  227. package/dist/orchestration/workflow-completion-inbox.js +29 -7
  228. package/dist/orchestration/workflow-notify-journal.d.ts +43 -19
  229. package/dist/orchestration/workflow-notify-journal.js +17 -0
  230. package/dist/outbound-dispatcher.d.ts +4 -4
  231. package/dist/parent-watch.d.ts +4 -4
  232. package/dist/parked-decide.d.ts +16 -15
  233. package/dist/parked-decide.js +5 -4
  234. package/dist/parked-revive-surface.d.ts +7 -7
  235. package/dist/parked-revive-surface.js +2 -3
  236. package/dist/peer-directory.d.ts +3 -3
  237. package/dist/peer-directory.js +1 -1
  238. package/dist/permission-rule-list.d.ts +10 -1
  239. package/dist/permission-rule-list.js +7 -5
  240. package/dist/permission-rule-vocab.d.ts +2 -2
  241. package/dist/plugins/adoption-log-sql.d.ts +1 -1
  242. package/dist/plugins/approval-ask-store-file.d.ts +8 -1
  243. package/dist/plugins/approval-ask-store-file.js +6 -3
  244. package/dist/plugins/approval-ask-store-memory.d.ts +11 -7
  245. package/dist/plugins/approval-ask-store-memory.js +11 -7
  246. package/dist/plugins/approval-ask-store-sql.d.ts +34 -15
  247. package/dist/plugins/approval-ask-store-sql.js +18 -5
  248. package/dist/plugins/approval-exemption-store.d.ts +3 -3
  249. package/dist/plugins/approval-nonce-store.d.ts +3 -3
  250. package/dist/plugins/background-agent-store-sql.d.ts +1 -1
  251. package/dist/plugins/background-shell-support.d.ts +2 -2
  252. package/dist/plugins/blob-backend.d.ts +1 -1
  253. package/dist/plugins/caching-session-store.d.ts +23 -32
  254. package/dist/plugins/caching-session-store.js +5 -17
  255. package/dist/plugins/checkpoint-index-columns.d.ts +81 -0
  256. package/dist/plugins/checkpoint-index-columns.js +62 -0
  257. package/dist/plugins/checkpoint-store-sql.d.ts +44 -66
  258. package/dist/plugins/checkpoint-store-sql.js +55 -102
  259. package/dist/plugins/device-store-sql.d.ts +7 -6
  260. package/dist/plugins/e2b-orphan-reclaim.d.ts +1 -1
  261. package/dist/plugins/ensure-schema-lock-policy.d.ts +1 -1
  262. package/dist/plugins/file-history-store-sql.d.ts +9 -7
  263. package/dist/plugins/file-history-store-sql.js +27 -15
  264. package/dist/plugins/file-run-store.d.ts +8 -8
  265. package/dist/plugins/fork-routing-session-store.d.ts +2 -2
  266. package/dist/plugins/fork-routing-session-store.js +1 -1
  267. package/dist/plugins/host-platform.d.ts +10 -10
  268. package/dist/plugins/image-bake-store-sql.d.ts +1 -1
  269. package/dist/plugins/image-index-sql.d.ts +1 -1
  270. package/dist/plugins/leader-run-store-sql.d.ts +1 -1
  271. package/dist/plugins/local-checkpoint-store.d.ts +10 -10
  272. package/dist/plugins/local-checkpoint-store.js +3 -4
  273. package/dist/plugins/local-session-store.d.ts +34 -38
  274. package/dist/plugins/local-session-store.js +20 -39
  275. package/dist/plugins/local-session-window.d.ts +1 -1
  276. package/dist/plugins/mailbox-store-sql.d.ts +2 -2
  277. package/dist/plugins/memory-engine-pg.d.ts +1 -1
  278. package/dist/plugins/memory-run-store.d.ts +4 -4
  279. package/dist/plugins/memory-sync-store-pg.d.ts +3 -3
  280. package/dist/plugins/one-time-migrations.d.ts +66 -40
  281. package/dist/plugins/one-time-migrations.js +115 -34
  282. package/dist/plugins/outcome-ledger-sql.d.ts +1 -1
  283. package/dist/plugins/park-commit-watch.d.ts +3 -3
  284. package/dist/plugins/permission-rule-store-file.d.ts +5 -5
  285. package/dist/plugins/permission-rule-store-file.js +12 -19
  286. package/dist/plugins/permission-rule-store-sql.d.ts +38 -4
  287. package/dist/plugins/permission-rule-store-sql.js +67 -24
  288. package/dist/plugins/pg-cost-quota.d.ts +1 -1
  289. package/dist/plugins/pg-pool.d.ts +2 -2
  290. package/dist/plugins/pg-pool.js +5 -2
  291. package/dist/plugins/pg-rate-limiter.d.ts +1 -1
  292. package/dist/plugins/pg-session-storage.d.ts +8 -20
  293. package/dist/plugins/pg-session-storage.js +14 -27
  294. package/dist/plugins/remote-env-adb.d.ts +10 -10
  295. package/dist/plugins/remote-env-device.d.ts +10 -9
  296. package/dist/plugins/remote-env-device.js +6 -2
  297. package/dist/plugins/remote-env-e2b.d.ts +3 -3
  298. package/dist/plugins/remote-env-host.d.ts +16 -16
  299. package/dist/plugins/remote-env-k8s.d.ts +8 -8
  300. package/dist/plugins/remote-env-local-docker.d.ts +2 -2
  301. package/dist/plugins/remote-env-ssh.d.ts +4 -4
  302. package/dist/plugins/remote-scratchpad.d.ts +2 -3
  303. package/dist/plugins/remote-scratchpad.js +0 -4
  304. package/dist/plugins/remote-shell.d.ts +6 -6
  305. package/dist/plugins/retention-lane-store-sql.d.ts +4 -4
  306. package/dist/plugins/retention-store-sql.d.ts +4 -4
  307. package/dist/plugins/roster-store-sql.d.ts +1 -1
  308. package/dist/plugins/run-store-sql.d.ts +8 -8
  309. package/dist/plugins/schema-consistency.d.ts +2 -2
  310. package/dist/plugins/schema-ensure-legs.d.ts +3 -3
  311. package/dist/plugins/schema-indexes.d.ts +1 -1
  312. package/dist/plugins/schema-live-columns.d.ts +1 -1
  313. package/dist/plugins/session-event-payload.d.ts +4 -4
  314. package/dist/plugins/session-fork.d.ts +34 -0
  315. package/dist/plugins/session-fork.js +29 -0
  316. package/dist/plugins/session-ownership.js +1 -1
  317. package/dist/plugins/session-placement.d.ts +1 -1
  318. package/dist/plugins/session-policy-store-sql.d.ts +12 -12
  319. package/dist/plugins/session-store.d.ts +2 -2
  320. package/dist/plugins/session-store.js +2 -2
  321. package/dist/plugins/shared-memory-store-sql.d.ts +2 -2
  322. package/dist/plugins/sql-driver.d.ts +8 -8
  323. package/dist/plugins/sql-errors.d.ts +1 -1
  324. package/dist/plugins/sql-json-column.d.ts +21 -21
  325. package/dist/plugins/sql-row-helpers.d.ts +2 -2
  326. package/dist/plugins/store-backend.d.ts +17 -16
  327. package/dist/plugins/store-backend.js +3 -3
  328. package/dist/plugins/store-contracts.d.ts +21 -21
  329. package/dist/plugins/task-attachment-store.d.ts +2 -2
  330. package/dist/plugins/task-list-store-sql.d.ts +1 -1
  331. package/dist/plugins/tidb-pool.d.ts +2 -2
  332. package/dist/plugins/tidb-pool.js +9 -2
  333. package/dist/plugins/tidb-session-store.d.ts +16 -26
  334. package/dist/plugins/tidb-session-store.js +15 -27
  335. package/dist/plugins/tool-result-store-sql.d.ts +1 -1
  336. package/dist/plugins/usage-window-store-sql.d.ts +3 -3
  337. package/dist/plugins/user-input-ledger-file.d.ts +1 -1
  338. package/dist/plugins/user-input-ledger-sql.d.ts +3 -3
  339. package/dist/plugins/web-search.d.ts +19 -5
  340. package/dist/plugins/web-search.js +19 -4
  341. package/dist/{orchestration/workflow-journal-entry.d.ts → plugins/workflow-journal-payload.d.ts} +23 -32
  342. package/dist/plugins/workflow-journal-payload.js +32 -0
  343. package/dist/plugins/workflow-journal-store-sql.d.ts +28 -14
  344. package/dist/plugins/workflow-journal-store-sql.js +34 -15
  345. package/dist/plugins/workflow-run-store-sql.d.ts +4 -4
  346. package/dist/posture-source.d.ts +11 -11
  347. package/dist/principal-jwt.d.ts +6 -6
  348. package/dist/project-identity.d.ts +3 -3
  349. package/dist/project-memory.d.ts +4 -4
  350. package/dist/read-face-posture.d.ts +7 -7
  351. package/dist/request-key-closure.d.ts +1 -1
  352. package/dist/request-key-closure.js +1 -1
  353. package/dist/request-value-closure.d.ts +15 -8
  354. package/dist/request-value-closure.js +2 -0
  355. package/dist/router/route-orchestration.d.ts +11 -16
  356. package/dist/router/route-orchestration.js +2 -12
  357. package/dist/rule-entry-list.d.ts +8 -7
  358. package/dist/rule-entry-list.js +2 -9
  359. package/dist/rules-consent.d.ts +6 -6
  360. package/dist/rules-consent.js +2 -0
  361. package/dist/run-cancel-context.d.ts +5 -5
  362. package/dist/run-local.d.ts +10 -10
  363. package/dist/runs.d.ts +13 -11
  364. package/dist/runs.js +15 -1
  365. package/dist/runtime-caps-resolver.d.ts +6 -6
  366. package/dist/runtime-governance.d.ts +9 -9
  367. package/dist/sandbox-pkg-source.d.ts +9 -31
  368. package/dist/sandbox-pkg-source.js +14 -8
  369. package/dist/sealed-key.d.ts +3 -3
  370. package/dist/security.d.ts +23 -26
  371. package/dist/security.js +12 -9
  372. package/dist/server-secret-env.d.ts +10 -10
  373. package/dist/session-children-retire.d.ts +1 -1
  374. package/dist/session-error-wire.d.ts +7 -7
  375. package/dist/session-incarnation.d.ts +52 -35
  376. package/dist/session-incarnation.js +23 -8
  377. package/dist/session-policy-wire.d.ts +27 -5
  378. package/dist/session-policy-wire.js +15 -1
  379. package/dist/session-records-skipped-notice.d.ts +1 -1
  380. package/dist/session-sync-kernel.d.ts +4 -4
  381. package/dist/session-sync.d.ts +49 -6
  382. package/dist/session-sync.js +52 -10
  383. package/dist/session-titler.d.ts +7 -6
  384. package/dist/session-titler.js +8 -13
  385. package/dist/session-watch.d.ts +3 -3
  386. package/dist/session-watch.js +4 -4
  387. package/dist/sighup-idle.d.ts +2 -2
  388. package/dist/spec-fields.d.ts +4 -4
  389. package/dist/sql-engine-posture.d.ts +3 -3
  390. package/dist/store-posture.d.ts +2 -2
  391. package/dist/stored-request-tool-axes-m19.d.ts +1 -1
  392. package/dist/task-a2a.d.ts +3 -1
  393. package/dist/task-a2a.js +34 -2
  394. package/dist/task-cwd.d.ts +7 -88
  395. package/dist/task-cwd.js +2 -15
  396. package/dist/task-mcp.d.ts +12 -8
  397. package/dist/task-mcp.js +19 -4
  398. package/dist/task-settings.d.ts +30 -18
  399. package/dist/task-settings.js +33 -3
  400. package/dist/task-workflow.d.ts +0 -24
  401. package/dist/task-workflow.js +2 -1
  402. package/dist/terminal.d.ts +5 -5
  403. package/dist/tighten-only-seats.d.ts +7 -6
  404. package/dist/tighten-only-seats.js +1 -1
  405. package/dist/tool-approval.d.ts +143 -197
  406. package/dist/tool-approval.js +13 -28
  407. package/dist/tool-rule-names.d.ts +2 -2
  408. package/dist/trace/core-keyset-guard.d.ts +12 -7
  409. package/dist/trace/engine-notice-wire.d.ts +5 -5
  410. package/dist/trace/engine-notice-wire.js +1 -0
  411. package/dist/trace/exit-seat.d.ts +31 -4
  412. package/dist/trace/exit-seat.js +41 -63
  413. package/dist/trace/ledger-events.d.ts +3 -3
  414. package/dist/trace/ledger-sink.d.ts +1 -1
  415. package/dist/trace/model-segment.d.ts +3 -3
  416. package/dist/trace/project.d.ts +47 -45
  417. package/dist/trace/project.js +33 -1
  418. package/dist/trace/redact.d.ts +44 -30
  419. package/dist/trace/redact.js +191 -89
  420. package/dist/trace/self-minted-wire.d.ts +35 -14
  421. package/dist/trace/self-minted-wire.js +8 -0
  422. package/dist/trace/sema-provenance.d.ts +1 -1
  423. package/dist/trace/task-notification-facets.d.ts +4 -4
  424. package/dist/trace/wire-projection-faces.d.ts +3 -3
  425. package/dist/trace/wire-projection-faces.js +1 -1
  426. package/dist/unattended-permission-mode.d.ts +5 -5
  427. package/dist/url-credential.d.ts +52 -0
  428. package/dist/url-credential.js +49 -0
  429. package/dist/url-refusal.d.ts +6 -2
  430. package/dist/url-refusal.js +8 -1
  431. package/dist/usage-analytics.d.ts +2 -2
  432. package/dist/user-input-ledger.d.ts +23 -23
  433. package/dist/web-admin-client/apply-effective.d.ts +5 -5
  434. package/dist/web-admin-client/apply-effective.js +2 -1
  435. package/dist/web-admin-client/apply-ledger.d.ts +2 -2
  436. package/dist/web-admin-client/center-request.d.ts +2 -2
  437. package/dist/web-admin-client/facade.d.ts +5 -5
  438. package/dist/web-admin-client/facade.js +1 -1
  439. package/dist/web-admin-client/hot-keys-registry.d.ts +2 -2
  440. package/dist/web-admin-client/http-client.d.ts +4 -4
  441. package/dist/web-admin-client/mcp-revocation.d.ts +1 -1
  442. package/dist/web-admin-client/pull-state.d.ts +1 -1
  443. package/dist/web-admin-client/read-face.d.ts +2 -2
  444. package/dist/web-admin-client/read-warnings.d.ts +5 -5
  445. package/dist/web-admin-client/restart-signal.d.ts +6 -6
  446. package/dist/web-admin-client/skills-mcp.d.ts +28 -3
  447. package/dist/web-admin-client/skills-mcp.js +29 -1
  448. package/dist/web-admin-client/types.d.ts +16 -9
  449. package/dist/workspace-space.d.ts +5 -3
  450. package/dist/write-protection.d.ts +2 -2
  451. package/package.json +4 -3
  452. package/scripts/drain-check-local.mjs +2 -1
  453. package/scripts/drain-check.mysql.sql +4 -2
  454. package/scripts/drain-check.pg.sql +4 -2
  455. package/skills/loop.md +1 -1
  456. package/dist/http/run-declared-families.d.ts +0 -16
  457. package/dist/http/run-declared-families.js +0 -12
  458. package/dist/orchestration/workflow-journal-entry.js +0 -27
@@ -1,5 +1,5 @@
1
1
  import { displayUrlOf, stripFormatCharacters } from "@sema-agent/core";
2
- import { isHierarchicalUrl } from "@sema-agent/settings-schema";
2
+ import { CONTROL_AND_BIDI_CHARS, isHierarchicalUrl } from "@sema-agent/settings-schema";
3
3
  import { recordFailOpen } from "../observability/fail-open.js";
4
4
  const normalizeForRedaction = stripFormatCharacters;
5
5
  export function mapNormalizedToOriginal(text, normalized) {
@@ -28,43 +28,91 @@ export function mapNormalizedToOriginal(text, normalized) {
28
28
  map[normalized.length] = text.length;
29
29
  return map;
30
30
  }
31
- function deleteSpelledFormatCharacters(s) {
31
+ const SPELLED_FORMAT = 1, SPELLED_CONTROL = 2, RAW_CONTROL = 4, RAW_WHITESPACE = 8;
32
+ const INVISIBLE_UNIT_CLASS = (() => {
33
+ const inSet = new RegExp(`[${CONTROL_AND_BIDI_CHARS}]`);
34
+ const table = new Uint8Array(0x10000);
35
+ for (let unit = 0; unit < table.length; unit++) {
36
+ const ch = String.fromCharCode(unit);
37
+ if (inSet.test(ch))
38
+ table[unit] = /\s/.test(ch) ? 2 : 1;
39
+ }
40
+ return table;
41
+ })();
42
+ const RAW_STRIP_SET_RE = (() => {
43
+ let body = "";
44
+ for (let unit = 0; unit < 0x10000; unit++) {
45
+ if (INVISIBLE_UNIT_CLASS[unit] === 0)
46
+ continue;
47
+ let last = unit;
48
+ while (last + 1 < 0x10000 && INVISIBLE_UNIT_CLASS[last + 1] !== 0)
49
+ last += 1;
50
+ const hex = (u) => `\\u${u.toString(16).padStart(4, "0")}`;
51
+ body += last === unit ? hex(unit) : `${hex(unit)}-${hex(last)}`;
52
+ unit = last;
53
+ }
54
+ return new RegExp(`[${body}]`, "g");
55
+ })();
56
+ function collectRawControlCuts(s, allowed) {
57
+ const cuts = [];
58
+ let present = 0;
59
+ if ((allowed & (RAW_CONTROL | RAW_WHITESPACE)) === 0)
60
+ return { cuts, present };
61
+ RAW_STRIP_SET_RE.lastIndex = 0;
62
+ for (let m = RAW_STRIP_SET_RE.exec(s); m !== null; m = RAW_STRIP_SET_RE.exec(s)) {
63
+ const cls = INVISIBLE_UNIT_CLASS[s.charCodeAt(m.index)] === 2 ? RAW_WHITESPACE : RAW_CONTROL;
64
+ if ((cls & allowed) === 0)
65
+ continue;
66
+ cuts.push(m.index, m.index + 1, cls);
67
+ present |= cls;
68
+ }
69
+ return { cuts, present };
70
+ }
71
+ function collectSpelledCuts(s) {
72
+ const cuts = [];
73
+ let present = 0;
32
74
  let i = s.indexOf("\\");
33
75
  if (i < 0)
34
- return { text: s, at: undefined, cum: undefined };
76
+ return { cuts, present };
35
77
  const n = s.length;
36
78
  const read = { end: 0 };
37
- let cuts;
38
79
  while (i >= 0) {
39
80
  let body = i + 1;
40
81
  while (body < n && s.charCodeAt(body) === CH_BACKSLASH)
41
82
  body += 1;
42
83
  const cp = readSpelledCodePoint(s, body, read);
43
- if (cp >= 0 && isFormatCodePoint(cp)) {
44
- (cuts ??= []).push(i, read.end);
84
+ const cls = cp < 0 ? 0 : isFormatCodePoint(cp) ? SPELLED_FORMAT : cp < 0x10000 && INVISIBLE_UNIT_CLASS[cp] === 1 ? SPELLED_CONTROL : 0;
85
+ if (cls !== 0) {
86
+ cuts.push(i, read.end, cls);
87
+ present |= cls;
45
88
  body = read.end;
46
89
  }
47
90
  i = s.indexOf("\\", body);
48
91
  }
49
- if (cuts === undefined)
50
- return { text: s, at: undefined, cum: undefined };
51
- const count = cuts.length / 2;
52
- const at = new Int32Array(count);
53
- const cum = new Int32Array(count);
92
+ return { cuts, present };
93
+ }
94
+ function deleteInvisibleCharacters(s, all, mask) {
95
+ const atList = [];
96
+ const cumList = [];
54
97
  const parts = [];
55
98
  let from = 0;
56
99
  let removed = 0;
57
- for (let k = 0; k < count; k++) {
58
- const a = cuts[2 * k];
59
- const b = cuts[2 * k + 1];
100
+ const { cuts } = all;
101
+ for (let k = 0; k < cuts.length; k += 3) {
102
+ if ((cuts[k + 2] & mask) === 0)
103
+ continue;
104
+ const a = cuts[k];
105
+ const b = cuts[k + 1];
60
106
  parts.push(s.slice(from, a));
61
- at[k] = a - removed;
107
+ atList.push(a - removed);
62
108
  removed += b - a;
63
- cum[k] = removed;
109
+ cumList.push(removed);
64
110
  from = b;
65
111
  }
112
+ if (atList.length === 0)
113
+ return { text: s, at: undefined, cum: undefined };
66
114
  parts.push(s.slice(from));
67
- return { text: parts.join(""), at, cum };
115
+ return { text: parts.join(""), at: Int32Array.from(atList), cum: Int32Array.from(cumList) };
68
116
  }
69
117
  function viewIndexInInput(fold, v) {
70
118
  const at = fold.at;
@@ -413,8 +461,9 @@ let urlSegmentRuns = 0;
413
461
  let urlSegmentReplays = 0;
414
462
  let ssh2ScanBytes = 0;
415
463
  let mappedUnits = 0;
464
+ let readings = 0;
416
465
  export function armPoolBudgetForTest() {
417
- return { spanCount: poolSpanCount, coveredPositions, headScreenHits, fullYCalls, armCount: poolArmCount, boundaryArmCount: poolBoundaryArmCount, forensicLevels, forensicRuns, forensicSkips, urlSegmentRuns, urlSegmentReplays, ssh2ScanBytes, mappedUnits };
466
+ return { spanCount: poolSpanCount, coveredPositions, headScreenHits, fullYCalls, armCount: poolArmCount, boundaryArmCount: poolBoundaryArmCount, forensicLevels, forensicRuns, forensicSkips, urlSegmentRuns, urlSegmentReplays, ssh2ScanBytes, mappedUnits, readings };
418
467
  }
419
468
  export function resetArmPoolBudgetForTest() {
420
469
  poolSpanCount = 0;
@@ -428,6 +477,7 @@ export function resetArmPoolBudgetForTest() {
428
477
  urlSegmentReplays = 0;
429
478
  ssh2ScanBytes = 0;
430
479
  mappedUnits = 0;
480
+ readings = 0;
431
481
  }
432
482
  const unitBit = (t, c) => (t[c >>> 5] >>> (c & 31)) & 1;
433
483
  let codeUnitDomain;
@@ -794,6 +844,12 @@ const CREDENTIAL_NAME_ALT = (() => {
794
844
  }
795
845
  return [...CREDENTIAL_NAME_WORDS].sort((a, b) => b.length - a.length || (a < b ? -1 : 1)).join("|");
796
846
  })();
847
+ const CREDENTIAL_NAME_MAX = Math.max(...CREDENTIAL_NAME_WORDS.map((w) => w.length));
848
+ const asciiLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());
849
+ function credentialNameAnchor(name) {
850
+ return CREDENTIAL_ANCHOR_OF.get(asciiLower(name));
851
+ }
852
+ const CREDENTIAL_ANCHOR_OF = new Map(Object.entries(CREDENTIAL_NAME_ANCHORS));
797
853
  const STRUCTURAL_SECRET_PATTERNS = [
798
854
  [/-----BEGIN(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,8192}?-----END(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----/g, "«redacted:private-key»"],
799
855
  [/---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----[\s\S]{0,8192}?---- END SSH2 ENCRYPTED PRIVATE KEY ----/g, "«redacted:private-key»"],
@@ -1386,9 +1442,11 @@ const isRegexSpace = (c) => c === 32 || (c >= 9 && c <= 13) || c === 0xa0 || c =
1386
1442
  const isLineTerminator = (c) => c === 10 || c === 13 || c === 0x2028 || c === 0x2029;
1387
1443
  const isControlCode = (c) => c < 0x20 || c === 0x7f;
1388
1444
  const TOKEN_UNIT_Y = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
1389
- const CREDENTIAL_PARAM_Y = new RegExp(`(?:${CREDENTIAL_NAME_ALT})=`, "iy");
1390
- const CREDENTIAL_NAME_SET = new Set(CREDENTIAL_NAME_WORDS);
1391
- const CREDENTIAL_NAME_SCAN_MAX = Math.max(...CREDENTIAL_NAME_WORDS.map((w) => w.length)) * 3 + 1;
1445
+ export const CREDENTIAL_PARAM_NAMES = Object.freeze([...CREDENTIAL_NAME_WORDS]);
1446
+ export function isCredentialParamName(decodedName) {
1447
+ return credentialNameAnchor(decodedName) !== undefined;
1448
+ }
1449
+ const CREDENTIAL_NAME_SCAN_MAX = CREDENTIAL_NAME_MAX * 3 + 1;
1392
1450
  function decodeAsciiName(name) {
1393
1451
  let out = "";
1394
1452
  for (let i = 0; i < name.length; i++) {
@@ -1409,9 +1467,6 @@ function decodeAsciiName(name) {
1409
1467
  return out;
1410
1468
  }
1411
1469
  function credentialParamValueStart(text, p) {
1412
- CREDENTIAL_PARAM_Y.lastIndex = p;
1413
- if (CREDENTIAL_PARAM_Y.test(text))
1414
- return CREDENTIAL_PARAM_Y.lastIndex;
1415
1470
  const limit = Math.min(text.length, p + CREDENTIAL_NAME_SCAN_MAX);
1416
1471
  let hasPct = false;
1417
1472
  for (let i = p; i < limit; i++) {
@@ -1420,12 +1475,14 @@ function credentialParamValueStart(text, p) {
1420
1475
  hasPct = true;
1421
1476
  continue;
1422
1477
  }
1423
- if (c !== CH_EQ)
1424
- continue;
1425
- if (!hasPct)
1478
+ if (c === CH_EQ) {
1479
+ if (i === p)
1480
+ return -1;
1481
+ const name = hasPct ? decodeAsciiName(text.slice(p, i)) : text.slice(p, i);
1482
+ return name !== undefined && credentialNameAnchor(name) !== undefined ? i + 1 : -1;
1483
+ }
1484
+ if (!(isAsciiAlnumCode(c) || c === CH_UNDERSCORE || c === CH_MINUS))
1426
1485
  return -1;
1427
- const decoded = decodeAsciiName(text.slice(p, i));
1428
- return decoded !== undefined && CREDENTIAL_NAME_SET.has(decoded.toLowerCase()) ? i + 1 : -1;
1429
1486
  }
1430
1487
  return -1;
1431
1488
  }
@@ -1834,24 +1891,19 @@ function collectUrlCredentialSpans(scan, text, json, span) {
1834
1891
  scan.footHi = armHi;
1835
1892
  }
1836
1893
  const JSON_FIELD_ANCHOR = '"';
1837
- const CREDENTIAL_NAME_MAX = Math.max(...CREDENTIAL_NAME_WORDS.map((w) => w.length));
1838
1894
  function jsonSecretFieldValueQuoteAt(text, p) {
1839
1895
  const n = text.length;
1840
- let name = "";
1841
1896
  let i = p + 1;
1842
1897
  for (; i < n; i++) {
1843
- let c = text.charCodeAt(i);
1898
+ const c = text.charCodeAt(i);
1844
1899
  if (c === CH_QUOTE)
1845
1900
  break;
1846
1901
  if (i - p > CREDENTIAL_NAME_MAX)
1847
1902
  return -1;
1848
- if (c >= CH_A && c <= CH_Z)
1849
- c += 32;
1850
- if (!((c >= CH_a && c <= CH_z) || (c >= CH_0 && c <= CH_9) || c === CH_UNDERSCORE || c === CH_MINUS))
1903
+ if (!(isAsciiAlnumCode(c) || c === CH_UNDERSCORE || c === CH_MINUS))
1851
1904
  return -1;
1852
- name += String.fromCharCode(c);
1853
1905
  }
1854
- if (i >= n || !CREDENTIAL_NAME_SET.has(name))
1906
+ if (i >= n || i === p + 1 || credentialNameAnchor(text.slice(p + 1, i)) === undefined)
1855
1907
  return -1;
1856
1908
  i += 1;
1857
1909
  while (i < n && isRegexSpace(text.charCodeAt(i)))
@@ -1896,7 +1948,6 @@ const STRONG_AUTH_SCHEMES = new Set(["basic", "bearer"]);
1896
1948
  const STRONG_AUTH_SCHEME_MAX = Math.max(...[...STRONG_AUTH_SCHEMES].map((w) => w.length));
1897
1949
  const ABSENT_OR_BOOLEAN_WORDS = new Set(["null", "nil", "none", "undefined", "true", "false", "yes", "no"]);
1898
1950
  const ABSENT_OR_BOOLEAN_MAX = Math.max(...[...ABSENT_OR_BOOLEAN_WORDS].map((w) => w.length));
1899
- const CREDENTIAL_ANCHOR_OF = new Map(Object.entries(CREDENTIAL_NAME_ANCHORS));
1900
1951
  const CH_GRAVE = 96, CH_APOS = 39, CH_DOT = 46, CH_COMMA = 44, CH_SEMI = 59, CH_DOLLAR = 36;
1901
1952
  const CH_LPAREN = 40, CH_RPAREN = 41, CH_RBRACKET = 93, CH_LBRACE = 123, CH_RBRACE = 125, CH_LT = 60, CH_GT = 62;
1902
1953
  const CH_QMARK = 63, CH_AMP = 38, CH_HASH = 35;
@@ -2021,7 +2072,7 @@ function anchorHeadAt(text, op, json) {
2021
2072
  return undefined;
2022
2073
  before = j - openLen;
2023
2074
  }
2024
- const strength = CREDENTIAL_ANCHOR_OF.get(text.slice(nameStart, nameEnd).toLowerCase());
2075
+ const strength = credentialNameAnchor(text.slice(nameStart, nameEnd));
2025
2076
  if (strength === undefined)
2026
2077
  return undefined;
2027
2078
  if (!afterEscape && runStart === j + 1 && quote === 0 && j >= 0 && text.charCodeAt(j) === CH_SLASH)
@@ -2256,7 +2307,7 @@ export function structuralScannerForTest(arm) {
2256
2307
  let ppkScanBytes = 0;
2257
2308
  export function ppkScanBytesForTest() { return ppkScanBytes; }
2258
2309
  export function resetPpkScanBytesForTest() { ppkScanBytes = 0; }
2259
- function collectPpkContainerSpans(scan, text, record, span) {
2310
+ function collectPpkContainerSpans(scan, text, eat, span) {
2260
2311
  const HEAD = "PuTTY-User-Key-File-";
2261
2312
  const MAC = "Private-MAC: ";
2262
2313
  const HASH = "Private-Hash: ";
@@ -2342,8 +2393,10 @@ function collectPpkContainerSpans(scan, text, record, span) {
2342
2393
  end = ateToEnd ? text.length : hexEnd;
2343
2394
  break;
2344
2395
  }
2345
- if (ateToEnd && record)
2346
- recordFailOpen("server.redact.ppk-eat-to-end", `from=${at} len=${text.length}`);
2396
+ if (ateToEnd && eat !== undefined && eat.from < 0) {
2397
+ eat.from = at;
2398
+ eat.len = text.length;
2399
+ }
2347
2400
  span(at, end);
2348
2401
  at = end >= text.length ? Number.POSITIVE_INFINITY : nextVersionedHead(end);
2349
2402
  }
@@ -2376,8 +2429,8 @@ const armPool = (() => {
2376
2429
  phase: 1,
2377
2430
  lexical: LEXICAL_KEYWORD_ARMS.has(re),
2378
2431
  collect: boundary === undefined
2379
- ? (text, _json, _observe, out) => collectRegexSpans(arm, text, out)
2380
- : (text, _json, _observe, out) => collectValueArmSpans(boundary, text, out),
2432
+ ? (text, _json, _eat, out) => collectRegexSpans(arm, text, out)
2433
+ : (text, _json, _eat, out) => collectValueArmSpans(boundary, text, out),
2381
2434
  retry: boundary === undefined ? undefined : (text, at, out) => collectStickySpans(boundary, text, at, out),
2382
2435
  headSrc: boundary === undefined ? undefined : headSrc,
2383
2436
  headFirst: boundary === undefined ? undefined : headFirst,
@@ -2391,7 +2444,7 @@ const armPool = (() => {
2391
2444
  order,
2392
2445
  phase: 1,
2393
2446
  lexical,
2394
- collect: (text, json, observe, out) => arm(text, json, observe, (start, end) => out.push({ start, end, repl, rank, order })),
2447
+ collect: (text, json, eat, out) => arm(text, json, eat, (start, end) => out.push({ start, end, repl, rank, order })),
2395
2448
  retry: undefined,
2396
2449
  headSrc: undefined,
2397
2450
  headFirst: undefined,
@@ -2406,7 +2459,7 @@ const armPool = (() => {
2406
2459
  order,
2407
2460
  phase: 2,
2408
2461
  lexical: false,
2409
- collect: (scan, text, json, observe, out) => arm(scan, text, json, observe, (start, end) => out.push({ start, end, repl, rank, order })),
2462
+ collect: (scan, text, json, eat, out) => arm(scan, text, json, eat, (start, end) => out.push({ start, end, repl, rank, order })),
2410
2463
  retry: undefined,
2411
2464
  headSrc: undefined,
2412
2465
  headFirst: undefined,
@@ -2414,22 +2467,22 @@ const armPool = (() => {
2414
2467
  };
2415
2468
  const structuralScannerMember = (row, order) => {
2416
2469
  if (row === PEM_FENCE_PATTERN)
2417
- return scannerMember(row[1], order, (text, _json, _observe, span) => collectPemFenceSpans(text, span));
2470
+ return scannerMember(row[1], order, (text, _json, _eat, span) => collectPemFenceSpans(text, span));
2418
2471
  if (row === SSH2_FENCE_PATTERN)
2419
- return forensicMember(row[1], order, (scan, text, _json, _observe, span) => collectSsh2FenceSpans(scan, text, span));
2472
+ return forensicMember(row[1], order, (scan, text, _json, _eat, span) => collectSsh2FenceSpans(scan, text, span));
2420
2473
  if (row === URL_CREDENTIAL_PATTERN)
2421
- return forensicMember(row[1], order, (scan, text, json, _observe, span) => collectUrlCredentialSpans(scan, text, json, span));
2474
+ return forensicMember(row[1], order, (scan, text, json, _eat, span) => collectUrlCredentialSpans(scan, text, json, span));
2422
2475
  if (row === JSON_SECRET_FIELD_PATTERN)
2423
- return scannerMember(row[1], order, (text, _json, _observe, span) => collectJsonSecretFieldSpans(text, span));
2476
+ return scannerMember(row[1], order, (text, _json, _eat, span) => collectJsonSecretFieldSpans(text, span));
2424
2477
  throw new Error(`redact: structural row /${row[0].source}/ has no hand-written scanner — structural grammars are declared as regexes but never executed as one (S-102 / S-265)`);
2425
2478
  };
2426
2479
  const members = [];
2427
2480
  for (const row of STRUCTURAL_SECRET_PATTERNS)
2428
2481
  members.push(structuralScannerMember(row, members.length));
2429
- members.push(forensicMember(PPK_CONTAINER_TOKEN, members.length, (scan, text, _json, observe, span) => collectPpkContainerSpans(scan, text, observe, span)));
2430
- members.push(forensicMember(PEM_FRAGMENT_TOKEN, members.length, (scan, text, json, _observe, span) => collectPemFragmentSpans(scan, text, json, span)));
2431
- members.push(forensicMember(HEADLESS_PPK_TOKEN, members.length, (scan, text, _json, _observe, span) => collectHeadlessPpkSpans(scan, text, span)));
2432
- members.push(scannerMember(ANCHORED_VALUE_TOKEN, members.length, (text, json, _observe, span) => collectAnchoredValueSpans(text, json, span), ARM_RANK.keyword, true));
2482
+ members.push(forensicMember(PPK_CONTAINER_TOKEN, members.length, (scan, text, _json, eat, span) => collectPpkContainerSpans(scan, text, eat, span)));
2483
+ members.push(forensicMember(PEM_FRAGMENT_TOKEN, members.length, (scan, text, json, _eat, span) => collectPemFragmentSpans(scan, text, json, span)));
2484
+ members.push(forensicMember(HEADLESS_PPK_TOKEN, members.length, (scan, text, _json, _eat, span) => collectHeadlessPpkSpans(scan, text, span)));
2485
+ members.push(scannerMember(ANCHORED_VALUE_TOKEN, members.length, (text, json, _eat, span) => collectAnchoredValueSpans(text, json, span), ARM_RANK.keyword, true));
2433
2486
  for (const row of KEYWORD_SECRET_PATTERNS)
2434
2487
  members.push(regexMember(row, ARM_RANK.keyword, members.length));
2435
2488
  for (const row of SHAPE_SECRET_PATTERNS)
@@ -2460,7 +2513,8 @@ const armPool = (() => {
2460
2513
  const headFirstUnit = unionMembers(retryMembers.map((m) => m.headFirst)) ?? new Uint32Array(0x10000 >>> 5).fill(0xffffffff);
2461
2514
  poolArmCount = members.length;
2462
2515
  poolBoundaryArmCount = retryMembers.length;
2463
- return (text, wantCount, json, observe, scope) => {
2516
+ return (text, wantCount, json, eat, scope) => {
2517
+ readings += 1;
2464
2518
  const lane = LANES[scope];
2465
2519
  const spans = [];
2466
2520
  let tried;
@@ -2496,7 +2550,7 @@ const armPool = (() => {
2496
2550
  }
2497
2551
  };
2498
2552
  for (const m of lane.phase1)
2499
- m.collect(text, json, observe, spans);
2553
+ m.collect(text, json, eat, spans);
2500
2554
  closeCoveragePositions(0);
2501
2555
  if (lane.phase2.length > 0) {
2502
2556
  const scan = buildForensicScan(credentialSpans(text), lane.phase2.length);
@@ -2513,7 +2567,7 @@ const armPool = (() => {
2513
2567
  }
2514
2568
  scan.footLo = FOOT_NONE;
2515
2569
  scan.footHi = -1;
2516
- lane.phase2[j].collect(scan, text, json, observe && level === 0, spans);
2570
+ lane.phase2[j].collect(scan, text, json, level === 0 ? eat : undefined, spans);
2517
2571
  foot[2 * j] = scan.footLo;
2518
2572
  foot[2 * j + 1] = scan.footHi;
2519
2573
  forensicRuns += 1;
@@ -2559,8 +2613,8 @@ let onRedaction;
2559
2613
  export function setRedactionObserver(fn) {
2560
2614
  onRedaction = fn;
2561
2615
  }
2562
- function applyRules(text, wantCount, json, observe, scope) {
2563
- return armPool(text, wantCount, json, observe, scope);
2616
+ function applyRules(text, wantCount, json, eat, scope) {
2617
+ return armPool(text, wantCount, json, eat, scope);
2564
2618
  }
2565
2619
  function reportHits(hits) {
2566
2620
  if (onRedaction === undefined)
@@ -2573,24 +2627,59 @@ function reportHits(hits) {
2573
2627
  }
2574
2628
  }
2575
2629
  }
2576
- function runRedaction(text, observe, json, wantHits, scope, muteCount = false) {
2577
- const wantCount = wantHits || (onRedaction !== undefined && observe && !muteCount);
2578
- const normalized = normalizeForRedaction(text);
2579
- const first = applyRules(normalized, wantCount, json, observe, scope);
2580
- forgetEscapedSeparatorTails();
2581
- let spans = spansInOriginal(text, normalized, undefined, first.kept);
2582
- let hits = first.hits;
2583
- const second = deleteSpelledFormatCharacters(normalized);
2584
- if (second.at !== undefined) {
2585
- const r2 = applyRules(second.text, wantCount, json, false, scope);
2630
+ function invisibleClassesOf(layout) {
2631
+ switch (layout) {
2632
+ case "multi-line":
2633
+ return SPELLED_FORMAT | SPELLED_CONTROL | RAW_CONTROL;
2634
+ case "single-line":
2635
+ return SPELLED_FORMAT | SPELLED_CONTROL | RAW_CONTROL | RAW_WHITESPACE;
2636
+ default: {
2637
+ const unhandled = layout;
2638
+ throw new Error(`redact: unhandled layout ${String(unhandled)}`);
2639
+ }
2640
+ }
2641
+ }
2642
+ function runRedaction(text, observe, json, wantHits, scope, layout) {
2643
+ const wantCount = wantHits || (onRedaction !== undefined && observe);
2644
+ const eat = observe ? { from: -1, len: 0 } : undefined;
2645
+ let spans = [];
2646
+ let hits = NO_HITS;
2647
+ let readsSoFar = 0;
2648
+ let unioned = false;
2649
+ const read = (layers, view) => {
2650
+ const r = applyRules(view, wantCount, json, eat, scope);
2586
2651
  forgetEscapedSeparatorTails();
2587
- const extra = spansInOriginal(text, normalized, second, r2.kept);
2588
- if (extra.length > 0) {
2589
- spans = resolveSpanOverlaps([...spans, ...extra]);
2590
- hits = wantCount ? hitsOfSpans(spans) : NO_HITS;
2652
+ readsSoFar += 1;
2653
+ if (readsSoFar === 1) {
2654
+ spans = spansInOriginal(layers, r.kept);
2655
+ hits = r.hits;
2656
+ return;
2591
2657
  }
2658
+ const extra = spansInOriginal(layers, r.kept);
2659
+ if (extra.length === 0)
2660
+ return;
2661
+ spans = resolveSpanOverlaps([...spans, ...extra]);
2662
+ unioned = true;
2663
+ };
2664
+ const raw = collectRawControlCuts(text, invisibleClassesOf(layout));
2665
+ for (let rmask = 0;; rmask = (rmask - raw.present) & raw.present) {
2666
+ const rfold = deleteInvisibleCharacters(text, raw, rmask);
2667
+ const normalized = normalizeForRedaction(rfold.text);
2668
+ const spelled = collectSpelledCuts(normalized);
2669
+ for (let smask = 0;; smask = (smask - spelled.present) & spelled.present) {
2670
+ const sfold = deleteInvisibleCharacters(normalized, spelled, smask);
2671
+ read([{ fold: sfold }, { input: rfold.text, view: normalized }, { fold: rfold }], sfold.text);
2672
+ if (smask === spelled.present)
2673
+ break;
2674
+ }
2675
+ if (rmask === raw.present)
2676
+ break;
2592
2677
  }
2593
- if (observe && !muteCount)
2678
+ if (unioned && wantCount)
2679
+ hits = hitsOfSpans(spans);
2680
+ if (eat !== undefined && eat.from >= 0)
2681
+ recordFailOpen("server.redact.ppk-eat-to-end", `from=${eat.from} len=${eat.len}`);
2682
+ if (observe)
2594
2683
  reportHits(hits);
2595
2684
  return { text: applySpans(text, spans).out, hits, spans };
2596
2685
  }
@@ -2608,28 +2697,41 @@ function hitsOfSpans(spans) {
2608
2697
  }
2609
2698
  return [...by.values()].map(({ token, arm, count }) => ({ label: labelOfToken(token), count, arm }));
2610
2699
  }
2611
- function spansInOriginal(text, normalized, fold, kept) {
2612
- if (kept.length === 0)
2613
- return kept;
2614
- const inNormalized = fold?.at === undefined ? kept : kept.map((s) => ({ ...s, start: viewIndexInInput(fold, s.start), end: viewIndexInInput(fold, s.end - 1) + 1 }));
2615
- if (normalized === text)
2616
- return inNormalized;
2617
- const map = mapNormalizedToOriginal(text, normalized);
2618
- return inNormalized.map((s) => ({ ...s, start: map[s.start], end: map[s.end - 1] + 1 }));
2700
+ function spansInOriginal(layers, kept) {
2701
+ let out = kept;
2702
+ for (const layer of layers) {
2703
+ if (out.length === 0)
2704
+ return out;
2705
+ let at;
2706
+ if ("fold" in layer) {
2707
+ const fold = layer.fold;
2708
+ if (fold.at === undefined)
2709
+ continue;
2710
+ at = (v) => viewIndexInInput(fold, v);
2711
+ }
2712
+ else {
2713
+ if (layer.view === layer.input)
2714
+ continue;
2715
+ const map = mapNormalizedToOriginal(layer.input, layer.view);
2716
+ at = (v) => map[v];
2717
+ }
2718
+ out = out.map((s) => ({ ...s, start: at(s.start), end: at(s.end - 1) + 1 }));
2719
+ }
2720
+ return out;
2619
2721
  }
2620
2722
  export function redactSecrets(text, opts) {
2621
- return runRedaction(text, opts?.observe ?? true, opts?.json === true, false, "free-text").text;
2723
+ return runRedaction(text, opts?.observe ?? true, opts?.json === true, false, "free-text", "multi-line").text;
2622
2724
  }
2623
2725
  export function redactSecretsWithArms(text, opts) {
2624
- const r = runRedaction(text, opts?.observe ?? true, opts?.json === true, true, "free-text");
2726
+ const r = runRedaction(text, opts?.observe ?? true, opts?.json === true, true, "free-text", "multi-line");
2625
2727
  return { text: r.text, arms: new Set(r.hits.map((h) => h.arm)) };
2626
2728
  }
2627
2729
  export function redactionSpansForTest(text, opts) {
2628
- const r = runRedaction(text, false, opts?.json === true, false, "free-text");
2730
+ const r = runRedaction(text, false, opts?.json === true, false, "free-text", "multi-line");
2629
2731
  return { text: r.text, spans: r.spans.map((sp) => ({ start: sp.start, end: sp.end })) };
2630
2732
  }
2631
- export function proposeRedactionSpans(text, scope, opts) {
2632
- return runRedaction(text, true, false, false, scope, opts?.countHits === false).spans.map((sp) => ({ start: sp.start, end: sp.end, repl: sp.repl }));
2733
+ export function proposeRedactionSpans(text, scope, layout) {
2734
+ return runRedaction(text, true, false, false, scope, layout).spans.map((sp) => ({ start: sp.start, end: sp.end, repl: sp.repl }));
2633
2735
  }
2634
2736
  const REDACT_MAX_DEPTH = 64;
2635
2737
  export function redactDeep(value) {
@@ -2731,7 +2833,7 @@ function unitCarriesCredential(unit) {
2731
2833
  for (const v of armValueClassViews())
2732
2834
  views.add(boundedUnitView(spelling, v.inClass, v.filler));
2733
2835
  views.delete("");
2734
- const hit = [...views].some((view) => runRedaction(view, true, false, false, "bounded-unit").text !== view);
2836
+ const hit = [...views].some((view) => runRedaction(view, true, false, false, "bounded-unit", "multi-line").text !== view);
2735
2837
  return { hit, unreadable: decoded.residue };
2736
2838
  }
2737
2839
  function displaySafePathname(pathname) {
@@ -2761,7 +2863,7 @@ function shapeLawCredentialInQueryOrFragment(canonical) {
2761
2863
  const boundary = canonical.indexOf("?");
2762
2864
  if (boundary < 0)
2763
2865
  return false;
2764
- if (runRedaction(canonical, false, false, false, "free-text").spans.some((sp) => sp.end > boundary))
2866
+ if (runRedaction(canonical, false, false, false, "free-text", "multi-line").spans.some((sp) => sp.end > boundary))
2765
2867
  return true;
2766
2868
  for (const unit of canonical.slice(boundary + 1).split("&").flatMap((sg) => {
2767
2869
  const eq = sg.indexOf("=");
@@ -8,7 +8,7 @@ export interface SelfMintedRetiredMember extends SelfMintedWireMember {
8
8
  readonly until: string;
9
9
  }
10
10
  export declare const SELF_MINTED_WIRE: {
11
- /** [ref](7.55.0)起的终态成因注;S-929(7.108.0)+`shutdown_before_park`。 */
11
+ /** [ref](7.55.0)起的终态成因注;[ref](7.108.0)+`shutdown_before_park`。 */
12
12
  readonly crashConvergedCause: {
13
13
  readonly at: "GET /v1/approvals crashConverged[].cause";
14
14
  readonly members: {
@@ -23,7 +23,7 @@ export declare const SELF_MINTED_WIRE: {
23
23
  };
24
24
  };
25
25
  /**
26
- * S-928(7.110.0):`engine_notice` `task.user_steer_undrained` 上**本仓铸**的那一臂。词表属主是 core(`USER_INPUT_UNDRAINED_CAUSES`,两族共用;
26
+ * [ref](7.110.0):`engine_notice` `task.user_steer_undrained` 上**本仓铸**的那一臂。词表属主是 core(`USER_INPUT_UNDRAINED_CAUSES`,两族共用;
27
27
  * `leg_end` 由引擎铸、逐字过境,不在本表);本表登记的是「这个值自哪一版起由本服务出现在 wire 上」。`satisfies Record<CrashedCause, …>`:
28
28
  * core 删掉 `crashed` ⇒ `CrashedCause` 成 never ⇒ 本行编译红。码按受理时的车道选(`user-input-ledger.ts` `acceptedInputKindOf`,车道 = core `injectionLaneOf`,码 = core `USER_INPUT_UNDRAINED_FAMILIES`):本行 = steer 车道。
29
29
  */
@@ -36,7 +36,7 @@ export declare const SELF_MINTED_WIRE: {
36
36
  };
37
37
  };
38
38
  };
39
- /** S-1122(7.118.0,core 7.44.0 #1362):同一臂在 follow-up 车道(`later` 档)上的那一族。7.110.0–7.117.x 的这类丢失报在 steer 一族里。 */
39
+ /** [ref](7.118.0,core 7.44.0 [ref]):同一臂在 follow-up 车道(`later` 档)上的那一族。7.110.0–7.117.x 的这类丢失报在 steer 一族里。 */
40
40
  readonly userFollowupUndrainedServerCause: {
41
41
  readonly at: "engine_notice task.user_followup_undrained detail.cause(本服务铸的臂;`later` 档受理的崩溃丢失,下一条同会话 run 开通告口那一拍)";
42
42
  readonly members: {
@@ -47,7 +47,7 @@ export declare const SELF_MINTED_WIRE: {
47
47
  };
48
48
  };
49
49
  /**
50
- * S-961(7.111.0):`wiring_manifest.instructions.selected[]` 的成员值 = 指令文件链的成员(相对 cwd 的拼写)。属主是 `project-memory.ts`
50
+ * [ref](7.111.0):`wiring_manifest.instructions.selected[]` 的成员值 = 指令文件链的成员(相对 cwd 的拼写)。属主是 `project-memory.ts`
51
51
  * 的 `INSTRUCTION_FILE_CHAIN`([ref] 序:CLAUDE 族先、AGENTS 族后,首中即选)—— 链加 / 删一员 ⇒ 本行 `satisfies` 编译红,登记跟着动。
52
52
  * 段本身(键)登记在 `wire-projection-faces.ts` 的 `wiring_manifest_tenant.minted`。
53
53
  */
@@ -73,7 +73,7 @@ export declare const SELF_MINTED_WIRE: {
73
73
  };
74
74
  };
75
75
  /**
76
- * S-947(7.112.0):server 发起的中止在取消终局上留下的机读成因 —— `PersistedTaskResult.abortCause`,与 `cancelContext` 同住、同铸点、
76
+ * [ref](7.112.0):server 发起的中止在取消终局上留下的机读成因 —— `PersistedTaskResult.abortCause`,与 `cancelContext` 同住、同铸点、
77
77
  * 同在场闸(在场 ⇔ 这条终局就是 server 那次中止铸出来的取消终局)。逐词站点见契约 §5.0d。键本身是 run 结果上的 server 侧记键
78
78
  * (`store-contracts.ts` 的 `PersistedResultSideKeys`),不是事件投影面的键 ⇒ 不在 `wire-projection-faces.ts`。
79
79
  */
@@ -95,7 +95,7 @@ export declare const SELF_MINTED_WIRE: {
95
95
  };
96
96
  };
97
97
  /**
98
- * 会话所有者自助抹除面的**已分类拒** → HTTP 状态(S-930 起与 operator 面 `POST /v1/memory/erase` 同一只映射;`since` 记的是**本面**
98
+ * 会话所有者自助抹除面的**已分类拒** → HTTP 状态([ref] 起与 operator 面 `POST /v1/memory/erase` 同一只映射;`since` 记的是**本面**
99
99
  * 自哪一版起这样答 —— 7.107.0 及以前本面只认前两只,其余落 500 `internal.error`)。
100
100
  */
101
101
  readonly sessionMemoryEraseStatus: {
@@ -492,7 +492,7 @@ export declare const SELF_MINTED_WIRE: {
492
492
  };
493
493
  };
494
494
  /**
495
- * S-667(7.133.0):`GET /health` 的 `centerIdentityNotice.code` —— 中心凭证换人后的两态通告(最近一条)。词表属主 = `center-config-tier.ts` 的
495
+ * [ref](7.133.0):`GET /health` 的 `centerIdentityNotice.code` —— 中心凭证换人后的两态通告(最近一条)。词表属主 = `center-config-tier.ts` 的
496
496
  * `CENTER_IDENTITY_NOTICE_CODES`(`satisfies Record<…>`:加词而本行没跟 / 多一个词 ⇒ tsc 红);冻结句 `CENTER_IDENTITY_NOTICE_MESSAGE` 进
497
497
  * `test/api-notice-text-freeze.test.ts` §8。这两只码不在 core 的 `EngineNotice` 码册里(那是 core 的闭集)—— 它们是本服务自铸的 `/health` 值,契约 §0.4 成文。
498
498
  */
@@ -509,7 +509,7 @@ export declare const SELF_MINTED_WIRE: {
509
509
  };
510
510
  };
511
511
  };
512
- /** S-667(7.133.0):`demoted` 通告上的 `retained[]` —— 降档没能降到底的组(世代账组闭集;`satisfies Record<ConfigApplyGroup, …>`)。 */
512
+ /** [ref](7.133.0):`demoted` 通告上的 `retained[]` —— 降档没能降到底的组(世代账组闭集;`satisfies Record<ConfigApplyGroup, …>`)。 */
513
513
  readonly centerIdentityNoticeRetained: {
514
514
  readonly at: "GET /health centerIdentityNotice.retained[]";
515
515
  readonly members: {
@@ -757,9 +757,25 @@ export declare const SELF_MINTED_WIRE: {
757
757
  };
758
758
  };
759
759
  /**
760
- * S-527(7.133.0):`GET /v1/config/catalog` 行上**对 `effectiveValue` 的判词位**(闭集 `CatalogValueVerdict`,属主 `config-catalog.ts`;行接口经映射型声明,
760
+ * [ref](7.135.0):场景卡技能清单一条的来处(`factory` = 本部署技能目录 · `center` = 配置源交来的)。钉 test/scenario-skills-read-face.test.ts ②。
761
+ */
762
+ readonly scenarioSkillSource: {
763
+ readonly at: "GET /v1/capabilities/scenarios/:name#skills[].source";
764
+ readonly members: {
765
+ factory: {
766
+ attr: string;
767
+ since: string;
768
+ };
769
+ center: {
770
+ attr: string;
771
+ since: string;
772
+ };
773
+ };
774
+ };
775
+ /**
776
+ * [ref](7.133.0):`GET /v1/config/catalog` 行上**对 `effectiveValue` 的判词位**(闭集 `CatalogValueVerdict`,属主 `config-catalog.ts`;行接口经映射型声明,
761
777
  * 每一位只取 `true`)。属性 = 在场律 `present-iff`:只在为真时出键,恒不铸 `false`,缺席 = 没有这件事(老 server 上也缺席 —— 对消费方两者的下一步相同:按值原样渲染)。
762
- * `satisfies Record<CatalogValueVerdict, …>`:判词位加一员而本表没跟 ⇒ 编译红。`effectiveValueInvalid` 自 7.70.0(S-100)在 wire 上、本版补登记;
778
+ * `satisfies Record<CatalogValueVerdict, …>`:判词位加一员而本表没跟 ⇒ 编译红。`effectiveValueInvalid` 自 7.70.0([ref])在 wire 上、本版补登记;
763
779
  * `effectiveValueWithheld`(url 型行:展示铸点扣下了一段)本版新上。
764
780
  */
765
781
  readonly configCatalogValueVerdict: {
@@ -778,8 +794,9 @@ export declare const SELF_MINTED_WIRE: {
778
794
  /**
779
795
  * `GET /v1/models` 应答体的顶层键(闭集;`src/http/routes/capabilities.ts` 的 `sendJson(res, 200, {…})` 字面量)。属性 = 在场律:`always` 恒在场(零条也出键),`present-iff` 条件成立才出键
780
796
  * (缺席不下「无」的结论——也可能是更早的 server)。`since` = 该键上 wire 的起始版本(`models` / `default` / `defaultModel` 在本仓首个 tag 就有)。
781
- * 7.126.0:`candidateRejected`(S-1457,present-iff:当前生效的配置是因判官整拒了最近一份候选而回落的那一份;契约 §A.1d)。
782
- * 7.133.0:`modelPlane`(S-1716,always:服务哪张表 / 最近一份目录候选的结局 / 起服路由判官的判决;契约 §A.1d)。
797
+ * 7.126.0:`candidateRejected`([ref],present-iff:当前生效的配置是因判官整拒了最近一份候选而回落的那一份;契约 §A.1d)。
798
+ * 7.133.0:`modelPlane`([ref],always:服务哪张表 / 最近一份目录候选的结局 / 起服路由判官的判决;契约 §A.1d)。
799
+ * 7.135.0:`aliases`([ref],always:选择面认、`models` 行不列的词 —— 受理口那一张可选目录的划分;契约 §A.1d)。
783
800
  */
784
801
  readonly modelsResponseKey: {
785
802
  readonly at: "GET /v1/models 应答体顶层键(<键> → 在场律)";
@@ -808,18 +825,22 @@ export declare const SELF_MINTED_WIRE: {
808
825
  readonly attr: "always";
809
826
  readonly since: "7.133.0";
810
827
  };
828
+ readonly aliases: {
829
+ readonly attr: "always";
830
+ readonly since: "7.135.0";
831
+ };
811
832
  };
812
833
  };
813
834
  /** 本仓在出口对 core 值做的变换(值变、键不变)。 */
814
835
  readonly wireValueRule: {
815
836
  readonly at: "出口值变换(<端点>#<键> → 变换)";
816
837
  readonly members: {
817
- /** S-105(7.57.0):run 读面的终态错误文案脱敏(钉 test/run-failure-visibility.test.ts)。 */
838
+ /** [ref](7.57.0):run 读面的终态错误文案脱敏(钉 test/run-failure-visibility.test.ts)。 */
818
839
  readonly "GET /v1/runs/:id#result.errorMessage": {
819
840
  readonly attr: "redactErrorMessage";
820
841
  readonly since: "7.57.0";
821
842
  };
822
- /** S-922(7.108.0):side-query 200 体 `errorMessage` 与任务面同一只脱敏口(钉 test/side-query-provider-echo.test.ts)。 */
843
+ /** [ref](7.108.0):side-query 200 体 `errorMessage` 与任务面同一只脱敏口(钉 test/side-query-provider-echo.test.ts)。 */
823
844
  readonly "POST /v1/side-query#errorMessage": {
824
845
  readonly attr: "redactErrorMessage";
825
846
  readonly since: "7.108.0";