@robinpath/cli 1.94.0 → 1.96.0
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 +21 -5
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -18598,7 +18598,7 @@ function getNativeModules() {
|
|
|
18598
18598
|
import { join as join3, basename as basename2 } from "node:path";
|
|
18599
18599
|
import { homedir as homedir2, platform as platform2 } from "node:os";
|
|
18600
18600
|
import { existsSync as existsSync2 } from "node:fs";
|
|
18601
|
-
var CLI_VERSION = true ? "1.
|
|
18601
|
+
var CLI_VERSION = true ? "1.96.0" : "1.96.0";
|
|
18602
18602
|
var FLAG_QUIET = false;
|
|
18603
18603
|
var FLAG_VERBOSE = false;
|
|
18604
18604
|
var FLAG_AUTO_ACCEPT = false;
|
|
@@ -21896,11 +21896,13 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
|
|
|
21896
21896
|
if (conversationHistory && conversationHistory.length > 0) {
|
|
21897
21897
|
body.conversationHistory = conversationHistory;
|
|
21898
21898
|
}
|
|
21899
|
+
const controller = new AbortController();
|
|
21900
|
+
const timeout = setTimeout(() => controller.abort(), 3e4);
|
|
21899
21901
|
const response = await fetch(`${AI_BRAIN_URL}/docs/generate`, {
|
|
21900
21902
|
method: "POST",
|
|
21901
21903
|
headers: { "Content-Type": "application/json" },
|
|
21902
21904
|
body: JSON.stringify(body),
|
|
21903
|
-
signal:
|
|
21905
|
+
signal: controller.signal
|
|
21904
21906
|
});
|
|
21905
21907
|
if (!response.ok) {
|
|
21906
21908
|
logVerbose("Brain stream returned", response.status);
|
|
@@ -21913,9 +21915,20 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
|
|
|
21913
21915
|
const reader = response.body.getReader();
|
|
21914
21916
|
const decoder = new TextDecoder();
|
|
21915
21917
|
let buffer = "";
|
|
21918
|
+
const READ_TIMEOUT = 1e4;
|
|
21916
21919
|
while (true) {
|
|
21917
|
-
const
|
|
21918
|
-
|
|
21920
|
+
const readPromise = reader.read();
|
|
21921
|
+
const timeoutPromise = new Promise(
|
|
21922
|
+
(resolve13) => setTimeout(() => resolve13({ done: true, value: void 0 }), READ_TIMEOUT)
|
|
21923
|
+
);
|
|
21924
|
+
const { done, value } = await Promise.race([readPromise, timeoutPromise]);
|
|
21925
|
+
if (done) {
|
|
21926
|
+
try {
|
|
21927
|
+
reader.cancel();
|
|
21928
|
+
} catch {
|
|
21929
|
+
}
|
|
21930
|
+
break;
|
|
21931
|
+
}
|
|
21919
21932
|
buffer += decoder.decode(value, { stream: true });
|
|
21920
21933
|
const events = buffer.split("\n\n");
|
|
21921
21934
|
buffer = events.pop() || "";
|
|
@@ -21945,7 +21958,9 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
|
|
|
21945
21958
|
}
|
|
21946
21959
|
} else if (eventType === "done") {
|
|
21947
21960
|
doneData = parsed;
|
|
21961
|
+
clearTimeout(timeout);
|
|
21948
21962
|
} else if (eventType === "error") {
|
|
21963
|
+
clearTimeout(timeout);
|
|
21949
21964
|
logVerbose("Brain stream error:", parsed.message);
|
|
21950
21965
|
return {
|
|
21951
21966
|
code: fullText,
|
|
@@ -21960,6 +21975,7 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
|
|
|
21960
21975
|
}
|
|
21961
21976
|
}
|
|
21962
21977
|
}
|
|
21978
|
+
clearTimeout(timeout);
|
|
21963
21979
|
return {
|
|
21964
21980
|
code: fullText,
|
|
21965
21981
|
sources: metadata?.sources || [],
|
|
@@ -24753,7 +24769,7 @@ Type / to see available commands.`;
|
|
|
24753
24769
|
const activeModel = readAiConfig().model || this.model;
|
|
24754
24770
|
const activeKey = readAiConfig().apiKey || this.apiKey;
|
|
24755
24771
|
const activeProvider = this.resolveProvider(activeKey);
|
|
24756
|
-
for (let loop = 0; loop <
|
|
24772
|
+
for (let loop = 0; loop < 5; loop++) {
|
|
24757
24773
|
let fullText = "";
|
|
24758
24774
|
const result = await fetchBrainStream(
|
|
24759
24775
|
loop === 0 ? expanded : this.conversationMessages[this.conversationMessages.length - 1].content,
|