@jeffreycao/copilot-api 1.9.12 → 1.9.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 +1 -1
- package/dist/{server-XuNjMVc6.js → server-DkUKa2I6.js} +36 -8
- package/dist/server-DkUKa2I6.js.map +1 -0
- package/dist/{start-C88Fy8qw.js → start-DFJynp4A.js} +2 -2
- package/dist/{start-C88Fy8qw.js.map → start-DFJynp4A.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-XuNjMVc6.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -42,7 +42,7 @@ bindElectronFetch();
|
|
|
42
42
|
const { auth } = await import("./auth-DEUCqXMV.js");
|
|
43
43
|
const { checkUsage } = await import("./check-usage-OcW_3tEg.js");
|
|
44
44
|
const { debug } = await import("./debug-CIXXx_bq.js");
|
|
45
|
-
const { start } = await import("./start-
|
|
45
|
+
const { start } = await import("./start-DFJynp4A.js");
|
|
46
46
|
await runMain(defineCommand({
|
|
47
47
|
meta: {
|
|
48
48
|
name: "copilot-api",
|
|
@@ -1789,6 +1789,7 @@ function handleFinish(choice, state, context) {
|
|
|
1789
1789
|
state.contentBlockIndex++;
|
|
1790
1790
|
if (!toolBlockOpen) handleReasoningOpaque(choice.delta, events, state);
|
|
1791
1791
|
}
|
|
1792
|
+
flushDeferredContent(state, events);
|
|
1792
1793
|
state.pendingMessageDelta = {
|
|
1793
1794
|
type: "message_delta",
|
|
1794
1795
|
delta: {
|
|
@@ -1879,13 +1880,9 @@ function handleReasoningOpaqueInToolCalls(state, events, delta) {
|
|
|
1879
1880
|
function handleContent(delta, state, events) {
|
|
1880
1881
|
if (delta.content && delta.content.length > 0) {
|
|
1881
1882
|
closeThinkingBlockIfOpen(state, events);
|
|
1882
|
-
if (isToolBlockOpen(state)) {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
index: state.contentBlockIndex
|
|
1886
|
-
});
|
|
1887
|
-
state.contentBlockIndex++;
|
|
1888
|
-
state.contentBlockOpen = false;
|
|
1883
|
+
if (isToolBlockOpen(state) || hasToolCallDelta(delta)) {
|
|
1884
|
+
state.deferredContent = `${state.deferredContent ?? ""}${delta.content}`;
|
|
1885
|
+
return;
|
|
1889
1886
|
}
|
|
1890
1887
|
if (!state.contentBlockOpen) {
|
|
1891
1888
|
events.push({
|
|
@@ -1923,6 +1920,37 @@ function handleContent(delta, state, events) {
|
|
|
1923
1920
|
state.thinkingBlockOpen = false;
|
|
1924
1921
|
}
|
|
1925
1922
|
}
|
|
1923
|
+
function hasToolCallDelta(delta) {
|
|
1924
|
+
return Boolean(delta.tool_calls && delta.tool_calls.length > 0);
|
|
1925
|
+
}
|
|
1926
|
+
function flushDeferredContent(state, events) {
|
|
1927
|
+
if (!state.deferredContent) return;
|
|
1928
|
+
if (!state.contentBlockOpen) {
|
|
1929
|
+
events.push({
|
|
1930
|
+
type: "content_block_start",
|
|
1931
|
+
index: state.contentBlockIndex,
|
|
1932
|
+
content_block: {
|
|
1933
|
+
type: "text",
|
|
1934
|
+
text: ""
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
state.contentBlockOpen = true;
|
|
1938
|
+
}
|
|
1939
|
+
events.push({
|
|
1940
|
+
type: "content_block_delta",
|
|
1941
|
+
index: state.contentBlockIndex,
|
|
1942
|
+
delta: {
|
|
1943
|
+
type: "text_delta",
|
|
1944
|
+
text: state.deferredContent
|
|
1945
|
+
}
|
|
1946
|
+
}, {
|
|
1947
|
+
type: "content_block_stop",
|
|
1948
|
+
index: state.contentBlockIndex
|
|
1949
|
+
});
|
|
1950
|
+
state.deferredContent = void 0;
|
|
1951
|
+
state.contentBlockOpen = false;
|
|
1952
|
+
state.contentBlockIndex++;
|
|
1953
|
+
}
|
|
1926
1954
|
function handleMessageStart(state, events, chunk) {
|
|
1927
1955
|
if (!state.messageStartSent) {
|
|
1928
1956
|
const { cachedTokens, cacheCreationTokens, inputTokens } = getOpenAIChunkUsageTokens(chunk);
|
|
@@ -4299,4 +4327,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
4299
4327
|
//#endregion
|
|
4300
4328
|
export { server };
|
|
4301
4329
|
|
|
4302
|
-
//# sourceMappingURL=server-
|
|
4330
|
+
//# sourceMappingURL=server-DkUKa2I6.js.map
|