@sideboard-ai/core 0.1.347 → 0.1.348
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/{chunk-27XWAI7S.js → chunk-OH3BAUMC.js} +27 -14
- package/dist/{chunk-IJNTTVFH.js → chunk-WMD77UCY.js} +27 -14
- package/dist/index.cjs +25 -11
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -4
- package/dist/mcp/run-stdio.cjs +24 -11
- package/dist/mcp/run-stdio.js +1 -1
- package/dist/{orchestrator-AJZNVREM.js → orchestrator-4SXTORD2.js} +1 -1
- package/dist/{orchestrator-BUEPWNCF.js → orchestrator-KNOMW5CZ.js} +1 -1
- package/package.json +1 -1
|
@@ -2215,6 +2215,10 @@ function resolveStopReason(opts) {
|
|
|
2215
2215
|
if (opts?.clearQueue === false) return "Stopped by the user";
|
|
2216
2216
|
return "Stopped (queue cleared)";
|
|
2217
2217
|
}
|
|
2218
|
+
function isRoutineStopNote(err) {
|
|
2219
|
+
const text3 = err?.trim() ?? "";
|
|
2220
|
+
return text3 === "Stopped" || text3 === "Stopped by the user" || text3 === "Stopped (queue cleared)" || text3 === "Stopped to send the next prompt";
|
|
2221
|
+
}
|
|
2218
2222
|
function reasonToKeepOnStop(existing, incoming) {
|
|
2219
2223
|
const next = incoming?.trim();
|
|
2220
2224
|
if (next) return next.slice(0, STOP_REASON_MAX);
|
|
@@ -2222,6 +2226,16 @@ function reasonToKeepOnStop(existing, incoming) {
|
|
|
2222
2226
|
if (prior) return prior.slice(0, STOP_REASON_MAX);
|
|
2223
2227
|
return "Stopped";
|
|
2224
2228
|
}
|
|
2229
|
+
function turnFinishedEvent(threadId, exitCode, userStopped, lastError) {
|
|
2230
|
+
const note = lastError?.trim() ?? "";
|
|
2231
|
+
const routineStop = userStopped && (note.length === 0 || isRoutineStopNote(note));
|
|
2232
|
+
return {
|
|
2233
|
+
type: "turn_finished",
|
|
2234
|
+
threadId,
|
|
2235
|
+
exitCode,
|
|
2236
|
+
...routineStop ? { routineStop: true } : {}
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2225
2239
|
function writeStoppedStatus(threadId, reason) {
|
|
2226
2240
|
const latest = readThread(threadId);
|
|
2227
2241
|
if (!latest || latest.status === "archived") return latest;
|
|
@@ -7527,11 +7541,11 @@ function realDeps() {
|
|
|
7527
7541
|
parentIdForThread,
|
|
7528
7542
|
designatedId: designatedOrchestratorId,
|
|
7529
7543
|
send: async (threadId, prompt) => {
|
|
7530
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
7544
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-4SXTORD2.js");
|
|
7531
7545
|
await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
|
|
7532
7546
|
},
|
|
7533
7547
|
startOrchestration: async (prompt) => {
|
|
7534
|
-
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7548
|
+
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-4SXTORD2.js");
|
|
7535
7549
|
const defaults = resolveOrchestratorDefaults();
|
|
7536
7550
|
await startOrchestration2({
|
|
7537
7551
|
goal: prompt,
|
|
@@ -7558,7 +7572,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
7558
7572
|
${prompt}`;
|
|
7559
7573
|
}
|
|
7560
7574
|
async function defaultDeps() {
|
|
7561
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7575
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-4SXTORD2.js");
|
|
7562
7576
|
const orch = getOrchestrator2();
|
|
7563
7577
|
return {
|
|
7564
7578
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -8033,7 +8047,7 @@ var Orchestrator = class {
|
|
|
8033
8047
|
if (!this.shouldReclaimRunningThread(thread)) continue;
|
|
8034
8048
|
setStatus(thread.id, "stopped", "Process died (agent exited)");
|
|
8035
8049
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
8036
|
-
this.emit(
|
|
8050
|
+
this.emit(turnFinishedEvent(thread.id, 1, this.stoppedTurns.has(thread.id), readThread(thread.id)?.lastError));
|
|
8037
8051
|
const latest = readThread(thread.id);
|
|
8038
8052
|
if (latest) {
|
|
8039
8053
|
notifyParentOfChildHalt(latest, "stopped", (id, prompt) => this.send(id, prompt));
|
|
@@ -8598,7 +8612,7 @@ var Orchestrator = class {
|
|
|
8598
8612
|
if (stopped?.status === "stopped") {
|
|
8599
8613
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
8600
8614
|
}
|
|
8601
|
-
this.emit(
|
|
8615
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
8602
8616
|
return;
|
|
8603
8617
|
}
|
|
8604
8618
|
thread = this.requireThread(threadId);
|
|
@@ -9006,7 +9020,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9006
9020
|
if (stopped?.status === "stopped") {
|
|
9007
9021
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
9008
9022
|
}
|
|
9009
|
-
this.emit(
|
|
9023
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9010
9024
|
} else {
|
|
9011
9025
|
const failDetail = formatTurnExitError(exitCode, detail);
|
|
9012
9026
|
const explainedInChat = exitCode !== 0 && Boolean(chatText) && (looksLikeAgentFailureMessage(chatText) || failDetail && chatText.includes(failDetail.replace(/^exit\s*\d+:\s*/i, "").trim()));
|
|
@@ -9023,7 +9037,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9023
9037
|
status: written.status
|
|
9024
9038
|
});
|
|
9025
9039
|
}
|
|
9026
|
-
this.emit(
|
|
9040
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9027
9041
|
if (exitCode === 0) {
|
|
9028
9042
|
this.crashContinued.delete(threadId);
|
|
9029
9043
|
this.maybeEnqueueJobContinue(threadId, chatText, parts);
|
|
@@ -9058,14 +9072,14 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9058
9072
|
if (stopped?.status === "stopped") {
|
|
9059
9073
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
9060
9074
|
}
|
|
9061
|
-
this.emit(
|
|
9075
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9062
9076
|
} else {
|
|
9063
9077
|
const written = writeLiveStatus(threadId, "error", message);
|
|
9064
9078
|
if (written?.status === "error") {
|
|
9065
9079
|
this.emit({ type: "error", threadId, message });
|
|
9066
9080
|
this.emit({ type: "status_changed", threadId, status: "error" });
|
|
9067
9081
|
}
|
|
9068
|
-
this.emit(
|
|
9082
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9069
9083
|
const failedOver = await isolateQuotaFailover(
|
|
9070
9084
|
() => this.maybeHandleOrchestrationQuotaFailover(threadId, message)
|
|
9071
9085
|
);
|
|
@@ -9113,9 +9127,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9113
9127
|
const continueQueue = opts?.continueQueue === true;
|
|
9114
9128
|
const thread = this.requireThread(threadRef);
|
|
9115
9129
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
9116
|
-
if (inFlight)
|
|
9117
|
-
this.stoppedTurns.add(thread.id);
|
|
9118
|
-
}
|
|
9130
|
+
if (inFlight) this.stoppedTurns.add(thread.id);
|
|
9119
9131
|
if (clearQueue && thread.queue.length > 0) {
|
|
9120
9132
|
this.haltDrain.delete(thread.id);
|
|
9121
9133
|
updateThread(thread.id, { queue: [], queueAttachments: [] });
|
|
@@ -9125,6 +9137,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9125
9137
|
} else if (continueQueue) {
|
|
9126
9138
|
this.haltDrain.delete(thread.id);
|
|
9127
9139
|
}
|
|
9140
|
+
let stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
|
|
9128
9141
|
const handle = this.activeTurns.get(thread.id);
|
|
9129
9142
|
if (handle) handle.kill();
|
|
9130
9143
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
@@ -9143,10 +9156,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9143
9156
|
}
|
|
9144
9157
|
}
|
|
9145
9158
|
}
|
|
9146
|
-
|
|
9159
|
+
stopped = readThread(thread.id) ?? stopped;
|
|
9147
9160
|
if (stopped.status === "stopped") {
|
|
9148
9161
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
9149
|
-
if (inFlight && opts?.notifyParent !== false) {
|
|
9162
|
+
if (inFlight && opts?.notifyParent !== false && !continueQueue) {
|
|
9150
9163
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
9151
9164
|
}
|
|
9152
9165
|
}
|
|
@@ -2339,6 +2339,10 @@ function resolveStopReason(opts) {
|
|
|
2339
2339
|
if (opts?.clearQueue === false) return "Stopped by the user";
|
|
2340
2340
|
return "Stopped (queue cleared)";
|
|
2341
2341
|
}
|
|
2342
|
+
function isRoutineStopNote(err) {
|
|
2343
|
+
const text3 = err?.trim() ?? "";
|
|
2344
|
+
return text3 === "Stopped" || text3 === "Stopped by the user" || text3 === "Stopped (queue cleared)" || text3 === "Stopped to send the next prompt";
|
|
2345
|
+
}
|
|
2342
2346
|
function reasonToKeepOnStop(existing, incoming) {
|
|
2343
2347
|
const next = incoming?.trim();
|
|
2344
2348
|
if (next) return next.slice(0, STOP_REASON_MAX);
|
|
@@ -2346,6 +2350,16 @@ function reasonToKeepOnStop(existing, incoming) {
|
|
|
2346
2350
|
if (prior) return prior.slice(0, STOP_REASON_MAX);
|
|
2347
2351
|
return "Stopped";
|
|
2348
2352
|
}
|
|
2353
|
+
function turnFinishedEvent(threadId, exitCode, userStopped, lastError) {
|
|
2354
|
+
const note = lastError?.trim() ?? "";
|
|
2355
|
+
const routineStop = userStopped && (note.length === 0 || isRoutineStopNote(note));
|
|
2356
|
+
return {
|
|
2357
|
+
type: "turn_finished",
|
|
2358
|
+
threadId,
|
|
2359
|
+
exitCode,
|
|
2360
|
+
...routineStop ? { routineStop: true } : {}
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2349
2363
|
function writeStoppedStatus(threadId, reason) {
|
|
2350
2364
|
const latest = readThread(threadId);
|
|
2351
2365
|
if (!latest || latest.status === "archived") return latest;
|
|
@@ -7877,11 +7891,11 @@ function realDeps() {
|
|
|
7877
7891
|
parentIdForThread,
|
|
7878
7892
|
designatedId: designatedOrchestratorId,
|
|
7879
7893
|
send: async (threadId, prompt) => {
|
|
7880
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
7894
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
7881
7895
|
await getOrchestrator2().send(threadId, prompt, { followUp: "queue" });
|
|
7882
7896
|
},
|
|
7883
7897
|
startOrchestration: async (prompt) => {
|
|
7884
|
-
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7898
|
+
const { startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
7885
7899
|
const defaults = resolveOrchestratorDefaults();
|
|
7886
7900
|
await startOrchestration2({
|
|
7887
7901
|
goal: prompt,
|
|
@@ -7908,7 +7922,7 @@ function formatScheduledPrompt(name, prompt) {
|
|
|
7908
7922
|
${prompt}`;
|
|
7909
7923
|
}
|
|
7910
7924
|
async function defaultDeps() {
|
|
7911
|
-
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-
|
|
7925
|
+
const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
7912
7926
|
const orch = getOrchestrator2();
|
|
7913
7927
|
return {
|
|
7914
7928
|
findThread: (id) => findThreadByRef(id),
|
|
@@ -8383,7 +8397,7 @@ var Orchestrator = class {
|
|
|
8383
8397
|
if (!this.shouldReclaimRunningThread(thread)) continue;
|
|
8384
8398
|
setStatus(thread.id, "stopped", "Process died (agent exited)");
|
|
8385
8399
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
8386
|
-
this.emit(
|
|
8400
|
+
this.emit(turnFinishedEvent(thread.id, 1, this.stoppedTurns.has(thread.id), readThread(thread.id)?.lastError));
|
|
8387
8401
|
const latest = readThread(thread.id);
|
|
8388
8402
|
if (latest) {
|
|
8389
8403
|
notifyParentOfChildHalt(latest, "stopped", (id, prompt) => this.send(id, prompt));
|
|
@@ -8948,7 +8962,7 @@ var Orchestrator = class {
|
|
|
8948
8962
|
if (stopped?.status === "stopped") {
|
|
8949
8963
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
8950
8964
|
}
|
|
8951
|
-
this.emit(
|
|
8965
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
8952
8966
|
return;
|
|
8953
8967
|
}
|
|
8954
8968
|
thread = this.requireThread(threadId);
|
|
@@ -9356,7 +9370,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9356
9370
|
if (stopped?.status === "stopped") {
|
|
9357
9371
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
9358
9372
|
}
|
|
9359
|
-
this.emit(
|
|
9373
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9360
9374
|
} else {
|
|
9361
9375
|
const failDetail = formatTurnExitError(exitCode, detail);
|
|
9362
9376
|
const explainedInChat = exitCode !== 0 && Boolean(chatText) && (looksLikeAgentFailureMessage(chatText) || failDetail && chatText.includes(failDetail.replace(/^exit\s*\d+:\s*/i, "").trim()));
|
|
@@ -9373,7 +9387,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9373
9387
|
status: written.status
|
|
9374
9388
|
});
|
|
9375
9389
|
}
|
|
9376
|
-
this.emit(
|
|
9390
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9377
9391
|
if (exitCode === 0) {
|
|
9378
9392
|
this.crashContinued.delete(threadId);
|
|
9379
9393
|
this.maybeEnqueueJobContinue(threadId, chatText, parts);
|
|
@@ -9408,14 +9422,14 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9408
9422
|
if (stopped?.status === "stopped") {
|
|
9409
9423
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
9410
9424
|
}
|
|
9411
|
-
this.emit(
|
|
9425
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9412
9426
|
} else {
|
|
9413
9427
|
const written = writeLiveStatus(threadId, "error", message);
|
|
9414
9428
|
if (written?.status === "error") {
|
|
9415
9429
|
this.emit({ type: "error", threadId, message });
|
|
9416
9430
|
this.emit({ type: "status_changed", threadId, status: "error" });
|
|
9417
9431
|
}
|
|
9418
|
-
this.emit(
|
|
9432
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
9419
9433
|
const failedOver = await isolateQuotaFailover(
|
|
9420
9434
|
() => this.maybeHandleOrchestrationQuotaFailover(threadId, message)
|
|
9421
9435
|
);
|
|
@@ -9463,9 +9477,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9463
9477
|
const continueQueue = opts?.continueQueue === true;
|
|
9464
9478
|
const thread = this.requireThread(threadRef);
|
|
9465
9479
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
9466
|
-
if (inFlight)
|
|
9467
|
-
this.stoppedTurns.add(thread.id);
|
|
9468
|
-
}
|
|
9480
|
+
if (inFlight) this.stoppedTurns.add(thread.id);
|
|
9469
9481
|
if (clearQueue && thread.queue.length > 0) {
|
|
9470
9482
|
this.haltDrain.delete(thread.id);
|
|
9471
9483
|
updateThread(thread.id, { queue: [], queueAttachments: [] });
|
|
@@ -9475,6 +9487,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9475
9487
|
} else if (continueQueue) {
|
|
9476
9488
|
this.haltDrain.delete(thread.id);
|
|
9477
9489
|
}
|
|
9490
|
+
let stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
|
|
9478
9491
|
const handle = this.activeTurns.get(thread.id);
|
|
9479
9492
|
if (handle) handle.kill();
|
|
9480
9493
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
@@ -9493,10 +9506,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
9493
9506
|
}
|
|
9494
9507
|
}
|
|
9495
9508
|
}
|
|
9496
|
-
|
|
9509
|
+
stopped = readThread(thread.id) ?? stopped;
|
|
9497
9510
|
if (stopped.status === "stopped") {
|
|
9498
9511
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
9499
|
-
if (inFlight && opts?.notifyParent !== false) {
|
|
9512
|
+
if (inFlight && opts?.notifyParent !== false && !continueQueue) {
|
|
9500
9513
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
9501
9514
|
}
|
|
9502
9515
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -26449,6 +26449,10 @@ function resolveStopReason(opts) {
|
|
|
26449
26449
|
if (opts?.clearQueue === false) return "Stopped by the user";
|
|
26450
26450
|
return "Stopped (queue cleared)";
|
|
26451
26451
|
}
|
|
26452
|
+
function isRoutineStopNote(err) {
|
|
26453
|
+
const text7 = err?.trim() ?? "";
|
|
26454
|
+
return text7 === "Stopped" || text7 === "Stopped by the user" || text7 === "Stopped (queue cleared)" || text7 === "Stopped to send the next prompt";
|
|
26455
|
+
}
|
|
26452
26456
|
function reasonToKeepOnStop(existing, incoming) {
|
|
26453
26457
|
const next = incoming?.trim();
|
|
26454
26458
|
if (next) return next.slice(0, STOP_REASON_MAX);
|
|
@@ -26456,6 +26460,16 @@ function reasonToKeepOnStop(existing, incoming) {
|
|
|
26456
26460
|
if (prior) return prior.slice(0, STOP_REASON_MAX);
|
|
26457
26461
|
return "Stopped";
|
|
26458
26462
|
}
|
|
26463
|
+
function turnFinishedEvent(threadId, exitCode, userStopped, lastError) {
|
|
26464
|
+
const note = lastError?.trim() ?? "";
|
|
26465
|
+
const routineStop = userStopped && (note.length === 0 || isRoutineStopNote(note));
|
|
26466
|
+
return {
|
|
26467
|
+
type: "turn_finished",
|
|
26468
|
+
threadId,
|
|
26469
|
+
exitCode,
|
|
26470
|
+
...routineStop ? { routineStop: true } : {}
|
|
26471
|
+
};
|
|
26472
|
+
}
|
|
26459
26473
|
function writeStoppedStatus(threadId, reason) {
|
|
26460
26474
|
const latest = readThread(threadId);
|
|
26461
26475
|
if (!latest || latest.status === "archived") return latest;
|
|
@@ -34306,7 +34320,7 @@ var init_orchestrator = __esm({
|
|
|
34306
34320
|
if (!this.shouldReclaimRunningThread(thread)) continue;
|
|
34307
34321
|
setStatus(thread.id, "stopped", "Process died (agent exited)");
|
|
34308
34322
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
34309
|
-
this.emit(
|
|
34323
|
+
this.emit(turnFinishedEvent(thread.id, 1, this.stoppedTurns.has(thread.id), readThread(thread.id)?.lastError));
|
|
34310
34324
|
const latest = readThread(thread.id);
|
|
34311
34325
|
if (latest) {
|
|
34312
34326
|
notifyParentOfChildHalt(latest, "stopped", (id, prompt) => this.send(id, prompt));
|
|
@@ -34871,7 +34885,7 @@ var init_orchestrator = __esm({
|
|
|
34871
34885
|
if (stopped?.status === "stopped") {
|
|
34872
34886
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
34873
34887
|
}
|
|
34874
|
-
this.emit(
|
|
34888
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
34875
34889
|
return;
|
|
34876
34890
|
}
|
|
34877
34891
|
thread = this.requireThread(threadId);
|
|
@@ -35279,7 +35293,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35279
35293
|
if (stopped?.status === "stopped") {
|
|
35280
35294
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
35281
35295
|
}
|
|
35282
|
-
this.emit(
|
|
35296
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
35283
35297
|
} else {
|
|
35284
35298
|
const failDetail = formatTurnExitError(exitCode, detail);
|
|
35285
35299
|
const explainedInChat = exitCode !== 0 && Boolean(chatText) && (looksLikeAgentFailureMessage(chatText) || failDetail && chatText.includes(failDetail.replace(/^exit\s*\d+:\s*/i, "").trim()));
|
|
@@ -35296,7 +35310,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35296
35310
|
status: written.status
|
|
35297
35311
|
});
|
|
35298
35312
|
}
|
|
35299
|
-
this.emit(
|
|
35313
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
35300
35314
|
if (exitCode === 0) {
|
|
35301
35315
|
this.crashContinued.delete(threadId);
|
|
35302
35316
|
this.maybeEnqueueJobContinue(threadId, chatText, parts);
|
|
@@ -35331,14 +35345,14 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35331
35345
|
if (stopped?.status === "stopped") {
|
|
35332
35346
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
35333
35347
|
}
|
|
35334
|
-
this.emit(
|
|
35348
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
35335
35349
|
} else {
|
|
35336
35350
|
const written = writeLiveStatus(threadId, "error", message);
|
|
35337
35351
|
if (written?.status === "error") {
|
|
35338
35352
|
this.emit({ type: "error", threadId, message });
|
|
35339
35353
|
this.emit({ type: "status_changed", threadId, status: "error" });
|
|
35340
35354
|
}
|
|
35341
|
-
this.emit(
|
|
35355
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
35342
35356
|
const failedOver = await isolateQuotaFailover(
|
|
35343
35357
|
() => this.maybeHandleOrchestrationQuotaFailover(threadId, message)
|
|
35344
35358
|
);
|
|
@@ -35386,9 +35400,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35386
35400
|
const continueQueue = opts?.continueQueue === true;
|
|
35387
35401
|
const thread = this.requireThread(threadRef);
|
|
35388
35402
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
35389
|
-
if (inFlight)
|
|
35390
|
-
this.stoppedTurns.add(thread.id);
|
|
35391
|
-
}
|
|
35403
|
+
if (inFlight) this.stoppedTurns.add(thread.id);
|
|
35392
35404
|
if (clearQueue && thread.queue.length > 0) {
|
|
35393
35405
|
this.haltDrain.delete(thread.id);
|
|
35394
35406
|
updateThread(thread.id, { queue: [], queueAttachments: [] });
|
|
@@ -35398,6 +35410,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35398
35410
|
} else if (continueQueue) {
|
|
35399
35411
|
this.haltDrain.delete(thread.id);
|
|
35400
35412
|
}
|
|
35413
|
+
let stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
|
|
35401
35414
|
const handle = this.activeTurns.get(thread.id);
|
|
35402
35415
|
if (handle) handle.kill();
|
|
35403
35416
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
@@ -35416,10 +35429,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
35416
35429
|
}
|
|
35417
35430
|
}
|
|
35418
35431
|
}
|
|
35419
|
-
|
|
35432
|
+
stopped = readThread(thread.id) ?? stopped;
|
|
35420
35433
|
if (stopped.status === "stopped") {
|
|
35421
35434
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
35422
|
-
if (inFlight && opts?.notifyParent !== false) {
|
|
35435
|
+
if (inFlight && opts?.notifyParent !== false && !continueQueue) {
|
|
35423
35436
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
35424
35437
|
}
|
|
35425
35438
|
}
|
|
@@ -43006,6 +43019,7 @@ function pushNotes(input) {
|
|
|
43006
43019
|
}
|
|
43007
43020
|
const event = input.event;
|
|
43008
43021
|
if (!event || event.type !== "turn_finished" && event.type !== "error") return notes;
|
|
43022
|
+
if (event.type === "turn_finished" && event.routineStop) return notes;
|
|
43009
43023
|
if (fresh.has(event.threadId)) return notes;
|
|
43010
43024
|
const finished = event.type === "turn_finished" && (event.exitCode === 0 || event.exitCode == null);
|
|
43011
43025
|
notes.push({ chatId: event.threadId, kind: finished ? "finished" : "failed" });
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -222,7 +222,7 @@ import {
|
|
|
222
222
|
worktreeCleanupSettings,
|
|
223
223
|
writeAgentBlock,
|
|
224
224
|
writeWorktreeFile
|
|
225
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-WMD77UCY.js";
|
|
226
226
|
import {
|
|
227
227
|
OPTIONAL_SERVICES,
|
|
228
228
|
OPTIONAL_SERVICE_IDS,
|
|
@@ -5966,6 +5966,7 @@ function pushNotes(input) {
|
|
|
5966
5966
|
}
|
|
5967
5967
|
const event = input.event;
|
|
5968
5968
|
if (!event || event.type !== "turn_finished" && event.type !== "error") return notes;
|
|
5969
|
+
if (event.type === "turn_finished" && event.routineStop) return notes;
|
|
5969
5970
|
if (fresh.has(event.threadId)) return notes;
|
|
5970
5971
|
const finished = event.type === "turn_finished" && (event.exitCode === 0 || event.exitCode == null);
|
|
5971
5972
|
notes.push({ chatId: event.threadId, kind: finished ? "finished" : "failed" });
|
|
@@ -9956,7 +9957,7 @@ async function startHeadlessHost(opts) {
|
|
|
9956
9957
|
};
|
|
9957
9958
|
const refreshRunning = async () => {
|
|
9958
9959
|
try {
|
|
9959
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
9960
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
9960
9961
|
agentsRunning = getOrchestrator2().getRuntime().running;
|
|
9961
9962
|
} catch {
|
|
9962
9963
|
agentsRunning = 0;
|
|
@@ -12690,7 +12691,7 @@ async function handleJobStop(params, _ctx) {
|
|
|
12690
12691
|
return stopDetachedJob(jobCwd(rec), id, reason ? { reason } : void 0);
|
|
12691
12692
|
}
|
|
12692
12693
|
async function defaultTurnWait(ref, timeoutMs) {
|
|
12693
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
12694
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
12694
12695
|
const orch = getOrchestrator2();
|
|
12695
12696
|
const thread = await orch.waitForTurn(ref, timeoutMs, {
|
|
12696
12697
|
resolveIfStillRunning: true
|
|
@@ -16264,7 +16265,7 @@ async function continueSourceThread(threadId, prompt) {
|
|
|
16264
16265
|
await continueOnReply(threadId, prompt);
|
|
16265
16266
|
return;
|
|
16266
16267
|
}
|
|
16267
|
-
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-
|
|
16268
|
+
const { getOrchestrator: getOrchestrator2 } = await import("./orchestrator-KNOMW5CZ.js");
|
|
16268
16269
|
await getOrchestrator2().send(threadId, prompt);
|
|
16269
16270
|
} catch {
|
|
16270
16271
|
}
|
package/dist/mcp/run-stdio.cjs
CHANGED
|
@@ -23194,6 +23194,10 @@ function resolveStopReason(opts) {
|
|
|
23194
23194
|
if (opts?.clearQueue === false) return "Stopped by the user";
|
|
23195
23195
|
return "Stopped (queue cleared)";
|
|
23196
23196
|
}
|
|
23197
|
+
function isRoutineStopNote(err) {
|
|
23198
|
+
const text7 = err?.trim() ?? "";
|
|
23199
|
+
return text7 === "Stopped" || text7 === "Stopped by the user" || text7 === "Stopped (queue cleared)" || text7 === "Stopped to send the next prompt";
|
|
23200
|
+
}
|
|
23197
23201
|
function reasonToKeepOnStop(existing, incoming) {
|
|
23198
23202
|
const next = incoming?.trim();
|
|
23199
23203
|
if (next) return next.slice(0, STOP_REASON_MAX);
|
|
@@ -23201,6 +23205,16 @@ function reasonToKeepOnStop(existing, incoming) {
|
|
|
23201
23205
|
if (prior) return prior.slice(0, STOP_REASON_MAX);
|
|
23202
23206
|
return "Stopped";
|
|
23203
23207
|
}
|
|
23208
|
+
function turnFinishedEvent(threadId, exitCode, userStopped, lastError) {
|
|
23209
|
+
const note = lastError?.trim() ?? "";
|
|
23210
|
+
const routineStop = userStopped && (note.length === 0 || isRoutineStopNote(note));
|
|
23211
|
+
return {
|
|
23212
|
+
type: "turn_finished",
|
|
23213
|
+
threadId,
|
|
23214
|
+
exitCode,
|
|
23215
|
+
...routineStop ? { routineStop: true } : {}
|
|
23216
|
+
};
|
|
23217
|
+
}
|
|
23204
23218
|
function writeStoppedStatus(threadId, reason) {
|
|
23205
23219
|
const latest = readThread(threadId);
|
|
23206
23220
|
if (!latest || latest.status === "archived") return latest;
|
|
@@ -31746,7 +31760,7 @@ var init_orchestrator = __esm({
|
|
|
31746
31760
|
if (!this.shouldReclaimRunningThread(thread)) continue;
|
|
31747
31761
|
setStatus(thread.id, "stopped", "Process died (agent exited)");
|
|
31748
31762
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
31749
|
-
this.emit(
|
|
31763
|
+
this.emit(turnFinishedEvent(thread.id, 1, this.stoppedTurns.has(thread.id), readThread(thread.id)?.lastError));
|
|
31750
31764
|
const latest = readThread(thread.id);
|
|
31751
31765
|
if (latest) {
|
|
31752
31766
|
notifyParentOfChildHalt(latest, "stopped", (id, prompt) => this.send(id, prompt));
|
|
@@ -32311,7 +32325,7 @@ var init_orchestrator = __esm({
|
|
|
32311
32325
|
if (stopped?.status === "stopped") {
|
|
32312
32326
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
32313
32327
|
}
|
|
32314
|
-
this.emit(
|
|
32328
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
32315
32329
|
return;
|
|
32316
32330
|
}
|
|
32317
32331
|
thread = this.requireThread(threadId);
|
|
@@ -32719,7 +32733,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32719
32733
|
if (stopped?.status === "stopped") {
|
|
32720
32734
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
32721
32735
|
}
|
|
32722
|
-
this.emit(
|
|
32736
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
32723
32737
|
} else {
|
|
32724
32738
|
const failDetail = formatTurnExitError(exitCode, detail);
|
|
32725
32739
|
const explainedInChat = exitCode !== 0 && Boolean(chatText) && (looksLikeAgentFailureMessage(chatText) || failDetail && chatText.includes(failDetail.replace(/^exit\s*\d+:\s*/i, "").trim()));
|
|
@@ -32736,7 +32750,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32736
32750
|
status: written.status
|
|
32737
32751
|
});
|
|
32738
32752
|
}
|
|
32739
|
-
this.emit(
|
|
32753
|
+
this.emit(turnFinishedEvent(threadId, exitCode, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
32740
32754
|
if (exitCode === 0) {
|
|
32741
32755
|
this.crashContinued.delete(threadId);
|
|
32742
32756
|
this.maybeEnqueueJobContinue(threadId, chatText, parts);
|
|
@@ -32771,14 +32785,14 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32771
32785
|
if (stopped?.status === "stopped") {
|
|
32772
32786
|
this.emit({ type: "status_changed", threadId, status: "stopped" });
|
|
32773
32787
|
}
|
|
32774
|
-
this.emit(
|
|
32788
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
32775
32789
|
} else {
|
|
32776
32790
|
const written = writeLiveStatus(threadId, "error", message);
|
|
32777
32791
|
if (written?.status === "error") {
|
|
32778
32792
|
this.emit({ type: "error", threadId, message });
|
|
32779
32793
|
this.emit({ type: "status_changed", threadId, status: "error" });
|
|
32780
32794
|
}
|
|
32781
|
-
this.emit(
|
|
32795
|
+
this.emit(turnFinishedEvent(threadId, 1, this.stoppedTurns.has(threadId), readThread(threadId)?.lastError));
|
|
32782
32796
|
const failedOver = await isolateQuotaFailover(
|
|
32783
32797
|
() => this.maybeHandleOrchestrationQuotaFailover(threadId, message)
|
|
32784
32798
|
);
|
|
@@ -32826,9 +32840,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32826
32840
|
const continueQueue = opts?.continueQueue === true;
|
|
32827
32841
|
const thread = this.requireThread(threadRef);
|
|
32828
32842
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
32829
|
-
if (inFlight)
|
|
32830
|
-
this.stoppedTurns.add(thread.id);
|
|
32831
|
-
}
|
|
32843
|
+
if (inFlight) this.stoppedTurns.add(thread.id);
|
|
32832
32844
|
if (clearQueue && thread.queue.length > 0) {
|
|
32833
32845
|
this.haltDrain.delete(thread.id);
|
|
32834
32846
|
updateThread(thread.id, { queue: [], queueAttachments: [] });
|
|
@@ -32838,6 +32850,7 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32838
32850
|
} else if (continueQueue) {
|
|
32839
32851
|
this.haltDrain.delete(thread.id);
|
|
32840
32852
|
}
|
|
32853
|
+
let stopped = writeStoppedStatus(thread.id, resolveStopReason(opts)) ?? readThread(thread.id) ?? thread;
|
|
32841
32854
|
const handle = this.activeTurns.get(thread.id);
|
|
32842
32855
|
if (handle) handle.kill();
|
|
32843
32856
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
@@ -32856,10 +32869,10 @@ ${formatEnvReminder(projectNameForRepoPath(thread.repoPath || thread.worktreePat
|
|
|
32856
32869
|
}
|
|
32857
32870
|
}
|
|
32858
32871
|
}
|
|
32859
|
-
|
|
32872
|
+
stopped = readThread(thread.id) ?? stopped;
|
|
32860
32873
|
if (stopped.status === "stopped") {
|
|
32861
32874
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
32862
|
-
if (inFlight && opts?.notifyParent !== false) {
|
|
32875
|
+
if (inFlight && opts?.notifyParent !== false && !continueQueue) {
|
|
32863
32876
|
notifyParentOfChildHalt(stopped, "stopped", (id, prompt) => this.send(id, prompt));
|
|
32864
32877
|
}
|
|
32865
32878
|
}
|
package/dist/mcp/run-stdio.js
CHANGED