agent-shim 7.8.0 → 7.10.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.
- package/README.md +2 -1
- package/dist/cli.cjs +534 -511
- package/dist/index.cjs +2315 -153
- package/dist/index.mjs +2307 -153
- package/dist/types/checkReport.d.ts +154 -0
- package/dist/types/claudeShim.d.ts +114 -0
- package/dist/types/cli/commandDeps.d.ts +28 -0
- package/dist/types/cli/envBool.d.ts +11 -0
- package/dist/types/codex/http.d.ts +15 -0
- package/dist/types/configure.d.ts +170 -0
- package/dist/types/doctorReport.d.ts +117 -0
- package/dist/types/frontdoor/custody.d.ts +32 -0
- package/dist/types/frontdoor/headroomHop.d.ts +22 -0
- package/dist/types/frontdoor/pipeline.d.ts +109 -0
- package/dist/types/frontdoor/server.d.ts +44 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/launcher/cascade.d.ts +42 -0
- package/dist/types/launcher/pool.d.ts +44 -0
- package/dist/types/pathNorm.d.ts +14 -0
- package/dist/types/poolPickReport.d.ts +44 -0
- package/dist/types/realPorts.d.ts +102 -0
- package/dist/types/usage/middleware.d.ts +17 -0
- package/dist/types/usage/pick.d.ts +62 -0
- package/dist/types/usage/plan.d.ts +18 -0
- package/dist/types/usage/poolPick.d.ts +31 -0
- package/dist/types/usage/preflight.d.ts +20 -0
- package/dist/types/usage/rateLimit.d.ts +25 -0
- package/dist/types/usage/scan.d.ts +24 -0
- package/dist/types/usage/store.d.ts +43 -0
- package/dist/types/versionDiscovery.d.ts +47 -0
- package/package.json +1 -1
- package/dist/types/cli/parsers.d.ts +0 -40
package/dist/cli.cjs
CHANGED
|
@@ -3248,42 +3248,42 @@ var require_defaults = __commonJS({
|
|
|
3248
3248
|
var require_env_paths = __commonJS({
|
|
3249
3249
|
"node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
|
|
3250
3250
|
"use strict";
|
|
3251
|
-
var
|
|
3251
|
+
var path40 = require("path");
|
|
3252
3252
|
var os9 = require("os");
|
|
3253
3253
|
var homedir = os9.homedir();
|
|
3254
3254
|
var tmpdir = os9.tmpdir();
|
|
3255
3255
|
var { env } = process;
|
|
3256
3256
|
var macos = (name) => {
|
|
3257
|
-
const library =
|
|
3257
|
+
const library = path40.join(homedir, "Library");
|
|
3258
3258
|
return {
|
|
3259
|
-
data:
|
|
3260
|
-
config:
|
|
3261
|
-
cache:
|
|
3262
|
-
log:
|
|
3263
|
-
temp:
|
|
3259
|
+
data: path40.join(library, "Application Support", name),
|
|
3260
|
+
config: path40.join(library, "Preferences", name),
|
|
3261
|
+
cache: path40.join(library, "Caches", name),
|
|
3262
|
+
log: path40.join(library, "Logs", name),
|
|
3263
|
+
temp: path40.join(tmpdir, name)
|
|
3264
3264
|
};
|
|
3265
3265
|
};
|
|
3266
3266
|
var windows = (name) => {
|
|
3267
|
-
const appData = env.APPDATA ||
|
|
3268
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
3267
|
+
const appData = env.APPDATA || path40.join(homedir, "AppData", "Roaming");
|
|
3268
|
+
const localAppData = env.LOCALAPPDATA || path40.join(homedir, "AppData", "Local");
|
|
3269
3269
|
return {
|
|
3270
3270
|
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
3271
|
-
data:
|
|
3272
|
-
config:
|
|
3273
|
-
cache:
|
|
3274
|
-
log:
|
|
3275
|
-
temp:
|
|
3271
|
+
data: path40.join(localAppData, name, "Data"),
|
|
3272
|
+
config: path40.join(appData, name, "Config"),
|
|
3273
|
+
cache: path40.join(localAppData, name, "Cache"),
|
|
3274
|
+
log: path40.join(localAppData, name, "Log"),
|
|
3275
|
+
temp: path40.join(tmpdir, name)
|
|
3276
3276
|
};
|
|
3277
3277
|
};
|
|
3278
3278
|
var linux = (name) => {
|
|
3279
|
-
const username =
|
|
3279
|
+
const username = path40.basename(homedir);
|
|
3280
3280
|
return {
|
|
3281
|
-
data:
|
|
3282
|
-
config:
|
|
3283
|
-
cache:
|
|
3281
|
+
data: path40.join(env.XDG_DATA_HOME || path40.join(homedir, ".local", "share"), name),
|
|
3282
|
+
config: path40.join(env.XDG_CONFIG_HOME || path40.join(homedir, ".config"), name),
|
|
3283
|
+
cache: path40.join(env.XDG_CACHE_HOME || path40.join(homedir, ".cache"), name),
|
|
3284
3284
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
3285
|
-
log:
|
|
3286
|
-
temp:
|
|
3285
|
+
log: path40.join(env.XDG_STATE_HOME || path40.join(homedir, ".local", "state"), name),
|
|
3286
|
+
temp: path40.join(tmpdir, username, name)
|
|
3287
3287
|
};
|
|
3288
3288
|
};
|
|
3289
3289
|
var envPaths = (name, options) => {
|
|
@@ -3351,11 +3351,11 @@ var require_util = __commonJS({
|
|
|
3351
3351
|
return result;
|
|
3352
3352
|
}
|
|
3353
3353
|
exports2.emplace = emplace;
|
|
3354
|
-
function getPropertyByPath(source,
|
|
3355
|
-
if (typeof
|
|
3356
|
-
return source[
|
|
3354
|
+
function getPropertyByPath(source, path40) {
|
|
3355
|
+
if (typeof path40 === "string" && Object.prototype.hasOwnProperty.call(source, path40)) {
|
|
3356
|
+
return source[path40];
|
|
3357
3357
|
}
|
|
3358
|
-
const parsedPath = typeof
|
|
3358
|
+
const parsedPath = typeof path40 === "string" ? path40.split(".") : path40;
|
|
3359
3359
|
return parsedPath.reduce((previous, key) => {
|
|
3360
3360
|
if (previous === void 0) {
|
|
3361
3361
|
return previous;
|
|
@@ -3378,9 +3378,9 @@ var require_util = __commonJS({
|
|
|
3378
3378
|
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
|
|
3379
3379
|
}
|
|
3380
3380
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
3381
|
-
async function isDirectory(
|
|
3381
|
+
async function isDirectory(path40) {
|
|
3382
3382
|
try {
|
|
3383
|
-
const stat = await fs_1.promises.stat(
|
|
3383
|
+
const stat = await fs_1.promises.stat(path40);
|
|
3384
3384
|
return stat.isDirectory();
|
|
3385
3385
|
} catch (e) {
|
|
3386
3386
|
if (e.code === "ENOENT") {
|
|
@@ -3390,9 +3390,9 @@ var require_util = __commonJS({
|
|
|
3390
3390
|
}
|
|
3391
3391
|
}
|
|
3392
3392
|
exports2.isDirectory = isDirectory;
|
|
3393
|
-
function isDirectorySync(
|
|
3393
|
+
function isDirectorySync(path40) {
|
|
3394
3394
|
try {
|
|
3395
|
-
const stat = fs_1.default.statSync(
|
|
3395
|
+
const stat = fs_1.default.statSync(path40);
|
|
3396
3396
|
return stat.isDirectory();
|
|
3397
3397
|
} catch (e) {
|
|
3398
3398
|
if (e.code === "ENOENT") {
|
|
@@ -3490,7 +3490,7 @@ var require_ExplorerBase = __commonJS({
|
|
|
3490
3490
|
const idx = importStack.indexOf(fullPath);
|
|
3491
3491
|
if (idx !== -1) {
|
|
3492
3492
|
throw new Error(`Circular import detected:
|
|
3493
|
-
${[...importStack, fullPath].map((
|
|
3493
|
+
${[...importStack, fullPath].map((path40, i2) => `${i2 + 1}. ${path40}`).join("\n")} (same as ${idx + 1}.)`);
|
|
3494
3494
|
}
|
|
3495
3495
|
}
|
|
3496
3496
|
}
|
|
@@ -3678,9 +3678,9 @@ var require_Explorer = __commonJS({
|
|
|
3678
3678
|
throw error62;
|
|
3679
3679
|
}
|
|
3680
3680
|
}
|
|
3681
|
-
async #fileExists(
|
|
3681
|
+
async #fileExists(path40) {
|
|
3682
3682
|
try {
|
|
3683
|
-
await promises_1.default.stat(
|
|
3683
|
+
await promises_1.default.stat(path40);
|
|
3684
3684
|
return true;
|
|
3685
3685
|
} catch (e) {
|
|
3686
3686
|
return false;
|
|
@@ -3840,9 +3840,9 @@ var require_ExplorerSync = __commonJS({
|
|
|
3840
3840
|
throw error62;
|
|
3841
3841
|
}
|
|
3842
3842
|
}
|
|
3843
|
-
#fileExists(
|
|
3843
|
+
#fileExists(path40) {
|
|
3844
3844
|
try {
|
|
3845
|
-
fs_1.default.statSync(
|
|
3845
|
+
fs_1.default.statSync(path40);
|
|
3846
3846
|
return true;
|
|
3847
3847
|
} catch (e) {
|
|
3848
3848
|
return false;
|
|
@@ -3966,7 +3966,7 @@ var require_dist = __commonJS({
|
|
|
3966
3966
|
};
|
|
3967
3967
|
}
|
|
3968
3968
|
function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
|
|
3969
|
-
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((
|
|
3969
|
+
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path40) => path40.replace("{name}", moduleName));
|
|
3970
3970
|
if (userConfiguredOptions.mergeSearchPlaces) {
|
|
3971
3971
|
return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
|
|
3972
3972
|
}
|
|
@@ -4374,8 +4374,8 @@ var require_utils = __commonJS({
|
|
|
4374
4374
|
}
|
|
4375
4375
|
return output2;
|
|
4376
4376
|
};
|
|
4377
|
-
exports2.basename = (
|
|
4378
|
-
const segs =
|
|
4377
|
+
exports2.basename = (path40, { windows } = {}) => {
|
|
4378
|
+
const segs = path40.split(windows ? /[\\/]/ : "/");
|
|
4379
4379
|
const last = segs[segs.length - 1];
|
|
4380
4380
|
if (last === "") {
|
|
4381
4381
|
return segs[segs.length - 2];
|
|
@@ -7003,14 +7003,14 @@ var require_util2 = __commonJS({
|
|
|
7003
7003
|
}
|
|
7004
7004
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
7005
7005
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
7006
|
-
let
|
|
7006
|
+
let path40 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
7007
7007
|
if (origin[origin.length - 1] === "/") {
|
|
7008
7008
|
origin = origin.slice(0, origin.length - 1);
|
|
7009
7009
|
}
|
|
7010
|
-
if (
|
|
7011
|
-
|
|
7010
|
+
if (path40 && path40[0] !== "/") {
|
|
7011
|
+
path40 = `/${path40}`;
|
|
7012
7012
|
}
|
|
7013
|
-
return new URL(`${origin}${
|
|
7013
|
+
return new URL(`${origin}${path40}`);
|
|
7014
7014
|
}
|
|
7015
7015
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
7016
7016
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -7831,9 +7831,9 @@ var require_diagnostics = __commonJS({
|
|
|
7831
7831
|
"undici:client:sendHeaders",
|
|
7832
7832
|
(evt) => {
|
|
7833
7833
|
const {
|
|
7834
|
-
request: { method, path:
|
|
7834
|
+
request: { method, path: path40, origin }
|
|
7835
7835
|
} = evt;
|
|
7836
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
7836
|
+
debugLog("sending request to %s %s%s", method, origin, path40);
|
|
7837
7837
|
}
|
|
7838
7838
|
);
|
|
7839
7839
|
}
|
|
@@ -7851,14 +7851,14 @@ var require_diagnostics = __commonJS({
|
|
|
7851
7851
|
"undici:request:headers",
|
|
7852
7852
|
(evt) => {
|
|
7853
7853
|
const {
|
|
7854
|
-
request: { method, path:
|
|
7854
|
+
request: { method, path: path40, origin },
|
|
7855
7855
|
response: { statusCode }
|
|
7856
7856
|
} = evt;
|
|
7857
7857
|
debugLog(
|
|
7858
7858
|
"received response to %s %s%s - HTTP %d",
|
|
7859
7859
|
method,
|
|
7860
7860
|
origin,
|
|
7861
|
-
|
|
7861
|
+
path40,
|
|
7862
7862
|
statusCode
|
|
7863
7863
|
);
|
|
7864
7864
|
}
|
|
@@ -7867,23 +7867,23 @@ var require_diagnostics = __commonJS({
|
|
|
7867
7867
|
"undici:request:trailers",
|
|
7868
7868
|
(evt) => {
|
|
7869
7869
|
const {
|
|
7870
|
-
request: { method, path:
|
|
7870
|
+
request: { method, path: path40, origin }
|
|
7871
7871
|
} = evt;
|
|
7872
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
7872
|
+
debugLog("trailers received from %s %s%s", method, origin, path40);
|
|
7873
7873
|
}
|
|
7874
7874
|
);
|
|
7875
7875
|
diagnosticsChannel.subscribe(
|
|
7876
7876
|
"undici:request:error",
|
|
7877
7877
|
(evt) => {
|
|
7878
7878
|
const {
|
|
7879
|
-
request: { method, path:
|
|
7879
|
+
request: { method, path: path40, origin },
|
|
7880
7880
|
error: error62
|
|
7881
7881
|
} = evt;
|
|
7882
7882
|
debugLog(
|
|
7883
7883
|
"request to %s %s%s errored - %s",
|
|
7884
7884
|
method,
|
|
7885
7885
|
origin,
|
|
7886
|
-
|
|
7886
|
+
path40,
|
|
7887
7887
|
error62.message
|
|
7888
7888
|
);
|
|
7889
7889
|
}
|
|
@@ -7998,7 +7998,7 @@ var require_request = __commonJS({
|
|
|
7998
7998
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
7999
7999
|
var Request = class {
|
|
8000
8000
|
constructor(origin, {
|
|
8001
|
-
path:
|
|
8001
|
+
path: path40,
|
|
8002
8002
|
method,
|
|
8003
8003
|
body,
|
|
8004
8004
|
headers,
|
|
@@ -8015,11 +8015,11 @@ var require_request = __commonJS({
|
|
|
8015
8015
|
maxRedirections,
|
|
8016
8016
|
typeOfService
|
|
8017
8017
|
}, handler) {
|
|
8018
|
-
if (typeof
|
|
8018
|
+
if (typeof path40 !== "string") {
|
|
8019
8019
|
throw new InvalidArgumentError2("path must be a string");
|
|
8020
|
-
} else if (
|
|
8020
|
+
} else if (path40[0] !== "/" && !(path40.startsWith("http://") || path40.startsWith("https://")) && method !== "CONNECT") {
|
|
8021
8021
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
8022
|
-
} else if (invalidPathRegex.test(
|
|
8022
|
+
} else if (invalidPathRegex.test(path40)) {
|
|
8023
8023
|
throw new InvalidArgumentError2("invalid request path");
|
|
8024
8024
|
}
|
|
8025
8025
|
if (typeof method !== "string") {
|
|
@@ -8094,7 +8094,7 @@ var require_request = __commonJS({
|
|
|
8094
8094
|
this.completed = false;
|
|
8095
8095
|
this.aborted = false;
|
|
8096
8096
|
this.upgrade = upgrade || null;
|
|
8097
|
-
this.path = query ? serializePathWithQuery(
|
|
8097
|
+
this.path = query ? serializePathWithQuery(path40, query) : path40;
|
|
8098
8098
|
this.origin = origin;
|
|
8099
8099
|
this.protocol = getProtocolFromUrlString(origin);
|
|
8100
8100
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -13276,7 +13276,7 @@ var require_client_h1 = __commonJS({
|
|
|
13276
13276
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
13277
13277
|
}
|
|
13278
13278
|
function writeH1(client, request6) {
|
|
13279
|
-
const { method, path:
|
|
13279
|
+
const { method, path: path40, host, upgrade, blocking, reset } = request6;
|
|
13280
13280
|
let { body, headers, contentLength } = request6;
|
|
13281
13281
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
13282
13282
|
if (util.isFormDataLike(body)) {
|
|
@@ -13354,7 +13354,7 @@ var require_client_h1 = __commonJS({
|
|
|
13354
13354
|
if (socket.setTypeOfService) {
|
|
13355
13355
|
socket.setTypeOfService(request6.typeOfService);
|
|
13356
13356
|
}
|
|
13357
|
-
let header = `${method} ${
|
|
13357
|
+
let header = `${method} ${path40} HTTP/1.1\r
|
|
13358
13358
|
`;
|
|
13359
13359
|
if (typeof host === "string") {
|
|
13360
13360
|
header += `host: ${host}\r
|
|
@@ -14033,7 +14033,7 @@ var require_client_h2 = __commonJS({
|
|
|
14033
14033
|
const headersTimeout = request6.headersTimeout ?? client[kHeadersTimeout];
|
|
14034
14034
|
const bodyTimeout = request6.bodyTimeout ?? client[kBodyTimeout];
|
|
14035
14035
|
const session = client[kHTTP2Session];
|
|
14036
|
-
const { method, path:
|
|
14036
|
+
const { method, path: path40, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request6;
|
|
14037
14037
|
let { body } = request6;
|
|
14038
14038
|
if (upgrade != null && upgrade !== "websocket") {
|
|
14039
14039
|
util.errorRequest(client, request6, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -14102,7 +14102,7 @@ var require_client_h2 = __commonJS({
|
|
|
14102
14102
|
}
|
|
14103
14103
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
14104
14104
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
14105
|
-
headers[HTTP2_HEADER_PATH] =
|
|
14105
|
+
headers[HTTP2_HEADER_PATH] = path40;
|
|
14106
14106
|
if (protocol === "ws:" || protocol === "wss:") {
|
|
14107
14107
|
headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
14108
14108
|
} else {
|
|
@@ -14144,7 +14144,7 @@ var require_client_h2 = __commonJS({
|
|
|
14144
14144
|
stream.setTimeout(headersTimeout);
|
|
14145
14145
|
return true;
|
|
14146
14146
|
}
|
|
14147
|
-
headers[HTTP2_HEADER_PATH] =
|
|
14147
|
+
headers[HTTP2_HEADER_PATH] = path40;
|
|
14148
14148
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
14149
14149
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
14150
14150
|
if (body && typeof body.read === "function") {
|
|
@@ -16496,10 +16496,10 @@ var require_proxy_agent = __commonJS({
|
|
|
16496
16496
|
};
|
|
16497
16497
|
const {
|
|
16498
16498
|
origin,
|
|
16499
|
-
path:
|
|
16499
|
+
path: path40 = "/",
|
|
16500
16500
|
headers = {}
|
|
16501
16501
|
} = opts;
|
|
16502
|
-
opts.path = origin +
|
|
16502
|
+
opts.path = origin + path40;
|
|
16503
16503
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
16504
16504
|
const { host } = new URL(origin);
|
|
16505
16505
|
headers.host = host;
|
|
@@ -18608,20 +18608,20 @@ var require_mock_utils = __commonJS({
|
|
|
18608
18608
|
}
|
|
18609
18609
|
return normalizedQp;
|
|
18610
18610
|
}
|
|
18611
|
-
function safeUrl(
|
|
18612
|
-
if (typeof
|
|
18613
|
-
return
|
|
18611
|
+
function safeUrl(path40) {
|
|
18612
|
+
if (typeof path40 !== "string") {
|
|
18613
|
+
return path40;
|
|
18614
18614
|
}
|
|
18615
|
-
const pathSegments =
|
|
18615
|
+
const pathSegments = path40.split("?", 3);
|
|
18616
18616
|
if (pathSegments.length !== 2) {
|
|
18617
|
-
return
|
|
18617
|
+
return path40;
|
|
18618
18618
|
}
|
|
18619
18619
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
18620
18620
|
qp.sort();
|
|
18621
18621
|
return [...pathSegments, qp.toString()].join("?");
|
|
18622
18622
|
}
|
|
18623
|
-
function matchKey(mockDispatch2, { path:
|
|
18624
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
18623
|
+
function matchKey(mockDispatch2, { path: path40, method, body, headers }) {
|
|
18624
|
+
const pathMatch = matchValue(mockDispatch2.path, path40);
|
|
18625
18625
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
18626
18626
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
18627
18627
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -18646,8 +18646,8 @@ var require_mock_utils = __commonJS({
|
|
|
18646
18646
|
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
18647
18647
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
18648
18648
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
18649
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
18650
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
18649
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path40, ignoreTrailingSlash }) => {
|
|
18650
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path40)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path40), resolvedPath);
|
|
18651
18651
|
});
|
|
18652
18652
|
if (matchedMockDispatches.length === 0) {
|
|
18653
18653
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
@@ -18686,19 +18686,19 @@ var require_mock_utils = __commonJS({
|
|
|
18686
18686
|
mockDispatches.splice(index, 1);
|
|
18687
18687
|
}
|
|
18688
18688
|
}
|
|
18689
|
-
function removeTrailingSlash(
|
|
18690
|
-
while (
|
|
18691
|
-
|
|
18689
|
+
function removeTrailingSlash(path40) {
|
|
18690
|
+
while (path40.endsWith("/")) {
|
|
18691
|
+
path40 = path40.slice(0, -1);
|
|
18692
18692
|
}
|
|
18693
|
-
if (
|
|
18694
|
-
|
|
18693
|
+
if (path40.length === 0) {
|
|
18694
|
+
path40 = "/";
|
|
18695
18695
|
}
|
|
18696
|
-
return
|
|
18696
|
+
return path40;
|
|
18697
18697
|
}
|
|
18698
18698
|
function buildKey(opts) {
|
|
18699
|
-
const { path:
|
|
18699
|
+
const { path: path40, method, body, headers, query } = opts;
|
|
18700
18700
|
return {
|
|
18701
|
-
path:
|
|
18701
|
+
path: path40,
|
|
18702
18702
|
method,
|
|
18703
18703
|
body,
|
|
18704
18704
|
headers,
|
|
@@ -19388,10 +19388,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
19388
19388
|
}
|
|
19389
19389
|
format(pendingInterceptors) {
|
|
19390
19390
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
19391
|
-
({ method, path:
|
|
19391
|
+
({ method, path: path40, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
19392
19392
|
Method: method,
|
|
19393
19393
|
Origin: origin,
|
|
19394
|
-
Path:
|
|
19394
|
+
Path: path40,
|
|
19395
19395
|
"Status code": statusCode,
|
|
19396
19396
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
19397
19397
|
Invocations: timesInvoked,
|
|
@@ -19473,9 +19473,9 @@ var require_mock_agent = __commonJS({
|
|
|
19473
19473
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
19474
19474
|
const dispatchOpts = { ...opts };
|
|
19475
19475
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
19476
|
-
const [
|
|
19476
|
+
const [path40, searchParams] = dispatchOpts.path.split("?");
|
|
19477
19477
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
19478
|
-
dispatchOpts.path = `${
|
|
19478
|
+
dispatchOpts.path = `${path40}?${normalizedSearchParams}`;
|
|
19479
19479
|
}
|
|
19480
19480
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
19481
19481
|
}
|
|
@@ -19876,12 +19876,12 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19876
19876
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
19877
19877
|
*/
|
|
19878
19878
|
async loadSnapshots(filePath) {
|
|
19879
|
-
const
|
|
19880
|
-
if (!
|
|
19879
|
+
const path40 = filePath || this.#snapshotPath;
|
|
19880
|
+
if (!path40) {
|
|
19881
19881
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
19882
19882
|
}
|
|
19883
19883
|
try {
|
|
19884
|
-
const data = await readFile(resolve(
|
|
19884
|
+
const data = await readFile(resolve(path40), "utf8");
|
|
19885
19885
|
const parsed = JSON.parse(data);
|
|
19886
19886
|
if (Array.isArray(parsed)) {
|
|
19887
19887
|
this.#snapshots.clear();
|
|
@@ -19895,7 +19895,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19895
19895
|
if (error62.code === "ENOENT") {
|
|
19896
19896
|
this.#snapshots.clear();
|
|
19897
19897
|
} else {
|
|
19898
|
-
throw new UndiciError(`Failed to load snapshots from ${
|
|
19898
|
+
throw new UndiciError(`Failed to load snapshots from ${path40}`, { cause: error62 });
|
|
19899
19899
|
}
|
|
19900
19900
|
}
|
|
19901
19901
|
}
|
|
@@ -19906,11 +19906,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
19906
19906
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
19907
19907
|
*/
|
|
19908
19908
|
async saveSnapshots(filePath) {
|
|
19909
|
-
const
|
|
19910
|
-
if (!
|
|
19909
|
+
const path40 = filePath || this.#snapshotPath;
|
|
19910
|
+
if (!path40) {
|
|
19911
19911
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
19912
19912
|
}
|
|
19913
|
-
const resolvedPath = resolve(
|
|
19913
|
+
const resolvedPath = resolve(path40);
|
|
19914
19914
|
await mkdir(dirname2(resolvedPath), { recursive: true });
|
|
19915
19915
|
const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
|
|
19916
19916
|
hash: hash2,
|
|
@@ -20542,15 +20542,15 @@ var require_redirect_handler = __commonJS({
|
|
|
20542
20542
|
return;
|
|
20543
20543
|
}
|
|
20544
20544
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
20545
|
-
const
|
|
20546
|
-
const redirectUrlString = `${origin}${
|
|
20545
|
+
const path40 = search ? `${pathname}${search}` : pathname;
|
|
20546
|
+
const redirectUrlString = `${origin}${path40}`;
|
|
20547
20547
|
for (const historyUrl of this.history) {
|
|
20548
20548
|
if (historyUrl.toString() === redirectUrlString) {
|
|
20549
20549
|
throw new InvalidArgumentError2(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
20550
20550
|
}
|
|
20551
20551
|
}
|
|
20552
20552
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
20553
|
-
this.opts.path =
|
|
20553
|
+
this.opts.path = path40;
|
|
20554
20554
|
this.opts.origin = origin;
|
|
20555
20555
|
this.opts.query = null;
|
|
20556
20556
|
}
|
|
@@ -22310,10 +22310,10 @@ var require_cache_handler = __commonJS({
|
|
|
22310
22310
|
}
|
|
22311
22311
|
return locationUrl.pathname + locationUrl.search;
|
|
22312
22312
|
}
|
|
22313
|
-
function deleteCachedUri(store, cacheKey,
|
|
22313
|
+
function deleteCachedUri(store, cacheKey, path40) {
|
|
22314
22314
|
deleteCachedValue(store, {
|
|
22315
22315
|
...cacheKey,
|
|
22316
|
-
path:
|
|
22316
|
+
path: path40
|
|
22317
22317
|
});
|
|
22318
22318
|
for (let i2 = 0; i2 < util.safeHTTPMethods.length; i2++) {
|
|
22319
22319
|
const method = util.safeHTTPMethods[i2];
|
|
@@ -22321,7 +22321,7 @@ var require_cache_handler = __commonJS({
|
|
|
22321
22321
|
deleteCachedValue(store, {
|
|
22322
22322
|
...cacheKey,
|
|
22323
22323
|
method,
|
|
22324
|
-
path:
|
|
22324
|
+
path: path40
|
|
22325
22325
|
});
|
|
22326
22326
|
}
|
|
22327
22327
|
}
|
|
@@ -22332,9 +22332,9 @@ var require_cache_handler = __commonJS({
|
|
|
22332
22332
|
}
|
|
22333
22333
|
const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
|
|
22334
22334
|
for (let i2 = 0; i2 < values.length; i2++) {
|
|
22335
|
-
const
|
|
22336
|
-
if (
|
|
22337
|
-
deleteCachedUri(store, cacheKey,
|
|
22335
|
+
const path40 = getSameOriginPath(cacheKey, values[i2]);
|
|
22336
|
+
if (path40 !== void 0) {
|
|
22337
|
+
deleteCachedUri(store, cacheKey, path40);
|
|
22338
22338
|
}
|
|
22339
22339
|
}
|
|
22340
22340
|
}
|
|
@@ -27334,11 +27334,11 @@ var require_fetch = __commonJS({
|
|
|
27334
27334
|
function dispatch({ body }) {
|
|
27335
27335
|
const url2 = requestCurrentURL(request6);
|
|
27336
27336
|
const agent = fetchParams.controller.dispatcher;
|
|
27337
|
-
const
|
|
27337
|
+
const path40 = url2.pathname + url2.search;
|
|
27338
27338
|
const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
|
|
27339
27339
|
return new Promise((resolve, reject) => agent.dispatch(
|
|
27340
27340
|
{
|
|
27341
|
-
path: hasTrailingQuestionMark ? `${
|
|
27341
|
+
path: hasTrailingQuestionMark ? `${path40}?` : path40,
|
|
27342
27342
|
origin: url2.origin,
|
|
27343
27343
|
method: request6.method,
|
|
27344
27344
|
body: agent.isMockActive ? request6.body && (request6.body.source || request6.body.stream) : body,
|
|
@@ -28285,9 +28285,9 @@ var require_util5 = __commonJS({
|
|
|
28285
28285
|
}
|
|
28286
28286
|
}
|
|
28287
28287
|
}
|
|
28288
|
-
function validateCookiePath(
|
|
28289
|
-
for (let i2 = 0; i2 <
|
|
28290
|
-
const code =
|
|
28288
|
+
function validateCookiePath(path40) {
|
|
28289
|
+
for (let i2 = 0; i2 < path40.length; ++i2) {
|
|
28290
|
+
const code = path40.charCodeAt(i2);
|
|
28291
28291
|
if (code < 32 || // exclude CTLs (0-31)
|
|
28292
28292
|
code > 126 || // exclude DEL and non-ascii
|
|
28293
28293
|
code === 59) {
|
|
@@ -31635,11 +31635,11 @@ var require_undici = __commonJS({
|
|
|
31635
31635
|
if (typeof opts.path !== "string") {
|
|
31636
31636
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
31637
31637
|
}
|
|
31638
|
-
let
|
|
31638
|
+
let path40 = opts.path;
|
|
31639
31639
|
if (!opts.path.startsWith("/")) {
|
|
31640
|
-
|
|
31640
|
+
path40 = `/${path40}`;
|
|
31641
31641
|
}
|
|
31642
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
31642
|
+
url2 = new URL(util.parseOrigin(url2).origin + path40);
|
|
31643
31643
|
} else {
|
|
31644
31644
|
if (!opts) {
|
|
31645
31645
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -31749,7 +31749,7 @@ ${captureLines}` : capture.stack;
|
|
|
31749
31749
|
});
|
|
31750
31750
|
|
|
31751
31751
|
// src/cli.ts
|
|
31752
|
-
var
|
|
31752
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
31753
31753
|
|
|
31754
31754
|
// node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
31755
31755
|
var CommanderError = class extends Error {
|
|
@@ -34862,9 +34862,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
34862
34862
|
* @param {string} [path]
|
|
34863
34863
|
* @return {(string|null|Command)}
|
|
34864
34864
|
*/
|
|
34865
|
-
executableDir(
|
|
34866
|
-
if (
|
|
34867
|
-
this._executableDir =
|
|
34865
|
+
executableDir(path40) {
|
|
34866
|
+
if (path40 === void 0) return this._executableDir;
|
|
34867
|
+
this._executableDir = path40;
|
|
34868
34868
|
return this;
|
|
34869
34869
|
}
|
|
34870
34870
|
/**
|
|
@@ -36002,10 +36002,10 @@ function mergeDefs(...defs) {
|
|
|
36002
36002
|
function cloneDef(schema) {
|
|
36003
36003
|
return mergeDefs(schema._zod.def);
|
|
36004
36004
|
}
|
|
36005
|
-
function getElementAtPath(obj,
|
|
36006
|
-
if (!
|
|
36005
|
+
function getElementAtPath(obj, path40) {
|
|
36006
|
+
if (!path40)
|
|
36007
36007
|
return obj;
|
|
36008
|
-
return
|
|
36008
|
+
return path40.reduce((acc, key) => acc?.[key], obj);
|
|
36009
36009
|
}
|
|
36010
36010
|
function promiseAllObject(promisesObj) {
|
|
36011
36011
|
const keys = Object.keys(promisesObj);
|
|
@@ -36345,11 +36345,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
36345
36345
|
}
|
|
36346
36346
|
return false;
|
|
36347
36347
|
}
|
|
36348
|
-
function prefixIssues(
|
|
36348
|
+
function prefixIssues(path40, issues) {
|
|
36349
36349
|
return issues.map((iss) => {
|
|
36350
36350
|
var _a3;
|
|
36351
36351
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
36352
|
-
iss.path.unshift(
|
|
36352
|
+
iss.path.unshift(path40);
|
|
36353
36353
|
return iss;
|
|
36354
36354
|
});
|
|
36355
36355
|
}
|
|
@@ -36799,16 +36799,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
36799
36799
|
}
|
|
36800
36800
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
36801
36801
|
const fieldErrors = { _errors: [] };
|
|
36802
|
-
const processError = (error63,
|
|
36802
|
+
const processError = (error63, path40 = []) => {
|
|
36803
36803
|
for (const issue2 of error63.issues) {
|
|
36804
36804
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
36805
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
36805
|
+
issue2.errors.map((issues) => processError({ issues }, [...path40, ...issue2.path]));
|
|
36806
36806
|
} else if (issue2.code === "invalid_key") {
|
|
36807
|
-
processError({ issues: issue2.issues }, [...
|
|
36807
|
+
processError({ issues: issue2.issues }, [...path40, ...issue2.path]);
|
|
36808
36808
|
} else if (issue2.code === "invalid_element") {
|
|
36809
|
-
processError({ issues: issue2.issues }, [...
|
|
36809
|
+
processError({ issues: issue2.issues }, [...path40, ...issue2.path]);
|
|
36810
36810
|
} else {
|
|
36811
|
-
const fullpath = [...
|
|
36811
|
+
const fullpath = [...path40, ...issue2.path];
|
|
36812
36812
|
if (fullpath.length === 0) {
|
|
36813
36813
|
fieldErrors._errors.push(mapper(issue2));
|
|
36814
36814
|
} else {
|
|
@@ -36847,17 +36847,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
36847
36847
|
}
|
|
36848
36848
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
36849
36849
|
const result = { errors: [] };
|
|
36850
|
-
const processError = (error63,
|
|
36850
|
+
const processError = (error63, path40 = []) => {
|
|
36851
36851
|
var _a3;
|
|
36852
36852
|
for (const issue2 of error63.issues) {
|
|
36853
36853
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
36854
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
36854
|
+
issue2.errors.map((issues) => processError({ issues }, [...path40, ...issue2.path]));
|
|
36855
36855
|
} else if (issue2.code === "invalid_key") {
|
|
36856
|
-
processError({ issues: issue2.issues }, [...
|
|
36856
|
+
processError({ issues: issue2.issues }, [...path40, ...issue2.path]);
|
|
36857
36857
|
} else if (issue2.code === "invalid_element") {
|
|
36858
|
-
processError({ issues: issue2.issues }, [...
|
|
36858
|
+
processError({ issues: issue2.issues }, [...path40, ...issue2.path]);
|
|
36859
36859
|
} else {
|
|
36860
|
-
const fullpath = [...
|
|
36860
|
+
const fullpath = [...path40, ...issue2.path];
|
|
36861
36861
|
if (fullpath.length === 0) {
|
|
36862
36862
|
result.errors.push(mapper(issue2));
|
|
36863
36863
|
continue;
|
|
@@ -36896,8 +36896,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
36896
36896
|
}
|
|
36897
36897
|
function toDotPath(_path) {
|
|
36898
36898
|
const segs = [];
|
|
36899
|
-
const
|
|
36900
|
-
for (const seg of
|
|
36899
|
+
const path40 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
36900
|
+
for (const seg of path40) {
|
|
36901
36901
|
if (typeof seg === "number")
|
|
36902
36902
|
segs.push(`[${seg}]`);
|
|
36903
36903
|
else if (typeof seg === "symbol")
|
|
@@ -53999,13 +53999,13 @@ function resolveRef(ref, ctx) {
|
|
|
53999
53999
|
if (!ref.startsWith("#")) {
|
|
54000
54000
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
54001
54001
|
}
|
|
54002
|
-
const
|
|
54003
|
-
if (
|
|
54002
|
+
const path40 = ref.slice(1).split("/").filter(Boolean);
|
|
54003
|
+
if (path40.length === 0) {
|
|
54004
54004
|
return ctx.rootSchema;
|
|
54005
54005
|
}
|
|
54006
54006
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
54007
|
-
if (
|
|
54008
|
-
const key =
|
|
54007
|
+
if (path40[0] === defsKey) {
|
|
54008
|
+
const key = path40[1] === void 0 ? void 0 : decodeJSONPointerSegment(path40[1]);
|
|
54009
54009
|
if (!key || !ctx.defs[key]) {
|
|
54010
54010
|
throw new Error(`Reference not found: ${ref}`);
|
|
54011
54011
|
}
|
|
@@ -60474,26 +60474,6 @@ function parseBool(input2) {
|
|
|
60474
60474
|
}
|
|
60475
60475
|
return parsed;
|
|
60476
60476
|
}
|
|
60477
|
-
var InvalidEnvBoolError = class extends UsageError {
|
|
60478
|
-
constructor(variable, value) {
|
|
60479
|
-
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
60480
|
-
this.variable = variable;
|
|
60481
|
-
this.value = value;
|
|
60482
|
-
this.name = "InvalidEnvBoolError";
|
|
60483
|
-
}
|
|
60484
|
-
variable;
|
|
60485
|
-
value;
|
|
60486
|
-
};
|
|
60487
|
-
function parseEnvBool(variable, value) {
|
|
60488
|
-
if (value === void 0 || value === "") {
|
|
60489
|
-
return void 0;
|
|
60490
|
-
}
|
|
60491
|
-
const parsed = parseBoolWord(value);
|
|
60492
|
-
if (parsed === void 0) {
|
|
60493
|
-
throw new InvalidEnvBoolError(variable, value);
|
|
60494
|
-
}
|
|
60495
|
-
return parsed;
|
|
60496
|
-
}
|
|
60497
60477
|
function parseBoolPairList(input2) {
|
|
60498
60478
|
const result = {};
|
|
60499
60479
|
for (const piece of splitCommas(input2)) {
|
|
@@ -60975,7 +60955,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
60975
60955
|
// package.json
|
|
60976
60956
|
var package_default = {
|
|
60977
60957
|
name: "agent-shim",
|
|
60978
|
-
version: "7.
|
|
60958
|
+
version: "7.10.0",
|
|
60979
60959
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
60980
60960
|
license: "MIT",
|
|
60981
60961
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -61069,55 +61049,10 @@ var package_default = {
|
|
|
61069
61049
|
};
|
|
61070
61050
|
|
|
61071
61051
|
// src/check.ts
|
|
61072
|
-
var
|
|
61073
|
-
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
61052
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
61074
61053
|
|
|
61075
|
-
// src/
|
|
61076
|
-
var
|
|
61077
|
-
"ANTHROPIC_API_KEY",
|
|
61078
|
-
"ANTHROPIC_AUTH_TOKEN",
|
|
61079
|
-
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
61080
|
-
"CLAUDE_CODE_USE_BEDROCK",
|
|
61081
|
-
"CLAUDE_CODE_USE_VERTEX",
|
|
61082
|
-
"CLAUDE_CODE_USE_FOUNDRY"
|
|
61083
|
-
];
|
|
61084
|
-
function detectAmbientCredential(env, injected) {
|
|
61085
|
-
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
61086
|
-
const value = env[variable];
|
|
61087
|
-
if (value === void 0 || value === "") {
|
|
61088
|
-
continue;
|
|
61089
|
-
}
|
|
61090
|
-
if (injected?.variable === variable && value === injected.token) {
|
|
61091
|
-
continue;
|
|
61092
|
-
}
|
|
61093
|
-
return { variable };
|
|
61094
|
-
}
|
|
61095
|
-
return void 0;
|
|
61096
|
-
}
|
|
61097
|
-
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
61098
|
-
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
61099
|
-
return [
|
|
61100
|
-
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
61101
|
-
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
61102
|
-
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
61103
|
-
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
61104
|
-
`\`${identitySetCommand}\`.`
|
|
61105
|
-
].join("\n");
|
|
61106
|
-
}
|
|
61107
|
-
function evaluateAmbientCredentialGuard(params) {
|
|
61108
|
-
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
61109
|
-
if (detected === void 0) {
|
|
61110
|
-
return { ok: true };
|
|
61111
|
-
}
|
|
61112
|
-
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
61113
|
-
return { ok: true };
|
|
61114
|
-
}
|
|
61115
|
-
return {
|
|
61116
|
-
ok: false,
|
|
61117
|
-
variable: detected.variable,
|
|
61118
|
-
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
61119
|
-
};
|
|
61120
|
-
}
|
|
61054
|
+
// src/checkReport.ts
|
|
61055
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
61121
61056
|
|
|
61122
61057
|
// src/usage/preflight.ts
|
|
61123
61058
|
var MS_PER_SECOND = 1e3;
|
|
@@ -61479,11 +61414,11 @@ function providerBaseUrl(port, provider) {
|
|
|
61479
61414
|
function directOrigin(port) {
|
|
61480
61415
|
return `http://127.0.0.1:${String(port)}`;
|
|
61481
61416
|
}
|
|
61482
|
-
function parseProviderPath(
|
|
61483
|
-
if (!
|
|
61417
|
+
function parseProviderPath(path40) {
|
|
61418
|
+
if (!path40.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
61484
61419
|
return void 0;
|
|
61485
61420
|
}
|
|
61486
|
-
const tail =
|
|
61421
|
+
const tail = path40.slice(PROVIDER_PATH_PREFIX.length);
|
|
61487
61422
|
const slash = tail.indexOf("/");
|
|
61488
61423
|
if (slash <= 0) {
|
|
61489
61424
|
return void 0;
|
|
@@ -61883,9 +61818,9 @@ function decoderFor(encoding) {
|
|
|
61883
61818
|
return void 0;
|
|
61884
61819
|
}
|
|
61885
61820
|
}
|
|
61886
|
-
function destinationOf(
|
|
61887
|
-
const scoped = parseProviderPath(
|
|
61888
|
-
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint:
|
|
61821
|
+
function destinationOf(path40) {
|
|
61822
|
+
const scoped = parseProviderPath(path40);
|
|
61823
|
+
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path40 } : { provider: scoped.provider, endpoint: scoped.rest };
|
|
61889
61824
|
}
|
|
61890
61825
|
function buildRecord(event, context) {
|
|
61891
61826
|
const { scan } = context;
|
|
@@ -62524,7 +62459,7 @@ function resolvePoolLaunch(params) {
|
|
|
62524
62459
|
}
|
|
62525
62460
|
}
|
|
62526
62461
|
|
|
62527
|
-
// src/
|
|
62462
|
+
// src/poolPickReport.ts
|
|
62528
62463
|
function candidateView(candidate) {
|
|
62529
62464
|
return {
|
|
62530
62465
|
identity: candidate.identity,
|
|
@@ -62557,116 +62492,6 @@ function collectPoolPick(params) {
|
|
|
62557
62492
|
...sticky.problem === void 0 ? {} : { stickyProblem: sticky.problem }
|
|
62558
62493
|
};
|
|
62559
62494
|
}
|
|
62560
|
-
function formatPoolPick(report, nowMs) {
|
|
62561
|
-
const head = report.pick === void 0 ? `Pool ${report.pool}: every member is refused right now${report.earliestReturn === void 0 ? "" : `; ${report.earliestReturn.identity} returns at ${report.earliestReturn.at} (in ${formatAge(Date.parse(report.earliestReturn.at) - nowMs)})`}` : `Pool ${report.pool}: a launch from ${report.directory} would run as ${report.pick}`;
|
|
62562
|
-
const rows = report.candidates.map((candidate, index) => {
|
|
62563
|
-
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}`;
|
|
62564
|
-
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
62565
|
-
return ` ${String(index + 1)}. ${candidate.identity} [${candidate.class}${score}]${dry}
|
|
62566
|
-
${candidate.reasons.join("; ")}`;
|
|
62567
|
-
});
|
|
62568
|
-
return [head, ...rows, ...report.missing.map((name) => ` (skipped: ${name} is not an identity)`), ...report.stickyProblem === void 0 ? [] : [`Note: ${report.stickyProblem}; the last-pick record was ignored.`]];
|
|
62569
|
-
}
|
|
62570
|
-
function requireIdentities(paths, names) {
|
|
62571
|
-
const existing = new Set(listIdentities(paths).map((entry) => entry.name));
|
|
62572
|
-
for (const name of names) {
|
|
62573
|
-
if (!existing.has(name)) {
|
|
62574
|
-
throw new IdentityNotFoundError(name);
|
|
62575
|
-
}
|
|
62576
|
-
}
|
|
62577
|
-
}
|
|
62578
|
-
function membersOf(options) {
|
|
62579
|
-
if (options.identity === void 0 || options.identity.length === 0) {
|
|
62580
|
-
throw new UsageError("A pool needs at least one member: pass --identity <name> (repeatable).");
|
|
62581
|
-
}
|
|
62582
|
-
return options.identity;
|
|
62583
|
-
}
|
|
62584
|
-
function registerPoolCommand(program2, deps) {
|
|
62585
|
-
const { paths } = deps;
|
|
62586
|
-
const pool = withExamples(
|
|
62587
|
-
program2.command("pool").description("Manage pools: named sets of identities that a launch picks one member of, by remaining quota, with `claude @pool:<name>`."),
|
|
62588
|
-
["agent-shim pool add subs --identity work --identity personal", "agent-shim pool pick subs"]
|
|
62589
|
-
);
|
|
62590
|
-
withExamples(
|
|
62591
|
-
pool.command("add <name>").description("Define a pool. Fails if one with this name already exists.").option("--identity <name>", "A member identity (repeatable).", collectRepeated).action((name, options) => {
|
|
62592
|
-
const members2 = membersOf(options);
|
|
62593
|
-
requireIdentities(paths, members2);
|
|
62594
|
-
addPool(paths, name, members2);
|
|
62595
|
-
console.log(`Created pool "${name}" with ${members2.join(", ")}.`);
|
|
62596
|
-
}),
|
|
62597
|
-
["agent-shim pool add subs --identity work --identity personal"]
|
|
62598
|
-
);
|
|
62599
|
-
withExamples(
|
|
62600
|
-
pool.command("set <name>").description("Replace a pool's members.").option("--identity <name>", "A member identity (repeatable); the full new list.", collectRepeated).action((name, options) => {
|
|
62601
|
-
const members2 = membersOf(options);
|
|
62602
|
-
requireIdentities(paths, members2);
|
|
62603
|
-
setPool(paths, name, members2);
|
|
62604
|
-
console.log(`Pool "${name}" now has ${members2.join(", ")}.`);
|
|
62605
|
-
}),
|
|
62606
|
-
["agent-shim pool set subs --identity work --identity personal --identity spare"]
|
|
62607
|
-
);
|
|
62608
|
-
withExamples(
|
|
62609
|
-
pool.command("list").description("List every pool and its members, marking the active selection with *.").option("--json", "Print the pools as JSON.").action((options) => {
|
|
62610
|
-
const pools = readPools(paths);
|
|
62611
|
-
const active = readActiveIdentity(paths);
|
|
62612
|
-
if (options.json === true) {
|
|
62613
|
-
printJson(Object.entries(pools).map(([name, entry]) => ({ name, identities: entry.identities, active: active === `${POOL_SELECTOR_PREFIX}${name}` })));
|
|
62614
|
-
return;
|
|
62615
|
-
}
|
|
62616
|
-
const names = Object.keys(pools).sort();
|
|
62617
|
-
if (names.length === 0) {
|
|
62618
|
-
console.log("No pools yet. Run `agent-shim pool add <name> --identity <name>...` to create one.");
|
|
62619
|
-
return;
|
|
62620
|
-
}
|
|
62621
|
-
for (const name of names) {
|
|
62622
|
-
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(pools[name]?.identities ?? []).join(", ")}`);
|
|
62623
|
-
}
|
|
62624
|
-
}),
|
|
62625
|
-
["agent-shim pool list", "agent-shim pool list --json"]
|
|
62626
|
-
);
|
|
62627
|
-
withExamples(
|
|
62628
|
-
pool.command("show <name>").description("Show one pool's members.").option("--json", "Print the pool as JSON.").action((name, options) => {
|
|
62629
|
-
const entry = requirePool(paths, name);
|
|
62630
|
-
if (options.json === true) {
|
|
62631
|
-
printJson({ name, identities: entry.identities });
|
|
62632
|
-
return;
|
|
62633
|
-
}
|
|
62634
|
-
console.log(`Pool: ${name}`);
|
|
62635
|
-
console.log(`Members: ${entry.identities.join(", ")}`);
|
|
62636
|
-
}),
|
|
62637
|
-
["agent-shim pool show subs"]
|
|
62638
|
-
);
|
|
62639
|
-
withExamples(
|
|
62640
|
-
pool.command("remove <name>").description("Delete a pool. Its member identities are untouched.").option("--yes", "Skip the confirmation prompt.").action(async (name, options) => {
|
|
62641
|
-
requirePool(paths, name);
|
|
62642
|
-
await confirmRemoval(deps, options.yes, `pool "${name}"`);
|
|
62643
|
-
removePool(paths, name);
|
|
62644
|
-
console.log(`Removed pool "${name}".`);
|
|
62645
|
-
}),
|
|
62646
|
-
["agent-shim pool remove subs --yes"]
|
|
62647
|
-
);
|
|
62648
|
-
withExamples(
|
|
62649
|
-
pool.command("use <name>").description("Make launches with no other selection pick a member of this pool.").action((name) => {
|
|
62650
|
-
useIdentity(paths, `${POOL_SELECTOR_PREFIX}${name}`);
|
|
62651
|
-
console.log(`Active selection is now pool "${name}".`);
|
|
62652
|
-
}),
|
|
62653
|
-
["agent-shim pool use subs"]
|
|
62654
|
-
);
|
|
62655
|
-
withExamples(
|
|
62656
|
-
pool.command("pick <name>").description("Show how a launch from this directory would rank the pool's members right now, and which it would run as. Read-only: it records nothing.").option("--json", "Print the ranking as JSON.").action((name, options) => {
|
|
62657
|
-
const nowMs = Date.now();
|
|
62658
|
-
const report = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: name, pool: requirePool(paths, name), directory: process.cwd(), nowMs });
|
|
62659
|
-
if (options.json === true) {
|
|
62660
|
-
printJson(report);
|
|
62661
|
-
return;
|
|
62662
|
-
}
|
|
62663
|
-
for (const line of formatPoolPick(report, nowMs)) {
|
|
62664
|
-
console.log(line);
|
|
62665
|
-
}
|
|
62666
|
-
}),
|
|
62667
|
-
["agent-shim pool pick subs", "agent-shim pool pick subs --json"]
|
|
62668
|
-
);
|
|
62669
|
-
}
|
|
62670
62495
|
|
|
62671
62496
|
// src/providersStore.ts
|
|
62672
62497
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
@@ -62936,7 +62761,79 @@ function resolveProvider(params) {
|
|
|
62936
62761
|
return { ok: true, provider: { name, definition, credential: resolution.credential }, warnings: resolution.credential.warnings };
|
|
62937
62762
|
}
|
|
62938
62763
|
|
|
62939
|
-
// src/
|
|
62764
|
+
// src/checkReport.ts
|
|
62765
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
62766
|
+
|
|
62767
|
+
// src/cli/envBool.ts
|
|
62768
|
+
var InvalidEnvBoolError = class extends UsageError {
|
|
62769
|
+
constructor(variable, value) {
|
|
62770
|
+
super(`${variable} must be one of true, false, 1 or 0, got "${value}".`);
|
|
62771
|
+
this.variable = variable;
|
|
62772
|
+
this.value = value;
|
|
62773
|
+
this.name = "InvalidEnvBoolError";
|
|
62774
|
+
}
|
|
62775
|
+
variable;
|
|
62776
|
+
value;
|
|
62777
|
+
};
|
|
62778
|
+
function parseEnvBool(variable, value) {
|
|
62779
|
+
if (value === void 0 || value === "") {
|
|
62780
|
+
return void 0;
|
|
62781
|
+
}
|
|
62782
|
+
const parsed = parseBoolWord(value);
|
|
62783
|
+
if (parsed === void 0) {
|
|
62784
|
+
throw new InvalidEnvBoolError(variable, value);
|
|
62785
|
+
}
|
|
62786
|
+
return parsed;
|
|
62787
|
+
}
|
|
62788
|
+
|
|
62789
|
+
// src/launcher/guard.ts
|
|
62790
|
+
var AMBIENT_CREDENTIAL_VARS = [
|
|
62791
|
+
"ANTHROPIC_API_KEY",
|
|
62792
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
62793
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
62794
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
62795
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
62796
|
+
"CLAUDE_CODE_USE_FOUNDRY"
|
|
62797
|
+
];
|
|
62798
|
+
function detectAmbientCredential(env, injected) {
|
|
62799
|
+
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
62800
|
+
const value = env[variable];
|
|
62801
|
+
if (value === void 0 || value === "") {
|
|
62802
|
+
continue;
|
|
62803
|
+
}
|
|
62804
|
+
if (injected?.variable === variable && value === injected.token) {
|
|
62805
|
+
continue;
|
|
62806
|
+
}
|
|
62807
|
+
return { variable };
|
|
62808
|
+
}
|
|
62809
|
+
return void 0;
|
|
62810
|
+
}
|
|
62811
|
+
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
62812
|
+
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
62813
|
+
return [
|
|
62814
|
+
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
62815
|
+
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
62816
|
+
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
62817
|
+
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
62818
|
+
`\`${identitySetCommand}\`.`
|
|
62819
|
+
].join("\n");
|
|
62820
|
+
}
|
|
62821
|
+
function evaluateAmbientCredentialGuard(params) {
|
|
62822
|
+
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
62823
|
+
if (detected === void 0) {
|
|
62824
|
+
return { ok: true };
|
|
62825
|
+
}
|
|
62826
|
+
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
62827
|
+
return { ok: true };
|
|
62828
|
+
}
|
|
62829
|
+
return {
|
|
62830
|
+
ok: false,
|
|
62831
|
+
variable: detected.variable,
|
|
62832
|
+
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
62833
|
+
};
|
|
62834
|
+
}
|
|
62835
|
+
|
|
62836
|
+
// src/checkReport.ts
|
|
62940
62837
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
62941
62838
|
function projectFragmentOf(rawKey) {
|
|
62942
62839
|
return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
|
|
@@ -63217,85 +63114,92 @@ function loadCheckProvider(paths, name) {
|
|
|
63217
63114
|
}
|
|
63218
63115
|
return definition === void 0 ? { name, problem: `no provider named "${name}"` } : { name, definition };
|
|
63219
63116
|
}
|
|
63117
|
+
function collectCheckReport(params) {
|
|
63118
|
+
const { paths, cwd } = params;
|
|
63119
|
+
const home = import_node_os5.default.homedir();
|
|
63120
|
+
const claudeHome = resolveClaudeHome();
|
|
63121
|
+
const read = cosmiconfigReader();
|
|
63122
|
+
const classification = loadClassification(paths);
|
|
63123
|
+
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
63124
|
+
const selections = readDirectorySelections(loaded);
|
|
63125
|
+
const git = resolveGitBranch(realRunPort, cwd);
|
|
63126
|
+
const decidedIdentity = decideIdentity({
|
|
63127
|
+
env: params.env,
|
|
63128
|
+
argv0Identity: params.identity,
|
|
63129
|
+
directoryPinnedIdentity: selections.identity,
|
|
63130
|
+
readActiveIdentityFile: () => {
|
|
63131
|
+
const raw = realFsPort.readFileUtf8(paths.activeIdentityFile);
|
|
63132
|
+
if (raw === void 0) {
|
|
63133
|
+
return void 0;
|
|
63134
|
+
}
|
|
63135
|
+
const trimmed = raw.trim();
|
|
63136
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
63137
|
+
}
|
|
63138
|
+
});
|
|
63139
|
+
let poolPick;
|
|
63140
|
+
if (decidedIdentity.pool !== void 0) {
|
|
63141
|
+
const pool = loaded.globalConfig?.pools?.[decidedIdentity.pool];
|
|
63142
|
+
if (pool === void 0) {
|
|
63143
|
+
throw new PoolNotFoundError(decidedIdentity.pool);
|
|
63144
|
+
}
|
|
63145
|
+
poolPick = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: decidedIdentity.pool, pool, directory: cwd, nowMs: Date.now() });
|
|
63146
|
+
}
|
|
63147
|
+
const identityDecision = poolPick?.pick === void 0 ? decidedIdentity : { ...decidedIdentity, name: poolPick.pick };
|
|
63148
|
+
const loadedIdentity = identityDecision.name === void 0 ? void 0 : loadIdentity(paths.identitiesDir, identityDecision.name, realFsPort);
|
|
63149
|
+
const configProfileDecision = decideConfigProfile({
|
|
63150
|
+
env: params.env,
|
|
63151
|
+
directoryRuleConfigProfile: selections.configProfile,
|
|
63152
|
+
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
63153
|
+
globalDefaultConfigProfile: loaded.globalConfig?.defaultConfigProfile
|
|
63154
|
+
});
|
|
63155
|
+
const cascade = loadCascadeInput({
|
|
63156
|
+
paths,
|
|
63157
|
+
home,
|
|
63158
|
+
cwd,
|
|
63159
|
+
read,
|
|
63160
|
+
...configProfileDecision.name === void 0 ? {} : { baseConfigProfile: configProfileDecision.name }
|
|
63161
|
+
}).input;
|
|
63162
|
+
const providerName = cascadeProviderName(cascade);
|
|
63163
|
+
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
63164
|
+
const farmRoot = identityDecision.name === void 0 ? void 0 : import_node_path26.default.join(paths.identitiesDir, identityDecision.name);
|
|
63165
|
+
const settingsFiles = {
|
|
63166
|
+
"settings.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.json")),
|
|
63167
|
+
"settings.local.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.local.json"))
|
|
63168
|
+
};
|
|
63169
|
+
const report = runCheck({
|
|
63170
|
+
cwd,
|
|
63171
|
+
home,
|
|
63172
|
+
claudeHome,
|
|
63173
|
+
env: params.env,
|
|
63174
|
+
...git.branch === void 0 ? {} : { branch: git.branch },
|
|
63175
|
+
...git.branchDetached === void 0 ? {} : { branchDetached: git.branchDetached },
|
|
63176
|
+
nowMs: Date.now(),
|
|
63177
|
+
farmFs: realFarmFs,
|
|
63178
|
+
cascade,
|
|
63179
|
+
classification,
|
|
63180
|
+
...identityDecision.name === void 0 ? {} : { identityName: identityDecision.name },
|
|
63181
|
+
identitySource: identityDecision.source,
|
|
63182
|
+
...poolPick === void 0 ? {} : { poolPick },
|
|
63183
|
+
...configProfileDecision.name === void 0 ? {} : { configProfileName: configProfileDecision.name },
|
|
63184
|
+
configProfileSource: configProfileDecision.source,
|
|
63185
|
+
...loadedIdentity === void 0 ? {} : { identity: loadedIdentity.config },
|
|
63186
|
+
settingsFiles,
|
|
63187
|
+
run: realRunPort,
|
|
63188
|
+
...farmRoot === void 0 ? {} : { farmRoot },
|
|
63189
|
+
platform: process.platform,
|
|
63190
|
+
...provider === void 0 ? {} : { provider }
|
|
63191
|
+
});
|
|
63192
|
+
return report;
|
|
63193
|
+
}
|
|
63194
|
+
|
|
63195
|
+
// src/check.ts
|
|
63220
63196
|
function registerCheckCommand(program2, deps) {
|
|
63221
63197
|
const { paths } = deps;
|
|
63222
63198
|
const command = program2.command("check [path]").description(
|
|
63223
63199
|
"Show what a launch in a directory would share or hide and why, plus credential and settings diagnostics. Never touches the farm or spawns claude."
|
|
63224
63200
|
).option("--identity <name>", "Identity to check (defaults to the identity a launch there would resolve).").option("--json", "Print the report as JSON.").option("--strict", "Exit 1 when the report carries any warning, not only on errors.").action((pathArg, options) => {
|
|
63225
|
-
const cwd = pathArg === void 0 ? process.cwd() :
|
|
63226
|
-
const
|
|
63227
|
-
const claudeHome = resolveClaudeHome();
|
|
63228
|
-
const read = cosmiconfigReader();
|
|
63229
|
-
const classification = loadClassification(paths);
|
|
63230
|
-
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
63231
|
-
const selections = readDirectorySelections(loaded);
|
|
63232
|
-
const git = resolveGitBranch(realRunPort, cwd);
|
|
63233
|
-
const decidedIdentity = decideIdentity({
|
|
63234
|
-
env: process.env,
|
|
63235
|
-
argv0Identity: options.identity,
|
|
63236
|
-
directoryPinnedIdentity: selections.identity,
|
|
63237
|
-
readActiveIdentityFile: () => {
|
|
63238
|
-
const raw = realFsPort.readFileUtf8(paths.activeIdentityFile);
|
|
63239
|
-
if (raw === void 0) {
|
|
63240
|
-
return void 0;
|
|
63241
|
-
}
|
|
63242
|
-
const trimmed = raw.trim();
|
|
63243
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
63244
|
-
}
|
|
63245
|
-
});
|
|
63246
|
-
let poolPick;
|
|
63247
|
-
if (decidedIdentity.pool !== void 0) {
|
|
63248
|
-
const pool = loaded.globalConfig?.pools?.[decidedIdentity.pool];
|
|
63249
|
-
if (pool === void 0) {
|
|
63250
|
-
throw new PoolNotFoundError(decidedIdentity.pool);
|
|
63251
|
-
}
|
|
63252
|
-
poolPick = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: decidedIdentity.pool, pool, directory: cwd, nowMs: Date.now() });
|
|
63253
|
-
}
|
|
63254
|
-
const identityDecision = poolPick?.pick === void 0 ? decidedIdentity : { ...decidedIdentity, name: poolPick.pick };
|
|
63255
|
-
const loadedIdentity = identityDecision.name === void 0 ? void 0 : loadIdentity(paths.identitiesDir, identityDecision.name, realFsPort);
|
|
63256
|
-
const configProfileDecision = decideConfigProfile({
|
|
63257
|
-
env: process.env,
|
|
63258
|
-
directoryRuleConfigProfile: selections.configProfile,
|
|
63259
|
-
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
63260
|
-
globalDefaultConfigProfile: loaded.globalConfig?.defaultConfigProfile
|
|
63261
|
-
});
|
|
63262
|
-
const cascade = loadCascadeInput({
|
|
63263
|
-
paths,
|
|
63264
|
-
home,
|
|
63265
|
-
cwd,
|
|
63266
|
-
read,
|
|
63267
|
-
...configProfileDecision.name === void 0 ? {} : { baseConfigProfile: configProfileDecision.name }
|
|
63268
|
-
}).input;
|
|
63269
|
-
const providerName = cascadeProviderName(cascade);
|
|
63270
|
-
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
63271
|
-
const farmRoot = identityDecision.name === void 0 ? void 0 : import_node_path26.default.join(paths.identitiesDir, identityDecision.name);
|
|
63272
|
-
const settingsFiles = {
|
|
63273
|
-
"settings.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.json")),
|
|
63274
|
-
"settings.local.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.local.json"))
|
|
63275
|
-
};
|
|
63276
|
-
const report = runCheck({
|
|
63277
|
-
cwd,
|
|
63278
|
-
home,
|
|
63279
|
-
claudeHome,
|
|
63280
|
-
env: process.env,
|
|
63281
|
-
...git.branch === void 0 ? {} : { branch: git.branch },
|
|
63282
|
-
...git.branchDetached === void 0 ? {} : { branchDetached: git.branchDetached },
|
|
63283
|
-
nowMs: Date.now(),
|
|
63284
|
-
farmFs: realFarmFs,
|
|
63285
|
-
cascade,
|
|
63286
|
-
classification,
|
|
63287
|
-
...identityDecision.name === void 0 ? {} : { identityName: identityDecision.name },
|
|
63288
|
-
identitySource: identityDecision.source,
|
|
63289
|
-
...poolPick === void 0 ? {} : { poolPick },
|
|
63290
|
-
...configProfileDecision.name === void 0 ? {} : { configProfileName: configProfileDecision.name },
|
|
63291
|
-
configProfileSource: configProfileDecision.source,
|
|
63292
|
-
...loadedIdentity === void 0 ? {} : { identity: loadedIdentity.config },
|
|
63293
|
-
settingsFiles,
|
|
63294
|
-
run: realRunPort,
|
|
63295
|
-
...farmRoot === void 0 ? {} : { farmRoot },
|
|
63296
|
-
platform: process.platform,
|
|
63297
|
-
...provider === void 0 ? {} : { provider }
|
|
63298
|
-
});
|
|
63201
|
+
const cwd = pathArg === void 0 ? process.cwd() : import_node_path27.default.resolve(pathArg);
|
|
63202
|
+
const report = collectCheckReport({ paths, cwd, ...options.identity === void 0 ? {} : { identity: options.identity }, env: process.env });
|
|
63299
63203
|
if (options.json === true) {
|
|
63300
63204
|
printJson(checkReportToJson(report));
|
|
63301
63205
|
} else {
|
|
@@ -63314,10 +63218,10 @@ function registerCheckCommand(program2, deps) {
|
|
|
63314
63218
|
var import_node_crypto6 = require("node:crypto");
|
|
63315
63219
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
63316
63220
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
63317
|
-
var
|
|
63221
|
+
var import_node_path29 = __toESM(require("node:path"), 1);
|
|
63318
63222
|
|
|
63319
63223
|
// src/frontdoor/state.ts
|
|
63320
|
-
var
|
|
63224
|
+
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
63321
63225
|
var FRONT_DOOR_PROTOCOL = 1;
|
|
63322
63226
|
var FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1) });
|
|
63323
63227
|
var FrontDoorStateSchema = external_exports.strictObject({
|
|
@@ -63368,7 +63272,7 @@ function readFrontDoorState(fs18, stateFile) {
|
|
|
63368
63272
|
}
|
|
63369
63273
|
}
|
|
63370
63274
|
function writeFrontDoorState(fs18, stateFile, state) {
|
|
63371
|
-
fs18.mkdirp(
|
|
63275
|
+
fs18.mkdirp(import_node_path28.default.dirname(stateFile));
|
|
63372
63276
|
fs18.writeFileUtf8(stateFile, `${JSON.stringify(state, null, 2)}
|
|
63373
63277
|
`);
|
|
63374
63278
|
}
|
|
@@ -63378,7 +63282,7 @@ function frontDoorOrigin(state) {
|
|
|
63378
63282
|
}
|
|
63379
63283
|
function writeFrontDoorSession(fs18, sessionsDir, session) {
|
|
63380
63284
|
fs18.mkdirPrivate(sessionsDir);
|
|
63381
|
-
fs18.writeFilePrivate(
|
|
63285
|
+
fs18.writeFilePrivate(import_node_path28.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
|
|
63382
63286
|
`);
|
|
63383
63287
|
}
|
|
63384
63288
|
function listFrontDoorSessions(fs18, sessionsDir) {
|
|
@@ -63388,7 +63292,7 @@ function listFrontDoorSessions(fs18, sessionsDir) {
|
|
|
63388
63292
|
continue;
|
|
63389
63293
|
}
|
|
63390
63294
|
try {
|
|
63391
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs18.readFileUtf8(
|
|
63295
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs18.readFileUtf8(import_node_path28.default.join(sessionsDir, name)) ?? ""));
|
|
63392
63296
|
if (parsed.success) {
|
|
63393
63297
|
sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt });
|
|
63394
63298
|
}
|
|
@@ -63399,7 +63303,7 @@ function listFrontDoorSessions(fs18, sessionsDir) {
|
|
|
63399
63303
|
return sessions.sort((a2, b) => a2.pid - b.pid);
|
|
63400
63304
|
}
|
|
63401
63305
|
function removeFrontDoorSession(fs18, sessionsDir, pid) {
|
|
63402
|
-
fs18.removeRecursive(
|
|
63306
|
+
fs18.removeRecursive(import_node_path28.default.join(sessionsDir, `${String(pid)}.json`));
|
|
63403
63307
|
}
|
|
63404
63308
|
function pruneDeadFrontDoorSessions(fs18, sessionsDir, isRunning) {
|
|
63405
63309
|
const removed = [];
|
|
@@ -63418,7 +63322,7 @@ function liveSessionTokens(fs18, sessionsDir) {
|
|
|
63418
63322
|
continue;
|
|
63419
63323
|
}
|
|
63420
63324
|
try {
|
|
63421
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs18.readFileUtf8(
|
|
63325
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs18.readFileUtf8(import_node_path28.default.join(sessionsDir, name)) ?? ""));
|
|
63422
63326
|
if (parsed.success) {
|
|
63423
63327
|
tokens.add(parsed.data.token);
|
|
63424
63328
|
}
|
|
@@ -63666,10 +63570,10 @@ async function callCodex(ports, request6, sessionId, signal) {
|
|
|
63666
63570
|
// src/codex/commands.ts
|
|
63667
63571
|
function codexHome(env, home) {
|
|
63668
63572
|
const fromEnv = env.CODEX_HOME;
|
|
63669
|
-
return fromEnv !== void 0 && fromEnv !== "" ? fromEnv :
|
|
63573
|
+
return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : import_node_path29.default.join(home, ".codex");
|
|
63670
63574
|
}
|
|
63671
63575
|
function codexUsageSnapshotPath() {
|
|
63672
|
-
return
|
|
63576
|
+
return import_node_path29.default.join(resolveClaudeHome(), "codex-quota.json");
|
|
63673
63577
|
}
|
|
63674
63578
|
function isEnoent4(error62) {
|
|
63675
63579
|
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
@@ -63698,7 +63602,7 @@ function writeUsageSnapshot(log, snapshot) {
|
|
|
63698
63602
|
const target = codexUsageSnapshotPath();
|
|
63699
63603
|
const temp = `${target}.${String(process.pid)}.tmp`;
|
|
63700
63604
|
try {
|
|
63701
|
-
import_node_fs10.default.mkdirSync(
|
|
63605
|
+
import_node_fs10.default.mkdirSync(import_node_path29.default.dirname(target), { recursive: true });
|
|
63702
63606
|
import_node_fs10.default.writeFileSync(temp, `${JSON.stringify(snapshot, null, 2)}
|
|
63703
63607
|
`);
|
|
63704
63608
|
import_node_fs10.default.renameSync(temp, target);
|
|
@@ -63709,7 +63613,7 @@ function writeUsageSnapshot(log, snapshot) {
|
|
|
63709
63613
|
function createCodexRoutePorts(log) {
|
|
63710
63614
|
const agent = createUpstreamAgent();
|
|
63711
63615
|
const upstreamFetch = createUpstreamFetch(agent);
|
|
63712
|
-
const auth = createCodexAuthStore(
|
|
63616
|
+
const auth = createCodexAuthStore(import_node_path29.default.join(codexHome(process.env, import_node_os6.default.homedir()), "auth.json"), {
|
|
63713
63617
|
fs: realCodexAuthFs,
|
|
63714
63618
|
fetch: upstreamFetch,
|
|
63715
63619
|
now: () => /* @__PURE__ */ new Date(),
|
|
@@ -63784,7 +63688,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
63784
63688
|
|
|
63785
63689
|
// src/frontdoor/commands.ts
|
|
63786
63690
|
var import_node_crypto13 = require("node:crypto");
|
|
63787
|
-
var
|
|
63691
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
63788
63692
|
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
63789
63693
|
|
|
63790
63694
|
// src/frontdoor/custody.ts
|
|
@@ -63924,7 +63828,7 @@ function isLiveCapability(presented, live) {
|
|
|
63924
63828
|
|
|
63925
63829
|
// src/frontdoor/capture.ts
|
|
63926
63830
|
var fs11 = __toESM(require("node:fs"), 1);
|
|
63927
|
-
var
|
|
63831
|
+
var path30 = __toESM(require("node:path"), 1);
|
|
63928
63832
|
var SECRET_HEADER_NAME = /authorization|cookie|token|secret|credential|api[-_]key/i;
|
|
63929
63833
|
var SECRET_JSON_KEY = /token|secret|password|credential|authorization|api[-_]key/i;
|
|
63930
63834
|
var SECRET_BODY_PATTERNS = [
|
|
@@ -63968,10 +63872,10 @@ function redactBody(chunk) {
|
|
|
63968
63872
|
}
|
|
63969
63873
|
var CAPTURE_ENV = "AGENT_SHIM_FRONTDOOR_CAPTURE";
|
|
63970
63874
|
function captureFromEnv(env, logsDir) {
|
|
63971
|
-
return env[CAPTURE_ENV] === "1" ? createFileCapture(
|
|
63875
|
+
return env[CAPTURE_ENV] === "1" ? createFileCapture(path30.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
|
|
63972
63876
|
}
|
|
63973
63877
|
function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
63974
|
-
fs11.mkdirSync(
|
|
63878
|
+
fs11.mkdirSync(path30.dirname(file2), { recursive: true });
|
|
63975
63879
|
let nextId = 0;
|
|
63976
63880
|
const append = (record2) => {
|
|
63977
63881
|
fs11.appendFileSync(file2, `${JSON.stringify({ ts: now().toISOString(), ...record2 })}
|
|
@@ -64514,8 +64418,8 @@ function parseConnectTarget(authority) {
|
|
|
64514
64418
|
}
|
|
64515
64419
|
return { host, port };
|
|
64516
64420
|
}
|
|
64517
|
-
function servedByPipeline(
|
|
64518
|
-
return
|
|
64421
|
+
function servedByPipeline(path40) {
|
|
64422
|
+
return path40?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
64519
64423
|
}
|
|
64520
64424
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
64521
64425
|
"connection",
|
|
@@ -64595,7 +64499,7 @@ async function startConnectServer(config2, effects, preferredPort) {
|
|
|
64595
64499
|
${request6.rawHeaders.reduce((accumulated, value, index) => index % 2 === 0 ? `${accumulated}${value}: ` : `${accumulated}${value}\r
|
|
64596
64500
|
`, "")}\r
|
|
64597
64501
|
`;
|
|
64598
|
-
pumpTapSession(socket, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn),
|
|
64502
|
+
pumpTapSession(socket, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn), config2.capture?.tapStream?.(host), Buffer.from(headText, "utf8"));
|
|
64599
64503
|
};
|
|
64600
64504
|
const sessions = config2.interceptHosts.map((host) => {
|
|
64601
64505
|
if (config2.tapHosts.includes(host)) {
|
|
@@ -66337,8 +66241,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
66337
66241
|
request6.body.resume();
|
|
66338
66242
|
return;
|
|
66339
66243
|
}
|
|
66340
|
-
const
|
|
66341
|
-
const translated = { method: request6.method, path:
|
|
66244
|
+
const path40 = new URL(request6.url, "http://127.0.0.1").pathname;
|
|
66245
|
+
const translated = { method: request6.method, path: path40, body, signal: request6.signal };
|
|
66342
66246
|
const routed = await route(translated);
|
|
66343
66247
|
if (request6.signal.aborted) {
|
|
66344
66248
|
return;
|
|
@@ -66372,7 +66276,7 @@ function createPassthroughRoute(name, target) {
|
|
|
66372
66276
|
headroomUpstream: target.headroomUpstream,
|
|
66373
66277
|
serve: async (request6, response) => {
|
|
66374
66278
|
const incoming = new URL(request6.url, "http://127.0.0.1");
|
|
66375
|
-
const
|
|
66279
|
+
const path40 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
66376
66280
|
const headers = forwardableHeaders(request6.headers);
|
|
66377
66281
|
delete headers.host;
|
|
66378
66282
|
await new Promise((resolve) => {
|
|
@@ -66380,7 +66284,7 @@ function createPassthroughRoute(name, target) {
|
|
|
66380
66284
|
host: base.hostname,
|
|
66381
66285
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
66382
66286
|
method: request6.method,
|
|
66383
|
-
path: `${basePath}${
|
|
66287
|
+
path: `${basePath}${path40}${incoming.search}`,
|
|
66384
66288
|
headers,
|
|
66385
66289
|
agent
|
|
66386
66290
|
};
|
|
@@ -66442,10 +66346,10 @@ function createProviderRouteResolver(deps) {
|
|
|
66442
66346
|
return route;
|
|
66443
66347
|
};
|
|
66444
66348
|
const resolve = (request6) => {
|
|
66445
|
-
const
|
|
66446
|
-
const scoped = parseProviderPath(
|
|
66349
|
+
const path40 = new URL(request6.url, "http://127.0.0.1").pathname;
|
|
66350
|
+
const scoped = parseProviderPath(path40);
|
|
66447
66351
|
if (scoped === void 0) {
|
|
66448
|
-
return
|
|
66352
|
+
return path40.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path40}` };
|
|
66449
66353
|
}
|
|
66450
66354
|
const { provider } = scoped;
|
|
66451
66355
|
let definition;
|
|
@@ -66486,11 +66390,11 @@ function createProviderRouteResolver(deps) {
|
|
|
66486
66390
|
|
|
66487
66391
|
// src/frontdoor/trust.ts
|
|
66488
66392
|
var import_node_crypto12 = require("node:crypto");
|
|
66489
|
-
var
|
|
66393
|
+
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
66490
66394
|
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
66491
66395
|
function resolveTrustBundle(params) {
|
|
66492
66396
|
const { caCertFile, bundlesDir, inherited, fs: fs18 } = params;
|
|
66493
|
-
if (inherited === void 0 || inherited === "" ||
|
|
66397
|
+
if (inherited === void 0 || inherited === "" || import_node_path30.default.resolve(inherited) === import_node_path30.default.resolve(caCertFile)) {
|
|
66494
66398
|
return { path: caCertFile };
|
|
66495
66399
|
}
|
|
66496
66400
|
const caPem = fs18.readFileUtf8(caCertFile);
|
|
@@ -66508,7 +66412,7 @@ function resolveTrustBundle(params) {
|
|
|
66508
66412
|
}
|
|
66509
66413
|
const combined = `${inheritedPem.trimEnd()}
|
|
66510
66414
|
${caPem}`;
|
|
66511
|
-
const bundle =
|
|
66415
|
+
const bundle = import_node_path30.default.join(bundlesDir, `${(0, import_node_crypto12.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
66512
66416
|
if (!fs18.exists(bundle)) {
|
|
66513
66417
|
fs18.mkdirp(bundlesDir);
|
|
66514
66418
|
fs18.writeFileAtomic(bundle, combined);
|
|
@@ -66878,7 +66782,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66878
66782
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
66879
66783
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
66880
66784
|
if (capture !== void 0) {
|
|
66881
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
66785
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path31.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
66882
66786
|
}
|
|
66883
66787
|
const server = await startConnectServer(
|
|
66884
66788
|
{
|
|
@@ -67328,15 +67232,15 @@ var import_node_child_process4 = require("node:child_process");
|
|
|
67328
67232
|
|
|
67329
67233
|
// src/identityToken.ts
|
|
67330
67234
|
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
67331
|
-
var
|
|
67235
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
67332
67236
|
var TOKEN_FILE_MODE = 384;
|
|
67333
67237
|
var TOKEN_DIR_MODE = 448;
|
|
67334
67238
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
67335
67239
|
function identityTokenDir(paths) {
|
|
67336
|
-
return
|
|
67240
|
+
return import_node_path32.default.join(paths.root, "credentials");
|
|
67337
67241
|
}
|
|
67338
67242
|
function identityTokenPath(paths, identityName) {
|
|
67339
|
-
return
|
|
67243
|
+
return import_node_path32.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
67340
67244
|
}
|
|
67341
67245
|
function storeIdentityToken(paths, identityName, raw) {
|
|
67342
67246
|
const token = raw.trim();
|
|
@@ -67347,7 +67251,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
67347
67251
|
import_node_fs12.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
67348
67252
|
import_node_fs12.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
67349
67253
|
const target = identityTokenPath(paths, identityName);
|
|
67350
|
-
const temp =
|
|
67254
|
+
const temp = import_node_path32.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
67351
67255
|
import_node_fs12.default.writeFileSync(temp, `${token}
|
|
67352
67256
|
`, { mode: TOKEN_FILE_MODE });
|
|
67353
67257
|
import_node_fs12.default.renameSync(temp, target);
|
|
@@ -67357,7 +67261,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
67357
67261
|
// src/realCredentialCache.ts
|
|
67358
67262
|
var import_node_child_process3 = require("node:child_process");
|
|
67359
67263
|
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
67360
|
-
var
|
|
67264
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
67361
67265
|
var KEYCHAIN_CACHE_SERVICE = "agent-shim-credential-cache";
|
|
67362
67266
|
var CACHE_DIR_MODE = 448;
|
|
67363
67267
|
var CACHE_FILE_MODE = 384;
|
|
@@ -67384,8 +67288,8 @@ function security(args, stdin2) {
|
|
|
67384
67288
|
return { status: result.status, stdout: result.stdout };
|
|
67385
67289
|
}
|
|
67386
67290
|
function createRealCredentialCache(root) {
|
|
67387
|
-
const dir =
|
|
67388
|
-
const filePath = (owner) =>
|
|
67291
|
+
const dir = import_node_path33.default.join(root, "credential-cache");
|
|
67292
|
+
const filePath = (owner) => import_node_path33.default.join(dir, cacheFileNameFor(owner));
|
|
67389
67293
|
return {
|
|
67390
67294
|
read(store, owner) {
|
|
67391
67295
|
if (store === "file") {
|
|
@@ -67562,9 +67466,9 @@ function subjectName(positional, provider) {
|
|
|
67562
67466
|
return name;
|
|
67563
67467
|
}
|
|
67564
67468
|
|
|
67565
|
-
// src/
|
|
67469
|
+
// src/doctorReport.ts
|
|
67566
67470
|
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
67567
|
-
var
|
|
67471
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
67568
67472
|
|
|
67569
67473
|
// src/headroom/source.ts
|
|
67570
67474
|
var GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
@@ -67591,7 +67495,7 @@ function parseInstalledCommit(directUrlJson) {
|
|
|
67591
67495
|
}
|
|
67592
67496
|
}
|
|
67593
67497
|
|
|
67594
|
-
// src/
|
|
67498
|
+
// src/doctorReport.ts
|
|
67595
67499
|
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
67596
67500
|
if (status.status !== "shadowed") {
|
|
67597
67501
|
return status;
|
|
@@ -67615,7 +67519,7 @@ function validateJson(schema, input2) {
|
|
|
67615
67519
|
return { ok: true, data: result.data };
|
|
67616
67520
|
}
|
|
67617
67521
|
function pushPathResolution(push, resolution) {
|
|
67618
|
-
const ownDir =
|
|
67522
|
+
const ownDir = import_node_path34.default.dirname(resolution.ownExecutablePath);
|
|
67619
67523
|
switch (resolution.agentShim.status) {
|
|
67620
67524
|
case "ok":
|
|
67621
67525
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -67683,14 +67587,14 @@ function pushProvider(push, entry) {
|
|
|
67683
67587
|
}
|
|
67684
67588
|
function pushLegacyName(push, params) {
|
|
67685
67589
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
67686
|
-
if (legacyVariables.length === 0 &&
|
|
67590
|
+
if (legacyVariables.length === 0 && import_node_path34.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
67687
67591
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
67688
67592
|
return;
|
|
67689
67593
|
}
|
|
67690
67594
|
for (const name of legacyVariables) {
|
|
67691
67595
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
67692
67596
|
}
|
|
67693
|
-
if (
|
|
67597
|
+
if (import_node_path34.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
67694
67598
|
push(
|
|
67695
67599
|
"legacy-name",
|
|
67696
67600
|
"warn",
|
|
@@ -67994,80 +67898,87 @@ function realpathOrSelf(target) {
|
|
|
67994
67898
|
return target;
|
|
67995
67899
|
}
|
|
67996
67900
|
}
|
|
67901
|
+
function collectDoctorReport(params) {
|
|
67902
|
+
const { paths } = params;
|
|
67903
|
+
const identityNames = import_node_fs14.default.existsSync(paths.identitiesDir) ? import_node_fs14.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
67904
|
+
const identities = identityNames.map((name) => {
|
|
67905
|
+
const farmRoot = import_node_path34.default.join(paths.identitiesDir, name);
|
|
67906
|
+
const identityPath = import_node_path34.default.join(farmRoot, "identity.json");
|
|
67907
|
+
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
67908
|
+
});
|
|
67909
|
+
const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
67910
|
+
const configProfiles = profileNames.map((name) => {
|
|
67911
|
+
const profilePath = import_node_path34.default.join(paths.configProfilesDir, `${name}.json`);
|
|
67912
|
+
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
67913
|
+
});
|
|
67914
|
+
const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
67915
|
+
const providers = providerNames.map((name) => {
|
|
67916
|
+
const providerPath = import_node_path34.default.join(paths.providersDir, `${name}.json`);
|
|
67917
|
+
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
67918
|
+
});
|
|
67919
|
+
const ownExecutablePath = realOwnExecutablePath();
|
|
67920
|
+
let binaryDiscovery;
|
|
67921
|
+
try {
|
|
67922
|
+
const binary = realResolveClaudeBinary(resolveOwnInstallDirs(paths, ownExecutablePath))();
|
|
67923
|
+
binaryDiscovery = { ok: true, binary };
|
|
67924
|
+
} catch (error62) {
|
|
67925
|
+
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
67926
|
+
}
|
|
67927
|
+
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
67928
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path34.default.delimiter).filter((dir) => dir !== "");
|
|
67929
|
+
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
67930
|
+
findPathShadow({
|
|
67931
|
+
pathDirs,
|
|
67932
|
+
targetDir: import_node_path34.default.dirname(shimState.targetPath),
|
|
67933
|
+
targetFilename: import_node_path34.default.basename(shimState.targetPath),
|
|
67934
|
+
findExecutableInDir
|
|
67935
|
+
}),
|
|
67936
|
+
shimState.targetPath,
|
|
67937
|
+
realpathOrSelf
|
|
67938
|
+
);
|
|
67939
|
+
const report = runDoctor({
|
|
67940
|
+
env: params.env,
|
|
67941
|
+
identities,
|
|
67942
|
+
configProfiles,
|
|
67943
|
+
providers,
|
|
67944
|
+
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
67945
|
+
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
67946
|
+
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
67947
|
+
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
67948
|
+
binaryDiscovery,
|
|
67949
|
+
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs14.default.existsSync(shimState.targetPath) },
|
|
67950
|
+
rootPath: paths.root,
|
|
67951
|
+
pathResolution: {
|
|
67952
|
+
ownExecutablePath,
|
|
67953
|
+
agentShim: refinePathShadow(
|
|
67954
|
+
findPathShadow({
|
|
67955
|
+
pathDirs,
|
|
67956
|
+
targetDir: import_node_path34.default.dirname(ownExecutablePath),
|
|
67957
|
+
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
67958
|
+
findExecutableInDir
|
|
67959
|
+
}),
|
|
67960
|
+
ownExecutablePath,
|
|
67961
|
+
realpathOrSelf
|
|
67962
|
+
),
|
|
67963
|
+
...claudeShimShadow === void 0 ? {} : { claude: claudeShimShadow }
|
|
67964
|
+
},
|
|
67965
|
+
run: realRunPort,
|
|
67966
|
+
platform: process.platform,
|
|
67967
|
+
headroom: {
|
|
67968
|
+
state: { path: paths.headroomStateFile, raw: realFsPort.readFileUtf8(paths.headroomStateFile) },
|
|
67969
|
+
isRunning: realIsProcessRunning
|
|
67970
|
+
}
|
|
67971
|
+
});
|
|
67972
|
+
return report;
|
|
67973
|
+
}
|
|
67974
|
+
|
|
67975
|
+
// src/doctor.ts
|
|
67997
67976
|
function registerDoctorCommand(program2, deps) {
|
|
67998
67977
|
const { paths } = deps;
|
|
67999
67978
|
const command = program2.command("doctor").description(
|
|
68000
67979
|
"Audit the whole ~/.agent-shim config graph: every identity, every configuration profile's extends chain, every provider, directory-rules.json, config.json, categories.local.json, active-identity, and real Claude Code binary discoverability. Identity/directory-agnostic, unlike `check`. Exits 1 when any check fails."
|
|
68001
67980
|
).option("--json", "Print the report as JSON.").action((options) => {
|
|
68002
|
-
const
|
|
68003
|
-
const identities = identityNames.map((name) => {
|
|
68004
|
-
const farmRoot = import_node_path33.default.join(paths.identitiesDir, name);
|
|
68005
|
-
const identityPath = import_node_path33.default.join(farmRoot, "identity.json");
|
|
68006
|
-
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
68007
|
-
});
|
|
68008
|
-
const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
68009
|
-
const configProfiles = profileNames.map((name) => {
|
|
68010
|
-
const profilePath = import_node_path33.default.join(paths.configProfilesDir, `${name}.json`);
|
|
68011
|
-
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
68012
|
-
});
|
|
68013
|
-
const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
68014
|
-
const providers = providerNames.map((name) => {
|
|
68015
|
-
const providerPath = import_node_path33.default.join(paths.providersDir, `${name}.json`);
|
|
68016
|
-
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
68017
|
-
});
|
|
68018
|
-
const ownExecutablePath = realOwnExecutablePath();
|
|
68019
|
-
let binaryDiscovery;
|
|
68020
|
-
try {
|
|
68021
|
-
const binary = realResolveClaudeBinary(resolveOwnInstallDirs(paths, ownExecutablePath))();
|
|
68022
|
-
binaryDiscovery = { ok: true, binary };
|
|
68023
|
-
} catch (error62) {
|
|
68024
|
-
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
68025
|
-
}
|
|
68026
|
-
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
68027
|
-
const pathDirs = (process.env.PATH ?? "").split(import_node_path33.default.delimiter).filter((dir) => dir !== "");
|
|
68028
|
-
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
68029
|
-
findPathShadow({
|
|
68030
|
-
pathDirs,
|
|
68031
|
-
targetDir: import_node_path33.default.dirname(shimState.targetPath),
|
|
68032
|
-
targetFilename: import_node_path33.default.basename(shimState.targetPath),
|
|
68033
|
-
findExecutableInDir
|
|
68034
|
-
}),
|
|
68035
|
-
shimState.targetPath,
|
|
68036
|
-
realpathOrSelf
|
|
68037
|
-
);
|
|
68038
|
-
const report = runDoctor({
|
|
68039
|
-
env: process.env,
|
|
68040
|
-
identities,
|
|
68041
|
-
configProfiles,
|
|
68042
|
-
providers,
|
|
68043
|
-
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
68044
|
-
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
68045
|
-
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
68046
|
-
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
68047
|
-
binaryDiscovery,
|
|
68048
|
-
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs14.default.existsSync(shimState.targetPath) },
|
|
68049
|
-
rootPath: paths.root,
|
|
68050
|
-
pathResolution: {
|
|
68051
|
-
ownExecutablePath,
|
|
68052
|
-
agentShim: refinePathShadow(
|
|
68053
|
-
findPathShadow({
|
|
68054
|
-
pathDirs,
|
|
68055
|
-
targetDir: import_node_path33.default.dirname(ownExecutablePath),
|
|
68056
|
-
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
68057
|
-
findExecutableInDir
|
|
68058
|
-
}),
|
|
68059
|
-
ownExecutablePath,
|
|
68060
|
-
realpathOrSelf
|
|
68061
|
-
),
|
|
68062
|
-
...claudeShimShadow === void 0 ? {} : { claude: claudeShimShadow }
|
|
68063
|
-
},
|
|
68064
|
-
run: realRunPort,
|
|
68065
|
-
platform: process.platform,
|
|
68066
|
-
headroom: {
|
|
68067
|
-
state: { path: paths.headroomStateFile, raw: realFsPort.readFileUtf8(paths.headroomStateFile) },
|
|
68068
|
-
isRunning: realIsProcessRunning
|
|
68069
|
-
}
|
|
68070
|
-
});
|
|
67981
|
+
const report = collectDoctorReport({ paths, env: process.env });
|
|
68071
67982
|
if (options.json === true) {
|
|
68072
67983
|
printJson(report);
|
|
68073
67984
|
} else {
|
|
@@ -68085,7 +67996,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
68085
67996
|
// src/headroom/commands.ts
|
|
68086
67997
|
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
68087
67998
|
var import_node_net3 = __toESM(require("node:net"), 1);
|
|
68088
|
-
var
|
|
67999
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
68089
68000
|
var import_node_child_process5 = require("node:child_process");
|
|
68090
68001
|
|
|
68091
68002
|
// src/headroom/settings.ts
|
|
@@ -68500,12 +68411,12 @@ function readInstalledHeadroomCommit() {
|
|
|
68500
68411
|
if (toolDir.status !== 0) {
|
|
68501
68412
|
return void 0;
|
|
68502
68413
|
}
|
|
68503
|
-
const libDir =
|
|
68414
|
+
const libDir = import_node_path35.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
68504
68415
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
68505
|
-
const sitePackages =
|
|
68416
|
+
const sitePackages = import_node_path35.default.join(libDir, python, "site-packages");
|
|
68506
68417
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
68507
68418
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
68508
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
68419
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path35.default.join(sitePackages, entry, "direct_url.json"));
|
|
68509
68420
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
68510
68421
|
}
|
|
68511
68422
|
}
|
|
@@ -68643,6 +68554,118 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
68643
68554
|
});
|
|
68644
68555
|
}
|
|
68645
68556
|
|
|
68557
|
+
// src/pools.ts
|
|
68558
|
+
function formatPoolPick(report, nowMs) {
|
|
68559
|
+
const head = report.pick === void 0 ? `Pool ${report.pool}: every member is refused right now${report.earliestReturn === void 0 ? "" : `; ${report.earliestReturn.identity} returns at ${report.earliestReturn.at} (in ${formatAge(Date.parse(report.earliestReturn.at) - nowMs)})`}` : `Pool ${report.pool}: a launch from ${report.directory} would run as ${report.pick}`;
|
|
68560
|
+
const rows = report.candidates.map((candidate, index) => {
|
|
68561
|
+
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}`;
|
|
68562
|
+
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
68563
|
+
return ` ${String(index + 1)}. ${candidate.identity} [${candidate.class}${score}]${dry}
|
|
68564
|
+
${candidate.reasons.join("; ")}`;
|
|
68565
|
+
});
|
|
68566
|
+
return [head, ...rows, ...report.missing.map((name) => ` (skipped: ${name} is not an identity)`), ...report.stickyProblem === void 0 ? [] : [`Note: ${report.stickyProblem}; the last-pick record was ignored.`]];
|
|
68567
|
+
}
|
|
68568
|
+
function requireIdentities(paths, names) {
|
|
68569
|
+
const existing = new Set(listIdentities(paths).map((entry) => entry.name));
|
|
68570
|
+
for (const name of names) {
|
|
68571
|
+
if (!existing.has(name)) {
|
|
68572
|
+
throw new IdentityNotFoundError(name);
|
|
68573
|
+
}
|
|
68574
|
+
}
|
|
68575
|
+
}
|
|
68576
|
+
function membersOf(options) {
|
|
68577
|
+
if (options.identity === void 0 || options.identity.length === 0) {
|
|
68578
|
+
throw new UsageError("A pool needs at least one member: pass --identity <name> (repeatable).");
|
|
68579
|
+
}
|
|
68580
|
+
return options.identity;
|
|
68581
|
+
}
|
|
68582
|
+
function registerPoolCommand(program2, deps) {
|
|
68583
|
+
const { paths } = deps;
|
|
68584
|
+
const pool = withExamples(
|
|
68585
|
+
program2.command("pool").description("Manage pools: named sets of identities that a launch picks one member of, by remaining quota, with `claude @pool:<name>`."),
|
|
68586
|
+
["agent-shim pool add subs --identity work --identity personal", "agent-shim pool pick subs"]
|
|
68587
|
+
);
|
|
68588
|
+
withExamples(
|
|
68589
|
+
pool.command("add <name>").description("Define a pool. Fails if one with this name already exists.").option("--identity <name>", "A member identity (repeatable).", collectRepeated).action((name, options) => {
|
|
68590
|
+
const members2 = membersOf(options);
|
|
68591
|
+
requireIdentities(paths, members2);
|
|
68592
|
+
addPool(paths, name, members2);
|
|
68593
|
+
console.log(`Created pool "${name}" with ${members2.join(", ")}.`);
|
|
68594
|
+
}),
|
|
68595
|
+
["agent-shim pool add subs --identity work --identity personal"]
|
|
68596
|
+
);
|
|
68597
|
+
withExamples(
|
|
68598
|
+
pool.command("set <name>").description("Replace a pool's members.").option("--identity <name>", "A member identity (repeatable); the full new list.", collectRepeated).action((name, options) => {
|
|
68599
|
+
const members2 = membersOf(options);
|
|
68600
|
+
requireIdentities(paths, members2);
|
|
68601
|
+
setPool(paths, name, members2);
|
|
68602
|
+
console.log(`Pool "${name}" now has ${members2.join(", ")}.`);
|
|
68603
|
+
}),
|
|
68604
|
+
["agent-shim pool set subs --identity work --identity personal --identity spare"]
|
|
68605
|
+
);
|
|
68606
|
+
withExamples(
|
|
68607
|
+
pool.command("list").description("List every pool and its members, marking the active selection with *.").option("--json", "Print the pools as JSON.").action((options) => {
|
|
68608
|
+
const pools = readPools(paths);
|
|
68609
|
+
const active = readActiveIdentity(paths);
|
|
68610
|
+
if (options.json === true) {
|
|
68611
|
+
printJson(Object.entries(pools).map(([name, entry]) => ({ name, identities: entry.identities, active: active === `${POOL_SELECTOR_PREFIX}${name}` })));
|
|
68612
|
+
return;
|
|
68613
|
+
}
|
|
68614
|
+
const names = Object.keys(pools).sort();
|
|
68615
|
+
if (names.length === 0) {
|
|
68616
|
+
console.log("No pools yet. Run `agent-shim pool add <name> --identity <name>...` to create one.");
|
|
68617
|
+
return;
|
|
68618
|
+
}
|
|
68619
|
+
for (const name of names) {
|
|
68620
|
+
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(pools[name]?.identities ?? []).join(", ")}`);
|
|
68621
|
+
}
|
|
68622
|
+
}),
|
|
68623
|
+
["agent-shim pool list", "agent-shim pool list --json"]
|
|
68624
|
+
);
|
|
68625
|
+
withExamples(
|
|
68626
|
+
pool.command("show <name>").description("Show one pool's members.").option("--json", "Print the pool as JSON.").action((name, options) => {
|
|
68627
|
+
const entry = requirePool(paths, name);
|
|
68628
|
+
if (options.json === true) {
|
|
68629
|
+
printJson({ name, identities: entry.identities });
|
|
68630
|
+
return;
|
|
68631
|
+
}
|
|
68632
|
+
console.log(`Pool: ${name}`);
|
|
68633
|
+
console.log(`Members: ${entry.identities.join(", ")}`);
|
|
68634
|
+
}),
|
|
68635
|
+
["agent-shim pool show subs"]
|
|
68636
|
+
);
|
|
68637
|
+
withExamples(
|
|
68638
|
+
pool.command("remove <name>").description("Delete a pool. Its member identities are untouched.").option("--yes", "Skip the confirmation prompt.").action(async (name, options) => {
|
|
68639
|
+
requirePool(paths, name);
|
|
68640
|
+
await confirmRemoval(deps, options.yes, `pool "${name}"`);
|
|
68641
|
+
removePool(paths, name);
|
|
68642
|
+
console.log(`Removed pool "${name}".`);
|
|
68643
|
+
}),
|
|
68644
|
+
["agent-shim pool remove subs --yes"]
|
|
68645
|
+
);
|
|
68646
|
+
withExamples(
|
|
68647
|
+
pool.command("use <name>").description("Make launches with no other selection pick a member of this pool.").action((name) => {
|
|
68648
|
+
useIdentity(paths, `${POOL_SELECTOR_PREFIX}${name}`);
|
|
68649
|
+
console.log(`Active selection is now pool "${name}".`);
|
|
68650
|
+
}),
|
|
68651
|
+
["agent-shim pool use subs"]
|
|
68652
|
+
);
|
|
68653
|
+
withExamples(
|
|
68654
|
+
pool.command("pick <name>").description("Show how a launch from this directory would rank the pool's members right now, and which it would run as. Read-only: it records nothing.").option("--json", "Print the ranking as JSON.").action((name, options) => {
|
|
68655
|
+
const nowMs = Date.now();
|
|
68656
|
+
const report = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: name, pool: requirePool(paths, name), directory: process.cwd(), nowMs });
|
|
68657
|
+
if (options.json === true) {
|
|
68658
|
+
printJson(report);
|
|
68659
|
+
return;
|
|
68660
|
+
}
|
|
68661
|
+
for (const line of formatPoolPick(report, nowMs)) {
|
|
68662
|
+
console.log(line);
|
|
68663
|
+
}
|
|
68664
|
+
}),
|
|
68665
|
+
["agent-shim pool pick subs", "agent-shim pool pick subs --json"]
|
|
68666
|
+
);
|
|
68667
|
+
}
|
|
68668
|
+
|
|
68646
68669
|
// src/providers.ts
|
|
68647
68670
|
function toProviderView(name, provider) {
|
|
68648
68671
|
return {
|
|
@@ -69178,7 +69201,7 @@ var import_node_crypto16 = require("node:crypto");
|
|
|
69178
69201
|
|
|
69179
69202
|
// src/launcher.ts
|
|
69180
69203
|
var import_node_crypto15 = require("node:crypto");
|
|
69181
|
-
var
|
|
69204
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
69182
69205
|
|
|
69183
69206
|
// src/launcher/cliOverride.ts
|
|
69184
69207
|
var InvalidCliCategoryError = class extends CliError {
|
|
@@ -69262,7 +69285,7 @@ function buildCliOverride(params) {
|
|
|
69262
69285
|
}
|
|
69263
69286
|
|
|
69264
69287
|
// src/launcher/flags.ts
|
|
69265
|
-
var
|
|
69288
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
69266
69289
|
|
|
69267
69290
|
// src/headroom/headers.ts
|
|
69268
69291
|
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
@@ -69332,7 +69355,7 @@ function buildEnv(params) {
|
|
|
69332
69355
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
69333
69356
|
let providerCustomHeaders;
|
|
69334
69357
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
69335
|
-
env.CLAUDE_CONFIG_DIR =
|
|
69358
|
+
env.CLAUDE_CONFIG_DIR = import_node_path36.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
69336
69359
|
}
|
|
69337
69360
|
if (params.provider !== void 0) {
|
|
69338
69361
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -69519,7 +69542,7 @@ function runLauncher(params) {
|
|
|
69519
69542
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
69520
69543
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
69521
69544
|
});
|
|
69522
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs18.readConfigFile(
|
|
69545
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs18.readConfigFile(import_node_path37.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
69523
69546
|
log.error(
|
|
69524
69547
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
69525
69548
|
);
|
|
@@ -69812,7 +69835,7 @@ async function runClaude(argvOverride) {
|
|
|
69812
69835
|
// src/cli.ts
|
|
69813
69836
|
async function main() {
|
|
69814
69837
|
aliasLegacyEnv(process.env);
|
|
69815
|
-
const invokedName =
|
|
69838
|
+
const invokedName = import_node_path38.default.basename(process.argv[1] ?? "agent-shim");
|
|
69816
69839
|
if (isInvokedAsClaude(invokedName)) {
|
|
69817
69840
|
await runClaude();
|
|
69818
69841
|
return;
|