opencode-codebuddy-external-auth 1.0.12 → 1.0.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/plugin.js +16 -13
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -230,11 +230,13 @@ function createProxyFetch() {
|
|
|
230
230
|
*/
|
|
231
231
|
async function executeViaHttpApi(openaiRequest, prompt, systemPrompt) {
|
|
232
232
|
// 构建 CodeBuddy /agent 请求
|
|
233
|
+
// 暂时禁用流式模式,先确保基础功能正常
|
|
234
|
+
const useStream = false; // openaiRequest.stream
|
|
233
235
|
const agentRequest = {
|
|
234
236
|
prompt,
|
|
235
237
|
model: openaiRequest.model,
|
|
236
238
|
print: true, // 关键:非交互模式,返回结果
|
|
237
|
-
outputFormat:
|
|
239
|
+
outputFormat: useStream ? "stream-json" : "text",
|
|
238
240
|
};
|
|
239
241
|
if (systemPrompt) {
|
|
240
242
|
agentRequest.systemPrompt = systemPrompt;
|
|
@@ -252,7 +254,7 @@ async function executeViaHttpApi(openaiRequest, prompt, systemPrompt) {
|
|
|
252
254
|
throw new Error(`HTTP API error: ${response.status} - ${errorText}`);
|
|
253
255
|
}
|
|
254
256
|
// 处理流式响应
|
|
255
|
-
if (
|
|
257
|
+
if (useStream && response.body) {
|
|
256
258
|
return new Response(transformCodeBuddyStreamToOpenAI(response.body, openaiRequest.model), {
|
|
257
259
|
headers: {
|
|
258
260
|
"Content-Type": "text/event-stream",
|
|
@@ -261,18 +263,19 @@ async function executeViaHttpApi(openaiRequest, prompt, systemPrompt) {
|
|
|
261
263
|
},
|
|
262
264
|
});
|
|
263
265
|
}
|
|
264
|
-
// 非流式响应
|
|
266
|
+
// 非流式响应 - 等待完整结果
|
|
265
267
|
const responseText = await response.text();
|
|
266
|
-
let resultText = responseText;
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
let resultText = responseText.trim();
|
|
269
|
+
// 返回 OpenAI 格式响应
|
|
270
|
+
// 如果客户端请求流式,返回伪流式响应
|
|
271
|
+
if (openaiRequest.stream) {
|
|
272
|
+
return new Response(createOpenAIStreamResponse(resultText, openaiRequest.model), {
|
|
273
|
+
headers: {
|
|
274
|
+
"Content-Type": "text/event-stream",
|
|
275
|
+
"Cache-Control": "no-cache",
|
|
276
|
+
"Connection": "keep-alive",
|
|
277
|
+
},
|
|
278
|
+
});
|
|
276
279
|
}
|
|
277
280
|
return new Response(createOpenAIResponse(resultText, openaiRequest.model), {
|
|
278
281
|
headers: { "Content-Type": "application/json" },
|