@hasna/assistants 0.6.30 → 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 +69 -40
- package/dist/index.js.map +11 -11
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
41204
|
-
|
|
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) {
|
|
@@ -47631,6 +47646,8 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
|
|
|
47631
47646
|
};
|
|
47632
47647
|
const visibleSkills = getVisibleItems(filteredSkills);
|
|
47633
47648
|
const visibleCommands = getVisibleItems(filteredCommands);
|
|
47649
|
+
const { stdout } = use_stdout_default();
|
|
47650
|
+
const terminalWidth = stdout?.columns ?? 80;
|
|
47634
47651
|
const lines = value.split(`
|
|
47635
47652
|
`);
|
|
47636
47653
|
const lineCount = lines.length;
|
|
@@ -47640,16 +47657,15 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
|
|
|
47640
47657
|
children: [
|
|
47641
47658
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
47642
47659
|
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
47643
|
-
|
|
47644
|
-
children: "\u2500".repeat(
|
|
47660
|
+
color: "gray",
|
|
47661
|
+
children: "\u2500".repeat(terminalWidth)
|
|
47645
47662
|
}, undefined, false, undefined, this)
|
|
47646
47663
|
}, undefined, false, undefined, this),
|
|
47647
47664
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
47648
47665
|
paddingY: 0,
|
|
47649
47666
|
children: [
|
|
47650
47667
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
47651
|
-
|
|
47652
|
-
color: isProcessing ? undefined : "cyan",
|
|
47668
|
+
color: isProcessing ? "gray" : "cyan",
|
|
47653
47669
|
children: "> "
|
|
47654
47670
|
}, undefined, false, undefined, this),
|
|
47655
47671
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
@@ -47666,7 +47682,7 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
|
|
|
47666
47682
|
lineCount > 1 && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
47667
47683
|
marginLeft: 2,
|
|
47668
47684
|
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
47669
|
-
|
|
47685
|
+
color: "gray",
|
|
47670
47686
|
children: [
|
|
47671
47687
|
"(",
|
|
47672
47688
|
lineCount,
|
|
@@ -47676,8 +47692,8 @@ function Input({ onSubmit, isProcessing, queueLength = 0, commands, skills = []
|
|
|
47676
47692
|
}, undefined, false, undefined, this),
|
|
47677
47693
|
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
47678
47694
|
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
47679
|
-
|
|
47680
|
-
children: "\u2500".repeat(
|
|
47695
|
+
color: "gray",
|
|
47696
|
+
children: "\u2500".repeat(terminalWidth)
|
|
47681
47697
|
}, undefined, false, undefined, this)
|
|
47682
47698
|
}, undefined, false, undefined, this),
|
|
47683
47699
|
isProcessing && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
@@ -48688,7 +48704,9 @@ function estimateMessageLines(message, maxWidth) {
|
|
|
48688
48704
|
const contentLines = content.length > 0 ? content.split(`
|
|
48689
48705
|
`) : [];
|
|
48690
48706
|
const hasContent = contentLines.length > 0;
|
|
48691
|
-
const
|
|
48707
|
+
const prefixWidth = message.role === "user" || message.role === "assistant" ? 2 : 0;
|
|
48708
|
+
const effectiveWidth = maxWidth ? Math.max(1, maxWidth - prefixWidth) : maxWidth;
|
|
48709
|
+
const wrappedLines = contentLines.length > 0 ? countWrappedLines(contentLines, effectiveWidth) : 0;
|
|
48692
48710
|
let lines = hasContent ? Math.max(1, wrappedLines) : 0;
|
|
48693
48711
|
if (message.role === "assistant" && message.toolCalls?.length) {
|
|
48694
48712
|
lines += estimateToolPanelLines(message.toolCalls, message.toolResults, hasContent);
|
|
@@ -48716,6 +48734,7 @@ function stripAnsi4(text) {
|
|
|
48716
48734
|
return text.replace(/\x1B\[[0-9;]*m/g, "");
|
|
48717
48735
|
}
|
|
48718
48736
|
function estimateActivityEntryLines(entry, wrapWidth, renderWidth) {
|
|
48737
|
+
const effectiveWidth = Math.max(1, wrapWidth - 2);
|
|
48719
48738
|
if (entry.type === "text") {
|
|
48720
48739
|
const content = entry.content ?? "";
|
|
48721
48740
|
if (!content.trim())
|
|
@@ -48723,7 +48742,7 @@ function estimateActivityEntryLines(entry, wrapWidth, renderWidth) {
|
|
|
48723
48742
|
const rendered = renderMarkdown(content, { maxWidth: renderWidth });
|
|
48724
48743
|
const lines = stripAnsi4(rendered).split(`
|
|
48725
48744
|
`);
|
|
48726
|
-
const wrapped = countWrappedLines(lines,
|
|
48745
|
+
const wrapped = countWrappedLines(lines, effectiveWidth);
|
|
48727
48746
|
return Math.max(1, wrapped) + 2;
|
|
48728
48747
|
}
|
|
48729
48748
|
if (entry.type === "tool_call") {
|
|
@@ -48733,7 +48752,7 @@ function estimateActivityEntryLines(entry, wrapWidth, renderWidth) {
|
|
|
48733
48752
|
const content = entry.toolResult ? truncateToolResult(entry.toolResult) : "";
|
|
48734
48753
|
const lines = content.split(`
|
|
48735
48754
|
`);
|
|
48736
|
-
const wrapped = countWrappedLines(lines,
|
|
48755
|
+
const wrapped = countWrappedLines(lines, effectiveWidth);
|
|
48737
48756
|
return Math.max(1, wrapped) + 2;
|
|
48738
48757
|
}
|
|
48739
48758
|
return 0;
|
|
@@ -49861,24 +49880,35 @@ function buildDisplayMessages(messages, chunkLines, wrapChars, options) {
|
|
|
49861
49880
|
display.push(msg);
|
|
49862
49881
|
continue;
|
|
49863
49882
|
}
|
|
49883
|
+
if (msg.role === "assistant") {
|
|
49884
|
+
const rendered = renderMarkdown(content, { maxWidth: options?.maxWidth });
|
|
49885
|
+
const renderedLines = rendered.split(`
|
|
49886
|
+
`);
|
|
49887
|
+
if (renderedLines.length <= chunkLines) {
|
|
49888
|
+
display.push({ ...msg, content: rendered, __rendered: true });
|
|
49889
|
+
continue;
|
|
49890
|
+
}
|
|
49891
|
+
const chunks2 = chunkRenderedLines(renderedLines, chunkLines);
|
|
49892
|
+
for (let i = 0;i < chunks2.length; i++) {
|
|
49893
|
+
const chunkContent = chunks2[i].join(`
|
|
49894
|
+
`);
|
|
49895
|
+
display.push({
|
|
49896
|
+
...msg,
|
|
49897
|
+
id: `${msg.id}::chunk-${i}`,
|
|
49898
|
+
content: chunkContent,
|
|
49899
|
+
__rendered: true,
|
|
49900
|
+
toolCalls: i === chunks2.length - 1 ? msg.toolCalls : undefined,
|
|
49901
|
+
toolResults: i === chunks2.length - 1 ? msg.toolResults : undefined
|
|
49902
|
+
});
|
|
49903
|
+
}
|
|
49904
|
+
continue;
|
|
49905
|
+
}
|
|
49864
49906
|
const lines = wrapTextLines(content, wrapChars);
|
|
49865
49907
|
if (lines.length <= chunkLines) {
|
|
49866
|
-
|
|
49867
|
-
const rendered2 = renderMarkdown(lines.join(`
|
|
49868
|
-
`), { maxWidth: options?.maxWidth });
|
|
49869
|
-
display.push({ ...msg, content: rendered2, __rendered: true });
|
|
49870
|
-
} else {
|
|
49871
|
-
display.push(msg);
|
|
49872
|
-
}
|
|
49908
|
+
display.push(msg);
|
|
49873
49909
|
continue;
|
|
49874
49910
|
}
|
|
49875
|
-
const
|
|
49876
|
-
`);
|
|
49877
|
-
const renderAssistant = msg.role === "assistant";
|
|
49878
|
-
const rendered = renderAssistant ? renderMarkdown(baseContent, { maxWidth: options?.maxWidth }) : baseContent;
|
|
49879
|
-
const renderedLines = rendered.split(`
|
|
49880
|
-
`);
|
|
49881
|
-
const chunks = chunkRenderedLines(renderedLines, chunkLines);
|
|
49911
|
+
const chunks = chunkRenderedLines(lines, chunkLines);
|
|
49882
49912
|
for (let i = 0;i < chunks.length; i++) {
|
|
49883
49913
|
const chunkContent = chunks[i].join(`
|
|
49884
49914
|
`);
|
|
@@ -49886,7 +49916,6 @@ function buildDisplayMessages(messages, chunkLines, wrapChars, options) {
|
|
|
49886
49916
|
...msg,
|
|
49887
49917
|
id: `${msg.id}::chunk-${i}`,
|
|
49888
49918
|
content: chunkContent,
|
|
49889
|
-
__rendered: renderAssistant,
|
|
49890
49919
|
toolCalls: i === chunks.length - 1 ? msg.toolCalls : undefined,
|
|
49891
49920
|
toolResults: i === chunks.length - 1 ? msg.toolResults : undefined
|
|
49892
49921
|
});
|
|
@@ -50949,7 +50978,7 @@ function formatStreamEvent(chunk) {
|
|
|
50949
50978
|
|
|
50950
50979
|
// packages/terminal/src/index.tsx
|
|
50951
50980
|
var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
|
|
50952
|
-
var VERSION3 = "0.6.
|
|
50981
|
+
var VERSION3 = "0.6.32";
|
|
50953
50982
|
process.env.ASSISTANTS_VERSION ??= VERSION3;
|
|
50954
50983
|
function parseArgs(argv) {
|
|
50955
50984
|
const args = argv.slice(2);
|
|
@@ -51105,4 +51134,4 @@ if (options.print !== null) {
|
|
|
51105
51134
|
});
|
|
51106
51135
|
}
|
|
51107
51136
|
|
|
51108
|
-
//# debugId=
|
|
51137
|
+
//# debugId=E7E53BFBEA38084764756E2164756E21
|