@jeffreycao/copilot-api 1.5.0 → 1.5.2
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 +1 -1
- package/dist/{server-DQ2PWnIi.js → server-219WLjAn.js} +18 -4
- package/dist/server-219WLjAn.js.map +1 -0
- package/dist/{start-DJvtSWSc.js → start-CjkReUy2.js} +2 -2
- package/dist/{start-DJvtSWSc.js.map → start-CjkReUy2.js.map} +1 -1
- package/package.json +2 -2
- package/dist/server-DQ2PWnIi.js.map +0 -1
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-8Vdh4fwv.js");
|
|
24
24
|
const { checkUsage } = await import("./check-usage-CTKVSdaJ.js");
|
|
25
25
|
const { debug } = await import("./debug-DcC7ZPH0.js");
|
|
26
|
-
const { start } = await import("./start-
|
|
26
|
+
const { start } = await import("./start-CjkReUy2.js");
|
|
27
27
|
const main = defineCommand({
|
|
28
28
|
meta: {
|
|
29
29
|
name: "copilot-api",
|
|
@@ -937,7 +937,7 @@ const translateAnthropicMessagesToResponsesPayload = (payload) => {
|
|
|
937
937
|
for (const message of payload.messages) input.push(...translateMessage(message, payload.model, applyPhase));
|
|
938
938
|
const translatedTools = convertAnthropicTools(payload.tools);
|
|
939
939
|
const toolChoice = convertAnthropicToolChoice(payload.tool_choice);
|
|
940
|
-
const {
|
|
940
|
+
const { sessionId: promptCacheKey } = parseUserIdMetadata(payload.metadata?.user_id);
|
|
941
941
|
return {
|
|
942
942
|
model: payload.model,
|
|
943
943
|
input,
|
|
@@ -948,7 +948,6 @@ const translateAnthropicMessagesToResponsesPayload = (payload) => {
|
|
|
948
948
|
tools: translatedTools,
|
|
949
949
|
tool_choice: toolChoice,
|
|
950
950
|
metadata: payload.metadata ? { ...payload.metadata } : null,
|
|
951
|
-
safety_identifier: safetyIdentifier,
|
|
952
951
|
prompt_cache_key: promptCacheKey,
|
|
953
952
|
stream: payload.stream ?? null,
|
|
954
953
|
store: false,
|
|
@@ -1140,7 +1139,7 @@ const translateSystemPrompt = (system, model) => {
|
|
|
1140
1139
|
const extraPrompt = getExtraPromptForModel(model);
|
|
1141
1140
|
if (typeof system === "string") return system + extraPrompt;
|
|
1142
1141
|
const text = system.map((block, index) => {
|
|
1143
|
-
if (index === 0) return block.text + extraPrompt;
|
|
1142
|
+
if (index === 0) return block.text + "\n\n" + extraPrompt + "\n\n";
|
|
1144
1143
|
return block.text;
|
|
1145
1144
|
}).join(" ");
|
|
1146
1145
|
return text.length > 0 ? text : null;
|
|
@@ -2182,6 +2181,9 @@ const parseSubagentMarkerFromSystemReminder = (text) => {
|
|
|
2182
2181
|
//#region src/routes/messages/handler.ts
|
|
2183
2182
|
const logger$5 = createHandlerLogger("messages-handler");
|
|
2184
2183
|
const compactSystemPromptStart = "You are a helpful AI assistant tasked with summarizing conversations";
|
|
2184
|
+
const compactTextOnlyGuard = "CRITICAL: Respond with TEXT ONLY. Do NOT call any tools.";
|
|
2185
|
+
const compactSummaryPromptStart = "Your task is to create a detailed summary of the conversation so far";
|
|
2186
|
+
const compactMessageSections = ["Pending Tasks:", "Current Work:"];
|
|
2185
2187
|
async function handleCompletion(c) {
|
|
2186
2188
|
await checkRateLimit(state);
|
|
2187
2189
|
const anthropicPayload = await c.req.json();
|
|
@@ -2378,7 +2380,19 @@ const getAnthropicEffortForModel = (model) => {
|
|
|
2378
2380
|
if (reasoningEffort === "none" || reasoningEffort === "minimal") return "low";
|
|
2379
2381
|
return reasoningEffort;
|
|
2380
2382
|
};
|
|
2383
|
+
const getCompactCandidateText = (message) => {
|
|
2384
|
+
if (message.role !== "user") return "";
|
|
2385
|
+
if (typeof message.content === "string") return message.content;
|
|
2386
|
+
return message.content.filter((block) => block.type === "text").map((block) => block.text.startsWith("<system-reminder>") ? "" : block.text).filter((text) => text.length > 0).join("\n\n");
|
|
2387
|
+
};
|
|
2388
|
+
const isCompactMessage = (lastMessage) => {
|
|
2389
|
+
const text = getCompactCandidateText(lastMessage);
|
|
2390
|
+
if (!text) return false;
|
|
2391
|
+
return text.includes(compactTextOnlyGuard) && text.includes(compactSummaryPromptStart) && compactMessageSections.some((section) => text.includes(section));
|
|
2392
|
+
};
|
|
2381
2393
|
const isCompactRequest = (anthropicPayload) => {
|
|
2394
|
+
const lastMessage = anthropicPayload.messages.at(-1);
|
|
2395
|
+
if (lastMessage && isCompactMessage(lastMessage)) return true;
|
|
2382
2396
|
const system = anthropicPayload.system;
|
|
2383
2397
|
if (typeof system === "string") return system.startsWith(compactSystemPromptStart);
|
|
2384
2398
|
if (!Array.isArray(system)) return false;
|
|
@@ -2904,4 +2918,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
2904
2918
|
|
|
2905
2919
|
//#endregion
|
|
2906
2920
|
export { server };
|
|
2907
|
-
//# sourceMappingURL=server-
|
|
2921
|
+
//# sourceMappingURL=server-219WLjAn.js.map
|