@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
@@ -143,7 +143,7 @@ function plainGraphError(message, graph) {
143
143
  if ((found = /^edge \S+: nonexistent outcome (\S+)/.exec(detail))) return { message: `A connection starts from the outcome “${found[1]}”, which its step no longer has. Remove it or pick another outcome.`, nodeId: null };
144
144
  if (/^duplicate edge /.test(detail)) return { message: 'Two connections join the same outcome to the same step. Remove one of them.', nodeId: null };
145
145
  if ((found = /^Join (\S+) needs an incoming branch$/.exec(detail))) return { message: `${name(found[1])}: connect at least one step into this Join.`, nodeId: found[1] };
146
- if ((found = /^(?:node|Join|Condition|Loop|Agent) (\S+?)(:\s*| )([\s\S]*)$/.exec(detail)) && nodes[found[1]]) {
146
+ if ((found = /^(?:node|Join|Condition|Loop|Agent|Andorra review) (\S+?)(:\s*| )([\s\S]*)$/.exec(detail)) && nodes[found[1]]) {
147
147
  return { message: `${name(found[1])}: ${sentence(words(found[3]))}`, nodeId: found[1] };
148
148
  }
149
149
  return { message: sentence(words(detail)), nodeId: null };
@@ -284,6 +284,7 @@ function outcomes(node) {
284
284
  if (node.type === 'condition') return ['true', 'false'];
285
285
  if (node.type === 'loop') return ['body', 'done'];
286
286
  if (node.type === 'approval') return ['approved', 'rejected'];
287
+ if (node.type === 'review') return ['findings', 'clean', 'stopped'];
287
288
  if (node.completion?.mode === 'outcomes') return node.completion.outcomes;
288
289
  const outcome = node.completion?.outcome ?? 'completed';
289
290
  // An Action's command that exits non-zero takes the optional failed port; unrouted, it stops the run.
@@ -327,7 +328,7 @@ function routeSelectionTo(targetId) {
327
328
  if (sources.some(node => !node || !outcomes(node).includes(pick.outcome)) || sources.some(node => selectionType(node) !== selectionType(sources[0]))) { state.routePick=null; renderInspector(); status('The selection changed. Select matching steps and choose an outcome again.',true); return; }
328
329
  mutate(() => {
329
330
  const existing = state.graph.edges;
330
- const replacements = sources.map(node => existing.find(edge => edge.source === node.id && edgeOutcome(edge) === pick.outcome && edge.target === targetId) || {id:`edge-${crypto.randomUUID().slice(0,8)}`,source:node.id,target:targetId,outcome:pick.outcome});
331
+ const replacements = sources.map(node => existing.find(edge => edge.source === node.id && edgeOutcome(edge) === pick.outcome && edge.target === targetId) || {id:`edge-${crypto.randomUUID().slice(0,8)}`,source:node.id,target:targetId,outcome:pick.outcome,...reviewFindingsMapping(node,target,pick.outcome)});
331
332
  state.graph.edges = [...existing.filter(edge => !pick.sources.includes(edge.source) || edgeOutcome(edge) !== pick.outcome),...replacements];
332
333
  state.routePick = null;
333
334
  },true);
@@ -802,13 +803,46 @@ function dismissCanvasHint() {
802
803
  try { localStorage.setItem(HINT_KEY, '1'); } catch { }
803
804
  if (!state.routePick && $('canvas-hint')) $('canvas-hint').hidden = true;
804
805
  }
806
+ const THINKING_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
807
+ /** The thinking levels a node's model has enabled here, lowest first; empty when its provider takes no level. */
808
+ function nodeThinkingLevels(node) {
809
+ const provider = state.providers.find(p => idFor(p) === (node.provider || state.defaultProvider));
810
+ if (!provider || typeof provider === 'string' || !provider.thinksAtLevels) return [];
811
+ const entry = provider.thinkingLevels?.[node.model || provider.model];
812
+ const supported = entry?.supported || THINKING_LEVELS;
813
+ const disabled = entry?.disabled || [];
814
+ return THINKING_LEVELS.filter(level => supported.includes(level) && !disabled.includes(level));
815
+ }
816
+ function thinkingSuffix(node) {
817
+ if (node.type !== 'agent' || !node.reasoningEffort) return '';
818
+ return node.reasoningEffort === 'auto' ? 'Auto thinking' : `${node.reasoningEffort} thinking`;
819
+ }
820
+ /** The thinking level control under a node's model: the session's level, Auto, or one of the model's enabled levels. */
821
+ function thinkingLevelField(parent, node) {
822
+ const levels = nodeThinkingLevels(node);
823
+ const current = node.reasoningEffort || '';
824
+ if (!levels.length && !current) return;
825
+ const options = [{ value: '', label: 'Same as session' }, { value: 'auto', label: 'Auto (Jev)' }, ...levels.map(level => ({ value: level, label: level }))];
826
+ if (current && current !== 'auto' && !levels.includes(current)) options.push({ value: current, label: `${current} (not available here)` });
827
+ const control = choice(parent, 'Thinking level', current, options, value => { if (value) node.reasoningEffort = value; else delete node.reasoningEffort; });
828
+ explain(control, 'How hard this step\'s model thinks before it answers. Auto (Jev) picks one of the levels this model has enabled each time the step starts, from how complex and how risky the task is, and keeps it for that run of the step; it needs Jev decisions on for this step, and otherwise keeps the session\'s level. A level that is switched off for this model on the machine running the graph moves to the nearest one that is on.');
829
+ }
805
830
  function nodeModelLabel(node) {
831
+ const model = nodeModelName(node);
832
+ const thinking = thinkingSuffix(node);
833
+ return model && thinking ? `${model} · ${thinking}` : model || thinking;
834
+ }
835
+ function nodeModelName(node) {
806
836
  if (node.model) return node.model;
807
837
  const providerId = node.provider || state.defaultProvider;
808
838
  const provider = state.providers.find(p => idFor(p) === providerId);
809
839
  if (provider && typeof provider !== 'string' && provider.model) return provider.model;
810
840
  return node.provider ? titleFor(provider || node.provider) : '';
811
841
  }
842
+ /** A review node's findings carry the fix prompt to the Agent they reach as its task. */
843
+ function reviewFindingsMapping(source, target, outcome) {
844
+ return source?.type === 'review' && outcome === 'findings' && target?.type === 'agent' ? { inputMapping: { taskInstruction: '$source.output.prompt' } } : {};
845
+ }
812
846
  function nodeSubtitle(node) {
813
847
  if (node.type === 'agent') {
814
848
  const model = nodeModelLabel(node);
@@ -816,7 +850,7 @@ function nodeSubtitle(node) {
816
850
  }
817
851
  if (node.type === 'end') return 'Graph complete';
818
852
  if (node.type === 'action') return node.action?.kind === 'tests' ? 'Run tests' : node.action?.kind === 'git' ? 'Git operation' : 'Run command';
819
- return { join: 'Wait for branches', loop: 'Bounded repetition', condition: 'Branch on run state', parallel: 'Fan out', approval: 'Human approval' }[node.type] || 'Flow control';
853
+ return { join: 'Wait for branches', loop: 'Bounded repetition', condition: 'Branch on run state', parallel: 'Fan out', approval: 'Human approval', review: 'Andorra review' }[node.type] || 'Flow control';
820
854
  }
821
855
  const nodeIconElement = node => globalThis.AndorraIcons?.icon?.(globalThis.AndorraIcons.nodeIcon(node));
822
856
  function renderCanvas() {
@@ -1514,7 +1548,7 @@ function routes(parent, node) {
1514
1548
  const row = section(group, outcome); row.id = `route-${outcome}`;
1515
1549
  for (const destination of Object.values(state.graph.nodes).filter(n => n.id !== node.id && n.agentRole !== 'orchestrator')) {
1516
1550
  const edge = state.graph.edges.find(e => e.source === node.id && edgeOutcome(e) === outcome && e.target === destination.id);
1517
- check(row, destination.name, !!edge, enabled => { if (enabled) state.graph.edges.push({id: `edge-${crypto.randomUUID().slice(0,8)}`, source: node.id, target: destination.id, outcome}); else state.graph.edges = state.graph.edges.filter(e => e !== edge); });
1551
+ check(row, destination.name, !!edge, enabled => { if (enabled) state.graph.edges.push({id: `edge-${crypto.randomUUID().slice(0,8)}`, source: node.id, target: destination.id, outcome, ...reviewFindingsMapping(node, destination, outcome)}); else state.graph.edges = state.graph.edges.filter(e => e !== edge); });
1518
1552
  if (edge) { const edit = el('button', 'Edit Connection', 'link-button'); edit.onclick = () => { state.selectedEdge = edge; state.selected = null; renderInspector(); renderCanvas(); }; row.append(edit); }
1519
1553
  }
1520
1554
  }
@@ -1625,7 +1659,84 @@ function renderControlInspector(parent,node) {
1625
1659
  if(node.type==='action') {choice(parent,'Action',node.action?.kind||'command',['command','tests','git'],value=>{node.action={command:'',...node.action,kind:value};});field(parent,'Command',node.action?.command||'',value=>{node.action={kind:'command',...node.action,command:value};},{multiline:true,maxLength:100000});}
1626
1660
  if(node.type==='parallel')parent.append(el('p','All completed connections become ready. A Parallel step is optional for ordinary outcome fan-out.', 'help'));
1627
1661
  if(node.type==='approval')parent.append(el('p','The CLI asks for approval. Route approved and rejected separately.', 'help'));
1662
+ if(node.type==='review')renderReviewInspector(parent,node);
1663
+ }
1664
+ const REVIEW_ROUNDS_DEFAULT = 3, REVIEW_ROUNDS_MAX = 10, REVIEW_INSTRUCTION_BYTES = 2048;
1665
+ /**
1666
+ * Every node may be visited at most limits.maxNodeVisits times (unset or 0: unlimited), and a cycle needs a ceiling. A
1667
+ * review loop's fixer and review node come back once per round: a finite ceiling below the rounds is raised to them; an
1668
+ * unlimited one stays, and a graph with no ceiling at all gets the rounds when `cycle` adds one.
1669
+ */
1670
+ function raiseVisitsFor(rounds, cycle = false) {
1671
+ const limits = state.graph.limits || {};
1672
+ const visits = limits.maxNodeVisits;
1673
+ const finite = typeof visits === 'number' && visits > 0;
1674
+ if (finite ? visits < rounds : cycle && limits.wallTimeMs === undefined) state.graph.limits = { ...limits, maxNodeVisits: rounds };
1675
+ }
1676
+ /** The text cut to at most `bytes` UTF-8 bytes, as the engine counts the instruction. */
1677
+ function cutToBytes(text, bytes) {
1678
+ const encoder = new TextEncoder();
1679
+ if (encoder.encode(text).length <= bytes) return text;
1680
+ let out = '';
1681
+ for (const character of text) { if (encoder.encode(out + character).length > bytes) break; out += character; }
1682
+ return out;
1683
+ }
1684
+ /** An Andorra review node: each visit reviews the task's pull request once (design/specs/andorra-review-loop.md, "Graphs"). */
1685
+ function renderReviewInspector(parent,node) {
1686
+ const review = node.review || { rounds: REVIEW_ROUNDS_DEFAULT };
1687
+ // Each change reads the node as it is now: the fields are not redrawn between edits.
1688
+ const set = patch => { node.review = { rounds: REVIEW_ROUNDS_DEFAULT, ...(node.review || {}), ...patch }; for (const key of Object.keys(node.review)) if (node.review[key] === undefined || node.review[key] === '') delete node.review[key]; };
1689
+ parent.append(el('p',`Each visit reviews the task's pull request once as andorra-code[bot], up to ${review.rounds} ${review.rounds === 1 ? 'time' : 'times'} in a run. Route findings to the Agent that fixes them; clean and stopped end the review.`,'help'));
1690
+ field(parent,'Rounds',review.rounds,value=>{const rounds=Math.min(REVIEW_ROUNDS_MAX,Math.max(1,Math.round(Number(value)||REVIEW_ROUNDS_DEFAULT)));set({rounds});raiseVisitsFor(rounds);},{type:'number',min:1,max:REVIEW_ROUNDS_MAX,refresh:true});
1691
+ choice(parent,'Drafts',review.when||'ready',[{value:'ready',label:'Wait until ready for review'},{value:'always',label:'Review drafts too'}],value=>set({when:value==='ready'?undefined:value}));
1692
+ field(parent,'Look at',review.instruction||'',value=>set({instruction:cutToBytes(String(value??''),REVIEW_INSTRUCTION_BYTES)}),{multiline:true,maxLength:REVIEW_INSTRUCTION_BYTES,placeholder:'Anything to focus on, for example security',refresh:true});
1693
+ // Provider and model go together, or neither (the task's model).
1694
+ modelFields(parent,review,value=>{const both=value.provider&&value.model;set({provider:both?value.provider:undefined,model:both?value.model:undefined});},undefined,undefined,undefined,{requireProvider:true,defaultLabel:'This task\'s model'});
1695
+ parent.append(el('p','The fixer gets the round\'s findings as its task through the findings connection\'s input mapping (taskInstruction ← output.prompt).','help'));
1696
+ }
1697
+ /** Why "Add Andorra Review After This Step" cannot wire this Agent as the server would accept it, if it cannot. */
1698
+ function reviewAfterRefusal(node) {
1699
+ const outcome = outcomes(node)[0];
1700
+ const moved = state.graph.edges.filter(edge => edge.source === node.id && edgeOutcome(edge) === outcome);
1701
+ if (node.modifiers?.condition) return 'This step branches on a condition; connect an Andorra review step by hand.';
1702
+ if (node.modifiers?.parallel?.mode === 'branches') return 'Parallel branches connect directly to Agents; connect an Andorra review step after them instead.';
1703
+ if (!moved.length) return `Connect this step's ${outcome} port first: the review goes where it went.`;
1704
+ if (moved.some(edge => state.graph.nodes[edge.target]?.type === 'join' && state.graph.nodes[edge.target].join?.mode !== 'any')) return 'This step leads to a Join that waits for all branches; connect an Andorra review step by hand.';
1705
+ const schema = node.inputSchema;
1706
+ if (schema?.additionalProperties === false && !schema.properties?.taskInstruction) return 'This step\'s input schema has no taskInstruction for the findings; add it, or connect the review by hand.';
1707
+ const required = (schema?.required || []).filter(name => name !== 'taskInstruction' && name !== 'task');
1708
+ if (required.length) return `This step needs ${required.join(', ')} as input, which the findings do not carry; connect the review by hand.`;
1709
+ if (Object.keys(state.graph.nodes).length >= nodeLimit(state.graph)) return 'This graph has as many steps as it can hold.';
1710
+ return freeNodeRefusal([{ type: 'review' }]);
1711
+ }
1712
+ /**
1713
+ * "Add Andorra Review After This Step": the Agent's routes on its first port go through a new review node, whose clean
1714
+ * and stopped routes go where they went (with their mappings), and whose findings come back to the Agent with the fix
1715
+ * prompt as its task.
1716
+ */
1717
+ function addReviewAfter(node) {
1718
+ const refusal = reviewAfterRefusal(node);
1719
+ if (refusal) { status(refusal, true); return; }
1720
+ const outcome = outcomes(node)[0];
1721
+ const moved = state.graph.edges.filter(edge => edge.source === node.id && edgeOutcome(edge) === outcome);
1722
+ mutate(() => {
1723
+ const short = crypto.randomUUID().slice(0, 8);
1724
+ const id = `review-${short}`;
1725
+ const p = position(node, Object.keys(state.graph.nodes).indexOf(node.id));
1726
+ state.graph.schemaVersion = 3;
1727
+ state.graph.nodes[id] = { id, name: 'Andorra review', type: 'review', review: { rounds: REVIEW_ROUNDS_DEFAULT }, position: { x: p.x + 300, y: p.y + 140 } };
1728
+ state.graph.edges = state.graph.edges.filter(edge => !moved.includes(edge));
1729
+ state.graph.edges.push({ id: `${id}-in`, source: node.id, target: id, outcome });
1730
+ state.graph.edges.push({ id: `${id}-findings`, source: id, target: node.id, outcome: 'findings', inputMapping: { taskInstruction: '$source.output.prompt' } });
1731
+ moved.forEach((edge, index) => {
1732
+ const carried = { ...(edge.inputMapping ? { inputMapping: copy(edge.inputMapping) } : {}), ...(edge.toInput ? { toInput: edge.toInput } : {}) };
1733
+ for (const end of ['clean', 'stopped']) state.graph.edges.push({ id: `${id}-${end}-${index}`, source: id, target: edge.target, outcome: end, ...copy(carried) });
1734
+ });
1735
+ raiseVisitsFor(REVIEW_ROUNDS_DEFAULT, true);
1736
+ state.selectedIds = [id]; state.selected = id; state.selectedEdge = null;
1737
+ }, true);
1628
1738
  }
1739
+
1629
1740
  function setAgentModifier(node, kind, value) {
1630
1741
  const before = outcomes(node);
1631
1742
  node.modifiers = {...node.modifiers};
@@ -1746,6 +1857,7 @@ function renderInspector() {
1746
1857
  explain(check(general, 'Jev decisions', node.jevEnabled === true, value => { if (value) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists this agent with routing decisions. The coding model still implements the task; sign-in, quota and runtime permissions apply.');
1747
1858
  const model = panels.model;
1748
1859
  modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
1860
+ thinkingLevelField(model, node);
1749
1861
  const conversation = choice(model, 'Conversation', node.contextPolicy?.conversation ?? 'reuse', [{value:'reuse',label:'Reuse with the same provider and model'}, {value:'isolate',label:'Start an isolated conversation'}], value => {node.contextPolicy={...node.contextPolicy,conversation:value};});
1750
1862
  explain(conversation, 'Reuse continues from the preceding Agent with this step\'s instructions and permissions. Different providers or models start fresh. Branches receive separate copies of their shared history. Provider caching and token savings depend on the model service.');
1751
1863
  const skills = choice(model, 'Skill inheritance', node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active graph skills'}, {value:'none',label:'Do not inherit skills'}], value => {node.contextPolicy={...node.contextPolicy,skillInheritance:value};});
@@ -1766,7 +1878,9 @@ function renderInspector() {
1766
1878
  const tools = disclosure(advanced,'Tool allowlist');
1767
1879
  for (const name of [...new Set([...state.tools.map(t=>typeof t==='string'?t:t.name||t.id),...(node.tools||[])])]) check(tools,name,node.tools===undefined||node.tools.includes(name),enabled=>{const all=state.tools.map(t=>typeof t==='string'?t:t.name||t.id); node.tools=enabled?[...new Set([...(node.tools??all),name])]:(node.tools??all).filter(t=>t!==name);});
1768
1880
  const saveDefinition = el('button','Save to Library'); saveDefinition.onclick=()=>saveAgentVariant(node); general.append(saveDefinition);
1769
- } else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
1881
+ if (node.agentRole !== 'orchestrator') { const addReview = el('button','Add Andorra Review After This Step'); addReview.onclick=()=>addReviewAfter(node); general.append(addReview); }
1882
+ } else if (node.type === 'review') renderControlInspector(general,node);
1883
+ else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
1770
1884
  if (panels.behavior) routes(panels.behavior,node);
1771
1885
  const layout = disclosure(panels.advanced,'Position'); const p=position(node,Object.keys(graph.nodes).indexOf(node.id)); field(layout,'X',p.x,value=>{node.position={...p,x:value};},{type:'number',min:-100000,max:100000,refresh:true});field(layout,'Y',p.y,value=>{node.position={...p,y:value};},{type:'number',min:-100000,max:100000,refresh:true});
1772
1886
  const remove=el('button','Remove Step','danger');remove.disabled=Object.keys(graph.nodes).length===1;remove.onclick=()=>{void askConfirm({title:`Remove ${node.name}?`,message:'The step and its connections are removed from this graph. Undo brings them back.',confirmLabel:'Remove Step',tone:'danger'}).then(confirmed=>{if(confirmed&&state.graph?.nodes?.[node.id])removeNodes(new Set([node.id]));});};panels.advanced.append(remove);
@@ -1855,7 +1969,7 @@ function addNode(type, definition, dropPosition) {
1855
1969
  const id = `${type}-${crypto.randomUUID().slice(0, 8)}`;
1856
1970
  if (!dropPosition) { dropPosition = {x:(120-state.x)/state.zoom,y:(180-state.y)/state.zoom}; for (let attempts=0; attempts<100 && Object.values(state.graph.nodes).some((node,index)=>{const p=position(node,index);return Math.abs(p.x-dropPosition.x)<45 && Math.abs(p.y-dropPosition.y)<45;});attempts++) {dropPosition.x+=48;dropPosition.y+=48;} }
1857
1971
  state.graph.schemaVersion = 3;
1858
- state.graph.nodes[id] = { ...(definition ? copy(definition) : type === 'agent' ? blankAgentSettings() : {}), id, type, ...(type==='join'?{join:{mode:'all'}}:type==='loop'?{loop:{maxIterations:3}}:type==='condition'?{condition:{source:state.graph.entry,path:'result',equals:true}}:{}), name: definition?.name || (type === 'agent' ? 'New Agent' : type.charAt(0).toUpperCase() + type.slice(1)), position: dropPosition || { x: (120 - state.x) / state.zoom, y: (180 - state.y) / state.zoom } };
1972
+ state.graph.nodes[id] = { ...(definition ? copy(definition) : type === 'agent' ? blankAgentSettings() : {}), id, type, ...(type==='join'?{join:{mode:'all'}}:type==='loop'?{loop:{maxIterations:3}}:type==='review'?{review:{rounds:REVIEW_ROUNDS_DEFAULT}}:type==='condition'?{condition:{source:state.graph.entry,path:'result',equals:true}}:{}), name: definition?.name || (type === 'agent' ? 'New Agent' : type.charAt(0).toUpperCase() + type.slice(1)), position: dropPosition || { x: (120 - state.x) / state.zoom, y: (180 - state.y) / state.zoom } };
1859
1973
  if (definition?.agentRole === 'orchestrator') {
1860
1974
  const previousEntry = state.graph.entry;
1861
1975
  if (state.graph.limits?.maxToolCalls !== undefined) state.graph.limits.maxToolCalls = Math.min(1_000_000_000, state.graph.limits.maxToolCalls + 2);
@@ -2061,7 +2175,7 @@ function renderLibrary() {
2061
2175
  if (agents) agents.append(el('p','Select an Agent to configure Condition, Loop, and Parallel modifiers.','help'));
2062
2176
  section(container,'control','Control',['join'].map(type=>({name:type.charAt(0).toUpperCase()+type.slice(1),type,description:{condition:'Branch on run state',loop:'Bounded repetition',parallel:'Explicit fan-out',join:'Wait for all or any branches'}[type]})));
2063
2177
  section(container,'actions','Actions',[{name:'Run command',type:'action',node:{name:'Run command',action:{kind:'command',command:''}},description:'Execute a shell command'},{name:'Run tests',type:'action',node:{name:'Run tests',action:{kind:'tests',command:'npm test'}},description:'Execute project tests'},{name:'Git operation',type:'action',node:{name:'Git operation',action:{kind:'git',command:'git status'}},description:'Run a Git operation'}]);
2064
- section(container,'flow','Flow',[{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this graph path'}]);
2178
+ section(container,'flow','Flow',[{name:'Andorra review',type:'review',node:{name:'Andorra review',review:{rounds:REVIEW_ROUNDS_DEFAULT}},description:'Review the task\'s pull request; route findings to a fixer'},{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this graph path'}]);
2065
2179
  if (query && !container.children.length) container.append(emptyState('search', 'No steps match', 'Try another name, or clear the search.'));
2066
2180
  }
2067
2181
  let viewAnimation = 0, viewTarget = null;
@@ -61,11 +61,12 @@ globalThis.AndorraIcons = (() => {
61
61
  flag: '<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" x2="4" y1="22" y2="15"/>',
62
62
  search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
63
63
  graph: '<rect width="8" height="8" x="3" y="3" rx="2"/><path d="M7 11v4a2 2 0 0 0 2 2h4"/><rect width="8" height="8" x="13" y="13" rx="2"/>',
64
+ review: '<circle cx="18" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><path d="M13 6h3a2 2 0 0 1 2 2v7"/><path d="M6 9v12"/><path d="m15 9-3-3 3-3"/>',
64
65
  };
65
66
 
66
67
  const NODE_ICONS = {
67
68
  agent: 'bot', orchestrator: 'compass', join: 'merge', parallel: 'fork', condition: 'fork',
68
- loop: 'repeat', action: 'terminal', approval: 'approval', end: 'flag',
69
+ loop: 'repeat', action: 'terminal', approval: 'approval', review: 'review', end: 'flag',
69
70
  };
70
71
 
71
72
  const SVG = 'http://www.w3.org/2000/svg';
@@ -238,6 +238,19 @@
238
238
  engineer.position = { x: 120, y: 120 };
239
239
  end.position = { x: 440, y: 120 };
240
240
  engineer.instruction = 'Inspect the task, make the smallest correct change, run the relevant verification and report the outcome.';
241
+ } else if (kind === 'andorra-review') {
242
+ // The engineer opens the PR; the review node reviews it as andorra-code[bot] and hands findings back to the engineer,
243
+ // which continues its own conversation, for up to 3 rounds (design/specs/andorra-review-loop.md, "The template").
244
+ base.name = 'Andorra Review Loop';
245
+ base.nodes.review = { id: 'review', name: 'Andorra review', type: 'review', review: { rounds: 3 }, position: { x: (engineer.position?.x ?? 440) + 320, y: (engineer.position?.y ?? 120) + 160 } };
246
+ end.position = { x: (engineer.position?.x ?? 440) + 640, y: engineer.position?.y ?? 120 };
247
+ base.edges = base.edges.filter(edge => !(edge.source === 'engineer' && edge.target === 'done'));
248
+ base.edges.push({ id: 'engineer-review', source: 'engineer', target: 'review', outcome: 'completed' });
249
+ base.edges.push({ id: 'review-findings', source: 'review', target: 'engineer', outcome: 'findings', inputMapping: { taskInstruction: '$source.output.prompt' } });
250
+ base.edges.push({ id: 'review-clean', source: 'review', target: 'done', outcome: 'clean' });
251
+ base.edges.push({ id: 'review-stopped', source: 'review', target: 'done', outcome: 'stopped' });
252
+ base.limits = { ...base.limits, maxNodeVisits: Math.max(3, base.limits?.maxNodeVisits ?? 0) };
253
+ engineer.instruction = `${engineer.instruction ?? ''}\n\nOpen a pull request for the change when it is done. When you are given Andorra review findings, fix the ones you agree with, push, reply to and resolve each thread you fixed with the pull_request tool, then finish.`.trim();
241
254
  } else {
242
255
  const qa = {
243
256
  id: 'reviewer', name: kind === 'review' ? 'PR Reviewer' : 'QA Reviewer',
@@ -276,6 +289,7 @@
276
289
  ['fast', 'Fast Fix', 'Direct coding-agent flow without an intake Orchestrator'],
277
290
  ['review', 'Review and Repair', 'Implement, review, then retry defects for as long as the run clock allows'],
278
291
  ['qa', 'QA Gate', 'Research, implement, and pass through an independent read-only QA Agent'],
292
+ ['andorra-review', 'Andorra Review Loop', 'Implement and open a pull request; andorra-code[bot] reviews it and the engineer fixes the findings, up to 3 rounds'],
279
293
  ]) {
280
294
  const row = element('div', undefined, 'studio-template');
281
295
  row.append(action(name, () => newTemplate(id), 'btn-small'));
@@ -732,6 +746,6 @@
732
746
  }
733
747
  }
734
748
 
735
- window.AndorraStudio = { selectedStepsText, eventWords, runStatusWords, durationWords, runEventLine, heading, canvas, inspector: enhanceInspector, createGroup, canCreateLayoutGroup, describeDiff, nodeStatuses, nodeActivityTotals, representableSourceField, refreshRunList, toggleDebugger, runMatchesCanvas, setHostMenu, previewMatchesDraft, acceptPreviewIfCurrent, openHistory, openImport, importGraphJson, importGraphFile };
749
+ window.AndorraStudio = { selectedStepsText, eventWords, runStatusWords, durationWords, runEventLine, heading, canvas, inspector: enhanceInspector, createGroup, canCreateLayoutGroup, describeDiff, nodeStatuses, nodeActivityTotals, representableSourceField, refreshRunList, toggleDebugger, runMatchesCanvas, setHostMenu, previewMatchesDraft, acceptPreviewIfCurrent, openHistory, openImport, openTemplates, importGraphJson, importGraphFile };
736
750
  initialize();
737
751
  })();
@@ -78,7 +78,7 @@
78
78
  --shadow-raised: 0 1px 2px rgba(0,0,0,.32);
79
79
  --shadow-knob: 0 1px 2px rgba(0,0,0,.4);
80
80
 
81
- --z-raised: 10; --z-chrome: 30; --z-rail-menu: 40; --z-dialog: 50; --z-menu: 60; --z-palette: 70; --z-toast: 80;
81
+ --z-raised: 10; --z-chrome: 30; --z-dialog: 50; --z-menu: 60; --z-palette: 70; --z-toast: 80;
82
82
  --z-lightbox: 90; --z-tooltip: 100;
83
83
 
84
84
  --dur-0: 80ms; --dur-1: 120ms; --dur-2: 160ms; --dur-3: 200ms; --dur-4: 240ms;
@@ -1,5 +1,9 @@
1
1
  import { type JsonSchema, type ValueExpression } from './handoffs.js';
2
+ import { type ReasoningEffort } from './providers.js';
2
3
  export type { JsonSchema, ValueExpression } from './handoffs.js';
4
+ /** A node's thinking level: one of the provider levels, or 'auto' for Jev to pick one each time the node starts. */
5
+ export type NodeReasoningEffort = ReasoningEffort | 'auto';
6
+ export declare function isNodeReasoningEffort(value: unknown): value is NodeReasoningEffort;
3
7
  export interface CapabilityPolicy {
4
8
  filesystem: 'none' | 'read' | 'read-write';
5
9
  shell: 'disabled' | 'read-only' | 'allowed';
@@ -88,7 +92,7 @@ export interface AgentModifiers {
88
92
  export interface GraphNode {
89
93
  id: string;
90
94
  name: string;
91
- type: 'agent' | 'end' | 'join' | 'parallel' | 'condition' | 'loop' | 'action' | 'approval';
95
+ type: 'agent' | 'end' | 'join' | 'parallel' | 'condition' | 'loop' | 'action' | 'approval' | 'review';
92
96
  position?: {
93
97
  x: number;
94
98
  y: number;
@@ -105,6 +109,8 @@ export interface GraphNode {
105
109
  tools?: string[];
106
110
  maxIterations?: number;
107
111
  jevEnabled?: boolean;
112
+ /** The thinking level this node runs at: a fixed level, or 'auto' for Jev to pick one each time the node starts. */
113
+ reasoningEffort?: NodeReasoningEffort;
108
114
  completion?: CompletionPolicy;
109
115
  capabilities?: CapabilityPolicy;
110
116
  contextPolicy?: ContextPolicy;
@@ -129,7 +135,19 @@ export interface GraphNode {
129
135
  kind: 'command' | 'tests' | 'git';
130
136
  command: string;
131
137
  };
138
+ /** An Andorra review node (design/specs/andorra-review-loop.md, "Graphs"): each visit is one round on the task's PR. */
139
+ review?: ReviewNodeSettings;
132
140
  }
141
+ export interface ReviewNodeSettings {
142
+ rounds: number;
143
+ when?: 'ready' | 'always';
144
+ instruction?: string;
145
+ provider?: string;
146
+ model?: string;
147
+ }
148
+ export declare const REVIEW_NODE_OUTCOMES: readonly ["findings", "clean", "stopped"];
149
+ export declare const REVIEW_NODE_ROUNDS_MAX = 10;
150
+ export declare const REVIEW_NODE_INSTRUCTION_BYTES = 2048;
133
151
  export interface GraphEdge {
134
152
  id?: string;
135
153
  source: string;
@@ -188,6 +206,27 @@ export declare const DEFAULT_HARNESS: Graph;
188
206
  export declare const DEFAULT_GRAPH: Graph;
189
207
  export declare const GRAPH_MANAGER_GRAPH_ID = "andorra-graph-manager";
190
208
  export declare const GRAPH_MANAGER_HARNESS: Graph;
209
+ /** The Andorra review loop's reviewer: one read-only agent that reviews a pull request's head in a throwaway worktree. */
210
+ export declare const REVIEWER_GRAPH_ID = "andorra-reviewer";
211
+ /** The most findings the reviewer is asked for in one round. */
212
+ export declare const REVIEWER_MAX_FINDINGS = 20;
213
+ export declare const REVIEWER_GRAPH: Graph;
214
+ /**
215
+ * What is wrong with a reviewer's output that its schema cannot say (the schema has no enums or bounds), or undefined when
216
+ * nothing is. The reviewer sees the message and can correct its output before the run ends.
217
+ */
218
+ export declare function reviewerOutputProblem(output: unknown): string | undefined;
219
+ /** The built-in graphs every engine has under a reserved id: never saved, listed, synced or deleted, and loaded without a membership read. */
220
+ export declare const BUILT_IN_GRAPHS: Readonly<Record<string, Graph>>;
221
+ export declare const isReservedGraphId: (id: string) => boolean;
222
+ /** A copy of the built-in graph with this id, or undefined when the id is not a reserved built-in one. */
223
+ export declare function builtInGraph(id: string): Graph | undefined;
224
+ /**
225
+ * A graph whose runs are kept apart from the person's private context: no memory of any kind, no project or user
226
+ * instructions, no skills, no MCP servers and no session history. Its output is posted publicly, so nothing the person
227
+ * keeps for themselves may reach it.
228
+ */
229
+ export declare const isolatedGraph: (id: string | undefined) => boolean;
191
230
  export declare function graphMcpServers<T>(graphId: string, servers: Record<string, T>): Record<string, T>;
192
231
  export declare const reservedGraphId: (id: string) => Error;
193
232
  export declare function migrateGraphForEditor(input: Graph, options?: {