@andorra-labs/code 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/src/acp-agent.d.ts +6 -0
  2. package/dist/src/acp-agent.js +15 -4
  3. package/dist/src/agent-execution.js +11 -8
  4. package/dist/src/agent-mcp-catalog.js +1 -0
  5. package/dist/src/agent-mcp.d.ts +3 -0
  6. package/dist/src/agent-mcp.js +33 -1
  7. package/dist/src/andorra/entry.d.ts +10 -0
  8. package/dist/src/andorra/entry.js +18 -4
  9. package/dist/src/andorra/hosted.d.ts +2 -1
  10. package/dist/src/andorra/hosted.js +2 -1
  11. package/dist/src/andorra/notices.d.ts +5 -0
  12. package/dist/src/andorra/notices.js +7 -0
  13. package/dist/src/andorra/state.d.ts +3 -2
  14. package/dist/src/andorra/state.js +4 -4
  15. package/dist/src/andorra/terminal.js +7 -2
  16. package/dist/src/anthropic-credentials.js +2 -0
  17. package/dist/src/app-server/error.d.ts +5 -0
  18. package/dist/src/app-server/error.js +7 -0
  19. package/dist/src/app-server/protocol.d.ts +19 -44
  20. package/dist/src/app-server/protocol.js +5 -1
  21. package/dist/src/app-server/workspace.d.ts +89 -0
  22. package/dist/src/app-server/workspace.js +457 -11
  23. package/dist/src/app-server.d.ts +358 -32
  24. package/dist/src/app-server.js +2429 -509
  25. package/dist/src/bridge/cloud.d.ts +27 -0
  26. package/dist/src/bridge/cloud.js +187 -0
  27. package/dist/src/bridge/command.d.ts +30 -0
  28. package/dist/src/bridge/command.js +347 -0
  29. package/dist/src/bridge/control.d.ts +68 -0
  30. package/dist/src/bridge/control.js +233 -0
  31. package/dist/src/bridge/engines.d.ts +90 -0
  32. package/dist/src/bridge/engines.js +601 -0
  33. package/dist/src/bridge/host-ops.d.ts +9 -0
  34. package/dist/src/bridge/host-ops.js +129 -0
  35. package/dist/src/bridge/host.d.ts +47 -0
  36. package/dist/src/bridge/host.js +540 -0
  37. package/dist/src/bridge/link.d.ts +38 -0
  38. package/dist/src/bridge/link.js +508 -0
  39. package/dist/src/bridge/login-link.d.ts +29 -0
  40. package/dist/src/bridge/login-link.js +54 -0
  41. package/dist/src/bridge/protocol.d.ts +136 -0
  42. package/dist/src/bridge/protocol.js +11 -0
  43. package/dist/src/bridge/store.d.ts +12 -0
  44. package/dist/src/bridge/store.js +61 -0
  45. package/dist/src/bridge/wording.d.ts +6 -0
  46. package/dist/src/bridge/wording.js +10 -0
  47. package/dist/src/browser-server.js +7 -1
  48. package/dist/src/browser-ui/tokens.css +1 -1
  49. package/dist/src/change-authors.d.ts +41 -0
  50. package/dist/src/change-authors.js +146 -0
  51. package/dist/src/cli.js +182 -32
  52. package/dist/src/coding-tools.js +15 -15
  53. package/dist/src/command-screens.d.ts +6 -0
  54. package/dist/src/command-screens.js +14 -11
  55. package/dist/src/commands.d.ts +14 -2
  56. package/dist/src/compaction-phrases.js +1 -1
  57. package/dist/src/completion.js +82 -5
  58. package/dist/src/config.d.ts +71 -3
  59. package/dist/src/config.js +202 -77
  60. package/dist/src/deadline.js +13 -1
  61. package/dist/src/decision/checks.js +1 -1
  62. package/dist/src/decision/requestPhrases.js +0 -1
  63. package/dist/src/default-graph.js +1 -1
  64. package/dist/src/file-diff.d.ts +4 -0
  65. package/dist/src/file-diff.js +2 -1
  66. package/dist/src/github-app/agent-writes.d.ts +102 -0
  67. package/dist/src/github-app/agent-writes.js +320 -0
  68. package/dist/src/github-app/client.d.ts +349 -0
  69. package/dist/src/github-app/client.js +810 -0
  70. package/dist/src/github-app/event-source.d.ts +208 -0
  71. package/dist/src/github-app/event-source.js +684 -0
  72. package/dist/src/github-app/metrics.d.ts +32 -0
  73. package/dist/src/github-app/metrics.js +49 -0
  74. package/dist/src/github-app/review-loop.d.ts +274 -0
  75. package/dist/src/github-app/review-loop.js +1177 -0
  76. package/dist/src/github-app/review-node.d.ts +81 -0
  77. package/dist/src/github-app/review-node.js +205 -0
  78. package/dist/src/github-app/review-post.d.ts +73 -0
  79. package/dist/src/github-app/review-post.js +139 -0
  80. package/dist/src/github-app/review-text.d.ts +107 -0
  81. package/dist/src/github-app/review-text.js +1133 -0
  82. package/dist/src/github-app/review-threads.d.ts +47 -0
  83. package/dist/src/github-app/review-threads.js +107 -0
  84. package/dist/src/github-app/reviewer.d.ts +121 -0
  85. package/dist/src/github-app/reviewer.js +598 -0
  86. package/dist/src/github-app/store.d.ts +59 -0
  87. package/dist/src/github-app/store.js +148 -0
  88. package/dist/src/github-app/triggers.d.ts +141 -0
  89. package/dist/src/github-app/triggers.js +441 -0
  90. package/dist/src/github-names.d.ts +8 -0
  91. package/dist/src/github-names.js +8 -0
  92. package/dist/src/glob-search.d.ts +61 -0
  93. package/dist/src/glob-search.js +180 -0
  94. package/dist/src/graph-health.js +6 -1
  95. package/dist/src/graph-manager-chat.js +1 -1
  96. package/dist/src/graph-preview.d.ts +46 -0
  97. package/dist/src/graph-preview.js +55 -0
  98. package/dist/src/graph-provider-portability.js +2 -1
  99. package/dist/src/graph-runner.js +64 -3
  100. package/dist/src/graph-server.js +3 -3
  101. package/dist/src/graph-sync.js +3 -3
  102. package/dist/src/graph-ui/app.js +91 -7
  103. package/dist/src/graph-ui/icons.js +2 -1
  104. package/dist/src/graph-ui/studio.js +15 -1
  105. package/dist/src/graph-ui/tokens.css +1 -1
  106. package/dist/src/graphs.d.ts +34 -1
  107. package/dist/src/graphs.js +158 -14
  108. package/dist/src/image-input.d.ts +16 -0
  109. package/dist/src/image-input.js +41 -0
  110. package/dist/src/membership.d.ts +10 -0
  111. package/dist/src/membership.js +19 -4
  112. package/dist/src/model-health-cache.js +1 -1
  113. package/dist/src/model-metadata.d.ts +6 -0
  114. package/dist/src/model-metadata.js +35 -15
  115. package/dist/src/model-relay/local.d.ts +116 -0
  116. package/dist/src/model-relay/local.js +468 -0
  117. package/dist/src/model-relay/remote.d.ts +129 -0
  118. package/dist/src/model-relay/remote.js +252 -0
  119. package/dist/src/model-relay/runs.d.ts +34 -0
  120. package/dist/src/model-relay/runs.js +146 -0
  121. package/dist/src/model-relay/wire.d.ts +5 -0
  122. package/dist/src/model-relay/wire.js +5 -0
  123. package/dist/src/project-registry.d.ts +21 -0
  124. package/dist/src/project-registry.js +74 -0
  125. package/dist/src/provider-import.d.ts +0 -12
  126. package/dist/src/provider-import.js +7 -195
  127. package/dist/src/providers.d.ts +23 -2
  128. package/dist/src/providers.js +25 -4
  129. package/dist/src/pull-request-logs.d.ts +12 -1
  130. package/dist/src/pull-request-logs.js +14 -3
  131. package/dist/src/pull-requests.d.ts +327 -7
  132. package/dist/src/pull-requests.js +429 -51
  133. package/dist/src/react-runtime.js +1 -1
  134. package/dist/src/remote/engine-pool.d.ts +88 -4
  135. package/dist/src/remote/engine-pool.js +366 -89
  136. package/dist/src/remote/roots.d.ts +19 -0
  137. package/dist/src/remote/roots.js +45 -7
  138. package/dist/src/remote/types.d.ts +0 -44
  139. package/dist/src/run-control.d.ts +7 -0
  140. package/dist/src/run-control.js +23 -0
  141. package/dist/src/run-records.d.ts +7 -2
  142. package/dist/src/run-records.js +71 -6
  143. package/dist/src/runtime.d.ts +5 -1
  144. package/dist/src/runtime.js +10 -2
  145. package/dist/src/session-changes.d.ts +35 -0
  146. package/dist/src/session-changes.js +194 -6
  147. package/dist/src/session-monitor.js +2 -1
  148. package/dist/src/session-reaper.d.ts +1 -1
  149. package/dist/src/session-reaper.js +6 -1
  150. package/dist/src/session-summary.d.ts +2 -1
  151. package/dist/src/session-summary.js +2 -1
  152. package/dist/src/sessions.d.ts +11 -1
  153. package/dist/src/sessions.js +17 -4
  154. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  155. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  156. package/dist/src/skills/bundled/provenance.json +2 -2
  157. package/dist/src/skills/runtime-skills.js +1 -1
  158. package/dist/src/telemetry/emitter.d.ts +15 -0
  159. package/dist/src/telemetry/emitter.js +35 -1
  160. package/dist/src/telemetry/schema.d.ts +25 -2
  161. package/dist/src/telemetry/schema.js +52 -4
  162. package/dist/src/telemetry/surface.d.ts +2 -1
  163. package/dist/src/telemetry/surface.js +4 -1
  164. package/dist/src/terminal-ui.d.ts +1 -0
  165. package/dist/src/terminal-ui.js +10 -3
  166. package/dist/src/test-edit-guard.d.ts +7 -0
  167. package/dist/src/test-edit-guard.js +49 -1
  168. package/dist/src/timers.d.ts +2 -0
  169. package/dist/src/tools.js +59 -9
  170. package/package.json +6 -1
  171. package/dist/src/remote/cert.d.ts +0 -11
  172. package/dist/src/remote/cert.js +0 -87
  173. package/dist/src/remote/client.d.ts +0 -119
  174. package/dist/src/remote/client.js +0 -544
  175. package/dist/src/remote/command.d.ts +0 -4
  176. package/dist/src/remote/command.js +0 -194
  177. package/dist/src/remote/errors.d.ts +0 -11
  178. package/dist/src/remote/errors.js +0 -14
  179. package/dist/src/remote/network.d.ts +0 -22
  180. package/dist/src/remote/network.js +0 -102
  181. package/dist/src/remote/pairing.d.ts +0 -63
  182. package/dist/src/remote/pairing.js +0 -299
  183. package/dist/src/remote/pem.d.ts +0 -2
  184. package/dist/src/remote/pem.js +0 -7
  185. package/dist/src/remote/serve.d.ts +0 -68
  186. package/dist/src/remote/serve.js +0 -244
  187. package/dist/src/remote/server.d.ts +0 -21
  188. package/dist/src/remote/server.js +0 -406
package/dist/src/cli.js CHANGED
@@ -14,12 +14,12 @@ import { homedir } from 'node:os';
14
14
  import { workspacePermissionKey, permissionLabel } from './permissions.js';
15
15
  import { configDirectory, loadConfig, resolveCodeIntelConfig, resolveConfiguredLimits, saveConfig } from './config.js';
16
16
  import { andorraRefusal, compactHistory, compactedContextEstimate, executeCommand, HELP } from './commands.js';
17
- import { applyModelContextWindow, createAdapter, findProviderById, providerModelId, modelDisplayName, modelIdForDisplayName, providerModelNames, providerSecrets, recordProviderModel } from './providers.js';
17
+ import { applyModelContextWindow, createAdapter, findProviderById, providerModelId, modelDisplayName, modelIdForDisplayName, providerModelNames, providerSecrets, recordProviderModel, runProvider } from './providers.js';
18
18
  import { disposeAllQaProcesses, disposeAllQaPtys, getQaPtyManager } from './qa/index.js';
19
19
  import { disposePooledPowerShell } from './powershell-pool.js';
20
20
  import { loadWorkspaceInstructions, systemPromptOverrideFor } from './workspace-instructions.js';
21
21
  import { runGraph, stopReasonPhrase } from './runtime.js';
22
- import { GraphDeletedError, validateGraph } from './graphs.js';
22
+ import { GraphDeletedError, REVIEWER_GRAPH_ID, graphMcpServers, isolatedGraph, validateGraph } from './graphs.js';
23
23
  import { checkGraphModelHealth, checkSessionModelHealth, formatGraphHealthFailure } from './graph-health.js';
24
24
  import { ModelHealthCache } from './model-health-cache.js';
25
25
  import { currentGraphSelection, getMembership, loadAccessibleGraph, PaidMembershipRequiredError } from './membership.js';
@@ -47,6 +47,12 @@ function offerSkillCommands(terminal, config, directory) {
47
47
  return;
48
48
  void listInvocableSkills(config, undefined, directory).then(skills => terminal.setSkillCommands(skills), () => { });
49
49
  }
50
+ /** True when `next` is `current` with only the selected provider changed: how the provider manager saves a selection. */
51
+ function sameConfigExceptProvider(current, next) {
52
+ const { provider: currentProvider, ...restCurrent } = current;
53
+ const { provider: nextProvider, ...restNext } = next;
54
+ return currentProvider !== nextProvider && JSON.stringify(restCurrent) === JSON.stringify(restNext);
55
+ }
50
56
  import { meterStreamedRequest } from './token-rate.js';
51
57
  import { attachmentLabel, attachmentReadRoots, attachmentReferenceBlock, pruneAttachments, readClipboardImage, resolveAttachments, writeClipboardText } from './attachments.js';
52
58
  import { describeTool, formatAnswer, formatEvent, formatRunResult } from './transcript.js';
@@ -55,7 +61,7 @@ import { LocalToolMemory } from './memory/LocalToolMemory.js';
55
61
  import { ProjectMemory } from './memory/ProjectMemory.js';
56
62
  import { askClarification } from './clarification-ui.js';
57
63
  import { configuredModelSnapshot, refreshModelContext, resolveModelContext, withEvaluationReasoningEffort } from './model-metadata.js';
58
- import { isScreenCommand, pickPermissionMode, pickProviderModel, runCommandScreen, withSelectedModel } from './command-screens.js';
64
+ import { isScreenCommand, pickPermissionMode, pickProviderModel, retireDroppedAccounts, runCommandScreen, SelectionReverted, withSelectedModel } from './command-screens.js';
59
65
  import { liveModelTarget } from './live-model.js';
60
66
  import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
61
67
  import { ToolActivity, activityForRuntimeEvent } from './tool-activity.js';
@@ -68,7 +74,7 @@ import { setAuthSignOutReporter } from './auth/index.js';
68
74
  import { getAccountPresentation } from './account-presentation.js';
69
75
  import { acquireSessionMutationLock, clearOpenRunClaim, createCheckpointFailureTracker, removeRunCheckpoint, RUNNING_TURN_SUMMARY, reconcileInterruptedRuns, runRecordPath, runRecordsDirectory, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
70
76
  import { gitChangeSummary } from './git-summary.js';
71
- import { writeActivity } from './activity.js';
77
+ import { writeActivity as writeSharedActivity } from './activity.js';
72
78
  import { TodoStore } from './todos.js';
73
79
  import { canExtendLineage, carryRailOwnedFields, displayHistory, lineagePoints, lineageThrough, SessionStore, sessionName, projectIdentity } from './sessions.js';
74
80
  import { SessionTitle } from './session-title.js';
@@ -324,13 +330,17 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
324
330
  return runAutomationCommand(argv.slice(1), line => process.stdout.write(line + '\n'));
325
331
  }
326
332
  if (argv[0] === 'remote') {
327
- const { REMOTE_USAGE, runRemoteCommand } = await import('./remote/command.js');
333
+ process.stdout.write('Remote pairing was replaced by the bridge. Run "andorra bridge link" on the machine you want to use. See docs/guides/desktop-app.md.\n');
334
+ return 1;
335
+ }
336
+ if (argv[0] === 'bridge') {
337
+ const { bridgeUsage, runBridgeCommand } = await import('./bridge/command.js');
328
338
  if (argv.includes('--help') || argv.includes('-h')) {
329
- process.stdout.write(`${REMOTE_USAGE}\n`);
339
+ process.stdout.write(`${bridgeUsage()}\n`);
330
340
  return 0;
331
341
  }
332
342
  const version = await cliVersion().catch(() => '0.0.0');
333
- return await runRemoteCommand(argv.slice(1), line => process.stdout.write(safeTerminal(line) + '\n'), { version });
343
+ return await runBridgeCommand(argv.slice(1), line => process.stdout.write(safeTerminal(line) + '\n'), { version });
334
344
  }
335
345
  if (argv[0] === 'setup') {
336
346
  if (argv.length !== 1)
@@ -368,7 +378,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
368
378
  let terminal;
369
379
  const print = (text) => terminal ? terminal.print(text) : process.stdout.write(safeTerminal(text) + '\n');
370
380
  if (values.help) {
371
- print(`Andorra Code\nUsage: andorra [--cwd path] [--provider id] [--model id] [--graph id] [--run-input file.json] [--run-state file.json] [--goal "text"] [--yolo] [--jev on|off] [--debug]\n andorra --prompt "task" [--json] [--yolo] [--jev on|off] [--tools default|coding] [--debug]\n andorra subagent --prompt "task" [--provider id] [--model id] [--read-only]\n andorra graph [--no-open]\n andorra automations list|run|service|serve\n andorra app-server --stdio\n andorra acp\n andorra mcp-server --stdio\n andorra remote serve|status|code|devices|revoke|share|unshare|pair|workspaces|unpair|rotate-cert\n andorra update\n andorra login [--no-browser]\n andorra logout [--all]\n andorra auth status\n\n${HELP}`);
381
+ print(`Andorra Code\nUsage: andorra [--cwd path] [--provider id] [--model id] [--graph id] [--run-input file.json] [--run-state file.json] [--goal "text"] [--yolo] [--jev on|off] [--debug]\n andorra --prompt "task" [--json] [--yolo] [--jev on|off] [--tools default|coding] [--debug]\n andorra subagent --prompt "task" [--provider id] [--model id] [--read-only]\n andorra graph [--no-open]\n andorra automations list|run|service|serve\n andorra app-server --stdio\n andorra acp\n andorra mcp-server --stdio\n andorra bridge link|run|status|unlink|folders\n andorra update\n andorra login [--no-browser]\n andorra logout [--all]\n andorra auth status\n\n${HELP}`);
372
382
  return 0;
373
383
  }
374
384
  if (values.version) {
@@ -439,6 +449,16 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
439
449
  values.graph = currentGraphSelection(values.graph);
440
450
  if (values.graph && values.graph !== 'default')
441
451
  await startupGuard(() => loadGraph(values.graph));
452
+ // The review loop's reviewer reads a pull request's head in a throwaway worktree and its findings are posted publicly:
453
+ // it runs in the ask-for-approval mode whatever is saved, so a headless run refuses every read outside that worktree.
454
+ const reviewerRun = values.graph === REVIEWER_GRAPH_ID;
455
+ if (reviewerRun && values.yolo)
456
+ await startupReject(`--yolo cannot be used with the ${REVIEWER_GRAPH_ID} graph`);
457
+ // A run the review loop started (ANDORRA_SESSION_ORIGIN=andorra-review, the only value taken) saves its session with that
458
+ // origin, which keeps it out of every task list while it can still be opened by id. Nor does it report its activity,
459
+ // which belongs to the person's own task.
460
+ const sessionOrigin = process.env.ANDORRA_SESSION_ORIGIN === 'andorra-review' ? 'andorra-review' : undefined;
461
+ const writeActivity = (...args) => sessionOrigin ? Promise.resolve() : writeSharedActivity(...args);
442
462
  if (values.json && !values.prompt)
443
463
  await startupReject('--json requires --prompt');
444
464
  if (values.tools !== undefined && !values.prompt)
@@ -496,7 +516,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
496
516
  }
497
517
  });
498
518
  bootMark('cli.config');
499
- const permissions = values.yolo ? 'full-access' : config.workspacePermissions?.[workspacePermissionKey(workspace)] ?? 'ask-for-approval';
519
+ const permissions = reviewerRun ? 'ask-for-approval' : values.yolo ? 'full-access' : config.workspacePermissions?.[workspacePermissionKey(workspace)] ?? 'ask-for-approval';
500
520
  if (values.jev === 'on' && config.jevEnabled === false)
501
521
  process.stderr.write('--jev on has no effect: the Global Jev switch is off. Turn it on with /jev global on or in Settings.\n');
502
522
  const jevOn = () => config.jevEnabled !== false && state.jev !== false;
@@ -647,7 +667,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
647
667
  const homeWorkspace = workspace === await realpath(homedir()).catch(() => homedir());
648
668
  const codeIntelOpening = CodeIntelligenceManager.create({
649
669
  permissions: state.permissions,
650
- config: homeWorkspace ? { ...resolveCodeIntelConfig(config), enabled: false, enabledRepos: [] } : resolveCodeIntelConfig(config), workspace,
670
+ config: homeWorkspace || reviewerRun ? { ...resolveCodeIntelConfig(config), enabled: false, enabledRepos: [] } : resolveCodeIntelConfig(config), workspace,
651
671
  onEvent: event => (runEventSink ?? codeIntelNotice)(event),
652
672
  });
653
673
  codeIntelOpening.catch(() => { });
@@ -983,7 +1003,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
983
1003
  browserPrompt = task;
984
1004
  trajectory.addSecrets(providerSecrets(config.providers));
985
1005
  if (!savedSession) {
986
- savedSession = { version: 1, id: trajectory.sessionId, name: sessionName(task), workspace, updatedAt: new Date().toISOString(), history: [], usage: { ...state.usage } };
1006
+ savedSession = { version: 1, id: trajectory.sessionId, name: sessionName(task), workspace, updatedAt: new Date().toISOString(), history: [], usage: { ...state.usage }, ...(sessionOrigin ? { origin: sessionOrigin } : {}) };
987
1007
  noteSessionStarted({ workspace });
988
1008
  }
989
1009
  const accepted = browserAcceptance;
@@ -1173,6 +1193,87 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1173
1193
  // (getLiveModel below), so the change lands at the run's next request, paused or not.
1174
1194
  let liveSelection;
1175
1195
  let switchRunModel;
1196
+ // The providers this run started with: a provider deleted while the run works is still resolved from here,
1197
+ // so the running task keeps the model it began with instead of failing with "Unknown provider".
1198
+ const runProviders = structuredClone(config.providers);
1199
+ // Providers the live manager dropped while this run works. Their Codex and Claude Console sign-ins are what the
1200
+ // run's requests still authenticate with, so they are retired when the run ends, and only if still dropped then.
1201
+ const droppedDuringRun = [];
1202
+ // Choosing a provider while the run works moves this run at its next model request, the way /model does.
1203
+ // The provider's own configured model is the one asked for; the switch persists it and rolls back on failure.
1204
+ // Returns whether the run actually moved, so a caller that saves the choice can keep a refusal out of memory.
1205
+ const switchLiveProvider = async (id) => {
1206
+ // An explicit selection takes the provider as configured now (its saved model included), not the run's copy.
1207
+ const target = config.providers.find(item => item.id === id);
1208
+ if (!target) {
1209
+ print(`Provider unchanged: ${id} is no longer configured, so this run keeps its current provider.`);
1210
+ return false;
1211
+ }
1212
+ if (!switchRunModel) {
1213
+ print('This run is still starting. Type /providers again in a moment.');
1214
+ return false;
1215
+ }
1216
+ return await switchRunModel({ provider: target.id, model: target.model });
1217
+ };
1218
+ // The provider manager while this run works: the same screens as between tasks, under the run-scoped
1219
+ // controller and yielding to the run's questions. Adding, editing or deleting saves configuration only;
1220
+ // selecting a provider is routed to switchLiveProvider instead of the between-tasks save.
1221
+ const liveProviderScreen = async () => {
1222
+ if (!terminal)
1223
+ return;
1224
+ // While the run is still starting (graph checks, provider preflight) it reads the configuration directly, so the
1225
+ // manager opens once that is done, the way /model does.
1226
+ if (!switchRunModel) {
1227
+ print('This run is still starting. Type /providers again in a moment.');
1228
+ return;
1229
+ }
1230
+ const ui = terminal;
1231
+ let selected;
1232
+ const liveUI = {
1233
+ question: (prompt, options) => ui.question(prompt, { ...options, yieldToQuestions: true }),
1234
+ print: text => ui.print(text),
1235
+ loadScreen: (title, load, options) => ui.loadScreen(title, load, { ...options, yieldToQuestions: true }),
1236
+ showScreen: (title, lines, options) => ui.showScreen(title, lines, { ...options, yieldToQuestions: true }),
1237
+ select: async (title, items, options) => {
1238
+ const picked = await ui.select(title, items, { ...options, yieldToQuestions: true });
1239
+ // The top list: choosing a configured provider ends the manager without saving, so the switch below
1240
+ // owns the change and this run moves at its next model request.
1241
+ if (picked !== undefined && title === 'Providers' && items.some(item => item.id === ':add')
1242
+ && state.config.providers.some(item => item.id === picked)) {
1243
+ selected = picked;
1244
+ return undefined;
1245
+ }
1246
+ return picked;
1247
+ },
1248
+ };
1249
+ try {
1250
+ state.retireAccounts = async (previous) => { droppedDuringRun.push(...structuredClone([...previous])); };
1251
+ await runCommandScreen('/providers', state, liveUI, async (draft) => {
1252
+ // A provider-only draft is the manager's own selection (the listed Andorra row among them).
1253
+ if (draft.provider !== state.config.provider && sameConfigExceptProvider(state.config, draft)) {
1254
+ // A refused switch must not reach memory: the enclosing save would otherwise reinstate the rejected
1255
+ // provider after the switch had already rolled the configuration back.
1256
+ if (!await switchLiveProvider(draft.provider))
1257
+ throw new SelectionReverted();
1258
+ return;
1259
+ }
1260
+ await persistConfig(draft);
1261
+ }, livePicker.signal, undefined, undefined, (signal, mode) => graphEditor.open(signal, mode));
1262
+ }
1263
+ catch (error) {
1264
+ if (!(error instanceof Error && error.name === 'AbortError'))
1265
+ throw error;
1266
+ if (!livePicker.signal.aborted && !exiting)
1267
+ print('Providers unchanged: the run asked a question, so the manager closed. Type /providers again afterwards.');
1268
+ return;
1269
+ }
1270
+ finally {
1271
+ delete state.retireAccounts;
1272
+ }
1273
+ if (selected === undefined || livePicker.signal.aborted || exiting)
1274
+ return;
1275
+ await switchLiveProvider(selected);
1276
+ };
1176
1277
  terminal?.setRunInputHandler(text => {
1177
1278
  if (!text.startsWith('/')) {
1178
1279
  void debugRecord('command.steer', { input: text });
@@ -1206,9 +1307,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1206
1307
  print('Compacting the run’s context, then continuing it.');
1207
1308
  return true;
1208
1309
  }
1209
- if (!['/model', '/browser', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools'].includes(command)) {
1310
+ if (!['/model', '/providers', '/browser', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools'].includes(command)) {
1210
1311
  void debugRecord('command.steer', { input: text });
1211
- print(`${command} is unavailable during a run. Use /model, /permissions <mode>, /yolo on|off, /jev on|off, /compact, /status, /usage, /help, or /exit.`);
1312
+ print(`${command} is unavailable during a run. Use /model, /providers, /permissions <mode>, /yolo on|off, /jev on|off, /compact, /status, /usage, /help, or /exit.`);
1212
1313
  return true;
1213
1314
  }
1214
1315
  const commandStartedAt = Date.now();
@@ -1225,6 +1326,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1225
1326
  openBrowserUrl(browserApp.url);
1226
1327
  }
1227
1328
  }
1329
+ else if (command === '/providers' && text.trim() === '/providers') {
1330
+ await liveProviderScreen();
1331
+ }
1228
1332
  else if (command === '/model') {
1229
1333
  const argument = text.trim().slice('/model'.length).trim();
1230
1334
  if (!switchRunModel) {
@@ -1383,12 +1487,16 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1383
1487
  graph: { id: graph.id, revision: graph.revision }
1384
1488
  }).catch(() => { });
1385
1489
  terminal?.setStatus({ activity: 'Thinking' });
1386
- const workspaceGuidance = await preflight(signal => loadWorkspaceInstructions(workspace, signal, systemPromptOverrideFor(graph, config.systemPromptOverride)));
1387
- const invocations = isBuiltinSlashCommand(task) ? [] : await preflight(signal => resolveSkillInvocations(task, effectiveExtensionConfig(config, workspace), signal, directory));
1388
- const runSkill = await preflight(signal => skillForRun({ invocations, home: directory, sessionId: savedSession?.id, config: effectiveExtensionConfig(config, workspace), signal }));
1490
+ // An isolated graph (the review loop's reviewer) reads none of the person's context: no project guide, skills, skill
1491
+ // catalog or MCP servers. runGraph strips what reaches it anyway; this keeps them from being read or started at all.
1492
+ const isolated = isolatedGraph(graph.id);
1493
+ const workspaceGuidance = isolated ? '' : await preflight(signal => loadWorkspaceInstructions(workspace, signal, systemPromptOverrideFor(graph, config.systemPromptOverride)));
1494
+ const invocations = isolated || isBuiltinSlashCommand(task) ? [] : await preflight(signal => resolveSkillInvocations(task, effectiveExtensionConfig(config, workspace), signal, directory));
1495
+ const runSkill = isolated ? {} : await preflight(signal => skillForRun({ invocations, home: directory, sessionId: savedSession?.id, config: effectiveExtensionConfig(config, workspace), signal }));
1389
1496
  if (runSkill.notice)
1390
1497
  terminal ? terminal.print(runSkill.notice) : process.stderr.write(safeTerminal(runSkill.notice) + '\n');
1391
- const snapshot = await preflight(signal => extensionSnapshot(effectiveExtensionConfig(config, workspace), signal, directory, runSkill.skills?.map(skill => skill.id)));
1498
+ const snapshot = isolated ? { instructions: '', servers: {}, tools: [], notices: [], claimsSkillName: () => false }
1499
+ : await preflight(signal => extensionSnapshot(effectiveExtensionConfig(config, workspace), signal, directory, runSkill.skills?.map(skill => skill.id)));
1392
1500
  for (const notice of snapshot.notices)
1393
1501
  terminal ? terminal.print(notice) : process.stderr.write(safeTerminal(notice) + '\n');
1394
1502
  const instructions = `${workspaceGuidance}${snapshot.instructions}`;
@@ -1434,7 +1542,8 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1434
1542
  }
1435
1543
  };
1436
1544
  runEventSink = onRunEvent;
1437
- mcp = Object.keys(snapshot.servers).length ? await preflight(async (signal) => {
1545
+ const mcpServers = graphMcpServers(graph.id, snapshot.servers);
1546
+ mcp = Object.keys(mcpServers).length ? await preflight(async (signal) => {
1438
1547
  const extensionContext = { workspace, signal, runControl, get yolo() { return state.yolo; }, get permissions() { return state.permissions; },
1439
1548
  onApprovalEvent: (type, data) => onRunEvent({ type, time: new Date().toISOString(), data: { ...data, runId } }),
1440
1549
  approvalMode: terminal ? 'interactive' : 'headless', approve: async (name, args, signal) => {
@@ -1462,7 +1571,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1462
1571
  }
1463
1572
  } };
1464
1573
  const mcpModule = await import('./mcp.js');
1465
- return mcpModule.connectMcpServers(snapshot.servers, extensionContext, message => terminal ? terminal.print(message) : process.stderr.write(safeTerminal(message) + '\n'), active.signal, { status: mcpModule.mcpTaskStatusReporter(configDirectory()) });
1574
+ return mcpModule.connectMcpServers(mcpServers, extensionContext, message => terminal ? terminal.print(message) : process.stderr.write(safeTerminal(message) + '\n'), active.signal, { status: mcpModule.mcpTaskStatusReporter(configDirectory()) });
1466
1575
  }) : { tools: [], close: async () => { } };
1467
1576
  if (terminal) {
1468
1577
  try {
@@ -1497,10 +1606,10 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1497
1606
  const decisionPolicy = hostedDecisionPolicy(membership, jevOn(), config.decisions);
1498
1607
  jevEnabled = jevOn();
1499
1608
  terminal?.setStatus({ graph, jevEnabled, jevOffThisRun: jevEnabled && !membership.subject });
1500
- const commandMemory = config.commandMemory === false ? undefined : await LocalToolMemory.open({ workspace, directory });
1501
- const projectMemory = config.projectMemory === false ? undefined : await ProjectMemory.open({ home: directory, workspace });
1609
+ const commandMemory = config.commandMemory === false || isolated ? undefined : await LocalToolMemory.open({ workspace, directory });
1610
+ const projectMemory = config.projectMemory === false || isolated ? undefined : await ProjectMemory.open({ home: directory, workspace });
1502
1611
  const resolveRunModel = (id, model, wait = preflight) => {
1503
- const provider = config.providers.find(item => item.id === id);
1612
+ const provider = runProvider(config, runProviders, id);
1504
1613
  if (!provider)
1505
1614
  throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
1506
1615
  const wanted = model || runDefaults.get(id) || provider.model;
@@ -1519,23 +1628,49 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1519
1628
  const wakeCarry = { provider: selected.id, model: selected.model, graph: runGraphSelection,
1520
1629
  ...(selected.reasoningEffort === undefined ? {} : { reasoningEffort: selected.reasoningEffort }) };
1521
1630
  switchRunModel = async (target) => {
1522
- const provider = config.providers.find(item => item.id === target.provider);
1631
+ // A switch to another provider or model moves the run onto that provider as configured now, edits included.
1632
+ const provider = config.providers.find(item => item.id === target.provider) ?? runProvider(config, runProviders, target.provider);
1523
1633
  if (!provider)
1524
1634
  throw new Error(`Unknown provider: ${target.provider}. Use /providers to add or edit providers.`);
1525
1635
  const refusal = andorraRefusal(state, provider.id);
1526
1636
  if (refusal) {
1527
1637
  print(refusal);
1528
- return;
1638
+ return false;
1529
1639
  }
1530
1640
  const from = liveSelection ?? { provider: selected.id, model: selected.model };
1531
1641
  const label = `${provider.id}/${modelDisplayName(provider, target.model)}`;
1532
1642
  if (from.provider === target.provider && from.model === target.model) {
1533
- print(`Model unchanged: this run already uses ${label}.`);
1534
- return;
1643
+ // The model in use is not reloaded mid-run: edits saved to its provider (endpoint, key, protocol) apply from
1644
+ // the next task, as every configuration change during a run does. Say so rather than imply they took effect.
1645
+ const runEntry = runProviders.find(item => item.id === provider.id);
1646
+ const edited = runEntry !== undefined && JSON.stringify(runEntry) !== JSON.stringify(provider);
1647
+ print(`Model unchanged: this run already uses ${label}.${edited ? ' Changes saved to this provider apply from the next task.' : ''}`);
1648
+ return true;
1535
1649
  }
1536
1650
  // Saved the way /model saves it between tasks, so the next task starts on the same model. The
1537
1651
  // conversation is kept: the run carries on with what it has.
1538
1652
  const restored = structuredClone(config);
1653
+ // The run's own entry for this provider takes the configured settings, and anything resolved from the old
1654
+ // entry is forgotten; a provider added during the run joins the run's providers, so deleting it later
1655
+ // leaves the run working. A failed switch puts all of it back.
1656
+ const entry = runProviders.findIndex(item => item.id === provider.id);
1657
+ const runEntry = entry >= 0 ? runProviders[entry] : undefined;
1658
+ const edited = runEntry !== undefined && JSON.stringify(runEntry) !== JSON.stringify(provider);
1659
+ // A provider and model this run already used are not reloaded: its agents keep the adapter they hold (the
1660
+ // engine replaces one only when the provider or model changes), so the run stays on its own settings and the
1661
+ // edits apply from the next task, as they do for the model in use.
1662
+ const keepsSettings = edited && resolvedModels.has(JSON.stringify([provider.id, target.model]));
1663
+ const adopt = edited && !keepsSettings;
1664
+ const added = runEntry === undefined;
1665
+ const forget = () => { for (const key of [...resolvedModels.keys()])
1666
+ if (JSON.parse(key)[0] === provider.id)
1667
+ resolvedModels.delete(key); };
1668
+ if (adopt) {
1669
+ runProviders[entry] = structuredClone(provider);
1670
+ forget();
1671
+ }
1672
+ if (added)
1673
+ runProviders.push(structuredClone(provider));
1539
1674
  const draft = withSelectedModel(config, provider.id, target.model);
1540
1675
  let saved = true;
1541
1676
  try {
@@ -1554,11 +1689,20 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1554
1689
  if (saved)
1555
1690
  await persistConfig(restored).catch(() => { });
1556
1691
  Object.assign(config, restored);
1692
+ if (adopt) {
1693
+ runProviders[entry] = runEntry;
1694
+ forget();
1695
+ }
1696
+ if (added) {
1697
+ const index = runProviders.findIndex(item => item.id === provider.id);
1698
+ if (index >= 0)
1699
+ runProviders.splice(index, 1);
1700
+ }
1557
1701
  refreshStatus();
1558
1702
  if (active.signal.aborted || livePicker.signal.aborted)
1559
- return;
1703
+ return true;
1560
1704
  print(`Model not changed: ${label} could not be loaded (${error instanceof Error ? error.message : String(error)}). This run stays on ${from.provider}/${from.model}.`);
1561
- return;
1705
+ return false;
1562
1706
  }
1563
1707
  liveSelection = { provider: provider.id, model: target.model, overrideAllNodes: false };
1564
1708
  wakeCarry.provider = provider.id;
@@ -1574,8 +1718,10 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1574
1718
  const pinned = Object.values(graph.nodes).filter(node => node.type === 'agent' && node.provider !== undefined).length;
1575
1719
  print(`Model: ${label}. This run uses it from its next model request${runControl?.isPaused ? ' (send a message to resume)' : ''}.`
1576
1720
  + (pinned ? ` ${pinned} graph node${pinned === 1 ? ' names its' : 's name their'} own model and keep${pinned === 1 ? 's' : ''} it.` : '')
1721
+ + (keepsSettings ? ` This run already used it, so changes saved to ${provider.id} apply from the next task.` : '')
1577
1722
  + (saved ? '' : ' The configuration could not be saved, so the next task starts on the previous model.'));
1578
1723
  refreshStatus();
1724
+ return true;
1579
1725
  };
1580
1726
  const execute = (options) => runGraph(graph, { ...options, runInput, runState, commandMemory, projectMemory, todoStore,
1581
1727
  ...(runSkill.skills?.length ? { inheritedSkills: runSkill.skills.map(skill => skill.id), skillInvocationInstruction: runSkill.instruction } : {}),
@@ -1588,7 +1734,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1588
1734
  const target = liveModelTarget(current, graph.nodes, nodeId);
1589
1735
  if (!target)
1590
1736
  return undefined;
1591
- const effective = target.model ?? runDefaults.get(target.provider) ?? config.providers.find(item => item.id === target.provider)?.model;
1737
+ const effective = target.model ?? runDefaults.get(target.provider) ?? runProvider(config, runProviders, target.provider)?.model;
1592
1738
  if (target.provider === currentProvider && effective === currentModel)
1593
1739
  return undefined;
1594
1740
  const resolved = await resolveRunModel(target.provider, target.model);
@@ -1598,7 +1744,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1598
1744
  }
1599
1745
  },
1600
1746
  resolveProvider: id => {
1601
- const provider = config.providers.find(item => item.id === id);
1747
+ const provider = runProvider(config, runProviders, id);
1602
1748
  if (!provider)
1603
1749
  throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
1604
1750
  const snapshot = withEvaluationReasoningEffort(runtimeProvider(configuredModelSnapshot(provider, runDefaults.get(id))), process.env.ANDORRA_EVAL_REASONING_EFFORT);
@@ -1789,6 +1935,10 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1789
1935
  livePicker.abort();
1790
1936
  await checkpointWrites;
1791
1937
  await liveCommands;
1938
+ // The run no longer needs them: retire the sign-ins of providers the live manager dropped, unless a later
1939
+ // change in this run brought the provider (or its account) back.
1940
+ if (droppedDuringRun.length)
1941
+ await retireDroppedAccounts(droppedDuringRun.splice(0), config.providers).catch(() => { });
1792
1942
  await mcp?.close();
1793
1943
  state.usage.requests += activeUsage.requests;
1794
1944
  state.usage.inputTokens += activeUsage.inputTokens;
@@ -1877,7 +2027,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1877
2027
  const previousSession = savedSession;
1878
2028
  browserPrompt = text;
1879
2029
  if (!savedSession)
1880
- savedSession = { version: 1, id: trajectory.sessionId, name: sessionName(text), workspace, updatedAt: new Date().toISOString(), history: [], usage: { ...state.usage } };
2030
+ savedSession = { version: 1, id: trajectory.sessionId, name: sessionName(text), workspace, updatedAt: new Date().toISOString(), history: [], usage: { ...state.usage }, ...(sessionOrigin ? { origin: sessionOrigin } : {}) };
1881
2031
  else
1882
2032
  savedSession = { ...savedSession, updatedAt: new Date().toISOString() };
1883
2033
  const record = { projectId: projectIdentity(workspace), ...savedSession, history: sessionArchive, contextHistory: state.history ?? [] };
@@ -2014,7 +2164,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
2014
2164
  sessionTimers.clear();
2015
2165
  timerPending.length = 0;
2016
2166
  timerSteering.length = 0;
2017
- const { archived: _archived, autoArchived: _autoArchived, ...resumedRecord } = record;
2167
+ const { archived: _archived, autoArchived: _autoArchived, pinned: _pinned, ...resumedRecord } = record;
2018
2168
  savedSession = { ...resumedRecord, id: randomUUID(), parentId: record.id,
2019
2169
  ancestors: lineageThrough(record.ancestors, record.id), inheritedUsage: { ...record.usage },
2020
2170
  inheritedTurns: record.history.length, lineage: lineagePoints(record, record.usage, record.history.length) };
@@ -25,6 +25,7 @@ import { claimReadImages, readImageObservation } from './read-image.js';
25
25
  import { READ_PDF_RENDER_PAGES, legacyTextObservation, pdfOnlyArgumentsIgnored, readDocumentObservation } from './read-document-tool.js';
26
26
  import { assertCommandAvoidsHarnessHome, guardsHarnessHome, withoutHarnessHomeLines } from './harness-home.js';
27
27
  import { privateRunTemp } from './run-temp.js';
28
+ import { completeGlobMatches, formatGlobResult, globSearch } from './glob-search.js';
28
29
  // Runs an agent command with the stray-file notice and, around it, the commit identity audit. The audit
29
30
  // starts git on the host, so it runs only when the command itself runs unrestricted on the host; a
30
31
  // restricted profile starts nothing it did not approve.
@@ -362,6 +363,16 @@ function zTool(name, description, parameters, executionMode, execute) {
362
363
  return { name, description, parameters, executionMode, execute };
363
364
  }
364
365
  export function createCodingTools(policy) {
366
+ // Restricted modes list files through the policy walk, which applies their protected roots; ripgrep would not.
367
+ function findFiles(context, pattern, root, limit) {
368
+ const restricted = context.pinFilePaths || (permissionMode(context) !== undefined && permissionMode(context) !== 'full-access');
369
+ return globSearch({
370
+ pattern, root, limit, signal: context.signal, rg: restricted ? null : andorraGetToolPath('rg'),
371
+ resolve: directory => policy.safePath(context, directory),
372
+ walk: (directory, budget) => policy.files(context, directory, 0, budget),
373
+ ...(guardsHarnessHome(context) ? { keep: (relative, cwd) => withoutHarnessHomeLines(relative, cwd) } : {}),
374
+ });
375
+ }
365
376
  function bound(context, beforeApproval) {
366
377
  const { workspace, signal } = context;
367
378
  const safe = (name, missing = false) => policy.safePath(context, name, missing);
@@ -395,17 +406,8 @@ export function createCodingTools(policy) {
395
406
  find: andorraCreateFindTool(workspace, { operations: {
396
407
  exists: async (name) => { await safe(name); return true; },
397
408
  glob: async (pattern, cwd, options) => {
398
- const matches = [];
399
409
  const root = await safe(cwd);
400
- for await (const name of policy.files(context, root)) {
401
- signal.throwIfAborted();
402
- const relative = path.relative(root, name).split(path.sep).join('/');
403
- if (path.matchesGlob(relative, pattern) || (!pattern.includes('/') && path.matchesGlob(path.basename(relative), pattern)))
404
- matches.push(name);
405
- if (matches.length >= options.limit)
406
- break;
407
- }
408
- return matches;
410
+ return completeGlobMatches(await findFiles(context, pattern, root, options.limit), root, options.limit);
409
411
  },
410
412
  } }),
411
413
  grep: andorraCreateGrepTool(workspace, { operations: {
@@ -503,7 +505,7 @@ export function createCodingTools(policy) {
503
505
  await remember(context, resolved, content, true, 'mutation');
504
506
  return `${existing ? 'Updated' : 'Created'} ${path.relative(context.workspace, resolved) || resolved} (${Buffer.byteLength(content)} bytes). File state is current; no Read-back is needed.`;
505
507
  });
506
- const Edit = zTool('Edit', 'Replace one exact old_string with new_string in a file. Copy old_string from observed current source; include only enough context to make it unique. Use replace_all only for an intentional repeated replacement. A file you have Read must still be fresh. A file you have not fully Read needs no separate Read first: the edit applies when old_string matches the current file, and otherwise fails and returns the file when it fits in one Read page. Failed matching leaves the file unchanged: inspect the reported area before retrying.', { type: 'object', properties: {
508
+ const Edit = zTool('Edit', 'Replace one exact old_string with new_string in a file. Copy old_string from observed current source; include only enough context to make it unique. Use replace_all only for an intentional repeated replacement. Several Edit calls in one turn, to different files or the same file, apply in the order listed, so send the edits for one change together. A file you have Read must still be fresh. A file you have not fully Read needs no separate Read first: the edit applies when old_string matches the current file, and otherwise fails and returns the file when it fits in one Read page. Failed matching leaves the file unchanged: inspect the reported area before retrying.', { type: 'object', properties: {
507
509
  file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
508
510
  edits: { type: 'array', minItems: 1, items: { type: 'object', properties: {
509
511
  old_string: { type: 'string' }, new_string: { type: 'string' },
@@ -645,7 +647,7 @@ export function createCodingTools(policy) {
645
647
  });
646
648
  return args;
647
649
  };
648
- const Glob = zTool('Glob', 'Find files by glob pattern inside the workspace. This replaces Andorra list_files and Pi find/ls with one bounded discovery tool. It matches names, not contents, so use it to find something by name (for example *deploy*) before searching file contents; raise head_limit when the result reaches the limit.', { type: 'object', properties: {
650
+ const Glob = zTool('Glob', 'Find files by glob pattern inside the workspace. This replaces Andorra list_files and Pi find/ls with one bounded discovery tool. It matches names, not contents, so use it to find something by name (for example *deploy*) before searching file contents; raise head_limit when the result reaches the limit. Files that .gitignore excludes are left out unless nothing else matches, and the result says when that happened. A result that could not cover every file carries an INCOMPLETE SEARCH note and is never a plain miss.', { type: 'object', properties: {
649
651
  pattern: { type: 'string', description: 'Glob pattern such as **/*.ts or src/**/*.spec.ts' },
650
652
  path: { type: 'string', description: 'Directory inside the workspace; defaults to .' },
651
653
  head_limit: { type: 'integer', minimum: 1, maximum: 1000, description: 'Maximum paths; default 100' },
@@ -655,9 +657,7 @@ export function createCodingTools(policy) {
655
657
  const pattern = stringArg(args, 'pattern'), searchPath = stringArg(args, 'path', true) ?? '.';
656
658
  const limit = intArg(args, 'head_limit', { min: 1, max: 1000 }) ?? 100;
657
659
  const resolved = await policy.safePath(context, searchPath);
658
- const current = bound(context).find;
659
- const result = await current.execute(randomUUID(), { pattern, path: resolved, limit }, context.signal);
660
- return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'));
660
+ return nativeObservation(formatGlobResult(await findFiles(context, pattern, resolved, limit), resolved, limit));
661
661
  });
662
662
  const Grep = zTool('Grep', 'Search file contents with file-name, count or content results. Uses ripgrep when it is installed. Without it, and in restricted modes, a built-in search runs instead: JavaScript single-line regular expressions, glob and common type filters, context lines and offsets; multiline and only-matching need ripgrep. A result that could not cover every file starts with INCOMPLETE SEARCH and is never a plain "No matches": narrow path or glob and search again.', { type: 'object', properties: {
663
663
  pattern: { type: 'string', description: 'Regular expression to search for' },
@@ -11,6 +11,7 @@ export interface CommandScreenUI {
11
11
  cancelOnEscape?: boolean;
12
12
  history?: boolean;
13
13
  secret?: boolean;
14
+ yieldToQuestions?: boolean;
14
15
  }): Promise<string>;
15
16
  print?(text: string): void;
16
17
  loadScreen<T>(title: string, load: (signal: AbortSignal) => Promise<T>, options?: {
@@ -54,6 +55,11 @@ export declare function pickPermissionMode(state: CommandState, ui: CommandScree
54
55
  /** The config with `model` on `providerId` as the selected pair: what choosing it in /model saves. */
55
56
  export declare function withSelectedModel(config: Config, providerId: string, model: string): Config;
56
57
  export declare function isScreenCommand(line: string): boolean;
58
+ /** Signs out and removes the Codex and Claude Console accounts of providers `next` no longer has. */
59
+ export declare function retireDroppedAccounts(previous: readonly ProviderConfig[], next: readonly ProviderConfig[], signal?: AbortSignal): Promise<void>;
60
+ /** Thrown by a live persist when the change it carried was refused, so the enclosing save keeps the old config. */
61
+ export declare class SelectionReverted extends Error {
62
+ }
57
63
  export declare function runCommandScreen(line: string, state: CommandState, ui: CommandScreenUI, persist: (config: Config) => Promise<void>, signal: AbortSignal, adapterFactory?: (provider: ProviderConfig) => ModelAdapter, graphAccess?: {
58
64
  load: typeof loadAccessibleGraph;
59
65
  requirePaid: (signal?: AbortSignal) => Promise<void>;
@@ -4,7 +4,6 @@ import { PERMISSION_OPTIONS } from './permissions.js';
4
4
  import { editProviderSettings } from './provider-settings.js';
5
5
  import { retireRemovedCodexAccounts, retireUnsavedCodexAccounts } from './codex-auth.js';
6
6
  import { droppedAnthropicAccounts, retireAnthropicAccounts } from './anthropic-console-auth.js';
7
- import { importProvidersFromRemote } from './provider-import.js';
8
7
  import { DEFAULT_GRAPH, listGraphs, withoutDeletedGraphs } from './graphs.js';
9
8
  import { graphStorageDirectory } from './graph-account.js';
10
9
  import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
@@ -44,6 +43,14 @@ export function isScreenCommand(line) {
44
43
  return ['/model', '/providers', '/graph', '/usage', '/permissions', '/skills', '/plugins', '/mcp', '/subagent'].includes(line.trim());
45
44
  }
46
45
  const CLEAR_SUBAGENT_SELECTION = '*clear*';
46
+ /** Signs out and removes the Codex and Claude Console accounts of providers `next` no longer has. */
47
+ export async function retireDroppedAccounts(previous, next, signal) {
48
+ await retireRemovedCodexAccounts(previous, next, signal ? { signal } : {}).catch(() => { });
49
+ await retireAnthropicAccounts(droppedAnthropicAccounts(previous, next)).catch(() => { });
50
+ }
51
+ /** Thrown by a live persist when the change it carried was refused, so the enclosing save keeps the old config. */
52
+ export class SelectionReverted extends Error {
53
+ }
47
54
  export async function runCommandScreen(line, state, ui, persist, signal, adapterFactory = createAdapter, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership, membership: getMembership }, openGraphBuilder, graphSubject = currentGraphSubject) {
48
55
  const unchanged = { clear: false };
49
56
  if (!isScreenCommand(line) || signal.aborted)
@@ -60,7 +67,11 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
60
67
  try {
61
68
  await (removesAndorra ? removingAndorraEntry(configDirectory(), () => persist(reconciled)) : persist(reconciled));
62
69
  }
63
- catch {
70
+ catch (error) {
71
+ // The live persist refused the change it carried (a provider the run could not move to): nothing was
72
+ // saved, so the configuration in memory stays as it was instead of taking the rejected draft.
73
+ if (error instanceof SelectionReverted)
74
+ return unchanged;
64
75
  await retireUnsavedCodexAccounts(reconciled.providers, state.config.providers, { signal });
65
76
  await retireAnthropicAccounts(droppedAnthropicAccounts(reconciled.providers, state.config.providers)).catch(() => { });
66
77
  if (!signal.aborted)
@@ -73,8 +84,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
73
84
  Object.assign(state.config, reconciled);
74
85
  if (removesAndorra)
75
86
  await state.andorra?.entryChanged?.();
76
- await retireRemovedCodexAccounts(previousProviders, reconciled.providers, { signal }).catch(() => { });
77
- await retireAnthropicAccounts(droppedAnthropicAccounts(previousProviders, reconciled.providers)).catch(() => { });
87
+ await (state.retireAccounts ?? retireDroppedAccounts)(previousProviders, reconciled.providers, signal).catch(() => { });
78
88
  if (reconciled.externalSubagent === undefined)
79
89
  delete state.config.externalSubagent;
80
90
  return { clear: true };
@@ -245,7 +255,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
245
255
  return { id: item.id, label: providerLabel(item, state.config.providers), ...(refusal ? { description: refusal } : {}) };
246
256
  }),
247
257
  { id: ':add', label: '+ Add provider' },
248
- { id: ':import', label: 'Import from remote connection' },
249
258
  ];
250
259
  };
251
260
  while (!signal.aborted) {
@@ -278,12 +287,6 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
278
287
  draft.provider = id;
279
288
  return await save(draft);
280
289
  }
281
- if (selected === ':import') {
282
- const draft = await importProvidersFromRemote(state.config, ui, signal);
283
- if (draft)
284
- return await save(draft);
285
- continue;
286
- }
287
290
  if (selected === ':add' || selected.startsWith(':edit:')) {
288
291
  const id = selected === ':add' ? undefined : selected.slice(6);
289
292
  if (id && !state.config.providers.some(item => item.id === id))
@@ -32,6 +32,11 @@ export interface CommandState {
32
32
  goal?: SessionGoal;
33
33
  jev?: boolean;
34
34
  andorra?: TerminalAndorraHooks;
35
+ /**
36
+ * Retires the sign-ins of providers a saved change dropped. Unset, a manager retires them at once; a run that is
37
+ * still working sets it to defer retirement until it ends, since its requests still read those credentials.
38
+ */
39
+ retireAccounts?: (previous: readonly import('./providers.js').ProviderConfig[], next: readonly import('./providers.js').ProviderConfig[], signal?: AbortSignal) => Promise<void>;
35
40
  }
36
41
  /** The message refusing a switch to this provider, or undefined when it may be selected. An absent `state.andorra` counts as available. */
37
42
  export declare function andorraRefusal(state: Pick<CommandState, 'andorra' | 'config'>, providerId: string): string | undefined;
@@ -49,19 +54,26 @@ export interface ConversationTurn {
49
54
  task: string;
50
55
  completion: Completion;
51
56
  runId?: string;
57
+ /** Given to the agent with the task but not shown with it (`run.note`), such as the person's hand edits. */
58
+ note?: string;
52
59
  resumed?: boolean;
53
60
  direction?: string;
54
61
  attachments?: import('./attachments.js').UserAttachmentRef[];
55
62
  wake?: TurnWake;
56
63
  steers?: {
57
64
  text: string;
65
+ note?: string;
58
66
  attachments?: import('./attachments.js').UserAttachmentRef[];
59
67
  wake?: TurnWake;
60
68
  subagentId?: string;
61
69
  }[];
62
70
  }
63
- /** Why a turn started without the person typing it: a timer the agent set, Auto-fix, or the PR tab's Fix with Agent. */
64
- export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks';
71
+ /**
72
+ * Why a turn started without the person typing it: a timer the agent set, Auto-fix, the PR tab's Fix with Agent,
73
+ * the person mentioning the App's bot on the task's PR (`mention`), or the Andorra review loop handing its findings to the
74
+ * task that owns the PR (`andorra-review`).
75
+ */
76
+ export type TurnWake = 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
65
77
  export declare function compactHistory(turns: ConversationTurn[]): ConversationTurn[];
66
78
  export declare function compactedContextEstimate(turns: ConversationTurn[]): number;
67
79
  export declare function subagentClearRequested(line: string, providers: {