claude-use 11.88.0 → 11.88.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 +490 -322
- package/dist/index.cjs +774 -606
- package/dist/index.mjs +756 -588
- package/dist/types/index.d.ts +8 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -31830,6 +31830,53 @@ var init_supervisor = __esm({
|
|
|
31830
31830
|
}
|
|
31831
31831
|
});
|
|
31832
31832
|
|
|
31833
|
+
// src/sameDirectory.ts
|
|
31834
|
+
function systemErrorCode(error63) {
|
|
31835
|
+
return typeof error63 === "object" && error63 !== null && "code" in error63 && typeof error63.code === "string" ? error63.code : void 0;
|
|
31836
|
+
}
|
|
31837
|
+
function reachableStat(target) {
|
|
31838
|
+
try {
|
|
31839
|
+
return import_node_fs3.default.statSync(target, { throwIfNoEntry: false });
|
|
31840
|
+
} catch (error63) {
|
|
31841
|
+
const code = systemErrorCode(error63);
|
|
31842
|
+
if (code !== void 0 && UNREACHABLE_CODES.has(code)) {
|
|
31843
|
+
return void 0;
|
|
31844
|
+
}
|
|
31845
|
+
throw error63;
|
|
31846
|
+
}
|
|
31847
|
+
}
|
|
31848
|
+
function sameDirectory(first, second) {
|
|
31849
|
+
const a10 = reachableStat(first);
|
|
31850
|
+
const b = reachableStat(second);
|
|
31851
|
+
if (a10 === void 0 || b === void 0) {
|
|
31852
|
+
return false;
|
|
31853
|
+
}
|
|
31854
|
+
return a10.dev === b.dev && a10.ino === b.ino;
|
|
31855
|
+
}
|
|
31856
|
+
function caseSwapped(name) {
|
|
31857
|
+
return name.replace(/[A-Za-z]/gu, (letter) => letter === letter.toLowerCase() ? letter.toUpperCase() : letter.toLowerCase());
|
|
31858
|
+
}
|
|
31859
|
+
function ignoresCase(directory) {
|
|
31860
|
+
if (!import_node_fs3.default.existsSync(directory)) {
|
|
31861
|
+
return false;
|
|
31862
|
+
}
|
|
31863
|
+
const probe = import_node_fs3.default.mkdtempSync(import_node_path11.default.join(directory, ".case-probe-"));
|
|
31864
|
+
try {
|
|
31865
|
+
return sameDirectory(probe, import_node_path11.default.join(directory, caseSwapped(import_node_path11.default.basename(probe))));
|
|
31866
|
+
} finally {
|
|
31867
|
+
import_node_fs3.default.rmSync(probe, { recursive: true, force: true });
|
|
31868
|
+
}
|
|
31869
|
+
}
|
|
31870
|
+
var import_node_fs3, import_node_path11, UNREACHABLE_CODES;
|
|
31871
|
+
var init_sameDirectory = __esm({
|
|
31872
|
+
"src/sameDirectory.ts"() {
|
|
31873
|
+
"use strict";
|
|
31874
|
+
import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
31875
|
+
import_node_path11 = __toESM(require("node:path"), 1);
|
|
31876
|
+
UNREACHABLE_CODES = /* @__PURE__ */ new Set(["ELOOP", "EACCES", "ENOTDIR"]);
|
|
31877
|
+
}
|
|
31878
|
+
});
|
|
31879
|
+
|
|
31833
31880
|
// src/launcher/report.ts
|
|
31834
31881
|
function renderReport(rows, style) {
|
|
31835
31882
|
if (rows.length === 0) {
|
|
@@ -31910,26 +31957,26 @@ function isErrorWithCode(error63, code) {
|
|
|
31910
31957
|
return typeof error63 === "object" && error63 !== null && "code" in error63 && error63.code === code;
|
|
31911
31958
|
}
|
|
31912
31959
|
function writeFileFlushed(file2, contents) {
|
|
31913
|
-
const descriptor =
|
|
31960
|
+
const descriptor = import_node_fs4.default.openSync(file2, "w", OWNER_ONLY_FILE_MODE);
|
|
31914
31961
|
try {
|
|
31915
|
-
|
|
31916
|
-
|
|
31917
|
-
|
|
31962
|
+
import_node_fs4.default.writeFileSync(descriptor, contents, "utf8");
|
|
31963
|
+
import_node_fs4.default.fchmodSync(descriptor, OWNER_ONLY_FILE_MODE);
|
|
31964
|
+
import_node_fs4.default.fsyncSync(descriptor);
|
|
31918
31965
|
} finally {
|
|
31919
|
-
|
|
31966
|
+
import_node_fs4.default.closeSync(descriptor);
|
|
31920
31967
|
}
|
|
31921
31968
|
}
|
|
31922
31969
|
function flushDirectory(directory) {
|
|
31923
|
-
const descriptor =
|
|
31970
|
+
const descriptor = import_node_fs4.default.openSync(directory, "r");
|
|
31924
31971
|
try {
|
|
31925
|
-
|
|
31972
|
+
import_node_fs4.default.fsyncSync(descriptor);
|
|
31926
31973
|
} catch (error63) {
|
|
31927
31974
|
const code = typeof error63 === "object" && error63 !== null && "code" in error63 && typeof error63.code === "string" ? error63.code : void 0;
|
|
31928
31975
|
if (code === void 0 || !DIRECTORY_FLUSH_UNSUPPORTED_CODES.has(code)) {
|
|
31929
31976
|
throw error63;
|
|
31930
31977
|
}
|
|
31931
31978
|
} finally {
|
|
31932
|
-
|
|
31979
|
+
import_node_fs4.default.closeSync(descriptor);
|
|
31933
31980
|
}
|
|
31934
31981
|
}
|
|
31935
31982
|
function realSleepSync(ms) {
|
|
@@ -31964,7 +32011,7 @@ function leadingContinuationBytes(bytes) {
|
|
|
31964
32011
|
}
|
|
31965
32012
|
function realFileSize(filePath) {
|
|
31966
32013
|
try {
|
|
31967
|
-
return
|
|
32014
|
+
return import_node_fs4.default.statSync(filePath).size;
|
|
31968
32015
|
} catch (error63) {
|
|
31969
32016
|
if (isEnoent2(error63)) {
|
|
31970
32017
|
return 0;
|
|
@@ -31979,11 +32026,11 @@ function realReadFileTail(filePath, fromByte, maxBytes) {
|
|
|
31979
32026
|
return "";
|
|
31980
32027
|
}
|
|
31981
32028
|
const buffer2 = Buffer.alloc(size - start);
|
|
31982
|
-
const descriptor =
|
|
32029
|
+
const descriptor = import_node_fs4.default.openSync(filePath, "r");
|
|
31983
32030
|
try {
|
|
31984
32031
|
let read = 0;
|
|
31985
32032
|
while (read < buffer2.length) {
|
|
31986
|
-
const got =
|
|
32033
|
+
const got = import_node_fs4.default.readSync(descriptor, buffer2, read, buffer2.length - read, start + read);
|
|
31987
32034
|
if (got === 0) {
|
|
31988
32035
|
break;
|
|
31989
32036
|
}
|
|
@@ -31996,7 +32043,7 @@ function realReadFileTail(filePath, fromByte, maxBytes) {
|
|
|
31996
32043
|
const lineBreak = bytes.indexOf(LINE_FEED);
|
|
31997
32044
|
return bytes.subarray(lineBreak === -1 ? leadingContinuationBytes(bytes) : lineBreak + 1).toString("utf8");
|
|
31998
32045
|
} finally {
|
|
31999
|
-
|
|
32046
|
+
import_node_fs4.default.closeSync(descriptor);
|
|
32000
32047
|
}
|
|
32001
32048
|
}
|
|
32002
32049
|
function realProcessCommandLine(pid) {
|
|
@@ -32039,7 +32086,7 @@ function realRunAsyncWithin(timeoutMs) {
|
|
|
32039
32086
|
});
|
|
32040
32087
|
}
|
|
32041
32088
|
function expandHome(filePath) {
|
|
32042
|
-
return filePath.startsWith("~/") ?
|
|
32089
|
+
return filePath.startsWith("~/") ? import_node_path12.default.join(import_node_os2.default.homedir(), filePath.slice(1)) : filePath;
|
|
32043
32090
|
}
|
|
32044
32091
|
function hasDesktopSession() {
|
|
32045
32092
|
if (process.platform === "darwin") {
|
|
@@ -32142,8 +32189,8 @@ function spawnDaemonThroughScript(script) {
|
|
|
32142
32189
|
return (paths, subcommand, logPath) => spawnDetachedDaemon({ command: process.execPath, args: [script, subcommand] }, paths, subcommand, logPath);
|
|
32143
32190
|
}
|
|
32144
32191
|
function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
32145
|
-
|
|
32146
|
-
const logFd =
|
|
32192
|
+
import_node_fs4.default.mkdirSync(import_node_path12.default.dirname(logPath), { recursive: true });
|
|
32193
|
+
const logFd = import_node_fs4.default.openSync(logPath, "a");
|
|
32147
32194
|
try {
|
|
32148
32195
|
const child = (0, import_node_child_process3.spawn)(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
|
|
32149
32196
|
child.unref();
|
|
@@ -32152,7 +32199,7 @@ function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
|
32152
32199
|
}
|
|
32153
32200
|
return child.pid;
|
|
32154
32201
|
} finally {
|
|
32155
|
-
|
|
32202
|
+
import_node_fs4.default.closeSync(logFd);
|
|
32156
32203
|
}
|
|
32157
32204
|
}
|
|
32158
32205
|
function spawnHeadroomSupervisor(paths, spawnDaemon) {
|
|
@@ -32188,7 +32235,7 @@ function realHeadroomPort(paths, options) {
|
|
|
32188
32235
|
function listVersionsDir(dir) {
|
|
32189
32236
|
let entries;
|
|
32190
32237
|
try {
|
|
32191
|
-
entries =
|
|
32238
|
+
entries = import_node_fs4.default.readdirSync(dir, { withFileTypes: true });
|
|
32192
32239
|
} catch (error63) {
|
|
32193
32240
|
if (isEnoent2(error63)) {
|
|
32194
32241
|
return [];
|
|
@@ -32196,8 +32243,8 @@ function listVersionsDir(dir) {
|
|
|
32196
32243
|
throw error63;
|
|
32197
32244
|
}
|
|
32198
32245
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
32199
|
-
const fullPath =
|
|
32200
|
-
const stat =
|
|
32246
|
+
const fullPath = import_node_path12.default.join(dir, entry.name);
|
|
32247
|
+
const stat = import_node_fs4.default.statSync(fullPath);
|
|
32201
32248
|
return {
|
|
32202
32249
|
name: entry.name,
|
|
32203
32250
|
isFile: true,
|
|
@@ -32210,7 +32257,7 @@ function windowsPathExtensions(pathext) {
|
|
|
32210
32257
|
return (pathext ?? WINDOWS_DEFAULT_PATHEXT).split(";").map((ext) => ext.trim()).filter((ext) => ext.length > 0);
|
|
32211
32258
|
}
|
|
32212
32259
|
function resolveExecutableCandidate(dir, name, env) {
|
|
32213
|
-
const candidate =
|
|
32260
|
+
const candidate = import_node_path12.default.join(dir, name);
|
|
32214
32261
|
if (env.platform === "win32") {
|
|
32215
32262
|
const extensions = windowsPathExtensions(env.pathext);
|
|
32216
32263
|
const alreadyHasRecognisedExtension = extensions.some((ext) => candidate.toLowerCase().endsWith(ext.toLowerCase()));
|
|
@@ -32230,7 +32277,7 @@ function resolveExecutableCandidate(dir, name, env) {
|
|
|
32230
32277
|
}
|
|
32231
32278
|
function realStatFileMode(candidate) {
|
|
32232
32279
|
try {
|
|
32233
|
-
const stat =
|
|
32280
|
+
const stat = import_node_fs4.default.statSync(candidate);
|
|
32234
32281
|
return stat.isFile() ? stat.mode : void 0;
|
|
32235
32282
|
} catch (error63) {
|
|
32236
32283
|
if (isEnoent2(error63)) {
|
|
@@ -32259,13 +32306,13 @@ function resolveOwnExecutablePath(env) {
|
|
|
32259
32306
|
if (env.argv1 !== void 0 && !env.argv1.includes("/") && !env.argv1.includes("\\")) {
|
|
32260
32307
|
return searchPathForExecutable(env.pathDirs, env.argv1, env.findExecutableInDir) ?? env.execPath;
|
|
32261
32308
|
}
|
|
32262
|
-
const candidate = env.argv1 === void 0 ? env.execPath :
|
|
32263
|
-
const candidateDir =
|
|
32264
|
-
const candidateDirOnPath = env.pathDirs.some((dir) =>
|
|
32309
|
+
const candidate = env.argv1 === void 0 ? env.execPath : import_node_path12.default.resolve(env.cwd, env.argv1);
|
|
32310
|
+
const candidateDir = import_node_path12.default.dirname(candidate);
|
|
32311
|
+
const candidateDirOnPath = env.pathDirs.some((dir) => import_node_path12.default.resolve(dir) === candidateDir);
|
|
32265
32312
|
if (candidateDirOnPath) {
|
|
32266
32313
|
return candidate;
|
|
32267
32314
|
}
|
|
32268
|
-
const viaPath = searchPathForExecutable(env.pathDirs,
|
|
32315
|
+
const viaPath = searchPathForExecutable(env.pathDirs, import_node_path12.default.basename(candidate), env.findExecutableInDir);
|
|
32269
32316
|
return viaPath ?? candidate;
|
|
32270
32317
|
}
|
|
32271
32318
|
function realOwnExecutablePath() {
|
|
@@ -32273,7 +32320,7 @@ function realOwnExecutablePath() {
|
|
|
32273
32320
|
argv1: process.argv[1],
|
|
32274
32321
|
execPath: process.execPath,
|
|
32275
32322
|
cwd: process.cwd(),
|
|
32276
|
-
pathDirs: (process.env.PATH ?? "").split(
|
|
32323
|
+
pathDirs: (process.env.PATH ?? "").split(import_node_path12.default.delimiter).filter((dir) => dir !== ""),
|
|
32277
32324
|
findExecutableInDir
|
|
32278
32325
|
});
|
|
32279
32326
|
}
|
|
@@ -32286,7 +32333,7 @@ function realContentSourcePath() {
|
|
|
32286
32333
|
function realResolveClaudeBinary(isOwnBinary) {
|
|
32287
32334
|
return (request7) => discoverClaudeBinary({
|
|
32288
32335
|
listVersionsDir,
|
|
32289
|
-
pathDirs: (process.env.PATH ?? "").split(
|
|
32336
|
+
pathDirs: (process.env.PATH ?? "").split(import_node_path12.default.delimiter).filter((dir) => dir !== ""),
|
|
32290
32337
|
findExecutableInDir,
|
|
32291
32338
|
isOwnBinary,
|
|
32292
32339
|
...request7?.version === void 0 ? {} : { version: request7.version }
|
|
@@ -32295,7 +32342,7 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
32295
32342
|
function realInstalledClaudeVersions() {
|
|
32296
32343
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
32297
32344
|
}
|
|
32298
|
-
var import_node_child_process3, import_node_crypto4,
|
|
32345
|
+
var import_node_child_process3, import_node_crypto4, import_node_fs4, import_node_os2, import_node_path12, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, DIRECTORY_FLUSH_UNSUPPORTED_CODES, realFarmFs, INT32_BYTE_LENGTH, KEY_POLL_MS, CTRL_C_BYTE, realHoldPort, LINE_FEED, UTF8_CONTINUATION_MASK, UTF8_CONTINUATION_BITS, PS_TIMEOUT_MS, RUN_OUTPUT_LIMIT_MIB, BYTES_PER_MIB2, RUN_OUTPUT_LIMIT_BYTES, realRunPort, ASYNC_RUN_TIMEOUT_MS, realRunAsync, MACOS_GUI_SESSION_MANAGER, realCredentialPort, realAsyncCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
|
|
32299
32346
|
var init_realPorts = __esm({
|
|
32300
32347
|
"src/realPorts.ts"() {
|
|
32301
32348
|
"use strict";
|
|
@@ -32303,9 +32350,9 @@ var init_realPorts = __esm({
|
|
|
32303
32350
|
init_processRole();
|
|
32304
32351
|
import_node_child_process3 = require("node:child_process");
|
|
32305
32352
|
import_node_crypto4 = require("node:crypto");
|
|
32306
|
-
|
|
32353
|
+
import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
32307
32354
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
32308
|
-
|
|
32355
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
32309
32356
|
import_node_sea = require("node:sea");
|
|
32310
32357
|
init_load();
|
|
32311
32358
|
init_versionDiscovery();
|
|
@@ -32313,11 +32360,13 @@ var init_realPorts = __esm({
|
|
|
32313
32360
|
init_ensure();
|
|
32314
32361
|
init_supervisor();
|
|
32315
32362
|
init_state2();
|
|
32363
|
+
init_sameDirectory();
|
|
32316
32364
|
init_logStyle();
|
|
32317
32365
|
realFsPort = {
|
|
32366
|
+
sameDirectory,
|
|
32318
32367
|
fileRevision(filePath) {
|
|
32319
32368
|
try {
|
|
32320
|
-
const stat =
|
|
32369
|
+
const stat = import_node_fs4.default.statSync(filePath, { bigint: true });
|
|
32321
32370
|
return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].map(String).join(":");
|
|
32322
32371
|
} catch (error63) {
|
|
32323
32372
|
if (isEnoent2(error63)) return void 0;
|
|
@@ -32326,7 +32375,7 @@ var init_realPorts = __esm({
|
|
|
32326
32375
|
},
|
|
32327
32376
|
readFileUtf8(filePath) {
|
|
32328
32377
|
try {
|
|
32329
|
-
return
|
|
32378
|
+
return import_node_fs4.default.readFileSync(filePath, "utf8");
|
|
32330
32379
|
} catch (error63) {
|
|
32331
32380
|
if (isEnoent2(error63)) {
|
|
32332
32381
|
return void 0;
|
|
@@ -32337,7 +32386,7 @@ var init_realPorts = __esm({
|
|
|
32337
32386
|
readConfigFile: cosmiconfigReader(),
|
|
32338
32387
|
readdir(dirPath) {
|
|
32339
32388
|
try {
|
|
32340
|
-
return
|
|
32389
|
+
return import_node_fs4.default.readdirSync(dirPath);
|
|
32341
32390
|
} catch (error63) {
|
|
32342
32391
|
if (isEnoent2(error63)) {
|
|
32343
32392
|
return [];
|
|
@@ -32354,7 +32403,7 @@ var init_realPorts = __esm({
|
|
|
32354
32403
|
lstat(filePath) {
|
|
32355
32404
|
let stat;
|
|
32356
32405
|
try {
|
|
32357
|
-
stat =
|
|
32406
|
+
stat = import_node_fs4.default.lstatSync(filePath);
|
|
32358
32407
|
} catch (error63) {
|
|
32359
32408
|
if (isEnoent2(error63)) {
|
|
32360
32409
|
return void 0;
|
|
@@ -32366,7 +32415,7 @@ var init_realPorts = __esm({
|
|
|
32366
32415
|
},
|
|
32367
32416
|
readdir(dirPath) {
|
|
32368
32417
|
try {
|
|
32369
|
-
return
|
|
32418
|
+
return import_node_fs4.default.readdirSync(dirPath);
|
|
32370
32419
|
} catch (error63) {
|
|
32371
32420
|
if (isEnoent2(error63) || isErrorWithCode(error63, "ENOTDIR")) {
|
|
32372
32421
|
return [];
|
|
@@ -32375,23 +32424,23 @@ var init_realPorts = __esm({
|
|
|
32375
32424
|
}
|
|
32376
32425
|
},
|
|
32377
32426
|
mkdirp(dirPath) {
|
|
32378
|
-
|
|
32427
|
+
import_node_fs4.default.mkdirSync(dirPath, { recursive: true });
|
|
32379
32428
|
},
|
|
32380
32429
|
symlink(target, linkPath) {
|
|
32381
|
-
|
|
32430
|
+
import_node_fs4.default.symlinkSync(target, linkPath);
|
|
32382
32431
|
},
|
|
32383
32432
|
rename(from, to2) {
|
|
32384
|
-
|
|
32433
|
+
import_node_fs4.default.renameSync(from, to2);
|
|
32385
32434
|
},
|
|
32386
32435
|
removeRecursive(targetPath) {
|
|
32387
|
-
|
|
32436
|
+
import_node_fs4.default.rmSync(targetPath, { recursive: true, force: true });
|
|
32388
32437
|
},
|
|
32389
32438
|
copyRecursive(from, to2) {
|
|
32390
|
-
|
|
32439
|
+
import_node_fs4.default.cpSync(from, to2, { recursive: true, force: true, verbatimSymlinks: true });
|
|
32391
32440
|
},
|
|
32392
32441
|
readFileUtf8(filePath) {
|
|
32393
32442
|
try {
|
|
32394
|
-
return
|
|
32443
|
+
return import_node_fs4.default.readFileSync(filePath, "utf8");
|
|
32395
32444
|
} catch (error63) {
|
|
32396
32445
|
if (isEnoent2(error63)) {
|
|
32397
32446
|
return void 0;
|
|
@@ -32400,47 +32449,47 @@ var init_realPorts = __esm({
|
|
|
32400
32449
|
}
|
|
32401
32450
|
},
|
|
32402
32451
|
writeFileUtf8(filePath, contents) {
|
|
32403
|
-
|
|
32452
|
+
import_node_fs4.default.writeFileSync(filePath, contents, "utf8");
|
|
32404
32453
|
},
|
|
32405
32454
|
mkdirPrivate(dirPath) {
|
|
32406
|
-
|
|
32407
|
-
|
|
32455
|
+
import_node_fs4.default.mkdirSync(dirPath, { recursive: true, mode: OWNER_ONLY_DIR_MODE });
|
|
32456
|
+
import_node_fs4.default.chmodSync(dirPath, OWNER_ONLY_DIR_MODE);
|
|
32408
32457
|
},
|
|
32409
32458
|
writeFilePrivate(filePath, contents, options) {
|
|
32410
32459
|
const temp = `${filePath}.${String(process.pid)}.tmp`;
|
|
32411
32460
|
try {
|
|
32412
32461
|
if (options?.durable === true) {
|
|
32413
32462
|
writeFileFlushed(temp, contents);
|
|
32414
|
-
|
|
32415
|
-
flushDirectory(
|
|
32463
|
+
import_node_fs4.default.renameSync(temp, filePath);
|
|
32464
|
+
flushDirectory(import_node_path12.default.dirname(filePath));
|
|
32416
32465
|
} else {
|
|
32417
|
-
|
|
32418
|
-
|
|
32419
|
-
|
|
32466
|
+
import_node_fs4.default.writeFileSync(temp, contents, { encoding: "utf8", mode: OWNER_ONLY_FILE_MODE });
|
|
32467
|
+
import_node_fs4.default.chmodSync(temp, OWNER_ONLY_FILE_MODE);
|
|
32468
|
+
import_node_fs4.default.renameSync(temp, filePath);
|
|
32420
32469
|
}
|
|
32421
32470
|
} catch (error63) {
|
|
32422
|
-
|
|
32471
|
+
import_node_fs4.default.rmSync(temp, { force: true });
|
|
32423
32472
|
throw error63;
|
|
32424
32473
|
}
|
|
32425
32474
|
},
|
|
32426
32475
|
appendFilePrivate(filePath, contents) {
|
|
32427
|
-
const descriptor =
|
|
32476
|
+
const descriptor = import_node_fs4.default.openSync(filePath, "a", OWNER_ONLY_FILE_MODE);
|
|
32428
32477
|
try {
|
|
32429
|
-
if ((
|
|
32430
|
-
|
|
32478
|
+
if ((import_node_fs4.default.fstatSync(descriptor).mode & PERMISSION_BITS) !== OWNER_ONLY_FILE_MODE) {
|
|
32479
|
+
import_node_fs4.default.fchmodSync(descriptor, OWNER_ONLY_FILE_MODE);
|
|
32431
32480
|
}
|
|
32432
32481
|
const bytes = Buffer.from(contents, "utf8");
|
|
32433
32482
|
let written = 0;
|
|
32434
32483
|
while (written < bytes.length) {
|
|
32435
|
-
written +=
|
|
32484
|
+
written += import_node_fs4.default.writeSync(descriptor, bytes, written, bytes.length - written);
|
|
32436
32485
|
}
|
|
32437
32486
|
} finally {
|
|
32438
|
-
|
|
32487
|
+
import_node_fs4.default.closeSync(descriptor);
|
|
32439
32488
|
}
|
|
32440
32489
|
},
|
|
32441
32490
|
writeFileExclusive(filePath, contents) {
|
|
32442
32491
|
try {
|
|
32443
|
-
|
|
32492
|
+
import_node_fs4.default.writeFileSync(filePath, contents, { encoding: "utf8", flag: "wx" });
|
|
32444
32493
|
return true;
|
|
32445
32494
|
} catch (error63) {
|
|
32446
32495
|
if (isErrorWithCode(error63, "EEXIST")) {
|
|
@@ -32451,7 +32500,7 @@ var init_realPorts = __esm({
|
|
|
32451
32500
|
},
|
|
32452
32501
|
hashFile(filePath) {
|
|
32453
32502
|
try {
|
|
32454
|
-
return (0, import_node_crypto4.createHash)("sha256").update(
|
|
32503
|
+
return (0, import_node_crypto4.createHash)("sha256").update(import_node_fs4.default.readFileSync(filePath)).digest("hex");
|
|
32455
32504
|
} catch (error63) {
|
|
32456
32505
|
if (isEnoent2(error63) || isErrorWithCode(error63, "EISDIR")) {
|
|
32457
32506
|
return void 0;
|
|
@@ -32472,7 +32521,7 @@ var init_realPorts = __esm({
|
|
|
32472
32521
|
const buffer2 = Buffer.alloc(1);
|
|
32473
32522
|
for (; ; ) {
|
|
32474
32523
|
try {
|
|
32475
|
-
const read =
|
|
32524
|
+
const read = import_node_fs4.default.readSync(process.stdin.fd, buffer2, 0, buffer2.length, null);
|
|
32476
32525
|
return read > 0 && buffer2[0] === CTRL_C_BYTE ? "interrupt" : "key";
|
|
32477
32526
|
} catch (error63) {
|
|
32478
32527
|
if (!(error63 instanceof Error && "code" in error63 && error63.code === "EAGAIN")) {
|
|
@@ -32508,8 +32557,8 @@ var init_realPorts = __esm({
|
|
|
32508
32557
|
let content;
|
|
32509
32558
|
let stat;
|
|
32510
32559
|
try {
|
|
32511
|
-
stat =
|
|
32512
|
-
content =
|
|
32560
|
+
stat = import_node_fs4.default.statSync(resolved);
|
|
32561
|
+
content = import_node_fs4.default.readFileSync(resolved, "utf8");
|
|
32513
32562
|
} catch (error63) {
|
|
32514
32563
|
if (isEnoent2(error63)) {
|
|
32515
32564
|
return { found: false };
|
|
@@ -32550,7 +32599,7 @@ var init_realPorts = __esm({
|
|
|
32550
32599
|
lstat: (target) => {
|
|
32551
32600
|
let stat;
|
|
32552
32601
|
try {
|
|
32553
|
-
stat =
|
|
32602
|
+
stat = import_node_fs4.default.lstatSync(target);
|
|
32554
32603
|
} catch (error63) {
|
|
32555
32604
|
if (isEnoent2(error63)) {
|
|
32556
32605
|
return void 0;
|
|
@@ -32560,7 +32609,7 @@ var init_realPorts = __esm({
|
|
|
32560
32609
|
const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : stat.isFile() ? "file" : stat.isSocket() ? "socket" : "other";
|
|
32561
32610
|
return { kind, uid: stat.uid, mode: stat.mode & SOCKET_PERMISSION_BITS };
|
|
32562
32611
|
},
|
|
32563
|
-
readlink: (target) =>
|
|
32612
|
+
readlink: (target) => import_node_fs4.default.readlinkSync(target, "utf8")
|
|
32564
32613
|
};
|
|
32565
32614
|
realSpawnPort = {
|
|
32566
32615
|
spawnSync(command, args, options) {
|
|
@@ -32601,10 +32650,10 @@ function isInvokedAsClaude(invokedName) {
|
|
|
32601
32650
|
}
|
|
32602
32651
|
function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
32603
32652
|
const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
32604
|
-
const recordedTarget = state === void 0 ? void 0 :
|
|
32653
|
+
const recordedTarget = state === void 0 ? void 0 : import_node_path13.default.resolve(state.targetPath);
|
|
32605
32654
|
let ownStat;
|
|
32606
32655
|
return (candidate) => {
|
|
32607
|
-
if (recordedTarget !== void 0 &&
|
|
32656
|
+
if (recordedTarget !== void 0 && import_node_path13.default.resolve(candidate) === recordedTarget) {
|
|
32608
32657
|
return true;
|
|
32609
32658
|
}
|
|
32610
32659
|
ownStat ??= statOrUndefined(contentSourcePath);
|
|
@@ -32614,7 +32663,7 @@ function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
|
32614
32663
|
};
|
|
32615
32664
|
}
|
|
32616
32665
|
function resolveClaudeTargetPath(ownExecutablePath, dir) {
|
|
32617
|
-
return
|
|
32666
|
+
return import_node_path13.default.join(dir ?? import_node_path13.default.dirname(ownExecutablePath), claudeTargetFilename(ownExecutablePath));
|
|
32618
32667
|
}
|
|
32619
32668
|
function isEnoent3(error63) {
|
|
32620
32669
|
return typeof error63 === "object" && error63 !== null && "code" in error63 && error63.code === "ENOENT";
|
|
@@ -32624,7 +32673,7 @@ function isCrossDeviceError(error63) {
|
|
|
32624
32673
|
}
|
|
32625
32674
|
function lstatOrUndefined(target) {
|
|
32626
32675
|
try {
|
|
32627
|
-
return
|
|
32676
|
+
return import_node_fs5.default.lstatSync(target);
|
|
32628
32677
|
} catch (error63) {
|
|
32629
32678
|
if (isEnoent3(error63)) {
|
|
32630
32679
|
return void 0;
|
|
@@ -32634,7 +32683,7 @@ function lstatOrUndefined(target) {
|
|
|
32634
32683
|
}
|
|
32635
32684
|
function statOrUndefined(target) {
|
|
32636
32685
|
try {
|
|
32637
|
-
return
|
|
32686
|
+
return import_node_fs5.default.statSync(target);
|
|
32638
32687
|
} catch (error63) {
|
|
32639
32688
|
if (isEnoent3(error63)) {
|
|
32640
32689
|
return void 0;
|
|
@@ -32643,22 +32692,22 @@ function statOrUndefined(target) {
|
|
|
32643
32692
|
}
|
|
32644
32693
|
}
|
|
32645
32694
|
function enableClaudeShim(params, linkFs = nodeLinkFs) {
|
|
32646
|
-
const realContentPath =
|
|
32695
|
+
const realContentPath = import_node_fs5.default.realpathSync(params.contentSourcePath);
|
|
32647
32696
|
if (params.platform === "win32" && !realContentPath.toLowerCase().endsWith(".exe")) {
|
|
32648
32697
|
throw new UnsupportedShimSourceError(realContentPath);
|
|
32649
32698
|
}
|
|
32650
32699
|
const targetPath = resolveClaudeTargetPath(params.ownExecutablePath, params.dir);
|
|
32651
|
-
|
|
32700
|
+
import_node_fs5.default.mkdirSync(import_node_path13.default.dirname(targetPath), { recursive: true });
|
|
32652
32701
|
const existing = lstatOrUndefined(targetPath);
|
|
32653
32702
|
if (existing !== void 0) {
|
|
32654
|
-
const ownStat =
|
|
32703
|
+
const ownStat = import_node_fs5.default.statSync(realContentPath);
|
|
32655
32704
|
const state = readJson(params.paths.claudeShimFile, ClaudeShimStateSchema);
|
|
32656
32705
|
const sameInode = existing.dev === ownStat.dev && existing.ino === ownStat.ino;
|
|
32657
|
-
const markerMatches = state !== void 0 &&
|
|
32706
|
+
const markerMatches = state !== void 0 && import_node_path13.default.resolve(state.targetPath) === targetPath;
|
|
32658
32707
|
if (!sameInode && !markerMatches && !params.force) {
|
|
32659
32708
|
throw new ForeignClaudeEntryError(targetPath, "enable");
|
|
32660
32709
|
}
|
|
32661
|
-
|
|
32710
|
+
import_node_fs5.default.rmSync(targetPath, { recursive: true, force: true });
|
|
32662
32711
|
}
|
|
32663
32712
|
let method;
|
|
32664
32713
|
try {
|
|
@@ -32677,36 +32726,36 @@ function enableClaudeShim(params, linkFs = nodeLinkFs) {
|
|
|
32677
32726
|
return { action: existing === void 0 ? "enabled" : "reenabled", targetPath, method };
|
|
32678
32727
|
}
|
|
32679
32728
|
function disableClaudeShim(params) {
|
|
32680
|
-
const realContentPath =
|
|
32729
|
+
const realContentPath = import_node_fs5.default.realpathSync(params.contentSourcePath);
|
|
32681
32730
|
const state = readJson(params.paths.claudeShimFile, ClaudeShimStateSchema);
|
|
32682
|
-
const targetPath = params.dir !== void 0 ?
|
|
32731
|
+
const targetPath = params.dir !== void 0 ? import_node_path13.default.join(params.dir, claudeTargetFilename(params.ownExecutablePath)) : state?.targetPath ?? resolveClaudeTargetPath(params.ownExecutablePath);
|
|
32683
32732
|
const existing = lstatOrUndefined(targetPath);
|
|
32684
32733
|
if (existing === void 0) {
|
|
32685
32734
|
if (state !== void 0) {
|
|
32686
|
-
|
|
32735
|
+
import_node_fs5.default.rmSync(params.paths.claudeShimFile, { force: true });
|
|
32687
32736
|
}
|
|
32688
32737
|
return { action: "not-enabled", targetPath };
|
|
32689
32738
|
}
|
|
32690
|
-
const ownStat =
|
|
32739
|
+
const ownStat = import_node_fs5.default.statSync(realContentPath);
|
|
32691
32740
|
const sameInode = existing.dev === ownStat.dev && existing.ino === ownStat.ino;
|
|
32692
|
-
const markerMatches = state !== void 0 &&
|
|
32741
|
+
const markerMatches = state !== void 0 && import_node_path13.default.resolve(state.targetPath) === targetPath;
|
|
32693
32742
|
if (!sameInode && !markerMatches && !params.force) {
|
|
32694
32743
|
throw new ForeignClaudeEntryError(targetPath, "disable");
|
|
32695
32744
|
}
|
|
32696
|
-
|
|
32697
|
-
|
|
32745
|
+
import_node_fs5.default.rmSync(targetPath, { recursive: true, force: true });
|
|
32746
|
+
import_node_fs5.default.rmSync(params.paths.claudeShimFile, { force: true });
|
|
32698
32747
|
return { action: "disabled", targetPath };
|
|
32699
32748
|
}
|
|
32700
32749
|
function findPathShadow(params) {
|
|
32701
|
-
const resolvedTargetDir =
|
|
32750
|
+
const resolvedTargetDir = import_node_path13.default.resolve(params.targetDir);
|
|
32702
32751
|
for (const dir of params.pathDirs) {
|
|
32703
32752
|
const found = params.findExecutableInDir(dir, params.targetFilename);
|
|
32704
32753
|
if (found === void 0) {
|
|
32705
32754
|
continue;
|
|
32706
32755
|
}
|
|
32707
|
-
return
|
|
32756
|
+
return import_node_path13.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
|
|
32708
32757
|
}
|
|
32709
|
-
return params.pathDirs.some((dir) =>
|
|
32758
|
+
return params.pathDirs.some((dir) => import_node_path13.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
32710
32759
|
}
|
|
32711
32760
|
function registerShimCommand(program2, deps) {
|
|
32712
32761
|
const { paths } = deps;
|
|
@@ -32724,21 +32773,21 @@ function registerShimCommand(program2, deps) {
|
|
|
32724
32773
|
ownExecutablePath,
|
|
32725
32774
|
contentSourcePath,
|
|
32726
32775
|
platform: process.platform,
|
|
32727
|
-
...options.dir === void 0 ? {} : { dir:
|
|
32776
|
+
...options.dir === void 0 ? {} : { dir: import_node_path13.default.resolve(options.dir) },
|
|
32728
32777
|
force: options.force ?? false
|
|
32729
32778
|
});
|
|
32730
32779
|
console.log(`${result.action === "enabled" ? "Installed" : "Reinstalled"} \`claude\` at ${result.targetPath} (${result.method}).`);
|
|
32731
32780
|
const shadow = findPathShadow({
|
|
32732
|
-
pathDirs: (process.env.PATH ?? "").split(
|
|
32733
|
-
targetDir:
|
|
32734
|
-
targetFilename:
|
|
32781
|
+
pathDirs: (process.env.PATH ?? "").split(import_node_path13.default.delimiter).filter((dir) => dir !== ""),
|
|
32782
|
+
targetDir: import_node_path13.default.dirname(result.targetPath),
|
|
32783
|
+
targetFilename: import_node_path13.default.basename(result.targetPath),
|
|
32735
32784
|
findExecutableInDir
|
|
32736
32785
|
});
|
|
32737
32786
|
if (shadow.status === "not-on-path") {
|
|
32738
|
-
console.warn(`warning: ${
|
|
32787
|
+
console.warn(`warning: ${import_node_path13.default.dirname(result.targetPath)} is not on PATH \u2014 add it, or use \`agent-shim run\` instead.`);
|
|
32739
32788
|
} else if (shadow.status === "shadowed") {
|
|
32740
32789
|
console.warn(
|
|
32741
|
-
`warning: 'claude' on PATH currently resolves to ${shadow.by}, not ${result.targetPath}. Put ${
|
|
32790
|
+
`warning: 'claude' on PATH currently resolves to ${shadow.by}, not ${result.targetPath}. Put ${import_node_path13.default.dirname(result.targetPath)} ahead of it on PATH.`
|
|
32742
32791
|
);
|
|
32743
32792
|
}
|
|
32744
32793
|
});
|
|
@@ -32750,7 +32799,7 @@ function registerShimCommand(program2, deps) {
|
|
|
32750
32799
|
paths,
|
|
32751
32800
|
ownExecutablePath,
|
|
32752
32801
|
contentSourcePath,
|
|
32753
|
-
...options.dir === void 0 ? {} : { dir:
|
|
32802
|
+
...options.dir === void 0 ? {} : { dir: import_node_path13.default.resolve(options.dir) },
|
|
32754
32803
|
force: options.force ?? false
|
|
32755
32804
|
});
|
|
32756
32805
|
console.log(
|
|
@@ -32759,12 +32808,12 @@ function registerShimCommand(program2, deps) {
|
|
|
32759
32808
|
});
|
|
32760
32809
|
withExamples(disable, ["agent-shim shim disable"]);
|
|
32761
32810
|
}
|
|
32762
|
-
var
|
|
32811
|
+
var import_node_fs5, import_node_path13, EXECUTABLE_FILE_MODE, ClaudeShimStateSchema, ForeignClaudeEntryError, UnsupportedShimSourceError, nodeLinkFs;
|
|
32763
32812
|
var init_claudeShim = __esm({
|
|
32764
32813
|
"src/claudeShim.ts"() {
|
|
32765
32814
|
"use strict";
|
|
32766
|
-
|
|
32767
|
-
|
|
32815
|
+
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
32816
|
+
import_node_path13 = __toESM(require("node:path"), 1);
|
|
32768
32817
|
init_zod();
|
|
32769
32818
|
init_commandDeps();
|
|
32770
32819
|
init_store();
|
|
@@ -32798,7 +32847,7 @@ var init_claudeShim = __esm({
|
|
|
32798
32847
|
}
|
|
32799
32848
|
contentSourcePath;
|
|
32800
32849
|
};
|
|
32801
|
-
nodeLinkFs = { link:
|
|
32850
|
+
nodeLinkFs = { link: import_node_fs5.default.linkSync, copyFile: import_node_fs5.default.copyFileSync, chmod: import_node_fs5.default.chmodSync };
|
|
32802
32851
|
}
|
|
32803
32852
|
});
|
|
32804
32853
|
|
|
@@ -33077,53 +33126,6 @@ var init_classify = __esm({
|
|
|
33077
33126
|
}
|
|
33078
33127
|
});
|
|
33079
33128
|
|
|
33080
|
-
// src/sameDirectory.ts
|
|
33081
|
-
function systemErrorCode(error63) {
|
|
33082
|
-
return typeof error63 === "object" && error63 !== null && "code" in error63 && typeof error63.code === "string" ? error63.code : void 0;
|
|
33083
|
-
}
|
|
33084
|
-
function reachableStat(target) {
|
|
33085
|
-
try {
|
|
33086
|
-
return import_node_fs5.default.statSync(target, { throwIfNoEntry: false });
|
|
33087
|
-
} catch (error63) {
|
|
33088
|
-
const code = systemErrorCode(error63);
|
|
33089
|
-
if (code !== void 0 && UNREACHABLE_CODES.has(code)) {
|
|
33090
|
-
return void 0;
|
|
33091
|
-
}
|
|
33092
|
-
throw error63;
|
|
33093
|
-
}
|
|
33094
|
-
}
|
|
33095
|
-
function sameDirectory(first, second) {
|
|
33096
|
-
const a10 = reachableStat(first);
|
|
33097
|
-
const b = reachableStat(second);
|
|
33098
|
-
if (a10 === void 0 || b === void 0) {
|
|
33099
|
-
return false;
|
|
33100
|
-
}
|
|
33101
|
-
return a10.dev === b.dev && a10.ino === b.ino;
|
|
33102
|
-
}
|
|
33103
|
-
function caseSwapped(name) {
|
|
33104
|
-
return name.replace(/[A-Za-z]/gu, (letter) => letter === letter.toLowerCase() ? letter.toUpperCase() : letter.toLowerCase());
|
|
33105
|
-
}
|
|
33106
|
-
function ignoresCase(directory) {
|
|
33107
|
-
if (!import_node_fs5.default.existsSync(directory)) {
|
|
33108
|
-
return false;
|
|
33109
|
-
}
|
|
33110
|
-
const probe = import_node_fs5.default.mkdtempSync(import_node_path13.default.join(directory, ".case-probe-"));
|
|
33111
|
-
try {
|
|
33112
|
-
return sameDirectory(probe, import_node_path13.default.join(directory, caseSwapped(import_node_path13.default.basename(probe))));
|
|
33113
|
-
} finally {
|
|
33114
|
-
import_node_fs5.default.rmSync(probe, { recursive: true, force: true });
|
|
33115
|
-
}
|
|
33116
|
-
}
|
|
33117
|
-
var import_node_fs5, import_node_path13, UNREACHABLE_CODES;
|
|
33118
|
-
var init_sameDirectory = __esm({
|
|
33119
|
-
"src/sameDirectory.ts"() {
|
|
33120
|
-
"use strict";
|
|
33121
|
-
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
33122
|
-
import_node_path13 = __toESM(require("node:path"), 1);
|
|
33123
|
-
UNREACHABLE_CODES = /* @__PURE__ */ new Set(["ELOOP", "EACCES", "ENOTDIR"]);
|
|
33124
|
-
}
|
|
33125
|
-
});
|
|
33126
|
-
|
|
33127
33129
|
// src/identityRecords.ts
|
|
33128
33130
|
function isSymlinkEntry(entry) {
|
|
33129
33131
|
return import_node_fs6.default.lstatSync(entry, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
|
|
@@ -33273,19 +33275,21 @@ function readActiveIdentity(fs36, activeIdentityFile) {
|
|
|
33273
33275
|
function isNonEmpty(value3) {
|
|
33274
33276
|
return value3 !== void 0 && value3 !== "";
|
|
33275
33277
|
}
|
|
33276
|
-
function selected(selector, source) {
|
|
33278
|
+
function selected(selector, source, supersededConfigDir) {
|
|
33277
33279
|
if (!IdentitySelectorSchema.safeParse(selector).success) {
|
|
33278
33280
|
throw new UnsafeNameError(selector, "identity", `${FILE_NAME_RULE}, or be pool:<name> for a pool`, IDENTITY_SOURCE_LABELS[source]);
|
|
33279
33281
|
}
|
|
33280
33282
|
const pool = poolNameOf(selector);
|
|
33281
|
-
|
|
33283
|
+
const superseded = supersededConfigDir === void 0 ? {} : { supersededConfigDir };
|
|
33284
|
+
return pool === void 0 ? { name: selector, source, configDirEscapeHatch: false, ...superseded } : { pool, source, configDirEscapeHatch: false, ...superseded };
|
|
33282
33285
|
}
|
|
33283
33286
|
function decideIdentity(params) {
|
|
33284
|
-
|
|
33285
|
-
return { source: "config-dir-escape-hatch", configDirEscapeHatch: true };
|
|
33286
|
-
}
|
|
33287
|
+
const inheritedConfigDir = isNonEmpty(params.env.CLAUDE_CONFIG_DIR) ? params.env.CLAUDE_CONFIG_DIR : void 0;
|
|
33287
33288
|
if (isNonEmpty(params.argv0Identity)) {
|
|
33288
|
-
return selected(params.argv0Identity, "argv");
|
|
33289
|
+
return selected(params.argv0Identity, "argv", inheritedConfigDir);
|
|
33290
|
+
}
|
|
33291
|
+
if (inheritedConfigDir !== void 0) {
|
|
33292
|
+
return { source: "config-dir-escape-hatch", configDirEscapeHatch: true };
|
|
33289
33293
|
}
|
|
33290
33294
|
if (isNonEmpty(params.env.AGENT_SHIM_IDENTITY)) {
|
|
33291
33295
|
return selected(params.env.AGENT_SHIM_IDENTITY, "env");
|
|
@@ -33364,7 +33368,7 @@ var init_identity = __esm({
|
|
|
33364
33368
|
init_identityRecords();
|
|
33365
33369
|
init_sameDirectory();
|
|
33366
33370
|
IDENTITY_DECISION_SOURCES = [
|
|
33367
|
-
/** `CLAUDE_CONFIG_DIR` was already set: identity resolution is skipped entirely and the real binary uses whatever it already points to. */
|
|
33371
|
+
/** `CLAUDE_CONFIG_DIR` was already set and nothing on the command line names an identity: identity resolution is skipped entirely and the real binary uses whatever it already points to. */
|
|
33368
33372
|
"config-dir-escape-hatch",
|
|
33369
33373
|
/** A leading `@name` argv[0] positional, or its explicit form `--identity <name>`. */
|
|
33370
33374
|
"argv",
|
|
@@ -41224,10 +41228,9 @@ function checkedProxyBypass(entries, source) {
|
|
|
41224
41228
|
}
|
|
41225
41229
|
return kept;
|
|
41226
41230
|
}
|
|
41227
|
-
function
|
|
41228
|
-
const
|
|
41229
|
-
|
|
41230
|
-
const added = hosts.filter((host) => {
|
|
41231
|
+
function appendedBypassHosts(existing, hosts) {
|
|
41232
|
+
const have = new Set((existing ?? "").split(",").map((entry) => entry.trim().toLowerCase()).filter((entry) => entry !== ""));
|
|
41233
|
+
return hosts.filter((host) => {
|
|
41231
41234
|
const key = host.toLowerCase();
|
|
41232
41235
|
if (have.has(key)) {
|
|
41233
41236
|
return false;
|
|
@@ -41235,7 +41238,10 @@ function withBypassHosts(existing, hosts) {
|
|
|
41235
41238
|
have.add(key);
|
|
41236
41239
|
return true;
|
|
41237
41240
|
});
|
|
41238
|
-
|
|
41241
|
+
}
|
|
41242
|
+
function withBypassHosts(existing, hosts) {
|
|
41243
|
+
const listed = (existing ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
41244
|
+
return [...listed, ...appendedBypassHosts(existing, hosts)].join(",");
|
|
41239
41245
|
}
|
|
41240
41246
|
var init_proxyBypass2 = __esm({
|
|
41241
41247
|
"src/launcher/proxyBypass.ts"() {
|
|
@@ -41980,7 +41986,7 @@ var init_package = __esm({
|
|
|
41980
41986
|
"package.json"() {
|
|
41981
41987
|
package_default = {
|
|
41982
41988
|
name: "claude-use",
|
|
41983
|
-
version: "11.88.
|
|
41989
|
+
version: "11.88.1",
|
|
41984
41990
|
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.",
|
|
41985
41991
|
license: "MIT",
|
|
41986
41992
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -42153,6 +42159,156 @@ var init_claudeVersion = __esm({
|
|
|
42153
42159
|
}
|
|
42154
42160
|
});
|
|
42155
42161
|
|
|
42162
|
+
// src/headroom/headers.ts
|
|
42163
|
+
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
42164
|
+
const merged = /* @__PURE__ */ new Map();
|
|
42165
|
+
for (const block2 of existing) {
|
|
42166
|
+
if (block2 === void 0) {
|
|
42167
|
+
continue;
|
|
42168
|
+
}
|
|
42169
|
+
for (const line of block2.split("\n")) {
|
|
42170
|
+
const entry = parseCustomHeaderLine(line);
|
|
42171
|
+
if (entry === void 0) {
|
|
42172
|
+
continue;
|
|
42173
|
+
}
|
|
42174
|
+
merged.set(entry.name, entry.value);
|
|
42175
|
+
}
|
|
42176
|
+
}
|
|
42177
|
+
for (const entry of additions) {
|
|
42178
|
+
merged.set(entry.name, entry.value);
|
|
42179
|
+
}
|
|
42180
|
+
return [...merged].map(([name, value3]) => `${name}: ${value3}`).join("\n");
|
|
42181
|
+
}
|
|
42182
|
+
function parseAnthropicCustomHeaders(block2) {
|
|
42183
|
+
return block2.split("\n").flatMap((line) => {
|
|
42184
|
+
const entry = parseCustomHeaderLine(line);
|
|
42185
|
+
return entry === void 0 ? [] : [entry];
|
|
42186
|
+
});
|
|
42187
|
+
}
|
|
42188
|
+
function withoutAnthropicCustomHeaders(block2, remove) {
|
|
42189
|
+
const lines = block2.split("\n");
|
|
42190
|
+
const kept = lines.filter((line) => {
|
|
42191
|
+
const entry = parseCustomHeaderLine(line);
|
|
42192
|
+
return entry === void 0 || !remove(entry);
|
|
42193
|
+
});
|
|
42194
|
+
return kept.length === lines.length ? block2 : kept.join("\n");
|
|
42195
|
+
}
|
|
42196
|
+
function parseCustomHeaderLine(line) {
|
|
42197
|
+
const trimmed = line.trim();
|
|
42198
|
+
if (trimmed === "") {
|
|
42199
|
+
return void 0;
|
|
42200
|
+
}
|
|
42201
|
+
const colon = trimmed.indexOf(":");
|
|
42202
|
+
if (colon <= 0) {
|
|
42203
|
+
return void 0;
|
|
42204
|
+
}
|
|
42205
|
+
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
42206
|
+
}
|
|
42207
|
+
var init_headers = __esm({
|
|
42208
|
+
"src/headroom/headers.ts"() {
|
|
42209
|
+
"use strict";
|
|
42210
|
+
}
|
|
42211
|
+
});
|
|
42212
|
+
|
|
42213
|
+
// src/launcher/injected.ts
|
|
42214
|
+
function listKey(list2) {
|
|
42215
|
+
return `${list2},appended`;
|
|
42216
|
+
}
|
|
42217
|
+
function digest2(value3) {
|
|
42218
|
+
return (0, import_node_crypto13.createHash)("sha256").update(value3).digest("hex");
|
|
42219
|
+
}
|
|
42220
|
+
function recordedDigests(env) {
|
|
42221
|
+
const raw = env[INJECTED_ENV];
|
|
42222
|
+
if (raw === void 0 || raw === "") {
|
|
42223
|
+
return {};
|
|
42224
|
+
}
|
|
42225
|
+
let parsed;
|
|
42226
|
+
try {
|
|
42227
|
+
parsed = JSON.parse(raw);
|
|
42228
|
+
} catch {
|
|
42229
|
+
return {};
|
|
42230
|
+
}
|
|
42231
|
+
const result = InjectedSchema.safeParse(parsed);
|
|
42232
|
+
return result.success ? result.data : {};
|
|
42233
|
+
}
|
|
42234
|
+
function recordInjections(base) {
|
|
42235
|
+
const env = { ...base };
|
|
42236
|
+
const digests = new Map(Object.entries(recordedDigests(env)));
|
|
42237
|
+
return {
|
|
42238
|
+
env,
|
|
42239
|
+
set: (name, value3) => {
|
|
42240
|
+
env[name] = value3;
|
|
42241
|
+
digests.set(name, digest2(value3));
|
|
42242
|
+
},
|
|
42243
|
+
unset: (name) => {
|
|
42244
|
+
env[name] = void 0;
|
|
42245
|
+
digests.delete(name);
|
|
42246
|
+
},
|
|
42247
|
+
recordHeaders: (names) => {
|
|
42248
|
+
const block2 = env[CUSTOM_HEADERS_ENV];
|
|
42249
|
+
for (const entry of block2 === void 0 ? [] : parseAnthropicCustomHeaders(block2)) {
|
|
42250
|
+
if (names.includes(entry.name)) {
|
|
42251
|
+
digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
|
|
42252
|
+
}
|
|
42253
|
+
}
|
|
42254
|
+
},
|
|
42255
|
+
recordBypassHosts: (list2, hosts) => {
|
|
42256
|
+
const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list2))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
|
|
42257
|
+
if (recordedHosts.length > 0) {
|
|
42258
|
+
digests.set(listKey(list2), recordedHosts.join(","));
|
|
42259
|
+
}
|
|
42260
|
+
},
|
|
42261
|
+
finish: () => {
|
|
42262
|
+
if (digests.size > 0) {
|
|
42263
|
+
env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
|
|
42264
|
+
}
|
|
42265
|
+
}
|
|
42266
|
+
};
|
|
42267
|
+
}
|
|
42268
|
+
function withoutRecordedHosts(list2, value3, digests) {
|
|
42269
|
+
const recordedHosts = new Set(digests[listKey(list2)]?.split(","));
|
|
42270
|
+
const entries = value3.split(",");
|
|
42271
|
+
const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
|
|
42272
|
+
return kept.length === entries.length ? value3 : kept.join(",");
|
|
42273
|
+
}
|
|
42274
|
+
function launchEnvironment(env, configDirEscapeHatch) {
|
|
42275
|
+
return configDirEscapeHatch ? env : withoutInjected(env);
|
|
42276
|
+
}
|
|
42277
|
+
function withoutInjected(env) {
|
|
42278
|
+
const digests = recordedDigests(env);
|
|
42279
|
+
const entries = Object.entries(env).flatMap(([name, value3]) => {
|
|
42280
|
+
if (name === INJECTED_ENV) {
|
|
42281
|
+
return [];
|
|
42282
|
+
}
|
|
42283
|
+
if (value3 === void 0) {
|
|
42284
|
+
return [[name, value3]];
|
|
42285
|
+
}
|
|
42286
|
+
if (name === CUSTOM_HEADERS_ENV) {
|
|
42287
|
+
const remaining = withoutAnthropicCustomHeaders(value3, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
|
|
42288
|
+
return remaining !== value3 && remaining.trim() === "" ? [] : [[name, remaining]];
|
|
42289
|
+
}
|
|
42290
|
+
if (name === "NO_PROXY" || name === "no_proxy") {
|
|
42291
|
+
const remaining = withoutRecordedHosts(name, value3, digests);
|
|
42292
|
+
return remaining !== value3 && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
|
|
42293
|
+
}
|
|
42294
|
+
return digests[name] === digest2(value3) ? [] : [[name, value3]];
|
|
42295
|
+
});
|
|
42296
|
+
return Object.fromEntries(entries);
|
|
42297
|
+
}
|
|
42298
|
+
var import_node_crypto13, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
42299
|
+
var init_injected = __esm({
|
|
42300
|
+
"src/launcher/injected.ts"() {
|
|
42301
|
+
"use strict";
|
|
42302
|
+
import_node_crypto13 = require("node:crypto");
|
|
42303
|
+
init_zod();
|
|
42304
|
+
init_headers();
|
|
42305
|
+
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
42306
|
+
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
42307
|
+
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
42308
|
+
InjectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
42309
|
+
}
|
|
42310
|
+
});
|
|
42311
|
+
|
|
42156
42312
|
// src/launcher/guard.ts
|
|
42157
42313
|
function detectAmbientCredential(env, injected) {
|
|
42158
42314
|
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
@@ -42191,10 +42347,22 @@ function evaluateAmbientCredentialGuard(params) {
|
|
|
42191
42347
|
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
42192
42348
|
};
|
|
42193
42349
|
}
|
|
42350
|
+
function ambientCredentialFinding(env) {
|
|
42351
|
+
const named = detectAmbientCredential(launchEnvironment(env, false));
|
|
42352
|
+
if (named !== void 0) {
|
|
42353
|
+
return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
|
|
42354
|
+
}
|
|
42355
|
+
const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
|
|
42356
|
+
if (bare !== void 0) {
|
|
42357
|
+
return { severity: "warn", message: `${bare.variable} was set in this session by the launcher that started it. A launch that names an identity drops it, but a launch naming none keeps the session's CLAUDE_CONFIG_DIR and environment and is refused. Name an identity, as in \`claude @<name>\`.` };
|
|
42358
|
+
}
|
|
42359
|
+
return { severity: "pass", message: "No ambient-credential environment variable is set." };
|
|
42360
|
+
}
|
|
42194
42361
|
var AMBIENT_CREDENTIAL_VARS;
|
|
42195
42362
|
var init_guard = __esm({
|
|
42196
42363
|
"src/launcher/guard.ts"() {
|
|
42197
42364
|
"use strict";
|
|
42365
|
+
init_injected();
|
|
42198
42366
|
AMBIENT_CREDENTIAL_VARS = [
|
|
42199
42367
|
"ANTHROPIC_API_KEY",
|
|
42200
42368
|
"ANTHROPIC_AUTH_TOKEN",
|
|
@@ -66029,8 +66197,8 @@ var require_connection = __commonJS({
|
|
|
66029
66197
|
return;
|
|
66030
66198
|
}
|
|
66031
66199
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
66032
|
-
const
|
|
66033
|
-
if (secWSAccept !==
|
|
66200
|
+
const digest3 = crypto.hash("sha1", keyValue + uid, "base64");
|
|
66201
|
+
if (secWSAccept !== digest3) {
|
|
66034
66202
|
failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
66035
66203
|
return;
|
|
66036
66204
|
}
|
|
@@ -68609,7 +68777,7 @@ function base64Url(bytes) {
|
|
|
68609
68777
|
}
|
|
68610
68778
|
function newPkce(randomBytes5) {
|
|
68611
68779
|
const verifier = base64Url(randomBytes5(SIWC_RANDOM_BYTES));
|
|
68612
|
-
return { verifier, challenge: (0,
|
|
68780
|
+
return { verifier, challenge: (0, import_node_crypto14.createHash)("sha256").update(verifier).digest("base64url") };
|
|
68613
68781
|
}
|
|
68614
68782
|
function newOpaqueValue(randomBytes5) {
|
|
68615
68783
|
return base64Url(randomBytes5(SIWC_RANDOM_BYTES));
|
|
@@ -68718,7 +68886,7 @@ async function verifyIdToken(ports, idToken, expected) {
|
|
|
68718
68886
|
throw new SiwcError("the issuer's key set has no key for the ID token's signature");
|
|
68719
68887
|
}
|
|
68720
68888
|
const signed = Buffer.from(`${headerSegment}.${payloadSegment}`);
|
|
68721
|
-
if (!(0,
|
|
68889
|
+
if (!(0, import_node_crypto14.verify)("sha256", signed, (0, import_node_crypto14.createPublicKey)({ key: jwk, format: "jwk" }), Buffer.from(signatureSegment, "base64url"))) {
|
|
68722
68890
|
throw new SiwcError("the ID token's signature did not verify");
|
|
68723
68891
|
}
|
|
68724
68892
|
const claims = IdTokenClaimsSchema.parse(decodeSegment(payloadSegment));
|
|
@@ -68736,11 +68904,11 @@ async function verifyIdToken(ports, idToken, expected) {
|
|
|
68736
68904
|
}
|
|
68737
68905
|
return { sub: claims.sub, email: claims.email };
|
|
68738
68906
|
}
|
|
68739
|
-
var
|
|
68907
|
+
var import_node_crypto14, SIWC_AUTHORIZE_URL, SIWC_TOKEN_URL, SIWC_REVOKE_URL, SIWC_ISSUER, SIWC_JWKS_URL, SIWC_DYNAMIC_CLIENT_ID, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_SCOPES, SIWC_PLAN_SCOPE, SIWC_CALLBACK_PORT, SIWC_CALLBACK_PATH, SIWC_RANDOM_BYTES, MS_PER_SECOND7, ID_TOKEN_ALGORITHM, SiwcError, SiwcInvalidGrantError, TokenResponseSchema, ERROR_BODY_CHARS, TOKEN_CALL_TIMEOUT_MS, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
68740
68908
|
var init_siwc = __esm({
|
|
68741
68909
|
"src/codex/siwc.ts"() {
|
|
68742
68910
|
"use strict";
|
|
68743
|
-
|
|
68911
|
+
import_node_crypto14 = require("node:crypto");
|
|
68744
68912
|
init_zod();
|
|
68745
68913
|
SIWC_AUTHORIZE_URL = "https://auth.openai.com/api/accounts/authorize";
|
|
68746
68914
|
SIWC_TOKEN_URL = "https://auth.openai.com/api/accounts/oauth/token";
|
|
@@ -68910,7 +69078,7 @@ function parseCatalogueBinding(raw) {
|
|
|
68910
69078
|
}
|
|
68911
69079
|
}
|
|
68912
69080
|
function catalogueCredentialFingerprint(cli, token, accountId) {
|
|
68913
|
-
return (0,
|
|
69081
|
+
return (0, import_node_crypto18.createHash)("sha256").update(JSON.stringify([cli, token, accountId])).digest("hex");
|
|
68914
69082
|
}
|
|
68915
69083
|
function cliCatalogueFingerprint(raw) {
|
|
68916
69084
|
if (raw === void 0) return void 0;
|
|
@@ -68935,11 +69103,11 @@ function savedCatalogueFingerprint(provider, paths, env, home, read) {
|
|
|
68935
69103
|
const codexHome2 = configuredHome === void 0 || configuredHome === "" ? import_node_path48.default.join(home, ".codex") : configuredHome;
|
|
68936
69104
|
return cliCatalogueFingerprint(read(import_node_path48.default.join(codexHome2, "auth.json")));
|
|
68937
69105
|
}
|
|
68938
|
-
var
|
|
69106
|
+
var import_node_crypto18, import_node_path48, CatalogueBindingSchema;
|
|
68939
69107
|
var init_catalogueCredential = __esm({
|
|
68940
69108
|
"src/codex/catalogueCredential.ts"() {
|
|
68941
69109
|
"use strict";
|
|
68942
|
-
|
|
69110
|
+
import_node_crypto18 = require("node:crypto");
|
|
68943
69111
|
import_node_path48 = __toESM(require("node:path"), 1);
|
|
68944
69112
|
init_zod();
|
|
68945
69113
|
init_siwcStore();
|
|
@@ -69117,7 +69285,7 @@ function ensureFrontDoor(params) {
|
|
|
69117
69285
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
69118
69286
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
69119
69287
|
if (supervisorPid === params.launcherPid && params.replace === void 0 && ports.isFrontDoorSupervisor(supervisorPid)) {
|
|
69120
|
-
const token = (0,
|
|
69288
|
+
const token = (0, import_node_crypto19.randomUUID)();
|
|
69121
69289
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
69122
69290
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
69123
69291
|
}
|
|
@@ -69138,7 +69306,7 @@ function ensureFrontDoor(params) {
|
|
|
69138
69306
|
continue;
|
|
69139
69307
|
}
|
|
69140
69308
|
if (verdict.ok) {
|
|
69141
|
-
const token = (0,
|
|
69309
|
+
const token = (0, import_node_crypto19.randomUUID)();
|
|
69142
69310
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid, ...recordOf(params.session) });
|
|
69143
69311
|
return { port: state.port, connectPort: state.connectPort, token, supervisorPid };
|
|
69144
69312
|
}
|
|
@@ -69208,11 +69376,11 @@ function restartFrontDoor(params) {
|
|
|
69208
69376
|
}
|
|
69209
69377
|
return { action: "restarted", previousPid, pid };
|
|
69210
69378
|
}
|
|
69211
|
-
var
|
|
69379
|
+
var import_node_crypto19, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
|
|
69212
69380
|
var init_ensure2 = __esm({
|
|
69213
69381
|
"src/frontdoor/ensure.ts"() {
|
|
69214
69382
|
"use strict";
|
|
69215
|
-
|
|
69383
|
+
import_node_crypto19 = require("node:crypto");
|
|
69216
69384
|
init_cliError();
|
|
69217
69385
|
init_state2();
|
|
69218
69386
|
init_replacement();
|
|
@@ -69397,18 +69565,18 @@ function resolveTrustBundle(params) {
|
|
|
69397
69565
|
}
|
|
69398
69566
|
const combined = `${inheritedPem.trimEnd()}
|
|
69399
69567
|
${caPem}`;
|
|
69400
|
-
const bundle = import_node_path52.default.join(bundlesDir, `${(0,
|
|
69568
|
+
const bundle = import_node_path52.default.join(bundlesDir, `${(0, import_node_crypto20.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
69401
69569
|
if (!fs36.exists(bundle)) {
|
|
69402
69570
|
fs36.mkdirp(bundlesDir);
|
|
69403
69571
|
fs36.writeFileAtomic(bundle, combined);
|
|
69404
69572
|
}
|
|
69405
69573
|
return { path: bundle };
|
|
69406
69574
|
}
|
|
69407
|
-
var
|
|
69575
|
+
var import_node_crypto20, import_node_path52, BUNDLE_NAME_HEX_DIGITS;
|
|
69408
69576
|
var init_trust = __esm({
|
|
69409
69577
|
"src/frontdoor/trust.ts"() {
|
|
69410
69578
|
"use strict";
|
|
69411
|
-
|
|
69579
|
+
import_node_crypto20 = require("node:crypto");
|
|
69412
69580
|
import_node_path52 = __toESM(require("node:path"), 1);
|
|
69413
69581
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
69414
69582
|
}
|
|
@@ -69681,11 +69849,11 @@ async function downloadAndInstall(ports, asset, target) {
|
|
|
69681
69849
|
throw new UpdateDownloadError(`the downloaded files for ${asset} are missing from ${tempDir}`);
|
|
69682
69850
|
}
|
|
69683
69851
|
const expected = expectedSha256(sidecar);
|
|
69684
|
-
const actual = (0,
|
|
69852
|
+
const actual = (0, import_node_crypto21.createHash)("sha256").update(downloaded).digest("hex");
|
|
69685
69853
|
if (expected === void 0 || expected !== actual) {
|
|
69686
69854
|
throw new UpdateDownloadError(`checksum mismatch for ${asset} (expected ${expected ?? "(none)"}, got ${actual})`);
|
|
69687
69855
|
}
|
|
69688
|
-
const tempBinary = import_node_path53.default.join(import_node_path53.default.dirname(target), `.${import_node_path53.default.basename(target)}.${String(process.pid)}.${(0,
|
|
69856
|
+
const tempBinary = import_node_path53.default.join(import_node_path53.default.dirname(target), `.${import_node_path53.default.basename(target)}.${String(process.pid)}.${(0, import_node_crypto21.randomUUID)()}.tmp`);
|
|
69689
69857
|
ports.fs.writeFileBytes(tempBinary, downloaded);
|
|
69690
69858
|
try {
|
|
69691
69859
|
ports.fs.chmod(tempBinary, EXECUTABLE_MODE);
|
|
@@ -69732,11 +69900,11 @@ async function runSelfUpdate(ports, options) {
|
|
|
69732
69900
|
}
|
|
69733
69901
|
return { current: options.currentVersion, latest, action: "updated" };
|
|
69734
69902
|
}
|
|
69735
|
-
var
|
|
69903
|
+
var import_node_crypto21, import_node_path53, LATEST_RELEASE_URL, DOWNLOAD_BASE_URL, MACOS_X64_NOTE, BREW_PREFIXES, EXECUTABLE_MODE, UpdateChannelError, UpdateConflictError, UpdateDownloadError;
|
|
69736
69904
|
var init_update = __esm({
|
|
69737
69905
|
"src/update/update.ts"() {
|
|
69738
69906
|
"use strict";
|
|
69739
|
-
|
|
69907
|
+
import_node_crypto21 = require("node:crypto");
|
|
69740
69908
|
import_node_path53 = __toESM(require("node:path"), 1);
|
|
69741
69909
|
init_cliError();
|
|
69742
69910
|
LATEST_RELEASE_URL = "https://github.com/ExaDev/agent-shim/releases/latest";
|
|
@@ -70177,43 +70345,6 @@ var init_cliOverride = __esm({
|
|
|
70177
70345
|
}
|
|
70178
70346
|
});
|
|
70179
70347
|
|
|
70180
|
-
// src/headroom/headers.ts
|
|
70181
|
-
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
70182
|
-
const merged = /* @__PURE__ */ new Map();
|
|
70183
|
-
for (const block2 of existing) {
|
|
70184
|
-
if (block2 === void 0) {
|
|
70185
|
-
continue;
|
|
70186
|
-
}
|
|
70187
|
-
for (const line of block2.split("\n")) {
|
|
70188
|
-
const entry = parseCustomHeaderLine(line);
|
|
70189
|
-
if (entry === void 0) {
|
|
70190
|
-
continue;
|
|
70191
|
-
}
|
|
70192
|
-
merged.set(entry.name, entry.value);
|
|
70193
|
-
}
|
|
70194
|
-
}
|
|
70195
|
-
for (const entry of additions) {
|
|
70196
|
-
merged.set(entry.name, entry.value);
|
|
70197
|
-
}
|
|
70198
|
-
return [...merged].map(([name, value3]) => `${name}: ${value3}`).join("\n");
|
|
70199
|
-
}
|
|
70200
|
-
function parseCustomHeaderLine(line) {
|
|
70201
|
-
const trimmed = line.trim();
|
|
70202
|
-
if (trimmed === "") {
|
|
70203
|
-
return void 0;
|
|
70204
|
-
}
|
|
70205
|
-
const colon = trimmed.indexOf(":");
|
|
70206
|
-
if (colon <= 0) {
|
|
70207
|
-
return void 0;
|
|
70208
|
-
}
|
|
70209
|
-
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
70210
|
-
}
|
|
70211
|
-
var init_headers = __esm({
|
|
70212
|
-
"src/headroom/headers.ts"() {
|
|
70213
|
-
"use strict";
|
|
70214
|
-
}
|
|
70215
|
-
});
|
|
70216
|
-
|
|
70217
70348
|
// src/statusline/settings.ts
|
|
70218
70349
|
function checkedStatusline(settings2, source) {
|
|
70219
70350
|
try {
|
|
@@ -70296,7 +70427,10 @@ function buildArgv(params) {
|
|
|
70296
70427
|
return [...params.toolFlags, ...params.extraFlags, ...params.passthrough];
|
|
70297
70428
|
}
|
|
70298
70429
|
function buildEnv(params) {
|
|
70299
|
-
const
|
|
70430
|
+
const injections = recordInjections(params.baseEnv);
|
|
70431
|
+
const { env } = injections;
|
|
70432
|
+
const inject = injections.set;
|
|
70433
|
+
const injectedHeaderNames = [];
|
|
70300
70434
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
70301
70435
|
let providerCustomHeaders;
|
|
70302
70436
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
@@ -70305,53 +70439,75 @@ function buildEnv(params) {
|
|
|
70305
70439
|
if (params.provider !== void 0) {
|
|
70306
70440
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
70307
70441
|
providerCustomHeaders = providerEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
70308
|
-
|
|
70309
|
-
|
|
70442
|
+
injections.unset("ANTHROPIC_BASE_URL");
|
|
70443
|
+
inject("AGENT_SHIM_PROVIDER", params.provider.definition.displayName);
|
|
70310
70444
|
for (const [key, value3] of Object.entries(providerEnv)) {
|
|
70311
|
-
|
|
70445
|
+
if (key === CUSTOM_HEADERS_ENV) {
|
|
70446
|
+
env[key] = value3;
|
|
70447
|
+
injectedHeaderNames.push(...parseAnthropicCustomHeaders(value3).map(({ name }) => name));
|
|
70448
|
+
} else if (key === "NO_PROXY" || key === "no_proxy") {
|
|
70449
|
+
env[key] = value3;
|
|
70450
|
+
injections.recordBypassHosts(key, value3.split(","));
|
|
70451
|
+
} else {
|
|
70452
|
+
inject(key, value3);
|
|
70453
|
+
}
|
|
70312
70454
|
}
|
|
70313
70455
|
}
|
|
70314
70456
|
for (const tier of CLAUDE_TIERS) {
|
|
70315
70457
|
const ref = params.tierModels?.[tier];
|
|
70316
70458
|
if (ref !== void 0) {
|
|
70317
|
-
|
|
70459
|
+
inject(`ANTHROPIC_DEFAULT_${tier.toUpperCase()}_MODEL`, ref);
|
|
70318
70460
|
}
|
|
70319
70461
|
}
|
|
70320
70462
|
if (params.provider !== void 0) {
|
|
70321
|
-
|
|
70322
|
-
|
|
70323
|
-
|
|
70463
|
+
if (params.remoteControl) {
|
|
70464
|
+
injections.unset("ANTHROPIC_AUTH_TOKEN");
|
|
70465
|
+
} else {
|
|
70466
|
+
inject("ANTHROPIC_AUTH_TOKEN", PROVIDER_SESSION_PLACEHOLDER);
|
|
70467
|
+
}
|
|
70468
|
+
injections.unset("ANTHROPIC_API_KEY");
|
|
70469
|
+
injections.unset("CLAUDE_CODE_OAUTH_TOKEN");
|
|
70324
70470
|
} else if (params.identityCredential !== void 0) {
|
|
70325
70471
|
for (const [variable, value3] of Object.entries(credentialVariables(params.identityCredential.target, params.identityCredential.token))) {
|
|
70326
|
-
|
|
70472
|
+
if (value3 === void 0) {
|
|
70473
|
+
injections.unset(variable);
|
|
70474
|
+
} else {
|
|
70475
|
+
inject(variable, value3);
|
|
70476
|
+
}
|
|
70327
70477
|
}
|
|
70328
70478
|
}
|
|
70329
70479
|
if (params.frontdoor !== void 0) {
|
|
70480
|
+
const launcherHeaders = [
|
|
70481
|
+
...params.identityId === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.identityId }],
|
|
70482
|
+
{ name: SESSION_HEADER, value: params.sessionId },
|
|
70483
|
+
{ name: AUTH_HEADER, value: params.frontdoor.sessionToken },
|
|
70484
|
+
...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
|
|
70485
|
+
...params.headroom === void 0 ? [] : [
|
|
70486
|
+
{ name: HEADROOM_FLAG_HEADER, value: "1" },
|
|
70487
|
+
{ name: PROJECT_ID_HEADER, value: params.headroom.projectId }
|
|
70488
|
+
]
|
|
70489
|
+
];
|
|
70490
|
+
injectedHeaderNames.push(...launcherHeaders.map(({ name }) => name));
|
|
70330
70491
|
env.ANTHROPIC_CUSTOM_HEADERS = mergeAnthropicCustomHeaders(
|
|
70331
70492
|
[
|
|
70332
70493
|
...parentCustomHeaders === void 0 ? [] : [parentCustomHeaders],
|
|
70333
70494
|
...providerCustomHeaders === void 0 ? [] : [providerCustomHeaders]
|
|
70334
70495
|
],
|
|
70335
|
-
|
|
70336
|
-
...params.identityId === void 0 ? [] : [{ name: IDENTITY_HEADER, value: params.identityId }],
|
|
70337
|
-
{ name: SESSION_HEADER, value: params.sessionId },
|
|
70338
|
-
{ name: AUTH_HEADER, value: params.frontdoor.sessionToken },
|
|
70339
|
-
...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
|
|
70340
|
-
...params.headroom === void 0 ? [] : [
|
|
70341
|
-
{ name: HEADROOM_FLAG_HEADER, value: "1" },
|
|
70342
|
-
{ name: PROJECT_ID_HEADER, value: params.headroom.projectId }
|
|
70343
|
-
]
|
|
70344
|
-
]
|
|
70496
|
+
launcherHeaders
|
|
70345
70497
|
);
|
|
70346
|
-
|
|
70347
|
-
|
|
70498
|
+
inject("NODE_EXTRA_CA_CERTS", params.frontdoor.trustBundlePath);
|
|
70499
|
+
inject("HTTPS_PROXY", connectProxyUrl(params.frontdoor.connectPort, params.frontdoor.sessionToken));
|
|
70348
70500
|
const bypassed = [...LOOPBACK_HOSTS, ...params.proxyBypass ?? []];
|
|
70349
|
-
|
|
70350
|
-
|
|
70501
|
+
for (const list2 of ["NO_PROXY", "no_proxy"]) {
|
|
70502
|
+
injections.recordBypassHosts(list2, appendedBypassHosts(env[list2], bypassed));
|
|
70503
|
+
env[list2] = withBypassHosts(env[list2], bypassed);
|
|
70504
|
+
}
|
|
70351
70505
|
}
|
|
70352
70506
|
if (params.statusline !== void 0) {
|
|
70353
|
-
|
|
70507
|
+
inject(STATUSLINE_ENV, JSON.stringify(params.statusline));
|
|
70354
70508
|
}
|
|
70509
|
+
injections.recordHeaders(injectedHeaderNames);
|
|
70510
|
+
injections.finish();
|
|
70355
70511
|
return env;
|
|
70356
70512
|
}
|
|
70357
70513
|
var import_node_path56, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
@@ -70365,6 +70521,7 @@ var init_flags = __esm({
|
|
|
70365
70521
|
init_schema();
|
|
70366
70522
|
init_credential();
|
|
70367
70523
|
init_headers();
|
|
70524
|
+
init_injected();
|
|
70368
70525
|
init_capability();
|
|
70369
70526
|
init_route();
|
|
70370
70527
|
init_statusline();
|
|
@@ -71309,7 +71466,7 @@ function buildCloudRequestBody(params) {
|
|
|
71309
71466
|
if (isCcpaEndpoint(base)) {
|
|
71310
71467
|
return JSON.stringify({
|
|
71311
71468
|
project: params.config.cloud.projectId ?? CCPA_DEFAULT_PROJECT_ID,
|
|
71312
|
-
requestId: `agent/${(0,
|
|
71469
|
+
requestId: `agent/${(0, import_node_crypto22.randomUUID)()}/${String(Date.now())}/1`,
|
|
71313
71470
|
request: params.request,
|
|
71314
71471
|
model: params.model,
|
|
71315
71472
|
userAgent: "antigravity"
|
|
@@ -71377,11 +71534,11 @@ function* chunksOfLine(line) {
|
|
|
71377
71534
|
}
|
|
71378
71535
|
}
|
|
71379
71536
|
}
|
|
71380
|
-
var
|
|
71537
|
+
var import_node_crypto22, CCPA_ENDPOINT, CCPA_DEFAULT_PROJECT_ID, CCPA_USER_AGENT, AntigravityUpstreamError, SSE_DATA_PREFIX;
|
|
71381
71538
|
var init_cloudUpstream = __esm({
|
|
71382
71539
|
"src/antigravity/cloudUpstream.ts"() {
|
|
71383
71540
|
"use strict";
|
|
71384
|
-
|
|
71541
|
+
import_node_crypto22 = require("node:crypto");
|
|
71385
71542
|
CCPA_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
|
|
71386
71543
|
CCPA_DEFAULT_PROJECT_ID = "aicode-consumers";
|
|
71387
71544
|
CCPA_USER_AGENT = "antigravity/cli/1.3.5 (aidev_client; os_type=darwin; arch=arm64; cl=998863838; auth_method=consumer)";
|
|
@@ -71921,7 +72078,7 @@ function shortToolName(name, names) {
|
|
|
71921
72078
|
if (sanitized.length <= ANTIGRAVITY_TOOL_NAME_LIMIT) {
|
|
71922
72079
|
result = sanitized;
|
|
71923
72080
|
} else {
|
|
71924
|
-
const hash2 = (0,
|
|
72081
|
+
const hash2 = (0, import_node_crypto23.createHash)("sha256").update(name).digest("hex").slice(0, TOOL_NAME_HASH_CHARS);
|
|
71925
72082
|
const prefix = sanitized.slice(0, ANTIGRAVITY_TOOL_NAME_LIMIT - TOOL_NAME_HASH_CHARS - 1);
|
|
71926
72083
|
result = `${prefix}_${hash2}`;
|
|
71927
72084
|
}
|
|
@@ -72090,11 +72247,11 @@ function translateRequest(request7, config2, routing) {
|
|
|
72090
72247
|
toolNames
|
|
72091
72248
|
};
|
|
72092
72249
|
}
|
|
72093
|
-
var
|
|
72250
|
+
var import_node_crypto23, SECONDS_PER_HOUR3, NEUTRAL_PRESSURE, AUTO_ALIAS, BACKEND_FAMILY_PREFIXES, BACKEND_CLAUDE_NAME, EFFORT_TO_BUDGET, BILLING_HEADER_LINE, ANTIGRAVITY_TOOL_NAME_LIMIT, TOOL_NAME_HASH_CHARS, NON_TEXT_TOOL_RESULT, EMPTY_SCHEMA, EFFORT_SUFFIXES;
|
|
72094
72251
|
var init_translate = __esm({
|
|
72095
72252
|
"src/antigravity/translate.ts"() {
|
|
72096
72253
|
"use strict";
|
|
72097
|
-
|
|
72254
|
+
import_node_crypto23 = require("node:crypto");
|
|
72098
72255
|
init_identity2();
|
|
72099
72256
|
init_engine();
|
|
72100
72257
|
init_quota();
|
|
@@ -72164,7 +72321,7 @@ function shortToolName2(name, names) {
|
|
|
72164
72321
|
if (name.length <= CODEX_TOOL_NAME_LIMIT) {
|
|
72165
72322
|
return name;
|
|
72166
72323
|
}
|
|
72167
|
-
const hash2 = (0,
|
|
72324
|
+
const hash2 = (0, import_node_crypto24.createHash)("sha256").update(name).digest("hex").slice(0, TOOL_NAME_HASH_CHARS2);
|
|
72168
72325
|
const shortened = `${name.slice(0, CODEX_TOOL_NAME_LIMIT - TOOL_NAME_HASH_CHARS2 - 1)}_${hash2}`;
|
|
72169
72326
|
names.set(shortened, name);
|
|
72170
72327
|
return shortened;
|
|
@@ -72287,11 +72444,11 @@ function translateRequest2(body, config2) {
|
|
|
72287
72444
|
};
|
|
72288
72445
|
return { request: request7, toolNames: names };
|
|
72289
72446
|
}
|
|
72290
|
-
var
|
|
72447
|
+
var import_node_crypto24, REQUESTABLE_EFFORTS, BILLING_HEADER_LINE2, CODEX_TOOL_NAME_LIMIT, TOOL_NAME_HASH_CHARS2, NON_TEXT_TOOL_RESULT2, EMPTY_PARAMETERS;
|
|
72291
72448
|
var init_translate2 = __esm({
|
|
72292
72449
|
"src/codex/translate.ts"() {
|
|
72293
72450
|
"use strict";
|
|
72294
|
-
|
|
72451
|
+
import_node_crypto24 = require("node:crypto");
|
|
72295
72452
|
init_schema();
|
|
72296
72453
|
init_anthropic();
|
|
72297
72454
|
REQUESTABLE_EFFORTS = ["low", "medium", "high"];
|
|
@@ -72884,19 +73041,18 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
72884
73041
|
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
72885
73042
|
};
|
|
72886
73043
|
}
|
|
73044
|
+
function warnOfSupersededConfigDir(warn, fs36, superseded, identity, identityDir) {
|
|
73045
|
+
if (superseded === void 0 || superseded === identityDir || fs36.sameDirectory(superseded, identityDir)) {
|
|
73046
|
+
return;
|
|
73047
|
+
}
|
|
73048
|
+
warn(`agent-shim: the identity named on the command line outranks the inherited CLAUDE_CONFIG_DIR ${superseded}; running as ${identity} in ${identityDir}`);
|
|
73049
|
+
}
|
|
72887
73050
|
function decideLaunch(params, readOnly, onRecorded) {
|
|
72888
73051
|
const { paths, fs: fs36, proc, log } = params;
|
|
72889
|
-
const {
|
|
73052
|
+
const { argv } = proc;
|
|
72890
73053
|
const parsedArgv = parseLauncherArgv(argv);
|
|
72891
|
-
const cliOverride = buildCliOverride({
|
|
72892
|
-
env,
|
|
72893
|
-
categoryFlags: parsedArgv.categoryFlags,
|
|
72894
|
-
shareFlags: parsedArgv.shareFlags,
|
|
72895
|
-
hideFlags: parsedArgv.hideFlags
|
|
72896
|
-
});
|
|
72897
|
-
const configDirEscapeHatchApplies = env.CLAUDE_CONFIG_DIR !== void 0 && env.CLAUDE_CONFIG_DIR !== "";
|
|
72898
73054
|
const decidedIdentity = decideIdentity({
|
|
72899
|
-
env,
|
|
73055
|
+
env: proc.env,
|
|
72900
73056
|
argv0Identity: params.pickedIdentity ?? parsedArgv.identity,
|
|
72901
73057
|
directoryPinnedIdentity: params.directoryPinnedIdentity,
|
|
72902
73058
|
readActiveIdentityFile: () => {
|
|
@@ -72908,6 +73064,14 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
72908
73064
|
return trimmed === "" ? void 0 : trimmed;
|
|
72909
73065
|
}
|
|
72910
73066
|
});
|
|
73067
|
+
const configDirEscapeHatchApplies = decidedIdentity.configDirEscapeHatch;
|
|
73068
|
+
const env = launchEnvironment(proc.env, configDirEscapeHatchApplies);
|
|
73069
|
+
const cliOverride = buildCliOverride({
|
|
73070
|
+
env,
|
|
73071
|
+
categoryFlags: parsedArgv.categoryFlags,
|
|
73072
|
+
shareFlags: parsedArgv.shareFlags,
|
|
73073
|
+
hideFlags: parsedArgv.hideFlags
|
|
73074
|
+
});
|
|
72911
73075
|
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
72912
73076
|
const lockFarm = !readOnly && !configDirEscapeHatchApplies && identityDecision.name !== void 0 ? params.farm : void 0;
|
|
72913
73077
|
const lockPorts = params.namesLock ?? (lockFarm === void 0 ? realIdentityNamesLockPorts : { fs: lockFarm.fs, nowMs: lockFarm.now, ...lockFarm.lock });
|
|
@@ -72915,6 +73079,9 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
72915
73079
|
try {
|
|
72916
73080
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs36);
|
|
72917
73081
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
73082
|
+
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
73083
|
+
warnOfSupersededConfigDir(log.warn, fs36, identityDecision.supersededConfigDir, identityDecision.name, import_node_path58.default.join(paths.identitiesDir, farmIdentity));
|
|
73084
|
+
}
|
|
72918
73085
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
72919
73086
|
try {
|
|
72920
73087
|
recoverFarmWarning(
|
|
@@ -73081,7 +73248,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
73081
73248
|
const doorPid = supervisorPid ?? (recordedPid !== void 0 && proc.isProcessAlive(recordedPid) ? recordedPid : void 0);
|
|
73082
73249
|
const doorRecord = doorPid === void 0 ? void 0 : readFrontDoorCodexRecord(params.fs, paths.frontdoorDir, doorPid);
|
|
73083
73250
|
const doorHome = doorRecord?.codexHome;
|
|
73084
|
-
const catalogueEnv = doorHome === void 0 ?
|
|
73251
|
+
const catalogueEnv = doorHome === void 0 ? env : { ...env, CODEX_HOME: doorHome };
|
|
73085
73252
|
const listedProviders = listProviderNames(fs36.readdir, paths.providersDir).flatMap((name) => {
|
|
73086
73253
|
try {
|
|
73087
73254
|
const definition = loadProvider(paths.providersDir, name, fs36);
|
|
@@ -73143,6 +73310,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
73143
73310
|
billing,
|
|
73144
73311
|
notes,
|
|
73145
73312
|
configDirEscapeHatch: configDirEscapeHatchApplies,
|
|
73313
|
+
env,
|
|
73146
73314
|
farmIdentity,
|
|
73147
73315
|
farmContext,
|
|
73148
73316
|
configProfileDecision,
|
|
@@ -73178,12 +73346,12 @@ function prepareLaunch(params) {
|
|
|
73178
73346
|
}
|
|
73179
73347
|
function prepareRegisteredLaunch(params, onRecorded) {
|
|
73180
73348
|
const { paths, proc, log } = params;
|
|
73181
|
-
const { env } = proc;
|
|
73182
73349
|
let unregisterLaunch;
|
|
73183
73350
|
const decided = decideLaunch(params, false, (remove) => {
|
|
73184
73351
|
unregisterLaunch = remove;
|
|
73185
73352
|
onRecorded(remove);
|
|
73186
73353
|
});
|
|
73354
|
+
const { env } = decided;
|
|
73187
73355
|
const { identityDecision, configProfileDecision, resolvedProvider, identityCredential, poolPick, poolRanking, lastRanAs, billing, notes, flags: resolvedFlags, configDirEscapeHatch: configDirEscapeHatchApplies, decision } = decided;
|
|
73188
73356
|
const rows = [
|
|
73189
73357
|
...decisionRows({
|
|
@@ -73258,7 +73426,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
73258
73426
|
log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
|
|
73259
73427
|
proc.exit(1);
|
|
73260
73428
|
}
|
|
73261
|
-
const sessionId = params.supervised?.sessionId ?? (0,
|
|
73429
|
+
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto25.randomUUID)();
|
|
73262
73430
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
73263
73431
|
const sessionModels = (0, import_node_util6.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
73264
73432
|
const session = { sessionId, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -73319,7 +73487,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
73319
73487
|
}
|
|
73320
73488
|
function resolveLaunch(params) {
|
|
73321
73489
|
const decided = decideLaunch(params, true);
|
|
73322
|
-
const { env } =
|
|
73490
|
+
const { env } = decided;
|
|
73323
73491
|
const frontDoor = decided.provider !== void 0 || decided.flags.headroom || decided.flags.trackUsage;
|
|
73324
73492
|
const built = buildEnv({
|
|
73325
73493
|
baseEnv: env,
|
|
@@ -73335,7 +73503,7 @@ function resolveLaunch(params) {
|
|
|
73335
73503
|
...decided.flags.statusline === void 0 ? {} : { statusline: decided.flags.statusline }
|
|
73336
73504
|
});
|
|
73337
73505
|
const credentialNames = decided.identityCredentialBlock === void 0 ? [] : Object.keys(credentialVariables(decided.identityCredentialBlock.target ?? "bearer", ""));
|
|
73338
|
-
const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => built[name] !== env[name]), ...credentialNames])].sort();
|
|
73506
|
+
const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => name !== INJECTED_ENV && built[name] !== env[name]), ...credentialNames])].sort();
|
|
73339
73507
|
const credential = decided.provider !== void 0 ? isRouterProvider(decided.provider.definition) ? void 0 : { subject: "provider", name: decided.provider.name, summary: summariseCredential(decided.provider.definition.credential) } : decided.identityCredentialBlock !== void 0 && decided.farmIdentity !== void 0 && decided.identityDecision.name !== void 0 ? { subject: "identity", name: decided.identityDecision.name, summary: summariseCredential(decided.identityCredentialBlock) } : void 0;
|
|
73340
73508
|
return {
|
|
73341
73509
|
decision: decided.decision,
|
|
@@ -73366,11 +73534,11 @@ function runLaunchPlan(plan, spawn10) {
|
|
|
73366
73534
|
function runLauncher(params) {
|
|
73367
73535
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
73368
73536
|
}
|
|
73369
|
-
var
|
|
73537
|
+
var import_node_crypto25, import_node_os13, import_node_util6, import_node_path58;
|
|
73370
73538
|
var init_launcher = __esm({
|
|
73371
73539
|
"src/launcher.ts"() {
|
|
73372
73540
|
"use strict";
|
|
73373
|
-
|
|
73541
|
+
import_node_crypto25 = require("node:crypto");
|
|
73374
73542
|
import_node_os13 = __toESM(require("node:os"), 1);
|
|
73375
73543
|
init_catalogueCredential();
|
|
73376
73544
|
import_node_util6 = require("node:util");
|
|
@@ -73416,6 +73584,7 @@ var init_launcher = __esm({
|
|
|
73416
73584
|
init_launchHook();
|
|
73417
73585
|
init_targets();
|
|
73418
73586
|
init_names();
|
|
73587
|
+
init_injected();
|
|
73419
73588
|
}
|
|
73420
73589
|
});
|
|
73421
73590
|
|
|
@@ -73500,7 +73669,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
73500
73669
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
73501
73670
|
}).input,
|
|
73502
73671
|
now: () => Date.now(),
|
|
73503
|
-
uniqueSuffix: `${String(process.pid)}.${(0,
|
|
73672
|
+
uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto26.randomUUID)()}`,
|
|
73504
73673
|
// Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
|
|
73505
73674
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
73506
73675
|
},
|
|
@@ -73569,13 +73738,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
73569
73738
|
async function resolveClaudeLaunchAsync(options, runAsync2 = realRunAsync) {
|
|
73570
73739
|
return await resolveWithAsyncRuns((run) => resolveClaudeLaunch(options, run), runAsync2);
|
|
73571
73740
|
}
|
|
73572
|
-
var import_node_os14, import_node_path59,
|
|
73741
|
+
var import_node_os14, import_node_path59, import_node_crypto26, LaunchRefusedError;
|
|
73573
73742
|
var init_launchWiring = __esm({
|
|
73574
73743
|
"src/launchWiring.ts"() {
|
|
73575
73744
|
"use strict";
|
|
73576
73745
|
import_node_os14 = __toESM(require("node:os"), 1);
|
|
73577
73746
|
import_node_path59 = __toESM(require("node:path"), 1);
|
|
73578
|
-
|
|
73747
|
+
import_node_crypto26 = require("node:crypto");
|
|
73579
73748
|
init_cliError();
|
|
73580
73749
|
init_claudeShim();
|
|
73581
73750
|
init_classify();
|
|
@@ -73610,7 +73779,7 @@ function identityLaunchArgv(identity, flags) {
|
|
|
73610
73779
|
}
|
|
73611
73780
|
async function withIdentityClaude(params, identity, flags, use2) {
|
|
73612
73781
|
const refusals = [];
|
|
73613
|
-
const env =
|
|
73782
|
+
const env = { ...process.env };
|
|
73614
73783
|
const argv = [...identityLaunchArgv(identity, flags)];
|
|
73615
73784
|
const run = await recordRuns((replay) => resolveClaudeLaunch({ argv, cwd: params.cwd, env: definedEnvironment(env), paths: params.paths }, replay), params.runAsync ?? realRunAsync);
|
|
73616
73785
|
const farm = buildFarmRuntime(params.paths, params.cwd, run);
|
|
@@ -73648,7 +73817,7 @@ async function withIdentityClaude(params, identity, flags, use2) {
|
|
|
73648
73817
|
plan.release();
|
|
73649
73818
|
}
|
|
73650
73819
|
}
|
|
73651
|
-
var
|
|
73820
|
+
var IDENTITY_ONLY_FLAG;
|
|
73652
73821
|
var init_identityClaude = __esm({
|
|
73653
73822
|
"src/usage/identityClaude.ts"() {
|
|
73654
73823
|
"use strict";
|
|
@@ -73657,7 +73826,6 @@ var init_identityClaude = __esm({
|
|
|
73657
73826
|
init_realPorts();
|
|
73658
73827
|
init_replayRun();
|
|
73659
73828
|
init_identityNamesLock();
|
|
73660
|
-
CONFIG_DIR_VARIABLE2 = "CLAUDE_CONFIG_DIR";
|
|
73661
73829
|
IDENTITY_ONLY_FLAG = "--no-provider";
|
|
73662
73830
|
}
|
|
73663
73831
|
});
|
|
@@ -124492,6 +124660,7 @@ init_farm();
|
|
|
124492
124660
|
init_guard();
|
|
124493
124661
|
init_providersStore();
|
|
124494
124662
|
init_projects();
|
|
124663
|
+
init_injected();
|
|
124495
124664
|
init_pipeline();
|
|
124496
124665
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
124497
124666
|
function projectFragmentOf(rawKey) {
|
|
@@ -124664,10 +124833,11 @@ function runCheck(params) {
|
|
|
124664
124833
|
const resolved = resolveDecisions({ facts, cascade: params.cascade, classification: params.classification });
|
|
124665
124834
|
const decisionLines = [...resolved.decisions.values()].slice().sort((a10, b) => a10.relPath < b.relPath ? -1 : a10.relPath > b.relPath ? 1 : 0).map(formatDecision);
|
|
124666
124835
|
const projectEncodingAmbiguities = flagAmbiguousEncodings(resolved.flattened, facts);
|
|
124836
|
+
const guardEnv = launchEnvironment(params.env, params.configDirEscapeHatch);
|
|
124667
124837
|
const ambientCredential = isCodex ? codexCredentialGuard(params.env, params.identity?.allowAmbientCredential ?? false) : evaluateAmbientCredentialGuard({
|
|
124668
|
-
env:
|
|
124838
|
+
env: guardEnv,
|
|
124669
124839
|
allowAmbientCredential: params.identity?.allowAmbientCredential ?? false,
|
|
124670
|
-
allowAmbientCredentialOverride: parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL",
|
|
124840
|
+
allowAmbientCredentialOverride: parseEnvBool("AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL", guardEnv.AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL) === true,
|
|
124671
124841
|
...params.identityName === void 0 ? {} : { identityName: params.identityName }
|
|
124672
124842
|
});
|
|
124673
124843
|
const settingsShared = resolved.flattened.categories.get("settings") ?? SHIPPED_CATEGORY_DEFAULTS.settings;
|
|
@@ -124837,6 +125007,7 @@ function collectCheckReport(params) {
|
|
|
124837
125007
|
home,
|
|
124838
125008
|
claudeHome,
|
|
124839
125009
|
env: params.env,
|
|
125010
|
+
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
124840
125011
|
...git.branch === void 0 ? {} : { branch: git.branch },
|
|
124841
125012
|
...git.branchDetached === void 0 ? {} : { branchDetached: git.branchDetached },
|
|
124842
125013
|
nowMs: Date.now(),
|
|
@@ -124884,7 +125055,7 @@ function registerCheckCommand(program2, deps) {
|
|
|
124884
125055
|
}
|
|
124885
125056
|
|
|
124886
125057
|
// src/codex/commands.ts
|
|
124887
|
-
var
|
|
125058
|
+
var import_node_crypto17 = require("node:crypto");
|
|
124888
125059
|
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
124889
125060
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
124890
125061
|
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
@@ -125007,7 +125178,7 @@ async function runSiwcLogout(ports) {
|
|
|
125007
125178
|
|
|
125008
125179
|
// src/codex/siwcPorts.ts
|
|
125009
125180
|
var import_node_child_process5 = require("node:child_process");
|
|
125010
|
-
var
|
|
125181
|
+
var import_node_crypto15 = require("node:crypto");
|
|
125011
125182
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
125012
125183
|
|
|
125013
125184
|
// src/codex/http.ts
|
|
@@ -125030,7 +125201,7 @@ var HTTP_STATUS = {
|
|
|
125030
125201
|
// src/codex/siwcPorts.ts
|
|
125031
125202
|
init_siwc();
|
|
125032
125203
|
function realSiwcPorts(fetch3) {
|
|
125033
|
-
return { fetch: fetch3, randomBytes: (size) => (0,
|
|
125204
|
+
return { fetch: fetch3, randomBytes: (size) => (0, import_node_crypto15.randomBytes)(size), now: () => /* @__PURE__ */ new Date() };
|
|
125034
125205
|
}
|
|
125035
125206
|
var CALLBACK_PAGE = "<!doctype html><meta charset=utf-8><title>Signed in</title><p>You can close this tab and return to the terminal.</p>";
|
|
125036
125207
|
async function listenForCallback(port, state) {
|
|
@@ -125080,7 +125251,7 @@ function openInBrowser(url2) {
|
|
|
125080
125251
|
init_siwcStore();
|
|
125081
125252
|
|
|
125082
125253
|
// src/codex/upstream.ts
|
|
125083
|
-
var
|
|
125254
|
+
var import_node_crypto16 = require("node:crypto");
|
|
125084
125255
|
init_siwc();
|
|
125085
125256
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
125086
125257
|
var CODEX_UPSTREAM_TIMEOUT_MS = 3e5;
|
|
@@ -125117,7 +125288,7 @@ function sessionIdFor(userId, randomId) {
|
|
|
125117
125288
|
if (userId === void 0 || userId === "") {
|
|
125118
125289
|
return randomId();
|
|
125119
125290
|
}
|
|
125120
|
-
const hex3 = (0,
|
|
125291
|
+
const hex3 = (0, import_node_crypto16.createHash)("sha256").update(`agent-shim codex session
|
|
125121
125292
|
${userId}`).digest("hex");
|
|
125122
125293
|
let next = 0;
|
|
125123
125294
|
return UUID_TEMPLATE.replace(/x/g, () => hex3.charAt(next++));
|
|
@@ -125202,7 +125373,7 @@ function writeUsageSnapshot(log, snapshot) {
|
|
|
125202
125373
|
function createCodexRoutePorts(log, signInFile, options) {
|
|
125203
125374
|
const agent = createUpstreamAgent();
|
|
125204
125375
|
const upstreamFetch = createUpstreamFetch(agent);
|
|
125205
|
-
const tempSuffix = `${String(process.pid)}.${(0,
|
|
125376
|
+
const tempSuffix = `${String(process.pid)}.${(0, import_node_crypto17.randomUUID)()}`;
|
|
125206
125377
|
const auth = createCodexAuthStore(import_node_path47.default.join(codexHome(options?.env ?? process.env, import_node_os8.default.homedir()), "auth.json"), {
|
|
125207
125378
|
fs: realCodexAuthFs,
|
|
125208
125379
|
fetch: upstreamFetch,
|
|
@@ -125212,8 +125383,8 @@ function createCodexRoutePorts(log, signInFile, options) {
|
|
|
125212
125383
|
const signIn = createSiwcStore(signInFile, { fs: realCodexAuthFs, siwc: realSiwcPorts(upstreamFetch), tempSuffix });
|
|
125213
125384
|
return {
|
|
125214
125385
|
upstreams: {
|
|
125215
|
-
"codex-cli": { fetch: upstreamFetch, auth, timers: realTimers, randomId:
|
|
125216
|
-
"chatgpt-sign-in": { fetch: upstreamFetch, auth: signIn.auth, timers: realTimers, randomId:
|
|
125386
|
+
"codex-cli": { fetch: upstreamFetch, auth, timers: realTimers, randomId: import_node_crypto17.randomUUID },
|
|
125387
|
+
"chatgpt-sign-in": { fetch: upstreamFetch, auth: signIn.auth, timers: realTimers, randomId: import_node_crypto17.randomUUID, target: RESPONSES_API_TARGET }
|
|
125217
125388
|
},
|
|
125218
125389
|
...options?.enableUsageSnapshot === true ? {
|
|
125219
125390
|
writeUsageSnapshot: (snapshot) => {
|
|
@@ -125292,7 +125463,7 @@ async function runCodexLogout(paths) {
|
|
|
125292
125463
|
}
|
|
125293
125464
|
function realSiwcLoginPorts(paths) {
|
|
125294
125465
|
const siwc = realSiwcPorts(createUpstreamFetch(createUpstreamAgent()));
|
|
125295
|
-
const store = createSiwcStore(paths.chatgptSignInFile, { fs: realCodexAuthFs, siwc, tempSuffix: `${String(process.pid)}.${(0,
|
|
125466
|
+
const store = createSiwcStore(paths.chatgptSignInFile, { fs: realCodexAuthFs, siwc, tempSuffix: `${String(process.pid)}.${(0, import_node_crypto17.randomUUID)()}` });
|
|
125296
125467
|
return {
|
|
125297
125468
|
store,
|
|
125298
125469
|
siwc,
|
|
@@ -125350,7 +125521,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
125350
125521
|
}
|
|
125351
125522
|
|
|
125352
125523
|
// src/frontdoor/commands.ts
|
|
125353
|
-
var
|
|
125524
|
+
var import_node_crypto30 = require("node:crypto");
|
|
125354
125525
|
var import_node_os18 = __toESM(require("node:os"), 1);
|
|
125355
125526
|
init_catalogueCredential();
|
|
125356
125527
|
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
@@ -129796,12 +129967,8 @@ function runDoctor(params) {
|
|
|
129796
129967
|
}
|
|
129797
129968
|
push(section, "warn", `${where} pins Claude Code ${version2}, which is not installed (installed: ${installed.length === 0 ? "none" : installed.join(", ")}); a launch that resolves to it fails.`, subject);
|
|
129798
129969
|
};
|
|
129799
|
-
const ambient =
|
|
129800
|
-
|
|
129801
|
-
push("ambient-credential", "pass", "No ambient-credential environment variable is set.");
|
|
129802
|
-
} else {
|
|
129803
|
-
push("ambient-credential", "warn", formatAmbientCredentialGuardMessage(ambient.variable));
|
|
129804
|
-
}
|
|
129970
|
+
const ambient = ambientCredentialFinding(params.env);
|
|
129971
|
+
push("ambient-credential", ambient.severity, ambient.message);
|
|
129805
129972
|
if (params.binaryDiscovery.ok) {
|
|
129806
129973
|
const { binary } = params.binaryDiscovery;
|
|
129807
129974
|
const versionNote = binary.version === void 0 ? "" : `, version ${binary.version}`;
|
|
@@ -141582,6 +141749,7 @@ var LaunchDecisionSchema = external_exports.strictObject({
|
|
|
141582
141749
|
identityId: external_exports.string().optional(),
|
|
141583
141750
|
identitySource: external_exports.enum(IDENTITY_DECISION_SOURCES),
|
|
141584
141751
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
141752
|
+
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
141585
141753
|
configDirEscapeHatch: external_exports.boolean(),
|
|
141586
141754
|
configDir: external_exports.string().optional(),
|
|
141587
141755
|
configProfile: external_exports.string().optional(),
|
|
@@ -142361,7 +142529,7 @@ init_connect();
|
|
|
142361
142529
|
init_route();
|
|
142362
142530
|
|
|
142363
142531
|
// src/frontdoor/lineage.ts
|
|
142364
|
-
var
|
|
142532
|
+
var import_node_crypto27 = require("node:crypto");
|
|
142365
142533
|
var CACHE_MARKER_KEY = '"cache_control"';
|
|
142366
142534
|
var THREAD_MEMBER_KEYS = /* @__PURE__ */ new Set(['"model"', '"system"', '"tools"']);
|
|
142367
142535
|
var MESSAGES_KEY = '"messages"';
|
|
@@ -142438,8 +142606,8 @@ function nextToken(body, from) {
|
|
|
142438
142606
|
return SCALAR;
|
|
142439
142607
|
}
|
|
142440
142608
|
function walk2(body, hashing, parentAfter) {
|
|
142441
|
-
const thread = (0,
|
|
142442
|
-
const messages = (0,
|
|
142609
|
+
const thread = (0, import_node_crypto27.createHash)("sha256");
|
|
142610
|
+
const messages = (0, import_node_crypto27.createHash)("sha256");
|
|
142443
142611
|
let parentDigest;
|
|
142444
142612
|
let elements = 0;
|
|
142445
142613
|
let depth = 0;
|
|
@@ -142560,7 +142728,7 @@ function lineageOf(body) {
|
|
|
142560
142728
|
}
|
|
142561
142729
|
const parentAfter = counted3.elements > MESSAGES_PER_TURN ? counted3.elements - MESSAGES_PER_TURN : void 0;
|
|
142562
142730
|
const hashed = walk2(body, true, parentAfter);
|
|
142563
|
-
const combine = (messagesDigest) => (0,
|
|
142731
|
+
const combine = (messagesDigest) => (0, import_node_crypto27.createHash)("sha256").update(hashed.threadDigest).update(messagesDigest).digest("hex");
|
|
142564
142732
|
return { ownKey: combine(hashed.messagesDigest), parentKey: hashed.parentDigest === void 0 ? void 0 : combine(hashed.parentDigest) };
|
|
142565
142733
|
}
|
|
142566
142734
|
|
|
@@ -143678,7 +143846,7 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
|
|
|
143678
143846
|
}
|
|
143679
143847
|
|
|
143680
143848
|
// src/antigravity/route.ts
|
|
143681
|
-
var
|
|
143849
|
+
var import_node_crypto28 = require("node:crypto");
|
|
143682
143850
|
init_route();
|
|
143683
143851
|
init_anthropic();
|
|
143684
143852
|
|
|
@@ -144142,7 +144310,7 @@ function exhaustedMessage(exhaustion) {
|
|
|
144142
144310
|
return `Antigravity ${window} limit reached; it resets at ${new Date(exhaustion.resetSec * MS_PER_SECOND13).toISOString()}.`;
|
|
144143
144311
|
}
|
|
144144
144312
|
function createAntigravityRoute(ports) {
|
|
144145
|
-
const fallbackId = ports.fallbackId ?? (() => (0,
|
|
144313
|
+
const fallbackId = ports.fallbackId ?? (() => (0, import_node_crypto28.randomUUID)());
|
|
144146
144314
|
const lastRouted = ports.lastRouted ?? /* @__PURE__ */ new Map();
|
|
144147
144315
|
const exhaustedModels = ports.exhaustedModels ?? /* @__PURE__ */ new Map();
|
|
144148
144316
|
const liveQuota = (nowMs) => {
|
|
@@ -145270,7 +145438,7 @@ function predecessorOfThisProcess() {
|
|
|
145270
145438
|
init_realFrontDoorPort();
|
|
145271
145439
|
|
|
145272
145440
|
// src/frontdoor/rcCommands.ts
|
|
145273
|
-
var
|
|
145441
|
+
var import_node_crypto29 = require("node:crypto");
|
|
145274
145442
|
init_commandDeps();
|
|
145275
145443
|
init_cliError();
|
|
145276
145444
|
init_realPorts();
|
|
@@ -145984,8 +146152,8 @@ function registerRcCommand(frontdoor, paths) {
|
|
|
145984
146152
|
identitiesDir: paths.identitiesDir,
|
|
145985
146153
|
frontdoorDir: paths.frontdoorDir,
|
|
145986
146154
|
identity,
|
|
145987
|
-
newUuid:
|
|
145988
|
-
randomToken: () => (0,
|
|
146155
|
+
newUuid: import_node_crypto29.randomUUID,
|
|
146156
|
+
randomToken: () => (0, import_node_crypto29.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
|
|
145989
146157
|
force: options.force === true,
|
|
145990
146158
|
now: () => Date.now()
|
|
145991
146159
|
});
|
|
@@ -148559,7 +148727,7 @@ function inheritedControlToken(paths) {
|
|
|
148559
148727
|
return token;
|
|
148560
148728
|
}
|
|
148561
148729
|
function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, trackTunnels) {
|
|
148562
|
-
const catalogueGeneration = (0,
|
|
148730
|
+
const catalogueGeneration = (0, import_node_crypto30.randomUUID)();
|
|
148563
148731
|
const log = (line) => {
|
|
148564
148732
|
appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${line}`);
|
|
148565
148733
|
};
|
|
@@ -148592,14 +148760,14 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148592
148760
|
};
|
|
148593
148761
|
const rcSelfHostSurface = rcSelfHost ? createRcSelfHostSurface({
|
|
148594
148762
|
now: () => Date.now(),
|
|
148595
|
-
newUuid:
|
|
148596
|
-
randomToken: () => (0,
|
|
148763
|
+
newUuid: import_node_crypto30.randomUUID,
|
|
148764
|
+
randomToken: () => (0, import_node_crypto30.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
|
|
148597
148765
|
credentialRecord: () => readRcSelfHostRecord(realFarmFs, paths.frontdoorDir),
|
|
148598
148766
|
webFetch: realRcWebFetch({ allowPrivate: rcWebFetchAllowsPrivateFromEnv(process.env) }),
|
|
148599
148767
|
log
|
|
148600
148768
|
}) : void 0;
|
|
148601
148769
|
const rcCredentialStore = createRcCredentialStore(realFarmFs, paths.frontdoorRcCredentialsDir);
|
|
148602
|
-
const rcSessionEvents = createRcSessionEventLog({ generation: (0,
|
|
148770
|
+
const rcSessionEvents = createRcSessionEventLog({ generation: (0, import_node_crypto30.randomUUID)(), capacity: RC_SESSION_EVENT_LOG_CAPACITY });
|
|
148603
148771
|
const rcTracker = createRcSessionTracker({ now: () => Date.now(), idleMs: RC_IDLE_EXPIRY_MS, credentialStore: rcCredentialStore, onTransition: rcSessionEvents.append, onClose: rcSessionEvents.close });
|
|
148604
148772
|
const doorEvents = createDoorEventHub();
|
|
148605
148773
|
const usagePublisher = doorEvents.publisher(USAGE_EVENT_SOURCE);
|
|
@@ -148621,7 +148789,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148621
148789
|
saveSequenceNum: rcCredentialStore.writeCursor,
|
|
148622
148790
|
dial: rcSelfHost ? lateRcStreamDial(rcSelfHostDialTarget) : realRcStreamDial(),
|
|
148623
148791
|
fanout: rcFanout,
|
|
148624
|
-
newClientId:
|
|
148792
|
+
newClientId: import_node_crypto30.randomUUID,
|
|
148625
148793
|
backoffMs: RC_STREAM_BACKOFF_MS,
|
|
148626
148794
|
sleep: async (ms) => {
|
|
148627
148795
|
await new Promise((resolve3) => {
|
|
@@ -148634,7 +148802,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148634
148802
|
});
|
|
148635
148803
|
const observations = createTargetObservationStore(realFarmFs, paths);
|
|
148636
148804
|
const routingSnapshots = /* @__PURE__ */ new Map();
|
|
148637
|
-
const rcControlToken = lifecycle.predecessor === void 0 ? (0,
|
|
148805
|
+
const rcControlToken = lifecycle.predecessor === void 0 ? (0, import_node_crypto30.randomUUID)() : inheritedControlToken(paths);
|
|
148638
148806
|
const sessionRegistry = createLiveSessionRegistry({ fs: realFarmFs, sessionsDir: paths.frontdoorSessionsDir });
|
|
148639
148807
|
const resolveRoute = rcObservingResolver(
|
|
148640
148808
|
createProviderRouteResolver({
|
|
@@ -148811,9 +148979,9 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148811
148979
|
now: () => Date.now(),
|
|
148812
148980
|
headroomSocket: () => headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, paths),
|
|
148813
148981
|
// 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.
|
|
148814
|
-
hopSecret: (0,
|
|
148982
|
+
hopSecret: (0, import_node_crypto30.randomUUID)(),
|
|
148815
148983
|
headroomDecision,
|
|
148816
|
-
custody: createCredentialCustody(() => (0,
|
|
148984
|
+
custody: createCredentialCustody(() => (0, import_node_crypto30.randomUUID)()),
|
|
148817
148985
|
log
|
|
148818
148986
|
});
|
|
148819
148987
|
const onListenerError = (name) => (error63) => {
|
|
@@ -148840,9 +149008,9 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148840
149008
|
startProviderListener: async (source) => {
|
|
148841
149009
|
const authority = loadCa();
|
|
148842
149010
|
const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
|
|
148843
|
-
const rcInject = async (sessionId, text5) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid:
|
|
149011
|
+
const rcInject = async (sessionId, text5) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto30.randomUUID }, sessionId, text5);
|
|
148844
149012
|
const rcAnswer = async (sessionId, requestId, decision) => await answerRcControlRequest({ credentialOf: rcTracker.credentialOf, pendingOf: (id2) => rcTracker.pendingOf(id2), completePending: rcTracker.completePending, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial }, sessionId, requestId, decision);
|
|
148845
|
-
const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid:
|
|
149013
|
+
const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto30.randomUUID };
|
|
148846
149014
|
const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
|
|
148847
149015
|
const rcSetModel = async (sessionId, model) => await setRcSessionModel(rcControlRequestDeps, sessionId, model);
|
|
148848
149016
|
const rcSetPermissionMode = async (sessionId, mode) => await setRcSessionPermissionMode(rcControlRequestDeps, sessionId, mode);
|
|
@@ -148954,7 +149122,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
148954
149122
|
},
|
|
148955
149123
|
startConnectListener: async (source) => {
|
|
148956
149124
|
const wantedTransparentPort = process.env.AGENT_SHIM_TRANSPARENT_SURFACE === void 0 ? void 0 : Number(process.env.AGENT_SHIM_TRANSPARENT_SURFACE);
|
|
148957
|
-
const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0,
|
|
149125
|
+
const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0, import_node_crypto30.randomUUID)();
|
|
148958
149126
|
if (transparentCapability !== void 0) {
|
|
148959
149127
|
writeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, { pid: process.pid, startedAt: Date.now(), token: transparentCapability });
|
|
148960
149128
|
}
|
|
@@ -150546,14 +150714,14 @@ init_zod();
|
|
|
150546
150714
|
init_schema2();
|
|
150547
150715
|
|
|
150548
150716
|
// src/statusline/cacheFile.ts
|
|
150549
|
-
var
|
|
150717
|
+
var import_node_crypto31 = require("node:crypto");
|
|
150550
150718
|
var import_node_path73 = __toESM(require("node:path"), 1);
|
|
150551
150719
|
var SESSION_CACHE_DIRECTORY = "session";
|
|
150552
150720
|
function cacheDirectory(ports) {
|
|
150553
150721
|
return import_node_path73.default.join(ports.stateDirectory, SESSION_CACHE_DIRECTORY);
|
|
150554
150722
|
}
|
|
150555
150723
|
function cacheFileFor(ports, kind, transcriptPath) {
|
|
150556
|
-
return import_node_path73.default.join(cacheDirectory(ports), `${kind}-${(0,
|
|
150724
|
+
return import_node_path73.default.join(cacheDirectory(ports), `${kind}-${(0, import_node_crypto31.createHash)("sha256").update(transcriptPath).digest("hex")}.json`);
|
|
150557
150725
|
}
|
|
150558
150726
|
function transcriptKeyOf(ports, transcriptPath) {
|
|
150559
150727
|
const trimmed = transcriptPath.trim();
|
|
@@ -152853,11 +153021,11 @@ function compactUnits(rows, barCells) {
|
|
|
152853
153021
|
}
|
|
152854
153022
|
|
|
152855
153023
|
// src/statusline/transcript/reader.ts
|
|
152856
|
-
var
|
|
153024
|
+
var import_node_crypto33 = require("node:crypto");
|
|
152857
153025
|
init_zod();
|
|
152858
153026
|
|
|
152859
153027
|
// src/statusline/transcript/activity.ts
|
|
152860
|
-
var
|
|
153028
|
+
var import_node_crypto32 = require("node:crypto");
|
|
152861
153029
|
init_zod();
|
|
152862
153030
|
init_graphemes();
|
|
152863
153031
|
|
|
@@ -153177,7 +153345,7 @@ function foldTodoCall(state, call2) {
|
|
|
153177
153345
|
return { ...state, todos: state.todos.map((item, at2) => at2 === index ? updated : item), todosEdited: true };
|
|
153178
153346
|
}
|
|
153179
153347
|
function digestOf(id2) {
|
|
153180
|
-
return (0,
|
|
153348
|
+
return (0, import_node_crypto32.createHash)("sha256").update(id2).digest("base64url").slice(0, CALL_DIGEST_CHARS);
|
|
153181
153349
|
}
|
|
153182
153350
|
function timeKeyOf(atMs) {
|
|
153183
153351
|
const key = atMs === void 0 || atMs < 0 ? "" : atMs.toString(CALL_TIME_RADIX);
|
|
@@ -153188,8 +153356,8 @@ function isRemembered(state, id2, atMs) {
|
|
|
153188
153356
|
if (atMs !== void 0 && state.forgottenUpToMs !== void 0 && atMs <= state.forgottenUpToMs) {
|
|
153189
153357
|
return true;
|
|
153190
153358
|
}
|
|
153191
|
-
const
|
|
153192
|
-
return state.rememberedCalls.some((entry) => entry.startsWith(
|
|
153359
|
+
const digest3 = digestOf(id2);
|
|
153360
|
+
return state.rememberedCalls.some((entry) => entry.startsWith(digest3)) || state.skippedCalls.some((entry) => entry.startsWith(digest3));
|
|
153193
153361
|
}
|
|
153194
153362
|
function beyondFloor(entries, floorMs) {
|
|
153195
153363
|
return entries.filter((entry) => floorMs === void 0 || Number.parseInt(timeKeyOfEntry(entry), CALL_TIME_RADIX) > floorMs);
|
|
@@ -153342,14 +153510,14 @@ function withName(set3, name) {
|
|
|
153342
153510
|
if (set3.others.length === 0 && set3.names.reduce((total, kept) => total + nameBytes(kept), nameBytes(name)) <= NAME_MEMORY_BYTES) {
|
|
153343
153511
|
return { ...set3, names: [...set3.names, name] };
|
|
153344
153512
|
}
|
|
153345
|
-
const
|
|
153346
|
-
if (set3.others.includes(
|
|
153513
|
+
const digest3 = digestOf(name);
|
|
153514
|
+
if (set3.others.includes(digest3)) {
|
|
153347
153515
|
return set3;
|
|
153348
153516
|
}
|
|
153349
153517
|
if (set3.others.length >= MAX_COUNTED_NAMES) {
|
|
153350
153518
|
return set3.overflowed === true ? set3 : { ...set3, overflowed: true };
|
|
153351
153519
|
}
|
|
153352
|
-
return { ...set3, others: [...set3.others,
|
|
153520
|
+
return { ...set3, others: [...set3.others, digest3] };
|
|
153353
153521
|
}
|
|
153354
153522
|
function foldActivityCumulative(state, record3) {
|
|
153355
153523
|
const content = record3.message?.content;
|
|
@@ -153584,7 +153752,7 @@ function foldLines(state, bytes) {
|
|
|
153584
153752
|
}
|
|
153585
153753
|
function fingerprintOf(head) {
|
|
153586
153754
|
const newline = head.subarray(0, FINGERPRINT_BYTES).indexOf(NEWLINE2);
|
|
153587
|
-
return (0,
|
|
153755
|
+
return (0, import_node_crypto33.createHash)("sha256").update(head.subarray(0, newline === -1 ? FINGERPRINT_BYTES : newline + 1)).digest("hex");
|
|
153588
153756
|
}
|
|
153589
153757
|
function factsOf(size, cache, reachedEnd, nowMs, env) {
|
|
153590
153758
|
return { bytes: size, complete: cache.complete && reachedEnd, session: sessionFactsOf(cache.session, cache.newer?.state), tokens: cache.tokens.totals, activity: activityFactsOf(cache.activity, nowMs, { bashMs: bashLiveLimitMs(env) }, cache.newer?.activity) };
|
|
@@ -166328,7 +166496,7 @@ function registerRuleCommand(program2, deps) {
|
|
|
166328
166496
|
}
|
|
166329
166497
|
|
|
166330
166498
|
// src/codex/launch.ts
|
|
166331
|
-
var
|
|
166499
|
+
var import_node_crypto34 = require("node:crypto");
|
|
166332
166500
|
var import_node_fs37 = __toESM(require("node:fs"), 1);
|
|
166333
166501
|
var import_node_os23 = __toESM(require("node:os"), 1);
|
|
166334
166502
|
var import_node_path90 = __toESM(require("node:path"), 1);
|
|
@@ -166532,7 +166700,7 @@ async function runCodex(paths, argv) {
|
|
|
166532
166700
|
}
|
|
166533
166701
|
throw new UsageError("No real Codex CLI found on PATH. Install Codex or set AGENT_SHIM_CODEX_BIN to its executable.");
|
|
166534
166702
|
};
|
|
166535
|
-
const plan = prepareCodexLaunch({ paths, argv, env: process.env, cwd: import_node_fs37.default.realpathSync(process.cwd()), home: import_node_os23.default.homedir(), fs: realFarmFs, read: cosmiconfigReader(), resolveBinary, now: Date.now, pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync, uniqueSuffix: `${String(process.pid)}.${(0,
|
|
166703
|
+
const plan = prepareCodexLaunch({ paths, argv, env: process.env, cwd: import_node_fs37.default.realpathSync(process.cwd()), home: import_node_os23.default.homedir(), fs: realFarmFs, read: cosmiconfigReader(), resolveBinary, now: Date.now, pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync, uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto34.randomUUID)()}`, warn: (message) => {
|
|
166536
166704
|
console.error(`agent-shim: ${message}`);
|
|
166537
166705
|
}, ...resolveGitBranch(realRunPort, process.cwd()) });
|
|
166538
166706
|
import_node_fs37.default.chmodSync(plan.env.CODEX_HOME ?? "", PRIVATE_DIRECTORY_MODE);
|
|
@@ -167280,7 +167448,7 @@ async function realRefresher(params) {
|
|
|
167280
167448
|
}
|
|
167281
167449
|
|
|
167282
167450
|
// src/supervise/launch.ts
|
|
167283
|
-
var
|
|
167451
|
+
var import_node_crypto36 = require("node:crypto");
|
|
167284
167452
|
var import_node_fs40 = require("node:fs");
|
|
167285
167453
|
var import_node_path97 = __toESM(require("node:path"), 1);
|
|
167286
167454
|
var import_promises21 = require("node:stream/promises");
|
|
@@ -167515,7 +167683,7 @@ function createLifecycleRecorder(params) {
|
|
|
167515
167683
|
}
|
|
167516
167684
|
|
|
167517
167685
|
// src/supervise/nativeCompact.ts
|
|
167518
|
-
var
|
|
167686
|
+
var import_node_crypto35 = require("node:crypto");
|
|
167519
167687
|
var import_node_fs38 = require("node:fs");
|
|
167520
167688
|
var import_promises20 = require("node:timers/promises");
|
|
167521
167689
|
var RESULT_POLL_MS = 250;
|
|
@@ -167525,7 +167693,7 @@ function nativeCompactionReady(plugin) {
|
|
|
167525
167693
|
async function compactInSession(plugin, conversationId, signal) {
|
|
167526
167694
|
if (!nativeCompactionReady(plugin)) throw new Error("the in-process compaction plugin did not load");
|
|
167527
167695
|
signal.throwIfAborted();
|
|
167528
|
-
const id2 = (0,
|
|
167696
|
+
const id2 = (0, import_node_crypto35.randomUUID)();
|
|
167529
167697
|
const temporary = `${plugin.request}.${id2}`;
|
|
167530
167698
|
(0, import_node_fs38.writeFileSync)(temporary, JSON.stringify({ id: id2, conversationId }), { mode: 384 });
|
|
167531
167699
|
(0, import_node_fs38.renameSync)(temporary, plugin.request);
|
|
@@ -168186,21 +168354,21 @@ async function runSupervised(params) {
|
|
|
168186
168354
|
log.warn(`agent-shim: pool "${pool}" cannot supervise a launch whose extra flags end option parsing`);
|
|
168187
168355
|
return void 0;
|
|
168188
168356
|
}
|
|
168189
|
-
const first = initialConversationOf(params.passthrough, { newId:
|
|
168357
|
+
const first = initialConversationOf(params.passthrough, { newId: import_node_crypto36.randomUUID, latestId: () => latestConversationId(farm.fs, { claudeHome: farm.claudeHome, cwd: farm.cwd }) });
|
|
168190
168358
|
if ("reason" in first) {
|
|
168191
168359
|
log.warn(`agent-shim: pool "${pool}" resumes on a spent quota, but this launch runs unsupervised: ${first.reason}`);
|
|
168192
168360
|
return void 0;
|
|
168193
168361
|
}
|
|
168194
168362
|
let entrypointSha256AtStart;
|
|
168195
168363
|
try {
|
|
168196
|
-
const hash2 = (0,
|
|
168364
|
+
const hash2 = (0, import_node_crypto36.createHash)("sha256");
|
|
168197
168365
|
await (0, import_promises21.pipeline)((0, import_node_fs40.createReadStream)(realContentSourcePath()), hash2);
|
|
168198
168366
|
entrypointSha256AtStart = hash2.digest("hex");
|
|
168199
168367
|
} catch {
|
|
168200
168368
|
entrypointSha256AtStart = null;
|
|
168201
168369
|
log.warn("agent-shim: could not fingerprint the supervisor entrypoint");
|
|
168202
168370
|
}
|
|
168203
|
-
const lifecycle = createLifecycleRecorder({ fs: realFarmFs, logsDir: paths.logsDir, fileId: (0,
|
|
168371
|
+
const lifecycle = createLifecycleRecorder({ fs: realFarmFs, logsDir: paths.logsDir, fileId: (0, import_node_crypto36.randomUUID)(), sessionId: first.sessionId, supervisorPid: farm.lock.pid, supervisorVersion: package_default.version, entrypointSha256AtStart, now: farm.now, log });
|
|
168204
168372
|
let compaction;
|
|
168205
168373
|
const policy = params.pools[pool];
|
|
168206
168374
|
const markSettings = markHooksSettings(selfInvocation([]), paths.root, pool, first.sessionId);
|