@andorra-labs/code 0.1.5 → 0.1.7

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 (224) hide show
  1. package/dist/src/account-presentation.js +3 -3
  2. package/dist/src/agent-execution.d.ts +2 -0
  3. package/dist/src/agent-execution.js +526 -41
  4. package/dist/src/agent-mcp-catalog.d.ts +21 -0
  5. package/dist/src/agent-mcp-catalog.js +40 -0
  6. package/dist/src/agent-mcp.d.ts +36 -3
  7. package/dist/src/agent-mcp.js +114 -45
  8. package/dist/src/app-server/protocol.d.ts +57 -5
  9. package/dist/src/app-server/protocol.js +18 -1
  10. package/dist/src/app-server/workspace.d.ts +9 -1
  11. package/dist/src/app-server/workspace.js +50 -3
  12. package/dist/src/app-server.d.ts +115 -41
  13. package/dist/src/app-server.js +1316 -221
  14. package/dist/src/auth/AuthManager.d.ts +33 -1
  15. package/dist/src/auth/AuthManager.js +138 -10
  16. package/dist/src/auth/callback-page.d.ts +4 -0
  17. package/dist/src/auth/callback-page.js +70 -0
  18. package/dist/src/auth/callback.d.ts +39 -0
  19. package/dist/src/auth/callback.js +146 -22
  20. package/dist/src/auth/index.d.ts +10 -6
  21. package/dist/src/auth/index.js +2 -2
  22. package/dist/src/auth/store.d.ts +142 -3
  23. package/dist/src/auth/store.js +334 -13
  24. package/dist/src/auth/types.d.ts +17 -1
  25. package/dist/src/auth-commands.d.ts +11 -2
  26. package/dist/src/auth-commands.js +14 -7
  27. package/dist/src/automation-runner.d.ts +9 -0
  28. package/dist/src/automation-runner.js +22 -1
  29. package/dist/src/automation-tool.js +18 -3
  30. package/dist/src/automations.d.ts +5 -0
  31. package/dist/src/automations.js +11 -1
  32. package/dist/src/browser-captcha-tool.d.ts +54 -0
  33. package/dist/src/browser-captcha-tool.js +374 -0
  34. package/dist/src/browser-panel-tool.d.ts +7 -0
  35. package/dist/src/browser-panel-tool.js +74 -3
  36. package/dist/src/browser-runner.js +19 -4
  37. package/dist/src/browser-server.js +21 -1
  38. package/dist/src/browser-session.d.ts +16 -0
  39. package/dist/src/browser-session.js +35 -0
  40. package/dist/src/browser-ui/app.js +193 -3
  41. package/dist/src/browser-ui/style.css +15 -1
  42. package/dist/src/browser-view.d.ts +72 -4
  43. package/dist/src/browser-view.js +229 -17
  44. package/dist/src/capabilities.d.ts +9 -3
  45. package/dist/src/capabilities.js +20 -5
  46. package/dist/src/capsolver.d.ts +60 -0
  47. package/dist/src/capsolver.js +101 -0
  48. package/dist/src/claude-provider.d.ts +6 -0
  49. package/dist/src/claude-provider.js +34 -3
  50. package/dist/src/cli-executable.d.ts +33 -0
  51. package/dist/src/cli-executable.js +64 -0
  52. package/dist/src/cli-process.d.ts +47 -0
  53. package/dist/src/cli-process.js +113 -0
  54. package/dist/src/cli-sign-in.d.ts +68 -0
  55. package/dist/src/cli-sign-in.js +224 -0
  56. package/dist/src/cli.js +84 -26
  57. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
  58. package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
  59. package/dist/src/codex-provider.js +12 -0
  60. package/dist/src/coding-tools.d.ts +5 -0
  61. package/dist/src/coding-tools.js +98 -53
  62. package/dist/src/command-output-tap.d.ts +16 -0
  63. package/dist/src/command-output-tap.js +45 -0
  64. package/dist/src/command-screens.js +3 -3
  65. package/dist/src/commands.d.ts +15 -2
  66. package/dist/src/commands.js +14 -13
  67. package/dist/src/completion.d.ts +23 -5
  68. package/dist/src/completion.js +380 -17
  69. package/dist/src/config.d.ts +61 -0
  70. package/dist/src/config.js +276 -12
  71. package/dist/src/context-budget.d.ts +7 -0
  72. package/dist/src/context-budget.js +18 -1
  73. package/dist/src/deadline.js +6 -0
  74. package/dist/src/decision/FactContinuations.d.ts +41 -6
  75. package/dist/src/decision/FactContinuations.js +211 -64
  76. package/dist/src/decision/PreparedSteps.js +3 -1
  77. package/dist/src/decision/checks.d.ts +25 -0
  78. package/dist/src/decision/checks.js +77 -6
  79. package/dist/src/delegation-changes.d.ts +109 -0
  80. package/dist/src/delegation-changes.js +431 -0
  81. package/dist/src/extensions.d.ts +1 -0
  82. package/dist/src/extensions.js +16 -3
  83. package/dist/src/graph-provider-portability.js +2 -2
  84. package/dist/src/graph-quota.d.ts +1 -1
  85. package/dist/src/graph-quota.js +1 -1
  86. package/dist/src/graph-runner.js +35 -21
  87. package/dist/src/graph-selection.d.ts +6 -0
  88. package/dist/src/graph-selection.js +10 -0
  89. package/dist/src/graph-server.d.ts +8 -0
  90. package/dist/src/graph-server.js +76 -6
  91. package/dist/src/graph-sync.d.ts +65 -0
  92. package/dist/src/graph-sync.js +433 -13
  93. package/dist/src/graph-tool.d.ts +52 -0
  94. package/dist/src/graph-tool.js +136 -0
  95. package/dist/src/graph-ui/app.js +272 -50
  96. package/dist/src/graph-ui/controls.js +6 -0
  97. package/dist/src/graph-ui/drafts.js +39 -0
  98. package/dist/src/graph-ui/embed.js +1 -1
  99. package/dist/src/graph-ui/icons.js +1 -0
  100. package/dist/src/graph-ui/index.html +2 -2
  101. package/dist/src/graph-ui/skill-picker.js +242 -0
  102. package/dist/src/graph-ui/studio.css +7 -5
  103. package/dist/src/graph-ui/style.css +65 -12
  104. package/dist/src/graphs.d.ts +60 -5
  105. package/dist/src/graphs.js +191 -37
  106. package/dist/src/grok-provider.d.ts +50 -0
  107. package/dist/src/grok-provider.js +186 -0
  108. package/dist/src/handoffs.d.ts +13 -0
  109. package/dist/src/handoffs.js +31 -1
  110. package/dist/src/hardened-runtime.d.ts +4 -4
  111. package/dist/src/hardened-runtime.js +109 -9
  112. package/dist/src/managed-sign-in.d.ts +38 -0
  113. package/dist/src/managed-sign-in.js +169 -0
  114. package/dist/src/markdown.d.ts +5 -0
  115. package/dist/src/markdown.js +5 -2
  116. package/dist/src/mcp.js +11 -0
  117. package/dist/src/membership.d.ts +8 -1
  118. package/dist/src/membership.js +15 -5
  119. package/dist/src/model-metadata.js +14 -2
  120. package/dist/src/model-override.d.ts +10 -0
  121. package/dist/src/model-override.js +20 -0
  122. package/dist/src/opencode-cli-provider.d.ts +122 -0
  123. package/dist/src/opencode-cli-provider.js +415 -0
  124. package/dist/src/opencode-provider.js +23 -8
  125. package/dist/src/palette.d.ts +2 -0
  126. package/dist/src/palette.js +2 -0
  127. package/dist/src/permissions.d.ts +19 -1
  128. package/dist/src/permissions.js +30 -1
  129. package/dist/src/powershell-pool.d.ts +11 -2
  130. package/dist/src/powershell-pool.js +34 -5
  131. package/dist/src/provider-connection.js +36 -0
  132. package/dist/src/provider-engine.d.ts +2 -1
  133. package/dist/src/provider-engine.js +64 -13
  134. package/dist/src/provider-import.js +6 -1
  135. package/dist/src/provider-keys.d.ts +48 -0
  136. package/dist/src/provider-keys.js +121 -0
  137. package/dist/src/provider-settings.js +22 -3
  138. package/dist/src/providers.d.ts +12 -1
  139. package/dist/src/providers.js +27 -8
  140. package/dist/src/pull-requests.d.ts +123 -20
  141. package/dist/src/pull-requests.js +334 -84
  142. package/dist/src/qa/qa-authorize.js +9 -1
  143. package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
  144. package/dist/src/qa/runtime/ProcessManager.js +16 -0
  145. package/dist/src/react-runtime.js +106 -7
  146. package/dist/src/read-image.d.ts +30 -0
  147. package/dist/src/read-image.js +97 -0
  148. package/dist/src/remote/engine-pool.js +1 -1
  149. package/dist/src/run-progress.js +6 -1
  150. package/dist/src/run-records.d.ts +133 -27
  151. package/dist/src/run-records.js +320 -40
  152. package/dist/src/runtime.d.ts +38 -1
  153. package/dist/src/runtime.js +27 -4
  154. package/dist/src/save-lock.d.ts +11 -0
  155. package/dist/src/save-lock.js +29 -2
  156. package/dist/src/secret-redaction.d.ts +13 -0
  157. package/dist/src/secret-redaction.js +71 -0
  158. package/dist/src/session-summary.d.ts +10 -4
  159. package/dist/src/session-summary.js +14 -7
  160. package/dist/src/sessions.js +8 -2
  161. package/dist/src/shell.js +4 -1
  162. package/dist/src/side-panel.d.ts +1 -1
  163. package/dist/src/side-panel.js +1 -1
  164. package/dist/src/skill-commands.d.ts +2 -0
  165. package/dist/src/skill-commands.js +2 -0
  166. package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
  167. package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
  168. package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
  169. package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
  170. package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
  171. package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
  172. package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
  173. package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
  174. package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
  175. package/dist/src/skills/bundled/provenance.json +50 -0
  176. package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
  177. package/dist/src/skills/invocable-skills.d.ts +41 -0
  178. package/dist/src/skills/invocable-skills.js +49 -0
  179. package/dist/src/skills/prompt-skills.d.ts +1 -0
  180. package/dist/src/skills/prompt-skills.js +33 -0
  181. package/dist/src/skills/runtime-skills.d.ts +4 -0
  182. package/dist/src/skills/runtime-skills.js +21 -0
  183. package/dist/src/structured-step.d.ts +55 -0
  184. package/dist/src/structured-step.js +85 -0
  185. package/dist/src/subagent-run.d.ts +1 -1
  186. package/dist/src/subagent-run.js +29 -33
  187. package/dist/src/telemetry/schema.d.ts +2 -2
  188. package/dist/src/telemetry/schema.js +3 -2
  189. package/dist/src/terminal-ui.d.ts +38 -0
  190. package/dist/src/terminal-ui.js +126 -28
  191. package/dist/src/timers.d.ts +21 -2
  192. package/dist/src/timers.js +12 -4
  193. package/dist/src/tool-dependencies.js +4 -0
  194. package/dist/src/tool-names.d.ts +18 -0
  195. package/dist/src/tool-names.js +26 -0
  196. package/dist/src/tools.d.ts +9 -0
  197. package/dist/src/tools.js +159 -20
  198. package/dist/src/trajectory.js +32 -12
  199. package/dist/src/transcript.js +5 -0
  200. package/dist/src/types.d.ts +36 -0
  201. package/dist/src/web-search.d.ts +59 -0
  202. package/dist/src/web-search.js +216 -0
  203. package/docs/agents/README.md +2 -2
  204. package/docs/agents/mcp-server.md +28 -3
  205. package/docs/agents/subagent-mode.md +7 -4
  206. package/docs/concepts/README.md +1 -1
  207. package/docs/concepts/security.md +4 -2
  208. package/docs/getting-started/accounts.md +15 -4
  209. package/docs/getting-started/configure-providers.md +30 -3
  210. package/docs/guides/README.md +1 -0
  211. package/docs/guides/browser.md +12 -0
  212. package/docs/guides/desktop-app.md +11 -4
  213. package/docs/guides/graph-builder.md +9 -1
  214. package/docs/guides/web-search.md +47 -0
  215. package/docs/reference/cli.md +4 -3
  216. package/docs/reference/config.md +4 -4
  217. package/docs/reference/slash-commands.md +2 -1
  218. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
  219. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
  220. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
  221. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
  222. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
  223. package/package.json +1 -1
  224. package/tests/permissions-test-plan.md +2 -1
@@ -58,26 +58,41 @@ function freeNodeRefusal(added) {
58
58
  return counted && countedNodes(state.graph) + counted > state.plan.nodeLimit ? freeNodeTip() : undefined;
59
59
  }
60
60
  async function api(path, body, options = {}) {
61
- const response = await fetch(path, { method: options.method || (body ? 'POST' : 'GET'), headers: { Authorization: `Bearer ${token || ''}`, ...(body ? { 'Content-Type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}), ...(options.signal ? { signal: options.signal } : {}) });
61
+ const response = await fetch(path, { method: options.method || (body ? 'POST' : 'GET'), headers: { Authorization: `Bearer ${token || ''}`, ...(body ? { 'Content-Type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}), ...(options.signal ? { signal: options.signal } : {}), ...(options.keepalive ? { keepalive: true } : {}) });
62
62
  const data = await response.json();
63
63
  if (!response.ok) throw new Error(typeof data.error === 'string' ? data.error : JSON.stringify(data.error || data));
64
64
  return data;
65
65
  }
66
66
  function checkpoint() { state.undo.push(copy(state.graph)); if (state.undo.length > 80) state.undo.shift(); state.redo = []; }
67
67
  function changed() { scheduleValidation(); state.dirty = true; renderCanvas(); renderHeading(); renderValidation(); status('Unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
68
- let draftTimer, pendingDraft;
69
- function flushDraft() {
68
+ let draftTimer, pendingDraft, draftWrite;
69
+ // How long editing must pause before a draft is written. Every draft is a snapshot the account
70
+ // keeps, so a pause shorter than this would store one per keystroke burst.
71
+ const DRAFT_PAUSE_MS = 2000;
72
+ function flushDraft(leaving = false) {
70
73
  clearTimeout(draftTimer);
71
74
  const graph = pendingDraft; pendingDraft = null;
72
- if (graph) return api('/api/drafts', graph).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
75
+ if (graph) return draftWrite = api('/api/drafts', graph, leaving ? { keepalive: true } : {}).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
76
+ }
77
+ // Whether the open graph holds edits a draft should keep. A graph that is still exactly what New
78
+ // or Duplicate made holds nothing to recover, so it gets no draft until an edit makes it differ.
79
+ // Without this every New graph left a draft behind, from the autosave and from the embedded
80
+ // editor's flush on leaving alike.
81
+ function hasDraftableEdits() {
82
+ if (!state.graph || !state.dirty) return false;
83
+ if (state.untouched) {
84
+ if (globalThis.AndorraDrafts && !globalThis.AndorraDrafts.worthSaving(state.graph, state.untouched)) return false;
85
+ state.untouched = null;
86
+ }
87
+ return true;
73
88
  }
74
89
  function queueDraft() {
75
- if (!state.graph || !state.dirty) return;
90
+ if (!hasDraftableEdits()) return;
76
91
  if (pendingDraft && pendingDraft.id !== state.graph.id) void flushDraft();
77
92
  pendingDraft = copy(state.graph);
78
93
  if ($('sync-status')) $('sync-status').textContent = 'Saving draft locally…';
79
94
  clearTimeout(draftTimer);
80
- draftTimer = setTimeout(flushDraft, 500);
95
+ draftTimer = setTimeout(flushDraft, DRAFT_PAUSE_MS);
81
96
  }
82
97
  async function refreshDrafts() {
83
98
  state.drafts = await api('/api/drafts'); renderList();
@@ -106,15 +121,46 @@ function restoreImportRequirements(graph) {
106
121
  }
107
122
  async function openDraft(snapshot) {
108
123
  if (state.dirty && !await askConfirm({ title: 'Open the saved draft?', message: 'Current edits are retained in draft history.', confirmLabel: 'Open draft' })) return;
109
- try { const graph = await api(`/api/drafts/${snapshot}`); const owed = restoreImportRequirements(graph); state.graph = graph; 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 node, then save.' : 'Recovered draft. Save a revision when valid, or duplicate if its base revision changed.'); }
124
+ try { const graph = foldGraphSubagentCaps(await api(`/api/drafts/${snapshot}`)); const owed = restoreImportRequirements(graph); state.graph = graph; 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 node, then save.' : 'Recovered draft. Save a revision when valid, or duplicate if its base revision changed.'); }
110
125
  catch (error) { status(error.message, true); }
111
126
  }
112
127
  function mutate(action, inspector = false) { if (!state.graph) return; checkpoint(); action(); changed(); if (inspector) renderInspector(); }
128
+ /**
129
+ * Fold an Orchestrator's legacy `maxSubagents` cap into its subagent policy, the same way
130
+ * migrateGraphToOrchestrator does in src/graphs.ts. The editor no longer shows that field: it
131
+ * duplicated "Max total per node run" and silently lowered or disabled the Subagents settings.
132
+ * The runtime still honours the field, so a saved value must not stay hidden; folding it keeps
133
+ * the run identical (the runtime uses the smaller of the two) and makes Advanced the only place
134
+ * the limits live. Zero turns subagents off; a node without a policy has nothing to cap.
135
+ */
136
+ function foldSubagentCap(node) {
137
+ if (!node || typeof node !== 'object' || node.maxSubagents === undefined) return node;
138
+ const cap = node.maxSubagents; const policy = node.subagents;
139
+ delete node.maxSubagents;
140
+ if (!policy || typeof policy !== 'object' || typeof cap !== 'number') return node;
141
+ if (cap === 0) { policy.enabled = false; return node; }
142
+ policy.maxTotal = Math.min(policy.maxTotal ?? 8, cap);
143
+ policy.maxConcurrent = Math.min(policy.maxConcurrent ?? 3, policy.maxTotal);
144
+ policy.maxDepth = Math.min(policy.maxDepth ?? 1, policy.maxConcurrent);
145
+ return node;
146
+ }
147
+ function foldDefinitionCaps(definitions) {
148
+ for (const definition of definitions || []) foldSubagentCap(definition?.node);
149
+ return definitions || [];
150
+ }
151
+ function hasSubagentCap(graph) {
152
+ return Object.values(graph?.nodes || {}).some(node => node && typeof node === 'object' && node.maxSubagents !== undefined);
153
+ }
154
+ function foldGraphSubagentCaps(graph) {
155
+ for (const node of Object.values(graph?.nodes || {})) foldSubagentCap(node);
156
+ return graph;
157
+ }
113
158
  /**
114
159
  * Drop settings the runtime no longer defines. `maxTokens` and the subagent token pair were
115
160
  * removed with the cumulative token ceiling; the server still accepts them so old graphs keep
116
161
  * loading, but hiding their controls alone would not remove them from a saved revision because
117
162
  * the editor serializes the whole graph. Removing them here makes the next save authoritative.
163
+ * An Orchestrator's hidden `maxSubagents` cap is folded into its policy for the same reason.
118
164
  * The import-requirements marker (`pendingProviderNodes`) is stripped here too: it is editor
119
165
  * state riding on draft snapshots, not graph content, so it never reaches a saved revision, an
120
166
  * export or a reopened saved graph. Only the draft round-trip keeps it (queueDraft and
@@ -128,6 +174,7 @@ function dropLegacyTokenFields(graph) {
128
174
  if (!node || typeof node !== 'object') continue;
129
175
  if (node.limits && typeof node.limits === 'object') delete node.limits.maxTokens;
130
176
  if (node.subagents && typeof node.subagents === 'object') { delete node.subagents.maxTokensPerSubagent; delete node.subagents.maxCombinedTokens; }
177
+ foldSubagentCap(node);
131
178
  }
132
179
  return graph;
133
180
  }
@@ -165,6 +212,14 @@ function applyProviderRegistry(value) {
165
212
  }
166
213
  return true;
167
214
  }
215
+ // Browser copies of isWritingRole and delegatesWriting in src/graphs.ts. The server decides which
216
+ // ports a node has and whether it delegates; these must agree with it exactly, or the canvas
217
+ // shows a port the server does not know, or hides one it offers.
218
+ function isWritingRole(role) { return role?.capabilities?.filesystem === 'read-write' || role?.capabilities?.git === 'write'; }
219
+ function delegatesWriting(node) {
220
+ return node?.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0
221
+ && (node.subagents.roles ?? []).some(isWritingRole);
222
+ }
168
223
  function outcomes(node) {
169
224
  if (node.type === 'end') return [];
170
225
  if (node.type === 'agent' && node.modifiers?.condition) return ['true', 'false'];
@@ -172,9 +227,17 @@ function outcomes(node) {
172
227
  if (node.type === 'condition') return ['true', 'false'];
173
228
  if (node.type === 'loop') return ['body', 'done'];
174
229
  if (node.type === 'approval') return ['approved', 'rejected'];
175
- return node.completion?.mode === 'outcomes' ? node.completion.outcomes : [node.completion?.outcome ?? 'completed'];
230
+ if (node.completion?.mode === 'outcomes') return node.completion.outcomes;
231
+ const outcome = node.completion?.outcome ?? 'completed';
232
+ // Mirrors nodeOutcomes: a delegating Orchestrator also ends as delivered once it has landed
233
+ // accepted changes. The server accepts delivered without an edge, so the port needs no route.
234
+ return delegatesWriting(node) ? [outcome, 'delivered'] : [outcome];
176
235
  }
177
236
  function edgeOutcome(edge) { return edge.outcome || 'completed'; }
237
+ // Drops this node's connections whose outcome it no longer has. Called inside the mutate that
238
+ // changed its outcomes, so undo restores the routes together with the setting. An edge left on a
239
+ // vanished port is refused by the server and is drawn as if it left the first port.
240
+ function pruneRoutes(node) { state.graph.edges = state.graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge))); }
178
241
  function selectedNodes() { return (state.selectedIds.length ? state.selectedIds : state.selected ? [state.selected] : []).map(id => state.graph?.nodes[id]).filter(Boolean); }
179
242
  function selectionType(node) { return `${node.type}:${node.agentRole || 'regular'}`; }
180
243
  function clearSelection() { state.selectedIds = []; state.selected = null; state.selectedEdge = null; state.routePick = null; state.bulkOutcome = null; }
@@ -279,7 +342,7 @@ function scheduleValidation() {
279
342
  }
280
343
  function renderHeading() {
281
344
  $('graph-title').textContent = state.graph?.name || 'Graph studio';
282
- $('revision').textContent = state.graph ? `${state.graph.revision ? `Revision ${state.graph.revision}` : 'New graph'}${state.dirty ? ' - Unsaved' : ''}` : '';
345
+ $('revision').textContent = state.graph ? `${state.graph.revision ? `Revision ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
283
346
  $('save').disabled = state.saving || !state.graph || !state.dirty || state.graph.id === 'default';
284
347
  $('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
285
348
  $('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
@@ -302,19 +365,49 @@ function renderList() {
302
365
  button.oncontextmenu = event => { event.preventDefault(); showGraphMenu(graph, event.clientX, event.clientY); };
303
366
  $('graphs').append(button);
304
367
  }
305
- const draftGraphs = new Set();
306
- for (const draft of (state.drafts || []).filter(draft => draft.name.toLowerCase().includes($('search').value.toLowerCase()))) {
307
- if (!state.showDraftHistory && draftGraphs.has(draft.graphId)) continue;
308
- draftGraphs.add(draft.graphId);
309
- const button = el('button', undefined, 'graph-row'); button.disabled = state.saving;
310
- button.append(el('span', draft.name), el('small', 'Draft ' + (draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)')));
311
- button.onclick = () => openDraft(draft.snapshot); $('graphs').append(button);
368
+ // Drafts sit under their own heading, below the saved graphs. By default only the ones still
369
+ // holding unsaved work are listed (the newest per graph, and not one a later revision
370
+ // overtook); the history toggle lists every snapshot.
371
+ const matching = (state.drafts || []).filter(draft => draft.name.toLowerCase().includes($('search').value.toLowerCase()));
372
+ const latest = () => { const seen = new Set(); return matching.filter(draft => !seen.has(draft.graphId) && seen.add(draft.graphId)); };
373
+ const current = globalThis.AndorraDrafts ? globalThis.AndorraDrafts.currentDrafts(matching, state.graphs) : latest();
374
+ const shown = state.showDraftHistory ? matching : current;
375
+ if (shown.length) {
376
+ const head = el('div', undefined, 'graph-drafts-head');
377
+ head.append(el('span', state.showDraftHistory ? 'Draft history' : 'Unsaved drafts'));
378
+ const clear = el('button', 'Clear', 'graph-drafts-clear'); clear.type = 'button'; clear.disabled = state.saving;
379
+ clear.title = 'Remove these drafts and their history from the list'; clear.onclick = () => clearDrafts(matching, true);
380
+ head.append(clear); $('graphs').append(head);
381
+ }
382
+ for (const draft of shown) {
383
+ const button = el('button', undefined, 'graph-row draft-row'); button.disabled = state.saving;
384
+ const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
385
+ const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
386
+ button.title = `${draft.name} — draft saved ${saved}`;
387
+ button.append(el('span', draft.name), when);
388
+ button.onclick = () => openDraft(draft.snapshot);
389
+ button.oncontextmenu = event => { event.preventDefault(); showMenuAt(event.clientX, event.clientY, `Actions for the draft of ${draft.name}`, [
390
+ { label: 'Open draft', icon: 'history', run: () => openDraft(draft.snapshot) },
391
+ { label: 'Clear draft', icon: 'trash', danger: true, run: () => clearDrafts([draft]) },
392
+ ]); };
393
+ $('graphs').append(button);
312
394
  }
313
- if (state.drafts?.length) {
314
- const history = el('button', state.showDraftHistory ? 'Show latest drafts' : `Show draft history (${state.drafts.length})`);
395
+ if (state.showDraftHistory || matching.length > current.length) {
396
+ const history = el('button', state.showDraftHistory ? 'Show latest drafts' : `Show draft history (${matching.length})`, 'graph-drafts-toggle');
397
+ history.type = 'button';
315
398
  history.onclick = () => { state.showDraftHistory = !state.showDraftHistory; renderList(); }; $('graphs').append(history);
316
399
  }
317
400
  }
401
+ // Clearing takes a graph's drafts off the list; saved graphs and their revisions are untouched.
402
+ // The open graph's edits are not lost: its next autosave is a new draft.
403
+ async function clearDrafts(drafts, all = false) {
404
+ const graphIds = [...new Set(drafts.map(draft => draft.graphId))];
405
+ if (!graphIds.length) return;
406
+ const one = graphIds.length === 1 && !all;
407
+ if (!await askConfirm({ title: one ? `Clear the draft of "${drafts[0].name}"?` : $('search').value ? 'Clear the matching drafts?' : 'Clear all drafts?', message: 'Cleared drafts leave this list, with their history. Saved graphs and their revisions are not affected.', confirmLabel: 'Clear', tone: 'danger' })) return;
408
+ try { state.drafts = await api('/api/drafts/clear', { graphIds }); if (!state.drafts.length) state.showDraftHistory = false; renderList(); status(one ? 'Draft cleared' : 'Drafts cleared'); }
409
+ catch (error) { status('Drafts not cleared: ' + error.message, true); }
410
+ }
318
411
  // Right-click actions for a saved graph row, and the Plus button's New/Import choices. The menu
319
412
  // floats at the pointer as a body-level overlay, so a list re-render cannot tear it down
320
413
  // mid-choice; a pointerdown outside it or Escape closes it.
@@ -332,6 +425,7 @@ function showMenuAt(x, y, ariaLabel, items) {
332
425
  const button = el('button', item.label, item.danger ? 'danger' : undefined);
333
426
  button.type = 'button'; button.setAttribute('role', 'menuitem');
334
427
  if (item.icon) button.setAttribute('data-icon', item.icon);
428
+ if (item.danger) button.className = 'danger';
335
429
  button.onclick = () => { closeGraphMenu(); item.run(); };
336
430
  menu.append(button); buttons.push(button);
337
431
  }
@@ -365,10 +459,14 @@ function showMenuAt(x, y, ariaLabel, items) {
365
459
  buttons[0]?.focus?.();
366
460
  }
367
461
  function showGraphMenu(graph, x, y) {
368
- showMenuAt(x, y, `${graph.name} actions`, [
462
+ const items = [
369
463
  { label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) },
370
464
  { label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
371
- ]);
465
+ ];
466
+ // The preset is bundled with the CLI: it has no storage to remove, and hiding it would only
467
+ // last until the next launch, so deletion is offered for saved graphs alone.
468
+ if (graph.id !== 'default') items.push({ label: 'Delete', icon: 'trash', danger: true, run: () => { deleteGraph(graph).catch(error => status(error.message, true)); } });
469
+ showMenuAt(x, y, `${graph.name} actions`, items);
372
470
  }
373
471
  function showNewGraphMenu(x, y) {
374
472
  showMenuAt(x, y, 'Create a graph', [
@@ -418,6 +516,46 @@ async function duplicateGraph(source) {
418
516
  await openGraph(created.id);
419
517
  if (state.graph?.id === created.id) status(`Duplicated "${source.name}" - Rename it in Graph settings.`);
420
518
  }
519
+ // Deleting removes the graph, its revisions and its draft history from this machine, and for a
520
+ // signed-in account the cloud copies stop restoring it. The confirm names that loss: there is no undo.
521
+ async function deleteGraph(graph) {
522
+ if (state.saving) { status('Wait for the current save before deleting a graph.'); return; }
523
+ if (!confirm(`Delete "${graph.name}"? Its revisions and drafts are removed from this machine.`)) return;
524
+ state.saving = true; renderHeading(); renderList();
525
+ // The confirm accepted the loss of unsaved edits of the deleted graph, so no draft of it may
526
+ // outlive it: stop its queued write, and let an in-flight one land before the deletion's
527
+ // cleanup rather than racing the removal it must not survive. A queued draft of the open
528
+ // graph is not part of this deletion: flush it before the request, so the autosave of the
529
+ // graph the user kept is neither discarded nor left writing during the rail refresh.
530
+ if (!pendingDraft || pendingDraft.id === graph.id) { pendingDraft = null; clearTimeout(draftTimer); }
531
+ else void flushDraft();
532
+ await draftWrite?.catch(() => {});
533
+ let deleted = false;
534
+ try {
535
+ await api(`/api/graphs/${encodeURIComponent(graph.id)}`, undefined, { method: 'DELETE' });
536
+ deleted = true;
537
+ state.graphs = state.graphs.filter(item => item.id !== graph.id);
538
+ // The free allowance pinned this graph: a stale kept id would mark a replacement read-only
539
+ // through issues(), so the plan's pointer steps aside the way a reload would recompute it.
540
+ if (state.plan?.freeGraphId === graph.id) delete state.plan.freeGraphId;
541
+ await refreshDrafts().catch(() => {});
542
+ } catch (error) {
543
+ status(error.message, true);
544
+ // The deletion cancelled the open graph's queued autosave. When the same graph survives the
545
+ // failed request and nothing re-queued a draft while it ran, queue one again: otherwise the
546
+ // edits the confirm was about to discard stay out of draft history until the next edit.
547
+ if (state.graph?.id === graph.id && state.dirty && !pendingDraft) queueDraft();
548
+ }
549
+ state.saving = false; renderHeading(); renderList();
550
+ if (!deleted) return;
551
+ if (state.graph?.id === graph.id) {
552
+ // The open graph is gone: a later save would recreate it, so fall back to the preset. The
553
+ // delete already confirmed the loss of unsaved edits, so skip the second confirmation.
554
+ state.dirty = false; pendingDraft = null; clearTimeout(draftTimer);
555
+ await openGraph('default');
556
+ }
557
+ if (state.graph?.id !== graph.id) status(`Deleted "${graph.name}".`);
558
+ }
421
559
  function position(node, index) { return node.position || { x: index * 290, y: 0 }; }
422
560
  function transform() { $('scene').style.transform = `translate(${state.x}px,${state.y}px) scale(${state.zoom})`; $('zoom').textContent = `${Math.round(state.zoom * 100)}%`; window.AndorraStudio?.viewport?.(); }
423
561
  // The canvas tips show until the reader dismisses them once. The choice is a per-browser
@@ -453,7 +591,7 @@ function nodeSubtitle(node) {
453
591
  const nodeIconElement = node => globalThis.AndorraIcons?.icon?.(globalThis.AndorraIcons.nodeIcon(node));
454
592
  function renderCanvas() {
455
593
  $('nodes').replaceChildren(); $('edges').replaceChildren(); $('canvas').classList.toggle('picking-destination',!!state.routePick);
456
- const hintText = state.routePick ? 'Click a destination node - Escape cancels' : 'Ctrl/Cmd-click same-type nodes to select together - Drag to pan - Scroll to zoom';
594
+ const hintText = state.routePick ? 'Click a destination node · Escape cancels' : 'Ctrl/Cmd-click same-type nodes to select together · Drag to pan · Scroll to zoom';
457
595
  $('canvas-hint-text').textContent = hintText; $('canvas-hint').hidden = !state.routePick && canvasHintDismissed(); $('canvas-hint-close').hidden = !!state.routePick;
458
596
  $('empty').hidden = !!state.graph;
459
597
  if (!state.graph) return;
@@ -612,7 +750,7 @@ function nodeErrorIds() {
612
750
  }
613
751
  function renderValidation() {
614
752
  const container=$('validation');if(!container)return;container.replaceChildren();const errors=[...issues(),...state.validationErrors].map(errorEntry);
615
- if(!errors.length)container.append(el('p',state.validated?'Validated - Ready to save':'Checking graph...','valid'));
753
+ if(!errors.length)container.append(el('p',state.validated?'Validated · Ready to save':'Checking graph…',state.validated?'valid ok':'valid'));
616
754
  else {const list=el('ul',undefined,'validation');errors.forEach(({message,nodeId})=>{ const row=el('li',message); row.tabIndex=0; row.title='Click to focus the affected node'; row.onclick=()=>{if(nodeId){clearSelection();state.selected=nodeId;state.selectedIds=[nodeId];renderCanvas();renderInspector();}};row.onkeydown=e=>{if(e.key==='Enter'||e.key===' ')row.click();};list.append(row);});container.append(list);}
617
755
  }
618
756
  function disclosure(parent, title, open = false) { const item = el('details', undefined, 'section disclosure'); const key = `${state.selectedEdge?.id || state.selected || 'graph'}:${title}`; item.open = state.disclosures[key] ?? open; item.ontoggle = () => {state.disclosures[key] = item.open;}; item.append(el('summary', title)); const body = el('div'); item.append(body); parent.append(item); return body; }
@@ -700,9 +838,16 @@ function promptField(parent, label, value, onChange, options = {}) {
700
838
  expand.onclick = event => { event?.preventDefault?.(); event?.stopPropagation?.(); setFullscreen(!isFullscreen()); };
701
839
  input.addEventListener?.('keydown', event => { if (event.key === 'Escape' && isFullscreen()) { event.preventDefault(); setFullscreen(false); } });
702
840
  setFullscreen(false); wrapper.append(expand);
841
+ skillPrompt(input);
703
842
  setTimeout(grow, 0);
704
843
  return input;
705
844
  }
845
+ // Typing `/` in a prompt opens this machine's skills (skill-picker.js); a `/name` none of them
846
+ // answers to is a warning under the field, never a validation error.
847
+ function skillPrompt(input) {
848
+ globalThis.AndorraSkillPicker?.attach?.(input, { load: () => api('/api/skills') });
849
+ return input;
850
+ }
706
851
  // A provider the graph names but this machine does not configure is a warning, not a model name.
707
852
  function providerWarning(parent, providerId) {
708
853
  const chip = el('p', undefined, 'chip chip-warning provider-warning'); chip.setAttribute('role', 'status');
@@ -729,10 +874,38 @@ function capabilities(parent, policy, update, ceiling) {
729
874
  }
730
875
  let modelSuggestionSeq = 0;
731
876
  function modelFields(parent, target, update, parentModel, inheritedProvider, fallbackProvider) {
732
- const providers = state.providers.map(p => ({value: idFor(p), label: `${titleFor(p)}${p.model ? ' - ' + p.model : ''}`}));
877
+ // The provider dropdown lists every configured provider by name; the Model dropdown under it
878
+ // lists every model the chosen provider serves. Labelling each provider with its one active
879
+ // model made the provider list read as the whole model list.
880
+ const providers = state.providers.map(p => ({value: idFor(p), label: titleFor(p)}));
733
881
  if (target.provider && !providers.some(p => p.value === target.provider)) providers.push({value: target.provider, label: target.provider + ' (unavailable)'});
734
- choice(parent, 'Model profile / provider', target.provider || '', [{value:'', label:'Use configured default'}, ...providers], value => update({ ...target, provider: value || undefined, model: undefined }));
882
+ const defaultProviderLabel = inheritedProvider ? `Same as parent node (${inheritedProvider})` : state.defaultProvider ? `Use configured default (${state.defaultProvider})` : 'Use configured default';
883
+ choice(parent, 'Provider', target.provider || '', [{value:'', label: defaultProviderLabel}, ...providers], value => update({ ...target, provider: value || undefined, model: undefined }));
735
884
  if (target.provider && !state.providers.some(p => idFor(p) === target.provider)) providerWarning(parent, target.provider);
885
+ // A providerless subagent child inherits the parent node's provider at execution
886
+ // (bindPortableGraphProviders adds its model to the parent's requirements), so the suggestions
887
+ // shown here and the recording that makes a discovered pick runnable must resolve against that
888
+ // inherited provider, not the machine default, or the selection lands on the wrong provider.
889
+ const listingProvider = target.provider || inheritedProvider || state.defaultProvider || '';
890
+ const provider = state.providers.find(p => idFor(p) === listingProvider);
891
+ const activeName = provider?.model?.trim() || '';
892
+ // Every model the resolved provider serves: its configured models first, then whatever its
893
+ // endpoint lists once discovery answers (filled in by addModelOption below). Picking one commits
894
+ // through the custom-name field so a discovered pick is recorded exactly as a typed one is.
895
+ const picker = field(parent, 'Model', '', () => {}, { options: [] });
896
+ const pickerModels = [];
897
+ const inheritedModel = parentModel?.trim() || activeName;
898
+ const renderPicker = () => {
899
+ picker.replaceChildren();
900
+ const rows = [{ value: '', label: inheritedModel ? `${parentModel ? 'Same as parent' : 'Provider default'} (${inheritedModel})` : 'Provider default' },
901
+ ...pickerModels.map(name => ({ value: name, label: name === activeName ? `${name} (active)` : name }))];
902
+ for (const row of rows) { const option = el('option', row.label); option.value = row.value; picker.append(option); }
903
+ picker.value = target.model?.trim() || '';
904
+ // Discovery can answer while the list is open; the branded panel copies the options when it
905
+ // opens, so redraw it or the newly served models stay out of reach until it is reopened.
906
+ window.AndorraControls?.refreshSelect?.(picker);
907
+ };
908
+ renderPicker();
736
909
  // Surface portability without rewriting the synced revision or local credentials. The alias must
737
910
  // satisfy every reference to the original provider graph-wide (bindPortableGraphProviders groups
738
911
  // them), so the hint mirrors that grouping instead of promising an alias execution would refuse.
@@ -799,12 +972,6 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
799
972
  parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
800
973
  }
801
974
  }
802
- // A providerless subagent child inherits the parent node's provider at execution
803
- // (bindPortableGraphProviders adds its model to the parent's requirements), so the suggestions
804
- // shown here and the recording that makes a discovered pick runnable must resolve against that
805
- // inherited provider, not the machine default, or the selection lands on the wrong provider.
806
- const listingProvider = target.provider || inheritedProvider || state.defaultProvider || '';
807
- const provider = state.providers.find(p => idFor(p) === listingProvider);
808
975
  const info = el('p', 'Context window: detecting from model...', 'help model-context'); parent.append(info);
809
976
  const key = JSON.stringify([target.provider || '', target.model || '', provider?.model || '']);
810
977
  // Capture the registry generation before any discovery request starts: a callback resolving
@@ -816,8 +983,8 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
816
983
  if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
817
984
  info.textContent = data.contextWindow ? `Context window: ${data.contextWindow.toLocaleString()} tokens (automatic)` : 'Context window: not reported by this model. Runtime uses its default budget.';
818
985
  });
819
- const override = disclosure(parent, 'Model override');
820
- const model = field(override, 'Model override (optional)', target.model, value => update({...target, model: value.trim() || undefined}), {maxLength:500,refresh:true}); model.placeholder = provider?.model || 'Configured profile model';
986
+ const override = disclosure(parent, 'Custom model name');
987
+ const model = field(override, 'Custom model name (optional)', target.model, value => update({...target, model: value.trim() || undefined}), {maxLength:500,refresh:true}); model.placeholder = provider?.model || 'Configured profile model';
821
988
  // The override stays free-text so a graph can name a model this machine has never seen, but the
822
989
  // provider's catalog is offered alongside it: the configured models first, then everything the
823
990
  // endpoint itself lists, so a provider that serves several models is selectable here rather than
@@ -836,21 +1003,27 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
836
1003
  if (!value || displayed.has(value)) return;
837
1004
  displayed.add(value);
838
1005
  const option = el('option'); option.value = value; if (label) option.label = label; datalist.append(option);
1006
+ // The picker is rebuilt once per batch by the caller: rebuilding per model is quadratic for a
1007
+ // large catalog, and an open panel would be redrawn and re-measured for every entry.
1008
+ pickerModels.push(value);
1009
+ return true;
839
1010
  };
840
- const activeName = provider?.model?.trim() || '';
841
1011
  for (const name of [activeName, ...(provider?.models || [])]) addModelOption(name, name?.trim() === activeName && name ? '(active)' : undefined);
842
1012
  if (target.model) addModelOption(target.model, target.model.trim() === activeName ? '(active)' : undefined);
1013
+ renderPicker();
843
1014
  // Keyed by the resolved provider: a node using the configured default must follow that default's
844
1015
  // identity, not share a blank key that survives a default switch.
845
1016
  state.providerModelRequests ||= new Map();
846
1017
  if (!state.providerModelRequests.has(listingProvider)) state.providerModelRequests.set(listingProvider, api(`/api/provider-models?provider=${encodeURIComponent(listingProvider)}`).catch(() => ({ models: [] })));
847
1018
  state.providerModelRequests.get(listingProvider).then(data => {
848
1019
  if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
1020
+ let added = false;
849
1021
  for (const name of data.models || []) {
850
1022
  const value = name?.trim();
851
1023
  if (value) offered.add(value);
852
- addModelOption(name, name === activeName ? '(active)' : undefined);
1024
+ if (addModelOption(name, name === activeName ? '(active)' : undefined)) added = true;
853
1025
  }
1026
+ if (added) renderPicker();
854
1027
  });
855
1028
  // Committing one of the discovered suggestions records it with the provider, the way /model does:
856
1029
  // execution validates a node's explicit model against the provider's configured models, so an
@@ -929,6 +1102,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
929
1102
  const initialWarning = state.providerModelWarnings?.get(warningKey(target.model?.trim() || ''));
930
1103
  if (initialWarning) override.append(el('p', initialWarning, 'help'));
931
1104
  }
1105
+ picker.onchange = () => { model.value = picker.value; model.onchange(); };
932
1106
  model.onchange = () => {
933
1107
  committed?.();
934
1108
  // Recording eligibility keys on whether the model still needs recording, not on whether the
@@ -954,6 +1128,9 @@ function renderCompletion(parent, node) {
954
1128
  graph.edges = graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge)));
955
1129
  });
956
1130
  explain(behavior, 'Outcome names are short phrases such as DONE, PASS, FAILED TESTING or BLOCKED. Describe when the agent should choose each one; for a single outcome, describe when the work is considered achieved, for example "This is considered DONE when xyz is finished". The agent evaluates these written criteria using its evidence; they are not automatic checks. Connect outcomes to destinations under Connections.');
1131
+ // The server refuses written criteria on a delegating Orchestrator, so the option is withheld
1132
+ // rather than offered and then rejected on save.
1133
+ if (delegatesWriting(node) && node.completion?.mode !== 'outcomes') { for (const option of behavior.options) option.disabled = option.value === 'outcomes'; parent.append(el('p', 'An Orchestrator with a writing role keeps a single outcome: it completes with a handoff, or delivers landed changes through its delivered port.', 'help')); }
957
1134
  if (node.completion?.mode === 'outcomes') {
958
1135
  parent.append(el('p', 'Criteria are optional; blank rows use the agent prompt. Removing or renaming an outcome removes its old routes. Undo restores routes and criteria.', 'help'));
959
1136
  if (node.modifiers?.condition || node.modifiers?.loop?.until.outcome !== undefined) parent.append(el('p', 'Modifiers control the final connections: a Condition routes to true/false; an outcome Loop exposes its exit outcome.', 'help'));
@@ -1068,7 +1245,32 @@ function displayToolName(name) { return TOOL_ALIASES[name] || name; }
1068
1245
  // Permission comparison spelling: folds the whole shell family onto one token so the server's
1069
1246
  // platform-dependent resolution of 'shell' cannot change which tools the editor offers.
1070
1247
  function canonicalToolName(name) { const d = displayToolName(name); return SHELL_TOOLS.includes(d) ? 'shell' : d; }
1248
+ // Browser copy of permitsBuiltInTool in src/graphs.ts for a delegated worktree child, the one
1249
+ // kind of subagent that runs commands. The server validates a writing role's tools with that rule,
1250
+ // so a tool offered here that it refuses could be ticked and then fail validation.
1251
+ const QA_TOOL_NAMES = ['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser'];
1252
+ function delegatedRolePermits(caps, name) {
1253
+ const display = displayToolName(name);
1254
+ const commands = caps.shell === 'allowed' && caps.filesystem === 'read-write' && caps.git === 'write';
1255
+ if (name === 'qa.browser_session' || name === 'browser.solve_captcha' || name === 'web_search') return caps.browser === 'playwright';
1256
+ if (['Read', 'Glob', 'Grep', 'repo_explore', 'read_skill_resource'].includes(display)) return caps.filesystem !== 'none';
1257
+ if (['Write', 'Edit'].includes(display)) return caps.filesystem === 'read-write';
1258
+ if ([...SHELL_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast'].includes(display) || QA_TOOL_NAMES.includes(name)) return commands;
1259
+ if (name === 'ShellMetrics') return caps.filesystem !== 'none';
1260
+ if (name === 'git_read') return caps.git !== 'none';
1261
+ return name === 'read_artifact' || name === 'write_artifact';
1262
+ }
1071
1263
  function roleToolOptions(node, role, policy) {
1264
+ // A writing role of an Orchestrator is a delegated one. The runtime builds its tools from the
1265
+ // node's capabilities, for a child that works in its own worktree with a shell, and ignores both
1266
+ // the node's tool list (the Orchestrator's read-only intake kit) and the tool-inheritance
1267
+ // setting. So do the tools offered here; a role with no list of its own gets all of them.
1268
+ if (delegatesWriting(node) && isWritingRole(role)) {
1269
+ const ceiling = effectiveCaps(node), own = role.capabilities || ceiling;
1270
+ const available = state.tools.map(t => displayToolName(typeof t === 'string' ? t : t.name || t.id)).filter((name, index, array) => array.indexOf(name) === index)
1271
+ .filter(name => delegatedRolePermits(ceiling, name) && delegatedRolePermits(own, name));
1272
+ return {available, selected: role.tools?.map(displayToolName) ?? available, delegated: true};
1273
+ }
1072
1274
  const parent = effectiveCaps(node);
1073
1275
  const child = role.capabilities || {...parent,...((policy.workspace || 'shared-read-only') === 'shared-read-only' ? {filesystem:parent.filesystem === 'none' ? 'none' : 'read',git:parent.git === 'none' ? 'none' : 'read',shell:'disabled'} : {})};
1074
1276
  const canonical = canonicalToolName;
@@ -1080,15 +1282,24 @@ function roleToolOptions(node, role, policy) {
1080
1282
  }
1081
1283
  function renderSubagents(parent, node) {
1082
1284
  const policy = node.subagents || {enabled:false}; const set = patch => {Object.assign(policy,patch);node.subagents=policy;};
1083
- explain(check(parent,'Allow subagents',policy.enabled,value=>set({enabled:value})),'Internal delegation returns observations to this Agent. Only this parent chooses its graph outcome. Active children finish or cancel before the parent can complete. Subagents never receive the unsandboxed host shell, including in worktrees. Read-only roles use filesystem tools and supported Git read operations.');
1285
+ // The server rule that adds the delivered port (delegatesWriting) also decides this text: once
1286
+ // a role on an Orchestrator may write, its children run commands in their own worktrees.
1287
+ const delegating = delegatesWriting(node);
1288
+ explain(check(parent,'Allow subagents',policy.enabled,value=>{set({enabled:value});pruneRoutes(node);}), delegating
1289
+ ? 'Writing roles of an Orchestrator run in their own Git worktree with a shell. The shell is not sandboxed and follows your permission mode. The Orchestrator reviews each change and lands the ones it accepts into your working folder; it never writes code itself.'
1290
+ : 'Internal delegation returns observations to this Agent. Only this parent chooses its graph outcome. Active children finish or cancel before the parent can complete. Subagents of ordinary agents never receive the unsandboxed host shell. Read-only roles use filesystem tools and supported Git read operations.');
1084
1291
  if (!policy.enabled) return;
1292
+ // The server refuses writing roles on an Orchestrator outside separate worktrees, so the
1293
+ // editor moves the policy there as soon as a role may write.
1294
+ const requireWorktree = () => { if (node.agentRole === 'orchestrator' && (policy.roles || []).some(isWritingRole)) set({workspace:'worktree'}); };
1085
1295
  for (const [key,label,fallback] of [['maxConcurrent','Max concurrent',3],['maxTotal','Max total per node run',8],['maxDepth','Max nesting depth',1]]) field(parent,label,policy[key]??fallback,value=>set({[key]:value}),{type:'number',min:1,max:key==='maxDepth'?3:key==='maxConcurrent'?16:1000});
1086
1296
  choice(parent,'Model policy',policy.modelPolicy||'inherit',[{value:'inherit',label:'Inherit parent model'},{value:'specific',label:'Use specific model'},{value:'per-role',label:'Per-role model'}],value=>set({modelPolicy:value}));
1087
1297
  // Mirrors bindPortableGraphProviders: enabled retry attempts may spawn providerless children on
1088
1298
  // the fallback provider, so a discovered child pick must be recorded there as well.
1089
1299
  const childFallbackProvider = node.retry?.fallback && node.retry.maxAttempts > 1 ? node.retry.fallback.provider : '';
1090
1300
  if(policy.modelPolicy==='specific') modelFields(parent,policy,value=>set({provider:value.provider,model:value.model}),undefined,node.provider,childFallbackProvider);
1091
- choice(parent,'Workspace policy',policy.workspace||'shared-read-only',[{value:'shared-read-only',label:'Shared workspace, read only'},{value:'shared-write',label:'Shared workspace, write allowed'},{value:'worktree',label:'Separate Git worktree'}],value=>set({workspace:value}));
1301
+ const workspace = choice(parent,'Workspace policy',policy.workspace||'shared-read-only',[{value:'shared-read-only',label:'Shared workspace, read only'},{value:'shared-write',label:'Shared workspace, write allowed'},{value:'worktree',label:'Separate Git worktree'}],value=>set({workspace:value}));
1302
+ if (delegating) { for (const option of workspace.options) option.disabled = option.value !== 'worktree'; explain(workspace, 'A writing role on an Orchestrator requires separate worktrees: each child edits its own copy, and the Orchestrator lands accepted changes into your working folder.'); }
1092
1303
  choice(parent,'Tool inheritance',policy.toolInheritance||'restricted',[{value:'restricted',label:'Restricted subset'},{value:'inherit',label:'Inherit parent allowlist'}],value=>set({toolInheritance:value}));
1093
1304
  choice(parent,'Context',policy.context||'selected',[{value:'selected',label:'Selected context only'},{value:'task-only',label:'Task only'}],value=>set({context:value}));
1094
1305
  // The runtime no longer invents a child deadline, so this field must not display one: blank
@@ -1100,17 +1311,22 @@ function renderSubagents(parent, node) {
1100
1311
  for(const role of policy.roles||[]) {
1101
1312
  const body=disclosure(roles,role.name||'New role',true);
1102
1313
  field(body,'Role ID',role.id,value=>{role.id=value;}); field(body,'Name',role.name,value=>{role.name=value;});field(body,'Instruction',role.instruction,value=>{role.instruction=value;},{multiline:true,maxLength:100000});
1103
- if(policy.modelPolicy==='per-role')modelFields(body,role,value=>{role.provider=value.provider;role.model=value.model;},role.provider===node.provider?node.model:undefined,node.provider,childFallbackProvider);
1104
- capabilities(disclosure(body,'Role capabilities'),role.capabilities||effectiveCaps(node),value=>{role.capabilities=value;},effectiveCaps(node));
1314
+ if(policy.modelPolicy==='per-role')modelFields(body,role,value=>{role.provider=value.provider;role.model=value.model;},// A per-role child with no provider of its own runs on the parent's provider and inherits the
1315
+ // parent's model there (agent-execution resolves `role.model ?? model`), so its default row must
1316
+ // name that model, not the provider's active one.
1317
+ // Both sides are compared as execution resolves them: an unset parent provider is the machine
1318
+ // default, so a role naming that default explicitly still inherits the parent's model.
1319
+ (role.provider||node.provider||state.defaultProvider)===(node.provider||state.defaultProvider)?node.model:undefined,node.provider,childFallbackProvider);
1320
+ capabilities(disclosure(body,'Role capabilities'),role.capabilities||effectiveCaps(node),value=>{role.capabilities=value;requireWorktree();pruneRoutes(node);},effectiveCaps(node));
1105
1321
  const allowedTools=disclosure(body,'Role tools'); const toolOptions=roleToolOptions(node,role,policy);
1106
1322
  for(const name of new Set([...toolOptions.available,...toolOptions.selected])) {
1107
1323
  const available=toolOptions.available.includes(name);
1108
- check(allowedTools,available?name:`${name} (unavailable — remove to repair)`,toolOptions.selected.includes(name),enabled=>{role.tools=enabled?[...new Set([...toolOptions.selected,name])]:toolOptions.selected.filter(t=>t!==name);policy.toolInheritance='restricted';});
1324
+ check(allowedTools,available?name:`${name} (unavailable — remove to repair)`,toolOptions.selected.includes(name),enabled=>{role.tools=enabled?[...new Set([...toolOptions.selected,name])]:toolOptions.selected.filter(t=>t!==name);if(!toolOptions.delegated)policy.toolInheritance='restricted';});
1109
1325
  }
1110
1326
  const contracts=disclosure(body,'Role contracts');jsonField(contracts,'Input schema',role.inputSchema,value=>{role.inputSchema=value;});jsonField(contracts,'Output schema',role.outputSchema,value=>{role.outputSchema=value;});
1111
- const remove=el('button','Remove role');remove.onclick=()=>mutate(()=>{set({roles:policy.roles.filter(r=>r!==role)});},true);body.append(remove);
1327
+ const remove=el('button','Remove role');remove.onclick=()=>mutate(()=>{set({roles:policy.roles.filter(r=>r!==role)});pruneRoutes(node);},true);body.append(remove);
1112
1328
  }
1113
- const add=el('button','Add role');add.onclick=()=>mutate(()=>{set({roles:[...(policy.roles||[]),{id:`role-${crypto.randomUUID().slice(0,8)}`,name:'Repository Researcher',instruction:'Research the bounded task and return findings.',capabilities:{...effectiveCaps(node),filesystem:effectiveCaps(node).filesystem==='none'?'none':'read',shell:effectiveCaps(node).shell==='disabled'?'disabled':'read-only',git:effectiveCaps(node).git==='none'?'none':'read'}}]});},true);roles.append(add);
1329
+ const add=el('button','Add role');add.onclick=()=>mutate(()=>{set({roles:[...(policy.roles||[]),{id:`role-${crypto.randomUUID().slice(0,8)}`,name:'Repository Researcher',instruction:'Research the bounded task and return findings.',capabilities:{...effectiveCaps(node),filesystem:effectiveCaps(node).filesystem==='none'?'none':'read',shell:effectiveCaps(node).shell==='disabled'?'disabled':'read-only',git:effectiveCaps(node).git==='none'?'none':'read'}}]});requireWorktree();},true);roles.append(add);
1114
1330
  }
1115
1331
  function renderControlInspector(parent,node) {
1116
1332
  if(node.type==='join')choice(parent,'Wait for branches',node.join?.mode||'all',['all','any'],value=>{node.join={mode:value};});
@@ -1203,13 +1419,14 @@ function renderInspector() {
1203
1419
  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; }
1204
1420
  if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
1205
1421
  const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Node settings' : 'Graph settings';
1422
+ $('graph-settings').hidden = !node && !state.selectedEdge && selectedNodes().length <= 1;
1206
1423
  retryLimitHelp(parent, graph);
1207
1424
  if (state.selectedEdge) renderEdgeInspector(parent, state.selectedEdge);
1208
1425
  else if (selectedNodes().length > 1) renderBulkInspector(parent,selectedNodes());
1209
1426
  else if (!node) {
1210
1427
  const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
1211
1428
  field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
1212
- general.append(el('p', `${graph.id} - Revision ${graph.revision}`, 'mono'));
1429
+ const meta = el('p', `${graph.id} · Revision ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
1213
1430
  if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
1214
1431
  const start = field(general,'Starting node',graph.nodes[graph.entry]?.name || '',()=>{}); start.disabled=true; explain(start,'The Orchestrator is optional. Deleting the starting node promotes its first remaining connected successor, or the first remaining node if none is connected.');
1215
1432
  field(general, 'Description', graph.metadata?.description, value => {graph.metadata={...graph.metadata,description:value};}, {multiline:true,maxLength:2000});
@@ -1238,9 +1455,9 @@ function renderInspector() {
1238
1455
  const panels = inspectorTabs(parent, node.type === 'agent' ? ['general', 'model', 'behavior', 'advanced'] : outcomes(node).length ? ['general', 'behavior', 'advanced'] : ['general', 'advanced']);
1239
1456
  const general = panels.general; field(general, 'Name', node.name, value => {node.name=value;}, {maxLength:200});
1240
1457
  if (node.type === 'agent') {
1241
- if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator - optional starting Agent for research, clarification and handoff. Remove it to start directly at the next node.','help'));explain(field(general,'Max subagents',node.maxSubagents,value=>{if(value===undefined)delete node.maxSubagents;else node.maxSubagents=value;},{type:'number',optional:true,min:0,max:100}),'Optional ceiling, not a target. Leave blank to use the configured subagent policy default. Zero disables internal subagents; this does not control top-level graph concurrency.');}
1242
- const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;});
1243
- explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this node\'s instructions; project guidance, advanced system instructions and runtime permissions still apply.');
1458
+ if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator - optional starting Agent for research, clarification and handoff. Remove it to start directly at the next node.','help'));}
1459
+ const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;}, { placeholder: 'Type / to add a skill' });
1460
+ explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this node\'s instructions; project guidance, advanced system instructions and runtime permissions still apply. Type / to add a skill: the node loads every /skill its prompt names when it runs. A skill this machine does not have is flagged here and skipped at run time; it never stops the graph.');
1244
1461
  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.');
1245
1462
  const model = panels.model;
1246
1463
  modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
@@ -1266,7 +1483,7 @@ function renderInspector() {
1266
1483
  // Tool calls default to blank, and blank means unlimited: an absent limit is only
1267
1484
  // written when the field is cleared, so a node keeps its ceiling once one is set.
1268
1485
  field(limits,'Tool calls (blank = unlimited)',node.limits?.maxToolCalls,value=>{node.limits={...node.limits,maxToolCalls:value}; if(value===undefined)delete node.limits.maxToolCalls;},{type:'number',min:0,optional:true,placeholder:'Unlimited'});
1269
- field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000}); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retry attempts',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};});
1486
+ skillPrompt(field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000})); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retry attempts',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};});
1270
1487
  field(advanced,'Executor','react-basic',()=>{}).disabled=true;
1271
1488
  const tools = disclosure(advanced,'Tool allowlist');
1272
1489
  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);});
@@ -1283,7 +1500,7 @@ function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas
1283
1500
  async function openGraph(id) {
1284
1501
  if (state.saving) { status('Wait for the current save before opening another graph.'); return; }
1285
1502
  if (state.dirty && !await askConfirm(DISCARD_QUESTION)) return;
1286
- try { state.graph = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(id)}`)); state.dirty = state.graph.editorMigration === true; delete state.graph.editorMigration; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(state.dirty ? 'Legacy graph upgraded in editor - Save to persist a new revision' : 'Graph loaded'); } catch (error) { status(error.message, true); }
1503
+ try { const opened = await api(`/api/graphs/${encodeURIComponent(id)}`); const capMoved = hasSubagentCap(opened); state.graph = dropLegacyTokenFields(opened); const migrated = state.graph.editorMigration === true; state.dirty = migrated || capMoved; delete state.graph.editorMigration; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(migrated ? 'Legacy graph upgraded in editor - Save to persist a new revision' : capMoved ? 'Orchestrator Max subagents moved to Advanced > Subagents - Save to persist a new revision' : 'Graph loaded'); } catch (error) { status(error.message, true); }
1287
1504
  }
1288
1505
  function newId() { return `graph-${crypto.randomUUID()}`; }
1289
1506
  function newGraph(duplicate = false, discarded = false) {
@@ -1311,6 +1528,7 @@ function newGraph(duplicate = false, discarded = false) {
1311
1528
  // A duplicate copies the open graph, providerless nodes included, so its unmet provider
1312
1529
  // requirements travel with it; an unrelated new graph starts without any.
1313
1530
  state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
1531
+ state.untouched = JSON.stringify(state.graph);
1314
1532
  state.pendingProviderNodes = duplicate ? new Set(state.pendingProviderNodes ?? []) : null;
1315
1533
  render(); fit(); status('New graph - Customize your agent and save your first revision');
1316
1534
  }
@@ -1453,12 +1671,13 @@ function copyAgent(definition) {
1453
1671
  function addAgent() {
1454
1672
  const name = el('input'); name.required = true; name.maxLength = 200;
1455
1673
  const description = el('input'); description.maxLength = 2000;
1456
- const instruction = el('textarea'); instruction.maxLength = 100000; instruction.rows = 5;
1674
+ const instruction = el('textarea'); instruction.maxLength = 100000; instruction.rows = 5; instruction.placeholder = 'Type / to add a skill';
1457
1675
  const id = `definition-${crypto.randomUUID()}`;
1458
1676
  libraryDialog('Add agent', [['Agent name', name], ['Description', description], ['Instructions', instruction]], async () => {
1459
1677
  const agentName = requireAgentName(name);
1460
1678
  await writeDefinition({schemaVersion:2, id, name:agentName, description:description.value.trim(), revision:0, node:{id:'agent', type:'agent', name:agentName, ...blankAgentSettings(), instruction:instruction.value.trim()}}, `Agent ${agentName} added`);
1461
1679
  }, 'Add agent');
1680
+ skillPrompt(instruction);
1462
1681
  }
1463
1682
  // The server's 512 KiB limit applies to the import request, not the file: Share pretty-prints its
1464
1683
  // file, so a file over that limit can still make a request under it. The request is measured
@@ -1528,7 +1747,7 @@ function showAgentMenu(definition, use, x, y) {
1528
1747
  ]);
1529
1748
  }
1530
1749
  async function readDefinitions() {
1531
- const data = await api('/api/bootstrap'); state.definitions = data.definitions || []; return state.definitions;
1750
+ const data = await api('/api/bootstrap'); state.definitions = foldDefinitionCaps(data.definitions); return state.definitions;
1532
1751
  }
1533
1752
  // The id is fixed for the dialog's lifetime and a committed write is confirmed from the store
1534
1753
  // before any failure is reported: a dropped response or a failed refresh must not turn the
@@ -1694,6 +1913,9 @@ $('export').onclick = () => { if (!state.graph) return; downloadGraph(state.grap
1694
1913
  if (typeof document.addEventListener === 'function') {
1695
1914
  document.addEventListener('andorra:themechange', () => { if (state.graph) renderCanvas(); });
1696
1915
  }
1916
+ // A draft still waiting out its pause is written as the page goes, so closing the tab right after
1917
+ // an edit does not lose it.
1918
+ window.addEventListener('pagehide', () => { void flushDraft(true); });
1697
1919
  window.addEventListener('beforeunload', event => { document.activeElement?.blur(); if (state.dirty) { event.preventDefault(); event.returnValue = ''; } });
1698
1920
  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(); } });
1699
1921
  async function refreshCloudState() {
@@ -1800,4 +2022,4 @@ setFavicon('idle');
1800
2022
  if (token) watchActivity();
1801
2023
  try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { /* Partial DOM. */ }
1802
2024
 
1803
- (async () => { renderHeading(); if (!token) { status('Session token missing. Open this app using andorra graph.', 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 = data.definitions || []; renderLibrary(); renderList(); const wantsNew = new URLSearchParams(location.search).get('new') === '1'; if (wantsNew && canCreateGraph()) newGraph(); 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 revisions are unchanged.', true); } catch (error) { status(error.message, true); } })();
2025
+ (async () => { renderHeading(); if (!token) { status('Session token missing. Open this app using andorra graph.', 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 (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 revisions are unchanged.', true); } catch (error) { status(error.message, true); } })();