agent-shim 8.14.0 → 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 +1144 -787
- package/dist/index.cjs +4654 -4223
- package/dist/index.mjs +4628 -4221
- package/dist/types/index.d.ts +2778 -1224
- 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"];
|
|
@@ -65063,6 +65098,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
65063
65098
|
...lastDirectPort === void 0 ? {} : { lastDirectPort }
|
|
65064
65099
|
});
|
|
65065
65100
|
const fail = (message) => {
|
|
65101
|
+
ports.closeRcStreamHub();
|
|
65066
65102
|
writeFrontDoorState(fs19, paths.frontdoorStateFile, { lastError: message, ...sticky() });
|
|
65067
65103
|
fs19.removeRecursive(paths.frontdoorLockFile);
|
|
65068
65104
|
ports.log(`agent-shim frontdoor supervisor: ${message}`);
|
|
@@ -65123,6 +65159,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
65123
65159
|
await direct.close();
|
|
65124
65160
|
await connect3.close();
|
|
65125
65161
|
await http6.close();
|
|
65162
|
+
ports.closeRcStreamHub();
|
|
65126
65163
|
writeFrontDoorState(fs19, paths.frontdoorStateFile, sticky());
|
|
65127
65164
|
return 0;
|
|
65128
65165
|
}
|
|
@@ -65176,8 +65213,8 @@ function parseConnectTarget(authority) {
|
|
|
65176
65213
|
}
|
|
65177
65214
|
return { host, port };
|
|
65178
65215
|
}
|
|
65179
|
-
function servedByPipeline(
|
|
65180
|
-
return
|
|
65216
|
+
function servedByPipeline(path44) {
|
|
65217
|
+
return path44?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
65181
65218
|
}
|
|
65182
65219
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
65183
65220
|
"connection",
|
|
@@ -65703,11 +65740,11 @@ function createRcSessionTracker(deps) {
|
|
|
65703
65740
|
};
|
|
65704
65741
|
const observeExchange = (request7) => {
|
|
65705
65742
|
const method = (request7.method ?? "").toUpperCase();
|
|
65706
|
-
const
|
|
65707
|
-
if (!
|
|
65743
|
+
const path44 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
65744
|
+
if (!path44.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
65708
65745
|
return void 0;
|
|
65709
65746
|
}
|
|
65710
|
-
const tail =
|
|
65747
|
+
const tail = path44.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
65711
65748
|
const facts = {
|
|
65712
65749
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
65713
65750
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -66447,9 +66484,9 @@ function sequenceNumsOfBody(body) {
|
|
|
66447
66484
|
}
|
|
66448
66485
|
function frontDoorRcControl(transport, token) {
|
|
66449
66486
|
const headers = { authorization: `Bearer ${token}` };
|
|
66450
|
-
const listAnswerOf = async (
|
|
66487
|
+
const listAnswerOf = async (path44, what) => {
|
|
66451
66488
|
try {
|
|
66452
|
-
return await transport.request({ method: "GET", path:
|
|
66489
|
+
return await transport.request({ method: "GET", path: path44, headers });
|
|
66453
66490
|
} catch (error62) {
|
|
66454
66491
|
throw new Error(`${what}: could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}`, { cause: error62 });
|
|
66455
66492
|
}
|
|
@@ -66521,10 +66558,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
66521
66558
|
}
|
|
66522
66559
|
return pending;
|
|
66523
66560
|
};
|
|
66524
|
-
const writeOf = async (
|
|
66561
|
+
const writeOf = async (path44, body, describeFailure) => {
|
|
66525
66562
|
let answer;
|
|
66526
66563
|
try {
|
|
66527
|
-
answer = await transport.request({ method: "POST", path:
|
|
66564
|
+
answer = await transport.request({ method: "POST", path: path44, headers: { ...headers, "content-type": "application/json" }, body });
|
|
66528
66565
|
} catch (error62) {
|
|
66529
66566
|
return { ok: false, message: `could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
66530
66567
|
}
|
|
@@ -66897,12 +66934,12 @@ function lateRcStreamDial(resolve) {
|
|
|
66897
66934
|
}
|
|
66898
66935
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
66899
66936
|
const agent = new ExemptTlsAgent();
|
|
66900
|
-
const request7 = async (method,
|
|
66937
|
+
const request7 = async (method, path44, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
66901
66938
|
const options = {
|
|
66902
66939
|
host: target.host,
|
|
66903
66940
|
port: target.port,
|
|
66904
66941
|
method,
|
|
66905
|
-
path:
|
|
66942
|
+
path: path44,
|
|
66906
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.
|
|
66907
66944
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
66908
66945
|
agent,
|
|
@@ -66939,9 +66976,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
66939
66976
|
return { status, body: await readAll(response) };
|
|
66940
66977
|
},
|
|
66941
66978
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
66942
|
-
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)}`;
|
|
66943
66980
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
66944
|
-
const { status, response } = await request7("GET",
|
|
66981
|
+
const { status, response } = await request7("GET", path44, streamHeaders, void 0, signal);
|
|
66945
66982
|
if (!isSuccessful2(status)) {
|
|
66946
66983
|
await readAll(response);
|
|
66947
66984
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -67152,6 +67189,527 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
67152
67189
|
};
|
|
67153
67190
|
}
|
|
67154
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
|
+
|
|
67155
67713
|
// node_modules/.pnpm/radash@12.1.1/node_modules/radash/dist/esm/async.mjs
|
|
67156
67714
|
var guard = (func, shouldGuard) => {
|
|
67157
67715
|
const _guard = (err) => {
|
|
@@ -68064,9 +68622,9 @@ function resolveFriendlyClientOptions(options) {
|
|
|
68064
68622
|
};
|
|
68065
68623
|
}
|
|
68066
68624
|
function createORPCClient(link, options = {}) {
|
|
68067
|
-
const
|
|
68625
|
+
const path44 = options.path ?? [];
|
|
68068
68626
|
const procedureClient = async (...[input2, options2 = {}]) => {
|
|
68069
|
-
return await link.call(
|
|
68627
|
+
return await link.call(path44, input2, resolveFriendlyClientOptions(options2));
|
|
68070
68628
|
};
|
|
68071
68629
|
const recursive2 = new Proxy(procedureClient, {
|
|
68072
68630
|
get(target, key) {
|
|
@@ -68075,13 +68633,243 @@ function createORPCClient(link, options = {}) {
|
|
|
68075
68633
|
}
|
|
68076
68634
|
return createORPCClient(link, {
|
|
68077
68635
|
...options,
|
|
68078
|
-
path: [...
|
|
68636
|
+
path: [...path44, key]
|
|
68079
68637
|
});
|
|
68080
68638
|
}
|
|
68081
68639
|
});
|
|
68082
68640
|
return preventNativeAwait(recursive2);
|
|
68083
68641
|
}
|
|
68084
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
|
+
|
|
68085
68873
|
// node_modules/.pnpm/@orpc+standard-server-fetch@1.15.4/node_modules/@orpc/standard-server-fetch/dist/index.mjs
|
|
68086
68874
|
function toEventIterator(stream, options = {}) {
|
|
68087
68875
|
const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
@@ -68377,19 +69165,19 @@ var StandardLink = class {
|
|
|
68377
69165
|
}
|
|
68378
69166
|
interceptors;
|
|
68379
69167
|
clientInterceptors;
|
|
68380
|
-
call(
|
|
69168
|
+
call(path44, input2, options) {
|
|
68381
69169
|
return runWithSpan(
|
|
68382
|
-
{ name: `${ORPC_NAME}.${
|
|
69170
|
+
{ name: `${ORPC_NAME}.${path44.join("/")}`, signal: options.signal },
|
|
68383
69171
|
(span) => {
|
|
68384
69172
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
68385
|
-
span?.setAttribute("rpc.method",
|
|
69173
|
+
span?.setAttribute("rpc.method", path44.join("."));
|
|
68386
69174
|
if (isAsyncIteratorObject(input2)) {
|
|
68387
69175
|
input2 = asyncIteratorWithSpan(
|
|
68388
69176
|
{ name: "consume_event_iterator_input", signal: options.signal },
|
|
68389
69177
|
input2
|
|
68390
69178
|
);
|
|
68391
69179
|
}
|
|
68392
|
-
return intercept(this.interceptors, { ...options, path:
|
|
69180
|
+
return intercept(this.interceptors, { ...options, path: path44, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
68393
69181
|
const otelConfig = getGlobalOtelConfig();
|
|
68394
69182
|
let otelContext;
|
|
68395
69183
|
const currentSpan = otelConfig?.trace.getActiveSpan() ?? span;
|
|
@@ -68624,8 +69412,8 @@ var StandardRPCJsonSerializer = class {
|
|
|
68624
69412
|
return ref.data;
|
|
68625
69413
|
}
|
|
68626
69414
|
};
|
|
68627
|
-
function toHttpPath(
|
|
68628
|
-
return `/${
|
|
69415
|
+
function toHttpPath(path44) {
|
|
69416
|
+
return `/${path44.map(encodeURIComponent).join("/")}`;
|
|
68629
69417
|
}
|
|
68630
69418
|
function toStandardHeaders2(headers) {
|
|
68631
69419
|
if (typeof headers.forEach === "function") {
|
|
@@ -68650,18 +69438,18 @@ var StandardRPCLinkCodec = class {
|
|
|
68650
69438
|
fallbackMethod;
|
|
68651
69439
|
expectedMethod;
|
|
68652
69440
|
headers;
|
|
68653
|
-
async encode(
|
|
68654
|
-
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));
|
|
68655
69443
|
if (options.lastEventId !== void 0) {
|
|
68656
69444
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
68657
69445
|
}
|
|
68658
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
68659
|
-
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);
|
|
68660
69448
|
const url2 = new URL(baseUrl);
|
|
68661
|
-
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(
|
|
69449
|
+
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(path44)}`;
|
|
68662
69450
|
const serialized = this.serializer.serialize(input2);
|
|
68663
69451
|
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
68664
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
69452
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path44, input2);
|
|
68665
69453
|
const getUrl = new URL(url2);
|
|
68666
69454
|
getUrl.searchParams.append("data", stringifyJSON(serialized));
|
|
68667
69455
|
if (getUrl.toString().length <= maxUrlLength) {
|
|
@@ -68812,11 +69600,11 @@ var LinkFetchClient = class {
|
|
|
68812
69600
|
this.toFetchRequestOptions = options;
|
|
68813
69601
|
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
68814
69602
|
}
|
|
68815
|
-
async call(standardRequest, options,
|
|
69603
|
+
async call(standardRequest, options, path44, input2) {
|
|
68816
69604
|
const request7 = toFetchRequest(standardRequest, this.toFetchRequestOptions);
|
|
68817
69605
|
const fetchResponse = await intercept(
|
|
68818
69606
|
this.adapterInterceptors,
|
|
68819
|
-
{ ...options, request: request7, path:
|
|
69607
|
+
{ ...options, request: request7, path: path44, input: input2, init: { redirect: "manual" } },
|
|
68820
69608
|
({ request: request22, path: path210, input: input22, init, ...options2 }) => this.fetch(request22, init, options2, path210, input22)
|
|
68821
69609
|
);
|
|
68822
69610
|
const lazyResponse = toStandardLazyResponse(fetchResponse, { signal: request7.signal });
|
|
@@ -69216,7 +70004,7 @@ function middlewareOutputFn(output2) {
|
|
|
69216
70004
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
69217
70005
|
const options = resolveMaybeOptionalOptions(rest);
|
|
69218
70006
|
return async (...[input2, callerOptions]) => {
|
|
69219
|
-
const
|
|
70007
|
+
const path44 = toArray(options.path);
|
|
69220
70008
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
69221
70009
|
const clientContext = callerOptions?.context ?? {};
|
|
69222
70010
|
const context = await value(options.context ?? {}, clientContext);
|
|
@@ -69231,7 +70019,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69231
70019
|
const output2 = await runWithSpan(
|
|
69232
70020
|
{ name: "call_procedure", signal: callerOptions?.signal },
|
|
69233
70021
|
(span) => {
|
|
69234
|
-
span?.setAttribute("procedure.path", [...
|
|
70022
|
+
span?.setAttribute("procedure.path", [...path44]);
|
|
69235
70023
|
return intercept(
|
|
69236
70024
|
toArray(options.interceptors),
|
|
69237
70025
|
{
|
|
@@ -69239,7 +70027,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69239
70027
|
input: input2,
|
|
69240
70028
|
// input only optional when it undefinable so we can safely cast it
|
|
69241
70029
|
errors,
|
|
69242
|
-
path:
|
|
70030
|
+
path: path44,
|
|
69243
70031
|
procedure,
|
|
69244
70032
|
signal: callerOptions?.signal,
|
|
69245
70033
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -69361,10 +70149,10 @@ var HIDDEN_ROUTER_CONTRACT_SYMBOL = /* @__PURE__ */ Symbol("ORPC_HIDDEN_ROUTER_C
|
|
|
69361
70149
|
function getHiddenRouterContract(router) {
|
|
69362
70150
|
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
69363
70151
|
}
|
|
69364
|
-
function getRouter(router,
|
|
70152
|
+
function getRouter(router, path44) {
|
|
69365
70153
|
let current = router;
|
|
69366
|
-
for (let i2 = 0; i2 <
|
|
69367
|
-
const segment =
|
|
70154
|
+
for (let i2 = 0; i2 < path44.length; i2++) {
|
|
70155
|
+
const segment = path44[i2];
|
|
69368
70156
|
if (!current) {
|
|
69369
70157
|
return void 0;
|
|
69370
70158
|
}
|
|
@@ -69379,7 +70167,7 @@ function getRouter(router, path43) {
|
|
|
69379
70167
|
continue;
|
|
69380
70168
|
}
|
|
69381
70169
|
const lazied = current;
|
|
69382
|
-
const rest =
|
|
70170
|
+
const rest = path44.slice(i2);
|
|
69383
70171
|
return lazy2(async () => {
|
|
69384
70172
|
const unwrapped = await unlazy(lazied);
|
|
69385
70173
|
const next = getRouter(unwrapped.default, rest);
|
|
@@ -69957,8 +70745,8 @@ function toAbortSignal(stream) {
|
|
|
69957
70745
|
function toStandardUrl(req) {
|
|
69958
70746
|
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
|
69959
70747
|
const origin = guard(() => new URL(`${protocol}//${req.headers.host ?? "localhost"}`).origin) ?? `${protocol}//localhost`;
|
|
69960
|
-
const
|
|
69961
|
-
return new URL(`${origin}${
|
|
70748
|
+
const path44 = req.originalUrl ?? req.url ?? "/";
|
|
70749
|
+
return new URL(`${origin}${path44.startsWith("/") ? "" : "/"}${path44}`);
|
|
69962
70750
|
}
|
|
69963
70751
|
function toStandardLazyRequest(req, res) {
|
|
69964
70752
|
const signal = toAbortSignal(res);
|
|
@@ -70157,8 +70945,8 @@ var StandardRPCMatcher = class {
|
|
|
70157
70945
|
constructor(options = {}) {
|
|
70158
70946
|
this.filter = options.filter ?? true;
|
|
70159
70947
|
}
|
|
70160
|
-
init(router,
|
|
70161
|
-
const laziedOptions = traverseContractProcedures({ router, path:
|
|
70948
|
+
init(router, path44 = []) {
|
|
70949
|
+
const laziedOptions = traverseContractProcedures({ router, path: path44 }, (traverseOptions) => {
|
|
70162
70950
|
if (!value(this.filter, traverseOptions)) {
|
|
70163
70951
|
return;
|
|
70164
70952
|
}
|
|
@@ -70436,16 +71224,19 @@ var RcAnswerOutputSchema = external_exports.strictObject({
|
|
|
70436
71224
|
// src/frontdoor/rcApi.ts
|
|
70437
71225
|
var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
|
|
70438
71226
|
var RC_SUBSCRIBER_BUFFER_EVENTS = 100;
|
|
70439
|
-
function
|
|
70440
|
-
|
|
71227
|
+
function doorApiAuth(expectedToken) {
|
|
71228
|
+
return os7.$context().use(({ context, next }) => {
|
|
70441
71229
|
const presented = context.headers.authorization;
|
|
70442
71230
|
const bearerPrefix = "bearer ".length;
|
|
70443
71231
|
const token = typeof presented === "string" && presented.slice(0, bearerPrefix).toLowerCase() === "bearer " ? presented.slice(bearerPrefix) : void 0;
|
|
70444
|
-
if (token === void 0 || !isLiveCapability(token, [
|
|
71232
|
+
if (token === void 0 || !isLiveCapability(token, [expectedToken])) {
|
|
70445
71233
|
throw new ORPCError("UNAUTHORIZED", { message: "the front door's typed API demands this generation's control token as a Bearer credential" });
|
|
70446
71234
|
}
|
|
70447
71235
|
return next();
|
|
70448
71236
|
});
|
|
71237
|
+
}
|
|
71238
|
+
function createRcApiRouter(deps) {
|
|
71239
|
+
const authed = doorApiAuth(deps.expectedToken);
|
|
70449
71240
|
const delivered = (sessionId, result) => {
|
|
70450
71241
|
if (!result.ok) {
|
|
70451
71242
|
throw new ORPCError("BAD_GATEWAY", { message: result.message });
|
|
@@ -70514,16 +71305,16 @@ function createRcApiRouter(deps) {
|
|
|
70514
71305
|
}
|
|
70515
71306
|
};
|
|
70516
71307
|
}
|
|
70517
|
-
function
|
|
70518
|
-
const handler = new RPCHandler(
|
|
71308
|
+
function doorApiNodeHandlerOf(router) {
|
|
71309
|
+
const handler = new RPCHandler(router, { plugins: [new BodyLimitPlugin({ maxBodySize: CONTROL_BODY_CAP_BYTES })] });
|
|
70519
71310
|
return {
|
|
70520
71311
|
pathPrefix: RC_ORPC_PATH_PREFIX,
|
|
70521
71312
|
handle: async (request7, response) => await handler.handle(request7, response, { context: { headers: request7.headers }, prefix: RC_ORPC_PATH_PREFIX })
|
|
70522
71313
|
};
|
|
70523
71314
|
}
|
|
70524
|
-
function
|
|
71315
|
+
function frontDoorApiLink(port, ca, token) {
|
|
70525
71316
|
const dispatcher = new import_undici2.Agent({ connect: { ca } });
|
|
70526
|
-
|
|
71317
|
+
return new RPCLink({
|
|
70527
71318
|
url: `https://127.0.0.1:${String(port)}${RC_ORPC_PATH_PREFIX}`,
|
|
70528
71319
|
headers: { authorization: `Bearer ${token}` },
|
|
70529
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.
|
|
@@ -70539,7 +71330,53 @@ function frontDoorRcApiClient(port, ca, token) {
|
|
|
70539
71330
|
return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
|
|
70540
71331
|
}
|
|
70541
71332
|
});
|
|
70542
|
-
|
|
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));
|
|
70543
71380
|
}
|
|
70544
71381
|
|
|
70545
71382
|
// src/frontdoor/headroomHop.ts
|
|
@@ -71620,8 +72457,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
71620
72457
|
request7.body.resume();
|
|
71621
72458
|
return;
|
|
71622
72459
|
}
|
|
71623
|
-
const
|
|
71624
|
-
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 };
|
|
71625
72462
|
const routed = await route(translated);
|
|
71626
72463
|
if (request7.signal.aborted) {
|
|
71627
72464
|
return;
|
|
@@ -71655,7 +72492,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71655
72492
|
headroomUpstream: target.headroomUpstream,
|
|
71656
72493
|
serve: async (request7, response) => {
|
|
71657
72494
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
71658
|
-
const
|
|
72495
|
+
const path44 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
71659
72496
|
const headers = forwardableHeaders(request7.headers);
|
|
71660
72497
|
delete headers.host;
|
|
71661
72498
|
await new Promise((resolve) => {
|
|
@@ -71663,7 +72500,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71663
72500
|
host: base.hostname,
|
|
71664
72501
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
71665
72502
|
method: request7.method,
|
|
71666
|
-
path: `${basePath}${
|
|
72503
|
+
path: `${basePath}${path44}${incoming.search}`,
|
|
71667
72504
|
headers,
|
|
71668
72505
|
agent
|
|
71669
72506
|
};
|
|
@@ -71712,7 +72549,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71712
72549
|
|
|
71713
72550
|
// src/frontdoor/providerRoute.ts
|
|
71714
72551
|
function createProviderRouteResolver(deps) {
|
|
71715
|
-
const isRcSelfHostPath = (
|
|
72552
|
+
const isRcSelfHostPath = (path44) => path44 === "/v1/code/sessions" || path44.startsWith("/v1/code/sessions/") || path44 === "/v1/sessions" || path44.startsWith("/v1/sessions/");
|
|
71716
72553
|
const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
|
|
71717
72554
|
const passthroughByTarget = /* @__PURE__ */ new Map();
|
|
71718
72555
|
const passthroughFor = (name, target) => {
|
|
@@ -71726,13 +72563,13 @@ function createProviderRouteResolver(deps) {
|
|
|
71726
72563
|
return route;
|
|
71727
72564
|
};
|
|
71728
72565
|
const resolve = (request7) => {
|
|
71729
|
-
const
|
|
71730
|
-
const scoped = parseProviderPath(
|
|
72566
|
+
const path44 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
72567
|
+
const scoped = parseProviderPath(path44);
|
|
71731
72568
|
if (scoped === void 0) {
|
|
71732
|
-
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(
|
|
72569
|
+
if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path44)) {
|
|
71733
72570
|
return { ok: true, route: deps.rcSelfHostRoute };
|
|
71734
72571
|
}
|
|
71735
|
-
return
|
|
72572
|
+
return path44.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path44}` };
|
|
71736
72573
|
}
|
|
71737
72574
|
const { provider } = scoped;
|
|
71738
72575
|
let definition;
|
|
@@ -71772,7 +72609,7 @@ function createProviderRouteResolver(deps) {
|
|
|
71772
72609
|
}
|
|
71773
72610
|
|
|
71774
72611
|
// src/frontdoor/rcCredentialStore.ts
|
|
71775
|
-
var
|
|
72612
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
71776
72613
|
function isSafeSessionId(sessionId) {
|
|
71777
72614
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
71778
72615
|
}
|
|
@@ -71798,7 +72635,7 @@ function sequenceNumOfJson(value2) {
|
|
|
71798
72635
|
}
|
|
71799
72636
|
function createRcCredentialStore(fs19, dir) {
|
|
71800
72637
|
fs19.mkdirPrivate(dir);
|
|
71801
|
-
const fileFor = (sessionId) =>
|
|
72638
|
+
const fileFor = (sessionId) => import_node_path34.default.join(dir, `${sessionId}.json`);
|
|
71802
72639
|
const readParsed = (sessionId) => {
|
|
71803
72640
|
const raw = fs19.readFileUtf8(fileFor(sessionId));
|
|
71804
72641
|
if (raw === void 0) {
|
|
@@ -72448,7 +73285,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
72448
73285
|
}
|
|
72449
73286
|
|
|
72450
73287
|
// src/frontdoor/rcSelfHostMint.ts
|
|
72451
|
-
var
|
|
73288
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
72452
73289
|
var CREDENTIALS_FILE = ".credentials.json";
|
|
72453
73290
|
var CLAUDE_JSON2 = ".claude.json";
|
|
72454
73291
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -72472,7 +73309,7 @@ function readJsonObject(fs19, file2) {
|
|
|
72472
73309
|
return isRecord6(parsed) ? parsed : void 0;
|
|
72473
73310
|
}
|
|
72474
73311
|
function readRcSelfHostRecord(fs19, frontdoorDir) {
|
|
72475
|
-
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));
|
|
72476
73313
|
if (parsed === void 0) {
|
|
72477
73314
|
return void 0;
|
|
72478
73315
|
}
|
|
@@ -72486,11 +73323,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
72486
73323
|
if (!isIdentityName(deps.identity)) {
|
|
72487
73324
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
72488
73325
|
}
|
|
72489
|
-
const identityDir =
|
|
72490
|
-
const credentialsFile =
|
|
72491
|
-
const claudeJsonFile =
|
|
72492
|
-
const recordDir =
|
|
72493
|
-
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);
|
|
72494
73331
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
72495
73332
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
72496
73333
|
const existingOauth = isRecord6(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -72506,7 +73343,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
72506
73343
|
const organizationUuid = deps.newUuid();
|
|
72507
73344
|
const accountUuid = deps.newUuid();
|
|
72508
73345
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
72509
|
-
deps.fs.mkdirPrivate(
|
|
73346
|
+
deps.fs.mkdirPrivate(import_node_path35.default.dirname(credentialsFile));
|
|
72510
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)}
|
|
72511
73348
|
`);
|
|
72512
73349
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -72818,6 +73655,59 @@ function createRcStreamHub(deps) {
|
|
|
72818
73655
|
};
|
|
72819
73656
|
}
|
|
72820
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
|
+
|
|
72821
73711
|
// src/usage/providerQuota.ts
|
|
72822
73712
|
var ProviderQuotaError = class extends Error {
|
|
72823
73713
|
constructor(source, detail) {
|
|
@@ -73101,15 +73991,11 @@ function createRealQuotaRefresher(params) {
|
|
|
73101
73991
|
|
|
73102
73992
|
// src/frontdoor/commands.ts
|
|
73103
73993
|
function appendLog(paths, line) {
|
|
73104
|
-
|
|
73105
|
-
|
|
73994
|
+
import_node_fs13.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
73995
|
+
import_node_fs13.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
73106
73996
|
`);
|
|
73107
73997
|
}
|
|
73108
73998
|
var MINTED_TOKEN_RANDOM_BYTES = 32;
|
|
73109
|
-
function headroomSocketTarget(fsPort, trust, paths) {
|
|
73110
|
-
const socketPath = readHeadroomState(fsPort, paths.headroomStateFile)?.socketPath;
|
|
73111
|
-
return socketPath === void 0 ? void 0 : verifyHeadroomSocket(socketPath, trust);
|
|
73112
|
-
}
|
|
73113
73999
|
function rcObservingResolver(resolve, tracker, hub) {
|
|
73114
74000
|
return async (request7) => {
|
|
73115
74001
|
const resolution = await resolve(request7);
|
|
@@ -73229,6 +74115,14 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73229
74115
|
const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
|
|
73230
74116
|
const rcSetModel = async (sessionId, model) => await setRcSessionModel(rcControlRequestDeps, sessionId, model);
|
|
73231
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
|
+
};
|
|
73232
74126
|
realFarmFs.mkdirp(paths.frontdoorDir);
|
|
73233
74127
|
realFarmFs.writeFilePrivate(paths.frontdoorControlTokenFile, `${rcControlToken}
|
|
73234
74128
|
`);
|
|
@@ -73239,7 +74133,19 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73239
74133
|
log,
|
|
73240
74134
|
mintLeaf(authority, LOOPBACK_LEAF_NAMES, /* @__PURE__ */ new Date()),
|
|
73241
74135
|
createRcControlHandler({ expectedToken: rcControlToken, list: rcTracker.list, statusOf: rcTracker.statusOf, pendingOf: rcTracker.pendingOf, inject: rcInject, answer: rcAnswer, interrupt: rcInterrupt, setModel: rcSetModel, setPermissionMode: rcSetPermissionMode }),
|
|
73242
|
-
|
|
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
|
+
})
|
|
73243
74149
|
);
|
|
73244
74150
|
const handle = await listenFrontDoor(server, { ...preferredPort === void 0 ? {} : { preferredPort }, ca: authority.certPem, onError: onListenerError("provider") });
|
|
73245
74151
|
return {
|
|
@@ -73259,7 +74165,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73259
74165
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
73260
74166
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
73261
74167
|
if (capture !== void 0) {
|
|
73262
|
-
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")}`);
|
|
73263
74169
|
}
|
|
73264
74170
|
if (rcSelfHostSurface !== void 0) {
|
|
73265
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");
|
|
@@ -73324,58 +74230,12 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
73324
74230
|
});
|
|
73325
74231
|
return { port: handle.port, close: handle.close };
|
|
73326
74232
|
},
|
|
74233
|
+
closeRcStreamHub: rcHub.close,
|
|
73327
74234
|
log: (line) => {
|
|
73328
74235
|
appendLog(paths, line);
|
|
73329
74236
|
}
|
|
73330
74237
|
};
|
|
73331
74238
|
}
|
|
73332
|
-
function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
|
|
73333
|
-
const state = readFrontDoorState(fsPort, paths.frontdoorStateFile) ?? {};
|
|
73334
|
-
return {
|
|
73335
|
-
state,
|
|
73336
|
-
supervisorAlive: state.supervisorPid !== void 0 && isRunning(state.supervisorPid),
|
|
73337
|
-
sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
|
|
73338
|
-
headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
|
|
73339
|
-
logPath: paths.frontdoorLogPath,
|
|
73340
|
-
logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
|
|
73341
|
-
};
|
|
73342
|
-
}
|
|
73343
|
-
function formatFrontDoorStatus(status, caCertPath) {
|
|
73344
|
-
const lines = [];
|
|
73345
|
-
if (status.state.supervisorPid === void 0) {
|
|
73346
|
-
lines.push("supervisor: not running");
|
|
73347
|
-
} else {
|
|
73348
|
-
lines.push(`supervisor: pid ${String(status.state.supervisorPid)} (${status.supervisorAlive ? "alive" : "NOT running"})`);
|
|
73349
|
-
}
|
|
73350
|
-
if (status.state.port === void 0) {
|
|
73351
|
-
lines.push(`front door: not listening${status.state.lastPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastPort)})`}`);
|
|
73352
|
-
} else {
|
|
73353
|
-
lines.push(`front door: listening on https://127.0.0.1:${String(status.state.port)}, routing /providers/<name> requests`);
|
|
73354
|
-
}
|
|
73355
|
-
if (status.state.connectPort === void 0) {
|
|
73356
|
-
lines.push(`connect surface: not listening${status.state.lastConnectPort === void 0 ? "" : ` (next start on 127.0.0.1:${String(status.state.lastConnectPort)})`}`);
|
|
73357
|
-
} else {
|
|
73358
|
-
lines.push(`connect surface: listening on 127.0.0.1:${String(status.state.connectPort)}, CA ${caCertPath}`);
|
|
73359
|
-
}
|
|
73360
|
-
if (status.headroomSocket === void 0) {
|
|
73361
|
-
lines.push("headroom hop: the daemon is not serving (sessions asking for headroom fail until it is up)");
|
|
73362
|
-
} else if (status.headroomSocket.refused === void 0) {
|
|
73363
|
-
lines.push(`headroom hop: daemon on unix socket ${status.headroomSocket.socketPath}`);
|
|
73364
|
-
} else {
|
|
73365
|
-
lines.push(`headroom hop: REFUSING the daemon's socket (sessions asking for headroom fail until it is fixed): ${status.headroomSocket.refused}`);
|
|
73366
|
-
}
|
|
73367
|
-
if (status.sessions.length === 0) {
|
|
73368
|
-
lines.push("sessions: none");
|
|
73369
|
-
} else {
|
|
73370
|
-
const pids = status.sessions.map((session) => `${String(session.pid)}${session.alive ? "" : " (dead)"}`);
|
|
73371
|
-
lines.push(`sessions: ${String(status.sessions.length)} registered (${pids.join(", ")})`);
|
|
73372
|
-
}
|
|
73373
|
-
if (status.state.lastError !== void 0) {
|
|
73374
|
-
lines.push(`last error: ${status.state.lastError}`);
|
|
73375
|
-
}
|
|
73376
|
-
lines.push(`daemon log: ${status.logPath}${status.logExists ? "" : " (not created yet)"}`);
|
|
73377
|
-
return lines;
|
|
73378
|
-
}
|
|
73379
74239
|
function formatRcSessionList(sessions) {
|
|
73380
74240
|
if (sessions.length === 0) {
|
|
73381
74241
|
return ["no Remote Control sessions observed"];
|
|
@@ -73959,16 +74819,16 @@ function registerCompletionCommand(program2) {
|
|
|
73959
74819
|
var import_node_child_process4 = require("node:child_process");
|
|
73960
74820
|
|
|
73961
74821
|
// src/identityToken.ts
|
|
73962
|
-
var
|
|
73963
|
-
var
|
|
74822
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
74823
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
73964
74824
|
var TOKEN_FILE_MODE = 384;
|
|
73965
74825
|
var TOKEN_DIR_MODE = 448;
|
|
73966
74826
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
73967
74827
|
function identityTokenDir(paths) {
|
|
73968
|
-
return
|
|
74828
|
+
return import_node_path37.default.join(paths.root, "credentials");
|
|
73969
74829
|
}
|
|
73970
74830
|
function identityTokenPath(paths, identityName) {
|
|
73971
|
-
return
|
|
74831
|
+
return import_node_path37.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
73972
74832
|
}
|
|
73973
74833
|
function storeIdentityToken(paths, identityName, raw) {
|
|
73974
74834
|
const token = raw.trim();
|
|
@@ -73976,13 +74836,13 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
73976
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.");
|
|
73977
74837
|
}
|
|
73978
74838
|
const dir = identityTokenDir(paths);
|
|
73979
|
-
|
|
73980
|
-
|
|
74839
|
+
import_node_fs14.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
74840
|
+
import_node_fs14.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
73981
74841
|
const target = identityTokenPath(paths, identityName);
|
|
73982
|
-
const temp =
|
|
73983
|
-
|
|
74842
|
+
const temp = import_node_path37.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
74843
|
+
import_node_fs14.default.writeFileSync(temp, `${token}
|
|
73984
74844
|
`, { mode: TOKEN_FILE_MODE });
|
|
73985
|
-
|
|
74845
|
+
import_node_fs14.default.renameSync(temp, target);
|
|
73986
74846
|
return target;
|
|
73987
74847
|
}
|
|
73988
74848
|
|
|
@@ -74116,509 +74976,6 @@ function subjectName(positional, provider) {
|
|
|
74116
74976
|
return name;
|
|
74117
74977
|
}
|
|
74118
74978
|
|
|
74119
|
-
// src/doctorReport.ts
|
|
74120
|
-
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
74121
|
-
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
74122
|
-
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
74123
|
-
if (status.status !== "shadowed") {
|
|
74124
|
-
return status;
|
|
74125
|
-
}
|
|
74126
|
-
return realpath(status.by) === realpath(ownExecutablePath) ? { status: "ok" } : status;
|
|
74127
|
-
}
|
|
74128
|
-
function validateJson(schema, input2) {
|
|
74129
|
-
if (input2.raw === void 0) {
|
|
74130
|
-
return { ok: false, message: `${input2.path} is missing.` };
|
|
74131
|
-
}
|
|
74132
|
-
let parsed;
|
|
74133
|
-
try {
|
|
74134
|
-
parsed = JSON.parse(input2.raw);
|
|
74135
|
-
} catch (error62) {
|
|
74136
|
-
return { ok: false, message: `${input2.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
74137
|
-
}
|
|
74138
|
-
const result = schema.safeParse(parsed);
|
|
74139
|
-
if (!result.success) {
|
|
74140
|
-
return { ok: false, message: new ConfigValidationError(input2.path, result.error.issues).message };
|
|
74141
|
-
}
|
|
74142
|
-
return { ok: true, data: result.data };
|
|
74143
|
-
}
|
|
74144
|
-
function pushPathResolution(push, resolution) {
|
|
74145
|
-
const ownDir = import_node_path36.default.dirname(resolution.ownExecutablePath);
|
|
74146
|
-
switch (resolution.agentShim.status) {
|
|
74147
|
-
case "ok":
|
|
74148
|
-
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
74149
|
-
break;
|
|
74150
|
-
case "not-on-path":
|
|
74151
|
-
push(
|
|
74152
|
-
"path-resolution",
|
|
74153
|
-
"warn",
|
|
74154
|
-
`${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.`,
|
|
74155
|
-
"agent-shim"
|
|
74156
|
-
);
|
|
74157
|
-
break;
|
|
74158
|
-
case "shadowed":
|
|
74159
|
-
push(
|
|
74160
|
-
"path-resolution",
|
|
74161
|
-
"fail",
|
|
74162
|
-
`\`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.`,
|
|
74163
|
-
"agent-shim"
|
|
74164
|
-
);
|
|
74165
|
-
break;
|
|
74166
|
-
}
|
|
74167
|
-
if (resolution.claude === void 0) {
|
|
74168
|
-
return;
|
|
74169
|
-
}
|
|
74170
|
-
switch (resolution.claude.status) {
|
|
74171
|
-
case "ok":
|
|
74172
|
-
push("path-resolution", "pass", "`claude` on PATH resolves to the enabled shim.", "claude");
|
|
74173
|
-
break;
|
|
74174
|
-
case "not-on-path":
|
|
74175
|
-
push("path-resolution", "warn", "The enabled `claude` shim's directory is not on PATH \u2014 add it, or use `agent-shim run` instead.", "claude");
|
|
74176
|
-
break;
|
|
74177
|
-
case "shadowed":
|
|
74178
|
-
push(
|
|
74179
|
-
"path-resolution",
|
|
74180
|
-
"warn",
|
|
74181
|
-
`\`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.`,
|
|
74182
|
-
"claude"
|
|
74183
|
-
);
|
|
74184
|
-
break;
|
|
74185
|
-
}
|
|
74186
|
-
}
|
|
74187
|
-
function cacheClause(cacheEnv, owner, block2) {
|
|
74188
|
-
if (cacheEnv === void 0 || block2.cache === void 0) {
|
|
74189
|
-
return { text: "", unreadable: false };
|
|
74190
|
-
}
|
|
74191
|
-
const state = describeCachedCredential({ port: cacheEnv.port, platform: cacheEnv.platform, owner, cache: block2.cache, nowMs: cacheEnv.now() });
|
|
74192
|
-
return { text: `; ${formatCachedCredentialState(state)}`, unreadable: state.status === "unreadable" };
|
|
74193
|
-
}
|
|
74194
|
-
function pushProvider(push, entry, cacheEnv) {
|
|
74195
|
-
if (entry.raw === void 0) {
|
|
74196
|
-
push("provider", "fail", `${entry.path} is missing.`, entry.name);
|
|
74197
|
-
return;
|
|
74198
|
-
}
|
|
74199
|
-
let parsed;
|
|
74200
|
-
try {
|
|
74201
|
-
parsed = JSON.parse(entry.raw);
|
|
74202
|
-
} catch (error62) {
|
|
74203
|
-
push("provider", "fail", `${entry.path} is not valid JSON: ${error62 instanceof Error ? error62.message : String(error62)}`, entry.name);
|
|
74204
|
-
return;
|
|
74205
|
-
}
|
|
74206
|
-
const conversion = legacyProviderConversion(parsed);
|
|
74207
|
-
if (conversion !== void 0) {
|
|
74208
|
-
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
74209
|
-
return;
|
|
74210
|
-
}
|
|
74211
|
-
const validated2 = ProviderSchema.safeParse(parsed);
|
|
74212
|
-
if (!validated2.success) {
|
|
74213
|
-
push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
|
|
74214
|
-
return;
|
|
74215
|
-
}
|
|
74216
|
-
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
|
|
74217
|
-
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
|
|
74218
|
-
if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
74219
|
-
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);
|
|
74220
|
-
}
|
|
74221
|
-
}
|
|
74222
|
-
function pushLegacyName(push, params) {
|
|
74223
|
-
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
74224
|
-
if (legacyVariables.length === 0 && import_node_path36.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
74225
|
-
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
74226
|
-
return;
|
|
74227
|
-
}
|
|
74228
|
-
for (const name of legacyVariables) {
|
|
74229
|
-
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);
|
|
74230
|
-
}
|
|
74231
|
-
if (import_node_path36.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
74232
|
-
push(
|
|
74233
|
-
"legacy-name",
|
|
74234
|
-
"warn",
|
|
74235
|
-
`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.`
|
|
74236
|
-
);
|
|
74237
|
-
}
|
|
74238
|
-
}
|
|
74239
|
-
function runDoctor(params) {
|
|
74240
|
-
const findings = [];
|
|
74241
|
-
const push = (section, severity, message, subject) => {
|
|
74242
|
-
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
74243
|
-
};
|
|
74244
|
-
const checkPin = (section, subject, where, version2) => {
|
|
74245
|
-
const installed = params.installedClaudeVersions;
|
|
74246
|
-
if (version2 === void 0 || installed === void 0 || installed.includes(version2)) {
|
|
74247
|
-
return;
|
|
74248
|
-
}
|
|
74249
|
-
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);
|
|
74250
|
-
};
|
|
74251
|
-
const ambient = detectAmbientCredential(params.env);
|
|
74252
|
-
if (ambient === void 0) {
|
|
74253
|
-
push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
|
|
74254
|
-
} else {
|
|
74255
|
-
push("ambient-credential", "warn", formatAmbientCredentialGuardMessage(ambient.variable));
|
|
74256
|
-
}
|
|
74257
|
-
if (params.binaryDiscovery.ok) {
|
|
74258
|
-
const { binary } = params.binaryDiscovery;
|
|
74259
|
-
const versionNote = binary.version === void 0 ? "" : `, version ${binary.version}`;
|
|
74260
|
-
push("binary-discovery", "pass", `Found ${binary.path} (${binary.source}${versionNote}).`);
|
|
74261
|
-
} else {
|
|
74262
|
-
push("binary-discovery", "fail", params.binaryDiscovery.message);
|
|
74263
|
-
}
|
|
74264
|
-
if (params.claudeShim.state === void 0) {
|
|
74265
|
-
push("claude-shim", "pass", "No `claude` command shim enabled (the default). Run `agent-shim shim enable` to add one.");
|
|
74266
|
-
} else if (!params.claudeShim.targetExists) {
|
|
74267
|
-
push(
|
|
74268
|
-
"claude-shim",
|
|
74269
|
-
"warn",
|
|
74270
|
-
`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.`
|
|
74271
|
-
);
|
|
74272
|
-
} else {
|
|
74273
|
-
push(
|
|
74274
|
-
"claude-shim",
|
|
74275
|
-
"pass",
|
|
74276
|
-
`\`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.`
|
|
74277
|
-
);
|
|
74278
|
-
}
|
|
74279
|
-
pushPathResolution(push, params.pathResolution);
|
|
74280
|
-
pushLegacyName(push, params);
|
|
74281
|
-
const profileSources = /* @__PURE__ */ new Map();
|
|
74282
|
-
for (const entry of params.configProfiles) {
|
|
74283
|
-
const validated2 = validateJson(ConfigProfileSchema, entry);
|
|
74284
|
-
if (!validated2.ok) {
|
|
74285
|
-
push("config-profile", "fail", validated2.message, entry.name);
|
|
74286
|
-
continue;
|
|
74287
|
-
}
|
|
74288
|
-
profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
|
|
74289
|
-
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
|
|
74290
|
-
}
|
|
74291
|
-
const loadProfile = (name) => profileSources.get(name);
|
|
74292
|
-
for (const name of profileSources.keys()) {
|
|
74293
|
-
const linearised = lineariseProfile(name, loadProfile);
|
|
74294
|
-
if (linearised.diagnostics.length === 0) {
|
|
74295
|
-
push("config-profile", "pass", `${name} is valid and its extends chain resolves cleanly.`, name);
|
|
74296
|
-
} else {
|
|
74297
|
-
for (const diagnostic of linearised.diagnostics) {
|
|
74298
|
-
push("config-profile", "fail", diagnostic.message, name);
|
|
74299
|
-
}
|
|
74300
|
-
}
|
|
74301
|
-
}
|
|
74302
|
-
const validProfileNames = new Set(profileSources.keys());
|
|
74303
|
-
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
74304
|
-
for (const entry of params.identities) {
|
|
74305
|
-
const validated2 = validateJson(IdentitySchema, entry);
|
|
74306
|
-
if (!validated2.ok) {
|
|
74307
|
-
push("identity", "fail", validated2.message, entry.name);
|
|
74308
|
-
continue;
|
|
74309
|
-
}
|
|
74310
|
-
validIdentityNames.add(entry.name);
|
|
74311
|
-
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
74312
|
-
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
74313
|
-
push(
|
|
74314
|
-
"identity",
|
|
74315
|
-
"fail",
|
|
74316
|
-
`Identity "${entry.name}" names configuration profile "${defaultProfile}" as its default, but no such profile exists.`,
|
|
74317
|
-
entry.name
|
|
74318
|
-
);
|
|
74319
|
-
} else {
|
|
74320
|
-
const credential = validated2.data.credential;
|
|
74321
|
-
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
74322
|
-
push(
|
|
74323
|
-
"identity",
|
|
74324
|
-
cache.unreadable ? "fail" : "pass",
|
|
74325
|
-
`${entry.name} is valid and authenticates with ${credential === void 0 ? "its stored login" : `credential ${describeCredential(credential)}`}${cache.text}.`,
|
|
74326
|
-
entry.name
|
|
74327
|
-
);
|
|
74328
|
-
}
|
|
74329
|
-
}
|
|
74330
|
-
const validatedGlobalConfig = params.globalConfig.raw === void 0 ? void 0 : validateJson(GlobalConfigSchema, params.globalConfig);
|
|
74331
|
-
const pools = validatedGlobalConfig?.ok === true ? validatedGlobalConfig.data.pools ?? {} : {};
|
|
74332
|
-
for (const [poolName, pool] of Object.entries(pools)) {
|
|
74333
|
-
const missing = pool.identities.filter((member) => !validIdentityNames.has(member));
|
|
74334
|
-
if (missing.length === 0) {
|
|
74335
|
-
push("pool", "pass", `${poolName} is valid (${pool.identities.join(", ")}).`, poolName);
|
|
74336
|
-
} else {
|
|
74337
|
-
push("pool", "fail", `Pool "${poolName}" names ${missing.map((member) => `identity "${member}"`).join(" and ")}, which ${missing.length === 1 ? "does" : "do"} not exist.`, poolName);
|
|
74338
|
-
}
|
|
74339
|
-
}
|
|
74340
|
-
const selectionExists = (selector) => {
|
|
74341
|
-
const poolName = poolNameOf(selector);
|
|
74342
|
-
return poolName === void 0 ? validIdentityNames.has(selector) : poolName in pools;
|
|
74343
|
-
};
|
|
74344
|
-
for (const entry of params.providers) {
|
|
74345
|
-
pushProvider(push, entry, params.credentialCache);
|
|
74346
|
-
}
|
|
74347
|
-
if (params.platform !== "darwin" || params.run === void 0) {
|
|
74348
|
-
push("keychain", "pass", "Skipped (not macOS).");
|
|
74349
|
-
} else {
|
|
74350
|
-
for (const entry of params.identities) {
|
|
74351
|
-
const result = lookupKeychainService(params.run, entry.farmRoot);
|
|
74352
|
-
push("keychain", result.found ? "pass" : "warn", result.note, entry.name);
|
|
74353
|
-
}
|
|
74354
|
-
}
|
|
74355
|
-
if (params.directoryRules.raw === void 0) {
|
|
74356
|
-
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
74357
|
-
} else {
|
|
74358
|
-
const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
|
|
74359
|
-
if (!validated2.ok) {
|
|
74360
|
-
push("directory-rules", "fail", validated2.message);
|
|
74361
|
-
} else {
|
|
74362
|
-
push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
|
|
74363
|
-
for (const rule of validated2.data.rules) {
|
|
74364
|
-
const badRefs = [];
|
|
74365
|
-
if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
|
|
74366
|
-
badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
|
|
74367
|
-
}
|
|
74368
|
-
if (rule.configProfile !== void 0 && !validProfileNames.has(rule.configProfile)) {
|
|
74369
|
-
badRefs.push(`configuration profile "${rule.configProfile}"`);
|
|
74370
|
-
}
|
|
74371
|
-
checkPin("directory-rules", rule.path, `Rule for "${rule.path}"`, rule.launch?.claudeVersion);
|
|
74372
|
-
if (badRefs.length > 0) {
|
|
74373
|
-
push("directory-rules", "fail", `Rule for "${rule.path}" names ${badRefs.join(" and ")}, which do not exist.`, rule.path);
|
|
74374
|
-
} else {
|
|
74375
|
-
push("directory-rules", "pass", `Rule for "${rule.path}" is valid.`, rule.path);
|
|
74376
|
-
}
|
|
74377
|
-
}
|
|
74378
|
-
}
|
|
74379
|
-
}
|
|
74380
|
-
if (params.globalConfig.raw === void 0) {
|
|
74381
|
-
push("global-config", "pass", "No config.json configured.");
|
|
74382
|
-
} else {
|
|
74383
|
-
const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
|
|
74384
|
-
if (!validated2.ok) {
|
|
74385
|
-
push("global-config", "fail", validated2.message);
|
|
74386
|
-
} else {
|
|
74387
|
-
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
74388
|
-
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
74389
|
-
push(
|
|
74390
|
-
"global-config",
|
|
74391
|
-
"fail",
|
|
74392
|
-
`config.json names configuration profile "${defaultProfile}" as its default, but no such profile exists.`
|
|
74393
|
-
);
|
|
74394
|
-
} else {
|
|
74395
|
-
push("global-config", "pass", `${params.globalConfig.path} is valid.`);
|
|
74396
|
-
checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
|
|
74397
|
-
}
|
|
74398
|
-
}
|
|
74399
|
-
}
|
|
74400
|
-
if (params.categoriesLocal.raw === void 0) {
|
|
74401
|
-
push("categories-local", "pass", "No categories.local.json configured.");
|
|
74402
|
-
} else {
|
|
74403
|
-
const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
|
|
74404
|
-
push(
|
|
74405
|
-
"categories-local",
|
|
74406
|
-
validated2.ok ? "pass" : "fail",
|
|
74407
|
-
validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
|
|
74408
|
-
);
|
|
74409
|
-
}
|
|
74410
|
-
if (params.headroom.state.raw === void 0) {
|
|
74411
|
-
push("headroom", "pass", "No headroom daemon has ever run; nothing to check.");
|
|
74412
|
-
} else {
|
|
74413
|
-
const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
|
|
74414
|
-
if (!validated2.ok) {
|
|
74415
|
-
push("headroom", "fail", validated2.message);
|
|
74416
|
-
} else {
|
|
74417
|
-
const state = validated2.data;
|
|
74418
|
-
const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
|
|
74419
|
-
const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
|
|
74420
|
-
if (state.supervisorPid === void 0) {
|
|
74421
|
-
if (state.lastError === void 0) {
|
|
74422
|
-
push("headroom", "pass", "Headroom daemon is stopped (idle shutdown) with no recorded error.");
|
|
74423
|
-
} else {
|
|
74424
|
-
push("headroom", "warn", `Headroom supervisor is not running; last error: ${state.lastError}`);
|
|
74425
|
-
}
|
|
74426
|
-
} else if (!supervisorAlive) {
|
|
74427
|
-
push(
|
|
74428
|
-
"headroom",
|
|
74429
|
-
"warn",
|
|
74430
|
-
`Headroom state names supervisor pid ${String(state.supervisorPid)}, which is not running; the next launch through headroom will start a replacement.`
|
|
74431
|
-
);
|
|
74432
|
-
} else if (state.headroomPid === void 0 || state.socketPath === void 0) {
|
|
74433
|
-
push(
|
|
74434
|
-
"headroom",
|
|
74435
|
-
"warn",
|
|
74436
|
-
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}`
|
|
74437
|
-
);
|
|
74438
|
-
} else if (!headroomAlive) {
|
|
74439
|
-
push(
|
|
74440
|
-
"headroom",
|
|
74441
|
-
"warn",
|
|
74442
|
-
`Headroom state names daemon pid ${String(state.headroomPid)}, which is not running; its supervisor should be restarting it.`
|
|
74443
|
-
);
|
|
74444
|
-
} else {
|
|
74445
|
-
push(
|
|
74446
|
-
"headroom",
|
|
74447
|
-
"pass",
|
|
74448
|
-
`Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
|
|
74449
|
-
);
|
|
74450
|
-
}
|
|
74451
|
-
if (state.lastError !== void 0 && supervisorAlive) {
|
|
74452
|
-
push("headroom", "warn", `Headroom recorded a previous error: ${state.lastError}`);
|
|
74453
|
-
}
|
|
74454
|
-
if (state.installedSource !== void 0 && isMovingGitSource(state.installedSource)) {
|
|
74455
|
-
push(
|
|
74456
|
-
"headroom",
|
|
74457
|
-
"warn",
|
|
74458
|
-
`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.`
|
|
74459
|
-
);
|
|
74460
|
-
}
|
|
74461
|
-
}
|
|
74462
|
-
}
|
|
74463
|
-
if (params.activeIdentity.raw === void 0) {
|
|
74464
|
-
push("active-identity", "pass", "No active identity set.");
|
|
74465
|
-
} else {
|
|
74466
|
-
const trimmed = params.activeIdentity.raw.trim();
|
|
74467
|
-
if (trimmed === "") {
|
|
74468
|
-
push("active-identity", "warn", "active-identity is present but empty \u2014 treated the same as unset.");
|
|
74469
|
-
} else if (!selectionExists(trimmed)) {
|
|
74470
|
-
push("active-identity", "fail", `active-identity names "${trimmed}", which does not exist.`);
|
|
74471
|
-
} else {
|
|
74472
|
-
push("active-identity", "pass", `Active identity "${trimmed}" is valid.`);
|
|
74473
|
-
}
|
|
74474
|
-
}
|
|
74475
|
-
return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
|
|
74476
|
-
}
|
|
74477
|
-
var SECTION_TITLES = {
|
|
74478
|
-
"ambient-credential": "Ambient-credential exposure",
|
|
74479
|
-
"binary-discovery": "Claude Code binary discovery",
|
|
74480
|
-
"claude-shim": "`claude` command shim",
|
|
74481
|
-
"path-resolution": "PATH resolution",
|
|
74482
|
-
"legacy-name": "Former `claude-use` name",
|
|
74483
|
-
"config-profile": "Configuration profiles",
|
|
74484
|
-
identity: "Identities",
|
|
74485
|
-
pool: "Pools",
|
|
74486
|
-
provider: "Providers",
|
|
74487
|
-
keychain: "macOS Keychain",
|
|
74488
|
-
"directory-rules": "Directory rules",
|
|
74489
|
-
"global-config": "Global config",
|
|
74490
|
-
headroom: "Headroom daemon",
|
|
74491
|
-
"categories-local": "categories.local.json",
|
|
74492
|
-
"active-identity": "Active identity"
|
|
74493
|
-
};
|
|
74494
|
-
var SECTION_ORDER = [
|
|
74495
|
-
"ambient-credential",
|
|
74496
|
-
"binary-discovery",
|
|
74497
|
-
"claude-shim",
|
|
74498
|
-
"path-resolution",
|
|
74499
|
-
"config-profile",
|
|
74500
|
-
"identity",
|
|
74501
|
-
"pool",
|
|
74502
|
-
"provider",
|
|
74503
|
-
"keychain",
|
|
74504
|
-
"directory-rules",
|
|
74505
|
-
"global-config",
|
|
74506
|
-
"headroom",
|
|
74507
|
-
"categories-local",
|
|
74508
|
-
"active-identity"
|
|
74509
|
-
];
|
|
74510
|
-
function severityPrefix(severity) {
|
|
74511
|
-
switch (severity) {
|
|
74512
|
-
case "pass":
|
|
74513
|
-
return "[PASS]";
|
|
74514
|
-
case "warn":
|
|
74515
|
-
return "[WARN]";
|
|
74516
|
-
case "fail":
|
|
74517
|
-
return "[FAIL]";
|
|
74518
|
-
default:
|
|
74519
|
-
return severity;
|
|
74520
|
-
}
|
|
74521
|
-
}
|
|
74522
|
-
function formatDoctorReport(report) {
|
|
74523
|
-
const lines = [];
|
|
74524
|
-
for (const section of SECTION_ORDER) {
|
|
74525
|
-
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
74526
|
-
if (sectionFindings.length === 0) {
|
|
74527
|
-
continue;
|
|
74528
|
-
}
|
|
74529
|
-
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
74530
|
-
for (const finding of sectionFindings) {
|
|
74531
|
-
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
74532
|
-
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
74533
|
-
}
|
|
74534
|
-
}
|
|
74535
|
-
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
74536
|
-
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
74537
|
-
return lines;
|
|
74538
|
-
}
|
|
74539
|
-
function realpathOrSelf(target) {
|
|
74540
|
-
try {
|
|
74541
|
-
return import_node_fs14.default.realpathSync(target);
|
|
74542
|
-
} catch {
|
|
74543
|
-
return target;
|
|
74544
|
-
}
|
|
74545
|
-
}
|
|
74546
|
-
function collectDoctorReport(params) {
|
|
74547
|
-
const { paths } = params;
|
|
74548
|
-
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() : [];
|
|
74549
|
-
const identities = identityNames.map((name) => {
|
|
74550
|
-
const farmRoot = import_node_path36.default.join(paths.identitiesDir, name);
|
|
74551
|
-
const identityPath = import_node_path36.default.join(farmRoot, "identity.json");
|
|
74552
|
-
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
74553
|
-
});
|
|
74554
|
-
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() : [];
|
|
74555
|
-
const configProfiles = profileNames.map((name) => {
|
|
74556
|
-
const profilePath = import_node_path36.default.join(paths.configProfilesDir, `${name}.json`);
|
|
74557
|
-
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
74558
|
-
});
|
|
74559
|
-
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() : [];
|
|
74560
|
-
const providers = providerNames.map((name) => {
|
|
74561
|
-
const providerPath = import_node_path36.default.join(paths.providersDir, `${name}.json`);
|
|
74562
|
-
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
74563
|
-
});
|
|
74564
|
-
const ownExecutablePath = realOwnExecutablePath();
|
|
74565
|
-
let binaryDiscovery;
|
|
74566
|
-
try {
|
|
74567
|
-
const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
|
|
74568
|
-
binaryDiscovery = { ok: true, binary };
|
|
74569
|
-
} catch (error62) {
|
|
74570
|
-
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
74571
|
-
}
|
|
74572
|
-
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
74573
|
-
const pathDirs = (params.env.PATH ?? "").split(import_node_path36.default.delimiter).filter((dir) => dir !== "");
|
|
74574
|
-
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
74575
|
-
findPathShadow({
|
|
74576
|
-
pathDirs,
|
|
74577
|
-
targetDir: import_node_path36.default.dirname(shimState.targetPath),
|
|
74578
|
-
targetFilename: import_node_path36.default.basename(shimState.targetPath),
|
|
74579
|
-
findExecutableInDir
|
|
74580
|
-
}),
|
|
74581
|
-
shimState.targetPath,
|
|
74582
|
-
realpathOrSelf
|
|
74583
|
-
);
|
|
74584
|
-
const report = runDoctor({
|
|
74585
|
-
env: params.env,
|
|
74586
|
-
credentialCache: realCredentialCacheEnv(paths),
|
|
74587
|
-
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
74588
|
-
identities,
|
|
74589
|
-
configProfiles,
|
|
74590
|
-
providers,
|
|
74591
|
-
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
74592
|
-
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
74593
|
-
categoriesLocal: { path: paths.categoriesLocalFile, raw: realFsPort.readFileUtf8(paths.categoriesLocalFile) },
|
|
74594
|
-
activeIdentity: { path: paths.activeIdentityFile, raw: realFsPort.readFileUtf8(paths.activeIdentityFile) },
|
|
74595
|
-
binaryDiscovery,
|
|
74596
|
-
claudeShim: { state: shimState, targetExists: shimState !== void 0 && import_node_fs14.default.existsSync(shimState.targetPath) },
|
|
74597
|
-
rootPath: paths.root,
|
|
74598
|
-
pathResolution: {
|
|
74599
|
-
ownExecutablePath,
|
|
74600
|
-
agentShim: refinePathShadow(
|
|
74601
|
-
findPathShadow({
|
|
74602
|
-
pathDirs,
|
|
74603
|
-
targetDir: import_node_path36.default.dirname(ownExecutablePath),
|
|
74604
|
-
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
74605
|
-
findExecutableInDir
|
|
74606
|
-
}),
|
|
74607
|
-
ownExecutablePath,
|
|
74608
|
-
realpathOrSelf
|
|
74609
|
-
),
|
|
74610
|
-
...claudeShimShadow === void 0 ? {} : { claude: claudeShimShadow }
|
|
74611
|
-
},
|
|
74612
|
-
run: realRunPort,
|
|
74613
|
-
platform: process.platform,
|
|
74614
|
-
headroom: {
|
|
74615
|
-
state: { path: paths.headroomStateFile, raw: realFsPort.readFileUtf8(paths.headroomStateFile) },
|
|
74616
|
-
isRunning: realIsProcessRunning
|
|
74617
|
-
}
|
|
74618
|
-
});
|
|
74619
|
-
return report;
|
|
74620
|
-
}
|
|
74621
|
-
|
|
74622
74979
|
// src/doctor.ts
|
|
74623
74980
|
function registerDoctorCommand(program2, deps) {
|
|
74624
74981
|
const { paths } = deps;
|
|
@@ -74643,7 +75000,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
74643
75000
|
// src/headroom/commands.ts
|
|
74644
75001
|
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
74645
75002
|
var import_node_http2 = __toESM(require("node:http"), 1);
|
|
74646
|
-
var
|
|
75003
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
74647
75004
|
var import_node_child_process5 = require("node:child_process");
|
|
74648
75005
|
|
|
74649
75006
|
// src/frontdoor/realFrontDoorPort.ts
|
|
@@ -74789,11 +75146,11 @@ function probeFrontDoorSync(port, caPem) {
|
|
|
74789
75146
|
|
|
74790
75147
|
// src/frontdoor/trust.ts
|
|
74791
75148
|
var import_node_crypto14 = require("node:crypto");
|
|
74792
|
-
var
|
|
75149
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
74793
75150
|
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
74794
75151
|
function resolveTrustBundle(params) {
|
|
74795
75152
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs19 } = params;
|
|
74796
|
-
if (inherited === void 0 || inherited === "" ||
|
|
75153
|
+
if (inherited === void 0 || inherited === "" || import_node_path38.default.resolve(inherited) === import_node_path38.default.resolve(caCertFile)) {
|
|
74797
75154
|
return { path: caCertFile };
|
|
74798
75155
|
}
|
|
74799
75156
|
const caPem = fs19.readFileUtf8(caCertFile);
|
|
@@ -74811,7 +75168,7 @@ function resolveTrustBundle(params) {
|
|
|
74811
75168
|
}
|
|
74812
75169
|
const combined = `${inheritedPem.trimEnd()}
|
|
74813
75170
|
${caPem}`;
|
|
74814
|
-
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`);
|
|
74815
75172
|
if (!fs19.exists(bundle)) {
|
|
74816
75173
|
fs19.mkdirp(bundlesDir);
|
|
74817
75174
|
fs19.writeFileAtomic(bundle, combined);
|
|
@@ -74969,12 +75326,12 @@ function readInstalledHeadroomCommit() {
|
|
|
74969
75326
|
if (toolDir.status !== 0) {
|
|
74970
75327
|
return void 0;
|
|
74971
75328
|
}
|
|
74972
|
-
const libDir =
|
|
75329
|
+
const libDir = import_node_path39.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
74973
75330
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
74974
|
-
const sitePackages =
|
|
75331
|
+
const sitePackages = import_node_path39.default.join(libDir, python, "site-packages");
|
|
74975
75332
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
74976
75333
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
74977
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
75334
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path39.default.join(sitePackages, entry, "direct_url.json"));
|
|
74978
75335
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
74979
75336
|
}
|
|
74980
75337
|
}
|
|
@@ -75781,7 +76138,7 @@ var import_node_crypto16 = require("node:crypto");
|
|
|
75781
76138
|
|
|
75782
76139
|
// src/launcher.ts
|
|
75783
76140
|
var import_node_crypto15 = require("node:crypto");
|
|
75784
|
-
var
|
|
76141
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
75785
76142
|
|
|
75786
76143
|
// src/launcher/cliOverride.ts
|
|
75787
76144
|
var InvalidCliCategoryError = class extends CliError {
|
|
@@ -75865,7 +76222,7 @@ function buildCliOverride(params) {
|
|
|
75865
76222
|
}
|
|
75866
76223
|
|
|
75867
76224
|
// src/launcher/flags.ts
|
|
75868
|
-
var
|
|
76225
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
75869
76226
|
|
|
75870
76227
|
// src/headroom/headers.ts
|
|
75871
76228
|
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
@@ -75935,7 +76292,7 @@ function buildEnv(params) {
|
|
|
75935
76292
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
75936
76293
|
let providerCustomHeaders;
|
|
75937
76294
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
75938
|
-
env.CLAUDE_CONFIG_DIR =
|
|
76295
|
+
env.CLAUDE_CONFIG_DIR = import_node_path40.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
75939
76296
|
}
|
|
75940
76297
|
if (params.provider !== void 0) {
|
|
75941
76298
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -76119,7 +76476,7 @@ function prepareLaunch(params) {
|
|
|
76119
76476
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
76120
76477
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
76121
76478
|
});
|
|
76122
|
-
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) {
|
|
76123
76480
|
log.error(
|
|
76124
76481
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
76125
76482
|
);
|
|
@@ -76465,7 +76822,7 @@ async function runClaude(argvOverride) {
|
|
|
76465
76822
|
// src/cli.ts
|
|
76466
76823
|
async function main() {
|
|
76467
76824
|
aliasLegacyEnv(process.env);
|
|
76468
|
-
const invokedName =
|
|
76825
|
+
const invokedName = import_node_path42.default.basename(process.argv[1] ?? "agent-shim");
|
|
76469
76826
|
if (isInvokedAsClaude(invokedName)) {
|
|
76470
76827
|
await runClaude();
|
|
76471
76828
|
return;
|