claude-use 12.0.0 → 12.1.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 +678 -380
- package/dist/index.cjs +828 -547
- package/dist/index.mjs +820 -540
- package/dist/types/index.d.ts +1062 -1002
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5269,6 +5269,23 @@ function identityIdResolver(identitiesDir, fs17) {
|
|
|
5269
5269
|
return identityIdIn(records, name);
|
|
5270
5270
|
};
|
|
5271
5271
|
}
|
|
5272
|
+
function identityReader(identitiesDir, fs17) {
|
|
5273
|
+
const read = /* @__PURE__ */ new Map();
|
|
5274
|
+
const readOnce = (file) => {
|
|
5275
|
+
if (!read.has(file)) {
|
|
5276
|
+
read.set(file, fs17.readConfigFile(file));
|
|
5277
|
+
}
|
|
5278
|
+
return read.get(file);
|
|
5279
|
+
};
|
|
5280
|
+
const idOf = identityIdResolver(identitiesDir, { readdir: fs17.readdir, readConfigFile: readOnce });
|
|
5281
|
+
return {
|
|
5282
|
+
idOf,
|
|
5283
|
+
load: (name) => {
|
|
5284
|
+
const id = idOf(name);
|
|
5285
|
+
return id === void 0 ? void 0 : loadConfigFile(import_node_path15.default.join(identitiesDir, id, IDENTITY_FILE), IdentitySchema, readOnce)?.config;
|
|
5286
|
+
}
|
|
5287
|
+
};
|
|
5288
|
+
}
|
|
5272
5289
|
function loadIdentity(identitiesDir, name, fs17) {
|
|
5273
5290
|
if (!isFileName(name)) {
|
|
5274
5291
|
throw new UnsafeNameError(name, "identity", FILE_NAME_RULE);
|
|
@@ -6689,9 +6706,224 @@ var init_blockingSpawn = __esm({
|
|
|
6689
6706
|
}
|
|
6690
6707
|
});
|
|
6691
6708
|
|
|
6709
|
+
// src/headroom/headers.ts
|
|
6710
|
+
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
6711
|
+
const merged = /* @__PURE__ */ new Map();
|
|
6712
|
+
for (const block of existing) {
|
|
6713
|
+
if (block === void 0) {
|
|
6714
|
+
continue;
|
|
6715
|
+
}
|
|
6716
|
+
for (const line of block.split("\n")) {
|
|
6717
|
+
const entry = parseCustomHeaderLine(line);
|
|
6718
|
+
if (entry === void 0) {
|
|
6719
|
+
continue;
|
|
6720
|
+
}
|
|
6721
|
+
merged.set(entry.name, entry.value);
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6724
|
+
for (const entry of additions) {
|
|
6725
|
+
merged.set(entry.name, entry.value);
|
|
6726
|
+
}
|
|
6727
|
+
return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
|
|
6728
|
+
}
|
|
6729
|
+
function parseAnthropicCustomHeaders(block) {
|
|
6730
|
+
return block.split("\n").flatMap((line) => {
|
|
6731
|
+
const entry = parseCustomHeaderLine(line);
|
|
6732
|
+
return entry === void 0 ? [] : [entry];
|
|
6733
|
+
});
|
|
6734
|
+
}
|
|
6735
|
+
function withoutAnthropicCustomHeaders(block, remove) {
|
|
6736
|
+
const lines = block.split("\n");
|
|
6737
|
+
const kept = lines.filter((line) => {
|
|
6738
|
+
const entry = parseCustomHeaderLine(line);
|
|
6739
|
+
return entry === void 0 || !remove(entry);
|
|
6740
|
+
});
|
|
6741
|
+
return kept.length === lines.length ? block : kept.join("\n");
|
|
6742
|
+
}
|
|
6743
|
+
function parseCustomHeaderLine(line) {
|
|
6744
|
+
const trimmed = line.trim();
|
|
6745
|
+
if (trimmed === "") {
|
|
6746
|
+
return void 0;
|
|
6747
|
+
}
|
|
6748
|
+
const colon = trimmed.indexOf(":");
|
|
6749
|
+
if (colon <= 0) {
|
|
6750
|
+
return void 0;
|
|
6751
|
+
}
|
|
6752
|
+
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
6753
|
+
}
|
|
6754
|
+
var init_headers = __esm({
|
|
6755
|
+
"src/headroom/headers.ts"() {
|
|
6756
|
+
"use strict";
|
|
6757
|
+
}
|
|
6758
|
+
});
|
|
6759
|
+
|
|
6760
|
+
// src/launcher/injected.ts
|
|
6761
|
+
function listKey(list) {
|
|
6762
|
+
return `${list},appended`;
|
|
6763
|
+
}
|
|
6764
|
+
function digest2(value) {
|
|
6765
|
+
return (0, import_node_crypto7.createHash)("sha256").update(value).digest("hex");
|
|
6766
|
+
}
|
|
6767
|
+
function recordedDigests(env) {
|
|
6768
|
+
const raw = env[INJECTED_ENV];
|
|
6769
|
+
if (raw === void 0 || raw === "") {
|
|
6770
|
+
return {};
|
|
6771
|
+
}
|
|
6772
|
+
let parsed;
|
|
6773
|
+
try {
|
|
6774
|
+
parsed = JSON.parse(raw);
|
|
6775
|
+
} catch {
|
|
6776
|
+
return {};
|
|
6777
|
+
}
|
|
6778
|
+
const result = InjectedSchema.safeParse(parsed);
|
|
6779
|
+
return result.success ? result.data : {};
|
|
6780
|
+
}
|
|
6781
|
+
function recordInjections(base) {
|
|
6782
|
+
const env = { ...base };
|
|
6783
|
+
const digests = new Map(Object.entries(recordedDigests(env)));
|
|
6784
|
+
return {
|
|
6785
|
+
env,
|
|
6786
|
+
set: (name, value) => {
|
|
6787
|
+
env[name] = value;
|
|
6788
|
+
digests.set(name, digest2(value));
|
|
6789
|
+
},
|
|
6790
|
+
unset: (name) => {
|
|
6791
|
+
env[name] = void 0;
|
|
6792
|
+
digests.delete(name);
|
|
6793
|
+
},
|
|
6794
|
+
recordHeaders: (names) => {
|
|
6795
|
+
const block = env[CUSTOM_HEADERS_ENV];
|
|
6796
|
+
for (const entry of block === void 0 ? [] : parseAnthropicCustomHeaders(block)) {
|
|
6797
|
+
if (names.includes(entry.name)) {
|
|
6798
|
+
digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
|
|
6799
|
+
}
|
|
6800
|
+
}
|
|
6801
|
+
},
|
|
6802
|
+
recordBypassHosts: (list, hosts) => {
|
|
6803
|
+
const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
|
|
6804
|
+
if (recordedHosts.length > 0) {
|
|
6805
|
+
digests.set(listKey(list), recordedHosts.join(","));
|
|
6806
|
+
}
|
|
6807
|
+
},
|
|
6808
|
+
finish: () => {
|
|
6809
|
+
if (digests.size > 0) {
|
|
6810
|
+
env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
|
|
6811
|
+
}
|
|
6812
|
+
}
|
|
6813
|
+
};
|
|
6814
|
+
}
|
|
6815
|
+
function withoutRecordedHosts(list, value, digests) {
|
|
6816
|
+
const recordedHosts = new Set(digests[listKey(list)]?.split(","));
|
|
6817
|
+
const entries = value.split(",");
|
|
6818
|
+
const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
|
|
6819
|
+
return kept.length === entries.length ? value : kept.join(",");
|
|
6820
|
+
}
|
|
6821
|
+
function launchEnvironment(env, configDirEscapeHatch) {
|
|
6822
|
+
return configDirEscapeHatch ? env : withoutInjected(env);
|
|
6823
|
+
}
|
|
6824
|
+
function withoutInjected(env) {
|
|
6825
|
+
const digests = recordedDigests(env);
|
|
6826
|
+
const entries = Object.entries(env).flatMap(([name, value]) => {
|
|
6827
|
+
if (name === INJECTED_ENV) {
|
|
6828
|
+
return [];
|
|
6829
|
+
}
|
|
6830
|
+
if (value === void 0) {
|
|
6831
|
+
return [[name, value]];
|
|
6832
|
+
}
|
|
6833
|
+
if (name === CUSTOM_HEADERS_ENV) {
|
|
6834
|
+
const remaining = withoutAnthropicCustomHeaders(value, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
|
|
6835
|
+
return remaining !== value && remaining.trim() === "" ? [] : [[name, remaining]];
|
|
6836
|
+
}
|
|
6837
|
+
if (name === "NO_PROXY" || name === "no_proxy") {
|
|
6838
|
+
const remaining = withoutRecordedHosts(name, value, digests);
|
|
6839
|
+
return remaining !== value && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
|
|
6840
|
+
}
|
|
6841
|
+
return digests[name] === digest2(value) ? [] : [[name, value]];
|
|
6842
|
+
});
|
|
6843
|
+
return Object.fromEntries(entries);
|
|
6844
|
+
}
|
|
6845
|
+
var import_node_crypto7, import_zod14, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
6846
|
+
var init_injected = __esm({
|
|
6847
|
+
"src/launcher/injected.ts"() {
|
|
6848
|
+
"use strict";
|
|
6849
|
+
import_node_crypto7 = require("node:crypto");
|
|
6850
|
+
import_zod14 = require("zod");
|
|
6851
|
+
init_headers();
|
|
6852
|
+
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
6853
|
+
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
6854
|
+
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
6855
|
+
InjectedSchema = import_zod14.z.record(import_zod14.z.string(), import_zod14.z.string());
|
|
6856
|
+
}
|
|
6857
|
+
});
|
|
6858
|
+
|
|
6859
|
+
// src/launcher/guard.ts
|
|
6860
|
+
function detectAmbientCredential(env, injected) {
|
|
6861
|
+
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
6862
|
+
const value = env[variable];
|
|
6863
|
+
if (value === void 0 || value === "") {
|
|
6864
|
+
continue;
|
|
6865
|
+
}
|
|
6866
|
+
if (injected?.variable === variable && value === injected.token) {
|
|
6867
|
+
continue;
|
|
6868
|
+
}
|
|
6869
|
+
return { variable };
|
|
6870
|
+
}
|
|
6871
|
+
return void 0;
|
|
6872
|
+
}
|
|
6873
|
+
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
6874
|
+
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
6875
|
+
return [
|
|
6876
|
+
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
6877
|
+
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
6878
|
+
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
6879
|
+
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
6880
|
+
`\`${identitySetCommand}\`.`
|
|
6881
|
+
].join("\n");
|
|
6882
|
+
}
|
|
6883
|
+
function evaluateAmbientCredentialGuard(params) {
|
|
6884
|
+
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
6885
|
+
if (detected === void 0) {
|
|
6886
|
+
return { ok: true };
|
|
6887
|
+
}
|
|
6888
|
+
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
6889
|
+
return { ok: true };
|
|
6890
|
+
}
|
|
6891
|
+
return {
|
|
6892
|
+
ok: false,
|
|
6893
|
+
variable: detected.variable,
|
|
6894
|
+
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
6895
|
+
};
|
|
6896
|
+
}
|
|
6897
|
+
function ambientCredentialFinding(env) {
|
|
6898
|
+
const named = detectAmbientCredential(launchEnvironment(env, false));
|
|
6899
|
+
if (named !== void 0) {
|
|
6900
|
+
return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
|
|
6901
|
+
}
|
|
6902
|
+
const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
|
|
6903
|
+
if (bare !== void 0) {
|
|
6904
|
+
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>\`.` };
|
|
6905
|
+
}
|
|
6906
|
+
return { severity: "pass", message: "No ambient-credential environment variable is set." };
|
|
6907
|
+
}
|
|
6908
|
+
var AMBIENT_CREDENTIAL_VARS;
|
|
6909
|
+
var init_guard = __esm({
|
|
6910
|
+
"src/launcher/guard.ts"() {
|
|
6911
|
+
"use strict";
|
|
6912
|
+
init_injected();
|
|
6913
|
+
AMBIENT_CREDENTIAL_VARS = [
|
|
6914
|
+
"ANTHROPIC_API_KEY",
|
|
6915
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
6916
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
6917
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
6918
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
6919
|
+
"CLAUDE_CODE_USE_FOUNDRY"
|
|
6920
|
+
];
|
|
6921
|
+
}
|
|
6922
|
+
});
|
|
6923
|
+
|
|
6692
6924
|
// src/usage/signIn.ts
|
|
6693
6925
|
function claudeCodeKeychainService(configDir) {
|
|
6694
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${(0,
|
|
6926
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${(0, import_node_crypto8.createHash)("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
6695
6927
|
}
|
|
6696
6928
|
function keychainHasItem(run, configDir) {
|
|
6697
6929
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -6724,15 +6956,35 @@ function identitySignIn(fs17, probe, identity) {
|
|
|
6724
6956
|
platform: probe.platform
|
|
6725
6957
|
});
|
|
6726
6958
|
}
|
|
6727
|
-
|
|
6959
|
+
function storedLoginUsable(run, claudeBin, configDir, env) {
|
|
6960
|
+
const childEnv = { ...env, CLAUDE_CONFIG_DIR: configDir };
|
|
6961
|
+
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
6962
|
+
childEnv[variable] = void 0;
|
|
6963
|
+
}
|
|
6964
|
+
const result = run.run(claudeBin, ["auth", "status"], void 0, { env: childEnv, timeoutMs: AUTH_STATUS_TIMEOUT_MS });
|
|
6965
|
+
if (result.status === null) {
|
|
6966
|
+
return void 0;
|
|
6967
|
+
}
|
|
6968
|
+
try {
|
|
6969
|
+
const status = JSON.parse(result.stdout);
|
|
6970
|
+
if (typeof status === "object" && status !== null && "loggedIn" in status && typeof status.loggedIn === "boolean") {
|
|
6971
|
+
return status.loggedIn;
|
|
6972
|
+
}
|
|
6973
|
+
} catch {
|
|
6974
|
+
}
|
|
6975
|
+
return void 0;
|
|
6976
|
+
}
|
|
6977
|
+
var import_node_crypto8, import_node_path19, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS, AUTH_STATUS_TIMEOUT_MS;
|
|
6728
6978
|
var init_signIn = __esm({
|
|
6729
6979
|
"src/usage/signIn.ts"() {
|
|
6730
6980
|
"use strict";
|
|
6731
|
-
|
|
6981
|
+
import_node_crypto8 = require("node:crypto");
|
|
6732
6982
|
import_node_path19 = __toESM(require("node:path"), 1);
|
|
6983
|
+
init_guard();
|
|
6733
6984
|
CREDENTIALS_FILE = ".credentials.json";
|
|
6734
6985
|
KEYCHAIN_SERVICE_PREFIX = "Claude Code-credentials";
|
|
6735
6986
|
KEYCHAIN_SERVICE_HASH_DIGITS = 8;
|
|
6987
|
+
AUTH_STATUS_TIMEOUT_MS = 1e4;
|
|
6736
6988
|
}
|
|
6737
6989
|
});
|
|
6738
6990
|
|
|
@@ -6863,7 +7115,7 @@ function serialisedFor(entry, owner) {
|
|
|
6863
7115
|
return JSON.stringify({ owner, ...withoutOwner(entry) });
|
|
6864
7116
|
}
|
|
6865
7117
|
function tempPathFor(target) {
|
|
6866
|
-
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0,
|
|
7118
|
+
return import_node_path20.default.join(import_node_path20.default.dirname(target), `${TEMP_PREFIX}${String(process.pid)}-${(0, import_node_crypto9.randomUUID)()}`);
|
|
6867
7119
|
}
|
|
6868
7120
|
function processRuns(pid) {
|
|
6869
7121
|
try {
|
|
@@ -6982,11 +7234,11 @@ function createRealCredentialCache(root, keychain = { run: security, platform: p
|
|
|
6982
7234
|
function realCredentialCacheEnv(paths) {
|
|
6983
7235
|
return { port: createRealCredentialCache(paths.root), platform: process.platform, now: () => Date.now() };
|
|
6984
7236
|
}
|
|
6985
|
-
var
|
|
7237
|
+
var import_node_crypto9, import_node_fs5, import_node_path20, CACHE_DIR_MODE, CACHE_FILE_MODE, TEMP_PREFIX, TEMP_NAME, RELEASED_TEMP_NAME;
|
|
6986
7238
|
var init_realCredentialCache = __esm({
|
|
6987
7239
|
"src/realCredentialCache.ts"() {
|
|
6988
7240
|
"use strict";
|
|
6989
|
-
|
|
7241
|
+
import_node_crypto9 = require("node:crypto");
|
|
6990
7242
|
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
6991
7243
|
import_node_path20 = __toESM(require("node:path"), 1);
|
|
6992
7244
|
init_blockingSpawn();
|
|
@@ -7143,7 +7395,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
7143
7395
|
fs17.removeRecursive(files.legacyStateFile);
|
|
7144
7396
|
}
|
|
7145
7397
|
function hashAllowlist(allowlist) {
|
|
7146
|
-
return (0,
|
|
7398
|
+
return (0, import_node_crypto10.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
|
|
7147
7399
|
}
|
|
7148
7400
|
function formatAllowlistFile(allowlist) {
|
|
7149
7401
|
return allowlist.map((entry) => `${entry}
|
|
@@ -7248,40 +7500,40 @@ function readStartLock(fs17, lockFile) {
|
|
|
7248
7500
|
return void 0;
|
|
7249
7501
|
}
|
|
7250
7502
|
}
|
|
7251
|
-
var
|
|
7503
|
+
var import_node_crypto10, import_node_path21, import_zod15, HeadroomStateSchema, HeadroomSessionSchema, HeadroomLockSchema, HEADROOM_ALLOWLIST_FILE_FLAG, ALLOWLIST_LINE_BREAKS, ALLOWLIST_WHITESPACE, ALLOWLIST_FILE_SEPARATORS, ALLOWLIST_FILE_COMMENT, ALLOWLIST_ENTRY_WHITESPACE, ALLOWLIST_SURROUNDING_WHITESPACE, ALLOWLIST_SAFE_SCHEMES;
|
|
7252
7504
|
var init_state2 = __esm({
|
|
7253
7505
|
"src/headroom/state.ts"() {
|
|
7254
7506
|
"use strict";
|
|
7255
|
-
|
|
7507
|
+
import_node_crypto10 = require("node:crypto");
|
|
7256
7508
|
import_node_path21 = __toESM(require("node:path"), 1);
|
|
7257
|
-
|
|
7509
|
+
import_zod15 = require("zod");
|
|
7258
7510
|
init_schema();
|
|
7259
|
-
HeadroomStateSchema =
|
|
7511
|
+
HeadroomStateSchema = import_zod15.z.strictObject({
|
|
7260
7512
|
/** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
|
|
7261
|
-
supervisorPid:
|
|
7513
|
+
supervisorPid: import_zod15.z.number().int().positive().optional(),
|
|
7262
7514
|
/** The headroom proxy process itself, recorded as soon as it is spawned (before it is ready, which `socketPath` signals) so a successor can find a daemon whose supervisor died during its start. Absent while the supervisor is between restarts. */
|
|
7263
|
-
headroomPid:
|
|
7515
|
+
headroomPid: import_zod15.z.number().int().positive().optional(),
|
|
7264
7516
|
/**
|
|
7265
7517
|
* The unix socket the proxy serves on, inside the owner-only socket directory. Absent until the proxy has passed its readiness check, so "socketPath is set" is itself the ready signal a launcher polls for. The front door reads it on every hop, so a restart (which keeps the generation's path) is followed without anything being relaunched.
|
|
7266
7518
|
*/
|
|
7267
|
-
socketPath:
|
|
7519
|
+
socketPath: import_zod15.z.string().min(1).optional(),
|
|
7268
7520
|
/** The `headroom --version` output of the running install. */
|
|
7269
|
-
version:
|
|
7521
|
+
version: import_zod15.z.string().optional(),
|
|
7270
7522
|
/**
|
|
7271
7523
|
* Hash of the allowlist the running proxy serves. The supervisor records it in the same tick it writes that allowlist to `LayoutPaths.headroomAllowlistFile`, which the proxy re-reads on its next request, so a provider launch, whose requests come back through its front door's direct origin, waits until this names an allowlist holding that origin. A supervisor from an earlier release records here the hash of the allowlist its daemon was started with instead (see `earlierRelease.ts`).
|
|
7272
7524
|
*/
|
|
7273
|
-
allowlistHash:
|
|
7525
|
+
allowlistHash: import_zod15.z.string().optional(),
|
|
7274
7526
|
/** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
|
|
7275
|
-
settingsHash:
|
|
7527
|
+
settingsHash: import_zod15.z.string().optional(),
|
|
7276
7528
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
7277
|
-
installedSource:
|
|
7529
|
+
installedSource: import_zod15.z.string().optional(),
|
|
7278
7530
|
/** The install spec the supervisor is installing right now, present only while `uv tool install` runs, so a launcher that finds a live supervisor with no daemon yet keeps waiting for the install instead of counting it against its start bound. Cleared by the write that follows the install, whatever its outcome. */
|
|
7279
|
-
installing:
|
|
7531
|
+
installing: import_zod15.z.string().optional(),
|
|
7280
7532
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
7281
|
-
lastError:
|
|
7533
|
+
lastError: import_zod15.z.string().optional()
|
|
7282
7534
|
});
|
|
7283
|
-
HeadroomSessionSchema =
|
|
7284
|
-
HeadroomLockSchema =
|
|
7535
|
+
HeadroomSessionSchema = import_zod15.z.strictObject({ pid: import_zod15.z.number().int().positive(), startedAt: import_zod15.z.number(), supervisorPid: import_zod15.z.number().int().positive() });
|
|
7536
|
+
HeadroomLockSchema = import_zod15.z.strictObject({ pid: import_zod15.z.number().int().positive(), at: import_zod15.z.number() });
|
|
7285
7537
|
HEADROOM_ALLOWLIST_FILE_FLAG = "--allowed-base-urls-file";
|
|
7286
7538
|
ALLOWLIST_LINE_BREAKS = "\\n\\r\\u000b\\u000c\\u001c\\u001d\\u001e\\u0085\\u2028\\u2029";
|
|
7287
7539
|
ALLOWLIST_WHITESPACE = "\\t\\n\\u000b\\u000c\\r\\u001c-\\u001f \\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
@@ -7495,13 +7747,13 @@ function settingsEnv(settings) {
|
|
|
7495
7747
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
7496
7748
|
}
|
|
7497
7749
|
function hashSettings(settings) {
|
|
7498
|
-
return (0,
|
|
7750
|
+
return (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
7499
7751
|
}
|
|
7500
|
-
var
|
|
7752
|
+
var import_node_crypto11;
|
|
7501
7753
|
var init_settings = __esm({
|
|
7502
7754
|
"src/headroom/settings.ts"() {
|
|
7503
7755
|
"use strict";
|
|
7504
|
-
|
|
7756
|
+
import_node_crypto11 = require("node:crypto");
|
|
7505
7757
|
}
|
|
7506
7758
|
});
|
|
7507
7759
|
|
|
@@ -7701,14 +7953,14 @@ function pinnedGitCommit(spec) {
|
|
|
7701
7953
|
const ref = GIT_SPEC_RE.exec(spec)?.[1];
|
|
7702
7954
|
return ref !== void 0 && COMMIT_SHA_RE.test(ref) ? ref.toLowerCase() : void 0;
|
|
7703
7955
|
}
|
|
7704
|
-
var
|
|
7956
|
+
var import_zod16, GIT_SPEC_RE, COMMIT_SHA_RE, DirectUrlSchema;
|
|
7705
7957
|
var init_source = __esm({
|
|
7706
7958
|
"src/headroom/source.ts"() {
|
|
7707
7959
|
"use strict";
|
|
7708
|
-
|
|
7960
|
+
import_zod16 = require("zod");
|
|
7709
7961
|
GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
7710
7962
|
COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
|
|
7711
|
-
DirectUrlSchema =
|
|
7963
|
+
DirectUrlSchema = import_zod16.z.object({ vcs_info: import_zod16.z.object({ commit_id: import_zod16.z.string() }) });
|
|
7712
7964
|
}
|
|
7713
7965
|
});
|
|
7714
7966
|
|
|
@@ -8214,6 +8466,9 @@ function realFrontDoorLiveness(pids) {
|
|
|
8214
8466
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr, ...result.error === void 0 ? {} : { error: result.error } };
|
|
8215
8467
|
});
|
|
8216
8468
|
}
|
|
8469
|
+
function definedEntries(env) {
|
|
8470
|
+
return Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0));
|
|
8471
|
+
}
|
|
8217
8472
|
function realRunAsyncWithin(timeoutMs) {
|
|
8218
8473
|
return async (command, args) => await new Promise((resolve) => {
|
|
8219
8474
|
(0, import_node_child_process2.execFile)(command, [...args], { encoding: "utf8", timeout: timeoutMs }, (error, stdout, stderr) => {
|
|
@@ -8422,14 +8677,14 @@ function realResolveClaudeBinary(isOwnBinary) {
|
|
|
8422
8677
|
function realInstalledClaudeVersions() {
|
|
8423
8678
|
return installedVersions(listVersionsDir(defaultVersionsDir()));
|
|
8424
8679
|
}
|
|
8425
|
-
var import_node_child_process2,
|
|
8680
|
+
var import_node_child_process2, import_node_crypto12, import_node_fs6, import_node_os2, import_node_path24, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS2, DIRECTORY_FLUSH_UNSUPPORTED_CODES, realFarmFs, INT32_BYTE_LENGTH, KEY_POLL_MS, CTRL_C_BYTE, realHoldPort, 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, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
|
|
8426
8681
|
var init_realPorts = __esm({
|
|
8427
8682
|
"src/realPorts.ts"() {
|
|
8428
8683
|
"use strict";
|
|
8429
8684
|
init_blockingSpawn();
|
|
8430
8685
|
init_processRole();
|
|
8431
8686
|
import_node_child_process2 = require("node:child_process");
|
|
8432
|
-
|
|
8687
|
+
import_node_crypto12 = require("node:crypto");
|
|
8433
8688
|
import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
8434
8689
|
import_node_os2 = __toESM(require("node:os"), 1);
|
|
8435
8690
|
import_node_path24 = __toESM(require("node:path"), 1);
|
|
@@ -8580,7 +8835,7 @@ var init_realPorts = __esm({
|
|
|
8580
8835
|
},
|
|
8581
8836
|
hashFile(filePath) {
|
|
8582
8837
|
try {
|
|
8583
|
-
return (0,
|
|
8838
|
+
return (0, import_node_crypto12.createHash)("sha256").update(import_node_fs6.default.readFileSync(filePath)).digest("hex");
|
|
8584
8839
|
} catch (error) {
|
|
8585
8840
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
8586
8841
|
return void 0;
|
|
@@ -8620,8 +8875,14 @@ var init_realPorts = __esm({
|
|
|
8620
8875
|
BYTES_PER_MIB2 = 1048576;
|
|
8621
8876
|
RUN_OUTPUT_LIMIT_BYTES = RUN_OUTPUT_LIMIT_MIB * BYTES_PER_MIB2;
|
|
8622
8877
|
realRunPort = {
|
|
8623
|
-
run(command, args, input) {
|
|
8624
|
-
const result = spawnSyncBlocking("an external command", command, args, {
|
|
8878
|
+
run(command, args, input, options) {
|
|
8879
|
+
const result = spawnSyncBlocking("an external command", command, args, {
|
|
8880
|
+
encoding: "utf8",
|
|
8881
|
+
maxBuffer: RUN_OUTPUT_LIMIT_BYTES,
|
|
8882
|
+
...input === void 0 ? {} : { input },
|
|
8883
|
+
...options?.env === void 0 ? {} : { env: definedEntries(options.env) },
|
|
8884
|
+
...options?.timeoutMs === void 0 ? {} : { timeout: options.timeoutMs }
|
|
8885
|
+
});
|
|
8625
8886
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr };
|
|
8626
8887
|
}
|
|
8627
8888
|
};
|
|
@@ -8999,7 +9260,8 @@ var init_identityAccounts = __esm({
|
|
|
8999
9260
|
function candidateHeading(candidate) {
|
|
9000
9261
|
const score = candidate.score === void 0 ? "" : ` score ${candidate.score.toFixed(2)}${candidate.scoreWindow === "fiveHour" ? " by 5h reset" : " by 7d reset"}`;
|
|
9001
9262
|
const dry = candidate.feasible ? "" : " (5h would run dry)";
|
|
9002
|
-
|
|
9263
|
+
const onProvider = candidate.provider === void 0 ? "" : ` on provider ${candidate.provider}`;
|
|
9264
|
+
return `[${candidate.class}${score}]${dry}${onProvider}`;
|
|
9003
9265
|
}
|
|
9004
9266
|
function percent(fraction) {
|
|
9005
9267
|
return `${String(Math.round(fraction * PERCENT))}%`;
|
|
@@ -9041,24 +9303,27 @@ function planOf(account) {
|
|
|
9041
9303
|
}
|
|
9042
9304
|
return { kind: "subscription", capacity: 1, recognised: BASE_TIER.test(tier), ...tierField };
|
|
9043
9305
|
}
|
|
9044
|
-
|
|
9306
|
+
function planOfProviderQuota(quota) {
|
|
9307
|
+
return planOf(quota?.level === void 0 ? void 0 : { organizationRateLimitTier: quota.level });
|
|
9308
|
+
}
|
|
9309
|
+
var import_zod17, PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
9045
9310
|
var init_plan2 = __esm({
|
|
9046
9311
|
"src/usage/plan.ts"() {
|
|
9047
9312
|
"use strict";
|
|
9048
|
-
|
|
9049
|
-
PlanClassSchema =
|
|
9050
|
-
|
|
9051
|
-
kind:
|
|
9313
|
+
import_zod17 = require("zod");
|
|
9314
|
+
PlanClassSchema = import_zod17.z.union([
|
|
9315
|
+
import_zod17.z.strictObject({
|
|
9316
|
+
kind: import_zod17.z.literal("subscription"),
|
|
9052
9317
|
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
9053
|
-
capacity:
|
|
9318
|
+
capacity: import_zod17.z.number().positive(),
|
|
9054
9319
|
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
9055
|
-
recognised:
|
|
9320
|
+
recognised: import_zod17.z.boolean(),
|
|
9056
9321
|
/** The tier string the classification rests on, when the account had one. */
|
|
9057
|
-
tier:
|
|
9322
|
+
tier: import_zod17.z.string().optional()
|
|
9058
9323
|
}),
|
|
9059
|
-
|
|
9060
|
-
kind:
|
|
9061
|
-
tier:
|
|
9324
|
+
import_zod17.z.strictObject({
|
|
9325
|
+
kind: import_zod17.z.literal("pay-per-use"),
|
|
9326
|
+
tier: import_zod17.z.string().optional()
|
|
9062
9327
|
})
|
|
9063
9328
|
]);
|
|
9064
9329
|
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
@@ -9068,21 +9333,21 @@ var init_plan2 = __esm({
|
|
|
9068
9333
|
});
|
|
9069
9334
|
|
|
9070
9335
|
// src/usage/scan.ts
|
|
9071
|
-
var
|
|
9336
|
+
var import_zod18, AnthropicUsageSchema, ErrorObjectSchema;
|
|
9072
9337
|
var init_scan = __esm({
|
|
9073
9338
|
"src/usage/scan.ts"() {
|
|
9074
9339
|
"use strict";
|
|
9075
|
-
|
|
9076
|
-
AnthropicUsageSchema =
|
|
9077
|
-
input_tokens:
|
|
9078
|
-
output_tokens:
|
|
9079
|
-
cache_creation_input_tokens:
|
|
9080
|
-
cache_read_input_tokens:
|
|
9340
|
+
import_zod18 = require("zod");
|
|
9341
|
+
AnthropicUsageSchema = import_zod18.z.looseObject({
|
|
9342
|
+
input_tokens: import_zod18.z.number().int().nonnegative().nullish(),
|
|
9343
|
+
output_tokens: import_zod18.z.number().int().nonnegative().nullish(),
|
|
9344
|
+
cache_creation_input_tokens: import_zod18.z.number().int().nonnegative().nullish(),
|
|
9345
|
+
cache_read_input_tokens: import_zod18.z.number().int().nonnegative().nullish()
|
|
9081
9346
|
});
|
|
9082
|
-
ErrorObjectSchema =
|
|
9083
|
-
type:
|
|
9084
|
-
code:
|
|
9085
|
-
message:
|
|
9347
|
+
ErrorObjectSchema = import_zod18.z.looseObject({
|
|
9348
|
+
type: import_zod18.z.string().optional(),
|
|
9349
|
+
code: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).optional(),
|
|
9350
|
+
message: import_zod18.z.string().optional()
|
|
9086
9351
|
});
|
|
9087
9352
|
}
|
|
9088
9353
|
});
|
|
@@ -9100,12 +9365,58 @@ var init_middleware = __esm({
|
|
|
9100
9365
|
}
|
|
9101
9366
|
});
|
|
9102
9367
|
|
|
9368
|
+
// src/usage/windowLengths.ts
|
|
9369
|
+
var MS_PER_HOUR2, HOURS_PER_DAY3, FIVE_HOURS, SEVEN_DAYS, FIVE_HOUR_WINDOW_MS, SEVEN_DAY_WINDOW_MS;
|
|
9370
|
+
var init_windowLengths = __esm({
|
|
9371
|
+
"src/usage/windowLengths.ts"() {
|
|
9372
|
+
"use strict";
|
|
9373
|
+
MS_PER_HOUR2 = 36e5;
|
|
9374
|
+
HOURS_PER_DAY3 = 24;
|
|
9375
|
+
FIVE_HOURS = 5;
|
|
9376
|
+
SEVEN_DAYS = 7;
|
|
9377
|
+
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR2;
|
|
9378
|
+
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY3 * MS_PER_HOUR2;
|
|
9379
|
+
}
|
|
9380
|
+
});
|
|
9381
|
+
|
|
9382
|
+
// src/usage/providerWindows.ts
|
|
9383
|
+
function bindingWindow(quota, periodMs) {
|
|
9384
|
+
const same = quota.windows.filter((window) => window.periodMs === periodMs);
|
|
9385
|
+
const tightest = same.reduce((binding, window) => binding === void 0 || window.utilization > binding.utilization ? window : binding, void 0);
|
|
9386
|
+
if (tightest === void 0) {
|
|
9387
|
+
return void 0;
|
|
9388
|
+
}
|
|
9389
|
+
return { utilization: tightest.utilization, ...tightest.resetsAt === void 0 ? {} : { resetsAt: tightest.resetsAt }, status: tightest.utilization >= 1 ? "rejected" : "allowed" };
|
|
9390
|
+
}
|
|
9391
|
+
function unifiedFromQuota(quota) {
|
|
9392
|
+
const fiveHour = bindingWindow(quota, FIVE_HOUR_WINDOW_MS);
|
|
9393
|
+
const sevenDay = bindingWindow(quota, SEVEN_DAY_WINDOW_MS);
|
|
9394
|
+
return fiveHour === void 0 && sevenDay === void 0 ? void 0 : { ...fiveHour === void 0 ? {} : { fiveHour }, ...sevenDay === void 0 ? {} : { sevenDay } };
|
|
9395
|
+
}
|
|
9396
|
+
function rankingWindowsOf(provider, state) {
|
|
9397
|
+
const recorded = state?.rateLimit;
|
|
9398
|
+
if (provider === void 0) {
|
|
9399
|
+
return recorded?.unified === void 0 ? void 0 : { unified: recorded.unified, observedAt: recorded.observedAt };
|
|
9400
|
+
}
|
|
9401
|
+
if (recorded?.unified !== void 0 && (recorded.unified.fiveHour !== void 0 || recorded.unified.sevenDay !== void 0)) {
|
|
9402
|
+
return { unified: recorded.unified, observedAt: recorded.observedAt };
|
|
9403
|
+
}
|
|
9404
|
+
const pulled = state?.quota === void 0 ? void 0 : unifiedFromQuota(state.quota);
|
|
9405
|
+
return state?.quota === void 0 || pulled === void 0 ? void 0 : { unified: pulled, observedAt: state.quota.observedAt };
|
|
9406
|
+
}
|
|
9407
|
+
var init_providerWindows = __esm({
|
|
9408
|
+
"src/usage/providerWindows.ts"() {
|
|
9409
|
+
"use strict";
|
|
9410
|
+
init_windowLengths();
|
|
9411
|
+
}
|
|
9412
|
+
});
|
|
9413
|
+
|
|
9103
9414
|
// src/usage/quotaFacts.ts
|
|
9104
9415
|
function windowFacts(window, nowMs) {
|
|
9105
9416
|
if (window?.utilization === void 0 || window.resetsAt === void 0) {
|
|
9106
9417
|
return void 0;
|
|
9107
9418
|
}
|
|
9108
|
-
return { remaining: Math.max(0, 1 - window.utilization), utilization: window.utilization, hoursUntilReset: Math.max(0, (Date.parse(window.resetsAt) - nowMs) /
|
|
9419
|
+
return { remaining: Math.max(0, 1 - window.utilization), utilization: window.utilization, hoursUntilReset: Math.max(0, (Date.parse(window.resetsAt) - nowMs) / MS_PER_HOUR3) };
|
|
9109
9420
|
}
|
|
9110
9421
|
function quotaFactsOf(unified, nowMs) {
|
|
9111
9422
|
const fiveHour = windowFacts(unified?.fiveHour, nowMs);
|
|
@@ -9113,19 +9424,16 @@ function quotaFactsOf(unified, nowMs) {
|
|
|
9113
9424
|
const extraUsage = windowFacts(unified === void 0 ? void 0 : soleOverageWindow(unified), nowMs);
|
|
9114
9425
|
return { ...fiveHour === void 0 ? {} : { fiveHour }, ...sevenDay === void 0 ? {} : { sevenDay }, ...extraUsage === void 0 ? {} : { extraUsage } };
|
|
9115
9426
|
}
|
|
9116
|
-
var
|
|
9427
|
+
var MS_PER_HOUR3;
|
|
9117
9428
|
var init_quotaFacts = __esm({
|
|
9118
9429
|
"src/usage/quotaFacts.ts"() {
|
|
9119
9430
|
"use strict";
|
|
9120
9431
|
init_rateLimit();
|
|
9121
|
-
|
|
9432
|
+
MS_PER_HOUR3 = 36e5;
|
|
9122
9433
|
}
|
|
9123
9434
|
});
|
|
9124
9435
|
|
|
9125
9436
|
// src/usage/pick.ts
|
|
9126
|
-
function unifiedOf(state) {
|
|
9127
|
-
return state?.rateLimit?.unified;
|
|
9128
|
-
}
|
|
9129
9437
|
function limitBlockedUntil(state, nowMs) {
|
|
9130
9438
|
const limit = state?.lastLimit;
|
|
9131
9439
|
if (state === void 0 || limit === void 0) {
|
|
@@ -9215,6 +9523,10 @@ function assessRefusedNested(member, nested, nowMs) {
|
|
|
9215
9523
|
};
|
|
9216
9524
|
}
|
|
9217
9525
|
function assess(member, nowMs) {
|
|
9526
|
+
const assessment = assessMember(member, nowMs);
|
|
9527
|
+
return member.provider === void 0 ? assessment : { ...assessment, candidate: { ...assessment.candidate, provider: member.provider } };
|
|
9528
|
+
}
|
|
9529
|
+
function assessMember(member, nowMs) {
|
|
9218
9530
|
if (member.sameLoginAs !== void 0) {
|
|
9219
9531
|
return { candidate: { identity: member.identity, class: "ineligible", plan: planOf(member.account), reasons: [`same login as ${member.sameLoginAs}`] } };
|
|
9220
9532
|
}
|
|
@@ -9228,22 +9540,43 @@ function assess(member, nowMs) {
|
|
|
9228
9540
|
const assessment = assessIdentity(member, nowMs);
|
|
9229
9541
|
return { ...assessment, candidate: { ...assessment.candidate, reasons: [`picked by pool "${nested.pool}"`, ...nested.reasons] } };
|
|
9230
9542
|
}
|
|
9543
|
+
function sliceOf(member) {
|
|
9544
|
+
return member.snapshot?.providers[member.provider ?? ANTHROPIC_PROVIDER];
|
|
9545
|
+
}
|
|
9546
|
+
function assessProviderWithoutWindows(member, provider, state, base, planReasons, nowMs) {
|
|
9547
|
+
const blockedUntil = limitBlockedUntil(state, nowMs);
|
|
9548
|
+
if (blockedUntil !== void 0) {
|
|
9549
|
+
return { candidate: { ...base, class: "ineligible", blockedUntilMs: blockedUntil, reasons: [`refused until ${new Date(blockedUntil).toISOString()} (in ${formatAge(blockedUntil - nowMs)})`, ...planReasons] } };
|
|
9550
|
+
}
|
|
9551
|
+
if (base.plan.kind === "pay-per-use") {
|
|
9552
|
+
return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, `provider ${provider} reports no plan windows, so its spend is not tracked`] } };
|
|
9553
|
+
}
|
|
9554
|
+
const why = state === void 0 ? `no usage recorded for provider ${provider} yet, so its quota is unknown` : `provider ${provider} reports no plan windows, so its quota is unknown`;
|
|
9555
|
+
return { candidate: { ...base, class: "unknown", reasons: [why, ...planReasons] } };
|
|
9556
|
+
}
|
|
9231
9557
|
function assessIdentity(member, nowMs) {
|
|
9232
|
-
const
|
|
9558
|
+
const state = sliceOf(member);
|
|
9559
|
+
const plan = member.provider === void 0 ? planOf(member.account) : planOfProviderQuota(state?.quota);
|
|
9233
9560
|
const planReasons = plan.kind === "pay-per-use" ? ["billed by use (no plan allowance)"] : plan.recognised ? [`${String(plan.capacity)}x plan`] : [`plan tier ${plan.tier === void 0 ? "not known" : `"${plan.tier}" not recognised`}, counted as 1x`];
|
|
9234
9561
|
const base = { identity: member.identity, plan };
|
|
9235
9562
|
if (member.readError !== void 0) {
|
|
9236
9563
|
return { candidate: { ...base, class: "unknown", reasons: [`usage state unreadable: ${member.readError}`, ...planReasons] } };
|
|
9237
9564
|
}
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9565
|
+
if (member.providerError !== void 0) {
|
|
9566
|
+
return { candidate: { ...base, class: "unknown", reasons: [`provider configuration unreadable: ${member.providerError}`, ...planReasons] } };
|
|
9567
|
+
}
|
|
9568
|
+
const windows = rankingWindowsOf(member.provider, state);
|
|
9569
|
+
if (member.snapshot === void 0 || state === void 0 || windows === void 0) {
|
|
9570
|
+
if (member.provider !== void 0) {
|
|
9571
|
+
return assessProviderWithoutWindows(member, member.provider, state, base, planReasons, nowMs);
|
|
9572
|
+
}
|
|
9241
9573
|
if (plan.kind === "pay-per-use") {
|
|
9242
9574
|
return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, "no usage recorded yet, so its spend is not tracked (turn on trackUsage for it)"] } };
|
|
9243
9575
|
}
|
|
9244
9576
|
return { candidate: { ...base, class: "unknown", reasons: ["no usage recorded yet, so its quota is unknown (turn on trackUsage for it)", ...planReasons] } };
|
|
9245
9577
|
}
|
|
9246
|
-
const
|
|
9578
|
+
const { unified } = windows;
|
|
9579
|
+
const observedAgo = ` (last seen ${formatAge(nowMs - Date.parse(windows.observedAt))} ago)`;
|
|
9247
9580
|
const fiveHourWindow = unified.fiveHour;
|
|
9248
9581
|
const sevenDayWindow = unified.sevenDay;
|
|
9249
9582
|
const five = fiveHourWindow === void 0 ? void 0 : effectiveWindow(fiveHourWindow, nowMs);
|
|
@@ -9255,6 +9588,15 @@ function assessIdentity(member, nowMs) {
|
|
|
9255
9588
|
const overageWindow = soleOverageWindow(unified);
|
|
9256
9589
|
const overage = overageWindow === void 0 ? void 0 : effectiveWindow(overageWindow, nowMs);
|
|
9257
9590
|
const overageReasons = overageWindow === void 0 || overage === void 0 ? [] : [describeWindow("extra usage", overageWindow, overage, nowMs)];
|
|
9591
|
+
if (member.provider !== void 0) {
|
|
9592
|
+
const spent = [
|
|
9593
|
+
{ name: "5h", window: five },
|
|
9594
|
+
{ name: "7d", window: seven }
|
|
9595
|
+
].filter(({ window }) => window?.status === "rejected" && window.resetsAtMs === void 0).map(({ name }) => name);
|
|
9596
|
+
if (spent.length > 0) {
|
|
9597
|
+
return { candidate: { ...base, class: "ineligible", reasons: [`provider ${member.provider} ${spent.join(" and ")} window used in full with no reset time reported, so it is refused until it reports one`, ...windowReasons, ...planReasons] } };
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9258
9600
|
const blockedUntil = Math.max(
|
|
9259
9601
|
windowBlockedUntil([five, seven, overage].flatMap((window) => window === void 0 ? [] : [window])) ?? 0,
|
|
9260
9602
|
limitBlockedUntil(state, nowMs) ?? 0
|
|
@@ -9275,11 +9617,11 @@ function assessIdentity(member, nowMs) {
|
|
|
9275
9617
|
}
|
|
9276
9618
|
const remaining = Math.max(0, 1 - basis.window.utilization);
|
|
9277
9619
|
const untilResetMs = basis.window.resetsAtMs === void 0 ? basis.windowMs : Math.max(basis.window.resetsAtMs - nowMs, MS_PER_SECOND5);
|
|
9278
|
-
const weeklyScore = remaining * plan.capacity / (untilResetMs /
|
|
9620
|
+
const weeklyScore = remaining * plan.capacity / (untilResetMs / MS_PER_HOUR4);
|
|
9279
9621
|
const fiveRemaining = five?.utilization === void 0 ? void 0 : Math.max(0, 1 - five.utilization);
|
|
9280
9622
|
const fiveUntil = five?.resetsAtMs === void 0 ? FIVE_HOUR_WINDOW_MS : Math.max(five.resetsAtMs - nowMs, MS_PER_SECOND5);
|
|
9281
9623
|
const ratio = windowRatio(member.records);
|
|
9282
|
-
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil /
|
|
9624
|
+
const fiveHourScore = basis.name === "sevenDay" && fiveRemaining !== void 0 && ratio !== void 0 ? Math.min(fiveRemaining * ratio, remaining) * plan.capacity / (fiveUntil / MS_PER_HOUR4) : void 0;
|
|
9283
9625
|
const fiveHourLeads = fiveHourScore !== void 0 && fiveHourScore > weeklyScore;
|
|
9284
9626
|
const score = fiveHourLeads ? fiveHourScore : weeklyScore;
|
|
9285
9627
|
const scoreWindow = fiveHourLeads ? "fiveHour" : basis.name;
|
|
@@ -9297,15 +9639,15 @@ function assessIdentity(member, nowMs) {
|
|
|
9297
9639
|
};
|
|
9298
9640
|
}
|
|
9299
9641
|
function poolFactsOf(member, nowMs, resuming, sticky) {
|
|
9300
|
-
const { fiveHour, sevenDay, extraUsage } = quotaFactsOf(member.
|
|
9642
|
+
const { fiveHour, sevenDay, extraUsage } = quotaFactsOf(rankingWindowsOf(member.provider, sliceOf(member))?.unified, nowMs);
|
|
9301
9643
|
const burn = windowBurn(member.records, "fiveHour");
|
|
9302
9644
|
return {
|
|
9303
9645
|
...fiveHour === void 0 ? {} : { fiveHour },
|
|
9304
9646
|
...sevenDay === void 0 ? {} : { sevenDay },
|
|
9305
9647
|
...extraUsage === void 0 ? {} : { extraUsage },
|
|
9306
|
-
...burn === void 0 ? {} : { burnPerHour: burn *
|
|
9648
|
+
...burn === void 0 ? {} : { burnPerHour: burn * MS_PER_HOUR4 },
|
|
9307
9649
|
resuming,
|
|
9308
|
-
...sticky?.identity === member.identity ? { lastPickHoursAgo: Math.max(0, (nowMs - Date.parse(sticky.at)) /
|
|
9650
|
+
...sticky?.identity === member.identity ? { lastPickHoursAgo: Math.max(0, (nowMs - Date.parse(sticky.at)) / MS_PER_HOUR4) } : {}
|
|
9309
9651
|
};
|
|
9310
9652
|
}
|
|
9311
9653
|
function rankPool(input) {
|
|
@@ -9400,7 +9742,7 @@ function rankPool(input) {
|
|
|
9400
9742
|
...holdForReturn === void 0 ? {} : { holdForReturn }
|
|
9401
9743
|
};
|
|
9402
9744
|
}
|
|
9403
|
-
var MS_PER_SECOND5,
|
|
9745
|
+
var MS_PER_SECOND5, MS_PER_HOUR4, PROMPT_CACHE_TTL_HOURS, PROMPT_CACHE_TTL_MS, CLASS_ORDER;
|
|
9404
9746
|
var init_pick = __esm({
|
|
9405
9747
|
"src/usage/pick.ts"() {
|
|
9406
9748
|
"use strict";
|
|
@@ -9409,17 +9751,14 @@ var init_pick = __esm({
|
|
|
9409
9751
|
init_plan2();
|
|
9410
9752
|
init_middleware();
|
|
9411
9753
|
init_preflight();
|
|
9754
|
+
init_providerWindows();
|
|
9412
9755
|
init_quotaFacts();
|
|
9756
|
+
init_windowLengths();
|
|
9413
9757
|
init_rateLimit();
|
|
9414
9758
|
MS_PER_SECOND5 = 1e3;
|
|
9415
|
-
|
|
9416
|
-
HOURS_PER_DAY3 = 24;
|
|
9417
|
-
FIVE_HOURS = 5;
|
|
9759
|
+
MS_PER_HOUR4 = 36e5;
|
|
9418
9760
|
PROMPT_CACHE_TTL_HOURS = 1;
|
|
9419
|
-
|
|
9420
|
-
FIVE_HOUR_WINDOW_MS = FIVE_HOURS * MS_PER_HOUR3;
|
|
9421
|
-
SEVEN_DAY_WINDOW_MS = SEVEN_DAYS * HOURS_PER_DAY3 * MS_PER_HOUR3;
|
|
9422
|
-
PROMPT_CACHE_TTL_MS = PROMPT_CACHE_TTL_HOURS * MS_PER_HOUR3;
|
|
9761
|
+
PROMPT_CACHE_TTL_MS = PROMPT_CACHE_TTL_HOURS * MS_PER_HOUR4;
|
|
9423
9762
|
CLASS_ORDER = { scored: 0, unknown: 1, "pay-per-use": 2, ineligible: 3 };
|
|
9424
9763
|
}
|
|
9425
9764
|
});
|
|
@@ -9554,7 +9893,7 @@ var init_store2 = __esm({
|
|
|
9554
9893
|
function errorMessage(error) {
|
|
9555
9894
|
return error instanceof Error ? error.message : String(error);
|
|
9556
9895
|
}
|
|
9557
|
-
function loadPoolMembers(fs17, paths, identities, nowMs, idOf) {
|
|
9896
|
+
function loadPoolMembers(fs17, paths, identities, nowMs, idOf, providerOf) {
|
|
9558
9897
|
const windowStartMs = nowMs - FIVE_HOUR_WINDOW_MS;
|
|
9559
9898
|
const log = readUsageLog(fs17, paths.usageLogDir, { sinceMs: windowStartMs });
|
|
9560
9899
|
return identities.map((identity) => {
|
|
@@ -9562,14 +9901,20 @@ function loadPoolMembers(fs17, paths, identities, nowMs, idOf) {
|
|
|
9562
9901
|
if (id === void 0) {
|
|
9563
9902
|
return { identity, records: [] };
|
|
9564
9903
|
}
|
|
9565
|
-
const
|
|
9904
|
+
const resolved = providerOf?.(identity);
|
|
9905
|
+
const provider = typeof resolved === "object" ? resolved.named : resolved;
|
|
9906
|
+
const providerField = {
|
|
9907
|
+
...provider === void 0 ? {} : { provider },
|
|
9908
|
+
...typeof resolved === "object" ? { providerError: resolved.reason } : {}
|
|
9909
|
+
};
|
|
9910
|
+
const records = log.records.filter((record) => record.identity === id && record.provider === (provider ?? ANTHROPIC_PROVIDER) && Date.parse(record.at) >= windowStartMs);
|
|
9566
9911
|
try {
|
|
9567
9912
|
const snapshot = readUsageSnapshot(fs17, paths.usageSnapshotsDir, id);
|
|
9568
9913
|
const account = readAccountMetadata(fs17, paths.identitiesDir, id) ?? snapshot?.account;
|
|
9569
|
-
return { identity, records, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
|
|
9914
|
+
return { identity, records, ...providerField, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
|
|
9570
9915
|
} catch (error) {
|
|
9571
9916
|
if (error instanceof UsageSnapshotError || error instanceof AccountMetadataError) {
|
|
9572
|
-
return { identity, records, readError: errorMessage(error) };
|
|
9917
|
+
return { identity, records, ...providerField, readError: errorMessage(error) };
|
|
9573
9918
|
}
|
|
9574
9919
|
throw error;
|
|
9575
9920
|
}
|
|
@@ -9579,7 +9924,7 @@ function snapshotAgeKey(member) {
|
|
|
9579
9924
|
return member.snapshot === void 0 ? Number.NEGATIVE_INFINITY : Date.parse(member.snapshot.updatedAt);
|
|
9580
9925
|
}
|
|
9581
9926
|
function collapseSharedLogins(members) {
|
|
9582
|
-
const groups = groupSharedLogins(members, (member) => member.nested === void 0 && member.account !== void 0 ? loginKeyOf(member.account) : void 0);
|
|
9927
|
+
const groups = groupSharedLogins(members, (member) => member.nested === void 0 && member.provider === void 0 && member.account !== void 0 ? loginKeyOf(member.account) : void 0);
|
|
9583
9928
|
const representativeOf = /* @__PURE__ */ new Map();
|
|
9584
9929
|
for (const group of groups) {
|
|
9585
9930
|
const representative = group.reduce((freshest, member) => snapshotAgeKey(member) > snapshotAgeKey(freshest) ? member : freshest);
|
|
@@ -9609,7 +9954,7 @@ function rankNamedPool(input, poolName, stack, sticky) {
|
|
|
9609
9954
|
const childStack = [...stack, poolName];
|
|
9610
9955
|
const direct = pool.identities.filter((entry) => poolNameOf(poolMemberIdentity(entry)) === void 0);
|
|
9611
9956
|
const missing = direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) === void 0).map((entry) => ({ pool: poolName, identity: poolMemberIdentity(entry) }));
|
|
9612
|
-
const loaded = new Map(loadPoolMembers(input.fs, input.paths, direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) !== void 0).map(poolMemberIdentity), input.nowMs, input.identityIdOf).map((member) => [member.identity, member]));
|
|
9957
|
+
const loaded = new Map(loadPoolMembers(input.fs, input.paths, direct.filter((entry) => input.identityIdOf(poolMemberIdentity(entry)) !== void 0).map(poolMemberIdentity), input.nowMs, input.identityIdOf, input.providerOf).map((member) => [member.identity, member]));
|
|
9613
9958
|
const members = [];
|
|
9614
9959
|
for (const entry of pool.identities) {
|
|
9615
9960
|
const nestedName = poolNameOf(poolMemberIdentity(entry));
|
|
@@ -9650,7 +9995,7 @@ function nestedMember(input, nestedName, childStack, sticky) {
|
|
|
9650
9995
|
const nested = rankNamedPool(input, nestedName, childStack, sticky);
|
|
9651
9996
|
const pick = nested.ranking.pick;
|
|
9652
9997
|
if (pick !== void 0) {
|
|
9653
|
-
const [member] = loadPoolMembers(input.fs, input.paths, [pick.identity], input.nowMs, input.identityIdOf);
|
|
9998
|
+
const [member] = loadPoolMembers(input.fs, input.paths, [pick.identity], input.nowMs, input.identityIdOf, input.providerOf);
|
|
9654
9999
|
return { member: { ...member ?? { identity: pick.identity, records: [] }, nested: { kind: "pick", pool: nestedName, reasons: pick.reasons } }, missing: nested.missing };
|
|
9655
10000
|
}
|
|
9656
10001
|
const earliestReturn = nested.ranking.earliestReturn;
|
|
@@ -9732,12 +10077,12 @@ function recordStickyPick(fs17, picksFile, directory, identity, nowMs) {
|
|
|
9732
10077
|
fs17.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
|
|
9733
10078
|
`);
|
|
9734
10079
|
}
|
|
9735
|
-
var import_node_path26,
|
|
10080
|
+
var import_node_path26, import_zod19, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
|
|
9736
10081
|
var init_poolPick = __esm({
|
|
9737
10082
|
"src/usage/poolPick.ts"() {
|
|
9738
10083
|
"use strict";
|
|
9739
10084
|
import_node_path26 = __toESM(require("node:path"), 1);
|
|
9740
|
-
|
|
10085
|
+
import_zod19 = require("zod");
|
|
9741
10086
|
init_cliError();
|
|
9742
10087
|
init_identity();
|
|
9743
10088
|
init_schema();
|
|
@@ -9747,6 +10092,7 @@ var init_poolPick = __esm({
|
|
|
9747
10092
|
init_read();
|
|
9748
10093
|
init_middleware();
|
|
9749
10094
|
init_store2();
|
|
10095
|
+
init_windowLengths();
|
|
9750
10096
|
PoolGraphError = class extends CliError {
|
|
9751
10097
|
constructor(message) {
|
|
9752
10098
|
super(message);
|
|
@@ -9754,17 +10100,17 @@ var init_poolPick = __esm({
|
|
|
9754
10100
|
}
|
|
9755
10101
|
};
|
|
9756
10102
|
SCHEMA_VERSION = 1;
|
|
9757
|
-
PickEntrySchema =
|
|
9758
|
-
PicksFileSchema =
|
|
9759
|
-
schemaVersion:
|
|
9760
|
-
picks:
|
|
10103
|
+
PickEntrySchema = import_zod19.z.strictObject({ identity: import_zod19.z.string().min(1), at: import_zod19.z.iso.datetime() });
|
|
10104
|
+
PicksFileSchema = import_zod19.z.strictObject({
|
|
10105
|
+
schemaVersion: import_zod19.z.literal(SCHEMA_VERSION),
|
|
10106
|
+
picks: import_zod19.z.record(import_zod19.z.string().min(1), PickEntrySchema)
|
|
9761
10107
|
});
|
|
9762
10108
|
}
|
|
9763
10109
|
});
|
|
9764
10110
|
|
|
9765
10111
|
// src/identityRenameJournal.ts
|
|
9766
10112
|
function renamePairFileName(from, to, suffix) {
|
|
9767
|
-
return `${(0,
|
|
10113
|
+
return `${(0, import_node_crypto13.createHash)("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
9768
10114
|
}
|
|
9769
10115
|
function readRenameJournal(fs17, file) {
|
|
9770
10116
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -9835,28 +10181,28 @@ function requireNameFreeOfUnfinishedRename(fs17, directory, name, action, sameNa
|
|
|
9835
10181
|
throw new NameHeldByUnfinishedRenameError(action, name, held, finishabilityOf(held, exists));
|
|
9836
10182
|
}
|
|
9837
10183
|
}
|
|
9838
|
-
var
|
|
10184
|
+
var import_node_crypto13, import_node_path27, import_zod20, RenameJournalSchema, FILE_NAME_HASH_DIGITS, JOURNAL_SUFFIX, RenameJournalUnreadableError, NameHeldByUnfinishedRenameError;
|
|
9839
10185
|
var init_identityRenameJournal = __esm({
|
|
9840
10186
|
"src/identityRenameJournal.ts"() {
|
|
9841
10187
|
"use strict";
|
|
9842
|
-
|
|
10188
|
+
import_node_crypto13 = require("node:crypto");
|
|
9843
10189
|
import_node_path27 = __toESM(require("node:path"), 1);
|
|
9844
|
-
|
|
10190
|
+
import_zod20 = require("zod");
|
|
9845
10191
|
init_cliError();
|
|
9846
|
-
RenameJournalSchema =
|
|
9847
|
-
version:
|
|
9848
|
-
from:
|
|
9849
|
-
to:
|
|
9850
|
-
startedAt:
|
|
10192
|
+
RenameJournalSchema = import_zod20.z.strictObject({
|
|
10193
|
+
version: import_zod20.z.literal(1),
|
|
10194
|
+
from: import_zod20.z.string().min(1),
|
|
10195
|
+
to: import_zod20.z.string().min(1),
|
|
10196
|
+
startedAt: import_zod20.z.iso.datetime(),
|
|
9851
10197
|
/** The process that began the rename, for a person reading the file. Whether it is still running is told by the locks, not by this. */
|
|
9852
|
-
pid:
|
|
9853
|
-
steps:
|
|
9854
|
-
|
|
9855
|
-
description:
|
|
10198
|
+
pid: import_zod20.z.number().int().positive(),
|
|
10199
|
+
steps: import_zod20.z.array(
|
|
10200
|
+
import_zod20.z.strictObject({
|
|
10201
|
+
description: import_zod20.z.string().min(1),
|
|
9856
10202
|
/** Whether the step has been applied and marked so. */
|
|
9857
|
-
done:
|
|
10203
|
+
done: import_zod20.z.boolean(),
|
|
9858
10204
|
/** Whether the step was begun: written ahead of the step, before it runs, so a process that dies after the step took effect and before `done` was written still leaves a record that it may have. */
|
|
9859
|
-
started:
|
|
10205
|
+
started: import_zod20.z.boolean()
|
|
9860
10206
|
})
|
|
9861
10207
|
)
|
|
9862
10208
|
});
|
|
@@ -9961,13 +10307,13 @@ function requireNoInterruptedNameRename(paths, name, action, except) {
|
|
|
9961
10307
|
throw new InterruptedNameRenameError(action, describeInterruptedNameRename(paths, held));
|
|
9962
10308
|
}
|
|
9963
10309
|
}
|
|
9964
|
-
var import_node_fs7, import_node_path28,
|
|
10310
|
+
var import_node_fs7, import_node_path28, import_zod21, NameRenameRecordSchema, RECORD_SUFFIX, InterruptedNameRenameError;
|
|
9965
10311
|
var init_identityNameRenameRecord = __esm({
|
|
9966
10312
|
"src/identityNameRenameRecord.ts"() {
|
|
9967
10313
|
"use strict";
|
|
9968
10314
|
import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
9969
10315
|
import_node_path28 = __toESM(require("node:path"), 1);
|
|
9970
|
-
|
|
10316
|
+
import_zod21 = require("zod");
|
|
9971
10317
|
init_cliError();
|
|
9972
10318
|
init_configProfilesStore();
|
|
9973
10319
|
init_directoryRulesStore();
|
|
@@ -9977,12 +10323,12 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9977
10323
|
init_poolPick();
|
|
9978
10324
|
init_identityRecords();
|
|
9979
10325
|
init_identityRenameJournal();
|
|
9980
|
-
NameRenameRecordSchema =
|
|
9981
|
-
version:
|
|
9982
|
-
id:
|
|
9983
|
-
from:
|
|
9984
|
-
to:
|
|
9985
|
-
startedAt:
|
|
10326
|
+
NameRenameRecordSchema = import_zod21.z.strictObject({
|
|
10327
|
+
version: import_zod21.z.literal(1),
|
|
10328
|
+
id: import_zod21.z.string().min(1),
|
|
10329
|
+
from: import_zod21.z.string().min(1),
|
|
10330
|
+
to: import_zod21.z.string().min(1),
|
|
10331
|
+
startedAt: import_zod21.z.iso.datetime()
|
|
9986
10332
|
});
|
|
9987
10333
|
RECORD_SUFFIX = ".json";
|
|
9988
10334
|
InterruptedNameRenameError = class extends CliError {
|
|
@@ -9996,7 +10342,7 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9996
10342
|
|
|
9997
10343
|
// src/launcher/launchRecords.ts
|
|
9998
10344
|
function recordFile(directory, pid) {
|
|
9999
|
-
return import_node_path29.default.join(directory, `${String(pid)}.${(0,
|
|
10345
|
+
return import_node_path29.default.join(directory, `${String(pid)}.${(0, import_node_crypto14.randomUUID)()}${RECORD_SUFFIX2}`);
|
|
10000
10346
|
}
|
|
10001
10347
|
function readRecord(fs17, directory, name) {
|
|
10002
10348
|
if (!name.endsWith(RECORD_SUFFIX2)) {
|
|
@@ -10037,18 +10383,18 @@ function liveLaunchesOn(fs17, directory, identity, isRunning) {
|
|
|
10037
10383
|
return record?.identity === identity && isRunning(record.pid) ? [record.pid] : [];
|
|
10038
10384
|
}).sort((left, right) => left - right);
|
|
10039
10385
|
}
|
|
10040
|
-
var import_node_path29,
|
|
10386
|
+
var import_node_path29, import_node_crypto14, import_zod22, LaunchRecordSchema, RECORD_SUFFIX2;
|
|
10041
10387
|
var init_launchRecords = __esm({
|
|
10042
10388
|
"src/launcher/launchRecords.ts"() {
|
|
10043
10389
|
"use strict";
|
|
10044
10390
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
LaunchRecordSchema =
|
|
10391
|
+
import_node_crypto14 = require("node:crypto");
|
|
10392
|
+
import_zod22 = require("zod");
|
|
10393
|
+
LaunchRecordSchema = import_zod22.z.strictObject({
|
|
10048
10394
|
/** The launcher's process id, which is what tells a launch in progress from a record a crashed launcher left behind. */
|
|
10049
|
-
pid:
|
|
10050
|
-
identity:
|
|
10051
|
-
startedAt:
|
|
10395
|
+
pid: import_zod22.z.number().int().positive(),
|
|
10396
|
+
identity: import_zod22.z.string().min(1),
|
|
10397
|
+
startedAt: import_zod22.z.iso.datetime()
|
|
10052
10398
|
});
|
|
10053
10399
|
RECORD_SUFFIX2 = ".json";
|
|
10054
10400
|
}
|
|
@@ -10519,7 +10865,7 @@ var init_package = __esm({
|
|
|
10519
10865
|
"package.json"() {
|
|
10520
10866
|
package_default = {
|
|
10521
10867
|
name: "claude-use",
|
|
10522
|
-
version: "12.
|
|
10868
|
+
version: "12.1.0",
|
|
10523
10869
|
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.",
|
|
10524
10870
|
license: "MIT",
|
|
10525
10871
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10779,93 +11125,6 @@ var init_cascade = __esm({
|
|
|
10779
11125
|
}
|
|
10780
11126
|
});
|
|
10781
11127
|
|
|
10782
|
-
// src/paths.ts
|
|
10783
|
-
function resolveAgentShimHome(env = process.env, home = import_node_os4.default.homedir(), isDirectory = isExistingDirectory) {
|
|
10784
|
-
const fromEnv = env.AGENT_SHIM_HOME;
|
|
10785
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
10786
|
-
return fromEnv;
|
|
10787
|
-
}
|
|
10788
|
-
const current = import_node_path36.default.join(home, HOME_DIRNAME);
|
|
10789
|
-
const legacy = import_node_path36.default.join(home, LEGACY_HOME_DIRNAME);
|
|
10790
|
-
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
10791
|
-
}
|
|
10792
|
-
function isExistingDirectory(candidate) {
|
|
10793
|
-
return import_node_fs9.default.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
10794
|
-
}
|
|
10795
|
-
function resolveClaudeHome() {
|
|
10796
|
-
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
10797
|
-
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
10798
|
-
return fromEnv;
|
|
10799
|
-
}
|
|
10800
|
-
return import_node_path36.default.join(import_node_os4.default.homedir(), ".claude");
|
|
10801
|
-
}
|
|
10802
|
-
function buildLayoutPaths(root) {
|
|
10803
|
-
return {
|
|
10804
|
-
root,
|
|
10805
|
-
identitiesDir: import_node_path36.default.join(root, "identities"),
|
|
10806
|
-
configProfilesDir: import_node_path36.default.join(root, "config-profiles"),
|
|
10807
|
-
providersDir: import_node_path36.default.join(root, "providers"),
|
|
10808
|
-
providerAliasesFile: import_node_path36.default.join(root, "provider-aliases.json"),
|
|
10809
|
-
directoryRulesFile: import_node_path36.default.join(root, "directory-rules.json"),
|
|
10810
|
-
activeIdentityFile: import_node_path36.default.join(root, "active-identity"),
|
|
10811
|
-
globalConfigFile: import_node_path36.default.join(root, "config.json"),
|
|
10812
|
-
categoriesLocalFile: import_node_path36.default.join(root, "categories.local.json"),
|
|
10813
|
-
claudeShimFile: import_node_path36.default.join(root, "claude-shim.json"),
|
|
10814
|
-
headroomDir: import_node_path36.default.join(root, "headroom"),
|
|
10815
|
-
headroomStateFile: import_node_path36.default.join(root, "headroom", "state.json"),
|
|
10816
|
-
headroomRoutingFile: import_node_path36.default.join(root, "headroom", "routing.json"),
|
|
10817
|
-
headroomLegacyStateFile: import_node_path36.default.join(root, "headroom", "state.v2.json"),
|
|
10818
|
-
headroomAllowlistFile: import_node_path36.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
10819
|
-
headroomSocketDir: import_node_path36.default.join(root, "headroom", "run"),
|
|
10820
|
-
headroomLockFile: import_node_path36.default.join(root, "headroom", "start.lock"),
|
|
10821
|
-
headroomSessionsDir: import_node_path36.default.join(root, "headroom", "sessions"),
|
|
10822
|
-
logsDir: import_node_path36.default.join(root, "logs"),
|
|
10823
|
-
headroomLogPath: import_node_path36.default.join(root, "logs", "headroom.log"),
|
|
10824
|
-
frontdoorDir: import_node_path36.default.join(root, "frontdoor"),
|
|
10825
|
-
frontdoorCaDir: import_node_path36.default.join(root, "frontdoor", "ca"),
|
|
10826
|
-
frontdoorCaCertFile: import_node_path36.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
10827
|
-
frontdoorCaKeyFile: import_node_path36.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
10828
|
-
frontdoorCaBundlesDir: import_node_path36.default.join(root, "frontdoor", "ca", "bundles"),
|
|
10829
|
-
chatgptSignInFile: import_node_path36.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
10830
|
-
frontdoorStateFile: import_node_path36.default.join(root, "frontdoor", "state.json"),
|
|
10831
|
-
frontdoorLockFile: import_node_path36.default.join(root, "frontdoor", "start.lock"),
|
|
10832
|
-
frontdoorControlTokenFile: import_node_path36.default.join(root, "frontdoor", "control-token"),
|
|
10833
|
-
frontdoorSessionsDir: import_node_path36.default.join(root, "frontdoor", "sessions"),
|
|
10834
|
-
frontdoorDirectRecordsDir: import_node_path36.default.join(root, "frontdoor", "direct"),
|
|
10835
|
-
frontdoorDrainingDir: import_node_path36.default.join(root, "frontdoor", "draining"),
|
|
10836
|
-
frontdoorRcCredentialsDir: import_node_path36.default.join(root, "frontdoor", "rc-credentials"),
|
|
10837
|
-
frontdoorLogPath: import_node_path36.default.join(root, "logs", "frontdoor.log"),
|
|
10838
|
-
usageDir: import_node_path36.default.join(root, "usage"),
|
|
10839
|
-
usageLogDir: import_node_path36.default.join(root, "usage", "log"),
|
|
10840
|
-
usageSnapshotsDir: import_node_path36.default.join(root, "usage", "snapshots"),
|
|
10841
|
-
statuslineDir: import_node_path36.default.join(root, "statusline"),
|
|
10842
|
-
catalogueDir: import_node_path36.default.join(root, "catalogues"),
|
|
10843
|
-
usagePicksFile: import_node_path36.default.join(root, "usage", "picks.json"),
|
|
10844
|
-
usageAnchorsFile: import_node_path36.default.join(root, "usage", "anchors.json"),
|
|
10845
|
-
usageJobsFile: import_node_path36.default.join(root, "usage", "jobs.json"),
|
|
10846
|
-
jobLogsDir: import_node_path36.default.join(root, "logs", "jobs"),
|
|
10847
|
-
identityRenamesDir: import_node_path36.default.join(root, "identity-renames"),
|
|
10848
|
-
identityNameRenamesDir: import_node_path36.default.join(root, "identity-name-renames"),
|
|
10849
|
-
launchesDir: import_node_path36.default.join(root, "launches"),
|
|
10850
|
-
superviseDir: import_node_path36.default.join(root, "supervise"),
|
|
10851
|
-
modelMovesDir: import_node_path36.default.join(root, "model-moves"),
|
|
10852
|
-
mcpPermissionsFile: import_node_path36.default.join(root, "mcp", "permissions.json")
|
|
10853
|
-
};
|
|
10854
|
-
}
|
|
10855
|
-
function resolveLayoutPaths() {
|
|
10856
|
-
return buildLayoutPaths(resolveAgentShimHome());
|
|
10857
|
-
}
|
|
10858
|
-
var import_node_fs9, import_node_os4, import_node_path36;
|
|
10859
|
-
var init_paths = __esm({
|
|
10860
|
-
"src/paths.ts"() {
|
|
10861
|
-
"use strict";
|
|
10862
|
-
import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
10863
|
-
import_node_os4 = __toESM(require("node:os"), 1);
|
|
10864
|
-
import_node_path36 = __toESM(require("node:path"), 1);
|
|
10865
|
-
init_legacy();
|
|
10866
|
-
}
|
|
10867
|
-
});
|
|
10868
|
-
|
|
10869
11128
|
// src/providerAliases.ts
|
|
10870
11129
|
function parseAliases(file, raw) {
|
|
10871
11130
|
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
@@ -10898,15 +11157,15 @@ function aliasFindings(aliases, providerNames) {
|
|
|
10898
11157
|
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
10899
11158
|
});
|
|
10900
11159
|
}
|
|
10901
|
-
var
|
|
11160
|
+
var import_zod26, ProviderAliasesSchema;
|
|
10902
11161
|
var init_providerAliases = __esm({
|
|
10903
11162
|
"src/providerAliases.ts"() {
|
|
10904
11163
|
"use strict";
|
|
10905
|
-
|
|
11164
|
+
import_zod26 = require("zod");
|
|
10906
11165
|
init_cliError();
|
|
10907
11166
|
init_load();
|
|
10908
11167
|
init_store();
|
|
10909
|
-
ProviderAliasesSchema =
|
|
11168
|
+
ProviderAliasesSchema = import_zod26.z.record(import_zod26.z.string().min(1), import_zod26.z.string().min(1));
|
|
10910
11169
|
}
|
|
10911
11170
|
});
|
|
10912
11171
|
|
|
@@ -11122,7 +11381,7 @@ function providerJsonPath(paths, name) {
|
|
|
11122
11381
|
return providerFilePath(paths.providersDir, name);
|
|
11123
11382
|
}
|
|
11124
11383
|
function providerExists(paths, name) {
|
|
11125
|
-
return
|
|
11384
|
+
return import_node_fs9.default.existsSync(providerJsonPath(paths, name));
|
|
11126
11385
|
}
|
|
11127
11386
|
function requireProviderExists(paths, name) {
|
|
11128
11387
|
const canonical = canonicalProviderName(name, (candidate) => providerExists(paths, candidate), () => readProviderAliases(paths));
|
|
@@ -11179,12 +11438,12 @@ function parseProviderFile(filePath, raw) {
|
|
|
11179
11438
|
}
|
|
11180
11439
|
function readProvider(paths, name) {
|
|
11181
11440
|
const filePath = providerJsonPath(paths, name);
|
|
11182
|
-
if (!
|
|
11441
|
+
if (!import_node_fs9.default.existsSync(filePath)) {
|
|
11183
11442
|
return void 0;
|
|
11184
11443
|
}
|
|
11185
11444
|
let raw;
|
|
11186
11445
|
try {
|
|
11187
|
-
raw = JSON.parse(
|
|
11446
|
+
raw = JSON.parse(import_node_fs9.default.readFileSync(filePath, "utf8"));
|
|
11188
11447
|
} catch (error) {
|
|
11189
11448
|
throw error instanceof SyntaxError ? new ConfigFileNotJsonError(filePath) : error;
|
|
11190
11449
|
}
|
|
@@ -11200,7 +11459,7 @@ function reportInvalidProvider(name, message) {
|
|
|
11200
11459
|
}
|
|
11201
11460
|
function listProviders(paths, onInvalid = reportInvalidProvider) {
|
|
11202
11461
|
const names = listProviderNames(
|
|
11203
|
-
(dir) =>
|
|
11462
|
+
(dir) => import_node_fs9.default.readdirSync(dir),
|
|
11204
11463
|
paths.providersDir
|
|
11205
11464
|
);
|
|
11206
11465
|
const result = [];
|
|
@@ -11367,7 +11626,7 @@ function removeProvider(paths, name) {
|
|
|
11367
11626
|
if (!providerExists(paths, name)) {
|
|
11368
11627
|
throw new ProviderNotFoundError(name);
|
|
11369
11628
|
}
|
|
11370
|
-
|
|
11629
|
+
import_node_fs9.default.rmSync(providerJsonPath(paths, name));
|
|
11371
11630
|
createRealCredentialCache(paths.root).remove("file", `provider ${name}`);
|
|
11372
11631
|
}
|
|
11373
11632
|
function cascadeProviderName(cascade, identityProvider) {
|
|
@@ -11379,13 +11638,19 @@ function cascadeProviderName(cascade, identityProvider) {
|
|
|
11379
11638
|
}
|
|
11380
11639
|
return name ?? identityProvider;
|
|
11381
11640
|
}
|
|
11382
|
-
function
|
|
11641
|
+
function selectedProviderName(params) {
|
|
11383
11642
|
const cliName = params.cliProvider !== void 0 && params.cliProvider !== "" ? params.cliProvider : void 0;
|
|
11384
11643
|
const named = cliName ?? (params.cascade === void 0 ? params.identityProvider : cascadeProviderName(params.cascade, params.identityProvider));
|
|
11385
11644
|
if (named === void 0) {
|
|
11386
11645
|
return void 0;
|
|
11387
11646
|
}
|
|
11388
|
-
|
|
11647
|
+
return canonicalProviderName(named, (candidate) => loadProvider(params.paths.providersDir, candidate, params.port) !== void 0, () => loadProviderAliases(params.paths.providerAliasesFile, params.port));
|
|
11648
|
+
}
|
|
11649
|
+
function selectProvider(params) {
|
|
11650
|
+
const name = selectedProviderName(params);
|
|
11651
|
+
if (name === void 0) {
|
|
11652
|
+
return void 0;
|
|
11653
|
+
}
|
|
11389
11654
|
const definition = loadProvider(params.paths.providersDir, name, params.port);
|
|
11390
11655
|
if (definition === void 0) {
|
|
11391
11656
|
const known = listProviderNames(params.port.readdir, params.paths.providersDir);
|
|
@@ -11474,11 +11739,11 @@ function resolveRoutedProviderCredentials(params) {
|
|
|
11474
11739
|
}
|
|
11475
11740
|
return { ok: true, checked: [...providerNames].sort() };
|
|
11476
11741
|
}
|
|
11477
|
-
var
|
|
11742
|
+
var import_node_fs9, ProviderNotFoundError, ProviderAlreadyExistsError, LEGACY_PROVIDER_FIELDS, LEGACY_ENV_CREDENTIAL_KEYS, LEGACY_LITERAL_PLACEHOLDER, LegacyProviderFileError, ProviderKindMismatchError;
|
|
11478
11743
|
var init_providersStore = __esm({
|
|
11479
11744
|
"src/providersStore.ts"() {
|
|
11480
11745
|
"use strict";
|
|
11481
|
-
|
|
11746
|
+
import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
11482
11747
|
init_load();
|
|
11483
11748
|
init_store();
|
|
11484
11749
|
init_unrecognisedKeys();
|
|
@@ -11531,6 +11796,168 @@ var init_providersStore = __esm({
|
|
|
11531
11796
|
}
|
|
11532
11797
|
});
|
|
11533
11798
|
|
|
11799
|
+
// src/launcher/memberProvider.ts
|
|
11800
|
+
function unreadableFileReason(error) {
|
|
11801
|
+
if (error instanceof ConfigValidationError) {
|
|
11802
|
+
return `${error.filepath} is invalid`;
|
|
11803
|
+
}
|
|
11804
|
+
if (error instanceof ConfigFileNotJsonError) {
|
|
11805
|
+
return error.message.replace(/\.$/, "");
|
|
11806
|
+
}
|
|
11807
|
+
if (error instanceof LegacyProviderFileError) {
|
|
11808
|
+
return `${error.filePath} uses ${error.conversion.fields.join(", ")}, which a credential block replaced`;
|
|
11809
|
+
}
|
|
11810
|
+
return void 0;
|
|
11811
|
+
}
|
|
11812
|
+
function memberProviderResolver(params) {
|
|
11813
|
+
if (params.cliProvider === false) {
|
|
11814
|
+
return () => void 0;
|
|
11815
|
+
}
|
|
11816
|
+
const cliProvider = params.cliProvider;
|
|
11817
|
+
const identities = identityReader(params.paths.identitiesDir, params.fs);
|
|
11818
|
+
const cascades = /* @__PURE__ */ new Map();
|
|
11819
|
+
const cascadeOver = (baseConfigProfile) => {
|
|
11820
|
+
const cached = cascades.get(baseConfigProfile);
|
|
11821
|
+
if (cached !== void 0) {
|
|
11822
|
+
return cached;
|
|
11823
|
+
}
|
|
11824
|
+
const loaded = params.loadCascade(baseConfigProfile);
|
|
11825
|
+
cascades.set(baseConfigProfile, loaded);
|
|
11826
|
+
return loaded;
|
|
11827
|
+
};
|
|
11828
|
+
return (name) => {
|
|
11829
|
+
let declared;
|
|
11830
|
+
try {
|
|
11831
|
+
declared = identities.load(name);
|
|
11832
|
+
} catch (error) {
|
|
11833
|
+
if (!(error instanceof ConfigValidationError)) {
|
|
11834
|
+
throw error;
|
|
11835
|
+
}
|
|
11836
|
+
}
|
|
11837
|
+
const profile = decideConfigProfile({
|
|
11838
|
+
env: params.env,
|
|
11839
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
11840
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
11841
|
+
...declared?.defaultConfigProfile === void 0 ? {} : { identityDefaultConfigProfile: declared.defaultConfigProfile },
|
|
11842
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile }
|
|
11843
|
+
});
|
|
11844
|
+
const flagged = cliProvider !== void 0 && cliProvider !== "" ? cliProvider : void 0;
|
|
11845
|
+
let named = flagged ?? declared?.provider;
|
|
11846
|
+
try {
|
|
11847
|
+
const cascade = cascadeOver(profile.name);
|
|
11848
|
+
named = flagged ?? cascadeProviderName(cascade, declared?.provider);
|
|
11849
|
+
return selectedProviderName({
|
|
11850
|
+
paths: params.paths,
|
|
11851
|
+
port: params.fs,
|
|
11852
|
+
...cliProvider === void 0 ? {} : { cliProvider },
|
|
11853
|
+
cascade,
|
|
11854
|
+
...declared?.provider === void 0 ? {} : { identityProvider: declared.provider }
|
|
11855
|
+
});
|
|
11856
|
+
} catch (error) {
|
|
11857
|
+
const reason = unreadableFileReason(error);
|
|
11858
|
+
if (reason === void 0) {
|
|
11859
|
+
throw error;
|
|
11860
|
+
}
|
|
11861
|
+
return { ...named === void 0 ? {} : { named }, reason };
|
|
11862
|
+
}
|
|
11863
|
+
};
|
|
11864
|
+
}
|
|
11865
|
+
var init_memberProvider = __esm({
|
|
11866
|
+
"src/launcher/memberProvider.ts"() {
|
|
11867
|
+
"use strict";
|
|
11868
|
+
init_load();
|
|
11869
|
+
init_providersStore();
|
|
11870
|
+
init_identity();
|
|
11871
|
+
}
|
|
11872
|
+
});
|
|
11873
|
+
|
|
11874
|
+
// src/paths.ts
|
|
11875
|
+
function resolveAgentShimHome(env = process.env, home = import_node_os5.default.homedir(), isDirectory = isExistingDirectory) {
|
|
11876
|
+
const fromEnv = env.AGENT_SHIM_HOME;
|
|
11877
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11878
|
+
return fromEnv;
|
|
11879
|
+
}
|
|
11880
|
+
const current = import_node_path36.default.join(home, HOME_DIRNAME);
|
|
11881
|
+
const legacy = import_node_path36.default.join(home, LEGACY_HOME_DIRNAME);
|
|
11882
|
+
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
11883
|
+
}
|
|
11884
|
+
function isExistingDirectory(candidate) {
|
|
11885
|
+
return import_node_fs10.default.statSync(candidate, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
11886
|
+
}
|
|
11887
|
+
function resolveClaudeHome() {
|
|
11888
|
+
const fromEnv = process.env.AGENT_SHIM_CLAUDE_HOME;
|
|
11889
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
11890
|
+
return fromEnv;
|
|
11891
|
+
}
|
|
11892
|
+
return import_node_path36.default.join(import_node_os5.default.homedir(), ".claude");
|
|
11893
|
+
}
|
|
11894
|
+
function buildLayoutPaths(root) {
|
|
11895
|
+
return {
|
|
11896
|
+
root,
|
|
11897
|
+
identitiesDir: import_node_path36.default.join(root, "identities"),
|
|
11898
|
+
configProfilesDir: import_node_path36.default.join(root, "config-profiles"),
|
|
11899
|
+
providersDir: import_node_path36.default.join(root, "providers"),
|
|
11900
|
+
providerAliasesFile: import_node_path36.default.join(root, "provider-aliases.json"),
|
|
11901
|
+
directoryRulesFile: import_node_path36.default.join(root, "directory-rules.json"),
|
|
11902
|
+
activeIdentityFile: import_node_path36.default.join(root, "active-identity"),
|
|
11903
|
+
globalConfigFile: import_node_path36.default.join(root, "config.json"),
|
|
11904
|
+
categoriesLocalFile: import_node_path36.default.join(root, "categories.local.json"),
|
|
11905
|
+
claudeShimFile: import_node_path36.default.join(root, "claude-shim.json"),
|
|
11906
|
+
headroomDir: import_node_path36.default.join(root, "headroom"),
|
|
11907
|
+
headroomStateFile: import_node_path36.default.join(root, "headroom", "state.json"),
|
|
11908
|
+
headroomRoutingFile: import_node_path36.default.join(root, "headroom", "routing.json"),
|
|
11909
|
+
headroomLegacyStateFile: import_node_path36.default.join(root, "headroom", "state.v2.json"),
|
|
11910
|
+
headroomAllowlistFile: import_node_path36.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
11911
|
+
headroomSocketDir: import_node_path36.default.join(root, "headroom", "run"),
|
|
11912
|
+
headroomLockFile: import_node_path36.default.join(root, "headroom", "start.lock"),
|
|
11913
|
+
headroomSessionsDir: import_node_path36.default.join(root, "headroom", "sessions"),
|
|
11914
|
+
logsDir: import_node_path36.default.join(root, "logs"),
|
|
11915
|
+
headroomLogPath: import_node_path36.default.join(root, "logs", "headroom.log"),
|
|
11916
|
+
frontdoorDir: import_node_path36.default.join(root, "frontdoor"),
|
|
11917
|
+
frontdoorCaDir: import_node_path36.default.join(root, "frontdoor", "ca"),
|
|
11918
|
+
frontdoorCaCertFile: import_node_path36.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
11919
|
+
frontdoorCaKeyFile: import_node_path36.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
11920
|
+
frontdoorCaBundlesDir: import_node_path36.default.join(root, "frontdoor", "ca", "bundles"),
|
|
11921
|
+
chatgptSignInFile: import_node_path36.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
11922
|
+
frontdoorStateFile: import_node_path36.default.join(root, "frontdoor", "state.json"),
|
|
11923
|
+
frontdoorLockFile: import_node_path36.default.join(root, "frontdoor", "start.lock"),
|
|
11924
|
+
frontdoorControlTokenFile: import_node_path36.default.join(root, "frontdoor", "control-token"),
|
|
11925
|
+
frontdoorSessionsDir: import_node_path36.default.join(root, "frontdoor", "sessions"),
|
|
11926
|
+
frontdoorDirectRecordsDir: import_node_path36.default.join(root, "frontdoor", "direct"),
|
|
11927
|
+
frontdoorDrainingDir: import_node_path36.default.join(root, "frontdoor", "draining"),
|
|
11928
|
+
frontdoorRcCredentialsDir: import_node_path36.default.join(root, "frontdoor", "rc-credentials"),
|
|
11929
|
+
frontdoorLogPath: import_node_path36.default.join(root, "logs", "frontdoor.log"),
|
|
11930
|
+
usageDir: import_node_path36.default.join(root, "usage"),
|
|
11931
|
+
usageLogDir: import_node_path36.default.join(root, "usage", "log"),
|
|
11932
|
+
usageSnapshotsDir: import_node_path36.default.join(root, "usage", "snapshots"),
|
|
11933
|
+
statuslineDir: import_node_path36.default.join(root, "statusline"),
|
|
11934
|
+
catalogueDir: import_node_path36.default.join(root, "catalogues"),
|
|
11935
|
+
usagePicksFile: import_node_path36.default.join(root, "usage", "picks.json"),
|
|
11936
|
+
usageAnchorsFile: import_node_path36.default.join(root, "usage", "anchors.json"),
|
|
11937
|
+
usageJobsFile: import_node_path36.default.join(root, "usage", "jobs.json"),
|
|
11938
|
+
jobLogsDir: import_node_path36.default.join(root, "logs", "jobs"),
|
|
11939
|
+
identityRenamesDir: import_node_path36.default.join(root, "identity-renames"),
|
|
11940
|
+
identityNameRenamesDir: import_node_path36.default.join(root, "identity-name-renames"),
|
|
11941
|
+
launchesDir: import_node_path36.default.join(root, "launches"),
|
|
11942
|
+
superviseDir: import_node_path36.default.join(root, "supervise"),
|
|
11943
|
+
modelMovesDir: import_node_path36.default.join(root, "model-moves"),
|
|
11944
|
+
mcpPermissionsFile: import_node_path36.default.join(root, "mcp", "permissions.json")
|
|
11945
|
+
};
|
|
11946
|
+
}
|
|
11947
|
+
function resolveLayoutPaths() {
|
|
11948
|
+
return buildLayoutPaths(resolveAgentShimHome());
|
|
11949
|
+
}
|
|
11950
|
+
var import_node_fs10, import_node_os5, import_node_path36;
|
|
11951
|
+
var init_paths = __esm({
|
|
11952
|
+
"src/paths.ts"() {
|
|
11953
|
+
"use strict";
|
|
11954
|
+
import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
11955
|
+
import_node_os5 = __toESM(require("node:os"), 1);
|
|
11956
|
+
import_node_path36 = __toESM(require("node:path"), 1);
|
|
11957
|
+
init_legacy();
|
|
11958
|
+
}
|
|
11959
|
+
});
|
|
11960
|
+
|
|
11534
11961
|
// src/launcher/claudeVersion.ts
|
|
11535
11962
|
function validated2(value, origin) {
|
|
11536
11963
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -11568,227 +11995,12 @@ var init_claudeVersion = __esm({
|
|
|
11568
11995
|
}
|
|
11569
11996
|
});
|
|
11570
11997
|
|
|
11571
|
-
// src/headroom/headers.ts
|
|
11572
|
-
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
11573
|
-
const merged = /* @__PURE__ */ new Map();
|
|
11574
|
-
for (const block of existing) {
|
|
11575
|
-
if (block === void 0) {
|
|
11576
|
-
continue;
|
|
11577
|
-
}
|
|
11578
|
-
for (const line of block.split("\n")) {
|
|
11579
|
-
const entry = parseCustomHeaderLine(line);
|
|
11580
|
-
if (entry === void 0) {
|
|
11581
|
-
continue;
|
|
11582
|
-
}
|
|
11583
|
-
merged.set(entry.name, entry.value);
|
|
11584
|
-
}
|
|
11585
|
-
}
|
|
11586
|
-
for (const entry of additions) {
|
|
11587
|
-
merged.set(entry.name, entry.value);
|
|
11588
|
-
}
|
|
11589
|
-
return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
|
|
11590
|
-
}
|
|
11591
|
-
function parseAnthropicCustomHeaders(block) {
|
|
11592
|
-
return block.split("\n").flatMap((line) => {
|
|
11593
|
-
const entry = parseCustomHeaderLine(line);
|
|
11594
|
-
return entry === void 0 ? [] : [entry];
|
|
11595
|
-
});
|
|
11596
|
-
}
|
|
11597
|
-
function withoutAnthropicCustomHeaders(block, remove) {
|
|
11598
|
-
const lines = block.split("\n");
|
|
11599
|
-
const kept = lines.filter((line) => {
|
|
11600
|
-
const entry = parseCustomHeaderLine(line);
|
|
11601
|
-
return entry === void 0 || !remove(entry);
|
|
11602
|
-
});
|
|
11603
|
-
return kept.length === lines.length ? block : kept.join("\n");
|
|
11604
|
-
}
|
|
11605
|
-
function parseCustomHeaderLine(line) {
|
|
11606
|
-
const trimmed = line.trim();
|
|
11607
|
-
if (trimmed === "") {
|
|
11608
|
-
return void 0;
|
|
11609
|
-
}
|
|
11610
|
-
const colon = trimmed.indexOf(":");
|
|
11611
|
-
if (colon <= 0) {
|
|
11612
|
-
return void 0;
|
|
11613
|
-
}
|
|
11614
|
-
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
11615
|
-
}
|
|
11616
|
-
var init_headers = __esm({
|
|
11617
|
-
"src/headroom/headers.ts"() {
|
|
11618
|
-
"use strict";
|
|
11619
|
-
}
|
|
11620
|
-
});
|
|
11621
|
-
|
|
11622
|
-
// src/launcher/injected.ts
|
|
11623
|
-
function listKey(list) {
|
|
11624
|
-
return `${list},appended`;
|
|
11625
|
-
}
|
|
11626
|
-
function digest2(value) {
|
|
11627
|
-
return (0, import_node_crypto14.createHash)("sha256").update(value).digest("hex");
|
|
11628
|
-
}
|
|
11629
|
-
function recordedDigests(env) {
|
|
11630
|
-
const raw = env[INJECTED_ENV];
|
|
11631
|
-
if (raw === void 0 || raw === "") {
|
|
11632
|
-
return {};
|
|
11633
|
-
}
|
|
11634
|
-
let parsed;
|
|
11635
|
-
try {
|
|
11636
|
-
parsed = JSON.parse(raw);
|
|
11637
|
-
} catch {
|
|
11638
|
-
return {};
|
|
11639
|
-
}
|
|
11640
|
-
const result = InjectedSchema.safeParse(parsed);
|
|
11641
|
-
return result.success ? result.data : {};
|
|
11642
|
-
}
|
|
11643
|
-
function recordInjections(base) {
|
|
11644
|
-
const env = { ...base };
|
|
11645
|
-
const digests = new Map(Object.entries(recordedDigests(env)));
|
|
11646
|
-
return {
|
|
11647
|
-
env,
|
|
11648
|
-
set: (name, value) => {
|
|
11649
|
-
env[name] = value;
|
|
11650
|
-
digests.set(name, digest2(value));
|
|
11651
|
-
},
|
|
11652
|
-
unset: (name) => {
|
|
11653
|
-
env[name] = void 0;
|
|
11654
|
-
digests.delete(name);
|
|
11655
|
-
},
|
|
11656
|
-
recordHeaders: (names) => {
|
|
11657
|
-
const block = env[CUSTOM_HEADERS_ENV];
|
|
11658
|
-
for (const entry of block === void 0 ? [] : parseAnthropicCustomHeaders(block)) {
|
|
11659
|
-
if (names.includes(entry.name)) {
|
|
11660
|
-
digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
|
|
11661
|
-
}
|
|
11662
|
-
}
|
|
11663
|
-
},
|
|
11664
|
-
recordBypassHosts: (list, hosts) => {
|
|
11665
|
-
const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
|
|
11666
|
-
if (recordedHosts.length > 0) {
|
|
11667
|
-
digests.set(listKey(list), recordedHosts.join(","));
|
|
11668
|
-
}
|
|
11669
|
-
},
|
|
11670
|
-
finish: () => {
|
|
11671
|
-
if (digests.size > 0) {
|
|
11672
|
-
env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
|
|
11673
|
-
}
|
|
11674
|
-
}
|
|
11675
|
-
};
|
|
11676
|
-
}
|
|
11677
|
-
function withoutRecordedHosts(list, value, digests) {
|
|
11678
|
-
const recordedHosts = new Set(digests[listKey(list)]?.split(","));
|
|
11679
|
-
const entries = value.split(",");
|
|
11680
|
-
const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
|
|
11681
|
-
return kept.length === entries.length ? value : kept.join(",");
|
|
11682
|
-
}
|
|
11683
|
-
function launchEnvironment(env, configDirEscapeHatch) {
|
|
11684
|
-
return configDirEscapeHatch ? env : withoutInjected(env);
|
|
11685
|
-
}
|
|
11686
|
-
function withoutInjected(env) {
|
|
11687
|
-
const digests = recordedDigests(env);
|
|
11688
|
-
const entries = Object.entries(env).flatMap(([name, value]) => {
|
|
11689
|
-
if (name === INJECTED_ENV) {
|
|
11690
|
-
return [];
|
|
11691
|
-
}
|
|
11692
|
-
if (value === void 0) {
|
|
11693
|
-
return [[name, value]];
|
|
11694
|
-
}
|
|
11695
|
-
if (name === CUSTOM_HEADERS_ENV) {
|
|
11696
|
-
const remaining = withoutAnthropicCustomHeaders(value, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
|
|
11697
|
-
return remaining !== value && remaining.trim() === "" ? [] : [[name, remaining]];
|
|
11698
|
-
}
|
|
11699
|
-
if (name === "NO_PROXY" || name === "no_proxy") {
|
|
11700
|
-
const remaining = withoutRecordedHosts(name, value, digests);
|
|
11701
|
-
return remaining !== value && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
|
|
11702
|
-
}
|
|
11703
|
-
return digests[name] === digest2(value) ? [] : [[name, value]];
|
|
11704
|
-
});
|
|
11705
|
-
return Object.fromEntries(entries);
|
|
11706
|
-
}
|
|
11707
|
-
var import_node_crypto14, import_zod26, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
11708
|
-
var init_injected = __esm({
|
|
11709
|
-
"src/launcher/injected.ts"() {
|
|
11710
|
-
"use strict";
|
|
11711
|
-
import_node_crypto14 = require("node:crypto");
|
|
11712
|
-
import_zod26 = require("zod");
|
|
11713
|
-
init_headers();
|
|
11714
|
-
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
11715
|
-
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
11716
|
-
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
11717
|
-
InjectedSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.string());
|
|
11718
|
-
}
|
|
11719
|
-
});
|
|
11720
|
-
|
|
11721
|
-
// src/launcher/guard.ts
|
|
11722
|
-
function detectAmbientCredential(env, injected) {
|
|
11723
|
-
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
11724
|
-
const value = env[variable];
|
|
11725
|
-
if (value === void 0 || value === "") {
|
|
11726
|
-
continue;
|
|
11727
|
-
}
|
|
11728
|
-
if (injected?.variable === variable && value === injected.token) {
|
|
11729
|
-
continue;
|
|
11730
|
-
}
|
|
11731
|
-
return { variable };
|
|
11732
|
-
}
|
|
11733
|
-
return void 0;
|
|
11734
|
-
}
|
|
11735
|
-
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
11736
|
-
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
11737
|
-
return [
|
|
11738
|
-
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
11739
|
-
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
11740
|
-
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
11741
|
-
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
11742
|
-
`\`${identitySetCommand}\`.`
|
|
11743
|
-
].join("\n");
|
|
11744
|
-
}
|
|
11745
|
-
function evaluateAmbientCredentialGuard(params) {
|
|
11746
|
-
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
11747
|
-
if (detected === void 0) {
|
|
11748
|
-
return { ok: true };
|
|
11749
|
-
}
|
|
11750
|
-
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
11751
|
-
return { ok: true };
|
|
11752
|
-
}
|
|
11753
|
-
return {
|
|
11754
|
-
ok: false,
|
|
11755
|
-
variable: detected.variable,
|
|
11756
|
-
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
11757
|
-
};
|
|
11758
|
-
}
|
|
11759
|
-
function ambientCredentialFinding(env) {
|
|
11760
|
-
const named = detectAmbientCredential(launchEnvironment(env, false));
|
|
11761
|
-
if (named !== void 0) {
|
|
11762
|
-
return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
|
|
11763
|
-
}
|
|
11764
|
-
const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
|
|
11765
|
-
if (bare !== void 0) {
|
|
11766
|
-
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>\`.` };
|
|
11767
|
-
}
|
|
11768
|
-
return { severity: "pass", message: "No ambient-credential environment variable is set." };
|
|
11769
|
-
}
|
|
11770
|
-
var AMBIENT_CREDENTIAL_VARS;
|
|
11771
|
-
var init_guard = __esm({
|
|
11772
|
-
"src/launcher/guard.ts"() {
|
|
11773
|
-
"use strict";
|
|
11774
|
-
init_injected();
|
|
11775
|
-
AMBIENT_CREDENTIAL_VARS = [
|
|
11776
|
-
"ANTHROPIC_API_KEY",
|
|
11777
|
-
"ANTHROPIC_AUTH_TOKEN",
|
|
11778
|
-
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
11779
|
-
"CLAUDE_CODE_USE_BEDROCK",
|
|
11780
|
-
"CLAUDE_CODE_USE_VERTEX",
|
|
11781
|
-
"CLAUDE_CODE_USE_FOUNDRY"
|
|
11782
|
-
];
|
|
11783
|
-
}
|
|
11784
|
-
});
|
|
11785
|
-
|
|
11786
11998
|
// src/usage/resets.ts
|
|
11787
11999
|
function formatPeriod(window) {
|
|
11788
12000
|
if (window.periodMs === void 0) {
|
|
11789
12001
|
return window.period ?? "unknown period";
|
|
11790
12002
|
}
|
|
11791
|
-
const hours = window.periodMs /
|
|
12003
|
+
const hours = window.periodMs / MS_PER_HOUR5;
|
|
11792
12004
|
return hours >= HOURS_PER_DAY4 && Number.isInteger(hours / HOURS_PER_DAY4) ? `${String(hours / HOURS_PER_DAY4)}d` : `${String(hours)}h`;
|
|
11793
12005
|
}
|
|
11794
12006
|
function groupOf(row) {
|
|
@@ -11828,13 +12040,13 @@ function collectResets(snapshots, nowMs) {
|
|
|
11828
12040
|
);
|
|
11829
12041
|
return { resets: rows.sort(compareRows) };
|
|
11830
12042
|
}
|
|
11831
|
-
var
|
|
12043
|
+
var MS_PER_HOUR5, HOURS_PER_DAY4;
|
|
11832
12044
|
var init_resets = __esm({
|
|
11833
12045
|
"src/usage/resets.ts"() {
|
|
11834
12046
|
"use strict";
|
|
11835
12047
|
init_preflight();
|
|
11836
12048
|
init_rateLimit();
|
|
11837
|
-
|
|
12049
|
+
MS_PER_HOUR5 = 36e5;
|
|
11838
12050
|
HOURS_PER_DAY4 = 24;
|
|
11839
12051
|
}
|
|
11840
12052
|
});
|
|
@@ -12448,7 +12660,7 @@ function providerModels(paths) {
|
|
|
12448
12660
|
if (entry.provider.kind === "codex") {
|
|
12449
12661
|
if (catalogue !== void 0 && catalogue.supervisorPid !== supervisorPid) return [];
|
|
12450
12662
|
const env = doorHome === void 0 ? process.env : { ...process.env, CODEX_HOME: doorHome };
|
|
12451
|
-
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env,
|
|
12663
|
+
const fingerprint = savedCatalogueFingerprint(entry.provider, paths, env, import_node_os7.default.homedir(), realFsPort.readFileUtf8);
|
|
12452
12664
|
if (fingerprint === void 0 || catalogue?.credentialFingerprint !== fingerprint) return [];
|
|
12453
12665
|
}
|
|
12454
12666
|
return providerModelRows(entry.provider, catalogue?.models).map((row) => ({ provider: entry.name, model: row.model }));
|
|
@@ -12457,11 +12669,11 @@ function providerModels(paths) {
|
|
|
12457
12669
|
function targetRefs(paths) {
|
|
12458
12670
|
return providerModels(paths).map((entry) => `${entry.provider}/${entry.model}`);
|
|
12459
12671
|
}
|
|
12460
|
-
var
|
|
12672
|
+
var import_node_os7;
|
|
12461
12673
|
var init_targets = __esm({
|
|
12462
12674
|
"src/models/targets.ts"() {
|
|
12463
12675
|
"use strict";
|
|
12464
|
-
|
|
12676
|
+
import_node_os7 = __toESM(require("node:os"), 1);
|
|
12465
12677
|
init_catalogueCredential();
|
|
12466
12678
|
init_state();
|
|
12467
12679
|
init_modelPicker();
|
|
@@ -13758,7 +13970,10 @@ var init_hold = __esm({
|
|
|
13758
13970
|
// src/launcher/launchReport.ts
|
|
13759
13971
|
function poolDetail(pool) {
|
|
13760
13972
|
const [reason] = pool.reasons;
|
|
13761
|
-
|
|
13973
|
+
if (reason === void 0) {
|
|
13974
|
+
return {};
|
|
13975
|
+
}
|
|
13976
|
+
return { detail: pool.provider === void 0 ? reason : `${reason} (ranked on provider ${pool.provider})` };
|
|
13762
13977
|
}
|
|
13763
13978
|
function rankingNotes(ranking, picked) {
|
|
13764
13979
|
return ranking.flatMap((candidate, index) => [
|
|
@@ -13920,6 +14135,7 @@ function resolvePoolLaunch(params) {
|
|
|
13920
14135
|
resuming,
|
|
13921
14136
|
...params.resumeContextTokens === void 0 ? {} : { resumeContextTokens: params.resumeContextTokens },
|
|
13922
14137
|
...params.committedContextTokens === void 0 ? {} : { committedContextTokens: params.committedContextTokens },
|
|
14138
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf },
|
|
13923
14139
|
identityIdOf: identityIdResolver(params.paths.identitiesDir, params.fs),
|
|
13924
14140
|
...stickyRead.sticky === void 0 ? {} : { sticky: stickyRead.sticky }
|
|
13925
14141
|
});
|
|
@@ -13961,6 +14177,7 @@ function resolvePoolLaunch(params) {
|
|
|
13961
14177
|
explanation: `pool ${poolName}: ${move}${pick.reasons.slice(0, REASONS_LOGGED).join("; ")}`,
|
|
13962
14178
|
reasons: pick.reasons,
|
|
13963
14179
|
candidates: graph.ranking.candidates,
|
|
14180
|
+
...pick.provider === void 0 ? {} : { provider: pick.provider },
|
|
13964
14181
|
...movedOff === void 0 ? {} : { movedOff },
|
|
13965
14182
|
...stickyRead.sticky === void 0 ? {} : { lastRanAs: stickyRead.sticky }
|
|
13966
14183
|
};
|
|
@@ -13998,7 +14215,7 @@ function childExitCode(result) {
|
|
|
13998
14215
|
return result.status;
|
|
13999
14216
|
}
|
|
14000
14217
|
if (result.signal !== null) {
|
|
14001
|
-
return SIGNAL_EXIT_CODE_OFFSET +
|
|
14218
|
+
return SIGNAL_EXIT_CODE_OFFSET + import_node_os8.default.constants.signals[result.signal];
|
|
14002
14219
|
}
|
|
14003
14220
|
return 1;
|
|
14004
14221
|
}
|
|
@@ -14012,11 +14229,11 @@ function spawnClaude(params) {
|
|
|
14012
14229
|
}
|
|
14013
14230
|
return params.proc.exit(childExitCode(result));
|
|
14014
14231
|
}
|
|
14015
|
-
var
|
|
14232
|
+
var import_node_os8, SIGNAL_EXIT_CODE_OFFSET;
|
|
14016
14233
|
var init_spawn = __esm({
|
|
14017
14234
|
"src/launcher/spawn.ts"() {
|
|
14018
14235
|
"use strict";
|
|
14019
|
-
|
|
14236
|
+
import_node_os8 = __toESM(require("node:os"), 1);
|
|
14020
14237
|
SIGNAL_EXIT_CODE_OFFSET = 128;
|
|
14021
14238
|
}
|
|
14022
14239
|
});
|
|
@@ -14098,7 +14315,7 @@ function resolveIdentityCredential(identity, credential, env, port) {
|
|
|
14098
14315
|
const resolution = resolveCredential({ credential, env, port, subject: `identity ${identity.name}`, cacheKey: identityCacheKey(identity.id) });
|
|
14099
14316
|
return resolution.ok ? resolution : { ok: false, status: CREDENTIAL_UNAVAILABLE_EXIT, message: `agent-shim: ${resolution.message}` };
|
|
14100
14317
|
}
|
|
14101
|
-
function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
14318
|
+
function pickFromPool(decided, params, parsedArgv, readOnly, providerSelections) {
|
|
14102
14319
|
const { paths, fs: fs17, proc, log } = params;
|
|
14103
14320
|
if (decided.pool === void 0) {
|
|
14104
14321
|
return { identityDecision: decided };
|
|
@@ -14113,6 +14330,17 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14113
14330
|
return proc.exit(1);
|
|
14114
14331
|
}
|
|
14115
14332
|
const resumeContextTokens = resumedContextTokens(farmRuntime.fs, { claudeHome: farmRuntime.claudeHome, cwd: farmRuntime.cwd, passthrough: parsedArgv.rest });
|
|
14333
|
+
const cliFlagConfigProfile = params.cliFlagConfigProfile ?? parsedArgv.configProfile;
|
|
14334
|
+
const providerOf = memberProviderResolver({
|
|
14335
|
+
paths,
|
|
14336
|
+
fs: fs17,
|
|
14337
|
+
env: providerSelections.env,
|
|
14338
|
+
cliProvider: parsedArgv.provider,
|
|
14339
|
+
...cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile },
|
|
14340
|
+
...params.directoryRuleConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: params.directoryRuleConfigProfile },
|
|
14341
|
+
...params.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: params.globalDefaultConfigProfile },
|
|
14342
|
+
loadCascade: (baseConfigProfile) => farmRuntime.loadCascade(baseConfigProfile, providerSelections.cliOverride)
|
|
14343
|
+
});
|
|
14116
14344
|
const resolution = resolvePoolLaunch({
|
|
14117
14345
|
poolName: decided.pool,
|
|
14118
14346
|
selectedVia: decided.source,
|
|
@@ -14124,6 +14352,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14124
14352
|
now: farmRuntime.now,
|
|
14125
14353
|
sleep: farmRuntime.lock.sleep,
|
|
14126
14354
|
passthrough: parsedArgv.rest,
|
|
14355
|
+
providerOf,
|
|
14127
14356
|
...resumeContextTokens === void 0 ? {} : { resumeContextTokens },
|
|
14128
14357
|
// A read-only decision never sleeps for a refused pool and never records its pick, so asking what a launch would pick leaves the next real launch's keep-warm preference as it was.
|
|
14129
14358
|
wait: !readOnly && parsedArgv.wait === true,
|
|
@@ -14136,7 +14365,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
|
|
|
14136
14365
|
}
|
|
14137
14366
|
return {
|
|
14138
14367
|
identityDecision: { ...decided, name: resolution.identity },
|
|
14139
|
-
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
14368
|
+
poolPick: { name: decided.pool, reasons: resolution.reasons, ...resolution.provider === void 0 ? {} : { provider: resolution.provider }, ...resolution.movedOff === void 0 ? {} : { movedOff: resolution.movedOff } },
|
|
14140
14369
|
poolRanking: resolution.candidates,
|
|
14141
14370
|
...resolution.lastRanAs === void 0 ? {} : { lastRanAs: { identity: resolution.lastRanAs.identity, agoMs: farmRuntime.now() - Date.parse(resolution.lastRanAs.at) } }
|
|
14142
14371
|
};
|
|
@@ -14172,7 +14401,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14172
14401
|
shareFlags: parsedArgv.shareFlags,
|
|
14173
14402
|
hideFlags: parsedArgv.hideFlags
|
|
14174
14403
|
});
|
|
14175
|
-
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly);
|
|
14404
|
+
const { identityDecision, poolPick, poolRanking, lastRanAs } = pickFromPool(decidedIdentity, params, parsedArgv, readOnly, { env, cliOverride });
|
|
14176
14405
|
const lockFarm = !readOnly && !configDirEscapeHatchApplies && identityDecision.name !== void 0 ? params.farm : void 0;
|
|
14177
14406
|
const lockPorts = params.namesLock ?? (lockFarm === void 0 ? realIdentityNamesLockPorts : { fs: lockFarm.fs, nowMs: lockFarm.now, ...lockFarm.lock });
|
|
14178
14407
|
const namesLock = readOnly || configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : acquireIdentityNamesLock(paths, lockPorts);
|
|
@@ -14331,10 +14560,22 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14331
14560
|
...parsedArgv.delay === void 0 ? {} : { delay: parsedArgv.delay }
|
|
14332
14561
|
}
|
|
14333
14562
|
});
|
|
14334
|
-
const loginlessProvider =
|
|
14563
|
+
const loginlessProvider = (() => {
|
|
14564
|
+
if (!requestedFlags.remoteControl || selectedProvider === void 0 || farmIdentity === void 0 || identityDecision.name === void 0) {
|
|
14565
|
+
return void 0;
|
|
14566
|
+
}
|
|
14567
|
+
const stored = params.hasStoredLogin?.(farmIdentity);
|
|
14568
|
+
if (stored === false) {
|
|
14569
|
+
return { identity: identityDecision.name, provider: selectedProvider.name, why: "has no stored login" };
|
|
14570
|
+
}
|
|
14571
|
+
if (stored === true && params.hasUsableLogin?.(farmIdentity, discovered.path) === false) {
|
|
14572
|
+
return { identity: identityDecision.name, provider: selectedProvider.name, why: "has a stored login that is no longer usable" };
|
|
14573
|
+
}
|
|
14574
|
+
return void 0;
|
|
14575
|
+
})();
|
|
14335
14576
|
const notes = [];
|
|
14336
14577
|
if (loginlessProvider !== void 0) {
|
|
14337
|
-
notes.push(`${loginlessProvider.identity}
|
|
14578
|
+
notes.push(`${loginlessProvider.identity} ${loginlessProvider.why}, so Remote Control is off; provider ${loginlessProvider.provider} runs without it`);
|
|
14338
14579
|
}
|
|
14339
14580
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
14340
14581
|
const globalModels = loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models;
|
|
@@ -14361,12 +14602,12 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14361
14602
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
14362
14603
|
const binding = parseCatalogueBinding(params.fs.readFileUtf8(catalogueBindingPath(paths, name, catalogueOwner, generation)));
|
|
14363
14604
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
14364
|
-
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path51.default.join(
|
|
14605
|
+
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path51.default.join(import_node_os9.default.homedir(), ".codex") : configuredHome;
|
|
14365
14606
|
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path51.default.resolve(home, "auth.json");
|
|
14366
14607
|
const revision = params.fs.fileRevision?.(source);
|
|
14367
14608
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
14368
14609
|
}
|
|
14369
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv,
|
|
14610
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os9.default.homedir(), params.fs.readFileUtf8) : void 0;
|
|
14370
14611
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
14371
14612
|
return [[name, definition, cache?.models ?? []]];
|
|
14372
14613
|
} catch {
|
|
@@ -14634,12 +14875,12 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
14634
14875
|
function runLauncher(params) {
|
|
14635
14876
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
14636
14877
|
}
|
|
14637
|
-
var import_node_crypto17,
|
|
14878
|
+
var import_node_crypto17, import_node_os9, import_node_util2, import_node_path51;
|
|
14638
14879
|
var init_launcher = __esm({
|
|
14639
14880
|
"src/launcher.ts"() {
|
|
14640
14881
|
"use strict";
|
|
14641
14882
|
import_node_crypto17 = require("node:crypto");
|
|
14642
|
-
|
|
14883
|
+
import_node_os9 = __toESM(require("node:os"), 1);
|
|
14643
14884
|
init_catalogueCredential();
|
|
14644
14885
|
import_node_util2 = require("node:util");
|
|
14645
14886
|
import_node_path51 = __toESM(require("node:path"), 1);
|
|
@@ -14665,6 +14906,7 @@ var init_launcher = __esm({
|
|
|
14665
14906
|
init_state();
|
|
14666
14907
|
init_providerCatalogue();
|
|
14667
14908
|
init_providersStore();
|
|
14909
|
+
init_memberProvider();
|
|
14668
14910
|
init_pool();
|
|
14669
14911
|
init_resumeContext();
|
|
14670
14912
|
init_lock();
|
|
@@ -14834,7 +15076,7 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
14834
15076
|
const cache2 = parseCatalogueCache(realFarmFs.readFileUtf8(catalogueCachePath(paths, name, supervisorPid, owner.generation)));
|
|
14835
15077
|
let fingerprint;
|
|
14836
15078
|
try {
|
|
14837
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome },
|
|
15079
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os10.default.homedir(), realFarmFs.readFileUtf8);
|
|
14838
15080
|
} catch (error) {
|
|
14839
15081
|
warnings.add(`Cannot read catalogue credentials for ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
14840
15082
|
return false;
|
|
@@ -14884,12 +15126,12 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
14884
15126
|
}
|
|
14885
15127
|
};
|
|
14886
15128
|
}
|
|
14887
|
-
var import_node_fs17,
|
|
15129
|
+
var import_node_fs17, import_node_os10, realTrustBundleFs;
|
|
14888
15130
|
var init_realFrontDoorPort = __esm({
|
|
14889
15131
|
"src/frontdoor/realFrontDoorPort.ts"() {
|
|
14890
15132
|
"use strict";
|
|
14891
15133
|
import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
14892
|
-
|
|
15134
|
+
import_node_os10 = __toESM(require("node:os"), 1);
|
|
14893
15135
|
init_providersStore();
|
|
14894
15136
|
init_providerCatalogue();
|
|
14895
15137
|
init_catalogueCredential();
|
|
@@ -14916,7 +15158,7 @@ var init_realFrontDoorPort = __esm({
|
|
|
14916
15158
|
|
|
14917
15159
|
// src/launchWiring.ts
|
|
14918
15160
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
14919
|
-
const home =
|
|
15161
|
+
const home = import_node_os11.default.homedir();
|
|
14920
15162
|
const read = cosmiconfigReader();
|
|
14921
15163
|
const classification = loadClassification(paths);
|
|
14922
15164
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
@@ -14969,6 +15211,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
14969
15211
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
14970
15212
|
hold: realHoldPort,
|
|
14971
15213
|
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path54.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
15214
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path54.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
14972
15215
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
14973
15216
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
14974
15217
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -15029,11 +15272,11 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
15029
15272
|
};
|
|
15030
15273
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
15031
15274
|
}
|
|
15032
|
-
var
|
|
15275
|
+
var import_node_os11, import_node_path54, import_node_crypto19, LaunchRefusedError;
|
|
15033
15276
|
var init_launchWiring = __esm({
|
|
15034
15277
|
"src/launchWiring.ts"() {
|
|
15035
15278
|
"use strict";
|
|
15036
|
-
|
|
15279
|
+
import_node_os11 = __toESM(require("node:os"), 1);
|
|
15037
15280
|
import_node_path54 = __toESM(require("node:path"), 1);
|
|
15038
15281
|
import_node_crypto19 = require("node:crypto");
|
|
15039
15282
|
init_cliError();
|
|
@@ -15191,7 +15434,7 @@ var init_anthropicUsageRefresh = __esm({
|
|
|
15191
15434
|
init_schema();
|
|
15192
15435
|
init_identity();
|
|
15193
15436
|
init_middleware();
|
|
15194
|
-
|
|
15437
|
+
init_windowLengths();
|
|
15195
15438
|
init_plan2();
|
|
15196
15439
|
PERCENT2 = 100;
|
|
15197
15440
|
ANTHROPIC_USAGE_FRESHNESS_MS = FIVE_HOUR_WINDOW_MS / PERCENT2;
|
|
@@ -15397,14 +15640,14 @@ function createRealAnthropicUsageRefresher(params) {
|
|
|
15397
15640
|
},
|
|
15398
15641
|
now: () => Date.now(),
|
|
15399
15642
|
log: params.log,
|
|
15400
|
-
concurrency: (0,
|
|
15643
|
+
concurrency: (0, import_node_os12.availableParallelism)()
|
|
15401
15644
|
});
|
|
15402
15645
|
}
|
|
15403
|
-
var
|
|
15646
|
+
var import_node_os12, PROBE_LAUNCH_FLAGS;
|
|
15404
15647
|
var init_realAnthropicUsageProbe = __esm({
|
|
15405
15648
|
"src/usage/realAnthropicUsageProbe.ts"() {
|
|
15406
15649
|
"use strict";
|
|
15407
|
-
|
|
15650
|
+
import_node_os12 = require("node:os");
|
|
15408
15651
|
init_identityStore();
|
|
15409
15652
|
init_anthropicUsageRefresh();
|
|
15410
15653
|
init_identityClaude();
|
|
@@ -15770,6 +16013,7 @@ __export(index_exports, {
|
|
|
15770
16013
|
realCodexAppServerPort: () => realCodexAppServerPort,
|
|
15771
16014
|
realConnectCertStore: () => realConnectCertStore,
|
|
15772
16015
|
realConnectEffects: () => realConnectEffects,
|
|
16016
|
+
realMemberProviderResolver: () => realMemberProviderResolver,
|
|
15773
16017
|
realRcControlTransport: () => realRcControlTransport,
|
|
15774
16018
|
realRcEventDial: () => realRcEventDial,
|
|
15775
16019
|
realRcStreamDial: () => realRcStreamDial,
|
|
@@ -18424,20 +18668,20 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
18424
18668
|
|
|
18425
18669
|
// src/frontdoor/rcSessionRegistry.ts
|
|
18426
18670
|
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
18427
|
-
var
|
|
18671
|
+
var import_zod23 = require("zod");
|
|
18428
18672
|
init_identityStore();
|
|
18429
18673
|
var REGISTRY_BRIDGE_PREFIX = "session_";
|
|
18430
18674
|
var DOOR_SESSION_PREFIX = "cse_";
|
|
18431
18675
|
var REGISTRY_DIR = "sessions";
|
|
18432
18676
|
var ENTRY_SUFFIX = ".json";
|
|
18433
18677
|
var RC_REGISTRY_ENTRY_MAX_BYTES = 8192;
|
|
18434
|
-
var RegistryEntrySchema =
|
|
18435
|
-
sessionId:
|
|
18436
|
-
pid:
|
|
18437
|
-
bridgeSessionId:
|
|
18438
|
-
cwd:
|
|
18439
|
-
name:
|
|
18440
|
-
updatedAt:
|
|
18678
|
+
var RegistryEntrySchema = import_zod23.z.looseObject({
|
|
18679
|
+
sessionId: import_zod23.z.string().min(1),
|
|
18680
|
+
pid: import_zod23.z.int().positive(),
|
|
18681
|
+
bridgeSessionId: import_zod23.z.union([import_zod23.z.string().startsWith(REGISTRY_BRIDGE_PREFIX), import_zod23.z.string().startsWith(DOOR_SESSION_PREFIX)]),
|
|
18682
|
+
cwd: import_zod23.z.string().optional(),
|
|
18683
|
+
name: import_zod23.z.string().optional(),
|
|
18684
|
+
updatedAt: import_zod23.z.number().optional()
|
|
18441
18685
|
});
|
|
18442
18686
|
function supersedes(candidate, kept) {
|
|
18443
18687
|
return candidate.updatedAt > kept.updatedAt || candidate.updatedAt === kept.updatedAt && candidate.session.pid > kept.session.pid;
|
|
@@ -18644,7 +18888,7 @@ var COMPACT_TIMEOUT_MS = 9e5;
|
|
|
18644
18888
|
init_capability();
|
|
18645
18889
|
|
|
18646
18890
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18647
|
-
var
|
|
18891
|
+
var import_zod24 = require("zod");
|
|
18648
18892
|
|
|
18649
18893
|
// src/frontdoor/rcSessionCommands.ts
|
|
18650
18894
|
var import_promises = require("node:timers/promises");
|
|
@@ -19032,47 +19276,47 @@ function createRcSessionCommands(deps) {
|
|
|
19032
19276
|
}
|
|
19033
19277
|
|
|
19034
19278
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19035
|
-
var WaitMsSchema =
|
|
19036
|
-
var RcGoalSessionInputSchema =
|
|
19037
|
-
session:
|
|
19279
|
+
var WaitMsSchema = import_zod24.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
19280
|
+
var RcGoalSessionInputSchema = import_zod24.z.strictObject({
|
|
19281
|
+
session: import_zod24.z.string().min(1),
|
|
19038
19282
|
waitMs: WaitMsSchema
|
|
19039
19283
|
});
|
|
19040
|
-
var RcGoalSetInputSchema =
|
|
19041
|
-
session:
|
|
19042
|
-
condition:
|
|
19284
|
+
var RcGoalSetInputSchema = import_zod24.z.strictObject({
|
|
19285
|
+
session: import_zod24.z.string().min(1),
|
|
19286
|
+
condition: import_zod24.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
19043
19287
|
waitMs: WaitMsSchema
|
|
19044
19288
|
});
|
|
19045
|
-
var RcCompactInputSchema =
|
|
19046
|
-
session:
|
|
19289
|
+
var RcCompactInputSchema = import_zod24.z.strictObject({
|
|
19290
|
+
session: import_zod24.z.string().min(1),
|
|
19047
19291
|
waitMs: WaitMsSchema
|
|
19048
19292
|
});
|
|
19049
|
-
var RcCompactWithInstructionsInputSchema =
|
|
19050
|
-
session:
|
|
19051
|
-
instructions:
|
|
19293
|
+
var RcCompactWithInstructionsInputSchema = import_zod24.z.strictObject({
|
|
19294
|
+
session: import_zod24.z.string().min(1),
|
|
19295
|
+
instructions: import_zod24.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
19052
19296
|
waitMs: WaitMsSchema
|
|
19053
19297
|
});
|
|
19054
19298
|
var commandAnswerShape = {
|
|
19055
|
-
session:
|
|
19056
|
-
route:
|
|
19299
|
+
session: import_zod24.z.string(),
|
|
19300
|
+
route: import_zod24.z.enum(["supervised", "self-hosted"])
|
|
19057
19301
|
};
|
|
19058
|
-
var RcGoalGetOutputSchema =
|
|
19302
|
+
var RcGoalGetOutputSchema = import_zod24.z.strictObject({
|
|
19059
19303
|
...commandAnswerShape,
|
|
19060
|
-
goal:
|
|
19304
|
+
goal: import_zod24.z.strictObject({ condition: import_zod24.z.string(), iterations: import_zod24.z.int().nonnegative(), lastCheck: import_zod24.z.string().optional() }).nullable()
|
|
19061
19305
|
});
|
|
19062
|
-
var RcGoalSetOutputSchema =
|
|
19306
|
+
var RcGoalSetOutputSchema = import_zod24.z.strictObject({
|
|
19063
19307
|
...commandAnswerShape,
|
|
19064
|
-
condition:
|
|
19065
|
-
superseded:
|
|
19308
|
+
condition: import_zod24.z.string(),
|
|
19309
|
+
superseded: import_zod24.z.string().nullable()
|
|
19066
19310
|
});
|
|
19067
|
-
var RcGoalClearOutputSchema =
|
|
19311
|
+
var RcGoalClearOutputSchema = import_zod24.z.strictObject({
|
|
19068
19312
|
...commandAnswerShape,
|
|
19069
|
-
cleared:
|
|
19313
|
+
cleared: import_zod24.z.string().nullable()
|
|
19070
19314
|
});
|
|
19071
|
-
var RcCompactOutputSchema =
|
|
19315
|
+
var RcCompactOutputSchema = import_zod24.z.strictObject({
|
|
19072
19316
|
...commandAnswerShape,
|
|
19073
|
-
trigger:
|
|
19074
|
-
preTokens:
|
|
19075
|
-
postTokens:
|
|
19317
|
+
trigger: import_zod24.z.string(),
|
|
19318
|
+
preTokens: import_zod24.z.number().optional(),
|
|
19319
|
+
postTokens: import_zod24.z.number().optional()
|
|
19076
19320
|
});
|
|
19077
19321
|
|
|
19078
19322
|
// src/frontdoor/rcApi.ts
|
|
@@ -19293,48 +19537,48 @@ init_cliError();
|
|
|
19293
19537
|
init_package();
|
|
19294
19538
|
|
|
19295
19539
|
// src/codex/appServerSchemas.ts
|
|
19296
|
-
var
|
|
19540
|
+
var import_zod25 = require("zod");
|
|
19297
19541
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
19298
|
-
var RateLimitWindowSchema =
|
|
19299
|
-
usedPercent:
|
|
19300
|
-
resetsAt:
|
|
19301
|
-
windowDurationMins:
|
|
19302
|
-
});
|
|
19303
|
-
var RateLimitSnapshotSchema =
|
|
19304
|
-
limitId:
|
|
19305
|
-
limitName:
|
|
19306
|
-
planType:
|
|
19542
|
+
var RateLimitWindowSchema = import_zod25.z.object({
|
|
19543
|
+
usedPercent: import_zod25.z.number(),
|
|
19544
|
+
resetsAt: import_zod25.z.number().nullish(),
|
|
19545
|
+
windowDurationMins: import_zod25.z.number().nullish()
|
|
19546
|
+
});
|
|
19547
|
+
var RateLimitSnapshotSchema = import_zod25.z.object({
|
|
19548
|
+
limitId: import_zod25.z.string().nullish(),
|
|
19549
|
+
limitName: import_zod25.z.string().nullish(),
|
|
19550
|
+
planType: import_zod25.z.string().nullish(),
|
|
19307
19551
|
primary: RateLimitWindowSchema.nullish(),
|
|
19308
19552
|
secondary: RateLimitWindowSchema.nullish(),
|
|
19309
|
-
rateLimitReachedType:
|
|
19310
|
-
spendControlReached:
|
|
19311
|
-
});
|
|
19312
|
-
var RateLimitResetCreditSchema =
|
|
19313
|
-
id:
|
|
19314
|
-
grantedAt:
|
|
19315
|
-
expiresAt:
|
|
19316
|
-
resetType:
|
|
19317
|
-
status:
|
|
19318
|
-
title:
|
|
19319
|
-
description:
|
|
19320
|
-
});
|
|
19321
|
-
var CodexAccountSchema =
|
|
19322
|
-
|
|
19323
|
-
|
|
19324
|
-
|
|
19553
|
+
rateLimitReachedType: import_zod25.z.string().nullish(),
|
|
19554
|
+
spendControlReached: import_zod25.z.boolean().nullish()
|
|
19555
|
+
});
|
|
19556
|
+
var RateLimitResetCreditSchema = import_zod25.z.object({
|
|
19557
|
+
id: import_zod25.z.string(),
|
|
19558
|
+
grantedAt: import_zod25.z.number(),
|
|
19559
|
+
expiresAt: import_zod25.z.number().nullish(),
|
|
19560
|
+
resetType: import_zod25.z.string(),
|
|
19561
|
+
status: import_zod25.z.string(),
|
|
19562
|
+
title: import_zod25.z.string().nullish(),
|
|
19563
|
+
description: import_zod25.z.string().nullish()
|
|
19564
|
+
});
|
|
19565
|
+
var CodexAccountSchema = import_zod25.z.discriminatedUnion("type", [
|
|
19566
|
+
import_zod25.z.object({ type: import_zod25.z.literal("apiKey") }),
|
|
19567
|
+
import_zod25.z.object({ type: import_zod25.z.literal("chatgpt"), email: import_zod25.z.string().nullable(), planType: import_zod25.z.string() }),
|
|
19568
|
+
import_zod25.z.object({ type: import_zod25.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod25.z.boolean().default(false) })
|
|
19325
19569
|
]);
|
|
19326
|
-
var CodexAccountReadSchema =
|
|
19570
|
+
var CodexAccountReadSchema = import_zod25.z.object({
|
|
19327
19571
|
account: CodexAccountSchema.nullable(),
|
|
19328
|
-
requiresOpenaiAuth:
|
|
19572
|
+
requiresOpenaiAuth: import_zod25.z.boolean()
|
|
19329
19573
|
});
|
|
19330
|
-
var CodexRateLimitsReadSchema =
|
|
19574
|
+
var CodexRateLimitsReadSchema = import_zod25.z.object({
|
|
19331
19575
|
rateLimits: RateLimitSnapshotSchema,
|
|
19332
|
-
rateLimitsByLimitId:
|
|
19333
|
-
rateLimitResetCredits:
|
|
19334
|
-
accountId:
|
|
19335
|
-
ordinaryUsageAllowed:
|
|
19576
|
+
rateLimitsByLimitId: import_zod25.z.record(import_zod25.z.string(), RateLimitSnapshotSchema).nullish(),
|
|
19577
|
+
rateLimitResetCredits: import_zod25.z.object({ availableCount: import_zod25.z.number(), credits: import_zod25.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
19578
|
+
accountId: import_zod25.z.string().nullish(),
|
|
19579
|
+
ordinaryUsageAllowed: import_zod25.z.boolean().nullish()
|
|
19336
19580
|
});
|
|
19337
|
-
var CodexInitializeResultSchema =
|
|
19581
|
+
var CodexInitializeResultSchema = import_zod25.z.object({ userAgent: import_zod25.z.string() });
|
|
19338
19582
|
|
|
19339
19583
|
// src/codex/appServer.ts
|
|
19340
19584
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -19533,7 +19777,7 @@ var import_client8 = require("@orpc/client");
|
|
|
19533
19777
|
var import_openapi9 = require("@orpc/openapi");
|
|
19534
19778
|
|
|
19535
19779
|
// src/checkReport.ts
|
|
19536
|
-
var
|
|
19780
|
+
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
19537
19781
|
init_cliError();
|
|
19538
19782
|
|
|
19539
19783
|
// src/codex/categories.ts
|
|
@@ -19563,7 +19807,7 @@ init_classify();
|
|
|
19563
19807
|
init_load();
|
|
19564
19808
|
|
|
19565
19809
|
// src/launchSelection.ts
|
|
19566
|
-
var
|
|
19810
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
19567
19811
|
init_load();
|
|
19568
19812
|
init_cascade();
|
|
19569
19813
|
init_identity();
|
|
@@ -19580,6 +19824,7 @@ function candidateView(candidate) {
|
|
|
19580
19824
|
feasible: candidate.feasible,
|
|
19581
19825
|
...candidate.blockedUntilMs === void 0 ? {} : { blockedUntil: new Date(candidate.blockedUntilMs).toISOString() },
|
|
19582
19826
|
plan: candidate.plan,
|
|
19827
|
+
...candidate.provider === void 0 ? {} : { provider: candidate.provider },
|
|
19583
19828
|
reasons: [...candidate.reasons]
|
|
19584
19829
|
};
|
|
19585
19830
|
}
|
|
@@ -19593,6 +19838,7 @@ function collectPoolPick(params) {
|
|
|
19593
19838
|
nowMs: params.nowMs,
|
|
19594
19839
|
resuming: false,
|
|
19595
19840
|
identityIdOf: identityIdResolver(params.paths.identitiesDir, params.fs),
|
|
19841
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf },
|
|
19596
19842
|
...sticky.sticky === void 0 ? {} : { sticky: sticky.sticky }
|
|
19597
19843
|
});
|
|
19598
19844
|
return {
|
|
@@ -19607,6 +19853,29 @@ function collectPoolPick(params) {
|
|
|
19607
19853
|
};
|
|
19608
19854
|
}
|
|
19609
19855
|
|
|
19856
|
+
// src/poolProviderWiring.ts
|
|
19857
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
19858
|
+
init_load();
|
|
19859
|
+
init_cascade();
|
|
19860
|
+
init_memberProvider();
|
|
19861
|
+
init_realPorts();
|
|
19862
|
+
function realMemberProviderResolver(params) {
|
|
19863
|
+
const home = import_node_os3.default.homedir();
|
|
19864
|
+
const read = cosmiconfigReader();
|
|
19865
|
+
const loaded = params.loaded ?? loadCascadeInput({ paths: params.paths, home, cwd: params.cwd, read });
|
|
19866
|
+
const selections = readDirectorySelections(loaded);
|
|
19867
|
+
return memberProviderResolver({
|
|
19868
|
+
paths: params.paths,
|
|
19869
|
+
fs: realFsPort,
|
|
19870
|
+
env: params.env,
|
|
19871
|
+
cliProvider: params.cliProvider,
|
|
19872
|
+
...params.cliFlagConfigProfile === void 0 ? {} : { cliFlagConfigProfile: params.cliFlagConfigProfile },
|
|
19873
|
+
...selections.configProfile === void 0 ? {} : { directoryRuleConfigProfile: selections.configProfile },
|
|
19874
|
+
...loaded.globalConfig?.defaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: loaded.globalConfig.defaultConfigProfile },
|
|
19875
|
+
loadCascade: (baseConfigProfile) => loadCascadeInput({ paths: params.paths, home, cwd: params.cwd, read, ...baseConfigProfile === void 0 ? {} : { baseConfigProfile } }).input
|
|
19876
|
+
});
|
|
19877
|
+
}
|
|
19878
|
+
|
|
19610
19879
|
// src/launchSelection.ts
|
|
19611
19880
|
init_poolStore();
|
|
19612
19881
|
init_realPorts();
|
|
@@ -19632,7 +19901,8 @@ function selectLaunch(params, loaded) {
|
|
|
19632
19901
|
if (pools[decidedIdentity.pool] === void 0) {
|
|
19633
19902
|
throw new PoolNotFoundError(decidedIdentity.pool);
|
|
19634
19903
|
}
|
|
19635
|
-
|
|
19904
|
+
const providerOf = realMemberProviderResolver({ paths, cwd, env: params.env, ...params.configProfile === void 0 ? {} : { cliFlagConfigProfile: params.configProfile }, loaded });
|
|
19905
|
+
poolPick = collectPoolPick({ paths, fs: realFsPort, usageFs: realFarmFs, poolName: decidedIdentity.pool, pools, directory: cwd, nowMs: Date.now(), providerOf });
|
|
19636
19906
|
}
|
|
19637
19907
|
const identity = poolPick?.pick === void 0 ? decidedIdentity : { ...decidedIdentity, name: poolPick.pick };
|
|
19638
19908
|
const loadedIdentity = identity.name === void 0 ? void 0 : loadIdentity(paths.identitiesDir, identity.name, realFsPort);
|
|
@@ -19649,7 +19919,7 @@ function selectLaunch(params, loaded) {
|
|
|
19649
19919
|
};
|
|
19650
19920
|
}
|
|
19651
19921
|
function resolveLaunchSelection(params) {
|
|
19652
|
-
const loaded = loadCascadeInput({ paths: params.paths, home:
|
|
19922
|
+
const loaded = loadCascadeInput({ paths: params.paths, home: import_node_os4.default.homedir(), cwd: params.cwd, read: cosmiconfigReader() });
|
|
19653
19923
|
return selectLaunch(params, loaded).selection;
|
|
19654
19924
|
}
|
|
19655
19925
|
|
|
@@ -19989,7 +20259,7 @@ function loadCheckProvider(paths, name) {
|
|
|
19989
20259
|
}
|
|
19990
20260
|
function collectCheckReport(params) {
|
|
19991
20261
|
const { paths, cwd } = params;
|
|
19992
|
-
const home =
|
|
20262
|
+
const home = import_node_os6.default.homedir();
|
|
19993
20263
|
const read = cosmiconfigReader();
|
|
19994
20264
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
19995
20265
|
const git = resolveGitBranch(realRunPort, cwd);
|
|
@@ -20125,6 +20395,8 @@ var PoolPickCandidateViewSchema = import_zod28.z.strictObject({
|
|
|
20125
20395
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
20126
20396
|
blockedUntil: import_zod28.z.iso.datetime().optional(),
|
|
20127
20397
|
plan: PlanClassSchema,
|
|
20398
|
+
/** The provider the member was ranked on, when its launch spends one in place of its Claude account: its windows, refusals and plan are the provider's own. Absent when ranked on the Claude account. */
|
|
20399
|
+
provider: import_zod28.z.string().optional(),
|
|
20128
20400
|
/** The facts behind the class and score, in the order they matter. */
|
|
20129
20401
|
reasons: import_zod28.z.array(import_zod28.z.string())
|
|
20130
20402
|
});
|
|
@@ -22292,6 +22564,8 @@ var LaunchResolveInputSchema = import_zod41.z.strictObject({
|
|
|
22292
22564
|
var LaunchPoolDecisionSchema = import_zod41.z.strictObject({
|
|
22293
22565
|
name: import_zod41.z.string(),
|
|
22294
22566
|
reasons: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
22567
|
+
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
22568
|
+
provider: import_zod41.z.string().optional(),
|
|
22295
22569
|
movedOff: import_zod41.z.strictObject({ identity: import_zod41.z.string(), reason: import_zod41.z.string() }).optional()
|
|
22296
22570
|
});
|
|
22297
22571
|
var LaunchDecisionSchema = import_zod41.z.strictObject({
|
|
@@ -23042,7 +23316,7 @@ function createDoorHealthPublisher(hub, now, pid) {
|
|
|
23042
23316
|
}
|
|
23043
23317
|
|
|
23044
23318
|
// src/frontdoor/quotaExpiringEvents.ts
|
|
23045
|
-
|
|
23319
|
+
init_windowLengths();
|
|
23046
23320
|
var FINAL_SPAN_DENOMINATOR = 30;
|
|
23047
23321
|
var QUOTA_EXPIRING_WINDOW_FRACTION = 1 / FINAL_SPAN_DENOMINATOR;
|
|
23048
23322
|
function createQuotaExpiringPublisher(hub, deps) {
|
|
@@ -25343,7 +25617,7 @@ init_launcher();
|
|
|
25343
25617
|
init_launchWiring();
|
|
25344
25618
|
|
|
25345
25619
|
// src/poolUsageRefresh.ts
|
|
25346
|
-
var
|
|
25620
|
+
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
25347
25621
|
init_load();
|
|
25348
25622
|
init_launchWiring();
|
|
25349
25623
|
init_argv();
|
|
@@ -25357,7 +25631,8 @@ async function refreshStalePoolMembers(params) {
|
|
|
25357
25631
|
if (identities.size === 0) {
|
|
25358
25632
|
return;
|
|
25359
25633
|
}
|
|
25360
|
-
|
|
25634
|
+
const members = params.loadMembers([...identities]).filter((member) => member.provider === void 0 && member.providerError === void 0);
|
|
25635
|
+
await params.refresher.refreshStale(members);
|
|
25361
25636
|
}
|
|
25362
25637
|
|
|
25363
25638
|
// src/poolUsageRefresh.ts
|
|
@@ -25377,7 +25652,7 @@ async function refreshPools(params) {
|
|
|
25377
25652
|
await refreshStalePoolMembers({
|
|
25378
25653
|
poolNames: params.poolNames,
|
|
25379
25654
|
pools: readPools(paths),
|
|
25380
|
-
loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now(), (name) => identityIdOf(paths, name)),
|
|
25655
|
+
loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now(), (name) => identityIdOf(paths, name), params.providerOf),
|
|
25381
25656
|
refresher
|
|
25382
25657
|
});
|
|
25383
25658
|
}
|
|
@@ -25399,12 +25674,13 @@ async function refreshPoolUsage(params) {
|
|
|
25399
25674
|
poolNames: params.poolNames,
|
|
25400
25675
|
spawnDaemon: daemonSpawnerFor(params.agentShim),
|
|
25401
25676
|
log: params.log ?? (() => void 0),
|
|
25402
|
-
...params.refresher === void 0 ? {} : { refresher: params.refresher }
|
|
25677
|
+
...params.refresher === void 0 ? {} : { refresher: params.refresher },
|
|
25678
|
+
...params.providerOf === void 0 ? {} : { providerOf: params.providerOf }
|
|
25403
25679
|
});
|
|
25404
25680
|
}
|
|
25405
25681
|
function poolSelectedByLaunch(options) {
|
|
25406
25682
|
const paths = options.paths ?? resolveLayoutPaths();
|
|
25407
|
-
const loaded = loadCascadeInput({ paths, home:
|
|
25683
|
+
const loaded = loadCascadeInput({ paths, home: import_node_os13.default.homedir(), cwd: options.cwd, read: cosmiconfigReader() });
|
|
25408
25684
|
return decideIdentity({
|
|
25409
25685
|
env: options.env,
|
|
25410
25686
|
argv0Identity: parseLauncherArgv(options.argv).identity,
|
|
@@ -25414,8 +25690,12 @@ function poolSelectedByLaunch(options) {
|
|
|
25414
25690
|
}
|
|
25415
25691
|
async function refreshLaunchPoolUsage(options) {
|
|
25416
25692
|
const pool = poolSelectedByLaunch(options);
|
|
25693
|
+
const paths = options.paths ?? resolveLayoutPaths();
|
|
25694
|
+
const parsed = parseLauncherArgv(options.argv);
|
|
25417
25695
|
await refreshPoolUsage({
|
|
25418
|
-
|
|
25696
|
+
paths,
|
|
25697
|
+
// The provider each member's launch will spend, resolved as the launch resolves it, so a launch through a provider probes no Claude account.
|
|
25698
|
+
...pool === void 0 ? {} : { providerOf: realMemberProviderResolver({ paths, cwd: options.cwd, env: options.env, ...parsed.provider === void 0 ? {} : { cliProvider: parsed.provider }, ...parsed.configProfile === void 0 ? {} : { cliFlagConfigProfile: parsed.configProfile } }) },
|
|
25419
25699
|
cwd: options.cwd,
|
|
25420
25700
|
poolNames: pool === void 0 ? [] : [pool],
|
|
25421
25701
|
...options.agentShim === void 0 ? {} : { agentShim: options.agentShim },
|
|
@@ -25788,6 +26068,7 @@ init_ownCli();
|
|
|
25788
26068
|
realCodexAppServerPort,
|
|
25789
26069
|
realConnectCertStore,
|
|
25790
26070
|
realConnectEffects,
|
|
26071
|
+
realMemberProviderResolver,
|
|
25791
26072
|
realRcControlTransport,
|
|
25792
26073
|
realRcEventDial,
|
|
25793
26074
|
realRcStreamDial,
|