@hasna/assistants 0.6.35 → 0.6.37

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: {
@@ -38989,10 +38989,20 @@ class FilesystemTools {
38989
38989
  }
38990
38990
  const glob = new Glob(pattern);
38991
38991
  const matches = [];
38992
- for await (const file of glob.scan({ cwd: validated.resolved })) {
38993
- matches.push(file);
38994
- if (matches.length >= 1000)
38995
- break;
38992
+ try {
38993
+ for await (const file of glob.scan({ cwd: validated.resolved })) {
38994
+ if (file.includes(".Trash") || file.includes(".Spotlight-V100") || file.includes(".fseventsd")) {
38995
+ continue;
38996
+ }
38997
+ matches.push(file);
38998
+ if (matches.length >= 1000)
38999
+ break;
39000
+ }
39001
+ } catch (scanError) {
39002
+ const errMsg = scanError instanceof Error ? scanError.message : String(scanError);
39003
+ if (errMsg.includes("operation not permitted") || errMsg.includes("EPERM") || errMsg.includes("EACCES")) {} else {
39004
+ throw scanError;
39005
+ }
38996
39006
  }
38997
39007
  if (matches.length === 0) {
38998
39008
  return "No files found matching pattern";
@@ -39094,22 +39104,32 @@ class FilesystemTools {
39094
39104
  const regex2 = new RegExp(pattern, flags);
39095
39105
  const results = [];
39096
39106
  const glob = new Glob(globPattern);
39097
- for await (const file of glob.scan({ cwd: validated.resolved })) {
39098
- const filePath = join4(validated.resolved, file);
39099
- try {
39100
- const content = await Bun.file(filePath).text();
39101
- const lines = content.split(`
39107
+ try {
39108
+ for await (const file of glob.scan({ cwd: validated.resolved })) {
39109
+ if (file.includes(".Trash") || file.includes(".Spotlight-V100") || file.includes(".fseventsd")) {
39110
+ continue;
39111
+ }
39112
+ const filePath = join4(validated.resolved, file);
39113
+ try {
39114
+ const content = await Bun.file(filePath).text();
39115
+ const lines = content.split(`
39102
39116
  `);
39103
- for (let i = 0;i < lines.length; i++) {
39104
- if (regex2.test(lines[i])) {
39105
- results.push(`${file}:${i + 1}: ${lines[i].trim()}`);
39106
- if (results.length >= 500)
39107
- break;
39117
+ for (let i = 0;i < lines.length; i++) {
39118
+ if (regex2.test(lines[i])) {
39119
+ results.push(`${file}:${i + 1}: ${lines[i].trim()}`);
39120
+ if (results.length >= 500)
39121
+ break;
39122
+ }
39108
39123
  }
39109
- }
39110
- } catch {}
39111
- if (results.length >= 500)
39112
- break;
39124
+ } catch {}
39125
+ if (results.length >= 500)
39126
+ break;
39127
+ }
39128
+ } catch (scanError) {
39129
+ const errMsg = scanError instanceof Error ? scanError.message : String(scanError);
39130
+ if (errMsg.includes("operation not permitted") || errMsg.includes("EPERM") || errMsg.includes("EACCES")) {} else {
39131
+ throw scanError;
39132
+ }
39113
39133
  }
39114
39134
  if (results.length === 0) {
39115
39135
  return "No matches found";
@@ -44783,18 +44803,18 @@ class RecoveryManager {
44783
44803
  }
44784
44804
  // packages/core/src/energy/types.ts
44785
44805
  var DEFAULT_ENERGY_COSTS = {
44786
- message: 2,
44787
- toolCall: 5,
44788
- llmCall: 3,
44789
- longContext: 10
44806
+ message: 200,
44807
+ toolCall: 500,
44808
+ llmCall: 300,
44809
+ longContext: 1000
44790
44810
  };
44791
44811
  var DEFAULT_ENERGY_CONFIG = {
44792
44812
  enabled: true,
44793
44813
  costs: DEFAULT_ENERGY_COSTS,
44794
- regenRate: 5,
44795
- lowEnergyThreshold: 30,
44796
- criticalThreshold: 10,
44797
- maxEnergy: 100
44814
+ regenRate: 500,
44815
+ lowEnergyThreshold: 3000,
44816
+ criticalThreshold: 1000,
44817
+ maxEnergy: 1e4
44798
44818
  };
44799
44819
  function buildEnergyConfig(config) {
44800
44820
  return {
@@ -49007,13 +49027,15 @@ function stripAnsi3(text) {
49007
49027
  }
49008
49028
 
49009
49029
  // packages/terminal/src/components/messageLines.ts
49010
- function estimateToolPanelLines(toolCalls, toolResults, hasContent) {
49030
+ function estimateToolPanelLines(toolCalls, toolResults, hasContent, maxWidth) {
49011
49031
  if (!toolCalls || toolCalls.length === 0) {
49012
49032
  return 0;
49013
49033
  }
49034
+ const innerWidth = maxWidth ? Math.max(1, maxWidth - 4) : undefined;
49035
+ const resultWidth = innerWidth ? Math.max(1, innerWidth - 4) : undefined;
49014
49036
  const resultLines = new Map;
49015
49037
  for (const result of toolResults || []) {
49016
- resultLines.set(result.toolCallId, estimateToolResultLines(result));
49038
+ resultLines.set(result.toolCallId, estimateToolResultLines(result, resultWidth));
49017
49039
  }
49018
49040
  let lines = 3;
49019
49041
  if (hasContent) {
@@ -49028,13 +49050,14 @@ function estimateToolPanelLines(toolCalls, toolResults, hasContent) {
49028
49050
  }
49029
49051
  return lines;
49030
49052
  }
49031
- function estimateToolResultLines(result, maxLines = 4) {
49053
+ function estimateToolResultLines(result, maxWidth, maxLines = 4) {
49032
49054
  const content = truncateToolResult(result, maxLines, 400);
49033
49055
  if (!content)
49034
49056
  return 1;
49035
49057
  const lines = stripAnsi4(content).split(`
49036
49058
  `);
49037
- return Math.max(1, lines.length);
49059
+ const wrapped = countWrappedLines(lines, maxWidth);
49060
+ return Math.max(1, wrapped);
49038
49061
  }
49039
49062
  function estimateMessageLines(message, maxWidth) {
49040
49063
  if (message.role === "system") {
@@ -49049,7 +49072,7 @@ function estimateMessageLines(message, maxWidth) {
49049
49072
  const wrappedLines = typeof message.__lineCount === "number" ? message.__lineCount : contentLines.length > 0 ? countWrappedLines(contentLines, effectiveWidth) : 0;
49050
49073
  let lines = hasContent ? Math.max(1, wrappedLines) : 0;
49051
49074
  if (message.role === "assistant" && message.toolCalls?.length) {
49052
- lines += estimateToolPanelLines(message.toolCalls, message.toolResults, hasContent);
49075
+ lines += estimateToolPanelLines(message.toolCalls, message.toolResults, hasContent, maxWidth);
49053
49076
  }
49054
49077
  if (message.role === "user" || message.role === "assistant") {
49055
49078
  if (!isContinuationChunk(message.id)) {
@@ -49058,6 +49081,27 @@ function estimateMessageLines(message, maxWidth) {
49058
49081
  }
49059
49082
  return lines;
49060
49083
  }
49084
+ function estimateGroupedToolMessagesLines(messages, maxWidth) {
49085
+ const toolCalls = [];
49086
+ const toolResults = [];
49087
+ for (const msg of messages) {
49088
+ if (msg.toolCalls)
49089
+ toolCalls.push(...msg.toolCalls);
49090
+ if (msg.toolResults)
49091
+ toolResults.push(...msg.toolResults);
49092
+ }
49093
+ if (toolCalls.length === 0)
49094
+ return 0;
49095
+ const synthetic = {
49096
+ id: "grouped-tool-call",
49097
+ role: "assistant",
49098
+ content: "",
49099
+ timestamp: 0,
49100
+ toolCalls,
49101
+ toolResults: toolResults.length > 0 ? toolResults : undefined
49102
+ };
49103
+ return estimateMessageLines(synthetic, maxWidth);
49104
+ }
49061
49105
  function countWrappedLines(lines, maxWidth) {
49062
49106
  if (!maxWidth || maxWidth <= 0) {
49063
49107
  return lines.length;
@@ -49107,6 +49151,34 @@ function isContinuationChunk(id) {
49107
49151
  const idx = Number(match[1]);
49108
49152
  return Number.isFinite(idx) && idx > 0;
49109
49153
  }
49154
+ function groupConsecutiveToolMessages(messages) {
49155
+ const groups = [];
49156
+ let currentToolGroup = [];
49157
+ for (const msg of messages) {
49158
+ const isToolOnlyAssistant = msg.role === "assistant" && (!msg.content || !msg.content.trim()) && msg.toolCalls && msg.toolCalls.length > 0;
49159
+ if (isToolOnlyAssistant) {
49160
+ currentToolGroup.push(msg);
49161
+ } else {
49162
+ if (currentToolGroup.length > 0) {
49163
+ if (currentToolGroup.length === 1) {
49164
+ groups.push({ type: "single", message: currentToolGroup[0] });
49165
+ } else {
49166
+ groups.push({ type: "grouped", messages: currentToolGroup });
49167
+ }
49168
+ currentToolGroup = [];
49169
+ }
49170
+ groups.push({ type: "single", message: msg });
49171
+ }
49172
+ }
49173
+ if (currentToolGroup.length > 0) {
49174
+ if (currentToolGroup.length === 1) {
49175
+ groups.push({ type: "single", message: currentToolGroup[0] });
49176
+ } else {
49177
+ groups.push({ type: "grouped", messages: currentToolGroup });
49178
+ }
49179
+ }
49180
+ return groups;
49181
+ }
49110
49182
 
49111
49183
  // packages/terminal/src/components/Messages.tsx
49112
49184
  var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
@@ -49144,7 +49216,7 @@ function Messages3({
49144
49216
  const lineSpans = import_react24.useMemo(() => {
49145
49217
  let cursor = 0;
49146
49218
  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);
49219
+ const lines = item.kind === "activity" ? estimateActivityEntryLines(item.entry, wrapWidth, messageWidth) : item.kind === "grouped" ? estimateGroupedToolMessagesLines(item.messages, messageWidth) : estimateMessageLines(item.message, messageWidth);
49148
49220
  const start = cursor;
49149
49221
  cursor += lines;
49150
49222
  return { item, index, start, end: cursor, lines };
@@ -49308,34 +49380,6 @@ function formatDuration(ms) {
49308
49380
  const secs = totalSeconds % 60;
49309
49381
  return `${mins}m ${secs}s`;
49310
49382
  }
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
49383
  function CombinedToolMessage({ messages }) {
49340
49384
  const allToolCalls = [];
49341
49385
  const allToolResults = [];
@@ -49355,27 +49399,6 @@ function CombinedToolMessage({ messages }) {
49355
49399
  }, undefined, false, undefined, this)
49356
49400
  }, undefined, false, undefined, this);
49357
49401
  }
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
49402
  function MessageBubble({ message, queuedMessageIds }) {
49380
49403
  const isUser = message.role === "user";
49381
49404
  const isSystem = message.role === "system";
@@ -50733,6 +50756,7 @@ function App2({ cwd: cwd2, version }) {
50733
50756
  }, [activityLog, renderWidth, wrapChars]);
50734
50757
  const reservedLines = import_react29.useMemo(() => {
50735
50758
  let lines = 0;
50759
+ const wrapWidth = Math.max(1, (columns ?? 80) - 2);
50736
50760
  lines += 2;
50737
50761
  if (showWelcome) {
50738
50762
  lines += 4;
@@ -50748,16 +50772,23 @@ function App2({ cwd: cwd2, version }) {
50748
50772
  const hasMore = activeQueue.length + inlineCount > MAX_QUEUED_PREVIEW;
50749
50773
  lines += 2;
50750
50774
  lines += 1;
50751
- lines += previewCount;
50775
+ const previewWidth = Math.max(1, wrapWidth - 2);
50776
+ const previewItems = [...activeInline, ...activeQueue].slice(0, MAX_QUEUED_PREVIEW);
50777
+ const previewLines = previewItems.reduce((sum, queued) => {
50778
+ const label = queued.mode === "inline" ? "\u21B3" : "\u23F3";
50779
+ const text = `${label} ${truncateQueued(queued.content)}`;
50780
+ return sum + countWrappedLines2([text], previewWidth);
50781
+ }, 0);
50782
+ lines += Math.max(previewCount, previewLines);
50752
50783
  if (hasMore)
50753
50784
  lines += 1;
50754
50785
  }
50755
50786
  if (error2) {
50756
50787
  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;
50788
+ const messageLines = parsed.message ? countWrappedLines2(parsed.message.split(`
50789
+ `), wrapWidth) : 1;
50790
+ const suggestionLines = parsed.suggestion ? countWrappedLines2(parsed.suggestion.split(`
50791
+ `), wrapWidth) : 0;
50761
50792
  lines += 2;
50762
50793
  lines += Math.max(1, messageLines) + suggestionLines;
50763
50794
  }
@@ -50778,7 +50809,8 @@ function App2({ cwd: cwd2, version }) {
50778
50809
  scrollOffset,
50779
50810
  error2,
50780
50811
  isProcessing,
50781
- showWelcome
50812
+ showWelcome,
50813
+ columns
50782
50814
  ]);
50783
50815
  const displayMessages = import_react29.useMemo(() => buildDisplayMessages(messages, MESSAGE_CHUNK_LINES, wrapChars, { maxWidth: renderWidth }), [messages, wrapChars, renderWidth]);
50784
50816
  const streamingMessages = import_react29.useMemo(() => {
@@ -50793,8 +50825,15 @@ function App2({ cwd: cwd2, version }) {
50793
50825
  return buildDisplayMessages([streamingMessage], MESSAGE_CHUNK_LINES, wrapChars, { maxWidth: renderWidth });
50794
50826
  }, [currentResponse, isProcessing, wrapChars, renderWidth]);
50795
50827
  const displayLineCount = import_react29.useMemo(() => {
50796
- const combined = [...displayMessages, ...streamingMessages];
50797
- return combined.reduce((sum, msg) => sum + estimateMessageLines(msg, renderWidth), 0);
50828
+ const grouped = groupConsecutiveToolMessages(displayMessages);
50829
+ const groupedLines = grouped.reduce((sum, group) => {
50830
+ if (group.type === "single") {
50831
+ return sum + estimateMessageLines(group.message, renderWidth);
50832
+ }
50833
+ return sum + estimateGroupedToolMessagesLines(group.messages, renderWidth);
50834
+ }, 0);
50835
+ const streamingLines = streamingMessages.reduce((sum, msg) => sum + estimateMessageLines(msg, renderWidth), 0);
50836
+ return groupedLines + streamingLines;
50798
50837
  }, [displayMessages, streamingMessages, renderWidth]);
50799
50838
  const totalLineCount = displayLineCount + activityLogLineCount;
50800
50839
  import_react29.useEffect(() => {
@@ -51379,7 +51418,7 @@ function formatStreamEvent(chunk) {
51379
51418
 
51380
51419
  // packages/terminal/src/index.tsx
51381
51420
  var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
51382
- var VERSION3 = "0.6.35";
51421
+ var VERSION3 = "0.6.37";
51383
51422
  process.env.ASSISTANTS_VERSION ??= VERSION3;
51384
51423
  function parseArgs(argv) {
51385
51424
  const args = argv.slice(2);
@@ -51535,4 +51574,4 @@ if (options.print !== null) {
51535
51574
  });
51536
51575
  }
51537
51576
 
51538
- //# debugId=2F2CC5B1781D557164756E2164756E21
51577
+ //# debugId=883CA92CA3B9183064756E2164756E21