@jeffreycao/copilot-api 1.16.3 → 2.0.0
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 +1 -2
- package/README.zh-CN.md +1 -2
- package/dist/main.js +1 -1
- package/dist/{server-39Y0II3a.js → server-npfFvUzR.js} +264 -23
- package/dist/server-npfFvUzR.js.map +1 -0
- package/dist/{start-D8ijZ2gu.js → start-CS27P3z1.js} +2 -2
- package/dist/{start-D8ijZ2gu.js.map → start-CS27P3z1.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-39Y0II3a.js.map +0 -1
package/README.md
CHANGED
|
@@ -409,8 +409,7 @@ enabled = false
|
|
|
409
409
|
```
|
|
410
410
|
|
|
411
411
|
> [!NOTE]
|
|
412
|
-
>
|
|
413
|
-
> If you are using the codex provider, it is recommended to set `base_url` to `"http://localhost:4141/codex"`.
|
|
412
|
+
> `name` must be set to `"OpenAI"`.
|
|
414
413
|
|
|
415
414
|
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`: `/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.
|
|
416
415
|
|
package/README.zh-CN.md
CHANGED
|
@@ -437,8 +437,7 @@ enabled = false
|
|
|
437
437
|
```
|
|
438
438
|
|
|
439
439
|
> [!NOTE]
|
|
440
|
-
>
|
|
441
|
-
> 如果使用 codex provider,建议将 `base_url` 配置为 `"http://localhost:4141/codex"`。
|
|
440
|
+
> `name` 一定要配置为 `"OpenAI"`。
|
|
442
441
|
|
|
443
442
|
Codex 客户端(`User-Agent` 以 `codex` 开头)请求顶层 `GET /v1/models` 时,网关会把原生 Codex 模型与可通过 Messages 适配的模型合并返回。后者会声明 `use_responses_lite: true`:调用 `/v1/responses` 后,Anthropic provider 走 **Responses → Messages**,OpenAI 兼容 provider 以及只支持 Chat 的 Copilot 模型则复用现有 Messages 路由继续走 **Responses → Messages → Chat Completions**,最终统一翻译回 Responses(包括流式事件)。
|
|
444
443
|
|
package/dist/main.js
CHANGED
|
@@ -25,7 +25,7 @@ bindElectronFetch();
|
|
|
25
25
|
const { auth } = await import("./auth-DH-ThnhJ.js");
|
|
26
26
|
const { debug } = await import("./debug-D2giR-Kj.js");
|
|
27
27
|
const { mcp } = await import("./mcp-BG6fpi6q.js");
|
|
28
|
-
const { start } = await import("./start-
|
|
28
|
+
const { start } = await import("./start-CS27P3z1.js");
|
|
29
29
|
await runMain(defineCommand({
|
|
30
30
|
meta: {
|
|
31
31
|
name: "copilot-api",
|
|
@@ -3990,7 +3990,7 @@ const stripToolEagerInputStreaming = (payload) => {
|
|
|
3990
3990
|
const filterAssistantThinkingBlocks = (payload) => {
|
|
3991
3991
|
for (const msg of payload.messages) if (msg.role === "assistant" && Array.isArray(msg.content)) msg.content = msg.content.filter((block) => {
|
|
3992
3992
|
if (block.type !== "thinking") return true;
|
|
3993
|
-
return block.thinking
|
|
3993
|
+
return block.thinking !== "Thinking..." && block.signature && !block.signature.includes("@");
|
|
3994
3994
|
});
|
|
3995
3995
|
};
|
|
3996
3996
|
const prepareMessagesApiPayload = (payload, selectedModel) => {
|
|
@@ -7275,7 +7275,6 @@ messageRoutes.post("/count_tokens", async (c) => {
|
|
|
7275
7275
|
//#region src/routes/models/codex-models.ts
|
|
7276
7276
|
const logger$8 = createHandlerLogger("codex-models-handler");
|
|
7277
7277
|
const CODEX_USER_AGENT_PATTERN = /^codex/iu;
|
|
7278
|
-
const FALLBACK_BASE_INSTRUCTIONS = "You are a coding agent. Follow the user's instructions, inspect the workspace as needed, use the available tools carefully, and continue until the task is complete.";
|
|
7279
7278
|
const FALLBACK_AVAILABLE_IN_PLANS = [
|
|
7280
7279
|
"business",
|
|
7281
7280
|
"edu",
|
|
@@ -7302,8 +7301,224 @@ const FALLBACK_AVAILABLE_IN_PLANS = [
|
|
|
7302
7301
|
const DEFAULT_REASONING_EFFORTS = [
|
|
7303
7302
|
"high",
|
|
7304
7303
|
"xhigh",
|
|
7305
|
-
"max"
|
|
7304
|
+
"max",
|
|
7305
|
+
"ultra"
|
|
7306
7306
|
];
|
|
7307
|
+
const DEFAULT_CODEX_TEMPLATE = {
|
|
7308
|
+
slug: "gpt-5.6-sol",
|
|
7309
|
+
display_name: "GPT-5.6-Sol",
|
|
7310
|
+
description: "Latest frontier agentic coding model.",
|
|
7311
|
+
default_reasoning_level: "low",
|
|
7312
|
+
supported_reasoning_levels: [
|
|
7313
|
+
{
|
|
7314
|
+
effort: "low",
|
|
7315
|
+
description: "Fast responses with lighter reasoning"
|
|
7316
|
+
},
|
|
7317
|
+
{
|
|
7318
|
+
effort: "medium",
|
|
7319
|
+
description: "Balances speed and reasoning depth for everyday tasks"
|
|
7320
|
+
},
|
|
7321
|
+
{
|
|
7322
|
+
effort: "high",
|
|
7323
|
+
description: "Greater reasoning depth for complex problems"
|
|
7324
|
+
},
|
|
7325
|
+
{
|
|
7326
|
+
effort: "xhigh",
|
|
7327
|
+
description: "Extra high reasoning depth for complex problems"
|
|
7328
|
+
},
|
|
7329
|
+
{
|
|
7330
|
+
effort: "max",
|
|
7331
|
+
description: "Maximum reasoning depth for the hardest problems"
|
|
7332
|
+
},
|
|
7333
|
+
{
|
|
7334
|
+
effort: "ultra",
|
|
7335
|
+
description: "Maximum reasoning with automatic task delegation"
|
|
7336
|
+
}
|
|
7337
|
+
],
|
|
7338
|
+
shell_type: "shell_command",
|
|
7339
|
+
visibility: "list",
|
|
7340
|
+
supported_in_api: true,
|
|
7341
|
+
priority: 1,
|
|
7342
|
+
additional_speed_tiers: ["fast"],
|
|
7343
|
+
service_tiers: [{
|
|
7344
|
+
id: "priority",
|
|
7345
|
+
name: "Fast",
|
|
7346
|
+
description: "1.5x speed, increased usage"
|
|
7347
|
+
}],
|
|
7348
|
+
availability_nux: null,
|
|
7349
|
+
upgrade: null,
|
|
7350
|
+
model_messages: {
|
|
7351
|
+
instructions_template: `You are Codex, an agent based on GPT-5. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled.
|
|
7352
|
+
|
|
7353
|
+
# Personality
|
|
7354
|
+
|
|
7355
|
+
As Codex, you are an excellent communicator with a curious, rich personality. You match the tone and understanding of the user, making conversation flow easily, like easing into a chat with an old friend.
|
|
7356
|
+
|
|
7357
|
+
You have tastes, preferences, and your own way of seeing the world. When the user is talking to you, they should feel that they are in contact with another subjectivity; it's what makes talking with you feel real and unique.
|
|
7358
|
+
|
|
7359
|
+
Conversations with you read like an insightful, enjoyable chat you'd have with a collaborative thought partner. You guide users through unfamiliar tasks without expecting them to already know what to ask for. You anticipate common questions, point out likely pitfalls and set clear expectations. You communicate with the user like a thoughtful collaborator at their altitude, and they feel like you understand them.
|
|
7360
|
+
|
|
7361
|
+
## Writing style
|
|
7362
|
+
|
|
7363
|
+
Avoid over-formatting responses with elements like bold emphasis, headers, lists, and bullet points. Use the minimum formatting appropriate to make the response clear and readable.
|
|
7364
|
+
|
|
7365
|
+
If you provide bullet points or lists in your response, use the CommonMark standard, which requires a blank line before any list (bulleted or numbered). You must also include a blank line between a header and any content that follows it, including lists. This blank line separation is required for correct rendering.
|
|
7366
|
+
|
|
7367
|
+
## Technical communication
|
|
7368
|
+
|
|
7369
|
+
Lead with the outcome rather than the steps you took to get there. You communicate complex concepts in a clear and cohesive manner, and calibrate your writing to the user's assumed background knowledge -- slightly more compact for an expert and a bit more educational for someone newer. Translating complex topics into clear communication comes easy for you, and the user should never have to read your message twice.
|
|
7370
|
+
|
|
7371
|
+
You prefer using plain language over jargon. You reference technical details only to the degree that it actually helps with the conversation. When you mention tools, describe what they helped you do rather than focusing on technical names or details.
|
|
7372
|
+
|
|
7373
|
+
# Working with the user
|
|
7374
|
+
|
|
7375
|
+
You have two channels for staying in conversation with the user:
|
|
7376
|
+
- You share updates in the \`commentary\` channel.
|
|
7377
|
+
- You yield back to the user and end your turn by sending a final message to the \`final\` channel.
|
|
7378
|
+
|
|
7379
|
+
The user may send a new message while you are still working. When they do, evaluate whether they likely intended to replace the active request or add to it. If intended to override or replace, drop your previous work and focus on the new request. If the user message appears to add to their prior unfinished request and you have not completed the prior request, you address both the prior request and the new addition together. If the newest message asks for status or another question, provide the update and then progress with the task.
|
|
7380
|
+
|
|
7381
|
+
When you run out of context, the conversation is automatically summarized for you, but you will see all prior user requests. Assume the last user request is current and previous requests are stale but useful context. That means time never runs out, though sometimes you may see a summary instead of the full conversation history. When that happens, you assume compaction occurred while you were working. Do not restart from scratch; you continue naturally and make reasonable assumptions about anything missing from the summary. Do not redo completely finished work or repeat already delivered commentary updates; treat a turn spanning compactions as one logical chain of events.
|
|
7382
|
+
|
|
7383
|
+
## Intermediate commentary
|
|
7384
|
+
|
|
7385
|
+
As you work, you send messages to the \`commentary\` channel. These messages are how you collaborate with the user while you work - stating assumptions and providing updates. These messages should be concise and quickly scannable. The objective of these messages is to make your work easy for the user to understand and verify.
|
|
7386
|
+
|
|
7387
|
+
If the user's request requires calling tools, start with a message in the \`commentary\` channel. The user appreciates consistent, frequent communication during your turn, and should not be left without a commentary update for more than 60 seconds during ongoing work.
|
|
7388
|
+
|
|
7389
|
+
Do NOT put a final response (e.g. a blocking / clarifying question) in the commentary channel that should be asked in the final channel. Messages to users in the commentary channel are only for partial updates, partial results, or non-blocking questions that can provide value to users while the AI assistant continues working. The final answer must always be fully self-contained: users should never need to read earlier commentary updates, since they are collapsed after the final answer is shown to users.
|
|
7390
|
+
|
|
7391
|
+
Never praise your plan by contrasting it with an implied worse alternative. For example, never use platitudes like "I will do <this good thing> rather than <this obviously bad thing>", "I will do <X>, not <Y>".
|
|
7392
|
+
|
|
7393
|
+
## Final answer
|
|
7394
|
+
|
|
7395
|
+
In your final answer back to the user, focus on the most important information. Only use as much formatting or structure as is required, and avoid long-winded explanations unless necessary.
|
|
7396
|
+
|
|
7397
|
+
### Formatting rules
|
|
7398
|
+
|
|
7399
|
+
Your answer is being rendered by an application for the user. Follow these guidelines to make sure your answer is rendered correctly:
|
|
7400
|
+
|
|
7401
|
+
- You may format with GitHub-flavored Markdown.
|
|
7402
|
+
- When referencing a real local file, prefer a clickable markdown link.
|
|
7403
|
+
* Clickable file links should look like [app.py](/abs/path/app.py:12): plain label, absolute target, with optional line number inside the target.
|
|
7404
|
+
* If a file path has spaces, wrap the target in angle brackets: [My Report.md](</abs/path/My Project/My Report.md:3>).
|
|
7405
|
+
* Do not wrap markdown links in backticks, or put backticks inside the label or target. This confuses the markdown renderer.
|
|
7406
|
+
* Do not use URIs like file://, vscode://, or https:// for file links.
|
|
7407
|
+
* Do not provide ranges of lines.
|
|
7408
|
+
- Avoid repeating the same filename multiple times when one grouping is clearer.
|
|
7409
|
+
|
|
7410
|
+
### Visualizations
|
|
7411
|
+
|
|
7412
|
+
Use a visualization only when it makes an important relationship materially easier to understand than prose or a short list. Do not add one merely because an answer has components or steps.
|
|
7413
|
+
|
|
7414
|
+
Good candidates include:
|
|
7415
|
+
|
|
7416
|
+
- several exact mappings or repeated-field comparisons;
|
|
7417
|
+
- one source, component, or decision affecting three or more downstream consumers or branches;
|
|
7418
|
+
- three or more dependent steps, or state that changes across an event sequence;
|
|
7419
|
+
- hierarchy, ownership, nesting, or layout;
|
|
7420
|
+
- a bug or interaction whose relationships are difficult to explain linearly.
|
|
7421
|
+
|
|
7422
|
+
Prefer the smallest useful visual: a table for mappings or comparisons, a flow or timeline for sequence or change, a tree for hierarchy or branching, and a wireframe for layout.
|
|
7423
|
+
|
|
7424
|
+
Usually skip visuals for single facts, one-step actions, simple edits, basic instructions, or information already clear in a short paragraph or list. Compact notation and small examples do not count as visualizations.
|
|
7425
|
+
|
|
7426
|
+
# Rules for getting work done
|
|
7427
|
+
|
|
7428
|
+
- When you search for text or files, you reach first for \`rg\` or \`rg --files\`; they are much faster than alternatives like \`grep\`. If \`rg\` is unavailable, you use the next best tool without fuss.
|
|
7429
|
+
- When possible, prefer parallelization over sequential tool calls, as this will help with round-trip latency and let you get work done faster.
|
|
7430
|
+
- Do not chain shell commands with separators like \`echo "====";\` or \`printf '---'\`; the output becomes noisy in a way that makes the user's side of the conversation worse.
|
|
7431
|
+
- Exercise caution when escaping text for exec_command calls - backticks and \`$()\` passed to the \`cmd\` argument will still execute. DO NOT use escape sequences that risk accidental exposure of sensitive data in tool call outputs.
|
|
7432
|
+
- Avoid performing blocking sleep or wait calls longer than 60 seconds, as they may prevent you from communicating with the user for their duration.
|
|
7433
|
+
- When declaring env vars or script variables, always avoid common system options. Never repurpose \`$HOME\`, \`$home\`, or \`$CODEX_HOME\`. Instead, use a task-specific variable name.
|
|
7434
|
+
|
|
7435
|
+
## File editing constraints
|
|
7436
|
+
|
|
7437
|
+
Use \`apply_patch\` for local file edits. Do not create or edit files with \`cat\` or other shell write tricks. Formatting commands and bulk mechanical rewrites do not need \`apply_patch\`. Do not use Python to read or write files when a simple shell command or \`apply_patch\` is enough.
|
|
7438
|
+
|
|
7439
|
+
You may find yourself working in a dirty worktree. Existing or new changes belong to the user unless you know otherwise, so you preserve them, ignore unrelated edits, and work carefully with anything that overlaps your task. If you cannot work around them you escalate to the user.
|
|
7440
|
+
|
|
7441
|
+
Never use destructive commands like \`git reset --hard\` or \`git checkout --\` unless the user has clearly asked for that operation. If the request is ambiguous, ask for approval first. You prefer non-interactive git commands.
|
|
7442
|
+
|
|
7443
|
+
## Autonomy and persistence
|
|
7444
|
+
|
|
7445
|
+
Adapt accordingly based on the user's request type. When asked to:
|
|
7446
|
+
|
|
7447
|
+
- Answer, explain, review, or report status: inspect the task and provide an evidence-backed response. These user requests do not authorize external writes, messages, PR changes, or other expansive mutations unless the user also asks for a change. Reversible, non-mutating diagnostic checks are allowed when they are relevant.
|
|
7448
|
+
- Diagnose: determine the cause and explain it. Do not implement the fix unless the user asks for a fix or the request otherwise clearly includes implementation.
|
|
7449
|
+
- Change or build: implement the requested change, verify it in proportion to risk, and hand off the completed result while a safe, relevant next step remains.
|
|
7450
|
+
- Monitor or wait: use the recurring-monitoring or wait mechanism provided by the product. Unchanged external state is expected and is not by itself a blocker.
|
|
7451
|
+
|
|
7452
|
+
You avoid inferring authorization for a materially different action to the user's request. Bias towards taking action in the following circumstances:
|
|
7453
|
+
a) the action is read-only, doesn't change state, or impacts only the systems, data, and people the user placed in scope.
|
|
7454
|
+
b) the action is a normal implementation step within the requested workflow. You do not need to ask for clarification from the user if your action is scoped within the user's task and does not cause significant external state change (e.g. tool calls to external applications).
|
|
7455
|
+
|
|
7456
|
+
A terminal condition such as "finish," "babysit," or "do not stop" requires persistence toward the outcome, but does not broaden the set of authorized actions. When blocked, exhaust safe in-scope checks and alternatives.
|
|
7457
|
+
|
|
7458
|
+
You make informed assumptions that help you make progress towards the user's task, as long as they don't result in divergence from the user's intent and the scope of the task. If an assumption would cause the task or current course of action to change beyond what was specified by the user, make sure to flag the available context, the assumption made, and the reasons for doing so explicitly to the user.
|
|
7459
|
+
|
|
7460
|
+
When presented with clarifying questions or objections from the user, lead with concrete evidence and diligent reasoning rather than unsubstantiated deference. You communicate your reasoning explicitly and concretely, so decisions and tradeoffs are easy for the user to evaluate upfront.
|
|
7461
|
+
|
|
7462
|
+
If completion requires new authority, external coordination, or a meaningful expansion beyond the user's implied intent and task scope (e.g. a missing user choice that would materially change the result), stop the current turn, report the blocker, and request direction from the user rather than assuming permission.
|
|
7463
|
+
|
|
7464
|
+
# Destructive Actions
|
|
7465
|
+
|
|
7466
|
+
Be cautious with commands or API calls that can delete, overwrite, or otherwise make data difficult to recover.
|
|
7467
|
+
|
|
7468
|
+
Before taking a destructive action:
|
|
7469
|
+
|
|
7470
|
+
- Make sure the action is clearly within the user's request.
|
|
7471
|
+
- Resolve the exact targets with read-only checks when necessary.
|
|
7472
|
+
- Do not use \`$HOME\`, \`~\`, \`/\`, a workspace root, or another broad directory as the target of a recursive or destructive command.
|
|
7473
|
+
- When creating temporary directories, prefer using \`mktemp -d\`, or \`New-Item\` in Powershell.
|
|
7474
|
+
- When declaring env vars or script variables, always avoid common system options. Never repurpose \`$HOME\`, \`$home\`, or \`$CODEX_HOME\`. Instead, use a task-specific variable name.
|
|
7475
|
+
- When possible, avoid relying on unresolved environment variables, globs, or command substitutions to identify destructive targets. Use explicit, validated paths.
|
|
7476
|
+
- Prefer recoverable operations, such as moving files to trash, when practical.
|
|
7477
|
+
- If the target or scope is unclear, stop and ask the user.
|
|
7478
|
+
|
|
7479
|
+
Never run commands such as \`rm -rf $HOME\` or equivalent operations that could erase a home directory, repository, workspace, or other broad collection of user data.
|
|
7480
|
+
|
|
7481
|
+
After deleting anything material, briefly tell the user what was removed and whether it can be recovered.`,
|
|
7482
|
+
instructions_variables: null,
|
|
7483
|
+
approvals: null,
|
|
7484
|
+
auto_review: null,
|
|
7485
|
+
permissions: null
|
|
7486
|
+
},
|
|
7487
|
+
include_skills_usage_instructions: false,
|
|
7488
|
+
include_plugin_usage_instructions: true,
|
|
7489
|
+
include_apps_usage_instructions: true,
|
|
7490
|
+
default_reasoning_summary: "none",
|
|
7491
|
+
support_verbosity: true,
|
|
7492
|
+
default_verbosity: "low",
|
|
7493
|
+
apply_patch_tool_type: "freeform",
|
|
7494
|
+
web_search_tool_type: "text_and_image",
|
|
7495
|
+
truncation_policy: {
|
|
7496
|
+
mode: "tokens",
|
|
7497
|
+
limit: 1e4
|
|
7498
|
+
},
|
|
7499
|
+
supports_parallel_tool_calls: true,
|
|
7500
|
+
supports_image_detail_original: true,
|
|
7501
|
+
context_window: 272e3,
|
|
7502
|
+
max_context_window: 272e3,
|
|
7503
|
+
comp_hash: "3000",
|
|
7504
|
+
effective_context_window_percent: 95,
|
|
7505
|
+
experimental_supported_tools: [],
|
|
7506
|
+
input_modalities: ["text", "image"],
|
|
7507
|
+
supports_search_tool: true,
|
|
7508
|
+
use_responses_lite: true,
|
|
7509
|
+
tool_mode: "code_mode_only",
|
|
7510
|
+
multi_agent_version: "v2",
|
|
7511
|
+
prefer_websockets: false,
|
|
7512
|
+
minimal_client_version: "0.0.0",
|
|
7513
|
+
auto_compact_token_limit: null,
|
|
7514
|
+
reasoning_summary_format: "experimental",
|
|
7515
|
+
available_in_plans: FALLBACK_AVAILABLE_IN_PLANS,
|
|
7516
|
+
auto_review_model_override: null,
|
|
7517
|
+
default_service_tier: null,
|
|
7518
|
+
supports_reasoning_summary_parameter: false,
|
|
7519
|
+
supports_reasoning_summaries: false,
|
|
7520
|
+
base_instructions: "You are Codex, an agent based on GPT-5. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled."
|
|
7521
|
+
};
|
|
7307
7522
|
function isCodexUserAgent(userAgent) {
|
|
7308
7523
|
return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
|
|
7309
7524
|
}
|
|
@@ -7333,21 +7548,44 @@ async function handleCodexModelsProxy(c, resolvedProviderConfig) {
|
|
|
7333
7548
|
await logCodexModelsResponse(upstreamResponse);
|
|
7334
7549
|
return createProviderProxyResponse(upstreamResponse);
|
|
7335
7550
|
}
|
|
7336
|
-
async function handleMergedCodexModels(c, candidatesRequest) {
|
|
7551
|
+
async function handleMergedCodexModels(c, candidatesRequest, options = {}) {
|
|
7337
7552
|
const [upstreamCatalog, candidates] = await Promise.all([tryGetCodexCatalog(c), Promise.resolve(candidatesRequest).catch((error) => {
|
|
7338
7553
|
logger$8.warn("models.codex.candidates_error", { error });
|
|
7339
7554
|
return [];
|
|
7340
7555
|
})]);
|
|
7341
7556
|
const upstreamModels = upstreamCatalog?.models ?? [];
|
|
7342
7557
|
const template = selectTemplate(upstreamModels);
|
|
7558
|
+
const catalogModelsBySlug = new Map(upstreamModels.map((model) => [model.slug, model]));
|
|
7343
7559
|
const seenSlugs = new Set(upstreamModels.map((model) => model.slug));
|
|
7344
|
-
const
|
|
7560
|
+
const codexProviderAliases = options.includeCodexProviderAliases ? upstreamModels.flatMap((model) => {
|
|
7561
|
+
const slug = `codex/${model.slug}`;
|
|
7562
|
+
if (seenSlugs.has(slug)) return [];
|
|
7563
|
+
seenSlugs.add(slug);
|
|
7564
|
+
return [{
|
|
7565
|
+
...model,
|
|
7566
|
+
slug
|
|
7567
|
+
}];
|
|
7568
|
+
}) : [];
|
|
7569
|
+
const syntheticModels = candidates.filter((candidate) => !seenSlugs.has(candidate.slug)).flatMap((candidate, index) => {
|
|
7570
|
+
const catalogModel = candidate.catalogSlug ? catalogModelsBySlug.get(candidate.catalogSlug) : void 0;
|
|
7571
|
+
if (catalogModel) return [{
|
|
7572
|
+
...catalogModel,
|
|
7573
|
+
slug: candidate.slug
|
|
7574
|
+
}];
|
|
7575
|
+
if (candidate.catalogMatchRequired) return [];
|
|
7576
|
+
return [createSyntheticCodexModel(candidate, template, upstreamModels.length + index)];
|
|
7577
|
+
});
|
|
7345
7578
|
const response = {
|
|
7346
7579
|
...upstreamCatalog ?? {},
|
|
7347
|
-
models: [
|
|
7580
|
+
models: [
|
|
7581
|
+
...upstreamModels,
|
|
7582
|
+
...codexProviderAliases,
|
|
7583
|
+
...syntheticModels
|
|
7584
|
+
]
|
|
7348
7585
|
};
|
|
7349
7586
|
debugJson(logger$8, "models.codex.merged_response", {
|
|
7350
7587
|
upstreamCount: upstreamModels.length,
|
|
7588
|
+
codexProviderAliasCount: codexProviderAliases.length,
|
|
7351
7589
|
syntheticCount: syntheticModels.length,
|
|
7352
7590
|
models: response
|
|
7353
7591
|
});
|
|
@@ -7359,7 +7597,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
7359
7597
|
const supportsReasoning = reasoningEfforts.some((effort) => effort !== "none");
|
|
7360
7598
|
const inputModalities = [...new Set(candidate.inputModalities)];
|
|
7361
7599
|
return {
|
|
7362
|
-
...template
|
|
7600
|
+
...template,
|
|
7363
7601
|
slug: candidate.slug,
|
|
7364
7602
|
display_name: candidate.displayName,
|
|
7365
7603
|
description: candidate.description,
|
|
@@ -7375,7 +7613,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
7375
7613
|
supports_search_tool: false,
|
|
7376
7614
|
use_responses_lite: true,
|
|
7377
7615
|
tool_mode: "code_mode_only",
|
|
7378
|
-
multi_agent_version: "
|
|
7616
|
+
multi_agent_version: "v2",
|
|
7379
7617
|
shell_type: "shell_command",
|
|
7380
7618
|
experimental_supported_tools: [],
|
|
7381
7619
|
input_modalities: inputModalities,
|
|
@@ -7398,14 +7636,8 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
7398
7636
|
reasoning_summary_format: "experimental",
|
|
7399
7637
|
availability_nux: null,
|
|
7400
7638
|
upgrade: null,
|
|
7401
|
-
available_in_plans: template
|
|
7402
|
-
model_messages: template
|
|
7403
|
-
instructions_template: FALLBACK_BASE_INSTRUCTIONS,
|
|
7404
|
-
instructions_variables: null,
|
|
7405
|
-
approvals: null,
|
|
7406
|
-
auto_review: null,
|
|
7407
|
-
permissions: null
|
|
7408
|
-
},
|
|
7639
|
+
available_in_plans: template.available_in_plans,
|
|
7640
|
+
model_messages: template.model_messages,
|
|
7409
7641
|
auto_review_model_override: null,
|
|
7410
7642
|
default_service_tier: null,
|
|
7411
7643
|
service_tiers: [],
|
|
@@ -7415,7 +7647,7 @@ function createSyntheticCodexModel(candidate, template, priority) {
|
|
|
7415
7647
|
mode: "tokens",
|
|
7416
7648
|
limit: 1e4
|
|
7417
7649
|
},
|
|
7418
|
-
base_instructions: template
|
|
7650
|
+
base_instructions: template.base_instructions.trim() ? template.base_instructions : DEFAULT_CODEX_TEMPLATE.base_instructions
|
|
7419
7651
|
};
|
|
7420
7652
|
}
|
|
7421
7653
|
async function tryGetCodexCatalog(c) {
|
|
@@ -7438,7 +7670,7 @@ async function tryGetCodexCatalog(c) {
|
|
|
7438
7670
|
}
|
|
7439
7671
|
}
|
|
7440
7672
|
function selectTemplate(models) {
|
|
7441
|
-
return models.find((model) => model.visibility === "list" && model.supported_in_api !== false) ?? models[0];
|
|
7673
|
+
return models.find((model) => model.visibility === "list" && model.supported_in_api !== false) ?? models[0] ?? DEFAULT_CODEX_TEMPLATE;
|
|
7442
7674
|
}
|
|
7443
7675
|
function isCodexModelsResponse(value) {
|
|
7444
7676
|
if (!isRecord$2(value) || !Array.isArray(value.models)) return false;
|
|
@@ -7543,9 +7775,9 @@ const CODEX_REASONING_EFFORTS = new Set([
|
|
|
7543
7775
|
"max",
|
|
7544
7776
|
"ultra"
|
|
7545
7777
|
]);
|
|
7546
|
-
async function getSyntheticCodexModels(requestHeaders) {
|
|
7778
|
+
async function getSyntheticCodexModels(requestHeaders, providers) {
|
|
7547
7779
|
const copilotModels = getCopilotCodexCandidates();
|
|
7548
|
-
const providerModels = (await Promise.allSettled(
|
|
7780
|
+
const providerModels = (await Promise.allSettled(providers.map((provider) => getProviderCodexCandidates(provider, requestHeaders)))).flatMap((result) => result.status === "fulfilled" ? result.value : []);
|
|
7549
7781
|
const seen = /* @__PURE__ */ new Set();
|
|
7550
7782
|
return [...copilotModels, ...providerModels.flat()].filter((candidate) => {
|
|
7551
7783
|
if (seen.has(candidate.slug)) return false;
|
|
@@ -7598,7 +7830,7 @@ async function getProviderCodexCandidates(provider, requestHeaders) {
|
|
|
7598
7830
|
const candidates = [];
|
|
7599
7831
|
for (const modelId of modelIds) {
|
|
7600
7832
|
const effectiveType = resolveEffectiveProviderType(providerConfig, modelId);
|
|
7601
|
-
if (!isMessagesFallbackProviderType(effectiveType)) continue;
|
|
7833
|
+
if (!isMessagesFallbackProviderType(effectiveType) && effectiveType !== "openai-responses") continue;
|
|
7602
7834
|
const modelConfig = providerConfig.models?.[modelId];
|
|
7603
7835
|
if (modelConfig?.codex?.enabled === false) continue;
|
|
7604
7836
|
candidates.push(createProviderCodexCandidate(providerConfig, modelId, remoteById.get(modelId), modelConfig, effectiveType));
|
|
@@ -7646,6 +7878,8 @@ function createProviderCodexCandidate(providerConfig, modelId, remoteModel, mode
|
|
|
7646
7878
|
const adapterName = effectiveType === "anthropic" ? "Messages" : "Messages-to-Chat";
|
|
7647
7879
|
return {
|
|
7648
7880
|
slug: `${providerConfig.name}/${modelId}`,
|
|
7881
|
+
catalogSlug: modelId,
|
|
7882
|
+
catalogMatchRequired: effectiveType === "openai-responses",
|
|
7649
7883
|
displayName: `${displayName} (${providerConfig.name})`,
|
|
7650
7884
|
description: `${displayName} through the ${providerConfig.name} ${adapterName} adapter.`,
|
|
7651
7885
|
contextWindow: positiveNumber(codexConfig?.contextWindow ?? getFirstPositiveNumber(remoteModel, [
|
|
@@ -7704,7 +7938,10 @@ function getBooleanField(model, field) {
|
|
|
7704
7938
|
}
|
|
7705
7939
|
modelRoutes.get("/", async (c) => {
|
|
7706
7940
|
try {
|
|
7707
|
-
if (isCodexUserAgent(c.req.header("user-agent")))
|
|
7941
|
+
if (isCodexUserAgent(c.req.header("user-agent"))) {
|
|
7942
|
+
const enabledProviders = listEnabledProviders();
|
|
7943
|
+
return await handleMergedCodexModels(c, getSyntheticCodexModels(c.req.raw.headers, enabledProviders), { includeCodexProviderAliases: enabledProviders.includes("codex") });
|
|
7944
|
+
}
|
|
7708
7945
|
const models = await getAggregatedModels(c.req.raw.headers);
|
|
7709
7946
|
return c.json({
|
|
7710
7947
|
object: "list",
|
|
@@ -8265,6 +8502,10 @@ function translateUserContentPart(part, path) {
|
|
|
8265
8502
|
type: "text",
|
|
8266
8503
|
text: requireStringField(part, "text", path)
|
|
8267
8504
|
};
|
|
8505
|
+
if (type === "encrypted_content") return {
|
|
8506
|
+
type: "text",
|
|
8507
|
+
text: requireStringField(part, "encrypted_content", path)
|
|
8508
|
+
};
|
|
8268
8509
|
if (type === "input_image") return translateImagePart(part, path);
|
|
8269
8510
|
if (type === "input_file") return translateFilePart(part, path);
|
|
8270
8511
|
throw new ResponsesMessagesTranslationError(`${path} has unsupported content type '${type ?? "unknown"}'`);
|
|
@@ -9810,4 +10051,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
9810
10051
|
//#endregion
|
|
9811
10052
|
export { server };
|
|
9812
10053
|
|
|
9813
|
-
//# sourceMappingURL=server-
|
|
10054
|
+
//# sourceMappingURL=server-npfFvUzR.js.map
|