@hasna/assistants 0.6.35 → 0.6.36

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/index.js CHANGED
@@ -37324,15 +37324,15 @@ var DEFAULT_CONFIG = {
37324
37324
  },
37325
37325
  energy: {
37326
37326
  enabled: true,
37327
- regenRate: 5,
37328
- lowEnergyThreshold: 30,
37329
- criticalThreshold: 10,
37330
- maxEnergy: 100,
37327
+ regenRate: 500,
37328
+ lowEnergyThreshold: 3000,
37329
+ criticalThreshold: 1000,
37330
+ maxEnergy: 1e4,
37331
37331
  costs: {
37332
- message: 2,
37333
- toolCall: 5,
37334
- llmCall: 3,
37335
- longContext: 10
37332
+ message: 200,
37333
+ toolCall: 500,
37334
+ llmCall: 300,
37335
+ longContext: 1000
37336
37336
  }
37337
37337
  },
37338
37338
  validation: {
@@ -44783,18 +44783,18 @@ class RecoveryManager {
44783
44783
  }
44784
44784
  // packages/core/src/energy/types.ts
44785
44785
  var DEFAULT_ENERGY_COSTS = {
44786
- message: 2,
44787
- toolCall: 5,
44788
- llmCall: 3,
44789
- longContext: 10
44786
+ message: 200,
44787
+ toolCall: 500,
44788
+ llmCall: 300,
44789
+ longContext: 1000
44790
44790
  };
44791
44791
  var DEFAULT_ENERGY_CONFIG = {
44792
44792
  enabled: true,
44793
44793
  costs: DEFAULT_ENERGY_COSTS,
44794
- regenRate: 5,
44795
- lowEnergyThreshold: 30,
44796
- criticalThreshold: 10,
44797
- maxEnergy: 100
44794
+ regenRate: 500,
44795
+ lowEnergyThreshold: 3000,
44796
+ criticalThreshold: 1000,
44797
+ maxEnergy: 1e4
44798
44798
  };
44799
44799
  function buildEnergyConfig(config) {
44800
44800
  return {
@@ -49058,6 +49058,27 @@ function estimateMessageLines(message, maxWidth) {
49058
49058
  }
49059
49059
  return lines;
49060
49060
  }
49061
+ function estimateGroupedToolMessagesLines(messages, maxWidth) {
49062
+ const toolCalls = [];
49063
+ const toolResults = [];
49064
+ for (const msg of messages) {
49065
+ if (msg.toolCalls)
49066
+ toolCalls.push(...msg.toolCalls);
49067
+ if (msg.toolResults)
49068
+ toolResults.push(...msg.toolResults);
49069
+ }
49070
+ if (toolCalls.length === 0)
49071
+ return 0;
49072
+ const synthetic = {
49073
+ id: "grouped-tool-call",
49074
+ role: "assistant",
49075
+ content: "",
49076
+ timestamp: 0,
49077
+ toolCalls,
49078
+ toolResults: toolResults.length > 0 ? toolResults : undefined
49079
+ };
49080
+ return estimateMessageLines(synthetic, maxWidth);
49081
+ }
49061
49082
  function countWrappedLines(lines, maxWidth) {
49062
49083
  if (!maxWidth || maxWidth <= 0) {
49063
49084
  return lines.length;
@@ -49107,6 +49128,34 @@ function isContinuationChunk(id) {
49107
49128
  const idx = Number(match[1]);
49108
49129
  return Number.isFinite(idx) && idx > 0;
49109
49130
  }
49131
+ function groupConsecutiveToolMessages(messages) {
49132
+ const groups = [];
49133
+ let currentToolGroup = [];
49134
+ for (const msg of messages) {
49135
+ const isToolOnlyAssistant = msg.role === "assistant" && (!msg.content || !msg.content.trim()) && msg.toolCalls && msg.toolCalls.length > 0;
49136
+ if (isToolOnlyAssistant) {
49137
+ currentToolGroup.push(msg);
49138
+ } else {
49139
+ if (currentToolGroup.length > 0) {
49140
+ if (currentToolGroup.length === 1) {
49141
+ groups.push({ type: "single", message: currentToolGroup[0] });
49142
+ } else {
49143
+ groups.push({ type: "grouped", messages: currentToolGroup });
49144
+ }
49145
+ currentToolGroup = [];
49146
+ }
49147
+ groups.push({ type: "single", message: msg });
49148
+ }
49149
+ }
49150
+ if (currentToolGroup.length > 0) {
49151
+ if (currentToolGroup.length === 1) {
49152
+ groups.push({ type: "single", message: currentToolGroup[0] });
49153
+ } else {
49154
+ groups.push({ type: "grouped", messages: currentToolGroup });
49155
+ }
49156
+ }
49157
+ return groups;
49158
+ }
49110
49159
 
49111
49160
  // packages/terminal/src/components/Messages.tsx
49112
49161
  var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
@@ -49144,7 +49193,7 @@ function Messages3({
49144
49193
  const lineSpans = import_react24.useMemo(() => {
49145
49194
  let cursor = 0;
49146
49195
  return items.map((item, index) => {
49147
- const lines = item.kind === "activity" ? estimateActivityEntryLines(item.entry, wrapWidth, messageWidth) : item.kind === "grouped" ? estimateGroupedToolLines(item.messages, messageWidth) : estimateMessageLines(item.message, messageWidth);
49196
+ const lines = item.kind === "activity" ? estimateActivityEntryLines(item.entry, wrapWidth, messageWidth) : item.kind === "grouped" ? estimateGroupedToolMessagesLines(item.messages, messageWidth) : estimateMessageLines(item.message, messageWidth);
49148
49197
  const start = cursor;
49149
49198
  cursor += lines;
49150
49199
  return { item, index, start, end: cursor, lines };
@@ -49308,34 +49357,6 @@ function formatDuration(ms) {
49308
49357
  const secs = totalSeconds % 60;
49309
49358
  return `${mins}m ${secs}s`;
49310
49359
  }
49311
- function groupConsecutiveToolMessages(messages) {
49312
- const groups = [];
49313
- let currentToolGroup = [];
49314
- for (const msg of messages) {
49315
- const isToolOnlyAssistant = msg.role === "assistant" && (!msg.content || !msg.content.trim()) && msg.toolCalls && msg.toolCalls.length > 0;
49316
- if (isToolOnlyAssistant) {
49317
- currentToolGroup.push(msg);
49318
- } else {
49319
- if (currentToolGroup.length > 0) {
49320
- if (currentToolGroup.length === 1) {
49321
- groups.push({ type: "single", message: currentToolGroup[0] });
49322
- } else {
49323
- groups.push({ type: "grouped", messages: currentToolGroup });
49324
- }
49325
- currentToolGroup = [];
49326
- }
49327
- groups.push({ type: "single", message: msg });
49328
- }
49329
- }
49330
- if (currentToolGroup.length > 0) {
49331
- if (currentToolGroup.length === 1) {
49332
- groups.push({ type: "single", message: currentToolGroup[0] });
49333
- } else {
49334
- groups.push({ type: "grouped", messages: currentToolGroup });
49335
- }
49336
- }
49337
- return groups;
49338
- }
49339
49360
  function CombinedToolMessage({ messages }) {
49340
49361
  const allToolCalls = [];
49341
49362
  const allToolResults = [];
@@ -49355,27 +49376,6 @@ function CombinedToolMessage({ messages }) {
49355
49376
  }, undefined, false, undefined, this)
49356
49377
  }, undefined, false, undefined, this);
49357
49378
  }
49358
- function estimateGroupedToolLines(messages, messageWidth) {
49359
- const toolCalls = [];
49360
- const toolResults = [];
49361
- for (const msg of messages) {
49362
- if (msg.toolCalls)
49363
- toolCalls.push(...msg.toolCalls);
49364
- if (msg.toolResults)
49365
- toolResults.push(...msg.toolResults);
49366
- }
49367
- if (toolCalls.length === 0)
49368
- return 0;
49369
- const synthetic = {
49370
- id: "grouped-tool-call",
49371
- role: "assistant",
49372
- content: "",
49373
- timestamp: 0,
49374
- toolCalls,
49375
- toolResults: toolResults.length > 0 ? toolResults : undefined
49376
- };
49377
- return estimateMessageLines(synthetic, messageWidth);
49378
- }
49379
49379
  function MessageBubble({ message, queuedMessageIds }) {
49380
49380
  const isUser = message.role === "user";
49381
49381
  const isSystem = message.role === "system";
@@ -50733,6 +50733,7 @@ function App2({ cwd: cwd2, version }) {
50733
50733
  }, [activityLog, renderWidth, wrapChars]);
50734
50734
  const reservedLines = import_react29.useMemo(() => {
50735
50735
  let lines = 0;
50736
+ const wrapWidth = Math.max(1, (columns ?? 80) - 2);
50736
50737
  lines += 2;
50737
50738
  if (showWelcome) {
50738
50739
  lines += 4;
@@ -50748,16 +50749,23 @@ function App2({ cwd: cwd2, version }) {
50748
50749
  const hasMore = activeQueue.length + inlineCount > MAX_QUEUED_PREVIEW;
50749
50750
  lines += 2;
50750
50751
  lines += 1;
50751
- lines += previewCount;
50752
+ const previewWidth = Math.max(1, wrapWidth - 2);
50753
+ const previewItems = [...activeInline, ...activeQueue].slice(0, MAX_QUEUED_PREVIEW);
50754
+ const previewLines = previewItems.reduce((sum, queued) => {
50755
+ const label = queued.mode === "inline" ? "\u21B3" : "\u23F3";
50756
+ const text = `${label} ${truncateQueued(queued.content)}`;
50757
+ return sum + countWrappedLines2([text], previewWidth);
50758
+ }, 0);
50759
+ lines += Math.max(previewCount, previewLines);
50752
50760
  if (hasMore)
50753
50761
  lines += 1;
50754
50762
  }
50755
50763
  if (error2) {
50756
50764
  const parsed = parseErrorMessage(error2);
50757
- const messageLines = parsed.message ? parsed.message.split(`
50758
- `).length : 1;
50759
- const suggestionLines = parsed.suggestion ? parsed.suggestion.split(`
50760
- `).length : 0;
50765
+ const messageLines = parsed.message ? countWrappedLines2(parsed.message.split(`
50766
+ `), wrapWidth) : 1;
50767
+ const suggestionLines = parsed.suggestion ? countWrappedLines2(parsed.suggestion.split(`
50768
+ `), wrapWidth) : 0;
50761
50769
  lines += 2;
50762
50770
  lines += Math.max(1, messageLines) + suggestionLines;
50763
50771
  }
@@ -50778,7 +50786,8 @@ function App2({ cwd: cwd2, version }) {
50778
50786
  scrollOffset,
50779
50787
  error2,
50780
50788
  isProcessing,
50781
- showWelcome
50789
+ showWelcome,
50790
+ columns
50782
50791
  ]);
50783
50792
  const displayMessages = import_react29.useMemo(() => buildDisplayMessages(messages, MESSAGE_CHUNK_LINES, wrapChars, { maxWidth: renderWidth }), [messages, wrapChars, renderWidth]);
50784
50793
  const streamingMessages = import_react29.useMemo(() => {
@@ -50793,8 +50802,15 @@ function App2({ cwd: cwd2, version }) {
50793
50802
  return buildDisplayMessages([streamingMessage], MESSAGE_CHUNK_LINES, wrapChars, { maxWidth: renderWidth });
50794
50803
  }, [currentResponse, isProcessing, wrapChars, renderWidth]);
50795
50804
  const displayLineCount = import_react29.useMemo(() => {
50796
- const combined = [...displayMessages, ...streamingMessages];
50797
- return combined.reduce((sum, msg) => sum + estimateMessageLines(msg, renderWidth), 0);
50805
+ const grouped = groupConsecutiveToolMessages(displayMessages);
50806
+ const groupedLines = grouped.reduce((sum, group) => {
50807
+ if (group.type === "single") {
50808
+ return sum + estimateMessageLines(group.message, renderWidth);
50809
+ }
50810
+ return sum + estimateGroupedToolMessagesLines(group.messages, renderWidth);
50811
+ }, 0);
50812
+ const streamingLines = streamingMessages.reduce((sum, msg) => sum + estimateMessageLines(msg, renderWidth), 0);
50813
+ return groupedLines + streamingLines;
50798
50814
  }, [displayMessages, streamingMessages, renderWidth]);
50799
50815
  const totalLineCount = displayLineCount + activityLogLineCount;
50800
50816
  import_react29.useEffect(() => {
@@ -51379,7 +51395,7 @@ function formatStreamEvent(chunk) {
51379
51395
 
51380
51396
  // packages/terminal/src/index.tsx
51381
51397
  var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
51382
- var VERSION3 = "0.6.35";
51398
+ var VERSION3 = "0.6.36";
51383
51399
  process.env.ASSISTANTS_VERSION ??= VERSION3;
51384
51400
  function parseArgs(argv) {
51385
51401
  const args = argv.slice(2);
@@ -51535,4 +51551,4 @@ if (options.print !== null) {
51535
51551
  });
51536
51552
  }
51537
51553
 
51538
- //# debugId=2F2CC5B1781D557164756E2164756E21
51554
+ //# debugId=D20D9C4F4FE5D66664756E2164756E21