copilot-operator 0.1.58 → 0.1.61
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 +89 -1
- package/dist/src/api/operator.service.js +276 -9
- package/dist/src/cli.js +4 -0
- package/dist/src/config/exportHome.js +78 -0
- package/dist/src/config/schema.js +38 -0
- package/dist/src/exec/authorizer.js +16 -4
- package/dist/src/exec/platforms.js +87 -0
- package/dist/src/orchestrator/leadRunner.js +22 -3
- package/dist/src/orchestrator/taskRunner.js +101 -13
- package/dist/src/plan/systemGuide.js +353 -36
- package/dist/src/protocol/parser.js +3 -2
- package/dist/src/protocol/replySchema.js +20 -2
- package/dist/src/queue/queue.js +113 -0
- package/dist/src/transport/copilotTransport.js +263 -131
- package/dist/src/transport/locators.js +119 -33
- package/dist/src/util/zip.js +80 -0
- package/dist/src/vcs/taskVcs.js +25 -1
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/VmnUW8Gr79dsc-Ifk8oGP/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/1077.d84d3a09cffc08c0.js +1 -0
- package/dist/web/_next/static/chunks/1548.03db34ce36acd5d5.js +1 -0
- package/dist/web/_next/static/chunks/2163.56378b27583dfc24.js +1 -0
- package/dist/web/_next/static/chunks/4512-db21be6b8e4eabf4.js +1 -0
- package/dist/web/_next/static/chunks/714.5cc516832a5f44c9.js +1 -0
- package/dist/web/_next/static/chunks/7220.26bb7ae30c8a587a.js +1 -0
- package/dist/web/_next/static/chunks/7921-51a72190643f4b1a.js +1 -0
- package/dist/web/_next/static/chunks/8197-e2fcb43f38a2b4a7.js +1 -0
- package/dist/web/_next/static/chunks/8584.49c69cd6e77d2fd7.js +1 -0
- package/dist/web/_next/static/chunks/9067.7ae4ac6836a74d94.js +1 -0
- package/dist/web/_next/static/chunks/9747.5a244ec2d1b84d29.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-f18945b2fe2c8719.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-d83191667baa1077.js → page-9c0f8e27ab7c8677.js} +1 -1
- package/dist/web/_next/static/chunks/app/queue/page-7d853e6bcbbacf0d.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-1833ace66fc9eb0e.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-3466496814a70b62.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-4da26d364c22b773.js → webpack-047b9e390d242a45.js} +1 -1
- package/dist/web/_next/static/css/{ad8f9884b90fbe47.css → 975a0235944db79c.css} +1 -1
- 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 +14 -0
- package/dist/web/queue.txt +26 -0
- 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 +7 -2
- package/prompts/lead1.md +7 -1
- package/prompts/level1.md +31 -1
- package/dist/web/_next/static/chunks/1077.34c49edcb60b74b8.js +0 -1
- package/dist/web/_next/static/chunks/1548.2e00c25619517e57.js +0 -1
- package/dist/web/_next/static/chunks/2163.896e18423ed494d6.js +0 -1
- package/dist/web/_next/static/chunks/3134-b6a7bc1f267c39aa.js +0 -1
- package/dist/web/_next/static/chunks/4512-8bcb4b34f41115b4.js +0 -1
- package/dist/web/_next/static/chunks/714.97d7b448e3fcd1d0.js +0 -1
- package/dist/web/_next/static/chunks/7220.d4bbc9d12b9971fa.js +0 -1
- package/dist/web/_next/static/chunks/7921-03e96df8fc05c712.js +0 -1
- package/dist/web/_next/static/chunks/8584.502a04a441f41a6d.js +0 -1
- package/dist/web/_next/static/chunks/9067.6d2ab3fd6308b1be.js +0 -1
- package/dist/web/_next/static/chunks/9747.0430cf4a4e70a033.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-9cd9b0b0587f4882.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-832ed3149649b77a.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-176448acb2c8baa6.js +0 -1
- package/dist/web/_next/static/wjvJJpx5dfDucIRnV0mIG/_buildManifest.js +0 -1
- /package/dist/web/_next/static/{wjvJJpx5dfDucIRnV0mIG → VmnUW8Gr79dsc-Ifk8oGP}/_ssgManifest.js +0 -0
|
@@ -115,6 +115,12 @@ export const RunConfigSchema = z.object({
|
|
|
115
115
|
* different from whatever did the work.
|
|
116
116
|
*/
|
|
117
117
|
defaultReviewModel: z.string().default(''),
|
|
118
|
+
/**
|
|
119
|
+
* The model the lead of two chats starts on (operator, 2026-10-23: "Model for the worker, Model for the lead, Model
|
|
120
|
+
* for the review" — `defaultModel` being the worker's: the one chat, or the worker of two chats). Empty leaves the
|
|
121
|
+
* lead's conversation on whatever it is set to.
|
|
122
|
+
*/
|
|
123
|
+
defaultLeadModel: z.string().default(''),
|
|
118
124
|
/**
|
|
119
125
|
* Choose the model by hand (operator's workaround, 2026-10-06): at the start of a run, and of a review's
|
|
120
126
|
* conversation, the runner does not touch the picker; a card in the UI asks the operator to choose the
|
|
@@ -123,6 +129,9 @@ export const RunConfigSchema = z.object({
|
|
|
123
129
|
* user choosing it by hand, and test the bot itself"); off, the runner chooses the model itself.
|
|
124
130
|
*/
|
|
125
131
|
manualModel: z.boolean().default(true),
|
|
132
|
+
/** The lead's and the review's models chosen by hand, each on its own (2026-10-23); absent, as `manualModel`. */
|
|
133
|
+
leadManualModel: z.boolean().optional(),
|
|
134
|
+
reviewManualModel: z.boolean().optional(),
|
|
126
135
|
replyTimeoutSec: z.number().int().positive().default(900),
|
|
127
136
|
signInTimeoutSec: z.number().int().positive().default(900),
|
|
128
137
|
humanWaitSec: z.number().int().positive().default(900),
|
|
@@ -133,6 +142,28 @@ export const RunConfigSchema = z.object({
|
|
|
133
142
|
* runs/ is a folder on disk. The screenshot and the URL are always kept.
|
|
134
143
|
*/
|
|
135
144
|
keepFailurePage: z.boolean().default(false),
|
|
145
|
+
/**
|
|
146
|
+
* The model menu's locators (operator, 2026-10-24: "an option in Settings to edit the general locators, so the
|
|
147
|
+
* user can put the right ones when the page changes"): the picker button, the rows the names are read from, and
|
|
148
|
+
* the templates for a model of the main menu, a provider's row and a model in a provider's menu, with
|
|
149
|
+
* `{$model_name}` / `{$provider_name}` where the name goes. Each one left out, or empty, is the default in
|
|
150
|
+
* `transport/locators.ts`; one that cannot be used is not, and the run says why.
|
|
151
|
+
*/
|
|
152
|
+
pickerLocators: z
|
|
153
|
+
.object({
|
|
154
|
+
button: z.string().optional(),
|
|
155
|
+
rows: z.string().optional(),
|
|
156
|
+
model: z.string().optional(),
|
|
157
|
+
provider: z.string().optional(),
|
|
158
|
+
providerModel: z.string().optional(),
|
|
159
|
+
})
|
|
160
|
+
.optional(),
|
|
161
|
+
/**
|
|
162
|
+
* A picture and the menu's HTML at every step of choosing a model, with what each locator found (operator,
|
|
163
|
+
* 2026-10-24: "an option in Settings to keep this information"), beside the run's other browser files. Off: only
|
|
164
|
+
* a failed choice keeps the menu (models-select-failed.*).
|
|
165
|
+
*/
|
|
166
|
+
pickerSteps: z.boolean().default(false),
|
|
136
167
|
})
|
|
137
168
|
.prefault({}),
|
|
138
169
|
/** Level 1: the base prompt about how the runner works. Shipped with the project; editable in the UI. */
|
|
@@ -169,6 +200,13 @@ export const RunConfigSchema = z.object({
|
|
|
169
200
|
* there, a fetch included, is put in front of a person anyway.
|
|
170
201
|
*/
|
|
171
202
|
networkFetch: z.enum(['ask', 'refuse', 'run']).default('ask'),
|
|
203
|
+
/**
|
|
204
|
+
* The bot's questions (operator, 2026-10-23: "an option in Settings to pass over questions — the user always agrees
|
|
205
|
+
* with what the bot proposes"): `ask` puts them to the operator — a command that reaches a platform with the
|
|
206
|
+
* operator's access (`exec/platforms.ts`), and a chat's or the lead's question with its answers to click; `agree`
|
|
207
|
+
* takes what the bot proposes — the command runs, the recommended answer is given — and says so in the chat.
|
|
208
|
+
*/
|
|
209
|
+
questions: z.enum(['ask', 'agree']).default('ask'),
|
|
172
210
|
/**
|
|
173
211
|
* Plan mode, for every session that does not set its own (see `PlanMode` in session/model.ts): a
|
|
174
212
|
* task's chat first looks at the project read-only and replies with a plan, and the work begins once
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { staticCheck, describeStep } from './policy.js';
|
|
2
2
|
import { networkFetchReason, networkFetchRefusal } from './network.js';
|
|
3
3
|
import { scriptNetworkReason } from './policy.js';
|
|
4
|
+
import { platformReason } from './platforms.js';
|
|
4
5
|
import { createInterface } from 'node:readline/promises';
|
|
5
6
|
import { stdin, stdout } from 'node:process';
|
|
6
7
|
/**
|
|
@@ -31,26 +32,37 @@ export function makeAuthorizer(cfg, ask, signal) {
|
|
|
31
32
|
return blocked;
|
|
32
33
|
const cwd = ctx.confinement?.cwd;
|
|
33
34
|
const network = networkFetchReason(step.cmd, cwd) ?? (cwd ? scriptNetworkReason(step.cmd, cwd) : null);
|
|
35
|
+
// A platform reached with the operator's access (2026-10-23): asked in every mode, unless Settings agree to it.
|
|
36
|
+
const platform = cfg.platformAccess === 'allow' ? null : platformReason(step.cmd, step.shell);
|
|
34
37
|
if (network) {
|
|
35
38
|
if (cfg.mode === 'unattended' && cfg.networkFetch === 'refuse')
|
|
36
39
|
return { action: 'skip', reason: networkFetchRefusal(network) };
|
|
37
|
-
if (cfg.mode === 'unattended' && cfg.networkFetch === 'run')
|
|
40
|
+
if (!platform && cfg.mode === 'unattended' && cfg.networkFetch === 'run')
|
|
38
41
|
return { action: 'run' };
|
|
39
|
-
return await ask(step, ctx, { network });
|
|
42
|
+
return await ask(step, ctx, { network, ...(platform ? { platform } : {}) });
|
|
40
43
|
}
|
|
44
|
+
if (platform)
|
|
45
|
+
return await ask(step, ctx, { platform });
|
|
41
46
|
if (cfg.mode === 'unattended')
|
|
42
47
|
return { action: 'run' };
|
|
43
48
|
return await ask(step, ctx);
|
|
44
49
|
},
|
|
45
50
|
};
|
|
46
51
|
}
|
|
52
|
+
/** What the chat is told when a command to a platform was held and nobody was there to allow it. */
|
|
53
|
+
export function platformRefusal(platform) {
|
|
54
|
+
return (`refused: this command reaches ${platform} with the operator's access, which only the operator may allow, and this run has ` +
|
|
55
|
+
'nobody to ask. Do the work without it, or say in `notes` what is needed there and end `blocked`.');
|
|
56
|
+
}
|
|
47
57
|
/** The terminal version: Enter runs, `s` skips, `q` aborts. */
|
|
48
58
|
export function terminalAuthorizer(cfg, print) {
|
|
49
59
|
return makeAuthorizer(cfg, async (step, _ctx, held) => {
|
|
50
60
|
print('');
|
|
51
61
|
print(` step ${step.id}: ${describeStep(step)}`);
|
|
52
|
-
if (held)
|
|
62
|
+
if (held?.network)
|
|
53
63
|
print(` held: ${held.network}`);
|
|
64
|
+
if (held?.platform)
|
|
65
|
+
print(` held: it reaches ${held.platform} with your access`);
|
|
54
66
|
const rl = createInterface({ input: stdin, output: stdout });
|
|
55
67
|
try {
|
|
56
68
|
const answer = (await rl.question(' [Enter] run [s] skip [q] abort > ')).trim().toLowerCase();
|
|
@@ -75,5 +87,5 @@ export function terminalAuthorizer(cfg, print) {
|
|
|
75
87
|
* those steps.
|
|
76
88
|
*/
|
|
77
89
|
export function unattendedAuthorizer(cfg) {
|
|
78
|
-
return makeAuthorizer({ ...cfg, mode: 'unattended' }, async (_step, _ctx, held) => held ? { action: 'skip', reason: networkFetchRefusal(held.network) } : { action: 'run' });
|
|
90
|
+
return makeAuthorizer({ ...cfg, mode: 'unattended' }, async (_step, _ctx, held) => held?.network ? { action: 'skip', reason: networkFetchRefusal(held.network) } : held?.platform ? { action: 'skip', reason: platformRefusal(held.platform) } : { action: 'run' });
|
|
79
91
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands that reach a platform outside this machine with the operator's own access (operator, 2026-10-23: "it asked
|
|
3
|
+
* me whether to run Azure CLI commands; ask the same for every other such platform — Jira, Vercel, AWS, GitHub —
|
|
4
|
+
* permission must come from the user"). Such a command acts in the operator's name, on their cloud, their tickets,
|
|
5
|
+
* their repositories, their packages: it is put to the operator in every run, an unattended one too, as a download is
|
|
6
|
+
* (`network.ts`), unless Settings say to agree with what the bot proposes (`execution.questions: agree`).
|
|
7
|
+
*
|
|
8
|
+
* Read by the programs a line starts (`commandHeads`, as the shell reads it), not by words anywhere in it: a file
|
|
9
|
+
* that mentions `az` is not a command to Azure.
|
|
10
|
+
*/
|
|
11
|
+
import { commandHeads, externalProgram } from './programs.js';
|
|
12
|
+
/** Platform command-line tools, by the program's name. */
|
|
13
|
+
const TOOLS = {
|
|
14
|
+
az: 'Azure (az)',
|
|
15
|
+
azd: 'Azure Developer CLI (azd)',
|
|
16
|
+
func: 'Azure Functions (func)',
|
|
17
|
+
aws: 'AWS (aws)',
|
|
18
|
+
sam: 'AWS SAM (sam)',
|
|
19
|
+
cdk: 'AWS CDK (cdk)',
|
|
20
|
+
eb: 'AWS Elastic Beanstalk (eb)',
|
|
21
|
+
eksctl: 'AWS EKS (eksctl)',
|
|
22
|
+
gcloud: 'Google Cloud (gcloud)',
|
|
23
|
+
gsutil: 'Google Cloud Storage (gsutil)',
|
|
24
|
+
bq: 'Google BigQuery (bq)',
|
|
25
|
+
gh: 'GitHub (gh)',
|
|
26
|
+
glab: 'GitLab (glab)',
|
|
27
|
+
jira: 'Jira (jira)',
|
|
28
|
+
acli: 'Atlassian (acli)',
|
|
29
|
+
vercel: 'Vercel (vercel)',
|
|
30
|
+
netlify: 'Netlify (netlify)',
|
|
31
|
+
heroku: 'Heroku (heroku)',
|
|
32
|
+
fly: 'Fly.io (fly)',
|
|
33
|
+
flyctl: 'Fly.io (flyctl)',
|
|
34
|
+
firebase: 'Firebase (firebase)',
|
|
35
|
+
doctl: 'DigitalOcean (doctl)',
|
|
36
|
+
wrangler: 'Cloudflare (wrangler)',
|
|
37
|
+
supabase: 'Supabase (supabase)',
|
|
38
|
+
railway: 'Railway (railway)',
|
|
39
|
+
kubectl: 'Kubernetes (kubectl)',
|
|
40
|
+
helm: 'Kubernetes (helm)',
|
|
41
|
+
oc: 'OpenShift (oc)',
|
|
42
|
+
terraform: 'Terraform (terraform)',
|
|
43
|
+
pulumi: 'Pulumi (pulumi)',
|
|
44
|
+
serverless: 'Serverless (serverless)',
|
|
45
|
+
sls: 'Serverless (sls)',
|
|
46
|
+
};
|
|
47
|
+
/** PowerShell modules that sign in to a platform or act on it, by the cmdlet's name. */
|
|
48
|
+
const CMDLETS = [
|
|
49
|
+
[/^(?:connect|disconnect)-azaccount$|^[A-Za-z]+-Az[A-Z]\w*$/, 'Azure (Az PowerShell)'],
|
|
50
|
+
[/^(?:connect|disconnect)-azuread$|^[A-Za-z]+-AzureAD\w*$/, 'Azure AD (AzureAD PowerShell)'],
|
|
51
|
+
[/^(?:connect|disconnect)-mggraph$|^[A-Za-z]+-Mg[A-Z]\w*$/, 'Microsoft Graph (PowerShell)'],
|
|
52
|
+
[/^(?:connect|disconnect)-exchangeonline$|^(?:connect|disconnect)-ippssession$/, 'Exchange Online (PowerShell)'],
|
|
53
|
+
[/^(?:connect|disconnect)-pnponline$|^[A-Za-z]+-PnP[A-Z]\w*$/, 'SharePoint (PnP PowerShell)'],
|
|
54
|
+
[/^(?:connect|disconnect)-microsoftteams$/, 'Microsoft Teams (PowerShell)'],
|
|
55
|
+
[/^(?:connect|disconnect)-msolservice$/, 'Microsoft Online (MSOnline PowerShell)'],
|
|
56
|
+
[/^(?:set|initialize)-awsdefault\w*$|^set-awscredential$/, 'AWS (AWS Tools for PowerShell)'],
|
|
57
|
+
];
|
|
58
|
+
/** Package registries and image registries, written to: publishing, signing in, removing. */
|
|
59
|
+
const REGISTRIES = [
|
|
60
|
+
[/(?:^|[\s;|&(])(?:npm|pnpm|yarn|bun)(?:\.cmd|\.exe)?\s+(?:[^\s;|&]+\s+)*?(?:publish|unpublish|deprecate|login|adduser|logout|owner|token|dist-tag|access)\b/i, 'the npm registry'],
|
|
61
|
+
[/(?:^|[\s;|&(])(?:docker|podman)(?:\.exe)?\s+(?:login|push|logout)\b/i, 'a container registry'],
|
|
62
|
+
[/(?:^|[\s;|&(])dotnet(?:\.exe)?\s+nuget\s+(?:push|delete)\b|(?:^|[\s;|&(])nuget(?:\.exe)?\s+(?:push|delete)\b/i, 'NuGet'],
|
|
63
|
+
[/(?:^|[\s;|&(])twine(?:\.exe)?\s+upload\b/i, 'PyPI (twine)'],
|
|
64
|
+
[/(?:^|[\s;|&(])gem\s+(?:push|yank|signin)\b/i, 'RubyGems'],
|
|
65
|
+
[/(?:^|[\s;|&(])cargo(?:\.exe)?\s+(?:publish|yank|login)\b/i, 'crates.io'],
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* The platform a command reaches with the operator's access, as the card names it, or null. `Connect-AzAccount` is
|
|
69
|
+
* Azure; `npm publish` the npm registry; `az login; gh repo list` the first one met.
|
|
70
|
+
*/
|
|
71
|
+
export function platformReason(command, shell) {
|
|
72
|
+
for (const head of commandHeads(command, shell)) {
|
|
73
|
+
const program = externalProgram(head);
|
|
74
|
+
if (program && TOOLS[program.toLowerCase()])
|
|
75
|
+
return TOOLS[program.toLowerCase()];
|
|
76
|
+
const bare = head.replace(/^.*[\\/]/, '').replace(/^['"]|['"]$/g, '');
|
|
77
|
+
// Cmdlets are matched as written (`Get-AzVM`, not `get-azvm`, keeps Az apart from words that start so), and
|
|
78
|
+
// case-insensitively for the verbs that sign in.
|
|
79
|
+
for (const [pattern, name] of CMDLETS)
|
|
80
|
+
if (pattern.test(bare) || pattern.test(bare.toLowerCase()))
|
|
81
|
+
return name;
|
|
82
|
+
}
|
|
83
|
+
for (const [pattern, name] of REGISTRIES)
|
|
84
|
+
if (pattern.test(command))
|
|
85
|
+
return name;
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
@@ -351,10 +351,16 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
351
351
|
* The worker's model as chosen under the chat's box; with none chosen, the lead's — by hand when the lead's is.
|
|
352
352
|
* A worker with no model of its own would be asked about by hand on every conversation that named one.
|
|
353
353
|
*/
|
|
354
|
+
/*
|
|
355
|
+
* The worker's model as chosen under the chat's box; with none chosen, Settings' model for the worker (2026-10-23:
|
|
356
|
+
* three models in Settings — the worker's, the lead's, the review's); with none there either, the lead's, by hand
|
|
357
|
+
* when the lead's is — as before Settings had one for each.
|
|
358
|
+
*/
|
|
354
359
|
const own = lead2.workerModel?.trim();
|
|
355
|
-
|
|
360
|
+
const fromSettings = (cfg.copilot.defaultModel ?? '').trim();
|
|
361
|
+
if (lead2.workerManualModel || (!own && !fromSettings && now?.manualModel))
|
|
356
362
|
s.manualModel = true;
|
|
357
|
-
else if (own || now?.model?.trim()) {
|
|
363
|
+
else if (own || (!fromSettings && now?.model?.trim())) {
|
|
358
364
|
s.model = own || now?.model?.trim();
|
|
359
365
|
s.modelSource = 'operator';
|
|
360
366
|
}
|
|
@@ -600,12 +606,25 @@ export async function runLeadTask(transport, session, task, deps) {
|
|
|
600
606
|
case 'ask': {
|
|
601
607
|
round.question = { text: r.question, ...(r.why ? { why: r.why } : {}), ...(r.options.length > 0 ? { options: r.options } : {}) };
|
|
602
608
|
await saveLead();
|
|
609
|
+
/*
|
|
610
|
+
* Settings agree with what the bot proposes (2026-10-23): the lead's recommended answer, its first, is taken
|
|
611
|
+
* and said; with no answers given, it is told to go on as it proposes.
|
|
612
|
+
*/
|
|
613
|
+
if (cfg.execution.questions === 'agree') {
|
|
614
|
+
const agreed = r.options[0] ?? 'Go on as you propose.';
|
|
615
|
+
round.question.answer = agreed;
|
|
616
|
+
round.question.at = new Date().toISOString();
|
|
617
|
+
await saveLead();
|
|
618
|
+
sink.event('question-agreed', { round: round.n, question: r.question, answer: agreed }, `the lead asked: ${r.question} — answered as it recommends (Settings agree with what the bot proposes): ${agreed}`);
|
|
619
|
+
markdown = await tell(operatorAnswerMessage(agreed, max - lead.subtasks));
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
603
622
|
if (!deps.askQuestion) {
|
|
604
623
|
markdown = await tell(NOBODY_TO_ASK);
|
|
605
624
|
break;
|
|
606
625
|
}
|
|
607
626
|
sink.event('lead-question', { round: round.n, question: r.question }, `the lead asks the operator: ${r.question}`, 'warn');
|
|
608
|
-
const got = await deps.askQuestion({ sessionId: session.id, taskId: task.id, question: r.question, ...(r.why ? { why: r.why } : {}), options: r.options });
|
|
627
|
+
const got = await deps.askQuestion({ sessionId: session.id, taskId: task.id, question: r.question, ...(r.why ? { why: r.why } : {}), options: r.options, actor: 'lead' });
|
|
609
628
|
if (got === 'stop' || signal?.aborted)
|
|
610
629
|
return await finish('aborted', 'the operator stopped the task at the lead\'s question');
|
|
611
630
|
round.question.answer = got.answer;
|
|
@@ -31,7 +31,7 @@ import { describeCrash } from '../transport/edgeCrash.js';
|
|
|
31
31
|
import { runReview, findingsMessage, deliverableFor } from './review.js';
|
|
32
32
|
import { allAboutTheTask, isRepeat, findingId } from '../protocol/reviewSchema.js';
|
|
33
33
|
import { repoState, workingTreePaths } from '../vcs/git.js';
|
|
34
|
-
import { describeStep, checkCommandRefusal, commandRefusal } from '../exec/policy.js';
|
|
34
|
+
import { describeStep, checkCommandRefusal, commandRefusal, staticCheck } from '../exec/policy.js';
|
|
35
35
|
import { networkFetchReason } from '../exec/network.js';
|
|
36
36
|
import { collectPolicyManifest, describePolicyManifest } from '../exec/policyManifest.js';
|
|
37
37
|
import { assessIsolation, readIsolationSignals } from '../exec/isolation.js';
|
|
@@ -76,10 +76,10 @@ async function followPageModels(which, wanted, result, session, store, hooks, fr
|
|
|
76
76
|
if (own) {
|
|
77
77
|
await store
|
|
78
78
|
?.updateSession(session.id, (s) => {
|
|
79
|
-
if (which === '
|
|
80
|
-
s.model = result.matched;
|
|
81
|
-
else
|
|
79
|
+
if (which === 'review')
|
|
82
80
|
s.review = { ...(s.review ?? {}), model: result.matched };
|
|
81
|
+
else
|
|
82
|
+
s.model = result.matched;
|
|
83
83
|
})
|
|
84
84
|
.catch(() => undefined);
|
|
85
85
|
}
|
|
@@ -381,6 +381,10 @@ export function speakFor(transport, sessionId, opts = {}) {
|
|
|
381
381
|
if (opts.alone)
|
|
382
382
|
speaker.alone = true;
|
|
383
383
|
}
|
|
384
|
+
/** The model menu's locators and its step pictures, as Settings have them (2026-10-24), for every window that picks a model. */
|
|
385
|
+
export function pickerOptions(cfg) {
|
|
386
|
+
return { ...(cfg.copilot.pickerLocators ? { pickerLocators: cfg.copilot.pickerLocators } : {}), ...(cfg.copilot.pickerSteps ? { modelStepShots: true } : {}) };
|
|
387
|
+
}
|
|
384
388
|
export async function openBrowser(cfg, bus, transportDir, sessionId,
|
|
385
389
|
/** The run's Stop: a sign-in still awaited ends with it. */
|
|
386
390
|
signal) {
|
|
@@ -395,6 +399,7 @@ signal) {
|
|
|
395
399
|
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
396
400
|
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
397
401
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
402
|
+
...pickerOptions(cfg),
|
|
398
403
|
onEvent: (event, detail) => {
|
|
399
404
|
const spoken = {
|
|
400
405
|
'sign-in-required': 'The chat is asking you to sign in. Do it in the open Edge window; the run is waiting.',
|
|
@@ -643,7 +648,12 @@ export async function openSessionTransport(cfg, session, bus, runsDir, signal) {
|
|
|
643
648
|
export function effectiveModels(session, cfg) {
|
|
644
649
|
const pick = (own, source, settings) => own && source === 'operator' ? [own, 'session'] : settings ? [settings, 'settings'] : own ? [own, 'plan'] : ['', 'none'];
|
|
645
650
|
// Set by hand in the Copilot window: no name is asked for, neither the session's nor the one in Settings.
|
|
646
|
-
|
|
651
|
+
/*
|
|
652
|
+
* Settings' model for the conversation's part (2026-10-23): the lead's for the lead of two chats — the worker's when
|
|
653
|
+
* none is chosen for the lead, as before there were two — else the worker's.
|
|
654
|
+
*/
|
|
655
|
+
const fromSettings = ((session.lead ? cfg.copilot.defaultLeadModel?.trim() || cfg.copilot.defaultModel : cfg.copilot.defaultModel) ?? '').trim();
|
|
656
|
+
const [model, modelFrom] = session.manualModel ? ['', 'none'] : pick((session.model ?? '').trim(), session.modelSource, fromSettings);
|
|
647
657
|
const [reviewModel, reviewModelFrom] = pick((session.review?.model ?? '').trim(), session.reviewModelSource, (cfg.copilot.defaultReviewModel ?? '').trim());
|
|
648
658
|
return { model, reviewModel, modelFrom, reviewModelFrom };
|
|
649
659
|
}
|
|
@@ -653,7 +663,9 @@ export function effectiveModels(session, cfg) {
|
|
|
653
663
|
* model and has none from Settings either — its picker shows "by hand" for that, and what it shows is what happens.
|
|
654
664
|
*/
|
|
655
665
|
export function modelByHand(session, cfg) {
|
|
656
|
-
|
|
666
|
+
// Settings' "by hand" for the conversation's part (2026-10-23): the lead's has its own, absent as the worker's.
|
|
667
|
+
const settingsSay = session.lead ? (cfg.copilot.leadManualModel ?? cfg.copilot.manualModel) : cfg.copilot.manualModel;
|
|
668
|
+
if (settingsSay || session.manualModel)
|
|
657
669
|
return true;
|
|
658
670
|
return session.kind === 'chat' && !effectiveModels(session, cfg).model;
|
|
659
671
|
}
|
|
@@ -736,7 +748,7 @@ signal) {
|
|
|
736
748
|
const hand = await withOperatorHand(transport, wanted, result, hooks, session.id, bus, false, asks);
|
|
737
749
|
result = hand.result;
|
|
738
750
|
const goOnAsItIs = hand.goOnAsItIs;
|
|
739
|
-
const renamed = await followPageModels('model', wanted, result, session, store, hooks, modelFrom);
|
|
751
|
+
const renamed = await followPageModels(session.lead ? 'lead' : 'model', wanted, result, session, store, hooks, modelFrom);
|
|
740
752
|
if (renamed)
|
|
741
753
|
bus.publish({ sessionId: session.id, type: 'model-renamed', level: 'warn', message: renamed, data: { asked: wanted, chosen: result.matched } });
|
|
742
754
|
bus.publish({
|
|
@@ -1018,6 +1030,11 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1018
1030
|
let disputes = [];
|
|
1019
1031
|
/** What the runner tells the model in its next message about the reply just processed. */
|
|
1020
1032
|
let runnerNotes = [];
|
|
1033
|
+
/*
|
|
1034
|
+
* Commands the operator chose an answer for (2026-10-23): the click is the permission for that one command, once.
|
|
1035
|
+
* The rules that refuse a command still apply to it.
|
|
1036
|
+
*/
|
|
1037
|
+
const consented = new Set();
|
|
1021
1038
|
/** The projects for reference only, watched for the length of the task (see `vcs/referenceGuard.ts`). */
|
|
1022
1039
|
let reference = null;
|
|
1023
1040
|
/** Steps the chat sent that were not run, for the handoff at the end. */
|
|
@@ -1131,9 +1148,14 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1131
1148
|
}
|
|
1132
1149
|
return check;
|
|
1133
1150
|
};
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1151
|
+
/*
|
|
1152
|
+
* A chat message's checkpoint and folder (2026-10-17), set where the task starts; read by `finish`. Not for a chat on
|
|
1153
|
+
* a branch of the runner's own (a task of the queue on a new branch from main, 2026-10-24): its work is committed on
|
|
1154
|
+
* that branch, and the photograph after it wrote over the task's record of the branch, so nothing was committed.
|
|
1155
|
+
*/
|
|
1156
|
+
const photographed = session.kind === 'chat' && !session.vcs?.enabled;
|
|
1157
|
+
let chatCheckpoint = photographed ? task.checkpoint : undefined;
|
|
1158
|
+
const chatDir = photographed ? session.projectDir?.trim() ?? '' : '';
|
|
1137
1159
|
const finish = async (status, reason, summary, finalReply) => {
|
|
1138
1160
|
// How it ended as reported; the runner's own checks below can still change it, and the final word is written at the end.
|
|
1139
1161
|
await record(`ENDING: ${status.toUpperCase()}`, [summary ?? '', reason ? `Reason: ${reason}` : ''].filter(Boolean).join('\n\n') || '(no details)');
|
|
@@ -1723,7 +1745,8 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1723
1745
|
// The operator's new prompt goes out whether or not the attempt it follows reached a conversation.
|
|
1724
1746
|
...(task.continuing?.instruction ? { instruction: { text: task.continuing.instruction, fromAttempt: task.continuing.fromAttempt, ended: task.continuing.ended } } : {}),
|
|
1725
1747
|
workDirNote: workingDirNote(work),
|
|
1726
|
-
|
|
1748
|
+
// A chat on a branch of the runner's own (a task of the queue, 2026-10-24) is told about that branch, not the folder's.
|
|
1749
|
+
vcsNote: session.kind === 'chat' && !session.vcs?.enabled ? CHAT_NOTE : prepared.note,
|
|
1727
1750
|
// What is said about a commit is true only where one happens (live run 2026-10-03: promised with commits off).
|
|
1728
1751
|
referenceNote: forReference.length > 0 ? referenceNote(forReference, work.cwd) : undefined,
|
|
1729
1752
|
readOnlyNote: task.readOnly ? readOnlyNote(!!(session.vcs?.enabled && session.vcs.commitOnFinish !== false && trackedRepoOf(session)), artifactPatterns(session.vcs)) : undefined,
|
|
@@ -2160,7 +2183,8 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2160
2183
|
* hand unless one is named (2026-10-17), and its review is too: asked on a card that says it is the review's
|
|
2161
2184
|
* and why a different, stronger model is worth choosing for it (operator, 2026-10-20).
|
|
2162
2185
|
*/
|
|
2163
|
-
|
|
2186
|
+
// The review's own "by hand" in Settings (2026-10-23), absent as the worker's.
|
|
2187
|
+
const reviewByHand = (cfg.copilot.reviewManualModel ?? cfg.copilot.manualModel) || !!session.manualModel || (session.kind === 'chat' && !model);
|
|
2164
2188
|
const repoDir = trackedRepoOf(session);
|
|
2165
2189
|
/*
|
|
2166
2190
|
* What changed, read from git rather than from anybody's account of it.
|
|
@@ -2646,6 +2670,67 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2646
2670
|
* what the reply said, at greater length and one message later. The reason carries the
|
|
2647
2671
|
* approaches that were tried, and that is what the register shows.
|
|
2648
2672
|
*/
|
|
2673
|
+
/*
|
|
2674
|
+
* A question only the operator can answer (operator, 2026-10-23: "answers to click, not only a text field; when the
|
|
2675
|
+
* chat proposes a command for the user to run by hand, a button behind it, and the bot runs it"): put to the
|
|
2676
|
+
* operator with its answers — or, Settings agreeing with what the bot proposes, or nobody there to ask, the first,
|
|
2677
|
+
* which the chat recommends. The answer goes back; an answer that carries a command has it run here and now, as
|
|
2678
|
+
* this reply's step, its output going back with the answer.
|
|
2679
|
+
*/
|
|
2680
|
+
if (reply.status === 'ask') {
|
|
2681
|
+
const question = (reply.question ?? '').trim();
|
|
2682
|
+
const options = reply.options;
|
|
2683
|
+
const agree = cfg.execution.questions === 'agree' || !deps.askQuestion;
|
|
2684
|
+
let answer = options[0].answer;
|
|
2685
|
+
if (agree) {
|
|
2686
|
+
sink.event('question-agreed', { question, answer, why: cfg.execution.questions === 'agree' ? 'settings' : 'nobody to ask' }, `the chat asked: ${question} — answered as it recommends (${cfg.execution.questions === 'agree' ? 'Settings agree with what the bot proposes' : 'nobody is there to ask'}): ${answer}`);
|
|
2687
|
+
}
|
|
2688
|
+
else {
|
|
2689
|
+
sink.event('question-asked', { question, options: options.map((o) => o.answer) }, `the chat asks the operator: ${question}`, 'warn');
|
|
2690
|
+
await setTask((t) => {
|
|
2691
|
+
t.status = 'waiting-approval';
|
|
2692
|
+
});
|
|
2693
|
+
const got = await deps.askQuestion({
|
|
2694
|
+
sessionId: session.id,
|
|
2695
|
+
taskId: task.id,
|
|
2696
|
+
question,
|
|
2697
|
+
...(reply.why?.trim() ? { why: reply.why.trim() } : {}),
|
|
2698
|
+
options: options.map((o) => o.answer),
|
|
2699
|
+
commands: options.map((o) => o.run ?? null),
|
|
2700
|
+
actor: planning ? 'plan' : 'worker',
|
|
2701
|
+
});
|
|
2702
|
+
await setTask((t) => {
|
|
2703
|
+
t.status = 'running';
|
|
2704
|
+
});
|
|
2705
|
+
if (got === 'stop' || signal?.aborted)
|
|
2706
|
+
return await finish('aborted', 'stopped by the operator at its question', undefined, lastMarkdown);
|
|
2707
|
+
answer = got.answer;
|
|
2708
|
+
sink.event('question-answered', { question, answer }, `the operator answered: ${answer}`);
|
|
2709
|
+
}
|
|
2710
|
+
await record('QUESTION', `${question}\n\nAnswer${agree ? ' (as the chat recommends)' : ''}: ${answer}`);
|
|
2711
|
+
const chosen = options.find((o) => o.answer === answer);
|
|
2712
|
+
if (chosen?.run) {
|
|
2713
|
+
// Run as this reply's one step: through the step loop below, its output reported as any step's.
|
|
2714
|
+
consented.add(chosen.run.trim());
|
|
2715
|
+
const mutable = reply;
|
|
2716
|
+
mutable.status = 'continue';
|
|
2717
|
+
mutable.steps = [{ id: 1, type: 'command', cmd: chosen.run, ...(chosen.shell ? { shell: chosen.shell } : {}) }];
|
|
2718
|
+
runnerNotes.push(`${agree ? 'The runner took your recommended answer' : 'The operator answered your question'} ("${question}"): "${answer}". ` +
|
|
2719
|
+
'The runner ran the command that answer carries — step 1 below, its output with it. Go on from there.');
|
|
2720
|
+
}
|
|
2721
|
+
else {
|
|
2722
|
+
const message = `${agree ? 'The runner took your recommended answer' : 'The operator answered your question'} ("${question}"): "${answer}".\n\n` +
|
|
2723
|
+
'Go on with the work from here, in the same format.';
|
|
2724
|
+
await record('ANSWER', message);
|
|
2725
|
+
await pacer.throttleSend();
|
|
2726
|
+
const before = await transport.sendAndConfirm(message);
|
|
2727
|
+
const next = await transport.waitForReply(before);
|
|
2728
|
+
await saveReply('answer', next);
|
|
2729
|
+
lastMarkdown = next.markdown;
|
|
2730
|
+
await pacer.settle();
|
|
2731
|
+
continue;
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2649
2734
|
/*
|
|
2650
2735
|
* Plan mode: the reply that ends the planning phase — put to the operator or approved by the runner —
|
|
2651
2736
|
* and the two that do not belong in it. Answered here, in a message of its own, as a repair of the
|
|
@@ -2880,7 +2965,10 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2880
2965
|
t.status = 'waiting-approval';
|
|
2881
2966
|
});
|
|
2882
2967
|
sink.event('step-proposed', { id: step.id, description: describeStep(step) }, `step ${step.id}: ${describeStep(step)}`);
|
|
2883
|
-
|
|
2968
|
+
// The command of an answer the operator chose (2026-10-23): their click allowed it; the refusing rules still hold.
|
|
2969
|
+
const decided = consented.delete(step.cmd.trim())
|
|
2970
|
+
? (staticCheck(step, { mode: 'confirm', denyPatterns: cfg.execution.denyPatterns, allowedPrograms: cfg.execution.allowedPrograms }, undefined, confinement) ?? { action: 'run' })
|
|
2971
|
+
: await authorizer.authorize(step, { sessionId: session.id, taskId: task.id, iteration: iterations, confinement, actor: planning ? 'plan' : 'worker' });
|
|
2884
2972
|
await setTask((t) => {
|
|
2885
2973
|
t.status = 'running';
|
|
2886
2974
|
});
|