@andorra-labs/code 0.1.8 → 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 (187) hide show
  1. package/THIRD_PARTY_NOTICES.md +2 -1
  2. package/dist/src/account-presentation.d.ts +11 -0
  3. package/dist/src/account-presentation.js +29 -2
  4. package/dist/src/agent-execution.js +57 -4
  5. package/dist/src/agent-mcp.d.ts +12 -0
  6. package/dist/src/agent-mcp.js +81 -2
  7. package/dist/src/app-server/protocol.d.ts +120 -1
  8. package/dist/src/app-server/protocol.js +8 -1
  9. package/dist/src/app-server/reasoning.d.ts +0 -8
  10. package/dist/src/app-server/reasoning.js +15 -28
  11. package/dist/src/app-server.d.ts +32 -0
  12. package/dist/src/app-server.js +214 -21
  13. package/dist/src/auth/AuthManager.d.ts +15 -0
  14. package/dist/src/auth/AuthManager.js +66 -7
  15. package/dist/src/auth/index.d.ts +1 -1
  16. package/dist/src/auth/index.js +1 -1
  17. package/dist/src/auth/store.d.ts +17 -1
  18. package/dist/src/auth/store.js +25 -2
  19. package/dist/src/browser-runner.js +1 -2
  20. package/dist/src/browser-server.js +10 -2
  21. package/dist/src/browser-session.js +6 -2
  22. package/dist/src/browser-stealth.d.ts +29 -0
  23. package/dist/src/browser-stealth.js +166 -0
  24. package/dist/src/browser-ui/app.js +123 -28
  25. package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
  26. package/dist/src/browser-ui/index.html +8 -8
  27. package/dist/src/browser-ui/style.css +199 -171
  28. package/dist/src/browser-ui/tokens.css +198 -0
  29. package/dist/src/browser-view.d.ts +57 -9
  30. package/dist/src/browser-view.js +187 -36
  31. package/dist/src/cli.js +31 -9
  32. package/dist/src/coding-tools.js +9 -5
  33. package/dist/src/command-screens.js +4 -4
  34. package/dist/src/commands.d.ts +1 -1
  35. package/dist/src/commands.js +3 -2
  36. package/dist/src/completion-gates.d.ts +35 -0
  37. package/dist/src/completion-gates.js +25 -0
  38. package/dist/src/completion.d.ts +7 -1
  39. package/dist/src/completion.js +37 -4
  40. package/dist/src/config.d.ts +1 -1
  41. package/dist/src/config.js +2 -2
  42. package/dist/src/context-budget.d.ts +11 -0
  43. package/dist/src/context-budget.js +13 -0
  44. package/dist/src/decision/DecisionEngine.d.ts +5 -1
  45. package/dist/src/decision/DecisionManager.d.ts +1 -0
  46. package/dist/src/decision/DecisionManager.js +14 -3
  47. package/dist/src/decision/FactContinuations.d.ts +6 -0
  48. package/dist/src/decision/FactContinuations.js +9 -1
  49. package/dist/src/decision/FactServiceGate.js +1 -1
  50. package/dist/src/decision/checks.js +1 -1
  51. package/dist/src/decision/hostedSkills.d.ts +37 -0
  52. package/dist/src/decision/hostedSkills.js +64 -0
  53. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
  54. package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
  55. package/dist/src/default-graph.d.ts +11 -0
  56. package/dist/src/default-graph.js +20 -0
  57. package/dist/src/duration.d.ts +13 -2
  58. package/dist/src/duration.js +27 -3
  59. package/dist/src/file-diff.d.ts +105 -0
  60. package/dist/src/file-diff.js +244 -0
  61. package/dist/src/graph-manager-chat.d.ts +302 -0
  62. package/dist/src/graph-manager-chat.js +940 -0
  63. package/dist/src/graph-runner.js +6 -0
  64. package/dist/src/graph-server.d.ts +9 -0
  65. package/dist/src/graph-server.js +171 -20
  66. package/dist/src/graph-studio-features.js +2 -2
  67. package/dist/src/graph-sync.js +5 -2
  68. package/dist/src/graph-ui/app.js +369 -183
  69. package/dist/src/graph-ui/controls.css +55 -32
  70. package/dist/src/graph-ui/controls.js +85 -9
  71. package/dist/src/graph-ui/edge-router.js +114 -13
  72. package/dist/src/graph-ui/embed.js +32 -17
  73. package/dist/src/graph-ui/icons.js +1 -0
  74. package/dist/src/graph-ui/index.html +4 -4
  75. package/dist/src/graph-ui/library.css +4 -10
  76. package/dist/src/graph-ui/manager-markdown.js +155 -0
  77. package/dist/src/graph-ui/manager-state.js +191 -0
  78. package/dist/src/graph-ui/manager.css +161 -0
  79. package/dist/src/graph-ui/manager.js +700 -0
  80. package/dist/src/graph-ui/skill-picker.js +6 -6
  81. package/dist/src/graph-ui/studio-canvas.js +17 -15
  82. package/dist/src/graph-ui/studio.css +24 -23
  83. package/dist/src/graph-ui/studio.js +69 -48
  84. package/dist/src/graph-ui/style.css +128 -93
  85. package/dist/src/graph-ui/theme.js +2 -2
  86. package/dist/src/graph-ui/tokens.css +217 -151
  87. package/dist/src/graphs.d.ts +76 -2
  88. package/dist/src/graphs.js +172 -9
  89. package/dist/src/hardened-runtime.js +8 -2
  90. package/dist/src/mcp.d.ts +75 -0
  91. package/dist/src/mcp.js +240 -8
  92. package/dist/src/membership-errors.d.ts +14 -0
  93. package/dist/src/membership-errors.js +24 -1
  94. package/dist/src/membership.d.ts +20 -0
  95. package/dist/src/membership.js +45 -16
  96. package/dist/src/palette.d.ts +25 -8
  97. package/dist/src/palette.js +26 -8
  98. package/dist/src/provider-engine.d.ts +4 -4
  99. package/dist/src/provider-engine.js +39 -22
  100. package/dist/src/provider-keys.d.ts +5 -1
  101. package/dist/src/provider-keys.js +7 -3
  102. package/dist/src/provider-settings.d.ts +4 -1
  103. package/dist/src/provider-settings.js +46 -5
  104. package/dist/src/providers.d.ts +24 -0
  105. package/dist/src/providers.js +47 -2
  106. package/dist/src/qa/guidance.d.ts +26 -0
  107. package/dist/src/qa/guidance.js +46 -0
  108. package/dist/src/qa/index.d.ts +1 -8
  109. package/dist/src/qa/index.js +1 -16
  110. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  111. package/dist/src/qa/profile/QaProfile.js +6 -2
  112. package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
  113. package/dist/src/qa/runtime/ProcessManager.js +69 -13
  114. package/dist/src/qa/tools.d.ts +19 -1
  115. package/dist/src/qa/tools.js +20 -145
  116. package/dist/src/react-runtime.d.ts +11 -0
  117. package/dist/src/react-runtime.js +203 -53
  118. package/dist/src/remote/engine-pool.js +21 -6
  119. package/dist/src/run-progress.d.ts +6 -0
  120. package/dist/src/run-progress.js +7 -0
  121. package/dist/src/runtime.d.ts +8 -0
  122. package/dist/src/screen-selection.d.ts +38 -0
  123. package/dist/src/screen-selection.js +103 -0
  124. package/dist/src/session-changes.d.ts +117 -0
  125. package/dist/src/session-changes.js +796 -0
  126. package/dist/src/session-skills.d.ts +75 -0
  127. package/dist/src/session-skills.js +151 -0
  128. package/dist/src/side-panel.d.ts +1 -1
  129. package/dist/src/side-panel.js +6 -12
  130. package/dist/src/skill-commands.js +1 -1
  131. package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
  132. package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
  133. package/dist/src/skills/bundled/provenance.json +3 -3
  134. package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
  135. package/dist/src/stall-recovery.d.ts +33 -0
  136. package/dist/src/stall-recovery.js +83 -0
  137. package/dist/src/subagent-run.js +1 -2
  138. package/dist/src/telemetry/schema.d.ts +1 -1
  139. package/dist/src/telemetry/schema.js +1 -2
  140. package/dist/src/terminal-ui.d.ts +66 -22
  141. package/dist/src/terminal-ui.js +327 -92
  142. package/dist/src/tool-diff-stats.d.ts +9 -0
  143. package/dist/src/tool-diff-stats.js +20 -0
  144. package/dist/src/tool-names.d.ts +1 -1
  145. package/dist/src/tool-result-filter.js +1 -1
  146. package/dist/src/tools.js +26 -2
  147. package/dist/src/transcript.d.ts +11 -0
  148. package/dist/src/transcript.js +23 -3
  149. package/dist/src/types.d.ts +24 -4
  150. package/dist/src/usage-analytics.d.ts +7 -0
  151. package/dist/src/usage-analytics.js +55 -15
  152. package/docs/concepts/README.md +1 -1
  153. package/docs/concepts/limits.md +9 -0
  154. package/docs/guides/desktop-app.md +1 -1
  155. package/docs/guides/graph-builder.md +16 -1
  156. package/docs/guides/tui.md +9 -9
  157. package/docs/reference/slash-commands.md +2 -1
  158. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
  159. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
  160. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
  161. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
  162. package/package.json +1 -1
  163. package/tests/chat-side-panel-test-plan.md +1 -1
  164. package/dist/src/qa/api/http-runner.d.ts +0 -3
  165. package/dist/src/qa/api/http-runner.js +0 -47
  166. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  167. package/dist/src/qa/git/ChangeDetector.js +0 -177
  168. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  169. package/dist/src/qa/git/DiffReviewer.js +0 -115
  170. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  171. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  172. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  173. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  174. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  175. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  176. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  177. package/dist/src/qa/runners/CommandRunner.js +0 -96
  178. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  179. package/dist/src/qa/runners/TestRunner.js +0 -66
  180. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  181. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  182. package/dist/src/qa/runtime-detect.d.ts +0 -10
  183. package/dist/src/qa/runtime-detect.js +0 -72
  184. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  185. package/dist/src/qa/security/DependencyScanner.js +0 -167
  186. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  187. package/dist/src/qa/security/SecretScanner.js +0 -55
@@ -12,12 +12,12 @@ export function isEngineContextOverflow(errorMessage) {
12
12
  model: '', timestamp: 0, usage: emptyUsage(), stopReason: 'error', errorMessage });
13
13
  }
14
14
  /**
15
- * Move the serializer's conversation breakpoint off the trailing run snapshots.
15
+ * Move the serializer's conversation breakpoint off the trailing messages a later request rewrites.
16
16
  *
17
17
  * Anthropic writes a cache entry only at a marked block, and the vendored serializer marks the
18
- * final message. With the snapshots at the tail, that entry would end at a message the next
19
- * request moves behind its new exchange, so no prefix of the next request ever matches it and
20
- * the whole history is re-written every turn. Marking the last committed message instead lets
18
+ * final message. When that message is transient guidance, the entry would end at a message the
19
+ * next request replaces, so no prefix of the next request ever matches it and the whole history
20
+ * is re-written every turn. Marking the last committed message instead lets
21
21
  * the next request find that entry by looking back from its own breakpoint.
22
22
  */
23
23
  export function relocateConversationBreakpoint(body, mutableTail) {
@@ -269,27 +269,35 @@ export async function generateEngineResponse(request, host) {
269
269
  ledger(message.usage);
270
270
  };
271
271
  // No provider SDK authentication/environment discovery: Andorra's send() owns credentials.
272
+ const sendWithFallbacks = async (body) => {
273
+ try {
274
+ return await host.send(body);
275
+ }
276
+ catch (error) {
277
+ const status = error.status;
278
+ if (status !== 400 && status !== 422)
279
+ throw error;
280
+ // A required tool choice is a recovery hint, never a reason to fail the request: a server
281
+ // that does not support it (no guided decoding, an older API) gets the same request without it.
282
+ if (body.tool_choice !== undefined) {
283
+ const { tool_choice: _choice, ...unforced } = body;
284
+ return sendWithFallbacks(unforced);
285
+ }
286
+ // Only replay when the failed request was actually streamed. Once the host has
287
+ // already forced whole-body mode, a 400/422 is a real provider rejection and a
288
+ // second identical request would only double-count the failure.
289
+ if (host.streamingDisabled?.())
290
+ throw error;
291
+ // A compatibility endpoint may reject streaming. Retry only this inference,
292
+ // never any completed tools, and account for both requests in the host.
293
+ const { stream_options: _options, ...plain } = body;
294
+ return host.send({ ...plain, stream: false });
295
+ }
296
+ };
272
297
  const nativeFetch = async (_url, init) => {
273
298
  try {
274
299
  const body = JSON.parse(String(init?.body));
275
- let response;
276
- try {
277
- response = await host.send(body);
278
- }
279
- catch (error) {
280
- const status = error.status;
281
- if (status !== 400 && status !== 422)
282
- throw error;
283
- // Only replay when the failed request was actually streamed. Once the host has
284
- // already forced whole-body mode, a 400/422 is a real provider rejection and a
285
- // second identical request would only double-count the failure.
286
- if (host.streamingDisabled?.())
287
- throw error;
288
- // A compatibility endpoint may reject streaming. Retry only this inference,
289
- // never any completed tools, and account for both requests in the host.
290
- const { stream_options: _options, ...plain } = body;
291
- response = await host.send({ ...plain, stream: false });
292
- }
300
+ const response = await sendWithFallbacks(body);
293
301
  if (/text\/event-stream/i.test(response.headers.get('content-type') ?? '')) {
294
302
  if (!response.body)
295
303
  throw new Error('Provider returned a malformed response.');
@@ -437,6 +445,15 @@ export async function generateEngineResponse(request, host) {
437
445
  }
438
446
  }
439
447
  }
448
+ if (request.toolChoice === 'required' && Array.isArray(body.tools) && body.tools.length) {
449
+ // Anthropic refuses a forced tool choice while extended thinking is on; that request goes
450
+ // out unforced rather than failing.
451
+ const thinking = body.thinking;
452
+ if (!host.anthropic)
453
+ body.tool_choice = 'required';
454
+ else if (thinking === undefined || thinking.type === 'disabled')
455
+ body.tool_choice = { type: 'any' };
456
+ }
440
457
  return body;
441
458
  },
442
459
  });
@@ -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;
@@ -227,6 +227,30 @@ export declare class ProviderRequestError extends Error {
227
227
  */
228
228
  constructor(message: string, contextOverflow?: boolean);
229
229
  }
230
+ /**
231
+ * How much blank tool-call output a stream may carry in a row before it is abandoned: whitespace
232
+ * characters in a call's arguments, plus one for every tool-call fragment that adds nothing.
233
+ *
234
+ * A model sometimes opens a tool call and then generates whitespace until the provider's output
235
+ * cap stops it. On DeepSeek V4.1 Flash that was 131,072 completion tokens over eight minutes for a
236
+ * call whose arguments arrived empty, about once in three thousand requests, and it was 16% of
237
+ * all output in a 90-task SWE-bench run. Real arguments never hold this much consecutive
238
+ * whitespace: line breaks inside a JSON string are escaped, and indentation between tokens is a
239
+ * few characters. The stream is cut here and the request replayed, which is safe because no tool
240
+ * from the abandoned response ran.
241
+ */
242
+ export declare const BLANK_TOOL_CALL_LIMIT = 4096;
243
+ /**
244
+ * Counts consecutive blank tool-call output across a stream and throws once it passes
245
+ * {@link BLANK_TOOL_CALL_LIMIT}. Anything the model visibly produces (argument text, a tool
246
+ * name, answer text, reasoning) ends the run of blanks.
247
+ */
248
+ export declare function createBlankToolCallGuard(limit?: number): {
249
+ /** One tool-call fragment's text: its name and argument pieces joined. */
250
+ fragment(text: string): void;
251
+ /** The model produced something other than a tool-call fragment. */
252
+ progress(): void;
253
+ };
230
254
  /**
231
255
  * Measure a streamed response's decode time from when its fragments arrive.
232
256
  *
@@ -330,6 +330,45 @@ class RetryableProviderError extends ProviderRequestError {
330
330
  class MalformedStreamProviderError extends RetryableProviderError {
331
331
  constructor() { super('Provider returned a malformed response.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
332
332
  }
333
+ /**
334
+ * How much blank tool-call output a stream may carry in a row before it is abandoned: whitespace
335
+ * characters in a call's arguments, plus one for every tool-call fragment that adds nothing.
336
+ *
337
+ * A model sometimes opens a tool call and then generates whitespace until the provider's output
338
+ * cap stops it. On DeepSeek V4.1 Flash that was 131,072 completion tokens over eight minutes for a
339
+ * call whose arguments arrived empty, about once in three thousand requests, and it was 16% of
340
+ * all output in a 90-task SWE-bench run. Real arguments never hold this much consecutive
341
+ * whitespace: line breaks inside a JSON string are escaped, and indentation between tokens is a
342
+ * few characters. The stream is cut here and the request replayed, which is safe because no tool
343
+ * from the abandoned response ran.
344
+ */
345
+ export const BLANK_TOOL_CALL_LIMIT = 4096;
346
+ /** A stream abandoned because a tool call kept generating blank output; replayed like a malformed one. */
347
+ class BlankToolCallProviderError extends RetryableProviderError {
348
+ constructor() { super('Provider streamed a tool call that kept generating blank output.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
349
+ }
350
+ /**
351
+ * Counts consecutive blank tool-call output across a stream and throws once it passes
352
+ * {@link BLANK_TOOL_CALL_LIMIT}. Anything the model visibly produces (argument text, a tool
353
+ * name, answer text, reasoning) ends the run of blanks.
354
+ */
355
+ export function createBlankToolCallGuard(limit = BLANK_TOOL_CALL_LIMIT) {
356
+ let blank = 0;
357
+ return {
358
+ /** One tool-call fragment's text: its name and argument pieces joined. */
359
+ fragment(text) {
360
+ if (/\S/.test(text)) {
361
+ blank = 0;
362
+ return;
363
+ }
364
+ blank += Math.max(1, text.length);
365
+ if (blank > limit)
366
+ throw new BlankToolCallProviderError();
367
+ },
368
+ /** The model produced something other than a tool-call fragment. */
369
+ progress() { blank = 0; },
370
+ };
371
+ }
333
372
  /** A completed HTTP exchange the provider refused outright; `status` drives compatibility fallbacks. */
334
373
  class HttpProviderError extends ProviderRequestError {
335
374
  status;
@@ -626,6 +665,7 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
626
665
  let content = '', refusal, reasoning = '', finishReason, chunkUsage;
627
666
  let sawChoice = false, sawText = false;
628
667
  const decode = createDecodeWindow(now);
668
+ const blankCalls = createBlankToolCallGuard();
629
669
  const fragments = [];
630
670
  const text = (value) => {
631
671
  if (value == null)
@@ -689,8 +729,10 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
689
729
  // reasoning_text, so a model that answers its reasoning through the other fields is still
690
730
  // generating, and its window must open at that first fragment rather than at the answer.
691
731
  const thinking = reasoningDelta || text(delta.reasoning) || text(delta.reasoning_text);
692
- if (thinking)
732
+ if (thinking) {
693
733
  stampOutput(thinking);
734
+ blankCalls.progress();
735
+ }
694
736
  const contentDelta = text(delta.content);
695
737
  // An empty content string still records the field's presence: the whole-body path
696
738
  // distinguishes `content: ""` from `null`, and the streamed answer must keep that
@@ -701,6 +743,7 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
701
743
  if (contentDelta) {
702
744
  content += contentDelta;
703
745
  stampOutput(contentDelta);
746
+ blankCalls.progress();
704
747
  }
705
748
  }
706
749
  const refusalDelta = text(delta.refusal);
@@ -743,8 +786,10 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
743
786
  callText += fn.arguments;
744
787
  }
745
788
  }
746
- if (delta.tool_calls.length > 0)
789
+ if (delta.tool_calls.length > 0) {
747
790
  stampOutput(callText);
791
+ blankCalls.fragment(callText);
792
+ }
748
793
  },
749
794
  finish(requests, completionAdvertised) {
750
795
  if (!sawChoice)
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The QA section of an agent node's workspace guidance.
3
+ *
4
+ * It is written per node rather than once per run: a line naming a qa.* tool the node was not
5
+ * granted is an instruction it cannot follow, and a node that hands its change to a testing node
6
+ * must not be told to test the running app itself. Before this was per node, an implementation
7
+ * node with a QA node after it read "Frontend/UI changes additionally need qa.browser against a
8
+ * running app" and spent most of its turns scripting clicks and screenshots into the user's own
9
+ * window — the QA node's job, done without the QA node's tools.
10
+ *
11
+ * A leaf module, so the agent runtime can import it without loading the QA orchestrator.
12
+ */
13
+ export interface QaGuidanceOptions {
14
+ /** The names of the tools this node holds; lines about a qa.* tool it lacks are left out. */
15
+ tools: Iterable<string>;
16
+ /**
17
+ * The name of a later node in the graph that tests the change in the running app. When set, the
18
+ * node is told to leave that testing to it instead of being told to drive the app itself.
19
+ */
20
+ laterTester?: string;
21
+ }
22
+ /**
23
+ * The QA guidance for one node, or the empty string for a node that holds
24
+ * no qa.* tool (an intake node, for example), which has nothing in it to follow.
25
+ */
26
+ export declare function qaGuidance(options: QaGuidanceOptions): string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The QA section of an agent node's workspace guidance.
3
+ *
4
+ * It is written per node rather than once per run: a line naming a qa.* tool the node was not
5
+ * granted is an instruction it cannot follow, and a node that hands its change to a testing node
6
+ * must not be told to test the running app itself. Before this was per node, an implementation
7
+ * node with a QA node after it read "Frontend/UI changes additionally need qa.browser against a
8
+ * running app" and spent most of its turns scripting clicks and screenshots into the user's own
9
+ * window — the QA node's job, done without the QA node's tools.
10
+ *
11
+ * A leaf module, so the agent runtime can import it without loading the QA orchestrator.
12
+ */
13
+ /** The qa.* tools the guidance can name, in the order it names them. */
14
+ const QA_TOOLS = [
15
+ ['qa.terminal', 'persistent PTY/ConPTY CLI/TUI interaction'],
16
+ ['qa.browser', 'page load, console and network check'],
17
+ ];
18
+ /**
19
+ * The QA guidance for one node, or the empty string for a node that holds
20
+ * no qa.* tool (an intake node, for example), which has nothing in it to follow.
21
+ */
22
+ export function qaGuidance(options) {
23
+ const held = new Set(options.tools);
24
+ const tools = QA_TOOLS.filter(([name]) => held.has(name));
25
+ if (tools.length === 0)
26
+ return '';
27
+ const has = (name) => held.has(name);
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.
32
+ const lines = [
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.`,
34
+ ];
35
+ if (tester !== undefined) {
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.`);
37
+ }
38
+ else {
39
+ if (has('qa.terminal'))
40
+ lines.push('- CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.');
41
+ if (has('qa.browser'))
42
+ lines.push('- Frontend/UI changes additionally need qa.browser against a running app.');
43
+ }
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.');
45
+ return `QA tooling:\n${lines.join('\n')}`;
46
+ }
@@ -1,12 +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
- /**
8
- * The QA section appended to workspace guidance. Keeps the model's QA loop
9
- * (verify after every edit, targeted re-runs, merge gate) explicit without
10
- * pulling tool JSON schemas into the prompt.
11
- */
12
- export declare const QA_SYSTEM_GUIDANCE = "\nQA tooling:\n- Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: qa.fast (lint + typecheck + related tests + diff/secret review), qa.test (scoped unit runs: related/file/pattern/all), qa.terminal (persistent PTY/ConPTY CLI/TUI interaction), qa.browser, qa.security, qa.deep (merge gate), qa.status, qa.inspect_project.\n- After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check (qa.test related/file/pattern) before the full qa.fast.\n- CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.\n- Frontend/UI changes additionally need qa.browser against a running app; 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.\n- 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.\n- Checks are remembered per session: qa.status shows stale results after later edits. Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.\n- 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 @(\u2026)` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.\n- Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.";
5
+ export { qaGuidance, type QaGuidanceOptions } from './guidance.js';
@@ -1,20 +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
- /**
8
- * The QA section appended to workspace guidance. Keeps the model's QA loop
9
- * (verify after every edit, targeted re-runs, merge gate) explicit without
10
- * pulling tool JSON schemas into the prompt.
11
- */
12
- export const QA_SYSTEM_GUIDANCE = `
13
- QA tooling:
14
- - Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: qa.fast (lint + typecheck + related tests + diff/secret review), qa.test (scoped unit runs: related/file/pattern/all), qa.terminal (persistent PTY/ConPTY CLI/TUI interaction), qa.browser, qa.security, qa.deep (merge gate), qa.status, qa.inspect_project.
15
- - After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check (qa.test related/file/pattern) before the full qa.fast.
16
- - CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.\n- Frontend/UI changes additionally need qa.browser against a running app; 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.
17
- - 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.
18
- - Checks are remembered per session: qa.status shows stale results after later edits. Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.
19
- - 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.
20
- - Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.`;
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']);
@@ -10,12 +10,26 @@ export interface ManagedProcessInfo {
10
10
  /** Epoch milliseconds the process was spawned and, once it has, exited; lets a surface show how long it ran. */
11
11
  startedAt: number;
12
12
  endedAt?: number;
13
+ /** Started to outlive the CLI: shutdown leaves it running. */
14
+ persistent?: boolean;
13
15
  }
16
+ /**
17
+ * Whether a job can be started to outlive the CLI. Not on Windows: there the PowerShell wrapper
18
+ * carries the command's output through its own pipeline, so the command dies with the wrapper, and
19
+ * a detached PowerShell exits before running the command at all.
20
+ */
21
+ export declare const PERSISTENT_JOBS_SUPPORTED: boolean;
14
22
  /**
15
23
  * Long-lived QA processes (dev servers) owned by the CLI session. Logs stay on
16
24
  * disk plus a bounded in-memory tail; every process inherits the shell
17
25
  * credential-allowlist environment and is tree-killed on stop, including when
18
26
  * the CLI exits.
27
+ *
28
+ * A persistent process is the exception at exit: it is a service the user asked to have left
29
+ * running (a web server the task sets up), so CLI shutdown leaves it alone. It writes straight to
30
+ * its log file rather than through pipes, because a pipe to a CLI that has exited would end it on
31
+ * its next write, and it is unreferenced (and, like every job, in its own process group) so the CLI
32
+ * can exit while it runs. An explicit stop and the removal of its workspace still end it.
19
33
  */
20
34
  export declare class QaProcessManager {
21
35
  private readonly workspace;
@@ -28,6 +42,7 @@ export declare class QaProcessManager {
28
42
  logDir?: string;
29
43
  launchPolicy?: () => ShellSandbox | undefined;
30
44
  signal?: AbortSignal;
45
+ persist?: boolean;
31
46
  }): Promise<ManagedProcessInfo>;
32
47
  private validateStart;
33
48
  private info;
@@ -47,7 +62,10 @@ export declare class QaProcessManager {
47
62
  /** Event-driven completion wait; an unfinished job returns running instead of polling. */
48
63
  wait(id: string, timeoutMs: number, signal: AbortSignal): Promise<ManagedProcessInfo>;
49
64
  stop(id: string): Promise<void>;
50
- stopAll(): Promise<void>;
65
+ /** `keepPersistent` is CLI shutdown: a job started to outlive the CLI is left running and forgotten. */
66
+ stopAll(options?: {
67
+ keepPersistent?: boolean;
68
+ }): Promise<void>;
51
69
  }
52
70
  export declare function defaultQaProcessesDir(workspace: string): string;
53
71
  /** One process manager per workspace, retained for the life of the CLI. */
@@ -65,5 +83,5 @@ export declare function stopQaProcess(workspace: string, id: string): Promise<bo
65
83
  * keeps its listeners, and on Windows keeps the folder from being removed. Never throws.
66
84
  */
67
85
  export declare function stopQaProcessesUnder(root: string): Promise<void>;
68
- /** CLI shutdown hook: kill every QA-owned background process. */
86
+ /** CLI shutdown hook: kill every QA-owned background process except those started to persist. */
69
87
  export declare function disposeAllQaProcesses(): Promise<void>;