copilot-operator 0.1.61 → 0.1.63
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 +31 -0
- package/dist/src/api/operator.service.js +89 -15
- package/dist/src/config/schema.js +10 -0
- package/dist/src/orchestrator/leadRunner.js +268 -30
- package/dist/src/orchestrator/subtaskRetry.js +152 -0
- package/dist/src/orchestrator/taskRunner.js +8 -0
- package/dist/src/plan/systemGuide.js +167 -0
- package/dist/src/queue/queue.js +52 -5
- package/dist/src/session/store.js +4 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1077.155f883ebfb223ae.js +1 -0
- package/dist/web/_next/static/chunks/1548.52fe19b2bb6dbe66.js +1 -0
- package/dist/web/_next/static/chunks/2163.51278cbd88674f1a.js +1 -0
- package/dist/web/_next/static/chunks/714.a3555e6b7e5f4339.js +1 -0
- package/dist/web/_next/static/chunks/7220.a7dcaec140695190.js +1 -0
- package/dist/web/_next/static/chunks/7921-b7eba39a21993047.js +1 -0
- package/dist/web/_next/static/chunks/8124-5458b17433987fab.js +1 -0
- package/dist/web/_next/static/chunks/8584.baf85c4394dc04eb.js +1 -0
- package/dist/web/_next/static/chunks/9067.2d7665cd257d7b47.js +1 -0
- package/dist/web/_next/static/chunks/9747.66a374501673612f.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-9201c637ca24b2c9.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-9c0f8e27ab7c8677.js → page-03f129240e06a07c.js} +1 -1
- package/dist/web/_next/static/chunks/app/queue/page-f86936d39121ade8.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-9a83381087178f80.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-047b9e390d242a45.js → webpack-38c956574db7c7a6.js} +1 -1
- package/dist/web/_next/static/css/2f2419505403ce07.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 +3 -2
- package/dist/web/_next/static/chunks/1077.d84d3a09cffc08c0.js +0 -1
- package/dist/web/_next/static/chunks/1548.03db34ce36acd5d5.js +0 -1
- package/dist/web/_next/static/chunks/2163.56378b27583dfc24.js +0 -1
- package/dist/web/_next/static/chunks/4512-db21be6b8e4eabf4.js +0 -1
- package/dist/web/_next/static/chunks/714.5cc516832a5f44c9.js +0 -1
- package/dist/web/_next/static/chunks/7220.26bb7ae30c8a587a.js +0 -1
- package/dist/web/_next/static/chunks/7921-51a72190643f4b1a.js +0 -1
- package/dist/web/_next/static/chunks/8584.49c69cd6e77d2fd7.js +0 -1
- package/dist/web/_next/static/chunks/9067.7ae4ac6836a74d94.js +0 -1
- package/dist/web/_next/static/chunks/9747.5a244ec2d1b84d29.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-f18945b2fe2c8719.js +0 -1
- package/dist/web/_next/static/chunks/app/queue/page-7d853e6bcbbacf0d.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-1833ace66fc9eb0e.js +0 -1
- package/dist/web/_next/static/css/975a0235944db79c.css +0 -1
- /package/dist/web/_next/static/{VmnUW8Gr79dsc-Ifk8oGP → kxZRE1oIu_arurqhfP4mS}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{VmnUW8Gr79dsc-Ifk8oGP → kxZRE1oIu_arurqhfP4mS}/_ssgManifest.js +0 -0
|
@@ -356,6 +356,20 @@ let OperatorController = class OperatorController {
|
|
|
356
356
|
}
|
|
357
357
|
return this.ops.decide(id, body.action);
|
|
358
358
|
}
|
|
359
|
+
/** A subtask that failed for a technical reason (two chats, 2026-10-25): one of its card's choices. */
|
|
360
|
+
answerRetry(id, body) {
|
|
361
|
+
const result = this.ops.answerRetry(id, typeof body?.choice === 'string' ? body.choice : '');
|
|
362
|
+
if (!result.ok)
|
|
363
|
+
throw new BadRequestException(result.problem);
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
/** After a Stop (two chats, 2026-10-25): the stopped message carried on with one of its subtasks tried again first. */
|
|
367
|
+
chatRetrySubtask(id, taskId, body = {}) {
|
|
368
|
+
const n = Number(body?.n);
|
|
369
|
+
if (!Number.isInteger(n) || n < 1)
|
|
370
|
+
throw new BadRequestException('n, the subtask\'s number, is required');
|
|
371
|
+
return this.ops.chatRetrySubtask(id, taskId, n, body?.fresh === true).catch(fail);
|
|
372
|
+
}
|
|
359
373
|
/** The lead's question (two chats): the operator's answer, as text. Stopping the task is `approvals/:id` with abort. */
|
|
360
374
|
answerQuestion(id, body) {
|
|
361
375
|
const result = this.ops.answerQuestion(id, typeof body?.text === 'string' ? body.text : '');
|
|
@@ -757,6 +771,23 @@ __decorate([
|
|
|
757
771
|
__metadata("design:paramtypes", [String, Object]),
|
|
758
772
|
__metadata("design:returntype", Object)
|
|
759
773
|
], OperatorController.prototype, "decide", null);
|
|
774
|
+
__decorate([
|
|
775
|
+
Post('approvals/:id/retry'),
|
|
776
|
+
__param(0, Param('id')),
|
|
777
|
+
__param(1, Body()),
|
|
778
|
+
__metadata("design:type", Function),
|
|
779
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
780
|
+
__metadata("design:returntype", Object)
|
|
781
|
+
], OperatorController.prototype, "answerRetry", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
Post('chat/:id/tasks/:taskId/retry-subtask'),
|
|
784
|
+
__param(0, Param('id')),
|
|
785
|
+
__param(1, Param('taskId')),
|
|
786
|
+
__param(2, Body()),
|
|
787
|
+
__metadata("design:type", Function),
|
|
788
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
789
|
+
__metadata("design:returntype", Promise)
|
|
790
|
+
], OperatorController.prototype, "chatRetrySubtask", null);
|
|
760
791
|
__decorate([
|
|
761
792
|
Post('approvals/:id/answer'),
|
|
762
793
|
__param(0, Param('id')),
|
|
@@ -20,7 +20,7 @@ import { join, resolve } from 'node:path';
|
|
|
20
20
|
import { chosenHome, defaultHome, installLayout } from '../config/layout.js';
|
|
21
21
|
import { chooseHome, homeRefusal, movedFrom } from '../config/home.js';
|
|
22
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';
|
|
23
|
+
import { checkItems, emptyQueue, itemTitle, mainBranchOf, mergeItems, nextStep, skippedBecause, statusOfTask, waitsByHand } from '../queue/queue.js';
|
|
24
24
|
import { EventBus } from '../session/events.js';
|
|
25
25
|
import { MAX_INSTRUCTION_CHARS, newId } from '../session/model.js';
|
|
26
26
|
import { runSession, queuedToRun, failedWhileOpening, pickerOptions } from '../orchestrator/taskRunner.js';
|
|
@@ -36,8 +36,11 @@ import { chatCode } from '../transport/chatSession.js';
|
|
|
36
36
|
/** The folders the operator works in: the default new sessions start on, and the rest by name. */
|
|
37
37
|
/** The longest level 2 a project may have: Kerrigan carries each one whole. */
|
|
38
38
|
export const MAX_PROJECT_LEVEL2 = 8000;
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/*
|
|
40
|
+
* Its instructions have no limit of their own (operator, 2026-10-25: "remove the limit; say how many characters there
|
|
41
|
+
* are instead"): the message they go with is held to Settings' `limits.maxMessageChars` like every other — longer, its
|
|
42
|
+
* beginning goes as text and the whole of it attached.
|
|
43
|
+
*/
|
|
41
44
|
export const MAX_SKILL_DESCRIPTION = 300;
|
|
42
45
|
export const MAX_SKILLS = 50;
|
|
43
46
|
/** What follows `/` at the start of a message: lowercase letters, digits and hyphens, 2 to 40 of them. */
|
|
@@ -919,6 +922,7 @@ let OperatorService = class OperatorService {
|
|
|
919
922
|
approvePlan: (ask) => this.askPlanApproval(ask, controller.signal),
|
|
920
923
|
// The two-chat mode (2026-10-20): the lead's questions, and the worker the run speaks for too.
|
|
921
924
|
askQuestion: (ask) => this.askLeadQuestion(ask, controller.signal),
|
|
925
|
+
askSubtaskRetry: (ask) => this.askSubtaskRetry(ask, controller.signal),
|
|
922
926
|
onWorker: (workerId) => this.workerLeads.set(workerId, sessionId),
|
|
923
927
|
hold,
|
|
924
928
|
})
|
|
@@ -1401,13 +1405,12 @@ let OperatorService = class OperatorService {
|
|
|
1401
1405
|
* worker" in Settings — a chat that names no model is asked for it by hand (`modelByHand`), and nobody is there.
|
|
1402
1406
|
*/
|
|
1403
1407
|
queueWithoutModel(items, cfg) {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
if (
|
|
1408
|
+
const said = items.flatMap((x) => waitsByHand(x, cfg.copilot).map((part) => part === 'model'
|
|
1409
|
+
? `"${itemTitle(x)}" has no model of its own, and Settings have no "${x.lead ? 'Model for the lead' : 'Model for the worker'}"`
|
|
1410
|
+
: `"${itemTitle(x)}" is reviewed, with no model for the review of its own, and Settings have no "Model for the review"`));
|
|
1411
|
+
if (said.length === 0)
|
|
1408
1412
|
return null;
|
|
1409
|
-
|
|
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.`;
|
|
1413
|
+
return `${said.join('; ')}: ${said.length === 1 ? 'it' : 'they'} would wait for you to choose a model by hand. Choose the model in the task, or in Settings.`;
|
|
1411
1414
|
}
|
|
1412
1415
|
/** Stops the queue: the task at work is stopped as the chat's Stop does, and the rest wait. */
|
|
1413
1416
|
async stopQueue() {
|
|
@@ -1465,7 +1468,14 @@ let OperatorService = class OperatorService {
|
|
|
1465
1468
|
const base = item.branch === 'main' ? await mainBranchOf(ws.dir) : null;
|
|
1466
1469
|
if (item.branch === 'main' && !base)
|
|
1467
1470
|
return { status: 'failed', why: `${ws.dir} has no main (or master) branch to make a new branch from` };
|
|
1468
|
-
|
|
1471
|
+
// As the chat's box sends a first message: the model, the review and its model, or two chats and the worker's model.
|
|
1472
|
+
const sent = await this.chatSend({
|
|
1473
|
+
text: item.prompt,
|
|
1474
|
+
...(item.model ? { model: item.model } : {}),
|
|
1475
|
+
review: item.review,
|
|
1476
|
+
...(item.reviewModel ? { reviewModel: item.reviewModel } : {}),
|
|
1477
|
+
...(item.lead ? { lead: true, ...(item.workerModel ? { workerModel: item.workerModel } : {}) } : {}),
|
|
1478
|
+
});
|
|
1469
1479
|
const sessionId = sent.threadId;
|
|
1470
1480
|
await this.store.updateSession(sessionId, (s) => {
|
|
1471
1481
|
s.name = `queue: ${itemTitle(item)}`;
|
|
@@ -1501,18 +1511,17 @@ let OperatorService = class OperatorService {
|
|
|
1501
1511
|
return { status, ...(status !== 'done' ? { why: task?.reason ?? `it ended ${task?.status ?? 'without a record'}` } : {}), sessionId };
|
|
1502
1512
|
}
|
|
1503
1513
|
// --- skills (2026-10-21) ----------------------------------------------------------------------------
|
|
1504
|
-
/** The skills in Settings, and how long
|
|
1514
|
+
/** The skills in Settings, and how long what each is for may be. */
|
|
1505
1515
|
async skills() {
|
|
1506
1516
|
const cfg = await this.settings.load();
|
|
1507
1517
|
return {
|
|
1508
1518
|
skills: (cfg.skills ?? []).map((k) => ({ name: k.name, description: k.description ?? '', text: k.text ?? '', projectDir: k.projectDir ?? '' })),
|
|
1509
|
-
maxText: MAX_SKILL_TEXT,
|
|
1510
1519
|
maxDescription: MAX_SKILL_DESCRIPTION,
|
|
1511
1520
|
};
|
|
1512
1521
|
}
|
|
1513
1522
|
/**
|
|
1514
1523
|
* Stores the list as given, held to the rules: a name to type after `/` — lowercase, digits and hyphens, each used
|
|
1515
|
-
* once — instructions that are there
|
|
1524
|
+
* once — instructions that are there, of any length, a project that is one of Settings' or every project.
|
|
1516
1525
|
*/
|
|
1517
1526
|
async setSkills(list) {
|
|
1518
1527
|
if (!Array.isArray(list))
|
|
@@ -1535,8 +1544,6 @@ let OperatorService = class OperatorService {
|
|
|
1535
1544
|
const text = String(k?.text ?? '');
|
|
1536
1545
|
if (!text.trim())
|
|
1537
1546
|
throw new Error(`The skill "${name}" has no instructions: write what the chat should know and do for this kind of task.`);
|
|
1538
|
-
if (text.length > MAX_SKILL_TEXT)
|
|
1539
|
-
throw new Error(`The instructions of "${name}" are longer than ${MAX_SKILL_TEXT.toLocaleString('en')} characters.`);
|
|
1540
1547
|
const projectDir = String(k?.projectDir ?? '').trim();
|
|
1541
1548
|
if (projectDir && !folders.some((f) => sameFolder(f, projectDir)))
|
|
1542
1549
|
throw new Error(`The skill "${name}" is for ${projectDir}, which is not one of the projects in Settings.`);
|
|
@@ -1671,6 +1678,73 @@ let OperatorService = class OperatorService {
|
|
|
1671
1678
|
});
|
|
1672
1679
|
}
|
|
1673
1680
|
/** The operator's answer to the lead's question. */
|
|
1681
|
+
/**
|
|
1682
|
+
* A subtask of two chats that failed for a technical reason, put to the operator (2026-10-25): a card under the subtask
|
|
1683
|
+
* with why, which attempt it was, what it left, and the choices; it waits until one is chosen, or the task is stopped.
|
|
1684
|
+
* Answered with `answerRetry`; "abort" on the card, a Stop or the end of the run stop the task.
|
|
1685
|
+
*/
|
|
1686
|
+
askSubtaskRetry(ask, signal) {
|
|
1687
|
+
return new Promise((resolveRetry) => {
|
|
1688
|
+
if (signal.aborted) {
|
|
1689
|
+
resolveRetry('stop');
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
const approval = {
|
|
1693
|
+
id: newId('a-'),
|
|
1694
|
+
sessionId: ask.sessionId,
|
|
1695
|
+
taskId: ask.taskId,
|
|
1696
|
+
stepId: 0,
|
|
1697
|
+
description: `Subtask ${ask.retry.n} (${ask.retry.title}) did not finish, attempt ${ask.retry.attempt} of ${ask.retry.maxAttempts}: ${ask.retry.reason || ask.retry.category}`,
|
|
1698
|
+
createdAt: new Date().toISOString(),
|
|
1699
|
+
actor: 'lead',
|
|
1700
|
+
retry: ask.retry,
|
|
1701
|
+
};
|
|
1702
|
+
this.waiting.set(approval.id, { approval, resolve: () => resolveRetry('stop'), resolveRetry });
|
|
1703
|
+
this.bus.publish({ sessionId: ask.sessionId, taskId: ask.taskId, type: 'approval-requested', level: 'warn',
|
|
1704
|
+
message: `subtask ${ask.retry.n} did not finish (attempt ${ask.retry.attempt} of ${ask.retry.maxAttempts}): the operator is asked what to do`, data: { approvalId: approval.id, retry: ask.retry } });
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
/** The operator's choice for a subtask that failed for a technical reason: one of the card's own. */
|
|
1708
|
+
answerRetry(approvalId, choice) {
|
|
1709
|
+
const w = this.waiting.get(approvalId);
|
|
1710
|
+
if (!w?.resolveRetry || !w.approval.retry)
|
|
1711
|
+
return { ok: false, problem: 'No subtask is waiting for a choice under that id.' };
|
|
1712
|
+
if (!w.approval.retry.choices.includes(choice))
|
|
1713
|
+
return { ok: false, problem: `"${choice}" is not one of this card's choices: ${w.approval.retry.choices.join(', ')}.` };
|
|
1714
|
+
this.waiting.delete(approvalId);
|
|
1715
|
+
w.resolveRetry(choice);
|
|
1716
|
+
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
1717
|
+
message: `the operator chose for subtask ${w.approval.retry.n}: ${choice}`, data: { approvalId, retry: choice } });
|
|
1718
|
+
return { ok: true };
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Two chats, after a Stop (2026-10-25): "do not start a task again by itself after Stop; when the operator carries on in
|
|
1722
|
+
* the same conversation, let a chosen failed subtask be tried again, with the plan and the reports kept". The message
|
|
1723
|
+
* is carried on with that subtask first (`TaskContinuation.retrySubtask`), then the lead goes on; the run is started
|
|
1724
|
+
* as a message of the chat is.
|
|
1725
|
+
*/
|
|
1726
|
+
async chatRetrySubtask(threadId, taskId, n, fresh) {
|
|
1727
|
+
await this.init();
|
|
1728
|
+
const session = await this.store.getSession(threadId);
|
|
1729
|
+
if (!session || session.kind !== 'chat')
|
|
1730
|
+
throw new Error('That conversation is not there any more.');
|
|
1731
|
+
if (this.running.has(threadId))
|
|
1732
|
+
throw new Error('The conversation is working: stop it first, or let it finish.');
|
|
1733
|
+
const task = session.tasks.find((t) => t.id === taskId);
|
|
1734
|
+
if (!task?.lead)
|
|
1735
|
+
throw new Error('That message is not one of two chats.');
|
|
1736
|
+
if (task.status !== 'aborted')
|
|
1737
|
+
throw new Error('Only a message that was stopped has a subtask to try again: the others carry on by themselves, or end.');
|
|
1738
|
+
const sub = [...task.lead.rounds].reverse().find((r) => r.subtask?.n === n)?.subtask;
|
|
1739
|
+
if (!sub)
|
|
1740
|
+
throw new Error(`The message has no subtask ${n}.`);
|
|
1741
|
+
const last = sub.attempts?.at(-1);
|
|
1742
|
+
if (last?.status === 'done')
|
|
1743
|
+
throw new Error(`Subtask ${n} was done; it is not done again.`);
|
|
1744
|
+
await this.store.rerunTask(threadId, taskId, {}, { fromAttempt: task.attempt ?? 1, stoppedBecause: task.reason, how: 'stopped', retrySubtask: { n, ...(fresh ? { fresh: true } : {}) } });
|
|
1745
|
+
const cfg = await this.settings.load();
|
|
1746
|
+
return await this.start(threadId, cfg.execution.mode);
|
|
1747
|
+
}
|
|
1674
1748
|
answerQuestion(approvalId, text) {
|
|
1675
1749
|
const w = this.waiting.get(approvalId);
|
|
1676
1750
|
if (!w?.resolveAnswer)
|
|
@@ -498,6 +498,16 @@ export const RunConfigSchema = z.object({
|
|
|
498
498
|
* subtask is a task of the worker's, with the limits above; this bounds the whole. Settings → Execution.
|
|
499
499
|
*/
|
|
500
500
|
maxSubtasks: z.number().int().min(1).max(100).default(20),
|
|
501
|
+
/*
|
|
502
|
+
* A subtask of two chats that failed for a technical reason (operator's specification, 2026-10-25; see
|
|
503
|
+
* `orchestrator/subtaskRetry.ts`): `ask` puts it to the operator on a card; `same` tries it again in the same
|
|
504
|
+
* worker's conversation, `fresh` in a new one — by themselves only for a proven, temporary fault of the chat; `lead`
|
|
505
|
+
* gives the lead the report, as before. At most `subtaskRetries` times more (0 to 3), `subtaskRetryWaitSec` apart.
|
|
506
|
+
* Settings → "Retrying an interrupted subtask". Only for two chats.
|
|
507
|
+
*/
|
|
508
|
+
subtaskRetryMode: z.enum(['ask', 'same', 'fresh', 'lead']).default('ask'),
|
|
509
|
+
subtaskRetries: z.number().int().min(0).max(3).default(2),
|
|
510
|
+
subtaskRetryWaitSec: z.number().int().min(0).max(600).default(15),
|
|
501
511
|
/*
|
|
502
512
|
* How many genuinely different approaches the chat must have tried before it may end a task
|
|
503
513
|
* "blocked". The reply format's own floor is 2 (replySchema.ts); this raises it. A "blocked"
|