@andorra-labs/code 0.1.14 → 0.1.16

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 (180) hide show
  1. package/dist/src/acp-agent.d.ts +54 -0
  2. package/dist/src/acp-agent.js +991 -0
  3. package/dist/src/agent-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +8 -2
  5. package/dist/src/agent-mcp-catalog.js +2 -0
  6. package/dist/src/agent-mcp.d.ts +3 -1
  7. package/dist/src/agent-mcp.js +97 -11
  8. package/dist/src/andorra/entry.js +21 -3
  9. package/dist/src/andorra/hosted.d.ts +3 -0
  10. package/dist/src/andorra/hosted.js +5 -1
  11. package/dist/src/andorra/notices.d.ts +10 -1
  12. package/dist/src/andorra/notices.js +25 -2
  13. package/dist/src/andorra/terminal.d.ts +2 -0
  14. package/dist/src/andorra/terminal.js +2 -2
  15. package/dist/src/app-server/protocol.d.ts +9 -2
  16. package/dist/src/app-server/protocol.js +1 -1
  17. package/dist/src/app-server/workspace.d.ts +1 -0
  18. package/dist/src/app-server/workspace.js +141 -10
  19. package/dist/src/app-server.d.ts +115 -0
  20. package/dist/src/app-server.js +980 -63
  21. package/dist/src/auth/AuthManager.js +4 -4
  22. package/dist/src/auth/deployment.js +2 -2
  23. package/dist/src/browser-bridge.d.ts +1 -0
  24. package/dist/src/browser-bridge.js +5 -2
  25. package/dist/src/browser-external-app.d.ts +27 -0
  26. package/dist/src/browser-external-app.js +60 -0
  27. package/dist/src/browser-panel-tool.d.ts +6 -0
  28. package/dist/src/browser-panel-tool.js +36 -0
  29. package/dist/src/browser-runner.js +1 -0
  30. package/dist/src/browser-server.d.ts +5 -0
  31. package/dist/src/browser-server.js +27 -3
  32. package/dist/src/browser-ui/style.css +3 -3
  33. package/dist/src/browser-ui/tokens.css +27 -16
  34. package/dist/src/browser-view.d.ts +16 -0
  35. package/dist/src/browser-view.js +60 -2
  36. package/dist/src/bug-report.d.ts +81 -0
  37. package/dist/src/bug-report.js +235 -0
  38. package/dist/src/claude-provider.d.ts +2 -1
  39. package/dist/src/claude-provider.js +13 -9
  40. package/dist/src/cli-sign-in.d.ts +3 -1
  41. package/dist/src/cli-sign-in.js +4 -1
  42. package/dist/src/cli.js +184 -40
  43. package/dist/src/codex-errors.js +4 -1
  44. package/dist/src/coding-tools.js +7 -7
  45. package/dist/src/command-screens.d.ts +9 -2
  46. package/dist/src/command-screens.js +166 -97
  47. package/dist/src/commands.d.ts +3 -2
  48. package/dist/src/commands.js +1 -0
  49. package/dist/src/compaction-phrases.d.ts +4 -0
  50. package/dist/src/compaction-phrases.js +20 -0
  51. package/dist/src/completion-gates.d.ts +22 -0
  52. package/dist/src/completion-gates.js +11 -0
  53. package/dist/src/config.d.ts +5 -0
  54. package/dist/src/config.js +48 -0
  55. package/dist/src/context-compaction.js +2 -1
  56. package/dist/src/decision/DecisionManager.js +3 -2
  57. package/dist/src/decision/requestPhrases.d.ts +4 -0
  58. package/dist/src/decision/requestPhrases.js +23 -0
  59. package/dist/src/github-inbox.d.ts +55 -0
  60. package/dist/src/github-inbox.js +153 -0
  61. package/dist/src/google-provider.d.ts +31 -0
  62. package/dist/src/google-provider.js +153 -0
  63. package/dist/src/graph-health.js +8 -4
  64. package/dist/src/graph-manager-chat.js +6 -1
  65. package/dist/src/graph-provider-portability.js +32 -10
  66. package/dist/src/graph-quota.d.ts +29 -2
  67. package/dist/src/graph-quota.js +68 -10
  68. package/dist/src/graph-runner.js +24 -7
  69. package/dist/src/graph-server.d.ts +1 -1
  70. package/dist/src/graph-server.js +9 -7
  71. package/dist/src/graph-sync.d.ts +1 -0
  72. package/dist/src/graph-sync.js +93 -34
  73. package/dist/src/graph-tool.d.ts +2 -0
  74. package/dist/src/graph-tool.js +2 -2
  75. package/dist/src/graph-ui/app.js +177 -41
  76. package/dist/src/graph-ui/controls.css +1 -0
  77. package/dist/src/graph-ui/edge-router.js +121 -53
  78. package/dist/src/graph-ui/embed.js +2 -2
  79. package/dist/src/graph-ui/icons.js +1 -0
  80. package/dist/src/graph-ui/index.html +1 -1
  81. package/dist/src/graph-ui/manager.css +1 -1
  82. package/dist/src/graph-ui/manager.js +2 -2
  83. package/dist/src/graph-ui/sidebar.js +30 -0
  84. package/dist/src/graph-ui/studio-canvas.js +26 -13
  85. package/dist/src/graph-ui/studio.css +15 -7
  86. package/dist/src/graph-ui/studio.js +11 -4
  87. package/dist/src/graph-ui/style.css +77 -45
  88. package/dist/src/graph-ui/theme.js +3 -36
  89. package/dist/src/graph-ui/tokens.css +27 -19
  90. package/dist/src/graph-visibility.d.ts +31 -0
  91. package/dist/src/graph-visibility.js +102 -0
  92. package/dist/src/graphs.js +4 -3
  93. package/dist/src/live-model.d.ts +24 -0
  94. package/dist/src/live-model.js +37 -0
  95. package/dist/src/managed-sign-in.d.ts +1 -0
  96. package/dist/src/managed-sign-in.js +13 -0
  97. package/dist/src/membership-errors.d.ts +2 -0
  98. package/dist/src/membership-errors.js +5 -1
  99. package/dist/src/membership.d.ts +23 -1
  100. package/dist/src/membership.js +48 -6
  101. package/dist/src/model-health-cache.js +1 -1
  102. package/dist/src/model-metadata.d.ts +1 -1
  103. package/dist/src/model-metadata.js +12 -3
  104. package/dist/src/paged-transcript.d.ts +2 -0
  105. package/dist/src/paged-transcript.js +16 -0
  106. package/dist/src/plan-pass.d.ts +59 -0
  107. package/dist/src/plan-pass.js +165 -0
  108. package/dist/src/provider-connection.js +17 -0
  109. package/dist/src/provider-engine.d.ts +5 -0
  110. package/dist/src/provider-engine.js +6 -3
  111. package/dist/src/provider-import.js +3 -1
  112. package/dist/src/provider-settings.js +14 -2
  113. package/dist/src/providers.d.ts +33 -2
  114. package/dist/src/providers.js +101 -28
  115. package/dist/src/pull-request-checks.d.ts +26 -0
  116. package/dist/src/pull-request-checks.js +56 -0
  117. package/dist/src/pull-request-conversation.d.ts +134 -0
  118. package/dist/src/pull-request-conversation.js +221 -0
  119. package/dist/src/pull-request-create.d.ts +175 -0
  120. package/dist/src/pull-request-create.js +392 -0
  121. package/dist/src/pull-request-details.d.ts +242 -0
  122. package/dist/src/pull-request-details.js +614 -0
  123. package/dist/src/pull-request-edit.d.ts +23 -0
  124. package/dist/src/pull-request-edit.js +91 -0
  125. package/dist/src/pull-request-logs.d.ts +76 -0
  126. package/dist/src/pull-request-logs.js +172 -0
  127. package/dist/src/pull-request-merge.d.ts +112 -0
  128. package/dist/src/pull-request-merge.js +258 -0
  129. package/dist/src/pull-request-review.d.ts +137 -0
  130. package/dist/src/pull-request-review.js +401 -0
  131. package/dist/src/pull-requests.d.ts +43 -2
  132. package/dist/src/pull-requests.js +112 -21
  133. package/dist/src/react-runtime.js +58 -9
  134. package/dist/src/read-document-tool.d.ts +2 -0
  135. package/dist/src/read-document-tool.js +6 -6
  136. package/dist/src/remote/engine-pool.js +42 -6
  137. package/dist/src/run-control.d.ts +10 -0
  138. package/dist/src/run-control.js +24 -0
  139. package/dist/src/run-progress.d.ts +10 -0
  140. package/dist/src/run-progress.js +122 -0
  141. package/dist/src/run-records.d.ts +2 -2
  142. package/dist/src/runtime-environment.d.ts +1 -0
  143. package/dist/src/runtime-environment.js +13 -0
  144. package/dist/src/runtime.d.ts +5 -1
  145. package/dist/src/runtime.js +14 -2
  146. package/dist/src/save-lock.js +14 -7
  147. package/dist/src/session-title.d.ts +3 -0
  148. package/dist/src/session-title.js +5 -2
  149. package/dist/src/sign-in-detection.d.ts +1 -1
  150. package/dist/src/sign-in-detection.js +10 -3
  151. package/dist/src/sign-in-offer.js +1 -1
  152. package/dist/src/skill-commands.js +1 -1
  153. package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
  154. package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
  155. package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
  156. package/dist/src/skills/bundled/provenance.json +7 -2
  157. package/dist/src/skills/runtime-skills.js +1 -0
  158. package/dist/src/subagent-run.js +1 -0
  159. package/dist/src/telemetry/capture-core.d.ts +17 -0
  160. package/dist/src/telemetry/capture-core.js +59 -1
  161. package/dist/src/telemetry/classify.d.ts +3 -1
  162. package/dist/src/telemetry/classify.js +37 -0
  163. package/dist/src/telemetry/emitter.d.ts +2 -0
  164. package/dist/src/telemetry/emitter.js +42 -5
  165. package/dist/src/telemetry/schema.d.ts +22 -0
  166. package/dist/src/telemetry/schema.js +68 -1
  167. package/dist/src/telemetry/surface.d.ts +1 -0
  168. package/dist/src/telemetry/uploader.d.ts +12 -1
  169. package/dist/src/telemetry/uploader.js +30 -2
  170. package/dist/src/terminal-links.d.ts +16 -0
  171. package/dist/src/terminal-links.js +113 -0
  172. package/dist/src/terminal-ui.d.ts +8 -1
  173. package/dist/src/terminal-ui.js +40 -14
  174. package/dist/src/tool-catalog.js +1 -1
  175. package/dist/src/trajectory.js +6 -1
  176. package/dist/src/transcript.d.ts +2 -0
  177. package/dist/src/transcript.js +10 -3
  178. package/dist/src/types.d.ts +9 -0
  179. package/dist/src/usage-analytics.js +18 -10
  180. package/package.json +2 -1
@@ -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);
@@ -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;
@@ -252,9 +293,20 @@ function outcomes(node) {
252
293
  function edgeOutcome(edge) { return edge.outcome || 'completed'; }
253
294
  function pruneRoutes(node) { state.graph.edges = state.graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge))); }
254
295
  function selectedNodes() { return (state.selectedIds.length ? state.selectedIds : state.selected ? [state.selected] : []).map(id => state.graph?.nodes[id]).filter(Boolean); }
255
- function selectionType(node) { return `${node.type}:${node.agentRole || 'regular'}`; }
296
+ function selectionType(node) { return node.type; }
256
297
  function clearSelection() { state.selectedIds = []; state.selected = null; state.selectedEdge = null; state.routePick = null; state.bulkOutcome = null; }
257
298
  function showInspector() { $('inspector').classList.remove('hidden'); $('toggle-inspector').setAttribute('aria-expanded','true'); }
299
+ // Under 1100px the inspector is an overlay on the canvas: it shows while something is selected, or while the
300
+ // reader opened Graph settings with the panel toggle, and gets out of the way otherwise.
301
+ const NARROW_LAYOUT = '(max-width: 1100px)';
302
+ function narrowLayout() { try { return typeof matchMedia === 'function' && matchMedia(NARROW_LAYOUT).matches; } catch { return false; } }
303
+ function hasSelection() { return selectedNodes().length > 0 || !!(state.selectedEdge && state.graph?.edges.includes(state.selectedEdge)); }
304
+ function syncInspectorOverlay() {
305
+ if (!narrowLayout()) return;
306
+ const show = !!state.graph && (hasSelection() || !!state.graphSettingsOpen);
307
+ $('inspector').classList.toggle('hidden', !show); $('toggle-inspector').setAttribute('aria-expanded', String(show));
308
+ }
309
+ function dismissInspectorOverlay() { clearSelection(); state.graphSettingsOpen = false; renderCanvas(); renderInspector(); }
258
310
  function selectNode(node, event = {}) {
259
311
  if (state.routePick) { routeSelectionTo(node.id); return; }
260
312
  if (state.suppressClick === node.id) { state.suppressClick = null; return; }
@@ -281,10 +333,65 @@ function routeSelectionTo(targetId) {
281
333
  },true);
282
334
  status(`Routed ${sources.length} steps to ${target.name}. Existing matching connections were kept; set the inputs of new ones below.`);
283
335
  }
336
+ const MIXED = 'Mixed';
337
+ // What every selected step has for one setting, or `mixed` when they differ.
338
+ function sharedValue(nodes, read) {
339
+ const first = read(nodes[0]), key = JSON.stringify(first ?? null);
340
+ return nodes.every(node => JSON.stringify(read(node) ?? null) === key) ? { value: first, mixed: false } : { value: undefined, mixed: true };
341
+ }
342
+ function bulkChoice(parent, label, nodes, read, values, write) {
343
+ const { value, mixed } = sharedValue(nodes, read);
344
+ const options = values.map(item => typeof item === 'string' ? { value: item, label: item.replaceAll('-', ' ') } : item);
345
+ const input = field(parent, label, mixed ? '' : value, chosen => { if (chosen !== '') for (const node of nodes) write(node, chosen); }, { options: mixed ? [{ value: '', label: MIXED }, ...options] : options, refresh: true });
346
+ if (mixed) input.children[0].disabled = true;
347
+ return input;
348
+ }
349
+ function bulkCheck(parent, label, nodes, read, write) {
350
+ const { value, mixed } = sharedValue(nodes, node => !!read(node));
351
+ const input = check(parent, label, !mixed && value, checked => { for (const node of nodes) write(node, checked); });
352
+ if (mixed) { input.indeterminate = true; input.setAttribute('aria-checked', 'mixed'); }
353
+ return input;
354
+ }
355
+ function bulkNumber(parent, label, nodes, read, write, options = {}) {
356
+ const { value, mixed } = sharedValue(nodes, read);
357
+ const input = field(parent, label, mixed ? '' : value, next => { for (const node of nodes) write(node, next); }, { type: 'number', refresh: true, ...options, placeholder: mixed ? MIXED : options.placeholder });
358
+ const commit = input.onchange;
359
+ // A blank box leaves the steps as they are while they differ, and is not a number where one is required.
360
+ input.onchange = () => { if (input.value.trim() === '' && (mixed || !options.optional)) { renderInspector(); return; } commit(); };
361
+ return input;
362
+ }
363
+ function renderBulkSettings(panels, nodes) {
364
+ explain(bulkCheck(panels.general, 'Jev decisions', nodes, node => node.jevEnabled === true, (node, on) => { if (on) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists each selected agent with routing decisions. A dash means some of the selected steps have it on; ticking turns it on for all of them.');
365
+ const models = sharedValue(nodes, node => [node.provider ?? null, node.model ?? null]);
366
+ modelFields(panels.model, models.mixed ? {} : { provider: nodes[0].provider, model: nodes[0].model }, value => { for (const node of nodes) { node.provider = value.provider; node.model = value.model; } }, undefined, undefined, undefined, { mixed: models.mixed });
367
+ bulkChoice(panels.model, 'Conversation', nodes, node => node.contextPolicy?.conversation ?? 'reuse', [{value:'reuse',label:'Reuse with the same provider and model'}, {value:'isolate',label:'Start an isolated conversation'}], (node, value) => { node.contextPolicy = { ...node.contextPolicy, conversation: value }; });
368
+ bulkChoice(panels.model, 'Skill inheritance', nodes, node => node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active graph skills'}, {value:'none',label:'Do not inherit skills'}], (node, value) => { node.contextPolicy = { ...node.contextPolicy, skillInheritance: value }; });
369
+ const advanced = panels.advanced;
370
+ const caps = disclosure(advanced, 'Permissions');
371
+ for (const [key, values] of Object.entries(CAPABILITIES)) bulkChoice(caps, key.charAt(0).toUpperCase() + key.slice(1), nodes, node => node.capabilities?.[key] || effectiveCaps()[key], values, (node, value) => { node.capabilities = { ...effectiveCaps(), ...node.capabilities, [key]: value }; });
372
+ const context = disclosure(advanced, 'Context sharing');
373
+ bulkCheck(context, 'Include previous task summaries', nodes, node => node.contextPolicy?.history ?? false, (node, value) => { node.contextPolicy = { ...node.contextPolicy, history: value }; });
374
+ bulkChoice(context, 'Visible predecessor state', nodes, node => node.contextPolicy?.predecessors || 'none', ['none', 'direct', 'all'], (node, value) => { node.contextPolicy = { ...node.contextPolicy, predecessors: value }; });
375
+ bulkNumber(context, 'Maximum context characters', nodes, node => node.contextPolicy?.maxChars ?? 32000, (node, value) => { node.contextPolicy = { ...node.contextPolicy, maxChars: value }; }, { min: 1 });
376
+ const limits = disclosure(advanced, 'Execution limits');
377
+ for (const [key, label, defaultValue] of [['maxContextChars', 'Context characters', 120000], ['maxCompletionRepairs', 'Completion repair tries', 2]]) bulkNumber(limits, label, nodes, node => node.limits?.[key] ?? defaultValue, (node, value) => { node.limits = { ...node.limits, [key]: value }; delete node.limits.maxTokens; }, { min: key === 'maxCompletionRepairs' ? 0 : 1 });
378
+ bulkNumber(limits, 'Iterations (blank = unlimited)', nodes, node => node.limits?.maxIterations ?? node.maxIterations, (node, value) => { node.limits = { ...node.limits, maxIterations: value }; delete node.limits.maxTokens; if (value === undefined) { delete node.limits.maxIterations; delete node.maxIterations; } else node.maxIterations = value; }, { min: 0, max: 1000, optional: true, placeholder: 'Unlimited' });
379
+ bulkNumber(limits, 'Wall time, seconds (blank = unlimited)', nodes, node => msToSeconds(node.limits?.wallTimeMs), (node, value) => { node.limits = { ...node.limits, wallTimeMs: secondsToMs(value) }; delete node.limits.maxTokens; if (value === undefined) delete node.limits.wallTimeMs; }, { min: 0, step: 'any', optional: true, placeholder: 'Unlimited' });
380
+ bulkNumber(limits, 'Tool calls (blank = unlimited)', nodes, node => node.limits?.maxToolCalls, (node, value) => { node.limits = { ...node.limits, maxToolCalls: value }; if (value === undefined) delete node.limits.maxToolCalls; }, { min: 0, optional: true, placeholder: 'Unlimited' });
381
+ bulkNumber(advanced, 'Retries', nodes, node => node.retry?.maxAttempts ?? 1, (node, value) => { node.retry = { ...node.retry, maxAttempts: value }; }, { min: 1 });
382
+ const tools = disclosure(advanced, 'Tool allowlist'), all = () => state.tools.map(tool => typeof tool === 'string' ? tool : tool.name || tool.id);
383
+ for (const name of [...new Set([...all(), ...nodes.flatMap(node => node.tools || [])])]) bulkCheck(tools, name, nodes, node => node.tools === undefined || node.tools.includes(name), (node, enabled) => { node.tools = enabled ? [...new Set([...(node.tools ?? all()), name])] : (node.tools ?? all()).filter(tool => tool !== name); });
384
+ }
284
385
  function renderBulkInspector(parent, nodes) {
285
386
  $('inspector-title').textContent = `${nodes.length} steps selected`;
286
387
  parent.append(el('p',nodes.map(node=>node.name).join(', '),'help'));
287
- const group = section(parent,'Output step');
388
+ let routing = parent;
389
+ if (nodes.every(node => node.type === 'agent')) {
390
+ parent.append(el('p', `Changes here apply to all ${nodes.length} selected steps. ${MIXED} marks a setting the steps do not share yet; names, prompts and outcomes stay per step.`, 'help'));
391
+ const panels = inspectorTabs(parent, ['general', 'model', 'behavior', 'advanced']);
392
+ renderBulkSettings(panels, nodes); routing = panels.behavior;
393
+ }
394
+ const group = section(routing,'Output step');
288
395
  const shared = outcomes(nodes[0]).filter(outcome => nodes.every(node => outcomes(node).includes(outcome)));
289
396
  if (!shared.length) {group.append(el('p','These steps have no shared outcome. Give them a matching completion outcome before routing together.','help'));return;}
290
397
  if (!shared.includes(state.bulkOutcome)) state.bulkOutcome=shared[0];
@@ -300,9 +407,11 @@ function cancelRoutePick() { state.routePick=null;renderCanvas();renderInspector
300
407
  function issues() {
301
408
  const graph = state.graph; if (!graph) return [];
302
409
  const result = [], nodes = Object.values(graph.nodes);
410
+ // A view-only graph is not being saved, so the limits it is over are not its reader's problem.
411
+ if (viewOnly()) return [{ message: FREE_LOCKED_TIP }];
303
412
  if (nodes.length < 2 || nodes.length > nodeLimit(graph)) result.push({ message: `Use between 2 and ${nodeLimit(graph)} steps; remove extra steps before saving.` });
304
413
  if (freeTier()) {
305
- 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 });
414
+ if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? FREE_LOCKED_TIP : FREE_CREATE_TIP });
306
415
  if (nodes.some(node => node.agentRole === 'orchestrator')) result.push({ message: FREE_ORCHESTRATOR_TIP });
307
416
  if (countedNodes(graph) > state.plan.nodeLimit) result.push({ message: freeNodeTip() });
308
417
  }
@@ -364,7 +473,7 @@ function rememberedGraph() {
364
473
  }
365
474
  async function reopenRemembered() {
366
475
  const remembered = rememberedGraph();
367
- if (!remembered || graphLocked(remembered.id)) return false;
476
+ if (!remembered) return false;
368
477
  const saved = state.graphs.some(graph => graph.id === remembered.id);
369
478
  if (remembered.unsaved || !saved) {
370
479
  try {
@@ -378,12 +487,20 @@ async function reopenRemembered() {
378
487
  function renderHeading() {
379
488
  rememberOpenGraph();
380
489
  $('graph-title').textContent = state.graph?.name || 'Graph Editor';
381
- $('revision').textContent = state.graph ? `${state.graph.revision ? `Version ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
490
+ $('revision').textContent = state.graph ? (state.graph.revision ? `Version ${state.graph.revision}` : 'New graph') : '';
382
491
  $('save').disabled = state.saving || state.orderSaving || !state.graph || !state.dirty || state.graph.id === 'default';
383
492
  $('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
493
+ $('save-state').textContent = viewOnly() ? 'View only' : 'Saved';
494
+ $('save-state').title = viewOnly() ? FREE_LOCKED_TIP : '';
495
+ document.body?.classList?.toggle?.('view-only', viewOnly());
496
+ // Save is the header's one primary and shows only while there is something to save; a clean graph says so quietly.
497
+ const pending = !!state.graph && (state.dirty || state.saving);
498
+ $('save').hidden = !pending;
499
+ $('save-state').hidden = !state.graph || pending;
384
500
  $('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
385
501
  for (const id of ['duplicate', 'export', 'layout', 'fit']) $(id).disabled = !state.graph;
386
502
  $('duplicate').disabled = state.saving || state.orderSaving || !state.graph || !canCreateGraph();
503
+ if (viewOnly()) for (const id of ['layout', 'undo', 'redo']) $(id).disabled = true;
387
504
  renderLibrary();
388
505
  window.AndorraStudio?.heading?.();
389
506
  globalThis.AndorraManager?.heading?.();
@@ -441,10 +558,9 @@ function renderList() {
441
558
  const locked = graphLocked(graph.id);
442
559
  const button = el('button', undefined, `graph-row${state.graph?.id === graph.id ? ' active' : ''}${locked ? ' locked' : ''}`);
443
560
  button.disabled = state.saving;
444
- const tag = el('small', graph.id === 'default' ? 'Preset' : `v${graph.revision}`);
561
+ const tag = el('small', graph.id === 'default' ? 'Preset' : locked ? 'View only' : `v${graph.revision}`);
445
562
  button.append(el('span', graph.name), tag);
446
563
  if (locked) {
447
- button.setAttribute('aria-disabled', 'true');
448
564
  button.title = FREE_LOCKED_TIP;
449
565
  const glyph = globalThis.AndorraIcons?.icon?.('lock', 12);
450
566
  if (glyph) tag.prepend(glyph);
@@ -494,7 +610,7 @@ function renderList() {
494
610
  const button = el('button', undefined, `graph-row draft-row${locked ? ' locked' : ''}`); button.disabled = state.saving;
495
611
  const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
496
612
  const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
497
- button.title = locked ? FREE_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
613
+ button.title = locked ? FREE_DRAFT_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
498
614
  if (locked) { button.setAttribute('aria-disabled', 'true'); const glyph = globalThis.AndorraIcons?.icon?.('lock', 12); if (glyph) when.prepend(glyph); }
499
615
  button.append(el('span', draft.name), when);
500
616
  button.onclick = () => openDraft(draft.snapshot, draft.graphId);
@@ -579,7 +695,7 @@ function showMenuAt(x, y, ariaLabel, items) {
579
695
  }
580
696
  function showGraphMenu(graph, x, y) {
581
697
  const items = [
582
- ...(graphLocked(graph.id) ? [] : [{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) }]),
698
+ { label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) },
583
699
  { label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
584
700
  ];
585
701
  if (graph.id !== 'default') items.push({ label: 'Delete', icon: 'trash', danger: true, run: () => { deleteGraph(graph).catch(error => status(error.message, true)); } });
@@ -593,7 +709,7 @@ function showNewGraphMenu(x, y) {
593
709
  }
594
710
  async function exportGraph(graph) {
595
711
  if (window.AndorraEmbed?.hostChrome?.() && window.AndorraEmbed.exportGraph) { window.AndorraEmbed.exportGraph(graph.id); return; }
596
- if (state.saving) { status('Wait for the current save before exporting a graph.'); return; }
712
+ if (state.saving) { status('Wait for the current save before exporting a graph.', 'notice'); return; }
597
713
  downloadGraph(dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(graph.id)}`)));
598
714
  }
599
715
  function exportFileName(graph) {
@@ -607,16 +723,19 @@ function downloadJson(value, stem) {
607
723
  setTimeout(() => URL.revokeObjectURL(url), 1000);
608
724
  }
609
725
  async function duplicateGraph(source) {
610
- if (state.saving || state.orderSaving) { status('Wait for the current save before duplicating a graph.'); return; }
726
+ if (state.saving || state.orderSaving) { status('Wait for the current save before duplicating a graph.', 'notice'); return; }
611
727
  state.saving = true; renderHeading(); renderList();
612
728
  let created;
613
729
  let orderSaveError;
614
730
  try {
615
731
  const saved = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(source.id)}`));
732
+ const refusal = freeCopyRefusal(saved);
733
+ if (refusal) throw new Error(refusal);
616
734
  const suffix = ' (Copy)', base = saved.name || 'Untitled graph';
617
735
  const name = base.length + suffix.length > 200 ? base.slice(0, 200 - suffix.length).trimEnd() + suffix : base + suffix;
618
736
  const duplicate = { ...saved, id: newId(), name, revision: 0 };
619
737
  const stored = await api('/api/graphs', duplicate);
738
+ if (freeTier()) state.plan.freeGraphId = stored.id;
620
739
  created = { id: stored.id, name: stored.name };
621
740
  const summary = { id: stored.id, name: stored.name, revision: stored.revision };
622
741
  state.graphs.push(summary);
@@ -630,7 +749,7 @@ async function duplicateGraph(source) {
630
749
  if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in Graph settings.`);
631
750
  }
632
751
  async function deleteGraph(graph) {
633
- if (state.saving || state.orderSaving) { status('Wait for the current save before deleting a graph.'); return; }
752
+ if (state.saving || state.orderSaving) { status('Wait for the current save before deleting a graph.', 'notice'); return; }
634
753
  if (!await askConfirm({ title: `Delete “${graph.name}”?`, message: 'Its versions and drafts are removed from this machine.', confirmLabel: 'Delete', tone: 'danger' })) return;
635
754
  state.saving = true; renderHeading(); renderList();
636
755
  if (!pendingDraft || pendingDraft.id === graph.id) { pendingDraft = null; clearTimeout(draftTimer); }
@@ -656,6 +775,10 @@ async function deleteGraph(graph) {
656
775
  if (state.graph?.id !== graph.id) status(`Deleted "${graph.name}".`);
657
776
  }
658
777
  function position(node, index) { return node.position || { x: index * 290, y: 0 }; }
778
+ // A step card's footprint before it is measured: one outcome is a dot on the right edge; several stack as labelled rows.
779
+ const NODE_WIDTH = 210, NODE_HEIGHT = 68, PORT_ROW = 24, PORT_Y = NODE_HEIGHT / 2;
780
+ function portLayout(node) { const count = outcomes(node).length; return count > 1 ? 'many' : count ? 'solo' : 'none'; }
781
+ function nodeHeight(node) { const count = outcomes(node).length; return NODE_HEIGHT + (count > 1 ? count * PORT_ROW - 4 : 0); }
659
782
  const GRID_STEP = 20;
660
783
  const GRID_MIN_PX = 10;
661
784
  function transform() {
@@ -706,7 +829,7 @@ function renderCanvas() {
706
829
  const connected = new Set(state.graph.edges.map(edge => JSON.stringify([edge.source, edgeOutcome(edge)])));
707
830
  const errorIds = nodeErrorIds();
708
831
  nodes.forEach((node, index) => {
709
- 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' : ''}`);
832
+ 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' : ''}`);
710
833
  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' : ''}`);
711
834
  const title = el('div', undefined, 'node-title'), glyph = nodeIconElement(node);
712
835
  if (glyph) title.append(glyph);
@@ -748,7 +871,7 @@ function measureBoxes() {
748
871
  Object.values(state.graph.nodes).forEach((node, index) => {
749
872
  const element = elements.get(node.id), p = position(node, index);
750
873
  if (!element) return;
751
- const offsets = Array.from(element.querySelectorAll('.output-port')).map(port => port.offsetTop + port.offsetHeight / 2);
874
+ const edge = element.clientTop || 0, offsets = Array.from(element.querySelectorAll('.output-port')).map(port => edge + port.offsetTop + port.offsetHeight / 2);
752
875
  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 })) });
753
876
  });
754
877
  return boxes;
@@ -756,7 +879,7 @@ function measureBoxes() {
756
879
  function routeInput(edge, boxes) {
757
880
  const from = boxes.get(edge.source), to = boxes.get(edge.target); if (!from || !to) return null;
758
881
  const source = from.ports[Math.max(0, outcomes(state.graph.nodes[edge.source]).indexOf(edgeOutcome(edge)))];
759
- return source ? { source, target: { x: to.x, y: to.y + 48 } } : null;
882
+ return source ? { source, target: { x: to.x, y: to.y + PORT_Y } } : null;
760
883
  }
761
884
  const drawnRoute = points => points && { d: (AndorraEdgeRouter.roundedPath || AndorraEdgeRouter.path)(points), label: AndorraEdgeRouter.labelPoint?.(points) };
762
885
  function dragFrame(node, boxes) {
@@ -848,14 +971,17 @@ function renderEdges() {
848
971
  for(const [name,value] of Object.entries({'text-anchor':'middle',fill:palette.pillInk}))text.setAttribute(name,value);
849
972
  text.textContent=outcome;group.append(rect,text);pillLayer.append(group);
850
973
  const pill={rect,text,width:Math.max(28,Math.round(outcome.length*6.6+16))};
851
- entry.pill=group;drawnEdges[index].pill=pill;drawnPills.push({pill,at});
974
+ entry.pill=group;drawnEdges[index].pill=pill;drawnPills.push({pill,at,index});
852
975
  }
853
976
  $('edges').append(pillLayer,caption);
854
- for(const {pill,at} of drawnPills){
977
+ const pillWidths=[];
978
+ for(const {pill,index} of drawnPills){
855
979
  const measured=typeof pill.text.getComputedTextLength==='function'?pill.text.getComputedTextLength():0;
856
980
  if(measured>0)pill.width=Math.max(28,Math.ceil(measured+16));
857
- pill.rect.setAttribute('width',String(pill.width));placePill(pill,at);
981
+ pill.rect.setAttribute('width',String(pill.width));pillWidths[index]=pill.width;
858
982
  }
983
+ const pillSpots=AndorraEdgeRouter.placeLabels?.(routedPoints,pillWidths,PILL_HEIGHT,rectangles);
984
+ for(const {pill,at,index} of drawnPills)placePill(pill,pillSpots?.[index]||at);
859
985
  emphasize(state.selectedEdge);
860
986
  }
861
987
  function removeNodes(ids) {
@@ -1131,6 +1257,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
1131
1257
  const pickerButton = modelPickerButton({
1132
1258
  ariaLabel: 'Model',
1133
1259
  current: () => {
1260
+ if (options.mixed) return { model: MIXED, provider: '', entry: undefined };
1134
1261
  const pinned = target.model?.trim();
1135
1262
  const entry = entryFor(effectiveProvider);
1136
1263
  if (!pinned && !target.provider && options.defaultLabel) return { model: options.defaultLabel, provider: '', entry: undefined };
@@ -1147,7 +1274,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
1147
1274
  });
1148
1275
  },
1149
1276
  selected: () => target.model?.trim() ? { provider: effectiveProvider, model: target.model.trim() } : null,
1150
- defaultRow: () => options.noDefault ? undefined : ({ label: defaultLabel, hint: defaultHint, selected: !target.provider && !target.model?.trim() }),
1277
+ defaultRow: () => options.noDefault ? undefined : ({ label: defaultLabel, hint: defaultHint, selected: !options.mixed && !target.provider && !target.model?.trim() }),
1151
1278
  pickDefault: () => mutate(() => update({ ...target, provider: undefined, model: undefined }), true),
1152
1279
  pick: ({ provider: chosenProvider, model: chosenModel }) => {
1153
1280
  if (chosenProvider === effectiveProvider && !(options.requireProvider && !target.provider)) { model.value = chosenModel; model.onchange(); return; }
@@ -1217,13 +1344,13 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
1217
1344
  parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
1218
1345
  }
1219
1346
  }
1220
- const info = el('p', 'Context window: detecting from model…', 'help model-context'); parent.append(info);
1347
+ const info = el('p', options.mixed ? 'The selected steps use different models. Choosing one applies it to all of them.' : 'Context window: detecting from model…', 'help model-context'); parent.append(info);
1221
1348
  const key = JSON.stringify([target.provider || '', target.model || '', provider?.model || '']);
1222
1349
  const registryGeneration = state.providerRegistryGeneration || 0;
1223
1350
  state.modelContextRequests ||= new Map();
1224
1351
  if (!state.modelContextRequests.has(key)) state.modelContextRequests.set(key, api(`/api/model-context?provider=${encodeURIComponent(target.provider || '')}&model=${encodeURIComponent(target.model || '')}`).catch(() => ({contextWindow:null})));
1225
1352
  state.modelContextRequests.get(key).then(data => {
1226
- if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
1353
+ if (options.mixed || (state.providerRegistryGeneration || 0) !== registryGeneration) return;
1227
1354
  info.textContent = data.contextWindow ? `Context window: ${data.contextWindow.toLocaleString()} tokens (automatic)` : 'Context window: not reported by this model. Runtime uses its default budget.';
1228
1355
  });
1229
1356
  const override = disclosure(parent, 'Custom model name');
@@ -1574,6 +1701,7 @@ function retryLimitHelp(parent, graph) {
1574
1701
  }
1575
1702
  function renderInspector() {
1576
1703
  document.body?.classList?.remove?.('prompt-fullscreen'); for (const backdrop of document.querySelectorAll?.('.prompt-backdrop') ?? []) backdrop.remove();
1704
+ syncInspectorOverlay();
1577
1705
  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; }
1578
1706
  if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
1579
1707
  const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : 'Graph settings';
@@ -1584,7 +1712,7 @@ function renderInspector() {
1584
1712
  else if (!node) {
1585
1713
  const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
1586
1714
  field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
1587
- const meta = el('p', `${graph.id} · Version ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
1715
+ 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);
1588
1716
  if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
1589
1717
  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.');
1590
1718
  field(general, 'Description', graph.metadata?.description, value => {graph.metadata={...graph.metadata,description:value};}, {multiline:true,maxLength:2000});
@@ -1648,16 +1776,17 @@ function renderInspector() {
1648
1776
  }
1649
1777
  function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas(); renderInspector(); scheduleValidation(); queueDraft(); }
1650
1778
  async function openGraph(id, options = {}) {
1651
- if (state.saving) { status('Wait for the current save before opening another graph.'); return false; }
1652
- if (graphLocked(id)) { status(FREE_LOCKED_TIP, true); return false; }
1779
+ if (state.saving) { status('Wait for the current save before opening another graph.', 'notice'); return false; }
1653
1780
  if (state.dirty && !options.discard && !await askConfirm(DISCARD_QUESTION)) return false;
1654
- 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; }
1781
+ 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; }
1655
1782
  }
1656
1783
  function newId() { return `graph-${crypto.randomUUID()}`; }
1657
1784
  function newGraph(duplicate = false, discarded = false) {
1658
- if (state.saving) { status('Wait for the current save before creating another graph.'); return; }
1785
+ if (state.saving) { status('Wait for the current save before creating another graph.', 'notice'); return; }
1659
1786
  if (!canCreateGraph()) { status(FREE_CREATE_TIP, true); return; }
1787
+ if (duplicate) { const refusal = freeCopyRefusal(state.graph); if (refusal) { status(refusal, true); return; } }
1660
1788
  if (state.dirty && !discarded) { void askConfirm(DISCARD_QUESTION).then(discard => { if (discard) newGraph(duplicate, true); }); return; }
1789
+ state.viewOnlySource = null;
1661
1790
  if (duplicate) state.graph={...copy(state.graph),id:newId(),name:`${state.graph.name} copy`,revision:0};
1662
1791
  else if (freeTier()) {
1663
1792
  const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
@@ -1957,7 +2086,7 @@ function animateView(target, anchor) {
1957
2086
  }
1958
2087
  function fit(animate = false) {
1959
2088
  if (!state.graph) return; const nodes = Object.values(state.graph.nodes); if (!nodes.length) return;
1960
- 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));
2089
+ 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)));
1961
2090
  const zoomed = Math.min(1, Math.max(.2, Math.min(($('canvas').clientWidth - 90) / (maxX - minX), ($('canvas').clientHeight - 170) / (maxY - minY))));
1962
2091
  const target = { zoom: zoomed, x: ($('canvas').clientWidth - (maxX - minX) * zoomed) / 2 - minX * zoomed, y: ($('canvas').clientHeight - (maxY - minY) * zoomed) / 2 - minY * zoomed };
1963
2092
  if (animate) { animateView(target); return; }
@@ -1974,8 +2103,15 @@ function zoomBy(factor) {
1974
2103
  }
1975
2104
  $('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('empty-create').onclick = () => newGraph(); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
1976
2105
  $('node-search').oninput = renderLibrary;
1977
- $('graph-settings').onclick = () => { clearSelection(); renderCanvas(); renderInspector(); };
1978
- $('toggle-inspector').onclick = () => { const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden)); };
2106
+ $('graph-settings').onclick = () => { clearSelection(); state.graphSettingsOpen = true; renderCanvas(); renderInspector(); };
2107
+ $('toggle-inspector').onclick = () => {
2108
+ if (narrowLayout()) { if ($('inspector').classList.contains?.('hidden')) { state.graphSettingsOpen = true; renderInspector(); } else dismissInspectorOverlay(); return; }
2109
+ const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden));
2110
+ };
2111
+ if (typeof matchMedia === 'function') {
2112
+ const narrow = matchMedia(NARROW_LAYOUT), relayout = () => { if (narrow.matches) syncInspectorOverlay(); else showInspector(); };
2113
+ if (typeof narrow.addEventListener === 'function') narrow.addEventListener('change', relayout); else narrow.addListener?.(relayout);
2114
+ }
1979
2115
  $('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'); };
1980
2116
  $('redo').onclick = () => { if (!state.redo.length) return; state.undo.push(copy(state.graph)); state.graph = state.redo.pop(); clearSelection(); refreshDirty(); render(); status('Change restored'); };
1981
2117
  function pulseErrorNodes() {
@@ -1999,7 +2135,7 @@ $('save').onclick = async () => {
1999
2135
  let orderFailed = false;
2000
2136
  try { const submitted = dropLegacyTokenFields(copy(state.graph)); const graph = await api('/api/graphs', submitted); if (state.graph.id === submitted.id) {
2001
2137
  const liveView = { ...state.graph }; delete liveView.pendingProviderNodes;
2002
- 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(); }
2138
+ 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(); }
2003
2139
  };
2004
2140
  $('canvas-hint-close').onclick = dismissCanvasHint;
2005
2141
  $('fit').onclick = () => fit(true); $('zoom-in').onclick = () => zoomBy(1.2); $('zoom-out').onclick = () => zoomBy(1 / 1.2);
@@ -2036,7 +2172,7 @@ $('canvas').ondrop = event => {
2036
2172
  const file = Array.from(event.dataTransfer?.files || []).find(item => /\.json$/i.test(item.name) || item.type === 'application/json');
2037
2173
  if (file) { event.preventDefault(); void window.AndorraStudio?.importGraphFile?.(file)?.catch(error => status(error.message, true)); }
2038
2174
  };
2039
- $('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; }; };
2175
+ $('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(); }; };
2040
2176
  $('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; }; };
2041
2177
  $('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`); };
2042
2178
  $('export').onclick = () => { if (!state.graph) return; downloadGraph(state.graph); };
@@ -2045,7 +2181,7 @@ if (typeof document.addEventListener === 'function') {
2045
2181
  }
2046
2182
  window.addEventListener('pagehide', () => { void flushDraft(true); });
2047
2183
  window.addEventListener('beforeunload', event => { document.activeElement?.blur(); if (state.dirty) { event.preventDefault(); event.returnValue = ''; } });
2048
- 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(); } });
2184
+ 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(); } });
2049
2185
  async function refreshCloudState() {
2050
2186
  if (!token) return;
2051
2187
  const orderSavingDuringSync = state.orderSaving;
@@ -2131,4 +2267,4 @@ setFavicon('idle');
2131
2267
  if (token) watchActivity();
2132
2268
  try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { }
2133
2269
 
2134
- (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); } })();
2270
+ (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; }