claude-use 12.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +295 -253
- package/dist/index.cjs +422 -380
- package/dist/index.mjs +406 -364
- package/dist/types/index.d.ts +9 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6663,11 +6663,226 @@ var init_blockingSpawn = __esm({
|
|
|
6663
6663
|
}
|
|
6664
6664
|
});
|
|
6665
6665
|
|
|
6666
|
-
// src/
|
|
6666
|
+
// src/headroom/headers.ts
|
|
6667
|
+
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
6668
|
+
const merged = /* @__PURE__ */ new Map();
|
|
6669
|
+
for (const block of existing) {
|
|
6670
|
+
if (block === void 0) {
|
|
6671
|
+
continue;
|
|
6672
|
+
}
|
|
6673
|
+
for (const line of block.split("\n")) {
|
|
6674
|
+
const entry = parseCustomHeaderLine(line);
|
|
6675
|
+
if (entry === void 0) {
|
|
6676
|
+
continue;
|
|
6677
|
+
}
|
|
6678
|
+
merged.set(entry.name, entry.value);
|
|
6679
|
+
}
|
|
6680
|
+
}
|
|
6681
|
+
for (const entry of additions) {
|
|
6682
|
+
merged.set(entry.name, entry.value);
|
|
6683
|
+
}
|
|
6684
|
+
return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
|
|
6685
|
+
}
|
|
6686
|
+
function parseAnthropicCustomHeaders(block) {
|
|
6687
|
+
return block.split("\n").flatMap((line) => {
|
|
6688
|
+
const entry = parseCustomHeaderLine(line);
|
|
6689
|
+
return entry === void 0 ? [] : [entry];
|
|
6690
|
+
});
|
|
6691
|
+
}
|
|
6692
|
+
function withoutAnthropicCustomHeaders(block, remove) {
|
|
6693
|
+
const lines = block.split("\n");
|
|
6694
|
+
const kept = lines.filter((line) => {
|
|
6695
|
+
const entry = parseCustomHeaderLine(line);
|
|
6696
|
+
return entry === void 0 || !remove(entry);
|
|
6697
|
+
});
|
|
6698
|
+
return kept.length === lines.length ? block : kept.join("\n");
|
|
6699
|
+
}
|
|
6700
|
+
function parseCustomHeaderLine(line) {
|
|
6701
|
+
const trimmed = line.trim();
|
|
6702
|
+
if (trimmed === "") {
|
|
6703
|
+
return void 0;
|
|
6704
|
+
}
|
|
6705
|
+
const colon = trimmed.indexOf(":");
|
|
6706
|
+
if (colon <= 0) {
|
|
6707
|
+
return void 0;
|
|
6708
|
+
}
|
|
6709
|
+
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
6710
|
+
}
|
|
6711
|
+
var init_headers = __esm({
|
|
6712
|
+
"src/headroom/headers.ts"() {
|
|
6713
|
+
"use strict";
|
|
6714
|
+
}
|
|
6715
|
+
});
|
|
6716
|
+
|
|
6717
|
+
// src/launcher/injected.ts
|
|
6667
6718
|
import { createHash as createHash4 } from "node:crypto";
|
|
6719
|
+
import { z as z14 } from "zod";
|
|
6720
|
+
function listKey(list) {
|
|
6721
|
+
return `${list},appended`;
|
|
6722
|
+
}
|
|
6723
|
+
function digest2(value) {
|
|
6724
|
+
return createHash4("sha256").update(value).digest("hex");
|
|
6725
|
+
}
|
|
6726
|
+
function recordedDigests(env) {
|
|
6727
|
+
const raw = env[INJECTED_ENV];
|
|
6728
|
+
if (raw === void 0 || raw === "") {
|
|
6729
|
+
return {};
|
|
6730
|
+
}
|
|
6731
|
+
let parsed;
|
|
6732
|
+
try {
|
|
6733
|
+
parsed = JSON.parse(raw);
|
|
6734
|
+
} catch {
|
|
6735
|
+
return {};
|
|
6736
|
+
}
|
|
6737
|
+
const result = InjectedSchema.safeParse(parsed);
|
|
6738
|
+
return result.success ? result.data : {};
|
|
6739
|
+
}
|
|
6740
|
+
function recordInjections(base) {
|
|
6741
|
+
const env = { ...base };
|
|
6742
|
+
const digests = new Map(Object.entries(recordedDigests(env)));
|
|
6743
|
+
return {
|
|
6744
|
+
env,
|
|
6745
|
+
set: (name, value) => {
|
|
6746
|
+
env[name] = value;
|
|
6747
|
+
digests.set(name, digest2(value));
|
|
6748
|
+
},
|
|
6749
|
+
unset: (name) => {
|
|
6750
|
+
env[name] = void 0;
|
|
6751
|
+
digests.delete(name);
|
|
6752
|
+
},
|
|
6753
|
+
recordHeaders: (names) => {
|
|
6754
|
+
const block = env[CUSTOM_HEADERS_ENV];
|
|
6755
|
+
for (const entry of block === void 0 ? [] : parseAnthropicCustomHeaders(block)) {
|
|
6756
|
+
if (names.includes(entry.name)) {
|
|
6757
|
+
digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
},
|
|
6761
|
+
recordBypassHosts: (list, hosts) => {
|
|
6762
|
+
const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
|
|
6763
|
+
if (recordedHosts.length > 0) {
|
|
6764
|
+
digests.set(listKey(list), recordedHosts.join(","));
|
|
6765
|
+
}
|
|
6766
|
+
},
|
|
6767
|
+
finish: () => {
|
|
6768
|
+
if (digests.size > 0) {
|
|
6769
|
+
env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
};
|
|
6773
|
+
}
|
|
6774
|
+
function withoutRecordedHosts(list, value, digests) {
|
|
6775
|
+
const recordedHosts = new Set(digests[listKey(list)]?.split(","));
|
|
6776
|
+
const entries = value.split(",");
|
|
6777
|
+
const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
|
|
6778
|
+
return kept.length === entries.length ? value : kept.join(",");
|
|
6779
|
+
}
|
|
6780
|
+
function launchEnvironment(env, configDirEscapeHatch) {
|
|
6781
|
+
return configDirEscapeHatch ? env : withoutInjected(env);
|
|
6782
|
+
}
|
|
6783
|
+
function withoutInjected(env) {
|
|
6784
|
+
const digests = recordedDigests(env);
|
|
6785
|
+
const entries = Object.entries(env).flatMap(([name, value]) => {
|
|
6786
|
+
if (name === INJECTED_ENV) {
|
|
6787
|
+
return [];
|
|
6788
|
+
}
|
|
6789
|
+
if (value === void 0) {
|
|
6790
|
+
return [[name, value]];
|
|
6791
|
+
}
|
|
6792
|
+
if (name === CUSTOM_HEADERS_ENV) {
|
|
6793
|
+
const remaining = withoutAnthropicCustomHeaders(value, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
|
|
6794
|
+
return remaining !== value && remaining.trim() === "" ? [] : [[name, remaining]];
|
|
6795
|
+
}
|
|
6796
|
+
if (name === "NO_PROXY" || name === "no_proxy") {
|
|
6797
|
+
const remaining = withoutRecordedHosts(name, value, digests);
|
|
6798
|
+
return remaining !== value && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
|
|
6799
|
+
}
|
|
6800
|
+
return digests[name] === digest2(value) ? [] : [[name, value]];
|
|
6801
|
+
});
|
|
6802
|
+
return Object.fromEntries(entries);
|
|
6803
|
+
}
|
|
6804
|
+
var INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
6805
|
+
var init_injected = __esm({
|
|
6806
|
+
"src/launcher/injected.ts"() {
|
|
6807
|
+
"use strict";
|
|
6808
|
+
init_headers();
|
|
6809
|
+
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
6810
|
+
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
6811
|
+
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
6812
|
+
InjectedSchema = z14.record(z14.string(), z14.string());
|
|
6813
|
+
}
|
|
6814
|
+
});
|
|
6815
|
+
|
|
6816
|
+
// src/launcher/guard.ts
|
|
6817
|
+
function detectAmbientCredential(env, injected) {
|
|
6818
|
+
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
6819
|
+
const value = env[variable];
|
|
6820
|
+
if (value === void 0 || value === "") {
|
|
6821
|
+
continue;
|
|
6822
|
+
}
|
|
6823
|
+
if (injected?.variable === variable && value === injected.token) {
|
|
6824
|
+
continue;
|
|
6825
|
+
}
|
|
6826
|
+
return { variable };
|
|
6827
|
+
}
|
|
6828
|
+
return void 0;
|
|
6829
|
+
}
|
|
6830
|
+
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
6831
|
+
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
6832
|
+
return [
|
|
6833
|
+
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
6834
|
+
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
6835
|
+
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
6836
|
+
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
6837
|
+
`\`${identitySetCommand}\`.`
|
|
6838
|
+
].join("\n");
|
|
6839
|
+
}
|
|
6840
|
+
function evaluateAmbientCredentialGuard(params) {
|
|
6841
|
+
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
6842
|
+
if (detected === void 0) {
|
|
6843
|
+
return { ok: true };
|
|
6844
|
+
}
|
|
6845
|
+
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
6846
|
+
return { ok: true };
|
|
6847
|
+
}
|
|
6848
|
+
return {
|
|
6849
|
+
ok: false,
|
|
6850
|
+
variable: detected.variable,
|
|
6851
|
+
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
6852
|
+
};
|
|
6853
|
+
}
|
|
6854
|
+
function ambientCredentialFinding(env) {
|
|
6855
|
+
const named = detectAmbientCredential(launchEnvironment(env, false));
|
|
6856
|
+
if (named !== void 0) {
|
|
6857
|
+
return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
|
|
6858
|
+
}
|
|
6859
|
+
const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
|
|
6860
|
+
if (bare !== void 0) {
|
|
6861
|
+
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>\`.` };
|
|
6862
|
+
}
|
|
6863
|
+
return { severity: "pass", message: "No ambient-credential environment variable is set." };
|
|
6864
|
+
}
|
|
6865
|
+
var AMBIENT_CREDENTIAL_VARS;
|
|
6866
|
+
var init_guard = __esm({
|
|
6867
|
+
"src/launcher/guard.ts"() {
|
|
6868
|
+
"use strict";
|
|
6869
|
+
init_injected();
|
|
6870
|
+
AMBIENT_CREDENTIAL_VARS = [
|
|
6871
|
+
"ANTHROPIC_API_KEY",
|
|
6872
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
6873
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
6874
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
6875
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
6876
|
+
"CLAUDE_CODE_USE_FOUNDRY"
|
|
6877
|
+
];
|
|
6878
|
+
}
|
|
6879
|
+
});
|
|
6880
|
+
|
|
6881
|
+
// src/usage/signIn.ts
|
|
6882
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
6668
6883
|
import path19 from "node:path";
|
|
6669
6884
|
function claudeCodeKeychainService(configDir) {
|
|
6670
|
-
return `${KEYCHAIN_SERVICE_PREFIX}-${
|
|
6885
|
+
return `${KEYCHAIN_SERVICE_PREFIX}-${createHash5("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
|
|
6671
6886
|
}
|
|
6672
6887
|
function keychainHasItem(run, configDir) {
|
|
6673
6888
|
return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
|
|
@@ -6700,13 +6915,33 @@ function identitySignIn(fs17, probe, identity) {
|
|
|
6700
6915
|
platform: probe.platform
|
|
6701
6916
|
});
|
|
6702
6917
|
}
|
|
6703
|
-
|
|
6918
|
+
function storedLoginUsable(run, claudeBin, configDir, env) {
|
|
6919
|
+
const childEnv = { ...env, CLAUDE_CONFIG_DIR: configDir };
|
|
6920
|
+
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
6921
|
+
childEnv[variable] = void 0;
|
|
6922
|
+
}
|
|
6923
|
+
const result = run.run(claudeBin, ["auth", "status"], void 0, { env: childEnv, timeoutMs: AUTH_STATUS_TIMEOUT_MS });
|
|
6924
|
+
if (result.status === null) {
|
|
6925
|
+
return void 0;
|
|
6926
|
+
}
|
|
6927
|
+
try {
|
|
6928
|
+
const status = JSON.parse(result.stdout);
|
|
6929
|
+
if (typeof status === "object" && status !== null && "loggedIn" in status && typeof status.loggedIn === "boolean") {
|
|
6930
|
+
return status.loggedIn;
|
|
6931
|
+
}
|
|
6932
|
+
} catch {
|
|
6933
|
+
}
|
|
6934
|
+
return void 0;
|
|
6935
|
+
}
|
|
6936
|
+
var CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS, AUTH_STATUS_TIMEOUT_MS;
|
|
6704
6937
|
var init_signIn = __esm({
|
|
6705
6938
|
"src/usage/signIn.ts"() {
|
|
6706
6939
|
"use strict";
|
|
6940
|
+
init_guard();
|
|
6707
6941
|
CREDENTIALS_FILE = ".credentials.json";
|
|
6708
6942
|
KEYCHAIN_SERVICE_PREFIX = "Claude Code-credentials";
|
|
6709
6943
|
KEYCHAIN_SERVICE_HASH_DIGITS = 8;
|
|
6944
|
+
AUTH_STATUS_TIMEOUT_MS = 1e4;
|
|
6710
6945
|
}
|
|
6711
6946
|
});
|
|
6712
6947
|
|
|
@@ -7071,9 +7306,9 @@ var init_supervisorProcesses = __esm({
|
|
|
7071
7306
|
});
|
|
7072
7307
|
|
|
7073
7308
|
// src/headroom/state.ts
|
|
7074
|
-
import { createHash as
|
|
7309
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
7075
7310
|
import path21 from "node:path";
|
|
7076
|
-
import { z as
|
|
7311
|
+
import { z as z15 } from "zod";
|
|
7077
7312
|
function parseJson(raw, schema) {
|
|
7078
7313
|
if (raw === void 0 || raw.trim() === "") {
|
|
7079
7314
|
return void 0;
|
|
@@ -7120,7 +7355,7 @@ function migrateHeadroomState(fs17, files, isRunning) {
|
|
|
7120
7355
|
fs17.removeRecursive(files.legacyStateFile);
|
|
7121
7356
|
}
|
|
7122
7357
|
function hashAllowlist(allowlist) {
|
|
7123
|
-
return
|
|
7358
|
+
return createHash6("sha256").update(allowlist.join("\n")).digest("hex");
|
|
7124
7359
|
}
|
|
7125
7360
|
function formatAllowlistFile(allowlist) {
|
|
7126
7361
|
return allowlist.map((entry) => `${entry}
|
|
@@ -7230,32 +7465,32 @@ var init_state2 = __esm({
|
|
|
7230
7465
|
"src/headroom/state.ts"() {
|
|
7231
7466
|
"use strict";
|
|
7232
7467
|
init_schema();
|
|
7233
|
-
HeadroomStateSchema =
|
|
7468
|
+
HeadroomStateSchema = z15.strictObject({
|
|
7234
7469
|
/** The supervisor process owning the daemon. Alive means someone is keeping headroom running. */
|
|
7235
|
-
supervisorPid:
|
|
7470
|
+
supervisorPid: z15.number().int().positive().optional(),
|
|
7236
7471
|
/** 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. */
|
|
7237
|
-
headroomPid:
|
|
7472
|
+
headroomPid: z15.number().int().positive().optional(),
|
|
7238
7473
|
/**
|
|
7239
7474
|
* 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.
|
|
7240
7475
|
*/
|
|
7241
|
-
socketPath:
|
|
7476
|
+
socketPath: z15.string().min(1).optional(),
|
|
7242
7477
|
/** The `headroom --version` output of the running install. */
|
|
7243
|
-
version:
|
|
7478
|
+
version: z15.string().optional(),
|
|
7244
7479
|
/**
|
|
7245
7480
|
* 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`).
|
|
7246
7481
|
*/
|
|
7247
|
-
allowlistHash:
|
|
7482
|
+
allowlistHash: z15.string().optional(),
|
|
7248
7483
|
/** Hash of the token-saving settings the running proxy was started with, so a settings change is detected as drift. */
|
|
7249
|
-
settingsHash:
|
|
7484
|
+
settingsHash: z15.string().optional(),
|
|
7250
7485
|
/** The install spec the running install was last installed from, so a `source` config change is detected as drift. */
|
|
7251
|
-
installedSource:
|
|
7486
|
+
installedSource: z15.string().optional(),
|
|
7252
7487
|
/** 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. */
|
|
7253
|
-
installing:
|
|
7488
|
+
installing: z15.string().optional(),
|
|
7254
7489
|
/** The last fatal error, kept across shutdowns so `headroom status` can explain a daemon that is not running. */
|
|
7255
|
-
lastError:
|
|
7490
|
+
lastError: z15.string().optional()
|
|
7256
7491
|
});
|
|
7257
|
-
HeadroomSessionSchema =
|
|
7258
|
-
HeadroomLockSchema =
|
|
7492
|
+
HeadroomSessionSchema = z15.strictObject({ pid: z15.number().int().positive(), startedAt: z15.number(), supervisorPid: z15.number().int().positive() });
|
|
7493
|
+
HeadroomLockSchema = z15.strictObject({ pid: z15.number().int().positive(), at: z15.number() });
|
|
7259
7494
|
HEADROOM_ALLOWLIST_FILE_FLAG = "--allowed-base-urls-file";
|
|
7260
7495
|
ALLOWLIST_LINE_BREAKS = "\\n\\r\\u000b\\u000c\\u001c\\u001d\\u001e\\u0085\\u2028\\u2029";
|
|
7261
7496
|
ALLOWLIST_WHITESPACE = "\\t\\n\\u000b\\u000c\\r\\u001c-\\u001f \\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
@@ -7445,7 +7680,7 @@ var init_ensure = __esm({
|
|
|
7445
7680
|
});
|
|
7446
7681
|
|
|
7447
7682
|
// src/headroom/settings.ts
|
|
7448
|
-
import { createHash as
|
|
7683
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
7449
7684
|
function settingsOf(config) {
|
|
7450
7685
|
return {
|
|
7451
7686
|
...config.mode === void 0 ? {} : { mode: config.mode },
|
|
@@ -7470,7 +7705,7 @@ function settingsEnv(settings) {
|
|
|
7470
7705
|
return settings.rolloutChannel === void 0 ? {} : { HEADROOM_ROLLOUT_CHANNEL: settings.rolloutChannel };
|
|
7471
7706
|
}
|
|
7472
7707
|
function hashSettings(settings) {
|
|
7473
|
-
return
|
|
7708
|
+
return createHash7("sha256").update(JSON.stringify([...settingsArgs(settings), JSON.stringify(settingsEnv(settings))])).digest("hex");
|
|
7474
7709
|
}
|
|
7475
7710
|
var init_settings = __esm({
|
|
7476
7711
|
"src/headroom/settings.ts"() {
|
|
@@ -7662,7 +7897,7 @@ var init_socket = __esm({
|
|
|
7662
7897
|
});
|
|
7663
7898
|
|
|
7664
7899
|
// src/headroom/source.ts
|
|
7665
|
-
import { z as
|
|
7900
|
+
import { z as z16 } from "zod";
|
|
7666
7901
|
function isMovingGitSource(spec) {
|
|
7667
7902
|
const match = GIT_SPEC_RE.exec(spec);
|
|
7668
7903
|
if (match === null) {
|
|
@@ -7681,7 +7916,7 @@ var init_source = __esm({
|
|
|
7681
7916
|
"use strict";
|
|
7682
7917
|
GIT_SPEC_RE = /git\+[^@\s]+(?:@([^\s#]+))?/;
|
|
7683
7918
|
COMMIT_SHA_RE = /^[0-9a-f]{40}$/i;
|
|
7684
|
-
DirectUrlSchema =
|
|
7919
|
+
DirectUrlSchema = z16.object({ vcs_info: z16.object({ commit_id: z16.string() }) });
|
|
7685
7920
|
}
|
|
7686
7921
|
});
|
|
7687
7922
|
|
|
@@ -8126,7 +8361,7 @@ var init_logStyle = __esm({
|
|
|
8126
8361
|
|
|
8127
8362
|
// src/realPorts.ts
|
|
8128
8363
|
import { execFile, spawn } from "node:child_process";
|
|
8129
|
-
import { createHash as
|
|
8364
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
8130
8365
|
import fs6 from "node:fs";
|
|
8131
8366
|
import os2 from "node:os";
|
|
8132
8367
|
import path24 from "node:path";
|
|
@@ -8193,6 +8428,9 @@ function realFrontDoorLiveness(pids) {
|
|
|
8193
8428
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr, ...result.error === void 0 ? {} : { error: result.error } };
|
|
8194
8429
|
});
|
|
8195
8430
|
}
|
|
8431
|
+
function definedEntries(env) {
|
|
8432
|
+
return Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0));
|
|
8433
|
+
}
|
|
8196
8434
|
function realRunAsyncWithin(timeoutMs) {
|
|
8197
8435
|
return async (command, args) => await new Promise((resolve) => {
|
|
8198
8436
|
execFile(command, [...args], { encoding: "utf8", timeout: timeoutMs }, (error, stdout, stderr) => {
|
|
@@ -8553,7 +8791,7 @@ var init_realPorts = __esm({
|
|
|
8553
8791
|
},
|
|
8554
8792
|
hashFile(filePath) {
|
|
8555
8793
|
try {
|
|
8556
|
-
return
|
|
8794
|
+
return createHash8("sha256").update(fs6.readFileSync(filePath)).digest("hex");
|
|
8557
8795
|
} catch (error) {
|
|
8558
8796
|
if (isEnoent3(error) || isErrorWithCode(error, "EISDIR")) {
|
|
8559
8797
|
return void 0;
|
|
@@ -8593,8 +8831,14 @@ var init_realPorts = __esm({
|
|
|
8593
8831
|
BYTES_PER_MIB2 = 1048576;
|
|
8594
8832
|
RUN_OUTPUT_LIMIT_BYTES = RUN_OUTPUT_LIMIT_MIB * BYTES_PER_MIB2;
|
|
8595
8833
|
realRunPort = {
|
|
8596
|
-
run(command, args, input) {
|
|
8597
|
-
const result = spawnSyncBlocking("an external command", command, args, {
|
|
8834
|
+
run(command, args, input, options) {
|
|
8835
|
+
const result = spawnSyncBlocking("an external command", command, args, {
|
|
8836
|
+
encoding: "utf8",
|
|
8837
|
+
maxBuffer: RUN_OUTPUT_LIMIT_BYTES,
|
|
8838
|
+
...input === void 0 ? {} : { input },
|
|
8839
|
+
...options?.env === void 0 ? {} : { env: definedEntries(options.env) },
|
|
8840
|
+
...options?.timeoutMs === void 0 ? {} : { timeout: options.timeoutMs }
|
|
8841
|
+
});
|
|
8598
8842
|
return { status: result.status, stdout: result.stdout, stderr: result.stderr };
|
|
8599
8843
|
}
|
|
8600
8844
|
};
|
|
@@ -8995,7 +9239,7 @@ var init_candidateText = __esm({
|
|
|
8995
9239
|
});
|
|
8996
9240
|
|
|
8997
9241
|
// src/usage/plan.ts
|
|
8998
|
-
import { z as
|
|
9242
|
+
import { z as z17 } from "zod";
|
|
8999
9243
|
function planOf(account) {
|
|
9000
9244
|
const userTier = account?.userRateLimitTier;
|
|
9001
9245
|
if (userTier !== void 0 && ZERO_TIER.test(userTier)) {
|
|
@@ -9019,19 +9263,19 @@ var PlanClassSchema, TIER_MULTIPLIER, ZERO_TIER, BASE_TIER;
|
|
|
9019
9263
|
var init_plan2 = __esm({
|
|
9020
9264
|
"src/usage/plan.ts"() {
|
|
9021
9265
|
"use strict";
|
|
9022
|
-
PlanClassSchema =
|
|
9023
|
-
|
|
9024
|
-
kind:
|
|
9266
|
+
PlanClassSchema = z17.union([
|
|
9267
|
+
z17.strictObject({
|
|
9268
|
+
kind: z17.literal("subscription"),
|
|
9025
9269
|
/** The plan's size as a multiple of the smallest subscription tier (Max is 5, Ultra is 20). */
|
|
9026
|
-
capacity:
|
|
9270
|
+
capacity: z17.number().positive(),
|
|
9027
9271
|
/** False when the tier string named no multiplier and no tier this project knows, so `capacity` is the neutral 1 rather than a reading. */
|
|
9028
|
-
recognised:
|
|
9272
|
+
recognised: z17.boolean(),
|
|
9029
9273
|
/** The tier string the classification rests on, when the account had one. */
|
|
9030
|
-
tier:
|
|
9274
|
+
tier: z17.string().optional()
|
|
9031
9275
|
}),
|
|
9032
|
-
|
|
9033
|
-
kind:
|
|
9034
|
-
tier:
|
|
9276
|
+
z17.strictObject({
|
|
9277
|
+
kind: z17.literal("pay-per-use"),
|
|
9278
|
+
tier: z17.string().optional()
|
|
9035
9279
|
})
|
|
9036
9280
|
]);
|
|
9037
9281
|
TIER_MULTIPLIER = /(?:^|_)(\d+)x$/;
|
|
@@ -9041,21 +9285,21 @@ var init_plan2 = __esm({
|
|
|
9041
9285
|
});
|
|
9042
9286
|
|
|
9043
9287
|
// src/usage/scan.ts
|
|
9044
|
-
import { z as
|
|
9288
|
+
import { z as z18 } from "zod";
|
|
9045
9289
|
var AnthropicUsageSchema, ErrorObjectSchema;
|
|
9046
9290
|
var init_scan = __esm({
|
|
9047
9291
|
"src/usage/scan.ts"() {
|
|
9048
9292
|
"use strict";
|
|
9049
|
-
AnthropicUsageSchema =
|
|
9050
|
-
input_tokens:
|
|
9051
|
-
output_tokens:
|
|
9052
|
-
cache_creation_input_tokens:
|
|
9053
|
-
cache_read_input_tokens:
|
|
9293
|
+
AnthropicUsageSchema = z18.looseObject({
|
|
9294
|
+
input_tokens: z18.number().int().nonnegative().nullish(),
|
|
9295
|
+
output_tokens: z18.number().int().nonnegative().nullish(),
|
|
9296
|
+
cache_creation_input_tokens: z18.number().int().nonnegative().nullish(),
|
|
9297
|
+
cache_read_input_tokens: z18.number().int().nonnegative().nullish()
|
|
9054
9298
|
});
|
|
9055
|
-
ErrorObjectSchema =
|
|
9056
|
-
type:
|
|
9057
|
-
code:
|
|
9058
|
-
message:
|
|
9299
|
+
ErrorObjectSchema = z18.looseObject({
|
|
9300
|
+
type: z18.string().optional(),
|
|
9301
|
+
code: z18.union([z18.string(), z18.number()]).optional(),
|
|
9302
|
+
message: z18.string().optional()
|
|
9059
9303
|
});
|
|
9060
9304
|
}
|
|
9061
9305
|
});
|
|
@@ -9525,7 +9769,7 @@ var init_store2 = __esm({
|
|
|
9525
9769
|
|
|
9526
9770
|
// src/usage/poolPick.ts
|
|
9527
9771
|
import path26 from "node:path";
|
|
9528
|
-
import { z as
|
|
9772
|
+
import { z as z19 } from "zod";
|
|
9529
9773
|
function errorMessage(error) {
|
|
9530
9774
|
return error instanceof Error ? error.message : String(error);
|
|
9531
9775
|
}
|
|
@@ -9727,20 +9971,20 @@ var init_poolPick = __esm({
|
|
|
9727
9971
|
}
|
|
9728
9972
|
};
|
|
9729
9973
|
SCHEMA_VERSION = 1;
|
|
9730
|
-
PickEntrySchema =
|
|
9731
|
-
PicksFileSchema =
|
|
9732
|
-
schemaVersion:
|
|
9733
|
-
picks:
|
|
9974
|
+
PickEntrySchema = z19.strictObject({ identity: z19.string().min(1), at: z19.iso.datetime() });
|
|
9975
|
+
PicksFileSchema = z19.strictObject({
|
|
9976
|
+
schemaVersion: z19.literal(SCHEMA_VERSION),
|
|
9977
|
+
picks: z19.record(z19.string().min(1), PickEntrySchema)
|
|
9734
9978
|
});
|
|
9735
9979
|
}
|
|
9736
9980
|
});
|
|
9737
9981
|
|
|
9738
9982
|
// src/identityRenameJournal.ts
|
|
9739
|
-
import { createHash as
|
|
9983
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
9740
9984
|
import path27 from "node:path";
|
|
9741
|
-
import { z as
|
|
9985
|
+
import { z as z20 } from "zod";
|
|
9742
9986
|
function renamePairFileName(from, to, suffix) {
|
|
9743
|
-
return `${
|
|
9987
|
+
return `${createHash9("sha256").update(`${from}\0${to}`).digest("hex").slice(0, FILE_NAME_HASH_DIGITS)}${suffix}`;
|
|
9744
9988
|
}
|
|
9745
9989
|
function readRenameJournal(fs17, file) {
|
|
9746
9990
|
const raw = fs17.readFileUtf8(file);
|
|
@@ -9816,20 +10060,20 @@ var init_identityRenameJournal = __esm({
|
|
|
9816
10060
|
"src/identityRenameJournal.ts"() {
|
|
9817
10061
|
"use strict";
|
|
9818
10062
|
init_cliError();
|
|
9819
|
-
RenameJournalSchema =
|
|
9820
|
-
version:
|
|
9821
|
-
from:
|
|
9822
|
-
to:
|
|
9823
|
-
startedAt:
|
|
10063
|
+
RenameJournalSchema = z20.strictObject({
|
|
10064
|
+
version: z20.literal(1),
|
|
10065
|
+
from: z20.string().min(1),
|
|
10066
|
+
to: z20.string().min(1),
|
|
10067
|
+
startedAt: z20.iso.datetime(),
|
|
9824
10068
|
/** 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. */
|
|
9825
|
-
pid:
|
|
9826
|
-
steps:
|
|
9827
|
-
|
|
9828
|
-
description:
|
|
10069
|
+
pid: z20.number().int().positive(),
|
|
10070
|
+
steps: z20.array(
|
|
10071
|
+
z20.strictObject({
|
|
10072
|
+
description: z20.string().min(1),
|
|
9829
10073
|
/** Whether the step has been applied and marked so. */
|
|
9830
|
-
done:
|
|
10074
|
+
done: z20.boolean(),
|
|
9831
10075
|
/** 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. */
|
|
9832
|
-
started:
|
|
10076
|
+
started: z20.boolean()
|
|
9833
10077
|
})
|
|
9834
10078
|
)
|
|
9835
10079
|
});
|
|
@@ -9855,7 +10099,7 @@ var init_identityRenameJournal = __esm({
|
|
|
9855
10099
|
// src/identityNameRenameRecord.ts
|
|
9856
10100
|
import fs7 from "node:fs";
|
|
9857
10101
|
import path28 from "node:path";
|
|
9858
|
-
import { z as
|
|
10102
|
+
import { z as z21 } from "zod";
|
|
9859
10103
|
function readRecordFiles(paths) {
|
|
9860
10104
|
if (!fs7.existsSync(paths.identityNameRenamesDir)) {
|
|
9861
10105
|
return [];
|
|
@@ -9950,12 +10194,12 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9950
10194
|
init_poolPick();
|
|
9951
10195
|
init_identityRecords();
|
|
9952
10196
|
init_identityRenameJournal();
|
|
9953
|
-
NameRenameRecordSchema =
|
|
9954
|
-
version:
|
|
9955
|
-
id:
|
|
9956
|
-
from:
|
|
9957
|
-
to:
|
|
9958
|
-
startedAt:
|
|
10197
|
+
NameRenameRecordSchema = z21.strictObject({
|
|
10198
|
+
version: z21.literal(1),
|
|
10199
|
+
id: z21.string().min(1),
|
|
10200
|
+
from: z21.string().min(1),
|
|
10201
|
+
to: z21.string().min(1),
|
|
10202
|
+
startedAt: z21.iso.datetime()
|
|
9959
10203
|
});
|
|
9960
10204
|
RECORD_SUFFIX = ".json";
|
|
9961
10205
|
InterruptedNameRenameError = class extends CliError {
|
|
@@ -9970,7 +10214,7 @@ var init_identityNameRenameRecord = __esm({
|
|
|
9970
10214
|
// src/launcher/launchRecords.ts
|
|
9971
10215
|
import path29 from "node:path";
|
|
9972
10216
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
9973
|
-
import { z as
|
|
10217
|
+
import { z as z22 } from "zod";
|
|
9974
10218
|
function recordFile(directory, pid) {
|
|
9975
10219
|
return path29.join(directory, `${String(pid)}.${randomUUID4()}${RECORD_SUFFIX2}`);
|
|
9976
10220
|
}
|
|
@@ -10017,11 +10261,11 @@ var LaunchRecordSchema, RECORD_SUFFIX2;
|
|
|
10017
10261
|
var init_launchRecords = __esm({
|
|
10018
10262
|
"src/launcher/launchRecords.ts"() {
|
|
10019
10263
|
"use strict";
|
|
10020
|
-
LaunchRecordSchema =
|
|
10264
|
+
LaunchRecordSchema = z22.strictObject({
|
|
10021
10265
|
/** The launcher's process id, which is what tells a launch in progress from a record a crashed launcher left behind. */
|
|
10022
|
-
pid:
|
|
10023
|
-
identity:
|
|
10024
|
-
startedAt:
|
|
10266
|
+
pid: z22.number().int().positive(),
|
|
10267
|
+
identity: z22.string().min(1),
|
|
10268
|
+
startedAt: z22.iso.datetime()
|
|
10025
10269
|
});
|
|
10026
10270
|
RECORD_SUFFIX2 = ".json";
|
|
10027
10271
|
}
|
|
@@ -10492,7 +10736,7 @@ var init_package = __esm({
|
|
|
10492
10736
|
"package.json"() {
|
|
10493
10737
|
package_default = {
|
|
10494
10738
|
name: "claude-use",
|
|
10495
|
-
version: "12.0.
|
|
10739
|
+
version: "12.0.1",
|
|
10496
10740
|
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.",
|
|
10497
10741
|
license: "MIT",
|
|
10498
10742
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10838,7 +11082,7 @@ var init_paths = __esm({
|
|
|
10838
11082
|
});
|
|
10839
11083
|
|
|
10840
11084
|
// src/providerAliases.ts
|
|
10841
|
-
import { z as
|
|
11085
|
+
import { z as z26 } from "zod";
|
|
10842
11086
|
function parseAliases(file, raw) {
|
|
10843
11087
|
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
10844
11088
|
if (!parsed.success) {
|
|
@@ -10877,7 +11121,7 @@ var init_providerAliases = __esm({
|
|
|
10877
11121
|
init_cliError();
|
|
10878
11122
|
init_load();
|
|
10879
11123
|
init_store();
|
|
10880
|
-
ProviderAliasesSchema =
|
|
11124
|
+
ProviderAliasesSchema = z26.record(z26.string().min(1), z26.string().min(1));
|
|
10881
11125
|
}
|
|
10882
11126
|
});
|
|
10883
11127
|
|
|
@@ -11539,221 +11783,6 @@ var init_claudeVersion = __esm({
|
|
|
11539
11783
|
}
|
|
11540
11784
|
});
|
|
11541
11785
|
|
|
11542
|
-
// src/headroom/headers.ts
|
|
11543
|
-
function mergeAnthropicCustomHeaders(existing, additions) {
|
|
11544
|
-
const merged = /* @__PURE__ */ new Map();
|
|
11545
|
-
for (const block of existing) {
|
|
11546
|
-
if (block === void 0) {
|
|
11547
|
-
continue;
|
|
11548
|
-
}
|
|
11549
|
-
for (const line of block.split("\n")) {
|
|
11550
|
-
const entry = parseCustomHeaderLine(line);
|
|
11551
|
-
if (entry === void 0) {
|
|
11552
|
-
continue;
|
|
11553
|
-
}
|
|
11554
|
-
merged.set(entry.name, entry.value);
|
|
11555
|
-
}
|
|
11556
|
-
}
|
|
11557
|
-
for (const entry of additions) {
|
|
11558
|
-
merged.set(entry.name, entry.value);
|
|
11559
|
-
}
|
|
11560
|
-
return [...merged].map(([name, value]) => `${name}: ${value}`).join("\n");
|
|
11561
|
-
}
|
|
11562
|
-
function parseAnthropicCustomHeaders(block) {
|
|
11563
|
-
return block.split("\n").flatMap((line) => {
|
|
11564
|
-
const entry = parseCustomHeaderLine(line);
|
|
11565
|
-
return entry === void 0 ? [] : [entry];
|
|
11566
|
-
});
|
|
11567
|
-
}
|
|
11568
|
-
function withoutAnthropicCustomHeaders(block, remove) {
|
|
11569
|
-
const lines = block.split("\n");
|
|
11570
|
-
const kept = lines.filter((line) => {
|
|
11571
|
-
const entry = parseCustomHeaderLine(line);
|
|
11572
|
-
return entry === void 0 || !remove(entry);
|
|
11573
|
-
});
|
|
11574
|
-
return kept.length === lines.length ? block : kept.join("\n");
|
|
11575
|
-
}
|
|
11576
|
-
function parseCustomHeaderLine(line) {
|
|
11577
|
-
const trimmed = line.trim();
|
|
11578
|
-
if (trimmed === "") {
|
|
11579
|
-
return void 0;
|
|
11580
|
-
}
|
|
11581
|
-
const colon = trimmed.indexOf(":");
|
|
11582
|
-
if (colon <= 0) {
|
|
11583
|
-
return void 0;
|
|
11584
|
-
}
|
|
11585
|
-
return { name: trimmed.slice(0, colon).trim(), value: trimmed.slice(colon + 1).trim() };
|
|
11586
|
-
}
|
|
11587
|
-
var init_headers = __esm({
|
|
11588
|
-
"src/headroom/headers.ts"() {
|
|
11589
|
-
"use strict";
|
|
11590
|
-
}
|
|
11591
|
-
});
|
|
11592
|
-
|
|
11593
|
-
// src/launcher/injected.ts
|
|
11594
|
-
import { createHash as createHash9 } from "node:crypto";
|
|
11595
|
-
import { z as z26 } from "zod";
|
|
11596
|
-
function listKey(list) {
|
|
11597
|
-
return `${list},appended`;
|
|
11598
|
-
}
|
|
11599
|
-
function digest2(value) {
|
|
11600
|
-
return createHash9("sha256").update(value).digest("hex");
|
|
11601
|
-
}
|
|
11602
|
-
function recordedDigests(env) {
|
|
11603
|
-
const raw = env[INJECTED_ENV];
|
|
11604
|
-
if (raw === void 0 || raw === "") {
|
|
11605
|
-
return {};
|
|
11606
|
-
}
|
|
11607
|
-
let parsed;
|
|
11608
|
-
try {
|
|
11609
|
-
parsed = JSON.parse(raw);
|
|
11610
|
-
} catch {
|
|
11611
|
-
return {};
|
|
11612
|
-
}
|
|
11613
|
-
const result = InjectedSchema.safeParse(parsed);
|
|
11614
|
-
return result.success ? result.data : {};
|
|
11615
|
-
}
|
|
11616
|
-
function recordInjections(base) {
|
|
11617
|
-
const env = { ...base };
|
|
11618
|
-
const digests = new Map(Object.entries(recordedDigests(env)));
|
|
11619
|
-
return {
|
|
11620
|
-
env,
|
|
11621
|
-
set: (name, value) => {
|
|
11622
|
-
env[name] = value;
|
|
11623
|
-
digests.set(name, digest2(value));
|
|
11624
|
-
},
|
|
11625
|
-
unset: (name) => {
|
|
11626
|
-
env[name] = void 0;
|
|
11627
|
-
digests.delete(name);
|
|
11628
|
-
},
|
|
11629
|
-
recordHeaders: (names) => {
|
|
11630
|
-
const block = env[CUSTOM_HEADERS_ENV];
|
|
11631
|
-
for (const entry of block === void 0 ? [] : parseAnthropicCustomHeaders(block)) {
|
|
11632
|
-
if (names.includes(entry.name)) {
|
|
11633
|
-
digests.set(`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`, digest2(entry.value));
|
|
11634
|
-
}
|
|
11635
|
-
}
|
|
11636
|
-
},
|
|
11637
|
-
recordBypassHosts: (list, hosts) => {
|
|
11638
|
-
const recordedHosts = [.../* @__PURE__ */ new Set([...digests.get(listKey(list))?.split(",") ?? [], ...hosts.map((host) => host.trim().toLowerCase()).filter((host) => host !== "")])];
|
|
11639
|
-
if (recordedHosts.length > 0) {
|
|
11640
|
-
digests.set(listKey(list), recordedHosts.join(","));
|
|
11641
|
-
}
|
|
11642
|
-
},
|
|
11643
|
-
finish: () => {
|
|
11644
|
-
if (digests.size > 0) {
|
|
11645
|
-
env[INJECTED_ENV] = JSON.stringify(Object.fromEntries(digests));
|
|
11646
|
-
}
|
|
11647
|
-
}
|
|
11648
|
-
};
|
|
11649
|
-
}
|
|
11650
|
-
function withoutRecordedHosts(list, value, digests) {
|
|
11651
|
-
const recordedHosts = new Set(digests[listKey(list)]?.split(","));
|
|
11652
|
-
const entries = value.split(",");
|
|
11653
|
-
const kept = entries.filter((entry) => !recordedHosts.has(entry.trim().toLowerCase()));
|
|
11654
|
-
return kept.length === entries.length ? value : kept.join(",");
|
|
11655
|
-
}
|
|
11656
|
-
function launchEnvironment(env, configDirEscapeHatch) {
|
|
11657
|
-
return configDirEscapeHatch ? env : withoutInjected(env);
|
|
11658
|
-
}
|
|
11659
|
-
function withoutInjected(env) {
|
|
11660
|
-
const digests = recordedDigests(env);
|
|
11661
|
-
const entries = Object.entries(env).flatMap(([name, value]) => {
|
|
11662
|
-
if (name === INJECTED_ENV) {
|
|
11663
|
-
return [];
|
|
11664
|
-
}
|
|
11665
|
-
if (value === void 0) {
|
|
11666
|
-
return [[name, value]];
|
|
11667
|
-
}
|
|
11668
|
-
if (name === CUSTOM_HEADERS_ENV) {
|
|
11669
|
-
const remaining = withoutAnthropicCustomHeaders(value, (entry) => digests[`${HEADER_KEY_PREFIX}${entry.name.toLowerCase()}`] === digest2(entry.value));
|
|
11670
|
-
return remaining !== value && remaining.trim() === "" ? [] : [[name, remaining]];
|
|
11671
|
-
}
|
|
11672
|
-
if (name === "NO_PROXY" || name === "no_proxy") {
|
|
11673
|
-
const remaining = withoutRecordedHosts(name, value, digests);
|
|
11674
|
-
return remaining !== value && remaining.split(",").every((entry) => entry.trim() === "") ? [] : [[name, remaining]];
|
|
11675
|
-
}
|
|
11676
|
-
return digests[name] === digest2(value) ? [] : [[name, value]];
|
|
11677
|
-
});
|
|
11678
|
-
return Object.fromEntries(entries);
|
|
11679
|
-
}
|
|
11680
|
-
var INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
11681
|
-
var init_injected = __esm({
|
|
11682
|
-
"src/launcher/injected.ts"() {
|
|
11683
|
-
"use strict";
|
|
11684
|
-
init_headers();
|
|
11685
|
-
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
11686
|
-
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
11687
|
-
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
11688
|
-
InjectedSchema = z26.record(z26.string(), z26.string());
|
|
11689
|
-
}
|
|
11690
|
-
});
|
|
11691
|
-
|
|
11692
|
-
// src/launcher/guard.ts
|
|
11693
|
-
function detectAmbientCredential(env, injected) {
|
|
11694
|
-
for (const variable of AMBIENT_CREDENTIAL_VARS) {
|
|
11695
|
-
const value = env[variable];
|
|
11696
|
-
if (value === void 0 || value === "") {
|
|
11697
|
-
continue;
|
|
11698
|
-
}
|
|
11699
|
-
if (injected?.variable === variable && value === injected.token) {
|
|
11700
|
-
continue;
|
|
11701
|
-
}
|
|
11702
|
-
return { variable };
|
|
11703
|
-
}
|
|
11704
|
-
return void 0;
|
|
11705
|
-
}
|
|
11706
|
-
function formatAmbientCredentialGuardMessage(variable, identityName) {
|
|
11707
|
-
const identitySetCommand = identityName === void 0 ? "agent-shim identity set <name> --allow-ambient-credential" : `agent-shim identity set ${identityName} --allow-ambient-credential`;
|
|
11708
|
-
return [
|
|
11709
|
-
`error: ${variable} is set in the environment. This identity's isolated`,
|
|
11710
|
-
"credential would be bypassed \u2014 every identity authenticates as this same key",
|
|
11711
|
-
"while it's set. Unset it, or if this is deliberate, opt in per-launch with",
|
|
11712
|
-
"AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL=1, or persistently for this identity with",
|
|
11713
|
-
`\`${identitySetCommand}\`.`
|
|
11714
|
-
].join("\n");
|
|
11715
|
-
}
|
|
11716
|
-
function evaluateAmbientCredentialGuard(params) {
|
|
11717
|
-
const detected = detectAmbientCredential(params.env, params.injectedCredential);
|
|
11718
|
-
if (detected === void 0) {
|
|
11719
|
-
return { ok: true };
|
|
11720
|
-
}
|
|
11721
|
-
if (params.allowAmbientCredentialOverride || params.allowAmbientCredential || params.providerSelected === true) {
|
|
11722
|
-
return { ok: true };
|
|
11723
|
-
}
|
|
11724
|
-
return {
|
|
11725
|
-
ok: false,
|
|
11726
|
-
variable: detected.variable,
|
|
11727
|
-
message: formatAmbientCredentialGuardMessage(detected.variable, params.identityName)
|
|
11728
|
-
};
|
|
11729
|
-
}
|
|
11730
|
-
function ambientCredentialFinding(env) {
|
|
11731
|
-
const named = detectAmbientCredential(launchEnvironment(env, false));
|
|
11732
|
-
if (named !== void 0) {
|
|
11733
|
-
return { severity: "warn", message: formatAmbientCredentialGuardMessage(named.variable) };
|
|
11734
|
-
}
|
|
11735
|
-
const bare = env.CLAUDE_CONFIG_DIR === void 0 || env.CLAUDE_CONFIG_DIR === "" ? void 0 : detectAmbientCredential(env);
|
|
11736
|
-
if (bare !== void 0) {
|
|
11737
|
-
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>\`.` };
|
|
11738
|
-
}
|
|
11739
|
-
return { severity: "pass", message: "No ambient-credential environment variable is set." };
|
|
11740
|
-
}
|
|
11741
|
-
var AMBIENT_CREDENTIAL_VARS;
|
|
11742
|
-
var init_guard = __esm({
|
|
11743
|
-
"src/launcher/guard.ts"() {
|
|
11744
|
-
"use strict";
|
|
11745
|
-
init_injected();
|
|
11746
|
-
AMBIENT_CREDENTIAL_VARS = [
|
|
11747
|
-
"ANTHROPIC_API_KEY",
|
|
11748
|
-
"ANTHROPIC_AUTH_TOKEN",
|
|
11749
|
-
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
11750
|
-
"CLAUDE_CODE_USE_BEDROCK",
|
|
11751
|
-
"CLAUDE_CODE_USE_VERTEX",
|
|
11752
|
-
"CLAUDE_CODE_USE_FOUNDRY"
|
|
11753
|
-
];
|
|
11754
|
-
}
|
|
11755
|
-
});
|
|
11756
|
-
|
|
11757
11786
|
// src/usage/resets.ts
|
|
11758
11787
|
function formatPeriod(window) {
|
|
11759
11788
|
if (window.periodMs === void 0) {
|
|
@@ -14304,10 +14333,22 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
14304
14333
|
...parsedArgv.delay === void 0 ? {} : { delay: parsedArgv.delay }
|
|
14305
14334
|
}
|
|
14306
14335
|
});
|
|
14307
|
-
const loginlessProvider =
|
|
14336
|
+
const loginlessProvider = (() => {
|
|
14337
|
+
if (!requestedFlags.remoteControl || selectedProvider === void 0 || farmIdentity === void 0 || identityDecision.name === void 0) {
|
|
14338
|
+
return void 0;
|
|
14339
|
+
}
|
|
14340
|
+
const stored = params.hasStoredLogin?.(farmIdentity);
|
|
14341
|
+
if (stored === false) {
|
|
14342
|
+
return { identity: identityDecision.name, provider: selectedProvider.name, why: "has no stored login" };
|
|
14343
|
+
}
|
|
14344
|
+
if (stored === true && params.hasUsableLogin?.(farmIdentity, discovered.path) === false) {
|
|
14345
|
+
return { identity: identityDecision.name, provider: selectedProvider.name, why: "has a stored login that is no longer usable" };
|
|
14346
|
+
}
|
|
14347
|
+
return void 0;
|
|
14348
|
+
})();
|
|
14308
14349
|
const notes = [];
|
|
14309
14350
|
if (loginlessProvider !== void 0) {
|
|
14310
|
-
notes.push(`${loginlessProvider.identity}
|
|
14351
|
+
notes.push(`${loginlessProvider.identity} ${loginlessProvider.why}, so Remote Control is off; provider ${loginlessProvider.provider} runs without it`);
|
|
14311
14352
|
}
|
|
14312
14353
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
14313
14354
|
const globalModels = loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models;
|
|
@@ -14939,6 +14980,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
14939
14980
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
14940
14981
|
hold: realHoldPort,
|
|
14941
14982
|
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path54.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
14983
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, path54.join(paths.identitiesDir, identity), options.proc.env),
|
|
14942
14984
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
14943
14985
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
14944
14986
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -17975,19 +18017,19 @@ function realConnectEffects(ports = DOOR_SOURCE_PORTS) {
|
|
|
17975
18017
|
// src/frontdoor/rcSessionRegistry.ts
|
|
17976
18018
|
init_identityStore();
|
|
17977
18019
|
import path31 from "node:path";
|
|
17978
|
-
import { z as
|
|
18020
|
+
import { z as z23 } from "zod";
|
|
17979
18021
|
var REGISTRY_BRIDGE_PREFIX = "session_";
|
|
17980
18022
|
var DOOR_SESSION_PREFIX = "cse_";
|
|
17981
18023
|
var REGISTRY_DIR = "sessions";
|
|
17982
18024
|
var ENTRY_SUFFIX = ".json";
|
|
17983
18025
|
var RC_REGISTRY_ENTRY_MAX_BYTES = 8192;
|
|
17984
|
-
var RegistryEntrySchema =
|
|
17985
|
-
sessionId:
|
|
17986
|
-
pid:
|
|
17987
|
-
bridgeSessionId:
|
|
17988
|
-
cwd:
|
|
17989
|
-
name:
|
|
17990
|
-
updatedAt:
|
|
18026
|
+
var RegistryEntrySchema = z23.looseObject({
|
|
18027
|
+
sessionId: z23.string().min(1),
|
|
18028
|
+
pid: z23.int().positive(),
|
|
18029
|
+
bridgeSessionId: z23.union([z23.string().startsWith(REGISTRY_BRIDGE_PREFIX), z23.string().startsWith(DOOR_SESSION_PREFIX)]),
|
|
18030
|
+
cwd: z23.string().optional(),
|
|
18031
|
+
name: z23.string().optional(),
|
|
18032
|
+
updatedAt: z23.number().optional()
|
|
17991
18033
|
});
|
|
17992
18034
|
function supersedes(candidate, kept) {
|
|
17993
18035
|
return candidate.updatedAt > kept.updatedAt || candidate.updatedAt === kept.updatedAt && candidate.session.pid > kept.session.pid;
|
|
@@ -18194,7 +18236,7 @@ var COMPACT_TIMEOUT_MS = 9e5;
|
|
|
18194
18236
|
init_capability();
|
|
18195
18237
|
|
|
18196
18238
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18197
|
-
import { z as
|
|
18239
|
+
import { z as z24 } from "zod";
|
|
18198
18240
|
|
|
18199
18241
|
// src/frontdoor/rcSessionCommands.ts
|
|
18200
18242
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
@@ -18582,47 +18624,47 @@ function createRcSessionCommands(deps) {
|
|
|
18582
18624
|
}
|
|
18583
18625
|
|
|
18584
18626
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18585
|
-
var WaitMsSchema =
|
|
18586
|
-
var RcGoalSessionInputSchema =
|
|
18587
|
-
session:
|
|
18627
|
+
var WaitMsSchema = z24.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
18628
|
+
var RcGoalSessionInputSchema = z24.strictObject({
|
|
18629
|
+
session: z24.string().min(1),
|
|
18588
18630
|
waitMs: WaitMsSchema
|
|
18589
18631
|
});
|
|
18590
|
-
var RcGoalSetInputSchema =
|
|
18591
|
-
session:
|
|
18592
|
-
condition:
|
|
18632
|
+
var RcGoalSetInputSchema = z24.strictObject({
|
|
18633
|
+
session: z24.string().min(1),
|
|
18634
|
+
condition: z24.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
18593
18635
|
waitMs: WaitMsSchema
|
|
18594
18636
|
});
|
|
18595
|
-
var RcCompactInputSchema =
|
|
18596
|
-
session:
|
|
18637
|
+
var RcCompactInputSchema = z24.strictObject({
|
|
18638
|
+
session: z24.string().min(1),
|
|
18597
18639
|
waitMs: WaitMsSchema
|
|
18598
18640
|
});
|
|
18599
|
-
var RcCompactWithInstructionsInputSchema =
|
|
18600
|
-
session:
|
|
18601
|
-
instructions:
|
|
18641
|
+
var RcCompactWithInstructionsInputSchema = z24.strictObject({
|
|
18642
|
+
session: z24.string().min(1),
|
|
18643
|
+
instructions: z24.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
18602
18644
|
waitMs: WaitMsSchema
|
|
18603
18645
|
});
|
|
18604
18646
|
var commandAnswerShape = {
|
|
18605
|
-
session:
|
|
18606
|
-
route:
|
|
18647
|
+
session: z24.string(),
|
|
18648
|
+
route: z24.enum(["supervised", "self-hosted"])
|
|
18607
18649
|
};
|
|
18608
|
-
var RcGoalGetOutputSchema =
|
|
18650
|
+
var RcGoalGetOutputSchema = z24.strictObject({
|
|
18609
18651
|
...commandAnswerShape,
|
|
18610
|
-
goal:
|
|
18652
|
+
goal: z24.strictObject({ condition: z24.string(), iterations: z24.int().nonnegative(), lastCheck: z24.string().optional() }).nullable()
|
|
18611
18653
|
});
|
|
18612
|
-
var RcGoalSetOutputSchema =
|
|
18654
|
+
var RcGoalSetOutputSchema = z24.strictObject({
|
|
18613
18655
|
...commandAnswerShape,
|
|
18614
|
-
condition:
|
|
18615
|
-
superseded:
|
|
18656
|
+
condition: z24.string(),
|
|
18657
|
+
superseded: z24.string().nullable()
|
|
18616
18658
|
});
|
|
18617
|
-
var RcGoalClearOutputSchema =
|
|
18659
|
+
var RcGoalClearOutputSchema = z24.strictObject({
|
|
18618
18660
|
...commandAnswerShape,
|
|
18619
|
-
cleared:
|
|
18661
|
+
cleared: z24.string().nullable()
|
|
18620
18662
|
});
|
|
18621
|
-
var RcCompactOutputSchema =
|
|
18663
|
+
var RcCompactOutputSchema = z24.strictObject({
|
|
18622
18664
|
...commandAnswerShape,
|
|
18623
|
-
trigger:
|
|
18624
|
-
preTokens:
|
|
18625
|
-
postTokens:
|
|
18665
|
+
trigger: z24.string(),
|
|
18666
|
+
preTokens: z24.number().optional(),
|
|
18667
|
+
postTokens: z24.number().optional()
|
|
18626
18668
|
});
|
|
18627
18669
|
|
|
18628
18670
|
// src/frontdoor/rcApi.ts
|
|
@@ -18843,48 +18885,48 @@ init_cliError();
|
|
|
18843
18885
|
init_package();
|
|
18844
18886
|
|
|
18845
18887
|
// src/codex/appServerSchemas.ts
|
|
18846
|
-
import { z as
|
|
18888
|
+
import { z as z25 } from "zod";
|
|
18847
18889
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
18848
|
-
var RateLimitWindowSchema =
|
|
18849
|
-
usedPercent:
|
|
18850
|
-
resetsAt:
|
|
18851
|
-
windowDurationMins:
|
|
18852
|
-
});
|
|
18853
|
-
var RateLimitSnapshotSchema =
|
|
18854
|
-
limitId:
|
|
18855
|
-
limitName:
|
|
18856
|
-
planType:
|
|
18890
|
+
var RateLimitWindowSchema = z25.object({
|
|
18891
|
+
usedPercent: z25.number(),
|
|
18892
|
+
resetsAt: z25.number().nullish(),
|
|
18893
|
+
windowDurationMins: z25.number().nullish()
|
|
18894
|
+
});
|
|
18895
|
+
var RateLimitSnapshotSchema = z25.object({
|
|
18896
|
+
limitId: z25.string().nullish(),
|
|
18897
|
+
limitName: z25.string().nullish(),
|
|
18898
|
+
planType: z25.string().nullish(),
|
|
18857
18899
|
primary: RateLimitWindowSchema.nullish(),
|
|
18858
18900
|
secondary: RateLimitWindowSchema.nullish(),
|
|
18859
|
-
rateLimitReachedType:
|
|
18860
|
-
spendControlReached:
|
|
18861
|
-
});
|
|
18862
|
-
var RateLimitResetCreditSchema =
|
|
18863
|
-
id:
|
|
18864
|
-
grantedAt:
|
|
18865
|
-
expiresAt:
|
|
18866
|
-
resetType:
|
|
18867
|
-
status:
|
|
18868
|
-
title:
|
|
18869
|
-
description:
|
|
18870
|
-
});
|
|
18871
|
-
var CodexAccountSchema =
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18901
|
+
rateLimitReachedType: z25.string().nullish(),
|
|
18902
|
+
spendControlReached: z25.boolean().nullish()
|
|
18903
|
+
});
|
|
18904
|
+
var RateLimitResetCreditSchema = z25.object({
|
|
18905
|
+
id: z25.string(),
|
|
18906
|
+
grantedAt: z25.number(),
|
|
18907
|
+
expiresAt: z25.number().nullish(),
|
|
18908
|
+
resetType: z25.string(),
|
|
18909
|
+
status: z25.string(),
|
|
18910
|
+
title: z25.string().nullish(),
|
|
18911
|
+
description: z25.string().nullish()
|
|
18912
|
+
});
|
|
18913
|
+
var CodexAccountSchema = z25.discriminatedUnion("type", [
|
|
18914
|
+
z25.object({ type: z25.literal("apiKey") }),
|
|
18915
|
+
z25.object({ type: z25.literal("chatgpt"), email: z25.string().nullable(), planType: z25.string() }),
|
|
18916
|
+
z25.object({ type: z25.literal("amazonBedrock"), usesCodexManagedCredentials: z25.boolean().default(false) })
|
|
18875
18917
|
]);
|
|
18876
|
-
var CodexAccountReadSchema =
|
|
18918
|
+
var CodexAccountReadSchema = z25.object({
|
|
18877
18919
|
account: CodexAccountSchema.nullable(),
|
|
18878
|
-
requiresOpenaiAuth:
|
|
18920
|
+
requiresOpenaiAuth: z25.boolean()
|
|
18879
18921
|
});
|
|
18880
|
-
var CodexRateLimitsReadSchema =
|
|
18922
|
+
var CodexRateLimitsReadSchema = z25.object({
|
|
18881
18923
|
rateLimits: RateLimitSnapshotSchema,
|
|
18882
|
-
rateLimitsByLimitId:
|
|
18883
|
-
rateLimitResetCredits:
|
|
18884
|
-
accountId:
|
|
18885
|
-
ordinaryUsageAllowed:
|
|
18924
|
+
rateLimitsByLimitId: z25.record(z25.string(), RateLimitSnapshotSchema).nullish(),
|
|
18925
|
+
rateLimitResetCredits: z25.object({ availableCount: z25.number(), credits: z25.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
18926
|
+
accountId: z25.string().nullish(),
|
|
18927
|
+
ordinaryUsageAllowed: z25.boolean().nullish()
|
|
18886
18928
|
});
|
|
18887
|
-
var CodexInitializeResultSchema =
|
|
18929
|
+
var CodexInitializeResultSchema = z25.object({ userAgent: z25.string() });
|
|
18888
18930
|
|
|
18889
18931
|
// src/codex/appServer.ts
|
|
18890
18932
|
var CodexAppServerUnavailableError = class extends CliError {
|