ghc-proxy 0.6.2 → 0.7.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 +38 -61
- package/dist/main.mjs +1225 -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,18 +186,17 @@ 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 |
|
|
199
197
|
| `responsesApiContextManagementModels` | `string[]` | -- | Models eligible for auto-injected Responses `context_management` |
|
|
198
|
+
| `responsesApiParameterFilters` | `{ models, params }[]` | -- | Extra rules to strip request parameters on the Responses boundary (see [Responses Parameter Filters](#responses-parameter-filters)) |
|
|
199
|
+
| `responsesApiParameterFiltersReplaceDefault` | `boolean` | `false` | Disable the built-in reasoning-model default rule so only your `responsesApiParameterFilters` apply |
|
|
200
200
|
| `responsesOfficialEmulator` | `boolean` | `false` | Enable local OpenAI-style Responses state emulation for `previous_response_id`, `conversation`, retrieve, input_items, delete, and input_tokens |
|
|
201
201
|
| `responsesOfficialEmulatorTtlSeconds` | `number` | `14400` | In-memory TTL for locally emulated Responses state |
|
|
202
202
|
| `modelReasoningEfforts` | `Record<string, string>` | -- | Per-model reasoning effort defaults for Anthropic-to-Responses translation |
|
|
@@ -209,16 +209,11 @@ Example:
|
|
|
209
209
|
{ "from": "claude-haiku-*", "to": "gpt-4.1-mini" }
|
|
210
210
|
],
|
|
211
211
|
"modelFallback": {
|
|
212
|
-
"claudeOpus": "claude-opus-4.
|
|
212
|
+
"claudeOpus": "claude-opus-4.8",
|
|
213
213
|
"claudeSonnet": "claude-sonnet-4.6"
|
|
214
214
|
},
|
|
215
215
|
"smallModel": "gpt-4.1-mini",
|
|
216
216
|
"compactUseSmallModel": true,
|
|
217
|
-
"contextUpgrade": true,
|
|
218
|
-
"contextUpgradeRules": [
|
|
219
|
-
{ "from": "claude-opus-4.6", "to": "claude-opus-4.6-1m" }
|
|
220
|
-
],
|
|
221
|
-
"contextUpgradeTokenThreshold": 160000,
|
|
222
217
|
"useFunctionApplyPatch": true,
|
|
223
218
|
"responsesApiAutoCompactInput": false,
|
|
224
219
|
"responsesApiAutoContextManagement": false,
|
|
@@ -245,7 +240,7 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
245
240
|
|
|
246
241
|
| Prefix | Default Fallback |
|
|
247
242
|
|--------|-----------------|
|
|
248
|
-
| `claude-opus-*` | `claude-opus-4.
|
|
243
|
+
| `claude-opus-*` | `claude-opus-4.8` |
|
|
249
244
|
| `claude-sonnet-*` | `claude-sonnet-4.6` |
|
|
250
245
|
| `claude-haiku-*` | `claude-haiku-4.5` |
|
|
251
246
|
|
|
@@ -254,7 +249,7 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
254
249
|
You can override the defaults with **environment variables**:
|
|
255
250
|
|
|
256
251
|
```bash
|
|
257
|
-
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-4.
|
|
252
|
+
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-4.8
|
|
258
253
|
MODEL_FALLBACK_CLAUDE_SONNET=claude-sonnet-4.6
|
|
259
254
|
MODEL_FALLBACK_CLAUDE_HAIKU=claude-haiku-4.5
|
|
260
255
|
```
|
|
@@ -264,7 +259,7 @@ Or in the proxy's **config file** (`~/.local/share/ghc-proxy/config.json`):
|
|
|
264
259
|
```json
|
|
265
260
|
{
|
|
266
261
|
"modelFallback": {
|
|
267
|
-
"claudeOpus": "claude-opus-4.
|
|
262
|
+
"claudeOpus": "claude-opus-4.8",
|
|
268
263
|
"claudeSonnet": "claude-sonnet-4.6",
|
|
269
264
|
"claudeHaiku": "claude-haiku-4.5"
|
|
270
265
|
}
|
|
@@ -288,48 +283,7 @@ For more general model substitution, use `modelRewrites` in the config file. Eac
|
|
|
288
283
|
|
|
289
284
|
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
285
|
|
|
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
|
-
```
|
|
286
|
+
Rewrites run **before** any other model policy — small-model routing and strategy selection all see the rewritten model.
|
|
333
287
|
|
|
334
288
|
### Small-Model Routing
|
|
335
289
|
|
|
@@ -429,6 +383,7 @@ This keeps the existing chat pipeline stable while allowing newer Copilot models
|
|
|
429
383
|
- automatic Responses `context_management` injection is disabled by default and only applies when `responsesApiAutoContextManagement` is `true` and the model matches `responsesApiContextManagementModels`
|
|
430
384
|
- automatic trimming of Responses `input` to the latest `compaction` item is disabled by default and only applies when `responsesApiAutoCompactInput` is `true`
|
|
431
385
|
- reasoning defaults for Anthropic -> Responses translation can be tuned with `modelReasoningEfforts`
|
|
386
|
+
- request parameters that a model rejects (e.g. `temperature`/`top_p` on reasoning models) are stripped on the Responses boundary rather than leaked upstream as a `400`; see [Responses Parameter Filters](#responses-parameter-filters)
|
|
432
387
|
- known unsupported builtin tools, such as `web_search`, fail explicitly with `400` instead of being silently removed
|
|
433
388
|
- external image URLs on the Responses path fail explicitly with `400`; use `file_id` or data URL image input instead
|
|
434
389
|
- official `input_file` and `item_reference` input items are modeled explicitly and validated before forwarding
|
|
@@ -447,6 +402,28 @@ Example opt-in configuration for these two Responses-specific policies:
|
|
|
447
402
|
|
|
448
403
|
> See [Responses Upstream Notes](./docs/responses-upstream-notes.md) for detailed upstream compatibility observations from live testing.
|
|
449
404
|
|
|
405
|
+
### Responses Parameter Filters
|
|
406
|
+
|
|
407
|
+
Some Copilot models reject request parameters that the OpenAI wire format allows. The clearest case: **reasoning models** (the `gpt-5` family, o-series, codex) reject sampling parameters and answer `POST /responses` with `400 Unsupported parameter: 'temperature' is not supported with this model.` Since the client cannot always be changed, the proxy strips the offending parameters on the Responses boundary instead of leaking the incompatibility outward.
|
|
408
|
+
|
|
409
|
+
This is expressed as a small rule engine that runs on both the native `/v1/responses` path and the `/v1/messages` → Responses translation path:
|
|
410
|
+
|
|
411
|
+
- **Built-in default rule:** any model that advertises `reasoning_effort` has `temperature` and `top_p` stripped. This covers the whole reasoning family (including future point releases like `gpt-5.4-mini`) with no configuration.
|
|
412
|
+
- **`responsesApiParameterFilters`:** add your own rules. Each rule is `{ "models": [glob, ...], "params": [name, ...] }`; every rule whose `models` glob matches the resolved model contributes its `params`. Rules are **added** to the default (the union of parameters is stripped). Model globs use the same `*` wildcard as `modelRewrites`.
|
|
413
|
+
- **`responsesApiParameterFiltersReplaceDefault`:** set to `true` to disable the built-in reasoning-model rule, so only your `responsesApiParameterFilters` apply — use this to fully **overwrite** the default behavior.
|
|
414
|
+
|
|
415
|
+
Stripped parameters are removed entirely (never sent as `null`), because upstream rejects the mere presence of the key.
|
|
416
|
+
|
|
417
|
+
```json
|
|
418
|
+
{
|
|
419
|
+
"responsesApiParameterFilters": [
|
|
420
|
+
{ "models": ["gpt-5*", "o1*"], "params": ["temperature", "top_p"] },
|
|
421
|
+
{ "models": ["some-model"], "params": ["top_k"] }
|
|
422
|
+
],
|
|
423
|
+
"responsesApiParameterFiltersReplaceDefault": false
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
450
427
|
## Docker
|
|
451
428
|
|
|
452
429
|
Pre-built images are available on GHCR:
|
|
@@ -522,9 +499,9 @@ bun run matrix:live --stateful-only --json --model=gpt-5.2-codex
|
|
|
522
499
|
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
500
|
|
|
524
501
|
```bash
|
|
525
|
-
bun scripts/
|
|
526
|
-
bun scripts/
|
|
527
|
-
bun scripts/
|
|
502
|
+
bun scripts/probes/copilot-tools.ts # human-readable table
|
|
503
|
+
bun scripts/probes/copilot-tools.ts --json # JSON snapshot to stdout
|
|
504
|
+
bun scripts/probes/copilot-tools.ts --model=claude-opus-4.6 # single model
|
|
528
505
|
```
|
|
529
506
|
|
|
530
507
|
The JSON output is designed for weekly diffing — `generatedAt` is the only volatile field:
|