@andorra-labs/code 0.1.16 → 0.1.17

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 (188) hide show
  1. package/dist/src/acp-agent.d.ts +6 -0
  2. package/dist/src/acp-agent.js +15 -4
  3. package/dist/src/agent-execution.js +11 -8
  4. package/dist/src/agent-mcp-catalog.js +1 -0
  5. package/dist/src/agent-mcp.d.ts +3 -0
  6. package/dist/src/agent-mcp.js +33 -1
  7. package/dist/src/andorra/entry.d.ts +10 -0
  8. package/dist/src/andorra/entry.js +18 -4
  9. package/dist/src/andorra/hosted.d.ts +2 -1
  10. package/dist/src/andorra/hosted.js +2 -1
  11. package/dist/src/andorra/notices.d.ts +5 -0
  12. package/dist/src/andorra/notices.js +7 -0
  13. package/dist/src/andorra/state.d.ts +3 -2
  14. package/dist/src/andorra/state.js +4 -4
  15. package/dist/src/andorra/terminal.js +7 -2
  16. package/dist/src/anthropic-credentials.js +2 -0
  17. package/dist/src/app-server/error.d.ts +5 -0
  18. package/dist/src/app-server/error.js +7 -0
  19. package/dist/src/app-server/protocol.d.ts +19 -44
  20. package/dist/src/app-server/protocol.js +5 -1
  21. package/dist/src/app-server/workspace.d.ts +89 -0
  22. package/dist/src/app-server/workspace.js +457 -11
  23. package/dist/src/app-server.d.ts +358 -32
  24. package/dist/src/app-server.js +2429 -509
  25. package/dist/src/bridge/cloud.d.ts +27 -0
  26. package/dist/src/bridge/cloud.js +187 -0
  27. package/dist/src/bridge/command.d.ts +30 -0
  28. package/dist/src/bridge/command.js +347 -0
  29. package/dist/src/bridge/control.d.ts +68 -0
  30. package/dist/src/bridge/control.js +233 -0
  31. package/dist/src/bridge/engines.d.ts +90 -0
  32. package/dist/src/bridge/engines.js +601 -0
  33. package/dist/src/bridge/host-ops.d.ts +9 -0
  34. package/dist/src/bridge/host-ops.js +129 -0
  35. package/dist/src/bridge/host.d.ts +47 -0
  36. package/dist/src/bridge/host.js +540 -0
  37. package/dist/src/bridge/link.d.ts +38 -0
  38. package/dist/src/bridge/link.js +508 -0
  39. package/dist/src/bridge/login-link.d.ts +29 -0
  40. package/dist/src/bridge/login-link.js +54 -0
  41. package/dist/src/bridge/protocol.d.ts +136 -0
  42. package/dist/src/bridge/protocol.js +11 -0
  43. package/dist/src/bridge/store.d.ts +12 -0
  44. package/dist/src/bridge/store.js +61 -0
  45. package/dist/src/bridge/wording.d.ts +6 -0
  46. package/dist/src/bridge/wording.js +10 -0
  47. package/dist/src/browser-server.js +7 -1
  48. package/dist/src/browser-ui/tokens.css +1 -1
  49. package/dist/src/change-authors.d.ts +41 -0
  50. package/dist/src/change-authors.js +146 -0
  51. package/dist/src/cli.js +182 -32
  52. package/dist/src/coding-tools.js +15 -15
  53. package/dist/src/command-screens.d.ts +6 -0
  54. package/dist/src/command-screens.js +14 -11
  55. package/dist/src/commands.d.ts +14 -2
  56. package/dist/src/compaction-phrases.js +1 -1
  57. package/dist/src/completion.js +82 -5
  58. package/dist/src/config.d.ts +71 -3
  59. package/dist/src/config.js +202 -77
  60. package/dist/src/deadline.js +13 -1
  61. package/dist/src/decision/checks.js +1 -1
  62. package/dist/src/decision/requestPhrases.js +0 -1
  63. package/dist/src/default-graph.js +1 -1
  64. package/dist/src/file-diff.d.ts +4 -0
  65. package/dist/src/file-diff.js +2 -1
  66. package/dist/src/github-app/agent-writes.d.ts +102 -0
  67. package/dist/src/github-app/agent-writes.js +320 -0
  68. package/dist/src/github-app/client.d.ts +349 -0
  69. package/dist/src/github-app/client.js +810 -0
  70. package/dist/src/github-app/event-source.d.ts +208 -0
  71. package/dist/src/github-app/event-source.js +684 -0
  72. package/dist/src/github-app/metrics.d.ts +32 -0
  73. package/dist/src/github-app/metrics.js +49 -0
  74. package/dist/src/github-app/review-loop.d.ts +274 -0
  75. package/dist/src/github-app/review-loop.js +1177 -0
  76. package/dist/src/github-app/review-node.d.ts +81 -0
  77. package/dist/src/github-app/review-node.js +205 -0
  78. package/dist/src/github-app/review-post.d.ts +73 -0
  79. package/dist/src/github-app/review-post.js +139 -0
  80. package/dist/src/github-app/review-text.d.ts +107 -0
  81. package/dist/src/github-app/review-text.js +1133 -0
  82. package/dist/src/github-app/review-threads.d.ts +47 -0
  83. package/dist/src/github-app/review-threads.js +107 -0
  84. package/dist/src/github-app/reviewer.d.ts +121 -0
  85. package/dist/src/github-app/reviewer.js +598 -0
  86. package/dist/src/github-app/store.d.ts +59 -0
  87. package/dist/src/github-app/store.js +148 -0
  88. package/dist/src/github-app/triggers.d.ts +141 -0
  89. package/dist/src/github-app/triggers.js +441 -0
  90. package/dist/src/github-names.d.ts +8 -0
  91. package/dist/src/github-names.js +8 -0
  92. package/dist/src/glob-search.d.ts +61 -0
  93. package/dist/src/glob-search.js +180 -0
  94. package/dist/src/graph-health.js +6 -1
  95. package/dist/src/graph-manager-chat.js +1 -1
  96. package/dist/src/graph-preview.d.ts +46 -0
  97. package/dist/src/graph-preview.js +55 -0
  98. package/dist/src/graph-provider-portability.js +2 -1
  99. package/dist/src/graph-runner.js +64 -3
  100. package/dist/src/graph-server.js +3 -3
  101. package/dist/src/graph-sync.js +3 -3
  102. package/dist/src/graph-ui/app.js +91 -7
  103. package/dist/src/graph-ui/icons.js +2 -1
  104. package/dist/src/graph-ui/studio.js +15 -1
  105. package/dist/src/graph-ui/tokens.css +1 -1
  106. package/dist/src/graphs.d.ts +34 -1
  107. package/dist/src/graphs.js +158 -14
  108. package/dist/src/image-input.d.ts +16 -0
  109. package/dist/src/image-input.js +41 -0
  110. package/dist/src/membership.d.ts +10 -0
  111. package/dist/src/membership.js +19 -4
  112. package/dist/src/model-health-cache.js +1 -1
  113. package/dist/src/model-metadata.d.ts +6 -0
  114. package/dist/src/model-metadata.js +35 -15
  115. package/dist/src/model-relay/local.d.ts +116 -0
  116. package/dist/src/model-relay/local.js +468 -0
  117. package/dist/src/model-relay/remote.d.ts +129 -0
  118. package/dist/src/model-relay/remote.js +252 -0
  119. package/dist/src/model-relay/runs.d.ts +34 -0
  120. package/dist/src/model-relay/runs.js +146 -0
  121. package/dist/src/model-relay/wire.d.ts +5 -0
  122. package/dist/src/model-relay/wire.js +5 -0
  123. package/dist/src/project-registry.d.ts +21 -0
  124. package/dist/src/project-registry.js +74 -0
  125. package/dist/src/provider-import.d.ts +0 -12
  126. package/dist/src/provider-import.js +7 -195
  127. package/dist/src/providers.d.ts +23 -2
  128. package/dist/src/providers.js +25 -4
  129. package/dist/src/pull-request-logs.d.ts +12 -1
  130. package/dist/src/pull-request-logs.js +14 -3
  131. package/dist/src/pull-requests.d.ts +327 -7
  132. package/dist/src/pull-requests.js +429 -51
  133. package/dist/src/react-runtime.js +1 -1
  134. package/dist/src/remote/engine-pool.d.ts +88 -4
  135. package/dist/src/remote/engine-pool.js +366 -89
  136. package/dist/src/remote/roots.d.ts +19 -0
  137. package/dist/src/remote/roots.js +45 -7
  138. package/dist/src/remote/types.d.ts +0 -44
  139. package/dist/src/run-control.d.ts +7 -0
  140. package/dist/src/run-control.js +23 -0
  141. package/dist/src/run-records.d.ts +7 -2
  142. package/dist/src/run-records.js +71 -6
  143. package/dist/src/runtime.d.ts +5 -1
  144. package/dist/src/runtime.js +10 -2
  145. package/dist/src/session-changes.d.ts +35 -0
  146. package/dist/src/session-changes.js +194 -6
  147. package/dist/src/session-monitor.js +2 -1
  148. package/dist/src/session-reaper.d.ts +1 -1
  149. package/dist/src/session-reaper.js +6 -1
  150. package/dist/src/session-summary.d.ts +2 -1
  151. package/dist/src/session-summary.js +2 -1
  152. package/dist/src/sessions.d.ts +11 -1
  153. package/dist/src/sessions.js +17 -4
  154. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  155. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  156. package/dist/src/skills/bundled/provenance.json +2 -2
  157. package/dist/src/skills/runtime-skills.js +1 -1
  158. package/dist/src/telemetry/emitter.d.ts +15 -0
  159. package/dist/src/telemetry/emitter.js +35 -1
  160. package/dist/src/telemetry/schema.d.ts +25 -2
  161. package/dist/src/telemetry/schema.js +52 -4
  162. package/dist/src/telemetry/surface.d.ts +2 -1
  163. package/dist/src/telemetry/surface.js +4 -1
  164. package/dist/src/terminal-ui.d.ts +1 -0
  165. package/dist/src/terminal-ui.js +10 -3
  166. package/dist/src/test-edit-guard.d.ts +7 -0
  167. package/dist/src/test-edit-guard.js +49 -1
  168. package/dist/src/timers.d.ts +2 -0
  169. package/dist/src/tools.js +59 -9
  170. package/package.json +6 -1
  171. package/dist/src/remote/cert.d.ts +0 -11
  172. package/dist/src/remote/cert.js +0 -87
  173. package/dist/src/remote/client.d.ts +0 -119
  174. package/dist/src/remote/client.js +0 -544
  175. package/dist/src/remote/command.d.ts +0 -4
  176. package/dist/src/remote/command.js +0 -194
  177. package/dist/src/remote/errors.d.ts +0 -11
  178. package/dist/src/remote/errors.js +0 -14
  179. package/dist/src/remote/network.d.ts +0 -22
  180. package/dist/src/remote/network.js +0 -102
  181. package/dist/src/remote/pairing.d.ts +0 -63
  182. package/dist/src/remote/pairing.js +0 -299
  183. package/dist/src/remote/pem.d.ts +0 -2
  184. package/dist/src/remote/pem.js +0 -7
  185. package/dist/src/remote/serve.d.ts +0 -68
  186. package/dist/src/remote/serve.js +0 -244
  187. package/dist/src/remote/server.d.ts +0 -21
  188. package/dist/src/remote/server.js +0 -406
@@ -0,0 +1,598 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createHash, randomBytes } from 'node:crypto';
3
+ import { chmod, lstat, mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises';
4
+ import { homedir, tmpdir } from 'node:os';
5
+ import { join, relative, resolve, sep } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import { REVIEWER_GRAPH_ID } from '../graphs.js';
8
+ /**
9
+ * The review loop's reviewer, outside the model: the throwaway worktree it reads, and the headless CLI child that runs
10
+ * the built-in `andorra-reviewer` graph in it (design/specs/andorra-review-loop.md, "The reviewer").
11
+ *
12
+ * - The worktree is detached at the pull request's head, under the engine's temporary directory, never the task's own
13
+ * checkout. It holds none of the task's uncommitted edits or untracked files, and its inputs live in
14
+ * `.andorra-review/` inside it, so they never reach the task's tree. `cleanup()` removes it whatever happened, and a
15
+ * start-up sweep removes any a crash left behind.
16
+ * - The child is the same CLI build, in a process of its own, so it never takes the task's run slot. It is stopped by
17
+ * its own handle (`child.kill()`), never by name.
18
+ */
19
+ /** Where every review worktree is made: one `round-<random>` folder per round. */
20
+ /**
21
+ * The review root, one per user: on a shared temporary folder another account cannot block or share it. It is named by
22
+ * the user id where there is one, otherwise by a hash of the home folder.
23
+ */
24
+ export const REVIEW_WORKSPACE_ROOT = () => join(tmpdir(), `andorra-review-${typeof process.getuid === 'function'
25
+ ? String(process.getuid()) : createHash('sha256').update(homedir()).digest('hex').slice(0, 16)}`);
26
+ /** The largest diff.patch, and the largest per-file patch, written for the reviewer. */
27
+ export const REVIEW_DIFF_INPUT_BYTES = 1024 * 1024;
28
+ /** A commit not yet fetchable is retried this many times, this far apart (3 times over 30 seconds). */
29
+ const FETCH_RETRIES = 3;
30
+ const FETCH_RETRY_MS = 10_000;
31
+ /** The most git output kept for one command; a diff past it fails the round rather than being read in part. */
32
+ const GIT_OUTPUT_BYTES = 256 * 1024 * 1024;
33
+ const GIT_TIMEOUT_MS = 5 * 60_000;
34
+ /**
35
+ * The diff the reviewer reads, and review-text.ts's indexDiff parses, is GitHub's whatever the person's diff settings
36
+ * say: no external diff or textconv program, no colour, rename detection on, git's default a/ and b/ prefixes (so
37
+ * diff.noprefix and diff.mnemonicPrefix change nothing), the standard context, no order file, non-ASCII paths written
38
+ * as they are rather than octal-quoted, and short submodule lines. The per-file patches are cut from this same diff.
39
+ */
40
+ const DIFF_CONFIG = ['-c', 'core.quotePath=false', '-c', 'diff.noprefix=false', '-c', 'diff.mnemonicPrefix=false',
41
+ '-c', 'diff.relative=false', '-c', 'diff.suppressBlankEmpty=false'];
42
+ const DIFF_FLAGS = ['--no-ext-diff', '--no-textconv', '--no-color', '-M', '--src-prefix=a/', '--dst-prefix=b/',
43
+ '--unified=3', '--inter-hunk-context=0', '--indent-heuristic', '--diff-algorithm=myers', '--submodule=short', '-O/dev/null'];
44
+ const SHA = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/i;
45
+ const OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
46
+ const REPOSITORY = /^(?!-)[A-Za-z0-9_.-]{1,100}$/;
47
+ /** A branch name git accepts (check-ref-format's rules), which also cannot be read as an option or a refspec. */
48
+ const validBranch = (ref) => ref.length > 0 && ref.length <= 255 && !/[\u0000-\u0020\u007f~^:?*[\\]/.test(ref)
49
+ && !ref.startsWith('-') && !ref.startsWith('/') && !ref.startsWith('.') && !ref.endsWith('/') && !ref.endsWith('.')
50
+ && !ref.endsWith('.lock') && !ref.includes('..') && !ref.includes('//') && !ref.includes('/.') && !ref.includes('@{') && ref !== '@';
51
+ class GitCommandError extends Error {
52
+ code;
53
+ stderr;
54
+ constructor(args, code, stderr) {
55
+ super(`git ${args.filter(arg => !arg.startsWith('-') && !arg.includes('=')).slice(0, 2).join(' ')} failed${code === null ? '' : ` (exit ${code})`}: ${stderr.trim().split('\n').slice(-3).join(' ').slice(0, 500) || 'no output'}`);
56
+ this.code = code;
57
+ this.stderr = stderr;
58
+ this.name = 'GitCommandError';
59
+ }
60
+ }
61
+ /** Runs git without a terminal to prompt on and without Git LFS downloads; output past the cap fails the command. */
62
+ function runGit(args, cwd, options = {}) {
63
+ return new Promise((resolveRun, reject) => {
64
+ if (options.signal?.aborted) {
65
+ reject(options.signal.reason ?? new Error('Cancelled'));
66
+ return;
67
+ }
68
+ const child = spawn('git', args, {
69
+ cwd, windowsHide: true, stdio: [options.input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
70
+ env: { ...process.env, GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'never', GIT_LFS_SKIP_SMUDGE: '1', ...options.env },
71
+ });
72
+ const chunks = [];
73
+ let bytes = 0, stderr = '', settled = false, overflow = false;
74
+ const finish = (error, value) => {
75
+ if (settled)
76
+ return;
77
+ settled = true;
78
+ clearTimeout(timer);
79
+ options.signal?.removeEventListener('abort', abort);
80
+ if (error)
81
+ reject(error);
82
+ else
83
+ resolveRun(value);
84
+ };
85
+ const abort = () => { child.kill(); finish(options.signal?.reason instanceof Error ? options.signal.reason : new Error('Cancelled')); };
86
+ const timer = setTimeout(() => { child.kill(); finish(new Error(`git ${args.find(arg => !arg.startsWith('-') && !arg.includes('=')) ?? ''} did not finish in ${GIT_TIMEOUT_MS / 60_000} minutes`)); }, GIT_TIMEOUT_MS);
87
+ timer.unref?.();
88
+ options.signal?.addEventListener('abort', abort, { once: true });
89
+ child.stdout.on('data', (chunk) => {
90
+ if (overflow)
91
+ return;
92
+ bytes += chunk.length;
93
+ if (bytes > GIT_OUTPUT_BYTES) {
94
+ overflow = true;
95
+ child.kill();
96
+ finish(new Error('The git output is too large to review'));
97
+ return;
98
+ }
99
+ chunks.push(chunk);
100
+ });
101
+ child.stderr.on('data', (chunk) => { stderr = (stderr + chunk.toString('utf8')).slice(-8192); });
102
+ child.once('error', error => finish(new Error(`Could not run git: ${error.message}`)));
103
+ child.once('close', code => {
104
+ if (code === 0)
105
+ finish(undefined, Buffer.concat(chunks).toString('utf8'));
106
+ else
107
+ finish(new GitCommandError(args, code, stderr));
108
+ });
109
+ if (options.input !== undefined)
110
+ child.stdin.end(options.input);
111
+ });
112
+ }
113
+ const defaultSleep = (ms, signal) => new Promise((resolveSleep, reject) => {
114
+ if (signal?.aborted) {
115
+ reject(signal.reason ?? new Error('Cancelled'));
116
+ return;
117
+ }
118
+ const done = () => { signal?.removeEventListener('abort', cancel); resolveSleep(); };
119
+ const timer = setTimeout(done, ms);
120
+ const cancel = () => { clearTimeout(timer); reject(signal.reason ?? new Error('Cancelled')); };
121
+ signal?.addEventListener('abort', cancel, { once: true });
122
+ });
123
+ /** The github.com owner and repository a remote URL names (https, ssh or scp-like form, `.git` optional), if any. */
124
+ export function githubRepositoryOf(url) {
125
+ const value = url.trim();
126
+ const match = /^(?:https?|ssh|git):\/\/(?:[^@/\s]+@)?github\.com(?::\d+)?\/([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(value)
127
+ ?? /^(?:[^@/\s]+@)?github\.com:\/?([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(value);
128
+ return match ? { owner: match[1], repo: match[2] } : undefined;
129
+ }
130
+ /** The checkout's remote whose URL is github.com/owner/repo, compared without regard to case. */
131
+ async function githubRemote(git, repoDir, owner, repo) {
132
+ let listed;
133
+ try {
134
+ listed = await git(['config', '--get-regexp', '^remote\\..*\\.url$'], repoDir);
135
+ }
136
+ catch {
137
+ return undefined;
138
+ }
139
+ for (const line of listed.split('\n')) {
140
+ const match = /^remote\.(.+)\.url\s+(.+)$/.exec(line.trim());
141
+ if (!match || match[1].startsWith('-'))
142
+ continue;
143
+ const named = githubRepositoryOf(match[2]);
144
+ if (named && named.owner.toLowerCase() === owner.toLowerCase() && named.repo.toLowerCase() === repo.toLowerCase())
145
+ return match[1];
146
+ }
147
+ return undefined;
148
+ }
149
+ async function hasCommit(git, repoDir, sha) {
150
+ try {
151
+ await git(['cat-file', '-e', `${sha}^{commit}`], repoDir);
152
+ return true;
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ }
158
+ /**
159
+ * Fetches the exact head commit: by its SHA, or else the pull request's `refs/pull/<n>/head` when that is this commit.
160
+ * A commit not yet fetchable is retried 3 times over 30 seconds. A commit the checkout already holds is the same commit.
161
+ */
162
+ async function fetchHead(git, repoDir, remote, headSha, number, sleep, signal) {
163
+ if (await hasCommit(git, repoDir, headSha))
164
+ return;
165
+ let last;
166
+ for (let attempt = 0; attempt <= FETCH_RETRIES; attempt++) {
167
+ signal?.throwIfAborted();
168
+ if (attempt > 0)
169
+ await sleep(FETCH_RETRY_MS);
170
+ signal?.throwIfAborted();
171
+ try {
172
+ await git(['fetch', '--no-tags', '--', remote, headSha], repoDir);
173
+ if (await hasCommit(git, repoDir, headSha))
174
+ return;
175
+ }
176
+ catch (error) {
177
+ last = error;
178
+ }
179
+ signal?.throwIfAborted();
180
+ try {
181
+ await git(['fetch', '--no-tags', '--', remote, `refs/pull/${number}/head`], repoDir);
182
+ const fetched = (await git(['rev-parse', '--verify', '--quiet', 'FETCH_HEAD^{commit}'], repoDir)).trim();
183
+ if (fetched.toLowerCase() === headSha.toLowerCase() && await hasCommit(git, repoDir, headSha))
184
+ return;
185
+ last = new Error(`The pull request's head is now ${fetched.slice(0, 12)}, not ${headSha.slice(0, 12)}`);
186
+ }
187
+ catch (error) {
188
+ last = error;
189
+ }
190
+ }
191
+ throw new Error(`Could not fetch the pull request's head ${headSha.slice(0, 12)}: ${last instanceof Error ? last.message : String(last)}`);
192
+ }
193
+ export function parseNumstat(output) {
194
+ const parts = output.split('\0');
195
+ const files = [];
196
+ for (let index = 0; index < parts.length;) {
197
+ const token = parts[index];
198
+ const match = /^(\d+|-)\t(\d+|-)\t([\s\S]*)$/.exec(token);
199
+ if (!match) {
200
+ index++;
201
+ continue;
202
+ }
203
+ const binary = match[1] === '-' || match[2] === '-';
204
+ const counts = { added: binary ? 0 : Number(match[1]), deleted: binary ? 0 : Number(match[2]), binary };
205
+ if (match[3] === '') {
206
+ const previousPath = parts[index + 1], path = parts[index + 2];
207
+ if (previousPath === undefined || path === undefined)
208
+ break;
209
+ files.push({ path, previousPath, ...counts });
210
+ index += 3;
211
+ }
212
+ else {
213
+ files.push({ path: match[3], ...counts });
214
+ index += 1;
215
+ }
216
+ }
217
+ return files;
218
+ }
219
+ /** `text` cut to at most `limit` bytes at a line end, its last line saying it was cut; unchanged when it fits. */
220
+ export function cutPatch(text, limit, note) {
221
+ const bytes = Buffer.byteLength(text);
222
+ if (bytes <= limit)
223
+ return text;
224
+ const tail = `${note(bytes)}\n`;
225
+ const room = Math.max(0, limit - Buffer.byteLength(tail));
226
+ const buffer = Buffer.from(text, 'utf8').subarray(0, room);
227
+ const end = buffer.lastIndexOf(0x0a);
228
+ return `${end < 0 ? '' : buffer.subarray(0, end + 1).toString('utf8')}${tail}`;
229
+ }
230
+ const WINDOWS_RESERVED = /^(?:con|prn|aux|nul|com\d|lpt\d)(?:\..*)?$/i;
231
+ /**
232
+ * A changed file's path made safe to write under `diff/`: no empty, `.` or `..` segments, no characters a file system
233
+ * refuses, and inside the folder whatever it said. Two paths that end up the same (or the same but for case) get a suffix.
234
+ */
235
+ function patchTargets(diffDir, paths) {
236
+ const used = new Set();
237
+ return paths.map((path, index) => {
238
+ const segments = path.split(/[\\/]+/).filter(segment => segment !== '' && segment !== '.').map(segment => {
239
+ const cleaned = (segment === '..' ? '_' : segment).replace(/[\u0000-\u001f<>:"|?*]/g, '_').replace(/[. ]+$/, match => '_'.repeat(match.length));
240
+ return WINDOWS_RESERVED.test(cleaned) ? `_${cleaned}` : cleaned;
241
+ });
242
+ let name = segments.length ? segments.join('/') : `file-${index + 1}`;
243
+ if (used.has(`${name}.patch`.toLowerCase()))
244
+ name = `${name}~${index + 1}`;
245
+ used.add(`${name}.patch`.toLowerCase());
246
+ const target = resolve(diffDir, `${name}.patch`);
247
+ return target.startsWith(resolve(diffDir) + sep) ? target : resolve(diffDir, `file-${index + 1}.patch`);
248
+ });
249
+ }
250
+ /**
251
+ * `-c` settings that switch off every filter the person's git config defines, so the review checkout holds the committed
252
+ * blobs: a smudge filter (git-crypt and the like) would otherwise put decrypted content where a public review can quote
253
+ * it, and a pull request's own `.gitattributes` can choose which of those filters apply. LFS is skipped already.
254
+ */
255
+ async function filterOverrides(git, repoDir) {
256
+ let listed;
257
+ // Exit 1 when no key matches: no filter is configured.
258
+ try {
259
+ listed = await git(['config', '--name-only', '--get-regexp', '^filter\\.'], repoDir);
260
+ }
261
+ catch {
262
+ return [];
263
+ }
264
+ const names = new Set();
265
+ for (const key of listed.split('\n').map(line => line.trim()).filter(Boolean)) {
266
+ const match = /^filter\.(.+)\.[^.]+$/i.exec(key);
267
+ if (match)
268
+ names.add(match[1]);
269
+ }
270
+ const overrides = [];
271
+ for (const name of names) {
272
+ if (/[=\r\n\0]/.test(name))
273
+ throw new Error('A git filter in your config has a name this review cannot switch off');
274
+ overrides.push('-c', `filter.${name}.smudge=`, '-c', `filter.${name}.clean=`, '-c', `filter.${name}.process=`, '-c', `filter.${name}.required=false`);
275
+ }
276
+ return overrides;
277
+ }
278
+ /**
279
+ * Removes the repository's records of review worktrees whose folders are gone (a crash, or the sweep), and nothing
280
+ * else: a bare `git worktree prune` would also drop the person's own worktrees that are only unavailable for now.
281
+ */
282
+ async function removeStaleReviewWorktrees(git, repoDir, root) {
283
+ let common;
284
+ try {
285
+ common = resolve(repoDir, (await git(['rev-parse', '--git-common-dir'], repoDir)).trim());
286
+ }
287
+ catch {
288
+ return;
289
+ }
290
+ const admin = join(common, 'worktrees');
291
+ const entries = await readdir(admin, { withFileTypes: true }).catch(() => []);
292
+ for (const entry of entries) {
293
+ if (!entry.isDirectory())
294
+ continue;
295
+ const gitdir = await readFile(join(admin, entry.name, 'gitdir'), 'utf8').then(text => text.trim(), () => undefined);
296
+ if (!gitdir)
297
+ continue;
298
+ const worktree = resolve(gitdir, '..');
299
+ if (!worktree.startsWith(resolve(root) + sep))
300
+ continue;
301
+ if (await lstat(worktree).then(() => true, () => false))
302
+ continue;
303
+ await rm(join(admin, entry.name), { recursive: true, force: true }).catch(() => { });
304
+ }
305
+ }
306
+ /** The patches written one per file under `diff/`: past this many files, diff.patch alone holds the rest. */
307
+ const PATCH_FILES = 300;
308
+ /**
309
+ * The review root, made private to this user: a symbolic link, or a folder another user owns or can write to, is
310
+ * refused, so no other account on the machine can swap a round's files.
311
+ */
312
+ async function reviewRoot(root) {
313
+ await mkdir(root, { recursive: true, mode: 0o700 });
314
+ const info = await lstat(root);
315
+ if (info.isSymbolicLink() || !info.isDirectory())
316
+ throw new Error(`The review folder ${root} is not a plain folder`);
317
+ if (process.platform !== 'win32' && typeof process.getuid === 'function') {
318
+ if (info.uid !== process.getuid())
319
+ throw new Error(`The review folder ${root} belongs to another user`);
320
+ if ((info.mode & 0o077) !== 0)
321
+ await chmod(root, 0o700);
322
+ }
323
+ }
324
+ export async function prepareReviewWorkspace(input) {
325
+ const { repoDir, owner, repo, number, headSha, baseRef, signal } = input;
326
+ if (!OWNER.test(owner) || !REPOSITORY.test(repo) || repo === '.' || repo === '..')
327
+ throw new Error('The repository owner and name must be GitHub names');
328
+ if (!Number.isSafeInteger(number) || number < 1)
329
+ throw new Error('The pull request number must be a positive integer');
330
+ if (!SHA.test(headSha))
331
+ throw new Error('The head must be a full commit SHA');
332
+ if (!validBranch(baseRef))
333
+ throw new Error('The base must be a branch name');
334
+ // An ssh remote that would ask for a passphrase or a host key fails at once instead of waiting on a terminal, unless
335
+ // the person set their own ssh command.
336
+ const quietSsh = input.git === undefined && process.env.GIT_SSH_COMMAND === undefined
337
+ && !await runGit(['config', '--get', 'core.sshCommand'], repoDir).then(value => value.trim() !== '', () => false);
338
+ const env = quietSsh ? { GIT_SSH_COMMAND: 'ssh -o BatchMode=yes' } : undefined;
339
+ const git = input.git ?? ((args, cwd, options) => runGit(args, cwd, { ...options, signal, env }));
340
+ // Cleanup runs even after the round was cancelled, so its git is never bound to the round's signal.
341
+ const cleanupGit = input.git ?? ((args, cwd, options) => runGit(args, cwd, { ...options, env }));
342
+ const sleep = input.sleep ?? ((ms) => defaultSleep(ms, signal));
343
+ signal?.throwIfAborted();
344
+ const remote = await githubRemote(git, repoDir, owner, repo) ?? `https://github.com/${owner}/${repo}.git`;
345
+ await fetchHead(git, repoDir, remote, headSha, number, sleep, signal);
346
+ await git(['fetch', '--no-tags', '--', remote, `refs/heads/${baseRef}`], repoDir);
347
+ const baseSha = (await git(['rev-parse', '--verify', '--quiet', 'FETCH_HEAD^{commit}'], repoDir)).trim();
348
+ if (!SHA.test(baseSha))
349
+ throw new Error(`Could not read the base branch ${baseRef}`);
350
+ const mergeBase = (await git(['merge-base', baseSha, headSha], repoDir)).trim();
351
+ if (!SHA.test(mergeBase))
352
+ throw new Error(`The pull request's head shares no history with ${baseRef}`);
353
+ const diff = await git([...DIFF_CONFIG, 'diff', ...DIFF_FLAGS, mergeBase, headSha], repoDir);
354
+ const changed = parseNumstat(await git([...DIFF_CONFIG, 'diff', ...DIFF_FLAGS, '--numstat', '-z', mergeBase, headSha], repoDir));
355
+ signal?.throwIfAborted();
356
+ const root = REVIEW_WORKSPACE_ROOT();
357
+ await reviewRoot(root);
358
+ const dir = join(root, `round-${randomBytes(9).toString('base64url').replace(/[^A-Za-z0-9]/g, 'x')}`);
359
+ let cleaning;
360
+ const cleanup = () => cleaning ??= (async () => {
361
+ try {
362
+ await cleanupGit(['worktree', 'remove', '--force', '--force', dir], repoDir);
363
+ }
364
+ catch { }
365
+ try {
366
+ await rm(dir, { recursive: true, force: true, maxRetries: 3 });
367
+ }
368
+ catch { }
369
+ try {
370
+ await removeStaleReviewWorktrees(cleanupGit, repoDir, root);
371
+ }
372
+ catch { }
373
+ })();
374
+ try {
375
+ await removeStaleReviewWorktrees(git, repoDir, root);
376
+ // No hook runs for this checkout (a relative core.hooksPath would otherwise run hooks committed in the pull request),
377
+ // and no filter: the files are the committed blobs.
378
+ await git(['-c', 'core.hooksPath=/dev/null', ...await filterOverrides(git, repoDir), 'worktree', 'add', '--detach', dir, headSha], repoDir);
379
+ signal?.throwIfAborted();
380
+ // A pull request may commit its own .andorra-review (a folder of forged inputs, or a link out of the worktree):
381
+ // it is removed, not followed, and the inputs are written into a new folder.
382
+ const inputs = join(dir, '.andorra-review');
383
+ await rm(inputs, { recursive: true, force: true });
384
+ const diffDir = join(inputs, 'diff');
385
+ await mkdir(diffDir, { recursive: true });
386
+ // Each file's own diff, asked of git by its paths (both, for a rename), so a type change's two parts stay together and
387
+ // nothing in the diff's text can move a file's boundary.
388
+ const targets = patchTargets(diffDir, changed.map(file => file.path));
389
+ const written = [];
390
+ for (const [index, file] of changed.entries()) {
391
+ if (index >= PATCH_FILES)
392
+ break;
393
+ const paths = [file.path, ...(file.previousPath === undefined ? [] : [file.previousPath])].map(path => `:(literal)${path}`);
394
+ const piece = await git([...DIFF_CONFIG, 'diff', ...DIFF_FLAGS, mergeBase, headSha, '--', ...paths], repoDir);
395
+ if (!piece)
396
+ continue;
397
+ const text = cutPatch(piece, REVIEW_DIFF_INPUT_BYTES, bytes => `[This patch was cut at 1 MiB: the file's whole diff is ${bytes} bytes. Read the file itself for the rest.]`);
398
+ let target = targets[index];
399
+ try {
400
+ await mkdir(resolve(target, '..'), { recursive: true });
401
+ await writeFile(target, text, { flag: 'wx', mode: 0o600 });
402
+ }
403
+ catch {
404
+ // A path that is both a file and a folder of another changed path: written flat beside the others instead.
405
+ target = join(diffDir, `file-${index + 1}.patch`);
406
+ await writeFile(target, text, { mode: 0o600 });
407
+ }
408
+ written[index] = relative(dir, target).split(sep).join('/');
409
+ }
410
+ const files = changed.map((file, index) => ({
411
+ path: file.path, ...(file.previousPath === undefined ? {} : { previousPath: file.previousPath }),
412
+ added: file.added, deleted: file.deleted, ...(file.binary ? { binary: true } : {}),
413
+ ...(written[index] === undefined ? {} : { patch: written[index] }),
414
+ }));
415
+ await writeFile(join(inputs, 'pr.json'), `${JSON.stringify({
416
+ url: input.pr.url, title: input.pr.title, body: input.pr.body, number,
417
+ base: { ref: baseRef, sha: baseSha }, head: { sha: headSha }, mergeBase, files,
418
+ }, null, 2)}\n`, { mode: 0o600 });
419
+ await writeFile(join(inputs, 'diff.patch'), cutPatch(diff, REVIEW_DIFF_INPUT_BYTES, bytes => `[diff.patch was cut at 1 MiB: the whole change is ${bytes} bytes over ${changed.length} files. Read the per-file patches that pr.json lists under .andorra-review/diff/.]`), { mode: 0o600 });
420
+ await writeFile(join(inputs, 'rounds.json'), `${JSON.stringify(input.rounds ?? [], null, 2)}\n`, { mode: 0o600 });
421
+ if (input.instruction !== undefined && input.instruction.trim())
422
+ await writeFile(join(inputs, 'instruction.md'), `${input.instruction.trim()}\n`, { mode: 0o600 });
423
+ signal?.throwIfAborted();
424
+ }
425
+ catch (error) {
426
+ await cleanup();
427
+ throw error;
428
+ }
429
+ return { dir, diff, mergeBase, files: changed.map(file => ({ path: file.path, added: file.added, deleted: file.deleted })), cleanup };
430
+ }
431
+ /** A little over the graph's 20 minutes, for the CLI's start and the model check before the run. */
432
+ export const REVIEWER_TIMEOUT_MS = 22 * 60_000;
433
+ const KILL_GRACE_MS = 5_000;
434
+ const STDOUT_KEEP_BYTES = 16 * 1024 * 1024;
435
+ const STDERR_KEEP_CHARS = 16 * 1024;
436
+ const REVIEWER_NODE = 'reviewer';
437
+ const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
438
+ /** The run result the CLI printed as its last JSON line under `--json`, if any. */
439
+ export function parseRunResult(stdout) {
440
+ const lines = stdout.split('\n');
441
+ for (let index = lines.length - 1; index >= 0; index--) {
442
+ const line = lines[index].trim();
443
+ if (!line.startsWith('{'))
444
+ continue;
445
+ try {
446
+ const value = JSON.parse(line);
447
+ if (record(value) && typeof value.status === 'string')
448
+ return value;
449
+ }
450
+ catch { }
451
+ }
452
+ return undefined;
453
+ }
454
+ function reviewerRunFrom(result, exitCode, stderrTail) {
455
+ const nodeResults = record(result.nodeResults) ? result.nodeResults : {};
456
+ const node = record(nodeResults[REVIEWER_NODE]) ? nodeResults[REVIEWER_NODE] : undefined;
457
+ const completion = record(result.completion) ? result.completion : undefined;
458
+ const output = node && Object.hasOwn(node, 'output') ? node.output : completion?.output;
459
+ const usage = record(result.usage) && typeof result.usage.inputTokens === 'number' && typeof result.usage.outputTokens === 'number'
460
+ ? { inputTokens: result.usage.inputTokens, outputTokens: result.usage.outputTokens } : undefined;
461
+ // A run that says it succeeded but carries no findings output cannot be posted: the loop treats it as a failed run.
462
+ if (result.status === 'succeeded' && output === undefined) {
463
+ return { status: 'failed', reason: 'The reviewer finished without its findings', ...(typeof result.id === 'string' ? { runId: result.id } : {}), exitCode, stderrTail };
464
+ }
465
+ return {
466
+ status: result.status,
467
+ ...(typeof result.id === 'string' ? { runId: result.id } : {}),
468
+ ...(typeof result.reason === 'string' ? { reason: result.reason } : {}),
469
+ ...(output === undefined ? {} : { output }),
470
+ ...(usage ? { usage } : {}),
471
+ ...(typeof result.toolCalls === 'number' ? { toolCalls: result.toolCalls } : {}),
472
+ exitCode, stderrTail,
473
+ };
474
+ }
475
+ const defaultCliPath = () => fileURLToPath(new URL('../cli.js', import.meta.url));
476
+ /**
477
+ * Runs the reviewer as a headless CLI child on `workspace` and reads its findings from the run result. The child's
478
+ * session is saved with the `andorra-review` origin, which keeps it out of the task lists. It is stopped through its
479
+ * own handle on abort or timeout: SIGTERM, then SIGKILL a few seconds later.
480
+ */
481
+ export async function runReviewer(input) {
482
+ if (input.signal?.aborted)
483
+ return { status: 'cancelled', reason: 'cancelled', exitCode: null, stderrTail: '' };
484
+ // The run input lives outside the worktree, so the reviewer cannot read or change it, and is removed afterwards.
485
+ const inputFolder = await mkdtemp(join(tmpdir(), 'andorra-review-input-'));
486
+ try {
487
+ const runInputPath = join(inputFolder, 'run-input.json');
488
+ await writeFile(runInputPath, `${JSON.stringify(input.runInput)}\n`, { mode: 0o600 });
489
+ const args = [input.cliPath ?? defaultCliPath(), '--prompt', 'Review this pull request.', '--json', '--graph', REVIEWER_GRAPH_ID,
490
+ '--jev', 'off', '--cwd', input.workspace, '--run-input', runInputPath, '--provider', input.provider, '--model', input.model];
491
+ return await new Promise(resolveRun => {
492
+ const child = spawn(input.nodePath ?? process.execPath, args, {
493
+ cwd: input.workspace, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'],
494
+ env: { ...process.env, ...input.env, ANDORRA_SESSION_ORIGIN: 'andorra-review' },
495
+ });
496
+ let stdout = [], stdoutBytes = 0, stderr = '';
497
+ let stopping;
498
+ let exitCode = null, settled = false;
499
+ let killTimer, drainTimer;
500
+ const stop = (why) => {
501
+ if (stopping || settled)
502
+ return;
503
+ stopping = why;
504
+ child.kill('SIGTERM');
505
+ killTimer = setTimeout(() => { if (!settled)
506
+ child.kill('SIGKILL'); }, KILL_GRACE_MS);
507
+ killTimer.unref?.();
508
+ };
509
+ const abort = () => stop('cancelled');
510
+ const timeout = setTimeout(() => stop('timeout'), input.timeoutMs ?? REVIEWER_TIMEOUT_MS);
511
+ timeout.unref?.();
512
+ input.signal?.addEventListener('abort', abort, { once: true });
513
+ // An abort while the run input was being written came before the listener: it still stops the child.
514
+ if (input.signal?.aborted)
515
+ abort();
516
+ const finish = (spawnError) => {
517
+ if (settled)
518
+ return;
519
+ settled = true;
520
+ clearTimeout(timeout);
521
+ clearTimeout(killTimer);
522
+ clearTimeout(drainTimer);
523
+ input.signal?.removeEventListener('abort', abort);
524
+ child.stdout?.destroy();
525
+ child.stderr?.destroy();
526
+ const stderrTail = stderr.slice(-STDERR_KEEP_CHARS);
527
+ const result = parseRunResult(Buffer.concat(stdout).toString('utf8'));
528
+ stdout = [];
529
+ if (result) {
530
+ resolveRun(reviewerRunFrom(result, exitCode, stderrTail));
531
+ return;
532
+ }
533
+ const lastLine = stderrTail.trim().split('\n').at(-1)?.trim();
534
+ resolveRun(stopping === 'cancelled' ? { status: 'cancelled', reason: 'cancelled', exitCode, stderrTail }
535
+ : stopping === 'timeout' ? { status: 'exhausted', reason: 'timeout', exitCode, stderrTail }
536
+ : { status: 'failed', reason: spawnError ? `Could not start the reviewer: ${spawnError.message}` : lastLine || `The reviewer exited with code ${exitCode ?? 'none'} and no result`, exitCode, stderrTail });
537
+ };
538
+ child.stdout.on('data', (chunk) => {
539
+ stdout.push(chunk);
540
+ stdoutBytes += chunk.length;
541
+ // Only the tail is kept: the result is the last line.
542
+ while (stdoutBytes > STDOUT_KEEP_BYTES && stdout.length > 1)
543
+ stdoutBytes -= stdout.shift().length;
544
+ });
545
+ child.stderr.on('data', (chunk) => { stderr = (stderr + chunk.toString('utf8')).slice(-STDERR_KEEP_CHARS); });
546
+ child.once('spawn', () => { if (child.pid !== undefined)
547
+ input.onSpawn?.(child.pid); });
548
+ child.once('error', error => { if (child.pid === undefined)
549
+ finish(error); });
550
+ child.once('exit', code => {
551
+ exitCode = code;
552
+ // A process the child started may still hold its output open; the result is read without waiting for it.
553
+ drainTimer = setTimeout(() => finish(), 2_000);
554
+ drainTimer.unref?.();
555
+ });
556
+ child.once('close', () => finish());
557
+ });
558
+ }
559
+ finally {
560
+ await rm(inputFolder, { recursive: true, force: true }).catch(() => { });
561
+ }
562
+ }
563
+ /**
564
+ * Removes the `round-*` folders under the review root older than `olderThanMs` (an hour by default) that a crash left
565
+ * behind, and answers how many. It never follows a symbolic link: a linked root or round is left alone.
566
+ */
567
+ export async function sweepReviewWorkspaces(options = {}) {
568
+ const root = options.root ?? REVIEW_WORKSPACE_ROOT();
569
+ const olderThan = options.olderThanMs ?? 60 * 60_000;
570
+ const now = options.now ?? Date.now;
571
+ const rootInfo = await lstat(root).catch(() => undefined);
572
+ if (!rootInfo || rootInfo.isSymbolicLink() || !rootInfo.isDirectory())
573
+ return 0;
574
+ let entries;
575
+ try {
576
+ entries = await readdir(root, { withFileTypes: true });
577
+ }
578
+ catch {
579
+ return 0;
580
+ }
581
+ let removed = 0;
582
+ for (const entry of entries) {
583
+ if (!/^round-[A-Za-z0-9_-]+$/.test(entry.name))
584
+ continue;
585
+ const path = join(root, entry.name);
586
+ const info = await lstat(path).catch(() => undefined);
587
+ if (!info || info.isSymbolicLink() || !info.isDirectory())
588
+ continue;
589
+ if (now() - info.mtimeMs < olderThan)
590
+ continue;
591
+ try {
592
+ await rm(path, { recursive: true, force: true, maxRetries: 3 });
593
+ removed++;
594
+ }
595
+ catch { }
596
+ }
597
+ return removed;
598
+ }
@@ -0,0 +1,59 @@
1
+ import { type GitHubCoverage } from './client.js';
2
+ /**
3
+ * What the GitHub App event source keeps under `<home>/github-app/`. A desktop engine and a CLI on one home
4
+ * share these files; only the process that holds the pull-request watcher's lease writes them.
5
+ *
6
+ * - `engine.json`: this home's engine id, 22 base64url characters, so a desktop and a bridge machine on one
7
+ * account do not overwrite each other's subscriptions.
8
+ * - `cursor.json`: the inbox cursor the next pull starts after.
9
+ * - `state.json`: the coverage the lease holder last saw, so `github.status` in another process on the same
10
+ * home answers the same coverage without subscribing itself.
11
+ * - `mentions.json`: the comments that mentioned the App's bot which this home has already acted on (their node
12
+ * ids and when), so a notice pulled again after a restart wakes nothing. Never a comment's text.
13
+ * - `own-comments.json`: the comments the agent's own writes made in the last 2 hours (node ids and links), so
14
+ * a mention in one of them never wakes the task (written by whichever process made the write).
15
+ */
16
+ export declare const githubAppDirectory: (home: string) => string;
17
+ export declare const newEngineId: () => string;
18
+ /** This home's engine id, created on first use. A malformed file is replaced, so the service never sees a bad id. */
19
+ export declare function engineId(home: string): Promise<string>;
20
+ export declare function readCursor(home: string): Promise<string | undefined>;
21
+ export declare function writeCursor(home: string, cursor: string | undefined, now: number): Promise<void>;
22
+ export type EventMode = 'off' | 'events' | 'polling';
23
+ export interface SharedCoverage {
24
+ updatedAt: string;
25
+ mode: EventMode;
26
+ /** Why event mode is off or polling, when it is. */
27
+ reason?: GitHubCoverage;
28
+ connected?: boolean;
29
+ pullRequests: Record<string, {
30
+ url: string;
31
+ coverage: GitHubCoverage;
32
+ }>;
33
+ }
34
+ export declare function readSharedCoverage(home: string): Promise<SharedCoverage | undefined>;
35
+ export declare function writeSharedCoverage(home: string, state: SharedCoverage): Promise<void>;
36
+ /** How long a handled mention is remembered: the service keeps a notice 7 days, so it cannot come back later. */
37
+ export declare const MENTION_MEMORY_MS: number;
38
+ /** At most this many handled mentions are remembered (the oldest go first). */
39
+ export declare const MENTION_MEMORY = 500;
40
+ /** The comment ids this home acted on, with when: entries older than `MENTION_MEMORY_MS` are left out. */
41
+ export declare function readMentions(home: string, now: number): Promise<Map<string, number>>;
42
+ export declare function writeMentions(home: string, handled: ReadonlyMap<string, number>): Promise<void>;
43
+ /**
44
+ * Comments the engine's own writes made on a PR (the agent's replies and comments, through the bot or gh), kept
45
+ * so a `request` notice for one of them never wakes the task that wrote it: a reply posted through gh is the
46
+ * person's, and one that names the bot would otherwise ask for the task again. Any process on the home may
47
+ * add one; the lease holder reads them. Ids and links only, never the text.
48
+ */
49
+ export declare const OWN_COMMENT_MEMORY_MS: number;
50
+ export interface OwnComment {
51
+ id?: string;
52
+ url?: string;
53
+ at: number;
54
+ }
55
+ export declare function readOwnComments(home: string, now: number): Promise<OwnComment[]>;
56
+ export declare function rememberOwnComment(home: string, comment: {
57
+ id?: string;
58
+ url?: string;
59
+ }, now: number): Promise<void>;