@andorra-labs/code 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) 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-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +15 -10
  5. package/dist/src/agent-mcp-catalog.js +1 -0
  6. package/dist/src/agent-mcp.d.ts +4 -1
  7. package/dist/src/agent-mcp.js +46 -10
  8. package/dist/src/andorra/entry.d.ts +10 -0
  9. package/dist/src/andorra/entry.js +18 -4
  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 +22 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +89 -0
  23. package/dist/src/app-server/workspace.js +457 -11
  24. package/dist/src/app-server.d.ts +465 -32
  25. package/dist/src/app-server.js +3308 -517
  26. package/dist/src/auth/deployment.js +2 -2
  27. package/dist/src/bridge/cloud.d.ts +27 -0
  28. package/dist/src/bridge/cloud.js +187 -0
  29. package/dist/src/bridge/command.d.ts +30 -0
  30. package/dist/src/bridge/command.js +347 -0
  31. package/dist/src/bridge/control.d.ts +68 -0
  32. package/dist/src/bridge/control.js +233 -0
  33. package/dist/src/bridge/engines.d.ts +90 -0
  34. package/dist/src/bridge/engines.js +601 -0
  35. package/dist/src/bridge/host-ops.d.ts +9 -0
  36. package/dist/src/bridge/host-ops.js +129 -0
  37. package/dist/src/bridge/host.d.ts +47 -0
  38. package/dist/src/bridge/host.js +540 -0
  39. package/dist/src/bridge/link.d.ts +38 -0
  40. package/dist/src/bridge/link.js +508 -0
  41. package/dist/src/bridge/login-link.d.ts +29 -0
  42. package/dist/src/bridge/login-link.js +54 -0
  43. package/dist/src/bridge/protocol.d.ts +136 -0
  44. package/dist/src/bridge/protocol.js +11 -0
  45. package/dist/src/bridge/store.d.ts +12 -0
  46. package/dist/src/bridge/store.js +61 -0
  47. package/dist/src/bridge/wording.d.ts +6 -0
  48. package/dist/src/bridge/wording.js +10 -0
  49. package/dist/src/browser-runner.js +1 -0
  50. package/dist/src/browser-server.js +7 -1
  51. package/dist/src/browser-ui/style.css +3 -3
  52. package/dist/src/browser-ui/tokens.css +28 -17
  53. package/dist/src/change-authors.d.ts +41 -0
  54. package/dist/src/change-authors.js +146 -0
  55. package/dist/src/claude-provider.js +3 -1
  56. package/dist/src/cli.js +202 -38
  57. package/dist/src/codex-errors.js +4 -1
  58. package/dist/src/coding-tools.js +15 -15
  59. package/dist/src/command-screens.d.ts +6 -0
  60. package/dist/src/command-screens.js +19 -14
  61. package/dist/src/commands.d.ts +14 -1
  62. package/dist/src/compaction-phrases.d.ts +4 -0
  63. package/dist/src/compaction-phrases.js +20 -0
  64. package/dist/src/completion.js +82 -5
  65. package/dist/src/config.d.ts +71 -3
  66. package/dist/src/config.js +202 -77
  67. package/dist/src/context-compaction.js +2 -1
  68. package/dist/src/deadline.js +13 -1
  69. package/dist/src/decision/DecisionManager.js +3 -2
  70. package/dist/src/decision/checks.js +1 -1
  71. package/dist/src/decision/requestPhrases.d.ts +4 -0
  72. package/dist/src/decision/requestPhrases.js +22 -0
  73. package/dist/src/default-graph.js +1 -1
  74. package/dist/src/file-diff.d.ts +4 -0
  75. package/dist/src/file-diff.js +2 -1
  76. package/dist/src/github-app/agent-writes.d.ts +102 -0
  77. package/dist/src/github-app/agent-writes.js +320 -0
  78. package/dist/src/github-app/client.d.ts +349 -0
  79. package/dist/src/github-app/client.js +810 -0
  80. package/dist/src/github-app/event-source.d.ts +208 -0
  81. package/dist/src/github-app/event-source.js +684 -0
  82. package/dist/src/github-app/metrics.d.ts +32 -0
  83. package/dist/src/github-app/metrics.js +49 -0
  84. package/dist/src/github-app/review-loop.d.ts +274 -0
  85. package/dist/src/github-app/review-loop.js +1177 -0
  86. package/dist/src/github-app/review-node.d.ts +81 -0
  87. package/dist/src/github-app/review-node.js +205 -0
  88. package/dist/src/github-app/review-post.d.ts +73 -0
  89. package/dist/src/github-app/review-post.js +139 -0
  90. package/dist/src/github-app/review-text.d.ts +107 -0
  91. package/dist/src/github-app/review-text.js +1133 -0
  92. package/dist/src/github-app/review-threads.d.ts +47 -0
  93. package/dist/src/github-app/review-threads.js +107 -0
  94. package/dist/src/github-app/reviewer.d.ts +121 -0
  95. package/dist/src/github-app/reviewer.js +598 -0
  96. package/dist/src/github-app/store.d.ts +59 -0
  97. package/dist/src/github-app/store.js +148 -0
  98. package/dist/src/github-app/triggers.d.ts +141 -0
  99. package/dist/src/github-app/triggers.js +441 -0
  100. package/dist/src/github-inbox.d.ts +55 -0
  101. package/dist/src/github-inbox.js +153 -0
  102. package/dist/src/github-names.d.ts +8 -0
  103. package/dist/src/github-names.js +8 -0
  104. package/dist/src/glob-search.d.ts +61 -0
  105. package/dist/src/glob-search.js +180 -0
  106. package/dist/src/graph-health.js +13 -4
  107. package/dist/src/graph-manager-chat.js +1 -1
  108. package/dist/src/graph-preview.d.ts +46 -0
  109. package/dist/src/graph-preview.js +55 -0
  110. package/dist/src/graph-provider-portability.js +34 -11
  111. package/dist/src/graph-quota.d.ts +29 -2
  112. package/dist/src/graph-quota.js +68 -10
  113. package/dist/src/graph-runner.js +88 -10
  114. package/dist/src/graph-server.d.ts +1 -1
  115. package/dist/src/graph-server.js +11 -9
  116. package/dist/src/graph-sync.js +3 -3
  117. package/dist/src/graph-ui/app.js +201 -40
  118. package/dist/src/graph-ui/controls.css +1 -0
  119. package/dist/src/graph-ui/embed.js +2 -2
  120. package/dist/src/graph-ui/icons.js +3 -1
  121. package/dist/src/graph-ui/index.html +1 -1
  122. package/dist/src/graph-ui/manager.css +1 -1
  123. package/dist/src/graph-ui/manager.js +2 -2
  124. package/dist/src/graph-ui/sidebar.js +30 -0
  125. package/dist/src/graph-ui/studio-canvas.js +26 -13
  126. package/dist/src/graph-ui/studio.css +15 -7
  127. package/dist/src/graph-ui/studio.js +26 -5
  128. package/dist/src/graph-ui/style.css +77 -45
  129. package/dist/src/graph-ui/theme.js +3 -36
  130. package/dist/src/graph-ui/tokens.css +28 -20
  131. package/dist/src/graphs.d.ts +34 -1
  132. package/dist/src/graphs.js +162 -17
  133. package/dist/src/image-input.d.ts +16 -0
  134. package/dist/src/image-input.js +41 -0
  135. package/dist/src/membership.d.ts +30 -1
  136. package/dist/src/membership.js +48 -8
  137. package/dist/src/model-health-cache.js +1 -1
  138. package/dist/src/model-metadata.d.ts +7 -1
  139. package/dist/src/model-metadata.js +39 -17
  140. package/dist/src/model-relay/local.d.ts +116 -0
  141. package/dist/src/model-relay/local.js +468 -0
  142. package/dist/src/model-relay/remote.d.ts +129 -0
  143. package/dist/src/model-relay/remote.js +252 -0
  144. package/dist/src/model-relay/runs.d.ts +34 -0
  145. package/dist/src/model-relay/runs.js +146 -0
  146. package/dist/src/model-relay/wire.d.ts +5 -0
  147. package/dist/src/model-relay/wire.js +5 -0
  148. package/dist/src/plan-pass.d.ts +59 -0
  149. package/dist/src/plan-pass.js +165 -0
  150. package/dist/src/project-registry.d.ts +21 -0
  151. package/dist/src/project-registry.js +74 -0
  152. package/dist/src/provider-engine.js +3 -0
  153. package/dist/src/provider-import.d.ts +0 -12
  154. package/dist/src/provider-import.js +7 -195
  155. package/dist/src/providers.d.ts +40 -2
  156. package/dist/src/providers.js +93 -23
  157. package/dist/src/pull-request-checks.d.ts +26 -0
  158. package/dist/src/pull-request-checks.js +56 -0
  159. package/dist/src/pull-request-conversation.d.ts +134 -0
  160. package/dist/src/pull-request-conversation.js +221 -0
  161. package/dist/src/pull-request-create.d.ts +175 -0
  162. package/dist/src/pull-request-create.js +392 -0
  163. package/dist/src/pull-request-details.d.ts +242 -0
  164. package/dist/src/pull-request-details.js +614 -0
  165. package/dist/src/pull-request-edit.d.ts +23 -0
  166. package/dist/src/pull-request-edit.js +91 -0
  167. package/dist/src/pull-request-logs.d.ts +87 -0
  168. package/dist/src/pull-request-logs.js +183 -0
  169. package/dist/src/pull-request-merge.d.ts +112 -0
  170. package/dist/src/pull-request-merge.js +258 -0
  171. package/dist/src/pull-request-review.d.ts +137 -0
  172. package/dist/src/pull-request-review.js +401 -0
  173. package/dist/src/pull-requests.d.ts +369 -8
  174. package/dist/src/pull-requests.js +524 -55
  175. package/dist/src/react-runtime.js +38 -5
  176. package/dist/src/remote/engine-pool.d.ts +88 -4
  177. package/dist/src/remote/engine-pool.js +379 -90
  178. package/dist/src/remote/roots.d.ts +19 -0
  179. package/dist/src/remote/roots.js +45 -7
  180. package/dist/src/remote/types.d.ts +0 -44
  181. package/dist/src/run-control.d.ts +17 -0
  182. package/dist/src/run-control.js +47 -0
  183. package/dist/src/run-progress.d.ts +10 -0
  184. package/dist/src/run-progress.js +122 -0
  185. package/dist/src/run-records.d.ts +7 -2
  186. package/dist/src/run-records.js +71 -6
  187. package/dist/src/runtime.d.ts +9 -1
  188. package/dist/src/runtime.js +24 -4
  189. package/dist/src/session-changes.d.ts +35 -0
  190. package/dist/src/session-changes.js +194 -6
  191. package/dist/src/session-monitor.js +2 -1
  192. package/dist/src/session-reaper.d.ts +1 -1
  193. package/dist/src/session-reaper.js +6 -1
  194. package/dist/src/session-summary.d.ts +2 -1
  195. package/dist/src/session-summary.js +2 -1
  196. package/dist/src/sessions.d.ts +11 -1
  197. package/dist/src/sessions.js +17 -4
  198. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  199. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  200. package/dist/src/skills/bundled/provenance.json +2 -2
  201. package/dist/src/skills/runtime-skills.js +1 -1
  202. package/dist/src/subagent-run.js +1 -0
  203. package/dist/src/telemetry/capture-core.d.ts +17 -0
  204. package/dist/src/telemetry/capture-core.js +59 -1
  205. package/dist/src/telemetry/classify.d.ts +3 -1
  206. package/dist/src/telemetry/classify.js +37 -0
  207. package/dist/src/telemetry/emitter.d.ts +17 -0
  208. package/dist/src/telemetry/emitter.js +76 -5
  209. package/dist/src/telemetry/schema.d.ts +47 -2
  210. package/dist/src/telemetry/schema.js +120 -5
  211. package/dist/src/telemetry/surface.d.ts +3 -1
  212. package/dist/src/telemetry/surface.js +4 -1
  213. package/dist/src/telemetry/uploader.d.ts +6 -1
  214. package/dist/src/telemetry/uploader.js +22 -3
  215. package/dist/src/terminal-ui.d.ts +1 -0
  216. package/dist/src/terminal-ui.js +10 -3
  217. package/dist/src/test-edit-guard.d.ts +7 -0
  218. package/dist/src/test-edit-guard.js +49 -1
  219. package/dist/src/timers.d.ts +2 -0
  220. package/dist/src/tools.js +59 -9
  221. package/dist/src/transcript.js +8 -2
  222. package/dist/src/types.d.ts +7 -0
  223. package/dist/src/usage-analytics.js +18 -10
  224. package/package.json +6 -1
  225. package/dist/src/remote/cert.d.ts +0 -11
  226. package/dist/src/remote/cert.js +0 -87
  227. package/dist/src/remote/client.d.ts +0 -119
  228. package/dist/src/remote/client.js +0 -544
  229. package/dist/src/remote/command.d.ts +0 -4
  230. package/dist/src/remote/command.js +0 -194
  231. package/dist/src/remote/errors.d.ts +0 -11
  232. package/dist/src/remote/errors.js +0 -14
  233. package/dist/src/remote/network.d.ts +0 -22
  234. package/dist/src/remote/network.js +0 -102
  235. package/dist/src/remote/pairing.d.ts +0 -63
  236. package/dist/src/remote/pairing.js +0 -299
  237. package/dist/src/remote/pem.d.ts +0 -2
  238. package/dist/src/remote/pem.js +0 -7
  239. package/dist/src/remote/serve.d.ts +0 -68
  240. package/dist/src/remote/serve.js +0 -244
  241. package/dist/src/remote/server.d.ts +0 -21
  242. package/dist/src/remote/server.js +0 -406
@@ -40,15 +40,56 @@ function closeDialog(dialog) {
40
40
  if (typeof controls?.closeDialog === 'function') controls.closeDialog(dialog); else dialog.close();
41
41
  }
42
42
  const DISCARD_QUESTION = { title: 'Discard unsaved changes?', message: 'Edits to this graph since its last version are lost. Recoverable drafts stay in draft history.', confirmLabel: 'Discard', tone: 'danger' };
43
- function status(message, error = false) { $('status').textContent = message; $('status').parentElement.classList.toggle('error', error); }
43
+ // Every message reaches assistive technology through the hidden live region. Errors, and the few notices a
44
+ // person has to see (pass 'notice'), also show as a toast; routine confirmations stay quiet.
45
+ const TOAST_MS = { error: 8000, notice: 5000 }, TOAST_LIMIT = 3;
46
+ function status(message, tone = false) {
47
+ const live = $('status'); if (live) live.textContent = message;
48
+ const kind = tone === true || tone === 'error' ? 'error' : tone === 'notice' ? 'notice' : '';
49
+ if (kind && message) toast(message, kind);
50
+ }
51
+ function toast(message, tone) {
52
+ const stack = $('toasts');
53
+ if (!stack || typeof stack.append !== 'function') return;
54
+ // The same message again keeps its toast up rather than stacking or replaying it.
55
+ const shown = Array.from(stack.children || []).find(item => item.getAttribute?.('data-message') === message && item.andorraLater);
56
+ if (shown) { shown.andorraLater(); return; }
57
+ const item = el('div', undefined, 'toast'), close = el('button', undefined, 'icon-button toast-close');
58
+ item.setAttribute('data-tone', tone); item.setAttribute('data-message', message);
59
+ close.type = 'button'; close.title = 'Dismiss'; close.setAttribute('aria-label', 'Dismiss'); close.setAttribute('data-icon', 'x');
60
+ item.append(el('span', message, 'toast-text'), close);
61
+ globalThis.AndorraIcons?.hydrate?.(item);
62
+ let timer = 0;
63
+ const dismiss = () => { clearTimeout(timer); item.andorraLater = null; leaveLayer(item, () => item.remove()); };
64
+ const later = () => { clearTimeout(timer); timer = setTimeout(dismiss, TOAST_MS[tone]); timer?.unref?.(); };
65
+ close.onclick = dismiss; item.onpointerenter = () => clearTimeout(timer); item.onpointerleave = later; item.andorraLater = later;
66
+ stack.append(item);
67
+ for (const extra of Array.from(stack.children || []).slice(0, -TOAST_LIMIT)) extra.remove?.();
68
+ later();
69
+ }
44
70
  const FREE_CREATE_TIP = 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.';
45
71
  const FREE_ORCHESTRATOR_TIP = 'The Orchestrator is a Premium feature. Free tier graphs can use the other agents.';
46
72
  function freeTier() { return state.plan?.paid === false; }
47
73
  function freeNodeTip() { return `Free tier graphs can have up to ${state.plan.nodeLimit} steps, not counting Done. Upgrade to Premium for larger graphs.`; }
48
74
  function countedNodes(graph) { return Object.values(graph.nodes).filter(node => node.type !== 'end').length; }
49
- function canCreateGraph() { return !freeTier() || state.graphs.filter(graph => graph.id !== 'default').length < state.plan.customGraphLimit; }
50
- function freeGraphEditable(graph) { return !freeTier() || (graph.revision ? graph.id === (state.plan.freeGraphId ?? state.graphs.find(item => item.id !== 'default')?.id) : canCreateGraph()); }
51
- const FREE_LOCKED_TIP = 'On the free tier only your first custom graph is available. Upgrade to Premium to open this graph.';
75
+ function canCreateGraph() { return !freeTier() || state.plan.freeGraphId === undefined; }
76
+ function freeGraphEditable(graph) { return !freeTier() || (graph.revision ? graph.id === state.plan.freeGraphId : canCreateGraph()); }
77
+ const FREE_LOCKED_TIP = 'View only on the free tier. Duplicate it to make a copy you can change, or upgrade to Premium.';
78
+ const FREE_DRAFT_LOCKED_TIP = 'This draft belongs to a view-only graph. Duplicate the graph to change it, or upgrade to Premium.';
79
+ // Why a free account cannot copy this graph, or undefined when the copy would be its free graph.
80
+ function freeCopyRefusal(graph) {
81
+ if (!freeTier()) return undefined;
82
+ if (!canCreateGraph()) return FREE_CREATE_TIP;
83
+ if (Object.values(graph.nodes).some(node => node?.agentRole === 'orchestrator')) return 'This graph uses the Orchestrator, a Premium feature, so it cannot be duplicated on the free tier.';
84
+ const counted = countedNodes(graph);
85
+ return counted > state.plan.nodeLimit ? `This graph has ${counted} steps. Free tier graphs can have up to ${state.plan.nodeLimit}, not counting Done, so it cannot be duplicated.` : undefined;
86
+ }
87
+ function viewOnly() { return !!state.graph && graphLocked(state.graph.id); }
88
+ // A view-only graph can be explored but never changed: whatever an edit did is put back.
89
+ function restoreViewOnly() {
90
+ state.graph = copy(state.viewOnlySource); state.dirty = false; state.undo = []; state.redo = [];
91
+ renderCanvas(); renderInspector(); renderHeading(); status(FREE_LOCKED_TIP, 'notice');
92
+ }
52
93
  function graphLocked(id) {
53
94
  if (!freeTier() || id === 'default') return false;
54
95
  const graph = state.graphs.find(item => item.id === id);
@@ -102,7 +143,7 @@ function plainGraphError(message, graph) {
102
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 };
103
144
  if (/^duplicate edge /.test(detail)) return { message: 'Two connections join the same outcome to the same step. Remove one of them.', nodeId: null };
104
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] };
105
- 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]]) {
106
147
  return { message: `${name(found[1])}: ${sentence(words(found[3]))}`, nodeId: found[1] };
107
148
  }
108
149
  return { message: sentence(words(detail)), nodeId: null };
@@ -120,7 +161,7 @@ function refreshDirty() {
120
161
  state.dirty = !!state.graph && (state.savedKey == null || graphKey(state.graph) !== state.savedKey);
121
162
  if (!state.dirty && pendingDraft && pendingDraft.id === state.graph?.id) { pendingDraft = null; clearTimeout(draftTimer); }
122
163
  }
123
- function changed() { scheduleValidation(); refreshDirty(); renderCanvas(); renderHeading(); renderValidation(); status(state.dirty ? 'Unsaved changes' : 'No unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
164
+ function changed() { if (viewOnly() && state.viewOnlySource) { restoreViewOnly(); return; } scheduleValidation(); refreshDirty(); renderCanvas(); renderHeading(); renderValidation(); status(state.dirty ? 'Unsaved changes' : 'No unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
124
165
  function adoptServerStamps(saved) {
125
166
  for (const key of ['updatedAt', 'createdAt']) {
126
167
  if (saved.metadata?.[key] !== undefined) state.graph.metadata = { ...state.graph.metadata, [key]: saved.metadata[key] };
@@ -169,12 +210,12 @@ function restoreImportRequirements(graph) {
169
210
  return owed.size ? owed : null;
170
211
  }
171
212
  async function openDraft(snapshot, graphId) {
172
- if (graphLocked(graphId)) { status(FREE_LOCKED_TIP, true); return; }
213
+ if (graphLocked(graphId)) { status(FREE_DRAFT_LOCKED_TIP, true); return; }
173
214
  if (state.dirty && !await askConfirm({ title: 'Open the saved draft?', message: 'Current edits are retained in draft history.', confirmLabel: 'Open Draft' })) return;
174
- try { const graph = foldGraphSubagentCaps(await api(`/api/drafts/${snapshot}`)); const owed = restoreImportRequirements(graph); state.graph = graph; markSaved(null); state.dirty = true; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = owed; render(); fit(); status(owed ? 'Recovered imported draft. Assign a model profile to every outlined step, then save.' : 'Recovered draft. Save when valid, or duplicate if its base version changed.'); graphOpened('open'); }
215
+ try { const graph = foldGraphSubagentCaps(await api(`/api/drafts/${snapshot}`)); const owed = restoreImportRequirements(graph); state.graph = graph; markSaved(null); state.dirty = true; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = owed; render(); fit(); status(owed ? 'Recovered imported draft. Assign a model profile to every outlined step, then save.' : 'Recovered draft. Save when valid, or duplicate if its base version changed.', 'notice'); graphOpened('open'); }
175
216
  catch (error) { status(error.message, true); }
176
217
  }
177
- function mutate(action, inspector = false) { if (!state.graph) return; checkpoint(); action(); changed(); if (inspector) renderInspector(); }
218
+ function mutate(action, inspector = false) { if (!state.graph) return; if (viewOnly()) { status(FREE_LOCKED_TIP, 'notice'); return; } checkpoint(); action(); changed(); if (inspector) renderInspector(); }
178
219
  function foldSubagentCap(node) {
179
220
  if (!node || typeof node !== 'object' || node.maxSubagents === undefined) return node;
180
221
  const cap = node.maxSubagents; const policy = node.subagents;
@@ -243,6 +284,7 @@ function outcomes(node) {
243
284
  if (node.type === 'condition') return ['true', 'false'];
244
285
  if (node.type === 'loop') return ['body', 'done'];
245
286
  if (node.type === 'approval') return ['approved', 'rejected'];
287
+ if (node.type === 'review') return ['findings', 'clean', 'stopped'];
246
288
  if (node.completion?.mode === 'outcomes') return node.completion.outcomes;
247
289
  const outcome = node.completion?.outcome ?? 'completed';
248
290
  // An Action's command that exits non-zero takes the optional failed port; unrouted, it stops the run.
@@ -255,6 +297,17 @@ function selectedNodes() { return (state.selectedIds.length ? state.selectedIds
255
297
  function selectionType(node) { return node.type; }
256
298
  function clearSelection() { state.selectedIds = []; state.selected = null; state.selectedEdge = null; state.routePick = null; state.bulkOutcome = null; }
257
299
  function showInspector() { $('inspector').classList.remove('hidden'); $('toggle-inspector').setAttribute('aria-expanded','true'); }
300
+ // Under 1100px the inspector is an overlay on the canvas: it shows while something is selected, or while the
301
+ // reader opened Graph settings with the panel toggle, and gets out of the way otherwise.
302
+ const NARROW_LAYOUT = '(max-width: 1100px)';
303
+ function narrowLayout() { try { return typeof matchMedia === 'function' && matchMedia(NARROW_LAYOUT).matches; } catch { return false; } }
304
+ function hasSelection() { return selectedNodes().length > 0 || !!(state.selectedEdge && state.graph?.edges.includes(state.selectedEdge)); }
305
+ function syncInspectorOverlay() {
306
+ if (!narrowLayout()) return;
307
+ const show = !!state.graph && (hasSelection() || !!state.graphSettingsOpen);
308
+ $('inspector').classList.toggle('hidden', !show); $('toggle-inspector').setAttribute('aria-expanded', String(show));
309
+ }
310
+ function dismissInspectorOverlay() { clearSelection(); state.graphSettingsOpen = false; renderCanvas(); renderInspector(); }
258
311
  function selectNode(node, event = {}) {
259
312
  if (state.routePick) { routeSelectionTo(node.id); return; }
260
313
  if (state.suppressClick === node.id) { state.suppressClick = null; return; }
@@ -275,7 +328,7 @@ function routeSelectionTo(targetId) {
275
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; }
276
329
  mutate(() => {
277
330
  const existing = state.graph.edges;
278
- 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)});
279
332
  state.graph.edges = [...existing.filter(edge => !pick.sources.includes(edge.source) || edgeOutcome(edge) !== pick.outcome),...replacements];
280
333
  state.routePick = null;
281
334
  },true);
@@ -355,9 +408,11 @@ function cancelRoutePick() { state.routePick=null;renderCanvas();renderInspector
355
408
  function issues() {
356
409
  const graph = state.graph; if (!graph) return [];
357
410
  const result = [], nodes = Object.values(graph.nodes);
411
+ // A view-only graph is not being saved, so the limits it is over are not its reader's problem.
412
+ if (viewOnly()) return [{ message: FREE_LOCKED_TIP }];
358
413
  if (nodes.length < 2 || nodes.length > nodeLimit(graph)) result.push({ message: `Use between 2 and ${nodeLimit(graph)} steps; remove extra steps before saving.` });
359
414
  if (freeTier()) {
360
- if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? 'On the free tier only your first custom graph can be changed. Upgrade to Premium to edit this graph.' : FREE_CREATE_TIP });
415
+ if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? FREE_LOCKED_TIP : FREE_CREATE_TIP });
361
416
  if (nodes.some(node => node.agentRole === 'orchestrator')) result.push({ message: FREE_ORCHESTRATOR_TIP });
362
417
  if (countedNodes(graph) > state.plan.nodeLimit) result.push({ message: freeNodeTip() });
363
418
  }
@@ -419,7 +474,7 @@ function rememberedGraph() {
419
474
  }
420
475
  async function reopenRemembered() {
421
476
  const remembered = rememberedGraph();
422
- if (!remembered || graphLocked(remembered.id)) return false;
477
+ if (!remembered) return false;
423
478
  const saved = state.graphs.some(graph => graph.id === remembered.id);
424
479
  if (remembered.unsaved || !saved) {
425
480
  try {
@@ -433,12 +488,20 @@ async function reopenRemembered() {
433
488
  function renderHeading() {
434
489
  rememberOpenGraph();
435
490
  $('graph-title').textContent = state.graph?.name || 'Graph Editor';
436
- $('revision').textContent = state.graph ? `${state.graph.revision ? `Version ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
491
+ $('revision').textContent = state.graph ? (state.graph.revision ? `Version ${state.graph.revision}` : 'New graph') : '';
437
492
  $('save').disabled = state.saving || state.orderSaving || !state.graph || !state.dirty || state.graph.id === 'default';
438
493
  $('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
494
+ $('save-state').textContent = viewOnly() ? 'View only' : 'Saved';
495
+ $('save-state').title = viewOnly() ? FREE_LOCKED_TIP : '';
496
+ document.body?.classList?.toggle?.('view-only', viewOnly());
497
+ // Save is the header's one primary and shows only while there is something to save; a clean graph says so quietly.
498
+ const pending = !!state.graph && (state.dirty || state.saving);
499
+ $('save').hidden = !pending;
500
+ $('save-state').hidden = !state.graph || pending;
439
501
  $('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
440
502
  for (const id of ['duplicate', 'export', 'layout', 'fit']) $(id).disabled = !state.graph;
441
503
  $('duplicate').disabled = state.saving || state.orderSaving || !state.graph || !canCreateGraph();
504
+ if (viewOnly()) for (const id of ['layout', 'undo', 'redo']) $(id).disabled = true;
442
505
  renderLibrary();
443
506
  window.AndorraStudio?.heading?.();
444
507
  globalThis.AndorraManager?.heading?.();
@@ -496,10 +559,9 @@ function renderList() {
496
559
  const locked = graphLocked(graph.id);
497
560
  const button = el('button', undefined, `graph-row${state.graph?.id === graph.id ? ' active' : ''}${locked ? ' locked' : ''}`);
498
561
  button.disabled = state.saving;
499
- const tag = el('small', graph.id === 'default' ? 'Preset' : `v${graph.revision}`);
562
+ const tag = el('small', graph.id === 'default' ? 'Preset' : locked ? 'View only' : `v${graph.revision}`);
500
563
  button.append(el('span', graph.name), tag);
501
564
  if (locked) {
502
- button.setAttribute('aria-disabled', 'true');
503
565
  button.title = FREE_LOCKED_TIP;
504
566
  const glyph = globalThis.AndorraIcons?.icon?.('lock', 12);
505
567
  if (glyph) tag.prepend(glyph);
@@ -549,7 +611,7 @@ function renderList() {
549
611
  const button = el('button', undefined, `graph-row draft-row${locked ? ' locked' : ''}`); button.disabled = state.saving;
550
612
  const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
551
613
  const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
552
- button.title = locked ? FREE_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
614
+ button.title = locked ? FREE_DRAFT_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
553
615
  if (locked) { button.setAttribute('aria-disabled', 'true'); const glyph = globalThis.AndorraIcons?.icon?.('lock', 12); if (glyph) when.prepend(glyph); }
554
616
  button.append(el('span', draft.name), when);
555
617
  button.onclick = () => openDraft(draft.snapshot, draft.graphId);
@@ -634,7 +696,7 @@ function showMenuAt(x, y, ariaLabel, items) {
634
696
  }
635
697
  function showGraphMenu(graph, x, y) {
636
698
  const items = [
637
- ...(graphLocked(graph.id) ? [] : [{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) }]),
699
+ { label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) },
638
700
  { label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
639
701
  ];
640
702
  if (graph.id !== 'default') items.push({ label: 'Delete', icon: 'trash', danger: true, run: () => { deleteGraph(graph).catch(error => status(error.message, true)); } });
@@ -648,7 +710,7 @@ function showNewGraphMenu(x, y) {
648
710
  }
649
711
  async function exportGraph(graph) {
650
712
  if (window.AndorraEmbed?.hostChrome?.() && window.AndorraEmbed.exportGraph) { window.AndorraEmbed.exportGraph(graph.id); return; }
651
- if (state.saving) { status('Wait for the current save before exporting a graph.'); return; }
713
+ if (state.saving) { status('Wait for the current save before exporting a graph.', 'notice'); return; }
652
714
  downloadGraph(dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(graph.id)}`)));
653
715
  }
654
716
  function exportFileName(graph) {
@@ -662,16 +724,19 @@ function downloadJson(value, stem) {
662
724
  setTimeout(() => URL.revokeObjectURL(url), 1000);
663
725
  }
664
726
  async function duplicateGraph(source) {
665
- if (state.saving || state.orderSaving) { status('Wait for the current save before duplicating a graph.'); return; }
727
+ if (state.saving || state.orderSaving) { status('Wait for the current save before duplicating a graph.', 'notice'); return; }
666
728
  state.saving = true; renderHeading(); renderList();
667
729
  let created;
668
730
  let orderSaveError;
669
731
  try {
670
732
  const saved = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(source.id)}`));
733
+ const refusal = freeCopyRefusal(saved);
734
+ if (refusal) throw new Error(refusal);
671
735
  const suffix = ' (Copy)', base = saved.name || 'Untitled graph';
672
736
  const name = base.length + suffix.length > 200 ? base.slice(0, 200 - suffix.length).trimEnd() + suffix : base + suffix;
673
737
  const duplicate = { ...saved, id: newId(), name, revision: 0 };
674
738
  const stored = await api('/api/graphs', duplicate);
739
+ if (freeTier()) state.plan.freeGraphId = stored.id;
675
740
  created = { id: stored.id, name: stored.name };
676
741
  const summary = { id: stored.id, name: stored.name, revision: stored.revision };
677
742
  state.graphs.push(summary);
@@ -685,7 +750,7 @@ async function duplicateGraph(source) {
685
750
  if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in Graph settings.`);
686
751
  }
687
752
  async function deleteGraph(graph) {
688
- if (state.saving || state.orderSaving) { status('Wait for the current save before deleting a graph.'); return; }
753
+ if (state.saving || state.orderSaving) { status('Wait for the current save before deleting a graph.', 'notice'); return; }
689
754
  if (!await askConfirm({ title: `Delete “${graph.name}”?`, message: 'Its versions and drafts are removed from this machine.', confirmLabel: 'Delete', tone: 'danger' })) return;
690
755
  state.saving = true; renderHeading(); renderList();
691
756
  if (!pendingDraft || pendingDraft.id === graph.id) { pendingDraft = null; clearTimeout(draftTimer); }
@@ -711,6 +776,10 @@ async function deleteGraph(graph) {
711
776
  if (state.graph?.id !== graph.id) status(`Deleted "${graph.name}".`);
712
777
  }
713
778
  function position(node, index) { return node.position || { x: index * 290, y: 0 }; }
779
+ // A step card's footprint before it is measured: one outcome is a dot on the right edge; several stack as labelled rows.
780
+ const NODE_WIDTH = 210, NODE_HEIGHT = 68, PORT_ROW = 24, PORT_Y = NODE_HEIGHT / 2;
781
+ function portLayout(node) { const count = outcomes(node).length; return count > 1 ? 'many' : count ? 'solo' : 'none'; }
782
+ function nodeHeight(node) { const count = outcomes(node).length; return NODE_HEIGHT + (count > 1 ? count * PORT_ROW - 4 : 0); }
714
783
  const GRID_STEP = 20;
715
784
  const GRID_MIN_PX = 10;
716
785
  function transform() {
@@ -741,6 +810,10 @@ function nodeModelLabel(node) {
741
810
  if (provider && typeof provider !== 'string' && provider.model) return provider.model;
742
811
  return node.provider ? titleFor(provider || node.provider) : '';
743
812
  }
813
+ /** A review node's findings carry the fix prompt to the Agent they reach as its task. */
814
+ function reviewFindingsMapping(source, target, outcome) {
815
+ return source?.type === 'review' && outcome === 'findings' && target?.type === 'agent' ? { inputMapping: { taskInstruction: '$source.output.prompt' } } : {};
816
+ }
744
817
  function nodeSubtitle(node) {
745
818
  if (node.type === 'agent') {
746
819
  const model = nodeModelLabel(node);
@@ -748,7 +821,7 @@ function nodeSubtitle(node) {
748
821
  }
749
822
  if (node.type === 'end') return 'Graph complete';
750
823
  if (node.type === 'action') return node.action?.kind === 'tests' ? 'Run tests' : node.action?.kind === 'git' ? 'Git operation' : 'Run command';
751
- return { join: 'Wait for branches', loop: 'Bounded repetition', condition: 'Branch on run state', parallel: 'Fan out', approval: 'Human approval' }[node.type] || 'Flow control';
824
+ 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';
752
825
  }
753
826
  const nodeIconElement = node => globalThis.AndorraIcons?.icon?.(globalThis.AndorraIcons.nodeIcon(node));
754
827
  function renderCanvas() {
@@ -761,7 +834,7 @@ function renderCanvas() {
761
834
  const connected = new Set(state.graph.edges.map(edge => JSON.stringify([edge.source, edgeOutcome(edge)])));
762
835
  const errorIds = nodeErrorIds();
763
836
  nodes.forEach((node, index) => {
764
- const p = positions.get(node.id), button = el('div', undefined, `node ${node.type}${selectedNodes().some(item=>item.id===node.id) ? ' selected' : ''}${errorIds.has(node.id) ? ' node-error' : ''}${state.routePick && !state.routePick.sources.includes(node.id) && node.agentRole !== 'orchestrator' ? ' route-target' : ''}`);
837
+ const p = positions.get(node.id), button = el('div', undefined, `node ${node.type} ports-${portLayout(node)}${selectedNodes().some(item=>item.id===node.id) ? ' selected' : ''}${errorIds.has(node.id) ? ' node-error' : ''}${state.routePick && !state.routePick.sources.includes(node.id) && node.agentRole !== 'orchestrator' ? ' route-target' : ''}`);
765
838
  button.tabIndex = 0; button.setAttribute('data-node-id',node.id); button.setAttribute('role', 'button'); button.style.left = `${p.x}px`; button.style.top = `${p.y}px`; button.setAttribute('aria-label', `${node.name}, ${node.agentRole === 'orchestrator' ? 'orchestrator' : node.type}${node.id === state.graph.entry ? ', entry' : ''}`);
766
839
  const title = el('div', undefined, 'node-title'), glyph = nodeIconElement(node);
767
840
  if (glyph) title.append(glyph);
@@ -803,7 +876,7 @@ function measureBoxes() {
803
876
  Object.values(state.graph.nodes).forEach((node, index) => {
804
877
  const element = elements.get(node.id), p = position(node, index);
805
878
  if (!element) return;
806
- const offsets = Array.from(element.querySelectorAll('.output-port')).map(port => port.offsetTop + port.offsetHeight / 2);
879
+ const edge = element.clientTop || 0, offsets = Array.from(element.querySelectorAll('.output-port')).map(port => edge + port.offsetTop + port.offsetHeight / 2);
807
880
  boxes.set(node.id, { ...p, width: element.offsetWidth, height: element.offsetHeight, offsets, ports: offsets.map(offset => ({ x: p.x + element.offsetWidth, y: p.y + offset })) });
808
881
  });
809
882
  return boxes;
@@ -811,7 +884,7 @@ function measureBoxes() {
811
884
  function routeInput(edge, boxes) {
812
885
  const from = boxes.get(edge.source), to = boxes.get(edge.target); if (!from || !to) return null;
813
886
  const source = from.ports[Math.max(0, outcomes(state.graph.nodes[edge.source]).indexOf(edgeOutcome(edge)))];
814
- return source ? { source, target: { x: to.x, y: to.y + 48 } } : null;
887
+ return source ? { source, target: { x: to.x, y: to.y + PORT_Y } } : null;
815
888
  }
816
889
  const drawnRoute = points => points && { d: (AndorraEdgeRouter.roundedPath || AndorraEdgeRouter.path)(points), label: AndorraEdgeRouter.labelPoint?.(points) };
817
890
  function dragFrame(node, boxes) {
@@ -1446,7 +1519,7 @@ function routes(parent, node) {
1446
1519
  const row = section(group, outcome); row.id = `route-${outcome}`;
1447
1520
  for (const destination of Object.values(state.graph.nodes).filter(n => n.id !== node.id && n.agentRole !== 'orchestrator')) {
1448
1521
  const edge = state.graph.edges.find(e => e.source === node.id && edgeOutcome(e) === outcome && e.target === destination.id);
1449
- 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); });
1522
+ 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); });
1450
1523
  if (edge) { const edit = el('button', 'Edit Connection', 'link-button'); edit.onclick = () => { state.selectedEdge = edge; state.selected = null; renderInspector(); renderCanvas(); }; row.append(edit); }
1451
1524
  }
1452
1525
  }
@@ -1557,7 +1630,84 @@ function renderControlInspector(parent,node) {
1557
1630
  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});}
1558
1631
  if(node.type==='parallel')parent.append(el('p','All completed connections become ready. A Parallel step is optional for ordinary outcome fan-out.', 'help'));
1559
1632
  if(node.type==='approval')parent.append(el('p','The CLI asks for approval. Route approved and rejected separately.', 'help'));
1633
+ if(node.type==='review')renderReviewInspector(parent,node);
1634
+ }
1635
+ const REVIEW_ROUNDS_DEFAULT = 3, REVIEW_ROUNDS_MAX = 10, REVIEW_INSTRUCTION_BYTES = 2048;
1636
+ /**
1637
+ * Every node may be visited at most limits.maxNodeVisits times (unset or 0: unlimited), and a cycle needs a ceiling. A
1638
+ * review loop's fixer and review node come back once per round: a finite ceiling below the rounds is raised to them; an
1639
+ * unlimited one stays, and a graph with no ceiling at all gets the rounds when `cycle` adds one.
1640
+ */
1641
+ function raiseVisitsFor(rounds, cycle = false) {
1642
+ const limits = state.graph.limits || {};
1643
+ const visits = limits.maxNodeVisits;
1644
+ const finite = typeof visits === 'number' && visits > 0;
1645
+ if (finite ? visits < rounds : cycle && limits.wallTimeMs === undefined) state.graph.limits = { ...limits, maxNodeVisits: rounds };
1646
+ }
1647
+ /** The text cut to at most `bytes` UTF-8 bytes, as the engine counts the instruction. */
1648
+ function cutToBytes(text, bytes) {
1649
+ const encoder = new TextEncoder();
1650
+ if (encoder.encode(text).length <= bytes) return text;
1651
+ let out = '';
1652
+ for (const character of text) { if (encoder.encode(out + character).length > bytes) break; out += character; }
1653
+ return out;
1654
+ }
1655
+ /** An Andorra review node: each visit reviews the task's pull request once (design/specs/andorra-review-loop.md, "Graphs"). */
1656
+ function renderReviewInspector(parent,node) {
1657
+ const review = node.review || { rounds: REVIEW_ROUNDS_DEFAULT };
1658
+ // Each change reads the node as it is now: the fields are not redrawn between edits.
1659
+ 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]; };
1660
+ 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'));
1661
+ 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});
1662
+ 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}));
1663
+ 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});
1664
+ // Provider and model go together, or neither (the task's model).
1665
+ 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'});
1666
+ 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'));
1667
+ }
1668
+ /** Why "Add Andorra Review After This Step" cannot wire this Agent as the server would accept it, if it cannot. */
1669
+ function reviewAfterRefusal(node) {
1670
+ const outcome = outcomes(node)[0];
1671
+ const moved = state.graph.edges.filter(edge => edge.source === node.id && edgeOutcome(edge) === outcome);
1672
+ if (node.modifiers?.condition) return 'This step branches on a condition; connect an Andorra review step by hand.';
1673
+ if (node.modifiers?.parallel?.mode === 'branches') return 'Parallel branches connect directly to Agents; connect an Andorra review step after them instead.';
1674
+ if (!moved.length) return `Connect this step's ${outcome} port first: the review goes where it went.`;
1675
+ 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.';
1676
+ const schema = node.inputSchema;
1677
+ 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.';
1678
+ const required = (schema?.required || []).filter(name => name !== 'taskInstruction' && name !== 'task');
1679
+ if (required.length) return `This step needs ${required.join(', ')} as input, which the findings do not carry; connect the review by hand.`;
1680
+ if (Object.keys(state.graph.nodes).length >= nodeLimit(state.graph)) return 'This graph has as many steps as it can hold.';
1681
+ return freeNodeRefusal([{ type: 'review' }]);
1682
+ }
1683
+ /**
1684
+ * "Add Andorra Review After This Step": the Agent's routes on its first port go through a new review node, whose clean
1685
+ * and stopped routes go where they went (with their mappings), and whose findings come back to the Agent with the fix
1686
+ * prompt as its task.
1687
+ */
1688
+ function addReviewAfter(node) {
1689
+ const refusal = reviewAfterRefusal(node);
1690
+ if (refusal) { status(refusal, true); return; }
1691
+ const outcome = outcomes(node)[0];
1692
+ const moved = state.graph.edges.filter(edge => edge.source === node.id && edgeOutcome(edge) === outcome);
1693
+ mutate(() => {
1694
+ const short = crypto.randomUUID().slice(0, 8);
1695
+ const id = `review-${short}`;
1696
+ const p = position(node, Object.keys(state.graph.nodes).indexOf(node.id));
1697
+ state.graph.schemaVersion = 3;
1698
+ state.graph.nodes[id] = { id, name: 'Andorra review', type: 'review', review: { rounds: REVIEW_ROUNDS_DEFAULT }, position: { x: p.x + 300, y: p.y + 140 } };
1699
+ state.graph.edges = state.graph.edges.filter(edge => !moved.includes(edge));
1700
+ state.graph.edges.push({ id: `${id}-in`, source: node.id, target: id, outcome });
1701
+ state.graph.edges.push({ id: `${id}-findings`, source: id, target: node.id, outcome: 'findings', inputMapping: { taskInstruction: '$source.output.prompt' } });
1702
+ moved.forEach((edge, index) => {
1703
+ const carried = { ...(edge.inputMapping ? { inputMapping: copy(edge.inputMapping) } : {}), ...(edge.toInput ? { toInput: edge.toInput } : {}) };
1704
+ for (const end of ['clean', 'stopped']) state.graph.edges.push({ id: `${id}-${end}-${index}`, source: id, target: edge.target, outcome: end, ...copy(carried) });
1705
+ });
1706
+ raiseVisitsFor(REVIEW_ROUNDS_DEFAULT, true);
1707
+ state.selectedIds = [id]; state.selected = id; state.selectedEdge = null;
1708
+ }, true);
1560
1709
  }
1710
+
1561
1711
  function setAgentModifier(node, kind, value) {
1562
1712
  const before = outcomes(node);
1563
1713
  node.modifiers = {...node.modifiers};
@@ -1633,6 +1783,7 @@ function retryLimitHelp(parent, graph) {
1633
1783
  }
1634
1784
  function renderInspector() {
1635
1785
  document.body?.classList?.remove?.('prompt-fullscreen'); for (const backdrop of document.querySelectorAll?.('.prompt-backdrop') ?? []) backdrop.remove();
1786
+ syncInspectorOverlay();
1636
1787
  const parent = $('inspector-body'); parent.replaceChildren(); const graph = state.graph; if (!graph) { parent.append(el('p', 'Create a graph or choose a preset.', 'help')); return; }
1637
1788
  if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
1638
1789
  const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : 'Graph settings';
@@ -1643,7 +1794,7 @@ function renderInspector() {
1643
1794
  else if (!node) {
1644
1795
  const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
1645
1796
  field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
1646
- const meta = el('p', `${graph.id} · Version ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
1797
+ const meta = el('p', [graphIsFixed(graph) ? 'Preset' : '', graph.revision ? `Version ${graph.revision}` : 'Not saved yet'].filter(Boolean).join(' · '), 'graph-meta'); meta.title = `Graph ID: ${graph.id}`; general.append(meta);
1647
1798
  if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
1648
1799
  const start = field(general,'Starting step',graph.nodes[graph.entry]?.name || '',()=>{}); start.disabled=true; explain(start,'The Orchestrator is optional. Deleting the starting step promotes its first remaining connected successor, or the first remaining step if none is connected.');
1649
1800
  field(general, 'Description', graph.metadata?.description, value => {graph.metadata={...graph.metadata,description:value};}, {multiline:true,maxLength:2000});
@@ -1697,7 +1848,9 @@ function renderInspector() {
1697
1848
  const tools = disclosure(advanced,'Tool allowlist');
1698
1849
  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);});
1699
1850
  const saveDefinition = el('button','Save to Library'); saveDefinition.onclick=()=>saveAgentVariant(node); general.append(saveDefinition);
1700
- } else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
1851
+ if (node.agentRole !== 'orchestrator') { const addReview = el('button','Add Andorra Review After This Step'); addReview.onclick=()=>addReviewAfter(node); general.append(addReview); }
1852
+ } else if (node.type === 'review') renderControlInspector(general,node);
1853
+ else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
1701
1854
  if (panels.behavior) routes(panels.behavior,node);
1702
1855
  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});
1703
1856
  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);
@@ -1707,16 +1860,17 @@ function renderInspector() {
1707
1860
  }
1708
1861
  function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas(); renderInspector(); scheduleValidation(); queueDraft(); }
1709
1862
  async function openGraph(id, options = {}) {
1710
- if (state.saving) { status('Wait for the current save before opening another graph.'); return false; }
1711
- if (graphLocked(id)) { status(FREE_LOCKED_TIP, true); return false; }
1863
+ if (state.saving) { status('Wait for the current save before opening another graph.', 'notice'); return false; }
1712
1864
  if (state.dirty && !options.discard && !await askConfirm(DISCARD_QUESTION)) return false;
1713
- try { const opened = options.fetched === undefined ? await api(`/api/graphs/${encodeURIComponent(id)}`) : options.fetched; const capMoved = hasSubagentCap(opened); state.graph = dropLegacyTokenFields(opened); const migrated = state.graph.editorMigration === true; state.dirty = migrated || capMoved; delete state.graph.editorMigration; markSaved(state.dirty ? null : state.graph); clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(migrated ? 'This graph was updated to the current format. Save to keep it.' : capMoved ? 'Orchestrator Max subagents moved to Advanced > Subagents. Save to keep it.' : 'Graph loaded'); graphOpened(options.reason || 'open'); return true; } catch (error) { status(error.message, true); return false; }
1865
+ try { const opened = options.fetched === undefined ? await api(`/api/graphs/${encodeURIComponent(id)}`) : options.fetched; const locked = graphLocked(id); const capMoved = !locked && hasSubagentCap(opened); state.graph = dropLegacyTokenFields(opened); const migrated = !locked && state.graph.editorMigration === true; state.dirty = migrated || capMoved; delete state.graph.editorMigration; state.viewOnlySource = locked ? copy(state.graph) : null; markSaved(state.dirty ? null : state.graph); clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(locked ? FREE_LOCKED_TIP : migrated ? 'This graph was updated to the current format. Save to keep it.' : capMoved ? 'Orchestrator Max subagents moved to Advanced > Subagents. Save to keep it.' : 'Graph loaded', locked || migrated || capMoved ? 'notice' : false); graphOpened(options.reason || 'open'); return true; } catch (error) { status(error.message, true); return false; }
1714
1866
  }
1715
1867
  function newId() { return `graph-${crypto.randomUUID()}`; }
1716
1868
  function newGraph(duplicate = false, discarded = false) {
1717
- if (state.saving) { status('Wait for the current save before creating another graph.'); return; }
1869
+ if (state.saving) { status('Wait for the current save before creating another graph.', 'notice'); return; }
1718
1870
  if (!canCreateGraph()) { status(FREE_CREATE_TIP, true); return; }
1871
+ if (duplicate) { const refusal = freeCopyRefusal(state.graph); if (refusal) { status(refusal, true); return; } }
1719
1872
  if (state.dirty && !discarded) { void askConfirm(DISCARD_QUESTION).then(discard => { if (discard) newGraph(duplicate, true); }); return; }
1873
+ state.viewOnlySource = null;
1720
1874
  if (duplicate) state.graph={...copy(state.graph),id:newId(),name:`${state.graph.name} copy`,revision:0};
1721
1875
  else if (freeTier()) {
1722
1876
  const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
@@ -1785,7 +1939,7 @@ function addNode(type, definition, dropPosition) {
1785
1939
  const id = `${type}-${crypto.randomUUID().slice(0, 8)}`;
1786
1940
  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;} }
1787
1941
  state.graph.schemaVersion = 3;
1788
- 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 } };
1942
+ 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 } };
1789
1943
  if (definition?.agentRole === 'orchestrator') {
1790
1944
  const previousEntry = state.graph.entry;
1791
1945
  if (state.graph.limits?.maxToolCalls !== undefined) state.graph.limits.maxToolCalls = Math.min(1_000_000_000, state.graph.limits.maxToolCalls + 2);
@@ -1991,7 +2145,7 @@ function renderLibrary() {
1991
2145
  if (agents) agents.append(el('p','Select an Agent to configure Condition, Loop, and Parallel modifiers.','help'));
1992
2146
  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]})));
1993
2147
  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'}]);
1994
- section(container,'flow','Flow',[{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this graph path'}]);
2148
+ 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'}]);
1995
2149
  if (query && !container.children.length) container.append(emptyState('search', 'No steps match', 'Try another name, or clear the search.'));
1996
2150
  }
1997
2151
  let viewAnimation = 0, viewTarget = null;
@@ -2016,7 +2170,7 @@ function animateView(target, anchor) {
2016
2170
  }
2017
2171
  function fit(animate = false) {
2018
2172
  if (!state.graph) return; const nodes = Object.values(state.graph.nodes); if (!nodes.length) return;
2019
- const positions = nodes.map(position), minX = Math.min(...positions.map(p => p.x)), minY = Math.min(...positions.map(p => p.y)), maxX = Math.max(...positions.map(p => p.x)) + 210, maxY = Math.max(...positions.map(p => p.y)) + Math.max(...nodes.map(n => 94 + outcomes(n).length * 25));
2173
+ const positions = nodes.map(position), minX = Math.min(...positions.map(p => p.x)), minY = Math.min(...positions.map(p => p.y)), maxX = Math.max(...positions.map(p => p.x)) + NODE_WIDTH, maxY = Math.max(...nodes.map((n, i) => positions[i].y + nodeHeight(n)));
2020
2174
  const zoomed = Math.min(1, Math.max(.2, Math.min(($('canvas').clientWidth - 90) / (maxX - minX), ($('canvas').clientHeight - 170) / (maxY - minY))));
2021
2175
  const target = { zoom: zoomed, x: ($('canvas').clientWidth - (maxX - minX) * zoomed) / 2 - minX * zoomed, y: ($('canvas').clientHeight - (maxY - minY) * zoomed) / 2 - minY * zoomed };
2022
2176
  if (animate) { animateView(target); return; }
@@ -2033,8 +2187,15 @@ function zoomBy(factor) {
2033
2187
  }
2034
2188
  $('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('empty-create').onclick = () => newGraph(); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
2035
2189
  $('node-search').oninput = renderLibrary;
2036
- $('graph-settings').onclick = () => { clearSelection(); renderCanvas(); renderInspector(); };
2037
- $('toggle-inspector').onclick = () => { const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden)); };
2190
+ $('graph-settings').onclick = () => { clearSelection(); state.graphSettingsOpen = true; renderCanvas(); renderInspector(); };
2191
+ $('toggle-inspector').onclick = () => {
2192
+ if (narrowLayout()) { if ($('inspector').classList.contains?.('hidden')) { state.graphSettingsOpen = true; renderInspector(); } else dismissInspectorOverlay(); return; }
2193
+ const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden));
2194
+ };
2195
+ if (typeof matchMedia === 'function') {
2196
+ const narrow = matchMedia(NARROW_LAYOUT), relayout = () => { if (narrow.matches) syncInspectorOverlay(); else showInspector(); };
2197
+ if (typeof narrow.addEventListener === 'function') narrow.addEventListener('change', relayout); else narrow.addListener?.(relayout);
2198
+ }
2038
2199
  $('undo').onclick = () => { if (!state.undo.length) return; state.redo.push(copy(state.graph)); state.graph = state.undo.pop(); clearSelection(); refreshDirty(); render(); status(state.dirty ? 'Change undone' : 'Change undone · No unsaved changes'); };
2039
2200
  $('redo').onclick = () => { if (!state.redo.length) return; state.undo.push(copy(state.graph)); state.graph = state.redo.pop(); clearSelection(); refreshDirty(); render(); status('Change restored'); };
2040
2201
  function pulseErrorNodes() {
@@ -2058,7 +2219,7 @@ $('save').onclick = async () => {
2058
2219
  let orderFailed = false;
2059
2220
  try { const submitted = dropLegacyTokenFields(copy(state.graph)); const graph = await api('/api/graphs', submitted); if (state.graph.id === submitted.id) {
2060
2221
  const liveView = { ...state.graph }; delete liveView.pendingProviderNodes;
2061
- const edited = JSON.stringify(liveView) !== JSON.stringify(submitted); markSaved(graph); if (edited) { state.graph.revision = graph.revision; adoptServerStamps(graph); state.undo = []; state.redo = []; refreshDirty(); } else { state.graph = graph; state.dirty = false; state.undo = []; state.redo = []; } retireSatisfiedProviderRequirements(); } const index = state.graphs.findIndex(g => g.id === graph.id); const summary = { id: graph.id, name: graph.name, revision: graph.revision }; if (index >= 0) state.graphs[index] = summary; else { state.graphs.push(summary); try { await persistGraphOrder(); } catch { orderFailed = true; } } render(); status(`Saved version ${graph.revision}${state.dirty ? ' · You have newer unsaved changes' : ''}${orderFailed ? ' · Graph order not saved' : ''}`); } catch (error) { status(error.message, true); } finally { state.saving = false; renderHeading(); renderList(); }
2222
+ const edited = JSON.stringify(liveView) !== JSON.stringify(submitted); markSaved(graph); if (edited) { state.graph.revision = graph.revision; adoptServerStamps(graph); state.undo = []; state.redo = []; refreshDirty(); } else { state.graph = graph; state.dirty = false; state.undo = []; state.redo = []; } retireSatisfiedProviderRequirements(); } if (freeTier()) state.plan.freeGraphId = graph.id; const index = state.graphs.findIndex(g => g.id === graph.id); const summary = { id: graph.id, name: graph.name, revision: graph.revision }; if (index >= 0) state.graphs[index] = summary; else { state.graphs.push(summary); try { await persistGraphOrder(); } catch { orderFailed = true; } } render(); status(`Saved version ${graph.revision}${state.dirty ? ' · You have newer unsaved changes' : ''}${orderFailed ? ' · Graph order not saved' : ''}`, orderFailed ? 'notice' : false); } catch (error) { status(error.message, true); } finally { state.saving = false; renderHeading(); renderList(); }
2062
2223
  };
2063
2224
  $('canvas-hint-close').onclick = dismissCanvasHint;
2064
2225
  $('fit').onclick = () => fit(true); $('zoom-in').onclick = () => zoomBy(1.2); $('zoom-out').onclick = () => zoomBy(1 / 1.2);
@@ -2095,7 +2256,7 @@ $('canvas').ondrop = event => {
2095
2256
  const file = Array.from(event.dataTransfer?.files || []).find(item => /\.json$/i.test(item.name) || item.type === 'application/json');
2096
2257
  if (file) { event.preventDefault(); void window.AndorraStudio?.importGraphFile?.(file)?.catch(error => status(error.message, true)); }
2097
2258
  };
2098
- $('canvas').onpointerdown = event => { if (event.button !== 0 || event.target.closest('button, .node, path, .canvas-hint')) return; dismissCanvasHint(); stopViewAnimation(); const start = { x: event.clientX - state.x, y: event.clientY - state.y }; $('canvas').setPointerCapture(event.pointerId); $('canvas').onpointermove = e => { state.x = e.clientX - start.x; state.y = e.clientY - start.y; requestTransform(); }; $('canvas').onpointerup = () => { $('canvas').onpointermove = null; }; };
2259
+ $('canvas').onpointerdown = event => { if (event.button !== 0 || event.target.closest('button, .node, path, .canvas-hint')) return; dismissCanvasHint(); stopViewAnimation(); const start = { x: event.clientX - state.x, y: event.clientY - state.y }; $('canvas').setPointerCapture(event.pointerId); $('canvas').onpointermove = e => { state.x = e.clientX - start.x; state.y = e.clientY - start.y; requestTransform(); }; $('canvas').onpointerup = e => { $('canvas').onpointermove = null; if (narrowLayout() && Math.hypot(e.clientX - event.clientX, e.clientY - event.clientY) < 3 && !$('inspector').classList.contains?.('hidden')) dismissInspectorOverlay(); }; };
2099
2260
  $('resize').onpointerdown = event => { $('resize').setPointerCapture(event.pointerId); $('resize').onpointermove = e => { document.documentElement.style.setProperty('--panel', `${Math.max(360, Math.min(720, innerWidth - e.clientX))}px`); }; $('resize').onpointerup = () => { $('resize').onpointermove = null; }; };
2100
2261
  $('resize').onkeydown = event => { if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) return; event.preventDefault(); const width = $('inspector').getBoundingClientRect().width + (event.key === 'ArrowLeft' ? 20 : -20); document.documentElement.style.setProperty('--panel', `${Math.max(360, Math.min(720, width))}px`); };
2101
2262
  $('export').onclick = () => { if (!state.graph) return; downloadGraph(state.graph); };
@@ -2104,7 +2265,7 @@ if (typeof document.addEventListener === 'function') {
2104
2265
  }
2105
2266
  window.addEventListener('pagehide', () => { void flushDraft(true); });
2106
2267
  window.addEventListener('beforeunload', event => { document.activeElement?.blur(); if (state.dirty) { event.preventDefault(); event.returnValue = ''; } });
2107
- window.addEventListener('keydown', event => { if(event.key==='Delete' && !document.querySelector('dialog[open]') && !event.target?.closest('input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])') && !event.isComposing) {event.preventDefault();deleteSelection();return;} if(event.key==='Escape' && state.routePick){event.preventDefault();cancelRoutePick();return;} if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') { event.preventDefault(); document.activeElement?.blur(); if (!$('save').disabled) $('save').click(); } });
2268
+ window.addEventListener('keydown', event => { if(event.key==='Delete' && !document.querySelector('dialog[open]') && !event.target?.closest('input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])') && !event.isComposing) {event.preventDefault();deleteSelection();return;} if(event.key==='Escape' && state.routePick){event.preventDefault();cancelRoutePick();return;} if(event.key==='Escape' && narrowLayout() && !$('inspector').classList.contains?.('hidden') && !document.body?.classList?.contains?.('library-overlay') && !document.querySelector('dialog[open]') && !event.target?.closest('input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), .menu-list, .select-panel')){event.preventDefault();dismissInspectorOverlay();return;} if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') { event.preventDefault(); document.activeElement?.blur(); if (!$('save').disabled) $('save').click(); } });
2108
2269
  async function refreshCloudState() {
2109
2270
  if (!token) return;
2110
2271
  const orderSavingDuringSync = state.orderSaving;
@@ -2190,4 +2351,4 @@ setFavicon('idle');
2190
2351
  if (token) watchActivity();
2191
2352
  try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { }
2192
2353
 
2193
- (async () => { renderHeading(); if (!token) { status('The sign-in token is missing. Open this app with the andorra graph command.', true); return; } try { const data = await api('/api/bootstrap'); state.plan = data.plan; state.graphs = data.graphs; applyProviderRegistry(data); state.tools = data.tools || []; state.definitions = foldDefinitionCaps(data.definitions); renderLibrary(); renderList(); const wantsNew = new URLSearchParams(location.search).get('new') === '1'; if (wantsNew && canCreateGraph()) newGraph(); else if (!wantsNew && await reopenRemembered()) { } else if (state.graphs.length) { await openGraph((freeTier() && state.plan.freeGraphId) || state.graphs[0].id); if (wantsNew) status(FREE_CREATE_TIP, true); } else { render(); status('Create your first graph'); } window.AndorraEmbed?.ready?.(); if (data.graphMigrationErrors?.length) status('Some saved graphs could not be opened: ' + data.graphMigrationErrors.map(item => item.name + ' (' + item.id + '): ' + item.error).join('; ') + '. Their saved versions are unchanged.', true); } catch (error) { status(error.message, true); } })();
2354
+ (async () => { renderHeading(); if (!token) { status('The sign-in token is missing. Open this app with the andorra graph command.', true); return; } try { const data = await api('/api/bootstrap'); state.plan = data.plan; state.graphs = data.graphs; applyProviderRegistry(data); state.tools = data.tools || []; state.definitions = foldDefinitionCaps(data.definitions); renderLibrary(); renderList(); const params = new URLSearchParams(location.search); const wantsNew = params.get('new') === '1'; const requested = (params.get('graph') || '').length >= 1 && params.get('graph').length <= 120 ? params.get('graph') : undefined; if (requested !== undefined) { params.delete('graph'); const rest = params.toString(); history.replaceState(null, '', location.pathname + (rest ? `?${rest}` : '')); } if (requested !== undefined && await openGraph(requested)) { } else if (wantsNew && canCreateGraph()) newGraph(); else if (!wantsNew && !requested && await reopenRemembered()) { } else if (state.graphs.length) { await openGraph((freeTier() && state.plan.freeGraphId) || state.graphs[0].id); if (wantsNew) status(FREE_CREATE_TIP, true); } else { render(); status('Create your first graph'); } window.AndorraEmbed?.ready?.(); if (data.graphMigrationErrors?.length) status('Some saved graphs could not be opened: ' + data.graphMigrationErrors.map(item => item.name + ' (' + item.id + '): ' + item.error).join('; ') + '. Their saved versions are unchanged.', true); } catch (error) { status(error.message, true); } })();
@@ -69,6 +69,7 @@ select:disabled { cursor: default; color: var(--text-disabled); }
69
69
  font-size: var(--type-row);
70
70
  }
71
71
  .select-option:hover, .select-option[data-active="true"] { background: var(--hover); }
72
+ .select-option:active:not([aria-disabled="true"]) { background: var(--pressed); }
72
73
  .select-option[aria-disabled="true"] { color: var(--text-disabled); cursor: default; }
73
74
  .select-option[aria-disabled="true"]:hover { background: transparent; }
74
75
  .select-option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@@ -218,7 +218,7 @@
218
218
  .then(result => { status(result.error, true); return result; });
219
219
  }
220
220
  return requestExport({ type: 'andorra.graph.export', graphId }).then(result => {
221
- if (result.ok && result.path) status(`Exported to ${result.path}`);
221
+ if (result.ok && result.path) status(`Exported to ${result.path}`, 'notice');
222
222
  else status(result.error || 'The export failed.', true);
223
223
  return result;
224
224
  });
@@ -229,7 +229,7 @@
229
229
  .then(result => { status(result.error, true); return result; });
230
230
  }
231
231
  return requestExport({ type: 'andorra.graph.agent.export', agentId }).then(result => {
232
- if (result.ok && result.path) status(`Agent shared to ${result.path}`);
232
+ if (result.ok && result.path) status(`Agent shared to ${result.path}`, 'notice');
233
233
  else status(result.error || 'The Agent could not be shared.', true);
234
234
  return result;
235
235
  });
@@ -30,6 +30,7 @@ globalThis.AndorraIcons = (() => {
30
30
  magnet: '<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>',
31
31
  more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',
32
32
  'panel-right': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/>',
33
+ 'panel-left': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>',
33
34
  flask: '<path d="M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"/><path d="M8.5 2h7"/><path d="M7 16h10"/>',
34
35
  activity: '<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>',
35
36
  copy: '<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',
@@ -60,11 +61,12 @@ globalThis.AndorraIcons = (() => {
60
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"/>',
61
62
  search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
62
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"/>',
63
65
  };
64
66
 
65
67
  const NODE_ICONS = {
66
68
  agent: 'bot', orchestrator: 'compass', join: 'merge', parallel: 'fork', condition: 'fork',
67
- loop: 'repeat', action: 'terminal', approval: 'approval', end: 'flag',
69
+ loop: 'repeat', action: 'terminal', approval: 'approval', review: 'review', end: 'flag',
68
70
  };
69
71
 
70
72
  const SVG = 'http://www.w3.org/2000/svg';