@andorra-labs/code 0.1.14 → 0.1.15

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 (107) hide show
  1. package/dist/src/acp-agent.d.ts +54 -0
  2. package/dist/src/acp-agent.js +991 -0
  3. package/dist/src/agent-execution.js +4 -0
  4. package/dist/src/agent-mcp-catalog.js +2 -0
  5. package/dist/src/agent-mcp.d.ts +2 -0
  6. package/dist/src/agent-mcp.js +84 -2
  7. package/dist/src/andorra/entry.js +21 -3
  8. package/dist/src/andorra/hosted.d.ts +3 -0
  9. package/dist/src/andorra/hosted.js +5 -1
  10. package/dist/src/andorra/notices.d.ts +10 -1
  11. package/dist/src/andorra/notices.js +25 -2
  12. package/dist/src/andorra/terminal.d.ts +2 -0
  13. package/dist/src/andorra/terminal.js +2 -2
  14. package/dist/src/app-server/protocol.d.ts +6 -2
  15. package/dist/src/app-server/protocol.js +1 -1
  16. package/dist/src/app-server/workspace.d.ts +1 -0
  17. package/dist/src/app-server/workspace.js +141 -10
  18. package/dist/src/app-server.d.ts +8 -0
  19. package/dist/src/app-server.js +87 -41
  20. package/dist/src/auth/AuthManager.js +4 -4
  21. package/dist/src/browser-bridge.d.ts +1 -0
  22. package/dist/src/browser-bridge.js +5 -2
  23. package/dist/src/browser-external-app.d.ts +27 -0
  24. package/dist/src/browser-external-app.js +60 -0
  25. package/dist/src/browser-panel-tool.d.ts +6 -0
  26. package/dist/src/browser-panel-tool.js +36 -0
  27. package/dist/src/browser-server.d.ts +5 -0
  28. package/dist/src/browser-server.js +27 -3
  29. package/dist/src/browser-view.d.ts +16 -0
  30. package/dist/src/browser-view.js +60 -2
  31. package/dist/src/bug-report.d.ts +81 -0
  32. package/dist/src/bug-report.js +235 -0
  33. package/dist/src/claude-provider.d.ts +2 -1
  34. package/dist/src/claude-provider.js +10 -8
  35. package/dist/src/cli-sign-in.d.ts +3 -1
  36. package/dist/src/cli-sign-in.js +4 -1
  37. package/dist/src/cli.js +164 -34
  38. package/dist/src/coding-tools.js +7 -7
  39. package/dist/src/command-screens.d.ts +9 -2
  40. package/dist/src/command-screens.js +161 -94
  41. package/dist/src/commands.d.ts +1 -1
  42. package/dist/src/commands.js +1 -0
  43. package/dist/src/completion-gates.d.ts +22 -0
  44. package/dist/src/completion-gates.js +11 -0
  45. package/dist/src/config.d.ts +5 -0
  46. package/dist/src/config.js +48 -0
  47. package/dist/src/google-provider.d.ts +31 -0
  48. package/dist/src/google-provider.js +153 -0
  49. package/dist/src/graph-health.js +1 -1
  50. package/dist/src/graph-manager-chat.js +6 -1
  51. package/dist/src/graph-sync.d.ts +1 -0
  52. package/dist/src/graph-sync.js +93 -34
  53. package/dist/src/graph-tool.d.ts +2 -0
  54. package/dist/src/graph-tool.js +2 -2
  55. package/dist/src/graph-ui/app.js +67 -8
  56. package/dist/src/graph-ui/edge-router.js +121 -53
  57. package/dist/src/graph-visibility.d.ts +31 -0
  58. package/dist/src/graph-visibility.js +102 -0
  59. package/dist/src/live-model.d.ts +24 -0
  60. package/dist/src/live-model.js +37 -0
  61. package/dist/src/managed-sign-in.d.ts +1 -0
  62. package/dist/src/managed-sign-in.js +13 -0
  63. package/dist/src/membership-errors.d.ts +2 -0
  64. package/dist/src/membership-errors.js +5 -1
  65. package/dist/src/membership.d.ts +3 -0
  66. package/dist/src/membership.js +19 -2
  67. package/dist/src/model-health-cache.js +1 -1
  68. package/dist/src/model-metadata.js +8 -1
  69. package/dist/src/paged-transcript.d.ts +2 -0
  70. package/dist/src/paged-transcript.js +16 -0
  71. package/dist/src/provider-connection.js +17 -0
  72. package/dist/src/provider-engine.d.ts +5 -0
  73. package/dist/src/provider-engine.js +3 -3
  74. package/dist/src/provider-import.js +3 -1
  75. package/dist/src/provider-settings.js +14 -2
  76. package/dist/src/providers.d.ts +16 -2
  77. package/dist/src/providers.js +36 -12
  78. package/dist/src/react-runtime.js +21 -5
  79. package/dist/src/read-document-tool.d.ts +2 -0
  80. package/dist/src/read-document-tool.js +6 -6
  81. package/dist/src/remote/engine-pool.js +26 -2
  82. package/dist/src/runtime-environment.d.ts +1 -0
  83. package/dist/src/runtime-environment.js +13 -0
  84. package/dist/src/save-lock.js +14 -7
  85. package/dist/src/session-title.d.ts +3 -0
  86. package/dist/src/session-title.js +5 -2
  87. package/dist/src/sign-in-detection.d.ts +1 -1
  88. package/dist/src/sign-in-detection.js +10 -3
  89. package/dist/src/sign-in-offer.js +1 -1
  90. package/dist/src/skill-commands.js +1 -1
  91. package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
  92. package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
  93. package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
  94. package/dist/src/skills/bundled/provenance.json +7 -2
  95. package/dist/src/skills/runtime-skills.js +1 -0
  96. package/dist/src/telemetry/uploader.d.ts +7 -1
  97. package/dist/src/telemetry/uploader.js +11 -2
  98. package/dist/src/terminal-links.d.ts +16 -0
  99. package/dist/src/terminal-links.js +113 -0
  100. package/dist/src/terminal-ui.d.ts +8 -1
  101. package/dist/src/terminal-ui.js +40 -14
  102. package/dist/src/tool-catalog.js +1 -1
  103. package/dist/src/trajectory.js +6 -1
  104. package/dist/src/transcript.d.ts +2 -0
  105. package/dist/src/transcript.js +2 -1
  106. package/dist/src/types.d.ts +2 -0
  107. package/package.json +2 -1
package/dist/src/cli.js CHANGED
@@ -13,8 +13,8 @@ import { fileURLToPath } from 'node:url';
13
13
  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
- import { compactHistory, compactedContextEstimate, executeCommand, HELP } from './commands.js';
17
- import { applyModelContextWindow, createAdapter, providerModelNames, providerSecrets, recordProviderModel } from './providers.js';
16
+ import { andorraRefusal, compactHistory, compactedContextEstimate, executeCommand, HELP } from './commands.js';
17
+ import { applyModelContextWindow, createAdapter, modelDisplayName, modelIdForDisplayName, providerModelNames, providerSecrets, recordProviderModel } 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';
@@ -54,8 +54,9 @@ import { staticToolTimestamp } from './tool-call-clock.js';
54
54
  import { LocalToolMemory } from './memory/LocalToolMemory.js';
55
55
  import { ProjectMemory } from './memory/ProjectMemory.js';
56
56
  import { askClarification } from './clarification-ui.js';
57
- import { refreshModelContext, resolveModelContext, withEvaluationReasoningEffort } from './model-metadata.js';
58
- import { isScreenCommand, pickPermissionMode, runCommandScreen } from './command-screens.js';
57
+ import { configuredModelSnapshot, refreshModelContext, resolveModelContext, withEvaluationReasoningEffort } from './model-metadata.js';
58
+ import { isScreenCommand, pickPermissionMode, pickProviderModel, runCommandScreen, withSelectedModel } from './command-screens.js';
59
+ import { liveModelTarget } from './live-model.js';
59
60
  import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
60
61
  import { ToolActivity, activityForRuntimeEvent } from './tool-activity.js';
61
62
  import { effectiveExtensionConfig, extensionSnapshot, resolveSkillInvocations } from './extensions.js';
@@ -94,6 +95,7 @@ async function warmRunModules(lastInputAt, stop) {
94
95
  const updateInstallation = async (...args) => (await import('./update.js')).updateInstallation(...args);
95
96
  const launchGraphEditor = async (noOpen) => (await import('./graph-server.js')).launchGraphEditor(noOpen);
96
97
  const startBrowserServer = async () => (await import('./browser-server.js')).startBrowserServer();
98
+ const browserLaunch = async (url) => (await import('./browser-server.js')).browserLaunch(url);
97
99
  const openBrowserUrl = (url) => { void import('./browser-server.js').then(module => module.openBrowserUrl(url)); };
98
100
  export async function cliVersion() {
99
101
  try {
@@ -311,6 +313,12 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
311
313
  bootMark('app-server.imported');
312
314
  return await runAppServer();
313
315
  }
316
+ if (argv[0] === 'acp' || argv[0] === '--acp') {
317
+ if (argv.length !== 1)
318
+ throw new Error('Usage: andorra acp');
319
+ const { runAcpAgent } = await import('./acp-agent.js');
320
+ return await runAcpAgent({ version: await cliVersion().catch(() => '0.0.0') });
321
+ }
314
322
  if (argv[0] === 'automations') {
315
323
  const { runAutomationCommand } = await import('./automation-service.js');
316
324
  return runAutomationCommand(argv.slice(1), line => process.stdout.write(line + '\n'));
@@ -360,7 +368,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
360
368
  let terminal;
361
369
  const print = (text) => terminal ? terminal.print(text) : process.stdout.write(safeTerminal(text) + '\n');
362
370
  if (values.help) {
363
- 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 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}`);
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}`);
364
372
  return 0;
365
373
  }
366
374
  if (values.version) {
@@ -755,7 +763,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
755
763
  await startupGuard(async () => {
756
764
  const selected = config.providers.find(p => p.id === config.provider);
757
765
  const codeIntelState = codeIntelLabel((await codeIntel.getStatus()).state);
758
- terminal = new TerminalUI({ goal: state.goal, account: { label: 'Checking account...', notice: 'Checking member access. Local Andorra Agent remains available.' }, workspace, provider: selected?.id ?? 'No provider', model: selected?.model ?? '/providers to configure', providerModels: Object.fromEntries(config.providers.map(p => [p.id, p.model])), modelNames: providerModelNames(config.providers), andorraProviders: andorraProviderIds(config.providers), reasoningEffort: selected?.reasoningEffort, contextWindow: selected?.contextWindow, version: await cliVersion(), branch: await gitBranch(workspace), yolo: state.yolo, permissions: permissionLabel(state.permissions), graphSelection: state.graph ?? 'default',
766
+ terminal = new TerminalUI({ sessionId: () => savedSession?.id ?? trajectory.sessionId, goal: state.goal, account: { label: 'Checking account...', notice: 'Checking member access. Local Andorra Agent remains available.' }, workspace, provider: selected?.id ?? 'No provider', model: selected?.model ?? '/providers to configure', providerModels: Object.fromEntries(config.providers.map(p => [p.id, p.model])), modelNames: providerModelNames(config.providers), andorraProviders: andorraProviderIds(config.providers), reasoningEffort: selected?.reasoningEffort, contextWindow: selected?.contextWindow, version: await cliVersion(), branch: await gitBranch(workspace), yolo: state.yolo, permissions: permissionLabel(state.permissions), graphSelection: state.graph ?? 'default',
759
767
  graph: startupGraph ?? await loadGraph(state.graph ?? 'default').catch(() => undefined), ...(codeIntelState ? { codeIntel: codeIntelState } : {}), clipboardImageProbe: readClipboardImage, clipboardTextWriter: writeClipboardText });
760
768
  offerSkillCommands(terminal, state.config, directory);
761
769
  terminal.setLocalCommandHandler((input, mode, durationMs) => {
@@ -1157,6 +1165,10 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1157
1165
  });
1158
1166
  let liveCommands = Promise.resolve();
1159
1167
  const livePicker = new AbortController();
1168
+ // The model chosen with /model while this run works. The engine asks for it before each model request
1169
+ // (getLiveModel below), so the change lands at the run's next request, paused or not.
1170
+ let liveSelection;
1171
+ let switchRunModel;
1160
1172
  terminal?.setRunInputHandler(text => {
1161
1173
  if (!text.startsWith('/')) {
1162
1174
  void debugRecord('command.steer', { input: text });
@@ -1180,9 +1192,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1180
1192
  print(`Attached ${target}. It rides your next steer.`);
1181
1193
  return true;
1182
1194
  }
1183
- if (!['/browser', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools'].includes(command)) {
1195
+ if (!['/model', '/browser', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools'].includes(command)) {
1184
1196
  void debugRecord('command.steer', { input: text });
1185
- print(`${command} is unavailable during a run. Use /permissions <mode>, /yolo on|off, /jev on|off, /status, /usage, /help, or /exit.`);
1197
+ print(`${command} is unavailable during a run. Use /model, /permissions <mode>, /yolo on|off, /jev on|off, /status, /usage, /help, or /exit.`);
1186
1198
  return true;
1187
1199
  }
1188
1200
  const commandStartedAt = Date.now();
@@ -1193,8 +1205,40 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1193
1205
  if (exiting)
1194
1206
  await browserApp.close().catch(() => { });
1195
1207
  else {
1196
- print(`Andorra Browser: ${browserApp.url}`);
1197
- openBrowserUrl(browserApp.url);
1208
+ const launch = await browserLaunch(browserApp.url);
1209
+ print(launch.text);
1210
+ if (launch.open)
1211
+ openBrowserUrl(browserApp.url);
1212
+ }
1213
+ }
1214
+ else if (command === '/model') {
1215
+ const argument = text.trim().slice('/model'.length).trim();
1216
+ if (!switchRunModel) {
1217
+ print('This run is still starting. Type /model again in a moment.');
1218
+ }
1219
+ else if (!argument || argument === 'list') {
1220
+ if (!terminal)
1221
+ return;
1222
+ let picked;
1223
+ try {
1224
+ picked = await pickProviderModel(state, terminal, createAdapter, livePicker.signal, { yieldToQuestions: true });
1225
+ }
1226
+ catch (error) {
1227
+ if (!(error instanceof Error && error.name === 'AbortError'))
1228
+ throw error;
1229
+ if (!livePicker.signal.aborted)
1230
+ print('Model unchanged: the run asked a question, so the picker closed. Type /model again afterwards.');
1231
+ }
1232
+ if (picked !== undefined && !livePicker.signal.aborted)
1233
+ await switchRunModel(picked);
1234
+ }
1235
+ else {
1236
+ const current = config.providers.find(item => item.id === config.provider);
1237
+ const chosen = current && (modelIdForDisplayName(current, argument) ?? (/\s/.test(argument) ? undefined : argument));
1238
+ if (!current || chosen === undefined)
1239
+ print('Usage: /model <model-id>, or /model to pick from a list.');
1240
+ else
1241
+ await switchRunModel({ provider: current.id, model: chosen });
1198
1242
  }
1199
1243
  }
1200
1244
  else if (text.trim() === '/permissions' && terminal) {
@@ -1261,6 +1305,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1261
1305
  terminal?.setStatus({ activity: 'Thinking' });
1262
1306
  terminal?.setSteering(true);
1263
1307
  const selected = config.providers.find(p => p.id === config.provider);
1308
+ // Each provider's model as this run started. A graph node, subagent policy or retry fallback that names a
1309
+ // provider without a model means this one for the whole run, whatever /model saves for the next task.
1310
+ const runDefaults = new Map(config.providers.map(item => [item.id, item.model]));
1264
1311
  const preflight = async (operation) => {
1265
1312
  while (true) {
1266
1313
  if (active.signal.aborted)
@@ -1364,7 +1411,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1364
1411
  const entry = formatEvent(event);
1365
1412
  if (entry) {
1366
1413
  if (terminal)
1367
- terminal.print(entry.text, entry.detail, entry.toolCall, false, /failed|error|stopped/.test(event.type), false, entry.clipRows);
1414
+ terminal.print(entry.text, entry.detail, entry.toolCall, false, /failed|error|stopped/.test(event.type), false, entry.clipRows, entry.replaceKey);
1368
1415
  else if (event.type === 'agent.message' && entry.detail)
1369
1416
  print(staticToolTimestamp(entry.detail, entry.toolCall));
1370
1417
  else
@@ -1425,8 +1472,9 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1425
1472
  }
1426
1473
  if (jevOn() && !membership.subject) {
1427
1474
  const reason = membership.unavailable ? membership.failureReason ?? 'membership_unavailable' : 'not_signed_in';
1428
- await onRunEvent({ type: 'decision.unavailable', time: new Date().toISOString(), data: { runId, provider: 'andorra', reason } });
1429
- const notice = `Jev is off for this run: ${reason === 'not_signed_in' ? 'no signed-in account' : `the account lookup was unavailable (${reason})`}.`;
1475
+ const detail = reason === 'not_signed_in' ? undefined : membership.failureDetail;
1476
+ await onRunEvent({ type: 'decision.unavailable', time: new Date().toISOString(), data: { runId, provider: 'andorra', reason, ...(detail ? { detail } : {}) } });
1477
+ const notice = `Jev is off for this run: ${reason === 'not_signed_in' ? 'no signed-in account' : `the account lookup was unavailable (${reason}${detail ? `; ${detail}` : ''})`}.`;
1430
1478
  if (terminal)
1431
1479
  terminal.print(notice);
1432
1480
  else
@@ -1434,32 +1482,112 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1434
1482
  }
1435
1483
  const decisionPolicy = hostedDecisionPolicy(membership, jevOn(), config.decisions);
1436
1484
  jevEnabled = jevOn();
1437
- terminal?.setStatus({ graph, jevEnabled });
1485
+ terminal?.setStatus({ graph, jevEnabled, jevOffThisRun: jevEnabled && !membership.subject });
1438
1486
  const commandMemory = config.commandMemory === false ? undefined : await LocalToolMemory.open({ workspace, directory });
1439
1487
  const projectMemory = config.projectMemory === false ? undefined : await ProjectMemory.open({ home: directory, workspace });
1488
+ const resolveRunModel = (id, model, wait = preflight) => {
1489
+ const provider = config.providers.find(item => item.id === id);
1490
+ if (!provider)
1491
+ throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
1492
+ const wanted = model || runDefaults.get(id) || provider.model;
1493
+ const key = JSON.stringify([id, wanted]);
1494
+ let pending = resolvedModels.get(key);
1495
+ if (!pending) {
1496
+ pending = wait(signal => resolveModelContext(provider, wanted, signal))
1497
+ .then(snapshot => withEvaluationReasoningEffort(snapshot, process.env.ANDORRA_EVAL_REASONING_EFFORT))
1498
+ .then(snapshot => ({ model: snapshot.model, adapter: tracedAdapter(snapshot), contextWindow: snapshot.contextWindow, reasoningEffort: snapshot.reasoningEffort, providerType: provider.type, baseUrl: provider.baseUrl }));
1499
+ resolvedModels.set(key, pending);
1500
+ void pending.catch(() => { if (resolvedModels.get(key) === pending)
1501
+ resolvedModels.delete(key); });
1502
+ }
1503
+ return pending;
1504
+ };
1505
+ const wakeCarry = { provider: selected.id, model: selected.model, graph: runGraphSelection,
1506
+ ...(selected.reasoningEffort === undefined ? {} : { reasoningEffort: selected.reasoningEffort }) };
1507
+ switchRunModel = async (target) => {
1508
+ const provider = config.providers.find(item => item.id === target.provider);
1509
+ if (!provider)
1510
+ throw new Error(`Unknown provider: ${target.provider}. Use /providers to add or edit providers.`);
1511
+ const refusal = andorraRefusal(state, provider.id);
1512
+ if (refusal) {
1513
+ print(refusal);
1514
+ return;
1515
+ }
1516
+ const from = liveSelection ?? { provider: selected.id, model: selected.model };
1517
+ const label = `${provider.id}/${modelDisplayName(provider, target.model)}`;
1518
+ if (from.provider === target.provider && from.model === target.model) {
1519
+ print(`Model unchanged: this run already uses ${label}.`);
1520
+ return;
1521
+ }
1522
+ // Saved the way /model saves it between tasks, so the next task starts on the same model. The
1523
+ // conversation is kept: the run carries on with what it has.
1524
+ const restored = structuredClone(config);
1525
+ const draft = withSelectedModel(config, provider.id, target.model);
1526
+ let saved = true;
1527
+ try {
1528
+ await persistConfig(draft);
1529
+ }
1530
+ catch {
1531
+ saved = false;
1532
+ }
1533
+ Object.assign(config, draft);
1534
+ // Resolved here rather than at the run's next request, and without waiting out a pause: a model the
1535
+ // provider cannot describe is refused now, while the run still holds its old one.
1536
+ try {
1537
+ await resolveRunModel(provider.id, target.model, operation => operation(AbortSignal.any([active.signal, livePicker.signal])));
1538
+ }
1539
+ catch (error) {
1540
+ if (saved)
1541
+ await persistConfig(restored).catch(() => { });
1542
+ Object.assign(config, restored);
1543
+ refreshStatus();
1544
+ if (active.signal.aborted || livePicker.signal.aborted)
1545
+ return;
1546
+ print(`Model not changed: ${label} could not be loaded (${error instanceof Error ? error.message : String(error)}). This run stays on ${from.provider}/${from.model}.`);
1547
+ return;
1548
+ }
1549
+ liveSelection = { provider: provider.id, model: target.model, overrideAllNodes: false };
1550
+ wakeCarry.provider = provider.id;
1551
+ wakeCarry.model = target.model;
1552
+ delete wakeCarry.reasoningEffort;
1553
+ if (openRecordWritten) {
1554
+ openRecord.provider = provider.id;
1555
+ openRecord.model = target.model;
1556
+ await writeOpenRunRecord(directory, openRecord).catch(() => { });
1557
+ }
1558
+ trajectory.addSecrets(providerSecrets(config.providers));
1559
+ await onRunEvent({ type: 'run.model.switched', time: new Date().toISOString(), data: { runId, scope: 'run', from: { provider: from.provider, model: from.model }, to: { provider: provider.id, model: target.model } } });
1560
+ const pinned = Object.values(graph.nodes).filter(node => node.type === 'agent' && node.provider !== undefined).length;
1561
+ print(`Model: ${label}. This run uses it from its next model request${runControl?.isPaused ? ' (send a message to resume)' : ''}.`
1562
+ + (pinned ? ` ${pinned} graph node${pinned === 1 ? ' names its' : 's name their'} own model and keep${pinned === 1 ? 's' : ''} it.` : '')
1563
+ + (saved ? '' : ' The configuration could not be saved, so the next task starts on the previous model.'));
1564
+ refreshStatus();
1565
+ };
1440
1566
  const execute = (options) => runGraph(graph, { ...options, runInput, runState, commandMemory, projectMemory, todoStore,
1441
1567
  ...(runSkill.skills?.length ? { inheritedSkills: runSkill.skills.map(skill => skill.id), skillInvocationInstruction: runSkill.instruction } : {}),
1442
- resolveModel: (id, model) => {
1443
- const provider = config.providers.find(item => item.id === id);
1444
- if (!provider)
1445
- throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
1446
- const key = JSON.stringify([id, model || provider.model]);
1447
- let pending = resolvedModels.get(key);
1448
- if (!pending) {
1449
- pending = preflight(signal => resolveModelContext(provider, model || provider.model, signal))
1450
- .then(snapshot => withEvaluationReasoningEffort(snapshot, process.env.ANDORRA_EVAL_REASONING_EFFORT))
1451
- .then(snapshot => ({ model: snapshot.model, adapter: tracedAdapter(snapshot), contextWindow: snapshot.contextWindow, reasoningEffort: snapshot.reasoningEffort, providerType: provider.type, baseUrl: provider.baseUrl }));
1452
- resolvedModels.set(key, pending);
1453
- void pending.catch(() => { if (resolvedModels.get(key) === pending)
1454
- resolvedModels.delete(key); });
1568
+ resolveModel: (id, model) => resolveRunModel(id, model),
1569
+ getLiveModel: async (nodeId, currentProvider, currentModel) => {
1570
+ while (true) {
1571
+ const current = liveSelection;
1572
+ if (!current)
1573
+ return undefined;
1574
+ const target = liveModelTarget(current, graph.nodes, nodeId);
1575
+ if (!target)
1576
+ return undefined;
1577
+ const effective = target.model ?? runDefaults.get(target.provider) ?? config.providers.find(item => item.id === target.provider)?.model;
1578
+ if (target.provider === currentProvider && effective === currentModel)
1579
+ return undefined;
1580
+ const resolved = await resolveRunModel(target.provider, target.model);
1581
+ if (liveSelection !== current)
1582
+ continue;
1583
+ return { ...resolved, provider: target.provider };
1455
1584
  }
1456
- return pending;
1457
1585
  },
1458
1586
  resolveProvider: id => {
1459
1587
  const provider = config.providers.find(item => item.id === id);
1460
1588
  if (!provider)
1461
1589
  throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
1462
- const snapshot = withEvaluationReasoningEffort(runtimeProvider(provider), process.env.ANDORRA_EVAL_REASONING_EFFORT);
1590
+ const snapshot = withEvaluationReasoningEffort(runtimeProvider(configuredModelSnapshot(provider, runDefaults.get(id))), process.env.ANDORRA_EVAL_REASONING_EFFORT);
1463
1591
  return { model: snapshot.model, adapter: tracedAdapter(snapshot), contextWindow: snapshot.contextWindow, providerType: snapshot.type, baseUrl: snapshot.baseUrl };
1464
1592
  },
1465
1593
  });
@@ -1514,8 +1642,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1514
1642
  } : undefined,
1515
1643
  context: { workspace, signal: active.signal, runControl, timers: terminal ? sessionTimers : undefined,
1516
1644
  automationDirectory: directory,
1517
- wakeCarry: { provider: selected.id, model: selected.model, graph: runGraphSelection,
1518
- ...(selected.reasoningEffort === undefined ? {} : { reasoningEffort: selected.reasoningEffort }) },
1645
+ wakeCarry,
1519
1646
  get yolo() { return state.yolo; }, get permissions() { return state.permissions; }, get attachmentRoots() { return [...attachmentSpools]; }, approvalMode: terminal ? 'interactive' : 'headless',
1520
1647
  askUser: terminal ? async (question, signal, choices) => {
1521
1648
  if (exiting)
@@ -1644,6 +1771,7 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1644
1771
  void andorraMonitor?.check('run-end').catch(() => { });
1645
1772
  browserDraining = true;
1646
1773
  terminal?.setRunInputHandler(undefined);
1774
+ switchRunModel = undefined;
1647
1775
  livePicker.abort();
1648
1776
  await checkpointWrites;
1649
1777
  await liveCommands;
@@ -1847,12 +1975,14 @@ export async function main(argv = process.argv.slice(2), dependencies = {}) {
1847
1975
  if (exiting)
1848
1976
  await browserApp.close().catch(() => { });
1849
1977
  else {
1850
- print(`Andorra Browser: ${browserApp.url}`);
1851
- openBrowserUrl(browserApp.url);
1978
+ const launch = await browserLaunch(browserApp.url);
1979
+ print(launch.text);
1980
+ if (launch.open)
1981
+ openBrowserUrl(browserApp.url);
1852
1982
  }
1853
1983
  continue;
1854
1984
  }
1855
- if (line === '/session') {
1985
+ if (line === '/session' || line === '/resume') {
1856
1986
  await persistSession();
1857
1987
  const records = await sessions.list(workspace);
1858
1988
  if (!records.length) {
@@ -22,7 +22,7 @@ import { CommandExitError, FileReadRequiredError } from './tool-errors.js';
22
22
  import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
23
23
  import { withGrepRegex } from './grep-regex.js';
24
24
  import { claimReadImages, readImageObservation } from './read-image.js';
25
- import { READ_PDF_RENDER_PAGES, legacyTextObservation, readDocumentObservation } from './read-document-tool.js';
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
28
  // Runs an agent command with the stray-file notice and, around it, the commit identity audit. The audit
@@ -449,20 +449,20 @@ export function createCodingTools(policy) {
449
449
  throw error;
450
450
  return legacyTextObservation(filePath, decoded, documentOptions);
451
451
  }
452
- if (pages !== undefined || render)
453
- throw new Error('pages and render apply to PDF files only; page through a text file with offset and limit.');
452
+ // A model that fills in every optional argument sends `pages` with a source file; refusing it cost a whole run.
453
+ const ignored = pdfOnlyArgumentsIgnored(documentOptions, 'a text file');
454
454
  const lines = content.split('\n');
455
455
  if (content.endsWith('\n') || content === '')
456
456
  lines.pop();
457
457
  const first = Math.max(1, offset ?? 1);
458
458
  if (!lines.length) {
459
459
  await rememberReadRange(context, resolved, content, 1, 0, 0);
460
- return '[Empty file]';
460
+ return ignored ? `[Empty file]\n${ignored}` : '[Empty file]';
461
461
  }
462
462
  if (first > lines.length)
463
463
  throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
464
464
  const lastRequested = Math.min(lines.length, first + limit - 1);
465
- const budget = MAX_MODEL_OUTPUT - 200;
465
+ const budget = MAX_MODEL_OUTPUT - 200 - ignored.length;
466
466
  let rendered = '';
467
467
  let emittedLast = first - 1;
468
468
  for (let line = first; line <= lastRequested; line++) {
@@ -481,7 +481,7 @@ export function createCodingTools(policy) {
481
481
  await rememberReadRange(context, resolved, content, first, emittedLast, lines.length);
482
482
  if (emittedLast < lines.length)
483
483
  rendered += `\n[Showing lines ${first}-${emittedLast} of ${lines.length}. Use offset=${emittedLast + 1} to continue.]`;
484
- return rendered;
484
+ return ignored ? `${rendered}\n${ignored}` : rendered;
485
485
  }), resultImages: claimReadImages };
486
486
  const Write = zTool('Write', 'Create a new file or completely replace an existing file. Existing files must first be fully Read (or supplied completely by CodeGraph) and must still match that snapshot. Prefer Edit for partial changes.', { type: 'object', properties: {
487
487
  file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
@@ -880,7 +880,7 @@ export function createCodingTools(policy) {
880
880
  const actual = kind === 'powershell' ? 'PowerShell' : 'Bash';
881
881
  const syntax = kind === 'powershell'
882
882
  ? 'PowerShell syntax; use & before a quoted executable path. No cmd.exe substitution. Do not pipe a running child into Select-Object -First: it terminates the pipeline before the child completes and can cause exit 4294967295. Host output is already tail-bounded; use Select-Object -Last if further filtering is needed. Prefer file-written scripts over nested quoting for multiline Python/JavaScript. Prefer direct invocation (& $exe @args) for child processes: Windows PowerShell Start-Process -ArgumentList flattens arrays and can split a multi-word argument unless it is quoted manually. Windows PowerShell also alters what it hands a native program: piping a string into one (ssh, wsl, bash -s, docker exec) appends CRLF after the last line, so a remote shell runs that line with a stray \r, and double quotes inside a native argument are dropped. Windows PowerShell binds the content of Set-Content or Add-Content as the file name when a switch such as -NoNewline comes before a positional path: name -Path and -Value, or use Write. Send a multi-line script to a remote or POSIX shell as base64 instead: $b = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($script -replace "`r", "") + "`n")); & ssh host "echo $b | base64 -d | bash".'
883
- : 'Bash syntax (Git Bash on Windows).';
883
+ : `Bash syntax${process.platform === 'win32' ? ' (Git Bash on Windows)' : ''}.`;
884
884
  const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.${privateRunTemp() ? ` Put scratch files in ${kind === 'powershell' ? '$env:TEMP' : '"$TMPDIR"'}, a private directory that is removed when the run ends, not in the shared system temporary directory.` : ''}`, { type: 'object', properties: {
885
885
  command: { type: 'string', description: 'Command to execute' },
886
886
  timeout: { type: 'integer', minimum: 1, maximum: SHELL_MAX_TIMEOUT_MS, description: `Timeout in milliseconds; default ${SHELL_DEFAULT_TIMEOUT_MS}, at most ${SHELL_MAX_TIMEOUT_MS}. Set it for a build, install, download or test run you expect to take longer than the default` },
@@ -16,6 +16,7 @@ export interface CommandScreenUI {
16
16
  loadScreen<T>(title: string, load: (signal: AbortSignal) => Promise<T>, options?: {
17
17
  description?: string;
18
18
  signal?: AbortSignal;
19
+ yieldToQuestions?: boolean;
19
20
  }): Promise<T | undefined>;
20
21
  select(title: string, items: {
21
22
  id: string;
@@ -44,11 +45,14 @@ export interface CommandScreenUI {
44
45
  }): Promise<string | undefined>;
45
46
  showScreen(title: string, lines: string[], options?: {
46
47
  signal?: AbortSignal;
48
+ yieldToQuestions?: boolean;
47
49
  }): Promise<void>;
48
50
  }
49
51
  export declare function pickPermissionMode(state: CommandState, ui: CommandScreenUI, signal: AbortSignal, options?: {
50
52
  yieldToQuestions?: boolean;
51
53
  }): Promise<string | undefined>;
54
+ /** The config with `model` on `providerId` as the selected pair: what choosing it in /model saves. */
55
+ export declare function withSelectedModel(config: Config, providerId: string, model: string): Config;
52
56
  export declare function isScreenCommand(line: string): boolean;
53
57
  export declare function runCommandScreen(line: string, state: CommandState, ui: CommandScreenUI, persist: (config: Config) => Promise<void>, signal: AbortSignal, adapterFactory?: (provider: ProviderConfig) => ModelAdapter, graphAccess?: {
54
58
  load: typeof loadAccessibleGraph;
@@ -75,9 +79,12 @@ export declare function andorraRefresh<Row>(state: CommandState, rows: () => Row
75
79
  /**
76
80
  * The /model screen: every configured provider as a collapsed row ending in `>`, with its models
77
81
  * indented beneath once expanded (Right Arrow or Enter expands, Left Arrow collapses). A provider's
78
- * models load the first time it opens; when discovery fails its configured models are shown instead.
82
+ * models load the first time it opens, behind a loading row in the open tree; when discovery fails its
83
+ * configured models are shown instead.
79
84
  */
80
- export declare function pickProviderModel(state: CommandState, ui: CommandScreenUI, adapterFactory: (provider: ProviderConfig) => ModelAdapter, signal: AbortSignal): Promise<{
85
+ export declare function pickProviderModel(state: CommandState, ui: CommandScreenUI, adapterFactory: (provider: ProviderConfig) => ModelAdapter, signal: AbortSignal, options?: {
86
+ yieldToQuestions?: boolean;
87
+ }): Promise<{
81
88
  provider: string;
82
89
  model: string;
83
90
  } | undefined>;