@jeffreycao/copilot-api 1.9.2 → 1.9.3
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 +12 -6
- package/README.zh-CN.md +12 -6
- package/dist/{auth-C3UbfaIB.js → auth-CWEhhJYn.js} +3 -3
- package/dist/{auth-C3UbfaIB.js.map → auth-CWEhhJYn.js.map} +1 -1
- package/dist/{check-usage-CELArOu5.js → check-usage-B5yr4fpk.js} +3 -3
- package/dist/{check-usage-CELArOu5.js.map → check-usage-B5yr4fpk.js.map} +1 -1
- package/dist/main.js +3 -3
- package/dist/{server-CA39Gy7x.js → server-D1nq9oGf.js} +825 -62
- package/dist/server-D1nq9oGf.js.map +1 -0
- package/dist/{start-DKwPr9vl.js → start-1ogeufrV.js} +4 -4
- package/dist/{start-DKwPr9vl.js.map → start-1ogeufrV.js.map} +1 -1
- package/dist/{token-CIwAFD_6.js → token-rgdB2YWP.js} +3 -2
- package/dist/{token-CIwAFD_6.js.map → token-rgdB2YWP.js.map} +1 -1
- package/dist/{utils-DG6CB51Z.js → utils-DEJvF68W.js} +2 -2
- package/dist/utils-DEJvF68W.js.map +1 -0
- package/package.json +1 -1
- package/dist/server-CA39Gy7x.js.map +0 -1
- package/dist/utils-DG6CB51Z.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,11 +21,6 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
> [!NOTE]
|
|
25
|
-
> [opencode](https://github.com/sst/opencode) already ships with a built-in GitHub Copilot provider, so you may not need this project for basic usage. This proxy is still useful if you want OpenCode to talk to Copilot through `@ai-sdk/anthropic`, preserve Anthropic Messages semantics for tool use, prefer the native Messages API over Chat Completions API for Claude-family models, use gpt phase-aware commentary, or optimize premium requests.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
24
|
## Important Notes
|
|
30
25
|
|
|
31
26
|
> [!IMPORTANT]
|
|
@@ -129,6 +124,7 @@ When an Anthropic API key is configured, the proxy forwards Claude model token c
|
|
|
129
124
|
## Prerequisites
|
|
130
125
|
|
|
131
126
|
- Bun (>= 1.2.x)
|
|
127
|
+
- Node.js if you plan to run the published CLI with `npx`
|
|
132
128
|
- GitHub account with Copilot subscription (individual, business, or enterprise)
|
|
133
129
|
|
|
134
130
|
## Installation
|
|
@@ -149,6 +145,11 @@ bun run start start
|
|
|
149
145
|
|
|
150
146
|
You can run the project directly using npx:
|
|
151
147
|
|
|
148
|
+
> [!IMPORTANT]
|
|
149
|
+
> Token usage storage uses Node's built-in `node:sqlite` module when running with `npx`. It is enabled on Node.js >= 22.13.0. On Node.js < 22.13.0, the CLI still starts, but token usage storage is disabled.
|
|
150
|
+
>
|
|
151
|
+
> If you want token usage storage without upgrading Node.js, run the published CLI with Bun instead: `bunx --bun @jeffreycao/copilot-api@latest start`.
|
|
152
|
+
|
|
152
153
|
```sh
|
|
153
154
|
npx @jeffreycao/copilot-api@latest start
|
|
154
155
|
```
|
|
@@ -173,7 +174,7 @@ The settings screen also exposes `OAuth App`, `API Home`, `Enterprise URL`, verb
|
|
|
173
174
|
|
|
174
175
|
https://github.com/caozhiyuan/copilot-api/releases
|
|
175
176
|
|
|
176
|
-
Download the installer for your platform, sign in inside the app, choose a port, start the server, then point your client at the local endpoint shown in the app.
|
|
177
|
+
Download the installer for your platform, sign in inside the app, choose a port, start the server, then point your client at the local endpoint shown in the app. Packaged desktop builds use the bundled Electron runtime, so normal desktop usage does not require installing Node.js separately. Token usage history is enabled when that bundled runtime supports SQLite.
|
|
177
178
|
|
|
178
179
|
## Using with Docker
|
|
179
180
|
|
|
@@ -465,6 +466,9 @@ npx @jeffreycao/copilot-api@latest --oauth-app=opencode start
|
|
|
465
466
|
|
|
466
467
|
# Combine multiple global options
|
|
467
468
|
npx @jeffreycao/copilot-api@latest --api-home=/custom/path --oauth-app=opencode --enterprise-url=company.ghe.com start
|
|
469
|
+
|
|
470
|
+
# Run the published CLI with Bun instead of Node.js
|
|
471
|
+
bunx --bun @jeffreycao/copilot-api@latest start
|
|
468
472
|
```
|
|
469
473
|
|
|
470
474
|
## Using with OpenCode
|
|
@@ -571,6 +575,8 @@ After starting the server, a URL to the Copilot Usage Dashboard will be displaye
|
|
|
571
575
|
|
|
572
576
|
The dashboard provides a user-friendly interface to view your Copilot usage data:
|
|
573
577
|
|
|
578
|
+
> Token usage history requires Bun or Node.js >= 22.13.0. On Node.js < 22.13.0, the server runs normally but token usage storage is disabled.
|
|
579
|
+
|
|
574
580
|
- **API Endpoint URL**: The dashboard is pre-configured to fetch data from your local server endpoint via the URL query parameter. You can change this URL to point to any other compatible API endpoint.
|
|
575
581
|
- **Fetch Data**: Click the "Fetch" button to load or refresh the usage data. The dashboard will automatically fetch data on load.
|
|
576
582
|
- **Usage Quotas**: View a summary of your usage quotas for different services like Chat and Completions, displayed with progress bars for a quick overview.
|
package/README.zh-CN.md
CHANGED
|
@@ -21,11 +21,6 @@
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
> [!NOTE]
|
|
25
|
-
> [opencode](https://github.com/sst/opencode) 已经内置 GitHub Copilot provider,因此在基础使用场景下你未必需要本项目。如果你希望 OpenCode 通过 `@ai-sdk/anthropic` 接入 Copilot、保留 Anthropic Messages 的工具调用语义、对 Claude 系模型优先走原生 Messages API 而不是 Chat Completions API、使用带阶段提示的 gpt commentary,或者优化 premium request 的消耗,这个代理仍然很有价值。
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
24
|
## 重要说明
|
|
30
25
|
|
|
31
26
|
> [!IMPORTANT]
|
|
@@ -131,6 +126,7 @@
|
|
|
131
126
|
## 前置要求
|
|
132
127
|
|
|
133
128
|
- Bun(>= 1.2.x)
|
|
129
|
+
- 如果要通过 `npx` 运行已发布 CLI,需要 Node.js
|
|
134
130
|
- 已订阅 Copilot 的 GitHub 账号(个人版、Business 或 Enterprise)
|
|
135
131
|
|
|
136
132
|
## 安装
|
|
@@ -151,6 +147,11 @@ bun run start start
|
|
|
151
147
|
|
|
152
148
|
你可以直接用 npx 运行本项目:
|
|
153
149
|
|
|
150
|
+
> [!IMPORTANT]
|
|
151
|
+
> 通过 `npx` 运行时,token usage 存储会使用 Node 内置的 `node:sqlite` 模块。该能力会在 Node.js >= 22.13.0 时启用;Node.js < 22.13.0 时 CLI 仍可启动,但会禁用 token usage 存储。
|
|
152
|
+
>
|
|
153
|
+
> 如果不升级 Node.js 但仍需要 token usage 存储,可以改用 Bun 运行已发布 CLI:`bunx --bun @jeffreycao/copilot-api@latest start`。
|
|
154
|
+
|
|
154
155
|
```sh
|
|
155
156
|
npx @jeffreycao/copilot-api@latest start
|
|
156
157
|
```
|
|
@@ -175,7 +176,7 @@ npx @jeffreycao/copilot-api@latest auth
|
|
|
175
176
|
|
|
176
177
|
https://github.com/caozhiyuan/copilot-api/releases
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
下载对应平台的安装包后,在应用内登录、选择端口并启动服务,再把你的客户端指向应用里显示的本地端点即可。发布版桌面应用使用随包内置的 Electron 运行时,正常使用不需要额外安装 Node.js;token usage 历史记录会在该内置运行时支持 SQLite 时启用。
|
|
179
180
|
|
|
180
181
|
## 配合 Docker 使用
|
|
181
182
|
|
|
@@ -469,6 +470,9 @@ npx @jeffreycao/copilot-api@latest --oauth-app=opencode start
|
|
|
469
470
|
|
|
470
471
|
# 组合多个全局选项
|
|
471
472
|
npx @jeffreycao/copilot-api@latest --api-home=/custom/path --oauth-app=opencode --enterprise-url=company.ghe.com start
|
|
473
|
+
|
|
474
|
+
# 用 Bun 而不是 Node.js 运行已发布 CLI
|
|
475
|
+
bunx --bun @jeffreycao/copilot-api@latest start
|
|
472
476
|
```
|
|
473
477
|
|
|
474
478
|
## 与 OpenCode 一起使用
|
|
@@ -575,6 +579,8 @@ npx @jeffreycao/copilot-api@latest --oauth-app=opencode start
|
|
|
575
579
|
|
|
576
580
|
看板提供了更易读的 Copilot 用量视图:
|
|
577
581
|
|
|
582
|
+
> token usage 历史记录需要 Bun 或 Node.js >= 22.13.0。Node.js < 22.13.0 时服务会正常运行,但 token usage 存储会被禁用。
|
|
583
|
+
|
|
578
584
|
- **API Endpoint URL**:看板会通过 URL 查询参数,默认从本地服务端点拉取数据。你也可以把这个 URL 改成任意其他兼容 API 端点。
|
|
579
585
|
- **Fetch Data**:点击 “Fetch” 按钮即可加载或刷新使用数据。页面首次加载时也会自动拉取。
|
|
580
586
|
- **Usage Quotas**:使用进度条汇总展示 Chat、Completions 等不同服务的额度使用情况。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PATHS, ensurePaths } from "./paths-Cla6y5eD.js";
|
|
2
|
-
import { state } from "./utils-
|
|
3
|
-
import { setupGitHubToken } from "./token-
|
|
2
|
+
import { state } from "./utils-DEJvF68W.js";
|
|
3
|
+
import { setupGitHubToken } from "./token-rgdB2YWP.js";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
|
|
@@ -43,4 +43,4 @@ const auth = defineCommand({
|
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { auth };
|
|
46
|
-
//# sourceMappingURL=auth-
|
|
46
|
+
//# sourceMappingURL=auth-CWEhhJYn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-
|
|
1
|
+
{"version":3,"file":"auth-CWEhhJYn.js","names":[],"sources":["../src/auth.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { PATHS, ensurePaths } from \"./lib/paths\"\nimport { state } from \"./lib/state\"\nimport { setupGitHubToken } from \"./lib/token\"\n\ninterface RunAuthOptions {\n verbose: boolean\n showToken: boolean\n}\n\nexport async function runAuth(options: RunAuthOptions): Promise<void> {\n if (options.verbose) {\n consola.level = 5\n consola.info(\"Verbose logging enabled\")\n }\n\n state.showToken = options.showToken\n\n await ensurePaths()\n await setupGitHubToken({ force: true })\n consola.success(\"GitHub token written to\", PATHS.GITHUB_TOKEN_PATH)\n}\n\nexport const auth = defineCommand({\n meta: {\n name: \"auth\",\n description: \"Run GitHub auth flow without running the server\",\n },\n args: {\n verbose: {\n alias: \"v\",\n type: \"boolean\",\n default: false,\n description: \"Enable verbose logging\",\n },\n \"show-token\": {\n type: \"boolean\",\n default: false,\n description: \"Show GitHub token on auth\",\n },\n },\n run({ args }) {\n return runAuth({\n verbose: args.verbose,\n showToken: args[\"show-token\"],\n })\n },\n})\n"],"mappings":";;;;;;;AAcA,eAAsB,QAAQ,SAAwC;AACpE,KAAI,QAAQ,SAAS;AACnB,UAAQ,QAAQ;AAChB,UAAQ,KAAK,0BAA0B;;AAGzC,OAAM,YAAY,QAAQ;AAE1B,OAAM,aAAa;AACnB,OAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AACvC,SAAQ,QAAQ,2BAA2B,MAAM,kBAAkB;;AAGrE,MAAa,OAAO,cAAc;CAChC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM;EACJ,SAAS;GACP,OAAO;GACP,MAAM;GACN,SAAS;GACT,aAAa;GACd;EACD,cAAc;GACZ,MAAM;GACN,SAAS;GACT,aAAa;GACd;EACF;CACD,IAAI,EAAE,QAAQ;AACZ,SAAO,QAAQ;GACb,SAAS,KAAK;GACd,WAAW,KAAK;GACjB,CAAC;;CAEL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ensurePaths } from "./paths-Cla6y5eD.js";
|
|
2
|
-
import { getCopilotUsage } from "./utils-
|
|
3
|
-
import { setupGitHubToken } from "./token-
|
|
2
|
+
import { getCopilotUsage } from "./utils-DEJvF68W.js";
|
|
3
|
+
import { setupGitHubToken } from "./token-rgdB2YWP.js";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import consola from "consola";
|
|
6
6
|
|
|
@@ -41,4 +41,4 @@ const checkUsage = defineCommand({
|
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
43
|
export { checkUsage };
|
|
44
|
-
//# sourceMappingURL=check-usage-
|
|
44
|
+
//# sourceMappingURL=check-usage-B5yr4fpk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-usage-
|
|
1
|
+
{"version":3,"file":"check-usage-B5yr4fpk.js","names":[],"sources":["../src/check-usage.ts"],"sourcesContent":["import { defineCommand } from \"citty\"\nimport consola from \"consola\"\n\nimport { ensurePaths } from \"./lib/paths\"\nimport { setupGitHubToken } from \"./lib/token\"\nimport {\n getCopilotUsage,\n type QuotaDetail,\n} from \"./services/github/get-copilot-usage\"\n\nexport const checkUsage = defineCommand({\n meta: {\n name: \"check-usage\",\n description: \"Show current GitHub Copilot usage/quota information\",\n },\n async run() {\n await ensurePaths()\n await setupGitHubToken()\n try {\n const usage = await getCopilotUsage()\n const premium = usage.quota_snapshots.premium_interactions\n const premiumTotal = premium.entitlement\n const premiumUsed = premiumTotal - premium.remaining\n const premiumPercentUsed =\n premiumTotal > 0 ? (premiumUsed / premiumTotal) * 100 : 0\n const premiumPercentRemaining = premium.percent_remaining\n\n // Helper to summarize a quota snapshot\n function summarizeQuota(name: string, snap: QuotaDetail | undefined) {\n if (!snap) return `${name}: N/A`\n const total = snap.entitlement\n const used = total - snap.remaining\n const percentUsed = total > 0 ? (used / total) * 100 : 0\n const percentRemaining = snap.percent_remaining\n return `${name}: ${used}/${total} used (${percentUsed.toFixed(1)}% used, ${percentRemaining.toFixed(1)}% remaining)`\n }\n\n const premiumLine = `Premium: ${premiumUsed}/${premiumTotal} used (${premiumPercentUsed.toFixed(1)}% used, ${premiumPercentRemaining.toFixed(1)}% remaining)`\n const chatLine = summarizeQuota(\"Chat\", usage.quota_snapshots.chat)\n const completionsLine = summarizeQuota(\n \"Completions\",\n usage.quota_snapshots.completions,\n )\n\n consola.box(\n `Copilot Usage (plan: ${usage.copilot_plan})\\n`\n + `Quota resets: ${usage.quota_reset_date}\\n`\n + `\\nQuotas:\\n`\n + ` ${premiumLine}\\n`\n + ` ${chatLine}\\n`\n + ` ${completionsLine}`,\n )\n } catch (err) {\n consola.error(\"Failed to fetch Copilot usage:\", err)\n process.exit(1)\n }\n },\n})\n"],"mappings":";;;;;;;AAUA,MAAa,aAAa,cAAc;CACtC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM,MAAM;AACV,QAAM,aAAa;AACnB,QAAM,kBAAkB;AACxB,MAAI;GACF,MAAM,QAAQ,MAAM,iBAAiB;GACrC,MAAM,UAAU,MAAM,gBAAgB;GACtC,MAAM,eAAe,QAAQ;GAC7B,MAAM,cAAc,eAAe,QAAQ;GAC3C,MAAM,qBACJ,eAAe,IAAK,cAAc,eAAgB,MAAM;GAC1D,MAAM,0BAA0B,QAAQ;GAGxC,SAAS,eAAe,MAAc,MAA+B;AACnE,QAAI,CAAC,KAAM,QAAO,GAAG,KAAK;IAC1B,MAAM,QAAQ,KAAK;IACnB,MAAM,OAAO,QAAQ,KAAK;IAC1B,MAAM,cAAc,QAAQ,IAAK,OAAO,QAAS,MAAM;IACvD,MAAM,mBAAmB,KAAK;AAC9B,WAAO,GAAG,KAAK,IAAI,KAAK,GAAG,MAAM,SAAS,YAAY,QAAQ,EAAE,CAAC,UAAU,iBAAiB,QAAQ,EAAE,CAAC;;GAGzG,MAAM,cAAc,YAAY,YAAY,GAAG,aAAa,SAAS,mBAAmB,QAAQ,EAAE,CAAC,UAAU,wBAAwB,QAAQ,EAAE,CAAC;GAChJ,MAAM,WAAW,eAAe,QAAQ,MAAM,gBAAgB,KAAK;GACnE,MAAM,kBAAkB,eACtB,eACA,MAAM,gBAAgB,YACvB;AAED,WAAQ,IACN,wBAAwB,MAAM,aAAa,mBACtB,MAAM,iBAAiB,iBAEnC,YAAY,MACZ,SAAS,MACT,kBACV;WACM,KAAK;AACZ,WAAQ,MAAM,kCAAkC,IAAI;AACpD,WAAQ,KAAK,EAAE;;;CAGpB,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -41,10 +41,10 @@ if (typeof args["api-home"] === "string") process.env.COPILOT_API_HOME = args["a
|
|
|
41
41
|
if (typeof args["oauth-app"] === "string") process.env.COPILOT_API_OAUTH_APP = args["oauth-app"];
|
|
42
42
|
if (typeof args["enterprise-url"] === "string") process.env.COPILOT_API_ENTERPRISE_URL = args["enterprise-url"];
|
|
43
43
|
bindElectronFetch();
|
|
44
|
-
const { auth } = await import("./auth-
|
|
45
|
-
const { checkUsage } = await import("./check-usage-
|
|
44
|
+
const { auth } = await import("./auth-CWEhhJYn.js");
|
|
45
|
+
const { checkUsage } = await import("./check-usage-B5yr4fpk.js");
|
|
46
46
|
const { debug } = await import("./debug-DcC7ZPH0.js");
|
|
47
|
-
const { start } = await import("./start-
|
|
47
|
+
const { start } = await import("./start-1ogeufrV.js");
|
|
48
48
|
const main = defineCommand({
|
|
49
49
|
meta: {
|
|
50
50
|
name: "copilot-api",
|