@sema-agent/core 7.62.0 → 7.64.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 (320) hide show
  1. package/CHANGELOG.md +936 -0
  2. package/dist/agents/cc-peer-directory.js +1 -0
  3. package/dist/agents/cc-peer-wire.d.ts +4 -0
  4. package/dist/agents/cc-peer-wire.js +1 -0
  5. package/dist/agents/cc-uds-peer-channel.js +5 -0
  6. package/dist/agents/cross-session-judge.d.ts +3 -1
  7. package/dist/agents/cross-session-judge.js +4 -1
  8. package/dist/agents/peer-directory.d.ts +8 -0
  9. package/dist/agents/peer-directory.js +4 -0
  10. package/dist/agents/peer-held-queue.d.ts +9 -3
  11. package/dist/agents/peer-held-queue.js +12 -9
  12. package/dist/agents/peer-idle.d.ts +20 -1
  13. package/dist/agents/peer-idle.js +23 -12
  14. package/dist/agents/peer-notice-route.d.ts +16 -5
  15. package/dist/agents/peer-notice-route.js +11 -9
  16. package/dist/agents/peer-notices.d.ts +25 -8
  17. package/dist/agents/peer-notices.js +6 -1
  18. package/dist/agents/peer-session-drain.d.ts +32 -6
  19. package/dist/agents/peer-session-drain.js +100 -26
  20. package/dist/agents/send-message-tool.d.ts +7 -0
  21. package/dist/agents/send-message-tool.js +18 -6
  22. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  23. package/dist/agents/subagent-transcript-placement.js +14 -0
  24. package/dist/agents/subagent.js +102 -54
  25. package/dist/brain/route-adjudicator.js +9 -4
  26. package/dist/core/allow-entry.d.ts +4 -0
  27. package/dist/core/approval-object.js +1 -1
  28. package/dist/core/arg-summary.js +1 -1
  29. package/dist/core/ask-origin.d.ts +1 -1
  30. package/dist/core/ask-origin.js +2 -2
  31. package/dist/core/ask-question.d.ts +2 -2
  32. package/dist/core/ask-unresolvable-notice.d.ts +13 -4
  33. package/dist/core/ask-unresolvable-notice.js +10 -3
  34. package/dist/core/auto-compaction.d.ts +7 -5
  35. package/dist/core/background-agent-store.d.ts +7 -0
  36. package/dist/core/background-agent-store.js +3 -0
  37. package/dist/core/canonical-json.d.ts +23 -13
  38. package/dist/core/canonical-json.js +4 -4
  39. package/dist/core/checkpoint-queries.d.ts +50 -4
  40. package/dist/core/checkpoint-queries.js +42 -17
  41. package/dist/core/checkpoint-requirements.d.ts +3 -3
  42. package/dist/core/checkpoint-requirements.js +2 -1
  43. package/dist/core/checkpoint-row-verdict.d.ts +15 -4
  44. package/dist/core/checkpoint-row-verdict.js +22 -2
  45. package/dist/core/checkpoint-store.d.ts +28 -11
  46. package/dist/core/checkpoint-store.js +45 -4
  47. package/dist/core/compliance.d.ts +6 -2
  48. package/dist/core/compliance.js +3 -3
  49. package/dist/core/context-settings.d.ts +40 -9
  50. package/dist/core/context-settings.js +32 -10
  51. package/dist/core/engine-attestation.d.ts +27 -7
  52. package/dist/core/engine-attestation.js +5 -1
  53. package/dist/core/engine-notice.d.ts +43 -5
  54. package/dist/core/extension-requester.d.ts +9 -0
  55. package/dist/core/extension-requester.js +7 -0
  56. package/dist/core/file-history-store.d.ts +28 -0
  57. package/dist/core/file-history-store.js +48 -5
  58. package/dist/core/fs-write-gate-policy.js +1 -1
  59. package/dist/core/gate-fold.js +2 -0
  60. package/dist/core/gate-lanes.js +2 -0
  61. package/dist/core/gate-outcome.d.ts +39 -2
  62. package/dist/core/gate-outcome.js +20 -1
  63. package/dist/core/git-worktree-env.d.ts +62 -3
  64. package/dist/core/git-worktree-env.js +91 -30
  65. package/dist/core/governance-codes.d.ts +9 -3
  66. package/dist/core/governance-codes.js +17 -3
  67. package/dist/core/leg-identity.d.ts +19 -1
  68. package/dist/core/leg-identity.js +12 -0
  69. package/dist/core/mailbox-store.d.ts +39 -4
  70. package/dist/core/mailbox-store.js +14 -2
  71. package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
  72. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  73. package/dist/core/memory-engine/consolidation.d.ts +74 -10
  74. package/dist/core/memory-engine/consolidation.js +183 -11
  75. package/dist/core/memory-engine/control-objects.d.ts +25 -0
  76. package/dist/core/memory-engine/control-objects.js +151 -0
  77. package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
  78. package/dist/core/memory-engine/control-plane-adoption.js +159 -0
  79. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  80. package/dist/core/memory-engine/data-plane.js +11 -6
  81. package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
  82. package/dist/core/memory-engine/delegation-settlement.js +270 -85
  83. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  84. package/dist/core/memory-engine/dual-root.js +11 -7
  85. package/dist/core/memory-engine/engine.d.ts +136 -58
  86. package/dist/core/memory-engine/engine.js +491 -394
  87. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  88. package/dist/core/memory-engine/entry-scan.js +3 -0
  89. package/dist/core/memory-engine/file-backend.d.ts +62 -60
  90. package/dist/core/memory-engine/file-backend.js +122 -198
  91. package/dist/core/memory-engine/index.d.ts +8 -7
  92. package/dist/core/memory-engine/index.js +7 -6
  93. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  94. package/dist/core/memory-engine/landing-admission.js +3 -3
  95. package/dist/core/memory-engine/layout.d.ts +127 -46
  96. package/dist/core/memory-engine/layout.js +264 -109
  97. package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
  98. package/dist/core/memory-engine/memory-backend-contract.js +476 -0
  99. package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
  100. package/dist/core/memory-engine/memory-deployment.js +54 -15
  101. package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
  102. package/dist/core/memory-engine/origin-clearance.js +68 -9
  103. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  104. package/dist/core/memory-engine/scope-contract.js +68 -19
  105. package/dist/core/memory-engine/session-write-home.d.ts +37 -2
  106. package/dist/core/memory-engine/session-write-home.js +38 -11
  107. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  108. package/dist/core/memory-engine/sync-client.js +7 -0
  109. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  110. package/dist/core/memory-engine/sync-report.js +6 -2
  111. package/dist/core/memory-engine/tools.d.ts +2 -2
  112. package/dist/core/memory-engine/tools.js +10 -10
  113. package/dist/core/memory-engine/types.d.ts +155 -19
  114. package/dist/core/memory-engine/types.js +2 -0
  115. package/dist/core/memory.js +15 -6
  116. package/dist/core/mode-policy.js +3 -3
  117. package/dist/core/mods/agent-stations.d.ts +18 -0
  118. package/dist/core/mods/agent-stations.js +8 -6
  119. package/dist/core/mods/extension-call.d.ts +4 -0
  120. package/dist/core/mods/extension-call.js +8 -0
  121. package/dist/core/mods/stations.d.ts +20 -1
  122. package/dist/core/mods/stations.js +21 -2
  123. package/dist/core/mods/tool-call.js +3 -4
  124. package/dist/core/parent-spec-seat.d.ts +2 -2
  125. package/dist/core/park-selfcheck.js +2 -2
  126. package/dist/core/pause-registry.d.ts +2 -0
  127. package/dist/core/pause-registry.js +3 -0
  128. package/dist/core/peer-channel.d.ts +5 -0
  129. package/dist/core/permission-rule-consent.d.ts +26 -8
  130. package/dist/core/permission-rule-consent.js +76 -36
  131. package/dist/core/permission-rule-store.d.ts +72 -13
  132. package/dist/core/permission-rule-store.js +29 -8
  133. package/dist/core/read-only-shell.js +3 -2
  134. package/dist/core/redaction-marks.d.ts +8 -0
  135. package/dist/core/redaction-marks.js +6 -0
  136. package/dist/core/refusal-echo.d.ts +20 -0
  137. package/dist/core/refusal-echo.js +33 -0
  138. package/dist/core/remote-env.d.ts +12 -1
  139. package/dist/core/remote-env.js +3 -0
  140. package/dist/core/retention.d.ts +180 -10
  141. package/dist/core/retention.js +45 -0
  142. package/dist/core/retired-keys.d.ts +5 -0
  143. package/dist/core/retired-keys.js +3 -0
  144. package/dist/core/rule-offer-read.d.ts +0 -4
  145. package/dist/core/rule-offer-read.js +2 -18
  146. package/dist/core/runner/child-tree.d.ts +29 -3
  147. package/dist/core/runner/child-tree.js +39 -16
  148. package/dist/core/runner/classifier-ladder.d.ts +7 -1
  149. package/dist/core/runner/classifier-ladder.js +4 -2
  150. package/dist/core/runner/compact-session.js +10 -7
  151. package/dist/core/runner/compaction-call-options.d.ts +7 -7
  152. package/dist/core/runner/compaction-call-options.js +3 -2
  153. package/dist/core/runner/contracts.d.ts +39 -11
  154. package/dist/core/runner/delegation-owner.d.ts +10 -3
  155. package/dist/core/runner/delegation-owner.js +4 -1
  156. package/dist/core/runner/gate-exit.d.ts +6 -0
  157. package/dist/core/runner/gate-exit.js +13 -4
  158. package/dist/core/runner/inherited-ask-grants.js +1 -1
  159. package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
  160. package/dist/core/runner/memory-consolidation-driver.js +12 -9
  161. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  162. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  163. package/dist/core/runner/person-path-rows.d.ts +8 -3
  164. package/dist/core/runner/person-path-rows.js +5 -1
  165. package/dist/core/runner/placement-fence.d.ts +12 -0
  166. package/dist/core/runner/placement-fence.js +20 -6
  167. package/dist/core/runner/prepare-ask-lane.js +5 -5
  168. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
  169. package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
  170. package/dist/core/runner/prepare-config-doors.js +4 -0
  171. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  172. package/dist/core/runner/prepare-delegation-surface.js +2 -2
  173. package/dist/core/runner/prepare-execution-env.js +17 -6
  174. package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
  175. package/dist/core/runner/prepare-gate-stations.js +5 -5
  176. package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
  177. package/dist/core/runner/prepare-hands-readface.js +5 -4
  178. package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
  179. package/dist/core/runner/prepare-inherited-gate.js +12 -6
  180. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  181. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  182. package/dist/core/runner/prepare-memory.d.ts +7 -2
  183. package/dist/core/runner/prepare-memory.js +41 -39
  184. package/dist/core/runner/prepare-park-ask.js +4 -3
  185. package/dist/core/runner/prepare-policy-chain.js +7 -7
  186. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  187. package/dist/core/runner/prepare-task.js +26 -18
  188. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  189. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  190. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  191. package/dist/core/runner/resume-admission.d.ts +2 -2
  192. package/dist/core/runner/resume-admission.js +2 -23
  193. package/dist/core/runner/role-resolution-table.d.ts +98 -0
  194. package/dist/core/runner/role-resolution-table.js +62 -0
  195. package/dist/core/runner/run-compaction-machinery.js +2 -2
  196. package/dist/core/runner/run-identity-wiring.js +12 -9
  197. package/dist/core/runner/run-leg.js +9 -5
  198. package/dist/core/runner/run-notification-lane.js +22 -22
  199. package/dist/core/runner/run-recovery-lanes.js +3 -3
  200. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  201. package/dist/core/runner/run-terminal-adoption.js +1 -1
  202. package/dist/core/runner/run-turn-boundary.js +14 -15
  203. package/dist/core/runner/runtask.js +1 -1
  204. package/dist/core/runner/terminal-account.js +1 -1
  205. package/dist/core/runner/tool-occurrence.d.ts +4 -2
  206. package/dist/core/runner/tool-occurrence.js +2 -2
  207. package/dist/core/runner-deps.d.ts +7 -3
  208. package/dist/core/secret-env.d.ts +1 -1
  209. package/dist/core/secret-env.js +4 -4
  210. package/dist/core/session-checkout.d.ts +168 -0
  211. package/dist/core/session-checkout.js +579 -0
  212. package/dist/core/session-store.d.ts +12 -4
  213. package/dist/core/session-store.js +23 -3
  214. package/dist/core/session.d.ts +16 -2
  215. package/dist/core/session.js +3 -0
  216. package/dist/core/shell-read-silence.js +8 -0
  217. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
  218. package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
  219. package/dist/core/store-contracts/peer-directory-contract.js +8 -1
  220. package/dist/core/store-contracts/session-store-contract.js +39 -0
  221. package/dist/core/task-event.d.ts +30 -5
  222. package/dist/core/task-notification.d.ts +119 -32
  223. package/dist/core/task-notification.js +186 -100
  224. package/dist/core/task-registry-agent.d.ts +25 -2
  225. package/dist/core/task-registry-agent.js +56 -22
  226. package/dist/core/task-registry-shared.d.ts +33 -11
  227. package/dist/core/task-registry.d.ts +33 -9
  228. package/dist/core/task-registry.js +36 -18
  229. package/dist/core/task-spec-members.js +1 -1
  230. package/dist/core/task-spec.d.ts +27 -2
  231. package/dist/core/tool-errors.d.ts +14 -6
  232. package/dist/core/tool-errors.js +1 -1
  233. package/dist/core/tool-policy.d.ts +32 -13
  234. package/dist/core/tool-policy.js +27 -17
  235. package/dist/core/tool-result-store.d.ts +20 -0
  236. package/dist/core/tool-spec.d.ts +42 -19
  237. package/dist/core/trace.d.ts +3 -2
  238. package/dist/core/types.d.ts +1 -1
  239. package/dist/core/untrusted-egress.d.ts +15 -4
  240. package/dist/core/untrusted-egress.js +23 -22
  241. package/dist/core/workflow-journal-store.d.ts +11 -0
  242. package/dist/core/workflow-journal-store.js +7 -0
  243. package/dist/core/workflow-run-store.d.ts +9 -0
  244. package/dist/core/workflow-run-store.js +6 -0
  245. package/dist/core/workspace-snapshot.d.ts +3 -1
  246. package/dist/core/workspace-snapshot.js +1 -0
  247. package/dist/engine/compaction/compaction.d.ts +2 -1
  248. package/dist/engine/harness/types.d.ts +67 -1
  249. package/dist/engine/harness/types.js +108 -0
  250. package/dist/engine/session/import-validate.js +6 -1
  251. package/dist/engine/session/session.d.ts +30 -1
  252. package/dist/engine/session/session.js +48 -1
  253. package/dist/index.d.ts +12 -7
  254. package/dist/index.js +12 -7
  255. package/dist/internal/harness-types.d.ts +1 -1
  256. package/dist/orchestration/run-workflow-tool.d.ts +8 -1
  257. package/dist/orchestration/run-workflow-tool.js +8 -0
  258. package/dist/orchestration/workflow-types.d.ts +2 -1
  259. package/dist/orchestration/workflow.d.ts +6 -0
  260. package/dist/orchestration/workflow.js +5 -2
  261. package/dist/stores/file/checkpoint-store.d.ts +6 -0
  262. package/dist/stores/file/checkpoint-store.js +4 -1
  263. package/dist/stores/file/file-history-store.d.ts +13 -0
  264. package/dist/stores/file/file-history-store.js +75 -13
  265. package/dist/stores/file/index.d.ts +11 -1
  266. package/dist/stores/file/index.js +7 -11
  267. package/dist/stores/file/permission-rule-store.d.ts +23 -0
  268. package/dist/stores/file/permission-rule-store.js +75 -7
  269. package/dist/stores/file/session-store.js +2 -1
  270. package/dist/stores/file/tool-result-store.d.ts +14 -0
  271. package/dist/stores/file/tool-result-store.js +39 -2
  272. package/dist/stores/file/workflow-journal-store.d.ts +4 -0
  273. package/dist/stores/file/workflow-journal-store.js +17 -0
  274. package/dist/stores/file/workflow-run-store.d.ts +3 -0
  275. package/dist/stores/file/workflow-run-store.js +15 -0
  276. package/dist/tools/fs/bash-program-position.js +3 -3
  277. package/dist/tools/fs/program-read-model.d.ts +34 -10
  278. package/dist/tools/fs/program-read-model.js +37 -7
  279. package/dist/tools/fs/program-read-model.rows.js +13 -2
  280. package/dist/tools/fs/read-deny.d.ts +28 -3
  281. package/dist/tools/fs/read-deny.js +18 -2
  282. package/dist/tools/fs/removal-targets.js +3 -3
  283. package/dist/tools/fs/safety.d.ts +2 -0
  284. package/dist/tools/fs/safety.js +1 -1
  285. package/dist/tools/fs/shell-read-argv.d.ts +8 -1
  286. package/dist/tools/fs/shell-read-argv.js +34 -29
  287. package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
  288. package/dist/tools/fs/shell-read-bindings.js +5 -1
  289. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  290. package/dist/tools/fs/shell-read-brace.js +79 -0
  291. package/dist/tools/fs/shell-read-check.d.ts +8 -2
  292. package/dist/tools/fs/shell-read-check.js +16 -14
  293. package/dist/tools/fs/shell-read-establish.js +23 -16
  294. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  295. package/dist/tools/fs/shell-read-judge.js +3 -3
  296. package/dist/tools/fs/shell-read-plan.d.ts +10 -0
  297. package/dist/tools/fs/shell-read-plan.js +189 -93
  298. package/dist/tools/fs/shell-read-start.d.ts +19 -9
  299. package/dist/tools/fs/shell-read-start.js +20 -12
  300. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  301. package/dist/tools/fs/shell-read-word.js +9 -5
  302. package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
  303. package/dist/tools/fs/shell-read-workdir.js +73 -12
  304. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  305. package/dist/tools/worktree.d.ts +3 -2
  306. package/dist/tools/worktree.js +7 -35
  307. package/package.json +3 -2
  308. package/test/export-surface.snapshot.json +135 -11
  309. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  310. package/wire-changes/core-stores-sql@7.64.0.json +30 -0
  311. package/wire-changes/core@7.63.0.json +3523 -0
  312. package/wire-changes/core@7.64.0.json +2653 -0
  313. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  314. package/wire-changes/mods-kernel@7.64.0.json +30 -0
  315. package/wire-changes/primitives@7.63.0.json +445 -0
  316. package/wire-changes/primitives@7.64.0.json +30 -0
  317. package/dist/core/credential-vocabulary.d.ts +0 -176
  318. package/dist/core/credential-vocabulary.js +0 -190
  319. package/dist/core/redaction-passes.d.ts +0 -82
  320. package/dist/core/redaction-passes.js +0 -377
@@ -1,176 +0,0 @@
1
- /**
2
- * Where a text holds a credential — answered by ONE table, {@link CREDENTIAL_VOCABULARY}, and the three views read
3
- * off it:
4
- * - refuse-write ({@link refuseWriteView}): the rows that carry a `strict` form, in table order. A hit fail-closed
5
- * rejects a durable write, so a strict form is narrow (vendor-distinctive prefix, long body, word boundary): a
6
- * wrongly refused ordinary note is that face's head risk.
7
- * - egress ({@link egressPassGroups}): every row's wide `match`, in table order, grouped into passes. A hit replaces
8
- * the value in text that is persisted and forwarded, so a wide form is broad: a missed credential is that face's
9
- * head risk and over-redaction is cheap.
10
- * - env names ({@link envNameView}): the exact credential names, the credential words by position, the
11
- * connection-string name shape and the token-prefix value predicate a spawned child's environment is judged by.
12
- * - record keys ({@link recordKeyView}): the same credential words, read as the name of a member of a structured record
13
- * (a header name, a config member) rather than of an environment variable.
14
- *
15
- * A family's strict and wide forms live on the SAME row, and every text the strict form matches the wide form matches
16
- * too (machine-judged over the fixture file by `scripts/verify-credential-vocabulary.mjs`): the two faces may differ in
17
- * floors, never in vocabulary. Detection is shared; each layer renders its own marker.
18
- *
19
- * Zero imports by design: this module is the detection definition and moves into its own package as written.
20
- */
21
- /** How sure a detection is. */
22
- export type RedactionConfidence = "high" | "medium" | "low";
23
- /** Which rule table a finding names as its minter. A closed set: a report's entries can only have been written by
24
- * the engine's own tables, so "this finding says X" is an engine statement. */
25
- export type RedactionSource = "arg-summary" | "untrusted-egress" | "secret-env";
26
- /** One value family: "this run of characters is itself a credential". */
27
- export interface ValueFamilyRow {
28
- /** Stable family name, `^[a-z0-9-]+$`; a finding's `family`. The refuse-write label is this id spelled with `_`. */
29
- readonly id: string;
30
- /** The finding `kind` this family reports (the coarse class a consumer groups by). */
31
- readonly kind: string;
32
- readonly source: RedactionSource;
33
- readonly confidence: RedactionConfidence;
34
- /** The wide form (egress), global. A capture group 1, when the form has one, is a label kept verbatim ahead of the
35
- * marker (`AccountKey=`, `api_key=`). */
36
- readonly match: RegExp;
37
- /** The strict form (refuse-write), never global. Present = this family refuses a durable write; absent = it does
38
- * not (refusing is the tightening, so it is written, never implied). */
39
- readonly strict?: RegExp;
40
- /** The egress pass this wide form runs in. Rows naming the same pass sit next to each other and join as ONE
41
- * alternation, so a token is taken at its leftmost start whichever of them it is (a nested shape is never cut by
42
- * an earlier family's pass). Absent = a pass of its own. */
43
- readonly pass?: string;
44
- }
45
- /** Where a credential word counts in a name (env names are upper-cased words joined by `_`):
46
- * - `leading` — at the start of the name or right after `_`;
47
- * - `plural` — the word plus `S`, in the leading position;
48
- * - `counted-plural` — a plural, unless a count word (`MAX_TOKENS`) stands right in front of it;
49
- * - `separated` — only right after `_` (the shell's own `PWD` is none; a record has no such variable, so the record-key
50
- * view reads it as `leading`);
51
- * - `embedded` — anywhere (`AUTHTOKEN`, `MYSECRET`).
52
- * In every position the word must end the name or be followed by `_` or a digit (`KEYBOARD` is no word). */
53
- export type CredentialWordPosition = "leading" | "plural" | "counted-plural" | "separated" | "embedded";
54
- /** One credential word: "a name holding this word names a credential". */
55
- export interface CredentialWordRow {
56
- readonly word: string;
57
- readonly position: CredentialWordPosition;
58
- /** Further words that name the same credential as a record key only, read in this row's position by the record-key
59
- * view alone (`AUTH` → the `Authorization` header). The env-name view never reads them: a variable named
60
- * `AUTHORIZATION` is not withheld by its name. */
61
- readonly recordKeys?: readonly string[];
62
- }
63
- /** The URL userinfo rendering every renderer follows: keep the username (an auditor can tell whose account leaked
64
- * and revoke it) and replace the password, or replace the whole userinfo. */
65
- export interface VocabularyPolicy {
66
- readonly urlUserinfo: "keep-username" | "whole";
67
- }
68
- export interface CredentialVocabulary {
69
- /** Value families, in egress pass order. */
70
- readonly values: readonly ValueFamilyRow[];
71
- readonly words: readonly CredentialWordRow[];
72
- /** The words that turn a following counted plural into a number. */
73
- readonly countWords: readonly string[];
74
- /** A connection string named as such (`DB_CONN_STR`, `CONNECTION_STRINGS`), case-insensitive. */
75
- readonly connectionStringName: RegExp;
76
- /** Credential env names, each also judged under the `INPUT_` prefix (a GitHub Actions input). */
77
- readonly exactEnvNames: readonly string[];
78
- /** Credential-shaped names that hold no credential: declared names, never a pattern over names (the one pattern is
79
- * {@link CredentialVocabulary.nonSecretNameShape}). Three readings of the same list: the env-name view and the
80
- * record-member reading ({@link isSensitiveRecordKey}) take each as the WHOLE name (`CACHE_KEY` holds a setting,
81
- * `SECRET_CACHE_KEY` a secret, in an environment and in a config or detail record alike); the HTTP header-name
82
- * reading ({@link isSensitiveHeaderName}) takes it as the whole name or the TAIL of a longer one whose front part names
83
- * no credential word (`cf-aig-cache-key`, `X-Idempotency-Key`: a gateway's header for the same non-secret thing;
84
- * `secret-cache-key` stays a secret). */
85
- readonly nonSecretExactNames: readonly string[];
86
- /** The one name shape that holds no credential whatever words it carries: git's `GIT_CONFIG_KEY_<n…>` names a
87
- * configuration key (its value sits in `GIT_CONFIG_VALUE_<n>`). Read by every name view, beside the exact names. */
88
- readonly nonSecretNameShape: RegExp;
89
- /** A leading vendor prefix that spells a credential word without being one (`AUTH0_`): dropped from a name before the
90
- * credential words are looked for, in every name view alike. */
91
- readonly nonCredentialPrefix: RegExp;
92
- /** A value (or a password-less URL user) opening with a known token prefix. */
93
- readonly tokenPrefix: RegExp;
94
- readonly policy: VocabularyPolicy;
95
- }
96
- /**
97
- * The URI scheme: RFC 3986's scheme production plus `_`, of any length, read from the START of its run of scheme characters
98
- * (a run's leading digits and marks are taken into it, so the match keeps them). An unanchored unbounded `\w+` made every
99
- * `://` pattern quadratic in the longest unbroken word run (one long base64 paste cost seconds of synchronous CPU), and a
100
- * 64-character cap that replaced it missed a longer scheme; anchored at the run's start, each run is tried once — linear, and
101
- * no scheme is too long to be read.
102
- */
103
- export declare const URI_SCHEME_SOURCE: string;
104
- /**
105
- * A URL's userinfo with the `@` that ends it, up to the LAST `@` before the host (a password may hold `@`): runs of characters
106
- * that are no `/`, white space, `"` or `@`, each closed by an `@`. The class holds all of RFC 3986's userinfo (unreserved,
107
- * pct-encoded, sub-delims — `'` among them — and `:`) and the characters a password written unencoded carries (`#`, `?`, …);
108
- * `"` ends it, the quote of a string around the URL. The one userinfo grammar: every reader that removes a userinfo matches
109
- * this, and each renders the match its own way.
110
- */
111
- export declare const URL_USERINFO_SOURCE: string;
112
- /** The fewest characters a string can have and still be read as a credential: the floor of a vendor-prefixed token's body
113
- * and of a bearer / authorization credential run in this table, and of the value rules of the env scrub. A shorter
114
- * string names no secret, whoever holds it. */
115
- export declare const CREDENTIAL_MIN_CHARS = 8;
116
- export declare const CREDENTIAL_VOCABULARY: CredentialVocabulary;
117
- /** The refuse-write label of a family: its id spelled with `_` (surfaced in the refusal; never the matched value). */
118
- export declare const refuseLabel: (id: string) => string;
119
- /** One refuse-write form: the family's label and its strict form. */
120
- export interface RefuseWriteForm {
121
- readonly label: string;
122
- readonly re: RegExp;
123
- }
124
- /** The refuse-write view: every row carrying a strict form, in table order (the first hit names the label). */
125
- export declare function refuseWriteView(vocabulary: CredentialVocabulary): readonly RefuseWriteForm[];
126
- /** The egress view: the rows in table order, each run of adjacent rows naming the same `pass` as one group. */
127
- export declare function egressPassGroups(vocabulary: CredentialVocabulary): ReadonlyArray<readonly ValueFamilyRow[]>;
128
- /** The env-name view: what {@link CREDENTIAL_VOCABULARY} says about variable names and token-prefixed values. */
129
- export interface EnvNameView {
130
- /** Upper-cased, `-` read as `_`; each name also under `INPUT_`. */
131
- readonly exactNames: ReadonlySet<string>;
132
- readonly nonSecretExactNames: ReadonlySet<string>;
133
- readonly nonSecretNameShape: RegExp;
134
- readonly nonCredentialPrefix: RegExp;
135
- /** A credential word in its position, case-insensitive. */
136
- readonly credentialWord: RegExp;
137
- readonly connectionStringName: RegExp;
138
- /** A credential word that is a whole `_` segment of a name (every position but `embedded`; a counted plural no count
139
- * word touches), as a regex source. */
140
- readonly segmentWord: string;
141
- readonly tokenPrefix: RegExp;
142
- }
143
- export declare function envNameView(vocabulary: CredentialVocabulary): EnvNameView;
144
- /** `camelCase` / `PascalCase` read as `_`-separated words, `OAuth` and `NextAuth` kept whole. */
145
- export declare function splitCamelCase(name: string): string;
146
- /** The record-key view: what {@link CREDENTIAL_VOCABULARY} says about the names a structured record carries — the member
147
- * of a config or detail record and the HTTP header — the credential words of the env-name view, each row's `recordKeys`
148
- * spellings besides, and a `separated` word standing alone (`pwd`, `pass`: a record has no shell variable of that name).
149
- * The names the vocabulary declares non-secret stay non-secret here too, as the whole name; the header-name reading
150
- * ({@link isSensitiveHeaderName}) alone also takes one as the tail of a longer name — a gateway prefixes the header it
151
- * names the same non-secret thing with (`cf-aig-cache-key`), where a secret named `secret_cache_key` lives in a
152
- * body or a config record and is read whole. */
153
- export interface RecordKeyView {
154
- /** A credential word in its position, case-insensitive. Applied to a key with `-` read as `_`, as written and
155
- * camel-split ({@link isSensitiveRecordKey}, {@link isSensitiveHeaderName}). */
156
- readonly credentialWord: RegExp;
157
- readonly nonSecretExactNames: ReadonlySet<string>;
158
- readonly nonSecretNameShape: RegExp;
159
- readonly nonCredentialPrefix: RegExp;
160
- }
161
- export declare function recordKeyView(vocabulary: CredentialVocabulary): RecordKeyView;
162
- /** Does `key`, the name of a record's MEMBER (`Proxy-Authorization`, `pwd`, `X_API_KEY`, `clientSecret`), name a credential?
163
- * Case does not matter, `-` and `_` are one. A name the vocabulary declares non-secret is none as the WHOLE name only
164
- * (`partition_key`; `x_partition_key` and `secret_cache_key` are still read by their words): a
165
- * secret is named by the system that holds it, and what this reading decides is whether a value is shown or kept out of
166
- * a record. The HTTP header-name reading is {@link isSensitiveHeaderName}. `view` is the vocabulary's record-key view
167
- * unless a caller holds another. */
168
- export declare function isSensitiveRecordKey(key: string, view?: RecordKeyView): boolean;
169
- /** Does `name`, an HTTP header's name (`Authorization`, `X-Api-Key`, `cf-aig-cache-key`), name a credential? The
170
- * record-key reading ({@link isSensitiveRecordKey}) plus one exemption: a declared non-secret name is none also as the
171
- * TAIL of a longer name, at a `_` / `-` boundary, whose front part holds no credential word (`cf-aig-cache-key`,
172
- * `X-Idempotency-Key`, `X-Partition-Key`; `secret-cache-key`, `clientAuth-cache-key` and `xcache-key`
173
- * are still read by their words). A gateway prefixes the header it names the same non-secret thing with, and the reading
174
- * that mistakes such a header for a credential drops the key that should have gone out. `view` is the vocabulary's
175
- * record-key view unless a caller holds another. */
176
- export declare function isSensitiveHeaderName(name: string, view?: RecordKeyView): boolean;
@@ -1,190 +0,0 @@
1
- export const URI_SCHEME_SOURCE = String.raw `(?<![A-Za-z0-9+.\-_])[0-9+.\-_]*[A-Za-z][A-Za-z0-9+.\-_]*`;
2
- export const URL_USERINFO_SOURCE = String.raw `(?:[^/\s"@]*@)+`;
3
- export const CREDENTIAL_MIN_CHARS = 8;
4
- const VENDOR_BODY = `[A-Za-z0-9_-]{${CREDENTIAL_MIN_CHARS},}`;
5
- const VALUE_END = String.raw `\s"';|&`;
6
- const VALUE_CHAR = `[^${VALUE_END}]`;
7
- const ESCAPE_DEPTH = 63;
8
- const QUOTED_VALUE_MAX = 1024;
9
- const PLAIN_QUOTES = [`"`, `'`, `&quot;`, `&apos;`, `&#34;`, `&#39;`, `%22`, `%27`];
10
- const ESCAPED_QUOTES = [`"`, `'`, `x22`, `x27`, `u0022`, `u0027`, `042`, `047`];
11
- const BACKSLASHES = String.raw `\\{1,${ESCAPE_DEPTH}}`;
12
- const QUOTE = `(?:${PLAIN_QUOTES.join("|")}|${BACKSLASHES}(?:${ESCAPED_QUOTES.join("|")}))`;
13
- const WORD_START = `(?:(?<![A-Za-z0-9])|(?<=${QUOTE}))`;
14
- const AFTER_CLOSING_QUOTE = String.raw `(?:[\s,}\]:]|["']|$)`;
15
- const VALUE_RUN_END = `(?:(?<!\\\\)|(?!\\\\{0,${ESCAPE_DEPTH}}["']))`;
16
- const GLUED_RUN = `${VALUE_CHAR}*${VALUE_RUN_END}`;
17
- const pairedValue = (open, close) => `${open}(?!${AFTER_CLOSING_QUOTE})[^\\n]{0,${QUOTED_VALUE_MAX}}?${close}`;
18
- const QUOTED_VALUE = [
19
- ...PLAIN_QUOTES.map((q) => pairedValue(q, q)),
20
- ...ESCAPED_QUOTES.map((q, i) => pairedValue(`(${BACKSLASHES})${q}`, `(?<!\\\\)(?:\\${i + 2})${q}`)),
21
- `${QUOTE}(?!${AFTER_CLOSING_QUOTE})${GLUED_RUN}`,
22
- ].join("|");
23
- const BEARER_TAIL = `(?:(?!${QUOTE})\\S${GLUED_RUN}|(?<==)(?:${QUOTED_VALUE}))`;
24
- const HEADER_PARAM = String.raw `=[ \t]*(\\{0,${ESCAPE_DEPTH}})(["'])(?:(?!(?<!\\)\2\3)[^\r\n])*(?:(?<!\\)\2\3(?=[\s,;]|\\{0,${ESCAPE_DEPTH}}["']|$)|(?=[\r\n]|$))`;
25
- const HEADER_VALUE = String.raw `(?:[A-Za-z][A-Za-z0-9!#$%&*+.^_|~-]*[ \t]+)?(?:${HEADER_PARAM}|[^\s"',]|[ \t]*,[ \t]*(?=[^\s"',])|[ \t]+(?==)|(?<==)[ \t]+(?=[^\s"',]))+${VALUE_RUN_END}`;
26
- const headed = (body, flags = "g") => new RegExp(`${WORD_START}${body}`, flags);
27
- const HUMP_BEFORE = "[a-z0-9]";
28
- const KEYWORD_VALUE_WORDS = ["token", "secret", "key", "password", "passwd", "credential"];
29
- const anyCase = (word) => [...word].map((c) => `[${c.toUpperCase()}${c.toLowerCase()}]`).join("");
30
- const VALUE_ROW_FIELDS = [["Account", "Key"]];
31
- const leftToItsRow = (keyword) => VALUE_ROW_FIELDS.filter(([, k]) => k.toLowerCase() === keyword).map(([front]) => `(?<!(?<![A-Za-z0-9])${front})`).join("");
32
- const KEYWORD_HEAD = `(?:${WORD_START}(?:${KEYWORD_VALUE_WORDS.map(anyCase).join("|")})|(?<=${HUMP_BEFORE})(?:${KEYWORD_VALUE_WORDS.map((w) => leftToItsRow(w) + w[0].toUpperCase() + anyCase(w.slice(1))).join("|")})|(?<=[A-Z])(?:${KEYWORD_VALUE_WORDS.map((w) => w[0].toUpperCase() + w[1] + anyCase(w.slice(2))).join("|")}))`;
33
- const KEY_QUOTE = `(?:\\\\{0,${ESCAPE_DEPTH}}["'])?`;
34
- export const CREDENTIAL_VOCABULARY = {
35
- values: [
36
- { id: "github-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`gh[opsur][-_]${VENDOR_BODY}`), strict: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}\b/ },
37
- { id: "github-fine-grained-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`github_pat[-_]${VENDOR_BODY}`), strict: /\bgithub_pat_[A-Za-z0-9_]{60,}\b/ },
38
- { id: "openai-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`sk-${VENDOR_BODY}`), strict: /\bsk-(?:ant-(?:api03-)?|proj-)?[A-Za-z0-9_]{20,}\b/ },
39
- { id: "stripe-secret-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`(?:sk_|rk[-_])${VENDOR_BODY}`), strict: /\b[sr]k_(?:live|test)_[A-Za-z0-9]{24,}\b/ },
40
- { id: "stripe-publishable-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`pk[-_]${VENDOR_BODY}`) },
41
- { id: "gitlab-pat", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed("glpat-[A-Za-z0-9_-]{20,}") },
42
- { id: "npm-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed("npm_[A-Za-z0-9]{36,}") },
43
- { id: "google-oauth-access-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(String.raw `ya29\.[A-Za-z0-9_.-]{20,}`) },
44
- { id: "google-api-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed("AIza[A-Za-z0-9_-]{20,}"), strict: /\bAIza[0-9A-Za-z_-]{35}\b/ },
45
- { id: "slack-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed("xox[baprs]-[A-Za-z0-9-]{10,}"), strict: /\bxox[baprs]-(?:[A-Za-z0-9]+-){1,3}[A-Za-z0-9]{16,}\b/ },
46
- { id: "aws-access-key-id", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed("(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[0-9A-Z]{12,}"), strict: /\bAKIA[0-9A-Z]{16}\b/ },
47
- { id: "huggingface-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: headed("hf_[A-Za-z0-9]{20,}"), strict: /\bhf_(?=[A-Za-z0-9]*[0-9])[A-Za-z0-9]{20,}\b/ },
48
- { id: "jwt", kind: "jwt", source: "arg-summary", confidence: "high", match: headed("eyJ[A-Za-z0-9._-]{20,}"), strict: /\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{16,}\b/ },
49
- { id: "private-key", kind: "private-key-block", source: "arg-summary", confidence: "high", match: /-----BEGIN[ A-Z0-9]*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END[ A-Z0-9]*PRIVATE KEY(?: BLOCK)?-----|$)/g, strict: /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----/ },
50
- { id: "bearer-token", kind: "bearer-token", source: "arg-summary", confidence: "high", match: headed(String.raw `()[Bb][Ee][Aa][Rr][Ee][Rr]\s+[A-Za-z0-9._~+/-]{${CREDENTIAL_MIN_CHARS},}=*(?:${BEARER_TAIL})?`), strict: /\bAuthorization:\s*Bearer\s+(?=[A-Za-z0-9._~+/-]*[0-9])[A-Za-z0-9._~+/-]{20,}=*/ },
51
- { id: "authorization-header", kind: "authorization-header", source: "arg-summary", confidence: "high", match: headed(String.raw `(authorization(?:\\{0,${ESCAPE_DEPTH}}["'])?[ \t]*[=:][ \t]*(?:\\{0,${ESCAPE_DEPTH}}["'])?)${HEADER_VALUE}`, "gi") },
52
- { id: "azure-storage-account-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: /(AccountKey=)[A-Za-z0-9+/]{40,}={0,2}/g, strict: /AccountKey=[A-Za-z0-9+/]{40,}={0,2}/ },
53
- { id: "keyword-value", kind: "keyword-value", source: "arg-summary", confidence: "medium", match: new RegExp(String.raw `(${KEYWORD_HEAD}${KEY_QUOTE}\s*[=:]\s*${KEY_QUOTE})${VALUE_CHAR}{4,}${VALUE_RUN_END}`, "g") },
54
- { id: "url-userinfo", kind: "url-credentials", source: "untrusted-egress", confidence: "medium", match: new RegExp(String.raw `(${URI_SCHEME_SOURCE}:\/\/)(${URL_USERINFO_SOURCE})`, "gi") },
55
- { id: "signed-url-param", kind: "signed-url-param", source: "untrusted-egress", confidence: "high", match: /([?&#](?:sig|signature|sas|code)=)[^&\s"'#]+/gi },
56
- ],
57
- words: [
58
- ...["TOKEN", "SECRET", "PASSWORD", "PASSWD", "PASSPHRASE", "KEY"].map((word) => ({ word, position: "leading" })),
59
- { word: "AUTH", position: "leading", recordKeys: ["AUTHORIZATION", "AUTHENTICATION", "OAUTH", "AUTHN", "AUTHZ"] },
60
- ...["COOKIE", "PAT", "DSN", "WEBHOOK", "CREDENTIAL", "CREDENTIALS", "CREDS", "APIKEY", "ACCESSKEY", "SECRETKEY", "ACCOUNTKEY", "PRIVATEKEY", "AUTHKEY", "SSHKEY", "SIGNINGKEY", "MASTERKEY", "DEPLOYKEY", "ENCRYPTIONKEY", "PGPASSWORD", "SSHPASS"].map((word) => ({ word, position: "leading" })),
61
- ...["KEY", "SECRET", "PASSWORD", "CREDENTIAL"].map((word) => ({ word, position: "plural" })),
62
- { word: "TOKEN", position: "counted-plural" },
63
- ...["PWD", "PASS", "JWT"].map((word) => ({ word, position: "separated" })),
64
- ...["TOKEN", "SECRET", "PASSWORD", "PASSWD", "PASSPHRASE"].map((word) => ({ word, position: "embedded" })),
65
- ],
66
- countWords: ["MAX", "OUTPUT", "INPUT", "THINKING", "NUM", "TOTAL"],
67
- connectionStringName: /CONN(ECT(ION)?)?_?STR(ING)?S?(?=$|[_0-9])/i,
68
- exactEnvNames: [
69
- "ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN", "CLAUDE_CODE_ARTIFACTS_API_TOKEN", "CLAUDE_CODE_MEMORY_API_TOKEN",
70
- "CLAUDE_CODE_SLACK_TAG_TOKEN", "ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_FOUNDRY_API_KEY", "ANTHROPIC_FOUNDRY_AUTH_TOKEN",
71
- "ANTHROPIC_AWS_API_KEY", "ANTHROPIC_CUSTOM_HEADERS", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN",
72
- "AWS_BEARER_TOKEN_BEDROCK", "GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_GHA_CREDS_PATH", "AZURE_CLIENT_SECRET",
73
- "IDENTITY_HEADER", "MSI_SECRET", "AZURE_CLIENT_CERTIFICATE_PATH", "AZURE_CLIENT_CERTIFICATE_PASSWORD",
74
- "AZURE_PASSWORD", "AZURE_FEDERATED_TOKEN_FILE", "AWS_WEB_IDENTITY_TOKEN_FILE",
75
- "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI", "AWS_CONTAINER_CREDENTIALS_FULL_URI",
76
- "AWS_CONTAINER_AUTHORIZATION_TOKEN", "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE", "CLOUDSDK_AUTH_ACCESS_TOKEN",
77
- "GOOGLE_OAUTH_ACCESS_TOKEN", "CLAUDE_CODE_OAUTH_REFRESH_TOKEN", "HF_TOKEN", "HUGGING_FACE_HUB_TOKEN",
78
- "HUGGINGFACEHUB_API_TOKEN", "NODE_AUTH_TOKEN", "NUGET_AUTH_TOKEN", "CARGO_REGISTRY_TOKEN", "TWINE_PASSWORD",
79
- "TWINE_USERNAME", "PYPI_TOKEN", "PYPI_API_TOKEN", "UV_PUBLISH_TOKEN", "UV_PUBLISH_PASSWORD", "UV_PUBLISH_USERNAME",
80
- "FLIT_PASSWORD", "FLIT_USERNAME", "HATCH_INDEX_AUTH", "HATCH_INDEX_USER", "GEM_HOST_API_KEY", "MATURIN_PYPI_TOKEN",
81
- "MATURIN_PASSWORD", "MATURIN_USERNAME", "CONAN_LOGIN_USERNAME", "CONAN_PASSWORD", "ANACONDA_API_TOKEN",
82
- "BINSTAR_API_TOKEN", "VAULT_TOKEN", "VAULT_AUTH_TOKEN", "VAULT_ROLE_ID", "VAULT_SECRET_ID", "CONSUL_HTTP_TOKEN",
83
- "CONSUL_HTTP_AUTH", "NOMAD_TOKEN", "NOMAD_HTTP_AUTH", "CI_REGISTRY_USER", "CI_DEPLOY_USER", "JF_USER",
84
- "FASTLANE_SESSION", "MATCH_GIT_BASIC_AUTHORIZATION", "SONAR_TOKEN", "SONARQUBE_SCANNER_PARAMS",
85
- "SONAR_SCANNER_JSON_PARAMS", "SLACK_WEBHOOK_URL", "SLACK_WEBHOOK", "DISCORD_WEBHOOK", "DISCORD_WEBHOOK_URL",
86
- "TEAMS_WEBHOOK_URL", "MS_TEAMS_WEBHOOK_URI", "ANTHROPIC_IDENTITY_TOKEN", "ANTHROPIC_IDENTITY_TOKEN_FILE",
87
- "CLOUDSDK_AUTH_ACCESS_TOKEN_FILE", "CLOUDSDK_AUTH_AUTHORIZATION_TOKEN_FILE", "AZURE_AUTH_LOCATION",
88
- "ACTIONS_ID_TOKEN_REQUEST_TOKEN", "ACTIONS_ID_TOKEN_REQUEST_URL", "ACTIONS_RUNTIME_TOKEN", "ACTIONS_RUNTIME_URL",
89
- "ALL_INPUTS", "VSS_NUGET_EXTERNAL_FEED_ENDPOINTS", "ARTIFACTS_CREDENTIALPROVIDER_EXTERNAL_FEED_ENDPOINTS",
90
- "VSS_NUGET_ACCESSTOKEN", "ARTIFACTS_CREDENTIALPROVIDER_ACCESSTOKEN", "COMPOSER_AUTH", "OVERRIDE_GITHUB_TOKEN",
91
- "DEFAULT_WORKFLOW_TOKEN", "SSH_SIGNING_KEY",
92
- ],
93
- nonSecretExactNames: [
94
- "PARTITION_KEY", "SORT_KEY", "RANGE_KEY", "IDEMPOTENCY_KEY", "CACHE_KEY",
95
- "DB_FOREIGN_KEYS", "JSON_SORT_KEYS",
96
- "MAX_NEW_TOKENS", "MAX_COMPLETION_TOKENS", "AIDER_MAP_TOKENS", "AIDER_MAX_CHAT_HISTORY_TOKENS",
97
- "MAX_BATCH_PREFILL_TOKENS", "MAX_WAITING_TOKENS", "MAX_TOP_N_TOKENS", "RATE_LIMIT_TOKENS",
98
- "PROMPT_TOKENS", "CONTEXT_TOKENS",
99
- ],
100
- nonSecretNameShape: /^GIT_CONFIG_KEY_[0-9][A-Za-z0-9_]*$/,
101
- nonCredentialPrefix: /^AUTH0_/i,
102
- tokenPrefix: /^(?:gh[opusr]_|github_pat_|glpat-|xox[abpr]-|sk-|pk-|AKIA|eyJ|ya29\.|npm_)/,
103
- policy: { urlUserinfo: "keep-username" },
104
- };
105
- export const refuseLabel = (id) => id.replaceAll("-", "_");
106
- export function refuseWriteView(vocabulary) {
107
- return vocabulary.values.flatMap((row) => (row.strict === undefined ? [] : [{ label: refuseLabel(row.id), re: row.strict }]));
108
- }
109
- export function egressPassGroups(vocabulary) {
110
- const groups = [];
111
- for (const row of vocabulary.values) {
112
- const last = groups[groups.length - 1];
113
- if (row.pass !== undefined && last !== undefined && last[0].pass === row.pass)
114
- last.push(row);
115
- else
116
- groups.push([row]);
117
- }
118
- return groups;
119
- }
120
- function credentialWordPattern(countWords, rows) {
121
- const at = (position) => rows.filter((r) => r.position === position).map((r) => r.word);
122
- const countedPlural = `(?<!(?:^|_)(?:${countWords.join("|")})_)(?:${at("counted-plural").join("|")})S`;
123
- const [separated, embedded] = [at("separated"), at("embedded")];
124
- const positions = [
125
- `(^|_)(${at("leading").join("|")}|(${at("plural").join("|")})S|${countedPlural})`,
126
- ...(separated.length > 0 ? [`_(${separated.join("|")})`] : []),
127
- ...(embedded.length > 0 ? [`(${embedded.join("|")})`] : []),
128
- ];
129
- const segmentWord = `(?:${[...at("leading"), ...at("plural").map((w) => `${w}S`), ...separated, countedPlural].join("|")})`;
130
- return { credentialWord: new RegExp(`(${positions.join("|")})(?=$|[_0-9])`, "i"), segmentWord };
131
- }
132
- export function envNameView(vocabulary) {
133
- const { credentialWord, segmentWord } = credentialWordPattern(vocabulary.countWords, vocabulary.words);
134
- return {
135
- exactNames: new Set(vocabulary.exactEnvNames.flatMap((name) => [name, `INPUT_${name}`])),
136
- nonSecretExactNames: new Set(vocabulary.nonSecretExactNames),
137
- nonSecretNameShape: vocabulary.nonSecretNameShape,
138
- nonCredentialPrefix: vocabulary.nonCredentialPrefix,
139
- credentialWord,
140
- connectionStringName: vocabulary.connectionStringName,
141
- segmentWord,
142
- tokenPrefix: vocabulary.tokenPrefix,
143
- };
144
- }
145
- export function splitCamelCase(name) {
146
- return ["OAuth", "NextAuth"]
147
- .reduce((text, word) => text.replaceAll(word, word[0] + word.slice(1).toLowerCase()), name)
148
- .replace(new RegExp(`(${HUMP_BEFORE})([A-Z])`, "g"), "$1_$2")
149
- .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2");
150
- }
151
- export function recordKeyView(vocabulary) {
152
- const rows = vocabulary.words.flatMap((w) => [w.word, ...(w.recordKeys ?? [])].map((word) => ({ word, position: w.position === "separated" ? "leading" : w.position })));
153
- return {
154
- credentialWord: credentialWordPattern(vocabulary.countWords, rows).credentialWord,
155
- nonSecretExactNames: new Set(vocabulary.nonSecretExactNames),
156
- nonSecretNameShape: vocabulary.nonSecretNameShape,
157
- nonCredentialPrefix: vocabulary.nonCredentialPrefix,
158
- };
159
- }
160
- const RECORD_KEYS = recordKeyView(CREDENTIAL_VOCABULARY);
161
- function holdsCredentialWord(text, view) {
162
- const words = text.replace(view.nonCredentialPrefix, "").replace(/-/g, "_");
163
- return view.credentialWord.test(words) || view.credentialWord.test(splitCamelCase(words));
164
- }
165
- function isNonSecretRecordName(key, source, view) {
166
- const spelled = key.replace(/-/g, "_");
167
- const folded = spelled.toUpperCase();
168
- if (view.nonSecretExactNames.has(folded))
169
- return true;
170
- if (source !== "header")
171
- return false;
172
- if (folded.length !== spelled.length)
173
- return false;
174
- for (const name of view.nonSecretExactNames) {
175
- if (folded.endsWith(`_${name}`) && !holdsCredentialWord(spelled.slice(0, spelled.length - name.length - 1), view))
176
- return true;
177
- }
178
- return false;
179
- }
180
- function readsAsCredential(key, source, view) {
181
- if (view.nonSecretNameShape.test(key))
182
- return false;
183
- return holdsCredentialWord(key, view) && !isNonSecretRecordName(key, source, view);
184
- }
185
- export function isSensitiveRecordKey(key, view = RECORD_KEYS) {
186
- return readsAsCredential(key, "member", view);
187
- }
188
- export function isSensitiveHeaderName(name, view = RECORD_KEYS) {
189
- return readsAsCredential(name, "header", view);
190
- }
@@ -1,82 +0,0 @@
1
- /**
2
- * The redaction pass engine every egress tier runs on, and the core bracket RENDERER of the vocabulary's answer.
3
- * Which text is a credential is the vocabulary's answer (credential-vocabulary.ts); which passes a text meets is
4
- * its tier's (untrusted-egress.ts).
5
- */
6
- import type { RedactionConfidence, RedactionSource, ValueFamilyRow } from "./credential-vocabulary.js";
7
- export type { RedactionConfidence, RedactionSource } from "./credential-vocabulary.js";
8
- /** One redaction hit: what was detected, where (ORIGINAL-input coordinates), how confidently, the marker
9
- * literal written in its place, which rule table minted it, and — present when a vocabulary row minted it — the
10
- * value family (the row's stable id; a host-leak hit such as a URL or a path names none). */
11
- export interface RedactionFinding {
12
- kind: string;
13
- span: readonly [number, number];
14
- confidence: RedactionConfidence;
15
- marker: string;
16
- source: RedactionSource;
17
- family?: string;
18
- }
19
- /** The minimum a finding must declare to be summarizable. Both text findings ({@link RedactionFinding})
20
- * and the env arm's entry findings satisfy it, so {@link summarizeRedactions} is ONE helper rather than
21
- * one per material kind. */
22
- export interface SummarizableFinding {
23
- kind: string;
24
- confidence: RedactionConfidence;
25
- }
26
- /** ANG-3 (envelope declaration) — render findings as ONE human-readable line, e.g.
27
- * `"3 redactions: prefixed-token (high) x1, url (medium) x1, fs-path (low) x1"`, so an upper layer can
28
- * declare to its consumer how much was removed and how confidently.
29
- *
30
- * PURE, and deliberately only that: it reads the array, returns a string, and injects nothing anywhere.
31
- * Attaching this line to an output is the caller's decision — a redaction pipeline that silently
32
- * appended prose to the very text it was asked to bound would break both the size contract
33
- * (`boundedString`) and the byte-invariance the whole channel is built on.
34
- *
35
- * Grouping is by kind AND confidence together: collapsing on kind alone would report whichever
36
- * confidence happened to arrive first for the rest of that group, which is exactly the silent
37
- * mis-statement ANG-4 exists to prevent. */
38
- export declare function summarizeRedactions(findings: readonly SummarizableFinding[]): string;
39
- /** The optional collector every redaction entry point accepts. `preexistingMarkers` (ANG-11) counts
40
- * marker-shaped literals ALREADY present in the input before any pass ran — a nonzero value means the
41
- * text arrived pre-redacted or carries caller-declared markers, either way "marker present" is not proof this
42
- * pipeline ran. Caller-owned: pass `{ findings: [] }` and read it back after the call. */
43
- export interface RedactionReport {
44
- findings: RedactionFinding[];
45
- preexistingMarkers?: number;
46
- }
47
- /** A declared redaction pass — the unit {@link runRedactionPasses} executes and reports on. */
48
- export interface RedactionPass {
49
- kind: string;
50
- confidence: RedactionConfidence;
51
- marker: string;
52
- /** The rule table that owns this pass's rule — copied verbatim onto every finding it mints (ANG-11), whoever
53
- * runs the pass. */
54
- source: RedactionSource;
55
- re: RegExp;
56
- /** A literal replacement (only `$1` substitution is used by these passes) or a replacer fn. */
57
- replace: string | ((match: string, ...groups: string[]) => string);
58
- /** The value family a hit belongs to: one id, or — for a pass joining several rows — the id of the row that
59
- * matches at the hit's offset in the pass input. Absent = the pass is no vocabulary row. */
60
- family?: string | ((input: string, at: number) => string);
61
- }
62
- /**
63
- * Run the declared passes in order, collecting findings (original-input spans) when a report is given.
64
- *
65
- * FORMAT CHARACTERS (#532): the passes scan a VIEW of the input with every `\p{Cf}` removed, so a
66
- * credential split by a zero-width character is one token to the scanner, not two fragments of which
67
- * only the first (or neither) matches. The OUTPUT keeps every format character that sits OUTSIDE a
68
- * replaced span — a joiner in an emoji sequence, a non-joiner in Persian text, a soft hyphen in a word
69
- * — and drops only those INSIDE the span the marker replaces (they were part of the secret). A
70
- * format-free input takes the exact historical path (byte-identical output). The view's replacements and
71
- * every boundary scan's are taken as disjoint spans of their input (a later pass that matched across an
72
- * earlier pass's inserted text is rendered from the removals instead), so the spans always map back
73
- * exactly and no scan is skipped.
74
- */
75
- export declare function runRedactionPasses(input: string, passes: readonly RedactionPass[], report?: RedactionReport): string;
76
- /**
77
- * The egress view rendered as passes, in the vocabulary's order: one pass per group (a group of several rows is ONE
78
- * leftmost alternation, its hits attributed to the row that matches at the hit's offset). A row whose wide form
79
- * captures a label keeps it ahead of the marker; `replacers` renders a kind whose marker placement is a policy (the
80
- * URL userinfo).
81
- */
82
- export declare function egressPasses(groups: ReadonlyArray<readonly ValueFamilyRow[]>, replacers?: Readonly<Record<string, (match: string, ...groups: string[]) => string>>): RedactionPass[];