@gonzih/cc-tg 0.3.3 → 0.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/dist/bot.js +35 -13
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -990,24 +990,46 @@ export class CcTgBot {
|
|
|
990
990
|
await this.bot.sendMessage(chatId, `cc-agent npm version: ${npmVersion}\n\nnpx cache (~/.npm/_npx/):\n${cacheEntries}`);
|
|
991
991
|
}
|
|
992
992
|
async handleClearNpxCache(chatId) {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
993
|
+
const home = process.env.HOME ?? "/tmp";
|
|
994
|
+
const cleared = [];
|
|
995
|
+
const failed = [];
|
|
996
|
+
// Clear both npx execution cache and full npm package cache
|
|
997
|
+
for (const dir of [`${home}/.npm/_npx`, `${home}/.npm/cache`]) {
|
|
998
|
+
try {
|
|
999
|
+
execSync(`rm -rf "${dir}"`, { encoding: "utf8", shell: "/bin/sh" });
|
|
1000
|
+
cleared.push(dir.replace(home, "~"));
|
|
1001
|
+
console.log(`[cache] cleared ${dir}`);
|
|
1002
|
+
}
|
|
1003
|
+
catch (err) {
|
|
1004
|
+
failed.push(dir.replace(home, "~"));
|
|
1005
|
+
console.warn(`[cache] failed to clear ${dir}:`, err.message);
|
|
1006
|
+
}
|
|
1001
1007
|
}
|
|
1002
1008
|
const pids = this.killCcAgent();
|
|
1003
1009
|
const pidNote = pids.length > 0
|
|
1004
|
-
? ` Sent SIGTERM to pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}.`
|
|
1005
|
-
: " No cc-agent
|
|
1006
|
-
|
|
1010
|
+
? ` Sent SIGTERM to cc-agent pid${pids.length > 1 ? "s" : ""}: ${pids.join(", ")}.`
|
|
1011
|
+
: " No cc-agent running.";
|
|
1012
|
+
const clearNote = failed.length
|
|
1013
|
+
? `Cleared: ${cleared.join(", ")}. Failed: ${failed.join(", ")}.`
|
|
1014
|
+
: `Cleared: ${cleared.join(", ")}.`;
|
|
1015
|
+
await this.bot.sendMessage(chatId, `${clearNote}${pidNote} Next call picks up latest npm version.`);
|
|
1007
1016
|
}
|
|
1008
1017
|
async handleRestart(chatId) {
|
|
1009
|
-
await this.bot.sendMessage(chatId, "
|
|
1010
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
1018
|
+
await this.bot.sendMessage(chatId, "Clearing cache and restarting... brb.");
|
|
1019
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
1020
|
+
// Clear npm caches before restart so launchd brings up fresh version
|
|
1021
|
+
const home = process.env.HOME ?? "/tmp";
|
|
1022
|
+
for (const dir of [`${home}/.npm/_npx`, `${home}/.npm/cache`]) {
|
|
1023
|
+
try {
|
|
1024
|
+
execSync(`rm -rf "${dir}"`, { shell: "/bin/sh" });
|
|
1025
|
+
}
|
|
1026
|
+
catch { }
|
|
1027
|
+
}
|
|
1028
|
+
// Kill all active Claude sessions cleanly
|
|
1029
|
+
for (const [cid] of this.sessions) {
|
|
1030
|
+
this.killSession(cid);
|
|
1031
|
+
}
|
|
1032
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
1011
1033
|
process.exit(0);
|
|
1012
1034
|
}
|
|
1013
1035
|
async handleGetFile(chatId, text) {
|