copilot-operator 0.1.70 → 0.1.75
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 +2 -1
- package/dist/src/api/operator.service.js +35 -4
- package/dist/src/cli.js +1 -0
- package/dist/src/config/schema.js +7 -0
- package/dist/src/exec/authorizer.js +2 -2
- 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 +20 -2
- package/dist/src/exec/scriptKinds.js +7 -7
- package/dist/src/orchestrator/hold.js +83 -4
- package/dist/src/orchestrator/taskRunner.js +1 -0
- package/dist/src/plan/kerrigan.js +34 -13
- package/dist/src/plan/systemGuide.js +34 -10
- package/dist/src/vcs/newBranch.js +69 -10
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.14d6c828d8f71111.js +1 -0
- package/dist/web/_next/static/chunks/1548.2f75926c6e664f79.js +1 -0
- package/dist/web/_next/static/chunks/2163.f9f1ad4af05520cc.js +1 -0
- package/dist/web/_next/static/chunks/714.4507656685cb9337.js +1 -0
- package/dist/web/_next/static/chunks/7220.9bc9dd9f211b11e4.js +1 -0
- package/dist/web/_next/static/chunks/7921-9aaec581982b2329.js +1 -0
- package/dist/web/_next/static/chunks/8584.f2cb3ca81223d626.js +1 -0
- package/dist/web/_next/static/chunks/9067.a6cb3b9157a80921.js +1 -0
- package/dist/web/_next/static/chunks/9747.15aa40a046d54a2a.js +1 -0
- package/dist/web/_next/static/chunks/app/page-80730838a81da226.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/{page-2df196e25cb7bfe1.js → page-4f3c739287d7f32e.js} +1 -1
- package/dist/web/_next/static/chunks/{webpack-950df0f512eef7ec.js → webpack-f9f820c51a8952c8.js} +1 -1
- package/dist/web/_next/static/css/63b30b8e1a4aa500.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 +1 -1
- package/prompts/level1.md +42 -36
- 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/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/app/page-44eac9d137f26dc5.js +0 -1
- package/dist/web/_next/static/css/cfe8ccb4adf3a311.css +0 -1
- /package/dist/web/_next/static/{DzoLjnxX5FvdxuPasWlnb → 9DmRzBb0M5BZ3dvVpbFMM}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{DzoLjnxX5FvdxuPasWlnb → 9DmRzBb0M5BZ3dvVpbFMM}/_ssgManifest.js +0 -0
|
@@ -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);
|
|
@@ -26,7 +26,7 @@ import { EventBus } from '../session/events.js';
|
|
|
26
26
|
import { MAX_INSTRUCTION_CHARS, newId } 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
30
|
import { exportFileName, exportMachine, writeAttemptRecord } from '../session/exports.js';
|
|
31
31
|
import { suggestRunName } from '../session/runName.js';
|
|
32
32
|
import { buildStory } from '../session/story.js';
|
|
@@ -165,12 +165,24 @@ let OperatorService = class OperatorService {
|
|
|
165
165
|
followsActing = this.bus.subscribe('*', (e) => {
|
|
166
166
|
if (e.type === 'acting' && e.data)
|
|
167
167
|
this.acting.set(e.sessionId, e.data);
|
|
168
|
+
else if (e.type === 'browser:sign-in-required' || e.type === 'browser:verification-required') {
|
|
169
|
+
// The Copilot window waits for the operator to sign in, or to show a person is there: not counted (2026-10-29).
|
|
170
|
+
this.holdOf(e.sessionId)?.waitFor(`${e.type}:${e.sessionId}`);
|
|
171
|
+
}
|
|
172
|
+
else if (e.type === 'browser:signed-in' || e.type === 'browser:verification-cleared') {
|
|
173
|
+
this.holdOf(e.sessionId)?.waited(`${e.type === 'browser:signed-in' ? 'browser:sign-in-required' : 'browser:verification-required'}:${e.sessionId}`);
|
|
174
|
+
}
|
|
168
175
|
else if (e.type === 'password-window') {
|
|
169
176
|
const open = e.data?.open === true;
|
|
170
177
|
if (open)
|
|
171
178
|
this.passwordAsked.set(e.sessionId, e.at);
|
|
172
179
|
else
|
|
173
180
|
this.passwordAsked.delete(e.sessionId);
|
|
181
|
+
// Git's own window waits for the operator's password: not counted either (2026-10-29).
|
|
182
|
+
if (open)
|
|
183
|
+
this.holdOf(e.sessionId)?.waitFor(`pw:${e.sessionId}`);
|
|
184
|
+
else
|
|
185
|
+
this.holdOf(e.sessionId)?.waited(`pw:${e.sessionId}`);
|
|
174
186
|
// In the queue, a password nobody types sets the task aside, as an unanswered card does (2026-10-26).
|
|
175
187
|
if (open) {
|
|
176
188
|
const step = Number(e.data?.id) || 0;
|
|
@@ -182,12 +194,29 @@ let OperatorService = class OperatorService {
|
|
|
182
194
|
else if (e.type === 'task-finished') {
|
|
183
195
|
this.acting.delete(e.sessionId);
|
|
184
196
|
this.passwordAsked.delete(e.sessionId);
|
|
197
|
+
for (const key of [`pw:${e.sessionId}`, `browser:sign-in-required:${e.sessionId}`, `browser:verification-required:${e.sessionId}`])
|
|
198
|
+
this.holdOf(e.sessionId)?.waited(key);
|
|
185
199
|
const status = e.data?.status;
|
|
186
200
|
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId))
|
|
187
201
|
this.lastOutcome = { status, at: e.at, sessionId: e.sessionId };
|
|
188
202
|
}
|
|
189
203
|
});
|
|
190
|
-
|
|
204
|
+
/**
|
|
205
|
+
* 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
|
|
206
|
+
* — answered, set aside, stopped — ends it, so a task's minutes, and its limit, leave out the time it waited
|
|
207
|
+
* (operator, 2026-10-29: "while the bot waits for the user to type something or answer, it must not count").
|
|
208
|
+
*/
|
|
209
|
+
waiting = new WaitsFor((id, w, begins) => {
|
|
210
|
+
const hold = this.holdOf(w.approval.sessionId);
|
|
211
|
+
if (begins)
|
|
212
|
+
hold?.waitFor(`card:${id}`);
|
|
213
|
+
else
|
|
214
|
+
hold?.waited(`card:${id}`);
|
|
215
|
+
});
|
|
216
|
+
/** The clock of the run a session's work belongs to: its own, or its lead's for a worker. */
|
|
217
|
+
holdOf(sessionId) {
|
|
218
|
+
return this.running.get(this.runKey(sessionId))?.hold;
|
|
219
|
+
}
|
|
191
220
|
/**
|
|
192
221
|
* 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
222
|
* carry its own session's id, while the run, its mode and its Stop are the lead's: they are looked up through this.
|
|
@@ -849,6 +878,7 @@ let OperatorService = class OperatorService {
|
|
|
849
878
|
networkFetch: cfg.execution.networkFetch,
|
|
850
879
|
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
851
880
|
readOnlyPrograms: cfg.execution.readOnlyPrograms,
|
|
881
|
+
runWithoutAsking: cfg.execution.runWithoutAsking,
|
|
852
882
|
scripts: cfg.execution.scripts,
|
|
853
883
|
writtenScripts: cfg.execution.writtenScripts,
|
|
854
884
|
};
|
|
@@ -1153,7 +1183,7 @@ let OperatorService = class OperatorService {
|
|
|
1153
1183
|
throw new Error(busy);
|
|
1154
1184
|
return await planNewBranch(ws.dir, { fetch, askpass: fetch ? await askpassProgram() : null });
|
|
1155
1185
|
}
|
|
1156
|
-
/** The branch made and checked out, the uncommitted changes taken to it or
|
|
1186
|
+
/** The branch made and checked out, the uncommitted changes taken to it, put aside or committed where they are, as the operator chose. */
|
|
1157
1187
|
async newBranchCreate(input) {
|
|
1158
1188
|
const ws = await this.workspace();
|
|
1159
1189
|
if (!ws.ok)
|
|
@@ -1163,8 +1193,9 @@ let OperatorService = class OperatorService {
|
|
|
1163
1193
|
throw new Error(busy);
|
|
1164
1194
|
return await createNewBranch(ws.dir, {
|
|
1165
1195
|
name: typeof input.name === 'string' ? input.name : '',
|
|
1166
|
-
carry: input.carry === 'aside'
|
|
1196
|
+
carry: input.carry === 'aside' || input.carry === 'commit' ? input.carry : 'take',
|
|
1167
1197
|
fingerprint: typeof input.fingerprint === 'string' ? input.fingerprint : '',
|
|
1198
|
+
...(typeof input.message === 'string' && input.message.trim() ? { message: input.message.trim().slice(0, 2000) } : {}),
|
|
1168
1199
|
// The saved branch under the bot's own prefix, as its other branches are.
|
|
1169
1200
|
prefix: DEFAULT_VCS.branchPrefix,
|
|
1170
1201
|
});
|
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
|
};
|
|
@@ -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 } : {}),
|
package/dist/src/exec/policy.js
CHANGED
|
@@ -5,7 +5,7 @@ import { inlineCodeRefusal, programRefusal } from './programs.js';
|
|
|
5
5
|
import { unattendedIsolationRefusal } from './isolation.js';
|
|
6
6
|
import { confinementRefusal } from './confinement.js';
|
|
7
7
|
import { botSelfRefusal, networkFetchReason, networkFetchRefusal } from './network.js';
|
|
8
|
-
import { ownScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
|
|
8
|
+
import { ownScriptRefusal, scratchScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
|
|
9
9
|
import { existsSync, readdirSync } from 'node:fs';
|
|
10
10
|
import { dirname, join } from 'node:path';
|
|
11
11
|
import { readOnlyRefusal, readOnlyUnaskedRefusal, readOnlyUnclearRefusal, readOnlyVerdict } from './readOnly.js';
|
|
@@ -218,7 +218,7 @@ export function checkAccessRefusal(command, shell, cfg) {
|
|
|
218
218
|
const reading = readOnlyVerdict(command, shell, cfg.readOnlyPrograms);
|
|
219
219
|
if (reading?.kind === 'unclear')
|
|
220
220
|
return readOnlyUnclearRefusal(reading.program, reading.why);
|
|
221
|
-
const platform = cfg.questions === 'agree' ? null : platformReason(command, shell, reading?.kind === 'reads' ?
|
|
221
|
+
const platform = cfg.questions === 'agree' ? null : platformReason(command, shell, notHeldFor(cfg, reading?.kind === 'reads' ? reading.programs : []));
|
|
222
222
|
if (!platform)
|
|
223
223
|
return null;
|
|
224
224
|
return `refused: this check reaches ${platform} with the operator's access, which only the operator may allow, and a check runs with nobody asked. Check it another way, or do it in a step, where it is put to the operator.`;
|
|
@@ -248,6 +248,14 @@ export function writtenScriptScreen(cfg, confinement, env = process.env) {
|
|
|
248
248
|
return null;
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The programs whose platform a command is not held for: those set to run without asking (2026-10-28), and those set to
|
|
253
|
+
* read only whose every command on the line only reads.
|
|
254
|
+
*/
|
|
255
|
+
export function notHeldFor(cfg, reading) {
|
|
256
|
+
const all = [...(cfg.runWithoutAsking ?? []), ...reading].map((p) => p.trim().toLowerCase().replace(/\.(?:exe|cmd)$/, '')).filter(Boolean);
|
|
257
|
+
return all.length ? new Set(all) : undefined;
|
|
258
|
+
}
|
|
251
259
|
/** A fetch inside a script the line runs — held or refused exactly as one on the line would be. */
|
|
252
260
|
export function scriptNetworkReason(command, cwd) {
|
|
253
261
|
let found = null;
|
|
@@ -305,6 +313,10 @@ actor) {
|
|
|
305
313
|
* next. See `scriptFiles.ts`.
|
|
306
314
|
*/
|
|
307
315
|
if (confinement) {
|
|
316
|
+
// No script written only to be run (operator, 2026-10-28): one written into .cop-tmp is refused at the writing.
|
|
317
|
+
const scratch = scratchScriptRefusal(step.cmd, actor === 'review');
|
|
318
|
+
if (scratch)
|
|
319
|
+
return { action: 'skip', reason: scratch };
|
|
308
320
|
const own = ownScriptRefusal(step.cmd, confinement.cwd, confinement.workStartedAt, effectiveShell(step.shell), {
|
|
309
321
|
rules: cfg.scripts,
|
|
310
322
|
reviewer: actor === 'review',
|
|
@@ -79,6 +79,7 @@ export function collectPolicyManifest(input, env = process.env) {
|
|
|
79
79
|
},
|
|
80
80
|
readOnly: readOnlyInForce(input.readOnlyPrograms ?? [], input.allowedPrograms),
|
|
81
81
|
scripts: scriptsStatement(input.scripts ?? DEFAULT_SCRIPT_RULES, input.writtenScripts ?? 'ask', input.mode),
|
|
82
|
+
runWithoutAsking: [...(input.runWithoutAsking ?? [])],
|
|
82
83
|
chatFiles: 'the chat cannot supply a file: this runner has no file step and executes nothing it did not receive as a command',
|
|
83
84
|
networkFetch: networkFetchStatement(input.mode, input.networkFetch),
|
|
84
85
|
denyPatterns: { count: input.denyPatterns.length, digest: digestOf(input.denyPatterns) },
|
|
@@ -101,6 +102,7 @@ export function describePolicyManifest(m) {
|
|
|
101
102
|
`allowlist : ${m.allowlist.enforced ? `${m.allowlist.count} programs, digest ${m.allowlist.digest}` : 'NOT ENFORCED — any program could be started'}`,
|
|
102
103
|
`read only : ${m.readOnly.length ? `${m.readOnly.join(', ')} — a command that changes something, signs in or out or shows a secret is refused` : 'none'}`,
|
|
103
104
|
`scripts : ${m.scripts}`,
|
|
105
|
+
`no card for : ${m.runWithoutAsking.length ? `${m.runWithoutAsking.join(', ')} — reaching a platform with the operator's access, run without asking, changes included` : 'none — every platform command was put to the operator'}`,
|
|
104
106
|
`chat files : ${m.chatFiles}`,
|
|
105
107
|
`downloads : ${m.networkFetch}`,
|
|
106
108
|
`deny list : ${m.denyPatterns.count} patterns, digest ${m.denyPatterns.digest}`,
|
|
@@ -144,12 +144,17 @@ export async function processTable(since) {
|
|
|
144
144
|
}))
|
|
145
145
|
.filter((p) => p.pid !== process.pid);
|
|
146
146
|
}
|
|
147
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* The ports these processes are listening on — asked about them only, not the whole machine. A socket with no other end
|
|
149
|
+
* (remote port 0) counts as well as one in the Listen state: seen on 2026-10-29, Windows on this machine reported a
|
|
150
|
+
* server's listening socket, which answered requests, as "Closed", and `-State Listen` found nothing.
|
|
151
|
+
*/
|
|
148
152
|
async function listenersOf(pids) {
|
|
149
153
|
if (pids.length === 0)
|
|
150
154
|
return [];
|
|
151
|
-
const text = await powershell(`Get-NetTCPConnection -
|
|
152
|
-
|
|
155
|
+
const text = await powershell(`Get-NetTCPConnection -OwningProcess ${pids.map((p) => Math.trunc(p)).join(',')} -ErrorAction SilentlyContinue | ` +
|
|
156
|
+
"Where-Object { $_.State -eq 'Listen' -or $_.RemotePort -eq 0 } | " +
|
|
157
|
+
'Select-Object LocalPort, OwningProcess -Unique | ConvertTo-Json -Compress');
|
|
153
158
|
return parseJsonList(text).map((l) => ({ port: l.LocalPort, pid: l.OwningProcess }));
|
|
154
159
|
}
|
|
155
160
|
/**
|
|
@@ -441,7 +441,25 @@ export function writtenScriptsLetRun(command, cwd, since, shell, rules) {
|
|
|
441
441
|
return scriptsRun(command, cwd, since, shell).filter((r) => r.written !== null && r.written !== SAME_LINE && r.kind !== null && rules[r.kind].written);
|
|
442
442
|
}
|
|
443
443
|
/** What the chat is told to do instead (2026-10-26). */
|
|
444
|
-
const HAND_IT_OVER = 'Put what it does in the step itself — a command may be several lines
|
|
445
|
-
'the
|
|
444
|
+
const HAND_IT_OVER = 'Put what it does in the step itself, in the terminal — a command may be several lines; you never write a script to run something ' +
|
|
445
|
+
'(the operator\'s rule). Only what the runner cannot run at all goes to the operator, as commands, with status "handoff".';
|
|
446
|
+
/** The extensions of a script, as `.cop-tmp` must never hold one (2026-10-28). */
|
|
447
|
+
const SCRIPT_EXT = String.raw `(?:ps1|psm1|cmd|bat|sh|bash|zsh|js|mjs|cjs|jsx|ts|mts|cts|tsx|py|pyw|rb|pl|php|vbs|vbe|wsf|wsh|hta|jse|csx)`;
|
|
448
|
+
/** A line that writes a file into `.cop-tmp`: a cmdlet or an alias that writes, a .NET file write, or a redirection. */
|
|
449
|
+
const SCRATCH_SCRIPT_WRITE = new RegExp(String.raw `\b(?:Set-Content|Add-Content|Out-File|New-Item|Copy-Item|Move-Item|Rename-Item|Tee-Object|sc|ac|ni|cp|copy|mv|move|ren|tee|WriteAllText|WriteAllLines|WriteAllBytes|AppendAllText)\b[^|;\n]*?\.cop-tmp[\\/][^\s'"|;),]*\.${SCRIPT_EXT}\b` +
|
|
450
|
+
String.raw `|>{1,2}\s*["']?[^\s"'|;]*\.cop-tmp[\\/][^\s"'|;]*\.${SCRIPT_EXT}\b`, 'i');
|
|
451
|
+
/**
|
|
452
|
+
* Why a chat's step must not write a script into `.cop-tmp`, or null (operator, 2026-10-28: "I want the bot not to make
|
|
453
|
+
* scripts: when something has to run, it runs it dynamically in the terminal; it creates a file only when it is code of
|
|
454
|
+
* the project"). `.cop-tmp` holds what is not the work, so a script there is one written only to be run — refused at
|
|
455
|
+
* the writing, before the operator is asked about running it.
|
|
456
|
+
*/
|
|
457
|
+
export function scratchScriptRefusal(command, reviewer = false) {
|
|
458
|
+
if (!SCRATCH_SCRIPT_WRITE.test(command))
|
|
459
|
+
return null;
|
|
460
|
+
return ('refused: this writes a script into .cop-tmp, and you never write a script to run something (the operator\'s rule): put what it ' +
|
|
461
|
+
'would do in the step itself, in the terminal, on as many lines as it needs. ' +
|
|
462
|
+
(reviewer ? REVIEW_INSTEAD : 'Write a file only when it is code of the project, part of the work.'));
|
|
463
|
+
}
|
|
446
464
|
/** What the reviewer is told instead: a review hands nothing over. */
|
|
447
465
|
const REVIEW_INSTEAD = 'A review runs commands only: check what it would show with commands of your own, written out in the step itself, or say in a finding that the operator has to run it.';
|
|
@@ -60,9 +60,9 @@ export function kindForChat(kind) {
|
|
|
60
60
|
return kind === 'npm' ? 'package.json "scripts" (npm run, npm test, pnpm, yarn)' : SCRIPT_EXTENSIONS[kind].map((e) => `.${e}`).join(' ');
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* What the chat is told of the operator's boxes, in the opening, when they are not the defaults: which kinds of
|
|
64
|
-
* it writes the runner runs itself, and which of the project's own it does not run. Nothing
|
|
65
|
-
*
|
|
63
|
+
* What the chat is told of the operator's boxes, in the opening, when they are not the defaults: which kinds of file of
|
|
64
|
+
* code it writes as part of the work the runner runs itself, and which of the project's own it does not run. Nothing
|
|
65
|
+
* when they are as shipped. Either way it never writes a script only to run something (operator, 2026-10-28).
|
|
66
66
|
*/
|
|
67
67
|
export function scriptsNote(rules, written) {
|
|
68
68
|
const mine = SCRIPT_KINDS.filter((k) => rules[k].written);
|
|
@@ -71,16 +71,16 @@ export function scriptsNote(rules, written) {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
const lines = ['## Scripts on this machine', ''];
|
|
73
73
|
if (mine.length > 0) {
|
|
74
|
-
lines.push(`The operator lets the runner run
|
|
75
|
-
'
|
|
74
|
+
lines.push(`The operator lets the runner run files of these kinds that you write as part of the work — code of the project: ${mine.map(kindForChat).join('; ')}. ` +
|
|
75
|
+
'Write such a file in one step and run it in the next, never both in one line, ' +
|
|
76
76
|
(written === 'ask' ? 'and the operator is shown it, in full, before it runs. ' : 'and it runs as any other step. ') +
|
|
77
|
-
'Its text passes the same rules as a step.
|
|
77
|
+
'Its text passes the same rules as a step. Still, never write a script only to run something: that goes in the step itself.');
|
|
78
78
|
}
|
|
79
79
|
if (notOwn.length > 0) {
|
|
80
80
|
if (mine.length > 0)
|
|
81
81
|
lines.push('');
|
|
82
82
|
lines.push(`The operator does not let the runner run the project's own scripts of these kinds: ${notOwn.map(kindForChat).join('; ')}. ` +
|
|
83
|
-
'Do what they do in the step itself
|
|
83
|
+
'Do what they do in the step itself.');
|
|
84
84
|
}
|
|
85
85
|
return lines.join('\n');
|
|
86
86
|
}
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
* operator continues. Nothing ends: it is the same task, in the same conversation and the same browser window,
|
|
8
8
|
* after it, and the time it spent held does not count against `maxRunMinutes`.
|
|
9
9
|
*
|
|
10
|
+
* Nor does the time the work waits for the operator (operator, 2026-10-29: "the time the browser session may be used
|
|
11
|
+
* went on while the user had not answered the chat's questions; while the bot waits for the user to type something or
|
|
12
|
+
* answer, it must not count"): a card — a command, a question, a plan, the model to choose, a subtask to try again,
|
|
13
|
+
* commands handed over —, Git's password window, a sign-in or a check that a person is there, each from the moment it
|
|
14
|
+
* waits to the moment it is answered (`waitFor`, `waited`). A pause and a wait, or two waits, at the same time are
|
|
15
|
+
* counted once.
|
|
16
|
+
*
|
|
10
17
|
* Not `RunDeps.shouldPause`, which holds a queue between tasks, after the task running has ended properly.
|
|
11
18
|
*/
|
|
12
19
|
export class Hold {
|
|
@@ -18,6 +25,10 @@ export class Hold {
|
|
|
18
25
|
* paused is taken off a task's minutes — its limit, and the minutes the page shows.
|
|
19
26
|
*/
|
|
20
27
|
spans = [];
|
|
28
|
+
/** What waits for the operator now, by a key of its own (`card:<id>`, `pw:<session>`…), since when. */
|
|
29
|
+
waits = new Map();
|
|
30
|
+
/** The waits that were answered, or went any other way. */
|
|
31
|
+
waitedSpans = [];
|
|
21
32
|
/** Whether the operator has asked the task to hold. */
|
|
22
33
|
get held() {
|
|
23
34
|
return this.paused;
|
|
@@ -42,13 +53,30 @@ export class Hold {
|
|
|
42
53
|
go();
|
|
43
54
|
return true;
|
|
44
55
|
}
|
|
45
|
-
/**
|
|
56
|
+
/** Something waits for the operator from now; a second start of the same one changes nothing. */
|
|
57
|
+
waitFor(key, at = Date.now()) {
|
|
58
|
+
if (!this.waits.has(key))
|
|
59
|
+
this.waits.set(key, at);
|
|
60
|
+
}
|
|
61
|
+
/** It was answered, or went any other way; nothing when it was not waiting. */
|
|
62
|
+
waited(key, at = Date.now()) {
|
|
63
|
+
const from = this.waits.get(key);
|
|
64
|
+
if (from === undefined)
|
|
65
|
+
return;
|
|
66
|
+
this.waits.delete(key);
|
|
67
|
+
this.waitedSpans.push({ from, to: Math.max(from, at) });
|
|
68
|
+
}
|
|
69
|
+
/** The time not counted — paused, or waiting for the operator — joined where it overlaps, in order. */
|
|
70
|
+
notCounted() {
|
|
71
|
+
return joined([...this.spans, ...this.waitedSpans, ...[...this.waits.values()].map((from) => ({ from }))]);
|
|
72
|
+
}
|
|
73
|
+
/** How long the work was paused or waited for the operator since `since` (ms), what goes on counted to now. */
|
|
46
74
|
pausedSince(since, now = Date.now()) {
|
|
47
|
-
return pausedWithin(this.
|
|
75
|
+
return pausedWithin(this.notCounted(), since, now);
|
|
48
76
|
}
|
|
49
|
-
/** The
|
|
77
|
+
/** The time not counted, for the page to take it off the minutes it shows: the pauses and the waits, joined. */
|
|
50
78
|
get pauses() {
|
|
51
|
-
return this.
|
|
79
|
+
return this.notCounted().map((s) => ({ from: new Date(s.from).toISOString(), ...(s.to !== undefined ? { to: new Date(s.to).toISOString() } : {}) }));
|
|
52
80
|
}
|
|
53
81
|
/** Resolves at once when not held; otherwise when the operator continues, or the run is stopped. */
|
|
54
82
|
until(signal) {
|
|
@@ -65,6 +93,57 @@ export class Hold {
|
|
|
65
93
|
});
|
|
66
94
|
}
|
|
67
95
|
}
|
|
96
|
+
/** Spans joined where they overlap or touch, in order; one with no end takes in every span that starts after it. */
|
|
97
|
+
export function joined(spans) {
|
|
98
|
+
const out = [];
|
|
99
|
+
for (const s of [...spans].sort((a, b) => a.from - b.from)) {
|
|
100
|
+
const last = out.at(-1);
|
|
101
|
+
if (last && (last.to === undefined || s.from <= last.to)) {
|
|
102
|
+
if (last.to !== undefined) {
|
|
103
|
+
if (s.to === undefined)
|
|
104
|
+
delete last.to;
|
|
105
|
+
else
|
|
106
|
+
last.to = Math.max(last.to, s.to);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else
|
|
110
|
+
out.push(s.to === undefined ? { from: s.from } : { from: s.from, to: s.to });
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The cards that wait for the operator, kept as a map, each starting a wait when it is put in and ending it when it
|
|
116
|
+
* goes — answered, set aside, stopped —, so no card can wait without its time being left out (2026-10-29).
|
|
117
|
+
*/
|
|
118
|
+
export class WaitsFor extends Map {
|
|
119
|
+
onWait;
|
|
120
|
+
constructor(onWait) {
|
|
121
|
+
super();
|
|
122
|
+
this.onWait = onWait;
|
|
123
|
+
}
|
|
124
|
+
set(key, value) {
|
|
125
|
+
const fresh = !this.has(key);
|
|
126
|
+
super.set(key, value);
|
|
127
|
+
// `onWait` is not there yet while `super()` runs: Map's constructor puts nothing in, but be sure.
|
|
128
|
+
if (fresh)
|
|
129
|
+
this.onWait?.(key, value, true);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
delete(key) {
|
|
133
|
+
const had = this.has(key);
|
|
134
|
+
const value = this.get(key);
|
|
135
|
+
const gone = super.delete(key);
|
|
136
|
+
if (had && gone)
|
|
137
|
+
this.onWait(key, value, false);
|
|
138
|
+
return gone;
|
|
139
|
+
}
|
|
140
|
+
clear() {
|
|
141
|
+
const all = [...this.entries()];
|
|
142
|
+
super.clear();
|
|
143
|
+
for (const [key, value] of all)
|
|
144
|
+
this.onWait(key, value, false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
68
147
|
/** The time of `spans` that falls between `since` and `now`, a span with no end lasting to `now`. */
|
|
69
148
|
export function pausedWithin(spans, since, now) {
|
|
70
149
|
let ms = 0;
|
|
@@ -1599,6 +1599,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1599
1599
|
networkFetch: cfg.execution.networkFetch,
|
|
1600
1600
|
allowedPrograms: cfg.execution.allowedPrograms,
|
|
1601
1601
|
readOnlyPrograms: cfg.execution.readOnlyPrograms,
|
|
1602
|
+
runWithoutAsking: cfg.execution.runWithoutAsking,
|
|
1602
1603
|
scripts: cfg.execution.scripts,
|
|
1603
1604
|
writtenScripts: cfg.execution.writtenScripts,
|
|
1604
1605
|
denyPatterns: cfg.execution.denyPatterns,
|