@jeffreycao/copilot-api 1.14.0 → 1.14.2

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
@@ -288,7 +288,6 @@ Add the following `[model_providers.copilot_api]` section to your Codex `~/.code
288
288
  ```toml
289
289
  model_provider = "copilot_api"
290
290
  model_reasoning_summary = "auto"
291
- model_verbosity = "medium"
292
291
  model_context_window = 272000
293
292
  model_auto_compact_token_limit = 244800
294
293
 
@@ -311,7 +310,7 @@ enabled = false
311
310
  ```
312
311
 
313
312
  > [!NOTE]
314
- > This configuration is specific to Codex and the GitHub Copilot provider. `name` must be set to `"OpenAI"`. It can help mitigate Codex local compact cache miss issues. If you enable `contextManagement.responses` (Responses API context management compaction), `remote_compaction_v2` or local compact is generally not triggered, but it may still occur when tool results return a large number of tokens. Before enabling it for native Responses API traffic, check that your client supports context management compaction.
313
+ > This configuration is specific to Codex and the GitHub Copilot provider. `name` must be set to `"OpenAI"`. It can help mitigate Codex local compact cache miss issues.
315
314
 
316
315
  ## GPT Tool Search
317
316
 
@@ -615,7 +614,10 @@ Use `copilot-api auth login --provider custom` to add or update another third-pa
615
614
  - **smallModel:** Fallback model used for tool-less warmup messages (e.g., Claude Code probe requests); defaults to gpt-5-mini.
616
615
  - **contextManagement:** Controls whether the proxy adds Responses API `context_management` compaction instructions. `messages` applies when Anthropic-style `/v1/messages` requests are translated to Responses API, including `openai-responses` provider message routes, and defaults to `true`. `responses` applies to native `/v1/responses` traffic, including `provider/model` aliases and the built-in `codex` provider, and defaults to `false`. Enable `responses` only after checking that your client supports context management compaction. When enabled, the request includes `context_management` in the body and keeps only the latest compaction carrier on follow-up turns. **Note:** Context management is forcibly disabled for GPT-5.6 and above models (e.g. `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`) because enabling it breaks prompt cache hits on those models. This override takes precedence over the `contextManagement` and `modelResponsesApiCompactThresholds` settings.
617
616
  - **modelResponsesApiCompactThresholds:** Per-model Responses API `compact_threshold` overrides used when the proxy adds `context_management`. These values take precedence over the fallback threshold from `resolveResponsesCompactThreshold` (`max_prompt_tokens * ratio`, or the default fallback). Defaults set `gpt-5.4` and `gpt-5.5` to `217600` (`272000 * 0.8`), and `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna` to `231200` (`272000 * 0.85`). Models not listed continue to use the normal fallback logic.
618
- - **modelReasoningEfforts:** Per-model reasoning effort applied to `/v1/messages` requests. When routed to the Copilot native Messages API it sets `output_config.effort`; when translated to the Responses API it sets `reasoning.effort`. Allowed values are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. If a model isn't listed, `high` is used by default; GPT-5.3+ models fall back to `xhigh` when not explicitly configured.
617
+ - **modelReasoningEfforts:** Per-model fallback reasoning effort for `/v1/messages` requests. It is used only when the request does not provide `output_config.effort`.
618
+ - **Priority:** request `output_config.effort` > `modelReasoningEfforts[model]` > built-in default (`xhigh` for GPT-5.3+ models, otherwise `high`).
619
+ - **Forwarding:** the resolved value remains `output_config.effort` for the Copilot native Messages API and becomes `reasoning.effort` when translated to the Responses API.
620
+ - **Configuration values:** `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.
619
621
  - **useMessagesApi:** When `true`, Claude-family models that support Copilot's native `/v1/messages` endpoint will use the Messages API; otherwise they fall back to `/chat/completions`. Set to `false` to disable Messages API routing and always use `/chat/completions`. Defaults to `true`.
620
622
  - **useResponsesApiWebSocket:** When `true`, Responses API requests use Copilot's websocket transport for models that advertise `ws:/responses`; models that only advertise `/responses` continue to use HTTP. Set to `false` to disable websocket routing and use HTTP `/responses` whenever the selected model supports it. Defaults to `true`.
621
623
  - **useResponsesApiWebSearch:** When `true`, the server keeps Responses API tools with `type: "web_search"` and forwards them upstream. Set to `false` to strip those tools from `/responses` payloads. Defaults to `true`.
package/README.zh-CN.md CHANGED
@@ -290,7 +290,6 @@ npx @jeffreycao/copilot-api@latest start
290
290
  ```toml
291
291
  model_provider = "copilot_api"
292
292
  model_reasoning_summary = "auto"
293
- model_verbosity = "medium"
294
293
  model_context_window = 272000
295
294
  model_auto_compact_token_limit = 244800
296
295
 
@@ -313,7 +312,7 @@ enabled = false
313
312
  ```
314
313
 
315
314
  > [!NOTE]
316
- > 此配置仅限于 Codex 与 GitHub Copilot provider。`name` 一定要配置为 `"OpenAI"`。它可以缓解 Codex local compact 不命中缓存的问题。如果你开启了 `contextManagement.responses`(Responses API context management 压缩),通常不会走到 `remote_compaction_v2` 或者 local compact,但如果工具返回 tokens 过大,仍有可能触发。在 native Responses API 流量下启用前,请先确认客户端支持 context management compaction。
315
+ > 此配置仅限于 Codex 与 GitHub Copilot provider。`name` 一定要配置为 `"OpenAI"`。它可以缓解 Codex local compact 不命中缓存的问题。
317
316
 
318
317
  ## GPT Tool Search
319
318
 
@@ -621,7 +620,10 @@ Copilot API 现在使用子命令结构,主要命令包括:
621
620
  - **smallModel:** 无工具预热消息的回退模型(例如 Claude Code 的探测请求);默认是 `gpt-5-mini`。
622
621
  - **contextManagement:** 控制代理是否为 Responses API 附加 `context_management` 压缩指令。`messages` 作用于被翻译成 Responses API 的 Anthropic 风格 `/v1/messages` 请求,包括 `openai-responses` provider 的 Messages 路由,默认值为 `true`。`responses` 作用于 native `/v1/responses` 流量,包括 `provider/model` 别名和内置 `codex` provider,默认值为 `false`。只有在确认客户端支持 context management compaction 后,才建议在 Responses API 下启用 `responses`。启用后,请求体会带上 `context_management`,并在后续轮次中仅保留最新的压缩承载内容。**注意:** 对于 GPT-5.6 及以上模型(如 `gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`),context management 功能会被强制禁用,因为开启后会破坏这些模型的 prompt 缓存命中。此强制覆盖优先于 `contextManagement` 和 `modelResponsesApiCompactThresholds` 配置。
623
622
  - **modelResponsesApiCompactThresholds:** 按模型覆盖 Responses API 的 `compact_threshold`,仅在代理自动附加 `context_management` 时使用。它的优先级高于 `resolveResponsesCompactThreshold` 基于 `max_prompt_tokens * ratio` 的兜底阈值。默认将 `gpt-5.4` 和 `gpt-5.5` 设为 `217600`(`272000 * 0.8`),将 `gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna` 设为 `231200`(`272000 * 0.85`)。未列出的模型继续使用原有兜底逻辑。
624
- - **modelReasoningEfforts:** 按模型配置的推理强度,仅作用于 `/v1/messages` 请求。当请求走 Copilot 原生 Messages API 时设置 `output_config.effort`;当请求被翻译为 Responses API 时设置 `reasoning.effort`。可选值包括 `none`、`minimal`、`low`、`medium`、`high`、`xhigh` 和 `max`。若某模型未配置,则默认使用 `high`;GPT-5.3+ 模型未显式配置时回退为 `xhigh`。
623
+ - **modelReasoningEfforts:** `/v1/messages` 请求的模型级默认推理强度。仅当请求没有传入 `output_config.effort` 时,该配置才会生效。
624
+ - **优先级:** 请求中的 `output_config.effort` > `modelReasoningEfforts[model]` > 内置默认值(GPT-5.3+ 模型为 `xhigh`,其他模型为 `high`)。
625
+ - **转发字段:** 走 Copilot 原生 Messages API 时,最终值写入 `output_config.effort`;转换为 Responses API 时,最终值写入 `reasoning.effort`。
626
+ - **配置可选值:** `none`、`minimal`、`low`、`medium`、`high`、`xhigh`、`max`。
625
627
  - **useMessagesApi:** 当为 `true` 时,支持 Copilot 原生 `/v1/messages` 的 Claude 系模型会走 Messages API;否则回退到 `/chat/completions`。设为 `false` 可禁用 Messages API 路由,始终使用 `/chat/completions`。默认值为 `true`。
626
628
  - **useResponsesApiWebSocket:** 当为 `true` 时,Responses API 请求会优先对声明了 `ws:/responses` 的模型使用 Copilot websocket transport;仅声明 `/responses` 的模型仍走 HTTP。设为 `false` 可禁用 websocket 路由,并在模型支持 `/responses` 时使用 HTTP `/responses`。默认值为 `true`。
627
629
  - **useResponsesApiWebSearch:** 当为 `true` 时,服务端会保留 Responses API 中 `type: "web_search"` 的工具并透传到上游。设为 `false` 则会从 `/responses` payload 中移除这些工具。默认值为 `true`。
package/dist/main.js CHANGED
@@ -25,7 +25,7 @@ bindElectronFetch();
25
25
  const { auth } = await import("./auth-DvJ8r_tN.js");
26
26
  const { debug } = await import("./debug-Bb5hamXX.js");
27
27
  const { mcp } = await import("./mcp-BseuqgHR.js");
28
- const { start } = await import("./start-jNRGYGpo.js");
28
+ const { start } = await import("./start-BUCPPobx.js");
29
29
  await runMain(defineCommand({
30
30
  meta: {
31
31
  name: "copilot-api",
@@ -3568,6 +3568,7 @@ const MESSAGE_TYPE = "message";
3568
3568
  const COMPACTION_SIGNATURE_PREFIX = "cm1#";
3569
3569
  const COMPACTION_SIGNATURE_SEPARATOR = "@";
3570
3570
  const THINKING_TEXT = "Thinking...";
3571
+ const resolveReasoningEffort = (payload) => payload.output_config?.effort ?? getReasoningEffortForModel(payload.model);
3571
3572
  const buildPromptCacheKey = (basePromptCacheKey, subagentAgentId) => {
3572
3573
  if (!basePromptCacheKey) return null;
3573
3574
  const normalizedSubagentAgentId = subagentAgentId?.trim() || null;
@@ -3607,7 +3608,7 @@ const translateAnthropicMessagesToResponsesPayload = (payload, subagentAgentId)
3607
3608
  store: false,
3608
3609
  parallel_tool_calls: true,
3609
3610
  reasoning: {
3610
- effort: getReasoningEffortForModel(payload.model),
3611
+ effort: resolveReasoningEffort(payload),
3611
3612
  summary: "detailed",
3612
3613
  context: "all_turns"
3613
3614
  },
@@ -6696,13 +6697,16 @@ const removeWebSearchTool = (payload) => {
6696
6697
  });
6697
6698
  };
6698
6699
  const COPILOT_UNSUPPORTED_TOOL_TYPES = new Set(["image_generation"]);
6700
+ const COPILOT_UNSUPPORTED_TOOL_NAMESPACES = new Set(["image_gen"]);
6699
6701
  const removeUnsupportedTools = (payload) => {
6700
6702
  if (!Array.isArray(payload.tools) || payload.tools.length === 0) return;
6701
6703
  const dropped = [];
6702
6704
  payload.tools = payload.tools.filter((t) => {
6703
6705
  const type = t.type;
6704
- if (COPILOT_UNSUPPORTED_TOOL_TYPES.has(type)) {
6705
- dropped.push(type);
6706
+ const name = "name" in t && typeof t.name === "string" ? t.name : void 0;
6707
+ const isUnsupportedNamespace = type === "namespace" && name !== void 0 && COPILOT_UNSUPPORTED_TOOL_NAMESPACES.has(name);
6708
+ if (COPILOT_UNSUPPORTED_TOOL_TYPES.has(type) || isUnsupportedNamespace) {
6709
+ dropped.push(isUnsupportedNamespace ? `${type}:${name}` : type);
6706
6710
  return false;
6707
6711
  }
6708
6712
  return true;
@@ -6847,4 +6851,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
6847
6851
  //#endregion
6848
6852
  export { server };
6849
6853
 
6850
- //# sourceMappingURL=server-BMEABwl7.js.map
6854
+ //# sourceMappingURL=server-HvdtsRfY.js.map