agent-shim 7.14.0 → 8.0.1
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/dist/cli.cjs +661 -572
- package/dist/index.cjs +226 -150
- package/dist/index.mjs +226 -150
- package/dist/types/index.d.ts +36 -18
- 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 path41 = require("path");
|
|
3252
3252
|
var os9 = require("os");
|
|
3253
3253
|
var homedir = os9.homedir();
|
|
3254
3254
|
var tmpdir = os9.tmpdir();
|
|
3255
3255
|
var { env } = process;
|
|
3256
3256
|
var macos = (name) => {
|
|
3257
|
-
const library =
|
|
3257
|
+
const library = path41.join(homedir, "Library");
|
|
3258
3258
|
return {
|
|
3259
|
-
data:
|
|
3260
|
-
config:
|
|
3261
|
-
cache:
|
|
3262
|
-
log:
|
|
3263
|
-
temp:
|
|
3259
|
+
data: path41.join(library, "Application Support", name),
|
|
3260
|
+
config: path41.join(library, "Preferences", name),
|
|
3261
|
+
cache: path41.join(library, "Caches", name),
|
|
3262
|
+
log: path41.join(library, "Logs", name),
|
|
3263
|
+
temp: path41.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 || path41.join(homedir, "AppData", "Roaming");
|
|
3268
|
+
const localAppData = env.LOCALAPPDATA || path41.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: path41.join(localAppData, name, "Data"),
|
|
3272
|
+
config: path41.join(appData, name, "Config"),
|
|
3273
|
+
cache: path41.join(localAppData, name, "Cache"),
|
|
3274
|
+
log: path41.join(localAppData, name, "Log"),
|
|
3275
|
+
temp: path41.join(tmpdir, name)
|
|
3276
3276
|
};
|
|
3277
3277
|
};
|
|
3278
3278
|
var linux = (name) => {
|
|
3279
|
-
const username =
|
|
3279
|
+
const username = path41.basename(homedir);
|
|
3280
3280
|
return {
|
|
3281
|
-
data:
|
|
3282
|
-
config:
|
|
3283
|
-
cache:
|
|
3281
|
+
data: path41.join(env.XDG_DATA_HOME || path41.join(homedir, ".local", "share"), name),
|
|
3282
|
+
config: path41.join(env.XDG_CONFIG_HOME || path41.join(homedir, ".config"), name),
|
|
3283
|
+
cache: path41.join(env.XDG_CACHE_HOME || path41.join(homedir, ".cache"), name),
|
|
3284
3284
|
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
3285
|
-
log:
|
|
3286
|
-
temp:
|
|
3285
|
+
log: path41.join(env.XDG_STATE_HOME || path41.join(homedir, ".local", "state"), name),
|
|
3286
|
+
temp: path41.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, path41) {
|
|
3355
|
+
if (typeof path41 === "string" && Object.prototype.hasOwnProperty.call(source, path41)) {
|
|
3356
|
+
return source[path41];
|
|
3357
3357
|
}
|
|
3358
|
-
const parsedPath = typeof
|
|
3358
|
+
const parsedPath = typeof path41 === "string" ? path41.split(".") : path41;
|
|
3359
3359
|
return parsedPath.reduce((previous, key) => {
|
|
3360
3360
|
if (previous === void 0) {
|
|
3361
3361
|
return previous;
|
|
@@ -3378,9 +3378,9 @@ var require_util = __commonJS({
|
|
|
3378
3378
|
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
|
|
3379
3379
|
}
|
|
3380
3380
|
exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
|
|
3381
|
-
async function isDirectory(
|
|
3381
|
+
async function isDirectory(path41) {
|
|
3382
3382
|
try {
|
|
3383
|
-
const stat = await fs_1.promises.stat(
|
|
3383
|
+
const stat = await fs_1.promises.stat(path41);
|
|
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(path41) {
|
|
3394
3394
|
try {
|
|
3395
|
-
const stat = fs_1.default.statSync(
|
|
3395
|
+
const stat = fs_1.default.statSync(path41);
|
|
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((path41, i2) => `${i2 + 1}. ${path41}`).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(path41) {
|
|
3682
3682
|
try {
|
|
3683
|
-
await promises_1.default.stat(
|
|
3683
|
+
await promises_1.default.stat(path41);
|
|
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(path41) {
|
|
3844
3844
|
try {
|
|
3845
|
-
fs_1.default.statSync(
|
|
3845
|
+
fs_1.default.statSync(path41);
|
|
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((path41) => path41.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 = (path41, { windows } = {}) => {
|
|
4378
|
+
const segs = path41.split(windows ? /[\\/]/ : "/");
|
|
4379
4379
|
const last = segs[segs.length - 1];
|
|
4380
4380
|
if (last === "") {
|
|
4381
4381
|
return segs[segs.length - 2];
|
|
@@ -6891,7 +6891,7 @@ var require_util2 = __commonJS({
|
|
|
6891
6891
|
var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
|
|
6892
6892
|
var { IncomingMessage } = require("node:http");
|
|
6893
6893
|
var stream = require("node:stream");
|
|
6894
|
-
var
|
|
6894
|
+
var net3 = require("node:net");
|
|
6895
6895
|
var { stringify } = require("node:querystring");
|
|
6896
6896
|
var { EventEmitter: EE } = require("node:events");
|
|
6897
6897
|
var timers = require_timers();
|
|
@@ -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 path41 = 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 (path41 && path41[0] !== "/") {
|
|
7011
|
+
path41 = `/${path41}`;
|
|
7012
7012
|
}
|
|
7013
|
-
return new URL(`${origin}${
|
|
7013
|
+
return new URL(`${origin}${path41}`);
|
|
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:`.");
|
|
@@ -7040,7 +7040,7 @@ var require_util2 = __commonJS({
|
|
|
7040
7040
|
}
|
|
7041
7041
|
assert2(typeof host === "string");
|
|
7042
7042
|
const servername = getHostname(host);
|
|
7043
|
-
if (
|
|
7043
|
+
if (net3.isIP(servername)) {
|
|
7044
7044
|
return "";
|
|
7045
7045
|
}
|
|
7046
7046
|
return servername;
|
|
@@ -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: path41, origin }
|
|
7835
7835
|
} = evt;
|
|
7836
|
-
debugLog("sending request to %s %s%s", method, origin,
|
|
7836
|
+
debugLog("sending request to %s %s%s", method, origin, path41);
|
|
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: path41, 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
|
+
path41,
|
|
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: path41, origin }
|
|
7871
7871
|
} = evt;
|
|
7872
|
-
debugLog("trailers received from %s %s%s", method, origin,
|
|
7872
|
+
debugLog("trailers received from %s %s%s", method, origin, path41);
|
|
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: path41, 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
|
+
path41,
|
|
7887
7887
|
error62.message
|
|
7888
7888
|
);
|
|
7889
7889
|
}
|
|
@@ -7998,7 +7998,7 @@ var require_request = __commonJS({
|
|
|
7998
7998
|
var kHandler = /* @__PURE__ */ Symbol("handler");
|
|
7999
7999
|
var Request = class {
|
|
8000
8000
|
constructor(origin, {
|
|
8001
|
-
path:
|
|
8001
|
+
path: path41,
|
|
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 path41 !== "string") {
|
|
8019
8019
|
throw new InvalidArgumentError2("path must be a string");
|
|
8020
|
-
} else if (
|
|
8020
|
+
} else if (path41[0] !== "/" && !(path41.startsWith("http://") || path41.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(path41)) {
|
|
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(path41, query) : path41;
|
|
8098
8098
|
this.origin = origin;
|
|
8099
8099
|
this.protocol = getProtocolFromUrlString(origin);
|
|
8100
8100
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -8703,7 +8703,7 @@ var require_dispatcher_base = __commonJS({
|
|
|
8703
8703
|
var require_connect = __commonJS({
|
|
8704
8704
|
"node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/core/connect.js"(exports2, module2) {
|
|
8705
8705
|
"use strict";
|
|
8706
|
-
var
|
|
8706
|
+
var net3 = require("node:net");
|
|
8707
8707
|
var assert2 = require("node:assert");
|
|
8708
8708
|
var util = require_util2();
|
|
8709
8709
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_errors();
|
|
@@ -8786,7 +8786,7 @@ var require_connect = __commonJS({
|
|
|
8786
8786
|
} else {
|
|
8787
8787
|
assert2(!httpSocket, "httpSocket can only be sent on TLS update");
|
|
8788
8788
|
port = port || 80;
|
|
8789
|
-
socket =
|
|
8789
|
+
socket = net3.connect({
|
|
8790
8790
|
highWaterMark: 64 * 1024,
|
|
8791
8791
|
// Same as nodejs fs streams.
|
|
8792
8792
|
...options,
|
|
@@ -13276,7 +13276,7 @@ var require_client_h1 = __commonJS({
|
|
|
13276
13276
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
13277
13277
|
}
|
|
13278
13278
|
function writeH1(client, request6) {
|
|
13279
|
-
const { method, path:
|
|
13279
|
+
const { method, path: path41, host, upgrade, blocking, reset } = request6;
|
|
13280
13280
|
let { body, headers, contentLength } = request6;
|
|
13281
13281
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
13282
13282
|
if (util.isFormDataLike(body)) {
|
|
@@ -13354,7 +13354,7 @@ var require_client_h1 = __commonJS({
|
|
|
13354
13354
|
if (socket.setTypeOfService) {
|
|
13355
13355
|
socket.setTypeOfService(request6.typeOfService);
|
|
13356
13356
|
}
|
|
13357
|
-
let header = `${method} ${
|
|
13357
|
+
let header = `${method} ${path41} HTTP/1.1\r
|
|
13358
13358
|
`;
|
|
13359
13359
|
if (typeof host === "string") {
|
|
13360
13360
|
header += `host: ${host}\r
|
|
@@ -14033,7 +14033,7 @@ var require_client_h2 = __commonJS({
|
|
|
14033
14033
|
const headersTimeout = request6.headersTimeout ?? client[kHeadersTimeout];
|
|
14034
14034
|
const bodyTimeout = request6.bodyTimeout ?? client[kBodyTimeout];
|
|
14035
14035
|
const session = client[kHTTP2Session];
|
|
14036
|
-
const { method, path:
|
|
14036
|
+
const { method, path: path41, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request6;
|
|
14037
14037
|
let { body } = request6;
|
|
14038
14038
|
if (upgrade != null && upgrade !== "websocket") {
|
|
14039
14039
|
util.errorRequest(client, request6, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -14102,7 +14102,7 @@ var require_client_h2 = __commonJS({
|
|
|
14102
14102
|
}
|
|
14103
14103
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
14104
14104
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
14105
|
-
headers[HTTP2_HEADER_PATH] =
|
|
14105
|
+
headers[HTTP2_HEADER_PATH] = path41;
|
|
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] = path41;
|
|
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") {
|
|
@@ -14463,8 +14463,8 @@ var require_client = __commonJS({
|
|
|
14463
14463
|
"node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/dispatcher/client.js"(exports2, module2) {
|
|
14464
14464
|
"use strict";
|
|
14465
14465
|
var assert2 = require("node:assert");
|
|
14466
|
-
var
|
|
14467
|
-
var
|
|
14466
|
+
var net3 = require("node:net");
|
|
14467
|
+
var http6 = require("node:http");
|
|
14468
14468
|
var util = require_util2();
|
|
14469
14469
|
var { ClientStats } = require_stats();
|
|
14470
14470
|
var { channels } = require_diagnostics();
|
|
@@ -14522,7 +14522,7 @@ var require_client = __commonJS({
|
|
|
14522
14522
|
var connectH1 = require_client_h1();
|
|
14523
14523
|
var connectH2 = require_client_h2();
|
|
14524
14524
|
var kClosedResolve = /* @__PURE__ */ Symbol("kClosedResolve");
|
|
14525
|
-
var getDefaultNodeMaxHeaderSize =
|
|
14525
|
+
var getDefaultNodeMaxHeaderSize = http6 && http6.maxHeaderSize && Number.isInteger(http6.maxHeaderSize) && http6.maxHeaderSize > 0 ? () => http6.maxHeaderSize : () => {
|
|
14526
14526
|
throw new InvalidArgumentError2("http module not available or http.maxHeaderSize invalid");
|
|
14527
14527
|
};
|
|
14528
14528
|
var noop = () => {
|
|
@@ -14618,7 +14618,7 @@ var require_client = __commonJS({
|
|
|
14618
14618
|
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
|
|
14619
14619
|
throw new InvalidArgumentError2("maxRequestsPerClient must be a positive number");
|
|
14620
14620
|
}
|
|
14621
|
-
if (localAddress != null && (typeof localAddress !== "string" ||
|
|
14621
|
+
if (localAddress != null && (typeof localAddress !== "string" || net3.isIP(localAddress) === 0)) {
|
|
14622
14622
|
throw new InvalidArgumentError2("localAddress must be valid string IP address");
|
|
14623
14623
|
}
|
|
14624
14624
|
if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
|
|
@@ -14798,7 +14798,7 @@ var require_client = __commonJS({
|
|
|
14798
14798
|
const idx = hostname3.indexOf("]");
|
|
14799
14799
|
assert2(idx !== -1);
|
|
14800
14800
|
const ip = hostname3.substring(1, idx);
|
|
14801
|
-
assert2(
|
|
14801
|
+
assert2(net3.isIPv6(ip));
|
|
14802
14802
|
hostname3 = ip;
|
|
14803
14803
|
}
|
|
14804
14804
|
client[kConnecting] = true;
|
|
@@ -15743,10 +15743,10 @@ var require_socks5_utils = __commonJS({
|
|
|
15743
15743
|
"node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/core/socks5-utils.js"(exports2, module2) {
|
|
15744
15744
|
"use strict";
|
|
15745
15745
|
var { Buffer: Buffer2 } = require("node:buffer");
|
|
15746
|
-
var
|
|
15746
|
+
var net3 = require("node:net");
|
|
15747
15747
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_errors();
|
|
15748
15748
|
function parseAddress(address) {
|
|
15749
|
-
if (
|
|
15749
|
+
if (net3.isIPv4(address)) {
|
|
15750
15750
|
const parts = address.split(".").map(Number);
|
|
15751
15751
|
return {
|
|
15752
15752
|
type: 1,
|
|
@@ -15754,7 +15754,7 @@ var require_socks5_utils = __commonJS({
|
|
|
15754
15754
|
buffer: Buffer2.from(parts)
|
|
15755
15755
|
};
|
|
15756
15756
|
}
|
|
15757
|
-
if (
|
|
15757
|
+
if (net3.isIPv6(address)) {
|
|
15758
15758
|
return {
|
|
15759
15759
|
type: 4,
|
|
15760
15760
|
// IPv6
|
|
@@ -15777,7 +15777,7 @@ var require_socks5_utils = __commonJS({
|
|
|
15777
15777
|
if (address.includes(".")) {
|
|
15778
15778
|
const lastColonIndex = address.lastIndexOf(":");
|
|
15779
15779
|
const ipv4Part = address.slice(lastColonIndex + 1);
|
|
15780
|
-
if (
|
|
15780
|
+
if (net3.isIPv4(ipv4Part)) {
|
|
15781
15781
|
const octets = ipv4Part.split(".").map(Number);
|
|
15782
15782
|
const high = (octets[0] << 8 | octets[1]).toString(16);
|
|
15783
15783
|
const low = (octets[2] << 8 | octets[3]).toString(16);
|
|
@@ -16496,10 +16496,10 @@ var require_proxy_agent = __commonJS({
|
|
|
16496
16496
|
};
|
|
16497
16497
|
const {
|
|
16498
16498
|
origin,
|
|
16499
|
-
path:
|
|
16499
|
+
path: path41 = "/",
|
|
16500
16500
|
headers = {}
|
|
16501
16501
|
} = opts;
|
|
16502
|
-
opts.path = origin +
|
|
16502
|
+
opts.path = origin + path41;
|
|
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(path41) {
|
|
18612
|
+
if (typeof path41 !== "string") {
|
|
18613
|
+
return path41;
|
|
18614
18614
|
}
|
|
18615
|
-
const pathSegments =
|
|
18615
|
+
const pathSegments = path41.split("?", 3);
|
|
18616
18616
|
if (pathSegments.length !== 2) {
|
|
18617
|
-
return
|
|
18617
|
+
return path41;
|
|
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: path41, method, body, headers }) {
|
|
18624
|
+
const pathMatch = matchValue(mockDispatch2.path, path41);
|
|
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: path41, ignoreTrailingSlash }) => {
|
|
18650
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path41)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path41), 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(path41) {
|
|
18690
|
+
while (path41.endsWith("/")) {
|
|
18691
|
+
path41 = path41.slice(0, -1);
|
|
18692
18692
|
}
|
|
18693
|
-
if (
|
|
18694
|
-
|
|
18693
|
+
if (path41.length === 0) {
|
|
18694
|
+
path41 = "/";
|
|
18695
18695
|
}
|
|
18696
|
-
return
|
|
18696
|
+
return path41;
|
|
18697
18697
|
}
|
|
18698
18698
|
function buildKey(opts) {
|
|
18699
|
-
const { path:
|
|
18699
|
+
const { path: path41, method, body, headers, query } = opts;
|
|
18700
18700
|
return {
|
|
18701
|
-
path:
|
|
18701
|
+
path: path41,
|
|
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: path41, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
19392
19392
|
Method: method,
|
|
19393
19393
|
Origin: origin,
|
|
19394
|
-
Path:
|
|
19394
|
+
Path: path41,
|
|
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 [path41, searchParams] = dispatchOpts.path.split("?");
|
|
19477
19477
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
19478
|
-
dispatchOpts.path = `${
|
|
19478
|
+
dispatchOpts.path = `${path41}?${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 path41 = filePath || this.#snapshotPath;
|
|
19880
|
+
if (!path41) {
|
|
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(path41), "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 ${path41}`, { 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 path41 = filePath || this.#snapshotPath;
|
|
19910
|
+
if (!path41) {
|
|
19911
19911
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
19912
19912
|
}
|
|
19913
|
-
const resolvedPath = resolve(
|
|
19913
|
+
const resolvedPath = resolve(path41);
|
|
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 path41 = search ? `${pathname}${search}` : pathname;
|
|
20546
|
+
const redirectUrlString = `${origin}${path41}`;
|
|
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 = path41;
|
|
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, path41) {
|
|
22314
22314
|
deleteCachedValue(store, {
|
|
22315
22315
|
...cacheKey,
|
|
22316
|
-
path:
|
|
22316
|
+
path: path41
|
|
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: path41
|
|
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 path41 = getSameOriginPath(cacheKey, values[i2]);
|
|
22336
|
+
if (path41 !== void 0) {
|
|
22337
|
+
deleteCachedUri(store, cacheKey, path41);
|
|
22338
22338
|
}
|
|
22339
22339
|
}
|
|
22340
22340
|
}
|
|
@@ -27334,11 +27334,11 @@ var require_fetch = __commonJS({
|
|
|
27334
27334
|
function dispatch({ body }) {
|
|
27335
27335
|
const url2 = requestCurrentURL(request6);
|
|
27336
27336
|
const agent = fetchParams.controller.dispatcher;
|
|
27337
|
-
const
|
|
27337
|
+
const path41 = 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 ? `${path41}?` : path41,
|
|
27342
27342
|
origin: url2.origin,
|
|
27343
27343
|
method: request6.method,
|
|
27344
27344
|
body: agent.isMockActive ? request6.body && (request6.body.source || request6.body.stream) : body,
|
|
@@ -28285,9 +28285,9 @@ var require_util5 = __commonJS({
|
|
|
28285
28285
|
}
|
|
28286
28286
|
}
|
|
28287
28287
|
}
|
|
28288
|
-
function validateCookiePath(
|
|
28289
|
-
for (let i2 = 0; i2 <
|
|
28290
|
-
const code =
|
|
28288
|
+
function validateCookiePath(path41) {
|
|
28289
|
+
for (let i2 = 0; i2 < path41.length; ++i2) {
|
|
28290
|
+
const code = path41.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 path41 = opts.path;
|
|
31639
31639
|
if (!opts.path.startsWith("/")) {
|
|
31640
|
-
|
|
31640
|
+
path41 = `/${path41}`;
|
|
31641
31641
|
}
|
|
31642
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
31642
|
+
url2 = new URL(util.parseOrigin(url2).origin + path41);
|
|
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_path39 = __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(path41) {
|
|
34866
|
+
if (path41 === void 0) return this._executableDir;
|
|
34867
|
+
this._executableDir = path41;
|
|
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, path41) {
|
|
36006
|
+
if (!path41)
|
|
36007
36007
|
return obj;
|
|
36008
|
-
return
|
|
36008
|
+
return path41.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(path41, 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(path41);
|
|
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, path41 = []) => {
|
|
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 }, [...path41, ...issue2.path]));
|
|
36806
36806
|
} else if (issue2.code === "invalid_key") {
|
|
36807
|
-
processError({ issues: issue2.issues }, [...
|
|
36807
|
+
processError({ issues: issue2.issues }, [...path41, ...issue2.path]);
|
|
36808
36808
|
} else if (issue2.code === "invalid_element") {
|
|
36809
|
-
processError({ issues: issue2.issues }, [...
|
|
36809
|
+
processError({ issues: issue2.issues }, [...path41, ...issue2.path]);
|
|
36810
36810
|
} else {
|
|
36811
|
-
const fullpath = [...
|
|
36811
|
+
const fullpath = [...path41, ...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, path41 = []) => {
|
|
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 }, [...path41, ...issue2.path]));
|
|
36855
36855
|
} else if (issue2.code === "invalid_key") {
|
|
36856
|
-
processError({ issues: issue2.issues }, [...
|
|
36856
|
+
processError({ issues: issue2.issues }, [...path41, ...issue2.path]);
|
|
36857
36857
|
} else if (issue2.code === "invalid_element") {
|
|
36858
|
-
processError({ issues: issue2.issues }, [...
|
|
36858
|
+
processError({ issues: issue2.issues }, [...path41, ...issue2.path]);
|
|
36859
36859
|
} else {
|
|
36860
|
-
const fullpath = [...
|
|
36860
|
+
const fullpath = [...path41, ...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 path41 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
36900
|
+
for (const seg of path41) {
|
|
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 path41 = ref.slice(1).split("/").filter(Boolean);
|
|
54003
|
+
if (path41.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 (path41[0] === defsKey) {
|
|
54008
|
+
const key = path41[1] === void 0 ? void 0 : decodeJSONPointerSegment(path41[1]);
|
|
54009
54009
|
if (!key || !ctx.defs[key]) {
|
|
54010
54010
|
throw new Error(`Reference not found: ${ref}`);
|
|
54011
54011
|
}
|
|
@@ -55052,7 +55052,6 @@ function applyPatch(filePath, schema, patch, options = {}) {
|
|
|
55052
55052
|
var import_node_child_process2 = require("node:child_process");
|
|
55053
55053
|
var import_node_crypto3 = require("node:crypto");
|
|
55054
55054
|
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
55055
|
-
var import_node_net = __toESM(require("node:net"), 1);
|
|
55056
55055
|
var import_node_os2 = __toESM(require("node:os"), 1);
|
|
55057
55056
|
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
55058
55057
|
var import_node_sea = require("node:sea");
|
|
@@ -55324,7 +55323,7 @@ var HeadroomGlobalConfigSchema = HeadroomGlobalConfigObjectSchema.superRefine((c
|
|
|
55324
55323
|
context.addIssue({ code: "custom", path: ["readMaturation"], message: "readMaturation needs rolloutChannel beta or dev" });
|
|
55325
55324
|
}
|
|
55326
55325
|
});
|
|
55327
|
-
var HEADROOM_DEFAULT_SOURCE = "headroom-ai[proxy] @ git+https://github.com/ExaDev/headroom@
|
|
55326
|
+
var HEADROOM_DEFAULT_SOURCE = "headroom-ai[proxy] @ git+https://github.com/ExaDev/headroom@53525f479f2f48e8ef6b08cf729601feab7d2382";
|
|
55328
55327
|
var HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES = 15;
|
|
55329
55328
|
var FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES = 15;
|
|
55330
55329
|
var FrontDoorGlobalConfigSchema = external_exports.strictObject({
|
|
@@ -55375,17 +55374,16 @@ var SHIPPED_CATEGORY_DEFAULTS = Object.freeze({
|
|
|
55375
55374
|
|
|
55376
55375
|
// src/headroom/state.ts
|
|
55377
55376
|
var HEADROOM_ANTHROPIC_UPSTREAM = "https://api.anthropic.com";
|
|
55377
|
+
var HEADROOM_STATE_SCHEMA_VERSION = 2;
|
|
55378
55378
|
var HeadroomStateSchema = external_exports.strictObject({
|
|
55379
55379
|
/** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
|
|
55380
55380
|
supervisorPid: external_exports.number().int().positive().optional(),
|
|
55381
55381
|
/** The headroom proxy process itself. Absent while the supervisor is between restarts. */
|
|
55382
55382
|
headroomPid: external_exports.number().int().positive().optional(),
|
|
55383
|
-
/** The loopback port the proxy listens on. Absent until the proxy has passed its readiness check, so "port is set" is itself the ready signal a launcher polls for. */
|
|
55384
|
-
port: external_exports.number().int().positive().optional(),
|
|
55385
55383
|
/**
|
|
55386
|
-
* The
|
|
55384
|
+
* The unix socket the proxy serves on, inside the owner-only socket directory. Absent until the proxy has passed its readiness check, so "socketPath is set" is itself the ready signal a launcher polls for. The front door reads it on every hop, so a restart (which keeps the generation's path) is followed without anything being relaunched.
|
|
55387
55385
|
*/
|
|
55388
|
-
|
|
55386
|
+
socketPath: external_exports.string().min(1).optional(),
|
|
55389
55387
|
/** The `headroom --version` output of the running install. */
|
|
55390
55388
|
version: external_exports.string().optional(),
|
|
55391
55389
|
/** Hash of the allowlist the running proxy was started with, so a provider-file change is detected as drift. */
|
|
@@ -55514,10 +55512,10 @@ function ensureHeadroom(params) {
|
|
|
55514
55512
|
for (; ; ) {
|
|
55515
55513
|
const state = readHeadroomState(ports.fs, paths.headroomStateFile);
|
|
55516
55514
|
if (state?.supervisorPid !== void 0 && ports.isRunning(state.supervisorPid)) {
|
|
55517
|
-
const daemonUp = state.
|
|
55518
|
-
if (daemonUp && state.
|
|
55515
|
+
const daemonUp = state.socketPath !== void 0 && state.headroomPid !== void 0 && ports.isRunning(state.headroomPid);
|
|
55516
|
+
if (daemonUp && state.socketPath !== void 0) {
|
|
55519
55517
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
55520
|
-
return {
|
|
55518
|
+
return { socketPath: state.socketPath };
|
|
55521
55519
|
}
|
|
55522
55520
|
if (state.lastError !== void 0) {
|
|
55523
55521
|
throw new HeadroomStartError(
|
|
@@ -55802,21 +55800,29 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
|
55802
55800
|
function spawnHeadroomSupervisor(paths, spawnDaemon) {
|
|
55803
55801
|
return spawnDaemon(paths, "__headroom-supervisor", paths.headroomLogPath);
|
|
55804
55802
|
}
|
|
55805
|
-
|
|
55806
|
-
|
|
55807
|
-
|
|
55808
|
-
|
|
55809
|
-
|
|
55810
|
-
|
|
55811
|
-
}
|
|
55812
|
-
|
|
55813
|
-
|
|
55814
|
-
|
|
55815
|
-
|
|
55816
|
-
|
|
55817
|
-
|
|
55818
|
-
|
|
55819
|
-
|
|
55803
|
+
var SOCKET_PERMISSION_BITS = 511;
|
|
55804
|
+
var realHeadroomSocketTrust = {
|
|
55805
|
+
platform: process.platform,
|
|
55806
|
+
currentUid: () => {
|
|
55807
|
+
if (process.getuid === void 0) {
|
|
55808
|
+
throw new Error(`no POSIX user id on ${process.platform}`);
|
|
55809
|
+
}
|
|
55810
|
+
return process.getuid();
|
|
55811
|
+
},
|
|
55812
|
+
lstat: (target) => {
|
|
55813
|
+
let stat;
|
|
55814
|
+
try {
|
|
55815
|
+
stat = import_node_fs3.default.lstatSync(target);
|
|
55816
|
+
} catch (error62) {
|
|
55817
|
+
if (isEnoent2(error62)) {
|
|
55818
|
+
return void 0;
|
|
55819
|
+
}
|
|
55820
|
+
throw error62;
|
|
55821
|
+
}
|
|
55822
|
+
const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : stat.isSocket() ? "socket" : "other";
|
|
55823
|
+
return { kind, uid: stat.uid, mode: stat.mode & SOCKET_PERMISSION_BITS };
|
|
55824
|
+
}
|
|
55825
|
+
};
|
|
55820
55826
|
function realHeadroomPort(paths, options) {
|
|
55821
55827
|
return {
|
|
55822
55828
|
ensure: () => {
|
|
@@ -55833,7 +55839,7 @@ function realHeadroomPort(paths, options) {
|
|
|
55833
55839
|
}
|
|
55834
55840
|
});
|
|
55835
55841
|
return {
|
|
55836
|
-
|
|
55842
|
+
socketPath: up.socketPath,
|
|
55837
55843
|
projectId: resolveGitRoot(realRunPort, options.cwd) ?? options.cwd
|
|
55838
55844
|
};
|
|
55839
55845
|
},
|
|
@@ -59648,7 +59654,8 @@ function buildLayoutPaths(root) {
|
|
|
59648
59654
|
categoriesLocalFile: import_node_path17.default.join(root, "categories.local.json"),
|
|
59649
59655
|
claudeShimFile: import_node_path17.default.join(root, "claude-shim.json"),
|
|
59650
59656
|
headroomDir: import_node_path17.default.join(root, "headroom"),
|
|
59651
|
-
headroomStateFile: import_node_path17.default.join(root, "headroom",
|
|
59657
|
+
headroomStateFile: import_node_path17.default.join(root, "headroom", `state.v${String(HEADROOM_STATE_SCHEMA_VERSION)}.json`),
|
|
59658
|
+
headroomSocketDir: import_node_path17.default.join(root, "headroom", "run"),
|
|
59652
59659
|
headroomLockFile: import_node_path17.default.join(root, "headroom", "start.lock"),
|
|
59653
59660
|
headroomSessionsDir: import_node_path17.default.join(root, "headroom", "sessions"),
|
|
59654
59661
|
logsDir: import_node_path17.default.join(root, "logs"),
|
|
@@ -61032,7 +61039,7 @@ function registerIdentityCommand(program2, deps) {
|
|
|
61032
61039
|
// package.json
|
|
61033
61040
|
var package_default = {
|
|
61034
61041
|
name: "agent-shim",
|
|
61035
|
-
version: "
|
|
61042
|
+
version: "8.0.1",
|
|
61036
61043
|
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.",
|
|
61037
61044
|
license: "MIT",
|
|
61038
61045
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -61493,11 +61500,11 @@ function providerBaseUrl(port, provider) {
|
|
|
61493
61500
|
function directOrigin(port) {
|
|
61494
61501
|
return `http://127.0.0.1:${String(port)}`;
|
|
61495
61502
|
}
|
|
61496
|
-
function parseProviderPath(
|
|
61497
|
-
if (!
|
|
61503
|
+
function parseProviderPath(path41) {
|
|
61504
|
+
if (!path41.startsWith(PROVIDER_PATH_PREFIX)) {
|
|
61498
61505
|
return void 0;
|
|
61499
61506
|
}
|
|
61500
|
-
const tail =
|
|
61507
|
+
const tail = path41.slice(PROVIDER_PATH_PREFIX.length);
|
|
61501
61508
|
const slash = tail.indexOf("/");
|
|
61502
61509
|
if (slash <= 0) {
|
|
61503
61510
|
return void 0;
|
|
@@ -61897,9 +61904,9 @@ function decoderFor(encoding) {
|
|
|
61897
61904
|
return void 0;
|
|
61898
61905
|
}
|
|
61899
61906
|
}
|
|
61900
|
-
function destinationOf(
|
|
61901
|
-
const scoped = parseProviderPath(
|
|
61902
|
-
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint:
|
|
61907
|
+
function destinationOf(path41) {
|
|
61908
|
+
const scoped = parseProviderPath(path41);
|
|
61909
|
+
return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path41 } : { provider: scoped.provider, endpoint: scoped.rest };
|
|
61903
61910
|
}
|
|
61904
61911
|
function buildRecord(event, context) {
|
|
61905
61912
|
const { scan } = context;
|
|
@@ -63302,7 +63309,7 @@ var import_node_path29 = __toESM(require("node:path"), 1);
|
|
|
63302
63309
|
|
|
63303
63310
|
// src/frontdoor/state.ts
|
|
63304
63311
|
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
63305
|
-
var FRONT_DOOR_PROTOCOL =
|
|
63312
|
+
var FRONT_DOOR_PROTOCOL = 2;
|
|
63306
63313
|
var FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1) });
|
|
63307
63314
|
var FrontDoorStateSchema = external_exports.strictObject({
|
|
63308
63315
|
/**
|
|
@@ -63768,9 +63775,84 @@ function registerCodexCommand(program2, deps) {
|
|
|
63768
63775
|
|
|
63769
63776
|
// src/frontdoor/commands.ts
|
|
63770
63777
|
var import_node_crypto11 = require("node:crypto");
|
|
63771
|
-
var
|
|
63778
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
63772
63779
|
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
63773
63780
|
|
|
63781
|
+
// src/headroom/socket.ts
|
|
63782
|
+
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
63783
|
+
var GROUP_OR_OTHER_BITS = 63;
|
|
63784
|
+
var OCTAL_RADIX2 = 8;
|
|
63785
|
+
var MODE_DIGITS = 4;
|
|
63786
|
+
var HEADROOM_SOCKET_SUFFIX = ".sock";
|
|
63787
|
+
var HEADROOM_SOCKET_NAME = /^(\d+)\.sock$/;
|
|
63788
|
+
var UNIX_SOCKET_PATH_MAX_BYTES = 103;
|
|
63789
|
+
var PLATFORMS_WITHOUT_UNIX_SOCKETS = ["win32"];
|
|
63790
|
+
function headroomSocketPath(paths, supervisorPid) {
|
|
63791
|
+
return import_node_path30.default.join(paths.headroomSocketDir, `${String(supervisorPid)}${HEADROOM_SOCKET_SUFFIX}`);
|
|
63792
|
+
}
|
|
63793
|
+
function platformRefusal(platform) {
|
|
63794
|
+
return PLATFORMS_WITHOUT_UNIX_SOCKETS.includes(platform) ? `headroom routing needs a unix domain socket, which headroom cannot serve on ${platform}; agent-shim never falls back to a TCP port for this hop` : void 0;
|
|
63795
|
+
}
|
|
63796
|
+
function ownerOnlyRefusal(label, target, stat, expected, uid) {
|
|
63797
|
+
if (stat === void 0) {
|
|
63798
|
+
return `the headroom ${label} ${target} does not exist`;
|
|
63799
|
+
}
|
|
63800
|
+
if (stat.kind === "symlink") {
|
|
63801
|
+
return `the headroom ${label} ${target} is a symlink; it must be the real ${expected === "dir" ? "directory" : "socket"}`;
|
|
63802
|
+
}
|
|
63803
|
+
if (stat.kind !== expected) {
|
|
63804
|
+
return `the headroom ${label} ${target} is not a ${expected === "dir" ? "directory" : "socket"}`;
|
|
63805
|
+
}
|
|
63806
|
+
if (stat.uid !== uid) {
|
|
63807
|
+
return `the headroom ${label} ${target} is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)})`;
|
|
63808
|
+
}
|
|
63809
|
+
if ((stat.mode & GROUP_OR_OTHER_BITS) !== 0) {
|
|
63810
|
+
return `the headroom ${label} ${target} has mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}, which lets other users reach it; it must be accessible to its owner only`;
|
|
63811
|
+
}
|
|
63812
|
+
return void 0;
|
|
63813
|
+
}
|
|
63814
|
+
function verifyHeadroomSocket(socketPath, ports) {
|
|
63815
|
+
const unsupported = platformRefusal(ports.platform);
|
|
63816
|
+
if (unsupported !== void 0) {
|
|
63817
|
+
return { refused: unsupported };
|
|
63818
|
+
}
|
|
63819
|
+
const uid = ports.currentUid();
|
|
63820
|
+
const directory = import_node_path30.default.dirname(socketPath);
|
|
63821
|
+
const refusal = ownerOnlyRefusal("socket directory", directory, ports.lstat(directory), "dir", uid) ?? ownerOnlyRefusal("socket", socketPath, ports.lstat(socketPath), "socket", uid);
|
|
63822
|
+
return refusal === void 0 ? { socketPath } : { refused: refusal };
|
|
63823
|
+
}
|
|
63824
|
+
function prepareHeadroomSocket(fs19, ports, paths, supervisorPid) {
|
|
63825
|
+
const unsupported = platformRefusal(ports.platform);
|
|
63826
|
+
if (unsupported !== void 0) {
|
|
63827
|
+
return { refused: unsupported };
|
|
63828
|
+
}
|
|
63829
|
+
const socketPath = headroomSocketPath(paths, supervisorPid);
|
|
63830
|
+
const length = Buffer.byteLength(socketPath, "utf8");
|
|
63831
|
+
if (length > UNIX_SOCKET_PATH_MAX_BYTES) {
|
|
63832
|
+
return {
|
|
63833
|
+
refused: `the headroom socket path ${socketPath} is ${String(length)} bytes, longer than the ${String(UNIX_SOCKET_PATH_MAX_BYTES)} a unix socket path can hold; set AGENT_SHIM_HOME to a shorter directory`
|
|
63834
|
+
};
|
|
63835
|
+
}
|
|
63836
|
+
if (ports.lstat(paths.headroomSocketDir)?.kind === "symlink") {
|
|
63837
|
+
return { refused: `the headroom socket directory ${paths.headroomSocketDir} is a symlink; it must be the real directory` };
|
|
63838
|
+
}
|
|
63839
|
+
fs19.mkdirPrivate(paths.headroomSocketDir);
|
|
63840
|
+
const refusal = ownerOnlyRefusal("socket directory", paths.headroomSocketDir, ports.lstat(paths.headroomSocketDir), "dir", ports.currentUid());
|
|
63841
|
+
return refusal === void 0 ? { socketPath } : { refused: refusal };
|
|
63842
|
+
}
|
|
63843
|
+
function pruneStaleHeadroomSockets(fs19, paths, isRunning) {
|
|
63844
|
+
const removed = [];
|
|
63845
|
+
for (const name of fs19.readdir(paths.headroomSocketDir)) {
|
|
63846
|
+
const pid = HEADROOM_SOCKET_NAME.exec(name)?.[1];
|
|
63847
|
+
if (pid === void 0 || isRunning(Number.parseInt(pid, 10))) {
|
|
63848
|
+
continue;
|
|
63849
|
+
}
|
|
63850
|
+
fs19.removeRecursive(import_node_path30.default.join(paths.headroomSocketDir, name));
|
|
63851
|
+
removed.push(name);
|
|
63852
|
+
}
|
|
63853
|
+
return removed;
|
|
63854
|
+
}
|
|
63855
|
+
|
|
63774
63856
|
// src/frontdoor/custody.ts
|
|
63775
63857
|
var CREDENTIAL_HEADERS = ["authorization", "x-api-key"];
|
|
63776
63858
|
var SEQUESTERED_CREDENTIAL = "agent-shim-sequestered";
|
|
@@ -63857,7 +63939,7 @@ function createDoorPipelines(deps) {
|
|
|
63857
63939
|
// The response middleware hook point, where usage tracking registers. The direct listener registers none, because its responses are consumed by headroom, not by the client: the entry the client sees is where observation belongs, and observing both would record every hopped request twice.
|
|
63858
63940
|
responseObservers: deps.responseObservers,
|
|
63859
63941
|
admit: admitLaunch(deps.isLiveToken),
|
|
63860
|
-
headroom: {
|
|
63942
|
+
headroom: { headroomSocket: deps.headroomSocket, hopSecret: deps.hopSecret, custody: deps.custody, log: deps.log },
|
|
63861
63943
|
now: deps.now,
|
|
63862
63944
|
log: deps.log
|
|
63863
63945
|
},
|
|
@@ -63908,7 +63990,7 @@ function isLiveCapability(presented, live) {
|
|
|
63908
63990
|
|
|
63909
63991
|
// src/frontdoor/capture.ts
|
|
63910
63992
|
var fs11 = __toESM(require("node:fs"), 1);
|
|
63911
|
-
var
|
|
63993
|
+
var path31 = __toESM(require("node:path"), 1);
|
|
63912
63994
|
var SECRET_HEADER_NAME = /authorization|cookie|token|secret|credential|api[-_]key/i;
|
|
63913
63995
|
var SECRET_JSON_KEY = /token|secret|password|credential|authorization|api[-_]key/i;
|
|
63914
63996
|
var SECRET_BODY_PATTERNS = [
|
|
@@ -63952,10 +64034,10 @@ function redactBody(chunk) {
|
|
|
63952
64034
|
}
|
|
63953
64035
|
var CAPTURE_ENV = "AGENT_SHIM_FRONTDOOR_CAPTURE";
|
|
63954
64036
|
function captureFromEnv(env, logsDir) {
|
|
63955
|
-
return env[CAPTURE_ENV] === "1" ? createFileCapture(
|
|
64037
|
+
return env[CAPTURE_ENV] === "1" ? createFileCapture(path31.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
|
|
63956
64038
|
}
|
|
63957
64039
|
function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
63958
|
-
fs11.mkdirSync(
|
|
64040
|
+
fs11.mkdirSync(path31.dirname(file2), { recursive: true });
|
|
63959
64041
|
let nextId = 0;
|
|
63960
64042
|
const append = (record2) => {
|
|
63961
64043
|
fs11.appendFileSync(file2, `${JSON.stringify({ ts: now().toISOString(), ...record2 })}
|
|
@@ -64049,7 +64131,7 @@ var fs12 = __toESM(require("node:fs"), 1);
|
|
|
64049
64131
|
|
|
64050
64132
|
// src/frontdoor/x509.ts
|
|
64051
64133
|
var import_node_crypto8 = require("node:crypto");
|
|
64052
|
-
var
|
|
64134
|
+
var import_node_net = __toESM(require("node:net"), 1);
|
|
64053
64135
|
var TAG_BOOLEAN = 1;
|
|
64054
64136
|
var TAG_INTEGER = 2;
|
|
64055
64137
|
var TAG_BIT_STRING = 3;
|
|
@@ -64175,7 +64257,7 @@ function ipv6Groups(address) {
|
|
|
64175
64257
|
const [head = "", tail] = address.split("::");
|
|
64176
64258
|
const split = (text2) => text2 === "" ? [] : text2.split(":");
|
|
64177
64259
|
const expand = (groups) => groups.flatMap((group) => {
|
|
64178
|
-
if (!
|
|
64260
|
+
if (!import_node_net.default.isIPv4(group)) {
|
|
64179
64261
|
return [Number.parseInt(group, HEX_RADIX)];
|
|
64180
64262
|
}
|
|
64181
64263
|
const [a2 = 0, b = 0, c2 = 0, d = 0] = group.split(".").map(Number);
|
|
@@ -64187,10 +64269,10 @@ function ipv6Groups(address) {
|
|
|
64187
64269
|
return [...before, ...filler, ...after];
|
|
64188
64270
|
}
|
|
64189
64271
|
function ipBytes(address) {
|
|
64190
|
-
if (
|
|
64272
|
+
if (import_node_net.default.isIPv4(address)) {
|
|
64191
64273
|
return Buffer.from(address.split(".").map(Number));
|
|
64192
64274
|
}
|
|
64193
|
-
if (!
|
|
64275
|
+
if (!import_node_net.default.isIPv6(address)) {
|
|
64194
64276
|
throw new Error(`${address} is not an IP address`);
|
|
64195
64277
|
}
|
|
64196
64278
|
const bytes = Buffer.alloc(IPV6_GROUPS * BYTES_PER_IPV6_GROUP);
|
|
@@ -64298,7 +64380,7 @@ function issueLeafCertificate(ca, names, notBefore, notAfter) {
|
|
|
64298
64380
|
const caCertificate = new import_node_crypto8.X509Certificate(ca.certPem);
|
|
64299
64381
|
const caPrivateKey = (0, import_node_crypto8.createPrivateKey)(ca.keyPem);
|
|
64300
64382
|
const { publicKey, privateKey } = rsaKeyPair();
|
|
64301
|
-
const generalNames = names.map((name) =>
|
|
64383
|
+
const generalNames = names.map((name) => import_node_net.default.isIP(name) === 0 ? tlv(TAG_GENERAL_NAME_DNS, Buffer.from(name, "ascii")) : tlv(TAG_GENERAL_NAME_IP, ipBytes(name)));
|
|
64302
64384
|
const der = assemble({
|
|
64303
64385
|
subjectPublicKey: publicKey,
|
|
64304
64386
|
subjectName: commonNameOnly(commonName),
|
|
@@ -64392,22 +64474,22 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64392
64474
|
};
|
|
64393
64475
|
writeFrontDoorState(fs19, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
|
|
64394
64476
|
const previousSticky = lastPort;
|
|
64395
|
-
let
|
|
64477
|
+
let http6;
|
|
64396
64478
|
try {
|
|
64397
|
-
|
|
64479
|
+
http6 = await ports.startProviderListener(lastPort);
|
|
64398
64480
|
} catch (error62) {
|
|
64399
64481
|
return fail(`could not start the provider listener: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64400
64482
|
}
|
|
64401
|
-
if (previousSticky !== void 0 &&
|
|
64402
|
-
ports.log(`agent-shim frontdoor supervisor: sticky port ${String(previousSticky)} was occupied; moving to ${String(
|
|
64483
|
+
if (previousSticky !== void 0 && http6.port !== previousSticky) {
|
|
64484
|
+
ports.log(`agent-shim frontdoor supervisor: sticky port ${String(previousSticky)} was occupied; moving to ${String(http6.port)} (sessions launched against the old port are stale until they relaunch)`);
|
|
64403
64485
|
}
|
|
64404
|
-
lastPort =
|
|
64486
|
+
lastPort = http6.port;
|
|
64405
64487
|
const previousStickyConnect = lastConnectPort;
|
|
64406
64488
|
let connect3;
|
|
64407
64489
|
try {
|
|
64408
64490
|
connect3 = await ports.startConnectListener(lastConnectPort);
|
|
64409
64491
|
} catch (error62) {
|
|
64410
|
-
await
|
|
64492
|
+
await http6.close();
|
|
64411
64493
|
return fail(`could not start the CONNECT surface: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64412
64494
|
}
|
|
64413
64495
|
if (previousStickyConnect !== void 0 && connect3.port !== previousStickyConnect) {
|
|
@@ -64420,16 +64502,16 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64420
64502
|
direct = await ports.startDirectListener(lastDirectPort);
|
|
64421
64503
|
} catch (error62) {
|
|
64422
64504
|
await connect3.close();
|
|
64423
|
-
await
|
|
64505
|
+
await http6.close();
|
|
64424
64506
|
return fail(`could not start the direct listener: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64425
64507
|
}
|
|
64426
64508
|
if (previousStickyDirect !== void 0 && direct.port !== previousStickyDirect) {
|
|
64427
64509
|
ports.log(`agent-shim frontdoor supervisor: sticky direct port ${String(previousStickyDirect)} was occupied; moving to ${String(direct.port)} (headroom must be restarted to admit the new address)`);
|
|
64428
64510
|
}
|
|
64429
64511
|
lastDirectPort = direct.port;
|
|
64430
|
-
writeFrontDoorState(fs19, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port:
|
|
64512
|
+
writeFrontDoorState(fs19, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http6.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
|
|
64431
64513
|
fs19.removeRecursive(paths.frontdoorLockFile);
|
|
64432
|
-
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(
|
|
64514
|
+
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http6.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
|
|
64433
64515
|
let idleSince;
|
|
64434
64516
|
let ticks = 0;
|
|
64435
64517
|
for (; ; ) {
|
|
@@ -64444,7 +64526,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64444
64526
|
ports.log(`agent-shim frontdoor supervisor: no sessions for ${String(idleShutdownMinutes)} minute(s); closing the front door and exiting`);
|
|
64445
64527
|
await direct.close();
|
|
64446
64528
|
await connect3.close();
|
|
64447
|
-
await
|
|
64529
|
+
await http6.close();
|
|
64448
64530
|
writeFrontDoorState(fs19, paths.frontdoorStateFile, sticky());
|
|
64449
64531
|
return 0;
|
|
64450
64532
|
}
|
|
@@ -64498,8 +64580,8 @@ function parseConnectTarget(authority) {
|
|
|
64498
64580
|
}
|
|
64499
64581
|
return { host, port };
|
|
64500
64582
|
}
|
|
64501
|
-
function servedByPipeline(
|
|
64502
|
-
return
|
|
64583
|
+
function servedByPipeline(path41) {
|
|
64584
|
+
return path41?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
64503
64585
|
}
|
|
64504
64586
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
64505
64587
|
"connection",
|
|
@@ -64836,7 +64918,7 @@ function realConnectCertStore(paths) {
|
|
|
64836
64918
|
var dns = __toESM(require("node:dns"), 1);
|
|
64837
64919
|
var http = __toESM(require("node:http"), 1);
|
|
64838
64920
|
var https = __toESM(require("node:https"), 1);
|
|
64839
|
-
var
|
|
64921
|
+
var net2 = __toESM(require("node:net"), 1);
|
|
64840
64922
|
var tls = __toESM(require("node:tls"), 1);
|
|
64841
64923
|
var UPSTREAM_LOCAL_PORT_START = 47900;
|
|
64842
64924
|
var UPSTREAM_LOCAL_PORT_END = 47919;
|
|
@@ -64847,8 +64929,8 @@ function upstreamLocalPort() {
|
|
|
64847
64929
|
return port;
|
|
64848
64930
|
}
|
|
64849
64931
|
var realAddressLookup = (host, _options, callback) => {
|
|
64850
|
-
if (
|
|
64851
|
-
callback(null, [{ address: host, family:
|
|
64932
|
+
if (net2.isIP(host) !== 0) {
|
|
64933
|
+
callback(null, [{ address: host, family: net2.isIP(host) }]);
|
|
64852
64934
|
return;
|
|
64853
64935
|
}
|
|
64854
64936
|
dns.resolve4(host, (error62, addresses) => {
|
|
@@ -64864,7 +64946,7 @@ var HTTP_PORT = 80;
|
|
|
64864
64946
|
function exemptDial(options, defaultPort) {
|
|
64865
64947
|
const host = typeof options.host === "string" ? options.host : "";
|
|
64866
64948
|
const port = typeof options.port === "number" ? options.port : defaultPort;
|
|
64867
|
-
return
|
|
64949
|
+
return net2.connect(net2.isIP(host) === 0 ? { host, port, localPort: upstreamLocalPort(), lookup: realAddressLookup } : { host, port });
|
|
64868
64950
|
}
|
|
64869
64951
|
function requestServername(options, fallback) {
|
|
64870
64952
|
return "servername" in options && typeof options.servername === "string" && options.servername !== "" ? options.servername : fallback;
|
|
@@ -64892,7 +64974,7 @@ function realConnectEffects() {
|
|
|
64892
64974
|
const tlsAgent = new ExemptTlsAgent();
|
|
64893
64975
|
const listenOnce = async (port, onSocket) => await new Promise((resolve, reject) => {
|
|
64894
64976
|
const accepted = /* @__PURE__ */ new Set();
|
|
64895
|
-
const server =
|
|
64977
|
+
const server = net2.createServer((socket) => {
|
|
64896
64978
|
accepted.add(socket);
|
|
64897
64979
|
socket.on("close", () => {
|
|
64898
64980
|
accepted.delete(socket);
|
|
@@ -64976,7 +65058,7 @@ function realConnectEffects() {
|
|
|
64976
65058
|
},
|
|
64977
65059
|
connectTlsUpstream: async (host, port, clientAlpn) => await new Promise((resolve, reject) => {
|
|
64978
65060
|
const dial = (localPort) => {
|
|
64979
|
-
const raw =
|
|
65061
|
+
const raw = net2.connect({ host, port, localPort, lookup: realAddressLookup });
|
|
64980
65062
|
return tls.connect({ socket: raw, servername: host, ...clientAlpn === void 0 ? {} : { ALPNProtocols: [clientAlpn] } });
|
|
64981
65063
|
};
|
|
64982
65064
|
const settle2 = (candidate) => {
|
|
@@ -64994,7 +65076,7 @@ function realConnectEffects() {
|
|
|
64994
65076
|
settle2(dial(upstreamLocalPort()));
|
|
64995
65077
|
}),
|
|
64996
65078
|
connectTcp: async (host, port) => await new Promise((resolve, reject) => {
|
|
64997
|
-
const socket =
|
|
65079
|
+
const socket = net2.connect({ host, port });
|
|
64998
65080
|
socket.once("connect", () => {
|
|
64999
65081
|
resolve(socket);
|
|
65000
65082
|
});
|
|
@@ -65202,13 +65284,17 @@ function responseHeaders(headers) {
|
|
|
65202
65284
|
return result;
|
|
65203
65285
|
}
|
|
65204
65286
|
async function applyHeadroomHop(request6, response, upstream, deps) {
|
|
65205
|
-
const
|
|
65206
|
-
if (
|
|
65207
|
-
response
|
|
65208
|
-
|
|
65209
|
-
|
|
65287
|
+
const target = deps.headroomSocket();
|
|
65288
|
+
if (target === void 0) {
|
|
65289
|
+
await answerBadGateway(response, "agent-shim front door: the headroom daemon is restarting");
|
|
65290
|
+
return;
|
|
65291
|
+
}
|
|
65292
|
+
if (target.refused !== void 0) {
|
|
65293
|
+
deps.log(`front door: refusing the headroom hop (${request6.method} ${new URL(request6.url, "http://127.0.0.1").pathname}): ${target.refused}`);
|
|
65294
|
+
await answerBadGateway(response, `agent-shim front door: refusing to send this request to headroom: ${target.refused}`);
|
|
65210
65295
|
return;
|
|
65211
65296
|
}
|
|
65297
|
+
const { socketPath } = target;
|
|
65212
65298
|
let headers = forwardableHeaders(request6.headers);
|
|
65213
65299
|
let hopId;
|
|
65214
65300
|
if (upstream !== void 0) {
|
|
@@ -65227,16 +65313,21 @@ async function applyHeadroomHop(request6, response, upstream, deps) {
|
|
|
65227
65313
|
}
|
|
65228
65314
|
headers[HOP_SECRET_HEADER] = deps.hopSecret;
|
|
65229
65315
|
try {
|
|
65230
|
-
await forwardThroughHeadroom(request6, response, {
|
|
65316
|
+
await forwardThroughHeadroom(request6, response, { socketPath, headers, log: deps.log });
|
|
65231
65317
|
} finally {
|
|
65232
65318
|
if (hopId !== void 0) {
|
|
65233
65319
|
deps.custody.release(hopId);
|
|
65234
65320
|
}
|
|
65235
65321
|
}
|
|
65236
65322
|
}
|
|
65323
|
+
async function answerBadGateway(response, message) {
|
|
65324
|
+
response.start(HTTP_BAD_GATEWAY2, { "Content-Type": "application/json" });
|
|
65325
|
+
await response.write(JSON.stringify({ type: "error", error: { type: "api_error", message } }));
|
|
65326
|
+
response.end();
|
|
65327
|
+
}
|
|
65237
65328
|
var HOP_AGENT = new http3.Agent({ keepAlive: false });
|
|
65238
65329
|
async function forwardThroughHeadroom(request6, response, target) {
|
|
65239
|
-
const {
|
|
65330
|
+
const { socketPath, headers } = target;
|
|
65240
65331
|
await new Promise((resolve) => {
|
|
65241
65332
|
const onUpstreamResponse = (upstreamResponse) => {
|
|
65242
65333
|
response.start(upstreamResponse.statusCode ?? HTTP_BAD_GATEWAY2, responseHeaders(upstreamResponse.headers));
|
|
@@ -65254,7 +65345,7 @@ async function forwardThroughHeadroom(request6, response, target) {
|
|
|
65254
65345
|
}
|
|
65255
65346
|
} catch (error62) {
|
|
65256
65347
|
if (!request6.signal.aborted) {
|
|
65257
|
-
target.log(`front door: headroom hop to
|
|
65348
|
+
target.log(`front door: headroom hop to ${socketPath} ended mid-stream (${request6.method} ${new URL(request6.url, "http://127.0.0.1").pathname}): ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
65258
65349
|
}
|
|
65259
65350
|
response.destroy();
|
|
65260
65351
|
}
|
|
@@ -65262,11 +65353,11 @@ async function forwardThroughHeadroom(request6, response, target) {
|
|
|
65262
65353
|
};
|
|
65263
65354
|
void stream();
|
|
65264
65355
|
};
|
|
65265
|
-
const hop = http3.request({
|
|
65356
|
+
const hop = http3.request({ socketPath, method: request6.method, path: request6.url, headers, agent: HOP_AGENT }, onUpstreamResponse);
|
|
65266
65357
|
hop.on("error", (error62) => {
|
|
65267
65358
|
const phase = response.headersSent ? "mid-stream" : "before the response started";
|
|
65268
65359
|
const code = "code" in error62 && typeof error62.code === "string" ? ` ${error62.code}` : "";
|
|
65269
|
-
target.log(`front door: headroom hop to
|
|
65360
|
+
target.log(`front door: headroom hop to ${socketPath} failed (${request6.method} ${new URL(request6.url, "http://127.0.0.1").pathname}, ${phase}): ${error62.message}${code}`);
|
|
65270
65361
|
if (!response.headersSent) {
|
|
65271
65362
|
response.start(HTTP_BAD_GATEWAY2, { "Content-Type": "application/json" });
|
|
65272
65363
|
void response.write(JSON.stringify({ type: "error", error: { type: "api_error", message: `agent-shim front door: the headroom daemon is unreachable (${error62.message})` } })).then(() => {
|
|
@@ -66257,8 +66348,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
66257
66348
|
request6.body.resume();
|
|
66258
66349
|
return;
|
|
66259
66350
|
}
|
|
66260
|
-
const
|
|
66261
|
-
const translated = { method: request6.method, path:
|
|
66351
|
+
const path41 = new URL(request6.url, "http://127.0.0.1").pathname;
|
|
66352
|
+
const translated = { method: request6.method, path: path41, body, signal: request6.signal };
|
|
66262
66353
|
const routed = await route(translated);
|
|
66263
66354
|
if (request6.signal.aborted) {
|
|
66264
66355
|
return;
|
|
@@ -66292,7 +66383,7 @@ function createPassthroughRoute(name, target) {
|
|
|
66292
66383
|
headroomUpstream: target.headroomUpstream,
|
|
66293
66384
|
serve: async (request6, response) => {
|
|
66294
66385
|
const incoming = new URL(request6.url, "http://127.0.0.1");
|
|
66295
|
-
const
|
|
66386
|
+
const path41 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
|
|
66296
66387
|
const headers = forwardableHeaders(request6.headers);
|
|
66297
66388
|
delete headers.host;
|
|
66298
66389
|
await new Promise((resolve) => {
|
|
@@ -66300,7 +66391,7 @@ function createPassthroughRoute(name, target) {
|
|
|
66300
66391
|
host: base.hostname,
|
|
66301
66392
|
port: base.port === "" ? void 0 : Number(base.port),
|
|
66302
66393
|
method: request6.method,
|
|
66303
|
-
path: `${basePath}${
|
|
66394
|
+
path: `${basePath}${path41}${incoming.search}`,
|
|
66304
66395
|
headers,
|
|
66305
66396
|
agent
|
|
66306
66397
|
};
|
|
@@ -66362,10 +66453,10 @@ function createProviderRouteResolver(deps) {
|
|
|
66362
66453
|
return route;
|
|
66363
66454
|
};
|
|
66364
66455
|
const resolve = (request6) => {
|
|
66365
|
-
const
|
|
66366
|
-
const scoped = parseProviderPath(
|
|
66456
|
+
const path41 = new URL(request6.url, "http://127.0.0.1").pathname;
|
|
66457
|
+
const scoped = parseProviderPath(path41);
|
|
66367
66458
|
if (scoped === void 0) {
|
|
66368
|
-
return
|
|
66459
|
+
return path41.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path41}` };
|
|
66369
66460
|
}
|
|
66370
66461
|
const { provider } = scoped;
|
|
66371
66462
|
let definition;
|
|
@@ -66457,8 +66548,8 @@ function zaiWindow(limit) {
|
|
|
66457
66548
|
var zaiQuotaAdapter = {
|
|
66458
66549
|
source: ZAI_SOURCE,
|
|
66459
66550
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === ZAI_HOST,
|
|
66460
|
-
fetch: async (apiKey,
|
|
66461
|
-
const response = await
|
|
66551
|
+
fetch: async (apiKey, http6, signal, nowMs) => {
|
|
66552
|
+
const response = await http6(ZAI_QUOTA_URL, { authorization: apiKey, accept: "application/json" }, signal);
|
|
66462
66553
|
if (response.status !== HTTP_OK) {
|
|
66463
66554
|
throw new ProviderQuotaError(ZAI_SOURCE, `answered HTTP ${String(response.status)}`);
|
|
66464
66555
|
}
|
|
@@ -66499,8 +66590,8 @@ var OpenRouterKeySchema = external_exports.object({
|
|
|
66499
66590
|
})
|
|
66500
66591
|
});
|
|
66501
66592
|
var OpenRouterCreditsSchema = external_exports.object({ data: external_exports.object({ total_credits: external_exports.number().nonnegative(), total_usage: external_exports.number().nonnegative() }) });
|
|
66502
|
-
async function openRouterGet(url2, schema, apiKey,
|
|
66503
|
-
const response = await
|
|
66593
|
+
async function openRouterGet(url2, schema, apiKey, http6, signal) {
|
|
66594
|
+
const response = await http6(url2, { authorization: `Bearer ${apiKey}`, accept: "application/json" }, signal);
|
|
66504
66595
|
if (response.status === HTTP_FORBIDDEN) {
|
|
66505
66596
|
return "forbidden";
|
|
66506
66597
|
}
|
|
@@ -66525,12 +66616,12 @@ function nextUtcMidnight(nowMs) {
|
|
|
66525
66616
|
var openRouterQuotaAdapter = {
|
|
66526
66617
|
source: OPENROUTER_SOURCE,
|
|
66527
66618
|
matches: (baseUrl) => URL.canParse(baseUrl) && new URL(baseUrl).hostname === OPENROUTER_HOST,
|
|
66528
|
-
fetch: async (apiKey,
|
|
66529
|
-
const key = await openRouterGet(OPENROUTER_KEY_URL, OpenRouterKeySchema, apiKey,
|
|
66619
|
+
fetch: async (apiKey, http6, signal, nowMs) => {
|
|
66620
|
+
const key = await openRouterGet(OPENROUTER_KEY_URL, OpenRouterKeySchema, apiKey, http6, signal);
|
|
66530
66621
|
if (key === "forbidden") {
|
|
66531
66622
|
throw new ProviderQuotaError(OPENROUTER_SOURCE, "/api/v1/key refused the key (HTTP 403)");
|
|
66532
66623
|
}
|
|
66533
|
-
const credits = await openRouterGet(OPENROUTER_CREDITS_URL, OpenRouterCreditsSchema, apiKey,
|
|
66624
|
+
const credits = await openRouterGet(OPENROUTER_CREDITS_URL, OpenRouterCreditsSchema, apiKey, http6, signal);
|
|
66534
66625
|
const { limit, limit_remaining: limitRemaining, limit_reset: limitReset, free_model_daily_requests: free, is_free_tier: isFreeTier } = key.data;
|
|
66535
66626
|
const windows = [];
|
|
66536
66627
|
if (limit !== null && limit > 0) {
|
|
@@ -66691,8 +66782,9 @@ function appendLog(paths, line) {
|
|
|
66691
66782
|
import_node_fs11.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
66692
66783
|
`);
|
|
66693
66784
|
}
|
|
66694
|
-
function
|
|
66695
|
-
|
|
66785
|
+
function headroomSocketTarget(fsPort, trust, paths) {
|
|
66786
|
+
const socketPath = readHeadroomState(fsPort, paths.headroomStateFile)?.socketPath;
|
|
66787
|
+
return socketPath === void 0 ? void 0 : verifyHeadroomSocket(socketPath, trust);
|
|
66696
66788
|
}
|
|
66697
66789
|
function realFrontDoorSupervisorPorts(paths) {
|
|
66698
66790
|
const log = (line) => {
|
|
@@ -66724,7 +66816,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66724
66816
|
isLiveToken,
|
|
66725
66817
|
responseObservers: [usageMiddleware],
|
|
66726
66818
|
now: () => Date.now(),
|
|
66727
|
-
|
|
66819
|
+
headroomSocket: () => headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, paths),
|
|
66728
66820
|
// The per-generation capability the direct listener demands: held only in this process's memory, so a loopback process that discovers the direct port still cannot use it.
|
|
66729
66821
|
hopSecret: (0, import_node_crypto11.randomUUID)(),
|
|
66730
66822
|
custody: createCredentialCustody(() => (0, import_node_crypto11.randomUUID)()),
|
|
@@ -66771,7 +66863,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66771
66863
|
const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
|
|
66772
66864
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
66773
66865
|
if (capture !== void 0) {
|
|
66774
|
-
log(`capture enabled, recording CONNECT targets and piped exchanges to ${
|
|
66866
|
+
log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path31.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
|
|
66775
66867
|
}
|
|
66776
66868
|
const server = await startConnectServer(
|
|
66777
66869
|
{
|
|
@@ -66827,13 +66919,13 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66827
66919
|
}
|
|
66828
66920
|
};
|
|
66829
66921
|
}
|
|
66830
|
-
function collectFrontDoorStatus(fsPort, paths, isRunning) {
|
|
66922
|
+
function collectFrontDoorStatus(fsPort, socketTrust, paths, isRunning) {
|
|
66831
66923
|
const state = readFrontDoorState(fsPort, paths.frontdoorStateFile) ?? {};
|
|
66832
66924
|
return {
|
|
66833
66925
|
state,
|
|
66834
66926
|
supervisorAlive: state.supervisorPid !== void 0 && isRunning(state.supervisorPid),
|
|
66835
66927
|
sessions: listFrontDoorSessions(fsPort, paths.frontdoorSessionsDir).map((session) => ({ ...session, alive: isRunning(session.pid) })),
|
|
66836
|
-
|
|
66928
|
+
headroomSocket: headroomSocketTarget(fsPort, socketTrust, paths),
|
|
66837
66929
|
logPath: paths.frontdoorLogPath,
|
|
66838
66930
|
logExists: fsPort.readFileUtf8(paths.frontdoorLogPath) !== void 0
|
|
66839
66931
|
};
|
|
@@ -66855,9 +66947,13 @@ function formatFrontDoorStatus(status, caCertPath) {
|
|
|
66855
66947
|
} else {
|
|
66856
66948
|
lines.push(`connect surface: listening on 127.0.0.1:${String(status.state.connectPort)}, CA ${caCertPath}`);
|
|
66857
66949
|
}
|
|
66858
|
-
|
|
66859
|
-
|
|
66860
|
-
)
|
|
66950
|
+
if (status.headroomSocket === void 0) {
|
|
66951
|
+
lines.push("headroom hop: the daemon is not serving (sessions asking for headroom fail until it is up)");
|
|
66952
|
+
} else if (status.headroomSocket.refused === void 0) {
|
|
66953
|
+
lines.push(`headroom hop: daemon on unix socket ${status.headroomSocket.socketPath}`);
|
|
66954
|
+
} else {
|
|
66955
|
+
lines.push(`headroom hop: REFUSING the daemon's socket (sessions asking for headroom fail until it is fixed): ${status.headroomSocket.refused}`);
|
|
66956
|
+
}
|
|
66861
66957
|
if (status.sessions.length === 0) {
|
|
66862
66958
|
lines.push("sessions: none");
|
|
66863
66959
|
} else {
|
|
@@ -66877,7 +66973,7 @@ function registerFrontDoorCommand(program2, deps) {
|
|
|
66877
66973
|
]);
|
|
66878
66974
|
withExamples(
|
|
66879
66975
|
frontdoor.command("status").description("Report the front door's supervisor, listeners, sessions, and last error. Read-only.").option("--json", "Print the status as JSON.").action((options) => {
|
|
66880
|
-
const status = collectFrontDoorStatus(realFarmFs, paths, realIsProcessRunning);
|
|
66976
|
+
const status = collectFrontDoorStatus(realFarmFs, realHeadroomSocketTrust, paths, realIsProcessRunning);
|
|
66881
66977
|
if (options.json === true) {
|
|
66882
66978
|
printJson(status);
|
|
66883
66979
|
return;
|
|
@@ -67179,15 +67275,15 @@ var import_node_child_process4 = require("node:child_process");
|
|
|
67179
67275
|
|
|
67180
67276
|
// src/identityToken.ts
|
|
67181
67277
|
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
67182
|
-
var
|
|
67278
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
67183
67279
|
var TOKEN_FILE_MODE = 384;
|
|
67184
67280
|
var TOKEN_DIR_MODE = 448;
|
|
67185
67281
|
var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
|
|
67186
67282
|
function identityTokenDir(paths) {
|
|
67187
|
-
return
|
|
67283
|
+
return import_node_path32.default.join(paths.root, "credentials");
|
|
67188
67284
|
}
|
|
67189
67285
|
function identityTokenPath(paths, identityName) {
|
|
67190
|
-
return
|
|
67286
|
+
return import_node_path32.default.join(identityTokenDir(paths), `${identityName}.token`);
|
|
67191
67287
|
}
|
|
67192
67288
|
function storeIdentityToken(paths, identityName, raw) {
|
|
67193
67289
|
const token = raw.trim();
|
|
@@ -67198,7 +67294,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
67198
67294
|
import_node_fs12.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
|
|
67199
67295
|
import_node_fs12.default.chmodSync(dir, TOKEN_DIR_MODE);
|
|
67200
67296
|
const target = identityTokenPath(paths, identityName);
|
|
67201
|
-
const temp =
|
|
67297
|
+
const temp = import_node_path32.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
|
|
67202
67298
|
import_node_fs12.default.writeFileSync(temp, `${token}
|
|
67203
67299
|
`, { mode: TOKEN_FILE_MODE });
|
|
67204
67300
|
import_node_fs12.default.renameSync(temp, target);
|
|
@@ -67208,7 +67304,7 @@ function storeIdentityToken(paths, identityName, raw) {
|
|
|
67208
67304
|
// src/realCredentialCache.ts
|
|
67209
67305
|
var import_node_child_process3 = require("node:child_process");
|
|
67210
67306
|
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
67211
|
-
var
|
|
67307
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
67212
67308
|
var KEYCHAIN_CACHE_SERVICE = "agent-shim-credential-cache";
|
|
67213
67309
|
var CACHE_DIR_MODE = 448;
|
|
67214
67310
|
var CACHE_FILE_MODE = 384;
|
|
@@ -67235,8 +67331,8 @@ function security(args, stdin2) {
|
|
|
67235
67331
|
return { status: result.status, stdout: result.stdout };
|
|
67236
67332
|
}
|
|
67237
67333
|
function createRealCredentialCache(root) {
|
|
67238
|
-
const dir =
|
|
67239
|
-
const filePath = (owner) =>
|
|
67334
|
+
const dir = import_node_path33.default.join(root, "credential-cache");
|
|
67335
|
+
const filePath = (owner) => import_node_path33.default.join(dir, cacheFileNameFor(owner));
|
|
67240
67336
|
return {
|
|
67241
67337
|
read(store, owner) {
|
|
67242
67338
|
if (store === "file") {
|
|
@@ -67415,7 +67511,7 @@ function subjectName(positional, provider) {
|
|
|
67415
67511
|
|
|
67416
67512
|
// src/doctorReport.ts
|
|
67417
67513
|
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
67418
|
-
var
|
|
67514
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
67419
67515
|
|
|
67420
67516
|
// src/headroom/source.ts
|
|
67421
67517
|
var GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
@@ -67466,7 +67562,7 @@ function validateJson(schema, input2) {
|
|
|
67466
67562
|
return { ok: true, data: result.data };
|
|
67467
67563
|
}
|
|
67468
67564
|
function pushPathResolution(push, resolution) {
|
|
67469
|
-
const ownDir =
|
|
67565
|
+
const ownDir = import_node_path34.default.dirname(resolution.ownExecutablePath);
|
|
67470
67566
|
switch (resolution.agentShim.status) {
|
|
67471
67567
|
case "ok":
|
|
67472
67568
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -67534,14 +67630,14 @@ function pushProvider(push, entry) {
|
|
|
67534
67630
|
}
|
|
67535
67631
|
function pushLegacyName(push, params) {
|
|
67536
67632
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
67537
|
-
if (legacyVariables.length === 0 &&
|
|
67633
|
+
if (legacyVariables.length === 0 && import_node_path34.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
67538
67634
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
67539
67635
|
return;
|
|
67540
67636
|
}
|
|
67541
67637
|
for (const name of legacyVariables) {
|
|
67542
67638
|
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);
|
|
67543
67639
|
}
|
|
67544
|
-
if (
|
|
67640
|
+
if (import_node_path34.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
67545
67641
|
push(
|
|
67546
67642
|
"legacy-name",
|
|
67547
67643
|
"warn",
|
|
@@ -67731,7 +67827,7 @@ function runDoctor(params) {
|
|
|
67731
67827
|
"warn",
|
|
67732
67828
|
`Headroom state names supervisor pid ${String(state.supervisorPid)}, which is not running; the next launch through headroom will start a replacement.`
|
|
67733
67829
|
);
|
|
67734
|
-
} else if (state.headroomPid === void 0 || state.
|
|
67830
|
+
} else if (state.headroomPid === void 0 || state.socketPath === void 0) {
|
|
67735
67831
|
push(
|
|
67736
67832
|
"headroom",
|
|
67737
67833
|
"warn",
|
|
@@ -67747,7 +67843,7 @@ function runDoctor(params) {
|
|
|
67747
67843
|
push(
|
|
67748
67844
|
"headroom",
|
|
67749
67845
|
"pass",
|
|
67750
|
-
`Headroom daemon is up on
|
|
67846
|
+
`Headroom daemon is up on unix socket ${state.socketPath} (supervisor ${String(state.supervisorPid)}, daemon ${String(state.headroomPid)}).`
|
|
67751
67847
|
);
|
|
67752
67848
|
}
|
|
67753
67849
|
if (state.lastError !== void 0 && supervisorAlive) {
|
|
@@ -67849,18 +67945,18 @@ function collectDoctorReport(params) {
|
|
|
67849
67945
|
const { paths } = params;
|
|
67850
67946
|
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() : [];
|
|
67851
67947
|
const identities = identityNames.map((name) => {
|
|
67852
|
-
const farmRoot =
|
|
67853
|
-
const identityPath =
|
|
67948
|
+
const farmRoot = import_node_path34.default.join(paths.identitiesDir, name);
|
|
67949
|
+
const identityPath = import_node_path34.default.join(farmRoot, "identity.json");
|
|
67854
67950
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
67855
67951
|
});
|
|
67856
67952
|
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() : [];
|
|
67857
67953
|
const configProfiles = profileNames.map((name) => {
|
|
67858
|
-
const profilePath =
|
|
67954
|
+
const profilePath = import_node_path34.default.join(paths.configProfilesDir, `${name}.json`);
|
|
67859
67955
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
67860
67956
|
});
|
|
67861
67957
|
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() : [];
|
|
67862
67958
|
const providers = providerNames.map((name) => {
|
|
67863
|
-
const providerPath =
|
|
67959
|
+
const providerPath = import_node_path34.default.join(paths.providersDir, `${name}.json`);
|
|
67864
67960
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
67865
67961
|
});
|
|
67866
67962
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -67872,12 +67968,12 @@ function collectDoctorReport(params) {
|
|
|
67872
67968
|
binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
67873
67969
|
}
|
|
67874
67970
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
67875
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
67971
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path34.default.delimiter).filter((dir) => dir !== "");
|
|
67876
67972
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
67877
67973
|
findPathShadow({
|
|
67878
67974
|
pathDirs,
|
|
67879
|
-
targetDir:
|
|
67880
|
-
targetFilename:
|
|
67975
|
+
targetDir: import_node_path34.default.dirname(shimState.targetPath),
|
|
67976
|
+
targetFilename: import_node_path34.default.basename(shimState.targetPath),
|
|
67881
67977
|
findExecutableInDir
|
|
67882
67978
|
}),
|
|
67883
67979
|
shimState.targetPath,
|
|
@@ -67900,7 +67996,7 @@ function collectDoctorReport(params) {
|
|
|
67900
67996
|
agentShim: refinePathShadow(
|
|
67901
67997
|
findPathShadow({
|
|
67902
67998
|
pathDirs,
|
|
67903
|
-
targetDir:
|
|
67999
|
+
targetDir: import_node_path34.default.dirname(ownExecutablePath),
|
|
67904
68000
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
67905
68001
|
findExecutableInDir
|
|
67906
68002
|
}),
|
|
@@ -67941,13 +68037,231 @@ function registerDoctorCommand(program2, deps) {
|
|
|
67941
68037
|
}
|
|
67942
68038
|
|
|
67943
68039
|
// src/headroom/commands.ts
|
|
67944
|
-
var
|
|
67945
|
-
var
|
|
67946
|
-
var
|
|
68040
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
68041
|
+
var import_node_http2 = __toESM(require("node:http"), 1);
|
|
68042
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
67947
68043
|
var import_node_child_process5 = require("node:child_process");
|
|
67948
68044
|
|
|
67949
|
-
// src/
|
|
68045
|
+
// src/frontdoor/realFrontDoorPort.ts
|
|
68046
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
68047
|
+
|
|
68048
|
+
// src/frontdoor/ensure.ts
|
|
67950
68049
|
var import_node_crypto12 = require("node:crypto");
|
|
68050
|
+
var FRONTDOOR_START_TIMEOUT_MS = 3e4;
|
|
68051
|
+
var FRONTDOOR_LAUNCHER_POLL_MS = 100;
|
|
68052
|
+
var FrontDoorStartError = class extends CliError {
|
|
68053
|
+
constructor(message) {
|
|
68054
|
+
super(message);
|
|
68055
|
+
this.name = "FrontDoorStartError";
|
|
68056
|
+
}
|
|
68057
|
+
};
|
|
68058
|
+
function ensureFrontDoor(params) {
|
|
68059
|
+
const { paths, ports } = params;
|
|
68060
|
+
const deadline = ports.now() + FRONTDOOR_START_TIMEOUT_MS;
|
|
68061
|
+
let spawned = false;
|
|
68062
|
+
let replaced = false;
|
|
68063
|
+
const distrusted = /* @__PURE__ */ new Set();
|
|
68064
|
+
let lastRejection;
|
|
68065
|
+
for (; ; ) {
|
|
68066
|
+
const state = readFrontDoorState(ports.fs, paths.frontdoorStateFile);
|
|
68067
|
+
const supervisorPid = state?.supervisorPid;
|
|
68068
|
+
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
68069
|
+
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
68070
|
+
const verdict = ports.verifyListener(state.port);
|
|
68071
|
+
if (verdict.ok && (state.protocol ?? 0) < FRONT_DOOR_PROTOCOL && !replaced) {
|
|
68072
|
+
ports.stopSupervisor(supervisorPid);
|
|
68073
|
+
while (ports.isRunning(supervisorPid)) {
|
|
68074
|
+
if (ports.now() >= deadline) {
|
|
68075
|
+
throw new FrontDoorStartError(`agent-shim: the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}) is older than this launcher (protocol ${String(FRONT_DOOR_PROTOCOL)}) and did not exit when asked. Daemon log: ${paths.frontdoorLogPath}`);
|
|
68076
|
+
}
|
|
68077
|
+
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
68078
|
+
}
|
|
68079
|
+
replaced = true;
|
|
68080
|
+
continue;
|
|
68081
|
+
}
|
|
68082
|
+
if (verdict.ok) {
|
|
68083
|
+
const token = (0, import_node_crypto12.randomUUID)();
|
|
68084
|
+
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token });
|
|
68085
|
+
return { port: state.port, connectPort: state.connectPort, token };
|
|
68086
|
+
}
|
|
68087
|
+
lastRejection = `the listener on 127.0.0.1:${String(state.port)} (recorded for pid ${String(supervisorPid)}) failed authentication: ${verdict.reason}`;
|
|
68088
|
+
if (spawned) {
|
|
68089
|
+
throw new FrontDoorStartError(`agent-shim: ${lastRejection}; refusing to send this session's credentials to it. Daemon log: ${paths.frontdoorLogPath}`);
|
|
68090
|
+
}
|
|
68091
|
+
distrusted.add(supervisorPid);
|
|
68092
|
+
continue;
|
|
68093
|
+
}
|
|
68094
|
+
if (state?.lastError !== void 0) {
|
|
68095
|
+
throw new FrontDoorStartError(`agent-shim: the front door reported a fatal error and is not serving: ${state.lastError} (daemon log: ${paths.frontdoorLogPath})`);
|
|
68096
|
+
}
|
|
68097
|
+
} else if (!spawned) {
|
|
68098
|
+
ports.fs.mkdirp(paths.frontdoorDir);
|
|
68099
|
+
const created = ports.fs.writeFileExclusive(paths.frontdoorLockFile, `${JSON.stringify({ pid: params.launcherPid, at: ports.now() })}
|
|
68100
|
+
`);
|
|
68101
|
+
if (created) {
|
|
68102
|
+
ports.spawnSupervisor(paths);
|
|
68103
|
+
spawned = true;
|
|
68104
|
+
} else {
|
|
68105
|
+
const lock = readStartLock(ports.fs, paths.frontdoorLockFile);
|
|
68106
|
+
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
68107
|
+
ports.fs.removeRecursive(paths.frontdoorLockFile);
|
|
68108
|
+
continue;
|
|
68109
|
+
}
|
|
68110
|
+
}
|
|
68111
|
+
}
|
|
68112
|
+
if (ports.now() >= deadline) {
|
|
68113
|
+
const lastError = state?.lastError;
|
|
68114
|
+
throw new FrontDoorStartError(
|
|
68115
|
+
`agent-shim: the front door did not become ready within ${String(FRONTDOOR_START_TIMEOUT_MS)}ms` + (lastError === void 0 ? "" : ` (last error: ${lastError})`) + (lastRejection === void 0 ? "" : ` (${lastRejection})`) + `. Daemon log: ${paths.frontdoorLogPath}`
|
|
68116
|
+
);
|
|
68117
|
+
}
|
|
68118
|
+
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
68119
|
+
}
|
|
68120
|
+
}
|
|
68121
|
+
|
|
68122
|
+
// src/frontdoor/probe.ts
|
|
68123
|
+
var import_node_worker_threads = require("node:worker_threads");
|
|
68124
|
+
var PROBE_TIMEOUT_MS = 2e3;
|
|
68125
|
+
var PROBE_WAIT_MARGIN_MS = 1e3;
|
|
68126
|
+
var REASON_BYTES = 1024;
|
|
68127
|
+
var HEADER_SLOTS = 2;
|
|
68128
|
+
var INT32_BYTES = 4;
|
|
68129
|
+
var VERDICT_PENDING = 0;
|
|
68130
|
+
var VERDICT_OK = 1;
|
|
68131
|
+
var VERDICT_FAILED = 2;
|
|
68132
|
+
var PROBE_SOURCE = `
|
|
68133
|
+
const { workerData } = require("node:worker_threads");
|
|
68134
|
+
const https = require("node:https");
|
|
68135
|
+
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
68136
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
68137
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
68138
|
+
let done = false;
|
|
68139
|
+
const finish = (verdict, message) => {
|
|
68140
|
+
if (done) return;
|
|
68141
|
+
done = true;
|
|
68142
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
68143
|
+
reason.set(bytes);
|
|
68144
|
+
Atomics.store(header, 1, bytes.length);
|
|
68145
|
+
Atomics.store(header, 0, verdict);
|
|
68146
|
+
Atomics.notify(header, 0);
|
|
68147
|
+
};
|
|
68148
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
68149
|
+
let body = "";
|
|
68150
|
+
response.setEncoding("utf8");
|
|
68151
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
68152
|
+
response.on("end", () => {
|
|
68153
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
68154
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
68155
|
+
});
|
|
68156
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
68157
|
+
});
|
|
68158
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
68159
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
68160
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
68161
|
+
`;
|
|
68162
|
+
function probeFrontDoorSync(port, caPem) {
|
|
68163
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
68164
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
68165
|
+
const worker = new import_node_worker_threads.Worker(PROBE_SOURCE, {
|
|
68166
|
+
eval: true,
|
|
68167
|
+
workerData: { port, ca: caPem, timeoutMs: PROBE_TIMEOUT_MS, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
68168
|
+
});
|
|
68169
|
+
worker.unref();
|
|
68170
|
+
try {
|
|
68171
|
+
const waited = Atomics.wait(header, 0, VERDICT_PENDING, PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS);
|
|
68172
|
+
const verdict = Atomics.load(header, 0);
|
|
68173
|
+
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
68174
|
+
return { ok: false, reason: `the probe did not finish within ${String(PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
68175
|
+
}
|
|
68176
|
+
if (verdict === VERDICT_OK) {
|
|
68177
|
+
return { ok: true };
|
|
68178
|
+
}
|
|
68179
|
+
const length = Atomics.load(header, 1);
|
|
68180
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
68181
|
+
} finally {
|
|
68182
|
+
void worker.terminate();
|
|
68183
|
+
}
|
|
68184
|
+
}
|
|
68185
|
+
|
|
68186
|
+
// src/frontdoor/trust.ts
|
|
68187
|
+
var import_node_crypto13 = require("node:crypto");
|
|
68188
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
68189
|
+
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
68190
|
+
function resolveTrustBundle(params) {
|
|
68191
|
+
const { caCertFile, bundlesDir, variable, inherited, fs: fs19 } = params;
|
|
68192
|
+
if (inherited === void 0 || inherited === "" || import_node_path35.default.resolve(inherited) === import_node_path35.default.resolve(caCertFile)) {
|
|
68193
|
+
return { path: caCertFile };
|
|
68194
|
+
}
|
|
68195
|
+
const caPem = fs19.readFileUtf8(caCertFile);
|
|
68196
|
+
let inheritedPem;
|
|
68197
|
+
try {
|
|
68198
|
+
inheritedPem = fs19.readFileUtf8(inherited);
|
|
68199
|
+
} catch (error62) {
|
|
68200
|
+
return {
|
|
68201
|
+
path: caCertFile,
|
|
68202
|
+
warning: `agent-shim: ${variable} names ${inherited}, which could not be read (${error62 instanceof Error ? error62.message : String(error62)}); the child trusts agent-shim's front-door CA on top of the system store, and nothing from that file`
|
|
68203
|
+
};
|
|
68204
|
+
}
|
|
68205
|
+
if (inheritedPem.includes(caPem.trim())) {
|
|
68206
|
+
return { path: inherited };
|
|
68207
|
+
}
|
|
68208
|
+
const combined = `${inheritedPem.trimEnd()}
|
|
68209
|
+
${caPem}`;
|
|
68210
|
+
const bundle = import_node_path35.default.join(bundlesDir, `${(0, import_node_crypto13.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
68211
|
+
if (!fs19.exists(bundle)) {
|
|
68212
|
+
fs19.mkdirp(bundlesDir);
|
|
68213
|
+
fs19.writeFileAtomic(bundle, combined);
|
|
68214
|
+
}
|
|
68215
|
+
return { path: bundle };
|
|
68216
|
+
}
|
|
68217
|
+
|
|
68218
|
+
// src/frontdoor/realFrontDoorPort.ts
|
|
68219
|
+
var realTrustBundleFs = {
|
|
68220
|
+
readFileUtf8: (file2) => import_node_fs15.default.readFileSync(file2, "utf8"),
|
|
68221
|
+
exists: (file2) => import_node_fs15.default.existsSync(file2),
|
|
68222
|
+
mkdirp: (dir) => {
|
|
68223
|
+
import_node_fs15.default.mkdirSync(dir, { recursive: true });
|
|
68224
|
+
},
|
|
68225
|
+
writeFileAtomic: (file2, contents) => {
|
|
68226
|
+
realFarmFs.writeFilePrivate(file2, contents);
|
|
68227
|
+
}
|
|
68228
|
+
};
|
|
68229
|
+
function realFrontDoorPort(paths, spawnDaemon) {
|
|
68230
|
+
return {
|
|
68231
|
+
ensure: (inheritedExtraCaCerts) => {
|
|
68232
|
+
const up = ensureFrontDoor({
|
|
68233
|
+
paths,
|
|
68234
|
+
launcherPid: process.pid,
|
|
68235
|
+
ports: {
|
|
68236
|
+
fs: realFarmFs,
|
|
68237
|
+
isRunning: realIsProcessRunning,
|
|
68238
|
+
now: () => Date.now(),
|
|
68239
|
+
sleep: realSleepSync,
|
|
68240
|
+
spawnSupervisor: (layout) => spawnDaemon(layout, "__frontdoor-supervisor", layout.frontdoorLogPath),
|
|
68241
|
+
stopSupervisor: (pid) => {
|
|
68242
|
+
process.kill(pid, "SIGTERM");
|
|
68243
|
+
},
|
|
68244
|
+
// Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
|
|
68245
|
+
verifyListener: (port) => probeFrontDoorSync(port, import_node_fs15.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
|
|
68246
|
+
}
|
|
68247
|
+
});
|
|
68248
|
+
const trust = resolveTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, variable: "NODE_EXTRA_CA_CERTS", inherited: inheritedExtraCaCerts, fs: realTrustBundleFs });
|
|
68249
|
+
return {
|
|
68250
|
+
port: up.port,
|
|
68251
|
+
connectPort: up.connectPort,
|
|
68252
|
+
trustBundlePath: trust.path,
|
|
68253
|
+
...trust.warning === void 0 ? {} : { trustWarning: trust.warning },
|
|
68254
|
+
sessionToken: up.token
|
|
68255
|
+
};
|
|
68256
|
+
},
|
|
68257
|
+
release: () => {
|
|
68258
|
+
removeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, process.pid);
|
|
68259
|
+
}
|
|
68260
|
+
};
|
|
68261
|
+
}
|
|
68262
|
+
|
|
68263
|
+
// src/headroom/settings.ts
|
|
68264
|
+
var import_node_crypto14 = require("node:crypto");
|
|
67951
68265
|
function settingsOf(config2) {
|
|
67952
68266
|
return {
|
|
67953
68267
|
...config2.mode === void 0 ? {} : { mode: config2.mode },
|
|
@@ -67972,7 +68286,7 @@ function settingsEnv(settings2) {
|
|
|
67972
68286
|
return settings2.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings2.rolloutChannel };
|
|
67973
68287
|
}
|
|
67974
68288
|
function hashSettings(settings2) {
|
|
67975
|
-
return (0,
|
|
68289
|
+
return (0, import_node_crypto14.createHash)("sha256").update(JSON.stringify([...settingsArgs(settings2), JSON.stringify(settingsEnv(settings2))])).digest("hex");
|
|
67976
68290
|
}
|
|
67977
68291
|
|
|
67978
68292
|
// src/headroom/supervisor.ts
|
|
@@ -68082,8 +68396,6 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68082
68396
|
return 0;
|
|
68083
68397
|
}
|
|
68084
68398
|
let installedSource = previousState?.installedSource;
|
|
68085
|
-
let lastPort = previousState?.lastPort;
|
|
68086
|
-
const sticky = () => lastPort === void 0 ? {} : { lastPort };
|
|
68087
68399
|
const ownsState = () => {
|
|
68088
68400
|
const owner = readHeadroomState(fs19, paths.headroomStateFile)?.supervisorPid;
|
|
68089
68401
|
return owner === void 0 || owner === ports.ownPid || !ports.isRunning(owner);
|
|
@@ -68096,7 +68408,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68096
68408
|
return true;
|
|
68097
68409
|
};
|
|
68098
68410
|
const fail = (message) => {
|
|
68099
|
-
if (writeOwnState({ lastError: message
|
|
68411
|
+
if (writeOwnState({ lastError: message })) {
|
|
68100
68412
|
fs19.removeRecursive(paths.headroomLockFile);
|
|
68101
68413
|
}
|
|
68102
68414
|
ports.log(`agent-shim headroom supervisor: ${message}`);
|
|
@@ -68119,11 +68431,17 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68119
68431
|
installedSource = config2.source;
|
|
68120
68432
|
return true;
|
|
68121
68433
|
};
|
|
68434
|
+
const socket = prepareHeadroomSocket(fs19, ports.socketTrust, paths, ports.ownPid);
|
|
68435
|
+
if (socket.refused !== void 0) {
|
|
68436
|
+
return fail(socket.refused);
|
|
68437
|
+
}
|
|
68438
|
+
const { socketPath } = socket;
|
|
68439
|
+
pruneStaleHeadroomSockets(fs19, paths, ports.isRunning);
|
|
68122
68440
|
if (!ensureInstalled()) {
|
|
68123
68441
|
return fail(`could not install headroom from ${config2.source}: install failed (is uv installed and on PATH?)`);
|
|
68124
68442
|
}
|
|
68125
68443
|
const version2 = ports.headroomVersion() ?? "unknown";
|
|
68126
|
-
writeOwnState({ supervisorPid: ports.ownPid, version: version2, installedSource
|
|
68444
|
+
writeOwnState({ supervisorPid: ports.ownPid, version: version2, installedSource });
|
|
68127
68445
|
ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: managing headroom on allowlist [${allowlistOf(ports).join(", ")}]`);
|
|
68128
68446
|
const orphanPid = previousState?.headroomPid;
|
|
68129
68447
|
if (orphanPid !== void 0 && ports.isRunning(orphanPid)) {
|
|
@@ -68149,7 +68467,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68149
68467
|
pruneDeadSessions(fs19, paths.headroomSessionsDir, ports.isRunning);
|
|
68150
68468
|
const ownsNow = ownsState();
|
|
68151
68469
|
if (!ownsNow && !superseded) {
|
|
68152
|
-
ports.log("agent-shim headroom supervisor: another supervisor now owns state
|
|
68470
|
+
ports.log("agent-shim headroom supervisor: another supervisor now owns the state file; serving this daemon's own sessions until they end");
|
|
68153
68471
|
}
|
|
68154
68472
|
superseded = !ownsNow;
|
|
68155
68473
|
const crashed = headroomPid !== void 0 && !ports.isRunning(headroomPid);
|
|
@@ -68162,8 +68480,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68162
68480
|
writeOwnState({
|
|
68163
68481
|
supervisorPid: ports.ownPid,
|
|
68164
68482
|
version: version2,
|
|
68165
|
-
installedSource
|
|
68166
|
-
...sticky()
|
|
68483
|
+
installedSource
|
|
68167
68484
|
});
|
|
68168
68485
|
}
|
|
68169
68486
|
if (consecutiveFailures >= HEADROOM_START_RETRY_BUDGET) {
|
|
@@ -68172,41 +68489,32 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68172
68489
|
if (installedSource !== config2.source && !ensureInstalled()) {
|
|
68173
68490
|
return fail(`could not install headroom from ${config2.source}: install failed (is uv installed and on PATH?)`);
|
|
68174
68491
|
}
|
|
68175
|
-
const
|
|
68176
|
-
const
|
|
68177
|
-
const pid = ports.spawnHeadroom(port, allowlist, config2.settings);
|
|
68178
|
-
const ready = await waitUntilReady(ports, port);
|
|
68492
|
+
const pid = ports.spawnHeadroom(socketPath, allowlist, config2.settings);
|
|
68493
|
+
const ready = await waitUntilReady(ports, socketPath);
|
|
68179
68494
|
if (ready) {
|
|
68180
68495
|
consecutiveFailures = 0;
|
|
68181
68496
|
headroomPid = pid;
|
|
68182
68497
|
runningHash = allowlistHash;
|
|
68183
68498
|
runningSettingsHash = settingsHash;
|
|
68184
|
-
lastPort = port;
|
|
68185
|
-
if (previousSticky !== void 0 && port !== previousSticky) {
|
|
68186
|
-
ports.log(
|
|
68187
|
-
`agent-shim headroom supervisor: sticky port ${String(previousSticky)} was occupied; moving to ${String(port)} (sessions launched against the old port are stale until they relaunch)`
|
|
68188
|
-
);
|
|
68189
|
-
}
|
|
68190
68499
|
const recorded = writeOwnState({
|
|
68191
68500
|
supervisorPid: ports.ownPid,
|
|
68192
68501
|
headroomPid: pid,
|
|
68193
|
-
|
|
68502
|
+
socketPath,
|
|
68194
68503
|
version: version2,
|
|
68195
68504
|
allowlistHash,
|
|
68196
68505
|
settingsHash,
|
|
68197
|
-
installedSource: config2.source
|
|
68198
|
-
...sticky()
|
|
68506
|
+
installedSource: config2.source
|
|
68199
68507
|
});
|
|
68200
68508
|
if (recorded) {
|
|
68201
68509
|
fs19.removeRecursive(paths.headroomLockFile);
|
|
68202
68510
|
}
|
|
68203
68511
|
idleSince = void 0;
|
|
68204
|
-
ports.log(`agent-shim headroom supervisor: headroom pid ${String(pid)} ready on
|
|
68512
|
+
ports.log(`agent-shim headroom supervisor: headroom pid ${String(pid)} ready on unix socket ${socketPath}`);
|
|
68205
68513
|
} else {
|
|
68206
68514
|
ports.stopProcess(pid);
|
|
68207
68515
|
consecutiveFailures += 1;
|
|
68208
68516
|
ports.log(
|
|
68209
|
-
`agent-shim headroom supervisor: headroom did not become ready on
|
|
68517
|
+
`agent-shim headroom supervisor: headroom did not become ready on unix socket ${socketPath} (attempt ${String(consecutiveFailures)} of ${String(HEADROOM_START_RETRY_BUDGET)})`
|
|
68210
68518
|
);
|
|
68211
68519
|
await ports.sleep(backoffForAttempt(consecutiveFailures));
|
|
68212
68520
|
continue;
|
|
@@ -68231,10 +68539,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
|
|
|
68231
68539
|
`agent-shim headroom supervisor: no sessions for ${String(config2.idleShutdownMinutes)} minute(s); stopping headroom and exiting`
|
|
68232
68540
|
);
|
|
68233
68541
|
ports.stopProcess(headroomPid);
|
|
68234
|
-
writeOwnState({
|
|
68235
|
-
version: version2,
|
|
68236
|
-
...sticky()
|
|
68237
|
-
});
|
|
68542
|
+
writeOwnState({ version: version2 });
|
|
68238
68543
|
return 0;
|
|
68239
68544
|
}
|
|
68240
68545
|
} else {
|
|
@@ -68251,10 +68556,10 @@ function currentHeadroomAllowlist(fs19, paths) {
|
|
|
68251
68556
|
function allowlistOf(ports) {
|
|
68252
68557
|
return currentHeadroomAllowlist(ports.fs, ports.paths);
|
|
68253
68558
|
}
|
|
68254
|
-
async function waitUntilReady(ports,
|
|
68559
|
+
async function waitUntilReady(ports, socketPath) {
|
|
68255
68560
|
const deadline = ports.now() + HEADROOM_READY_TIMEOUT_MS;
|
|
68256
68561
|
for (; ; ) {
|
|
68257
|
-
if (await ports.ready(
|
|
68562
|
+
if (await ports.ready(socketPath)) {
|
|
68258
68563
|
return true;
|
|
68259
68564
|
}
|
|
68260
68565
|
if (ports.now() >= deadline) {
|
|
@@ -68294,11 +68599,11 @@ function formatHeadroomStatus(status) {
|
|
|
68294
68599
|
`supervisor: pid ${String(status.state.supervisorPid)} (${status.supervisorAlive ? "alive" : "NOT running"})`
|
|
68295
68600
|
);
|
|
68296
68601
|
}
|
|
68297
|
-
if (status.state.headroomPid === void 0 || status.state.
|
|
68602
|
+
if (status.state.headroomPid === void 0 || status.state.socketPath === void 0) {
|
|
68298
68603
|
lines.push("headroom: not running");
|
|
68299
68604
|
} else {
|
|
68300
68605
|
lines.push(
|
|
68301
|
-
`headroom: pid ${String(status.state.headroomPid)} (${status.headroomAlive ? "alive" : "NOT running"}), listening on
|
|
68606
|
+
`headroom: pid ${String(status.state.headroomPid)} (${status.headroomAlive ? "alive" : "NOT running"}), listening on unix socket ${status.state.socketPath}` + (status.state.version === void 0 ? "" : `, ${status.state.version}`)
|
|
68302
68607
|
);
|
|
68303
68608
|
}
|
|
68304
68609
|
const drift = status.allowlistDrifted ? " (DRIFTED: current provider files differ from the running daemon's allowlist; a restart is pending)" : "";
|
|
@@ -68320,52 +68625,61 @@ function formatHeadroomStatus(status) {
|
|
|
68320
68625
|
lines.push(`daemon log: ${status.logPath}${status.logExists ? "" : " (not created yet)"}`);
|
|
68321
68626
|
return lines;
|
|
68322
68627
|
}
|
|
68323
|
-
async function realFreePort() {
|
|
68324
|
-
return await new Promise((resolve, reject) => {
|
|
68325
|
-
const server = import_node_net3.default.createServer();
|
|
68326
|
-
server.unref();
|
|
68327
|
-
server.on("error", reject);
|
|
68328
|
-
server.listen(0, "127.0.0.1", () => {
|
|
68329
|
-
const address = server.address();
|
|
68330
|
-
const port = typeof address === "object" && address !== null ? address.port : 0;
|
|
68331
|
-
server.close(() => {
|
|
68332
|
-
if (port === 0) {
|
|
68333
|
-
reject(new Error("could not reserve a loopback port"));
|
|
68334
|
-
return;
|
|
68335
|
-
}
|
|
68336
|
-
resolve(port);
|
|
68337
|
-
});
|
|
68338
|
-
});
|
|
68339
|
-
});
|
|
68340
|
-
}
|
|
68341
68628
|
var ownedHeadroom = /* @__PURE__ */ new Map();
|
|
68342
68629
|
var exitedHeadroom = /* @__PURE__ */ new Set();
|
|
68343
68630
|
var READY_FETCH_TIMEOUT_MS = 2e3;
|
|
68344
68631
|
function headroomPidRunning(pid) {
|
|
68345
68632
|
return !exitedHeadroom.has(pid) && realIsProcessRunning(pid);
|
|
68346
68633
|
}
|
|
68347
|
-
|
|
68634
|
+
var HEADROOM_CA_BUNDLE = "HEADROOM_CA_BUNDLE";
|
|
68635
|
+
function resolveHeadroomTrustBundle(params) {
|
|
68636
|
+
if (!params.fs.exists(params.caCertFile)) {
|
|
68637
|
+
return void 0;
|
|
68638
|
+
}
|
|
68639
|
+
return resolveTrustBundle({ ...params, variable: HEADROOM_CA_BUNDLE });
|
|
68640
|
+
}
|
|
68641
|
+
function headroomSpawnEnv(parentEnv, allowlist, settings2, trustBundlePath) {
|
|
68642
|
+
const inherited = { ...parentEnv };
|
|
68643
|
+
delete inherited.HEADROOM_HOST;
|
|
68644
|
+
delete inherited.HEADROOM_PORT;
|
|
68348
68645
|
return {
|
|
68349
|
-
...
|
|
68646
|
+
...inherited,
|
|
68350
68647
|
HEADROOM_ALLOWED_BASE_URLS: allowlist.join(","),
|
|
68351
68648
|
HEADROOM_HTTP2: parentEnv.HEADROOM_HTTP2 ?? "0",
|
|
68352
|
-
//
|
|
68353
|
-
...
|
|
68649
|
+
// The bundle already holds any inherited HEADROOM_CA_BUNDLE's certificates, so replacing the variable loses nothing. An inherited SSL_CERT_FILE or REQUESTS_CA_BUNDLE passes through untouched and, by headroom's own precedence, still replaces everything: an explicit choice in the parent environment wins.
|
|
68650
|
+
...trustBundlePath === void 0 ? {} : { [HEADROOM_CA_BUNDLE]: trustBundlePath },
|
|
68354
68651
|
...settingsEnv(settings2)
|
|
68355
68652
|
};
|
|
68356
68653
|
}
|
|
68654
|
+
function headroomProxyArgs(socketPath, settings2) {
|
|
68655
|
+
return ["proxy", "--uds", socketPath, ...settingsArgs(settings2)];
|
|
68656
|
+
}
|
|
68657
|
+
async function readyOverSocket(socketPath) {
|
|
68658
|
+
return await new Promise((resolve) => {
|
|
68659
|
+
const probe = import_node_http2.default.get({ socketPath, path: "/readyz", timeout: READY_FETCH_TIMEOUT_MS }, (response) => {
|
|
68660
|
+
response.resume();
|
|
68661
|
+
resolve(response.statusCode === HTTP_STATUS.ok);
|
|
68662
|
+
});
|
|
68663
|
+
probe.on("timeout", () => {
|
|
68664
|
+
probe.destroy();
|
|
68665
|
+
});
|
|
68666
|
+
probe.on("error", () => {
|
|
68667
|
+
resolve(false);
|
|
68668
|
+
});
|
|
68669
|
+
});
|
|
68670
|
+
}
|
|
68357
68671
|
var HEADROOM_TOOL_NAME = "headroom-ai";
|
|
68358
68672
|
function readInstalledHeadroomCommit() {
|
|
68359
68673
|
const toolDir = (0, import_node_child_process5.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
|
|
68360
68674
|
if (toolDir.status !== 0) {
|
|
68361
68675
|
return void 0;
|
|
68362
68676
|
}
|
|
68363
|
-
const libDir =
|
|
68677
|
+
const libDir = import_node_path36.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
|
|
68364
68678
|
for (const python of realFarmFs.readdir(libDir)) {
|
|
68365
|
-
const sitePackages =
|
|
68679
|
+
const sitePackages = import_node_path36.default.join(libDir, python, "site-packages");
|
|
68366
68680
|
for (const entry of realFarmFs.readdir(sitePackages)) {
|
|
68367
68681
|
if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
|
|
68368
|
-
const directUrl = realFarmFs.readFileUtf8(
|
|
68682
|
+
const directUrl = realFarmFs.readFileUtf8(import_node_path36.default.join(sitePackages, entry, "direct_url.json"));
|
|
68369
68683
|
return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
|
|
68370
68684
|
}
|
|
68371
68685
|
}
|
|
@@ -68385,18 +68699,21 @@ function realSupervisorPorts(paths) {
|
|
|
68385
68699
|
});
|
|
68386
68700
|
},
|
|
68387
68701
|
isRunning: headroomPidRunning,
|
|
68388
|
-
|
|
68389
|
-
isPortFree: realIsPortFree,
|
|
68702
|
+
socketTrust: realHeadroomSocketTrust,
|
|
68390
68703
|
readConfig: () => resolveSupervisorConfig(readGlobalConfig(paths)?.headroom ?? {}),
|
|
68391
|
-
spawnHeadroom: (
|
|
68392
|
-
const
|
|
68393
|
-
|
|
68394
|
-
|
|
68704
|
+
spawnHeadroom: (socketPath, allowlist, settings2) => {
|
|
68705
|
+
const trust = resolveHeadroomTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, inherited: process.env[HEADROOM_CA_BUNDLE], fs: realTrustBundleFs });
|
|
68706
|
+
import_node_fs16.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
68707
|
+
if (trust?.warning !== void 0) {
|
|
68708
|
+
import_node_fs16.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
|
|
68709
|
+
`);
|
|
68710
|
+
}
|
|
68711
|
+
const logFd = import_node_fs16.default.openSync(paths.headroomLogPath, "a");
|
|
68395
68712
|
try {
|
|
68396
|
-
const child = (0, import_node_child_process5.spawn)("headroom",
|
|
68713
|
+
const child = (0, import_node_child_process5.spawn)("headroom", headroomProxyArgs(socketPath, settings2), {
|
|
68397
68714
|
detached: true,
|
|
68398
68715
|
stdio: ["ignore", logFd, logFd],
|
|
68399
|
-
env: headroomSpawnEnv(process.env, allowlist, settings2,
|
|
68716
|
+
env: headroomSpawnEnv(process.env, allowlist, settings2, trust?.path)
|
|
68400
68717
|
});
|
|
68401
68718
|
if (child.pid === void 0) {
|
|
68402
68719
|
throw new Error("spawning headroom returned no pid");
|
|
@@ -68406,12 +68723,12 @@ function realSupervisorPorts(paths) {
|
|
|
68406
68723
|
child.once("exit", (code, signal) => {
|
|
68407
68724
|
ownedHeadroom.delete(pid);
|
|
68408
68725
|
exitedHeadroom.add(pid);
|
|
68409
|
-
|
|
68726
|
+
import_node_fs16.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
|
|
68410
68727
|
`);
|
|
68411
68728
|
});
|
|
68412
68729
|
return pid;
|
|
68413
68730
|
} finally {
|
|
68414
|
-
|
|
68731
|
+
import_node_fs16.default.closeSync(logFd);
|
|
68415
68732
|
}
|
|
68416
68733
|
},
|
|
68417
68734
|
stopProcess: (pid) => {
|
|
@@ -68424,31 +68741,24 @@ function realSupervisorPorts(paths) {
|
|
|
68424
68741
|
now: () => Date.now()
|
|
68425
68742
|
});
|
|
68426
68743
|
if (outcome === "still-running") {
|
|
68427
|
-
|
|
68744
|
+
import_node_fs16.default.appendFileSync(
|
|
68428
68745
|
paths.headroomLogPath,
|
|
68429
68746
|
`${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: pid ${String(pid)} survived SIGKILL within its grace; it is stuck uninterruptibly
|
|
68430
68747
|
`
|
|
68431
68748
|
);
|
|
68432
68749
|
}
|
|
68433
68750
|
},
|
|
68434
|
-
ready:
|
|
68435
|
-
try {
|
|
68436
|
-
const response = await fetch(`http://127.0.0.1:${String(port)}/readyz`, { signal: AbortSignal.timeout(READY_FETCH_TIMEOUT_MS) });
|
|
68437
|
-
return response.ok;
|
|
68438
|
-
} catch {
|
|
68439
|
-
return false;
|
|
68440
|
-
}
|
|
68441
|
-
},
|
|
68751
|
+
ready: readyOverSocket,
|
|
68442
68752
|
install: (spec) => {
|
|
68443
68753
|
const result = (0, import_node_child_process5.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8" });
|
|
68444
68754
|
if (result.error !== void 0) {
|
|
68445
68755
|
return { ok: false, error: `uv is not installed or not on PATH (${result.error.message})` };
|
|
68446
68756
|
}
|
|
68447
68757
|
if (result.stdout !== "") {
|
|
68448
|
-
|
|
68758
|
+
import_node_fs16.default.appendFileSync(paths.headroomLogPath, result.stdout);
|
|
68449
68759
|
}
|
|
68450
68760
|
if (result.stderr !== "") {
|
|
68451
|
-
|
|
68761
|
+
import_node_fs16.default.appendFileSync(paths.headroomLogPath, result.stderr);
|
|
68452
68762
|
}
|
|
68453
68763
|
return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
|
|
68454
68764
|
},
|
|
@@ -68458,8 +68768,8 @@ function realSupervisorPorts(paths) {
|
|
|
68458
68768
|
},
|
|
68459
68769
|
installedCommit: readInstalledHeadroomCommit,
|
|
68460
68770
|
log: (line) => {
|
|
68461
|
-
|
|
68462
|
-
|
|
68771
|
+
import_node_fs16.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
68772
|
+
import_node_fs16.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
68463
68773
|
`);
|
|
68464
68774
|
}
|
|
68465
68775
|
};
|
|
@@ -68470,7 +68780,7 @@ function registerHeadroomCommand(program2, deps) {
|
|
|
68470
68780
|
"agent-shim headroom status"
|
|
68471
68781
|
]);
|
|
68472
68782
|
withExamples(
|
|
68473
|
-
headroom.command("status").description("Report the headroom daemon's supervisor, process,
|
|
68783
|
+
headroom.command("status").description("Report the headroom daemon's supervisor, process, socket, sessions, and last error. Read-only.").option("--json", "Print the status as JSON.").action((options) => {
|
|
68474
68784
|
const status = collectHeadroomStatus(realFarmFs, paths, realIsProcessRunning);
|
|
68475
68785
|
if (options.json === true) {
|
|
68476
68786
|
printJson(status);
|
|
@@ -69172,227 +69482,9 @@ function buildProgram(deps) {
|
|
|
69172
69482
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
69173
69483
|
var import_node_crypto16 = require("node:crypto");
|
|
69174
69484
|
|
|
69175
|
-
// src/frontdoor/realFrontDoorPort.ts
|
|
69176
|
-
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
69177
|
-
|
|
69178
|
-
// src/frontdoor/ensure.ts
|
|
69179
|
-
var import_node_crypto13 = require("node:crypto");
|
|
69180
|
-
var FRONTDOOR_START_TIMEOUT_MS = 3e4;
|
|
69181
|
-
var FRONTDOOR_LAUNCHER_POLL_MS = 100;
|
|
69182
|
-
var FrontDoorStartError = class extends CliError {
|
|
69183
|
-
constructor(message) {
|
|
69184
|
-
super(message);
|
|
69185
|
-
this.name = "FrontDoorStartError";
|
|
69186
|
-
}
|
|
69187
|
-
};
|
|
69188
|
-
function ensureFrontDoor(params) {
|
|
69189
|
-
const { paths, ports } = params;
|
|
69190
|
-
const deadline = ports.now() + FRONTDOOR_START_TIMEOUT_MS;
|
|
69191
|
-
let spawned = false;
|
|
69192
|
-
let replaced = false;
|
|
69193
|
-
const distrusted = /* @__PURE__ */ new Set();
|
|
69194
|
-
let lastRejection;
|
|
69195
|
-
for (; ; ) {
|
|
69196
|
-
const state = readFrontDoorState(ports.fs, paths.frontdoorStateFile);
|
|
69197
|
-
const supervisorPid = state?.supervisorPid;
|
|
69198
|
-
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
69199
|
-
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
69200
|
-
const verdict = ports.verifyListener(state.port);
|
|
69201
|
-
if (verdict.ok && (state.protocol ?? 0) < FRONT_DOOR_PROTOCOL && !replaced) {
|
|
69202
|
-
ports.stopSupervisor(supervisorPid);
|
|
69203
|
-
while (ports.isRunning(supervisorPid)) {
|
|
69204
|
-
if (ports.now() >= deadline) {
|
|
69205
|
-
throw new FrontDoorStartError(`agent-shim: the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}) is older than this launcher (protocol ${String(FRONT_DOOR_PROTOCOL)}) and did not exit when asked. Daemon log: ${paths.frontdoorLogPath}`);
|
|
69206
|
-
}
|
|
69207
|
-
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
69208
|
-
}
|
|
69209
|
-
replaced = true;
|
|
69210
|
-
continue;
|
|
69211
|
-
}
|
|
69212
|
-
if (verdict.ok) {
|
|
69213
|
-
const token = (0, import_node_crypto13.randomUUID)();
|
|
69214
|
-
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token });
|
|
69215
|
-
return { port: state.port, connectPort: state.connectPort, token };
|
|
69216
|
-
}
|
|
69217
|
-
lastRejection = `the listener on 127.0.0.1:${String(state.port)} (recorded for pid ${String(supervisorPid)}) failed authentication: ${verdict.reason}`;
|
|
69218
|
-
if (spawned) {
|
|
69219
|
-
throw new FrontDoorStartError(`agent-shim: ${lastRejection}; refusing to send this session's credentials to it. Daemon log: ${paths.frontdoorLogPath}`);
|
|
69220
|
-
}
|
|
69221
|
-
distrusted.add(supervisorPid);
|
|
69222
|
-
continue;
|
|
69223
|
-
}
|
|
69224
|
-
if (state?.lastError !== void 0) {
|
|
69225
|
-
throw new FrontDoorStartError(`agent-shim: the front door reported a fatal error and is not serving: ${state.lastError} (daemon log: ${paths.frontdoorLogPath})`);
|
|
69226
|
-
}
|
|
69227
|
-
} else if (!spawned) {
|
|
69228
|
-
ports.fs.mkdirp(paths.frontdoorDir);
|
|
69229
|
-
const created = ports.fs.writeFileExclusive(paths.frontdoorLockFile, `${JSON.stringify({ pid: params.launcherPid, at: ports.now() })}
|
|
69230
|
-
`);
|
|
69231
|
-
if (created) {
|
|
69232
|
-
ports.spawnSupervisor(paths);
|
|
69233
|
-
spawned = true;
|
|
69234
|
-
} else {
|
|
69235
|
-
const lock = readStartLock(ports.fs, paths.frontdoorLockFile);
|
|
69236
|
-
if (lock === void 0 || !ports.isRunning(lock.pid)) {
|
|
69237
|
-
ports.fs.removeRecursive(paths.frontdoorLockFile);
|
|
69238
|
-
continue;
|
|
69239
|
-
}
|
|
69240
|
-
}
|
|
69241
|
-
}
|
|
69242
|
-
if (ports.now() >= deadline) {
|
|
69243
|
-
const lastError = state?.lastError;
|
|
69244
|
-
throw new FrontDoorStartError(
|
|
69245
|
-
`agent-shim: the front door did not become ready within ${String(FRONTDOOR_START_TIMEOUT_MS)}ms` + (lastError === void 0 ? "" : ` (last error: ${lastError})`) + (lastRejection === void 0 ? "" : ` (${lastRejection})`) + `. Daemon log: ${paths.frontdoorLogPath}`
|
|
69246
|
-
);
|
|
69247
|
-
}
|
|
69248
|
-
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
69249
|
-
}
|
|
69250
|
-
}
|
|
69251
|
-
|
|
69252
|
-
// src/frontdoor/probe.ts
|
|
69253
|
-
var import_node_worker_threads = require("node:worker_threads");
|
|
69254
|
-
var PROBE_TIMEOUT_MS = 2e3;
|
|
69255
|
-
var PROBE_WAIT_MARGIN_MS = 1e3;
|
|
69256
|
-
var REASON_BYTES = 1024;
|
|
69257
|
-
var HEADER_SLOTS = 2;
|
|
69258
|
-
var INT32_BYTES = 4;
|
|
69259
|
-
var VERDICT_PENDING = 0;
|
|
69260
|
-
var VERDICT_OK = 1;
|
|
69261
|
-
var VERDICT_FAILED = 2;
|
|
69262
|
-
var PROBE_SOURCE = `
|
|
69263
|
-
const { workerData } = require("node:worker_threads");
|
|
69264
|
-
const https = require("node:https");
|
|
69265
|
-
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
69266
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
69267
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
69268
|
-
let done = false;
|
|
69269
|
-
const finish = (verdict, message) => {
|
|
69270
|
-
if (done) return;
|
|
69271
|
-
done = true;
|
|
69272
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
69273
|
-
reason.set(bytes);
|
|
69274
|
-
Atomics.store(header, 1, bytes.length);
|
|
69275
|
-
Atomics.store(header, 0, verdict);
|
|
69276
|
-
Atomics.notify(header, 0);
|
|
69277
|
-
};
|
|
69278
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
69279
|
-
let body = "";
|
|
69280
|
-
response.setEncoding("utf8");
|
|
69281
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
69282
|
-
response.on("end", () => {
|
|
69283
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
69284
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
69285
|
-
});
|
|
69286
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
69287
|
-
});
|
|
69288
|
-
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
69289
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
69290
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
69291
|
-
`;
|
|
69292
|
-
function probeFrontDoorSync(port, caPem) {
|
|
69293
|
-
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
69294
|
-
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
69295
|
-
const worker = new import_node_worker_threads.Worker(PROBE_SOURCE, {
|
|
69296
|
-
eval: true,
|
|
69297
|
-
workerData: { port, ca: caPem, timeoutMs: PROBE_TIMEOUT_MS, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
69298
|
-
});
|
|
69299
|
-
worker.unref();
|
|
69300
|
-
try {
|
|
69301
|
-
const waited = Atomics.wait(header, 0, VERDICT_PENDING, PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS);
|
|
69302
|
-
const verdict = Atomics.load(header, 0);
|
|
69303
|
-
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
69304
|
-
return { ok: false, reason: `the probe did not finish within ${String(PROBE_TIMEOUT_MS + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
69305
|
-
}
|
|
69306
|
-
if (verdict === VERDICT_OK) {
|
|
69307
|
-
return { ok: true };
|
|
69308
|
-
}
|
|
69309
|
-
const length = Atomics.load(header, 1);
|
|
69310
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
69311
|
-
} finally {
|
|
69312
|
-
void worker.terminate();
|
|
69313
|
-
}
|
|
69314
|
-
}
|
|
69315
|
-
|
|
69316
|
-
// src/frontdoor/trust.ts
|
|
69317
|
-
var import_node_crypto14 = require("node:crypto");
|
|
69318
|
-
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
69319
|
-
var BUNDLE_NAME_HEX_DIGITS = 16;
|
|
69320
|
-
function resolveTrustBundle(params) {
|
|
69321
|
-
const { caCertFile, bundlesDir, inherited, fs: fs19 } = params;
|
|
69322
|
-
if (inherited === void 0 || inherited === "" || import_node_path35.default.resolve(inherited) === import_node_path35.default.resolve(caCertFile)) {
|
|
69323
|
-
return { path: caCertFile };
|
|
69324
|
-
}
|
|
69325
|
-
const caPem = fs19.readFileUtf8(caCertFile);
|
|
69326
|
-
let inheritedPem;
|
|
69327
|
-
try {
|
|
69328
|
-
inheritedPem = fs19.readFileUtf8(inherited);
|
|
69329
|
-
} catch (error62) {
|
|
69330
|
-
return {
|
|
69331
|
-
path: caCertFile,
|
|
69332
|
-
warning: `agent-shim: NODE_EXTRA_CA_CERTS names ${inherited}, which could not be read (${error62 instanceof Error ? error62.message : String(error62)}); the child trusts agent-shim's front-door CA on top of the system store, and nothing from that file`
|
|
69333
|
-
};
|
|
69334
|
-
}
|
|
69335
|
-
if (inheritedPem.includes(caPem.trim())) {
|
|
69336
|
-
return { path: inherited };
|
|
69337
|
-
}
|
|
69338
|
-
const combined = `${inheritedPem.trimEnd()}
|
|
69339
|
-
${caPem}`;
|
|
69340
|
-
const bundle = import_node_path35.default.join(bundlesDir, `${(0, import_node_crypto14.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
69341
|
-
if (!fs19.exists(bundle)) {
|
|
69342
|
-
fs19.mkdirp(bundlesDir);
|
|
69343
|
-
fs19.writeFileAtomic(bundle, combined);
|
|
69344
|
-
}
|
|
69345
|
-
return { path: bundle };
|
|
69346
|
-
}
|
|
69347
|
-
|
|
69348
|
-
// src/frontdoor/realFrontDoorPort.ts
|
|
69349
|
-
var realTrustBundleFs = {
|
|
69350
|
-
readFileUtf8: (file2) => import_node_fs16.default.readFileSync(file2, "utf8"),
|
|
69351
|
-
exists: (file2) => import_node_fs16.default.existsSync(file2),
|
|
69352
|
-
mkdirp: (dir) => {
|
|
69353
|
-
import_node_fs16.default.mkdirSync(dir, { recursive: true });
|
|
69354
|
-
},
|
|
69355
|
-
writeFileAtomic: (file2, contents) => {
|
|
69356
|
-
realFarmFs.writeFilePrivate(file2, contents);
|
|
69357
|
-
}
|
|
69358
|
-
};
|
|
69359
|
-
function realFrontDoorPort(paths, spawnDaemon) {
|
|
69360
|
-
return {
|
|
69361
|
-
ensure: (inheritedExtraCaCerts) => {
|
|
69362
|
-
const up = ensureFrontDoor({
|
|
69363
|
-
paths,
|
|
69364
|
-
launcherPid: process.pid,
|
|
69365
|
-
ports: {
|
|
69366
|
-
fs: realFarmFs,
|
|
69367
|
-
isRunning: realIsProcessRunning,
|
|
69368
|
-
now: () => Date.now(),
|
|
69369
|
-
sleep: realSleepSync,
|
|
69370
|
-
spawnSupervisor: (layout) => spawnDaemon(layout, "__frontdoor-supervisor", layout.frontdoorLogPath),
|
|
69371
|
-
stopSupervisor: (pid) => {
|
|
69372
|
-
process.kill(pid, "SIGTERM");
|
|
69373
|
-
},
|
|
69374
|
-
// Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
|
|
69375
|
-
verifyListener: (port) => probeFrontDoorSync(port, import_node_fs16.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
|
|
69376
|
-
}
|
|
69377
|
-
});
|
|
69378
|
-
const trust = resolveTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, inherited: inheritedExtraCaCerts, fs: realTrustBundleFs });
|
|
69379
|
-
return {
|
|
69380
|
-
port: up.port,
|
|
69381
|
-
connectPort: up.connectPort,
|
|
69382
|
-
trustBundlePath: trust.path,
|
|
69383
|
-
...trust.warning === void 0 ? {} : { trustWarning: trust.warning },
|
|
69384
|
-
sessionToken: up.token
|
|
69385
|
-
};
|
|
69386
|
-
},
|
|
69387
|
-
release: () => {
|
|
69388
|
-
removeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, process.pid);
|
|
69389
|
-
}
|
|
69390
|
-
};
|
|
69391
|
-
}
|
|
69392
|
-
|
|
69393
69485
|
// src/launcher.ts
|
|
69394
69486
|
var import_node_crypto15 = require("node:crypto");
|
|
69395
|
-
var
|
|
69487
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
69396
69488
|
|
|
69397
69489
|
// src/launcher/cliOverride.ts
|
|
69398
69490
|
var InvalidCliCategoryError = class extends CliError {
|
|
@@ -69476,7 +69568,7 @@ function buildCliOverride(params) {
|
|
|
69476
69568
|
}
|
|
69477
69569
|
|
|
69478
69570
|
// src/launcher/flags.ts
|
|
69479
|
-
var
|
|
69571
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
69480
69572
|
|
|
69481
69573
|
// src/headroom/headers.ts
|
|
69482
69574
|
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
@@ -69546,7 +69638,7 @@ function buildEnv(params) {
|
|
|
69546
69638
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
69547
69639
|
let providerCustomHeaders;
|
|
69548
69640
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
69549
|
-
env.CLAUDE_CONFIG_DIR =
|
|
69641
|
+
env.CLAUDE_CONFIG_DIR = import_node_path37.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
69550
69642
|
}
|
|
69551
69643
|
if (params.provider !== void 0) {
|
|
69552
69644
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -69567,9 +69659,6 @@ function buildEnv(params) {
|
|
|
69567
69659
|
env[variable] = value;
|
|
69568
69660
|
}
|
|
69569
69661
|
}
|
|
69570
|
-
if (params.headroom !== void 0) {
|
|
69571
|
-
env.HEADROOM_PROXY_URL = `http://127.0.0.1:${String(params.headroom.port)}`;
|
|
69572
|
-
}
|
|
69573
69662
|
if (params.frontdoor !== void 0) {
|
|
69574
69663
|
env.ANTHROPIC_CUSTOM_HEADERS = mergeAnthropicCustomHeaders(
|
|
69575
69664
|
[
|
|
@@ -69733,7 +69822,7 @@ function prepareLaunch(params) {
|
|
|
69733
69822
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
69734
69823
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
69735
69824
|
});
|
|
69736
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(
|
|
69825
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs19.readConfigFile(import_node_path38.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
69737
69826
|
log.error(
|
|
69738
69827
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
69739
69828
|
);
|
|
@@ -69869,7 +69958,7 @@ function prepareLaunch(params) {
|
|
|
69869
69958
|
if (resolvedFlags.headroom && headroomPort !== void 0) {
|
|
69870
69959
|
headroom = headroomPort.ensure();
|
|
69871
69960
|
const via = resolvedProvider === void 0 ? `OAuth via the door's CONNECT surface on 127.0.0.1:${String(frontDoor?.connectPort ?? 0)}` : `provider ${resolvedProvider.name}`;
|
|
69872
|
-
log.info(`agent-shim: routing through the front door on 127.0.0.1:${String(frontDoor?.port ?? 0)} with headroom on
|
|
69961
|
+
log.info(`agent-shim: routing through the front door on 127.0.0.1:${String(frontDoor?.port ?? 0)} with headroom on unix socket ${headroom.socketPath} (${via}, project ${headroom.projectId})`);
|
|
69873
69962
|
} else if (resolvedFlags.headroom) {
|
|
69874
69963
|
log.error("agent-shim: headroom routing was requested but this launcher has no headroom port wired; refusing to launch without it.");
|
|
69875
69964
|
proc.exit(1);
|
|
@@ -70033,7 +70122,7 @@ async function runClaude(argvOverride) {
|
|
|
70033
70122
|
// src/cli.ts
|
|
70034
70123
|
async function main() {
|
|
70035
70124
|
aliasLegacyEnv(process.env);
|
|
70036
|
-
const invokedName =
|
|
70125
|
+
const invokedName = import_node_path39.default.basename(process.argv[1] ?? "agent-shim");
|
|
70037
70126
|
if (isInvokedAsClaude(invokedName)) {
|
|
70038
70127
|
await runClaude();
|
|
70039
70128
|
return;
|