@jeffreycao/copilot-api 2.2.9 → 2.2.11

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
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
30
30
  const { auth } = await import("./auth-C-RWNXGU.js");
31
31
  const { debug } = await import("./debug-41w6Whae.js");
32
32
  const { mcp } = await import("./mcp-fpSlKZxK.js");
33
- const { start } = await import("./start-BwRZWHAE.js");
33
+ const { start } = await import("./start-DmLlG7PU.js");
34
34
  await runMain(defineCommand({
35
35
  meta: {
36
36
  name: "copilot-api",
@@ -576,9 +576,19 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
576
576
  inputModalities: ["text"],
577
577
  maxOutputTokens: 64e3,
578
578
  pricing: {
579
- cachedInput: .02,
580
- input: 1,
581
- output: 2
579
+ cachedInput: .1,
580
+ input: 3,
581
+ output: 9
582
+ }
583
+ },
584
+ "deepseek-v4-flash-vision-exp": {
585
+ contextWindow: 1e6,
586
+ inputModalities: ["text", "image"],
587
+ maxOutputTokens: 64e3,
588
+ pricing: {
589
+ cachedInput: .1,
590
+ input: 3,
591
+ output: 9
582
592
  }
583
593
  },
584
594
  "deepseek-v4-pro": {
@@ -586,9 +596,9 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
586
596
  inputModalities: ["text"],
587
597
  maxOutputTokens: 64e3,
588
598
  pricing: {
589
- cachedInput: .025,
590
- input: 3,
591
- output: 6
599
+ cachedInput: .3,
600
+ input: 9,
601
+ output: 27
592
602
  }
593
603
  }
594
604
  },
@@ -661,19 +671,34 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
661
671
  inputModalities: ["text"],
662
672
  maxOutputTokens: 64e3,
663
673
  pricing: {
664
- cachedInput: .0028,
665
- input: .14,
666
- output: .28
674
+ cachedInput: .007,
675
+ input: .22,
676
+ output: .66
667
677
  }
668
678
  },
679
+ "deepseek-v4-flash-vision-exp": {
680
+ contextWindow: 1e6,
681
+ inputModalities: ["text", "image"],
682
+ maxOutputTokens: 384e3,
683
+ pricing: {
684
+ cachedInput: .007,
685
+ input: .22,
686
+ output: .66
687
+ },
688
+ reasoningEfforts: [
689
+ "low",
690
+ "high",
691
+ "max"
692
+ ]
693
+ },
669
694
  "deepseek-v4-pro": {
670
695
  contextWindow: 1e6,
671
696
  inputModalities: ["text"],
672
697
  maxOutputTokens: 64e3,
673
698
  pricing: {
674
- cachedInput: .0145,
675
- input: 1.74,
676
- output: 3.48
699
+ cachedInput: .022,
700
+ input: .66,
701
+ output: 1.98
677
702
  }
678
703
  },
679
704
  "kimi-k2.7-code": {
@@ -781,6 +806,21 @@ const builtinProviderModelRegistry = new class BuiltinProviderModelRegistry {
781
806
  maxInputTokens: 512e3,
782
807
  output: 2.4
783
808
  }] }
809
+ },
810
+ "ox-alpha-free": {
811
+ contextWindow: 1e6,
812
+ inputModalities: ["text", "image"],
813
+ maxOutputTokens: 131072,
814
+ pricing: {
815
+ cachedInput: 0,
816
+ input: 0,
817
+ output: 0
818
+ },
819
+ reasoningEfforts: [
820
+ "low",
821
+ "high",
822
+ "max"
823
+ ]
784
824
  }
785
825
  },
786
826
  kimi: {
@@ -2858,6 +2898,7 @@ const applyDashScopePreserveThinkingDefault = (payload, providerConfig) => {
2858
2898
  if (!Object.hasOwn(payload, "preserve_thinking")) payload.preserve_thinking = true;
2859
2899
  };
2860
2900
  const applyOpenAICompatibleContextCache = (payload) => {
2901
+ if (payload.model.includes("/")) return;
2861
2902
  const messageIndexes = selectContextCacheMessageIndexes(payload.messages);
2862
2903
  for (const messageIndex of messageIndexes) applyContextCacheControl(payload.messages[messageIndex]);
2863
2904
  };
@@ -8439,6 +8480,14 @@ const MESSAGES_COMPACTION_PROMPT = [
8439
8480
  "",
8440
8481
  compactTextOnlyGuard
8441
8482
  ].join("\n");
8483
+ const MESSAGES_TOOL_CALL_TIPS = [
8484
+ "# Tool Call Tips",
8485
+ "- Do NOT call `exec_command` directly; that tool does not exist. Use `functions__exec` to run commands instead.",
8486
+ "- 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.",
8487
+ "- Construct all tools.exec_command(...) arguments strictly according to its tool definition, and use OS/shell-compatible commands for Windows, Linux, and macOS.",
8488
+ "- Always assign the awaited tools.exec_command(...) call to a variable, then forward its output with text(result.output) and inspect result.exit_code; unforwarded output is silently dropped and makes results look empty.",
8489
+ "- 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."
8490
+ ].join("\n");
8442
8491
  const COMPACTION_REPLAY_PROMPT = "The previous conversation was compacted. Continue from this handoff summary:\n\n";
8443
8492
  const MAX_DEVELOPER_PROMPTS = 5;
8444
8493
  const TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/u;
@@ -8459,7 +8508,7 @@ var ResponsesMessagesTranslationError = class extends Error {
8459
8508
  function translateResponsesToMessages(payload, options) {
8460
8509
  const registry = createToolRegistry(payload);
8461
8510
  const normalized = normalizeResponsesInput(payload.input);
8462
- const { messages, system } = translateInputToAnthropic(normalized.input, registry, payload.instructions, payload.input);
8511
+ const { messages, system } = translateInputToAnthropic(normalized.input, registry, payload.instructions, payload.input, options.toolCallTips ?? false);
8463
8512
  if (normalized.compaction) messages.push({
8464
8513
  role: "user",
8465
8514
  content: MESSAGES_COMPACTION_PROMPT
@@ -8668,7 +8717,7 @@ function registerMessagesTool(registration, registry) {
8668
8717
  });
8669
8718
  return descriptor;
8670
8719
  }
8671
- function translateInputToAnthropic(input, registry, instructions, originalInput) {
8720
+ function translateInputToAnthropic(input, registry, instructions, originalInput, toolCallTips) {
8672
8721
  const messages = [];
8673
8722
  const system = [];
8674
8723
  if (instructions?.trim()) system.push({
@@ -8676,20 +8725,29 @@ function translateInputToAnthropic(input, registry, instructions, originalInput)
8676
8725
  text: instructions
8677
8726
  });
8678
8727
  appendDeveloperPrompts(system, originalInput);
8679
- if (typeof input === "string") {
8680
- messages.push({
8681
- role: "user",
8682
- content: input
8683
- });
8684
- return {
8685
- messages,
8686
- system
8687
- };
8688
- }
8689
- if (!Array.isArray(input)) return {
8728
+ if (typeof input === "string") messages.push({
8729
+ role: "user",
8730
+ content: input
8731
+ });
8732
+ else if (Array.isArray(input)) translateInputItems(input, messages, system, registry);
8733
+ if (toolCallTips) appendToolCallTips(system);
8734
+ return {
8690
8735
  messages,
8691
8736
  system
8692
8737
  };
8738
+ }
8739
+ function appendToolCallTips(system) {
8740
+ const lastSystemBlock = system.at(-1);
8741
+ if (!lastSystemBlock) {
8742
+ system.push({
8743
+ type: "text",
8744
+ text: MESSAGES_TOOL_CALL_TIPS
8745
+ });
8746
+ return;
8747
+ }
8748
+ lastSystemBlock.text = `${lastSystemBlock.text}\n\n${MESSAGES_TOOL_CALL_TIPS}`;
8749
+ }
8750
+ function translateInputItems(input, messages, system, registry) {
8693
8751
  let userMessageSeen = false;
8694
8752
  for (const item of input) {
8695
8753
  const type = getItemType(item);
@@ -8725,10 +8783,6 @@ function translateInputToAnthropic(input, registry, instructions, originalInput)
8725
8783
  default: throw new ResponsesMessagesTranslationError(`Responses Messages fallback does not support input item type '${type}'`);
8726
8784
  }
8727
8785
  }
8728
- return {
8729
- messages,
8730
- system
8731
- };
8732
8786
  }
8733
8787
  function translateInputMessage(item, messages, system, userMessageSeen) {
8734
8788
  if (!isRecord(item)) throw new ResponsesMessagesTranslationError("Invalid Responses message item");
@@ -9937,13 +9991,15 @@ async function handleResponsesViaMessages(c, options) {
9937
9991
  model: options.publicModel
9938
9992
  }, {
9939
9993
  model: options.targetModel,
9940
- publicModel: options.publicModel
9994
+ publicModel: options.publicModel,
9995
+ toolCallTips: isCodexUserAgent(c.req.header("user-agent"))
9941
9996
  });
9942
9997
  const context = translation;
9943
9998
  debugJson(logger$3, "Translated Messages request:", {
9944
9999
  payload: translation.messagesPayload,
9945
10000
  publicModel: options.publicModel,
9946
- targetModel: options.targetModel
10001
+ targetModel: options.targetModel,
10002
+ userAgent: c.req.header("user-agent") ?? ""
9947
10003
  });
9948
10004
  const messagesResponse = await responsesMessagesDependencies.handleCompletionPayload(c, translation.messagesPayload, {
9949
10005
  compactType: translation.compaction ? 1 : void 0,
@@ -10513,4 +10569,4 @@ server.route("/:provider/images", providerImageRoutes);
10513
10569
  //#endregion
10514
10570
  export { server };
10515
10571
 
10516
- //# sourceMappingURL=server-xe8QDEN1.js.map
10572
+ //# sourceMappingURL=server-D_qrybxD.js.map