@inetafrica/open-claudia 1.3.2 → 1.3.4
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 +42 -2
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -480,6 +480,8 @@ ${lastSessionId ? "Resuming conversation — you have prior context." : "New con
|
|
|
480
480
|
- When asked about yourself, you are Open Claudia — an AI coding assistant running Claude Code via Telegram.
|
|
481
481
|
- If a task will take a while, let the user know upfront.
|
|
482
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.
|
|
483
485
|
`.trim();
|
|
484
486
|
}
|
|
485
487
|
|
|
@@ -623,13 +625,17 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
623
625
|
cwd,
|
|
624
626
|
env: { ...process.env, PATH: FULL_PATH, HOME: process.env.HOME },
|
|
625
627
|
stdio: ["ignore", "pipe", "pipe"],
|
|
628
|
+
detached: process.platform !== "win32", // Create process group so /stop kills children too
|
|
626
629
|
});
|
|
627
630
|
|
|
628
631
|
runningProcess = proc;
|
|
632
|
+
const startTime = Date.now();
|
|
633
|
+
let longRunningNotified = false;
|
|
629
634
|
|
|
630
635
|
let lastUpdate = "";
|
|
631
636
|
streamInterval = setInterval(async () => {
|
|
632
637
|
bot.sendChatAction(CHAT_ID, "typing");
|
|
638
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
633
639
|
const display = formatProgress(assistantText, toolUses, currentTool);
|
|
634
640
|
if (display && display !== lastUpdate) {
|
|
635
641
|
if (!statusMessageId && assistantText) {
|
|
@@ -639,6 +645,11 @@ async function runClaude(prompt, cwd, replyToMsgId, opts = {}) {
|
|
|
639
645
|
}
|
|
640
646
|
lastUpdate = display;
|
|
641
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
|
+
}
|
|
642
653
|
}, 1500);
|
|
643
654
|
|
|
644
655
|
proc.stdout.on("data", (data) => {
|
|
@@ -823,7 +834,20 @@ bot.onText(/\/restart$/, async (msg) => {
|
|
|
823
834
|
|
|
824
835
|
bot.onText(/\/upgrade$/, async (msg) => {
|
|
825
836
|
if (!isOwner(msg)) return;
|
|
826
|
-
|
|
837
|
+
// Check if there's actually a newer version
|
|
838
|
+
try {
|
|
839
|
+
const latest = execSync("npm view @inetafrica/open-claudia version", {
|
|
840
|
+
encoding: "utf-8", timeout: 15000,
|
|
841
|
+
env: { ...process.env, PATH: FULL_PATH, HOME: process.env.HOME || require("os").homedir() },
|
|
842
|
+
}).trim();
|
|
843
|
+
if (latest === CURRENT_VERSION) {
|
|
844
|
+
await send(`Already on the latest version (v${CURRENT_VERSION}).`);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
await send(`Upgrading v${CURRENT_VERSION} → v${latest}...`);
|
|
848
|
+
} catch (e) {
|
|
849
|
+
await send("Upgrading...");
|
|
850
|
+
}
|
|
827
851
|
try {
|
|
828
852
|
execSync("npm install -g @inetafrica/open-claudia@latest 2>&1", {
|
|
829
853
|
encoding: "utf-8", timeout: 120000,
|
|
@@ -898,7 +922,23 @@ bot.onText(/\/worktree$/, (msg) => { if (!isAuthorized(msg)) return; settings.wo
|
|
|
898
922
|
|
|
899
923
|
bot.onText(/\/stop/, async (msg) => {
|
|
900
924
|
if (!isAuthorized(msg)) return;
|
|
901
|
-
if (runningProcess) {
|
|
925
|
+
if (runningProcess) {
|
|
926
|
+
const pid = runningProcess.pid;
|
|
927
|
+
try {
|
|
928
|
+
// Kill entire process group to catch child processes (dev servers, etc.)
|
|
929
|
+
process.kill(-pid, "SIGTERM");
|
|
930
|
+
} catch (e) {
|
|
931
|
+
try { runningProcess.kill("SIGTERM"); } catch (e2) {}
|
|
932
|
+
}
|
|
933
|
+
// Force kill after 3 seconds if still alive
|
|
934
|
+
setTimeout(() => {
|
|
935
|
+
try { process.kill(-pid, "SIGKILL"); } catch (e) {}
|
|
936
|
+
}, 3000);
|
|
937
|
+
runningProcess = null;
|
|
938
|
+
if (streamInterval) clearInterval(streamInterval);
|
|
939
|
+
messageQueue = [];
|
|
940
|
+
await send("Cancelled.");
|
|
941
|
+
}
|
|
902
942
|
else await send("Nothing running.");
|
|
903
943
|
});
|
|
904
944
|
|