@andorra-labs/code 0.1.9 → 0.1.10

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 (96) hide show
  1. package/dist/src/agent-execution.js +20 -0
  2. package/dist/src/app-server/protocol.d.ts +108 -1
  3. package/dist/src/app-server/protocol.js +8 -1
  4. package/dist/src/app-server.d.ts +25 -0
  5. package/dist/src/app-server.js +156 -11
  6. package/dist/src/auth/index.d.ts +1 -1
  7. package/dist/src/auth/index.js +1 -1
  8. package/dist/src/auth/store.d.ts +17 -1
  9. package/dist/src/auth/store.js +25 -2
  10. package/dist/src/browser-ui/app.js +19 -19
  11. package/dist/src/browser-ui/index.html +7 -7
  12. package/dist/src/cli.js +10 -5
  13. package/dist/src/commands.d.ts +1 -1
  14. package/dist/src/commands.js +1 -1
  15. package/dist/src/completion-gates.js +1 -1
  16. package/dist/src/completion.d.ts +1 -1
  17. package/dist/src/completion.js +1 -1
  18. package/dist/src/decision/checks.js +1 -1
  19. package/dist/src/file-diff.d.ts +105 -0
  20. package/dist/src/file-diff.js +244 -0
  21. package/dist/src/graph-manager-chat.js +15 -15
  22. package/dist/src/graph-server.js +9 -9
  23. package/dist/src/graph-ui/app.js +123 -118
  24. package/dist/src/graph-ui/embed.js +9 -9
  25. package/dist/src/graph-ui/icons.js +1 -0
  26. package/dist/src/graph-ui/index.html +3 -3
  27. package/dist/src/graph-ui/manager-state.js +3 -3
  28. package/dist/src/graph-ui/manager.js +14 -14
  29. package/dist/src/graph-ui/skill-picker.js +6 -6
  30. package/dist/src/graph-ui/studio-canvas.js +15 -15
  31. package/dist/src/graph-ui/studio.js +40 -40
  32. package/dist/src/graph-ui/style.css +3 -1
  33. package/dist/src/graph-ui/theme.js +2 -2
  34. package/dist/src/graphs.d.ts +7 -1
  35. package/dist/src/graphs.js +12 -2
  36. package/dist/src/mcp.d.ts +75 -0
  37. package/dist/src/mcp.js +240 -8
  38. package/dist/src/membership-errors.js +1 -1
  39. package/dist/src/provider-keys.d.ts +5 -1
  40. package/dist/src/provider-keys.js +7 -3
  41. package/dist/src/provider-settings.d.ts +4 -1
  42. package/dist/src/provider-settings.js +46 -5
  43. package/dist/src/qa/guidance.js +6 -19
  44. package/dist/src/qa/index.d.ts +0 -2
  45. package/dist/src/qa/index.js +0 -2
  46. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  47. package/dist/src/qa/profile/QaProfile.js +6 -2
  48. package/dist/src/qa/tools.d.ts +19 -1
  49. package/dist/src/qa/tools.js +20 -145
  50. package/dist/src/react-runtime.js +13 -2
  51. package/dist/src/remote/engine-pool.js +18 -6
  52. package/dist/src/screen-selection.d.ts +38 -0
  53. package/dist/src/screen-selection.js +103 -0
  54. package/dist/src/session-changes.d.ts +117 -0
  55. package/dist/src/session-changes.js +796 -0
  56. package/dist/src/stall-recovery.d.ts +11 -0
  57. package/dist/src/stall-recovery.js +12 -0
  58. package/dist/src/telemetry/schema.d.ts +1 -1
  59. package/dist/src/telemetry/schema.js +1 -2
  60. package/dist/src/terminal-ui.d.ts +64 -20
  61. package/dist/src/terminal-ui.js +310 -80
  62. package/dist/src/tool-diff-stats.d.ts +9 -0
  63. package/dist/src/tool-diff-stats.js +20 -0
  64. package/dist/src/tool-names.d.ts +1 -1
  65. package/dist/src/tool-result-filter.js +1 -1
  66. package/dist/src/tools.js +26 -2
  67. package/dist/src/transcript.d.ts +11 -0
  68. package/dist/src/transcript.js +14 -2
  69. package/dist/src/types.d.ts +6 -0
  70. package/docs/guides/desktop-app.md +1 -1
  71. package/docs/guides/tui.md +9 -9
  72. package/package.json +1 -1
  73. package/dist/src/qa/api/http-runner.d.ts +0 -3
  74. package/dist/src/qa/api/http-runner.js +0 -47
  75. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  76. package/dist/src/qa/git/ChangeDetector.js +0 -177
  77. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  78. package/dist/src/qa/git/DiffReviewer.js +0 -115
  79. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  80. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  81. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  82. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  83. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  84. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  85. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  86. package/dist/src/qa/runners/CommandRunner.js +0 -96
  87. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  88. package/dist/src/qa/runners/TestRunner.js +0 -66
  89. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  90. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  91. package/dist/src/qa/runtime-detect.d.ts +0 -10
  92. package/dist/src/qa/runtime-detect.js +0 -72
  93. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  94. package/dist/src/qa/security/DependencyScanner.js +0 -167
  95. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  96. package/dist/src/qa/security/SecretScanner.js +0 -55
package/dist/src/mcp.js CHANGED
@@ -2,7 +2,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
2
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
3
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
4
  import { createHash, randomUUID } from 'node:crypto';
5
- import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
5
+ import { mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
6
6
  import { join } from 'node:path';
7
7
  import { authorize } from './tools.js';
8
8
  import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
@@ -132,6 +132,238 @@ function checkCatalogTool(id, tool, seen) {
132
132
  throw new Error('MCP tool metadata exceeds limits');
133
133
  seen.add(mcpToolName(id, tool.name));
134
134
  }
135
+ /**
136
+ * The transport one configured server is reached over.
137
+ *
138
+ * The SDK adds its minimal default environment; only the explicitly configured entries are passed,
139
+ * so unrelated provider and cloud credentials never reach an MCP process. `${NAME}` references in
140
+ * the environment and headers are expanded from this process's environment (and `${PLUGIN_ROOT}`
141
+ * from the plugin that declared the server); a reference that is not set throws.
142
+ */
143
+ function mcpTransport(config, workspace, overflow) {
144
+ const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
145
+ throw new Error(MISSING_REFERENCE); return value; });
146
+ const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, overflow) });
147
+ if (transport instanceof StdioClientTransport)
148
+ transport.stderr?.on('data', () => { });
149
+ return transport;
150
+ }
151
+ const MISSING_REFERENCE = 'Missing MCP environment reference';
152
+ /**
153
+ * A server definition as an edit form sent it, applied over the saved one.
154
+ *
155
+ * Environment values and header values are secrets the engine never returns, so the form cannot
156
+ * send them back: an entry whose value is `null` keeps the saved value of that name, an entry with
157
+ * a string is the new value, and a name the edit leaves out is removed. An endpoint sent without
158
+ * the query string the saved one carries (the form is shown it without, since a query can hold a
159
+ * credential) keeps the saved endpoint. The transport may change; whether the server is enabled
160
+ * does not — the switch beside it does that.
161
+ */
162
+ export function mergeMcpEdit(saved, edit) {
163
+ if (!edit || typeof edit !== 'object' || Array.isArray(edit))
164
+ throw new Error('Invalid MCP server');
165
+ const draft = edit;
166
+ const keep = (values, previous, what) => {
167
+ if (values === undefined)
168
+ return undefined;
169
+ if (!values || typeof values !== 'object' || Array.isArray(values))
170
+ throw new Error(`Invalid MCP ${what}`);
171
+ const merged = {};
172
+ for (const [key, value] of Object.entries(values)) {
173
+ if (value === null) {
174
+ if (previous === undefined || !Object.prototype.hasOwnProperty.call(previous, key))
175
+ throw new Error(`MCP ${what} ${key} has no saved value to keep`);
176
+ merged[key] = previous[key];
177
+ }
178
+ else
179
+ merged[key] = value;
180
+ }
181
+ return Object.keys(merged).length > 0 ? merged : undefined;
182
+ };
183
+ const enabled = saved.enabled === undefined ? {} : { enabled: saved.enabled };
184
+ if (draft.transport === 'stdio') {
185
+ const env = keep(draft.env, saved.transport === 'stdio' ? saved.env : undefined, 'environment variable');
186
+ return validateMcpServer({ transport: 'stdio', command: draft.command, ...(draft.args === undefined ? {} : { args: draft.args }), ...(env === undefined ? {} : { env }), ...enabled });
187
+ }
188
+ if (draft.transport === 'http') {
189
+ const headers = keep(draft.headers, saved.transport === 'http' ? saved.headers : undefined, 'header');
190
+ let url = draft.url;
191
+ if (saved.transport === 'http' && typeof url === 'string') {
192
+ try {
193
+ const bare = new URL(saved.url);
194
+ bare.search = '';
195
+ if (new URL(url).href === bare.href)
196
+ url = saved.url;
197
+ }
198
+ catch { /* An endpoint that does not parse is refused by the validation below. */ }
199
+ }
200
+ return validateMcpServer({ transport: 'http', url, ...(headers === undefined ? {} : { headers }), ...enabled });
201
+ }
202
+ throw new Error('MCP transport must be stdio or http');
203
+ }
204
+ /**
205
+ * A reporter that records what a task's connections answered. A task names a server from the
206
+ * configuration `configured:<id>` (the extension snapshot's namespace, apart from plugins' servers),
207
+ * and the record is filed under the configuration's own id, which is what the settings page lists.
208
+ */
209
+ export function mcpTaskStatusReporter(directory) {
210
+ const store = mcpStatusStore(directory);
211
+ return (id, config, result) => {
212
+ const configured = id.startsWith('configured:') ? id.slice('configured:'.length) : id;
213
+ void store.record(configured, config, result, 'task').catch(() => { });
214
+ };
215
+ }
216
+ /**
217
+ * The identity of a server's definition — command, arguments, environment, address, headers — and
218
+ * not whether it is turned on, so a status survives the switch but not an edit. Credentials in the
219
+ * definition only enter the digest.
220
+ */
221
+ export function mcpDefinitionKey(config) {
222
+ const { enabled: _enabled, ...definition } = config;
223
+ return createHash('sha256').update(canonical(definition)).digest('hex');
224
+ }
225
+ /** Status records are small; a file past this was not written here and is not read. */
226
+ const MCP_STATUS_FILE_MAX_BYTES = 16_000;
227
+ /**
228
+ * The last thing each server answered, one small file per server under the configuration home, so a
229
+ * settings page can show it without starting anything. A task's connection writes it, and so does an
230
+ * explicit check (`mcp.status`); one file per server keeps two processes recording at once from
231
+ * overwriting each other's servers. Every failure to read reads as "not checked".
232
+ */
233
+ export function mcpStatusStore(directory) {
234
+ const root = join(directory, 'mcp-status');
235
+ const file = (id) => join(root, `${createHash('sha256').update(id).digest('hex')}.json`);
236
+ return {
237
+ async list() {
238
+ let names;
239
+ try {
240
+ names = await readdir(root);
241
+ }
242
+ catch {
243
+ return [];
244
+ }
245
+ const records = [];
246
+ for (const name of names.filter(entry => /^[a-f0-9]{64}\.json$/.test(entry)).slice(0, 1000)) {
247
+ try {
248
+ const raw = await readFile(join(root, name), 'utf8');
249
+ if (raw.length > MCP_STATUS_FILE_MAX_BYTES)
250
+ continue;
251
+ const parsed = JSON.parse(raw);
252
+ if (parsed.version !== 1 || typeof parsed.id !== 'string' || typeof parsed.definition !== 'string' || typeof parsed.checkedAt !== 'string'
253
+ || (parsed.state !== 'ready' && parsed.state !== 'failed') || (parsed.source !== 'task' && parsed.source !== 'check'))
254
+ continue;
255
+ records.push({
256
+ id: parsed.id, definition: parsed.definition, state: parsed.state, checkedAt: parsed.checkedAt, source: parsed.source,
257
+ ...(typeof parsed.tools === 'number' ? { tools: parsed.tools } : {}),
258
+ ...(typeof parsed.error === 'string' ? { error: parsed.error } : {}),
259
+ });
260
+ }
261
+ catch { /* An unreadable record is a server not checked. */ }
262
+ }
263
+ return records;
264
+ },
265
+ async record(id, config, result, source, at = new Date()) {
266
+ const record = {
267
+ id, definition: mcpDefinitionKey(config), state: result.state, checkedAt: at.toISOString(), source,
268
+ ...(result.state === 'ready' ? { tools: result.tools } : { error: result.error }),
269
+ };
270
+ const target = file(id);
271
+ const staging = `${target}.${process.pid}.${randomUUID()}.tmp`;
272
+ try {
273
+ await mkdir(root, { recursive: true });
274
+ await writeFile(staging, `${JSON.stringify({ version: 1, ...record })}\n`, { mode: 0o600 });
275
+ await rename(staging, target);
276
+ }
277
+ catch (error) {
278
+ await rm(staging, { force: true }).catch(() => { });
279
+ throw error;
280
+ }
281
+ return record;
282
+ },
283
+ };
284
+ }
285
+ /**
286
+ * Start one configured server, list its tools, and stop it again: the check a person asks for from
287
+ * the settings page ("Check Connection"), never one a page makes on its own — a task asks before it
288
+ * connects a server, and opening a page is not that consent.
289
+ *
290
+ * Nothing is kept. The catalog is only counted, and the client — with the process it started, for a
291
+ * stdio server — is closed before this returns, whatever happened. A probe is bounded in time as a
292
+ * task's connection is: 15 seconds to connect, 15 per page of tools, 30 in all.
293
+ */
294
+ export async function probeMcpServer(config, workspace, signal) {
295
+ const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
296
+ const limit = AbortSignal.timeout(30_000);
297
+ const probeSignal = signal === undefined ? limit : AbortSignal.any([signal, limit]);
298
+ let http;
299
+ try {
300
+ validateMcpServer(config);
301
+ const transport = mcpTransport(config, workspace, () => { void client.close().catch(() => { }); });
302
+ if (transport instanceof StreamableHTTPClientTransport)
303
+ http = transport;
304
+ await client.connect(transport, { signal: probeSignal, timeout: 15_000 });
305
+ let tools = 0;
306
+ const cursors = new Set();
307
+ let cursor;
308
+ let pages = 0;
309
+ do {
310
+ if (++pages > 100)
311
+ throw new Error('MCP catalog exceeded the 100-page limit');
312
+ const page = await client.listTools({ cursor }, { signal: probeSignal, timeout: 15_000 });
313
+ tools += page.tools.length;
314
+ cursor = page.nextCursor;
315
+ if (cursor && cursors.has(cursor))
316
+ throw new Error('MCP catalog repeated a cursor');
317
+ if (cursor)
318
+ cursors.add(cursor);
319
+ } while (cursor);
320
+ return { state: 'ready', tools };
321
+ }
322
+ catch (error) {
323
+ return { state: 'failed', error: probeFailureReason(error, config) };
324
+ }
325
+ finally {
326
+ try {
327
+ await http?.terminateSession();
328
+ }
329
+ catch { }
330
+ await client.close().catch(() => { });
331
+ }
332
+ }
333
+ /**
334
+ * Why a probe failed, in words a person can act on.
335
+ *
336
+ * A transport error can carry what the server sent back, and an HTTP one can echo the request's own
337
+ * headers, so the message itself is never passed on: the error is sorted into a known kind, and only
338
+ * the facts that are the configuration's own (its command) or the protocol's (a status code) are named.
339
+ */
340
+ export function probeFailureReason(error, config) {
341
+ const message = error instanceof Error ? error.message : String(error);
342
+ const name = error instanceof Error ? error.name : '';
343
+ const code = error?.code ?? error?.cause?.code;
344
+ if (message === MISSING_REFERENCE)
345
+ return 'An environment variable its settings refer to is not set.';
346
+ if (message.startsWith('Invalid MCP') || message.startsWith('MCP requires') || message.startsWith('MCP transport'))
347
+ return 'Its settings are not valid.';
348
+ if (config.transport === 'stdio' && (code === 'ENOENT' || /\bENOENT\b/.test(message)))
349
+ return `Command not found: ${config.command ?? 'the configured command'}.`;
350
+ if (config.transport === 'stdio' && (code === 'EACCES' || /\bEACCES\b/.test(message)))
351
+ return `Not allowed to run ${config.command ?? 'the configured command'}.`;
352
+ if (name === 'TimeoutError' || /timed? ?out/i.test(message) || code === -32001)
353
+ return 'It did not answer in time.';
354
+ const status = /\(HTTP (\d{3})\)/.exec(message)?.[1];
355
+ if (status === '401' || status === '403')
356
+ return `Not authorized (HTTP ${status}). Check its headers.`;
357
+ if (status !== undefined)
358
+ return `The server answered HTTP ${status}.`;
359
+ if (typeof code === 'string' && /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ECONNRESET|ETIMEDOUT|EHOSTUNREACH)$/.test(code))
360
+ return 'Could not reach the server.';
361
+ if (/connection closed/i.test(message))
362
+ return 'The server stopped before it answered.';
363
+ if (message === 'MCP response exceeds 1 MiB transport limit')
364
+ return 'Its answer was larger than 1 MiB.';
365
+ return 'Could not connect or list its tools. Check its command and authentication.';
366
+ }
135
367
  const OVER_BUDGET = 'MCP catalog exceeds task metadata budget';
136
368
  // Transport errors can contain server-provided strings or auth headers: report a bounded, non-secret status.
137
369
  const unavailableReason = (error) => error instanceof Error && error.message === 'Permission denied' ? 'connection permission denied'
@@ -214,14 +446,8 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
214
446
  const connectServer = async (id, config, accept) => {
215
447
  const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
216
448
  try {
217
- const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
218
- throw new Error('Missing MCP environment reference'); return value; });
219
449
  startupSignal.throwIfAborted();
220
- // The SDK adds its minimal default environment; pass only explicitly configured
221
- // entries so unrelated provider/cloud credentials never reach MCP processes.
222
- const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: context.workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, () => { void client.close().catch(() => { }); }) });
223
- if (transport instanceof StdioClientTransport)
224
- transport.stderr?.on('data', () => { });
450
+ const transport = mcpTransport(config, context.workspace, () => { void client.close().catch(() => { }); });
225
451
  clients.set(client, transport instanceof StreamableHTTPClientTransport ? transport : undefined);
226
452
  await client.connect(transport, { signal: startupSignal, timeout: 15_000 });
227
453
  const discoverySignal = AbortSignal.any([startupSignal, AbortSignal.timeout(30_000)]);
@@ -374,6 +600,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
374
600
  });
375
601
  });
376
602
  background = connection.then(async (live) => {
603
+ options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
377
604
  // Key order inside a schema is the server's serializer's business, not a change of catalog.
378
605
  if (canonical(live.catalog) === canonical(known.catalog)) {
379
606
  notice(`MCP ${id}: ${known.catalog.length} tools available to agents with shell permission.`);
@@ -390,6 +617,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
390
617
  // A task that is ending says nothing about the server: its record stands.
391
618
  if (startupSignal.aborted)
392
619
  return;
620
+ options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
393
621
  // The next task asks the server before offering its tools, as for one never seen.
394
622
  await store.remove(key).catch(() => { });
395
623
  notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
@@ -434,6 +662,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
434
662
  }
435
663
  catalogBytes += limits.bytes;
436
664
  notice(`MCP ${id}: ${live.catalog.length} tools available to agents with shell permission.`);
665
+ options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
437
666
  // Remembered for the next task. An empty catalog offers nothing to wait for and is asked again.
438
667
  if (store && key !== undefined && live.catalog.length > 0)
439
668
  await store.write(key, { tools: live.catalog }).catch(() => { });
@@ -444,6 +673,9 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
444
673
  // next task is told the same thing without waiting for the server to say it again.
445
674
  if (store && key !== undefined && error instanceof Error && error.message === OVER_BUDGET)
446
675
  await store.write(key, { overBudget: true }).catch(() => { });
676
+ // A catalog refused for the task's budget came from a server that answered: that is not its status.
677
+ else
678
+ options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
447
679
  notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
448
680
  }
449
681
  }
@@ -1,4 +1,4 @@
1
- const FEATURES = 'the Andorra graph, custom graphs and the graph builder';
1
+ const FEATURES = 'the Andorra workflow, custom workflows and the Workflow Editor';
2
2
  const REASONS = {
3
3
  tls: 'a secure connection to the account service could not be verified',
4
4
  dns: 'the account service address could not be resolved',
@@ -41,7 +41,11 @@ export declare function storeProviderKeys(directory: string, keys: Map<string, s
41
41
  * them could not publish its configuration. Best-effort: the save's own failure is what is reported.
42
42
  */
43
43
  export declare function restoreProviderKeys(directory: string, providers: Iterable<string>, current: Map<string, string>): Promise<void>;
44
- /** Delete the keys a configuration directory saved for these providers. A machine without an OS store holds none. */
44
+ /**
45
+ * Delete the keys a configuration directory saved for these providers. A machine without an OS store
46
+ * holds none. A locked one this session cannot unlock still holds them, so its failure is reported and
47
+ * the keys stay pending deletion for a later save to retry.
48
+ */
45
49
  export declare function removeProviderKeys(directory: string, providers: Iterable<string>): Promise<void>;
46
50
  /** Whether saving should move plaintext keys out of `config.json` on this machine. */
47
51
  export declare function providerKeysBelongInKeyring(environment?: NodeJS.ProcessEnv): boolean;
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'node:path';
2
- import { credentialStoreMode, KeyringAbsentError, KeyringCredentialStore } from './auth/store.js';
2
+ import { credentialStoreMode, KeyringAbsentError, KeyringCredentialStore, KeyringUnreachableError } from './auth/store.js';
3
3
  /**
4
4
  * Saved provider API keys, kept in the OS credential store rather than in `config.json`.
5
5
  *
@@ -102,14 +102,18 @@ export async function restoreProviderKeys(directory, providers, current) {
102
102
  await (key === undefined ? vaultFor(directory, provider).remove() : vaultFor(directory, provider).write(key)).catch(() => { });
103
103
  }
104
104
  }
105
- /** Delete the keys a configuration directory saved for these providers. A machine without an OS store holds none. */
105
+ /**
106
+ * Delete the keys a configuration directory saved for these providers. A machine without an OS store
107
+ * holds none. A locked one this session cannot unlock still holds them, so its failure is reported and
108
+ * the keys stay pending deletion for a later save to retry.
109
+ */
106
110
  export async function removeProviderKeys(directory, providers) {
107
111
  for (const provider of new Set(providers)) {
108
112
  try {
109
113
  await vaultFor(directory, provider).remove();
110
114
  }
111
115
  catch (error) {
112
- if (error instanceof KeyringAbsentError)
116
+ if (error instanceof KeyringAbsentError && !(error instanceof KeyringUnreachableError))
113
117
  return;
114
118
  throw new Error('Unable to remove saved provider API keys from the OS credential store. Unlock it and retry.', { cause: error });
115
119
  }
@@ -1,8 +1,11 @@
1
1
  import type { CommandScreenUI } from './command-screens.js';
2
2
  import { type Config } from './config.js';
3
+ import { type ProviderConfig } from './providers.js';
3
4
  import { retireUnsavedCodexAccounts } from './codex-auth.js';
4
5
  import type { AnthropicConsoleAuth } from './anthropic-console-auth.js';
5
6
  type ConsoleAuth = Pick<AnthropicConsoleAuth, 'start' | 'status' | 'cancel'>;
7
+ /** Lists the model ids an endpoint offers with the draft's credentials, as a run would request them. */
8
+ type ModelLister = (provider: ProviderConfig, signal: AbortSignal) => Promise<string[] | undefined>;
6
9
  /** Provider edits remain isolated until the caller atomically persists the returned draft. */
7
- export declare function editProviderSettings(config: Config, id: string | undefined, ui: CommandScreenUI, signal: AbortSignal, login?: typeof import('./codex-auth.js').loginCodex, retire?: typeof retireUnsavedCodexAccounts, consoleAuth?: () => Promise<ConsoleAuth>): Promise<Config | undefined>;
10
+ export declare function editProviderSettings(config: Config, id: string | undefined, ui: CommandScreenUI, signal: AbortSignal, login?: typeof import('./codex-auth.js').loginCodex, retire?: typeof retireUnsavedCodexAccounts, consoleAuth?: () => Promise<ConsoleAuth>, discover?: ModelLister): Promise<Config | undefined>;
8
11
  export {};
@@ -8,20 +8,21 @@ import { ANTHROPIC_CONSOLE_BASE_URL, anthropicAccountHome } from './anthropic-cr
8
8
  import { GROK_BASE_URL } from './grok-provider.js';
9
9
  import { OPENCODE_BASE_URL } from './opencode-cli-provider.js';
10
10
  const defaultConsoleAuth = async () => new (await import('./anthropic-console-auth.js')).AnthropicConsoleAuth();
11
+ const defaultModelLister = async (provider, signal) => createAdapter(provider).listModels?.(signal);
11
12
  /** Provider edits remain isolated until the caller atomically persists the returned draft. */
12
- export async function editProviderSettings(config, id, ui, signal, login = async (options) => (await import('./codex-auth.js')).loginCodex(options), retire = retireUnsavedCodexAccounts, consoleAuth = defaultConsoleAuth) {
13
+ export async function editProviderSettings(config, id, ui, signal, login = async (options) => (await import('./codex-auth.js')).loginCodex(options), retire = retireUnsavedCodexAccounts, consoleAuth = defaultConsoleAuth, discover = defaultModelLister) {
13
14
  // Every exit that returns no draft abandons the edit, including one an abort or a failing prompt
14
15
  // raises: a login or account slot made while editing must not outlive an edit that was never saved.
15
16
  const abandon = {};
16
17
  try {
17
- return await editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon);
18
+ return await editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover);
18
19
  }
19
20
  catch (error) {
20
21
  await abandon.discard?.().catch(() => { });
21
22
  throw error;
22
23
  }
23
24
  }
24
- async function editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon) {
25
+ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover) {
25
26
  if (!ui.question)
26
27
  throw new Error('Provider settings require interactive input.');
27
28
  const draft = structuredClone(config);
@@ -239,7 +240,47 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
239
240
  candidate.baseUrl = value;
240
241
  }
241
242
  else if (field === 'model') {
242
- const value = await ask('Model ID (blank keeps current)');
243
+ // The picker offers what the endpoint lists next to the models already configured, and a row
244
+ // for typing an id: a listing that fails or is empty must never stop a person naming a model.
245
+ // Only read-only catalogs are consulted here; a ChatGPT sign-in stays behind its own row.
246
+ let listed = [];
247
+ let unavailable = false;
248
+ try {
249
+ const models = await ui.loadScreen('Available models', async (loadSignal) => {
250
+ if (isCodex)
251
+ return [];
252
+ if (isClaude)
253
+ return (await (await import('./claude-provider.js')).readClaudeCatalog(loadSignal)).models.map(id => ({ id }));
254
+ if (isGrok)
255
+ return (await (await import('./grok-provider.js')).readGrokCatalog(loadSignal)).models.map(id => ({ id }));
256
+ if (isOpenCode)
257
+ return (await (await import('./opencode-cli-provider.js')).readOpenCodeCatalog(loadSignal)).models.map(model => ({ id: model.id }));
258
+ return (await discover(candidate, loadSignal) ?? []).map(id => ({ id }));
259
+ }, { signal });
260
+ if (!models)
261
+ continue;
262
+ listed = models.filter(model => model.id.trim());
263
+ }
264
+ catch (error) {
265
+ if (signal.aborted)
266
+ throw error;
267
+ unavailable = true;
268
+ }
269
+ const rows = new Map();
270
+ const row = (model, recommended) => ({ id: `:use:${model}`, label: `${model}${model === candidate.model ? ' · active' : ''}${recommended ? ' (recommended)' : ''}` });
271
+ for (const model of providerModels(candidate))
272
+ rows.set(model, row(model));
273
+ for (const model of listed)
274
+ if (!rows.has(model.id))
275
+ rows.set(model.id, row(model.id, model.isDefault));
276
+ const recommended = listed.find(model => model.isDefault)?.id;
277
+ const preferred = candidate.model && rows.has(candidate.model) ? candidate.model : recommended;
278
+ const title = unavailable ? 'Active model (could not list available models)'
279
+ : !isCodex && !listed.length ? 'Active model (no models listed)' : 'Active model';
280
+ const choice = await choose(title, [...rows.values(), { id: ':custom', label: '+ Enter a custom model ID' }], preferred ? `:use:${preferred}` : undefined);
281
+ if (!choice)
282
+ continue;
283
+ const value = choice === ':custom' ? await ask('Model ID (blank cancels)') : choice.slice(5);
243
284
  if (!value)
244
285
  continue;
245
286
  if (value !== provider.model)
@@ -420,7 +461,7 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
420
461
  candidate.codexEmail = result.email;
421
462
  return result.models;
422
463
  }
423
- return (await createAdapter(candidate).listModels?.(loadSignal) ?? []).map(id => ({ id }));
464
+ return (await discover(candidate, loadSignal) ?? []).map(id => ({ id }));
424
465
  }, { signal });
425
466
  if (!models)
426
467
  continue;
@@ -12,14 +12,8 @@
12
12
  */
13
13
  /** The qa.* tools the guidance can name, in the order it names them. */
14
14
  const QA_TOOLS = [
15
- ['qa.fast', 'lint + typecheck + related tests + diff/secret review'],
16
- ['qa.test', 'scoped unit runs: related/file/pattern/all'],
17
15
  ['qa.terminal', 'persistent PTY/ConPTY CLI/TUI interaction'],
18
- ['qa.browser', ''],
19
- ['qa.security', ''],
20
- ['qa.deep', 'merge gate'],
21
- ['qa.status', ''],
22
- ['qa.inspect_project', ''],
16
+ ['qa.browser', 'page load, console and network check'],
23
17
  ];
24
18
  /**
25
19
  * The QA guidance for one node, or the empty string for a node that holds
@@ -32,11 +26,12 @@ export function qaGuidance(options) {
32
26
  return '';
33
27
  const has = (name) => held.has(name);
34
28
  const tester = options.laterTester;
29
+ // Lint, tests and builds are not qa.* tools: the agent runs the project's own commands through
30
+ // its shell. A pipeline of them (qa.fast, qa.deep and four more) was removed after it cost about
31
+ // two extra requests per run and mostly reported failures the change had not caused.
35
32
  const lines = [
36
- `- Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: ${tools.map(([name, description]) => description ? `${name} (${description})` : name).join(', ')}.`,
33
+ `- Use the qa.* tools instead of ad-hoc shell when they fit: ${tools.map(([name, description]) => `${name} (${description})`).join(', ')}. Lint, tests and builds have no qa.* tool: run the project's own commands for them.`,
37
34
  ];
38
- if (has('qa.fast'))
39
- lines.push(`- After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check${has('qa.test') ? ' (qa.test related/file/pattern)' : ''} before the full qa.fast.`);
40
35
  if (tester !== undefined) {
41
36
  lines.push(`- ${JSON.stringify(tester)} runs after this node and tests the change in the running app. Do not launch, click through, type into or screenshot the app yourself, and do not script keyboard or mouse input into any window: build the change, run the checks that cover it, and hand ${JSON.stringify(tester)} what it needs to test.`);
42
37
  }
@@ -46,14 +41,6 @@ export function qaGuidance(options) {
46
41
  if (has('qa.browser'))
47
42
  lines.push('- Frontend/UI changes additionally need qa.browser against a running app.');
48
43
  }
49
- if (has('qa.security'))
50
- lines.push('- Security-sensitive or dependency changes need qa.security. Treat a secret-scan finding as a hard blocker: rotate and remove the secret, never commit it.');
51
- // The merge gate adds browser checks and runtime smoke runs for the change it classifies, which
52
- // is the testing a later tester owns.
53
- if (has('qa.deep') && tester === undefined)
54
- lines.push('- Before declaring feature work complete, run qa.deep; report the gate verdict. If a required check is blocked, say so plainly instead of calling the work verified.');
55
- if (has('qa.status'))
56
- lines.push('- Checks are remembered per session: qa.status shows stale results after later edits.');
57
- lines.push('- Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.', '- On Windows, run foreground child commands directly with PowerShell\'s invocation operator (for example `& $exe @args`) instead of wrapping them in `Start-Job` just to impose a timeout; the shell tool already owns timeout and process-tree cleanup. Avoid `Start-Process -ArgumentList @(…)` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.', '- Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.');
44
+ lines.push('- Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.', '- On Windows, run foreground child commands directly with PowerShell\'s invocation operator (for example `& $exe @args`) instead of wrapping them in `Start-Job` just to impose a timeout; the shell tool already owns timeout and process-tree cleanup. Avoid `Start-Process -ArgumentList @(…)` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.');
58
45
  return `QA tooling:\n${lines.join('\n')}`;
59
46
  }
@@ -1,7 +1,5 @@
1
1
  export { createQaTools } from './tools.js';
2
- export { getQaOrchestrator, QaOrchestrator } from './orchestrator/QaOrchestrator.js';
3
2
  export { disposeAllQaProcesses, getQaProcessManager, listQaProcesses, stopQaProcess } from './runtime/ProcessManager.js';
4
3
  export { disposeAllQaPtys, getQaPtyManager, listQaPtys, stopQaPty } from './runtime/PtyManager.js';
5
4
  export { onBackgroundChange } from './runtime/changes.js';
6
- export { detectRuntimeCapabilities } from './runtime-detect.js';
7
5
  export { qaGuidance, type QaGuidanceOptions } from './guidance.js';
@@ -1,7 +1,5 @@
1
1
  export { createQaTools } from './tools.js';
2
- export { getQaOrchestrator, QaOrchestrator } from './orchestrator/QaOrchestrator.js';
3
2
  export { disposeAllQaProcesses, getQaProcessManager, listQaProcesses, stopQaProcess } from './runtime/ProcessManager.js';
4
3
  export { disposeAllQaPtys, getQaPtyManager, listQaPtys, stopQaPty } from './runtime/PtyManager.js';
5
4
  export { onBackgroundChange } from './runtime/changes.js';
6
- export { detectRuntimeCapabilities } from './runtime-detect.js';
7
5
  export { qaGuidance } from './guidance.js';
@@ -13,5 +13,9 @@ export declare const DEFAULT_AUTO_REPAIR: {
13
13
  enabled: boolean;
14
14
  maxAttemptsPerCheck: number;
15
15
  };
16
- /** Marker directories excluded from QA scans and change analysis. */
16
+ /**
17
+ * Marker directories excluded from QA scans and change analysis. `.codegraph` is the code index
18
+ * Andorra Code writes into the workspace itself; it is never part of the user's change,
19
+ * and neither are the caches a test run leaves behind (one pytest run added four .pyc files to a one-file change).
20
+ */
17
21
  export declare const QA_EXCLUDED_DIRS: Set<string>;
@@ -11,5 +11,9 @@ export const DEFAULT_SECURITY = {
11
11
  dependencyScan: true, secretScan: true, semgrep: false, failOn: ['critical', 'high'],
12
12
  };
13
13
  export const DEFAULT_AUTO_REPAIR = { enabled: true, maxAttemptsPerCheck: 3 };
14
- /** Marker directories excluded from QA scans and change analysis. */
15
- export const QA_EXCLUDED_DIRS = new Set(['.git', 'node_modules', '.andorracode', '.andorra', 'dist', 'build', 'out', 'coverage', '.next', 'vendor']);
14
+ /**
15
+ * Marker directories excluded from QA scans and change analysis. `.codegraph` is the code index
16
+ * Andorra Code writes into the workspace itself; it is never part of the user's change,
17
+ * and neither are the caches a test run leaves behind (one pytest run added four .pyc files to a one-file change).
18
+ */
19
+ export const QA_EXCLUDED_DIRS = new Set(['.git', 'node_modules', '.andorracode', '.andorra', '.codegraph', '__pycache__', '.pytest_cache', 'dist', 'build', 'out', 'coverage', '.next', 'vendor']);
@@ -1,3 +1,21 @@
1
1
  import type { Tool } from '../types.js';
2
- /** The LLM-facing QA tools. All command execution is permission-gated. */
2
+ import type { QaCheckResult } from './types.js';
3
+ /**
4
+ * The host work behind qa.browser, behind one seam so a test can stand in for the browser and
5
+ * observe that permission was decided before it ran.
6
+ */
7
+ export declare const qaBrowserHost: {
8
+ check(options: {
9
+ workspace: string;
10
+ url?: string;
11
+ accessibility?: boolean;
12
+ signal: AbortSignal;
13
+ }): Promise<QaCheckResult[]>;
14
+ };
15
+ /**
16
+ * The LLM-facing QA tools: a terminal to drive a CLI or TUI and a browser page check. All command
17
+ * execution is permission-gated. The check pipeline that used to sit beside them (qa.fast,
18
+ * qa.test, qa.deep, qa.security, qa.status, qa.inspect_project) is gone: an agent verifies a
19
+ * change with the project's own commands through its shell.
20
+ */
3
21
  export declare function createQaTools(): Tool[];