copilot-operator 0.1.75 → 0.1.80
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 +7 -4
- package/dist/src/api/operator.service.js +73 -20
- package/dist/src/config/live.js +122 -0
- package/dist/src/exec/commandHeads.js +11 -2
- package/dist/src/exec/locations.js +194 -0
- package/dist/src/exec/network.js +3 -1
- package/dist/src/exec/scriptFiles.js +46 -21
- package/dist/src/exec/stops.js +147 -0
- package/dist/src/orchestrator/chosenAnswers.js +22 -0
- package/dist/src/orchestrator/handoff.js +37 -2
- package/dist/src/orchestrator/leadRunner.js +39 -22
- package/dist/src/orchestrator/taskRunner.js +129 -50
- package/dist/src/plan/kerrigan.js +2 -2
- package/dist/src/plan/systemGuide.js +38 -22
- package/dist/src/protocol/leadSchema.js +6 -1
- package/dist/src/protocol/replySchema.js +6 -0
- package/dist/src/queue/queue.js +6 -0
- package/dist/src/session/model.js +12 -0
- package/dist/src/util/pacing.js +6 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-17c74da39fb738c9.js +1 -0
- package/dist/web/_next/static/chunks/1077.ad76ce55c8120db5.js +1 -0
- package/dist/web/_next/static/chunks/1548.4dc2e419eee42487.js +1 -0
- package/dist/web/_next/static/chunks/2163.9f5c1d052712579f.js +1 -0
- package/dist/web/_next/static/chunks/714.3f04498b624bc1a4.js +1 -0
- package/dist/web/_next/static/chunks/7220.43612a34a3cb5146.js +1 -0
- package/dist/web/_next/static/chunks/7921-df716a0338420836.js +1 -0
- package/dist/web/_next/static/chunks/8124-2f07cc63c1494443.js +1 -0
- package/dist/web/_next/static/chunks/8584.36fd8289becb2d75.js +1 -0
- package/dist/web/_next/static/chunks/895-9c1f0751920e6624.js +1 -0
- package/dist/web/_next/static/chunks/9067.eff8198294aec025.js +1 -0
- package/dist/web/_next/static/chunks/9747.43e5b7201aa505ba.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-b8a1e0075a48b025.js +1 -0
- package/dist/web/_next/static/chunks/app/page-4a7cf5d83c000d73.js +1 -0
- package/dist/web/_next/static/chunks/app/queue/{page-82f724d0842f4870.js → page-317151444eda8115.js} +1 -1
- package/dist/web/_next/static/chunks/app/settings/page-ec85a538fda29964.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-f9f820c51a8952c8.js → webpack-a7f5c4d1eda36000.js} +1 -1
- package/dist/web/_next/static/css/0e586e29189e8783.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 +4 -3
- package/prompts/lead1.md +5 -2
- package/prompts/level1.md +8 -2
- package/dist/web/_next/static/chunks/1024-67625a65f58057ae.js +0 -1
- package/dist/web/_next/static/chunks/1077.14d6c828d8f71111.js +0 -1
- package/dist/web/_next/static/chunks/1548.2f75926c6e664f79.js +0 -1
- package/dist/web/_next/static/chunks/2163.f9f1ad4af05520cc.js +0 -1
- package/dist/web/_next/static/chunks/714.4507656685cb9337.js +0 -1
- package/dist/web/_next/static/chunks/7220.9bc9dd9f211b11e4.js +0 -1
- package/dist/web/_next/static/chunks/7921-9aaec581982b2329.js +0 -1
- package/dist/web/_next/static/chunks/8124-a39d85dff0db6600.js +0 -1
- package/dist/web/_next/static/chunks/8584.f2cb3ca81223d626.js +0 -1
- package/dist/web/_next/static/chunks/9067.a6cb3b9157a80921.js +0 -1
- package/dist/web/_next/static/chunks/9747.15aa40a046d54a2a.js +0 -1
- package/dist/web/_next/static/chunks/9929-2e0b1d006ebd5345.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-52a2079ffa83c21f.js +0 -1
- package/dist/web/_next/static/chunks/app/page-80730838a81da226.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-4f3c739287d7f32e.js +0 -1
- package/dist/web/_next/static/css/63b30b8e1a4aa500.css +0 -1
- /package/dist/web/_next/static/{9DmRzBb0M5BZ3dvVpbFMM → NP3hd8WmgkJYg_cn8gcXy}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{9DmRzBb0M5BZ3dvVpbFMM → NP3hd8WmgkJYg_cn8gcXy}/_ssgManifest.js +0 -0
|
@@ -32,6 +32,7 @@ import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
|
32
32
|
import { basename, dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
33
33
|
import { gitSync, RUNNER_EMAIL } from '../vcs/git.js';
|
|
34
34
|
import { scanCommandHeads } from './commandHeads.js';
|
|
35
|
+
import { foldersAlong } from './locations.js';
|
|
35
36
|
import { packageScriptsRun, packageScriptWritten, writesPackageScripts } from './npmScripts.js';
|
|
36
37
|
import { DEFAULT_SCRIPT_RULES, kindForChat, kindOfFile } from './scriptKinds.js';
|
|
37
38
|
/** Larger than this is not a step's script; it is not read, and running it is refused. */
|
|
@@ -40,8 +41,8 @@ const MAX_SCRIPT_BYTES = 256 * 1024;
|
|
|
40
41
|
export function scriptPathsRun(command) {
|
|
41
42
|
const paths = new Set();
|
|
42
43
|
const patterns = [
|
|
43
|
-
/\b(?:pwsh|powershell)(?:\.exe)?\b[^|;\n]*?\s-(?:File|f)\s+(?:"([^"]+)"|'([^']+)'|(
|
|
44
|
-
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.ps1)"|'([^']+\.ps1)'|(
|
|
44
|
+
/\b(?:pwsh|powershell)(?:\.exe)?\b[^|;\n]*?\s-(?:File|f)\s+(?:"([^"]+)"|'([^']+)'|([^\s;|&)}]+))/gi,
|
|
45
|
+
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.ps1)"|'([^']+\.ps1)'|([^\s;|&)}]+\.ps1))(?=$|[\s;|&)}])/gi,
|
|
45
46
|
];
|
|
46
47
|
for (const re of patterns) {
|
|
47
48
|
for (const m of command.matchAll(re)) {
|
|
@@ -56,10 +57,14 @@ export function scriptPathsRun(command) {
|
|
|
56
57
|
export function writesScript(command) {
|
|
57
58
|
return /\b(Set-Content|Add-Content|Out-File|New-Item|Copy-Item|Move-Item|Rename-Item|sc|ac|cp|copy|mv|move|ren|ni)\b[^|;\n]*\.ps1\b|>\s*["']?[^\s"']*\.ps1\b/i.test(command);
|
|
58
59
|
}
|
|
59
|
-
/** Reads the scripts a command runs, relative to `cwd
|
|
60
|
+
/** Reads the scripts a command runs, relative to `cwd`, or to the folder the line has moved to (`foldersAlong`). */
|
|
60
61
|
export function scriptFilesRun(command, cwd) {
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const paths = new Set();
|
|
63
|
+
for (const seg of foldersAlong(command, cwd)) {
|
|
64
|
+
for (const p of scriptPathsRun(seg.text))
|
|
65
|
+
paths.add(isAbsolute(p) ? p : resolve(seg.cwd, p));
|
|
66
|
+
}
|
|
67
|
+
return [...paths].map((path) => {
|
|
63
68
|
try {
|
|
64
69
|
const size = statSync(path).size;
|
|
65
70
|
if (size > MAX_SCRIPT_BYTES)
|
|
@@ -101,21 +106,35 @@ const RUNS_A_FILE = String.raw `(?:node|nodejs|python3?|py|pwsh|powershell|cmd|t
|
|
|
101
106
|
* Windows Script Host's `.vbs`, `.wsf` and the rest — as full paths:
|
|
102
107
|
* given to `-File`, dot-sourced, called with `&` or by a path, passed to `cmd /c`, started with Start-Process, or
|
|
103
108
|
* imported as a module. A bare name counts only when that file is in the folder, where cmd and Start-Process look
|
|
104
|
-
* first; otherwise it is a program found on PATH — `npm.cmd`, `npx.cmd` — and not one of the project's files.
|
|
109
|
+
* first; otherwise it is a program found on PATH — `npm.cmd`, `npx.cmd` — and not one of the project's files. Each is
|
|
110
|
+
* looked for in the folder the line is in where it runs it (`foldersAlong`, 2026-11-03).
|
|
105
111
|
*/
|
|
106
|
-
export function shellScriptsRun(command, cwd) {
|
|
112
|
+
export function shellScriptsRun(command, cwd, shell) {
|
|
113
|
+
return alongTheLine(command, cwd, shell, shellScriptsRunIn);
|
|
114
|
+
}
|
|
115
|
+
/** What `find` gives for each stretch of the line in its own folder, each file once. */
|
|
116
|
+
function alongTheLine(command, cwd, shell, find) {
|
|
117
|
+
const files = new Map();
|
|
118
|
+
for (const seg of foldersAlong(command, cwd, shell)) {
|
|
119
|
+
for (const file of find(seg.text, seg.cwd))
|
|
120
|
+
if (!files.has(file.toLowerCase()))
|
|
121
|
+
files.set(file.toLowerCase(), file);
|
|
122
|
+
}
|
|
123
|
+
return [...files.values()];
|
|
124
|
+
}
|
|
125
|
+
function shellScriptsRunIn(command, cwd) {
|
|
107
126
|
const named = new Set(scriptPathsRun(command));
|
|
108
127
|
const patterns = [
|
|
109
|
-
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:ps1|psm1|cmd|bat))"|'([^']+\.(?:ps1|psm1|cmd|bat))'|(
|
|
110
|
-
/\bcmd(?:\.exe)?\b[^|;\n]*?\s\/[ck]\s+(?:"([^"]+\.(?:cmd|bat))"|'([^']+\.(?:cmd|bat))'|(
|
|
128
|
+
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:ps1|psm1|cmd|bat))"|'([^']+\.(?:ps1|psm1|cmd|bat))'|([^\s;|&)}]+\.(?:ps1|psm1|cmd|bat)))(?=$|[\s;|&)}])/gi,
|
|
129
|
+
/\bcmd(?:\.exe)?\b[^|;\n]*?\s\/[ck]\s+(?:"([^"]+\.(?:cmd|bat))"|'([^']+\.(?:cmd|bat))'|([^\s;|&)}]+\.(?:cmd|bat)))/gi,
|
|
111
130
|
/\b(?:Start-Process|saps)\b[^|;\n]*?(?:"([^"]+\.(?:ps1|cmd|bat))"|'([^']+\.(?:ps1|cmd|bat))'|([^\s'",]+\.(?:ps1|cmd|bat)))/gi,
|
|
112
|
-
/\b(?:Import-Module|ipmo)\b[^|;\n]*?(?:"([^"]+\.psm1)"|'([^']+\.psm1)'|(
|
|
131
|
+
/\b(?:Import-Module|ipmo)\b[^|;\n]*?(?:"([^"]+\.psm1)"|'([^']+\.psm1)'|([^\s;|&)}]+\.psm1))/gi,
|
|
113
132
|
// A shell script for bash and its kin (Git Bash, WSL), by a path or given to the shell.
|
|
114
|
-
/(?:^|[|;&(\n{]\s*)(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|(
|
|
115
|
-
/\b(?:bash|sh|zsh|ksh|dash|wsl)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|(
|
|
133
|
+
/(?:^|[|;&(\n{]\s*)(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|([^\s;|&)}]+\.(?:sh|bash|zsh)))(?=$|[\s;|&)}])/gi,
|
|
134
|
+
/\b(?:bash|sh|zsh|ksh|dash|wsl)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|([^\s;|&)}]+\.(?:sh|bash|zsh)))/gi,
|
|
116
135
|
// Windows Script Host's scripts.
|
|
117
|
-
/\b(?:wscript|cscript)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:vbs|vbe|js|jse|wsf|wsh))"|'([^']+\.(?:vbs|vbe|js|jse|wsf|wsh))'|(
|
|
118
|
-
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:vbs|vbe|wsf|wsh|hta))"|'([^']+\.(?:vbs|vbe|wsf|wsh|hta))'|(
|
|
136
|
+
/\b(?:wscript|cscript)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:vbs|vbe|js|jse|wsf|wsh))"|'([^']+\.(?:vbs|vbe|js|jse|wsf|wsh))'|([^\s;|&)}]+\.(?:vbs|vbe|js|jse|wsf|wsh)))/gi,
|
|
137
|
+
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:vbs|vbe|wsf|wsh|hta))"|'([^']+\.(?:vbs|vbe|wsf|wsh|hta))'|([^\s;|&)}]+\.(?:vbs|vbe|wsf|wsh|hta)))(?=$|[\s;|&)}])/gi,
|
|
119
138
|
];
|
|
120
139
|
for (const re of patterns) {
|
|
121
140
|
for (const m of command.matchAll(re)) {
|
|
@@ -218,9 +237,12 @@ function startedProcesses(command) {
|
|
|
218
237
|
* started with Start-Process (`Start-Process node -ArgumentList x.js`). The first argument that is not a switch is the
|
|
219
238
|
* file; a line whose first one is not a file of code (`node --version`, `python -m pytest`) gives none. The project's
|
|
220
239
|
* test runners are not this (operator, 2026-10-26: "tests as before"): `node --test` is left alone, as are `npm test`,
|
|
221
|
-
* `npx playwright test` and the rest, which are not runtimes given a file.
|
|
240
|
+
* `npx playwright test` and the rest, which are not runtimes given a file. Each in the folder the line is in there.
|
|
222
241
|
*/
|
|
223
242
|
export function codeFilesRun(command, cwd, shell) {
|
|
243
|
+
return alongTheLine(command, cwd, shell, (text, folder) => codeFilesRunIn(text, folder, shell));
|
|
244
|
+
}
|
|
245
|
+
function codeFilesRunIn(command, cwd, shell) {
|
|
224
246
|
const files = new Set();
|
|
225
247
|
const add = (literal) => void files.add(isAbsolute(literal) ? literal : resolve(cwd, literal));
|
|
226
248
|
for (const call of [...scanCommandHeads(command, shell ?? 'pwsh').calls, ...startedProcesses(command)]) {
|
|
@@ -343,7 +365,7 @@ export function scriptsRun(command, cwd, since, shell) {
|
|
|
343
365
|
seen.add(key);
|
|
344
366
|
return true;
|
|
345
367
|
};
|
|
346
|
-
for (const file of shellScriptsRun(command, cwd)) {
|
|
368
|
+
for (const file of shellScriptsRun(command, cwd, shell)) {
|
|
347
369
|
if (first(file))
|
|
348
370
|
out.push({ file, kind: kindOfFile(file, /\.jse?$/i.test(file)), written: notTheProjects(file, since), shell: true });
|
|
349
371
|
}
|
|
@@ -353,13 +375,16 @@ export function scriptsRun(command, cwd, since, shell) {
|
|
|
353
375
|
const written = inScratch(file) ? `it is in ${SCRATCH}, the folder for scratch files` : writesFileNamed(command, file) ? SAME_LINE : writtenDuringTheWork(file, since);
|
|
354
376
|
out.push({ file, kind: kindOfFile(file), written });
|
|
355
377
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
378
|
+
const segments = foldersAlong(command, cwd, shell);
|
|
379
|
+
for (const seg of segments) {
|
|
380
|
+
for (const m of seg.text.matchAll(SCRATCH_RUN)) {
|
|
381
|
+
const file = resolve(seg.cwd, m[1]);
|
|
382
|
+
if (first(file))
|
|
383
|
+
out.push({ file, kind: kindOfFile(file), written: `it is in ${SCRATCH}, the folder for scratch files` });
|
|
384
|
+
}
|
|
360
385
|
}
|
|
361
386
|
const sameLine = writesPackageScripts(command);
|
|
362
|
-
for (const run of packageScriptsRun(
|
|
387
|
+
for (const run of segments.flatMap((seg) => packageScriptsRun(seg.text, seg.cwd, shell))) {
|
|
363
388
|
const written = packageScriptWritten(run, since, sameLine);
|
|
364
389
|
// No such script and nothing writes it: npm says so, and nothing runs.
|
|
365
390
|
if (run.command === null && written === null)
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lines that stop what they should not (operator, 2026-11-03: "this command stops the cop package — it kills its
|
|
3
|
+
* terminal outright"). Two of them, read with the lexer (`commandHeads.ts`) so that a word in a string is not taken
|
|
4
|
+
* for a command:
|
|
5
|
+
*
|
|
6
|
+
* - `stopsTheBot`: a line or a script that stops processes by the name the bot runs under — `node`, which is the bot
|
|
7
|
+
* itself, its API and its web page, and `msedge`, the window its chat is in — or by the bot's own port. An
|
|
8
|
+
* environment switch that "restarts the server" with `Stop-Process -Name node` stops the bot with it, whichever
|
|
9
|
+
* terminal it is typed in. The runner refuses it in a step; the card of commands handed over says so.
|
|
10
|
+
* - `endsTheShell`: a line handed to the operator that ends the PowerShell it is typed in — `exit`, and its kin. The
|
|
11
|
+
* chat writes one out of habit, to pass on an exit code, as a step run in a process of its own would; typed into
|
|
12
|
+
* the operator's open terminal, it closes that terminal, and what it printed with it, which is what the operator
|
|
13
|
+
* was asked to send back.
|
|
14
|
+
*/
|
|
15
|
+
import { scanCommandHeads } from './commandHeads.js';
|
|
16
|
+
/** The programs and cmdlets that stop processes: by name, by id, or by a filter given to them. */
|
|
17
|
+
const KILL_HEADS = new Set([
|
|
18
|
+
'stop-process', 'spps', 'kill', 'taskkill', 'tskill', 'pkill', 'killall', 'kill-port', 'fkill', 'wmic',
|
|
19
|
+
'remove-ciminstance', 'invoke-cimmethod', 'invoke-wmimethod', 'remove-wmiobject',
|
|
20
|
+
]);
|
|
21
|
+
/** The cmdlets that list processes, to hand to one that stops them. */
|
|
22
|
+
const LIST_HEADS = new Set(['get-process', 'gps', 'ps', 'get-ciminstance', 'gcim', 'get-wmiobject', 'gwmi']);
|
|
23
|
+
/** The cmdlets and programs that say which process listens on a port. */
|
|
24
|
+
const PORT_HEADS = new Set(['get-nettcpconnection', 'get-netudpendpoint', 'findstr', 'select-string', 'sls', 'grep', 'kill-port', 'fkill']);
|
|
25
|
+
/** A process stopped by a method of its own: `(Get-Process node).Kill()`, a CIM instance's `Terminate()`. */
|
|
26
|
+
const KILL_METHOD = /\.\s*(?:Kill|Terminate)\s*\(/i;
|
|
27
|
+
/** A filter by name on a list of processes: `Where-Object { $_.Name -eq 'node' }`, `-Filter "Name='node.exe'"`. */
|
|
28
|
+
const NAME_FILTER = /\b(?:Process)?Name\b['"]?\s*(?:-[ic]?(?:eq|like|match)\s*|=\s*\\?)['"]?\*?(node|msedge)(?:\.exe)?\b/i;
|
|
29
|
+
/** The bot's own processes, by the names a line stops them under. */
|
|
30
|
+
const BOT_PROCESSES = [
|
|
31
|
+
{ name: 'node', what: 'the bot itself runs on node (its API and its web page)' },
|
|
32
|
+
{ name: 'msedge', what: "the bot's chat is in an Edge window" },
|
|
33
|
+
];
|
|
34
|
+
/** The operator's terminal, by the names a line stops it under. */
|
|
35
|
+
const SHELL_PROCESSES = ['pwsh', 'powershell', 'cmd', 'windowsterminal', 'conhost', 'wt'];
|
|
36
|
+
/** A head as compared: its file name, lower case, without the extension Windows adds. */
|
|
37
|
+
const headName = (head) => (head.split(/[\\/]/).pop() ?? head).toLowerCase().replace(/\.(?:exe|cmd|bat|com)$/, '');
|
|
38
|
+
/** The words in a call's literal arguments, quoted ones split too: `"IMAGENAME eq node.exe"` gives three. */
|
|
39
|
+
function words(call) {
|
|
40
|
+
return call.args.filter((a) => !a.dynamic).flatMap((a) => a.literal.split(/[\s,;=()'"]+/)).filter(Boolean);
|
|
41
|
+
}
|
|
42
|
+
/** The programs that stop a process only when told to: `wmic … delete`, `Invoke-CimMethod -MethodName Terminate`. */
|
|
43
|
+
const KILL_WHEN_TOLD = new Set(['wmic', 'invoke-cimmethod', 'invoke-wmimethod']);
|
|
44
|
+
/** Whether the call stops processes: a cmdlet or program for it, or `npx kill-port`. */
|
|
45
|
+
function isKill(call) {
|
|
46
|
+
const head = headName(call.head);
|
|
47
|
+
if (head === 'npx')
|
|
48
|
+
return words(call).some((w) => /^(?:kill-port|fkill(?:-cli)?)$/i.test(w));
|
|
49
|
+
if (!KILL_HEADS.has(head))
|
|
50
|
+
return false;
|
|
51
|
+
return !KILL_WHEN_TOLD.has(head) || words(call).some((w) => /^(?:delete|terminate)$/i.test(w));
|
|
52
|
+
}
|
|
53
|
+
/** Whether a word, as a process name with PowerShell's and taskkill's wildcards, takes in `name`. */
|
|
54
|
+
function namesProcess(word, name) {
|
|
55
|
+
if (/^[-/]/.test(word))
|
|
56
|
+
return false;
|
|
57
|
+
const bare = word.replace(/\.exe$/i, '');
|
|
58
|
+
if (!/[*?[]/.test(bare))
|
|
59
|
+
return bare.toLowerCase() === name;
|
|
60
|
+
const pattern = bare.replace(/[.+^${}()|\\]/g, '\\$&').replace(/\*/g, '.*').replace(/\?/g, '.');
|
|
61
|
+
try {
|
|
62
|
+
return new RegExp(`^${pattern}$`, 'i').test(name);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** The process among `names` that the line stops by name, or null. */
|
|
69
|
+
function stoppedByName(text, calls, names) {
|
|
70
|
+
const kills = calls.filter(isKill);
|
|
71
|
+
if (kills.length === 0 && !KILL_METHOD.test(text))
|
|
72
|
+
return null;
|
|
73
|
+
const named = (call) => {
|
|
74
|
+
for (const w of words(call)) {
|
|
75
|
+
const hit = names.find((n) => namesProcess(w, n));
|
|
76
|
+
if (hit)
|
|
77
|
+
return hit;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
for (const c of kills) {
|
|
82
|
+
const hit = named(c);
|
|
83
|
+
if (hit)
|
|
84
|
+
return hit;
|
|
85
|
+
}
|
|
86
|
+
for (const c of calls.filter((x) => LIST_HEADS.has(headName(x.head)))) {
|
|
87
|
+
const hit = named(c);
|
|
88
|
+
if (hit)
|
|
89
|
+
return hit;
|
|
90
|
+
}
|
|
91
|
+
const filter = NAME_FILTER.exec(text);
|
|
92
|
+
if (filter && names.includes(filter[1].toLowerCase()))
|
|
93
|
+
return filter[1].toLowerCase();
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/** The bot's port that the line stops a process on, or null: `Get-NetTCPConnection -LocalPort 4000 | … Stop-Process`. */
|
|
97
|
+
function stoppedByPort(text, calls, ports) {
|
|
98
|
+
if (!calls.some(isKill) && !KILL_METHOD.test(text))
|
|
99
|
+
return null;
|
|
100
|
+
for (const c of calls) {
|
|
101
|
+
const head = headName(c.head);
|
|
102
|
+
if (!PORT_HEADS.has(head) && head !== 'npx')
|
|
103
|
+
continue;
|
|
104
|
+
for (const w of words(c)) {
|
|
105
|
+
const n = Number(w.replace(/^:/, ''));
|
|
106
|
+
if (Number.isInteger(n) && ports.includes(n))
|
|
107
|
+
return n;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Why a line or a script must not run because it stops the bot, or null. `ports` are the bot's own (`botPorts`).
|
|
114
|
+
*/
|
|
115
|
+
export function stopsTheBot(text, ports) {
|
|
116
|
+
const { calls } = scanCommandHeads(text);
|
|
117
|
+
const name = stoppedByName(text, calls, BOT_PROCESSES.map((p) => p.name));
|
|
118
|
+
const port = name ? null : stoppedByPort(text, calls, ports);
|
|
119
|
+
if (!name && port === null)
|
|
120
|
+
return null;
|
|
121
|
+
const what = name ? `every process named ${name}, and ${BOT_PROCESSES.find((p) => p.name === name).what}` : `the process on port ${port}, which is the bot's own`;
|
|
122
|
+
return (`refused: this stops ${what}, so it stops the bot too, and the task with it. Stop only the process the work started: ` +
|
|
123
|
+
'by the id Start-Process -PassThru gave for it, or by the port it listens on (Get-NetTCPConnection -LocalPort <its port>), ' +
|
|
124
|
+
'never by the name node or msedge.');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Why a line typed into the operator's own terminal would end that terminal, or null: `exit` anywhere outside a
|
|
128
|
+
* string, `[Environment]::Exit`, `$host.SetShouldExit`, its own process stopped by `$PID`, or the shell stopped by name.
|
|
129
|
+
*/
|
|
130
|
+
export function endsTheShell(line) {
|
|
131
|
+
const scan = scanCommandHeads(line);
|
|
132
|
+
if (scan.exits)
|
|
133
|
+
return '"exit" closes the PowerShell it is typed in';
|
|
134
|
+
if (/\[\s*(?:System\.)?Environment\s*\]\s*::\s*Exit\s*\(/i.test(line))
|
|
135
|
+
return '[Environment]::Exit closes the PowerShell it is typed in';
|
|
136
|
+
if (/\$host\s*\.\s*SetShouldExit\s*\(/i.test(line))
|
|
137
|
+
return '$host.SetShouldExit closes the PowerShell it is typed in';
|
|
138
|
+
if (/\bGetCurrentProcess\s*\(\s*\)\s*\.\s*Kill\s*\(/i.test(line))
|
|
139
|
+
return 'stopping its own process closes the PowerShell it is typed in';
|
|
140
|
+
const own = scan.calls.some((c) => isKill(c) && c.args.some((a) => /^\$pid$/i.test(a.literal.trim())));
|
|
141
|
+
if (own || /\b(?:Stop-Process|spps|kill)\b[^;|\n]*\$PID\b/i.test(line))
|
|
142
|
+
return 'stopping $PID closes the PowerShell it is typed in';
|
|
143
|
+
const shell = stoppedByName(line, scan.calls, SHELL_PROCESSES);
|
|
144
|
+
if (shell)
|
|
145
|
+
return `stopping every ${shell} process closes the terminal it is typed in`;
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A question whose answers may be chosen more than one at a time (operator, 2026-11-02: "can the chat offer options not
|
|
3
|
+
* only as radio buttons but as check boxes — more than one choice; I do not want them to look like radio buttons or
|
|
4
|
+
* check boxes"): the answers chosen, by their place, checked against the question, and the answer they make — the
|
|
5
|
+
* chosen ones as a list, with what the operator wrote under it. The card in the chat and the card of a queue task set
|
|
6
|
+
* aside at the question answer through it alike.
|
|
7
|
+
*/
|
|
8
|
+
export function chosenAnswer(question, picks, written) {
|
|
9
|
+
if (!question.multiple)
|
|
10
|
+
return { problem: 'This question takes one answer: press it, or write one.' };
|
|
11
|
+
const valid = Array.isArray(picks) && picks.length > 0 && picks.every((n) => Number.isInteger(n) && n >= 0 && n < question.options.length);
|
|
12
|
+
if (!valid)
|
|
13
|
+
return { problem: 'Choose at least one of the answers offered.' };
|
|
14
|
+
const chosen = [...new Set(picks)].sort((a, b) => a - b).map((n) => question.options[n]);
|
|
15
|
+
const text = written.trim();
|
|
16
|
+
return { answer: [chosen.map((c) => `- ${c}`).join('\n'), text].filter(Boolean).join('\n\n'), chosen, ...(text ? { written: text } : {}) };
|
|
17
|
+
}
|
|
18
|
+
/** What the chat or the lead is told after "The operator answered your question, ": the ones chosen, and what was written besides. */
|
|
19
|
+
export function chosenSaid(a) {
|
|
20
|
+
const n = a.chosen.length;
|
|
21
|
+
return [`choosing ${n === 1 ? 'one' : n} of your answers:`, '', ...a.chosen.map((c) => `- ${c}`), ...(a.written ? ['', 'And wrote:', '', a.written] : [])].join('\n');
|
|
22
|
+
}
|
|
@@ -21,6 +21,8 @@ import { dangerousRefusal } from '../exec/dangerous.js';
|
|
|
21
21
|
import { botSelfRefusal, networkFetchReason } from '../exec/network.js';
|
|
22
22
|
import { matchDenyPattern } from '../exec/policy.js';
|
|
23
23
|
import { platformReason } from '../exec/platforms.js';
|
|
24
|
+
import { codeFilesRun, shellScriptsRun } from '../exec/scriptFiles.js';
|
|
25
|
+
import { endsTheShell } from '../exec/stops.js';
|
|
24
26
|
/** The most of one script shown on the card. */
|
|
25
27
|
const MAX_SHOWN_BYTES = 64 * 1024;
|
|
26
28
|
/** A script larger than this is not read for the card at all. */
|
|
@@ -44,7 +46,20 @@ export function handoffCard(h, cwd, roots, denyPatterns, revision = 1) {
|
|
|
44
46
|
const folder = resolve(cwd, h.cwd ?? '.');
|
|
45
47
|
const texts = [...h.commands];
|
|
46
48
|
const warnings = [];
|
|
47
|
-
|
|
49
|
+
/*
|
|
50
|
+
* The scripts the chat names, and every one its lines run besides (2026-11-03): `Push-Location 'rules-engine';
|
|
51
|
+
* .\switch-env.ps1 qa` went on a card with no script on it, and what the script did was found out when it stopped
|
|
52
|
+
* the bot. The lines are typed one after another in one terminal, so a folder one of them moves to holds for the next.
|
|
53
|
+
*/
|
|
54
|
+
const typed = h.commands.join('\n');
|
|
55
|
+
const named = new Map();
|
|
56
|
+
for (const f of h.files)
|
|
57
|
+
named.set(resolve(folder, f).toLowerCase(), f);
|
|
58
|
+
for (const full of [...shellScriptsRun(typed, folder, 'pwsh'), ...codeFilesRun(typed, folder, 'pwsh')]) {
|
|
59
|
+
if (!named.has(full.toLowerCase()))
|
|
60
|
+
named.set(full.toLowerCase(), full);
|
|
61
|
+
}
|
|
62
|
+
const files = [...named.values()].map((f) => {
|
|
48
63
|
const full = resolve(folder, f);
|
|
49
64
|
const path = relative(cwd, full).replace(/\\/g, '/') || f;
|
|
50
65
|
if (!inside(roots, full))
|
|
@@ -69,7 +84,7 @@ export function handoffCard(h, cwd, roots, denyPatterns, revision = 1) {
|
|
|
69
84
|
}
|
|
70
85
|
});
|
|
71
86
|
h.commands.forEach((line, i) => {
|
|
72
|
-
const why = refusedText(line, denyPatterns);
|
|
87
|
+
const why = refusedText(line, denyPatterns) ?? endsTheShell(line);
|
|
73
88
|
if (why)
|
|
74
89
|
warnings.push(`${i + 1}: ${why}`);
|
|
75
90
|
});
|
|
@@ -125,6 +140,26 @@ export function handoffResultMessage(h, outcome, text) {
|
|
|
125
140
|
`You expected: ${h.expect}\n\nCompare the two and go on with the work from here, in the same format. ` +
|
|
126
141
|
'A script that is not part of the work can be deleted once you have what you needed from it.');
|
|
127
142
|
}
|
|
143
|
+
/** How many times a handoff whose lines end the terminal goes back to the chat before the card shows it, marked. */
|
|
144
|
+
export const MAX_SHELL_ENDING_RETURNS = 2;
|
|
145
|
+
/** Which lines of a handoff end the terminal they are typed in (`endsTheShell`), by their number. */
|
|
146
|
+
export function shellEndingLines(h) {
|
|
147
|
+
return h.commands.flatMap((line, i) => {
|
|
148
|
+
const why = endsTheShell(line);
|
|
149
|
+
return why ? [{ n: i + 1, why }] : [];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* What the chat is told of lines that would end the operator's terminal (operator, 2026-11-03: "this command stops the
|
|
154
|
+
* cop package — it kills its terminal outright"): sent back before the operator sees them, which costs the operator
|
|
155
|
+
* nothing — they would have lost what the lines printed, and the chat what it asked for.
|
|
156
|
+
*/
|
|
157
|
+
export function shellEndingMessage(lines) {
|
|
158
|
+
return (`Not shown to the operator yet: ${lines.map((l) => `line ${l.n} — ${l.why}`).join('; ')}. The operator types these commands ` +
|
|
159
|
+
'into their own open terminal, where that closes the terminal itself, and with it what the commands printed — which is ' +
|
|
160
|
+
'what you ask them to send back. Hand them over again with status "handoff": the same commands, without it. To show how ' +
|
|
161
|
+
"they ended, print it instead, for example Write-Output ('EXIT=' + $LASTEXITCODE).");
|
|
162
|
+
}
|
|
128
163
|
/** What the chat is told when nobody is here to run them: the terminal's run, or one with nobody to ask. */
|
|
129
164
|
export const HANDOFF_NOBODY = 'Nobody is here to run the commands you handed over: this run has nobody to ask. Go on with the work without them, ' +
|
|
130
165
|
'or end blocked and say in "needed" what the operator has to run and what it should show.';
|
|
@@ -31,6 +31,7 @@ import { operatorNotesSection, whyItStopped } from '../session/compose.js';
|
|
|
31
31
|
import { describeDeviations } from '../protocol/replySchema.js';
|
|
32
32
|
import { leadFormatErrorMessage, parseLeadReply, UNDERSTANDING_FIRST } from '../protocol/leadSchema.js';
|
|
33
33
|
import { describePlan, planFrom } from './planMode.js';
|
|
34
|
+
import { chosenSaid } from './chosenAnswers.js';
|
|
34
35
|
import { closeLedger, describeLedger, nextLedger } from './leadLedger.js';
|
|
35
36
|
import { classifySubtaskEnd, describeAttempts, FAILURE_WORDS, retryMessage, retryPlan, sanitizedReason, sideEffectsOf, stepFacts, stepsOf } from './subtaskRetry.js';
|
|
36
37
|
import { ACTOR_WORDS, applySessionModel, enterSessionConversation, holdsWhilePaused, limitsMessageLength, redactsMessages, runTask, Sink, speakFor, StoppedSend } from './taskRunner.js';
|
|
@@ -159,8 +160,10 @@ export function leadPlanRevise(comment, version) {
|
|
|
159
160
|
].join('\n');
|
|
160
161
|
}
|
|
161
162
|
/** The operator's answer to the lead's question. */
|
|
162
|
-
export function operatorAnswerMessage(answer, left) {
|
|
163
|
-
|
|
163
|
+
export function operatorAnswerMessage(answer, left, many) {
|
|
164
|
+
// A question of several answers (2026-11-02): the ones chosen, one a line, and what was written besides.
|
|
165
|
+
const said = many ? ['The operator answered your question, ' + chosenSaid(many)] : ['The operator answers your question:', '', answer.trim()];
|
|
166
|
+
return [...said, '', `Go on in the lead's format. Subtasks left: ${left}.`].join('\n');
|
|
164
167
|
}
|
|
165
168
|
/** Nobody can answer the lead's question (a run with no page to ask on). */
|
|
166
169
|
export const NOBODY_TO_ASK = 'Nobody can answer a question in this run: decide it yourself, the way that keeps the most options open, say the assumption in "notes", and go on.';
|
|
@@ -236,6 +239,8 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
236
239
|
signal,
|
|
237
240
|
onGap: (ms) => sink.event('pacing-gap', { ms, lead: true }, `the next message to the lead waits ${Math.ceil(ms / 1000)} s: Settings ask for a pause between messages`),
|
|
238
241
|
});
|
|
242
|
+
// The pauses as Settings have them when one is saved while the lead works (2026-11-03); the worker's task says the rest.
|
|
243
|
+
const unlive = deps.live?.onChange(() => pacer.retune({ enabled: cfg.pacing.enabled, settleMs: cfg.pacing.settleMs, maxMessagesPerHour: cfg.pacing.maxMessagesPerHour, gapMs: gapFrom(cfg.pacing) })) ?? (() => undefined);
|
|
239
244
|
let limitHit;
|
|
240
245
|
/*
|
|
241
246
|
* Paused (see `Hold`): the lead's next message waits, as the worker's do in `runTask`. True when the run was stopped
|
|
@@ -254,7 +259,9 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
254
259
|
};
|
|
255
260
|
// No message to the lead longer than Settings allow as text: the rest goes attached (2026-10-22).
|
|
256
261
|
const leadChat = redactsMessages(limitsMessageLength(holdsWhilePaused(transport, holdHere), {
|
|
257
|
-
max
|
|
262
|
+
get max() {
|
|
263
|
+
return cfg.limits.maxMessageChars;
|
|
264
|
+
},
|
|
258
265
|
dir: log.path('messages'),
|
|
259
266
|
onLong: ({ chars, max, file }) => sink.event('message-long', { chars, max, file, lead: true }, `a message to the lead of ${chars} characters is over the ${max} sent as text: its beginning is sent, the whole of it attached as ${file}`, 'warn'),
|
|
260
267
|
}), {
|
|
@@ -337,6 +344,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
337
344
|
});
|
|
338
345
|
await record(`TASK ${status.toUpperCase()}`, [summary ?? '', reason ? `Reason: ${reason}` : ''].filter(Boolean).join('\n\n') || '(no details)');
|
|
339
346
|
sink.event('task-finished', { status, reason, iterations: lead.rounds.length, subtasks: lead.subtasks, lead: true }, `task "${task.title}" ${status}${reason ? `: ${reason}` : ''}`);
|
|
347
|
+
unlive();
|
|
340
348
|
await log.close();
|
|
341
349
|
return { status, iterations: lead.rounds.length, summary, reason };
|
|
342
350
|
};
|
|
@@ -433,9 +441,16 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
433
441
|
* many times more, so far apart. Only for two chats.
|
|
434
442
|
*/
|
|
435
443
|
const retrying = {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
444
|
+
// As Settings have them when a subtask is tried again (2026-11-03: a save takes effect at once).
|
|
445
|
+
get mode() {
|
|
446
|
+
return (cfg.limits.subtaskRetryMode ?? 'ask');
|
|
447
|
+
},
|
|
448
|
+
get maxAttempts() {
|
|
449
|
+
return 1 + Math.max(0, Math.min(3, cfg.limits.subtaskRetries ?? 2));
|
|
450
|
+
},
|
|
451
|
+
get waitMs() {
|
|
452
|
+
return Math.max(0, cfg.limits.subtaskRetryWaitSec ?? 15) * 1000;
|
|
453
|
+
},
|
|
439
454
|
};
|
|
440
455
|
/** A pause the run's Stop ends. */
|
|
441
456
|
const pauseFor = (ms) => new Promise((resolve) => {
|
|
@@ -741,37 +756,37 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
741
756
|
else {
|
|
742
757
|
markdown = await tell(assignment);
|
|
743
758
|
}
|
|
744
|
-
const maxFormat = Math.max(0, cfg.limits.maxFormatRetries ?? 2);
|
|
759
|
+
const maxFormat = () => Math.max(0, cfg.limits.maxFormatRetries ?? 2);
|
|
745
760
|
let formatRetries = 0;
|
|
746
761
|
// A message carried on was restated when it began: its first reply now need not do it again.
|
|
747
762
|
let understood = carryingOn;
|
|
748
763
|
let planVersion = 0;
|
|
749
764
|
let revisions = [];
|
|
750
|
-
const maxRounds = Math.max(1, cfg.limits.maxIterations);
|
|
765
|
+
const maxRounds = () => Math.max(1, cfg.limits.maxIterations);
|
|
751
766
|
for (;;) {
|
|
752
767
|
if (signal?.aborted)
|
|
753
768
|
return await finish('aborted', 'stopped by the operator');
|
|
754
|
-
if (lead.rounds.length >= maxRounds) {
|
|
755
|
-
limitHit = { setting: 'maxIterations', value: maxRounds };
|
|
756
|
-
return await finish('limit-reached', `maxIterations (${maxRounds}) reached: the lead's replies`);
|
|
769
|
+
if (lead.rounds.length >= maxRounds()) {
|
|
770
|
+
limitHit = { setting: 'maxIterations', value: maxRounds() };
|
|
771
|
+
return await finish('limit-reached', `maxIterations (${maxRounds()}) reached: the lead's replies`);
|
|
757
772
|
}
|
|
758
773
|
const parsed = parseLeadReply(markdown);
|
|
759
774
|
if (!parsed.ok) {
|
|
760
775
|
formatRetries += 1;
|
|
761
|
-
if (formatRetries > maxFormat) {
|
|
762
|
-
limitHit = { setting: 'maxFormatRetries', value: maxFormat };
|
|
763
|
-
return await finish('limit-reached', `maxFormatRetries (${maxFormat}) reached: the lead's replies did not match its format (${parsed.detail})`);
|
|
776
|
+
if (formatRetries > maxFormat()) {
|
|
777
|
+
limitHit = { setting: 'maxFormatRetries', value: maxFormat() };
|
|
778
|
+
return await finish('limit-reached', `maxFormatRetries (${maxFormat()}) reached: the lead's replies did not match its format (${parsed.detail})`);
|
|
764
779
|
}
|
|
765
|
-
sink.event('lead-format-retry', { reason: parsed.reason, detail: parsed.detail, retry: formatRetries }, `the lead's reply did not match its format, asked again (${formatRetries} of ${maxFormat})`, 'warn');
|
|
766
|
-
markdown = await tell(leadFormatErrorMessage(parsed, formatRetries, maxFormat));
|
|
780
|
+
sink.event('lead-format-retry', { reason: parsed.reason, detail: parsed.detail, retry: formatRetries }, `the lead's reply did not match its format, asked again (${formatRetries} of ${maxFormat()})`, 'warn');
|
|
781
|
+
markdown = await tell(leadFormatErrorMessage(parsed, formatRetries, maxFormat()));
|
|
767
782
|
continue;
|
|
768
783
|
}
|
|
769
784
|
const r = parsed.reply;
|
|
770
785
|
if (!understood && !r.understanding) {
|
|
771
786
|
formatRetries += 1;
|
|
772
|
-
if (formatRetries > maxFormat) {
|
|
773
|
-
limitHit = { setting: 'maxFormatRetries', value: maxFormat };
|
|
774
|
-
return await finish('limit-reached', `maxFormatRetries (${maxFormat}) reached: the lead did not restate the assignment`);
|
|
787
|
+
if (formatRetries > maxFormat()) {
|
|
788
|
+
limitHit = { setting: 'maxFormatRetries', value: maxFormat() };
|
|
789
|
+
return await finish('limit-reached', `maxFormatRetries (${maxFormat()}) reached: the lead did not restate the assignment`);
|
|
775
790
|
}
|
|
776
791
|
markdown = await tell(UNDERSTANDING_FIRST);
|
|
777
792
|
continue;
|
|
@@ -845,7 +860,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
845
860
|
break;
|
|
846
861
|
}
|
|
847
862
|
case 'ask': {
|
|
848
|
-
round.question = { text: r.question, ...(r.why ? { why: r.why } : {}), ...(r.options.length > 0 ? { options: r.options } : {}) };
|
|
863
|
+
round.question = { text: r.question, ...(r.why ? { why: r.why } : {}), ...(r.options.length > 0 ? { options: r.options } : {}), ...(r.multiple ? { multiple: true } : {}) };
|
|
849
864
|
await saveLead();
|
|
850
865
|
/*
|
|
851
866
|
* Settings agree with what the bot proposes (2026-10-23): the lead's recommended answer, its first, is taken
|
|
@@ -865,14 +880,16 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
865
880
|
break;
|
|
866
881
|
}
|
|
867
882
|
sink.event('lead-question', { round: round.n, question: r.question }, `the lead asks the operator: ${r.question}`, 'warn');
|
|
868
|
-
const got = await deps.askQuestion({ sessionId: session.id, taskId: task.id, question: r.question, ...(r.why ? { why: r.why } : {}), options: r.options, actor: 'lead' });
|
|
883
|
+
const got = await deps.askQuestion({ sessionId: session.id, taskId: task.id, question: r.question, ...(r.why ? { why: r.why } : {}), options: r.options, ...(r.multiple ? { multiple: true } : {}), actor: 'lead' });
|
|
869
884
|
if (got === 'stop' || signal?.aborted)
|
|
870
885
|
return await finish('aborted', 'the operator stopped the task at the lead\'s question');
|
|
871
886
|
round.question.answer = got.answer;
|
|
887
|
+
if (got.chosen)
|
|
888
|
+
round.question.chosen = got.chosen;
|
|
872
889
|
round.question.at = new Date().toISOString();
|
|
873
890
|
await saveLead();
|
|
874
891
|
sink.event('lead-question-answered', { round: round.n }, 'the operator answered the lead');
|
|
875
|
-
markdown = await tell(operatorAnswerMessage(got.answer, limit - lead.subtasks));
|
|
892
|
+
markdown = await tell(operatorAnswerMessage(got.answer, limit - lead.subtasks, got.chosen ? { chosen: got.chosen, ...(got.written ? { written: got.written } : {}) } : undefined));
|
|
876
893
|
break;
|
|
877
894
|
}
|
|
878
895
|
case 'done': {
|