betahi-copilot-bridge 0.20.2 → 0.20.4
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 +108 -65
- package/dist/main.js +937 -129
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
<h1 align="center">copilot-bridge</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://www.npmjs.com/package/betahi-copilot-bridge"><img src="https://img.shields.io/npm/v/betahi-copilot-bridge.svg?v=0.20.
|
|
4
|
+
<a href="https://www.npmjs.com/package/betahi-copilot-bridge"><img src="https://img.shields.io/npm/v/betahi-copilot-bridge.svg?v=0.20.4" alt="npm version"></a>
|
|
5
5
|
<a href="https://github.com/betahi/copilot-bridge/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/betahi-copilot-bridge.svg" alt="license"></a>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
> Use GitHub Copilot as a local OpenAI/Anthropic-compatible API, so [Codex CLI](https://developers.openai.com/codex/cli), [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) and Continue can talk to Copilot with minimal configuration.
|
|
9
9
|
|
|
10
|
-
> [!
|
|
11
|
-
> This is
|
|
12
|
-
>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
>
|
|
27
|
-
> - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github)
|
|
28
|
-
> - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
|
|
29
|
-
>
|
|
30
|
-
> Use this bridge responsibly to avoid account restrictions. The
|
|
31
|
-
> `--rate-limit <seconds>` flag is provided to help throttle upstream traffic.
|
|
10
|
+
> [!CAUTION]
|
|
11
|
+
> This is an unofficial bridge for the GitHub Copilot API and may break if the
|
|
12
|
+
> upstream API changes.
|
|
13
|
+
|
|
14
|
+
## Contents
|
|
15
|
+
- [Demo](#demo)
|
|
16
|
+
- [Install & run](#install--run)
|
|
17
|
+
- [Configure Codex CLI](#configure-codex-cli)
|
|
18
|
+
- [Configure Claude Code](#configure-claude-code)
|
|
19
|
+
- [Web Search](#web-search)
|
|
20
|
+
- [Start flags](#start-flags)
|
|
21
|
+
- [Environment overrides](#environment-overrides)
|
|
22
|
+
- [Supported models](#supported-models)
|
|
23
|
+
- [Development](#development)
|
|
24
|
+
- [Acknowledgements](#acknowledgements)
|
|
25
|
+
- [License](#license)
|
|
32
26
|
|
|
33
27
|
## Demo
|
|
34
28
|
|
|
@@ -50,10 +44,6 @@ npx betahi-copilot-bridge@latest auth
|
|
|
50
44
|
npx betahi-copilot-bridge@latest start
|
|
51
45
|
```
|
|
52
46
|
|
|
53
|
-
`start` flags: `--host`, `--port`, `--show-token`, `--debug`,
|
|
54
|
-
`--no-codex-setup`, `--select-model`, `--no-prompt`,
|
|
55
|
-
`--rate-limit <seconds>`, `--wait`.
|
|
56
|
-
|
|
57
47
|
After startup the banner prints a **Usage Viewer** link of the form
|
|
58
48
|
`https://betahi.github.io/copilot-bridge?endpoint=http://127.0.0.1:4142/usage`,
|
|
59
49
|
which renders the Copilot quota snapshot (chat / completions / premium
|
|
@@ -65,22 +55,18 @@ The bridge exposes both adapter-style endpoints (`/v1/responses`,
|
|
|
65
55
|
LiteLLM, Continue, Cline and Aider work out of the box. CORS is enabled
|
|
66
56
|
globally for browser-based clients.
|
|
67
57
|
|
|
68
|
-
`--rate-limit N` enforces a minimum of N seconds between upstream
|
|
69
|
-
requests (anti–abuse-detection throttle). Add `--wait` to block instead
|
|
70
|
-
of returning HTTP 429 when the window has not elapsed.
|
|
71
|
-
|
|
72
|
-
`--debug` enables extra upstream error diagnostics in console logs.
|
|
73
|
-
- Includes: token limits, stream mode, tool count, invalid tool names, and suspicious tool-schema paths.
|
|
74
|
-
- Does not include: request messages, prompt text, bearer tokens, tool descriptions, or the full request body.
|
|
75
|
-
|
|
76
|
-
**Review or redact debug logs before sharing them publicly.**
|
|
77
|
-
|
|
78
58
|
## Configure Codex CLI
|
|
79
59
|
|
|
80
60
|
`start` writes a managed block into **`~/.codex/config.toml`**. You don't edit
|
|
81
|
-
|
|
61
|
+
between the markers; the bridge regenerates that block on every start. To pin
|
|
62
|
+
the **default model** for `codex` (without passing `-m` every time), add your
|
|
63
|
+
top-level keys above the managed block:
|
|
82
64
|
|
|
83
65
|
```toml
|
|
66
|
+
# User defaults; edit these freely.
|
|
67
|
+
model = "gpt-5.3-codex"
|
|
68
|
+
model_reasoning_effort = "high"
|
|
69
|
+
|
|
84
70
|
# >>> copilot-bridge managed block — auto-generated, do not edit between markers >>>
|
|
85
71
|
model_provider = "bridge"
|
|
86
72
|
model_supports_reasoning_summaries = true
|
|
@@ -94,37 +80,21 @@ requires_openai_auth = false
|
|
|
94
80
|
# <<< copilot-bridge managed block — edits outside this block are preserved <<<
|
|
95
81
|
```
|
|
96
82
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
these keys across rewrites:
|
|
100
|
-
|
|
101
|
-
```toml
|
|
102
|
-
model = "gpt-5.3-codex"
|
|
103
|
-
model_reasoning_effort = "high"
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
That's it — `codex exec '...'` will now route through the bridge to Copilot.
|
|
107
|
-
|
|
108
|
-
Use `--no-codex-setup` to skip the managed-block writer entirely (e.g. if you
|
|
109
|
-
manage `~/.codex/config.toml` yourself).
|
|
83
|
+
Use `--no-codex-setup` to skip this writer if you manage
|
|
84
|
+
`~/.codex/config.toml` yourself.
|
|
110
85
|
|
|
111
86
|
### Codex warning: "Model metadata ... not found"
|
|
112
87
|
|
|
113
|
-
This is a Codex client-side metadata warning, not a bridge routing failure.
|
|
114
|
-
Requests can still complete through the bridge.
|
|
88
|
+
This is a Codex client-side metadata warning, not a bridge routing failure, requests can still complete through the bridge.
|
|
115
89
|
|
|
116
|
-
For
|
|
90
|
+
For 1M models, upstream still enforces a 1,000,000-token prompt
|
|
117
91
|
limit (about 900k succeeds; around 1,000,046 is rejected as too long).
|
|
118
92
|
|
|
119
93
|
## Configure Claude Code
|
|
120
94
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
`ANTHROPIC_AUTH_TOKEN` if absent) into **`~/.claude/settings.json`**, so
|
|
125
|
-
`claude` works the moment the bridge is listening — even on a different host
|
|
126
|
-
or port. Pass `--no-claude-setup` to skip this. All other keys in your
|
|
127
|
-
settings file (model overrides, plugins, marketplaces) are preserved.
|
|
95
|
+
`copilot-bridge start` writes `ANTHROPIC_BASE_URL` and a dummy
|
|
96
|
+
`ANTHROPIC_AUTH_TOKEN` into **`~/.claude/settings.json`**. Other settings are
|
|
97
|
+
preserved; use `--no-claude-setup` to skip this writer.
|
|
128
98
|
|
|
129
99
|
Minimal recommended config is:
|
|
130
100
|
|
|
@@ -146,12 +116,12 @@ the bridge maps it to the real Copilot `-1m` model upstream:
|
|
|
146
116
|
```json
|
|
147
117
|
{
|
|
148
118
|
"env": {
|
|
149
|
-
"ANTHROPIC_MODEL": "claude-opus-4.7-[1m]"
|
|
119
|
+
"ANTHROPIC_MODEL": "claude-opus-4.7-[1m]"
|
|
150
120
|
}
|
|
151
121
|
}
|
|
152
122
|
```
|
|
153
123
|
|
|
154
|
-
|
|
124
|
+
Slot-specific overrides:
|
|
155
125
|
|
|
156
126
|
```json
|
|
157
127
|
{
|
|
@@ -171,6 +141,76 @@ project-local `.claude/settings.json` and `.claude/settings.local.json` and
|
|
|
171
141
|
applied to Claude requests only when the model supports reasoning. If it is not
|
|
172
142
|
configured, Claude requests do not infer or attach a reasoning effort.
|
|
173
143
|
|
|
144
|
+
## Web Search
|
|
145
|
+
|
|
146
|
+
Not every Copilot model can run web search. If web search is not configured or
|
|
147
|
+
the selected backend cannot search, the bridge tells the client how to configure
|
|
148
|
+
`COPILOT_WEB_SEARCH_BACKEND` and does not switch models automatically.
|
|
149
|
+
|
|
150
|
+
For Claude Code, configure web search in the user-level
|
|
151
|
+
`~/.claude/settings.json`:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"env": {
|
|
156
|
+
"COPILOT_WEB_SEARCH_BACKEND": "gpt-5.5"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
For Codex CLI, configure the same backend as a top-level key in
|
|
162
|
+
`~/.codex/config.toml`:
|
|
163
|
+
|
|
164
|
+
```toml
|
|
165
|
+
COPILOT_WEB_SEARCH_BACKEND = "gpt-5.5"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
| Value | Search path | Requirement |
|
|
169
|
+
| ----- | ----------- | ----------- |
|
|
170
|
+
| Copilot model id, for example `gpt-5.5` | Copilot HTTP `/responses` + `web_search_preview` | The model must support Copilot Responses web search. |
|
|
171
|
+
| `searxng` | Local SearXNG at `http://localhost:8080` | Start SearXNG yourself. Setup guide: https://github.com/betaHi/openclaw-searxng-search. |
|
|
172
|
+
| `copilot-cli` or `copilot` | GitHub Copilot CLI `web_search` tool, using the current request model | Install and sign in to GitHub Copilot CLI yourself. |
|
|
173
|
+
|
|
174
|
+
The bridge never installs Docker, SearXNG, or Copilot CLI automatically.
|
|
175
|
+
|
|
176
|
+
## Start flags
|
|
177
|
+
|
|
178
|
+
Common:
|
|
179
|
+
|
|
180
|
+
| Flag | Purpose |
|
|
181
|
+
| ---- | ------- |
|
|
182
|
+
| `--host <host>` | Bind address. Defaults to `127.0.0.1`. |
|
|
183
|
+
| `--port <port>` | Listen port. Overrides `$PORT` and the port inferred from Claude settings. |
|
|
184
|
+
| `--model <model>` | Override the request model for this bridge process only; does not edit config files. |
|
|
185
|
+
| `--rate-limit <seconds>` | Enforce a minimum delay between upstream requests. |
|
|
186
|
+
| `--wait` | With `--rate-limit`, wait instead of returning HTTP 429. |
|
|
187
|
+
|
|
188
|
+
Codex:
|
|
189
|
+
|
|
190
|
+
| Flag | Purpose |
|
|
191
|
+
| ---- | ------- |
|
|
192
|
+
| `--no-codex-setup` | Skip writing the managed block into `~/.codex/config.toml`. |
|
|
193
|
+
| `--no-prompt` | Never prompt for a Codex default model. |
|
|
194
|
+
|
|
195
|
+
Claude:
|
|
196
|
+
|
|
197
|
+
| Flag | Purpose |
|
|
198
|
+
| ---- | ------- |
|
|
199
|
+
| `--no-claude-setup` | Skip writing `ANTHROPIC_BASE_URL` into `~/.claude/settings.json`. |
|
|
200
|
+
|
|
201
|
+
Diagnostics:
|
|
202
|
+
|
|
203
|
+
| Flag | Purpose |
|
|
204
|
+
| ---- | ------- |
|
|
205
|
+
| `--debug` | Print extra upstream error diagnostics. |
|
|
206
|
+
| `--show-token` | Print GitHub and Copilot tokens during startup. Sensitive; use only for local debugging. |
|
|
207
|
+
|
|
208
|
+
`--debug` enables extra upstream error diagnostics in console logs.
|
|
209
|
+
- Includes: token limits, stream mode, tool count, invalid tool names, and suspicious tool-schema paths.
|
|
210
|
+
- Does not include: request messages, prompt text, bearer tokens, tool descriptions, or the full request body.
|
|
211
|
+
|
|
212
|
+
**Review or redact debug logs before sharing them publicly.**
|
|
213
|
+
|
|
174
214
|
## Environment overrides
|
|
175
215
|
|
|
176
216
|
| Variable | Purpose |
|
|
@@ -181,8 +221,6 @@ configured, Claude requests do not infer or attach a reasoning effort.
|
|
|
181
221
|
| `COPILOT_VSCODE_VERSION` | Override the VS Code version sent upstream. |
|
|
182
222
|
| `MODEL_REASONING_EFFORT` | Claude-side reasoning effort override. |
|
|
183
223
|
|
|
184
|
-
|
|
185
|
-
|
|
186
224
|
## Supported models
|
|
187
225
|
|
|
188
226
|
The bridge resolves aliases and clamps reasoning effort to what each model
|
|
@@ -265,6 +303,11 @@ Adding another CLI: drop a new translator under `src/bridges/<client>/`,
|
|
|
265
303
|
reuse `src/services/copilot/` for upstream calls, register routes in
|
|
266
304
|
`src/server.ts`, and add tests under `tests/`.
|
|
267
305
|
|
|
306
|
+
## Acknowledgements
|
|
307
|
+
|
|
308
|
+
Claude Code bridge notes inspired by
|
|
309
|
+
[ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api). Respect.
|
|
310
|
+
|
|
268
311
|
## License
|
|
269
312
|
|
|
270
313
|
MIT — see [LICENSE](./LICENSE).
|