copilot-operator 0.1.93 → 0.1.96
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/README.md +640 -625
- package/dist/src/api/operator.controller.js +5 -1
- package/dist/src/api/operator.service.js +354 -66
- package/dist/src/config/live.js +12 -12
- package/dist/src/exec/readOnly.js +27 -2
- package/dist/src/orchestrator/kerriganRunner.js +20 -6
- package/dist/src/orchestrator/leadRunner.js +76 -23
- package/dist/src/orchestrator/review.js +6 -2
- package/dist/src/orchestrator/subtaskRetry.js +2 -1
- package/dist/src/orchestrator/taskRunner.js +89 -19
- package/dist/src/plan/kerrigan.js +263 -243
- package/dist/src/plan/systemGuide.js +130 -82
- package/dist/src/queue/queue.js +12 -0
- package/dist/src/queue/queueBranch.js +34 -9
- package/dist/src/session/compose.js +13 -0
- package/dist/src/session/locatorFailures.js +8 -5
- package/dist/src/session/store.js +9 -0
- package/dist/src/session/workspace.js +3 -2
- package/dist/src/transport/copilotTransport.js +103 -70
- package/dist/src/transport/keptWindow.js +17 -14
- package/dist/src/vcs/newBranch.js +69 -0
- package/dist/src/vcs/referenceGuard.js +16 -2
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-214ded25b9048526.js +1 -0
- package/dist/web/_next/static/chunks/1077.161de82f740d47f0.js +1 -0
- package/dist/web/_next/static/chunks/1548.f2688468bf946e13.js +1 -0
- package/dist/web/_next/static/chunks/2163.b8ada3b7bde69f03.js +1 -0
- package/dist/web/_next/static/chunks/714.d1489788e598833b.js +1 -0
- package/dist/web/_next/static/chunks/7220.b85c8d105f394389.js +1 -0
- package/dist/web/_next/static/chunks/7921-00ebbcc6f65fbe35.js +1 -0
- package/dist/web/_next/static/chunks/8584.a678bfced1cea938.js +1 -0
- package/dist/web/_next/static/chunks/9067.6da03ae052877b19.js +1 -0
- package/dist/web/_next/static/chunks/9747.ba29e64e97e8a15b.js +1 -0
- package/dist/web/_next/static/chunks/app/{layout-1b7d13f7b2efd008.js → layout-2364903896c2c175.js} +1 -1
- package/dist/web/_next/static/chunks/app/{page-b71841852e6b9ff5.js → page-d031bf326e401246.js} +1 -1
- package/dist/web/_next/static/chunks/app/queue/page-9cfc8f78d536cfb6.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-9c2b961beb8b3dce.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-33252b1a0a7d93ba.js → webpack-3f144d13be3516c2.js} +1 -1
- package/dist/web/_next/static/css/{6b92f118889ca88b.css → 523d11041085f836.css} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +2 -1
- package/dist/web/_next/static/chunks/1024-dee283a1ddf295bf.js +0 -1
- package/dist/web/_next/static/chunks/1077.626a11362f53d35c.js +0 -1
- package/dist/web/_next/static/chunks/1548.79f05ff765581b0a.js +0 -1
- package/dist/web/_next/static/chunks/2163.09f1212655504f3a.js +0 -1
- package/dist/web/_next/static/chunks/714.acea3698b6af7a61.js +0 -1
- package/dist/web/_next/static/chunks/7220.1eba10bd9d449cea.js +0 -1
- package/dist/web/_next/static/chunks/7921-29256ac683ea4bc5.js +0 -1
- package/dist/web/_next/static/chunks/8584.b5aac5354f124d4b.js +0 -1
- package/dist/web/_next/static/chunks/9067.177163495f3bd8fa.js +0 -1
- package/dist/web/_next/static/chunks/9747.5b9d763e89abc7e4.js +0 -1
- package/dist/web/_next/static/chunks/app/queue/page-7909ba7c9e3d4c2d.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-c92548f9c6318962.js +0 -1
- /package/dist/web/_next/static/{ZrEcjGdZEXe66UUxUqine → kNfJ9jSwlboc-1sFBBfuI}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{ZrEcjGdZEXe66UUxUqine → kNfJ9jSwlboc-1sFBBfuI}/_ssgManifest.js +0 -0
|
@@ -28,7 +28,7 @@ import { chosenHome, defaultHome, installLayout } from '../config/layout.js';
|
|
|
28
28
|
import { chooseHome, homeRefusal, movedFrom } from '../config/home.js';
|
|
29
29
|
import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, writeFileAtomically } from '../session/store.js';
|
|
30
30
|
import { checkItems, emptyQueue, itemTitle, mergeItems, nextStep, parkAfterMs, parkedAnswerFrom, skippedBecause, statusOfTask, waitsByHand, MAX_PARK_AFTER_SEC, PARKED_WORDS } from '../queue/queue.js';
|
|
31
|
-
import { branchStart, makeQueueBranch, refreshQueueBranch } from '../queue/queueBranch.js';
|
|
31
|
+
import { branchStart, madeFromRemote, makeQueueBranch, refreshQueueBranch } from '../queue/queueBranch.js';
|
|
32
32
|
import { EventBus } from '../session/events.js';
|
|
33
33
|
import { isContinuable, MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
34
34
|
import { handoffOutcomeOf, handoffResultMessage } from '../orchestrator/handoff.js';
|
|
@@ -73,6 +73,17 @@ function sameFolder(a, b) {
|
|
|
73
73
|
const norm = (p) => p.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
|
|
74
74
|
return a.trim() !== '' && norm(a) === norm(b);
|
|
75
75
|
}
|
|
76
|
+
/** Why a queue's task waits to carry on, in its own chat, at the queue's next run (2026-11-18). */
|
|
77
|
+
const CARRIES_ON_AFTER = (what) => `${what}; it carries on from where it stopped, in its own chat, when the queue is run again`;
|
|
78
|
+
/** A card answered after it went: by Kerrigan, another tab, or its work having ended (2026-11-18). */
|
|
79
|
+
export const CARD_GONE = 'That card is not waiting any more: it was answered, or its work ended.';
|
|
80
|
+
/** "Run this and the rest" where the run may not go on unasked: said, and the card kept (2026-11-18). */
|
|
81
|
+
export const RUN_ALL_REFUSED = (why) => `"Run this and the rest" cannot be given here — ${why} Nothing was run: "Run" runs this step.`;
|
|
82
|
+
/** Whether a folder is another, or inside it: Windows paths, as `sameFolder` reads them. */
|
|
83
|
+
function folderInside(inner, outer) {
|
|
84
|
+
const norm = (p) => p.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
|
|
85
|
+
return inner.trim() !== '' && outer.trim() !== '' && (norm(inner) === norm(outer) || norm(inner).startsWith(`${norm(outer)}\\`));
|
|
86
|
+
}
|
|
76
87
|
import { saveWorkspaceFile, workspaceFile, workspaceFiles, workspaceInfo, workspaceRaw } from '../session/workspace.js';
|
|
77
88
|
import { searchWorkspace } from '../session/workspaceSearch.js';
|
|
78
89
|
import { restoreCheckpoint } from '../session/checkpoint.js';
|
|
@@ -98,10 +109,11 @@ import { sessionRoots } from '../exec/confinement.js';
|
|
|
98
109
|
import { dirtyPolicy } from '../vcs/snapshot.js';
|
|
99
110
|
import { runVcsPreflight } from '../vcs/runPreflight.js';
|
|
100
111
|
import { inputSettings, normalisePatterns } from '../vcs/inputs.js';
|
|
101
|
-
import { createNewBranch, planNewBranch } from '../vcs/newBranch.js';
|
|
112
|
+
import { createNewBranch, planNewBranch, putBackAside, setAsideUncommitted } from '../vcs/newBranch.js';
|
|
102
113
|
import { commitAsOperator, identityOf, pushAsOperator, setIdentity, stageFiles, TrustedHooks } from '../vcs/operatorGit.js';
|
|
103
114
|
import { askpassProgram, closePasswordWindows } from '../vcs/remoteAuth.js';
|
|
104
115
|
import { planApprovedMessage, planReviseMessage } from '../orchestrator/planMode.js';
|
|
116
|
+
import { leadPlanApproved, leadPlanRevise } from '../orchestrator/leadRunner.js';
|
|
105
117
|
import { coveredByArtifacts } from '../vcs/artifacts.js';
|
|
106
118
|
import { botVersion } from '../config/version.js';
|
|
107
119
|
import { exportEntries, exportFileName as homeExportName, exportSizes } from '../config/exportHome.js';
|
|
@@ -220,6 +232,12 @@ let OperatorService = class OperatorService {
|
|
|
220
232
|
* operator in another window): a worker's subtask is not the message.
|
|
221
233
|
*/
|
|
222
234
|
lastOutcome = null;
|
|
235
|
+
/**
|
|
236
|
+
* The runs the operator stopped: their Stop, "Stop the queue", Stop or "Abort task" on a card (bug hunt 2026-11-18).
|
|
237
|
+
* Only such a stop is theirs and says nothing at the end ("Done" is not shown); a window closed past the times it is
|
|
238
|
+
* opened again, a conversation lost, the program closed, are said.
|
|
239
|
+
*/
|
|
240
|
+
stoppedByOperator = new Set();
|
|
223
241
|
/** Where Git asks the operator for a password now, in its own window (2026-10-26): the step waits for it. */
|
|
224
242
|
passwordAsked = new Map();
|
|
225
243
|
followsActing = this.bus.subscribe('*', (e) => {
|
|
@@ -260,8 +278,10 @@ let OperatorService = class OperatorService {
|
|
|
260
278
|
for (const key of [`pw:${e.sessionId}`, `browser:sign-in-required:${e.sessionId}`, `browser:verification-required:${e.sessionId}`])
|
|
261
279
|
this.holdOf(e.sessionId)?.waited(key);
|
|
262
280
|
const status = e.data?.status;
|
|
263
|
-
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId))
|
|
264
|
-
|
|
281
|
+
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId)) {
|
|
282
|
+
const byOperator = status === 'aborted' && this.stoppedByOperator.has(this.runKey(e.sessionId));
|
|
283
|
+
this.lastOutcome = { status, at: e.at, sessionId: e.sessionId, ...(byOperator ? { byOperator: true } : {}) };
|
|
284
|
+
}
|
|
265
285
|
}
|
|
266
286
|
});
|
|
267
287
|
/**
|
|
@@ -414,7 +434,7 @@ let OperatorService = class OperatorService {
|
|
|
414
434
|
await this.init();
|
|
415
435
|
const all = await this.store.listSessions();
|
|
416
436
|
// The pauses of the run going on, for the page to take them off the minutes it shows (2026-10-21).
|
|
417
|
-
return all.map((s) => ({ ...s, running: this.running.has(s.id), paused: this.running.get(s.id)?.hold.held ?? false, ...this.pausesOf(s.id) }));
|
|
437
|
+
return all.map((s) => ({ ...s, running: this.running.has(s.id), paused: this.running.get(this.runKey(s.id))?.hold.held ?? false, ...this.pausesOf(s.id) }));
|
|
418
438
|
}
|
|
419
439
|
async getSession(id) {
|
|
420
440
|
await this.init();
|
|
@@ -422,11 +442,15 @@ let OperatorService = class OperatorService {
|
|
|
422
442
|
if (!s)
|
|
423
443
|
return null;
|
|
424
444
|
const pending = [...this.waiting.values()].filter((w) => w.approval.sessionId === id).map((w) => w.approval);
|
|
425
|
-
|
|
445
|
+
/*
|
|
446
|
+
* Held or not, as its run is: a chat Kerrigan directs is held with hers (bug hunt 2026-11-18: "Pause" there held her
|
|
447
|
+
* run, `pause` goes up the chain, but the chat read its own id, so the button never said "Continue").
|
|
448
|
+
*/
|
|
449
|
+
return { ...s, running: this.running.has(id), paused: this.running.get(this.runKey(id))?.hold.held ?? false, ...this.pausesOf(id), pending, runMode: this.running.get(id)?.mode };
|
|
426
450
|
}
|
|
427
451
|
/** The pauses of the run going on in a session, from "Pause" to "Continue"; none when nothing runs or it was never paused. */
|
|
428
452
|
pausesOf(id) {
|
|
429
|
-
const pauses = this.running.get(id)?.hold.pauses ?? [];
|
|
453
|
+
const pauses = this.running.get(this.runKey(id))?.hold.pauses ?? [];
|
|
430
454
|
return pauses.length > 0 ? { pauses } : {};
|
|
431
455
|
}
|
|
432
456
|
async updateSession(id, patch) {
|
|
@@ -732,6 +756,10 @@ let OperatorService = class OperatorService {
|
|
|
732
756
|
this.browser = holder;
|
|
733
757
|
return { holder };
|
|
734
758
|
}
|
|
759
|
+
/** Why a run of `sessionId` could not have the browser now, without taking it; null when it could. */
|
|
760
|
+
browserBusyFor(sessionId) {
|
|
761
|
+
return this.browser ? browserRefusal(this.browser, { kind: 'run', sessionId }) : null;
|
|
762
|
+
}
|
|
735
763
|
releaseBrowser(holder) {
|
|
736
764
|
if (this.browser === holder)
|
|
737
765
|
this.browser = null;
|
|
@@ -1057,6 +1085,14 @@ let OperatorService = class OperatorService {
|
|
|
1057
1085
|
const cfg = session.kind === 'chat' ? { ...loaded, execution: { ...loaded.execution, denyPatterns: chatDenyPatterns(loaded.execution.denyPatterns) } } : loaded;
|
|
1058
1086
|
// The run's own settings; a save while it goes on changes them in place (`saveSettings`), and these rules with them.
|
|
1059
1087
|
const runCfg = { ...cfg, execution: { ...cfg.execution, mode } };
|
|
1088
|
+
/*
|
|
1089
|
+
* A task of the queue (bug hunt 2026-11-18): nobody is there to choose a model by hand, so the model it names, or
|
|
1090
|
+
* Settings name, is chosen by the bot, whatever Settings say — "by hand" is on by default, and every task of the
|
|
1091
|
+
* queue waited on its model's card and was set aside. One with no model named is refused at "Run the queue"
|
|
1092
|
+
* (`queueWithoutModel`). The models are taken when a message starts, so a save under the run does not undo it.
|
|
1093
|
+
*/
|
|
1094
|
+
if (session.queueItem)
|
|
1095
|
+
runCfg.copilot = { ...runCfg.copilot, manualModel: false, leadManualModel: false, reviewManualModel: false, kerriganManualModel: false };
|
|
1060
1096
|
const live = new LiveSettings(runCfg, session.kind === 'chat', loaded);
|
|
1061
1097
|
const policy = { mode, ...stepRules(runCfg) };
|
|
1062
1098
|
/*
|
|
@@ -1086,6 +1122,7 @@ let OperatorService = class OperatorService {
|
|
|
1086
1122
|
const startedAt = new Date().toISOString();
|
|
1087
1123
|
const hold = new Hold();
|
|
1088
1124
|
this.running.set(sessionId, { controller, startedAt, mode, policy, hold, live });
|
|
1125
|
+
this.stoppedByOperator.delete(sessionId);
|
|
1089
1126
|
// Who was at work in a run of it that ended without saying so is not who is at work in this one.
|
|
1090
1127
|
this.acting.delete(sessionId);
|
|
1091
1128
|
{
|
|
@@ -1210,14 +1247,25 @@ let OperatorService = class OperatorService {
|
|
|
1210
1247
|
}
|
|
1211
1248
|
return tally;
|
|
1212
1249
|
})
|
|
1213
|
-
.finally(() => {
|
|
1250
|
+
.finally(async () => {
|
|
1214
1251
|
for (const [id, w] of this.waiting) {
|
|
1215
1252
|
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
1216
1253
|
w.resolve({ action: 'abort', reason: 'the run ended' });
|
|
1217
1254
|
this.waiting.delete(id);
|
|
1218
1255
|
}
|
|
1219
1256
|
}
|
|
1257
|
+
/*
|
|
1258
|
+
* A Stop that landed as the run ended (bug hunt 2026-11-18): the run had written "idle", and was only adding up
|
|
1259
|
+
* how it went, when `stop` wrote "stopping" over it, which nothing undid: the conversation read as working for
|
|
1260
|
+
* good — "Stopping…", Go back refused, New chat off — until the next message. Before the run is let go of, so no
|
|
1261
|
+
* other run of the session can have begun.
|
|
1262
|
+
*/
|
|
1263
|
+
await this.store.updateSession(sessionId, (s) => {
|
|
1264
|
+
if (s.status === 'stopping')
|
|
1265
|
+
s.status = 'idle';
|
|
1266
|
+
}).catch(() => undefined);
|
|
1220
1267
|
this.running.delete(sessionId);
|
|
1268
|
+
this.stoppedByOperator.delete(sessionId);
|
|
1221
1269
|
});
|
|
1222
1270
|
return { started: true, done };
|
|
1223
1271
|
}
|
|
@@ -1275,12 +1323,14 @@ let OperatorService = class OperatorService {
|
|
|
1275
1323
|
this.bus.publish({ sessionId, type: 'resume-asked', level: 'info', message: 'continued by the operator' });
|
|
1276
1324
|
return { paused: false };
|
|
1277
1325
|
}
|
|
1278
|
-
async stop(asked) {
|
|
1326
|
+
async stop(asked, by = 'operator') {
|
|
1279
1327
|
// A chat Kerrigan directs is stopped with her run (2026-11-12): it is one run.
|
|
1280
1328
|
const sessionId = this.runKey(asked);
|
|
1281
1329
|
const r = this.running.get(sessionId);
|
|
1282
1330
|
if (!r)
|
|
1283
1331
|
return { stopping: false };
|
|
1332
|
+
if (by === 'operator')
|
|
1333
|
+
this.stoppedByOperator.add(sessionId);
|
|
1284
1334
|
r.controller.abort();
|
|
1285
1335
|
for (const [id, w] of this.waiting) {
|
|
1286
1336
|
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
@@ -1325,7 +1375,7 @@ let OperatorService = class OperatorService {
|
|
|
1325
1375
|
// The queue still has its turn going, between one of its tasks and the next (2026-11-03): the work is not over.
|
|
1326
1376
|
...(this.queueLoop ? { queue: true } : {}),
|
|
1327
1377
|
// How the last message ended, while nothing runs: what the tab says until the operator has looked.
|
|
1328
|
-
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at } } : {}),
|
|
1378
|
+
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at, ...(this.lastOutcome.byOperator ? { byOperator: true } : {}) } } : {}),
|
|
1329
1379
|
};
|
|
1330
1380
|
}
|
|
1331
1381
|
/**
|
|
@@ -1652,11 +1702,17 @@ let OperatorService = class OperatorService {
|
|
|
1652
1702
|
}
|
|
1653
1703
|
throw new Error('Kerrigan is at work with this chat: write to her conversation, or Stop her first.');
|
|
1654
1704
|
}
|
|
1655
|
-
|
|
1705
|
+
/*
|
|
1706
|
+
* While the run starts — the window opening, the sign-in, the model's card — its message is still queued (2026-11-18:
|
|
1707
|
+
* "Add to it" then made a message of its own, refused to start and left waiting). The note goes with that message,
|
|
1708
|
+
* which takes the notes not sent yet with its opening.
|
|
1709
|
+
*/
|
|
1710
|
+
const atWork = inFlight ?? (this.running.has(session.id) ? session.tasks.find((t) => t.status === 'queued') : undefined);
|
|
1711
|
+
if (atWork && this.running.has(session.id)) {
|
|
1656
1712
|
if (skill)
|
|
1657
1713
|
throw new Error(`A skill goes with a new message, and this one would be a note to the message at work. Send /${skill.name} when it has finished.`);
|
|
1658
|
-
await this.addTaskNote(session.id,
|
|
1659
|
-
return { threadId: session.id, taskId:
|
|
1714
|
+
await this.addTaskNote(session.id, atWork.id, text);
|
|
1715
|
+
return { threadId: session.id, taskId: atWork.id, noted: true, needsStart: false };
|
|
1660
1716
|
}
|
|
1661
1717
|
}
|
|
1662
1718
|
else {
|
|
@@ -1732,15 +1788,19 @@ let OperatorService = class OperatorService {
|
|
|
1732
1788
|
});
|
|
1733
1789
|
}
|
|
1734
1790
|
// After going back, the conversation is told with this message: it still holds what was undone.
|
|
1735
|
-
|
|
1736
|
-
if (pending) {
|
|
1737
|
-
await this.store.addTaskNote(session.id, task.id, pending);
|
|
1738
|
-
await this.store.updateSession(session.id, (s) => {
|
|
1739
|
-
s.rewindNote = undefined;
|
|
1740
|
-
});
|
|
1741
|
-
}
|
|
1791
|
+
await this.moveRewindNote(session.id, task.id);
|
|
1742
1792
|
return { threadId: session.id, taskId: task.id, needsStart: false };
|
|
1743
1793
|
}
|
|
1794
|
+
/** What going back undid, told to the conversation with the next message that goes to it: a new one, or one carried on. */
|
|
1795
|
+
async moveRewindNote(sessionId, taskId) {
|
|
1796
|
+
const pending = (await this.store.getSession(sessionId))?.rewindNote;
|
|
1797
|
+
if (!pending)
|
|
1798
|
+
return;
|
|
1799
|
+
await this.store.addTaskNote(sessionId, taskId, pending);
|
|
1800
|
+
await this.store.updateSession(sessionId, (s) => {
|
|
1801
|
+
s.rewindNote = undefined;
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1744
1804
|
// --- the queue of tasks (2026-10-24) ----------------------------------------------------------------
|
|
1745
1805
|
//
|
|
1746
1806
|
// Tasks written beforehand, each run in a new chat on its own model while nobody watches; one that failed takes
|
|
@@ -1790,6 +1850,30 @@ let OperatorService = class OperatorService {
|
|
|
1790
1850
|
this.queueTurn = done.catch(() => undefined);
|
|
1791
1851
|
return done;
|
|
1792
1852
|
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Changes put aside before a task (2026-11-18): when they are the work of one task on "the folder as it is" that waits
|
|
1855
|
+
* to carry on — set aside at a card, stopped with the queue — on the branch they were left on, that task gets them back
|
|
1856
|
+
* when it carries on (`putBackAside`). Two such tasks there: whose is whose cannot be told, and they stay where they
|
|
1857
|
+
* were put, as said.
|
|
1858
|
+
*/
|
|
1859
|
+
async leftoversOf(onBranch, except, saved) {
|
|
1860
|
+
if (!onBranch)
|
|
1861
|
+
return;
|
|
1862
|
+
const q = await this.readQueue();
|
|
1863
|
+
const owners = [];
|
|
1864
|
+
for (const x of q.items) {
|
|
1865
|
+
if (x.id === except || x.branch !== 'folder' || !x.sessionId || !(x.status === 'parked' || (x.status === 'waiting' && x.resume)))
|
|
1866
|
+
continue;
|
|
1867
|
+
const s = await this.store.getSession(x.sessionId);
|
|
1868
|
+
const t = s?.tasks.find((k) => k.parked && !k.parked.answer) ?? s?.tasks.at(-1);
|
|
1869
|
+
if (s && !s.vcs?.enabled && t?.checkpoint?.branch === onBranch)
|
|
1870
|
+
owners.push(x.id);
|
|
1871
|
+
}
|
|
1872
|
+
if (owners.length !== 1)
|
|
1873
|
+
return;
|
|
1874
|
+
const owner = owners[0];
|
|
1875
|
+
await this.changeQueue((x) => this.setQueueItem(x, owner, { setAside: [...(x.items.find((i) => i.id === owner)?.setAside ?? []), saved] }));
|
|
1876
|
+
}
|
|
1793
1877
|
setQueueItem(q, id, patch) {
|
|
1794
1878
|
const item = q.items.find((x) => x.id === id);
|
|
1795
1879
|
if (!item)
|
|
@@ -1813,8 +1897,15 @@ let OperatorService = class OperatorService {
|
|
|
1813
1897
|
await this.changeQueue((x) => {
|
|
1814
1898
|
x.running = false;
|
|
1815
1899
|
for (const item of x.items) {
|
|
1816
|
-
|
|
1817
|
-
|
|
1900
|
+
/*
|
|
1901
|
+
* It carries on, in its own chat, when the queue is run again (bug hunt 2026-11-18): marked stopped, every task
|
|
1902
|
+
* that depends on it was skipped at the next run, and only "Run again", which starts it over, was left.
|
|
1903
|
+
*/
|
|
1904
|
+
if (item.status === 'running') {
|
|
1905
|
+
Object.assign(item, item.sessionId
|
|
1906
|
+
? { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the bot was closed while it ran'), endedAt: new Date().toISOString() }
|
|
1907
|
+
: { status: 'waiting', why: undefined });
|
|
1908
|
+
}
|
|
1818
1909
|
}
|
|
1819
1910
|
});
|
|
1820
1911
|
}
|
|
@@ -1847,7 +1938,17 @@ let OperatorService = class OperatorService {
|
|
|
1847
1938
|
throw new Error(checked.problem);
|
|
1848
1939
|
// A skill is one of Settings' (2026-10-25); whether it is for the folder is said when the task runs, in its chat.
|
|
1849
1940
|
const { skills } = await this.skills();
|
|
1850
|
-
|
|
1941
|
+
/*
|
|
1942
|
+
* Only a task that will run with it (bug hunt 2026-11-18): one done, failed or skipped with a skill taken out of
|
|
1943
|
+
* Settings since blocked every edit of the queue, and cannot itself be edited. A new one, one whose skill changes,
|
|
1944
|
+
* and one that waits or is put back to wait are held to Settings' skills.
|
|
1945
|
+
*/
|
|
1946
|
+
const before = new Map((await this.readQueue()).items.map((x) => [x.id, x]));
|
|
1947
|
+
const runs = (x) => {
|
|
1948
|
+
const was = before.get(x.id);
|
|
1949
|
+
return !was || was.skill !== x.skill || (x.status ?? was.status) === 'waiting';
|
|
1950
|
+
};
|
|
1951
|
+
const unknown = checked.items.findIndex((x) => x.skill && runs(x) && !skills.some((k) => k.name === x.skill));
|
|
1851
1952
|
if (unknown >= 0) {
|
|
1852
1953
|
const name = checked.items[unknown].skill;
|
|
1853
1954
|
throw new Error(`Task ${unknown + 1} is sent with the skill "${name}", which is not in Settings → Skills${skills.length > 0 ? `; there are ${skills.map((k) => k.name).join(', ')}` : ''}.`);
|
|
@@ -2023,7 +2124,8 @@ let OperatorService = class OperatorService {
|
|
|
2023
2124
|
if (ask)
|
|
2024
2125
|
await closePasswordWindows(ask, new Date(Date.parse(approval.createdAt) - 5_000)).catch(() => 0);
|
|
2025
2126
|
}
|
|
2026
|
-
|
|
2127
|
+
// Set aside by the queue, not stopped by the operator: its ending is said.
|
|
2128
|
+
await this.stop(key, 'bot').catch(() => undefined);
|
|
2027
2129
|
}
|
|
2028
2130
|
/**
|
|
2029
2131
|
* The operator's answer to a parked task, given when they are back (2026-10-26): kept on the task's record, and the
|
|
@@ -2038,13 +2140,30 @@ let OperatorService = class OperatorService {
|
|
|
2038
2140
|
throw new Error('That task is not in the queue any more.');
|
|
2039
2141
|
if (item.status !== 'parked' || !item.sessionId)
|
|
2040
2142
|
throw new Error('That task is not waiting for an answer.');
|
|
2143
|
+
/*
|
|
2144
|
+
* The card of another run of it (bug hunt 2026-11-18): a card left in the chat of an earlier run — stopped, run
|
|
2145
|
+
* again, or a task removed whose id a new one took — answered the card the queue's task waits on now, unseen.
|
|
2146
|
+
*/
|
|
2147
|
+
if (typeof input?.sessionId === 'string' && input.sessionId !== item.sessionId) {
|
|
2148
|
+
throw new Error('That card is of another run of this task: what the task waits for now is on the queue\'s page.');
|
|
2149
|
+
}
|
|
2041
2150
|
const s = await this.store.getSession(item.sessionId);
|
|
2042
2151
|
const task = s?.tasks.find((t) => t.parked && !t.parked.answer);
|
|
2043
|
-
|
|
2044
|
-
|
|
2152
|
+
// Stopped whatever its record says (2026-11-18): a Stop that failed with the record gone left the task, and the ones
|
|
2153
|
+
// that depend on it, waiting for good.
|
|
2045
2154
|
if (input?.stop === true) {
|
|
2155
|
+
// Said on the record too, so its chat does not offer the card again (bug hunt 2026-11-18).
|
|
2156
|
+
if (s && task) {
|
|
2157
|
+
await this.store.updateSession(s.id, (x) => {
|
|
2158
|
+
const t = x.tasks.find((y) => y.id === task.id);
|
|
2159
|
+
if (t?.parked && !t.parked.answer)
|
|
2160
|
+
t.parked.answer = { kind: 'stopped', at: new Date().toISOString() };
|
|
2161
|
+
}).catch(() => undefined);
|
|
2162
|
+
}
|
|
2046
2163
|
return await this.withBusy(await this.changeQueue((x) => this.setQueueItem(x, itemId, { status: 'stopped', why: 'stopped by the operator at its card', waitsFor: undefined })));
|
|
2047
2164
|
}
|
|
2165
|
+
if (!s || !task?.parked)
|
|
2166
|
+
throw new Error('What that task waited for is not on its record any more; run it again.');
|
|
2048
2167
|
const answer = parkedAnswerFrom(task.parked, input);
|
|
2049
2168
|
if ('problem' in answer)
|
|
2050
2169
|
throw new Error(answer.problem);
|
|
@@ -2090,6 +2209,9 @@ let OperatorService = class OperatorService {
|
|
|
2090
2209
|
// Stopped — from the queue, or the chat's Stop: the rest wait for the operator. Parked: the queue goes on.
|
|
2091
2210
|
if (ended.status === 'stopped')
|
|
2092
2211
|
return;
|
|
2212
|
+
// Stopped with the queue, to carry on at the next run: the loop sees the queue stopped and ends (2026-11-18).
|
|
2213
|
+
if (ended.status === 'waiting' && !(await this.readQueue()).running)
|
|
2214
|
+
return;
|
|
2093
2215
|
}
|
|
2094
2216
|
}
|
|
2095
2217
|
/** One task of the queue, in a new chat — or, answered after it was parked, in its own — to its end. */
|
|
@@ -2099,9 +2221,10 @@ let OperatorService = class OperatorService {
|
|
|
2099
2221
|
// Read afresh each time: the browser is let go of by other work while this waits.
|
|
2100
2222
|
const holder = () => this.browser;
|
|
2101
2223
|
// The browser may be the chat's, or a reading of the models': the task waits its turn.
|
|
2224
|
+
// Stopped before it began: it waits as it did (2026-11-18), not "stopped", which skipped what depends on it.
|
|
2102
2225
|
while (holder()) {
|
|
2103
2226
|
if (this.queueClosing || !(await stillRunning()))
|
|
2104
|
-
return { status: '
|
|
2227
|
+
return { status: 'waiting', why: undefined };
|
|
2105
2228
|
await pause(1_000);
|
|
2106
2229
|
}
|
|
2107
2230
|
const ws = await this.workspace();
|
|
@@ -2110,12 +2233,64 @@ let OperatorService = class OperatorService {
|
|
|
2110
2233
|
const cfg = await this.settings.load();
|
|
2111
2234
|
let sessionId;
|
|
2112
2235
|
let taskId;
|
|
2236
|
+
/** Carried on with "Continue" in its own chat: stopped with the queue, or the bot closed under it (2026-11-18). */
|
|
2237
|
+
let carryOn = false;
|
|
2113
2238
|
if (item.resume && item.sessionId) {
|
|
2114
|
-
const
|
|
2115
|
-
|
|
2116
|
-
|
|
2239
|
+
const s0 = await this.store.getSession(item.sessionId);
|
|
2240
|
+
const answered = s0?.tasks.find((t) => t.parked?.answer && t.parked.answer.kind !== 'stopped');
|
|
2241
|
+
const last = s0?.tasks.at(-1);
|
|
2242
|
+
if (!s0 || !last)
|
|
2243
|
+
return { status: 'failed', why: 'its chat is not there any more; run it again' };
|
|
2244
|
+
/*
|
|
2245
|
+
* Back on the branch it began on, a task on "the folder as it is" (bug hunt 2026-11-18): it carried on on whatever
|
|
2246
|
+
* branch the task after it left the folder on — one made for another task. What that left uncommitted is put
|
|
2247
|
+
* aside first, kept whole and not pushed, as before a task on a branch of its own.
|
|
2248
|
+
*/
|
|
2249
|
+
const began = (answered ?? last).checkpoint?.branch;
|
|
2250
|
+
if (ws.isRepo && !s0.vcs?.enabled && began) {
|
|
2251
|
+
const onNow = (await git(ws.dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']).catch(() => null))?.stdout || null;
|
|
2252
|
+
if (onNow !== began) {
|
|
2253
|
+
const aside = await setAsideUncommitted(ws.dir, `the queue's task "${itemTitle(item)}" carries on on ${began}, where it began, and the folder held changes left on ${onNow ?? 'a detached HEAD'}`);
|
|
2254
|
+
if (aside && 'problem' in aside)
|
|
2255
|
+
return { status: 'failed', why: `what was not committed in the folder could not be put aside before it: ${aside.problem}`, sessionId: s0.id };
|
|
2256
|
+
const back = await git(ws.dir, ['switch', began]);
|
|
2257
|
+
if (!back.ok)
|
|
2258
|
+
return { status: 'failed', why: `it could not be put back on ${began}, where it began: ${(back.stderr || back.stdout).trim().slice(0, 300)}`, sessionId: s0.id };
|
|
2259
|
+
this.bus.publish({ sessionId: s0.id, type: 'queue-back-on-branch', level: 'info',
|
|
2260
|
+
message: `back on ${began}, where it began, before it carries on (the folder was on ${onNow ?? 'a detached HEAD'})${aside ? `; what was not committed there is kept on ${aside.saved}, not pushed` : ''}`,
|
|
2261
|
+
data: { branch: began, was: onNow, ...(aside ? { saved: aside.saved } : {}) } });
|
|
2262
|
+
if (aside && 'saved' in aside)
|
|
2263
|
+
await this.leftoversOf(onNow, item.id, aside.saved);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
// Its own work, put aside by a task after it on a branch of its own (2026-11-18): put back before it carries on.
|
|
2267
|
+
for (const saved of item.setAside ?? []) {
|
|
2268
|
+
const back = ws.isRepo && !s0.vcs?.enabled ? await putBackAside(ws.dir, saved) : { problem: 'it no longer works on the folder as it is' };
|
|
2269
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { setAside: (x.items.find((i) => i.id === item.id)?.setAside ?? []).filter((n) => n !== saved) }));
|
|
2270
|
+
this.bus.publish({ sessionId: s0.id, type: 'queue-put-back', level: 'problem' in back ? 'warn' : 'info',
|
|
2271
|
+
message: 'problem' in back
|
|
2272
|
+
? `what it had not committed, put aside on ${saved} by a task after it, could not be put back: ${back.problem}`
|
|
2273
|
+
: `what it had not committed (${back.files} file(s)), put aside on ${saved} by a task after it, is back in the folder, not committed`,
|
|
2274
|
+
data: { saved, ...('problem' in back ? { problem: back.problem } : { files: back.files }) } });
|
|
2275
|
+
if ('problem' in back)
|
|
2276
|
+
await this.store.addTaskNote(s0.id, (answered ?? last).id, `What you had changed and not committed was put aside on the branch ${saved} while you waited, and could not be put back: ${back.problem}. Take back what you need from there (git restore --source ${saved} -- <path>).`).catch(() => undefined);
|
|
2277
|
+
}
|
|
2278
|
+
if (answered) {
|
|
2279
|
+
const carried = await this.resumeParked(item.sessionId, ws.dir);
|
|
2280
|
+
if ('problem' in carried)
|
|
2281
|
+
return { status: 'failed', why: carried.problem, sessionId: item.sessionId };
|
|
2282
|
+
taskId = carried.taskId;
|
|
2283
|
+
}
|
|
2284
|
+
else {
|
|
2285
|
+
// Finished in its chat meanwhile, or ended there in a way "Continue" does not carry on: as it ended.
|
|
2286
|
+
if (last.status !== 'queued' && !isContinuable(last)) {
|
|
2287
|
+
const status = statusOfTask(last.status);
|
|
2288
|
+
return { status, ...(status !== 'done' ? { why: last.reason ?? `it ended ${last.status}` } : {}), sessionId: s0.id };
|
|
2289
|
+
}
|
|
2290
|
+
taskId = last.id;
|
|
2291
|
+
carryOn = true;
|
|
2292
|
+
}
|
|
2117
2293
|
sessionId = item.sessionId;
|
|
2118
|
-
taskId = carried.taskId;
|
|
2119
2294
|
}
|
|
2120
2295
|
else {
|
|
2121
2296
|
// Settings may have changed since the queue was started.
|
|
@@ -2128,13 +2303,14 @@ let OperatorService = class OperatorService {
|
|
|
2128
2303
|
if (!(await branchExists(ws.dir, branchName)))
|
|
2129
2304
|
branchName = undefined;
|
|
2130
2305
|
else {
|
|
2131
|
-
const fresh = await refreshQueueBranch(ws.dir, branchName, item.branchBase);
|
|
2306
|
+
const fresh = await refreshQueueBranch(ws.dir, branchName, item.branchBase, item.branchFrom);
|
|
2132
2307
|
if (fresh.moved)
|
|
2133
|
-
await this.changeQueue((x) => this.setQueueItem(x, item.id, { branchBase: fresh.base, branchFrom:
|
|
2308
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { branchBase: fresh.base, ...(fresh.from ? { branchFrom: fresh.from } : {}) }));
|
|
2134
2309
|
}
|
|
2135
2310
|
}
|
|
2136
2311
|
// Not made when it was added — no repository then, or no main to make it from: made now, asking nobody anything.
|
|
2137
|
-
|
|
2312
|
+
// As it is now: brought up to the remote's main just above, it was made from that.
|
|
2313
|
+
let branchFrom = (await this.readQueue()).items.find((x) => x.id === item.id)?.branchFrom ?? item.branchFrom;
|
|
2138
2314
|
if (item.branch === 'main' && ws.isRepo && !branchName) {
|
|
2139
2315
|
const start = await branchStart(ws.dir, null);
|
|
2140
2316
|
if ('problem' in start)
|
|
@@ -2169,31 +2345,54 @@ let OperatorService = class OperatorService {
|
|
|
2169
2345
|
});
|
|
2170
2346
|
// Where its branch came from, told with its opening message: the local main when the server's could not be read.
|
|
2171
2347
|
if (branchName) {
|
|
2172
|
-
await this.store.addTaskNote(sessionId, taskId, branchFrom &&
|
|
2348
|
+
await this.store.addTaskNote(sessionId, taskId, branchFrom && !(await madeFromRemote(ws.dir, branchFrom))
|
|
2173
2349
|
? `This task works on its own branch ${branchName}, made from the local \`${branchFrom}\`: the server's main could not be fetched without asking for a password, and a run never types one. Do not try to fetch or pull it.`
|
|
2174
2350
|
: `This task works on its own branch ${branchName}, made from the server's main (${branchFrom ?? 'origin/main'}). Do not switch to another branch.`).catch(() => undefined);
|
|
2175
2351
|
}
|
|
2176
2352
|
await this.changeQueue((x) => this.setQueueItem(x, item.id, { sessionId }));
|
|
2177
2353
|
}
|
|
2354
|
+
/*
|
|
2355
|
+
* On a branch of its own, in a folder another task left changes in (2026-11-18): those are put aside, kept whole on a
|
|
2356
|
+
* branch of their own and never pushed, as "New branch from main" puts them aside — or the task is refused for them,
|
|
2357
|
+
* and so is every task that depends on it, in a queue nobody is watching. Left alone when the folder is already on
|
|
2358
|
+
* this task's own branch: what is there is its own work, carried on.
|
|
2359
|
+
*/
|
|
2360
|
+
const runOn = (await this.store.getSession(sessionId))?.vcs;
|
|
2361
|
+
if (ws.isRepo && runOn?.enabled && runOn.startFrom === 'existing-branch' && runOn.existingBranch) {
|
|
2362
|
+
const onNow = (await git(ws.dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']).catch(() => null))?.stdout || null;
|
|
2363
|
+
if (onNow !== runOn.existingBranch) {
|
|
2364
|
+
const aside = await setAsideUncommitted(ws.dir, `the queue's task "${itemTitle(item)}" works on its own branch ${runOn.existingBranch}, and the folder held changes left on ${onNow ?? 'a detached HEAD'}`);
|
|
2365
|
+
if (aside && 'problem' in aside)
|
|
2366
|
+
return { status: 'failed', why: `what was not committed in the folder could not be put aside before it: ${aside.problem}`, sessionId };
|
|
2367
|
+
if (aside) {
|
|
2368
|
+
this.bus.publish({ sessionId, type: 'queue-set-aside', level: 'warn',
|
|
2369
|
+
message: `what was not committed in the folder (${aside.files} file(s), on ${onNow ?? 'a detached HEAD'}) was put aside on ${aside.saved}, not pushed, before this task started on its own branch` });
|
|
2370
|
+
await this.leftoversOf(onNow, item.id, aside.saved);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2178
2374
|
/*
|
|
2179
2375
|
* A message of the chat sent meanwhile has the browser: this one starts after it, never refused for it. The browser
|
|
2180
2376
|
* is looked at and taken in the same moment — `start` takes it before it awaits anything.
|
|
2181
2377
|
*/
|
|
2182
2378
|
while (holder()) {
|
|
2183
2379
|
if (this.queueClosing || !(await stillRunning()))
|
|
2184
|
-
return { status: '
|
|
2380
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the queue was stopped before it began'), sessionId };
|
|
2185
2381
|
await pause(1_000);
|
|
2186
2382
|
}
|
|
2187
2383
|
this.queueAtWork.add(sessionId);
|
|
2384
|
+
/** Stopped with the queue: it carries on at the next run rather than counting as stopped (2026-11-18). */
|
|
2385
|
+
let asked = false;
|
|
2188
2386
|
try {
|
|
2189
|
-
const reply =
|
|
2387
|
+
const reply = carryOn
|
|
2388
|
+
? await this.chatContinue(sessionId, taskId).catch((e) => ({ started: false, reason: e.message }))
|
|
2389
|
+
: await this.start(sessionId, cfg.execution.mode);
|
|
2190
2390
|
if (!reply.started)
|
|
2191
2391
|
return { status: 'failed', why: reply.reason ?? 'it did not start', sessionId };
|
|
2192
2392
|
// Until its run has ended and its window let the browser go, so the next one can have it.
|
|
2193
|
-
let asked = false;
|
|
2194
2393
|
while (this.running.has(sessionId) || (holder()?.kind === 'run' && holder().sessionId === sessionId)) {
|
|
2195
2394
|
if (this.queueClosing)
|
|
2196
|
-
return { status: '
|
|
2395
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the bot was closed while it ran'), sessionId };
|
|
2197
2396
|
if (!asked && !(await stillRunning())) {
|
|
2198
2397
|
asked = true;
|
|
2199
2398
|
await this.stop(sessionId).catch(() => undefined);
|
|
@@ -2216,6 +2415,10 @@ let OperatorService = class OperatorService {
|
|
|
2216
2415
|
});
|
|
2217
2416
|
return { status: 'parked', why, sessionId };
|
|
2218
2417
|
}
|
|
2418
|
+
// Stopped with the queue ("Stop the queue … the rest wait"): it carries on, in its own chat, at the next run.
|
|
2419
|
+
if ((asked || !(await stillRunning())) && task && (task.status === 'queued' || isContinuable(task))) {
|
|
2420
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the queue was stopped while it ran'), sessionId };
|
|
2421
|
+
}
|
|
2219
2422
|
const status = statusOfTask(task?.status);
|
|
2220
2423
|
return { status, ...(status !== 'done' ? { why: task?.reason ?? `it ended ${task?.status ?? 'without a record'}` } : {}), sessionId };
|
|
2221
2424
|
}
|
|
@@ -2227,23 +2430,31 @@ let OperatorService = class OperatorService {
|
|
|
2227
2430
|
*/
|
|
2228
2431
|
async resumeParked(sessionId, dir) {
|
|
2229
2432
|
const s = await this.store.getSession(sessionId);
|
|
2230
|
-
|
|
2433
|
+
// Not one stopped at its card (2026-11-18): that is an answer that does not carry it on.
|
|
2434
|
+
const task = s?.tasks.find((t) => t.parked?.answer && t.parked.answer.kind !== 'stopped');
|
|
2231
2435
|
const p = task?.parked;
|
|
2232
2436
|
const a = p?.answer;
|
|
2233
|
-
if (!s || !task || !p || !a)
|
|
2437
|
+
if (!s || !task || !p || !a || a.kind === 'stopped')
|
|
2234
2438
|
return { problem: 'its answer is not on its record any more; run it again' };
|
|
2235
2439
|
const continuing = { fromAttempt: task.attempt ?? 1, stoppedBecause: task.reason, how: 'parked', parkedFor: p.kind };
|
|
2236
2440
|
let note = '';
|
|
2237
2441
|
let approvedPlan;
|
|
2238
2442
|
const command = p.approval.description.replace(/^\[[\w-]+\]\s*/, '');
|
|
2443
|
+
/*
|
|
2444
|
+
* The lead's plan, with two chats (bug hunt 2026-11-18): told in the lead's words. The single chat's said to reply
|
|
2445
|
+
* with status "continue", which is not the lead's, and it was asked again for its format.
|
|
2446
|
+
*/
|
|
2447
|
+
const ofLead = !!task.lead;
|
|
2239
2448
|
if (a.kind === 'plan') {
|
|
2449
|
+
const revised = a.note?.trim() || 'Make the plan more concrete: name the files and the stages.';
|
|
2240
2450
|
if (a.decision === 'approve' && p.approval.plan) {
|
|
2241
2451
|
approvedPlan = { ...p.approval.plan.plan, approved: { by: 'operator', at: a.at, ...(a.note?.trim() ? { note: a.note.trim() } : {}) } };
|
|
2242
|
-
|
|
2452
|
+
// Carried on, the lead may give as many subtasks again as Settings allow (see `runLeadTask`).
|
|
2453
|
+
note = ofLead ? leadPlanApproved(approvedPlan.approved, Math.max(1, (await this.settings.load()).limits.maxSubtasks ?? 20)) : planApprovedMessage(approvedPlan.approved);
|
|
2243
2454
|
}
|
|
2244
2455
|
else {
|
|
2245
2456
|
continuing.replan = true;
|
|
2246
|
-
note =
|
|
2457
|
+
note = ofLead ? leadPlanRevise(revised, p.approval.plan?.plan.version ?? 1) : planReviseMessage(revised, p.approval.plan?.plan.version ?? 1);
|
|
2247
2458
|
}
|
|
2248
2459
|
}
|
|
2249
2460
|
else if (a.kind === 'question') {
|
|
@@ -2260,17 +2471,30 @@ let OperatorService = class OperatorService {
|
|
|
2260
2471
|
}
|
|
2261
2472
|
else if (a.kind === 'retry' && p.approval.retry) {
|
|
2262
2473
|
const r = p.approval.retry;
|
|
2263
|
-
|
|
2264
|
-
|
|
2474
|
+
const worker = await this.store.getSession(p.approval.sessionId);
|
|
2475
|
+
if (a.choice === 'accept') {
|
|
2476
|
+
/*
|
|
2477
|
+
* With what its last attempt ended on (bug hunt 2026-11-18): the lead was given only that it failed, where the
|
|
2478
|
+
* run itself gives it the subtask's report.
|
|
2479
|
+
*/
|
|
2480
|
+
const last = worker?.tasks.find((t) => t.id === p.approval.taskId);
|
|
2481
|
+
const ended = last ? [`Its last attempt ended ${last.status}${last.reason ? `: ${last.reason}` : ''}.`, ...(last.summary?.trim() ? ['', 'The worker\'s summary:', '', last.summary.trim()] : [])] : [];
|
|
2482
|
+
note = [`Subtask ${r.n} (${r.title}) is taken as failed, at the operator's word: decide what to do next without it.`, ...(ended.length > 0 ? ['', ...ended] : [])].join('\n');
|
|
2483
|
+
}
|
|
2265
2484
|
else {
|
|
2266
2485
|
if (a.choice === 'restore') {
|
|
2267
|
-
|
|
2268
|
-
|
|
2486
|
+
/*
|
|
2487
|
+
* To the subtask's start, its first attempt's photograph, as the run puts it back (bug hunt 2026-11-18): the
|
|
2488
|
+
* card's own task is the last attempt's, whose photograph holds what the attempts before it changed.
|
|
2489
|
+
*/
|
|
2490
|
+
const first = [...(task.lead?.rounds ?? [])].reverse().find((x) => x.subtask?.n === r.n)?.subtask?.attempts?.[0]?.taskId ?? p.approval.taskId;
|
|
2491
|
+
const cp = worker?.tasks.find((t) => t.id === first)?.checkpoint;
|
|
2269
2492
|
const back = cp ? await restoreCheckpoint(dir, cp) : { ok: false, problem: 'the subtask\'s start was not photographed' };
|
|
2270
2493
|
if (!back.ok)
|
|
2271
2494
|
return { problem: `the folder could not be put back to the subtask's start (${back.problem}); answer it again with another choice` };
|
|
2272
2495
|
}
|
|
2273
|
-
|
|
2496
|
+
// Put back: the next attempt is told it starts over, not to carry on from what the last one left.
|
|
2497
|
+
continuing.retrySubtask = { n: r.n, ...(a.choice === 'fresh' ? { fresh: true } : {}), ...(a.choice === 'restore' ? { restored: true } : {}) };
|
|
2274
2498
|
}
|
|
2275
2499
|
}
|
|
2276
2500
|
else if (a.kind === 'command') {
|
|
@@ -2571,6 +2795,10 @@ let OperatorService = class OperatorService {
|
|
|
2571
2795
|
const last = sub.attempts?.at(-1);
|
|
2572
2796
|
if (last?.status === 'done')
|
|
2573
2797
|
throw new Error(`Subtask ${n} was done; it is not done again.`);
|
|
2798
|
+
// The browser first, as for Continue (2026-11-18): nothing changes when it is not free.
|
|
2799
|
+
const busy = this.browserBusyFor(threadId);
|
|
2800
|
+
if (busy)
|
|
2801
|
+
throw new Error(busy);
|
|
2574
2802
|
await this.store.rerunTask(threadId, taskId, {}, { fromAttempt: task.attempt ?? 1, stoppedBecause: task.reason, how: 'stopped', retrySubtask: { n, ...(fresh ? { fresh: true } : {}) } });
|
|
2575
2803
|
const cfg = await this.settings.load();
|
|
2576
2804
|
return await this.start(threadId, cfg.execution.mode);
|
|
@@ -2588,21 +2816,45 @@ let OperatorService = class OperatorService {
|
|
|
2588
2816
|
const session = await this.store.getSession(threadId);
|
|
2589
2817
|
if (!session || session.kind !== 'chat')
|
|
2590
2818
|
throw new Error('That conversation is not there any more.');
|
|
2591
|
-
if (session.directedBy)
|
|
2592
|
-
throw new Error('Kerrigan directs this chat: carry her conversation on instead.');
|
|
2593
2819
|
if (this.running.has(this.runKey(threadId)))
|
|
2594
2820
|
throw new Error('The conversation is working: stop it first, or let it finish.');
|
|
2595
2821
|
const task = session.tasks.find((t) => t.id === taskId);
|
|
2596
2822
|
if (!task)
|
|
2597
2823
|
throw new Error('That message is not in this conversation.');
|
|
2824
|
+
/*
|
|
2825
|
+
* A chat Kerrigan directs: her messages are carried on in her conversation. One the operator wrote there while she
|
|
2826
|
+
* was not at work is theirs, and Continue carries it on as in any chat (bug hunt 2026-11-18: it ran, and when it
|
|
2827
|
+
* stopped nothing could carry it on).
|
|
2828
|
+
*/
|
|
2829
|
+
if (session.directedBy && task.fromKerrigan)
|
|
2830
|
+
throw new Error('Kerrigan sent this message: carry her conversation on instead.');
|
|
2598
2831
|
if (session.tasks.at(-1)?.id !== taskId)
|
|
2599
2832
|
throw new Error('Only the last message of a conversation is carried on: the conversation has gone on past this one.');
|
|
2833
|
+
/*
|
|
2834
|
+
* The browser first (2026-11-18): the message was put back on the queue and then refused the browser — another
|
|
2835
|
+
* conversation, the queue, a read of the models had it — and was left "waiting to start", with no Continue and only
|
|
2836
|
+
* "Go back" under it. Now nothing changes when the browser is not free.
|
|
2837
|
+
*/
|
|
2838
|
+
// A queue task set aside is answered on its card (2026-11-18): carried on here, its queue entry lost what it waited for.
|
|
2839
|
+
if (task.parked && !task.parked.answer)
|
|
2840
|
+
throw new Error('This message waits for an answer on its card in the queue: answer it there, and the queue carries it on.');
|
|
2841
|
+
const busy = this.browserBusyFor(threadId);
|
|
2842
|
+
if (busy)
|
|
2843
|
+
throw new Error(busy);
|
|
2844
|
+
const cfg = await this.settings.load();
|
|
2845
|
+
/*
|
|
2846
|
+
* A message never sent (2026-11-18): stopped while the window opened, the sign-in was awaited or the model chosen, its
|
|
2847
|
+
* start refused, or the bot closed first. It is sent now as it is: not "carried on", which Copilot never saw begin.
|
|
2848
|
+
*/
|
|
2849
|
+
if (task.status === 'queued')
|
|
2850
|
+
return await this.start(threadId, cfg.execution.mode);
|
|
2600
2851
|
if (!isContinuable(task)) {
|
|
2601
2852
|
throw new Error(task.status === 'done' ? 'This message is done.' : 'Only a message that stopped before it was done is carried on; write the next message instead.');
|
|
2602
2853
|
}
|
|
2603
|
-
const cfg = await this.settings.load();
|
|
2604
2854
|
const stoppedAt = task.status === 'aborted' && !task.interruption && task.runId ? await readInterruption(join(cfg.resolved.runsDir, task.runId)).catch(() => null) : null;
|
|
2605
2855
|
const queued = await this.store.continueTask(threadId, taskId, stoppedAt);
|
|
2856
|
+
// After going back, the conversation is told with the message that carries on, as with a new one (2026-11-18).
|
|
2857
|
+
await this.moveRewindNote(threadId, taskId);
|
|
2606
2858
|
await appendSessionLog(cfg.resolved.runsDir, threadId, {
|
|
2607
2859
|
type: 'continue',
|
|
2608
2860
|
message: `"${queued.title}" carried on as attempt ${queued.attempt ?? 1}, from where it stopped: ${task.reason ?? task.status}`,
|
|
@@ -2695,9 +2947,14 @@ let OperatorService = class OperatorService {
|
|
|
2695
2947
|
if (text.length > MAX_INSTRUCTION_CHARS)
|
|
2696
2948
|
return { ok: false, problem: `The note is ${text.length} characters; it can be at most ${MAX_INSTRUCTION_CHARS}.` };
|
|
2697
2949
|
this.waiting.delete(approvalId);
|
|
2950
|
+
if (action === 'stop' && !as)
|
|
2951
|
+
this.stoppedByOperator.add(this.runKey(w.approval.sessionId));
|
|
2698
2952
|
w.resolvePlan({ decision: action, ...(text ? { note: text } : {}), ...(as ? { by: as.by } : {}) });
|
|
2699
2953
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2700
2954
|
message: `plan: ${action}${text ? ' (with a note)' : ''}${as ? `, by Kerrigan${as.why ? ` — ${as.why}` : ''}` : ''}`, data: { approvalId, action, plan: true, ...(as ? { by: as.by } : {}) } });
|
|
2955
|
+
// The operator's Stop on the plan of a chat inside another's run stops the run (see `decide`); Kerrigan's is her own.
|
|
2956
|
+
if (action === 'stop' && !as && this.runKey(w.approval.sessionId) !== w.approval.sessionId)
|
|
2957
|
+
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
2701
2958
|
return { ok: true };
|
|
2702
2959
|
}
|
|
2703
2960
|
/** What waits for the operator; of one session, its worker's included (two chats: they are asked in its conversation). */
|
|
@@ -2715,9 +2972,23 @@ let OperatorService = class OperatorService {
|
|
|
2715
2972
|
*/
|
|
2716
2973
|
decide(approvalId, action) {
|
|
2717
2974
|
const w = this.waiting.get(approvalId);
|
|
2975
|
+
// Said (bug hunt 2026-11-18): answered "ok: false" with 200, the press looked taken, and the card went on waiting.
|
|
2718
2976
|
if (!w)
|
|
2719
|
-
return { ok: false };
|
|
2977
|
+
return { ok: false, problem: CARD_GONE };
|
|
2978
|
+
/*
|
|
2979
|
+
* "Run this and the rest" where the run may not go on unasked (policy.lock.json, an empty allowlist, the isolation):
|
|
2980
|
+
* it ran the step as "Run", the next was asked again, and nothing said why (bug hunt 2026-11-18). Refused before the
|
|
2981
|
+
* card is answered, with the reason; "Run" is there for this step.
|
|
2982
|
+
*/
|
|
2983
|
+
if (action === 'run-all') {
|
|
2984
|
+
const run = this.running.get(this.runKey(w.approval.sessionId));
|
|
2985
|
+
const blocked = run && run.mode !== 'unattended' ? unattendedPrecondition({ ...run.policy, mode: 'unattended' }) : null;
|
|
2986
|
+
if (blocked)
|
|
2987
|
+
return { ok: false, problem: RUN_ALL_REFUSED(blocked) };
|
|
2988
|
+
}
|
|
2720
2989
|
this.waiting.delete(approvalId);
|
|
2990
|
+
if (action === 'abort')
|
|
2991
|
+
this.stoppedByOperator.add(this.runKey(w.approval.sessionId));
|
|
2721
2992
|
if (action === 'run-all')
|
|
2722
2993
|
this.setRunMode(this.runKey(w.approval.sessionId), 'unattended');
|
|
2723
2994
|
const decision = action === 'run' || action === 'run-all'
|
|
@@ -2728,6 +2999,21 @@ let OperatorService = class OperatorService {
|
|
|
2728
2999
|
w.resolve(decision);
|
|
2729
3000
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2730
3001
|
message: `step ${w.approval.stepId}: ${action}`, data: { approvalId, action } });
|
|
3002
|
+
/*
|
|
3003
|
+
* "Stop" on the card that asks for the model to be chosen by hand (2026-11-18): the run stops, as the chat's own Stop
|
|
3004
|
+
* stops it — nothing failed, the operator stopped. Only the card was answered before: the work then ended "failed"
|
|
3005
|
+
* with two chats or Kerrigan, with no Continue, and a single chat was said as a start that did not happen. On the card
|
|
3006
|
+
* of a model the bot could not choose, a failure it is, and is said with what the page offers.
|
|
3007
|
+
*/
|
|
3008
|
+
if (w.approval.model?.manual && action === 'abort')
|
|
3009
|
+
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
3010
|
+
/*
|
|
3011
|
+
* "Stop the task" or "Abort task" on a card of a conversation inside another's run — the worker of two chats, a chat
|
|
3012
|
+
* Kerrigan directs (bug hunt 2026-11-18): it ended only that conversation's task, and the lead, or Kerrigan, was told
|
|
3013
|
+
* it stopped and went on. The operator stopped the work: the run stops, as the chat's Stop stops it.
|
|
3014
|
+
*/
|
|
3015
|
+
else if (action === 'abort' && this.runKey(w.approval.sessionId) !== w.approval.sessionId)
|
|
3016
|
+
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
2731
3017
|
return { ok: true };
|
|
2732
3018
|
}
|
|
2733
3019
|
/**
|
|
@@ -2902,7 +3188,7 @@ let OperatorService = class OperatorService {
|
|
|
2902
3188
|
'use-current-branch': `Use the current branch instead of ${g.baseBranch ?? 'the base branch'}`,
|
|
2903
3189
|
'allow-snapshot': 'Take uncommitted changes as a starting snapshot',
|
|
2904
3190
|
};
|
|
2905
|
-
note('snapshot-approval-required', `${g.repoDir}: nothing runs until
|
|
3191
|
+
note('snapshot-approval-required', `${g.repoDir}: nothing runs until what is not committed there is dealt with. Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.`, { repoDir: g.repoDir, actions: fixes }, ids, 'warn');
|
|
2906
3192
|
}
|
|
2907
3193
|
}
|
|
2908
3194
|
const open = groups.filter((g) => !g.ready);
|
|
@@ -2927,7 +3213,7 @@ let OperatorService = class OperatorService {
|
|
|
2927
3213
|
? [
|
|
2928
3214
|
'Version control is not ready for this run, so nothing was opened or sent. ' +
|
|
2929
3215
|
open.map((g) => `${g.repoDir}: ${g.problem ?? 'it needs your approval'}`).join(' ') +
|
|
2930
|
-
'
|
|
3216
|
+
' Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.',
|
|
2931
3217
|
]
|
|
2932
3218
|
: []),
|
|
2933
3219
|
...(contradictions.length > 0 ? [`${open.length > 0 ? '' : 'Nothing was opened or sent. '}${contradictions.join(' ')}`] : []),
|
|
@@ -3068,7 +3354,7 @@ let OperatorService = class OperatorService {
|
|
|
3068
3354
|
return null;
|
|
3069
3355
|
// The panel is named only where it has a fix to offer: for a chain waiting on its predecessor the remedy is that one's Continue (live run 2026-10-04).
|
|
3070
3356
|
const panel = group.actions.some((a) => a.available && a.id !== 'review-inputs');
|
|
3071
|
-
return `Version control is not ready for "${session.name}", so it did not start and its tasks stay queued: ${group.problem ?? 'it needs your approval'}${panel ? '
|
|
3357
|
+
return `Version control is not ready for "${session.name}", so it did not start and its tasks stay queued: ${group.problem ?? 'it needs your approval'}${panel ? ' Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.' : ''}`;
|
|
3072
3358
|
}
|
|
3073
3359
|
/** Recorded in the run's log just before the browser is opened for it: see `runPreflight`. */
|
|
3074
3360
|
async browserRequested(runId, sessionIds) {
|
|
@@ -3206,6 +3492,17 @@ let OperatorService = class OperatorService {
|
|
|
3206
3492
|
throw new Error(`Two projects are named "${o.name}". Names are how the folders are told apart, so each needs its own.`);
|
|
3207
3493
|
seen.add(key);
|
|
3208
3494
|
}
|
|
3495
|
+
/*
|
|
3496
|
+
* A project that may be changed inside one for reference only (bug hunt 2026-11-18): every change made in it would
|
|
3497
|
+
* be put back after each step, so no task there could finish. Refused, with what to do.
|
|
3498
|
+
*/
|
|
3499
|
+
const all = [{ name: name || rootDir, rootDir, readOnly }, ...others].filter((p) => p.rootDir);
|
|
3500
|
+
for (const w of all.filter((p) => !p.readOnly)) {
|
|
3501
|
+
const r = all.find((p) => p.readOnly && p !== w && folderInside(w.rootDir, p.rootDir));
|
|
3502
|
+
if (r) {
|
|
3503
|
+
throw new Error(`${w.name} (${w.rootDir}) is inside ${r.name} (${r.rootDir}), which is for reference only: every change made in it would be put back after each step. Untick "for reference only" on ${r.name}, or list for reference only the folders of it beside ${w.name}.`);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3209
3506
|
// What the removed Desktop copies left in the stored project is dropped with the next save.
|
|
3210
3507
|
const { mirror: _m, desktop: _d, mirrorToDesktop: _t, ...rest } = current;
|
|
3211
3508
|
return { ...raw, project: { ...rest, rootDir, name, level2, readOnly, others } };
|
|
@@ -3397,9 +3694,6 @@ let OperatorService = class OperatorService {
|
|
|
3397
3694
|
chatUrl: cfg.copilot.url,
|
|
3398
3695
|
channel: cfg.copilot.channel,
|
|
3399
3696
|
headless: cfg.copilot.headless,
|
|
3400
|
-
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
3401
|
-
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
3402
|
-
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
3403
3697
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
3404
3698
|
// The rows' locator reads the names (Settings' own, 2026-10-24).
|
|
3405
3699
|
...pickerOptions(cfg),
|
|
@@ -3459,9 +3753,6 @@ let OperatorService = class OperatorService {
|
|
|
3459
3753
|
chatUrl: cfg.copilot.url,
|
|
3460
3754
|
channel: cfg.copilot.channel,
|
|
3461
3755
|
headless: cfg.copilot.headless,
|
|
3462
|
-
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
3463
|
-
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
3464
|
-
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
3465
3756
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
3466
3757
|
...pickerOptions(cfg),
|
|
3467
3758
|
onEvent: (event, detail) => {
|
|
@@ -3473,11 +3764,8 @@ let OperatorService = class OperatorService {
|
|
|
3473
3764
|
await transport.open();
|
|
3474
3765
|
let results;
|
|
3475
3766
|
try {
|
|
3476
|
-
// A step of the operator's own that is not there
|
|
3477
|
-
await transport.ensureSignedIn(
|
|
3478
|
-
if (!(e instanceof LocatorMissing) || !isStepKey(e.key))
|
|
3479
|
-
throw e;
|
|
3480
|
-
});
|
|
3767
|
+
// A step of the operator's own that is not there does not stop a check, which only reads: each is looked for below.
|
|
3768
|
+
await transport.ensureSignedIn(undefined, { stepsLookOnly: true });
|
|
3481
3769
|
results = await transport.checkLocators();
|
|
3482
3770
|
}
|
|
3483
3771
|
catch (e) {
|