claude-task-worker 0.23.0 → 0.24.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 +3 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1024,16 +1024,12 @@ import { spawn } from "node:child_process";
|
|
|
1024
1024
|
init_table();
|
|
1025
1025
|
|
|
1026
1026
|
// src/task-result.ts
|
|
1027
|
-
var TASK_TIMEOUT_MS = 120 * 60 * 1e3;
|
|
1028
1027
|
var STDERR_TAIL_LIMIT = 8 * 1024;
|
|
1029
|
-
function buildTaskResult(code,
|
|
1028
|
+
function buildTaskResult(code, stdout, stderrTail) {
|
|
1030
1029
|
const emptyOutput = stdout.trim() === "";
|
|
1031
|
-
const completed =
|
|
1030
|
+
const completed = code === 0 && !emptyOutput;
|
|
1032
1031
|
let output = stdout;
|
|
1033
|
-
if (
|
|
1034
|
-
output += `
|
|
1035
|
-
[worker] task timed out after ${TASK_TIMEOUT_MS / 1e3}s`;
|
|
1036
|
-
} else if (code === 0 && emptyOutput) {
|
|
1032
|
+
if (code === 0 && emptyOutput) {
|
|
1037
1033
|
output += "[worker] claude exited with code 0 but produced no output (session aborted before the model ran; e.g. a skill preamble command failed)";
|
|
1038
1034
|
} else if (!completed) {
|
|
1039
1035
|
output += `
|
|
@@ -1194,27 +1190,9 @@ function run(command, args, id, title, workerName, path, onComplete, cwd, env) {
|
|
|
1194
1190
|
stderrChunks.shift();
|
|
1195
1191
|
}
|
|
1196
1192
|
});
|
|
1197
|
-
let timedOut = false;
|
|
1198
|
-
const timeoutHandle = setTimeout(() => {
|
|
1199
|
-
timedOut = true;
|
|
1200
|
-
console.error(`[worker] task #${id} timed out after ${TASK_TIMEOUT_MS / 1e3}s, terminating`);
|
|
1201
|
-
if (child.pid) {
|
|
1202
|
-
try {
|
|
1203
|
-
process.kill(-child.pid, "SIGTERM");
|
|
1204
|
-
} catch {
|
|
1205
|
-
try {
|
|
1206
|
-
child.kill("SIGTERM");
|
|
1207
|
-
} catch {
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}, TASK_TIMEOUT_MS);
|
|
1212
|
-
timeoutHandle.unref();
|
|
1213
1193
|
child.on("close", async (code) => {
|
|
1214
|
-
clearTimeout(timeoutHandle);
|
|
1215
1194
|
const { status: finalStatus, output } = buildTaskResult(
|
|
1216
1195
|
code,
|
|
1217
|
-
timedOut,
|
|
1218
1196
|
Buffer.concat(outputChunks).toString("utf-8"),
|
|
1219
1197
|
Buffer.concat(stderrChunks).toString("utf-8").slice(-STDERR_TAIL_LIMIT)
|
|
1220
1198
|
);
|
|
@@ -1237,7 +1215,6 @@ function run(command, args, id, title, workerName, path, onComplete, cwd, env) {
|
|
|
1237
1215
|
renderTable();
|
|
1238
1216
|
});
|
|
1239
1217
|
child.on("error", async (err) => {
|
|
1240
|
-
clearTimeout(timeoutHandle);
|
|
1241
1218
|
console.error(`[worker] failed to spawn process for #${id}: ${err.message}`);
|
|
1242
1219
|
try {
|
|
1243
1220
|
await Promise.race([
|