copilot-operator 0.1.58 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/operator.controller.js +89 -1
- package/dist/src/api/operator.service.js +276 -9
- package/dist/src/cli.js +4 -0
- package/dist/src/config/exportHome.js +78 -0
- package/dist/src/config/schema.js +38 -0
- package/dist/src/exec/authorizer.js +16 -4
- package/dist/src/exec/platforms.js +87 -0
- package/dist/src/orchestrator/leadRunner.js +22 -3
- package/dist/src/orchestrator/taskRunner.js +101 -13
- package/dist/src/plan/systemGuide.js +353 -36
- package/dist/src/protocol/parser.js +3 -2
- package/dist/src/protocol/replySchema.js +20 -2
- package/dist/src/queue/queue.js +113 -0
- package/dist/src/transport/copilotTransport.js +263 -131
- package/dist/src/transport/locators.js +119 -33
- package/dist/src/util/zip.js +80 -0
- package/dist/src/vcs/taskVcs.js +25 -1
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/VmnUW8Gr79dsc-Ifk8oGP/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/1077.d84d3a09cffc08c0.js +1 -0
- package/dist/web/_next/static/chunks/1548.03db34ce36acd5d5.js +1 -0
- package/dist/web/_next/static/chunks/2163.56378b27583dfc24.js +1 -0
- package/dist/web/_next/static/chunks/4512-db21be6b8e4eabf4.js +1 -0
- package/dist/web/_next/static/chunks/714.5cc516832a5f44c9.js +1 -0
- package/dist/web/_next/static/chunks/7220.26bb7ae30c8a587a.js +1 -0
- package/dist/web/_next/static/chunks/7921-51a72190643f4b1a.js +1 -0
- package/dist/web/_next/static/chunks/8197-e2fcb43f38a2b4a7.js +1 -0
- package/dist/web/_next/static/chunks/8584.49c69cd6e77d2fd7.js +1 -0
- package/dist/web/_next/static/chunks/9067.7ae4ac6836a74d94.js +1 -0
- package/dist/web/_next/static/chunks/9747.5a244ec2d1b84d29.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-f18945b2fe2c8719.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-d83191667baa1077.js → page-9c0f8e27ab7c8677.js} +1 -1
- package/dist/web/_next/static/chunks/app/queue/page-7d853e6bcbbacf0d.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-1833ace66fc9eb0e.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-3466496814a70b62.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-4da26d364c22b773.js → webpack-047b9e390d242a45.js} +1 -1
- package/dist/web/_next/static/css/{ad8f9884b90fbe47.css → 975a0235944db79c.css} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +14 -0
- package/dist/web/queue.txt +26 -0
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +7 -2
- package/prompts/lead1.md +7 -1
- package/prompts/level1.md +31 -1
- package/dist/web/_next/static/chunks/1077.34c49edcb60b74b8.js +0 -1
- package/dist/web/_next/static/chunks/1548.2e00c25619517e57.js +0 -1
- package/dist/web/_next/static/chunks/2163.896e18423ed494d6.js +0 -1
- package/dist/web/_next/static/chunks/3134-b6a7bc1f267c39aa.js +0 -1
- package/dist/web/_next/static/chunks/4512-8bcb4b34f41115b4.js +0 -1
- package/dist/web/_next/static/chunks/714.97d7b448e3fcd1d0.js +0 -1
- package/dist/web/_next/static/chunks/7220.d4bbc9d12b9971fa.js +0 -1
- package/dist/web/_next/static/chunks/7921-03e96df8fc05c712.js +0 -1
- package/dist/web/_next/static/chunks/8584.502a04a441f41a6d.js +0 -1
- package/dist/web/_next/static/chunks/9067.6d2ab3fd6308b1be.js +0 -1
- package/dist/web/_next/static/chunks/9747.0430cf4a4e70a033.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-9cd9b0b0587f4882.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-832ed3149649b77a.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-176448acb2c8baa6.js +0 -1
- package/dist/web/_next/static/wjvJJpx5dfDucIRnV0mIG/_buildManifest.js +0 -1
- /package/dist/web/_next/static/{wjvJJpx5dfDucIRnV0mIG → VmnUW8Gr79dsc-Ifk8oGP}/_ssgManifest.js +0 -0
|
@@ -24,6 +24,8 @@ import { OperatorService } from './operator.service.js';
|
|
|
24
24
|
import { SettingsUnusableError } from './settings.js';
|
|
25
25
|
import { PolicyLockUnusableError } from '../config/lockedPolicy.js';
|
|
26
26
|
import { CHANGED_ON_DISK } from '../session/workspace.js';
|
|
27
|
+
import { join } from 'node:path';
|
|
28
|
+
import { DefaultPickerLocators } from '../transport/locators.js';
|
|
27
29
|
function fail(e) {
|
|
28
30
|
// A settings file or a policy lock that cannot be used is not the request's fault, and every route
|
|
29
31
|
// that reads the settings meets it, wrapped here or not: it is passed on as it is, for the server
|
|
@@ -76,7 +78,12 @@ let OperatorController = class OperatorController {
|
|
|
76
78
|
// --- settings ---------------------------------------------------------------------------
|
|
77
79
|
async settings() {
|
|
78
80
|
const [raw, defaults, resolved] = await Promise.all([this.ops.settings.raw(), this.ops.settings.defaults(), this.ops.settings.load()]);
|
|
79
|
-
|
|
81
|
+
/*
|
|
82
|
+
* The model menu's locators (2026-10-24): their defaults, which Settings shows and puts back, and where the
|
|
83
|
+
* pictures of a choice are kept — a run's beside its browser's other files, a reading of the list in its own.
|
|
84
|
+
*/
|
|
85
|
+
const picker = { defaults: DefaultPickerLocators, dirs: { run: join(resolved.resolved.runsDir, '_browser'), read: join(resolved.resolved.runsDir, '_models') } };
|
|
86
|
+
return { raw, defaults, resolved: resolved.resolved, picker };
|
|
80
87
|
}
|
|
81
88
|
async saveSettings(body) {
|
|
82
89
|
await this.ops.settings.save(body).catch(fail);
|
|
@@ -163,6 +170,22 @@ let OperatorController = class OperatorController {
|
|
|
163
170
|
failText(res, e);
|
|
164
171
|
}
|
|
165
172
|
}
|
|
173
|
+
/** How much an export of the bot's folder would hold (2026-10-23). */
|
|
174
|
+
exportSize() {
|
|
175
|
+
return this.ops.exportSizes();
|
|
176
|
+
}
|
|
177
|
+
/** Everything the bot has kept, as a .zip: `data/`, and `runs/` with `?runs=1`. See `config/exportHome.ts`. */
|
|
178
|
+
exportHome(runs, res) {
|
|
179
|
+
try {
|
|
180
|
+
const { fileName, content } = this.ops.exportHome(runs === '1' || runs === 'true');
|
|
181
|
+
res.type('application/zip');
|
|
182
|
+
res.setHeader('content-disposition', contentDisposition(fileName));
|
|
183
|
+
res.send(content);
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
failText(res, e);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
166
189
|
/** What the bot's console showed, the latest lines, as a text file. See `log/terminal.ts`. */
|
|
167
190
|
async terminal(res) {
|
|
168
191
|
try {
|
|
@@ -299,6 +322,21 @@ let OperatorController = class OperatorController {
|
|
|
299
322
|
})
|
|
300
323
|
.catch(fail);
|
|
301
324
|
}
|
|
325
|
+
// --- the queue of tasks (2026-10-24) -------------------------------------------------------------------
|
|
326
|
+
/** The tasks prepared to run one after another, each in a new chat, and whether the queue is running. */
|
|
327
|
+
queue() {
|
|
328
|
+
return this.ops.queue().catch(fail);
|
|
329
|
+
}
|
|
330
|
+
/** The list as the page edits it: added, changed, moved, taken out, put back to wait. */
|
|
331
|
+
setQueue(body = {}) {
|
|
332
|
+
return this.ops.setQueue(body?.items).catch(fail);
|
|
333
|
+
}
|
|
334
|
+
runQueue() {
|
|
335
|
+
return this.ops.runQueue().catch(fail);
|
|
336
|
+
}
|
|
337
|
+
stopQueue() {
|
|
338
|
+
return this.ops.stopQueue().catch(fail);
|
|
339
|
+
}
|
|
302
340
|
/** Back to before a message: the folder as it was then, that message and the ones after it taken out. */
|
|
303
341
|
async chatRewind(id, body = {}) {
|
|
304
342
|
if (typeof body?.taskId !== 'string' || !body.taskId)
|
|
@@ -391,6 +429,10 @@ let OperatorController = class OperatorController {
|
|
|
391
429
|
setDefaultModel(body) {
|
|
392
430
|
return this.ops.setDefaultModel(body?.model ?? '').catch(fail);
|
|
393
431
|
}
|
|
432
|
+
/** The model the lead of two chats starts on (2026-10-23). An empty name leaves its chat on whatever it is. */
|
|
433
|
+
setDefaultLeadModel(body) {
|
|
434
|
+
return this.ops.setDefaultLeadModel(body?.model ?? '').catch(fail);
|
|
435
|
+
}
|
|
394
436
|
/** The model of the independent review. An empty name means "the session's own". */
|
|
395
437
|
setDefaultReviewModel(body) {
|
|
396
438
|
return this.ops.setDefaultReviewModel(body?.model ?? '').catch(fail);
|
|
@@ -530,6 +572,20 @@ __decorate([
|
|
|
530
572
|
__metadata("design:paramtypes", [String, Object]),
|
|
531
573
|
__metadata("design:returntype", Promise)
|
|
532
574
|
], OperatorController.prototype, "startFailureReport", null);
|
|
575
|
+
__decorate([
|
|
576
|
+
Get('home/export/size'),
|
|
577
|
+
__metadata("design:type", Function),
|
|
578
|
+
__metadata("design:paramtypes", []),
|
|
579
|
+
__metadata("design:returntype", Object)
|
|
580
|
+
], OperatorController.prototype, "exportSize", null);
|
|
581
|
+
__decorate([
|
|
582
|
+
Get('home/export'),
|
|
583
|
+
__param(0, Query('runs')),
|
|
584
|
+
__param(1, Res()),
|
|
585
|
+
__metadata("design:type", Function),
|
|
586
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
587
|
+
__metadata("design:returntype", void 0)
|
|
588
|
+
], OperatorController.prototype, "exportHome", null);
|
|
533
589
|
__decorate([
|
|
534
590
|
Get('terminal'),
|
|
535
591
|
__param(0, Res()),
|
|
@@ -653,6 +709,31 @@ __decorate([
|
|
|
653
709
|
__metadata("design:paramtypes", [Object]),
|
|
654
710
|
__metadata("design:returntype", Promise)
|
|
655
711
|
], OperatorController.prototype, "chatSend", null);
|
|
712
|
+
__decorate([
|
|
713
|
+
Get('queue'),
|
|
714
|
+
__metadata("design:type", Function),
|
|
715
|
+
__metadata("design:paramtypes", []),
|
|
716
|
+
__metadata("design:returntype", Promise)
|
|
717
|
+
], OperatorController.prototype, "queue", null);
|
|
718
|
+
__decorate([
|
|
719
|
+
Put('queue'),
|
|
720
|
+
__param(0, Body()),
|
|
721
|
+
__metadata("design:type", Function),
|
|
722
|
+
__metadata("design:paramtypes", [Object]),
|
|
723
|
+
__metadata("design:returntype", Promise)
|
|
724
|
+
], OperatorController.prototype, "setQueue", null);
|
|
725
|
+
__decorate([
|
|
726
|
+
Post('queue/run'),
|
|
727
|
+
__metadata("design:type", Function),
|
|
728
|
+
__metadata("design:paramtypes", []),
|
|
729
|
+
__metadata("design:returntype", Promise)
|
|
730
|
+
], OperatorController.prototype, "runQueue", null);
|
|
731
|
+
__decorate([
|
|
732
|
+
Post('queue/stop'),
|
|
733
|
+
__metadata("design:type", Function),
|
|
734
|
+
__metadata("design:paramtypes", []),
|
|
735
|
+
__metadata("design:returntype", Promise)
|
|
736
|
+
], OperatorController.prototype, "stopQueue", null);
|
|
656
737
|
__decorate([
|
|
657
738
|
Post('chat/:id/rewind'),
|
|
658
739
|
__param(0, Param('id')),
|
|
@@ -750,6 +831,13 @@ __decorate([
|
|
|
750
831
|
__metadata("design:paramtypes", [Object]),
|
|
751
832
|
__metadata("design:returntype", Promise)
|
|
752
833
|
], OperatorController.prototype, "setDefaultModel", null);
|
|
834
|
+
__decorate([
|
|
835
|
+
Put('models/lead-default'),
|
|
836
|
+
__param(0, Body()),
|
|
837
|
+
__metadata("design:type", Function),
|
|
838
|
+
__metadata("design:paramtypes", [Object]),
|
|
839
|
+
__metadata("design:returntype", Promise)
|
|
840
|
+
], OperatorController.prototype, "setDefaultLeadModel", null);
|
|
753
841
|
__decorate([
|
|
754
842
|
Put('models/review-default'),
|
|
755
843
|
__param(0, Body()),
|
|
@@ -15,13 +15,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
15
15
|
import { pageModelFor, sameModel } from '../transport/modelMatch.js';
|
|
16
16
|
import { Injectable } from '@nestjs/common';
|
|
17
17
|
import { existsSync } from 'node:fs';
|
|
18
|
+
import { readFile } from 'node:fs/promises';
|
|
18
19
|
import { join, resolve } from 'node:path';
|
|
19
20
|
import { chosenHome, defaultHome, installLayout } from '../config/layout.js';
|
|
20
21
|
import { chooseHome, homeRefusal, movedFrom } from '../config/home.js';
|
|
21
|
-
import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW } from '../session/store.js';
|
|
22
|
+
import { SessionStore, DEFAULT_VCS, DEFAULT_REVIEW, writeFileAtomically } from '../session/store.js';
|
|
23
|
+
import { checkItems, emptyQueue, itemTitle, mainBranchOf, mergeItems, nextStep, skippedBecause, statusOfTask } from '../queue/queue.js';
|
|
22
24
|
import { EventBus } from '../session/events.js';
|
|
23
25
|
import { MAX_INSTRUCTION_CHARS, newId } from '../session/model.js';
|
|
24
|
-
import { runSession, queuedToRun, failedWhileOpening } from '../orchestrator/taskRunner.js';
|
|
26
|
+
import { runSession, queuedToRun, failedWhileOpening, pickerOptions } from '../orchestrator/taskRunner.js';
|
|
25
27
|
import { Hold } from '../orchestrator/hold.js';
|
|
26
28
|
import { exportFileName, exportMachine, writeAttemptRecord } from '../session/exports.js';
|
|
27
29
|
import { suggestRunName } from '../session/runName.js';
|
|
@@ -83,6 +85,8 @@ import { runVcsPreflight } from '../vcs/runPreflight.js';
|
|
|
83
85
|
import { inputSettings, normalisePatterns } from '../vcs/inputs.js';
|
|
84
86
|
import { coveredByArtifacts } from '../vcs/artifacts.js';
|
|
85
87
|
import { botVersion } from '../config/version.js';
|
|
88
|
+
import { exportEntries, exportFileName as homeExportName, exportSizes } from '../config/exportHome.js';
|
|
89
|
+
import { createZip } from '../util/zip.js';
|
|
86
90
|
import { settingsOf, SettingsUnusableError } from './settings.js';
|
|
87
91
|
import { PolicyLockUnusableError } from '../config/lockedPolicy.js';
|
|
88
92
|
import { chatDenyPatterns } from '../config/schema.js';
|
|
@@ -141,11 +145,20 @@ let OperatorService = class OperatorService {
|
|
|
141
145
|
* for `activity`, which every page asks on a timer and answers from memory. Gone when the message ends.
|
|
142
146
|
*/
|
|
143
147
|
acting = new Map();
|
|
148
|
+
/**
|
|
149
|
+
* How the last message ended (2026-10-23: the tab reads "Done", "Error" and the like when the work stops, for an
|
|
150
|
+
* operator in another window): a worker's subtask is not the message.
|
|
151
|
+
*/
|
|
152
|
+
lastOutcome = null;
|
|
144
153
|
followsActing = this.bus.subscribe('*', (e) => {
|
|
145
154
|
if (e.type === 'acting' && e.data)
|
|
146
155
|
this.acting.set(e.sessionId, e.data);
|
|
147
|
-
else if (e.type === 'task-finished')
|
|
156
|
+
else if (e.type === 'task-finished') {
|
|
148
157
|
this.acting.delete(e.sessionId);
|
|
158
|
+
const status = e.data?.status;
|
|
159
|
+
if (typeof status === 'string' && !this.workerLeads.has(e.sessionId))
|
|
160
|
+
this.lastOutcome = { status, at: e.at, sessionId: e.sessionId };
|
|
161
|
+
}
|
|
149
162
|
});
|
|
150
163
|
waiting = new Map();
|
|
151
164
|
/**
|
|
@@ -614,6 +627,8 @@ let OperatorService = class OperatorService {
|
|
|
614
627
|
}
|
|
615
628
|
/** The program is closing: so is the window the chat left open. */
|
|
616
629
|
async onModuleDestroy() {
|
|
630
|
+
// The queue's loop lets go; its file still says running, and the next start says what was in flight (`recoverQueue`).
|
|
631
|
+
this.queueClosing = true;
|
|
617
632
|
await this.closeChatWindow('the program is closing');
|
|
618
633
|
}
|
|
619
634
|
/**
|
|
@@ -736,6 +751,18 @@ let OperatorService = class OperatorService {
|
|
|
736
751
|
return { fileName: `copilot-operator-not-started-${fileStamp(f.at)}.txt`, content: redactSecrets(text, cfg.report.redactPatterns) };
|
|
737
752
|
}
|
|
738
753
|
/** What the bot's console showed: the latest lines kept in memory, as a file. See `log/terminal.ts`. */
|
|
754
|
+
/** How much an export of the bot's folder would hold (2026-10-23): its data, and its runs' records. */
|
|
755
|
+
exportSizes() {
|
|
756
|
+
return exportSizes(this.layout);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Everything the bot has kept, as one .zip (operator, 2026-10-23): `data/` — the key and the Edge profile left out,
|
|
760
|
+
* the manifest says why — and `runs/` when asked for.
|
|
761
|
+
*/
|
|
762
|
+
exportHome(runs) {
|
|
763
|
+
const now = new Date();
|
|
764
|
+
return { fileName: homeExportName(now), content: createZip(exportEntries(this.layout, { runs, version: botVersion(), now })) };
|
|
765
|
+
}
|
|
739
766
|
async terminalReport() {
|
|
740
767
|
const cfg = await this.settings.load();
|
|
741
768
|
const lines = terminalLines({ max: 5_000 });
|
|
@@ -786,6 +813,7 @@ let OperatorService = class OperatorService {
|
|
|
786
813
|
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
787
814
|
// Read once per run like the rest of the policy: a change in Settings applies from the next start.
|
|
788
815
|
networkFetch: cfg.execution.networkFetch,
|
|
816
|
+
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
789
817
|
};
|
|
790
818
|
/*
|
|
791
819
|
* An unattended run that cannot legally execute anything is stopped here, where the operator
|
|
@@ -880,6 +908,8 @@ let OperatorService = class OperatorService {
|
|
|
880
908
|
await this.setDefaultModel(to);
|
|
881
909
|
if (which === 'review' && (now.defaultReviewModel ?? '').trim() === from)
|
|
882
910
|
await this.setDefaultReviewModel(to);
|
|
911
|
+
if (which === 'lead' && (now.defaultLeadModel ?? '').trim() === from)
|
|
912
|
+
await this.setDefaultLeadModel(to);
|
|
883
913
|
},
|
|
884
914
|
seen: async (options, current) => {
|
|
885
915
|
await this.store.saveModels({ options, current: current ?? undefined, readAt: new Date().toISOString() });
|
|
@@ -1019,6 +1049,8 @@ let OperatorService = class OperatorService {
|
|
|
1019
1049
|
starting,
|
|
1020
1050
|
...(acting ? { acting } : {}),
|
|
1021
1051
|
...(run?.hold?.held ? { paused: true } : {}),
|
|
1052
|
+
// How the last message ended, while nothing runs: what the tab says until the operator has looked.
|
|
1053
|
+
...(this.running.size === 0 && this.lastOutcome ? { last: { status: this.lastOutcome.status, at: this.lastOutcome.at } } : {}),
|
|
1022
1054
|
};
|
|
1023
1055
|
}
|
|
1024
1056
|
/**
|
|
@@ -1254,6 +1286,220 @@ let OperatorService = class OperatorService {
|
|
|
1254
1286
|
}
|
|
1255
1287
|
return { threadId: session.id, taskId: task.id, needsStart: false };
|
|
1256
1288
|
}
|
|
1289
|
+
// --- the queue of tasks (2026-10-24) ----------------------------------------------------------------
|
|
1290
|
+
//
|
|
1291
|
+
// Tasks written beforehand, each run in a new chat on its own model while nobody watches; one that failed takes
|
|
1292
|
+
// the tasks that depend on it with it, and the queue goes on with the next. See `queue/queue.ts`.
|
|
1293
|
+
queueFile = join(this.dataDir, 'queue.json');
|
|
1294
|
+
queueTurn = Promise.resolve();
|
|
1295
|
+
queueLoop = null;
|
|
1296
|
+
queueRecovered = false;
|
|
1297
|
+
/** The program is closing: the queue's loop stops where it is. */
|
|
1298
|
+
queueClosing = false;
|
|
1299
|
+
/** The queue as it is on disk; one that cannot be read is an empty one, said in the console. */
|
|
1300
|
+
async readQueue() {
|
|
1301
|
+
try {
|
|
1302
|
+
const q = JSON.parse(await readFile(this.queueFile, 'utf8'));
|
|
1303
|
+
return { items: Array.isArray(q.items) ? q.items : [], running: q.running === true, updatedAt: q.updatedAt ?? '' };
|
|
1304
|
+
}
|
|
1305
|
+
catch (e) {
|
|
1306
|
+
if (e.code !== 'ENOENT')
|
|
1307
|
+
console.error('[queue] data/queue.json could not be read:', e.message);
|
|
1308
|
+
return emptyQueue();
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
/** Changes the queue in a turn of its own, so two changes never write over each other. */
|
|
1312
|
+
changeQueue(change) {
|
|
1313
|
+
const run = async () => {
|
|
1314
|
+
const q = await this.readQueue();
|
|
1315
|
+
change(q);
|
|
1316
|
+
q.updatedAt = new Date().toISOString();
|
|
1317
|
+
await writeFileAtomically(this.queueFile, JSON.stringify(q, null, 2));
|
|
1318
|
+
return q;
|
|
1319
|
+
};
|
|
1320
|
+
const done = this.queueTurn.then(run, run);
|
|
1321
|
+
this.queueTurn = done.catch(() => undefined);
|
|
1322
|
+
return done;
|
|
1323
|
+
}
|
|
1324
|
+
setQueueItem(q, id, patch) {
|
|
1325
|
+
const item = q.items.find((x) => x.id === id);
|
|
1326
|
+
if (!item)
|
|
1327
|
+
return;
|
|
1328
|
+
Object.assign(item, patch);
|
|
1329
|
+
for (const key of Object.keys(patch))
|
|
1330
|
+
if (patch[key] === undefined)
|
|
1331
|
+
delete item[key];
|
|
1332
|
+
}
|
|
1333
|
+
/** A queue that was running when the bot last closed: not running now, and its task in flight stopped. */
|
|
1334
|
+
async recoverQueue() {
|
|
1335
|
+
if (this.queueRecovered)
|
|
1336
|
+
return;
|
|
1337
|
+
this.queueRecovered = true;
|
|
1338
|
+
const q = await this.readQueue();
|
|
1339
|
+
if (!q.running && !q.items.some((x) => x.status === 'running'))
|
|
1340
|
+
return;
|
|
1341
|
+
await this.changeQueue((x) => {
|
|
1342
|
+
x.running = false;
|
|
1343
|
+
for (const item of x.items) {
|
|
1344
|
+
if (item.status === 'running')
|
|
1345
|
+
Object.assign(item, { status: 'stopped', why: 'the bot was closed while it ran', endedAt: new Date().toISOString() });
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
async queue() {
|
|
1350
|
+
await this.recoverQueue();
|
|
1351
|
+
return await this.readQueue();
|
|
1352
|
+
}
|
|
1353
|
+
/** The list as the page edits it: added, changed, moved, taken out, put back to wait ("Run again"). */
|
|
1354
|
+
async setQueue(items) {
|
|
1355
|
+
await this.recoverQueue();
|
|
1356
|
+
const checked = checkItems(items, MAX_INSTRUCTION_CHARS);
|
|
1357
|
+
if ('problem' in checked)
|
|
1358
|
+
throw new Error(checked.problem);
|
|
1359
|
+
let problem;
|
|
1360
|
+
const q = await this.changeQueue((x) => {
|
|
1361
|
+
const merged = mergeItems(x.items, checked.items);
|
|
1362
|
+
if ('problem' in merged)
|
|
1363
|
+
problem = merged.problem;
|
|
1364
|
+
else
|
|
1365
|
+
x.items = merged.items;
|
|
1366
|
+
});
|
|
1367
|
+
if (problem)
|
|
1368
|
+
throw new Error(problem);
|
|
1369
|
+
return q;
|
|
1370
|
+
}
|
|
1371
|
+
/** Runs the waiting tasks one after another, in the background; the page follows `queue()`. */
|
|
1372
|
+
async runQueue() {
|
|
1373
|
+
await this.init();
|
|
1374
|
+
await this.recoverQueue();
|
|
1375
|
+
if (this.queueLoop)
|
|
1376
|
+
throw new Error('The queue is running already.');
|
|
1377
|
+
const q = await this.readQueue();
|
|
1378
|
+
if (!nextStep(q.items))
|
|
1379
|
+
throw new Error('No task in the queue is waiting. Add one, or put one back with "Run again".');
|
|
1380
|
+
const ws = await this.workspace();
|
|
1381
|
+
if (!ws.ok)
|
|
1382
|
+
throw new Error(ws.problem ?? 'No project folder is open: open one in the chat first.');
|
|
1383
|
+
const unnamed = this.queueWithoutModel(q.items.filter((x) => x.status === 'waiting'), await this.settings.load());
|
|
1384
|
+
if (unnamed)
|
|
1385
|
+
throw new Error(unnamed);
|
|
1386
|
+
const started = await this.changeQueue((x) => {
|
|
1387
|
+
x.running = true;
|
|
1388
|
+
});
|
|
1389
|
+
this.queueLoop = this.runQueueLoop()
|
|
1390
|
+
.catch((e) => console.error('[queue] the queue stopped:', e.stack ?? e.message))
|
|
1391
|
+
.finally(() => {
|
|
1392
|
+
this.queueLoop = null;
|
|
1393
|
+
void this.changeQueue((x) => {
|
|
1394
|
+
x.running = false;
|
|
1395
|
+
});
|
|
1396
|
+
});
|
|
1397
|
+
return started;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Tasks that would wait for the operator to choose their model by hand: none of their own, and no "Model for the
|
|
1401
|
+
* worker" in Settings — a chat that names no model is asked for it by hand (`modelByHand`), and nobody is there.
|
|
1402
|
+
*/
|
|
1403
|
+
queueWithoutModel(items, cfg) {
|
|
1404
|
+
if ((cfg.copilot.defaultModel ?? '').trim())
|
|
1405
|
+
return null;
|
|
1406
|
+
const none = items.filter((x) => !x.model.trim());
|
|
1407
|
+
if (none.length === 0)
|
|
1408
|
+
return null;
|
|
1409
|
+
const names = none.map((x) => `"${itemTitle(x)}"`).join(', ');
|
|
1410
|
+
return `${names} ${none.length === 1 ? 'has' : 'have'} no model of ${none.length === 1 ? 'its' : 'their'} own, and Settings have no "Model for the worker": ${none.length === 1 ? 'it' : 'they'} would wait for you to choose one by hand. Choose a model for ${none.length === 1 ? 'it' : 'them'}, or one in Settings.`;
|
|
1411
|
+
}
|
|
1412
|
+
/** Stops the queue: the task at work is stopped as the chat's Stop does, and the rest wait. */
|
|
1413
|
+
async stopQueue() {
|
|
1414
|
+
const q = await this.changeQueue((x) => {
|
|
1415
|
+
x.running = false;
|
|
1416
|
+
});
|
|
1417
|
+
const at = q.items.find((x) => x.status === 'running');
|
|
1418
|
+
if (at?.sessionId)
|
|
1419
|
+
await this.stop(at.sessionId).catch(() => undefined);
|
|
1420
|
+
return q;
|
|
1421
|
+
}
|
|
1422
|
+
async runQueueLoop() {
|
|
1423
|
+
const now = () => new Date().toISOString();
|
|
1424
|
+
for (;;) {
|
|
1425
|
+
if (this.queueClosing)
|
|
1426
|
+
return;
|
|
1427
|
+
const q = await this.readQueue();
|
|
1428
|
+
if (!q.running)
|
|
1429
|
+
return;
|
|
1430
|
+
const step = nextStep(q.items);
|
|
1431
|
+
if (!step)
|
|
1432
|
+
return;
|
|
1433
|
+
if ('skip' in step) {
|
|
1434
|
+
await this.changeQueue((x) => this.setQueueItem(x, step.skip.id, { status: 'skipped', why: skippedBecause(step.because), endedAt: now() }));
|
|
1435
|
+
continue;
|
|
1436
|
+
}
|
|
1437
|
+
const item = step.run;
|
|
1438
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { status: 'running', startedAt: now(), why: undefined, endedAt: undefined, sessionId: undefined }));
|
|
1439
|
+
const ended = await this.runQueueItem(item).catch((e) => ({ status: 'failed', why: e.message }));
|
|
1440
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { ...ended, endedAt: now() }));
|
|
1441
|
+
// Stopped — from the queue, or the chat's Stop: the rest wait for the operator.
|
|
1442
|
+
if (ended.status === 'stopped')
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
/** One task of the queue, in a new chat, to its end. */
|
|
1447
|
+
async runQueueItem(item) {
|
|
1448
|
+
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1449
|
+
const stillRunning = async () => (await this.readQueue()).running;
|
|
1450
|
+
// Read afresh each time: the browser is let go of by other work while this waits.
|
|
1451
|
+
const holder = () => this.browser;
|
|
1452
|
+
// The browser may be the chat's, or a reading of the models': the task waits its turn.
|
|
1453
|
+
while (holder()) {
|
|
1454
|
+
if (this.queueClosing || !(await stillRunning()))
|
|
1455
|
+
return { status: 'stopped', why: 'the queue was stopped before it began' };
|
|
1456
|
+
await pause(1_000);
|
|
1457
|
+
}
|
|
1458
|
+
const ws = await this.workspace();
|
|
1459
|
+
if (!ws.ok)
|
|
1460
|
+
return { status: 'failed', why: ws.problem ?? 'no project folder is open' };
|
|
1461
|
+
// Settings may have changed since the queue was started.
|
|
1462
|
+
const unnamed = this.queueWithoutModel([item], await this.settings.load());
|
|
1463
|
+
if (unnamed)
|
|
1464
|
+
return { status: 'failed', why: unnamed };
|
|
1465
|
+
const base = item.branch === 'main' ? await mainBranchOf(ws.dir) : null;
|
|
1466
|
+
if (item.branch === 'main' && !base)
|
|
1467
|
+
return { status: 'failed', why: `${ws.dir} has no main (or master) branch to make a new branch from` };
|
|
1468
|
+
const sent = await this.chatSend({ text: item.prompt, ...(item.model ? { model: item.model } : {}), review: item.review });
|
|
1469
|
+
const sessionId = sent.threadId;
|
|
1470
|
+
await this.store.updateSession(sessionId, (s) => {
|
|
1471
|
+
s.name = `queue: ${itemTitle(item)}`;
|
|
1472
|
+
s.queueItem = item.id;
|
|
1473
|
+
/*
|
|
1474
|
+
* A new branch from main (2026-10-24): the runner's own version control, as a session of the bot's has it — the
|
|
1475
|
+
* branch cut from main, brought up to date from the server first when that needs no password (`updateFromRemote`
|
|
1476
|
+
* asks nobody anything; it fails, and the local main is used), and the work committed on it. The chat is told
|
|
1477
|
+
* which main it was (`noteFor`).
|
|
1478
|
+
*/
|
|
1479
|
+
if (base) {
|
|
1480
|
+
s.vcs = { ...DEFAULT_VCS, enabled: true, repoDir: ws.dir, branchMode: 'per-session', commitOnFinish: true, startFrom: 'branch', baseBranch: base, updateFromRemote: true };
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
await this.changeQueue((x) => this.setQueueItem(x, item.id, { sessionId }));
|
|
1484
|
+
const cfg = await this.settings.load();
|
|
1485
|
+
const reply = await this.start(sessionId, cfg.execution.mode);
|
|
1486
|
+
if (!reply.started)
|
|
1487
|
+
return { status: 'failed', why: reply.reason ?? 'it did not start', sessionId };
|
|
1488
|
+
// Until its run has ended and its window let the browser go, so the next one can have it.
|
|
1489
|
+
let asked = false;
|
|
1490
|
+
while (this.running.has(sessionId) || (holder()?.kind === 'run' && holder().sessionId === sessionId)) {
|
|
1491
|
+
if (this.queueClosing)
|
|
1492
|
+
return { status: 'stopped', why: 'the bot was closed while it ran', sessionId };
|
|
1493
|
+
if (!asked && !(await stillRunning())) {
|
|
1494
|
+
asked = true;
|
|
1495
|
+
await this.stop(sessionId).catch(() => undefined);
|
|
1496
|
+
}
|
|
1497
|
+
await pause(1_000);
|
|
1498
|
+
}
|
|
1499
|
+
const task = (await this.store.getSession(sessionId))?.tasks.find((t) => t.id === sent.taskId);
|
|
1500
|
+
const status = statusOfTask(task?.status);
|
|
1501
|
+
return { status, ...(status !== 'done' ? { why: task?.reason ?? `it ended ${task?.status ?? 'without a record'}` } : {}), sessionId };
|
|
1502
|
+
}
|
|
1257
1503
|
// --- skills (2026-10-21) ----------------------------------------------------------------------------
|
|
1258
1504
|
/** The skills in Settings, and how long their instructions may be. */
|
|
1259
1505
|
async skills() {
|
|
@@ -1408,10 +1654,11 @@ let OperatorService = class OperatorService {
|
|
|
1408
1654
|
sessionId: ask.sessionId,
|
|
1409
1655
|
taskId: ask.taskId,
|
|
1410
1656
|
stepId: 0,
|
|
1411
|
-
description:
|
|
1657
|
+
description: `${(ask.actor ?? 'lead') === 'lead' ? 'The lead asks' : 'The chat asks'}: ${ask.question}`,
|
|
1412
1658
|
createdAt: new Date().toISOString(),
|
|
1413
|
-
|
|
1414
|
-
|
|
1659
|
+
// The lead's, or since 2026-10-23 the chat's own (plan mode's or the worker's).
|
|
1660
|
+
actor: ask.actor ?? 'lead',
|
|
1661
|
+
question: { text: ask.question, ...(ask.why ? { why: ask.why } : {}), options: ask.options, ...(ask.commands?.some(Boolean) ? { commands: ask.commands } : {}) },
|
|
1415
1662
|
};
|
|
1416
1663
|
this.waiting.set(approval.id, {
|
|
1417
1664
|
approval,
|
|
@@ -1596,12 +1843,13 @@ let OperatorService = class OperatorService {
|
|
|
1596
1843
|
description: `[${step.shell ?? 'pwsh'}] ${step.cmd}`,
|
|
1597
1844
|
createdAt: new Date().toISOString(),
|
|
1598
1845
|
...(ctx.actor ? { actor: ctx.actor } : {}),
|
|
1599
|
-
...(held ? { network: held.network } : {}),
|
|
1846
|
+
...(held?.network ? { network: held.network } : {}),
|
|
1847
|
+
...(held?.platform ? { platform: held.platform } : {}),
|
|
1600
1848
|
};
|
|
1601
1849
|
this.waiting.set(approval.id, { approval, resolve: resolvePromise });
|
|
1602
1850
|
this.bus.publish({ sessionId: approval.sessionId, taskId: approval.taskId, type: 'approval-requested', level: 'warn',
|
|
1603
1851
|
message: held
|
|
1604
|
-
? `held for the operator — ${held.network}: ${approval.description}`
|
|
1852
|
+
? `held for the operator — ${[held.platform ? `it reaches ${held.platform} with the operator's access` : '', held.network ?? ''].filter(Boolean).join('; ')}: ${approval.description}`
|
|
1605
1853
|
: `waiting for approval: ${approval.description}`,
|
|
1606
1854
|
data: { ...approval } });
|
|
1607
1855
|
}), signal);
|
|
@@ -1974,13 +2222,26 @@ let OperatorService = class OperatorService {
|
|
|
1974
2222
|
const cached = await this.store.getModels();
|
|
1975
2223
|
const defaultModel = cfg.copilot.defaultModel ?? '';
|
|
1976
2224
|
const defaultReviewModel = cfg.copilot.defaultReviewModel ?? '';
|
|
1977
|
-
|
|
2225
|
+
const defaultLeadModel = cfg.copilot.defaultLeadModel ?? '';
|
|
2226
|
+
return cached ? { ...cached, defaultModel, defaultLeadModel, defaultReviewModel } : { defaultModel, defaultLeadModel, defaultReviewModel, options: [], readAt: null };
|
|
1978
2227
|
}
|
|
1979
2228
|
/**
|
|
1980
2229
|
* Sets the model a new session's independent review starts on. An empty name clears it,
|
|
1981
2230
|
* which means the review runs on the session's own model — the weaker choice, and the one
|
|
1982
2231
|
* every session had before this existed.
|
|
1983
2232
|
*/
|
|
2233
|
+
/** Sets the model the lead of two chats starts on (2026-10-23). An empty name leaves its chat on whatever it is. */
|
|
2234
|
+
async setDefaultLeadModel(name) {
|
|
2235
|
+
await this.init();
|
|
2236
|
+
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultLeadModel: name.trim() } }));
|
|
2237
|
+
this.bus.publish({
|
|
2238
|
+
sessionId: '*',
|
|
2239
|
+
type: 'default-lead-model-changed',
|
|
2240
|
+
level: 'info',
|
|
2241
|
+
message: name.trim() ? `the lead of two chats will start on ${name.trim()}` : 'the lead of two chats leaves the chat on its model',
|
|
2242
|
+
});
|
|
2243
|
+
return { defaultLeadModel: name.trim() };
|
|
2244
|
+
}
|
|
1984
2245
|
async setDefaultReviewModel(name) {
|
|
1985
2246
|
await this.init();
|
|
1986
2247
|
await this.settings.update((raw) => ({ ...raw, copilot: { ...(raw.copilot ?? {}), defaultReviewModel: name.trim() } }));
|
|
@@ -2114,6 +2375,8 @@ let OperatorService = class OperatorService {
|
|
|
2114
2375
|
signInTimeoutMs: cfg.copilot.signInTimeoutSec * 1000,
|
|
2115
2376
|
humanWaitMs: cfg.copilot.humanWaitSec * 1000,
|
|
2116
2377
|
keepFailurePage: cfg.copilot.keepFailurePage,
|
|
2378
|
+
// The rows' locator reads the names (Settings' own, 2026-10-24).
|
|
2379
|
+
...pickerOptions(cfg),
|
|
2117
2380
|
});
|
|
2118
2381
|
await this.closeChatWindow('reading the models needs the browser');
|
|
2119
2382
|
await transport.open();
|
|
@@ -2125,12 +2388,16 @@ let OperatorService = class OperatorService {
|
|
|
2125
2388
|
const saved = cfg.copilot;
|
|
2126
2389
|
const work = (saved.defaultModel ?? '').trim();
|
|
2127
2390
|
const review = (saved.defaultReviewModel ?? '').trim();
|
|
2391
|
+
const lead = (saved.defaultLeadModel ?? '').trim();
|
|
2128
2392
|
const workNow = work ? pageModelFor(work, options) : null;
|
|
2129
2393
|
const reviewNow = review ? pageModelFor(review, options) : null;
|
|
2394
|
+
const leadNow = lead ? pageModelFor(lead, options) : null;
|
|
2130
2395
|
if (workNow && !sameModel(workNow.name, work))
|
|
2131
2396
|
await this.setDefaultModel(workNow.name);
|
|
2132
2397
|
if (reviewNow && !sameModel(reviewNow.name, review))
|
|
2133
2398
|
await this.setDefaultReviewModel(reviewNow.name);
|
|
2399
|
+
if (leadNow && !sameModel(leadNow.name, lead))
|
|
2400
|
+
await this.setDefaultLeadModel(leadNow.name);
|
|
2134
2401
|
return catalogue;
|
|
2135
2402
|
}
|
|
2136
2403
|
finally {
|
package/dist/src/cli.js
CHANGED
|
@@ -388,7 +388,10 @@ program
|
|
|
388
388
|
.option('--steps', 'with --set: print each step of the choice with its time, and keep a picture of each in runs/_models')
|
|
389
389
|
.option('--chat <id-or-address>', 'first open this existing conversation (its id, or its address from the browser), as a task carried on does')
|
|
390
390
|
.action(async (opts) => {
|
|
391
|
+
// The model menu's locators saved in Settings (2026-10-24), as a run and "Read the list from Copilot" use them.
|
|
392
|
+
const saved = await settingsOf(installLayout()).load().catch(() => null);
|
|
391
393
|
const transport = new CopilotTransport({
|
|
394
|
+
...(saved?.copilot.pickerLocators ? { pickerLocators: saved.copilot.pickerLocators } : {}),
|
|
392
395
|
profileDir: opts.profile,
|
|
393
396
|
transportDir: join(installLayout().runsDir, '_models'),
|
|
394
397
|
chatUrl: opts.url,
|
|
@@ -497,6 +500,7 @@ program
|
|
|
497
500
|
isolation: cfg.execution.isolation,
|
|
498
501
|
lockedToConfirm: cfg.policyLock?.maxMode === 'confirm',
|
|
499
502
|
networkFetch: cfg.execution.networkFetch,
|
|
503
|
+
platformAccess: cfg.execution.questions === 'agree' ? 'allow' : 'ask',
|
|
500
504
|
};
|
|
501
505
|
const authorizer = cfg.execution.mode === 'unattended'
|
|
502
506
|
? unattendedAuthorizer(policy)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything the bot has kept, as one file (operator, 2026-10-23: "an option to export everything saved so far under
|
|
3
|
+
* this profile — we keep it in the bot's folder anyway"): its settings, conversations, skills, level 2 templates and
|
|
4
|
+
* logs — `data/` — and, when asked for, every run's records — `runs/`. A `manifest.json` says what is in it and what
|
|
5
|
+
* was left out, and why: the API's key, which belongs to this machine alone, and the Edge profile, which holds the
|
|
6
|
+
* Microsoft 365 sign-in — a file carrying that would sign anybody who has it in as the operator.
|
|
7
|
+
*/
|
|
8
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
9
|
+
import { join, relative } from 'node:path';
|
|
10
|
+
/** Files of the data folder never exported, by name: this machine's key and the API's own bookkeeping. */
|
|
11
|
+
const NEVER = new Set(['api-token', 'dev-pids.json', '.cop-lock.json']);
|
|
12
|
+
function filesUnder(dir) {
|
|
13
|
+
const out = [];
|
|
14
|
+
const walk = (d) => {
|
|
15
|
+
let names;
|
|
16
|
+
try {
|
|
17
|
+
names = readdirSync(d);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const name of names) {
|
|
23
|
+
const p = join(d, name);
|
|
24
|
+
let st;
|
|
25
|
+
try {
|
|
26
|
+
st = statSync(p);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (st.isDirectory())
|
|
32
|
+
walk(p);
|
|
33
|
+
else if (st.isFile())
|
|
34
|
+
out.push({ path: p, size: st.size, mtime: st.mtime });
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
walk(dir);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
const dataFiles = (layout) => filesUnder(layout.dataDir).filter((f) => !NEVER.has(relative(layout.dataDir, f.path).replace(/\\/g, '/')));
|
|
41
|
+
/** How much an export would hold: the data folder, and the runs' records if asked for. */
|
|
42
|
+
export function exportSizes(layout) {
|
|
43
|
+
const data = dataFiles(layout);
|
|
44
|
+
const runs = filesUnder(layout.runsDir);
|
|
45
|
+
return { data: data.reduce((n, f) => n + f.size, 0), dataFiles: data.length, runs: runs.reduce((n, f) => n + f.size, 0), runsFiles: runs.length };
|
|
46
|
+
}
|
|
47
|
+
/** The files of an export, named as they go in the archive (`data/…`, `runs/…`), and its manifest first. */
|
|
48
|
+
export function exportEntries(layout, opts) {
|
|
49
|
+
const now = opts.now ?? new Date();
|
|
50
|
+
const entries = [];
|
|
51
|
+
const add = (root, under) => (f) => {
|
|
52
|
+
entries.push({ name: `${under}/${relative(root, f.path).replace(/\\/g, '/')}`, data: readFileSync(f.path), mtime: f.mtime });
|
|
53
|
+
};
|
|
54
|
+
const data = dataFiles(layout);
|
|
55
|
+
data.forEach(add(layout.dataDir, 'data'));
|
|
56
|
+
const runs = opts.runs ? filesUnder(layout.runsDir) : [];
|
|
57
|
+
runs.forEach(add(layout.runsDir, 'runs'));
|
|
58
|
+
const manifest = {
|
|
59
|
+
exportedBy: `copilot-operator ${opts.version}`,
|
|
60
|
+
exportedAt: now.toISOString(),
|
|
61
|
+
from: layout.homeDir,
|
|
62
|
+
holds: [
|
|
63
|
+
{ what: 'data/', files: data.length, is: 'settings, conversations, skills, level 2 templates, logs' },
|
|
64
|
+
...(opts.runs ? [{ what: 'runs/', files: runs.length, is: "every run's records: transcripts, replies, reports" }] : []),
|
|
65
|
+
],
|
|
66
|
+
leftOut: [
|
|
67
|
+
{ what: 'data/api-token', why: "the key of this machine's API: it belongs to this machine alone" },
|
|
68
|
+
{ what: 'edge-profile/', why: 'the Edge profile holds the Microsoft 365 sign-in; anybody with it would be signed in as you' },
|
|
69
|
+
...(opts.runs ? [] : [{ what: 'runs/', why: 'not asked for' }]),
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
return [{ name: 'manifest.json', data: Buffer.from(JSON.stringify(manifest, null, 2), 'utf8'), mtime: now }, ...entries];
|
|
73
|
+
}
|
|
74
|
+
/** The export's file name: copilot-operator-export-20261023-1142.zip. */
|
|
75
|
+
export function exportFileName(now = new Date()) {
|
|
76
|
+
const two = (n) => String(n).padStart(2, '0');
|
|
77
|
+
return `copilot-operator-export-${now.getFullYear()}${two(now.getMonth() + 1)}${two(now.getDate())}-${two(now.getHours())}${two(now.getMinutes())}.zip`;
|
|
78
|
+
}
|