@inetafrica/open-claudia 1.1.4 → 1.1.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.
Files changed (2) hide show
  1. package/bot.js +30 -1
  2. package/package.json +1 -1
package/bot.js CHANGED
@@ -98,9 +98,38 @@ const FULL_PATH = [
98
98
  "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin",
99
99
  ].filter(Boolean).join(":");
100
100
 
101
- const bot = new TelegramBot(TOKEN, { polling: true });
101
+ const bot = new TelegramBot(TOKEN, {
102
+ polling: {
103
+ autoStart: true,
104
+ params: { timeout: 30 },
105
+ },
106
+ });
102
107
  const vault = new Vault(VAULT_FILE);
103
108
 
109
+ // ── Auto-reconnect on polling errors ───────────────────────────────
110
+ let reconnectTimer = null;
111
+ bot.on("polling_error", (err) => {
112
+ const msg = err.message || "";
113
+ console.error("Polling error:", msg);
114
+ if (msg.includes("ETIMEDOUT") || msg.includes("ECONNRESET") || msg.includes("ENOTFOUND") || msg.includes("EFATAL")) {
115
+ if (reconnectTimer) return; // Already scheduled
116
+ console.log("Network lost. Reconnecting in 10s...");
117
+ reconnectTimer = setTimeout(async () => {
118
+ reconnectTimer = null;
119
+ try {
120
+ await bot.stopPolling();
121
+ await new Promise((r) => setTimeout(r, 2000));
122
+ await bot.startPolling();
123
+ console.log("Reconnected.");
124
+ } catch (e) {
125
+ console.error("Reconnect failed:", e.message);
126
+ // launchd will restart us if we exit
127
+ process.exit(1);
128
+ }
129
+ }, 10000);
130
+ }
131
+ });
132
+
104
133
  // ── Commands Menu ───────────────────────────────────────────────────
105
134
  bot.setMyCommands([
106
135
  { command: "session", description: "Pick a project to work on" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inetafrica/open-claudia",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Your always-on AI coding assistant — Claude Code via Telegram",
5
5
  "main": "bot.js",
6
6
  "bin": {