copilot-operator 0.1.55 → 0.1.57
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/LICENSE +21 -21
- package/README.md +625 -609
- package/dist/src/api/folderPicker.js +22 -22
- package/dist/src/api/operator.controller.js +30 -3
- package/dist/src/api/operator.service.js +96 -10
- package/dist/src/api/security.js +1 -1
- package/dist/src/api/server.js +9 -1
- package/dist/src/api/settings.js +18 -4
- package/dist/src/cli.js +16 -15
- package/dist/src/config/home.js +109 -0
- package/dist/src/config/layout.js +40 -5
- package/dist/src/config/schema.js +5 -1
- package/dist/src/exec/network.js +50 -3
- package/dist/src/orchestrator/leadRunner.js +20 -3
- package/dist/src/orchestrator/review.js +3 -2
- package/dist/src/orchestrator/taskRunner.js +88 -6
- package/dist/src/plan/kerrigan.js +126 -126
- package/dist/src/plan/systemGuide.js +99 -11
- package/dist/src/session/store.js +4 -0
- package/dist/src/session/workspaceGit.js +95 -1
- package/dist/src/transport/profileLock.js +34 -4
- package/dist/web/404.html +3 -3
- package/dist/web/_next/static/chunks/1077.7e88c156c16718c0.js +1 -0
- package/dist/web/_next/static/chunks/1083.0122bea31f7199d9.js +1 -0
- package/dist/web/_next/static/chunks/1490.f5154054ddfd3dee.js +1 -0
- package/dist/web/_next/static/chunks/1536.98fab69162f370f0.js +1 -0
- package/dist/web/_next/static/chunks/1548.a7127a9edf3f266b.js +1 -0
- package/dist/web/_next/static/chunks/1584.7500138d08971f81.js +1 -0
- package/dist/web/_next/static/chunks/1732.90182d376c75c315.js +1 -0
- package/dist/web/_next/static/chunks/17449abc.fa53da036b7dcfb4.js +1 -0
- package/dist/web/_next/static/chunks/1872.d12259d09bb1173f.js +1 -0
- package/dist/web/_next/static/chunks/192.955be0d5fcd27ec6.js +1 -0
- package/dist/web/_next/static/chunks/1920.59b93a4215a75653.js +1 -0
- package/dist/web/_next/static/chunks/2063.4745e20abad5b208.js +1 -0
- package/dist/web/_next/static/chunks/2163.60f52655ceb57752.js +1 -0
- package/dist/web/_next/static/chunks/2175.8c8957600f6b88a8.js +1 -0
- package/dist/web/_next/static/chunks/2280.5a3754f49656d989.js +1 -0
- package/dist/web/_next/static/chunks/2355.d6bb92f10d516f81.js +1 -0
- package/dist/web/_next/static/chunks/2378.4f15342be64a9d23.js +1 -0
- package/dist/web/_next/static/chunks/2395.c2c4d3696d3b5542.js +1 -0
- package/dist/web/_next/static/chunks/2486.d130023b2b399eaa.js +1 -0
- package/dist/web/_next/static/chunks/2606.8e9434e7fee257b9.js +1 -0
- package/dist/web/_next/static/chunks/26dd8e60.1890515693b4ca88.js +1 -0
- package/dist/web/_next/static/chunks/2738.2559ed1058f6fb19.js +1 -0
- package/dist/web/_next/static/chunks/2821.409d92f5ac5b8142.js +1 -0
- package/dist/web/_next/static/chunks/3088.12b1d19ca55225b7.js +1 -0
- package/dist/web/_next/static/chunks/3152.d623d85a9afed5d3.js +1 -0
- package/dist/web/_next/static/chunks/3184.0788c67536fc4140.js +1 -0
- package/dist/web/_next/static/chunks/3194.8ee589997ce1e093.js +1 -0
- package/dist/web/_next/static/chunks/3322.4f7b378a41711478.js +1 -0
- package/dist/web/_next/static/chunks/3564.bfa030e92401f57d.js +1 -0
- package/dist/web/_next/static/chunks/358.4791f77f174006f3.js +1 -0
- package/dist/web/_next/static/chunks/3696.a367f4c8f42909d1.js +1 -0
- package/dist/web/_next/static/chunks/3748.8726b202d79d0dba.js +3 -0
- package/dist/web/_next/static/chunks/3794.19aedfb95f89dc48.js +1 -0
- package/dist/web/_next/static/chunks/384.063f394c789898a7.js +1 -0
- package/dist/web/_next/static/chunks/3854.39b7a1bf2b4189fe.js +1 -0
- package/dist/web/_next/static/chunks/386.2718f961400a3322.js +1 -0
- package/dist/web/_next/static/chunks/4008.3691a32e1711848f.js +1 -0
- package/dist/web/_next/static/chunks/4054.1c8d37b1513d20d8.js +1 -0
- package/dist/web/_next/static/chunks/4328.e326d66dd5c820c6.js +1 -0
- package/dist/web/_next/static/chunks/4444.36f5d8532bd6300d.js +1 -0
- package/dist/web/_next/static/chunks/4512-8bcb4b34f41115b4.js +1 -0
- package/dist/web/_next/static/chunks/4560.b8235d283fb3608c.js +1 -0
- package/dist/web/_next/static/chunks/464.f60ecfb6c72ec733.js +1 -0
- package/dist/web/_next/static/chunks/4912.1ab85b0ebf52a3e0.js +1 -0
- package/dist/web/_next/static/chunks/4982.bbbd303d665de4f0.js +1 -0
- package/dist/web/_next/static/chunks/4fecf3c3.e14d65bd1dce80cf.js +1 -0
- package/dist/web/_next/static/chunks/5052.dc8c36742419eed5.js +1 -0
- package/dist/web/_next/static/chunks/{7496.17282033df0e8794.js → 5115.fbe164892bfd6fa4.js} +1 -1
- package/dist/web/_next/static/chunks/5120.b4aadb89d4fb4f65.js +1 -0
- package/dist/web/_next/static/chunks/5448.1c4e0b719af53b3f.js +1 -0
- package/dist/web/_next/static/chunks/5623.cc6818f4096ce4c2.js +1 -0
- package/dist/web/_next/static/chunks/5664.507fea1f6305067e.js +1 -0
- package/dist/web/_next/static/chunks/5706.be484c6a7bed3fde.js +1 -0
- package/dist/web/_next/static/chunks/6336.b09d0d920c7631eb.js +1 -0
- package/dist/web/_next/static/chunks/6364.5b0466f24f4ecf58.js +1 -0
- package/dist/web/_next/static/chunks/640.2c2baacde5197a77.js +1 -0
- package/dist/web/_next/static/chunks/6419.61399b0413b8bef0.js +1 -0
- package/dist/web/_next/static/chunks/642.b70763e1cfe9e45e.js +1 -0
- package/dist/web/_next/static/chunks/6554.0110334a71e72bbe.js +1 -0
- package/dist/web/_next/static/chunks/6688.4a6ac23ba061262b.js +1 -0
- package/dist/web/_next/static/chunks/6815.6537cc012ba16cca.js +1 -0
- package/dist/web/_next/static/chunks/6896.33fdeb4e682c2cab.js +1 -0
- package/dist/web/_next/static/chunks/6912.3416822e13b4bc03.js +1 -0
- package/dist/web/_next/static/chunks/6944.635230aa8cb23871.js +1 -0
- package/dist/web/_next/static/chunks/6964.35718884ad3375bc.js +1 -0
- package/dist/web/_next/static/chunks/6992.4b059bae2659231d.js +1 -0
- package/dist/web/_next/static/chunks/6996.7c41217972cabc3f.js +1 -0
- package/dist/web/_next/static/chunks/7024.8bc670b892a558bb.js +1 -0
- package/dist/web/_next/static/chunks/7040.e058d8f95c3c11e7.js +1 -0
- package/dist/web/_next/static/chunks/714.bee36b765509e92c.js +1 -0
- package/dist/web/_next/static/chunks/7220.c9c5c5f25baafec7.js +1 -0
- package/dist/web/_next/static/chunks/7250.7f1d45021e49d2fd.js +1 -0
- package/dist/web/_next/static/chunks/7290.7bceed706f7b6df5.js +1 -0
- package/dist/web/_next/static/chunks/7301.c60eb2ba8ae6b859.js +1 -0
- package/dist/web/_next/static/chunks/7328.021e5e45124e40de.js +1 -0
- package/dist/web/_next/static/chunks/7340.a5a75ee889c30b74.js +1 -0
- package/dist/web/_next/static/chunks/7443.c189418756727101.js +1 -0
- package/dist/web/_next/static/chunks/7484.c0e6bfca7b2fb65e.js +1 -0
- package/dist/web/_next/static/chunks/7496.e638a7286c17e438.js +1 -0
- package/dist/web/_next/static/chunks/7695.11ba99db589cb586.js +1 -0
- package/dist/web/_next/static/chunks/7764.e62333ee1d63a458.js +1 -0
- package/dist/web/_next/static/chunks/7921-fb0045927b0e86a8.js +1 -0
- package/dist/web/_next/static/chunks/80.df762af692aca107.js +1 -0
- package/dist/web/_next/static/chunks/8024.4bd0b5a7f26a0f7d.js +1 -0
- package/dist/web/_next/static/chunks/82b69429.c6dd4e5c5ac704f3.js +368 -0
- package/dist/web/_next/static/chunks/8360.371456f14873ee9f.js +1 -0
- package/dist/web/_next/static/chunks/8544.7c1fb012f9073eaa.js +1 -0
- package/dist/web/_next/static/chunks/8547.424f9970cc72775f.js +1 -0
- package/dist/web/_next/static/chunks/8584.97613589db58864f.js +1 -0
- package/dist/web/_next/static/chunks/8616.8e05c4a20dcdf39d.js +1 -0
- package/dist/web/_next/static/chunks/8752.bf29293df3366e17.js +298 -0
- package/dist/web/_next/static/chunks/8800.3c7b01176e98160a.js +1 -0
- package/dist/web/_next/static/chunks/88b2132a.04b02968da05b8a6.js +1005 -0
- package/dist/web/_next/static/chunks/8924.49dd385ac101fb7e.js +1 -0
- package/dist/web/_next/static/chunks/896.eb46d6e001d25d0f.js +1 -0
- package/dist/web/_next/static/chunks/9003.3d5c7a418d0b858b.js +1 -0
- package/dist/web/_next/static/chunks/9067.f7e111c6aa999784.js +1 -0
- package/dist/web/_next/static/chunks/9068.9662bb8fa5fdc637.js +1 -0
- package/dist/web/_next/static/chunks/9178.a7631bd283f2a69c.js +1 -0
- package/dist/web/_next/static/chunks/9190.e3a90b1a9ed21668.js +1 -0
- package/dist/web/_next/static/chunks/9296.59fcfc8261a4c6bd.js +1 -0
- package/dist/web/_next/static/chunks/9312.e1fb4089a122d3d3.js +1 -0
- package/dist/web/_next/static/chunks/9348.022486b05b882739.js +1 -0
- package/dist/web/_next/static/chunks/948.132a0571d85c8b01.js +1 -0
- package/dist/web/_next/static/chunks/951.43a4ba54b1d1ff4e.js +3 -0
- package/dist/web/_next/static/chunks/9544.acc06fe34aa32c5c.js +7 -0
- package/dist/web/_next/static/chunks/9591.d205941f0062de24.js +1 -0
- package/dist/web/_next/static/chunks/9628.d8954a2bd28b85a6.js +1 -0
- package/dist/web/_next/static/chunks/9636.35df6241125f8513.js +1 -0
- package/dist/web/_next/static/chunks/9658.cdecb568f615e4c9.js +782 -0
- package/dist/web/_next/static/chunks/9672.b379566a8bfcd947.js +1 -0
- package/dist/web/_next/static/chunks/9680.d10b204d08ca3a62.js +1 -0
- package/dist/web/_next/static/chunks/9728.1d4cb6c68bd55f44.js +1 -0
- package/dist/web/_next/static/chunks/9747.a5828643aaff11c0.js +1 -0
- package/dist/web/_next/static/chunks/9784.c9938b7e977e14eb.js +1 -0
- package/dist/web/_next/static/chunks/9812.024424a52730b057.js +1 -0
- package/dist/web/_next/static/chunks/9888.ce925cd415b672ef.js +1 -0
- package/dist/web/_next/static/chunks/{9891.91a2c59fd073fd48.js → 9891.a97db7c8f05693d1.js} +1 -1
- package/dist/web/_next/static/chunks/9904.a3d2f8569d7355ab.js +1 -0
- package/dist/web/_next/static/chunks/992.8470b96c23472686.js +1 -0
- package/dist/web/_next/static/chunks/9924.03252dda78c705c3.js +1 -0
- package/dist/web/_next/static/chunks/9968.3d45ff9183e8b07b.js +1 -0
- package/dist/web/_next/static/chunks/app/_not-found/page-23c6c0396966da29.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-4e5be923763ba3d9.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-9cd9b0b0587f4882.js +1 -0
- package/dist/web/_next/static/chunks/app/page-8e85b507af649f85.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-b39878dce98ded94.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-176448acb2c8baa6.js +1 -0
- package/dist/web/_next/static/chunks/{main-app-f747f0f5ddb4213b.js → main-app-d23441ca81b3a063.js} +1 -1
- package/dist/web/_next/static/chunks/webpack-d103630008e57024.js +1 -0
- package/dist/web/_next/static/css/2de713eca93a7750.css +3 -0
- package/dist/web/_next/static/css/4bf77b2aec4626c2.css +1 -0
- package/dist/web/_next/static/css/4bfdd3ebb3d1a180.css +1 -0
- package/dist/web/_next/static/css/73368887921d70d9.css +1 -0
- package/dist/web/_next/static/g2MUlOzNxfAGFR7EI9zQv/_buildManifest.js +1 -0
- package/dist/web/_next/static/media/codicon.5ce2572b.ttf +0 -0
- package/dist/web/_next/static/media/editorWebWorkerMain.828b206c.js +1 -0
- package/dist/web/defaults.html +3 -3
- package/dist/web/defaults.txt +11 -10
- package/dist/web/icon.svg +4 -0
- package/dist/web/index.html +4 -4
- package/dist/web/index.txt +11 -10
- package/dist/web/settings.html +14 -0
- package/dist/web/settings.txt +26 -0
- package/dist/web/system.html +3 -3
- package/dist/web/system.txt +11 -10
- package/dist/web/third-party-notices.txt +5966 -0
- package/package.json +160 -153
- package/prompts/lead1.md +140 -140
- package/prompts/level1.md +574 -574
- package/prompts/review1.md +287 -287
- package/dist/src/context/desktopDir.js +0 -44
- package/dist/web/_next/static/chunks/1077.3c07f38a61cef38a.js +0 -1
- package/dist/web/_next/static/chunks/1548.55dadf800d6c2a79.js +0 -1
- package/dist/web/_next/static/chunks/2163.83d1085b99ac1773.js +0 -1
- package/dist/web/_next/static/chunks/714.88c495053f62f187.js +0 -1
- package/dist/web/_next/static/chunks/7220.f1e8a10d52a7ee87.js +0 -1
- package/dist/web/_next/static/chunks/7500-1353339f7e2eda10.js +0 -1
- package/dist/web/_next/static/chunks/7921-56de379f7bdfbacf.js +0 -1
- package/dist/web/_next/static/chunks/8547.0a9997b67008c706.js +0 -1
- package/dist/web/_next/static/chunks/8584.b34930a6837344a6.js +0 -1
- package/dist/web/_next/static/chunks/9067.5651e8647cef053f.js +0 -1
- package/dist/web/_next/static/chunks/9591.fabd60bd0d10341c.js +0 -1
- package/dist/web/_next/static/chunks/9747.ad6b319cf12169ee.js +0 -1
- package/dist/web/_next/static/chunks/app/_not-found/page-1264c0db9665169c.js +0 -1
- package/dist/web/_next/static/chunks/app/defaults/page-ba24062a86d50e12.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-46efb208d7c88648.js +0 -1
- package/dist/web/_next/static/chunks/app/page-07f80fd07281a230.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-825f53f14d16033d.js +0 -1
- package/dist/web/_next/static/chunks/webpack-ab0451ef95a8f52a.js +0 -1
- package/dist/web/_next/static/css/131c746a9d388eda.css +0 -1
- package/dist/web/_next/static/w1xPyNasTvFr11R3F7HkS/_buildManifest.js +0 -1
- /package/dist/web/_next/static/{w1xPyNasTvFr11R3F7HkS → g2MUlOzNxfAGFR7EI9zQv}/_ssgManifest.js +0 -0
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* Next.js dev server of its own.
|
|
7
7
|
* package `npm i -D copilot-operator` in a project, started with `npx cop start`. The code
|
|
8
8
|
* is in `node_modules`, which `npm install` rewrites whenever it likes, so nothing of
|
|
9
|
-
* the operator's may live there: the records go to
|
|
9
|
+
* the operator's may live there: the records go to the bot's own folder —
|
|
10
|
+
* `%LOCALAPPDATA%\copilot-operator` unless the operator chose another on the System
|
|
11
|
+
* page, or COP_HOME names one (2026-10-22; until then `<project>/.copilot-operator/`) —
|
|
10
12
|
* and the UI is the prebuilt one shipped in the package, served by the API itself.
|
|
11
13
|
*
|
|
12
14
|
* Which one is decided by where the code is: inside a `node_modules` folder is a package. The
|
|
@@ -20,11 +22,37 @@
|
|
|
20
22
|
* data folder or the runs folder asks here instead, so the two installs cannot disagree about
|
|
21
23
|
* where a thing is.
|
|
22
24
|
*/
|
|
23
|
-
import { existsSync } from 'node:fs';
|
|
24
|
-
import {
|
|
25
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
26
|
+
import { homedir } from 'node:os';
|
|
27
|
+
import { basename, dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
25
28
|
import { botRootDir } from '../exec/workDir.js';
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The name of the records folder a package kept inside the project until 2026-10-22 — and still keeps there when the
|
|
31
|
+
* operator chooses that folder. See `defaultHome`.
|
|
32
|
+
*/
|
|
27
33
|
export const HOME_FOLDER = '.copilot-operator';
|
|
34
|
+
/**
|
|
35
|
+
* Where a package keeps its records unless the operator chose another folder (operator, 2026-10-22: "I do not want a
|
|
36
|
+
* .copilot-operator folder in the project's folder unless I set it there"): the user's own local application data,
|
|
37
|
+
* `%LOCALAPPDATA%\copilot-operator`, where the bot's Edge profile already was. Not the folder it was started from —
|
|
38
|
+
* a global install started from C:\ kept everything in C:\.copilot-operator.
|
|
39
|
+
*/
|
|
40
|
+
export function defaultHome(env = process.env) {
|
|
41
|
+
const local = env.LOCALAPPDATA?.trim() || join(env.USERPROFILE?.trim() || homedir(), 'AppData', 'Local');
|
|
42
|
+
return join(local, 'copilot-operator');
|
|
43
|
+
}
|
|
44
|
+
/** The file in the default home that names the folder the operator chose instead: `{ "home": "D:\\bot" }`. */
|
|
45
|
+
export const HOME_CHOICE_FILE = 'location.json';
|
|
46
|
+
/** The folder the operator chose for the records, when they chose one (System → the bot's folder). */
|
|
47
|
+
export function chosenHome(env = process.env) {
|
|
48
|
+
try {
|
|
49
|
+
const value = JSON.parse(readFileSync(join(defaultHome(env), HOME_CHOICE_FILE), 'utf8'));
|
|
50
|
+
return typeof value.home === 'string' && isAbsolute(value.home.trim()) ? resolve(value.home.trim()) : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
28
56
|
/** The project a package install belongs to: the folder holding the `node_modules` the code sits in. */
|
|
29
57
|
function projectOfPackage(botRoot) {
|
|
30
58
|
const parent = dirname(resolve(botRoot));
|
|
@@ -49,7 +77,11 @@ export function installLayout(env = process.env, cwd = process.cwd(), botRoot =
|
|
|
49
77
|
// was started. Checked by folder, so a start from a subfolder of the project still finds it.
|
|
50
78
|
const owner = isInside(cwd, packaged) ? packaged : cwd;
|
|
51
79
|
const projectRoot = resolve(env.COP_PROJECT_ROOT ?? owner);
|
|
52
|
-
|
|
80
|
+
// The operator's own folder by default; another they chose; COP_HOME over both (2026-10-22).
|
|
81
|
+
const fromEnv = env.COP_HOME?.trim() ?? '';
|
|
82
|
+
const chosen = fromEnv ? null : chosenHome(env);
|
|
83
|
+
const homeFrom = fromEnv ? 'env' : chosen ? 'chosen' : 'default';
|
|
84
|
+
const homeDir = resolve(fromEnv || chosen || defaultHome(env));
|
|
53
85
|
const shippedWeb = join(botRoot, 'dist', 'web');
|
|
54
86
|
return {
|
|
55
87
|
mode: 'package',
|
|
@@ -57,6 +89,8 @@ export function installLayout(env = process.env, cwd = process.cwd(), botRoot =
|
|
|
57
89
|
promptsDir,
|
|
58
90
|
projectRoot,
|
|
59
91
|
homeDir,
|
|
92
|
+
homeFrom,
|
|
93
|
+
legacyHomeDir: join(projectRoot, HOME_FOLDER),
|
|
60
94
|
dataDir: resolve(env.COP_DATA_DIR ?? join(homeDir, 'data')),
|
|
61
95
|
runsDir: join(homeDir, 'runs'),
|
|
62
96
|
webDir: existsSync(join(shippedWeb, 'index.html')) ? shippedWeb : null,
|
|
@@ -69,6 +103,7 @@ export function installLayout(env = process.env, cwd = process.cwd(), botRoot =
|
|
|
69
103
|
promptsDir,
|
|
70
104
|
projectRoot,
|
|
71
105
|
homeDir: projectRoot,
|
|
106
|
+
homeFrom: 'checkout',
|
|
72
107
|
dataDir: resolve(env.COP_DATA_DIR ?? join(projectRoot, 'data')),
|
|
73
108
|
runsDir: join(projectRoot, 'runs'),
|
|
74
109
|
/*
|
|
@@ -382,7 +382,11 @@ export const RunConfigSchema = z.object({
|
|
|
382
382
|
maxIterations: z.number().int().positive().default(60),
|
|
383
383
|
maxRunMinutes: z.number().int().positive().default(240),
|
|
384
384
|
maxFormatRetries: z.number().int().nonnegative().default(2),
|
|
385
|
-
|
|
385
|
+
/*
|
|
386
|
+
* The most characters of one message sent to the chat as text (operator, 2026-10-22: 120 000 by default, set in
|
|
387
|
+
* Settings → Execution): a longer one goes as its beginning with the whole of it attached (`limitsMessageLength`).
|
|
388
|
+
*/
|
|
389
|
+
maxMessageChars: z.number().int().min(1000).max(1_000_000).default(120_000),
|
|
386
390
|
/**
|
|
387
391
|
* How many times a task may be sent back because its checks did not pass.
|
|
388
392
|
*
|
package/dist/src/exec/network.js
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
import { existsSync } from 'node:fs';
|
|
53
53
|
import { dirname, join, resolve } from 'node:path';
|
|
54
54
|
import { botRootDir } from './workDir.js';
|
|
55
|
+
import { chosenHome, defaultHome, installLayout } from '../config/layout.js';
|
|
55
56
|
const FETCHERS = [
|
|
56
57
|
{ name: 'Invoke-WebRequest', pattern: /\b(Invoke-WebRequest|iwr)\b/i },
|
|
57
58
|
{ name: 'Invoke-RestMethod', pattern: /\b(Invoke-RestMethod|irm)\b/i },
|
|
@@ -279,13 +280,24 @@ export function networkFetchReason(command, cwd) {
|
|
|
279
280
|
* `127.0.0.1:4000` and answer its own held download. The token is no longer passed (`stepEnv.ts`);
|
|
280
281
|
* this refuses the attempt as well, so a step that goes looking gets a reason instead of a 401.
|
|
281
282
|
*/
|
|
282
|
-
export function botSelfRefusal(command, ports = botPorts(), root = botRootDir()) {
|
|
283
|
+
export function botSelfRefusal(command, ports = botPorts(), root = botRootDir(), homes = botHomeFolders()) {
|
|
283
284
|
const port = `(?:${ports.map((p) => String(Math.trunc(p))).join('|')})`;
|
|
284
285
|
const host = String.raw `(?:localhost|127(?:\.\d{1,3}){3}|\[::1\]|0\.0\.0\.0|::1)`;
|
|
285
286
|
// The folders the bot keeps its records in, by path: its data, its runs, its update backups.
|
|
286
|
-
const folded = command
|
|
287
|
-
const own = root
|
|
287
|
+
const folded = foldPath(command);
|
|
288
|
+
const own = foldPath(root).replace(/\\+$/, '');
|
|
288
289
|
const reachesRecords = ['data', 'runs', 'data-backups'].some((d) => folded.includes(`${own}\\${d}`));
|
|
290
|
+
/*
|
|
291
|
+
* The bot's own folder (2026-10-22): its settings, conversations, logs, its key and its Edge profile, kept in the
|
|
292
|
+
* user's local application data by default and wherever the operator chose otherwise — by its path, and the default
|
|
293
|
+
* one by the variables that spell it as well.
|
|
294
|
+
*/
|
|
295
|
+
const reachesHome = homes.some((h) => namesFolder(folded, foldPath(h).replace(/\\+$/, ''))) ||
|
|
296
|
+
(/appdata|localapplicationdata/i.test(command) && /(?:^|[\s'"`=(\\/,;])copilot-operator(?![\w-])/i.test(command));
|
|
297
|
+
if (reachesHome) {
|
|
298
|
+
return ("refused: this reaches the bot's own folder — its settings, conversations, logs, its key and its Edge profile. " +
|
|
299
|
+
'The bot that runs the task is not part of the work; leave that folder alone.');
|
|
300
|
+
}
|
|
289
301
|
/*
|
|
290
302
|
* Installed from npm, the bot is a dependency of the very project it works on: its code sits in
|
|
291
303
|
* the project's `node_modules`, its records in the project's `.copilot-operator`, and both are
|
|
@@ -306,6 +318,41 @@ export function botSelfRefusal(command, ports = botPorts(), root = botRootDir())
|
|
|
306
318
|
}
|
|
307
319
|
return null;
|
|
308
320
|
}
|
|
321
|
+
/** A path or a command as compared here: one backslash for any run of slashes, lower case. */
|
|
322
|
+
function foldPath(text) {
|
|
323
|
+
return text.replace(/[\\/]+/g, '\\').toLowerCase();
|
|
324
|
+
}
|
|
325
|
+
/** Whether `folded` names `folder` itself or something in it — not a folder whose name merely starts the same. */
|
|
326
|
+
function namesFolder(folded, folder) {
|
|
327
|
+
if (!folder)
|
|
328
|
+
return false;
|
|
329
|
+
for (let i = folded.indexOf(folder); i >= 0; i = folded.indexOf(folder, i + 1)) {
|
|
330
|
+
const next = folded[i + folder.length];
|
|
331
|
+
if (next === undefined || /[\\\s'"`;|),]/.test(next))
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
/** The bot's folders as this process found them when it started: a folder chosen since takes effect at the next start. */
|
|
337
|
+
const homesAtStart = (() => {
|
|
338
|
+
try {
|
|
339
|
+
const layout = installLayout();
|
|
340
|
+
// A clone's folder is the clone, whose records are found by `root` above; its data may be elsewhere (COP_DATA_DIR).
|
|
341
|
+
return layout.mode === 'package' ? [layout.homeDir, layout.dataDir] : [layout.dataDir];
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
})();
|
|
347
|
+
/**
|
|
348
|
+
* The folders that hold the bot's records apart from its code: its folder now, the one its next start will use, and
|
|
349
|
+
* the default one — which holds a clone's Edge profile and the pointer to a chosen folder, so a step that rewrote it
|
|
350
|
+
* would move the bot's records where it likes.
|
|
351
|
+
*/
|
|
352
|
+
export function botHomeFolders(env = process.env) {
|
|
353
|
+
const next = chosenHome(env);
|
|
354
|
+
return [...new Set([...homesAtStart, defaultHome(env), ...(next ? [next] : [])])];
|
|
355
|
+
}
|
|
309
356
|
/** The ports the bot's API and web page listen on. */
|
|
310
357
|
export function botPorts(env = process.env) {
|
|
311
358
|
const api = Number(env.COP_API_PORT ?? 4000);
|
|
@@ -32,7 +32,7 @@ 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
34
|
import { closeLedger, describeLedger, nextLedger } from './leadLedger.js';
|
|
35
|
-
import { applySessionModel, enterSessionConversation, holdsWhilePaused, runTask, Sink, speakFor, StoppedSend } from './taskRunner.js';
|
|
35
|
+
import { ACTOR_WORDS, applySessionModel, enterSessionConversation, holdsWhilePaused, limitsMessageLength, runTask, Sink, speakFor, StoppedSend } from './taskRunner.js';
|
|
36
36
|
import { DEFAULT_VCS } from '../session/store.js';
|
|
37
37
|
/** The assignment as the lead is given it: the operator's message, and what the runner tells it about the work. */
|
|
38
38
|
export function assignmentMessage(task, n, facts, again) {
|
|
@@ -168,6 +168,14 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
168
168
|
const setTask = async (mutate) => {
|
|
169
169
|
await store.updateTask(session.id, task.id, mutate);
|
|
170
170
|
};
|
|
171
|
+
// Who is at work on the message now (2026-10-22): the lead, or the worker on a subtask it was given.
|
|
172
|
+
const actingNow = async (actor, more = {}) => {
|
|
173
|
+
const acting = { actor, since: new Date().toISOString(), ...more };
|
|
174
|
+
await setTask((t) => {
|
|
175
|
+
t.acting = acting;
|
|
176
|
+
});
|
|
177
|
+
sink.event('acting', acting, `at work now: ${ACTOR_WORDS[actor]}${more.subtask ? ` (subtask ${more.subtask})` : ''}`);
|
|
178
|
+
};
|
|
171
179
|
const max = Math.max(1, cfg.limits.maxSubtasks ?? 20);
|
|
172
180
|
const lead = { rounds: [], subtasks: 0, maxSubtasks: max };
|
|
173
181
|
const saveLead = async () => {
|
|
@@ -188,6 +196,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
188
196
|
});
|
|
189
197
|
await writeFile(taskLogPath, `TASK: ${task.title}\nSESSION: ${session.name} (${session.id})\nRUN: ${runId}\nSTARTED: ${new Date().toISOString()}\nMODE: lead and worker\n`, 'utf8');
|
|
190
198
|
sink.event('task-started', { runId, title: task.title, lead: true }, `task "${task.title}" starting with a lead and a worker (run ${runId})`);
|
|
199
|
+
await actingNow('lead');
|
|
191
200
|
// The folder before the message, for "go back" and for what the whole of it changed.
|
|
192
201
|
const chatDir = session.projectDir?.trim() ?? '';
|
|
193
202
|
let checkpoint = task.checkpoint;
|
|
@@ -227,7 +236,12 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
227
236
|
sink.event('task-resumed', { heldMs: Date.now() - from, stopped }, stopped ? 'stopped while paused' : 'continued by the operator');
|
|
228
237
|
return stopped;
|
|
229
238
|
};
|
|
230
|
-
|
|
239
|
+
// No message to the lead longer than Settings allow as text: the rest goes attached (2026-10-22).
|
|
240
|
+
const leadChat = limitsMessageLength(holdsWhilePaused(transport, holdHere), {
|
|
241
|
+
max: cfg.limits.maxMessageChars,
|
|
242
|
+
dir: log.path('messages'),
|
|
243
|
+
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'),
|
|
244
|
+
});
|
|
231
245
|
let sent = 0;
|
|
232
246
|
let replies = 0;
|
|
233
247
|
/** One message to the lead, and its reply. */
|
|
@@ -291,6 +305,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
291
305
|
if (vcs)
|
|
292
306
|
t.vcs = vcs;
|
|
293
307
|
t.status = status;
|
|
308
|
+
delete t.acting;
|
|
294
309
|
t.finishedAt = new Date().toISOString();
|
|
295
310
|
const held = deps.hold?.pausedSince(leadStartedAt) ?? 0;
|
|
296
311
|
if (held > 0)
|
|
@@ -399,6 +414,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
399
414
|
round.subtask = { n, taskId: made.id, title: sub.title, ...(sub.readOnly ? { readOnly: true } : {}), ...(sub.freshWorker ? { fresh: true } : {}) };
|
|
400
415
|
await saveLead();
|
|
401
416
|
sink.event('subtask-given', { n, taskId: made.id, title: sub.title, readOnly: sub.readOnly, fresh: sub.freshWorker }, `subtask ${n} to the worker: ${sub.title}`);
|
|
417
|
+
await actingNow('worker', { subtask: n });
|
|
402
418
|
// To the worker's conversation, in the same window.
|
|
403
419
|
speakFor(transport, worker.id);
|
|
404
420
|
const fresh = !worker.chat;
|
|
@@ -434,6 +450,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
434
450
|
if (signal?.aborted)
|
|
435
451
|
return 'stopped';
|
|
436
452
|
sink.event('subtask-ended', { n, status: out.status }, `subtask ${n} ${out.status}`);
|
|
453
|
+
await actingNow('lead');
|
|
437
454
|
// Back to the lead's conversation.
|
|
438
455
|
const leadNow = (await store.getSession(session.id));
|
|
439
456
|
await enterSessionConversation(transport, leadNow, { closeOnFailure: false });
|
|
@@ -556,7 +573,7 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
556
573
|
await record(`THE LEAD'S PLAN (version ${planVersion})`, describePlan(plan));
|
|
557
574
|
let approved;
|
|
558
575
|
if (facts.planApproval && deps.approvePlan) {
|
|
559
|
-
const answer = await deps.approvePlan({ sessionId: session.id, taskId: task.id, title: task.title, plan });
|
|
576
|
+
const answer = await deps.approvePlan({ sessionId: session.id, taskId: task.id, title: task.title, plan, actor: 'lead' });
|
|
560
577
|
if (answer.decision === 'stop' || signal?.aborted)
|
|
561
578
|
return await finish('aborted', 'the operator stopped the task at the lead\'s plan');
|
|
562
579
|
if (answer.decision === 'revise') {
|
|
@@ -261,8 +261,8 @@ export async function runReview(transport, session, task, deps) {
|
|
|
261
261
|
// The machine's shells, when they are not what the contract's example assumes — the same note
|
|
262
262
|
// the implementer's conversation opens with, for a conversation working to the same example.
|
|
263
263
|
const machineNote = shellNote(undefined, defaultShell);
|
|
264
|
-
let before = await transport.sendAndConfirm(machineNote ? `${contract}
|
|
265
|
-
|
|
264
|
+
let before = await transport.sendAndConfirm(machineNote ? `${contract}
|
|
265
|
+
|
|
266
266
|
${machineNote}` : contract);
|
|
267
267
|
await transport.waitForReply(before);
|
|
268
268
|
await pacer.throttleSend();
|
|
@@ -468,6 +468,7 @@ ${machineNote}` : contract);
|
|
|
468
468
|
}
|
|
469
469
|
deps.event('review-step-proposed', { round, id: step.id, description: describeStep(step) }, `review step ${step.id}: ${describeStep(step)}`);
|
|
470
470
|
const decision = await authorizer.authorize(step, {
|
|
471
|
+
actor: 'review',
|
|
471
472
|
sessionId: session.id,
|
|
472
473
|
taskId: task.id,
|
|
473
474
|
iteration: iterations,
|
|
@@ -294,6 +294,36 @@ export function holdsWhilePaused(transport, hold) {
|
|
|
294
294
|
},
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The same chat, whose every message is at most `max` characters of text (operator, 2026-10-22: "the most characters
|
|
299
|
+
* the chat takes as text, not as an attached document, set in Settings; and a check that the messages made are not
|
|
300
|
+
* longer"). A longer one — the contract, a task's opening with its brief, a report, a review's — goes as its
|
|
301
|
+
* beginning, said to be only that, with the whole of it attached as a text file beside the files it already had;
|
|
302
|
+
* `onLong` is told of each. Like `holdsWhilePaused`, it holds every message the runner sends, from wherever.
|
|
303
|
+
*/
|
|
304
|
+
export function limitsMessageLength(transport, opts) {
|
|
305
|
+
let n = 0;
|
|
306
|
+
return new Proxy(transport, {
|
|
307
|
+
get(target, key) {
|
|
308
|
+
if (key === 'sendAndConfirm') {
|
|
309
|
+
return async (text, attachments = []) => {
|
|
310
|
+
if (text.length <= opts.max)
|
|
311
|
+
return await target.sendAndConfirm(text, attachments);
|
|
312
|
+
n += 1;
|
|
313
|
+
await mkdir(opts.dir, { recursive: true });
|
|
314
|
+
const file = join(opts.dir, `message-${String(n).padStart(2, '0')}-in-full.txt`);
|
|
315
|
+
await writeFile(file, text, 'utf8');
|
|
316
|
+
const note = `\n\n[This message is ${text.length} characters long, more than the ${opts.max} sent as text: the whole of it is in the attached file ` +
|
|
317
|
+
`${basename(file)}. Read it there and answer it as a whole; what is above is only its beginning.]`;
|
|
318
|
+
opts.onLong?.({ chars: text.length, max: opts.max, file });
|
|
319
|
+
return await target.sendAndConfirm(`${text.slice(0, Math.max(0, opts.max - note.length))}${note}`, [...attachments, file]);
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const value = Reflect.get(target, key, target);
|
|
323
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
}
|
|
297
327
|
/** One place that writes to the transcript, the console and the live stream at once. */
|
|
298
328
|
export class Sink {
|
|
299
329
|
log;
|
|
@@ -546,6 +576,19 @@ async function joinGroupConversation(store, session, bus) {
|
|
|
546
576
|
export function roleOf(session) {
|
|
547
577
|
return session.workerOf ? { role: 'worker' } : session.lead ? { role: 'lead' } : {};
|
|
548
578
|
}
|
|
579
|
+
/** Who is at work, as the run's transcript and the Output panel say it. */
|
|
580
|
+
export const ACTOR_WORDS = { plan: 'the chat writing its plan', lead: 'the lead', worker: 'the worker', review: 'the reviewer' };
|
|
581
|
+
/**
|
|
582
|
+
* Who a session's conversation is, for a card it raises before its first message (2026-10-22): the lead or the worker
|
|
583
|
+
* of two chats, the chat that writes its plan first in plan mode, or else the chat that does the work.
|
|
584
|
+
*/
|
|
585
|
+
export function actorOfSession(session, cfg) {
|
|
586
|
+
if (session.workerOf)
|
|
587
|
+
return 'worker';
|
|
588
|
+
if (session.lead)
|
|
589
|
+
return 'lead';
|
|
590
|
+
return (session.planMode ?? cfg.execution?.planMode ?? 'off') !== 'off' ? 'plan' : 'worker';
|
|
591
|
+
}
|
|
549
592
|
/**
|
|
550
593
|
* Marks a run's failure as one of opening the browser, its profile, the sign-in or the conversation, so the notice of
|
|
551
594
|
* a start that could not begin says "opening the browser" rather than "the run" (2026-10-20: with the batch's own
|
|
@@ -627,6 +670,8 @@ signal) {
|
|
|
627
670
|
const manual = modelByHand(session, cfg) && !!hooks?.askHelp;
|
|
628
671
|
if (!wanted && !manual)
|
|
629
672
|
return {};
|
|
673
|
+
// Whose conversation the card is for: said on it, whichever way it is asked (2026-10-22).
|
|
674
|
+
const asks = { ...roleOf(session), actor: actorOfSession(session, cfg) };
|
|
630
675
|
let result;
|
|
631
676
|
if (manual) {
|
|
632
677
|
/*
|
|
@@ -650,7 +695,7 @@ signal) {
|
|
|
650
695
|
const why = cfg.copilot.manualModel ? 'Settings ask for the model to be chosen by hand' : 'the session asks for the model to be set by hand';
|
|
651
696
|
const hand = wanted && buttonShows(shown, wanted)
|
|
652
697
|
? { result: { ok: true, current: wanted, by: 'already' }, goOnAsItIs: false }
|
|
653
|
-
: await withOperatorHand(transport, wanted, { ok: false, current: shown, reason: why }, hooks, session.id, bus, true,
|
|
698
|
+
: await withOperatorHand(transport, wanted, { ok: false, current: shown, reason: why }, hooks, session.id, bus, true, asks);
|
|
654
699
|
if (!wanted) {
|
|
655
700
|
const now = await transport.currentModel().catch(() => null);
|
|
656
701
|
if (hand.result.ok || hand.goOnAsItIs) {
|
|
@@ -688,7 +733,7 @@ signal) {
|
|
|
688
733
|
return stopped;
|
|
689
734
|
}
|
|
690
735
|
}
|
|
691
|
-
const hand = await withOperatorHand(transport, wanted, result, hooks, session.id, bus, false);
|
|
736
|
+
const hand = await withOperatorHand(transport, wanted, result, hooks, session.id, bus, false, asks);
|
|
692
737
|
result = hand.result;
|
|
693
738
|
const goOnAsItIs = hand.goOnAsItIs;
|
|
694
739
|
const renamed = await followPageModels('model', wanted, result, session, store, hooks, modelFrom);
|
|
@@ -751,7 +796,17 @@ opts = {}) {
|
|
|
751
796
|
? `asking the operator to choose ${what} in the Copilot window (by hand; picker shows "${shown ?? 'nothing'}")`
|
|
752
797
|
: `the chat could not be put on ${what} by the runner; asking the operator to choose it in the Copilot window (picker shows "${shown ?? 'nothing'}")`,
|
|
753
798
|
data: { asked: wanted, shown, why: result.reason ?? '', tries, manual, ...(opts.review ? { review: true } : {}), ...(opts.role ? { role: opts.role } : {}) } });
|
|
754
|
-
const answer = await hooks.askHelp({
|
|
799
|
+
const answer = await hooks.askHelp({
|
|
800
|
+
sessionId,
|
|
801
|
+
asked: wanted,
|
|
802
|
+
shown,
|
|
803
|
+
why: result.reason ?? 'unknown reason',
|
|
804
|
+
tries,
|
|
805
|
+
...(manual ? { manual: true } : {}),
|
|
806
|
+
...(opts.review ? { review: true } : {}),
|
|
807
|
+
...(opts.role ? { role: opts.role } : {}),
|
|
808
|
+
actor: opts.actor ?? (opts.review ? 'review' : opts.role ?? 'worker'),
|
|
809
|
+
});
|
|
755
810
|
if (answer === 'stop')
|
|
756
811
|
return { result, goOnAsItIs: false };
|
|
757
812
|
if (answer === 'continue') {
|
|
@@ -910,6 +965,21 @@ export async function runTask(transport, session, task, deps) {
|
|
|
910
965
|
const setTask = async (mutate) => {
|
|
911
966
|
await store.updateTask(session.id, task.id, mutate);
|
|
912
967
|
};
|
|
968
|
+
/*
|
|
969
|
+
* Who is at work on the task now (2026-10-22): kept on it for the chat and the status bar, and said as an event for
|
|
970
|
+
* the bot's own count of what is going on (`activity`). Only when it changes.
|
|
971
|
+
*/
|
|
972
|
+
let actingAs = null;
|
|
973
|
+
const actingNow = async (actor, more = {}) => {
|
|
974
|
+
if (actingAs === actor && !more.round)
|
|
975
|
+
return;
|
|
976
|
+
actingAs = actor;
|
|
977
|
+
const acting = { actor, since: new Date().toISOString(), ...more };
|
|
978
|
+
await setTask((t) => {
|
|
979
|
+
t.acting = acting;
|
|
980
|
+
});
|
|
981
|
+
sink.event('acting', acting, `at work now: ${ACTOR_WORDS[actor]}${more.round ? ` (round ${more.round})` : ''}`);
|
|
982
|
+
};
|
|
913
983
|
const startedAt = Date.now();
|
|
914
984
|
/*
|
|
915
985
|
* The limit is on the work, not on the pause: the time from "Pause" pressed to "Continue" is taken off (2026-10-21:
|
|
@@ -935,6 +1005,12 @@ export async function runTask(transport, session, task, deps) {
|
|
|
935
1005
|
return stopped;
|
|
936
1006
|
};
|
|
937
1007
|
transport = holdsWhilePaused(transport, () => holdHere('message'));
|
|
1008
|
+
// No message longer than Settings allow as text: the rest goes attached (2026-10-22, see `limitsMessageLength`).
|
|
1009
|
+
transport = limitsMessageLength(transport, {
|
|
1010
|
+
max: cfg.limits.maxMessageChars,
|
|
1011
|
+
dir: log.path('messages'),
|
|
1012
|
+
onLong: ({ chars, max, file }) => sink.event('message-long', { chars, max, file }, `a message of ${chars} characters is over the ${max} sent as text: its beginning is sent, the whole of it attached as ${file}`, 'warn'),
|
|
1013
|
+
});
|
|
938
1014
|
let iterations = 0;
|
|
939
1015
|
/** What the model has declared it could not do as written, merged across every reply. */
|
|
940
1016
|
let deviations = [];
|
|
@@ -1259,6 +1335,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1259
1335
|
if (vcsAfter)
|
|
1260
1336
|
t.vcs = vcsAfter;
|
|
1261
1337
|
t.status = status;
|
|
1338
|
+
delete t.acting;
|
|
1262
1339
|
t.iterations = iterations;
|
|
1263
1340
|
t.finishedAt = new Date().toISOString();
|
|
1264
1341
|
const held = pausedMs();
|
|
@@ -1502,6 +1579,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1502
1579
|
*/
|
|
1503
1580
|
const planMode = session.planMode ?? cfg.execution.planMode ?? 'off';
|
|
1504
1581
|
let planning = planMode !== 'off' && !task.continuing;
|
|
1582
|
+
await actingNow(planning ? 'plan' : 'worker');
|
|
1505
1583
|
const planEnforced = planning && onOwnBranch;
|
|
1506
1584
|
let planVersion = 0;
|
|
1507
1585
|
let planningRounds = 0;
|
|
@@ -2100,6 +2178,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2100
2178
|
// When nothing changed, or nothing was allowed to, the closing account is the product and
|
|
2101
2179
|
// the reviewer is given it — as claims to test. See `Deliverable` in review.ts.
|
|
2102
2180
|
const deliverable = deliverableFor(task, closing, repoDir !== '' || chatChanged !== null, changedFiles);
|
|
2181
|
+
await actingNow('review', { round: reviewRounds });
|
|
2103
2182
|
sink.event('review-started', { round: reviewRounds, model: model || '(the session model)', files: changedFiles.length, deliverable: deliverable?.why }, `an independent review is opening a fresh conversation (round ${reviewRounds} of ${maxReviewRounds})` +
|
|
2104
2183
|
(deliverable ? `; the closing summary goes with it as the product (${deliverable.why})` : ''));
|
|
2105
2184
|
// What is running before the review, so that what the review leaves is its own.
|
|
@@ -2115,7 +2194,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2115
2194
|
const shown = await transport.currentModel().catch(() => null);
|
|
2116
2195
|
picked = model && buttonShows(shown, model)
|
|
2117
2196
|
? { ok: true, current: model, by: 'already' }
|
|
2118
|
-
: (await withOperatorHand(transport, model, { ok: false, current: shown, reason: 'the model is chosen by hand (the review)' }, deps.models, session.id, bus, true, { review: true })).result;
|
|
2197
|
+
: (await withOperatorHand(transport, model, { ok: false, current: shown, reason: 'the model is chosen by hand (the review)' }, deps.models, session.id, bus, true, { review: true, actor: 'review' })).result;
|
|
2119
2198
|
// Stopped on the card: the run stops, as it does on the work's card, and nothing is sent to the review.
|
|
2120
2199
|
if (!picked.ok && signal?.aborted)
|
|
2121
2200
|
throw new StoppedSend();
|
|
@@ -2196,6 +2275,8 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2196
2275
|
sink.event('review-return-failed', { error: String(e) }, `could not return to the task's own conversation after the review: ${e.message}`, 'error');
|
|
2197
2276
|
});
|
|
2198
2277
|
}
|
|
2278
|
+
// The work's own chat again: it fixes what the review found, or closes the task.
|
|
2279
|
+
await actingNow('worker');
|
|
2199
2280
|
// A reviewer that left its own server listening once failed the work for it.
|
|
2200
2281
|
roundLeftovers = [...roundLeftovers, ...(await reap(beforeReview, `review round ${reviewRounds}`))];
|
|
2201
2282
|
/*
|
|
@@ -2601,7 +2682,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2601
2682
|
let answer = { decision: 'approve' };
|
|
2602
2683
|
if (asks) {
|
|
2603
2684
|
sink.event('plan-waiting', { version: planVersion }, `plan ${planVersion} is waiting for the operator`, 'warn');
|
|
2604
|
-
answer = await deps.approvePlan({ sessionId: session.id, taskId: task.id, title: task.title, plan });
|
|
2685
|
+
answer = await deps.approvePlan({ sessionId: session.id, taskId: task.id, title: task.title, plan, actor: 'plan' });
|
|
2605
2686
|
}
|
|
2606
2687
|
if (signal?.aborted || answer.decision === 'stop') {
|
|
2607
2688
|
return await finish('aborted', answer.decision === 'stop' ? 'stopped by the operator at its plan' : 'stopped by the operator', undefined, lastMarkdown);
|
|
@@ -2632,6 +2713,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2632
2713
|
planInForce = { ...plan, approved };
|
|
2633
2714
|
sink.event('plan-approved', { version: planVersion, by: approved.by, ...(approved.note ? { note: approved.note } : {}) }, `plan ${planVersion} approved ${asks ? 'by the operator' : `by the runner — ${why}`}${approved.note ? `, with a note` : ''}`);
|
|
2634
2715
|
planning = false;
|
|
2716
|
+
await actingNow('worker');
|
|
2635
2717
|
message = planApprovedMessage(approved);
|
|
2636
2718
|
}
|
|
2637
2719
|
}
|
|
@@ -2798,7 +2880,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2798
2880
|
t.status = 'waiting-approval';
|
|
2799
2881
|
});
|
|
2800
2882
|
sink.event('step-proposed', { id: step.id, description: describeStep(step) }, `step ${step.id}: ${describeStep(step)}`);
|
|
2801
|
-
const decided = await authorizer.authorize(step, { sessionId: session.id, taskId: task.id, iteration: iterations, confinement });
|
|
2883
|
+
const decided = await authorizer.authorize(step, { sessionId: session.id, taskId: task.id, iteration: iterations, confinement, actor: planning ? 'plan' : 'worker' });
|
|
2802
2884
|
await setTask((t) => {
|
|
2803
2885
|
t.status = 'running';
|
|
2804
2886
|
});
|