@inetafrica/open-claudia 1.4.4 → 1.4.5
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/bot.js +19 -5
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -619,6 +619,7 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
619
619
|
let assistantText = "";
|
|
620
620
|
let toolUses = [];
|
|
621
621
|
let currentTool = null;
|
|
622
|
+
let currentToolDetail = "";
|
|
622
623
|
|
|
623
624
|
const args = buildClaudeArgs(prompt, opts);
|
|
624
625
|
const proc = spawn(CLAUDE_PATH, args, {
|
|
@@ -636,7 +637,7 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
636
637
|
streamInterval = setInterval(async () => {
|
|
637
638
|
bot.sendChatAction(CHAT_ID, "typing");
|
|
638
639
|
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
639
|
-
const display = formatProgress(assistantText, toolUses, currentTool, elapsed);
|
|
640
|
+
const display = formatProgress(assistantText, toolUses, currentTool, elapsed, currentToolDetail);
|
|
640
641
|
if (display && display !== lastUpdate) {
|
|
641
642
|
if (!statusMessageId && assistantText) {
|
|
642
643
|
statusMessageId = await send(display.length > 4000 ? display.slice(-4000) : display, { replyTo: replyToMsgId });
|
|
@@ -661,7 +662,19 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
661
662
|
if (evt.type === "assistant" && evt.message?.content) {
|
|
662
663
|
for (const block of evt.message.content) {
|
|
663
664
|
if (block.type === "text") assistantText += block.text;
|
|
664
|
-
else if (block.type === "tool_use") {
|
|
665
|
+
else if (block.type === "tool_use") {
|
|
666
|
+
currentTool = block.name;
|
|
667
|
+
toolUses.push(block.name);
|
|
668
|
+
// Extract useful detail from tool input
|
|
669
|
+
const input = block.input || {};
|
|
670
|
+
if (block.name === "Bash" && input.command) currentToolDetail = input.command.slice(0, 80);
|
|
671
|
+
else if (block.name === "Read" && input.file_path) currentToolDetail = input.file_path.split("/").slice(-2).join("/");
|
|
672
|
+
else if (block.name === "Edit" && input.file_path) currentToolDetail = input.file_path.split("/").slice(-2).join("/");
|
|
673
|
+
else if (block.name === "Write" && input.file_path) currentToolDetail = input.file_path.split("/").slice(-2).join("/");
|
|
674
|
+
else if (block.name === "Grep" && input.pattern) currentToolDetail = input.pattern.slice(0, 40);
|
|
675
|
+
else if (block.name === "Glob" && input.pattern) currentToolDetail = input.pattern;
|
|
676
|
+
else currentToolDetail = "";
|
|
677
|
+
}
|
|
665
678
|
}
|
|
666
679
|
}
|
|
667
680
|
if (evt.type === "result" && evt.session_id) { lastSessionId = evt.session_id; saveState(); }
|
|
@@ -724,15 +737,16 @@ async function runClaudeSilent(prompt, cwd, label) {
|
|
|
724
737
|
});
|
|
725
738
|
}
|
|
726
739
|
|
|
727
|
-
function formatProgress(text, tools, currentTool, elapsed) {
|
|
740
|
+
function formatProgress(text, tools, currentTool, elapsed, toolDetail) {
|
|
728
741
|
const mins = Math.floor(elapsed / 60);
|
|
729
742
|
const secs = elapsed % 60;
|
|
730
743
|
const time = mins > 0 ? `${mins}m ${secs}s` : `${secs}s`;
|
|
731
744
|
|
|
732
745
|
const parts = [];
|
|
733
|
-
|
|
746
|
+
let status = currentTool ? `Working: ${currentTool}` : (tools.length > 0 ? "Processing..." : "Thinking...");
|
|
747
|
+
if (currentTool && toolDetail) status += ` — ${toolDetail}`;
|
|
734
748
|
parts.push(`${status} (${time})`);
|
|
735
|
-
if (tools.length >
|
|
749
|
+
if (tools.length > 1) parts.push(`Steps: ${[...new Set(tools)].join(" > ")}`);
|
|
736
750
|
if (text) parts.push(text.length > 800 ? "..." + text.slice(-800) : text);
|
|
737
751
|
return parts.join("\n\n");
|
|
738
752
|
}
|