diff --git a/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch b/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch new file mode 100644 index 0000000000..cebfdd00a5 --- /dev/null +++ b/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch @@ -0,0 +1,44 @@ +diff --git a/dist/index.js b/dist/index.js +index 53f411e55a4c9a06fd29bb4ab8161c4ad15980cd..71b91f196c8b886ed90dd237dec5625d79d5677e 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -12676,10 +12676,13 @@ var OpenAIResponsesLanguageModel = class { + } + }); + } else if (value.item.type === "message") { +- controller.enqueue({ +- type: "text-end", +- id: value.item.id +- }); ++ // Fix for gpt-5-codex: use currentTextId to ensure text-end matches text-start ++ if (currentTextId) { ++ controller.enqueue({ ++ type: "text-end", ++ id: currentTextId ++ }); ++ } + currentTextId = null; + } else if (isResponseOutputItemDoneReasoningChunk(value)) { + const activeReasoningPart = activeReasoning[value.item.id]; +diff --git a/dist/index.mjs b/dist/index.mjs +index 7719264da3c49a66c2626082f6ccaae6e3ef5e89..090fd8cf142674192a826148428ed6a0c4a54e35 100644 +--- a/dist/index.mjs ++++ b/dist/index.mjs +@@ -12670,10 +12670,13 @@ var OpenAIResponsesLanguageModel = class { + } + }); + } else if (value.item.type === "message") { +- controller.enqueue({ +- type: "text-end", +- id: value.item.id +- }); ++ // Fix for gpt-5-codex: use currentTextId to ensure text-end matches text-start ++ if (currentTextId) { ++ controller.enqueue({ ++ type: "text-end", ++ id: currentTextId ++ }); ++ } + currentTextId = null; + } else if (isResponseOutputItemDoneReasoningChunk(value)) { + const activeReasoningPart = activeReasoning[value.item.id]; diff --git a/package.json b/package.json index e82153922c..1dad6a9f5a 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "@opentelemetry/sdk-trace-base": "^2.0.0", "@opentelemetry/sdk-trace-node": "^2.0.0", "@opentelemetry/sdk-trace-web": "^2.0.0", - "@opeoginni/github-copilot-openai-compatible": "0.1.18", + "@opeoginni/github-copilot-openai-compatible": "patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch", "@playwright/test": "^1.52.0", "@radix-ui/react-context-menu": "^2.2.16", "@reduxjs/toolkit": "^2.2.5", diff --git a/src/renderer/src/aiCore/legacy/clients/openai/OpenAIBaseClient.ts b/src/renderer/src/aiCore/legacy/clients/openai/OpenAIBaseClient.ts index 79762e9474..71ed1c95fe 100644 --- a/src/renderer/src/aiCore/legacy/clients/openai/OpenAIBaseClient.ts +++ b/src/renderer/src/aiCore/legacy/clients/openai/OpenAIBaseClient.ts @@ -1,4 +1,5 @@ import { loggerService } from '@logger' +import { COPILOT_DEFAULT_HEADERS } from '@renderer/aiCore/provider/constants' import { isClaudeReasoningModel, isOpenAIReasoningModel, @@ -166,7 +167,8 @@ export abstract class OpenAIBaseClient< baseURL: this.getBaseURL(), defaultHeaders: { ...this.defaultHeaders(), - ...this.provider.extra_headers + ...this.provider.extra_headers, + ...(this.provider.id === 'copilot' ? COPILOT_DEFAULT_HEADERS : {}) } }) as TSdkInstance } diff --git a/yarn.lock b/yarn.lock index 4fcea693ba..2d5bffcfd0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7421,6 +7421,18 @@ __metadata: languageName: node linkType: hard +"@opeoginni/github-copilot-openai-compatible@patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch": + version: 0.1.18 + resolution: "@opeoginni/github-copilot-openai-compatible@patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch::version=0.1.18&hash=1cf9d0" + dependencies: + "@ai-sdk/openai": "npm:^2.0.42" + "@ai-sdk/openai-compatible": "npm:^1.0.19" + "@ai-sdk/provider": "npm:^2.1.0-beta.4" + "@ai-sdk/provider-utils": "npm:^3.0.10" + checksum: 10c0/cfffc031d2742068d20baed0e0ade6e9182c29ee7a425fa64262c04023ae75220b8b944ad2c9554255681e325fa1a70ec5e1f961b5f7370c871e70cbaeac0e79 + languageName: node + linkType: hard + "@oxc-project/runtime@npm:0.71.0": version: 0.71.0 resolution: "@oxc-project/runtime@npm:0.71.0" @@ -13993,7 +14005,7 @@ __metadata: "@opentelemetry/sdk-trace-base": "npm:^2.0.0" "@opentelemetry/sdk-trace-node": "npm:^2.0.0" "@opentelemetry/sdk-trace-web": "npm:^2.0.0" - "@opeoginni/github-copilot-openai-compatible": "npm:0.1.18" + "@opeoginni/github-copilot-openai-compatible": "patch:@opeoginni/github-copilot-openai-compatible@npm%3A0.1.18#~/.yarn/patches/@opeoginni-github-copilot-openai-compatible-npm-0.1.18-3f65760532.patch" "@playwright/test": "npm:^1.52.0" "@radix-ui/react-context-menu": "npm:^2.2.16" "@reduxjs/toolkit": "npm:^2.2.5"