@r-33/r33-claude 0.0.0-stage → 0.7.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/README.md +91 -2
- package/dist/cli/main/main.js +3851 -0
- package/package.json +53 -4
package/README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @r-33/r33-claude
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Interactive wizard that configures Anthropic's [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI to run on [Route 33](https://route33.ai) inference.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx @r-33/r33-claude
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Claude Code starts automatically when the wizard finishes.
|
|
12
|
+
|
|
13
|
+
## What the wizard does
|
|
14
|
+
|
|
15
|
+
1. **Welcomes you** and explains what will change.
|
|
16
|
+
2. **Asks which Route 33 API key to use** — three sources (no manual pasting: raw key material never passes through the terminal):
|
|
17
|
+
- **Saved keys** — keys from earlier runs are remembered (in `~/.config/r33-claude/keys.json`, mode `0600`) with a local name and offered first.
|
|
18
|
+
- **Sign in with Route 33** — a browser login (PKCE) opens; the wizard then lists your organisations (auto-selects when you have exactly one), asks whether the key is attributed to you personally or to one of your projects, and lists your usable keys in that org. Picking an existing key **rotates its secret** (the current secret stops working immediately — the wizard asks first); "Create a new key" mints a one-year key via the management API. The fresh secret is shown once and saved to the local store.
|
|
19
|
+
- **Current Claude Code key** — the `ANTHROPIC_AUTH_TOKEN` already in `~/.claude/settings.json`, when present.
|
|
20
|
+
|
|
21
|
+
Sign-in needs a browser and an OAuth client id (baked into released builds; override with `ROUTE33_CLIENT_ID`). A failed sign-in returns you to the key picker; when sign-in is the only source left, the wizard exits with guidance instead.
|
|
22
|
+
|
|
23
|
+
3. **Lets you add up to 5 models** from the live catalog (`GET /v1/models`) — the Default model is required, the other slots are optional, and you can stop after any pick. Slots you fill are switchable during a session with `/model`:
|
|
24
|
+
|
|
25
|
+
| Slot | Env var | Where it's used |
|
|
26
|
+
| --------------------- | -------------------------------- | ---------------------------------- |
|
|
27
|
+
| Default model | `ANTHROPIC_MODEL` | new sessions start here |
|
|
28
|
+
| Opus pick | `ANTHROPIC_DEFAULT_OPUS_MODEL` | `/model` → Opus |
|
|
29
|
+
| Sonnet pick | `ANTHROPIC_DEFAULT_SONNET_MODEL` | `/model` → Sonnet |
|
|
30
|
+
| Haiku pick | `ANTHROPIC_DEFAULT_HAIKU_MODEL` | `/model` → Haiku |
|
|
31
|
+
| Background fast model | `ANTHROPIC_SMALL_FAST_MODEL` | titles, summaries, background work |
|
|
32
|
+
|
|
33
|
+
Slots you skip stay unset — `/model` picks for those fall back to Claude Code's built-in model ids, which Route 33 does not serve, and their env vars from an earlier wizard run are removed.
|
|
34
|
+
|
|
35
|
+
Each pick is **verified with a Claude-Code-shaped request** (the same payload shape Claude Code sends, including `thinking` and the `anthropic-beta` headers). Models served through translated Messages→OpenAI lanes (e.g. `openai/gpt-5.5`) reject Claude's `thinking` field with `400 UPSTREAM_REQUEST_REJECTED`; the wizard detects this and offers to set `MAX_THINKING_TOKENS=0` (Claude Code then omits `thinking`), which disables extended thinking for all models.
|
|
36
|
+
|
|
37
|
+
4. **Asks how Claude Code should authenticate** — two wirings:
|
|
38
|
+
- **Static key** — `ANTHROPIC_AUTH_TOKEN` lands in `~/.claude/settings.json` env (simple, no switching).
|
|
39
|
+
- **Switchable key** — settings carry `apiKeyHelper` pointing at `r33-claude key current`, which prints the key named in the active-key selector (`~/.config/r33-claude/active-key`). **Switch keys inside a running session** with the `/r33-key <name>` command (installed into `~/.claude/commands/`): the switch lands within ~30s (a `CLAUDE_CODE_API_KEY_HELPER_TTL_MS=30000` cache), immediately on an auth failure, or instantly in any new session. `/r33-keys` lists your keys and the active one.
|
|
40
|
+
5. **Overwrites Claude Code's env vars** in `~/.claude/settings.json` (a timestamped backup of your previous settings is written next to it): `ANTHROPIC_BASE_URL=https://api.route33.ai`, the auth wiring above, the chosen model slots, and `MAX_THINKING_TOKENS=0` when needed. All pre-existing `ANTHROPIC_*` values (including `ANTHROPIC_API_KEY`) are replaced; all other settings (hooks, theme, …) are preserved. Re-running the wizard in static mode removes any `apiKeyHelper` it wrote earlier.
|
|
41
|
+
6. **Starts Claude Code** — the wizard launches `claude` interactively and exits with its status code.
|
|
42
|
+
|
|
43
|
+
## Key subcommands (non-interactive)
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
r33-claude key current # print the active key's material (the apiKeyHelper command)
|
|
47
|
+
r33-claude key list # list saved keys, marking the active one
|
|
48
|
+
r33-claude key use <name> # switch the active key (warns when settings still beat it)
|
|
49
|
+
r33-claude model list # list the chat-capable models in the live catalog
|
|
50
|
+
r33-claude model check <id> # verify a model answers Claude-Code-shaped requests (ok / needs-thinking-off)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The wizard also installs **`/r33-model`** and **`/r33-models`** into `~/.claude/commands/` (both auth modes): `/r33-models` lists the live catalog; bare `/r33-model` lists the catalog and lets you pick, `/r33-model <id>` goes straight — either way the model is checked against the gateway, then Claude Code's built-in `/model <id>` does the switch, with a warning when the model needs extended thinking disabled.
|
|
54
|
+
|
|
55
|
+
## Undo / restore
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
cp ~/.claude/settings.backup-<timestamp>.json ~/.claude/settings.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Node.js >= 18
|
|
64
|
+
- A Route 33 account (browser sign-in) — or a Claude Code already configured with a Route 33 key
|
|
65
|
+
- Claude Code (`npm install -g @anthropic-ai/claude-code`)
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
| Variable | Default | What it overrides |
|
|
70
|
+
| --------------------- | -------------------------- | --------------------------------------- |
|
|
71
|
+
| `ROUTE33_CLIENT_ID` | baked into released builds | OAuth client id for browser sign-in |
|
|
72
|
+
| `ROUTE33_AUTH_ISSUER` | `https://auth.route33.ai` | auth issuer URL (sign-in) |
|
|
73
|
+
| `ROUTE33_API_BASE` | `https://mapi.route33.ai` | management API origin (key list/create) |
|
|
74
|
+
|
|
75
|
+
## Troubleshooting
|
|
76
|
+
|
|
77
|
+
- **"No Route 33 OAuth client id configured"** — the build has no baked client id; set `ROUTE33_CLIENT_ID`, or configure Claude Code with a Route 33 key first and pick "current Claude Code key".
|
|
78
|
+
- **Sign-in fails or the browser can't open** — the wizard warns and returns you to the key picker; nothing is written. When sign-in is the only source left, the wizard exits with guidance.
|
|
79
|
+
- **"invalid_scope" at sign-in** — the OAuth client isn't allowed one of `openid offline_access orgs:read projects:read keys:read keys:write`; fix the client config server-side.
|
|
80
|
+
- **Rotated a key by accident** — the old secret is dead; other users of that key need the fresh secret (it was shown once and saved to `~/.config/r33-claude/keys.json`).
|
|
81
|
+
- **`claude -p` hangs silently after setup** — your key is dead (revoked or expired). Claude Code retries 401s with no output; run the wizard again to rotate or replace the key.
|
|
82
|
+
- **`/r33-key` switch has no effect** — your settings carry a static `ANTHROPIC_AUTH_TOKEN` (it beats the apiKeyHelper) or no `apiKeyHelper` at all. Re-run the wizard and pick the switchable wiring; `r33-claude key use` warns about this on every switch.
|
|
83
|
+
- **`r33-claude key current` fails after an npx setup** — npx runs from a package cache; the baked `apiKeyHelper` path may have been evicted. Install globally (`npm i -g @r-33/r33-claude`) and re-run the wizard to re-bake the path.
|
|
84
|
+
|
|
85
|
+
## Develop
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
pnpm --filter @r-33/r33-claude build
|
|
89
|
+
pnpm --filter @r-33/r33-claude test
|
|
90
|
+
pnpm --filter @r-33/r33-claude type:check
|
|
91
|
+
pnpm --filter @r-33/r33-claude lint
|
|
92
|
+
```
|