@jeffreycao/copilot-api 2.5.4 → 2.5.6

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
@@ -12,7 +12,7 @@
12
12
 
13
13
  <p align="center">
14
14
  <a href="https://www.npmjs.com/package/@jeffreycao/copilot-api"><img src="https://img.shields.io/npm/v/@jeffreycao/copilot-api.svg" alt="npm version"></a>
15
- <a href="https://github.com/caozhiyuan/copilot-api/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
15
+ <a href="https://github.com/caozhiyuan/copilot-api/blob/dev/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
16
16
  <a href="https://github.com/caozhiyuan/copilot-api/stargazers"><img src="https://img.shields.io/github/stars/caozhiyuan/copilot-api.svg" alt="GitHub stars"></a>
17
17
  <a href="https://bun.sh"><img src="https://img.shields.io/badge/Bun-%3E%3D1.2.x-orange.svg" alt="Bun >= 1.2.x"></a>
18
18
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-%3E%3D22.13.0-green.svg" alt="Node >= 22.13.0"></a>
@@ -425,30 +425,39 @@ npx @jeffreycao/copilot-api@latest start
425
425
 
426
426
  ## Using with Docker
427
427
 
428
- Build the image:
428
+ The supplied Compose file uses the current published `ghcr.io/caozhiyuan/copilot-api:latest` image. No local image build is required. It stores gateway state in `/data` and runs the server as the non-root `bun` user.
429
+
430
+ ### Quick start with Docker Compose
431
+
432
+ Run these commands from the repository root. Replace `YOUR_GATEWAY_API_KEY` with a strong key for clients connecting to this gateway:
429
433
 
430
434
  ```sh
431
- docker build -t copilot-api .
435
+ mkdir -p copilot-data
436
+ docker compose pull
437
+ docker compose run --rm copilot-api --auth keys --add YOUR_GATEWAY_API_KEY
438
+ docker compose run --rm copilot-api --auth login
439
+ docker compose up -d
440
+ docker compose ps
432
441
  ```
433
442
 
434
- Run the container with a bind mount so auth data survives restarts:
443
+ If `COPILOT_API_GITHUB_TOKEN` or the legacy `GH_TOKEN` is already available in your environment or a private `.env` file, you can skip `--auth login`. A GitHub token authorizes access to GitHub Copilot; it does not replace the gateway API key configured above.
435
444
 
436
- ```sh
437
- mkdir -p ./copilot-data
438
- docker run --rm -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api --auth keys --add your-gateway-api-key
439
- docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api
445
+ Before every server or authentication run, the one-shot `data-init` service repairs ownership of the gateway's own state in the mounted data directory: `config.json`, `github_token` (including the enterprise `ent_github_token` and OAuth app subdirectories such as `opencode/github_token`), `codex_credentials.json`, `desktop-config.json`, `copilot-api.sqlite*`, `logs/`, and `cache/`. Other files and directories in the mount are left untouched. This lets the non-root server reuse files written by an earlier root container, including mode `0600` configuration files. The host directory defaults to `./copilot-data`, matching the earlier Docker instructions; Compose mounts it at `/data` and sets `COPILOT_API_HOME` accordingly. Set `COPILOT_API_DATA_DIR` in the environment or your own `.env` to use an existing directory elsewhere.
446
+
447
+ ```dotenv
448
+ COPILOT_API_DATA_DIR=/absolute/path/to/copilot-data
440
449
  ```
441
450
 
442
- This stores GitHub auth data, provider config, and other gateway state in `./copilot-data` on the host, mapped to `/root/.local/share/copilot-api` in the container.
443
- The image explicitly listens on `0.0.0.0` so Docker port publishing works and refuses to start until at least one gateway API key is configured. Non-loopback listeners also restrict CORS to the request's own origin.
451
+ Create the host directory before the first run. Compose does not auto-create a missing host directory (`create_host_path: false`), so a typo in `COPILOT_API_DATA_DIR` fails fast instead of starting with empty state. The one-shot `data-init` service also refuses unsafe values such as `/`, and refuses to run when the mount contains system directories (`/etc`, `/usr`, and so on), which means the path resolved to a system root.
444
452
 
445
- Or pass a GitHub token directly:
453
+ The local endpoint is `http://127.0.0.1:4141`. To publish the gateway on every host interface after configuring a gateway API key, add this to your `.env`:
446
454
 
447
- ```sh
448
- docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api -e GH_TOKEN=your_github_token_here copilot-api
455
+ ```dotenv
456
+ COPILOT_API_BIND=0.0.0.0
457
+ COPILOT_API_PORT=4141
449
458
  ```
450
459
 
451
- The entrypoint exports `GH_TOKEN` as `COPILOT_API_GITHUB_TOKEN`, so the token is handed to the server through the environment instead of the process arguments.
460
+ Token and proxy variables can be overridden in the same file. Proxy addresses must be reachable from inside the container. Keep the internal port at `4141` so the health check remains valid.
452
461
 
453
462
  ## Electron Desktop App
454
463
 
package/README.zh-CN.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  <p align="center">
14
14
  <a href="https://www.npmjs.com/package/@jeffreycao/copilot-api"><img src="https://img.shields.io/npm/v/@jeffreycao/copilot-api.svg" alt="npm version"></a>
15
- <a href="https://github.com/caozhiyuan/copilot-api/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
15
+ <a href="https://github.com/caozhiyuan/copilot-api/blob/dev/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
16
16
  <a href="https://github.com/caozhiyuan/copilot-api/stargazers"><img src="https://img.shields.io/github/stars/caozhiyuan/copilot-api.svg" alt="GitHub stars"></a>
17
17
  <a href="https://bun.sh"><img src="https://img.shields.io/badge/Bun-%3E%3D1.2.x-orange.svg" alt="Bun >= 1.2.x"></a>
18
18
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-%3E%3D22.13.0-green.svg" alt="Node >= 22.13.0"></a>
@@ -455,30 +455,39 @@ npx @jeffreycao/copilot-api@latest start
455
455
 
456
456
  ## 配合 Docker 使用
457
457
 
458
- 构建镜像:
458
+ 仓库提供的 Compose 文件使用当前已发布的 `ghcr.io/caozhiyuan/copilot-api:latest` 镜像,无需在用户机器上构建镜像。它将 gateway 状态保存在 `/data`,并以非 root 的 `bun` 用户运行服务。
459
+
460
+ ### 使用 Docker Compose 快速启动
461
+
462
+ 在仓库根目录执行以下命令。将 `YOUR_GATEWAY_API_KEY` 替换为客户端访问 gateway 时使用的强密钥:
459
463
 
460
464
  ```sh
461
- docker build -t copilot-api .
465
+ mkdir -p copilot-data
466
+ docker compose pull
467
+ docker compose run --rm copilot-api --auth keys --add YOUR_GATEWAY_API_KEY
468
+ docker compose run --rm copilot-api --auth login
469
+ docker compose up -d
470
+ docker compose ps
462
471
  ```
463
472
 
464
- 通过 bind mount 运行容器,让认证数据在重启后保留:
473
+ 如果环境变量或用户自己创建的私有 `.env` 中已经设置 `COPILOT_API_GITHUB_TOKEN` 或旧变量 `GH_TOKEN`,可以跳过 `--auth login`。GitHub token 用于访问 GitHub Copilot,不能替代上面配置的 gateway API Key。
465
474
 
466
- ```sh
467
- mkdir -p ./copilot-data
468
- docker run --rm -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api --auth keys --add your-gateway-api-key
469
- docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api copilot-api
475
+ 每次启动服务或执行认证命令前,一次性的 `data-init` 服务只会修复挂载目录中属于 gateway 自身的状态文件:`config.json`、`github_token`(含企业版的 `ent_github_token`,以及 `opencode/github_token` 这类 OAuth 应用子目录)、`codex_credentials.json`、`desktop-config.json`、`copilot-api.sqlite*`、`logs/` 和 `cache/`。挂载目录中的其他文件和目录不会被改动。因此非 root 服务可以直接复用旧 root 容器写入的数据,包括权限为 `0600` 的配置文件。宿主机目录仍默认使用旧 Docker 文档中的 `./copilot-data`;Compose 将它挂载到 `/data`,并设置对应的 `COPILOT_API_HOME`。如需复用其他位置的已有目录,可在环境变量或用户自己的 `.env` 中设置 `COPILOT_API_DATA_DIR`。
476
+
477
+ ```dotenv
478
+ COPILOT_API_DATA_DIR=/absolute/path/to/copilot-data
470
479
  ```
471
480
 
472
- 这会把宿主机上的 `./copilot-data` 映射到容器内的 `/root/.local/share/copilot-api`,用于持久化 GitHub 认证数据、provider 配置和其他 gateway 状态。
473
- 镜像会显式监听 `0.0.0.0` 以支持 Docker 端口映射,并在未配置网关 API Key 时拒绝启动。非回环监听还会将 CORS 限制为请求自身的同源地址。
481
+ 首次运行前请先建好宿主机目录。Compose 不会自动创建缺失的宿主机目录(`create_host_path: false`),因此 `COPILOT_API_DATA_DIR` 写错会直接报错,而不会以空状态启动。一次性的 `data-init` 服务在改归属前会拒绝 `/` 这类危险路径;当挂载内容中出现 `/etc`、`/usr` 等系统目录时(说明路径实际指向了系统根目录)也会直接拒绝运行。
474
482
 
475
- 也可以直接通过环境变量传入 GitHub token:
483
+ 默认本地地址为 `http://127.0.0.1:4141`。配置好 gateway API Key 后,如需监听宿主机所有网卡,可在用户自己的 `.env` 中设置:
476
484
 
477
- ```sh
478
- docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api -e GH_TOKEN=your_github_token_here copilot-api
485
+ ```dotenv
486
+ COPILOT_API_BIND=0.0.0.0
487
+ COPILOT_API_PORT=4141
479
488
  ```
480
489
 
481
- entrypoint 会把 `GH_TOKEN` 导出为 `COPILOT_API_GITHUB_TOKEN`,因此 token 是通过环境变量交给服务的,不会出现在进程参数里。
490
+ Token 和代理变量也可以在同一文件中覆盖。代理地址必须能从容器内部访问。容器内部端口保持 `4141`,以便健康检查正常工作。
482
491
 
483
492
  <a id="electron-desktop-app"></a>
484
493
 
package/dist/main.js CHANGED
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
30
30
  const { auth } = await import("./auth-BKEWjsYR.js");
31
31
  const { debug } = await import("./debug-CcgIYPL-.js");
32
32
  const { mcp } = await import("./mcp-fpSlKZxK.js");
33
- const { start } = await import("./start-R_GdLsiW.js");
33
+ const { start } = await import("./start-r3xnAtBs.js");
34
34
  await runMain(defineCommand({
35
35
  meta: {
36
36
  name: "copilot-api",
@@ -644,7 +644,12 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
644
644
  cachedInput: .04,
645
645
  input: 2,
646
646
  output: 8
647
- }
647
+ },
648
+ reasoningEfforts: [
649
+ "low",
650
+ "high",
651
+ "max"
652
+ ]
648
653
  },
649
654
  "deepseek-v4-pro": {
650
655
  contextWindow: 1e6,
@@ -654,7 +659,12 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
654
659
  cachedInput: .3,
655
660
  input: 9,
656
661
  output: 27
657
- }
662
+ },
663
+ reasoningEfforts: [
664
+ "low",
665
+ "high",
666
+ "max"
667
+ ]
658
668
  }
659
669
  },
660
670
  "opencode-go": {
@@ -805,7 +815,7 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
805
815
  "xhigh"
806
816
  ]
807
817
  },
808
- "deepseek-flash": {
818
+ "deepseek-v4.1-flash": {
809
819
  contextWindow: 1e6,
810
820
  inputModalities: ["text", "image"],
811
821
  maxOutputTokens: 384e3,
@@ -12543,4 +12553,4 @@ createServer();
12543
12553
  //#endregion
12544
12554
  export { createServer };
12545
12555
 
12546
- //# sourceMappingURL=server-Cqju93ku.js.map
12556
+ //# sourceMappingURL=server-DJl6uDKl.js.map