@astra-cli/cli 1.2.7 → 1.2.8

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/astra.js +30 -9
  2. package/package.json +1 -1
package/dist/astra.js CHANGED
@@ -5125,7 +5125,7 @@ import { useState as useState3, useEffect as useEffect2 } from "react";
5125
5125
  import { Text as Text9 } from "ink";
5126
5126
  import { jsxs as jsxs9 } from "react/jsx-runtime";
5127
5127
  var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
5128
- var INTERVAL_MS = 80;
5128
+ var INTERVAL_MS = 120;
5129
5129
  function Spinner({ label }) {
5130
5130
  const [frame, setFrame] = useState3(0);
5131
5131
  useEffect2(() => {
@@ -5179,6 +5179,27 @@ function App({
5179
5179
  isLoadingRef.current = isLoading;
5180
5180
  }, [isLoading]);
5181
5181
  const [toolName, setToolName] = useState4(void 0);
5182
+ const streamBufferRef = useRef2("");
5183
+ const streamFlushTimerRef = useRef2(null);
5184
+ const flushStreamBuffer = useCallback2(() => {
5185
+ streamFlushTimerRef.current = null;
5186
+ setStreamingText((prev) => (prev ?? "") + streamBufferRef.current);
5187
+ streamBufferRef.current = "";
5188
+ }, []);
5189
+ const appendStreamChunk = useCallback2((chunk) => {
5190
+ streamBufferRef.current += chunk;
5191
+ if (!streamFlushTimerRef.current) {
5192
+ streamFlushTimerRef.current = setTimeout(flushStreamBuffer, 50);
5193
+ }
5194
+ }, [flushStreamBuffer]);
5195
+ const clearStream = useCallback2(() => {
5196
+ if (streamFlushTimerRef.current) {
5197
+ clearTimeout(streamFlushTimerRef.current);
5198
+ streamFlushTimerRef.current = null;
5199
+ }
5200
+ streamBufferRef.current = "";
5201
+ clearStream();
5202
+ }, []);
5182
5203
  const [autopilotMode, setAutopilotMode] = useState4(initialAutopilotConfig?.mode ?? "off");
5183
5204
  const [autopilotIntervalMs, setAutopilotIntervalMs] = useState4(initialAutopilotConfig?.intervalMs ?? 3e5);
5184
5205
  const epochCallCountRef = useRef2(0);
@@ -5248,7 +5269,7 @@ function App({
5248
5269
  { ...profile, autopilotMode },
5249
5270
  {
5250
5271
  onTextChunk: displayMode === "chat" ? (chunk) => {
5251
- setStreamingText((prev) => (prev ?? "") + chunk);
5272
+ appendStreamChunk(chunk);
5252
5273
  } : () => {
5253
5274
  },
5254
5275
  onToolCallStart: displayMode === "chat" ? (name) => {
@@ -5268,7 +5289,7 @@ function App({
5268
5289
  setCoreMessages(updatedCore);
5269
5290
  const responseText = result.text.trim();
5270
5291
  if (displayMode === "chat") {
5271
- setStreamingText(void 0);
5292
+ clearStream();
5272
5293
  setChatMessages((prev) => [
5273
5294
  ...prev,
5274
5295
  { role: "assistant", content: responseText || "Market checked \u2014 holding." }
@@ -5289,7 +5310,7 @@ function App({
5289
5310
  } catch (error) {
5290
5311
  const message = error instanceof Error ? error.message : "Unknown error";
5291
5312
  if (displayMode === "chat") {
5292
- setStreamingText(void 0);
5313
+ clearStream();
5293
5314
  setChatMessages((prev) => [...prev, { role: "assistant", content: `Autopilot error: ${message}` }]);
5294
5315
  } else {
5295
5316
  addLogEntry("error", message);
@@ -5299,7 +5320,7 @@ function App({
5299
5320
  if (displayMode === "chat") setToolName(void 0);
5300
5321
  }
5301
5322
  },
5302
- [skillContext, tradingContext, walletContext, rewardsContext, onboardingContext, apiContext, profile, autopilotMode, agentName, sessionId, memoryContent, addLogEntry]
5323
+ [skillContext, tradingContext, walletContext, rewardsContext, onboardingContext, apiContext, profile, autopilotMode, agentName, sessionId, memoryContent, addLogEntry, appendStreamChunk, clearStream, pluginMap]
5303
5324
  );
5304
5325
  useEffect3(() => {
5305
5326
  if (!hasAutopilot || autopilotMode === "off") return;
@@ -5597,7 +5618,7 @@ Let's go through it and improve or replace it.` : "I want to create a trading st
5597
5618
  { ...profile, autopilotMode },
5598
5619
  {
5599
5620
  onTextChunk: (chunk) => {
5600
- setStreamingText((prev) => (prev ?? "") + chunk);
5621
+ appendStreamChunk(chunk);
5601
5622
  },
5602
5623
  onToolCallStart: (name) => {
5603
5624
  setToolName(name);
@@ -5630,7 +5651,7 @@ Let's go through it and improve or replace it.` : "I want to create a trading st
5630
5651
  }
5631
5652
  setChatMessages(updatedChat);
5632
5653
  setCoreMessages(updatedCore);
5633
- setStreamingText(void 0);
5654
+ clearStream();
5634
5655
  saveSession({
5635
5656
  agentName,
5636
5657
  provider: providerRef.current,
@@ -5656,13 +5677,13 @@ ${stack}
5656
5677
  { role: "assistant", content: `Error: ${message}${debugInfo}` }
5657
5678
  ]);
5658
5679
  setCoreMessages(newCoreMessages);
5659
- setStreamingText(void 0);
5680
+ clearStream();
5660
5681
  } finally {
5661
5682
  setIsLoading(false);
5662
5683
  setToolName(void 0);
5663
5684
  }
5664
5685
  },
5665
- [coreMessages, chatMessages, skillContext, tradingContext, walletContext, rewardsContext, onboardingContext, apiContext, profile, autopilotMode, agentName, sessionId, memoryContent, addLogEntry, pluginMap, hasAutopilot, hasJourneyStages, exit, debug]
5686
+ [coreMessages, chatMessages, skillContext, tradingContext, walletContext, rewardsContext, onboardingContext, apiContext, profile, autopilotMode, agentName, sessionId, memoryContent, addLogEntry, pluginMap, hasAutopilot, hasJourneyStages, exit, debug, appendStreamChunk, clearStream, runAutopilotTurn]
5666
5687
  );
5667
5688
  useEffect3(() => {
5668
5689
  sendMessageRef.current = sendMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astra-cli/cli",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "The terminal for autonomous agents. Powered by AstraNova.",
5
5
  "type": "module",
6
6
  "bin": {