@nick3/copilot-api 1.6.8 → 1.7.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/dist/main.js CHANGED
@@ -23,7 +23,7 @@ if (typeof args["enterprise-url"] === "string") process.env.COPILOT_API_ENTERPRI
23
23
  const { auth } = await import("./auth-xiepl3lk.js");
24
24
  const { checkUsage } = await import("./check-usage-3sFXqP0F.js");
25
25
  const { debug } = await import("./debug-BJfZVBB7.js");
26
- const { start } = await import("./start-CpNBaRGB.js");
26
+ const { start } = await import("./start-C45MX44a.js");
27
27
  await runMain(defineCommand({
28
28
  meta: {
29
29
  name: "copilot-api",
@@ -675,11 +675,18 @@ const getTokenCount = async (payload, model) => {
675
675
  const COMPACT_REQUEST = 1;
676
676
  const COMPACT_AUTO_CONTINUE = 2;
677
677
  const compactSystemPromptStart = "You are a helpful AI assistant tasked with summarizing conversations";
678
+ const compactOpenCodeSystemPromptStart = "You are an anchored context summarization assistant for coding sessions.";
679
+ const compactSystemPromptStarts = [compactSystemPromptStart, compactOpenCodeSystemPromptStart];
678
680
  const compactTextOnlyGuard = "CRITICAL: Respond with TEXT ONLY. Do NOT call any tools.";
679
681
  const compactSummaryPromptStart = "Your task is to create a detailed summary of the conversation so far";
680
682
  const compactAutoContinueClaudeCodePromptStart = "This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation.";
681
683
  const compactAutoContinueOpenCodePromptStart = "Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed.";
682
- const compactAutoContinuePromptStarts = [compactAutoContinueClaudeCodePromptStart, compactAutoContinueOpenCodePromptStart];
684
+ const compactAutoContinueOpenCodePromptStart2 = "The previous request exceeded the provider's size limit due to large media attachments. The conversation was compacted and media files were removed from context.";
685
+ const compactAutoContinuePromptStarts = [
686
+ compactAutoContinueClaudeCodePromptStart,
687
+ compactAutoContinueOpenCodePromptStart,
688
+ compactAutoContinueOpenCodePromptStart2
689
+ ];
683
690
  const compactMessageSections = ["Pending Tasks:", "Current Work:"];
684
691
 
685
692
  //#endregion
@@ -708,9 +715,9 @@ const getCompactType = (anthropicPayload) => {
708
715
  if (lastMessage && isCompactMessage(lastMessage)) return COMPACT_REQUEST;
709
716
  if (lastMessage && isCompactAutoContinueMessage(lastMessage)) return COMPACT_AUTO_CONTINUE;
710
717
  const system = anthropicPayload.system;
711
- if (typeof system === "string") return system.startsWith(compactSystemPromptStart) ? COMPACT_REQUEST : 0;
718
+ if (typeof system === "string") return compactSystemPromptStarts.some((promptStart) => system.startsWith(promptStart)) ? COMPACT_REQUEST : 0;
712
719
  if (!Array.isArray(system)) return 0;
713
- if (system.some((msg) => typeof msg.text === "string" && msg.text.startsWith(compactSystemPromptStart))) return COMPACT_REQUEST;
720
+ if (system.some((msg) => typeof msg.text === "string" && compactSystemPromptStarts.some((promptStart) => msg.text.startsWith(promptStart)))) return COMPACT_REQUEST;
714
721
  return 0;
715
722
  };
716
723
  const mergeContentWithText = (tr, textBlock) => {
@@ -7034,6 +7041,7 @@ const handleResponses = async (c) => {
7034
7041
  model: selectedModel.id
7035
7042
  };
7036
7043
  useFunctionApplyPatch(upstreamPayload);
7044
+ removeUnsupportedTools(upstreamPayload);
7037
7045
  applyResponsesApiContextManagement(upstreamPayload, selectedModel.capabilities.limits.max_prompt_tokens);
7038
7046
  compactInputByLatestCompaction(upstreamPayload);
7039
7047
  const premiumRemainingBefore = account.premiumRemaining;
@@ -7426,6 +7434,20 @@ async function handleNonStreamingResponses(params) {
7426
7434
  });
7427
7435
  }
7428
7436
  }
7437
+ const COPILOT_UNSUPPORTED_TOOL_TYPES = new Set(["image_generation"]);
7438
+ const removeUnsupportedTools = (payload) => {
7439
+ if (!Array.isArray(payload.tools) || payload.tools.length === 0) return;
7440
+ const dropped = [];
7441
+ payload.tools = payload.tools.filter((t) => {
7442
+ const type = t.type;
7443
+ if (COPILOT_UNSUPPORTED_TOOL_TYPES.has(type)) {
7444
+ dropped.push(type);
7445
+ return false;
7446
+ }
7447
+ return true;
7448
+ });
7449
+ if (dropped.length > 0) logger$1.debug("Removed unsupported tools:", dropped);
7450
+ };
7429
7451
 
7430
7452
  //#endregion
7431
7453
  //#region src/routes/responses/route.ts
@@ -7519,4 +7541,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
7519
7541
 
7520
7542
  //#endregion
7521
7543
  export { server };
7522
- //# sourceMappingURL=server-CiYbUOTL.js.map
7544
+ //# sourceMappingURL=server-D4_KW4V9.js.map