copilot-operator 0.1.47 → 0.1.50
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 +62 -0
- package/dist/src/api/operator.service.js +39 -0
- package/dist/src/plan/systemGuide.js +96 -16
- package/dist/src/session/taskExchange.js +230 -0
- package/dist/src/session/workspaceGit.js +212 -0
- package/dist/src/transport/chatSession.js +28 -4
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +1 -0
- package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +1 -0
- package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +1 -0
- package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +1 -0
- package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +1 -0
- package/dist/web/_next/static/chunks/app/sessions/view/{page-835d3533fdc63082.js → page-adb64f8ba3d8c06e.js} +1 -1
- package/dist/web/_next/static/css/{70ceb261074b139c.css → 4335e4ce269ba1ea.css} +1 -1
- package/dist/web/appearance.html +2 -2
- package/dist/web/appearance.txt +10 -10
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +10 -10
- package/dist/web/history.html +2 -2
- package/dist/web/history.txt +10 -10
- package/dist/web/import.html +2 -2
- package/dist/web/import.txt +10 -10
- package/dist/web/index.html +2 -2
- package/dist/web/index.txt +10 -10
- package/dist/web/level1.html +2 -2
- package/dist/web/level1.txt +10 -10
- package/dist/web/presets.html +2 -2
- package/dist/web/presets.txt +10 -10
- package/dist/web/sessions/view.html +2 -2
- package/dist/web/sessions/view.txt +10 -10
- package/dist/web/sessions.html +2 -2
- package/dist/web/sessions.txt +10 -10
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +10 -10
- package/package.json +3 -2
- package/dist/web/_next/static/chunks/549-8732dd2c1339bc5d.js +0 -1
- package/dist/web/_next/static/chunks/867-7fb52be342fa64e5.js +0 -1
- package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +0 -1
- package/dist/web/_next/static/chunks/app/history/page-0bb537407fed5944.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-485ce9395cb17998.js +0 -1
- package/dist/web/_next/static/chunks/app/page-ed6a5a2ff1b6285e.js +0 -1
- /package/dist/web/_next/static/{HT6yqFoDPOXChAZVDxshC → z74_FBfnnXW5IJCHTgTH2}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{HT6yqFoDPOXChAZVDxshC → z74_FBfnnXW5IJCHTgTH2}/_ssgManifest.js +0 -0
|
@@ -382,6 +382,18 @@ let OperatorController = class OperatorController {
|
|
|
382
382
|
* format that imports again), `domain` (what happened to the work) or `bot` (what the runner
|
|
383
383
|
* did). Exactly one of `run`, `session` or `session`+`task` names the scope.
|
|
384
384
|
*/
|
|
385
|
+
/** One task's whole exchange with Copilot, as a JSON file (see `taskExchange.ts`). */
|
|
386
|
+
async taskExchange(id, taskId, res) {
|
|
387
|
+
try {
|
|
388
|
+
const { fileName, content } = await this.ops.taskExchange(id, taskId);
|
|
389
|
+
res.type('application/json; charset=utf-8');
|
|
390
|
+
res.setHeader('content-disposition', contentDisposition(fileName));
|
|
391
|
+
res.send(content);
|
|
392
|
+
}
|
|
393
|
+
catch (e) {
|
|
394
|
+
failText(res, e);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
385
397
|
async exportView(kind, res, run, session, task) {
|
|
386
398
|
if (kind !== 'plan' && kind !== 'domain' && kind !== 'bot') {
|
|
387
399
|
res.status(400).send('kind must be plan, domain or bot');
|
|
@@ -536,6 +548,25 @@ let OperatorController = class OperatorController {
|
|
|
536
548
|
throw new BadRequestException('path is required');
|
|
537
549
|
return this.ops.workspaceFile(path).catch(fail);
|
|
538
550
|
}
|
|
551
|
+
/** The open folder's git: the changes, staged and not, and the branch's commits. Read-only. */
|
|
552
|
+
workspaceGit() {
|
|
553
|
+
return this.ops.workspaceGit().catch(fail);
|
|
554
|
+
}
|
|
555
|
+
workspaceCommit(sha) {
|
|
556
|
+
if (!sha)
|
|
557
|
+
throw new BadRequestException('sha is required');
|
|
558
|
+
return this.ops.workspaceCommit(sha).catch(fail);
|
|
559
|
+
}
|
|
560
|
+
/** A file of those lists, its two versions: `area` staged, changes or commit (with `commit`). */
|
|
561
|
+
workspaceGitFile(area, path, commit) {
|
|
562
|
+
if (!path)
|
|
563
|
+
throw new BadRequestException('path is required');
|
|
564
|
+
if (area !== 'staged' && area !== 'changes' && area !== 'commit')
|
|
565
|
+
throw new BadRequestException('area must be staged, changes or commit');
|
|
566
|
+
if (area === 'commit' && !commit)
|
|
567
|
+
throw new BadRequestException('commit is required');
|
|
568
|
+
return this.ops.workspaceGitFile(area, path, commit).catch(fail);
|
|
569
|
+
}
|
|
539
570
|
/** The chat's conversations, newest first. */
|
|
540
571
|
chatThreads() {
|
|
541
572
|
return this.ops.chatThreads().catch(fail);
|
|
@@ -1103,6 +1134,15 @@ __decorate([
|
|
|
1103
1134
|
__metadata("design:paramtypes", [Object, Object]),
|
|
1104
1135
|
__metadata("design:returntype", Promise)
|
|
1105
1136
|
], OperatorController.prototype, "exportBundle", null);
|
|
1137
|
+
__decorate([
|
|
1138
|
+
Get('sessions/:id/tasks/:taskId/exchange'),
|
|
1139
|
+
__param(0, Param('id')),
|
|
1140
|
+
__param(1, Param('taskId')),
|
|
1141
|
+
__param(2, Res()),
|
|
1142
|
+
__metadata("design:type", Function),
|
|
1143
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
1144
|
+
__metadata("design:returntype", Promise)
|
|
1145
|
+
], OperatorController.prototype, "taskExchange", null);
|
|
1106
1146
|
__decorate([
|
|
1107
1147
|
Get('export/:kind'),
|
|
1108
1148
|
__param(0, Param('kind')),
|
|
@@ -1253,6 +1293,28 @@ __decorate([
|
|
|
1253
1293
|
__metadata("design:paramtypes", [String]),
|
|
1254
1294
|
__metadata("design:returntype", Promise)
|
|
1255
1295
|
], OperatorController.prototype, "workspaceFile", null);
|
|
1296
|
+
__decorate([
|
|
1297
|
+
Get('workspace/git'),
|
|
1298
|
+
__metadata("design:type", Function),
|
|
1299
|
+
__metadata("design:paramtypes", []),
|
|
1300
|
+
__metadata("design:returntype", Promise)
|
|
1301
|
+
], OperatorController.prototype, "workspaceGit", null);
|
|
1302
|
+
__decorate([
|
|
1303
|
+
Get('workspace/git/commit'),
|
|
1304
|
+
__param(0, Query('sha')),
|
|
1305
|
+
__metadata("design:type", Function),
|
|
1306
|
+
__metadata("design:paramtypes", [String]),
|
|
1307
|
+
__metadata("design:returntype", Promise)
|
|
1308
|
+
], OperatorController.prototype, "workspaceCommit", null);
|
|
1309
|
+
__decorate([
|
|
1310
|
+
Get('workspace/git/file'),
|
|
1311
|
+
__param(0, Query('area')),
|
|
1312
|
+
__param(1, Query('path')),
|
|
1313
|
+
__param(2, Query('commit')),
|
|
1314
|
+
__metadata("design:type", Function),
|
|
1315
|
+
__metadata("design:paramtypes", [String, String, String]),
|
|
1316
|
+
__metadata("design:returntype", Promise)
|
|
1317
|
+
], OperatorController.prototype, "workspaceGitFile", null);
|
|
1256
1318
|
__decorate([
|
|
1257
1319
|
Get('chat/threads'),
|
|
1258
1320
|
__metadata("design:type", Function),
|
|
@@ -27,6 +27,9 @@ import { buildDebugExport } from '../session/debugExport.js';
|
|
|
27
27
|
import { buildPlanExport, buildDomainExport, buildBotExport, buildBundleExport, exportFileName, exportMachine, runScope, taskAtAttempt, taskInRun, withTask, writeAttemptRecord } from '../session/exports.js';
|
|
28
28
|
import { suggestRunName } from '../session/runName.js';
|
|
29
29
|
import { buildStory } from '../session/story.js';
|
|
30
|
+
import { buildTaskExchange } from '../session/taskExchange.js';
|
|
31
|
+
import { workspaceCommit, workspaceGit, workspaceGitVersions } from '../session/workspaceGit.js';
|
|
32
|
+
import { chatCode } from '../transport/chatSession.js';
|
|
30
33
|
import { checkPlan } from '../plan/schema.js';
|
|
31
34
|
import { planBrief } from '../plan/brief.js';
|
|
32
35
|
/**
|
|
@@ -985,6 +988,23 @@ let OperatorService = class OperatorService {
|
|
|
985
988
|
: await buildBotExport(scope, cfg.resolved.runsDir, exportMachine(cfg));
|
|
986
989
|
return { fileName: exportFileName(kind, scope.label), content: JSON.stringify(document, null, 2) };
|
|
987
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* Everything that passed between the bot and Copilot for one task — every message sent, every reply, every
|
|
993
|
+
* command with its whole output — every attempt of it and nothing of the tasks around it (2026-10-18: one JSON per
|
|
994
|
+
* message of the chat). See `taskExchange.ts`.
|
|
995
|
+
*/
|
|
996
|
+
async taskExchange(sessionId, taskId) {
|
|
997
|
+
await this.init();
|
|
998
|
+
const session = await this.store.getSession(sessionId);
|
|
999
|
+
const task = session?.tasks.find((t) => t.id === taskId);
|
|
1000
|
+
if (!session || !task)
|
|
1001
|
+
throw new Error('No such task.');
|
|
1002
|
+
const cfg = await this.settings.load();
|
|
1003
|
+
const document = await buildTaskExchange(cfg.resolved.runsDir, session, task);
|
|
1004
|
+
// The conversation's code and the message's place in it, then its first words: findable among a day's files.
|
|
1005
|
+
const label = `${chatCode(session.id)}-${String(session.tasks.indexOf(task) + 1).padStart(2, '0')}-${task.title}`;
|
|
1006
|
+
return { fileName: exportFileName('exchange', label), content: JSON.stringify(document, null, 2) };
|
|
1007
|
+
}
|
|
988
1008
|
/**
|
|
989
1009
|
* All three views of a set of tasks the operator picked by hand, in one file.
|
|
990
1010
|
*
|
|
@@ -2275,6 +2295,25 @@ let OperatorService = class OperatorService {
|
|
|
2275
2295
|
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2276
2296
|
return await workspaceFile(ws.dir, path);
|
|
2277
2297
|
}
|
|
2298
|
+
/** The open folder's git, as an IDE's Source Control view shows it (see `workspaceGit.ts`). Read-only. */
|
|
2299
|
+
async workspaceGit() {
|
|
2300
|
+
const ws = await this.workspace();
|
|
2301
|
+
if (!ws.ok)
|
|
2302
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2303
|
+
return await workspaceGit(ws.dir);
|
|
2304
|
+
}
|
|
2305
|
+
async workspaceCommit(sha) {
|
|
2306
|
+
const ws = await this.workspace();
|
|
2307
|
+
if (!ws.ok)
|
|
2308
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2309
|
+
return await workspaceCommit(ws.dir, sha);
|
|
2310
|
+
}
|
|
2311
|
+
async workspaceGitFile(area, path, commit) {
|
|
2312
|
+
const ws = await this.workspace();
|
|
2313
|
+
if (!ws.ok)
|
|
2314
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2315
|
+
return await workspaceGitVersions(ws.dir, area, path, commit);
|
|
2316
|
+
}
|
|
2278
2317
|
/** The chat's conversations, newest first. */
|
|
2279
2318
|
async chatThreads() {
|
|
2280
2319
|
await this.init();
|
|
@@ -423,18 +423,18 @@ export const SYSTEM_GUIDE = [
|
|
|
423
423
|
{
|
|
424
424
|
key: 'approval.manualReady',
|
|
425
425
|
kind: 'button',
|
|
426
|
-
en: 'Ready —
|
|
427
|
-
bg: 'Готово —
|
|
428
|
-
doesEn: '
|
|
429
|
-
doesBg: '
|
|
426
|
+
en: 'Ready — continue',
|
|
427
|
+
bg: 'Готово — продължи',
|
|
428
|
+
doesEn: 'The one way on of the card shown when the model is chosen by hand (the default, or "Set the model by hand" in the chat): after you chose it in the Copilot window, the run goes on, on that model; the conversation is not asked again.',
|
|
429
|
+
doesBg: 'Единственият бутон за продължаване на картата при ръчен избор на модела (по подразбиране или „Ръчно задаване на модел“ в чата): след като го изберете в прозореца на Copilot, изпълнението продължава на този модел; разговорът не се пита пак.',
|
|
430
430
|
},
|
|
431
431
|
{
|
|
432
432
|
key: 'approval.modelAsItIs',
|
|
433
433
|
kind: 'button',
|
|
434
434
|
en: 'Continue on the model it is on',
|
|
435
435
|
bg: 'Продължи на текущия модел',
|
|
436
|
-
doesEn: '
|
|
437
|
-
doesBg: '
|
|
436
|
+
doesEn: 'On the card shown when the bot could not choose the model: the run goes on with whatever model the chat is on, and the record says so.',
|
|
437
|
+
doesBg: 'На картата, когато ботът не успее да избере модела: изпълнението продължава с модела, на който е чатът, и записът го казва.',
|
|
438
438
|
},
|
|
439
439
|
{
|
|
440
440
|
key: 'approval.modelStop',
|
|
@@ -932,6 +932,22 @@ export const SYSTEM_GUIDE = [
|
|
|
932
932
|
doesEn: 'Reads the sessions again at once (they are read every few seconds anyway).',
|
|
933
933
|
doesBg: 'Прочита сесиите веднага (те се четат на всеки няколко секунди и без това).',
|
|
934
934
|
},
|
|
935
|
+
{
|
|
936
|
+
key: 'git.refresh',
|
|
937
|
+
kind: 'button',
|
|
938
|
+
en: 'Read the folder\'s git again',
|
|
939
|
+
bg: 'Прочети отново git на папката',
|
|
940
|
+
doesEn: 'The ↻ of the Git view (the activity bar\'s "Git"): reads the open folder\'s git again at once. The view shows, as an IDE\'s Source Control does, the branch, the staged changes and the changes, each file with its letter (M modified, A added, D deleted, R renamed, U untracked, ! in conflict) and its lines, and the branch\'s commits; a file opens its two versions side by side in the editor, a commit opens to its files. Read-only: it stages and commits nothing.',
|
|
941
|
+
doesBg: '↻ на изгледа Git („Git“ в лентата вляво): прочита веднага git на отворената папка. Изгледът показва, както Source Control в IDE, клона, подготвените промени и промените — всеки файл с буквата си (M променен, A добавен, D изтрит, R преименуван, U непроследен, ! в конфликт) и редовете си — и комитите на клона; файл отваря двете си версии една до друга в редактора, комит се разгъва до файловете си. Само чете: не подготвя и не комитва нищо.',
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
key: 'wb.byTask',
|
|
945
|
+
kind: 'link',
|
|
946
|
+
en: 'by “{title}”',
|
|
947
|
+
bg: 'от „{title}“',
|
|
948
|
+
doesEn: 'Under a commit of the Git view that a task made: opens that task.',
|
|
949
|
+
doesBg: 'Под комит в изгледа Git, направен от задача: отваря задачата.',
|
|
950
|
+
},
|
|
935
951
|
{
|
|
936
952
|
key: 'wb.newSession',
|
|
937
953
|
kind: 'link',
|
|
@@ -1244,10 +1260,10 @@ export const SYSTEM_GUIDE = [
|
|
|
1244
1260
|
{
|
|
1245
1261
|
key: 'chat.newChat',
|
|
1246
1262
|
kind: 'button',
|
|
1247
|
-
en: 'New
|
|
1248
|
-
bg: 'Нов
|
|
1249
|
-
doesEn: '
|
|
1250
|
-
doesBg: '
|
|
1263
|
+
en: 'New chat',
|
|
1264
|
+
bg: 'Нов чат',
|
|
1265
|
+
doesEn: 'Beside the list: the next message starts a new conversation, in a new Copilot conversation with nothing of this one in it; this one stays in the list.',
|
|
1266
|
+
doesBg: 'До списъка: следващото съобщение започва нов разговор, в нов разговор в Copilot без нищо от този; този остава в списъка.',
|
|
1251
1267
|
},
|
|
1252
1268
|
{
|
|
1253
1269
|
key: 'chat.welcome',
|
|
@@ -1278,8 +1294,8 @@ export const SYSTEM_GUIDE = [
|
|
|
1278
1294
|
kind: 'select',
|
|
1279
1295
|
en: 'Model',
|
|
1280
1296
|
bg: 'Модел',
|
|
1281
|
-
doesEn: 'The model of this conversation (or of the next one): "
|
|
1282
|
-
doesBg: 'Моделът на този разговор (или на следващия): „Както е в Настройки“ или някой, предложен от избора в чата при последното
|
|
1297
|
+
doesEn: 'The model of this conversation (or of the next one): "Set the model by hand" (the run waits after signing in until it is chosen in the Copilot window and "Ready" is pressed, once per conversation), "As in Settings", or one the chat\'s picker offered when last read.',
|
|
1298
|
+
doesBg: 'Моделът на този разговор (или на следващия): „Ръчно задаване на модел“ (след входа пускането чака, докато моделът бъде избран в прозореца на Copilot и се натисне „Готово“, веднъж на разговор), „Както е в Настройки“ или някой, предложен от избора в чата при последното четене.',
|
|
1283
1299
|
},
|
|
1284
1300
|
{
|
|
1285
1301
|
key: 'chat.readModels',
|
|
@@ -1289,6 +1305,38 @@ export const SYSTEM_GUIDE = [
|
|
|
1289
1305
|
doesEn: 'The ↻ beside the model: reads the models Copilot\'s own picker offers now (the browser opens for a moment; not while a conversation works).',
|
|
1290
1306
|
doesBg: '↻ до модела: прочита моделите, които изборът в Copilot предлага сега (браузърът се отваря за момент; не и докато разговор работи).',
|
|
1291
1307
|
},
|
|
1308
|
+
{
|
|
1309
|
+
key: 'copy.copy',
|
|
1310
|
+
kind: 'button',
|
|
1311
|
+
en: 'Copy',
|
|
1312
|
+
bg: 'Копирай',
|
|
1313
|
+
doesEn: 'Under your message, under what the chat said, beside how it ended and beside a command: copies that text (a command with what it printed); it says "Copied" for a moment.',
|
|
1314
|
+
doesBg: 'Под твое съобщение, под казаното от чата, до края и до команда: копира този текст (команда — заедно с изписаното от нея); за момент пише „Копирано“.',
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
key: 'chat.foldOpen',
|
|
1318
|
+
kind: 'button',
|
|
1319
|
+
en: 'Show the whole message',
|
|
1320
|
+
bg: 'Покажи цялото съобщение',
|
|
1321
|
+
doesEn: 'The ▾ under a long message of yours, shown folded to its first three lines, fading out: opens it whole.',
|
|
1322
|
+
doesBg: 'Стрелката ▾ под твое дълго съобщение, свито до първите три реда, които избледняват: разгъва го цялото.',
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
key: 'chat.foldClose',
|
|
1326
|
+
kind: 'button',
|
|
1327
|
+
en: 'Fold the message to its first lines',
|
|
1328
|
+
bg: 'Свий съобщението до първите редове',
|
|
1329
|
+
doesEn: 'The ▴ under an opened long message: folds it back to three lines.',
|
|
1330
|
+
doesBg: 'Стрелката ▴ под разгънато дълго съобщение: свива го обратно до три реда.',
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
key: 'chat.exchange',
|
|
1334
|
+
kind: 'link',
|
|
1335
|
+
en: '⤓ JSON',
|
|
1336
|
+
bg: '⤓ JSON',
|
|
1337
|
+
doesEn: 'Under a message: saves everything between the bot and Copilot for that message alone, as a JSON file — every message sent with its files, every reply, every command with its whole output and exit code, every attempt.',
|
|
1338
|
+
doesBg: 'Под съобщение: запазва всичко между бота и Copilot само за това съобщение, като JSON файл — всяко изпратено съобщение с файловете му, всеки отговор, всяка команда с целия ѝ изход и изходен код, всеки опит.',
|
|
1339
|
+
},
|
|
1292
1340
|
{
|
|
1293
1341
|
key: 'chat.rewind',
|
|
1294
1342
|
kind: 'button',
|
|
@@ -1531,16 +1579,48 @@ export const SYSTEM_GUIDE = [
|
|
|
1531
1579
|
kind: 'tab',
|
|
1532
1580
|
en: 'Terminal',
|
|
1533
1581
|
bg: 'Терминал',
|
|
1534
|
-
doesEn: 'The commands the chosen task ran and what each printed, following the newest while it runs.',
|
|
1535
|
-
doesBg: 'Командите, които избраната задача е изпълнила, и какво е изписала всяка, като следва най-новата, докато върви.',
|
|
1582
|
+
doesEn: 'The commands the chosen task ran and what each printed, following the newest while it runs. After "New chat" it is empty until the new chat runs, until a task is opened in the editor.',
|
|
1583
|
+
doesBg: 'Командите, които избраната задача е изпълнила, и какво е изписала всяка, като следва най-новата, докато върви. След „Нов чат“ е празен, докато новият чат не тръгне, освен ако не отвориш задача в редактора.',
|
|
1536
1584
|
},
|
|
1537
1585
|
{
|
|
1538
1586
|
key: 'wb.problems',
|
|
1539
1587
|
kind: 'tab',
|
|
1540
1588
|
en: 'Problems',
|
|
1541
1589
|
bg: 'Проблеми',
|
|
1542
|
-
doesEn: 'What did not pass in the chosen session — checks, review findings, why a task stopped — each opening its task.',
|
|
1543
|
-
doesBg: 'Какво не е минало в избраната сесия — проверки, находки от прегледа, защо е спряла задача — всяко отваря задачата
|
|
1590
|
+
doesEn: 'What did not pass in the chosen session — checks, review findings, why a task stopped — each opening its task; the count is of the ones not marked seen. Empty on a new chat.',
|
|
1591
|
+
doesBg: 'Какво не е минало в избраната сесия — проверки, находки от прегледа, защо е спряла задача — всяко отваря задачата си; броят е на тези, които не са отбелязани като видени. Празно при нов чат.',
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
key: 'wb.problemSeen',
|
|
1595
|
+
kind: 'button',
|
|
1596
|
+
en: 'Seen',
|
|
1597
|
+
bg: 'Видях',
|
|
1598
|
+
doesEn: 'Beside a problem: takes it off the list and the count, in this browser. It is still on its task, and shows again if a later run of that task has it again.',
|
|
1599
|
+
doesBg: 'До проблем: маха го от списъка и от броя, в този браузър. Остава записан към задачата си и се показва пак, ако следващо пускане на задачата има същия проблем.',
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
key: 'wb.problemsAllSeen',
|
|
1603
|
+
kind: 'button',
|
|
1604
|
+
en: 'Seen all',
|
|
1605
|
+
bg: 'Видях всички',
|
|
1606
|
+
doesEn: 'Under the problems: marks every one shown as seen.',
|
|
1607
|
+
doesBg: 'Под проблемите: отбелязва всички показани като видени.',
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
key: 'wb.problemsShowSeen',
|
|
1611
|
+
kind: 'button',
|
|
1612
|
+
en: 'Show the {n} seen',
|
|
1613
|
+
bg: 'Покажи видените ({n})',
|
|
1614
|
+
doesEn: 'Under the problems: shows the ones marked seen too, faded.',
|
|
1615
|
+
doesBg: 'Под проблемите: показва и видените, избледнени.',
|
|
1616
|
+
},
|
|
1617
|
+
{
|
|
1618
|
+
key: 'wb.problemsHideSeen',
|
|
1619
|
+
kind: 'button',
|
|
1620
|
+
en: 'Hide the seen',
|
|
1621
|
+
bg: 'Скрий видените',
|
|
1622
|
+
doesEn: 'Hides the ones marked seen again.',
|
|
1623
|
+
doesBg: 'Скрива отново видените.',
|
|
1544
1624
|
},
|
|
1545
1625
|
{
|
|
1546
1626
|
key: 'wb.output',
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything that passed between the bot and Copilot for one task, as one JSON document.
|
|
3
|
+
*
|
|
4
|
+
* Asked for on 2026-10-18 for the workbench's chat: "a JSON with the whole communication between the bot and
|
|
5
|
+
* Copilot, every terminal command that ran and every response from them — one per task the user gives, not for
|
|
6
|
+
* the whole chat session, only what happened since that message". A task here is one message of the chat (or one
|
|
7
|
+
* task of a session), with every attempt of it in order: the retries in a fresh conversation, the continuations.
|
|
8
|
+
* Nothing from the messages before it or after it.
|
|
9
|
+
*
|
|
10
|
+
* Read from the attempt's run folder, file by file, and nothing is clipped or inferred:
|
|
11
|
+
*
|
|
12
|
+
* - `messages/NN.md` is every message the bot sent into the conversation, in the order it went out, the opening
|
|
13
|
+
* included; the files attached to it are named by the transcript and read from `reports/`;
|
|
14
|
+
* - `replies/NN-<label>.md` is every reply, as it was copied from the chat;
|
|
15
|
+
* - `steps/<iteration>-<step>.log` is every command that ran, with its shell, its folder, its whole output, its
|
|
16
|
+
* exit code and how long it took; the command itself is the one the transcript recorded as proposed, since a
|
|
17
|
+
* command of several lines spills into the log's output;
|
|
18
|
+
* - a step that was not run (refused, skipped) is in the transcript only, and is listed with why;
|
|
19
|
+
* - `checks/` holds the runner's own checks after "done", in the same form as a step;
|
|
20
|
+
* - `review/N/` holds a review round's conversation, in the same form again;
|
|
21
|
+
* - `transcript.jsonl` is the run's own record of everything, kept whole beside the rest as `events`.
|
|
22
|
+
*
|
|
23
|
+
* Each entry's time is its file's creation time (when the runner wrote it, which is when it happened; see
|
|
24
|
+
* `story.ts`), or the transcript's time for what has no file. Entries are in time order.
|
|
25
|
+
*/
|
|
26
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
27
|
+
import { join } from 'node:path';
|
|
28
|
+
async function createdAt(path) {
|
|
29
|
+
const info = await stat(path).catch(() => null);
|
|
30
|
+
if (!info)
|
|
31
|
+
return undefined;
|
|
32
|
+
return new Date(info.birthtimeMs > 0 ? info.birthtimeMs : info.mtimeMs).toISOString();
|
|
33
|
+
}
|
|
34
|
+
const names = async (dir) => (await readdir(dir).catch(() => [])).sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
35
|
+
const text = async (path) => await readFile(path, 'utf8').catch(() => null);
|
|
36
|
+
async function eventsOf(dir) {
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const line of ((await text(join(dir, 'transcript.jsonl'))) ?? '').split('\n')) {
|
|
39
|
+
if (!line.trim())
|
|
40
|
+
continue;
|
|
41
|
+
try {
|
|
42
|
+
out.push(JSON.parse(line));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* a line cut off by a crash */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A step's or a check's log: `# step <id> shell=<s> exe=<path> cwd=<dir>`, `# <command>`, the output, and the footer
|
|
52
|
+
* `# outcome=<o> exit=<n> durationMs=<ms>`. With the command as proposed, the lines of a command of several lines
|
|
53
|
+
* are taken off the front of the output, where the log put them.
|
|
54
|
+
*/
|
|
55
|
+
export function readStepLog(log, proposed) {
|
|
56
|
+
const lines = log.replace(/\r\n/g, '\n').split('\n');
|
|
57
|
+
const head = /^# step \S+ shell=(\S+) exe=.*? cwd=(.*)$/.exec(lines[0] ?? '');
|
|
58
|
+
let command = (lines[1] ?? '').replace(/^# /, '');
|
|
59
|
+
let body = lines.slice(2);
|
|
60
|
+
const more = proposed?.replace(/\r\n/g, '\n').split('\n') ?? [];
|
|
61
|
+
if (more.length > 1 && more[0] === command && more.slice(1).every((l, i) => body[i] === l)) {
|
|
62
|
+
command = more.join('\n');
|
|
63
|
+
body = body.slice(more.length - 1);
|
|
64
|
+
}
|
|
65
|
+
const footerAt = body.map((l) => /^# outcome=(\S+) exit=(-?\d+) durationMs=(\d+)/.test(l)).lastIndexOf(true);
|
|
66
|
+
const footer = footerAt >= 0 ? /^# outcome=(\S+) exit=(-?\d+) durationMs=(\d+)/.exec(body[footerAt]) : null;
|
|
67
|
+
if (footerAt >= 0)
|
|
68
|
+
body = body.slice(0, footerAt);
|
|
69
|
+
return {
|
|
70
|
+
...(head ? { shell: head[1], cwd: head[2].trim() } : {}),
|
|
71
|
+
command,
|
|
72
|
+
output: body.join('\n').replace(/^\n+|\n+$/g, ''),
|
|
73
|
+
...(footer ? { outcome: footer[1], exitCode: Number(footer[2]), durationMs: Number(footer[3]) } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** The commands the transcript recorded as proposed, by step number, in order: `[shell] command` taken apart. */
|
|
77
|
+
function proposals(events) {
|
|
78
|
+
return events
|
|
79
|
+
.filter((e) => e.type === 'step-proposed' && typeof e.description === 'string')
|
|
80
|
+
.map((e) => {
|
|
81
|
+
const m = /^\[([^\]]+)\] ([\s\S]*)$/.exec(e.description);
|
|
82
|
+
return { at: e.at, step: Number(e.id), ...(m ? { shell: m[1], command: m[2] } : { command: e.description }) };
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** The commands of a folder of step logs, each with the command as proposed when the transcript has it. */
|
|
86
|
+
async function commandsIn(dir, proposed) {
|
|
87
|
+
const out = [];
|
|
88
|
+
for (const name of await names(dir)) {
|
|
89
|
+
const m = /^(\d+)-(\d+)\.log$/.exec(name);
|
|
90
|
+
if (!m)
|
|
91
|
+
continue;
|
|
92
|
+
const at = await createdAt(join(dir, name));
|
|
93
|
+
const step = Number(m[2]);
|
|
94
|
+
// The latest proposal of this step number before its log was opened: step numbers start again each round.
|
|
95
|
+
const before = proposed.filter((p) => p.step === step && (!at || !p.at || p.at <= at)).at(-1);
|
|
96
|
+
out.push({ kind: 'command', at, iteration: Number(m[1]), step, ...readStepLog((await text(join(dir, name))) ?? '', before?.command) });
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
/** The steps that were not run, from the transcript: refused by the runner or the operator, or skipped after one was. */
|
|
101
|
+
function notRun(events, proposed) {
|
|
102
|
+
return events
|
|
103
|
+
.filter((e) => e.type === 'step-skipped')
|
|
104
|
+
.map((e) => {
|
|
105
|
+
const step = Number(e.id);
|
|
106
|
+
const at = e.at;
|
|
107
|
+
const before = proposed.filter((p) => p.step === step && (!at || !p.at || p.at <= at)).at(-1);
|
|
108
|
+
return { kind: 'not-run', at, step, ...(before ? { command: before.command } : {}), reason: String(e.reason ?? ''), ...(e.by ? { by: String(e.by) } : {}) };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function checksIn(dir, under = '') {
|
|
112
|
+
const out = [];
|
|
113
|
+
for (const name of await names(dir)) {
|
|
114
|
+
const path = join(dir, name);
|
|
115
|
+
if ((await stat(path).catch(() => null))?.isDirectory()) {
|
|
116
|
+
out.push(...(await checksIn(path, `${under}${name}/`)));
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (!name.endsWith('.txt') && !name.endsWith('.log'))
|
|
120
|
+
continue;
|
|
121
|
+
out.push({ kind: 'check', at: await createdAt(path), file: `${under}${name}`, ...readStepLog((await text(path)) ?? '') });
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
const byTime = (a, b) => (a.at ?? '').localeCompare(b.at ?? '');
|
|
126
|
+
/** A review round's own conversation: the brief and the results it was sent, its replies, the commands it ran. */
|
|
127
|
+
async function reviewRound(dir, round) {
|
|
128
|
+
const entries = [];
|
|
129
|
+
let n = 0;
|
|
130
|
+
for (const name of await names(dir)) {
|
|
131
|
+
const path = join(dir, name);
|
|
132
|
+
if (name === '00-brief.md' || /^iteration-\d+\.txt$/.test(name) || name === 'findings-sent.md') {
|
|
133
|
+
n += 1;
|
|
134
|
+
entries.push({ kind: 'sent', at: await createdAt(path), n, text: (await text(path)) ?? '', attachments: [] });
|
|
135
|
+
}
|
|
136
|
+
else if (name === '00-opening.md' || /^\d+-review\.md$/.test(name)) {
|
|
137
|
+
entries.push({ kind: 'reply', at: await createdAt(path), n: entries.filter((e) => e.kind === 'reply').length + 1, label: name.replace(/\.md$/, ''), text: (await text(path)) ?? '' });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
entries.push(...(await commandsIn(join(dir, 'steps'), [])));
|
|
141
|
+
entries.sort(byTime);
|
|
142
|
+
return { kind: 'review', at: entries[0]?.at, round, entries };
|
|
143
|
+
}
|
|
144
|
+
/** One attempt, from its run folder. */
|
|
145
|
+
export async function readAttempt(runsDir, runId) {
|
|
146
|
+
const dir = join(runsDir, runId);
|
|
147
|
+
const events = await eventsOf(dir);
|
|
148
|
+
const proposed = proposals(events);
|
|
149
|
+
const entries = [];
|
|
150
|
+
// The files each message carried, by the number the transcript gives the message.
|
|
151
|
+
const attachedTo = new Map();
|
|
152
|
+
for (const e of events) {
|
|
153
|
+
if (e.type === 'message-sent' && typeof e.n === 'number' && Array.isArray(e.attachments))
|
|
154
|
+
attachedTo.set(e.n, e.attachments.map(String));
|
|
155
|
+
}
|
|
156
|
+
for (const name of await names(join(dir, 'messages'))) {
|
|
157
|
+
const m = /^(\d+)\.md$/.exec(name);
|
|
158
|
+
if (!m)
|
|
159
|
+
continue;
|
|
160
|
+
const n = Number(m[1]);
|
|
161
|
+
const attachments = [];
|
|
162
|
+
for (const file of attachedTo.get(n) ?? []) {
|
|
163
|
+
attachments.push({ name: file, text: (await text(join(dir, 'reports', file))) ?? (await text(join(dir, file))) });
|
|
164
|
+
}
|
|
165
|
+
entries.push({ kind: 'sent', at: await createdAt(join(dir, 'messages', name)), n, text: (await text(join(dir, 'messages', name))) ?? '', attachments });
|
|
166
|
+
}
|
|
167
|
+
let replies = 0;
|
|
168
|
+
for (const name of await names(join(dir, 'replies'))) {
|
|
169
|
+
const m = /^(\d+)-(.+)\.md$/.exec(name);
|
|
170
|
+
if (!m)
|
|
171
|
+
continue;
|
|
172
|
+
replies += 1;
|
|
173
|
+
entries.push({ kind: 'reply', at: await createdAt(join(dir, 'replies', name)), n: Number(m[1]), label: m[2], text: (await text(join(dir, 'replies', name))) ?? '' });
|
|
174
|
+
}
|
|
175
|
+
const commands = await commandsIn(join(dir, 'steps'), proposed);
|
|
176
|
+
entries.push(...commands, ...notRun(events, proposed), ...(await checksIn(join(dir, 'checks'))));
|
|
177
|
+
for (const name of await names(join(dir, 'review'))) {
|
|
178
|
+
if (/^\d+$/.test(name))
|
|
179
|
+
entries.push(await reviewRound(join(dir, 'review', name), Number(name)));
|
|
180
|
+
}
|
|
181
|
+
entries.sort(byTime);
|
|
182
|
+
const pointer = JSON.parse((await text(join(dir, 'chat.json'))) ?? 'null');
|
|
183
|
+
return {
|
|
184
|
+
runId,
|
|
185
|
+
conversation: pointer?.chatId ? { chatId: pointer.chatId, ...(pointer.name ? { name: pointer.name } : {}), ...(pointer.url ? { url: pointer.url } : {}) } : null,
|
|
186
|
+
counts: {
|
|
187
|
+
sent: entries.filter((e) => e.kind === 'sent').length,
|
|
188
|
+
replies,
|
|
189
|
+
commands: commands.length,
|
|
190
|
+
failed: commands.filter((c) => c.outcome !== undefined && (c.outcome !== 'completed' || c.exitCode !== 0)).length,
|
|
191
|
+
notRun: entries.filter((e) => e.kind === 'not-run').length,
|
|
192
|
+
checks: entries.filter((e) => e.kind === 'check').length,
|
|
193
|
+
},
|
|
194
|
+
entries,
|
|
195
|
+
events,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** Every attempt of the task, oldest first, each read from its own run folder. */
|
|
199
|
+
export async function buildTaskExchange(runsDir, session, task, now = new Date()) {
|
|
200
|
+
const attempts = [];
|
|
201
|
+
const earlier = task.attempts ?? [];
|
|
202
|
+
for (const [i, a] of earlier.entries()) {
|
|
203
|
+
if (!a.runId)
|
|
204
|
+
continue;
|
|
205
|
+
attempts.push({ attempt: i + 1, status: a.status, startedAt: a.startedAt, finishedAt: a.finishedAt, summary: a.summary, reason: a.reason, ...(await readAttempt(runsDir, a.runId)) });
|
|
206
|
+
}
|
|
207
|
+
if (task.runId && !earlier.some((a) => a.runId === task.runId)) {
|
|
208
|
+
attempts.push({ attempt: task.attempt ?? earlier.length + 1, status: task.status, startedAt: task.startedAt, finishedAt: task.finishedAt, summary: task.summary, reason: task.reason, ...(await readAttempt(runsDir, task.runId)) });
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
format: 'copilot-operator.task-exchange',
|
|
212
|
+
version: 1,
|
|
213
|
+
exportedAt: now.toISOString(),
|
|
214
|
+
session: { id: session.id, name: session.name, ...(session.kind ? { kind: session.kind } : {}), ...(session.projectDir ? { projectDir: session.projectDir } : {}) },
|
|
215
|
+
task: {
|
|
216
|
+
id: task.id,
|
|
217
|
+
title: task.title,
|
|
218
|
+
message: task.prompt,
|
|
219
|
+
status: task.status,
|
|
220
|
+
...(task.reason ? { reason: task.reason } : {}),
|
|
221
|
+
...(task.summary ? { summary: task.summary } : {}),
|
|
222
|
+
createdAt: task.createdAt,
|
|
223
|
+
...(task.startedAt ? { startedAt: task.startedAt } : {}),
|
|
224
|
+
...(task.finishedAt ? { finishedAt: task.finishedAt } : {}),
|
|
225
|
+
notes: (task.notes ?? []).map((x) => ({ text: x.text, at: x.at, ...(x.sentAt ? { sentAt: x.sentAt } : {}) })),
|
|
226
|
+
changedFiles: (task.vcs?.files ?? []).map((f) => f.path),
|
|
227
|
+
},
|
|
228
|
+
attempts,
|
|
229
|
+
};
|
|
230
|
+
}
|