copilot-operator 0.1.39 → 0.1.40

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 (53) hide show
  1. package/dist/src/api/operator.controller.js +101 -2
  2. package/dist/src/api/operator.service.js +292 -25
  3. package/dist/src/api/server.js +7 -0
  4. package/dist/src/log/terminal.js +145 -0
  5. package/dist/src/plan/brief.js +1375 -1369
  6. package/dist/src/plan/schema.js +5 -0
  7. package/dist/src/plan/systemGuide.js +158 -16
  8. package/dist/src/session/exports.js +1 -0
  9. package/dist/src/session/startFailure.js +91 -0
  10. package/dist/src/vcs/prepareFromRemote.js +7 -20
  11. package/dist/src/vcs/remoteAuth.js +26 -1
  12. package/dist/src/vcs/runPreflight.js +31 -14
  13. package/dist/src/vcs/snapshot.js +3 -1
  14. package/dist/src/vcs/startChoice.js +295 -0
  15. package/dist/src/vcs/taskVcs.js +40 -5
  16. package/dist/web/404.html +2 -2
  17. package/dist/web/_next/static/chunks/499-28e118e33ce07935.js +1 -0
  18. package/dist/web/_next/static/chunks/549-f295c8429e83b25b.js +1 -0
  19. package/dist/web/_next/static/chunks/584-578be94a0786334b.js +1 -0
  20. package/dist/web/_next/static/chunks/867-8dc5bbb092ca2c5c.js +1 -0
  21. package/dist/web/_next/static/chunks/app/history/page-9f69ccde726c9be2.js +1 -0
  22. package/dist/web/_next/static/chunks/app/layout-73f28bc065a46ed3.js +1 -0
  23. package/dist/web/_next/static/chunks/app/page-e557d58476ae6383.js +1 -0
  24. package/dist/web/_next/static/chunks/app/sessions/view/page-0485ee7f781156ec.js +1 -0
  25. package/dist/web/_next/static/chunks/app/system/{page-5ae1f8054208e6eb.js → page-227a259e383ca2a0.js} +1 -1
  26. package/dist/web/appearance.html +2 -2
  27. package/dist/web/appearance.txt +27 -25
  28. package/dist/web/defaults.html +2 -2
  29. package/dist/web/defaults.txt +27 -25
  30. package/dist/web/history.html +2 -2
  31. package/dist/web/history.txt +27 -25
  32. package/dist/web/import.html +2 -2
  33. package/dist/web/import.txt +27 -25
  34. package/dist/web/index.html +2 -2
  35. package/dist/web/index.txt +27 -25
  36. package/dist/web/level1.html +2 -2
  37. package/dist/web/level1.txt +27 -25
  38. package/dist/web/presets.html +2 -2
  39. package/dist/web/presets.txt +27 -25
  40. package/dist/web/sessions/view.html +2 -2
  41. package/dist/web/sessions/view.txt +27 -25
  42. package/dist/web/system.html +2 -2
  43. package/dist/web/system.txt +27 -25
  44. package/package.json +158 -157
  45. package/dist/web/_next/static/chunks/549-bfde82e4a70ed1a0.js +0 -1
  46. package/dist/web/_next/static/chunks/584-eba7ffe26cf1be83.js +0 -1
  47. package/dist/web/_next/static/chunks/867-7fccf68b0840c0de.js +0 -1
  48. package/dist/web/_next/static/chunks/app/history/page-d3461384566aa332.js +0 -1
  49. package/dist/web/_next/static/chunks/app/layout-630b663626cebe4a.js +0 -1
  50. package/dist/web/_next/static/chunks/app/page-4defcfd1eb482644.js +0 -1
  51. package/dist/web/_next/static/chunks/app/sessions/view/page-945be57e397ae162.js +0 -1
  52. /package/dist/web/_next/static/{KYi1jz7Awse_66Fg8c7Ur → Y9tuV5LV-O0XyCREkeGc5}/_buildManifest.js +0 -0
  53. /package/dist/web/_next/static/{KYi1jz7Awse_66Fg8c7Ur → Y9tuV5LV-O0XyCREkeGc5}/_ssgManifest.js +0 -0
@@ -0,0 +1,295 @@
1
+ import { git, isAncestor, isValidBranchName, lastFetchedAt } from './git.js';
2
+ import { fetchAsOperator, fetchCommandFor } from './remoteAuth.js';
3
+ import { describeStart, remoteTip, repoDirOf } from './taskVcs.js';
4
+ const lines = (s) => s.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
5
+ const norm = (dir) => dir.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
6
+ /** A task of the session has run: a start recorded since then is the one its work stands on. */
7
+ export function startIsFixed(session) {
8
+ const ran = session.tasks.some((t) => !!t.startedAt || (t.attempts ?? []).some((a) => !!a.startedAt));
9
+ return !!session.vcsBaseCommit && ran;
10
+ }
11
+ /** The branches of the repository at `dir`, read without touching the network. */
12
+ export async function repoBranches(dir) {
13
+ const empty = (problem) => ({ repoDir: dir, problem, current: null, head: null, local: [], remotes: [] });
14
+ const inside = await git(dir, ['rev-parse', '--is-inside-work-tree']);
15
+ if (!inside.ok || inside.stdout !== 'true')
16
+ return empty(`${dir} is not a git repository.`);
17
+ const current = await git(dir, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
18
+ const head = await git(dir, ['rev-parse', '--verify', '--quiet', 'HEAD']);
19
+ const refs = await git(dir, ['for-each-ref', '--format=%(objectname) %(refname)', 'refs/heads', 'refs/remotes']);
20
+ const remoteNames = lines((await git(dir, ['remote'])).stdout);
21
+ const local = [];
22
+ const byRemote = new Map(remoteNames.map((r) => [r, []]));
23
+ for (const line of refs.ok ? lines(refs.stdout) : []) {
24
+ const [commit, ref] = [line.slice(0, line.indexOf(' ')), line.slice(line.indexOf(' ') + 1)];
25
+ if (ref.startsWith('refs/heads/'))
26
+ local.push({ name: ref.slice('refs/heads/'.length), commit });
27
+ else if (ref.startsWith('refs/remotes/')) {
28
+ const rest = ref.slice('refs/remotes/'.length);
29
+ const remote = remoteNames.find((r) => rest.startsWith(`${r}/`));
30
+ const name = remote ? rest.slice(remote.length + 1) : '';
31
+ // `origin/HEAD` points at a branch; it is not one.
32
+ if (!remote || !name || name === 'HEAD')
33
+ continue;
34
+ byRemote.get(remote)?.push({ name, commit });
35
+ }
36
+ }
37
+ const gitDir = (await git(dir, ['rev-parse', '--absolute-git-dir'])).stdout;
38
+ const fetched = gitDir ? lastFetchedAt(gitDir) : undefined;
39
+ return {
40
+ repoDir: dir,
41
+ current: current.ok && current.stdout ? current.stdout : null,
42
+ head: head.ok && head.stdout ? head.stdout : null,
43
+ local,
44
+ remotes: [...byRemote.entries()].map(([name, branches]) => ({ name, branches })),
45
+ ...(fetched ? { lastFetched: fetched } : {}),
46
+ };
47
+ }
48
+ /** The remote a branch is most likely wanted from: `origin`, else the first one. */
49
+ export function defaultRemote(repo) {
50
+ return repo.remotes.find((r) => r.name === 'origin')?.name ?? repo.remotes[0]?.name;
51
+ }
52
+ /**
53
+ * What the start window offers first for a session: its own setting, as one of the choices. A local
54
+ * branch that is not here is offered from the remote when the remote has it, else the branch the
55
+ * repository is on — a start from wherever it happens to be (`head`) is offered as that branch, which
56
+ * is what it would have been.
57
+ */
58
+ export function defaultChoice(session, repo) {
59
+ const vcs = session.vcs;
60
+ const how = vcs?.startFrom ?? 'head';
61
+ if (how === 'previous-session')
62
+ return { from: 'previous-session' };
63
+ const onBranch = how === 'existing-branch';
64
+ // A branch the session names, as against one assumed (`main`, or wherever the repository is).
65
+ const named = (how === 'head' ? '' : (onBranch ? vcs?.existingBranch : vcs?.baseBranch)?.trim()) ?? '';
66
+ const wanted = named || (how === 'head' ? repo.current ?? '' : 'main');
67
+ const remote = vcs?.baseRemote?.trim();
68
+ const hasRemote = (r, b) => !!repo.remotes.find((x) => x.name === r)?.branches.some((x) => x.name === b);
69
+ if (remote && hasRemote(remote, wanted))
70
+ return { from: 'remote', remote, branch: wanted, ...(onBranch ? { onBranch } : {}) };
71
+ if (wanted && repo.local.some((b) => b.name === wanted))
72
+ return { from: 'local', branch: wanted, ...(onBranch ? { onBranch } : {}) };
73
+ const other = remote && repo.remotes.some((x) => x.name === remote) ? remote : defaultRemote(repo);
74
+ if (other && wanted && hasRemote(other, wanted))
75
+ return { from: 'remote', remote: other, branch: wanted, ...(onBranch ? { onBranch } : {}) };
76
+ /*
77
+ * Named, and neither here nor fetched yet — a branch a colleague pushed after the last fetch: offered from
78
+ * the remote all the same, which the window fetches by name. Offered as the branch the repository is on,
79
+ * it was started from that instead with one press, and the session's own branch was written over.
80
+ */
81
+ if (named && other)
82
+ return { from: 'remote', remote: other, branch: named, ...(onBranch ? { onBranch } : {}) };
83
+ return { from: 'local', branch: repo.current ?? repo.local[0]?.name ?? wanted };
84
+ }
85
+ /**
86
+ * The sessions of a run as the start window shows them, in run order, with the branches of each
87
+ * repository they work in.
88
+ */
89
+ export async function startOptions(sessions) {
90
+ const repos = new Map();
91
+ const out = [];
92
+ const seenRepos = new Set();
93
+ for (const s of sessions) {
94
+ const dir = s.vcs?.enabled ? repoDirOf(s) : '';
95
+ if (!dir) {
96
+ out.push({ id: s.id, name: s.name, vcs: false, previousOffered: false });
97
+ continue;
98
+ }
99
+ const key = norm(dir);
100
+ if (!repos.has(key))
101
+ repos.set(key, await repoBranches(dir));
102
+ const repo = repos.get(key);
103
+ const earlierHere = seenRepos.has(key);
104
+ seenRepos.add(key);
105
+ const entry = {
106
+ id: s.id,
107
+ name: s.name,
108
+ vcs: true,
109
+ repoDir: repo.repoDir,
110
+ previousOffered: s.vcs?.startFrom === 'previous-session' || earlierHere,
111
+ };
112
+ if (startIsFixed(s) && s.vcsStart)
113
+ entry.fixed = describeStart(s.vcsStart);
114
+ else if (startIsFixed(s))
115
+ entry.fixed = `it started from ${s.vcsBaseCommit?.slice(0, 8)}`;
116
+ else {
117
+ if (s.vcsStart)
118
+ entry.prepared = describeStart(s.vcsStart);
119
+ if (!repo.problem)
120
+ entry.choice = defaultChoice(s, repo);
121
+ }
122
+ out.push(entry);
123
+ }
124
+ return { repos: [...repos.values()], sessions: out };
125
+ }
126
+ /**
127
+ * Checks a choice against the repository and works out what it sets. Nothing is written to the session
128
+ * here; for `remote` with `onBranch` the local branch is made, or moved forward, since that is the
129
+ * choice — and only then, after everything else about it has been checked, and never with `dry`, which
130
+ * only says whether it could be done (every session of a run is checked so before any branch moves).
131
+ */
132
+ export async function applyStartChoice(session, choice, opts = {}) {
133
+ // Nothing to choose without version control, or once the start is fixed: see `startIsFixed`.
134
+ if (!session.vcs?.enabled || startIsFixed(session))
135
+ return { ok: true };
136
+ const dir = repoDirOf(session);
137
+ const before = pointOf(session.vcs);
138
+ if (choice.from === 'previous-session') {
139
+ const vcs = { startFrom: 'previous-session' };
140
+ return { ok: true, applied: { vcs, clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit, said: `"${session.name}" carries on the session before it in this repository` } };
141
+ }
142
+ const name = choice.branch.trim();
143
+ if (!name || !(await isValidBranchName(dir, name)))
144
+ return { ok: false, problem: `"${choice.branch}" is not a branch name git accepts.` };
145
+ if (choice.from === 'local') {
146
+ const tip = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
147
+ if (!tip)
148
+ return { ok: false, problem: `${dir} has no local branch "${name}". Choose one it has, or the remote branch of that name.` };
149
+ const vcs = choice.onBranch
150
+ ? { startFrom: 'existing-branch', existingBranch: name, baseRemote: undefined, updateFromRemote: false }
151
+ : { startFrom: 'branch', baseBranch: name, baseRemote: undefined, existingBranch: undefined, updateFromRemote: false };
152
+ return {
153
+ ok: true,
154
+ applied: {
155
+ vcs,
156
+ clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
157
+ said: choice.onBranch
158
+ ? `"${session.name}" works on the local branch ${name} itself (${tip.slice(0, 8)}), as it is here`
159
+ : `"${session.name}" starts from the local branch ${name} (${tip.slice(0, 8)}), as it is here`,
160
+ },
161
+ };
162
+ }
163
+ const remote = choice.remote.trim();
164
+ const remotes = lines((await git(dir, ['remote'])).stdout);
165
+ if (!remotes.includes(remote))
166
+ return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.` };
167
+ const theirs = await remoteTip(dir, remote, name);
168
+ if (!theirs)
169
+ return { ok: false, problem: `${remote}/${name} is not known here: it was not fetched. Start again, and it is fetched first.` };
170
+ if (!choice.onBranch) {
171
+ const vcs = { startFrom: 'branch', baseBranch: name, baseRemote: remote, existingBranch: undefined, updateFromRemote: false };
172
+ return {
173
+ ok: true,
174
+ applied: {
175
+ vcs,
176
+ clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
177
+ said: `"${session.name}" starts from the remote branch ${remote}/${name} (${theirs.slice(0, 8)}), as fetched now; the local branch ${name} is not touched`,
178
+ },
179
+ };
180
+ }
181
+ // Work on the branch itself: the local branch made from the remote one, or brought up to it.
182
+ const ours = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
183
+ let note;
184
+ if (!ours) {
185
+ // By its full name: `origin/x` alone is looked up among tags and local branches first.
186
+ const made = opts.dry ? { ok: true, stdout: '', stderr: '' } : await git(dir, ['branch', '--track', name, `refs/remotes/${remote}/${name}`]);
187
+ if (!made.ok)
188
+ return { ok: false, problem: `the local branch ${name} could not be made from ${remote}/${name}: ${(made.stderr || made.stdout).split(/\r?\n/)[0]}` };
189
+ note = `made the local branch ${name} from ${remote}/${name} (${theirs.slice(0, 8)})`;
190
+ }
191
+ else if (ours === theirs) {
192
+ note = `the local branch ${name} is already where ${remote}/${name} is (${theirs.slice(0, 8)})`;
193
+ }
194
+ else if (await isAncestor(dir, ours, theirs)) {
195
+ const current = (await git(dir, ['symbolic-ref', '--quiet', '--short', 'HEAD'])).stdout;
196
+ if (current === name) {
197
+ const dirty = (await git(dir, ['status', '--porcelain', '--untracked-files=no'])).stdout.trim();
198
+ if (dirty)
199
+ return { ok: false, problem: `${name} is checked out with uncommitted changes, so it cannot be brought up to ${remote}/${name}. Commit or stash them first; nothing was changed.` };
200
+ }
201
+ const moved = opts.dry
202
+ ? { ok: true, stdout: '', stderr: '' }
203
+ : current === name
204
+ ? await git(dir, ['merge', '--ff-only', '--quiet', theirs])
205
+ : await git(dir, ['update-ref', '-m', `copilot-operator: brought up to ${remote}/${name} in the start window`, `refs/heads/${name}`, theirs, ours]);
206
+ if (!moved.ok)
207
+ return { ok: false, problem: `${name} could not be brought up to ${remote}/${name}: ${(moved.stderr || moved.stdout).split(/\r?\n/)[0]}. Nothing else was changed.` };
208
+ note = `brought the local branch ${name} up to ${remote}/${name}: ${ours.slice(0, 8)} → ${theirs.slice(0, 8)}, fast-forward`;
209
+ }
210
+ else if (await isAncestor(dir, theirs, ours)) {
211
+ note = `the local branch ${name} has commits ${remote}/${name} does not; it was left as it is (${ours.slice(0, 8)}) and the work goes on top of them`;
212
+ }
213
+ else {
214
+ return {
215
+ ok: false,
216
+ problem: `the local branch ${name} (${ours.slice(0, 8)}) and ${remote}/${name} (${theirs.slice(0, 8)}) have each gone their own way, so working on it would mean choosing one of them. ` +
217
+ `Nothing was changed. Start from ${remote}/${name} on a new branch instead, or bring the two together yourself first.`,
218
+ };
219
+ }
220
+ const vcs = { startFrom: 'existing-branch', existingBranch: name, baseRemote: remote, updateFromRemote: false };
221
+ return {
222
+ ok: true,
223
+ applied: {
224
+ vcs,
225
+ clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
226
+ note,
227
+ said: `"${session.name}" works on the branch ${name} itself, from ${remote}/${name} as fetched now`,
228
+ },
229
+ };
230
+ }
231
+ /** Where a session's settings say it starts: the fields that decide the commit, nothing else. */
232
+ function pointOf(vcs) {
233
+ return JSON.stringify([vcs?.startFrom ?? 'head', vcs?.baseBranch?.trim() || 'main', vcs?.baseRemote?.trim() ?? '', vcs?.existingBranch?.trim() ?? '']);
234
+ }
235
+ function changed(before, after) {
236
+ return before !== pointOf(after);
237
+ }
238
+ /** The fields of an `AppliedChoice` written onto a session's version control: `undefined` removes one. */
239
+ export function withChoice(vcs, patch) {
240
+ const out = { ...vcs };
241
+ for (const [k, v] of Object.entries(patch)) {
242
+ if (v === undefined)
243
+ delete out[k];
244
+ else
245
+ out[k] = v;
246
+ }
247
+ return out;
248
+ }
249
+ /**
250
+ * The refspecs that fetch exactly these branches of `remote` into their remote-tracking branches, or
251
+ * why one of the names cannot be fetched.
252
+ */
253
+ export async function refspecsFor(dir, remote, branches) {
254
+ const refspecs = [];
255
+ for (const b of [...new Set(branches.map((x) => x.trim()).filter(Boolean))]) {
256
+ if (!(await isValidBranchName(dir, b)))
257
+ return { problem: `"${b}" is not a branch name git accepts.` };
258
+ refspecs.push(`+refs/heads/${b}:refs/remotes/${remote}/${b}`);
259
+ }
260
+ return { refspecs };
261
+ }
262
+ /** The branch names a failed fetch said the remote does not have. */
263
+ export function missingOnRemote(detail) {
264
+ return [...detail.matchAll(/couldn't find remote ref (?:refs\/heads\/)?(\S+)/gi)].map((m) => m[1].replace(/[.,;:]+$/, ''));
265
+ }
266
+ /** Where git keeps the repository's records, for `lastFetchedAt`. */
267
+ export async function gitDirOf(dir) {
268
+ const r = await git(dir, ['rev-parse', '--absolute-git-dir']);
269
+ return r.ok && r.stdout ? r.stdout : null;
270
+ }
271
+ /**
272
+ * Fetches `branches` of `remote` — or the whole remote, pruned, when none are named — for the start
273
+ * window, where the operator is looking: through Git's password window when there is one (`askpass`).
274
+ * Only remote-tracking branches move; no local branch, no checkout.
275
+ */
276
+ export async function fetchForStart(dir, remote, branches, askpass) {
277
+ const remotes = lines((await git(dir, ['remote'])).stdout);
278
+ if (!remotes.includes(remote))
279
+ return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.`, missing: [] };
280
+ const specs = branches && branches.length > 0 ? await refspecsFor(dir, remote, branches) : { refspecs: [] };
281
+ if ('problem' in specs)
282
+ return { ok: false, problem: specs.problem, missing: [] };
283
+ const gitDir = await gitDirOf(dir);
284
+ // Read before fetching: a fetch that fails empties FETCH_HEAD, and with it the time of the last one that worked.
285
+ const lastBefore = gitDir ? lastFetchedAt(gitDir) : undefined;
286
+ const fetched = await fetchAsOperator(dir, remote, { askpass, refspecs: specs.refspecs });
287
+ const missing = fetched.ok ? [] : missingOnRemote(fetched.detail ?? '');
288
+ return {
289
+ ok: fetched.ok,
290
+ fetched,
291
+ missing,
292
+ ...(fetched.ok ? {} : { fetchCommand: fetchCommandFor(dir, remote), ...(lastBefore ? { lastFetched: lastBefore } : {}) }),
293
+ repo: await repoBranches(dir),
294
+ };
295
+ }
@@ -375,9 +375,25 @@ export async function sessionStart(session, dir, head, allSessions,
375
375
  opts = {}) {
376
376
  const how = session.vcs?.startFrom ?? 'head';
377
377
  const baseBranch = session.vcs?.baseBranch?.trim() || 'main';
378
+ const baseRemote = session.vcs?.baseRemote?.trim() || '';
378
379
  if (how === 'head')
379
380
  return head ? { start: { kind: 'head', commit: head } } : {};
380
381
  const fromBranch = async (note) => {
382
+ /*
383
+ * A remote branch chosen in the start window: the remote-tracking branch as that window fetched it,
384
+ * with the operator there to type a key's passphrase. Not fetched again here — a run's fetch may not
385
+ * ask anybody anything — and the local branch of that name is neither read nor moved.
386
+ */
387
+ if (baseRemote) {
388
+ const tip = await remoteTip(dir, baseRemote, baseBranch);
389
+ if (!tip) {
390
+ return {
391
+ problem: `this session is set to start from the remote branch "${baseRemote}/${baseBranch}", and ${dir} has no copy of it. ` +
392
+ 'Start the run again and choose it in the start window, which fetches it.',
393
+ };
394
+ }
395
+ return { start: { kind: 'branch', commit: tip, branch: `${baseRemote}/${baseBranch}`, remote: baseRemote, ...(note ? { note } : {}) } };
396
+ }
381
397
  // The code as it is on the server, not as this checkout last pulled it: see `updateFromRemote`.
382
398
  const update = !opts.dry && session.vcs?.updateFromRemote !== false && (await branchTip(dir, baseBranch)) ? await updateFromRemote(dir, baseBranch) : undefined;
383
399
  const tip = await branchTip(dir, baseBranch);
@@ -520,6 +536,22 @@ async function branchTip(dir, branch) {
520
536
  const r = await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}^{commit}`]);
521
537
  return r.ok && r.stdout.trim() ? r.stdout.trim() : null;
522
538
  }
539
+ /** Where `<remote>/<branch>` was when it was last fetched here, or null when it never was. */
540
+ export async function remoteTip(dir, remote, branch) {
541
+ if (!/^[\w.-]+$/.test(remote) || !(await isValidBranchName(dir, branch)))
542
+ return null;
543
+ const r = await git(dir, ['rev-parse', '--verify', '--quiet', `refs/remotes/${remote}/${branch}^{commit}`]);
544
+ return r.ok && r.stdout.trim() ? r.stdout.trim() : null;
545
+ }
546
+ /**
547
+ * The ref a session's `startFrom: branch` reads, and the name it is shown by: `refs/remotes/origin/x`
548
+ * as `origin/x` for a remote branch chosen in the start window, else `refs/heads/<baseBranch>`.
549
+ */
550
+ export function baseRefOf(vcs) {
551
+ const branch = vcs?.baseBranch?.trim() || 'main';
552
+ const remote = vcs?.baseRemote?.trim();
553
+ return remote ? { ref: `refs/remotes/${remote}/${branch}`, name: `${remote}/${branch}`, remote, branch } : { ref: `refs/heads/${branch}`, name: branch, branch };
554
+ }
523
555
  function normalise(dir) {
524
556
  return dir.trim().replace(/[\\/]+$/, '').replace(/\//g, '\\').toLowerCase();
525
557
  }
@@ -535,7 +567,9 @@ export function describeStart(start) {
535
567
  : start.kind === 'existing-branch'
536
568
  ? `this session carries on the existing branch ${start.branch}, from its tip ${at}`
537
569
  : start.kind === 'branch'
538
- ? `this session starts from the local branch ${start.branch} (${at})`
570
+ ? start.remote
571
+ ? `this session starts from the remote branch ${start.branch} (${at}), as fetched when the run was started`
572
+ : `this session starts from the local branch ${start.branch} (${at})`
539
573
  : `this session starts from where the repository was (${at})`;
540
574
  const updated = start.update ? ` (${describeUpdate(start.update)})` : '';
541
575
  const plus = carried ? `, plus the operator's input files carried from ${carried.from} as ${start.commit.slice(0, 8)} on ${carried.branch}` : '';
@@ -552,11 +586,11 @@ export async function whereLeft(session) {
552
586
  const dir = repoDirOf(session);
553
587
  if (!session.vcs?.enabled || files.length === 0 || !dir)
554
588
  return null;
555
- const base = session.vcs.baseBranch?.trim() || 'main';
589
+ const { ref, name: base } = baseRefOf(session.vcs);
556
590
  const state = await repoState(dir).catch(() => null);
557
591
  if (!state?.isRepo || !state.branch || state.branch === base)
558
592
  return null;
559
- const onBase = await git(dir, ['cat-file', '-e', `refs/heads/${base}:${files[0].path}`]);
593
+ const onBase = await git(dir, ['cat-file', '-e', `${ref}:${files[0].path}`]);
560
594
  if (onBase.ok)
561
595
  return null;
562
596
  const paths = files.map((f) => f.path);
@@ -739,7 +773,7 @@ export function noteFor(repoDir, vcs, ctx = { mode: 'per-task', earlier: [] }) {
739
773
  : ctx.start?.kind === 'existing-branch'
740
774
  ? `This session carries on the existing branch \`${ctx.start.branch}\`: the work already on it is in your working tree. Build on it; do not redo it.`
741
775
  : ctx.start?.kind === 'branch'
742
- ? `This session started from the local branch \`${ctx.start.branch}\`, not from any earlier session's work${ctx.start.note ? ` (${ctx.start.note})` : ''}.`
776
+ ? `This session started from the ${ctx.start.remote ? 'remote branch' : 'local branch'} \`${ctx.start.branch}\`${ctx.start.remote ? ' (the code on the server, fetched when the run was started)' : ''}, not from any earlier session's work${ctx.start.note ? ` (${ctx.start.note})` : ''}.`
743
777
  : '';
744
778
  return [
745
779
  '## Version control',
@@ -1164,8 +1198,9 @@ export async function vcsPreflight(session, allSessions = async () => []) {
1164
1198
  */
1165
1199
  if (!session.vcsBaseCommit && settings.startFrom === 'previous-session') {
1166
1200
  const planned = await sessionStart(session, repoDir, state.head, allSessions, { dry: true });
1201
+ // About where it starts only: another choice in the start window gets past it (see `RunVcsGroup.startChoiceCanFix`).
1167
1202
  if ('problem' in planned)
1168
- return { ok: false, repoDir, branch: state.branch ?? undefined, problem: planned.problem };
1203
+ return { ok: false, repoDir, branch: state.branch ?? undefined, problem: planned.problem, startProblem: true };
1169
1204
  }
1170
1205
  return { ok: true, repoDir, branch: state.branch ?? undefined };
1171
1206
  }
package/dist/web/404.html CHANGED
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html><!--KYi1jz7Awse_66Fg8c7Ur--><html lang="en" data-theme="light" data-textsize="normal" data-contrast="normal" data-motion="normal" data-links="plain" data-focus="normal"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/cea7913ba416dbb7.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-0f31b926d9a9c5a4.js"/><script src="/_next/static/chunks/c7879cf7-b5ab1053c1d9a2e7.js" async=""></script><script src="/_next/static/chunks/131-bae98f790a541679.js" async=""></script><script src="/_next/static/chunks/main-app-e3a5f713ba31557e.js" async=""></script><script src="/_next/static/chunks/197-f7c33a0114fc3db3.js" async=""></script><script src="/_next/static/chunks/867-7fccf68b0840c0de.js" async=""></script><script src="/_next/static/chunks/549-bfde82e4a70ed1a0.js" async=""></script><script src="/_next/static/chunks/app/layout-630b663626cebe4a.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><title>copilot-operator</title><meta name="description" content="Runs task loops with Microsoft 365 Copilot on this machine."/><script>
1
+ <!DOCTYPE html><!--Y9tuV5LV_O0XyCREkeGc5--><html lang="en" data-theme="light" data-textsize="normal" data-contrast="normal" data-motion="normal" data-links="plain" data-focus="normal"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/cea7913ba416dbb7.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-0f31b926d9a9c5a4.js"/><script src="/_next/static/chunks/c7879cf7-b5ab1053c1d9a2e7.js" async=""></script><script src="/_next/static/chunks/131-bae98f790a541679.js" async=""></script><script src="/_next/static/chunks/main-app-e3a5f713ba31557e.js" async=""></script><script src="/_next/static/chunks/197-f7c33a0114fc3db3.js" async=""></script><script src="/_next/static/chunks/867-8dc5bbb092ca2c5c.js" async=""></script><script src="/_next/static/chunks/549-f295c8429e83b25b.js" async=""></script><script src="/_next/static/chunks/499-28e118e33ce07935.js" async=""></script><script src="/_next/static/chunks/app/layout-73f28bc065a46ed3.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><title>copilot-operator</title><meta name="description" content="Runs task loops with Microsoft 365 Copilot on this machine."/><script>
2
2
  (function () {
3
3
  try {
4
4
  var d = document.documentElement;
@@ -13,4 +13,4 @@
13
13
  d.dataset.focus = a.strongFocus ? 'strong' : 'normal';
14
14
  } catch (e) {}
15
15
  })();
16
- </script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><a class="skip-link" href="#main">Skip to the content</a><div class="wrap"><header class="top"><h1><a href="/">copilot-operator</a></h1><nav aria-label="Main"><a href="/"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M4 5h16v4H4zM4 11h16v4H4zM4 17h10v2H4z"></path></svg><span>Sessions</span></a><a href="/defaults"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm8.5 4 1.5 1-1.6 2.8-1.8-.4a7 7 0 0 1-1.5 1.5l.4 1.8L14.7 21l-1-1.5a7 7 0 0 1-3.4 0l-1 1.5-2.8-1.6.4-1.8A7 7 0 0 1 5.4 16l-1.8.4L2 13.6 3.5 12.6V11.4L2 10.4l1.6-2.8 1.8.4A7 7 0 0 1 6.9 6.5l-.4-1.8L9.3 3l1 1.5a7 7 0 0 1 3.4 0l1-1.5 2.8 1.6-.4 1.8a7 7 0 0 1 1.5 1.5l1.8-.4L22 10.4l-1.5 1z"></path></svg><span>Settings</span></a><a href="/import"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3v10m0 0 4-4m-4 4-4-4M4 15v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg><span>Plan from JSON</span></a><a href="/history"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3a9 9 0 1 0 8.5 6M12 7v5l3 2M3 4v5h5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg><span>Task register</span></a><a href="/level1"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M6 3h9l5 5v13H6zM14 3v6h6M9 13h7M9 17h7" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>Level 1 prompt</span></a><a href="/presets"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M5 4h14v4H5zM5 10h14v4H5zM5 16h9v4H5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>Level 2 presets</span></a><a href="/appearance"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-1-1.5-1-2.5S14 15 15.5 15H17a4 4 0 0 0 4-4 8 8 0 0 0-9-8zM8 9a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4-3a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"></path></svg><span>Appearance</span></a><a href="/system"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M4 5h16v10H4zM2 19h20M9 15v4M15 15v4" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>System</span></a><select aria-label="Language" style="width:auto"><option value="en" selected="">English</option><option value="bg">Български</option></select></nav></header><main id="main"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--></main></div><script src="/_next/static/chunks/webpack-0f31b926d9a9c5a4.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[8078,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"AppearanceProvider\"]\n3:I[867,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"LanguageProvider\"]\n4:I[1035,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"DialogHost\"]\n5:I[8214,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"SkipLink\"]\n6:I[8197,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"\"]\n7:I[8214,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"Nav\"]\n8:I[6657,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"GlobalApprovals\"]\n9:I[5204,[],\"\"]\na:I[2642,[],\"\"]\nb:I[7712,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-7fccf68b0840c0de.js\",\"549\",\"static/chunks/549-bfde82e4a70ed1a0.js\",\"177\",\"static/chunks/app/layout-630b663626cebe4a.js\"],\"ScrollJump\"]\nc:I[433,[],\"OutletBoundary\"]\ne:I[9884,[],\"AsyncMetadataOutlet\"]\n10:I[433,[],\"ViewportBoundary\"]\n12:I[433,[],\"MetadataBoundary\"]\n13:\"$Sreact.suspense\"\n15:I[3536,[],\"\"]\n:HL[\"/_next/static/css/cea7913ba416dbb7.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"KYi1jz7Awse_66Fg8c7Ur\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/cea7913ba416dbb7.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"suppressHydrationWarning\":true,\"data-theme\":\"light\",\"data-textsize\":\"normal\",\"data-contrast\":\"normal\",\"data-motion\":\"normal\",\"data-links\":\"plain\",\"data-focus\":\"normal\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"\\n(function () {\\n try {\\n var d = document.documentElement;\\n var raw = localStorage.getItem('cop.appearance');\\n var a = raw ? JSON.parse(raw) : {};\\n if (!a || typeof a !== 'object') a = {};\\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\\n d.dataset.textsize = [\\\"small\\\",\\\"normal\\\",\\\"large\\\",\\\"huge\\\",\\\"giant\\\"].indexOf(a.textSize) \u003e= 0 ? a.textSize : 'normal';\\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\\n } catch (e) {}\\n})();\\n\"}}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"children\":[\"$\",\"$L4\",null,{\"children\":[[\"$\",\"$L5\",null,{}],[\"$\",\"div\",null,{\"className\":\"wrap\",\"children\":[[\"$\",\"header\",null,{\"className\":\"top\",\"children\":[[\"$\",\"h1\",null,{\"children\":[\"$\",\"$L6\",null,{\"href\":\"/\",\"children\":\"copilot-operator\"}]}],[\"$\",\"$L7\",null,{}]]}],[\"$\",\"$L8\",null,{}],[\"$\",\"main\",null,{\"id\":\"main\",\"children\":[\"$\",\"$L9\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$La\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]]}],[\"$\",\"$Lb\",null,{}]]}]}]}]}]]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L9\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$La\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$Lc\",null,{\"children\":[\"$Ld\",[\"$\",\"$Le\",null,{\"promise\":\"$@f\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L10\",null,{\"children\":\"$L11\"}],null],[\"$\",\"$L12\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$13\",null,{\"fallback\":null,\"children\":\"$L14\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$15\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"11:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\nd:null\n"])</script><script>self.__next_f.push([1,"f:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"copilot-operator\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Runs task loops with Microsoft 365 Copilot on this machine.\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"14:\"$f:metadata\"\n"])</script></body></html>
16
+ </script><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><a class="skip-link" href="#main">Skip to the content</a><div class="wrap"><header class="top"><h1><a href="/">copilot-operator</a></h1><nav aria-label="Main"><a href="/"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M4 5h16v4H4zM4 11h16v4H4zM4 17h10v2H4z"></path></svg><span>Sessions</span></a><a href="/defaults"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm8.5 4 1.5 1-1.6 2.8-1.8-.4a7 7 0 0 1-1.5 1.5l.4 1.8L14.7 21l-1-1.5a7 7 0 0 1-3.4 0l-1 1.5-2.8-1.6.4-1.8A7 7 0 0 1 5.4 16l-1.8.4L2 13.6 3.5 12.6V11.4L2 10.4l1.6-2.8 1.8.4A7 7 0 0 1 6.9 6.5l-.4-1.8L9.3 3l1 1.5a7 7 0 0 1 3.4 0l1-1.5 2.8 1.6-.4 1.8a7 7 0 0 1 1.5 1.5l1.8-.4L22 10.4l-1.5 1z"></path></svg><span>Settings</span></a><a href="/import"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3v10m0 0 4-4m-4 4-4-4M4 15v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg><span>Plan from JSON</span></a><a href="/history"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3a9 9 0 1 0 8.5 6M12 7v5l3 2M3 4v5h5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg><span>Task register</span></a><a href="/level1"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M6 3h9l5 5v13H6zM14 3v6h6M9 13h7M9 17h7" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>Level 1 prompt</span></a><a href="/presets"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M5 4h14v4H5zM5 10h14v4H5zM5 16h9v4H5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>Level 2 presets</span></a><a href="/appearance"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-1-1.5-1-2.5S14 15 15.5 15H17a4 4 0 0 0 4-4 8 8 0 0 0-9-8zM8 9a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4-3a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"></path></svg><span>Appearance</span></a><a href="/system"><svg class="nav-icon" viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M4 5h16v10H4zM2 19h20M9 15v4M15 15v4" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"></path></svg><span>System</span></a><select aria-label="Language" style="width:auto"><option value="en" selected="">English</option><option value="bg">Български</option></select></nav></header><main id="main"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--></main></div><script src="/_next/static/chunks/webpack-0f31b926d9a9c5a4.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[8078,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"AppearanceProvider\"]\n3:I[867,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"LanguageProvider\"]\n4:I[1035,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"DialogHost\"]\n5:I[8214,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"SkipLink\"]\n6:I[8197,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"\"]\n7:I[8214,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"Nav\"]\n8:I[6657,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"GlobalApprovals\"]\n9:I[3069,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\","])</script><script>self.__next_f.push([1,"\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"StartFailureBanner\"]\na:I[5204,[],\"\"]\nb:I[2642,[],\"\"]\nc:I[7712,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"ScrollJump\"]\nd:I[1701,[\"197\",\"static/chunks/197-f7c33a0114fc3db3.js\",\"867\",\"static/chunks/867-8dc5bbb092ca2c5c.js\",\"549\",\"static/chunks/549-f295c8429e83b25b.js\",\"499\",\"static/chunks/499-28e118e33ce07935.js\",\"177\",\"static/chunks/app/layout-73f28bc065a46ed3.js\"],\"StartDialogHost\"]\ne:I[433,[],\"OutletBoundary\"]\n10:I[9884,[],\"AsyncMetadataOutlet\"]\n12:I[433,[],\"ViewportBoundary\"]\n14:I[433,[],\"MetadataBoundary\"]\n15:\"$Sreact.suspense\"\n17:I[3536,[],\"\"]\n:HL[\"/_next/static/css/cea7913ba416dbb7.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"Y9tuV5LV-O0XyCREkeGc5\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/cea7913ba416dbb7.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"suppressHydrationWarning\":true,\"data-theme\":\"light\",\"data-textsize\":\"normal\",\"data-contrast\":\"normal\",\"data-motion\":\"normal\",\"data-links\":\"plain\",\"data-focus\":\"normal\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"script\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"\\n(function () {\\n try {\\n var d = document.documentElement;\\n var raw = localStorage.getItem('cop.appearance');\\n var a = raw ? JSON.parse(raw) : {};\\n if (!a || typeof a !== 'object') a = {};\\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\\n d.dataset.textsize = [\\\"small\\\",\\\"normal\\\",\\\"large\\\",\\\"huge\\\",\\\"giant\\\"].indexOf(a.textSize) \u003e= 0 ? a.textSize : 'normal';\\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\\n } catch (e) {}\\n})();\\n\"}}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"$L2\",null,{\"children\":[\"$\",\"$L3\",null,{\"children\":[\"$\",\"$L4\",null,{\"children\":[[\"$\",\"$L5\",null,{}],[\"$\",\"div\",null,{\"className\":\"wrap\",\"children\":[[\"$\",\"header\",null,{\"className\":\"top\",\"children\":[[\"$\",\"h1\",null,{\"children\":[\"$\",\"$L6\",null,{\"href\":\"/\",\"children\":\"copilot-operator\"}]}],[\"$\",\"$L7\",null,{}]]}],[\"$\",\"$L8\",null,{}],[\"$\",\"$L9\",null,{}],[\"$\",\"main\",null,{\"id\":\"main\",\"children\":[\"$\",\"$La\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$Lb\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]]}],[\"$\",\"$Lc\",null,{}],[\"$\",\"$Ld\",null,{}]]}]}]}]}]]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$La\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$Lb\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$Le\",null,{\"children\":[\"$Lf\",[\"$\",\"$L10\",null,{\"promise\":\"$@11\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L12\",null,{\"children\":\"$L13\"}],null],[\"$\",\"$L14\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$15\",null,{\"fallback\":null,\"children\":\"$L16\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$17\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"13:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\nf:null\n"])</script><script>self.__next_f.push([1,"11:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"copilot-operator\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Runs task loops with Microsoft 365 Copilot on this machine.\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"16:\"$11:metadata\"\n"])</script></body></html>
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[499],{1035:(e,l,s)=>{s.d(l,{DialogHost:()=>d,Z:()=>c});var t=s(3365),n=s(1521),a=s(867),r=s(4969);let i=null,o=[];function c(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(s=>{var t;return t={kind:"confirm",message:e,...l,resolve:s},void(i?i(t):o.push(t))})}function d(e){var l,s;let{children:c}=e,{t:d}=(0,a.kj)(),[h,u]=(0,n.useState)([]),m=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(i=e=>u(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);u(l=>[...l,...e])}return()=>{i=null}},[]);let g=h[0],x=(0,n.useCallback)(e=>{g&&(g.resolve(e),u(e=>e.slice(1)))},[g]);return(0,r.V)(p,!!g,m),(0,n.useEffect)(()=>{if(!g)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),x(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,x]),(0,t.jsxs)(t.Fragment,{children:[c,g&&(0,t.jsx)("div",{className:"modal-backdrop",onClick:()=>x(!1),role:"presentation",children:(0,t.jsxs)("div",{ref:p,className:"modal".concat(g.danger?" danger":""),role:"confirm"===g.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("h2",{id:"modal-title",children:null!=(l=g.title)?l:d("confirm"===g.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,t.jsx)("div",{id:"modal-body",className:"modal-body",children:g.message}),(0,t.jsxs)("div",{className:"row modal-actions",children:["confirm"===g.kind&&(0,t.jsx)("button",{type:"button",className:"quiet",onClick:()=>x(!1),children:d("dialog.cancel")}),(0,t.jsx)("button",{ref:m,type:"button",className:g.danger?"danger":"primary",onClick:()=>x(!0),children:null!=(s=g.okLabel)?s:d("dialog.ok")})]})]})})]})}},1701:(e,l,s)=>{s.d(l,{L:()=>m,StartDialogHost:()=>p});var t=s(3365),n=s(1521),a=s(5549),r=s(867),i=s(4969),o=s(3486),c=s(3069);let d=null,h=[],u=1;function m(e){return new Promise(l=>{let s={...e,id:u++,resolve:l};d?d(s):h.push(s)})}function p(){let[e,l]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(d=e=>l(l=>[...l,e]),h.length>0){let e=h.splice(0,h.length);l(l=>[...l,...e])}return()=>{d=null}},[]);let s=e[0];return s?(0,t.jsx)(x,{req:s,onDone:e=>{s.resolve(e),l(e=>e.slice(1))}},s.id):null}let g=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase();function x(e){var l,s,d,h,u;let{req:m,onDone:p}=e,{t:x}=(0,r.kj)(),f=(0,r.W3)(),j=(0,n.useId)(),v=(0,n.useRef)(null),b=(0,n.useRef)(null),[y,k]=(0,n.useState)(null),[w,N]=(0,n.useState)(""),[F,C]=(0,n.useState)({}),[B,S]=(0,n.useState)({}),[D,E]=(0,n.useState)({kind:"choose"}),[T,H]=(0,n.useState)(""),[W,I]=(0,n.useState)(""),[L,R]=(0,n.useState)({}),[A,O]=(0,n.useState)([]),[P,q]=(0,n.useState)(!1),z=(0,n.useRef)(new Set),V=(0,n.useRef)(void 0),K=e=>p({started:e,...V.current?{reply:V.current}:{}}),U="fetching"===D.kind||"starting"===D.kind||""!==W,_=()=>a.FH.startOptions(m.sessionIds).then(e=>{k(e);let l={};for(let s of e.repos)l[g(s.repoDir)]=s;C(l);let s={};for(let t of e.sessions){if(!t.vcs||t.fixed||!t.repoDir)continue;let e=function(e,l){var s,t,n,a,r,i,o;let c=null!=(r=null!=(a=null==l||null==(s=l.remotes.find(e=>"origin"===e.name))?void 0:s.name)?a:null==l||null==(t=l.remotes[0])?void 0:t.name)?r:"",d=null!=(o=null!=(i=null==l?void 0:l.current)?i:null==l||null==(n=l.local[0])?void 0:n.name)?o:"main";return e?"previous-session"===e.from?{from:"previous-session",local:d,remote:c,remoteBranch:d,onBranch:!1}:"local"===e.from?{from:"local",local:e.branch,remote:c,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"remote",local:(null==l?void 0:l.local.some(l=>l.name===e.branch))?e.branch:d,remote:e.remote,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"local",local:d,remote:c,remoteBranch:"main",onBranch:!1}}(t.choice,l[g(t.repoDir)]);s[t.id]=t.prepared?{...e,from:"keep"}:e}S(s)}).catch(e=>N(e.message));(0,n.useEffect)(()=>{_()},[m.sessionIds]),(0,i.V)(v,!0,b),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&(e.preventDefault(),U||K(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[U,K]);let X=e=>e?F[g(e)]:void 0,J=(e,l)=>S(s=>({...s,[e]:{...s[e],...l}})),M=e=>{e&&C(l=>({...l,[g(e.repoDir)]:e}))},Z=()=>{a.FH.runVcs(m.sessionIds).then(O).catch(()=>O([]))},$=()=>{z.current.clear(),E({kind:"choose"})},G=async function(){var e;let l,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};H("");let t=(()=>{var e,l;let s={},t=new Map;for(let n of null!=(e=null==y?void 0:y.sessions)?e:[]){let e=B[n.id],a=X(n.repoDir);if(e&&n.repoDir&&a&&!a.problem&&"keep"!==e.from)if("previous-session"===e.from)s[n.id]={from:"previous-session"};else if("local"===e.from){if(!e.local||!a.local.some(l=>l.name===e.local))return{problem:x("startdlg.needBranch",{name:n.name})};s[n.id]={from:"local",branch:e.local,...e.onBranch?{onBranch:!0}:{}}}else{let r=e.remoteBranch.trim();if(!e.remote||!r)return{problem:x("startdlg.needBranch",{name:n.name})};s[n.id]={from:"remote",remote:e.remote,branch:r,...e.onBranch?{onBranch:!0}:{}};let i="".concat(g(n.repoDir),"|").concat(e.remote),o=null!=(l=t.get(i))?l:{key:i,dir:a.repoDir,remote:e.remote,branches:[]};o.branches.includes(r)||o.branches.push(r),t.set(i,o)}}return{starts:s,groups:[...t.values()].map(e=>({...e,key:"".concat(e.key,"|").concat([...e.branches].sort().join(","))}))}})();if("problem"in t)return void H(t.problem);if(!s.skipFetch)for(let e of t.groups){if(z.current.has(e.key))continue;E({kind:"fetching",what:e.branches.map(l=>"".concat(e.remote,"/").concat(l)).join(", ")});let l=await a.FH.startFetch(e.dir,e.remote,e.branches).catch(e=>({ok:!1,problem:e.message,missing:[]}));if(M(l.repo),!l.ok)return void E({kind:"fetchFailed",group:e,result:l})}E({kind:"starting"});try{l=await m.start(t.starts)}catch(e){l={started:!1,reason:e.message}}if(V.current=l,l.started)return void K(!0);E({kind:"failed",reply:l}),(null==(e=l.failure)?void 0:e.stage)==="preflight"&&Z()},Q=async(e,l)=>{I("".concat(g(e),"|").concat(l)),R(s=>({...s,[g(e)]:x("startdlg.fetching",{what:l})}));try{let s=await a.FH.startFetch(e,l);M(s.repo),R(t=>{var n,a,r,i;return{...t,[g(e)]:s.ok?"":"".concat(x("startdlg.fetchFailed",{what:l})," ").concat(null!=(i=null!=(r=s.problem)?r:null==(n=s.fetched)?void 0:n.detail)?i:"").concat((null==(a=s.fetched)?void 0:a.auth)?" ".concat(x("prep.fetchAuth")):"")}})}catch(l){R(s=>({...s,[g(e)]:l.message}))}finally{I("")}},Y=async e=>{try{await navigator.clipboard.writeText(e),q(!0),window.setTimeout(()=>q(!1),2500)}catch(e){H(x("plan.copyFailed"))}},ee=Object.values(B).some(e=>"remote"===e.from),el="unattended"===m.mode?x("startdlg.goUnattended"):x("startdlg.goStep");return(0,t.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!U&&K(!1),children:(0,t.jsxs)("div",{ref:v,className:"modal wide start-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"".concat(j,"-title"),onClick:e=>e.stopPropagation(),style:{overflowWrap:"anywhere"},children:[(0,t.jsx)("h2",{id:"".concat(j,"-title"),children:x("startdlg.title")}),(0,t.jsx)("p",{className:"small muted",style:{marginTop:0},children:x("startdlg.intro")}),w&&(0,t.jsx)(c.X,{reason:w}),!y&&!w&&(0,t.jsx)("p",{className:"small",role:"status",children:x("startdlg.loading")}),y&&("choose"===D.kind||"fetching"===D.kind||"starting"===D.kind)&&y.sessions.map(e=>{var l,s,n,a;let r=X(e.repoDir),i=B[e.id],o="start-".concat(j,"-").concat(e.id),c=null!=(s=null==r||null==(l=r.remotes.find(e=>e.name===(null==i?void 0:i.remote)))?void 0:l.branches)?s:[];return(0,t.jsxs)("fieldset",{className:"option",style:{border:"1px solid var(--line)",borderRadius:"var(--radius)",padding:"8px 12px",margin:"10px 0"},children:[(0,t.jsx)("legend",{style:{padding:"0 4px"},children:(0,t.jsx)("strong",{children:e.name})}),e.repoDir&&(0,t.jsx)("p",{className:"muted small",style:{margin:"2px 0 6px"},children:x("startdlg.repoOn",{repo:e.repoDir,branch:null!=(n=null==r?void 0:r.current)?n:"HEAD"})}),e.vcs?e.fixed?(0,t.jsx)("p",{className:"small",children:x("startdlg.fixed",{start:e.fixed})}):r&&!r.problem&&i?(0,t.jsxs)(t.Fragment,{children:[e.prepared&&(0,t.jsxs)("div",{className:"option",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"radio",name:o,checked:"keep"===i.from,onChange:()=>J(e.id,{from:"keep"}),disabled:U}),(0,t.jsx)("span",{children:x("startdlg.keep")})]}),(0,t.jsx)("p",{className:"why",children:x("startdlg.prepared",{start:e.prepared})})]}),(0,t.jsxs)("div",{className:"option",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"radio",name:o,checked:"local"===i.from,onChange:()=>J(e.id,{from:"local"}),disabled:U}),(0,t.jsx)("span",{children:x("startdlg.local")})]}),(0,t.jsx)("div",{className:"row",style:{marginTop:4},children:(0,t.jsxs)("select",{"aria-label":x("startdlg.localBranch"),value:i.local,onChange:l=>J(e.id,{from:"local",local:l.target.value}),disabled:U,style:{width:"auto",minWidth:240,maxWidth:"100%"},children:[!r.local.some(e=>e.name===i.local)&&(0,t.jsx)("option",{value:i.local,children:i.local}),r.local.map(e=>(0,t.jsxs)("option",{value:e.name,children:[e.name," \xb7 ",e.commit.slice(0,8)]},e.name))]})}),(0,t.jsx)("p",{className:"why",children:x("startdlg.localWhy")})]}),(0,t.jsxs)("div",{className:"option",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"radio",name:o,checked:"remote"===i.from,onChange:()=>J(e.id,{from:"remote"}),disabled:U||0===r.remotes.length}),(0,t.jsx)("span",{children:x("startdlg.remote")})]}),0===r.remotes.length?(0,t.jsx)("p",{className:"muted small",children:x("startdlg.noRemote")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"row",style:{marginTop:4},children:[r.remotes.length>1&&(0,t.jsx)("select",{"aria-label":x("startdlg.remoteName"),value:i.remote,onChange:l=>J(e.id,{from:"remote",remote:l.target.value}),disabled:U,style:{width:"auto"},children:r.remotes.map(e=>(0,t.jsx)("option",{value:e.name,children:e.name},e.name))}),1===r.remotes.length&&(0,t.jsxs)("code",{children:[i.remote,"/"]}),(0,t.jsx)("input",{type:"text","aria-label":x("startdlg.remoteBranch"),list:"".concat(o,"-remote"),value:i.remoteBranch,onChange:l=>J(e.id,{from:"remote",remoteBranch:l.target.value}),onFocus:()=>"remote"!==i.from&&J(e.id,{from:"remote"}),disabled:U,style:{width:"auto",minWidth:240,flex:"1 1 240px"},placeholder:"main"}),(0,t.jsx)("datalist",{id:"".concat(o,"-remote"),children:c.map(e=>(0,t.jsx)("option",{value:e.name},e.name))}),(0,t.jsx)("button",{type:"button",onClick:()=>void Q(r.repoDir,i.remote),disabled:U||!i.remote,children:x("startdlg.refreshRemote")})]}),(0,t.jsx)("p",{className:"why",children:x("startdlg.remoteWhy")}),(0,t.jsx)("p",{className:"muted small",style:{margin:"2px 0"},children:r.lastFetched?x("startdlg.lastFetched",{when:f(r.lastFetched)}):c.length>0?x("startdlg.lastFetchedUnknown"):x("startdlg.neverFetched")}),L[g(r.repoDir)]&&(0,t.jsx)("p",{className:"small",role:"status",children:L[g(r.repoDir)]})]})]}),e.previousOffered&&(0,t.jsxs)("div",{className:"option",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"radio",name:o,checked:"previous-session"===i.from,onChange:()=>J(e.id,{from:"previous-session"}),disabled:U}),(0,t.jsx)("span",{children:x("startdlg.previous")})]}),(0,t.jsx)("p",{className:"why",children:x("startdlg.previousWhy")})]}),(0,t.jsxs)("div",{className:"option",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:i.onBranch&&("local"===i.from||"remote"===i.from),onChange:l=>J(e.id,{onBranch:l.target.checked}),disabled:U||"local"!==i.from&&"remote"!==i.from}),(0,t.jsx)("span",{children:x("startdlg.onBranch")})]}),(0,t.jsx)("p",{className:"why",children:x("startdlg.onBranchWhy")})]})]}):(0,t.jsx)("p",{className:"err small",children:x("startdlg.repoProblem",{problem:null!=(a=null==r?void 0:r.problem)?a:""})}):(0,t.jsx)("p",{className:"small",children:x("startdlg.vcsOff")})]},e.id)}),"fetching"===D.kind&&(0,t.jsx)("p",{className:"notice small",role:"status",children:x("startdlg.fetching",{what:D.what})}),"starting"===D.kind&&(0,t.jsx)("p",{className:"notice small",role:"status",children:x("startdlg.starting")}),"fetchFailed"===D.kind&&(0,t.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,t.jsxs)("p",{style:{marginTop:0},children:[(0,t.jsx)("strong",{children:x("startdlg.fetchFailed",{what:D.group.branches.map(e=>"".concat(D.group.remote,"/").concat(e)).join(", ")})})," ",(0,t.jsx)("code",{children:null!=(u=null!=(h=D.result.problem)?h:null==(l=D.result.fetched)?void 0:l.detail)?u:""})]}),D.result.missing.length>0&&(0,t.jsx)("p",{className:"small",children:x("startdlg.missing",{names:D.result.missing.join(", ")})}),(null==(s=D.result.fetched)?void 0:s.auth)&&(0,t.jsx)("p",{className:"small",children:x("prep.fetchAuth")}),(0,t.jsxs)("div",{className:"row",children:[(0,t.jsx)("button",{type:"button",className:"primary",onClick:()=>void G(),children:x("startdlg.retryFetch")}),(()=>{var e,l;let s=X(D.group.dir),n=null!=(l=null==s||null==(e=s.remotes.find(e=>e.name===D.group.remote))?void 0:e.branches)?l:[];return D.group.branches.every(e=>n.some(l=>l.name===e))?(0,t.jsx)("button",{type:"button",onClick:()=>{z.current.add(D.group.key),G()},children:x("startdlg.useFetched")}):null})(),(0,t.jsx)("button",{type:"button",className:"quiet",onClick:$,children:x("startdlg.back")})]}),(()=>{var e,l;let s=X(D.group.dir),n=null!=(l=null==s||null==(e=s.remotes.find(e=>e.name===D.group.remote))?void 0:e.branches)?l:[],a=D.group.branches.filter(e=>!n.some(l=>l.name===e));return a.length>0?(0,t.jsx)("p",{className:"muted small",children:x("startdlg.useFetchedNo",{what:a.map(e=>"".concat(D.group.remote,"/").concat(e)).join(", ")})}):D.result.lastFetched?(0,t.jsx)("p",{className:"muted small",children:x("prep.lastFetched",{when:f(D.result.lastFetched)})}):null})(),D.result.fetchCommand&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"small",style:{marginTop:8},children:x("prep.ownTerminal")}),(0,t.jsx)("pre",{className:"sync-cmd",children:D.result.fetchCommand}),(0,t.jsxs)("div",{className:"row",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{var e;Y(null!=(e=D.result.fetchCommand)?e:"")},children:x("prep.copyFetch")}),P&&(0,t.jsx)("span",{className:"badge done",children:x("prep.copied")})]})]})]}),"failed"===D.kind&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.X,{failure:D.reply.failure,reason:D.reply.reason}),(null==(d=D.reply.failure)?void 0:d.stage)==="preflight"&&A.some(e=>!e.ready)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"small",children:x("startdlg.vcsFix")}),(0,t.jsx)(o.w,{groups:A,sessionIds:m.sessionIds,onChange:()=>{Z(),_()}})]})]}),T&&(0,t.jsx)("p",{className:"err small",role:"alert",children:T}),"choose"===D.kind&&ee&&(0,t.jsx)("p",{className:"why",children:x("prep.password")}),(0,t.jsxs)("div",{className:"row modal-actions",children:[(0,t.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(!1),disabled:U,children:x("dialog.cancel")}),"failed"===D.kind?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:$,children:x("startdlg.back")}),(0,t.jsx)("button",{type:"button",className:"primary",onClick:()=>void G({skipFetch:!0}),children:x("startdlg.tryAgain")})]}):"fetchFailed"!==D.kind&&(0,t.jsx)("button",{ref:b,type:"button",className:"primary",onClick:()=>void G(),disabled:U||!y,children:el})]})]})})}},3069:(e,l,s)=>{s.d(l,{StartFailureBanner:()=>h,X:()=>o});var t=s(3365),n=s(1521),a=s(5549),r=s(867),i=s(7527);function o(e){var l,s;let{failure:n,reason:i,onDismiss:o,intro:c,children:d}=e,{t:h}=(0,r.kj)(),u=(0,r.W3)(),m=null!=(s=null!=(l=null==n?void 0:n.message)?l:i)?s:"";return(0,t.jsxs)("div",{className:"notice caution start-failure",role:"alert",style:{overflowWrap:"anywhere"},children:[c&&(0,t.jsx)("p",{className:"small",style:{marginTop:0},children:c}),(0,t.jsx)("strong",{children:h("startfail.title")}),n&&(0,t.jsx)("p",{className:"small",style:{margin:"4px 0"},children:h("startfail.where",{stage:h("startfail.stage.".concat(n.stage))})}),(0,t.jsx)("pre",{className:"sync-cmd small",style:{margin:"6px 0"},children:m}),d,n&&(0,t.jsxs)("p",{className:"muted small",style:{margin:"4px 0"},children:[n.runId?h("startfail.when",{when:u(n.at),run:n.runId}):h("startfail.whenNoRun",{when:u(n.at)}),n.sessions.length>0?" \xb7 ".concat(n.sessions.map(e=>'"'.concat(e,'"')).join(", ")):""]}),(0,t.jsxs)("div",{className:"row",style:{marginTop:6},children:[n&&(0,t.jsx)("a",{className:"button-link",href:a.FH.startFailureUrl(n.id),download:!0,children:h("startfail.download")}),(0,t.jsx)("a",{className:n?"button-link":"button-link plain",href:a.FH.terminalUrl(),download:!0,children:h("startfail.terminal")}),o&&(0,t.jsx)("button",{type:"button",className:"quiet",onClick:o,children:h("startfail.dismiss")})]}),(0,t.jsx)("p",{className:"why",children:h("startfail.downloadWhy")})]})}let c="cop.startFailure.dismissed";function d(){try{var e;let l=JSON.parse(null!=(e=window.localStorage.getItem(c))?e:"[]");return Array.isArray(l)?l.filter(e=>"string"==typeof e):[]}catch(e){return[]}}function h(){let{t:e}=(0,r.kj)(),[l,s]=(0,n.useState)([]),[h,u]=(0,n.useState)([]);(0,i.z)(()=>a.FH.startFailures(!0).then(e=>{s(e),u(d())}).catch(()=>void 0),5e3);let m=l.find(e=>!h.includes(e.id));return m?(0,t.jsx)("div",{style:{marginBottom:12},children:(0,t.jsx)(o,{failure:m,intro:e("at-turn"===m.stage?"startfail.laterSession":"startfail.later"),onDismiss:()=>{let e=[...new Set([...d(),m.id])].slice(-50);try{window.localStorage.setItem(c,JSON.stringify(e))}catch(e){}u(e)}})}):null}},3486:(e,l,s)=>{s.d(l,{w:()=>o});var t=s(3365),n=s(1521),a=s(5549),r=s(867);let i={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function o(e){let{groups:l,sessionIds:s,onChange:a}=e,{t:i}=(0,r.kj)(),[o,d]=(0,n.useState)(""),h=l.filter(e=>!e.ready);return 0===h.length?o?(0,t.jsxs)("p",{className:"notice small",role:"status",children:[(0,t.jsx)("strong",{children:i("runvcs.ready")})," ",o]}):null:(0,t.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,t.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:i("runvcs.title")}),(0,t.jsx)("p",{className:"small",children:i("runvcs.why")}),h.map(e=>(0,t.jsx)(c,{group:e,sessionIds:s,onChange:a,onDone:d},e.repoDir))]})}function c(e){var l;let{group:s,sessionIds:o,onChange:c,onDone:d}=e,{t:h}=(0,r.kj)(),[u,m]=(0,n.useState)(!1),[p,g]=(0,n.useState)(!1),[x,f]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[b,y]=(0,n.useState)({}),k=(e,l)=>{var s,t;return null!=(t=null!=(s=b[e])?s:l)?t:void 0},w=s.actions.find(e=>"snapshot-here"===e.id&&e.available),N=e=>(null!=e?e:"—").slice(0,8),F=async e=>{if("review-inputs"===e)return void m(e=>!e);f(!0),v("");try{var l,t,n;let r="snapshot-on-base"===e?Object.fromEntries(s.inputs.map(e=>[e.path,"include"])):Object.fromEntries(s.entries.filter(e=>k(e.path,e.choice)).map(e=>[e.path,k(e.path,e.choice)])),i=await a.FH.runVcsPrepare(o,s.repoDir,e,r);v(i.ok?null!=(l=i.result)?l:"":null!=(t=i.problem)?t:""),i.ok&&d("".concat(s.repoDir,": ").concat(null!=(n=i.result)?n:"")),c()}catch(e){v(e.message)}finally{f(!1)}};return(0,t.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,t.jsx)("table",{className:"small",children:(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.repo")}),(0,t.jsx)("td",{children:(0,t.jsx)("code",{children:s.repoDir})})]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.current")}),(0,t.jsxs)("td",{children:[(0,t.jsx)("code",{children:null!=(l=s.branch)?l:"HEAD"})," @ ",(0,t.jsx)("code",{children:N(s.head)})]})]}),s.workBranch&&(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.workBranch")}),(0,t.jsxs)("td",{children:[(0,t.jsx)("code",{children:s.workBranch.name})," @ ",(0,t.jsx)("code",{children:N(s.workBranch.head)})]})]}),s.baseBranch&&(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.base")}),(0,t.jsxs)("td",{children:[(0,t.jsx)("code",{children:s.baseBranch})," @ ",(0,t.jsx)("code",{children:N(s.baseHead)})]})]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.sessions")}),(0,t.jsx)("td",{children:s.sessions.map(e=>"".concat(e.name," (").concat(h("runvcs.role.".concat(e.role)),")")).join(", ")})]}),s.inputPatterns.length>0&&(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:h("runvcs.patterns")}),(0,t.jsx)("td",{children:s.inputPatterns.map(e=>(0,t.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),s.problem&&(0,t.jsxs)("p",{className:"small",children:[(0,t.jsx)("strong",{children:h("runvcs.problem")})," ",s.problem]}),s.inputs.length>0&&(0,t.jsx)("p",{className:"small",children:h("runvcs.inputsCount",{n:s.inputs.length})}),u&&s.inputs.length>0&&(0,t.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:s.inputs.map(e=>(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:e.path})," — ",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,a.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,t.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),s.unrelated.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"small",children:(0,t.jsx)("strong",{children:h("runvcs.unrelated",{n:s.unrelated.length})})}),(0,t.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:s.unrelated.slice(0,30).map(e=>(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&s.entries.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"small",children:(0,t.jsx)("strong",{children:h("runvcs.choose",{n:s.entries.length})})}),(0,t.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:s.entries.map(e=>{var l;return(0,t.jsxs)("li",{style:{marginBottom:4},children:[(0,t.jsx)("code",{children:e.path})," ",(0,t.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(h("vcs.snapshotInput"),", "):"",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,a.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,t.jsx)("span",{className:"err",children:h("vcs.snapshotBlocked")}):(0,t.jsx)("select",{"aria-label":e.path,value:null!=(l=k(e.path,e.choice))?l:"",onChange:l=>y({...b,[e.path]:l.target.value}),disabled:x||e.allowed.length<2,children:e.allowed.map(e=>(0,t.jsx)("option",{value:e,children:h("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,t.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,t.jsxs)("p",{className:"small muted",children:[h("runvcs.cancelled")," ",(0,t.jsx)("button",{className:"quiet",onClick:()=>g(!1),children:h("runvcs.showAgain")})]}):(0,t.jsxs)("div",{children:[s.actions.map(e=>{var l,n,a;return(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void F(e.id),disabled:x||!e.available,children:[h(i[e.id],{branch:null!=(l=s.baseBranch)?l:"",current:null!=(n=s.branch)?n:"HEAD"}),"review-inputs"===e.id&&u?" ✓":""]}),e.recommended&&(0,t.jsx)("span",{className:"badge done",style:{marginLeft:6},children:h("runvcs.recommended")}),(0,t.jsx)("p",{className:"why",children:e.available?e.result:"".concat(h("runvcs.notNow")," ").concat(null!=(a=e.why)?a:"")})]},e.id)}),(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("button",{className:"quiet",onClick:()=>g(!0),disabled:x,children:h("runvcs.cancel")}),(0,t.jsx)("p",{className:"why",children:h("runvcs.cancelWhy")})]})]}),j&&(0,t.jsx)("p",{className:"small",role:"status",children:j})]})}},4969:(e,l,s)=>{s.d(l,{V:()=>a});var t=s(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function a(e,l,s){(0,t.useEffect)(()=>{var t,a;if(!l)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(a=null!=(t=null==s?void 0:s.current)?t:null==i?void 0:i.querySelector(n))?a:null;null==o||o.focus();let c=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let s=l[0],t=l[l.length-1],a=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===s||!a)?(e.preventDefault(),t.focus()):e.shiftKey||document.activeElement!==t&&a||(e.preventDefault(),s.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c),r&&document.contains(r)&&r.focus()}},[e,l,s])}},7527:(e,l,s)=>{s.d(l,{z:()=>n});var t=s(1521);function n(e,l){let s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{let e;if(!s)return;let t=!1,a=async()=>{try{await n.current()}catch(e){}finally{t||(e=setTimeout(()=>void a(),l))}};return a(),()=>{t=!0,e&&clearTimeout(e)}},[l,s])}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,e,o)=>{o.d(e,{AV:()=>a,FH:()=>h,FZ:()=>r,Zm:()=>u,aT:()=>s,c5:()=>y,dK:()=>l,nC:()=>n,rt:()=>d,ub:()=>i,zi:()=>p});let n="/api";function s(t,e){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(e?"#".concat(e):"")}let c="cop-api-token";function a(){try{let t=/(?:^#|&)token=([0-9a-f]{16,})/i.exec(window.location.hash);if(t)return window.localStorage.setItem(c,t[1]),window.history.replaceState(null,"",window.location.pathname+window.location.search),t[1];return window.localStorage.getItem(c)||""}catch(t){return""}}function i(t){let e=a();return e?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(e)):t}let r=["exit-zero","exit-nonzero","output-contains","output-omits","output-matches","file-exists","file-missing","file-contains"];function d(t){return t.startsWith("exit-")||t.startsWith("output-")}function l(t){return"output-contains"===t||"output-omits"===t||"output-matches"===t||"file-contains"===t}function u(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}async function m(t,e){let o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;o=await fetch("".concat(n).concat(t),{...e,...null!==c&&!(null==e?void 0:e.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==e?void 0:e.headers)?i:{}}})}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 h={health:()=>m("/health"),doctor:()=>m("/doctor"),settings:()=>m("/settings"),saveSettings:t=>m("/settings",{method:"PUT",body:JSON.stringify(t)}),level1:()=>m("/level1"),setLevel1:t=>m("/level1",{method:"PUT",body:JSON.stringify({content:t})}),resetLevel1:()=>m("/level1",{method:"DELETE"}),presets:()=>m("/presets"),savePreset:(t,e)=>m("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePreset:t=>m("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>m("/personas"),savePersona:(t,e)=>m("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:e})}),deletePersona:t=>m("/personas/".concat(encodeURIComponent(t)),{method:"DELETE"}),sessions:()=>m("/sessions"),reorderSessions:t=>m("/sessions-order",{method:"PUT",body:JSON.stringify({ids:t})}),metrics:()=>m("/metrics"),preparePreview:function(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return m("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:t,fetch:e})},{timeoutMs:33e4})},prepareProject:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/repo/prepare",{method:"POST",body:JSON.stringify({dir:t,fingerprint:e,...o})})},session:t=>m("/sessions/".concat(t)),createSession:(t,e)=>m("/sessions",{method:"POST",body:JSON.stringify({name:t,projectDir:e})}),updateSession:(t,e)=>m("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(e)}),deleteSession:t=>m("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,e)=>m("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(e)}),updateTask:(t,e,o)=>m("/sessions/".concat(t,"/tasks/").concat(e),{method:"PUT",body:JSON.stringify(o)}),deleteTask:(t,e)=>m("/sessions/".concat(t,"/tasks/").concat(e),{method:"DELETE"}),continueTask:(t,e)=>m("/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 m("/sessions/".concat(t,"/tasks/").concat(e,"/rerun"),{method:"POST",body:JSON.stringify({...o,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,e,o)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/changes").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskChangeFile:(t,e,o,n)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/changes/file?path=").concat(encodeURIComponent(o)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,e,o)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/story").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskFiles:(t,e,o)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/files").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskLogUrl:(t,e,o)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),taskFileUrl:(t,e,o,s,c)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(e,"/files/").concat(o,"/").concat(encodeURIComponent(s)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,e,o)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/log").concat(o?"?run=".concat(encodeURIComponent(o)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,e,o,n,s)=>m("/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,n)=>m("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:e,name:o,starts:n})},{timeoutMs:12e4}),startOptions:t=>m("/start/options?sessions=".concat(encodeURIComponent(t.join(",")))),startFetch:(t,e,o)=>m("/start/fetch",{method:"POST",body:JSON.stringify({dir:t,remote:e,...o?{branches:o}:{}})},{timeoutMs:33e4}),startFailures:function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return m("/start/failures".concat(t?"?unanswered=1":""))},startFailureUrl:t=>i("".concat(n,"/start/failures/").concat(encodeURIComponent(t),"/report")),terminalUrl:()=>i("".concat(n,"/terminal")),stop:t=>m("/sessions/".concat(t,"/stop"),{method:"POST",body:"{}"}),approvals:t=>m("/approvals".concat(t?"?session=".concat(encodeURIComponent(t)):"")),decide:(t,e)=>m("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:e})}),setRunMode:(t,e)=>m("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:e})}),streamUrl:t=>i("".concat(n,"/sessions/").concat(t,"/stream")),batch:()=>m("/batch").then(t=>null!=t?t:null),startBatch:(t,e,o,n,s,c,a,i)=>m("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:e,onFailure:o,model:n,reviewModel:s,name:c,taskIds:a,starts:i})},{timeoutMs:12e4}),suggestedRunName:t=>m("/batch/name?sessions=".concat(encodeURIComponent(t.join(",")))),stopBatch:()=>m("/batch/stop",{method:"POST",body:"{}"}),pauseBatch:()=>m("/batch/pause",{method:"POST",body:"{}"}),resumeBatch:()=>m("/batch/resume",{method:"POST",body:"{}"}),planBrief:t=>m("/plan/brief?lang=".concat(encodeURIComponent(t))),context:(t,e)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(e))),setContext:(t,e)=>m("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:e})}),resetContext:(t,e)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(e)),{method:"DELETE"}),checkPlan:t=>m("/plan/check",{method:"POST",body:JSON.stringify({text:t})}),importPlan:t=>m("/plan/import",{method:"POST",body:JSON.stringify({text:t})}),browseFolder:t=>m("/browse-folder",{method:"POST",body:JSON.stringify({start:t})},{timeoutMs:null}),tasks:()=>m("/tasks"),activity:()=>m("/activity"),downloadBundle:async t=>{var e,o,s;let c=await fetch("".concat(n,"/export/bundle"),{method:"POST",headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{}},body:JSON.stringify({tasks:t})});if(!c.ok)throw Error(await c.text()||"".concat(c.status," ").concat(c.statusText));let i=null!=(s=c.headers.get("content-disposition"))?s:"",r=null==(e=/filename\*=UTF-8''([^;]+)/i.exec(i))?void 0:e[1],d=null==(o=/filename="([^"]+)"/i.exec(i))?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),i("".concat(n,"/export/").concat(t,"?").concat(o.toString()))},debugExportUrl:t=>i("".concat(n,"/debug/export").concat(t.length>0?"?sessions=".concat(encodeURIComponent(t.join(","))):"")),vcsStatus:t=>m("/sessions/".concat(t,"/vcs")),runVcs:t=>m("/batch/vcs?ids=".concat(encodeURIComponent(t.join(",")))),runVcsPrepare:function(t,e,o){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return m("/batch/vcs/prepare",{method:"POST",body:JSON.stringify({sessionIds:t,repoDir:e,action:o,choices:n})})},vcsSnapshot:(t,e)=>m("/sessions/".concat(t,"/vcs/snapshot"),{method:"POST",body:JSON.stringify({choices:e})}),restorePreview:(t,e)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/restore")),restore:(t,e)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/restore"),{method:"POST",body:"{}"}),contractCheck:(t,e)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/contract")),applyContractFix:(t,e,o,n)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/contract-fix"),{method:"POST",body:JSON.stringify({choices:o,expect:n})}),restartPlan:(t,e)=>m("/sessions/".concat(t,"/tasks/").concat(e,"/restart")),restartFrom:function(t,e){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/sessions/".concat(t,"/tasks/").concat(e,"/restart"),{method:"POST",body:JSON.stringify(o)})},repoCheck:t=>m("/repo?dir=".concat(encodeURIComponent(t))),project:()=>m("/project"),setProject:t=>m("/project",{method:"PUT",body:JSON.stringify(t)}),models:()=>m("/models"),setDefaultModel:t=>m("/models/default",{method:"PUT",body:JSON.stringify({model:t})}),setDefaultReviewModel:t=>m("/models/review-default",{method:"PUT",body:JSON.stringify({model:t})}),refreshModels:()=>m("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null}),login:t=>m("/login",{method:"POST",body:JSON.stringify({account:(null==t?void 0:t.trim())||void 0})},{timeoutMs:null})};function p(t){return t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}function y(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")}}}]);