virouter 0.2.0 → 0.2.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/README.md +9 -5
- package/bin/virouter.mjs +31 -7
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -15,10 +15,14 @@ npx virouter@latest
|
|
|
15
15
|
|
|
16
16
|
The installer asks for a `viro_...` API key and configures:
|
|
17
17
|
|
|
18
|
-
- `ANTHROPIC_BASE_URL=https://virouter
|
|
19
|
-
- `
|
|
20
|
-
- `ANTHROPIC_MODEL=
|
|
21
|
-
- `ANTHROPIC_SMALL_FAST_MODEL=
|
|
18
|
+
- `ANTHROPIC_BASE_URL=https://virouter.click`
|
|
19
|
+
- `ANTHROPIC_AUTH_TOKEN`
|
|
20
|
+
- `ANTHROPIC_MODEL=claude-sonnet-5`
|
|
21
|
+
- `ANTHROPIC_SMALL_FAST_MODEL=claude-haiku-4-5`
|
|
22
|
+
|
|
23
|
+
The customer key is never stored in this package or repository. Obtain it from the one-time
|
|
24
|
+
claim/recovery flow documented in `docs/claude-code-setup.md`; do not use an upstream
|
|
25
|
+
`OPENCODE_GO_API_KEYS` credential here.
|
|
22
26
|
|
|
23
27
|
Then open a new terminal and run:
|
|
24
28
|
|
|
@@ -27,4 +31,4 @@ claude
|
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
It does not install a local server or a model. The gateway remains hosted at
|
|
30
|
-
`https://virouter
|
|
34
|
+
`https://virouter.click`.
|
package/bin/virouter.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { homedir } from 'node:os';
|
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { createInterface } from 'node:readline/promises';
|
|
8
8
|
|
|
9
|
-
const API_ORIGIN = (process.env.VIROUTER_API_ORIGIN || 'https://virouter
|
|
9
|
+
const API_ORIGIN = (process.env.VIROUTER_API_ORIGIN || 'https://virouter.click').replace(/\/$/, '');
|
|
10
10
|
const MARKER_START = '# >>> VIROUTER CLAUDE CODE CONFIG >>>';
|
|
11
11
|
const MARKER_END = '# <<< VIROUTER CLAUDE CODE CONFIG <<<';
|
|
12
12
|
|
|
@@ -73,12 +73,29 @@ async function chooseOs(input) {
|
|
|
73
73
|
return answer;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Claude Code needs ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY.
|
|
78
|
+
*
|
|
79
|
+
* ANTHROPIC_API_KEY is reserved for a real Anthropic-issued key: Claude Code validates it
|
|
80
|
+
* against its own auth and, on a machine with a logged-in session, sends the OAuth token to
|
|
81
|
+
* the configured base URL instead of our key. The gateway then rejects a token it has never
|
|
82
|
+
* issued, and the user is told to run /login. ANTHROPIC_AUTH_TOKEN is the third-party
|
|
83
|
+
* gateway path — it is forwarded verbatim as `Authorization: Bearer`.
|
|
84
|
+
*
|
|
85
|
+
* The unset matters: an ANTHROPIC_API_KEY left over from an earlier install keeps
|
|
86
|
+
* shadowing the token, so the fix has to remove it rather than just add the right variable.
|
|
87
|
+
*/
|
|
76
88
|
function configLines(apiKey) {
|
|
77
89
|
return [
|
|
90
|
+
'unset ANTHROPIC_API_KEY',
|
|
78
91
|
`export ANTHROPIC_BASE_URL="${API_ORIGIN}"`,
|
|
79
|
-
`export
|
|
80
|
-
'export ANTHROPIC_MODEL="
|
|
81
|
-
'export ANTHROPIC_SMALL_FAST_MODEL="
|
|
92
|
+
`export ANTHROPIC_AUTH_TOKEN="${apiKey}"`,
|
|
93
|
+
'export ANTHROPIC_MODEL="claude-sonnet-5"',
|
|
94
|
+
'export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5"',
|
|
95
|
+
// Lets Claude Code's /model picker list our models from /v1/models. Nonessential
|
|
96
|
+
// traffic must stay enabled or discovery is skipped.
|
|
97
|
+
'export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY="1"',
|
|
98
|
+
'unset CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC',
|
|
82
99
|
];
|
|
83
100
|
}
|
|
84
101
|
|
|
@@ -94,9 +111,16 @@ function updateProfile(path, lines) {
|
|
|
94
111
|
function configureWindows(apiKey) {
|
|
95
112
|
const values = {
|
|
96
113
|
ANTHROPIC_BASE_URL: API_ORIGIN,
|
|
97
|
-
|
|
98
|
-
ANTHROPIC_MODEL: '
|
|
99
|
-
ANTHROPIC_SMALL_FAST_MODEL: '
|
|
114
|
+
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
115
|
+
ANTHROPIC_MODEL: 'claude-sonnet-5',
|
|
116
|
+
ANTHROPIC_SMALL_FAST_MODEL: 'claude-haiku-4-5',
|
|
117
|
+
// Lets Claude Code's /model picker list our models from /v1/models.
|
|
118
|
+
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: '1',
|
|
119
|
+
// Blanked rather than left alone — see configLines. A value here shadows the token and
|
|
120
|
+
// sends the user round the /login loop. `setx` has no delete, so empty is the removal.
|
|
121
|
+
ANTHROPIC_API_KEY: '',
|
|
122
|
+
// Discovery is skipped while this is set; clear it.
|
|
123
|
+
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '',
|
|
100
124
|
};
|
|
101
125
|
|
|
102
126
|
for (const [name, value] of Object.entries(values)) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virouter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Configure Claude Code to use the VIROUTER API gateway",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude-code",
|
|
7
|
+
"anthropic",
|
|
8
|
+
"openai",
|
|
9
|
+
"api-gateway",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
6
12
|
"license": "MIT",
|
|
7
13
|
"type": "module",
|
|
8
14
|
"bin": {
|
|
9
15
|
"virouter": "bin/virouter.mjs"
|
|
10
16
|
},
|
|
11
|
-
"files": [
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
12
21
|
"engines": {
|
|
13
22
|
"node": ">=20"
|
|
14
23
|
},
|
|
@@ -18,4 +27,4 @@
|
|
|
18
27
|
"scripts": {
|
|
19
28
|
"typecheck": "node --check bin/virouter.mjs"
|
|
20
29
|
}
|
|
21
|
-
}
|
|
30
|
+
}
|