@inetafrica/open-claudia 1.4.3 → 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 +26 -11
- 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);
|
|
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(); }
|
|
@@ -676,11 +689,8 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
676
689
|
clearInterval(streamInterval); streamInterval = null;
|
|
677
690
|
const finalText = assistantText || "(no output)";
|
|
678
691
|
const chunks = splitMessage(finalText);
|
|
679
|
-
//
|
|
692
|
+
// Keep the streaming progress message and send final result as a new message
|
|
680
693
|
// This ensures the user gets a notification for the final answer
|
|
681
|
-
if (statusMessageId) {
|
|
682
|
-
await deleteMessage(statusMessageId);
|
|
683
|
-
}
|
|
684
694
|
await send(chunks[0], { replyTo: replyToMsgId });
|
|
685
695
|
for (let i = 1; i < chunks.length; i++) {
|
|
686
696
|
await send(chunks[i]);
|
|
@@ -727,13 +737,18 @@ async function runClaudeSilent(prompt, cwd, label) {
|
|
|
727
737
|
});
|
|
728
738
|
}
|
|
729
739
|
|
|
730
|
-
function formatProgress(text, tools, currentTool) {
|
|
740
|
+
function formatProgress(text, tools, currentTool, elapsed, toolDetail) {
|
|
741
|
+
const mins = Math.floor(elapsed / 60);
|
|
742
|
+
const secs = elapsed % 60;
|
|
743
|
+
const time = mins > 0 ? `${mins}m ${secs}s` : `${secs}s`;
|
|
744
|
+
|
|
731
745
|
const parts = [];
|
|
732
|
-
|
|
733
|
-
if (
|
|
746
|
+
let status = currentTool ? `Working: ${currentTool}` : (tools.length > 0 ? "Processing..." : "Thinking...");
|
|
747
|
+
if (currentTool && toolDetail) status += ` — ${toolDetail}`;
|
|
748
|
+
parts.push(`${status} (${time})`);
|
|
749
|
+
if (tools.length > 1) parts.push(`Steps: ${[...new Set(tools)].join(" > ")}`);
|
|
734
750
|
if (text) parts.push(text.length > 800 ? "..." + text.slice(-800) : text);
|
|
735
|
-
|
|
736
|
-
return parts.join("\n\n") || "Thinking...";
|
|
751
|
+
return parts.join("\n\n");
|
|
737
752
|
}
|
|
738
753
|
|
|
739
754
|
// ── Cron System ─────────────────────────────────────────────────────
|