agent-shim 8.9.0 → 8.11.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 +3 -1
- package/dist/cli.cjs +498 -282
- package/dist/index.cjs +530 -317
- package/dist/index.mjs +531 -319
- package/dist/types/index.d.ts +81 -4
- 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 path42 = 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 = path42.join(homedir, "Library");
|
|
3258
3258
|
return {
|
|
3259
|
-
data:
|
|
3260
|
-
config:
|
|
3261
|
-
cache:
|
|
3262
|
-
log:
|
|
3263
|
-
temp:
|
|
3259
|
+
data: path42.join(library, "Application Support", name),
|
|
3260
|
+
config: path42.join(library, "Preferences", name),
|
|
3261
|
+
cache: path42.join(library, "Caches", name),
|
|
3262
|
+
log: path42.join(library, "Logs", name),
|
|
3263
|
+
temp: path42.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 || path42.join(homedir, "AppData", "Roaming");
|
|
3268
|
+
const localAppData = env.LOCALAPPDATA || path42.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: path42.join(localAppData, name, "Data"),
|
|
3272
|
+
config: path42.join(appData, name, "Config"),
|
|
3273
|
+
cache: path42.join(localAppData, name, "Cache"),
|
|
3274
|
+
log: path42.join(localAppData, name, "Log"),
|
|
3275
|
+
temp: path42.join(tmpdir, name)
|
|
3276
3276
|
};
|
|
3277
3277
|
};
|
|
3278
3278
|
var linux = (name) => {
|
|
3279
|
-
const username =
|
|
3279
|
+
const username = path42.basename(homedir);
|
|
3280
3280
|
return {
|
|
3281
|
-
data:
|
|
3282
|
-
config:
|
|
3283
|
-
cache:
|
|
3281
|
+
data: path42.join(env.XDG_DATA_HOME || path42.join(homedir, ".local", "share"), name),
|
|
3282
|
+
config: path42.join(env.XDG_CONFIG_HOME || path42.join(homedir, ".config"), name),
|
|
3283
|
+
cache: path42.join(env.XDG_CACHE_HOME || path42.join(homedir, ".cache"), name),
|
|
3284
3284
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
3285
|
-
log:
|
|
3286
|
-
temp:
|
|
3285
|
+
log: path42.join(env.XDG_STATE_HOME || path42.join(homedir, ".local", "state"), name),
|
|
3286
|
+
temp: path42.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, path42) {
|
|
3355
|
+
if (typeof path42 === "string" && Object.prototype.hasOwnProperty.call(source, path42)) {
|
|
3356
|
+
return source[path42];
|
|
3357
3357
|
}
|
|
3358
|
-
const parsedPath = typeof
|
|
3358
|
+
const parsedPath = typeof path42 === "string" ? path42.split(".") : path42;
|
|
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(path42) {
|
|
3382
3382
|
try {
|
|
3383
|
-
const stat = await fs_1.promises.stat(
|
|
3383
|
+
const stat = await fs_1.promises.stat(path42);
|
|
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(path42) {
|
|
3394
3394
|
try {
|
|
3395
|
-
const stat = fs_1.default.statSync(
|
|
3395
|
+
const stat = fs_1.default.statSync(path42);
|
|
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((path42, i2) => `${i2 + 1}. ${path42}`).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(path42) {
|
|
3682
3682
|
try {
|
|
3683
|
-
await promises_1.default.stat(
|
|
3683
|
+
await promises_1.default.stat(path42);
|
|
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(path42) {
|
|
3844
3844
|
try {
|
|
3845
|
-
fs_1.default.statSync(
|
|
3845
|
+
fs_1.default.statSync(path42);
|
|
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((path42) => path42.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 = (path42, { windows } = {}) => {
|
|
4378
|
+
const segs = path42.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 path42 = 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 (path42 && path42[0] !== "/") {
|
|
7011
|
+
path42 = `/${path42}`;
|
|
7012
7012
|
}
|
|
7013
|
-
return new URL(`${origin}${
|
|
7013
|
+
return new URL(`${origin}${path42}`);
|
|
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: path42, origin }
|
|
7835
7835
|
} = evt;
|
|
7836
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
7836
|
+
debugLog("sending request to %s %s%s", method, origin, path42);
|
|
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: path42, 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
|
+
path42,
|
|
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: path42, origin }
|
|
7871
7871
|
} = evt;
|
|
7872
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
7872
|
+
debugLog("trailers received from %s %s%s", method, origin, path42);
|
|
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: path42, 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
|
+
path42,
|
|
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: path42,
|
|
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 path42 !== "string") {
|
|
8019
8019
|
throw new InvalidArgumentError2("path must be a string");
|
|
8020
|
-
} else if (
|
|
8020
|
+
} else if (path42[0] !== "/" && !(path42.startsWith("http://") || path42.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(path42)) {
|
|
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(path42, query) : path42;
|
|
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: path42, 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} ${path42} 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: path42, 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] = path42;
|
|
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] = path42;
|
|
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: path42 = "/",
|
|
16500
16500
|
headers = {}
|
|
16501
16501
|
} = opts;
|
|
16502
|
-
opts.path = origin +
|
|
16502
|
+
opts.path = origin + path42;
|
|
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(path42) {
|
|
18612
|
+
if (typeof path42 !== "string") {
|
|
18613
|
+
return path42;
|
|
18614
18614
|
}
|
|
18615
|
-
const pathSegments =
|
|
18615
|
+
const pathSegments = path42.split("?", 3);
|
|
18616
18616
|
if (pathSegments.length !== 2) {
|
|
18617
|
-
return
|
|
18617
|
+
return path42;
|
|
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: path42, method, body, headers }) {
|
|
18624
|
+
const pathMatch = matchValue(mockDispatch2.path, path42);
|
|
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: path42, ignoreTrailingSlash }) => {
|
|
18650
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path42)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path42), 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(path42) {
|
|
18690
|
+
while (path42.endsWith("/")) {
|
|
18691
|
+
path42 = path42.slice(0, -1);
|
|
18692
18692
|
}
|
|
18693
|
-
if (
|
|
18694
|
-
|
|
18693
|
+
if (path42.length === 0) {
|
|
18694
|
+
path42 = "/";
|
|
18695
18695
|
}
|
|
18696
|
-
return
|
|
18696
|
+
return path42;
|
|
18697
18697
|
}
|
|
18698
18698
|
function buildKey(opts) {
|
|
18699
|
-
const { path:
|
|
18699
|
+
const { path: path42, method, body, headers, query } = opts;
|
|
18700
18700
|
return {
|
|
18701
|
-
path:
|
|
18701
|
+
path: path42,
|
|
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: path42, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
19392
19392
|
Method: method,
|
|
19393
19393
|
Origin: origin,
|
|
19394
|
-
Path:
|
|
19394
|
+
Path: path42,
|
|
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 [path42, searchParams] = dispatchOpts.path.split("?");
|
|
19477
19477
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
19478
|
-
dispatchOpts.path = `${
|
|
19478
|
+
dispatchOpts.path = `${path42}?${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 path42 = filePath || this.#snapshotPath;
|
|
19880
|
+
if (!path42) {
|
|
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(path42), "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 ${path42}`, { 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 path42 = filePath || this.#snapshotPath;
|
|
19910
|
+
if (!path42) {
|
|
19911
19911
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
19912
19912
|
}
|
|
19913
|
-
const resolvedPath = resolve(
|
|
19913
|
+
const resolvedPath = resolve(path42);
|
|
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 path42 = search ? `${pathname}${search}` : pathname;
|
|
20546
|
+
const redirectUrlString = `${origin}${path42}`;
|
|
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 = path42;
|
|
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, path42) {
|
|
22314
22314
|
deleteCachedValue(store, {
|
|
22315
22315
|
...cacheKey,
|
|
22316
|
-
path:
|
|
22316
|
+
path: path42
|
|
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: path42
|
|
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 path42 = getSameOriginPath(cacheKey, values[i2]);
|
|
22336
|
+
if (path42 !== void 0) {
|
|
22337
|
+
deleteCachedUri(store, cacheKey, path42);
|
|
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 path42 = 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 ? `${path42}?` : path42,
|
|
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(path42) {
|
|
28289
|
+
for (let i2 = 0; i2 < path42.length; ++i2) {
|
|
28290
|
+
const code = path42.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 path42 = opts.path;
|
|
31639
31639
|
if (!opts.path.startsWith("/")) {
|
|
31640
|
-
|
|
31640
|
+
path42 = `/${path42}`;
|
|
31641
31641
|
}
|
|
31642
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
31642
|
+
url2 = new URL(util.parseOrigin(url2).origin + path42);
|
|
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_path40 = __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(path42) {
|
|
34866
|
+
if (path42 === void 0) return this._executableDir;
|
|
34867
|
+
this._executableDir = path42;
|
|
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, path42) {
|
|
36006
|
+
if (!path42)
|
|
36007
36007
|
return obj;
|
|
36008
|
-
return
|
|
36008
|
+
return path42.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(path42, 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(path42);
|
|
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, path42 = []) => {
|
|
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 }, [...path42, ...issue2.path]));
|
|
36806
36806
|
} else if (issue2.code === "invalid_key") {
|
|
36807
|
-
processError({ issues: issue2.issues }, [...
|
|
36807
|
+
processError({ issues: issue2.issues }, [...path42, ...issue2.path]);
|
|
36808
36808
|
} else if (issue2.code === "invalid_element") {
|
|
36809
|
-
processError({ issues: issue2.issues }, [...
|
|
36809
|
+
processError({ issues: issue2.issues }, [...path42, ...issue2.path]);
|
|
36810
36810
|
} else {
|
|
36811
|
-
const fullpath = [...
|
|
36811
|
+
const fullpath = [...path42, ...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, path42 = []) => {
|
|
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 }, [...path42, ...issue2.path]));
|
|
36855
36855
|
} else if (issue2.code === "invalid_key") {
|
|
36856
|
-
processError({ issues: issue2.issues }, [...
|
|
36856
|
+
processError({ issues: issue2.issues }, [...path42, ...issue2.path]);
|
|
36857
36857
|
} else if (issue2.code === "invalid_element") {
|
|
36858
|
-
processError({ issues: issue2.issues }, [...
|
|
36858
|
+
processError({ issues: issue2.issues }, [...path42, ...issue2.path]);
|
|
36859
36859
|
} else {
|
|
36860
|
-
const fullpath = [...
|
|
36860
|
+
const fullpath = [...path42, ...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 path42 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
36900
|
+
for (const seg of path42) {
|
|
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 path42 = ref.slice(1).split("/").filter(Boolean);
|
|
54003
|
+
if (path42.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 (path42[0] === defsKey) {
|
|
54008
|
+
const key = path42[1] === void 0 ? void 0 : decodeJSONPointerSegment(path42[1]);
|
|
54009
54009
|
if (!key || !ctx.defs[key]) {
|
|
54010
54010
|
throw new Error(`Reference not found: ${ref}`);
|
|
54011
54011
|
}
|
|
@@ -55043,9 +55043,9 @@ function applyPatch(filePath, schema, patch, options = {}) {
|
|
|
55043
55043
|
if (!result.success) {
|
|
55044
55044
|
throw new ConfigValidationError(filePath, result.error.issues);
|
|
55045
55045
|
}
|
|
55046
|
-
const
|
|
55047
|
-
writeJsonAtomic(filePath,
|
|
55048
|
-
return
|
|
55046
|
+
const validated2 = result.data;
|
|
55047
|
+
writeJsonAtomic(filePath, validated2, storeFs);
|
|
55048
|
+
return validated2;
|
|
55049
55049
|
}
|
|
55050
55050
|
|
|
55051
55051
|
// src/realPorts.ts
|
|
@@ -55085,6 +55085,23 @@ function compareVersions(a2, b) {
|
|
|
55085
55085
|
}
|
|
55086
55086
|
return 0;
|
|
55087
55087
|
}
|
|
55088
|
+
var ClaudeVersionNotInstalledError = class extends CliError {
|
|
55089
|
+
constructor(version2, versionsDir, installed) {
|
|
55090
|
+
super(
|
|
55091
|
+
`Claude Code ${version2} is pinned for this launch but is not installed under "${versionsDir}"` + (installed.length === 0 ? " (no versions are installed there)." : `. Installed: ${installed.join(", ")}.`) + " Install it, or change or remove the pin (--claude-version, AGENT_SHIM_CLAUDE_VERSION, or launch.claudeVersion)."
|
|
55092
|
+
);
|
|
55093
|
+
this.version = version2;
|
|
55094
|
+
this.versionsDir = versionsDir;
|
|
55095
|
+
this.installed = installed;
|
|
55096
|
+
this.name = "ClaudeVersionNotInstalledError";
|
|
55097
|
+
}
|
|
55098
|
+
version;
|
|
55099
|
+
versionsDir;
|
|
55100
|
+
installed;
|
|
55101
|
+
};
|
|
55102
|
+
function installedVersions(entries) {
|
|
55103
|
+
return entries.filter((entry) => entry.isFile && entry.isExecutable && entry.sizeBytes > 0 && isNumericDottedVersion(entry.name)).map((entry) => entry.name).sort(compareVersions);
|
|
55104
|
+
}
|
|
55088
55105
|
function pickHighestVersion(entries) {
|
|
55089
55106
|
const candidates = entries.filter(
|
|
55090
55107
|
(entry) => entry.isFile && entry.isExecutable && entry.sizeBytes > 0 && isNumericDottedVersion(entry.name)
|
|
@@ -55100,6 +55117,13 @@ function discoverClaudeBinary(options) {
|
|
|
55100
55117
|
const versionsDir = options.versionsDir ?? defaultVersionsDir();
|
|
55101
55118
|
const entries = options.listVersionsDir(versionsDir);
|
|
55102
55119
|
const highestVersion = pickHighestVersion(entries);
|
|
55120
|
+
if (options.version !== void 0) {
|
|
55121
|
+
const installed = installedVersions(entries);
|
|
55122
|
+
if (!installed.includes(options.version)) {
|
|
55123
|
+
throw new ClaudeVersionNotInstalledError(options.version, versionsDir, installed);
|
|
55124
|
+
}
|
|
55125
|
+
return { path: import_node_path3.default.join(versionsDir, options.version), source: "versions-dir", version: options.version };
|
|
55126
|
+
}
|
|
55103
55127
|
if (highestVersion !== void 0) {
|
|
55104
55128
|
return {
|
|
55105
55129
|
path: import_node_path3.default.join(versionsDir, highestVersion),
|
|
@@ -55167,7 +55191,9 @@ var LaunchSchema = external_exports.strictObject({
|
|
|
55167
55191
|
remoteControl: external_exports.boolean().optional(),
|
|
55168
55192
|
provider: external_exports.string().min(1).optional(),
|
|
55169
55193
|
headroom: external_exports.boolean().optional(),
|
|
55170
|
-
trackUsage: external_exports.boolean().optional()
|
|
55194
|
+
trackUsage: external_exports.boolean().optional(),
|
|
55195
|
+
/** The exact Claude Code version to run, as it is named in Claude Code's versions directory (`2.1.220`). A pin that is not installed fails the launch; it never falls back to the highest version. */
|
|
55196
|
+
claudeVersion: external_exports.string().regex(NUMERIC_DOTTED_VERSION_RE, "must be an exact dotted-numeric Claude Code version such as 2.1.220").optional()
|
|
55171
55197
|
});
|
|
55172
55198
|
var CREDENTIAL_TARGETS = ["bearer", "apiKey", "oauthToken"];
|
|
55173
55199
|
var PROVIDER_CREDENTIAL_TARGETS = ["bearer", "apiKey"];
|
|
@@ -56501,13 +56527,17 @@ function realContentSourcePath() {
|
|
|
56501
56527
|
return resolveContentSourcePath({ isSea: (0, import_node_sea.isSea)(), execPath: process.execPath, argv1: process.argv[1] });
|
|
56502
56528
|
}
|
|
56503
56529
|
function realResolveClaudeBinary(isOwnBinary) {
|
|
56504
|
-
return () => discoverClaudeBinary({
|
|
56530
|
+
return (request7) => discoverClaudeBinary({
|
|
56505
56531
|
listVersionsDir,
|
|
56506
56532
|
pathDirs: (process.env.PATH ?? "").split(import_node_path8.default.delimiter).filter((dir) => dir !== ""),
|
|
56507
56533
|
findExecutableInDir,
|
|
56508
|
-
isOwnBinary
|
|
56534
|
+
isOwnBinary,
|
|
56535
|
+
...request7?.version === void 0 ? {} : { version: request7.version }
|
|
56509
56536
|
});
|
|
56510
56537
|
}
|
|
56538
|
+
function realInstalledClaudeVersions() {
|
|
56539
|
+
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
56540
|
+
}
|
|
56511
56541
|
|
|
56512
56542
|
// src/claudeShim.ts
|
|
56513
56543
|
var EXECUTABLE_FILE_MODE = 493;
|
|
@@ -59284,6 +59314,9 @@ function flattenLayers(layers, options) {
|
|
|
59284
59314
|
if (layer.launch.trackUsage !== void 0) {
|
|
59285
59315
|
launch.trackUsage = layer.launch.trackUsage;
|
|
59286
59316
|
}
|
|
59317
|
+
if (layer.launch.claudeVersion !== void 0) {
|
|
59318
|
+
launch.claudeVersion = layer.launch.claudeVersion;
|
|
59319
|
+
}
|
|
59287
59320
|
}
|
|
59288
59321
|
if (layer.entries === void 0) {
|
|
59289
59322
|
continue;
|
|
@@ -60215,6 +60248,7 @@ function buildLayoutPaths(root) {
|
|
|
60215
60248
|
frontdoorLockFile: import_node_path19.default.join(root, "frontdoor", "start.lock"),
|
|
60216
60249
|
frontdoorControlTokenFile: import_node_path19.default.join(root, "frontdoor", "control-token"),
|
|
60217
60250
|
frontdoorSessionsDir: import_node_path19.default.join(root, "frontdoor", "sessions"),
|
|
60251
|
+
frontdoorRcCredentialsDir: import_node_path19.default.join(root, "frontdoor", "rc-credentials"),
|
|
60218
60252
|
frontdoorLogPath: import_node_path19.default.join(root, "logs", "frontdoor.log"),
|
|
60219
60253
|
usageDir: import_node_path19.default.join(root, "usage"),
|
|
60220
60254
|
usageLogDir: import_node_path19.default.join(root, "usage", "log"),
|
|
@@ -61264,6 +61298,9 @@ function applyProfileSet(paths, name, options) {
|
|
|
61264
61298
|
if (options.launchProvider !== void 0) {
|
|
61265
61299
|
launchPatch.provider = options.launchProvider === false ? void 0 : options.launchProvider;
|
|
61266
61300
|
}
|
|
61301
|
+
if (options.launchClaudeVersion !== void 0) {
|
|
61302
|
+
launchPatch.claudeVersion = options.launchClaudeVersion === false ? void 0 : options.launchClaudeVersion;
|
|
61303
|
+
}
|
|
61267
61304
|
if (Object.keys(launchPatch).length > 0) {
|
|
61268
61305
|
setProfileLaunchFlags(paths, name, launchPatch);
|
|
61269
61306
|
touched = true;
|
|
@@ -61305,7 +61342,7 @@ function registerProfileCommand(program2, deps) {
|
|
|
61305
61342
|
withExamples(
|
|
61306
61343
|
profile.command("set <name>").description(
|
|
61307
61344
|
"Update a configuration profile's categories, entries, extends list, description or launch settings. With no options on a terminal, walks through its categories."
|
|
61308
|
-
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
61345
|
+
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
61309
61346
|
const { json: json2, ...options } = allOptions;
|
|
61310
61347
|
requireProfileExists(paths, name);
|
|
61311
61348
|
if (Object.entries(allOptions).every(([key, value2]) => key === "json" || value2 === void 0)) {
|
|
@@ -61673,7 +61710,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
61673
61710
|
// package.json
|
|
61674
61711
|
var package_default = {
|
|
61675
61712
|
name: "agent-shim",
|
|
61676
|
-
version: "8.
|
|
61713
|
+
version: "8.11.0",
|
|
61677
61714
|
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.",
|
|
61678
61715
|
license: "MIT",
|
|
61679
61716
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -62103,11 +62140,11 @@ function providerBaseUrl(port, provider) {
|
|
|
62103
62140
|
function directOrigin(port) {
|
|
62104
62141
|
return `http://127.0.0.1:${String(port)}`;
|
|
62105
62142
|
}
|
|
62106
|
-
function parseProviderPath(
|
|
62107
|
-
if (!
|
|
62143
|
+
function parseProviderPath(path42) {
|
|
62144
|
+
if (!path42.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
62108
62145
|
return void 0;
|
|
62109
62146
|
}
|
|
62110
|
-
const tail =
|
|
62147
|
+
const tail = path42.slice(PROVIDER_PATH_PREFIX.length);
|
|
62111
62148
|
const slash = tail.indexOf("/");
|
|
62112
62149
|
if (slash <= 0) {
|
|
62113
62150
|
return void 0;
|
|
@@ -62507,9 +62544,9 @@ function decoderFor(encoding) {
|
|
|
62507
62544
|
return void 0;
|
|
62508
62545
|
}
|
|
62509
62546
|
}
|
|
62510
|
-
function destinationOf(
|
|
62511
|
-
const scoped = parseProviderPath(
|
|
62512
|
-
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint:
|
|
62547
|
+
function destinationOf(path42) {
|
|
62548
|
+
const scoped = parseProviderPath(path42);
|
|
62549
|
+
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path42 } : { provider: scoped.provider, endpoint: scoped.rest };
|
|
62513
62550
|
}
|
|
62514
62551
|
function buildRecord(event, context) {
|
|
62515
62552
|
const { scan } = context;
|
|
@@ -63553,6 +63590,34 @@ function parseEnvBool(variable, value2) {
|
|
|
63553
63590
|
return parsed;
|
|
63554
63591
|
}
|
|
63555
63592
|
|
|
63593
|
+
// src/launcher/claudeVersion.ts
|
|
63594
|
+
var InvalidClaudeVersionError = class extends UsageError {
|
|
63595
|
+
constructor(value2, origin) {
|
|
63596
|
+
super(`${origin} names Claude Code version "${value2}", which is not an exact dotted-numeric version such as 2.1.220.`);
|
|
63597
|
+
this.value = value2;
|
|
63598
|
+
this.origin = origin;
|
|
63599
|
+
this.name = "InvalidClaudeVersionError";
|
|
63600
|
+
}
|
|
63601
|
+
value;
|
|
63602
|
+
origin;
|
|
63603
|
+
};
|
|
63604
|
+
function validated(value2, origin) {
|
|
63605
|
+
if (!NUMERIC_DOTTED_VERSION_RE.test(value2)) {
|
|
63606
|
+
throw new InvalidClaudeVersionError(value2, origin);
|
|
63607
|
+
}
|
|
63608
|
+
return value2;
|
|
63609
|
+
}
|
|
63610
|
+
function resolveClaudeVersion(params) {
|
|
63611
|
+
if (params.flag !== void 0) {
|
|
63612
|
+
return { version: validated(params.flag, "--claude-version"), source: "flag" };
|
|
63613
|
+
}
|
|
63614
|
+
const fromEnv = params.env.AGENT_SHIM_CLAUDE_VERSION;
|
|
63615
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
63616
|
+
return { version: validated(fromEnv, "AGENT_SHIM_CLAUDE_VERSION"), source: "environment" };
|
|
63617
|
+
}
|
|
63618
|
+
return params.cascade === void 0 ? void 0 : { version: params.cascade, source: "cascade" };
|
|
63619
|
+
}
|
|
63620
|
+
|
|
63556
63621
|
// src/launcher/guard.ts
|
|
63557
63622
|
var AMBIENT_CREDENTIAL_VARS = [
|
|
63558
63623
|
"ANTHROPIC_API_KEY",
|
|
@@ -63750,6 +63815,19 @@ function buildCredentialReport(provider, identity, identityName, cacheEnv) {
|
|
|
63750
63815
|
...identityCached === void 0 ? {} : { identityCached }
|
|
63751
63816
|
};
|
|
63752
63817
|
}
|
|
63818
|
+
function buildClaudeVersionReport(params, cascadePin) {
|
|
63819
|
+
const installed = params.installedClaudeVersions;
|
|
63820
|
+
if (installed === void 0) {
|
|
63821
|
+
return void 0;
|
|
63822
|
+
}
|
|
63823
|
+
const pin = resolveClaudeVersion({ env: params.env, ...cascadePin === void 0 ? {} : { cascade: cascadePin } });
|
|
63824
|
+
const highestInstalled = installed.at(-1);
|
|
63825
|
+
return {
|
|
63826
|
+
...pin === void 0 ? {} : { pinned: { ...pin, installed: installed.includes(pin.version) } },
|
|
63827
|
+
...highestInstalled === void 0 ? {} : { highestInstalled },
|
|
63828
|
+
installed
|
|
63829
|
+
};
|
|
63830
|
+
}
|
|
63753
63831
|
function runCheck(params) {
|
|
63754
63832
|
const facts = buildEntryFacts({
|
|
63755
63833
|
fs: params.farmFs,
|
|
@@ -63774,6 +63852,7 @@ function runCheck(params) {
|
|
|
63774
63852
|
const settingsShared = resolved.flattened.categories.get("settings") ?? SHIPPED_CATEGORY_DEFAULTS.settings;
|
|
63775
63853
|
const settingsExposure = inspectSettingsExposure({ settingsShared, files: params.settingsFiles });
|
|
63776
63854
|
const keychain = params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
|
|
63855
|
+
const claudeVersion = buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
|
|
63777
63856
|
return {
|
|
63778
63857
|
...params.identityName === void 0 ? {} : { identityName: params.identityName },
|
|
63779
63858
|
identitySource: params.identitySource,
|
|
@@ -63786,7 +63865,8 @@ function runCheck(params) {
|
|
|
63786
63865
|
ambientCredential,
|
|
63787
63866
|
...keychain === void 0 ? {} : { keychain },
|
|
63788
63867
|
settingsExposure,
|
|
63789
|
-
credential: buildCredentialReport(params.provider, params.identity, params.identityName, params.credentialCache)
|
|
63868
|
+
credential: buildCredentialReport(params.provider, params.identity, params.identityName, params.credentialCache),
|
|
63869
|
+
...claudeVersion === void 0 ? {} : { claudeVersion }
|
|
63790
63870
|
};
|
|
63791
63871
|
}
|
|
63792
63872
|
function formatCheckReport(report) {
|
|
@@ -63835,6 +63915,17 @@ function formatCheckReport(report) {
|
|
|
63835
63915
|
if (credential.applies === "stored-login") {
|
|
63836
63916
|
lines.push(" The identity's stored login (no credential block applies).");
|
|
63837
63917
|
}
|
|
63918
|
+
if (report.claudeVersion !== void 0) {
|
|
63919
|
+
lines.push("", "Claude Code version:");
|
|
63920
|
+
const { pinned, highestInstalled, installed } = report.claudeVersion;
|
|
63921
|
+
if (pinned !== void 0) {
|
|
63922
|
+
lines.push(
|
|
63923
|
+
pinned.installed ? ` ${pinned.version}, pinned by the ${pinned.source} (installed)` : ` ${pinned.version}, pinned by the ${pinned.source}, but NOT installed; a launch here fails. Installed: ${installed.length === 0 ? "none" : installed.join(", ")}`
|
|
63924
|
+
);
|
|
63925
|
+
} else {
|
|
63926
|
+
lines.push(highestInstalled === void 0 ? " none installed in the versions directory (a launch falls back to a claude on PATH)" : ` ${highestInstalled} (the highest installed; nothing pins a version)`);
|
|
63927
|
+
}
|
|
63928
|
+
}
|
|
63838
63929
|
lines.push("", "Ambient-credential exposure:");
|
|
63839
63930
|
lines.push(
|
|
63840
63931
|
report.ambientCredential.ok ? ` OK \u2014 none of ${AMBIENT_CREDENTIAL_VARS.join(", ")} is set to a non-empty value.` : report.ambientCredential.message.split("\n").map((line) => ` ${line}`).join("\n")
|
|
@@ -63873,11 +63964,12 @@ function checkReportToJson(report) {
|
|
|
63873
63964
|
ambientCredential: report.ambientCredential.ok ? { ok: true } : { ok: false, variable: report.ambientCredential.variable, message: report.ambientCredential.message },
|
|
63874
63965
|
...report.keychain === void 0 ? {} : { keychain: report.keychain },
|
|
63875
63966
|
settingsExposure: report.settingsExposure,
|
|
63876
|
-
credential: report.credential
|
|
63967
|
+
credential: report.credential,
|
|
63968
|
+
...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion }
|
|
63877
63969
|
};
|
|
63878
63970
|
}
|
|
63879
63971
|
function checkReportHasWarnings(report) {
|
|
63880
|
-
return report.resolved.diagnostics.some((diagnostic) => diagnostic.severity !== "info") || report.projectEncodingAmbiguities.length > 0 || !report.ambientCredential.ok || report.credential.provider?.problem !== void 0;
|
|
63972
|
+
return report.resolved.diagnostics.some((diagnostic) => diagnostic.severity !== "info") || report.projectEncodingAmbiguities.length > 0 || !report.ambientCredential.ok || report.credential.provider?.problem !== void 0 || report.claudeVersion?.pinned?.installed === false;
|
|
63881
63973
|
}
|
|
63882
63974
|
function loadCheckProvider(paths, name) {
|
|
63883
63975
|
let definition;
|
|
@@ -63963,6 +64055,7 @@ function collectCheckReport(params) {
|
|
|
63963
64055
|
settingsFiles,
|
|
63964
64056
|
run: realRunPort,
|
|
63965
64057
|
credentialCache: realCredentialCacheEnv(paths),
|
|
64058
|
+
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
63966
64059
|
...farmRoot === void 0 ? {} : { farmRoot },
|
|
63967
64060
|
platform: process.platform,
|
|
63968
64061
|
...provider === void 0 ? {} : { provider }
|
|
@@ -64353,7 +64446,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
64353
64446
|
|
|
64354
64447
|
// src/frontdoor/commands.ts
|
|
64355
64448
|
var import_node_crypto12 = require("node:crypto");
|
|
64356
|
-
var
|
|
64449
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
64357
64450
|
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
64358
64451
|
|
|
64359
64452
|
// src/frontdoor/custody.ts
|
|
@@ -65083,8 +65176,8 @@ function parseConnectTarget(authority) {
|
|
|
65083
65176
|
}
|
|
65084
65177
|
return { host, port };
|
|
65085
65178
|
}
|
|
65086
|
-
function servedByPipeline(
|
|
65087
|
-
return
|
|
65179
|
+
function servedByPipeline(path42) {
|
|
65180
|
+
return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
65088
65181
|
}
|
|
65089
65182
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
65090
65183
|
"connection",
|
|
@@ -65597,13 +65690,18 @@ function createRcSessionTracker(deps) {
|
|
|
65597
65690
|
entries.set(id, record2);
|
|
65598
65691
|
return record2;
|
|
65599
65692
|
};
|
|
65693
|
+
const persistCredential = (entry) => {
|
|
65694
|
+
if (entry.oauthAuthorization !== void 0) {
|
|
65695
|
+
deps.credentialStore?.write(entry.id, { authorization: entry.oauthAuthorization, anthropicVersion: entry.anthropicVersion, anthropicClientPlatform: entry.anthropicClientPlatform });
|
|
65696
|
+
}
|
|
65697
|
+
};
|
|
65600
65698
|
const observeExchange = (request7) => {
|
|
65601
65699
|
const method = (request7.method ?? "").toUpperCase();
|
|
65602
|
-
const
|
|
65603
|
-
if (!
|
|
65700
|
+
const path42 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
|
|
65701
|
+
if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
65604
65702
|
return void 0;
|
|
65605
65703
|
}
|
|
65606
|
-
const tail =
|
|
65704
|
+
const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
65607
65705
|
const facts = {
|
|
65608
65706
|
oauthAuthorization: oauthAuthorizationOf(request7.headers),
|
|
65609
65707
|
anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
|
|
@@ -65636,7 +65734,7 @@ function createRcSessionTracker(deps) {
|
|
|
65636
65734
|
if (id2 === void 0) {
|
|
65637
65735
|
return;
|
|
65638
65736
|
}
|
|
65639
|
-
birth(id2, facts);
|
|
65737
|
+
persistCredential(birth(id2, facts));
|
|
65640
65738
|
}
|
|
65641
65739
|
};
|
|
65642
65740
|
}
|
|
@@ -65650,6 +65748,7 @@ function createRcSessionTracker(deps) {
|
|
|
65650
65748
|
entry.oauthAuthorization = facts.oauthAuthorization ?? entry.oauthAuthorization;
|
|
65651
65749
|
entry.anthropicVersion = facts.anthropicVersion ?? entry.anthropicVersion;
|
|
65652
65750
|
entry.anthropicClientPlatform = facts.anthropicClientPlatform ?? entry.anthropicClientPlatform;
|
|
65751
|
+
persistCredential(entry);
|
|
65653
65752
|
const bodyKind = method === "POST" && rest === `${id}/worker/events` ? "worker-events" : method === "POST" && rest === `${id}/events` ? "client-events" : method === "POST" && rest === `${id}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id}/worker` ? "worker-registration" : void 0;
|
|
65654
65753
|
let chunks = [];
|
|
65655
65754
|
let buffered = 0;
|
|
@@ -65703,6 +65802,7 @@ function createRcSessionTracker(deps) {
|
|
|
65703
65802
|
},
|
|
65704
65803
|
onResponse: (status, headers) => {
|
|
65705
65804
|
if (singleHeader(headers, CONFLICT_REASON_HEADER) !== void 0 || archiving && isSuccessful(status)) {
|
|
65805
|
+
deps.credentialStore?.remove(id);
|
|
65706
65806
|
expire(id);
|
|
65707
65807
|
return;
|
|
65708
65808
|
}
|
|
@@ -65735,7 +65835,18 @@ function createRcSessionTracker(deps) {
|
|
|
65735
65835
|
},
|
|
65736
65836
|
credentialOf: (sessionId) => {
|
|
65737
65837
|
const entry = entries.get(sessionId);
|
|
65738
|
-
|
|
65838
|
+
if (entry === void 0) {
|
|
65839
|
+
return void 0;
|
|
65840
|
+
}
|
|
65841
|
+
if (entry.oauthAuthorization === void 0 && deps.credentialStore !== void 0) {
|
|
65842
|
+
const persisted = deps.credentialStore.read(sessionId);
|
|
65843
|
+
if (persisted?.authorization !== void 0) {
|
|
65844
|
+
entry.oauthAuthorization = persisted.authorization;
|
|
65845
|
+
entry.anthropicVersion = entry.anthropicVersion ?? persisted.anthropicVersion;
|
|
65846
|
+
entry.anthropicClientPlatform = entry.anthropicClientPlatform ?? persisted.anthropicClientPlatform;
|
|
65847
|
+
}
|
|
65848
|
+
}
|
|
65849
|
+
return { authorization: entry.oauthAuthorization, anthropicVersion: entry.anthropicVersion, anthropicClientPlatform: entry.anthropicClientPlatform };
|
|
65739
65850
|
},
|
|
65740
65851
|
noteSequenceNums: (sessionId, sequenceNums) => {
|
|
65741
65852
|
const entry = entries.get(sessionId);
|
|
@@ -66330,9 +66441,9 @@ function sequenceNumsOfBody(body) {
|
|
|
66330
66441
|
}
|
|
66331
66442
|
function frontDoorRcControl(transport, token) {
|
|
66332
66443
|
const headers = { authorization: `Bearer ${token}` };
|
|
66333
|
-
const listAnswerOf = async (
|
|
66444
|
+
const listAnswerOf = async (path42, what) => {
|
|
66334
66445
|
try {
|
|
66335
|
-
return await transport.request({ method: "GET", path:
|
|
66446
|
+
return await transport.request({ method: "GET", path: path42, headers });
|
|
66336
66447
|
} catch (error62) {
|
|
66337
66448
|
throw new Error(`${what}: could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}`, { cause: error62 });
|
|
66338
66449
|
}
|
|
@@ -66404,10 +66515,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
66404
66515
|
}
|
|
66405
66516
|
return pending;
|
|
66406
66517
|
};
|
|
66407
|
-
const writeOf = async (
|
|
66518
|
+
const writeOf = async (path42, body, describeFailure) => {
|
|
66408
66519
|
let answer;
|
|
66409
66520
|
try {
|
|
66410
|
-
answer = await transport.request({ method: "POST", path:
|
|
66521
|
+
answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
|
|
66411
66522
|
} catch (error62) {
|
|
66412
66523
|
return { ok: false, message: `could not reach the front door's control listener: ${error62 instanceof Error ? error62.message : String(error62)}` };
|
|
66413
66524
|
}
|
|
@@ -66589,15 +66700,27 @@ var SUCCESS_STATUS_MAX_EXCLUSIVE2 = 300;
|
|
|
66589
66700
|
function isSuccessful2(status) {
|
|
66590
66701
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE2;
|
|
66591
66702
|
}
|
|
66592
|
-
var
|
|
66593
|
-
|
|
66594
|
-
|
|
66595
|
-
|
|
66596
|
-
|
|
66597
|
-
|
|
66598
|
-
|
|
66599
|
-
|
|
66600
|
-
|
|
66703
|
+
var SourcePortRange = class {
|
|
66704
|
+
constructor(start, end) {
|
|
66705
|
+
this.start = start;
|
|
66706
|
+
this.end = end;
|
|
66707
|
+
this.count = end - start + 1;
|
|
66708
|
+
this.next = start;
|
|
66709
|
+
}
|
|
66710
|
+
start;
|
|
66711
|
+
end;
|
|
66712
|
+
count;
|
|
66713
|
+
next;
|
|
66714
|
+
/** The next port in rotation, wrapping from the end back to the start. */
|
|
66715
|
+
take() {
|
|
66716
|
+
const port = this.next;
|
|
66717
|
+
this.next = this.next === this.end ? this.start : this.next + 1;
|
|
66718
|
+
return port;
|
|
66719
|
+
}
|
|
66720
|
+
};
|
|
66721
|
+
var DOOR_SOURCE_PORT_START = 47900;
|
|
66722
|
+
var DOOR_SOURCE_PORT_END = 47919;
|
|
66723
|
+
var DOOR_SOURCE_PORTS = new SourcePortRange(DOOR_SOURCE_PORT_START, DOOR_SOURCE_PORT_END);
|
|
66601
66724
|
var realAddressLookup = (host, _options, callback) => {
|
|
66602
66725
|
if (net2.isIP(host) !== 0) {
|
|
66603
66726
|
callback(null, [{ address: host, family: net2.isIP(host) }]);
|
|
@@ -66635,14 +66758,14 @@ function dialTarget(options, defaultPort) {
|
|
|
66635
66758
|
function literalDial(target) {
|
|
66636
66759
|
return net2.connect({ host: target.host, port: target.port });
|
|
66637
66760
|
}
|
|
66638
|
-
async function reservedDial(target) {
|
|
66761
|
+
async function reservedDial(target, ports) {
|
|
66639
66762
|
for (let attempt = 0; ; attempt += 1) {
|
|
66640
|
-
const outcome = await dialOnce({ host: target.host, port: target.port, localPort:
|
|
66763
|
+
const outcome = await dialOnce({ host: target.host, port: target.port, localPort: ports.take(), lookup: realAddressLookup });
|
|
66641
66764
|
if (outcome.error === null) {
|
|
66642
66765
|
return outcome;
|
|
66643
66766
|
}
|
|
66644
66767
|
const held = outcome.error.code !== void 0 && HELD_PORT_ERRNOS.has(outcome.error.code);
|
|
66645
|
-
if (!held || attempt ===
|
|
66768
|
+
if (!held || attempt === ports.count - 1) {
|
|
66646
66769
|
return outcome;
|
|
66647
66770
|
}
|
|
66648
66771
|
}
|
|
@@ -66651,26 +66774,36 @@ function requestServername(options, fallback) {
|
|
|
66651
66774
|
return "servername" in options && typeof options.servername === "string" && options.servername !== "" ? options.servername : fallback;
|
|
66652
66775
|
}
|
|
66653
66776
|
var ExemptHttpAgent = class extends http2.Agent {
|
|
66777
|
+
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
66778
|
+
super();
|
|
66779
|
+
this.ports = ports;
|
|
66780
|
+
}
|
|
66781
|
+
ports;
|
|
66654
66782
|
// A reserved-port dial that has to retry cannot produce its socket synchronously, so it settles first and arrives through the callback (node's documented asynchronous createConnection form); a literal dial has nothing to retry and keeps node's own synchronous shape.
|
|
66655
66783
|
createConnection(options, oncreate) {
|
|
66656
66784
|
const target = dialTarget(options, HTTP_PORT);
|
|
66657
66785
|
if (net2.isIP(target.host) !== 0) {
|
|
66658
66786
|
return literalDial(target);
|
|
66659
66787
|
}
|
|
66660
|
-
void reservedDial(target).then((outcome) => {
|
|
66788
|
+
void reservedDial(target, this.ports).then((outcome) => {
|
|
66661
66789
|
oncreate?.(outcome.error, outcome.socket);
|
|
66662
66790
|
});
|
|
66663
66791
|
return void 0;
|
|
66664
66792
|
}
|
|
66665
66793
|
};
|
|
66666
66794
|
var ExemptTlsAgent = class extends https3.Agent {
|
|
66795
|
+
constructor(ports = DOOR_SOURCE_PORTS) {
|
|
66796
|
+
super();
|
|
66797
|
+
this.ports = ports;
|
|
66798
|
+
}
|
|
66799
|
+
ports;
|
|
66667
66800
|
// The same split as the plain sibling: a literal dial wraps TLS around the socket node's own agent would have returned, a reserved dial settles (retries included) first and arrives through the callback, which is exactly where node's own agent wraps its own dials.
|
|
66668
66801
|
createConnection(options, oncreate) {
|
|
66669
66802
|
const target = dialTarget(options, HTTPS_PORT);
|
|
66670
66803
|
if (net2.isIP(target.host) !== 0) {
|
|
66671
66804
|
return tls.connect({ socket: literalDial(target), servername: requestServername(options, target.host), ...tlsFacts(options) });
|
|
66672
66805
|
}
|
|
66673
|
-
void reservedDial(target).then((outcome) => {
|
|
66806
|
+
void reservedDial(target, this.ports).then((outcome) => {
|
|
66674
66807
|
if (outcome.error !== null) {
|
|
66675
66808
|
oncreate?.(outcome.error, outcome.socket);
|
|
66676
66809
|
return;
|
|
@@ -66731,12 +66864,12 @@ var NO_CHUNKS = {
|
|
|
66731
66864
|
};
|
|
66732
66865
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
66733
66866
|
const agent = new ExemptTlsAgent();
|
|
66734
|
-
const request7 = async (method,
|
|
66867
|
+
const request7 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
66735
66868
|
const options = {
|
|
66736
66869
|
host: target.host,
|
|
66737
66870
|
port: target.port,
|
|
66738
66871
|
method,
|
|
66739
|
-
path:
|
|
66872
|
+
path: path42,
|
|
66740
66873
|
// 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.
|
|
66741
66874
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
66742
66875
|
agent,
|
|
@@ -66773,9 +66906,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
66773
66906
|
return { status, body: await readAll(response) };
|
|
66774
66907
|
},
|
|
66775
66908
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
66776
|
-
const
|
|
66909
|
+
const path42 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
66777
66910
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
66778
|
-
const { status, response } = await request7("GET",
|
|
66911
|
+
const { status, response } = await request7("GET", path42, streamHeaders, void 0, signal);
|
|
66779
66912
|
if (!isSuccessful2(status)) {
|
|
66780
66913
|
await readAll(response);
|
|
66781
66914
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -66784,9 +66917,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
66784
66917
|
}
|
|
66785
66918
|
};
|
|
66786
66919
|
}
|
|
66787
|
-
function realConnectEffects() {
|
|
66788
|
-
const plainAgent = new ExemptHttpAgent();
|
|
66789
|
-
const tlsAgent = new ExemptTlsAgent();
|
|
66920
|
+
function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
66921
|
+
const plainAgent = new ExemptHttpAgent(ports);
|
|
66922
|
+
const tlsAgent = new ExemptTlsAgent(ports);
|
|
66790
66923
|
const listenOnce = async (port, onSocket) => await new Promise((resolve, reject) => {
|
|
66791
66924
|
const accepted = /* @__PURE__ */ new Set();
|
|
66792
66925
|
const server = net2.createServer((socket) => {
|
|
@@ -66904,7 +67037,7 @@ function realConnectEffects() {
|
|
|
66904
67037
|
};
|
|
66905
67038
|
},
|
|
66906
67039
|
connectTlsUpstream: async (host, port, clientAlpn) => {
|
|
66907
|
-
const dialled = await reservedDial({ host, port });
|
|
67040
|
+
const dialled = await reservedDial({ host, port }, ports);
|
|
66908
67041
|
if (dialled.error !== null) {
|
|
66909
67042
|
throw dialled.error;
|
|
66910
67043
|
}
|
|
@@ -67898,9 +68031,9 @@ function resolveFriendlyClientOptions(options) {
|
|
|
67898
68031
|
};
|
|
67899
68032
|
}
|
|
67900
68033
|
function createORPCClient(link, options = {}) {
|
|
67901
|
-
const
|
|
68034
|
+
const path42 = options.path ?? [];
|
|
67902
68035
|
const procedureClient = async (...[input2, options2 = {}]) => {
|
|
67903
|
-
return await link.call(
|
|
68036
|
+
return await link.call(path42, input2, resolveFriendlyClientOptions(options2));
|
|
67904
68037
|
};
|
|
67905
68038
|
const recursive2 = new Proxy(procedureClient, {
|
|
67906
68039
|
get(target, key) {
|
|
@@ -67909,7 +68042,7 @@ function createORPCClient(link, options = {}) {
|
|
|
67909
68042
|
}
|
|
67910
68043
|
return createORPCClient(link, {
|
|
67911
68044
|
...options,
|
|
67912
|
-
path: [...
|
|
68045
|
+
path: [...path42, key]
|
|
67913
68046
|
});
|
|
67914
68047
|
}
|
|
67915
68048
|
});
|
|
@@ -68211,19 +68344,19 @@ var StandardLink = class {
|
|
|
68211
68344
|
}
|
|
68212
68345
|
interceptors;
|
|
68213
68346
|
clientInterceptors;
|
|
68214
|
-
call(
|
|
68347
|
+
call(path42, input2, options) {
|
|
68215
68348
|
return runWithSpan(
|
|
68216
|
-
{ name: `${ORPC_NAME}.${
|
|
68349
|
+
{ name: `${ORPC_NAME}.${path42.join("/")}`, signal: options.signal },
|
|
68217
68350
|
(span) => {
|
|
68218
68351
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
68219
|
-
span?.setAttribute("rpc.method",
|
|
68352
|
+
span?.setAttribute("rpc.method", path42.join("."));
|
|
68220
68353
|
if (isAsyncIteratorObject(input2)) {
|
|
68221
68354
|
input2 = asyncIteratorWithSpan(
|
|
68222
68355
|
{ name: "consume_event_iterator_input", signal: options.signal },
|
|
68223
68356
|
input2
|
|
68224
68357
|
);
|
|
68225
68358
|
}
|
|
68226
|
-
return intercept(this.interceptors, { ...options, path:
|
|
68359
|
+
return intercept(this.interceptors, { ...options, path: path42, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
|
|
68227
68360
|
const otelConfig = getGlobalOtelConfig();
|
|
68228
68361
|
let otelContext;
|
|
68229
68362
|
const currentSpan = otelConfig?.trace.getActiveSpan() ?? span;
|
|
@@ -68458,8 +68591,8 @@ var StandardRPCJsonSerializer = class {
|
|
|
68458
68591
|
return ref.data;
|
|
68459
68592
|
}
|
|
68460
68593
|
};
|
|
68461
|
-
function toHttpPath(
|
|
68462
|
-
return `/${
|
|
68594
|
+
function toHttpPath(path42) {
|
|
68595
|
+
return `/${path42.map(encodeURIComponent).join("/")}`;
|
|
68463
68596
|
}
|
|
68464
68597
|
function toStandardHeaders2(headers) {
|
|
68465
68598
|
if (typeof headers.forEach === "function") {
|
|
@@ -68484,18 +68617,18 @@ var StandardRPCLinkCodec = class {
|
|
|
68484
68617
|
fallbackMethod;
|
|
68485
68618
|
expectedMethod;
|
|
68486
68619
|
headers;
|
|
68487
|
-
async encode(
|
|
68488
|
-
let headers = toStandardHeaders2(await value(this.headers, options,
|
|
68620
|
+
async encode(path42, input2, options) {
|
|
68621
|
+
let headers = toStandardHeaders2(await value(this.headers, options, path42, input2));
|
|
68489
68622
|
if (options.lastEventId !== void 0) {
|
|
68490
68623
|
headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
68491
68624
|
}
|
|
68492
|
-
const expectedMethod = await value(this.expectedMethod, options,
|
|
68493
|
-
const baseUrl = await value(this.baseUrl, options,
|
|
68625
|
+
const expectedMethod = await value(this.expectedMethod, options, path42, input2);
|
|
68626
|
+
const baseUrl = await value(this.baseUrl, options, path42, input2);
|
|
68494
68627
|
const url2 = new URL(baseUrl);
|
|
68495
|
-
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(
|
|
68628
|
+
url2.pathname = `${url2.pathname.replace(/\/$/, "")}${toHttpPath(path42)}`;
|
|
68496
68629
|
const serialized = this.serializer.serialize(input2);
|
|
68497
68630
|
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
68498
|
-
const maxUrlLength = await value(this.maxUrlLength, options,
|
|
68631
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path42, input2);
|
|
68499
68632
|
const getUrl = new URL(url2);
|
|
68500
68633
|
getUrl.searchParams.append("data", stringifyJSON(serialized));
|
|
68501
68634
|
if (getUrl.toString().length <= maxUrlLength) {
|
|
@@ -68646,11 +68779,11 @@ var LinkFetchClient = class {
|
|
|
68646
68779
|
this.toFetchRequestOptions = options;
|
|
68647
68780
|
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
68648
68781
|
}
|
|
68649
|
-
async call(standardRequest, options,
|
|
68782
|
+
async call(standardRequest, options, path42, input2) {
|
|
68650
68783
|
const request7 = toFetchRequest(standardRequest, this.toFetchRequestOptions);
|
|
68651
68784
|
const fetchResponse = await intercept(
|
|
68652
68785
|
this.adapterInterceptors,
|
|
68653
|
-
{ ...options, request: request7, path:
|
|
68786
|
+
{ ...options, request: request7, path: path42, input: input2, init: { redirect: "manual" } },
|
|
68654
68787
|
({ request: request22, path: path210, input: input22, init, ...options2 }) => this.fetch(request22, init, options2, path210, input22)
|
|
68655
68788
|
);
|
|
68656
68789
|
const lazyResponse = toStandardLazyResponse(fetchResponse, { signal: request7.signal });
|
|
@@ -68686,11 +68819,11 @@ async function validateORPCError(map3, error62) {
|
|
|
68686
68819
|
if (!config2.data) {
|
|
68687
68820
|
return defined ? error62 : new ORPCError(code, { defined: true, status, message, data, cause });
|
|
68688
68821
|
}
|
|
68689
|
-
const
|
|
68690
|
-
if (
|
|
68822
|
+
const validated2 = await config2.data["~standard"].validate(error62.data);
|
|
68823
|
+
if (validated2.issues) {
|
|
68691
68824
|
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error62;
|
|
68692
68825
|
}
|
|
68693
|
-
return new ORPCError(code, { defined: true, status, message, data:
|
|
68826
|
+
return new ORPCError(code, { defined: true, status, message, data: validated2.value, cause });
|
|
68694
68827
|
}
|
|
68695
68828
|
var ContractProcedure = class {
|
|
68696
68829
|
/**
|
|
@@ -69050,7 +69183,7 @@ function middlewareOutputFn(output2) {
|
|
|
69050
69183
|
function createProcedureClient(lazyableProcedure, ...rest) {
|
|
69051
69184
|
const options = resolveMaybeOptionalOptions(rest);
|
|
69052
69185
|
return async (...[input2, callerOptions]) => {
|
|
69053
|
-
const
|
|
69186
|
+
const path42 = toArray(options.path);
|
|
69054
69187
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
|
69055
69188
|
const clientContext = callerOptions?.context ?? {};
|
|
69056
69189
|
const context = await value(options.context ?? {}, clientContext);
|
|
@@ -69065,7 +69198,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69065
69198
|
const output2 = await runWithSpan(
|
|
69066
69199
|
{ name: "call_procedure", signal: callerOptions?.signal },
|
|
69067
69200
|
(span) => {
|
|
69068
|
-
span?.setAttribute("procedure.path", [...
|
|
69201
|
+
span?.setAttribute("procedure.path", [...path42]);
|
|
69069
69202
|
return intercept(
|
|
69070
69203
|
toArray(options.interceptors),
|
|
69071
69204
|
{
|
|
@@ -69073,7 +69206,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
69073
69206
|
input: input2,
|
|
69074
69207
|
// input only optional when it undefinable so we can safely cast it
|
|
69075
69208
|
errors,
|
|
69076
|
-
path:
|
|
69209
|
+
path: path42,
|
|
69077
69210
|
procedure,
|
|
69078
69211
|
signal: callerOptions?.signal,
|
|
69079
69212
|
lastEventId: callerOptions?.lastEventId
|
|
@@ -69195,10 +69328,10 @@ var HIDDEN_ROUTER_CONTRACT_SYMBOL = /* @__PURE__ */ Symbol("ORPC_HIDDEN_ROUTER_C
|
|
|
69195
69328
|
function getHiddenRouterContract(router) {
|
|
69196
69329
|
return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
|
|
69197
69330
|
}
|
|
69198
|
-
function getRouter(router,
|
|
69331
|
+
function getRouter(router, path42) {
|
|
69199
69332
|
let current = router;
|
|
69200
|
-
for (let i2 = 0; i2 <
|
|
69201
|
-
const segment =
|
|
69333
|
+
for (let i2 = 0; i2 < path42.length; i2++) {
|
|
69334
|
+
const segment = path42[i2];
|
|
69202
69335
|
if (!current) {
|
|
69203
69336
|
return void 0;
|
|
69204
69337
|
}
|
|
@@ -69213,7 +69346,7 @@ function getRouter(router, path41) {
|
|
|
69213
69346
|
continue;
|
|
69214
69347
|
}
|
|
69215
69348
|
const lazied = current;
|
|
69216
|
-
const rest =
|
|
69349
|
+
const rest = path42.slice(i2);
|
|
69217
69350
|
return lazy2(async () => {
|
|
69218
69351
|
const unwrapped = await unlazy(lazied);
|
|
69219
69352
|
const next = getRouter(unwrapped.default, rest);
|
|
@@ -69791,8 +69924,8 @@ function toAbortSignal(stream) {
|
|
|
69791
69924
|
function toStandardUrl(req) {
|
|
69792
69925
|
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
|
69793
69926
|
const origin = guard(() => new URL(`${protocol}//${req.headers.host ?? "localhost"}`).origin) ?? `${protocol}//localhost`;
|
|
69794
|
-
const
|
|
69795
|
-
return new URL(`${origin}${
|
|
69927
|
+
const path42 = req.originalUrl ?? req.url ?? "/";
|
|
69928
|
+
return new URL(`${origin}${path42.startsWith("/") ? "" : "/"}${path42}`);
|
|
69796
69929
|
}
|
|
69797
69930
|
function toStandardLazyRequest(req, res) {
|
|
69798
69931
|
const signal = toAbortSignal(res);
|
|
@@ -69991,8 +70124,8 @@ var StandardRPCMatcher = class {
|
|
|
69991
70124
|
constructor(options = {}) {
|
|
69992
70125
|
this.filter = options.filter ?? true;
|
|
69993
70126
|
}
|
|
69994
|
-
init(router,
|
|
69995
|
-
const laziedOptions = traverseContractProcedures({ router, path:
|
|
70127
|
+
init(router, path42 = []) {
|
|
70128
|
+
const laziedOptions = traverseContractProcedures({ router, path: path42 }, (traverseOptions) => {
|
|
69996
70129
|
if (!value(this.filter, traverseOptions)) {
|
|
69997
70130
|
return;
|
|
69998
70131
|
}
|
|
@@ -71454,8 +71587,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
71454
71587
|
request7.body.resume();
|
|
71455
71588
|
return;
|
|
71456
71589
|
}
|
|
71457
|
-
const
|
|
71458
|
-
const translated = { method: request7.method, path:
|
|
71590
|
+
const path42 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
71591
|
+
const translated = { method: request7.method, path: path42, body, signal: request7.signal };
|
|
71459
71592
|
const routed = await route(translated);
|
|
71460
71593
|
if (request7.signal.aborted) {
|
|
71461
71594
|
return;
|
|
@@ -71489,7 +71622,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71489
71622
|
headroomUpstream: target.headroomUpstream,
|
|
71490
71623
|
serve: async (request7, response) => {
|
|
71491
71624
|
const incoming = new URL(request7.url, "http://127.0.0.1");
|
|
71492
|
-
const
|
|
71625
|
+
const path42 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
71493
71626
|
const headers = forwardableHeaders(request7.headers);
|
|
71494
71627
|
delete headers.host;
|
|
71495
71628
|
await new Promise((resolve) => {
|
|
@@ -71497,7 +71630,7 @@ function createPassthroughRoute(name, target) {
|
|
|
71497
71630
|
host: base.hostname,
|
|
71498
71631
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
71499
71632
|
method: request7.method,
|
|
71500
|
-
path: `${basePath}${
|
|
71633
|
+
path: `${basePath}${path42}${incoming.search}`,
|
|
71501
71634
|
headers,
|
|
71502
71635
|
agent
|
|
71503
71636
|
};
|
|
@@ -71559,10 +71692,10 @@ function createProviderRouteResolver(deps) {
|
|
|
71559
71692
|
return route;
|
|
71560
71693
|
};
|
|
71561
71694
|
const resolve = (request7) => {
|
|
71562
|
-
const
|
|
71563
|
-
const scoped = parseProviderPath(
|
|
71695
|
+
const path42 = new URL(request7.url, "http://127.0.0.1").pathname;
|
|
71696
|
+
const scoped = parseProviderPath(path42);
|
|
71564
71697
|
if (scoped === void 0) {
|
|
71565
|
-
return
|
|
71698
|
+
return path42.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path42}` };
|
|
71566
71699
|
}
|
|
71567
71700
|
const { provider } = scoped;
|
|
71568
71701
|
let definition;
|
|
@@ -71601,6 +71734,64 @@ function createProviderRouteResolver(deps) {
|
|
|
71601
71734
|
return async (request7) => await Promise.resolve(resolve(request7));
|
|
71602
71735
|
}
|
|
71603
71736
|
|
|
71737
|
+
// src/frontdoor/rcCredentialStore.ts
|
|
71738
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
71739
|
+
function isSafeSessionId(sessionId) {
|
|
71740
|
+
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
71741
|
+
}
|
|
71742
|
+
function isRecord4(value2) {
|
|
71743
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
71744
|
+
}
|
|
71745
|
+
function credentialOfJson(parsed) {
|
|
71746
|
+
if (!isRecord4(parsed)) {
|
|
71747
|
+
return void 0;
|
|
71748
|
+
}
|
|
71749
|
+
const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
|
|
71750
|
+
if (typeof authorization !== "string" || authorization === "") {
|
|
71751
|
+
return void 0;
|
|
71752
|
+
}
|
|
71753
|
+
return {
|
|
71754
|
+
authorization,
|
|
71755
|
+
anthropicVersion: typeof anthropicVersion === "string" ? anthropicVersion : void 0,
|
|
71756
|
+
anthropicClientPlatform: typeof anthropicClientPlatform === "string" ? anthropicClientPlatform : void 0
|
|
71757
|
+
};
|
|
71758
|
+
}
|
|
71759
|
+
function createRcCredentialStore(fs19, dir) {
|
|
71760
|
+
fs19.mkdirPrivate(dir);
|
|
71761
|
+
const fileFor = (sessionId) => import_node_path32.default.join(dir, `${sessionId}.json`);
|
|
71762
|
+
return {
|
|
71763
|
+
read: (sessionId) => {
|
|
71764
|
+
if (!isSafeSessionId(sessionId)) {
|
|
71765
|
+
return void 0;
|
|
71766
|
+
}
|
|
71767
|
+
const raw = fs19.readFileUtf8(fileFor(sessionId));
|
|
71768
|
+
if (raw === void 0) {
|
|
71769
|
+
return void 0;
|
|
71770
|
+
}
|
|
71771
|
+
let parsed;
|
|
71772
|
+
try {
|
|
71773
|
+
parsed = JSON.parse(raw);
|
|
71774
|
+
} catch {
|
|
71775
|
+
return void 0;
|
|
71776
|
+
}
|
|
71777
|
+
return credentialOfJson(parsed);
|
|
71778
|
+
},
|
|
71779
|
+
write: (sessionId, credential) => {
|
|
71780
|
+
if (!isSafeSessionId(sessionId)) {
|
|
71781
|
+
return;
|
|
71782
|
+
}
|
|
71783
|
+
fs19.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(credential, null, 2)}
|
|
71784
|
+
`);
|
|
71785
|
+
},
|
|
71786
|
+
remove: (sessionId) => {
|
|
71787
|
+
if (!isSafeSessionId(sessionId)) {
|
|
71788
|
+
return;
|
|
71789
|
+
}
|
|
71790
|
+
fs19.removeRecursive(fileFor(sessionId));
|
|
71791
|
+
}
|
|
71792
|
+
};
|
|
71793
|
+
}
|
|
71794
|
+
|
|
71604
71795
|
// src/frontdoor/rcStream.ts
|
|
71605
71796
|
var RC_STREAM_EVENT_NAME = "client_event";
|
|
71606
71797
|
var SSE_BYTE_ORDER_MARK = 65279;
|
|
@@ -71663,7 +71854,7 @@ function createSseParser() {
|
|
|
71663
71854
|
}
|
|
71664
71855
|
};
|
|
71665
71856
|
}
|
|
71666
|
-
function
|
|
71857
|
+
function isRecord5(value2) {
|
|
71667
71858
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
71668
71859
|
}
|
|
71669
71860
|
function sequenceNumOf(value2) {
|
|
@@ -71685,7 +71876,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
71685
71876
|
} catch {
|
|
71686
71877
|
return void 0;
|
|
71687
71878
|
}
|
|
71688
|
-
if (!
|
|
71879
|
+
if (!isRecord5(data)) {
|
|
71689
71880
|
return void 0;
|
|
71690
71881
|
}
|
|
71691
71882
|
const eventType = data.event_type;
|
|
@@ -71774,6 +71965,7 @@ function createRcStreamHub(deps) {
|
|
|
71774
71965
|
if (!isSuccessful3(answer.status)) {
|
|
71775
71966
|
throw new Error(`the client read stream answered HTTP ${String(answer.status)}`);
|
|
71776
71967
|
}
|
|
71968
|
+
deps.log?.(`rc stream ${attachment.sessionId}: attached as client ${attachment.clientId}${resume === void 0 ? ", reading from the stream's own head" : `, resuming after sequence number ${String(resume.fromSequenceNum)}`}`);
|
|
71777
71969
|
const parser = createSseParser();
|
|
71778
71970
|
for await (const chunk of answer.chunks) {
|
|
71779
71971
|
attachment.controller.signal.throwIfAborted();
|
|
@@ -71797,6 +71989,7 @@ function createRcStreamHub(deps) {
|
|
|
71797
71989
|
const live = deps.trackedSessions().includes(attachment.sessionId);
|
|
71798
71990
|
const credential = deps.credentialOf(attachment.sessionId);
|
|
71799
71991
|
if (!live || credential?.authorization === void 0) {
|
|
71992
|
+
deps.log?.(`rc stream ${attachment.sessionId}: the attachment ended (${live ? "the session's client credential is no longer known" : "the tracker gave up on the session"})`);
|
|
71800
71993
|
if (attachments.get(attachment.sessionId) === attachment) {
|
|
71801
71994
|
attachments.delete(attachment.sessionId);
|
|
71802
71995
|
}
|
|
@@ -71818,6 +72011,7 @@ function createRcStreamHub(deps) {
|
|
|
71818
72011
|
return;
|
|
71819
72012
|
}
|
|
71820
72013
|
if (outcome === "dropped") {
|
|
72014
|
+
deps.log?.(`rc stream ${attachment.sessionId}: the stream ended of its own accord, reconnecting`);
|
|
71821
72015
|
retriedUnauthorized = false;
|
|
71822
72016
|
continue;
|
|
71823
72017
|
}
|
|
@@ -72167,7 +72361,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
72167
72361
|
};
|
|
72168
72362
|
let directPort = 0;
|
|
72169
72363
|
const codexPorts = createCodexRoutePorts(log);
|
|
72170
|
-
const rcTracker = createRcSessionTracker({ now: () => Date.now(), idleMs: RC_IDLE_EXPIRY_MS });
|
|
72364
|
+
const rcTracker = createRcSessionTracker({ now: () => Date.now(), idleMs: RC_IDLE_EXPIRY_MS, credentialStore: createRcCredentialStore(realFarmFs, paths.frontdoorRcCredentialsDir) });
|
|
72171
72365
|
const rcFanout = createRcEventFanout();
|
|
72172
72366
|
const rcHub = createRcStreamHub({
|
|
72173
72367
|
now: () => Date.now(),
|
|
@@ -72278,7 +72472,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
72278
72472
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
72279
72473
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
72280
72474
|
if (capture !== void 0) {
|
|
72281
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
72475
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path33.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
72282
72476
|
}
|
|
72283
72477
|
const server = await startConnectServer(
|
|
72284
72478
|
{
|
|
@@ -72649,7 +72843,7 @@ var ConflictingIdentityError = class extends UsageError {
|
|
|
72649
72843
|
positional;
|
|
72650
72844
|
flag;
|
|
72651
72845
|
};
|
|
72652
|
-
var VALUED_FLAGS = ["--identity", "--config-profile", "--provider", "--category", "--share", "--hide"];
|
|
72846
|
+
var VALUED_FLAGS = ["--identity", "--config-profile", "--provider", "--claude-version", "--category", "--share", "--hide"];
|
|
72653
72847
|
var BOOLEAN_FLAGS = [
|
|
72654
72848
|
{ flag: "--headroom", key: "headroom" },
|
|
72655
72849
|
{ flag: "--track-usage", key: "trackUsage" },
|
|
@@ -72695,6 +72889,7 @@ function parseLauncherArgv(argv) {
|
|
|
72695
72889
|
let flagIdentity;
|
|
72696
72890
|
let configProfile;
|
|
72697
72891
|
let provider;
|
|
72892
|
+
let claudeVersion;
|
|
72698
72893
|
const booleans = {};
|
|
72699
72894
|
const categoryFlags = [];
|
|
72700
72895
|
const shareFlags = [];
|
|
@@ -72749,6 +72944,9 @@ function parseLauncherArgv(argv) {
|
|
|
72749
72944
|
case "--provider":
|
|
72750
72945
|
provider = value2;
|
|
72751
72946
|
break;
|
|
72947
|
+
case "--claude-version":
|
|
72948
|
+
claudeVersion = value2;
|
|
72949
|
+
break;
|
|
72752
72950
|
case "--category":
|
|
72753
72951
|
categoryFlags.push(value2);
|
|
72754
72952
|
break;
|
|
@@ -72770,6 +72968,7 @@ function parseLauncherArgv(argv) {
|
|
|
72770
72968
|
...identity === void 0 ? {} : { identity },
|
|
72771
72969
|
...configProfile === void 0 ? {} : { configProfile },
|
|
72772
72970
|
...provider === void 0 ? {} : { provider },
|
|
72971
|
+
...claudeVersion === void 0 ? {} : { claudeVersion },
|
|
72773
72972
|
...native ? { native: true } : {},
|
|
72774
72973
|
...booleans,
|
|
72775
72974
|
categoryFlags,
|
|
@@ -72925,15 +73124,15 @@ var import_node_child_process4 = require("node:child_process");
|
|
|
72925
73124
|
|
|
72926
73125
|
// src/identityToken.ts
|
|
72927
73126
|
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
72928
|
-
var
|
|
73127
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
72929
73128
|
var TOKEN_FILE_MODE = 384;
|
|
72930
73129
|
var TOKEN_DIR_MODE = 448;
|
|
72931
73130
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
72932
73131
|
function identityTokenDir(paths) {
|
|
72933
|
-
return
|
|
73132
|
+
return import_node_path34.default.join(paths.root, "credentials");
|
|
72934
73133
|
}
|
|
72935
73134
|
function identityTokenPath(paths, identityName) {
|
|
72936
|
-
return
|
|
73135
|
+
return import_node_path34.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
72937
73136
|
}
|
|
72938
73137
|
function storeIdentityToken(paths, identityName, raw) {
|
|
72939
73138
|
const token = raw.trim();
|
|
@@ -72944,7 +73143,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
72944
73143
|
import_node_fs13.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
72945
73144
|
import_node_fs13.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
72946
73145
|
const target = identityTokenPath(paths, identityName);
|
|
72947
|
-
const temp =
|
|
73146
|
+
const temp = import_node_path34.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
72948
73147
|
import_node_fs13.default.writeFileSync(temp, `${token}
|
|
72949
73148
|
`, { mode: TOKEN_FILE_MODE });
|
|
72950
73149
|
import_node_fs13.default.renameSync(temp, target);
|
|
@@ -73083,7 +73282,7 @@ function subjectName(positional, provider) {
|
|
|
73083
73282
|
|
|
73084
73283
|
// src/doctorReport.ts
|
|
73085
73284
|
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
73086
|
-
var
|
|
73285
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
73087
73286
|
function refinePathShadow(status, ownExecutablePath, realpath) {
|
|
73088
73287
|
if (status.status !== "shadowed") {
|
|
73089
73288
|
return status;
|
|
@@ -73107,7 +73306,7 @@ function validateJson(schema, input2) {
|
|
|
73107
73306
|
return { ok: true, data: result.data };
|
|
73108
73307
|
}
|
|
73109
73308
|
function pushPathResolution(push, resolution) {
|
|
73110
|
-
const ownDir =
|
|
73309
|
+
const ownDir = import_node_path35.default.dirname(resolution.ownExecutablePath);
|
|
73111
73310
|
switch (resolution.agentShim.status) {
|
|
73112
73311
|
case "ok":
|
|
73113
73312
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -73173,24 +73372,24 @@ function pushProvider(push, entry, cacheEnv) {
|
|
|
73173
73372
|
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
73174
73373
|
return;
|
|
73175
73374
|
}
|
|
73176
|
-
const
|
|
73177
|
-
if (!
|
|
73178
|
-
push("provider", "fail", new ConfigValidationError(entry.path,
|
|
73375
|
+
const validated2 = ProviderSchema.safeParse(parsed);
|
|
73376
|
+
if (!validated2.success) {
|
|
73377
|
+
push("provider", "fail", new ConfigValidationError(entry.path, validated2.error.issues).message, entry.name);
|
|
73179
73378
|
return;
|
|
73180
73379
|
}
|
|
73181
|
-
const cache = cacheClause(cacheEnv, `provider ${entry.name}`,
|
|
73182
|
-
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(
|
|
73380
|
+
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
|
|
73381
|
+
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
|
|
73183
73382
|
}
|
|
73184
73383
|
function pushLegacyName(push, params) {
|
|
73185
73384
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
73186
|
-
if (legacyVariables.length === 0 &&
|
|
73385
|
+
if (legacyVariables.length === 0 && import_node_path35.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
73187
73386
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
73188
73387
|
return;
|
|
73189
73388
|
}
|
|
73190
73389
|
for (const name of legacyVariables) {
|
|
73191
73390
|
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);
|
|
73192
73391
|
}
|
|
73193
|
-
if (
|
|
73392
|
+
if (import_node_path35.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
73194
73393
|
push(
|
|
73195
73394
|
"legacy-name",
|
|
73196
73395
|
"warn",
|
|
@@ -73203,6 +73402,13 @@ function runDoctor(params) {
|
|
|
73203
73402
|
const push = (section, severity, message, subject) => {
|
|
73204
73403
|
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
73205
73404
|
};
|
|
73405
|
+
const checkPin = (section, subject, where, version2) => {
|
|
73406
|
+
const installed = params.installedClaudeVersions;
|
|
73407
|
+
if (version2 === void 0 || installed === void 0 || installed.includes(version2)) {
|
|
73408
|
+
return;
|
|
73409
|
+
}
|
|
73410
|
+
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);
|
|
73411
|
+
};
|
|
73206
73412
|
const ambient = detectAmbientCredential(params.env);
|
|
73207
73413
|
if (ambient === void 0) {
|
|
73208
73414
|
push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
|
|
@@ -73235,12 +73441,13 @@ function runDoctor(params) {
|
|
|
73235
73441
|
pushLegacyName(push, params);
|
|
73236
73442
|
const profileSources = /* @__PURE__ */ new Map();
|
|
73237
73443
|
for (const entry of params.configProfiles) {
|
|
73238
|
-
const
|
|
73239
|
-
if (!
|
|
73240
|
-
push("config-profile", "fail",
|
|
73444
|
+
const validated2 = validateJson(ConfigProfileSchema, entry);
|
|
73445
|
+
if (!validated2.ok) {
|
|
73446
|
+
push("config-profile", "fail", validated2.message, entry.name);
|
|
73241
73447
|
continue;
|
|
73242
73448
|
}
|
|
73243
|
-
profileSources.set(entry.name, { name: entry.name, profile:
|
|
73449
|
+
profileSources.set(entry.name, { name: entry.name, profile: validated2.data });
|
|
73450
|
+
checkPin("config-profile", entry.name, `Configuration profile "${entry.name}"`, validated2.data.launch?.claudeVersion);
|
|
73244
73451
|
}
|
|
73245
73452
|
const loadProfile = (name) => profileSources.get(name);
|
|
73246
73453
|
for (const name of profileSources.keys()) {
|
|
@@ -73256,13 +73463,13 @@ function runDoctor(params) {
|
|
|
73256
73463
|
const validProfileNames = new Set(profileSources.keys());
|
|
73257
73464
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
73258
73465
|
for (const entry of params.identities) {
|
|
73259
|
-
const
|
|
73260
|
-
if (!
|
|
73261
|
-
push("identity", "fail",
|
|
73466
|
+
const validated2 = validateJson(IdentitySchema, entry);
|
|
73467
|
+
if (!validated2.ok) {
|
|
73468
|
+
push("identity", "fail", validated2.message, entry.name);
|
|
73262
73469
|
continue;
|
|
73263
73470
|
}
|
|
73264
73471
|
validIdentityNames.add(entry.name);
|
|
73265
|
-
const defaultProfile =
|
|
73472
|
+
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
73266
73473
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
73267
73474
|
push(
|
|
73268
73475
|
"identity",
|
|
@@ -73271,7 +73478,7 @@ function runDoctor(params) {
|
|
|
73271
73478
|
entry.name
|
|
73272
73479
|
);
|
|
73273
73480
|
} else {
|
|
73274
|
-
const credential =
|
|
73481
|
+
const credential = validated2.data.credential;
|
|
73275
73482
|
const cache = credential === void 0 ? { text: "", unreadable: false } : cacheClause(params.credentialCache, `identity ${entry.name}`, credential);
|
|
73276
73483
|
push(
|
|
73277
73484
|
"identity",
|
|
@@ -73309,12 +73516,12 @@ function runDoctor(params) {
|
|
|
73309
73516
|
if (params.directoryRules.raw === void 0) {
|
|
73310
73517
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
73311
73518
|
} else {
|
|
73312
|
-
const
|
|
73313
|
-
if (!
|
|
73314
|
-
push("directory-rules", "fail",
|
|
73519
|
+
const validated2 = validateJson(DirectoryRulesSchema, params.directoryRules);
|
|
73520
|
+
if (!validated2.ok) {
|
|
73521
|
+
push("directory-rules", "fail", validated2.message);
|
|
73315
73522
|
} else {
|
|
73316
73523
|
push("directory-rules", "pass", `${params.directoryRules.path} is valid.`);
|
|
73317
|
-
for (const rule of
|
|
73524
|
+
for (const rule of validated2.data.rules) {
|
|
73318
73525
|
const badRefs = [];
|
|
73319
73526
|
if (rule.identity !== void 0 && !selectionExists(rule.identity)) {
|
|
73320
73527
|
badRefs.push(poolNameOf(rule.identity) === void 0 ? `identity "${rule.identity}"` : `pool "${poolNameOf(rule.identity) ?? ""}"`);
|
|
@@ -73322,6 +73529,7 @@ function runDoctor(params) {
|
|
|
73322
73529
|
if (rule.configProfile !== void 0 && !validProfileNames.has(rule.configProfile)) {
|
|
73323
73530
|
badRefs.push(`configuration profile "${rule.configProfile}"`);
|
|
73324
73531
|
}
|
|
73532
|
+
checkPin("directory-rules", rule.path, `Rule for "${rule.path}"`, rule.launch?.claudeVersion);
|
|
73325
73533
|
if (badRefs.length > 0) {
|
|
73326
73534
|
push("directory-rules", "fail", `Rule for "${rule.path}" names ${badRefs.join(" and ")}, which do not exist.`, rule.path);
|
|
73327
73535
|
} else {
|
|
@@ -73333,11 +73541,11 @@ function runDoctor(params) {
|
|
|
73333
73541
|
if (params.globalConfig.raw === void 0) {
|
|
73334
73542
|
push("global-config", "pass", "No config.json configured.");
|
|
73335
73543
|
} else {
|
|
73336
|
-
const
|
|
73337
|
-
if (!
|
|
73338
|
-
push("global-config", "fail",
|
|
73544
|
+
const validated2 = validateJson(GlobalConfigSchema, params.globalConfig);
|
|
73545
|
+
if (!validated2.ok) {
|
|
73546
|
+
push("global-config", "fail", validated2.message);
|
|
73339
73547
|
} else {
|
|
73340
|
-
const defaultProfile =
|
|
73548
|
+
const defaultProfile = validated2.data.defaultConfigProfile;
|
|
73341
73549
|
if (defaultProfile !== void 0 && !validProfileNames.has(defaultProfile)) {
|
|
73342
73550
|
push(
|
|
73343
73551
|
"global-config",
|
|
@@ -73346,27 +73554,28 @@ function runDoctor(params) {
|
|
|
73346
73554
|
);
|
|
73347
73555
|
} else {
|
|
73348
73556
|
push("global-config", "pass", `${params.globalConfig.path} is valid.`);
|
|
73557
|
+
checkPin("global-config", void 0, "config.json", validated2.data.launch?.claudeVersion);
|
|
73349
73558
|
}
|
|
73350
73559
|
}
|
|
73351
73560
|
}
|
|
73352
73561
|
if (params.categoriesLocal.raw === void 0) {
|
|
73353
73562
|
push("categories-local", "pass", "No categories.local.json configured.");
|
|
73354
73563
|
} else {
|
|
73355
|
-
const
|
|
73564
|
+
const validated2 = validateJson(CategoryClassificationOverlaySchema, params.categoriesLocal);
|
|
73356
73565
|
push(
|
|
73357
73566
|
"categories-local",
|
|
73358
|
-
|
|
73359
|
-
|
|
73567
|
+
validated2.ok ? "pass" : "fail",
|
|
73568
|
+
validated2.ok ? `${params.categoriesLocal.path} is valid.` : validated2.message
|
|
73360
73569
|
);
|
|
73361
73570
|
}
|
|
73362
73571
|
if (params.headroom.state.raw === void 0) {
|
|
73363
73572
|
push("headroom", "pass", "No headroom daemon has ever run; nothing to check.");
|
|
73364
73573
|
} else {
|
|
73365
|
-
const
|
|
73366
|
-
if (!
|
|
73367
|
-
push("headroom", "fail",
|
|
73574
|
+
const validated2 = validateJson(HeadroomStateSchema, params.headroom.state);
|
|
73575
|
+
if (!validated2.ok) {
|
|
73576
|
+
push("headroom", "fail", validated2.message);
|
|
73368
73577
|
} else {
|
|
73369
|
-
const state =
|
|
73578
|
+
const state = validated2.data;
|
|
73370
73579
|
const supervisorAlive = state.supervisorPid !== void 0 && params.headroom.isRunning(state.supervisorPid);
|
|
73371
73580
|
const headroomAlive = state.headroomPid !== void 0 && params.headroom.isRunning(state.headroomPid);
|
|
73372
73581
|
if (state.supervisorPid === void 0) {
|
|
@@ -73499,18 +73708,18 @@ function collectDoctorReport(params) {
|
|
|
73499
73708
|
const { paths } = params;
|
|
73500
73709
|
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() : [];
|
|
73501
73710
|
const identities = identityNames.map((name) => {
|
|
73502
|
-
const farmRoot =
|
|
73503
|
-
const identityPath =
|
|
73711
|
+
const farmRoot = import_node_path35.default.join(paths.identitiesDir, name);
|
|
73712
|
+
const identityPath = import_node_path35.default.join(farmRoot, "identity.json");
|
|
73504
73713
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
73505
73714
|
});
|
|
73506
73715
|
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() : [];
|
|
73507
73716
|
const configProfiles = profileNames.map((name) => {
|
|
73508
|
-
const profilePath =
|
|
73717
|
+
const profilePath = import_node_path35.default.join(paths.configProfilesDir, `${name}.json`);
|
|
73509
73718
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
73510
73719
|
});
|
|
73511
73720
|
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() : [];
|
|
73512
73721
|
const providers = providerNames.map((name) => {
|
|
73513
|
-
const providerPath =
|
|
73722
|
+
const providerPath = import_node_path35.default.join(paths.providersDir, `${name}.json`);
|
|
73514
73723
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
73515
73724
|
});
|
|
73516
73725
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -73522,12 +73731,12 @@ function collectDoctorReport(params) {
|
|
|
73522
73731
|
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
73523
73732
|
}
|
|
73524
73733
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
73525
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
73734
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path35.default.delimiter).filter((dir) => dir !== "");
|
|
73526
73735
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
73527
73736
|
findPathShadow({
|
|
73528
73737
|
pathDirs,
|
|
73529
|
-
targetDir:
|
|
73530
|
-
targetFilename:
|
|
73738
|
+
targetDir: import_node_path35.default.dirname(shimState.targetPath),
|
|
73739
|
+
targetFilename: import_node_path35.default.basename(shimState.targetPath),
|
|
73531
73740
|
findExecutableInDir
|
|
73532
73741
|
}),
|
|
73533
73742
|
shimState.targetPath,
|
|
@@ -73536,6 +73745,7 @@ function collectDoctorReport(params) {
|
|
|
73536
73745
|
const report = runDoctor({
|
|
73537
73746
|
env: params.env,
|
|
73538
73747
|
credentialCache: realCredentialCacheEnv(paths),
|
|
73748
|
+
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
73539
73749
|
identities,
|
|
73540
73750
|
configProfiles,
|
|
73541
73751
|
providers,
|
|
@@ -73551,7 +73761,7 @@ function collectDoctorReport(params) {
|
|
|
73551
73761
|
agentShim: refinePathShadow(
|
|
73552
73762
|
findPathShadow({
|
|
73553
73763
|
pathDirs,
|
|
73554
|
-
targetDir:
|
|
73764
|
+
targetDir: import_node_path35.default.dirname(ownExecutablePath),
|
|
73555
73765
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
73556
73766
|
findExecutableInDir
|
|
73557
73767
|
}),
|
|
@@ -73594,7 +73804,7 @@ function registerDoctorCommand(program2, deps) {
|
|
|
73594
73804
|
// src/headroom/commands.ts
|
|
73595
73805
|
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
73596
73806
|
var import_node_http2 = __toESM(require("node:http"), 1);
|
|
73597
|
-
var
|
|
73807
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
73598
73808
|
var import_node_child_process5 = require("node:child_process");
|
|
73599
73809
|
|
|
73600
73810
|
// src/frontdoor/realFrontDoorPort.ts
|
|
@@ -73740,11 +73950,11 @@ function probeFrontDoorSync(port, caPem) {
|
|
|
73740
73950
|
|
|
73741
73951
|
// src/frontdoor/trust.ts
|
|
73742
73952
|
var import_node_crypto14 = require("node:crypto");
|
|
73743
|
-
var
|
|
73953
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
73744
73954
|
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
73745
73955
|
function resolveTrustBundle(params) {
|
|
73746
73956
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs19 } = params;
|
|
73747
|
-
if (inherited === void 0 || inherited === "" ||
|
|
73957
|
+
if (inherited === void 0 || inherited === "" || import_node_path36.default.resolve(inherited) === import_node_path36.default.resolve(caCertFile)) {
|
|
73748
73958
|
return { path: caCertFile };
|
|
73749
73959
|
}
|
|
73750
73960
|
const caPem = fs19.readFileUtf8(caCertFile);
|
|
@@ -73762,7 +73972,7 @@ function resolveTrustBundle(params) {
|
|
|
73762
73972
|
}
|
|
73763
73973
|
const combined = `${inheritedPem.trimEnd()}
|
|
73764
73974
|
${caPem}`;
|
|
73765
|
-
const bundle =
|
|
73975
|
+
const bundle = import_node_path36.default.join(bundlesDir, `${(0, import_node_crypto14.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
73766
73976
|
if (!fs19.exists(bundle)) {
|
|
73767
73977
|
fs19.mkdirp(bundlesDir);
|
|
73768
73978
|
fs19.writeFileAtomic(bundle, combined);
|
|
@@ -73920,12 +74130,12 @@ function readInstalledHeadroomCommit() {
|
|
|
73920
74130
|
if (toolDir.status !== 0) {
|
|
73921
74131
|
return void 0;
|
|
73922
74132
|
}
|
|
73923
|
-
const libDir =
|
|
74133
|
+
const libDir = import_node_path37.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
73924
74134
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
73925
|
-
const sitePackages =
|
|
74135
|
+
const sitePackages = import_node_path37.default.join(libDir, python, "site-packages");
|
|
73926
74136
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
73927
74137
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
73928
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
74138
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path37.default.join(sitePackages, entry, "direct_url.json"));
|
|
73929
74139
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
73930
74140
|
}
|
|
73931
74141
|
}
|
|
@@ -74686,6 +74896,7 @@ Launching:
|
|
|
74686
74896
|
--category <category=bool> share or hide a category (repeatable)
|
|
74687
74897
|
--share <path>, --hide <path> share or hide one <category>/<path> entry (repeatable)
|
|
74688
74898
|
--[no-]skip-permissions, --[no-]remote-control, --[no-]headroom, --[no-]track-usage
|
|
74899
|
+
--claude-version <version> run exactly this installed Claude Code version (not the highest)
|
|
74689
74900
|
--[no-]wait with @pool:<name>, sleep until the earliest member returns when all are refused
|
|
74690
74901
|
--native run the real claude with nothing from agent-shim applied (no other launch flag allowed)
|
|
74691
74902
|
|
|
@@ -74731,7 +74942,7 @@ var import_node_crypto16 = require("node:crypto");
|
|
|
74731
74942
|
|
|
74732
74943
|
// src/launcher.ts
|
|
74733
74944
|
var import_node_crypto15 = require("node:crypto");
|
|
74734
|
-
var
|
|
74945
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
74735
74946
|
|
|
74736
74947
|
// src/launcher/cliOverride.ts
|
|
74737
74948
|
var InvalidCliCategoryError = class extends CliError {
|
|
@@ -74815,7 +75026,7 @@ function buildCliOverride(params) {
|
|
|
74815
75026
|
}
|
|
74816
75027
|
|
|
74817
75028
|
// src/launcher/flags.ts
|
|
74818
|
-
var
|
|
75029
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
74819
75030
|
|
|
74820
75031
|
// src/headroom/headers.ts
|
|
74821
75032
|
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
@@ -74885,7 +75096,7 @@ function buildEnv(params) {
|
|
|
74885
75096
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
74886
75097
|
let providerCustomHeaders;
|
|
74887
75098
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
74888
|
-
env.CLAUDE_CONFIG_DIR =
|
|
75099
|
+
env.CLAUDE_CONFIG_DIR = import_node_path38.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
74889
75100
|
}
|
|
74890
75101
|
if (params.provider !== void 0) {
|
|
74891
75102
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -75069,7 +75280,7 @@ function prepareLaunch(params) {
|
|
|
75069
75280
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
75070
75281
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
75071
75282
|
});
|
|
75072
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(
|
|
75283
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(import_node_path39.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
75073
75284
|
log.error(
|
|
75074
75285
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
75075
75286
|
);
|
|
@@ -75173,7 +75384,11 @@ function prepareLaunch(params) {
|
|
|
75173
75384
|
} else if (params.farm !== void 0) {
|
|
75174
75385
|
cascadeLaunch = flattenLayers(assembleCascade(params.farm.loadCascade(configProfileDecision.name, cliOverride)).layers, { home: params.farm.home }).launch;
|
|
75175
75386
|
}
|
|
75176
|
-
const
|
|
75387
|
+
const pinnedVersion = resolveClaudeVersion({ env, ...parsedArgv.claudeVersion === void 0 ? {} : { flag: parsedArgv.claudeVersion }, ...cascadeLaunch?.claudeVersion === void 0 ? {} : { cascade: cascadeLaunch.claudeVersion } });
|
|
75388
|
+
const discovered = params.resolveClaudeBinary(pinnedVersion === void 0 ? void 0 : { version: pinnedVersion.version });
|
|
75389
|
+
if (pinnedVersion !== void 0) {
|
|
75390
|
+
log.info(`agent-shim: Claude Code ${pinnedVersion.version} (pinned by ${pinnedVersion.source})`);
|
|
75391
|
+
}
|
|
75177
75392
|
const resolvedFlags = resolveLaunchFlags({
|
|
75178
75393
|
env,
|
|
75179
75394
|
// A pool pick reads the usage the front door records, so a pool launch records its own unless something says otherwise.
|
|
@@ -75319,6 +75534,7 @@ function otherLaunchFlags(parsed) {
|
|
|
75319
75534
|
...parsed.identity === void 0 ? [] : ["@<identity> / --identity"],
|
|
75320
75535
|
...parsed.configProfile === void 0 ? [] : ["--config-profile"],
|
|
75321
75536
|
...parsed.provider === void 0 ? [] : [parsed.provider === false ? "--no-provider" : "--provider"],
|
|
75537
|
+
...parsed.claudeVersion === void 0 ? [] : ["--claude-version"],
|
|
75322
75538
|
...parsed.headroom === void 0 ? [] : ["--[no-]headroom"],
|
|
75323
75539
|
...parsed.trackUsage === void 0 ? [] : ["--[no-]track-usage"],
|
|
75324
75540
|
...parsed.skipPermissions === void 0 ? [] : ["--[no-]skip-permissions"],
|
|
@@ -75410,7 +75626,7 @@ async function runClaude(argvOverride) {
|
|
|
75410
75626
|
// src/cli.ts
|
|
75411
75627
|
async function main() {
|
|
75412
75628
|
aliasLegacyEnv(process.env);
|
|
75413
|
-
const invokedName =
|
|
75629
|
+
const invokedName = import_node_path40.default.basename(process.argv[1] ?? "agent-shim");
|
|
75414
75630
|
if (isInvokedAsClaude(invokedName)) {
|
|
75415
75631
|
await runClaude();
|
|
75416
75632
|
return;
|