copilot-operator 0.1.50 → 0.1.51

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 (81) hide show
  1. package/README.md +582 -574
  2. package/dist/src/api/operator.controller.js +77 -932
  3. package/dist/src/api/operator.service.js +197 -2461
  4. package/dist/src/orchestrator/hold.js +49 -0
  5. package/dist/src/orchestrator/taskRunner.js +157 -23
  6. package/dist/src/plan/kerrigan.js +107 -0
  7. package/dist/src/plan/systemGuide.js +438 -3374
  8. package/dist/src/session/chatNotice.js +76 -0
  9. package/dist/src/session/store.js +2 -57
  10. package/dist/src/session/workspace.js +52 -5
  11. package/dist/src/transport/chatTransport.js +1 -1
  12. package/dist/src/transport/copilotTransport.js +133 -1
  13. package/dist/web/404.html +5 -3
  14. package/dist/web/_next/static/chunks/134-ddd50a7fbb536ec8.js +1 -0
  15. package/dist/web/_next/static/chunks/190-70555f20dd0da19b.js +1 -0
  16. package/dist/web/_next/static/chunks/643-e85d221d57900ed7.js +1 -0
  17. package/dist/web/_next/static/chunks/867-869900ec999e6345.js +1 -0
  18. package/dist/web/_next/static/chunks/app/appearance/page-cdef33c421397cbe.js +1 -0
  19. package/dist/web/_next/static/chunks/app/defaults/page-e0a2b8f9a41a94c4.js +1 -0
  20. package/dist/web/_next/static/chunks/app/layout-b4fc21e26e1bad95.js +1 -0
  21. package/dist/web/_next/static/chunks/app/level1/page-31b74cae86d960d8.js +1 -0
  22. package/dist/web/_next/static/chunks/app/page-1075921d44db3e4d.js +1 -0
  23. package/dist/web/_next/static/chunks/app/presets/page-f8abdd83cdf468f7.js +1 -0
  24. package/dist/web/_next/static/chunks/app/system/page-2a270bb885885821.js +1 -0
  25. package/dist/web/_next/static/css/8b14cb3cf0051138.css +1 -0
  26. package/dist/web/_next/static/eqTUTH_SJtBgNgq8Zzy3n/_buildManifest.js +1 -0
  27. package/dist/web/appearance.html +5 -3
  28. package/dist/web/appearance.txt +22 -23
  29. package/dist/web/defaults.html +5 -3
  30. package/dist/web/defaults.txt +22 -23
  31. package/dist/web/index.html +5 -3
  32. package/dist/web/index.txt +22 -23
  33. package/dist/web/level1.html +5 -3
  34. package/dist/web/level1.txt +22 -23
  35. package/dist/web/presets.html +6 -4
  36. package/dist/web/presets.txt +22 -23
  37. package/dist/web/system.html +5 -3
  38. package/dist/web/system.txt +22 -23
  39. package/package.json +3 -20
  40. package/dist/src/api/saveToDesktop.js +0 -157
  41. package/dist/src/plan/brief.js +0 -2003
  42. package/dist/src/plan/changes.js +0 -217
  43. package/dist/src/plan/script.js +0 -1014
  44. package/dist/src/session/debugExport.js +0 -165
  45. package/dist/src/session/exportRecord.js +0 -277
  46. package/dist/src/session/metrics.js +0 -95
  47. package/dist/src/vcs/startChoice.js +0 -367
  48. package/dist/web/_next/static/chunks/197-f7c33a0114fc3db3.js +0 -1
  49. package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +0 -1
  50. package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +0 -1
  51. package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +0 -1
  52. package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +0 -1
  53. package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +0 -1
  54. package/dist/web/_next/static/chunks/app/appearance/page-a18019cdc395de3d.js +0 -1
  55. package/dist/web/_next/static/chunks/app/defaults/page-614be29d185a2947.js +0 -1
  56. package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +0 -1
  57. package/dist/web/_next/static/chunks/app/import/page-8ef75fc08638e75f.js +0 -1
  58. package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +0 -1
  59. package/dist/web/_next/static/chunks/app/level1/page-dd3ebf37d29dce4f.js +0 -1
  60. package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +0 -1
  61. package/dist/web/_next/static/chunks/app/presets/page-93ab518db67e52a2.js +0 -1
  62. package/dist/web/_next/static/chunks/app/sessions/page-28376d2e4a9b4738.js +0 -1
  63. package/dist/web/_next/static/chunks/app/sessions/view/page-adb64f8ba3d8c06e.js +0 -1
  64. package/dist/web/_next/static/chunks/app/system/page-227a259e383ca2a0.js +0 -1
  65. package/dist/web/_next/static/css/4335e4ce269ba1ea.css +0 -1
  66. package/dist/web/_next/static/z74_FBfnnXW5IJCHTgTH2/_buildManifest.js +0 -1
  67. package/dist/web/history.html +0 -16
  68. package/dist/web/history.txt +0 -26
  69. package/dist/web/import.html +0 -16
  70. package/dist/web/import.txt +0 -26
  71. package/dist/web/sessions/view.html +0 -16
  72. package/dist/web/sessions/view.txt +0 -26
  73. package/dist/web/sessions.html +0 -16
  74. package/dist/web/sessions.txt +0 -26
  75. package/prompts/organisation.bg.md +0 -43
  76. package/prompts/organisation.en.md +0 -43
  77. package/prompts/persona.bg.md +0 -17
  78. package/prompts/persona.en.md +0 -17
  79. package/prompts/work.bg.md +0 -19
  80. package/prompts/work.en.md +0 -19
  81. /package/dist/web/_next/static/{z74_FBfnnXW5IJCHTgTH2 → eqTUTH_SJtBgNgq8Zzy3n}/_ssgManifest.js +0 -0
@@ -1,367 +0,0 @@
1
- import { freeBranchName, git, isAncestor, isValidBranchName, lastFetchedAt } from './git.js';
2
- import { fetchAsOperator, fetchCommandFor } from './remoteAuth.js';
3
- import { describeStart, remoteTip, repoDirOf, sessionBranchName } 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)) {
113
- entry.fixed = s.vcsStart ? describeStart(s.vcsStart) : `it started from ${s.vcsBaseCommit?.slice(0, 8)}`;
114
- if (!repo.problem) {
115
- entry.started = await startedOn(s, repo);
116
- // What "another branch" offers first: the session's own setting, as for a session that has not run.
117
- entry.choice = defaultChoice(s, repo);
118
- const carries = carriedOn(s);
119
- if (carries.length > 0)
120
- entry.rechooseBlocked = carries.join(', ');
121
- }
122
- }
123
- else {
124
- if (s.vcsStart)
125
- entry.prepared = describeStart(s.vcsStart);
126
- if (!repo.problem)
127
- entry.choice = defaultChoice(s, repo);
128
- }
129
- out.push(entry);
130
- }
131
- return { repos: [...repos.values()], sessions: out };
132
- }
133
- /** The queued tasks that carry an earlier attempt on, on that attempt's branch: by title, quoted. */
134
- function carriedOn(s) {
135
- return s.tasks.filter((t) => t.status === 'queued' && (t.continuing || t.buildsOn)).map((t) => `"${t.title}"`);
136
- }
137
- /** Where a session that has run stands: see `StartOptionSession.started`. */
138
- async function startedOn(s, repo) {
139
- const dir = repo.repoDir;
140
- const mode = s.vcs?.startFrom === 'existing-branch' ? 'existing-branch' : s.vcs?.branchMode === 'per-session' ? 'per-session' : 'per-task';
141
- const branch = mode === 'existing-branch' ? s.vcs?.existingBranch?.trim() : mode === 'per-session' ? sessionBranchName(s) : s.vcsStart?.branch;
142
- const recorded = s.vcsStart?.commit ?? s.vcsBaseCommit;
143
- let tipNow = null;
144
- let remote;
145
- if (branch) {
146
- if (mode === 'per-task' && s.vcsStart?.remote && branch.startsWith(`${s.vcsStart.remote}/`)) {
147
- tipNow = await remoteTip(dir, s.vcsStart.remote, branch.slice(s.vcsStart.remote.length + 1));
148
- }
149
- else {
150
- tipNow = repo.local.find((b) => b.name === branch)?.commit ?? null;
151
- const r = s.vcs?.baseRemote?.trim() || defaultRemote(repo);
152
- const theirs = r ? repo.remotes.find((x) => x.name === r)?.branches.find((b) => b.name === branch) : undefined;
153
- if (r && theirs)
154
- remote = { name: `${r}/${branch}`, commit: theirs.commit };
155
- }
156
- }
157
- return { mode, ...(branch ? { branch } : {}), ...(recorded ? { recorded } : {}), tipNow, ...(remote ? { remote } : {}) };
158
- }
159
- /**
160
- * Checks a choice against the repository and works out what it sets. Nothing is written to the session
161
- * here; for `remote` with `onBranch` the local branch is made, or moved forward, since that is the
162
- * choice — and only then, after everything else about it has been checked, and never with `dry`, which
163
- * only says whether it could be done (every session of a run is checked so before any branch moves).
164
- */
165
- export async function applyStartChoice(session, choice, opts = {}) {
166
- // Nothing to choose without version control; a start that is fixed is kept unless chosen again.
167
- if (!session.vcs?.enabled)
168
- return { ok: true };
169
- if (!startIsFixed(session))
170
- return await chooseStart(session, choice, opts);
171
- if (!choice.rechoose)
172
- return { ok: true };
173
- /*
174
- * Chosen again after the session ran (operator's report, 2026-10-13: "the retry remains permanently bound
175
- * to the session's original branch and commit"). Not while a queued task carries an earlier attempt on:
176
- * that attempt's work is on its own branch, and the task goes on there.
177
- */
178
- const carries = carriedOn(session);
179
- if (carries.length > 0) {
180
- return {
181
- ok: false,
182
- problem: `${carries.join(', ')} ${carries.length === 1 ? 'carries' : 'carry'} an earlier attempt on, on its own branch, so where "${session.name}" starts stays as it is. ` +
183
- 'To start it from another branch, queue it with "Fix the prompt and queue it again" instead.',
184
- };
185
- }
186
- const done = await chooseStart(session, choice, opts);
187
- if (!done.ok || !done.applied)
188
- return done;
189
- const applied = done.applied;
190
- // A branch carried on is the new one itself; the one branch of a per-session session goes on under a new name.
191
- const perSession = session.vcs.branchMode === 'per-session' && (applied.vcs.startFrom ?? session.vcs.startFrom) !== 'existing-branch';
192
- const freshBranch = perSession && !opts.dry ? await freeBranchName(repoDirOf(session), sessionBranchName(session)) : undefined;
193
- return {
194
- ok: true,
195
- applied: {
196
- ...applied,
197
- clearStart: true,
198
- restart: freshBranch ? { freshBranch } : {},
199
- said: `${applied.said} — chosen again after the session had run: the tasks that run next start from it, a task run again included` +
200
- (freshBranch ? `, on the new branch ${freshBranch} (${sessionBranchName(session)} keeps what was done on it)` : ''),
201
- },
202
- };
203
- }
204
- /** `applyStartChoice` for a session whose start is not fixed: see there. */
205
- async function chooseStart(session, choice, opts) {
206
- if (!session.vcs?.enabled)
207
- return { ok: true };
208
- const dir = repoDirOf(session);
209
- const before = pointOf(session.vcs);
210
- if (choice.from === 'previous-session') {
211
- const vcs = { startFrom: 'previous-session' };
212
- 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` } };
213
- }
214
- const name = choice.branch.trim();
215
- if (!name || !(await isValidBranchName(dir, name)))
216
- return { ok: false, problem: `"${choice.branch}" is not a branch name git accepts.` };
217
- if (choice.from === 'local') {
218
- const tip = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
219
- if (!tip)
220
- return { ok: false, problem: `${dir} has no local branch "${name}". Choose one it has, or the remote branch of that name.` };
221
- const vcs = choice.onBranch
222
- ? { startFrom: 'existing-branch', existingBranch: name, baseRemote: undefined, updateFromRemote: false }
223
- : { startFrom: 'branch', baseBranch: name, baseRemote: undefined, existingBranch: undefined, updateFromRemote: false };
224
- return {
225
- ok: true,
226
- applied: {
227
- vcs,
228
- clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
229
- said: choice.onBranch
230
- ? `"${session.name}" works on the local branch ${name} itself (${tip.slice(0, 8)}), as it is here`
231
- : `"${session.name}" starts from the local branch ${name} (${tip.slice(0, 8)}), as it is here`,
232
- },
233
- };
234
- }
235
- const remote = choice.remote.trim();
236
- const remotes = lines((await git(dir, ['remote'])).stdout);
237
- if (!remotes.includes(remote))
238
- return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.` };
239
- const theirs = await remoteTip(dir, remote, name);
240
- if (!theirs)
241
- return { ok: false, problem: `${remote}/${name} is not known here: it was not fetched. Start again, and it is fetched first.` };
242
- if (!choice.onBranch) {
243
- const vcs = { startFrom: 'branch', baseBranch: name, baseRemote: remote, existingBranch: undefined, updateFromRemote: false };
244
- return {
245
- ok: true,
246
- applied: {
247
- vcs,
248
- clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
249
- said: `"${session.name}" starts from the remote branch ${remote}/${name} (${theirs.slice(0, 8)}), as fetched now; the local branch ${name} is not touched`,
250
- },
251
- };
252
- }
253
- // Work on the branch itself: the local branch made from the remote one, or brought up to it.
254
- const ours = (await git(dir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}^{commit}`])).stdout;
255
- let note;
256
- if (!ours) {
257
- // By its full name: `origin/x` alone is looked up among tags and local branches first.
258
- const made = opts.dry ? { ok: true, stdout: '', stderr: '' } : await git(dir, ['branch', '--track', name, `refs/remotes/${remote}/${name}`]);
259
- if (!made.ok)
260
- return { ok: false, problem: `the local branch ${name} could not be made from ${remote}/${name}: ${(made.stderr || made.stdout).split(/\r?\n/)[0]}` };
261
- note = `made the local branch ${name} from ${remote}/${name} (${theirs.slice(0, 8)})`;
262
- }
263
- else if (ours === theirs) {
264
- note = `the local branch ${name} is already where ${remote}/${name} is (${theirs.slice(0, 8)})`;
265
- }
266
- else if (await isAncestor(dir, ours, theirs)) {
267
- const current = (await git(dir, ['symbolic-ref', '--quiet', '--short', 'HEAD'])).stdout;
268
- if (current === name) {
269
- const dirty = (await git(dir, ['status', '--porcelain', '--untracked-files=no'])).stdout.trim();
270
- if (dirty)
271
- 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.` };
272
- }
273
- const moved = opts.dry
274
- ? { ok: true, stdout: '', stderr: '' }
275
- : current === name
276
- ? await git(dir, ['merge', '--ff-only', '--quiet', theirs])
277
- : await git(dir, ['update-ref', '-m', `copilot-operator: brought up to ${remote}/${name} in the start window`, `refs/heads/${name}`, theirs, ours]);
278
- if (!moved.ok)
279
- 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.` };
280
- note = `brought the local branch ${name} up to ${remote}/${name}: ${ours.slice(0, 8)} → ${theirs.slice(0, 8)}, fast-forward`;
281
- }
282
- else if (await isAncestor(dir, theirs, ours)) {
283
- 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`;
284
- }
285
- else {
286
- return {
287
- ok: false,
288
- 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. ` +
289
- `Nothing was changed. Start from ${remote}/${name} on a new branch instead, or bring the two together yourself first.`,
290
- };
291
- }
292
- const vcs = { startFrom: 'existing-branch', existingBranch: name, baseRemote: remote, updateFromRemote: false };
293
- return {
294
- ok: true,
295
- applied: {
296
- vcs,
297
- clearStart: changed(before, { ...session.vcs, ...vcs }) && !!session.vcsBaseCommit,
298
- note,
299
- said: `"${session.name}" works on the branch ${name} itself, from ${remote}/${name} as fetched now`,
300
- },
301
- };
302
- }
303
- /** Where a session's settings say it starts: the fields that decide the commit, nothing else. */
304
- function pointOf(vcs) {
305
- return JSON.stringify([vcs?.startFrom ?? 'head', vcs?.baseBranch?.trim() || 'main', vcs?.baseRemote?.trim() ?? '', vcs?.existingBranch?.trim() ?? '']);
306
- }
307
- function changed(before, after) {
308
- return before !== pointOf(after);
309
- }
310
- /** The fields of an `AppliedChoice` written onto a session's version control: `undefined` removes one. */
311
- export function withChoice(vcs, patch) {
312
- const out = { ...vcs };
313
- for (const [k, v] of Object.entries(patch)) {
314
- if (v === undefined)
315
- delete out[k];
316
- else
317
- out[k] = v;
318
- }
319
- return out;
320
- }
321
- /**
322
- * The refspecs that fetch exactly these branches of `remote` into their remote-tracking branches, or
323
- * why one of the names cannot be fetched.
324
- */
325
- export async function refspecsFor(dir, remote, branches) {
326
- const refspecs = [];
327
- for (const b of [...new Set(branches.map((x) => x.trim()).filter(Boolean))]) {
328
- if (!(await isValidBranchName(dir, b)))
329
- return { problem: `"${b}" is not a branch name git accepts.` };
330
- refspecs.push(`+refs/heads/${b}:refs/remotes/${remote}/${b}`);
331
- }
332
- return { refspecs };
333
- }
334
- /** The branch names a failed fetch said the remote does not have. */
335
- export function missingOnRemote(detail) {
336
- return [...detail.matchAll(/couldn't find remote ref (?:refs\/heads\/)?(\S+)/gi)].map((m) => m[1].replace(/[.,;:]+$/, ''));
337
- }
338
- /** Where git keeps the repository's records, for `lastFetchedAt`. */
339
- export async function gitDirOf(dir) {
340
- const r = await git(dir, ['rev-parse', '--absolute-git-dir']);
341
- return r.ok && r.stdout ? r.stdout : null;
342
- }
343
- /**
344
- * Fetches `branches` of `remote` — or the whole remote, pruned, when none are named — for the start
345
- * window, where the operator is looking: through Git's password window when there is one (`askpass`).
346
- * Only remote-tracking branches move; no local branch, no checkout.
347
- */
348
- export async function fetchForStart(dir, remote, branches, askpass) {
349
- const remotes = lines((await git(dir, ['remote'])).stdout);
350
- if (!remotes.includes(remote))
351
- return { ok: false, problem: `${dir} has no remote called "${remote}"${remotes.length > 0 ? ` (it has: ${remotes.join(', ')})` : ''}.`, missing: [] };
352
- const specs = branches && branches.length > 0 ? await refspecsFor(dir, remote, branches) : { refspecs: [] };
353
- if ('problem' in specs)
354
- return { ok: false, problem: specs.problem, missing: [] };
355
- const gitDir = await gitDirOf(dir);
356
- // Read before fetching: a fetch that fails empties FETCH_HEAD, and with it the time of the last one that worked.
357
- const lastBefore = gitDir ? lastFetchedAt(gitDir) : undefined;
358
- const fetched = await fetchAsOperator(dir, remote, { askpass, refspecs: specs.refspecs });
359
- const missing = fetched.ok ? [] : missingOnRemote(fetched.detail ?? '');
360
- return {
361
- ok: fetched.ok,
362
- fetched,
363
- missing,
364
- ...(fetched.ok ? {} : { fetchCommand: fetchCommandFor(dir, remote), ...(lastBefore ? { lastFetched: lastBefore } : {}) }),
365
- repo: await repoBranches(dir),
366
- };
367
- }
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[197],{257:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return o}});let n=r(1521);function o(e,t){let r=(0,n.useRef)(null),o=(0,n.useRef)(null);return(0,n.useCallback)(n=>{if(null===n){let e=r.current;e&&(r.current=null,e());let t=o.current;t&&(o.current=null,t())}else e&&(r.current=u(e,n)),t&&(o.current=u(t,n))},[e,t])}function u(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4251:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"errorOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},4866:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{DecodeError:function(){return h},MiddlewareNotFoundError:function(){return b},MissingStaticPage:function(){return m},NormalizeError:function(){return y},PageNotFoundError:function(){return g},SP:function(){return p},ST:function(){return d},WEB_VITALS:function(){return r},execOnce:function(){return n},getDisplayName:function(){return l},getLocationOrigin:function(){return a},getURL:function(){return i},isAbsoluteUrl:function(){return u},isResSent:function(){return f},loadGetInitialProps:function(){return s},normalizeRepeatedSlashes:function(){return c},stringifyError:function(){return P}});let r=["CLS","FCP","FID","INP","LCP","TTFB"];function n(e){let t,r=!1;return function(){for(var n=arguments.length,o=Array(n),u=0;u<n;u++)o[u]=arguments[u];return r||(r=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,u=e=>o.test(e);function a(){let{protocol:e,hostname:t,port:r}=window.location;return e+"//"+t+(r?":"+r:"")}function i(){let{href:e}=window.location,t=a();return e.substring(t.length)}function l(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function c(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function s(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await s(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error('"'+l(e)+'.getInitialProps()" should resolve to an object. But found "'+n+'" instead.'),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}let p="undefined"!=typeof performance,d=p&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class h extends Error{}class y extends Error{}class g extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class m extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class b extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function P(e){return JSON.stringify({message:e.message,stack:e.stack})}},5700:(e,t)=>{function r(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function n(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,n(e));else t.set(r,n(o));return t}function u(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(let t of r){for(let r of t.keys())e.delete(r);for(let[r,n]of t.entries())e.append(r,n)}return e}Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{assign:function(){return u},searchParamsToUrlQuery:function(){return r},urlQueryToSearchParams:function(){return o}})},6348:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{formatUrl:function(){return u},formatWithValidation:function(){return i},urlObjectKeys:function(){return a}});let n=r(2371)._(r(5700)),o=/https?|ftp|gopher|file/;function u(e){let{auth:t,hostname:r}=e,u=e.protocol||"",a=e.pathname||"",i=e.hash||"",l=e.query||"",f=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?f=t+e.host:r&&(f=t+(~r.indexOf(":")?"["+r+"]":r),e.port&&(f+=":"+e.port)),l&&"object"==typeof l&&(l=String(n.urlQueryToSearchParams(l)));let c=e.search||l&&"?"+l||"";return u&&!u.endsWith(":")&&(u+=":"),e.slashes||(!u||o.test(u))&&!1!==f?(f="//"+(f||""),a&&"/"!==a[0]&&(a="/"+a)):f||(f=""),i&&"#"!==i[0]&&(i="#"+i),c&&"?"!==c[0]&&(c="?"+c),""+u+f+(a=a.replace(/[?#]/g,encodeURIComponent))+(c=c.replace("#","%23"))+i}let a=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return u(e)}},7125:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return u}});let n=r(4866),o=r(2875);function u(e){if(!(0,n.isAbsoluteUrl)(e))return!0;try{let t=(0,n.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,o.hasBasePath)(r.pathname)}catch(e){return!1}}},8197:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{default:function(){return g},useLinkStatus:function(){return b}});let n=r(2371),o=r(3365),u=n._(r(1521)),a=r(6348),i=r(5722),l=r(257),f=r(4866),c=r(3424);r(4691);let s=r(2557),p=r(7125),d=r(2921);r(4251);let h=r(2418);function y(e){return"string"==typeof e?e:(0,a.formatUrl)(e)}function g(e){var t;let r,n,a,[g,b]=(0,u.useOptimistic)(s.IDLE_LINK_STATUS),P=(0,u.useRef)(null),{href:_,as:v,children:E,prefetch:O=null,passHref:j,replace:S,shallow:C,scroll:N,onClick:T,onMouseEnter:x,onTouchStart:A,legacyBehavior:M=!1,onNavigate:R,ref:L,unstable_dynamicOnHover:k,...I}=e;r=E,M&&("string"==typeof r||"number"==typeof r)&&(r=(0,o.jsx)("a",{children:r}));let U=u.default.useContext(i.AppRouterContext),w=!1!==O,F=!1!==O?null===(t=O)||"auto"===t?h.FetchStrategy.PPR:h.FetchStrategy.Full:h.FetchStrategy.PPR,{href:D,as:K}=u.default.useMemo(()=>{let e=y(_);return{href:e,as:v?y(v):e}},[_,v]);M&&(n=u.default.Children.only(r));let B=M?n&&"object"==typeof n&&n.ref:L,z=u.default.useCallback(e=>(null!==U&&(P.current=(0,s.mountLinkInstance)(e,D,U,F,w,b)),()=>{P.current&&((0,s.unmountLinkForCurrentNavigation)(P.current),P.current=null),(0,s.unmountPrefetchableInstance)(e)}),[w,D,U,F,b]),Q={ref:(0,l.useMergedRef)(z,B),onClick(e){M||"function"!=typeof T||T(e),M&&n.props&&"function"==typeof n.props.onClick&&n.props.onClick(e),U&&(e.defaultPrevented||function(e,t,r,n,o,a,i){let{nodeName:l}=e.currentTarget;if(!("A"===l.toUpperCase()&&function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||e.currentTarget.hasAttribute("download"))){if(!(0,p.isLocalURL)(t)){o&&(e.preventDefault(),location.replace(t));return}if(e.preventDefault(),i){let e=!1;if(i({preventDefault:()=>{e=!0}}),e)return}u.default.startTransition(()=>{(0,d.dispatchNavigateAction)(r||t,o?"replace":"push",null==a||a,n.current)})}}(e,D,K,P,S,N,R))},onMouseEnter(e){M||"function"!=typeof x||x(e),M&&n.props&&"function"==typeof n.props.onMouseEnter&&n.props.onMouseEnter(e),U&&w&&(0,s.onNavigationIntent)(e.currentTarget,!0===k)},onTouchStart:function(e){M||"function"!=typeof A||A(e),M&&n.props&&"function"==typeof n.props.onTouchStart&&n.props.onTouchStart(e),U&&w&&(0,s.onNavigationIntent)(e.currentTarget,!0===k)}};return(0,f.isAbsoluteUrl)(K)?Q.href=K:M&&!j&&("a"!==n.type||"href"in n.props)||(Q.href=(0,c.addBasePath)(K)),a=M?u.default.cloneElement(n,Q):(0,o.jsx)("a",{...I,...Q,children:r}),(0,o.jsx)(m.Provider,{value:g,children:a})}let m=(0,u.createContext)(s.IDLE_LINK_STATUS),b=()=>(0,u.useContext)(m);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[499],{1035:(e,t,l)=>{l.d(t,{DialogHost:()=>d,Z:()=>o});var r=l(3365),n=l(1521),s=l(867),a=l(4969);let c=null,i=[];function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(l=>{var r;return r={kind:"confirm",message:e,...t,resolve:l},void(c?c(r):i.push(r))})}function d(e){var t,l;let{children:o}=e,{t:d}=(0,s.kj)(),[h,m]=(0,n.useState)([]),u=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(c=e=>m(t=>[...t,e]),i.length>0){let e=i.splice(0,i.length);m(t=>[...t,...e])}return()=>{c=null}},[]);let x=h[0],g=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,a.V)(p,!!x,u),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),g(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,g]),(0,r.jsxs)(r.Fragment,{children:[o,x&&(0,r.jsx)("div",{className:"modal-backdrop",onClick:()=>g(!1),role:"presentation",children:(0,r.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{id:"modal-title",children:null!=(t=x.title)?t:d("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,r.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,r.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>g(!1),children:d("dialog.cancel")}),(0,r.jsx)("button",{ref:u,type:"button",className:x.danger?"danger":"primary",onClick:()=>g(!0),children:null!=(l=x.okLabel)?l:d("dialog.ok")})]})]})})]})}},1701:(e,t,l)=>{l.d(t,{L:()=>u,StartDialogHost:()=>p});var r=l(3365),n=l(1521),s=l(5549),a=l(867),c=l(4969),i=l(3486),o=l(3069);let d=null,h=[],m=1;function u(e){return new Promise(t=>{let l={...e,id:m++,resolve:t};d?d(l):h.push(l)})}function p(){let[e,t]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(d=e=>t(t=>[...t,e]),h.length>0){let e=h.splice(0,h.length);t(t=>[...t,...e])}return()=>{d=null}},[]);let l=e[0];return l?(0,r.jsx)(g,{req:l,onDone:e=>{l.resolve(e),t(e=>e.slice(1))}},l.id):null}let x=e=>e.trim().replace(/[\\/]+$/,"").replace(/\//g,"\\").toLowerCase();function g(e){var t,l,d,h,m,u;let{req:p,onDone:g}=e,{t:f}=(0,a.kj)(),j=(0,a.W3)(),v=(0,n.useId)(),b=(0,n.useRef)(null),y=(0,n.useRef)(null),[k,w]=(0,n.useState)(null),[N,F]=(0,n.useState)(""),[B,C]=(0,n.useState)({}),[S,D]=(0,n.useState)({}),[E,T]=(0,n.useState)({kind:"choose"}),[H,O]=(0,n.useState)(""),[W,I]=(0,n.useState)(""),[L,R]=(0,n.useState)({}),[A,q]=(0,n.useState)([]),[P,z]=(0,n.useState)(!1),U=(0,n.useRef)(new Set),V=(0,n.useRef)(void 0),K=e=>g({started:e,...V.current?{reply:V.current}:{}}),_="fetching"===E.kind||"starting"===E.kind||""!==W,X=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return s.FH.startOptions(p.sessionIds).then(t=>{w(t);let l={};for(let e of t.repos)l[x(e.repoDir)]=e;C(l);let r={};for(let e of t.sessions){if(!e.vcs||!e.repoDir||e.fixed&&!e.choice)continue;let t=function(e,t){var l,r,n,s,a,c,i;let o=null!=(a=null!=(s=null==t||null==(l=t.remotes.find(e=>"origin"===e.name))?void 0:l.name)?s:null==t||null==(r=t.remotes[0])?void 0:r.name)?a:"",d=null!=(i=null!=(c=null==t?void 0:t.current)?c:null==t||null==(n=t.local[0])?void 0:n.name)?i:"main";return e?"previous-session"===e.from?{from:"previous-session",local:d,remote:o,remoteBranch:d,onBranch:!1}:"local"===e.from?{from:"local",local:e.branch,remote:o,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"remote",local:(null==t?void 0:t.local.some(t=>t.name===e.branch))?e.branch:d,remote:e.remote,remoteBranch:e.branch,onBranch:!!e.onBranch}:{from:"local",local:d,remote:o,remoteBranch:"main",onBranch:!1}}(e.choice,l[x(e.repoDir)]);r[e.id]=e.prepared||e.fixed?{...t,from:"keep"}:t}D(t=>e?{...r,...Object.fromEntries(Object.entries(t).filter(e=>{let[t]=e;return t in r}))}:r)}).catch(e=>F(e.message))};(0,n.useEffect)(()=>{X()},[p.sessionIds]),(0,c.V)(b,!0,y),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&!e.defaultPrevented&&(e.preventDefault(),_||K(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[_,K]);let J=e=>e?B[x(e)]:void 0,M=(e,t)=>D(l=>({...l,[e]:{...l[e],...t}})),$=e=>{e&&C(t=>({...t,[x(e.repoDir)]:e}))},G=()=>{s.FH.runVcs(p.sessionIds).then(q).catch(()=>q([]))},Z=()=>{U.current.clear(),T({kind:"choose"})},Q=async function(){var e;let t,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};O("");let r=(()=>{var e,t;let l={},r=new Map;for(let n of null!=(e=null==k?void 0:k.sessions)?e:[]){let e=S[n.id],s=J(n.repoDir);if(!e||!n.repoDir||!s||s.problem||"keep"===e.from)continue;let a=n.fixed?{rechoose:!0}:{};if("previous-session"===e.from)l[n.id]={from:"previous-session",...a};else if("current"===e.from){if(!s.current)return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"local",branch:s.current,...e.onBranch?{onBranch:!0}:{},...a}}else if("local"===e.from){if(!e.local||!s.local.some(t=>t.name===e.local))return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"local",branch:e.local,...e.onBranch?{onBranch:!0}:{},...a}}else{let c=e.remoteBranch.trim();if(!e.remote||!c)return{problem:f("startdlg.needBranch",{name:n.name})};l[n.id]={from:"remote",remote:e.remote,branch:c,...e.onBranch?{onBranch:!0}:{},...a};let i="".concat(x(n.repoDir),"|").concat(e.remote),o=null!=(t=r.get(i))?t:{key:i,dir:s.repoDir,remote:e.remote,branches:[]};o.branches.includes(c)||o.branches.push(c),r.set(i,o)}}return{starts:l,groups:[...r.values()].map(e=>({...e,key:"".concat(e.key,"|").concat([...e.branches].sort().join(","))}))}})();if("problem"in r)return void O(r.problem);if(!l.skipFetch)for(let e of r.groups){if(U.current.has(e.key))continue;T({kind:"fetching",what:e.branches.map(t=>"".concat(e.remote,"/").concat(t)).join(", ")});let t=await s.FH.startFetch(e.dir,e.remote,e.branches).catch(e=>({ok:!1,problem:e.message,missing:[]}));if($(t.repo),!t.ok)return void T({kind:"fetchFailed",group:e,result:t})}T({kind:"starting"});try{t=await p.start(r.starts)}catch(e){t={started:!1,reason:e.message}}if(V.current=t,t.started)return void K(!0);T({kind:"failed",reply:t}),(null==(e=t.failure)?void 0:e.stage)==="preflight"&&G()},Y=async(e,t)=>{I("".concat(x(e),"|").concat(t)),R(l=>({...l,[x(e)]:f("startdlg.fetching",{what:t})}));try{let l=await s.FH.startFetch(e,t);$(l.repo),R(r=>{var n,s,a,c;return{...r,[x(e)]:l.ok?"":"".concat(f("startdlg.fetchFailed",{what:t})," ").concat(null!=(c=null!=(a=l.problem)?a:null==(n=l.fetched)?void 0:n.detail)?c:"").concat((null==(s=l.fetched)?void 0:s.auth)?" ".concat(f("prep.fetchAuth")):"")}})}catch(t){R(l=>({...l,[x(e)]:t.message}))}finally{I("")}},ee=async e=>{try{await navigator.clipboard.writeText(e),z(!0),window.setTimeout(()=>z(!1),2500)}catch(e){O(f("plan.copyFailed"))}},et=Object.values(S).some(e=>"remote"===e.from),el=(null!=(h=null==k?void 0:k.sessions)?h:[]).filter(e=>e.vcs),er=1===el.length?(e=>{var t,l,r;let n=S[e.id],s=J(e.repoDir);if(!n||!s)return;let a=e=>e?" @ ".concat(e.slice(0,8)):"";return"keep"===n.from?e.fixed&&(null==(t=e.started)?void 0:t.branch)?"".concat(e.started.branch).concat(a(null!=(r=e.started.tipNow)?r:e.started.recorded)):void 0:"current"===n.from?s.current?"".concat(s.current).concat(a(s.head)):void 0:"local"===n.from?"".concat(n.local).concat(a(null==(l=s.local.find(e=>e.name===n.local))?void 0:l.commit)):"remote"===n.from&&n.remoteBranch.trim()?"".concat(n.remote,"/").concat(n.remoteBranch.trim()):void 0})(el[0]):void 0,en=er?f("unattended"===p.mode?"startdlg.goUnattendedOn":"startdlg.goStepOn",{where:er}):"unattended"===p.mode?f("startdlg.goUnattended"):f("startdlg.goStep");return(0,r.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>!_&&K(!1),children:(0,r.jsxs)("div",{ref:b,className:"modal wide start-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"".concat(v,"-title"),onClick:e=>e.stopPropagation(),style:{overflowWrap:"anywhere"},children:[(0,r.jsx)("h2",{id:"".concat(v,"-title"),children:f("startdlg.title")}),(0,r.jsxs)("p",{className:"small muted",style:{marginTop:0},children:[f("startdlg.intro")," ",k&&"choose"===E.kind&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>void X(!0),disabled:_,children:f("startdlg.refresh")})]}),N&&(0,r.jsx)(o.X,{reason:N}),!k&&!N&&(0,r.jsx)("p",{className:"small",role:"status",children:f("startdlg.loading")}),k&&("choose"===E.kind||"fetching"===E.kind||"starting"===E.kind)&&k.sessions.map(e=>{var t,l,n,s,a,c,i,o,d,h,m,u;let p=J(e.repoDir),g=S[e.id],b="start-".concat(v,"-").concat(e.id),y=null!=(c=null==p||null==(t=p.remotes.find(e=>e.name===(null==g?void 0:g.remote)))?void 0:t.branches)?c:[];return(0,r.jsxs)("fieldset",{className:"option",style:{border:"1px solid var(--line)",borderRadius:"var(--radius)",padding:"8px 12px",margin:"10px 0"},children:[(0,r.jsx)("legend",{style:{padding:"0 4px"},children:(0,r.jsx)("strong",{children:e.name})}),e.repoDir&&(0,r.jsx)("p",{className:"muted small",style:{margin:"2px 0 6px"},children:f("startdlg.repoOn",{repo:e.repoDir,branch:null!=(i=null==p?void 0:p.current)?i:"HEAD"})}),e.vcs?p&&!p.problem&&g?e.fixed&&e.rechooseBlocked?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}),(0,r.jsx)("p",{className:"muted small",children:f("startdlg.rechooseBlocked",{tasks:e.rechooseBlocked})})]}):(0,r.jsxs)(r.Fragment,{children:[e.fixed&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",style:{margin:"2px 0"},children:f("startdlg.fixed",{start:e.fixed})}),(null==(l=e.started)?void 0:l.branch)&&(0,r.jsxs)("p",{className:"small",style:{margin:"2px 0"},children:[e.started.tipNow?f("startdlg.branchNow",{branch:e.started.branch,now:e.started.tipNow.slice(0,8),recorded:(null!=(d=e.started.recorded)?d:"").slice(0,8)}):f("startdlg.branchGone",{branch:e.started.branch,recorded:(null!=(h=e.started.recorded)?h:"").slice(0,8)}),e.started.remote?" ".concat(f("startdlg.branchRemote",{name:e.started.remote.name,commit:e.started.remote.commit.slice(0,8)})):""]}),p.current&&(null==(n=e.started)?void 0:n.branch)&&p.current!==e.started.branch&&"per-task"!==e.started.mode&&(0,r.jsx)("p",{className:"notice caution small",style:{margin:"4px 0"},children:f("startdlg.differs",{current:p.current,head:(null!=(m=p.head)?m:"").slice(0,8),branch:e.started.branch})}),(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,r.jsx)("span",{children:(null==(s=e.started)?void 0:s.branch)?f("startdlg.keepStarted",{branch:e.started.branch}):f("startdlg.keepStartedNoBranch")})]})}),p.current&&p.current!==(null==(a=e.started)?void 0:a.branch)&&(0,r.jsx)("div",{className:"option",children:(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"current"===g.from,onChange:()=>M(e.id,{from:"current"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.useCurrent",{branch:p.current,commit:(null!=(u=p.head)?u:"").slice(0,8)})})]})})]}),e.prepared&&(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"keep"===g.from,onChange:()=>M(e.id,{from:"keep"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.keep")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.prepared",{start:e.prepared})})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"local"===g.from,onChange:()=>M(e.id,{from:"local"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.local")})]}),(0,r.jsx)("div",{className:"row",style:{marginTop:4},children:(0,r.jsxs)("select",{"aria-label":f("startdlg.localBranch"),value:g.local,onChange:t=>M(e.id,{from:"local",local:t.target.value}),disabled:_,style:{width:"auto",minWidth:240,maxWidth:"100%"},children:[!p.local.some(e=>e.name===g.local)&&(0,r.jsx)("option",{value:g.local,children:g.local}),p.local.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," \xb7 ",e.commit.slice(0,8)]},e.name))]})}),(0,r.jsx)("p",{className:"why",children:f("startdlg.localWhy")})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"remote"===g.from,onChange:()=>M(e.id,{from:"remote"}),disabled:_||0===p.remotes.length}),(0,r.jsx)("span",{children:f("startdlg.remote")})]}),0===p.remotes.length?(0,r.jsx)("p",{className:"muted small",children:f("startdlg.noRemote")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"row",style:{marginTop:4},children:[p.remotes.length>1&&(0,r.jsx)("select",{"aria-label":f("startdlg.remoteName"),value:g.remote,onChange:t=>M(e.id,{from:"remote",remote:t.target.value}),disabled:_,style:{width:"auto"},children:p.remotes.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))}),1===p.remotes.length&&(0,r.jsxs)("code",{children:[g.remote,"/"]}),(0,r.jsx)("input",{type:"text","aria-label":f("startdlg.remoteBranch"),list:"".concat(b,"-remote"),value:g.remoteBranch,onChange:t=>M(e.id,{from:"remote",remoteBranch:t.target.value}),onFocus:()=>"remote"!==g.from&&M(e.id,{from:"remote"}),disabled:_,style:{width:"auto",minWidth:240,flex:"1 1 240px"},placeholder:"main"}),(0,r.jsx)("datalist",{id:"".concat(b,"-remote"),children:y.map(e=>(0,r.jsx)("option",{value:e.name},e.name))}),(0,r.jsx)("button",{type:"button",onClick:()=>void Y(p.repoDir,g.remote),disabled:_||!g.remote,children:f("startdlg.refreshRemote")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.remoteWhy")}),(0,r.jsx)("p",{className:"muted small",style:{margin:"2px 0"},children:p.lastFetched?f("startdlg.lastFetched",{when:j(p.lastFetched)}):y.length>0?f("startdlg.lastFetchedUnknown"):f("startdlg.neverFetched")}),L[x(p.repoDir)]&&(0,r.jsx)("p",{className:"small",role:"status",children:L[x(p.repoDir)]})]})]}),e.previousOffered&&(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"radio",name:b,checked:"previous-session"===g.from,onChange:()=>M(e.id,{from:"previous-session"}),disabled:_}),(0,r.jsx)("span",{children:f("startdlg.previous")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.previousWhy")})]}),(0,r.jsxs)("div",{className:"option",children:[(0,r.jsxs)("label",{children:[(0,r.jsx)("input",{type:"checkbox",checked:g.onBranch&&("local"===g.from||"remote"===g.from||"current"===g.from),onChange:t=>M(e.id,{onBranch:t.target.checked}),disabled:_||"local"!==g.from&&"remote"!==g.from&&"current"!==g.from}),(0,r.jsx)("span",{children:f("startdlg.onBranch")})]}),(0,r.jsx)("p",{className:"why",children:f("startdlg.onBranchWhy")})]}),e.fixed&&"keep"!==g.from&&(0,r.jsx)("p",{className:"notice caution small",children:f("startdlg.rechooseNote")})]}):e.fixed?(0,r.jsx)("p",{className:"small",children:f("startdlg.fixed",{start:e.fixed})}):(0,r.jsx)("p",{className:"err small",children:f("startdlg.repoProblem",{problem:null!=(o=null==p?void 0:p.problem)?o:""})}):(0,r.jsx)("p",{className:"small",children:f("startdlg.vcsOff")})]},e.id)}),"fetching"===E.kind&&(0,r.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.fetching",{what:E.what})}),"starting"===E.kind&&(0,r.jsx)("p",{className:"notice small",role:"status",children:f("startdlg.starting")}),"fetchFailed"===E.kind&&(0,r.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,r.jsxs)("p",{style:{marginTop:0},children:[(0,r.jsx)("strong",{children:f("startdlg.fetchFailed",{what:E.group.branches.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})})," ",(0,r.jsx)("code",{children:null!=(u=null!=(m=E.result.problem)?m:null==(t=E.result.fetched)?void 0:t.detail)?u:""})]}),E.result.missing.length>0&&(0,r.jsx)("p",{className:"small",children:f("startdlg.missing",{names:E.result.missing.join(", ")})}),(null==(l=E.result.fetched)?void 0:l.auth)&&(0,r.jsx)("p",{className:"small",children:f("prep.fetchAuth")}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q(),children:f("startdlg.retryFetch")}),(()=>{var e,t;let l=J(E.group.dir),n=null!=(t=null==l||null==(e=l.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[];return E.group.branches.every(e=>n.some(t=>t.name===e))?(0,r.jsx)("button",{type:"button",onClick:()=>{U.current.add(E.group.key),Q()},children:f("startdlg.useFetched")}):null})(),(0,r.jsx)("button",{type:"button",className:"quiet",onClick:Z,children:f("startdlg.back")})]}),(()=>{var e,t;let l=J(E.group.dir),n=null!=(t=null==l||null==(e=l.remotes.find(e=>e.name===E.group.remote))?void 0:e.branches)?t:[],s=E.group.branches.filter(e=>!n.some(t=>t.name===e));return s.length>0?(0,r.jsx)("p",{className:"muted small",children:f("startdlg.useFetchedNo",{what:s.map(e=>"".concat(E.group.remote,"/").concat(e)).join(", ")})}):E.result.lastFetched?(0,r.jsx)("p",{className:"muted small",children:f("prep.lastFetched",{when:j(E.result.lastFetched)})}):null})(),E.result.fetchCommand&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",style:{marginTop:8},children:f("prep.ownTerminal")}),(0,r.jsx)("pre",{className:"sync-cmd",children:E.result.fetchCommand}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{var e;ee(null!=(e=E.result.fetchCommand)?e:"")},children:f("prep.copyFetch")}),P&&(0,r.jsx)("span",{className:"badge done",children:f("prep.copied")})]})]})]}),"failed"===E.kind&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.X,{failure:E.reply.failure,reason:E.reply.reason}),(null==(d=E.reply.failure)?void 0:d.stage)==="preflight"&&A.some(e=>!e.ready)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:f("startdlg.vcsFix")}),(0,r.jsx)(i.w,{groups:A,sessionIds:p.sessionIds,onChange:()=>{G(),X()}})]})]}),H&&(0,r.jsx)("p",{className:"err small",role:"alert",children:H}),"choose"===E.kind&&et&&(0,r.jsx)("p",{className:"why",children:f("prep.password")}),(0,r.jsxs)("div",{className:"row modal-actions",children:[(0,r.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(!1),disabled:_,children:f("dialog.cancel")}),"failed"===E.kind?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:Z,children:f("startdlg.back")}),(0,r.jsx)("button",{type:"button",className:"primary",onClick:()=>void Q({skipFetch:!0}),children:f("startdlg.tryAgain")})]}):"fetchFailed"!==E.kind&&(0,r.jsx)("button",{ref:y,type:"button",className:"primary",onClick:()=>void Q(),disabled:_||!k,children:en})]})]})})}},3069:(e,t,l)=>{l.d(t,{$:()=>h,X:()=>i});var r=l(3365),n=l(1521),s=l(5549),a=l(867),c=l(7527);function i(e){var t,l;let{failure:n,reason:c,onDismiss:i,intro:o,children:d}=e,{t:h}=(0,a.kj)(),m=(0,a.W3)(),u=null!=(l=null!=(t=null==n?void 0:n.message)?t:c)?l:"";return(0,r.jsxs)("div",{className:"notice caution start-failure",role:"alert",style:{overflowWrap:"anywhere"},children:[o&&(0,r.jsx)("p",{className:"small",style:{marginTop:0},children:o}),(0,r.jsx)("strong",{children:h("startfail.title")}),n&&(0,r.jsx)("p",{className:"small",style:{margin:"4px 0"},children:h("startfail.where",{stage:h("startfail.stage.".concat(n.stage))})}),(0,r.jsx)("pre",{className:"sync-cmd small",style:{margin:"6px 0"},children:u}),d,n&&(0,r.jsxs)("p",{className:"muted small",style:{margin:"4px 0"},children:[n.runId?h("startfail.when",{when:m(n.at),run:n.runId}):h("startfail.whenNoRun",{when:m(n.at)}),n.sessions.length>0?" \xb7 ".concat(n.sessions.map(e=>'"'.concat(e,'"')).join(", ")):""]}),(0,r.jsxs)("div",{className:"row",style:{marginTop:6},children:[n&&(0,r.jsx)("a",{className:"button-link",href:s.FH.startFailureUrl(n.id),download:!0,children:h("startfail.download")}),(0,r.jsx)("a",{className:n?"button-link":"button-link plain",href:s.FH.terminalUrl(),download:!0,children:h("startfail.terminal")}),i&&(0,r.jsx)("button",{type:"button",className:"quiet",onClick:i,children:h("startfail.dismiss")})]}),(0,r.jsx)("p",{className:"why",children:h("startfail.downloadWhy")})]})}let o="cop.startFailure.dismissed";function d(){try{var e;let t=JSON.parse(null!=(e=window.localStorage.getItem(o))?e:"[]");return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch(e){return[]}}function h(){let{t:e}=(0,a.kj)(),[t,l]=(0,n.useState)([]),[h,m]=(0,n.useState)([]);(0,c.z)(()=>s.FH.startFailures(!0).then(e=>{l(e),m(d())}).catch(()=>void 0),5e3);let u=t.find(e=>!h.includes(e.id));return u?(0,r.jsx)("div",{style:{marginBottom:12},children:(0,r.jsx)(i,{failure:u,intro:e("at-turn"===u.stage?"startfail.laterSession":"startfail.later"),onDismiss:()=>{let e=[...new Set([...d(),u.id])].slice(-50);try{window.localStorage.setItem(o,JSON.stringify(e))}catch(e){}m(e)}})}):null}},3486:(e,t,l)=>{l.d(t,{w:()=>i});var r=l(3365),n=l(1521),s=l(5549),a=l(867);let c={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function i(e){let{groups:t,sessionIds:l,onChange:s}=e,{t:c}=(0,a.kj)(),[i,d]=(0,n.useState)(""),h=t.filter(e=>!e.ready);return 0===h.length?i?(0,r.jsxs)("p",{className:"notice small",role:"status",children:[(0,r.jsx)("strong",{children:c("runvcs.ready")})," ",i]}):null:(0,r.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,r.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:c("runvcs.title")}),(0,r.jsx)("p",{className:"small",children:c("runvcs.why")}),h.map(e=>(0,r.jsx)(o,{group:e,sessionIds:l,onChange:s,onDone:d},e.repoDir))]})}function o(e){var t;let{group:l,sessionIds:i,onChange:o,onDone:d}=e,{t:h}=(0,a.kj)(),[m,u]=(0,n.useState)(!1),[p,x]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[b,y]=(0,n.useState)({}),k=(e,t)=>{var l,r;return null!=(r=null!=(l=b[e])?l:t)?r:void 0},w=l.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 u(e=>!e);f(!0),v("");try{var t,r,n;let a="snapshot-on-base"===e?Object.fromEntries(l.inputs.map(e=>[e.path,"include"])):Object.fromEntries(l.entries.filter(e=>k(e.path,e.choice)).map(e=>[e.path,k(e.path,e.choice)])),c=await s.FH.runVcsPrepare(i,l.repoDir,e,a);v(c.ok?null!=(t=c.result)?t:"":null!=(r=c.problem)?r:""),c.ok&&d("".concat(l.repoDir,": ").concat(null!=(n=c.result)?n:"")),o()}catch(e){v(e.message)}finally{f(!1)}};return(0,r.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,r.jsx)("table",{className:"small",children:(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.repo")}),(0,r.jsx)("td",{children:(0,r.jsx)("code",{children:l.repoDir})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.current")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:null!=(t=l.branch)?t:"HEAD"})," @ ",(0,r.jsx)("code",{children:N(l.head)})]})]}),l.workBranch&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.workBranch")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:l.workBranch.name})," @ ",(0,r.jsx)("code",{children:N(l.workBranch.head)})]})]}),l.baseBranch&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.base")}),(0,r.jsxs)("td",{children:[(0,r.jsx)("code",{children:l.baseBranch})," @ ",(0,r.jsx)("code",{children:N(l.baseHead)})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.sessions")}),(0,r.jsx)("td",{children:l.sessions.map(e=>"".concat(e.name," (").concat(h("runvcs.role.".concat(e.role)),")")).join(", ")})]}),l.inputPatterns.length>0&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:h("runvcs.patterns")}),(0,r.jsx)("td",{children:l.inputPatterns.map(e=>(0,r.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),l.problem&&(0,r.jsxs)("p",{className:"small",children:[(0,r.jsx)("strong",{children:h("runvcs.problem")})," ",l.problem]}),l.inputs.length>0&&(0,r.jsx)("p",{className:"small",children:h("runvcs.inputsCount",{n:l.inputs.length})}),m&&l.inputs.length>0&&(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:l.inputs.map(e=>(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:e.path})," — ",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,r.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),l.unrelated.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:(0,r.jsx)("strong",{children:h("runvcs.unrelated",{n:l.unrelated.length})})}),(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:l.unrelated.slice(0,30).map(e=>(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&l.entries.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"small",children:(0,r.jsx)("strong",{children:h("runvcs.choose",{n:l.entries.length})})}),(0,r.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var t;return(0,r.jsxs)("li",{style:{marginBottom:4},children:[(0,r.jsx)("code",{children:e.path})," ",(0,r.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(h("vcs.snapshotInput"),", "):"",h("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,s.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,r.jsx)("span",{className:"err",children:h("vcs.snapshotBlocked")}):(0,r.jsx)("select",{"aria-label":e.path,value:null!=(t=k(e.path,e.choice))?t:"",onChange:t=>y({...b,[e.path]:t.target.value}),disabled:g||e.allowed.length<2,children:e.allowed.map(e=>(0,r.jsx)("option",{value:e,children:h("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,r.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,r.jsxs)("p",{className:"small muted",children:[h("runvcs.cancelled")," ",(0,r.jsx)("button",{className:"quiet",onClick:()=>x(!1),children:h("runvcs.showAgain")})]}):(0,r.jsxs)("div",{children:[l.actions.map(e=>{var t,n,s;return(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void F(e.id),disabled:g||!e.available,children:[h(c[e.id],{branch:null!=(t=l.baseBranch)?t:"",current:null!=(n=l.branch)?n:"HEAD"}),"review-inputs"===e.id&&m?" ✓":""]}),e.recommended&&(0,r.jsx)("span",{className:"badge done",style:{marginLeft:6},children:h("runvcs.recommended")}),(0,r.jsx)("p",{className:"why",children:e.available?e.result:"".concat(h("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,r.jsxs)("div",{style:{marginTop:8},children:[(0,r.jsx)("button",{className:"quiet",onClick:()=>x(!0),disabled:g,children:h("runvcs.cancel")}),(0,r.jsx)("p",{className:"why",children:h("runvcs.cancelWhy")})]})]}),j&&(0,r.jsx)("p",{className:"small",role:"status",children:j})]})}},4969:(e,t,l)=>{l.d(t,{V:()=>s});var r=l(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,t,l){(0,r.useEffect)(()=>{var r,s;if(!t)return;let a=document.activeElement instanceof HTMLElement?document.activeElement:null,c=e.current,i=null!=(s=null!=(r=null==l?void 0:l.current)?r:null==c?void 0:c.querySelector(n))?s:null;null==i||i.focus();let o=e=>{if("Tab"!==e.key||!c)return;let t=Array.from(c.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let l=t[0],r=t[t.length-1],s=c.contains(document.activeElement);e.shiftKey&&(document.activeElement===l||!s)?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r&&s||(e.preventDefault(),l.focus())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),a&&document.contains(a)&&a.focus()}},[e,t,l])}},7527:(e,t,l)=>{l.d(t,{z:()=>n});var r=l(1521);function n(e,t){let l=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=(0,r.useRef)(e);n.current=e,(0,r.useEffect)(()=>{let e;if(!l)return;let r=!1,s=async()=>{try{await n.current()}catch(e){}finally{r||(e=setTimeout(()=>void s(),t))}};return s(),()=>{r=!0,e&&clearTimeout(e)}},[t,l])}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[534],{287:(e,t,s)=>{s.d(t,{y:()=>h,f:()=>u});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7527),c=s(1035),d=s(1701),o=s(4811);function u(e){var t,s,u;let{target:f,intro:m,initial:p="one",focusFirst:x=!1,checkContract:g=!0,onClose:j}=e,{t:y}=(0,i.kj)(),k=(0,o.p)(),[v,N]=(0,l.useState)(null),[b,w]=(0,l.useState)(p),[S,C]=(0,l.useState)(!1),[q,I]=(0,l.useState)(""),[F,R]=(0,l.useState)(!1),E=(0,l.useRef)(null),L=(0,l.useRef)(null),T=(0,l.useRef)(null),M=(0,l.useId)(),H=()=>a.FH.session(f.sessionId).then(N).catch(e=>I(e.message));(0,l.useEffect)(()=>{H(),g&&a.FH.contractCheck(f.sessionId,f.taskId).then(e=>R(e.conflicts.length>0)).catch(()=>void 0)},[f.sessionId,f.taskId]),(0,r.z)(H,3e3,!!(null==v?void 0:v.running));let O=null!==v;if((0,l.useEffect)(()=>{var e,t,s;if(!O||(null==(t=E.current)||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest"}),!x))return;let n=L.current;n&&!n.disabled?n.focus():null==(s=T.current)||s.focus()},[O,x]),!v)return(0,n.jsx)("div",{className:"notice calm",style:{marginTop:8},children:(0,n.jsx)("span",{className:"small",children:q||y("runq.loading")})});let D=function(e,t){let s=e.tasks.findIndex(e=>e.id===t),n=s>=0?e.tasks[s]:void 0,l=s>=0?e.tasks.slice(0,s):[],a=s>=0?e.tasks.slice(s+1):[],i="continue"!==e.onFailure,r=-1;return a.forEach((e,t)=>{"queued"===e.status&&(r=t)}),{task:n,followingQueued:a.filter(e=>"queued"===e.status),laterRan:a.filter(e=>"queued"!==e.status),earlierRan:l.filter(e=>"queued"!==e.status),chain:i,chainGap:i?l.find(e=>"done"!==e.status):void 0,chainGapLater:i&&r>0?a.slice(0,r).find(e=>"queued"!==e.status&&"done"!==e.status):void 0}}(v,f.taskId),W=(null==(t=D.task)?void 0:t.status)==="queued",G="following"===b?[D.task,...D.followingQueued]:D.task?[D.task]:[],Q=v.running?y("runq.sessionRunning"):!1===v.active?y("runq.sessionInactive"):"",P=async e=>{if("unattended"!==e||k||await (0,c.Z)(y("batch.unattendedConfirm",{n:1}))){C(!0),I(""),R(!1);try{var t,s;let n=await a.FH.suggestedRunName([f.sessionId]).then(e=>e.name).catch(()=>void 0),l=await (0,d.L)({sessionIds:[f.sessionId],mode:e,start:t=>a.FH.startBatch([f.sessionId],e,"stop",void 0,void 0,n,G.map(e=>e.id),t)});if(!l.started&&!l.reply)return;let i=null!=(t=l.reply)?t:{started:!0};if(!l.started){I(y("batch.notStarted",{reason:null!=(s=i.reason)?s:""}));let e=await a.FH.contractCheck(f.sessionId,f.taskId).catch(()=>({conflicts:[]}));R(e.conflicts.length>0);return}I(y("runq.started",{n:G.length})),j(!0)}catch(e){I(e.message)}finally{C(!1)}}},V=y("runq.title",{title:f.title});return(0,n.jsxs)("div",{ref:E,className:"notice calm",role:"group","aria-label":V,style:{marginTop:8},children:[m&&(0,n.jsx)("p",{className:"small",style:{marginTop:0},children:m}),(0,n.jsx)("strong",{children:V}),W?(0,n.jsxs)(n.Fragment,{children:[D.followingQueued.length>0&&(0,n.jsxs)("div",{className:"small",role:"radiogroup","aria-label":V,style:{marginTop:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"one"===b,onChange:()=>w("one"),disabled:S}),y("runq.onlyThis")]}),(0,n.jsxs)("label",{className:"option-inline",title:y("runq.followingWhy"),children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"following"===b,onChange:()=>w("following"),disabled:S}),y("runq.following",{n:D.followingQueued.length,session:v.name})]})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:y("runq.willRun")}),(0,n.jsx)("ol",{className:"small",style:{margin:"4px 0",paddingLeft:22},children:G.map(e=>(0,n.jsx)("li",{children:e.title},e.id))}),(0,n.jsxs)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18},children:[D.chain&&G.length>1&&(0,n.jsx)("li",{children:y("runq.chainStops")}),D.earlierRan.length>0&&(0,n.jsx)("li",{children:y("runq.untouched",{n:D.earlierRan.length})}),D.laterRan.length>0&&(0,n.jsx)("li",{children:y("runq.laterRan",{list:D.laterRan.map(e=>'"'.concat(e.title,'"')).join(", ")})}),"one"===b&&D.followingQueued.length>0&&(0,n.jsx)("li",{children:y("runq.restWait",{n:D.followingQueued.length})})]}),D.chainGap&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGap",{before:D.chainGap.title,status:y("status.".concat(D.chainGap.status))})}),"following"===b&&D.chainGapLater&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGapLater",{between:D.chainGapLater.title,status:y("status.".concat(D.chainGapLater.status))})}),Q&&(0,n.jsx)("p",{className:"small",children:Q})]}):(0,n.jsx)("p",{className:"small",children:y("runq.notQueued",{status:y("status.".concat(null!=(u=null==(s=D.task)?void 0:s.status)?u:"queued"))})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[W&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:L,className:"primary",disabled:S||!!Q,onClick:()=>void P("confirm"),title:y("runq.goWhy"),children:y("runq.go")}),(0,n.jsx)("button",{disabled:S||!!Q,onClick:()=>void P("unattended"),title:y("runq.unattendedWhy"),children:y("runq.unattended")})]}),(0,n.jsx)("button",{ref:T,className:"quiet",disabled:S,onClick:()=>j(!1),children:m?y("runq.later"):y("dialog.cancel")}),q&&(0,n.jsx)("span",{className:"small",role:"status",children:q})]}),F&&(0,n.jsx)(h,{target:f,onApplied:(e,t)=>{H(),0===e&&(R(!1),I(t))}})]})}function h(e){let{target:t,onApplied:s}=e,{t:r}=(0,i.kj)(),[c,d]=(0,l.useState)(null),[o,u]=(0,l.useState)([]),[h,f]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),[x,g]=(0,l.useState)(null),[j,y]=(0,l.useState)(null),k=(0,l.useId)();(0,l.useEffect)(()=>{d(null),Promise.all([a.FH.contractCheck(t.sessionId,t.taskId),a.FH.session(t.sessionId)]).then(e=>{var s;let[n,l]=e,a=l.tasks.find(e=>e.id===t.taskId);d(n.conflicts),u(n.conflicts.map(e=>e.fixes.length>0?0:-1)),g(null!=(s=null==a?void 0:a.status)?s:null),y(a?{readOnly:a.readOnly,scope:a.scope,checks:a.checks}:null)}).catch(e=>p(e.message))},[t.sessionId,t.taskId]);let v=async()=>{if(c){f(!0),p("");try{let e=await a.FH.applyContractFix(t.sessionId,t.taskId,o,c.map(e=>e.text)),n=r("cfix.applied",{list:(j?function(e,t,s){var n,l,a,i;let r=[];!!t.readOnly!=!!s.readOnly&&r.push(e(s.readOnly?"cfix.chReadOnlyOn":"cfix.chReadOnlyOff"));let c=(null!=(n=t.scope)?n:[]).join(", "),d=(null!=(l=s.scope)?l:[]).join(", ");c!==d&&r.push(d?e("cfix.chScope",{paths:d}):e("cfix.chScopeRemoved"));let o=new Set((null!=(a=s.checks)?a:[]).map(e=>e.name));for(let s of null!=(i=t.checks)?i:[])o.has(s.name)||r.push(e("cfix.chDropped",{check:s.name}));return r.join("; ")}(r,j,e.task):e.applied.join("; "))||r("cfix.chNothing")});p(n+(e.remaining.length>0?" ".concat(r("cfix.remaining",{n:e.remaining.length})):"")),d(e.remaining),u(e.remaining.map(e=>e.fixes.length>0?0:-1)),g("queued"),y({readOnly:e.task.readOnly,scope:e.task.scope,checks:e.task.checks}),s(e.remaining.length,n)}catch(e){p(e.message)}finally{f(!1)}}},N=r("cfix.title",{title:t.title});return(0,n.jsxs)("div",{className:"notice caution",role:"group","aria-label":N,style:{marginTop:8},children:[(0,n.jsx)("strong",{children:N}),(0,n.jsx)("p",{className:"why",children:r("cfix.why")}),null===c?(0,n.jsx)("p",{className:"small",children:m||r("cfix.loading")}):0===c.length?(0,n.jsx)("p",{className:"small",role:"status",children:m||r("cfix.none")}):(0,n.jsxs)(n.Fragment,{children:[c.map((e,t)=>(0,n.jsxs)("fieldset",{className:"small",style:{margin:"8px 0",border:0,padding:0},children:[(0,n.jsx)("legend",{style:{fontWeight:600},children:e.text}),e.fixes.map((e,s)=>(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:o[t]===s,onChange:()=>u(e=>e.map((e,n)=>n===t?s:e)),disabled:h}),"add-to-scope"===e.kind?r("cfix.addToScope",{path:e.path}):"not-read-only"===e.kind?e.scope.length>0?r("cfix.notReadOnly",{paths:e.scope.join(", ")}):r("cfix.notReadOnlyAll"):"drop-scope"===e.kind?r("cfix.dropScope"):r("cfix.dropCheck",{check:e.check}),0===s&&(0,n.jsxs)("span",{className:"muted",children:[" ",r("cfix.minimal")]})]},s)),(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:-1===o[t],onChange:()=>u(e=>e.map((e,s)=>s===t?-1:e)),disabled:h}),e.fixes.length>0?r("cfix.leave"):r("cfix.noFix")]})]},t)),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:h||o.every(e=>-1===e),onClick:()=>void v(),children:"queued"===x?r("cfix.applyQueued"):r("cfix.apply")}),m&&(0,n.jsx)("span",{className:"small",role:"status",children:m})]})]})]})}},853:(e,t,s)=>{function n(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function l(e,t){let s=function(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;let a=[];for(let e=0;e<s;e+=1)a.push({kind:"same",a:e,b:e});for(let i of function(e,t){let s=e.length,n=t.length;if(0===s)return t.map((e,t)=>({kind:"add",b:t}));if(0===n)return e.map((e,t)=>({kind:"del",a:t}));let l=s+n,a=l+1,i=new Int32Array(2*l+3),r=[];for(let c=0;c<=Math.min(l,2e3);c+=1){r.push(i.slice(a-c-1,a+c+2));for(let l=-c;l<=c;l+=2){let d=l===-c||l!==c&&i[a+l-1]<i[a+l+1]?i[a+l+1]:i[a+l-1]+1,o=d-l;for(;d<s&&o<n&&e[d]===t[o];)d+=1,o+=1;if(i[a+l]=d,d>=s&&o>=n)return function(e,t,s,n){let l=[],a=t.length,i=s.length;for(let t=n;t>0;t-=1){let s=e[t],n=e=>s[e+t+1],r=a-i,c=r===-t||r!==t&&n(r-1)<n(r+1)?r+1:r-1,d=n(c),o=d-c;for(;a>d&&i>o;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});a===d?l.push({kind:"add",b:o}):l.push({kind:"del",a:d}),a=d,i=o}for(;a>0&&i>0;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});return l.reverse()}(r,e,t,c)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(s,n),t.slice(s,l)))a.push({kind:i.kind,...void 0!==i.a?{a:i.a+s}:{},...void 0!==i.b?{b:i.b+s}:{}});for(let t=0;n+t<e.length;t+=1)a.push({kind:"same",a:n+t,b:l+t});return a}(e,t),n=[];for(let l=0;l<s.length;){let a=s[l];if("same"===a.kind){n.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 i=[],r=[];for(;l<s.length&&"same"!==s[l].kind;){let e=s[l];"del"===e.kind?i.push(e.a):r.push(e.b),l+=1}let c=Math.max(i.length,r.length);for(let s=0;s<c;s+=1){let l=i[s],a=r[s];n.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 n}function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(n)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let n=0;n<e.length;){if("same"!==e[n].kind){l.push({type:"row",row:e[n],index:n}),n+=1;continue}let a=n;for(;a<e.length&&"same"===e[a].kind;)a+=1;let i=0===n?0:t,r=a===e.length?0:t,c=a-n-i-r;if(c>1&&!s.has(n+i)){for(let t=n;t<n+i;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:n+i,count:c});for(let t=a-r;t<a;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=n;t<a;t+=1)l.push({type:"row",row:e[t],index:t});n=a}return l}function i(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;return{start:s,leftEnd:n,rightEnd:l}}s.d(t,{$8:()=>a,Dx:()=>n,Nj:()=>i,Qp:()=>l})},3374:(e,t,s)=>{s.d(t,{c:()=>l});var n=s(1521);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[s,l]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{if(!e)return;l(Date.now());let s=window.setInterval(()=>l(Date.now()),t);return()=>window.clearInterval(s)},[e,t]),s}},4811:(e,t,s)=>{s.d(t,{p:()=>a});var n=s(1521),l=s(5549);function a(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=!0;return l.FH.settings().then(s=>{var n;let l=null!=(n=s.raw.execution)?n:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},5132:(e,t,s)=>{s.d(t,{s:()=>r});var n=s(3365),l=s(1521);function a(e,t){let s,l=[],a=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,i=0,r=0;for(;null!==(s=a.exec(e));){s.index>i&&l.push(e.slice(i,s.index));let a=s[0],c="".concat(t,"-i").concat(r+=1);a.startsWith("`")?l.push((0,n.jsx)("code",{children:a.slice(1,-1)},c)):a.startsWith("**")?l.push((0,n.jsx)("strong",{children:a.slice(2,-2)},c)):l.push((0,n.jsx)("em",{children:a.slice(1,-1)},c)),i=s.index+a.length}return i<e.length&&l.push(e.slice(i)),l}function i(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let s=/^\s*\d+[.)]\s+(.*)$/.exec(e);return s?s[1]:null}function r(e){let{text:t,className:s}=e,r=[],c=t.replace(/\r\n/g,"\n").split("\n"),d=0,o=0;for(;d<c.length;){let e=c[d];if(e.trim().startsWith("```")){let e=[];for(d+=1;d<c.length&&!c[d].trim().startsWith("```");)e.push(c[d++]);d+=1,e.length>0&&r.push((0,n.jsx)("pre",{children:e.join("\n")},"b".concat(o+=1)));continue}if(null!==i(e)){let e=[];for(;d<c.length&&null!==i(c[d]);)e.push(i(c[d++]));r.push((0,n.jsx)("ul",{children:e.map((e,t)=>(0,n.jsx)("li",{children:a(e,"b".concat(o,"-").concat(t))},t))},"b".concat(o+=1)));continue}if(""===e.trim()){d+=1;continue}let t=[];for(;d<c.length&&""!==c[d].trim()&&null===i(c[d])&&!c[d].trim().startsWith("```");)t.push(c[d++]);let s=o+=1;r.push((0,n.jsx)("p",{children:t.map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),a(e,"b".concat(s,"-").concat(t))]},t))},"b".concat(s)))}return(0,n.jsx)("div",{className:"rich ".concat(null!=s?s:""),children:r})}},6481:(e,t,s)=>{s.d(t,{CV:()=>d,Q1:()=>u});var n=s(3365),l=s(1521),a=s(5549),i=s(4969),r=s(867),c=s(853);function d(e){let{sessionId:t,taskId:s,runId:a,title:i,files:c}=e,{t:d}=(0,r.kj)(),[u,h]=(0,l.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish",onClick:()=>h(!0),title:d("diff.openWhy"),children:d("diff.open",{n:c})}),u&&(0,n.jsx)(o,{sessionId:t,taskId:s,runId:a,title:i,onClose:()=>h(!1)})]})}function o(e){var t,s,d,o,h,f,m;let{sessionId:p,taskId:x,runId:g,title:j,onClose:y}=e,{t:k}=(0,r.kj)(),[v,N]=(0,l.useState)(null),[b,w]=(0,l.useState)(""),[S,C]=(0,l.useState)(0),[q,I]=(0,l.useState)(new Map),[F,R]=(0,l.useState)(!1),[E,L]=(0,l.useState)(!0),[T,M]=(0,l.useState)(new Map),[H,O]=(0,l.useState)(-1),D=(0,l.useRef)(null),W=(0,l.useRef)(null),G=(0,l.useRef)(null);(0,i.V)(W,!0,G),(0,l.useEffect)(()=>{a.FH.taskChanges(p,x,g).then(N).catch(e=>w(e.message))},[p,x,g]);let Q=null!=(d=null==v?void 0:v.files)?d:[],P=Q[S];(0,l.useEffect)(()=>{!P||q.has(P.path)||a.FH.taskChangeFile(p,x,P.path,g).then(e=>I(t=>new Map(t).set(P.path,e))).catch(e=>I(t=>new Map(t).set(P.path,e.message)))},[P,q,p,x,g]);let V=P?q.get(P.path):void 0,A=(0,l.useMemo)(()=>!V||"string"==typeof V||V.binary||V.tooLarge?[]:(0,c.Qp)((0,c.Dx)(V.before),(0,c.Dx)(V.after)),[V]),B=P&&T.get(P.path)||new Set,$=(0,l.useMemo)(()=>(0,c.$8)(A,3,B,F),[A,B,F]),_=(0,l.useMemo)(()=>A.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===A[t-1].kind)?[t]:[]),[A]);(0,l.useEffect)(()=>{O(-1),D.current&&(D.current.scrollTop=0)},[S]);let K=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let s=H<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,H+e));O(s);let n=null==(t=D.current)?void 0:t.querySelector('[data-row="'.concat(_[s],'"]'));null==n||n.scrollIntoView({block:"center"})},[H,_]),U=(0,l.useCallback)(e=>C(t=>Math.min(Math.max(0,t+e),Math.max(0,Q.length-1))),[Q.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)y();else if("n"===e.key)K(1);else if("p"===e.key)K(-1);else if("]"===e.key)U(1);else{if("["!==e.key)return;U(-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}},[K,U,y]);let z=Q.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,n.jsxs)("div",{ref:W,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,n.jsxs)("div",{className:"diff-head",children:[(0,n.jsx)("h2",{id:"diff-title",children:k("diff.title",{title:j})}),(null==v?void 0:v.ok)&&(0,n.jsxs)("span",{className:"muted small",children:[v.branch?"".concat(v.branch," \xb7 "):"",null==(t=v.base)?void 0:t.slice(0,8)," → ",null==(s=v.commit)?void 0:s.slice(0,8)," \xb7 ",k("diff.summary",{n:Q.length,a:z.added,r:z.removed})]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("span",{className:"muted small",children:k("diff.keys")}),(0,n.jsx)("button",{ref:G,type:"button",onClick:y,children:k("diff.close")})]}),b&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:b}),!v&&!b&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),v&&!v.ok&&(0,n.jsx)("div",{className:"notice caution",style:{margin:12},children:v.problem}),(null==v?void 0:v.ok)&&0===Q.length&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.nothing")}),(null==v?void 0:v.ok)&&Q.length>0&&(0,n.jsxs)("div",{className:"diff-body",children:[(0,n.jsx)("nav",{className:"diff-files","aria-label":k("diff.files"),children:Q.map((e,t)=>{let s=e.path.lastIndexOf("/");return(0,n.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,n.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,n.jsxs)("span",{className:"diff-path",children:[s>=0&&(0,n.jsx)("span",{className:"muted",children:e.path.slice(0,s+1)}),(0,n.jsx)("strong",{children:e.path.slice(s+1)})]}),(0,n.jsx)("span",{className:"diff-counts",children:e.added<0?k("diff.binaryShort"):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,n.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,n.jsxs)("div",{className:"diff-main",children:[P&&(0,n.jsxs)("div",{className:"diff-toolbar",children:[(0,n.jsx)("strong",{className:"diff-name",children:P.oldPath?"".concat(P.oldPath," → ").concat(P.path):P.path}),(0,n.jsx)("span",{className:"muted small",children:"A"===P.status?k("diff.added"):"D"===P.status?k("diff.deleted"):"R"===P.status?k("diff.renamed"):""}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(-1),disabled:0===_.length,children:k("diff.prevChange")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>K(1),disabled:0===_.length,children:k("diff.nextChange")}),(0,n.jsx)("span",{className:"muted small",children:_.length>0?k("diff.changeN",{i:H<0?"–":H+1,n:_.length}):""}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(-1),disabled:0===S,children:k("diff.prevFile")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(1),disabled:S>=Q.length-1,children:k("diff.nextFile")}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:F,onChange:e=>R(e.target.checked)})," ",k("diff.whole")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:E,onChange:e=>L(e.target.checked)})," ",k("diff.wrap")]})]}),(0,n.jsxs)("div",{className:"diff-scroll",ref:D,children:[void 0===V&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),"string"==typeof V&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:V}),V&&"string"!=typeof V&&V.binary&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.binary")}),V&&"string"!=typeof V&&V.tooLarge&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.tooLarge")}),V&&"string"!=typeof V&&!V.binary&&!V.tooLarge&&(0,n.jsxs)(n.Fragment,{children:[(null!=(o=V.before)?o:"").includes("\r\n")!==(null!=(h=V.after)?h:"").includes("\r\n")&&null!==V.before&&null!==V.after&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.eol",{from:(null!=(f=V.before)?f:"").includes("\r\n")?"CRLF":"LF",to:(null!=(m=V.after)?m:"").includes("\r\n")?"CRLF":"LF"})}),A.length>0&&0===_.length&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.sameText")}),(0,n.jsxs)("table",{className:"diff-table".concat(E?"":" nowrap"),children:[(0,n.jsxs)("colgroup",{children:[(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{}),(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{})]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{colSpan:2,children:k("diff.before")}),(0,n.jsx)("th",{colSpan:2,children:k("diff.after")})]})}),(0,n.jsx)("tbody",{children:$.map(e=>"gap"===e.type?(0,n.jsx)("tr",{className:"diff-gap",children:(0,n.jsx)("td",{colSpan:4,children:(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(P&&M(e=>{var s;return new Map(e).set(P.path,new Set([...null!=(s=e.get(P.path))?s:[],t]))}))},children:k("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,n.jsx)(u,{row:e.row,index:e.index,current:H>=0&&_[H]===e.index},e.index))})]})]})]})]})]})]})}function u(e){var t,s,a,i;let{row:r,index:d,current:o}=e,u="change"===r.kind?(0,c.Nj)(r.left.text,r.right.text):null,h=e=>{let t=r[e];if(!t)return null;if(!u)return t.text;let s="left"===e?u.leftEnd:u.rightEnd;return(0,n.jsxs)(l.Fragment,{children:[t.text.slice(0,u.start),(0,n.jsx)("mark",{children:t.text.slice(u.start,s)}),t.text.slice(s)]})};return(0,n.jsxs)("tr",{className:"diff-row ".concat(r.kind).concat(o?" current":""),"data-row":d,children:[(0,n.jsx)("td",{className:"num",children:null!=(a=null==(t=r.left)?void 0:t.no)?a:""}),(0,n.jsx)("td",{className:"code l".concat(r.left?"":" empty"),children:h("left")}),(0,n.jsx)("td",{className:"num",children:null!=(i=null==(s=r.right)?void 0:s.no)?i:""}),(0,n.jsx)("td",{className:"code r".concat(r.right?"":" empty"),children:h("right")})]})}},7619:(e,t,s)=>{s.d(t,{P:()=>o});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7908),c=s(5132);function d(e){let{text:t,follow:s}=e,{ref:l}=(0,r.U)(s,t);return(0,n.jsx)("pre",{ref:l,className:"story-out".concat(s?" terminal":""),children:t})}function o(e){let{sessionId:t,taskId:s,runId:o,live:h}=e,{t:f}=(0,i.kj)(),[m,p]=(0,l.useState)(null),[x,g]=(0,l.useState)(""),[j,y]=(0,l.useState)(!0),[k,v]=(0,l.useState)(!0),[N,b]=(0,l.useState)(new Set),[w,S]=(0,l.useState)(new Set),[C,q]=(0,l.useState)(new Set),I=!!(null==m?void 0:m.live),F=(0,l.useRef)(0);F.current+=1;let R=(0,r.U)(I,F.current),E=(0,l.useRef)(null),L=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!m)return;let e=[],t=(s,n)=>s.forEach((s,l)=>{let a="".concat(n).concat(l);"review"===s.kind?t(s.entries,"".concat(a,"-")):"step"!==s.kind||s.outcome||e.push(a)});t(m.entries,"e"),e.some(e=>!w.has(e))&&S(t=>new Set([...t,...e])),m.live&&!L.current&&E.current&&(L.current=!0,E.current.scrollIntoView({block:"nearest",behavior:"smooth"}))},[m,w]),(0,l.useEffect)(()=>{let e,n=!0,l=async()=>{try{let i=await a.FH.taskStory(t,s,o);if(!n)return;p(i),g(""),(i.live||h)&&(e=setTimeout(l,2e3))}catch(t){if(!n)return;g(t.message),h&&(e=setTimeout(l,2e3))}};return l(),()=>{n=!1,e&&clearTimeout(e)}},[t,s,o,h]),x&&!m)return(0,n.jsx)("div",{className:"err small",children:x});if(!m)return(0,n.jsx)("div",{className:"muted small",children:f("story.loading")});let T=e=>N.has(e)||w.has(e)&&!C.has(e),M=e=>{let t=T(e);b(s=>{let n=new Set(s);return t?n.delete(e):n.add(e),n}),q(s=>{let n=new Set(s);return t?n.add(e):n.delete(e),n})},H=(e,t)=>{if(!("review"===e.kind?j||k:"step"===e.kind?k:j))return null;if("review"===e.kind)return(0,n.jsxs)("li",{className:"story-review",children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.review",{n:e.round})})]}),(0,n.jsx)("ol",{className:"story",children:e.entries.map((e,s)=>H(e,"".concat(t,"-").concat(s)))})]},t);if("step"===e.kind){let s=T(t),l=!e.outcome&&m.live;return(0,n.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,n.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,n.jsx)("span",{className:"badge running",children:f("story.running")}),e.failed&&(0,n.jsx)("span",{className:"badge failed",children:f("story.failedHere")})]}),(0,n.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideOutput"):f("story.showOutput",{n:e.output.length})}),s&&(0,n.jsx)(d,{text:e.output,follow:l})]})]},t)}let s=N.has(t),l="sent"===e.kind?f("story.bot"):f("story.chat"),i="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,n.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(i?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("strong",{children:l}),(0,n.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,n.jsx)("span",{className:"badge ".concat(i?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,n.jsx)("p",{className:"story-notes",children:e.notes}),(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideText"):f("story.showText",{n:e.text.length})}),s&&(0,n.jsx)("pre",{className:"story-out",children:e.text})]},t)},O=m.close,D=O&&"done"!==O.status;return(0,n.jsxs)("div",{className:"story-box",ref:E,children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:j,onChange:e=>y(e.target.checked)})," ",f("story.showChat")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:k,onChange:e=>v(e.target.checked)})," ",f("story.showCommands")]}),m.live&&(0,n.jsxs)("span",{className:"live",children:[(0,n.jsx)("span",{className:"dot","aria-hidden":"true"})," ",f("story.live")]}),m.live&&!R.following&&(0,n.jsx)("button",{type:"button",className:"quiet small",onClick:R.follow,title:f("story.followWhy"),children:f("story.follow")}),x&&(0,n.jsx)("span",{className:"err",children:x})]}),(0,n.jsxs)("div",{className:"story-fixed",children:[(0,n.jsx)("strong",{children:f("story.prompt")}),(0,n.jsx)("pre",{className:"story-out always",children:m.prompt})]}),(0,n.jsx)("div",{ref:R.ref,className:"story-scroll".concat(m.live?" live":""),children:(0,n.jsx)("ol",{className:"story",children:m.entries.map((e,t)=>H(e,"e".concat(t)))})}),O?(0,n.jsxs)("div",{className:"story-fixed close".concat(D?" failed":""),children:[(0,n.jsx)("strong",{children:D?f("story.endedBadly",{status:O.status}):f("story.ended")}),O.reason&&(0,n.jsx)("p",{className:"err small",children:O.reason}),O.summary&&(0,n.jsx)(c.s,{text:O.summary,className:"what"}),O.checks&&O.checks.length>0&&(0,n.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:O.checks.map((e,t)=>(0,n.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,n.jsx)("div",{className:"story-fixed muted small",children:f("story.notEnded")})]})}function u(e){let{at:t}=e,s=(0,i.W3)(),{locale:l}=(0,i.kj)();if(!t)return null;let a=new Date(t),r="bg"===l?"bg-BG":void 0,c=a.toLocaleTimeString(r,{hour12:!1}),d=new Date().toDateString()===a.toDateString();return(0,n.jsx)("time",{className:"story-when",dateTime:t,title:s(t),children:d?c:"".concat(a.toLocaleDateString(r)," ").concat(c)})}},7908:(e,t,s)=>{s.d(t,{U:()=>l});var n=s(1521);function l(e,t){let[s,l]=(0,n.useState)(null),a=(0,n.useRef)(!0),[i,r]=(0,n.useState)(!0),c=(0,n.useCallback)(e=>l(e),[]);return(0,n.useLayoutEffect)(()=>{if(!s)return;let e=()=>{let e=s.scrollHeight-s.scrollTop-s.clientHeight<=24;a.current=e,r(e)};return s.addEventListener("scroll",e,{passive:!0}),()=>s.removeEventListener("scroll",e)},[s]),(0,n.useLayoutEffect)(()=>{s&&e&&a.current&&(s.scrollTop=s.scrollHeight)},[s,e,t]),{ref:c,following:i,follow:(0,n.useCallback)(()=>{a.current=!0,r(!0),s&&(s.scrollTop=s.scrollHeight)},[s])}}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[549],{5549:(t,o,e)=>{e.d(o,{AV:()=>a,Dh:()=>h,FH:()=>u,FZ:()=>r,Zm:()=>p,aT:()=>s,c5:()=>f,dK:()=>l,nC:()=>n,rt:()=>d,ub:()=>i,zi:()=>y});let n="/api";function s(t,o){return"/sessions/view?id=".concat(encodeURIComponent(t)).concat(o?"#".concat(o):"")}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 o=a();return o?"".concat(t).concat(t.includes("?")?"&":"?","token=").concat(encodeURIComponent(o)):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 p(t){return"limit-reached"===t.status||"aborted"===t.status||!!t.limit&&("failed"===t.status||"blocked"===t.status)}function h(t){return("failed"===t.status||"blocked"===t.status)&&"contract-conflict"!==t.stopCode}async function m(t,o){let e,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;e=await fetch("".concat(n).concat(t),{...o,...null!==c&&!(null==o?void 0:o.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==o?void 0:o.headers)?i:{}}})}catch(o){if("TimeoutError"===o.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 o}if(!e.ok){let t="".concat(e.status," ").concat(e.statusText);try{let o=await e.json();(null==o?void 0:o.message)&&(t=Array.isArray(o.message)?o.message.join("; "):o.message)}catch(t){}throw Error(t)}let r=await e.text();return r?JSON.parse(r):void 0}let u={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,o)=>m("/presets/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),deletePreset:t=>m("/presets/".concat(encodeURIComponent(t)),{method:"DELETE"}),personas:()=>m("/personas"),savePersona:(t,o)=>m("/personas/".concat(encodeURIComponent(t)),{method:"PUT",body:JSON.stringify({content:o})}),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 o=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return m("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:t,fetch:o})},{timeoutMs:33e4})},prepareProject:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/repo/prepare",{method:"POST",body:JSON.stringify({dir:t,fingerprint:o,...e})})},session:t=>m("/sessions/".concat(t)),createSession:(t,o)=>m("/sessions",{method:"POST",body:JSON.stringify({name:t,projectDir:o})}),updateSession:(t,o)=>m("/sessions/".concat(t),{method:"PUT",body:JSON.stringify(o)}),deleteSession:t=>m("/sessions/".concat(t),{method:"DELETE"}),addTask:(t,o)=>m("/sessions/".concat(t,"/tasks"),{method:"POST",body:JSON.stringify(o)}),updateTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o),{method:"PUT",body:JSON.stringify(e)}),deleteTask:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o),{method:"DELETE"}),continueTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/continue"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{instruction:e}:{})}),rerunTask:function(t,o){let e=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(o,"/rerun"),{method:"POST",body:JSON.stringify({...e,...n.buildOnFinished?{buildOnFinished:!0}:{}})})},taskChanges:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/changes").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskChangeFile:(t,o,e,n)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/changes/file?path=").concat(encodeURIComponent(e)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/story").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskFiles:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/files").concat(e?"?run=".concat(encodeURIComponent(e)):"")),taskLogUrl:(t,o,e)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),taskFileUrl:(t,o,e,s,c)=>"".concat(n,"/sessions/").concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(s)).concat(c?"?run=".concat(encodeURIComponent(c)):""),saveTaskLog:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/log").concat(e?"?run=".concat(encodeURIComponent(e)):""),{method:"POST",body:"{}"}),saveTaskFile:(t,o,e,n,s)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/files/").concat(e,"/").concat(encodeURIComponent(n)).concat(s?"?run=".concat(encodeURIComponent(s)):""),{method:"POST",body:"{}"}),start:(t,o,e,n)=>m("/sessions/".concat(t,"/start"),{method:"POST",body:JSON.stringify({mode:o,name:e,starts:n})},{timeoutMs:12e4}),startOptions:t=>m("/start/options?sessions=".concat(encodeURIComponent(t.join(",")))),startFetch:(t,o,e)=>m("/start/fetch",{method:"POST",body:JSON.stringify({dir:t,remote:o,...e?{branches:e}:{}})},{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)):"")),undoPreview:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/undo")),undoTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/undo"),{method:"POST",body:JSON.stringify({how:e})}),acceptTask:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/accept"),{method:"POST",body:JSON.stringify((null==e?void 0:e.trim())?{note:e}:{})}),addTaskNote:(t,o,e)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/notes"),{method:"POST",body:JSON.stringify({text:e})}),kerriganReport:t=>m("/kerrigan/report",{method:"POST",body:JSON.stringify(t)}),checkChanges:t=>m("/changes/check",{method:"POST",body:JSON.stringify({text:t})}),applyChanges:t=>m("/changes/apply",{method:"POST",body:JSON.stringify({text:t})}),workspace:()=>m("/workspace"),workspaceFiles:()=>m("/workspace/files"),workspaceFile:t=>m("/workspace/file?path=".concat(encodeURIComponent(t))),workspaceGit:()=>m("/workspace/git"),workspaceCommit:t=>m("/workspace/git/commit?sha=".concat(encodeURIComponent(t))),workspaceGitFile:(t,o,e)=>m("/workspace/git/file?area=".concat(t,"&path=").concat(encodeURIComponent(o)).concat(e?"&commit=".concat(encodeURIComponent(e)):"")),chatThreads:()=>m("/chat/threads"),chatSend:(t,o,e,n)=>m("/chat",{method:"POST",body:JSON.stringify({text:t,...o?{threadId:o}:{},...e?{model:e}:{},...n?{manualModel:!0}:{}})}),chatRewind:(t,o)=>m("/chat/".concat(t,"/rewind"),{method:"POST",body:JSON.stringify({taskId:o})}),repoTree:function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2?arguments[2]:void 0;return m("/sessions/".concat(t,"/repo/tree?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):""))},repoFile:(t,o,e)=>m("/sessions/".concat(t,"/repo/file?path=").concat(encodeURIComponent(o)).concat(e?"&task=".concat(encodeURIComponent(e)):"")),repoLog:t=>m("/sessions/".concat(t,"/repo/log")),sessionEvents:t=>m("/sessions/".concat(t,"/events")),decidePlan:(t,o,e)=>m("/approvals/".concat(t,"/plan"),{method:"POST",body:JSON.stringify({action:o,...(null==e?void 0:e.trim())?{note:e}:{}})}),decide:(t,o)=>m("/approvals/".concat(t),{method:"POST",body:JSON.stringify({action:o})}),setRunMode:(t,o)=>m("/sessions/".concat(t,"/mode"),{method:"POST",body:JSON.stringify({mode:o})}),streamUrl:t=>i("".concat(n,"/sessions/").concat(t,"/stream")),batch:()=>m("/batch").then(t=>null!=t?t:null),startBatch:(t,o,e,n,s,c,a,i)=>m("/batch/start",{method:"POST",body:JSON.stringify({sessionIds:t,mode:o,onFailure:e,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,o)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(o))),setContext:(t,o)=>m("/context/".concat(t),{method:"PUT",body:JSON.stringify({content:o})}),resetContext:(t,o)=>m("/context/".concat(t,"?lang=").concat(encodeURIComponent(o)),{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 o,e,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==(o=/filename\*=UTF-8''([^;]+)/i.exec(i))?void 0:o[1],d=null==(e=/filename="([^"]+)"/i.exec(i))?void 0:e[1],l=null!=d?d:"copilot-operator-bundle.json";if(r)try{l=decodeURIComponent(r)}catch(t){}let p=URL.createObjectURL(await c.blob()),h=document.createElement("a");return h.href=p,h.download=l,document.body.appendChild(h),h.click(),h.remove(),setTimeout(()=>URL.revokeObjectURL(p),1e4),l},exportUrl:(t,o)=>{let e=new URLSearchParams;return o.run&&e.set("run",o.run),o.session&&e.set("session",o.session),o.task&&e.set("task",o.task),i("".concat(n,"/export/").concat(t,"?").concat(e.toString()))},taskExchangeUrl:(t,o)=>i("".concat(n,"/sessions/").concat(encodeURIComponent(t),"/tasks/").concat(encodeURIComponent(o),"/exchange")),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,o,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return m("/batch/vcs/prepare",{method:"POST",body:JSON.stringify({sessionIds:t,repoDir:o,action:e,choices:n})})},vcsSnapshot:(t,o)=>m("/sessions/".concat(t,"/vcs/snapshot"),{method:"POST",body:JSON.stringify({choices:o})}),restorePreview:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restore")),restore:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restore"),{method:"POST",body:"{}"}),contractCheck:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/contract")),applyContractFix:(t,o,e,n)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/contract-fix"),{method:"POST",body:JSON.stringify({choices:e,expect:n})}),restartPlan:(t,o)=>m("/sessions/".concat(t,"/tasks/").concat(o,"/restart")),restartFrom:function(t,o){let e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return m("/sessions/".concat(t,"/tasks/").concat(o,"/restart"),{method:"POST",body:JSON.stringify(e)})},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 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 o=Math.round(t/1e3);if(o<60)return"".concat(o,"s");let e=Math.floor(o/60);return e<60?"".concat(e,"m ").concat(o%60,"s"):"".concat(Math.floor(e/60),"h ").concat(e%60,"m")}}}]);