@jeffreycao/copilot-api 2.5.11 → 2.6.1
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 +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/main.js +1 -1
- package/dist/{server-CTAJaZn-.js → server-BfbNbfYw.js} +12 -5
- package/dist/{server-CTAJaZn-.js.map → server-BfbNbfYw.js.map} +1 -1
- package/dist/{start-DDNVmyLY.js → start-tVcNsIV-.js} +2 -2
- package/dist/{start-DDNVmyLY.js.map → start-tVcNsIV-.js.map} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -308,7 +308,9 @@ args = [
|
|
|
308
308
|
|
|
309
309
|
Without this configuration, Codex cannot fetch `/v1/models` while not signed in to a GPT account, so custom models are unavailable in the model picker.
|
|
310
310
|
|
|
311
|
-
When a Codex client (`User-Agent` starts with `codex`) requests the top-level `GET /v1/models`, the gateway merges native Codex models with models available through the Messages adapter. The latter advertise `use_responses_lite: true` and `tool_mode:
|
|
311
|
+
When a Codex client (`User-Agent` starts with `codex`) requests the top-level `GET /v1/models`, the gateway merges native Codex models with models available through the Messages adapter. The latter advertise `use_responses_lite: true`, except DeepSeek models, which use `use_responses_lite: false` and `tool_mode: null`. For other models, `/v1/responses` uses **Responses → Messages** for Anthropic providers, while OpenAI-compatible providers and Chat-only Copilot models reuse the existing Messages route for **Responses → Messages → Chat Completions**, then translate streaming or JSON results back to Responses.
|
|
312
|
+
|
|
313
|
+
> **Note:** DeepSeek models do not use Responses Lite (`use_responses_lite: false`, `tool_mode: null`), so the tool set they advertise to Codex differs from other models, which use `tool_mode: "code_mode_only"`. Switching between a DeepSeek model and a Responses Lite model mid-session is not compatible, because tool calls and conversation history produced under one tool set do not translate to the other. Start a new Codex session when switching between them.
|
|
312
314
|
|
|
313
315
|
The merged catalog is what Codex shows in its model picker, including the models exposed by your configured providers:
|
|
314
316
|
|
|
@@ -735,7 +737,7 @@ Gateway API keys live under `auth.apiKeys` in `config.json`. Manage them with `c
|
|
|
735
737
|
- **auth.adminApiKey:** Single admin key used only for `/admin/*` routes. If missing, the server generates a random key at startup and writes it back to `config.json`. Requests use the same `x-api-key` or `Authorization: Bearer` headers, but regular `auth.apiKeys` never grant access to `/admin/*`.
|
|
736
738
|
- **modelMappings:** Exact `sourceModel -> targetModel` rewrites shared by top-level `POST /v1/messages`, `POST /v1/messages/count_tokens`, `POST /v1/responses`, and `POST /v1/chat/completions` requests. Omit it or leave it as `{}` to disable rewrites. Both the source and target must be non-empty strings. Targets can be regular model IDs or `provider/model` aliases such as `dashscope/qwen3.6-plus`, and the rewrite happens before provider alias parsing. These mappings are not split per interface. The admin endpoints `GET/POST /admin/config/model-mappings` read and update only this field.
|
|
737
739
|
- **extraPrompts:** Map of `model -> prompt` appended to the first system prompt when translating Anthropic-style requests to Responses API. Use this to inject guardrails or guidance per model. Missing default entries are auto-added without overwriting your custom prompts. For GPT-5.3+ models (e.g. `gpt-5.3-codex`, `gpt-5.4`, `gpt-5.5`), a built-in commentary prompt is used as fallback when not explicitly configured. The built-in prompts enable phase-aware commentary, which lets the model emit a short user-facing progress update before tools or deeper reasoning.
|
|
738
|
-
- **providers:** Global upstream provider map. Each provider key (for example `dashscope`) becomes a route prefix (`/dashscope/v1/messages`). Supports `type: "anthropic"`, `type: "openai-compatible"`, and `type: "openai-responses"`. Top-level clients can also use `model: "dashscope/model-id"` with `/v1/messages`, `/v1/messages/count_tokens`, `/v1/responses`, and `/v1/chat/completions`; the gateway strips the `dashscope/` prefix before forwarding upstream. The `/v1/responses` route for `anthropic` and `openai-compatible` providers uses the Responses Lite → Messages adapter; `openai-compatible` providers then reuse the Messages → Chat translation. Codex clients (`User-Agent` starting with `codex`) also use the adapter for non-`gpt-*` models on `openai-responses` providers. `GET /v1/models` aggregates enabled provider models with `provider/model-id` IDs, while the top-level Codex-UA catalog also merges these adaptable models as `use_responses_lite` entries. Use `GET /dashscope/v1/models` for a single provider's raw model list.
|
|
740
|
+
- **providers:** Global upstream provider map. Each provider key (for example `dashscope`) becomes a route prefix (`/dashscope/v1/messages`). Supports `type: "anthropic"`, `type: "openai-compatible"`, and `type: "openai-responses"`. Top-level clients can also use `model: "dashscope/model-id"` with `/v1/messages`, `/v1/messages/count_tokens`, `/v1/responses`, and `/v1/chat/completions`; the gateway strips the `dashscope/` prefix before forwarding upstream. The `/v1/responses` route for `anthropic` and `openai-compatible` providers uses the Responses Lite → Messages adapter; `openai-compatible` providers then reuse the Messages → Chat translation. Codex clients (`User-Agent` starting with `codex`) also use the adapter for non-`gpt-*` models on `openai-responses` providers. `GET /v1/models` aggregates enabled provider models with `provider/model-id` IDs, while the top-level Codex-UA catalog also merges these adaptable models as `use_responses_lite` entries (except DeepSeek models, which use `use_responses_lite: false` and `tool_mode: null`). Use `GET /dashscope/v1/models` for a single provider's raw model list.
|
|
739
741
|
- `enabled` defaults to `true` if omitted.
|
|
740
742
|
- `baseUrl` should be provider API base URL without the final endpoint. For Anthropic providers, omit `/v1/messages`; for OpenAI-compatible providers, omit `/v1/chat/completions`; for OpenAI Responses providers, omit `/v1/responses`.
|
|
741
743
|
- `apiKey` is used as the upstream credential value and is required unless `authType` is `azure-entra`.
|
package/README.zh-CN.md
CHANGED
|
@@ -324,7 +324,9 @@ args = [
|
|
|
324
324
|
|
|
325
325
|
未按上述方式配置时,Codex 未登录 GPT 账号拉不到 `/v1/models`,无法选择自定义模型。
|
|
326
326
|
|
|
327
|
-
Codex 客户端(`User-Agent` 以 `codex` 开头)请求顶层 `GET /v1/models` 时,网关会把原生 Codex 模型与可通过 Messages
|
|
327
|
+
Codex 客户端(`User-Agent` 以 `codex` 开头)请求顶层 `GET /v1/models` 时,网关会把原生 Codex 模型与可通过 Messages 适配的模型合并返回。除 DeepSeek 模型外,后者会声明 `use_responses_lite: true`;DeepSeek 模型使用 `use_responses_lite: false` 和 `tool_mode: null`。调用 `/v1/responses` 后,Anthropic provider 走 **Responses → Messages**,OpenAI 兼容 provider 以及只支持 Chat 的 Copilot 模型则复用现有 Messages 路由继续走 **Responses → Messages → Chat Completions**,最终统一翻译回 Responses(包括流式事件)。
|
|
328
|
+
|
|
329
|
+
> **注意:** DeepSeek 模型不使用 Responses Lite(`use_responses_lite: false`、`tool_mode: null`),因此向 Codex 暴露的工具集合与其他模型(`tool_mode: "code_mode_only"`)不一致。在会话中途切换 DeepSeek 模型与 Responses Lite 模型并不兼容——一套工具集合下产生的工具调用和会话历史无法直接沿用到另一套。切换模型时请新建 Codex 会话。
|
|
328
330
|
|
|
329
331
|
合并后的模型列表会直接展示在 Codex 的模型选择界面中,包含各 provider 暴露的模型:
|
|
330
332
|
|
|
@@ -779,7 +781,7 @@ Codex provider 最多保存 3 个账号。使用 `copilot-api auth login --provi
|
|
|
779
781
|
- **auth.adminApiKey:** 仅用于 `/admin/*` 路由的单个 admin key。若未配置,服务会在启动时自动生成一个随机 key,并回写到 `config.json`。它同样使用 `x-api-key` 或 `Authorization: Bearer` 这两种头,但普通 `auth.apiKeys` 不能访问 `/admin/*`。
|
|
780
782
|
- **modelMappings:** 用于顶层 `POST /v1/messages`、`POST /v1/messages/count_tokens`、`POST /v1/responses` 和 `POST /v1/chat/completions` 请求的精确 `sourceModel -> targetModel` 重写映射,这几类接口共用同一份规则。省略该字段或保留为 `{}` 时,不会做模型重写。`source` 和 `target` 都必须是非空字符串。`target` 可以是普通模型 ID,也可以是 `provider/model` 形式的别名,例如 `dashscope/qwen3.6-plus`;重写发生在 provider alias 解析之前。这些映射不再按接口区分。`GET/POST /admin/config/model-mappings` 管理接口读写的也只有这个字段。
|
|
781
783
|
- **extraPrompts:** `model -> prompt` 的映射。把 Anthropic 风格请求翻译为 Responses API 时,会将其附加到第一条 system prompt 后面。你可以借此为不同模型注入护栏或指引。缺失的默认项会自动补齐,但不会覆盖你自定义的 prompt。对于 GPT-5.3+ 模型(如 `gpt-5.3-codex`、`gpt-5.4`、`gpt-5.5`),未显式配置时会自动使用内置的 commentary prompt。内置 prompt 会启用带阶段感知的 commentary,让模型在工具调用或更深层推理前先发出简短的用户可见进度说明。
|
|
782
|
-
- **providers:** 全局上游 provider 映射。每个 provider key(例如 `dashscope`)都会变成一个路由前缀(`/dashscope/v1/messages`)。支持 `type: "anthropic"`、`type: "openai-compatible"` 和 `type: "openai-responses"`。顶层客户端也可以在 `/v1/messages`、`/v1/messages/count_tokens`、`/v1/responses` 和 `/v1/chat/completions` 中使用 `model: "dashscope/model-id"`;AI gateway 会在转发上游前移除 `dashscope/` 前缀。`anthropic` 和 `openai-compatible` provider 的 `/v1/responses` 会通过 Responses Lite → Messages 适配;其中 `openai-compatible` provider 再复用 Messages → Chat 翻译。Codex 客户端(`User-Agent` 以 `codex` 开头)在 `openai-responses` provider 上请求非 `gpt-*` 模型时同样走该适配路径。`GET /v1/models` 会聚合已启用 provider 的模型,并以 `provider/model-id` 形式返回;Codex UA 的顶层模型列表还会把这些可适配模型合并为 `use_responses_lite`
|
|
784
|
+
- **providers:** 全局上游 provider 映射。每个 provider key(例如 `dashscope`)都会变成一个路由前缀(`/dashscope/v1/messages`)。支持 `type: "anthropic"`、`type: "openai-compatible"` 和 `type: "openai-responses"`。顶层客户端也可以在 `/v1/messages`、`/v1/messages/count_tokens`、`/v1/responses` 和 `/v1/chat/completions` 中使用 `model: "dashscope/model-id"`;AI gateway 会在转发上游前移除 `dashscope/` 前缀。`anthropic` 和 `openai-compatible` provider 的 `/v1/responses` 会通过 Responses Lite → Messages 适配;其中 `openai-compatible` provider 再复用 Messages → Chat 翻译。Codex 客户端(`User-Agent` 以 `codex` 开头)在 `openai-responses` provider 上请求非 `gpt-*` 模型时同样走该适配路径。`GET /v1/models` 会聚合已启用 provider 的模型,并以 `provider/model-id` 形式返回;Codex UA 的顶层模型列表还会把这些可适配模型合并为 `use_responses_lite` 模型(DeepSeek 模型除外,它们使用 `use_responses_lite: false` 和 `tool_mode: null`)。单个 provider 的原始模型列表仍可使用 `GET /dashscope/v1/models`。
|
|
783
785
|
- `enabled`:可选,若省略则默认为 `true`。
|
|
784
786
|
- `baseUrl`:provider API 的基础 URL,不要带结尾的 endpoint。Anthropic provider 不要带 `/v1/messages`;OpenAI 兼容 provider 不要带 `/v1/chat/completions`;OpenAI Responses provider 不要带 `/v1/responses`。
|
|
785
787
|
- `apiKey`:作为上游凭据值使用;除 `authType` 为 `azure-entra` 外,普通 provider 必须配置。
|
package/dist/main.js
CHANGED
|
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
|
|
|
30
30
|
const { auth } = await import("./auth-vYMQMBSa.js");
|
|
31
31
|
const { debug } = await import("./debug-DIQi6mF1.js");
|
|
32
32
|
const { mcp } = await import("./mcp-Byz9h_xz.js");
|
|
33
|
-
const { start } = await import("./start-
|
|
33
|
+
const { start } = await import("./start-tVcNsIV-.js");
|
|
34
34
|
await runMain(defineCommand({
|
|
35
35
|
meta: {
|
|
36
36
|
name: "copilot-api",
|
|
@@ -10638,6 +10638,12 @@ const FALLBACK_BASE_INSTRUCTIONS = FALLBACK_CODEX_MODELS.find((model) => model.b
|
|
|
10638
10638
|
function isCodexUserAgent(userAgent) {
|
|
10639
10639
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
10640
10640
|
}
|
|
10641
|
+
function isDeepSeekModelId(modelId) {
|
|
10642
|
+
return modelId.toLowerCase().includes("deepseek");
|
|
10643
|
+
}
|
|
10644
|
+
function shouldInjectMessagesToolCallTips(userAgent, targetModel) {
|
|
10645
|
+
return isCodexUserAgent(userAgent) && !isDeepSeekModelId(targetModel);
|
|
10646
|
+
}
|
|
10641
10647
|
/**
|
|
10642
10648
|
* Proxies a models request to the fixed Codex upstream models endpoint.
|
|
10643
10649
|
* Returns a 404 JSON response when the codex provider is unavailable.
|
|
@@ -10707,6 +10713,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
10707
10713
|
const defaultReasoningEffort = reasoningEfforts.includes(candidate.defaultReasoningEffort) ? candidate.defaultReasoningEffort : reasoningEfforts[0];
|
|
10708
10714
|
const supportsReasoning = reasoningEfforts.some((effort) => effort !== "none");
|
|
10709
10715
|
const inputModalities = [...new Set(candidate.inputModalities)];
|
|
10716
|
+
const isDeepSeekModel = isDeepSeekModelId(candidate.slug);
|
|
10710
10717
|
return {
|
|
10711
10718
|
...template,
|
|
10712
10719
|
slug: candidate.slug,
|
|
@@ -10722,11 +10729,11 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
10722
10729
|
apply_patch_tool_type: "freeform",
|
|
10723
10730
|
web_search_tool_type: "text_and_image",
|
|
10724
10731
|
supports_search_tool: false,
|
|
10725
|
-
use_responses_lite: true,
|
|
10726
|
-
tool_mode: "code_mode_only",
|
|
10732
|
+
use_responses_lite: isDeepSeekModel ? false : true,
|
|
10733
|
+
tool_mode: isDeepSeekModel ? null : "code_mode_only",
|
|
10727
10734
|
multi_agent_version: "v2",
|
|
10728
10735
|
multi_agent_reasoning_effort: null,
|
|
10729
|
-
shell_type: template.shell_type,
|
|
10736
|
+
shell_type: isDeepSeekModel ? "shell_command" : template.shell_type,
|
|
10730
10737
|
experimental_supported_tools: [],
|
|
10731
10738
|
input_modalities: inputModalities,
|
|
10732
10739
|
supports_image_detail_original: false,
|
|
@@ -12080,7 +12087,7 @@ async function handleResponsesViaMessages(c, options) {
|
|
|
12080
12087
|
}, {
|
|
12081
12088
|
model: options.targetModel,
|
|
12082
12089
|
publicModel: options.publicModel,
|
|
12083
|
-
toolCallTips:
|
|
12090
|
+
toolCallTips: shouldInjectMessagesToolCallTips(c.req.header("user-agent"), options.targetModel)
|
|
12084
12091
|
});
|
|
12085
12092
|
const context = translation;
|
|
12086
12093
|
debugJson(logger$3, "Translated Messages request:", {
|
|
@@ -12679,4 +12686,4 @@ createServer();
|
|
|
12679
12686
|
//#endregion
|
|
12680
12687
|
export { createServer };
|
|
12681
12688
|
|
|
12682
|
-
//# sourceMappingURL=server-
|
|
12689
|
+
//# sourceMappingURL=server-BfbNbfYw.js.map
|