copilot-operator 0.1.84 → 0.1.88
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 +113 -0
- package/dist/src/api/operator.service.js +329 -32
- package/dist/src/config/schema.js +32 -0
- package/dist/src/orchestrator/cardText.js +91 -0
- package/dist/src/orchestrator/kerriganRunner.js +914 -0
- package/dist/src/orchestrator/leadRunner.js +25 -15
- package/dist/src/orchestrator/planMode.js +6 -4
- package/dist/src/orchestrator/taskRunner.js +93 -40
- package/dist/src/plan/kerrigan.js +109 -4
- package/dist/src/plan/systemGuide.js +227 -4
- package/dist/src/protocol/kerriganSchema.js +175 -0
- package/dist/src/session/compose.js +5 -1
- package/dist/src/session/store.js +9 -0
- package/dist/src/transport/chatTransport.js +6 -2
- package/dist/src/transport/copilotTransport.js +226 -11
- package/dist/src/transport/keptWindow.js +247 -0
- package/dist/src/transport/locators.js +14 -4
- package/dist/src/vcs/git.js +72 -2
- package/dist/src/vcs/operatorGit.js +409 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.26ca37faa3726fff.js +1 -0
- package/dist/web/_next/static/chunks/1548.f5790cd11a91309f.js +1 -0
- package/dist/web/_next/static/chunks/2163.aa9d9b82fcde6caa.js +1 -0
- package/dist/web/_next/static/chunks/714.b7dbce98ba0b59a8.js +1 -0
- package/dist/web/_next/static/chunks/7220.0ca53eefec5d01ea.js +1 -0
- package/dist/web/_next/static/chunks/7921-8f6503aba840928a.js +1 -0
- package/dist/web/_next/static/chunks/8124-1dba8babfcfbc6e2.js +1 -0
- package/dist/web/_next/static/chunks/8584.9f3b058a8f67d3d7.js +1 -0
- package/dist/web/_next/static/chunks/9067.107f6164157e0aa1.js +1 -0
- package/dist/web/_next/static/chunks/9747.984a86f70f9cd973.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-127e5af1ebf21876.js +1 -0
- package/dist/web/_next/static/chunks/app/page-b71841852e6b9ff5.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-95069cb94d79e909.js +1 -0
- package/dist/web/_next/static/chunks/webpack-c015bbeb103c0856.js +1 -0
- package/dist/web/_next/static/css/0c5d6d5914aa3824.css +1 -0
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +176 -173
- package/prompts/kerrigan1.md +169 -0
- package/prompts/lead1.md +4 -1
- package/prompts/level1.md +8 -1
- package/dist/web/_next/static/chunks/1077.e0136d293069ccb8.js +0 -1
- package/dist/web/_next/static/chunks/1548.5cc0c57b00c2e44f.js +0 -1
- package/dist/web/_next/static/chunks/2163.2af0979126ae613a.js +0 -1
- package/dist/web/_next/static/chunks/714.410e2b61aa8c72b7.js +0 -1
- package/dist/web/_next/static/chunks/7220.2c4e5173a060769f.js +0 -1
- package/dist/web/_next/static/chunks/7921-3d21f385338afdf9.js +0 -1
- package/dist/web/_next/static/chunks/8124-1dc34be1646970a8.js +0 -1
- package/dist/web/_next/static/chunks/8584.61650a59d2bfa54d.js +0 -1
- package/dist/web/_next/static/chunks/9067.553056fc9b6cf80e.js +0 -1
- package/dist/web/_next/static/chunks/9747.d5826524bf4b714d.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-b8a1e0075a48b025.js +0 -1
- package/dist/web/_next/static/chunks/app/page-13147b69cf336831.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-e3909ef6c2d8e321.js +0 -1
- package/dist/web/_next/static/chunks/webpack-19a2d7161f23b21d.js +0 -1
- package/dist/web/_next/static/css/f152f27d6afce55c.css +0 -1
- /package/dist/web/_next/static/{WU_J4Ke1d3xVfpW2acqqf → hLBBsG7Kn4vd0p_J-47BJ}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{WU_J4Ke1d3xVfpW2acqqf → hLBBsG7Kn4vd0p_J-47BJ}/_ssgManifest.js +0 -0
|
@@ -23,7 +23,7 @@ import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, writeFileAtomically } from '
|
|
|
23
23
|
import { checkItems, emptyQueue, itemTitle, mergeItems, nextStep, parkAfterMs, parkedAnswerFrom, skippedBecause, statusOfTask, waitsByHand, MAX_PARK_AFTER_SEC, PARKED_WORDS } from '../queue/queue.js';
|
|
24
24
|
import { branchStart, makeQueueBranch, refreshQueueBranch } from '../queue/queueBranch.js';
|
|
25
25
|
import { EventBus } from '../session/events.js';
|
|
26
|
-
import { MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
26
|
+
import { isContinuable, MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
27
27
|
import { handoffOutcomeOf, handoffResultMessage } from '../orchestrator/handoff.js';
|
|
28
28
|
import { runSession, queuedToRun, failedWhileOpening, pickerOptions } from '../orchestrator/taskRunner.js';
|
|
29
29
|
import { Hold, WaitsFor } from '../orchestrator/hold.js';
|
|
@@ -33,7 +33,7 @@ import { suggestRunName } from '../session/runName.js';
|
|
|
33
33
|
import { buildStory } from '../session/story.js';
|
|
34
34
|
import { buildTaskExchange } from '../session/taskExchange.js';
|
|
35
35
|
import { chatNotice } from '../session/chatNotice.js';
|
|
36
|
-
import { kerriganFileName, kerriganPersona } from '../plan/kerrigan.js';
|
|
36
|
+
import { kerriganBrief, kerriganFileName, kerriganPersona } from '../plan/kerrigan.js';
|
|
37
37
|
import { branchChanges, gitCounts, workspaceCommit, workspaceGit, workspaceGitVersions } from '../session/workspaceGit.js';
|
|
38
38
|
import { chatCode } from '../transport/chatSession.js';
|
|
39
39
|
/** The folders the operator works in: the default new sessions start on, and the rest by name. */
|
|
@@ -45,6 +45,8 @@ export const MAX_SESSION_NAME = 120;
|
|
|
45
45
|
* beginning goes as text and the whole of it attached.
|
|
46
46
|
*/
|
|
47
47
|
export const MAX_SKILL_DESCRIPTION = 300;
|
|
48
|
+
/** What a skill says for Kerrigan is short (2026-11-12): its phases, its result, what it needs. */
|
|
49
|
+
export const MAX_SKILL_FOR_KERRIGAN = 3000;
|
|
48
50
|
export const MAX_SKILLS = 50;
|
|
49
51
|
/** What follows `/` at the start of a message: lowercase letters, digits and hyphens, 2 to 40 of them. */
|
|
50
52
|
export const SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,38}[a-z0-9]$/;
|
|
@@ -90,6 +92,7 @@ import { dirtyPolicy } from '../vcs/snapshot.js';
|
|
|
90
92
|
import { runVcsPreflight } from '../vcs/runPreflight.js';
|
|
91
93
|
import { inputSettings, normalisePatterns } from '../vcs/inputs.js';
|
|
92
94
|
import { createNewBranch, planNewBranch } from '../vcs/newBranch.js';
|
|
95
|
+
import { commitAsOperator, identityOf, pushAsOperator, setIdentity, stageFiles, TrustedHooks } from '../vcs/operatorGit.js';
|
|
93
96
|
import { askpassProgram, closePasswordWindows } from '../vcs/remoteAuth.js';
|
|
94
97
|
import { planApprovedMessage, planReviseMessage } from '../orchestrator/planMode.js';
|
|
95
98
|
import { coveredByArtifacts } from '../vcs/artifacts.js';
|
|
@@ -118,6 +121,18 @@ function stepRules(cfg) {
|
|
|
118
121
|
writtenScripts: cfg.execution.writtenScripts,
|
|
119
122
|
};
|
|
120
123
|
}
|
|
124
|
+
/** The languages of the page, by their names in English: the language Kerrigan writes to the person in (2026-11-12). */
|
|
125
|
+
const LANGUAGE_NAMES = {
|
|
126
|
+
en: 'English',
|
|
127
|
+
bg: 'Bulgarian',
|
|
128
|
+
de: 'German',
|
|
129
|
+
es: 'Spanish',
|
|
130
|
+
fr: 'French',
|
|
131
|
+
ja: 'Japanese',
|
|
132
|
+
ko: 'Korean',
|
|
133
|
+
pt: 'Portuguese',
|
|
134
|
+
ar: 'Arabic',
|
|
135
|
+
};
|
|
121
136
|
const INACTIVE_REASON = 'the session is inactive; make it active on the Sessions page to run it';
|
|
122
137
|
/**
|
|
123
138
|
* Why the browser cannot be had now, said in terms of what was pressed. The sentences a start, a
|
|
@@ -147,6 +162,16 @@ function browserRefusal(held, ask) {
|
|
|
147
162
|
? 'already running'
|
|
148
163
|
: 'another conversation is running, and the browser takes one run at a time; start this one once it has finished';
|
|
149
164
|
}
|
|
165
|
+
/** What the Git view said about the project's hooks: none of them (`skip`), or these run although flagged, each as shown then. */
|
|
166
|
+
function hookChoiceOf(input) {
|
|
167
|
+
const trust = Array.isArray(input.trust)
|
|
168
|
+
? input.trust
|
|
169
|
+
.filter((t) => !!t && typeof t.path === 'string' && typeof t.sha === 'string')
|
|
170
|
+
.slice(0, 100)
|
|
171
|
+
.map((t) => ({ path: t.path, sha: t.sha }))
|
|
172
|
+
: [];
|
|
173
|
+
return { hooks: input.hooks === 'skip' ? 'skip' : 'auto', ...(trust.length > 0 ? { trust } : {}) };
|
|
174
|
+
}
|
|
150
175
|
/** A folder as compared: absolute, forward slashes, no trailing slash, and case folded as Windows does. */
|
|
151
176
|
function normaliseDir(dir) {
|
|
152
177
|
if (!dir.trim())
|
|
@@ -236,13 +261,35 @@ let OperatorService = class OperatorService {
|
|
|
236
261
|
return this.running.get(this.runKey(sessionId))?.hold;
|
|
237
262
|
}
|
|
238
263
|
/**
|
|
239
|
-
* The workers of the two-chat mode, by the session of the lead they work for (2026-10-20)
|
|
240
|
-
*
|
|
264
|
+
* The workers of the two-chat mode, by the session of the lead they work for (2026-10-20); and since 2026-11-12 the
|
|
265
|
+
* chats Kerrigan directs, by her conversation's session, and their workers by their chat. A worker's steps and cards
|
|
266
|
+
* carry its own session's id, while the run, its mode and its Stop are the lead's — or Kerrigan's: they are looked up
|
|
267
|
+
* through this, up the chain.
|
|
241
268
|
*/
|
|
242
269
|
workerLeads = new Map();
|
|
243
|
-
/** The session whose run a session's steps belong to: its own, or its
|
|
270
|
+
/** The session whose run a session's steps belong to: its own, or the one up its chain whose run it is. */
|
|
244
271
|
runKey(sessionId) {
|
|
245
|
-
|
|
272
|
+
let key = sessionId;
|
|
273
|
+
for (let i = 0; i < 4 && !this.running.has(key); i++) {
|
|
274
|
+
const up = this.workerLeads.get(key);
|
|
275
|
+
if (!up)
|
|
276
|
+
break;
|
|
277
|
+
key = up;
|
|
278
|
+
}
|
|
279
|
+
return this.running.has(key) ? key : sessionId;
|
|
280
|
+
}
|
|
281
|
+
/** Whether a session is this one or below it: its worker, a chat Kerrigan directs, that chat's worker. */
|
|
282
|
+
under(sessionId, top) {
|
|
283
|
+
let key = sessionId;
|
|
284
|
+
for (let i = 0; i < 4; i++) {
|
|
285
|
+
if (key === top)
|
|
286
|
+
return true;
|
|
287
|
+
const up = this.workerLeads.get(key);
|
|
288
|
+
if (!up)
|
|
289
|
+
return false;
|
|
290
|
+
key = up;
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
246
293
|
}
|
|
247
294
|
ready = null;
|
|
248
295
|
/**
|
|
@@ -406,6 +453,12 @@ let OperatorService = class OperatorService {
|
|
|
406
453
|
const model = patch.workerModel !== undefined ? patch.workerModel.trim() : (s.lead.workerModel ?? '');
|
|
407
454
|
s.lead = { ...s.lead, workerManualModel: manual || undefined, workerModel: manual ? undefined : model || undefined };
|
|
408
455
|
}
|
|
456
|
+
// Kerrigan's (2026-11-12): the same fields are the model of the chats she sends to — the ones she makes from now on.
|
|
457
|
+
if (s.kerrigan && (patch.workerModel !== undefined || typeof patch.workerManualModel === 'boolean')) {
|
|
458
|
+
const manual = typeof patch.workerManualModel === 'boolean' ? patch.workerManualModel : !!s.kerrigan.chatManualModel;
|
|
459
|
+
const model = patch.workerModel !== undefined ? patch.workerModel.trim() : (s.kerrigan.chatModel ?? '');
|
|
460
|
+
s.kerrigan = { ...(manual ? { chatManualModel: true } : {}), ...(!manual && model ? { chatModel: model } : {}) };
|
|
461
|
+
}
|
|
409
462
|
// The same for the group: clearing it gives this session its conversation back. It does
|
|
410
463
|
// not move the conversation it is already in; that history is where it is.
|
|
411
464
|
if (patch.conversationGroup !== undefined)
|
|
@@ -873,6 +926,10 @@ let OperatorService = class OperatorService {
|
|
|
873
926
|
const idle = { ran: 0, failed: 0, leftQueued: 0, failedTitles: [] };
|
|
874
927
|
if (this.running.has(sessionId))
|
|
875
928
|
return { started: false, reason: 'already running', done: Promise.resolve(idle) };
|
|
929
|
+
// The operator's own commit or push still running in the folder: a run's git would go under it (2026-11-11).
|
|
930
|
+
const gitBusy = this.gitOpBusy();
|
|
931
|
+
if (gitBusy)
|
|
932
|
+
return { started: false, reason: gitBusy, done: Promise.resolve(idle) };
|
|
876
933
|
const session = await this.store.getSession(sessionId);
|
|
877
934
|
if (!session)
|
|
878
935
|
return { started: false, reason: 'no such session', done: Promise.resolve(idle) };
|
|
@@ -923,6 +980,16 @@ let OperatorService = class OperatorService {
|
|
|
923
980
|
const asLead = await this.store.getSession(sessionId);
|
|
924
981
|
if (asLead?.lead?.workerSessionId)
|
|
925
982
|
this.workerLeads.set(asLead.lead.workerSessionId, sessionId);
|
|
983
|
+
// Kerrigan's (2026-11-12): the chats she directs, and their workers, are hers to speak for from the start.
|
|
984
|
+
if (asLead?.kerrigan) {
|
|
985
|
+
for (const s of await this.store.listSessions()) {
|
|
986
|
+
if (s.directedBy !== sessionId)
|
|
987
|
+
continue;
|
|
988
|
+
this.workerLeads.set(s.id, sessionId);
|
|
989
|
+
if (s.lead?.workerSessionId)
|
|
990
|
+
this.workerLeads.set(s.lead.workerSessionId, s.id);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
926
993
|
}
|
|
927
994
|
this.bus.publish({ sessionId, type: 'run-requested', level: 'info', message: `starting in ${mode} mode` });
|
|
928
995
|
// Said at the start of every run, in both modes, because it is the one fact about this tool a
|
|
@@ -986,6 +1053,8 @@ let OperatorService = class OperatorService {
|
|
|
986
1053
|
await this.setDefaultReviewModel(to);
|
|
987
1054
|
if (which === 'lead' && (now.defaultLeadModel ?? '').trim() === from)
|
|
988
1055
|
await this.setDefaultLeadModel(to);
|
|
1056
|
+
if (which === 'kerrigan' && (now.defaultKerriganModel ?? '').trim() === from)
|
|
1057
|
+
await this.setDefaultKerriganModel(to);
|
|
989
1058
|
},
|
|
990
1059
|
seen: async (options, current) => {
|
|
991
1060
|
await this.store.saveModels({ options, current: current ?? undefined, readAt: new Date().toISOString() });
|
|
@@ -996,7 +1065,15 @@ let OperatorService = class OperatorService {
|
|
|
996
1065
|
// The two-chat mode (2026-10-20): the lead's questions, and the worker the run speaks for too.
|
|
997
1066
|
askQuestion: (ask) => this.askLeadQuestion(ask, controller.signal),
|
|
998
1067
|
askSubtaskRetry: (ask) => this.askSubtaskRetry(ask, controller.signal),
|
|
999
|
-
onWorker: (workerId) => this.workerLeads.set(workerId, sessionId),
|
|
1068
|
+
onWorker: (workerId, parent) => this.workerLeads.set(workerId, parent ?? sessionId),
|
|
1069
|
+
// A conversation Kerrigan directs (2026-11-12): the facts she is told, and the skills she sends with.
|
|
1070
|
+
kerrigan: {
|
|
1071
|
+
brief: async () => await this.kerriganBriefText((await this.store.getSession(sessionId))?.lang ?? session.lang, sessionId),
|
|
1072
|
+
skill: async (name, dir) => {
|
|
1073
|
+
const found = await this.skillFor(name, dir).catch(() => null);
|
|
1074
|
+
return found ? { name: found.name, description: found.description, text: found.text } : null;
|
|
1075
|
+
},
|
|
1076
|
+
},
|
|
1000
1077
|
hold,
|
|
1001
1078
|
})
|
|
1002
1079
|
.then(async (outcome) => {
|
|
@@ -1067,7 +1144,9 @@ let OperatorService = class OperatorService {
|
|
|
1067
1144
|
* "Pause" on the chat (operator, 2026-10-20): the running work holds at its next message to Copilot or its next
|
|
1068
1145
|
* command, and the button becomes "Continue". A reply being written and a command running are let finish.
|
|
1069
1146
|
*/
|
|
1070
|
-
pause(
|
|
1147
|
+
pause(asked) {
|
|
1148
|
+
// A chat Kerrigan directs is paused with her run (2026-11-12).
|
|
1149
|
+
const sessionId = this.runKey(asked);
|
|
1071
1150
|
const r = this.running.get(sessionId);
|
|
1072
1151
|
if (!r)
|
|
1073
1152
|
throw new Error('Nothing of this conversation is running, so there is nothing to pause.');
|
|
@@ -1077,13 +1156,16 @@ let OperatorService = class OperatorService {
|
|
|
1077
1156
|
return { paused: true };
|
|
1078
1157
|
}
|
|
1079
1158
|
/** "Continue": the paused work goes on from where it held. A run that has ended meanwhile has nothing to go on with. */
|
|
1080
|
-
resume(
|
|
1159
|
+
resume(asked) {
|
|
1160
|
+
const sessionId = this.runKey(asked);
|
|
1081
1161
|
const r = this.running.get(sessionId);
|
|
1082
1162
|
if (r?.hold.resume())
|
|
1083
1163
|
this.bus.publish({ sessionId, type: 'resume-asked', level: 'info', message: 'continued by the operator' });
|
|
1084
1164
|
return { paused: false };
|
|
1085
1165
|
}
|
|
1086
|
-
async stop(
|
|
1166
|
+
async stop(asked) {
|
|
1167
|
+
// A chat Kerrigan directs is stopped with her run (2026-11-12): it is one run.
|
|
1168
|
+
const sessionId = this.runKey(asked);
|
|
1087
1169
|
const r = this.running.get(sessionId);
|
|
1088
1170
|
if (!r)
|
|
1089
1171
|
return { stopping: false };
|
|
@@ -1172,13 +1254,90 @@ let OperatorService = class OperatorService {
|
|
|
1172
1254
|
return await workspaceInfo(cfg.project?.rootDir ?? '', cfg.project?.name ?? '');
|
|
1173
1255
|
}
|
|
1174
1256
|
// --- a new branch from main, from the chat (2026-10-26) --------------------------------------------------------
|
|
1175
|
-
/** Why the folder's branch may not be changed now: a task at work,
|
|
1257
|
+
/** Why the folder's branch may not be changed now: a task at work, the queue between its tasks, or the operator's own commit or push. */
|
|
1176
1258
|
branchBusy() {
|
|
1177
1259
|
if (this.running.size > 0 || this.browser?.kind === 'run')
|
|
1178
1260
|
return 'A task is working: stop it or let it finish first; the branch is not changed under it.';
|
|
1179
1261
|
if (this.queueLoop)
|
|
1180
1262
|
return 'The queue is running: stop it first; the branch is not changed under its tasks.';
|
|
1181
|
-
return
|
|
1263
|
+
return this.gitOpBusy();
|
|
1264
|
+
}
|
|
1265
|
+
// --- the operator's own commit and push, from the Git view (2026-11-11, see `vcs/operatorGit.ts`) ------------------
|
|
1266
|
+
/** The commit or push of the operator's that runs now, or ran last: what the Git view follows. One at a time. */
|
|
1267
|
+
gitOp = null;
|
|
1268
|
+
/** Hook files the operator said to run although they were not the project's own, each as it was then. */
|
|
1269
|
+
trustedHooks = new TrustedHooks(join(this.dataDir, 'trusted-hooks.json'));
|
|
1270
|
+
/** Why nothing else may change the folder's git now: the operator's commit or push still running. */
|
|
1271
|
+
gitOpBusy() {
|
|
1272
|
+
if (this.gitOp?.state !== 'running')
|
|
1273
|
+
return null;
|
|
1274
|
+
return this.gitOp.kind === 'commit'
|
|
1275
|
+
? 'Git is committing in the project folder (the Git view follows it): let it finish first.'
|
|
1276
|
+
: 'Git is pushing from the project folder (the Git view follows it): let it finish first.';
|
|
1277
|
+
}
|
|
1278
|
+
/** The folder the Git view acts in, when nothing else is changing its git; else why not. */
|
|
1279
|
+
async gitFolder() {
|
|
1280
|
+
const ws = await this.workspace();
|
|
1281
|
+
if (!ws.ok)
|
|
1282
|
+
throw new Error(ws.problem ?? 'No project folder is open: open one first.');
|
|
1283
|
+
const busy = this.branchBusy();
|
|
1284
|
+
if (busy)
|
|
1285
|
+
throw new Error(busy);
|
|
1286
|
+
return ws.dir;
|
|
1287
|
+
}
|
|
1288
|
+
/** The commit or push running now, or the last one. */
|
|
1289
|
+
gitOpState() {
|
|
1290
|
+
return this.gitOp;
|
|
1291
|
+
}
|
|
1292
|
+
/** Files of the Git view's lists staged or unstaged; the folder's git as it is then. */
|
|
1293
|
+
async gitStage(how, which) {
|
|
1294
|
+
const dir = await this.gitFolder();
|
|
1295
|
+
await stageFiles(dir, how, which);
|
|
1296
|
+
return await workspaceGit(dir);
|
|
1297
|
+
}
|
|
1298
|
+
/** Starts a commit or a push and answers at once with it; the Git view reads it again while it runs (`gitOpState`). */
|
|
1299
|
+
startGitOp(kind, dir, run, extra = {}) {
|
|
1300
|
+
const op = { id: newId('g-'), kind, state: 'running', startedAt: new Date().toISOString(), command: kind === 'commit' ? 'git commit' : 'git push', output: '', hooks: 'none', ...extra };
|
|
1301
|
+
this.gitOp = op;
|
|
1302
|
+
const update = (patch) => {
|
|
1303
|
+
// A later one replaces this one only once this one has ended, so nothing is written into another's record.
|
|
1304
|
+
if (this.gitOp?.id === op.id)
|
|
1305
|
+
Object.assign(op, patch);
|
|
1306
|
+
};
|
|
1307
|
+
void run(update)
|
|
1308
|
+
.catch((e) => update({ state: 'failed', cause: 'unknown', output: `${op.output}${op.output ? '\n' : ''}${e.message}\n`, endedAt: new Date().toISOString() }))
|
|
1309
|
+
.finally(() => {
|
|
1310
|
+
if (op.state === 'running')
|
|
1311
|
+
update({ state: 'failed', cause: 'unknown', endedAt: new Date().toISOString() });
|
|
1312
|
+
console.log(`[git] ${op.kind} in ${dir}: ${op.state}${op.cause ? ` (${op.cause})` : ''}${op.commit ? ` ${op.commit.slice(0, 8)}` : ''}${op.target ? ` → ${op.target}` : ''}`);
|
|
1313
|
+
});
|
|
1314
|
+
return op;
|
|
1315
|
+
}
|
|
1316
|
+
/** The operator's commit of what is staged, or of everything (`all`), with the project's hooks as `hooks`/`trust` say. */
|
|
1317
|
+
async gitCommit(input) {
|
|
1318
|
+
const dir = await this.gitFolder();
|
|
1319
|
+
const message = typeof input.message === 'string' ? input.message.slice(0, 20_000) : '';
|
|
1320
|
+
const all = input.all === true;
|
|
1321
|
+
const choice = hookChoiceOf(input);
|
|
1322
|
+
return this.startGitOp('commit', dir, (update) => commitAsOperator(dir, { message, all, ...choice }, this.trustedHooks, update), { message, all });
|
|
1323
|
+
}
|
|
1324
|
+
/** The operator's push of the branch the folder is on, to its upstream or published (see `pushAsOperator`). */
|
|
1325
|
+
async gitPush(input) {
|
|
1326
|
+
const dir = await this.gitFolder();
|
|
1327
|
+
return this.startGitOp('push', dir, (update) => pushAsOperator(dir, hookChoiceOf(input), this.trustedHooks, update));
|
|
1328
|
+
}
|
|
1329
|
+
/** The operator's name and e-mail as git has them for the open folder's repository. */
|
|
1330
|
+
async gitIdentity() {
|
|
1331
|
+
const ws = await this.workspace();
|
|
1332
|
+
if (!ws.ok)
|
|
1333
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
1334
|
+
return await identityOf(ws.dir);
|
|
1335
|
+
}
|
|
1336
|
+
/** The operator's name and e-mail set for git, in this repository or for all of theirs: what a first commit asks for. */
|
|
1337
|
+
async setGitIdentity(input) {
|
|
1338
|
+
const dir = await this.gitFolder();
|
|
1339
|
+
await setIdentity(dir, { name: typeof input.name === 'string' ? input.name : '', email: typeof input.email === 'string' ? input.email : '', global: input.global === true });
|
|
1340
|
+
return await identityOf(dir);
|
|
1182
1341
|
}
|
|
1183
1342
|
/**
|
|
1184
1343
|
* What a new branch from main would start from (see `vcs/newBranch.ts`). With `fetch`, the remote's main is fetched
|
|
@@ -1286,6 +1445,22 @@ let OperatorService = class OperatorService {
|
|
|
1286
1445
|
* language she is not written out in, the page fills in the names of the controls (`filled: false`).
|
|
1287
1446
|
*/
|
|
1288
1447
|
async kerrigan(lang, skill) {
|
|
1448
|
+
const { facts, chosen } = await this.kerriganFacts(skill);
|
|
1449
|
+
const text = kerriganPersona(lang, facts);
|
|
1450
|
+
return { lang, fileName: kerriganFileName(lang, chosen?.name), text, filled: lang === 'en' || lang === 'bg' };
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* The facts of this machine for Kerrigan when she directs a conversation herself (2026-11-12): the same as her text's,
|
|
1454
|
+
* with the person's language, how many messages she may send to chats, and how the chats' commands run in this run.
|
|
1455
|
+
*/
|
|
1456
|
+
async kerriganBriefText(lang, sessionId) {
|
|
1457
|
+
const cfg = await this.settings.load();
|
|
1458
|
+
const { facts } = await this.kerriganFacts();
|
|
1459
|
+
const mode = this.running.get(this.runKey(sessionId))?.mode ?? cfg.execution.mode;
|
|
1460
|
+
return kerriganBrief({ ...facts, language: LANGUAGE_NAMES[lang ?? 'en'] ?? 'English', maxSends: cfg.limits.maxKerriganSends ?? 6, commands: mode === 'unattended' ? 'auto' : 'ask' });
|
|
1461
|
+
}
|
|
1462
|
+
/** What Kerrigan is told of this machine: its limits, the projects with their notes, the skills; a skill chosen, too. */
|
|
1463
|
+
async kerriganFacts(skill) {
|
|
1289
1464
|
const cfg = await this.settings.load();
|
|
1290
1465
|
const p = await this.project();
|
|
1291
1466
|
const projects = [
|
|
@@ -1295,13 +1470,13 @@ let OperatorService = class OperatorService {
|
|
|
1295
1470
|
// The skills, each with the name of the project it is for.
|
|
1296
1471
|
const nameOf = (dir) => [{ name: p.name || p.rootDir, rootDir: p.rootDir }, ...p.others].find((x) => x.rootDir && sameFolder(x.rootDir, dir))?.name ?? dir;
|
|
1297
1472
|
const all = (await this.skills()).skills;
|
|
1298
|
-
const skills = all.map((k) => ({ name: k.name, description: k.description, ...(k.projectDir ? { project: nameOf(k.projectDir) } : {}) }));
|
|
1473
|
+
const skills = all.map((k) => ({ name: k.name, description: k.description, ...(k.projectDir ? { project: nameOf(k.projectDir) } : {}), forKerrigan: k.forKerrigan, text: k.text }));
|
|
1299
1474
|
// The skill chosen beside her button (2026-10-26): its instructions go with her text.
|
|
1300
1475
|
const asked = skill?.trim().replace(/^\//, '').toLowerCase();
|
|
1301
1476
|
const chosen = asked ? all.find((k) => k.name === asked) : undefined;
|
|
1302
1477
|
if (asked && !chosen)
|
|
1303
1478
|
throw new Error(`There is no skill called "${asked}" in Settings → Skills.`);
|
|
1304
|
-
const
|
|
1479
|
+
const facts = {
|
|
1305
1480
|
version: botVersion(),
|
|
1306
1481
|
skills,
|
|
1307
1482
|
maxIterations: cfg.limits.maxIterations,
|
|
@@ -1311,8 +1486,8 @@ let OperatorService = class OperatorService {
|
|
|
1311
1486
|
maxSubtasks: cfg.limits.maxSubtasks ?? 20,
|
|
1312
1487
|
projects,
|
|
1313
1488
|
...(chosen ? { chosenSkill: { name: chosen.name, description: chosen.description, text: chosen.text, ...(chosen.projectDir ? { project: nameOf(chosen.projectDir) } : {}) } } : {}),
|
|
1314
|
-
}
|
|
1315
|
-
return {
|
|
1489
|
+
};
|
|
1490
|
+
return { facts, ...(chosen ? { chosen } : {}) };
|
|
1316
1491
|
}
|
|
1317
1492
|
/** The chat's conversations, newest first. */
|
|
1318
1493
|
async chatThreads() {
|
|
@@ -1321,7 +1496,18 @@ let OperatorService = class OperatorService {
|
|
|
1321
1496
|
// A worker's session (two chats) is not a conversation of the list: it is shown under its lead's messages.
|
|
1322
1497
|
.filter((s) => s.kind === 'chat' && !s.workerOf)
|
|
1323
1498
|
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
1324
|
-
.map((s) => ({
|
|
1499
|
+
.map((s) => ({
|
|
1500
|
+
id: s.id,
|
|
1501
|
+
name: s.name,
|
|
1502
|
+
createdAt: s.createdAt,
|
|
1503
|
+
status: s.status,
|
|
1504
|
+
turns: s.tasks.length,
|
|
1505
|
+
// A chat Kerrigan directs runs in her run (2026-11-12): running while a message of its is at work in it.
|
|
1506
|
+
running: this.running.has(s.id) || (!!s.directedBy && this.running.has(this.runKey(s.id)) && s.tasks.some((t) => t.status === 'running' || t.status === 'waiting-approval')),
|
|
1507
|
+
repoDir: s.vcs?.repoDir || s.projectDir,
|
|
1508
|
+
...(s.kerrigan ? { kerrigan: true } : {}),
|
|
1509
|
+
...(s.directedBy ? { directedBy: s.directedBy } : {}),
|
|
1510
|
+
}));
|
|
1325
1511
|
}
|
|
1326
1512
|
/**
|
|
1327
1513
|
* A message written in the chat. With no conversation yet, one is made in the open project folder: a session of
|
|
@@ -1344,6 +1530,16 @@ let OperatorService = class OperatorService {
|
|
|
1344
1530
|
const skill = input.skill?.trim() ? await this.skillFor(input.skill, session?.projectDir ?? (await this.workspace()).dir) : undefined;
|
|
1345
1531
|
if (session) {
|
|
1346
1532
|
const inFlight = session.tasks.find((t) => t.status === 'running' || t.status === 'waiting-approval');
|
|
1533
|
+
// A chat Kerrigan directs, while she works (2026-11-12): a note to its message at work, or to her.
|
|
1534
|
+
if (session.directedBy && !this.running.has(session.id) && this.running.has(this.runKey(session.id))) {
|
|
1535
|
+
if (skill)
|
|
1536
|
+
throw new Error('Kerrigan is at work with this chat: write to her conversation, or Stop her first.');
|
|
1537
|
+
if (inFlight) {
|
|
1538
|
+
await this.addTaskNote(session.id, inFlight.id, text);
|
|
1539
|
+
return { threadId: session.id, taskId: inFlight.id, noted: true, needsStart: false };
|
|
1540
|
+
}
|
|
1541
|
+
throw new Error('Kerrigan is at work with this chat: write to her conversation, or Stop her first.');
|
|
1542
|
+
}
|
|
1347
1543
|
if (inFlight && this.running.has(session.id)) {
|
|
1348
1544
|
if (skill)
|
|
1349
1545
|
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.`);
|
|
@@ -1382,7 +1578,19 @@ let OperatorService = class OperatorService {
|
|
|
1382
1578
|
* Two chats (operator, 2026-10-20): this conversation is the lead's, and a worker carries out its subtasks. The
|
|
1383
1579
|
* lead judges the worker's reports, so there is no review of its own.
|
|
1384
1580
|
*/
|
|
1385
|
-
|
|
1581
|
+
/*
|
|
1582
|
+
* Kerrigan directs (operator, 2026-11-12): the conversation is hers, and she chooses plan mode, two chats, the review
|
|
1583
|
+
* and the skill for each message she sends to a chat of its own. The model of those chats, as chosen beside hers.
|
|
1584
|
+
*/
|
|
1585
|
+
if (input.kerrigan) {
|
|
1586
|
+
s.kerrigan = {
|
|
1587
|
+
...(input.chatManualModel ? { chatManualModel: true } : {}),
|
|
1588
|
+
...(!input.chatManualModel && input.chatModel?.trim() ? { chatModel: input.chatModel.trim() } : {}),
|
|
1589
|
+
};
|
|
1590
|
+
s.review = { enabled: false, model: '' };
|
|
1591
|
+
s.planMode = 'off';
|
|
1592
|
+
}
|
|
1593
|
+
else if (input.lead) {
|
|
1386
1594
|
s.lead = {
|
|
1387
1595
|
...(input.workerManualModel ? { workerManualModel: true } : {}),
|
|
1388
1596
|
...(!input.workerManualModel && input.workerModel?.trim() ? { workerModel: input.workerModel.trim() } : {}),
|
|
@@ -1985,8 +2193,9 @@ let OperatorService = class OperatorService {
|
|
|
1985
2193
|
async skills() {
|
|
1986
2194
|
const cfg = await this.settings.load();
|
|
1987
2195
|
return {
|
|
1988
|
-
skills: (cfg.skills ?? []).map((k) => ({ name: k.name, description: k.description ?? '', text: k.text ?? '', projectDir: k.projectDir ?? '' })),
|
|
2196
|
+
skills: (cfg.skills ?? []).map((k) => ({ name: k.name, description: k.description ?? '', text: k.text ?? '', projectDir: k.projectDir ?? '', forKerrigan: k.forKerrigan ?? '' })),
|
|
1989
2197
|
maxDescription: MAX_SKILL_DESCRIPTION,
|
|
2198
|
+
maxForKerrigan: MAX_SKILL_FOR_KERRIGAN,
|
|
1990
2199
|
};
|
|
1991
2200
|
}
|
|
1992
2201
|
/**
|
|
@@ -2017,7 +2226,10 @@ let OperatorService = class OperatorService {
|
|
|
2017
2226
|
const projectDir = String(k?.projectDir ?? '').trim();
|
|
2018
2227
|
if (projectDir && !folders.some((f) => sameFolder(f, projectDir)))
|
|
2019
2228
|
throw new Error(`The skill "${name}" is for ${projectDir}, which is not one of the projects in Settings.`);
|
|
2020
|
-
|
|
2229
|
+
const forKerrigan = String(k?.forKerrigan ?? '').trim();
|
|
2230
|
+
if (forKerrigan.length > MAX_SKILL_FOR_KERRIGAN)
|
|
2231
|
+
throw new Error(`What "${name}" says for Kerrigan is longer than ${MAX_SKILL_FOR_KERRIGAN} characters: its phases, its result and what it needs, in a few lines.`);
|
|
2232
|
+
return { name, description, text, projectDir, forKerrigan };
|
|
2021
2233
|
});
|
|
2022
2234
|
await this.settings.update((raw) => ({ ...raw, skills }));
|
|
2023
2235
|
return await this.skills();
|
|
@@ -2156,6 +2368,7 @@ let OperatorService = class OperatorService {
|
|
|
2156
2368
|
this.parkLater(approval);
|
|
2157
2369
|
this.bus.publish({ sessionId: ask.sessionId, taskId: ask.taskId, type: 'approval-requested', level: 'warn',
|
|
2158
2370
|
message: `the lead asks the operator: ${ask.question}`, data: { approvalId: approval.id, question: approval.question } });
|
|
2371
|
+
ask.onCard?.(this.cardHandle(approval.id, (a, why) => this.answerQuestion(approval.id, a.text, undefined, undefined, a.chosen, { by: 'kerrigan', why })));
|
|
2159
2372
|
});
|
|
2160
2373
|
}
|
|
2161
2374
|
/** The operator's answer to the lead's question. */
|
|
@@ -2184,10 +2397,11 @@ let OperatorService = class OperatorService {
|
|
|
2184
2397
|
this.parkLater(approval);
|
|
2185
2398
|
this.bus.publish({ sessionId: ask.sessionId, taskId: ask.taskId, type: 'approval-requested', level: 'warn',
|
|
2186
2399
|
message: `subtask ${ask.retry.n} did not finish (attempt ${ask.retry.attempt} of ${ask.retry.maxAttempts}): the operator is asked what to do`, data: { approvalId: approval.id, retry: ask.retry } });
|
|
2400
|
+
ask.onCard?.(this.cardHandle(approval.id, (choice, why) => this.answerRetry(approval.id, choice, { by: 'kerrigan', why })));
|
|
2187
2401
|
});
|
|
2188
2402
|
}
|
|
2189
2403
|
/** The operator's choice for a subtask that failed for a technical reason: one of the card's own. */
|
|
2190
|
-
answerRetry(approvalId, choice) {
|
|
2404
|
+
answerRetry(approvalId, choice, as) {
|
|
2191
2405
|
const w = this.waiting.get(approvalId);
|
|
2192
2406
|
if (!w?.resolveRetry || !w.approval.retry)
|
|
2193
2407
|
return { ok: false, problem: 'No subtask is waiting for a choice under that id.' };
|
|
@@ -2196,9 +2410,31 @@ let OperatorService = class OperatorService {
|
|
|
2196
2410
|
this.waiting.delete(approvalId);
|
|
2197
2411
|
w.resolveRetry(choice);
|
|
2198
2412
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2199
|
-
message:
|
|
2413
|
+
message: `${as ? 'Kerrigan' : 'the operator'} chose for subtask ${w.approval.retry.n}: ${choice}${as?.why ? ` — ${as.why}` : ''}`, data: { approvalId, retry: choice, ...(as ? { by: as.by } : {}) } });
|
|
2200
2414
|
return { ok: true };
|
|
2201
2415
|
}
|
|
2416
|
+
/**
|
|
2417
|
+
* A card, handed to Kerrigan to answer in the operator's place (2026-11-12): answered through the same way as their
|
|
2418
|
+
* press, said to be hers; marked with what she is doing about it, which the card shows.
|
|
2419
|
+
*/
|
|
2420
|
+
cardHandle(id, answer) {
|
|
2421
|
+
return {
|
|
2422
|
+
id,
|
|
2423
|
+
open: () => this.waiting.has(id),
|
|
2424
|
+
answer: (a, why) => (this.waiting.has(id) ? answer(a, why) : { ok: false, problem: 'The card was answered already.' }),
|
|
2425
|
+
mark: (state) => {
|
|
2426
|
+
const w = this.waiting.get(id);
|
|
2427
|
+
if (!w)
|
|
2428
|
+
return;
|
|
2429
|
+
if (state)
|
|
2430
|
+
w.approval.kerrigan = state;
|
|
2431
|
+
else
|
|
2432
|
+
delete w.approval.kerrigan;
|
|
2433
|
+
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-kerrigan', level: state?.state === 'yours' ? 'warn' : 'info',
|
|
2434
|
+
message: state?.state === 'yours' ? `Kerrigan leaves the card to the operator: ${state.why ?? ''}` : state ? 'the card went to Kerrigan' : 'the card is the operator\'s again', data: { approvalId: id, kerrigan: state } });
|
|
2435
|
+
},
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2202
2438
|
/**
|
|
2203
2439
|
* Two chats, after a Stop (2026-10-25): "do not start a task again by itself after Stop; when the operator carries on in
|
|
2204
2440
|
* the same conversation, let a chosen failed subtask be tried again, with the plan and the reports kept". The message
|
|
@@ -2227,19 +2463,59 @@ let OperatorService = class OperatorService {
|
|
|
2227
2463
|
const cfg = await this.settings.load();
|
|
2228
2464
|
return await this.start(threadId, cfg.execution.mode);
|
|
2229
2465
|
}
|
|
2230
|
-
|
|
2466
|
+
/**
|
|
2467
|
+
* "Continue" under a message that stopped before it was done (operator, 2026-11-13: "for every stop" — a window closed
|
|
2468
|
+
* past the times it is opened again, Stop, the bot itself stopped or restarted, a limit): carried on in its conversation
|
|
2469
|
+
* from where it got to. The chat is told how it stopped and, for one that was stopped, which of its last commands ran,
|
|
2470
|
+
* with the end of what they printed, which was cut off and which never ran — read from its run folder — rather than
|
|
2471
|
+
* only that it was stopped, after which it ran its inspections again (live run, 2026-10-03). Only the last message of
|
|
2472
|
+
* a conversation: one the conversation has gone on past is not carried on in it. A chat Kerrigan directs is hers.
|
|
2473
|
+
*/
|
|
2474
|
+
async chatContinue(threadId, taskId) {
|
|
2475
|
+
await this.init();
|
|
2476
|
+
const session = await this.store.getSession(threadId);
|
|
2477
|
+
if (!session || session.kind !== 'chat')
|
|
2478
|
+
throw new Error('That conversation is not there any more.');
|
|
2479
|
+
if (session.directedBy)
|
|
2480
|
+
throw new Error('Kerrigan directs this chat: carry her conversation on instead.');
|
|
2481
|
+
if (this.running.has(this.runKey(threadId)))
|
|
2482
|
+
throw new Error('The conversation is working: stop it first, or let it finish.');
|
|
2483
|
+
const task = session.tasks.find((t) => t.id === taskId);
|
|
2484
|
+
if (!task)
|
|
2485
|
+
throw new Error('That message is not in this conversation.');
|
|
2486
|
+
if (session.tasks.at(-1)?.id !== taskId)
|
|
2487
|
+
throw new Error('Only the last message of a conversation is carried on: the conversation has gone on past this one.');
|
|
2488
|
+
if (!isContinuable(task)) {
|
|
2489
|
+
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.');
|
|
2490
|
+
}
|
|
2491
|
+
const cfg = await this.settings.load();
|
|
2492
|
+
const stoppedAt = task.status === 'aborted' && !task.interruption && task.runId ? await readInterruption(join(cfg.resolved.runsDir, task.runId)).catch(() => null) : null;
|
|
2493
|
+
const queued = await this.store.continueTask(threadId, taskId, stoppedAt);
|
|
2494
|
+
await appendSessionLog(cfg.resolved.runsDir, threadId, {
|
|
2495
|
+
type: 'continue',
|
|
2496
|
+
message: `"${queued.title}" carried on as attempt ${queued.attempt ?? 1}, from where it stopped: ${task.reason ?? task.status}`,
|
|
2497
|
+
data: { taskId, attempt: queued.attempt, was: task.status },
|
|
2498
|
+
}).catch(() => undefined);
|
|
2499
|
+
this.bus.publish({ sessionId: threadId, taskId, type: 'task-requeued', level: 'info', message: `"${queued.title}" carried on from where it stopped` });
|
|
2500
|
+
return await this.start(threadId, cfg.execution.mode);
|
|
2501
|
+
}
|
|
2502
|
+
answerQuestion(approvalId, text, ran, outcome, chosen, as) {
|
|
2231
2503
|
const w = this.waiting.get(approvalId);
|
|
2232
2504
|
if (!w?.resolveAnswer)
|
|
2233
2505
|
return { ok: false, problem: 'No question of the lead is waiting under that id.' };
|
|
2506
|
+
// Kerrigan never answers commands handed over to run (2026-11-12): those are the operator's.
|
|
2507
|
+
if (as && w.approval.question?.handoff)
|
|
2508
|
+
return { ok: false, problem: 'Commands handed over to run are the operator\'s to answer.' };
|
|
2509
|
+
const who = as ? 'Kerrigan' : 'the operator';
|
|
2234
2510
|
// A question of several answers (2026-11-02): the ones chosen, by their place, and what was written besides.
|
|
2235
2511
|
if (chosen !== undefined && w.approval.question && !w.approval.question.handoff) {
|
|
2236
2512
|
const many = chosenAnswer(w.approval.question, chosen, text);
|
|
2237
2513
|
if ('problem' in many)
|
|
2238
2514
|
return { ok: false, problem: many.problem };
|
|
2239
2515
|
this.waiting.delete(approvalId);
|
|
2240
|
-
w.resolveAnswer(many);
|
|
2516
|
+
w.resolveAnswer({ ...many, ...(as ? { by: as.by } : {}) });
|
|
2241
2517
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2242
|
-
message:
|
|
2518
|
+
message: `${who} chose ${many.chosen.length} of the answers${as?.why ? ` — ${as.why}` : ''}`, data: { approvalId, question: true, ...(as ? { by: as.by } : {}) } });
|
|
2243
2519
|
return { ok: true };
|
|
2244
2520
|
}
|
|
2245
2521
|
/*
|
|
@@ -2255,9 +2531,9 @@ let OperatorService = class OperatorService {
|
|
|
2255
2531
|
if (!handed && !text.trim())
|
|
2256
2532
|
return { ok: false, problem: 'Write the answer first.' };
|
|
2257
2533
|
this.waiting.delete(approvalId);
|
|
2258
|
-
w.resolveAnswer(handed ? { answer: text.trim(), ran: how === 'ran', outcome: how } : { answer: text.trim() });
|
|
2534
|
+
w.resolveAnswer(handed ? { answer: text.trim(), ran: how === 'ran', outcome: how } : { answer: text.trim(), ...(as ? { by: as.by } : {}) });
|
|
2259
2535
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2260
|
-
message:
|
|
2536
|
+
message: `${who} answered: ${text.trim().slice(0, 200)}${as?.why ? ` — ${as.why}` : ''}`, data: { approvalId, question: true, ...(as ? { by: as.by } : {}) } });
|
|
2261
2537
|
return { ok: true };
|
|
2262
2538
|
}
|
|
2263
2539
|
/**
|
|
@@ -2290,13 +2566,14 @@ let OperatorService = class OperatorService {
|
|
|
2290
2566
|
this.parkLater(approval);
|
|
2291
2567
|
this.bus.publish({ sessionId: ask.sessionId, taskId: ask.taskId, type: 'approval-requested', level: 'warn',
|
|
2292
2568
|
message: `the plan of "${ask.title}" (version ${ask.plan.version}) is waiting for you to approve it`, data: { approvalId: approval.id, plan: true } });
|
|
2569
|
+
ask.onCard?.(this.cardHandle(approval.id, (a, why) => this.decidePlan(approval.id, a.decision, a.note, { by: 'kerrigan', why })));
|
|
2293
2570
|
});
|
|
2294
2571
|
}
|
|
2295
2572
|
/**
|
|
2296
2573
|
* Answers a plan waiting for approval: approve it (with a note the chat is given beside it), ask for
|
|
2297
2574
|
* another (saying what to change), or stop the task.
|
|
2298
2575
|
*/
|
|
2299
|
-
decidePlan(approvalId, action, note) {
|
|
2576
|
+
decidePlan(approvalId, action, note, as) {
|
|
2300
2577
|
const w = this.waiting.get(approvalId);
|
|
2301
2578
|
if (!w || !w.resolvePlan)
|
|
2302
2579
|
return { ok: false, problem: 'That plan is not waiting any more.' };
|
|
@@ -2306,14 +2583,15 @@ let OperatorService = class OperatorService {
|
|
|
2306
2583
|
if (text.length > MAX_INSTRUCTION_CHARS)
|
|
2307
2584
|
return { ok: false, problem: `The note is ${text.length} characters; it can be at most ${MAX_INSTRUCTION_CHARS}.` };
|
|
2308
2585
|
this.waiting.delete(approvalId);
|
|
2309
|
-
w.resolvePlan({ decision: action, ...(text ? { note: text } : {}) });
|
|
2586
|
+
w.resolvePlan({ decision: action, ...(text ? { note: text } : {}), ...(as ? { by: as.by } : {}) });
|
|
2310
2587
|
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2311
|
-
message: `plan: ${action}${text ? ' (with a note)' : ''}`, data: { approvalId, action, plan: true } });
|
|
2588
|
+
message: `plan: ${action}${text ? ' (with a note)' : ''}${as ? `, by Kerrigan${as.why ? ` — ${as.why}` : ''}` : ''}`, data: { approvalId, action, plan: true, ...(as ? { by: as.by } : {}) } });
|
|
2312
2589
|
return { ok: true };
|
|
2313
2590
|
}
|
|
2314
2591
|
/** What waits for the operator; of one session, its worker's included (two chats: they are asked in its conversation). */
|
|
2315
2592
|
pendingApprovals(sessionId) {
|
|
2316
|
-
|
|
2593
|
+
// Kerrigan's (2026-11-12): the cards of the chats she directs, and of their workers, are shown in hers too.
|
|
2594
|
+
return [...this.waiting.values()].map((w) => w.approval).filter((a) => !sessionId || this.under(a.sessionId, sessionId));
|
|
2317
2595
|
}
|
|
2318
2596
|
/**
|
|
2319
2597
|
* Answers one pending approval.
|
|
@@ -2836,7 +3114,10 @@ let OperatorService = class OperatorService {
|
|
|
2836
3114
|
const defaultModel = cfg.copilot.defaultModel ?? '';
|
|
2837
3115
|
const defaultReviewModel = cfg.copilot.defaultReviewModel ?? '';
|
|
2838
3116
|
const defaultLeadModel = cfg.copilot.defaultLeadModel ?? '';
|
|
2839
|
-
|
|
3117
|
+
const defaultKerriganModel = cfg.copilot.defaultKerriganModel ?? '';
|
|
3118
|
+
return cached
|
|
3119
|
+
? { ...cached, defaultModel, defaultLeadModel, defaultKerriganModel, defaultReviewModel }
|
|
3120
|
+
: { defaultModel, defaultLeadModel, defaultKerriganModel, defaultReviewModel, options: [], readAt: null };
|
|
2840
3121
|
}
|
|
2841
3122
|
/**
|
|
2842
3123
|
* Sets the model a new session's independent review starts on. An empty name clears it,
|
|
@@ -2855,6 +3136,18 @@ let OperatorService = class OperatorService {
|
|
|
2855
3136
|
});
|
|
2856
3137
|
return { defaultLeadModel: name.trim() };
|
|
2857
3138
|
}
|
|
3139
|
+
/** Sets the model Kerrigan's conversation starts on (2026-11-13). An empty name: the lead's, else the worker's. */
|
|
3140
|
+
async setDefaultKerriganModel(name) {
|
|
3141
|
+
await this.init();
|
|
3142
|
+
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultKerriganModel: name.trim() } }));
|
|
3143
|
+
this.bus.publish({
|
|
3144
|
+
sessionId: '*',
|
|
3145
|
+
type: 'default-kerrigan-model-changed',
|
|
3146
|
+
level: 'info',
|
|
3147
|
+
message: name.trim() ? `Kerrigan will start on ${name.trim()}` : "Kerrigan starts on the lead's model",
|
|
3148
|
+
});
|
|
3149
|
+
return { defaultKerriganModel: name.trim() };
|
|
3150
|
+
}
|
|
2858
3151
|
async setDefaultReviewModel(name) {
|
|
2859
3152
|
await this.init();
|
|
2860
3153
|
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultReviewModel: name.trim() } }));
|
|
@@ -3002,15 +3295,19 @@ let OperatorService = class OperatorService {
|
|
|
3002
3295
|
const work = (saved.defaultModel ?? '').trim();
|
|
3003
3296
|
const review = (saved.defaultReviewModel ?? '').trim();
|
|
3004
3297
|
const lead = (saved.defaultLeadModel ?? '').trim();
|
|
3298
|
+
const kerrigan = (saved.defaultKerriganModel ?? '').trim();
|
|
3005
3299
|
const workNow = work ? pageModelFor(work, options) : null;
|
|
3006
3300
|
const reviewNow = review ? pageModelFor(review, options) : null;
|
|
3007
3301
|
const leadNow = lead ? pageModelFor(lead, options) : null;
|
|
3302
|
+
const kerriganNow = kerrigan ? pageModelFor(kerrigan, options) : null;
|
|
3008
3303
|
if (workNow && !sameModel(workNow.name, work))
|
|
3009
3304
|
await this.setDefaultModel(workNow.name);
|
|
3010
3305
|
if (reviewNow && !sameModel(reviewNow.name, review))
|
|
3011
3306
|
await this.setDefaultReviewModel(reviewNow.name);
|
|
3012
3307
|
if (leadNow && !sameModel(leadNow.name, lead))
|
|
3013
3308
|
await this.setDefaultLeadModel(leadNow.name);
|
|
3309
|
+
if (kerriganNow && !sameModel(kerriganNow.name, kerrigan))
|
|
3310
|
+
await this.setDefaultKerriganModel(kerriganNow.name);
|
|
3014
3311
|
return catalogue;
|
|
3015
3312
|
}
|
|
3016
3313
|
finally {
|