copilot-operator 0.1.92 → 0.1.94

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.
Files changed (53) hide show
  1. package/README.md +640 -625
  2. package/dist/src/api/operator.controller.js +26 -0
  3. package/dist/src/api/operator.service.js +117 -25
  4. package/dist/src/exec/readOnly.js +27 -2
  5. package/dist/src/orchestrator/kerriganRunner.js +9 -2
  6. package/dist/src/orchestrator/taskRunner.js +14 -3
  7. package/dist/src/plan/kerrigan.js +263 -243
  8. package/dist/src/plan/systemGuide.js +125 -85
  9. package/dist/src/session/chatbotFile.js +117 -0
  10. package/dist/src/session/compose.js +13 -0
  11. package/dist/src/session/locatorFailures.js +8 -5
  12. package/dist/src/transport/copilotTransport.js +94 -12
  13. package/dist/src/transport/locators.js +53 -0
  14. package/dist/src/transport/pageHtml.js +36 -2
  15. package/dist/src/vcs/newBranch.js +46 -0
  16. package/dist/web/404.html +2 -2
  17. package/dist/web/_next/static/chunks/1077.b7df9cb8ca810075.js +1 -0
  18. package/dist/web/_next/static/chunks/1548.417c17b63c371f00.js +1 -0
  19. package/dist/web/_next/static/chunks/2163.469367b8fbcc862d.js +1 -0
  20. package/dist/web/_next/static/chunks/714.72112704f3cb8127.js +1 -0
  21. package/dist/web/_next/static/chunks/{7220.260579c8dbfa2c30.js → 7220.8bd897c7ddfee701.js} +1 -1
  22. package/dist/web/_next/static/chunks/7921-25d1755799107ea7.js +1 -0
  23. package/dist/web/_next/static/chunks/8584.f87df7324303ab75.js +1 -0
  24. package/dist/web/_next/static/chunks/9067.67a7c7cf3b019b5c.js +1 -0
  25. package/dist/web/_next/static/chunks/9747.a87dbd4acd45e39d.js +1 -0
  26. package/dist/web/_next/static/chunks/app/layout-1b7d13f7b2efd008.js +1 -0
  27. package/dist/web/_next/static/chunks/app/{page-b71841852e6b9ff5.js → page-7eae1e8848525e1d.js} +1 -1
  28. package/dist/web/_next/static/chunks/app/settings/page-c92548f9c6318962.js +1 -0
  29. package/dist/web/_next/static/chunks/{webpack-abd1f09115b96456.js → webpack-91b2de9c3da6f8b9.js} +1 -1
  30. package/dist/web/_next/static/css/{6b92f118889ca88b.css → 523d11041085f836.css} +1 -1
  31. package/dist/web/defaults.html +2 -2
  32. package/dist/web/defaults.txt +8 -8
  33. package/dist/web/index.html +3 -3
  34. package/dist/web/index.txt +9 -9
  35. package/dist/web/queue.html +2 -2
  36. package/dist/web/queue.txt +9 -9
  37. package/dist/web/settings.html +2 -2
  38. package/dist/web/settings.txt +9 -9
  39. package/dist/web/system.html +2 -2
  40. package/dist/web/system.txt +9 -9
  41. package/package.json +2 -1
  42. package/dist/web/_next/static/chunks/1077.922b5f1492f6e0dd.js +0 -1
  43. package/dist/web/_next/static/chunks/1548.4a09f12e23d369ec.js +0 -1
  44. package/dist/web/_next/static/chunks/2163.14e7879a45ae9748.js +0 -1
  45. package/dist/web/_next/static/chunks/714.2daeede6dd07ee60.js +0 -1
  46. package/dist/web/_next/static/chunks/7921-1de1f08d23145c0d.js +0 -1
  47. package/dist/web/_next/static/chunks/8584.01e3a7f9f14f0b4f.js +0 -1
  48. package/dist/web/_next/static/chunks/9067.75d4fdcf47f62fd1.js +0 -1
  49. package/dist/web/_next/static/chunks/9747.f1bdfbefaba61f8b.js +0 -1
  50. package/dist/web/_next/static/chunks/app/layout-f5681fae8247797b.js +0 -1
  51. package/dist/web/_next/static/chunks/app/settings/page-7d343eecdd9c7500.js +0 -1
  52. /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_buildManifest.js +0 -0
  53. /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_ssgManifest.js +0 -0
@@ -202,6 +202,23 @@ let OperatorController = class OperatorController {
202
202
  failText(res, e);
203
203
  }
204
204
  }
205
+ /**
206
+ * The one file for a chatbot (2026-11-18): everything it needs to give the right locator, the piece of the page and
207
+ * the whole page included (see `session/chatbotFile.ts`). A download, like the HTML; `lang` is the language the
208
+ * chatbot is told to speak to the operator in.
209
+ */
210
+ async locatorFailureChatbotFile(key, lang, res) {
211
+ try {
212
+ const { fileName, content } = await this.ops.locatorFailureChatbotFile(key, typeof lang === 'string' ? lang.slice(0, 8) : undefined);
213
+ res.type('application/octet-stream');
214
+ res.setHeader('content-disposition', contentDisposition(fileName));
215
+ res.setHeader('x-content-type-options', 'nosniff');
216
+ res.send(Buffer.from(content, 'utf8'));
217
+ }
218
+ catch (e) {
219
+ failText(res, e);
220
+ }
221
+ }
205
222
  /**
206
223
  * "Check the locators" (2026-11-17): the Copilot window opened, each of the chat's locators looked for, and what each
207
224
  * found. Takes as long as the window takes to open, a sign-in included.
@@ -717,6 +734,15 @@ __decorate([
717
734
  __metadata("design:paramtypes", [String, Object]),
718
735
  __metadata("design:returntype", Promise)
719
736
  ], OperatorController.prototype, "locatorFailureHtml", null);
737
+ __decorate([
738
+ Get('locators/failures/:key/chatbot'),
739
+ __param(0, Param('key')),
740
+ __param(1, Query('lang')),
741
+ __param(2, Res()),
742
+ __metadata("design:type", Function),
743
+ __metadata("design:paramtypes", [String, Object, Object]),
744
+ __metadata("design:returntype", Promise)
745
+ ], OperatorController.prototype, "locatorFailureChatbotFile", null);
720
746
  __decorate([
721
747
  Post('locators/check'),
722
748
  __metadata("design:type", Function),
@@ -18,6 +18,7 @@ import { existsSync } from 'node:fs';
18
18
  import { isAbsolute, relative } from 'node:path';
19
19
  import { readFile as readFileText } from 'node:fs/promises';
20
20
  import { LocatorFailures } from '../session/locatorFailures.js';
21
+ import { chatbotFile } from '../session/chatbotFile.js';
21
22
  import { CHAT_LOCATOR_KEYS, locatorPrompt, resolveChatLocators } from '../transport/locators.js';
22
23
  import { LocatorMissing } from '../transport/copilotTransport.js';
23
24
  import { isStepKey, stepKey, stepPrompt } from '../transport/chatSteps.js';
@@ -97,7 +98,7 @@ import { sessionRoots } from '../exec/confinement.js';
97
98
  import { dirtyPolicy } from '../vcs/snapshot.js';
98
99
  import { runVcsPreflight } from '../vcs/runPreflight.js';
99
100
  import { inputSettings, normalisePatterns } from '../vcs/inputs.js';
100
- import { createNewBranch, planNewBranch } from '../vcs/newBranch.js';
101
+ import { createNewBranch, planNewBranch, setAsideUncommitted } from '../vcs/newBranch.js';
101
102
  import { commitAsOperator, identityOf, pushAsOperator, setIdentity, stageFiles, TrustedHooks } from '../vcs/operatorGit.js';
102
103
  import { askpassProgram, closePasswordWindows } from '../vcs/remoteAuth.js';
103
104
  import { planApprovedMessage, planReviseMessage } from '../orchestrator/planMode.js';
@@ -731,6 +732,10 @@ let OperatorService = class OperatorService {
731
732
  this.browser = holder;
732
733
  return { holder };
733
734
  }
735
+ /** Why a run of `sessionId` could not have the browser now, without taking it; null when it could. */
736
+ browserBusyFor(sessionId) {
737
+ return this.browser ? browserRefusal(this.browser, { kind: 'run', sessionId }) : null;
738
+ }
734
739
  releaseBrowser(holder) {
735
740
  if (this.browser === holder)
736
741
  this.browser = null;
@@ -898,6 +903,8 @@ let OperatorService = class OperatorService {
898
903
  const html = str(detail.html);
899
904
  const picture = str(detail.picture);
900
905
  const url = str(detail.url);
906
+ const piece = str(detail.piece);
907
+ const around = str(detail.around);
901
908
  void this.locatorFailures
902
909
  .record({
903
910
  key: key,
@@ -909,6 +916,7 @@ let OperatorService = class OperatorService {
909
916
  ...(html ? { html } : {}),
910
917
  ...(picture ? { picture } : {}),
911
918
  ...(url ? { url } : {}),
919
+ ...(piece ? { piece, ...(around ? { around } : {}) } : {}),
912
920
  })
913
921
  .catch(() => undefined);
914
922
  }
@@ -922,7 +930,7 @@ let OperatorService = class OperatorService {
922
930
  const inForce = resolveChatLocators(cfg.copilot.chatLocators).locators;
923
931
  // A step's (2026-11-17): changed when its locator is, or it is switched off, made not required, or gone.
924
932
  const steps = new Map(cfg.copilot.extraSteps.map((s) => [stepKey(s.id), s]));
925
- return (await this.locatorFailures.list()).map(({ html, picture: _picture, ...f }) => {
933
+ return (await this.locatorFailures.list()).map(({ html, picture: _picture, piece: _piece, around: _around, ...f }) => {
926
934
  const step = isStepKey(f.key) ? steps.get(f.key) : undefined;
927
935
  return {
928
936
  ...f,
@@ -938,19 +946,41 @@ let OperatorService = class OperatorService {
938
946
  const f = await this.locatorFailures.get(key);
939
947
  if (!f?.html)
940
948
  throw new Error(`No HTML is kept for the "${key}" locator.`);
949
+ const content = await this.keptFailureFile(key, f.html, 'HTML');
950
+ const stamp = f.at.replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
951
+ // A step's key holds a colon, which a Windows file name cannot.
952
+ return { fileName: `copilot-page-${key.replace(/[^\w-]/g, '-')}-${stamp}.html`, content };
953
+ }
954
+ /**
955
+ * The one file for a chatbot (operator, 2026-11-18: "everything in one file; the user takes it and sends it to the
956
+ * chat, and that is all"): what to do, the goal, what failed, the old locator, the piece of the page where the element
957
+ * most likely is, the whole page, and how to find it by hand when it is in neither. See `session/chatbotFile.ts`.
958
+ * Made from what is kept, also for a failure kept before the piece was (then without it).
959
+ */
960
+ async locatorFailureChatbotFile(key, lang) {
961
+ const f = await this.locatorFailures.get(key);
962
+ if (!f)
963
+ throw new Error(`No failure is kept for the "${key}" locator.`);
964
+ const page = f.html ? await this.keptFailureFile(key, f.html, 'HTML').catch(() => '') : '';
965
+ const piece = f.piece ? await this.keptFailureFile(key, f.piece, 'piece of HTML').catch(() => '') : '';
966
+ const cfg = await this.settings.load();
967
+ const step = isStepKey(f.key) ? cfg.copilot.extraSteps.find((s) => stepKey(s.id) === f.key) : undefined;
968
+ const content = chatbotFile({ failure: f, step, piece, page, ...(lang ? { lang } : {}) });
969
+ const stamp = f.at.replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
970
+ return { fileName: `for-chatbot-${key.replace(/[^\w-]/g, '-')}-${stamp}.txt`, content };
971
+ }
972
+ /** A file kept with a failure, read: only one in the bot's runs folder. */
973
+ async keptFailureFile(key, path, what) {
941
974
  const cfg = await this.settings.load();
942
975
  const runs = resolve(cfg.resolved.runsDir);
943
- const file = resolve(f.html);
976
+ const file = resolve(path);
944
977
  const inside = relative(runs, file);
945
978
  if (!inside || inside.startsWith('..') || isAbsolute(inside)) {
946
- throw new Error(`The HTML kept for the "${key}" locator is not in the bot's runs folder.`);
979
+ throw new Error(`The ${what} kept for the "${key}" locator is not in the bot's runs folder.`);
947
980
  }
948
- const content = await readFileText(file, 'utf8').catch(() => {
949
- throw new Error(`The HTML kept for the "${key}" locator is gone (${file}).`);
981
+ return await readFileText(file, 'utf8').catch(() => {
982
+ throw new Error(`The ${what} kept for the "${key}" locator is gone (${file}).`);
950
983
  });
951
- const stamp = f.at.replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
952
- // A step's key holds a colon, which a Windows file name cannot.
953
- return { fileName: `copilot-page-${key.replace(/[^\w-]/g, '-')}-${stamp}.html`, content };
954
984
  }
955
985
  async startFailureReport(id) {
956
986
  await this.init();
@@ -1626,11 +1656,17 @@ let OperatorService = class OperatorService {
1626
1656
  }
1627
1657
  throw new Error('Kerrigan is at work with this chat: write to her conversation, or Stop her first.');
1628
1658
  }
1629
- if (inFlight && this.running.has(session.id)) {
1659
+ /*
1660
+ * While the run starts — the window opening, the sign-in, the model's card — its message is still queued (2026-11-18:
1661
+ * "Add to it" then made a message of its own, refused to start and left waiting). The note goes with that message,
1662
+ * which takes the notes not sent yet with its opening.
1663
+ */
1664
+ const atWork = inFlight ?? (this.running.has(session.id) ? session.tasks.find((t) => t.status === 'queued') : undefined);
1665
+ if (atWork && this.running.has(session.id)) {
1630
1666
  if (skill)
1631
1667
  throw new Error(`A skill goes with a new message, and this one would be a note to the message at work. Send /${skill.name} when it has finished.`);
1632
- await this.addTaskNote(session.id, inFlight.id, text);
1633
- return { threadId: session.id, taskId: inFlight.id, noted: true, needsStart: false };
1668
+ await this.addTaskNote(session.id, atWork.id, text);
1669
+ return { threadId: session.id, taskId: atWork.id, noted: true, needsStart: false };
1634
1670
  }
1635
1671
  }
1636
1672
  else {
@@ -1706,15 +1742,19 @@ let OperatorService = class OperatorService {
1706
1742
  });
1707
1743
  }
1708
1744
  // After going back, the conversation is told with this message: it still holds what was undone.
1709
- const pending = (await this.store.getSession(session.id))?.rewindNote;
1710
- if (pending) {
1711
- await this.store.addTaskNote(session.id, task.id, pending);
1712
- await this.store.updateSession(session.id, (s) => {
1713
- s.rewindNote = undefined;
1714
- });
1715
- }
1745
+ await this.moveRewindNote(session.id, task.id);
1716
1746
  return { threadId: session.id, taskId: task.id, needsStart: false };
1717
1747
  }
1748
+ /** What going back undid, told to the conversation with the next message that goes to it: a new one, or one carried on. */
1749
+ async moveRewindNote(sessionId, taskId) {
1750
+ const pending = (await this.store.getSession(sessionId))?.rewindNote;
1751
+ if (!pending)
1752
+ return;
1753
+ await this.store.addTaskNote(sessionId, taskId, pending);
1754
+ await this.store.updateSession(sessionId, (s) => {
1755
+ s.rewindNote = undefined;
1756
+ });
1757
+ }
1718
1758
  // --- the queue of tasks (2026-10-24) ----------------------------------------------------------------
1719
1759
  //
1720
1760
  // Tasks written beforehand, each run in a new chat on its own model while nobody watches; one that failed takes
@@ -2014,11 +2054,13 @@ let OperatorService = class OperatorService {
2014
2054
  throw new Error('That task is not waiting for an answer.');
2015
2055
  const s = await this.store.getSession(item.sessionId);
2016
2056
  const task = s?.tasks.find((t) => t.parked && !t.parked.answer);
2017
- if (!s || !task?.parked)
2018
- throw new Error('What that task waited for is not on its record any more; run it again.');
2057
+ // Stopped whatever its record says (2026-11-18): a Stop that failed with the record gone left the task, and the ones
2058
+ // that depend on it, waiting for good.
2019
2059
  if (input?.stop === true) {
2020
2060
  return await this.withBusy(await this.changeQueue((x) => this.setQueueItem(x, itemId, { status: 'stopped', why: 'stopped by the operator at its card', waitsFor: undefined })));
2021
2061
  }
2062
+ if (!s || !task?.parked)
2063
+ throw new Error('What that task waited for is not on its record any more; run it again.');
2022
2064
  const answer = parkedAnswerFrom(task.parked, input);
2023
2065
  if ('problem' in answer)
2024
2066
  throw new Error(answer.problem);
@@ -2149,6 +2191,25 @@ let OperatorService = class OperatorService {
2149
2191
  }
2150
2192
  await this.changeQueue((x) => this.setQueueItem(x, item.id, { sessionId }));
2151
2193
  }
2194
+ /*
2195
+ * On a branch of its own, in a folder another task left changes in (2026-11-18): those are put aside, kept whole on a
2196
+ * branch of their own and never pushed, as "New branch from main" puts them aside — or the task is refused for them,
2197
+ * and so is every task that depends on it, in a queue nobody is watching. Left alone when the folder is already on
2198
+ * this task's own branch: what is there is its own work, carried on.
2199
+ */
2200
+ const runOn = (await this.store.getSession(sessionId))?.vcs;
2201
+ if (ws.isRepo && runOn?.enabled && runOn.startFrom === 'existing-branch' && runOn.existingBranch) {
2202
+ const onNow = (await git(ws.dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']).catch(() => null))?.stdout || null;
2203
+ if (onNow !== runOn.existingBranch) {
2204
+ const aside = await setAsideUncommitted(ws.dir, `the queue's task "${itemTitle(item)}" works on its own branch ${runOn.existingBranch}, and the folder held changes left on ${onNow ?? 'a detached HEAD'}`);
2205
+ if (aside && 'problem' in aside)
2206
+ return { status: 'failed', why: `what was not committed in the folder could not be put aside before it: ${aside.problem}`, sessionId };
2207
+ if (aside) {
2208
+ this.bus.publish({ sessionId, type: 'queue-set-aside', level: 'warn',
2209
+ 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` });
2210
+ }
2211
+ }
2212
+ }
2152
2213
  /*
2153
2214
  * A message of the chat sent meanwhile has the browser: this one starts after it, never refused for it. The browser
2154
2215
  * is looked at and taken in the same moment — `start` takes it before it awaits anything.
@@ -2545,6 +2606,10 @@ let OperatorService = class OperatorService {
2545
2606
  const last = sub.attempts?.at(-1);
2546
2607
  if (last?.status === 'done')
2547
2608
  throw new Error(`Subtask ${n} was done; it is not done again.`);
2609
+ // The browser first, as for Continue (2026-11-18): nothing changes when it is not free.
2610
+ const busy = this.browserBusyFor(threadId);
2611
+ if (busy)
2612
+ throw new Error(busy);
2548
2613
  await this.store.rerunTask(threadId, taskId, {}, { fromAttempt: task.attempt ?? 1, stoppedBecause: task.reason, how: 'stopped', retrySubtask: { n, ...(fresh ? { fresh: true } : {}) } });
2549
2614
  const cfg = await this.settings.load();
2550
2615
  return await this.start(threadId, cfg.execution.mode);
@@ -2571,12 +2636,31 @@ let OperatorService = class OperatorService {
2571
2636
  throw new Error('That message is not in this conversation.');
2572
2637
  if (session.tasks.at(-1)?.id !== taskId)
2573
2638
  throw new Error('Only the last message of a conversation is carried on: the conversation has gone on past this one.');
2639
+ /*
2640
+ * The browser first (2026-11-18): the message was put back on the queue and then refused the browser — another
2641
+ * conversation, the queue, a read of the models had it — and was left "waiting to start", with no Continue and only
2642
+ * "Go back" under it. Now nothing changes when the browser is not free.
2643
+ */
2644
+ // 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
+ if (task.parked && !task.parked.answer)
2646
+ throw new Error('This message waits for an answer on its card in the queue: answer it there, and the queue carries it on.');
2647
+ const busy = this.browserBusyFor(threadId);
2648
+ if (busy)
2649
+ throw new Error(busy);
2650
+ const cfg = await this.settings.load();
2651
+ /*
2652
+ * A message never sent (2026-11-18): stopped while the window opened, the sign-in was awaited or the model chosen, its
2653
+ * start refused, or the bot closed first. It is sent now as it is: not "carried on", which Copilot never saw begin.
2654
+ */
2655
+ if (task.status === 'queued')
2656
+ return await this.start(threadId, cfg.execution.mode);
2574
2657
  if (!isContinuable(task)) {
2575
2658
  throw new Error(task.status === 'done' ? 'This message is done.' : 'Only a message that stopped before it was done is carried on; write the next message instead.');
2576
2659
  }
2577
- const cfg = await this.settings.load();
2578
2660
  const stoppedAt = task.status === 'aborted' && !task.interruption && task.runId ? await readInterruption(join(cfg.resolved.runsDir, task.runId)).catch(() => null) : null;
2579
2661
  const queued = await this.store.continueTask(threadId, taskId, stoppedAt);
2662
+ // After going back, the conversation is told with the message that carries on, as with a new one (2026-11-18).
2663
+ await this.moveRewindNote(threadId, taskId);
2580
2664
  await appendSessionLog(cfg.resolved.runsDir, threadId, {
2581
2665
  type: 'continue',
2582
2666
  message: `"${queued.title}" carried on as attempt ${queued.attempt ?? 1}, from where it stopped: ${task.reason ?? task.status}`,
@@ -2702,6 +2786,14 @@ let OperatorService = class OperatorService {
2702
2786
  w.resolve(decision);
2703
2787
  this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
2704
2788
  message: `step ${w.approval.stepId}: ${action}`, data: { approvalId, action } });
2789
+ /*
2790
+ * "Stop" on the card that asks for the model to be chosen by hand (2026-11-18): the run stops, as the chat's own Stop
2791
+ * stops it — nothing failed, the operator stopped. Only the card was answered before: the work then ended "failed"
2792
+ * with two chats or Kerrigan, with no Continue, and a single chat was said as a start that did not happen. On the card
2793
+ * of a model the bot could not choose, a failure it is, and is said with what the page offers.
2794
+ */
2795
+ if (w.approval.model?.manual && action === 'abort')
2796
+ void this.stop(w.approval.sessionId).catch(() => undefined);
2705
2797
  return { ok: true };
2706
2798
  }
2707
2799
  /**
@@ -2876,7 +2968,7 @@ let OperatorService = class OperatorService {
2876
2968
  'use-current-branch': `Use the current branch instead of ${g.baseBranch ?? 'the base branch'}`,
2877
2969
  'allow-snapshot': 'Take uncommitted changes as a starting snapshot',
2878
2970
  };
2879
- note('snapshot-approval-required', `${g.repoDir}: nothing runs until one of these is pressed under "Prepare version control for this run" on the Sessions page: ${fixes.map((f) => `"${label[f] ?? f}"`).join(', ')}`, { repoDir: g.repoDir, actions: fixes }, ids, 'warn');
2971
+ note('snapshot-approval-required', `${g.repoDir}: nothing runs until what is not committed there is dealt with. Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.`, { repoDir: g.repoDir, actions: fixes }, ids, 'warn');
2880
2972
  }
2881
2973
  }
2882
2974
  const open = groups.filter((g) => !g.ready);
@@ -2901,7 +2993,7 @@ let OperatorService = class OperatorService {
2901
2993
  ? [
2902
2994
  'Version control is not ready for this run, so nothing was opened or sent. ' +
2903
2995
  open.map((g) => `${g.repoDir}: ${g.problem ?? 'it needs your approval'}`).join(' ') +
2904
- ' Fix it under "Prepare version control for this run" on the Sessions page.',
2996
+ ' Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.',
2905
2997
  ]
2906
2998
  : []),
2907
2999
  ...(contradictions.length > 0 ? [`${open.length > 0 ? '' : 'Nothing was opened or sent. '}${contradictions.join(' ')}`] : []),
@@ -3042,7 +3134,7 @@ let OperatorService = class OperatorService {
3042
3134
  return null;
3043
3135
  // The panel is named only where it has a fix to offer: for a chain waiting on its predecessor the remedy is that one's Continue (live run 2026-10-04).
3044
3136
  const panel = group.actions.some((a) => a.available && a.id !== 'review-inputs');
3045
- return `Version control is not ready for "${session.name}", so it did not start and its tasks stay queued: ${group.problem ?? 'it needs your approval'}${panel ? ' Fix it under "Prepare version control for this run" on the Sessions page.' : ''}`;
3137
+ return `Version control is not ready for "${session.name}", so it did not start and its tasks stay queued: ${group.problem ?? 'it needs your approval'}${panel ? ' Commit what is not committed in the folder (the Git view), or put it aside ("⎇ New branch from main" → "Put them aside"), then run it again.' : ''}`;
3046
3138
  }
3047
3139
  /** Recorded in the run's log just before the browser is opened for it: see `runPreflight`. */
3048
3140
  async browserRequested(runId, sessionIds) {
@@ -99,6 +99,9 @@ const AZ_SECRET = /(?:^|-)(?:keys?|credentials?|secrets?|passwords?|tokens?|sas|
99
99
  const AZ_READ = /^(?:list|show|query|exists|wait|version|what-if|(?:list|show|get)-[a-z0-9-]+|check-name(?:-availability)?)$/;
100
100
  /** The verbs that change something, in Azure or in az's own setup; and the ones named after them (`create-for-rbac`). */
101
101
  const AZ_WRITE = /^(?:create|delete|update|set|unset|add|remove|start|stop|restart|reboot|deploy|redeploy|reimage|deallocate|generalize|capture|resize|scale|swap|assign|unassign|purge|recover|restore|backup|renew|regenerate|rotate|reset|import|upload|sync|move|lock|unlock|enable|disable|approve|reject|attach|detach|connect|disconnect|apply|cancel|abort|run|invoke|execute|install|uninstall|register|unregister|grant|revoke|push|tag|untag|migrate|upgrade|failover|promote|convert|link|unlink|clear|flush|cordon|drain|retry|rerun|trigger|publish|release|merge|close|reopen|accept|archive|unarchive|schedule|power-off|rollback|repair|refresh|replace|rename|copy|patch|put|post|send|mount|unmount|activate|deactivate|pause|resume|suspend|terminate|kill)(?:-[a-z0-9-]+)?$/;
102
+ /** az's own options, which it takes anywhere, before its command too: alone, and with a value. */
103
+ const AZ_GLOBAL_FLAGS = new Set(['--debug', '--verbose', '--only-show-errors']);
104
+ const AZ_GLOBAL_WITH_VALUE = new Set(['--output', '-o', '--query', '--subscription']);
102
105
  /**
103
106
  * One `az` invocation. Its command is the group path and the verb at its end, the words before the first option:
104
107
  * `az storage account list --query ...` is `storage account list`, read by `list`. `--help` anywhere only prints help.
@@ -106,15 +109,37 @@ const AZ_WRITE = /^(?:create|delete|update|set|unset|add|remove|start|stop|resta
106
109
  function azReading(args) {
107
110
  if (args.some((a) => !a.dynamic && /^(?:--help|-h)$/i.test(a.literal)))
108
111
  return { kind: 'reads' };
112
+ /*
113
+ * az's own options may come before its command (2026-11-18: `az -o none group delete -n rg --yes` was read as `az`
114
+ * alone, "nothing but the version", and ran with no card where az is read only). Those are passed over, with the value
115
+ * of one that takes a value; any other option there is not read as anything, and is put to the operator.
116
+ */
117
+ let i = 0;
118
+ while (i < args.length) {
119
+ const a = args[i];
120
+ if (a.dynamic)
121
+ return { kind: 'unclear', why: 'a word of the az command is known only when it runs' };
122
+ if (!a.literal.startsWith('-'))
123
+ break;
124
+ const name = a.literal.split('=')[0].toLowerCase();
125
+ if (name === '--version' && args.length === 1)
126
+ return { kind: 'reads' };
127
+ if (AZ_GLOBAL_FLAGS.has(name))
128
+ i += 1;
129
+ else if (AZ_GLOBAL_WITH_VALUE.has(name))
130
+ i += a.literal.includes('=') ? 1 : 2;
131
+ else
132
+ return { kind: 'unclear', why: `az's option ${a.literal} comes before its command, and is not one of az's own options this check knows` };
133
+ }
109
134
  const path = [];
110
- for (const a of args) {
135
+ for (const a of args.slice(i)) {
111
136
  if (a.dynamic)
112
137
  return { kind: 'unclear', why: 'a word of the az command is known only when it runs' };
113
138
  if (a.literal.startsWith('-'))
114
139
  break;
115
140
  path.push(a.literal.toLowerCase());
116
141
  }
117
- // `az`, `az --version`: nothing but the version or the help.
142
+ // `az`, `az --version`, `az -o table`: nothing but the version or the help.
118
143
  if (path.length === 0)
119
144
  return { kind: 'reads' };
120
145
  const p = path.join(' ');
@@ -161,7 +161,13 @@ export async function runKerriganTask(transport, session, task, deps) {
161
161
  sink.event('acting', acting, `at work now: ${actor === 'kerrigan' ? 'Kerrigan' : actor}`);
162
162
  };
163
163
  const maxSends = () => Math.max(1, cfg.limits.maxKerriganSends ?? 6);
164
- const k = { rounds: [], sent: 0, maxSends: maxSends(), messages: 0, chats: [] };
164
+ /*
165
+ * Carried on (2026-11-18): the attempt before, of this same message — its chats, and how many messages she sent. Each
166
+ * attempt started from none, so "same" was refused ("no chat of yours is there yet"), the chat she was directing was
167
+ * lost with its conversation, and the most messages she may send began again.
168
+ */
169
+ const before = task.continuing ? task.attempts?.at(-1)?.kerrigan : undefined;
170
+ const k = { rounds: [], sent: before?.sent ?? 0, maxSends: maxSends(), messages: 0, chats: [...(before?.chats ?? [])] };
165
171
  const save = async () => {
166
172
  const copy = JSON.parse(JSON.stringify(k));
167
173
  await setTask((t) => {
@@ -320,7 +326,8 @@ export async function runKerriganTask(transport, session, task, deps) {
320
326
  let lastChat = null;
321
327
  let lastTitle = '';
322
328
  {
323
- const earlier = [...session.tasks].reverse().find((x) => x.id !== task.id && (x.kerrigan?.chats.length ?? 0) > 0);
329
+ // This message's own attempt before, when it is carried on; else the last message of hers that sent to a chat.
330
+ const earlier = (before?.chats.length ?? 0) > 0 ? { kerrigan: before } : [...session.tasks].reverse().find((x) => x.id !== task.id && (x.kerrigan?.chats.length ?? 0) > 0);
324
331
  const id = earlier?.kerrigan?.chats.at(-1);
325
332
  const found = id ? await store.getSession(id) : null;
326
333
  if (found) {
@@ -825,6 +825,12 @@ signal) {
825
825
  const hand = wanted && buttonShows(shown, wanted)
826
826
  ? { result: { ok: true, current: wanted, by: 'already' }, goOnAsItIs: false }
827
827
  : await withOperatorHand(transport, wanted, { ok: false, current: shown, reason: why }, hooks, session.id, bus, true, asks);
828
+ /*
829
+ * Stopped on the card (2026-11-18): the run stops, as the card's "Stop" says — with a model named too, which asked
830
+ * the operator a second time ("could not choose the model") before.
831
+ */
832
+ if ('stopped' in hand && hand.stopped)
833
+ return { refused: 'The model was to be chosen by hand, and the operator stopped the run. Nothing was sent.' };
828
834
  if (!wanted) {
829
835
  const now = await transport.currentModel().catch(() => null);
830
836
  if (hand.result.ok || hand.goOnAsItIs) {
@@ -938,7 +944,7 @@ opts = {}) {
938
944
  actor: opts.actor ?? (opts.review ? 'review' : opts.role ?? 'worker'),
939
945
  });
940
946
  if (answer === 'stop')
941
- return { result, goOnAsItIs: false };
947
+ return { result, goOnAsItIs: false, stopped: true };
942
948
  if (answer === 'continue') {
943
949
  bus.publish({ sessionId, type: 'model-help-continue', level: 'warn', message: `the operator chose to go on with the model the chat is on ("${shown ?? 'unknown'}")${wanted ? `, not "${wanted}"` : ''}`, data: { asked: wanted, shown } });
944
950
  return { result: { ok: false, current: shown, reason: `the operator chose to go on with "${shown ?? 'unknown'}"` }, goOnAsItIs: true };
@@ -1792,8 +1798,13 @@ export async function runTask(transport, session, task, deps) {
1792
1798
  * the way a read-only task is wherever the task has a branch of its own.
1793
1799
  */
1794
1800
  const planMode = session.planMode ?? cfg.execution.planMode ?? 'off';
1795
- // A continued task does not plan again, unless its plan was sent back while the queue had it set aside (2026-10-26).
1796
- let planning = planMode !== 'off' && (!task.continuing || task.continuing.replan === true);
1801
+ /*
1802
+ * A continued task does not plan again when a plan was approved for it — it carries on from that plan — nor when it
1803
+ * was sent back while the queue had it set aside it does (2026-10-26). One carried on with no plan approved at all
1804
+ * plans first (2026-11-18: a Stop at the plan's card, a restart, or a limit while planning, then "Continue" or the
1805
+ * carrying on after a limit, went straight to the work, and files changed with no plan approved).
1806
+ */
1807
+ let planning = planMode !== 'off' && (!task.continuing || task.continuing.replan === true || !approvedPlanOf(task));
1797
1808
  await actingNow(planning ? 'plan' : 'worker');
1798
1809
  const planEnforced = planning && onOwnBranch;
1799
1810
  let planVersion = 0;