audit-tools 0.33.0 → 0.33.3
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.
- package/README.md +7 -0
- package/dist/audit/cli/args.d.ts.map +1 -1
- package/dist/audit/cli/args.js +3 -0
- package/dist/audit/cli/args.js.map +1 -1
- package/dist/audit/cli/hybridDispatch.d.ts.map +1 -1
- package/dist/audit/cli/hybridDispatch.js +5 -0
- package/dist/audit/cli/hybridDispatch.js.map +1 -1
- package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
- package/dist/audit/cli/nextStepCommand.js +23 -1
- package/dist/audit/cli/nextStepCommand.js.map +1 -1
- package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
- package/dist/audit/cli/rollingAuditDispatch.js +14 -1
- package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
- package/dist/audit/cli.js +3 -3
- package/dist/audit/cli.js.map +1 -1
- package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
- package/dist/audit/orchestrator/rollingDispatch.js +2 -0
- package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
- package/dist/audit/providers/claudeWorkerProvider.d.ts +10 -0
- package/dist/audit/providers/claudeWorkerProvider.d.ts.map +1 -0
- package/dist/audit/providers/claudeWorkerProvider.js +15 -0
- package/dist/audit/providers/claudeWorkerProvider.js.map +1 -0
- package/dist/audit/providers/index.d.ts.map +1 -1
- package/dist/audit/providers/index.js +2 -0
- package/dist/audit/providers/index.js.map +1 -1
- package/dist/audit/quota/index.d.ts +15 -10
- package/dist/audit/quota/index.d.ts.map +1 -1
- package/dist/remediate/index.d.ts.map +1 -1
- package/dist/remediate/index.js +2 -2
- package/dist/remediate/index.js.map +1 -1
- package/dist/remediate/providers/claudeWorkerProvider.d.ts +11 -0
- package/dist/remediate/providers/claudeWorkerProvider.d.ts.map +1 -0
- package/dist/remediate/providers/claudeWorkerProvider.js +16 -0
- package/dist/remediate/providers/claudeWorkerProvider.js.map +1 -0
- package/dist/remediate/providers/index.d.ts.map +1 -1
- package/dist/remediate/providers/index.js +2 -0
- package/dist/remediate/providers/index.js.map +1 -1
- package/dist/remediate/steps/dispatch/acceptNode.d.ts +1 -1
- package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -1
- package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -1
- package/dist/remediate/steps/nextStep.d.ts +21 -0
- package/dist/remediate/steps/nextStep.d.ts.map +1 -1
- package/dist/remediate/steps/nextStep.js +21 -2
- package/dist/remediate/steps/nextStep.js.map +1 -1
- package/dist/remediate/steps/sessionConfigLoad.d.ts.map +1 -1
- package/dist/remediate/steps/sessionConfigLoad.js +8 -1
- package/dist/remediate/steps/sessionConfigLoad.js.map +1 -1
- package/dist/shared/config/resolveSessionConfig.d.ts +6 -3
- package/dist/shared/config/resolveSessionConfig.d.ts.map +1 -1
- package/dist/shared/config/resolveSessionConfig.js +21 -1
- package/dist/shared/config/resolveSessionConfig.js.map +1 -1
- package/dist/shared/dispatch/coordinator.d.ts.map +1 -1
- package/dist/shared/dispatch/coordinator.js +52 -6
- package/dist/shared/dispatch/coordinator.js.map +1 -1
- package/dist/shared/dispatch/hybridDispatch.d.ts +6 -0
- package/dist/shared/dispatch/hybridDispatch.d.ts.map +1 -1
- package/dist/shared/dispatch/hybridDispatch.js +6 -0
- package/dist/shared/dispatch/hybridDispatch.js.map +1 -1
- package/dist/shared/dispatch/providerLaunchFinalize.d.ts +2 -1
- package/dist/shared/dispatch/providerLaunchFinalize.d.ts.map +1 -1
- package/dist/shared/dispatch/providerLaunchFinalize.js +123 -68
- package/dist/shared/dispatch/providerLaunchFinalize.js.map +1 -1
- package/dist/shared/dispatch/rollingDispatch.d.ts +69 -2
- package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
- package/dist/shared/dispatch/rollingDispatch.js +177 -7
- package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
- package/dist/shared/dispatch/unifiedRolling.d.ts +23 -0
- package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
- package/dist/shared/dispatch/unifiedRolling.js +2 -0
- package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
- package/dist/shared/friction/stepBoundaryCapture.d.ts +31 -1
- package/dist/shared/friction/stepBoundaryCapture.d.ts.map +1 -1
- package/dist/shared/friction/stepBoundaryCapture.js +47 -0
- package/dist/shared/friction/stepBoundaryCapture.js.map +1 -1
- package/dist/shared/index.d.ts +8 -4
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +10 -2
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/io/stateDir.d.ts +27 -0
- package/dist/shared/io/stateDir.d.ts.map +1 -0
- package/dist/shared/io/stateDir.js +40 -0
- package/dist/shared/io/stateDir.js.map +1 -0
- package/dist/shared/providers/auditorSources.d.ts +94 -4
- package/dist/shared/providers/auditorSources.d.ts.map +1 -1
- package/dist/shared/providers/auditorSources.js +261 -8
- package/dist/shared/providers/auditorSources.js.map +1 -1
- package/dist/shared/providers/claudeWorkerProvider.d.ts +71 -0
- package/dist/shared/providers/claudeWorkerProvider.d.ts.map +1 -0
- package/dist/shared/providers/claudeWorkerProvider.js +133 -0
- package/dist/shared/providers/claudeWorkerProvider.js.map +1 -0
- package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
- package/dist/shared/providers/providerConfirmation.js +24 -3
- package/dist/shared/providers/providerConfirmation.js.map +1 -1
- package/dist/shared/providers/providerFactory.d.ts +7 -1
- package/dist/shared/providers/providerFactory.d.ts.map +1 -1
- package/dist/shared/providers/providerFactory.js +6 -0
- package/dist/shared/providers/providerFactory.js.map +1 -1
- package/dist/shared/providers/proxyCatalog.d.ts +95 -0
- package/dist/shared/providers/proxyCatalog.d.ts.map +1 -0
- package/dist/shared/providers/proxyCatalog.js +426 -0
- package/dist/shared/providers/proxyCatalog.js.map +1 -0
- package/dist/shared/quota/apiPool.d.ts.map +1 -1
- package/dist/shared/quota/apiPool.js +31 -0
- package/dist/shared/quota/apiPool.js.map +1 -1
- package/dist/shared/quota/capacity.d.ts +33 -4
- package/dist/shared/quota/capacity.d.ts.map +1 -1
- package/dist/shared/quota/capacity.js +40 -5
- package/dist/shared/quota/capacity.js.map +1 -1
- package/dist/shared/quota/errorParsing.d.ts +39 -0
- package/dist/shared/quota/errorParsing.d.ts.map +1 -1
- package/dist/shared/quota/errorParsing.js +76 -0
- package/dist/shared/quota/errorParsing.js.map +1 -1
- package/dist/shared/types/auditorDescriptor.d.ts +8 -0
- package/dist/shared/types/auditorDescriptor.d.ts.map +1 -1
- package/dist/shared/types/auditorDescriptor.js.map +1 -1
- package/dist/shared/types/rollingDispatch.d.ts +45 -1
- package/dist/shared/types/rollingDispatch.d.ts.map +1 -1
- package/dist/shared/types/sessionConfig.d.ts +77 -3
- package/dist/shared/types/sessionConfig.d.ts.map +1 -1
- package/dist/shared/types/sessionConfig.js +39 -2
- package/dist/shared/types/sessionConfig.js.map +1 -1
- package/dist/shared/validation/sessionConfig.d.ts.map +1 -1
- package/dist/shared/validation/sessionConfig.js +25 -1
- package/dist/shared/validation/sessionConfig.js.map +1 -1
- package/docs/audit-pkg/operator-guide.md +4 -4
- package/package.json +1 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { accessSync, constants, readFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
2
|
import { join } from "node:path";
|
|
3
|
+
import { resolveAuditCodeStateDir } from "../io/stateDir.js";
|
|
4
|
+
import { spawnSyncHidden } from "../tooling/exec.js";
|
|
4
5
|
import { validateSessionConfig } from "../validation/sessionConfig.js";
|
|
6
|
+
import { populateProxyCatalog, readProxyCatalog, } from "./proxyCatalog.js";
|
|
5
7
|
import { commandExists } from "./providerPathGuard.js";
|
|
6
8
|
/**
|
|
7
9
|
* The machine-level declaration file: the backends the OPERATOR owns, hand-authored
|
|
8
10
|
* like `session-config.json`. Deliberately NOT id-keyed and deliberately NOT named
|
|
9
|
-
* `catalog
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
12
15
|
*
|
|
13
16
|
* A declaration is not a cache: it is operator INTENT, not a prior auditor's resolved
|
|
14
17
|
* state. Reading it and intersecting it with live ambient reach does not inherit
|
|
15
18
|
* anything ([[capability-is-per-auditor-not-per-audit]]).
|
|
16
19
|
*/
|
|
17
20
|
export const SOURCE_DECLARATION_FILENAME = "sources-declared.json";
|
|
18
|
-
/** `~/.audit-code` — the established home-dir state dir (`src/audit/cli.ts` puts quota state here). */
|
|
19
|
-
const STATE_DIR_NAME = ".audit-code";
|
|
20
21
|
/**
|
|
21
22
|
* Default launcher command per CLI-backed dispatchable source, mirroring each
|
|
22
23
|
* provider's own `config.command ?? "<default>"` fallback (`codexProvider.ts:59`,
|
|
@@ -48,13 +49,54 @@ function defaultReadDeclarationFile(path) {
|
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Default {@link AmbientSourceDeps.probeHttpReachable}: a `GET <url>` run in a hidden
|
|
54
|
+
* node child so the check stays SYNCHRONOUS (resolve is sync by design — see the
|
|
55
|
+
* populate/resolve split) without blocking the event loop machinery this process owns.
|
|
56
|
+
* Exit 0 ⇔ HTTP 2xx within the attempt budget.
|
|
57
|
+
*
|
|
58
|
+
* TWO bounded attempts with escalating budgets: a healthy declared lane must NOT be
|
|
59
|
+
* dropped for the whole invocation on a single cold probe. Warm, a proxy's `/registry`
|
|
60
|
+
* answers in ~25ms and the first (1s) attempt passes; a COLD proxy whose model catalog
|
|
61
|
+
* is being (re)built synchronously can exceed a short budget, so a second, longer (4s)
|
|
62
|
+
* attempt covers it. (The proxy side also serves `/registry` stale-while-revalidate so
|
|
63
|
+
* this is rare — but the run's FIRST probe is exactly when a drop is most costly, so the
|
|
64
|
+
* retry is kept as defense in depth.) A genuinely-dead endpoint costs both budgets once,
|
|
65
|
+
* at run start, for one lane — acceptable.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Escalating-budget reachability: try `probeOnce` at each budget in order, returning
|
|
69
|
+
* true on the first success. The retry (not the spawn) is the load-bearing property —
|
|
70
|
+
* a healthy lane must survive a slow first attempt — so it is factored out here to be
|
|
71
|
+
* unit-testable without spawning. `budgets` is ordered small→large so the common warm
|
|
72
|
+
* case exits on the first, cheap attempt.
|
|
73
|
+
*/
|
|
74
|
+
export function probeReachableWithEscalation(probeOnce, budgets = [1_000, 4_000]) {
|
|
75
|
+
for (const budgetMs of budgets) {
|
|
76
|
+
if (probeOnce(budgetMs))
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
function defaultProbeHttpReachable(url) {
|
|
82
|
+
const probeOnce = (budgetMs) => {
|
|
83
|
+
const script = "const [url, ms] = process.argv.slice(1);" +
|
|
84
|
+
"fetch(url, { signal: AbortSignal.timeout(Number(ms)) })" +
|
|
85
|
+
".then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1));";
|
|
86
|
+
const result = spawnSyncHidden(process.execPath, ["-e", script, url, String(budgetMs)], {
|
|
87
|
+
timeout: budgetMs + 1_500,
|
|
88
|
+
});
|
|
89
|
+
return result.status === 0;
|
|
90
|
+
};
|
|
91
|
+
return probeReachableWithEscalation(probeOnce);
|
|
92
|
+
}
|
|
51
93
|
/** The source's stable id, matching `DispatchableSource.id`'s documented default. */
|
|
52
94
|
function sourceId(source) {
|
|
53
95
|
return source.id ?? `${source.provider}:${source.model ?? source.endpoint ?? "?"}`;
|
|
54
96
|
}
|
|
55
|
-
/** Resolve the declaration file path for this machine. */
|
|
97
|
+
/** Resolve the declaration file path for this machine (state dir via `io/stateDir.ts`). */
|
|
56
98
|
export function resolveSourceDeclarationPath(homeDir) {
|
|
57
|
-
return join(homeDir
|
|
99
|
+
return join(resolveAuditCodeStateDir(homeDir), SOURCE_DECLARATION_FILENAME);
|
|
58
100
|
}
|
|
59
101
|
/**
|
|
60
102
|
* Read the operator's machine-level source declaration.
|
|
@@ -90,6 +132,118 @@ export function readSourceDeclaration(deps = {}) {
|
|
|
90
132
|
return [];
|
|
91
133
|
return sources;
|
|
92
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Read the optional `repair_proxy` block from the machine declaration. Tolerant like
|
|
137
|
+
* {@link readSourceDeclaration}: an absent / unparseable file or a missing key is
|
|
138
|
+
* simply `{declaration: null}`; a PRESENT-but-malformed block degrades to lane-absent
|
|
139
|
+
* WITH a reason (surfaced via `resolveAmbientSources`' `dropped[]`), never a throw.
|
|
140
|
+
* Malformed optional knobs (`top_k` / `cost_per_mtok`) are dropped individually — a
|
|
141
|
+
* bad tuning value must not cost the operator the whole lane.
|
|
142
|
+
*/
|
|
143
|
+
export function readRepairProxyDeclaration(deps = {}) {
|
|
144
|
+
const path = resolveSourceDeclarationPath(deps.homeDir);
|
|
145
|
+
const raw = (deps.readDeclarationFile ?? defaultReadDeclarationFile)(path);
|
|
146
|
+
if (raw === null)
|
|
147
|
+
return { declaration: null };
|
|
148
|
+
let parsed;
|
|
149
|
+
try {
|
|
150
|
+
parsed = JSON.parse(raw);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return { declaration: null };
|
|
154
|
+
}
|
|
155
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
156
|
+
return { declaration: null };
|
|
157
|
+
}
|
|
158
|
+
const block = parsed.repair_proxy;
|
|
159
|
+
if (block === undefined)
|
|
160
|
+
return { declaration: null };
|
|
161
|
+
if (typeof block !== "object" || block === null || Array.isArray(block)) {
|
|
162
|
+
return {
|
|
163
|
+
declaration: null,
|
|
164
|
+
reason: "repair_proxy must be a JSON object with an endpoint — fix the declaration.",
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const { endpoint, top_k, cost_per_mtok } = block;
|
|
168
|
+
if (typeof endpoint !== "string" || endpoint.trim().length === 0) {
|
|
169
|
+
return {
|
|
170
|
+
declaration: null,
|
|
171
|
+
reason: "repair_proxy.endpoint must be a non-empty url string — fix the declaration.",
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const declaration = {
|
|
175
|
+
// Trailing slashes stripped so the reach probe, the populate cache's stored
|
|
176
|
+
// endpoint, and the expanded sources all compare on one canonical form.
|
|
177
|
+
endpoint: endpoint.trim().replace(/\/+$/u, ""),
|
|
178
|
+
};
|
|
179
|
+
if (typeof top_k === "number" && Number.isInteger(top_k) && top_k > 0) {
|
|
180
|
+
declaration.top_k = top_k;
|
|
181
|
+
}
|
|
182
|
+
if (typeof cost_per_mtok === "number" &&
|
|
183
|
+
Number.isFinite(cost_per_mtok) &&
|
|
184
|
+
cost_per_mtok >= 0) {
|
|
185
|
+
declaration.cost_per_mtok = cost_per_mtok;
|
|
186
|
+
}
|
|
187
|
+
return { declaration };
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The default populate fetch: time-boxed so a routable-but-dead proxy cannot hang a
|
|
191
|
+
* `next-step` at the Gate-0 build (network-tolerant means bounded, not just caught).
|
|
192
|
+
*/
|
|
193
|
+
const populateFetchWithTimeout = (input, init) => fetch(input, { ...init, signal: AbortSignal.timeout(5_000) });
|
|
194
|
+
/**
|
|
195
|
+
* POPULATE the declared repair-proxy lane (plan §populate-vs-resolve): read the
|
|
196
|
+
* machine declaration's `repair_proxy` block and, when present, fetch its registry
|
|
197
|
+
* into the machine-level populate cache ({@link populateProxyCatalog}). This is the
|
|
198
|
+
* network half the resolve path must never run — call it at Gate-0 build time (once
|
|
199
|
+
* per run) or on explicit refresh, NEVER from `resolveAmbientSources`.
|
|
200
|
+
*
|
|
201
|
+
* "Present + reachable" gating is the fetch itself: the registry GET is both the
|
|
202
|
+
* liveness proof and the payload, so a separate pre-probe would only double the
|
|
203
|
+
* network. Never throws: no declared lane ⇒ `null`; a failed/unreachable fetch ⇒
|
|
204
|
+
* `{written:false, reason}` and any prior cache is left untouched — the lane then
|
|
205
|
+
* resolves from the existing cache or unexpanded with its own `dropped[]` reason,
|
|
206
|
+
* degrading Gate-0, never blocking it.
|
|
207
|
+
*/
|
|
208
|
+
export async function populateDeclaredProxyCatalog(deps = {}) {
|
|
209
|
+
const { declaration } = readRepairProxyDeclaration(deps);
|
|
210
|
+
if (declaration === null)
|
|
211
|
+
return null;
|
|
212
|
+
return populateProxyCatalog({
|
|
213
|
+
endpoint: declaration.endpoint,
|
|
214
|
+
...(declaration.top_k !== undefined ? { topK: declaration.top_k } : {}),
|
|
215
|
+
...(declaration.cost_per_mtok !== undefined
|
|
216
|
+
? { costPerMtok: declaration.cost_per_mtok }
|
|
217
|
+
: {}),
|
|
218
|
+
fetchImpl: deps.fetchImpl ?? populateFetchWithTimeout,
|
|
219
|
+
...(deps.homeDir !== undefined ? { homeDir: deps.homeDir } : {}),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Populate the proxy catalog ONLY when the resolve half would otherwise drop the
|
|
224
|
+
* lane for it: a `repair_proxy` is declared but the cache is absent or was fetched
|
|
225
|
+
* from a different endpoint. Bounded by construction — after one success the cache
|
|
226
|
+
* exists and this is a cheap read — so a draw with no Gate-0 build moment (remediate)
|
|
227
|
+
* can call it on every config load without a per-load network fetch. Freshness
|
|
228
|
+
* (TTL / explicit refresh) is deliberately NOT this function's job (backlog).
|
|
229
|
+
* [[silent-fail-closed-on-one-draw]] — both draws must trigger populate, not just audit.
|
|
230
|
+
*/
|
|
231
|
+
export async function populateProxyCatalogIfMissing(deps = {}) {
|
|
232
|
+
const { declaration } = readRepairProxyDeclaration(deps);
|
|
233
|
+
if (declaration === null)
|
|
234
|
+
return null;
|
|
235
|
+
const cache = readProxyCatalog(deps);
|
|
236
|
+
if (cache !== null &&
|
|
237
|
+
cache.endpoint.replace(/\/+$/u, "") === declaration.endpoint) {
|
|
238
|
+
return {
|
|
239
|
+
sources: cache.sources,
|
|
240
|
+
written: false,
|
|
241
|
+
reason: "populate cache already present",
|
|
242
|
+
dropped: [],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return populateDeclaredProxyCatalog(deps);
|
|
246
|
+
}
|
|
93
247
|
/**
|
|
94
248
|
* Can THIS process prove it can reach this declared source?
|
|
95
249
|
*
|
|
@@ -192,6 +346,36 @@ export function verifySourceReach(source, deps = {}) {
|
|
|
192
346
|
reason: "worker-command reach is per-task (task.worker_command), so it is not declarable as an ambient source.",
|
|
193
347
|
};
|
|
194
348
|
}
|
|
349
|
+
case "claude-worker": {
|
|
350
|
+
// The proxied isolated Claude-harness worker: its reach IS the repair-proxy's
|
|
351
|
+
// liveness (endpoint = the proxy url). Normally these sources come pre-verified
|
|
352
|
+
// from the populate cache via the `repair_proxy` lane; a hand-declared one is
|
|
353
|
+
// held to the same bar. Inline api_key refused for the same possession≠reach
|
|
354
|
+
// reasons as openai-compatible above (the loopback proxy needs no key anyway).
|
|
355
|
+
if (!source.endpoint?.trim()) {
|
|
356
|
+
return {
|
|
357
|
+
verified: false,
|
|
358
|
+
reason: "claude-worker source has no endpoint (the repair-proxy url).",
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
if (!source.model?.trim()) {
|
|
362
|
+
return { verified: false, reason: "claude-worker source has no model." };
|
|
363
|
+
}
|
|
364
|
+
if (source.api_key !== undefined) {
|
|
365
|
+
return {
|
|
366
|
+
verified: false,
|
|
367
|
+
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).",
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
const probe = deps.probeHttpReachable ?? defaultProbeHttpReachable;
|
|
371
|
+
const endpoint = source.endpoint.trim().replace(/\/+$/u, "");
|
|
372
|
+
return probe(`${endpoint}/registry`)
|
|
373
|
+
? { verified: true }
|
|
374
|
+
: {
|
|
375
|
+
verified: false,
|
|
376
|
+
reason: `repair-proxy at "${endpoint}" failed the liveness probe (GET /registry).`,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
195
379
|
}
|
|
196
380
|
}
|
|
197
381
|
/**
|
|
@@ -221,6 +405,75 @@ export function resolveAmbientSources(deps = {}) {
|
|
|
221
405
|
else
|
|
222
406
|
dropped.push({ id: sourceId(source), reason: reach.reason });
|
|
223
407
|
}
|
|
408
|
+
resolveRepairProxyLane(deps, sources, dropped);
|
|
224
409
|
return { sources, dropped };
|
|
225
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* The repair-proxy lane of the resolve half (plan §populate-vs-resolve): a declared
|
|
413
|
+
* `repair_proxy` whose liveness probe passes expands from the POPULATE CACHE — never
|
|
414
|
+
* a mid-resolve fetch. Fail-open, mirroring the declared-source contract: every
|
|
415
|
+
* outcome short of expansion lands in `dropped[]` with an operator-facing reason
|
|
416
|
+
* (malformed declaration / probe failure / cache absent-stale-empty), so the lane is
|
|
417
|
+
* never silently discarded.
|
|
418
|
+
*/
|
|
419
|
+
function resolveRepairProxyLane(deps, sources, dropped) {
|
|
420
|
+
const { declaration, reason } = readRepairProxyDeclaration(deps);
|
|
421
|
+
if (reason !== undefined) {
|
|
422
|
+
dropped.push({ id: "repair-proxy", reason });
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (declaration === null)
|
|
426
|
+
return;
|
|
427
|
+
const { endpoint } = declaration;
|
|
428
|
+
const laneId = `repair-proxy:${endpoint}`;
|
|
429
|
+
const probe = deps.probeHttpReachable ?? defaultProbeHttpReachable;
|
|
430
|
+
if (!probe(`${endpoint}/registry`)) {
|
|
431
|
+
dropped.push({
|
|
432
|
+
id: laneId,
|
|
433
|
+
reason: `repair-proxy at "${endpoint}" failed the liveness probe (GET /registry) — lane dropped for this invocation.`,
|
|
434
|
+
});
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const catalog = readProxyCatalog(deps);
|
|
438
|
+
if (catalog === null) {
|
|
439
|
+
dropped.push({
|
|
440
|
+
id: laneId,
|
|
441
|
+
reason: "repair-proxy is reachable but the populate cache is absent/invalid — run the registry populate (populateProxyCatalog) to expand this lane.",
|
|
442
|
+
});
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (catalog.endpoint.replace(/\/+$/u, "") !== endpoint) {
|
|
446
|
+
dropped.push({
|
|
447
|
+
id: laneId,
|
|
448
|
+
reason: `populate cache was fetched from "${catalog.endpoint}", not the declared "${endpoint}" — re-run the registry populate.`,
|
|
449
|
+
});
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (catalog.sources.length === 0) {
|
|
453
|
+
dropped.push({
|
|
454
|
+
id: laneId,
|
|
455
|
+
reason: "repair-proxy registry expansion is empty (no reachable+keyed backend models at populate time) — lane present but unexpanded.",
|
|
456
|
+
});
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
// Declared-wins dedup: an expanded lane whose (backend_provider, model)
|
|
460
|
+
// identity a DECLARED source already covers is skipped, so one pool identity
|
|
461
|
+
// never maps to two sources (the launch bridge's pool→source map is 1:1 by
|
|
462
|
+
// assumption — a duplicate would arbitrate the transport by silent map-order
|
|
463
|
+
// clobber). The operator's explicit lane always beats auto-expansion; routing
|
|
464
|
+
// through the proxy for that model is still available by declaring the
|
|
465
|
+
// claude-worker source explicitly.
|
|
466
|
+
const declaredIdentities = new Set(sources.map((s) => `${s.backend_provider ?? s.provider}/${s.model ?? ""}`));
|
|
467
|
+
for (const expanded of catalog.sources) {
|
|
468
|
+
const identity = `${expanded.backend_provider ?? expanded.provider}/${expanded.model ?? ""}`;
|
|
469
|
+
if (declaredIdentities.has(identity)) {
|
|
470
|
+
dropped.push({
|
|
471
|
+
id: sourceId(expanded),
|
|
472
|
+
reason: `expanded lane skipped — a declared source already covers backend identity "${identity}" (declared wins over registry expansion).`,
|
|
473
|
+
});
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
sources.push(expanded);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
226
479
|
//# sourceMappingURL=auditorSources.js.map
|
|
@@ -1 +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,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AAEnE,uGAAuG;AACvG,MAAM,cAAc,GAAG,aAAa,CAAC;AAgCrC;;;;;;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,IAAI,CAAC;QACH,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,IAAY;IAC9C,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,SAAS,QAAQ,CAAC,MAA0B;IAC1C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rC,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;gBACtB,MAAM,EAAE,8EAA8E,QAAQ,4CAA4C;aAC3I,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,OAAO,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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { readFile, mkdir, writeFile, rm } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { readJsonFile } from "../io/json.js";
|
|
6
|
+
import { spawnLoggedCommand } from "./spawnLoggedCommand.js";
|
|
7
|
+
import { applyWorkerTaskLaunchSettings, } from "./workerTaskLaunch.js";
|
|
8
|
+
import { emitProviderLaunchDiagnostic, emitProviderDoneDiagnostic, } from "./providerDiagnostics.js";
|
|
9
|
+
export const CLAUDE_WORKER_PROVIDER_NAME = "claude-worker";
|
|
10
|
+
/**
|
|
11
|
+
* The explicit DUMMY key presented to a proxied spawn. The loopback repair-proxy
|
|
12
|
+
* needs no key, and an ambient real `ANTHROPIC_API_KEY` must NEVER be silently
|
|
13
|
+
* presented to a proxied spawn — so the overlay always sets this sentinel rather
|
|
14
|
+
* than leaving the variable to inherit from the parent env.
|
|
15
|
+
*/
|
|
16
|
+
export const CLAUDE_WORKER_DUMMY_API_KEY = "audit-tools-claude-worker";
|
|
17
|
+
/**
|
|
18
|
+
* The `projects` key the Claude CLI trusts a repo under: the absolute repo root
|
|
19
|
+
* with FORWARD slashes on every platform (live probe: the trust warning referenced
|
|
20
|
+
* `projects["C:/Code/audit-tools"].hasTrustDialogAccepted` on win32). Trailing
|
|
21
|
+
* separators are stripped so the key matches the CLI's cwd-derived form.
|
|
22
|
+
*/
|
|
23
|
+
export function claudeWorkerTrustProjectKey(repoRoot) {
|
|
24
|
+
const forward = repoRoot.trim().replace(/\\/g, "/");
|
|
25
|
+
return forward.length > 1 ? forward.replace(/\/+$/u, "") : forward;
|
|
26
|
+
}
|
|
27
|
+
/** A filesystem-safe stem for the per-launch isolated config dir. */
|
|
28
|
+
function sanitizeForDirName(value) {
|
|
29
|
+
return value.replace(/[^A-Za-z0-9._-]/gu, "-");
|
|
30
|
+
}
|
|
31
|
+
function requireNonEmpty(value, field) {
|
|
32
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
33
|
+
throw new Error(`claude-worker provider requires a non-empty ${field} — the source carries it ` +
|
|
34
|
+
`({endpoint: <repair-proxy url>, backend_provider, model}); an isolated spawn ` +
|
|
35
|
+
`with no proxy ${field === "endpoint" ? "endpoint" : "route"} must be impossible.`);
|
|
36
|
+
}
|
|
37
|
+
return value.trim();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* claude-worker backend — the proxied, ISOLATED, per-packet-routed Claude-harness
|
|
41
|
+
* worker (the kind-1 launch transport,
|
|
42
|
+
* docs/reviews/commit3-proxy-kind1-transport-plan-2026-07-16.md). It spawns
|
|
43
|
+
* `claude -p` with a REQUIRED `ANTHROPIC_BASE_URL` overlay pointing at the
|
|
44
|
+
* repair-proxy, a dummy `ANTHROPIC_API_KEY` (never the ambient real key), an
|
|
45
|
+
* isolated per-launch `CLAUDE_CONFIG_DIR`, and `--model
|
|
46
|
+
* <backend_provider>/<model>` — the namespace string the proxy routes on,
|
|
47
|
+
* composed at launch for argv only (it never enters the quota identity).
|
|
48
|
+
*
|
|
49
|
+
* Deliberately NO nested-session guard: this class is NOT `claude-code` (the
|
|
50
|
+
* conversation host) wearing a flag — isolation is its CONSTRUCTOR INVARIANT, not
|
|
51
|
+
* a guard exception. Construction throws unless endpoint/backend_provider/model
|
|
52
|
+
* are present, so every spawn is proxy-fronted with a scrubbed parent env
|
|
53
|
+
* (spawnLoggedCommand strips `CLAUDECODE`/`CLAUDE_CODE*`; `CLAUDE_CONFIG_DIR`
|
|
54
|
+
* survives the scrub and is overlaid per launch) and can safely run from inside a
|
|
55
|
+
* live Claude Code session. The `claude-code` host provider KEEPS its blanket
|
|
56
|
+
* guard, and all four in-session refusal layers key on `claude-code` and never
|
|
57
|
+
* see this name — no guard is refined for this class to exist.
|
|
58
|
+
*/
|
|
59
|
+
export class ClaudeWorkerProvider {
|
|
60
|
+
name = CLAUDE_WORKER_PROVIDER_NAME;
|
|
61
|
+
config;
|
|
62
|
+
endpoint;
|
|
63
|
+
backendProvider;
|
|
64
|
+
model;
|
|
65
|
+
launchCommand;
|
|
66
|
+
skipPermissionsDefault;
|
|
67
|
+
constructor(config = {}, options = {}, launchCommand = spawnLoggedCommand) {
|
|
68
|
+
this.config = config;
|
|
69
|
+
this.endpoint = requireNonEmpty(config.endpoint, "endpoint");
|
|
70
|
+
this.backendProvider = requireNonEmpty(config.backend_provider, "backend_provider");
|
|
71
|
+
this.model = requireNonEmpty(config.model, "model");
|
|
72
|
+
this.launchCommand = launchCommand;
|
|
73
|
+
this.skipPermissionsDefault = options.skipPermissionsDefault ?? false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create the per-launch isolated `CLAUDE_CONFIG_DIR` and mechanically pre-seed
|
|
77
|
+
* trust for the node's repo root, so the spawned harness never stalls on the
|
|
78
|
+
* interactive trust dialog (tool-enforced, never host-remembered).
|
|
79
|
+
*/
|
|
80
|
+
async prepareIsolatedConfigDir(input) {
|
|
81
|
+
const configDir = join(tmpdir(), "audit-tools-claude-worker", `${sanitizeForDirName(input.runId)}-${randomUUID()}`);
|
|
82
|
+
await mkdir(configDir, { recursive: true });
|
|
83
|
+
await writeFile(join(configDir, ".claude.json"), JSON.stringify({
|
|
84
|
+
projects: {
|
|
85
|
+
[claudeWorkerTrustProjectKey(input.repoRoot)]: {
|
|
86
|
+
hasTrustDialogAccepted: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}), "utf8");
|
|
90
|
+
return configDir;
|
|
91
|
+
}
|
|
92
|
+
async launch(input) {
|
|
93
|
+
const prompt = await readFile(input.promptPath, "utf8");
|
|
94
|
+
const task = await readJsonFile(input.taskPath);
|
|
95
|
+
const command = this.config.command ?? "claude";
|
|
96
|
+
const promptFlag = this.config.prompt_flag ?? "-p";
|
|
97
|
+
const skipPermissions = this.config.dangerously_skip_permissions ?? this.skipPermissionsDefault;
|
|
98
|
+
// The prompt is delivered via stdin (mirrors ClaudeCodeProvider), so
|
|
99
|
+
// `promptFlag` is a bare flag; `--model` carries the proxy's namespace
|
|
100
|
+
// routing key `<backend_provider>/<model>`, passed VERBATIM to the endpoint.
|
|
101
|
+
const args = [
|
|
102
|
+
promptFlag,
|
|
103
|
+
"--model",
|
|
104
|
+
`${this.backendProvider}/${this.model}`,
|
|
105
|
+
...(this.config.extra_args ?? []),
|
|
106
|
+
...(skipPermissions ? ["--dangerously-skip-permissions"] : []),
|
|
107
|
+
];
|
|
108
|
+
const configDir = await this.prepareIsolatedConfigDir(input);
|
|
109
|
+
emitProviderLaunchDiagnostic(this.name, input);
|
|
110
|
+
try {
|
|
111
|
+
const result = await this.launchCommand(command, args, {
|
|
112
|
+
...applyWorkerTaskLaunchSettings(input, task),
|
|
113
|
+
stdinText: prompt,
|
|
114
|
+
},
|
|
115
|
+
// spawnLoggedCommand merges this overlay over process.env, THEN scrubs
|
|
116
|
+
// CLAUDECODE/CLAUDE_CODE* — CLAUDE_CONFIG_DIR survives the scrub (prefix
|
|
117
|
+
// is CLAUDE_CONF), so the child sees exactly this isolated dir.
|
|
118
|
+
{
|
|
119
|
+
ANTHROPIC_BASE_URL: this.endpoint,
|
|
120
|
+
ANTHROPIC_API_KEY: CLAUDE_WORKER_DUMMY_API_KEY,
|
|
121
|
+
CLAUDE_CONFIG_DIR: configDir,
|
|
122
|
+
});
|
|
123
|
+
emitProviderDoneDiagnostic(this.name, input, result);
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
// Best-effort cleanup of the per-launch config dir — a cleanup failure
|
|
128
|
+
// must never fail (or mask) the launch result.
|
|
129
|
+
await rm(configDir, { recursive: true, force: true }).catch(() => { });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=claudeWorkerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeWorkerProvider.js","sourceRoot":"","sources":["../../../src/shared/providers/claudeWorkerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,6BAA6B,GAE9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,MAAM,2BAA2B,GAAG,eAAwB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,2BAA2B,CAAC;AAkBvE;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,C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AAI,GAAG;YACX,UAAU;YACV,SAAS;YACT,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,EAAE;YACvC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;YACjC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/D,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAC7D,4BAA4B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CACrC,OAAO,EACP,IAAI,EACJ;gBACE,GAAG,6BAA6B,CAAC,KAAK,EAAE,IAAI,CAAC;gBAC7C,SAAS,EAAE,MAAM;aAClB;YACD,uEAAuE;YACvE,yEAAyE;YACzE,gEAAgE;YAChE;gBACE,kBAAkB,EAAE,IAAI,CAAC,QAAQ;gBACjC,iBAAiB,EAAE,2BAA2B;gBAC9C,iBAAiB,EAAE,SAAS;aAC7B,CACF,CAAC;YACF,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YACrD,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,uEAAuE;YACvE,+CAA+C;YAC/C,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerConfirmation.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/providerConfirmation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAO3E,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"providerConfirmation.d.ts","sourceRoot":"","sources":["../../../src/shared/providers/providerConfirmation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAO3E,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;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ACX,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,aAAa,GAC3B,sBAAsB,EAAE,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,kBAAkB,EAAE,GAC5B,sBAAsB,EAAE,CAmB1B"}
|
|
@@ -29,6 +29,9 @@ function defaultCapabilityTier(name) {
|
|
|
29
29
|
case "vscode-task":
|
|
30
30
|
case "antigravity":
|
|
31
31
|
case "agy":
|
|
32
|
+
case "claude-worker":
|
|
33
|
+
// Proxied non-Claude backend behind the Claude harness — ranks strictly below
|
|
34
|
+
// the host tier by default (the operator promotes deliberately; plan §risks).
|
|
32
35
|
return "capable";
|
|
33
36
|
case "worker-command":
|
|
34
37
|
return "unknown";
|
|
@@ -175,8 +178,9 @@ function dispatchSourceKey(source) {
|
|
|
175
178
|
* would let one entry's `cost_order` silently overwrite the other's. The prefix is internal
|
|
176
179
|
* only; the emitted `source_id` + the operator `cost_order` keyspace are unaffected.
|
|
177
180
|
*/
|
|
181
|
+
const SOURCE_CANDIDATE_KEY_PREFIX = "source::";
|
|
178
182
|
function sourceCandidateKey(source) {
|
|
179
|
-
return
|
|
183
|
+
return `${SOURCE_CANDIDATE_KEY_PREFIX}${dispatchSourceKey(source)}`;
|
|
180
184
|
}
|
|
181
185
|
/**
|
|
182
186
|
* Resolve the FINAL 0-based cost position for every candidate key. Without an
|
|
@@ -191,10 +195,27 @@ function resolveFinalCostOrder(candidates, operatorOrder) {
|
|
|
191
195
|
return new Map(suggested.map((c) => [c.key, c.suggested_order]));
|
|
192
196
|
}
|
|
193
197
|
const knownKeys = new Set(candidates.map((c) => c.key));
|
|
198
|
+
// Display keyspace ≡ match keyspace (backlog: source pools were displayed as
|
|
199
|
+
// orderable but silently ignored). A source candidate is keyed
|
|
200
|
+
// `source::<id>` internally (collision-proofing against provider names / host
|
|
201
|
+
// model ids in this shared position map) but the Gate-0 prompt DISPLAYS it under
|
|
202
|
+
// its bare id — so the bare id must match too. An exact candidate key always
|
|
203
|
+
// wins the token: a bare alias never shadows a genuine provider/model key, which
|
|
204
|
+
// preserves exactly the collision-safety the prefix exists for.
|
|
205
|
+
const bareSourceAliases = new Map();
|
|
206
|
+
for (const key of knownKeys) {
|
|
207
|
+
if (!key.startsWith(SOURCE_CANDIDATE_KEY_PREFIX))
|
|
208
|
+
continue;
|
|
209
|
+
const bare = key.slice(SOURCE_CANDIDATE_KEY_PREFIX.length);
|
|
210
|
+
if (!knownKeys.has(bare) && !bareSourceAliases.has(bare)) {
|
|
211
|
+
bareSourceAliases.set(bare, key);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
194
214
|
const seen = new Set();
|
|
195
215
|
const orderedNamed = [];
|
|
196
|
-
for (const
|
|
197
|
-
|
|
216
|
+
for (const token of operatorOrder) {
|
|
217
|
+
const key = knownKeys.has(token) ? token : bareSourceAliases.get(token);
|
|
218
|
+
if (key !== undefined && !seen.has(key)) {
|
|
198
219
|
seen.add(key);
|
|
199
220
|
orderedNamed.push(key);
|
|
200
221
|
}
|