claude-notification-plugin 1.1.88 → 1.1.90
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/.claude-plugin/plugin.json +1 -1
- package/commit-sha +1 -1
- package/listener/listener.js +51 -5
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-notification-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.90",
|
|
4
4
|
"description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Viacheslav Makarov",
|
package/commit-sha
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3ff3888c80833878b3240fd6344ed8f5d3d06c17
|
package/listener/listener.js
CHANGED
|
@@ -172,14 +172,57 @@ for (const alias of Object.keys(listenerConfig.projects)) {
|
|
|
172
172
|
// WATCHDOG + ORPHAN RECOVERY
|
|
173
173
|
// ----------------------
|
|
174
174
|
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
// Wall-clock watchdog: kills PTY sessions whose active task exceeded taskTimeout
|
|
176
|
+
// since startedAt. Complements the inactivity-based marker timeout in pty-runner —
|
|
177
|
+
// catches the case where Claude keeps emitting bytes (update checks, spinners)
|
|
178
|
+
// but never produces a Stop hook signal, so inactivity never accumulates.
|
|
179
|
+
async function runWatchdog () {
|
|
180
|
+
for (const [workDir, entry] of Object.entries(queue.queues)) {
|
|
181
|
+
if (!entry.active) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const startedAt = entry.active.startedAt ? new Date(entry.active.startedAt).getTime() : 0;
|
|
185
|
+
if (startedAt <= 0 || (Date.now() - startedAt) <= taskTimeout) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const task = entry.active;
|
|
189
|
+
const label = formatLabel(entry);
|
|
190
|
+
const elapsedMin = Math.round((Date.now() - startedAt) / 60000);
|
|
191
|
+
const timeoutMin = Math.round(taskTimeout / 60000);
|
|
192
|
+
logger.warn(`Watchdog: stale task "${task.id}" in ${workDir} (${elapsedMin}min) — killing PTY`);
|
|
193
|
+
if (runner.isRunning(workDir)) {
|
|
194
|
+
try {
|
|
195
|
+
runner.cancel(workDir);
|
|
196
|
+
} catch (err) {
|
|
197
|
+
logger.error(`Watchdog: cancel PTY failed in ${workDir}: ${err.message}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
stopLiveConsole(workDir);
|
|
201
|
+
runner.cleanActivitySignal(workDir);
|
|
202
|
+
try {
|
|
203
|
+
if (task.runningMessageId) {
|
|
204
|
+
await poller.deleteMessage(task.runningMessageId);
|
|
205
|
+
}
|
|
206
|
+
const header = `⏰ <code>${label}</code>\nTask forcefully stopped — exceeded ${timeoutMin} min wall-clock limit`;
|
|
207
|
+
const sentId = await poller.sendMessage(header, task.telegramMessageId);
|
|
208
|
+
if (!sentId && task.telegramMessageId) {
|
|
209
|
+
await poller.sendMessage(`${header}: ${escapeHtml(task.text)}`);
|
|
210
|
+
}
|
|
211
|
+
} catch (err) {
|
|
212
|
+
logger.error(`Watchdog: notify failed: ${err.message}`);
|
|
213
|
+
}
|
|
214
|
+
const next = queue.onTaskComplete(workDir, 'STALE (watchdog cleanup)');
|
|
215
|
+
if (next) {
|
|
216
|
+
startTask(workDir, next);
|
|
217
|
+
}
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
|
|
221
|
+
// 1. Initial watchdog sweep on startup. Must finish before orphan recovery,
|
|
222
|
+
// otherwise orphan recovery sees the stale active (still set) and re-spawns
|
|
223
|
+
// the killed task while watchdog is still awaiting its Telegram notify.
|
|
224
|
+
await runWatchdog();
|
|
225
|
+
|
|
183
226
|
// 2. Re-start orphaned active tasks (PTY sessions lost on restart)
|
|
184
227
|
for (const [workDir, entry] of Object.entries(queue.queues)) {
|
|
185
228
|
if (entry.active && !runner.isRunning(workDir)) {
|
|
@@ -188,6 +231,9 @@ for (const [workDir, entry] of Object.entries(queue.queues)) {
|
|
|
188
231
|
}
|
|
189
232
|
}
|
|
190
233
|
|
|
234
|
+
// 3. Periodic watchdog — wall-clock check every minute
|
|
235
|
+
setInterval(runWatchdog, 60_000);
|
|
236
|
+
|
|
191
237
|
// ----------------------
|
|
192
238
|
// TASK RUNNER EVENTS
|
|
193
239
|
// ----------------------
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-notification-plugin",
|
|
3
3
|
"productName": "claude-notification-plugin",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.90",
|
|
5
5
|
"description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|