@andorra-labs/code 0.1.16 → 0.1.18

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 (236) 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 +108 -19
  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/errors.js +3 -0
  10. package/dist/src/andorra/hosted.d.ts +2 -1
  11. package/dist/src/andorra/hosted.js +2 -1
  12. package/dist/src/andorra/notices.d.ts +5 -0
  13. package/dist/src/andorra/notices.js +7 -0
  14. package/dist/src/andorra/state.d.ts +3 -2
  15. package/dist/src/andorra/state.js +4 -4
  16. package/dist/src/andorra/terminal.js +7 -2
  17. package/dist/src/anthropic-credentials.js +2 -0
  18. package/dist/src/app-server/error.d.ts +5 -0
  19. package/dist/src/app-server/error.js +7 -0
  20. package/dist/src/app-server/protocol.d.ts +30 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +108 -0
  23. package/dist/src/app-server/workspace.js +608 -11
  24. package/dist/src/app-server.d.ts +390 -33
  25. package/dist/src/app-server.js +3033 -565
  26. package/dist/src/attachments.d.ts +10 -0
  27. package/dist/src/attachments.js +102 -7
  28. package/dist/src/automation-tool.js +2 -1
  29. package/dist/src/bridge/cloud.d.ts +27 -0
  30. package/dist/src/bridge/cloud.js +187 -0
  31. package/dist/src/bridge/command.d.ts +30 -0
  32. package/dist/src/bridge/command.js +359 -0
  33. package/dist/src/bridge/control.d.ts +70 -0
  34. package/dist/src/bridge/control.js +238 -0
  35. package/dist/src/bridge/engines.d.ts +90 -0
  36. package/dist/src/bridge/engines.js +601 -0
  37. package/dist/src/bridge/github.d.ts +108 -0
  38. package/dist/src/bridge/github.js +378 -0
  39. package/dist/src/bridge/host-ops.d.ts +9 -0
  40. package/dist/src/bridge/host-ops.js +139 -0
  41. package/dist/src/bridge/host.d.ts +47 -0
  42. package/dist/src/bridge/host.js +543 -0
  43. package/dist/src/bridge/link.d.ts +38 -0
  44. package/dist/src/bridge/link.js +508 -0
  45. package/dist/src/bridge/login-link.d.ts +29 -0
  46. package/dist/src/bridge/login-link.js +54 -0
  47. package/dist/src/bridge/protocol.d.ts +136 -0
  48. package/dist/src/bridge/protocol.js +11 -0
  49. package/dist/src/bridge/store.d.ts +12 -0
  50. package/dist/src/bridge/store.js +61 -0
  51. package/dist/src/bridge/wording.d.ts +6 -0
  52. package/dist/src/bridge/wording.js +10 -0
  53. package/dist/src/browser-server.js +7 -1
  54. package/dist/src/browser-ui/tokens.css +1 -1
  55. package/dist/src/bug-report-attachments.d.ts +48 -0
  56. package/dist/src/bug-report-attachments.js +327 -0
  57. package/dist/src/bug-report.d.ts +23 -3
  58. package/dist/src/bug-report.js +72 -9
  59. package/dist/src/change-authors.d.ts +41 -0
  60. package/dist/src/change-authors.js +146 -0
  61. package/dist/src/cli.d.ts +1 -3
  62. package/dist/src/cli.js +191 -35
  63. package/dist/src/codex-provider.js +1 -1
  64. package/dist/src/coding-tools.js +24 -17
  65. package/dist/src/command-screens.d.ts +6 -0
  66. package/dist/src/command-screens.js +14 -11
  67. package/dist/src/commands.d.ts +15 -3
  68. package/dist/src/commands.js +2 -1
  69. package/dist/src/compaction-phrases.js +1 -1
  70. package/dist/src/completion.js +89 -8
  71. package/dist/src/config.d.ts +71 -3
  72. package/dist/src/config.js +205 -78
  73. package/dist/src/context-budget.js +15 -2
  74. package/dist/src/deadline.js +13 -1
  75. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  76. package/dist/src/decision/DecisionManager.d.ts +11 -0
  77. package/dist/src/decision/DecisionManager.js +36 -0
  78. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  79. package/dist/src/decision/applyTaskKind.js +53 -0
  80. package/dist/src/decision/checks.js +1 -1
  81. package/dist/src/decision/hostedPolicy.js +2 -1
  82. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
  83. package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
  84. package/dist/src/decision/requestPhrases.js +0 -1
  85. package/dist/src/decision/taskKind.d.ts +52 -0
  86. package/dist/src/decision/taskKind.js +76 -0
  87. package/dist/src/decision/types.d.ts +1 -1
  88. package/dist/src/default-graph.js +1 -1
  89. package/dist/src/efficiency.d.ts +5 -0
  90. package/dist/src/efficiency.js +5 -1
  91. package/dist/src/effort-routing.d.ts +27 -0
  92. package/dist/src/effort-routing.js +34 -0
  93. package/dist/src/evidence.d.ts +110 -0
  94. package/dist/src/evidence.js +195 -0
  95. package/dist/src/file-diff.d.ts +4 -0
  96. package/dist/src/file-diff.js +2 -1
  97. package/dist/src/github-app/agent-writes.d.ts +102 -0
  98. package/dist/src/github-app/agent-writes.js +320 -0
  99. package/dist/src/github-app/client.d.ts +368 -0
  100. package/dist/src/github-app/client.js +830 -0
  101. package/dist/src/github-app/event-source.d.ts +208 -0
  102. package/dist/src/github-app/event-source.js +684 -0
  103. package/dist/src/github-app/metrics.d.ts +32 -0
  104. package/dist/src/github-app/metrics.js +49 -0
  105. package/dist/src/github-app/review-loop.d.ts +274 -0
  106. package/dist/src/github-app/review-loop.js +1177 -0
  107. package/dist/src/github-app/review-node.d.ts +81 -0
  108. package/dist/src/github-app/review-node.js +205 -0
  109. package/dist/src/github-app/review-post.d.ts +73 -0
  110. package/dist/src/github-app/review-post.js +139 -0
  111. package/dist/src/github-app/review-text.d.ts +107 -0
  112. package/dist/src/github-app/review-text.js +1133 -0
  113. package/dist/src/github-app/review-threads.d.ts +47 -0
  114. package/dist/src/github-app/review-threads.js +107 -0
  115. package/dist/src/github-app/reviewer.d.ts +121 -0
  116. package/dist/src/github-app/reviewer.js +598 -0
  117. package/dist/src/github-app/store.d.ts +59 -0
  118. package/dist/src/github-app/store.js +148 -0
  119. package/dist/src/github-app/triggers.d.ts +141 -0
  120. package/dist/src/github-app/triggers.js +441 -0
  121. package/dist/src/github-names.d.ts +15 -0
  122. package/dist/src/github-names.js +15 -0
  123. package/dist/src/glob-search.d.ts +61 -0
  124. package/dist/src/glob-search.js +180 -0
  125. package/dist/src/graph-health.js +6 -1
  126. package/dist/src/graph-manager-chat.js +1 -1
  127. package/dist/src/graph-preview.d.ts +48 -0
  128. package/dist/src/graph-preview.js +56 -0
  129. package/dist/src/graph-provider-portability.js +2 -1
  130. package/dist/src/graph-runner.js +65 -4
  131. package/dist/src/graph-server.js +7 -5
  132. package/dist/src/graph-sync.js +3 -3
  133. package/dist/src/graph-ui/app.js +121 -7
  134. package/dist/src/graph-ui/icons.js +2 -1
  135. package/dist/src/graph-ui/studio.js +15 -1
  136. package/dist/src/graph-ui/tokens.css +1 -1
  137. package/dist/src/graphs.d.ts +40 -1
  138. package/dist/src/graphs.js +164 -15
  139. package/dist/src/hardened-runtime.js +32 -21
  140. package/dist/src/image-input.d.ts +16 -0
  141. package/dist/src/image-input.js +41 -0
  142. package/dist/src/membership.d.ts +10 -0
  143. package/dist/src/membership.js +19 -4
  144. package/dist/src/model-health-cache.js +1 -1
  145. package/dist/src/model-metadata.d.ts +6 -0
  146. package/dist/src/model-metadata.js +35 -15
  147. package/dist/src/model-override.d.ts +2 -1
  148. package/dist/src/model-override.js +9 -0
  149. package/dist/src/model-relay/local.d.ts +116 -0
  150. package/dist/src/model-relay/local.js +468 -0
  151. package/dist/src/model-relay/remote.d.ts +129 -0
  152. package/dist/src/model-relay/remote.js +252 -0
  153. package/dist/src/model-relay/runs.d.ts +34 -0
  154. package/dist/src/model-relay/runs.js +146 -0
  155. package/dist/src/model-relay/wire.d.ts +5 -0
  156. package/dist/src/model-relay/wire.js +5 -0
  157. package/dist/src/model-tiers.d.ts +3 -0
  158. package/dist/src/model-tiers.js +3 -3
  159. package/dist/src/project-registry.d.ts +21 -0
  160. package/dist/src/project-registry.js +74 -0
  161. package/dist/src/provider-engine.d.ts +13 -1
  162. package/dist/src/provider-engine.js +74 -0
  163. package/dist/src/provider-import.d.ts +0 -12
  164. package/dist/src/provider-import.js +7 -195
  165. package/dist/src/providers.d.ts +28 -2
  166. package/dist/src/providers.js +59 -12
  167. package/dist/src/pull-request-logs.d.ts +12 -1
  168. package/dist/src/pull-request-logs.js +14 -3
  169. package/dist/src/pull-requests.d.ts +338 -8
  170. package/dist/src/pull-requests.js +482 -53
  171. package/dist/src/react-runtime.js +99 -16
  172. package/dist/src/remote/engine-pool.d.ts +88 -4
  173. package/dist/src/remote/engine-pool.js +367 -90
  174. package/dist/src/remote/roots.d.ts +19 -0
  175. package/dist/src/remote/roots.js +45 -7
  176. package/dist/src/remote/types.d.ts +0 -44
  177. package/dist/src/run-control.d.ts +7 -0
  178. package/dist/src/run-control.js +23 -0
  179. package/dist/src/run-records.d.ts +7 -2
  180. package/dist/src/run-records.js +71 -6
  181. package/dist/src/runtime.d.ts +34 -2
  182. package/dist/src/runtime.js +18 -2
  183. package/dist/src/session-changes.d.ts +35 -0
  184. package/dist/src/session-changes.js +194 -6
  185. package/dist/src/session-monitor.js +2 -1
  186. package/dist/src/session-reaper.d.ts +1 -1
  187. package/dist/src/session-reaper.js +6 -1
  188. package/dist/src/session-summary.d.ts +2 -1
  189. package/dist/src/session-summary.js +2 -1
  190. package/dist/src/sessions.d.ts +35 -1
  191. package/dist/src/sessions.js +70 -4
  192. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  193. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  194. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  195. package/dist/src/skills/bundled/provenance.json +3 -3
  196. package/dist/src/skills/runtime-skills.js +1 -1
  197. package/dist/src/task-checkout.d.ts +141 -0
  198. package/dist/src/task-checkout.js +558 -0
  199. package/dist/src/telemetry/emitter.d.ts +15 -0
  200. package/dist/src/telemetry/emitter.js +35 -1
  201. package/dist/src/telemetry/schema.d.ts +25 -2
  202. package/dist/src/telemetry/schema.js +52 -4
  203. package/dist/src/telemetry/surface.d.ts +2 -1
  204. package/dist/src/telemetry/surface.js +4 -1
  205. package/dist/src/terminal-ui.d.ts +1 -0
  206. package/dist/src/terminal-ui.js +10 -3
  207. package/dist/src/test-edit-guard.d.ts +37 -0
  208. package/dist/src/test-edit-guard.js +216 -3
  209. package/dist/src/thinking-level-detect.d.ts +11 -0
  210. package/dist/src/thinking-level-detect.js +47 -0
  211. package/dist/src/thinking-levels.d.ts +30 -0
  212. package/dist/src/thinking-levels.js +124 -0
  213. package/dist/src/timers.d.ts +3 -0
  214. package/dist/src/tool-catalog.js +1 -1
  215. package/dist/src/tools.js +59 -9
  216. package/dist/src/transcript.js +1 -1
  217. package/dist/src/types.d.ts +34 -0
  218. package/package.json +6 -1
  219. package/dist/src/remote/cert.d.ts +0 -11
  220. package/dist/src/remote/cert.js +0 -87
  221. package/dist/src/remote/client.d.ts +0 -119
  222. package/dist/src/remote/client.js +0 -544
  223. package/dist/src/remote/command.d.ts +0 -4
  224. package/dist/src/remote/command.js +0 -194
  225. package/dist/src/remote/errors.d.ts +0 -11
  226. package/dist/src/remote/errors.js +0 -14
  227. package/dist/src/remote/network.d.ts +0 -22
  228. package/dist/src/remote/network.js +0 -102
  229. package/dist/src/remote/pairing.d.ts +0 -63
  230. package/dist/src/remote/pairing.js +0 -299
  231. package/dist/src/remote/pem.d.ts +0 -2
  232. package/dist/src/remote/pem.js +0 -7
  233. package/dist/src/remote/serve.d.ts +0 -68
  234. package/dist/src/remote/serve.js +0 -244
  235. package/dist/src/remote/server.d.ts +0 -21
  236. package/dist/src/remote/server.js +0 -406
@@ -18,6 +18,12 @@ export declare function promptText(blocks: readonly ContentBlock[]): string;
18
18
  export declare function toolKind(name: string): ToolKind;
19
19
  /** A short, readable title for a tool call: what it reads, changes, searches for or runs. */
20
20
  export declare function toolTitle(name: string, input: unknown, cwd: string): string;
21
+ /**
22
+ * What "Always allow" in a session covers: the tool, except that each of pull_request's writes of public text
23
+ * (reply, resolve, comment) is allowed on its own, so allowing a settings change never lets the agent post on
24
+ * GitHub unasked.
25
+ */
26
+ export declare function alwaysAllowKey(name: string, input: unknown): string;
21
27
  /** A file's text for a diff: null when it does not exist, undefined when it cannot be shown whole. */
22
28
  export type FileSnapshot = string | null | undefined;
23
29
  /**
@@ -288,6 +288,16 @@ export function toolTitle(name, input, cwd) {
288
288
  }
289
289
  /** Files larger than this are shown as a positioned text diff instead of whole before and after texts. */
290
290
  const MAX_DIFF_FILE_BYTES = 1_000_000;
291
+ /**
292
+ * What "Always allow" in a session covers: the tool, except that each of pull_request's writes of public text
293
+ * (reply, resolve, comment) is allowed on its own, so allowing a settings change never lets the agent post on
294
+ * GitHub unasked.
295
+ */
296
+ export function alwaysAllowKey(name, input) {
297
+ const tool = canonicalCodingToolName(name) ?? name;
298
+ const action = typeof input === 'object' && input !== null ? input.action : undefined;
299
+ return tool === 'pull_request' && (action === 'reply' || action === 'resolve' || action === 'comment') ? `pull_request ${action}` : tool;
300
+ }
291
301
  /** A text as lines that keep their own line endings. */
292
302
  function snapshotLines(text) {
293
303
  return text === null || text === '' ? [] : text.split(/(?<=\n)/);
@@ -551,11 +561,12 @@ export async function runAcpAgent(options = {}) {
551
561
  await new Promise(next => setImmediate(next));
552
562
  const name = typeof data.name === 'string' ? data.name : 'tool';
553
563
  const key = canonicalCodingToolName(name) ?? name;
554
- if (session.alwaysAllow.has(key)) {
564
+ const rawInput = toolInput(data.arguments);
565
+ const allowKey = alwaysAllowKey(name, rawInput);
566
+ if (session.alwaysAllow.has(allowKey)) {
555
567
  await answerApproval(id, true);
556
568
  return;
557
569
  }
558
- const rawInput = toolInput(data.arguments);
559
570
  // The engine asks after the call has started: point the request at that call, so the client shows one item.
560
571
  let matched;
561
572
  for (const [toolCallId, open] of [...openTools].reverse()) {
@@ -577,7 +588,7 @@ export async function runAcpAgent(options = {}) {
577
588
  toolCall: { toolCallId: matched ?? `approval-${id}`, title, kind: toolKind(name), status: 'pending', rawInput },
578
589
  options: [
579
590
  { optionId: 'allow', name: 'Allow', kind: 'allow_once' },
580
- { optionId: 'allow-always', name: `Always allow ${key} in this session`, kind: 'allow_always' },
591
+ { optionId: 'allow-always', name: `Always allow ${allowKey} in this session`, kind: 'allow_always' },
581
592
  { optionId: 'reject', name: 'Reject', kind: 'reject_once' },
582
593
  ],
583
594
  });
@@ -588,7 +599,7 @@ export async function runAcpAgent(options = {}) {
588
599
  }
589
600
  catch { }
590
601
  if (always)
591
- session.alwaysAllow.add(key);
602
+ session.alwaysAllow.add(allowKey);
592
603
  if (matched && approved)
593
604
  update({ sessionUpdate: 'tool_call_update', toolCallId: matched, status: 'in_progress' });
594
605
  await answerApproval(id, approved);
@@ -7,11 +7,14 @@ import { conversationContains, omittedContextNote, selectContext } from './conte
7
7
  import { MAPPED_INPUTS_HEADING } from './context-compaction.js';
8
8
  import { orderSkillCatalog, selectToolCatalog } from './tool-catalog.js';
9
9
  import { decideModelTier } from './model-tiers.js';
10
+ import { decideEffort, EFFORT_ESCALATION_REASONS } from './effort-routing.js';
11
+ import { nearestEnabled } from './thinking-levels.js';
12
+ import { REASONING_EFFORTS, supportsReasoningEffort } from './providers.js';
10
13
  import { structuredText } from './code-intelligence/CodeIntelligenceManager.js';
11
14
  import { buildMemoryBlock } from './memory/MemoryRetriever.js';
12
15
  import { discoverRuntimeSkills, matchRuntimeSkill, runtimeSkillTools } from './skills/runtime-skills.js';
13
16
  import { promptSkillReferences } from './skills/prompt-skills.js';
14
- import { BUG_REPORT_SKILL, bugReportTool } from './bug-report.js';
17
+ import { BUG_REPORT_SKILL, bugReportSessionsTool, bugReportTool } from './bug-report.js';
15
18
  import { toolFamilies, routeToolFamilies, decisionExecutionGuidance } from './decision/toolFamilies.js';
16
19
  import { allowsGraphRouting, route as codeGraphRoute } from './code-intelligence/ContextRouter.js';
17
20
  import { randomUUID } from 'node:crypto';
@@ -21,13 +24,13 @@ import { promisify } from 'node:util';
21
24
  import { mkdtemp, realpath } from 'node:fs/promises';
22
25
  import { tmpdir } from 'node:os';
23
26
  import { join, relative } from 'node:path';
24
- import { ClarificationRequiredError, DEFAULT_GRAPH, LIMIT_KEYS, isUnlimitedAlias, resolveLimits, turnModelTask } from './runtime.js';
27
+ import { ClarificationRequiredError, DEFAULT_GRAPH, LIMIT_KEYS, isUnlimitedAlias, resolveLimits, turnModelCompletion, turnModelTask } from './runtime.js';
25
28
  import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordDecisionEvent, recordEfficiencyEvent } from './telemetry/capture.js';
26
29
  import { bindUserWaits, createRuntimeBudget } from './deadline.js';
27
30
  import { createAgentEngine } from './hardened-runtime.js';
28
31
  import { completionTool } from './completion.js';
29
32
  import { applyToolProfile } from './tool-profile.js';
30
- import { DELIVERED_OUTCOME, GRAPH_MANAGER_GRAPH_ID, capabilitySubset, delegatesWriting, effectiveCapabilities, intakeCapabilities, isTestingNode, isWritingRole, laterAgentNodes, permitsBuiltInTool, testerOnEveryRoute } from './graphs.js';
33
+ import { DELIVERED_OUTCOME, GRAPH_MANAGER_GRAPH_ID, REVIEWER_GRAPH_ID, capabilitySubset, isolatedGraph, reviewerOutputProblem, delegatesWriting, effectiveCapabilities, intakeCapabilities, isTestingNode, isWritingRole, laterAgentNodes, permitsBuiltInTool, testerOnEveryRoute } from './graphs.js';
31
34
  import { DELEGATION_DIFF_LIMIT, LandingRestoreError, addChangeWorktree, assertDelegationGit, applyLanding, collectChange, prepareLanding, removeChangeWorktree, repositoryRoot, snapshotWorkspace } from './delegation-changes.js';
32
35
  import { stopQaProcessesUnder } from './qa/runtime/ProcessManager.js';
33
36
  import { qaGuidance } from './qa/guidance.js';
@@ -147,6 +150,8 @@ export async function executeAgentNode(node, options) {
147
150
  options = { ...options, runId: randomUUID() };
148
151
  const store = options.artifactStore ?? new ArtifactStore(options.runId ?? randomUUID());
149
152
  const orchestrator = node.agentRole === 'orchestrator';
153
+ // An isolated graph's agent (the review loop's reviewer) gets its configured tools and the completion tools, nothing more.
154
+ const isolated = isolatedGraph(options.graph?.id);
150
155
  // With declared outcomes the Orchestrator picks its route itself; with a single outcome, delegation needs a routed delivered port.
151
156
  const routedDelegation = orchestrator && delegatesWriting(node) && node.completion?.mode === 'outcomes';
152
157
  const delegationActive = routedDelegation || (orchestrator && delegatesWriting(node) && !!options.graph?.edges.some(edge => edge.source === node.id && edge.outcome === DELIVERED_OUTCOME));
@@ -362,8 +367,8 @@ export async function executeAgentNode(node, options) {
362
367
  throw new Error('Mapped inputs exceed context limit; pass artifact references instead');
363
368
  const configuredProvider = configured.provider ?? options.provider;
364
369
  const configuredModel = configured.model ?? (configured.provider === undefined ? options.model : undefined);
365
- const resolve = async (provider, model) => retryReadOnly(context, signal => options.resolveModel
366
- ? options.resolveModel(provider, model, signal)
370
+ const resolve = async (provider, model, effort) => retryReadOnly(context, signal => options.resolveModel
371
+ ? options.resolveModel(provider, model, signal, effort)
367
372
  : provider === options.provider ? { model: options.model, adapter: options.adapter, contextWindow: options.contextWindow } : options.resolveProvider?.(provider));
368
373
  let provider = configuredProvider, resolved = await resolve(provider, configuredModel);
369
374
  if (!resolved)
@@ -371,6 +376,14 @@ export async function executeAgentNode(node, options) {
371
376
  // The resolved model is the provider's own spelling of the configured one when they differ only in case.
372
377
  const spelled = (wanted, got) => wanted !== undefined && wanted.toLowerCase() === got.toLowerCase() ? got : wanted ?? got;
373
378
  let model = spelled(configured.model, resolved.model);
379
+ // The thinking level in force for this node's requests; a subagent that inherits the model runs at it too.
380
+ let activeEffort;
381
+ const asLevel = (value) => value !== undefined && REASONING_EFFORTS.includes(value) ? value : undefined;
382
+ const levelsFor = (id, name, type, forAuto) => options.thinkingLevels?.(id, name, forAuto) ?? (type === undefined || !supportsReasoningEffort(type) ? [] : forAuto ? ['low', 'medium', 'high'] : [...REASONING_EFFORTS]);
383
+ // The run's own model: the one it started on, or the one a live whole-run change moved it to.
384
+ let sessionModel = { provider: options.provider, model: options.model };
385
+ const wantedEffort = () => configured.reasoningEffort
386
+ ?? (options.sessionEffortAuto && depth === 0 && provider === sessionModel.provider && model === sessionModel.model ? 'auto' : undefined);
374
387
  let fallbackAttempt = parentFallback;
375
388
  const orchestratorCompletionGuard = () => {
376
389
  if (!clarified)
@@ -381,7 +394,7 @@ export async function executeAgentNode(node, options) {
381
394
  return 'Inspect relevant repository files, search or list the workspace (or obtain a successful research child result) before completing.';
382
395
  };
383
396
  let observedResearch = false;
384
- const codeManager = options.codeIntel;
397
+ const codeManager = isolated ? undefined : options.codeIntel;
385
398
  const codeLedger = codeManager?.createLedger();
386
399
  const codeIntel = codeManager?.active && permitsBuiltInTool(configured, 'repo_explore') ? codeManager : undefined;
387
400
  const researchTool = (name) => ['Read', 'Glob', 'Grep', 'git_read', 'repo_explore'].includes(canonicalToolName(name));
@@ -458,7 +471,7 @@ export async function executeAgentNode(node, options) {
458
471
  } });
459
472
  if (orchestrator && depth === 0 && effectiveCapabilities(configured).filesystem !== 'none')
460
473
  tools.push(removeUntrackedFileTool());
461
- if (!orchestrator && depth === 0 && options.context.approvalMode !== 'headless' && options.context.askUser)
474
+ if (!orchestrator && !isolated && depth === 0 && options.context.approvalMode !== 'headless' && options.context.askUser)
462
475
  tools.push({ name: 'ask_user', executionMode: 'sequential', description: 'Ask the user a question only they can answer and wait for the answer. Use it whenever a choice is theirs to make: a skill or instruction that says to ask, a preference, a missing requirement. A question written in your reply does not pause the run and may go unseen, so never ask that way. Ask one short question per call in plain language; when the options are known give 2-4 short choices, the recommended one first and labelled (Recommended). Do not ask what your tools can find out or what you can reasonably decide yourself. Before asking where something is or what a name refers to, finish a search for it by file name and by content; a search that was cut short or timed out does not count.',
463
476
  parameters: { type: 'object', properties: { question: { type: 'string', minLength: 1, maxLength: 500, description: 'One plain-language question.' }, choices: { type: 'array', items: { type: 'string', minLength: 1, maxLength: 200 }, minItems: 2, maxItems: 8, description: 'Short answers the user can pick from; they can always type their own.' } }, required: ['question'], additionalProperties: false },
464
477
  execute: async (args, ctx) => {
@@ -484,7 +497,7 @@ export async function executeAgentNode(node, options) {
484
497
  throw new Error('The answer exceeds 16000 characters; ask for a shorter decision.');
485
498
  return JSON.stringify({ answered: true, answer });
486
499
  } });
487
- if (depth === 0)
500
+ if (depth === 0 && !isolated)
488
501
  tools.push({ name: 'present_plan', executionMode: 'sequential', description: 'Present the implementation plan for the user to approve, reject, or send feedback on. Only meaningful while the run is in plan mode: file mutations and escalations stay refused until a plan is approved. Present one complete plan in markdown after researching; a later call may present a revised plan after feedback.',
489
502
  parameters: { type: 'object', properties: { plan: { type: 'string', minLength: 1, maxLength: 16000, description: 'The implementation plan in markdown: what will change, the files or areas touched, the approach, and how it will be verified.' } }, required: ['plan'], additionalProperties: false },
490
503
  execute: async (args, ctx) => {
@@ -569,7 +582,10 @@ export async function executeAgentNode(node, options) {
569
582
  const childProvider = policy.modelPolicy === 'specific' ? policy.provider ?? provider : policy.modelPolicy === 'per-role' ? role.provider ?? provider : provider;
570
583
  const childModel = policy.modelPolicy === 'specific' ? policy.model : policy.modelPolicy === 'per-role' ? role.model ?? (childProvider === provider ? model : undefined) : model;
571
584
  const child = { id: role.id, type: 'agent', executor: 'react-basic', name: role.name, instruction: role.instruction,
572
- provider: childProvider, ...(childModel ? { model: childModel } : {}), capabilities: childCapabilities, tools: childToolNames,
585
+ provider: childProvider, ...(childModel ? { model: childModel } : {}),
586
+ // With no model named, a child on the same provider runs that provider's default, which may not be the parent's.
587
+ ...(activeEffort !== undefined && childProvider === provider && childModel === model ? { reasoningEffort: activeEffort } : {}),
588
+ capabilities: childCapabilities, tools: childToolNames,
573
589
  completion: { mode: 'single', outcome: 'completed' }, inputSchema: role.inputSchema, outputSchema: role.outputSchema,
574
590
  contextPolicy: { history: false, maxChars: Math.min(contextChars, 16000) } };
575
591
  if (depth > 0 && active >= (policy.maxConcurrent ?? 3))
@@ -950,7 +966,7 @@ export async function executeAgentNode(node, options) {
950
966
  || options.efficiency?.projectSkillDiscovery === true
951
967
  || (options.efficiency?.projectSkillDiscovery !== false && options.decisionManager?.skillRoutingEnabled === true));
952
968
  const resourceReader = tools.find(tool => tool.name === 'read_skill_resource');
953
- const skills = discoverProjectSkills || requestedInheritedSkills.length > 0 || promptSkillNames.length > 0 || resourceReader || tools.some(tool => tool.name === 'qa.browser_session')
969
+ const skills = !isolated && (discoverProjectSkills || requestedInheritedSkills.length > 0 || promptSkillNames.length > 0 || resourceReader || tools.some(tool => tool.name === 'qa.browser_session'))
954
970
  ? await discoverRuntimeSkills(context.workspace, context.signal, tools.map(tool => tool.name), discoverProjectSkills) : [];
955
971
  // A skill inherited from earlier nodes that this node cannot load (broken locally, or no skill
956
972
  // reader among its tools) is left out for this node only; the run continues without it.
@@ -1000,9 +1016,9 @@ export async function executeAgentNode(node, options) {
1000
1016
  }).map(requirePublishedPlan) : [];
1001
1017
  if (skillTools.length)
1002
1018
  tools = tools.filter(tool => tool.name !== 'read_skill_resource');
1003
- // The report tool exists only in a run that carries the bug-report skill, so no other run pays for its schema.
1019
+ // The report tools exist only in a run that carries the bug-report skill, so no other run pays for their schemas.
1004
1020
  if (depth === 0 && [...inheritedSkills, ...promptSkills].includes(BUG_REPORT_SKILL))
1005
- tools.push(bugReportTool({ emit }));
1021
+ tools.push(bugReportSessionsTool(), bugReportTool({ emit }));
1006
1022
  const effectiveTask = typeof inputs.taskInstruction === 'string' && inputs.taskInstruction.trim() ? inputs.taskInstruction.trim() : task;
1007
1023
  const graphFirstSearch = depth === 0 && !!codeIntel?.active && codeGraphRoute(effectiveTask) === 'graph';
1008
1024
  const decisionTask = depth > 0 ? task : options.decisionPreflight?.task ?? effectiveTask;
@@ -1014,6 +1030,8 @@ export async function executeAgentNode(node, options) {
1014
1030
  ? options.workspaceFacts ?? await collectWorkspaceFacts(context.workspace, { signal: context.signal }) : undefined;
1015
1031
  const nodeBaseline = { provider, model };
1016
1032
  let routedTier;
1033
+ let effortLevel;
1034
+ let effortEscalated = false;
1017
1035
  let escalations = 0;
1018
1036
  let previousAttemptReason;
1019
1037
  let escalationPending = false;
@@ -1036,6 +1054,8 @@ export async function executeAgentNode(node, options) {
1036
1054
  const liveNodeId = `${node.id}${subagentId ? '/' + configured.id : ''}${fallbackAttempt ? '#fallback' : ''}`;
1037
1055
  const liveModel = await options.getLiveModel?.(liveNodeId, provider, model, context.signal);
1038
1056
  const liveSelected = liveModel !== undefined;
1057
+ if (liveModel?.sessionModel)
1058
+ sessionModel = { provider: liveModel.provider, model: liveModel.model };
1039
1059
  if (liveModel && (liveModel.provider !== provider || liveModel.model !== model)) {
1040
1060
  provider = liveModel.provider;
1041
1061
  model = liveModel.model;
@@ -1091,7 +1111,7 @@ export async function executeAgentNode(node, options) {
1091
1111
  const spendRepoRoom = (chars) => { repoBudget -= chars; repoPolicyRoom -= chars; };
1092
1112
  let committedChars = 0;
1093
1113
  if (depth === 0 && codeLedger && codeIntel) {
1094
- const historyChars = configured.contextPolicy?.history ? (options.history ?? []).reduce((sum, item) => sum + turnModelTask(item).length + JSON.stringify(item.completion).length, 0) : 0;
1114
+ const historyChars = configured.contextPolicy?.history ? (options.history ?? []).reduce((sum, item) => sum + turnModelTask(item).length + JSON.stringify(turnModelCompletion(item.completion)).length, 0) : 0;
1095
1115
  const toolSchemaChars = JSON.stringify(tools.map(tool => ({ name: tool.name, description: tool.description, parameters: tool.parameters }))).length;
1096
1116
  const contractChars = JSON.stringify({ outputSchema: configured.outputSchema, completion: configured.completion }).length;
1097
1117
  const todoChars = JSON.stringify(todoStore.snapshot()).length;
@@ -1110,7 +1130,7 @@ export async function executeAgentNode(node, options) {
1110
1130
  JSON.stringify(completionPolicy.mode === 'single' ? completionPolicy.outcome : completionPolicy.outcomes[0]),
1111
1131
  JSON.stringify(todoStore.snapshot())];
1112
1132
  const historyChars = JSON.stringify(configured.contextPolicy?.history ? (options.history ?? []).flatMap(turn => [
1113
- { role: 'user', content: turnModelTask(turn) }, { role: 'assistant', content: JSON.stringify(turn.completion) },
1133
+ { role: 'user', content: turnModelTask(turn) }, { role: 'assistant', content: JSON.stringify(turnModelCompletion(turn.completion)) },
1114
1134
  ]) : []).length;
1115
1135
  const schemaChars = JSON.stringify([...attemptTools, completionTool({ ...options, completionPolicy, outputSchema: configured.outputSchema })]
1116
1136
  .map(({ name, description, parameters }) => ({ name, description, parameters }))).length
@@ -1141,7 +1161,9 @@ export async function executeAgentNode(node, options) {
1141
1161
  consumers: { answerOnly: answerOnlyTask(decisionTask),
1142
1162
  adaptiveRouting: attempt === 1 && depth === 0 && !subagentId && !fallbackAttempt
1143
1163
  && configured.provider === undefined && configured.model === undefined && !options.modelPinned && !liveSelected
1144
- && hasAdaptiveAlternative(efficiency.adaptiveRouting, nodeBaseline, options.configuredModels ?? []),
1164
+ && hasAdaptiveAlternative(efficiency.adaptiveRouting, nodeBaseline, options.configuredModels ?? [])
1165
+ // A node on Auto thinking needs the same three answers to pick among its model's levels.
1166
+ || attempt === 1 && depth === 0 && !subagentId && wantedEffort() === 'auto' && levelsFor(provider, model, resolved?.providerType, true).length >= 2,
1145
1167
  },
1146
1168
  }, { runId: options.runId, nodeId: configured.id, invocationId: randomUUID(), ...(subagentId ? { subagentId } : {}) }, { codeGraph: depth === 0 && !!codeIntel?.active && repoRoom() >= 512 && codeGraphRoute(effectiveTask) === 'graph', memory: depth === 0 && (options.decisionPreflight?.memory ?? (configured.agentRole !== 'orchestrator' && !!options.memory?.activeFor(options.runId) && options.memory.automaticRetrieval)) }, signal, event => {
1147
1169
  if (signal.aborted)
@@ -1235,6 +1257,62 @@ export async function executeAgentNode(node, options) {
1235
1257
  }
1236
1258
  await emitEfficiency('efficiency.routing.decided', { tier: decision.tier, reason: unresolved ? 'unconfigured' : decision.reason, evidence: decision.evidence, applied, served, attempt });
1237
1259
  }
1260
+ {
1261
+ // The thinking level is settled once per attempt, before the first request, and held for the whole attempt:
1262
+ // a change between requests makes the provider re-read the conversation uncached.
1263
+ const wanted = wantedEffort();
1264
+ const current = asLevel(resolved.reasoningEffort);
1265
+ const enabled = levelsFor(provider, model, resolved.providerType, false);
1266
+ if (wanted === undefined) {
1267
+ // The saved level is the session's or the provider's. A level switched off for this model is never sent.
1268
+ const allowed = current === undefined || enabled.length === 0 ? current : nearestEnabled(enabled, current);
1269
+ activeEffort = current;
1270
+ if (allowed !== undefined && allowed !== current) {
1271
+ try {
1272
+ const levelled = await resolve(provider, model, allowed);
1273
+ if (levelled) {
1274
+ resolved = levelled;
1275
+ activeEffort = allowed;
1276
+ }
1277
+ }
1278
+ catch {
1279
+ context.signal.throwIfAborted();
1280
+ }
1281
+ await emitEfficiency('efficiency.effort.decided', { mode: 'fixed', wanted: current, level: allowed, evidence: 'fixed', applied: activeEffort === allowed, attempt, ...(subagentId ? { subagentId } : {}) });
1282
+ }
1283
+ }
1284
+ else {
1285
+ // Auto chooses among its own list; when that list is empty (every widely accepted level of an undetected
1286
+ // model was switched off) it chooses among everything still enabled, so a switched-off level is never kept.
1287
+ const forAuto = wanted === 'auto' ? levelsFor(provider, model, resolved.providerType, true) : [];
1288
+ const levels = forAuto.length > 0 ? forAuto : enabled;
1289
+ const decision = wanted === 'auto'
1290
+ // The task as the user wrote it, which is also what Jev was asked about.
1291
+ ? decideEffort({ task: decisionTask, levels, hints: depth === 0 && !subagentId ? activeRouting?.decisions : undefined, fallback: current,
1292
+ previous: attempt > 1 && effortLevel !== undefined ? { level: effortLevel, reason: previousAttemptReason } : undefined })
1293
+ : { level: nearestEnabled(levels, wanted), evidence: 'fixed' };
1294
+ let inForce = current;
1295
+ if (decision.level !== undefined && decision.level !== current) {
1296
+ try {
1297
+ const levelled = await resolve(provider, model, decision.level);
1298
+ if (levelled) {
1299
+ resolved = levelled;
1300
+ inForce = decision.level;
1301
+ }
1302
+ }
1303
+ catch {
1304
+ context.signal.throwIfAborted();
1305
+ }
1306
+ }
1307
+ effortLevel = wanted === 'auto' ? decision.level : undefined;
1308
+ activeEffort = inForce;
1309
+ if (wanted === 'auto' || decision.level !== wanted) {
1310
+ await emitEfficiency('efficiency.effort.decided', { mode: wanted === 'auto' ? 'auto' : 'fixed', ...(wanted === 'auto' ? {} : { wanted }),
1311
+ ...(decision.level === undefined ? {} : { level: decision.level }), evidence: decision.evidence, applied: decision.level !== undefined && inForce === decision.level, attempt,
1312
+ ...(subagentId ? { subagentId } : {}) });
1313
+ }
1314
+ }
1315
+ }
1238
1316
  const inheritedConversation = depth === 0 && configured.contextPolicy?.conversation !== 'isolate' && configured.contextPolicy?.skillInheritance !== 'none'
1239
1317
  && options.previousConversation?.provider === provider && options.previousConversation.model === model ? options.previousConversation : undefined;
1240
1318
  const historicalToolNames = [...new Set((inheritedConversation?.messages ?? []).flatMap(message => (message.toolCalls ?? []).map(call => call.name)))];
@@ -1477,7 +1555,7 @@ export async function executeAgentNode(node, options) {
1477
1555
  return [...replay, ...fresh];
1478
1556
  };
1479
1557
  result = await createAgentEngine().execute({ ...options, instructions: nodeInstructions || undefined, todoStore, context, provider, model,
1480
- todoList: options.todoList !== false && options.graph?.id !== GRAPH_MANAGER_GRAPH_ID,
1558
+ todoList: options.todoList !== false && options.graph?.id !== GRAPH_MANAGER_GRAPH_ID && !isolated,
1481
1559
  efficiency: configured.tools && options.efficiency?.toolMenuRouting
1482
1560
  ? { ...options.efficiency, toolMenuRouting: { ...options.efficiency.toolMenuRouting, pinnedTools: [...new Set([...(options.efficiency.toolMenuRouting.pinnedTools ?? []), ...configured.tools.map(canonicalToolName)])] } }
1483
1561
  : options.efficiency,
@@ -1523,8 +1601,9 @@ export async function executeAgentNode(node, options) {
1523
1601
  if (!routedDelegation && !records.some(change => change.state === 'landed'))
1524
1602
  return 'Land at least one accepted change before completing as delivered.';
1525
1603
  }
1526
- } : depth === 0 && policy.enabled ? () => backgroundGuard() ?? (inheritedSkills.length || promptSkills.length ? missingSkillError() : undefined)
1527
- : inheritedSkills.length || promptSkills.length ? () => missingSkillError() : undefined, completionPolicy, outputSchema: configured.outputSchema,
1604
+ } : isolated && depth === 0 && options.graph?.id === REVIEWER_GRAPH_ID ? completion => reviewerOutputProblem(completion.output)
1605
+ : depth === 0 && policy.enabled ? () => backgroundGuard() ?? (inheritedSkills.length || promptSkills.length ? missingSkillError() : undefined)
1606
+ : inheritedSkills.length || promptSkills.length ? () => missingSkillError() : undefined, completionPolicy, outputSchema: configured.outputSchema,
1528
1607
  history: configured.contextPolicy?.history ? options.history : [],
1529
1608
  task: attemptRepoBlock ? `${taskBase}\n\n${attemptRepoBlock}` : taskBase,
1530
1609
  onUsage: (usage, origin) => {
@@ -1549,7 +1628,17 @@ export async function executeAgentNode(node, options) {
1549
1628
  if (attempt === attempts)
1550
1629
  attempts = attempt + 1;
1551
1630
  }
1552
- if (!escalate && (result.status !== 'infrastructure_error' || result.providerRequestFailed || attempt === attempts))
1631
+ // A node on Auto thinking that ran out of steps gets one more attempt a level higher, when there is one.
1632
+ const effortLevels = effortLevel === undefined ? [] : levelsFor(provider, model, resolved.providerType, true);
1633
+ const raiseEffort = !escalate && !effortEscalated && depth === 0 && !subagentId && effortLevel !== undefined && result.status === 'exhausted'
1634
+ && EFFORT_ESCALATION_REASONS.has(result.reason ?? '') && effortLevels.indexOf(effortLevel) < effortLevels.length - 1 && !context.signal.aborted
1635
+ && (options.budget === undefined || options.budget.maxToolCalls === undefined || options.budget.toolCalls < options.budget.maxToolCalls);
1636
+ if (raiseEffort) {
1637
+ effortEscalated = true;
1638
+ if (attempt === attempts)
1639
+ attempts = attempt + 1;
1640
+ }
1641
+ if (!escalate && !raiseEffort && (result.status !== 'infrastructure_error' || result.providerRequestFailed || attempt === attempts))
1553
1642
  break;
1554
1643
  await emit('agent.retry', { attempt, reason: result.reason, ...(escalate ? { escalation: true, tier: routedTier } : {}) });
1555
1644
  if (configured.retry?.fallback) {
@@ -18,6 +18,7 @@ export const AGENT_MCP_CATALOG = [
18
18
  { name: 'andorra_graph_edge_upsert', description: 'Create or replace an edge. Outcome must match a source node port (pass/fail, true/false, body/done...).', inputSchema: obj({ draftId: str, edge: { type: 'object' } }, ['draftId', 'edge']) },
19
19
  { name: 'andorra_graph_edge_remove', description: 'Remove an edge by ID from a draft.', inputSchema: obj({ ...graphDraftSchema, edgeId: str }, ['draftId', 'edgeId']) },
20
20
  { name: 'andorra_graph_patch', description: 'Set graph entry, name, limits, schemas, widgets or metadata in a draft.', inputSchema: obj({ draftId: str, patch: { type: 'object' } }, ['draftId', 'patch']) },
21
+ { name: 'andorra_graph_show', description: 'Show a graph to the user in the chat. The Andorra desktop app draws it the way the Graph Editor does (steps, models, outcome routes, the entry); other hosts get the reply\'s plain-text sketch. Pass draftId for a draft, or id (and optionally revision) for a published graph. Use it whenever you present, sketch or review a graph, instead of drawing a diagram.', inputSchema: obj({ draftId: str, id: str, revision: { type: 'integer', minimum: 1 } }) },
21
22
  { name: 'andorra_graph_validate', description: 'Validate a draft; report all missing provider and outcome paths, plus graph topology issues.', inputSchema: obj(graphDraftSchema, ['draftId']) },
22
23
  { name: 'andorra_graph_publish', description: 'Validate and atomically publish the next immutable graph revision; optimistic concurrency guards other editors.', inputSchema: obj(graphDraftSchema, ['draftId']) },
23
24
  { name: 'andorra_graph_delete', description: 'Soft-delete a graph after the user confirms in chat: publishes a revision marked deleted, hides it from listings and new runs, keeps every revision. confirm must repeat the id.', inputSchema: obj({ id: str, expectedRevision: { type: 'integer', minimum: 1 }, confirm: str }, ['id', 'expectedRevision', 'confirm']) },
@@ -40,6 +40,8 @@ export interface AgentMcpBackendOptions {
40
40
  subagentWorkspace?: string;
41
41
  subagentAdapterFactory?: (provider: import('./providers.js').ProviderConfig) => ModelAdapter;
42
42
  recoverRuns?: boolean;
43
+ /** Whether a desktop app draws andorra_graph_show replies; defaults to running under one (ANDORRA_DESKTOP_HOST_PID). */
44
+ desktopHost?: boolean;
43
45
  }
44
46
  export declare const GRAPH_AGENT_GUIDE: string;
45
47
  export declare class AgentMcpError extends Error {
@@ -81,6 +83,7 @@ export declare class AgentMcpBackend {
81
83
  private assertGraphIdentity;
82
84
  private obtainDraft;
83
85
  private providers;
86
+ private showGraph;
84
87
  private setDeleted;
85
88
  private readGraph;
86
89
  private upsertNode;
@@ -18,6 +18,9 @@ import { AutomationStore } from './automations.js';
18
18
  import { canonicalWorkspace, MAX_SUBAGENT_TASK_CHARS, SubagentInvalidArgumentError, SubagentProviderNotSetError, SubagentRunInProgressError, SubagentRunner, SubagentSelectionError } from './subagent-run.js';
19
19
  import { reconcileInterruptedRuns } from './run-records.js';
20
20
  import { AGENT_MCP_CATALOG, AGENT_MCP_TOOL_NAMES } from './agent-mcp-catalog.js';
21
+ import { graphPreview, graphSketch } from './graph-preview.js';
22
+ /** The longest andorra_graph_show reply that still carries its sketch, inside the 24,000-character tool event. */
23
+ const SHOW_REPLY_BUDGET = 20_000;
21
24
  export const GRAPH_AGENT_GUIDE = [
22
25
  '# Andorra Code Graph Agent Architecture (MCP)',
23
26
  '',
@@ -32,6 +35,7 @@ export const GRAPH_AGENT_GUIDE = [
32
35
  '4. andorra_graph_edge_upsert links the exact source outcome to a target node.',
33
36
  '5. andorra_graph_patch sets entry, name, limits, widgets and schemas.',
34
37
  '6. andorra_graph_validate returns all missing-provider and missing-path issues plus the structural validator error.',
38
+ ' andorra_graph_show draws a draft (draftId) or a published graph (id) for the user in the chat; use it instead of a diagram.',
35
39
  '7. andorra_graph_publish validates and saves an optimistic, immutable revision. Fix issues; do not suppress them.',
36
40
  '8. andorra_graph_discard abandons a draft. Drafts are process-local, expire after an hour and are not published until saved.',
37
41
  '',
@@ -52,6 +56,10 @@ export const GRAPH_AGENT_GUIDE = [
52
56
  ' A cycle still needs a ceiling: graph.limits.maxNodeVisits or graph.limits.wallTimeMs, one of the two.',
53
57
  ' A finite graph.limits.maxNodeVisits must be large enough for loop maxIterations plus reentry.',
54
58
  'approval: ports approved and rejected. The live runtime asks the person before advancing.',
59
+ 'review: Andorra review of the task\'s pull request; requires review {rounds 1-10, when "ready"|"always", instruction <= 2 KiB, provider and model together or neither}.',
60
+ ' Ports findings, clean and stopped. Each visit posts one review as andorra-code[bot]; route findings back to the Agent that fixes them',
61
+ ' with inputMapping {taskInstruction: "$source.output.prompt"}, and clean and stopped onward. On a cycle, a finite graph.limits.maxNodeVisits must be at least rounds.',
62
+ ' Output: round, rounds, loop, head, reviewUrl, findings [{priority, where, threadId, url, path, line, title}], nits, reason, prompt.',
55
63
  'join: join {mode:"all"|"any"}. Join all must not wait on mutually exclusive outcome branches.',
56
64
  'parallel: fan-out; connect its completed port to downstream work.',
57
65
  'action: action {kind:"command"|"tests"|"git",command:"..."}; graph capability constraints still apply.',
@@ -149,7 +157,7 @@ function draftId(args) {
149
157
  throw new AgentMcpError('INVALID_DRAFT', 'draftId must be the UUID returned by andorra_graph_begin.');
150
158
  return value;
151
159
  }
152
- const knownTypes = ['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval'];
160
+ const knownTypes = ['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval', 'review'];
153
161
  const CARD_WIDTH = 210, CARD_HEIGHT = 94, PORT_HEIGHT = 25;
154
162
  const UNPLACED_SPACING = 290;
155
163
  const COORDINATE_LIMIT = 100_000;
@@ -423,6 +431,28 @@ export class AgentMcpBackend {
423
431
  // not only its default; without it validation rejects a graph the app itself runs.
424
432
  return { providers: config.providers.map(({ id, model, type, models }) => ({ id, model, type, ...(models?.length ? { models: [...models] } : {}) })), active: config.provider };
425
433
  }
434
+ async showGraph(args, access) {
435
+ const byDraft = args.draftId !== undefined, byId = args.id !== undefined;
436
+ if (byDraft === byId)
437
+ throw new AgentMcpError('INVALID_ARGUMENTS', 'Pass draftId to show a draft, or id (and optionally revision) to show a published graph, not both.');
438
+ const revision = args.revision;
439
+ if (revision !== undefined && (byDraft || typeof revision !== 'number' || !Number.isSafeInteger(revision) || revision < 1))
440
+ throw new AgentMcpError('INVALID_ARGUMENTS', 'revision must be a positive safe integer, and only with id.');
441
+ const graph = byDraft ? this.obtainDraft(draftId(args), access).graph : await this.readGraph(field(args, 'id'), access.directory, revision);
442
+ await this.assertGraphIdentity(access);
443
+ const { providers, active } = await this.providers();
444
+ const deleted = !byDraft && isDeletedGraph(graph);
445
+ const preview = { ...graphPreview(graph, byDraft ? 'draft' : graph.revision, provider => providers.find(item => item.id === (provider ?? active))?.model),
446
+ ...(deleted ? { deleted: true } : {}) };
447
+ const drawn = this.options.desktopHost ?? Boolean(process.env.ANDORRA_DESKTOP_HOST_PID);
448
+ // The chat reads the reply from an event cut at 24,000 characters; the sketch goes only while the whole reply stays well inside it.
449
+ const sketch = graphSketch(preview);
450
+ const fits = JSON.stringify({ preview, sketch }).length <= SHOW_REPLY_BUDGET;
451
+ const note = drawn
452
+ ? 'The Andorra desktop app draws this graph in the chat; do not draw it again or retype it as arrows.'
453
+ : fits ? 'Nothing in this host draws the graph: put the sketch in your reply.' : 'Nothing in this host draws the graph, and it is too large for a sketch: describe its steps and routes in words.';
454
+ return { preview, ...(fits ? { sketch } : {}), ...(deleted ? { deletedAt: graph.metadata.deletedAt } : {}), note };
455
+ }
426
456
  async setDeleted(deleting, args, access, beforeSave) {
427
457
  const tool = deleting ? 'andorra_graph_delete' : 'andorra_graph_restore';
428
458
  const id = field(args, 'id');
@@ -814,6 +844,8 @@ export class AgentMcpBackend {
814
844
  publishing: false, touched: Date.now(), authoredAgents: new Set() });
815
845
  return { draftId: key, graph, expectedRevision, note: 'This draft is local to this MCP process until published.' };
816
846
  }
847
+ if (name === 'andorra_graph_show')
848
+ return this.showGraph(args, access);
817
849
  if (name === 'andorra_graph_discard') {
818
850
  const key = draftId(args);
819
851
  this.obtainDraft(key, access);
@@ -17,5 +17,15 @@ export declare function applyAndorraEntry(config: Config, answer: HostedAnswer,
17
17
  * Andorra is offered and not saved yet. It exists in memory only; nothing validates, saves or sends requests with it.
18
18
  */
19
19
  export declare function virtualAndorraEntry(config: Pick<Config, 'providers'>, answer: HostedAnswer): ProviderConfig | undefined;
20
+ /**
21
+ * The move an Andorra entry made when the model it was on left the offer: the display names of the model before
22
+ * and after (the id where the router gave no other name). Undefined when the entry is new, gone, on the same
23
+ * model, or changed model while the old one is still served (the user's own pick).
24
+ */
25
+ export declare function andorraModelSwitch(before: Pick<Config, 'providers'>, after: Pick<Config, 'providers'>): {
26
+ id: string;
27
+ from: string;
28
+ to: string;
29
+ } | undefined;
20
30
  /** The provider to select when the active one goes away: never Andorra by position. */
21
31
  export declare function fallbackProviderId(providers: readonly Pick<ProviderConfig, 'id' | 'type'>[]): string;
@@ -1,5 +1,5 @@
1
1
  import { reconcileSubagentPair } from '../config.js';
2
- import { applyModelContextWindow, MAX_MODEL_DISPLAY_NAME_LENGTH } from '../providers.js';
2
+ import { applyModelContextWindow, MAX_MODEL_DISPLAY_NAME_LENGTH, modelDisplayName } from '../providers.js';
3
3
  import { ANDORRA_PROVIDER_BASE_URL } from './endpoint.js';
4
4
  const ANDORRA_ID = 'andorra';
5
5
  const ANDORRA_NAME = 'Andorra';
@@ -77,8 +77,10 @@ export function applyAndorraEntry(config, answer, mode) {
77
77
  const modelNames = hostedNames(answer);
78
78
  const modelParameters = hostedParameters(answer);
79
79
  const freeModels = answer.models.filter(model => model.free === true).map(model => model.id);
80
+ const textOnlyModels = answer.models.filter(model => model.imageInput === false).map(model => model.id);
80
81
  const named = { ...(Object.keys(modelNames).length ? { modelNames } : {}),
81
- ...(Object.keys(modelParameters).length ? { modelParameters } : {}), ...(freeModels.length ? { freeModels } : {}) };
82
+ ...(Object.keys(modelParameters).length ? { modelParameters } : {}), ...(freeModels.length ? { freeModels } : {}),
83
+ ...(textOnlyModels.length ? { textOnlyModels } : {}) };
82
84
  const index = config.providers.findIndex(provider => provider.type === 'andorra');
83
85
  if (index < 0) {
84
86
  if (mode !== 'create')
@@ -91,9 +93,9 @@ export function applyAndorraEntry(config, answer, mode) {
91
93
  const model = models.includes(existing.model) ? existing.model : models[0];
92
94
  if (model === existing.model && sameList(existing.models, models) && sameWindows(existing.modelContextWindows, modelContextWindows)
93
95
  && sameNames(existing.modelNames, modelNames) && sameNumbers(existing.modelParameters, modelParameters)
94
- && sameList(existing.freeModels ?? [], freeModels))
96
+ && sameList(existing.freeModels ?? [], freeModels) && sameList(existing.textOnlyModels ?? [], textOnlyModels))
95
97
  return undefined;
96
- const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, ...rest } = existing;
98
+ const { modelNames: _previous, modelParameters: _sizes, freeModels: _free, textOnlyModels: _textOnly, ...rest } = existing;
97
99
  const refreshed = { ...rest, model, models, modelContextWindows, ...named };
98
100
  if (refreshed.contextWindow !== undefined)
99
101
  applyModelContextWindow(refreshed, model);
@@ -112,6 +114,18 @@ export function virtualAndorraEntry(config, answer) {
112
114
  return undefined;
113
115
  return applyAndorraEntry({ version: 1, provider: '', providers: [...config.providers] }, answer, 'create')?.providers[0];
114
116
  }
117
+ /**
118
+ * The move an Andorra entry made when the model it was on left the offer: the display names of the model before
119
+ * and after (the id where the router gave no other name). Undefined when the entry is new, gone, on the same
120
+ * model, or changed model while the old one is still served (the user's own pick).
121
+ */
122
+ export function andorraModelSwitch(before, after) {
123
+ const next = after.providers.find(provider => provider.type === 'andorra');
124
+ const previous = next && before.providers.find(provider => provider.type === 'andorra' && provider.id === next.id);
125
+ if (!next || !previous || previous.model === next.model || !next.models || next.models.includes(previous.model))
126
+ return undefined;
127
+ return { id: next.id, from: modelDisplayName(previous, previous.model), to: modelDisplayName(next, next.model) };
128
+ }
115
129
  /** The provider to select when the active one goes away: never Andorra by position. */
116
130
  export function fallbackProviderId(providers) {
117
131
  return providers.find(provider => provider.type !== 'andorra')?.id ?? providers[0]?.id ?? '';
@@ -35,5 +35,8 @@ export function andorraRefusal(status, body, retryAfter) {
35
35
  const seconds = retrySeconds(retryAfter);
36
36
  return `Andorra is busy. Try again in ${seconds === undefined ? 'a moment' : `${seconds} second${seconds === 1 ? '' : 's'}`}.`;
37
37
  }
38
+ if (status === 429 && code === 'stream_limit_reached') {
39
+ return 'You are running your limit of concurrent requests. Finish one before starting another.';
40
+ }
38
41
  return undefined;
39
42
  }
@@ -1,10 +1,11 @@
1
- /** `parametersBillions`: the model's size, where the router states one. `free`: served past the weekly allowance. */
1
+ /** `parametersBillions`: the model's size, where the router states one. `free`: served past the weekly allowance. `imageInput: false`: text-only, never sent images. */
2
2
  export interface HostedModel {
3
3
  id: string;
4
4
  name: string;
5
5
  contextWindow: number;
6
6
  parametersBillions?: number;
7
7
  free?: boolean;
8
+ imageInput?: false;
8
9
  }
9
10
  /** How much of the account's weekly allowance is used (0-100) and when it renews (ISO timestamp). */
10
11
  export interface HostedAllowance {
@@ -24,7 +24,8 @@ export function parseHostedAnswer(value) {
24
24
  // Both are optional and descriptive: a malformed one is dropped on its own and never fails the answer.
25
25
  models.push({ id: item.id, name, contextWindow: item.contextWindow,
26
26
  ...(isModelParameters(item.parametersBillions) ? { parametersBillions: item.parametersBillions } : {}),
27
- ...(item.free === true ? { free: true } : {}) });
27
+ ...(item.free === true ? { free: true } : {}),
28
+ ...(item.imageInput === false ? { imageInput: false } : {}) });
28
29
  }
29
30
  const answer = { enabled: true, promotionId: body.promotionId, models };
30
31
  const allowance = parseAllowance(body.allowance);
@@ -9,6 +9,11 @@ export declare function andorraAnnouncement(random?: () => number): string;
9
9
  export declare const ANDORRA_ADD_HINT = "Choose Andorra in /model to use it.";
10
10
  /** Said when the model the user picked is not served by the entry that was just saved (the offer changed meanwhile). */
11
11
  export declare const ANDORRA_MODEL_GONE = "That model is no longer available.";
12
+ /**
13
+ * Said when the Andorra model the user was on left the offer and they were moved to another one. `from` and `to`
14
+ * are display names; without a name for the one that went, the sentence does not guess at one.
15
+ */
16
+ export declare function andorraModelSwitched(from: string | undefined, to: string): string;
12
17
  /** The last line of the bubble, in two parts so the terminal can draw the tail as part of the box. */
13
18
  export declare const ANDORRA_BUBBLE_TAIL = " \u2570 ";
14
19
  export declare const ANDORRA_BUBBLE_SPEAKER = "Andorra";
@@ -23,6 +23,13 @@ export function andorraAnnouncement(random = Math.random) {
23
23
  export const ANDORRA_ADD_HINT = 'Choose Andorra in /model to use it.';
24
24
  /** Said when the model the user picked is not served by the entry that was just saved (the offer changed meanwhile). */
25
25
  export const ANDORRA_MODEL_GONE = 'That model is no longer available.';
26
+ /**
27
+ * Said when the Andorra model the user was on left the offer and they were moved to another one. `from` and `to`
28
+ * are display names; without a name for the one that went, the sentence does not guess at one.
29
+ */
30
+ export function andorraModelSwitched(from, to) {
31
+ return `${from ?? 'Your Andorra model'} is not available at the moment. Switched to ${to}.`;
32
+ }
26
33
  /** The last line of the bubble, in two parts so the terminal can draw the tail as part of the box. */
27
34
  export const ANDORRA_BUBBLE_TAIL = ' ╰ ';
28
35
  export const ANDORRA_BUBBLE_SPEAKER = 'Andorra';
@@ -69,8 +69,9 @@ export declare function removingAndorraEntry<T>(home: string, save: () => Promis
69
69
  export declare function recordAndorraRemoved(home?: string): Promise<boolean>;
70
70
  /**
71
71
  * What one client surface should say about a new answer, and what it has now seen. `entry` is the user's decision:
72
- * a removed provider is silent, and the turned-off notice is only for someone who added the provider. The surface
73
- * is advanced in every case, so nothing replays later.
72
+ * a removed provider is silent, and the turned-off notice is only for someone who added the provider. A model
73
+ * leaving an offer that stays on is not said here: the client that was on it is moved and told which one it is on
74
+ * now (`andorraModelSwitch`). The surface is advanced in every case, so nothing replays later.
74
75
  */
75
76
  export declare function advanceSurface(surface: SurfaceState | undefined, answer: HostedAnswer, entry?: AndorraEntryState): {
76
77
  surface: SurfaceState;
@@ -213,14 +213,14 @@ export function recordAndorraRemoved(home = configDirectory()) {
213
213
  }
214
214
  /**
215
215
  * What one client surface should say about a new answer, and what it has now seen. `entry` is the user's decision:
216
- * a removed provider is silent, and the turned-off notice is only for someone who added the provider. The surface
217
- * is advanced in every case, so nothing replays later.
216
+ * a removed provider is silent, and the turned-off notice is only for someone who added the provider. A model
217
+ * leaving an offer that stays on is not said here: the client that was on it is moved and told which one it is on
218
+ * now (`andorraModelSwitch`). The surface is advanced in every case, so nothing replays later.
218
219
  */
219
220
  export function advanceSurface(surface, answer, entry) {
220
221
  const ids = answer.enabled ? answer.models.map(m => m.id) : [];
221
222
  const fresh = answer.enabled && !!answer.promotionId && answer.promotionId !== surface?.announced;
222
- const lostModel = (surface?.models ?? []).some(id => !ids.includes(id));
223
- const changed = surface?.available === true && (!answer.enabled || lostModel);
223
+ const changed = surface?.available === true && !answer.enabled;
224
224
  const next = {};
225
225
  const announced = fresh ? answer.promotionId : surface?.announced;
226
226
  if (announced !== undefined)