@jeffreycao/copilot-api 2.1.11 → 2.1.13

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
@@ -25,7 +25,7 @@ bindElectronFetch();
25
25
  const { auth } = await import("./auth-PIo0IPSc.js");
26
26
  const { debug } = await import("./debug-ChC85ySp.js");
27
27
  const { mcp } = await import("./mcp-BG6fpi6q.js");
28
- const { start } = await import("./start-DcTeH8wz.js");
28
+ const { start } = await import("./start-CqQngxum.js");
29
29
  await runMain(defineCommand({
30
30
  meta: {
31
31
  name: "copilot-api",
@@ -3724,7 +3724,8 @@ function translateAnthropicToolsToOpenAI(anthropicTools) {
3724
3724
  function: {
3725
3725
  name: tool.name,
3726
3726
  description: tool.description,
3727
- parameters: normalizeToolSchema(tool.input_schema)
3727
+ parameters: normalizeToolSchema(tool.input_schema),
3728
+ ...tool.strict === void 0 ? {} : { strict: tool.strict }
3728
3729
  }
3729
3730
  }));
3730
3731
  }
@@ -5082,7 +5083,7 @@ const convertToolToFunction = (tool) => ({
5082
5083
  type: "function",
5083
5084
  name: tool.name,
5084
5085
  parameters: normalizeToolSchema(tool.input_schema),
5085
- strict: false,
5086
+ strict: tool.strict ?? false,
5086
5087
  ...tool.description ? { description: tool.description } : {}
5087
5088
  });
5088
5089
  const convertDeferredToolToNamespace = (tool) => ({
@@ -5093,7 +5094,7 @@ const convertDeferredToolToNamespace = (tool) => ({
5093
5094
  type: "function",
5094
5095
  name: tool.name,
5095
5096
  parameters: normalizeToolSchema(tool.input_schema),
5096
- strict: false,
5097
+ strict: tool.strict ?? false,
5097
5098
  defer_loading: true,
5098
5099
  ...tool.description ? { description: tool.description } : {}
5099
5100
  }]
@@ -8456,7 +8457,7 @@ var ResponsesMessagesTranslationError = class extends Error {
8456
8457
  }
8457
8458
  };
8458
8459
  function translateResponsesToMessages(payload, options) {
8459
- const registry = createToolRegistry(payload);
8460
+ const registry = createToolRegistry(payload, options.provider);
8460
8461
  const normalized = normalizeResponsesInput(payload.input);
8461
8462
  const { messages, system } = translateInputToAnthropic(normalized.input, registry, payload.instructions, payload.input);
8462
8463
  if (normalized.compaction) messages.push({
@@ -8609,10 +8610,11 @@ function normalizeResponsesInput(input) {
8609
8610
  }, ...withoutTrigger.slice(latestCompactionIndex + 1)]
8610
8611
  };
8611
8612
  }
8612
- function createToolRegistry(payload) {
8613
+ function createToolRegistry(payload, provider) {
8613
8614
  const registry = {
8614
8615
  byAlias: /* @__PURE__ */ new Map(),
8615
8616
  byOriginal: /* @__PURE__ */ new Map(),
8617
+ provider,
8616
8618
  tools: []
8617
8619
  };
8618
8620
  for (const tool of payload.tools ?? []) registerTool(tool, registry);
@@ -8662,7 +8664,8 @@ function registerMessagesTool(registration, registry) {
8662
8664
  input_schema: registration.kind === "custom" ? CUSTOM_TOOL_INPUT_SCHEMA : registration.parameters ?? {
8663
8665
  type: "object",
8664
8666
  properties: {}
8665
- }
8667
+ },
8668
+ ...registration.kind === "custom" && registry.provider !== "kimi" ? { strict: true } : {}
8666
8669
  });
8667
8670
  return descriptor;
8668
8671
  }
@@ -9923,6 +9926,7 @@ async function handleResponsesViaMessages(c, options) {
9923
9926
  model: options.publicModel
9924
9927
  }, {
9925
9928
  model: options.targetModel,
9929
+ provider: options.provider,
9926
9930
  publicModel: options.publicModel
9927
9931
  });
9928
9932
  const context = translation;
@@ -9998,6 +10002,7 @@ async function handleProviderResponsesForProvider(c, options) {
9998
10002
  normalizeProviderResponsesReasoningEffort(payload, providerConfig);
9999
10003
  if (shouldFallbackToMessages$1(c, payload.model, effectiveType)) return await handleResponsesViaMessages(c, {
10000
10004
  payload,
10005
+ provider: providerConfig.name,
10001
10006
  publicModel: options.publicModel ?? payload.model,
10002
10007
  targetModel: `${provider}/${payload.model}`
10003
10008
  });
@@ -10039,7 +10044,7 @@ async function handleProviderResponsesForProvider(c, options) {
10039
10044
  }
10040
10045
  const shouldFallbackToMessages$1 = (c, modelId, effectiveType) => {
10041
10046
  if (effectiveType === "anthropic" || effectiveType === "openai-compatible") return true;
10042
- if (isCodexUserAgent(c.req.header("user-agent"))) return !modelId.startsWith("gpt");
10047
+ if (isCodexUserAgent(c.req.header("user-agent"))) return !(modelId.startsWith("gpt") || modelId.startsWith("codex"));
10043
10048
  return false;
10044
10049
  };
10045
10050
  const createProviderResponsesUsageRecorder = (payload, provider, modelConfig, pricingCurrency) => {
@@ -10296,7 +10301,7 @@ const handleResponses = async (c) => {
10296
10301
  };
10297
10302
  const isStreamingRequested = (payload) => Boolean(payload.stream);
10298
10303
  const shouldFallbackToMessages = (c, modelId, selectedModel, responsesTransport) => {
10299
- if (isCodexUserAgent(c.req.header("user-agent"))) return !modelId.startsWith("gpt");
10304
+ if (isCodexUserAgent(c.req.header("user-agent"))) return !(modelId.startsWith("gpt") || modelId.startsWith("codex"));
10300
10305
  if (responsesTransport) return false;
10301
10306
  const supportedEndpoints = selectedModel?.supported_endpoints ?? [];
10302
10307
  return supportedEndpoints.includes("/v1/messages") || supportedEndpoints.includes("/chat/completions");
@@ -10497,4 +10502,4 @@ server.route("/:provider/images", providerImageRoutes);
10497
10502
  //#endregion
10498
10503
  export { server };
10499
10504
 
10500
- //# sourceMappingURL=server-tlEQmO0Y.js.map
10505
+ //# sourceMappingURL=server-DwyuQV3u.js.map