copilot-operator 0.1.85 → 0.1.90

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 (58) hide show
  1. package/dist/src/api/operator.controller.js +89 -3
  2. package/dist/src/api/operator.service.js +200 -2
  3. package/dist/src/api/server.js +5 -1
  4. package/dist/src/cli.js +6 -0
  5. package/dist/src/config/live.js +1 -1
  6. package/dist/src/config/schema.js +27 -0
  7. package/dist/src/orchestrator/kerriganRunner.js +3 -1
  8. package/dist/src/orchestrator/leadRunner.js +3 -1
  9. package/dist/src/orchestrator/taskRunner.js +64 -32
  10. package/dist/src/plan/systemGuide.js +193 -4
  11. package/dist/src/session/compose.js +5 -1
  12. package/dist/src/session/locatorFailures.js +55 -0
  13. package/dist/src/transport/chatTransport.js +6 -2
  14. package/dist/src/transport/copilotTransport.js +519 -59
  15. package/dist/src/transport/keptWindow.js +250 -0
  16. package/dist/src/transport/locators.js +140 -9
  17. package/dist/src/transport/pageHtml.js +62 -0
  18. package/dist/web/404.html +2 -2
  19. package/dist/web/_next/static/chunks/1077.1cc6d439e3dd0fa9.js +1 -0
  20. package/dist/web/_next/static/chunks/1548.3de9dc874e47558e.js +1 -0
  21. package/dist/web/_next/static/chunks/2163.66458fb9c54fb52d.js +1 -0
  22. package/dist/web/_next/static/chunks/714.cffed2b87154be0f.js +1 -0
  23. package/dist/web/_next/static/chunks/7220.30b6a3e1bd41e51a.js +1 -0
  24. package/dist/web/_next/static/chunks/7921-d3a4a261e08950e0.js +1 -0
  25. package/dist/web/_next/static/chunks/8584.36422ed19d6c43e9.js +1 -0
  26. package/dist/web/_next/static/chunks/9067.e579f97591576de2.js +1 -0
  27. package/dist/web/_next/static/chunks/9747.11247f0e21542f6d.js +1 -0
  28. package/dist/web/_next/static/chunks/app/layout-7b5fa7c74ecd6939.js +1 -0
  29. package/dist/web/_next/static/chunks/app/page-b71841852e6b9ff5.js +1 -0
  30. package/dist/web/_next/static/chunks/app/queue/{page-317151444eda8115.js → page-7909ba7c9e3d4c2d.js} +1 -1
  31. package/dist/web/_next/static/chunks/app/settings/page-7651920337bbb580.js +1 -0
  32. package/dist/web/_next/static/chunks/{webpack-13ccb80d7b7094ca.js → webpack-78ec62098b09e4a0.js} +1 -1
  33. package/dist/web/_next/static/css/{6e2b8656501f0dd7.css → d74aa18c98dacdb4.css} +1 -1
  34. package/dist/web/defaults.html +2 -2
  35. package/dist/web/defaults.txt +8 -8
  36. package/dist/web/index.html +3 -3
  37. package/dist/web/index.txt +9 -9
  38. package/dist/web/queue.html +2 -2
  39. package/dist/web/queue.txt +9 -9
  40. package/dist/web/settings.html +2 -2
  41. package/dist/web/settings.txt +9 -9
  42. package/dist/web/system.html +2 -2
  43. package/dist/web/system.txt +9 -9
  44. package/package.json +4 -2
  45. package/dist/web/_next/static/chunks/1077.06fe73b2c16f8f49.js +0 -1
  46. package/dist/web/_next/static/chunks/1548.b38c5d8d00ab2a72.js +0 -1
  47. package/dist/web/_next/static/chunks/2163.ba933c9a506302ca.js +0 -1
  48. package/dist/web/_next/static/chunks/714.575273a189d030fe.js +0 -1
  49. package/dist/web/_next/static/chunks/7220.988dfd28e00f407c.js +0 -1
  50. package/dist/web/_next/static/chunks/7921-65dd56d87144bd44.js +0 -1
  51. package/dist/web/_next/static/chunks/8584.2221587201bc2fa2.js +0 -1
  52. package/dist/web/_next/static/chunks/9067.8d94a08830c3d1da.js +0 -1
  53. package/dist/web/_next/static/chunks/9747.8671194406acd839.js +0 -1
  54. package/dist/web/_next/static/chunks/app/layout-127e5af1ebf21876.js +0 -1
  55. package/dist/web/_next/static/chunks/app/page-76139370c7ca3715.js +0 -1
  56. package/dist/web/_next/static/chunks/app/settings/page-116da78c83f0c5c9.js +0 -1
  57. /package/dist/web/_next/static/{aCQe1FDhYTj4zGeI5ueVq → 3VkK1sxEugkae88HSFR-i}/_buildManifest.js +0 -0
  58. /package/dist/web/_next/static/{aCQe1FDhYTj4zGeI5ueVq → 3VkK1sxEugkae88HSFR-i}/_ssgManifest.js +0 -0
@@ -15,6 +15,7 @@ import { readFile, mkdir, writeFile, appendFile } from 'node:fs/promises';
15
15
  import { basename, join, resolve } from 'node:path';
16
16
  import { buttonShows, normModel } from '../transport/modelMatch.js';
17
17
  import { ChatLost, createTransport, isReplyTimeout, WindowClosed } from '../transport/chatTransport.js';
18
+ import { CLOSED_NOT_REOPENED } from '../transport/keptWindow.js';
18
19
  import { buildChatName, chatCode, loadPointer, savePointer } from '../transport/chatSession.js';
19
20
  import { parseReply, formatErrorMessage, findLikelyDamage, damageGuidance } from '../protocol/parser.js';
20
21
  import { resolveDeviations, describeDeviations, mergeDisputes, describeDisputes } from '../protocol/replySchema.js';
@@ -100,7 +101,8 @@ async function followPageModels(which, wanted, result, session, store, hooks, fr
100
101
  else {
101
102
  await hooks?.renamedDefault?.(which, wanted, result.matched).catch(() => undefined);
102
103
  }
103
- return `"${wanted}" is no longer offered under that name; the page offers it as "${result.matched}", which was chosen, and ${own ? "the session's" : 'Settings\''} ${which === 'model' ? 'model' : 'review model'} now says so`;
104
+ const what = which === 'review' ? 'review model' : own ? 'model' : which === 'lead' ? 'model for the lead' : which === 'kerrigan' ? 'model for Kerrigan' : 'model';
105
+ return `"${wanted}" is no longer offered under that name; the page offers it as "${result.matched}", which was chosen, and ${own ? "the session's" : 'Settings\''} ${what} now says so`;
104
106
  }
105
107
  /** Why a task that was reported as done is being closed as failed. */
106
108
  function checksFailedReason(outcomes) {
@@ -455,8 +457,13 @@ export function speakFor(transport, sessionId, opts = {}) {
455
457
  speaker.alone = true;
456
458
  }
457
459
  /** The model menu's locators and its step pictures, as Settings have them (2026-10-24), for every window that picks a model. */
460
+ /** 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). */
458
461
  export function pickerOptions(cfg) {
459
- return { ...(cfg.copilot.pickerLocators ? { pickerLocators: cfg.copilot.pickerLocators } : {}), ...(cfg.copilot.pickerSteps ? { modelStepShots: true } : {}) };
462
+ return {
463
+ ...(cfg.copilot.pickerLocators ? { pickerLocators: cfg.copilot.pickerLocators } : {}),
464
+ ...(cfg.copilot.chatLocators ? { chatLocators: cfg.copilot.chatLocators } : {}),
465
+ ...(cfg.copilot.pickerSteps ? { modelStepShots: true } : {}),
466
+ };
460
467
  }
461
468
  export async function openBrowser(cfg, bus, transportDir, sessionId,
462
469
  /** The run's Stop: a sign-in still awaited ends with it. */
@@ -482,17 +489,28 @@ signal) {
482
489
  'error-banner': 'The chat reported a transient error; reloading the page.',
483
490
  'reply-files-ignored': 'The reply came with a file attached. It was not downloaded and will not be run: the runner takes only the text of a reply.',
484
491
  'model-menu-stuck': 'The model menu would not close — Escape, the menu button and a click outside all left it open. Close it in the Edge window; the run goes on.',
485
- 'window-closed': 'The Edge window was closed. A run in it stops; the next message opens a new one.',
492
+ 'window-closed': 'The Edge window was closed. While a message is at work it is opened again on its conversation, as many times as ' +
493
+ 'Settings allow (limits.reopenWindow); between messages, the next message opens a new one.',
494
+ // Opened again under the work (2026-11-13): see transport/keptWindow.ts.
495
+ 'window-reopening': `Opening Edge again on this conversation (${String(detail?.time ?? '?')} of ${String(detail?.of ?? '?')} for this message), so the work goes on there.`,
496
+ 'window-reopened': 'Back on this conversation in a new Edge window; the work goes on from where it was.',
497
+ 'window-not-reopened': `The window was not opened again: ${String(detail?.reason ?? '')}`,
498
+ 'reply-asked-again': 'The chat was writing its answer when the window was closed; it was asked to send that answer again.',
499
+ 'message-sent-again': 'The window was closed while a message was being sent; it was sent again, saying it is a copy.',
486
500
  // The window left its conversation while the work waited (2026-11-09): put back before anything is sent.
487
501
  'chat-left': `The Copilot window is no longer on this conversation (it shows ${String(detail?.found ?? 'another page')}). Going back to it before anything is sent.`,
488
502
  'chat-returned': `Back on this conversation${detail?.signedIn ? ', after the sign-in' : ''}${detail?.by === 'name' ? ', found by its name in the sidebar' : ''}. The work goes on there.`,
489
503
  'chat-lost': 'The conversation could not be opened again, by its address or by its name. Nothing was sent, and nothing went into another chat.',
504
+ // A locator of the chat that found nothing (2026-11-17): which, and where Settings has it; the API keeps it for the red field.
505
+ 'locator-missing': `Not found on Copilot's page: the "${String(detail?.key ?? '')}" locator (${String(detail?.locator ?? '')}) found nothing ${String(detail?.why ?? '')}. ${detail?.stopped === false ? 'The work goes on without it. ' : ''}Settings → "The chat's locators" shows it in red, with the page's HTML for a chatbot to find the right one in.`,
506
+ // Copilot showed another of its pages, its home page, instead of the chat (2026-11-17): the chat opened from it.
507
+ 'chat-page-elsewhere': `Copilot showed its page ${String(detail?.found ?? '')} instead of the chat; opening the chat ${detail?.by === 'link' ? "by the page's own link to it" : `at ${String(detail?.to ?? '')}`}.`,
490
508
  };
491
509
  for (const id of new Set(speaker.alone ? [speaker.id] : [speaker.id, sessionId])) {
492
510
  bus.publish({
493
511
  sessionId: id,
494
512
  type: `browser:${event}`,
495
- level: event === 'chat-lost' ? 'error' : event === 'verification-required' || event === 'reply-files-ignored' || event === 'model-menu-stuck' || event === 'chat-left' ? 'warn' : 'info',
513
+ level: event === 'chat-lost' || (event === 'locator-missing' && detail?.stopped !== false) ? 'error' : event === 'locator-missing' ? 'warn' : ['verification-required', 'reply-files-ignored', 'model-menu-stuck', 'chat-left', 'window-closed', 'window-not-reopened', 'reply-asked-again', 'message-sent-again'].includes(event) ? 'warn' : 'info',
496
514
  // An event with no sentence of its own is named, not said as "undefined".
497
515
  message: spoken[event] ?? event.replace(/-/g, ' '),
498
516
  data: detail,
@@ -702,28 +720,25 @@ export async function openSessionTransport(cfg, session, bus, runsDir, signal) {
702
720
  }
703
721
  return transport;
704
722
  }
723
+ /** Which part of Settings a session's conversation takes its model from. */
724
+ export function modelPartOf(session) {
725
+ return session.kerrigan ? 'kerrigan' : session.lead ? 'lead' : 'model';
726
+ }
705
727
  /**
706
- * Puts the conversation on the model the session asks for, once per run.
707
- *
708
- * Applied here rather than per task because the picker belongs to the conversation, and a
709
- * failure is reported rather than raised: a model that is out of quota or has been withdrawn
710
- * should not throw away a queue of tasks. The run continues on whatever the chat is actually
711
- * set to, and the session records that, so the register shows which model did the work rather
712
- * than which one was asked for.
713
- */
714
- /**
715
- * The models a session runs on: its own, or else the ones chosen in Settings at this moment.
716
- * A session gets a model of its own from the plan or from its own picker; one that has none
717
- * follows Settings, so a model chosen there after the session was made still reaches it.
718
- */
719
- /**
720
- * The models a session runs on, and where each came from.
721
- *
722
- * The operator's choice on the session's page or the run panel first; then Settings; the plan's last.
723
- * Settings used to come after any model the session held, and a plan imported with a "model" — written
724
- * by another chat, often a model the picker no longer had — overrode what the operator chose in Settings
725
- * on every run (operator's rule, 2026-10-06: what is set in Settings outranks the same thing in the JSON).
728
+ * Settings' model for a part, with what stands in for it when none is chosen there: Kerrigan's, else the lead's; the
729
+ * lead's, else the worker's. `setting` names the one the name comes from, so a model the page renamed is followed there.
726
730
  */
731
+ export function settingsModelOf(part, copilot) {
732
+ const own = (x) => (x ?? '').trim();
733
+ if (part === 'kerrigan' && own(copilot.defaultKerriganModel))
734
+ return { model: own(copilot.defaultKerriganModel), setting: 'kerrigan' };
735
+ if (part !== 'model' && own(copilot.defaultLeadModel))
736
+ return { model: own(copilot.defaultLeadModel), setting: 'lead' };
737
+ return { model: own(copilot.defaultModel), setting: 'model' };
738
+ }
739
+ function settingsModelFor(session, cfg) {
740
+ return settingsModelOf(modelPartOf(session), cfg.copilot).model;
741
+ }
727
742
  export function effectiveModels(session, cfg) {
728
743
  const pick = (own, source, settings) => own && source === 'operator' ? [own, 'session'] : settings ? [settings, 'settings'] : own ? [own, 'plan'] : ['', 'none'];
729
744
  // Set by hand in the Copilot window: no name is asked for, neither the session's nor the one in Settings.
@@ -731,9 +746,11 @@ export function effectiveModels(session, cfg) {
731
746
  * Settings' model for the conversation's part (2026-10-23): the lead's for the lead of two chats — the worker's when
732
747
  * none is chosen for the lead, as before there were two — else the worker's.
733
748
  */
734
- // Kerrigan directs as the lead does (2026-11-12): her conversation takes Settings' model for the lead.
735
- const directs = !!session.lead || !!session.kerrigan;
736
- const fromSettings = ((directs ? cfg.copilot.defaultLeadModel?.trim() || cfg.copilot.defaultModel : cfg.copilot.defaultModel) ?? '').trim();
749
+ /*
750
+ * Kerrigan's conversation (2026-11-13): Settings' model for Kerrigan; none chosen there, the lead's, as it was from
751
+ * 2026-11-12 when she directed as the lead does; none for the lead either, the worker's.
752
+ */
753
+ const fromSettings = settingsModelFor(session, cfg);
737
754
  const [model, modelFrom] = session.manualModel ? ['', 'none'] : pick((session.model ?? '').trim(), session.modelSource, fromSettings);
738
755
  const [reviewModel, reviewModelFrom] = pick((session.review?.model ?? '').trim(), session.reviewModelSource, (cfg.copilot.defaultReviewModel ?? '').trim());
739
756
  return { model, reviewModel, modelFrom, reviewModelFrom };
@@ -744,8 +761,12 @@ export function effectiveModels(session, cfg) {
744
761
  * model and has none from Settings either — its picker shows "by hand" for that, and what it shows is what happens.
745
762
  */
746
763
  export function modelByHand(session, cfg) {
747
- // Settings' "by hand" for the conversation's part (2026-10-23): the lead's has its own, absent as the worker's; Kerrigan's is the lead's.
748
- const settingsSay = session.lead || session.kerrigan ? (cfg.copilot.leadManualModel ?? cfg.copilot.manualModel) : cfg.copilot.manualModel;
764
+ /*
765
+ * Settings' "by hand" for the conversation's part (2026-10-23): the lead's has its own, absent as the worker's.
766
+ * Kerrigan's has her own since 2026-11-13, absent as the lead's.
767
+ */
768
+ const lead = cfg.copilot.leadManualModel ?? cfg.copilot.manualModel;
769
+ const settingsSay = session.kerrigan ? (cfg.copilot.kerriganManualModel ?? lead) : session.lead ? lead : cfg.copilot.manualModel;
749
770
  if (settingsSay || session.manualModel)
750
771
  return true;
751
772
  return session.kind === 'chat' && !effectiveModels(session, cfg).model;
@@ -829,7 +850,8 @@ signal) {
829
850
  const hand = await withOperatorHand(transport, wanted, result, hooks, session.id, bus, false, asks);
830
851
  result = hand.result;
831
852
  const goOnAsItIs = hand.goOnAsItIs;
832
- const renamed = await followPageModels(session.lead ? 'lead' : 'model', wanted, result, session, store, hooks, modelFrom);
853
+ // Followed in the setting the name came from: a part with none of its own takes another's (see `settingsModelOf`).
854
+ const renamed = await followPageModels(settingsModelOf(modelPartOf(session), cfg.copilot).setting, wanted, result, session, store, hooks, modelFrom);
833
855
  if (renamed)
834
856
  bus.publish({ sessionId: session.id, type: 'model-renamed', level: 'warn', message: renamed, data: { asked: wanted, chosen: result.matched } });
835
857
  bus.publish({
@@ -3559,8 +3581,10 @@ export async function runTask(transport, session, task, deps) {
3559
3581
  * Edge left a crash report, which says it was not them.
3560
3582
  */
3561
3583
  if (transport.closedOutside() && !(await transport.recentCrash().catch(() => null))) {
3562
- sink.event('window-closed', { error: message }, 'the browser window was closed; nothing more is sent', 'warn');
3563
- return await finish('aborted', 'the browser window was closed; nothing more was sent');
3584
+ // Why, as the kept window says it (2026-11-13): not opened again by Settings, past the times allowed, or not found.
3585
+ const why = e instanceof WindowClosed ? e.message : CLOSED_NOT_REOPENED;
3586
+ sink.event('window-closed', { error: message, reopened: transport.reopenedTimes?.() ?? 0 }, why, 'warn');
3587
+ return await finish('aborted', why);
3564
3588
  }
3565
3589
  sink.event('task-error', { error: message, stack: e.stack }, message, 'error');
3566
3590
  await transport.dumpFailure(log.path('failures'), 'crash').catch(() => undefined);
@@ -3673,6 +3697,12 @@ export async function runSession(sessionId, deps) {
3673
3697
  let task = session.tasks.find((t) => t.id === queuedTask.id);
3674
3698
  if (!task || task.status !== 'queued')
3675
3699
  continue;
3700
+ /*
3701
+ * The window, closed under this message, is opened again on its conversation and the work goes on there (operator,
3702
+ * 2026-11-13: "if I close the browser by accident, carry the task on from where it got to"), up to the times
3703
+ * Settings allow for one message — its runs again in a fresh chat and on its own after a limit included.
3704
+ */
3705
+ chat.holdWindow?.(cfg.limits.reopenWindow ?? 3, deps.signal);
3676
3706
  /*
3677
3707
  * A task taken from the queue was started by the operator, never by the retry loop below, which
3678
3708
  * runs its own. A fresh-retry mark on it is left from a retry that was queued and never ran —
@@ -3889,6 +3919,8 @@ export async function runSession(sessionId, deps) {
3889
3919
  }
3890
3920
  }
3891
3921
  finally {
3922
+ // No message at work: a window closed from now on is the next message's to open. One being opened again is let finish.
3923
+ await transport?.releaseWindow?.().catch(() => undefined);
3892
3924
  // A borrowed window belongs to whoever opened it and stays open for the next session.
3893
3925
  if (!borrowed) {
3894
3926
  // The chat's, still open, is kept for its next message; one the operator closed is let go of.
@@ -192,6 +192,45 @@ export const SYSTEM_GUIDE = [
192
192
  },
193
193
  ],
194
194
  },
195
+ {
196
+ headingKey: 'chatloc.failTitle',
197
+ en: 'The bot could not find "{name}" on Copilot\'s page; the work stopped',
198
+ bg: 'Ботът не намери „{name}“ в страницата на Copilot; работата спря',
199
+ controls: [
200
+ {
201
+ key: 'chatloc.fix',
202
+ kind: 'link',
203
+ en: 'Fix in Settings',
204
+ bg: 'Поправи в Settings',
205
+ doesEn: 'On every page, when a locator of the chat found nothing (2026-11-17): opens Settings → "The chat\'s locators" at that locator\'s field, in red, the cursor in it. A failure that stopped the work opens it once by itself.',
206
+ doesBg: 'На всяка страница, когато локатор на чата не е намерил нищо (2026-11-17): отваря Settings → „Локатори на чата“ на полето на този локатор, в червено, с курсора в него. Провал, спрял работата, го отваря веднъж сам.',
207
+ },
208
+ {
209
+ key: 'chatloc.html',
210
+ kind: 'link',
211
+ en: 'Download the HTML',
212
+ bg: 'Изтегли HTML',
213
+ doesEn: 'The page\'s HTML at the moment the locator found nothing, scripts, styles and the sidebar\'s conversation names taken out: the file to give a chatbot with "Copy for a chatbot", which answers with the right locator.',
214
+ doesBg: 'HTML-ът на страницата в момента, в който локаторът не е намерил нищо, без скриптове, стилове и имената на разговорите от страничната лента: файлът, който се дава на чатбот заедно с „Копирай за чатбот“, и той отговаря с правилния локатор.',
215
+ },
216
+ {
217
+ key: 'chatloc.prompt',
218
+ kind: 'button',
219
+ en: 'Copy for a chatbot',
220
+ bg: 'Копирай за чатбот',
221
+ doesEn: 'Copies the text that asks a chatbot, given the HTML file, for the locator of this element: what it is, the locator that stopped finding it, and what a good locator uses.',
222
+ doesBg: 'Копира текста, който пита чатбот, получил HTML файла, за локатора на този елемент: какъв е, локаторът, който е спрял да го намира, и какво ползва добрият локатор.',
223
+ },
224
+ {
225
+ key: 'chatloc.dismiss',
226
+ kind: 'button',
227
+ en: 'Close',
228
+ bg: 'Затвори',
229
+ doesEn: 'Closes the notice of this locator, on every page and in Settings; changing the locator in Settings takes it away too.',
230
+ doesBg: 'Затваря съобщението за този локатор, на всяка страница и в Settings; смяната на локатора в Settings също го маха.',
231
+ },
232
+ ],
233
+ },
195
234
  {
196
235
  headingKey: 'approval.waitingHere',
197
236
  en: 'A step is waiting for your decision',
@@ -1010,6 +1049,14 @@ export const SYSTEM_GUIDE = [
1010
1049
  doesEn: 'While it is paused: goes on with the work from where it held.',
1011
1050
  doesBg: 'Докато е на пауза: продължава работата оттам, където е задържана.',
1012
1051
  },
1052
+ {
1053
+ key: 'chat.carryOn',
1054
+ kind: 'button',
1055
+ en: 'Continue',
1056
+ bg: 'Продължи',
1057
+ doesEn: 'Under the last message of a conversation when it stopped before it was done — its window closed more times than Settings reopen it, Stop, the bot stopped or restarted, a limit: carries it on in the same conversation from where it got to; Copilot is told how it stopped and which of its last commands ran, with what they printed.',
1058
+ doesBg: 'Под последното съобщение на разговор, когато е спряло, преди да е готово — прозорецът му е затварян повече пъти, отколкото Настройките го отварят отново, „Стоп“, ботът е спрял или рестартиран, лимит: продължава го в същия разговор оттам, докъдето е стигнало; на Copilot се казва как е спряло и кои от последните му команди са минали, с изписаното от тях.',
1059
+ },
1013
1060
  {
1014
1061
  key: 'chat.stop',
1015
1062
  kind: 'button',
@@ -1079,8 +1126,8 @@ export const SYSTEM_GUIDE = [
1079
1126
  kind: 'note',
1080
1127
  en: 'Kerrigan\'s model',
1081
1128
  bg: 'Модел на Кериган',
1082
- doesEn: 'With Kerrigan directing: beside the first model, which is hers; none chosen, Settings\' model for the lead.',
1083
- doesBg: 'Когато Кериган води: до първия модел, който е неин; ако не е избран — моделът за ръководителя от Настройки.',
1129
+ doesEn: 'With Kerrigan directing: beside the first model, which is hers; none chosen, Settings\' model for Kerrigan, else the lead\'s, else the worker\'s.',
1130
+ doesBg: 'Когато Кериган води: до първия модел, който е неин; ако не е избран — моделът за Кериган от Настройки, иначе този за ръководителя, иначе този за изпълнителя.',
1084
1131
  },
1085
1132
  {
1086
1133
  key: 'chat.kerriganChatsModel',
@@ -2436,8 +2483,8 @@ export const SYSTEM_GUIDE = [
2436
2483
  kind: 'checkbox',
2437
2484
  en: 'Choose the model by hand at the start of each run',
2438
2485
  bg: 'Избирай модела ръчно в началото на всяко пускане',
2439
- doesEn: 'In each of the three sections, for that part: nothing is chosen for it; a card asks you to choose its model in the Copilot window and press "Ready". The lead\'s and the review\'s are as the worker\'s until set.',
2440
- doesBg: 'Във всяка от трите секции, за съответната част: нищо не се избира за нея; карта ви моли да изберете модела ѝ в прозореца на Copilot и да натиснете „Готово“. Тези на ръководителя и на рецензията са като на изпълнителя, докато не се зададат.',
2486
+ doesEn: 'In each of the four sections, for that part: nothing is chosen for it; a card asks you to choose its model in the Copilot window and press "Ready". The lead\'s and the review\'s are as the worker\'s until set; Kerrigan\'s is as the lead\'s.',
2487
+ doesBg: 'Във всяка от четирите секции, за съответната част: нищо не се избира за нея; карта ви моли да изберете модела ѝ в прозореца на Copilot и да натиснете „Готово“. Тези на ръководителя и на рецензията са като на изпълнителя, докато не се зададат; този на Кериган е като на ръководителя.',
2441
2488
  },
2442
2489
  {
2443
2490
  key: 'def.saving',
@@ -2464,6 +2511,21 @@ export const SYSTEM_GUIDE = [
2464
2511
  },
2465
2512
  ],
2466
2513
  },
2514
+ {
2515
+ headingKey: 'def.kerriganTitle',
2516
+ en: 'Model for Kerrigan',
2517
+ bg: 'Модел за Кериган',
2518
+ controls: [
2519
+ {
2520
+ key: 'def.kerriganTitle',
2521
+ kind: 'note',
2522
+ en: 'Model for Kerrigan',
2523
+ bg: 'Модел за Кериган',
2524
+ doesEn: 'The model Kerrigan\'s own conversation starts on, with "Kerrigan directs", unless one is chosen under the chat\'s box as "Kerrigan\'s model"; none chosen, the lead\'s, else the worker\'s. The chats she sends the work to take the worker\'s (and, with two chats, the lead\'s), not this. Best a strong reasoning model. Its picker and buttons are those of the worker\'s section; its "by hand" is as the lead\'s until set.',
2525
+ doesBg: 'Моделът, с който започва собственият разговор на Кериган при „Кериган води“, освен ако под полето на чата не е избран друг като „Модел на Кериган“; ако не е избран — този на ръководителя, иначе този на изпълнителя. Чатовете, на които тя праща работата, вземат модела на изпълнителя (а при два чата — и на ръководителя), не този. Най-добре силен модел за разсъждение. Менюто и бутоните му са като в секцията на изпълнителя; „ръчно“ е като при ръководителя, докато не се зададе.',
2526
+ },
2527
+ ],
2528
+ },
2467
2529
  {
2468
2530
  headingKey: 'def.reviewTitle',
2469
2531
  en: 'Model for the review',
@@ -2479,6 +2541,125 @@ export const SYSTEM_GUIDE = [
2479
2541
  },
2480
2542
  ],
2481
2543
  },
2544
+ {
2545
+ headingKey: 'chatloc.title',
2546
+ en: "The chat's locators",
2547
+ bg: 'Локатори на чата',
2548
+ controls: [
2549
+ {
2550
+ key: 'chatloc.check',
2551
+ kind: 'button',
2552
+ en: 'Check the locators',
2553
+ bg: 'Провери локаторите',
2554
+ doesEn: 'Opens the Copilot window, as reading the models does, and looks for each locator: the box and Send, the sidebar, the newest conversation (opened by its address) and its "More" menu (opened and closed again). It only reads; nothing is sent or renamed. Under each field: found, not found (then in red, with the page\'s HTML), or not on the page then and why.',
2555
+ doesBg: 'Отваря прозореца на Copilot, както при четенето на моделите, и търси всеки локатор: полето и Send, страничната лента, най-новия разговор (отворен по адреса му) и менюто му „More“ (отворено и затворено отново). Само чете; нищо не се изпраща и не се преименува. Под всяко поле: намерен, ненамерен (тогава в червено, с HTML-а на страницата) или не беше на страницата тогава и защо.',
2556
+ },
2557
+ {
2558
+ key: 'chatloc.composer',
2559
+ kind: 'field',
2560
+ en: 'Box to write in',
2561
+ bg: 'Поле за писане',
2562
+ doesEn: 'How the bot finds the box it writes its messages in (2026-11-17): a CSS selector, or an XPath starting with /; empty is the default, which finds the box of before November 2026 and the one of 17 November 2026. A locator of an element around the box works too. When a start is refused as "not the Microsoft 365 Copilot chat" and its picture shows the chat, this is the one to change. The next Copilot window takes it.',
2563
+ doesBg: 'Как ботът намира полето, в което пише съобщенията си (2026-11-17): CSS селектор или XPath, започващ с /; празно е стойността по подразбиране, която намира полето отпреди ноември 2026 и това от 17 ноември 2026. Става и локатор на елемент около полето. Когато стартът е отказан с „not the Microsoft 365 Copilot chat“, а снимката му показва чата, сменя се този. Важи от следващия прозорец на Copilot.',
2564
+ },
2565
+ {
2566
+ key: 'chatloc.howTitle',
2567
+ kind: 'disclosure',
2568
+ en: 'How to find the right locator',
2569
+ bg: 'Как да намерите правилния локатор',
2570
+ doesEn: 'Opens the steps: download the page\'s HTML, give it to a chatbot with the text "Copy for a chatbot", put the locator it answers in the field in red; or by hand, with Inspect and Ctrl+F.',
2571
+ doesBg: 'Отваря стъпките: изтеглете HTML-а на страницата, дайте го на чатбот с текста от „Копирай за чатбот“, сложете локатора, който върне, в полето в червено; или на ръка, с Inspect и Ctrl+F.',
2572
+ },
2573
+ {
2574
+ key: 'chatloc.send',
2575
+ kind: 'field',
2576
+ en: 'Send button',
2577
+ bg: 'Бутон Send',
2578
+ doesEn: 'How the bot finds the button that sends the message; empty is the default, the button named "Send" in the box\'s wrapper.',
2579
+ doesBg: 'Как ботът намира бутона, който изпраща съобщението; празно е стойността по подразбиране — бутонът с име „Send“ в обвивката на полето.',
2580
+ },
2581
+ {
2582
+ key: 'chatloc.userMessage',
2583
+ kind: 'field',
2584
+ en: 'Your message in the conversation',
2585
+ bg: 'Вашето съобщение в разговора',
2586
+ doesEn: 'How the bot finds the messages it sent in the conversation, to know one arrived; empty is the default, [id^="user-message-"].',
2587
+ doesBg: 'Как ботът намира изпратените от него съобщения в разговора, за да разбере, че са пристигнали; празно е стойността по подразбиране, [id^="user-message-"].',
2588
+ },
2589
+ {
2590
+ key: 'chatloc.turn',
2591
+ kind: 'field',
2592
+ en: 'Messages of the conversation',
2593
+ bg: 'Съобщенията в разговора',
2594
+ doesEn: 'How the bot finds each message of the conversation, to count them; empty is the default.',
2595
+ doesBg: 'Как ботът намира всяко съобщение в разговора, за да ги брои; празно е стойността по подразбиране.',
2596
+ },
2597
+ {
2598
+ key: 'chatloc.answer',
2599
+ kind: 'field',
2600
+ en: 'Copilot\'s answer',
2601
+ bg: 'Отговорът на Copilot',
2602
+ doesEn: 'How the bot finds each of Copilot\'s answers, with its toolbar; empty is the default.',
2603
+ doesBg: 'Как ботът намира всеки отговор на Copilot, с лентата му; празно е стойността по подразбиране.',
2604
+ },
2605
+ {
2606
+ key: 'chatloc.copy',
2607
+ kind: 'field',
2608
+ en: 'Copy button of the answer',
2609
+ bg: 'Бутон Copy на отговора',
2610
+ doesEn: 'How the bot finds the Copy button inside the answer, through which it takes the answer; empty is the default.',
2611
+ doesBg: 'Как ботът намира бутона Copy в отговора, през който взема отговора; празно е стойността по подразбиране.',
2612
+ },
2613
+ {
2614
+ key: 'chatloc.stop',
2615
+ kind: 'field',
2616
+ en: 'Stop button',
2617
+ bg: 'Бутон Stop',
2618
+ doesEn: 'How the bot finds the button shown while Copilot is still writing; empty is the default.',
2619
+ doesBg: 'Как ботът намира бутона, който се вижда, докато Copilot още пише; празно е стойността по подразбиране.',
2620
+ },
2621
+ {
2622
+ key: 'chatloc.conversationLink',
2623
+ kind: 'field',
2624
+ en: 'A conversation in the sidebar',
2625
+ bg: 'Разговор в страничната лента',
2626
+ doesEn: 'How the bot finds a conversation\'s link in the sidebar, to name it or open it again by its name; empty is the default.',
2627
+ doesBg: 'Как ботът намира връзката към разговор в страничната лента, за да го кръсти или отвори отново по името му; празно е стойността по подразбиране.',
2628
+ },
2629
+ {
2630
+ key: 'chatloc.chatMore',
2631
+ kind: 'field',
2632
+ en: '"More" button of a conversation',
2633
+ bg: 'Бутон „More“ на разговор',
2634
+ doesEn: 'How the bot finds a conversation\'s "More" button in the sidebar; {$chat_id} is where the conversation\'s id goes; empty is the default.',
2635
+ doesBg: 'Как ботът намира бутона „More“ на разговор в страничната лента; {$chat_id} е мястото на id-то на разговора; празно е стойността по подразбиране.',
2636
+ },
2637
+ {
2638
+ key: 'chatloc.renameItem',
2639
+ kind: 'field',
2640
+ en: '"Rename" in that menu',
2641
+ bg: '„Rename“ в това меню',
2642
+ doesEn: 'How the bot finds "Rename" in a conversation\'s menu; empty is the default.',
2643
+ doesBg: 'Как ботът намира „Rename“ в менюто на разговор; празно е стойността по подразбиране.',
2644
+ },
2645
+ {
2646
+ key: 'chatloc.renameInput',
2647
+ kind: 'field',
2648
+ en: 'The name field of the rename dialog',
2649
+ bg: 'Полето за име в прозореца за преименуване',
2650
+ doesEn: 'How the bot finds the field the new name is written in; empty is the default.',
2651
+ doesBg: 'Как ботът намира полето, в което се пише новото име; празно е стойността по подразбиране.',
2652
+ },
2653
+ {
2654
+ key: 'chatloc.renameSave',
2655
+ kind: 'field',
2656
+ en: '"Save" of the rename dialog',
2657
+ bg: '„Save“ в прозореца за преименуване',
2658
+ doesEn: 'How the bot finds the button that saves the new name; empty is the default.',
2659
+ doesBg: 'Как ботът намира бутона, който записва новото име; празно е стойността по подразбиране.',
2660
+ },
2661
+ ],
2662
+ },
2482
2663
  {
2483
2664
  headingKey: 'loc.title',
2484
2665
  en: "The model menu's locators",
@@ -2563,6 +2744,14 @@ export const SYSTEM_GUIDE = [
2563
2744
  doesEn: 'How many times a task stopped by a limit is carried on by itself.',
2564
2745
  doesBg: 'Колко пъти задача, спряна от ограничение, продължава сама.',
2565
2746
  },
2747
+ {
2748
+ key: 'exec.reopenWindow',
2749
+ kind: 'field',
2750
+ en: 'Open the closed Copilot window again',
2751
+ bg: 'Отваряй отново затворения прозорец на Copilot',
2752
+ doesEn: 'How many times, for one message, the Edge window with the Copilot chat — closed while the message is at work, its X pressed by accident or Edge ending — is opened again on the same conversation and the work carried on there (3 by default); past it the message stops and waits for "Continue". 0: closing the window stops the message. The Stop button stops the work.',
2753
+ doesBg: 'Колко пъти за едно съобщение прозорецът на Edge с чата на Copilot — затворен, докато съобщението е в работа, с X по случайност или спрял Edge — се отваря отново на същия разговор и работата продължава там (по подразбиране 3); над това съобщението спира и чака „Продължи“. 0: затварянето на прозореца спира съобщението. Работата се спира с бутона „Стоп“.',
2754
+ },
2566
2755
  {
2567
2756
  key: 'exec.minApproaches',
2568
2757
  kind: 'field',
@@ -103,7 +103,11 @@ export function whyItStopped(c) {
103
103
  }
104
104
  if (c.how === 'stopped') {
105
105
  const where = c.interruption ? `\n\n${describeInterruption(c.interruption).replace(/when the runner stopped/g, 'when it was stopped')}\n\n` : ' ';
106
- return `It was stopped by the operator before it finished — not because anything failed. The files are as you left them.${where}`.trimEnd();
106
+ // The window closed under it (2026-11-13): said as that, in the runner's own words, not as the operator's Stop.
107
+ const first = /browser window/.test(c.stoppedBecause ?? '')
108
+ ? `It stopped because the browser window this conversation is in was closed (${c.stoppedBecause}) — not because anything failed.`
109
+ : 'It was stopped by the operator before it finished — not because anything failed.';
110
+ return `${first} The files are as you left them.${where}`.trimEnd();
107
111
  }
108
112
  const why = c.stoppedBecause ? ` (${c.stoppedBecause})` : '';
109
113
  // Out of rounds of fixing: something did say no, and the chat needs to hear it was not waved through.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The chat's locators that found nothing where the bot needed them (operator, 2026-11-17: "a mechanism that detects
3
+ * which locator exactly the bot failed on, so we can easily see which locator has to be updated"), the last time for
4
+ * each. Kept in the data folder, so a failure seen before a restart is still shown; read by the banner on every page
5
+ * and by Settings, where the locator's field is in red, until the locator is changed there or the operator closes it.
6
+ */
7
+ import { readFile, rename, writeFile } from 'node:fs/promises';
8
+ import { CHAT_LOCATOR_KEYS } from '../transport/locators.js';
9
+ const isKey = (k) => typeof k === 'string' && CHAT_LOCATOR_KEYS.includes(k);
10
+ export class LocatorFailures {
11
+ file;
12
+ /** One write at a time: two failures in the same second are both kept. */
13
+ queue = Promise.resolve();
14
+ constructor(file) {
15
+ this.file = file;
16
+ }
17
+ async list() {
18
+ try {
19
+ const raw = JSON.parse(await readFile(this.file, 'utf8'));
20
+ if (!Array.isArray(raw))
21
+ return [];
22
+ return raw.filter((f) => !!f && typeof f === 'object' && isKey(f.key) && typeof f.locator === 'string' && typeof f.at === 'string');
23
+ }
24
+ catch {
25
+ return [];
26
+ }
27
+ }
28
+ async get(key) {
29
+ return (await this.list()).find((f) => f.key === key) ?? null;
30
+ }
31
+ /** Kept as the one for its locator: the newest replaces the one before. */
32
+ async record(failure) {
33
+ await this.change((all) => [failure, ...all.filter((f) => f.key !== failure.key)]);
34
+ }
35
+ /** Closed by the operator. True when there was one. */
36
+ async dismiss(key) {
37
+ let had = false;
38
+ await this.change((all) => {
39
+ had = all.some((f) => f.key === key);
40
+ return all.filter((f) => f.key !== key);
41
+ });
42
+ return had;
43
+ }
44
+ async change(edit) {
45
+ const run = async () => {
46
+ const next = edit(await this.list());
47
+ const tmp = `${this.file}.tmp`;
48
+ await writeFile(tmp, JSON.stringify(next, null, 2), 'utf8');
49
+ await rename(tmp, this.file);
50
+ };
51
+ const done = this.queue.then(run, run);
52
+ this.queue = done.catch(() => undefined);
53
+ await done;
54
+ }
55
+ }
@@ -20,12 +20,16 @@
20
20
  * running in this process — a check script — can call `setTransportFactory`.
21
21
  */
22
22
  import { CopilotTransport } from './copilotTransport.js';
23
+ import { keptWindow } from './keptWindow.js';
23
24
  export { ReplyTimeoutError, isReplyTimeout, WindowClosed, ChatLost } from './copilotTransport.js';
24
25
  const realChat = (opts) => new CopilotTransport(opts);
25
26
  let factory = realChat;
26
- /** A chat for these options: the real Copilot window, unless a check has put a scripted one in. */
27
+ /**
28
+ * A chat for these options: the real Copilot window, unless a check has put a scripted one in — either way kept for the
29
+ * work by the same rules (see keptWindow.ts).
30
+ */
27
31
  export function createTransport(opts) {
28
- return factory(opts);
32
+ return keptWindow(factory, opts);
29
33
  }
30
34
  /** For checks only: every chat opened from now on comes from `f`. `null` puts the real one back. */
31
35
  export function setTransportFactory(f) {