audit-tools 0.32.68 → 0.33.1

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 (238) hide show
  1. package/README.md +7 -0
  2. package/dist/audit/cli/advanceAuditCommand.d.ts.map +1 -1
  3. package/dist/audit/cli/advanceAuditCommand.js +8 -3
  4. package/dist/audit/cli/advanceAuditCommand.js.map +1 -1
  5. package/dist/audit/cli/args.d.ts +9 -27
  6. package/dist/audit/cli/args.d.ts.map +1 -1
  7. package/dist/audit/cli/args.js +119 -50
  8. package/dist/audit/cli/args.js.map +1 -1
  9. package/dist/audit/cli/auditStep.d.ts +15 -1
  10. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  11. package/dist/audit/cli/auditStep.js +2 -0
  12. package/dist/audit/cli/auditStep.js.map +1 -1
  13. package/dist/audit/cli/dispatch/quotaPool.d.ts +2 -1
  14. package/dist/audit/cli/dispatch/quotaPool.d.ts.map +1 -1
  15. package/dist/audit/cli/dispatch/quotaPool.js +43 -77
  16. package/dist/audit/cli/dispatch/quotaPool.js.map +1 -1
  17. package/dist/audit/cli/dispatch.d.ts.map +1 -1
  18. package/dist/audit/cli/dispatch.js +14 -6
  19. package/dist/audit/cli/dispatch.js.map +1 -1
  20. package/dist/audit/cli/hybridDispatch.d.ts +3 -1
  21. package/dist/audit/cli/hybridDispatch.d.ts.map +1 -1
  22. package/dist/audit/cli/hybridDispatch.js +6 -0
  23. package/dist/audit/cli/hybridDispatch.js.map +1 -1
  24. package/dist/audit/cli/nextStepCommand.d.ts +0 -9
  25. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  26. package/dist/audit/cli/nextStepCommand.js +173 -92
  27. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  28. package/dist/audit/cli/nextStepHelpers.d.ts +11 -2
  29. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  30. package/dist/audit/cli/nextStepHelpers.js +56 -8
  31. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  32. package/dist/audit/cli/prepareDispatchCommand.d.ts.map +1 -1
  33. package/dist/audit/cli/prepareDispatchCommand.js +15 -9
  34. package/dist/audit/cli/prepareDispatchCommand.js.map +1 -1
  35. package/dist/audit/cli/prompts.d.ts +12 -32
  36. package/dist/audit/cli/prompts.d.ts.map +1 -1
  37. package/dist/audit/cli/prompts.js +19 -33
  38. package/dist/audit/cli/prompts.js.map +1 -1
  39. package/dist/audit/cli/providerConfirmationStep.d.ts +13 -5
  40. package/dist/audit/cli/providerConfirmationStep.d.ts.map +1 -1
  41. package/dist/audit/cli/providerConfirmationStep.js +47 -8
  42. package/dist/audit/cli/providerConfirmationStep.js.map +1 -1
  43. package/dist/audit/cli/quotaCommand.d.ts.map +1 -1
  44. package/dist/audit/cli/quotaCommand.js +16 -10
  45. package/dist/audit/cli/quotaCommand.js.map +1 -1
  46. package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
  47. package/dist/audit/cli/rollingAuditDispatch.js +14 -1
  48. package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
  49. package/dist/audit/cli/semanticReviewStep.d.ts +11 -1
  50. package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
  51. package/dist/audit/cli/semanticReviewStep.js +11 -15
  52. package/dist/audit/cli/semanticReviewStep.js.map +1 -1
  53. package/dist/audit/cli/validateCommand.d.ts.map +1 -1
  54. package/dist/audit/cli/validateCommand.js +3 -3
  55. package/dist/audit/cli/validateCommand.js.map +1 -1
  56. package/dist/audit/cli.js +3 -3
  57. package/dist/audit/cli.js.map +1 -1
  58. package/dist/audit/contracts/wrapperResponse.d.ts +6 -6
  59. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/advance.js +39 -7
  61. package/dist/audit/orchestrator/advance.js.map +1 -1
  62. package/dist/audit/orchestrator/advanceTypes.d.ts +52 -1
  63. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  64. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  65. package/dist/audit/orchestrator/executorRunners.js +9 -1
  66. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  67. package/dist/audit/orchestrator/intakeExecutors.d.ts +27 -3
  68. package/dist/audit/orchestrator/intakeExecutors.d.ts.map +1 -1
  69. package/dist/audit/orchestrator/intakeExecutors.js +119 -19
  70. package/dist/audit/orchestrator/intakeExecutors.js.map +1 -1
  71. package/dist/audit/orchestrator/nextStep.d.ts +7 -0
  72. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  73. package/dist/audit/orchestrator/nextStep.js +3 -0
  74. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  75. package/dist/audit/orchestrator/providerConfirmation.d.ts.map +1 -1
  76. package/dist/audit/orchestrator/providerConfirmation.js +0 -2
  77. package/dist/audit/orchestrator/providerConfirmation.js.map +1 -1
  78. package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
  79. package/dist/audit/orchestrator/rollingDispatch.js +2 -0
  80. package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
  81. package/dist/audit/orchestrator/state.d.ts +17 -0
  82. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  83. package/dist/audit/orchestrator/state.js +13 -1
  84. package/dist/audit/orchestrator/state.js.map +1 -1
  85. package/dist/audit/providers/claudeWorkerProvider.d.ts +10 -0
  86. package/dist/audit/providers/claudeWorkerProvider.d.ts.map +1 -0
  87. package/dist/audit/providers/claudeWorkerProvider.js +15 -0
  88. package/dist/audit/providers/claudeWorkerProvider.js.map +1 -0
  89. package/dist/audit/providers/index.d.ts.map +1 -1
  90. package/dist/audit/providers/index.js +2 -0
  91. package/dist/audit/providers/index.js.map +1 -1
  92. package/dist/audit/quota/index.d.ts +133 -128
  93. package/dist/audit/quota/index.d.ts.map +1 -1
  94. package/dist/audit/supervisor/sessionConfig.d.ts +3 -11
  95. package/dist/audit/supervisor/sessionConfig.d.ts.map +1 -1
  96. package/dist/audit/supervisor/sessionConfig.js +3 -25
  97. package/dist/audit/supervisor/sessionConfig.js.map +1 -1
  98. package/dist/audit/types/analyzerCapability.d.ts +6 -6
  99. package/dist/audit/types/externalAnalyzer.d.ts +10 -10
  100. package/dist/remediate/index.d.ts.map +1 -1
  101. package/dist/remediate/index.js +2 -2
  102. package/dist/remediate/index.js.map +1 -1
  103. package/dist/remediate/phases/plan.d.ts.map +1 -1
  104. package/dist/remediate/phases/plan.js +5 -4
  105. package/dist/remediate/phases/plan.js.map +1 -1
  106. package/dist/remediate/providers/claudeWorkerProvider.d.ts +11 -0
  107. package/dist/remediate/providers/claudeWorkerProvider.d.ts.map +1 -0
  108. package/dist/remediate/providers/claudeWorkerProvider.js +16 -0
  109. package/dist/remediate/providers/claudeWorkerProvider.js.map +1 -0
  110. package/dist/remediate/providers/index.d.ts.map +1 -1
  111. package/dist/remediate/providers/index.js +2 -0
  112. package/dist/remediate/providers/index.js.map +1 -1
  113. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  114. package/dist/remediate/steps/contractPipeline.js +9 -3
  115. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  116. package/dist/remediate/steps/dispatch/acceptNode.d.ts +1 -1
  117. package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -1
  118. package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -1
  119. package/dist/remediate/steps/dispatch/marshal.d.ts.map +1 -1
  120. package/dist/remediate/steps/dispatch/marshal.js +5 -4
  121. package/dist/remediate/steps/dispatch/marshal.js.map +1 -1
  122. package/dist/remediate/steps/dispatch/waveScheduling.d.ts +4 -2
  123. package/dist/remediate/steps/dispatch/waveScheduling.d.ts.map +1 -1
  124. package/dist/remediate/steps/dispatch/waveScheduling.js +33 -85
  125. package/dist/remediate/steps/dispatch/waveScheduling.js.map +1 -1
  126. package/dist/remediate/steps/nextStep.d.ts +21 -10
  127. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  128. package/dist/remediate/steps/nextStep.js +45 -25
  129. package/dist/remediate/steps/nextStep.js.map +1 -1
  130. package/dist/remediate/steps/sessionConfigLoad.d.ts +46 -0
  131. package/dist/remediate/steps/sessionConfigLoad.d.ts.map +1 -0
  132. package/dist/remediate/steps/sessionConfigLoad.js +39 -0
  133. package/dist/remediate/steps/sessionConfigLoad.js.map +1 -0
  134. package/dist/shared/config/resolveSessionConfig.d.ts +75 -0
  135. package/dist/shared/config/resolveSessionConfig.d.ts.map +1 -0
  136. package/dist/shared/config/resolveSessionConfig.js +125 -0
  137. package/dist/shared/config/resolveSessionConfig.js.map +1 -0
  138. package/dist/shared/dispatch/admissionLoop.d.ts +12 -12
  139. package/dist/shared/dispatch/coordinator.d.ts.map +1 -1
  140. package/dist/shared/dispatch/coordinator.js +52 -6
  141. package/dist/shared/dispatch/coordinator.js.map +1 -1
  142. package/dist/shared/dispatch/hybridDispatch.d.ts +6 -0
  143. package/dist/shared/dispatch/hybridDispatch.d.ts.map +1 -1
  144. package/dist/shared/dispatch/hybridDispatch.js +6 -0
  145. package/dist/shared/dispatch/hybridDispatch.js.map +1 -1
  146. package/dist/shared/dispatch/providerLaunchFinalize.d.ts +2 -1
  147. package/dist/shared/dispatch/providerLaunchFinalize.d.ts.map +1 -1
  148. package/dist/shared/dispatch/providerLaunchFinalize.js +123 -68
  149. package/dist/shared/dispatch/providerLaunchFinalize.js.map +1 -1
  150. package/dist/shared/dispatch/rollingDispatch.d.ts +69 -2
  151. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  152. package/dist/shared/dispatch/rollingDispatch.js +177 -7
  153. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  154. package/dist/shared/dispatch/unifiedRolling.d.ts +23 -0
  155. package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
  156. package/dist/shared/dispatch/unifiedRolling.js +2 -0
  157. package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
  158. package/dist/shared/friction/stepBoundaryCapture.d.ts +52 -1
  159. package/dist/shared/friction/stepBoundaryCapture.d.ts.map +1 -1
  160. package/dist/shared/friction/stepBoundaryCapture.js +87 -0
  161. package/dist/shared/friction/stepBoundaryCapture.js.map +1 -1
  162. package/dist/shared/index.d.ts +20 -10
  163. package/dist/shared/index.d.ts.map +1 -1
  164. package/dist/shared/index.js +20 -6
  165. package/dist/shared/index.js.map +1 -1
  166. package/dist/shared/io/stateDir.d.ts +27 -0
  167. package/dist/shared/io/stateDir.d.ts.map +1 -0
  168. package/dist/shared/io/stateDir.js +40 -0
  169. package/dist/shared/io/stateDir.js.map +1 -0
  170. package/dist/shared/providers/auditorSources.d.ts +169 -0
  171. package/dist/shared/providers/auditorSources.d.ts.map +1 -0
  172. package/dist/shared/providers/auditorSources.js +453 -0
  173. package/dist/shared/providers/auditorSources.js.map +1 -0
  174. package/dist/shared/providers/claudeWorkerProvider.d.ts +71 -0
  175. package/dist/shared/providers/claudeWorkerProvider.d.ts.map +1 -0
  176. package/dist/shared/providers/claudeWorkerProvider.js +133 -0
  177. package/dist/shared/providers/claudeWorkerProvider.js.map +1 -0
  178. package/dist/shared/providers/providerConfirmation.d.ts +3 -20
  179. package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
  180. package/dist/shared/providers/providerConfirmation.js +27 -40
  181. package/dist/shared/providers/providerConfirmation.js.map +1 -1
  182. package/dist/shared/providers/providerFactory.d.ts +13 -1
  183. package/dist/shared/providers/providerFactory.d.ts.map +1 -1
  184. package/dist/shared/providers/providerFactory.js +12 -0
  185. package/dist/shared/providers/providerFactory.js.map +1 -1
  186. package/dist/shared/providers/proxyCatalog.d.ts +95 -0
  187. package/dist/shared/providers/proxyCatalog.d.ts.map +1 -0
  188. package/dist/shared/providers/proxyCatalog.js +426 -0
  189. package/dist/shared/providers/proxyCatalog.js.map +1 -0
  190. package/dist/shared/providers/sharedProviderConfirmation.d.ts +264 -75
  191. package/dist/shared/providers/sharedProviderConfirmation.d.ts.map +1 -1
  192. package/dist/shared/providers/sharedProviderConfirmation.js +534 -113
  193. package/dist/shared/providers/sharedProviderConfirmation.js.map +1 -1
  194. package/dist/shared/quota/apiPool.d.ts +34 -11
  195. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  196. package/dist/shared/quota/apiPool.js +52 -23
  197. package/dist/shared/quota/apiPool.js.map +1 -1
  198. package/dist/shared/quota/capacity.d.ts +79 -50
  199. package/dist/shared/quota/capacity.d.ts.map +1 -1
  200. package/dist/shared/quota/capacity.js +40 -5
  201. package/dist/shared/quota/capacity.js.map +1 -1
  202. package/dist/shared/quota/errorParsing.d.ts +39 -0
  203. package/dist/shared/quota/errorParsing.d.ts.map +1 -1
  204. package/dist/shared/quota/errorParsing.js +76 -0
  205. package/dist/shared/quota/errorParsing.js.map +1 -1
  206. package/dist/shared/quota/hostPool.d.ts +107 -0
  207. package/dist/shared/quota/hostPool.d.ts.map +1 -0
  208. package/dist/shared/quota/hostPool.js +103 -0
  209. package/dist/shared/quota/hostPool.js.map +1 -0
  210. package/dist/shared/quota/quotaSource.d.ts +2 -2
  211. package/dist/shared/types/auditorDescriptor.d.ts +120 -0
  212. package/dist/shared/types/auditorDescriptor.d.ts.map +1 -0
  213. package/dist/shared/types/auditorDescriptor.js +28 -0
  214. package/dist/shared/types/auditorDescriptor.js.map +1 -0
  215. package/dist/shared/types/providerConfirmation.d.ts +64 -6
  216. package/dist/shared/types/providerConfirmation.d.ts.map +1 -1
  217. package/dist/shared/types/providerConfirmation.js +1 -1
  218. package/dist/shared/types/rollingDispatch.d.ts +45 -1
  219. package/dist/shared/types/rollingDispatch.d.ts.map +1 -1
  220. package/dist/shared/types/sessionConfig.d.ts +149 -67
  221. package/dist/shared/types/sessionConfig.d.ts.map +1 -1
  222. package/dist/shared/types/sessionConfig.js +87 -2
  223. package/dist/shared/types/sessionConfig.js.map +1 -1
  224. package/dist/shared/validation/sessionConfig.d.ts +26 -14
  225. package/dist/shared/validation/sessionConfig.d.ts.map +1 -1
  226. package/dist/shared/validation/sessionConfig.js +95 -69
  227. package/dist/shared/validation/sessionConfig.js.map +1 -1
  228. package/docs/audit-pkg/contracts.md +4 -4
  229. package/docs/audit-pkg/operator-guide.md +43 -24
  230. package/package.json +1 -1
  231. package/skills/audit-code/SKILL.md +17 -14
  232. package/skills/audit-code/audit-code.prompt.md +17 -16
  233. package/wrapper/audit-code-wrapper-install-hosts.mjs +6 -10
  234. package/wrapper/remediate-code-wrapper-install-hosts.mjs +4 -8
  235. package/dist/shared/quota/repairProxyRegistry.d.ts +0 -84
  236. package/dist/shared/quota/repairProxyRegistry.d.ts.map +0 -1
  237. package/dist/shared/quota/repairProxyRegistry.js +0 -144
  238. package/dist/shared/quota/repairProxyRegistry.js.map +0 -1
@@ -0,0 +1,453 @@
1
+ import { accessSync, constants, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { resolveAuditCodeStateDir } from "../io/stateDir.js";
4
+ import { spawnSyncHidden } from "../tooling/exec.js";
5
+ import { validateSessionConfig } from "../validation/sessionConfig.js";
6
+ import { populateProxyCatalog, readProxyCatalog, } from "./proxyCatalog.js";
7
+ import { commandExists } from "./providerPathGuard.js";
8
+ /**
9
+ * The machine-level declaration file: the backends the OPERATOR owns, hand-authored
10
+ * like `session-config.json`. Deliberately NOT id-keyed and deliberately NOT named
11
+ * like the POPULATE cache (`catalog-cache.json`, `proxyCatalog.ts` — the
12
+ * `catalog-<auditor-id>.json` name this comment once reserved landed WITHOUT the
13
+ * auditor-id key; see the rationale there) — squatting the cache name would turn
14
+ * this read into a direct cache read, violating never-inherit by filename collision.
15
+ *
16
+ * A declaration is not a cache: it is operator INTENT, not a prior auditor's resolved
17
+ * state. Reading it and intersecting it with live ambient reach does not inherit
18
+ * anything ([[capability-is-per-auditor-not-per-audit]]).
19
+ */
20
+ export const SOURCE_DECLARATION_FILENAME = "sources-declared.json";
21
+ /**
22
+ * Default launcher command per CLI-backed dispatchable source, mirroring each
23
+ * provider's own `config.command ?? "<default>"` fallback (`codexProvider.ts:59`,
24
+ * `opencodeProvider.ts:58`, `agyProvider.ts:67-69`). A source overrides it via
25
+ * `endpoint`, which IS the launcher command for CLI providers
26
+ * (`DispatchableSource.endpoint` docs, `sessionConfig.ts`).
27
+ */
28
+ const CLI_DEFAULT_COMMAND = {
29
+ codex: "codex",
30
+ opencode: "opencode",
31
+ agy: "agy",
32
+ };
33
+ /** Gated for the 2026-07-18 agy sunset: `agy` falls back to a legacy `gemini` binary. */
34
+ const AGY_LEGACY_COMMAND = "gemini";
35
+ function defaultFileReadable(path) {
36
+ try {
37
+ accessSync(path, constants.R_OK);
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ function defaultReadDeclarationFile(path) {
45
+ try {
46
+ return readFileSync(path, "utf8");
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ /**
53
+ * Default {@link AmbientSourceDeps.probeHttpReachable}: a short-timeout
54
+ * `GET <url>` run in a hidden node child so the check stays SYNCHRONOUS (resolve is
55
+ * sync by design — see the populate/resolve split) without blocking the event loop
56
+ * machinery this process owns. Exit 0 ⇔ HTTP 2xx within the 750ms budget.
57
+ */
58
+ function defaultProbeHttpReachable(url) {
59
+ const script = "const [url] = process.argv.slice(1);" +
60
+ "fetch(url, { signal: AbortSignal.timeout(750) })" +
61
+ ".then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1));";
62
+ const result = spawnSyncHidden(process.execPath, ["-e", script, url], {
63
+ timeout: 2_000,
64
+ });
65
+ return result.status === 0;
66
+ }
67
+ /** The source's stable id, matching `DispatchableSource.id`'s documented default. */
68
+ function sourceId(source) {
69
+ return source.id ?? `${source.provider}:${source.model ?? source.endpoint ?? "?"}`;
70
+ }
71
+ /** Resolve the declaration file path for this machine (state dir via `io/stateDir.ts`). */
72
+ export function resolveSourceDeclarationPath(homeDir) {
73
+ return join(resolveAuditCodeStateDir(homeDir), SOURCE_DECLARATION_FILENAME);
74
+ }
75
+ /**
76
+ * Read the operator's machine-level source declaration.
77
+ *
78
+ * Degrades to `[]` on absent / unparseable / structurally-invalid input — never
79
+ * throws. This read sits on the path of every `next-step`, so a malformed file must
80
+ * not be able to fail a run (the two-tier dependency policy's "wrap the parser so
81
+ * malformed input degrades to empty"). Validation reuses `validateSessionConfig`, so
82
+ * the declaration is held to exactly the same bar as a `--auditor sources[]`.
83
+ */
84
+ export function readSourceDeclaration(deps = {}) {
85
+ const path = resolveSourceDeclarationPath(deps.homeDir);
86
+ const raw = (deps.readDeclarationFile ?? defaultReadDeclarationFile)(path);
87
+ if (raw === null)
88
+ return [];
89
+ let parsed;
90
+ try {
91
+ parsed = JSON.parse(raw);
92
+ }
93
+ catch {
94
+ return [];
95
+ }
96
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
97
+ return [];
98
+ }
99
+ const sources = parsed.sources;
100
+ if (sources === undefined)
101
+ return [];
102
+ // Hold the declaration to the same validator both other boundaries use. Any
103
+ // error-severity issue ⇒ degrade to empty rather than admit a half-checked pool.
104
+ const issues = validateSessionConfig({ sources });
105
+ if (issues.some((issue) => issue.severity === "error"))
106
+ return [];
107
+ return sources;
108
+ }
109
+ /**
110
+ * Read the optional `repair_proxy` block from the machine declaration. Tolerant like
111
+ * {@link readSourceDeclaration}: an absent / unparseable file or a missing key is
112
+ * simply `{declaration: null}`; a PRESENT-but-malformed block degrades to lane-absent
113
+ * WITH a reason (surfaced via `resolveAmbientSources`' `dropped[]`), never a throw.
114
+ * Malformed optional knobs (`top_k` / `cost_per_mtok`) are dropped individually — a
115
+ * bad tuning value must not cost the operator the whole lane.
116
+ */
117
+ export function readRepairProxyDeclaration(deps = {}) {
118
+ const path = resolveSourceDeclarationPath(deps.homeDir);
119
+ const raw = (deps.readDeclarationFile ?? defaultReadDeclarationFile)(path);
120
+ if (raw === null)
121
+ return { declaration: null };
122
+ let parsed;
123
+ try {
124
+ parsed = JSON.parse(raw);
125
+ }
126
+ catch {
127
+ return { declaration: null };
128
+ }
129
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
130
+ return { declaration: null };
131
+ }
132
+ const block = parsed.repair_proxy;
133
+ if (block === undefined)
134
+ return { declaration: null };
135
+ if (typeof block !== "object" || block === null || Array.isArray(block)) {
136
+ return {
137
+ declaration: null,
138
+ reason: "repair_proxy must be a JSON object with an endpoint — fix the declaration.",
139
+ };
140
+ }
141
+ const { endpoint, top_k, cost_per_mtok } = block;
142
+ if (typeof endpoint !== "string" || endpoint.trim().length === 0) {
143
+ return {
144
+ declaration: null,
145
+ reason: "repair_proxy.endpoint must be a non-empty url string — fix the declaration.",
146
+ };
147
+ }
148
+ const declaration = {
149
+ // Trailing slashes stripped so the reach probe, the populate cache's stored
150
+ // endpoint, and the expanded sources all compare on one canonical form.
151
+ endpoint: endpoint.trim().replace(/\/+$/u, ""),
152
+ };
153
+ if (typeof top_k === "number" && Number.isInteger(top_k) && top_k > 0) {
154
+ declaration.top_k = top_k;
155
+ }
156
+ if (typeof cost_per_mtok === "number" &&
157
+ Number.isFinite(cost_per_mtok) &&
158
+ cost_per_mtok >= 0) {
159
+ declaration.cost_per_mtok = cost_per_mtok;
160
+ }
161
+ return { declaration };
162
+ }
163
+ /**
164
+ * The default populate fetch: time-boxed so a routable-but-dead proxy cannot hang a
165
+ * `next-step` at the Gate-0 build (network-tolerant means bounded, not just caught).
166
+ */
167
+ const populateFetchWithTimeout = (input, init) => fetch(input, { ...init, signal: AbortSignal.timeout(5_000) });
168
+ /**
169
+ * POPULATE the declared repair-proxy lane (plan §populate-vs-resolve): read the
170
+ * machine declaration's `repair_proxy` block and, when present, fetch its registry
171
+ * into the machine-level populate cache ({@link populateProxyCatalog}). This is the
172
+ * network half the resolve path must never run — call it at Gate-0 build time (once
173
+ * per run) or on explicit refresh, NEVER from `resolveAmbientSources`.
174
+ *
175
+ * "Present + reachable" gating is the fetch itself: the registry GET is both the
176
+ * liveness proof and the payload, so a separate pre-probe would only double the
177
+ * network. Never throws: no declared lane ⇒ `null`; a failed/unreachable fetch ⇒
178
+ * `{written:false, reason}` and any prior cache is left untouched — the lane then
179
+ * resolves from the existing cache or unexpanded with its own `dropped[]` reason,
180
+ * degrading Gate-0, never blocking it.
181
+ */
182
+ export async function populateDeclaredProxyCatalog(deps = {}) {
183
+ const { declaration } = readRepairProxyDeclaration(deps);
184
+ if (declaration === null)
185
+ return null;
186
+ return populateProxyCatalog({
187
+ endpoint: declaration.endpoint,
188
+ ...(declaration.top_k !== undefined ? { topK: declaration.top_k } : {}),
189
+ ...(declaration.cost_per_mtok !== undefined
190
+ ? { costPerMtok: declaration.cost_per_mtok }
191
+ : {}),
192
+ fetchImpl: deps.fetchImpl ?? populateFetchWithTimeout,
193
+ ...(deps.homeDir !== undefined ? { homeDir: deps.homeDir } : {}),
194
+ });
195
+ }
196
+ /**
197
+ * Populate the proxy catalog ONLY when the resolve half would otherwise drop the
198
+ * lane for it: a `repair_proxy` is declared but the cache is absent or was fetched
199
+ * from a different endpoint. Bounded by construction — after one success the cache
200
+ * exists and this is a cheap read — so a draw with no Gate-0 build moment (remediate)
201
+ * can call it on every config load without a per-load network fetch. Freshness
202
+ * (TTL / explicit refresh) is deliberately NOT this function's job (backlog).
203
+ * [[silent-fail-closed-on-one-draw]] — both draws must trigger populate, not just audit.
204
+ */
205
+ export async function populateProxyCatalogIfMissing(deps = {}) {
206
+ const { declaration } = readRepairProxyDeclaration(deps);
207
+ if (declaration === null)
208
+ return null;
209
+ const cache = readProxyCatalog(deps);
210
+ if (cache !== null &&
211
+ cache.endpoint.replace(/\/+$/u, "") === declaration.endpoint) {
212
+ return {
213
+ sources: cache.sources,
214
+ written: false,
215
+ reason: "populate cache already present",
216
+ dropped: [],
217
+ };
218
+ }
219
+ return populateDeclaredProxyCatalog(deps);
220
+ }
221
+ /**
222
+ * Can THIS process prove it can reach this declared source?
223
+ *
224
+ * The spec's rule is `declared ∩ ambient-verifiable-by-this-process` — a declared lane
225
+ * enters the pool only if this process PROVES reach, never `declared ∪ stored`. Each
226
+ * check verifies what the declaration actually asserts:
227
+ *
228
+ * - `api_key_env` → the env var is present and non-empty
229
+ * - CLI provider → its launcher resolves on PATH
230
+ * - `subprocess-template` → its `command_template[0]` resolves on PATH
231
+ * - `credentials_path` → the file is readable
232
+ * - inline `api_key` → NOT verifiable (see below)
233
+ *
234
+ * **Inline `api_key` is refused.** Possessing a credential proves nothing about reach:
235
+ * the endpoint may be dead, the key revoked. It is also the one shape an operator can
236
+ * always choose, so admitting it would make the whole rule opt-out by construction —
237
+ * and it is an always-passes lane whose only catcher (the reactive `lies reachably`
238
+ * quarantine) is G5, not yet built. A stale free-tier declaration would be admitted as
239
+ * reachable and, under cost-first routing (λ=0), take EVERY packet first and fail them
240
+ * all. A public constant lives in an env var fine.
241
+ *
242
+ * NOTE — this is the repo's first ambient CREDENTIAL probe, and it deliberately
243
+ * inverts the policy stated at `providerFactory.ts` ("env presence is intentionally not
244
+ * probed here"). That policy governs LAUNCH-TIME resolution; this is REACH declaration.
245
+ * The two are different questions; see that comment's pointer back here.
246
+ */
247
+ export function verifySourceReach(source, deps = {}) {
248
+ const env = deps.env ?? process.env;
249
+ const exists = deps.commandExists ?? commandExists;
250
+ const readable = deps.fileReadable ?? defaultFileReadable;
251
+ if (source.credentials_path !== undefined) {
252
+ if (typeof source.credentials_path !== "string" || !readable(source.credentials_path)) {
253
+ return {
254
+ verified: false,
255
+ reason: `credentials_path "${String(source.credentials_path)}" is not readable.`,
256
+ };
257
+ }
258
+ }
259
+ switch (source.provider) {
260
+ case "openai-compatible": {
261
+ if (!source.endpoint?.trim()) {
262
+ return { verified: false, reason: "openai-compatible source has no endpoint (base_url)." };
263
+ }
264
+ if (!source.model?.trim()) {
265
+ return { verified: false, reason: "openai-compatible source has no model." };
266
+ }
267
+ if (source.api_key !== undefined && source.api_key_env === undefined) {
268
+ return {
269
+ verified: false,
270
+ reason: "inline api_key is not ambient-verifiable (it proves possession, not reach) — move the key into an env var and declare api_key_env.",
271
+ };
272
+ }
273
+ if (!source.api_key_env?.trim()) {
274
+ return { verified: false, reason: "openai-compatible source has no api_key_env." };
275
+ }
276
+ if (!(env[source.api_key_env] ?? "").trim()) {
277
+ return {
278
+ verified: false,
279
+ reason: `env var "${source.api_key_env}" is unset or empty in this process.`,
280
+ };
281
+ }
282
+ return { verified: true };
283
+ }
284
+ case "codex":
285
+ case "opencode":
286
+ case "agy": {
287
+ const declared = source.endpoint?.trim();
288
+ if (declared) {
289
+ return exists(declared)
290
+ ? { verified: true }
291
+ : { verified: false, reason: `launcher "${declared}" is not on PATH.` };
292
+ }
293
+ const fallback = CLI_DEFAULT_COMMAND[source.provider];
294
+ if (exists(fallback))
295
+ return { verified: true };
296
+ // Gated for the 2026-07-18 sunset, mirroring agyProvider's own fallback.
297
+ if (source.provider === "agy" && exists(AGY_LEGACY_COMMAND)) {
298
+ return { verified: true };
299
+ }
300
+ return { verified: false, reason: `launcher "${fallback}" is not on PATH.` };
301
+ }
302
+ case "subprocess-template": {
303
+ const template = source.parameters?.command_template;
304
+ const launcher = Array.isArray(template) ? template[0] : undefined;
305
+ if (typeof launcher !== "string" || !launcher.trim()) {
306
+ return {
307
+ verified: false,
308
+ reason: "subprocess-template source has no parameters.command_template[0] to probe.",
309
+ };
310
+ }
311
+ return exists(launcher)
312
+ ? { verified: true }
313
+ : { verified: false, reason: `launcher "${launcher}" is not on PATH.` };
314
+ }
315
+ case "worker-command": {
316
+ // worker-command runs `task.worker_command` — a PER-TASK argv with no
317
+ // source-level launcher, so there is nothing to probe ahead of dispatch.
318
+ return {
319
+ verified: false,
320
+ reason: "worker-command reach is per-task (task.worker_command), so it is not declarable as an ambient source.",
321
+ };
322
+ }
323
+ case "claude-worker": {
324
+ // The proxied isolated Claude-harness worker: its reach IS the repair-proxy's
325
+ // liveness (endpoint = the proxy url). Normally these sources come pre-verified
326
+ // from the populate cache via the `repair_proxy` lane; a hand-declared one is
327
+ // held to the same bar. Inline api_key refused for the same possession≠reach
328
+ // reasons as openai-compatible above (the loopback proxy needs no key anyway).
329
+ if (!source.endpoint?.trim()) {
330
+ return {
331
+ verified: false,
332
+ reason: "claude-worker source has no endpoint (the repair-proxy url).",
333
+ };
334
+ }
335
+ if (!source.model?.trim()) {
336
+ return { verified: false, reason: "claude-worker source has no model." };
337
+ }
338
+ if (source.api_key !== undefined) {
339
+ return {
340
+ verified: false,
341
+ reason: "inline api_key is not ambient-verifiable (it proves possession, not reach) — the proxied lane needs no inline key; remove it (declare api_key_env if the proxy requires one).",
342
+ };
343
+ }
344
+ const probe = deps.probeHttpReachable ?? defaultProbeHttpReachable;
345
+ const endpoint = source.endpoint.trim().replace(/\/+$/u, "");
346
+ return probe(`${endpoint}/registry`)
347
+ ? { verified: true }
348
+ : {
349
+ verified: false,
350
+ reason: `repair-proxy at "${endpoint}" failed the liveness probe (GET /registry).`,
351
+ };
352
+ }
353
+ }
354
+ }
355
+ /**
356
+ * `declared ∩ ambient-verifiable` — the dispatch pool THIS process can actually reach.
357
+ *
358
+ * Resolved IN-PROCESS, never routed through the conversational host. That is a
359
+ * correctness property, not an optimization: `openAiCompatibleProvider` reads its key
360
+ * from `process.env` AT LAUNCH, so resolving here makes the reach check and the launch
361
+ * read the SAME env — they cannot disagree. A host relay would open a gap between what
362
+ * was promised and what is true at the moment of use (CLAUDE.md, *Auditor-agnostic
363
+ * robustness*).
364
+ *
365
+ * It is also what makes concurrent multi-IDE runs safe with no identity machinery: each
366
+ * IDE spawns its own audit-tools process, which inherits THAT IDE's env, so each
367
+ * intersects the same machine-level declaration against its own real reach and gets its
368
+ * own answer. Nothing is shared, so nothing can contaminate
369
+ * ([[capability-is-per-auditor-not-per-audit]]).
370
+ */
371
+ export function resolveAmbientSources(deps = {}) {
372
+ const declared = readSourceDeclaration(deps);
373
+ const sources = [];
374
+ const dropped = [];
375
+ for (const source of declared) {
376
+ const reach = verifySourceReach(source, deps);
377
+ if (reach.verified)
378
+ sources.push(source);
379
+ else
380
+ dropped.push({ id: sourceId(source), reason: reach.reason });
381
+ }
382
+ resolveRepairProxyLane(deps, sources, dropped);
383
+ return { sources, dropped };
384
+ }
385
+ /**
386
+ * The repair-proxy lane of the resolve half (plan §populate-vs-resolve): a declared
387
+ * `repair_proxy` whose liveness probe passes expands from the POPULATE CACHE — never
388
+ * a mid-resolve fetch. Fail-open, mirroring the declared-source contract: every
389
+ * outcome short of expansion lands in `dropped[]` with an operator-facing reason
390
+ * (malformed declaration / probe failure / cache absent-stale-empty), so the lane is
391
+ * never silently discarded.
392
+ */
393
+ function resolveRepairProxyLane(deps, sources, dropped) {
394
+ const { declaration, reason } = readRepairProxyDeclaration(deps);
395
+ if (reason !== undefined) {
396
+ dropped.push({ id: "repair-proxy", reason });
397
+ return;
398
+ }
399
+ if (declaration === null)
400
+ return;
401
+ const { endpoint } = declaration;
402
+ const laneId = `repair-proxy:${endpoint}`;
403
+ const probe = deps.probeHttpReachable ?? defaultProbeHttpReachable;
404
+ if (!probe(`${endpoint}/registry`)) {
405
+ dropped.push({
406
+ id: laneId,
407
+ reason: `repair-proxy at "${endpoint}" failed the liveness probe (GET /registry) — lane dropped for this invocation.`,
408
+ });
409
+ return;
410
+ }
411
+ const catalog = readProxyCatalog(deps);
412
+ if (catalog === null) {
413
+ dropped.push({
414
+ id: laneId,
415
+ reason: "repair-proxy is reachable but the populate cache is absent/invalid — run the registry populate (populateProxyCatalog) to expand this lane.",
416
+ });
417
+ return;
418
+ }
419
+ if (catalog.endpoint.replace(/\/+$/u, "") !== endpoint) {
420
+ dropped.push({
421
+ id: laneId,
422
+ reason: `populate cache was fetched from "${catalog.endpoint}", not the declared "${endpoint}" — re-run the registry populate.`,
423
+ });
424
+ return;
425
+ }
426
+ if (catalog.sources.length === 0) {
427
+ dropped.push({
428
+ id: laneId,
429
+ reason: "repair-proxy registry expansion is empty (no reachable+keyed backend models at populate time) — lane present but unexpanded.",
430
+ });
431
+ return;
432
+ }
433
+ // Declared-wins dedup: an expanded lane whose (backend_provider, model)
434
+ // identity a DECLARED source already covers is skipped, so one pool identity
435
+ // never maps to two sources (the launch bridge's pool→source map is 1:1 by
436
+ // assumption — a duplicate would arbitrate the transport by silent map-order
437
+ // clobber). The operator's explicit lane always beats auto-expansion; routing
438
+ // through the proxy for that model is still available by declaring the
439
+ // claude-worker source explicitly.
440
+ const declaredIdentities = new Set(sources.map((s) => `${s.backend_provider ?? s.provider}/${s.model ?? ""}`));
441
+ for (const expanded of catalog.sources) {
442
+ const identity = `${expanded.backend_provider ?? expanded.provider}/${expanded.model ?? ""}`;
443
+ if (declaredIdentities.has(identity)) {
444
+ dropped.push({
445
+ id: sourceId(expanded),
446
+ reason: `expanded lane skipped — a declared source already covers backend identity "${identity}" (declared wins over registry expansion).`,
447
+ });
448
+ continue;
449
+ }
450
+ sources.push(expanded);
451
+ }
452
+ }
453
+ //# sourceMappingURL=auditorSources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditorSources.js","sourceRoot":"","sources":["../../../src/shared/providers/auditorSources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AA0CnE;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAqC;IAC5D,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,yFAAyF;AACzF,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC,SAAS,mBAAmB,CAAC,IAAY;IACvC,I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AO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { FreshSessionProvider, LaunchFreshSessionInput } from "./types.js";
2
+ import type { ClaudeWorkerConfig } from "../types/sessionConfig.js";
3
+ import { spawnLoggedCommand } from "./spawnLoggedCommand.js";
4
+ export declare const CLAUDE_WORKER_PROVIDER_NAME: "claude-worker";
5
+ /**
6
+ * The explicit DUMMY key presented to a proxied spawn. The loopback repair-proxy
7
+ * needs no key, and an ambient real `ANTHROPIC_API_KEY` must NEVER be silently
8
+ * presented to a proxied spawn — so the overlay always sets this sentinel rather
9
+ * than leaving the variable to inherit from the parent env.
10
+ */
11
+ export declare const CLAUDE_WORKER_DUMMY_API_KEY = "audit-tools-claude-worker";
12
+ /**
13
+ * Per-orchestrator tuning for the otherwise-identical claude-worker provider —
14
+ * mirrors {@link ClaudeCodeProviderOptions} minus the nested-session guard message
15
+ * (this class has no guard; see the class doc). The only intended delta between
16
+ * orchestrators is the skip-permissions default.
17
+ */
18
+ export interface ClaudeWorkerProviderOptions {
19
+ /**
20
+ * Whether to default to `--dangerously-skip-permissions` when the config does
21
+ * not set `dangerously_skip_permissions` explicitly. The auditor keeps the safe
22
+ * `false`; the autonomous remediator passes `true` (it applies changes
23
+ * unattended and cannot pause mid-run). An explicit config value wins.
24
+ */
25
+ skipPermissionsDefault?: boolean;
26
+ }
27
+ /**
28
+ * The `projects` key the Claude CLI trusts a repo under: the absolute repo root
29
+ * with FORWARD slashes on every platform (live probe: the trust warning referenced
30
+ * `projects["C:/Code/audit-tools"].hasTrustDialogAccepted` on win32). Trailing
31
+ * separators are stripped so the key matches the CLI's cwd-derived form.
32
+ */
33
+ export declare function claudeWorkerTrustProjectKey(repoRoot: string): string;
34
+ /**
35
+ * claude-worker backend — the proxied, ISOLATED, per-packet-routed Claude-harness
36
+ * worker (the kind-1 launch transport,
37
+ * docs/reviews/commit3-proxy-kind1-transport-plan-2026-07-16.md). It spawns
38
+ * `claude -p` with a REQUIRED `ANTHROPIC_BASE_URL` overlay pointing at the
39
+ * repair-proxy, a dummy `ANTHROPIC_API_KEY` (never the ambient real key), an
40
+ * isolated per-launch `CLAUDE_CONFIG_DIR`, and `--model
41
+ * <backend_provider>/<model>` — the namespace string the proxy routes on,
42
+ * composed at launch for argv only (it never enters the quota identity).
43
+ *
44
+ * Deliberately NO nested-session guard: this class is NOT `claude-code` (the
45
+ * conversation host) wearing a flag — isolation is its CONSTRUCTOR INVARIANT, not
46
+ * a guard exception. Construction throws unless endpoint/backend_provider/model
47
+ * are present, so every spawn is proxy-fronted with a scrubbed parent env
48
+ * (spawnLoggedCommand strips `CLAUDECODE`/`CLAUDE_CODE*`; `CLAUDE_CONFIG_DIR`
49
+ * survives the scrub and is overlaid per launch) and can safely run from inside a
50
+ * live Claude Code session. The `claude-code` host provider KEEPS its blanket
51
+ * guard, and all four in-session refusal layers key on `claude-code` and never
52
+ * see this name — no guard is refined for this class to exist.
53
+ */
54
+ export declare class ClaudeWorkerProvider implements FreshSessionProvider {
55
+ name: "claude-worker";
56
+ private readonly config;
57
+ private readonly endpoint;
58
+ private readonly backendProvider;
59
+ private readonly model;
60
+ private readonly launchCommand;
61
+ private readonly skipPermissionsDefault;
62
+ constructor(config?: ClaudeWorkerConfig, options?: ClaudeWorkerProviderOptions, launchCommand?: typeof spawnLoggedCommand);
63
+ /**
64
+ * Create the per-launch isolated `CLAUDE_CONFIG_DIR` and mechanically pre-seed
65
+ * trust for the node's repo root, so the spawned harness never stalls on the
66
+ * interactive trust dialog (tool-enforced, never host-remembered).
67
+ */
68
+ private prepareIsolatedConfigDir;
69
+ launch(input: LaunchFreshSessionInput): Promise<import("./types.js").LaunchFreshSessionResult>;
70
+ }
71
+ //# sourceMappingURL=claudeWorkerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudeWorkerProvider.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/claudeWorkerProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAU7D,eAAO,MAAM,2BAA2B,EAAG,eAAwB,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpE;AAqBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,oBAAqB,YAAW,oBAAoB;IAC/D,IAAI,kBAA+B;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAU;gBAG/C,MAAM,GAAE,kBAAuB,EAC/B,OAAO,GAAE,2BAAgC,EACzC,aAAa,GAAE,OAAO,kBAAuC;IAa/D;;;;OAIG;YACW,wBAAwB;IAuBhC,MAAM,CAAC,KAAK,EAAE,uBAAuB;CA4C5C"}