@nick3/copilot-api 1.5.6 → 1.6.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.
Files changed (32) hide show
  1. package/README.md +41 -31
  2. package/README.zh-CN.md +953 -0
  3. package/dist/{account-AacnHem5.js → account-B2tSWtVS.js} +12 -4
  4. package/dist/account-B2tSWtVS.js.map +1 -0
  5. package/dist/accounts-manager-CAyZJSn8.js +2932 -0
  6. package/dist/accounts-manager-CAyZJSn8.js.map +1 -0
  7. package/dist/admin/assets/index-BESw8Vvd.css +1 -0
  8. package/dist/admin/assets/index-Ddo9RHg-.js +101 -0
  9. package/dist/admin/index.html +2 -2
  10. package/dist/{auth-B7x3wjry.js → auth-BXCeDjRG.js} +3 -3
  11. package/dist/{auth-B7x3wjry.js.map → auth-BXCeDjRG.js.map} +1 -1
  12. package/dist/{check-usage-B1cbDEOI.js → check-usage-CQxXYfUx.js} +3 -3
  13. package/dist/check-usage-CQxXYfUx.js.map +1 -0
  14. package/dist/{get-copilot-token-cha9rQwA.js → get-copilot-token-p17sJyPU.js} +2 -2
  15. package/dist/{get-copilot-token-cha9rQwA.js.map → get-copilot-token-p17sJyPU.js.map} +1 -1
  16. package/dist/main.js +3 -3
  17. package/dist/{poll-access-token-DFooFWhY.js → poll-access-token-Bc6VwWab.js} +105 -40
  18. package/dist/poll-access-token-Bc6VwWab.js.map +1 -0
  19. package/dist/{server-DVpkQrk2.js → server-CFijvv3C.js} +969 -945
  20. package/dist/server-CFijvv3C.js.map +1 -0
  21. package/dist/{start-fPbCDj4c.js → start-DQlnH71A.js} +7 -6
  22. package/dist/start-DQlnH71A.js.map +1 -0
  23. package/package.json +1 -1
  24. package/dist/account-AacnHem5.js.map +0 -1
  25. package/dist/accounts-manager-BE-Dq5Wn.js +0 -1494
  26. package/dist/accounts-manager-BE-Dq5Wn.js.map +0 -1
  27. package/dist/admin/assets/index-CdoHTemy.css +0 -1
  28. package/dist/admin/assets/index-wcoGQpIM.js +0 -66
  29. package/dist/check-usage-B1cbDEOI.js.map +0 -1
  30. package/dist/poll-access-token-DFooFWhY.js.map +0 -1
  31. package/dist/server-DVpkQrk2.js.map +0 -1
  32. package/dist/start-fPbCDj4c.js.map +0 -1
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Copilot API Proxy
2
2
 
3
- English | [中文](./README_CN.md)
3
+ English | [简体中文](./README.zh-CN.md)
4
4
 
5
5
  > [!WARNING]
6
- > This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk. In the current version, if not using opencode OAuth, the device ID and machine ID will be sent to GitHub Copilot. It is not recommended to use a large number of accounts on a single device; if necessary, it is advised to run them in Docker containers.
6
+ > This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk. In the current version, if not using opencode OAuth, the device ID and machine ID will be sent to GitHub Copilot.
7
7
 
8
8
  > [!WARNING]
9
9
  > **GitHub Security Notice:**
@@ -44,7 +44,7 @@ English | [中文](./README_CN.md)
44
44
 
45
45
  ## Project Overview
46
46
 
47
- A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. This allows you to use GitHub Copilot with any tool that supports the OpenAI Chat Completions API or the Anthropic Messages API, including to power [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview).
47
+ A reverse-engineered proxy for the GitHub Copilot API that exposes it as an OpenAI and Anthropic compatible service. This allows you to use GitHub Copilot with any tool that supports the OpenAI Chat Completions / Responses API or the Anthropic Messages API, including to power [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview).
48
48
 
49
49
  Compared with routing everything through plain Chat Completions compatibility, this proxy can prefer Copilot's native Anthropic-style Messages API for Claude-family models, preserve more native thinking/tool semantics, reduce unnecessary Premium request consumption on warmup or resumed tool turns, and expose phase-aware `gpt-5.4` / `gpt-5.3-codex` responses that are easier for users to follow.
50
50
 
@@ -128,10 +128,6 @@ When an Anthropic API key is configured, the proxy forwards Claude model token c
128
128
  > [!NOTE]
129
129
  > Anthropic's `/v1/messages/count_tokens` endpoint is **free** (no per-token cost). It is rate-limited to 100 RPM at Tier 1. The $5 credit purchase is only needed to activate API access — the token counting calls themselves cost nothing.
130
130
 
131
- ## Demo
132
-
133
- https://github.com/user-attachments/assets/7654b383-669d-4eb9-b23c-06d7aefee8c5
134
-
135
131
  ## Prerequisites
136
132
 
137
133
  - Bun (>= 1.2.x)
@@ -145,6 +141,32 @@ To install dependencies, run:
145
141
  bun install
146
142
  ```
147
143
 
144
+ To start the server directly from source:
145
+
146
+ ```sh
147
+ bun run start start
148
+ ```
149
+
150
+ ## Using with npx
151
+
152
+ You can run the project directly using npx:
153
+
154
+ ```sh
155
+ npx @nick3/copilot-api@latest start
156
+ ```
157
+
158
+ With options:
159
+
160
+ ```sh
161
+ npx @nick3/copilot-api@latest start --port 8080
162
+ ```
163
+
164
+ For authentication only:
165
+
166
+ ```sh
167
+ npx @nick3/copilot-api@latest auth
168
+ ```
169
+
148
170
  ## Using with Docker
149
171
 
150
172
  Build image
@@ -233,26 +255,6 @@ The Docker image includes:
233
255
  - Health check for container monitoring
234
256
  - Pinned base image version for reproducible builds
235
257
 
236
- ## Using with npx
237
-
238
- You can run the project directly using npx:
239
-
240
- ```sh
241
- npx @nick3/copilot-api@latest start
242
- ```
243
-
244
- With options:
245
-
246
- ```sh
247
- npx @nick3/copilot-api@latest start --port 8080
248
- ```
249
-
250
- For authentication only:
251
-
252
- ```sh
253
- npx @nick3/copilot-api@latest auth
254
- ```
255
-
256
258
  ## Command Structure
257
259
 
258
260
  Copilot API now uses a subcommand structure with these main commands:
@@ -357,11 +359,14 @@ The `<target>` can be either the account ID (GitHub username) or a 1-based index
357
359
  },
358
360
  "allowOriginalModelNamesForAliases": false,
359
361
  "useFunctionApplyPatch": true,
362
+ "forceAgent": false,
360
363
  "compactUseSmallModel": true,
361
364
  "messageStartInputTokensFallback": false,
362
365
  "modelRefreshIntervalHours": 24,
366
+ "sessionAffinityRetentionDays": 7,
363
367
  "useMessagesApi": true,
364
- "useResponsesApiWebSearch": true
368
+ "useResponsesApiWebSearch": true,
369
+ "logLevel": "info"
365
370
  }
366
371
  ```
367
372
  - **auth.apiKeys:** API keys used for request authentication. Supports multiple keys for rotation. Requests can authenticate with either `x-api-key: <key>` or `Authorization: Bearer <key>`. If empty or omitted, authentication is disabled.
@@ -411,10 +416,14 @@ The `<target>` can be either the account ID (GitHub username) or a 1-based index
411
416
  - **compactUseSmallModel:** When `true`, detected "compact" requests (e.g., from Claude Code or opencode compact mode) will automatically use the configured `smallModel` to avoid consuming premium usage for short/background tasks. Defaults to `true`.
412
417
  - **messageStartInputTokensFallback:** When `true`, the Anthropic streaming translation layer estimates `message_start.input_tokens` when upstream stream events do not provide it. Defaults to `false`.
413
418
  - **modelRefreshIntervalHours:** Interval for refreshing account model lists in the background. Set to `0` to disable refresh. Defaults to `24`.
419
+ - **sessionAffinityRetentionDays:** Number of days to retain session affinity bindings. Defaults to `7`.
414
420
  - **useMessagesApi:** When `true` (default), Claude-family models that support Copilot's native `/v1/messages` endpoint may use the Messages API path. Set to `false` to skip the Messages API candidate and fall back to `/responses` (if supported) or `/chat/completions`.
415
421
  - **useResponsesApiWebSearch:** When `true` (default), `/v1/responses` keeps tools with `type: "web_search"` and forwards them upstream. Set to `false` to strip them before the Copilot request is sent.
422
+ - **logLevel:** Controls handler file-log verbosity under `logs/*.log`. Allowed values: `error`, `warn`, `info`, `debug`. Defaults to `info`. Set it to `debug` when you need payload- or stream-level diagnostics written into file logs.
416
423
  - **anthropicApiKey:** Optional Anthropic API key used for accurate Claude token counting (see [Accurate Claude Token Counting](#accurate-claude-token-counting) below). Can also be set via the `ANTHROPIC_API_KEY` environment variable. If not set, token counting falls back to GPT tokenizer estimation.
417
424
 
425
+ `--verbose` no longer implicitly enables debug-level file logging. If you need detailed handler logs under `logs/*.log`, explicitly set `"logLevel": "debug"` in `config.json`.
426
+
418
427
  Edit this file to customize prompts or swap in your own fast model. If you edit it manually, restart the server (or call `GET /api/admin/config`) so the cached config is refreshed. Changes made through the Admin UI/API are validated, written to disk, and applied immediately; unknown keys are rejected.
419
428
 
420
429
  ## API Authentication
@@ -824,7 +833,8 @@ Here is an example `.claude/settings.json` file:
824
833
  },
825
834
  "permissions": {
826
835
  "deny": [
827
- "WebSearch"
836
+ "WebSearch",
837
+ "mcp__ide__executeCode"
828
838
  ]
829
839
  }
830
840
  }
@@ -910,13 +920,13 @@ The project can be run from source in several ways:
910
920
  ### Development Mode
911
921
 
912
922
  ```sh
913
- bun run dev
923
+ bun run dev start
914
924
  ```
915
925
 
916
926
  ### Production Mode
917
927
 
918
928
  ```sh
919
- bun run start
929
+ bun run start start
920
930
  ```
921
931
 
922
932
  ## Usage Tips