@andorra-labs/code 0.1.15 → 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 (242) 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-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +15 -10
  5. package/dist/src/agent-mcp-catalog.js +1 -0
  6. package/dist/src/agent-mcp.d.ts +4 -1
  7. package/dist/src/agent-mcp.js +46 -10
  8. package/dist/src/andorra/entry.d.ts +10 -0
  9. package/dist/src/andorra/entry.js +18 -4
  10. package/dist/src/andorra/hosted.d.ts +2 -1
  11. package/dist/src/andorra/hosted.js +2 -1
  12. package/dist/src/andorra/notices.d.ts +5 -0
  13. package/dist/src/andorra/notices.js +7 -0
  14. package/dist/src/andorra/state.d.ts +3 -2
  15. package/dist/src/andorra/state.js +4 -4
  16. package/dist/src/andorra/terminal.js +7 -2
  17. package/dist/src/anthropic-credentials.js +2 -0
  18. package/dist/src/app-server/error.d.ts +5 -0
  19. package/dist/src/app-server/error.js +7 -0
  20. package/dist/src/app-server/protocol.d.ts +22 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +89 -0
  23. package/dist/src/app-server/workspace.js +457 -11
  24. package/dist/src/app-server.d.ts +465 -32
  25. package/dist/src/app-server.js +3308 -517
  26. package/dist/src/auth/deployment.js +2 -2
  27. package/dist/src/bridge/cloud.d.ts +27 -0
  28. package/dist/src/bridge/cloud.js +187 -0
  29. package/dist/src/bridge/command.d.ts +30 -0
  30. package/dist/src/bridge/command.js +347 -0
  31. package/dist/src/bridge/control.d.ts +68 -0
  32. package/dist/src/bridge/control.js +233 -0
  33. package/dist/src/bridge/engines.d.ts +90 -0
  34. package/dist/src/bridge/engines.js +601 -0
  35. package/dist/src/bridge/host-ops.d.ts +9 -0
  36. package/dist/src/bridge/host-ops.js +129 -0
  37. package/dist/src/bridge/host.d.ts +47 -0
  38. package/dist/src/bridge/host.js +540 -0
  39. package/dist/src/bridge/link.d.ts +38 -0
  40. package/dist/src/bridge/link.js +508 -0
  41. package/dist/src/bridge/login-link.d.ts +29 -0
  42. package/dist/src/bridge/login-link.js +54 -0
  43. package/dist/src/bridge/protocol.d.ts +136 -0
  44. package/dist/src/bridge/protocol.js +11 -0
  45. package/dist/src/bridge/store.d.ts +12 -0
  46. package/dist/src/bridge/store.js +61 -0
  47. package/dist/src/bridge/wording.d.ts +6 -0
  48. package/dist/src/bridge/wording.js +10 -0
  49. package/dist/src/browser-runner.js +1 -0
  50. package/dist/src/browser-server.js +7 -1
  51. package/dist/src/browser-ui/style.css +3 -3
  52. package/dist/src/browser-ui/tokens.css +28 -17
  53. package/dist/src/change-authors.d.ts +41 -0
  54. package/dist/src/change-authors.js +146 -0
  55. package/dist/src/claude-provider.js +3 -1
  56. package/dist/src/cli.js +202 -38
  57. package/dist/src/codex-errors.js +4 -1
  58. package/dist/src/coding-tools.js +15 -15
  59. package/dist/src/command-screens.d.ts +6 -0
  60. package/dist/src/command-screens.js +19 -14
  61. package/dist/src/commands.d.ts +14 -1
  62. package/dist/src/compaction-phrases.d.ts +4 -0
  63. package/dist/src/compaction-phrases.js +20 -0
  64. package/dist/src/completion.js +82 -5
  65. package/dist/src/config.d.ts +71 -3
  66. package/dist/src/config.js +202 -77
  67. package/dist/src/context-compaction.js +2 -1
  68. package/dist/src/deadline.js +13 -1
  69. package/dist/src/decision/DecisionManager.js +3 -2
  70. package/dist/src/decision/checks.js +1 -1
  71. package/dist/src/decision/requestPhrases.d.ts +4 -0
  72. package/dist/src/decision/requestPhrases.js +22 -0
  73. package/dist/src/default-graph.js +1 -1
  74. package/dist/src/file-diff.d.ts +4 -0
  75. package/dist/src/file-diff.js +2 -1
  76. package/dist/src/github-app/agent-writes.d.ts +102 -0
  77. package/dist/src/github-app/agent-writes.js +320 -0
  78. package/dist/src/github-app/client.d.ts +349 -0
  79. package/dist/src/github-app/client.js +810 -0
  80. package/dist/src/github-app/event-source.d.ts +208 -0
  81. package/dist/src/github-app/event-source.js +684 -0
  82. package/dist/src/github-app/metrics.d.ts +32 -0
  83. package/dist/src/github-app/metrics.js +49 -0
  84. package/dist/src/github-app/review-loop.d.ts +274 -0
  85. package/dist/src/github-app/review-loop.js +1177 -0
  86. package/dist/src/github-app/review-node.d.ts +81 -0
  87. package/dist/src/github-app/review-node.js +205 -0
  88. package/dist/src/github-app/review-post.d.ts +73 -0
  89. package/dist/src/github-app/review-post.js +139 -0
  90. package/dist/src/github-app/review-text.d.ts +107 -0
  91. package/dist/src/github-app/review-text.js +1133 -0
  92. package/dist/src/github-app/review-threads.d.ts +47 -0
  93. package/dist/src/github-app/review-threads.js +107 -0
  94. package/dist/src/github-app/reviewer.d.ts +121 -0
  95. package/dist/src/github-app/reviewer.js +598 -0
  96. package/dist/src/github-app/store.d.ts +59 -0
  97. package/dist/src/github-app/store.js +148 -0
  98. package/dist/src/github-app/triggers.d.ts +141 -0
  99. package/dist/src/github-app/triggers.js +441 -0
  100. package/dist/src/github-inbox.d.ts +55 -0
  101. package/dist/src/github-inbox.js +153 -0
  102. package/dist/src/github-names.d.ts +8 -0
  103. package/dist/src/github-names.js +8 -0
  104. package/dist/src/glob-search.d.ts +61 -0
  105. package/dist/src/glob-search.js +180 -0
  106. package/dist/src/graph-health.js +13 -4
  107. package/dist/src/graph-manager-chat.js +1 -1
  108. package/dist/src/graph-preview.d.ts +46 -0
  109. package/dist/src/graph-preview.js +55 -0
  110. package/dist/src/graph-provider-portability.js +34 -11
  111. package/dist/src/graph-quota.d.ts +29 -2
  112. package/dist/src/graph-quota.js +68 -10
  113. package/dist/src/graph-runner.js +88 -10
  114. package/dist/src/graph-server.d.ts +1 -1
  115. package/dist/src/graph-server.js +11 -9
  116. package/dist/src/graph-sync.js +3 -3
  117. package/dist/src/graph-ui/app.js +201 -40
  118. package/dist/src/graph-ui/controls.css +1 -0
  119. package/dist/src/graph-ui/embed.js +2 -2
  120. package/dist/src/graph-ui/icons.js +3 -1
  121. package/dist/src/graph-ui/index.html +1 -1
  122. package/dist/src/graph-ui/manager.css +1 -1
  123. package/dist/src/graph-ui/manager.js +2 -2
  124. package/dist/src/graph-ui/sidebar.js +30 -0
  125. package/dist/src/graph-ui/studio-canvas.js +26 -13
  126. package/dist/src/graph-ui/studio.css +15 -7
  127. package/dist/src/graph-ui/studio.js +26 -5
  128. package/dist/src/graph-ui/style.css +77 -45
  129. package/dist/src/graph-ui/theme.js +3 -36
  130. package/dist/src/graph-ui/tokens.css +28 -20
  131. package/dist/src/graphs.d.ts +34 -1
  132. package/dist/src/graphs.js +162 -17
  133. package/dist/src/image-input.d.ts +16 -0
  134. package/dist/src/image-input.js +41 -0
  135. package/dist/src/membership.d.ts +30 -1
  136. package/dist/src/membership.js +48 -8
  137. package/dist/src/model-health-cache.js +1 -1
  138. package/dist/src/model-metadata.d.ts +7 -1
  139. package/dist/src/model-metadata.js +39 -17
  140. package/dist/src/model-relay/local.d.ts +116 -0
  141. package/dist/src/model-relay/local.js +468 -0
  142. package/dist/src/model-relay/remote.d.ts +129 -0
  143. package/dist/src/model-relay/remote.js +252 -0
  144. package/dist/src/model-relay/runs.d.ts +34 -0
  145. package/dist/src/model-relay/runs.js +146 -0
  146. package/dist/src/model-relay/wire.d.ts +5 -0
  147. package/dist/src/model-relay/wire.js +5 -0
  148. package/dist/src/plan-pass.d.ts +59 -0
  149. package/dist/src/plan-pass.js +165 -0
  150. package/dist/src/project-registry.d.ts +21 -0
  151. package/dist/src/project-registry.js +74 -0
  152. package/dist/src/provider-engine.js +3 -0
  153. package/dist/src/provider-import.d.ts +0 -12
  154. package/dist/src/provider-import.js +7 -195
  155. package/dist/src/providers.d.ts +40 -2
  156. package/dist/src/providers.js +93 -23
  157. package/dist/src/pull-request-checks.d.ts +26 -0
  158. package/dist/src/pull-request-checks.js +56 -0
  159. package/dist/src/pull-request-conversation.d.ts +134 -0
  160. package/dist/src/pull-request-conversation.js +221 -0
  161. package/dist/src/pull-request-create.d.ts +175 -0
  162. package/dist/src/pull-request-create.js +392 -0
  163. package/dist/src/pull-request-details.d.ts +242 -0
  164. package/dist/src/pull-request-details.js +614 -0
  165. package/dist/src/pull-request-edit.d.ts +23 -0
  166. package/dist/src/pull-request-edit.js +91 -0
  167. package/dist/src/pull-request-logs.d.ts +87 -0
  168. package/dist/src/pull-request-logs.js +183 -0
  169. package/dist/src/pull-request-merge.d.ts +112 -0
  170. package/dist/src/pull-request-merge.js +258 -0
  171. package/dist/src/pull-request-review.d.ts +137 -0
  172. package/dist/src/pull-request-review.js +401 -0
  173. package/dist/src/pull-requests.d.ts +369 -8
  174. package/dist/src/pull-requests.js +524 -55
  175. package/dist/src/react-runtime.js +38 -5
  176. package/dist/src/remote/engine-pool.d.ts +88 -4
  177. package/dist/src/remote/engine-pool.js +379 -90
  178. package/dist/src/remote/roots.d.ts +19 -0
  179. package/dist/src/remote/roots.js +45 -7
  180. package/dist/src/remote/types.d.ts +0 -44
  181. package/dist/src/run-control.d.ts +17 -0
  182. package/dist/src/run-control.js +47 -0
  183. package/dist/src/run-progress.d.ts +10 -0
  184. package/dist/src/run-progress.js +122 -0
  185. package/dist/src/run-records.d.ts +7 -2
  186. package/dist/src/run-records.js +71 -6
  187. package/dist/src/runtime.d.ts +9 -1
  188. package/dist/src/runtime.js +24 -4
  189. package/dist/src/session-changes.d.ts +35 -0
  190. package/dist/src/session-changes.js +194 -6
  191. package/dist/src/session-monitor.js +2 -1
  192. package/dist/src/session-reaper.d.ts +1 -1
  193. package/dist/src/session-reaper.js +6 -1
  194. package/dist/src/session-summary.d.ts +2 -1
  195. package/dist/src/session-summary.js +2 -1
  196. package/dist/src/sessions.d.ts +11 -1
  197. package/dist/src/sessions.js +17 -4
  198. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  199. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  200. package/dist/src/skills/bundled/provenance.json +2 -2
  201. package/dist/src/skills/runtime-skills.js +1 -1
  202. package/dist/src/subagent-run.js +1 -0
  203. package/dist/src/telemetry/capture-core.d.ts +17 -0
  204. package/dist/src/telemetry/capture-core.js +59 -1
  205. package/dist/src/telemetry/classify.d.ts +3 -1
  206. package/dist/src/telemetry/classify.js +37 -0
  207. package/dist/src/telemetry/emitter.d.ts +17 -0
  208. package/dist/src/telemetry/emitter.js +76 -5
  209. package/dist/src/telemetry/schema.d.ts +47 -2
  210. package/dist/src/telemetry/schema.js +120 -5
  211. package/dist/src/telemetry/surface.d.ts +3 -1
  212. package/dist/src/telemetry/surface.js +4 -1
  213. package/dist/src/telemetry/uploader.d.ts +6 -1
  214. package/dist/src/telemetry/uploader.js +22 -3
  215. package/dist/src/terminal-ui.d.ts +1 -0
  216. package/dist/src/terminal-ui.js +10 -3
  217. package/dist/src/test-edit-guard.d.ts +7 -0
  218. package/dist/src/test-edit-guard.js +49 -1
  219. package/dist/src/timers.d.ts +2 -0
  220. package/dist/src/tools.js +59 -9
  221. package/dist/src/transcript.js +8 -2
  222. package/dist/src/types.d.ts +7 -0
  223. package/dist/src/usage-analytics.js +18 -10
  224. package/package.json +6 -1
  225. package/dist/src/remote/cert.d.ts +0 -11
  226. package/dist/src/remote/cert.js +0 -87
  227. package/dist/src/remote/client.d.ts +0 -119
  228. package/dist/src/remote/client.js +0 -544
  229. package/dist/src/remote/command.d.ts +0 -4
  230. package/dist/src/remote/command.js +0 -194
  231. package/dist/src/remote/errors.d.ts +0 -11
  232. package/dist/src/remote/errors.js +0 -14
  233. package/dist/src/remote/network.d.ts +0 -22
  234. package/dist/src/remote/network.js +0 -102
  235. package/dist/src/remote/pairing.d.ts +0 -63
  236. package/dist/src/remote/pairing.js +0 -299
  237. package/dist/src/remote/pem.d.ts +0 -2
  238. package/dist/src/remote/pem.js +0 -7
  239. package/dist/src/remote/serve.d.ts +0 -68
  240. package/dist/src/remote/serve.js +0 -244
  241. package/dist/src/remote/server.d.ts +0 -21
  242. package/dist/src/remote/server.js +0 -406
@@ -43,6 +43,164 @@ export function isProjectExtensionOverride(entry) {
43
43
  return false;
44
44
  return true;
45
45
  }
46
+ /** At most this many machines are allowed per account; allowing another drops the oldest. */
47
+ export const MODEL_RELAY_ALLOWED_LIMIT = 64;
48
+ const MODEL_RELAY_ACCOUNT_LIMIT = 64;
49
+ const ENVIRONMENT_ID = /^env_[A-Za-z0-9_-]{22}$/;
50
+ const ACCOUNT_SUBJECT = /^[A-Za-z0-9-]{1,128}$/;
51
+ /** The machines `subject` allowed to use this computer's models, from a saved `environments.modelRelay`. */
52
+ export function modelRelayAllowedFor(environments, subject) {
53
+ const saved = environments?.modelRelay;
54
+ if (subject === undefined || !saved || Array.isArray(saved) || !Object.hasOwn(saved, subject))
55
+ return [];
56
+ return [...saved[subject]];
57
+ }
58
+ /**
59
+ * `map` with `subject`'s list set to `list` and moved to the end: the object's key order is the order in which the
60
+ * accounts' lists were last written. Past 64 accounts, the least recently written are dropped, so the file always
61
+ * validates. (Account subjects are Cognito ids, never integer-like keys, so the order holds.)
62
+ */
63
+ export function withModelRelayEntry(map, subject, list) {
64
+ const others = Object.entries(map).filter(([key]) => key !== subject);
65
+ return Object.fromEntries([...others.slice(Math.max(0, others.length - (MODEL_RELAY_ACCOUNT_LIMIT - 1))), [subject, list.slice(-MODEL_RELAY_ALLOWED_LIMIT)]]);
66
+ }
67
+ /**
68
+ * The Andorra GitHub App, per user. `app.enabled: false` turns its events off on this installation (every PR
69
+ * is polled through gh, as without the App). `app.agentWrites` says who the agent's replies, resolves and PR
70
+ * comments post as on a PR the App covers: `bot` (the default) for the App's bot, `me` for the person's own gh
71
+ * account. `app.triggers: false` stops a mention of the App's bot on a task's PR from waking the task on this
72
+ * installation (the per-machine opt-out; on by default). `app.reviews: false` refuses switching the Andorra review loop
73
+ * on here (on by default); `app.reviewNewPullRequests: true` switches it on for each PR a task opens (off by default).
74
+ * Other keys under `github.app` belong to later versions and are kept as written.
75
+ */
76
+ export const GITHUB_AGENT_WRITES = ['bot', 'me'];
77
+ export function validateGitHubConfig(value) {
78
+ const c = value;
79
+ if (!c || typeof c !== 'object' || Array.isArray(c))
80
+ throw new Error('Invalid github configuration');
81
+ if (c.app !== undefined && (!c.app || typeof c.app !== 'object' || Array.isArray(c.app)))
82
+ throw new Error('Invalid github.app configuration');
83
+ if (c.app?.enabled !== undefined && typeof c.app.enabled !== 'boolean')
84
+ throw new Error('github.app.enabled must be a boolean');
85
+ if (c.app?.agentWrites !== undefined && !GITHUB_AGENT_WRITES.includes(c.app.agentWrites))
86
+ throw new Error('github.app.agentWrites must be bot or me');
87
+ if (c.app?.triggers !== undefined && typeof c.app.triggers !== 'boolean')
88
+ throw new Error('github.app.triggers must be a boolean');
89
+ if (c.app?.reviews !== undefined && typeof c.app.reviews !== 'boolean')
90
+ throw new Error('github.app.reviews must be a boolean');
91
+ if (c.app?.reviewNewPullRequests !== undefined && typeof c.app.reviewNewPullRequests !== 'boolean')
92
+ throw new Error('github.app.reviewNewPullRequests must be a boolean');
93
+ return c;
94
+ }
95
+ /** Who the agent's PR writes post as: `me` only when the config says so; anything else, or no config, is `bot`. */
96
+ function agentWritesOf(config) {
97
+ const github = typeof config === 'object' && config !== null ? config.github : undefined;
98
+ const app = typeof github === 'object' && github !== null ? github.app : undefined;
99
+ return typeof app === 'object' && app !== null && app.agentWrites === 'me' ? 'me' : 'bot';
100
+ }
101
+ export function githubAgentWrites(config) {
102
+ return agentWritesOf(config);
103
+ }
104
+ /** The same, read from `config.json` for each write and each Auto-fix prompt, without validation or keyring; unreadable reads as `bot`. */
105
+ export async function readGitHubAgentWrites(directory) {
106
+ let value;
107
+ try {
108
+ value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
109
+ }
110
+ catch {
111
+ return 'bot';
112
+ }
113
+ return agentWritesOf(value);
114
+ }
115
+ /**
116
+ * The one rule for whether the GitHub App's events may run here: not switched off by `ANDORRA_GITHUB_APP=off`,
117
+ * nor by `github.app.enabled: false` in the config (parsed, or read raw from `config.json`).
118
+ */
119
+ function githubAppEventsAllowed(config, env) {
120
+ if (env.ANDORRA_GITHUB_APP?.trim().toLowerCase() === 'off')
121
+ return false;
122
+ const github = typeof config === 'object' && config !== null ? config.github : undefined;
123
+ const app = typeof github === 'object' && github !== null ? github.app : undefined;
124
+ return !(typeof app === 'object' && app !== null && app.enabled === false);
125
+ }
126
+ /** Whether the GitHub App's events may run here: not switched off in config, nor by `ANDORRA_GITHUB_APP=off`. */
127
+ export function githubAppEventsEnabled(config, env = process.env) {
128
+ return githubAppEventsAllowed(config, env);
129
+ }
130
+ /**
131
+ * The same, read cheaply for a check that runs every minute: only `github.app.enabled` is taken from
132
+ * `config.json`, with no validation, no provider keys and no keyring. A missing or unreadable file reads as on,
133
+ * as `loadConfig`'s default config would.
134
+ */
135
+ export async function readGitHubAppEventsEnabled(directory, env = process.env) {
136
+ if (!githubAppEventsAllowed(undefined, env))
137
+ return false;
138
+ let value;
139
+ try {
140
+ value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
141
+ }
142
+ catch {
143
+ return true;
144
+ }
145
+ return githubAppEventsAllowed(value, env);
146
+ }
147
+ /** A mention of the bot may wake a task here: only `github.app.triggers: false` says no. */
148
+ function triggersOf(config) {
149
+ const github = typeof config === 'object' && config !== null ? config.github : undefined;
150
+ const app = typeof github === 'object' && github !== null ? github.app : undefined;
151
+ return !(typeof app === 'object' && app !== null && app.triggers === false);
152
+ }
153
+ export function githubAppTriggersEnabled(config) {
154
+ return triggersOf(config);
155
+ }
156
+ /** The same, read from `config.json` for each mention, without validation or keyring; a missing or unreadable file reads as on. */
157
+ export async function readGitHubAppTriggersEnabled(directory) {
158
+ let value;
159
+ try {
160
+ value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
161
+ }
162
+ catch {
163
+ return true;
164
+ }
165
+ return triggersOf(value);
166
+ }
167
+ /** One boolean key under `github.app`, or undefined when the config does not set it. */
168
+ function githubAppFlag(config, key) {
169
+ const github = typeof config === 'object' && config !== null ? config.github : undefined;
170
+ const app = typeof github === 'object' && github !== null ? github.app : undefined;
171
+ const value = typeof app === 'object' && app !== null ? app[key] : undefined;
172
+ return typeof value === 'boolean' ? value : undefined;
173
+ }
174
+ /** The Andorra review loop may be switched on here: only `github.app.reviews: false` says no. */
175
+ export function githubAppReviewsEnabled(config) {
176
+ return githubAppFlag(config, 'reviews') !== false;
177
+ }
178
+ /** The same, read from `config.json` without validation or keyring; a missing or unreadable file reads as on. */
179
+ export async function readGitHubAppReviewsEnabled(directory) {
180
+ let value;
181
+ try {
182
+ value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
183
+ }
184
+ catch {
185
+ return true;
186
+ }
187
+ return githubAppFlag(value, 'reviews') !== false;
188
+ }
189
+ /** A PR a task opens starts with the review loop on: only `github.app.reviewNewPullRequests: true` says so. */
190
+ export function githubAppReviewNewPullRequests(config) {
191
+ return githubAppFlag(config, 'reviewNewPullRequests') === true;
192
+ }
193
+ /** The same, read from `config.json`; a missing or unreadable file reads as off. */
194
+ export async function readGitHubAppReviewNewPullRequests(directory) {
195
+ let value;
196
+ try {
197
+ value = JSON.parse(await readFile(join(directory, 'config.json'), 'utf8'));
198
+ }
199
+ catch {
200
+ return false;
201
+ }
202
+ return githubAppFlag(value, 'reviewNewPullRequests') === true;
203
+ }
46
204
  export const MAX_CAPSOLVER_API_KEY_LENGTH = 256;
47
205
  export function validateBrowserConfig(value) {
48
206
  const c = value;
@@ -235,6 +393,8 @@ export function validateConfig(value) {
235
393
  validateBrowserConfig(c.browser);
236
394
  if (c.webSearch !== undefined)
237
395
  validateWebSearchConfig(c.webSearch);
396
+ if (c.github !== undefined)
397
+ validateGitHubConfig(c.github);
238
398
  if (c.extensions !== undefined) {
239
399
  if (!c.extensions || typeof c.extensions !== 'object' || Array.isArray(c.extensions))
240
400
  throw new Error('Invalid extensions configuration');
@@ -256,8 +416,10 @@ export function validateConfig(value) {
256
416
  || Object.entries(c.projectExtensions).some(([key, entry]) => !/^[a-f0-9]{64}$/.test(key) || !isProjectExtensionOverride(entry)))) {
257
417
  throw new Error('Invalid projectExtensions configuration');
258
418
  }
259
- if (c.remote !== undefined)
260
- validateRemoteConfig(c.remote);
419
+ if (c.bridge !== undefined)
420
+ validateBridgeConfig(c.bridge);
421
+ if (c.environments !== undefined)
422
+ validateEnvironmentsConfig(c.environments);
261
423
  if (c.projects !== undefined)
262
424
  validateProjectsConfig(c.projects);
263
425
  if (c.externalSubagent !== undefined && !c.providers.some(p => p?.id === c.externalSubagent.provider)) {
@@ -271,6 +433,9 @@ export function validateConfig(value) {
271
433
  const ids = new Set();
272
434
  let andorraSeen = false;
273
435
  for (const p of c.providers) {
436
+ // A relayed provider lives only in the run that a desktop started with it: never in a config file.
437
+ if (p && typeof p === 'object' && p.type === 'relayed')
438
+ throw new Error('Relayed providers cannot be saved.');
274
439
  if (p && typeof p === 'object' && p.type === 'andorra')
275
440
  normaliseAndorraEntry(p);
276
441
  if (!p || typeof p.id !== 'string' || !/^[\w-]+$/.test(p.id) || ids.has(p.id)
@@ -294,6 +459,9 @@ export function validateConfig(value) {
294
459
  throw new Error(`The active model must be one of provider ${p.id}'s configured models`);
295
460
  }
296
461
  }
462
+ if (p.textOnlyModels !== undefined && (!Array.isArray(p.textOnlyModels) || p.textOnlyModels.some((model) => typeof model !== 'string' || !model.trim() || model.length > 500))) {
463
+ throw new Error('Provider textOnlyModels must be a list of nonempty model ids');
464
+ }
297
465
  if (p.modelContextWindows !== undefined) {
298
466
  if (!p.modelContextWindows || typeof p.modelContextWindows !== 'object' || Array.isArray(p.modelContextWindows)) {
299
467
  throw new Error('Provider modelContextWindows must map model ids to positive integer context windows');
@@ -785,9 +953,6 @@ export function resolveCodeIntelConfig(config) {
785
953
  validateCodeIntelConfig(codeIntel);
786
954
  return codeIntel;
787
955
  }
788
- const BASE64URL_32 = /^[A-Za-z0-9_-]{43}$/;
789
- const HEX_16 = /^[a-f0-9]{16}$/;
790
- const HEX_32 = /^[a-f0-9]{32}$/;
791
956
  const HEX_12 = /^[a-f0-9]{12}$/;
792
957
  const ISO_DATE = /^\d{4}-\d{2}-\d{2}T/;
793
958
  function isDisplayLabel(value) {
@@ -796,80 +961,40 @@ function isDisplayLabel(value) {
796
961
  function isIsoDate(value) {
797
962
  return typeof value === 'string' && ISO_DATE.test(value) && !Number.isNaN(Date.parse(value));
798
963
  }
799
- function isPort(value) {
800
- return Number.isSafeInteger(value) && value >= 1 && value <= 65535;
801
- }
802
- export function validateRemoteConfig(remote) {
803
- const r = remote;
804
- if (!r || typeof r !== 'object' || Array.isArray(r))
805
- throw new Error('Invalid remote configuration');
806
- if (r.hosting !== undefined) {
807
- const h = r.hosting;
808
- if (!h || typeof h !== 'object' || Array.isArray(h))
809
- throw new Error('Invalid remote hosting configuration');
810
- if (h.installId !== undefined && !HEX_32.test(h.installId))
811
- throw new Error('remote.hosting.installId must be 32 hex characters');
812
- if (h.port !== undefined && !isPort(h.port))
813
- throw new Error('remote.hosting.port must be a port number');
814
- if (h.transport !== undefined && h.transport !== 'https' && h.transport !== 'http')
815
- throw new Error('remote.hosting.transport must be https or http');
816
- if (h.invitation !== undefined && h.invitation !== null) {
817
- const i = h.invitation;
818
- if (!i || typeof i !== 'object' || Array.isArray(i) || !BASE64URL_32.test(i.token) || !isIsoDate(i.createdAt) || !isIsoDate(i.expiresAt)
819
- || (i.redeemedAt !== undefined && !isIsoDate(i.redeemedAt))
820
- || (i.grant !== undefined && i.grant !== 'browse' && i.grant !== 'full'))
821
- throw new Error('Invalid remote invitation');
822
- }
823
- if (h.devices !== undefined) {
824
- if (!Array.isArray(h.devices) || h.devices.length > 32)
825
- throw new Error('remote.hosting.devices must be an array of at most 32 devices');
826
- const ids = new Set();
827
- for (const device of h.devices) {
828
- if (!device || typeof device !== 'object' || Array.isArray(device) || !HEX_16.test(device.id) || ids.has(device.id)
829
- || !BASE64URL_32.test(device.token) || !isIsoDate(device.addedAt)
830
- || (device.label !== undefined && !isDisplayLabel(device.label))
831
- || (device.lastSeenAt !== undefined && !isIsoDate(device.lastSeenAt))
832
- || (device.grant !== undefined && device.grant !== 'browse' && device.grant !== 'full'))
833
- throw new Error('Invalid paired remote device');
834
- ids.add(device.id);
835
- }
836
- }
837
- if (h.shares !== undefined) {
838
- if (!Array.isArray(h.shares) || h.shares.length > 64)
839
- throw new Error('remote.hosting.shares must be an array of at most 64 shares');
840
- const ids = new Set();
841
- for (const share of h.shares) {
842
- if (!share || typeof share !== 'object' || Array.isArray(share) || !HEX_12.test(share.id) || ids.has(share.id)
843
- || typeof share.path !== 'string' || !share.path.trim() || share.path.includes('\0')
844
- || (share.label !== undefined && !isDisplayLabel(share.label)))
845
- throw new Error('Invalid remote share');
846
- ids.add(share.id);
847
- }
848
- }
964
+ export function validateBridgeConfig(bridge) {
965
+ const b = bridge;
966
+ if (!b || typeof b !== 'object' || Array.isArray(b))
967
+ throw new Error('Invalid bridge configuration');
968
+ if (b.folders === undefined)
969
+ return;
970
+ if (!Array.isArray(b.folders) || b.folders.length > 64)
971
+ throw new Error('bridge.folders must be an array of at most 64 folders');
972
+ const ids = new Set();
973
+ for (const folder of b.folders) {
974
+ if (!folder || typeof folder !== 'object' || Array.isArray(folder) || typeof folder.id !== 'string' || !HEX_12.test(folder.id) || ids.has(folder.id)
975
+ || typeof folder.path !== 'string' || !folder.path.trim() || folder.path.includes('\0')
976
+ || (folder.label !== undefined && !isDisplayLabel(folder.label)))
977
+ throw new Error('Invalid bridge folder');
978
+ ids.add(folder.id);
849
979
  }
850
- if (r.workspaces !== undefined) {
851
- if (!Array.isArray(r.workspaces) || r.workspaces.length > 32)
852
- throw new Error('remote.workspaces must be an array of at most 32 workspaces');
853
- const ids = new Set();
854
- for (const workspace of r.workspaces) {
855
- if (!workspace || typeof workspace !== 'object' || Array.isArray(workspace)
856
- || !/^ws-[a-f0-9]{12}$/.test(workspace.id) || ids.has(workspace.id)
857
- || !isDisplayLabel(workspace.nickname) || !Array.isArray(workspace.hosts) || workspace.hosts.length < 1 || workspace.hosts.length > 8
858
- || workspace.hosts.some((host) => typeof host !== 'string' || !host.trim() || host.length > 253 || /[\0\r\n /]/.test(host))
859
- || (workspace.host !== undefined && (typeof workspace.host !== 'string' || !workspace.host.trim() || workspace.host.length > 253 || /[\0\r\n /]/.test(workspace.host)))
860
- || !isPort(workspace.port) || (workspace.transport !== 'https' && workspace.transport !== 'http')
861
- || !BASE64URL_32.test(workspace.fingerprint)
862
- || (workspace.transport === 'https'
863
- ? (typeof workspace.certPem !== 'string' || !workspace.certPem.includes('BEGIN CERTIFICATE'))
864
- : (workspace.certPem !== undefined && typeof workspace.certPem !== 'string'))
865
- || !BASE64URL_32.test(workspace.token) || !isIsoDate(workspace.addedAt)
866
- || (workspace.hostname !== undefined && (typeof workspace.hostname !== 'string' || !workspace.hostname.trim() || workspace.hostname.length > 128 || /[\0\r\n]/.test(workspace.hostname)))
867
- || (workspace.platform !== undefined && (typeof workspace.platform !== 'string' || !workspace.platform.trim() || workspace.platform.length > 64 || /[\0\r\n]/.test(workspace.platform)))
868
- || (workspace.version !== undefined && (typeof workspace.version !== 'string' || !workspace.version.trim() || workspace.version.length > 64 || /[\0\r\n]/.test(workspace.version))))
869
- throw new Error('Invalid paired remote workspace');
870
- ids.add(workspace.id);
871
- }
980
+ }
981
+ export function validateEnvironmentsConfig(environments) {
982
+ const e = environments;
983
+ if (!e || typeof e !== 'object' || Array.isArray(e) || Object.keys(e).some(key => key !== 'modelRelay'))
984
+ throw new Error('Invalid environments configuration');
985
+ if (e.modelRelay === undefined)
986
+ return;
987
+ // The earlier list shape is read as nothing allowed; it is still a valid file.
988
+ if (Array.isArray(e.modelRelay)) {
989
+ if (e.modelRelay.length > MODEL_RELAY_ALLOWED_LIMIT || e.modelRelay.some(id => typeof id !== 'string'))
990
+ throw new Error('environments.modelRelay must map accounts to at most 64 environment ids');
991
+ return;
872
992
  }
993
+ const byAccount = e.modelRelay;
994
+ if (!byAccount || typeof byAccount !== 'object' || Object.keys(byAccount).length > MODEL_RELAY_ACCOUNT_LIMIT
995
+ || Object.entries(byAccount).some(([subject, ids]) => !ACCOUNT_SUBJECT.test(subject) || !Array.isArray(ids) || ids.length > MODEL_RELAY_ALLOWED_LIMIT
996
+ || ids.some(id => typeof id !== 'string' || !ENVIRONMENT_ID.test(id))))
997
+ throw new Error('environments.modelRelay must map accounts to at most 64 environment ids');
873
998
  }
874
999
  export function validateProjectsConfig(projects) {
875
1000
  if (!Array.isArray(projects) || projects.length > 256)
@@ -2,6 +2,7 @@ import { engineModel } from './engine/protocol.js';
2
2
  import { generateWithUsage } from './runtime.js';
3
3
  import { selectCompactGroups } from '../vendor/zcode/source/compact/selection.js';
4
4
  import { serializeContext } from './context-budget.js';
5
+ import { pickCompactionPhrase } from './compaction-phrases.js';
5
6
  export const EFFICIENT_CONTEXT_POLICY = { triggerChars: 128_000, targetChars: 64_000, keepRecentToolTurns: 8, protectDiscovery: true };
6
7
  function completeExchanges(messages) {
7
8
  const exchanges = [];
@@ -248,7 +249,7 @@ export class HistoryCompactor {
248
249
  let batchTarget = targetChars;
249
250
  let batchMaxTokens = maxTokens;
250
251
  await options.onEvent?.({ type: 'agent.context.compaction.started', time: new Date().toISOString(), data: {
251
- runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber,
252
+ runId: result.id, nodeId: options.nodeId ?? 'engineer', ...(options.subagentId ? { subagentId: options.subagentId } : {}), maxTokens: batchMaxTokens, batch: batchNumber, text: pickCompactionPhrase(),
252
253
  } });
253
254
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
254
255
  signal.throwIfAborted();
@@ -84,8 +84,20 @@ export function createRuntimeBudget(callerSignal, wallTimeMs, control) {
84
84
  resume = undefined;
85
85
  }
86
86
  };
87
- unsubscribe = control.onChange(changed);
87
+ const unsubscribePause = control.onChange(changed);
88
88
  changed(control.isPaused);
89
+ let resumeHold;
90
+ const held = (holding) => {
91
+ if (holding)
92
+ resumeHold ??= budget.suspend();
93
+ else {
94
+ resumeHold?.();
95
+ resumeHold = undefined;
96
+ }
97
+ };
98
+ const unsubscribeHold = control.onBudgetHold(held);
99
+ held(control.budgetsHeld);
100
+ unsubscribe = () => { unsubscribePause(); unsubscribeHold(); };
89
101
  }
90
102
  return budget;
91
103
  }
@@ -10,6 +10,7 @@ import { HOSTED_SKILL_LIMIT, hostedSkillLimitNotice, rankHostedSkills } from './
10
10
  import { markFactGuidance } from './guidancePolicy.js';
11
11
  import { actionablePreflightQuestion, answerOnlyTask } from './optimizationPolicy.js';
12
12
  import { parseToolRouteEvidence } from './routeTools.js';
13
+ import { pickJevRequestPhrase } from './requestPhrases.js';
13
14
  const FACT_TIMEOUT_MS = 2000;
14
15
  const families = new Set(['filesystem-read', 'filesystem-write', 'code-search', 'codegraph', 'git', 'shell', 'memory', 'web', 'browser', 'subagents', 'artifact']);
15
16
  export const toolFamilyQuestion = (family) => `tool_family_${family.replace(/-/g, '_')}`;
@@ -173,7 +174,7 @@ export class DecisionManager {
173
174
  };
174
175
  const evaluateFact = this.provider.evaluateFact?.bind(this.provider);
175
176
  if (!evaluateFact) {
176
- emit('decision.requested', { questions: [request.id] });
177
+ emit('decision.requested', { questions: [request.id], text: pickJevRequestPhrase() });
177
178
  emit('decision.fallback', { reason: 'provider_unavailable' });
178
179
  return undefined;
179
180
  }
@@ -229,7 +230,7 @@ export class DecisionManager {
229
230
  return this.settle(questions.map(q => q.id), (controllerSignal, deadlineAt) => this.provider.evaluate(structuredClone(snapshot), structuredClone(questions), controllerSignal, this.observer(emit), { deadlineAt }), value => validateBatch(value, questions), batch => Object.fromEntries(Object.entries(batch).map(([id, r]) => [id, r.type === 'noul' ? { probability: r.probability } : r.type === 'score' ? { score: r.score, confidence: r.confidence } : { ...(id === 'verification_tier' ? { choice: r.choice } : {}), confidence: r.confidence, selected: r.probabilities[r.choice] ?? 0 }])), signal, emit, this.config.requestTimeoutMs ?? DECISION_DEFAULTS.requestTimeoutMs);
230
231
  }
231
232
  async settle(questionIds, evaluate, validate, describe, signal, emit, timeoutMs) {
232
- emit('decision.requested', { questions: questionIds });
233
+ emit('decision.requested', { questions: questionIds, text: pickJevRequestPhrase() });
233
234
  if (this.config.mode === 'active' && !this.active) {
234
235
  emit('decision.fallback', { reason: 'active_unsupported' });
235
236
  return undefined;
@@ -197,7 +197,7 @@ export function replayableTestRun(line) {
197
197
  const source = line.trim().replace(/^cd\s+"?\$\(pwd\)"?\s*&&\s*/, '');
198
198
  if (!source || MUTATING_FLAG.test(source) || source.includes('<<'))
199
199
  return undefined;
200
- const masked = source.replace(/'[^']*'/g, quoted => `'${'_'.repeat(quoted.length - 2)}'`).replace(/"(?:[^"\$`]|\.)*"/g, quoted => `"${'_'.repeat(quoted.length - 2)}"`);
200
+ const masked = source.replace(/'[^']*'/g, quoted => `'${'_'.repeat(quoted.length - 2)}'`).replace(/"[^"$`]*"/g, quoted => `"${'_'.repeat(quoted.length - 2)}"`);
201
201
  let cut = -1;
202
202
  for (let index = 0; index < masked.length; index++) {
203
203
  if (masked[index] !== '|')
@@ -0,0 +1,4 @@
1
+ export declare const JEV_DEFAULT_REQUEST_PHRASE = "Evaluating context needs";
2
+ export declare const JEV_REQUEST_PHRASES: readonly string[];
3
+ export declare function pickJevRequestPhrase(random?: () => number): string;
4
+ export declare function jevRequestPhrase(text: unknown): string;
@@ -0,0 +1,22 @@
1
+ // What the transcript says while a Jev request is in flight. The engine picks one per request and
2
+ // carries it on `decision.requested` as `text`, so the CLI and the desktop show the same line.
3
+ export const JEV_DEFAULT_REQUEST_PHRASE = 'Evaluating context needs';
4
+ export const JEV_REQUEST_PHRASES = [
5
+ 'Asking the tokens to carpool',
6
+ 'Clipping coupons for your context',
7
+ 'Checking which tokens spark joy',
8
+ 'Haggling with the token meter',
9
+ 'Teaching the prompt to travel light',
10
+ 'Bargain-hunting for bytes',
11
+ "Shrinking the bill before it's printed",
12
+ 'Leaving the extra tokens at home',
13
+ 'Sending unnecessary tokens home',
14
+ ];
15
+ export function pickJevRequestPhrase(random = Math.random) {
16
+ const index = Math.floor(random() * JEV_REQUEST_PHRASES.length);
17
+ return JEV_REQUEST_PHRASES[Math.min(Math.max(index, 0), JEV_REQUEST_PHRASES.length - 1)] ?? JEV_DEFAULT_REQUEST_PHRASE;
18
+ }
19
+ // Only a phrase from the list is shown; anything else on the event falls back to the default line.
20
+ export function jevRequestPhrase(text) {
21
+ return typeof text === 'string' && JEV_REQUEST_PHRASES.includes(text) ? text : JEV_DEFAULT_REQUEST_PHRASE;
22
+ }
@@ -2,7 +2,7 @@ export const DEFAULT_AGENT_GRAPH = {
2
2
  name: 'Andorra Agent', entry: 'engineer',
3
3
  nodes: {
4
4
  engineer: { id: 'engineer', name: 'Andorra Agent', type: 'agent', executor: 'react-basic',
5
- instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. If no pull request was created or its number is unknown, say so rather than guessing. Start new implementation work only when the user requests it.',
5
+ instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. Never guess a pull request number. Mention pull requests in the report only when the task asked for one or one was opened; a pull request nobody asked for is not unfinished work. Start new implementation work only when the user requests it.',
6
6
  contextPolicy: { history: true }, jevEnabled: true,
7
7
  subagents: { enabled: false }, position: { x: 120, y: 120 } },
8
8
  done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
@@ -5,6 +5,8 @@ export interface FileDiffLine {
5
5
  newLine?: number;
6
6
  noNewline?: true;
7
7
  clipped?: true;
8
+ /** Set on a file the person also edited (`change-authors.ts`): who added or removed the line. */
9
+ author?: 'agent' | 'user';
8
10
  }
9
11
  export interface FileDiffHunk {
10
12
  oldStart: number;
@@ -19,6 +21,8 @@ export interface FileDiff {
19
21
  linesRemoved: number;
20
22
  hiddenLines: number;
21
23
  coarse?: true;
24
+ /** The line matcher gave up (too many edits, or too slow), so the middle is shown as all removed, then all added. */
25
+ approximate?: true;
22
26
  }
23
27
  export type DiffSide = Buffer | string | null;
24
28
  export type FileDiffResult = {
@@ -74,6 +74,7 @@ export function textDiff(oldText, newText, options = {}) {
74
74
  let changes = midA.length && midB.length
75
75
  ? diffArrays(midA, midB, { timeout: MATCH_TIMEOUT_MS, maxEditLength: MATCH_EDIT_LIMIT })
76
76
  : undefined;
77
+ const approximate = changes === undefined && midA.length > 0 && midB.length > 0;
77
78
  changes ??= [
78
79
  ...(midA.length ? [{ value: midA, added: false, removed: true }] : []),
79
80
  ...(midB.length ? [{ value: midB, added: true, removed: false }] : []),
@@ -179,7 +180,7 @@ export function textDiff(oldText, newText, options = {}) {
179
180
  if (lines.length)
180
181
  hunks.push({ oldStart, oldLines, newStart, newLines, lines });
181
182
  }
182
- return { hunks, linesAdded, linesRemoved, hiddenLines: hidden };
183
+ return { hunks, linesAdded, linesRemoved, hiddenLines: hidden, ...(approximate ? { approximate: true } : {}) };
183
184
  }
184
185
  export function coarseCounts(oldText, newText) {
185
186
  if (oldText === newText)
@@ -0,0 +1,102 @@
1
+ import type { GhRunner, SessionPullRequest } from '../pull-requests.js';
2
+ import { type BotWriteAction, type BotWriteFallback, type GitHubAppClient, type GitHubCoverage } from './client.js';
3
+ /**
4
+ * The agent's writes on its session's pull request (`design/specs/github-app.md`, "Bot replies"): a reply to a
5
+ * review thread, resolving or reopening one, and a comment on the PR's conversation. On a PR the GitHub App
6
+ * covers, with agent writes set to the bot, the account API makes the write as the App's bot; the engine never
7
+ * holds the installation token that does it. Otherwise, and whenever the service says it wrote nothing, the
8
+ * write goes through gh as the account the session's PR record names, and never as another account. A write
9
+ * whose fate is unknown is never repeated through gh.
10
+ */
11
+ /** `github.app.agentWrites`: who the agent's PR writes post as. */
12
+ export type AgentWritesSetting = 'bot' | 'me';
13
+ export type AgentPullRequestWrite = {
14
+ action: 'reply';
15
+ threadId: string;
16
+ body: string;
17
+ } | {
18
+ action: 'resolve';
19
+ threadId: string;
20
+ resolved: boolean;
21
+ } | {
22
+ action: 'comment';
23
+ body: string;
24
+ };
25
+ /** A thread the agent named that is not on its session's PR: refused before anything was written. */
26
+ export declare class ThreadElsewhere extends Error {
27
+ }
28
+ /**
29
+ * The person's own pending review on the PR: GitHub files a reply made through gh into it, where nobody sees it
30
+ * until the person submits the review. Refused before anything is written.
31
+ */
32
+ export declare class PendingReview extends Error {
33
+ }
34
+ export declare const AGENT_WRITE_ACTIONS: readonly ["reply", "resolve", "comment"];
35
+ /** A ULID: 48 bits of milliseconds, then 80 random bits, in Crockford's base 32. */
36
+ export declare function newRequestId(now?: number, random?: Uint8Array): string;
37
+ /** The write the pull_request tool's `reply`, `resolve` or `comment` asks for, checked before anything is approved or sent. */
38
+ export declare function agentWriteFromArgs(args: Record<string, unknown>): AgentPullRequestWrite;
39
+ export declare const botAction: (write: AgentPullRequestWrite) => BotWriteAction;
40
+ /** Why a write went through gh without asking the service: the PR's coverage, or the person's setting. */
41
+ export declare function coverageReason(coverage: GitHubCoverage, pullRequest: SessionPullRequest): string;
42
+ /** Why the service wrote nothing, in the words the tool result uses. */
43
+ export declare function fallbackReason(reason: BotWriteFallback, pullRequest: SessionPullRequest): string;
44
+ export declare const AS_ME_REASON = "agent replies on pull requests are set to post as you";
45
+ export interface AgentWriteResult {
46
+ /** The tool result: who posted (or may have) and why. */
47
+ text: string;
48
+ /** `pending`: filed into the person's pending review, not visible yet. `unknown`: it may have been written. */
49
+ by: 'bot' | 'gh' | 'pending' | 'unknown';
50
+ as?: string;
51
+ url?: string;
52
+ /** The new comment's GraphQL node id, when GitHub's answer named it (the gh route's reply and comment). */
53
+ nodeId?: string;
54
+ /** Why it went through gh. */
55
+ reason?: string;
56
+ requestId?: string;
57
+ }
58
+ export interface AgentWriteOptions {
59
+ pullRequest: SessionPullRequest;
60
+ write: AgentPullRequestWrite;
61
+ setting: AgentWritesSetting;
62
+ /** The PR's coverage, as the event source last learned it. Only `covered` and `permissions-pending` ask the service. */
63
+ coverage: GitHubCoverage;
64
+ client: Pick<GitHubAppClient, 'write'>;
65
+ gh: GhRunner;
66
+ /**
67
+ * Asked once the route is known and the write passes its checks, before anything is sent anywhere, with who
68
+ * the write posts as (see `approvalDetail`). A fallback to gh after the bot wrote nothing is not asked again.
69
+ */
70
+ approve(detail: string): Promise<void>;
71
+ /** The bot's login, for the approval (`GET /v1/github`'s `bot`); unknown, "the Andorra Code bot". */
72
+ botName?: string;
73
+ /**
74
+ * Reads the PR record, the setting and the coverage again once the approval is given: a write whose PR, account
75
+ * or route changed while the person was asked is refused, so it never goes where the approval did not say.
76
+ */
77
+ current?(): Promise<{
78
+ pullRequest: SessionPullRequest;
79
+ setting: AgentWritesSetting;
80
+ coverage: GitHubCoverage;
81
+ } | undefined>;
82
+ signal?: AbortSignal;
83
+ requestId?: () => string;
84
+ }
85
+ export declare const CHANGED_WHILE_APPROVING = "The pull request or reply setting changed while awaiting approval; retry.";
86
+ /**
87
+ * What the approval says the write does and who it posts as: the bot first and the PR record's account if the
88
+ * bot cannot, or the account alone. One approval covers both, so a fallback is never asked about again.
89
+ */
90
+ export declare function approvalDetail(write: AgentPullRequestWrite, pullRequest: SessionPullRequest, bot: boolean, botName?: string): string;
91
+ /**
92
+ * Whether an agent write goes to the service first: agent writes set to the bot, and the PR covered (or
93
+ * `permissions-pending`, where the service decides per action). The Auto-fix prompt uses the same rule, so
94
+ * the prompt and the tool agree on who the replies post as.
95
+ */
96
+ export declare const asksBot: (setting: AgentWritesSetting, coverage: GitHubCoverage) => boolean;
97
+ /**
98
+ * Carries out one agent write on the session's tracked PR. Throws for a write that must not fall back (the
99
+ * service refused it as malformed, or the thread is not on this PR), for one the person's pending review would
100
+ * swallow, and for a gh write that certainly failed; answers the tool result otherwise.
101
+ */
102
+ export declare function performAgentWrite(options: AgentWriteOptions): Promise<AgentWriteResult>;