copilot-operator 0.1.58 → 0.1.59
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 +11 -0
- package/dist/src/api/operator.service.js +28 -6
- package/dist/src/cli.js +1 -0
- package/dist/src/config/schema.js +16 -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 +86 -9
- package/dist/src/plan/systemGuide.js +80 -41
- package/dist/src/protocol/parser.js +3 -2
- package/dist/src/protocol/replySchema.js +20 -2
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.34c33df752c793fd.js +1 -0
- package/dist/web/_next/static/chunks/1548.9bd3216f2e2ed40a.js +1 -0
- package/dist/web/_next/static/chunks/2163.c764c5ddf04e8f3c.js +1 -0
- package/dist/web/_next/static/chunks/4512-bf72c643d4a4db71.js +1 -0
- package/dist/web/_next/static/chunks/714.ce1d54a2c2b5474f.js +1 -0
- package/dist/web/_next/static/chunks/7220.07100b580a566f9c.js +1 -0
- package/dist/web/_next/static/chunks/7921-97fcfd1f6aff2774.js +1 -0
- package/dist/web/_next/static/chunks/8584.d863bb44ea78998d.js +1 -0
- package/dist/web/_next/static/chunks/9067.3d3d65b5fb1c6a61.js +1 -0
- package/dist/web/_next/static/chunks/9747.af530d25cd7cc8fb.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-d83191667baa1077.js → page-c3c50d426109e8c5.js} +1 -1
- package/dist/web/_next/static/chunks/app/settings/page-e485720f199e3194.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-4da26d364c22b773.js → webpack-d210ad961e7a9237.js} +1 -1
- package/dist/web/_next/static/css/{ad8f9884b90fbe47.css → e544b477e4b4b108.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/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 -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/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/settings/page-832ed3149649b77a.js +0 -1
- /package/dist/web/_next/static/{wjvJJpx5dfDucIRnV0mIG → Gan_sPghz9GR_aVaCL2ah}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{wjvJJpx5dfDucIRnV0mIG → Gan_sPghz9GR_aVaCL2ah}/_ssgManifest.js +0 -0
|
@@ -391,6 +391,10 @@ let OperatorController = class OperatorController {
|
|
|
391
391
|
setDefaultModel(body) {
|
|
392
392
|
return this.ops.setDefaultModel(body?.model ?? '').catch(fail);
|
|
393
393
|
}
|
|
394
|
+
/** The model the lead of two chats starts on (2026-10-23). An empty name leaves its chat on whatever it is. */
|
|
395
|
+
setDefaultLeadModel(body) {
|
|
396
|
+
return this.ops.setDefaultLeadModel(body?.model ?? '').catch(fail);
|
|
397
|
+
}
|
|
394
398
|
/** The model of the independent review. An empty name means "the session's own". */
|
|
395
399
|
setDefaultReviewModel(body) {
|
|
396
400
|
return this.ops.setDefaultReviewModel(body?.model ?? '').catch(fail);
|
|
@@ -750,6 +754,13 @@ __decorate([
|
|
|
750
754
|
__metadata("design:paramtypes", [Object]),
|
|
751
755
|
__metadata("design:returntype", Promise)
|
|
752
756
|
], OperatorController.prototype, "setDefaultModel", null);
|
|
757
|
+
__decorate([
|
|
758
|
+
Put('models/lead-default'),
|
|
759
|
+
__param(0, Body()),
|
|
760
|
+
__metadata("design:type", Function),
|
|
761
|
+
__metadata("design:paramtypes", [Object]),
|
|
762
|
+
__metadata("design:returntype", Promise)
|
|
763
|
+
], OperatorController.prototype, "setDefaultLeadModel", null);
|
|
753
764
|
__decorate([
|
|
754
765
|
Put('models/review-default'),
|
|
755
766
|
__param(0, Body()),
|
|
@@ -786,6 +786,7 @@ let OperatorService = class OperatorService {
|
|
|
786
786
|
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
787
787
|
// Read once per run like the rest of the policy: a change in Settings applies from the next start.
|
|
788
788
|
networkFetch: cfg.execution.networkFetch,
|
|
789
|
+
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
789
790
|
};
|
|
790
791
|
/*
|
|
791
792
|
* An unattended run that cannot legally execute anything is stopped here, where the operator
|
|
@@ -880,6 +881,8 @@ let OperatorService = class OperatorService {
|
|
|
880
881
|
await this.setDefaultModel(to);
|
|
881
882
|
if (which === 'review' && (now.defaultReviewModel ?? '').trim() === from)
|
|
882
883
|
await this.setDefaultReviewModel(to);
|
|
884
|
+
if (which === 'lead' && (now.defaultLeadModel ?? '').trim() === from)
|
|
885
|
+
await this.setDefaultLeadModel(to);
|
|
883
886
|
},
|
|
884
887
|
seen: async (options, current) => {
|
|
885
888
|
await this.store.saveModels({ options, current: current ?? undefined, readAt: new Date().toISOString() });
|
|
@@ -1408,10 +1411,11 @@ let OperatorService = class OperatorService {
|
|
|
1408
1411
|
sessionId: ask.sessionId,
|
|
1409
1412
|
taskId: ask.taskId,
|
|
1410
1413
|
stepId: 0,
|
|
1411
|
-
description:
|
|
1414
|
+
description: `${(ask.actor ?? 'lead') === 'lead' ? 'The lead asks' : 'The chat asks'}: ${ask.question}`,
|
|
1412
1415
|
createdAt: new Date().toISOString(),
|
|
1413
|
-
|
|
1414
|
-
|
|
1416
|
+
// The lead's, or since 2026-10-23 the chat's own (plan mode's or the worker's).
|
|
1417
|
+
actor: ask.actor ?? 'lead',
|
|
1418
|
+
question: { text: ask.question, ...(ask.why ? { why: ask.why } : {}), options: ask.options, ...(ask.commands?.some(Boolean) ? { commands: ask.commands } : {}) },
|
|
1415
1419
|
};
|
|
1416
1420
|
this.waiting.set(approval.id, {
|
|
1417
1421
|
approval,
|
|
@@ -1596,12 +1600,13 @@ let OperatorService = class OperatorService {
|
|
|
1596
1600
|
description: `[${step.shell ?? 'pwsh'}] ${step.cmd}`,
|
|
1597
1601
|
createdAt: new Date().toISOString(),
|
|
1598
1602
|
...(ctx.actor ? { actor: ctx.actor } : {}),
|
|
1599
|
-
...(held ? { network: held.network } : {}),
|
|
1603
|
+
...(held?.network ? { network: held.network } : {}),
|
|
1604
|
+
...(held?.platform ? { platform: held.platform } : {}),
|
|
1600
1605
|
};
|
|
1601
1606
|
this.waiting.set(approval.id, { approval, resolve: resolvePromise });
|
|
1602
1607
|
this.bus.publish({ sessionId: approval.sessionId, taskId: approval.taskId, type: 'approval-requested', level: 'warn',
|
|
1603
1608
|
message: held
|
|
1604
|
-
? `held for the operator — ${held.network}: ${approval.description}`
|
|
1609
|
+
? `held for the operator — ${[held.platform ? `it reaches ${held.platform} with the operator's access` : '', held.network ?? ''].filter(Boolean).join('; ')}: ${approval.description}`
|
|
1605
1610
|
: `waiting for approval: ${approval.description}`,
|
|
1606
1611
|
data: { ...approval } });
|
|
1607
1612
|
}), signal);
|
|
@@ -1974,13 +1979,26 @@ let OperatorService = class OperatorService {
|
|
|
1974
1979
|
const cached = await this.store.getModels();
|
|
1975
1980
|
const defaultModel = cfg.copilot.defaultModel ?? '';
|
|
1976
1981
|
const defaultReviewModel = cfg.copilot.defaultReviewModel ?? '';
|
|
1977
|
-
|
|
1982
|
+
const defaultLeadModel = cfg.copilot.defaultLeadModel ?? '';
|
|
1983
|
+
return cached ? { ...cached, defaultModel, defaultLeadModel, defaultReviewModel } : { defaultModel, defaultLeadModel, defaultReviewModel, options: [], readAt: null };
|
|
1978
1984
|
}
|
|
1979
1985
|
/**
|
|
1980
1986
|
* Sets the model a new session's independent review starts on. An empty name clears it,
|
|
1981
1987
|
* which means the review runs on the session's own model — the weaker choice, and the one
|
|
1982
1988
|
* every session had before this existed.
|
|
1983
1989
|
*/
|
|
1990
|
+
/** Sets the model the lead of two chats starts on (2026-10-23). An empty name leaves its chat on whatever it is. */
|
|
1991
|
+
async setDefaultLeadModel(name) {
|
|
1992
|
+
await this.init();
|
|
1993
|
+
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultLeadModel: name.trim() } }));
|
|
1994
|
+
this.bus.publish({
|
|
1995
|
+
sessionId: '*',
|
|
1996
|
+
type: 'default-lead-model-changed',
|
|
1997
|
+
level: 'info',
|
|
1998
|
+
message: name.trim() ? `the lead of two chats will start on ${name.trim()}` : 'the lead of two chats leaves the chat on its model',
|
|
1999
|
+
});
|
|
2000
|
+
return { defaultLeadModel: name.trim() };
|
|
2001
|
+
}
|
|
1984
2002
|
async setDefaultReviewModel(name) {
|
|
1985
2003
|
await this.init();
|
|
1986
2004
|
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultReviewModel: name.trim() } }));
|
|
@@ -2125,12 +2143,16 @@ let OperatorService = class OperatorService {
|
|
|
2125
2143
|
const saved = cfg.copilot;
|
|
2126
2144
|
const work = (saved.defaultModel ?? '').trim();
|
|
2127
2145
|
const review = (saved.defaultReviewModel ?? '').trim();
|
|
2146
|
+
const lead = (saved.defaultLeadModel ?? '').trim();
|
|
2128
2147
|
const workNow = work ? pageModelFor(work, options) : null;
|
|
2129
2148
|
const reviewNow = review ? pageModelFor(review, options) : null;
|
|
2149
|
+
const leadNow = lead ? pageModelFor(lead, options) : null;
|
|
2130
2150
|
if (workNow && !sameModel(workNow.name, work))
|
|
2131
2151
|
await this.setDefaultModel(workNow.name);
|
|
2132
2152
|
if (reviewNow && !sameModel(reviewNow.name, review))
|
|
2133
2153
|
await this.setDefaultReviewModel(reviewNow.name);
|
|
2154
|
+
if (leadNow && !sameModel(leadNow.name, lead))
|
|
2155
|
+
await this.setDefaultLeadModel(leadNow.name);
|
|
2134
2156
|
return catalogue;
|
|
2135
2157
|
}
|
|
2136
2158
|
finally {
|
package/dist/src/cli.js
CHANGED
|
@@ -497,6 +497,7 @@ program
|
|
|
497
497
|
isolation: cfg.execution.isolation,
|
|
498
498
|
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
499
499
|
networkFetch: cfg.execution.networkFetch,
|
|
500
|
+
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
500
501
|
};
|
|
501
502
|
const authorizer = cfg.execution.mode === 'unattended'
|
|
502
503
|
? unattendedAuthorizer(policy)
|
|
@@ -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),
|
|
@@ -169,6 +178,13 @@ export const RunConfigSchema = z.object({
|
|
|
169
178
|
* there, a fetch included, is put in front of a person anyway.
|
|
170
179
|
*/
|
|
171
180
|
networkFetch: z.enum(['ask', 'refuse', 'run']).default('ask'),
|
|
181
|
+
/**
|
|
182
|
+
* The bot's questions (operator, 2026-10-23: "an option in Settings to pass over questions — the user always agrees
|
|
183
|
+
* with what the bot proposes"): `ask` puts them to the operator — a command that reaches a platform with the
|
|
184
|
+
* operator's access (`exec/platforms.ts`), and a chat's or the lead's question with its answers to click; `agree`
|
|
185
|
+
* takes what the bot proposes — the command runs, the recommended answer is given — and says so in the chat.
|
|
186
|
+
*/
|
|
187
|
+
questions: z.enum(['ask', 'agree']).default('ask'),
|
|
172
188
|
/**
|
|
173
189
|
* Plan mode, for every session that does not set its own (see `PlanMode` in session/model.ts): a
|
|
174
190
|
* 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
|
}
|
|
@@ -643,7 +643,12 @@ export async function openSessionTransport(cfg, session, bus, runsDir, signal) {
|
|
|
643
643
|
export function effectiveModels(session, cfg) {
|
|
644
644
|
const pick = (own, source, settings) => own && source === 'operator' ? [own, 'session'] : settings ? [settings, 'settings'] : own ? [own, 'plan'] : ['', 'none'];
|
|
645
645
|
// Set by hand in the Copilot window: no name is asked for, neither the session's nor the one in Settings.
|
|
646
|
-
|
|
646
|
+
/*
|
|
647
|
+
* Settings' model for the conversation's part (2026-10-23): the lead's for the lead of two chats — the worker's when
|
|
648
|
+
* none is chosen for the lead, as before there were two — else the worker's.
|
|
649
|
+
*/
|
|
650
|
+
const fromSettings = ((session.lead ? cfg.copilot.defaultLeadModel?.trim() || cfg.copilot.defaultModel : cfg.copilot.defaultModel) ?? '').trim();
|
|
651
|
+
const [model, modelFrom] = session.manualModel ? ['', 'none'] : pick((session.model ?? '').trim(), session.modelSource, fromSettings);
|
|
647
652
|
const [reviewModel, reviewModelFrom] = pick((session.review?.model ?? '').trim(), session.reviewModelSource, (cfg.copilot.defaultReviewModel ?? '').trim());
|
|
648
653
|
return { model, reviewModel, modelFrom, reviewModelFrom };
|
|
649
654
|
}
|
|
@@ -653,7 +658,9 @@ export function effectiveModels(session, cfg) {
|
|
|
653
658
|
* model and has none from Settings either — its picker shows "by hand" for that, and what it shows is what happens.
|
|
654
659
|
*/
|
|
655
660
|
export function modelByHand(session, cfg) {
|
|
656
|
-
|
|
661
|
+
// Settings' "by hand" for the conversation's part (2026-10-23): the lead's has its own, absent as the worker's.
|
|
662
|
+
const settingsSay = session.lead ? (cfg.copilot.leadManualModel ?? cfg.copilot.manualModel) : cfg.copilot.manualModel;
|
|
663
|
+
if (settingsSay || session.manualModel)
|
|
657
664
|
return true;
|
|
658
665
|
return session.kind === 'chat' && !effectiveModels(session, cfg).model;
|
|
659
666
|
}
|
|
@@ -736,7 +743,7 @@ signal) {
|
|
|
736
743
|
const hand = await withOperatorHand(transport, wanted, result, hooks, session.id, bus, false, asks);
|
|
737
744
|
result = hand.result;
|
|
738
745
|
const goOnAsItIs = hand.goOnAsItIs;
|
|
739
|
-
const renamed = await followPageModels('model', wanted, result, session, store, hooks, modelFrom);
|
|
746
|
+
const renamed = await followPageModels(session.lead ? 'lead' : 'model', wanted, result, session, store, hooks, modelFrom);
|
|
740
747
|
if (renamed)
|
|
741
748
|
bus.publish({ sessionId: session.id, type: 'model-renamed', level: 'warn', message: renamed, data: { asked: wanted, chosen: result.matched } });
|
|
742
749
|
bus.publish({
|
|
@@ -1018,6 +1025,11 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1018
1025
|
let disputes = [];
|
|
1019
1026
|
/** What the runner tells the model in its next message about the reply just processed. */
|
|
1020
1027
|
let runnerNotes = [];
|
|
1028
|
+
/*
|
|
1029
|
+
* Commands the operator chose an answer for (2026-10-23): the click is the permission for that one command, once.
|
|
1030
|
+
* The rules that refuse a command still apply to it.
|
|
1031
|
+
*/
|
|
1032
|
+
const consented = new Set();
|
|
1021
1033
|
/** The projects for reference only, watched for the length of the task (see `vcs/referenceGuard.ts`). */
|
|
1022
1034
|
let reference = null;
|
|
1023
1035
|
/** Steps the chat sent that were not run, for the handoff at the end. */
|
|
@@ -2160,7 +2172,8 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2160
2172
|
* 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
2173
|
* and why a different, stronger model is worth choosing for it (operator, 2026-10-20).
|
|
2162
2174
|
*/
|
|
2163
|
-
|
|
2175
|
+
// The review's own "by hand" in Settings (2026-10-23), absent as the worker's.
|
|
2176
|
+
const reviewByHand = (cfg.copilot.reviewManualModel ?? cfg.copilot.manualModel) || !!session.manualModel || (session.kind === 'chat' && !model);
|
|
2164
2177
|
const repoDir = trackedRepoOf(session);
|
|
2165
2178
|
/*
|
|
2166
2179
|
* What changed, read from git rather than from anybody's account of it.
|
|
@@ -2646,6 +2659,67 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2646
2659
|
* what the reply said, at greater length and one message later. The reason carries the
|
|
2647
2660
|
* approaches that were tried, and that is what the register shows.
|
|
2648
2661
|
*/
|
|
2662
|
+
/*
|
|
2663
|
+
* A question only the operator can answer (operator, 2026-10-23: "answers to click, not only a text field; when the
|
|
2664
|
+
* chat proposes a command for the user to run by hand, a button behind it, and the bot runs it"): put to the
|
|
2665
|
+
* operator with its answers — or, Settings agreeing with what the bot proposes, or nobody there to ask, the first,
|
|
2666
|
+
* which the chat recommends. The answer goes back; an answer that carries a command has it run here and now, as
|
|
2667
|
+
* this reply's step, its output going back with the answer.
|
|
2668
|
+
*/
|
|
2669
|
+
if (reply.status === 'ask') {
|
|
2670
|
+
const question = (reply.question ?? '').trim();
|
|
2671
|
+
const options = reply.options;
|
|
2672
|
+
const agree = cfg.execution.questions === 'agree' || !deps.askQuestion;
|
|
2673
|
+
let answer = options[0].answer;
|
|
2674
|
+
if (agree) {
|
|
2675
|
+
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}`);
|
|
2676
|
+
}
|
|
2677
|
+
else {
|
|
2678
|
+
sink.event('question-asked', { question, options: options.map((o) => o.answer) }, `the chat asks the operator: ${question}`, 'warn');
|
|
2679
|
+
await setTask((t) => {
|
|
2680
|
+
t.status = 'waiting-approval';
|
|
2681
|
+
});
|
|
2682
|
+
const got = await deps.askQuestion({
|
|
2683
|
+
sessionId: session.id,
|
|
2684
|
+
taskId: task.id,
|
|
2685
|
+
question,
|
|
2686
|
+
...(reply.why?.trim() ? { why: reply.why.trim() } : {}),
|
|
2687
|
+
options: options.map((o) => o.answer),
|
|
2688
|
+
commands: options.map((o) => o.run ?? null),
|
|
2689
|
+
actor: planning ? 'plan' : 'worker',
|
|
2690
|
+
});
|
|
2691
|
+
await setTask((t) => {
|
|
2692
|
+
t.status = 'running';
|
|
2693
|
+
});
|
|
2694
|
+
if (got === 'stop' || signal?.aborted)
|
|
2695
|
+
return await finish('aborted', 'stopped by the operator at its question', undefined, lastMarkdown);
|
|
2696
|
+
answer = got.answer;
|
|
2697
|
+
sink.event('question-answered', { question, answer }, `the operator answered: ${answer}`);
|
|
2698
|
+
}
|
|
2699
|
+
await record('QUESTION', `${question}\n\nAnswer${agree ? ' (as the chat recommends)' : ''}: ${answer}`);
|
|
2700
|
+
const chosen = options.find((o) => o.answer === answer);
|
|
2701
|
+
if (chosen?.run) {
|
|
2702
|
+
// Run as this reply's one step: through the step loop below, its output reported as any step's.
|
|
2703
|
+
consented.add(chosen.run.trim());
|
|
2704
|
+
const mutable = reply;
|
|
2705
|
+
mutable.status = 'continue';
|
|
2706
|
+
mutable.steps = [{ id: 1, type: 'command', cmd: chosen.run, ...(chosen.shell ? { shell: chosen.shell } : {}) }];
|
|
2707
|
+
runnerNotes.push(`${agree ? 'The runner took your recommended answer' : 'The operator answered your question'} ("${question}"): "${answer}". ` +
|
|
2708
|
+
'The runner ran the command that answer carries — step 1 below, its output with it. Go on from there.');
|
|
2709
|
+
}
|
|
2710
|
+
else {
|
|
2711
|
+
const message = `${agree ? 'The runner took your recommended answer' : 'The operator answered your question'} ("${question}"): "${answer}".\n\n` +
|
|
2712
|
+
'Go on with the work from here, in the same format.';
|
|
2713
|
+
await record('ANSWER', message);
|
|
2714
|
+
await pacer.throttleSend();
|
|
2715
|
+
const before = await transport.sendAndConfirm(message);
|
|
2716
|
+
const next = await transport.waitForReply(before);
|
|
2717
|
+
await saveReply('answer', next);
|
|
2718
|
+
lastMarkdown = next.markdown;
|
|
2719
|
+
await pacer.settle();
|
|
2720
|
+
continue;
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2649
2723
|
/*
|
|
2650
2724
|
* Plan mode: the reply that ends the planning phase — put to the operator or approved by the runner —
|
|
2651
2725
|
* and the two that do not belong in it. Answered here, in a message of its own, as a repair of the
|
|
@@ -2880,7 +2954,10 @@ export async function runTask(transport, session, task, deps) {
|
|
|
2880
2954
|
t.status = 'waiting-approval';
|
|
2881
2955
|
});
|
|
2882
2956
|
sink.event('step-proposed', { id: step.id, description: describeStep(step) }, `step ${step.id}: ${describeStep(step)}`);
|
|
2883
|
-
|
|
2957
|
+
// The command of an answer the operator chose (2026-10-23): their click allowed it; the refusing rules still hold.
|
|
2958
|
+
const decided = consented.delete(step.cmd.trim())
|
|
2959
|
+
? (staticCheck(step, { mode: 'confirm', denyPatterns: cfg.execution.denyPatterns, allowedPrograms: cfg.execution.allowedPrograms }, undefined, confinement) ?? { action: 'run' })
|
|
2960
|
+
: await authorizer.authorize(step, { sessionId: session.id, taskId: task.id, iteration: iterations, confinement, actor: planning ? 'plan' : 'worker' });
|
|
2884
2961
|
await setTask((t) => {
|
|
2885
2962
|
t.status = 'running';
|
|
2886
2963
|
});
|