copilot-operator 0.1.94 → 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/dist/src/api/operator.controller.js +5 -1
- package/dist/src/api/operator.service.js +272 -50
- package/dist/src/config/live.js +12 -12
- 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 +12 -12
- package/dist/src/queue/queue.js +12 -0
- package/dist/src/queue/queueBranch.js +34 -9
- package/dist/src/session/store.js +9 -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 +23 -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-d031bf326e401246.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-3f144d13be3516c2.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/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 → kNfJ9jSwlboc-1sFBBfuI}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{UNygvDtRnBVZrGJt53IE4 → kNfJ9jSwlboc-1sFBBfuI}/_ssgManifest.js +0 -0
package/dist/src/config/live.js
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
* agreement with the bot — the time a command may take, the limits, the pauses, the reports and their redaction.
|
|
11
11
|
* Each is read where it is used, so the next step, the next reply or the next message goes by the new value;
|
|
12
12
|
* - from the next message (`next`): what a message is built on when it starts — the models, plan mode, the shell and
|
|
13
|
-
* folder a step runs in by default, the project and its folders, the skills, the contract's stop word, the mode a
|
|
14
|
-
* start takes
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* (2026-11-17)
|
|
13
|
+
* folder a step runs in by default, the project and its folders, the skills, the contract's stop word, and the mode a
|
|
14
|
+
* start takes. Every limit is at once: the lead's number of subtasks too since 2026-11-18 — it is told how many are
|
|
15
|
+
* left with each report — as are Kerrigan's messages, the times the window is opened again and the carrying on;
|
|
16
|
+
* - when the chat window opens again (`window`): the chat's address and its browser; it is kept open between
|
|
17
|
+
* messages. Its locators and the steps on the way to the chat are taken at once (2026-11-17), and its waits for a
|
|
18
|
+
* reply, a sign-in and a verification (2026-11-18): the window open is handed them (`takeSettings`).
|
|
18
19
|
*
|
|
19
20
|
* A step that is running, and a card already put to the operator, go on as they began. The locked policy, when there is
|
|
20
21
|
* one, is in what was saved (`loadConfigObject`), so it is taken with the rest and still wins.
|
|
@@ -30,16 +31,15 @@ const NOW = {
|
|
|
30
31
|
limits: '*',
|
|
31
32
|
pacing: '*',
|
|
32
33
|
report: '*',
|
|
33
|
-
// The locators and the steps on the way to the chat (2026-11-17): handed to the window open, at once (`takeSettings`)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** Of a section taken whole, what a message is told when it starts: the lead's number of subtasks is its assignment's. */
|
|
37
|
-
const NOT_NOW = {
|
|
38
|
-
limits: ['maxSubtasks'],
|
|
34
|
+
// The locators and the steps on the way to the chat (2026-11-17): handed to the window open, at once (`takeSettings`);
|
|
35
|
+
// its waits too (2026-11-18), which the window kept open between messages went on with for days.
|
|
36
|
+
copilot: ['pickerLocators', 'chatLocators', 'pickerSteps', 'builtInSteps', 'extraSteps', 'replyTimeoutSec', 'signInTimeoutSec', 'humanWaitSec'],
|
|
39
37
|
};
|
|
38
|
+
/** Of a section taken whole, what a message is told only when it starts: none since 2026-11-18. */
|
|
39
|
+
const NOT_NOW = {};
|
|
40
40
|
/** What the chat window was opened with. */
|
|
41
41
|
const WINDOW = {
|
|
42
|
-
copilot: ['url', 'profileDir', 'channel', 'headless', '
|
|
42
|
+
copilot: ['url', 'profileDir', 'channel', 'headless', 'keepFailurePage'],
|
|
43
43
|
};
|
|
44
44
|
/** The sections a run compares; the rest (where the bot keeps its records) is read when the bot starts. */
|
|
45
45
|
const SECTIONS = ['copilot', 'task', 'execution', 'report', 'project', 'skills', 'pacing', 'limits'];
|
|
@@ -168,6 +168,8 @@ export async function runKerriganTask(transport, session, task, deps) {
|
|
|
168
168
|
*/
|
|
169
169
|
const before = task.continuing ? task.attempts?.at(-1)?.kerrigan : undefined;
|
|
170
170
|
const k = { rounds: [], sent: before?.sent ?? 0, maxSends: maxSends(), messages: 0, chats: [...(before?.chats ?? [])] };
|
|
171
|
+
/** The most she may send, as Settings have it now: saved during the message, it counts at once (bug hunt 2026-11-18). */
|
|
172
|
+
const budget = () => (k.maxSends = maxSends());
|
|
171
173
|
const save = async () => {
|
|
172
174
|
const copy = JSON.parse(JSON.stringify(k));
|
|
173
175
|
await setTask((t) => {
|
|
@@ -762,7 +764,7 @@ export async function runKerriganTask(transport, session, task, deps) {
|
|
|
762
764
|
];
|
|
763
765
|
if (attached)
|
|
764
766
|
lines.push('', `Attached, \`${attached}\`: the whole exchange of this message, as JSON — every message the chat was sent, every reply of its, every command with all it printed. Read it where the summary above is not enough.`);
|
|
765
|
-
lines.push('', `Messages to chats left: ${Math.max(0,
|
|
767
|
+
lines.push('', `Messages to chats left: ${Math.max(0, budget() - k.sent)} of ${budget()}.`, 'Reply in your format: the next message (send), your report (done), a question for the person (ask), or blocked.');
|
|
766
768
|
return lines.join('\n');
|
|
767
769
|
};
|
|
768
770
|
const finish = async (status, reason, summary) => {
|
|
@@ -852,8 +854,8 @@ export async function runKerriganTask(transport, session, task, deps) {
|
|
|
852
854
|
sink.event('kerrigan-reply', { round: k.rounds.length, status: r.status }, `Kerrigan: ${r.status}${r.title ? ` — ${r.title}` : ''}`);
|
|
853
855
|
switch (r.status) {
|
|
854
856
|
case 'send': {
|
|
855
|
-
if (k.sent >=
|
|
856
|
-
r = await askHer(`You have sent the ${
|
|
857
|
+
if (k.sent >= budget()) {
|
|
858
|
+
r = await askHer(`You have sent the ${budget()} message(s) to chats you may for this task. Deliver what you have now — status "done" with your report, what is missing said plainly — or "blocked".`, async (x) => (x.status === 'send' ? 'No message to a chat is left: reply "done" or "blocked".' : await decides(x)));
|
|
857
859
|
break;
|
|
858
860
|
}
|
|
859
861
|
const ran = await sendToChat(r, round);
|
|
@@ -879,7 +881,7 @@ export async function runKerriganTask(transport, session, task, deps) {
|
|
|
879
881
|
sink.event('kerrigan-question-answered', {}, 'the operator answered Kerrigan');
|
|
880
882
|
await actingNow('kerrigan');
|
|
881
883
|
const said = got.chosen ? `The person answered your question, ${chosenSaid({ chosen: got.chosen, ...(got.written ? { written: got.written } : {}) })}` : `The person answers your question:\n\n${got.answer.trim()}`;
|
|
882
|
-
r = await askHer(`${said}\n\nGo on in your format. Messages to chats left: ${Math.max(0,
|
|
884
|
+
r = await askHer(`${said}\n\nGo on in your format. Messages to chats left: ${Math.max(0, budget() - k.sent)} of ${budget()}.`, decides);
|
|
883
885
|
break;
|
|
884
886
|
}
|
|
885
887
|
case 'done': {
|
|
@@ -915,6 +917,11 @@ export async function runKerriganTask(transport, session, task, deps) {
|
|
|
915
917
|
// Why, as the kept window says it (2026-11-13): not opened again by Settings, past the times allowed, or not found.
|
|
916
918
|
if (e instanceof WindowClosed || transport.closedOutside())
|
|
917
919
|
return await finish('aborted', e instanceof WindowClosed ? e.message : CLOSED_NOT_REOPENED);
|
|
920
|
+
// A conversation the window could not be put back on, nothing sent: stopped, and Continue tries it again (2026-11-18).
|
|
921
|
+
if (e instanceof ChatLost) {
|
|
922
|
+
sink.event('chat-lost', { chatId: e.chatId, found: e.found }, message, 'warn');
|
|
923
|
+
return await finish('aborted', message);
|
|
924
|
+
}
|
|
918
925
|
sink.event('task-error', { error: message, stack: e.stack }, message, 'error');
|
|
919
926
|
return await finish('failed', message);
|
|
920
927
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* are shown and "go back" works for the whole of it.
|
|
21
21
|
*/
|
|
22
22
|
import { appendFile, mkdir, writeFile } from 'node:fs/promises';
|
|
23
|
-
import { isReplyTimeout, WindowClosed } from '../transport/chatTransport.js';
|
|
23
|
+
import { ChatLost, isReplyTimeout, WindowClosed } from '../transport/chatTransport.js';
|
|
24
24
|
import { CLOSED_NOT_REOPENED } from '../transport/keptWindow.js';
|
|
25
25
|
import { buildChatName, chatCode, savePointer } from '../transport/chatSession.js';
|
|
26
26
|
import { RunLog } from '../log/runLog.js';
|
|
@@ -82,12 +82,15 @@ export function assignmentMessage(task, n, facts, again) {
|
|
|
82
82
|
* conversation, told why it stopped, to carry on from where the work got to — the subtasks and their reports are above
|
|
83
83
|
* it — rather than to start the assignment again.
|
|
84
84
|
*/
|
|
85
|
-
export function continuationMessage(task, n, facts) {
|
|
85
|
+
export function continuationMessage(task, n, facts, unreported) {
|
|
86
86
|
const instruction = task.continuing?.instruction?.trim();
|
|
87
87
|
return [
|
|
88
88
|
`Continue assignment ${n}: ${task.title.trim() || 'untitled'}, in this same conversation. ${task.continuing ? whyItStopped(task.continuing) : ''}`.trim(),
|
|
89
89
|
'',
|
|
90
90
|
'Do not start over: the subtasks so far and the worker\'s reports are above in this conversation. Say in "notes" where the work got to, and carry on from there in the lead\'s format.',
|
|
91
|
+
...(unreported
|
|
92
|
+
? ['', `Subtask ${unreported.n} (${unreported.title}) was cut off when the work stopped, and has no report: what it did is not known. Give it again, or a subtask that checks what it left, if the work still needs it. The next subtask you give is number ${unreported.n + 1}.`]
|
|
93
|
+
: []),
|
|
91
94
|
...(instruction ? ['', 'The operator adds this, which wins where it and the assignment disagree:', '', instruction] : []),
|
|
92
95
|
'',
|
|
93
96
|
`You may give the worker up to ${facts.maxSubtasks} more subtask(s) for it.`,
|
|
@@ -141,6 +144,11 @@ export function noSubtasksLeft(max) {
|
|
|
141
144
|
'Deliver what the work has found (status "done", with what is missing said plainly in "answer"), or stop (status "blocked", with what would let it go on in "needed").',
|
|
142
145
|
].join('\n');
|
|
143
146
|
}
|
|
147
|
+
/** What the lead is told when it gives a subtask that changes the folder before the operator approved its plan. */
|
|
148
|
+
export const PLAN_BEFORE_CHANGES = [
|
|
149
|
+
'That subtask was not given to the worker: it changes the folder ("readOnly": false), and the operator approves plans in this conversation, so nothing changes before your plan is approved.',
|
|
150
|
+
'Send your plan first ("status": "plan"). A survey that changes nothing ("readOnly": true) may still be given before it.',
|
|
151
|
+
].join('\n');
|
|
144
152
|
/** The plan, as the lead is told it was approved. */
|
|
145
153
|
export function leadPlanApproved(approval, left) {
|
|
146
154
|
return [
|
|
@@ -196,13 +204,15 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
196
204
|
});
|
|
197
205
|
sink.event('acting', acting, `at work now: ${ACTOR_WORDS[actor]}${more.subtask ? ` (subtask ${more.subtask})` : ''}`);
|
|
198
206
|
};
|
|
199
|
-
|
|
207
|
+
/** "Most subtasks the lead may give", as Settings have it now: saved during the message, it counts at once (bug hunt 2026-11-18). */
|
|
208
|
+
const max = () => Math.max(1, cfg.limits.maxSubtasks ?? 20);
|
|
200
209
|
/*
|
|
201
210
|
* The most subtasks this attempt may have given in all: `max`, and as many again as the attempt before had given when a
|
|
202
|
-
* subtask is tried again after a Stop, its record carried on (2026-10-25).
|
|
211
|
+
* subtask is tried again after a Stop, its record carried on (2026-10-25), or when the message is carried on (2026-11-18).
|
|
203
212
|
*/
|
|
204
|
-
let
|
|
205
|
-
const lead = { rounds: [], subtasks: 0, maxSubtasks: max };
|
|
213
|
+
let givenBefore = 0;
|
|
214
|
+
const lead = { rounds: [], subtasks: 0, maxSubtasks: max() };
|
|
215
|
+
const limit = () => (lead.maxSubtasks = givenBefore + max());
|
|
206
216
|
const saveLead = async () => {
|
|
207
217
|
const copy = JSON.parse(JSON.stringify(lead));
|
|
208
218
|
await setTask((t) => {
|
|
@@ -217,7 +227,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
217
227
|
t.runId = runId;
|
|
218
228
|
t.runGroup = deps.runGroup;
|
|
219
229
|
t.startedAt = new Date().toISOString();
|
|
220
|
-
t.lead = { rounds: [], subtasks: 0, maxSubtasks: max };
|
|
230
|
+
t.lead = { rounds: [], subtasks: 0, maxSubtasks: max() };
|
|
221
231
|
});
|
|
222
232
|
await writeFile(taskLogPath, `TASK: ${task.title}\nSESSION: ${session.name} (${session.id})\nRUN: ${runId}\nSTARTED: ${new Date().toISOString()}\nMODE: lead and worker\n`, 'utf8');
|
|
223
233
|
sink.event('task-started', { runId, title: task.title, lead: true }, `task "${task.title}" starting with a lead and a worker (run ${runId})`);
|
|
@@ -432,9 +442,9 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
432
442
|
files.length > 0 ? `Files it changed: ${files.join(', ')}.` : 'It changed no file.',
|
|
433
443
|
...((t?.deviations?.length ?? 0) > 0 ? ['', describeDeviations(t.deviations)] : []),
|
|
434
444
|
'',
|
|
435
|
-
`Subtasks left: ${limit - lead.subtasks} of ${limit}.`,
|
|
445
|
+
`Subtasks left: ${limit() - lead.subtasks} of ${limit()}.`,
|
|
436
446
|
// Its own list, as it sent it last, to send again with the next subtask (2026-10-21).
|
|
437
|
-
...(lead.ledger ? ['', describeLedger(lead.ledger, lead.subtasks, limit)] : []),
|
|
447
|
+
...(lead.ledger ? ['', describeLedger(lead.ledger, lead.subtasks, limit())] : []),
|
|
438
448
|
'Reply in the lead\'s format: the next subtask, the plan, a question for the operator, or the result.',
|
|
439
449
|
].join('\n');
|
|
440
450
|
};
|
|
@@ -571,7 +581,8 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
571
581
|
const sub = round.subtask;
|
|
572
582
|
await saveLead();
|
|
573
583
|
let attempt = (sub.attempts?.length ?? 0) + 1;
|
|
574
|
-
|
|
584
|
+
// Put back to its start before (a card the queue kept, 2026-11-18): told it starts over, not to carry on.
|
|
585
|
+
let how = resume ? { fresh: resume.fresh, continued: !resume.restored, restored: !!resume.restored, by: 'after-stop' } : { fresh: given.fresh, continued: false, restored: false };
|
|
575
586
|
// What the attempt before left, for the next one's message: what finished, what was cut off, what changed so far.
|
|
576
587
|
let previous;
|
|
577
588
|
let changedSoFar = [];
|
|
@@ -581,7 +592,8 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
581
592
|
const lastTask = w?.tasks.find((x) => x.id === last.taskId);
|
|
582
593
|
const facts = stepFacts(await stepsOfTask(lastTask));
|
|
583
594
|
previous = { why: last.reason ? `${FAILURE_WORDS[last.category ?? 'USER_STOPPED']}: ${last.reason}` : FAILURE_WORDS[last.category ?? 'USER_STOPPED'], done: facts.done, cutOff: facts.cutOff };
|
|
584
|
-
|
|
595
|
+
// Put back to the subtask's start: nothing the attempts before changed is there any more.
|
|
596
|
+
changedSoFar = resume.restored ? [] : [...new Set(resume.from.attempts.flatMap((a) => (w?.tasks.find((x) => x.id === a.taskId)?.vcs?.files ?? []).map((f) => f.path)))];
|
|
585
597
|
}
|
|
586
598
|
let ended;
|
|
587
599
|
for (;;) {
|
|
@@ -699,7 +711,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
699
711
|
try {
|
|
700
712
|
const facts = {
|
|
701
713
|
workDir: chatDir,
|
|
702
|
-
maxSubtasks: max,
|
|
714
|
+
maxSubtasks: max(),
|
|
703
715
|
maxIterations: cfg.limits.maxIterations,
|
|
704
716
|
maxRunMinutes: cfg.limits.maxRunMinutes,
|
|
705
717
|
planApproval: session.planMode === 'approve' && !!deps.approvePlan,
|
|
@@ -712,7 +724,14 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
712
724
|
const contract = (await store.getLead1()).content.trim();
|
|
713
725
|
// Carried on in its own conversation: told why it stopped, and to go on from there (see `continuationMessage`).
|
|
714
726
|
const carryingOn = !!task.continuing && !!session.contractSent;
|
|
715
|
-
|
|
727
|
+
/*
|
|
728
|
+
* The attempt carried on (bug hunt 2026-11-18): its subtasks are counted on, not numbered from 1 again under the
|
|
729
|
+
* reports of 1 to k above in the conversation, and one it was cut off in, with no report, is named to the lead.
|
|
730
|
+
*/
|
|
731
|
+
const prior = carryingOn ? task.attempts?.at(-1)?.lead : undefined;
|
|
732
|
+
const lastGiven = prior ? [...prior.rounds].reverse().find((r) => r.subtask)?.subtask : undefined;
|
|
733
|
+
const unreported = lastGiven && !lastGiven.report && !task.continuing?.retrySubtask ? { n: lastGiven.n, title: lastGiven.title } : undefined;
|
|
734
|
+
const assignment = carryingOn ? continuationMessage(task, n || 1, facts, unreported) : assignmentMessage(task, n || 1, facts, !!session.contractSent);
|
|
716
735
|
await setTask((t) => {
|
|
717
736
|
t.firstMessage = session.contractSent ? assignment : `${contract}\n\n---\n\n${assignment}`;
|
|
718
737
|
});
|
|
@@ -733,17 +752,24 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
733
752
|
* folder as it is; then the lead is told to carry on, with that subtask's report.
|
|
734
753
|
*/
|
|
735
754
|
const retryFirst = carryingOn ? task.continuing?.retrySubtask : undefined;
|
|
755
|
+
/*
|
|
756
|
+
* The rounds of the attempt before, copied with its record when a subtask is tried again after a Stop: not this
|
|
757
|
+
* attempt's to count against its limit (bug hunt 2026-11-18: a Stop near the last round ended the next attempt at
|
|
758
|
+
* the limit as soon as the retried subtask's report went out).
|
|
759
|
+
*/
|
|
760
|
+
let roundsBefore = 0;
|
|
736
761
|
const before = retryFirst ? task.attempts?.at(-1)?.lead : undefined;
|
|
737
762
|
const from = before && retryFirst ? [...before.rounds].reverse().find((r) => r.subtask?.n === retryFirst.n)?.subtask : undefined;
|
|
738
763
|
if (retryFirst && before && from) {
|
|
764
|
+
roundsBefore = before.rounds.length;
|
|
739
765
|
lead.rounds = JSON.parse(JSON.stringify(before.rounds));
|
|
740
766
|
lead.subtasks = before.subtasks;
|
|
741
767
|
if (before.ledger)
|
|
742
768
|
lead.ledger = before.ledger;
|
|
743
769
|
if (before.workerSessionId)
|
|
744
770
|
lead.workerSessionId = before.workerSessionId;
|
|
745
|
-
|
|
746
|
-
|
|
771
|
+
givenBefore = before.subtasks;
|
|
772
|
+
limit();
|
|
747
773
|
const w = before.workerSessionId ? await store.getSession(before.workerSessionId) : null;
|
|
748
774
|
const firstId = from.attempts?.[0]?.taskId ?? from.taskId;
|
|
749
775
|
const firstTask = w?.tasks.find((x) => x.id === firstId);
|
|
@@ -755,12 +781,18 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
755
781
|
lead.rounds.push(round);
|
|
756
782
|
await saveLead();
|
|
757
783
|
sink.event('subtask-retry-after-stop', { n: retryFirst.n, fresh: !!retryFirst.fresh }, `subtask ${retryFirst.n} is tried again after the Stop, at the operator's word${retryFirst.fresh ? ', by a fresh worker' : ''}`);
|
|
758
|
-
const ran = await runSubtask({ title: from.title, readOnly: !!from.readOnly, fresh: !!retryFirst.fresh, prompt: () => firstTask?.prompt ?? '' }, round, { n: retryFirst.n, fresh: !!retryFirst.fresh, from: { ...from, attempts }, firstPrompt: firstTask?.prompt ?? '' });
|
|
784
|
+
const ran = await runSubtask({ title: from.title, readOnly: !!from.readOnly, fresh: !!retryFirst.fresh, prompt: () => firstTask?.prompt ?? '' }, round, { n: retryFirst.n, fresh: !!retryFirst.fresh, ...(retryFirst.restored ? { restored: true } : {}), from: { ...from, attempts }, firstPrompt: firstTask?.prompt ?? '' });
|
|
759
785
|
if (ran === 'stopped')
|
|
760
786
|
return await finish('aborted', 'stopped by the operator');
|
|
761
787
|
markdown = await tell(afterStopRetryMessage(assignment, retryFirst.n, ran.report));
|
|
762
788
|
}
|
|
763
789
|
else {
|
|
790
|
+
if (prior) {
|
|
791
|
+
lead.subtasks = prior.subtasks;
|
|
792
|
+
givenBefore = prior.subtasks;
|
|
793
|
+
limit();
|
|
794
|
+
await saveLead();
|
|
795
|
+
}
|
|
764
796
|
markdown = await tell(assignment);
|
|
765
797
|
}
|
|
766
798
|
const maxFormat = () => Math.max(0, cfg.limits.maxFormatRetries ?? 2);
|
|
@@ -769,11 +801,16 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
769
801
|
let understood = carryingOn;
|
|
770
802
|
let planVersion = 0;
|
|
771
803
|
let revisions = [];
|
|
804
|
+
/*
|
|
805
|
+
* Whether a plan of this message was approved: in this attempt, or, carried on, in one before it (a plan approved on
|
|
806
|
+
* a card the queue kept, or before a Stop) — what lets a subtask that changes the folder go to the worker.
|
|
807
|
+
*/
|
|
808
|
+
let planApproved = !!task.plan?.approved || (!!task.continuing && (task.attempts ?? []).some((a) => !!a.plan?.approved));
|
|
772
809
|
const maxRounds = () => Math.max(1, cfg.limits.maxIterations);
|
|
773
810
|
for (;;) {
|
|
774
811
|
if (signal?.aborted)
|
|
775
812
|
return await finish('aborted', 'stopped by the operator');
|
|
776
|
-
if (lead.rounds.length >= maxRounds()) {
|
|
813
|
+
if (lead.rounds.length - roundsBefore >= maxRounds()) {
|
|
777
814
|
limitHit = { setting: 'maxIterations', value: maxRounds() };
|
|
778
815
|
return await finish('limit-reached', `maxIterations (${maxRounds()}) reached: the lead's replies`);
|
|
779
816
|
}
|
|
@@ -809,7 +846,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
809
846
|
};
|
|
810
847
|
lead.rounds.push(round);
|
|
811
848
|
// Its list of subtasks, as this reply sends it (2026-10-21); the subtask given now is the running one.
|
|
812
|
-
const giving = r.status === 'delegate' && r.subtask && lead.subtasks < limit ? { title: r.subtask.title, n: lead.subtasks + 1 } : undefined;
|
|
849
|
+
const giving = r.status === 'delegate' && r.subtask && lead.subtasks < limit() ? { title: r.subtask.title, n: lead.subtasks + 1 } : undefined;
|
|
813
850
|
const listed = nextLedger(lead.ledger, r.todo, round.at, giving);
|
|
814
851
|
lead.ledger = listed.ledger;
|
|
815
852
|
if (listed.change) {
|
|
@@ -823,8 +860,18 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
823
860
|
sink.event('lead-reply', { round: round.n, status: r.status }, `the lead: ${r.status}${r.subtask ? ` — ${r.subtask.title}` : ''}`);
|
|
824
861
|
switch (r.status) {
|
|
825
862
|
case 'delegate': {
|
|
826
|
-
if (lead.subtasks >= limit) {
|
|
827
|
-
markdown = await tell(noSubtasksLeft(limit));
|
|
863
|
+
if (lead.subtasks >= limit()) {
|
|
864
|
+
markdown = await tell(noSubtasksLeft(limit()));
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
/*
|
|
868
|
+
* Plans approved by the operator, and none approved yet (bug hunt 2026-11-18): only the contract asked the lead to
|
|
869
|
+
* wait, and a subtask that changes the folder went to the worker all the same. A survey that changes nothing may
|
|
870
|
+
* go before the plan, as the contract says; anything else waits for the plan's approval.
|
|
871
|
+
*/
|
|
872
|
+
if (facts.planApproval && !planApproved && !r.subtask.readOnly) {
|
|
873
|
+
sink.event('lead-plan-first', { round: round.n, title: r.subtask.title }, `the lead gave a subtask that changes the folder before its plan was approved; told to send the plan first: ${r.subtask.title}`, 'warn');
|
|
874
|
+
markdown = await tell(PLAN_BEFORE_CHANGES);
|
|
828
875
|
break;
|
|
829
876
|
}
|
|
830
877
|
const ran = await runSubtask(givenOf(r.subtask), round);
|
|
@@ -863,7 +910,8 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
863
910
|
if (t.plan)
|
|
864
911
|
t.plan.approved = approved;
|
|
865
912
|
});
|
|
866
|
-
|
|
913
|
+
planApproved = true;
|
|
914
|
+
markdown = await tell(leadPlanApproved(approved, limit() - lead.subtasks));
|
|
867
915
|
break;
|
|
868
916
|
}
|
|
869
917
|
case 'ask': {
|
|
@@ -880,7 +928,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
880
928
|
round.question.at = new Date().toISOString();
|
|
881
929
|
await saveLead();
|
|
882
930
|
sink.event('question-agreed', { round: round.n, question: r.question, answer: agreed }, `the lead asked: ${r.question} — answered as it recommends (Settings agree with what the bot proposes): ${agreed}`);
|
|
883
|
-
markdown = await tell(operatorAnswerMessage(agreed, limit - lead.subtasks));
|
|
931
|
+
markdown = await tell(operatorAnswerMessage(agreed, limit() - lead.subtasks));
|
|
884
932
|
break;
|
|
885
933
|
}
|
|
886
934
|
if (!deps.askQuestion) {
|
|
@@ -899,7 +947,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
899
947
|
round.question.at = new Date().toISOString();
|
|
900
948
|
await saveLead();
|
|
901
949
|
sink.event('lead-question-answered', { round: round.n, ...(got.by ? { by: got.by } : {}) }, got.by === 'kerrigan' ? 'Kerrigan answered the lead' : 'the operator answered the lead');
|
|
902
|
-
markdown = await tell(operatorAnswerMessage(got.answer, limit - lead.subtasks, got.chosen ? { chosen: got.chosen, ...(got.written ? { written: got.written } : {}) } : undefined, got.by === 'kerrigan'));
|
|
950
|
+
markdown = await tell(operatorAnswerMessage(got.answer, limit() - lead.subtasks, got.chosen ? { chosen: got.chosen, ...(got.written ? { written: got.written } : {}) } : undefined, got.by === 'kerrigan'));
|
|
903
951
|
break;
|
|
904
952
|
}
|
|
905
953
|
case 'done': {
|
|
@@ -926,6 +974,11 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
926
974
|
// Why, as the kept window says it (2026-11-13): not opened again by Settings, past the times allowed, or not found.
|
|
927
975
|
if (e instanceof WindowClosed || transport.closedOutside())
|
|
928
976
|
return await finish('aborted', e instanceof WindowClosed ? e.message : CLOSED_NOT_REOPENED);
|
|
977
|
+
// A conversation the window could not be put back on, nothing sent: stopped, and Continue tries it again (2026-11-18).
|
|
978
|
+
if (e instanceof ChatLost) {
|
|
979
|
+
sink.event('chat-lost', { chatId: e.chatId, found: e.found }, message, 'warn');
|
|
980
|
+
return await finish('aborted', message);
|
|
981
|
+
}
|
|
929
982
|
sink.event('task-error', { error: message, stack: e.stack }, message, 'error');
|
|
930
983
|
return await finish('failed', message);
|
|
931
984
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
22
22
|
import { join } from 'node:path';
|
|
23
23
|
import { installLayout } from '../config/layout.js';
|
|
24
|
+
import { ChatLost, WindowClosed } from '../transport/chatTransport.js';
|
|
24
25
|
import { parseReview, formatErrorMessage, findLikelyDamage, damageGuidance } from '../protocol/parser.js';
|
|
25
26
|
import { describeFindings, findingId, isGrounded } from '../protocol/reviewSchema.js';
|
|
26
27
|
import { runStep } from '../exec/runner.js';
|
|
@@ -262,8 +263,8 @@ export async function runReview(transport, session, task, deps) {
|
|
|
262
263
|
// The machine's shells, when they are not what the contract's example assumes — the same note
|
|
263
264
|
// the implementer's conversation opens with, for a conversation working to the same example.
|
|
264
265
|
const machineNote = shellNote(undefined, defaultShell);
|
|
265
|
-
let before = await transport.sendAndConfirm(machineNote ? `${contract}
|
|
266
|
-
|
|
266
|
+
let before = await transport.sendAndConfirm(machineNote ? `${contract}
|
|
267
|
+
|
|
267
268
|
${machineNote}` : contract);
|
|
268
269
|
await transport.waitForReply(before);
|
|
269
270
|
await pacer.throttleSend();
|
|
@@ -572,6 +573,9 @@ ${machineNote}` : contract);
|
|
|
572
573
|
}
|
|
573
574
|
}
|
|
574
575
|
catch (e) {
|
|
576
|
+
// The window closed, or its conversation lost: not the review failing, the work's to stop on (`gateOnReview`).
|
|
577
|
+
if (e instanceof ChatLost || e instanceof WindowClosed)
|
|
578
|
+
throw e;
|
|
575
579
|
return { verdict: 'error', findings: [], stepsRun, iterations, problem: e.message };
|
|
576
580
|
}
|
|
577
581
|
}
|
|
@@ -25,7 +25,8 @@ export function stepFacts(steps) {
|
|
|
25
25
|
export function classifySubtaskEnd(task, opts = {}) {
|
|
26
26
|
if (task.status === 'done')
|
|
27
27
|
return null;
|
|
28
|
-
|
|
28
|
+
// Aborted by a fault of the chat (its conversation lost, 2026-11-18), not by the operator: a fault of the means.
|
|
29
|
+
if (opts.stopped || (task.status === 'aborted' && task.failure?.kind !== 'transport'))
|
|
29
30
|
return 'USER_STOPPED';
|
|
30
31
|
if (task.stopCode === 'environment' || task.failure?.kind === 'shell')
|
|
31
32
|
return 'COMMAND_INFRASTRUCTURE_FAILURE';
|
|
@@ -457,7 +457,11 @@ export function speakFor(transport, sessionId, opts = {}) {
|
|
|
457
457
|
speaker.alone = true;
|
|
458
458
|
}
|
|
459
459
|
/** The settings a window open takes at once (`takeSettings`): its locators and the steps on the way to the chat. */
|
|
460
|
-
const WINDOW_NOW = new Set([
|
|
460
|
+
const WINDOW_NOW = new Set([
|
|
461
|
+
'copilot.pickerLocators', 'copilot.chatLocators', 'copilot.pickerSteps', 'copilot.builtInSteps', 'copilot.extraSteps',
|
|
462
|
+
// The window's waits (2026-11-18), which the window kept open between messages went on with for days.
|
|
463
|
+
'copilot.replyTimeoutSec', 'copilot.signInTimeoutSec', 'copilot.humanWaitSec',
|
|
464
|
+
]);
|
|
461
465
|
/** The model menu's locators and its step pictures, as Settings have them (2026-10-24), for every window that picks a model. */
|
|
462
466
|
/** The locators Settings hold for the Copilot window: the model menu's, and the chat page's own (the box to write in, 2026-11-17). */
|
|
463
467
|
export function pickerOptions(cfg) {
|
|
@@ -472,11 +476,17 @@ export function pickerOptions(cfg) {
|
|
|
472
476
|
...(cfg.copilot.pickerSteps ? { modelStepShots: true } : {}),
|
|
473
477
|
...(switchedOff ? { builtInSteps: builtIn } : {}),
|
|
474
478
|
...(own.length > 0 ? { extraSteps: own } : {}),
|
|
479
|
+
// Its waits, as Settings have them now (2026-11-18): a window kept open is handed them with each message.
|
|
480
|
+
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
481
|
+
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
482
|
+
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
475
483
|
};
|
|
476
484
|
}
|
|
477
485
|
export async function openBrowser(cfg, bus, transportDir, sessionId,
|
|
478
486
|
/** The run's Stop: a sign-in still awaited ends with it. */
|
|
479
|
-
signal
|
|
487
|
+
signal,
|
|
488
|
+
/** The run's settings: a locator or a step fixed while the sign-in is awaited is handed to the window at once. */
|
|
489
|
+
live) {
|
|
480
490
|
const speaker = { id: sessionId };
|
|
481
491
|
const transport = createTransport({
|
|
482
492
|
profileDir: cfg.resolved.profileDir,
|
|
@@ -484,9 +494,6 @@ signal) {
|
|
|
484
494
|
chatUrl: cfg.copilot.url,
|
|
485
495
|
channel: cfg.copilot.channel,
|
|
486
496
|
headless: cfg.copilot.headless,
|
|
487
|
-
replyTimeoutMs: cfg.copilot.replyTimeoutSec * 1000,
|
|
488
|
-
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
489
|
-
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
490
497
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
491
498
|
...pickerOptions(cfg),
|
|
492
499
|
onEvent: (event, detail) => {
|
|
@@ -542,6 +549,11 @@ signal) {
|
|
|
542
549
|
* or read of the models, the one the error asks for, was refused as "Edge is already running with
|
|
543
550
|
* this profile" until the window was closed by hand.
|
|
544
551
|
*/
|
|
552
|
+
// Until the run has the window (`runSession` hands it what is saved from then on): bug hunt 2026-11-18.
|
|
553
|
+
const unlive = live?.onChange((change) => {
|
|
554
|
+
if (change.now.some((name) => WINDOW_NOW.has(name)))
|
|
555
|
+
transport.takeSettings(pickerOptions(cfg));
|
|
556
|
+
});
|
|
545
557
|
try {
|
|
546
558
|
await transport.open();
|
|
547
559
|
await transport.ensureSignedIn(undefined, { signal });
|
|
@@ -552,6 +564,9 @@ signal) {
|
|
|
552
564
|
// Closed with its X while it opened or the sign-in was awaited: a stop, not a failure to start (2026-10-19).
|
|
553
565
|
throw byHand ? new WindowClosed() : e;
|
|
554
566
|
}
|
|
567
|
+
finally {
|
|
568
|
+
unlive?.();
|
|
569
|
+
}
|
|
555
570
|
return transport;
|
|
556
571
|
}
|
|
557
572
|
/**
|
|
@@ -719,8 +734,8 @@ export function failedOpening(e) {
|
|
|
719
734
|
/** Whether a run failed while opening the browser or entering the conversation (see `failedOpening`). */
|
|
720
735
|
export const failedWhileOpening = (e) => !!e?.openingBrowser;
|
|
721
736
|
/** The old shape, kept for the terminal path: open a browser and enter the conversation. */
|
|
722
|
-
export async function openSessionTransport(cfg, session, bus, runsDir, signal) {
|
|
723
|
-
const transport = await openBrowser(cfg, bus, join(runsDir, '_browser'), session.id, signal);
|
|
737
|
+
export async function openSessionTransport(cfg, session, bus, runsDir, signal, live) {
|
|
738
|
+
const transport = await openBrowser(cfg, bus, join(runsDir, '_browser'), session.id, signal, live);
|
|
724
739
|
/*
|
|
725
740
|
* Closed on any failure to enter the conversation, not only a conversation that will not reopen: the caller has no
|
|
726
741
|
* transport yet, so a page that would not load left the window open on the profile with nobody holding it.
|
|
@@ -2415,6 +2430,8 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2415
2430
|
const beforeReview = processesBefore ? await snapshotProcesses(work.cwd, processesBefore.since).catch(() => null) : null;
|
|
2416
2431
|
let roundLeftovers = [];
|
|
2417
2432
|
let outcome;
|
|
2433
|
+
/** What cut the review off, when it was not the review's own failing: the window closed, the conversation lost. */
|
|
2434
|
+
let reviewCut;
|
|
2418
2435
|
try {
|
|
2419
2436
|
await transport.newChat();
|
|
2420
2437
|
if (model || (reviewByHand && deps.models?.askHelp)) {
|
|
@@ -2496,6 +2513,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2496
2513
|
});
|
|
2497
2514
|
}
|
|
2498
2515
|
catch (e) {
|
|
2516
|
+
reviewCut = e;
|
|
2499
2517
|
outcome = { verdict: 'error', findings: [], stepsRun: 0, iterations: 0, problem: e.message };
|
|
2500
2518
|
}
|
|
2501
2519
|
finally {
|
|
@@ -2528,6 +2546,21 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2528
2546
|
sink.event('review-stopped', { round: reviewRounds, stepsRun: outcome.stepsRun }, `the operator stopped the run during review round ${reviewRounds}; the work is neither accepted nor sent back`, 'warn');
|
|
2529
2547
|
return 'stopped';
|
|
2530
2548
|
}
|
|
2549
|
+
/*
|
|
2550
|
+
* The window closed during the review and not opened again, or a conversation lost (bug hunt 2026-11-18): said as
|
|
2551
|
+
* the review's error, which accepts the work unreviewed, so the task ended "done" where everywhere else it ends
|
|
2552
|
+
* stopped, with Continue. Thrown on, for the end of the task to say it as it says it anywhere (see `runTask`).
|
|
2553
|
+
*/
|
|
2554
|
+
if (transport.closedOutside() || reviewCut instanceof ChatLost || reviewCut instanceof WindowClosed) {
|
|
2555
|
+
await saveReview({
|
|
2556
|
+
verdict: 'error',
|
|
2557
|
+
rounds: reviewRounds,
|
|
2558
|
+
stepsRun: outcome.stepsRun,
|
|
2559
|
+
problem: `review round ${reviewRounds} was cut off: ${outcome.problem ?? 'the browser window was closed'}`,
|
|
2560
|
+
model: model || undefined,
|
|
2561
|
+
});
|
|
2562
|
+
throw reviewCut instanceof Error ? reviewCut : new WindowClosed(CLOSED_NOT_REOPENED);
|
|
2563
|
+
}
|
|
2531
2564
|
/*
|
|
2532
2565
|
* Which findings an earlier round already raised.
|
|
2533
2566
|
*
|
|
@@ -3617,6 +3650,19 @@ export async function runTask(transport, session, task, deps) {
|
|
|
3617
3650
|
sink.event('window-closed', { error: message, reopened: transport.reopenedTimes?.() ?? 0 }, why, 'warn');
|
|
3618
3651
|
return await finish('aborted', why);
|
|
3619
3652
|
}
|
|
3653
|
+
/*
|
|
3654
|
+
* The window could not be put back on its conversation (2026-11-09), nothing sent: a stop, not a failure of the work
|
|
3655
|
+
* (bug hunt 2026-11-18: it ended "failed", where no Continue is offered, though its own words say to continue once
|
|
3656
|
+
* signed in). Continue goes back to the conversation again. A fault of the means all the same, so a worker's subtask
|
|
3657
|
+
* that ends so may be tried again (`classifySubtaskEnd`), as any fault of the chat may.
|
|
3658
|
+
*/
|
|
3659
|
+
if (e instanceof ChatLost) {
|
|
3660
|
+
sink.event('chat-lost', { chatId: e.chatId, found: e.found }, message, 'warn');
|
|
3661
|
+
await setTask((t) => {
|
|
3662
|
+
t.failure = { kind: 'transport', detail: message.slice(0, 400) };
|
|
3663
|
+
}).catch(() => undefined);
|
|
3664
|
+
return await finish('aborted', message);
|
|
3665
|
+
}
|
|
3620
3666
|
sink.event('task-error', { error: message, stack: e.stack }, message, 'error');
|
|
3621
3667
|
await transport.dumpFailure(log.path('failures'), 'crash').catch(() => undefined);
|
|
3622
3668
|
/*
|
|
@@ -3678,6 +3724,16 @@ export async function runSession(sessionId, deps) {
|
|
|
3678
3724
|
let lastStatus;
|
|
3679
3725
|
/** Whether the queue stopped because the operator asked it to hold, rather than because it ended. */
|
|
3680
3726
|
let paused = false;
|
|
3727
|
+
/*
|
|
3728
|
+
* The locators and the steps on the way to the chat, fixed in Settings while this run goes (bug hunt 2026-11-18): the
|
|
3729
|
+
* window takes them at once, as the notice says, whatever the run is doing — waiting for a sign-in or on the model's
|
|
3730
|
+
* card, or the lead or Kerrigan at their turn. Only a task at work handed them on before (`tookSettings` in
|
|
3731
|
+
* `runTask`); the window opened for the run is handed them while it waits for the sign-in too (`openBrowser`).
|
|
3732
|
+
*/
|
|
3733
|
+
const unwindow = deps.live?.onChange((change) => {
|
|
3734
|
+
if (transport && change.now.some((name) => WINDOW_NOW.has(name)))
|
|
3735
|
+
transport.takeSettings(pickerOptions(cfg));
|
|
3736
|
+
}) ?? (() => undefined);
|
|
3681
3737
|
try {
|
|
3682
3738
|
session = await joinGroupConversation(store, session, bus);
|
|
3683
3739
|
try {
|
|
@@ -3695,7 +3751,7 @@ export async function runSession(sessionId, deps) {
|
|
|
3695
3751
|
else {
|
|
3696
3752
|
await deps.beforeBrowser?.();
|
|
3697
3753
|
// The chat's window outlives this message, so what it keeps goes where the batch's window keeps its own.
|
|
3698
|
-
transport = await openSessionTransport(cfg, session, bus, deps.chatWindow ? cfg.resolved.runsDir : sessionRunsDir, deps.signal);
|
|
3754
|
+
transport = await openSessionTransport(cfg, session, bus, deps.chatWindow ? cfg.resolved.runsDir : sessionRunsDir, deps.signal, deps.live);
|
|
3699
3755
|
if (deps.chatWindow)
|
|
3700
3756
|
speakFor(transport, session.id, { alone: true });
|
|
3701
3757
|
}
|
|
@@ -3735,7 +3791,8 @@ export async function runSession(sessionId, deps) {
|
|
|
3735
3791
|
* 2026-11-13: "if I close the browser by accident, carry the task on from where it got to"), up to the times
|
|
3736
3792
|
* Settings allow for one message — its runs again in a fresh chat and on its own after a limit included.
|
|
3737
3793
|
*/
|
|
3738
|
-
|
|
3794
|
+
// As Settings have it each time the window goes (bug hunt 2026-11-18: copied at the message's start).
|
|
3795
|
+
chat.holdWindow?.(() => cfg.limits.reopenWindow ?? 3, deps.signal);
|
|
3739
3796
|
/*
|
|
3740
3797
|
* A task taken from the queue was started by the operator, never by the retry loop below, which
|
|
3741
3798
|
* runs its own. A fresh-retry mark on it is left from a retry that was queued and never ran —
|
|
@@ -3809,10 +3866,11 @@ export async function runSession(sessionId, deps) {
|
|
|
3809
3866
|
* stopped, not one that blocked with nothing to do (that goes to a fresh chat below, then to a person),
|
|
3810
3867
|
* and not when a pause or Stop was asked for.
|
|
3811
3868
|
*/
|
|
3812
|
-
|
|
3869
|
+
// As Settings have it each time (bug hunt 2026-11-18: copied once, though Settings say limits count at once).
|
|
3870
|
+
const autoAllowed = () => Math.max(0, cfg.limits.autoContinue ?? 0);
|
|
3813
3871
|
let autoContinued = 0;
|
|
3814
3872
|
const carriedOnAtOnce = async () => {
|
|
3815
|
-
if (autoContinued >= autoAllowed || deps.signal?.aborted || deps.shouldPause?.())
|
|
3873
|
+
if (autoContinued >= autoAllowed() || deps.signal?.aborted || deps.shouldPause?.())
|
|
3816
3874
|
return false;
|
|
3817
3875
|
const now = (await store.getSession(sessionId))?.tasks.find((x) => x.id === task.id);
|
|
3818
3876
|
if (!now || !now.limit || now.status === 'aborted' || !isContinuable(now))
|
|
@@ -3823,8 +3881,8 @@ export async function runSession(sessionId, deps) {
|
|
|
3823
3881
|
taskId: task.id,
|
|
3824
3882
|
type: 'task-auto-continue',
|
|
3825
3883
|
level: 'warn',
|
|
3826
|
-
message: `"${task.title}" stopped at ${now.limit.setting} (${now.limit.value}); carrying it on in its own chat, from where it got to (${autoContinued} of ${autoAllowed})`,
|
|
3827
|
-
data: { setting: now.limit.setting, value: now.limit.value, time: autoContinued, of: autoAllowed, status: now.status },
|
|
3884
|
+
message: `"${task.title}" stopped at ${now.limit.setting} (${now.limit.value}); carrying it on in its own chat, from where it got to (${autoContinued} of ${autoAllowed()})`,
|
|
3885
|
+
data: { setting: now.limit.setting, value: now.limit.value, time: autoContinued, of: autoAllowed(), status: now.status },
|
|
3828
3886
|
});
|
|
3829
3887
|
await store.continueTask(sessionId, task.id);
|
|
3830
3888
|
session = (await store.getSession(sessionId));
|
|
@@ -3838,7 +3896,7 @@ export async function runSession(sessionId, deps) {
|
|
|
3838
3896
|
for (;;) {
|
|
3839
3897
|
while (outcome.status === 'blocked' && retried < retriesAllowed && !deps.signal?.aborted && !(outcome.stopCode && NOT_THE_CHATS.includes(outcome.stopCode))
|
|
3840
3898
|
// A task a limit stopped is carried on where it is, with its work, not started over in a fresh chat.
|
|
3841
|
-
&& !(autoContinued < autoAllowed && !!(await store.getSession(sessionId))?.tasks.find((x) => x.id === task.id)?.limit)) {
|
|
3899
|
+
&& !(autoContinued < autoAllowed() && !!(await store.getSession(sessionId))?.tasks.find((x) => x.id === task.id)?.limit)) {
|
|
3842
3900
|
retried += 1;
|
|
3843
3901
|
bus.publish({
|
|
3844
3902
|
sessionId,
|
|
@@ -3896,8 +3954,8 @@ export async function runSession(sessionId, deps) {
|
|
|
3896
3954
|
level: outcome.status === 'done' ? 'info' : 'warn',
|
|
3897
3955
|
message: outcome.status === 'done'
|
|
3898
3956
|
? `"${task.title}" done after being carried on ${autoContinued} time(s) on its own`
|
|
3899
|
-
: `"${task.title}" ended ${outcome.status} after being carried on ${autoContinued} time(s) on its own${autoContinued >= autoAllowed ? ` — limits.autoContinue (${autoAllowed}) reached` : ''}`,
|
|
3900
|
-
data: { times: autoContinued, of: autoAllowed, status: outcome.status },
|
|
3957
|
+
: `"${task.title}" ended ${outcome.status} after being carried on ${autoContinued} time(s) on its own${autoContinued >= autoAllowed() ? ` — limits.autoContinue (${autoAllowed()}) reached` : ''}`,
|
|
3958
|
+
data: { times: autoContinued, of: autoAllowed(), status: outcome.status },
|
|
3901
3959
|
});
|
|
3902
3960
|
}
|
|
3903
3961
|
if (retried > 0) {
|
|
@@ -3952,6 +4010,7 @@ export async function runSession(sessionId, deps) {
|
|
|
3952
4010
|
}
|
|
3953
4011
|
}
|
|
3954
4012
|
finally {
|
|
4013
|
+
unwindow();
|
|
3955
4014
|
// No message at work: a window closed from now on is the next message's to open. One being opened again is let finish.
|
|
3956
4015
|
await transport?.releaseWindow?.().catch(() => undefined);
|
|
3957
4016
|
// A borrowed window belongs to whoever opened it and stays open for the next session.
|