bravecode-cli 0.1.10 → 0.1.11
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/cli.mjs +76 -59
- package/dist/cli.mjs.map +3 -3
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -37370,70 +37370,87 @@ ${instructions}` : instructions;
|
|
|
37370
37370
|
payload.temperature = params.temperature;
|
|
37371
37371
|
}
|
|
37372
37372
|
const parser = new TextToolCallParser(() => this.nextToolCallId());
|
|
37373
|
-
|
|
37374
|
-
|
|
37375
|
-
|
|
37376
|
-
|
|
37377
|
-
|
|
37378
|
-
|
|
37379
|
-
|
|
37380
|
-
|
|
37381
|
-
|
|
37382
|
-
|
|
37383
|
-
|
|
37384
|
-
|
|
37385
|
-
|
|
37386
|
-
|
|
37387
|
-
|
|
37388
|
-
|
|
37389
|
-
|
|
37390
|
-
|
|
37391
|
-
|
|
37392
|
-
|
|
37393
|
-
|
|
37394
|
-
|
|
37395
|
-
|
|
37396
|
-
|
|
37397
|
-
|
|
37398
|
-
|
|
37399
|
-
|
|
37400
|
-
|
|
37401
|
-
|
|
37402
|
-
|
|
37403
|
-
|
|
37404
|
-
|
|
37405
|
-
|
|
37406
|
-
|
|
37407
|
-
|
|
37408
|
-
|
|
37409
|
-
|
|
37410
|
-
|
|
37411
|
-
const
|
|
37412
|
-
if (
|
|
37413
|
-
|
|
37373
|
+
const maxRetries = 2;
|
|
37374
|
+
let lastError = null;
|
|
37375
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
37376
|
+
try {
|
|
37377
|
+
const controller = new AbortController();
|
|
37378
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
37379
|
+
if (params.signal) {
|
|
37380
|
+
params.signal.addEventListener("abort", () => controller.abort());
|
|
37381
|
+
}
|
|
37382
|
+
const response = await fetch(this.coderoUrl, {
|
|
37383
|
+
method: "POST",
|
|
37384
|
+
headers: {
|
|
37385
|
+
"Content-Type": "application/json",
|
|
37386
|
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
|
|
37387
|
+
...this.coderoApiKey ? { Authorization: `Bearer ${this.coderoApiKey}` } : {}
|
|
37388
|
+
},
|
|
37389
|
+
body: JSON.stringify(payload),
|
|
37390
|
+
signal: controller.signal
|
|
37391
|
+
});
|
|
37392
|
+
clearTimeout(timeoutId);
|
|
37393
|
+
if (!response.ok) {
|
|
37394
|
+
throw new Error(`BraveCode API error: ${response.status}`);
|
|
37395
|
+
}
|
|
37396
|
+
const reader = response.body?.getReader();
|
|
37397
|
+
if (!reader) {
|
|
37398
|
+
throw new Error("No response body");
|
|
37399
|
+
}
|
|
37400
|
+
const decoder = new TextDecoder();
|
|
37401
|
+
let lineBuffer = "";
|
|
37402
|
+
let sawDone = false;
|
|
37403
|
+
while (!sawDone) {
|
|
37404
|
+
if (params.signal?.aborted) break;
|
|
37405
|
+
const { done, value } = await reader.read();
|
|
37406
|
+
if (done) break;
|
|
37407
|
+
lineBuffer += decoder.decode(value, { stream: true });
|
|
37408
|
+
const lines = lineBuffer.split("\n");
|
|
37409
|
+
lineBuffer = lines.pop() || "";
|
|
37410
|
+
for (const line of lines) {
|
|
37411
|
+
const trimmed = line.trim();
|
|
37412
|
+
if (!trimmed) continue;
|
|
37413
|
+
let delta = null;
|
|
37414
|
+
try {
|
|
37415
|
+
delta = JSON.parse(trimmed);
|
|
37416
|
+
} catch {
|
|
37417
|
+
delta = null;
|
|
37414
37418
|
}
|
|
37415
|
-
|
|
37416
|
-
|
|
37419
|
+
const rawText = delta?.delta || delta?.chunk || "";
|
|
37420
|
+
if (rawText) {
|
|
37421
|
+
const { text: text2, toolCalls } = parser.push(rawText);
|
|
37422
|
+
if (text2) {
|
|
37423
|
+
yield { type: "text", text: text2 };
|
|
37424
|
+
}
|
|
37425
|
+
for (const call of toolCalls) {
|
|
37426
|
+
yield { type: "tool_call", toolCall: call };
|
|
37427
|
+
}
|
|
37428
|
+
}
|
|
37429
|
+
if (delta && (delta.done || delta.type === "done")) {
|
|
37430
|
+
sawDone = true;
|
|
37431
|
+
break;
|
|
37417
37432
|
}
|
|
37418
|
-
}
|
|
37419
|
-
if (delta && (delta.done || delta.type === "done")) {
|
|
37420
|
-
sawDone = true;
|
|
37421
|
-
break;
|
|
37422
37433
|
}
|
|
37423
37434
|
}
|
|
37435
|
+
const tail = parser.end();
|
|
37436
|
+
if (tail.text) {
|
|
37437
|
+
yield { type: "text", text: tail.text };
|
|
37438
|
+
}
|
|
37439
|
+
for (const call of tail.toolCalls) {
|
|
37440
|
+
yield { type: "tool_call", toolCall: call };
|
|
37441
|
+
}
|
|
37442
|
+
yield { type: "finish", finishReason: "stop" };
|
|
37443
|
+
return;
|
|
37444
|
+
} catch (error40) {
|
|
37445
|
+
lastError = error40;
|
|
37446
|
+
console.error(`BraveCode stream error (attempt ${attempt + 1}/${maxRetries + 1}):`, error40.message);
|
|
37447
|
+
if (attempt < maxRetries) {
|
|
37448
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3 * (attempt + 1)));
|
|
37449
|
+
continue;
|
|
37450
|
+
}
|
|
37424
37451
|
}
|
|
37425
|
-
const tail = parser.end();
|
|
37426
|
-
if (tail.text) {
|
|
37427
|
-
yield { type: "text", text: tail.text };
|
|
37428
|
-
}
|
|
37429
|
-
for (const call of tail.toolCalls) {
|
|
37430
|
-
yield { type: "tool_call", toolCall: call };
|
|
37431
|
-
}
|
|
37432
|
-
yield { type: "finish", finishReason: "stop" };
|
|
37433
|
-
} catch (error40) {
|
|
37434
|
-
console.error("BraveCode stream error:", error40);
|
|
37435
|
-
throw error40;
|
|
37436
37452
|
}
|
|
37453
|
+
throw lastError || new Error("BraveCode API: All connection attempts failed");
|
|
37437
37454
|
}
|
|
37438
37455
|
async coderoChat(params) {
|
|
37439
37456
|
let text2 = "";
|
|
@@ -38030,7 +38047,7 @@ var APP_VERSION;
|
|
|
38030
38047
|
var init_version = __esm({
|
|
38031
38048
|
"src/version.ts"() {
|
|
38032
38049
|
"use strict";
|
|
38033
|
-
APP_VERSION = "0.1.
|
|
38050
|
+
APP_VERSION = "0.1.11";
|
|
38034
38051
|
}
|
|
38035
38052
|
});
|
|
38036
38053
|
|