claude-task-worker 0.12.0 → 0.14.0
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/index.js +48 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -193,6 +193,7 @@ __export(dispatcher_exports, {
|
|
|
193
193
|
POLL_INTERVAL_MS: () => POLL_INTERVAL_MS,
|
|
194
194
|
SHUTDOWN_RETRY_TIMEOUT_MS: () => SHUTDOWN_RETRY_TIMEOUT_MS,
|
|
195
195
|
SHUTDOWN_TIMEOUT_MS: () => SHUTDOWN_TIMEOUT_MS,
|
|
196
|
+
createDispatcherShutdownHandler: () => createDispatcherShutdownHandler,
|
|
196
197
|
formatUptime: () => formatUptime,
|
|
197
198
|
monitorSessions: () => monitorSessions,
|
|
198
199
|
pollOnce: () => pollOnce,
|
|
@@ -338,11 +339,9 @@ function monitorSessions(sessions, herdr, options) {
|
|
|
338
339
|
}
|
|
339
340
|
});
|
|
340
341
|
}, pollIntervalMs);
|
|
341
|
-
pollInterval.unref();
|
|
342
342
|
const renderInterval2 = setInterval(() => {
|
|
343
343
|
renderSessionTable(sessions);
|
|
344
344
|
}, renderIntervalMs);
|
|
345
|
-
renderInterval2.unref();
|
|
346
345
|
return {
|
|
347
346
|
stop: finish,
|
|
348
347
|
done
|
|
@@ -352,7 +351,7 @@ async function sendCtrlCToAllSessions(sessions, herdr) {
|
|
|
352
351
|
await Promise.all(
|
|
353
352
|
[...sessions.values()].map(async (session) => {
|
|
354
353
|
try {
|
|
355
|
-
await herdr.paneSendKeys(session.paneId,
|
|
354
|
+
await herdr.paneSendKeys(session.paneId, CTRL_C_KEY);
|
|
356
355
|
} catch (error) {
|
|
357
356
|
console.error(`[dispatcher] failed to send ctrl-c to session "${session.name}": ${error}`);
|
|
358
357
|
}
|
|
@@ -436,7 +435,34 @@ async function shutdownDispatcher(sessions, monitorHandle, options) {
|
|
|
436
435
|
shutdownPromise = void 0;
|
|
437
436
|
}
|
|
438
437
|
}
|
|
439
|
-
|
|
438
|
+
function createDispatcherShutdownHandler(shutdown2) {
|
|
439
|
+
let shuttingDown2 = false;
|
|
440
|
+
let forceKilling = false;
|
|
441
|
+
const handle = async () => {
|
|
442
|
+
if (shuttingDown2) {
|
|
443
|
+
if (forceKilling) return;
|
|
444
|
+
forceKilling = true;
|
|
445
|
+
console.log("\n[dispatcher] Force killing sessions immediately...");
|
|
446
|
+
try {
|
|
447
|
+
await shutdown2({ forceKill: true });
|
|
448
|
+
} catch (error) {
|
|
449
|
+
console.error(`[dispatcher] force-kill shutdown failed: ${error}`);
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
shuttingDown2 = true;
|
|
455
|
+
console.log("\n[dispatcher] Stopping sessions. Waiting for them to finish... (Press Ctrl-C again to force kill)");
|
|
456
|
+
try {
|
|
457
|
+
await shutdown2();
|
|
458
|
+
} catch (error) {
|
|
459
|
+
console.error(`[dispatcher] shutdown failed: ${error}`);
|
|
460
|
+
process.exit(1);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
return { handle, isShuttingDown: () => shuttingDown2 };
|
|
464
|
+
}
|
|
465
|
+
var getDisplayWidth2, truncateToWidth2, padToWidth2, POLL_INTERVAL_MS, SHUTDOWN_TIMEOUT_MS, SHUTDOWN_RETRY_TIMEOUT_MS, CTRL_C_KEY, shutdownPromise;
|
|
440
466
|
var init_dispatcher = __esm({
|
|
441
467
|
async "src/dispatcher.ts"() {
|
|
442
468
|
"use strict";
|
|
@@ -444,6 +470,7 @@ var init_dispatcher = __esm({
|
|
|
444
470
|
POLL_INTERVAL_MS = 7 * 1e3;
|
|
445
471
|
SHUTDOWN_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
446
472
|
SHUTDOWN_RETRY_TIMEOUT_MS = 90 * 1e3;
|
|
473
|
+
CTRL_C_KEY = "ctrl+c";
|
|
447
474
|
}
|
|
448
475
|
});
|
|
449
476
|
|
|
@@ -2572,20 +2599,28 @@ if (hasProjectFilter()) {
|
|
|
2572
2599
|
(async () => {
|
|
2573
2600
|
let sessions = /* @__PURE__ */ new Map();
|
|
2574
2601
|
let monitorHandle;
|
|
2575
|
-
const handleShutdown = async () => {
|
|
2576
|
-
const { shutdownDispatcher: shutdownDispatcher2 } = await init_dispatcher().then(() => dispatcher_exports);
|
|
2577
|
-
await shutdownDispatcher2(sessions, monitorHandle);
|
|
2578
|
-
};
|
|
2579
|
-
process.on("SIGTERM", handleShutdown);
|
|
2580
|
-
process.on("SIGINT", handleShutdown);
|
|
2581
2602
|
const herdr = await Promise.resolve().then(() => (init_herdr(), herdr_exports));
|
|
2603
|
+
const dispatcher = await init_dispatcher().then(() => dispatcher_exports);
|
|
2604
|
+
const shutdownController = dispatcher.createDispatcherShutdownHandler(
|
|
2605
|
+
(options) => dispatcher.shutdownDispatcher(sessions, monitorHandle, options)
|
|
2606
|
+
);
|
|
2607
|
+
process.on("SIGTERM", shutdownController.handle);
|
|
2608
|
+
process.on("SIGINT", shutdownController.handle);
|
|
2582
2609
|
try {
|
|
2583
2610
|
const config = loadProjectsConfig();
|
|
2584
2611
|
const projects = resolveTargetProjects(parseProjectFilters(), config);
|
|
2585
2612
|
const forwardedCommand = buildForwardedCommand(process.argv.slice(2));
|
|
2586
|
-
|
|
2587
|
-
sessions
|
|
2588
|
-
|
|
2613
|
+
sessions = await dispatcher.runDispatcher(projects, forwardedCommand);
|
|
2614
|
+
if (sessions.size === 0) {
|
|
2615
|
+
console.log("[dispatcher] no sessions were dispatched, exiting");
|
|
2616
|
+
process.exit(0);
|
|
2617
|
+
}
|
|
2618
|
+
monitorHandle = dispatcher.monitorSessions(sessions, herdr);
|
|
2619
|
+
await monitorHandle.done;
|
|
2620
|
+
if (!shutdownController.isShuttingDown()) {
|
|
2621
|
+
console.log("[dispatcher] all sessions finished, exiting");
|
|
2622
|
+
process.exit(0);
|
|
2623
|
+
}
|
|
2589
2624
|
} catch (err) {
|
|
2590
2625
|
if (err instanceof ProjectsConfigError || err instanceof herdr.HerdrUnavailableError) {
|
|
2591
2626
|
console.error(`[dispatcher] ${err.message}`);
|