@teamvibe/poller 0.1.13 → 0.1.15
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/claude-spawner.js +11 -10
- package/dist/cli/commands.js +5 -0
- package/dist/cli/logs.d.ts +1 -0
- package/dist/cli/logs.js +23 -0
- package/dist/config.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/claude-spawner.js
CHANGED
|
@@ -275,20 +275,21 @@ async function runClaudeCode(msg, sessionLog, cwd, sessionId, isFirstMessage = t
|
|
|
275
275
|
}
|
|
276
276
|
export async function spawnClaudeCode(msg, sessionLog, cwd, sessionId, isFirstMessage = true, lastMessageTs, onMessageSent) {
|
|
277
277
|
const result = await runClaudeCode(msg, sessionLog, cwd, sessionId, isFirstMessage, lastMessageTs, onMessageSent);
|
|
278
|
-
// If session ID is "already in use" (stale lock file), retry with no session ID (let Claude generate a new one)
|
|
279
|
-
if (!result.success && sessionId && result.error?.includes('already in use')) {
|
|
280
|
-
sessionLog.info('Session ID already in use (stale lock), retrying without session ID');
|
|
281
|
-
const { randomUUID } = await import('crypto');
|
|
282
|
-
const freshId = randomUUID();
|
|
283
|
-
const retryResult = await runClaudeCode(msg, sessionLog, cwd, freshId, true, lastMessageTs, onMessageSent);
|
|
284
|
-
return { ...retryResult, newSessionId: freshId };
|
|
285
|
-
}
|
|
286
278
|
// If --resume failed, retry as a fresh session (session files may have been lost on container restart)
|
|
279
|
+
let retryResult = result;
|
|
287
280
|
if (!result.success && sessionId && !isFirstMessage) {
|
|
288
281
|
sessionLog.info('Resume failed, retrying as fresh session (session files may have been lost)');
|
|
289
|
-
|
|
282
|
+
retryResult = await runClaudeCode(msg, sessionLog, cwd, sessionId, true, lastMessageTs, onMessageSent);
|
|
283
|
+
}
|
|
284
|
+
// If session ID is "already in use" (stale lock file), retry with a fresh session ID
|
|
285
|
+
if (!retryResult.success && sessionId && retryResult.error?.includes('already in use')) {
|
|
286
|
+
sessionLog.info('Session ID already in use (stale lock), retrying with fresh session ID');
|
|
287
|
+
const { randomUUID } = await import('crypto');
|
|
288
|
+
const freshId = randomUUID();
|
|
289
|
+
const freshResult = await runClaudeCode(msg, sessionLog, cwd, freshId, true, lastMessageTs, onMessageSent);
|
|
290
|
+
return { ...freshResult, newSessionId: freshId };
|
|
290
291
|
}
|
|
291
|
-
return
|
|
292
|
+
return retryResult;
|
|
292
293
|
}
|
|
293
294
|
const activeProcesses = new Map();
|
|
294
295
|
export function getActiveProcessCount() {
|
package/dist/cli/commands.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { install } from './install.js';
|
|
2
2
|
import { uninstall } from './uninstall.js';
|
|
3
3
|
import { update } from './update.js';
|
|
4
|
+
import { logs } from './logs.js';
|
|
4
5
|
import { start, stop, restart, status } from './service.js';
|
|
5
6
|
function showHelp() {
|
|
6
7
|
console.log(`TeamVibe Poller
|
|
@@ -16,6 +17,7 @@ Commands:
|
|
|
16
17
|
stop Stop the installed service
|
|
17
18
|
restart Restart the installed service
|
|
18
19
|
status Show service status
|
|
20
|
+
logs Tail service logs
|
|
19
21
|
--help, -h Show this help message
|
|
20
22
|
`);
|
|
21
23
|
}
|
|
@@ -30,6 +32,9 @@ export async function handleCommand(command) {
|
|
|
30
32
|
case 'update':
|
|
31
33
|
update();
|
|
32
34
|
break;
|
|
35
|
+
case 'logs':
|
|
36
|
+
logs();
|
|
37
|
+
break;
|
|
33
38
|
case 'start':
|
|
34
39
|
start();
|
|
35
40
|
break;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logs(): void;
|
package/dist/cli/logs.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { LOGS_DIR } from './plist.js';
|
|
5
|
+
export function logs() {
|
|
6
|
+
const stdoutLog = path.join(LOGS_DIR, 'poller.stdout.log');
|
|
7
|
+
const stderrLog = path.join(LOGS_DIR, 'poller.stderr.log');
|
|
8
|
+
const filesToTail = [];
|
|
9
|
+
if (fs.existsSync(stdoutLog))
|
|
10
|
+
filesToTail.push(stdoutLog);
|
|
11
|
+
if (fs.existsSync(stderrLog))
|
|
12
|
+
filesToTail.push(stderrLog);
|
|
13
|
+
if (filesToTail.length === 0) {
|
|
14
|
+
console.error(`No log files found in ${LOGS_DIR}`);
|
|
15
|
+
console.error('Is the service installed? Run `poller install` first.');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const tail = spawn('tail', ['-f', ...filesToTail], { stdio: 'inherit' });
|
|
19
|
+
process.on('SIGINT', () => {
|
|
20
|
+
tail.kill();
|
|
21
|
+
process.exit(0);
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -13,8 +13,8 @@ const configSchema = z.object({
|
|
|
13
13
|
// Poller settings
|
|
14
14
|
MAX_CONCURRENT_SESSIONS: z.coerce.number().default(5),
|
|
15
15
|
POLL_WAIT_TIME_SECONDS: z.coerce.number().default(20),
|
|
16
|
-
VISIBILITY_TIMEOUT_SECONDS: z.coerce.number().default(
|
|
17
|
-
HEARTBEAT_INTERVAL_MS: z.coerce.number().default(
|
|
16
|
+
VISIBILITY_TIMEOUT_SECONDS: z.coerce.number().default(60),
|
|
17
|
+
HEARTBEAT_INTERVAL_MS: z.coerce.number().default(40000), // 40 seconds
|
|
18
18
|
CLAUDE_TIMEOUT_MS: z.coerce.number().default(1800000), // 30 minutes
|
|
19
19
|
STALE_LOCK_TIMEOUT_MS: z.coerce.number().default(2100000), // 35 minutes
|
|
20
20
|
// Paths
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const command = process.argv[2];
|
|
3
|
-
if (command && ['install', 'uninstall', 'update', 'status', 'start', 'stop', 'restart', '--help', '-h'].includes(command)) {
|
|
3
|
+
if (command && ['install', 'uninstall', 'update', 'logs', 'status', 'start', 'stop', 'restart', '--help', '-h'].includes(command)) {
|
|
4
4
|
const { handleCommand } = await import('./cli/commands.js');
|
|
5
5
|
await handleCommand(command);
|
|
6
6
|
}
|