copilot-operator 0.1.70 → 0.1.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/operator.controller.js +9 -5
- package/dist/src/api/operator.service.js +107 -23
- package/dist/src/cli.js +1 -0
- package/dist/src/config/live.js +122 -0
- package/dist/src/config/schema.js +7 -0
- package/dist/src/exec/authorizer.js +2 -2
- package/dist/src/exec/commandHeads.js +11 -2
- package/dist/src/exec/locations.js +194 -0
- package/dist/src/exec/network.js +3 -1
- package/dist/src/exec/policy.js +14 -2
- package/dist/src/exec/policyManifest.js +2 -0
- package/dist/src/exec/processes.js +8 -3
- package/dist/src/exec/scriptFiles.js +66 -23
- package/dist/src/exec/scriptKinds.js +7 -7
- package/dist/src/exec/stops.js +147 -0
- package/dist/src/orchestrator/chosenAnswers.js +22 -0
- package/dist/src/orchestrator/handoff.js +37 -2
- package/dist/src/orchestrator/hold.js +83 -4
- package/dist/src/orchestrator/leadRunner.js +39 -22
- package/dist/src/orchestrator/taskRunner.js +130 -50
- package/dist/src/plan/kerrigan.js +36 -15
- package/dist/src/plan/systemGuide.js +72 -32
- package/dist/src/protocol/leadSchema.js +6 -1
- package/dist/src/protocol/replySchema.js +6 -0
- package/dist/src/queue/queue.js +6 -0
- package/dist/src/session/model.js +12 -0
- package/dist/src/util/pacing.js +6 -0
- package/dist/src/vcs/newBranch.js +69 -10
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-17c74da39fb738c9.js +1 -0
- package/dist/web/_next/static/chunks/1077.ad76ce55c8120db5.js +1 -0
- package/dist/web/_next/static/chunks/1548.4dc2e419eee42487.js +1 -0
- package/dist/web/_next/static/chunks/2163.9f5c1d052712579f.js +1 -0
- package/dist/web/_next/static/chunks/714.3f04498b624bc1a4.js +1 -0
- package/dist/web/_next/static/chunks/7220.43612a34a3cb5146.js +1 -0
- package/dist/web/_next/static/chunks/7921-df716a0338420836.js +1 -0
- package/dist/web/_next/static/chunks/8124-2f07cc63c1494443.js +1 -0
- package/dist/web/_next/static/chunks/8584.36fd8289becb2d75.js +1 -0
- package/dist/web/_next/static/chunks/895-9c1f0751920e6624.js +1 -0
- package/dist/web/_next/static/chunks/9067.eff8198294aec025.js +1 -0
- package/dist/web/_next/static/chunks/9747.43e5b7201aa505ba.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-b8a1e0075a48b025.js +1 -0
- package/dist/web/_next/static/chunks/app/page-4a7cf5d83c000d73.js +1 -0
- package/dist/web/_next/static/chunks/app/queue/{page-82f724d0842f4870.js → page-317151444eda8115.js} +1 -1
- package/dist/web/_next/static/chunks/app/settings/page-ec85a538fda29964.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-950df0f512eef7ec.js → webpack-a7f5c4d1eda36000.js} +1 -1
- package/dist/web/_next/static/css/0e586e29189e8783.css +1 -0
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +4 -3
- package/prompts/lead1.md +5 -2
- package/prompts/level1.md +50 -38
- package/dist/web/_next/static/chunks/1024-67625a65f58057ae.js +0 -1
- package/dist/web/_next/static/chunks/1077.9fe1c0425bf51375.js +0 -1
- package/dist/web/_next/static/chunks/1548.cae3ba2196c8d52f.js +0 -1
- package/dist/web/_next/static/chunks/2163.5c9f8477d98b75a4.js +0 -1
- package/dist/web/_next/static/chunks/714.a0b32193f71e0e91.js +0 -1
- package/dist/web/_next/static/chunks/7220.5d6da026e0b34169.js +0 -1
- package/dist/web/_next/static/chunks/7921-0f7954cb5a9f697b.js +0 -1
- package/dist/web/_next/static/chunks/8124-a39d85dff0db6600.js +0 -1
- package/dist/web/_next/static/chunks/8584.6aa7ce56f7552f17.js +0 -1
- package/dist/web/_next/static/chunks/9067.2e4ba2e0e572f21e.js +0 -1
- package/dist/web/_next/static/chunks/9747.763da2026719a863.js +0 -1
- package/dist/web/_next/static/chunks/9929-2e0b1d006ebd5345.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-52a2079ffa83c21f.js +0 -1
- package/dist/web/_next/static/chunks/app/page-44eac9d137f26dc5.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-2df196e25cb7bfe1.js +0 -1
- package/dist/web/_next/static/css/cfe8ccb4adf3a311.css +0 -1
- /package/dist/web/_next/static/{DzoLjnxX5FvdxuPasWlnb → NP3hd8WmgkJYg_cn8gcXy}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{DzoLjnxX5FvdxuPasWlnb → NP3hd8WmgkJYg_cn8gcXy}/_ssgManifest.js +0 -0
|
@@ -94,9 +94,9 @@ let OperatorController = class OperatorController {
|
|
|
94
94
|
const scripts = { inForce: resolved.execution.scripts, writtenScripts: resolved.execution.writtenScripts };
|
|
95
95
|
return { raw, defaults, resolved: resolved.resolved, picker, programs, scripts };
|
|
96
96
|
}
|
|
97
|
+
/** Saved, and taken at once by the work going on where it can be (2026-11-03): the answer says what was, and what waits. */
|
|
97
98
|
async saveSettings(body) {
|
|
98
|
-
await this.ops.
|
|
99
|
-
return { ok: true };
|
|
99
|
+
return await this.ops.saveSettings(body).catch(fail);
|
|
100
100
|
}
|
|
101
101
|
// --- level 1 ----------------------------------------------------------------------------
|
|
102
102
|
/** The contract the bot gives Copilot, as it ships: shown in Settings to read, changed only by an update of the bot. */
|
|
@@ -287,7 +287,8 @@ let OperatorController = class OperatorController {
|
|
|
287
287
|
/**
|
|
288
288
|
* A new branch from main, from the chat (2026-10-26): what it would start from — `fetch` true fetches the remote's
|
|
289
289
|
* main first, through Git's own password window when it asks — and then the branch made, the uncommitted changes
|
|
290
|
-
* taken to it (`carry: take`)
|
|
290
|
+
* taken to it (`carry: take`), put aside (`carry: aside`) or committed on the branch it is on (`carry: commit`, with
|
|
291
|
+
* `message`), after checking the folder is what the preview read.
|
|
291
292
|
*/
|
|
292
293
|
newBranchPreview(body = {}) {
|
|
293
294
|
return this.ops.newBranchPreview(body?.fetch !== false).catch(fail);
|
|
@@ -403,9 +404,12 @@ let OperatorController = class OperatorController {
|
|
|
403
404
|
throw new BadRequestException('n, the subtask\'s number, is required');
|
|
404
405
|
return this.ops.chatRetrySubtask(id, taskId, n, body?.fresh === true).catch(fail);
|
|
405
406
|
}
|
|
406
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* A question of the chat or the lead: the operator's answer, as text; for one of several answers (2026-11-02), the
|
|
409
|
+
* ones chosen by their place in `chosen`, with any text besides. Stopping the task is `approvals/:id` with abort.
|
|
410
|
+
*/
|
|
407
411
|
answerQuestion(id, body) {
|
|
408
|
-
const result = this.ops.answerQuestion(id, typeof body?.text === 'string' ? body.text : '', body?.ran === false ? false : undefined, typeof body?.outcome === 'string' ? body.outcome : undefined);
|
|
412
|
+
const result = this.ops.answerQuestion(id, typeof body?.text === 'string' ? body.text : '', body?.ran === false ? false : undefined, typeof body?.outcome === 'string' ? body.outcome : undefined, body?.chosen);
|
|
409
413
|
if (!result.ok)
|
|
410
414
|
throw new BadRequestException(result.problem);
|
|
411
415
|
return result;
|
|
@@ -23,10 +23,11 @@ import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, writeFileAtomically } from '
|
|
|
23
23
|
import { checkItems, emptyQueue, itemTitle, mergeItems, nextStep, parkAfterMs, parkedAnswerFrom, skippedBecause, statusOfTask, waitsByHand, MAX_PARK_AFTER_SEC, PARKED_WORDS } from '../queue/queue.js';
|
|
24
24
|
import { branchStart, makeQueueBranch, refreshQueueBranch } from '../queue/queueBranch.js';
|
|
25
25
|
import { EventBus } from '../session/events.js';
|
|
26
|
-
import { MAX_INSTRUCTION_CHARS, newId } from '../session/model.js';
|
|
26
|
+
import { MAX_INSTRUCTION_CHARS, newId, withProblemAt } from '../session/model.js';
|
|
27
27
|
import { handoffOutcomeOf, handoffResultMessage } from '../orchestrator/handoff.js';
|
|
28
28
|
import { runSession, queuedToRun, failedWhileOpening, pickerOptions } from '../orchestrator/taskRunner.js';
|
|
29
|
-
import { Hold } from '../orchestrator/hold.js';
|
|
29
|
+
import { Hold, WaitsFor } from '../orchestrator/hold.js';
|
|
30
|
+
import { chosenAnswer, chosenSaid } from '../orchestrator/chosenAnswers.js';
|
|
30
31
|
import { exportFileName, exportMachine, writeAttemptRecord } from '../session/exports.js';
|
|
31
32
|
import { suggestRunName } from '../session/runName.js';
|
|
32
33
|
import { buildStory } from '../session/story.js';
|
|
@@ -100,6 +101,25 @@ import { createZip } from '../util/zip.js';
|
|
|
100
101
|
import { settingsOf, SettingsUnusableError } from './settings.js';
|
|
101
102
|
import { PolicyLockUnusableError } from '../config/lockedPolicy.js';
|
|
102
103
|
import { chatDenyPatterns } from '../config/schema.js';
|
|
104
|
+
import { LiveSettings, mergedChange } from '../config/live.js';
|
|
105
|
+
/**
|
|
106
|
+
* The rules each step of a run is judged by, from its settings: at the start, and again when a save changes them while
|
|
107
|
+
* it goes on (2026-11-03). The mode is not among them: it is the start's, and "run the rest without asking" changes it.
|
|
108
|
+
*/
|
|
109
|
+
function stepRules(cfg) {
|
|
110
|
+
return {
|
|
111
|
+
denyPatterns: cfg.execution.denyPatterns,
|
|
112
|
+
allowedPrograms: cfg.execution.allowedPrograms,
|
|
113
|
+
isolation: cfg.execution.isolation,
|
|
114
|
+
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
115
|
+
networkFetch: cfg.execution.networkFetch,
|
|
116
|
+
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
117
|
+
readOnlyPrograms: cfg.execution.readOnlyPrograms,
|
|
118
|
+
runWithoutAsking: cfg.execution.runWithoutAsking,
|
|
119
|
+
scripts: cfg.execution.scripts,
|
|
120
|
+
writtenScripts: cfg.execution.writtenScripts,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
103
123
|
const INACTIVE_REASON = 'the session is inactive; make it active on the Sessions page to run it';
|
|
104
124
|
/**
|
|
105
125
|
* Why the browser cannot be had now, said in terms of what was pressed. The sentences a start, a
|
|
@@ -165,12 +185,24 @@ let OperatorService = class OperatorService {
|
|
|
165
185
|
followsActing = this.bus.subscribe('*', (e) => {
|
|
166
186
|
if (e.type === 'acting' && e.data)
|
|
167
187
|
this.acting.set(e.sessionId, e.data);
|
|
188
|
+
else if (e.type === 'browser:sign-in-required' || e.type === 'browser:verification-required') {
|
|
189
|
+
// The Copilot window waits for the operator to sign in, or to show a person is there: not counted (2026-10-29).
|
|
190
|
+
this.holdOf(e.sessionId)?.waitFor(`${e.type}:${e.sessionId}`);
|
|
191
|
+
}
|
|
192
|
+
else if (e.type === 'browser:signed-in' || e.type === 'browser:verification-cleared') {
|
|
193
|
+
this.holdOf(e.sessionId)?.waited(`${e.type === 'browser:signed-in' ? 'browser:sign-in-required' : 'browser:verification-required'}:${e.sessionId}`);
|
|
194
|
+
}
|
|
168
195
|
else if (e.type === 'password-window') {
|
|
169
196
|
const open = e.data?.open === true;
|
|
170
197
|
if (open)
|
|
171
198
|
this.passwordAsked.set(e.sessionId, e.at);
|
|
172
199
|
else
|
|
173
200
|
this.passwordAsked.delete(e.sessionId);
|
|
201
|
+
// Git's own window waits for the operator's password: not counted either (2026-10-29).
|
|
202
|
+
if (open)
|
|
203
|
+
this.holdOf(e.sessionId)?.waitFor(`pw:${e.sessionId}`);
|
|
204
|
+
else
|
|
205
|
+
this.holdOf(e.sessionId)?.waited(`pw:${e.sessionId}`);
|
|
174
206
|
// In the queue, a password nobody types sets the task aside, as an unanswered card does (2026-10-26).
|
|
175
207
|
if (open) {
|
|
176
208
|
const step = Number(e.data?.id) || 0;
|
|
@@ -182,12 +214,29 @@ let OperatorService = class OperatorService {
|
|
|
182
214
|
else if (e.type === 'task-finished') {
|
|
183
215
|
this.acting.delete(e.sessionId);
|
|
184
216
|
this.passwordAsked.delete(e.sessionId);
|
|
217
|
+
for (const key of [`pw:${e.sessionId}`, `browser:sign-in-required:${e.sessionId}`, `browser:verification-required:${e.sessionId}`])
|
|
218
|
+
this.holdOf(e.sessionId)?.waited(key);
|
|
185
219
|
const status = e.data?.status;
|
|
186
220
|
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId))
|
|
187
221
|
this.lastOutcome = { status, at: e.at, sessionId: e.sessionId };
|
|
188
222
|
}
|
|
189
223
|
});
|
|
190
|
-
|
|
224
|
+
/**
|
|
225
|
+
* What waits for the operator: every card, by its id. Each one put here starts a wait on its run's clock and its going
|
|
226
|
+
* — answered, set aside, stopped — ends it, so a task's minutes, and its limit, leave out the time it waited
|
|
227
|
+
* (operator, 2026-10-29: "while the bot waits for the user to type something or answer, it must not count").
|
|
228
|
+
*/
|
|
229
|
+
waiting = new WaitsFor((id, w, begins) => {
|
|
230
|
+
const hold = this.holdOf(w.approval.sessionId);
|
|
231
|
+
if (begins)
|
|
232
|
+
hold?.waitFor(`card:${id}`);
|
|
233
|
+
else
|
|
234
|
+
hold?.waited(`card:${id}`);
|
|
235
|
+
});
|
|
236
|
+
/** The clock of the run a session's work belongs to: its own, or its lead's for a worker. */
|
|
237
|
+
holdOf(sessionId) {
|
|
238
|
+
return this.running.get(this.runKey(sessionId))?.hold;
|
|
239
|
+
}
|
|
191
240
|
/**
|
|
192
241
|
* The workers of the two-chat mode, by the session of the lead they work for (2026-10-20). A worker's steps and cards
|
|
193
242
|
* carry its own session's id, while the run, its mode and its Stop are the lead's: they are looked up through this.
|
|
@@ -272,7 +321,7 @@ let OperatorService = class OperatorService {
|
|
|
272
321
|
if (interruption)
|
|
273
322
|
t.interruption = interruption;
|
|
274
323
|
if (vcs?.commit) {
|
|
275
|
-
t.vcs = vcs;
|
|
324
|
+
t.vcs = withProblemAt(t.vcs, vcs);
|
|
276
325
|
t.reason = `${t.reason ?? ''} What it had changed is committed on ${vcs.branch} as ${vcs.commit?.slice(0, 8)}.`.trim();
|
|
277
326
|
}
|
|
278
327
|
// The same fixed-shape ending a task the runner finished gets; the steps the bot never
|
|
@@ -839,19 +888,10 @@ let OperatorService = class OperatorService {
|
|
|
839
888
|
const loaded = await this.settings.load();
|
|
840
889
|
// A chat conversation's git is the operator's: switching branches and committing are allowed there (2026-10-17).
|
|
841
890
|
const cfg = session.kind === 'chat' ? { ...loaded, execution: { ...loaded.execution, denyPatterns: chatDenyPatterns(loaded.execution.denyPatterns) } } : loaded;
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
isolation: cfg.execution.isolation,
|
|
847
|
-
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
848
|
-
// Read once per run like the rest of the policy: a change in Settings applies from the next start.
|
|
849
|
-
networkFetch: cfg.execution.networkFetch,
|
|
850
|
-
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
851
|
-
readOnlyPrograms: cfg.execution.readOnlyPrograms,
|
|
852
|
-
scripts: cfg.execution.scripts,
|
|
853
|
-
writtenScripts: cfg.execution.writtenScripts,
|
|
854
|
-
};
|
|
891
|
+
// The run's own settings; a save while it goes on changes them in place (`saveSettings`), and these rules with them.
|
|
892
|
+
const runCfg = { ...cfg, execution: { ...cfg.execution, mode } };
|
|
893
|
+
const live = new LiveSettings(runCfg, session.kind === 'chat', loaded);
|
|
894
|
+
const policy = { mode, ...stepRules(runCfg) };
|
|
855
895
|
/*
|
|
856
896
|
* An unattended run that cannot legally execute anything is stopped here, where the operator
|
|
857
897
|
* is looking, rather than starting and returning every step refused. The step gate holds the
|
|
@@ -878,7 +918,7 @@ let OperatorService = class OperatorService {
|
|
|
878
918
|
const authorizer = this.webAuthorizer(policy, controller.signal);
|
|
879
919
|
const startedAt = new Date().toISOString();
|
|
880
920
|
const hold = new Hold();
|
|
881
|
-
this.running.set(sessionId, { controller, startedAt, mode, policy, hold });
|
|
921
|
+
this.running.set(sessionId, { controller, startedAt, mode, policy, hold, live });
|
|
882
922
|
// Who was at work in a run of it that ended without saying so is not who is at work in this one.
|
|
883
923
|
this.acting.delete(sessionId);
|
|
884
924
|
{
|
|
@@ -900,7 +940,8 @@ let OperatorService = class OperatorService {
|
|
|
900
940
|
'tenant; secret-shaped strings are redacted first',
|
|
901
941
|
});
|
|
902
942
|
const done = runSession(sessionId, {
|
|
903
|
-
cfg:
|
|
943
|
+
cfg: runCfg,
|
|
944
|
+
live,
|
|
904
945
|
store: this.store,
|
|
905
946
|
bus: this.bus,
|
|
906
947
|
authorizer,
|
|
@@ -1089,6 +1130,8 @@ let OperatorService = class OperatorService {
|
|
|
1089
1130
|
...(run?.hold?.held ? { paused: true } : {}),
|
|
1090
1131
|
// Git asks for a password in its own window, and the work waits for it (2026-10-26).
|
|
1091
1132
|
...(this.passwordAsked.size > 0 ? { password: true } : {}),
|
|
1133
|
+
// The queue still has its turn going, between one of its tasks and the next (2026-11-03): the work is not over.
|
|
1134
|
+
...(this.queueLoop ? { queue: true } : {}),
|
|
1092
1135
|
// How the last message ended, while nothing runs: what the tab says until the operator has looked.
|
|
1093
1136
|
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at } } : {}),
|
|
1094
1137
|
};
|
|
@@ -1153,7 +1196,7 @@ let OperatorService = class OperatorService {
|
|
|
1153
1196
|
throw new Error(busy);
|
|
1154
1197
|
return await planNewBranch(ws.dir, { fetch, askpass: fetch ? await askpassProgram() : null });
|
|
1155
1198
|
}
|
|
1156
|
-
/** The branch made and checked out, the uncommitted changes taken to it or
|
|
1199
|
+
/** The branch made and checked out, the uncommitted changes taken to it, put aside or committed where they are, as the operator chose. */
|
|
1157
1200
|
async newBranchCreate(input) {
|
|
1158
1201
|
const ws = await this.workspace();
|
|
1159
1202
|
if (!ws.ok)
|
|
@@ -1163,8 +1206,9 @@ let OperatorService = class OperatorService {
|
|
|
1163
1206
|
throw new Error(busy);
|
|
1164
1207
|
return await createNewBranch(ws.dir, {
|
|
1165
1208
|
name: typeof input.name === 'string' ? input.name : '',
|
|
1166
|
-
carry: input.carry === 'aside'
|
|
1209
|
+
carry: input.carry === 'aside' || input.carry === 'commit' ? input.carry : 'take',
|
|
1167
1210
|
fingerprint: typeof input.fingerprint === 'string' ? input.fingerprint : '',
|
|
1211
|
+
...(typeof input.message === 'string' && input.message.trim() ? { message: input.message.trim().slice(0, 2000) } : {}),
|
|
1168
1212
|
// The saved branch under the bot's own prefix, as its other branches are.
|
|
1169
1213
|
prefix: DEFAULT_VCS.branchPrefix,
|
|
1170
1214
|
});
|
|
@@ -1886,7 +1930,15 @@ let OperatorService = class OperatorService {
|
|
|
1886
1930
|
}
|
|
1887
1931
|
else if (a.kind === 'question') {
|
|
1888
1932
|
const handed = p.approval.question?.handoff;
|
|
1889
|
-
|
|
1933
|
+
const q = p.approval.question;
|
|
1934
|
+
const asked = `You asked: ${q?.text ?? ''}\n\n`;
|
|
1935
|
+
// An answer chosen that carries a command (2026-11-02): the card says it runs it, so the chat is told to.
|
|
1936
|
+
const run = q && !a.chosen ? q.commands?.[q.options.indexOf(a.answer)] : undefined;
|
|
1937
|
+
note = handed
|
|
1938
|
+
? handoffResultMessage(handed, handoffOutcomeOf(a.outcome, a.ran), a.answer)
|
|
1939
|
+
: a.chosen
|
|
1940
|
+
? `${asked}The operator answered your question, ${chosenSaid({ chosen: a.chosen, ...(a.written ? { written: a.written } : {}) })}`
|
|
1941
|
+
: `${asked}The operator answers: ${a.answer}${run ? `\n\nThat answer carries a command: send \`${run}\` as your next step.` : ''}`;
|
|
1890
1942
|
}
|
|
1891
1943
|
else if (a.kind === 'retry' && p.approval.retry) {
|
|
1892
1944
|
const r = p.approval.retry;
|
|
@@ -2093,6 +2145,7 @@ let OperatorService = class OperatorService {
|
|
|
2093
2145
|
...(ask.why ? { why: ask.why } : {}),
|
|
2094
2146
|
options: ask.options,
|
|
2095
2147
|
...(ask.commands?.some(Boolean) ? { commands: ask.commands } : {}),
|
|
2148
|
+
...(ask.multiple ? { multiple: true } : {}),
|
|
2096
2149
|
...(ask.handoff ? { handoff: ask.handoff } : {}),
|
|
2097
2150
|
},
|
|
2098
2151
|
};
|
|
@@ -2176,10 +2229,21 @@ let OperatorService = class OperatorService {
|
|
|
2176
2229
|
const cfg = await this.settings.load();
|
|
2177
2230
|
return await this.start(threadId, cfg.execution.mode);
|
|
2178
2231
|
}
|
|
2179
|
-
answerQuestion(approvalId, text, ran, outcome) {
|
|
2232
|
+
answerQuestion(approvalId, text, ran, outcome, chosen) {
|
|
2180
2233
|
const w = this.waiting.get(approvalId);
|
|
2181
2234
|
if (!w?.resolveAnswer)
|
|
2182
2235
|
return { ok: false, problem: 'No question of the lead is waiting under that id.' };
|
|
2236
|
+
// A question of several answers (2026-11-02): the ones chosen, by their place, and what was written besides.
|
|
2237
|
+
if (chosen !== undefined && w.approval.question && !w.approval.question.handoff) {
|
|
2238
|
+
const many = chosenAnswer(w.approval.question, chosen, text);
|
|
2239
|
+
if ('problem' in many)
|
|
2240
|
+
return { ok: false, problem: many.problem };
|
|
2241
|
+
this.waiting.delete(approvalId);
|
|
2242
|
+
w.resolveAnswer(many);
|
|
2243
|
+
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
2244
|
+
message: `the operator chose ${many.chosen.length} of the answers`, data: { approvalId, question: true } });
|
|
2245
|
+
return { ok: true };
|
|
2246
|
+
}
|
|
2183
2247
|
/*
|
|
2184
2248
|
* Commands handed over (2026-10-26): what they printed; sent back for a correction, which needs what to correct
|
|
2185
2249
|
* (2026-10-27); or that the operator will not run them, with a word or none.
|
|
@@ -2691,6 +2755,26 @@ let OperatorService = class OperatorService {
|
|
|
2691
2755
|
* folder that is not there, a name used twice, and the default listed again among the others
|
|
2692
2756
|
* — each of those would be a setting that looks filled in and points nowhere.
|
|
2693
2757
|
*/
|
|
2758
|
+
/**
|
|
2759
|
+
* Settings saved from their page (operator, 2026-11-03: "when I change a setting, if it can be, let it take effect at
|
|
2760
|
+
* once, even while a task is running"). Each run at work takes what can change under a message into its own settings
|
|
2761
|
+
* at once — the rules its steps are judged by with them — and the answer says, for the page to show, what did and
|
|
2762
|
+
* what waits for the next message or the next chat window. See `config/live.ts`.
|
|
2763
|
+
*/
|
|
2764
|
+
async saveSettings(body) {
|
|
2765
|
+
const saved = await this.settings.save(body);
|
|
2766
|
+
const changes = [];
|
|
2767
|
+
for (const run of this.running.values()) {
|
|
2768
|
+
changes.push(run.live.take(saved));
|
|
2769
|
+
Object.assign(run.policy, stepRules(run.live.cfg));
|
|
2770
|
+
// A lock that holds runs to asking now holds this one too, whatever it started as.
|
|
2771
|
+
if (run.policy.lockedToConfirm && run.mode === 'unattended') {
|
|
2772
|
+
run.mode = 'confirm';
|
|
2773
|
+
run.policy.mode = 'confirm';
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return { ok: true, running: this.running.size, ...mergedChange(changes) };
|
|
2777
|
+
}
|
|
2694
2778
|
async setProject(patch) {
|
|
2695
2779
|
// Worked out from the file in its turn (see `Settings.update`), so a model chosen at the same
|
|
2696
2780
|
// moment is kept, and a refusal below leaves the file as it was.
|
package/dist/src/cli.js
CHANGED
|
@@ -502,6 +502,7 @@ program
|
|
|
502
502
|
networkFetch: cfg.execution.networkFetch,
|
|
503
503
|
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
504
504
|
readOnlyPrograms: cfg.execution.readOnlyPrograms,
|
|
505
|
+
runWithoutAsking: cfg.execution.runWithoutAsking,
|
|
505
506
|
scripts: cfg.execution.scripts,
|
|
506
507
|
writtenScripts: cfg.execution.writtenScripts,
|
|
507
508
|
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings saved while a message is at work (operator, 2026-11-03: "when I change a setting in Settings, if it can be,
|
|
3
|
+
* let it take effect at once, even while a task is running"). A run read its settings once, when it started, so a
|
|
4
|
+
* program added to "Programs the bot may start" after a step was refused for it was refused again until the next
|
|
5
|
+
* message. Now each run keeps its settings in one object (`LiveSettings.cfg`) and takes into it, in place, what can
|
|
6
|
+
* change under a message without breaking it:
|
|
7
|
+
*
|
|
8
|
+
* - at once (`now`): the rules each step is judged by — the programs, the scripts, the ones set to read only, those
|
|
9
|
+
* run without asking, downloads, the deny patterns, isolation, the variables a step is given, and Settings'
|
|
10
|
+
* agreement with the bot — the time a command may take, the limits, the pauses, the reports and their redaction.
|
|
11
|
+
* Each is read where it is used, so the next step, the next reply or the next message goes by the new value;
|
|
12
|
+
* - from the next message (`next`): what a message is built on when it starts — the models, plan mode, the shell and
|
|
13
|
+
* folder a step runs in by default, the project and its folders, the skills, the contract's stop word, the mode a
|
|
14
|
+
* start takes, and the lead's number of subtasks, which its assignment states;
|
|
15
|
+
* - when the chat window opens again (`window`): the chat's address, its browser and the waits and locators the
|
|
16
|
+
* window was opened with; it is kept open between messages.
|
|
17
|
+
*
|
|
18
|
+
* A step that is running, and a card already put to the operator, go on as they began. The locked policy, when there is
|
|
19
|
+
* one, is in what was saved (`loadConfigObject`), so it is taken with the rest and still wins.
|
|
20
|
+
*/
|
|
21
|
+
import { chatDenyPatterns } from './schema.js';
|
|
22
|
+
/** Taken at once, by section; `*` is every field of it. */
|
|
23
|
+
const NOW = {
|
|
24
|
+
execution: [
|
|
25
|
+
'networkFetch', 'questions', 'commandTimeoutSec', 'idleTimeoutSec', 'longCommandTimeoutSec', 'longIdleTimeoutSec',
|
|
26
|
+
'maxStepTimeoutSec', 'isolation', 'passEnv', 'allowedPrograms', 'readOnlyPrograms', 'runWithoutAsking', 'scripts',
|
|
27
|
+
'writtenScripts', 'denyPatterns',
|
|
28
|
+
],
|
|
29
|
+
limits: '*',
|
|
30
|
+
pacing: '*',
|
|
31
|
+
report: '*',
|
|
32
|
+
};
|
|
33
|
+
/** Of a section taken whole, what a message is told when it starts: the lead's number of subtasks is its assignment's. */
|
|
34
|
+
const NOT_NOW = {
|
|
35
|
+
limits: ['maxSubtasks'],
|
|
36
|
+
};
|
|
37
|
+
/** What the chat window was opened with. */
|
|
38
|
+
const WINDOW = {
|
|
39
|
+
copilot: ['url', 'profileDir', 'channel', 'headless', 'replyTimeoutSec', 'signInTimeoutSec', 'humanWaitSec', 'keepFailurePage', 'pickerLocators', 'pickerSteps'],
|
|
40
|
+
};
|
|
41
|
+
/** The sections a run compares; the rest (where the bot keeps its records) is read when the bot starts. */
|
|
42
|
+
const SECTIONS = ['copilot', 'task', 'execution', 'report', 'project', 'skills', 'pacing', 'limits'];
|
|
43
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
44
|
+
function classOf(section, key) {
|
|
45
|
+
if (NOT_NOW[section]?.includes(key))
|
|
46
|
+
return 'next';
|
|
47
|
+
const now = NOW[section];
|
|
48
|
+
if (now === '*' || now?.includes(key))
|
|
49
|
+
return 'now';
|
|
50
|
+
return WINDOW[section]?.includes(key) ? 'window' : 'next';
|
|
51
|
+
}
|
|
52
|
+
/** One run's settings, and those who hear when a save changes what it goes by. */
|
|
53
|
+
export class LiveSettings {
|
|
54
|
+
cfg;
|
|
55
|
+
chat;
|
|
56
|
+
listeners = new Set();
|
|
57
|
+
/** The settings as last saved, so a save names what it changed, not what an earlier one did. */
|
|
58
|
+
last;
|
|
59
|
+
/**
|
|
60
|
+
* `cfg`: the run's own; `chat`: a conversation of the workbench's chat, whose deny patterns leave its git to the
|
|
61
|
+
* operator; `loaded`: the settings the run was made from, before that.
|
|
62
|
+
*/
|
|
63
|
+
constructor(cfg, chat, loaded = cfg) {
|
|
64
|
+
this.cfg = cfg;
|
|
65
|
+
this.chat = chat;
|
|
66
|
+
this.last = JSON.parse(JSON.stringify(loaded));
|
|
67
|
+
}
|
|
68
|
+
/** Hears every save that changes something this run takes at once. */
|
|
69
|
+
onChange(fn) {
|
|
70
|
+
this.listeners.add(fn);
|
|
71
|
+
return () => this.listeners.delete(fn);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Takes what was saved: the fields this run takes at once go into `cfg`, in place, so every part of the run holding
|
|
75
|
+
* it reads them; the rest is only named. Those who listen hear of it when anything was taken.
|
|
76
|
+
*/
|
|
77
|
+
take(saved) {
|
|
78
|
+
const change = { now: [], next: [], window: [] };
|
|
79
|
+
const target = this.cfg;
|
|
80
|
+
const source = saved;
|
|
81
|
+
for (const section of SECTIONS) {
|
|
82
|
+
const before = this.last[section] ?? {};
|
|
83
|
+
const from = source[section];
|
|
84
|
+
if (!from || typeof from !== 'object')
|
|
85
|
+
continue;
|
|
86
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(from)])) {
|
|
87
|
+
if (same(before[key], from[key]))
|
|
88
|
+
continue;
|
|
89
|
+
const kind = classOf(section, key);
|
|
90
|
+
change[kind].push(`${section}.${key}`);
|
|
91
|
+
if (kind !== 'now' || !target[section])
|
|
92
|
+
continue;
|
|
93
|
+
const value = from[key];
|
|
94
|
+
target[section][key] = section === 'execution' && key === 'denyPatterns' && this.chat && Array.isArray(value) ? chatDenyPatterns(value) : value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.last = JSON.parse(JSON.stringify(saved));
|
|
98
|
+
if (change.now.length > 0) {
|
|
99
|
+
this.cfg.policyLock = saved.policyLock;
|
|
100
|
+
for (const fn of this.listeners) {
|
|
101
|
+
try {
|
|
102
|
+
fn(change);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// One that cannot hear it does not keep it from the others.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return change;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** The names of several runs' changes together, each once. */
|
|
113
|
+
export function mergedChange(changes) {
|
|
114
|
+
const out = { now: [], next: [], window: [] };
|
|
115
|
+
for (const c of changes) {
|
|
116
|
+
for (const k of ['now', 'next', 'window'])
|
|
117
|
+
for (const name of c[k])
|
|
118
|
+
if (!out[k].includes(name))
|
|
119
|
+
out[k].push(name);
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
@@ -307,6 +307,13 @@ export const RunConfigSchema = z.object({
|
|
|
307
307
|
* named here are ignored.
|
|
308
308
|
*/
|
|
309
309
|
readOnlyPrograms: z.array(z.string()).default([]),
|
|
310
|
+
/**
|
|
311
|
+
* Programs on the list that reach a platform with the operator's access, set to run without asking (operator,
|
|
312
|
+
* 2026-10-28: "az asks for permission again, although it is on the list of allowed commands"): their commands run
|
|
313
|
+
* as any other step's, changes included — no card. The refused techniques, the folders and the network hold still
|
|
314
|
+
* apply. A program set to read only is not one of these.
|
|
315
|
+
*/
|
|
316
|
+
runWithoutAsking: z.array(z.string()).default([]),
|
|
310
317
|
/**
|
|
311
318
|
* Which scripts may run (operator, 2026-10-27: "whether I allow npm, ts files, ps1 files … only for scripts that
|
|
312
319
|
* are already there, and another box for scripts the bot created"). For each kind (`exec/scriptKinds.ts`): `own`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { staticCheck, describeStep } from './policy.js';
|
|
2
2
|
import { networkFetchReason, networkFetchRefusal } from './network.js';
|
|
3
|
-
import { scriptNetworkReason } from './policy.js';
|
|
3
|
+
import { notHeldFor, scriptNetworkReason } from './policy.js';
|
|
4
4
|
import { platformOf, platformReason } from './platforms.js';
|
|
5
5
|
import { readOnlyUnclearRefusal, readOnlyVerdict } from './readOnly.js';
|
|
6
6
|
import { scriptText, writtenScriptsLetRun } from './scriptFiles.js';
|
|
@@ -67,7 +67,7 @@ export function makeAuthorizer(cfg, askPerson, signal) {
|
|
|
67
67
|
? (platformReason(step.cmd, step.shell) ?? platformOf(unclear.program) ?? unclear.program)
|
|
68
68
|
: cfg.platformAccess === 'allow'
|
|
69
69
|
? null
|
|
70
|
-
: platformReason(step.cmd, step.shell, reading?.kind === 'reads' ?
|
|
70
|
+
: platformReason(step.cmd, step.shell, notHeldFor(cfg, reading?.kind === 'reads' ? reading.programs : []));
|
|
71
71
|
const held = {
|
|
72
72
|
...(platform ? { platform } : {}),
|
|
73
73
|
...(unclear ? { readOnly: unclear.why, readOnlyProgram: unclear.program } : {}),
|
|
@@ -77,12 +77,18 @@ class PowerShellScan {
|
|
|
77
77
|
calls = [];
|
|
78
78
|
uncertain;
|
|
79
79
|
depth = 0;
|
|
80
|
+
exits = 0;
|
|
80
81
|
constructor(s) {
|
|
81
82
|
this.s = s;
|
|
82
83
|
}
|
|
83
84
|
run() {
|
|
84
85
|
this.statements(0, null);
|
|
85
|
-
return
|
|
86
|
+
return {
|
|
87
|
+
heads: this.heads,
|
|
88
|
+
calls: this.calls,
|
|
89
|
+
...(this.uncertain ? { uncertain: this.uncertain } : {}),
|
|
90
|
+
...(this.exits ? { exits: this.exits } : {}),
|
|
91
|
+
};
|
|
86
92
|
}
|
|
87
93
|
/** A literal head: recorded, with the invocation its arguments are read into. */
|
|
88
94
|
record(head) {
|
|
@@ -231,8 +237,11 @@ class PowerShellScan {
|
|
|
231
237
|
return this.typeDefinition(word.end);
|
|
232
238
|
if (PIPELINE_KEYWORDS.has(lower))
|
|
233
239
|
return this.element(word.end);
|
|
234
|
-
if (BLOCK_KEYWORDS.has(lower))
|
|
240
|
+
if (BLOCK_KEYWORDS.has(lower)) {
|
|
241
|
+
if (lower === 'exit')
|
|
242
|
+
this.exits += 1;
|
|
235
243
|
return this.keywordRest(word.end);
|
|
244
|
+
}
|
|
236
245
|
}
|
|
237
246
|
if (word.dynamic)
|
|
238
247
|
this.fail(`the command "${word.literal}" is built from a variable, so which program it starts is known only when it runs`);
|