opencode-codebuddy-external-auth 1.0.11 → 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 +17 -13
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -230,10 +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, // 关键:非交互模式,返回结果
|
|
239
|
+
outputFormat: useStream ? "stream-json" : "text",
|
|
237
240
|
};
|
|
238
241
|
if (systemPrompt) {
|
|
239
242
|
agentRequest.systemPrompt = systemPrompt;
|
|
@@ -251,7 +254,7 @@ async function executeViaHttpApi(openaiRequest, prompt, systemPrompt) {
|
|
|
251
254
|
throw new Error(`HTTP API error: ${response.status} - ${errorText}`);
|
|
252
255
|
}
|
|
253
256
|
// 处理流式响应
|
|
254
|
-
if (
|
|
257
|
+
if (useStream && response.body) {
|
|
255
258
|
return new Response(transformCodeBuddyStreamToOpenAI(response.body, openaiRequest.model), {
|
|
256
259
|
headers: {
|
|
257
260
|
"Content-Type": "text/event-stream",
|
|
@@ -260,18 +263,19 @@ async function executeViaHttpApi(openaiRequest, prompt, systemPrompt) {
|
|
|
260
263
|
},
|
|
261
264
|
});
|
|
262
265
|
}
|
|
263
|
-
// 非流式响应
|
|
266
|
+
// 非流式响应 - 等待完整结果
|
|
264
267
|
const responseText = await response.text();
|
|
265
|
-
let resultText = responseText;
|
|
266
|
-
//
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
+
});
|
|
275
279
|
}
|
|
276
280
|
return new Response(createOpenAIResponse(resultText, openaiRequest.model), {
|
|
277
281
|
headers: { "Content-Type": "application/json" },
|