@andorra-labs/code 0.1.15 → 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 (100) hide show
  1. package/dist/src/agent-definitions.js +29 -6
  2. package/dist/src/agent-execution.js +4 -2
  3. package/dist/src/agent-mcp.d.ts +1 -1
  4. package/dist/src/agent-mcp.js +13 -9
  5. package/dist/src/app-server/protocol.d.ts +4 -1
  6. package/dist/src/app-server/protocol.js +1 -1
  7. package/dist/src/app-server.d.ts +107 -0
  8. package/dist/src/app-server.js +893 -22
  9. package/dist/src/auth/deployment.js +2 -2
  10. package/dist/src/browser-runner.js +1 -0
  11. package/dist/src/browser-ui/style.css +3 -3
  12. package/dist/src/browser-ui/tokens.css +27 -16
  13. package/dist/src/claude-provider.js +3 -1
  14. package/dist/src/cli.js +22 -8
  15. package/dist/src/codex-errors.js +4 -1
  16. package/dist/src/command-screens.js +5 -3
  17. package/dist/src/commands.d.ts +2 -1
  18. package/dist/src/compaction-phrases.d.ts +4 -0
  19. package/dist/src/compaction-phrases.js +20 -0
  20. package/dist/src/context-compaction.js +2 -1
  21. package/dist/src/decision/DecisionManager.js +3 -2
  22. package/dist/src/decision/requestPhrases.d.ts +4 -0
  23. package/dist/src/decision/requestPhrases.js +23 -0
  24. package/dist/src/github-inbox.d.ts +55 -0
  25. package/dist/src/github-inbox.js +153 -0
  26. package/dist/src/graph-health.js +7 -3
  27. package/dist/src/graph-provider-portability.js +32 -10
  28. package/dist/src/graph-quota.d.ts +29 -2
  29. package/dist/src/graph-quota.js +68 -10
  30. package/dist/src/graph-runner.js +24 -7
  31. package/dist/src/graph-server.d.ts +1 -1
  32. package/dist/src/graph-server.js +9 -7
  33. package/dist/src/graph-ui/app.js +110 -33
  34. package/dist/src/graph-ui/controls.css +1 -0
  35. package/dist/src/graph-ui/embed.js +2 -2
  36. package/dist/src/graph-ui/icons.js +1 -0
  37. package/dist/src/graph-ui/index.html +1 -1
  38. package/dist/src/graph-ui/manager.css +1 -1
  39. package/dist/src/graph-ui/manager.js +2 -2
  40. package/dist/src/graph-ui/sidebar.js +30 -0
  41. package/dist/src/graph-ui/studio-canvas.js +26 -13
  42. package/dist/src/graph-ui/studio.css +15 -7
  43. package/dist/src/graph-ui/studio.js +11 -4
  44. package/dist/src/graph-ui/style.css +77 -45
  45. package/dist/src/graph-ui/theme.js +3 -36
  46. package/dist/src/graph-ui/tokens.css +27 -19
  47. package/dist/src/graphs.js +4 -3
  48. package/dist/src/membership.d.ts +20 -1
  49. package/dist/src/membership.js +29 -4
  50. package/dist/src/model-metadata.d.ts +1 -1
  51. package/dist/src/model-metadata.js +4 -2
  52. package/dist/src/plan-pass.d.ts +59 -0
  53. package/dist/src/plan-pass.js +165 -0
  54. package/dist/src/provider-engine.js +3 -0
  55. package/dist/src/providers.d.ts +17 -0
  56. package/dist/src/providers.js +68 -19
  57. package/dist/src/pull-request-checks.d.ts +26 -0
  58. package/dist/src/pull-request-checks.js +56 -0
  59. package/dist/src/pull-request-conversation.d.ts +134 -0
  60. package/dist/src/pull-request-conversation.js +221 -0
  61. package/dist/src/pull-request-create.d.ts +175 -0
  62. package/dist/src/pull-request-create.js +392 -0
  63. package/dist/src/pull-request-details.d.ts +242 -0
  64. package/dist/src/pull-request-details.js +614 -0
  65. package/dist/src/pull-request-edit.d.ts +23 -0
  66. package/dist/src/pull-request-edit.js +91 -0
  67. package/dist/src/pull-request-logs.d.ts +76 -0
  68. package/dist/src/pull-request-logs.js +172 -0
  69. package/dist/src/pull-request-merge.d.ts +112 -0
  70. package/dist/src/pull-request-merge.js +258 -0
  71. package/dist/src/pull-request-review.d.ts +137 -0
  72. package/dist/src/pull-request-review.js +401 -0
  73. package/dist/src/pull-requests.d.ts +43 -2
  74. package/dist/src/pull-requests.js +112 -21
  75. package/dist/src/react-runtime.js +37 -4
  76. package/dist/src/remote/engine-pool.js +16 -4
  77. package/dist/src/run-control.d.ts +10 -0
  78. package/dist/src/run-control.js +24 -0
  79. package/dist/src/run-progress.d.ts +10 -0
  80. package/dist/src/run-progress.js +122 -0
  81. package/dist/src/run-records.d.ts +2 -2
  82. package/dist/src/runtime.d.ts +5 -1
  83. package/dist/src/runtime.js +14 -2
  84. package/dist/src/subagent-run.js +1 -0
  85. package/dist/src/telemetry/capture-core.d.ts +17 -0
  86. package/dist/src/telemetry/capture-core.js +59 -1
  87. package/dist/src/telemetry/classify.d.ts +3 -1
  88. package/dist/src/telemetry/classify.js +37 -0
  89. package/dist/src/telemetry/emitter.d.ts +2 -0
  90. package/dist/src/telemetry/emitter.js +42 -5
  91. package/dist/src/telemetry/schema.d.ts +22 -0
  92. package/dist/src/telemetry/schema.js +68 -1
  93. package/dist/src/telemetry/surface.d.ts +1 -0
  94. package/dist/src/telemetry/uploader.d.ts +6 -1
  95. package/dist/src/telemetry/uploader.js +22 -3
  96. package/dist/src/terminal-ui.js +1 -1
  97. package/dist/src/transcript.js +8 -2
  98. package/dist/src/types.d.ts +7 -0
  99. package/dist/src/usage-analytics.js +18 -10
  100. package/package.json +1 -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;
@@ -255,6 +296,17 @@ function selectedNodes() { return (state.selectedIds.length ? state.selectedIds
255
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; }
@@ -355,9 +407,11 @@ function cancelRoutePick() { state.routePick=null;renderCanvas();renderInspector
355
407
  function issues() {
356
408
  const graph = state.graph; if (!graph) return [];
357
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 }];
358
412
  if (nodes.length < 2 || nodes.length > nodeLimit(graph)) result.push({ message: `Use between 2 and ${nodeLimit(graph)} steps; remove extra steps before saving.` });
359
413
  if (freeTier()) {
360
- if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? 'On the free tier only your first custom graph can be changed. Upgrade to Premium to edit this graph.' : FREE_CREATE_TIP });
414
+ if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? FREE_LOCKED_TIP : FREE_CREATE_TIP });
361
415
  if (nodes.some(node => node.agentRole === 'orchestrator')) result.push({ message: FREE_ORCHESTRATOR_TIP });
362
416
  if (countedNodes(graph) > state.plan.nodeLimit) result.push({ message: freeNodeTip() });
363
417
  }
@@ -419,7 +473,7 @@ function rememberedGraph() {
419
473
  }
420
474
  async function reopenRemembered() {
421
475
  const remembered = rememberedGraph();
422
- if (!remembered || graphLocked(remembered.id)) return false;
476
+ if (!remembered) return false;
423
477
  const saved = state.graphs.some(graph => graph.id === remembered.id);
424
478
  if (remembered.unsaved || !saved) {
425
479
  try {
@@ -433,12 +487,20 @@ async function reopenRemembered() {
433
487
  function renderHeading() {
434
488
  rememberOpenGraph();
435
489
  $('graph-title').textContent = state.graph?.name || 'Graph Editor';
436
- $('revision').textContent = state.graph ? `${state.graph.revision ? `Version ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
490
+ $('revision').textContent = state.graph ? (state.graph.revision ? `Version ${state.graph.revision}` : 'New graph') : '';
437
491
  $('save').disabled = state.saving || state.orderSaving || !state.graph || !state.dirty || state.graph.id === 'default';
438
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;
439
500
  $('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
440
501
  for (const id of ['duplicate', 'export', 'layout', 'fit']) $(id).disabled = !state.graph;
441
502
  $('duplicate').disabled = state.saving || state.orderSaving || !state.graph || !canCreateGraph();
503
+ if (viewOnly()) for (const id of ['layout', 'undo', 'redo']) $(id).disabled = true;
442
504
  renderLibrary();
443
505
  window.AndorraStudio?.heading?.();
444
506
  globalThis.AndorraManager?.heading?.();
@@ -496,10 +558,9 @@ function renderList() {
496
558
  const locked = graphLocked(graph.id);
497
559
  const button = el('button', undefined, `graph-row${state.graph?.id === graph.id ? ' active' : ''}${locked ? ' locked' : ''}`);
498
560
  button.disabled = state.saving;
499
- 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}`);
500
562
  button.append(el('span', graph.name), tag);
501
563
  if (locked) {
502
- button.setAttribute('aria-disabled', 'true');
503
564
  button.title = FREE_LOCKED_TIP;
504
565
  const glyph = globalThis.AndorraIcons?.icon?.('lock', 12);
505
566
  if (glyph) tag.prepend(glyph);
@@ -549,7 +610,7 @@ function renderList() {
549
610
  const button = el('button', undefined, `graph-row draft-row${locked ? ' locked' : ''}`); button.disabled = state.saving;
550
611
  const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
551
612
  const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
552
- button.title = locked ? FREE_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
613
+ button.title = locked ? FREE_DRAFT_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
553
614
  if (locked) { button.setAttribute('aria-disabled', 'true'); const glyph = globalThis.AndorraIcons?.icon?.('lock', 12); if (glyph) when.prepend(glyph); }
554
615
  button.append(el('span', draft.name), when);
555
616
  button.onclick = () => openDraft(draft.snapshot, draft.graphId);
@@ -634,7 +695,7 @@ function showMenuAt(x, y, ariaLabel, items) {
634
695
  }
635
696
  function showGraphMenu(graph, x, y) {
636
697
  const items = [
637
- ...(graphLocked(graph.id) ? [] : [{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) }]),
698
+ { label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) },
638
699
  { label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
639
700
  ];
640
701
  if (graph.id !== 'default') items.push({ label: 'Delete', icon: 'trash', danger: true, run: () => { deleteGraph(graph).catch(error => status(error.message, true)); } });
@@ -648,7 +709,7 @@ function showNewGraphMenu(x, y) {
648
709
  }
649
710
  async function exportGraph(graph) {
650
711
  if (window.AndorraEmbed?.hostChrome?.() && window.AndorraEmbed.exportGraph) { window.AndorraEmbed.exportGraph(graph.id); return; }
651
- if (state.saving) { status('Wait for the current save before exporting a graph.'); return; }
712
+ if (state.saving) { status('Wait for the current save before exporting a graph.', 'notice'); return; }
652
713
  downloadGraph(dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(graph.id)}`)));
653
714
  }
654
715
  function exportFileName(graph) {
@@ -662,16 +723,19 @@ function downloadJson(value, stem) {
662
723
  setTimeout(() => URL.revokeObjectURL(url), 1000);
663
724
  }
664
725
  async function duplicateGraph(source) {
665
- 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; }
666
727
  state.saving = true; renderHeading(); renderList();
667
728
  let created;
668
729
  let orderSaveError;
669
730
  try {
670
731
  const saved = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(source.id)}`));
732
+ const refusal = freeCopyRefusal(saved);
733
+ if (refusal) throw new Error(refusal);
671
734
  const suffix = ' (Copy)', base = saved.name || 'Untitled graph';
672
735
  const name = base.length + suffix.length > 200 ? base.slice(0, 200 - suffix.length).trimEnd() + suffix : base + suffix;
673
736
  const duplicate = { ...saved, id: newId(), name, revision: 0 };
674
737
  const stored = await api('/api/graphs', duplicate);
738
+ if (freeTier()) state.plan.freeGraphId = stored.id;
675
739
  created = { id: stored.id, name: stored.name };
676
740
  const summary = { id: stored.id, name: stored.name, revision: stored.revision };
677
741
  state.graphs.push(summary);
@@ -685,7 +749,7 @@ async function duplicateGraph(source) {
685
749
  if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in Graph settings.`);
686
750
  }
687
751
  async function deleteGraph(graph) {
688
- 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; }
689
753
  if (!await askConfirm({ title: `Delete “${graph.name}”?`, message: 'Its versions and drafts are removed from this machine.', confirmLabel: 'Delete', tone: 'danger' })) return;
690
754
  state.saving = true; renderHeading(); renderList();
691
755
  if (!pendingDraft || pendingDraft.id === graph.id) { pendingDraft = null; clearTimeout(draftTimer); }
@@ -711,6 +775,10 @@ async function deleteGraph(graph) {
711
775
  if (state.graph?.id !== graph.id) status(`Deleted "${graph.name}".`);
712
776
  }
713
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); }
714
782
  const GRID_STEP = 20;
715
783
  const GRID_MIN_PX = 10;
716
784
  function transform() {
@@ -761,7 +829,7 @@ function renderCanvas() {
761
829
  const connected = new Set(state.graph.edges.map(edge => JSON.stringify([edge.source, edgeOutcome(edge)])));
762
830
  const errorIds = nodeErrorIds();
763
831
  nodes.forEach((node, index) => {
764
- const p = positions.get(node.id), button = el('div', undefined, `node ${node.type}${selectedNodes().some(item=>item.id===node.id) ? ' selected' : ''}${errorIds.has(node.id) ? ' node-error' : ''}${state.routePick && !state.routePick.sources.includes(node.id) && node.agentRole !== 'orchestrator' ? ' route-target' : ''}`);
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' : ''}`);
765
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' : ''}`);
766
834
  const title = el('div', undefined, 'node-title'), glyph = nodeIconElement(node);
767
835
  if (glyph) title.append(glyph);
@@ -803,7 +871,7 @@ function measureBoxes() {
803
871
  Object.values(state.graph.nodes).forEach((node, index) => {
804
872
  const element = elements.get(node.id), p = position(node, index);
805
873
  if (!element) return;
806
- 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);
807
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 })) });
808
876
  });
809
877
  return boxes;
@@ -811,7 +879,7 @@ function measureBoxes() {
811
879
  function routeInput(edge, boxes) {
812
880
  const from = boxes.get(edge.source), to = boxes.get(edge.target); if (!from || !to) return null;
813
881
  const source = from.ports[Math.max(0, outcomes(state.graph.nodes[edge.source]).indexOf(edgeOutcome(edge)))];
814
- return source ? { source, target: { x: to.x, y: to.y + 48 } } : null;
882
+ return source ? { source, target: { x: to.x, y: to.y + PORT_Y } } : null;
815
883
  }
816
884
  const drawnRoute = points => points && { d: (AndorraEdgeRouter.roundedPath || AndorraEdgeRouter.path)(points), label: AndorraEdgeRouter.labelPoint?.(points) };
817
885
  function dragFrame(node, boxes) {
@@ -1633,6 +1701,7 @@ function retryLimitHelp(parent, graph) {
1633
1701
  }
1634
1702
  function renderInspector() {
1635
1703
  document.body?.classList?.remove?.('prompt-fullscreen'); for (const backdrop of document.querySelectorAll?.('.prompt-backdrop') ?? []) backdrop.remove();
1704
+ syncInspectorOverlay();
1636
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; }
1637
1706
  if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
1638
1707
  const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : 'Graph settings';
@@ -1643,7 +1712,7 @@ function renderInspector() {
1643
1712
  else if (!node) {
1644
1713
  const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
1645
1714
  field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
1646
- const meta = el('p', `${graph.id} · Version ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
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);
1647
1716
  if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
1648
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.');
1649
1718
  field(general, 'Description', graph.metadata?.description, value => {graph.metadata={...graph.metadata,description:value};}, {multiline:true,maxLength:2000});
@@ -1707,16 +1776,17 @@ function renderInspector() {
1707
1776
  }
1708
1777
  function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas(); renderInspector(); scheduleValidation(); queueDraft(); }
1709
1778
  async function openGraph(id, options = {}) {
1710
- if (state.saving) { status('Wait for the current save before opening another graph.'); return false; }
1711
- if (graphLocked(id)) { status(FREE_LOCKED_TIP, true); return false; }
1779
+ if (state.saving) { status('Wait for the current save before opening another graph.', 'notice'); return false; }
1712
1780
  if (state.dirty && !options.discard && !await askConfirm(DISCARD_QUESTION)) return false;
1713
- try { const opened = options.fetched === undefined ? await api(`/api/graphs/${encodeURIComponent(id)}`) : options.fetched; const capMoved = hasSubagentCap(opened); state.graph = dropLegacyTokenFields(opened); const migrated = state.graph.editorMigration === true; state.dirty = migrated || capMoved; delete state.graph.editorMigration; markSaved(state.dirty ? null : state.graph); clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(migrated ? 'This graph was updated to the current format. Save to keep it.' : capMoved ? 'Orchestrator Max subagents moved to Advanced > Subagents. Save to keep it.' : 'Graph loaded'); graphOpened(options.reason || 'open'); return true; } catch (error) { status(error.message, true); return false; }
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; }
1714
1782
  }
1715
1783
  function newId() { return `graph-${crypto.randomUUID()}`; }
1716
1784
  function newGraph(duplicate = false, discarded = false) {
1717
- 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; }
1718
1786
  if (!canCreateGraph()) { status(FREE_CREATE_TIP, true); return; }
1787
+ if (duplicate) { const refusal = freeCopyRefusal(state.graph); if (refusal) { status(refusal, true); return; } }
1719
1788
  if (state.dirty && !discarded) { void askConfirm(DISCARD_QUESTION).then(discard => { if (discard) newGraph(duplicate, true); }); return; }
1789
+ state.viewOnlySource = null;
1720
1790
  if (duplicate) state.graph={...copy(state.graph),id:newId(),name:`${state.graph.name} copy`,revision:0};
1721
1791
  else if (freeTier()) {
1722
1792
  const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
@@ -2016,7 +2086,7 @@ function animateView(target, anchor) {
2016
2086
  }
2017
2087
  function fit(animate = false) {
2018
2088
  if (!state.graph) return; const nodes = Object.values(state.graph.nodes); if (!nodes.length) return;
2019
- const positions = nodes.map(position), minX = Math.min(...positions.map(p => p.x)), minY = Math.min(...positions.map(p => p.y)), maxX = Math.max(...positions.map(p => p.x)) + 210, maxY = Math.max(...positions.map(p => p.y)) + Math.max(...nodes.map(n => 94 + outcomes(n).length * 25));
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)));
2020
2090
  const zoomed = Math.min(1, Math.max(.2, Math.min(($('canvas').clientWidth - 90) / (maxX - minX), ($('canvas').clientHeight - 170) / (maxY - minY))));
2021
2091
  const target = { zoom: zoomed, x: ($('canvas').clientWidth - (maxX - minX) * zoomed) / 2 - minX * zoomed, y: ($('canvas').clientHeight - (maxY - minY) * zoomed) / 2 - minY * zoomed };
2022
2092
  if (animate) { animateView(target); return; }
@@ -2033,8 +2103,15 @@ function zoomBy(factor) {
2033
2103
  }
2034
2104
  $('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('empty-create').onclick = () => newGraph(); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
2035
2105
  $('node-search').oninput = renderLibrary;
2036
- $('graph-settings').onclick = () => { clearSelection(); renderCanvas(); renderInspector(); };
2037
- $('toggle-inspector').onclick = () => { const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden)); };
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
+ }
2038
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'); };
2039
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'); };
2040
2117
  function pulseErrorNodes() {
@@ -2058,7 +2135,7 @@ $('save').onclick = async () => {
2058
2135
  let orderFailed = false;
2059
2136
  try { const submitted = dropLegacyTokenFields(copy(state.graph)); const graph = await api('/api/graphs', submitted); if (state.graph.id === submitted.id) {
2060
2137
  const liveView = { ...state.graph }; delete liveView.pendingProviderNodes;
2061
- const edited = JSON.stringify(liveView) !== JSON.stringify(submitted); markSaved(graph); if (edited) { state.graph.revision = graph.revision; adoptServerStamps(graph); state.undo = []; state.redo = []; refreshDirty(); } else { state.graph = graph; state.dirty = false; state.undo = []; state.redo = []; } retireSatisfiedProviderRequirements(); } const index = state.graphs.findIndex(g => g.id === graph.id); const summary = { id: graph.id, name: graph.name, revision: graph.revision }; if (index >= 0) state.graphs[index] = summary; else { state.graphs.push(summary); try { await persistGraphOrder(); } catch { orderFailed = true; } } render(); status(`Saved version ${graph.revision}${state.dirty ? ' · You have newer unsaved changes' : ''}${orderFailed ? ' · Graph order not saved' : ''}`); } catch (error) { status(error.message, true); } finally { state.saving = false; renderHeading(); renderList(); }
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(); }
2062
2139
  };
2063
2140
  $('canvas-hint-close').onclick = dismissCanvasHint;
2064
2141
  $('fit').onclick = () => fit(true); $('zoom-in').onclick = () => zoomBy(1.2); $('zoom-out').onclick = () => zoomBy(1 / 1.2);
@@ -2095,7 +2172,7 @@ $('canvas').ondrop = event => {
2095
2172
  const file = Array.from(event.dataTransfer?.files || []).find(item => /\.json$/i.test(item.name) || item.type === 'application/json');
2096
2173
  if (file) { event.preventDefault(); void window.AndorraStudio?.importGraphFile?.(file)?.catch(error => status(error.message, true)); }
2097
2174
  };
2098
- $('canvas').onpointerdown = event => { if (event.button !== 0 || event.target.closest('button, .node, path, .canvas-hint')) return; dismissCanvasHint(); stopViewAnimation(); const start = { x: event.clientX - state.x, y: event.clientY - state.y }; $('canvas').setPointerCapture(event.pointerId); $('canvas').onpointermove = e => { state.x = e.clientX - start.x; state.y = e.clientY - start.y; requestTransform(); }; $('canvas').onpointerup = () => { $('canvas').onpointermove = null; }; };
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(); }; };
2099
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; }; };
2100
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`); };
2101
2178
  $('export').onclick = () => { if (!state.graph) return; downloadGraph(state.graph); };
@@ -2104,7 +2181,7 @@ if (typeof document.addEventListener === 'function') {
2104
2181
  }
2105
2182
  window.addEventListener('pagehide', () => { void flushDraft(true); });
2106
2183
  window.addEventListener('beforeunload', event => { document.activeElement?.blur(); if (state.dirty) { event.preventDefault(); event.returnValue = ''; } });
2107
- window.addEventListener('keydown', event => { if(event.key==='Delete' && !document.querySelector('dialog[open]') && !event.target?.closest('input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])') && !event.isComposing) {event.preventDefault();deleteSelection();return;} if(event.key==='Escape' && state.routePick){event.preventDefault();cancelRoutePick();return;} if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') { event.preventDefault(); document.activeElement?.blur(); if (!$('save').disabled) $('save').click(); } });
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(); } });
2108
2185
  async function refreshCloudState() {
2109
2186
  if (!token) return;
2110
2187
  const orderSavingDuringSync = state.orderSaving;
@@ -2190,4 +2267,4 @@ setFavicon('idle');
2190
2267
  if (token) watchActivity();
2191
2268
  try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { }
2192
2269
 
2193
- (async () => { renderHeading(); if (!token) { status('The sign-in token is missing. Open this app with the andorra graph command.', true); return; } try { const data = await api('/api/bootstrap'); state.plan = data.plan; state.graphs = data.graphs; applyProviderRegistry(data); state.tools = data.tools || []; state.definitions = foldDefinitionCaps(data.definitions); renderLibrary(); renderList(); const wantsNew = new URLSearchParams(location.search).get('new') === '1'; if (wantsNew && canCreateGraph()) newGraph(); else if (!wantsNew && await reopenRemembered()) { } else if (state.graphs.length) { await openGraph((freeTier() && state.plan.freeGraphId) || state.graphs[0].id); if (wantsNew) status(FREE_CREATE_TIP, true); } else { render(); status('Create your first graph'); } window.AndorraEmbed?.ready?.(); if (data.graphMigrationErrors?.length) status('Some saved graphs could not be opened: ' + data.graphMigrationErrors.map(item => item.name + ' (' + item.id + '): ' + item.error).join('; ') + '. Their saved versions are unchanged.', true); } catch (error) { status(error.message, true); } })();
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; }
@@ -218,7 +218,7 @@
218
218
  .then(result => { status(result.error, true); return result; });
219
219
  }
220
220
  return requestExport({ type: 'andorra.graph.export', graphId }).then(result => {
221
- if (result.ok && result.path) status(`Exported to ${result.path}`);
221
+ if (result.ok && result.path) status(`Exported to ${result.path}`, 'notice');
222
222
  else status(result.error || 'The export failed.', true);
223
223
  return result;
224
224
  });
@@ -229,7 +229,7 @@
229
229
  .then(result => { status(result.error, true); return result; });
230
230
  }
231
231
  return requestExport({ type: 'andorra.graph.agent.export', agentId }).then(result => {
232
- if (result.ok && result.path) status(`Agent shared to ${result.path}`);
232
+ if (result.ok && result.path) status(`Agent shared to ${result.path}`, 'notice');
233
233
  else status(result.error || 'The Agent could not be shared.', true);
234
234
  return result;
235
235
  });
@@ -30,6 +30,7 @@ globalThis.AndorraIcons = (() => {
30
30
  magnet: '<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>',
31
31
  more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',
32
32
  'panel-right': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/>',
33
+ 'panel-left': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>',
33
34
  flask: '<path d="M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"/><path d="M8.5 2h7"/><path d="M7 16h10"/>',
34
35
  activity: '<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>',
35
36
  copy: '<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',
@@ -3,5 +3,5 @@
3
3
  <head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Graph Editor · Andorra Code</title><link rel="icon" type="image/png" href="/andorra-logo.png"><link rel="stylesheet" href="/tokens.css"><link rel="stylesheet" href="/style.css"><link rel="stylesheet" href="/library.css"><link rel="stylesheet" href="/studio.css"><link rel="stylesheet" href="/controls.css"><link rel="stylesheet" href="/manager.css"><script src="/theme.js"></script></head>
4
4
  <body>
5
5
  <aside class="rail" id="library-rail"><div id="rail-resize" role="separator" aria-label="Resize library sidebar" aria-orientation="vertical" aria-controls="library-rail" tabindex="0"></div><div class="rail-caption" aria-hidden="true"></div><div class="rail-body" tabindex="0" aria-label="Graph and step library"><div class="section-label">Your graphs <button id="new-graph" aria-label="Create graph" title="Create graph" data-icon="plus"></button></div><div class="rail-search"><input id="search" type="search" placeholder="Find a graph" aria-label="Find a graph"></div><nav id="graphs" aria-label="Graphs" tabindex="0"></nav><div class="section-label library-label">Step library</div><div class="rail-search"><input id="node-search" type="search" placeholder="Search steps…" aria-label="Search steps"></div><nav id="node-library" aria-label="Step library"></nav><p class="hint">Drag a step onto the canvas, or select it and press Enter to add it. Connect each outcome to one or more destinations.</p></div><footer class="rail-footer">Your account <span id="sync-status" role="status">Saved locally; cloud sync pending</span></footer></aside>
6
- <main><header class="chrome"><div id="host-chrome" class="host-chrome" hidden></div><div class="graph-heading"><strong id="graph-title">Graph Editor</strong><span id="revision">Loading graphs…</span><span id="host-notice" class="chip chip-accent" role="status" hidden></span></div><div class="chrome-actions" id="chrome-actions"><button id="toggle-inspector" class="icon-button" aria-expanded="true" aria-label="Inspector" title="Show or hide the inspector" data-icon="panel-right"></button><div class="menu" id="more-wrap"><button id="more" class="icon-button" aria-haspopup="menu" aria-expanded="false" aria-controls="more-menu" aria-label="More actions" title="More actions" data-icon="more"></button><div id="more-menu" class="menu-list" role="menu" aria-label="More actions" hidden><button id="duplicate" type="button" role="menuitem" data-icon="copy">Duplicate</button></div></div><div class="manager-anchor" hidden><button id="graph-manager" class="btn-small studio-secondary" type="button" aria-label="Graph Manager" aria-expanded="false" aria-controls="manager-panel" title="Build or change this graph with Graph Manager" data-icon="bot" hidden><span>Graph Manager</span></button><div id="manager-tip" class="manager-tip" role="note" hidden><span>Let Graph Manager build this graph with you.</span><button id="manager-tip-close" type="button" class="icon-button" aria-label="Dismiss" title="Dismiss" data-icon="x"></button></div></div><button id="save" class="primary btn-small">Save</button></div></header><div class="workspace"><section id="canvas" aria-label="Graph canvas"><div id="scene"><svg id="edges" aria-label="Graph connections"></svg><div id="nodes"></div></div><div id="empty"><div class="empty-state"><span class="empty-state-icon" data-icon="graph"></span><p class="empty-state-title">No graph open</p><p class="empty-state-line">Create a graph to get started.</p><div class="empty-state-action"><button id="empty-create" type="button" class="primary btn-small">Create Graph</button></div></div></div><div id="canvas-hint" class="canvas-hint" role="note"><span id="canvas-hint-text">Drag or scroll to pan · Pinch or Ctrl/Cmd+scroll to zoom</span><button id="canvas-hint-close" type="button" class="icon-button" aria-label="Dismiss canvas tips" title="Dismiss" data-icon="x"></button></div><div class="canvas-toolbar" role="toolbar" aria-label="Canvas controls"><button id="undo" aria-label="Undo" title="Undo (Ctrl/Cmd+Z)" data-icon="undo"></button><button id="redo" aria-label="Redo" title="Redo (Ctrl/Cmd+Y)" data-icon="redo"></button><span class="toolbar-divider" aria-hidden="true"></span><button id="zoom-out" aria-label="Zoom out" title="Zoom out" data-icon="zoom-out"></button><output id="zoom" aria-label="Zoom level">100%</output><button id="zoom-in" aria-label="Zoom in" title="Zoom in" data-icon="zoom-in"></button><button id="fit" aria-label="Fit graph" title="Fit graph" data-icon="fit"></button><button id="layout" aria-label="Arrange" title="Arrange steps" data-icon="arrange"></button></div></section><aside id="inspector"><div id="resize" role="separator" aria-label="Resize inspector" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong id="inspector-title">Graph settings</strong><button id="graph-settings" class="btn-small" title="Show the graph's own settings">Graph Settings</button></header><div id="inspector-body"></div></aside><aside id="manager-panel" aria-label="Graph Manager" hidden><div id="manager-resize" role="separator" aria-label="Resize Graph Manager" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong>Graph Manager</strong><span class="manager-header-actions"><button id="manager-new-chat" type="button" class="btn-small" title="Start a new conversation. The current one stays in your history.">New Chat</button><button id="manager-close" type="button" class="icon-button" aria-label="Close Graph Manager" title="Close" data-icon="x"></button></span></header><div class="manager-models" id="manager-models"></div><div id="manager-notices"></div><div id="manager-transcript" role="log" aria-label="Graph Manager conversation" tabindex="0"></div><footer class="manager-composer"><textarea id="manager-input" rows="3" placeholder="Ask Graph Manager to build or change this graph" aria-label="Message Graph Manager"></textarea><div class="manager-composer-actions"><span id="manager-run-state" role="status"></span><button id="manager-stop" type="button" class="btn-small" hidden>Stop</button><button id="manager-send" type="button" class="primary btn-small">Send</button></div></footer></aside></div><footer class="status"><span id="status" role="status" aria-live="polite">Connecting to your workspace…</span><span class="status-actions"><button id="theme-toggle" type="button" hidden>Light</button><button id="export">Export JSON</button></span></footer></main>
6
+ <main><header class="chrome"><div id="host-chrome" class="host-chrome" hidden></div><button id="toggle-library" class="icon-button" type="button" aria-expanded="true" aria-controls="library-rail" aria-label="Library" title="Show or hide the library" data-icon="panel-left"></button><div class="graph-heading"><strong id="graph-title">Graph Editor</strong><span id="revision">Loading graphs…</span><span id="host-notice" class="chip chip-accent" role="status" hidden></span></div><div class="chrome-actions" id="chrome-actions"><div class="manager-anchor" hidden><button id="graph-manager" class="btn-small studio-secondary" type="button" aria-label="Graph Manager" aria-expanded="false" aria-controls="manager-panel" title="Build or change this graph with Graph Manager" data-icon="bot" hidden><span>Graph Manager</span></button><div id="manager-tip" class="manager-tip" role="note" hidden><span>Let Graph Manager build this graph with you.</span><button id="manager-tip-close" type="button" class="icon-button" aria-label="Dismiss" title="Dismiss" data-icon="x"></button></div></div><div class="menu" id="more-wrap"><button id="more" class="icon-button" aria-haspopup="menu" aria-expanded="false" aria-controls="more-menu" aria-label="More actions" title="More actions" data-icon="more"></button><div id="more-menu" class="menu-list" role="menu" aria-label="More actions" hidden><button id="duplicate" type="button" role="menuitem" data-icon="copy">Duplicate</button><button id="export" type="button" role="menuitem" data-icon="download">Export JSON</button></div></div><button id="toggle-inspector" class="icon-button" aria-expanded="true" aria-label="Inspector" title="Show or hide the inspector" data-icon="panel-right"></button><span id="save-state" class="save-state" hidden>Saved</span><button id="save" class="primary btn-small" hidden>Save</button></div></header><div class="workspace"><section id="canvas" aria-label="Graph canvas"><div id="scene"><svg id="edges" aria-label="Graph connections"></svg><div id="nodes"></div></div><div id="empty"><div class="empty-state"><span class="empty-state-icon" data-icon="graph"></span><p class="empty-state-title">No graph open</p><p class="empty-state-line">Create a graph to get started.</p><div class="empty-state-action"><button id="empty-create" type="button" class="primary btn-small">Create Graph</button></div></div></div><div id="canvas-hint" class="canvas-hint" role="note"><span id="canvas-hint-text">Drag or scroll to pan · Pinch or Ctrl/Cmd+scroll to zoom</span><button id="canvas-hint-close" type="button" class="icon-button" aria-label="Dismiss canvas tips" title="Dismiss" data-icon="x"></button></div><div class="canvas-toolbar" role="toolbar" aria-label="Canvas controls"><button id="undo" aria-label="Undo" title="Undo (Ctrl/Cmd+Z)" data-icon="undo"></button><button id="redo" aria-label="Redo" title="Redo (Ctrl/Cmd+Y)" data-icon="redo"></button><span class="toolbar-divider" aria-hidden="true"></span><button id="zoom-out" aria-label="Zoom out" title="Zoom out" data-icon="zoom-out"></button><output id="zoom" aria-label="Zoom level">100%</output><button id="zoom-in" aria-label="Zoom in" title="Zoom in" data-icon="zoom-in"></button><button id="fit" aria-label="Fit graph" title="Fit graph" data-icon="fit"></button><button id="layout" aria-label="Arrange" title="Arrange steps" data-icon="arrange"></button></div></section><aside id="inspector"><div id="resize" role="separator" aria-label="Resize inspector" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong id="inspector-title">Graph settings</strong><button id="graph-settings" class="btn-small" title="Show the graph's own settings">Graph Settings</button></header><div id="inspector-body"></div></aside><aside id="manager-panel" aria-label="Graph Manager" hidden><div id="manager-resize" role="separator" aria-label="Resize Graph Manager" aria-orientation="vertical" tabindex="0"></div><header class="panel-header"><strong>Graph Manager</strong><span class="manager-header-actions"><button id="manager-new-chat" type="button" class="btn-small" title="Start a new conversation. The current one stays in your history.">New Chat</button><button id="manager-close" type="button" class="icon-button" aria-label="Close Graph Manager" title="Close" data-icon="x"></button></span></header><div class="manager-models" id="manager-models"></div><div id="manager-notices"></div><div id="manager-transcript" role="log" aria-label="Graph Manager conversation" tabindex="0"></div><footer class="manager-composer"><textarea id="manager-input" rows="3" placeholder="Ask Graph Manager to build or change this graph" aria-label="Message Graph Manager"></textarea><div class="manager-composer-actions"><span id="manager-run-state" role="status"></span><button id="manager-stop" type="button" class="btn-small" hidden>Stop</button><button id="manager-send" type="button" class="primary btn-small">Send</button></div></footer></aside></div><span id="status" class="visually-hidden" role="status" aria-live="polite">Connecting to your workspace…</span><div id="toasts" class="toasts" aria-live="off"></div></main>
7
7
  <script src="/compat.js" defer></script><script src="/icons.js" defer></script><script src="/controls.js" defer></script><script src="/skill-picker.js" defer></script><script src="/model-picker.js" defer></script><script src="/edge-router.js" defer></script><script src="/drafts.js" defer></script><script src="/app.js" defer></script><script src="/manager-markdown.js" defer></script><script src="/manager-state.js" defer></script><script src="/manager.js" defer></script><script src="/embed.js" defer></script><script src="/sidebar.js" defer></script><script src="/studio.js" defer></script><script src="/studio-canvas.js" defer></script></body></html>
@@ -132,7 +132,7 @@ button.manager-fold-head::after {
132
132
  .manager-composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
133
133
  #manager-run-state { flex: 1; min-width: 0; font-size: var(--type-xs); color: var(--text-3); }
134
134
 
135
- @media (max-width: 1180px) {
135
+ @media (max-width: 1100px) {
136
136
  #manager-panel { width: min(var(--manager-panel, 380px), 60%); }
137
137
  .workspace.manager-open #inspector { right: min(var(--manager-panel, 380px), 60%); width: min(var(--panel), calc(40% - 24px)); }
138
138
  }
@@ -412,7 +412,7 @@ globalThis.AndorraManager = (() => {
412
412
  if (event.edit.kind === 'edge.remove') agentEdges.set(event.edit.edgeId, 'null');
413
413
  if (event.edit.kind === 'graph') for (const [key, value] of Object.entries(event.edit.patch)) agentFields[key] = JSON.stringify(value);
414
414
  if (!edit) {
415
- if (kept.length) { sentCanvas = null; status('Graph Manager changed something you also edited; your own edits were kept.'); }
415
+ if (kept.length) { sentCanvas = null; status('Graph Manager changed something you also edited; your own edits were kept.', 'notice'); }
416
416
  return;
417
417
  }
418
418
  const trial = JSON.parse(JSON.stringify(graph));
@@ -446,7 +446,7 @@ globalThis.AndorraManager = (() => {
446
446
  if (createdOffer?.id === event.graphId) createdOffer = null;
447
447
  if (state.graph?.id !== event.graphId) return;
448
448
  offeredRevision = null;
449
- status('Graph Manager deleted this graph.');
449
+ status('Graph Manager deleted this graph.', 'notice');
450
450
  }
451
451
  async function openCreated(offer) {
452
452
  if (!await openGraph(offer.id) || state.graph?.id !== offer.id) { renderNotices(); return; }
@@ -57,4 +57,34 @@
57
57
  region.addEventListener('scroll', reveal, {passive:true});
58
58
  region.addEventListener('wheel', reveal, {passive:true});
59
59
  }
60
+
61
+ // Under 1100px the library collapses to the header's toggle and opens over the canvas until dismissed.
62
+ const toggle = document.getElementById('toggle-library');
63
+ const narrow = typeof matchMedia === 'function' ? matchMedia('(max-width: 1100px)') : undefined;
64
+ const body = document.body;
65
+ if (!toggle || !narrow || !body) return;
66
+ const embedded = !!window.parent && window.parent !== window;
67
+ let open = false;
68
+ const sync = () => {
69
+ const shown = !narrow.matches || open;
70
+ body.classList.toggle('library-collapsed', !shown);
71
+ body.classList.toggle('library-overlay', narrow.matches && open);
72
+ toggle.setAttribute('aria-expanded', String(shown));
73
+ };
74
+ const setOpen = next => { open = next; sync(); };
75
+ toggle.addEventListener('click', () => setOpen(!open));
76
+ if (typeof narrow.addEventListener === 'function') narrow.addEventListener('change', () => setOpen(false));
77
+ else narrow.addListener?.(() => setOpen(false));
78
+ document.addEventListener('pointerdown', event => {
79
+ if (open && narrow.matches && !rail.contains(event.target) && !toggle.contains(event.target) && !event.target?.closest?.('.graph-context, dialog')) setOpen(false);
80
+ }, true);
81
+ rail.addEventListener('click', event => { if (open && narrow.matches && event.target?.closest?.('.graph-row:not(.locked), .library-item:not(:disabled)')) setOpen(false); });
82
+ window.addEventListener('keydown', event => {
83
+ if (!narrow.matches || event.defaultPrevented) return;
84
+ if (event.key === 'Escape' && open && !document.querySelector?.('dialog[open]')) { setOpen(false); toggle.focus(); return; }
85
+ // Framed in the desktop app, Ctrl/Cmd+B belongs to the app's own sidebar (embed.js forwards it).
86
+ const typing = event.target?.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])');
87
+ if (!embedded && !typing && (event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.key?.toLowerCase() === 'b') { event.preventDefault(); setOpen(!open); }
88
+ });
89
+ sync();
60
90
  })();