copilot-operator 0.1.51 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +8 -3
  2. package/dist/src/api/operator.controller.js +32 -81
  3. package/dist/src/api/operator.service.js +166 -109
  4. package/dist/src/config/schema.js +13 -0
  5. package/dist/src/orchestrator/leadRunner.js +559 -0
  6. package/dist/src/orchestrator/taskRunner.js +55 -17
  7. package/dist/src/plan/kerrigan.js +172 -47
  8. package/dist/src/plan/systemGuide.js +443 -506
  9. package/dist/src/protocol/leadSchema.js +156 -0
  10. package/dist/src/protocol/parser.js +1 -1
  11. package/dist/src/session/chatNotice.js +115 -0
  12. package/dist/src/session/checkpoint.js +19 -0
  13. package/dist/src/session/compose.js +1 -1
  14. package/dist/src/session/store.js +18 -72
  15. package/dist/src/transport/copilotTransport.js +2 -0
  16. package/dist/web/404.html +13 -18
  17. package/dist/web/_next/static/_1zhoDsMOPAH2xW702E5A/_buildManifest.js +1 -0
  18. package/dist/web/_next/static/chunks/163.dbd7d36584d0bb37.js +1 -0
  19. package/dist/web/_next/static/chunks/220.35531b39410e1a9f.js +1 -0
  20. package/dist/web/_next/static/chunks/548.71ac96c94136659b.js +1 -0
  21. package/dist/web/_next/static/chunks/584.6df695c5b86a75aa.js +1 -0
  22. package/dist/web/_next/static/chunks/67.9ed79e2fbfb56f26.js +1 -0
  23. package/dist/web/_next/static/chunks/714.1e2338736a70b9c7.js +1 -0
  24. package/dist/web/_next/static/chunks/747.d2c1249d736dc03b.js +1 -0
  25. package/dist/web/_next/static/chunks/77.a200abef0f5b4a7f.js +1 -0
  26. package/dist/web/_next/static/chunks/808-bc7d7eac6d823291.js +1 -0
  27. package/dist/web/_next/static/chunks/921-dc5538cd779c6432.js +1 -0
  28. package/dist/web/_next/static/chunks/app/defaults/page-edd7534ca9ecf366.js +1 -0
  29. package/dist/web/_next/static/chunks/app/layout-8f99a164d76897a0.js +1 -0
  30. package/dist/web/_next/static/chunks/app/page-4bed816eda370d0c.js +1 -0
  31. package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
  32. package/dist/web/_next/static/chunks/webpack-77147e31d2125631.js +1 -0
  33. package/dist/web/_next/static/css/3bea264adc472bc8.css +1 -0
  34. package/dist/web/defaults.html +13 -18
  35. package/dist/web/defaults.txt +9 -9
  36. package/dist/web/index.html +13 -18
  37. package/dist/web/index.txt +9 -9
  38. package/dist/web/system.html +13 -18
  39. package/dist/web/system.txt +9 -9
  40. package/package.json +4 -5
  41. package/prompts/lead1.md +116 -0
  42. package/dist/src/vcs/prepareFromRemote.js +0 -288
  43. package/dist/src/vcs/remoteAuth.js +0 -117
  44. package/dist/src/vcs/syncCommand.js +0 -97
  45. package/dist/web/_next/static/chunks/190-70555f20dd0da19b.js +0 -1
  46. package/dist/web/_next/static/chunks/643-e85d221d57900ed7.js +0 -1
  47. package/dist/web/_next/static/chunks/867-869900ec999e6345.js +0 -1
  48. package/dist/web/_next/static/chunks/app/appearance/page-cdef33c421397cbe.js +0 -1
  49. package/dist/web/_next/static/chunks/app/defaults/page-e0a2b8f9a41a94c4.js +0 -1
  50. package/dist/web/_next/static/chunks/app/layout-b4fc21e26e1bad95.js +0 -1
  51. package/dist/web/_next/static/chunks/app/level1/page-31b74cae86d960d8.js +0 -1
  52. package/dist/web/_next/static/chunks/app/page-1075921d44db3e4d.js +0 -1
  53. package/dist/web/_next/static/chunks/app/presets/page-f8abdd83cdf468f7.js +0 -1
  54. package/dist/web/_next/static/chunks/app/system/page-2a270bb885885821.js +0 -1
  55. package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
  56. package/dist/web/_next/static/css/8b14cb3cf0051138.css +0 -1
  57. package/dist/web/_next/static/eqTUTH_SJtBgNgq8Zzy3n/_buildManifest.js +0 -1
  58. package/dist/web/appearance.html +0 -18
  59. package/dist/web/appearance.txt +0 -25
  60. package/dist/web/level1.html +0 -18
  61. package/dist/web/level1.txt +0 -25
  62. package/dist/web/presets.html +0 -21
  63. package/dist/web/presets.txt +0 -25
  64. /package/dist/web/_next/static/{eqTUTH_SJtBgNgq8Zzy3n → _1zhoDsMOPAH2xW702E5A}/_ssgManifest.js +0 -0
@@ -1,288 +0,0 @@
1
- /**
2
- * "Prepare the folder from the remote main branch": the project folder put exactly where the team's
3
- * code is — the remote's main branch, freshly fetched, checked out as the local branch of the same
4
- * name, with no uncommitted changes — so the operator can add the files a task needs on top of it and
5
- * hand it to the bot from there.
6
- *
7
- * Asked for on 2026-10-03, after a run was refused for uncommitted files on a branch the operator had
8
- * put them on: a button beside the project in Settings, instead of the command to copy that
9
- * `syncCommand.ts` hands out. A command to paste was the answer while the only way back to the remote
10
- * was `reset --hard` and `clean -fd`, which throw work away. This does not throw anything away, which
11
- * is what makes it a button:
12
- *
13
- * 1. Everything not on the remote's main is kept first. Uncommitted changes and new files git does
14
- * not ignore become one commit on a branch of their own (`<prefix>saved/<when>`), made with a
15
- * temporary index, so neither the checkout nor the real index moves while it is made — and it is
16
- * checked to hold every one of them before anything else happens. Commits of the local main
17
- * branch that the remote does not have get a branch of their own too. The branch the folder was
18
- * on keeps its commits; no branch is deleted.
19
- * 2. Only then is the folder moved: the local main branch is set to the remote's main and checked
20
- * out, and the new files that are now on the saved branch are removed from the folder. Ignored
21
- * files — node_modules, .env, build output, what a snapshot left out — are not touched.
22
- * 3. The result is read back: HEAD on the remote's main, nothing uncommitted. Otherwise it says so.
23
- *
24
- * The preview fetches (so what it shows is against the remote as it is now) and changes nothing else;
25
- * the preparation itself refuses when the folder is no longer what the preview showed.
26
- */
27
- import { existsSync } from 'node:fs';
28
- import { rm } from 'node:fs/promises';
29
- import { tmpdir } from 'node:os';
30
- import { join, resolve } from 'node:path';
31
- import { createHash } from 'node:crypto';
32
- import { branchNameFrom, freeBranchName, git, lastFetchedAt, porcelainPaths, RUNNER_EMAIL } from './git.js';
33
- import { fetchAsOperator, fetchCommandFor } from './remoteAuth.js';
34
- const short = (c) => (c ?? '').slice(0, 8);
35
- const lines = (s) => s.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
36
- function stamp(now = new Date()) {
37
- const p = (n) => String(n).padStart(2, '0');
38
- return `${now.getFullYear()}${p(now.getMonth() + 1)}${p(now.getDate())}-${p(now.getHours())}${p(now.getMinutes())}${p(now.getSeconds())}`;
39
- }
40
- /** A merge, rebase, cherry-pick or revert half done: the folder is the operator's to finish first. */
41
- function operationInProgress(gitDir) {
42
- for (const [file, what] of [
43
- ['MERGE_HEAD', 'a merge'],
44
- ['rebase-merge', 'a rebase'],
45
- ['rebase-apply', 'a rebase'],
46
- ['CHERRY_PICK_HEAD', 'a cherry-pick'],
47
- ['REVERT_HEAD', 'a revert'],
48
- ]) {
49
- if (existsSync(join(gitDir, file)))
50
- return what;
51
- }
52
- return null;
53
- }
54
- const empty = (repoDir, problem) => ({
55
- ok: false,
56
- problem,
57
- repoDir,
58
- changed: [],
59
- untracked: [],
60
- mainOnlyCommits: [],
61
- branchOnlyCommits: [],
62
- });
63
- /**
64
- * What preparing the folder would do. Fetches the remote when `fetch` is true (the preview); reads
65
- * only when it is false (the preparation, which must compare against what the preview fetched, or a
66
- * preview after the operator fetched in their own terminal). With `askpass`, the fetch may ask for a
67
- * password through that program (see `remoteAuth.ts`); without it, it may not ask at all.
68
- */
69
- export async function planPrepare(folder, opts) {
70
- const inside = await git(folder, ['rev-parse', '--is-inside-work-tree']);
71
- if (!inside.ok || inside.stdout !== 'true')
72
- return empty(folder, `${folder} is not a git repository.`);
73
- // The whole repository, not the folder under it the project may name: a checkout moves all of it.
74
- const topR = await git(folder, ['rev-parse', '--show-toplevel']);
75
- const repoDir = topR.ok && topR.stdout ? resolve(topR.stdout) : folder;
76
- const gitDir = (await git(repoDir, ['rev-parse', '--absolute-git-dir'])).stdout;
77
- const busy = gitDir ? operationInProgress(gitDir) : null;
78
- if (busy)
79
- return empty(repoDir, `The repository is in the middle of ${busy}. Finish or abort it first; nothing was changed.`);
80
- const headR = await git(repoDir, ['rev-parse', '--verify', '--quiet', 'HEAD']);
81
- if (!headR.ok || !headR.stdout)
82
- return empty(repoDir, 'The repository has no commits yet, so there is nothing to keep the changes on top of. Make a first commit, then press it again.');
83
- const branchR = await git(repoDir, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
84
- const branch = branchR.ok && branchR.stdout ? branchR.stdout : null;
85
- const remotes = lines((await git(repoDir, ['remote'])).stdout);
86
- if (remotes.length === 0)
87
- return empty(repoDir, 'The repository has no remote, so there is no remote main branch to prepare it from.');
88
- const remote = remotes.includes('origin') ? 'origin' : remotes[0];
89
- const fetchCommand = fetchCommandFor(repoDir, remote);
90
- // Read before fetching: a fetch that fails empties FETCH_HEAD, and with it the time of the last one that worked.
91
- const lastBefore = gitDir ? lastFetchedAt(gitDir) : undefined;
92
- let fetched;
93
- if (opts.fetch) {
94
- /*
95
- * With the password window when there is one, the whole remote in one connection, so the remote's
96
- * main is read from what was fetched, below. Once more when the first try fails: see `gitFetch`
97
- * (2026-10-05, every first press failed at work).
98
- */
99
- const f = await fetchAsOperator(repoDir, remote, { askpass: opts.askpass ?? null });
100
- fetched = f.ok ? { ok: true, asked: f.asked, ...(f.retried ? { retried: true, ...(f.firstError ? { firstError: f.firstError } : {}) } : {}) } : { ok: false, detail: f.detail, auth: f.auth, asked: f.asked };
101
- }
102
- let target = '';
103
- const remoteHead = await git(repoDir, ['symbolic-ref', '--quiet', '--short', `refs/remotes/${remote}/HEAD`]);
104
- if (remoteHead.ok && remoteHead.stdout)
105
- target = remoteHead.stdout;
106
- for (const name of ['main', 'master']) {
107
- if (target)
108
- break;
109
- if ((await git(repoDir, ['rev-parse', '--verify', '--quiet', `refs/remotes/${remote}/${name}`])).ok)
110
- target = `${remote}/${name}`;
111
- }
112
- const last = fetched && !fetched.ok ? lastBefore : gitDir ? lastFetchedAt(gitDir) : undefined;
113
- if (!target) {
114
- return {
115
- ...empty(repoDir, fetched && !fetched.ok ? `The remote could not be fetched (${fetched.detail}), and no main branch of ${remote} is known here.` : `No main branch of ${remote} is known here.`),
116
- ...(fetched ? { fetched } : {}),
117
- fetchCommand,
118
- };
119
- }
120
- if (fetched && !fetched.ok) {
121
- return {
122
- ...empty(repoDir, `The remote could not be fetched, so the folder would be set to an old copy of ${target}: ${fetched.detail}. Nothing was changed.`),
123
- fetched,
124
- fetchCommand,
125
- ...(last ? { lastFetched: last } : {}),
126
- };
127
- }
128
- const targetCommit = (await git(repoDir, ['rev-parse', '--verify', '--quiet', `refs/remotes/${target}^{commit}`])).stdout;
129
- if (!targetCommit)
130
- return empty(repoDir, `${target} could not be read.`);
131
- const localBranch = target.slice(remote.length + 1);
132
- const localHead = (await git(repoDir, ['rev-parse', '--verify', '--quiet', `refs/heads/${localBranch}^{commit}`])).stdout || null;
133
- const status = await git(repoDir, ['status', '--porcelain', '--untracked-files=no']);
134
- const changed = porcelainPaths(status.stdout);
135
- const untracked = lines((await git(repoDir, ['ls-files', '--others', '--exclude-standard'])).stdout);
136
- const mainOnlyCommits = localHead ? lines((await git(repoDir, ['log', '--format=%h %s', `${targetCommit}..${localHead}`])).stdout) : [];
137
- const branchOnlyCommits = branch && branch !== localBranch ? lines((await git(repoDir, ['log', '--format=%h %s', `${targetCommit}..HEAD`])).stdout) : [];
138
- const prefix = opts.prefix || 'cop/';
139
- const when = stamp();
140
- const dirty = changed.length + untracked.length > 0;
141
- // The local main's own commits need a branch only when nothing else keeps them: the saved commit sits on top of them when the folder is on main.
142
- const mainNeedsKeeping = mainOnlyCommits.length > 0 && !(dirty && branch === localBranch);
143
- const savedBranch = dirty ? await freeBranchName(repoDir, `${branchNameFrom(['saved'], prefix)}/${when}`) : undefined;
144
- const savedMainBranch = mainNeedsKeeping ? await freeBranchName(repoDir, `${branchNameFrom(['saved'], prefix)}/${when}-${localBranch}`) : undefined;
145
- const alreadyThere = !dirty && branch === localBranch && headR.stdout === targetCommit;
146
- const fingerprint = createHash('sha256')
147
- .update([headR.stdout, branch ?? '', targetCommit, localHead ?? '', status.stdout, untracked.join('\n')].join('\0'))
148
- .digest('hex')
149
- .slice(0, 16);
150
- return {
151
- ok: true,
152
- repoDir,
153
- branch,
154
- head: headR.stdout,
155
- remote,
156
- target,
157
- targetCommit,
158
- localBranch,
159
- localHead,
160
- ...(fetched ? { fetched } : {}),
161
- ...(last ? { lastFetched: last } : {}),
162
- fetchCommand,
163
- changed,
164
- untracked,
165
- mainOnlyCommits,
166
- branchOnlyCommits,
167
- ...(savedBranch ? { savedBranch } : {}),
168
- ...(savedMainBranch ? { savedMainBranch } : {}),
169
- ...(alreadyThere ? { alreadyThere } : {}),
170
- fingerprint,
171
- };
172
- }
173
- /**
174
- * Every uncommitted change and new file, as one commit on top of HEAD on a branch of its own, made
175
- * with a temporary index — then checked to hold all of them, so nothing is removed from the folder
176
- * that is not kept.
177
- */
178
- async function keepUncommitted(dir, head, branch, message) {
179
- const index = join(tmpdir(), `cop-saved-index-${process.pid}-${Date.now()}`);
180
- const env = { ...process.env, GIT_INDEX_FILE: index };
181
- try {
182
- const read = await git(dir, ['read-tree', head], 60_000, env);
183
- if (!read.ok)
184
- return { problem: read.stderr || 'git read-tree failed' };
185
- const added = await git(dir, ['add', '-A', '--', '.'], 300_000, env);
186
- if (!added.ok)
187
- return { problem: `the changes could not be read into git: ${added.stderr || added.stdout}` };
188
- // Kept means kept: no tracked file differs from the saved index, and no new file is outside it.
189
- const differs = await git(dir, ['diff-files', '--name-only'], 120_000, env);
190
- const outside = await git(dir, ['ls-files', '--others', '--exclude-standard'], 120_000, env);
191
- if (!differs.ok || differs.stdout || !outside.ok || outside.stdout) {
192
- return { problem: `not every change could be kept (${[differs.stdout, outside.stdout].filter(Boolean).join(', ').slice(0, 300) || differs.stderr || outside.stderr}), so nothing was moved.` };
193
- }
194
- const tree = await git(dir, ['write-tree'], 60_000, env);
195
- if (!tree.ok || !tree.stdout)
196
- return { problem: tree.stderr || 'git write-tree failed' };
197
- const commit = await git(dir, ['-c', 'user.name=copilot-operator', '-c', `user.email=${RUNNER_EMAIL}`, 'commit-tree', tree.stdout, '-p', head, '-m', message]);
198
- if (!commit.ok || !commit.stdout)
199
- return { problem: commit.stderr || 'git commit-tree failed' };
200
- const made = await git(dir, ['branch', branch, commit.stdout]);
201
- if (!made.ok)
202
- return { problem: made.stderr || `the branch ${branch} could not be made` };
203
- return { commit: commit.stdout };
204
- }
205
- finally {
206
- await rm(index, { force: true });
207
- }
208
- }
209
- /** Does it, after checking the folder is still what the preview showed. */
210
- export async function prepareFromRemote(folder, fingerprint,
211
- /** `names`: the saved-branch names the preview showed, used when still free, so Confirm makes what was shown. */
212
- opts = {}) {
213
- const plan = await planPrepare(folder, { fetch: false, prefix: opts.prefix });
214
- // The names the operator saw, not ones stamped a minute later (live run 2026-10-03).
215
- const prefix = opts.prefix || 'cop/';
216
- const free = async (name) => !!name && name.startsWith(`${prefix}saved/`) && !(await git(plan.repoDir, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}`])).ok;
217
- if (plan.savedBranch && (await free(opts.names?.savedBranch)))
218
- plan.savedBranch = opts.names.savedBranch;
219
- if (plan.savedMainBranch && (await free(opts.names?.savedMainBranch)))
220
- plan.savedMainBranch = opts.names.savedMainBranch;
221
- if (!plan.ok)
222
- return { ok: false, problem: plan.problem ?? 'the folder could not be read.' };
223
- const repoDir = plan.repoDir;
224
- if (!fingerprint || plan.fingerprint !== fingerprint) {
225
- return { ok: false, problem: 'The folder changed since the preview was shown (a commit, a branch, a changed or new file). Look at the preview again; nothing was changed.' };
226
- }
227
- const target = plan.target;
228
- const targetCommit = plan.targetCommit;
229
- const localBranch = plan.localBranch;
230
- const head = plan.head;
231
- if (plan.alreadyThere) {
232
- return { ok: true, branch: localBranch, commit: targetCommit, target, saved: [], removedFromFolder: 0, result: `The folder is already on ${localBranch} at ${short(targetCommit)}, the same as ${target}, with nothing uncommitted. Nothing was changed.` };
233
- }
234
- const saved = [];
235
- if (plan.savedBranch) {
236
- const what = `${plan.changed.length} changed and ${plan.untracked.length} new file(s) from ${plan.branch ?? `HEAD ${short(head)}`}`;
237
- const message = [
238
- 'Keep uncommitted work before preparing the folder from the remote',
239
- '',
240
- `Everything that was not committed in the folder on ${plan.branch ?? 'a detached HEAD'} (${short(head)}), kept here before the folder was set to ${target} (${short(targetCommit)}).`,
241
- 'To take a file back: git restore --source <this branch> -- <path>',
242
- '',
243
- ...[...plan.changed.map((p) => `- changed: ${p}`), ...plan.untracked.map((p) => `- new: ${p}`)].slice(0, 300),
244
- '',
245
- 'Committed by copilot-operator. Not pushed.',
246
- '',
247
- ].join('\n');
248
- const kept = await keepUncommitted(repoDir, head, plan.savedBranch, message);
249
- if ('problem' in kept)
250
- return { ok: false, problem: kept.problem };
251
- saved.push({ branch: plan.savedBranch, commit: kept.commit, what });
252
- }
253
- if (plan.savedMainBranch && plan.localHead) {
254
- const made = await git(repoDir, ['branch', plan.savedMainBranch, plan.localHead]);
255
- if (!made.ok)
256
- return { ok: false, problem: `the commits of ${localBranch} the remote does not have could not be kept on ${plan.savedMainBranch}: ${made.stderr}. ${saved.length ? `The uncommitted work is on ${saved[0].branch}; ` : ''}the folder was not moved.` };
257
- saved.push({ branch: plan.savedMainBranch, commit: plan.localHead, what: `${plan.mainOnlyCommits.length} commit(s) of ${localBranch} that ${target} does not have` });
258
- }
259
- // Everything is kept; now the folder. The forced checkout drops tracked changes that are on the saved branch.
260
- const moved = await git(repoDir, ['checkout', '--quiet', '--force', '-B', localBranch, targetCommit], 300_000);
261
- if (!moved.ok) {
262
- return { ok: false, problem: `${localBranch} could not be checked out at ${short(targetCommit)}: ${moved.stderr || moved.stdout}. ${saved.map((s) => `${s.what} are on ${s.branch}.`).join(' ')}` };
263
- }
264
- await git(repoDir, ['branch', `--set-upstream-to=${target}`, localBranch]);
265
- // The new files, kept on the saved branch, out of the folder; ignored files stay (no -x).
266
- const removed = plan.untracked.length > 0 ? await git(repoDir, ['clean', '-fd', '--quiet'], 300_000) : { ok: true, stdout: '', stderr: '' };
267
- const nowHead = (await git(repoDir, ['rev-parse', 'HEAD'])).stdout;
268
- const left = lines((await git(repoDir, ['status', '--porcelain'])).stdout);
269
- const keptLine = saved.length > 0 ? ` Kept: ${saved.map((s) => `${s.what} on ${s.branch}`).join('; ')}.` : '';
270
- const branchLine = plan.branchOnlyCommits.length > 0 && plan.branch ? ` ${plan.branch} keeps its ${plan.branchOnlyCommits.length} commit(s); nothing was deleted.` : '';
271
- if (nowHead !== targetCommit || left.length > 0 || !removed.ok) {
272
- return {
273
- ok: false,
274
- problem: `The folder is on ${localBranch} at ${short(nowHead)}, but not exactly at ${target}: ${left.length > 0 ? `still uncommitted: ${left.slice(0, 10).join(', ')}` : removed.ok ? 'HEAD differs' : removed.stderr}.` +
275
- keptLine,
276
- };
277
- }
278
- return {
279
- ok: true,
280
- branch: localBranch,
281
- commit: targetCommit,
282
- target,
283
- saved,
284
- removedFromFolder: plan.untracked.length,
285
- result: `The folder is on ${localBranch} at ${short(targetCommit)}, the same as ${target}, with nothing uncommitted.${keptLine}${branchLine} ` +
286
- 'Ignored files (node_modules, .env, build output) were not touched. Add the files the task needs now; the run screen offers a starting snapshot of them.',
287
- };
288
- }
@@ -1,117 +0,0 @@
1
- /**
2
- * How a fetch the operator asked for gets past a remote that wants a password — without the bot ever
3
- * seeing it.
4
- *
5
- * Found on 2026-10-03 with "Prepare the folder from the remote main branch": the remote is reached over
6
- * SSH with a key that has a passphrase, and every fetch the bot makes forbids prompts (a prompt in a
7
- * run nobody watches would hang it), so the fetch failed. The operator asked for a safe way to type the
8
- * passphrase.
9
- *
10
- * Not a field on the bot's page: a password typed there passes through the browser, the API, this
11
- * process and its memory, and the bot would hold the one secret that unlocks the operator's key. So
12
- * the bot asks nobody anything. It lets ssh (and git, for HTTPS) ask through Git for Windows' own
13
- * password window, `git-askpass.exe`: ssh starts the window, the operator types into it, and the
14
- * answer goes from the window straight back to ssh through a pipe the bot is not part of. Nothing is
15
- * stored; the next fetch asks again (an ssh-agent, if the operator runs one, answers instead).
16
- *
17
- * Only for a fetch the operator just pressed a button for: a run's own fetches stay silent, since a
18
- * window nobody answers would hold the run until it times out.
19
- */
20
- import { execFile } from 'node:child_process';
21
- import { existsSync } from 'node:fs';
22
- import { resolve } from 'node:path';
23
- import { git, gitFetch } from './git.js';
24
- import { psQuote } from './syncCommand.js';
25
- /** No prompt anywhere: what every fetch of a run uses. */
26
- export const QUIET_FETCH_ENV = { ...process.env, GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'never', GIT_ASKPASS: '', SSH_ASKPASS: '' };
27
- /** Git for Windows' password window, next to the git that runs here; null when there is none. */
28
- export async function askpassProgram() {
29
- const exec = await git(process.cwd(), ['--exec-path']);
30
- if (!exec.ok || !exec.stdout)
31
- return null;
32
- // <Git>\mingw64\libexec\git-core → <Git>\mingw64\bin\git-askpass.exe
33
- const candidate = resolve(exec.stdout, '..', '..', 'bin', 'git-askpass.exe');
34
- return existsSync(candidate) ? candidate : null;
35
- }
36
- /**
37
- * The environment for a fetch the operator is present for: ssh asks through the password window even
38
- * with no terminal (`SSH_ASKPASS_REQUIRE=force`; `DISPLAY` for an older ssh that wants one), and git
39
- * asks through it for an HTTPS user name or password that its credential manager does not answer. No
40
- * terminal prompt: the bot's console is not where the operator is looking.
41
- */
42
- export function operatorFetchEnv(askpass) {
43
- return {
44
- ...process.env,
45
- GIT_TERMINAL_PROMPT: '0',
46
- GCM_INTERACTIVE: 'auto',
47
- GIT_ASKPASS: askpass,
48
- SSH_ASKPASS: askpass,
49
- SSH_ASKPASS_REQUIRE: 'force',
50
- DISPLAY: process.env.DISPLAY || 'needs-to-be-defined',
51
- };
52
- }
53
- /** A failed fetch, said so the operator knows whether it was the password. */
54
- export function describeFetchFailure(stderr) {
55
- const lines = stderr.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
56
- const auth = /permission denied|publickey|passphrase|authentication failed|could not read (username|password)|host key verification failed|terminal prompts disabled/i.test(stderr);
57
- return { detail: lines.slice(0, 3).join(' ') || 'git fetch failed', auth };
58
- }
59
- /**
60
- * Closes the password windows of a fetch that was given up on: every process of exactly this program
61
- * started since `since`.
62
- *
63
- * Needed because stopping git and its process tree does not reach them. Git for Windows starts ssh, and
64
- * ssh the window, the way its POSIX layer does, and the Windows parent of the window is a process that
65
- * is already gone — so `taskkill /T` stops git and leaves the window on screen (seen live on
66
- * 2026-10-03, and in a process listing: the window's parent id named no running process). Once the
67
- * window is closed the ssh waiting on it ends by itself: git, at the other end of its pipe, is gone.
68
- * Matched by the program's full path and its start time, so nothing else is touched; a second
69
- * password window of the operator's own, opened in the same minutes, would at worst be cancelled.
70
- */
71
- export function closePasswordWindows(program, since) {
72
- if (process.platform !== 'win32')
73
- return Promise.resolve(0);
74
- const script = [
75
- `$path = '${program.replace(/'/g, "''")}'`,
76
- `$since = [datetime]::Parse('${since.toISOString()}').ToUniversalTime()`,
77
- '$n = 0',
78
- "Get-CimInstance Win32_Process -Filter \"Name='git-askpass.exe' OR Name='$([IO.Path]::GetFileName($path))'\" |",
79
- ' Where-Object { $_.ExecutablePath -and $_.ExecutablePath -ieq $path -and $_.CreationDate.ToUniversalTime() -ge $since } |',
80
- ' ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; $n++ }',
81
- '$n',
82
- ].join('\n');
83
- return new Promise((resolve) => {
84
- execFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], { windowsHide: true, timeout: 30_000 }, (_e, stdout) => {
85
- resolve(Number.parseInt(String(stdout).trim(), 10) || 0);
86
- });
87
- });
88
- }
89
- /** The fetch for the operator to run in their own PowerShell, where ssh can ask them directly. */
90
- export function fetchCommandFor(dir, remote) {
91
- return `git -C ${psQuote(dir)} fetch --prune ${psQuote(remote)}`;
92
- }
93
- /**
94
- * A fetch the operator just pressed a button for, and is looking at: with Git's password window when
95
- * there is one (five minutes to type, the window not hidden), quiet otherwise. One connection only —
96
- * `remote set-head --auto` would open a second and ask for the password again. Tried once more when
97
- * the first try fails (see `gitFetch`), and a window left on screen by a fetch that was given up on is
98
- * closed. `refspecs` fetches only those branches; without them the whole remote is fetched and pruned.
99
- *
100
- * The one fetch behind "Prepare the folder from the remote main branch" and the start window's
101
- * remote branches (`startChoice.ts`).
102
- */
103
- export async function fetchAsOperator(repoDir, remote, opts) {
104
- const asked = !!opts.askpass;
105
- const env = asked ? operatorFetchEnv(opts.askpass) : QUIET_FETCH_ENV;
106
- const whole = !opts.refspecs || opts.refspecs.length === 0;
107
- const args = [...(asked ? [] : ['-c', 'credential.interactive=false']), 'fetch', '--quiet', '--no-tags', ...(whole ? ['--prune'] : []), remote, ...(opts.refspecs ?? [])];
108
- const started = new Date(Date.now() - 1000);
109
- const f = await gitFetch(repoDir, args, asked ? 300_000 : 120_000, env, { windowsHide: !asked, killTree: true });
110
- // Given up on with the window still open: closed, so it is not left on screen asking for nothing.
111
- if (!f.ok && asked && /gave up after/.test(f.stderr))
112
- await closePasswordWindows(opts.askpass, started);
113
- if (f.ok)
114
- return { ok: true, asked, ...(f.retried ? { retried: true, ...(f.firstError ? { firstError: f.firstError } : {}) } : {}) };
115
- const why = describeFetchFailure(f.stderr || f.stdout);
116
- return { ok: false, detail: why.detail, auth: why.auth, asked };
117
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * The command that brings a project's current branch back to the remote's main branch, handed to
3
- * the operator rather than run.
4
- *
5
- * Asked for after a day of runs: a project left on a task branch, with files a step created and
6
- * nobody committed, wants to go back to where the team's code is. That is `fetch`, `reset --hard`
7
- * to the remote's main, and `clean -fd` for the new files git does not ignore — three commands that
8
- * destroy work if pointed at the wrong folder or run a minute too early. So the bot never runs them.
9
- * It reads the repository, says exactly what would be lost — commits on this branch that the
10
- * remote's main does not have, changed tracked files, new files — and gives the command, ready to
11
- * paste into PowerShell, with a read-only preview beside it. Ignored files (`node_modules`, `.env`,
12
- * build output) are left alone: `clean` without `-x` does not touch them.
13
- *
14
- * Nothing here writes to the repository or the network. `git fetch` is in the command, not here:
15
- * what "would be lost" is computed against the remote branch as last fetched, and the page says so.
16
- */
17
- import { git, lastFetchedAt, porcelainPaths } from './git.js';
18
- /** A string as a single-quoted PowerShell literal: nothing inside it is expanded. */
19
- export function psQuote(text) {
20
- return `'${text.replace(/'/g, "''")}'`;
21
- }
22
- /**
23
- * The two commands, for Windows PowerShell 5.1 and PowerShell 7 alike: `;` and `$LASTEXITCODE`
24
- * rather than `&&`, which 5.1 does not have, so a failed fetch stops everything after it instead
25
- * of resetting to a remote branch that is out of date.
26
- */
27
- export function syncCommands(dir, remote, target) {
28
- const g = `git -C ${psQuote(dir)}`;
29
- return {
30
- preview: [
31
- `${g} fetch ${psQuote(remote)}`,
32
- `${g} log --oneline ${psQuote(`${target}..HEAD`)}`,
33
- `${g} status --short`,
34
- `${g} clean -nd`,
35
- ].join('; '),
36
- command: `${g} fetch ${psQuote(remote)}; if ($LASTEXITCODE -eq 0) { ${g} reset --hard ${psQuote(target)}; ` +
37
- `if ($LASTEXITCODE -eq 0) { ${g} clean -fd } }`,
38
- };
39
- }
40
- const empty = (repoDir, problem) => ({
41
- ok: false,
42
- problem,
43
- repoDir,
44
- willLose: { commits: [], changed: [], untracked: [] },
45
- preview: '',
46
- command: '',
47
- });
48
- export async function planSync(repoDir) {
49
- const inside = await git(repoDir, ['rev-parse', '--is-inside-work-tree']);
50
- if (!inside.ok || inside.stdout !== 'true')
51
- return empty(repoDir, `${repoDir} is not a git repository.`);
52
- const branch = await git(repoDir, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
53
- if (!branch.ok || !branch.stdout) {
54
- return empty(repoDir, 'The repository is not on a branch (a detached HEAD), so there is no "current branch" to bring up to date. Check out a branch first.');
55
- }
56
- const remotes = (await git(repoDir, ['remote'])).stdout.split('\n').map((r) => r.trim()).filter(Boolean);
57
- if (remotes.length === 0)
58
- return empty(repoDir, 'The repository has no remote, so there is no remote main branch to go back to.');
59
- const remote = remotes.includes('origin') ? 'origin' : remotes[0];
60
- // The remote's own idea of its main branch first, then the two usual names.
61
- let target = '';
62
- const head = await git(repoDir, ['symbolic-ref', '--quiet', '--short', `refs/remotes/${remote}/HEAD`]);
63
- if (head.ok && head.stdout)
64
- target = head.stdout;
65
- for (const name of ['main', 'master']) {
66
- if (target)
67
- break;
68
- const found = await git(repoDir, ['rev-parse', '--verify', '--quiet', `refs/remotes/${remote}/${name}`]);
69
- if (found.ok)
70
- target = `${remote}/${name}`;
71
- }
72
- if (!target) {
73
- return empty(repoDir, `No main branch of ${remote} is known here yet. Run ${syncCommands(repoDir, remote, `${remote}/main`).preview.split('; ')[0]} once, then look again.`);
74
- }
75
- const commits = await git(repoDir, ['log', '--format=%h %s', `${target}..HEAD`]);
76
- const status = await git(repoDir, ['status', '--porcelain', '--untracked-files=no']);
77
- const clean = await git(repoDir, ['clean', '-nd']);
78
- const gitDir = (await git(repoDir, ['rev-parse', '--absolute-git-dir'])).stdout;
79
- const lastFetched = gitDir ? lastFetchedAt(gitDir) : undefined;
80
- return {
81
- ok: true,
82
- repoDir,
83
- branch: branch.stdout,
84
- remote,
85
- target,
86
- ...(lastFetched ? { lastFetched } : {}),
87
- willLose: {
88
- commits: commits.ok && commits.stdout ? commits.stdout.split('\n') : [],
89
- changed: porcelainPaths(status.stdout),
90
- untracked: clean.stdout
91
- .split('\n')
92
- .map((l) => l.replace(/^Would remove\s+/, '').trim())
93
- .filter(Boolean),
94
- },
95
- ...syncCommands(repoDir, remote, target),
96
- };
97
- }
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[190],{6657:(e,a,t)=>{t.d(a,{M:()=>v,U:()=>m});var r=t(3365),s=t(1521),n=t(8197),l=t.n(n),i=t(1702),o=t(5549),c=t(867),d=t(1035),h=t(7527),p=t(9717);function m(){let{t:e}=(0,c.kj)(),a=(0,i.usePathname)(),[t,n]=(0,s.useState)([]),[l,d]=(0,s.useState)({}),p=(0,s.useRef)({}),m=(0,s.useRef)(new Set),v=(0,s.useRef)(""),x=(0,s.useCallback)(async()=>{try{let e=await o.FH.approvals();n(e);let a=[...new Set(e.map(e=>e.sessionId).filter(e=>!(e in p.current)))],t=a.sort().join(",");if(a.length>0&&t!==v.current){for(let e of(v.current=t,await o.FH.sessions().catch(()=>[])))p.current[e.id]=e.name,"chat"===e.kind&&m.current.add(e.id);d({...p.current})}}catch(e){}},[]);(0,h.z)(x,2e3),(0,s.useEffect)(()=>{let a="copilot-operator";document.title=t.length>0?"(".concat(t.length,") ").concat(e("approval.tabTitle")," — ").concat(a):a},[t.length,e]);let j="/"===a?t.filter(e=>e.sessionId in p.current&&(!m.current.has(e.sessionId)||!!e.model)):t;return 0===j.length?null:(0,r.jsxs)("section",{className:"approval-banner",role:"alert","aria-live":"assertive",children:[(0,r.jsx)("h2",{children:e("approval.waitingHere")}),(0,r.jsx)("p",{className:"small",children:e("approval.waitingHereWhy")}),j.map(e=>{var a;return(0,r.jsx)(u,{approval:e,sessionName:null!=(a=l[e.sessionId])?a:e.sessionId,onDecided:()=>void x()},e.id)})]})}function u(e){let{approval:a,sessionName:t,onDecided:n}=e,{t:i}=(0,c.kj)(),h=(0,c.W3)(),[p,m]=(0,s.useState)(!1),[u,x]=(0,s.useState)(""),j=(0,s.useRef)(!1),g=async e=>{if(!j.current&&("run-all"!==e||await (0,d.Z)(i("approval.runAllConfirm")))){j.current=!0,m(!0),x("");try{await o.FH.decide(a.id,e)}catch(e){x(e.message)}finally{j.current=!1,m(!1),n()}}};if(a.plan)return(0,r.jsx)(v,{approval:a,sessionName:t,onDecided:n});if(a.model){var f;let e=a.model;return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:i(e.manual?"approval.manualTitle":"approval.modelTitle")}),(0,r.jsx)(l(),{href:"/",children:t}),(0,r.jsx)("span",{className:"muted small",children:h(a.createdAt)})]}),(0,r.jsx)("p",{children:e.manual?e.asked?i("approval.manualAsk",{model:e.asked}):i("approval.manualAskAny"):i("approval.modelAsk",{model:e.asked})}),(0,r.jsx)("p",{className:"muted small",children:i("approval.modelShown",{shown:null!=(f=e.shown)?f:"—"})}),!e.manual&&(0,r.jsx)("p",{className:"reason small",children:i("approval.modelWhy",{why:e.why,tries:e.tries})}),u&&(0,r.jsx)("p",{className:"err",role:"alert",children:u}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:p,onClick:()=>void g("run"),children:i(e.manual?"approval.manualReady":"approval.modelChosen")}),!e.manual&&(0,r.jsx)("button",{disabled:p,onClick:()=>void g("skip"),children:i("approval.modelAsItIs")}),(0,r.jsx)("button",{className:"danger",disabled:p,onClick:()=>void g("abort"),children:i("approval.modelStop")})]})]})}return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:i("approval.title",{n:a.stepId})}),(0,r.jsx)(l(),{href:"/",children:t}),(0,r.jsx)("span",{className:"muted small",children:h(a.createdAt)})]}),(0,r.jsx)("pre",{style:{margin:"8px 0"},children:a.description}),a.network&&(0,r.jsx)("p",{className:"reason small",children:i("approval.network")}),u&&(0,r.jsx)("p",{className:"err",role:"alert",children:u}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:p,onClick:()=>void g("run"),children:i("approval.run")}),!a.network&&(0,r.jsx)("button",{disabled:p,onClick:()=>void g("run-all"),title:i("approval.runAllWhy"),children:i("approval.runAll")}),(0,r.jsx)("button",{disabled:p,onClick:()=>void g("skip"),children:i("approval.skip")}),(0,r.jsx)("button",{className:"danger",disabled:p,onClick:()=>void g("abort"),children:i("approval.abort")})]})]})}function v(e){let{approval:a,sessionName:t,onDecided:n}=e,{t:i}=(0,c.kj)(),h=(0,c.W3)(),[m,u]=(0,s.useState)(""),[v,x]=(0,s.useState)(!1),[j,g]=(0,s.useState)(""),f=(0,s.useRef)(!1),w=a.plan,k=async e=>{if(!f.current){if("revise"===e&&!m.trim())return void g(i("pm.reviseNeedsNote"));if("stop"!==e||await (0,d.Z)(i("pm.stopConfirm"))){f.current=!0,x(!0),g("");try{await o.FH.decidePlan(a.id,e,m)}catch(e){g(e.message)}finally{f.current=!1,x(!1),n()}}}};return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:i("pm.cardTitle",{title:w.title})}),void 0!==t&&(0,r.jsx)(l(),{href:"/",children:t}),(0,r.jsx)("span",{className:"muted small",children:h(a.createdAt)})]}),(0,r.jsx)("p",{className:"small",children:i("pm.cardWhy")}),(0,r.jsx)(p.D,{plan:w.plan,showApproval:!1}),(0,r.jsx)("label",{htmlFor:"plan-note-".concat(a.id),children:i("pm.note")}),(0,r.jsx)("textarea",{id:"plan-note-".concat(a.id),className:"prose",value:m,onChange:e=>u(e.target.value),placeholder:i("pm.notePlaceholder"),style:{minHeight:70},disabled:v}),j&&(0,r.jsx)("p",{className:"err",role:"alert",children:j}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:v,onClick:()=>void k("approve"),children:i("pm.approve")}),(0,r.jsx)("button",{disabled:v,onClick:()=>void k("revise"),title:i("pm.reviseWhy"),children:i("pm.revise")}),(0,r.jsx)("button",{className:"danger",disabled:v,onClick:()=>void k("stop"),children:i("pm.stop")})]})]})}},7527:(e,a,t)=>{t.d(a,{z:()=>s});var r=t(1521);function s(e,a){let t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],s=(0,r.useRef)(e);s.current=e,(0,r.useEffect)(()=>{let e;if(!t)return;let r=!1,n=async()=>{try{await s.current()}catch(e){}finally{r||(e=setTimeout(()=>void n(),a))}};return n(),()=>{r=!0,e&&clearTimeout(e)}},[a,t])}},8078:(e,a,t)=>{t.d(a,{AppearanceProvider:()=>d,Xm:()=>l,KP:()=>h});var r=t(3365),s=t(1521);let n="cop.appearance",l=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(n,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n // \"system\", the default: whatever the machine is set to, light or dark (2026-10-20).\n d.dataset.theme = a.theme === 'dark' || a.theme === 'light' ? a.theme : window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(l),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n d.dataset.night = a.nightLight ? 'on' : 'off';\n } catch (e) {}\n})();\n");let i={theme:"system",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1,nightLight:!1};function o(e){let a=document.documentElement;a.dataset.theme="system"===e.theme?!function(){try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch(e){return!1}}()?"light":"dark":e.theme,a.dataset.textsize=e.textSize,a.dataset.contrast=e.highContrast?"high":"normal",a.dataset.motion=e.reduceMotion?"reduced":"normal",a.dataset.links=e.underlineLinks?"underline":"plain",a.dataset.focus=e.strongFocus?"strong":"normal",a.dataset.night=e.nightLight?"on":"off"}let c=(0,s.createContext)({appearance:i,set:()=>void 0,reset:()=>void 0,loaded:!1});function d(e){let{children:a}=e,[t,d]=(0,s.useState)(i),[h,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=i;try{let a=window.localStorage.getItem(n);a&&(e=function(e){let a=e&&"object"==typeof e?e:{},t=(e,a)=>"boolean"==typeof e?e:a;return{theme:"dark"===a.theme||"light"===a.theme||"system"===a.theme?a.theme:i.theme,textSize:l.includes(a.textSize)?a.textSize:i.textSize,highContrast:t(a.highContrast,i.highContrast),reduceMotion:t(a.reduceMotion,i.reduceMotion),underlineLinks:t(a.underlineLinks,i.underlineLinks),strongFocus:t(a.strongFocus,i.strongFocus),nightLight:t(a.nightLight,i.nightLight)}}(JSON.parse(a))),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!a&&(e={...e,reduceMotion:!0})}catch(e){}d(e),o(e),p(!0)},[]),(0,s.useEffect)(()=>{let e;if("system"!==t.theme)return;try{e=window.matchMedia("(prefers-color-scheme: dark)")}catch(e){return}let a=()=>o(t);return e.addEventListener("change",a),()=>e.removeEventListener("change",a)},[t]);let m=(0,s.useCallback)(e=>{d(a=>{let t={...a,...e};o(t);try{window.localStorage.setItem(n,JSON.stringify(t))}catch(e){}return t})},[]),u=(0,s.useCallback)(()=>{d(i),o(i);try{window.localStorage.removeItem(n)}catch(e){}},[]);return(0,r.jsx)(c.Provider,{value:{appearance:t,set:m,reset:u,loaded:h},children:a})}function h(){return(0,s.useContext)(c)}},9717:(e,a,t)=>{t.d(a,{D:()=>n});var r=t(3365),s=t(867);function n(e){var a,t;let{plan:n,showApproval:l=!0}=e,{t:i}=(0,s.kj)(),o=(0,s.W3)(),c=n.approved;return(0,r.jsxs)("div",{className:"plan-view",children:[(0,r.jsx)("p",{className:"small muted",children:i("pm.version",{n:n.version,at:o(n.at)})}),l&&c&&(0,r.jsxs)("p",{className:"small",children:["operator"===c.by?i("pm.approvedByOperator",{at:o(c.at)}):i("pm.approvedAuto",{at:o(c.at)}),c.why&&" ".concat(c.why),c.note&&" ".concat(i("pm.approvedNote",{note:c.note}))]}),(0,r.jsx)("h4",{children:i("pm.existing")}),(0,r.jsx)("p",{className:"pre-wrap",children:n.existing}),(0,r.jsx)("h4",{children:i("pm.approach")}),(0,r.jsx)("p",{className:"pre-wrap",children:n.approach}),(0,r.jsx)("h4",{children:i("pm.steps")}),(0,r.jsx)("ol",{children:n.steps.map((e,a)=>(0,r.jsx)("li",{className:"pre-wrap",children:e},a))}),n.files.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.files")}),(0,r.jsx)("ul",{children:n.files.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)("code",{children:e})},e))})]}),(0,r.jsx)("h4",{children:i("pm.verification")}),(0,r.jsx)("p",{className:"pre-wrap",children:n.verification}),n.risks&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.risks")}),(0,r.jsx)("p",{className:"pre-wrap",children:n.risks})]}),(null!=(t=null==(a=n.revisions)?void 0:a.length)?t:0)>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.revisions")}),(0,r.jsx)("ul",{children:n.revisions.map(e=>(0,r.jsxs)("li",{className:"small",children:[i("pm.revision",{n:e.version,at:o(e.at)})," ",(0,r.jsx)("span",{className:"pre-wrap",children:e.comment})]},e.version))})]})]})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[643],{1035:(e,t,o)=>{o.d(t,{DialogHost:()=>d,Z:()=>l});var n=o(3365),s=o(1521),a=o(867),c=o(4969);let i=null,r=[];function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(o=>{var n;return n={kind:"confirm",message:e,...t,resolve:o},void(i?i(n):r.push(n))})}function d(e){var t,o;let{children:l}=e,{t:d}=(0,a.kj)(),[u,m]=(0,s.useState)([]),p=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(i=e=>m(t=>[...t,e]),r.length>0){let e=r.splice(0,r.length);m(t=>[...t,...e])}return()=>{i=null}},[]);let f=u[0],y=(0,s.useCallback)(e=>{f&&(f.resolve(e),m(e=>e.slice(1)))},[f]);return(0,c.V)(h,!!f,p),(0,s.useEffect)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),y(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[f,y]),(0,n.jsxs)(n.Fragment,{children:[l,f&&(0,n.jsx)("div",{className:"modal-backdrop",onClick:()=>y(!1),role:"presentation",children:(0,n.jsxs)("div",{ref:h,className:"modal".concat(f.danger?" danger":""),role:"confirm"===f.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"modal-title",children:null!=(t=f.title)?t:d("confirm"===f.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,n.jsx)("div",{id:"modal-body",className:"modal-body",children:f.message}),(0,n.jsxs)("div",{className:"row modal-actions",children:["confirm"===f.kind&&(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>y(!1),children:d("dialog.cancel")}),(0,n.jsx)("button",{ref:p,type:"button",className:f.danger?"danger":"primary",onClick:()=>y(!0),children:null!=(o=f.okLabel)?o:d("dialog.ok")})]})]})})]})}},4969:(e,t,o)=>{o.d(t,{V:()=>a});var n=o(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function a(e,t,o){(0,n.useEffect)(()=>{var n,a;if(!t)return;let c=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,r=null!=(a=null!=(n=null==o?void 0:o.current)?n:null==i?void 0:i.querySelector(s))?a:null;null==r||r.focus();let l=e=>{if("Tab"!==e.key||!i)return;let t=Array.from(i.querySelectorAll(s)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let o=t[0],n=t[t.length-1],a=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===o||!a)?(e.preventDefault(),n.focus()):e.shiftKey||document.activeElement!==n&&a||(e.preventDefault(),o.focus())};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l),c&&document.contains(c)&&c.focus()}},[e,t,o])}},5549:(e,t,o)=>{o.d(t,{FH:()=>r});let n="/api",s="cop-api-token";function a(){try{let e=/(?:^#|&)token=([0-9a-f]{16,})/i.exec(window.location.hash);if(e)return window.localStorage.setItem(s,e[1]),window.history.replaceState(null,"",window.location.pathname+window.location.search),e[1];return window.localStorage.getItem(s)||""}catch(e){return""}}function c(e){let t=a();return t?"".concat(e).concat(e.includes("?")?"&":"?","token=").concat(encodeURIComponent(t)):e}async function i(e,t){let o,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=void 0===s.timeoutMs?3e4:s.timeoutMs;try{var i;o=await fetch("".concat(n).concat(e),{...t,...null!==c&&!(null==t?void 0:t.signal)?{signal:AbortSignal.timeout(c)}:{},headers:{"content-type":"application/json",...a()?{"x-cop-token":a()}:{},...null!=(i=null==t?void 0:t.headers)?i:{}}})}catch(t){if("TimeoutError"===t.name)throw Error("The API did not answer within ".concat(Math.round((null!=c?c:0)/1e3)," s (").concat(e.split("?")[0],"). It may be busy; try again."));throw t}if(!o.ok){let e="".concat(o.status," ").concat(o.statusText);try{let t=await o.json();(null==t?void 0:t.message)&&(e=Array.isArray(t.message)?t.message.join("; "):t.message)}catch(e){}throw Object.assign(Error(e),{status:o.status})}let r=await o.text();return r?JSON.parse(r):void 0}let r={doctor:()=>i("/doctor"),settings:()=>i("/settings"),saveSettings:e=>i("/settings",{method:"PUT",body:JSON.stringify(e)}),level1:()=>i("/level1"),setLevel1:e=>i("/level1",{method:"PUT",body:JSON.stringify({content:e})}),resetLevel1:()=>i("/level1",{method:"DELETE"}),presets:()=>i("/presets"),savePreset:(e,t)=>i("/presets/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({content:t})}),deletePreset:e=>i("/presets/".concat(encodeURIComponent(e)),{method:"DELETE"}),sessions:()=>i("/sessions"),preparePreview:function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return i("/repo/prepare/preview",{method:"POST",body:JSON.stringify({dir:e,fetch:t})},{timeoutMs:33e4})},prepareProject:function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return i("/repo/prepare",{method:"POST",body:JSON.stringify({dir:e,fingerprint:t,...o})})},session:e=>i("/sessions/".concat(e)),updateSession:(e,t)=>i("/sessions/".concat(e),{method:"PUT",body:JSON.stringify(t)}),taskChanges:(e,t,o)=>i("/sessions/".concat(e,"/tasks/").concat(t,"/changes").concat(o?"?run=".concat(encodeURIComponent(o)):"")),taskChangeFile:(e,t,o,n)=>i("/sessions/".concat(e,"/tasks/").concat(t,"/changes/file?path=").concat(encodeURIComponent(o)).concat(n?"&run=".concat(encodeURIComponent(n)):"")),taskStory:(e,t,o)=>i("/sessions/".concat(e,"/tasks/").concat(t,"/story").concat(o?"?run=".concat(encodeURIComponent(o)):"")),start:(e,t)=>i("/sessions/".concat(e,"/start"),{method:"POST",body:JSON.stringify({mode:t})},{timeoutMs:12e4}),startFailures:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return i("/start/failures".concat(e?"?unanswered=1":""))},startFailureUrl:e=>c("".concat(n,"/start/failures/").concat(encodeURIComponent(e),"/report")),terminalUrl:()=>c("".concat(n,"/terminal")),stop:e=>i("/sessions/".concat(e,"/stop"),{method:"POST",body:"{}"}),pause:e=>i("/sessions/".concat(e,"/pause"),{method:"POST",body:"{}"}),resume:e=>i("/sessions/".concat(e,"/resume"),{method:"POST",body:"{}"}),approvals:e=>i("/approvals".concat(e?"?session=".concat(encodeURIComponent(e)):"")),workspace:()=>i("/workspace"),workspaceFiles:()=>i("/workspace/files"),workspaceFile:e=>i("/workspace/file?path=".concat(encodeURIComponent(e))),saveWorkspaceFile:(e,t,o)=>i("/workspace/file",{method:"PUT",body:JSON.stringify({path:e,text:t,...o?{base:o}:{}})}),workspaceGit:()=>i("/workspace/git"),workspaceCommit:e=>i("/workspace/git/commit?sha=".concat(encodeURIComponent(e))),workspaceGitFile:(e,t,o)=>i("/workspace/git/file?area=".concat(e,"&path=").concat(encodeURIComponent(t)).concat(o?"&commit=".concat(encodeURIComponent(o)):"")),chatThreads:()=>i("/chat/threads"),chatSend:(e,t,o,n,s,a)=>i("/chat",{method:"POST",body:JSON.stringify({text:e,...t?{threadId:t}:{},...o?{model:o}:{},...n?{manualModel:!0}:{},...s?{lang:s}:{},...a?{planMode:!0}:{}})}),chatRewind:(e,t)=>i("/chat/".concat(e,"/rewind"),{method:"POST",body:JSON.stringify({taskId:t})}),sessionEvents:e=>i("/sessions/".concat(e,"/events")),decidePlan:(e,t,o)=>i("/approvals/".concat(e,"/plan"),{method:"POST",body:JSON.stringify({action:t,...(null==o?void 0:o.trim())?{note:o}:{}})}),decide:(e,t)=>i("/approvals/".concat(e),{method:"POST",body:JSON.stringify({action:t})}),browseFolder:e=>i("/browse-folder",{method:"POST",body:JSON.stringify({start:e})},{timeoutMs:null}),activity:()=>i("/activity"),kerrigan:e=>i("/kerrigan?lang=".concat(encodeURIComponent(e))),taskExchangeUrl:(e,t)=>c("".concat(n,"/sessions/").concat(encodeURIComponent(e),"/tasks/").concat(encodeURIComponent(t),"/exchange")),project:()=>i("/project"),setProject:e=>i("/project",{method:"PUT",body:JSON.stringify(e)}),models:()=>i("/models"),setDefaultModel:e=>i("/models/default",{method:"PUT",body:JSON.stringify({model:e})}),setDefaultReviewModel:e=>i("/models/review-default",{method:"PUT",body:JSON.stringify({model:e})}),refreshModels:()=>i("/models/refresh",{method:"POST",body:"{}"},{timeoutMs:null}),login:e=>i("/login",{method:"POST",body:JSON.stringify({account:(null==e?void 0:e.trim())||void 0})},{timeoutMs:null})}}}]);