@jeffreycao/copilot-api 2.7.18 → 2.7.20

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.
@@ -1,9 +1,9 @@
1
1
  import { D as state, E as isGitHubCopilotEnabled, O as HTTPError, S as PATHS, a as getAnthropicApiKey, c as getConfig, d as getUpstreamTransportConfig, g as isResponsesApiWebSocketEnabled, h as isResponsesApiWebSearchEnabled, i as getAlphaSearchModel, j as forwardError, l as getMessageApiWebSearchModel, m as isMessagesApiEnabled, o as getClaudeAutoModel, p as isAlphaSearchCodexPriorityEnabled, s as getClaudeTokenMultiplier, u as getOpencodeModelContextWindow, w as GITHUB_COPILOT_PROVIDER, y as reloadConfig } from "./config-store-DeipVulH.js";
2
2
  import { A as resolveMappedModel, C as getModelResponsesApiCompactThreshold$1, D as isContextManagementEnabledForMessages, E as getSmallModelForProvider, O as isContextManagementEnabledForResponses, S as getModelMappings, T as getSmallModel, _ as getModelsDevModelMaxOutputTokens, a as normalizeProviderBaseUrl, d as isProviderModelVisible, f as resolveProviderModelsDevId, g as getModelsDevModel, h as getBuiltinProviderModelRecords, i as listEnabledProviders, j as setModelMappings, k as isGpt56OrAbove, l as getLocalProviderModelRecords, m as builtinProviderModelRegistry, n as getRawProviderConfig, o as resolveEffectiveProviderType, p as usesModelsDevModelCatalog, s as resolveProviderConfigForModel, t as getProviderConfig, u as getProviderModelConfig, v as getModelsDevModelPricing, w as getReasoningEffortForModel, x as getExtraPromptForModel } from "./config-0pYepRvK.js";
3
- import { $ as resolveTraceId$1, C as isOpencodeOauthApp, E as prepareMessageProxyHeaders, G as XAI_API_BASE_URL, J as CODEX_API_BASE_URL, L as getXaiAccessToken, M as compactTextOnlyGuard, N as createAuthMiddleware, O as compactAutoContinuePromptStarts, P as getConfiguredAdminApiKeys, Q as requestContext, S as copilotWebSocketHeaders, T as prepareInteractionHeaders, U as readGitHubToken, W as readGitHubTokenFromEnv, X as forwardCodexResponses, Y as buildCodexRequestHeaders, Z as generateTraceId, _ as parseUserIdMetadata, at as createPooledWebSocketStream, b as copilotHeaders, ct as stripInternalRequestHeaders, d as generateRequestIdFromPayload, et as fetchUpstreamWithLifecycle, f as getRootSessionId, g as isResponsesStream, h as isNullish, it as getResponsesStreamTerminalDisposition, j as compactSystemPromptStarts, k as compactMessageSections, m as isAsyncIterable, n as invalidateCodexRuntime, nt as createResponsesSafeStream, ot as createWebSocketUrl, p as getUUID, rt as encodePoolKeyPart, s as setupCodexToken, tt as createResponsesHttpEventStream, u as stopCopilotRefreshLoop, v as getCopilotUsage, w as prepareForCompact, y as copilotBaseUrl } from "./token-OftpnSxC.js";
3
+ import { $ as requestContext, A as compactMessageSections, C as copilotWebSocketHeaders, D as prepareMessageProxyHeaders, E as prepareInteractionHeaders, F as getConfiguredAdminApiKeys, G as readGitHubTokenFromEnv, K as XAI_API_BASE_URL, M as compactSystemPromptStarts, N as compactTextOnlyGuard, P as createAuthMiddleware, Q as generateTraceId, R as getXaiAccessToken, T as prepareForCompact, W as readGitHubToken, X as buildCodexRequestHeaders, Y as CODEX_API_BASE_URL, Z as forwardCodexResponses, _ as isResponsesStream, at as getResponsesStreamTerminalDisposition, b as copilotBaseUrl, d as generateRequestIdFromPayload, et as resolveTraceId$1, f as getPromptCacheKey, g as isNullish, h as isAsyncIterable, it as encodePoolKeyPart, k as compactAutoContinuePromptStarts, lt as stripInternalRequestHeaders, m as getUUID, n as invalidateCodexRuntime, nt as createResponsesHttpEventStream, ot as createPooledWebSocketStream, p as getRootSessionId, rt as createResponsesSafeStream, s as setupCodexToken, st as createWebSocketUrl, tt as fetchUpstreamWithLifecycle, u as stopCopilotRefreshLoop, v as parseUserIdMetadata, w as isOpencodeOauthApp, x as copilotHeaders, y as getCopilotUsage } from "./token-D4qvx2iT.js";
4
4
  import { a as isDeferredToolName, c as parseMcpToolSearchSentinel, d as shouldEnableResponsesToolSearch, i as isBridgeToolSearchName, l as resolveBridgeToolSearchName, o as listDeferredToolNames, r as formatToolSearchBridgeArguments, s as normalizeToolSearchBridgeArguments, t as BRIDGE_TOOL_SEARCH_NAME, u as selectDeferredToolsByNames } from "./tool-search-CcvaqM03.js";
5
5
  import { n as isProviderAgentModelVisible, t as getProviderAgentModels } from "./provider-management-CLV6-gBT.js";
6
- import { n as stopModelsRefreshLoop, t as setupCopilotRuntime } from "./copilot-runtime-D7uXIiMk.js";
6
+ import { n as stopModelsRefreshLoop, t as setupCopilotRuntime } from "./copilot-runtime-ln18qGOA.js";
7
7
  import consola from "consola";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
9
  import fs, { createWriteStream, readFileSync, rmSync } from "node:fs";
@@ -31,6 +31,7 @@ const traceIdMiddleware = async (c, next) => {
31
31
  startTime: Date.now(),
32
32
  userAgent: c.req.header("user-agent") || "",
33
33
  sessionAffinity: c.req.header("x-opencode-session-id") ?? c.req.header("x-session-affinity") ?? c.req.header("x-client-request-id"),
34
+ rootSessionId: c.req.header("session-id")?.trim() || c.req.header("x-root-session-id")?.trim() || c.req.header("x-session-id")?.trim(),
34
35
  parentSessionId: c.req.header("x-parent-session-id")
35
36
  };
36
37
  await requestContext.run(context, async () => {
@@ -2858,14 +2859,6 @@ const applyDashScopePreserveThinkingDefault = (payload, providerConfig) => {
2858
2859
  if (!isDashScopeAliyunProvider(providerConfig)) return;
2859
2860
  if (!Object.hasOwn(payload, "preserve_thinking")) payload.preserve_thinking = true;
2860
2861
  };
2861
- const normalizeDashScopeAssistantTextContent = (messages) => {
2862
- for (const message of messages) {
2863
- if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
2864
- const textParts = message.content.filter((part) => part.type === "text");
2865
- if (textParts.length === 0 || textParts.length !== message.content.length) continue;
2866
- message.content = textParts.map((part) => part.text).join("");
2867
- }
2868
- };
2869
2862
  const applyOpenAICompatibleContextCache = (payload) => {
2870
2863
  if (payload.model.includes("/")) return;
2871
2864
  if (!payload.model.toLowerCase().includes("qwen")) return;
@@ -4622,9 +4615,7 @@ function translateToOpenAI(payload, options = {}) {
4622
4615
  const model = state.models?.data.find((m) => m.id === modelId);
4623
4616
  const thinkingBudget = getThinkingBudget(payload, model);
4624
4617
  const reasoningEffort = getReasoningEffort(payload, options);
4625
- const { sessionId: metadataPromptCacheKey } = parseUserIdMetadata(payload.metadata?.user_id);
4626
- const sessionAffinity = requestContext.getStore()?.sessionAffinity?.trim() || null;
4627
- const promptCacheKey = metadataPromptCacheKey ?? sessionAffinity;
4618
+ const promptCacheKey = getPromptCacheKey(payload);
4628
4619
  const capabilities = {
4629
4620
  supportPdf: options.supportPdf ?? false,
4630
4621
  toolContentSupportType: options.toolContentSupportType ?? []
@@ -4784,9 +4775,10 @@ function handleAssistantMessage(message, modelId, capabilities) {
4784
4775
  const thinkingContents = thinkingBlocks.filter((b) => b.thinking && b.thinking !== "Thinking...").map((b) => b.thinking);
4785
4776
  const allThinkingContent = thinkingContents.length > 0 ? thinkingContents.join("\n\n") : void 0;
4786
4777
  const signature = thinkingBlocks.find((b) => b.signature)?.signature;
4778
+ const content = normalizeAssistantTextContent(mapContent(message.content, { supportPdf: capabilities.supportPdf }));
4787
4779
  return toolUseBlocks.length > 0 ? [{
4788
4780
  role: "assistant",
4789
- content: mapContent(message.content, { supportPdf: capabilities.supportPdf }),
4781
+ content,
4790
4782
  reasoning_text: allThinkingContent,
4791
4783
  reasoning_opaque: signature,
4792
4784
  tool_calls: toolUseBlocks.map((toolUse) => ({
@@ -4799,11 +4791,20 @@ function handleAssistantMessage(message, modelId, capabilities) {
4799
4791
  }))
4800
4792
  }] : [{
4801
4793
  role: "assistant",
4802
- content: mapContent(message.content, { supportPdf: capabilities.supportPdf }),
4794
+ content,
4803
4795
  reasoning_text: allThinkingContent,
4804
4796
  reasoning_opaque: signature
4805
4797
  }];
4806
4798
  }
4799
+ /**
4800
+ * DashScope-compatible upstreams reject assistant messages whose content is an
4801
+ * array of text parts, so collapse text-only arrays into a plain string here.
4802
+ */
4803
+ function normalizeAssistantTextContent(content) {
4804
+ if (!Array.isArray(content)) return content;
4805
+ const textParts = content.filter((part) => part.type === "text");
4806
+ return textParts.length === content.length ? textParts.map((part) => part.text).join("") : content;
4807
+ }
4807
4808
  function mapContent(content, options = {}) {
4808
4809
  if (typeof content === "string") return content;
4809
4810
  if (!Array.isArray(content)) return null;
@@ -5587,7 +5588,7 @@ const isCodexRateLimitWindow = (value) => {
5587
5588
  return typeof record.reset_after_seconds === "number" && typeof record.reset_at === "number" && typeof record.used_percent === "number" && typeof record.window_minutes === "number";
5588
5589
  };
5589
5590
  //#endregion
5590
- //#region src/routes/messages/stream-translation.ts
5591
+ //#region src/routes/messages/completions-stream-translation.ts
5591
5592
  function isToolBlockOpen(state) {
5592
5593
  if (!state.contentBlockOpen) return false;
5593
5594
  return Object.values(state.toolCalls).some((tc) => tc.anthropicBlockIndex === state.contentBlockIndex);
@@ -5913,13 +5914,7 @@ const COMPACTION_SIGNATURE_SEPARATOR = "@";
5913
5914
  const REASONING_SUMMARY_SEPARATOR = "\xA0\n\n";
5914
5915
  const REASONING_SUMMARY_SEPARATOR_PATTERN = /\u00a0\n\n|\u2063\n\n/;
5915
5916
  const resolveReasoningEffort = (payload) => payload.output_config?.effort ?? getReasoningEffortForModel(payload.model);
5916
- const buildPromptCacheKey = (basePromptCacheKey, subagentAgentId) => {
5917
- if (!basePromptCacheKey) return null;
5918
- const normalizedSubagentAgentId = subagentAgentId?.trim() || null;
5919
- if (!normalizedSubagentAgentId) return basePromptCacheKey;
5920
- return `${basePromptCacheKey}:agent:${normalizedSubagentAgentId}`;
5921
- };
5922
- const translateAnthropicMessagesToResponsesPayload = (payload, subagentAgentId) => {
5917
+ const translateAnthropicMessagesToResponsesPayload = (payload) => {
5923
5918
  const input = [];
5924
5919
  const applyPhase = shouldApplyPhase(payload.model);
5925
5920
  const toolSearchEnabled = shouldEnableResponsesToolSearch({
@@ -5935,9 +5930,7 @@ const translateAnthropicMessagesToResponsesPayload = (payload, subagentAgentId)
5935
5930
  const hasOriginalTools = Array.isArray(payload.tools) && payload.tools.length > 0;
5936
5931
  const translatedTools = convertAnthropicTools(payload.tools, toolSearchEnabled);
5937
5932
  const toolChoice = convertAnthropicToolChoice(payload.tool_choice, toolSearchEnabled);
5938
- const { sessionId: metadataPromptCacheKey } = parseUserIdMetadata(payload.metadata?.user_id);
5939
- const sessionAffinity = requestContext.getStore()?.sessionAffinity?.trim() || null;
5940
- const promptCacheKey = buildPromptCacheKey(metadataPromptCacheKey ?? sessionAffinity, subagentAgentId);
5933
+ const promptCacheKey = getPromptCacheKey(payload);
5941
5934
  const responsesPayload = {
5942
5935
  model: payload.model,
5943
5936
  input,
@@ -7072,16 +7065,16 @@ const MESSAGES_COMPACTION_PROMPT = [
7072
7065
  ].join("\n");
7073
7066
  const MESSAGES_TOOL_CALL_TIPS = [
7074
7067
  "# Tool Call Tips",
7075
- "- Do NOT call `exec_command` directly; that tool does not exist. Use `functions__exec` to run commands instead.",
7076
- "- The functions__exec tool accepts parameters only as {\"input\":\"...\"}; put the complete executable code inside input, including properly constructed tools.exec_command(...) calls and text(...) output handling.",
7068
+ "- Do NOT call `exec_command` directly; that tool does not exist. Use `functions.exec` (tool name: `exec`) to run commands instead.",
7069
+ "- The functions.exec tool accepts parameters only as {\"input\":\"...\"}; put the complete executable code inside input, including properly constructed tools.exec_command(...) calls and text(...) output handling.",
7077
7070
  "- Construct all tools.exec_command(...) arguments strictly according to its tool definition, and use OS/shell-compatible commands for Windows, Linux, and macOS.",
7078
7071
  "- Always assign the awaited tools.exec_command(...) call to a variable and forward the full result with text(JSON.stringify(r)); unforwarded output is silently dropped and makes results look empty.",
7079
- "- Yielded execution is not truncated output. Resume a running `cell_id` with `functions.wait`, and a live `session_id` with `tools.write_stdin`, until the command reaches a terminal result.",
7072
+ "- Yielded execution is not truncated output. Resume a running `cell_id` with `functions.wait` (tool name: `wait`), and a live `session_id` with `tools.write_stdin`, until the command reaches a terminal result.",
7080
7073
  "- Read files with the OS-native command (Get-Content/Test-Path on Windows PowerShell, cat/ls on POSIX), quote paths containing spaces, and verify the forwarded output is non-empty before concluding a file was read.",
7081
7074
  "- For long-running commands, keep the returned `session_id` and poll it with `tools.write_stdin` until the command finishes; do not redirect output to a temp file and read it back in a second call.",
7082
- "- If `functions__exec` returns `aborted`, retry at most 3 times. After 3 failures, terminate immediately and inform the user that `functions__exec` is unavailable."
7075
+ "- If `functions.exec` returns `aborted`, retry at most 3 times. After 3 failures, terminate immediately and inform the user that `functions.exec` is unavailable."
7083
7076
  ].join("\n");
7084
- const MESSAGES_BATCH_TOOL_CALL_TIPS = ["- Parallel tool calls are disabled for this request. Batch independent commands in one functions__exec call; keep dependent operations sequential.", "const results = await Promise.allSettled([tools.exec_command({cmd: \"git status --short\"})]); for (const result of results) text(JSON.stringify(result.status === \"fulfilled\" ? result.value : {error: String(result.reason)}))"].join("\n");
7077
+ const MESSAGES_BATCH_TOOL_CALL_TIPS = ["- Parallel tool calls are disabled for this request. Batch independent commands in one functions.exec call; keep dependent operations sequential.", "const results = await Promise.allSettled([tools.exec_command({cmd: \"git status --short\"})]); for (const result of results) text(JSON.stringify(result.status === \"fulfilled\" ? result.value : {error: String(result.reason)}))"].join("\n");
7085
7078
  const JSON_OUTPUT_CONSTRAINT = "Do not wrap the JSON in markdown code fences and do not add any text outside the JSON object.";
7086
7079
  const buildOutputFormatInstruction = (format) => {
7087
7080
  if (!format) return null;
@@ -7117,8 +7110,9 @@ function translateResponsesToMessages(payload, options) {
7117
7110
  const registry = createToolRegistry(payload, options.model);
7118
7111
  const normalized = normalizeResponsesInput(payload.input);
7119
7112
  const outputFormatInstruction = buildOutputFormatInstruction(payload.text?.format);
7120
- const { messages, system } = translateInputToAnthropic(normalized.input, registry, payload.instructions, payload.input, options.toolCallTips ?? false);
7121
- if (options.toolCallTips && payload.parallel_tool_calls === false) appendToolCallTips(system, MESSAGES_BATCH_TOOL_CALL_TIPS);
7113
+ const toolCallTips = (options.toolCallTips ?? false) && !hasExecCommandTool(payload);
7114
+ const { messages, system } = translateInputToAnthropic(normalized.input, registry, payload.instructions, payload.input, toolCallTips);
7115
+ if (toolCallTips && payload.parallel_tool_calls === false) appendToolCallTips(system, MESSAGES_BATCH_TOOL_CALL_TIPS);
7122
7116
  if (normalized.compaction) messages.push({
7123
7117
  role: "user",
7124
7118
  content: MESSAGES_COMPACTION_PROMPT
@@ -7303,9 +7297,34 @@ function createToolRegistry(payload, model) {
7303
7297
  if (Array.isArray(payload.input)) for (const item of payload.input) {
7304
7298
  if (getItemType(item) !== "additional_tools") continue;
7305
7299
  for (const tool of getArrayField(item, "tools")) registerTool(tool, registry, strictCustomTools);
7300
+ break;
7306
7301
  }
7307
7302
  return registry;
7308
7303
  }
7304
+ const EXEC_COMMAND_TOOL_NAME = "exec_command";
7305
+ /**
7306
+ * Reports whether the request exposes a direct `exec_command` tool, at the top
7307
+ * level, inside a namespace, or through `input.additional_tools`. The
7308
+ * additional_tools items are scanned in place, so no tool list is copied.
7309
+ */
7310
+ function hasExecCommandTool(payload) {
7311
+ if ((payload.tools ?? []).some(isExecCommandTool)) return true;
7312
+ if (!Array.isArray(payload.input)) return false;
7313
+ for (const item of payload.input) {
7314
+ if (getItemType(item) !== "additional_tools") continue;
7315
+ if (getArrayField(item, "tools").some(isExecCommandTool)) return true;
7316
+ break;
7317
+ }
7318
+ return false;
7319
+ }
7320
+ function isExecCommandTool(tool) {
7321
+ if (getStringField$1(tool, "name") === EXEC_COMMAND_TOOL_NAME) return true;
7322
+ if (!isNamespaceTool(tool)) return false;
7323
+ return tool.tools.some(isExecCommandTool);
7324
+ }
7325
+ function isNamespaceTool(tool) {
7326
+ return getStringField$1(tool, "type") === "namespace";
7327
+ }
7309
7328
  function registerTool(tool, registry, strictCustomTools, namespaces = []) {
7310
7329
  if (!isRecord$1(tool)) throw new ResponsesMessagesTranslationError("Invalid Responses tool definition");
7311
7330
  const type = getStringField$1(tool, "type");
@@ -7348,7 +7367,7 @@ function registerMessagesTool(registration, registry, strictCustomTools) {
7348
7367
  function createMessagesToolDescriptor(registration, registry) {
7349
7368
  const originalKey = createOriginalToolKey(registration);
7350
7369
  return {
7351
- alias: createToolAlias(registration.namespace ? `${registration.namespace.replaceAll(".", "_")}__${registration.name}` : registration.name, originalKey, registry),
7370
+ alias: createToolAlias(registration.namespace && registration.namespace !== "functions" ? `${registration.namespace.replaceAll(".", "_")}__${registration.name}` : registration.name, originalKey, registry),
7352
7371
  kind: registration.kind,
7353
7372
  name: registration.name,
7354
7373
  ...registration.namespace ? { namespace: registration.namespace } : {}
@@ -7484,12 +7503,14 @@ function translateInputReasoning(item, messages) {
7484
7503
  }
7485
7504
  function translateInputToolCall(item, kind, messages, registry) {
7486
7505
  if (!isRecord$1(item)) throw new ResponsesMessagesTranslationError("Invalid Responses tool call item");
7506
+ const name = requireStringField(item, "name", `${kind}_tool_call`);
7507
+ const namespace = getOptionalStringField(item, "namespace") ?? void 0;
7487
7508
  const toolIdentity = {
7488
7509
  kind,
7489
- name: requireStringField(item, "name", `${kind}_tool_call`),
7490
- namespace: getOptionalStringField(item, "namespace") ?? void 0
7510
+ name,
7511
+ namespace
7491
7512
  };
7492
- const descriptor = registry.byOriginal.get(createOriginalToolKey(toolIdentity)) ?? createMessagesToolDescriptor(toolIdentity, registry);
7513
+ const descriptor = findOriginalDescriptor(registry, kind, name, namespace) ?? createMessagesToolDescriptor(toolIdentity, registry);
7493
7514
  const input = kind === "custom" ? { input: getStringField$1(item, "input") ?? "" } : parseFunctionArguments(getStringField$1(item, "arguments") ?? "{}", `${kind}_tool_call.arguments`);
7494
7515
  appendAssistantBlock(messages, {
7495
7516
  type: "tool_use",
@@ -7755,16 +7776,15 @@ function parseDataUrl(value) {
7755
7776
  };
7756
7777
  }
7757
7778
  function findOriginalDescriptor(registry, kind, name, namespace) {
7758
- const matches = [];
7759
- for (const descriptor of registry.byOriginal.values()) {
7760
- if (descriptor.kind !== kind || descriptor.name !== name) continue;
7761
- if (namespace !== void 0) {
7762
- if (descriptor.namespace === namespace) return descriptor;
7763
- continue;
7764
- }
7765
- matches.push(descriptor);
7766
- }
7767
- return matches.find((descriptor) => descriptor.namespace === void 0) ?? (matches.length === 1 ? matches[0] : void 0);
7779
+ return registry.byOriginal.get(createOriginalToolKey({
7780
+ kind,
7781
+ name,
7782
+ namespace
7783
+ })) ?? (!namespace ? registry.byOriginal.get(createOriginalToolKey({
7784
+ kind,
7785
+ name,
7786
+ namespace: "functions"
7787
+ })) : void 0);
7768
7788
  }
7769
7789
  function createOriginalToolKey(tool) {
7770
7790
  return [
@@ -8129,7 +8149,7 @@ const prepareWebSearchResponsesPayload = (payload, options = {}) => {
8129
8149
  tools: [],
8130
8150
  stream: true
8131
8151
  };
8132
- const responsesPayload = translateAnthropicMessagesToResponsesPayload(switchedPayload, options.subagentAgentId);
8152
+ const responsesPayload = translateAnthropicMessagesToResponsesPayload(switchedPayload);
8133
8153
  responsesPayload.tools = [buildResponsesWebSearchTool({
8134
8154
  ...config,
8135
8155
  searchContextSize: "low"
@@ -8212,10 +8232,7 @@ const tryHandleWebSearch = async (c, payload, options) => {
8212
8232
  const handleWebSearchViaResponses = async (c, payload, options) => {
8213
8233
  const { logger, webSearchModel } = options;
8214
8234
  const wantsStream = Boolean(payload.stream);
8215
- const responsesPayload = prepareWebSearchResponsesPayload(payload, {
8216
- model: webSearchModel,
8217
- subagentAgentId: options.subagentMarker?.agent_id
8218
- });
8235
+ const responsesPayload = prepareWebSearchResponsesPayload(payload, { model: webSearchModel });
8219
8236
  const selectedModel = findEndpointModel(webSearchModel);
8220
8237
  const { vision, initiator } = getResponsesRequestOptions(responsesPayload);
8221
8238
  const transport = getResponsesTransportForModel(selectedModel, { compactType: options.compactType }) ?? "http";
@@ -9369,7 +9386,6 @@ const createOpenAICompatiblePayload = (payload, modelConfig, providerConfig) =>
9369
9386
  applyMiMoThinking(openAIPayload, payload);
9370
9387
  applyDashScopePreserveThinkingDefault(openAIPayload, providerConfig);
9371
9388
  if (!Object.hasOwn(openAIPayload, "parallel_tool_calls")) openAIPayload.parallel_tool_calls = true;
9372
- if (isDashScopeProvider) normalizeDashScopeAssistantTextContent(openAIPayload.messages);
9373
9389
  if (modelConfig?.contextCache ?? isDashScopeProvider) applyOpenAICompatibleContextCache(openAIPayload);
9374
9390
  return openAIPayload;
9375
9391
  };
@@ -9880,7 +9896,7 @@ const handleWithChatCompletions = async (c, anthropicPayload, options) => {
9880
9896
  };
9881
9897
  const handleWithResponsesApi = async (c, anthropicPayload, options) => {
9882
9898
  const { logger, selectedModel, ...requestOptions } = options;
9883
- const responsesPayload = translateAnthropicMessagesToResponsesPayload(anthropicPayload, requestOptions.subagentMarker?.agent_id);
9899
+ const responsesPayload = translateAnthropicMessagesToResponsesPayload(anthropicPayload);
9884
9900
  const recordUsage = createCopilotUsageRecorder({
9885
9901
  endpoint: options.usageEndpoint ?? "responses",
9886
9902
  fallbackSessionId: requestOptions.sessionId,
@@ -12196,12 +12212,6 @@ const FALLBACK_BASE_INSTRUCTIONS = FALLBACK_CODEX_MODELS.find((model) => model.b
12196
12212
  function isCodexUserAgent(userAgent) {
12197
12213
  return CODEX_USER_AGENT_PATTERN.test(userAgent?.trim() ?? "");
12198
12214
  }
12199
- function isDeepSeekModelId(modelId) {
12200
- return modelId.toLowerCase().includes("deepseek");
12201
- }
12202
- function shouldInjectMessagesToolCallTips(userAgent, targetModel) {
12203
- return isCodexUserAgent(userAgent) && !isDeepSeekModelId(targetModel);
12204
- }
12205
12215
  /**
12206
12216
  * Proxies a models request to the fixed Codex upstream models endpoint.
12207
12217
  * Returns a 404 JSON response when the codex provider is unavailable.
@@ -12323,7 +12333,6 @@ function createSyntheticCodexModel(candidate, template, priority) {
12323
12333
  const defaultReasoningEffort = reasoningEfforts.includes(candidate.defaultReasoningEffort) ? candidate.defaultReasoningEffort : reasoningEfforts[0];
12324
12334
  const supportsReasoning = reasoningEfforts.some((effort) => effort !== "none");
12325
12335
  const inputModalities = [...new Set(candidate.inputModalities)];
12326
- const isDeepSeekModel = isDeepSeekModelId(candidate.slug);
12327
12336
  return {
12328
12337
  ...template,
12329
12338
  slug: candidate.slug,
@@ -12339,11 +12348,11 @@ function createSyntheticCodexModel(candidate, template, priority) {
12339
12348
  apply_patch_tool_type: "freeform",
12340
12349
  web_search_tool_type: "text_and_image",
12341
12350
  supports_search_tool: false,
12342
- use_responses_lite: isDeepSeekModel ? false : true,
12343
- tool_mode: isDeepSeekModel ? null : "code_mode_only",
12351
+ use_responses_lite: true,
12352
+ tool_mode: "code_mode_only",
12344
12353
  multi_agent_version: "v2",
12345
12354
  multi_agent_reasoning_effort: null,
12346
- shell_type: isDeepSeekModel ? "shell_command" : template.shell_type,
12355
+ shell_type: template.shell_type,
12347
12356
  experimental_supported_tools: [],
12348
12357
  input_modalities: inputModalities,
12349
12358
  supports_image_detail_original: false,
@@ -13577,7 +13586,7 @@ async function handleResponsesViaMessages(c, options) {
13577
13586
  }, {
13578
13587
  model: options.targetModel,
13579
13588
  publicModel: options.publicModel,
13580
- toolCallTips: shouldInjectMessagesToolCallTips(c.req.header("user-agent"), options.targetModel)
13589
+ toolCallTips: isCodexUserAgent(c.req.header("user-agent"))
13581
13590
  });
13582
13591
  const context = translation;
13583
13592
  debugJson(logger$3, "Translated Messages request:", {
@@ -14204,4 +14213,4 @@ createServer();
14204
14213
  //#endregion
14205
14214
  export { createServer };
14206
14215
 
14207
- //# sourceMappingURL=server-D8LzQcmu.js.map
14216
+ //# sourceMappingURL=server-pQJNmc1Y.js.map