copilot-operator 0.1.94 → 0.1.97
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/src/api/apiLock.js +82 -0
- package/dist/src/api/main.js +5 -0
- package/dist/src/api/operator.controller.js +23 -5
- package/dist/src/api/operator.service.js +518 -83
- package/dist/src/api/server.js +10 -0
- package/dist/src/config/exportHome.js +1 -1
- package/dist/src/config/live.js +12 -12
- package/dist/src/config/schema.js +13 -0
- package/dist/src/exec/policy.js +9 -18
- package/dist/src/orchestrator/kerriganRunner.js +11 -4
- 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 +75 -16
- package/dist/src/plan/kerrigan.js +4 -4
- package/dist/src/plan/systemGuide.js +36 -36
- package/dist/src/queue/queue.js +19 -0
- package/dist/src/queue/queueBranch.js +34 -9
- package/dist/src/session/locatorFailures.js +10 -11
- package/dist/src/session/model.js +4 -0
- package/dist/src/session/store.js +56 -0
- package/dist/src/session/workspace.js +3 -2
- package/dist/src/transport/copilotTransport.js +83 -68
- package/dist/src/transport/keptWindow.js +17 -14
- package/dist/src/vcs/newBranch.js +28 -0
- package/dist/src/vcs/operatorGit.js +9 -10
- package/dist/src/vcs/referenceGuard.js +16 -2
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-c0eee3ec374816d1.js +1 -0
- package/dist/web/_next/static/chunks/1077.4da389906036b1bb.js +1 -0
- package/dist/web/_next/static/chunks/1548.4aa3e42afe4542ab.js +1 -0
- package/dist/web/_next/static/chunks/2163.4c6ce20cf967756c.js +1 -0
- package/dist/web/_next/static/chunks/714.ffb1325246519f64.js +1 -0
- package/dist/web/_next/static/chunks/7220.f483b83c11525063.js +1 -0
- package/dist/web/_next/static/chunks/7921-946e538fe3f9630f.js +1 -0
- package/dist/web/_next/static/chunks/8124-967df691ec1bfeeb.js +1 -0
- package/dist/web/_next/static/chunks/8584.3301b056c97be517.js +1 -0
- package/dist/web/_next/static/chunks/9067.03cdfb01ebf6a35d.js +1 -0
- package/dist/web/_next/static/chunks/9747.fe06238bc42bd23d.js +1 -0
- package/dist/web/_next/static/chunks/app/{layout-1b7d13f7b2efd008.js → layout-7943a4391ad2f88f.js} +1 -1
- package/dist/web/_next/static/chunks/app/page-6ec948e0cf4b24f0.js +1 -0
- 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-91b2de9c3da6f8b9.js → webpack-710628d673fa4afb.js} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +7 -7
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +8 -8
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +8 -8
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +8 -8
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +8 -8
- package/package.json +1 -1
- package/dist/web/_next/static/chunks/1024-dee283a1ddf295bf.js +0 -1
- package/dist/web/_next/static/chunks/1077.b7df9cb8ca810075.js +0 -1
- package/dist/web/_next/static/chunks/1548.417c17b63c371f00.js +0 -1
- package/dist/web/_next/static/chunks/2163.469367b8fbcc862d.js +0 -1
- package/dist/web/_next/static/chunks/714.72112704f3cb8127.js +0 -1
- package/dist/web/_next/static/chunks/7220.8bd897c7ddfee701.js +0 -1
- package/dist/web/_next/static/chunks/7921-25d1755799107ea7.js +0 -1
- package/dist/web/_next/static/chunks/8124-1dba8babfcfbc6e2.js +0 -1
- package/dist/web/_next/static/chunks/8584.f87df7324303ab75.js +0 -1
- package/dist/web/_next/static/chunks/9067.67a7c7cf3b019b5c.js +0 -1
- package/dist/web/_next/static/chunks/9747.a87dbd4acd45e39d.js +0 -1
- package/dist/web/_next/static/chunks/app/page-7eae1e8848525e1d.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/{UNygvDtRnBVZrGJt53IE4 → D3ew46wEw5JXPsTVwZwFC}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{UNygvDtRnBVZrGJt53IE4 → D3ew46wEw5JXPsTVwZwFC}/_ssgManifest.js +0 -0
|
@@ -22,15 +22,14 @@ import { chatbotFile } from '../session/chatbotFile.js';
|
|
|
22
22
|
import { CHAT_LOCATOR_KEYS, locatorPrompt, resolveChatLocators } from '../transport/locators.js';
|
|
23
23
|
import { LocatorMissing } from '../transport/copilotTransport.js';
|
|
24
24
|
import { isStepKey, stepKey, stepPrompt } from '../transport/chatSteps.js';
|
|
25
|
-
import {
|
|
26
|
-
import { join, resolve } from 'node:path';
|
|
25
|
+
import { basename, join, resolve } from 'node:path';
|
|
27
26
|
import { chosenHome, defaultHome, installLayout } from '../config/layout.js';
|
|
28
27
|
import { chooseHome, homeRefusal, movedFrom } from '../config/home.js';
|
|
29
|
-
import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, writeFileAtomically } from '../session/store.js';
|
|
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';
|
|
28
|
+
import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, readStoreJson, StoreFileUnusable, writeFileAtomically } from '../session/store.js';
|
|
29
|
+
import { checkItems, emptyQueue, holdsChat, itemTitle, mergeItems, nextStep, parkAfterMs, parkedAnswerFrom, skippedBecause, statusOfTask, waitsByHand, MAX_PARK_AFTER_SEC, PARKED_WORDS } from '../queue/queue.js';
|
|
30
|
+
import { branchStart, madeFromRemote, makeQueueBranch, refreshQueueBranch } from '../queue/queueBranch.js';
|
|
32
31
|
import { EventBus } from '../session/events.js';
|
|
33
|
-
import { isContinuable, MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
32
|
+
import { isContinuable, parkedOver, MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
34
33
|
import { handoffOutcomeOf, handoffResultMessage } from '../orchestrator/handoff.js';
|
|
35
34
|
import { runSession, queuedToRun, failedWhileOpening, pickerOptions } from '../orchestrator/taskRunner.js';
|
|
36
35
|
import { Hold, WaitsFor } from '../orchestrator/hold.js';
|
|
@@ -73,6 +72,25 @@ function sameFolder(a, b) {
|
|
|
73
72
|
const norm = (p) => p.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
|
|
74
73
|
return a.trim() !== '' && norm(a) === norm(b);
|
|
75
74
|
}
|
|
75
|
+
/** Why a queue's task waits to carry on, in its own chat, at the queue's next run (2026-11-18). */
|
|
76
|
+
const CARRIES_ON_AFTER = (what) => `${what}; it carries on from where it stopped, in its own chat, when the queue is run again`;
|
|
77
|
+
/** A card answered after it went: by Kerrigan, another tab, or its work having ended (2026-11-18). */
|
|
78
|
+
export const CARD_GONE = 'That card is not waiting any more: it was answered, or its work ended.';
|
|
79
|
+
/** "Run this and the rest" where the run may not go on unasked: said, and the card kept (2026-11-18). */
|
|
80
|
+
/** How long a task of the queue waits for a sign-in Copilot asks for: as long as it takes, a week (2026-11-19). */
|
|
81
|
+
export const QUEUE_SIGN_IN_WAIT_SEC = 7 * 24 * 3600;
|
|
82
|
+
/** Said when "Sign in to Copilot" is pressed while a run's own window waits for the sign-in (2026-11-19). */
|
|
83
|
+
export const SIGN_IN_IN_THE_RUNS_WINDOW = 'The Copilot window the work opened is waiting for you to sign in: sign in there — it may be behind this one — and the work goes on by itself.';
|
|
84
|
+
/** Said when a set-aside task's card is pressed after the queue let go of it (2026-11-19). */
|
|
85
|
+
export const PARKED_RELEASED = 'Its card is closed now: "Continue" under its message carries it on in its own chat.';
|
|
86
|
+
/** Said when "Continue" is pressed on a message answered on its card in the queue (2026-11-19). */
|
|
87
|
+
export const PARKED_ANSWERED = "This message was answered on its card, and the queue carries it on with that answer: at the queue's next turn, or when the queue is run.";
|
|
88
|
+
export const RUN_ALL_REFUSED = (why) => `"Run this and the rest" cannot be given here — ${why} Nothing was run: "Run" runs this step.`;
|
|
89
|
+
/** Whether a folder is another, or inside it: Windows paths, as `sameFolder` reads them. */
|
|
90
|
+
function folderInside(inner, outer) {
|
|
91
|
+
const norm = (p) => p.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
|
|
92
|
+
return inner.trim() !== '' && outer.trim() !== '' && (norm(inner) === norm(outer) || norm(inner).startsWith(`${norm(outer)}\\`));
|
|
93
|
+
}
|
|
76
94
|
import { saveWorkspaceFile, workspaceFile, workspaceFiles, workspaceInfo, workspaceRaw } from '../session/workspace.js';
|
|
77
95
|
import { searchWorkspace } from '../session/workspaceSearch.js';
|
|
78
96
|
import { restoreCheckpoint } from '../session/checkpoint.js';
|
|
@@ -83,7 +101,7 @@ import { makeAuthorizer } from '../exec/authorizer.js';
|
|
|
83
101
|
import { pickFolder } from './folderPicker.js';
|
|
84
102
|
import { findEdgeUsingProfile, profileHolder } from '../transport/profileLock.js';
|
|
85
103
|
import { assessIsolation, readIsolationSignals } from '../exec/isolation.js';
|
|
86
|
-
import { unattendedPrecondition } from '../exec/policy.js';
|
|
104
|
+
import { unattendedBlock, unattendedPrecondition } from '../exec/policy.js';
|
|
87
105
|
import { createTransport } from '../transport/chatTransport.js';
|
|
88
106
|
import { composeHandoff } from '../session/handoff.js';
|
|
89
107
|
import { appendRunLog, appendSessionLog, readRunLog } from '../session/runLog.js';
|
|
@@ -98,10 +116,11 @@ import { sessionRoots } from '../exec/confinement.js';
|
|
|
98
116
|
import { dirtyPolicy } from '../vcs/snapshot.js';
|
|
99
117
|
import { runVcsPreflight } from '../vcs/runPreflight.js';
|
|
100
118
|
import { inputSettings, normalisePatterns } from '../vcs/inputs.js';
|
|
101
|
-
import { createNewBranch, planNewBranch, setAsideUncommitted } from '../vcs/newBranch.js';
|
|
119
|
+
import { createNewBranch, planNewBranch, putBackAside, setAsideUncommitted } from '../vcs/newBranch.js';
|
|
102
120
|
import { commitAsOperator, identityOf, pushAsOperator, setIdentity, stageFiles, TrustedHooks } from '../vcs/operatorGit.js';
|
|
103
121
|
import { askpassProgram, closePasswordWindows } from '../vcs/remoteAuth.js';
|
|
104
122
|
import { planApprovedMessage, planReviseMessage } from '../orchestrator/planMode.js';
|
|
123
|
+
import { leadPlanApproved, leadPlanRevise } from '../orchestrator/leadRunner.js';
|
|
105
124
|
import { coveredByArtifacts } from '../vcs/artifacts.js';
|
|
106
125
|
import { botVersion } from '../config/version.js';
|
|
107
126
|
import { exportEntries, exportFileName as homeExportName, exportSizes } from '../config/exportHome.js';
|
|
@@ -220,8 +239,25 @@ let OperatorService = class OperatorService {
|
|
|
220
239
|
* operator in another window): a worker's subtask is not the message.
|
|
221
240
|
*/
|
|
222
241
|
lastOutcome = null;
|
|
242
|
+
/**
|
|
243
|
+
* The runs the operator stopped: their Stop, "Stop the queue", Stop or "Abort task" on a card (bug hunt 2026-11-18).
|
|
244
|
+
* Only such a stop is theirs and says nothing at the end ("Done" is not shown); a window closed past the times it is
|
|
245
|
+
* opened again, a conversation lost, the program closed, are said.
|
|
246
|
+
*/
|
|
247
|
+
stoppedByOperator = new Set();
|
|
248
|
+
/**
|
|
249
|
+
* Whether a conversation's latest message ended by the operator's own Stop, by its session: read by the queue, which
|
|
250
|
+
* only that stops (2026-11-19: a conversation lost, which ends a message stopped so that "Continue" is offered,
|
|
251
|
+
* stopped the whole queue left running).
|
|
252
|
+
*/
|
|
253
|
+
endedByOperator = new Map();
|
|
223
254
|
/** Where Git asks the operator for a password now, in its own window (2026-10-26): the step waits for it. */
|
|
224
255
|
passwordAsked = new Map();
|
|
256
|
+
/**
|
|
257
|
+
* Where the Copilot window of a run waits for the operator to sign in (2026-11-19): said on the tab and in the chat,
|
|
258
|
+
* and "Sign in to Copilot" points to that window rather than refusing because of it.
|
|
259
|
+
*/
|
|
260
|
+
signInAsked = new Map();
|
|
225
261
|
followsActing = this.bus.subscribe('*', (e) => {
|
|
226
262
|
if (e.type === 'acting' && e.data)
|
|
227
263
|
this.acting.set(e.sessionId, e.data);
|
|
@@ -231,9 +267,13 @@ let OperatorService = class OperatorService {
|
|
|
231
267
|
else if (e.type === 'browser:sign-in-required' || e.type === 'browser:verification-required') {
|
|
232
268
|
// The Copilot window waits for the operator to sign in, or to show a person is there: not counted (2026-10-29).
|
|
233
269
|
this.holdOf(e.sessionId)?.waitFor(`${e.type}:${e.sessionId}`);
|
|
270
|
+
if (e.type === 'browser:sign-in-required')
|
|
271
|
+
this.signInAsked.set(e.sessionId, e.at);
|
|
234
272
|
}
|
|
235
273
|
else if (e.type === 'browser:signed-in' || e.type === 'browser:verification-cleared') {
|
|
236
274
|
this.holdOf(e.sessionId)?.waited(`${e.type === 'browser:signed-in' ? 'browser:sign-in-required' : 'browser:verification-required'}:${e.sessionId}`);
|
|
275
|
+
if (e.type === 'browser:signed-in')
|
|
276
|
+
this.signInAsked.delete(e.sessionId);
|
|
237
277
|
}
|
|
238
278
|
else if (e.type === 'password-window') {
|
|
239
279
|
const open = e.data?.open === true;
|
|
@@ -257,11 +297,15 @@ let OperatorService = class OperatorService {
|
|
|
257
297
|
else if (e.type === 'task-finished') {
|
|
258
298
|
this.acting.delete(e.sessionId);
|
|
259
299
|
this.passwordAsked.delete(e.sessionId);
|
|
300
|
+
this.signInAsked.delete(e.sessionId);
|
|
260
301
|
for (const key of [`pw:${e.sessionId}`, `browser:sign-in-required:${e.sessionId}`, `browser:verification-required:${e.sessionId}`])
|
|
261
302
|
this.holdOf(e.sessionId)?.waited(key);
|
|
262
303
|
const status = e.data?.status;
|
|
263
|
-
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId))
|
|
264
|
-
|
|
304
|
+
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId)) {
|
|
305
|
+
const byOperator = status === 'aborted' && this.stoppedByOperator.has(this.runKey(e.sessionId));
|
|
306
|
+
this.lastOutcome = { status, at: e.at, sessionId: e.sessionId, ...(byOperator ? { byOperator: true } : {}) };
|
|
307
|
+
this.endedByOperator.set(e.sessionId, byOperator);
|
|
308
|
+
}
|
|
265
309
|
}
|
|
266
310
|
});
|
|
267
311
|
/**
|
|
@@ -401,8 +445,10 @@ let OperatorService = class OperatorService {
|
|
|
401
445
|
await writeAttemptRecord(settled, ended, cfg.resolved.runsDir, exportMachine(cfg));
|
|
402
446
|
}
|
|
403
447
|
/** Runs the startup work now, so it does not wait for the first request. */
|
|
404
|
-
bootstrap() {
|
|
405
|
-
|
|
448
|
+
async bootstrap() {
|
|
449
|
+
await this.init();
|
|
450
|
+
// At once, not at the queue's first use (2026-11-19): a chat shows a set-aside task's card before the queue is read.
|
|
451
|
+
await this.recoverQueue().catch((e) => console.error('[queue] could not be recovered at the start:', e.message));
|
|
406
452
|
}
|
|
407
453
|
// --- level 1 --------------------------------------------------------------------------
|
|
408
454
|
async getLevel1() {
|
|
@@ -414,7 +460,7 @@ let OperatorService = class OperatorService {
|
|
|
414
460
|
await this.init();
|
|
415
461
|
const all = await this.store.listSessions();
|
|
416
462
|
// 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) }));
|
|
463
|
+
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
464
|
}
|
|
419
465
|
async getSession(id) {
|
|
420
466
|
await this.init();
|
|
@@ -422,11 +468,15 @@ let OperatorService = class OperatorService {
|
|
|
422
468
|
if (!s)
|
|
423
469
|
return null;
|
|
424
470
|
const pending = [...this.waiting.values()].filter((w) => w.approval.sessionId === id).map((w) => w.approval);
|
|
425
|
-
|
|
471
|
+
/*
|
|
472
|
+
* Held or not, as its run is: a chat Kerrigan directs is held with hers (bug hunt 2026-11-18: "Pause" there held her
|
|
473
|
+
* run, `pause` goes up the chain, but the chat read its own id, so the button never said "Continue").
|
|
474
|
+
*/
|
|
475
|
+
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
476
|
}
|
|
427
477
|
/** The pauses of the run going on in a session, from "Pause" to "Continue"; none when nothing runs or it was never paused. */
|
|
428
478
|
pausesOf(id) {
|
|
429
|
-
const pauses = this.running.get(id)?.hold.pauses ?? [];
|
|
479
|
+
const pauses = this.running.get(this.runKey(id))?.hold.pauses ?? [];
|
|
430
480
|
return pauses.length > 0 ? { pauses } : {};
|
|
431
481
|
}
|
|
432
482
|
async updateSession(id, patch) {
|
|
@@ -1061,6 +1111,21 @@ let OperatorService = class OperatorService {
|
|
|
1061
1111
|
const cfg = session.kind === 'chat' ? { ...loaded, execution: { ...loaded.execution, denyPatterns: chatDenyPatterns(loaded.execution.denyPatterns) } } : loaded;
|
|
1062
1112
|
// The run's own settings; a save while it goes on changes them in place (`saveSettings`), and these rules with them.
|
|
1063
1113
|
const runCfg = { ...cfg, execution: { ...cfg.execution, mode } };
|
|
1114
|
+
/*
|
|
1115
|
+
* 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
|
|
1116
|
+
* Settings name, is chosen by the bot, whatever Settings say — "by hand" is on by default, and every task of the
|
|
1117
|
+
* queue waited on its model's card and was set aside. One with no model named is refused at "Run the queue"
|
|
1118
|
+
* (`queueWithoutModel`). The models are taken when a message starts, so a save under the run does not undo it.
|
|
1119
|
+
*/
|
|
1120
|
+
if (session.queueItem)
|
|
1121
|
+
runCfg.copilot = { ...runCfg.copilot, manualModel: false, leadManualModel: false, reviewManualModel: false, kerriganManualModel: false };
|
|
1122
|
+
/*
|
|
1123
|
+
* And a sign-in Copilot asks for is waited for as long as it takes (second bug hunt, 2026-11-19): a queue left
|
|
1124
|
+
* overnight whose account was signed out failed each task after fifteen minutes, skipping what depended on it, where
|
|
1125
|
+
* signed in in the morning it carries on by itself. The wait is not counted, and the run's Stop ends it.
|
|
1126
|
+
*/
|
|
1127
|
+
if (session.queueItem)
|
|
1128
|
+
runCfg.copilot = { ...runCfg.copilot, signInTimeoutSec: Math.max(runCfg.copilot.signInTimeoutSec, QUEUE_SIGN_IN_WAIT_SEC) };
|
|
1064
1129
|
const live = new LiveSettings(runCfg, session.kind === 'chat', loaded);
|
|
1065
1130
|
const policy = { mode, ...stepRules(runCfg) };
|
|
1066
1131
|
/*
|
|
@@ -1090,6 +1155,7 @@ let OperatorService = class OperatorService {
|
|
|
1090
1155
|
const startedAt = new Date().toISOString();
|
|
1091
1156
|
const hold = new Hold();
|
|
1092
1157
|
this.running.set(sessionId, { controller, startedAt, mode, policy, hold, live });
|
|
1158
|
+
this.stoppedByOperator.delete(sessionId);
|
|
1093
1159
|
// Who was at work in a run of it that ended without saying so is not who is at work in this one.
|
|
1094
1160
|
this.acting.delete(sessionId);
|
|
1095
1161
|
{
|
|
@@ -1214,14 +1280,25 @@ let OperatorService = class OperatorService {
|
|
|
1214
1280
|
}
|
|
1215
1281
|
return tally;
|
|
1216
1282
|
})
|
|
1217
|
-
.finally(() => {
|
|
1283
|
+
.finally(async () => {
|
|
1218
1284
|
for (const [id, w] of this.waiting) {
|
|
1219
1285
|
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
1220
1286
|
w.resolve({ action: 'abort', reason: 'the run ended' });
|
|
1221
1287
|
this.waiting.delete(id);
|
|
1222
1288
|
}
|
|
1223
1289
|
}
|
|
1290
|
+
/*
|
|
1291
|
+
* A Stop that landed as the run ended (bug hunt 2026-11-18): the run had written "idle", and was only adding up
|
|
1292
|
+
* how it went, when `stop` wrote "stopping" over it, which nothing undid: the conversation read as working for
|
|
1293
|
+
* good — "Stopping…", Go back refused, New chat off — until the next message. Before the run is let go of, so no
|
|
1294
|
+
* other run of the session can have begun.
|
|
1295
|
+
*/
|
|
1296
|
+
await this.store.updateSession(sessionId, (s) => {
|
|
1297
|
+
if (s.status === 'stopping')
|
|
1298
|
+
s.status = 'idle';
|
|
1299
|
+
}).catch(() => undefined);
|
|
1224
1300
|
this.running.delete(sessionId);
|
|
1301
|
+
this.stoppedByOperator.delete(sessionId);
|
|
1225
1302
|
});
|
|
1226
1303
|
return { started: true, done };
|
|
1227
1304
|
}
|
|
@@ -1279,12 +1356,14 @@ let OperatorService = class OperatorService {
|
|
|
1279
1356
|
this.bus.publish({ sessionId, type: 'resume-asked', level: 'info', message: 'continued by the operator' });
|
|
1280
1357
|
return { paused: false };
|
|
1281
1358
|
}
|
|
1282
|
-
async stop(asked) {
|
|
1359
|
+
async stop(asked, by = 'operator') {
|
|
1283
1360
|
// A chat Kerrigan directs is stopped with her run (2026-11-12): it is one run.
|
|
1284
1361
|
const sessionId = this.runKey(asked);
|
|
1285
1362
|
const r = this.running.get(sessionId);
|
|
1286
1363
|
if (!r)
|
|
1287
1364
|
return { stopping: false };
|
|
1365
|
+
if (by === 'operator')
|
|
1366
|
+
this.stoppedByOperator.add(sessionId);
|
|
1288
1367
|
r.controller.abort();
|
|
1289
1368
|
for (const [id, w] of this.waiting) {
|
|
1290
1369
|
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
@@ -1326,10 +1405,14 @@ let OperatorService = class OperatorService {
|
|
|
1326
1405
|
...(run?.hold?.held ? { paused: true } : {}),
|
|
1327
1406
|
// Git asks for a password in its own window, and the work waits for it (2026-10-26).
|
|
1328
1407
|
...(this.passwordAsked.size > 0 ? { password: true } : {}),
|
|
1408
|
+
// Copilot's window waits for the operator to sign in (2026-11-19): the work goes on by itself once signed in.
|
|
1409
|
+
...(this.signInAsked.size > 0 && this.running.size > 0 ? { signIn: true } : {}),
|
|
1329
1410
|
// The queue still has its turn going, between one of its tasks and the next (2026-11-03): the work is not over.
|
|
1330
1411
|
...(this.queueLoop ? { queue: true } : {}),
|
|
1412
|
+
// Tasks of the queue set aside, waiting for the operator's answer on their cards (2026-11-19): the work is not over.
|
|
1413
|
+
...(this.queueParked > 0 ? { parked: this.queueParked } : {}),
|
|
1331
1414
|
// How the last message ended, while nothing runs: what the tab says until the operator has looked.
|
|
1332
|
-
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at } } : {}),
|
|
1415
|
+
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at, ...(this.lastOutcome.byOperator ? { byOperator: true } : {}) } } : {}),
|
|
1333
1416
|
};
|
|
1334
1417
|
}
|
|
1335
1418
|
/**
|
|
@@ -1477,14 +1560,28 @@ let OperatorService = class OperatorService {
|
|
|
1477
1560
|
const busy = this.branchBusy();
|
|
1478
1561
|
if (busy)
|
|
1479
1562
|
throw new Error(busy);
|
|
1480
|
-
|
|
1563
|
+
const carry = input.carry === 'aside' || input.carry === 'commit' ? input.carry : 'take';
|
|
1564
|
+
/*
|
|
1565
|
+
* The work of a queue's task set aside on "the folder as it is" (2026-11-19): taken to the new branch, it carried on
|
|
1566
|
+
* without it, Copilot not told; put aside, nobody knew whose it was. Put aside, it is kept for that task and put back
|
|
1567
|
+
* when it carries on; taken along, refused, saying so; committed, it stays on the task's branch.
|
|
1568
|
+
*/
|
|
1569
|
+
const onNow = ws.isRepo ? (await git(ws.dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']).catch(() => null))?.stdout || null : null;
|
|
1570
|
+
const owners = await this.folderOwners(onNow);
|
|
1571
|
+
if (owners.length > 0 && carry === 'take' && (await git(ws.dir, ['status', '--porcelain']).catch(() => null))?.stdout.trim()) {
|
|
1572
|
+
throw new Error(`What is not committed here is the work of the queue's task "${itemTitle(owners[0].item)}", set aside while it waits for you: taken to the new branch, it would carry on without it. Put it aside instead — it is put back when that task carries on — or commit it, or answer the task's card first.`);
|
|
1573
|
+
}
|
|
1574
|
+
const made = await createNewBranch(ws.dir, {
|
|
1481
1575
|
name: typeof input.name === 'string' ? input.name : '',
|
|
1482
|
-
carry
|
|
1576
|
+
carry,
|
|
1483
1577
|
fingerprint: typeof input.fingerprint === 'string' ? input.fingerprint : '',
|
|
1484
1578
|
...(typeof input.message === 'string' && input.message.trim() ? { message: input.message.trim().slice(0, 2000) } : {}),
|
|
1485
1579
|
// The saved branch under the bot's own prefix, as its other branches are.
|
|
1486
1580
|
prefix: DEFAULT_VCS.branchPrefix,
|
|
1487
1581
|
});
|
|
1582
|
+
if (made.ok && made.saved && owners.length > 0)
|
|
1583
|
+
await this.leftoversOf(onNow, '', made.saved.branch);
|
|
1584
|
+
return made;
|
|
1488
1585
|
}
|
|
1489
1586
|
/** The open folder's code, searched as VS Code's Search view does (2026-10-21, see `workspaceSearch.ts`). */
|
|
1490
1587
|
async workspaceSearch(query, opts) {
|
|
@@ -1506,17 +1603,27 @@ let OperatorService = class OperatorService {
|
|
|
1506
1603
|
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
1507
1604
|
return { dir: ws.dir, ...(await workspaceFiles(ws.dir)) };
|
|
1508
1605
|
}
|
|
1509
|
-
async workspaceFile(path) {
|
|
1606
|
+
async workspaceFile(path, dir) {
|
|
1510
1607
|
const ws = await this.workspace();
|
|
1511
1608
|
if (!ws.ok)
|
|
1512
1609
|
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
1610
|
+
this.sameOpenFolder(ws.dir, dir);
|
|
1513
1611
|
return await workspaceFile(ws.dir, path);
|
|
1514
1612
|
}
|
|
1613
|
+
/**
|
|
1614
|
+
* A file opened in one folder, read or saved after another was opened (second bug hunt, 2026-11-19): its path was
|
|
1615
|
+
* taken in the folder open now, and Ctrl+S wrote one folder's edit into the other's file of the same name. Refused.
|
|
1616
|
+
*/
|
|
1617
|
+
sameOpenFolder(open, dir) {
|
|
1618
|
+
if (dir && !sameFolder(dir, open))
|
|
1619
|
+
throw new Error(`That file was opened in ${dir}, and the folder open now is ${open}: nothing was read or saved there. Open ${dir} again to save it.`);
|
|
1620
|
+
}
|
|
1515
1621
|
/** The editor's text saved over a file of the open folder, over the version it was made on (see `saveWorkspaceFile`). */
|
|
1516
|
-
async saveWorkspaceFile(path, text, base) {
|
|
1622
|
+
async saveWorkspaceFile(path, text, base, dir) {
|
|
1517
1623
|
const ws = await this.workspace();
|
|
1518
1624
|
if (!ws.ok)
|
|
1519
1625
|
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
1626
|
+
this.sameOpenFolder(ws.dir, dir);
|
|
1520
1627
|
const saved = await saveWorkspaceFile(ws.dir, path, text, base);
|
|
1521
1628
|
console.log(`[editor] saved ${saved.path} (${saved.size} bytes)`);
|
|
1522
1629
|
return saved;
|
|
@@ -1773,22 +1880,30 @@ let OperatorService = class OperatorService {
|
|
|
1773
1880
|
approvedAhead = new Map();
|
|
1774
1881
|
/** Branches made for tasks of the queue, one edit of the list at a time. */
|
|
1775
1882
|
branchTurn = Promise.resolve();
|
|
1776
|
-
/**
|
|
1883
|
+
/**
|
|
1884
|
+
* How many of the queue's tasks are set aside, waiting for the operator, as last read (2026-11-19): the work is not
|
|
1885
|
+
* over while one waits, and "Finished: aborted" — the queue's own stop to set it aside — was said instead.
|
|
1886
|
+
*/
|
|
1887
|
+
queueParked = 0;
|
|
1888
|
+
/**
|
|
1889
|
+
* The queue as it is on disk: empty when it was never written. One that is there but cannot be read is refused, never
|
|
1890
|
+
* read as empty (2026-11-19: the next change wrote the empty queue over it, every task and card kept in it lost).
|
|
1891
|
+
*/
|
|
1777
1892
|
async readQueue() {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
items: Array.isArray(q.items) ? q.items : [],
|
|
1782
|
-
running: q.running === true,
|
|
1783
|
-
updatedAt: q.updatedAt ?? '',
|
|
1784
|
-
...(typeof q.parkAfterSec === 'number' ? { parkAfterSec: q.parkAfterSec } : {}),
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1787
|
-
catch (e) {
|
|
1788
|
-
if (e.code !== 'ENOENT')
|
|
1789
|
-
console.error('[queue] data/queue.json could not be read:', e.message);
|
|
1893
|
+
const q = await readStoreJson(this.queueFile);
|
|
1894
|
+
if (q === undefined) {
|
|
1895
|
+
this.queueParked = 0;
|
|
1790
1896
|
return emptyQueue();
|
|
1791
1897
|
}
|
|
1898
|
+
if (!q || typeof q !== 'object' || Array.isArray(q))
|
|
1899
|
+
throw new StoreFileUnusable(this.queueFile, 'does not hold a queue');
|
|
1900
|
+
this.queueParked = Array.isArray(q.items) ? q.items.filter((x) => x?.status === 'parked').length : 0;
|
|
1901
|
+
return {
|
|
1902
|
+
items: Array.isArray(q.items) ? q.items : [],
|
|
1903
|
+
running: q.running === true,
|
|
1904
|
+
updatedAt: q.updatedAt ?? '',
|
|
1905
|
+
...(typeof q.parkAfterSec === 'number' ? { parkAfterSec: q.parkAfterSec } : {}),
|
|
1906
|
+
};
|
|
1792
1907
|
}
|
|
1793
1908
|
/** Changes the queue in a turn of its own, so two changes never write over each other. */
|
|
1794
1909
|
changeQueue(change) {
|
|
@@ -1798,12 +1913,53 @@ let OperatorService = class OperatorService {
|
|
|
1798
1913
|
q.updatedAt = new Date().toISOString();
|
|
1799
1914
|
delete q.busy;
|
|
1800
1915
|
await writeFileAtomically(this.queueFile, JSON.stringify(q, null, 2));
|
|
1916
|
+
this.queueParked = q.items.filter((x) => x.status === 'parked').length;
|
|
1801
1917
|
return q;
|
|
1802
1918
|
};
|
|
1803
1919
|
const done = this.queueTurn.then(run, run);
|
|
1804
1920
|
this.queueTurn = done.catch(() => undefined);
|
|
1805
1921
|
return done;
|
|
1806
1922
|
}
|
|
1923
|
+
/**
|
|
1924
|
+
* 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
|
|
1925
|
+
* to carry on — set aside at a card, stopped with the queue — on the branch they were left on, that task gets them back
|
|
1926
|
+
* when it carries on (`putBackAside`). Two such tasks there: whose is whose cannot be told, and they stay where they
|
|
1927
|
+
* were put, as said.
|
|
1928
|
+
*/
|
|
1929
|
+
async leftoversOf(onBranch, except, saved) {
|
|
1930
|
+
const owners = await this.folderOwners(onBranch, except);
|
|
1931
|
+
if (owners.length === 1) {
|
|
1932
|
+
const owner = owners[0].item.id;
|
|
1933
|
+
await this.changeQueue((x) => this.setQueueItem(x, owner, { setAside: [...(x.items.find((i) => i.id === owner)?.setAside ?? []), saved] }));
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
/*
|
|
1937
|
+
* Two or more such tasks (2026-11-19): whose each change is cannot be told, and nobody was told where the work went.
|
|
1938
|
+
* Each is told, in its chat, where it is kept; none has it put back, which would lay another's work on it.
|
|
1939
|
+
*/
|
|
1940
|
+
for (const o of owners) {
|
|
1941
|
+
await this.store.addTaskNote(o.sessionId, o.taskId, `What was not committed in the folder on ${onBranch} — yours, or another set-aside task's of the queue that works there too — was put aside on the branch ${saved} while you waited. It is not put back by itself, since it cannot be told whose each change is: take back what is yours from there (git restore --source ${saved} -- <path>).`).catch(() => undefined);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* The queue's tasks on "the folder as it is", set aside or carrying on at their next turn, whose work began on
|
|
1946
|
+
* `onBranch`: whose uncommitted changes the folder there holds.
|
|
1947
|
+
*/
|
|
1948
|
+
async folderOwners(onBranch, except = '') {
|
|
1949
|
+
if (!onBranch)
|
|
1950
|
+
return [];
|
|
1951
|
+
const q = await this.readQueue();
|
|
1952
|
+
const owners = [];
|
|
1953
|
+
for (const x of q.items) {
|
|
1954
|
+
if (x.id === except || x.branch !== 'folder' || !x.sessionId || !holdsChat(x))
|
|
1955
|
+
continue;
|
|
1956
|
+
const s = await this.store.getSession(x.sessionId);
|
|
1957
|
+
const t = s?.tasks.find((k) => k.parked && !k.parked.answer) ?? s?.tasks.at(-1);
|
|
1958
|
+
if (s && t && !s.vcs?.enabled && t.checkpoint?.branch === onBranch)
|
|
1959
|
+
owners.push({ item: x, sessionId: s.id, taskId: t.id });
|
|
1960
|
+
}
|
|
1961
|
+
return owners;
|
|
1962
|
+
}
|
|
1807
1963
|
setQueueItem(q, id, patch) {
|
|
1808
1964
|
const item = q.items.find((x) => x.id === id);
|
|
1809
1965
|
if (!item)
|
|
@@ -1822,16 +1978,59 @@ let OperatorService = class OperatorService {
|
|
|
1822
1978
|
return;
|
|
1823
1979
|
this.queueRecovered = true;
|
|
1824
1980
|
const q = await this.readQueue();
|
|
1981
|
+
/*
|
|
1982
|
+
* The cards of set-aside tasks the queue does not hold any more (2026-11-19) — taken out, run again, the queue's file
|
|
1983
|
+
* lost, before this was looked after — closed, so their messages are carried on in their chats.
|
|
1984
|
+
*/
|
|
1985
|
+
for (const s of await this.store.listSessions().catch(() => [])) {
|
|
1986
|
+
if (!s.queueItem || !s.tasks.some((t) => t.parked && !parkedOver(t.parked)))
|
|
1987
|
+
continue;
|
|
1988
|
+
const item = q.items.find((x) => x.id === s.queueItem);
|
|
1989
|
+
if (!item || item.sessionId !== s.id || !holdsChat(item))
|
|
1990
|
+
await this.releaseFromQueue(s.id, s.queueItem, undefined);
|
|
1991
|
+
}
|
|
1825
1992
|
if (!q.running && !q.items.some((x) => x.status === 'running'))
|
|
1826
1993
|
return;
|
|
1827
1994
|
await this.changeQueue((x) => {
|
|
1828
1995
|
x.running = false;
|
|
1829
1996
|
for (const item of x.items) {
|
|
1830
|
-
|
|
1831
|
-
|
|
1997
|
+
/*
|
|
1998
|
+
* It carries on, in its own chat, when the queue is run again (bug hunt 2026-11-18): marked stopped, every task
|
|
1999
|
+
* that depends on it was skipped at the next run, and only "Run again", which starts it over, was left.
|
|
2000
|
+
*/
|
|
2001
|
+
if (item.status === 'running') {
|
|
2002
|
+
Object.assign(item, item.sessionId
|
|
2003
|
+
? { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the bot was closed while it ran'), endedAt: new Date().toISOString() }
|
|
2004
|
+
: { status: 'waiting', why: undefined });
|
|
2005
|
+
}
|
|
1832
2006
|
}
|
|
1833
2007
|
});
|
|
1834
2008
|
}
|
|
2009
|
+
/**
|
|
2010
|
+
* A chat the queue lets go of (2026-11-19): its set-aside task's card closed — "Continue" carries the message on there —
|
|
2011
|
+
* and, when the task had work put aside by a task after it, where that work is said in the chat, since nothing will
|
|
2012
|
+
* put it back now.
|
|
2013
|
+
*/
|
|
2014
|
+
async releaseFromQueue(sessionId, itemId, setAside) {
|
|
2015
|
+
const s = await this.store.getSession(sessionId);
|
|
2016
|
+
if (!s || s.queueItem !== itemId)
|
|
2017
|
+
return;
|
|
2018
|
+
const open = s.tasks.find((t) => t.parked && !parkedOver(t.parked));
|
|
2019
|
+
if (open) {
|
|
2020
|
+
await this.store.updateSession(sessionId, (x) => {
|
|
2021
|
+
const t = x.tasks.find((y) => y.id === open.id);
|
|
2022
|
+
if (t?.parked && !parkedOver(t.parked))
|
|
2023
|
+
t.parked.answer = { kind: 'released', at: new Date().toISOString() };
|
|
2024
|
+
}).catch(() => undefined);
|
|
2025
|
+
this.bus.publish({ sessionId, taskId: open.id, type: 'queue-released', level: 'info', message: 'the queue does not hold this task any more: its card is closed, and "Continue" carries it on here' });
|
|
2026
|
+
}
|
|
2027
|
+
const last = open ?? s.tasks.at(-1);
|
|
2028
|
+
for (const saved of setAside ?? []) {
|
|
2029
|
+
if (last)
|
|
2030
|
+
await this.store.addTaskNote(sessionId, last.id, `What you had changed and not committed was put aside on the branch ${saved} while you waited, and the queue no longer puts it back. Take back what you need from there (git restore --source ${saved} -- <path>).`).catch(() => undefined);
|
|
2031
|
+
this.bus.publish({ sessionId, type: 'queue-put-back', level: 'warn', message: `what it had not committed is kept on ${saved}; the queue no longer puts it back`, data: { saved } });
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
1835
2034
|
async queue() {
|
|
1836
2035
|
await this.recoverQueue();
|
|
1837
2036
|
return await this.withBusy(await this.readQueue());
|
|
@@ -1861,21 +2060,37 @@ let OperatorService = class OperatorService {
|
|
|
1861
2060
|
throw new Error(checked.problem);
|
|
1862
2061
|
// A skill is one of Settings' (2026-10-25); whether it is for the folder is said when the task runs, in its chat.
|
|
1863
2062
|
const { skills } = await this.skills();
|
|
1864
|
-
|
|
2063
|
+
/*
|
|
2064
|
+
* Only a task that will run with it (bug hunt 2026-11-18): one done, failed or skipped with a skill taken out of
|
|
2065
|
+
* Settings since blocked every edit of the queue, and cannot itself be edited. A new one, one whose skill changes,
|
|
2066
|
+
* and one that waits or is put back to wait are held to Settings' skills.
|
|
2067
|
+
*/
|
|
2068
|
+
const before = new Map((await this.readQueue()).items.map((x) => [x.id, x]));
|
|
2069
|
+
const runs = (x) => {
|
|
2070
|
+
const was = before.get(x.id);
|
|
2071
|
+
return !was || was.skill !== x.skill || (x.status ?? was.status) === 'waiting';
|
|
2072
|
+
};
|
|
2073
|
+
const unknown = checked.items.findIndex((x) => x.skill && runs(x) && !skills.some((k) => k.name === x.skill));
|
|
1865
2074
|
if (unknown >= 0) {
|
|
1866
2075
|
const name = checked.items[unknown].skill;
|
|
1867
2076
|
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(', ')}` : ''}.`);
|
|
1868
2077
|
}
|
|
1869
2078
|
let problem;
|
|
2079
|
+
let letGo = [];
|
|
1870
2080
|
const q = await this.changeQueue((x) => {
|
|
1871
2081
|
const merged = mergeItems(x.items, checked.items);
|
|
1872
2082
|
if ('problem' in merged)
|
|
1873
2083
|
problem = merged.problem;
|
|
1874
|
-
else
|
|
2084
|
+
else {
|
|
2085
|
+
letGo = x.items.filter((was) => holdsChat(was) && !merged.items.some((now) => now.id === was.id && now.sessionId === was.sessionId && holdsChat(now)));
|
|
1875
2086
|
x.items = merged.items;
|
|
2087
|
+
}
|
|
1876
2088
|
});
|
|
1877
2089
|
if (problem)
|
|
1878
2090
|
throw new Error(problem);
|
|
2091
|
+
// Taken out, run again or started over (2026-11-19): its chat's card closed, so its message is carried on there.
|
|
2092
|
+
for (const was of letGo)
|
|
2093
|
+
await this.releaseFromQueue(was.sessionId, was.id, was.setAside);
|
|
1879
2094
|
return await this.withBusy(await this.makeQueueBranches(q));
|
|
1880
2095
|
}
|
|
1881
2096
|
/**
|
|
@@ -2037,7 +2252,8 @@ let OperatorService = class OperatorService {
|
|
|
2037
2252
|
if (ask)
|
|
2038
2253
|
await closePasswordWindows(ask, new Date(Date.parse(approval.createdAt) - 5_000)).catch(() => 0);
|
|
2039
2254
|
}
|
|
2040
|
-
|
|
2255
|
+
// Set aside by the queue, not stopped by the operator: its ending is said.
|
|
2256
|
+
await this.stop(key, 'bot').catch(() => undefined);
|
|
2041
2257
|
}
|
|
2042
2258
|
/**
|
|
2043
2259
|
* The operator's answer to a parked task, given when they are back (2026-10-26): kept on the task's record, and the
|
|
@@ -2048,16 +2264,42 @@ let OperatorService = class OperatorService {
|
|
|
2048
2264
|
await this.recoverQueue();
|
|
2049
2265
|
const q = await this.readQueue();
|
|
2050
2266
|
const item = q.items.find((x) => x.id === itemId);
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2267
|
+
/*
|
|
2268
|
+
* A card the queue does not hold any more (2026-11-19): its task taken out, run again or started over, or set aside
|
|
2269
|
+
* again in another chat. Every button failed, Stop included, and "Continue" was refused: the card is closed now, at
|
|
2270
|
+
* any press, and "Continue" carries its message on in its own chat. A Stop of it is simply taken.
|
|
2271
|
+
*/
|
|
2272
|
+
const from = typeof input?.sessionId === 'string' ? input.sessionId : undefined;
|
|
2273
|
+
if (!item || item.status !== 'parked' || !item.sessionId || (from && from !== item.sessionId)) {
|
|
2274
|
+
const of = from ?? (item?.status === 'parked' ? undefined : item?.sessionId);
|
|
2275
|
+
if (of)
|
|
2276
|
+
await this.releaseFromQueue(of, itemId);
|
|
2277
|
+
if (input?.stop === true && of)
|
|
2278
|
+
return await this.queue();
|
|
2279
|
+
if (!item)
|
|
2280
|
+
throw new Error(`That task is not in the queue any more. ${PARKED_RELEASED}`);
|
|
2281
|
+
// The card of another run of it (bug hunt 2026-11-18): it answered the card the queue's task waits on now, unseen.
|
|
2282
|
+
if (from && item.sessionId && from !== item.sessionId)
|
|
2283
|
+
throw new Error(`That card is of another run of this task: what the task waits for now is on the queue's page. ${PARKED_RELEASED}`);
|
|
2284
|
+
throw new Error(`That task is not waiting for an answer. ${PARKED_RELEASED}`);
|
|
2285
|
+
}
|
|
2055
2286
|
const s = await this.store.getSession(item.sessionId);
|
|
2056
2287
|
const task = s?.tasks.find((t) => t.parked && !t.parked.answer);
|
|
2057
2288
|
// Stopped whatever its record says (2026-11-18): a Stop that failed with the record gone left the task, and the ones
|
|
2058
2289
|
// that depend on it, waiting for good.
|
|
2059
2290
|
if (input?.stop === true) {
|
|
2060
|
-
|
|
2291
|
+
// Said on the record too, so its chat does not offer the card again (bug hunt 2026-11-18).
|
|
2292
|
+
if (s && task) {
|
|
2293
|
+
await this.store.updateSession(s.id, (x) => {
|
|
2294
|
+
const t = x.tasks.find((y) => y.id === task.id);
|
|
2295
|
+
if (t?.parked && !t.parked.answer)
|
|
2296
|
+
t.parked.answer = { kind: 'stopped', at: new Date().toISOString() };
|
|
2297
|
+
}).catch(() => undefined);
|
|
2298
|
+
}
|
|
2299
|
+
// Its work put aside by a task after it is not put back now (2026-11-19): where it is, said in its chat.
|
|
2300
|
+
if (item.setAside?.length)
|
|
2301
|
+
await this.releaseFromQueue(item.sessionId, itemId, item.setAside);
|
|
2302
|
+
return await this.withBusy(await this.changeQueue((x) => this.setQueueItem(x, itemId, { status: 'stopped', why: 'stopped by the operator at its card', waitsFor: undefined, setAside: undefined })));
|
|
2061
2303
|
}
|
|
2062
2304
|
if (!s || !task?.parked)
|
|
2063
2305
|
throw new Error('What that task waited for is not on its record any more; run it again.');
|
|
@@ -2106,6 +2348,9 @@ let OperatorService = class OperatorService {
|
|
|
2106
2348
|
// Stopped — from the queue, or the chat's Stop: the rest wait for the operator. Parked: the queue goes on.
|
|
2107
2349
|
if (ended.status === 'stopped')
|
|
2108
2350
|
return;
|
|
2351
|
+
// Stopped with the queue, to carry on at the next run: the loop sees the queue stopped and ends (2026-11-18).
|
|
2352
|
+
if (ended.status === 'waiting' && !(await this.readQueue()).running)
|
|
2353
|
+
return;
|
|
2109
2354
|
}
|
|
2110
2355
|
}
|
|
2111
2356
|
/** One task of the queue, in a new chat — or, answered after it was parked, in its own — to its end. */
|
|
@@ -2115,9 +2360,10 @@ let OperatorService = class OperatorService {
|
|
|
2115
2360
|
// Read afresh each time: the browser is let go of by other work while this waits.
|
|
2116
2361
|
const holder = () => this.browser;
|
|
2117
2362
|
// The browser may be the chat's, or a reading of the models': the task waits its turn.
|
|
2363
|
+
// Stopped before it began: it waits as it did (2026-11-18), not "stopped", which skipped what depends on it.
|
|
2118
2364
|
while (holder()) {
|
|
2119
2365
|
if (this.queueClosing || !(await stillRunning()))
|
|
2120
|
-
return { status: '
|
|
2366
|
+
return { status: 'waiting', why: undefined };
|
|
2121
2367
|
await pause(1_000);
|
|
2122
2368
|
}
|
|
2123
2369
|
const ws = await this.workspace();
|
|
@@ -2126,12 +2372,65 @@ let OperatorService = class OperatorService {
|
|
|
2126
2372
|
const cfg = await this.settings.load();
|
|
2127
2373
|
let sessionId;
|
|
2128
2374
|
let taskId;
|
|
2375
|
+
/** Carried on with "Continue" in its own chat: stopped with the queue, or the bot closed under it (2026-11-18). */
|
|
2376
|
+
let carryOn = false;
|
|
2129
2377
|
if (item.resume && item.sessionId) {
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2132
|
-
|
|
2378
|
+
const s0 = await this.store.getSession(item.sessionId);
|
|
2379
|
+
const answered = s0?.tasks.find((t) => t.parked?.answer && !parkedOver(t.parked));
|
|
2380
|
+
const last = s0?.tasks.at(-1);
|
|
2381
|
+
if (!s0 || !last)
|
|
2382
|
+
return { status: 'failed', why: 'its chat is not there any more; run it again' };
|
|
2383
|
+
/*
|
|
2384
|
+
* 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
|
|
2385
|
+
* branch the task after it left the folder on — one made for another task. What that left uncommitted is put
|
|
2386
|
+
* aside first, kept whole and not pushed, as before a task on a branch of its own.
|
|
2387
|
+
*/
|
|
2388
|
+
const began = (answered ?? last).checkpoint?.branch;
|
|
2389
|
+
if (ws.isRepo && !s0.vcs?.enabled && began) {
|
|
2390
|
+
const onNow = (await git(ws.dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']).catch(() => null))?.stdout || null;
|
|
2391
|
+
if (onNow !== began) {
|
|
2392
|
+
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'}`);
|
|
2393
|
+
if (aside && 'problem' in aside)
|
|
2394
|
+
return { status: 'failed', why: `what was not committed in the folder could not be put aside before it: ${aside.problem}`, sessionId: s0.id };
|
|
2395
|
+
// Kept for whose it is first (2026-11-19): a switch that failed after it said nothing of where it went.
|
|
2396
|
+
if (aside && 'saved' in aside)
|
|
2397
|
+
await this.leftoversOf(onNow, item.id, aside.saved);
|
|
2398
|
+
const back = await git(ws.dir, ['switch', began]);
|
|
2399
|
+
if (!back.ok)
|
|
2400
|
+
return { status: 'failed', why: `it could not be put back on ${began}, where it began: ${(back.stderr || back.stdout).trim().slice(0, 300)}${aside ? `; what was not committed in the folder is kept on ${aside.saved}, not pushed` : ''}`, sessionId: s0.id };
|
|
2401
|
+
this.bus.publish({ sessionId: s0.id, type: 'queue-back-on-branch', level: 'info',
|
|
2402
|
+
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` : ''}`,
|
|
2403
|
+
data: { branch: began, was: onNow, ...(aside ? { saved: aside.saved } : {}) } });
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
// 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.
|
|
2407
|
+
for (const saved of item.setAside ?? []) {
|
|
2408
|
+
const back = ws.isRepo && !s0.vcs?.enabled ? await putBackAside(ws.dir, saved) : { problem: 'it no longer works on the folder as it is' };
|
|
2409
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { setAside: (x.items.find((i) => i.id === item.id)?.setAside ?? []).filter((n) => n !== saved) }));
|
|
2410
|
+
this.bus.publish({ sessionId: s0.id, type: 'queue-put-back', level: 'problem' in back ? 'warn' : 'info',
|
|
2411
|
+
message: 'problem' in back
|
|
2412
|
+
? `what it had not committed, put aside on ${saved} by a task after it, could not be put back: ${back.problem}`
|
|
2413
|
+
: `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`,
|
|
2414
|
+
data: { saved, ...('problem' in back ? { problem: back.problem } : { files: back.files }) } });
|
|
2415
|
+
if ('problem' in back)
|
|
2416
|
+
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);
|
|
2417
|
+
}
|
|
2418
|
+
if (answered) {
|
|
2419
|
+
const carried = await this.resumeParked(item.sessionId, ws.dir);
|
|
2420
|
+
if ('problem' in carried)
|
|
2421
|
+
return { status: 'failed', why: carried.problem, sessionId: item.sessionId };
|
|
2422
|
+
taskId = carried.taskId;
|
|
2423
|
+
}
|
|
2424
|
+
else {
|
|
2425
|
+
// Finished in its chat meanwhile, or ended there in a way "Continue" does not carry on: as it ended.
|
|
2426
|
+
if (last.status !== 'queued' && !isContinuable(last)) {
|
|
2427
|
+
const status = statusOfTask(last.status);
|
|
2428
|
+
return { status, ...(status !== 'done' ? { why: last.reason ?? `it ended ${last.status}` } : {}), sessionId: s0.id };
|
|
2429
|
+
}
|
|
2430
|
+
taskId = last.id;
|
|
2431
|
+
carryOn = true;
|
|
2432
|
+
}
|
|
2133
2433
|
sessionId = item.sessionId;
|
|
2134
|
-
taskId = carried.taskId;
|
|
2135
2434
|
}
|
|
2136
2435
|
else {
|
|
2137
2436
|
// Settings may have changed since the queue was started.
|
|
@@ -2144,13 +2443,14 @@ let OperatorService = class OperatorService {
|
|
|
2144
2443
|
if (!(await branchExists(ws.dir, branchName)))
|
|
2145
2444
|
branchName = undefined;
|
|
2146
2445
|
else {
|
|
2147
|
-
const fresh = await refreshQueueBranch(ws.dir, branchName, item.branchBase);
|
|
2446
|
+
const fresh = await refreshQueueBranch(ws.dir, branchName, item.branchBase, item.branchFrom);
|
|
2148
2447
|
if (fresh.moved)
|
|
2149
|
-
await this.changeQueue((x) => this.setQueueItem(x, item.id, { branchBase: fresh.base, branchFrom:
|
|
2448
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { branchBase: fresh.base, ...(fresh.from ? { branchFrom: fresh.from } : {}) }));
|
|
2150
2449
|
}
|
|
2151
2450
|
}
|
|
2152
2451
|
// Not made when it was added — no repository then, or no main to make it from: made now, asking nobody anything.
|
|
2153
|
-
|
|
2452
|
+
// As it is now: brought up to the remote's main just above, it was made from that.
|
|
2453
|
+
let branchFrom = (await this.readQueue()).items.find((x) => x.id === item.id)?.branchFrom ?? item.branchFrom;
|
|
2154
2454
|
if (item.branch === 'main' && ws.isRepo && !branchName) {
|
|
2155
2455
|
const start = await branchStart(ws.dir, null);
|
|
2156
2456
|
if ('problem' in start)
|
|
@@ -2185,7 +2485,7 @@ let OperatorService = class OperatorService {
|
|
|
2185
2485
|
});
|
|
2186
2486
|
// Where its branch came from, told with its opening message: the local main when the server's could not be read.
|
|
2187
2487
|
if (branchName) {
|
|
2188
|
-
await this.store.addTaskNote(sessionId, taskId, branchFrom &&
|
|
2488
|
+
await this.store.addTaskNote(sessionId, taskId, branchFrom && !(await madeFromRemote(ws.dir, branchFrom))
|
|
2189
2489
|
? `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.`
|
|
2190
2490
|
: `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);
|
|
2191
2491
|
}
|
|
@@ -2207,6 +2507,7 @@ let OperatorService = class OperatorService {
|
|
|
2207
2507
|
if (aside) {
|
|
2208
2508
|
this.bus.publish({ sessionId, type: 'queue-set-aside', level: 'warn',
|
|
2209
2509
|
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` });
|
|
2510
|
+
await this.leftoversOf(onNow, item.id, aside.saved);
|
|
2210
2511
|
}
|
|
2211
2512
|
}
|
|
2212
2513
|
}
|
|
@@ -2216,19 +2517,22 @@ let OperatorService = class OperatorService {
|
|
|
2216
2517
|
*/
|
|
2217
2518
|
while (holder()) {
|
|
2218
2519
|
if (this.queueClosing || !(await stillRunning()))
|
|
2219
|
-
return { status: '
|
|
2520
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the queue was stopped before it began'), sessionId };
|
|
2220
2521
|
await pause(1_000);
|
|
2221
2522
|
}
|
|
2222
2523
|
this.queueAtWork.add(sessionId);
|
|
2524
|
+
/** Stopped with the queue: it carries on at the next run rather than counting as stopped (2026-11-18). */
|
|
2525
|
+
let asked = false;
|
|
2223
2526
|
try {
|
|
2224
|
-
const reply =
|
|
2527
|
+
const reply = carryOn
|
|
2528
|
+
? await this.chatContinue(sessionId, taskId).catch((e) => ({ started: false, reason: e.message }))
|
|
2529
|
+
: await this.start(sessionId, cfg.execution.mode);
|
|
2225
2530
|
if (!reply.started)
|
|
2226
2531
|
return { status: 'failed', why: reply.reason ?? 'it did not start', sessionId };
|
|
2227
2532
|
// Until its run has ended and its window let the browser go, so the next one can have it.
|
|
2228
|
-
let asked = false;
|
|
2229
2533
|
while (this.running.has(sessionId) || (holder()?.kind === 'run' && holder().sessionId === sessionId)) {
|
|
2230
2534
|
if (this.queueClosing)
|
|
2231
|
-
return { status: '
|
|
2535
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the bot was closed while it ran'), sessionId };
|
|
2232
2536
|
if (!asked && !(await stillRunning())) {
|
|
2233
2537
|
asked = true;
|
|
2234
2538
|
await this.stop(sessionId).catch(() => undefined);
|
|
@@ -2251,7 +2555,18 @@ let OperatorService = class OperatorService {
|
|
|
2251
2555
|
});
|
|
2252
2556
|
return { status: 'parked', why, sessionId };
|
|
2253
2557
|
}
|
|
2254
|
-
|
|
2558
|
+
// Stopped with the queue ("Stop the queue … the rest wait"): it carries on, in its own chat, at the next run.
|
|
2559
|
+
if ((asked || !(await stillRunning())) && task && (task.status === 'queued' || isContinuable(task))) {
|
|
2560
|
+
return { status: 'waiting', resume: true, why: CARRIES_ON_AFTER('the queue was stopped while it ran'), sessionId };
|
|
2561
|
+
}
|
|
2562
|
+
const byOperator = this.endedByOperator.get(sessionId) === true;
|
|
2563
|
+
this.endedByOperator.delete(sessionId);
|
|
2564
|
+
/*
|
|
2565
|
+
* Stopped by nobody — its conversation lost, its window closed past the times it is opened again (2026-11-19): it
|
|
2566
|
+
* ended stopped so that its chat offers "Continue", but only the operator's Stop stops the queue. It failed: what
|
|
2567
|
+
* depends on it is skipped, the others run, and its chat carries it on when the operator chooses.
|
|
2568
|
+
*/
|
|
2569
|
+
const status = task?.status === 'aborted' && !byOperator ? 'failed' : statusOfTask(task?.status);
|
|
2255
2570
|
return { status, ...(status !== 'done' ? { why: task?.reason ?? `it ended ${task?.status ?? 'without a record'}` } : {}), sessionId };
|
|
2256
2571
|
}
|
|
2257
2572
|
/**
|
|
@@ -2262,23 +2577,31 @@ let OperatorService = class OperatorService {
|
|
|
2262
2577
|
*/
|
|
2263
2578
|
async resumeParked(sessionId, dir) {
|
|
2264
2579
|
const s = await this.store.getSession(sessionId);
|
|
2265
|
-
|
|
2580
|
+
// Not one stopped at its card (2026-11-18): that is an answer that does not carry it on.
|
|
2581
|
+
const task = s?.tasks.find((t) => t.parked?.answer && !parkedOver(t.parked));
|
|
2266
2582
|
const p = task?.parked;
|
|
2267
2583
|
const a = p?.answer;
|
|
2268
|
-
if (!s || !task || !p || !a)
|
|
2584
|
+
if (!s || !task || !p || !a || a.kind === 'stopped' || a.kind === 'released')
|
|
2269
2585
|
return { problem: 'its answer is not on its record any more; run it again' };
|
|
2270
2586
|
const continuing = { fromAttempt: task.attempt ?? 1, stoppedBecause: task.reason, how: 'parked', parkedFor: p.kind };
|
|
2271
2587
|
let note = '';
|
|
2272
2588
|
let approvedPlan;
|
|
2273
2589
|
const command = p.approval.description.replace(/^\[[\w-]+\]\s*/, '');
|
|
2590
|
+
/*
|
|
2591
|
+
* 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
|
|
2592
|
+
* with status "continue", which is not the lead's, and it was asked again for its format.
|
|
2593
|
+
*/
|
|
2594
|
+
const ofLead = !!task.lead;
|
|
2274
2595
|
if (a.kind === 'plan') {
|
|
2596
|
+
const revised = a.note?.trim() || 'Make the plan more concrete: name the files and the stages.';
|
|
2275
2597
|
if (a.decision === 'approve' && p.approval.plan) {
|
|
2276
2598
|
approvedPlan = { ...p.approval.plan.plan, approved: { by: 'operator', at: a.at, ...(a.note?.trim() ? { note: a.note.trim() } : {}) } };
|
|
2277
|
-
|
|
2599
|
+
// Carried on, the lead may give as many subtasks again as Settings allow (see `runLeadTask`).
|
|
2600
|
+
note = ofLead ? leadPlanApproved(approvedPlan.approved, Math.max(1, (await this.settings.load()).limits.maxSubtasks ?? 20)) : planApprovedMessage(approvedPlan.approved);
|
|
2278
2601
|
}
|
|
2279
2602
|
else {
|
|
2280
2603
|
continuing.replan = true;
|
|
2281
|
-
note =
|
|
2604
|
+
note = ofLead ? leadPlanRevise(revised, p.approval.plan?.plan.version ?? 1) : planReviseMessage(revised, p.approval.plan?.plan.version ?? 1);
|
|
2282
2605
|
}
|
|
2283
2606
|
}
|
|
2284
2607
|
else if (a.kind === 'question') {
|
|
@@ -2295,17 +2618,30 @@ let OperatorService = class OperatorService {
|
|
|
2295
2618
|
}
|
|
2296
2619
|
else if (a.kind === 'retry' && p.approval.retry) {
|
|
2297
2620
|
const r = p.approval.retry;
|
|
2298
|
-
|
|
2299
|
-
|
|
2621
|
+
const worker = await this.store.getSession(p.approval.sessionId);
|
|
2622
|
+
if (a.choice === 'accept') {
|
|
2623
|
+
/*
|
|
2624
|
+
* With what its last attempt ended on (bug hunt 2026-11-18): the lead was given only that it failed, where the
|
|
2625
|
+
* run itself gives it the subtask's report.
|
|
2626
|
+
*/
|
|
2627
|
+
const last = worker?.tasks.find((t) => t.id === p.approval.taskId);
|
|
2628
|
+
const ended = last ? [`Its last attempt ended ${last.status}${last.reason ? `: ${last.reason}` : ''}.`, ...(last.summary?.trim() ? ['', 'The worker\'s summary:', '', last.summary.trim()] : [])] : [];
|
|
2629
|
+
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');
|
|
2630
|
+
}
|
|
2300
2631
|
else {
|
|
2301
2632
|
if (a.choice === 'restore') {
|
|
2302
|
-
|
|
2303
|
-
|
|
2633
|
+
/*
|
|
2634
|
+
* To the subtask's start, its first attempt's photograph, as the run puts it back (bug hunt 2026-11-18): the
|
|
2635
|
+
* card's own task is the last attempt's, whose photograph holds what the attempts before it changed.
|
|
2636
|
+
*/
|
|
2637
|
+
const first = [...(task.lead?.rounds ?? [])].reverse().find((x) => x.subtask?.n === r.n)?.subtask?.attempts?.[0]?.taskId ?? p.approval.taskId;
|
|
2638
|
+
const cp = worker?.tasks.find((t) => t.id === first)?.checkpoint;
|
|
2304
2639
|
const back = cp ? await restoreCheckpoint(dir, cp) : { ok: false, problem: 'the subtask\'s start was not photographed' };
|
|
2305
2640
|
if (!back.ok)
|
|
2306
2641
|
return { problem: `the folder could not be put back to the subtask's start (${back.problem}); answer it again with another choice` };
|
|
2307
2642
|
}
|
|
2308
|
-
|
|
2643
|
+
// Put back: the next attempt is told it starts over, not to carry on from what the last one left.
|
|
2644
|
+
continuing.retrySubtask = { n: r.n, ...(a.choice === 'fresh' ? { fresh: true } : {}), ...(a.choice === 'restore' ? { restored: true } : {}) };
|
|
2309
2645
|
}
|
|
2310
2646
|
}
|
|
2311
2647
|
else if (a.kind === 'command') {
|
|
@@ -2627,13 +2963,18 @@ let OperatorService = class OperatorService {
|
|
|
2627
2963
|
const session = await this.store.getSession(threadId);
|
|
2628
2964
|
if (!session || session.kind !== 'chat')
|
|
2629
2965
|
throw new Error('That conversation is not there any more.');
|
|
2630
|
-
if (session.directedBy)
|
|
2631
|
-
throw new Error('Kerrigan directs this chat: carry her conversation on instead.');
|
|
2632
2966
|
if (this.running.has(this.runKey(threadId)))
|
|
2633
2967
|
throw new Error('The conversation is working: stop it first, or let it finish.');
|
|
2634
2968
|
const task = session.tasks.find((t) => t.id === taskId);
|
|
2635
2969
|
if (!task)
|
|
2636
2970
|
throw new Error('That message is not in this conversation.');
|
|
2971
|
+
/*
|
|
2972
|
+
* A chat Kerrigan directs: her messages are carried on in her conversation. One the operator wrote there while she
|
|
2973
|
+
* 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
|
|
2974
|
+
* stopped nothing could carry it on).
|
|
2975
|
+
*/
|
|
2976
|
+
if (session.directedBy && task.fromKerrigan)
|
|
2977
|
+
throw new Error('Kerrigan sent this message: carry her conversation on instead.');
|
|
2637
2978
|
if (session.tasks.at(-1)?.id !== taskId)
|
|
2638
2979
|
throw new Error('Only the last message of a conversation is carried on: the conversation has gone on past this one.');
|
|
2639
2980
|
/*
|
|
@@ -2644,6 +2985,12 @@ let OperatorService = class OperatorService {
|
|
|
2644
2985
|
// A queue task set aside is answered on its card (2026-11-18): carried on here, its queue entry lost what it waited for.
|
|
2645
2986
|
if (task.parked && !task.parked.answer)
|
|
2646
2987
|
throw new Error('This message waits for an answer on its card in the queue: answer it there, and the queue carries it on.');
|
|
2988
|
+
/*
|
|
2989
|
+
* Answered on its card, the queue carries it on with the answer (2026-11-19): carried on here instead, the answer was
|
|
2990
|
+
* filed under the attempt before and lost — a plan approved was asked for again, a question's answer never sent.
|
|
2991
|
+
*/
|
|
2992
|
+
if (!parkedOver(task.parked))
|
|
2993
|
+
throw new Error(PARKED_ANSWERED);
|
|
2647
2994
|
const busy = this.browserBusyFor(threadId);
|
|
2648
2995
|
if (busy)
|
|
2649
2996
|
throw new Error(busy);
|
|
@@ -2753,15 +3100,39 @@ let OperatorService = class OperatorService {
|
|
|
2753
3100
|
if (text.length > MAX_INSTRUCTION_CHARS)
|
|
2754
3101
|
return { ok: false, problem: `The note is ${text.length} characters; it can be at most ${MAX_INSTRUCTION_CHARS}.` };
|
|
2755
3102
|
this.waiting.delete(approvalId);
|
|
3103
|
+
if (action === 'stop' && !as)
|
|
3104
|
+
this.stoppedByOperator.add(this.runKey(w.approval.sessionId));
|
|
2756
3105
|
w.resolvePlan({ decision: action, ...(text ? { note: text } : {}), ...(as ? { by: as.by } : {}) });
|
|
2757
3106
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2758
3107
|
message: `plan: ${action}${text ? ' (with a note)' : ''}${as ? `, by Kerrigan${as.why ? ` — ${as.why}` : ''}` : ''}`, data: { approvalId, action, plan: true, ...(as ? { by: as.by } : {}) } });
|
|
3108
|
+
// The operator's Stop on the plan of a chat inside another's run stops the run (see `decide`); Kerrigan's is her own.
|
|
3109
|
+
if (action === 'stop' && !as && this.runKey(w.approval.sessionId) !== w.approval.sessionId)
|
|
3110
|
+
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
2759
3111
|
return { ok: true };
|
|
2760
3112
|
}
|
|
2761
3113
|
/** What waits for the operator; of one session, its worker's included (two chats: they are asked in its conversation). */
|
|
2762
3114
|
pendingApprovals(sessionId) {
|
|
2763
3115
|
// Kerrigan's (2026-11-12): the cards of the chats she directs, and of their workers, are shown in hers too.
|
|
2764
|
-
return [...this.waiting.values()]
|
|
3116
|
+
return [...this.waiting.values()]
|
|
3117
|
+
.map((w) => w.approval)
|
|
3118
|
+
.filter((a) => !sessionId || this.under(a.sessionId, sessionId))
|
|
3119
|
+
.map((a) => {
|
|
3120
|
+
const off = this.runAllOff(a);
|
|
3121
|
+
return off ? { ...a, runAllOff: off } : a;
|
|
3122
|
+
});
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* What keeps "Run this and the rest" from this command's card, read as the card is shown (2026-11-19): under the
|
|
3126
|
+
* default Settings — no isolation — it was offered on every card and refused at every press. Only a command's card
|
|
3127
|
+
* has it, and not one that downloads or reaches a platform, which is asked about in every run anyway.
|
|
3128
|
+
*/
|
|
3129
|
+
runAllOff(a) {
|
|
3130
|
+
if (a.plan || a.question || a.retry || a.model || a.network || a.platform)
|
|
3131
|
+
return undefined;
|
|
3132
|
+
const run = this.running.get(this.runKey(a.sessionId));
|
|
3133
|
+
if (!run || run.mode === 'unattended')
|
|
3134
|
+
return undefined;
|
|
3135
|
+
return unattendedBlock(run.policy) ?? undefined;
|
|
2765
3136
|
}
|
|
2766
3137
|
/**
|
|
2767
3138
|
* Answers one pending approval.
|
|
@@ -2773,9 +3144,23 @@ let OperatorService = class OperatorService {
|
|
|
2773
3144
|
*/
|
|
2774
3145
|
decide(approvalId, action) {
|
|
2775
3146
|
const w = this.waiting.get(approvalId);
|
|
3147
|
+
// Said (bug hunt 2026-11-18): answered "ok: false" with 200, the press looked taken, and the card went on waiting.
|
|
2776
3148
|
if (!w)
|
|
2777
|
-
return { ok: false };
|
|
3149
|
+
return { ok: false, problem: CARD_GONE };
|
|
3150
|
+
/*
|
|
3151
|
+
* "Run this and the rest" where the run may not go on unasked (policy.lock.json, an empty allowlist, the isolation):
|
|
3152
|
+
* it ran the step as "Run", the next was asked again, and nothing said why (bug hunt 2026-11-18). Refused before the
|
|
3153
|
+
* card is answered, with the reason; "Run" is there for this step.
|
|
3154
|
+
*/
|
|
3155
|
+
if (action === 'run-all') {
|
|
3156
|
+
const run = this.running.get(this.runKey(w.approval.sessionId));
|
|
3157
|
+
const blocked = run && run.mode !== 'unattended' ? unattendedPrecondition({ ...run.policy, mode: 'unattended' }) : null;
|
|
3158
|
+
if (blocked)
|
|
3159
|
+
return { ok: false, problem: RUN_ALL_REFUSED(blocked) };
|
|
3160
|
+
}
|
|
2778
3161
|
this.waiting.delete(approvalId);
|
|
3162
|
+
if (action === 'abort')
|
|
3163
|
+
this.stoppedByOperator.add(this.runKey(w.approval.sessionId));
|
|
2779
3164
|
if (action === 'run-all')
|
|
2780
3165
|
this.setRunMode(this.runKey(w.approval.sessionId), 'unattended');
|
|
2781
3166
|
const decision = action === 'run' || action === 'run-all'
|
|
@@ -2794,6 +3179,13 @@ let OperatorService = class OperatorService {
|
|
|
2794
3179
|
*/
|
|
2795
3180
|
if (w.approval.model?.manual && action === 'abort')
|
|
2796
3181
|
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
3182
|
+
/*
|
|
3183
|
+
* "Stop the task" or "Abort task" on a card of a conversation inside another's run — the worker of two chats, a chat
|
|
3184
|
+
* Kerrigan directs (bug hunt 2026-11-18): it ended only that conversation's task, and the lead, or Kerrigan, was told
|
|
3185
|
+
* it stopped and went on. The operator stopped the work: the run stops, as the chat's Stop stops it.
|
|
3186
|
+
*/
|
|
3187
|
+
else if (action === 'abort' && this.runKey(w.approval.sessionId) !== w.approval.sessionId)
|
|
3188
|
+
void this.stop(w.approval.sessionId).catch(() => undefined);
|
|
2797
3189
|
return { ok: true };
|
|
2798
3190
|
}
|
|
2799
3191
|
/**
|
|
@@ -3174,6 +3566,44 @@ let OperatorService = class OperatorService {
|
|
|
3174
3566
|
* The repository check travels with it because the two questions are always asked together:
|
|
3175
3567
|
* somewhere to work, and whether that somewhere can be branched and committed.
|
|
3176
3568
|
*/
|
|
3569
|
+
/**
|
|
3570
|
+
* "Open a folder" in the workbench (second bug hunt, 2026-11-19): the folder becomes the project. It kept the name,
|
|
3571
|
+
* the level 2 and "for reference only" of the one before — a folder opened to work in was then for reference only,
|
|
3572
|
+
* every change put back, and Kerrigan given another project's notes. One of the other projects comes with its own,
|
|
3573
|
+
* and the one before takes its place among them; any other folder comes with what it had when it was the project
|
|
3574
|
+
* before, or with nothing, and the one before is remembered with its own.
|
|
3575
|
+
*/
|
|
3576
|
+
async openProjectFolder(dir) {
|
|
3577
|
+
const target = dir.trim();
|
|
3578
|
+
if (!target || !existsSync(target))
|
|
3579
|
+
throw new Error(`The folder ${target || '(none)'} does not exist on this machine.`);
|
|
3580
|
+
await this.settings.update((raw) => {
|
|
3581
|
+
const current = (raw.project ?? {});
|
|
3582
|
+
const was = { rootDir: (current.rootDir ?? '').trim(), name: (current.name ?? '').trim(), level2: current.level2 ?? '', readOnly: current.readOnly === true };
|
|
3583
|
+
if (was.rootDir && sameFolder(was.rootDir, target))
|
|
3584
|
+
return raw;
|
|
3585
|
+
const others = (current.others ?? []);
|
|
3586
|
+
let earlier = (current.earlier ?? []).filter((e) => e.rootDir && !sameFolder(e.rootDir, target) && !(was.rootDir && sameFolder(e.rootDir, was.rootDir)));
|
|
3587
|
+
const i = others.findIndex((o) => o.rootDir && sameFolder(o.rootDir, target));
|
|
3588
|
+
let next;
|
|
3589
|
+
let nextOthers = others;
|
|
3590
|
+
if (i >= 0) {
|
|
3591
|
+
const o = others[i];
|
|
3592
|
+
next = { rootDir: o.rootDir, name: o.name ?? '', level2: o.level2 ?? '', readOnly: o.readOnly === true };
|
|
3593
|
+
nextOthers = was.rootDir
|
|
3594
|
+
? others.map((x, j) => (j === i ? { name: was.name || basename(was.rootDir) || was.rootDir, rootDir: was.rootDir, level2: was.level2, readOnly: was.readOnly } : x))
|
|
3595
|
+
: others.filter((_, j) => j !== i);
|
|
3596
|
+
}
|
|
3597
|
+
else {
|
|
3598
|
+
const before = (current.earlier ?? []).find((e) => e.rootDir && sameFolder(e.rootDir, target));
|
|
3599
|
+
next = { rootDir: target, name: before?.name ?? '', level2: before?.level2 ?? '', readOnly: before?.readOnly === true };
|
|
3600
|
+
if (was.rootDir && (was.name || was.level2.trim() || was.readOnly))
|
|
3601
|
+
earlier = [was, ...earlier].slice(0, 20);
|
|
3602
|
+
}
|
|
3603
|
+
return { ...raw, project: { ...current, ...next, others: nextOthers, earlier } };
|
|
3604
|
+
});
|
|
3605
|
+
return await this.project();
|
|
3606
|
+
}
|
|
3177
3607
|
async project() {
|
|
3178
3608
|
const cfg = await this.settings.load();
|
|
3179
3609
|
const rootDir = (cfg.project?.rootDir ?? '').trim();
|
|
@@ -3272,6 +3702,17 @@ let OperatorService = class OperatorService {
|
|
|
3272
3702
|
throw new Error(`Two projects are named "${o.name}". Names are how the folders are told apart, so each needs its own.`);
|
|
3273
3703
|
seen.add(key);
|
|
3274
3704
|
}
|
|
3705
|
+
/*
|
|
3706
|
+
* A project that may be changed inside one for reference only (bug hunt 2026-11-18): every change made in it would
|
|
3707
|
+
* be put back after each step, so no task there could finish. Refused, with what to do.
|
|
3708
|
+
*/
|
|
3709
|
+
const all = [{ name: name || rootDir, rootDir, readOnly }, ...others].filter((p) => p.rootDir);
|
|
3710
|
+
for (const w of all.filter((p) => !p.readOnly)) {
|
|
3711
|
+
const r = all.find((p) => p.readOnly && p !== w && folderInside(w.rootDir, p.rootDir));
|
|
3712
|
+
if (r) {
|
|
3713
|
+
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}.`);
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3275
3716
|
// What the removed Desktop copies left in the stored project is dropped with the next save.
|
|
3276
3717
|
const { mirror: _m, desktop: _d, mirrorToDesktop: _t, ...rest } = current;
|
|
3277
3718
|
return { ...raw, project: { ...rest, rootDir, name, level2, readOnly, others } };
|
|
@@ -3384,6 +3825,9 @@ let OperatorService = class OperatorService {
|
|
|
3384
3825
|
if (upn && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(upn)) {
|
|
3385
3826
|
throw new Error(`"${upn}" is not an account address. Give the work or school address, for example name@company.com, or leave it empty.`);
|
|
3386
3827
|
}
|
|
3828
|
+
// The run's own window waits for exactly that (2026-11-19): it was refused "once the run has finished", which never came.
|
|
3829
|
+
if (this.signInAsked.size > 0 && this.running.size > 0)
|
|
3830
|
+
throw new Error(SIGN_IN_IN_THE_RUNS_WINDOW);
|
|
3387
3831
|
const claim = this.claimBrowser({ kind: 'login' });
|
|
3388
3832
|
if ('refused' in claim)
|
|
3389
3833
|
throw new Error(claim.refused);
|
|
@@ -3463,9 +3907,6 @@ let OperatorService = class OperatorService {
|
|
|
3463
3907
|
chatUrl: cfg.copilot.url,
|
|
3464
3908
|
channel: cfg.copilot.channel,
|
|
3465
3909
|
headless: cfg.copilot.headless,
|
|
3466
|
-
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
3467
|
-
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
3468
|
-
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
3469
3910
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
3470
3911
|
// The rows' locator reads the names (Settings' own, 2026-10-24).
|
|
3471
3912
|
...pickerOptions(cfg),
|
|
@@ -3525,9 +3966,6 @@ let OperatorService = class OperatorService {
|
|
|
3525
3966
|
chatUrl: cfg.copilot.url,
|
|
3526
3967
|
channel: cfg.copilot.channel,
|
|
3527
3968
|
headless: cfg.copilot.headless,
|
|
3528
|
-
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
3529
|
-
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
3530
|
-
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
3531
3969
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
3532
3970
|
...pickerOptions(cfg),
|
|
3533
3971
|
onEvent: (event, detail) => {
|
|
@@ -3539,11 +3977,8 @@ let OperatorService = class OperatorService {
|
|
|
3539
3977
|
await transport.open();
|
|
3540
3978
|
let results;
|
|
3541
3979
|
try {
|
|
3542
|
-
// A step of the operator's own that is not there
|
|
3543
|
-
await transport.ensureSignedIn(
|
|
3544
|
-
if (!(e instanceof LocatorMissing) || !isStepKey(e.key))
|
|
3545
|
-
throw e;
|
|
3546
|
-
});
|
|
3980
|
+
// A step of the operator's own that is not there does not stop a check, which only reads: each is looked for below.
|
|
3981
|
+
await transport.ensureSignedIn(undefined, { stepsLookOnly: true });
|
|
3547
3982
|
results = await transport.checkLocators();
|
|
3548
3983
|
}
|
|
3549
3984
|
catch (e) {
|