nightytidy 0.2.9 → 0.2.10
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/package.json +1 -1
- package/src/agent/index.js +40 -16
package/package.json
CHANGED
package/src/agent/index.js
CHANGED
|
@@ -378,6 +378,12 @@ export async function startAgent() {
|
|
|
378
378
|
|
|
379
379
|
case 'cancel-queued': {
|
|
380
380
|
runQueue.cancel(msg.runId);
|
|
381
|
+
// Also notify Firestore — the run may exist there even if not in local queue
|
|
382
|
+
// (e.g. orphaned after a timeout/crash where the agent already discarded it)
|
|
383
|
+
dispatchWithQueue('run_failed', {
|
|
384
|
+
projectId: msg.projectId || '',
|
|
385
|
+
run: { id: msg.runId },
|
|
386
|
+
}, []);
|
|
381
387
|
wsServer.broadcast({ type: 'queue-updated', queue: runQueue.getQueue() });
|
|
382
388
|
reply({ type: 'queue-updated', queue: runQueue.getQueue() });
|
|
383
389
|
break;
|
|
@@ -1080,22 +1086,35 @@ export async function startAgent() {
|
|
|
1080
1086
|
const progress = interrupted.lastProgress || {};
|
|
1081
1087
|
const completed = progress.completedCount || 0;
|
|
1082
1088
|
const total = interrupted.steps?.length || 0;
|
|
1083
|
-
info(`Found interrupted run: ${projName} (${completed}/${total} steps completed)`);
|
|
1084
|
-
info(` Run ID: ${interrupted.id}`);
|
|
1085
|
-
info(` Use the web app to Resume, Finish with Partial Results, or Discard`);
|
|
1086
1089
|
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
totalCost: progress.totalCost || 0,
|
|
1097
|
-
},
|
|
1090
|
+
if (completed === 0) {
|
|
1091
|
+
// Run never actually started (init timed out or crashed before any steps).
|
|
1092
|
+
// Auto-discard — there's nothing to resume or finish, and blocking the
|
|
1093
|
+
// queue for user action is pointless.
|
|
1094
|
+
info(`Auto-discarding interrupted run with 0 completed steps: ${projName} (${interrupted.id})`);
|
|
1095
|
+
runQueue.clearInterrupted();
|
|
1096
|
+
dispatchWithQueue('run_failed', {
|
|
1097
|
+
projectId: proj?.id || interrupted.projectId,
|
|
1098
|
+
run: { id: interrupted.id },
|
|
1098
1099
|
}, []);
|
|
1100
|
+
} else {
|
|
1101
|
+
info(`Found interrupted run: ${projName} (${completed}/${total} steps completed)`);
|
|
1102
|
+
info(` Run ID: ${interrupted.id}`);
|
|
1103
|
+
info(` Use the web app to Resume, Finish with Partial Results, or Discard`);
|
|
1104
|
+
|
|
1105
|
+
// Best-effort: notify Firestore that this run is interrupted
|
|
1106
|
+
// (in case the shutdown webhook didn't make it)
|
|
1107
|
+
if (proj) {
|
|
1108
|
+
dispatchWithQueue('run_interrupted', {
|
|
1109
|
+
projectId: proj.id,
|
|
1110
|
+
run: {
|
|
1111
|
+
id: interrupted.id,
|
|
1112
|
+
completedSteps: completed,
|
|
1113
|
+
failedSteps: progress.failedCount || 0,
|
|
1114
|
+
totalCost: progress.totalCost || 0,
|
|
1115
|
+
},
|
|
1116
|
+
}, []);
|
|
1117
|
+
}
|
|
1099
1118
|
}
|
|
1100
1119
|
}
|
|
1101
1120
|
|
|
@@ -1103,8 +1122,13 @@ export async function startAgent() {
|
|
|
1103
1122
|
// (agent died without graceful shutdown, so markInterrupted was never called)
|
|
1104
1123
|
const current = runQueue.getCurrent();
|
|
1105
1124
|
if (current && current.status === 'running' && !activeBridge) {
|
|
1106
|
-
|
|
1107
|
-
|
|
1125
|
+
// Orphaned run with no progress — auto-discard instead of blocking the queue
|
|
1126
|
+
info(`Found orphaned running run: ${current.id} — auto-discarding (0 steps completed)`);
|
|
1127
|
+
runQueue.completeCurrent({ success: false });
|
|
1128
|
+
dispatchWithQueue('run_failed', {
|
|
1129
|
+
projectId: current.projectId,
|
|
1130
|
+
run: { id: current.id },
|
|
1131
|
+
}, []);
|
|
1108
1132
|
}
|
|
1109
1133
|
|
|
1110
1134
|
// Process any queued runs left from a previous session
|