@jeffreycao/copilot-api 1.11.2 → 1.11.3
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--yUElsYz.js → server-CSpOUSFF.js} +46 -26
- package/dist/server-CSpOUSFF.js.map +1 -0
- package/dist/{start-CUCHCtOg.js → start-t4js93GE.js} +2 -2
- package/dist/{start-CUCHCtOg.js.map → start-t4js93GE.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server--yUElsYz.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -43,7 +43,7 @@ const { auth } = await import("./auth-D3ta3JW0.js");
|
|
|
43
43
|
const { checkUsage } = await import("./check-usage-Dh0WqiLC.js");
|
|
44
44
|
const { debug } = await import("./debug-BiX0ewij.js");
|
|
45
45
|
const { mcp } = await import("./mcp-DZgcvqQY.js");
|
|
46
|
-
const { start } = await import("./start-
|
|
46
|
+
const { start } = await import("./start-t4js93GE.js");
|
|
47
47
|
await runMain(defineCommand({
|
|
48
48
|
meta: {
|
|
49
49
|
name: "copilot-api",
|
|
@@ -2343,7 +2343,7 @@ const prepareMessagesApiPayload = (payload, selectedModel) => {
|
|
|
2343
2343
|
payload.thinking = { type: "adaptive" };
|
|
2344
2344
|
if (!hasThinking) payload.thinking.display = "summarized";
|
|
2345
2345
|
if (shouldSummarizeThinkingDisplayForModel(payload.model)) payload.thinking.display = "summarized";
|
|
2346
|
-
let effort = getReasoningEffortForModel(payload.model);
|
|
2346
|
+
let effort = payload.output_config?.effort ?? getReasoningEffortForModel(payload.model);
|
|
2347
2347
|
if (effort === "none" || effort === "minimal") effort = "low";
|
|
2348
2348
|
const reasoningEffort = selectedModel.capabilities.supports.reasoning_effort;
|
|
2349
2349
|
if (reasoningEffort && !reasoningEffort.includes(effort)) effort = reasoningEffort.at(-1);
|
|
@@ -5791,34 +5791,54 @@ const createProviderResponsesUsageRecorder = (payload, provider) => {
|
|
|
5791
5791
|
sessionId: sessionAffinity ?? ""
|
|
5792
5792
|
});
|
|
5793
5793
|
};
|
|
5794
|
-
const streamProviderResponses = (c, upstreamResponse, options) => {
|
|
5794
|
+
const streamProviderResponses = async (c, upstreamResponse, options) => {
|
|
5795
|
+
const iterator = upstreamResponse[Symbol.asyncIterator]();
|
|
5796
|
+
const firstResult = await iterator.next();
|
|
5797
|
+
if (firstResult.done) throw new HTTPError(`Empty stream from ${options.provider} responses`, new Response("", { status: 502 }));
|
|
5798
|
+
const firstChunk = firstResult.value;
|
|
5799
|
+
if (firstChunk.data && firstChunk.data !== "[DONE]") {
|
|
5800
|
+
const event = parseProviderResponsesStreamEvent(firstChunk.data, {
|
|
5801
|
+
normalizeCodex: options.normalizeCodex,
|
|
5802
|
+
provider: options.provider
|
|
5803
|
+
});
|
|
5804
|
+
if (event?.type === "error") {
|
|
5805
|
+
const errorEvent = event;
|
|
5806
|
+
const statusCode = errorEvent.status_code ?? 500;
|
|
5807
|
+
return c.json({ error: {
|
|
5808
|
+
message: errorEvent.message,
|
|
5809
|
+
...errorEvent.error
|
|
5810
|
+
} }, statusCode, errorEvent.headers ?? void 0);
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5795
5813
|
return streamSSE(c, async (stream) => {
|
|
5796
5814
|
let usage = {};
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
provider: options.provider
|
|
5806
|
-
});
|
|
5807
|
-
if (event && options.normalizeCodex) responseChunk = {
|
|
5808
|
-
...chunk,
|
|
5809
|
-
data: JSON.stringify(event),
|
|
5810
|
-
event: event.type
|
|
5811
|
-
};
|
|
5812
|
-
}
|
|
5813
|
-
if (event) {
|
|
5814
|
-
const nextUsage = getResponsesStreamEventUsage(event);
|
|
5815
|
-
if (nextUsage) usage = nextUsage;
|
|
5816
|
-
}
|
|
5817
|
-
await stream.writeSSE({
|
|
5818
|
-
data: responseChunk.data ?? "",
|
|
5819
|
-
event: responseChunk.event
|
|
5815
|
+
const writeChunk = async (chunk) => {
|
|
5816
|
+
debugJson(logger$2, "Responses stream chunk:", chunk);
|
|
5817
|
+
let responseChunk = chunk;
|
|
5818
|
+
let event = null;
|
|
5819
|
+
if (chunk.data && chunk.data !== "[DONE]") {
|
|
5820
|
+
event = parseProviderResponsesStreamEvent(chunk.data, {
|
|
5821
|
+
normalizeCodex: options.normalizeCodex,
|
|
5822
|
+
provider: options.provider
|
|
5820
5823
|
});
|
|
5824
|
+
if (event && options.normalizeCodex) responseChunk = {
|
|
5825
|
+
...chunk,
|
|
5826
|
+
data: JSON.stringify(event),
|
|
5827
|
+
event: event.type
|
|
5828
|
+
};
|
|
5821
5829
|
}
|
|
5830
|
+
if (event) {
|
|
5831
|
+
const nextUsage = getResponsesStreamEventUsage(event);
|
|
5832
|
+
if (nextUsage) usage = nextUsage;
|
|
5833
|
+
}
|
|
5834
|
+
await stream.writeSSE({
|
|
5835
|
+
data: responseChunk.data ?? "",
|
|
5836
|
+
event: responseChunk.event
|
|
5837
|
+
});
|
|
5838
|
+
};
|
|
5839
|
+
try {
|
|
5840
|
+
await writeChunk(firstChunk);
|
|
5841
|
+
for await (const chunk of { [Symbol.asyncIterator]: () => iterator }) await writeChunk(chunk);
|
|
5822
5842
|
} finally {
|
|
5823
5843
|
options.recordUsage(usage);
|
|
5824
5844
|
}
|
|
@@ -6136,4 +6156,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
6136
6156
|
//#endregion
|
|
6137
6157
|
export { server };
|
|
6138
6158
|
|
|
6139
|
-
//# sourceMappingURL=server
|
|
6159
|
+
//# sourceMappingURL=server-CSpOUSFF.js.map
|