@hasna/assistants 0.6.31 → 0.6.32

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
@@ -36645,6 +36645,8 @@ class AgentContext {
36645
36645
  return message;
36646
36646
  }
36647
36647
  extractPdfAttachment(content) {
36648
+ if (!content)
36649
+ return null;
36648
36650
  try {
36649
36651
  const parsed = JSON.parse(content);
36650
36652
  if (parsed && parsed.__pdf_attachment__ === true) {
@@ -36682,7 +36684,8 @@ class AgentContext {
36682
36684
  this.messages = this.messages.filter((msg) => {
36683
36685
  if (msg.role !== "system")
36684
36686
  return true;
36685
- return !predicate(msg.content);
36687
+ const content = msg.content ?? "";
36688
+ return !predicate(content);
36686
36689
  });
36687
36690
  }
36688
36691
  getMessages() {
@@ -36700,13 +36703,13 @@ class AgentContext {
36700
36703
  }
36701
36704
  const systemMessages = this.messages.filter((m) => m.role === "system");
36702
36705
  const nonSystemMessages = this.messages.filter((m) => m.role !== "system");
36703
- const targetCount = this.maxMessages - systemMessages.length;
36704
- let recentMessages = nonSystemMessages.slice(-targetCount);
36706
+ const targetCount = Math.max(0, this.maxMessages - systemMessages.length);
36707
+ let recentMessages = targetCount > 0 ? nonSystemMessages.slice(-targetCount) : [];
36705
36708
  while (recentMessages.length > 0 && recentMessages[0].toolResults) {
36706
36709
  const firstIndex = nonSystemMessages.indexOf(recentMessages[0]);
36707
36710
  if (firstIndex > 0) {
36708
36711
  recentMessages = nonSystemMessages.slice(firstIndex - 1);
36709
- if (recentMessages.length > targetCount + 1) {
36712
+ if (recentMessages.length > targetCount + 1 && targetCount > 0) {
36710
36713
  recentMessages = recentMessages.slice(-(targetCount + 1));
36711
36714
  }
36712
36715
  } else {
@@ -36903,7 +36906,8 @@ ${summary}`,
36903
36906
  };
36904
36907
  }
36905
36908
  isSummaryMessage(message) {
36906
- return message.role === "system" && message.content.trim().startsWith(SUMMARY_TAG);
36909
+ const content = message.content ?? "";
36910
+ return message.role === "system" && content.trim().startsWith(SUMMARY_TAG);
36907
36911
  }
36908
36912
  partitionMessages(messages) {
36909
36913
  const keepRecent = Math.max(0, this.config.keepRecentMessages);
@@ -37047,7 +37051,8 @@ class HybridSummarizer {
37047
37051
  const paths = new Set;
37048
37052
  const pathRegex = /(?:\.?\/|[A-Za-z]:\\)[\w\-.\/\\]+\.[A-Za-z0-9]+/g;
37049
37053
  for (const msg of messages) {
37050
- const matches = msg.content.match(pathRegex);
37054
+ const content = msg.content ?? "";
37055
+ const matches = content.match(pathRegex);
37051
37056
  if (matches) {
37052
37057
  for (const match of matches) {
37053
37058
  paths.add(match.replace(/\\/g, "/"));
@@ -37059,7 +37064,8 @@ class HybridSummarizer {
37059
37064
  extractCommands(messages) {
37060
37065
  const commands = new Set;
37061
37066
  for (const msg of messages) {
37062
- const lines = msg.content.split(`
37067
+ const content = msg.content ?? "";
37068
+ const lines = content.split(`
37063
37069
  `);
37064
37070
  for (const line of lines) {
37065
37071
  const trimmed = line.trim();
@@ -37084,7 +37090,8 @@ class HybridSummarizer {
37084
37090
  extractErrors(messages) {
37085
37091
  const errors = new Set;
37086
37092
  for (const msg of messages) {
37087
- const lines = msg.content.split(`
37093
+ const content = msg.content ?? "";
37094
+ const lines = content.split(`
37088
37095
  `);
37089
37096
  for (const line of lines) {
37090
37097
  if (/error|failed|exception/i.test(line)) {
@@ -41187,11 +41194,11 @@ function summarizeConversation(messages) {
41187
41194
  if (msg.role === "user") {
41188
41195
  if (msg.toolResults && msg.toolResults.length > 0) {
41189
41196
  for (const result of msg.toolResults) {
41190
- const content = result.content.slice(0, 500);
41197
+ const content = (result.content || "").slice(0, 500);
41191
41198
  summary.push(`[Tool Result - ${result.toolName || "unknown"}]: ${content}`);
41192
41199
  }
41193
41200
  } else {
41194
- summary.push(`User: ${msg.content.slice(0, 300)}`);
41201
+ summary.push(`User: ${(msg.content ?? "").slice(0, 300)}`);
41195
41202
  }
41196
41203
  } else if (msg.role === "assistant") {
41197
41204
  if (msg.toolCalls && msg.toolCalls.length > 0) {
@@ -41200,8 +41207,9 @@ function summarizeConversation(messages) {
41200
41207
  summary.push(`[Tool Call - ${call.name}]: ${input}`);
41201
41208
  }
41202
41209
  }
41203
- if (msg.content.trim()) {
41204
- summary.push(`Assistant: ${msg.content.slice(0, 300)}`);
41210
+ const assistantContent = msg.content ?? "";
41211
+ if (assistantContent.trim()) {
41212
+ summary.push(`Assistant: ${assistantContent.slice(0, 300)}`);
41205
41213
  }
41206
41214
  }
41207
41215
  }
@@ -46662,7 +46670,7 @@ ${this.identityContext}`);
46662
46670
  for (const msg of messages) {
46663
46671
  if (msg.role !== "system")
46664
46672
  continue;
46665
- const content = msg.content.trim();
46673
+ const content = (msg.content ?? "").trim();
46666
46674
  if (!content)
46667
46675
  continue;
46668
46676
  if (parts.includes(content))
@@ -47543,6 +47551,13 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
47543
47551
  return skills.filter((skill) => skill.name.toLowerCase().startsWith(search));
47544
47552
  }, [value, autocompleteMode, skills]);
47545
47553
  const autocompleteItems = autocompleteMode === "skill" ? filteredSkills : filteredCommands;
47554
+ import_react23.useEffect(() => {
47555
+ if (autocompleteItems.length === 0) {
47556
+ setSelectedIndex(0);
47557
+ return;
47558
+ }
47559
+ setSelectedIndex((prev) => Math.min(prev, autocompleteItems.length - 1));
47560
+ }, [autocompleteItems.length]);
47546
47561
  use_input_default((input, key) => {
47547
47562
  if (key.tab) {
47548
47563
  if (autocompleteItems.length > 0) {
@@ -47642,7 +47657,7 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
47642
47657
  children: [
47643
47658
  /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
47644
47659
  children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
47645
- dimColor: true,
47660
+ color: "gray",
47646
47661
  children: "\u2500".repeat(terminalWidth)
47647
47662
  }, undefined, false, undefined, this)
47648
47663
  }, undefined, false, undefined, this),
@@ -47650,8 +47665,7 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
47650
47665
  paddingY: 0,
47651
47666
  children: [
47652
47667
  /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
47653
- dimColor: isProcessing,
47654
- color: isProcessing ? undefined : "cyan",
47668
+ color: isProcessing ? "gray" : "cyan",
47655
47669
  children: "> "
47656
47670
  }, undefined, false, undefined, this),
47657
47671
  /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
@@ -47668,7 +47682,7 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
47668
47682
  lineCount > 1 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
47669
47683
  marginLeft: 2,
47670
47684
  children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
47671
- dimColor: true,
47685
+ color: "gray",
47672
47686
  children: [
47673
47687
  "(",
47674
47688
  lineCount,
@@ -47678,7 +47692,7 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
47678
47692
  }, undefined, false, undefined, this),
47679
47693
  /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
47680
47694
  children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
47681
- dimColor: true,
47695
+ color: "gray",
47682
47696
  children: "\u2500".repeat(terminalWidth)
47683
47697
  }, undefined, false, undefined, this)
47684
47698
  }, undefined, false, undefined, this),
@@ -50964,7 +50978,7 @@ function formatStreamEvent(chunk) {
50964
50978
 
50965
50979
  // packages/terminal/src/index.tsx
50966
50980
  var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
50967
- var VERSION3 = "0.6.31";
50981
+ var VERSION3 = "0.6.32";
50968
50982
  process.env.ASSISTANTS_VERSION ??= VERSION3;
50969
50983
  function parseArgs(argv) {
50970
50984
  const args = argv.slice(2);
@@ -51120,4 +51134,4 @@ if (options.print !== null) {
51120
51134
  });
51121
51135
  }
51122
51136
 
51123
- //# debugId=656AEF3B850A245D64756E2164756E21
51137
+ //# debugId=E7E53BFBEA38084764756E2164756E21