@blockrun/cc 0.5.0 → 0.6.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/README.md CHANGED
@@ -1,181 +1,278 @@
1
- # brcc
1
+ <div align="center">
2
2
 
3
- **Run Claude Code without rate limits.**
3
+ <h1>brcc — BlockRun Claude Code</h1>
4
4
 
5
- Hitting usage limits? Account disabled? Can't verify your phone? brcc fixes all of that.
5
+ <p>Claude Code hits rate limits. Accounts get locked. Phone verification fails.<br>
6
+ You're paying $200/month and still can't work.<br><br>
7
+ <strong>brcc removes all of that. Any model. No limits. Pay what you use.</strong></p>
6
8
 
7
- ```bash
8
- npm install -g @blockrun/cc
9
- brcc start
10
- ```
9
+ <br>
11
10
 
12
- One command. No Anthropic account needed. No rate limits. No phone verification. Just USDC.
11
+ <img src="https://img.shields.io/badge/🚀_No_Rate_Limits-black?style=for-the-badge" alt="No rate limits">&nbsp;
12
+ <img src="https://img.shields.io/badge/🔑_No_Account_Needed-blue?style=for-the-badge" alt="No account">&nbsp;
13
+ <img src="https://img.shields.io/badge/🤖_40+_Models-yellow?style=for-the-badge" alt="40+ models">&nbsp;
14
+ <img src="https://img.shields.io/badge/💰_Pay_Per_Use-purple?style=for-the-badge" alt="Pay per use">&nbsp;
15
+ <img src="https://img.shields.io/badge/⛓_Base_+_Solana-green?style=for-the-badge" alt="Base + Solana">
13
16
 
14
- ## The Problem
17
+ [![npm version](https://img.shields.io/npm/v/@blockrun/cc.svg?style=flat-square&color=cb3837)](https://npmjs.com/package/@blockrun/cc)
18
+ [![npm downloads](https://img.shields.io/npm/dm/@blockrun/cc.svg?style=flat-square&color=blue)](https://npmjs.com/package/@blockrun/cc)
19
+ [![GitHub stars](https://img.shields.io/github/stars/BlockRunAI/brcc?style=flat-square)](https://github.com/BlockRunAI/brcc)
20
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://typescriptlang.org)
21
+ [![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-orange?style=flat-square)](LICENSE)
15
22
 
16
- Claude Code users hit these walls daily ([4,350+ GitHub issue comments](https://github.com/anthropics/claude-code/issues)):
23
+ [![x402 Protocol](https://img.shields.io/badge/x402-Micropayments-purple?style=flat-square)](https://x402.org)
24
+ [![Base Network](https://img.shields.io/badge/Base-USDC-0052FF?style=flat-square&logo=coinbase&logoColor=white)](https://base.org)
25
+ [![Solana](https://img.shields.io/badge/Solana-USDC-9945FF?style=flat-square&logo=solana&logoColor=white)](https://solana.com)
26
+ [![BlockRun](https://img.shields.io/badge/Powered_by-BlockRun-black?style=flat-square)](https://blockrun.ai)
27
+ [![Telegram](https://img.shields.io/badge/Telegram-Community-26A5E4?style=flat-square&logo=telegram)](https://t.me/blockrunAI)
17
28
 
18
- - **"Instantly hitting usage limits with Max subscription"** — 1,252 comments
19
- - **"Account disabled after payment"** — 145 comments
20
- - **"Phone verification — unable to send code"** — 546 comments
21
- - **"5-hour limit reached in less than 1h30"** — 108 comments
22
- - **"Rate limit reached despite Max subscription"** — 89 comments
29
+ </div>
23
30
 
24
- ## The Fix
31
+ > **brcc** is a local proxy that lets you run Claude Code with any LLM model — GPT-5, Claude, Gemini, DeepSeek, Grok, and 40+ more — without rate limits, without an Anthropic account, and without phone verification. You pay per request with USDC via the [x402](https://x402.org) protocol. Your wallet is your identity. Your private key never leaves your machine.
25
32
 
26
- brcc routes Claude Code through [BlockRun](https://blockrun.ai), a pay-per-use AI gateway. You pay exactly what you use — no subscriptions, no limits, no accounts.
33
+ ---
27
34
 
28
- ```
29
- Claude Code --> brcc (local proxy) --> BlockRun API --> Any model
30
- auto-signs payments 40+ models GPT-5, Claude, Gemini, ...
31
- with your wallet pay per token
32
- ```
35
+ ## Why brcc exists
36
+
37
+ Claude Code users are frustrated. Over **4,350 GitHub issue comments** about the same problems:
38
+
39
+ | | Issue | Comments |
40
+ |--|-------|----------|
41
+ | 🔴 | ["Instantly hitting usage limits with Max subscription"](https://github.com/anthropics/claude-code/issues/16157) | 1,252 |
42
+ | 🔴 | ["Phone verification — unable to send code"](https://github.com/anthropics/claude-code/issues/34229) | 546 |
43
+ | 🔴 | ["Account disabled after payment"](https://github.com/anthropics/claude-code/issues/5088) | 145 |
44
+ | 🔴 | ["5-hour limit reached in less than 1h30"](https://github.com/anthropics/claude-code/issues/6457) | 108 |
45
+ | 🔴 | ["Rate limit reached despite Max subscription and only 16% usage"](https://github.com/anthropics/claude-code/issues/29579) | 89 |
46
+
47
+ **Every one of these people is a potential brcc user.**
48
+
49
+ brcc eliminates all of these problems:
50
+
51
+ - **No rate limits** — pay per request, use as much as you want
52
+ - **No account** — a wallet is generated locally, no signup
53
+ - **No phone verification** — USDC is your authentication
54
+ - **No region restrictions** — works everywhere, priced the same
55
+ - **No billing surprises** — transparent per-token pricing
56
+
57
+ ---
58
+
59
+ ## How it compares
60
+
61
+ | | Claude Max ($200/mo) | OpenRouter | **brcc** |
62
+ |--|---------------------|------------|----------|
63
+ | **Rate limits** | Constantly hit | Per-model limits | **None** |
64
+ | **Account required** | Yes + phone | Yes + email | **No** |
65
+ | **Models** | Claude only | 200+ (manual select) | **40+ (auto or manual)** |
66
+ | **Payment** | Credit card, subscription | Credit card, pre-pay | **USDC per-request** |
67
+ | **Auth** | OAuth + API key conflicts | API key | **Wallet signature** |
68
+ | **Pricing** | Opaque | Transparent | **Transparent** |
69
+ | **Runs locally** | N/A | No | **Yes (proxy)** |
70
+ | **Monthly cost** | $100-200 fixed | Varies | **$5-50 based on usage** |
71
+
72
+ ---
33
73
 
34
74
  ## Quick Start
35
75
 
76
+ ### One-line install (Linux/macOS)
77
+
36
78
  ```bash
37
- # Install
38
- npm install -g @blockrun/cc
79
+ curl -fsSL https://raw.githubusercontent.com/BlockRunAI/brcc/main/install.sh | bash
80
+ ```
81
+
82
+ Installs Node.js (if needed) + Claude Code + brcc + creates wallet.
83
+
84
+ ### Manual install
85
+
86
+ ```bash
87
+ # 1. Install Claude Code
88
+ curl -fsSL https://claude.ai/install.sh | bash
89
+
90
+ # 2. Install brcc (use sudo on Linux)
91
+ sudo npm install -g @blockrun/cc # use sudo on Linux
39
92
 
40
- # Create a wallet (one time)
41
- brcc setup
42
- # -> Wallet created: 0xCC8c...5EF8
43
- # -> Send USDC on Base to this address
93
+ # 3. Create wallet
94
+ brcc setup base # Base chain (Coinbase L2)
95
+ # or
96
+ brcc setup solana # Solana chain
44
97
 
45
- # Fund your wallet
46
- # Send $5-10 USDC on Base chain to your wallet address
47
- # Buy USDC on Coinbase, send directly to your address
98
+ # 4. Fund your wallet with USDC (or use free models without funding)
48
99
 
49
- # Launch Claude Code
100
+ # 5. Launch
50
101
  brcc start
51
102
  ```
52
103
 
53
104
  That's it. Claude Code opens with access to 40+ models, no rate limits.
54
105
 
106
+ ---
107
+
108
+ ## Choosing Models
109
+
110
+ ### From the command line
111
+
112
+ ```bash
113
+ brcc start # Default (Claude Sonnet 4.6)
114
+ brcc start --model nvidia/gpt-oss-120b # Free — no USDC needed
115
+ brcc start --model openai/gpt-5.4 # GPT-5.4
116
+ brcc start --model deepseek/deepseek-chat # Budget coding ($0.28/M)
117
+ brcc start --model anthropic/claude-opus-4.6 # Most capable
118
+ ```
119
+
120
+ ### Inside Claude Code
121
+
122
+ Use `/model` to switch between Sonnet, Opus, and Haiku. Each maps to the BlockRun model you've configured:
123
+
124
+ ```bash
125
+ # Customize what each /model option routes to
126
+ brcc config set sonnet-model anthropic/claude-sonnet-4.6 # default
127
+ brcc config set opus-model anthropic/claude-opus-4.6 # default
128
+ brcc config set haiku-model deepseek/deepseek-chat # cheap alternative
129
+ ```
130
+
131
+ ### List all models
132
+
133
+ ```bash
134
+ $ brcc models
135
+
136
+ Free Models (no USDC needed)
137
+ ──────────────────────────────────────────────────────────────────────
138
+ nvidia/gpt-oss-120b
139
+ nvidia/gpt-oss-20b
140
+
141
+ Paid Models
142
+ ──────────────────────────────────────────────────────────────────────
143
+ Model Input Output
144
+ deepseek/deepseek-chat $0.28/M $0.42/M
145
+ anthropic/claude-haiku-4.5 $1.00/M $5.00/M
146
+ openai/gpt-5.4 $2.50/M $15.00/M
147
+ anthropic/claude-sonnet-4.6 $3.00/M $15.00/M
148
+ anthropic/claude-opus-4.6 $5.00/M $25.00/M
149
+ ... (31 models total)
150
+ ```
151
+
152
+ ---
153
+
55
154
  ## What $5 Gets You
56
155
 
57
156
  | Model | ~Requests per $5 | Best For |
58
157
  |-------|-------------------|----------|
59
- | Claude Sonnet 4.6 | ~100 | Coding (default) |
60
- | GPT-5.4 | ~80 | Reasoning |
61
- | Claude Haiku 4.5 | ~500 | Fast tasks |
62
158
  | DeepSeek V3 | ~5,000 | Budget coding |
63
- | GPT-OSS 120B | Unlimited | Free tier |
64
-
65
- ## Why brcc vs Claude Max Subscription
159
+ | Claude Haiku 4.5 | ~500 | Fast tasks |
160
+ | Claude Sonnet 4.6 | ~100 | General coding |
161
+ | GPT-5.4 | ~80 | Reasoning |
162
+ | Claude Opus 4.6 | ~50 | Most capable |
163
+ | GPT-OSS 120B | **Unlimited** | Free tier |
66
164
 
67
- | | Claude Max ($100-200/mo) | brcc |
68
- |--|--------------------------|------|
69
- | **Rate limits** | Constantly hit | None |
70
- | **Account locks** | Common | Impossible — no account |
71
- | **Phone verification** | Required | Not needed |
72
- | **Pricing** | Opaque, subscription | Transparent, pay-per-token |
73
- | **Region restrictions** | Some countries blocked | Works everywhere |
74
- | **Models** | Claude only | 40+ models (GPT, Gemini, DeepSeek...) |
75
- | **Monthly cost** | $100-200 fixed | $5-50 based on usage |
76
- | **Auth issues** | OAuth, API key conflicts | Wallet = identity |
165
+ ---
77
166
 
78
167
  ## Commands
79
168
 
80
- ### `brcc setup`
169
+ | Command | Description |
170
+ |---------|-------------|
171
+ | `brcc setup [base\|solana]` | Create wallet for payments |
172
+ | `brcc start [--model <id>]` | Start proxy + launch Claude Code |
173
+ | `brcc models` | List all models with pricing |
174
+ | `brcc balance` | Check wallet USDC balance |
175
+ | `brcc config set <key> <value>` | Configure model mappings |
176
+ | `brcc config list` | View current settings |
81
177
 
82
- Creates a wallet and shows the address for funding.
178
+ ### `brcc setup`
83
179
 
84
- ```
85
- $ brcc setup
86
- Wallet created!
87
- Address: 0xCC8c44AD3dc2A58D841c3EB26131E49b22665EF8
88
- Send USDC on Base to this address to fund your account.
180
+ ```bash
181
+ brcc setup # Default: Base chain
182
+ brcc setup base # Coinbase L2 — low fees, fast
183
+ brcc setup solana # Solana — also low fees, fast
89
184
  ```
90
185
 
91
186
  Your wallet is saved to `~/.blockrun/` and shared with all BlockRun tools.
92
187
 
93
188
  ### `brcc start`
94
189
 
95
- Starts the payment proxy and launches Claude Code.
96
-
190
+ ```bash
191
+ brcc start # Default model
192
+ brcc start --model nvidia/gpt-oss-120b # Free model
193
+ brcc start --model openai/gpt-5.4 # Specific model
194
+ brcc start --no-launch # Proxy only mode
195
+ brcc start -p 9000 # Custom port
97
196
  ```
98
- $ brcc start
99
- brcc — BlockRun Claude Code
100
-
101
- Wallet: 0xCC8c...5EF8
102
- Proxy: http://localhost:8402
103
- Backend: https://blockrun.ai/api
104
197
 
105
- Starting Claude Code...
106
- ```
198
+ ### `brcc config`
107
199
 
108
- Options:
109
200
  ```bash
110
- brcc start # Start proxy + launch Claude Code
111
- brcc start --no-launch # Proxy only (for manual Claude Code setup)
112
- brcc start -p 9000 # Custom port
201
+ brcc config set default-model nvidia/gpt-oss-120b
202
+ brcc config set sonnet-model openai/gpt-5.4
203
+ brcc config set opus-model anthropic/claude-opus-4.6
204
+ brcc config set haiku-model deepseek/deepseek-chat
205
+ brcc config list
113
206
  ```
114
207
 
115
- ### `brcc balance`
208
+ ---
116
209
 
117
- Check your USDC balance.
210
+ ## How It Works
118
211
 
119
212
  ```
120
- $ brcc balance
121
- Wallet: 0xCC8c44AD3dc2A58D841c3EB26131E49b22665EF8
122
- USDC Balance: $4.17
213
+ ┌─────────────────────────────────────────────────────────────┐
214
+ │ Claude Code │
215
+ │ (thinks it's talking to Anthropic) │
216
+ └──────────────────────┬──────────────────────────────────────┘
217
+ │ Anthropic Messages API format
218
+
219
+ ┌─────────────────────────────────────────────────────────────┐
220
+ │ brcc proxy (localhost:8402) │
221
+ │ │
222
+ │ 1. Receives request from Claude Code │
223
+ │ 2. Replaces model name (if --model set) │
224
+ │ 3. Signs x402 USDC payment with your wallet │
225
+ │ 4. Forwards to BlockRun API │
226
+ │ 5. Streams response back to Claude Code │
227
+ └──────────────────────┬──────────────────────────────────────┘
228
+ │ + x402 payment signature
229
+
230
+ ┌─────────────────────────────────────────────────────────────┐
231
+ │ BlockRun API (blockrun.ai or sol.blockrun.ai) │
232
+ │ │
233
+ │ Routes to: GPT-5 · Claude · Gemini · DeepSeek · Grok · │
234
+ │ NVIDIA · MiniMax · Moonshot · 40+ models │
235
+ └─────────────────────────────────────────────────────────────┘
123
236
  ```
124
237
 
125
- ## How It Works
126
-
127
- 1. `brcc start` launches a local HTTP proxy on port 8402
128
- 2. Claude Code connects to the proxy (via `ANTHROPIC_BASE_URL`)
129
- 3. When Claude Code makes an API request, the proxy forwards it to BlockRun
130
- 4. If payment is needed, the proxy automatically signs a USDC micropayment
131
- 5. BlockRun processes the request and returns the response
132
- 6. Claude Code gets the response as normal
238
+ Your private key stays on your machine. Only payment signatures are sent.
133
239
 
134
- Your private key never leaves your machine. Only payment signatures are sent.
240
+ ---
135
241
 
136
242
  ## Funding Your Wallet
137
243
 
138
- brcc uses USDC on Base (Coinbase's L2 chain). To fund:
244
+ brcc uses USDC a dollar-pegged stablecoin. No crypto volatility.
139
245
 
140
- 1. **Buy USDC** on [Coinbase](https://coinbase.com), [Binance](https://binance.com), or any exchange
141
- 2. **Send USDC** to your brcc wallet address (shown in `brcc setup`)
142
- 3. **Make sure it's on Base chain** not Ethereum mainnet
246
+ **Base chain (default):**
247
+ 1. Buy USDC on [Coinbase](https://coinbase.com)
248
+ 2. Send to your brcc wallet address (shown in `brcc setup`)
249
+ 3. Make sure it's on **Base** network (not Ethereum mainnet)
143
250
 
144
- Typical cost: $0.001-0.05 per Claude Code interaction. $5 lasts most developers a week.
251
+ **Solana chain:**
252
+ 1. Buy USDC on any exchange
253
+ 2. Send to your brcc Solana address
254
+ 3. Send on **Solana** network
145
255
 
146
- ## Available Models
256
+ Typical cost: **$0.001–$0.05 per interaction**. $5 lasts most developers a week.
147
257
 
148
- All [BlockRun models](https://blockrun.ai) work through brcc:
149
-
150
- - **OpenAI**: GPT-5.4, GPT-5.2, GPT-5-mini, o3, o4-mini
151
- - **Anthropic**: Claude Opus 4.6, Sonnet 4.6, Haiku 4.5
152
- - **Google**: Gemini 3.1 Pro, 2.5 Pro, 2.5 Flash
153
- - **DeepSeek**: V3, Reasoner
154
- - **xAI**: Grok 3, Grok 4
155
- - **Free**: NVIDIA GPT-OSS 120B (no payment needed)
258
+ ---
156
259
 
157
260
  ## FAQ
158
261
 
159
- **Q: Is this legal?**
160
- A: Yes. brcc is an API proxy. You're using Claude Code (Anthropic's open CLI) with a different API backend. OpenRouter, LiteLLM, and others do the same thing. No Anthropic terms are violated because no Anthropic services are used.
161
-
162
- **Q: Do I need an Anthropic account?**
163
- A: No. brcc bypasses Anthropic entirely. You don't need an Anthropic account, API key, or subscription.
164
-
165
- **Q: Is my wallet safe?**
166
- A: Your private key stays on your machine (`~/.blockrun/.session`, chmod 600). It's only used for local signing — never transmitted over the network.
262
+ **Do I need an Anthropic account?**
263
+ No. brcc connects Claude Code to BlockRun instead of Anthropic.
167
264
 
168
- **Q: What if BlockRun goes down?**
169
- A: Your wallet and funds are yours on-chain. USDC is always withdrawable regardless of BlockRun's status.
265
+ **Can I use non-Claude models?**
266
+ Yes. GPT-5, Gemini, DeepSeek, Grok, and 30+ others work through Claude Code via brcc.
170
267
 
171
- **Q: Can I use models other than Claude?**
172
- A: Yes. Claude Code works with any model that speaks the Anthropic Messages API format. Through brcc, you can use GPT-5, Gemini, DeepSeek, and 30+ other models.
268
+ ---
173
269
 
174
270
  ## Links
175
271
 
176
272
  - [BlockRun](https://blockrun.ai) — The AI gateway powering brcc
177
- - [BlockRun TypeScript SDK](https://www.npmjs.com/package/@blockrun/llm)
178
- - [Telegram](https://t.me/+mroQv4-4hGgzOGUx)
273
+ - [npm package](https://npmjs.com/package/@blockrun/cc)
274
+ - [Roadmap](docs/ROADMAP.md)
275
+ - [Telegram](https://t.me/blockrunAI)
179
276
  - [GitHub Issues](https://github.com/BlockRunAI/brcc/issues)
180
277
 
181
278
  ## License
@@ -0,0 +1,9 @@
1
+ export interface BrccConfig {
2
+ 'default-model'?: string;
3
+ 'sonnet-model'?: string;
4
+ 'opus-model'?: string;
5
+ 'haiku-model'?: string;
6
+ 'smart-routing'?: string;
7
+ }
8
+ export declare function loadConfig(): BrccConfig;
9
+ export declare function configCommand(action: string, keyOrUndefined?: string, value?: string): void;
@@ -0,0 +1,92 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import chalk from 'chalk';
4
+ import { BLOCKRUN_DIR } from '../config.js';
5
+ const CONFIG_FILE = path.join(BLOCKRUN_DIR, 'brcc-config.json');
6
+ const VALID_KEYS = [
7
+ 'default-model',
8
+ 'sonnet-model',
9
+ 'opus-model',
10
+ 'haiku-model',
11
+ 'smart-routing',
12
+ ];
13
+ export function loadConfig() {
14
+ try {
15
+ const content = fs.readFileSync(CONFIG_FILE, 'utf-8');
16
+ return JSON.parse(content);
17
+ }
18
+ catch {
19
+ return {};
20
+ }
21
+ }
22
+ function saveConfig(config) {
23
+ fs.mkdirSync(BLOCKRUN_DIR, { recursive: true });
24
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', {
25
+ mode: 0o600,
26
+ });
27
+ }
28
+ function isValidKey(key) {
29
+ return VALID_KEYS.includes(key);
30
+ }
31
+ export function configCommand(action, keyOrUndefined, value) {
32
+ if (action === 'list') {
33
+ const config = loadConfig();
34
+ const entries = Object.entries(config);
35
+ if (entries.length === 0) {
36
+ console.log(chalk.dim('No config set. Defaults will be used.'));
37
+ console.log(chalk.dim(`\nConfig file: ${CONFIG_FILE}`));
38
+ return;
39
+ }
40
+ console.log(chalk.bold('brcc config\n'));
41
+ for (const [k, v] of entries) {
42
+ console.log(` ${chalk.cyan(k)} = ${chalk.green(v)}`);
43
+ }
44
+ console.log(chalk.dim(`\nConfig file: ${CONFIG_FILE}`));
45
+ return;
46
+ }
47
+ if (action === 'get') {
48
+ if (!keyOrUndefined) {
49
+ console.log(chalk.red('Usage: brcc config get <key>'));
50
+ process.exit(1);
51
+ }
52
+ const config = loadConfig();
53
+ const val = config[keyOrUndefined];
54
+ if (val !== undefined) {
55
+ console.log(val);
56
+ }
57
+ else {
58
+ console.log(chalk.dim('(not set)'));
59
+ }
60
+ return;
61
+ }
62
+ if (action === 'set') {
63
+ if (!keyOrUndefined || value === undefined) {
64
+ console.log(chalk.red('Usage: brcc config set <key> <value>'));
65
+ process.exit(1);
66
+ }
67
+ if (!isValidKey(keyOrUndefined)) {
68
+ console.log(chalk.red(`Unknown config key: ${keyOrUndefined}`));
69
+ console.log(`Valid keys: ${VALID_KEYS.map((k) => chalk.cyan(k)).join(', ')}`);
70
+ process.exit(1);
71
+ }
72
+ const config = loadConfig();
73
+ config[keyOrUndefined] = value;
74
+ saveConfig(config);
75
+ console.log(`${chalk.cyan(keyOrUndefined)} = ${chalk.green(value)}`);
76
+ return;
77
+ }
78
+ if (action === 'unset') {
79
+ if (!keyOrUndefined) {
80
+ console.log(chalk.red('Usage: brcc config unset <key>'));
81
+ process.exit(1);
82
+ }
83
+ const config = loadConfig();
84
+ delete config[keyOrUndefined];
85
+ saveConfig(config);
86
+ console.log(chalk.dim(`Unset ${keyOrUndefined}`));
87
+ return;
88
+ }
89
+ console.log(chalk.red(`Unknown action: ${action}`));
90
+ console.log('Usage: brcc config <set|get|unset|list> [key] [value]');
91
+ process.exit(1);
92
+ }
@@ -3,6 +3,7 @@ import chalk from 'chalk';
3
3
  import { getOrCreateWallet, getOrCreateSolanaWallet } from '@blockrun/llm';
4
4
  import { createProxy } from '../proxy/server.js';
5
5
  import { loadChain, API_URLS, DEFAULT_PROXY_PORT } from '../config.js';
6
+ import { loadConfig } from './config.js';
6
7
  export async function startCommand(options) {
7
8
  const chain = loadChain();
8
9
  const apiUrl = API_URLS[chain];
@@ -57,6 +58,10 @@ function launchServer(server, port, shouldLaunch, model) {
57
58
  const cleanEnv = { ...process.env };
58
59
  delete cleanEnv.CLAUDE_ACCESS_TOKEN;
59
60
  delete cleanEnv.CLAUDE_OAUTH_TOKEN;
61
+ const config = loadConfig();
62
+ const sonnetModel = config['sonnet-model'] || 'anthropic/claude-sonnet-4.6';
63
+ const opusModel = config['opus-model'] || 'anthropic/claude-opus-4.6';
64
+ const haikuModel = config['haiku-model'] || 'anthropic/claude-haiku-4.5';
60
65
  const claudeArgs = [];
61
66
  if (model)
62
67
  claudeArgs.push('--model', model);
@@ -66,6 +71,10 @@ function launchServer(server, port, shouldLaunch, model) {
66
71
  ...cleanEnv,
67
72
  ANTHROPIC_BASE_URL: `http://localhost:${port}/api`,
68
73
  ANTHROPIC_API_KEY: 'sk-ant-api03-brcc-proxy-00000000000000000000000000000000000000000000-00000000000000',
74
+ ANTHROPIC_DEFAULT_SONNET_MODEL: sonnetModel,
75
+ ANTHROPIC_DEFAULT_OPUS_MODEL: opusModel,
76
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: haikuModel,
77
+ ...(model ? { ANTHROPIC_MODEL: model } : {}),
69
78
  },
70
79
  });
71
80
  claude.on('error', (err) => {
package/dist/index.js CHANGED
@@ -4,11 +4,13 @@ import { setupCommand } from './commands/setup.js';
4
4
  import { startCommand } from './commands/start.js';
5
5
  import { balanceCommand } from './commands/balance.js';
6
6
  import { modelsCommand } from './commands/models.js';
7
+ import { configCommand } from './commands/config.js';
7
8
  const program = new Command();
8
9
  program
9
10
  .name('brcc')
10
- .description('BlockRun Claude Code — run Claude Code with any model, pay with USDC')
11
- .version('0.1.0');
11
+ .description('BlockRun Claude Code — run Claude Code with any model, pay with USDC.\n\n' +
12
+ 'Use /model inside Claude Code to switch between models on the fly.')
13
+ .version('0.5.0');
12
14
  program
13
15
  .command('setup [chain]')
14
16
  .description('Create a new wallet for payments (base or solana)')
@@ -17,7 +19,7 @@ program
17
19
  .command('start')
18
20
  .description('Start proxy and launch Claude Code')
19
21
  .option('-p, --port <port>', 'Proxy port', '8402')
20
- .option('-m, --model <model>', 'Model to use (e.g. openai/gpt-5.4, nvidia/gpt-oss-120b)')
22
+ .option('-m, --model <model>', 'Default model (e.g. openai/gpt-5.4, anthropic/claude-sonnet-4.6)')
21
23
  .option('--no-launch', 'Start proxy only, do not launch Claude Code')
22
24
  .action(startCommand);
23
25
  program
@@ -28,4 +30,9 @@ program
28
30
  .command('balance')
29
31
  .description('Check wallet USDC balance')
30
32
  .action(balanceCommand);
33
+ program
34
+ .command('config <action> [key] [value]')
35
+ .description('Manage brcc config (set, get, unset, list)\n' +
36
+ 'Keys: default-model, sonnet-model, opus-model, haiku-model, smart-routing')
37
+ .action(configCommand);
31
38
  program.parse();
@@ -7,3 +7,10 @@ export interface ProxyOptions {
7
7
  modelOverride?: string;
8
8
  }
9
9
  export declare function createProxy(options: ProxyOptions): http.Server;
10
+ type RequestCategory = 'simple' | 'code' | 'default';
11
+ interface ClassifiedRequest {
12
+ category: RequestCategory;
13
+ suggestedModel?: string;
14
+ }
15
+ export declare function classifyRequest(body: string): ClassifiedRequest;
16
+ export {};
@@ -29,13 +29,19 @@ export function createProxy(options) {
29
29
  });
30
30
  req.on('end', async () => {
31
31
  try {
32
- if (options.modelOverride && body) {
32
+ if (body) {
33
33
  try {
34
34
  const parsed = JSON.parse(body);
35
- if (parsed.model) {
35
+ if (options.modelOverride && parsed.model) {
36
36
  parsed.model = options.modelOverride;
37
- body = JSON.stringify(parsed);
38
37
  }
38
+ if (parsed.max_tokens && parsed.max_tokens > 8192) {
39
+ const model = parsed.model || '';
40
+ if (model.includes('deepseek') || model.includes('haiku')) {
41
+ parsed.max_tokens = 8192;
42
+ }
43
+ }
44
+ body = JSON.stringify(parsed);
39
45
  }
40
46
  catch { /* not JSON, pass through */ }
41
47
  }
@@ -149,6 +155,38 @@ async function handleSolanaPayment(response, url, method, headers, body, private
149
155
  body: body || undefined,
150
156
  });
151
157
  }
158
+ export function classifyRequest(body) {
159
+ try {
160
+ const parsed = JSON.parse(body);
161
+ const messages = parsed.messages;
162
+ if (!Array.isArray(messages) || messages.length === 0) {
163
+ return { category: 'default' };
164
+ }
165
+ const lastMessage = messages[messages.length - 1];
166
+ let content = '';
167
+ if (typeof lastMessage.content === 'string') {
168
+ content = lastMessage.content;
169
+ }
170
+ else if (Array.isArray(lastMessage.content)) {
171
+ content = lastMessage.content
172
+ .filter((b) => b.type === 'text' && b.text)
173
+ .map((b) => b.text)
174
+ .join('\n');
175
+ }
176
+ if (content.includes('```') || content.includes('function ') ||
177
+ content.includes('class ') || content.includes('import ') ||
178
+ content.includes('def ') || content.includes('const ')) {
179
+ return { category: 'code' };
180
+ }
181
+ if (content.length < 100) {
182
+ return { category: 'simple' };
183
+ }
184
+ return { category: 'default' };
185
+ }
186
+ catch {
187
+ return { category: 'default' };
188
+ }
189
+ }
152
190
  // ======================================================================
153
191
  // Shared helpers
154
192
  // ======================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/cc",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Run Claude Code with any model — no rate limits, no account locks, no phone verification. Pay per use with USDC.",
5
5
  "type": "module",
6
6
  "bin": {