copilot-operator 0.1.50 → 0.1.52
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/README.md +587 -574
- package/dist/src/api/operator.controller.js +119 -1023
- package/dist/src/api/operator.service.js +346 -2553
- package/dist/src/config/schema.js +13 -0
- package/dist/src/orchestrator/hold.js +49 -0
- package/dist/src/orchestrator/leadRunner.js +559 -0
- package/dist/src/orchestrator/taskRunner.js +211 -39
- package/dist/src/plan/kerrigan.js +232 -0
- package/dist/src/plan/systemGuide.js +758 -3757
- package/dist/src/protocol/leadSchema.js +156 -0
- package/dist/src/protocol/parser.js +1 -1
- package/dist/src/session/chatNotice.js +191 -0
- package/dist/src/session/checkpoint.js +19 -0
- package/dist/src/session/compose.js +1 -1
- package/dist/src/session/store.js +17 -126
- package/dist/src/session/workspace.js +52 -5
- package/dist/src/transport/chatTransport.js +1 -1
- package/dist/src/transport/copilotTransport.js +135 -1
- package/dist/web/404.html +13 -16
- package/dist/web/_next/static/_1zhoDsMOPAH2xW702E5A/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/134-ddd50a7fbb536ec8.js +1 -0
- package/dist/web/_next/static/chunks/163.dbd7d36584d0bb37.js +1 -0
- package/dist/web/_next/static/chunks/220.35531b39410e1a9f.js +1 -0
- package/dist/web/_next/static/chunks/548.71ac96c94136659b.js +1 -0
- package/dist/web/_next/static/chunks/584.6df695c5b86a75aa.js +1 -0
- package/dist/web/_next/static/chunks/67.9ed79e2fbfb56f26.js +1 -0
- package/dist/web/_next/static/chunks/714.1e2338736a70b9c7.js +1 -0
- package/dist/web/_next/static/chunks/747.d2c1249d736dc03b.js +1 -0
- package/dist/web/_next/static/chunks/77.a200abef0f5b4a7f.js +1 -0
- package/dist/web/_next/static/chunks/808-bc7d7eac6d823291.js +1 -0
- package/dist/web/_next/static/chunks/921-dc5538cd779c6432.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-edd7534ca9ecf366.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-8f99a164d76897a0.js +1 -0
- package/dist/web/_next/static/chunks/app/page-4bed816eda370d0c.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
- package/dist/web/_next/static/chunks/webpack-77147e31d2125631.js +1 -0
- package/dist/web/_next/static/css/3bea264adc472bc8.css +1 -0
- package/dist/web/defaults.html +13 -16
- package/dist/web/defaults.txt +22 -23
- package/dist/web/index.html +13 -16
- package/dist/web/index.txt +22 -23
- package/dist/web/system.html +13 -16
- package/dist/web/system.txt +22 -23
- package/package.json +5 -23
- package/prompts/lead1.md +116 -0
- package/dist/src/api/saveToDesktop.js +0 -157
- package/dist/src/plan/brief.js +0 -2003
- package/dist/src/plan/changes.js +0 -217
- package/dist/src/plan/script.js +0 -1014
- package/dist/src/session/debugExport.js +0 -165
- package/dist/src/session/exportRecord.js +0 -277
- package/dist/src/session/metrics.js +0 -95
- package/dist/src/vcs/prepareFromRemote.js +0 -288
- package/dist/src/vcs/remoteAuth.js +0 -117
- package/dist/src/vcs/startChoice.js +0 -367
- package/dist/src/vcs/syncCommand.js +0 -97
- package/dist/web/_next/static/chunks/197-f7c33a0114fc3db3.js +0 -1
- package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +0 -1
- package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +0 -1
- package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +0 -1
- package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +0 -1
- package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +0 -1
- package/dist/web/_next/static/chunks/app/appearance/page-a18019cdc395de3d.js +0 -1
- package/dist/web/_next/static/chunks/app/defaults/page-614be29d185a2947.js +0 -1
- package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +0 -1
- package/dist/web/_next/static/chunks/app/import/page-8ef75fc08638e75f.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +0 -1
- package/dist/web/_next/static/chunks/app/level1/page-dd3ebf37d29dce4f.js +0 -1
- package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +0 -1
- package/dist/web/_next/static/chunks/app/presets/page-93ab518db67e52a2.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/page-28376d2e4a9b4738.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/view/page-adb64f8ba3d8c06e.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-227a259e383ca2a0.js +0 -1
- package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
- package/dist/web/_next/static/css/4335e4ce269ba1ea.css +0 -1
- package/dist/web/_next/static/z74_FBfnnXW5IJCHTgTH2/_buildManifest.js +0 -1
- package/dist/web/appearance.html +0 -16
- package/dist/web/appearance.txt +0 -26
- package/dist/web/history.html +0 -16
- package/dist/web/history.txt +0 -26
- package/dist/web/import.html +0 -16
- package/dist/web/import.txt +0 -26
- package/dist/web/level1.html +0 -16
- package/dist/web/level1.txt +0 -26
- package/dist/web/presets.html +0 -19
- package/dist/web/presets.txt +0 -26
- package/dist/web/sessions/view.html +0 -16
- package/dist/web/sessions/view.txt +0 -26
- package/dist/web/sessions.html +0 -16
- package/dist/web/sessions.txt +0 -26
- package/prompts/organisation.bg.md +0 -43
- package/prompts/organisation.en.md +0 -43
- package/prompts/persona.bg.md +0 -17
- package/prompts/persona.en.md +0 -17
- package/prompts/work.bg.md +0 -19
- package/prompts/work.en.md +0 -19
- /package/dist/web/_next/static/{z74_FBfnnXW5IJCHTgTH2 → _1zhoDsMOPAH2xW702E5A}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lead's contract, as a schema (operator, 2026-10-20: "two chats — chat A takes the whole, complex task, breaks it
|
|
3
|
+
* into steps and directs; chat B carries out the small technical tasks and reports back").
|
|
4
|
+
*
|
|
5
|
+
* The prose the lead is given is `prompts/lead1.md`; this is the enforcement. The lead never runs anything: its replies
|
|
6
|
+
* say what to do next — give the worker a subtask, propose the plan, ask the operator, deliver the result, or stop —
|
|
7
|
+
* and anything that does not validate here is sent back with the reason, as a worker's reply in the wrong shape is.
|
|
8
|
+
* Lenient where nothing runs on it: a list that came as one string, an answer that came as an object (the fields of a
|
|
9
|
+
* bug report, say) are read as the text they mean rather than refused.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { findJsonCandidates, stripCitations, stripLineNumbers } from './parser.js';
|
|
13
|
+
import { MIN_SUMMARY_CHARS, PlanSchema } from './replySchema.js';
|
|
14
|
+
/** A value that is meant as prose, in whatever shape it came: an object or a list is written out as text. */
|
|
15
|
+
export function proseOfValue(value, depth = 0) {
|
|
16
|
+
if (value === undefined || value === null)
|
|
17
|
+
return '';
|
|
18
|
+
if (typeof value === 'string')
|
|
19
|
+
return value;
|
|
20
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
21
|
+
return String(value);
|
|
22
|
+
const pad = ' '.repeat(depth);
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value
|
|
25
|
+
.map((v) => {
|
|
26
|
+
const text = proseOfValue(v, depth + 1);
|
|
27
|
+
return text.includes('\n') ? `${pad}- ${text.trimStart()}` : `${pad}- ${text}`;
|
|
28
|
+
})
|
|
29
|
+
.join('\n');
|
|
30
|
+
}
|
|
31
|
+
// An object's fields, each on its line in the order they came: "**Title**: …".
|
|
32
|
+
return Object.entries(value)
|
|
33
|
+
.map(([k, v]) => {
|
|
34
|
+
const text = proseOfValue(v, depth + 1);
|
|
35
|
+
return typeof v === 'object' && v !== null ? `${pad}**${k}**:\n${text}` : `${pad}**${k}**: ${text}`;
|
|
36
|
+
})
|
|
37
|
+
.join('\n');
|
|
38
|
+
}
|
|
39
|
+
const prose = z.preprocess((v) => (v === undefined ? undefined : proseOfValue(v)), z.string().optional());
|
|
40
|
+
const proseList = z.preprocess((v) => v === undefined
|
|
41
|
+
? []
|
|
42
|
+
: typeof v === 'string'
|
|
43
|
+
? v.split(/\r?\n/).map((l) => l.replace(/^\s*(?:\d+[.)]|[-*•])\s+/, '').trim()).filter(Boolean)
|
|
44
|
+
: Array.isArray(v)
|
|
45
|
+
? v.map((x) => proseOfValue(x)).filter((x) => x.trim() !== '')
|
|
46
|
+
: [proseOfValue(v)], z.array(z.string()));
|
|
47
|
+
/** One subtask for the worker: what it is to find out or do, what it needs to know, and what to report back. */
|
|
48
|
+
export const SubtaskSchema = z.object({
|
|
49
|
+
title: z.preprocess((v) => proseOfValue(v), z.string().trim().min(3, 'subtask.title must name the subtask in a few words.').max(140)),
|
|
50
|
+
goal: z.preprocess((v) => proseOfValue(v), z.string().trim().min(15, 'subtask.goal must say what the worker is to find out or do, in a sentence or more.')),
|
|
51
|
+
context: prose.default(''),
|
|
52
|
+
steps: proseList.default([]),
|
|
53
|
+
report: z.preprocess((v) => proseOfValue(v), z.string().trim().min(10, 'subtask.report must say what the worker reports back to you, and in which shape.')),
|
|
54
|
+
doneWhen: prose.default(''),
|
|
55
|
+
readOnly: z.boolean().default(false),
|
|
56
|
+
freshWorker: z.boolean().default(false),
|
|
57
|
+
});
|
|
58
|
+
export const LeadReplySchema = z
|
|
59
|
+
.object({
|
|
60
|
+
/**
|
|
61
|
+
* What the lead does next.
|
|
62
|
+
*
|
|
63
|
+
* `delegate` — give the worker this subtask (`subtask`). `plan` — the plan of the whole assignment (`plan`), for the
|
|
64
|
+
* operator to approve when they approve plans. `ask` — a question only the operator can answer (`question`).
|
|
65
|
+
* `done` — the result, in the form the assignment asked for (`answer`). `blocked` — it cannot be taken further
|
|
66
|
+
* without the operator (`summary`, `needed`).
|
|
67
|
+
*/
|
|
68
|
+
status: z.enum(['delegate', 'plan', 'ask', 'done', 'blocked']),
|
|
69
|
+
understanding: prose,
|
|
70
|
+
notes: prose,
|
|
71
|
+
plan: PlanSchema.optional(),
|
|
72
|
+
subtask: SubtaskSchema.optional(),
|
|
73
|
+
question: prose,
|
|
74
|
+
why: prose,
|
|
75
|
+
options: proseList.default([]),
|
|
76
|
+
answer: prose,
|
|
77
|
+
evidence: proseList.default([]),
|
|
78
|
+
summary: prose,
|
|
79
|
+
needed: prose,
|
|
80
|
+
})
|
|
81
|
+
.refine((r) => r.status !== 'delegate' || !!r.subtask, {
|
|
82
|
+
message: 'status "delegate" requires a "subtask": {"title", "goal", "context", "steps", "report", "doneWhen", "readOnly", "freshWorker"}.',
|
|
83
|
+
})
|
|
84
|
+
.refine((r) => r.status !== 'plan' || !!r.plan, {
|
|
85
|
+
message: 'status "plan" requires a "plan": {"existing", "approach", "steps": [the stages], "files", "verification", "risks"}.',
|
|
86
|
+
})
|
|
87
|
+
.refine((r) => r.status !== 'ask' || (r.question ?? '').trim().length >= 10, {
|
|
88
|
+
message: 'status "ask" requires a "question" for the operator: what only a person can decide, said in full.',
|
|
89
|
+
})
|
|
90
|
+
.refine((r) => r.status !== 'done' || (r.answer ?? '').trim().length >= MIN_SUMMARY_CHARS, {
|
|
91
|
+
message: 'status "done" requires an "answer": the result, in the form the assignment asked for, in full.',
|
|
92
|
+
})
|
|
93
|
+
.refine((r) => r.status !== 'blocked' || (r.summary ?? '').trim().length >= MIN_SUMMARY_CHARS, {
|
|
94
|
+
message: 'status "blocked" requires a "summary": what was done and found, with its evidence, so the work can be picked up.',
|
|
95
|
+
})
|
|
96
|
+
.refine((r) => r.status !== 'blocked' || (r.needed ?? '').trim().length > 0, {
|
|
97
|
+
message: 'status "blocked" requires "needed": what would let the work go on.',
|
|
98
|
+
});
|
|
99
|
+
/** The lead's reply, found, validated and cleaned of citation markers. */
|
|
100
|
+
export function parseLeadReply(markdown) {
|
|
101
|
+
const candidates = findJsonCandidates(markdown);
|
|
102
|
+
if (candidates.length === 0) {
|
|
103
|
+
return { ok: false, reason: 'no-json-block', detail: 'The reply contained no fenced ```json block and no JSON object at all.' };
|
|
104
|
+
}
|
|
105
|
+
const errors = [];
|
|
106
|
+
const paths = new Set();
|
|
107
|
+
for (const raw of candidates) {
|
|
108
|
+
for (const text of [raw, stripLineNumbers(raw)]) {
|
|
109
|
+
let value;
|
|
110
|
+
try {
|
|
111
|
+
value = JSON.parse(text);
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
errors.push(`JSON.parse failed: ${e.message}`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const result = LeadReplySchema.safeParse(value);
|
|
118
|
+
if (!result.success) {
|
|
119
|
+
errors.push(result.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; '));
|
|
120
|
+
for (const i of result.error.issues)
|
|
121
|
+
paths.add(i.path.join('.') || '(root)');
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const r = result.data;
|
|
125
|
+
const clean = (s) => stripCitations(s)?.trim() || undefined;
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
reply: { ...r, understanding: clean(r.understanding), notes: clean(r.notes), answer: clean(r.answer), summary: clean(r.summary), question: clean(r.question) },
|
|
129
|
+
json: text.trim(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { ok: false, reason: 'invalid-json', detail: errors.slice(0, 4).join(' | '), ...(paths.size > 0 ? { paths: [...paths] } : {}) };
|
|
134
|
+
}
|
|
135
|
+
const LEAD_EXAMPLE = [
|
|
136
|
+
'```json',
|
|
137
|
+
'{"status": "delegate", "notes": "what you decide and why", "subtask": {"title": "Run the tests", "goal": "Find out which tests fail now.", "context": "Change nothing.", "steps": [], "report": "The totals, and for each failing test its name and its error, quoted.", "doneWhen": "The suite ran once.", "readOnly": true, "freshWorker": false}}',
|
|
138
|
+
'```',
|
|
139
|
+
'or {"status": "plan", "plan": {"existing": "…", "approach": "…", "steps": ["…"], "files": [], "verification": "…"}}',
|
|
140
|
+
'or {"status": "ask", "question": "…", "why": "…", "options": ["…", "…"]}',
|
|
141
|
+
'or {"status": "done", "answer": "the result, in the form asked for", "evidence": ["…"]}',
|
|
142
|
+
'or {"status": "blocked", "summary": "what was done and found", "needed": "what would let it go on"}',
|
|
143
|
+
].join('\n');
|
|
144
|
+
/** The message that asks the lead for the same answer again, in the format. */
|
|
145
|
+
export function leadFormatErrorMessage(fail, attempt, maxAttempts) {
|
|
146
|
+
return [
|
|
147
|
+
`Your last reply did not match the lead's format (format retry ${attempt} of ${maxAttempts}).`,
|
|
148
|
+
fail.reason === 'no-json-block' ? 'There was no fenced json code block in it.' : `The json block did not validate: ${fail.detail}`,
|
|
149
|
+
'Only the format is wrong: nothing from that reply was acted on. Send the same answer again, reformatted, as exactly one fenced code block tagged json. For example:',
|
|
150
|
+
LEAD_EXAMPLE,
|
|
151
|
+
].join('\n');
|
|
152
|
+
}
|
|
153
|
+
/** A first reply without the assignment restated. */
|
|
154
|
+
export const UNDERSTANDING_FIRST = 'Before anything else, restate the assignment in "understanding": the goal, the result to deliver and its exact form ' +
|
|
155
|
+
'(every field asked for), the constraints, and how you will know it is done. Send your reply again with it; nothing ' +
|
|
156
|
+
'from the last one was acted on.';
|
|
@@ -31,7 +31,7 @@ export function stripLineNumbers(body) {
|
|
|
31
31
|
return body;
|
|
32
32
|
return lines.filter((l) => !/^\s*\d+\s*$/.test(l)).join('\n');
|
|
33
33
|
}
|
|
34
|
-
function findJsonCandidates(markdown) {
|
|
34
|
+
export function findJsonCandidates(markdown) {
|
|
35
35
|
const blocks = extractFencedBlocks(markdown);
|
|
36
36
|
const out = [];
|
|
37
37
|
for (const b of blocks) {
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
const WORDS = {
|
|
2
|
+
en: {
|
|
3
|
+
done: 'The task is done',
|
|
4
|
+
stopped: 'The task was stopped',
|
|
5
|
+
failed: 'The task ended unfinished',
|
|
6
|
+
notStarted: 'The task could not start',
|
|
7
|
+
doneLine: 'Copilot finished it. What was done is in the copilot-operator chat.',
|
|
8
|
+
stoppedLine: 'It was stopped; nothing more is sent.',
|
|
9
|
+
blockedLine: 'Copilot could not finish it',
|
|
10
|
+
failedLine: 'It ended with an error',
|
|
11
|
+
limitLine: 'It stopped at a limit from the settings',
|
|
12
|
+
notStartedLine: 'Nothing was sent',
|
|
13
|
+
statusOf: { done: 'done', aborted: 'stopped', blocked: 'blocked', failed: 'failed', 'limit-reached': 'at a limit', queued: 'not started' },
|
|
14
|
+
keep: 'This window stays open for your next message. You can close it at any time.',
|
|
15
|
+
ok: 'OK',
|
|
16
|
+
quote: (s) => `“${s}”`,
|
|
17
|
+
},
|
|
18
|
+
bg: {
|
|
19
|
+
done: 'Заданието е изпълнено',
|
|
20
|
+
stopped: 'Заданието е спряно',
|
|
21
|
+
failed: 'Заданието приключи незавършено',
|
|
22
|
+
notStarted: 'Заданието не можа да започне',
|
|
23
|
+
doneLine: 'Copilot го завърши. Какво е направено, виждате в чата на copilot-operator.',
|
|
24
|
+
stoppedLine: 'Спряно е; нищо повече не се изпраща.',
|
|
25
|
+
blockedLine: 'Copilot не успя да го завърши',
|
|
26
|
+
failedLine: 'Завърши с грешка',
|
|
27
|
+
limitLine: 'Спря при ограничение от настройките',
|
|
28
|
+
notStartedLine: 'Нищо не беше изпратено',
|
|
29
|
+
statusOf: { done: 'изпълнено', aborted: 'спряно', blocked: 'незавършено', failed: 'с грешка', 'limit-reached': 'при ограничение', queued: 'не започна' },
|
|
30
|
+
keep: 'Прозорецът остава отворен за следващото ви съобщение. Можете да го затворите по всяко време.',
|
|
31
|
+
ok: 'ОК',
|
|
32
|
+
quote: (s) => `„${s}“`,
|
|
33
|
+
},
|
|
34
|
+
de: {
|
|
35
|
+
done: 'Die Aufgabe ist erledigt',
|
|
36
|
+
stopped: 'Die Aufgabe wurde angehalten',
|
|
37
|
+
failed: 'Die Aufgabe wurde nicht abgeschlossen',
|
|
38
|
+
notStarted: 'Die Aufgabe konnte nicht beginnen',
|
|
39
|
+
doneLine: 'Copilot hat sie abgeschlossen. Was getan wurde, steht im Chat von copilot-operator.',
|
|
40
|
+
stoppedLine: 'Sie wurde angehalten; es wird nichts mehr gesendet.',
|
|
41
|
+
blockedLine: 'Copilot konnte sie nicht abschließen',
|
|
42
|
+
failedLine: 'Sie endete mit einem Fehler',
|
|
43
|
+
limitLine: 'Sie hielt an einer Grenze aus den Einstellungen an',
|
|
44
|
+
notStartedLine: 'Es wurde nichts gesendet',
|
|
45
|
+
statusOf: { done: 'erledigt', aborted: 'angehalten', blocked: 'blockiert', failed: 'fehlgeschlagen', 'limit-reached': 'an einer Grenze', queued: 'nicht begonnen' },
|
|
46
|
+
keep: 'Dieses Fenster bleibt für Ihre nächste Nachricht geöffnet. Sie können es jederzeit schließen.',
|
|
47
|
+
ok: 'OK',
|
|
48
|
+
quote: (s) => `„${s}“`,
|
|
49
|
+
},
|
|
50
|
+
es: {
|
|
51
|
+
done: 'La tarea se ha completado',
|
|
52
|
+
stopped: 'La tarea se ha detenido',
|
|
53
|
+
failed: 'La tarea terminó sin completarse',
|
|
54
|
+
notStarted: 'La tarea no pudo empezar',
|
|
55
|
+
doneLine: 'Copilot la ha terminado. Lo que se hizo está en el chat de copilot-operator.',
|
|
56
|
+
stoppedLine: 'Se ha detenido; no se envía nada más.',
|
|
57
|
+
blockedLine: 'Copilot no pudo terminarla',
|
|
58
|
+
failedLine: 'Terminó con un error',
|
|
59
|
+
limitLine: 'Se detuvo en un límite de la configuración',
|
|
60
|
+
notStartedLine: 'No se envió nada',
|
|
61
|
+
statusOf: { done: 'completada', aborted: 'detenida', blocked: 'bloqueada', failed: 'con error', 'limit-reached': 'en un límite', queued: 'sin empezar' },
|
|
62
|
+
keep: 'Esta ventana sigue abierta para su próximo mensaje. Puede cerrarla en cualquier momento.',
|
|
63
|
+
ok: 'Aceptar',
|
|
64
|
+
quote: (s) => `«${s}»`,
|
|
65
|
+
},
|
|
66
|
+
fr: {
|
|
67
|
+
done: 'La tâche est terminée',
|
|
68
|
+
stopped: 'La tâche a été arrêtée',
|
|
69
|
+
failed: 'La tâche s’est terminée inachevée',
|
|
70
|
+
notStarted: 'La tâche n’a pas pu démarrer',
|
|
71
|
+
doneLine: 'Copilot l’a terminée. Ce qui a été fait se trouve dans le chat de copilot-operator.',
|
|
72
|
+
stoppedLine: 'Elle a été arrêtée ; plus rien n’est envoyé.',
|
|
73
|
+
blockedLine: 'Copilot n’a pas pu la terminer',
|
|
74
|
+
failedLine: 'Elle s’est terminée par une erreur',
|
|
75
|
+
limitLine: 'Elle s’est arrêtée à une limite des paramètres',
|
|
76
|
+
notStartedLine: 'Rien n’a été envoyé',
|
|
77
|
+
statusOf: { done: 'terminée', aborted: 'arrêtée', blocked: 'bloquée', failed: 'en erreur', 'limit-reached': 'à une limite', queued: 'non démarrée' },
|
|
78
|
+
keep: 'Cette fenêtre reste ouverte pour votre prochain message. Vous pouvez la fermer à tout moment.',
|
|
79
|
+
ok: 'OK',
|
|
80
|
+
quote: (s) => `« ${s} »`,
|
|
81
|
+
},
|
|
82
|
+
pt: {
|
|
83
|
+
done: 'A tarefa está concluída',
|
|
84
|
+
stopped: 'A tarefa foi parada',
|
|
85
|
+
failed: 'A tarefa terminou por concluir',
|
|
86
|
+
notStarted: 'A tarefa não pôde começar',
|
|
87
|
+
doneLine: 'O Copilot concluiu-a. O que foi feito está no chat do copilot-operator.',
|
|
88
|
+
stoppedLine: 'Foi parada; não é enviado mais nada.',
|
|
89
|
+
blockedLine: 'O Copilot não conseguiu concluí-la',
|
|
90
|
+
failedLine: 'Terminou com um erro',
|
|
91
|
+
limitLine: 'Parou num limite das definições',
|
|
92
|
+
notStartedLine: 'Nada foi enviado',
|
|
93
|
+
statusOf: { done: 'concluída', aborted: 'parada', blocked: 'bloqueada', failed: 'com erro', 'limit-reached': 'num limite', queued: 'não iniciada' },
|
|
94
|
+
keep: 'Esta janela fica aberta para a sua próxima mensagem. Pode fechá-la a qualquer momento.',
|
|
95
|
+
ok: 'OK',
|
|
96
|
+
quote: (s) => `«${s}»`,
|
|
97
|
+
},
|
|
98
|
+
ja: {
|
|
99
|
+
done: 'タスクが完了しました',
|
|
100
|
+
stopped: 'タスクを停止しました',
|
|
101
|
+
failed: 'タスクは未完了のまま終了しました',
|
|
102
|
+
notStarted: 'タスクを開始できませんでした',
|
|
103
|
+
doneLine: 'Copilot がタスクを完了しました。行われた内容は copilot-operator のチャットにあります。',
|
|
104
|
+
stoppedLine: '停止しました。これ以上は何も送信されません。',
|
|
105
|
+
blockedLine: 'Copilot はタスクを完了できませんでした',
|
|
106
|
+
failedLine: 'エラーで終了しました',
|
|
107
|
+
limitLine: '設定の上限で停止しました',
|
|
108
|
+
notStartedLine: '何も送信されませんでした',
|
|
109
|
+
statusOf: { done: '完了', aborted: '停止', blocked: 'ブロック', failed: 'エラー', 'limit-reached': '上限で停止', queued: '未開始' },
|
|
110
|
+
keep: 'このウィンドウは次のメッセージのために開いたままです。いつでも閉じることができます。',
|
|
111
|
+
ok: 'OK',
|
|
112
|
+
quote: (s) => `「${s}」`,
|
|
113
|
+
},
|
|
114
|
+
ko: {
|
|
115
|
+
done: '작업이 완료되었습니다',
|
|
116
|
+
stopped: '작업이 중지되었습니다',
|
|
117
|
+
failed: '작업이 완료되지 않은 채 끝났습니다',
|
|
118
|
+
notStarted: '작업을 시작할 수 없었습니다',
|
|
119
|
+
doneLine: 'Copilot이 작업을 마쳤습니다. 수행된 내용은 copilot-operator 채팅에 있습니다.',
|
|
120
|
+
stoppedLine: '중지되었습니다. 더 이상 아무것도 보내지 않습니다.',
|
|
121
|
+
blockedLine: 'Copilot이 작업을 마치지 못했습니다',
|
|
122
|
+
failedLine: '오류로 끝났습니다',
|
|
123
|
+
limitLine: '설정의 한도에서 멈췄습니다',
|
|
124
|
+
notStartedLine: '아무것도 보내지 않았습니다',
|
|
125
|
+
statusOf: { done: '완료', aborted: '중지됨', blocked: '차단됨', failed: '오류', 'limit-reached': '한도 도달', queued: '시작 안 됨' },
|
|
126
|
+
keep: '이 창은 다음 메시지를 위해 열려 있습니다. 언제든지 닫을 수 있습니다.',
|
|
127
|
+
ok: '확인',
|
|
128
|
+
quote: (s) => `‘${s}’`,
|
|
129
|
+
},
|
|
130
|
+
ar: {
|
|
131
|
+
done: 'اكتملت المهمة',
|
|
132
|
+
stopped: 'تم إيقاف المهمة',
|
|
133
|
+
failed: 'انتهت المهمة دون إكمالها',
|
|
134
|
+
notStarted: 'تعذّر بدء المهمة',
|
|
135
|
+
doneLine: 'أنهى Copilot المهمة. ما تم إنجازه موجود في دردشة copilot-operator.',
|
|
136
|
+
stoppedLine: 'تم إيقافها؛ لن يُرسل أي شيء آخر.',
|
|
137
|
+
blockedLine: 'لم يتمكن Copilot من إنهائها',
|
|
138
|
+
failedLine: 'انتهت بخطأ',
|
|
139
|
+
limitLine: 'توقفت عند حد من الإعدادات',
|
|
140
|
+
notStartedLine: 'لم يُرسل أي شيء',
|
|
141
|
+
statusOf: { done: 'مكتملة', aborted: 'متوقفة', blocked: 'محظورة', failed: 'بخطأ', 'limit-reached': 'عند حد', queued: 'لم تبدأ' },
|
|
142
|
+
keep: 'تبقى هذه النافذة مفتوحة لرسالتك التالية. يمكنك إغلاقها في أي وقت.',
|
|
143
|
+
ok: 'موافق',
|
|
144
|
+
quote: (s) => `«${s}»`,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
/** The languages written right to left: the card is drawn that way for them. */
|
|
148
|
+
const RIGHT_TO_LEFT = new Set(['ar']);
|
|
149
|
+
/** A reason as a line: its first sentence or so, since the whole of it is in the chat. */
|
|
150
|
+
function brief(text, max = 220) {
|
|
151
|
+
const one = (text ?? '').replace(/\s+/g, ' ').trim();
|
|
152
|
+
return one.length > max ? `${one.slice(0, max - 1).trimEnd()}…` : one;
|
|
153
|
+
}
|
|
154
|
+
/** The card for a run of the chat that has ended: how its message(s) ended, and that the window stays open. */
|
|
155
|
+
export function chatNotice(lang, tasks, error) {
|
|
156
|
+
const w = WORDS[lang] ?? WORDS.en;
|
|
157
|
+
const ran = tasks.filter((t) => t.status !== 'queued');
|
|
158
|
+
const unfinished = ran.filter((t) => t.status !== 'done' && t.status !== 'aborted');
|
|
159
|
+
const stopped = ran.some((t) => t.status === 'aborted');
|
|
160
|
+
const kind = unfinished.length > 0 ? 'failed' : stopped ? 'stopped' : ran.length > 0 ? 'done' : error ? 'notStarted' : 'stopped';
|
|
161
|
+
const subject = tasks.length === 1 ? w.quote(tasks[0].title) : undefined;
|
|
162
|
+
const lines = [];
|
|
163
|
+
if (tasks.length > 1) {
|
|
164
|
+
for (const t of tasks)
|
|
165
|
+
lines.push(`${w.quote(t.title)} — ${w.statusOf[t.status] ?? t.status}`);
|
|
166
|
+
}
|
|
167
|
+
else if (kind === 'done') {
|
|
168
|
+
lines.push(w.doneLine);
|
|
169
|
+
}
|
|
170
|
+
else if (kind === 'stopped') {
|
|
171
|
+
lines.push(w.stoppedLine);
|
|
172
|
+
}
|
|
173
|
+
else if (kind === 'notStarted') {
|
|
174
|
+
lines.push(`${w.notStartedLine}: ${brief(error)}`);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const t = unfinished[0];
|
|
178
|
+
const said = t.status === 'blocked' ? w.blockedLine : t.status === 'limit-reached' ? w.limitLine : w.failedLine;
|
|
179
|
+
const why = brief(t.status === 'blocked' ? t.summary || t.reason : t.reason || t.summary);
|
|
180
|
+
lines.push(why ? `${said}: ${why}` : `${said}.`);
|
|
181
|
+
}
|
|
182
|
+
lines.push(w.keep);
|
|
183
|
+
return {
|
|
184
|
+
tone: kind === 'done' ? 'done' : kind === 'stopped' ? 'stopped' : 'failed',
|
|
185
|
+
title: w[kind],
|
|
186
|
+
...(subject ? { subject } : {}),
|
|
187
|
+
lines,
|
|
188
|
+
button: w.ok,
|
|
189
|
+
...(RIGHT_TO_LEFT.has(lang) ? { dir: 'rtl' } : {}),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -63,6 +63,25 @@ export async function takeAfter(dir, id, before) {
|
|
|
63
63
|
const r = await photograph(dir, `refs/copilot-operator/after/${id}`, `after message ${id}`, before.commit);
|
|
64
64
|
return 'problem' in r ? r : { commit: r.commit };
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The files a message has changed so far: the folder photographed now, against its checkpoint (for the review of a
|
|
68
|
+
* chat message, 2026-10-20). The photograph is let go of afterwards; the one taken when the message ends is kept.
|
|
69
|
+
*/
|
|
70
|
+
export async function changedSince(dir, before, id) {
|
|
71
|
+
const ref = `refs/copilot-operator/review/${id}`;
|
|
72
|
+
const r = await photograph(dir, ref, `the folder during the review of ${id}`, before.commit);
|
|
73
|
+
if ('problem' in r)
|
|
74
|
+
throw new Error(r.problem);
|
|
75
|
+
try {
|
|
76
|
+
const diff = await git(dir, ['diff', '--name-only', '--no-renames', before.commit, r.commit]);
|
|
77
|
+
if (!diff.ok)
|
|
78
|
+
throw new Error(diff.stderr);
|
|
79
|
+
return diff.stdout.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
await git(dir, ['update-ref', '-d', ref]).catch(() => undefined);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
66
85
|
/**
|
|
67
86
|
* Puts the folder back as `cp` photographed it: its branch checked out at its commit, its working tree with the
|
|
68
87
|
* same uncommitted changes. The folder as it is now is photographed first, under `refs/copilot-operator/safety/`.
|
|
@@ -65,7 +65,7 @@ function level2Block(level2) {
|
|
|
65
65
|
* failed, that the files are as its work left them, and — after the bot stopped under it — which of
|
|
66
66
|
* the steps it had just asked for actually ran.
|
|
67
67
|
*/
|
|
68
|
-
function whyItStopped(c) {
|
|
68
|
+
export function whyItStopped(c) {
|
|
69
69
|
if (c.how === 'failed')
|
|
70
70
|
return describeEnding(c.fromAttempt, c.ended, c.stoppedBecause);
|
|
71
71
|
if (c.how === 'interrupted') {
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* at once cannot fail each other or undo each other's change.
|
|
9
9
|
*/
|
|
10
10
|
import { mkdir, readFile, writeFile, readdir, rename, rm } from 'node:fs/promises';
|
|
11
|
-
import { existsSync } from 'node:fs';
|
|
12
11
|
import { randomUUID } from 'node:crypto';
|
|
13
|
-
import { join, resolve } from 'node:path';
|
|
12
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
13
|
import { endingOf, isContinuable, MAX_INSTRUCTION_CHARS, newId, tidyVcsPlan } from './model.js';
|
|
15
14
|
/** A task the runner is inside of. It cannot be edited, deleted, or left behind at startup. */
|
|
16
15
|
const ACTIVE_STATUSES = ['running', 'waiting-approval'];
|
|
@@ -113,6 +112,9 @@ export const TASK_FIELD_ON_RERUN = {
|
|
|
113
112
|
notes: 'kept',
|
|
114
113
|
// The folder before the message first ran: the point "go back" returns to, whatever attempt came after.
|
|
115
114
|
checkpoint: 'kept',
|
|
115
|
+
// The lead's rounds belong to the attempt that made them (two chats, 2026-10-20); which lead a subtask serves, to the task.
|
|
116
|
+
lead: 'archived',
|
|
117
|
+
fromLead: 'kept',
|
|
116
118
|
interruption: 'cleared',
|
|
117
119
|
finalReply: 'cleared',
|
|
118
120
|
firstMessage: 'cleared',
|
|
@@ -191,59 +193,28 @@ export class SessionStore {
|
|
|
191
193
|
defaultLevel1Path;
|
|
192
194
|
dir;
|
|
193
195
|
sessionsDir;
|
|
194
|
-
presetsDir;
|
|
195
|
-
/** Named personas the operator keeps for the import page, one file each. */
|
|
196
|
-
personasDir;
|
|
197
|
-
level1Path;
|
|
198
196
|
modelsPath;
|
|
199
197
|
constructor(dataDir, defaultLevel1Path) {
|
|
200
198
|
this.defaultLevel1Path = defaultLevel1Path;
|
|
201
199
|
this.dir = resolve(dataDir);
|
|
202
200
|
this.sessionsDir = join(this.dir, 'sessions');
|
|
203
|
-
this.presetsDir = join(this.dir, 'level2');
|
|
204
|
-
this.personasDir = join(this.dir, 'personas');
|
|
205
|
-
this.level1Path = join(this.dir, 'level1.md');
|
|
206
201
|
this.modelsPath = join(this.dir, 'models.json');
|
|
207
202
|
}
|
|
208
203
|
async init() {
|
|
209
204
|
await mkdir(this.sessionsDir, { recursive: true });
|
|
210
|
-
await mkdir(this.presetsDir, { recursive: true });
|
|
211
205
|
}
|
|
212
206
|
// --- level 1 --------------------------------------------------------------------------
|
|
213
|
-
/** The contract in force: the user's edited copy if there is one, else the shipped one. */
|
|
214
|
-
async getLevel1() {
|
|
215
|
-
if (existsSync(this.level1Path)) {
|
|
216
|
-
return { content: await readFile(this.level1Path, 'utf8'), customised: true };
|
|
217
|
-
}
|
|
218
|
-
return { content: await readFile(this.defaultLevel1Path, 'utf8'), customised: false };
|
|
219
|
-
}
|
|
220
|
-
async setLevel1(content) {
|
|
221
|
-
await writeFileAtomically(this.level1Path, content);
|
|
222
|
-
}
|
|
223
|
-
async resetLevel1() {
|
|
224
|
-
await removeFile(this.level1Path);
|
|
225
|
-
}
|
|
226
|
-
// --- the organisation's part of the plan persona -------------------------------------
|
|
227
207
|
/**
|
|
228
|
-
* The
|
|
229
|
-
* the
|
|
230
|
-
*
|
|
208
|
+
* The contract in force: the one that ships with the bot, always (operator, 2026-10-20: "it no longer needs changing;
|
|
209
|
+
* it changes at system level, when the bot is updated"). An edited copy an earlier version kept in the data folder
|
|
210
|
+
* (`level1.md` there) is not read any more, and the page that edited it is gone.
|
|
231
211
|
*/
|
|
232
|
-
async
|
|
233
|
-
|
|
234
|
-
const shipped = join(this.defaultLevel1Path, '..', `${kind}.${lang}.md`);
|
|
235
|
-
const example = await readFile(shipped, 'utf8').catch(() => '');
|
|
236
|
-
if (existsSync(custom))
|
|
237
|
-
return { content: await readFile(custom, 'utf8'), customised: true, example };
|
|
238
|
-
// Nothing until the operator writes it: an empty field is what makes the persona ask.
|
|
239
|
-
// The shipped text is the example it is shown, not the answer.
|
|
240
|
-
return { content: '', customised: false, example };
|
|
241
|
-
}
|
|
242
|
-
async setContext(kind, content) {
|
|
243
|
-
await writeFileAtomically(join(this.dir, `context-${kind}.md`), content);
|
|
212
|
+
async getLevel1() {
|
|
213
|
+
return { content: await readFile(this.defaultLevel1Path, 'utf8') };
|
|
244
214
|
}
|
|
245
|
-
|
|
246
|
-
|
|
215
|
+
/** The lead's contract (two chats, 2026-10-20): `lead1.md`, beside the base prompt it ships with. */
|
|
216
|
+
async getLead1() {
|
|
217
|
+
return { content: await readFile(join(dirname(this.defaultLevel1Path), 'lead1.md'), 'utf8') };
|
|
247
218
|
}
|
|
248
219
|
// --- the model catalogue ----------------------------------------------------------------
|
|
249
220
|
/** What the chat's picker offered when it was last read, or null if it never was. */
|
|
@@ -258,68 +229,6 @@ export class SessionStore {
|
|
|
258
229
|
async saveModels(catalogue) {
|
|
259
230
|
await writeFileAtomically(this.modelsPath, JSON.stringify(catalogue, null, 2));
|
|
260
231
|
}
|
|
261
|
-
// --- level 2 presets ------------------------------------------------------------------
|
|
262
|
-
async listPresets() {
|
|
263
|
-
const names = (await readdir(this.presetsDir).catch(() => []))
|
|
264
|
-
.filter((n) => n.endsWith('.md'))
|
|
265
|
-
.sort();
|
|
266
|
-
const out = [];
|
|
267
|
-
for (const n of names) {
|
|
268
|
-
const path = join(this.presetsDir, n);
|
|
269
|
-
const content = await readFile(path, 'utf8');
|
|
270
|
-
const { mtime } = await import('node:fs').then((fs) => fs.statSync(path));
|
|
271
|
-
out.push({ name: n.slice(0, -3), content, updatedAt: mtime.toISOString() });
|
|
272
|
-
}
|
|
273
|
-
return out;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Saves a preset under the name it can later be deleted by.
|
|
277
|
-
*
|
|
278
|
-
* Stripping the characters a file name cannot hold is not enough on its own: a leading dot and
|
|
279
|
-
* ".." survive it, and `safePresetName` refuses both, so ".env" and "a..b" were saved and then
|
|
280
|
-
* could never be deleted. The name goes through the same rule as the delete, the way a persona's
|
|
281
|
-
* always has, so a name that could not be removed is refused here instead.
|
|
282
|
-
*/
|
|
283
|
-
async savePreset(name, content) {
|
|
284
|
-
const safe = name.replace(/[^\p{L}\p{N}._ -]/gu, '').trim();
|
|
285
|
-
if (!safe)
|
|
286
|
-
throw new Error('Preset name is empty after removing unsafe characters.');
|
|
287
|
-
await writeFileAtomically(join(this.presetsDir, `${safePresetName(safe)}.md`), content);
|
|
288
|
-
return { name: safe, content, updatedAt: new Date().toISOString() };
|
|
289
|
-
}
|
|
290
|
-
async deletePreset(name) {
|
|
291
|
-
await removeFile(await namedFile(this.presetsDir, name));
|
|
292
|
-
}
|
|
293
|
-
// --- named personas -------------------------------------------------------------------
|
|
294
|
-
//
|
|
295
|
-
// "How the tasks are carried out" is one box on the import page, and the persona in it depends
|
|
296
|
-
// on the kind of work: a Playwright suite wants a different agent from an API service. These
|
|
297
|
-
// are saved copies of that box under a name, so switching is one choice instead of pasting a
|
|
298
|
-
// JSON back in. The box itself (`context-persona.md`) stays the one that is in force.
|
|
299
|
-
async listPersonas() {
|
|
300
|
-
const names = (await readdir(this.personasDir).catch(() => []))
|
|
301
|
-
.filter((n) => n.endsWith('.md'))
|
|
302
|
-
.sort((a, b) => a.localeCompare(b));
|
|
303
|
-
const out = [];
|
|
304
|
-
for (const n of names) {
|
|
305
|
-
const path = join(this.personasDir, n);
|
|
306
|
-
const content = await readFile(path, 'utf8');
|
|
307
|
-
const { mtime } = await import('node:fs').then((fs) => fs.statSync(path));
|
|
308
|
-
out.push({ name: n.slice(0, -3), content, updatedAt: mtime.toISOString() });
|
|
309
|
-
}
|
|
310
|
-
return out;
|
|
311
|
-
}
|
|
312
|
-
async savePersona(name, content) {
|
|
313
|
-
const safe = name.replace(/[^\p{L}\p{N}._ -]/gu, '').trim();
|
|
314
|
-
if (!safe)
|
|
315
|
-
throw new Error('The persona name is empty after removing unsafe characters.');
|
|
316
|
-
await mkdir(this.personasDir, { recursive: true });
|
|
317
|
-
await writeFileAtomically(join(this.personasDir, `${safePresetName(safe)}.md`), content);
|
|
318
|
-
return { name: safe, content, updatedAt: new Date().toISOString() };
|
|
319
|
-
}
|
|
320
|
-
async deletePersona(name) {
|
|
321
|
-
await removeFile(await namedFile(this.personasDir, name));
|
|
322
|
-
}
|
|
323
232
|
// --- sessions -------------------------------------------------------------------------
|
|
324
233
|
/**
|
|
325
234
|
* Every session, newest first — by when it was made, not by what it is called.
|
|
@@ -682,6 +591,8 @@ export class SessionStore {
|
|
|
682
591
|
vcs: t.vcs,
|
|
683
592
|
plan: t.plan,
|
|
684
593
|
accepted: t.accepted,
|
|
594
|
+
// Two chats: the lead's rounds and subtasks of this attempt (the next one counts its own from nothing).
|
|
595
|
+
lead: t.lead,
|
|
685
596
|
},
|
|
686
597
|
];
|
|
687
598
|
// An edit is applied only after the old attempt has been put beyond its reach.
|
|
@@ -716,6 +627,7 @@ export class SessionStore {
|
|
|
716
627
|
t.handoff = undefined;
|
|
717
628
|
t.plan = undefined;
|
|
718
629
|
t.accepted = undefined;
|
|
630
|
+
t.lead = undefined;
|
|
719
631
|
t.scopeReverted = undefined;
|
|
720
632
|
t.treeChanged = undefined;
|
|
721
633
|
t.inputsRestored = undefined;
|
|
@@ -897,25 +809,11 @@ async function replaceFile(path, content) {
|
|
|
897
809
|
}
|
|
898
810
|
}
|
|
899
811
|
}
|
|
900
|
-
/**
|
|
901
|
-
* The file a preset or persona of this name is kept in, for removing it.
|
|
902
|
-
*
|
|
903
|
-
* A name `safePresetName` accepts, or one that is already a file in the folder. The save did not
|
|
904
|
-
* always apply that rule, so a preset called ".env" or "a..b" may be on disk from before; without
|
|
905
|
-
* the second way it is listed and can never be deleted. A name matched against the folder's own
|
|
906
|
-
* listing is a file name, which cannot hold a separator, so it cannot reach outside the folder.
|
|
907
|
-
*/
|
|
908
|
-
async function namedFile(dir, name) {
|
|
909
|
-
const onDisk = await readdir(dir).catch(() => []);
|
|
910
|
-
if (onDisk.includes(`${name}.md`))
|
|
911
|
-
return join(dir, `${name}.md`);
|
|
912
|
-
return join(dir, `${safePresetName(name)}.md`);
|
|
913
|
-
}
|
|
914
812
|
/**
|
|
915
813
|
* A session id as it may appear in a file name, or an error.
|
|
916
814
|
*
|
|
917
|
-
* Ids
|
|
918
|
-
* /presets/:name` joined them straight into a path, and Express decodes `%5C` and `%2F`, so
|
|
815
|
+
* Ids arrive from URL parameters. Found on 2026-09-27: `DELETE /sessions/:id` and `DELETE
|
|
816
|
+
* /presets/:name` (the presets went on 2026-10-20) joined them straight into a path, and Express decodes `%5C` and `%2F`, so
|
|
919
817
|
* `..\..\<anything>` reached a `.json` or `.md` file anywhere the process could write. The ids this
|
|
920
818
|
* store makes are letters, digits, `-`, `_` and `.` (not leading); anything else is not one of them.
|
|
921
819
|
*/
|
|
@@ -925,10 +823,3 @@ export function safeName(value) {
|
|
|
925
823
|
}
|
|
926
824
|
return value;
|
|
927
825
|
}
|
|
928
|
-
/** A preset name as `savePreset` allows it — letters in any script, digits, space, `.`, `_`, `-` — never a path. */
|
|
929
|
-
export function safePresetName(value) {
|
|
930
|
-
if (!/^[\p{L}\p{N}_ -][\p{L}\p{N}._ -]{0,199}$/u.test(value) || value.includes('..')) {
|
|
931
|
-
throw new Error(`Not a valid preset name: ${JSON.stringify(value).slice(0, 80)}`);
|
|
932
|
-
}
|
|
933
|
-
return value;
|
|
934
|
-
}
|