claude-notification-plugin 1.1.41 → 1.1.43
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 +32 -1
- package/listener/pty-runner.js +55 -4
- 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.43",
|
|
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
|
+
b460aaa05a941c411fb010c938655a256ff5ad57
|
package/listener/listener.js
CHANGED
|
@@ -13,6 +13,28 @@ import { WorktreeManager } from './worktree-manager.js';
|
|
|
13
13
|
import { parseMessage, parseTarget } from './message-parser.js';
|
|
14
14
|
import { CLAUDE_DIR, CONFIG_PATH, LISTENER_LOG_FILENAME } from '../bin/constants.js';
|
|
15
15
|
|
|
16
|
+
// ----------------------
|
|
17
|
+
// CRASH PROTECTION
|
|
18
|
+
// ----------------------
|
|
19
|
+
|
|
20
|
+
process.on('uncaughtException', (err) => {
|
|
21
|
+
const msg = `[UNCAUGHT] ${err.message}`;
|
|
22
|
+
try {
|
|
23
|
+
console.error(msg, err.stack);
|
|
24
|
+
} catch {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
// Don't exit for known node-pty cleanup errors
|
|
28
|
+
if (err.message?.includes('AttachConsole failed')) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
process.on('unhandledRejection', (reason) => {
|
|
35
|
+
console.error('[UNHANDLED REJECTION]', reason);
|
|
36
|
+
});
|
|
37
|
+
|
|
16
38
|
// ----------------------
|
|
17
39
|
// CONFIG
|
|
18
40
|
// ----------------------
|
|
@@ -131,9 +153,10 @@ for (const alias of Object.keys(listenerConfig.projects)) {
|
|
|
131
153
|
}
|
|
132
154
|
|
|
133
155
|
// ----------------------
|
|
134
|
-
// WATCHDOG
|
|
156
|
+
// WATCHDOG + ORPHAN RECOVERY
|
|
135
157
|
// ----------------------
|
|
136
158
|
|
|
159
|
+
// 1. Clean up tasks that exceeded taskTimeout
|
|
137
160
|
const recovered = queue.watchdog(taskTimeout);
|
|
138
161
|
for (const { workDir, next } of recovered) {
|
|
139
162
|
if (next) {
|
|
@@ -141,6 +164,14 @@ for (const { workDir, next } of recovered) {
|
|
|
141
164
|
}
|
|
142
165
|
}
|
|
143
166
|
|
|
167
|
+
// 2. Re-start orphaned active tasks (PTY sessions lost on restart)
|
|
168
|
+
for (const [workDir, entry] of Object.entries(queue.queues)) {
|
|
169
|
+
if (entry.active && !runner.isRunning(workDir)) {
|
|
170
|
+
logger.info(`Orphan recovery: re-starting task "${entry.active.id}" in ${workDir}`);
|
|
171
|
+
startTask(workDir, entry.active);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
144
175
|
// ----------------------
|
|
145
176
|
// TASK RUNNER EVENTS
|
|
146
177
|
// ----------------------
|
package/listener/pty-runner.js
CHANGED
|
@@ -233,14 +233,64 @@ export class PtyRunner extends EventEmitter {
|
|
|
233
233
|
// Set up marker wait + timeout
|
|
234
234
|
const markerPromise = this._waitForMarker(pendingId, this.timeout);
|
|
235
235
|
|
|
236
|
-
// Send the task text to the PTY
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
|
|
236
|
+
// Send the task text to the PTY.
|
|
237
|
+
// Bracketed paste mode (\x1b[200~...\x1b[201~) causes Claude to hang in ConPTY,
|
|
238
|
+
// so we send raw text. For multiline messages, use backslash + Enter as line
|
|
239
|
+
// continuation (Claude Code interprets \ + Enter as a newline within the prompt),
|
|
240
|
+
// with delays between lines so Claude can process each one.
|
|
241
|
+
const lines = task.text.split(/\r?\n/);
|
|
242
|
+
const writeLines = async () => {
|
|
243
|
+
if (lines.length === 1) {
|
|
244
|
+
session.pty.write(`${lines[0]}\r`);
|
|
245
|
+
} else {
|
|
246
|
+
for (let i = 0; i < lines.length; i++) {
|
|
247
|
+
if (i > 0) {
|
|
248
|
+
await new Promise(r => setTimeout(r, 300));
|
|
249
|
+
}
|
|
250
|
+
if (i < lines.length - 1) {
|
|
251
|
+
session.pty.write(`${lines[i]}\\\r`);
|
|
252
|
+
} else {
|
|
253
|
+
session.pty.write(`${lines[i]}\r`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Extra Enter to submit the multiline prompt
|
|
257
|
+
await new Promise(r => setTimeout(r, 300));
|
|
258
|
+
session.pty.write('\r');
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
writeLines();
|
|
240
262
|
this.logger.info(`PTY task sent to ${workDir}: ${task.text.slice(0, 100)}`);
|
|
241
263
|
|
|
264
|
+
// Monitor PTY output for fatal errors that prevent task completion
|
|
265
|
+
const errorPatterns = [
|
|
266
|
+
{ pattern: 'auto mode temporarily unavailable', msg: 'Claude auto mode temporarily unavailable — retry later' },
|
|
267
|
+
{ pattern: 'Session expired', msg: 'Claude session expired' },
|
|
268
|
+
{ pattern: 'Authentication required', msg: 'Claude authentication required' },
|
|
269
|
+
];
|
|
270
|
+
const errorCheckInterval = setInterval(() => {
|
|
271
|
+
const buf = session._buffer || '';
|
|
272
|
+
for (const { pattern, msg } of errorPatterns) {
|
|
273
|
+
if (buf.includes(pattern)) {
|
|
274
|
+
clearInterval(errorCheckInterval);
|
|
275
|
+
this.logger.error(`PTY fatal: ${msg} in ${workDir}`);
|
|
276
|
+
if (session._pendingId && this.pendingMarkers.has(session._pendingId)) {
|
|
277
|
+
this.pendingMarkers.delete(session._pendingId);
|
|
278
|
+
}
|
|
279
|
+
session.state = 'idle';
|
|
280
|
+
session.currentTask = null;
|
|
281
|
+
this._destroyPty(workDir);
|
|
282
|
+
this.emit('error', workDir, task, msg);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}, 3000);
|
|
287
|
+
|
|
288
|
+
// Clean up error monitor when task completes normally
|
|
289
|
+
const clearErrorCheck = () => clearInterval(errorCheckInterval);
|
|
290
|
+
|
|
242
291
|
// Handle completion asynchronously
|
|
243
292
|
markerPromise.then((marker) => {
|
|
293
|
+
clearErrorCheck();
|
|
244
294
|
session.state = 'idle';
|
|
245
295
|
session.currentTask = null;
|
|
246
296
|
session.sessionId = marker.sessionId;
|
|
@@ -262,6 +312,7 @@ export class PtyRunner extends EventEmitter {
|
|
|
262
312
|
}
|
|
263
313
|
this.emit('complete', workDir, task, result);
|
|
264
314
|
}).catch((err) => {
|
|
315
|
+
clearErrorCheck();
|
|
265
316
|
session.state = 'idle';
|
|
266
317
|
session.currentTask = null;
|
|
267
318
|
|
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.43",
|
|
5
5
|
"description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|