@inetafrica/open-claudia 1.3.1 → 1.3.3
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 +49 -7
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -455,6 +455,10 @@ The bot code. Read to understand capabilities. Only modify if explicitly asked.
|
|
|
455
455
|
### ${path.join(BOT_DIR, ".env")}
|
|
456
456
|
Configuration (Telegram token, paths, etc). Sensitive — don't expose values.
|
|
457
457
|
|
|
458
|
+
## Received Files
|
|
459
|
+
Files sent by the user are saved in: ${FILES_DIR}
|
|
460
|
+
${fs.existsSync(FILES_DIR) ? (() => { try { const f = fs.readdirSync(FILES_DIR); return f.length > 0 ? "Current files: " + f.slice(-10).join(", ") : "No files yet."; } catch(e) { return ""; } })() : ""}
|
|
461
|
+
|
|
458
462
|
## Telegram API
|
|
459
463
|
Send things directly to the user:
|
|
460
464
|
|
|
@@ -462,13 +466,22 @@ Text: curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" -d chat
|
|
|
462
466
|
File: curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendDocument" -F chat_id=${CHAT_ID} -F document=@/path/to/file
|
|
463
467
|
Image: curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendPhoto" -F chat_id=${CHAT_ID} -F photo=@/path/to/image.png
|
|
464
468
|
|
|
469
|
+
## Session
|
|
470
|
+
${lastSessionId ? "Resuming conversation — you have prior context." : "New conversation."}
|
|
471
|
+
|
|
465
472
|
## Guidelines
|
|
466
|
-
- Keep responses concise — mobile screen.
|
|
467
|
-
-
|
|
468
|
-
-
|
|
473
|
+
- Keep responses concise — this is a mobile screen.
|
|
474
|
+
- Use Telegram-compatible markdown: *bold*, _italic_, \`code\`, \`\`\`code blocks\`\`\`. No headers (#), no links [text](url).
|
|
475
|
+
- For long output (logs, diffs, large code), save to a file and send via the Telegram API curl above — don't paste walls of text.
|
|
476
|
+
- Act on screenshots (fix bugs, implement designs) — don't just describe what you see.
|
|
477
|
+
- When the user sends a file, it's saved in ${FILES_DIR}. Read it with the Read tool.
|
|
469
478
|
- When asked to remember credentials, tell the user to use /vault.
|
|
470
479
|
- When asked to change your personality, edit ${SOUL_FILE}.
|
|
471
|
-
-
|
|
480
|
+
- When asked about yourself, you are Open Claudia — an AI coding assistant running Claude Code via Telegram.
|
|
481
|
+
- If a task will take a while, let the user know upfront.
|
|
482
|
+
- Don't ask for confirmation on simple tasks — just do them.
|
|
483
|
+
- NEVER start long-running processes (dev servers, watchers, tails) in the foreground. They block all further messages. Instead, run them in the background: \`nohup command &\` or \`command &disown\`. Then report the PID so the user can stop it later.
|
|
484
|
+
- If asked to "start" or "run" a dev server, ALWAYS background it.
|
|
472
485
|
`.trim();
|
|
473
486
|
}
|
|
474
487
|
|
|
@@ -612,13 +625,17 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
612
625
|
cwd,
|
|
613
626
|
env: { ...process.env, PATH: FULL_PATH, HOME: process.env.HOME },
|
|
614
627
|
stdio: ["ignore", "pipe", "pipe"],
|
|
628
|
+
detached: process.platform !== "win32", // Create process group so /stop kills children too
|
|
615
629
|
});
|
|
616
630
|
|
|
617
631
|
runningProcess = proc;
|
|
632
|
+
const startTime = Date.now();
|
|
633
|
+
let longRunningNotified = false;
|
|
618
634
|
|
|
619
635
|
let lastUpdate = "";
|
|
620
636
|
streamInterval = setInterval(async () => {
|
|
621
637
|
bot.sendChatAction(CHAT_ID, "typing");
|
|
638
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
622
639
|
const display = formatProgress(assistantText, toolUses, currentTool);
|
|
623
640
|
if (display && display !== lastUpdate) {
|
|
624
641
|
if (!statusMessageId && assistantText) {
|
|
@@ -628,6 +645,11 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
628
645
|
}
|
|
629
646
|
lastUpdate = display;
|
|
630
647
|
}
|
|
648
|
+
// Notify after 5 minutes that it's still running
|
|
649
|
+
if (elapsed > 300 && !longRunningNotified) {
|
|
650
|
+
longRunningNotified = true;
|
|
651
|
+
await send(`Still working (${Math.floor(elapsed / 60)}min)... Send /stop to cancel.`);
|
|
652
|
+
}
|
|
631
653
|
}, 1500);
|
|
632
654
|
|
|
633
655
|
proc.stdout.on("data", (data) => {
|
|
@@ -654,8 +676,12 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
654
676
|
clearInterval(streamInterval); streamInterval = null;
|
|
655
677
|
const finalText = assistantText || "(no output)";
|
|
656
678
|
const chunks = splitMessage(finalText);
|
|
657
|
-
|
|
658
|
-
|
|
679
|
+
// Edit the streaming message with the first chunk, send rest as new messages
|
|
680
|
+
if (statusMessageId) {
|
|
681
|
+
await editMessage(statusMessageId, chunks[0]);
|
|
682
|
+
} else {
|
|
683
|
+
await send(chunks[0], { replyTo: replyToMsgId });
|
|
684
|
+
}
|
|
659
685
|
for (let i = 1; i < chunks.length; i++) {
|
|
660
686
|
await send(chunks[i]);
|
|
661
687
|
}
|
|
@@ -883,7 +909,23 @@ bot.onText(/\/worktree$/, (msg) => { if (!isAuthorized(msg)) return; settings.wo
|
|
|
883
909
|
|
|
884
910
|
bot.onText(/\/stop/, async (msg) => {
|
|
885
911
|
if (!isAuthorized(msg)) return;
|
|
886
|
-
if (runningProcess) {
|
|
912
|
+
if (runningProcess) {
|
|
913
|
+
const pid = runningProcess.pid;
|
|
914
|
+
try {
|
|
915
|
+
// Kill entire process group to catch child processes (dev servers, etc.)
|
|
916
|
+
process.kill(-pid, "SIGTERM");
|
|
917
|
+
} catch (e) {
|
|
918
|
+
try { runningProcess.kill("SIGTERM"); } catch (e2) {}
|
|
919
|
+
}
|
|
920
|
+
// Force kill after 3 seconds if still alive
|
|
921
|
+
setTimeout(() => {
|
|
922
|
+
try { process.kill(-pid, "SIGKILL"); } catch (e) {}
|
|
923
|
+
}, 3000);
|
|
924
|
+
runningProcess = null;
|
|
925
|
+
if (streamInterval) clearInterval(streamInterval);
|
|
926
|
+
messageQueue = [];
|
|
927
|
+
await send("Cancelled.");
|
|
928
|
+
}
|
|
887
929
|
else await send("Nothing running.");
|
|
888
930
|
});
|
|
889
931
|
|