@nick3/copilot-api 1.10.7 → 1.10.8

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.
@@ -3,7 +3,7 @@ import { a as getAccountClientIdentityByLoginAndApp, b as getCurrentIdentityEnvi
3
3
  import { r as ensurePaths, t as PATHS } from "./paths-CclKwouX.js";
4
4
  import { i as getRequestOutboundStore, r as getRedactedHeaderKeys } from "./request-outbound-Pu1kp2x8.js";
5
5
  import { a as isDeferredToolName, c as parseMcpToolSearchSentinel, i as isBridgeToolSearchName, l as selectDeferredToolsByNames, o as listDeferredToolNames, r as formatToolSearchBridgeArguments, s as normalizeToolSearchBridgeArguments, t as BRIDGE_TOOL_SEARCH_NAME, u as shouldEnableResponsesToolSearch } from "./tool-search-BrN7M0Dd.js";
6
- import { A as getModelRefreshIntervalMs, B as isResponsesApiWebSocketEnabled, C as getAnthropicApiKey, D as getLogLevel, E as getExtraPromptForModel, F as isForceAgentEnabled, H as resolveModelAlias, I as isMessageStartInputTokensFallbackEnabled, L as isMessagesApiEnabled, M as getReasoningEffortForModel, N as getSmallModel, O as getModelAliases, P as isAccountAffinityEnabled, R as isResponsesApiContextManagementModel, S as getAliasTargetSet, T as getConfig, U as shouldCompactUseSmallModel, V as mergeConfigWithDefaults, _ as toLocalDateString, b as isDevModeEnabled, c as applySharedSessionAffinityRetention, d as getClientIpInfo, f as getRequestHistoryStore, g as normalizeMessagesUsage, h as normalizeEmbeddingsUsage, j as getProviderConfig, k as getModelAliasesInfo, l as extractResponsesUsageFromResult, m as normalizeChatCompletionsUsage, o as updateQuotaRefreshSchedulerFromConfig, p as getStatsStore, s as accountsManager, t as getProxyEnvDispatcher, u as extractResponsesUsageFromStreamEvent, v as copilotFetch, w as getClaudeTokenMultiplier, x as PROVIDER_TYPE_ANTHROPIC, y as flushPendingCapture, z as isResponsesApiWebSearchEnabled } from "./proxy-YVh74m0I.js";
6
+ import { A as getModelRefreshIntervalMs, B as isResponsesApiWebSocketEnabled, C as getAnthropicApiKey, D as getLogLevel, E as getExtraPromptForModel, F as isForceAgentEnabled, H as resolveModelAlias, I as isMessageStartInputTokensFallbackEnabled, L as isMessagesApiEnabled, M as getReasoningEffortForModel, N as getSmallModel, O as getModelAliases, P as isAccountAffinityEnabled, R as isResponsesApiContextManagementModel, S as getAliasTargetSet, T as getConfig, U as shouldCompactUseSmallModel, V as mergeConfigWithDefaults, _ as toLocalDateString, b as isDevModeEnabled, c as applySharedSessionAffinityRetention, d as getClientIpInfo, f as getRequestHistoryStore, g as normalizeMessagesUsage, h as normalizeEmbeddingsUsage, j as getProviderConfig, k as getModelAliasesInfo, l as extractResponsesUsageFromResult, m as normalizeChatCompletionsUsage, o as updateQuotaRefreshSchedulerFromConfig, p as getStatsStore, s as accountsManager, t as getProxyEnvDispatcher, u as extractResponsesUsageFromStreamEvent, v as copilotFetch, w as getClaudeTokenMultiplier, x as PROVIDER_TYPE_ANTHROPIC, y as flushPendingCapture, z as isResponsesApiWebSearchEnabled } from "./proxy-_U-hgwIn.js";
7
7
  import consola from "consola";
8
8
  import fs, { readFile } from "node:fs/promises";
9
9
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
@@ -748,7 +748,7 @@ const mergeContentWithText = (tr, textBlock) => {
748
748
  if (hasToolRef(tr)) return tr;
749
749
  return {
750
750
  ...tr,
751
- content: [...tr.content, textBlock]
751
+ content: [...tr.content, stripContentBlockCacheControl(textBlock)]
752
752
  };
753
753
  };
754
754
  const mergeContentWithTexts = (tr, textBlocks) => {
@@ -762,22 +762,29 @@ const mergeContentWithTexts = (tr, textBlocks) => {
762
762
  if (hasToolRef(tr)) return tr;
763
763
  return {
764
764
  ...tr,
765
- content: [...tr.content, ...textBlocks]
765
+ content: [...tr.content, ...textBlocks.map(stripContentBlockCacheControl)]
766
766
  };
767
767
  };
768
768
  const mergeContentWithAttachments = (tr, attachments) => {
769
+ const cleanAttachments = attachments.map(stripContentBlockCacheControl);
769
770
  if (typeof tr.content === "string") return {
770
771
  ...tr,
771
772
  content: [{
772
773
  type: "text",
773
774
  text: tr.content
774
- }, ...attachments]
775
+ }, ...cleanAttachments]
775
776
  };
776
777
  return {
777
778
  ...tr,
778
- content: [...tr.content, ...attachments]
779
+ content: [...tr.content, ...cleanAttachments]
779
780
  };
780
781
  };
782
+ const stripContentBlockCacheControl = (block) => {
783
+ if (!Object.hasOwn(block, "cache_control")) return block;
784
+ const copy = { ...block };
785
+ delete copy.cache_control;
786
+ return copy;
787
+ };
781
788
  const isAttachmentBlock = (block) => {
782
789
  return block.type === "image" || block.type === "document";
783
790
  };
@@ -1769,7 +1776,6 @@ const CONFIG_KEYS = new Set([
1769
1776
  "modelReasoningEfforts",
1770
1777
  "modelAliases",
1771
1778
  "allowOriginalModelNamesForAliases",
1772
- "useFunctionApplyPatch",
1773
1779
  "forceAgent",
1774
1780
  "compactUseSmallModel",
1775
1781
  "messageStartInputTokensFallback",
@@ -2261,7 +2267,6 @@ const CONFIG_PATCH_HANDLERS = {
2261
2267
  modelReasoningEfforts: applyReasoningEfforts,
2262
2268
  modelAliases: applyModelAliases,
2263
2269
  allowOriginalModelNamesForAliases: (next, value) => applyOptionalBoolean(next, "allowOriginalModelNamesForAliases", value),
2264
- useFunctionApplyPatch: (next, value) => applyOptionalBoolean(next, "useFunctionApplyPatch", value),
2265
2270
  forceAgent: (next, value) => applyOptionalBoolean(next, "forceAgent", value),
2266
2271
  compactUseSmallModel: (next, value) => applyOptionalBoolean(next, "compactUseSmallModel", value),
2267
2272
  messageStartInputTokensFallback: (next, value) => applyOptionalBoolean(next, "messageStartInputTokensFallback", value),
@@ -6997,29 +7002,6 @@ const getPayloadItems = (payload) => {
6997
7002
  if (Array.isArray(input)) result.push(...input);
6998
7003
  return result;
6999
7004
  };
7000
- const useFunctionApplyPatch = (payload) => {
7001
- if (!(getConfig().useFunctionApplyPatch ?? true)) return;
7002
- if (Array.isArray(payload.tools)) {
7003
- const toolsArr = payload.tools;
7004
- for (let i = 0; i < toolsArr.length; i++) {
7005
- const t = toolsArr[i];
7006
- if (t.type === "custom" && t.name === "apply_patch") toolsArr[i] = {
7007
- type: "function",
7008
- name: t.name,
7009
- description: "Use the `apply_patch` tool to edit files",
7010
- parameters: {
7011
- type: "object",
7012
- properties: { input: {
7013
- type: "string",
7014
- description: "The entire contents of the apply_patch command"
7015
- } },
7016
- required: ["input"]
7017
- },
7018
- strict: false
7019
- };
7020
- }
7021
- }
7022
- };
7023
7005
  const removeWebSearchTool = (payload) => {
7024
7006
  if (!Array.isArray(payload.tools) || payload.tools.length === 0) return;
7025
7007
  payload.tools = payload.tools.filter((t) => {
@@ -8419,7 +8401,6 @@ const handleResponses = async (c) => {
8419
8401
  ...payload,
8420
8402
  model: selectedModel.id
8421
8403
  };
8422
- useFunctionApplyPatch(upstreamPayload);
8423
8404
  removeUnsupportedTools(upstreamPayload);
8424
8405
  applyResponsesApiContextManagement(upstreamPayload, selectedModel.capabilities.limits.max_prompt_tokens);
8425
8406
  compactInputByLatestCompaction(upstreamPayload);
@@ -8927,4 +8908,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
8927
8908
  //#endregion
8928
8909
  export { server };
8929
8910
 
8930
- //# sourceMappingURL=server-DmDAepfa.js.map
8911
+ //# sourceMappingURL=server-DulP9mYd.js.map