@jeffreycao/copilot-api 2.1.13 → 2.2.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/README.md +3 -2
- package/README.zh-CN.md +3 -2
- package/dist/main.js +1 -1
- package/dist/{server-DwyuQV3u.js → server-DN95QRWA.js} +30 -6
- package/dist/server-DN95QRWA.js.map +1 -0
- package/dist/{start-CqQngxum.js → start-BL3AiN3r.js} +5 -3
- package/dist/{start-CqQngxum.js.map → start-BL3AiN3r.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-DwyuQV3u.js.map +0 -1
package/README.md
CHANGED
|
@@ -278,10 +278,11 @@ Here is an example `.claude/settings.json` file:
|
|
|
278
278
|
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
|
|
279
279
|
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
|
|
280
280
|
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
|
|
281
|
-
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off"
|
|
281
|
+
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off",
|
|
282
|
+
"CLAUDE_CODE_EFFORT_LEVEL": "max",
|
|
283
|
+
"MCP_CONNECT_TIMEOUT_MS": "20000"
|
|
282
284
|
},
|
|
283
285
|
"alwaysThinkingEnabled": true,
|
|
284
|
-
"effortLevel": "xhigh",
|
|
285
286
|
"showThinkingSummaries": true
|
|
286
287
|
}
|
|
287
288
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -302,10 +302,11 @@ npx @jeffreycao/copilot-api@latest start --claude-code
|
|
|
302
302
|
"CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION": "false",
|
|
303
303
|
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "true",
|
|
304
304
|
"CLAUDE_CODE_ENABLE_AWAY_SUMMARY": "0",
|
|
305
|
-
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off"
|
|
305
|
+
"CLAUDE_CODE_TOTAL_TOKENS_REMINDER": "off",
|
|
306
|
+
"CLAUDE_CODE_EFFORT_LEVEL": "max",
|
|
307
|
+
"MCP_CONNECT_TIMEOUT_MS": "20000"
|
|
306
308
|
},
|
|
307
309
|
"alwaysThinkingEnabled": true,
|
|
308
|
-
"effortLevel": "xhigh",
|
|
309
310
|
"showThinkingSummaries": true
|
|
310
311
|
}
|
|
311
312
|
```
|
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-
|
|
28
|
+
const { start } = await import("./start-BL3AiN3r.js");
|
|
29
29
|
await runMain(defineCommand({
|
|
30
30
|
meta: {
|
|
31
31
|
name: "copilot-api",
|
|
@@ -3513,7 +3513,7 @@ function translateToOpenAI(payload, options = {}) {
|
|
|
3513
3513
|
supportPdf: options.supportPdf ?? false,
|
|
3514
3514
|
toolContentSupportType: options.toolContentSupportType ?? COPILOT_TOOL_CONTENT_SUPPORT_TYPE
|
|
3515
3515
|
}),
|
|
3516
|
-
|
|
3516
|
+
max_completion_tokens: payload.max_tokens,
|
|
3517
3517
|
stop: payload.stop_sequences,
|
|
3518
3518
|
stream: payload.stream,
|
|
3519
3519
|
temperature: payload.temperature,
|
|
@@ -3548,7 +3548,11 @@ function getThinkingBudget(payload, model) {
|
|
|
3548
3548
|
}
|
|
3549
3549
|
function translateAnthropicMessagesToOpenAI(payload, modelId, capabilities) {
|
|
3550
3550
|
const systemMessages = handleSystemPrompt(payload.system);
|
|
3551
|
-
const otherMessages = payload.messages.flatMap((message) =>
|
|
3551
|
+
const otherMessages = payload.messages.flatMap((message) => {
|
|
3552
|
+
if (message.role === "user") return handleUserMessage(message, capabilities);
|
|
3553
|
+
if (message.role === "system") return [handleInlineSystemMessage(message)];
|
|
3554
|
+
return handleAssistantMessage(message, modelId, capabilities);
|
|
3555
|
+
});
|
|
3552
3556
|
return [...systemMessages, ...otherMessages];
|
|
3553
3557
|
}
|
|
3554
3558
|
function handleSystemPrompt(system) {
|
|
@@ -3564,6 +3568,12 @@ function handleSystemPrompt(system) {
|
|
|
3564
3568
|
}).join("\n\n")
|
|
3565
3569
|
}];
|
|
3566
3570
|
}
|
|
3571
|
+
function handleInlineSystemMessage(message) {
|
|
3572
|
+
return {
|
|
3573
|
+
role: "user",
|
|
3574
|
+
content: mapContent(message.content)
|
|
3575
|
+
};
|
|
3576
|
+
}
|
|
3567
3577
|
function handleUserMessage(message, capabilities) {
|
|
3568
3578
|
const newMessages = [];
|
|
3569
3579
|
if (Array.isArray(message.content)) {
|
|
@@ -3857,9 +3867,16 @@ const normalizeSystemStringForMerge = (text) => {
|
|
|
3857
3867
|
};
|
|
3858
3868
|
const normalizeSystemContentForMerge = (content) => {
|
|
3859
3869
|
if (typeof content === "string") return normalizeSystemStringForMerge(content);
|
|
3860
|
-
return content.
|
|
3861
|
-
|
|
3862
|
-
|
|
3870
|
+
return content.flatMap((block) => {
|
|
3871
|
+
const normalized = normalizeSystemStringForMerge(block.text);
|
|
3872
|
+
if (typeof normalized === "string") return [{
|
|
3873
|
+
...block,
|
|
3874
|
+
text: normalized
|
|
3875
|
+
}];
|
|
3876
|
+
return normalized.map((normalizedBlock, index) => index === normalized.length - 1 ? {
|
|
3877
|
+
...block,
|
|
3878
|
+
text: normalizedBlock.text
|
|
3879
|
+
} : normalizedBlock);
|
|
3863
3880
|
});
|
|
3864
3881
|
};
|
|
3865
3882
|
const toSystemTextBlocks = (content) => {
|
|
@@ -3907,6 +3924,7 @@ const normalizeClaudeCodeBillingHeaderInSystem = (payload) => {
|
|
|
3907
3924
|
};
|
|
3908
3925
|
const normalizeSystemMessages = (payload) => {
|
|
3909
3926
|
normalizeClaudeCodeBillingHeaderInSystem(payload);
|
|
3927
|
+
if (payload.model.startsWith("gpt") || payload.model.startsWith("codex")) return;
|
|
3910
3928
|
if (!payload.messages.some((msg) => msg.role === "system")) return;
|
|
3911
3929
|
const normalizedMessages = [];
|
|
3912
3930
|
let system = payload.system;
|
|
@@ -4799,8 +4817,14 @@ const decodeCompactionCarrierSignature = (signature) => {
|
|
|
4799
4817
|
};
|
|
4800
4818
|
const translateMessage = (message, model, applyPhase, state) => {
|
|
4801
4819
|
if (message.role === "user") return translateUserMessage(message, state);
|
|
4820
|
+
if (message.role === "system") return translateSystemMessage(message);
|
|
4802
4821
|
return translateAssistantMessage(message, model, applyPhase, state);
|
|
4803
4822
|
};
|
|
4823
|
+
const translateSystemMessage = (message) => {
|
|
4824
|
+
if (typeof message.content === "string") return [createMessage("developer", message.content)];
|
|
4825
|
+
const content = message.content.map((block) => createTextContent(block.text));
|
|
4826
|
+
return content.length > 0 ? [createMessage("developer", content)] : [];
|
|
4827
|
+
};
|
|
4804
4828
|
const translateUserMessage = (message, state) => {
|
|
4805
4829
|
if (typeof message.content === "string") return [createMessage("user", message.content)];
|
|
4806
4830
|
if (!Array.isArray(message.content)) return [];
|
|
@@ -10502,4 +10526,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
10502
10526
|
//#endregion
|
|
10503
10527
|
export { server };
|
|
10504
10528
|
|
|
10505
|
-
//# sourceMappingURL=server-
|
|
10529
|
+
//# sourceMappingURL=server-DN95QRWA.js.map
|