pennyrouter 0.1.2 → 0.1.3
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/package.json +1 -1
- package/src/harnesses/claude-code.js +30 -2
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ export const claudeCodeHarness = {
|
|
|
17
17
|
`write ${CONFIG_PATH}`,
|
|
18
18
|
"set Anthropic-compatible base URL to PennyRouter",
|
|
19
19
|
"store the PennyRouter API key without printing it",
|
|
20
|
+
'label every tier "PennyRouter Bundle" (routing is automatic)',
|
|
20
21
|
],
|
|
21
22
|
};
|
|
22
23
|
},
|
|
@@ -26,7 +27,16 @@ export const claudeCodeHarness = {
|
|
|
26
27
|
const current = (await readJsonFile(CONFIG_PATH, null)) || {};
|
|
27
28
|
current.env ||= {};
|
|
28
29
|
current.env.ANTHROPIC_BASE_URL = gatewayBaseUrl;
|
|
29
|
-
|
|
30
|
+
// Custom base URL: Claude Code authenticates with the auth token, not an
|
|
31
|
+
// Anthropic API key. Clear any stale key so it doesn't take precedence.
|
|
32
|
+
current.env.ANTHROPIC_AUTH_TOKEN = apiKey;
|
|
33
|
+
delete current.env.ANTHROPIC_API_KEY;
|
|
34
|
+
// The gateway ignores the requested model and routes by bundle + triage, so the
|
|
35
|
+
// per-tier names are cosmetic. Brand all three so the Claude Code footer shows
|
|
36
|
+
// "PennyRouter Bundle" instead of Opus/Sonnet/Haiku.
|
|
37
|
+
current.env.ANTHROPIC_DEFAULT_OPUS_MODEL = "PennyRouter Bundle";
|
|
38
|
+
current.env.ANTHROPIC_DEFAULT_SONNET_MODEL = "PennyRouter Bundle";
|
|
39
|
+
current.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = "PennyRouter Bundle";
|
|
30
40
|
|
|
31
41
|
await atomicWrite(CONFIG_PATH, `${JSON.stringify(current, null, 2)}\n`);
|
|
32
42
|
|
|
@@ -37,7 +47,13 @@ export const claudeCodeHarness = {
|
|
|
37
47
|
installed_at: new Date().toISOString(),
|
|
38
48
|
restart: "restart Claude Code",
|
|
39
49
|
changes: {
|
|
40
|
-
env_keys: [
|
|
50
|
+
env_keys: [
|
|
51
|
+
"ANTHROPIC_BASE_URL",
|
|
52
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
53
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
54
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
55
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
56
|
+
],
|
|
41
57
|
},
|
|
42
58
|
};
|
|
43
59
|
},
|
|
@@ -46,9 +62,21 @@ export const claudeCodeHarness = {
|
|
|
46
62
|
const current = (await readJsonFile(record.config_path, null)) || {};
|
|
47
63
|
if (current.env?.ANTHROPIC_BASE_URL?.includes("pennyrouter.com")) {
|
|
48
64
|
delete current.env.ANTHROPIC_BASE_URL;
|
|
65
|
+
const tok = current.env.ANTHROPIC_AUTH_TOKEN;
|
|
66
|
+
if (typeof tok === "string" && tok.startsWith("pr-")) {
|
|
67
|
+
delete current.env.ANTHROPIC_AUTH_TOKEN;
|
|
68
|
+
}
|
|
69
|
+
// Legacy installs stored the key under ANTHROPIC_API_KEY.
|
|
49
70
|
if (typeof current.env.ANTHROPIC_API_KEY === "string" && current.env.ANTHROPIC_API_KEY.startsWith("pr-")) {
|
|
50
71
|
delete current.env.ANTHROPIC_API_KEY;
|
|
51
72
|
}
|
|
73
|
+
for (const k of [
|
|
74
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL",
|
|
75
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL",
|
|
76
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
77
|
+
]) {
|
|
78
|
+
if (current.env[k] === "PennyRouter Bundle") delete current.env[k];
|
|
79
|
+
}
|
|
52
80
|
}
|
|
53
81
|
if (current.env && Object.keys(current.env).length === 0) delete current.env;
|
|
54
82
|
await atomicWrite(record.config_path, `${JSON.stringify(current, null, 2)}\n`);
|