ghc-proxy 0.6.2 → 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 +13 -61
- package/dist/main.mjs +1154 -1416
- package/dist/main.mjs.map +1 -1
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ bunx ghc-proxy@latest start
|
|
|
19
19
|
|
|
20
20
|
Before you start, make sure you have:
|
|
21
21
|
|
|
22
|
-
1. **Bun** (>= 1.
|
|
22
|
+
1. **Bun** (>= 1.3) -- a fast JavaScript runtime used to run the proxy
|
|
23
23
|
- **Windows:** `winget install --id Oven-sh.Bun`
|
|
24
24
|
- **Other platforms:** see the [official installation guide](https://bun.com/docs/installation)
|
|
25
25
|
2. **A GitHub Copilot subscription** -- individual, business, or enterprise
|
|
@@ -59,7 +59,7 @@ Create or edit `~/.claude/settings.json` (this applies globally to all projects)
|
|
|
59
59
|
"env": {
|
|
60
60
|
"ANTHROPIC_BASE_URL": "http://localhost:4141",
|
|
61
61
|
"ANTHROPIC_AUTH_TOKEN": "dummy-token",
|
|
62
|
-
"ANTHROPIC_MODEL": "claude-opus-4.
|
|
62
|
+
"ANTHROPIC_MODEL": "claude-opus-4.8",
|
|
63
63
|
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4.6",
|
|
64
64
|
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4.5",
|
|
65
65
|
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
@@ -87,7 +87,7 @@ bunx ghc-proxy@latest start
|
|
|
87
87
|
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | The model used for Haiku-tier (fast/cheap) tasks |
|
|
88
88
|
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | Disables telemetry and non-essential network traffic |
|
|
89
89
|
|
|
90
|
-
> **Tip:** The model names above (e.g. `claude-opus-4.
|
|
90
|
+
> **Tip:** The model names above (e.g. `claude-opus-4.8`) are mapped to actual Copilot models by the proxy. See [Model Mapping](#model-mapping) below for details.
|
|
91
91
|
|
|
92
92
|
See the [Claude Code settings docs](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables) for more options.
|
|
93
93
|
|
|
@@ -100,6 +100,7 @@ bunx ghc-proxy@latest start # Start the proxy server
|
|
|
100
100
|
bunx ghc-proxy@latest auth # Run GitHub auth flow without starting the server
|
|
101
101
|
bunx ghc-proxy@latest check-usage # Show your Copilot usage/quota in the terminal
|
|
102
102
|
bunx ghc-proxy@latest debug # Print diagnostic info (version, paths, token status)
|
|
103
|
+
bunx ghc-proxy@latest selfcheck # Probe the packaged bundle (loads every tokenizer chunk; useful for install troubleshooting)
|
|
103
104
|
```
|
|
104
105
|
|
|
105
106
|
### `start` Options
|
|
@@ -185,14 +186,11 @@ All fields are optional. The full schema:
|
|
|
185
186
|
|-------|------|---------|-------------|
|
|
186
187
|
| `modelRewrites` | `{ from, to }[]` | -- | Glob-pattern model substitution rules (see [Model Rewrites](#model-rewrites)) |
|
|
187
188
|
| `modelFallback` | `object` | -- | Override default model fallbacks (see [Customizing Fallbacks](#customizing-fallbacks)) |
|
|
188
|
-
| `modelFallback.claudeOpus` | `string` | `claude-opus-4.
|
|
189
|
+
| `modelFallback.claudeOpus` | `string` | `claude-opus-4.8` | Fallback for `claude-opus-*` models |
|
|
189
190
|
| `modelFallback.claudeSonnet` | `string` | `claude-sonnet-4.6` | Fallback for `claude-sonnet-*` models |
|
|
190
191
|
| `modelFallback.claudeHaiku` | `string` | `claude-haiku-4.5` | Fallback for `claude-haiku-*` models |
|
|
191
192
|
| `smallModel` | `string` | -- | Target model for compact request routing (see [Small-Model Routing](#small-model-routing)) |
|
|
192
193
|
| `compactUseSmallModel` | `boolean` | `false` | Route compact/summarization requests to `smallModel` |
|
|
193
|
-
| `contextUpgrade` | `boolean` | `true` | Enable configured extended-context upgrade rules (see [Context-1M Auto-Upgrade](#context-1m-auto-upgrade)) |
|
|
194
|
-
| `contextUpgradeRules` | `{ from, to }[]` | `[]` | Glob-pattern context upgrade rules used for proactive, reactive, and beta-header upgrades |
|
|
195
|
-
| `contextUpgradeTokenThreshold` | `number` | `160000` | Token threshold for proactive context upgrade |
|
|
196
194
|
| `useFunctionApplyPatch` | `boolean` | `true` | Rewrite `apply_patch` custom tool as function tool on Responses path |
|
|
197
195
|
| `responsesApiAutoCompactInput` | `boolean` | `false` | Automatically trim Responses `input` to the latest `compaction` item |
|
|
198
196
|
| `responsesApiAutoContextManagement` | `boolean` | `false` | Automatically inject Responses `context_management` for selected models |
|
|
@@ -209,16 +207,11 @@ Example:
|
|
|
209
207
|
{ "from": "claude-haiku-*", "to": "gpt-4.1-mini" }
|
|
210
208
|
],
|
|
211
209
|
"modelFallback": {
|
|
212
|
-
"claudeOpus": "claude-opus-4.
|
|
210
|
+
"claudeOpus": "claude-opus-4.8",
|
|
213
211
|
"claudeSonnet": "claude-sonnet-4.6"
|
|
214
212
|
},
|
|
215
213
|
"smallModel": "gpt-4.1-mini",
|
|
216
214
|
"compactUseSmallModel": true,
|
|
217
|
-
"contextUpgrade": true,
|
|
218
|
-
"contextUpgradeRules": [
|
|
219
|
-
{ "from": "claude-opus-4.6", "to": "claude-opus-4.6-1m" }
|
|
220
|
-
],
|
|
221
|
-
"contextUpgradeTokenThreshold": 160000,
|
|
222
215
|
"useFunctionApplyPatch": true,
|
|
223
216
|
"responsesApiAutoCompactInput": false,
|
|
224
217
|
"responsesApiAutoContextManagement": false,
|
|
@@ -245,7 +238,7 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
245
238
|
|
|
246
239
|
| Prefix | Default Fallback |
|
|
247
240
|
|--------|-----------------|
|
|
248
|
-
| `claude-opus-*` | `claude-opus-4.
|
|
241
|
+
| `claude-opus-*` | `claude-opus-4.8` |
|
|
249
242
|
| `claude-sonnet-*` | `claude-sonnet-4.6` |
|
|
250
243
|
| `claude-haiku-*` | `claude-haiku-4.5` |
|
|
251
244
|
|
|
@@ -254,7 +247,7 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
254
247
|
You can override the defaults with **environment variables**:
|
|
255
248
|
|
|
256
249
|
```bash
|
|
257
|
-
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-4.
|
|
250
|
+
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-4.8
|
|
258
251
|
MODEL_FALLBACK_CLAUDE_SONNET=claude-sonnet-4.6
|
|
259
252
|
MODEL_FALLBACK_CLAUDE_HAIKU=claude-haiku-4.5
|
|
260
253
|
```
|
|
@@ -264,7 +257,7 @@ Or in the proxy's **config file** (`~/.local/share/ghc-proxy/config.json`):
|
|
|
264
257
|
```json
|
|
265
258
|
{
|
|
266
259
|
"modelFallback": {
|
|
267
|
-
"claudeOpus": "claude-opus-4.
|
|
260
|
+
"claudeOpus": "claude-opus-4.8",
|
|
268
261
|
"claudeSonnet": "claude-sonnet-4.6",
|
|
269
262
|
"claudeHaiku": "claude-haiku-4.5"
|
|
270
263
|
}
|
|
@@ -288,48 +281,7 @@ For more general model substitution, use `modelRewrites` in the config file. Eac
|
|
|
288
281
|
|
|
289
282
|
Unlike model fallbacks (which only apply to the chat completions path), rewrites are applied **uniformly to all three endpoints** — `/v1/messages`, `/v1/chat/completions`, and `/v1/responses`. Target model names are normalized against Copilot's known model list using dash/dot equivalence (e.g. `gpt-4.1` matches `gpt-4-1`).
|
|
290
283
|
|
|
291
|
-
Rewrites run **before** any other model policy —
|
|
292
|
-
|
|
293
|
-
### Context-1M Auto-Upgrade
|
|
294
|
-
|
|
295
|
-
The proxy can automatically upgrade models to extended-context variants when the request is large. Upgrade targets are config-driven so users only route to models their Copilot account can access.
|
|
296
|
-
|
|
297
|
-
**Proactive upgrade:** Before sending the request, the proxy estimates the input token count. If it exceeds the configured threshold (default: 160,000 tokens), the first matching `contextUpgradeRules` entry is applied before the request is sent.
|
|
298
|
-
|
|
299
|
-
**Reactive upgrade:** If the upstream returns a context-length error (e.g. "context length exceeded"), the proxy retries the request with the configured upgraded model automatically.
|
|
300
|
-
|
|
301
|
-
**Beta header support:** When a client sends an `anthropic-beta: context-*` header (e.g. `context-1m-2025-04-14`), the proxy strips the header (Copilot does not understand it) and applies the configured context upgrade rule instead.
|
|
302
|
-
|
|
303
|
-
Configuration:
|
|
304
|
-
|
|
305
|
-
- `contextUpgrade` (boolean, default `true`) — enable or disable configured auto-upgrade rules
|
|
306
|
-
- `contextUpgradeRules` (`{ from, to }[]`, default `[]`) — glob-pattern model upgrade rules; first match wins
|
|
307
|
-
- `contextUpgradeTokenThreshold` (number, default `160000`) — token count threshold for proactive upgrade
|
|
308
|
-
|
|
309
|
-
Example for the public Opus 4.6 1M model:
|
|
310
|
-
|
|
311
|
-
```json
|
|
312
|
-
{
|
|
313
|
-
"contextUpgradeRules": [
|
|
314
|
-
{ "from": "claude-opus-4.6", "to": "claude-opus-4.6-1m" }
|
|
315
|
-
]
|
|
316
|
-
}
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
Example for an enterprise account with access to the Opus 4.7 internal 1M model:
|
|
320
|
-
|
|
321
|
-
```json
|
|
322
|
-
{
|
|
323
|
-
"modelRewrites": [
|
|
324
|
-
{ "from": "claude-opus-*", "to": "claude-opus-4.7" }
|
|
325
|
-
],
|
|
326
|
-
"contextUpgrade": true,
|
|
327
|
-
"contextUpgradeRules": [
|
|
328
|
-
{ "from": "claude-opus-4.7", "to": "claude-opus-4.7-1m-internal" }
|
|
329
|
-
],
|
|
330
|
-
"contextUpgradeTokenThreshold": 160000
|
|
331
|
-
}
|
|
332
|
-
```
|
|
284
|
+
Rewrites run **before** any other model policy — small-model routing and strategy selection all see the rewritten model.
|
|
333
285
|
|
|
334
286
|
### Small-Model Routing
|
|
335
287
|
|
|
@@ -522,9 +474,9 @@ bun run matrix:live --stateful-only --json --model=gpt-5.2-codex
|
|
|
522
474
|
Tests which server-side tool types (bash, text_editor, web_search, memory, etc.) each Copilot model actually accepts. Useful for tracking backend changes over time.
|
|
523
475
|
|
|
524
476
|
```bash
|
|
525
|
-
bun scripts/
|
|
526
|
-
bun scripts/
|
|
527
|
-
bun scripts/
|
|
477
|
+
bun scripts/probes/copilot-tools.ts # human-readable table
|
|
478
|
+
bun scripts/probes/copilot-tools.ts --json # JSON snapshot to stdout
|
|
479
|
+
bun scripts/probes/copilot-tools.ts --model=claude-opus-4.6 # single model
|
|
528
480
|
```
|
|
529
481
|
|
|
530
482
|
The JSON output is designed for weekly diffing — `generatedAt` is the only volatile field:
|