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
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The queue of tasks (operator, 2026-10-24: "an option to prepare several tasks that run in a queue"): tasks written
|
|
3
|
+
* beforehand, each with its own model, run one after another while nobody watches, each in a new chat.
|
|
4
|
+
*
|
|
5
|
+
* The operator's rules, as they asked for them:
|
|
6
|
+
*
|
|
7
|
+
* - each task in a new chat, on its own model (empty: "Model for the worker" in Settings), chosen by the bot;
|
|
8
|
+
* - a task may depend on earlier ones, chosen task by task. When one fails, every task that depends on it — or on a
|
|
9
|
+
* task skipped for it — is skipped, and the queue goes on with the next one that does not;
|
|
10
|
+
* - a task works in the folder as it is, or on a new branch made from main. The server's main is fetched without a
|
|
11
|
+
* password or a key's passphrase, which nobody is there to type; when it cannot be, the local main is used, and the
|
|
12
|
+
* chat is told which it was.
|
|
13
|
+
*
|
|
14
|
+
* Kept as `data/queue.json` (see `OperatorService.queue`). This module is the part that needs no browser: the shape,
|
|
15
|
+
* the checks of an edit, and which task is next.
|
|
16
|
+
*/
|
|
17
|
+
import { branchExists } from '../vcs/git.js';
|
|
18
|
+
export const MAX_QUEUE_ITEMS = 50;
|
|
19
|
+
export function emptyQueue() {
|
|
20
|
+
return { items: [], running: false, updatedAt: new Date().toISOString() };
|
|
21
|
+
}
|
|
22
|
+
/** The first line of a task, for where a name is wanted. */
|
|
23
|
+
export function itemTitle(item) {
|
|
24
|
+
return item.prompt.split(/\r?\n/)[0].trim().slice(0, 80) || 'task';
|
|
25
|
+
}
|
|
26
|
+
/** An edit of the list as the page sends it, held to the rules, or the sentence that says why it cannot be. */
|
|
27
|
+
export function checkItems(items, maxPromptChars) {
|
|
28
|
+
if (!Array.isArray(items))
|
|
29
|
+
return { problem: 'The queue comes as a list of tasks.' };
|
|
30
|
+
if (items.length > MAX_QUEUE_ITEMS)
|
|
31
|
+
return { problem: `A queue holds at most ${MAX_QUEUE_ITEMS} tasks.` };
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
const out = [];
|
|
34
|
+
for (const [i, raw] of items.entries()) {
|
|
35
|
+
const x = (raw ?? {});
|
|
36
|
+
const n = i + 1;
|
|
37
|
+
const id = String(x.id ?? '').trim();
|
|
38
|
+
if (!/^[a-z0-9-]{1,40}$/i.test(id))
|
|
39
|
+
return { problem: `Task ${n} has no id the queue can keep.` };
|
|
40
|
+
if (seen.has(id))
|
|
41
|
+
return { problem: `Two tasks have the id "${id}".` };
|
|
42
|
+
const prompt = String(x.prompt ?? '').trim();
|
|
43
|
+
if (!prompt)
|
|
44
|
+
return { problem: `Task ${n} says nothing: write what it is to do.` };
|
|
45
|
+
if (prompt.length > maxPromptChars)
|
|
46
|
+
return { problem: `Task ${n} is ${prompt.length} characters; a task can be at most ${maxPromptChars}.` };
|
|
47
|
+
const dependsOn = Array.isArray(x.dependsOn) ? [...new Set(x.dependsOn.map((d) => String(d)))] : [];
|
|
48
|
+
// On earlier tasks only: they run first, so a task never waits for one after it, and never for itself.
|
|
49
|
+
const late = dependsOn.find((d) => !seen.has(d));
|
|
50
|
+
if (late)
|
|
51
|
+
return { problem: `Task ${n} depends on ${items.some((o) => o?.id === late) ? 'a task after it' : `"${late}", which is not in the queue`}: a task can depend only on tasks before it.` };
|
|
52
|
+
const branch = x.branch === 'main' ? 'main' : 'folder';
|
|
53
|
+
const status = typeof x.status === 'string' && ['waiting', 'running', 'done', 'failed', 'skipped', 'stopped'].includes(x.status) ? x.status : undefined;
|
|
54
|
+
out.push({ id, prompt, model: String(x.model ?? '').trim(), dependsOn, branch, review: x.review !== false, ...(status ? { status } : {}) });
|
|
55
|
+
seen.add(id);
|
|
56
|
+
}
|
|
57
|
+
return { items: out };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The list as edited, onto the queue as it is: a task already there keeps what the runs gave it — its status, why,
|
|
61
|
+
* its chat — unless it is being put back to wait ("Run again"); a task that is running is kept as it is, whatever
|
|
62
|
+
* the edit says; a new one waits.
|
|
63
|
+
*/
|
|
64
|
+
export function mergeItems(current, edited) {
|
|
65
|
+
const before = new Map(current.map((x) => [x.id, x]));
|
|
66
|
+
const running = current.find((x) => x.status === 'running');
|
|
67
|
+
if (running && !edited.some((x) => x.id === running.id))
|
|
68
|
+
return { problem: `"${itemTitle(running)}" is running: stop the queue before taking it out.` };
|
|
69
|
+
const items = edited.map((x) => {
|
|
70
|
+
const was = before.get(x.id);
|
|
71
|
+
if (was?.status === 'running')
|
|
72
|
+
return was;
|
|
73
|
+
if (!was)
|
|
74
|
+
return { ...x, status: 'waiting' };
|
|
75
|
+
const again = x.status === 'waiting' && was.status !== 'waiting';
|
|
76
|
+
if (again)
|
|
77
|
+
return { id: x.id, prompt: x.prompt, model: x.model, dependsOn: x.dependsOn, branch: x.branch, review: x.review, status: 'waiting' };
|
|
78
|
+
return { ...was, prompt: x.prompt, model: x.model, dependsOn: x.dependsOn, branch: x.branch, review: x.review };
|
|
79
|
+
});
|
|
80
|
+
return { items };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What the queue does next: run the first task that waits, or skip it when a task it depends on did not end done
|
|
84
|
+
* (failed, was skipped, was stopped); nothing when no task waits.
|
|
85
|
+
*/
|
|
86
|
+
export function nextStep(items) {
|
|
87
|
+
const byId = new Map(items.map((x) => [x.id, x]));
|
|
88
|
+
for (const item of items) {
|
|
89
|
+
if (item.status !== 'waiting')
|
|
90
|
+
continue;
|
|
91
|
+
const blocker = item.dependsOn.map((d) => byId.get(d)).find((d) => !d || d.status !== 'done');
|
|
92
|
+
if (blocker)
|
|
93
|
+
return { skip: item, because: blocker };
|
|
94
|
+
return { run: item };
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/** Why a task is skipped, in a sentence. */
|
|
99
|
+
export function skippedBecause(because) {
|
|
100
|
+
const what = because.status === 'failed' ? 'failed' : because.status === 'stopped' ? 'was stopped' : because.status === 'skipped' ? 'was skipped' : `has not run (${because.status})`;
|
|
101
|
+
return `it depends on "${itemTitle(because)}", which ${what}`;
|
|
102
|
+
}
|
|
103
|
+
/** A task's status from how its message ended. */
|
|
104
|
+
export function statusOfTask(taskStatus) {
|
|
105
|
+
return taskStatus === 'done' ? 'done' : taskStatus === 'aborted' ? 'stopped' : 'failed';
|
|
106
|
+
}
|
|
107
|
+
/** The branch a task "on a new branch from main" starts from: `main`, else `master`, as the repository has it. */
|
|
108
|
+
export async function mainBranchOf(dir) {
|
|
109
|
+
for (const name of ['main', 'master'])
|
|
110
|
+
if (await branchExists(dir, name))
|
|
111
|
+
return name;
|
|
112
|
+
return null;
|
|
113
|
+
}
|