ccem 2.62.0 → 2.64.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/index.js +112 -86
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,8 +11,13 @@ import * as fs11 from "fs";
|
|
|
11
11
|
import * as path9 from "path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
13
13
|
|
|
14
|
-
// ../../packages/core/dist/chunk-
|
|
14
|
+
// ../../packages/core/dist/chunk-LVDB6VZW.js
|
|
15
15
|
var TIER_MODEL_ALIASES = /* @__PURE__ */ new Set(["opus", "sonnet", "haiku"]);
|
|
16
|
+
var OFFICIAL_ENV_NAME = "official";
|
|
17
|
+
var OFFICIAL_BASE_URL = "https://api.anthropic.com";
|
|
18
|
+
var LEGACY_OFFICIAL_MODEL_PIN = "claude-opus-4-1-20250805";
|
|
19
|
+
var LEGACY_OFFICIAL_HAIKU_PIN = "claude-3-5-haiku-20241022";
|
|
20
|
+
var OFFICIAL_RUNTIME_ALIAS = "opus";
|
|
16
21
|
function normalizeEnvConfig(envConfig, defaultRuntimeModel = "opus") {
|
|
17
22
|
const hasTierDefaults = Boolean(envConfig.ANTHROPIC_DEFAULT_OPUS_MODEL) || Boolean(envConfig.ANTHROPIC_DEFAULT_SONNET_MODEL) || Boolean(envConfig.ANTHROPIC_DEFAULT_HAIKU_MODEL);
|
|
18
23
|
const defaultOpusModel = envConfig.ANTHROPIC_DEFAULT_OPUS_MODEL ?? (hasTierDefaults ? void 0 : envConfig.ANTHROPIC_MODEL);
|
|
@@ -37,6 +42,9 @@ function normalizeEnvConfig(envConfig, defaultRuntimeModel = "opus") {
|
|
|
37
42
|
ANTHROPIC_MODEL: hasTierDefaults ? envConfig.ANTHROPIC_MODEL ?? defaultRuntimeModel : defaultRuntimeModel,
|
|
38
43
|
...envConfig.CLAUDE_CODE_SUBAGENT_MODEL && {
|
|
39
44
|
CLAUDE_CODE_SUBAGENT_MODEL: envConfig.CLAUDE_CODE_SUBAGENT_MODEL
|
|
45
|
+
},
|
|
46
|
+
...typeof envConfig.CCEM_LIMIT_WRITE_TOOLS === "boolean" && {
|
|
47
|
+
CCEM_LIMIT_WRITE_TOOLS: envConfig.CCEM_LIMIT_WRITE_TOOLS
|
|
40
48
|
}
|
|
41
49
|
};
|
|
42
50
|
}
|
|
@@ -65,6 +73,15 @@ function recoverEnvConfigFromLegacy(currentEnvConfig, legacyEnvConfig) {
|
|
|
65
73
|
}
|
|
66
74
|
};
|
|
67
75
|
}
|
|
76
|
+
function resolveEnvConfigForRuntime(envName, envConfig) {
|
|
77
|
+
const resolved = { ...envConfig };
|
|
78
|
+
const hasUntouchedLegacyOfficialPins = envName === OFFICIAL_ENV_NAME && resolved.ANTHROPIC_BASE_URL === OFFICIAL_BASE_URL && resolved.ANTHROPIC_DEFAULT_OPUS_MODEL === LEGACY_OFFICIAL_MODEL_PIN && resolved.ANTHROPIC_DEFAULT_SONNET_MODEL === LEGACY_OFFICIAL_MODEL_PIN && resolved.ANTHROPIC_DEFAULT_HAIKU_MODEL === LEGACY_OFFICIAL_HAIKU_PIN && resolved.ANTHROPIC_MODEL === OFFICIAL_RUNTIME_ALIAS && resolved.CLAUDE_CODE_SUBAGENT_MODEL === void 0;
|
|
79
|
+
if (hasUntouchedLegacyOfficialPins) {
|
|
80
|
+
delete resolved.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
81
|
+
delete resolved.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
82
|
+
}
|
|
83
|
+
return resolved;
|
|
84
|
+
}
|
|
68
85
|
var ENV_PRESETS = {
|
|
69
86
|
"GLM": {
|
|
70
87
|
ANTHROPIC_BASE_URL: "https://open.bigmodel.cn/api/anthropic",
|
|
@@ -75,9 +92,9 @@ var ENV_PRESETS = {
|
|
|
75
92
|
},
|
|
76
93
|
"KIMI": {
|
|
77
94
|
ANTHROPIC_BASE_URL: "https://api.moonshot.cn/anthropic",
|
|
78
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: "kimi-k3",
|
|
79
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: "kimi-k3",
|
|
80
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: "kimi-k3",
|
|
95
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: "kimi-k3[1m]",
|
|
96
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: "kimi-k3[1m]",
|
|
97
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: "kimi-k3[1m]",
|
|
81
98
|
ANTHROPIC_MODEL: "opus"
|
|
82
99
|
},
|
|
83
100
|
"KimiCodePlan": {
|
|
@@ -116,9 +133,9 @@ var ENV_PRESETS = {
|
|
|
116
133
|
ANTHROPIC_MODEL: "opus"
|
|
117
134
|
},
|
|
118
135
|
"OpenRouter": {
|
|
119
|
-
ANTHROPIC_BASE_URL: "https://openrouter.ai/api
|
|
120
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: "anthropic/claude-opus-
|
|
121
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: "anthropic/claude-sonnet-
|
|
136
|
+
ANTHROPIC_BASE_URL: "https://openrouter.ai/api",
|
|
137
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: "anthropic/claude-opus-5",
|
|
138
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: "anthropic/claude-sonnet-5",
|
|
122
139
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: "anthropic/claude-haiku-4.5",
|
|
123
140
|
ANTHROPIC_MODEL: "opus"
|
|
124
141
|
},
|
|
@@ -396,13 +413,51 @@ var getPermissionModeNames = () => {
|
|
|
396
413
|
};
|
|
397
414
|
|
|
398
415
|
// ../../packages/core/dist/index.js
|
|
399
|
-
import
|
|
416
|
+
import crypto2 from "crypto";
|
|
400
417
|
import fs from "fs";
|
|
401
418
|
import os from "os";
|
|
402
419
|
import path from "path";
|
|
403
|
-
|
|
404
|
-
var LEGACY_KEY = crypto.scryptSync("claude-code-env-manager-secret", "salt", 32);
|
|
420
|
+
import crypto from "crypto";
|
|
405
421
|
var V2_ALGORITHM = "aes-256-gcm";
|
|
422
|
+
function encryptV2WithKey(text, key, nonce) {
|
|
423
|
+
const cipher = crypto.createCipheriv(V2_ALGORITHM, key, nonce);
|
|
424
|
+
let encrypted = cipher.update(text, "utf8", "hex");
|
|
425
|
+
encrypted += cipher.final("hex");
|
|
426
|
+
const tag = cipher.getAuthTag();
|
|
427
|
+
return `enc:v2:${nonce.toString("hex")}:${encrypted}:${tag.toString("hex")}`;
|
|
428
|
+
}
|
|
429
|
+
function parseV2Ciphertext(text) {
|
|
430
|
+
const parts = text.split(":");
|
|
431
|
+
if (parts.length !== 5) {
|
|
432
|
+
throw new Error("Invalid enc:v2: ciphertext format");
|
|
433
|
+
}
|
|
434
|
+
const nonceHex = parts[2];
|
|
435
|
+
const ciphertextHex = parts[3];
|
|
436
|
+
const tagHex = parts[4];
|
|
437
|
+
if (!/^[0-9a-f]{24}$/i.test(nonceHex)) {
|
|
438
|
+
throw new Error("Invalid enc:v2: nonce");
|
|
439
|
+
}
|
|
440
|
+
if (!/^[0-9a-f]{32}$/i.test(tagHex)) {
|
|
441
|
+
throw new Error("Invalid enc:v2: auth tag");
|
|
442
|
+
}
|
|
443
|
+
if (ciphertextHex.length === 0 || !/^[0-9a-f]+$/i.test(ciphertextHex) || ciphertextHex.length % 2 !== 0) {
|
|
444
|
+
throw new Error("Invalid enc:v2: ciphertext");
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
nonce: Buffer.from(nonceHex, "hex"),
|
|
448
|
+
ciphertextHex,
|
|
449
|
+
tag: Buffer.from(tagHex, "hex")
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function decryptParsedV2Ciphertext({ nonce, ciphertextHex, tag }, key) {
|
|
453
|
+
const decipher = crypto.createDecipheriv(V2_ALGORITHM, key, nonce);
|
|
454
|
+
decipher.setAuthTag(tag);
|
|
455
|
+
let decrypted = decipher.update(ciphertextHex, "hex", "utf8");
|
|
456
|
+
decrypted += decipher.final("utf8");
|
|
457
|
+
return decrypted;
|
|
458
|
+
}
|
|
459
|
+
var LEGACY_ALGORITHM = "aes-256-cbc";
|
|
460
|
+
var LEGACY_KEY = crypto2.scryptSync("claude-code-env-manager-secret", "salt", 32);
|
|
406
461
|
var _installKey = null;
|
|
407
462
|
function getOrCreateInstallKey() {
|
|
408
463
|
if (_installKey) return _installKey;
|
|
@@ -412,48 +467,20 @@ function getOrCreateInstallKey() {
|
|
|
412
467
|
return _installKey;
|
|
413
468
|
}
|
|
414
469
|
ensureCcemDir();
|
|
415
|
-
_installKey =
|
|
470
|
+
_installKey = crypto2.randomBytes(32);
|
|
416
471
|
fs.writeFileSync(keyPath, _installKey.toString("hex"), { mode: 384 });
|
|
417
472
|
return _installKey;
|
|
418
473
|
}
|
|
419
474
|
var encrypt = (text) => {
|
|
420
475
|
if (!text) return text;
|
|
421
|
-
|
|
422
|
-
const nonce = crypto.randomBytes(12);
|
|
423
|
-
const cipher = crypto.createCipheriv(V2_ALGORITHM, key, nonce);
|
|
424
|
-
let encrypted = cipher.update(text, "utf8", "hex");
|
|
425
|
-
encrypted += cipher.final("hex");
|
|
426
|
-
const tag = cipher.getAuthTag();
|
|
427
|
-
return `enc:v2:${nonce.toString("hex")}:${encrypted}:${tag.toString("hex")}`;
|
|
476
|
+
return encryptV2WithKey(text, getOrCreateInstallKey(), crypto2.randomBytes(12));
|
|
428
477
|
};
|
|
429
478
|
var decrypt = (text) => {
|
|
430
479
|
if (!text || !text.startsWith("enc:")) return text;
|
|
431
480
|
if (text.startsWith("enc:v2:")) {
|
|
432
|
-
const
|
|
433
|
-
if (parts.length !== 5) {
|
|
434
|
-
throw new Error("Invalid enc:v2: ciphertext format");
|
|
435
|
-
}
|
|
436
|
-
const nonceHex = parts[2];
|
|
437
|
-
const ciphertextHex = parts[3];
|
|
438
|
-
const tagHex = parts[4];
|
|
439
|
-
if (!/^[0-9a-f]{24}$/i.test(nonceHex)) {
|
|
440
|
-
throw new Error("Invalid enc:v2: nonce");
|
|
441
|
-
}
|
|
442
|
-
if (!/^[0-9a-f]{32}$/i.test(tagHex)) {
|
|
443
|
-
throw new Error("Invalid enc:v2: auth tag");
|
|
444
|
-
}
|
|
445
|
-
if (ciphertextHex.length === 0 || !/^[0-9a-f]+$/i.test(ciphertextHex) || ciphertextHex.length % 2 !== 0) {
|
|
446
|
-
throw new Error("Invalid enc:v2: ciphertext");
|
|
447
|
-
}
|
|
481
|
+
const parsed = parseV2Ciphertext(text);
|
|
448
482
|
try {
|
|
449
|
-
|
|
450
|
-
const nonce = Buffer.from(nonceHex, "hex");
|
|
451
|
-
const tag = Buffer.from(tagHex, "hex");
|
|
452
|
-
const decipher = crypto.createDecipheriv(V2_ALGORITHM, key, nonce);
|
|
453
|
-
decipher.setAuthTag(tag);
|
|
454
|
-
let decrypted = decipher.update(ciphertextHex, "hex", "utf8");
|
|
455
|
-
decrypted += decipher.final("utf8");
|
|
456
|
-
return decrypted;
|
|
483
|
+
return decryptParsedV2Ciphertext(parsed, getOrCreateInstallKey());
|
|
457
484
|
} catch {
|
|
458
485
|
throw new Error("Failed to decrypt enc:v2: data (tampered or wrong install key)");
|
|
459
486
|
}
|
|
@@ -463,7 +490,7 @@ var decrypt = (text) => {
|
|
|
463
490
|
if (parts.length !== 3) return text;
|
|
464
491
|
const iv = Buffer.from(parts[1], "hex");
|
|
465
492
|
const encryptedText = parts[2];
|
|
466
|
-
const decipher =
|
|
493
|
+
const decipher = crypto2.createDecipheriv(LEGACY_ALGORITHM, LEGACY_KEY, iv);
|
|
467
494
|
let decrypted = decipher.update(encryptedText, "hex", "utf8");
|
|
468
495
|
decrypted += decipher.final("utf8");
|
|
469
496
|
return decrypted;
|
|
@@ -972,6 +999,7 @@ var selectLogo = (termWidth) => {
|
|
|
972
999
|
return LOGO_FULL;
|
|
973
1000
|
};
|
|
974
1001
|
var renderLogoWithEnvPanel = (envName, env, defaultMode) => {
|
|
1002
|
+
const displayEnv = resolveEnvConfigForRuntime(envName, env);
|
|
975
1003
|
const termWidth = getTerminalWidth();
|
|
976
1004
|
const isNarrow = termWidth < 60;
|
|
977
1005
|
const isVeryNarrow = termWidth < 45;
|
|
@@ -980,11 +1008,11 @@ var renderLogoWithEnvPanel = (envName, env, defaultMode) => {
|
|
|
980
1008
|
const title = theme.primary("CCEM") + " " + theme.muted("Claude Code Env Manager");
|
|
981
1009
|
const titleShort = theme.primary("CCEM");
|
|
982
1010
|
const envLabel = theme.muted("Env: ") + theme.primary(envName);
|
|
983
|
-
const baseUrl =
|
|
984
|
-
const runtimeModel =
|
|
985
|
-
const opusModel =
|
|
986
|
-
const haikuModel =
|
|
987
|
-
const authToken =
|
|
1011
|
+
const baseUrl = displayEnv.ANTHROPIC_BASE_URL || "-";
|
|
1012
|
+
const runtimeModel = displayEnv.ANTHROPIC_MODEL || "-";
|
|
1013
|
+
const opusModel = displayEnv.ANTHROPIC_DEFAULT_OPUS_MODEL || (envName === "official" ? "Claude default" : "-");
|
|
1014
|
+
const haikuModel = displayEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL || "-";
|
|
1015
|
+
const authToken = displayEnv.ANTHROPIC_AUTH_TOKEN ? displayEnv.ANTHROPIC_AUTH_TOKEN.slice(0, 2) + "\u2022\u2022\u2022\u2022" + displayEnv.ANTHROPIC_AUTH_TOKEN.slice(-4) : "-";
|
|
988
1016
|
const truncate = (s, max) => s.length > max ? s.slice(0, max - 3) + "..." : s;
|
|
989
1017
|
const maskUrl = (url, max) => {
|
|
990
1018
|
if (url.length <= max) return url;
|
|
@@ -1438,11 +1466,11 @@ import chalk3 from "chalk";
|
|
|
1438
1466
|
import Table2 from "cli-table3";
|
|
1439
1467
|
|
|
1440
1468
|
// src/utils.ts
|
|
1441
|
-
import
|
|
1469
|
+
import crypto3 from "crypto";
|
|
1442
1470
|
import fs3 from "fs";
|
|
1443
1471
|
import os3 from "os";
|
|
1444
1472
|
import path3 from "path";
|
|
1445
|
-
var SECRET_KEY =
|
|
1473
|
+
var SECRET_KEY = crypto3.scryptSync("claude-code-env-manager-secret", "salt", 32);
|
|
1446
1474
|
var findProjectRoot = () => {
|
|
1447
1475
|
let currentDir = process.cwd();
|
|
1448
1476
|
const root = path3.parse(currentDir).root;
|
|
@@ -1839,15 +1867,16 @@ var MANAGED_CLAUDE_ENV_KEYS = [
|
|
|
1839
1867
|
"ANTHROPIC_API_KEY",
|
|
1840
1868
|
"ANTHROPIC_SMALL_FAST_MODEL"
|
|
1841
1869
|
];
|
|
1842
|
-
function buildEnvVars(envConfig) {
|
|
1870
|
+
function buildEnvVars(envName, envConfig) {
|
|
1871
|
+
const runtimeEnv = resolveEnvConfigForRuntime(envName, envConfig);
|
|
1843
1872
|
const vars = {};
|
|
1844
|
-
if (
|
|
1845
|
-
if (
|
|
1846
|
-
if (
|
|
1847
|
-
if (
|
|
1848
|
-
if (
|
|
1849
|
-
if (
|
|
1850
|
-
if (
|
|
1873
|
+
if (runtimeEnv.ANTHROPIC_BASE_URL) vars.ANTHROPIC_BASE_URL = runtimeEnv.ANTHROPIC_BASE_URL;
|
|
1874
|
+
if (runtimeEnv.ANTHROPIC_AUTH_TOKEN) vars.ANTHROPIC_AUTH_TOKEN = decrypt(runtimeEnv.ANTHROPIC_AUTH_TOKEN);
|
|
1875
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_OPUS_MODEL) vars.ANTHROPIC_DEFAULT_OPUS_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
1876
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_SONNET_MODEL) vars.ANTHROPIC_DEFAULT_SONNET_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
1877
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL) vars.ANTHROPIC_DEFAULT_HAIKU_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
1878
|
+
if (runtimeEnv.ANTHROPIC_MODEL) vars.ANTHROPIC_MODEL = runtimeEnv.ANTHROPIC_MODEL;
|
|
1879
|
+
if (runtimeEnv.CLAUDE_CODE_SUBAGENT_MODEL) vars.CLAUDE_CODE_SUBAGENT_MODEL = runtimeEnv.CLAUDE_CODE_SUBAGENT_MODEL;
|
|
1851
1880
|
return vars;
|
|
1852
1881
|
}
|
|
1853
1882
|
function buildPermArgs(modeName) {
|
|
@@ -1878,7 +1907,7 @@ async function launchClaude(options) {
|
|
|
1878
1907
|
delete env[key];
|
|
1879
1908
|
}
|
|
1880
1909
|
if (envConfig) {
|
|
1881
|
-
Object.assign(env, buildEnvVars(envConfig));
|
|
1910
|
+
Object.assign(env, buildEnvVars(envName, envConfig));
|
|
1882
1911
|
}
|
|
1883
1912
|
delete env.CLAUDECODE;
|
|
1884
1913
|
env.CCEM_RUNTIME_ID = ccemRuntimeId;
|
|
@@ -2836,7 +2865,7 @@ async function runSkillSelector() {
|
|
|
2836
2865
|
}
|
|
2837
2866
|
|
|
2838
2867
|
// src/remote.ts
|
|
2839
|
-
import
|
|
2868
|
+
import crypto4 from "crypto";
|
|
2840
2869
|
import chalk6 from "chalk";
|
|
2841
2870
|
import Conf from "conf";
|
|
2842
2871
|
var config = new Conf({
|
|
@@ -2851,7 +2880,7 @@ var isEnvelopeV2 = (value) => {
|
|
|
2851
2880
|
const v = value;
|
|
2852
2881
|
return v.v === 2 && typeof v.nonce === "string" && typeof v.ciphertext === "string" && typeof v.tag === "string";
|
|
2853
2882
|
};
|
|
2854
|
-
var deriveRemoteKey = (secret) =>
|
|
2883
|
+
var deriveRemoteKey = (secret) => crypto4.scryptSync(secret, "ccem-salt", 32);
|
|
2855
2884
|
var decryptV2Envelope = (envelope, key) => {
|
|
2856
2885
|
const nonce = Buffer.from(envelope.nonce, "base64");
|
|
2857
2886
|
const ciphertext = Buffer.from(envelope.ciphertext, "base64");
|
|
@@ -2859,7 +2888,7 @@ var decryptV2Envelope = (envelope, key) => {
|
|
|
2859
2888
|
if (nonce.length === 0 || ciphertext.length === 0 || tag.length === 0) {
|
|
2860
2889
|
throw new Error("v2 envelope has empty nonce/ciphertext/tag");
|
|
2861
2890
|
}
|
|
2862
|
-
const decipher =
|
|
2891
|
+
const decipher = crypto4.createDecipheriv(
|
|
2863
2892
|
REMOTE_CRYPTO_ALGORITHM_V2,
|
|
2864
2893
|
key,
|
|
2865
2894
|
nonce
|
|
@@ -2876,7 +2905,7 @@ var decryptV1Legacy = (encryptedBase64, key) => {
|
|
|
2876
2905
|
}
|
|
2877
2906
|
const iv = combined.subarray(0, 16);
|
|
2878
2907
|
const encryptedHex = combined.subarray(16).toString("hex");
|
|
2879
|
-
const decipher =
|
|
2908
|
+
const decipher = crypto4.createDecipheriv(REMOTE_CRYPTO_ALGORITHM_V1, key, iv);
|
|
2880
2909
|
let decrypted = decipher.update(encryptedHex, "hex", "utf8");
|
|
2881
2910
|
decrypted += decipher.final("utf8");
|
|
2882
2911
|
return decrypted;
|
|
@@ -3196,7 +3225,7 @@ ccem cron delete "TASK_ID_OR_EXACT_NAME"
|
|
|
3196
3225
|
`;
|
|
3197
3226
|
|
|
3198
3227
|
// src/cron.ts
|
|
3199
|
-
import
|
|
3228
|
+
import crypto5 from "crypto";
|
|
3200
3229
|
import * as fs9 from "fs";
|
|
3201
3230
|
import * as os5 from "os";
|
|
3202
3231
|
import * as path7 from "path";
|
|
@@ -3317,7 +3346,7 @@ function createCronTask(input, tasksPath = getCronTasksPath()) {
|
|
|
3317
3346
|
}
|
|
3318
3347
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3319
3348
|
const task = {
|
|
3320
|
-
id: `cron-${Date.now()}-${
|
|
3349
|
+
id: `cron-${Date.now()}-${crypto5.randomBytes(2).toString("hex")}`,
|
|
3321
3350
|
name,
|
|
3322
3351
|
cronExpression,
|
|
3323
3352
|
prompt,
|
|
@@ -3665,8 +3694,6 @@ var pkg = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
|
|
|
3665
3694
|
var program = new Command();
|
|
3666
3695
|
var DEFAULT_OFFICIAL_ENV = {
|
|
3667
3696
|
ANTHROPIC_BASE_URL: "https://api.anthropic.com",
|
|
3668
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: "claude-opus-4-1-20250805",
|
|
3669
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: "claude-opus-4-1-20250805",
|
|
3670
3697
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: "claude-3-5-haiku-20241022",
|
|
3671
3698
|
ANTHROPIC_MODEL: "opus"
|
|
3672
3699
|
};
|
|
@@ -3687,19 +3714,20 @@ var clearManagedClaudeEnv = (env) => {
|
|
|
3687
3714
|
delete env[key];
|
|
3688
3715
|
}
|
|
3689
3716
|
};
|
|
3690
|
-
var buildResolvedEnvVars = (env) => {
|
|
3717
|
+
var buildResolvedEnvVars = (envName, env) => {
|
|
3718
|
+
const runtimeEnv = resolveEnvConfigForRuntime(envName, env);
|
|
3691
3719
|
const resolved = {};
|
|
3692
|
-
if (
|
|
3693
|
-
if (
|
|
3694
|
-
if (
|
|
3695
|
-
if (
|
|
3696
|
-
if (
|
|
3697
|
-
if (
|
|
3698
|
-
if (
|
|
3720
|
+
if (runtimeEnv.ANTHROPIC_BASE_URL) resolved.ANTHROPIC_BASE_URL = runtimeEnv.ANTHROPIC_BASE_URL;
|
|
3721
|
+
if (runtimeEnv.ANTHROPIC_AUTH_TOKEN) resolved.ANTHROPIC_AUTH_TOKEN = decrypt(runtimeEnv.ANTHROPIC_AUTH_TOKEN);
|
|
3722
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_OPUS_MODEL) resolved.ANTHROPIC_DEFAULT_OPUS_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
3723
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_SONNET_MODEL) resolved.ANTHROPIC_DEFAULT_SONNET_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
3724
|
+
if (runtimeEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL) resolved.ANTHROPIC_DEFAULT_HAIKU_MODEL = runtimeEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
3725
|
+
if (runtimeEnv.ANTHROPIC_MODEL) resolved.ANTHROPIC_MODEL = runtimeEnv.ANTHROPIC_MODEL;
|
|
3726
|
+
if (runtimeEnv.CLAUDE_CODE_SUBAGENT_MODEL) resolved.CLAUDE_CODE_SUBAGENT_MODEL = runtimeEnv.CLAUDE_CODE_SUBAGENT_MODEL;
|
|
3699
3727
|
return resolved;
|
|
3700
3728
|
};
|
|
3701
|
-
var buildShellEnvCommands = (env) => {
|
|
3702
|
-
const resolved = buildResolvedEnvVars(env);
|
|
3729
|
+
var buildShellEnvCommands = (envName, env) => {
|
|
3730
|
+
const resolved = buildResolvedEnvVars(envName, env);
|
|
3703
3731
|
return MANAGED_CLAUDE_ENV_KEYS2.map(
|
|
3704
3732
|
(key) => resolved[key] ? `export ${key}=${shellQuote(resolved[key])}` : `unset ${key}`
|
|
3705
3733
|
);
|
|
@@ -3936,7 +3964,7 @@ var switchEnvironment = async (name) => {
|
|
|
3936
3964
|
}
|
|
3937
3965
|
showCurrentEnv(null, false);
|
|
3938
3966
|
const env = registries[name];
|
|
3939
|
-
const exportCmds = buildShellEnvCommands(env);
|
|
3967
|
+
const exportCmds = buildShellEnvCommands(name, env);
|
|
3940
3968
|
if (process.stdout.isTTY) {
|
|
3941
3969
|
console.log(chalk7.yellow("\nTo apply to current shell immediately, run:"));
|
|
3942
3970
|
console.log(chalk7.cyan("eval $(ccem env)"));
|
|
@@ -4060,11 +4088,12 @@ program.command("ls").description("List all configured environments").action(()
|
|
|
4060
4088
|
});
|
|
4061
4089
|
Object.keys(registries).forEach((name) => {
|
|
4062
4090
|
const reg = registries[name];
|
|
4091
|
+
const displayReg = resolveEnvConfigForRuntime(name, reg);
|
|
4063
4092
|
const prefix = name === current ? chalk7.green("* ") : " ";
|
|
4064
4093
|
table.push([
|
|
4065
4094
|
prefix + name,
|
|
4066
|
-
|
|
4067
|
-
|
|
4095
|
+
displayReg.ANTHROPIC_BASE_URL || "-",
|
|
4096
|
+
displayReg.ANTHROPIC_DEFAULT_OPUS_MODEL || (name === "official" ? "Claude default" : "-")
|
|
4068
4097
|
]);
|
|
4069
4098
|
});
|
|
4070
4099
|
console.log(table.toString());
|
|
@@ -4268,14 +4297,11 @@ program.command("env").description("Output environment variables for shell eval"
|
|
|
4268
4297
|
const current = config2.get("current");
|
|
4269
4298
|
const env = registries[current];
|
|
4270
4299
|
if (!env) return;
|
|
4271
|
-
const outputEnv =
|
|
4272
|
-
if (outputEnv.ANTHROPIC_AUTH_TOKEN) {
|
|
4273
|
-
outputEnv.ANTHROPIC_AUTH_TOKEN = decrypt(outputEnv.ANTHROPIC_AUTH_TOKEN);
|
|
4274
|
-
}
|
|
4300
|
+
const outputEnv = buildResolvedEnvVars(current, env);
|
|
4275
4301
|
if (options.json) {
|
|
4276
4302
|
console.log(JSON.stringify(outputEnv, null, 2));
|
|
4277
4303
|
} else {
|
|
4278
|
-
buildShellEnvCommands(env).forEach((cmd) => console.log(cmd));
|
|
4304
|
+
buildShellEnvCommands(current, env).forEach((cmd) => console.log(cmd));
|
|
4279
4305
|
}
|
|
4280
4306
|
});
|
|
4281
4307
|
program.command("run <command...>").description("Run a command with the current environment variables").action((command) => {
|
|
@@ -4288,7 +4314,7 @@ program.command("run <command...>").description("Run a command with the current
|
|
|
4288
4314
|
}
|
|
4289
4315
|
const env = { ...process.env };
|
|
4290
4316
|
clearManagedClaudeEnv(env);
|
|
4291
|
-
Object.assign(env, buildResolvedEnvVars(envConfig));
|
|
4317
|
+
Object.assign(env, buildResolvedEnvVars(current, envConfig));
|
|
4292
4318
|
const [cmd, ...args] = command;
|
|
4293
4319
|
const child = spawn3(cmd, args, {
|
|
4294
4320
|
env,
|