@robinpath/cli 1.96.0 → 1.98.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +38 -17
  2. 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.96.0" : "1.96.0";
18601
+ var CLI_VERSION = true ? "1.98.0" : "1.98.0";
18602
18602
  var FLAG_QUIET = false;
18603
18603
  var FLAG_VERBOSE = false;
18604
18604
  var FLAG_AUTO_ACCEPT = false;
@@ -21884,6 +21884,14 @@ async function fetchBrainContext(prompt) {
21884
21884
  }
21885
21885
  async function fetchBrainStream(prompt, { onToken, conversationHistory, provider, model, apiKey, cliContext } = {}) {
21886
21886
  try {
21887
+ let resetReadTimer2 = function() {
21888
+ if (readTimer) clearTimeout(readTimer);
21889
+ readTimer = setTimeout(() => {
21890
+ logVerbose("Stream read timeout \u2014 aborting");
21891
+ controller.abort();
21892
+ }, 1e4);
21893
+ };
21894
+ var resetReadTimer = resetReadTimer2;
21887
21895
  const body = {
21888
21896
  prompt,
21889
21897
  topK: 10,
@@ -21915,20 +21923,20 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
21915
21923
  const reader = response.body.getReader();
21916
21924
  const decoder = new TextDecoder();
21917
21925
  let buffer = "";
21918
- const READ_TIMEOUT = 1e4;
21926
+ let readTimer = null;
21927
+ resetReadTimer2();
21919
21928
  while (true) {
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
- }
21929
+ let done;
21930
+ let value;
21931
+ try {
21932
+ const result = await reader.read();
21933
+ done = result.done;
21934
+ value = result.value;
21935
+ } catch {
21930
21936
  break;
21931
21937
  }
21938
+ if (done) break;
21939
+ resetReadTimer2();
21932
21940
  buffer += decoder.decode(value, { stream: true });
21933
21941
  const events = buffer.split("\n\n");
21934
21942
  buffer = events.pop() || "";
@@ -21958,10 +21966,16 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
21958
21966
  }
21959
21967
  } else if (eventType === "done") {
21960
21968
  doneData = parsed;
21969
+ if (readTimer) clearTimeout(readTimer);
21961
21970
  clearTimeout(timeout);
21962
21971
  } else if (eventType === "error") {
21972
+ if (readTimer) clearTimeout(readTimer);
21963
21973
  clearTimeout(timeout);
21964
21974
  logVerbose("Brain stream error:", parsed.message);
21975
+ try {
21976
+ reader.cancel();
21977
+ } catch {
21978
+ }
21965
21979
  return {
21966
21980
  code: fullText,
21967
21981
  sources: metadata?.sources || [],
@@ -21975,7 +21989,12 @@ async function fetchBrainStream(prompt, { onToken, conversationHistory, provider
21975
21989
  }
21976
21990
  }
21977
21991
  }
21992
+ if (readTimer) clearTimeout(readTimer);
21978
21993
  clearTimeout(timeout);
21994
+ try {
21995
+ reader.cancel();
21996
+ } catch {
21997
+ }
21979
21998
  return {
21980
21999
  code: fullText,
21981
22000
  sources: metadata?.sources || [],
@@ -24595,10 +24614,7 @@ function ChatApp({ engine }) {
24595
24614
  },
24596
24615
  onCancel: () => setShowModelPicker(false)
24597
24616
  }
24598
- ) : loading ? /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", paddingX: 1, children: streaming ? /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
24599
- /* @__PURE__ */ jsx2(Markdown, { children: streaming }),
24600
- /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: "\u258D" })
24601
- ] }) : /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24617
+ ) : loading ? /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", paddingX: 1, children: streaming ? /* @__PURE__ */ jsx2(Text2, { wrap: "wrap", children: streaming }) : /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
24602
24618
  /* @__PURE__ */ jsx2(InkSpinner, { type: "dots" }),
24603
24619
  " Thinking"
24604
24620
  ] }) }) : /* @__PURE__ */ jsx2(
@@ -24782,7 +24798,9 @@ Type / to see available commands.`;
24782
24798
  }
24783
24799
  fullText += delta;
24784
24800
  const clean = fullText.replace(/<memory>[\s\S]*?<\/memory>/g, "").replace(/<cmd>[\s\S]*?<\/cmd>/g, "").replace(/\n{3,}/g, "\n\n").trim();
24785
- ui?.setStreaming(clean);
24801
+ const hasOpenCmd = fullText.includes("<cmd>") && !fullText.endsWith("</cmd>") && (fullText.match(/<cmd>/g) || []).length > (fullText.match(/<\/cmd>/g) || []).length;
24802
+ const display = hasOpenCmd ? clean + "\n\nPreparing commands..." : clean;
24803
+ ui?.setStreaming(display);
24786
24804
  },
24787
24805
  conversationHistory: this.conversationMessages.slice(0, -1),
24788
24806
  provider: activeProvider,
@@ -24821,6 +24839,8 @@ Type / to see available commands.`;
24821
24839
  finalResponse = cleaned || fullText;
24822
24840
  break;
24823
24841
  }
24842
+ ui?.setStreaming("");
24843
+ await new Promise((r) => setTimeout(r, 50));
24824
24844
  if (cleaned) ui?.addMessage(cleaned);
24825
24845
  const cmdResults = [];
24826
24846
  for (const cmd of commands) {
@@ -24861,6 +24881,7 @@ ${lines.slice(-5).join("\n")}`,
24861
24881
  ${summary}` });
24862
24882
  ui?.setStreaming("");
24863
24883
  finalResponse = "";
24884
+ await new Promise((r) => setTimeout(r, 50));
24864
24885
  }
24865
24886
  } catch (err) {
24866
24887
  finalResponse = `\u26A0 Error: ${err.message}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robinpath/cli",
3
- "version": "1.96.0",
3
+ "version": "1.98.0",
4
4
  "description": "AI-powered scripting CLI — automate anything from your terminal",
5
5
  "type": "module",
6
6
  "license": "MIT",