@jeffreycao/copilot-api 2.1.10 → 2.1.12
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 +7 -3
- package/README.zh-CN.md +7 -3
- package/dist/main.js +2 -2
- package/dist/{mcp-DOp7erlH.js → mcp-BG6fpi6q.js} +3 -7
- package/dist/mcp-BG6fpi6q.js.map +1 -0
- package/dist/{server-tlEQmO0Y.js → server-di38_SOi.js} +7 -5
- package/dist/server-di38_SOi.js.map +1 -0
- package/dist/{start-Bnk7SH7n.js → start-BAGQbk_n.js} +4 -3
- package/dist/{start-Bnk7SH7n.js.map → start-BAGQbk_n.js.map} +1 -1
- package/package.json +1 -1
- package/dist/mcp-DOp7erlH.js.map +0 -1
- package/dist/server-tlEQmO0Y.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,9 +63,9 @@ English | [简体中文](./README.zh-CN.md)
|
|
|
63
63
|
> [!IMPORTANT]
|
|
64
64
|
> **Before using, please be aware of the following:**
|
|
65
65
|
>
|
|
66
|
-
> 1. **
|
|
66
|
+
> 1. **Codex configuration:** When using with Codex, add the gateway provider to `~/.codex/config.toml`. See [Codex `config.toml` Reference](#codex-configtoml-reference).
|
|
67
67
|
>
|
|
68
|
-
> 2. **
|
|
68
|
+
> 2. **Claude Code configuration:** When using with Claude Code, please configure the model ID as `claude-opus-4-8[1m]`. Example claude `settings.json` see [Manual Configuration with `settings.json`](#manual-configuration-with-settingsjson).
|
|
69
69
|
>
|
|
70
70
|
> 3. **OpenCode configuration:** When using with OpenCode, configure `~/.config/opencode/opencode.json` with `@ai-sdk/anthropic`. See [Using with OpenCode](#using-with-opencode).
|
|
71
71
|
>
|
|
@@ -277,7 +277,8 @@ Here is an example `.claude/settings.json` file:
|
|
|
277
277
|
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
|
|
278
278
|
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
|
|
279
279
|
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
|
|
280
|
-
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0"
|
|
280
|
+
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
|
|
281
|
+
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off"
|
|
281
282
|
},
|
|
282
283
|
"alwaysThinkingEnabled": true,
|
|
283
284
|
"effortLevel": "xhigh",
|
|
@@ -286,6 +287,7 @@ Here is an example `.claude/settings.json` file:
|
|
|
286
287
|
```
|
|
287
288
|
|
|
288
289
|
- Replace `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` according to your needs. After configuration, please install the claude code plugin [Plugin Integrations](#plugin-integrations).
|
|
290
|
+
- `CLAUDE_CODE_TOTAL_TOKENS_REMINDER: "off"` disables Claude Code's total-tokens reminder, which injects a `<total_tokens>N tokens left</total_tokens>` block into the conversation to pace the model against a remaining token budget. The default budget is 15,000,000 (15M) tokens, which is not very meaningful, so it is turned off here.
|
|
289
291
|
- If you are using the codex provider, it is recommended **not** to configure the model name in the `codex/xxx` format (e.g. `codex/gpt-5.6-sol`). Claude Code treats the `codex/` prefix as a special pattern and applies degraded behavior — for example, it strips all previously returned thinking blocks on every request. Use the plain model name (e.g. `gpt-5.6-sol`) instead, and add a `modelMappings` entry in `config.json` to route it back to the codex provider:
|
|
290
292
|
```json
|
|
291
293
|
"modelMappings": {
|
|
@@ -514,6 +516,8 @@ The `agent-inject` plugin also registers a `UserPromptSubmit` hook that returns
|
|
|
514
516
|
|
|
515
517
|
The `tool-search` plugin bundles the same MCP bridge described in [GPT Tool Search](#gpt-tool-search), so Claude Code users do not need to add the `tool_search` server manually when they install that plugin.
|
|
516
518
|
|
|
519
|
+
The plugin also auto-approves bridge calls through a `PermissionRequest` hook scoped exactly to `mcp__plugin_tool-search_tool_search__search`. The hook does not approve other MCP tools and does not override explicit `ask` or `deny` permission rules.
|
|
520
|
+
|
|
517
521
|
### Opencode plugin
|
|
518
522
|
|
|
519
523
|
The subagent marker producer is packaged as an opencode plugin located at `plugin/opencode/subagent-marker.js`.
|
package/README.zh-CN.md
CHANGED
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
> [!IMPORTANT]
|
|
66
66
|
> **使用前请先注意以下几点:**
|
|
67
67
|
>
|
|
68
|
-
> 1. **
|
|
68
|
+
> 1. **Codex 配置:** 与 Codex 搭配使用时,请在 `~/.codex/config.toml` 中添加 gateway provider,详见 [Codex `config.toml` 参考配置](#codex-configtoml-参考配置)。
|
|
69
69
|
>
|
|
70
|
-
> 2. **
|
|
70
|
+
> 2. **Claude Code 配置:** 与 Claude Code 搭配使用时,请将模型 ID 配置为 `claude-opus-4-8[1m]`。示例 claude `settings.json` 见 [通过 `settings.json` 手动配置](#manual-configuration-with-settingsjson)。
|
|
71
71
|
>
|
|
72
72
|
> 3. **OpenCode 配置:** 与 OpenCode 搭配使用时,请使用 `@ai-sdk/anthropic` 配置 `~/.config/opencode/opencode.json`,详见 [与 OpenCode 一起使用](#与-opencode-一起使用)。
|
|
73
73
|
>
|
|
@@ -301,7 +301,8 @@ npx @jeffreycao/copilot-api@latest start --claude-code
|
|
|
301
301
|
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
|
|
302
302
|
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
|
|
303
303
|
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
|
|
304
|
-
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0"
|
|
304
|
+
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
|
|
305
|
+
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off"
|
|
305
306
|
},
|
|
306
307
|
"alwaysThinkingEnabled": true,
|
|
307
308
|
"effortLevel": "xhigh",
|
|
@@ -310,6 +311,7 @@ npx @jeffreycao/copilot-api@latest start --claude-code
|
|
|
310
311
|
```
|
|
311
312
|
|
|
312
313
|
- 请根据需要替换 `ANTHROPIC_MODEL`、`ANTHROPIC_DEFAULT_OPUS_MODEL`、`ANTHROPIC_DEFAULT_SONNET_MODEL` 和 `ANTHROPIC_DEFAULT_HAIKU_MODEL`。配置完成后,请安装 claude code 插件,见 [插件集成](#plugin-integrations)。
|
|
314
|
+
- `CLAUDE_CODE_TOTAL_TOKENS_REMINDER: "off"` 用于关闭 Claude Code 的 total tokens 提醒功能。该功能开启时会在对话中注入 `<total_tokens>N tokens left</total_tokens>` 块,提示模型剩余的 token 预算;默认预算为 1500w(15,000,000)tokens,意义不大,因此这里配置为关闭。
|
|
313
315
|
- 如果你使用的是 codex provider,建议**不要**将模型名配置成 `codex/xxx` 格式(如 `codex/gpt-5.6-sol`)。Claude Code 会针对 `codex/` 前缀做降智行为——例如每次请求时移除所有之前返回的思考块(thinking blocks)。请使用纯模型名(如 `gpt-5.6-sol`),并在 `config.json` 中配置 `modelMappings` 将其映射回 codex provider:
|
|
314
316
|
```json
|
|
315
317
|
"modelMappings": {
|
|
@@ -546,6 +548,8 @@ Claude Code 集成现在拆分为两个插件:
|
|
|
546
548
|
|
|
547
549
|
`tool-search` 插件内置了 [GPT Tool Search](#gpt-tool-search) 一节描述的同一个 MCP bridge,因此安装该插件后,Claude Code 用户无需再手动配置 `tool_search` server。
|
|
548
550
|
|
|
551
|
+
该插件还通过精确匹配 `mcp__plugin_tool-search_tool_search__search` 的 `PermissionRequest` hook 自动批准 bridge 调用。这个 hook 不会批准其他 MCP 工具,并且不会覆盖显式的 `ask` 或 `deny` 权限规则。
|
|
552
|
+
|
|
549
553
|
### Opencode 插件
|
|
550
554
|
|
|
551
555
|
subagent 标记生成器被打包为一个 opencode 插件,位于 `plugin/opencode/subagent-marker.js`。
|
package/dist/main.js
CHANGED
|
@@ -24,8 +24,8 @@ const { bindElectronFetch } = await import("./electron-fetch-DPhDE6JE.js");
|
|
|
24
24
|
bindElectronFetch();
|
|
25
25
|
const { auth } = await import("./auth-PIo0IPSc.js");
|
|
26
26
|
const { debug } = await import("./debug-ChC85ySp.js");
|
|
27
|
-
const { mcp } = await import("./mcp-
|
|
28
|
-
const { start } = await import("./start-
|
|
27
|
+
const { mcp } = await import("./mcp-BG6fpi6q.js");
|
|
28
|
+
const { start } = await import("./start-BAGQbk_n.js");
|
|
29
29
|
await runMain(defineCommand({
|
|
30
30
|
meta: {
|
|
31
31
|
name: "copilot-api",
|
|
@@ -6,7 +6,7 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/mcp.ts
|
|
7
7
|
const SERVER_NAME = "tool_search";
|
|
8
8
|
const SERVER_VERSION = "1.0.0";
|
|
9
|
-
const
|
|
9
|
+
const runMcpServer = async () => {
|
|
10
10
|
const server = new McpServer({
|
|
11
11
|
name: SERVER_NAME,
|
|
12
12
|
version: SERVER_VERSION
|
|
@@ -15,16 +15,12 @@ const createMcpToolSearchServer = () => {
|
|
|
15
15
|
title: "Tool Search Bridge",
|
|
16
16
|
description: "Load deferred tools by exact name through the Copilot API tool_search bridge.",
|
|
17
17
|
inputSchema: { names: z.string().describe("Comma-separated exact deferred tool names to load, for example \"TaskList,TaskGet,mcp__fetch__fetch\".") },
|
|
18
|
-
annotations: { readOnlyHint: true },
|
|
19
18
|
_meta: { "anthropic/alwaysLoad": true }
|
|
20
19
|
}, ({ names }) => ({ content: [{
|
|
21
20
|
type: "text",
|
|
22
21
|
text: createMcpToolSearchSentinel(names)
|
|
23
22
|
}] }));
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
const runMcpServer = async () => {
|
|
27
|
-
await createMcpToolSearchServer().connect(new StdioServerTransport());
|
|
23
|
+
await server.connect(new StdioServerTransport());
|
|
28
24
|
};
|
|
29
25
|
const mcp = defineCommand({
|
|
30
26
|
meta: {
|
|
@@ -38,4 +34,4 @@ const mcp = defineCommand({
|
|
|
38
34
|
//#endregion
|
|
39
35
|
export { mcp };
|
|
40
36
|
|
|
41
|
-
//# sourceMappingURL=mcp-
|
|
37
|
+
//# sourceMappingURL=mcp-BG6fpi6q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-BG6fpi6q.js","names":[],"sources":["../src/mcp.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\"\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\"\nimport { defineCommand } from \"citty\"\nimport { z } from \"zod\"\n\nimport { createMcpToolSearchSentinel } from \"./lib/tool-search\"\n\nconst SERVER_NAME = \"tool_search\"\nconst SERVER_VERSION = \"1.0.0\"\n\nexport const runMcpServer = async (): Promise<void> => {\n const server = new McpServer({\n name: SERVER_NAME,\n version: SERVER_VERSION,\n })\n\n server.registerTool(\n \"search\",\n {\n title: \"Tool Search Bridge\",\n description:\n \"Load deferred tools by exact name through the Copilot API tool_search bridge.\",\n inputSchema: {\n names: z\n .string()\n .describe(\n 'Comma-separated exact deferred tool names to load, for example \"TaskList,TaskGet,mcp__fetch__fetch\".',\n ),\n },\n _meta: {\n \"anthropic/alwaysLoad\": true,\n },\n },\n ({ names }) => ({\n content: [\n {\n type: \"text\",\n text: createMcpToolSearchSentinel(names),\n },\n ],\n }),\n )\n\n await server.connect(new StdioServerTransport())\n}\n\nexport const mcp = defineCommand({\n meta: {\n name: \"mcp\",\n description: \"Start the Copilot API MCP tool_search bridge over stdio\",\n },\n run() {\n return runMcpServer()\n },\n})\n"],"mappings":";;;;;;AASA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,MAAa,eAAe,YAA2B;CACrD,MAAM,SAAS,IAAI,UAAU;EAC3B,MAAM;EACN,SAAS;EACV,CAAC;CAEF,OAAO,aACL,UACA;EACE,OAAO;EACP,aACE;EACF,aAAa,EACX,OAAO,EACJ,QAAQ,CACR,SACC,yGACD,EACJ;EACD,OAAO,EACL,wBAAwB,MACzB;EACF,GACA,EAAE,aAAa,EACd,SAAS,CACP;EACE,MAAM;EACN,MAAM,4BAA4B,MAAM;EACzC,CACF,EACF,EACF;CAED,MAAM,OAAO,QAAQ,IAAI,sBAAsB,CAAC;;AAGlD,MAAa,MAAM,cAAc;CAC/B,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM;EACJ,OAAO,cAAc;;CAExB,CAAC"}
|
|
@@ -3724,7 +3724,8 @@ function translateAnthropicToolsToOpenAI(anthropicTools) {
|
|
|
3724
3724
|
function: {
|
|
3725
3725
|
name: tool.name,
|
|
3726
3726
|
description: tool.description,
|
|
3727
|
-
parameters: normalizeToolSchema(tool.input_schema)
|
|
3727
|
+
parameters: normalizeToolSchema(tool.input_schema),
|
|
3728
|
+
...tool.strict === void 0 ? {} : { strict: tool.strict }
|
|
3728
3729
|
}
|
|
3729
3730
|
}));
|
|
3730
3731
|
}
|
|
@@ -5082,7 +5083,7 @@ const convertToolToFunction = (tool) => ({
|
|
|
5082
5083
|
type: "function",
|
|
5083
5084
|
name: tool.name,
|
|
5084
5085
|
parameters: normalizeToolSchema(tool.input_schema),
|
|
5085
|
-
strict: false,
|
|
5086
|
+
strict: tool.strict ?? false,
|
|
5086
5087
|
...tool.description ? { description: tool.description } : {}
|
|
5087
5088
|
});
|
|
5088
5089
|
const convertDeferredToolToNamespace = (tool) => ({
|
|
@@ -5093,7 +5094,7 @@ const convertDeferredToolToNamespace = (tool) => ({
|
|
|
5093
5094
|
type: "function",
|
|
5094
5095
|
name: tool.name,
|
|
5095
5096
|
parameters: normalizeToolSchema(tool.input_schema),
|
|
5096
|
-
strict: false,
|
|
5097
|
+
strict: tool.strict ?? false,
|
|
5097
5098
|
defer_loading: true,
|
|
5098
5099
|
...tool.description ? { description: tool.description } : {}
|
|
5099
5100
|
}]
|
|
@@ -8662,7 +8663,8 @@ function registerMessagesTool(registration, registry) {
|
|
|
8662
8663
|
input_schema: registration.kind === "custom" ? CUSTOM_TOOL_INPUT_SCHEMA : registration.parameters ?? {
|
|
8663
8664
|
type: "object",
|
|
8664
8665
|
properties: {}
|
|
8665
|
-
}
|
|
8666
|
+
},
|
|
8667
|
+
...registration.kind === "custom" ? { strict: true } : {}
|
|
8666
8668
|
});
|
|
8667
8669
|
return descriptor;
|
|
8668
8670
|
}
|
|
@@ -10497,4 +10499,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
10497
10499
|
//#endregion
|
|
10498
10500
|
export { server };
|
|
10499
10501
|
|
|
10500
|
-
//# sourceMappingURL=server-
|
|
10502
|
+
//# sourceMappingURL=server-di38_SOi.js.map
|