agent-shim 8.42.0 → 8.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +324 -290
- package/dist/index.cjs +215 -187
- package/dist/index.mjs +196 -169
- package/dist/types/index.d.ts +33 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2619,7 +2619,7 @@ var init_package = __esm({
|
|
|
2619
2619
|
"package.json"() {
|
|
2620
2620
|
package_default = {
|
|
2621
2621
|
name: "agent-shim",
|
|
2622
|
-
version: "8.
|
|
2622
|
+
version: "8.44.0",
|
|
2623
2623
|
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.",
|
|
2624
2624
|
license: "MIT",
|
|
2625
2625
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -2723,7 +2723,7 @@ var init_package = __esm({
|
|
|
2723
2723
|
|
|
2724
2724
|
// src/headroom/state.ts
|
|
2725
2725
|
import { createHash as createHash3 } from "node:crypto";
|
|
2726
|
-
import
|
|
2726
|
+
import path11 from "node:path";
|
|
2727
2727
|
import { z as z5 } from "zod";
|
|
2728
2728
|
function parseJson(raw, schema) {
|
|
2729
2729
|
if (raw === void 0 || raw.trim() === "") {
|
|
@@ -2740,7 +2740,7 @@ function readHeadroomState(fs12, stateFile) {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
function writeHeadroomState(fs12, stateFile, state) {
|
|
2743
|
-
fs12.mkdirp(
|
|
2743
|
+
fs12.mkdirp(path11.dirname(stateFile));
|
|
2744
2744
|
fs12.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
|
|
2745
2745
|
`);
|
|
2746
2746
|
}
|
|
@@ -2768,7 +2768,7 @@ function readAllProviders(fs12, providersDir) {
|
|
|
2768
2768
|
continue;
|
|
2769
2769
|
}
|
|
2770
2770
|
try {
|
|
2771
|
-
const parsed = parseJson(fs12.readFileUtf8(
|
|
2771
|
+
const parsed = parseJson(fs12.readFileUtf8(path11.join(providersDir, name)), ProviderSchema);
|
|
2772
2772
|
if (parsed !== void 0) {
|
|
2773
2773
|
result.push({ name: name.slice(0, -".json".length), provider: parsed });
|
|
2774
2774
|
}
|
|
@@ -2780,11 +2780,11 @@ function readAllProviders(fs12, providersDir) {
|
|
|
2780
2780
|
}
|
|
2781
2781
|
function writeSession(fs12, sessionsDir, session) {
|
|
2782
2782
|
fs12.mkdirp(sessionsDir);
|
|
2783
|
-
fs12.writeFileUtf8(
|
|
2783
|
+
fs12.writeFileUtf8(path11.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
|
|
2784
2784
|
`);
|
|
2785
2785
|
}
|
|
2786
2786
|
function removeSession(fs12, sessionsDir, pid) {
|
|
2787
|
-
fs12.removeRecursive(
|
|
2787
|
+
fs12.removeRecursive(path11.join(sessionsDir, `${String(pid)}.json`));
|
|
2788
2788
|
}
|
|
2789
2789
|
function listSessions(fs12, sessionsDir) {
|
|
2790
2790
|
const sessions = [];
|
|
@@ -2793,7 +2793,7 @@ function listSessions(fs12, sessionsDir) {
|
|
|
2793
2793
|
continue;
|
|
2794
2794
|
}
|
|
2795
2795
|
try {
|
|
2796
|
-
const parsed = parseJson(fs12.readFileUtf8(
|
|
2796
|
+
const parsed = parseJson(fs12.readFileUtf8(path11.join(sessionsDir, name)), HeadroomSessionSchema);
|
|
2797
2797
|
if (parsed !== void 0) {
|
|
2798
2798
|
sessions.push(parsed);
|
|
2799
2799
|
}
|
|
@@ -2963,9 +2963,9 @@ var init_settings = __esm({
|
|
|
2963
2963
|
});
|
|
2964
2964
|
|
|
2965
2965
|
// src/headroom/socket.ts
|
|
2966
|
-
import
|
|
2966
|
+
import path12 from "node:path";
|
|
2967
2967
|
function headroomSocketPath(paths, supervisorPid) {
|
|
2968
|
-
return
|
|
2968
|
+
return path12.join(paths.headroomSocketDir, `${String(supervisorPid)}${HEADROOM_SOCKET_SUFFIX}`);
|
|
2969
2969
|
}
|
|
2970
2970
|
function platformRefusal(platform) {
|
|
2971
2971
|
return PLATFORMS_WITHOUT_UNIX_SOCKETS.includes(platform) ? `headroom routing needs a unix domain socket, which headroom cannot serve on ${platform}; agent-shim never falls back to a TCP port for this hop` : void 0;
|
|
@@ -2994,7 +2994,7 @@ function verifyHeadroomSocket(socketPath, ports) {
|
|
|
2994
2994
|
return { refused: unsupported };
|
|
2995
2995
|
}
|
|
2996
2996
|
const uid = ports.currentUid();
|
|
2997
|
-
const directory =
|
|
2997
|
+
const directory = path12.dirname(socketPath);
|
|
2998
2998
|
const refusal = ownerOnlyRefusal("socket directory", directory, ports.lstat(directory), "dir", uid) ?? ownerOnlyRefusal("socket", socketPath, ports.lstat(socketPath), "socket", uid);
|
|
2999
2999
|
return refusal === void 0 ? { socketPath } : { refused: refusal };
|
|
3000
3000
|
}
|
|
@@ -3024,7 +3024,7 @@ function pruneStaleHeadroomSockets(fs12, paths, isRunning) {
|
|
|
3024
3024
|
if (pid === void 0 || isRunning(Number.parseInt(pid, 10))) {
|
|
3025
3025
|
continue;
|
|
3026
3026
|
}
|
|
3027
|
-
fs12.removeRecursive(
|
|
3027
|
+
fs12.removeRecursive(path12.join(paths.headroomSocketDir, name));
|
|
3028
3028
|
removed.push(name);
|
|
3029
3029
|
}
|
|
3030
3030
|
return removed;
|
|
@@ -3334,7 +3334,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
3334
3334
|
import { createHash as createHash5 } from "node:crypto";
|
|
3335
3335
|
import fs3 from "node:fs";
|
|
3336
3336
|
import os3 from "node:os";
|
|
3337
|
-
import
|
|
3337
|
+
import path13 from "node:path";
|
|
3338
3338
|
import { isSea } from "node:sea";
|
|
3339
3339
|
function isEnoent3(error) {
|
|
3340
3340
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
@@ -3361,7 +3361,7 @@ function realIsProcessRunning(pid) {
|
|
|
3361
3361
|
return realIsProcessAlive(pid) && !realIsProcessZombie(pid);
|
|
3362
3362
|
}
|
|
3363
3363
|
function expandHome2(filePath) {
|
|
3364
|
-
return filePath.startsWith("~/") ?
|
|
3364
|
+
return filePath.startsWith("~/") ? path13.join(os3.homedir(), filePath.slice(1)) : filePath;
|
|
3365
3365
|
}
|
|
3366
3366
|
function hasDesktopSession() {
|
|
3367
3367
|
if (process.platform === "darwin") {
|
|
@@ -3405,7 +3405,7 @@ function spawnDaemonThroughScript(script) {
|
|
|
3405
3405
|
return (paths, subcommand, logPath) => spawnDetachedDaemon({ command: process.execPath, args: [script, subcommand] }, paths, subcommand, logPath);
|
|
3406
3406
|
}
|
|
3407
3407
|
function spawnDetachedDaemon(invocation, paths, subcommand, logPath) {
|
|
3408
|
-
fs3.mkdirSync(
|
|
3408
|
+
fs3.mkdirSync(path13.dirname(logPath), { recursive: true });
|
|
3409
3409
|
const logFd = fs3.openSync(logPath, "a");
|
|
3410
3410
|
try {
|
|
3411
3411
|
const child = spawn(invocation.command, invocation.args, detachedDaemonSpawnOptions(logFd, { ...process.env, AGENT_SHIM_HOME: paths.root }));
|
|
@@ -3458,7 +3458,7 @@ function listVersionsDir(dir) {
|
|
|
3458
3458
|
throw error;
|
|
3459
3459
|
}
|
|
3460
3460
|
return entries.filter((entry) => entry.isFile()).map((entry) => {
|
|
3461
|
-
const fullPath =
|
|
3461
|
+
const fullPath = path13.join(dir, entry.name);
|
|
3462
3462
|
const stat = fs3.statSync(fullPath);
|
|
3463
3463
|
return {
|
|
3464
3464
|
name: entry.name,
|
|
@@ -3472,7 +3472,7 @@ function windowsPathExtensions(pathext) {
|
|
|
3472
3472
|
return (pathext ?? WINDOWS_DEFAULT_PATHEXT).split(";").map((ext) => ext.trim()).filter((ext) => ext.length > 0);
|
|
3473
3473
|
}
|
|
3474
3474
|
function resolveExecutableCandidate(dir, name, env) {
|
|
3475
|
-
const candidate =
|
|
3475
|
+
const candidate = path13.join(dir, name);
|
|
3476
3476
|
if (env.platform === "win32") {
|
|
3477
3477
|
const extensions = windowsPathExtensions(env.pathext);
|
|
3478
3478
|
const alreadyHasRecognisedExtension = extensions.some((ext) => candidate.toLowerCase().endsWith(ext.toLowerCase()));
|
|
@@ -3521,13 +3521,13 @@ function resolveOwnExecutablePath(env) {
|
|
|
3521
3521
|
if (env.argv1 !== void 0 && !env.argv1.includes("/") && !env.argv1.includes("\\")) {
|
|
3522
3522
|
return searchPathForExecutable(env.pathDirs, env.argv1, env.findExecutableInDir) ?? env.execPath;
|
|
3523
3523
|
}
|
|
3524
|
-
const candidate = env.argv1 === void 0 ? env.execPath :
|
|
3525
|
-
const candidateDir =
|
|
3526
|
-
const candidateDirOnPath = env.pathDirs.some((dir) =>
|
|
3524
|
+
const candidate = env.argv1 === void 0 ? env.execPath : path13.resolve(env.cwd, env.argv1);
|
|
3525
|
+
const candidateDir = path13.dirname(candidate);
|
|
3526
|
+
const candidateDirOnPath = env.pathDirs.some((dir) => path13.resolve(dir) === candidateDir);
|
|
3527
3527
|
if (candidateDirOnPath) {
|
|
3528
3528
|
return candidate;
|
|
3529
3529
|
}
|
|
3530
|
-
const viaPath = searchPathForExecutable(env.pathDirs,
|
|
3530
|
+
const viaPath = searchPathForExecutable(env.pathDirs, path13.basename(candidate), env.findExecutableInDir);
|
|
3531
3531
|
return viaPath ?? candidate;
|
|
3532
3532
|
}
|
|
3533
3533
|
function realOwnExecutablePath() {
|
|
@@ -3535,7 +3535,7 @@ function realOwnExecutablePath() {
|
|
|
3535
3535
|
argv1: process.argv[1],
|
|
3536
3536
|
execPath: process.execPath,
|
|
3537
3537
|
cwd: process.cwd(),
|
|
3538
|
-
pathDirs: (process.env.PATH ?? "").split(
|
|
3538
|
+
pathDirs: (process.env.PATH ?? "").split(path13.delimiter).filter((dir) => dir !== ""),
|
|
3539
3539
|
findExecutableInDir
|
|
3540
3540
|
});
|
|
3541
3541
|
}
|
|
@@ -3548,7 +3548,7 @@ function realContentSourcePath() {
|
|
|
3548
3548
|
function realResolveClaudeBinary(isOwnBinary) {
|
|
3549
3549
|
return (request4) => discoverClaudeBinary({
|
|
3550
3550
|
listVersionsDir,
|
|
3551
|
-
pathDirs: (process.env.PATH ?? "").split(
|
|
3551
|
+
pathDirs: (process.env.PATH ?? "").split(path13.delimiter).filter((dir) => dir !== ""),
|
|
3552
3552
|
findExecutableInDir,
|
|
3553
3553
|
isOwnBinary,
|
|
3554
3554
|
...request4?.version === void 0 ? {} : { version: request4.version }
|
|
@@ -3770,18 +3770,18 @@ var init_realPorts = __esm({
|
|
|
3770
3770
|
});
|
|
3771
3771
|
|
|
3772
3772
|
// src/pathNorm.ts
|
|
3773
|
-
import
|
|
3773
|
+
import path14 from "node:path";
|
|
3774
3774
|
function expandTilde(value, home) {
|
|
3775
3775
|
if (value === "~") {
|
|
3776
3776
|
return home;
|
|
3777
3777
|
}
|
|
3778
3778
|
if (value.startsWith("~/")) {
|
|
3779
|
-
return
|
|
3779
|
+
return path14.join(home, value.slice(2));
|
|
3780
3780
|
}
|
|
3781
3781
|
return value;
|
|
3782
3782
|
}
|
|
3783
3783
|
function normaliseRulePath(rulePath, home) {
|
|
3784
|
-
return
|
|
3784
|
+
return path14.resolve(expandTilde(rulePath, home));
|
|
3785
3785
|
}
|
|
3786
3786
|
var init_pathNorm = __esm({
|
|
3787
3787
|
"src/pathNorm.ts"() {
|
|
@@ -3790,12 +3790,12 @@ var init_pathNorm = __esm({
|
|
|
3790
3790
|
});
|
|
3791
3791
|
|
|
3792
3792
|
// src/launcher/cascade.ts
|
|
3793
|
-
import
|
|
3793
|
+
import path15 from "node:path";
|
|
3794
3794
|
function loadCascadeInput(params) {
|
|
3795
3795
|
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
3796
3796
|
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
3797
3797
|
const loadProfile = (name) => {
|
|
3798
|
-
const filepath =
|
|
3798
|
+
const filepath = path15.join(params.paths.configProfilesDir, `${name}.json`);
|
|
3799
3799
|
const loaded = loadConfigFile(filepath, ConfigProfileSchema, params.read);
|
|
3800
3800
|
if (loaded === void 0) {
|
|
3801
3801
|
return void 0;
|
|
@@ -3810,8 +3810,8 @@ function loadCascadeInput(params) {
|
|
|
3810
3810
|
});
|
|
3811
3811
|
const levels = [];
|
|
3812
3812
|
for (const dir of dirs) {
|
|
3813
|
-
const portable = loadConfigFile(
|
|
3814
|
-
const portableLocal = loadConfigFile(
|
|
3813
|
+
const portable = loadConfigFile(path15.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path15.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
3814
|
+
const portableLocal = loadConfigFile(path15.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path15.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
3815
3815
|
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
3816
3816
|
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
3817
3817
|
return {
|
|
@@ -3873,7 +3873,7 @@ var init_cascade = __esm({
|
|
|
3873
3873
|
});
|
|
3874
3874
|
|
|
3875
3875
|
// src/launcher/identity.ts
|
|
3876
|
-
import
|
|
3876
|
+
import path16 from "node:path";
|
|
3877
3877
|
function poolNameOf(selector) {
|
|
3878
3878
|
return selector.startsWith(POOL_SELECTOR_PREFIX) ? selector.slice(POOL_SELECTOR_PREFIX.length) : void 0;
|
|
3879
3879
|
}
|
|
@@ -3926,7 +3926,7 @@ function decideConfigProfile(params) {
|
|
|
3926
3926
|
return { source: "none" };
|
|
3927
3927
|
}
|
|
3928
3928
|
function loadIdentity(identitiesDir, name, fs12) {
|
|
3929
|
-
return loadConfigFile(
|
|
3929
|
+
return loadConfigFile(path16.join(identitiesDir, name, "identity.json"), IdentitySchema, fs12.readConfigFile);
|
|
3930
3930
|
}
|
|
3931
3931
|
var IDENTITY_DECISION_SOURCES, CONFIG_PROFILE_DECISION_SOURCES;
|
|
3932
3932
|
var init_identity = __esm({
|
|
@@ -4120,7 +4120,7 @@ var init_schema2 = __esm({
|
|
|
4120
4120
|
});
|
|
4121
4121
|
|
|
4122
4122
|
// src/usage/account.ts
|
|
4123
|
-
import
|
|
4123
|
+
import path17 from "node:path";
|
|
4124
4124
|
function isObject(value) {
|
|
4125
4125
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4126
4126
|
}
|
|
@@ -4128,7 +4128,7 @@ function isIdentityName(name) {
|
|
|
4128
4128
|
return IdentitySchema.shape.name.safeParse(name).success;
|
|
4129
4129
|
}
|
|
4130
4130
|
function claudeJsonPath(identitiesDir, identity) {
|
|
4131
|
-
return
|
|
4131
|
+
return path17.join(identitiesDir, identity, CLAUDE_JSON);
|
|
4132
4132
|
}
|
|
4133
4133
|
function readAccountMetadata(fs12, identitiesDir, identity) {
|
|
4134
4134
|
if (!isIdentityName(identity)) {
|
|
@@ -4627,7 +4627,7 @@ var init_pick = __esm({
|
|
|
4627
4627
|
});
|
|
4628
4628
|
|
|
4629
4629
|
// src/usage/read.ts
|
|
4630
|
-
import
|
|
4630
|
+
import path18 from "node:path";
|
|
4631
4631
|
function segmentDay(epochMs) {
|
|
4632
4632
|
return new Date(epochMs).toISOString().slice(0, "YYYY-MM-DD".length);
|
|
4633
4633
|
}
|
|
@@ -4652,7 +4652,7 @@ function readUsageLog(fs12, logDir, options = {}) {
|
|
|
4652
4652
|
if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
|
|
4653
4653
|
continue;
|
|
4654
4654
|
}
|
|
4655
|
-
const contents = fs12.readFileUtf8(
|
|
4655
|
+
const contents = fs12.readFileUtf8(path18.join(logDir, segment.name));
|
|
4656
4656
|
if (contents === void 0) {
|
|
4657
4657
|
continue;
|
|
4658
4658
|
}
|
|
@@ -4686,7 +4686,7 @@ function snapshotPath(snapshotsDir, identity) {
|
|
|
4686
4686
|
if (!isIdentityName(identity)) {
|
|
4687
4687
|
throw new Error(`"${identity}" is not a valid identity name.`);
|
|
4688
4688
|
}
|
|
4689
|
-
return
|
|
4689
|
+
return path18.join(snapshotsDir, `${identity}.json`);
|
|
4690
4690
|
}
|
|
4691
4691
|
function readUsageSnapshot(fs12, snapshotsDir, identity) {
|
|
4692
4692
|
const file = snapshotPath(snapshotsDir, identity);
|
|
@@ -4739,12 +4739,12 @@ var init_read = __esm({
|
|
|
4739
4739
|
});
|
|
4740
4740
|
|
|
4741
4741
|
// src/usage/store.ts
|
|
4742
|
-
import
|
|
4742
|
+
import path19 from "node:path";
|
|
4743
4743
|
function pruneUsageLog(fs12, logDir, nowMs) {
|
|
4744
4744
|
const cutoff = nowMs - USAGE_RETENTION_MS;
|
|
4745
4745
|
for (const segment of listLogSegments(fs12, logDir)) {
|
|
4746
4746
|
if (segment.endsAt <= cutoff) {
|
|
4747
|
-
fs12.removeRecursive(
|
|
4747
|
+
fs12.removeRecursive(path19.join(logDir, segment.name));
|
|
4748
4748
|
}
|
|
4749
4749
|
}
|
|
4750
4750
|
}
|
|
@@ -4826,7 +4826,7 @@ function createUsageStore(deps) {
|
|
|
4826
4826
|
pruneUsageLog(fs12, paths.usageLogDir, nowMs);
|
|
4827
4827
|
prunedDay = day;
|
|
4828
4828
|
}
|
|
4829
|
-
fs12.appendFilePrivate(
|
|
4829
|
+
fs12.appendFilePrivate(path19.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record)}
|
|
4830
4830
|
`);
|
|
4831
4831
|
if (record.identity !== void 0) {
|
|
4832
4832
|
rewriteSnapshot(record.identity, (current) => ({ ...current?.providers, [record.provider]: foldProviderState(current?.providers[record.provider], record) }));
|
|
@@ -4864,7 +4864,7 @@ var init_store2 = __esm({
|
|
|
4864
4864
|
});
|
|
4865
4865
|
|
|
4866
4866
|
// src/usage/poolPick.ts
|
|
4867
|
-
import
|
|
4867
|
+
import path20 from "node:path";
|
|
4868
4868
|
import { z as z10 } from "zod";
|
|
4869
4869
|
function errorMessage(error) {
|
|
4870
4870
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -4992,7 +4992,7 @@ function recordStickyPick(fs12, picksFile, directory, identity, nowMs) {
|
|
|
4992
4992
|
const current = readPicksFile(fs12, picksFile).file.picks;
|
|
4993
4993
|
const kept = Object.entries(current).filter(([, entry]) => nowMs - Date.parse(entry.at) <= USAGE_RETENTION_MS);
|
|
4994
4994
|
const next = { schemaVersion: SCHEMA_VERSION, picks: { ...Object.fromEntries(kept), [directory]: { identity, at: new Date(nowMs).toISOString() } } };
|
|
4995
|
-
fs12.mkdirPrivate(
|
|
4995
|
+
fs12.mkdirPrivate(path20.dirname(picksFile));
|
|
4996
4996
|
fs12.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
|
|
4997
4997
|
`);
|
|
4998
4998
|
}
|
|
@@ -5026,14 +5026,14 @@ var init_poolPick = __esm({
|
|
|
5026
5026
|
// src/paths.ts
|
|
5027
5027
|
import fs5 from "node:fs";
|
|
5028
5028
|
import os5 from "node:os";
|
|
5029
|
-
import
|
|
5029
|
+
import path22 from "node:path";
|
|
5030
5030
|
function resolveAgentShimHome(env = process.env, home = os5.homedir(), isDirectory = isExistingDirectory) {
|
|
5031
5031
|
const fromEnv = env.AGENT_SHIM_HOME;
|
|
5032
5032
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
5033
5033
|
return fromEnv;
|
|
5034
5034
|
}
|
|
5035
|
-
const current =
|
|
5036
|
-
const legacy =
|
|
5035
|
+
const current = path22.join(home, HOME_DIRNAME);
|
|
5036
|
+
const legacy = path22.join(home, LEGACY_HOME_DIRNAME);
|
|
5037
5037
|
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
5038
5038
|
}
|
|
5039
5039
|
function isExistingDirectory(candidate) {
|
|
@@ -5044,42 +5044,42 @@ function resolveClaudeHome() {
|
|
|
5044
5044
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
5045
5045
|
return fromEnv;
|
|
5046
5046
|
}
|
|
5047
|
-
return
|
|
5047
|
+
return path22.join(os5.homedir(), ".claude");
|
|
5048
5048
|
}
|
|
5049
5049
|
function buildLayoutPaths(root) {
|
|
5050
5050
|
return {
|
|
5051
5051
|
root,
|
|
5052
|
-
identitiesDir:
|
|
5053
|
-
configProfilesDir:
|
|
5054
|
-
providersDir:
|
|
5055
|
-
directoryRulesFile:
|
|
5056
|
-
activeIdentityFile:
|
|
5057
|
-
globalConfigFile:
|
|
5058
|
-
categoriesLocalFile:
|
|
5059
|
-
claudeShimFile:
|
|
5060
|
-
headroomDir:
|
|
5061
|
-
headroomStateFile:
|
|
5062
|
-
headroomSocketDir:
|
|
5063
|
-
headroomLockFile:
|
|
5064
|
-
headroomSessionsDir:
|
|
5065
|
-
logsDir:
|
|
5066
|
-
headroomLogPath:
|
|
5067
|
-
frontdoorDir:
|
|
5068
|
-
frontdoorCaDir:
|
|
5069
|
-
frontdoorCaCertFile:
|
|
5070
|
-
frontdoorCaKeyFile:
|
|
5071
|
-
frontdoorCaBundlesDir:
|
|
5072
|
-
chatgptSignInFile:
|
|
5073
|
-
frontdoorStateFile:
|
|
5074
|
-
frontdoorLockFile:
|
|
5075
|
-
frontdoorControlTokenFile:
|
|
5076
|
-
frontdoorSessionsDir:
|
|
5077
|
-
frontdoorRcCredentialsDir:
|
|
5078
|
-
frontdoorLogPath:
|
|
5079
|
-
usageDir:
|
|
5080
|
-
usageLogDir:
|
|
5081
|
-
usageSnapshotsDir:
|
|
5082
|
-
usagePicksFile:
|
|
5052
|
+
identitiesDir: path22.join(root, "identities"),
|
|
5053
|
+
configProfilesDir: path22.join(root, "config-profiles"),
|
|
5054
|
+
providersDir: path22.join(root, "providers"),
|
|
5055
|
+
directoryRulesFile: path22.join(root, "directory-rules.json"),
|
|
5056
|
+
activeIdentityFile: path22.join(root, "active-identity"),
|
|
5057
|
+
globalConfigFile: path22.join(root, "config.json"),
|
|
5058
|
+
categoriesLocalFile: path22.join(root, "categories.local.json"),
|
|
5059
|
+
claudeShimFile: path22.join(root, "claude-shim.json"),
|
|
5060
|
+
headroomDir: path22.join(root, "headroom"),
|
|
5061
|
+
headroomStateFile: path22.join(root, "headroom", `state.v${String(HEADROOM_STATE_SCHEMA_VERSION)}.json`),
|
|
5062
|
+
headroomSocketDir: path22.join(root, "headroom", "run"),
|
|
5063
|
+
headroomLockFile: path22.join(root, "headroom", "start.lock"),
|
|
5064
|
+
headroomSessionsDir: path22.join(root, "headroom", "sessions"),
|
|
5065
|
+
logsDir: path22.join(root, "logs"),
|
|
5066
|
+
headroomLogPath: path22.join(root, "logs", "headroom.log"),
|
|
5067
|
+
frontdoorDir: path22.join(root, "frontdoor"),
|
|
5068
|
+
frontdoorCaDir: path22.join(root, "frontdoor", "ca"),
|
|
5069
|
+
frontdoorCaCertFile: path22.join(root, "frontdoor", "ca", "ca.pem"),
|
|
5070
|
+
frontdoorCaKeyFile: path22.join(root, "frontdoor", "ca", "ca.key"),
|
|
5071
|
+
frontdoorCaBundlesDir: path22.join(root, "frontdoor", "ca", "bundles"),
|
|
5072
|
+
chatgptSignInFile: path22.join(root, "codex", "chatgpt-sign-in.json"),
|
|
5073
|
+
frontdoorStateFile: path22.join(root, "frontdoor", "state.json"),
|
|
5074
|
+
frontdoorLockFile: path22.join(root, "frontdoor", "start.lock"),
|
|
5075
|
+
frontdoorControlTokenFile: path22.join(root, "frontdoor", "control-token"),
|
|
5076
|
+
frontdoorSessionsDir: path22.join(root, "frontdoor", "sessions"),
|
|
5077
|
+
frontdoorRcCredentialsDir: path22.join(root, "frontdoor", "rc-credentials"),
|
|
5078
|
+
frontdoorLogPath: path22.join(root, "logs", "frontdoor.log"),
|
|
5079
|
+
usageDir: path22.join(root, "usage"),
|
|
5080
|
+
usageLogDir: path22.join(root, "usage", "log"),
|
|
5081
|
+
usageSnapshotsDir: path22.join(root, "usage", "snapshots"),
|
|
5082
|
+
usagePicksFile: path22.join(root, "usage", "picks.json")
|
|
5083
5083
|
};
|
|
5084
5084
|
}
|
|
5085
5085
|
function resolveLayoutPaths() {
|
|
@@ -5172,7 +5172,7 @@ var init_credentialCache = __esm({
|
|
|
5172
5172
|
// src/realCredentialCache.ts
|
|
5173
5173
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
5174
5174
|
import fs6 from "node:fs";
|
|
5175
|
-
import
|
|
5175
|
+
import path23 from "node:path";
|
|
5176
5176
|
function cacheFileNameFor(owner) {
|
|
5177
5177
|
return `${owner.replace(/[^A-Za-z0-9._-]/g, "_")}.json`;
|
|
5178
5178
|
}
|
|
@@ -5196,8 +5196,8 @@ function security(args, stdin) {
|
|
|
5196
5196
|
return { status: result.status, stdout: result.stdout };
|
|
5197
5197
|
}
|
|
5198
5198
|
function createRealCredentialCache(root) {
|
|
5199
|
-
const dir =
|
|
5200
|
-
const filePath = (owner) =>
|
|
5199
|
+
const dir = path23.join(root, "credential-cache");
|
|
5200
|
+
const filePath = (owner) => path23.join(dir, cacheFileNameFor(owner));
|
|
5201
5201
|
return {
|
|
5202
5202
|
read(store, owner) {
|
|
5203
5203
|
if (store === "file") {
|
|
@@ -5429,9 +5429,9 @@ var init_credential = __esm({
|
|
|
5429
5429
|
|
|
5430
5430
|
// src/providersStore.ts
|
|
5431
5431
|
import fs7 from "node:fs";
|
|
5432
|
-
import
|
|
5432
|
+
import path24 from "node:path";
|
|
5433
5433
|
function providerJsonPath(paths, name) {
|
|
5434
|
-
return
|
|
5434
|
+
return path24.join(paths.providersDir, `${name}.json`);
|
|
5435
5435
|
}
|
|
5436
5436
|
function providerExists(paths, name) {
|
|
5437
5437
|
return fs7.existsSync(providerJsonPath(paths, name));
|
|
@@ -5491,7 +5491,7 @@ function readProvider(paths, name) {
|
|
|
5491
5491
|
return parseProviderFile(filePath, raw);
|
|
5492
5492
|
}
|
|
5493
5493
|
function loadProvider(providersDir, name, port) {
|
|
5494
|
-
const filePath =
|
|
5494
|
+
const filePath = path24.join(providersDir, `${name}.json`);
|
|
5495
5495
|
const raw = port.readConfigFile(filePath);
|
|
5496
5496
|
return raw === void 0 ? void 0 : parseProviderFile(filePath, raw);
|
|
5497
5497
|
}
|
|
@@ -5856,17 +5856,17 @@ var init_commandDeps = __esm({
|
|
|
5856
5856
|
|
|
5857
5857
|
// src/claudeShim.ts
|
|
5858
5858
|
import fs8 from "node:fs";
|
|
5859
|
-
import
|
|
5859
|
+
import path26 from "node:path";
|
|
5860
5860
|
import { z as z15 } from "zod";
|
|
5861
5861
|
function commandFilename(ownExecutablePath, commandName) {
|
|
5862
5862
|
return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
|
|
5863
5863
|
}
|
|
5864
5864
|
function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
5865
5865
|
const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
5866
|
-
const recordedTarget = state === void 0 ? void 0 :
|
|
5866
|
+
const recordedTarget = state === void 0 ? void 0 : path26.resolve(state.targetPath);
|
|
5867
5867
|
let ownStat;
|
|
5868
5868
|
return (candidate) => {
|
|
5869
|
-
if (recordedTarget !== void 0 &&
|
|
5869
|
+
if (recordedTarget !== void 0 && path26.resolve(candidate) === recordedTarget) {
|
|
5870
5870
|
return true;
|
|
5871
5871
|
}
|
|
5872
5872
|
ownStat ??= statOrUndefined(contentSourcePath);
|
|
@@ -5889,15 +5889,15 @@ function statOrUndefined(target) {
|
|
|
5889
5889
|
}
|
|
5890
5890
|
}
|
|
5891
5891
|
function findPathShadow(params) {
|
|
5892
|
-
const resolvedTargetDir =
|
|
5892
|
+
const resolvedTargetDir = path26.resolve(params.targetDir);
|
|
5893
5893
|
for (const dir of params.pathDirs) {
|
|
5894
5894
|
const found = params.findExecutableInDir(dir, params.targetFilename);
|
|
5895
5895
|
if (found === void 0) {
|
|
5896
5896
|
continue;
|
|
5897
5897
|
}
|
|
5898
|
-
return
|
|
5898
|
+
return path26.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
|
|
5899
5899
|
}
|
|
5900
|
-
return params.pathDirs.some((dir) =>
|
|
5900
|
+
return params.pathDirs.some((dir) => path26.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
5901
5901
|
}
|
|
5902
5902
|
var ClaudeShimStateSchema, nodeLinkFs;
|
|
5903
5903
|
var init_claudeShim = __esm({
|
|
@@ -6321,7 +6321,7 @@ var init_headers = __esm({
|
|
|
6321
6321
|
});
|
|
6322
6322
|
|
|
6323
6323
|
// src/launcher/flags.ts
|
|
6324
|
-
import
|
|
6324
|
+
import path31 from "node:path";
|
|
6325
6325
|
function resolveLaunchFlags(params) {
|
|
6326
6326
|
return {
|
|
6327
6327
|
skipPermissions: params.flags?.skipPermissions ?? parseEnvBool("AGENT_SHIM_SKIP_PERMISSIONS", params.env.AGENT_SHIM_SKIP_PERMISSIONS) ?? params.cascade?.skipPermissions ?? false,
|
|
@@ -6352,7 +6352,7 @@ function buildEnv(params) {
|
|
|
6352
6352
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
6353
6353
|
let providerCustomHeaders;
|
|
6354
6354
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
6355
|
-
env.CLAUDE_CONFIG_DIR =
|
|
6355
|
+
env.CLAUDE_CONFIG_DIR = path31.join(params.identitiesDir, params.resolvedIdentityName);
|
|
6356
6356
|
}
|
|
6357
6357
|
if (params.provider !== void 0) {
|
|
6358
6358
|
const providerEnv = params.provider.definition.env ?? {};
|
|
@@ -6639,7 +6639,7 @@ var init_launchHook = __esm({
|
|
|
6639
6639
|
|
|
6640
6640
|
// src/launcher.ts
|
|
6641
6641
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
6642
|
-
import
|
|
6642
|
+
import path32 from "node:path";
|
|
6643
6643
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
6644
6644
|
if (port === void 0) {
|
|
6645
6645
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -6747,7 +6747,7 @@ function prepareLaunch(params) {
|
|
|
6747
6747
|
identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
|
|
6748
6748
|
globalDefaultConfigProfile: params.globalDefaultConfigProfile
|
|
6749
6749
|
});
|
|
6750
|
-
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(
|
|
6750
|
+
if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs12.readConfigFile(path32.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
|
|
6751
6751
|
log.error(
|
|
6752
6752
|
`agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
|
|
6753
6753
|
);
|
|
@@ -6810,7 +6810,7 @@ function prepareLaunch(params) {
|
|
|
6810
6810
|
);
|
|
6811
6811
|
const updateCheck = runLaunchUpdateCheck({
|
|
6812
6812
|
mode: params.updateMode ?? "off",
|
|
6813
|
-
checkPath:
|
|
6813
|
+
checkPath: path32.join(paths.root, "update.check"),
|
|
6814
6814
|
currentVersion: package_default.version,
|
|
6815
6815
|
port: params.update
|
|
6816
6816
|
});
|
|
@@ -6976,12 +6976,12 @@ var init_launcher = __esm({
|
|
|
6976
6976
|
});
|
|
6977
6977
|
|
|
6978
6978
|
// src/ownCli.ts
|
|
6979
|
-
import
|
|
6979
|
+
import path33 from "node:path";
|
|
6980
6980
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
6981
6981
|
if (distDir === void 0) {
|
|
6982
6982
|
throw new OwnCliPathUnknownError();
|
|
6983
6983
|
}
|
|
6984
|
-
return
|
|
6984
|
+
return path33.join(distDir, OWN_CLI_FILE_NAME);
|
|
6985
6985
|
}
|
|
6986
6986
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
6987
6987
|
var init_ownCli = __esm({
|
|
@@ -7070,10 +7070,10 @@ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " :
|
|
|
7070
7070
|
|
|
7071
7071
|
// src/frontdoor/trust.ts
|
|
7072
7072
|
import { createHash as createHash6 } from "node:crypto";
|
|
7073
|
-
import
|
|
7073
|
+
import path34 from "node:path";
|
|
7074
7074
|
function resolveTrustBundle(params) {
|
|
7075
7075
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs12 } = params;
|
|
7076
|
-
if (inherited === void 0 || inherited === "" ||
|
|
7076
|
+
if (inherited === void 0 || inherited === "" || path34.resolve(inherited) === path34.resolve(caCertFile)) {
|
|
7077
7077
|
return { path: caCertFile };
|
|
7078
7078
|
}
|
|
7079
7079
|
const caPem = fs12.readFileUtf8(caCertFile);
|
|
@@ -7091,7 +7091,7 @@ function resolveTrustBundle(params) {
|
|
|
7091
7091
|
}
|
|
7092
7092
|
const combined = `${inheritedPem.trimEnd()}
|
|
7093
7093
|
${caPem}`;
|
|
7094
|
-
const bundle =
|
|
7094
|
+
const bundle = path34.join(bundlesDir, `${createHash6("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
7095
7095
|
if (!fs12.exists(bundle)) {
|
|
7096
7096
|
fs12.mkdirp(bundlesDir);
|
|
7097
7097
|
fs12.writeFileAtomic(bundle, combined);
|
|
@@ -7897,11 +7897,21 @@ init_route();
|
|
|
7897
7897
|
|
|
7898
7898
|
// src/frontdoor/supervisor.ts
|
|
7899
7899
|
init_state();
|
|
7900
|
+
import path9 from "node:path";
|
|
7901
|
+
function watchedInstallEntry(resolvedOwnExecutablePath, siblingExists) {
|
|
7902
|
+
const parsed = path9.parse(resolvedOwnExecutablePath);
|
|
7903
|
+
if (parsed.name === "agent-shim") {
|
|
7904
|
+
return resolvedOwnExecutablePath;
|
|
7905
|
+
}
|
|
7906
|
+
const sibling = path9.join(parsed.dir, `agent-shim${parsed.ext}`);
|
|
7907
|
+
return siblingExists(sibling) ? sibling : resolvedOwnExecutablePath;
|
|
7908
|
+
}
|
|
7900
7909
|
var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
|
|
7901
7910
|
var FRONTDOOR_POLL_MS = 1e3;
|
|
7902
7911
|
var MS_PER_MINUTE = 6e4;
|
|
7903
7912
|
async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {}) {
|
|
7904
7913
|
const { fs: fs12, paths } = ports;
|
|
7914
|
+
const servingBinary = ports.statOwnExecutable();
|
|
7905
7915
|
const previous = readFrontDoorState(fs12, paths.frontdoorStateFile);
|
|
7906
7916
|
let lastPort = previous?.lastPort;
|
|
7907
7917
|
let lastConnectPort = previous?.lastConnectPort;
|
|
@@ -7964,6 +7974,18 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
7964
7974
|
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http3.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
|
|
7965
7975
|
let idleSince;
|
|
7966
7976
|
let ticks = 0;
|
|
7977
|
+
const binaryReplaced = () => {
|
|
7978
|
+
const current = ports.statOwnExecutable();
|
|
7979
|
+
return current !== void 0 && servingBinary !== void 0 && (current.dev !== servingBinary.dev || current.ino !== servingBinary.ino || current.size !== servingBinary.size || current.mtimeMs !== servingBinary.mtimeMs);
|
|
7980
|
+
};
|
|
7981
|
+
const shutdown = async () => {
|
|
7982
|
+
await direct.close();
|
|
7983
|
+
await connect3.close();
|
|
7984
|
+
await http3.close();
|
|
7985
|
+
ports.closeRcStreamHub();
|
|
7986
|
+
writeFrontDoorState(fs12, paths.frontdoorStateFile, sticky());
|
|
7987
|
+
return 0;
|
|
7988
|
+
};
|
|
7967
7989
|
for (; ; ) {
|
|
7968
7990
|
if (options.tickLimit !== void 0 && ticks >= options.tickLimit) {
|
|
7969
7991
|
return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
|
|
@@ -7975,16 +7997,16 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
7975
7997
|
ports.checkQuotaExpiry();
|
|
7976
7998
|
const prunedPids = new Set(pruned);
|
|
7977
7999
|
if (listed.filter((session) => !prunedPids.has(session.pid)).length === 0) {
|
|
8000
|
+
if (ticks > 1 && binaryReplaced()) {
|
|
8001
|
+
ports.log("agent-shim frontdoor supervisor: the installed binary changed and no sessions are live; turning the door over for the next launch");
|
|
8002
|
+
ports.doorHealth.binaryTurnover();
|
|
8003
|
+
return await shutdown();
|
|
8004
|
+
}
|
|
7978
8005
|
idleSince ??= ports.now();
|
|
7979
8006
|
if (ports.now() - idleSince >= idleShutdownMinutes * MS_PER_MINUTE) {
|
|
7980
8007
|
ports.log(`agent-shim frontdoor supervisor: no sessions for ${String(idleShutdownMinutes)} minute(s); closing the front door and exiting`);
|
|
7981
8008
|
ports.doorHealth.idleShutdown();
|
|
7982
|
-
await
|
|
7983
|
-
await connect3.close();
|
|
7984
|
-
await http3.close();
|
|
7985
|
-
ports.closeRcStreamHub();
|
|
7986
|
-
writeFrontDoorState(fs12, paths.frontdoorStateFile, sticky());
|
|
7987
|
-
return 0;
|
|
8009
|
+
return await shutdown();
|
|
7988
8010
|
}
|
|
7989
8011
|
} else {
|
|
7990
8012
|
idleSince = void 0;
|
|
@@ -8038,8 +8060,8 @@ function parseConnectTarget(authority) {
|
|
|
8038
8060
|
function isInterceptedHost(host, interceptHosts) {
|
|
8039
8061
|
return interceptHosts.includes(host);
|
|
8040
8062
|
}
|
|
8041
|
-
function servedByPipeline(
|
|
8042
|
-
return
|
|
8063
|
+
function servedByPipeline(path35) {
|
|
8064
|
+
return path35?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
8043
8065
|
}
|
|
8044
8066
|
var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
8045
8067
|
"connection",
|
|
@@ -8573,11 +8595,11 @@ function createRcSessionTracker(deps) {
|
|
|
8573
8595
|
};
|
|
8574
8596
|
const observeExchange = (request4) => {
|
|
8575
8597
|
const method = (request4.method ?? "").toUpperCase();
|
|
8576
|
-
const
|
|
8577
|
-
if (!
|
|
8598
|
+
const path35 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
8599
|
+
if (!path35.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
8578
8600
|
return void 0;
|
|
8579
8601
|
}
|
|
8580
|
-
const tail =
|
|
8602
|
+
const tail = path35.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
8581
8603
|
const facts = {
|
|
8582
8604
|
oauthAuthorization: oauthAuthorizationOf(request4.headers),
|
|
8583
8605
|
anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
|
|
@@ -8959,8 +8981,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
8959
8981
|
function isRcReadFileEncoding(value) {
|
|
8960
8982
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
8961
8983
|
}
|
|
8962
|
-
function buildRcReadFilePayload(requestId,
|
|
8963
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
8984
|
+
function buildRcReadFilePayload(requestId, path35, options) {
|
|
8985
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path35, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
8964
8986
|
}
|
|
8965
8987
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
8966
8988
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -9062,15 +9084,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
9062
9084
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
9063
9085
|
return result.ok ? { ...result, requestId } : result;
|
|
9064
9086
|
}
|
|
9065
|
-
async function readRcSessionFile(deps, sessionId,
|
|
9066
|
-
if (
|
|
9087
|
+
async function readRcSessionFile(deps, sessionId, path35, options) {
|
|
9088
|
+
if (path35 === "") {
|
|
9067
9089
|
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
9068
9090
|
}
|
|
9069
9091
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
9070
9092
|
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
9071
9093
|
}
|
|
9072
9094
|
const requestId = deps.newUuid();
|
|
9073
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
9095
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path35, options), `read ${path35} from session ${sessionId}`);
|
|
9074
9096
|
return result.ok ? { ...result, requestId } : result;
|
|
9075
9097
|
}
|
|
9076
9098
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -9239,11 +9261,11 @@ function createRcControlHandler(deps) {
|
|
|
9239
9261
|
path: "read-file",
|
|
9240
9262
|
read: (body) => {
|
|
9241
9263
|
const session = bodyString(body, "session");
|
|
9242
|
-
const
|
|
9264
|
+
const path35 = bodyString(body, "path");
|
|
9243
9265
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
9244
9266
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
9245
|
-
const refused2 = session === void 0 ||
|
|
9246
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
9267
|
+
const refused2 = session === void 0 || path35 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
9268
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path35, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
9247
9269
|
}
|
|
9248
9270
|
},
|
|
9249
9271
|
{
|
|
@@ -9553,9 +9575,9 @@ function requestIdOfBody(body) {
|
|
|
9553
9575
|
}
|
|
9554
9576
|
function frontDoorRcControl(transport, token) {
|
|
9555
9577
|
const headers = { authorization: `Bearer ${token}` };
|
|
9556
|
-
const listAnswerOf = async (
|
|
9578
|
+
const listAnswerOf = async (path35, what) => {
|
|
9557
9579
|
try {
|
|
9558
|
-
return await transport.request({ method: "GET", path:
|
|
9580
|
+
return await transport.request({ method: "GET", path: path35, headers });
|
|
9559
9581
|
} catch (error) {
|
|
9560
9582
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
9561
9583
|
}
|
|
@@ -9627,10 +9649,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
9627
9649
|
}
|
|
9628
9650
|
return pending;
|
|
9629
9651
|
};
|
|
9630
|
-
const writeOf = async (
|
|
9652
|
+
const writeOf = async (path35, body, describeFailure) => {
|
|
9631
9653
|
let answer;
|
|
9632
9654
|
try {
|
|
9633
|
-
answer = await transport.request({ method: "POST", path:
|
|
9655
|
+
answer = await transport.request({ method: "POST", path: path35, headers: { ...headers, "content-type": "application/json" }, body });
|
|
9634
9656
|
} catch (error) {
|
|
9635
9657
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
9636
9658
|
}
|
|
@@ -9661,10 +9683,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
9661
9683
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
9662
9684
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
9663
9685
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
9664
|
-
readFile: async (sessionId,
|
|
9686
|
+
readFile: async (sessionId, path35, options) => await writeOf(
|
|
9665
9687
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
9666
|
-
JSON.stringify({ session: sessionId, path:
|
|
9667
|
-
(status, message) => `reading ${
|
|
9688
|
+
JSON.stringify({ session: sessionId, path: path35, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
9689
|
+
(status, message) => `reading ${path35} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
9668
9690
|
),
|
|
9669
9691
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
9670
9692
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -9819,12 +9841,12 @@ function tlsFacts(options) {
|
|
|
9819
9841
|
}
|
|
9820
9842
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
9821
9843
|
const agent = new ExemptTlsAgent();
|
|
9822
|
-
const post = async (
|
|
9844
|
+
const post = async (path35, headers, body) => await new Promise((resolve, reject) => {
|
|
9823
9845
|
const options = {
|
|
9824
9846
|
host: target.host,
|
|
9825
9847
|
port: target.port,
|
|
9826
9848
|
method: "POST",
|
|
9827
|
-
path:
|
|
9849
|
+
path: path35,
|
|
9828
9850
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
9829
9851
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
9830
9852
|
agent
|
|
@@ -9889,12 +9911,12 @@ function lateRcStreamDial(resolve) {
|
|
|
9889
9911
|
}
|
|
9890
9912
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
9891
9913
|
const agent = new ExemptTlsAgent();
|
|
9892
|
-
const request4 = async (method,
|
|
9914
|
+
const request4 = async (method, path35, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
9893
9915
|
const options = {
|
|
9894
9916
|
host: target.host,
|
|
9895
9917
|
port: target.port,
|
|
9896
9918
|
method,
|
|
9897
|
-
path:
|
|
9919
|
+
path: path35,
|
|
9898
9920
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
9899
9921
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
9900
9922
|
agent,
|
|
@@ -9936,9 +9958,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
9936
9958
|
return { status, body: await readAll(response) };
|
|
9937
9959
|
},
|
|
9938
9960
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
9939
|
-
const
|
|
9961
|
+
const path35 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
9940
9962
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
9941
|
-
const { status, response } = await request4("GET",
|
|
9963
|
+
const { status, response } = await request4("GET", path35, streamHeaders, void 0, signal);
|
|
9942
9964
|
if (!isSuccessful2(status)) {
|
|
9943
9965
|
await readAll(response);
|
|
9944
9966
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -10150,7 +10172,7 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
10150
10172
|
}
|
|
10151
10173
|
|
|
10152
10174
|
// src/frontdoor/rcCredentialStore.ts
|
|
10153
|
-
import
|
|
10175
|
+
import path10 from "node:path";
|
|
10154
10176
|
function isSafeSessionId(sessionId) {
|
|
10155
10177
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
10156
10178
|
}
|
|
@@ -10176,7 +10198,7 @@ function sequenceNumOfJson(value) {
|
|
|
10176
10198
|
}
|
|
10177
10199
|
function createRcCredentialStore(fs12, dir) {
|
|
10178
10200
|
fs12.mkdirPrivate(dir);
|
|
10179
|
-
const fileFor = (sessionId) =>
|
|
10201
|
+
const fileFor = (sessionId) => path10.join(dir, `${sessionId}.json`);
|
|
10180
10202
|
const readParsed = (sessionId) => {
|
|
10181
10203
|
const raw = fs12.readFileUtf8(fileFor(sessionId));
|
|
10182
10204
|
if (raw === void 0) {
|
|
@@ -10636,7 +10658,7 @@ init_schema();
|
|
|
10636
10658
|
init_cliError();
|
|
10637
10659
|
init_load();
|
|
10638
10660
|
import fs4 from "node:fs";
|
|
10639
|
-
import
|
|
10661
|
+
import path21 from "node:path";
|
|
10640
10662
|
var ProfileNotFoundError = class extends CliError {
|
|
10641
10663
|
constructor(profileName) {
|
|
10642
10664
|
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
@@ -10662,7 +10684,7 @@ var InvalidCategoryNameError = class extends CliError {
|
|
|
10662
10684
|
categoryName;
|
|
10663
10685
|
};
|
|
10664
10686
|
function profileJsonPath(paths, name) {
|
|
10665
|
-
return
|
|
10687
|
+
return path21.join(paths.configProfilesDir, `${name}.json`);
|
|
10666
10688
|
}
|
|
10667
10689
|
function profileExists(paths, name) {
|
|
10668
10690
|
return fs4.existsSync(profileJsonPath(paths, name));
|
|
@@ -10802,19 +10824,19 @@ function writePools(paths, pools) {
|
|
|
10802
10824
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
10803
10825
|
}
|
|
10804
10826
|
function poolCycleOf(pools, name) {
|
|
10805
|
-
const walk = (current,
|
|
10827
|
+
const walk = (current, path35) => {
|
|
10806
10828
|
for (const entry of pools[current]?.identities ?? []) {
|
|
10807
10829
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
10808
10830
|
if (nested === void 0) {
|
|
10809
10831
|
continue;
|
|
10810
10832
|
}
|
|
10811
10833
|
if (nested === name) {
|
|
10812
|
-
return [...
|
|
10834
|
+
return [...path35, nested];
|
|
10813
10835
|
}
|
|
10814
|
-
if (
|
|
10836
|
+
if (path35.includes(nested)) {
|
|
10815
10837
|
continue;
|
|
10816
10838
|
}
|
|
10817
|
-
const found = walk(nested, [...
|
|
10839
|
+
const found = walk(nested, [...path35, nested]);
|
|
10818
10840
|
if (found !== void 0) {
|
|
10819
10841
|
return found;
|
|
10820
10842
|
}
|
|
@@ -10924,7 +10946,7 @@ init_guard();
|
|
|
10924
10946
|
init_providersStore();
|
|
10925
10947
|
init_projects();
|
|
10926
10948
|
init_pipeline();
|
|
10927
|
-
import
|
|
10949
|
+
import path25 from "node:path";
|
|
10928
10950
|
import { z as z12 } from "zod";
|
|
10929
10951
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
10930
10952
|
function projectFragmentOf(rawKey) {
|
|
@@ -11262,10 +11284,10 @@ function collectCheckReport(params) {
|
|
|
11262
11284
|
}).input;
|
|
11263
11285
|
const providerName = cascadeProviderName(cascade);
|
|
11264
11286
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
11265
|
-
const farmRoot = identityDecision.name === void 0 ? void 0 :
|
|
11287
|
+
const farmRoot = identityDecision.name === void 0 ? void 0 : path25.join(paths.identitiesDir, identityDecision.name);
|
|
11266
11288
|
const settingsFiles = {
|
|
11267
|
-
"settings.json": realFsPort.readFileUtf8(
|
|
11268
|
-
"settings.local.json": realFsPort.readFileUtf8(
|
|
11289
|
+
"settings.json": realFsPort.readFileUtf8(path25.join(claudeHome, "settings.json")),
|
|
11290
|
+
"settings.local.json": realFsPort.readFileUtf8(path25.join(claudeHome, "settings.local.json"))
|
|
11269
11291
|
};
|
|
11270
11292
|
const report = runCheck({
|
|
11271
11293
|
cwd,
|
|
@@ -11485,7 +11507,7 @@ init_middleware();
|
|
|
11485
11507
|
init_preflight();
|
|
11486
11508
|
|
|
11487
11509
|
// src/frontdoor/controlSchemas.ts
|
|
11488
|
-
import
|
|
11510
|
+
import path29 from "node:path";
|
|
11489
11511
|
import { z as z19 } from "zod";
|
|
11490
11512
|
|
|
11491
11513
|
// src/doctorReport.ts
|
|
@@ -11499,7 +11521,7 @@ init_schema();
|
|
|
11499
11521
|
init_cliError();
|
|
11500
11522
|
init_identity();
|
|
11501
11523
|
import fs9 from "node:fs";
|
|
11502
|
-
import
|
|
11524
|
+
import path27 from "node:path";
|
|
11503
11525
|
init_lock();
|
|
11504
11526
|
var IdentityNotFoundError = class extends CliError {
|
|
11505
11527
|
constructor(name) {
|
|
@@ -11528,7 +11550,7 @@ var InvalidIdentityNameError = class extends CliError {
|
|
|
11528
11550
|
attemptedName;
|
|
11529
11551
|
};
|
|
11530
11552
|
function identityJsonPath(paths, name) {
|
|
11531
|
-
return
|
|
11553
|
+
return path27.join(paths.identitiesDir, name, "identity.json");
|
|
11532
11554
|
}
|
|
11533
11555
|
function identityExists(paths, name) {
|
|
11534
11556
|
return fs9.existsSync(identityJsonPath(paths, name));
|
|
@@ -11629,7 +11651,7 @@ function setIdentityCredential(paths, identityName, change) {
|
|
|
11629
11651
|
});
|
|
11630
11652
|
}
|
|
11631
11653
|
function belongsToIdentity(entry, name) {
|
|
11632
|
-
return entry === name || entry ===
|
|
11654
|
+
return entry === name || entry === path27.basename(identityLockPath("", name)) || entry.startsWith(`.${name}.scratch.`) || entry.startsWith(`.${name}.previous.`);
|
|
11633
11655
|
}
|
|
11634
11656
|
function removeIdentity(paths, name) {
|
|
11635
11657
|
if (!identityExists(paths, name)) {
|
|
@@ -11637,7 +11659,7 @@ function removeIdentity(paths, name) {
|
|
|
11637
11659
|
}
|
|
11638
11660
|
for (const entry of fs9.readdirSync(paths.identitiesDir)) {
|
|
11639
11661
|
if (belongsToIdentity(entry, name)) {
|
|
11640
|
-
fs9.rmSync(
|
|
11662
|
+
fs9.rmSync(path27.join(paths.identitiesDir, entry), { recursive: true, force: true });
|
|
11641
11663
|
}
|
|
11642
11664
|
}
|
|
11643
11665
|
if (readActiveIdentity2(paths) === name) {
|
|
@@ -11648,7 +11670,7 @@ function removeIdentity(paths, name) {
|
|
|
11648
11670
|
// src/doctorReport.ts
|
|
11649
11671
|
init_realPorts();
|
|
11650
11672
|
import fs10 from "node:fs";
|
|
11651
|
-
import
|
|
11673
|
+
import path28 from "node:path";
|
|
11652
11674
|
|
|
11653
11675
|
// src/codex/siwcStore.ts
|
|
11654
11676
|
import { z as z18 } from "zod";
|
|
@@ -11781,7 +11803,7 @@ function validateJson(schema, input) {
|
|
|
11781
11803
|
return { ok: true, data: result.data };
|
|
11782
11804
|
}
|
|
11783
11805
|
function pushPathResolution(push, resolution) {
|
|
11784
|
-
const ownDir =
|
|
11806
|
+
const ownDir = path28.dirname(resolution.ownExecutablePath);
|
|
11785
11807
|
switch (resolution.agentShim.status) {
|
|
11786
11808
|
case "ok":
|
|
11787
11809
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -11880,14 +11902,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
11880
11902
|
}
|
|
11881
11903
|
function pushLegacyName(push, params) {
|
|
11882
11904
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
11883
|
-
if (legacyVariables.length === 0 &&
|
|
11905
|
+
if (legacyVariables.length === 0 && path28.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
11884
11906
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
11885
11907
|
return;
|
|
11886
11908
|
}
|
|
11887
11909
|
for (const name of legacyVariables) {
|
|
11888
11910
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
11889
11911
|
}
|
|
11890
|
-
if (
|
|
11912
|
+
if (path28.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
11891
11913
|
push(
|
|
11892
11914
|
"legacy-name",
|
|
11893
11915
|
"warn",
|
|
@@ -12227,18 +12249,18 @@ function collectDoctorReport(params) {
|
|
|
12227
12249
|
const { paths } = params;
|
|
12228
12250
|
const identityNames = fs10.existsSync(paths.identitiesDir) ? fs10.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
|
|
12229
12251
|
const identities = identityNames.map((name) => {
|
|
12230
|
-
const farmRoot =
|
|
12231
|
-
const identityPath =
|
|
12252
|
+
const farmRoot = path28.join(paths.identitiesDir, name);
|
|
12253
|
+
const identityPath = path28.join(farmRoot, "identity.json");
|
|
12232
12254
|
return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot };
|
|
12233
12255
|
});
|
|
12234
12256
|
const profileNames = fs10.existsSync(paths.configProfilesDir) ? fs10.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
12235
12257
|
const configProfiles = profileNames.map((name) => {
|
|
12236
|
-
const profilePath =
|
|
12258
|
+
const profilePath = path28.join(paths.configProfilesDir, `${name}.json`);
|
|
12237
12259
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
12238
12260
|
});
|
|
12239
12261
|
const providerNames = fs10.existsSync(paths.providersDir) ? fs10.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
12240
12262
|
const providers = providerNames.map((name) => {
|
|
12241
|
-
const providerPath =
|
|
12263
|
+
const providerPath = path28.join(paths.providersDir, `${name}.json`);
|
|
12242
12264
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
12243
12265
|
});
|
|
12244
12266
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -12250,12 +12272,12 @@ function collectDoctorReport(params) {
|
|
|
12250
12272
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
12251
12273
|
}
|
|
12252
12274
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
12253
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
12275
|
+
const pathDirs = (params.env.PATH ?? "").split(path28.delimiter).filter((dir) => dir !== "");
|
|
12254
12276
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
12255
12277
|
findPathShadow({
|
|
12256
12278
|
pathDirs,
|
|
12257
|
-
targetDir:
|
|
12258
|
-
targetFilename:
|
|
12279
|
+
targetDir: path28.dirname(shimState.targetPath),
|
|
12280
|
+
targetFilename: path28.basename(shimState.targetPath),
|
|
12259
12281
|
findExecutableInDir
|
|
12260
12282
|
}),
|
|
12261
12283
|
shimState.targetPath,
|
|
@@ -12281,7 +12303,7 @@ function collectDoctorReport(params) {
|
|
|
12281
12303
|
agentShim: refinePathShadow(
|
|
12282
12304
|
findPathShadow({
|
|
12283
12305
|
pathDirs,
|
|
12284
|
-
targetDir:
|
|
12306
|
+
targetDir: path28.dirname(ownExecutablePath),
|
|
12285
12307
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
12286
12308
|
findExecutableInDir
|
|
12287
12309
|
}),
|
|
@@ -12350,11 +12372,11 @@ var FrontDoorSessionsOutputSchema = z19.strictObject({ sessions: z19.readonly(z1
|
|
|
12350
12372
|
var CheckRunInputSchema = z19.strictObject({
|
|
12351
12373
|
path: z19.string().min(1),
|
|
12352
12374
|
identity: z19.string().min(1).optional()
|
|
12353
|
-
}).refine((input) =>
|
|
12375
|
+
}).refine((input) => path29.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
12354
12376
|
var PoolPickInputSchema = z19.strictObject({
|
|
12355
12377
|
pool: z19.string().min(1),
|
|
12356
12378
|
path: z19.string().min(1)
|
|
12357
|
-
}).refine((input) =>
|
|
12379
|
+
}).refine((input) => path29.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
12358
12380
|
var DoctorFindingSchema = z19.strictObject({
|
|
12359
12381
|
section: z19.enum(DOCTOR_SECTIONS),
|
|
12360
12382
|
subject: z19.string().optional(),
|
|
@@ -12396,6 +12418,7 @@ var LaunchLifecycleEventSchema = z20.strictObject({
|
|
|
12396
12418
|
var DoorHealthEventSchema = z20.discriminatedUnion("kind", [
|
|
12397
12419
|
z20.strictObject({ kind: z20.literal("generation"), pid: z20.number().int().positive(), providerPort: z20.number().int().positive(), connectPort: z20.number().int().positive(), directPort: z20.number().int().positive(), observedAt: z20.number() }),
|
|
12398
12420
|
z20.strictObject({ kind: z20.literal("listenerFailed"), pid: z20.number().int().positive(), listener: z20.enum(["provider", "connect", "direct"]), message: z20.string(), observedAt: z20.number() }),
|
|
12421
|
+
z20.strictObject({ kind: z20.literal("binaryTurnover"), pid: z20.number().int().positive(), observedAt: z20.number() }),
|
|
12399
12422
|
z20.strictObject({ kind: z20.literal("idleShutdown"), pid: z20.number().int().positive(), observedAt: z20.number() })
|
|
12400
12423
|
]);
|
|
12401
12424
|
var QuotaExpiringEventSchema = z20.strictObject({
|
|
@@ -12767,6 +12790,9 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
12767
12790
|
},
|
|
12768
12791
|
idleShutdown: () => {
|
|
12769
12792
|
publisher.publish({ kind: "idleShutdown", pid, observedAt: now() });
|
|
12793
|
+
},
|
|
12794
|
+
binaryTurnover: () => {
|
|
12795
|
+
publisher.publish({ kind: "binaryTurnover", pid, observedAt: now() });
|
|
12770
12796
|
}
|
|
12771
12797
|
};
|
|
12772
12798
|
}
|
|
@@ -14462,7 +14488,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
14462
14488
|
|
|
14463
14489
|
// src/frontdoor/rcSelfHostMint.ts
|
|
14464
14490
|
init_account();
|
|
14465
|
-
import
|
|
14491
|
+
import path30 from "node:path";
|
|
14466
14492
|
var CREDENTIALS_FILE = ".credentials.json";
|
|
14467
14493
|
var CLAUDE_JSON2 = ".claude.json";
|
|
14468
14494
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -14486,7 +14512,7 @@ function readJsonObject(fs12, file) {
|
|
|
14486
14512
|
return isRecord11(parsed) ? parsed : void 0;
|
|
14487
14513
|
}
|
|
14488
14514
|
function readRcSelfHostRecord(fs12, frontdoorDir) {
|
|
14489
|
-
const parsed = readJsonObject(fs12,
|
|
14515
|
+
const parsed = readJsonObject(fs12, path30.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
14490
14516
|
if (parsed === void 0) {
|
|
14491
14517
|
return void 0;
|
|
14492
14518
|
}
|
|
@@ -14500,11 +14526,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
14500
14526
|
if (!isIdentityName(deps.identity)) {
|
|
14501
14527
|
throw new Error(`"${deps.identity}" is not a valid identity name.`);
|
|
14502
14528
|
}
|
|
14503
|
-
const identityDir =
|
|
14504
|
-
const credentialsFile =
|
|
14505
|
-
const claudeJsonFile =
|
|
14506
|
-
const recordDir =
|
|
14507
|
-
const recordFile =
|
|
14529
|
+
const identityDir = path30.join(deps.identitiesDir, deps.identity);
|
|
14530
|
+
const credentialsFile = path30.join(identityDir, CREDENTIALS_FILE);
|
|
14531
|
+
const claudeJsonFile = path30.join(identityDir, CLAUDE_JSON2);
|
|
14532
|
+
const recordDir = path30.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
14533
|
+
const recordFile = path30.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
14508
14534
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
14509
14535
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
14510
14536
|
const existingOauth = isRecord11(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -14520,7 +14546,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
14520
14546
|
const organizationUuid = deps.newUuid();
|
|
14521
14547
|
const accountUuid = deps.newUuid();
|
|
14522
14548
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
14523
|
-
deps.fs.mkdirPrivate(
|
|
14549
|
+
deps.fs.mkdirPrivate(path30.dirname(credentialsFile));
|
|
14524
14550
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
14525
14551
|
`);
|
|
14526
14552
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -15052,5 +15078,6 @@ export {
|
|
|
15052
15078
|
updateDirectoryRule,
|
|
15053
15079
|
updateProvider,
|
|
15054
15080
|
useIdentity,
|
|
15081
|
+
watchedInstallEntry,
|
|
15055
15082
|
writeDirectoryRules
|
|
15056
15083
|
};
|