agent-shim 8.14.1 → 8.15.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 +1 -1
- package/dist/cli.cjs +1141 -787
- package/dist/index.cjs +4652 -4223
- package/dist/index.mjs +4626 -4221
- package/dist/types/index.d.ts +2777 -1227
- package/package.json +1 -1
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 path44 = require("path");
|
|
3252
3252
|
var os10 = require("os");
|
|
3253
3253
|
var homedir = os10.homedir();
|
|
3254
3254
|
var tmpdir = os10.tmpdir();
|
|
3255
3255
|
var { env } = process;
|
|
3256
3256
|
var macos = (name) => {
|
|
3257
|
-
const library =
|
|
3257
|
+
const library = path44.join(homedir, "Library");
|
|
3258
3258
|
return {
|
|
3259
|
-
data:
|
|
3260
|
-
config:
|
|
3261
|
-
cache:
|
|
3262
|
-
log:
|
|
3263
|
-
temp:
|
|
3259
|
+
data: path44.join(library, "Application Support", name),
|
|
3260
|
+
config: path44.join(library, "Preferences", name),
|
|
3261
|
+
cache: path44.join(library, "Caches", name),
|
|
3262
|
+
log: path44.join(library, "Logs", name),
|
|
3263
|
+
temp: path44.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 || path44.join(homedir, "AppData", "Roaming");
|
|
3268
|
+
const localAppData = env.LOCALAPPDATA || path44.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: path44.join(localAppData, name, "Data"),
|
|
3272
|
+
config: path44.join(appData, name, "Config"),
|
|
3273
|
+
cache: path44.join(localAppData, name, "Cache"),
|
|
3274
|
+
log: path44.join(localAppData, name, "Log"),
|
|
3275
|
+
temp: path44.join(tmpdir, name)
|
|
3276
3276
|
};
|
|
3277
3277
|
};
|
|
3278
3278
|
var linux = (name) => {
|
|
3279
|
-
const username =
|
|
3279
|
+
const username = path44.basename(homedir);
|
|
3280
3280
|
return {
|
|
3281
|
-
data:
|
|
3282
|
-
config:
|
|
3283
|
-
cache:
|
|
3281
|
+
data: path44.join(env.XDG_DATA_HOME || path44.join(homedir, ".local", "share"), name),
|
|
3282
|
+
config: path44.join(env.XDG_CONFIG_HOME || path44.join(homedir, ".config"), name),
|
|
3283
|
+
cache: path44.join(env.XDG_CACHE_HOME || path44.join(homedir, ".cache"), name),
|
|
3284
3284
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
3285
|
-
log:
|
|
3286
|
-
temp:
|
|
3285
|
+
log: path44.join(env.XDG_STATE_HOME || path44.join(homedir, ".local", "state"), name),
|
|
3286
|
+
temp: path44.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, path44) {
|
|
3355
|
+
if (typeof path44 === "string" && Object.prototype.hasOwnProperty.call(source, path44)) {
|
|
3356
|
+
return source[path44];
|
|
3357
3357
|
}
|
|
3358
|
-
const parsedPath = typeof
|
|
3358
|
+
const parsedPath = typeof path44 === "string" ? path44.split(".") : path44;
|
|
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(([, value2]) => value2 !== void 0));
|
|
3379
3379
|
}
|
|
3380
3380
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
3381
|
-
async function isDirectory(
|
|
3381
|
+
async function isDirectory(path44) {
|
|
3382
3382
|
try {
|
|
3383
|
-
const stat = await fs_1.promises.stat(
|
|
3383
|
+
const stat = await fs_1.promises.stat(path44);
|
|
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(path44) {
|
|
3394
3394
|
try {
|
|
3395
|
-
const stat = fs_1.default.statSync(
|
|
3395
|
+
const stat = fs_1.default.statSync(path44);
|
|
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((path44, i2) => `${i2 + 1}. ${path44}`).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(path44) {
|
|
3682
3682
|
try {
|
|
3683
|
-
await promises_1.default.stat(
|
|
3683
|
+
await promises_1.default.stat(path44);
|
|
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(path44) {
|
|
3844
3844
|
try {
|
|
3845
|
-
fs_1.default.statSync(
|
|
3845
|
+
fs_1.default.statSync(path44);
|
|
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((path44) => path44.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 = (path44, { windows } = {}) => {
|
|
4378
|
+
const segs = path44.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 path44 = 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 (path44 && path44[0] !== "/") {
|
|
7011
|
+
path44 = `/${path44}`;
|
|
7012
7012
|
}
|
|
7013
|
-
return new URL(`${origin}${
|
|
7013
|
+
return new URL(`${origin}${path44}`);
|
|
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: path44, origin }
|
|
7835
7835
|
} = evt;
|
|
7836
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
7836
|
+
debugLog("sending request to %s %s%s", method, origin, path44);
|
|
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: path44, 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
|
+
path44,
|
|
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: path44, origin }
|
|
7871
7871
|
} = evt;
|
|
7872
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
7872
|
+
debugLog("trailers received from %s %s%s", method, origin, path44);
|
|
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: path44, 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
|
+
path44,
|
|
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 Request2 = class {
|
|
8000
8000
|
constructor(origin, {
|
|
8001
|
-
path:
|
|
8001
|
+
path: path44,
|
|
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 path44 !== "string") {
|
|
8019
8019
|
throw new InvalidArgumentError2("path must be a string");
|
|
8020
|
-
} else if (
|
|
8020
|
+
} else if (path44[0] !== "/" && !(path44.startsWith("http://") || path44.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(path44)) {
|
|
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(path44, query) : path44;
|
|
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, request7) {
|
|
13279
|
-
const { method, path:
|
|
13279
|
+
const { method, path: path44, host, upgrade, blocking, reset } = request7;
|
|
13280
13280
|
let { body, headers, contentLength } = request7;
|
|
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(request7.typeOfService);
|
|
13356
13356
|
}
|
|
13357
|
-
let header = `${method} ${
|
|
13357
|
+
let header = `${method} ${path44} 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 = request7.headersTimeout ?? client[kHeadersTimeout];
|
|
14034
14034
|
const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
|
|
14035
14035
|
const session = client[kHTTP2Session];
|
|
14036
|
-
const { method, path:
|
|
14036
|
+
const { method, path: path44, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
|
|
14037
14037
|
let { body } = request7;
|
|
14038
14038
|
if (upgrade != null && upgrade !== "websocket") {
|
|
14039
14039
|
util.errorRequest(client, request7, 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] = path44;
|
|
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] = path44;
|
|
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: path44 = "/",
|
|
16500
16500
|
headers = {}
|
|
16501
16501
|
} = opts;
|
|
16502
|
-
opts.path = origin +
|
|
16502
|
+
opts.path = origin + path44;
|
|
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(path44) {
|
|
18612
|
+
if (typeof path44 !== "string") {
|
|
18613
|
+
return path44;
|
|
18614
18614
|
}
|
|
18615
|
-
const pathSegments =
|
|
18615
|
+
const pathSegments = path44.split("?", 3);
|
|
18616
18616
|
if (pathSegments.length !== 2) {
|
|
18617
|
-
return
|
|
18617
|
+
return path44;
|
|
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: path44, method, body, headers }) {
|
|
18624
|
+
const pathMatch = matchValue(mockDispatch2.path, path44);
|
|
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: path44, ignoreTrailingSlash }) => {
|
|
18650
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path44)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path44), 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(path44) {
|
|
18690
|
+
while (path44.endsWith("/")) {
|
|
18691
|
+
path44 = path44.slice(0, -1);
|
|
18692
18692
|
}
|
|
18693
|
-
if (
|
|
18694
|
-
|
|
18693
|
+
if (path44.length === 0) {
|
|
18694
|
+
path44 = "/";
|
|
18695
18695
|
}
|
|
18696
|
-
return
|
|
18696
|
+
return path44;
|
|
18697
18697
|
}
|
|
18698
18698
|
function buildKey(opts) {
|
|
18699
|
-
const { path:
|
|
18699
|
+
const { path: path44, method, body, headers, query } = opts;
|
|
18700
18700
|
return {
|
|
18701
|
-
path:
|
|
18701
|
+
path: path44,
|
|
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: path44, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
19392
19392
|
Method: method,
|
|
19393
19393
|
Origin: origin,
|
|
19394
|
-
Path:
|
|
19394
|
+
Path: path44,
|
|
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 [path44, searchParams] = dispatchOpts.path.split("?");
|
|
19477
19477
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
19478
|
-
dispatchOpts.path = `${
|
|
19478
|
+
dispatchOpts.path = `${path44}?${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 path44 = filePath || this.#snapshotPath;
|
|
19880
|
+
if (!path44) {
|
|
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(path44), "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 ${path44}`, { 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 path44 = filePath || this.#snapshotPath;
|
|
19910
|
+
if (!path44) {
|
|
19911
19911
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
19912
19912
|
}
|
|
19913
|
-
const resolvedPath = resolve(
|
|
19913
|
+
const resolvedPath = resolve(path44);
|
|
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 path44 = search ? `${pathname}${search}` : pathname;
|
|
20546
|
+
const redirectUrlString = `${origin}${path44}`;
|
|
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 = path44;
|
|
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, path44) {
|
|
22314
22314
|
deleteCachedValue(store, {
|
|
22315
22315
|
...cacheKey,
|
|
22316
|
-
path:
|
|
22316
|
+
path: path44
|
|
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: path44
|
|
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 path44 = getSameOriginPath(cacheKey, values[i2]);
|
|
22336
|
+
if (path44 !== void 0) {
|
|
22337
|
+
deleteCachedUri(store, cacheKey, path44);
|
|
22338
22338
|
}
|
|
22339
22339
|
}
|
|
22340
22340
|
}
|
|
@@ -27334,11 +27334,11 @@ var require_fetch = __commonJS({
|
|
|
27334
27334
|
function dispatch({ body }) {
|
|
27335
27335
|
const url2 = requestCurrentURL(request7);
|
|
27336
27336
|
const agent = fetchParams.controller.dispatcher;
|
|
27337
|
-
const
|
|
27337
|
+
const path44 = 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 ? `${path44}?` : path44,
|
|
27342
27342
|
origin: url2.origin,
|
|
27343
27343
|
method: request7.method,
|
|
27344
27344
|
body: agent.isMockActive ? request7.body && (request7.body.source || request7.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(path44) {
|
|
28289
|
+
for (let i2 = 0; i2 < path44.length; ++i2) {
|
|
28290
|
+
const code = path44.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 path44 = opts.path;
|
|
31639
31639
|
if (!opts.path.startsWith("/")) {
|
|
31640
|
-
|
|
31640
|
+
path44 = `/${path44}`;
|
|
31641
31641
|
}
|
|
31642
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
31642
|
+
url2 = new URL(util.parseOrigin(url2).origin + path44);
|
|
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_path42 = __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(path44) {
|
|
34866
|
+
if (path44 === void 0) return this._executableDir;
|
|
34867
|
+
this._executableDir = path44;
|
|
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, path44) {
|
|
36006
|
+
if (!path44)
|
|
36007
36007
|
return obj;
|
|
36008
|
-
return
|
|
36008
|
+
return path44.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(path44, 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(path44);
|
|
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, path44 = []) => {
|
|
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 }, [...path44, ...issue2.path]));
|
|
36806
36806
|
} else if (issue2.code === "invalid_key") {
|
|
36807
|
-
processError({ issues: issue2.issues }, [...
|
|
36807
|
+
processError({ issues: issue2.issues }, [...path44, ...issue2.path]);
|
|
36808
36808
|
} else if (issue2.code === "invalid_element") {
|
|
36809
|
-
processError({ issues: issue2.issues }, [...
|
|
36809
|
+
processError({ issues: issue2.issues }, [...path44, ...issue2.path]);
|
|
36810
36810
|
} else {
|
|
36811
|
-
const fullpath = [...
|
|
36811
|
+
const fullpath = [...path44, ...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, path44 = []) => {
|
|
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 }, [...path44, ...issue2.path]));
|
|
36855
36855
|
} else if (issue2.code === "invalid_key") {
|
|
36856
|
-
processError({ issues: issue2.issues }, [...
|
|
36856
|
+
processError({ issues: issue2.issues }, [...path44, ...issue2.path]);
|
|
36857
36857
|
} else if (issue2.code === "invalid_element") {
|
|
36858
|
-
processError({ issues: issue2.issues }, [...
|
|
36858
|
+
processError({ issues: issue2.issues }, [...path44, ...issue2.path]);
|
|
36859
36859
|
} else {
|
|
36860
|
-
const fullpath = [...
|
|
36860
|
+
const fullpath = [...path44, ...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 path44 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
36900
|
+
for (const seg of path44) {
|
|
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 path44 = ref.slice(1).split("/").filter(Boolean);
|
|
54003
|
+
if (path44.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 (path44[0] === defsKey) {
|
|
54008
|
+
const key = path44[1] === void 0 ? void 0 : decodeJSONPointerSegment(path44[1]);
|
|
54009
54009
|
if (!key || !ctx.defs[key]) {
|
|
54010
54010
|
throw new Error(`Reference not found: ${ref}`);
|
|
54011
54011
|
}
|
|
@@ -58058,6 +58058,20 @@ var import_node_path13 = __toESM(require("node:path"), 1);
|
|
|
58058
58058
|
|
|
58059
58059
|
// src/launcher/identity.ts
|
|
58060
58060
|
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
58061
|
+
var IDENTITY_DECISION_SOURCES = [
|
|
58062
|
+
/** `CLAUDE_CONFIG_DIR` was already set: identity resolution is skipped entirely and the real binary uses whatever it already points to. */
|
|
58063
|
+
"config-dir-escape-hatch",
|
|
58064
|
+
/** A leading `@name` argv[0] positional, or its explicit form `--identity <name>`. */
|
|
58065
|
+
"argv",
|
|
58066
|
+
/** The `AGENT_SHIM_IDENTITY` environment variable. */
|
|
58067
|
+
"env",
|
|
58068
|
+
/** A directory rule pinning an identity to the current path. */
|
|
58069
|
+
"directory-pin",
|
|
58070
|
+
/** The persisted `~/.agent-shim/active-identity` file. */
|
|
58071
|
+
"active-identity-file",
|
|
58072
|
+
/** Nothing resolved an identity at all — a bare launch with no active identity. */
|
|
58073
|
+
"none"
|
|
58074
|
+
];
|
|
58061
58075
|
function poolNameOf(selector) {
|
|
58062
58076
|
return selector.startsWith(POOL_SELECTOR_PREFIX) ? selector.slice(POOL_SELECTOR_PREFIX.length) : void 0;
|
|
58063
58077
|
}
|
|
@@ -58087,6 +58101,20 @@ function decideIdentity(params) {
|
|
|
58087
58101
|
}
|
|
58088
58102
|
return { source: "none", configDirEscapeHatch: false };
|
|
58089
58103
|
}
|
|
58104
|
+
var CONFIG_PROFILE_DECISION_SOURCES = [
|
|
58105
|
+
/** An explicit `--config-profile` CLI flag. */
|
|
58106
|
+
"cli-flag",
|
|
58107
|
+
/** The `AGENT_SHIM_CONFIG_PROFILE` environment variable. */
|
|
58108
|
+
"env",
|
|
58109
|
+
/** A directory rule's `configProfile` selection for `$PWD`. */
|
|
58110
|
+
"directory-rule",
|
|
58111
|
+
/** The active identity's own declared `defaultConfigProfile`. */
|
|
58112
|
+
"identity-default",
|
|
58113
|
+
/** The user-global `~/.agent-shim/config.json` default. */
|
|
58114
|
+
"global-default",
|
|
58115
|
+
/** Nothing resolved a configuration profile at all. */
|
|
58116
|
+
"none"
|
|
58117
|
+
];
|
|
58090
58118
|
function decideConfigProfile(params) {
|
|
58091
58119
|
if (isNonEmpty(params.cliFlagConfigProfile)) {
|
|
58092
58120
|
return { name: params.cliFlagConfigProfile, source: "cli-flag" };
|
|
@@ -59114,6 +59142,12 @@ function encodeProjectPattern(fragment, options) {
|
|
|
59114
59142
|
}
|
|
59115
59143
|
return splitOnWildcards(expanded).map((piece) => piece.kind === "literal" ? encodeProjectPath(piece.text) : piece.text).join("");
|
|
59116
59144
|
}
|
|
59145
|
+
var ENCODING_AMBIGUITY_REASONS = [
|
|
59146
|
+
/** The literal portion contains a character other than `/` that encodes to `-`, so a sibling path differing only in that character encodes identically. */
|
|
59147
|
+
"lossy-characters",
|
|
59148
|
+
/** Two different patterns in the same configuration encode to the identical form. */
|
|
59149
|
+
"collides-with-sibling-pattern"
|
|
59150
|
+
];
|
|
59117
59151
|
function lossyCharacters(literal2) {
|
|
59118
59152
|
const found = /* @__PURE__ */ new Set();
|
|
59119
59153
|
for (const character of literal2) {
|
|
@@ -61710,7 +61744,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
61710
61744
|
// package.json
|
|
61711
61745
|
var package_default = {
|
|
61712
61746
|
name: "agent-shim",
|
|
61713
|
-
version: "8.
|
|
61747
|
+
version: "8.15.0",
|
|
61714
61748
|
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.",
|
|
61715
61749
|
license: "MIT",
|
|
61716
61750
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -62140,11 +62174,11 @@ function providerBaseUrl(port, provider) {
|
|
|
62140
62174
|
function directOrigin(port) {
|
|
62141
62175
|
return `http://127.0.0.1:${String(port)}`;
|
|
62142
62176
|
}
|
|
62143
|
-
function parseProviderPath(
|
|
62144
|
-
if (!
|
|
62177
|
+
function parseProviderPath(path44) {
|
|
62178
|
+
if (!path44.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
62145
62179
|
return void 0;
|
|
62146
62180
|
}
|
|
62147
|
-
const tail =
|
|
62181
|
+
const tail = path44.slice(PROVIDER_PATH_PREFIX.length);
|
|
62148
62182
|
const slash = tail.indexOf("/");
|
|
62149
62183
|
if (slash <= 0) {
|
|
62150
62184
|
return void 0;
|
|
@@ -62544,9 +62578,9 @@ function decoderFor(encoding) {
|
|
|
62544
62578
|
return void 0;
|
|
62545
62579
|
}
|
|
62546
62580
|
}
|
|
62547
|
-
function destinationOf(
|
|
62548
|
-
const scoped = parseProviderPath(
|
|
62549
|
-
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint:
|
|
62581
|
+
function destinationOf(path44) {
|
|
62582
|
+
const scoped = parseProviderPath(path44);
|
|
62583
|
+
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path44 } : { provider: scoped.provider, endpoint: scoped.rest };
|
|
62550
62584
|
}
|
|
62551
62585
|
function buildRecord(event, context) {
|
|
62552
62586
|
const { scan } = context;
|
|
@@ -63591,6 +63625,7 @@ function parseEnvBool(variable, value2) {
|
|
|
63591
63625
|
}
|
|
63592
63626
|
|
|
63593
63627
|
// src/launcher/claudeVersion.ts
|
|
63628
|
+
var CLAUDE_VERSION_SOURCES = ["flag", "environment", "cascade"];
|
|
63594
63629
|
var InvalidClaudeVersionError = class extends UsageError {
|
|
63595
63630
|
constructor(value2, origin) {
|
|
63596
63631
|
super(`${origin} names Claude Code version "${value2}", which is not an exact dotted-numeric version such as 2.1.220.`);
|
|
@@ -63904,7 +63939,7 @@ function formatCheckReport(report) {
|
|
|
63904
63939
|
const { credential } = report;
|
|
63905
63940
|
if (credential.provider !== void 0) {
|
|
63906
63941
|
lines.push(
|
|
63907
|
-
` Provider ${credential.provider.name}: ${credential.provider.credential === void 0 ? `unusable: ${credential.provider.problem
|
|
63942
|
+
` Provider ${credential.provider.name}: ${credential.provider.credential === void 0 ? `unusable: ${credential.provider.problem}` : formatCredentialSummary(credential.provider.credential)}${credential.provider.cached === void 0 ? "" : `; ${formatCachedCredentialState(credential.provider.cached)}`}`
|
|
63908
63943
|
);
|
|
63909
63944
|
}
|
|
63910
63945
|
if (credential.identity !== void 0) {
|
|
@@ -64446,8 +64481,8 @@ function registerCodexCommand(program2, deps) {
|
|
|
64446
64481
|
|
|
64447
64482
|
// src/frontdoor/commands.ts
|
|
64448
64483
|
var import_node_crypto12 = require("node:crypto");
|
|
64449
|
-
var
|
|
64450
|
-
var
|
|
64484
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
64485
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
64451
64486
|
|
|
64452
64487
|
// src/frontdoor/custody.ts
|
|
64453
64488
|
var CREDENTIAL_HEADERS = ["authorization", "x-api-key"];
|
|
@@ -65178,8 +65213,8 @@ function parseConnectTarget(authority) {
|
|
|
65178
65213
|
}
|
|
65179
65214
|
return { host, port };
|
|
65180
65215
|
}
|
|
65181
|
-
function servedByPipeline(
|
|
65182
|
-
return
|
|
65216
|
+
function servedByPipeline(path44) {
|
|
65217
|
+
return path44?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
65183
65218
|
}
|
|
65184
65219
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
65185
65220
|
"connection",
|
|
@@ -65705,11 +65740,11 @@ function createRcSessionTracker(deps) {
|
|
|
65705
65740
|
};
|
|
65706
65741
|
const observeExchange = (request7) => {
|
|
65707
65742
|
const method = (request7.method ?? "").toUpperCase();
|
|
65708
|
-
const
|
|
65709
|
-
if (!
|
|
65743
|
+
const path44 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
65744
|
+
if (!path44.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
65710
65745
|
return void 0;
|
|
65711
65746
|
}
|
|
65712
|
-
const tail =
|
|
65747
|
+
const tail = path44.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
65713
65748
|
const facts = {
|
|
65714
65749
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
65715
65750
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -66449,9 +66484,9 @@ function sequenceNumsOfBody(body) {
|
|
|
66449
66484
|
}
|
|
66450
66485
|
function frontDoorRcControl(transport, token) {
|
|
66451
66486
|
const headers = { authorization: `Bearer ${token}` };
|
|
66452
|
-
const listAnswerOf = async (
|
|
66487
|
+
const listAnswerOf = async (path44, what) => {
|
|
66453
66488
|
try {
|
|
66454
|
-
return await transport.request({ method: "GET", path:
|
|
66489
|
+
return await transport.request({ method: "GET", path: path44, headers });
|
|
66455
66490
|
} catch (error62) {
|
|
66456
66491
|
throw new Error(`${what}: could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}`, { cause: error62 });
|
|
66457
66492
|
}
|
|
@@ -66523,10 +66558,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
66523
66558
|
}
|
|
66524
66559
|
return pending;
|
|
66525
66560
|
};
|
|
66526
|
-
const writeOf = async (
|
|
66561
|
+
const writeOf = async (path44, body, describeFailure) => {
|
|
66527
66562
|
let answer;
|
|
66528
66563
|
try {
|
|
66529
|
-
answer = await transport.request({ method: "POST", path:
|
|
66564
|
+
answer = await transport.request({ method: "POST", path: path44, headers: { ...headers, "content-type": "application/json" }, body });
|
|
66530
66565
|
} catch (error62) {
|
|
66531
66566
|
return { ok: false, message: `could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
66532
66567
|
}
|
|
@@ -66899,12 +66934,12 @@ function lateRcStreamDial(resolve) {
|
|
|
66899
66934
|
}
|
|
66900
66935
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
66901
66936
|
const agent = new ExemptTlsAgent();
|
|
66902
|
-
const request7 = async (method,
|
|
66937
|
+
const request7 = async (method, path44, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
66903
66938
|
const options = {
|
|
66904
66939
|
host: target.host,
|
|
66905
66940
|
port: target.port,
|
|
66906
66941
|
method,
|
|
66907
|
-
path:
|
|
66942
|
+
path: path44,
|
|
66908
66943
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
66909
66944
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
66910
66945
|
agent,
|
|
@@ -66941,9 +66976,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
66941
66976
|
return { status, body: await readAll(response) };
|
|
66942
66977
|
},
|
|
66943
66978
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
66944
|
-
const
|
|
66979
|
+
const path44 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
66945
66980
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
66946
|
-
const { status, response } = await request7("GET",
|
|
66981
|
+
const { status, response } = await request7("GET", path44, streamHeaders, void 0, signal);
|
|
66947
66982
|
if (!isSuccessful2(status)) {
|
|
66948
66983
|
await readAll(response);
|
|
66949
66984
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -67154,6 +67189,527 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
67154
67189
|
};
|
|
67155
67190
|
}
|
|
67156
67191
|
|
|
67192
|
+
// src/doctorReport.ts
|
|
67193
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
67194
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
67195
|
+
var DOCTOR_SEVERITIES = ["pass", "warn", "fail"];
|
|
67196
|
+
var DOCTOR_SECTIONS = [
|
|
67197
|
+
"ambient-credential",
|
|
67198
|
+
"binary-discovery",
|
|
67199
|
+
"claude-shim",
|
|
67200
|
+
"path-resolution",
|
|
67201
|
+
"legacy-name",
|
|
67202
|
+
"config-profile",
|
|
67203
|
+
"identity",
|
|
67204
|
+
"pool",
|
|
67205
|
+
"provider",
|
|
67206
|
+
"keychain",
|
|
67207
|
+
"directory-rules",
|
|
67208
|
+
"global-config",
|
|
67209
|
+
"categories-local",
|
|
67210
|
+
"active-identity",
|
|
67211
|
+
"headroom"
|
|
67212
|
+
];
|
|
67213
|
+
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
67214
|
+
if (status.status !== "shadowed") {
|
|
67215
|
+
return status;
|
|
67216
|
+
}
|
|
67217
|
+
return realpath(status.by) === realpath(ownExecutablePath) ? { status: "ok" } : status;
|
|
67218
|
+
}
|
|
67219
|
+
function validateJson(schema, input2) {
|
|
67220
|
+
if (input2.raw === void 0) {
|
|
67221
|
+
return { ok: false, message: `${input2.path} is missing.` };
|
|
67222
|
+
}
|
|
67223
|
+
let parsed;
|
|
67224
|
+
try {
|
|
67225
|
+
parsed = JSON.parse(input2.raw);
|
|
67226
|
+
} catch (error62) {
|
|
67227
|
+
return { ok: false, message: `${input2.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
67228
|
+
}
|
|
67229
|
+
const result = schema.safeParse(parsed);
|
|
67230
|
+
if (!result.success) {
|
|
67231
|
+
return { ok: false, message: new ConfigValidationError(input2.path, result.error.issues).message };
|
|
67232
|
+
}
|
|
67233
|
+
return { ok: true, data: result.data };
|
|
67234
|
+
}
|
|
67235
|
+
function pushPathResolution(push, resolution) {
|
|
67236
|
+
const ownDir = import_node_path32.default.dirname(resolution.ownExecutablePath);
|
|
67237
|
+
switch (resolution.agentShim.status) {
|
|
67238
|
+
case "ok":
|
|
67239
|
+
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
67240
|
+
break;
|
|
67241
|
+
case "not-on-path":
|
|
67242
|
+
push(
|
|
67243
|
+
"path-resolution",
|
|
67244
|
+
"warn",
|
|
67245
|
+
`${ownDir} is not on PATH, so a bare \`agent-shim\` does not reach ${resolution.ownExecutablePath}. Add it to PATH, or keep invoking this executable by its full path.`,
|
|
67246
|
+
"agent-shim"
|
|
67247
|
+
);
|
|
67248
|
+
break;
|
|
67249
|
+
case "shadowed":
|
|
67250
|
+
push(
|
|
67251
|
+
"path-resolution",
|
|
67252
|
+
"fail",
|
|
67253
|
+
`\`agent-shim\` on PATH resolves to ${resolution.agentShim.by}, not this running executable, ${resolution.ownExecutablePath}. Every command you type runs that one instead, at whatever version it happens to be \u2014 including the checks in this report, which describe this executable. Remove ${resolution.agentShim.by}, repoint it at ${resolution.ownExecutablePath}, or put ${ownDir} ahead of it on PATH.`,
|
|
67254
|
+
"agent-shim"
|
|
67255
|
+
);
|
|
67256
|
+
break;
|
|
67257
|
+
}
|
|
67258
|
+
if (resolution.claude === void 0) {
|
|
67259
|
+
return;
|
|
67260
|
+
}
|
|
67261
|
+
switch (resolution.claude.status) {
|
|
67262
|
+
case "ok":
|
|
67263
|
+
push("path-resolution", "pass", "`claude` on PATH resolves to the enabled shim.", "claude");
|
|
67264
|
+
break;
|
|
67265
|
+
case "not-on-path":
|
|
67266
|
+
push("path-resolution", "warn", "The enabled `claude` shim's directory is not on PATH \u2014 add it, or use `agent-shim run` instead.", "claude");
|
|
67267
|
+
break;
|
|
67268
|
+
case "shadowed":
|
|
67269
|
+
push(
|
|
67270
|
+
"path-resolution",
|
|
67271
|
+
"warn",
|
|
67272
|
+
`\`claude\` on PATH resolves to ${resolution.claude.by}, not the enabled shim. Put the shim's directory ahead of it on PATH, or run \`agent-shim shim disable\` if you meant to launch that one directly.`,
|
|
67273
|
+
"claude"
|
|
67274
|
+
);
|
|
67275
|
+
break;
|
|
67276
|
+
}
|
|
67277
|
+
}
|
|
67278
|
+
function cacheClause(cacheEnv, owner, block2) {
|
|
67279
|
+
if (cacheEnv === void 0 || block2.cache === void 0) {
|
|
67280
|
+
return { text: "", unreadable: false };
|
|
67281
|
+
}
|
|
67282
|
+
const state = describeCachedCredential({ port: cacheEnv.port, platform: cacheEnv.platform, owner, cache: block2.cache, nowMs: cacheEnv.now() });
|
|
67283
|
+
return { text: `; ${formatCachedCredentialState(state)}`, unreadable: state.status === "unreadable" };
|
|
67284
|
+
}
|
|
67285
|
+
function pushProvider(push, entry, cacheEnv) {
|
|
67286
|
+
if (entry.raw === void 0) {
|
|
67287
|
+
push("provider", "fail", `${entry.path} is missing.`, entry.name);
|
|
67288
|
+
return;
|
|
67289
|
+
}
|
|
67290
|
+
let parsed;
|
|
67291
|
+
try {
|
|
67292
|
+
parsed = JSON.parse(entry.raw);
|
|
67293
|
+
} catch (error62) {
|
|
67294
|
+
push("provider", "fail", `${entry.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}`, entry.name);
|
|
67295
|
+
return;
|
|
67296
|
+
}
|
|
67297
|
+
const conversion = legacyProviderConversion(parsed);
|
|
67298
|
+
if (conversion !== void 0) {
|
|
67299
|
+
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
67300
|
+
return;
|
|
67301
|
+
}
|
|
67302
|
+
const validated2 = ProviderSchema.safeParse(parsed);
|
|
67303
|
+
if (!validated2.success) {
|
|
67304
|
+
push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
|
|
67305
|
+
return;
|
|
67306
|
+
}
|
|
67307
|
+
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
|
|
67308
|
+
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
|
|
67309
|
+
if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
67310
|
+
push("provider", "warn", `${entry.name} does not set ENABLE_TOOL_SEARCH: a session on this provider loads MCP tools upfront rather than deferring them, because its base URL is the front door, which Claude Code treats as a non-first-party host. Set ENABLE_TOOL_SEARCH in the provider's env block to restore deferred loading, when the upstream backend supports the tool_reference payloads it sends.`, entry.name);
|
|
67311
|
+
}
|
|
67312
|
+
}
|
|
67313
|
+
function pushLegacyName(push, params) {
|
|
67314
|
+
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
67315
|
+
if (legacyVariables.length === 0 && import_node_path32.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
67316
|
+
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
67317
|
+
return;
|
|
67318
|
+
}
|
|
67319
|
+
for (const name of legacyVariables) {
|
|
67320
|
+
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);
|
|
67321
|
+
}
|
|
67322
|
+
if (import_node_path32.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
67323
|
+
push(
|
|
67324
|
+
"legacy-name",
|
|
67325
|
+
"warn",
|
|
67326
|
+
`The state root is the former ${params.rootPath}, used in place. Leave it where it is: macOS Claude Code keys each identity's Keychain login on its exact configuration directory path, so moving it signs every identity out.`
|
|
67327
|
+
);
|
|
67328
|
+
}
|
|
67329
|
+
}
|
|
67330
|
+
function runDoctor(params) {
|
|
67331
|
+
const findings = [];
|
|
67332
|
+
const push = (section, severity, message, subject) => {
|
|
67333
|
+
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
67334
|
+
};
|
|
67335
|
+
const checkPin = (section, subject, where, version2) => {
|
|
67336
|
+
const installed = params.installedClaudeVersions;
|
|
67337
|
+
if (version2 === void 0 || installed === void 0 || installed.includes(version2)) {
|
|
67338
|
+
return;
|
|
67339
|
+
}
|
|
67340
|
+
push(section, "warn", `${where} pins Claude Code ${version2}, which is not installed (installed: ${installed.length === 0 ? "none" : installed.join(", ")}); a launch that resolves to it fails.`, subject);
|
|
67341
|
+
};
|
|
67342
|
+
const ambient = detectAmbientCredential(params.env);
|
|
67343
|
+
if (ambient === void 0) {
|
|
67344
|
+
push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
|
|
67345
|
+
} else {
|
|
67346
|
+
push("ambient-credential", "warn", formatAmbientCredentialGuardMessage(ambient.variable));
|
|
67347
|
+
}
|
|
67348
|
+
if (params.binaryDiscovery.ok) {
|
|
67349
|
+
const { binary } = params.binaryDiscovery;
|
|
67350
|
+
const versionNote = binary.version === void 0 ? "" : `, version ${binary.version}`;
|
|
67351
|
+
push("binary-discovery", "pass", `Found ${binary.path} (${binary.source}${versionNote}).`);
|
|
67352
|
+
} else {
|
|
67353
|
+
push("binary-discovery", "fail", params.binaryDiscovery.message);
|
|
67354
|
+
}
|
|
67355
|
+
if (params.claudeShim.state === void 0) {
|
|
67356
|
+
push("claude-shim", "pass", "No `claude` command shim enabled (the default). Run `agent-shim shim enable` to add one.");
|
|
67357
|
+
} else if (!params.claudeShim.targetExists) {
|
|
67358
|
+
push(
|
|
67359
|
+
"claude-shim",
|
|
67360
|
+
"warn",
|
|
67361
|
+
`claude-shim.json records a \`claude\` shim at ${params.claudeShim.state.targetPath}, but nothing is there. Run \`agent-shim shim enable\` again, or \`agent-shim shim disable\` to clear the stale record.`
|
|
67362
|
+
);
|
|
67363
|
+
} else {
|
|
67364
|
+
push(
|
|
67365
|
+
"claude-shim",
|
|
67366
|
+
"pass",
|
|
67367
|
+
`\`claude\` is enabled at ${params.claudeShim.state.targetPath} (${params.claudeShim.state.method}). If you've upgraded agent-shim since, re-run \`agent-shim shim enable\` to refresh it.`
|
|
67368
|
+
);
|
|
67369
|
+
}
|
|
67370
|
+
pushPathResolution(push, params.pathResolution);
|
|
67371
|
+
pushLegacyName(push, params);
|
|
67372
|
+
const profileSources = /* @__PURE__ */ new Map();
|
|
67373
|
+
for (const entry of params.configProfiles) {
|
|
67374
|
+
const validated2 = validateJson(ConfigProfileSchema, entry);
|
|
67375
|
+
if (!validated2.ok) {
|
|
67376
|
+
push("config-profile", "fail", validated2.message, entry.name);
|
|
67377
|
+
continue;
|
|
67378
|
+
}
|
|
67379
|
+
profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
|
|
67380
|
+
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
|
|
67381
|
+
}
|
|
67382
|
+
const loadProfile = (name) => profileSources.get(name);
|
|
67383
|
+
for (const name of profileSources.keys()) {
|
|
67384
|
+
const linearised = lineariseProfile(name, loadProfile);
|
|
67385
|
+
if (linearised.diagnostics.length === 0) {
|
|
67386
|
+
push("config-profile", "pass", `${name} is valid and its extends chain resolves cleanly.`, name);
|
|
67387
|
+
} else {
|
|
67388
|
+
for (const diagnostic of linearised.diagnostics) {
|
|
67389
|
+
push("config-profile", "fail", diagnostic.message, name);
|
|
67390
|
+
}
|
|
67391
|
+
}
|
|
67392
|
+
}
|
|
67393
|
+
const validProfileNames = new Set(profileSources.keys());
|
|
67394
|
+
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
67395
|
+
for (const entry of params.identities) {
|
|
67396
|
+
const validated2 = validateJson(IdentitySchema, entry);
|
|
67397
|
+
if (!validated2.ok) {
|
|
67398
|
+
push("identity", "fail", validated2.message, entry.name);
|
|
67399
|
+
continue;
|
|
67400
|
+
}
|
|
67401
|
+
validIdentityNames.add(entry.name);
|
|
67402
|
+
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
67403
|
+
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
67404
|
+
push(
|
|
67405
|
+
"identity",
|
|
67406
|
+
"fail",
|
|
67407
|
+
`Identity "${entry.name}" names configuration profile "${defaultProfile}" as its default, but no such profile exists.`,
|
|
67408
|
+
entry.name
|
|
67409
|
+
);
|
|
67410
|
+
} else {
|
|
67411
|
+
const credential = validated2.data.credential;
|
|
67412
|
+
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
67413
|
+
push(
|
|
67414
|
+
"identity",
|
|
67415
|
+
cache.unreadable ? "fail" : "pass",
|
|
67416
|
+
`${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
|
|
67417
|
+
entry.name
|
|
67418
|
+
);
|
|
67419
|
+
}
|
|
67420
|
+
}
|
|
67421
|
+
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
67422
|
+
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
67423
|
+
for (const [poolName, pool] of Object.entries(pools)) {
|
|
67424
|
+
const missing = pool.identities.filter((member) => !validIdentityNames.has(member));
|
|
67425
|
+
if (missing.length === 0) {
|
|
67426
|
+
push("pool", "pass", `${poolName} is valid (${pool.identities.join(", ")}).`, poolName);
|
|
67427
|
+
} else {
|
|
67428
|
+
push("pool", "fail", `Pool "${poolName}" names ${missing.map((member) => `identity "${member}"`).join(" and ")}, which ${missing.length === 1 ? "does" : "do"} not exist.`, poolName);
|
|
67429
|
+
}
|
|
67430
|
+
}
|
|
67431
|
+
const selectionExists = (selector) => {
|
|
67432
|
+
const poolName = poolNameOf(selector);
|
|
67433
|
+
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
67434
|
+
};
|
|
67435
|
+
for (const entry of params.providers) {
|
|
67436
|
+
pushProvider(push, entry, params.credentialCache);
|
|
67437
|
+
}
|
|
67438
|
+
if (params.platform !== "darwin" || params.run === void 0) {
|
|
67439
|
+
push("keychain", "pass", "Skipped (not macOS).");
|
|
67440
|
+
} else {
|
|
67441
|
+
for (const entry of params.identities) {
|
|
67442
|
+
const result = lookupKeychainService(params.run, entry.farmRoot);
|
|
67443
|
+
push("keychain", result.found ? "pass" : "warn", result.note, entry.name);
|
|
67444
|
+
}
|
|
67445
|
+
}
|
|
67446
|
+
if (params.directoryRules.raw === void 0) {
|
|
67447
|
+
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
67448
|
+
} else {
|
|
67449
|
+
const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
|
|
67450
|
+
if (!validated2.ok) {
|
|
67451
|
+
push("directory-rules", "fail", validated2.message);
|
|
67452
|
+
} else {
|
|
67453
|
+
push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
|
|
67454
|
+
for (const rule of validated2.data.rules) {
|
|
67455
|
+
const badRefs = [];
|
|
67456
|
+
if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
|
|
67457
|
+
badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
|
|
67458
|
+
}
|
|
67459
|
+
if (rule.configProfile !== void 0 && !validProfileNames.has(rule.configProfile)) {
|
|
67460
|
+
badRefs.push(`configuration profile "${rule.configProfile}"`);
|
|
67461
|
+
}
|
|
67462
|
+
checkPin("directory-rules", rule.path, `Rule for "${rule.path}"`, rule.launch?.claudeVersion);
|
|
67463
|
+
if (badRefs.length > 0) {
|
|
67464
|
+
push("directory-rules", "fail", `Rule for "${rule.path}" names ${badRefs.join(" and ")}, which do not exist.`, rule.path);
|
|
67465
|
+
} else {
|
|
67466
|
+
push("directory-rules", "pass", `Rule for "${rule.path}" is valid.`, rule.path);
|
|
67467
|
+
}
|
|
67468
|
+
}
|
|
67469
|
+
}
|
|
67470
|
+
}
|
|
67471
|
+
if (params.globalConfig.raw === void 0) {
|
|
67472
|
+
push("global-config", "pass", "No config.json configured.");
|
|
67473
|
+
} else {
|
|
67474
|
+
const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
|
|
67475
|
+
if (!validated2.ok) {
|
|
67476
|
+
push("global-config", "fail", validated2.message);
|
|
67477
|
+
} else {
|
|
67478
|
+
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
67479
|
+
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
67480
|
+
push(
|
|
67481
|
+
"global-config",
|
|
67482
|
+
"fail",
|
|
67483
|
+
`config.json names configuration profile "${defaultProfile}" as its default, but no such profile exists.`
|
|
67484
|
+
);
|
|
67485
|
+
} else {
|
|
67486
|
+
push("global-config", "pass", `${params.globalConfig.path} is valid.`);
|
|
67487
|
+
checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
|
|
67488
|
+
}
|
|
67489
|
+
}
|
|
67490
|
+
}
|
|
67491
|
+
if (params.categoriesLocal.raw === void 0) {
|
|
67492
|
+
push("categories-local", "pass", "No categories.local.json configured.");
|
|
67493
|
+
} else {
|
|
67494
|
+
const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
|
|
67495
|
+
push(
|
|
67496
|
+
"categories-local",
|
|
67497
|
+
validated2.ok ? "pass" : "fail",
|
|
67498
|
+
validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
|
|
67499
|
+
);
|
|
67500
|
+
}
|
|
67501
|
+
if (params.headroom.state.raw === void 0) {
|
|
67502
|
+
push("headroom", "pass", "No headroom daemon has ever run; nothing to check.");
|
|
67503
|
+
} else {
|
|
67504
|
+
const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
|
|
67505
|
+
if (!validated2.ok) {
|
|
67506
|
+
push("headroom", "fail", validated2.message);
|
|
67507
|
+
} else {
|
|
67508
|
+
const state = validated2.data;
|
|
67509
|
+
const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
|
|
67510
|
+
const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
|
|
67511
|
+
if (state.supervisorPid === void 0) {
|
|
67512
|
+
if (state.lastError === void 0) {
|
|
67513
|
+
push("headroom", "pass", "Headroom daemon is stopped (idle shutdown) with no recorded error.");
|
|
67514
|
+
} else {
|
|
67515
|
+
push("headroom", "warn", `Headroom supervisor is not running; last error: ${state.lastError}`);
|
|
67516
|
+
}
|
|
67517
|
+
} else if (!supervisorAlive) {
|
|
67518
|
+
push(
|
|
67519
|
+
"headroom",
|
|
67520
|
+
"warn",
|
|
67521
|
+
`Headroom state names supervisor pid ${String(state.supervisorPid)}, which is not running; the next launch through headroom will start a replacement.`
|
|
67522
|
+
);
|
|
67523
|
+
} else if (state.headroomPid === void 0 || state.socketPath === void 0) {
|
|
67524
|
+
push(
|
|
67525
|
+
"headroom",
|
|
67526
|
+
"warn",
|
|
67527
|
+
state.lastError === void 0 ? "Headroom supervisor is running but the daemon has no healthy process; it should be restarting it." : `Headroom supervisor is running but the daemon is down; last error: ${state.lastError}`
|
|
67528
|
+
);
|
|
67529
|
+
} else if (!headroomAlive) {
|
|
67530
|
+
push(
|
|
67531
|
+
"headroom",
|
|
67532
|
+
"warn",
|
|
67533
|
+
`Headroom state names daemon pid ${String(state.headroomPid)}, which is not running; its supervisor should be restarting it.`
|
|
67534
|
+
);
|
|
67535
|
+
} else {
|
|
67536
|
+
push(
|
|
67537
|
+
"headroom",
|
|
67538
|
+
"pass",
|
|
67539
|
+
`Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
|
|
67540
|
+
);
|
|
67541
|
+
}
|
|
67542
|
+
if (state.lastError !== void 0 && supervisorAlive) {
|
|
67543
|
+
push("headroom", "warn", `Headroom recorded a previous error: ${state.lastError}`);
|
|
67544
|
+
}
|
|
67545
|
+
if (state.installedSource !== void 0 && isMovingGitSource(state.installedSource)) {
|
|
67546
|
+
push(
|
|
67547
|
+
"headroom",
|
|
67548
|
+
"warn",
|
|
67549
|
+
`Headroom is installed from a git ref that can move (${state.installedSource}); pin headroom.source to a full commit SHA so a rebased or deleted branch cannot change or break the install.`
|
|
67550
|
+
);
|
|
67551
|
+
}
|
|
67552
|
+
}
|
|
67553
|
+
}
|
|
67554
|
+
if (params.activeIdentity.raw === void 0) {
|
|
67555
|
+
push("active-identity", "pass", "No active identity set.");
|
|
67556
|
+
} else {
|
|
67557
|
+
const trimmed = params.activeIdentity.raw.trim();
|
|
67558
|
+
if (trimmed === "") {
|
|
67559
|
+
push("active-identity", "warn", "active-identity is present but empty \u2014 treated the same as unset.");
|
|
67560
|
+
} else if (!selectionExists(trimmed)) {
|
|
67561
|
+
push("active-identity", "fail", `active-identity names "${trimmed}", which does not exist.`);
|
|
67562
|
+
} else {
|
|
67563
|
+
push("active-identity", "pass", `Active identity "${trimmed}" is valid.`);
|
|
67564
|
+
}
|
|
67565
|
+
}
|
|
67566
|
+
return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
|
|
67567
|
+
}
|
|
67568
|
+
var SECTION_TITLES = {
|
|
67569
|
+
"ambient-credential": "Ambient-credential exposure",
|
|
67570
|
+
"binary-discovery": "Claude Code binary discovery",
|
|
67571
|
+
"claude-shim": "`claude` command shim",
|
|
67572
|
+
"path-resolution": "PATH resolution",
|
|
67573
|
+
"legacy-name": "Former `claude-use` name",
|
|
67574
|
+
"config-profile": "Configuration profiles",
|
|
67575
|
+
identity: "Identities",
|
|
67576
|
+
pool: "Pools",
|
|
67577
|
+
provider: "Providers",
|
|
67578
|
+
keychain: "macOS Keychain",
|
|
67579
|
+
"directory-rules": "Directory rules",
|
|
67580
|
+
"global-config": "Global config",
|
|
67581
|
+
headroom: "Headroom daemon",
|
|
67582
|
+
"categories-local": "categories.local.json",
|
|
67583
|
+
"active-identity": "Active identity"
|
|
67584
|
+
};
|
|
67585
|
+
var SECTION_ORDER = [
|
|
67586
|
+
"ambient-credential",
|
|
67587
|
+
"binary-discovery",
|
|
67588
|
+
"claude-shim",
|
|
67589
|
+
"path-resolution",
|
|
67590
|
+
"config-profile",
|
|
67591
|
+
"identity",
|
|
67592
|
+
"pool",
|
|
67593
|
+
"provider",
|
|
67594
|
+
"keychain",
|
|
67595
|
+
"directory-rules",
|
|
67596
|
+
"global-config",
|
|
67597
|
+
"headroom",
|
|
67598
|
+
"categories-local",
|
|
67599
|
+
"active-identity"
|
|
67600
|
+
];
|
|
67601
|
+
function severityPrefix(severity) {
|
|
67602
|
+
switch (severity) {
|
|
67603
|
+
case "pass":
|
|
67604
|
+
return "[PASS]";
|
|
67605
|
+
case "warn":
|
|
67606
|
+
return "[WARN]";
|
|
67607
|
+
case "fail":
|
|
67608
|
+
return "[FAIL]";
|
|
67609
|
+
default:
|
|
67610
|
+
return severity;
|
|
67611
|
+
}
|
|
67612
|
+
}
|
|
67613
|
+
function formatDoctorReport(report) {
|
|
67614
|
+
const lines = [];
|
|
67615
|
+
for (const section of SECTION_ORDER) {
|
|
67616
|
+
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
67617
|
+
if (sectionFindings.length === 0) {
|
|
67618
|
+
continue;
|
|
67619
|
+
}
|
|
67620
|
+
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
67621
|
+
for (const finding of sectionFindings) {
|
|
67622
|
+
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
67623
|
+
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
67624
|
+
}
|
|
67625
|
+
}
|
|
67626
|
+
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
67627
|
+
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
67628
|
+
return lines;
|
|
67629
|
+
}
|
|
67630
|
+
function realpathOrSelf(target) {
|
|
67631
|
+
try {
|
|
67632
|
+
return import_node_fs12.default.realpathSync(target);
|
|
67633
|
+
} catch {
|
|
67634
|
+
return target;
|
|
67635
|
+
}
|
|
67636
|
+
}
|
|
67637
|
+
function collectDoctorReport(params) {
|
|
67638
|
+
const { paths } = params;
|
|
67639
|
+
const identityNames = import_node_fs12.default.existsSync(paths.identitiesDir) ? import_node_fs12.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
67640
|
+
const identities = identityNames.map((name) => {
|
|
67641
|
+
const farmRoot = import_node_path32.default.join(paths.identitiesDir, name);
|
|
67642
|
+
const identityPath = import_node_path32.default.join(farmRoot, "identity.json");
|
|
67643
|
+
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
67644
|
+
});
|
|
67645
|
+
const profileNames = import_node_fs12.default.existsSync(paths.configProfilesDir) ? import_node_fs12.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
67646
|
+
const configProfiles = profileNames.map((name) => {
|
|
67647
|
+
const profilePath = import_node_path32.default.join(paths.configProfilesDir, `${name}.json`);
|
|
67648
|
+
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
67649
|
+
});
|
|
67650
|
+
const providerNames = import_node_fs12.default.existsSync(paths.providersDir) ? import_node_fs12.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
67651
|
+
const providers = providerNames.map((name) => {
|
|
67652
|
+
const providerPath = import_node_path32.default.join(paths.providersDir, `${name}.json`);
|
|
67653
|
+
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
67654
|
+
});
|
|
67655
|
+
const ownExecutablePath = realOwnExecutablePath();
|
|
67656
|
+
let binaryDiscovery;
|
|
67657
|
+
try {
|
|
67658
|
+
const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
|
|
67659
|
+
binaryDiscovery = { ok: true, binary };
|
|
67660
|
+
} catch (error62) {
|
|
67661
|
+
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
67662
|
+
}
|
|
67663
|
+
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
67664
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path32.default.delimiter).filter((dir) => dir !== "");
|
|
67665
|
+
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
67666
|
+
findPathShadow({
|
|
67667
|
+
pathDirs,
|
|
67668
|
+
targetDir: import_node_path32.default.dirname(shimState.targetPath),
|
|
67669
|
+
targetFilename: import_node_path32.default.basename(shimState.targetPath),
|
|
67670
|
+
findExecutableInDir
|
|
67671
|
+
}),
|
|
67672
|
+
shimState.targetPath,
|
|
67673
|
+
realpathOrSelf
|
|
67674
|
+
);
|
|
67675
|
+
const report = runDoctor({
|
|
67676
|
+
env: params.env,
|
|
67677
|
+
credentialCache: realCredentialCacheEnv(paths),
|
|
67678
|
+
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
67679
|
+
identities,
|
|
67680
|
+
configProfiles,
|
|
67681
|
+
providers,
|
|
67682
|
+
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
67683
|
+
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
67684
|
+
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
67685
|
+
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
67686
|
+
binaryDiscovery,
|
|
67687
|
+
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs12.default.existsSync(shimState.targetPath) },
|
|
67688
|
+
rootPath: paths.root,
|
|
67689
|
+
pathResolution: {
|
|
67690
|
+
ownExecutablePath,
|
|
67691
|
+
agentShim: refinePathShadow(
|
|
67692
|
+
findPathShadow({
|
|
67693
|
+
pathDirs,
|
|
67694
|
+
targetDir: import_node_path32.default.dirname(ownExecutablePath),
|
|
67695
|
+
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
67696
|
+
findExecutableInDir
|
|
67697
|
+
}),
|
|
67698
|
+
ownExecutablePath,
|
|
67699
|
+
realpathOrSelf
|
|
67700
|
+
),
|
|
67701
|
+
...claudeShimShadow === void 0 ? {} : { claude: claudeShimShadow }
|
|
67702
|
+
},
|
|
67703
|
+
run: realRunPort,
|
|
67704
|
+
platform: process.platform,
|
|
67705
|
+
headroom: {
|
|
67706
|
+
state: { path: paths.headroomStateFile, raw: realFsPort.readFileUtf8(paths.headroomStateFile) },
|
|
67707
|
+
isRunning: realIsProcessRunning
|
|
67708
|
+
}
|
|
67709
|
+
});
|
|
67710
|
+
return report;
|
|
67711
|
+
}
|
|
67712
|
+
|
|
67157
67713
|
// node_modules/.pnpm/radash@12.1.1/node_modules/radash/dist/esm/async.mjs
|
|
67158
67714
|
var guard = (func, shouldGuard) => {
|
|
67159
67715
|
const _guard = (err) => {
|
|
@@ -68066,9 +68622,9 @@ function resolveFriendlyClientOptions(options) {
|
|
|
68066
68622
|
};
|
|
68067
68623
|
}
|
|
68068
68624
|
function createORPCClient(link, options = {}) {
|
|
68069
|
-
const
|
|
68625
|
+
const path44 = options.path ?? [];
|
|
68070
68626
|
const procedureClient = async (...[input2, options2 = {}]) => {
|
|
68071
|
-
return await link.call(
|
|
68627
|
+
return await link.call(path44, input2, resolveFriendlyClientOptions(options2));
|
|
68072
68628
|
};
|
|
68073
68629
|
const recursive2 = new Proxy(procedureClient, {
|
|
68074
68630
|
get(target, key) {
|
|
@@ -68077,13 +68633,243 @@ function createORPCClient(link, options = {}) {
|
|
|
68077
68633
|
}
|
|
68078
68634
|
return createORPCClient(link, {
|
|
68079
68635
|
...options,
|
|
68080
|
-
path: [...
|
|
68636
|
+
path: [...path44, key]
|
|
68081
68637
|
});
|
|
68082
68638
|
}
|
|
68083
68639
|
});
|
|
68084
68640
|
return preventNativeAwait(recursive2);
|
|
68085
68641
|
}
|
|
68086
68642
|
|
|
68643
|
+
// src/resolve/types.ts
|
|
68644
|
+
var LAYER_KINDS = [
|
|
68645
|
+
"global-config",
|
|
68646
|
+
"config-profile",
|
|
68647
|
+
"directory-rule",
|
|
68648
|
+
"portable",
|
|
68649
|
+
"portable-local",
|
|
68650
|
+
"cli-override"
|
|
68651
|
+
];
|
|
68652
|
+
var DECISION_VIAS = [
|
|
68653
|
+
/** The unconditional pre-cascade floor: the path's real classification is `secret`. */
|
|
68654
|
+
"secret-floor",
|
|
68655
|
+
/** Nothing in the classification map recognises the path's top-level entry. */
|
|
68656
|
+
"unclassified",
|
|
68657
|
+
/** An entries rule matched and its condition (if any) held. */
|
|
68658
|
+
"entry-rule",
|
|
68659
|
+
/** No entries rule survived; a layer's category toggle decided it. */
|
|
68660
|
+
"category-override",
|
|
68661
|
+
/** No entries rule and no category toggle; the shipped default for the category decided it. */
|
|
68662
|
+
"category-default"
|
|
68663
|
+
];
|
|
68664
|
+
var DIAGNOSTIC_CODES = [
|
|
68665
|
+
/** A profile's `extends` graph contains a cycle. */
|
|
68666
|
+
"EXTENDS_CYCLE",
|
|
68667
|
+
/** An `extends` entry names a profile that does not exist. */
|
|
68668
|
+
"MISSING_PROFILE",
|
|
68669
|
+
/** An entries key was written under the `secret/` prefix. Rejected at compile time — `secret` can never be overridden by any layer. */
|
|
68670
|
+
"SECRET_ENTRY_KEY",
|
|
68671
|
+
/** An entries key under some other prefix matched a path whose real classification is `secret`. Neutralised at resolve time by the floor check. */
|
|
68672
|
+
"SECRET_PATH_NEUTRALISED",
|
|
68673
|
+
/** An entries key's declared category prefix disagrees with the real classification of a path it matched. */
|
|
68674
|
+
"CATEGORY_PREFIX_MISMATCH",
|
|
68675
|
+
/** An entries key is not of the form `<category>/<path>`. The schema rejects these at parse time; this fires only for a layer built in code. */
|
|
68676
|
+
"MALFORMED_ENTRY_KEY",
|
|
68677
|
+
/** An earlier layer's exact key lost to a later layer's glob. Correct per the comparator, but worth surfacing rather than resolving silently. */
|
|
68678
|
+
"EXACT_ENTRY_OVERRIDDEN_BY_LATER_GLOB",
|
|
68679
|
+
/** A `history/projects/` pattern's encoded form could plausibly correspond to more than one real path. */
|
|
68680
|
+
"AMBIGUOUS_PROJECT_ENCODING",
|
|
68681
|
+
/** A `history/projects/` key's path fragment is neither home-rooted nor absolute, so it cannot be encoded. */
|
|
68682
|
+
"UNROOTED_PROJECT_PATH",
|
|
68683
|
+
/** A `~/.claude` entry nothing in the classification map recognises. */
|
|
68684
|
+
"UNCLASSIFIED_ENTRY",
|
|
68685
|
+
/** An empty `when: {}` object, which is vacuously true and therefore has no effect. */
|
|
68686
|
+
"EMPTY_WHEN",
|
|
68687
|
+
/** The previous farm's manifest is missing or unreadable, so reconciliation ran in conservative mode. */
|
|
68688
|
+
"FARM_MANIFEST_MISSING",
|
|
68689
|
+
/** A file Claude Code wrote into a materialised farm directory differs from the canonical copy of the same path. */
|
|
68690
|
+
"RECONCILE_CONFLICT",
|
|
68691
|
+
/** Reconciliation proposed adopting a path whose real classification is `secret`. Refused: the secret floor applies to data moving into `~/.claude` exactly as it applies to data moving out. */
|
|
68692
|
+
"RECONCILE_SECRET_BLOCKED",
|
|
68693
|
+
/** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
|
|
68694
|
+
"FARM_SWAP_RECOVERED",
|
|
68695
|
+
/** A superseded farm could not be discarded because it still held data the new farm has its own entry for, so it was left on disk for the user to look at. */
|
|
68696
|
+
"FARM_PREVIOUS_RETAINED"
|
|
68697
|
+
];
|
|
68698
|
+
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
68699
|
+
|
|
68700
|
+
// src/usage/pickReportSchema.ts
|
|
68701
|
+
var PoolPickCandidateViewSchema = external_exports.strictObject({
|
|
68702
|
+
identity: external_exports.string(),
|
|
68703
|
+
/** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
|
|
68704
|
+
class: external_exports.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
68705
|
+
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
68706
|
+
score: external_exports.number().optional(),
|
|
68707
|
+
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
68708
|
+
feasible: external_exports.boolean(),
|
|
68709
|
+
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
68710
|
+
blockedUntil: external_exports.iso.datetime().optional(),
|
|
68711
|
+
plan: PlanClassSchema,
|
|
68712
|
+
/** The facts behind the class and score, in the order they matter. */
|
|
68713
|
+
reasons: external_exports.array(external_exports.string())
|
|
68714
|
+
});
|
|
68715
|
+
var PoolPickReportSchema = external_exports.strictObject({
|
|
68716
|
+
pool: external_exports.string(),
|
|
68717
|
+
directory: external_exports.string(),
|
|
68718
|
+
/** The member a launch would run as, absent when every member is refused. */
|
|
68719
|
+
pick: external_exports.string().optional(),
|
|
68720
|
+
candidates: external_exports.array(PoolPickCandidateViewSchema),
|
|
68721
|
+
/** Members that name an identity that does not exist; a launch skips them. */
|
|
68722
|
+
missing: external_exports.array(external_exports.string()),
|
|
68723
|
+
/** When nothing can be picked, the soonest any member returns. */
|
|
68724
|
+
earliestReturn: external_exports.strictObject({ identity: external_exports.string(), at: external_exports.iso.datetime() }).optional(),
|
|
68725
|
+
/** Why the last-pick record could not be read, when that is the case. */
|
|
68726
|
+
stickyProblem: external_exports.string().optional()
|
|
68727
|
+
});
|
|
68728
|
+
|
|
68729
|
+
// src/checkReportSchema.ts
|
|
68730
|
+
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
68731
|
+
var CheckLayerViewSchema = external_exports.strictObject({
|
|
68732
|
+
id: external_exports.int(),
|
|
68733
|
+
kind: external_exports.enum(LAYER_KINDS),
|
|
68734
|
+
source: external_exports.string()
|
|
68735
|
+
});
|
|
68736
|
+
var CheckEntryViewSchema = external_exports.strictObject({
|
|
68737
|
+
path: external_exports.string(),
|
|
68738
|
+
shared: external_exports.boolean(),
|
|
68739
|
+
via: external_exports.enum(DECISION_VIAS),
|
|
68740
|
+
/** The entry's real category, or null when nothing classifies it. */
|
|
68741
|
+
category: external_exports.enum(CATEGORY_NAMES).nullable(),
|
|
68742
|
+
rule: external_exports.strictObject({ key: external_exports.string(), layer: external_exports.int() }).optional(),
|
|
68743
|
+
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
68744
|
+
eliminated: external_exports.readonly(external_exports.array(external_exports.strictObject({ key: external_exports.string(), failed: external_exports.readonly(external_exports.array(external_exports.string())) }))).optional()
|
|
68745
|
+
});
|
|
68746
|
+
var CheckDiagnosticSchema = external_exports.strictObject({
|
|
68747
|
+
code: external_exports.enum(DIAGNOSTIC_CODES),
|
|
68748
|
+
severity: external_exports.enum(DIAGNOSTIC_SEVERITIES),
|
|
68749
|
+
message: external_exports.string(),
|
|
68750
|
+
subject: external_exports.string().optional(),
|
|
68751
|
+
layer: external_exports.int().optional()
|
|
68752
|
+
});
|
|
68753
|
+
var CheckAmbientCredentialSchema = external_exports.union([external_exports.strictObject({ ok: external_exports.literal(true) }), external_exports.strictObject({ ok: external_exports.literal(false), variable: external_exports.string(), message: external_exports.string() })]);
|
|
68754
|
+
var CheckKeychainSchema = external_exports.strictObject({
|
|
68755
|
+
checked: external_exports.literal(true),
|
|
68756
|
+
found: external_exports.boolean(),
|
|
68757
|
+
serviceName: external_exports.string().optional(),
|
|
68758
|
+
note: external_exports.string()
|
|
68759
|
+
});
|
|
68760
|
+
var CheckSettingsExposureSchema = external_exports.strictObject({
|
|
68761
|
+
file: external_exports.string(),
|
|
68762
|
+
envKeyNames: external_exports.readonly(external_exports.array(external_exports.string())),
|
|
68763
|
+
hookEventNames: external_exports.readonly(external_exports.array(external_exports.string())),
|
|
68764
|
+
hookCommandCount: external_exports.int().nonnegative()
|
|
68765
|
+
});
|
|
68766
|
+
var CredentialSourceSummarySchema = external_exports.union([
|
|
68767
|
+
external_exports.strictObject({ kind: external_exports.literal("env"), variable: external_exports.string() }),
|
|
68768
|
+
external_exports.strictObject({ kind: external_exports.literal("file"), path: external_exports.string() }),
|
|
68769
|
+
external_exports.strictObject({ kind: external_exports.literal("command"), program: external_exports.string() }),
|
|
68770
|
+
external_exports.strictObject({ kind: external_exports.literal("op"), reference: external_exports.string() }),
|
|
68771
|
+
external_exports.strictObject({ kind: external_exports.literal("keychain"), service: external_exports.string(), account: external_exports.string().optional() }),
|
|
68772
|
+
external_exports.strictObject({ kind: external_exports.literal("literal") })
|
|
68773
|
+
]);
|
|
68774
|
+
var CredentialSummarySchema = external_exports.strictObject({
|
|
68775
|
+
target: external_exports.enum(CREDENTIAL_TARGETS),
|
|
68776
|
+
sources: external_exports.readonly(external_exports.array(CredentialSourceSummarySchema)),
|
|
68777
|
+
cache: CredentialCacheSchema.optional()
|
|
68778
|
+
});
|
|
68779
|
+
var CachedCredentialStateSchema = external_exports.union([
|
|
68780
|
+
external_exports.strictObject({ store: external_exports.enum(CREDENTIAL_CACHE_STORES), status: external_exports.literal("empty") }),
|
|
68781
|
+
external_exports.strictObject({ store: external_exports.enum(CREDENTIAL_CACHE_STORES), status: external_exports.literal("unreadable"), reason: external_exports.string() }),
|
|
68782
|
+
external_exports.strictObject({ store: external_exports.enum(CREDENTIAL_CACHE_STORES), status: external_exports.enum(["fresh", "expired"]), ageMs: external_exports.number(), expiresInMs: external_exports.number().optional() })
|
|
68783
|
+
]);
|
|
68784
|
+
var CheckCredentialProviderSchema = external_exports.union([
|
|
68785
|
+
external_exports.strictObject({ name: external_exports.string(), credential: CredentialSummarySchema, cached: CachedCredentialStateSchema.optional() }),
|
|
68786
|
+
external_exports.strictObject({ name: external_exports.string(), problem: external_exports.string() })
|
|
68787
|
+
]);
|
|
68788
|
+
var CheckCredentialSchema = external_exports.strictObject({
|
|
68789
|
+
applies: external_exports.enum(CHECK_CREDENTIAL_APPLIES),
|
|
68790
|
+
provider: CheckCredentialProviderSchema.optional(),
|
|
68791
|
+
identity: CredentialSummarySchema.optional(),
|
|
68792
|
+
identityCached: CachedCredentialStateSchema.optional()
|
|
68793
|
+
});
|
|
68794
|
+
var CheckClaudeVersionSchema = external_exports.strictObject({
|
|
68795
|
+
pinned: external_exports.strictObject({ version: external_exports.string(), source: external_exports.enum(CLAUDE_VERSION_SOURCES), installed: external_exports.boolean() }).optional(),
|
|
68796
|
+
highestInstalled: external_exports.string().optional(),
|
|
68797
|
+
installed: external_exports.readonly(external_exports.array(external_exports.string()))
|
|
68798
|
+
});
|
|
68799
|
+
var CheckReportJsonSchema = external_exports.strictObject({
|
|
68800
|
+
identity: external_exports.strictObject({ name: external_exports.string().nullable(), source: external_exports.enum(IDENTITY_DECISION_SOURCES) }),
|
|
68801
|
+
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
68802
|
+
pool: PoolPickReportSchema.optional(),
|
|
68803
|
+
configProfile: external_exports.strictObject({ name: external_exports.string().nullable(), source: external_exports.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
68804
|
+
layers: external_exports.readonly(external_exports.array(CheckLayerViewSchema)),
|
|
68805
|
+
entries: external_exports.readonly(external_exports.array(CheckEntryViewSchema)),
|
|
68806
|
+
projectEncodingAmbiguities: external_exports.readonly(
|
|
68807
|
+
external_exports.array(external_exports.strictObject({ fragment: external_exports.string(), encoded: external_exports.string(), reason: external_exports.enum(ENCODING_AMBIGUITY_REASONS), detail: external_exports.string() }))
|
|
68808
|
+
),
|
|
68809
|
+
diagnostics: external_exports.readonly(external_exports.array(CheckDiagnosticSchema)),
|
|
68810
|
+
ambientCredential: CheckAmbientCredentialSchema,
|
|
68811
|
+
keychain: CheckKeychainSchema.optional(),
|
|
68812
|
+
settingsExposure: external_exports.readonly(external_exports.array(CheckSettingsExposureSchema)),
|
|
68813
|
+
credential: CheckCredentialSchema,
|
|
68814
|
+
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
68815
|
+
});
|
|
68816
|
+
|
|
68817
|
+
// src/frontdoor/controlSchemas.ts
|
|
68818
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
68819
|
+
var UsageListOutputSchema = external_exports.strictObject({ snapshots: external_exports.readonly(external_exports.array(UsageSnapshotSchema)) });
|
|
68820
|
+
var UsageWindowsInputSchema = external_exports.strictObject({
|
|
68821
|
+
identity: external_exports.string().min(1),
|
|
68822
|
+
provider: external_exports.string().min(1).optional()
|
|
68823
|
+
});
|
|
68824
|
+
var EffectiveWindowSchema = external_exports.strictObject({
|
|
68825
|
+
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
68826
|
+
reset: external_exports.boolean(),
|
|
68827
|
+
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
68828
|
+
utilization: external_exports.number().optional(),
|
|
68829
|
+
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
68830
|
+
resetsAtMs: external_exports.number().optional(),
|
|
68831
|
+
/** The window's own status, for a window that has not reset yet. */
|
|
68832
|
+
status: external_exports.string().optional()
|
|
68833
|
+
});
|
|
68834
|
+
var UsageWindowsOutputSchema = external_exports.strictObject({
|
|
68835
|
+
identity: external_exports.string(),
|
|
68836
|
+
provider: external_exports.string(),
|
|
68837
|
+
/** When the rate-limit state the windows come from was observed. */
|
|
68838
|
+
observedAt: external_exports.iso.datetime().optional(),
|
|
68839
|
+
fiveHour: EffectiveWindowSchema.optional(),
|
|
68840
|
+
sevenDay: EffectiveWindowSchema.optional()
|
|
68841
|
+
});
|
|
68842
|
+
var FrontDoorSessionStatusSchema = external_exports.strictObject({
|
|
68843
|
+
pid: external_exports.int().positive(),
|
|
68844
|
+
startedAt: external_exports.number(),
|
|
68845
|
+
alive: external_exports.boolean()
|
|
68846
|
+
});
|
|
68847
|
+
var HeadroomSocketTargetSchema = external_exports.union([external_exports.strictObject({ socketPath: external_exports.string() }), external_exports.strictObject({ refused: external_exports.string() })]);
|
|
68848
|
+
var FrontDoorStatusOutputSchema = external_exports.strictObject({
|
|
68849
|
+
state: FrontDoorStateSchema,
|
|
68850
|
+
supervisorAlive: external_exports.boolean(),
|
|
68851
|
+
sessions: external_exports.readonly(external_exports.array(FrontDoorSessionStatusSchema)),
|
|
68852
|
+
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
68853
|
+
logPath: external_exports.string(),
|
|
68854
|
+
logExists: external_exports.boolean()
|
|
68855
|
+
});
|
|
68856
|
+
var FrontDoorSessionsOutputSchema = external_exports.strictObject({ sessions: external_exports.readonly(external_exports.array(FrontDoorSessionStatusSchema)) });
|
|
68857
|
+
var CheckRunInputSchema = external_exports.strictObject({
|
|
68858
|
+
path: external_exports.string().min(1),
|
|
68859
|
+
identity: external_exports.string().min(1).optional()
|
|
68860
|
+
}).refine((input2) => import_node_path33.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
68861
|
+
var DoctorFindingSchema = external_exports.strictObject({
|
|
68862
|
+
section: external_exports.enum(DOCTOR_SECTIONS),
|
|
68863
|
+
subject: external_exports.string().optional(),
|
|
68864
|
+
severity: external_exports.enum(DOCTOR_SEVERITIES),
|
|
68865
|
+
message: external_exports.string()
|
|
68866
|
+
});
|
|
68867
|
+
var DoctorRunOutputSchema = external_exports.strictObject({
|
|
68868
|
+
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
68869
|
+
ok: external_exports.boolean(),
|
|
68870
|
+
findings: external_exports.readonly(external_exports.array(DoctorFindingSchema))
|
|
68871
|
+
});
|
|
68872
|
+
|
|
68087
68873
|
// node_modules/.pnpm/@orpc+standard-server-fetch@1.15.4/node_modules/@orpc/standard-server-fetch/dist/index.mjs
|
|
68088
68874
|
function toEventIterator(stream, options = {}) {
|
|
68089
68875
|
const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
@@ -68379,19 +69165,19 @@ var StandardLink = class {
|
|
|
68379
69165
|
}
|
|
68380
69166
|
interceptors;
|
|
68381
69167
|
clientInterceptors;
|
|
68382
|
-
call(
|
|
69168
|
+
call(path44, input2, options) {
|
|
68383
69169
|
return runWithSpan(
|
|
68384
|
-
{ name: `${ORPC_NAME}.${
|
|
69170
|
+
{ name: `${ORPC_NAME}.${path44.join("/")}`, signal: options.signal },
|
|
68385
69171
|
(span) => {
|
|
68386
69172
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
68387
|
-
span?.setAttribute("rpc.method",
|
|
69173
|
+
span?.setAttribute("rpc.method", path44.join("."));
|
|
68388
69174
|
if (isAsyncIteratorObject(input2)) {
|
|
68389
69175
|
input2 = asyncIteratorWithSpan(
|
|
68390
69176
|
{ name: "consume_event_iterator_input", signal: options.signal },
|
|
68391
69177
|
input2
|
|
68392
69178
|
);
|
|
68393
69179
|
}
|
|
68394
|
-
return intercept(this.interceptors, { ...options, path:
|
|
69180
|
+
return intercept(this.interceptors, { ...options, path: path44, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
68395
69181
|
const otelConfig = getGlobalOtelConfig();
|
|
68396
69182
|
let otelContext;
|
|
68397
69183
|
const currentSpan = otelConfig?.trace.getActiveSpan() ?? span;
|
|
@@ -68626,8 +69412,8 @@ var StandardRPCJsonSerializer = class {
|
|
|
68626
69412
|
return ref.data;
|
|
68627
69413
|
}
|
|
68628
69414
|
};
|
|
68629
|
-
function toHttpPath(
|
|
68630
|
-
return `/${
|
|
69415
|
+
function toHttpPath(path44) {
|
|
69416
|
+
return `/${path44.map(encodeURIComponent).join("/")}`;
|
|
68631
69417
|
}
|
|
68632
69418
|
function toStandardHeaders2(headers) {
|
|
68633
69419
|
if (typeof headers.forEach === "function") {
|
|
@@ -68652,18 +69438,18 @@ var StandardRPCLinkCodec = class {
|
|
|
68652
69438
|
fallbackMethod;
|
|
68653
69439
|
expectedMethod;
|
|
68654
69440
|
headers;
|
|
68655
|
-
async encode(
|
|
68656
|
-
let headers = toStandardHeaders2(await value(this.headers, options,
|
|
69441
|
+
async encode(path44, input2, options) {
|
|
69442
|
+
let headers = toStandardHeaders2(await value(this.headers, options, path44, input2));
|
|
68657
69443
|
if (options.lastEventId !== void 0) {
|
|
68658
69444
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
68659
69445
|
}
|
|
68660
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
68661
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
69446
|
+
const expectedMethod = await value(this.expectedMethod, options, path44, input2);
|
|
69447
|
+
const baseUrl = await value(this.baseUrl, options, path44, input2);
|
|
68662
69448
|
const url2 = new URL(baseUrl);
|
|
68663
|
-
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(
|
|
69449
|
+
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(path44)}`;
|
|
68664
69450
|
const serialized = this.serializer.serialize(input2);
|
|
68665
69451
|
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
68666
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
69452
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path44, input2);
|
|
68667
69453
|
const getUrl = new URL(url2);
|
|
68668
69454
|
getUrl.searchParams.append("data", stringifyJSON(serialized));
|
|
68669
69455
|
if (getUrl.toString().length <= maxUrlLength) {
|
|
@@ -68814,11 +69600,11 @@ var LinkFetchClient = class {
|
|
|
68814
69600
|
this.toFetchRequestOptions = options;
|
|
68815
69601
|
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
68816
69602
|
}
|
|
68817
|
-
async call(standardRequest, options,
|
|
69603
|
+
async call(standardRequest, options, path44, input2) {
|
|
68818
69604
|
const request7 = toFetchRequest(standardRequest, this.toFetchRequestOptions);
|
|
68819
69605
|
const fetchResponse = await intercept(
|
|
68820
69606
|
this.adapterInterceptors,
|
|
68821
|
-
{ ...options, request: request7, path:
|
|
69607
|
+
{ ...options, request: request7, path: path44, input: input2, init: { redirect: "manual" } },
|
|
68822
69608
|
({ request: request22, path: path210, input: input22, init, ...options2 }) => this.fetch(request22, init, options2, path210, input22)
|
|
68823
69609
|
);
|
|
68824
69610
|
const lazyResponse = toStandardLazyResponse(fetchResponse, { signal: request7.signal });
|
|
@@ -69218,7 +70004,7 @@ function middlewareOutputFn(output2) {
|
|
|
69218
70004
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
69219
70005
|
const options = resolveMaybeOptionalOptions(rest);
|
|
69220
70006
|
return async (...[input2, callerOptions]) => {
|
|
69221
|
-
const
|
|
70007
|
+
const path44 = toArray(options.path);
|
|
69222
70008
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
69223
70009
|
const clientContext = callerOptions?.context ?? {};
|
|
69224
70010
|
const context = await value(options.context ?? {}, clientContext);
|
|
@@ -69233,7 +70019,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69233
70019
|
const output2 = await runWithSpan(
|
|
69234
70020
|
{ name: "call_procedure", signal: callerOptions?.signal },
|
|
69235
70021
|
(span) => {
|
|
69236
|
-
span?.setAttribute("procedure.path", [...
|
|
70022
|
+
span?.setAttribute("procedure.path", [...path44]);
|
|
69237
70023
|
return intercept(
|
|
69238
70024
|
toArray(options.interceptors),
|
|
69239
70025
|
{
|
|
@@ -69241,7 +70027,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69241
70027
|
input: input2,
|
|
69242
70028
|
// input only optional when it undefinable so we can safely cast it
|
|
69243
70029
|
errors,
|
|
69244
|
-
path:
|
|
70030
|
+
path: path44,
|
|
69245
70031
|
procedure,
|
|
69246
70032
|
signal: callerOptions?.signal,
|
|
69247
70033
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -69363,10 +70149,10 @@ var HIDDEN_ROUTER_CONTRACT_SYMBOL = /* @__PURE__ */ Symbol("ORPC_HIDDEN_ROUTER_C
|
|
|
69363
70149
|
function getHiddenRouterContract(router) {
|
|
69364
70150
|
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
69365
70151
|
}
|
|
69366
|
-
function getRouter(router,
|
|
70152
|
+
function getRouter(router, path44) {
|
|
69367
70153
|
let current = router;
|
|
69368
|
-
for (let i2 = 0; i2 <
|
|
69369
|
-
const segment =
|
|
70154
|
+
for (let i2 = 0; i2 < path44.length; i2++) {
|
|
70155
|
+
const segment = path44[i2];
|
|
69370
70156
|
if (!current) {
|
|
69371
70157
|
return void 0;
|
|
69372
70158
|
}
|
|
@@ -69381,7 +70167,7 @@ function getRouter(router, path43) {
|
|
|
69381
70167
|
continue;
|
|
69382
70168
|
}
|
|
69383
70169
|
const lazied = current;
|
|
69384
|
-
const rest =
|
|
70170
|
+
const rest = path44.slice(i2);
|
|
69385
70171
|
return lazy2(async () => {
|
|
69386
70172
|
const unwrapped = await unlazy(lazied);
|
|
69387
70173
|
const next = getRouter(unwrapped.default, rest);
|
|
@@ -69959,8 +70745,8 @@ function toAbortSignal(stream) {
|
|
|
69959
70745
|
function toStandardUrl(req) {
|
|
69960
70746
|
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
|
69961
70747
|
const origin = guard(() => new URL(`${protocol}//${req.headers.host ?? "localhost"}`).origin) ?? `${protocol}//localhost`;
|
|
69962
|
-
const
|
|
69963
|
-
return new URL(`${origin}${
|
|
70748
|
+
const path44 = req.originalUrl ?? req.url ?? "/";
|
|
70749
|
+
return new URL(`${origin}${path44.startsWith("/") ? "" : "/"}${path44}`);
|
|
69964
70750
|
}
|
|
69965
70751
|
function toStandardLazyRequest(req, res) {
|
|
69966
70752
|
const signal = toAbortSignal(res);
|
|
@@ -70159,8 +70945,8 @@ var StandardRPCMatcher = class {
|
|
|
70159
70945
|
constructor(options = {}) {
|
|
70160
70946
|
this.filter = options.filter ?? true;
|
|
70161
70947
|
}
|
|
70162
|
-
init(router,
|
|
70163
|
-
const laziedOptions = traverseContractProcedures({ router, path:
|
|
70948
|
+
init(router, path44 = []) {
|
|
70949
|
+
const laziedOptions = traverseContractProcedures({ router, path: path44 }, (traverseOptions) => {
|
|
70164
70950
|
if (!value(this.filter, traverseOptions)) {
|
|
70165
70951
|
return;
|
|
70166
70952
|
}
|
|
@@ -70438,16 +71224,19 @@ var RcAnswerOutputSchema = external_exports.strictObject({
|
|
|
70438
71224
|
// src/frontdoor/rcApi.ts
|
|
70439
71225
|
var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
|
|
70440
71226
|
var RC_SUBSCRIBER_BUFFER_EVENTS = 100;
|
|
70441
|
-
function
|
|
70442
|
-
|
|
71227
|
+
function doorApiAuth(expectedToken) {
|
|
71228
|
+
return os7.$context().use(({ context, next }) => {
|
|
70443
71229
|
const presented = context.headers.authorization;
|
|
70444
71230
|
const bearerPrefix = "bearer ".length;
|
|
70445
71231
|
const token = typeof presented === "string" && presented.slice(0, bearerPrefix).toLowerCase() === "bearer " ? presented.slice(bearerPrefix) : void 0;
|
|
70446
|
-
if (token === void 0 || !isLiveCapability(token, [
|
|
71232
|
+
if (token === void 0 || !isLiveCapability(token, [expectedToken])) {
|
|
70447
71233
|
throw new ORPCError("UNAUTHORIZED", { message: "the front door's typed API demands this generation's control token as a Bearer credential" });
|
|
70448
71234
|
}
|
|
70449
71235
|
return next();
|
|
70450
71236
|
});
|
|
71237
|
+
}
|
|
71238
|
+
function createRcApiRouter(deps) {
|
|
71239
|
+
const authed = doorApiAuth(deps.expectedToken);
|
|
70451
71240
|
const delivered = (sessionId, result) => {
|
|
70452
71241
|
if (!result.ok) {
|
|
70453
71242
|
throw new ORPCError("BAD_GATEWAY", { message: result.message });
|
|
@@ -70516,16 +71305,16 @@ function createRcApiRouter(deps) {
|
|
|
70516
71305
|
}
|
|
70517
71306
|
};
|
|
70518
71307
|
}
|
|
70519
|
-
function
|
|
70520
|
-
const handler = new RPCHandler(
|
|
71308
|
+
function doorApiNodeHandlerOf(router) {
|
|
71309
|
+
const handler = new RPCHandler(router, { plugins: [new BodyLimitPlugin({ maxBodySize: CONTROL_BODY_CAP_BYTES })] });
|
|
70521
71310
|
return {
|
|
70522
71311
|
pathPrefix: RC_ORPC_PATH_PREFIX,
|
|
70523
71312
|
handle: async (request7, response) => await handler.handle(request7, response, { context: { headers: request7.headers }, prefix: RC_ORPC_PATH_PREFIX })
|
|
70524
71313
|
};
|
|
70525
71314
|
}
|
|
70526
|
-
function
|
|
71315
|
+
function frontDoorApiLink(port, ca, token) {
|
|
70527
71316
|
const dispatcher = new import_undici2.Agent({ connect: { ca } });
|
|
70528
|
-
|
|
71317
|
+
return new RPCLink({
|
|
70529
71318
|
url: `https://127.0.0.1:${String(port)}${RC_ORPC_PATH_PREFIX}`,
|
|
70530
71319
|
headers: { authorization: `Bearer ${token}` },
|
|
70531
71320
|
// undici's own Request and Response types and the global ones are distinct declarations of the same standard shapes (the package's bundled types sit beside @types/node's own), and its fetch refuses the global Request instance outright, so the call is rebuilt from the request's parts and the answer re-wrapped through the global constructors, never cast between the two. The request body is one bounded JSON object (the same protocol cap the handler enforces), so reading it whole costs nothing; it is the answer that streams.
|
|
@@ -70541,7 +71330,53 @@ function frontDoorRcApiClient(port, ca, token) {
|
|
|
70541
71330
|
return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
|
|
70542
71331
|
}
|
|
70543
71332
|
});
|
|
70544
|
-
|
|
71333
|
+
}
|
|
71334
|
+
function frontDoorRcApiClient(port, ca, token) {
|
|
71335
|
+
return createORPCClient(frontDoorApiLink(port, ca, token));
|
|
71336
|
+
}
|
|
71337
|
+
|
|
71338
|
+
// src/frontdoor/controlApi.ts
|
|
71339
|
+
function createControlApiRouter(deps) {
|
|
71340
|
+
const authed = doorApiAuth(deps.expectedToken);
|
|
71341
|
+
return {
|
|
71342
|
+
usage: {
|
|
71343
|
+
list: authed.output(UsageListOutputSchema).handler(() => ({ snapshots: deps.usageSnapshots() })),
|
|
71344
|
+
effectiveWindow: authed.input(UsageWindowsInputSchema).output(UsageWindowsOutputSchema).handler(({ input: input2 }) => {
|
|
71345
|
+
const snapshot = deps.usageSnapshotOf(input2.identity);
|
|
71346
|
+
if (snapshot === void 0) {
|
|
71347
|
+
throw new ORPCError("NOT_FOUND", { message: `identity ${input2.identity} has no usage snapshot yet, so no quota window has been observed for it` });
|
|
71348
|
+
}
|
|
71349
|
+
const provider = input2.provider ?? ANTHROPIC_PROVIDER;
|
|
71350
|
+
const rateLimit = snapshot.providers[provider]?.rateLimit;
|
|
71351
|
+
const unified = rateLimit?.unified;
|
|
71352
|
+
const now = deps.now();
|
|
71353
|
+
return {
|
|
71354
|
+
identity: snapshot.identity,
|
|
71355
|
+
provider,
|
|
71356
|
+
...rateLimit === void 0 ? {} : { observedAt: rateLimit.observedAt },
|
|
71357
|
+
...unified?.fiveHour === void 0 ? {} : { fiveHour: effectiveWindow(unified.fiveHour, now) },
|
|
71358
|
+
...unified?.sevenDay === void 0 ? {} : { sevenDay: effectiveWindow(unified.sevenDay, now) }
|
|
71359
|
+
};
|
|
71360
|
+
})
|
|
71361
|
+
},
|
|
71362
|
+
frontdoor: {
|
|
71363
|
+
status: authed.output(FrontDoorStatusOutputSchema).handler(() => deps.frontDoorStatus()),
|
|
71364
|
+
sessions: authed.output(FrontDoorSessionsOutputSchema).handler(() => ({ sessions: deps.frontDoorStatus().sessions }))
|
|
71365
|
+
},
|
|
71366
|
+
check: {
|
|
71367
|
+
// The report's own JSON shape is the contract (the same one `check --json` prints and `checkReportSchema.ts` defines), so the procedure returns exactly that conversion.
|
|
71368
|
+
run: authed.input(CheckRunInputSchema).output(CheckReportJsonSchema).handler(({ input: input2 }) => checkReportToJson(deps.checkReport(input2.path, input2.identity)))
|
|
71369
|
+
},
|
|
71370
|
+
doctor: {
|
|
71371
|
+
run: authed.output(DoctorRunOutputSchema).handler(() => deps.doctorReport())
|
|
71372
|
+
}
|
|
71373
|
+
};
|
|
71374
|
+
}
|
|
71375
|
+
function createDoorApiRouter(deps) {
|
|
71376
|
+
return { ...createRcApiRouter(deps), ...createControlApiRouter(deps) };
|
|
71377
|
+
}
|
|
71378
|
+
function createDoorApiNodeHandler(deps) {
|
|
71379
|
+
return doorApiNodeHandlerOf(createDoorApiRouter(deps));
|
|
70545
71380
|
}
|
|
70546
71381
|
|
|
70547
71382
|
// src/frontdoor/headroomHop.ts
|
|
@@ -71622,8 +72457,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
71622
72457
|
request7.body.resume();
|
|
71623
72458
|
return;
|
|
71624
72459
|
}
|
|
71625
|
-
const
|
|
71626
|
-
const translated = { method: request7.method, path:
|
|
72460
|
+
const path44 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
72461
|
+
const translated = { method: request7.method, path: path44, body, signal: request7.signal };
|
|
71627
72462
|
const routed = await route(translated);
|
|
71628
72463
|
if (request7.signal.aborted) {
|
|
71629
72464
|
return;
|
|
@@ -71657,7 +72492,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71657
72492
|
headroomUpstream: target.headroomUpstream,
|
|
71658
72493
|
serve: async (request7, response) => {
|
|
71659
72494
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
71660
|
-
const
|
|
72495
|
+
const path44 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
71661
72496
|
const headers = forwardableHeaders(request7.headers);
|
|
71662
72497
|
delete headers.host;
|
|
71663
72498
|
await new Promise((resolve) => {
|
|
@@ -71665,7 +72500,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71665
72500
|
host: base.hostname,
|
|
71666
72501
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
71667
72502
|
method: request7.method,
|
|
71668
|
-
path: `${basePath}${
|
|
72503
|
+
path: `${basePath}${path44}${incoming.search}`,
|
|
71669
72504
|
headers,
|
|
71670
72505
|
agent
|
|
71671
72506
|
};
|
|
@@ -71714,7 +72549,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71714
72549
|
|
|
71715
72550
|
// src/frontdoor/providerRoute.ts
|
|
71716
72551
|
function createProviderRouteResolver(deps) {
|
|
71717
|
-
const isRcSelfHostPath = (
|
|
72552
|
+
const isRcSelfHostPath = (path44) => path44 === "/v1/code/sessions" || path44.startsWith("/v1/code/sessions/") || path44 === "/v1/sessions" || path44.startsWith("/v1/sessions/");
|
|
71718
72553
|
const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
|
|
71719
72554
|
const passthroughByTarget = /* @__PURE__ */ new Map();
|
|
71720
72555
|
const passthroughFor = (name, target) => {
|
|
@@ -71728,13 +72563,13 @@ function createProviderRouteResolver(deps) {
|
|
|
71728
72563
|
return route;
|
|
71729
72564
|
};
|
|
71730
72565
|
const resolve = (request7) => {
|
|
71731
|
-
const
|
|
71732
|
-
const scoped = parseProviderPath(
|
|
72566
|
+
const path44 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
72567
|
+
const scoped = parseProviderPath(path44);
|
|
71733
72568
|
if (scoped === void 0) {
|
|
71734
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
72569
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path44)) {
|
|
71735
72570
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
71736
72571
|
}
|
|
71737
|
-
return
|
|
72572
|
+
return path44.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path44}` };
|
|
71738
72573
|
}
|
|
71739
72574
|
const { provider } = scoped;
|
|
71740
72575
|
let definition;
|
|
@@ -71774,7 +72609,7 @@ function createProviderRouteResolver(deps) {
|
|
|
71774
72609
|
}
|
|
71775
72610
|
|
|
71776
72611
|
// src/frontdoor/rcCredentialStore.ts
|
|
71777
|
-
var
|
|
72612
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
71778
72613
|
function isSafeSessionId(sessionId) {
|
|
71779
72614
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
71780
72615
|
}
|
|
@@ -71800,7 +72635,7 @@ function sequenceNumOfJson(value2) {
|
|
|
71800
72635
|
}
|
|
71801
72636
|
function createRcCredentialStore(fs19, dir) {
|
|
71802
72637
|
fs19.mkdirPrivate(dir);
|
|
71803
|
-
const fileFor = (sessionId) =>
|
|
72638
|
+
const fileFor = (sessionId) => import_node_path34.default.join(dir, `${sessionId}.json`);
|
|
71804
72639
|
const readParsed = (sessionId) => {
|
|
71805
72640
|
const raw = fs19.readFileUtf8(fileFor(sessionId));
|
|
71806
72641
|
if (raw === void 0) {
|
|
@@ -72450,7 +73285,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
72450
73285
|
}
|
|
72451
73286
|
|
|
72452
73287
|
// src/frontdoor/rcSelfHostMint.ts
|
|
72453
|
-
var
|
|
73288
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
72454
73289
|
var CREDENTIALS_FILE = ".credentials.json";
|
|
72455
73290
|
var CLAUDE_JSON2 = ".claude.json";
|
|
72456
73291
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -72474,7 +73309,7 @@ function readJsonObject(fs19, file2) {
|
|
|
72474
73309
|
return isRecord6(parsed) ? parsed : void 0;
|
|
72475
73310
|
}
|
|
72476
73311
|
function readRcSelfHostRecord(fs19, frontdoorDir) {
|
|
72477
|
-
const parsed = readJsonObject(fs19,
|
|
73312
|
+
const parsed = readJsonObject(fs19, import_node_path35.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
72478
73313
|
if (parsed === void 0) {
|
|
72479
73314
|
return void 0;
|
|
72480
73315
|
}
|
|
@@ -72488,11 +73323,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
72488
73323
|
if (!isIdentityName(deps.identity)) {
|
|
72489
73324
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
72490
73325
|
}
|
|
72491
|
-
const identityDir =
|
|
72492
|
-
const credentialsFile =
|
|
72493
|
-
const claudeJsonFile =
|
|
72494
|
-
const recordDir =
|
|
72495
|
-
const recordFile =
|
|
73326
|
+
const identityDir = import_node_path35.default.join(deps.identitiesDir, deps.identity);
|
|
73327
|
+
const credentialsFile = import_node_path35.default.join(identityDir, CREDENTIALS_FILE);
|
|
73328
|
+
const claudeJsonFile = import_node_path35.default.join(identityDir, CLAUDE_JSON2);
|
|
73329
|
+
const recordDir = import_node_path35.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
73330
|
+
const recordFile = import_node_path35.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
72496
73331
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
72497
73332
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
72498
73333
|
const existingOauth = isRecord6(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -72508,7 +73343,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
72508
73343
|
const organizationUuid = deps.newUuid();
|
|
72509
73344
|
const accountUuid = deps.newUuid();
|
|
72510
73345
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
72511
|
-
deps.fs.mkdirPrivate(
|
|
73346
|
+
deps.fs.mkdirPrivate(import_node_path35.default.dirname(credentialsFile));
|
|
72512
73347
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
72513
73348
|
`);
|
|
72514
73349
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -72820,6 +73655,59 @@ function createRcStreamHub(deps) {
|
|
|
72820
73655
|
};
|
|
72821
73656
|
}
|
|
72822
73657
|
|
|
73658
|
+
// src/frontdoor/status.ts
|
|
73659
|
+
function headroomSocketTarget(fsPort, trust, paths) {
|
|
73660
|
+
const socketPath = readHeadroomState(fsPort, paths.headroomStateFile)?.socketPath;
|
|
73661
|
+
return socketPath === void 0 ? void 0 : verifyHeadroomSocket(socketPath, trust);
|
|
73662
|
+
}
|
|
73663
|
+
function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
|
|
73664
|
+
const state = readFrontDoorState(fsPort, paths.frontdoorStateFile) ?? {};
|
|
73665
|
+
return {
|
|
73666
|
+
state,
|
|
73667
|
+
supervisorAlive: state.supervisorPid !== void 0 && isRunning(state.supervisorPid),
|
|
73668
|
+
sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
|
|
73669
|
+
headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
|
|
73670
|
+
logPath: paths.frontdoorLogPath,
|
|
73671
|
+
logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
|
|
73672
|
+
};
|
|
73673
|
+
}
|
|
73674
|
+
function formatFrontDoorStatus(status, caCertPath) {
|
|
73675
|
+
const lines = [];
|
|
73676
|
+
if (status.state.supervisorPid === void 0) {
|
|
73677
|
+
lines.push("supervisor: not running");
|
|
73678
|
+
} else {
|
|
73679
|
+
lines.push(`supervisor: pid ${String(status.state.supervisorPid)} (${status.supervisorAlive ? "alive" : "NOT running"})`);
|
|
73680
|
+
}
|
|
73681
|
+
if (status.state.port === void 0) {
|
|
73682
|
+
lines.push(`front door: not listening${status.state.lastPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastPort)})`}`);
|
|
73683
|
+
} else {
|
|
73684
|
+
lines.push(`front door: listening on https://127.0.0.1:${String(status.state.port)}, routing /providers/<name> requests`);
|
|
73685
|
+
}
|
|
73686
|
+
if (status.state.connectPort === void 0) {
|
|
73687
|
+
lines.push(`connect surface: not listening${status.state.lastConnectPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastConnectPort)})`}`);
|
|
73688
|
+
} else {
|
|
73689
|
+
lines.push(`connect surface: listening on 127.0.0.1:${String(status.state.connectPort)}, CA ${caCertPath}`);
|
|
73690
|
+
}
|
|
73691
|
+
if (status.headroomSocket === void 0) {
|
|
73692
|
+
lines.push("headroom hop: the daemon is not serving (sessions asking for headroom fail until it is up)");
|
|
73693
|
+
} else if (status.headroomSocket.refused === void 0) {
|
|
73694
|
+
lines.push(`headroom hop: daemon on unix socket ${status.headroomSocket.socketPath}`);
|
|
73695
|
+
} else {
|
|
73696
|
+
lines.push(`headroom hop: REFUSING the daemon's socket (sessions asking for headroom fail until it is fixed): ${status.headroomSocket.refused}`);
|
|
73697
|
+
}
|
|
73698
|
+
if (status.sessions.length === 0) {
|
|
73699
|
+
lines.push("sessions: none");
|
|
73700
|
+
} else {
|
|
73701
|
+
const pids = status.sessions.map((session) => `${String(session.pid)}${session.alive ? "" : " (dead)"}`);
|
|
73702
|
+
lines.push(`sessions: ${String(status.sessions.length)} registered (${pids.join(", ")})`);
|
|
73703
|
+
}
|
|
73704
|
+
if (status.state.lastError !== void 0) {
|
|
73705
|
+
lines.push(`last error: ${status.state.lastError}`);
|
|
73706
|
+
}
|
|
73707
|
+
lines.push(`daemon log: ${status.logPath}${status.logExists ? "" : " (not created yet)"}`);
|
|
73708
|
+
return lines;
|
|
73709
|
+
}
|
|
73710
|
+
|
|
72823
73711
|
// src/usage/providerQuota.ts
|
|
72824
73712
|
var ProviderQuotaError = class extends Error {
|
|
72825
73713
|
constructor(source, detail) {
|
|
@@ -73103,15 +73991,11 @@ function createRealQuotaRefresher(params) {
|
|
|
73103
73991
|
|
|
73104
73992
|
// src/frontdoor/commands.ts
|
|
73105
73993
|
function appendLog(paths, line) {
|
|
73106
|
-
|
|
73107
|
-
|
|
73994
|
+
import_node_fs13.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
73995
|
+
import_node_fs13.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
73108
73996
|
`);
|
|
73109
73997
|
}
|
|
73110
73998
|
var MINTED_TOKEN_RANDOM_BYTES = 32;
|
|
73111
|
-
function headroomSocketTarget(fsPort, trust, paths) {
|
|
73112
|
-
const socketPath = readHeadroomState(fsPort, paths.headroomStateFile)?.socketPath;
|
|
73113
|
-
return socketPath === void 0 ? void 0 : verifyHeadroomSocket(socketPath, trust);
|
|
73114
|
-
}
|
|
73115
73999
|
function rcObservingResolver(resolve, tracker, hub) {
|
|
73116
74000
|
return async (request7) => {
|
|
73117
74001
|
const resolution = await resolve(request7);
|
|
@@ -73231,6 +74115,14 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73231
74115
|
const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
|
|
73232
74116
|
const rcSetModel = async (sessionId, model) => await setRcSessionModel(rcControlRequestDeps, sessionId, model);
|
|
73233
74117
|
const rcSetPermissionMode = async (sessionId, mode) => await setRcSessionPermissionMode(rcControlRequestDeps, sessionId, mode);
|
|
74118
|
+
const controlDeps = {
|
|
74119
|
+
usageSnapshots: () => listUsageSnapshots(realFarmFs, paths.usageSnapshotsDir),
|
|
74120
|
+
usageSnapshotOf: (identity) => readUsageSnapshot(realFarmFs, paths.usageSnapshotsDir, identity),
|
|
74121
|
+
now: () => Date.now(),
|
|
74122
|
+
frontDoorStatus: () => collectFrontDoorStatus(realFarmFs, realHeadroomSocketTrust, paths, realIsProcessRunning),
|
|
74123
|
+
checkReport: (target, identity) => collectCheckReport({ paths, cwd: target, ...identity === void 0 ? {} : { identity }, env: process.env }),
|
|
74124
|
+
doctorReport: () => collectDoctorReport({ paths, env: process.env })
|
|
74125
|
+
};
|
|
73234
74126
|
realFarmFs.mkdirp(paths.frontdoorDir);
|
|
73235
74127
|
realFarmFs.writeFilePrivate(paths.frontdoorControlTokenFile, `${rcControlToken}
|
|
73236
74128
|
`);
|
|
@@ -73241,7 +74133,19 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73241
74133
|
log,
|
|
73242
74134
|
mintLeaf(authority, LOOPBACK_LEAF_NAMES, /* @__PURE__ */ new Date()),
|
|
73243
74135
|
createRcControlHandler({ expectedToken: rcControlToken, list: rcTracker.list, statusOf: rcTracker.statusOf, pendingOf: rcTracker.pendingOf, inject: rcInject, answer: rcAnswer, interrupt: rcInterrupt, setModel: rcSetModel, setPermissionMode: rcSetPermissionMode }),
|
|
73244
|
-
|
|
74136
|
+
createDoorApiNodeHandler({
|
|
74137
|
+
expectedToken: rcControlToken,
|
|
74138
|
+
list: rcTracker.list,
|
|
74139
|
+
statusOf: rcTracker.statusOf,
|
|
74140
|
+
pendingOf: rcTracker.pendingOf,
|
|
74141
|
+
inject: rcInject,
|
|
74142
|
+
answer: rcAnswer,
|
|
74143
|
+
interrupt: rcInterrupt,
|
|
74144
|
+
setModel: rcSetModel,
|
|
74145
|
+
setPermissionMode: rcSetPermissionMode,
|
|
74146
|
+
fanout: rcFanout,
|
|
74147
|
+
...controlDeps
|
|
74148
|
+
})
|
|
73245
74149
|
);
|
|
73246
74150
|
const handle = await listenFrontDoor(server, { ...preferredPort === void 0 ? {} : { preferredPort }, ca: authority.certPem, onError: onListenerError("provider") });
|
|
73247
74151
|
return {
|
|
@@ -73261,7 +74165,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73261
74165
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
73262
74166
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
73263
74167
|
if (capture !== void 0) {
|
|
73264
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
74168
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path36.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
73265
74169
|
}
|
|
73266
74170
|
if (rcSelfHostSurface !== void 0) {
|
|
73267
74171
|
log("self-hosted Remote Control surface on: the door serves the CCR session family itself, and its own client-half dials its own transparent surface");
|
|
@@ -73332,53 +74236,6 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73332
74236
|
}
|
|
73333
74237
|
};
|
|
73334
74238
|
}
|
|
73335
|
-
function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
|
|
73336
|
-
const state = readFrontDoorState(fsPort, paths.frontdoorStateFile) ?? {};
|
|
73337
|
-
return {
|
|
73338
|
-
state,
|
|
73339
|
-
supervisorAlive: state.supervisorPid !== void 0 && isRunning(state.supervisorPid),
|
|
73340
|
-
sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
|
|
73341
|
-
headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
|
|
73342
|
-
logPath: paths.frontdoorLogPath,
|
|
73343
|
-
logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
|
|
73344
|
-
};
|
|
73345
|
-
}
|
|
73346
|
-
function formatFrontDoorStatus(status, caCertPath) {
|
|
73347
|
-
const lines = [];
|
|
73348
|
-
if (status.state.supervisorPid === void 0) {
|
|
73349
|
-
lines.push("supervisor: not running");
|
|
73350
|
-
} else {
|
|
73351
|
-
lines.push(`supervisor: pid ${String(status.state.supervisorPid)} (${status.supervisorAlive ? "alive" : "NOT running"})`);
|
|
73352
|
-
}
|
|
73353
|
-
if (status.state.port === void 0) {
|
|
73354
|
-
lines.push(`front door: not listening${status.state.lastPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastPort)})`}`);
|
|
73355
|
-
} else {
|
|
73356
|
-
lines.push(`front door: listening on https://127.0.0.1:${String(status.state.port)}, routing /providers/<name> requests`);
|
|
73357
|
-
}
|
|
73358
|
-
if (status.state.connectPort === void 0) {
|
|
73359
|
-
lines.push(`connect surface: not listening${status.state.lastConnectPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastConnectPort)})`}`);
|
|
73360
|
-
} else {
|
|
73361
|
-
lines.push(`connect surface: listening on 127.0.0.1:${String(status.state.connectPort)}, CA ${caCertPath}`);
|
|
73362
|
-
}
|
|
73363
|
-
if (status.headroomSocket === void 0) {
|
|
73364
|
-
lines.push("headroom hop: the daemon is not serving (sessions asking for headroom fail until it is up)");
|
|
73365
|
-
} else if (status.headroomSocket.refused === void 0) {
|
|
73366
|
-
lines.push(`headroom hop: daemon on unix socket ${status.headroomSocket.socketPath}`);
|
|
73367
|
-
} else {
|
|
73368
|
-
lines.push(`headroom hop: REFUSING the daemon's socket (sessions asking for headroom fail until it is fixed): ${status.headroomSocket.refused}`);
|
|
73369
|
-
}
|
|
73370
|
-
if (status.sessions.length === 0) {
|
|
73371
|
-
lines.push("sessions: none");
|
|
73372
|
-
} else {
|
|
73373
|
-
const pids = status.sessions.map((session) => `${String(session.pid)}${session.alive ? "" : " (dead)"}`);
|
|
73374
|
-
lines.push(`sessions: ${String(status.sessions.length)} registered (${pids.join(", ")})`);
|
|
73375
|
-
}
|
|
73376
|
-
if (status.state.lastError !== void 0) {
|
|
73377
|
-
lines.push(`last error: ${status.state.lastError}`);
|
|
73378
|
-
}
|
|
73379
|
-
lines.push(`daemon log: ${status.logPath}${status.logExists ? "" : " (not created yet)"}`);
|
|
73380
|
-
return lines;
|
|
73381
|
-
}
|
|
73382
74239
|
function formatRcSessionList(sessions) {
|
|
73383
74240
|
if (sessions.length === 0) {
|
|
73384
74241
|
return ["no Remote Control sessions observed"];
|
|
@@ -73962,16 +74819,16 @@ function registerCompletionCommand(program2) {
|
|
|
73962
74819
|
var import_node_child_process4 = require("node:child_process");
|
|
73963
74820
|
|
|
73964
74821
|
// src/identityToken.ts
|
|
73965
|
-
var
|
|
73966
|
-
var
|
|
74822
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
74823
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
73967
74824
|
var TOKEN_FILE_MODE = 384;
|
|
73968
74825
|
var TOKEN_DIR_MODE = 448;
|
|
73969
74826
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
73970
74827
|
function identityTokenDir(paths) {
|
|
73971
|
-
return
|
|
74828
|
+
return import_node_path37.default.join(paths.root, "credentials");
|
|
73972
74829
|
}
|
|
73973
74830
|
function identityTokenPath(paths, identityName) {
|
|
73974
|
-
return
|
|
74831
|
+
return import_node_path37.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
73975
74832
|
}
|
|
73976
74833
|
function storeIdentityToken(paths, identityName, raw) {
|
|
73977
74834
|
const token = raw.trim();
|
|
@@ -73979,13 +74836,13 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
73979
74836
|
throw new UsageError("That is not a claude setup-token token (expected it to start with sk-ant-oat). Run `claude setup-token` and pass its token on standard input.");
|
|
73980
74837
|
}
|
|
73981
74838
|
const dir = identityTokenDir(paths);
|
|
73982
|
-
|
|
73983
|
-
|
|
74839
|
+
import_node_fs14.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
74840
|
+
import_node_fs14.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
73984
74841
|
const target = identityTokenPath(paths, identityName);
|
|
73985
|
-
const temp =
|
|
73986
|
-
|
|
74842
|
+
const temp = import_node_path37.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
74843
|
+
import_node_fs14.default.writeFileSync(temp, `${token}
|
|
73987
74844
|
`, { mode: TOKEN_FILE_MODE });
|
|
73988
|
-
|
|
74845
|
+
import_node_fs14.default.renameSync(temp, target);
|
|
73989
74846
|
return target;
|
|
73990
74847
|
}
|
|
73991
74848
|
|
|
@@ -74119,509 +74976,6 @@ function subjectName(positional, provider) {
|
|
|
74119
74976
|
return name;
|
|
74120
74977
|
}
|
|
74121
74978
|
|
|
74122
|
-
// src/doctorReport.ts
|
|
74123
|
-
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
74124
|
-
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
74125
|
-
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
74126
|
-
if (status.status !== "shadowed") {
|
|
74127
|
-
return status;
|
|
74128
|
-
}
|
|
74129
|
-
return realpath(status.by) === realpath(ownExecutablePath) ? { status: "ok" } : status;
|
|
74130
|
-
}
|
|
74131
|
-
function validateJson(schema, input2) {
|
|
74132
|
-
if (input2.raw === void 0) {
|
|
74133
|
-
return { ok: false, message: `${input2.path} is missing.` };
|
|
74134
|
-
}
|
|
74135
|
-
let parsed;
|
|
74136
|
-
try {
|
|
74137
|
-
parsed = JSON.parse(input2.raw);
|
|
74138
|
-
} catch (error62) {
|
|
74139
|
-
return { ok: false, message: `${input2.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
74140
|
-
}
|
|
74141
|
-
const result = schema.safeParse(parsed);
|
|
74142
|
-
if (!result.success) {
|
|
74143
|
-
return { ok: false, message: new ConfigValidationError(input2.path, result.error.issues).message };
|
|
74144
|
-
}
|
|
74145
|
-
return { ok: true, data: result.data };
|
|
74146
|
-
}
|
|
74147
|
-
function pushPathResolution(push, resolution) {
|
|
74148
|
-
const ownDir = import_node_path36.default.dirname(resolution.ownExecutablePath);
|
|
74149
|
-
switch (resolution.agentShim.status) {
|
|
74150
|
-
case "ok":
|
|
74151
|
-
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
74152
|
-
break;
|
|
74153
|
-
case "not-on-path":
|
|
74154
|
-
push(
|
|
74155
|
-
"path-resolution",
|
|
74156
|
-
"warn",
|
|
74157
|
-
`${ownDir} is not on PATH, so a bare \`agent-shim\` does not reach ${resolution.ownExecutablePath}. Add it to PATH, or keep invoking this executable by its full path.`,
|
|
74158
|
-
"agent-shim"
|
|
74159
|
-
);
|
|
74160
|
-
break;
|
|
74161
|
-
case "shadowed":
|
|
74162
|
-
push(
|
|
74163
|
-
"path-resolution",
|
|
74164
|
-
"fail",
|
|
74165
|
-
`\`agent-shim\` on PATH resolves to ${resolution.agentShim.by}, not this running executable, ${resolution.ownExecutablePath}. Every command you type runs that one instead, at whatever version it happens to be \u2014 including the checks in this report, which describe this executable. Remove ${resolution.agentShim.by}, repoint it at ${resolution.ownExecutablePath}, or put ${ownDir} ahead of it on PATH.`,
|
|
74166
|
-
"agent-shim"
|
|
74167
|
-
);
|
|
74168
|
-
break;
|
|
74169
|
-
}
|
|
74170
|
-
if (resolution.claude === void 0) {
|
|
74171
|
-
return;
|
|
74172
|
-
}
|
|
74173
|
-
switch (resolution.claude.status) {
|
|
74174
|
-
case "ok":
|
|
74175
|
-
push("path-resolution", "pass", "`claude` on PATH resolves to the enabled shim.", "claude");
|
|
74176
|
-
break;
|
|
74177
|
-
case "not-on-path":
|
|
74178
|
-
push("path-resolution", "warn", "The enabled `claude` shim's directory is not on PATH \u2014 add it, or use `agent-shim run` instead.", "claude");
|
|
74179
|
-
break;
|
|
74180
|
-
case "shadowed":
|
|
74181
|
-
push(
|
|
74182
|
-
"path-resolution",
|
|
74183
|
-
"warn",
|
|
74184
|
-
`\`claude\` on PATH resolves to ${resolution.claude.by}, not the enabled shim. Put the shim's directory ahead of it on PATH, or run \`agent-shim shim disable\` if you meant to launch that one directly.`,
|
|
74185
|
-
"claude"
|
|
74186
|
-
);
|
|
74187
|
-
break;
|
|
74188
|
-
}
|
|
74189
|
-
}
|
|
74190
|
-
function cacheClause(cacheEnv, owner, block2) {
|
|
74191
|
-
if (cacheEnv === void 0 || block2.cache === void 0) {
|
|
74192
|
-
return { text: "", unreadable: false };
|
|
74193
|
-
}
|
|
74194
|
-
const state = describeCachedCredential({ port: cacheEnv.port, platform: cacheEnv.platform, owner, cache: block2.cache, nowMs: cacheEnv.now() });
|
|
74195
|
-
return { text: `; ${formatCachedCredentialState(state)}`, unreadable: state.status === "unreadable" };
|
|
74196
|
-
}
|
|
74197
|
-
function pushProvider(push, entry, cacheEnv) {
|
|
74198
|
-
if (entry.raw === void 0) {
|
|
74199
|
-
push("provider", "fail", `${entry.path} is missing.`, entry.name);
|
|
74200
|
-
return;
|
|
74201
|
-
}
|
|
74202
|
-
let parsed;
|
|
74203
|
-
try {
|
|
74204
|
-
parsed = JSON.parse(entry.raw);
|
|
74205
|
-
} catch (error62) {
|
|
74206
|
-
push("provider", "fail", `${entry.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}`, entry.name);
|
|
74207
|
-
return;
|
|
74208
|
-
}
|
|
74209
|
-
const conversion = legacyProviderConversion(parsed);
|
|
74210
|
-
if (conversion !== void 0) {
|
|
74211
|
-
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
74212
|
-
return;
|
|
74213
|
-
}
|
|
74214
|
-
const validated2 = ProviderSchema.safeParse(parsed);
|
|
74215
|
-
if (!validated2.success) {
|
|
74216
|
-
push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
|
|
74217
|
-
return;
|
|
74218
|
-
}
|
|
74219
|
-
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
|
|
74220
|
-
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
|
|
74221
|
-
if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
74222
|
-
push("provider", "warn", `${entry.name} does not set ENABLE_TOOL_SEARCH: a session on this provider loads MCP tools upfront rather than deferring them, because its base URL is the front door, which Claude Code treats as a non-first-party host. Set ENABLE_TOOL_SEARCH in the provider's env block to restore deferred loading, when the upstream backend supports the tool_reference payloads it sends.`, entry.name);
|
|
74223
|
-
}
|
|
74224
|
-
}
|
|
74225
|
-
function pushLegacyName(push, params) {
|
|
74226
|
-
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
74227
|
-
if (legacyVariables.length === 0 && import_node_path36.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
74228
|
-
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
74229
|
-
return;
|
|
74230
|
-
}
|
|
74231
|
-
for (const name of legacyVariables) {
|
|
74232
|
-
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);
|
|
74233
|
-
}
|
|
74234
|
-
if (import_node_path36.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
74235
|
-
push(
|
|
74236
|
-
"legacy-name",
|
|
74237
|
-
"warn",
|
|
74238
|
-
`The state root is the former ${params.rootPath}, used in place. Leave it where it is: macOS Claude Code keys each identity's Keychain login on its exact configuration directory path, so moving it signs every identity out.`
|
|
74239
|
-
);
|
|
74240
|
-
}
|
|
74241
|
-
}
|
|
74242
|
-
function runDoctor(params) {
|
|
74243
|
-
const findings = [];
|
|
74244
|
-
const push = (section, severity, message, subject) => {
|
|
74245
|
-
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
74246
|
-
};
|
|
74247
|
-
const checkPin = (section, subject, where, version2) => {
|
|
74248
|
-
const installed = params.installedClaudeVersions;
|
|
74249
|
-
if (version2 === void 0 || installed === void 0 || installed.includes(version2)) {
|
|
74250
|
-
return;
|
|
74251
|
-
}
|
|
74252
|
-
push(section, "warn", `${where} pins Claude Code ${version2}, which is not installed (installed: ${installed.length === 0 ? "none" : installed.join(", ")}); a launch that resolves to it fails.`, subject);
|
|
74253
|
-
};
|
|
74254
|
-
const ambient = detectAmbientCredential(params.env);
|
|
74255
|
-
if (ambient === void 0) {
|
|
74256
|
-
push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
|
|
74257
|
-
} else {
|
|
74258
|
-
push("ambient-credential", "warn", formatAmbientCredentialGuardMessage(ambient.variable));
|
|
74259
|
-
}
|
|
74260
|
-
if (params.binaryDiscovery.ok) {
|
|
74261
|
-
const { binary } = params.binaryDiscovery;
|
|
74262
|
-
const versionNote = binary.version === void 0 ? "" : `, version ${binary.version}`;
|
|
74263
|
-
push("binary-discovery", "pass", `Found ${binary.path} (${binary.source}${versionNote}).`);
|
|
74264
|
-
} else {
|
|
74265
|
-
push("binary-discovery", "fail", params.binaryDiscovery.message);
|
|
74266
|
-
}
|
|
74267
|
-
if (params.claudeShim.state === void 0) {
|
|
74268
|
-
push("claude-shim", "pass", "No `claude` command shim enabled (the default). Run `agent-shim shim enable` to add one.");
|
|
74269
|
-
} else if (!params.claudeShim.targetExists) {
|
|
74270
|
-
push(
|
|
74271
|
-
"claude-shim",
|
|
74272
|
-
"warn",
|
|
74273
|
-
`claude-shim.json records a \`claude\` shim at ${params.claudeShim.state.targetPath}, but nothing is there. Run \`agent-shim shim enable\` again, or \`agent-shim shim disable\` to clear the stale record.`
|
|
74274
|
-
);
|
|
74275
|
-
} else {
|
|
74276
|
-
push(
|
|
74277
|
-
"claude-shim",
|
|
74278
|
-
"pass",
|
|
74279
|
-
`\`claude\` is enabled at ${params.claudeShim.state.targetPath} (${params.claudeShim.state.method}). If you've upgraded agent-shim since, re-run \`agent-shim shim enable\` to refresh it.`
|
|
74280
|
-
);
|
|
74281
|
-
}
|
|
74282
|
-
pushPathResolution(push, params.pathResolution);
|
|
74283
|
-
pushLegacyName(push, params);
|
|
74284
|
-
const profileSources = /* @__PURE__ */ new Map();
|
|
74285
|
-
for (const entry of params.configProfiles) {
|
|
74286
|
-
const validated2 = validateJson(ConfigProfileSchema, entry);
|
|
74287
|
-
if (!validated2.ok) {
|
|
74288
|
-
push("config-profile", "fail", validated2.message, entry.name);
|
|
74289
|
-
continue;
|
|
74290
|
-
}
|
|
74291
|
-
profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
|
|
74292
|
-
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
|
|
74293
|
-
}
|
|
74294
|
-
const loadProfile = (name) => profileSources.get(name);
|
|
74295
|
-
for (const name of profileSources.keys()) {
|
|
74296
|
-
const linearised = lineariseProfile(name, loadProfile);
|
|
74297
|
-
if (linearised.diagnostics.length === 0) {
|
|
74298
|
-
push("config-profile", "pass", `${name} is valid and its extends chain resolves cleanly.`, name);
|
|
74299
|
-
} else {
|
|
74300
|
-
for (const diagnostic of linearised.diagnostics) {
|
|
74301
|
-
push("config-profile", "fail", diagnostic.message, name);
|
|
74302
|
-
}
|
|
74303
|
-
}
|
|
74304
|
-
}
|
|
74305
|
-
const validProfileNames = new Set(profileSources.keys());
|
|
74306
|
-
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
74307
|
-
for (const entry of params.identities) {
|
|
74308
|
-
const validated2 = validateJson(IdentitySchema, entry);
|
|
74309
|
-
if (!validated2.ok) {
|
|
74310
|
-
push("identity", "fail", validated2.message, entry.name);
|
|
74311
|
-
continue;
|
|
74312
|
-
}
|
|
74313
|
-
validIdentityNames.add(entry.name);
|
|
74314
|
-
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
74315
|
-
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
74316
|
-
push(
|
|
74317
|
-
"identity",
|
|
74318
|
-
"fail",
|
|
74319
|
-
`Identity "${entry.name}" names configuration profile "${defaultProfile}" as its default, but no such profile exists.`,
|
|
74320
|
-
entry.name
|
|
74321
|
-
);
|
|
74322
|
-
} else {
|
|
74323
|
-
const credential = validated2.data.credential;
|
|
74324
|
-
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
74325
|
-
push(
|
|
74326
|
-
"identity",
|
|
74327
|
-
cache.unreadable ? "fail" : "pass",
|
|
74328
|
-
`${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
|
|
74329
|
-
entry.name
|
|
74330
|
-
);
|
|
74331
|
-
}
|
|
74332
|
-
}
|
|
74333
|
-
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
74334
|
-
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
74335
|
-
for (const [poolName, pool] of Object.entries(pools)) {
|
|
74336
|
-
const missing = pool.identities.filter((member) => !validIdentityNames.has(member));
|
|
74337
|
-
if (missing.length === 0) {
|
|
74338
|
-
push("pool", "pass", `${poolName} is valid (${pool.identities.join(", ")}).`, poolName);
|
|
74339
|
-
} else {
|
|
74340
|
-
push("pool", "fail", `Pool "${poolName}" names ${missing.map((member) => `identity "${member}"`).join(" and ")}, which ${missing.length === 1 ? "does" : "do"} not exist.`, poolName);
|
|
74341
|
-
}
|
|
74342
|
-
}
|
|
74343
|
-
const selectionExists = (selector) => {
|
|
74344
|
-
const poolName = poolNameOf(selector);
|
|
74345
|
-
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
74346
|
-
};
|
|
74347
|
-
for (const entry of params.providers) {
|
|
74348
|
-
pushProvider(push, entry, params.credentialCache);
|
|
74349
|
-
}
|
|
74350
|
-
if (params.platform !== "darwin" || params.run === void 0) {
|
|
74351
|
-
push("keychain", "pass", "Skipped (not macOS).");
|
|
74352
|
-
} else {
|
|
74353
|
-
for (const entry of params.identities) {
|
|
74354
|
-
const result = lookupKeychainService(params.run, entry.farmRoot);
|
|
74355
|
-
push("keychain", result.found ? "pass" : "warn", result.note, entry.name);
|
|
74356
|
-
}
|
|
74357
|
-
}
|
|
74358
|
-
if (params.directoryRules.raw === void 0) {
|
|
74359
|
-
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
74360
|
-
} else {
|
|
74361
|
-
const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
|
|
74362
|
-
if (!validated2.ok) {
|
|
74363
|
-
push("directory-rules", "fail", validated2.message);
|
|
74364
|
-
} else {
|
|
74365
|
-
push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
|
|
74366
|
-
for (const rule of validated2.data.rules) {
|
|
74367
|
-
const badRefs = [];
|
|
74368
|
-
if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
|
|
74369
|
-
badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
|
|
74370
|
-
}
|
|
74371
|
-
if (rule.configProfile !== void 0 && !validProfileNames.has(rule.configProfile)) {
|
|
74372
|
-
badRefs.push(`configuration profile "${rule.configProfile}"`);
|
|
74373
|
-
}
|
|
74374
|
-
checkPin("directory-rules", rule.path, `Rule for "${rule.path}"`, rule.launch?.claudeVersion);
|
|
74375
|
-
if (badRefs.length > 0) {
|
|
74376
|
-
push("directory-rules", "fail", `Rule for "${rule.path}" names ${badRefs.join(" and ")}, which do not exist.`, rule.path);
|
|
74377
|
-
} else {
|
|
74378
|
-
push("directory-rules", "pass", `Rule for "${rule.path}" is valid.`, rule.path);
|
|
74379
|
-
}
|
|
74380
|
-
}
|
|
74381
|
-
}
|
|
74382
|
-
}
|
|
74383
|
-
if (params.globalConfig.raw === void 0) {
|
|
74384
|
-
push("global-config", "pass", "No config.json configured.");
|
|
74385
|
-
} else {
|
|
74386
|
-
const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
|
|
74387
|
-
if (!validated2.ok) {
|
|
74388
|
-
push("global-config", "fail", validated2.message);
|
|
74389
|
-
} else {
|
|
74390
|
-
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
74391
|
-
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
74392
|
-
push(
|
|
74393
|
-
"global-config",
|
|
74394
|
-
"fail",
|
|
74395
|
-
`config.json names configuration profile "${defaultProfile}" as its default, but no such profile exists.`
|
|
74396
|
-
);
|
|
74397
|
-
} else {
|
|
74398
|
-
push("global-config", "pass", `${params.globalConfig.path} is valid.`);
|
|
74399
|
-
checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
|
|
74400
|
-
}
|
|
74401
|
-
}
|
|
74402
|
-
}
|
|
74403
|
-
if (params.categoriesLocal.raw === void 0) {
|
|
74404
|
-
push("categories-local", "pass", "No categories.local.json configured.");
|
|
74405
|
-
} else {
|
|
74406
|
-
const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
|
|
74407
|
-
push(
|
|
74408
|
-
"categories-local",
|
|
74409
|
-
validated2.ok ? "pass" : "fail",
|
|
74410
|
-
validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
|
|
74411
|
-
);
|
|
74412
|
-
}
|
|
74413
|
-
if (params.headroom.state.raw === void 0) {
|
|
74414
|
-
push("headroom", "pass", "No headroom daemon has ever run; nothing to check.");
|
|
74415
|
-
} else {
|
|
74416
|
-
const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
|
|
74417
|
-
if (!validated2.ok) {
|
|
74418
|
-
push("headroom", "fail", validated2.message);
|
|
74419
|
-
} else {
|
|
74420
|
-
const state = validated2.data;
|
|
74421
|
-
const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
|
|
74422
|
-
const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
|
|
74423
|
-
if (state.supervisorPid === void 0) {
|
|
74424
|
-
if (state.lastError === void 0) {
|
|
74425
|
-
push("headroom", "pass", "Headroom daemon is stopped (idle shutdown) with no recorded error.");
|
|
74426
|
-
} else {
|
|
74427
|
-
push("headroom", "warn", `Headroom supervisor is not running; last error: ${state.lastError}`);
|
|
74428
|
-
}
|
|
74429
|
-
} else if (!supervisorAlive) {
|
|
74430
|
-
push(
|
|
74431
|
-
"headroom",
|
|
74432
|
-
"warn",
|
|
74433
|
-
`Headroom state names supervisor pid ${String(state.supervisorPid)}, which is not running; the next launch through headroom will start a replacement.`
|
|
74434
|
-
);
|
|
74435
|
-
} else if (state.headroomPid === void 0 || state.socketPath === void 0) {
|
|
74436
|
-
push(
|
|
74437
|
-
"headroom",
|
|
74438
|
-
"warn",
|
|
74439
|
-
state.lastError === void 0 ? "Headroom supervisor is running but the daemon has no healthy process; it should be restarting it." : `Headroom supervisor is running but the daemon is down; last error: ${state.lastError}`
|
|
74440
|
-
);
|
|
74441
|
-
} else if (!headroomAlive) {
|
|
74442
|
-
push(
|
|
74443
|
-
"headroom",
|
|
74444
|
-
"warn",
|
|
74445
|
-
`Headroom state names daemon pid ${String(state.headroomPid)}, which is not running; its supervisor should be restarting it.`
|
|
74446
|
-
);
|
|
74447
|
-
} else {
|
|
74448
|
-
push(
|
|
74449
|
-
"headroom",
|
|
74450
|
-
"pass",
|
|
74451
|
-
`Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
|
|
74452
|
-
);
|
|
74453
|
-
}
|
|
74454
|
-
if (state.lastError !== void 0 && supervisorAlive) {
|
|
74455
|
-
push("headroom", "warn", `Headroom recorded a previous error: ${state.lastError}`);
|
|
74456
|
-
}
|
|
74457
|
-
if (state.installedSource !== void 0 && isMovingGitSource(state.installedSource)) {
|
|
74458
|
-
push(
|
|
74459
|
-
"headroom",
|
|
74460
|
-
"warn",
|
|
74461
|
-
`Headroom is installed from a git ref that can move (${state.installedSource}); pin headroom.source to a full commit SHA so a rebased or deleted branch cannot change or break the install.`
|
|
74462
|
-
);
|
|
74463
|
-
}
|
|
74464
|
-
}
|
|
74465
|
-
}
|
|
74466
|
-
if (params.activeIdentity.raw === void 0) {
|
|
74467
|
-
push("active-identity", "pass", "No active identity set.");
|
|
74468
|
-
} else {
|
|
74469
|
-
const trimmed = params.activeIdentity.raw.trim();
|
|
74470
|
-
if (trimmed === "") {
|
|
74471
|
-
push("active-identity", "warn", "active-identity is present but empty \u2014 treated the same as unset.");
|
|
74472
|
-
} else if (!selectionExists(trimmed)) {
|
|
74473
|
-
push("active-identity", "fail", `active-identity names "${trimmed}", which does not exist.`);
|
|
74474
|
-
} else {
|
|
74475
|
-
push("active-identity", "pass", `Active identity "${trimmed}" is valid.`);
|
|
74476
|
-
}
|
|
74477
|
-
}
|
|
74478
|
-
return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
|
|
74479
|
-
}
|
|
74480
|
-
var SECTION_TITLES = {
|
|
74481
|
-
"ambient-credential": "Ambient-credential exposure",
|
|
74482
|
-
"binary-discovery": "Claude Code binary discovery",
|
|
74483
|
-
"claude-shim": "`claude` command shim",
|
|
74484
|
-
"path-resolution": "PATH resolution",
|
|
74485
|
-
"legacy-name": "Former `claude-use` name",
|
|
74486
|
-
"config-profile": "Configuration profiles",
|
|
74487
|
-
identity: "Identities",
|
|
74488
|
-
pool: "Pools",
|
|
74489
|
-
provider: "Providers",
|
|
74490
|
-
keychain: "macOS Keychain",
|
|
74491
|
-
"directory-rules": "Directory rules",
|
|
74492
|
-
"global-config": "Global config",
|
|
74493
|
-
headroom: "Headroom daemon",
|
|
74494
|
-
"categories-local": "categories.local.json",
|
|
74495
|
-
"active-identity": "Active identity"
|
|
74496
|
-
};
|
|
74497
|
-
var SECTION_ORDER = [
|
|
74498
|
-
"ambient-credential",
|
|
74499
|
-
"binary-discovery",
|
|
74500
|
-
"claude-shim",
|
|
74501
|
-
"path-resolution",
|
|
74502
|
-
"config-profile",
|
|
74503
|
-
"identity",
|
|
74504
|
-
"pool",
|
|
74505
|
-
"provider",
|
|
74506
|
-
"keychain",
|
|
74507
|
-
"directory-rules",
|
|
74508
|
-
"global-config",
|
|
74509
|
-
"headroom",
|
|
74510
|
-
"categories-local",
|
|
74511
|
-
"active-identity"
|
|
74512
|
-
];
|
|
74513
|
-
function severityPrefix(severity) {
|
|
74514
|
-
switch (severity) {
|
|
74515
|
-
case "pass":
|
|
74516
|
-
return "[PASS]";
|
|
74517
|
-
case "warn":
|
|
74518
|
-
return "[WARN]";
|
|
74519
|
-
case "fail":
|
|
74520
|
-
return "[FAIL]";
|
|
74521
|
-
default:
|
|
74522
|
-
return severity;
|
|
74523
|
-
}
|
|
74524
|
-
}
|
|
74525
|
-
function formatDoctorReport(report) {
|
|
74526
|
-
const lines = [];
|
|
74527
|
-
for (const section of SECTION_ORDER) {
|
|
74528
|
-
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
74529
|
-
if (sectionFindings.length === 0) {
|
|
74530
|
-
continue;
|
|
74531
|
-
}
|
|
74532
|
-
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
74533
|
-
for (const finding of sectionFindings) {
|
|
74534
|
-
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
74535
|
-
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
74536
|
-
}
|
|
74537
|
-
}
|
|
74538
|
-
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
74539
|
-
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
74540
|
-
return lines;
|
|
74541
|
-
}
|
|
74542
|
-
function realpathOrSelf(target) {
|
|
74543
|
-
try {
|
|
74544
|
-
return import_node_fs14.default.realpathSync(target);
|
|
74545
|
-
} catch {
|
|
74546
|
-
return target;
|
|
74547
|
-
}
|
|
74548
|
-
}
|
|
74549
|
-
function collectDoctorReport(params) {
|
|
74550
|
-
const { paths } = params;
|
|
74551
|
-
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() : [];
|
|
74552
|
-
const identities = identityNames.map((name) => {
|
|
74553
|
-
const farmRoot = import_node_path36.default.join(paths.identitiesDir, name);
|
|
74554
|
-
const identityPath = import_node_path36.default.join(farmRoot, "identity.json");
|
|
74555
|
-
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
74556
|
-
});
|
|
74557
|
-
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() : [];
|
|
74558
|
-
const configProfiles = profileNames.map((name) => {
|
|
74559
|
-
const profilePath = import_node_path36.default.join(paths.configProfilesDir, `${name}.json`);
|
|
74560
|
-
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
74561
|
-
});
|
|
74562
|
-
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() : [];
|
|
74563
|
-
const providers = providerNames.map((name) => {
|
|
74564
|
-
const providerPath = import_node_path36.default.join(paths.providersDir, `${name}.json`);
|
|
74565
|
-
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
74566
|
-
});
|
|
74567
|
-
const ownExecutablePath = realOwnExecutablePath();
|
|
74568
|
-
let binaryDiscovery;
|
|
74569
|
-
try {
|
|
74570
|
-
const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
|
|
74571
|
-
binaryDiscovery = { ok: true, binary };
|
|
74572
|
-
} catch (error62) {
|
|
74573
|
-
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
74574
|
-
}
|
|
74575
|
-
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
74576
|
-
const pathDirs = (params.env.PATH ?? "").split(import_node_path36.default.delimiter).filter((dir) => dir !== "");
|
|
74577
|
-
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
74578
|
-
findPathShadow({
|
|
74579
|
-
pathDirs,
|
|
74580
|
-
targetDir: import_node_path36.default.dirname(shimState.targetPath),
|
|
74581
|
-
targetFilename: import_node_path36.default.basename(shimState.targetPath),
|
|
74582
|
-
findExecutableInDir
|
|
74583
|
-
}),
|
|
74584
|
-
shimState.targetPath,
|
|
74585
|
-
realpathOrSelf
|
|
74586
|
-
);
|
|
74587
|
-
const report = runDoctor({
|
|
74588
|
-
env: params.env,
|
|
74589
|
-
credentialCache: realCredentialCacheEnv(paths),
|
|
74590
|
-
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
74591
|
-
identities,
|
|
74592
|
-
configProfiles,
|
|
74593
|
-
providers,
|
|
74594
|
-
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
74595
|
-
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
74596
|
-
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
74597
|
-
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
74598
|
-
binaryDiscovery,
|
|
74599
|
-
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs14.default.existsSync(shimState.targetPath) },
|
|
74600
|
-
rootPath: paths.root,
|
|
74601
|
-
pathResolution: {
|
|
74602
|
-
ownExecutablePath,
|
|
74603
|
-
agentShim: refinePathShadow(
|
|
74604
|
-
findPathShadow({
|
|
74605
|
-
pathDirs,
|
|
74606
|
-
targetDir: import_node_path36.default.dirname(ownExecutablePath),
|
|
74607
|
-
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
74608
|
-
findExecutableInDir
|
|
74609
|
-
}),
|
|
74610
|
-
ownExecutablePath,
|
|
74611
|
-
realpathOrSelf
|
|
74612
|
-
),
|
|
74613
|
-
...claudeShimShadow === void 0 ? {} : { claude: claudeShimShadow }
|
|
74614
|
-
},
|
|
74615
|
-
run: realRunPort,
|
|
74616
|
-
platform: process.platform,
|
|
74617
|
-
headroom: {
|
|
74618
|
-
state: { path: paths.headroomStateFile, raw: realFsPort.readFileUtf8(paths.headroomStateFile) },
|
|
74619
|
-
isRunning: realIsProcessRunning
|
|
74620
|
-
}
|
|
74621
|
-
});
|
|
74622
|
-
return report;
|
|
74623
|
-
}
|
|
74624
|
-
|
|
74625
74979
|
// src/doctor.ts
|
|
74626
74980
|
function registerDoctorCommand(program2, deps) {
|
|
74627
74981
|
const { paths } = deps;
|
|
@@ -74646,7 +75000,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
74646
75000
|
// src/headroom/commands.ts
|
|
74647
75001
|
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
74648
75002
|
var import_node_http2 = __toESM(require("node:http"), 1);
|
|
74649
|
-
var
|
|
75003
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
74650
75004
|
var import_node_child_process5 = require("node:child_process");
|
|
74651
75005
|
|
|
74652
75006
|
// src/frontdoor/realFrontDoorPort.ts
|
|
@@ -74792,11 +75146,11 @@ function probeFrontDoorSync(port, caPem) {
|
|
|
74792
75146
|
|
|
74793
75147
|
// src/frontdoor/trust.ts
|
|
74794
75148
|
var import_node_crypto14 = require("node:crypto");
|
|
74795
|
-
var
|
|
75149
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
74796
75150
|
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
74797
75151
|
function resolveTrustBundle(params) {
|
|
74798
75152
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs19 } = params;
|
|
74799
|
-
if (inherited === void 0 || inherited === "" ||
|
|
75153
|
+
if (inherited === void 0 || inherited === "" || import_node_path38.default.resolve(inherited) === import_node_path38.default.resolve(caCertFile)) {
|
|
74800
75154
|
return { path: caCertFile };
|
|
74801
75155
|
}
|
|
74802
75156
|
const caPem = fs19.readFileUtf8(caCertFile);
|
|
@@ -74814,7 +75168,7 @@ function resolveTrustBundle(params) {
|
|
|
74814
75168
|
}
|
|
74815
75169
|
const combined = `${inheritedPem.trimEnd()}
|
|
74816
75170
|
${caPem}`;
|
|
74817
|
-
const bundle =
|
|
75171
|
+
const bundle = import_node_path38.default.join(bundlesDir, `${(0, import_node_crypto14.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
74818
75172
|
if (!fs19.exists(bundle)) {
|
|
74819
75173
|
fs19.mkdirp(bundlesDir);
|
|
74820
75174
|
fs19.writeFileAtomic(bundle, combined);
|
|
@@ -74972,12 +75326,12 @@ function readInstalledHeadroomCommit() {
|
|
|
74972
75326
|
if (toolDir.status !== 0) {
|
|
74973
75327
|
return void 0;
|
|
74974
75328
|
}
|
|
74975
|
-
const libDir =
|
|
75329
|
+
const libDir = import_node_path39.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
74976
75330
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
74977
|
-
const sitePackages =
|
|
75331
|
+
const sitePackages = import_node_path39.default.join(libDir, python, "site-packages");
|
|
74978
75332
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
74979
75333
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
74980
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
75334
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path39.default.join(sitePackages, entry, "direct_url.json"));
|
|
74981
75335
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
74982
75336
|
}
|
|
74983
75337
|
}
|
|
@@ -75784,7 +76138,7 @@ var import_node_crypto16 = require("node:crypto");
|
|
|
75784
76138
|
|
|
75785
76139
|
// src/launcher.ts
|
|
75786
76140
|
var import_node_crypto15 = require("node:crypto");
|
|
75787
|
-
var
|
|
76141
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
75788
76142
|
|
|
75789
76143
|
// src/launcher/cliOverride.ts
|
|
75790
76144
|
var InvalidCliCategoryError = class extends CliError {
|
|
@@ -75868,7 +76222,7 @@ function buildCliOverride(params) {
|
|
|
75868
76222
|
}
|
|
75869
76223
|
|
|
75870
76224
|
// src/launcher/flags.ts
|
|
75871
|
-
var
|
|
76225
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
75872
76226
|
|
|
75873
76227
|
// src/headroom/headers.ts
|
|
75874
76228
|
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
@@ -75938,7 +76292,7 @@ function buildEnv(params) {
|
|
|
75938
76292
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
75939
76293
|
let providerCustomHeaders;
|
|
75940
76294
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
75941
|
-
env.CLAUDE_CONFIG_DIR =
|
|
76295
|
+
env.CLAUDE_CONFIG_DIR = import_node_path40.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
75942
76296
|
}
|
|
75943
76297
|
if (params.provider !== void 0) {
|
|
75944
76298
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -76122,7 +76476,7 @@ function prepareLaunch(params) {
|
|
|
76122
76476
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
76123
76477
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
76124
76478
|
});
|
|
76125
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(
|
|
76479
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(import_node_path41.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
76126
76480
|
log.error(
|
|
76127
76481
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
76128
76482
|
);
|
|
@@ -76468,7 +76822,7 @@ async function runClaude(argvOverride) {
|
|
|
76468
76822
|
// src/cli.ts
|
|
76469
76823
|
async function main() {
|
|
76470
76824
|
aliasLegacyEnv(process.env);
|
|
76471
|
-
const invokedName =
|
|
76825
|
+
const invokedName = import_node_path42.default.basename(process.argv[1] ?? "agent-shim");
|
|
76472
76826
|
if (isInvokedAsClaude(invokedName)) {
|
|
76473
76827
|
await runClaude();
|
|
76474
76828
|
return;
|