copilot-operator 0.1.13 → 0.1.16

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.
Files changed (78) hide show
  1. package/README.md +9 -14
  2. package/dist/src/api/operator.controller.js +42 -42
  3. package/dist/src/api/operator.service.js +743 -367
  4. package/dist/src/api/saveToDesktop.js +1 -1
  5. package/dist/src/api/security.js +40 -10
  6. package/dist/src/api/server.js +75 -12
  7. package/dist/src/api/settings.js +156 -15
  8. package/dist/src/cli.js +108 -97
  9. package/dist/src/config/handWritten.js +36 -0
  10. package/dist/src/config/layout.js +13 -4
  11. package/dist/src/config/lockedPolicy.js +56 -22
  12. package/dist/src/config/schema.js +13 -84
  13. package/dist/src/context/desktopDir.js +44 -0
  14. package/dist/src/exec/authorizer.js +9 -1
  15. package/dist/src/exec/checks.js +240 -23
  16. package/dist/src/exec/dangerous.js +29 -5
  17. package/dist/src/exec/network.js +105 -28
  18. package/dist/src/exec/redaction.js +52 -9
  19. package/dist/src/exec/reportFile.js +4 -5
  20. package/dist/src/exec/runner.js +146 -13
  21. package/dist/src/exec/shells.js +41 -6
  22. package/dist/src/exec/workDir.js +4 -4
  23. package/dist/src/orchestrator/derivedChecks.js +1 -0
  24. package/dist/src/orchestrator/review.js +25 -3
  25. package/dist/src/orchestrator/taskRunner.js +476 -163
  26. package/dist/src/plan/brief.js +37 -44
  27. package/dist/src/plan/importPlan.js +15 -7
  28. package/dist/src/plan/schema.js +64 -29
  29. package/dist/src/plan/script.js +0 -15
  30. package/dist/src/plan/systemGuide.js +33 -177
  31. package/dist/src/protocol/parser.js +5 -1
  32. package/dist/src/session/debugExport.js +1 -1
  33. package/dist/src/session/exportRecord.js +1 -1
  34. package/dist/src/session/exports.js +49 -9
  35. package/dist/src/session/store.js +215 -80
  36. package/dist/src/transport/copilotTransport.js +39 -1
  37. package/dist/src/vcs/scope.js +29 -6
  38. package/dist/src/vcs/taskVcs.js +78 -10
  39. package/dist/web/404.html +2 -2
  40. package/dist/web/_next/static/chunks/36-94660f1cde2da529.js +1 -0
  41. package/dist/web/_next/static/chunks/549-7fd4fe96682299f5.js +1 -0
  42. package/dist/web/_next/static/chunks/867-631dc4314840fed6.js +1 -0
  43. package/dist/web/_next/static/chunks/app/defaults/page-fd819bbfa7f33982.js +1 -0
  44. package/dist/web/_next/static/chunks/app/sessions/view/page-886f5fc99e146408.js +1 -0
  45. package/dist/web/_next/static/css/{a0642fdb8adf9edb.css → e2a2c9eb3c226313.css} +1 -1
  46. package/dist/web/appearance.html +2 -2
  47. package/dist/web/appearance.txt +12 -12
  48. package/dist/web/defaults.html +2 -2
  49. package/dist/web/defaults.txt +12 -12
  50. package/dist/web/history.html +2 -2
  51. package/dist/web/history.txt +12 -12
  52. package/dist/web/import.html +2 -2
  53. package/dist/web/import.txt +12 -12
  54. package/dist/web/index.html +2 -2
  55. package/dist/web/index.txt +12 -12
  56. package/dist/web/level1.html +2 -2
  57. package/dist/web/level1.txt +12 -12
  58. package/dist/web/presets.html +2 -2
  59. package/dist/web/presets.txt +12 -12
  60. package/dist/web/sessions/view.html +2 -2
  61. package/dist/web/sessions/view.txt +12 -12
  62. package/dist/web/system.html +2 -2
  63. package/dist/web/system.txt +12 -12
  64. package/package.json +19 -10
  65. package/prompts/level1.md +2 -1
  66. package/prompts/organisation.bg.md +0 -1
  67. package/prompts/organisation.en.md +0 -1
  68. package/dist/src/context/contextFiles.js +0 -295
  69. package/dist/src/context/desktopMirror.js +0 -173
  70. package/dist/src/context/projectMirror.js +0 -432
  71. package/dist/web/_next/static/chunks/295-04151ded0741d18d.js +0 -1
  72. package/dist/web/_next/static/chunks/36-c3dd06c6a459c114.js +0 -1
  73. package/dist/web/_next/static/chunks/549-a5a59a94f92bb3eb.js +0 -1
  74. package/dist/web/_next/static/chunks/867-84c19f047972ffc3.js +0 -1
  75. package/dist/web/_next/static/chunks/app/defaults/page-5f180a88398be4c9.js +0 -1
  76. package/dist/web/_next/static/chunks/app/sessions/view/page-34d7988849f9aa76.js +0 -1
  77. /package/dist/web/_next/static/{NosxirjkOgV-Boyq8dGPl → GhdY7nVcYi-WV3j7saVPK}/_buildManifest.js +0 -0
  78. /package/dist/web/_next/static/{NosxirjkOgV-Boyq8dGPl → GhdY7nVcYi-WV3j7saVPK}/_ssgManifest.js +0 -0
@@ -1,432 +0,0 @@
1
- /**
2
- * Mirrors selected parts of a project into one flat folder on the Desktop.
3
- *
4
- * Why flat, and why renamed. The folder is meant to sit inside a OneDrive-backed Desktop so
5
- * the copies reach the cloud with no user action, and the chat's upload input rejects source
6
- * extensions outright. So the directory structure cannot be kept as folders and the
7
- * extensions cannot be kept as-is. Both problems are solved by encoding the path into the
8
- * file name and giving everything a `.txt` tail:
9
- *
10
- * src/test/example-test.spec.ts -> src--test--example-test.spec.ts.txt
11
- *
12
- * The convention is taken from the user's own Context Picker
13
- * (https://github.com/ivan-markov-666/context-picker, MIT), specifically
14
- * `copySelectionToDir` in `src/scan-core.ts`, so that a folder produced here and a folder
15
- * produced by the extension are interchangeable:
16
- *
17
- * - relative path, forward slashes, joined with the separator
18
- * - name collisions get `<sep><n>` appended, starting at 2, compared case-insensitively
19
- * - `.txt` appended last, after the collision suffix
20
- * - sync mode writes only files whose bytes differ and deletes what is no longer selected
21
- *
22
- * The difference from the extension is the input. There the user ticks individual files in
23
- * an editor UI. Here the user names the project root and the directories to include, and
24
- * selecting a directory takes everything beneath it.
25
- */
26
- import { readFile, writeFile, readdir, stat, mkdir, rm } from 'node:fs/promises';
27
- import { join, relative, resolve, sep as osSep, basename, extname } from 'node:path';
28
- import ignore from 'ignore';
29
- /**
30
- * Directories that are never useful as chat context, pruned at any depth even when there is
31
- * no `.gitignore`. Same list as Context Picker's `DEFAULT_IGNORE`, plus the obvious
32
- * JavaScript and Python build output.
33
- */
34
- export const DEFAULT_IGNORE_DIRS = [
35
- 'node_modules',
36
- '.git',
37
- 'bin',
38
- 'obj',
39
- '.vs',
40
- '.idea',
41
- 'dist',
42
- 'build',
43
- 'out',
44
- 'coverage',
45
- '__pycache__',
46
- '.venv',
47
- 'venv',
48
- 'target',
49
- ];
50
- export const DEFAULT_SEPARATOR = '--';
51
- export const DEFAULT_MAX_FILE_BYTES = 2 * 1024 * 1024;
52
- /** A selection that cannot be copied as asked. Thrown before the target folder is touched. */
53
- export class MirrorSelectionError extends Error {
54
- constructor(message) {
55
- super(message);
56
- this.name = 'MirrorSelectionError';
57
- }
58
- }
59
- /**
60
- * Each include directory as a path under `rootDir`, looked for in `alsoUnder` when it is not there.
61
- *
62
- * `found` are the paths to copy; `missing` are the ones that are nowhere, with why. A directory found
63
- * in a folder outside `rootDir` is missing too: its files could not be named as the project's.
64
- */
65
- export async function resolveIncludeDirs(rootDir, includeDirs, alsoUnder = []) {
66
- const root = resolve(rootDir);
67
- const found = [];
68
- const moved = [];
69
- const missing = [];
70
- const isDir = async (p) => !!(await stat(p).catch(() => null))?.isDirectory();
71
- for (const dir of includeDirs) {
72
- const rel = normalizeDirPath(dir);
73
- if (await isDir(join(root, rel))) {
74
- found.push(rel);
75
- continue;
76
- }
77
- let reason = `not a folder under the project root ${root}`;
78
- let used = null;
79
- for (const other of alsoUnder.filter((o) => o.trim() !== '')) {
80
- const abs = resolve(other, rel);
81
- if (!(await isDir(abs)))
82
- continue;
83
- const underRoot = relative(root, abs);
84
- if (underRoot.startsWith('..') || resolve(root, underRoot) !== abs) {
85
- reason = `found under ${resolve(other)}, which is not inside the project root ${root}: make the root that folder`;
86
- continue;
87
- }
88
- used = underRoot.split(osSep).join('/') || '.';
89
- break;
90
- }
91
- if (used) {
92
- found.push(used);
93
- moved.push({ asked: rel, used });
94
- }
95
- else {
96
- missing.push({ dir: rel, reason });
97
- }
98
- }
99
- return { found, moved, missing };
100
- }
101
- /** `.\Src\Foo\` and `src/foo` are the same directory. This is the form both lists compare in. */
102
- export function normalizeDirPath(dir) {
103
- const cleaned = dir
104
- .trim()
105
- .replace(/\\/g, '/')
106
- .replace(/^\.\//, '')
107
- .replace(/\/+$/, '');
108
- return cleaned === '' ? '.' : cleaned;
109
- }
110
- function isUnder(child, parent) {
111
- if (parent === '.')
112
- return child !== '.';
113
- return child.toLowerCase().startsWith(`${parent.toLowerCase()}/`);
114
- }
115
- /** Every contradiction between the two lists, so a UI can refuse to save and say why. */
116
- export function findSelectionConflicts(includeDirs, excludeDirs) {
117
- const includes = includeDirs.map(normalizeDirPath).filter(Boolean);
118
- const excludes = excludeDirs.map(normalizeDirPath).filter(Boolean);
119
- const out = [];
120
- for (const inc of includes) {
121
- for (const exc of excludes) {
122
- if (inc.toLowerCase() === exc.toLowerCase()) {
123
- out.push({ include: inc, exclude: exc, kind: 'same' });
124
- }
125
- else if (isUnder(inc, exc)) {
126
- out.push({ include: inc, exclude: exc, kind: 'excluded-parent' });
127
- }
128
- }
129
- }
130
- return out;
131
- }
132
- /** One sentence per conflict, for a message box or a thrown error. */
133
- export function describeConflicts(conflicts) {
134
- return conflicts
135
- .map((c) => c.kind === 'same'
136
- ? `"${c.include}" is in both the include and the exclude list.`
137
- : `"${c.exclude}" is excluded but "${c.include}" is included, and lies under it.`)
138
- .join(' ');
139
- }
140
- /** Files the program owns in the target folder and must never delete as "stale". */
141
- const RESERVED_TARGET_NAMES = new Set(['.cop-manifest.json']);
142
- /**
143
- * Files that hold secrets by convention, never copied to the Desktop unless the operator says so.
144
- * `.env` was the only one until 2026-09-27; a key file, an `.npmrc` with a registry token or a
145
- * `credentials.json` are secrets just the same, and the Desktop is on its way to OneDrive.
146
- */
147
- function isEnvFile(path) {
148
- const name = basename(path).toLowerCase();
149
- if (name === '.env' || name.startsWith('.env.'))
150
- return true;
151
- if (/\.(pem|pfx|p12|key|jks|keystore|kdbx|ppk)$/.test(name))
152
- return true;
153
- if (/^id_(rsa|dsa|ecdsa|ed25519)(\.pub)?$/.test(name))
154
- return true;
155
- return ['.npmrc', '.netrc', '.pypirc', 'credentials.json', 'secrets.json', 'service-account.json', '.htpasswd'].includes(name)
156
- || /(^|\.)secrets?\.(json|ya?ml|toml|xml)$/.test(name);
157
- }
158
- /**
159
- * Flattens a relative path into a single file name.
160
- *
161
- * `used` carries the names already taken, lower-cased, and is mutated. Collisions are
162
- * possible because two different paths can flatten to the same string once separators are
163
- * substituted, so the suffix is not optional.
164
- */
165
- export function flattenName(relPath, used, separator = DEFAULT_SEPARATOR, txtMode = 'append') {
166
- const normalized = relPath.split(/[\\/]/).join(separator);
167
- let candidate = normalized;
168
- let i = 2;
169
- while (used.has(candidate.toLowerCase())) {
170
- candidate = `${normalized}${separator}${i}`;
171
- i += 1;
172
- }
173
- used.add(candidate.toLowerCase());
174
- switch (txtMode) {
175
- case 'append':
176
- return `${candidate}.txt`;
177
- case 'replace': {
178
- const ext = extname(candidate);
179
- return ext ? `${candidate.slice(0, -ext.length)}.txt` : `${candidate}.txt`;
180
- }
181
- case 'none':
182
- return candidate;
183
- }
184
- }
185
- async function loadGitignore(rootDir, respect) {
186
- if (!respect)
187
- return null;
188
- try {
189
- const content = await readFile(join(rootDir, '.gitignore'), 'utf8');
190
- return ignore().add(content);
191
- }
192
- catch {
193
- return null;
194
- }
195
- }
196
- /**
197
- * Depth-first walk of one directory, returning file paths relative to `rootDir`.
198
- *
199
- * Two rules about `.env` files are enforced here, and nowhere else:
200
- *
201
- * - `.gitignore` never decides an env file. Almost every project ignores `.env`, so letting
202
- * the gitignore option hide them would make the env option meaningless. Env files are
203
- * always handed to `collectFiles`, which keeps or drops them by the env option alone.
204
- * - When env files are wanted, a directory that only `.gitignore` hides is still descended
205
- * into, but nothing except env files is taken from it. That is how an env file inside an
206
- * ignored folder still reaches the selection without dragging the folder along with it.
207
- *
208
- * `DEFAULT_IGNORE_DIRS` and the user's own exclusions are absolute: they are never descended
209
- * into, env files or not.
210
- */
211
- async function walk(rootDir, dirRel, ig, ignoreDirs, excluded, out, opts) {
212
- const abs = join(rootDir, dirRel);
213
- let entries;
214
- try {
215
- entries = await readdir(abs, { withFileTypes: true });
216
- }
217
- catch {
218
- return;
219
- }
220
- for (const entry of entries) {
221
- const childRel = dirRel === '.' ? entry.name : `${dirRel}/${entry.name}`;
222
- const posixRel = childRel.split(osSep).join('/');
223
- if (entry.isDirectory()) {
224
- if (ignoreDirs.has(entry.name.toLowerCase()))
225
- continue;
226
- if (excluded.has(posixRel.toLowerCase()))
227
- continue;
228
- const gitignored = opts.inGitignored === true || (ig?.ignores(`${posixRel}/`) ?? false);
229
- if (gitignored && !opts.includeEnvFiles)
230
- continue;
231
- await walk(rootDir, childRel, ig, ignoreDirs, excluded, out, { ...opts, inGitignored: gitignored });
232
- }
233
- else if (entry.isFile()) {
234
- if (isEnvFile(entry.name)) {
235
- out.push(posixRel);
236
- continue;
237
- }
238
- if (opts.inGitignored)
239
- continue;
240
- if (ig?.ignores(posixRel))
241
- continue;
242
- out.push(posixRel);
243
- }
244
- }
245
- }
246
- /**
247
- * Lists the directories under `rootDir` that are worth offering for selection, so a CLI or
248
- * a UI can present the same kind of choice the extension's checkbox tree does. Pruned by the
249
- * same rules as the mirror itself, so what is listed is what can actually be copied.
250
- */
251
- export async function listSelectableDirs(rootDir, opts = {}) {
252
- const ig = await loadGitignore(resolve(rootDir), opts.respectGitignore ?? true);
253
- const ignoreDirs = new Set([...DEFAULT_IGNORE_DIRS, ...(opts.ignoreDirs ?? [])].map((d) => d.toLowerCase()));
254
- const maxDepth = opts.maxDepth ?? 4;
255
- const found = [];
256
- const recurse = async (dirRel, depth) => {
257
- if (depth > maxDepth)
258
- return;
259
- let entries;
260
- try {
261
- entries = await readdir(join(resolve(rootDir), dirRel), { withFileTypes: true });
262
- }
263
- catch {
264
- return;
265
- }
266
- for (const entry of entries) {
267
- if (!entry.isDirectory())
268
- continue;
269
- if (ignoreDirs.has(entry.name.toLowerCase()))
270
- continue;
271
- const childRel = dirRel === '.' ? entry.name : `${dirRel}/${entry.name}`;
272
- if (ig?.ignores(`${childRel}/`))
273
- continue;
274
- found.push(childRel);
275
- await recurse(childRel, depth + 1);
276
- }
277
- };
278
- await recurse('.', 1);
279
- return found.sort();
280
- }
281
- /**
282
- * Collects the files the configuration selects, as paths relative to `rootDir`, sorted and
283
- * de-duplicated. Exported separately so a caller can preview a selection without writing
284
- * anything.
285
- */
286
- export async function collectFiles(cfg) {
287
- const rootDir = resolve(cfg.rootDir);
288
- if (cfg.includeDirs.length === 0) {
289
- throw new Error('includeDirs is empty: nothing would be copied. Select at least one directory.');
290
- }
291
- const conflicts = findSelectionConflicts(cfg.includeDirs, cfg.excludeDirs ?? []);
292
- if (conflicts.length > 0) {
293
- throw new Error(`The include and exclude lists contradict each other. ${describeConflicts(conflicts)}`);
294
- }
295
- const includeEnvFiles = cfg.includeEnvFiles ?? false;
296
- const ig = await loadGitignore(rootDir, cfg.respectGitignore ?? true);
297
- const ignoreDirs = new Set([...DEFAULT_IGNORE_DIRS, ...(cfg.ignoreDirs ?? [])].map((d) => d.toLowerCase()));
298
- const excluded = new Set((cfg.excludeDirs ?? []).map((d) => normalizeDirPath(d).toLowerCase()));
299
- const collected = new Set();
300
- const skipped = [];
301
- for (const dir of cfg.includeDirs) {
302
- const dirRel = normalizeDirPath(dir);
303
- const abs = join(rootDir, dirRel);
304
- const s = await stat(abs).catch(() => null);
305
- if (!s?.isDirectory()) {
306
- skipped.push({ relPath: dirRel, reason: 'not a directory under the project root' });
307
- continue;
308
- }
309
- const found = [];
310
- await walk(rootDir, dirRel, ig, ignoreDirs, excluded, found, { includeEnvFiles });
311
- for (const f of found)
312
- collected.add(f);
313
- }
314
- const maxBytes = cfg.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
315
- const files = [];
316
- for (const rel of [...collected].sort()) {
317
- if (!includeEnvFiles && isEnvFile(rel)) {
318
- skipped.push({ relPath: rel, reason: 'env file, excluded to protect secrets' });
319
- continue;
320
- }
321
- const s = await stat(join(rootDir, rel)).catch(() => null);
322
- if (!s)
323
- continue;
324
- if (s.size > maxBytes) {
325
- skipped.push({ relPath: rel, reason: `larger than ${Math.round(maxBytes / 1024)} KB` });
326
- continue;
327
- }
328
- files.push(rel);
329
- }
330
- return { files, skipped };
331
- }
332
- /**
333
- * Brings `targetDir` in line with the selection.
334
- *
335
- * Incremental by construction: a file is written only when its bytes differ from what is
336
- * already there, and target files that are no longer part of the selection are deleted.
337
- * Unchanged files are left untouched, which is what keeps OneDrive from re-uploading a whole
338
- * project every time one file is edited.
339
- */
340
- export async function mirrorProject(cfg) {
341
- const rootDir = resolve(cfg.rootDir);
342
- const targetDir = resolve(cfg.targetDir);
343
- const separator = cfg.separator ?? DEFAULT_SEPARATOR;
344
- const txtMode = cfg.txtMode ?? 'append';
345
- /*
346
- * Checked before the target folder is touched.
347
- *
348
- * The folder is brought in line with the selection, which deletes whatever the selection does
349
- * not hold. A directory that could not be found made the selection empty, and every copy the
350
- * chat had been working from was deleted (seen live on 2026-09-30: `rules-engine` not found,
351
- * the whole context folder gone, totalBytes 0). A selection that is wrong is now an error that
352
- * leaves the copies as they were; so is one that finds no file at all.
353
- */
354
- const dirs = await resolveIncludeDirs(rootDir, cfg.includeDirs, cfg.alsoUnder);
355
- if (dirs.missing.length > 0) {
356
- throw new MirrorSelectionError(`The project files could not be copied: ${dirs.missing.map((m) => `"${m.dir}" is ${m.reason}`).join('; ')}. ` +
357
- `Nothing was copied, and the copies already in ${targetDir} were left as they are.`);
358
- }
359
- const { files, skipped } = await collectFiles({ ...cfg, includeDirs: dirs.found });
360
- if (files.length === 0) {
361
- throw new MirrorSelectionError(`The selection (${cfg.includeDirs.join(', ')}) holds no file that can be copied` +
362
- `${skipped.length > 0 ? ` (${skipped.length} skipped, for example ${skipped[0].relPath}: ${skipped[0].reason})` : ''}. ` +
363
- `Nothing was copied, and the copies already in ${targetDir} were left as they are.`);
364
- }
365
- await mkdir(targetDir, { recursive: true });
366
- const used = new Set();
367
- const desired = new Set();
368
- const mapping = {};
369
- const added = [];
370
- const updated = [];
371
- const unchanged = [];
372
- let totalBytes = 0;
373
- for (const rel of files) {
374
- const targetName = flattenName(cfg.namePrefix ? `${cfg.namePrefix}/${rel}` : rel, used, separator, txtMode);
375
- desired.add(targetName);
376
- mapping[rel] = targetName;
377
- const source = join(rootDir, rel);
378
- const dest = join(targetDir, targetName);
379
- const bytes = await readFile(source);
380
- totalBytes += bytes.length;
381
- const existing = await readFile(dest).catch(() => null);
382
- if (existing === null) {
383
- await writeFile(dest, bytes);
384
- added.push(targetName);
385
- }
386
- else if (existing.equals(bytes)) {
387
- unchanged.push(targetName);
388
- }
389
- else {
390
- await writeFile(dest, bytes);
391
- updated.push(targetName);
392
- }
393
- }
394
- const deleted = [];
395
- for (const entry of await readdir(targetDir).catch(() => [])) {
396
- if (desired.has(entry) || RESERVED_TARGET_NAMES.has(entry))
397
- continue;
398
- await rm(join(targetDir, entry), { recursive: true, force: true });
399
- deleted.push(entry);
400
- }
401
- return {
402
- added: added.sort(),
403
- updated: updated.sort(),
404
- deleted: deleted.sort(),
405
- unchanged: unchanged.sort(),
406
- skipped,
407
- mapping,
408
- totalBytes,
409
- };
410
- }
411
- /** One line for the console and the run log. */
412
- export function describeMirror(r) {
413
- const bits = [
414
- `${r.added.length} added`,
415
- `${r.updated.length} updated`,
416
- `${r.deleted.length} deleted`,
417
- `${r.unchanged.length} unchanged`,
418
- ];
419
- if (r.skipped.length)
420
- bits.push(`${r.skipped.length} skipped`);
421
- return bits.join(', ');
422
- }
423
- /** Recovers the original relative path from a mirrored file name. */
424
- export function unflattenName(targetName, separator = DEFAULT_SEPARATOR, txtMode = 'append') {
425
- let name = targetName;
426
- if (txtMode === 'append' && name.toLowerCase().endsWith('.txt')) {
427
- name = name.slice(0, -4);
428
- }
429
- return name.split(separator).join('/');
430
- }
431
- /** `relative()` re-exported for callers building configs from absolute paths. */
432
- export { relative as relativePath };
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[295],{2244:(e,n,t)=>{t.d(n,{k:()=>o});var l=t(3365),s=t(1521),i=t(5549),a=t(867);function r(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function c(e,n){return"."===n||""===n||e===n||e.startsWith("".concat(n,"/"))}function d(e,n,t){return t.includes(e)?"out":t.some(n=>n!==e&&c(e,n))?"out-inherited":n.includes(e)?"in":n.some(n=>n!==e&&c(e,n))?"inherited":"none"}function o(e){let{rootDir:n,respectGitignore:t,includeEnvFiles:o,include:u,exclude:h,onChange:m}=e,{t:p}=(0,a.kj)(),[x,j]=(0,s.useState)(null),[g,v]=(0,s.useState)(""),[f,y]=(0,s.useState)(new Set),[w,b]=(0,s.useState)(""),N=async()=>{if(n.trim()){v("");try{let e=await i.FH.dirs(n,t);j(e),b("".concat(n,"|").concat(t)),y(new Set(e.filter(e=>!e.includes("/"))))}catch(e){v(e.message)}}};(0,s.useEffect)(()=>{j(null),b("")},[n,t]);let k=(0,s.useMemo)(()=>(function(e){let n=[],t=new Map;for(let s of[...e].sort()){var l;let e={path:s,name:null!=(l=s.split("/").pop())?l:s,children:[]};t.set(s,e);let i=s.includes("/")?t.get(s.slice(0,s.lastIndexOf("/"))):void 0;(i?i.children:n).push(e)}return n})(null!=x?x:[]),[x]),L=u.map(r).filter(Boolean),C=h.map(r).filter(Boolean),F=e=>(0,l.jsx)("ul",{className:"dir-tree",children:e.map(e=>{let n=d(e.path,L,C),t=f.has(e.path),s=function(e,n,t){let l=n=>n.filter(n=>n!==e&&c(n,e)).length;return{included:l(n),excluded:l(t)}}(e.path,L,C),i=!t&&e.children.length>0&&(s.included>0||s.excluded>0);return(0,l.jsxs)("li",{className:"dir ".concat(n),children:[(0,l.jsxs)("div",{className:"dir-row",children:[e.children.length>0?(0,l.jsx)("button",{type:"button",className:"dir-flip",onClick:()=>{let n;return n=e.path,y(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t})},"aria-label":t?p("tree.fold"):p("tree.unfold"),"aria-expanded":t,children:t?"▾":"▸"}):(0,l.jsx)("span",{className:"dir-flip","aria-hidden":"true"}),(0,l.jsxs)("button",{type:"button",className:"dir-name",onClick:()=>(e=>{if("in"===d(e,L,C))return void m(L.filter(n=>n!==e),C);m([...L.filter(n=>!c(n,e)),e],C.filter(n=>!c(n,e)))})(e.path),title:"in"===n?p("tree.stateIn"):"inherited"===n?p("tree.stateInherited"):"out"===n?p("tree.stateOut"):"out-inherited"===n?p("tree.stateOutInherited"):p("tree.stateNone"),"aria-pressed":"in"===n||"inherited"===n,children:[(0,l.jsx)("span",{className:"dir-mark","aria-hidden":"true",children:"in"===n?"✓":"inherited"===n?"\xb7":"out"===n||"out-inherited"===n?"\xd7":""}),e.name]}),(0,l.jsx)("button",{type:"button",className:"dir-out".concat("out"===n?" on":""),onClick:()=>(e=>{if(C.includes(e))return void m(L,C.filter(n=>n!==e));m(L.filter(n=>n!==e&&!c(n,e)),[...C.filter(n=>!c(n,e)),e])})(e.path),title:"out"===n?p("tree.unexclude"):p("tree.exclude"),"aria-label":"".concat("out"===n?p("tree.unexclude"):p("tree.exclude"),": ").concat(e.path),children:"−"}),i&&(0,l.jsx)("span",{className:"chip inside".concat(s.excluded>0?" out":""),title:p("tree.insideWhy"),children:s.excluded>0&&s.included>0?p("tree.insideBoth",{i:s.included,e:s.excluded}):s.excluded>0?p("tree.insideOut",{n:s.excluded}):p("tree.insideIn",{n:s.included})})]}),t&&e.children.length>0&&F(e.children)]},e.path)})}),S=w!=="".concat(n,"|").concat(t);return(0,l.jsxs)("div",{className:"dir-tree-box",children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{type:"button",onClick:()=>void N(),disabled:!n.trim(),children:null===x||S?p("tree.load"):p("tree.reload")}),(0,l.jsx)("span",{className:"muted small",children:p("tree.hint")})]}),g&&(0,l.jsx)("div",{className:"err small",children:g}),(0,l.jsxs)("p",{className:"muted small",style:{marginTop:6},children:[p("tree.alsoOut")," ",[t?p("tree.alsoGitignore"):null,!1===o?p("tree.alsoEnv"):null,p("tree.alsoAlways")].filter(Boolean).join(" \xb7 ")]}),null!==x&&!S&&(0===x.length?(0,l.jsx)("p",{className:"muted small",children:p("mirror.noDirs")}):F(k))]})}},2285:(e,n,t)=>{t.d(n,{b:()=>r});var l=t(3365),s=t(1521),i=t(5549),a=t(867);function r(e){var n,t;let{dir:r}=e,{t:c}=(0,a.kj)(),d=(0,a.W3)(),[o,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(""),[p,x]=(0,s.useState)(""),j=async()=>{m("");try{u(await i.FH.syncPlan(r))}catch(e){m(e.message)}},g=async(e,n)=>{try{await navigator.clipboard.writeText(n),x(e),window.setTimeout(()=>x(""),2500)}catch(e){m(c("plan.copyFailed"))}},v=e=>(0,l.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,l.jsx)("li",{children:(0,l.jsx)("code",{children:e})},e)),e.length>30&&(0,l.jsx)("li",{className:"muted",children:c("sync.more",{n:e.length-30})})]});return(0,l.jsxs)("div",{className:"sync-command small",style:{marginTop:8},children:[(0,l.jsx)("button",{type:"button",onClick:()=>void j(),children:c("sync.show")}),h&&(0,l.jsx)("p",{className:"err",children:h}),o&&!o.ok&&(0,l.jsx)("p",{className:"err",children:o.problem}),(null==o?void 0:o.ok)&&(0,l.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,l.jsxs)("p",{children:[c("sync.what",{branch:null!=(n=o.branch)?n:"",target:null!=(t=o.target)?t:""})," ",(0,l.jsx)("span",{className:"muted",children:o.lastFetched?c("sync.fetchedAt",{when:d(o.lastFetched)}):c("sync.neverFetched")})]}),o.willLose.commits.length+o.willLose.changed.length+o.willLose.untracked.length===0?(0,l.jsx)("p",{children:c("sync.nothingLost")}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("strong",{children:c("sync.loses")}),o.willLose.commits.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{children:c("sync.commits",{n:o.willLose.commits.length})}),v(o.willLose.commits)]}),o.willLose.changed.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{children:c("sync.changed",{n:o.willLose.changed.length})}),v(o.willLose.changed)]}),o.willLose.untracked.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{children:c("sync.untracked",{n:o.willLose.untracked.length})}),v(o.willLose.untracked)]})]}),(0,l.jsx)("p",{className:"muted",children:c("sync.keeps")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{type:"button",onClick:()=>void g("preview",o.preview),children:c("sync.copyPreview")}),"preview"===p&&(0,l.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,l.jsx)("pre",{className:"sync-cmd",children:o.preview}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{type:"button",className:"danger",onClick:()=>void g("command",o.command),children:c("sync.copyCommand")}),"command"===p&&(0,l.jsx)("span",{className:"badge done",children:c("plan.copied")})]}),(0,l.jsx)("pre",{className:"sync-cmd",children:o.command}),(0,l.jsx)("p",{className:"muted",children:c("sync.howToRun")})]})]})}},4784:(e,n,t)=>{t.d(n,{Y:()=>r});var l=t(3365),s=t(1521),i=t(5549),a=t(867);function r(e){var n,t;let{id:r,chosen:c,onChange:d,none:o,catalogue:u,disabled:h=!1,style:m}=e,{t:p}=(0,a.kj)(),x=function(e){let[n,t]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(void 0!==e)return;let n=!0;return i.FH.models().then(e=>{n&&t(e)}).catch(()=>void 0),()=>{n=!1}},[e]),void 0!==e?e:n}(u),j=null!=(n=null==x?void 0:x.options)?n:[],g=j.some(e=>e.name===c),v=j.filter(e=>!e.group),f=new Map;for(let e of j)e.group&&f.set(e.group,[...null!=(t=f.get(e.group))?t:[],e]);return(0,l.jsxs)("select",{id:r,value:c,onChange:e=>d(e.target.value),disabled:h,style:{width:"auto",minWidth:280,...m},children:[(0,l.jsx)("option",{value:"",children:o}),c&&!g&&(0,l.jsx)("option",{value:c,children:p("model.notInList",{name:c})}),v.map(e=>(0,l.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name)),[...f.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(p("model.unavailable")):""]},e.name))},n)})]})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[36],{1035:(e,t,n)=>{n.d(t,{DialogHost:()=>d,Z:()=>c});var s=n(3365),l=n(1521),a=n(867),r=n(4969);let i=null,o=[];function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var s;return s={kind:"confirm",message:e,...t,resolve:n},void(i?i(s):o.push(s))})}function d(e){var t,n;let{children:c}=e,{t:d}=(0,a.kj)(),[u,h]=(0,l.useState)([]),m=(0,l.useRef)(null),f=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(i=e=>h(t=>[...t,e]),o.length>0){let e=o.splice(0,o.length);h(t=>[...t,...e])}return()=>{i=null}},[]);let p=u[0],x=(0,l.useCallback)(e=>{p&&(p.resolve(e),h(e=>e.slice(1)))},[p]);return(0,r.V)(f,!!p,m),(0,l.useEffect)(()=>{if(!p)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),x(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,x]),(0,s.jsxs)(s.Fragment,{children:[c,p&&(0,s.jsx)("div",{className:"modal-backdrop",onClick:()=>x(!1),role:"presentation",children:(0,s.jsxs)("div",{ref:f,className:"modal".concat(p.danger?" danger":""),role:"confirm"===p.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{id:"modal-title",children:null!=(t=p.title)?t:d("confirm"===p.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,s.jsx)("div",{id:"modal-body",className:"modal-body",children:p.message}),(0,s.jsxs)("div",{className:"row modal-actions",children:["confirm"===p.kind&&(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>x(!1),children:d("dialog.cancel")}),(0,s.jsx)("button",{ref:m,type:"button",className:p.danger?"danger":"primary",onClick:()=>x(!0),children:null!=(n=p.okLabel)?n:d("dialog.ok")})]})]})})]})}},1366:(e,t,n)=>{n.d(t,{w:()=>i,y:()=>r});var s=n(3365),l=n(1521),a=n(867);function r(e){let{readOnly:t,scope:n,onReadOnly:r,onScope:i}=e,{t:o}=(0,a.kj)(),c=(0,l.useId)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"option",style:{marginTop:10},children:[(0,s.jsxs)("label",{children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:e=>r(e.target.checked)}),(0,s.jsx)("span",{children:o("task.readOnlyEdit")})]}),(0,s.jsx)("p",{className:"why",children:o("task.readOnlyEditWhy")})]}),(0,s.jsx)("label",{htmlFor:"".concat(c,"-scope"),children:o("task.scopeEdit")}),(0,s.jsx)("textarea",{id:"".concat(c,"-scope"),value:n,onChange:e=>i(e.target.value),placeholder:"tests/e2e/\nsrc/**/*.ts",style:{minHeight:60},disabled:t}),(0,s.jsx)("p",{className:"why",children:o("task.scopeEditWhy")})]})}function i(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}},1910:(e,t,n)=>{n.d(t,{H:()=>o,u:()=>i});var s=n(3365),l=n(1521),a=n(867),r=n(5549);function i(e){let{label:t,save:n}=e,{t:r}=(0,a.kj)(),[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),m=async()=>{o(!0),d("");try{var e;let t=await n();h(!1),d(t.revealed?r("save.done",{path:t.path}):r("save.savedOnly",{path:t.path,note:null!=(e=t.note)?e:""}))}catch(e){h(!0),d(r("save.failed",{problem:e.message}))}finally{o(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",disabled:i,title:r("save.why"),onClick:()=>void m(),children:i?r("save.saving"):t}),c&&(0,s.jsx)("span",{className:u?"err small":"muted small",children:c})]})}function o(e){let{sessionId:t,taskId:n,attempt:i}=e,{t:o}=(0,a.kj)(),[c,d]=(0,l.useState)(!1),[u,h]=(0,l.useState)(""),[m,f]=(0,l.useState)(!1),p=async()=>{d(!0),h("");try{let e=await r.FH.downloadBundle([{sessionId:t,taskId:n,attempt:i}]);f(!1),h(o("reg.bundleSaved",{name:e}))}catch(e){f(!0),h(o("save.failed",{problem:e.message}))}finally{d(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",disabled:c,title:o("save.attemptRecordWhy"),onClick:()=>void p(),children:c?o("save.saving"):o("save.attemptRecord")}),u&&(0,s.jsx)("span",{className:m?"err small":"muted small",children:u})]})}},2876:(e,t,n)=>{n.d(t,{P:()=>d});var s=n(3365),l=n(1521),a=n(5549),r=n(867);function i(e,t){let[n,s]=(0,l.useState)(null),a=(0,l.useRef)(!0),[r,i]=(0,l.useState)(!0),o=(0,l.useCallback)(e=>s(e),[]);return(0,l.useLayoutEffect)(()=>{if(!n)return;let e=()=>{let e=n.scrollHeight-n.scrollTop-n.clientHeight<=24;a.current=e,i(e)};return n.addEventListener("scroll",e,{passive:!0}),()=>n.removeEventListener("scroll",e)},[n]),(0,l.useLayoutEffect)(()=>{n&&e&&a.current&&(n.scrollTop=n.scrollHeight)},[n,e,t]),{ref:o,following:r,follow:(0,l.useCallback)(()=>{a.current=!0,i(!0),n&&(n.scrollTop=n.scrollHeight)},[n])}}var o=n(5132);function c(e){let{text:t,follow:n}=e,{ref:l}=i(n,t);return(0,s.jsx)("pre",{ref:l,className:"story-out".concat(n?" terminal":""),children:t})}function d(e){let{sessionId:t,taskId:n,runId:d,live:h}=e,{t:m}=(0,r.kj)(),[f,p]=(0,l.useState)(null),[x,g]=(0,l.useState)(""),[v,y]=(0,l.useState)(!0),[j,k]=(0,l.useState)(!0),[b,N]=(0,l.useState)(new Set),[w,S]=(0,l.useState)(new Set),[C,E]=(0,l.useState)(new Set),I=!!(null==f?void 0:f.live),F=(0,l.useRef)(0);F.current+=1;let D=i(I,F.current),M=(0,l.useRef)(null),L=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!f)return;let e=[],t=(n,s)=>n.forEach((n,l)=>{let a="".concat(s).concat(l);"review"===n.kind?t(n.entries,"".concat(a,"-")):"step"!==n.kind||n.outcome||e.push(a)});t(f.entries,"e"),e.some(e=>!w.has(e))&&S(t=>new Set([...t,...e])),f.live&&!L.current&&M.current&&(L.current=!0,M.current.scrollIntoView({block:"nearest",behavior:"smooth"}))},[f,w]),(0,l.useEffect)(()=>{let e,s=!0,l=async()=>{try{let r=await a.FH.taskStory(t,n,d);if(!s)return;p(r),g(""),(r.live||h)&&(e=setTimeout(l,2e3))}catch(t){if(!s)return;g(t.message),h&&(e=setTimeout(l,2e3))}};return l(),()=>{s=!1,e&&clearTimeout(e)}},[t,n,d,h]),x&&!f)return(0,s.jsx)("div",{className:"err small",children:x});if(!f)return(0,s.jsx)("div",{className:"muted small",children:m("story.loading")});let T=e=>b.has(e)||w.has(e)&&!C.has(e),H=e=>{let t=T(e);N(n=>{let s=new Set(n);return t?s.delete(e):s.add(e),s}),E(n=>{let s=new Set(n);return t?s.add(e):s.delete(e),s})},R=(e,t)=>{if(!("review"===e.kind?v||j:"step"===e.kind?j:v))return null;if("review"===e.kind)return(0,s.jsxs)("li",{className:"story-review",children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("span",{className:"chip",children:m("story.review",{n:e.round})})]}),(0,s.jsx)("ol",{className:"story",children:e.entries.map((e,n)=>R(e,"".concat(t,"-").concat(n)))})]},t);if("step"===e.kind){let n=T(t),l=!e.outcome&&f.live;return(0,s.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("span",{className:"chip",children:m("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,s.jsxs)("span",{className:"badge ".concat(e.failed?"failed":"done"),children:[e.outcome,void 0!==e.exitCode?" \xb7 exit ".concat(e.exitCode):"",void 0!==e.durationMs?" \xb7 ".concat((0,a.c5)(e.durationMs)):""]}),!e.outcome&&(0,s.jsx)("span",{className:"badge running",children:m("story.running")}),e.failed&&(0,s.jsx)("span",{className:"badge failed",children:m("story.failedHere")})]}),(0,s.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>H(t),children:n?m("story.hideOutput"):m("story.showOutput",{n:e.output.length})}),n&&(0,s.jsx)(c,{text:e.output,follow:l})]})]},t)}let n=b.has(t),l="sent"===e.kind?m("story.bot"):m("story.chat"),r="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,s.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(r?" failed":""),children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("strong",{children:l}),(0,s.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,s.jsx)("span",{className:"badge ".concat(r?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,s.jsx)("p",{className:"story-notes",children:e.notes}),(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>H(t),children:n?m("story.hideText"):m("story.showText",{n:e.text.length})}),n&&(0,s.jsx)("pre",{className:"story-out",children:e.text})]},t)},q=f.close,A=q&&"done"!==q.status;return(0,s.jsxs)("div",{className:"story-box",ref:M,children:[(0,s.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:v,onChange:e=>y(e.target.checked)})," ",m("story.showChat")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:j,onChange:e=>k(e.target.checked)})," ",m("story.showCommands")]}),f.live&&(0,s.jsxs)("span",{className:"live",children:[(0,s.jsx)("span",{className:"dot","aria-hidden":"true"})," ",m("story.live")]}),f.live&&!D.following&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:D.follow,title:m("story.followWhy"),children:m("story.follow")}),x&&(0,s.jsx)("span",{className:"err",children:x})]}),(0,s.jsxs)("div",{className:"story-fixed",children:[(0,s.jsx)("strong",{children:m("story.prompt")}),(0,s.jsx)("pre",{className:"story-out always",children:f.prompt})]}),(0,s.jsx)("div",{ref:D.ref,className:"story-scroll".concat(f.live?" live":""),children:(0,s.jsx)("ol",{className:"story",children:f.entries.map((e,t)=>R(e,"e".concat(t)))})}),q?(0,s.jsxs)("div",{className:"story-fixed close".concat(A?" failed":""),children:[(0,s.jsx)("strong",{children:A?m("story.endedBadly",{status:q.status}):m("story.ended")}),q.reason&&(0,s.jsx)("p",{className:"err small",children:q.reason}),q.summary&&(0,s.jsx)(o.s,{text:q.summary,className:"what"}),q.checks&&q.checks.length>0&&(0,s.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:q.checks.map((e,t)=>(0,s.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,s.jsx)("div",{className:"story-fixed muted small",children:m("story.notEnded")})]})}function u(e){let{at:t}=e,n=(0,r.W3)(),{locale:l}=(0,r.kj)();if(!t)return null;let a=new Date(t),i="bg"===l?"bg-BG":void 0,o=a.toLocaleTimeString(i,{hour12:!1}),c=new Date().toDateString()===a.toDateString();return(0,s.jsx)("time",{className:"story-when",dateTime:t,title:n(t),children:c?o:"".concat(a.toLocaleDateString(i)," ").concat(o)})}},3041:(e,t,n)=>{n.d(t,{e:()=>i});var s=n(1521),l=n(5549),a=n(1035),r=n(867);function i(e){let{t}=(0,r.kj)(),[n,i]=(0,s.useState)(""),[o,c]=(0,s.useState)({taskId:"",text:""}),d=(e,t)=>c({taskId:e,text:t}),u=(0,s.useCallback)(async n=>{i("restore"),d(n.taskId,"");try{var s,r,o,c,u,h,m,f,p,x,g,v,y,j;let i=await l.FH.restorePreview(n.sessionId,n.taskId);if(!i.ok)return void d(n.taskId,t("restore.cannot",{problem:null!=(o=i.problem)?o:""}));let k={repo:i.repoDir,title:n.title,branch:null!=(c=i.branchName)?c:"",commit:(null!=(u=i.baseCommit)?u:"").slice(0,8)},b=i.leftBehind.length>0?t("restore.confirmLosing",{...k,n:i.leftBehind.length,kept:null!=(h=i.keptOn)?h:"",list:i.leftBehind.slice(0,10).join("\n")}):t("restore.confirm",k);if(!await (0,a.Z)(b))return;let N=await l.FH.restore(n.sessionId,n.taskId);if(!N.ok)return void d(n.taskId,t("restore.failed",{problem:null!=(m=N.problem)?m:""}));d(n.taskId,(null!=(f=null==(s=N.leftBehind)?void 0:s.length)?f:0)>0?t("restore.done",{branch:null!=(p=N.branch)?p:"",commit:(null!=(x=N.commit)?x:"").slice(0,8),n:null!=(g=null==(r=N.leftBehind)?void 0:r.length)?g:0,kept:null!=(v=N.keptOn)?v:""}):t("restore.doneNothing",{branch:null!=(y=N.branch)?y:"",commit:(null!=(j=N.commit)?j:"").slice(0,8)})),e()}catch(e){d(n.taskId,e.message)}finally{i("")}},[t,e]),h=(0,s.useCallback)(async n=>{i("restart"),d(n.taskId,"");try{var s,r;let i=await l.FH.restartPlan(n.sessionId,n.taskId);if(!i.ok)return void d(n.taskId,t("restart.cannot",{problem:null!=(s=i.problem)?s:""}));let o=i.restores.filter(e=>!e.ok);if(o.length>0)return void d(n.taskId,t("restart.cannot",{problem:o.map(e=>{var t;return"".concat(e.repoDir,": ").concat(null!=(t=e.problem)?t:"")}).join(" | ")}));let c=i.restores.map(e=>{var n,s,l;return t("restart.repoLine",{repo:e.repoDir,commit:(null!=(n=e.baseCommit)?n:"").slice(0,8),branch:null!=(s=e.branchName)?s:"",n:e.leftBehind.length,kept:null!=(l=e.keptOn)?l:""})}).join("\n"),u=i.tasks.map(e=>" ".concat(e.sessionName," / ").concat(e.title).concat(e.alreadyQueued?t("restart.alreadyQueued"):"")).join("\n"),h=t("restart.confirm",{title:i.from.title,tasks:i.tasks.length,sessions:i.sessions.length,list:u,repos:c||t("restart.noRepo"),mode:t("unattended"===i.mode?"run.unattended":"run.confirm")});if(!await (0,a.Z)(h))return;let m=await l.FH.restartFrom(n.sessionId,n.taskId);if(!m.started){d(n.taskId,t("restart.failed",{problem:null!=(r=m.reason)?r:""})),e();return}d(n.taskId,t("restart.started",{requeued:m.requeued,repos:m.restored.length})),e()}catch(e){d(n.taskId,e.message)}finally{i("")}},[t,e]);return{busy:n,message:o.text,messageTask:o.taskId,clearMessage:()=>d("",""),restore:u,restartFrom:h}}},3374:(e,t,n)=>{n.d(t,{c:()=>l});var s=n(1521);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[n,l]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{if(!e)return;l(Date.now());let n=window.setInterval(()=>l(Date.now()),t);return()=>window.clearInterval(n)},[e,t]),n}},3523:(e,t,n)=>{function s(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now();if(!e)return;let s=Date.parse(e);if(Number.isNaN(s))return;let l=t?Date.parse(t):n;return Number.isNaN(l)?void 0:Math.max(0,l-s)}function l(e){return!!e.startedAt&&!e.finishedAt&&"queued"!==e.status}function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),s=t.some(e=>l(e)),a=t.map(e=>e.finishedAt?Date.parse(e.finishedAt):NaN).filter(e=>!Number.isNaN(e)),r=Date.parse(e.startedAt),i=s||0===a.length?n:Math.max(...a);return{ms:Number.isNaN(r)?0:Math.max(0,i-r),live:s,tasks:t.length}}function r(e){var t,n;let s=new Map;for(let n of e){if(!n.runGroup)continue;let e=null!=(t=s.get(n.runGroup.id))?t:{run:n.runGroup,tasks:[]};e.tasks.push(n),s.set(n.runGroup.id,e)}return null!=(n=[...s.values()].sort((e,t)=>Date.parse(t.run.startedAt)-Date.parse(e.run.startedAt))[0])?n:null}n.d(t,{DG:()=>l,d5:()=>s,eZ:()=>a,hH:()=>r})},4811:(e,t,n)=>{n.d(t,{p:()=>a});var s=n(1521),l=n(5549);function a(){let[e,t]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let e=!0;return l.FH.settings().then(n=>{var s;let l=null!=(s=n.raw.execution)?s:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,t,n)=>{n.d(t,{V:()=>a});var s=n(1521);let l='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function a(e,t,n){(0,s.useEffect)(()=>{var s,a;if(!t)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(a=null!=(s=null==n?void 0:n.current)?s:null==i?void 0:i.querySelector(l))?a:null;null==o||o.focus();let c=e=>{if("Tab"!==e.key||!i)return;let t=Array.from(i.querySelectorAll(l)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let n=t[0],s=t[t.length-1],a=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!a)?(e.preventDefault(),s.focus()):e.shiftKey||document.activeElement!==s&&a||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),r&&document.contains(r)&&r.focus()}},[e,t,n])}},5132:(e,t,n)=>{n.d(t,{s:()=>i});var s=n(3365),l=n(1521);function a(e,t){let n,l=[],a=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,r=0,i=0;for(;null!==(n=a.exec(e));){n.index>r&&l.push(e.slice(r,n.index));let a=n[0],o="".concat(t,"-i").concat(i+=1);a.startsWith("`")?l.push((0,s.jsx)("code",{children:a.slice(1,-1)},o)):a.startsWith("**")?l.push((0,s.jsx)("strong",{children:a.slice(2,-2)},o)):l.push((0,s.jsx)("em",{children:a.slice(1,-1)},o)),r=n.index+a.length}return r<e.length&&l.push(e.slice(r)),l}function r(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let n=/^\s*\d+[.)]\s+(.*)$/.exec(e);return n?n[1]:null}function i(e){let{text:t,className:n}=e,i=[],o=t.replace(/\r\n/g,"\n").split("\n"),c=0,d=0;for(;c<o.length;){let e=o[c];if(e.trim().startsWith("```")){let e=[];for(c+=1;c<o.length&&!o[c].trim().startsWith("```");)e.push(o[c++]);c+=1,e.length>0&&i.push((0,s.jsx)("pre",{children:e.join("\n")},"b".concat(d+=1)));continue}if(null!==r(e)){let e=[];for(;c<o.length&&null!==r(o[c]);)e.push(r(o[c++]));i.push((0,s.jsx)("ul",{children:e.map((e,t)=>(0,s.jsx)("li",{children:a(e,"b".concat(d,"-").concat(t))},t))},"b".concat(d+=1)));continue}if(""===e.trim()){c+=1;continue}let t=[];for(;c<o.length&&""!==o[c].trim()&&null===r(o[c])&&!o[c].trim().startsWith("```");)t.push(o[c++]);let n=d+=1;i.push((0,s.jsx)("p",{children:t.map((e,t)=>(0,s.jsxs)(l.Fragment,{children:[t>0&&(0,s.jsx)("br",{}),a(e,"b".concat(n,"-").concat(t))]},t))},"b".concat(n)))}return(0,s.jsx)("div",{className:"rich ".concat(null!=n?n:""),children:i})}},7527:(e,t,n)=>{n.d(t,{z:()=>l});var s=n(1521);function l(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l=(0,s.useRef)(e);l.current=e,(0,s.useEffect)(()=>{let e;if(!n)return;let s=!1,a=async()=>{try{await l.current()}catch(e){}finally{s||(e=setTimeout(()=>void a(),t))}};return a(),()=>{s=!0,e&&clearTimeout(e)}},[t,n])}},8934:(e,t,n)=>{n.d(t,{C:()=>c});var s=n(3365),l=n(1521),a=n(5549),r=n(4969),i=n(867);function o(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function c(e){let{sessionId:t,taskId:n,runId:a,title:r,files:o}=e,{t:c}=(0,i.kj)(),[u,h]=(0,l.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>h(!0),title:c("diff.openWhy"),children:c("diff.open",{n:o})}),u&&(0,s.jsx)(d,{sessionId:t,taskId:n,runId:a,title:r,onClose:()=>h(!1)})]})}function d(e){var t,n,c,d,h,m,f;let{sessionId:p,taskId:x,runId:g,title:v,onClose:y}=e,{t:j}=(0,i.kj)(),[k,b]=(0,l.useState)(null),[N,w]=(0,l.useState)(""),[S,C]=(0,l.useState)(0),[E,I]=(0,l.useState)(new Map),[F,D]=(0,l.useState)(!1),[M,L]=(0,l.useState)(!0),[T,H]=(0,l.useState)(new Map),[R,q]=(0,l.useState)(-1),A=(0,l.useRef)(null),B=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,r.V)(B,!0,W),(0,l.useEffect)(()=>{a.FH.taskChanges(p,x,g).then(b).catch(e=>w(e.message))},[p,x,g]);let P=null!=(c=null==k?void 0:k.files)?c:[],O=P[S];(0,l.useEffect)(()=>{!O||E.has(O.path)||a.FH.taskChangeFile(p,x,O.path,g).then(e=>I(t=>new Map(t).set(O.path,e))).catch(e=>I(t=>new Map(t).set(O.path,e.message)))},[O,E,p,x,g]);let G=O?E.get(O.path):void 0,K=(0,l.useMemo)(()=>!G||"string"==typeof G||G.binary||G.tooLarge?[]:function(e,t){let n=function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let s=e.length,l=t.length;for(;s>n&&l>n&&e[s-1]===t[l-1];)s-=1,l-=1;let a=[];for(let e=0;e<n;e+=1)a.push({kind:"same",a:e,b:e});for(let r of function(e,t){let n=e.length,s=t.length;if(0===n)return t.map((e,t)=>({kind:"add",b:t}));if(0===s)return e.map((e,t)=>({kind:"del",a:t}));let l=n+s,a=l+1,r=new Int32Array(2*l+3),i=[];for(let o=0;o<=Math.min(l,2e3);o+=1){i.push(r.slice(a-o-1,a+o+2));for(let l=-o;l<=o;l+=2){let c=l===-o||l!==o&&r[a+l-1]<r[a+l+1]?r[a+l+1]:r[a+l-1]+1,d=c-l;for(;c<n&&d<s&&e[c]===t[d];)c+=1,d+=1;if(r[a+l]=c,c>=n&&d>=s)return function(e,t,n,s){let l=[],a=t.length,r=n.length;for(let t=s;t>0;t-=1){let n=e[t],s=e=>n[e+t+1],i=a-r,o=i===-t||i!==t&&s(i-1)<s(i+1)?i+1:i-1,c=s(o),d=c-o;for(;a>c&&r>d;)a-=1,r-=1,l.push({kind:"same",a:a,b:r});a===c?l.push({kind:"add",b:d}):l.push({kind:"del",a:c}),a=c,r=d}for(;a>0&&r>0;)a-=1,r-=1,l.push({kind:"same",a:a,b:r});return l.reverse()}(i,e,t,o)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(n,s),t.slice(n,l)))a.push({kind:r.kind,...void 0!==r.a?{a:r.a+n}:{},...void 0!==r.b?{b:r.b+n}:{}});for(let t=0;s+t<e.length;t+=1)a.push({kind:"same",a:s+t,b:l+t});return a}(e,t),s=[];for(let l=0;l<n.length;){let a=n[l];if("same"===a.kind){s.push({kind:"same",left:{no:a.a+1,text:e[a.a]},right:{no:a.b+1,text:t[a.b]}}),l+=1;continue}let r=[],i=[];for(;l<n.length&&"same"!==n[l].kind;){let e=n[l];"del"===e.kind?r.push(e.a):i.push(e.b),l+=1}let o=Math.max(r.length,i.length);for(let n=0;n<o;n+=1){let l=r[n],a=i[n];s.push({kind:void 0!==l&&void 0!==a?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==a?{right:{no:a+1,text:t[a]}}:{}})}}return s}(o(G.before),o(G.after)),[G]),V=O&&T.get(O.path)||new Set,Z=(0,l.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let s=0;s<e.length;){if("same"!==e[s].kind){l.push({type:"row",row:e[s],index:s}),s+=1;continue}let a=s;for(;a<e.length&&"same"===e[a].kind;)a+=1;let r=0===s?0:t,i=a===e.length?0:t,o=a-s-r-i;if(o>1&&!n.has(s+r)){for(let t=s;t<s+r;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:s+r,count:o});for(let t=a-i;t<a;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=s;t<a;t+=1)l.push({type:"row",row:e[t],index:t});s=a}return l})(K,3,V,F),[K,V,F]),_=(0,l.useMemo)(()=>K.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===K[t-1].kind)?[t]:[]),[K]);(0,l.useEffect)(()=>{q(-1),A.current&&(A.current.scrollTop=0)},[S]);let Q=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let n=R<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,R+e));q(n);let s=null==(t=A.current)?void 0:t.querySelector('[data-row="'.concat(_[n],'"]'));null==s||s.scrollIntoView({block:"center"})},[R,_]),$=(0,l.useCallback)(e=>C(t=>Math.min(Math.max(0,t+e),Math.max(0,P.length-1))),[P.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)y();else if("n"===e.key)Q(1);else if("p"===e.key)Q(-1);else if("]"===e.key)$(1);else{if("["!==e.key)return;$(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[Q,$,y]);let z=P.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,s.jsxs)("div",{ref:B,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,s.jsxs)("div",{className:"diff-head",children:[(0,s.jsx)("h2",{id:"diff-title",children:j("diff.title",{title:v})}),(null==k?void 0:k.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[k.branch?"".concat(k.branch," \xb7 "):"",null==(t=k.base)?void 0:t.slice(0,8)," → ",null==(n=k.commit)?void 0:n.slice(0,8)," \xb7 ",j("diff.summary",{n:P.length,a:z.added,r:z.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:j("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:y,children:j("diff.close")})]}),N&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:N}),!k&&!N&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:j("diff.loading")}),k&&!k.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:k.problem}),(null==k?void 0:k.ok)&&0===P.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.nothing")}),(null==k?void 0:k.ok)&&P.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":j("diff.files"),children:P.map((e,t)=>{let n=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===S?" on":""),onClick:()=>C(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,s.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,s.jsxs)("span",{className:"diff-path",children:[n>=0&&(0,s.jsx)("span",{className:"muted",children:e.path.slice(0,n+1)}),(0,s.jsx)("strong",{children:e.path.slice(n+1)})]}),(0,s.jsx)("span",{className:"diff-counts",children:e.added<0?j("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,s.jsxs)("div",{className:"diff-main",children:[O&&(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsx)("strong",{className:"diff-name",children:O.oldPath?"".concat(O.oldPath," → ").concat(O.path):O.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===O.status?j("diff.added"):"D"===O.status?j("diff.deleted"):"R"===O.status?j("diff.renamed"):""}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>Q(-1),disabled:0===_.length,children:j("diff.prevChange")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>Q(1),disabled:0===_.length,children:j("diff.nextChange")}),(0,s.jsx)("span",{className:"muted small",children:_.length>0?j("diff.changeN",{i:R<0?"–":R+1,n:_.length}):""}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(-1),disabled:0===S,children:j("diff.prevFile")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(1),disabled:S>=P.length-1,children:j("diff.nextFile")}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:F,onChange:e=>D(e.target.checked)})," ",j("diff.whole")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:M,onChange:e=>L(e.target.checked)})," ",j("diff.wrap")]})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:A,children:[void 0===G&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:j("diff.loading")}),"string"==typeof G&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:G}),G&&"string"!=typeof G&&G.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.binary")}),G&&"string"!=typeof G&&G.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.tooLarge")}),G&&"string"!=typeof G&&!G.binary&&!G.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(d=G.before)?d:"").includes("\r\n")!==(null!=(h=G.after)?h:"").includes("\r\n")&&null!==G.before&&null!==G.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:j("diff.eol",{from:(null!=(m=G.before)?m:"").includes("\r\n")?"CRLF":"LF",to:(null!=(f=G.after)?f:"").includes("\r\n")?"CRLF":"LF"})}),K.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:j("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(M?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{colSpan:2,children:j("diff.before")}),(0,s.jsx)("th",{colSpan:2,children:j("diff.after")})]})}),(0,s.jsx)("tbody",{children:Z.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(O&&H(e=>{var n;return new Map(e).set(O.path,new Set([...null!=(n=e.get(O.path))?n:[],t]))}))},children:j("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(u,{row:e.row,index:e.index,current:R>=0&&_[R]===e.index},e.index))})]})]})]})]})]})]})}function u(e){var t,n,a,r;let{row:i,index:o,current:c}=e,d="change"===i.kind?function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let s=e.length,l=t.length;for(;s>n&&l>n&&e[s-1]===t[l-1];)s-=1,l-=1;return{start:n,leftEnd:s,rightEnd:l}}(i.left.text,i.right.text):null,u=e=>{let t=i[e];if(!t)return null;if(!d)return t.text;let n="left"===e?d.leftEnd:d.rightEnd;return(0,s.jsxs)(l.Fragment,{children:[t.text.slice(0,d.start),(0,s.jsx)("mark",{children:t.text.slice(d.start,n)}),t.text.slice(n)]})};return(0,s.jsxs)("tr",{className:"diff-row ".concat(i.kind).concat(c?" current":""),"data-row":o,children:[(0,s.jsx)("td",{className:"num",children:null!=(a=null==(t=i.left)?void 0:t.no)?a:""}),(0,s.jsx)("td",{className:"code l".concat(i.left?"":" empty"),children:u("left")}),(0,s.jsx)("td",{className:"num",children:null!=(r=null==(n=i.right)?void 0:n.no)?r:""}),(0,s.jsx)("td",{className:"code r".concat(i.right?"":" empty"),children:u("right")})]})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,e,o)=>{o.d(e,{AV:()=>i,FH:()=>p,FZ:()=>d,Zm:()=>m,aT:()=>c,c5:()=>f,dK:()=>u,nC:()=>s,rt:()=>l,ub:()=>r,zi:()=>y});var n=o(986);let s="/api";function c(t,e){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(e?"#".concat(e):"")}let a="cop-api-token";function i(){try{var t;let e=/(?:^#|&)token=([0-9a-f]{16,})/i.exec(window.location.hash);if(e)return window.localStorage.setItem(a,e[1]),window.history.replaceState(null,"",window.location.pathname+window.location.search),e[1];return window.localStorage.getItem(a)||(null!=(t=n.env.NEXT_PUBLIC_COP_TOKEN)?t:"")}catch(t){return""}}function r(t){let e=i();return e?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(e)):t}let d=["exit-zero","exit-nonzero","output-contains","output-omits","output-matches","file-exists","file-missing","file-contains"];function l(t){return t.startsWith("exit-")||t.startsWith("output-")}function u(t){return"output-contains"===t||"output-omits"===t||"output-matches"===t||"file-contains"===t}function m(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}async function h(t,e){let o,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===n.timeoutMs?3e4:n.timeoutMs;try{var a;o=await fetch("".concat(s).concat(t),{...e,...null!==c&&!(null==e?void 0:e.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...i()?{"x-cop-token":i()}:{},...null!=(a=null==e?void 0:e.headers)?a:{}}})}catch(e){if("TimeoutError"===e.name)throw Error("The API did not answer within ".concat(Math.round((null!=c?c:0)/1e3)," s (").concat(t.split("?")[0],"). It may be busy; try again."));throw e}if(!o.ok){let t="".concat(o.status," ").concat(o.statusText);try{let e=await o.json();(null==e?void 0:e.message)&&(t=Array.isArray(e.message)?e.message.join("; "):e.message)}catch(t){}throw Error(t)}let r=await o.text();return r?JSON.parse(r):void 0}let p={health:()=>h("/health"),doctor:()=>h("/doctor"),settings:()=>h("/settings"),saveSettings:t=>h("/settings",{method:"PUT",body:JSON.stringify(t)}),level1:()=>h("/level1"),setLevel1:t=>h("/level1",{method:"PUT",body:JSON.stringify({content:t})}),resetLevel1:()=>h("/level1",{method:"DELETE"}),presets:()=>h("/presets"),savePreset:(t,e)=>h("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePreset:t=>h("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>h("/personas"),savePersona:(t,e)=>h("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePersona:t=>h("/personas/".concat(encodeURIComponent(t)),{method:"DELETE"}),sessions:()=>h("/sessions"),metrics:()=>h("/metrics"),syncPlan:t=>h("/repo/sync?dir=".concat(encodeURIComponent(t))),session:t=>h("/sessions/".concat(t)),createSession:(t,e)=>h("/sessions",{method:"POST",body:JSON.stringify({name:t,mirror:e})}),updateSession:(t,e)=>h("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(e)}),deleteSession:t=>h("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,e)=>h("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(e)}),updateTask:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e),{method:"PUT",body:JSON.stringify(o)}),deleteTask:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e),{method:"DELETE"}),continueTask:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/continue"),{method:"POST",body:"{}"}),rerunTask:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return h("/sessions/".concat(t,"/tasks/").concat(e,"/rerun"),{method:"POST",body:JSON.stringify({...o,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/changes").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskChangeFile:(t,e,o,n)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/changes/file?path=").concat(encodeURIComponent(o)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/story").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskFiles:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/files").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskLogUrl:(t,e,o)=>"".concat(s,"/sessions/").concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),taskFileUrl:(t,e,o,n,c)=>"".concat(s,"/sessions/").concat(t,"/tasks/").concat(e,"/files/").concat(o,"/").concat(encodeURIComponent(n)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,e,o)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,e,o,n,s)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/files/").concat(o,"/").concat(encodeURIComponent(n)).concat(s?"?run=".concat(encodeURIComponent(s)):""),{method:"POST",body:"{}"}),start:(t,e,o)=>h("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:e,name:o})}),stop:t=>h("/sessions/".concat(t,"/stop"),{method:"POST",body:"{}"}),approvals:t=>h("/approvals".concat(t?"?session=".concat(encodeURIComponent(t)):"")),decide:(t,e)=>h("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:e})}),setRunMode:(t,e)=>h("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:e})}),streamUrl:t=>r("".concat(s,"/sessions/").concat(t,"/stream")),batch:()=>h("/batch").then(t=>null!=t?t:null),startBatch:(t,e,o,n,s,c,a)=>h("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:e,onFailure:o,model:n,reviewModel:s,name:c,taskIds:a})}),suggestedRunName:t=>h("/batch/name?sessions=".concat(encodeURIComponent(t.join(",")))),stopBatch:()=>h("/batch/stop",{method:"POST",body:"{}"}),pauseBatch:()=>h("/batch/pause",{method:"POST",body:"{}"}),resumeBatch:()=>h("/batch/resume",{method:"POST",body:"{}"}),planBrief:t=>h("/plan/brief?lang=".concat(encodeURIComponent(t))),context:(t,e)=>h("/context/".concat(t,"?lang=").concat(encodeURIComponent(e))),setContext:(t,e)=>h("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:e})}),resetContext:(t,e)=>h("/context/".concat(t,"?lang=").concat(encodeURIComponent(e)),{method:"DELETE"}),checkPlan:t=>h("/plan/check",{method:"POST",body:JSON.stringify({text:t})}),importPlan:t=>h("/plan/import",{method:"POST",body:JSON.stringify({text:t})}),dirs:function(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return h("/dirs?root=".concat(encodeURIComponent(t),"&gitignore=").concat(e?"1":"0"))},browseFolder:t=>h("/browse-folder",{method:"POST",body:JSON.stringify({start:t})},{timeoutMs:null}),previewMirror:t=>h("/mirror/preview",{method:"POST",body:JSON.stringify(t)},{timeoutMs:18e4}),tasks:()=>h("/tasks"),activity:()=>h("/activity"),downloadBundle:async t=>{var e,o,n;let c=await fetch("".concat(s,"/export/bundle"),{method:"POST",headers:{"content-type":"application/json",...i()?{"x-cop-token":i()}:{}},body:JSON.stringify({tasks:t})});if(!c.ok)throw Error(await c.text()||"".concat(c.status," ").concat(c.statusText));let a=null!=(n=c.headers.get("content-disposition"))?n:"",r=null==(e=/filename\*=UTF-8''([^;]+)/i.exec(a))?void 0:e[1],d=null==(o=/filename="([^"]+)"/i.exec(a))?void 0:o[1],l=null!=d?d:"copilot-operator-bundle.json";if(r)try{l=decodeURIComponent(r)}catch(t){}let u=URL.createObjectURL(await c.blob()),m=document.createElement("a");return m.href=u,m.download=l,document.body.appendChild(m),m.click(),m.remove(),setTimeout(()=>URL.revokeObjectURL(u),1e4),l},exportUrl:(t,e)=>{let o=new URLSearchParams;return e.run&&o.set("run",e.run),e.session&&o.set("session",e.session),e.task&&o.set("task",e.task),r("".concat(s,"/export/").concat(t,"?").concat(o.toString()))},debugExportUrl:t=>r("".concat(s,"/debug/export").concat(t.length>0?"?sessions=".concat(encodeURIComponent(t.join(","))):"")),vcsStatus:t=>h("/sessions/".concat(t,"/vcs")),restorePreview:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restore")),restore:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restore"),{method:"POST",body:"{}"}),restartPlan:(t,e)=>h("/sessions/".concat(t,"/tasks/").concat(e,"/restart")),restartFrom:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return h("/sessions/".concat(t,"/tasks/").concat(e,"/restart"),{method:"POST",body:JSON.stringify(o)})},repoCheck:t=>h("/repo?dir=".concat(encodeURIComponent(t))),project:()=>h("/project"),setProject:t=>h("/project",{method:"PUT",body:JSON.stringify(t)}),models:()=>h("/models"),setDefaultModel:t=>h("/models/default",{method:"PUT",body:JSON.stringify({model:t})}),setDefaultReviewModel:t=>h("/models/review-default",{method:"PUT",body:JSON.stringify({model:t})}),refreshModels:()=>h("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null})};function y(t){return t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}function f(t){if(void 0===t)return"";let e=Math.round(t/1e3);if(e<60)return"".concat(e,"s");let o=Math.floor(e/60);return o<60?"".concat(o,"m ").concat(e%60,"s"):"".concat(Math.floor(o/60),"h ").concat(o%60,"m")}}}]);