@andorra-labs/code 0.1.10 → 0.1.11
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.
- package/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +36 -0
- package/dist/src/app-server/protocol.d.ts +1 -0
- package/dist/src/app-server.d.ts +34 -1
- package/dist/src/app-server.js +264 -54
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +8 -0
- package/dist/src/completion.js +19 -1
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/graph-manager-chat.js +13 -13
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-server.js +9 -9
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +262 -93
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +4 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +11 -11
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +3 -2
- package/dist/src/graphs.js +3 -2
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/react-runtime.js +121 -14
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/terminal-ui.js +2 -2
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
package/dist/src/graph-ui/app.js
CHANGED
|
@@ -17,14 +17,15 @@ const themeColor = (token, fallback) => {
|
|
|
17
17
|
// its outcome: an outcome is not a failure, and colouring "blocked" or "pass" made a resting graph
|
|
18
18
|
// read as a status board. The one red on the canvas is a run route into a node that failed
|
|
19
19
|
// (studio.css). The outcome's pill is outlined in the hairline with muted ink; the halo is the
|
|
20
|
-
// canvas ground, so a crossing stays legible. Each fallback is the dark token's own value
|
|
20
|
+
// canvas ground, so a crossing stays legible. Each fallback is the dark token's own value
|
|
21
|
+
// (desktop/src/styles/tokens.css), for a page that has not loaded the stylesheet.
|
|
21
22
|
const connectionPalette = () => ({
|
|
22
|
-
line: themeColor('--text-3', '
|
|
23
|
-
active: themeColor('--accent', '#
|
|
24
|
-
halo: themeColor('--canvas-bg', '#
|
|
25
|
-
pill: themeColor('--bg-input', '#
|
|
26
|
-
pillEdge: themeColor('--border', '
|
|
27
|
-
pillInk: themeColor('--text-2', '
|
|
23
|
+
line: themeColor('--text-3', 'rgba(245,245,245,.60)'),
|
|
24
|
+
active: themeColor('--accent', '#ececec'),
|
|
25
|
+
halo: themeColor('--canvas-bg', '#191919'),
|
|
26
|
+
pill: themeColor('--bg-input', '#1f1f1f'),
|
|
27
|
+
pillEdge: themeColor('--border', 'rgba(245,245,245,.08)'),
|
|
28
|
+
pillInk: themeColor('--text-2', 'rgba(245,245,245,.74)'),
|
|
28
29
|
});
|
|
29
30
|
/** The connection's stroke at rest and while it is traced (hovered, focused or selected). */
|
|
30
31
|
const EDGE_WIDTH = '1.5', EDGE_ACTIVE_WIDTH = '2';
|
|
@@ -53,19 +54,29 @@ function closeDialog(dialog) {
|
|
|
53
54
|
const controls = globalThis.AndorraControls;
|
|
54
55
|
if (typeof controls?.closeDialog === 'function') controls.closeDialog(dialog); else dialog.close();
|
|
55
56
|
}
|
|
56
|
-
const DISCARD_QUESTION = { title: 'Discard unsaved changes?', message: 'Edits to this
|
|
57
|
+
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' };
|
|
57
58
|
function status(message, error = false) { $('status').textContent = message; $('status').parentElement.classList.toggle('error', error); }
|
|
58
59
|
// The free tier keeps one custom graph of up to three nodes (Done does not count) and leaves the
|
|
59
60
|
// Orchestrator to Premium. The server enforces the same rules on save; these keep the editor honest
|
|
60
61
|
// about them before the user builds something it cannot save.
|
|
61
|
-
const FREE_CREATE_TIP = 'Free tier includes 1 custom
|
|
62
|
-
const FREE_ORCHESTRATOR_TIP = 'The Orchestrator is a Premium feature. Free tier
|
|
62
|
+
const FREE_CREATE_TIP = 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.';
|
|
63
|
+
const FREE_ORCHESTRATOR_TIP = 'The Orchestrator is a Premium feature. Free tier graphs can use the other agents.';
|
|
63
64
|
function freeTier() { return state.plan?.paid === false; }
|
|
64
|
-
function freeNodeTip() { return `Free tier
|
|
65
|
+
function freeNodeTip() { return `Free tier graphs can have up to ${state.plan.nodeLimit} steps, not counting Done. Upgrade to Premium for larger graphs.`; }
|
|
65
66
|
function countedNodes(graph) { return Object.values(graph.nodes).filter(node => node.type !== 'end').length; }
|
|
66
67
|
function canCreateGraph() { return !freeTier() || state.graphs.filter(graph => graph.id !== 'default').length < state.plan.customGraphLimit; }
|
|
67
68
|
/** Whether a free account may save this graph: its kept graph, or a new one while it has none. */
|
|
68
69
|
function freeGraphEditable(graph) { return !freeTier() || (graph.revision ? graph.id === (state.plan.freeGraphId ?? state.graphs.find(item => item.id !== 'default')?.id) : canCreateGraph()); }
|
|
70
|
+
const FREE_LOCKED_TIP = 'On the free tier only your first custom graph is available. Upgrade to Premium to open this graph.';
|
|
71
|
+
/**
|
|
72
|
+
* Whether a free account's saved workflow is outside its allowance: neither the preset nor the one it
|
|
73
|
+
* keeps. The server refuses to run or save it, so the list shows it locked and the editor never opens it.
|
|
74
|
+
*/
|
|
75
|
+
function graphLocked(id) {
|
|
76
|
+
if (!freeTier() || id === 'default') return false;
|
|
77
|
+
const graph = state.graphs.find(item => item.id === id);
|
|
78
|
+
return Boolean(graph?.revision) && !freeGraphEditable(graph);
|
|
79
|
+
}
|
|
69
80
|
/** Why adding these nodes would leave the free allowance, or undefined. */
|
|
70
81
|
function freeNodeRefusal(added) {
|
|
71
82
|
if (!freeTier() || !state.graph) return undefined;
|
|
@@ -76,11 +87,90 @@ function freeNodeRefusal(added) {
|
|
|
76
87
|
async function api(path, body, options = {}) {
|
|
77
88
|
const response = await fetch(path, { method: options.method || (body ? 'POST' : 'GET'), headers: { Authorization: `Bearer ${token || ''}`, ...(body ? { 'Content-Type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}), ...(options.signal ? { signal: options.signal } : {}), ...(options.keepalive ? { keepalive: true } : {}) });
|
|
78
89
|
const data = await response.json();
|
|
79
|
-
if (!response.ok)
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
const message = typeof data.error === 'string' ? data.error : JSON.stringify(data.error || data);
|
|
92
|
+
// A graph the engine refused is explained in the editor's words, naming the step it is about.
|
|
93
|
+
const graph = body?.graph && typeof body.graph === 'object' ? body.graph : body?.nodes ? body : state.graph;
|
|
94
|
+
const plain = plainGraphError(message, graph);
|
|
95
|
+
throw Object.assign(new Error(plain.message), plain.nodeId ? { nodeId: plain.nodeId } : {});
|
|
96
|
+
}
|
|
80
97
|
return data;
|
|
81
98
|
}
|
|
99
|
+
// The engine's validation says "Invalid graph: node fixer: required outcome fail has no route; connect
|
|
100
|
+
// its output port": its own identifiers and words (node, entry, edge, limits.maxNodeVisits), meant for
|
|
101
|
+
// the CLI and the agents that read them. The editor says the same thing in the words its own controls
|
|
102
|
+
// use (ADR 0022 D13: a step, a connection, the starting step, Maximum visits per step) and names the
|
|
103
|
+
// step by its name. The messages the editor's controls can produce are written out; any other keeps
|
|
104
|
+
// the engine's sentence with those words swapped. Engine text that is not a validation passes through.
|
|
105
|
+
function plainGraphError(message, graph) {
|
|
106
|
+
const match = /^Invalid graph: ([\s\S]*)$/.exec(String(message));
|
|
107
|
+
if (!match) return { message: String(message), nodeId: null };
|
|
108
|
+
const nodes = graph && typeof graph.nodes === 'object' && graph.nodes ? graph.nodes : {};
|
|
109
|
+
const name = id => (typeof nodes[id]?.name === 'string' && nodes[id].name.trim()) || id;
|
|
110
|
+
const quoted = id => `“${name(id)}”`;
|
|
111
|
+
const words = text => text
|
|
112
|
+
.replace(/\bgraph limits\.maxNodeVisits\b/g, 'Maximum visits per step').replace(/\blimits\.maxNodeVisits\b/g, 'Maximum visits per step')
|
|
113
|
+
.replace(/\bthe (graph )?entry\b/g, 'the starting step').replace(/\bgraph entry\b/g, 'starting step')
|
|
114
|
+
.replace(/\bnodes\b/g, 'steps').replace(/\bnode\b/g, 'step').replace(/\bNodes\b/g, 'Steps').replace(/\bNode\b/g, 'Step')
|
|
115
|
+
.replace(/\bedges\b/g, 'connections').replace(/\bedge\b/g, 'connection').replace(/\boutput port\b/g, 'outcome');
|
|
116
|
+
const sentence = text => { const value = text.trim(); return value ? value.charAt(0).toUpperCase() + value.slice(1) + (/[.!?]$/.test(value) ? '' : '.') : value; };
|
|
117
|
+
const detail = match[1];
|
|
118
|
+
let found;
|
|
119
|
+
if (/^all nodes must be reachable from the entry/.test(detail)) {
|
|
120
|
+
// Which steps no connection reaches from the starting step: the engine does not say, the editor can.
|
|
121
|
+
const reached = new Set(), queue = graph?.entry && nodes[graph.entry] ? [graph.entry] : [];
|
|
122
|
+
while (queue.length) { const id = queue.shift(); if (reached.has(id)) continue; reached.add(id); for (const edge of graph?.edges || []) if (edge?.source === id && nodes[edge.target]) queue.push(edge.target); }
|
|
123
|
+
const lost = Object.keys(nodes).filter(id => !reached.has(id));
|
|
124
|
+
if (lost.length === 1) return { message: `Step ${quoted(lost[0])} is not connected. Connect it or remove it.`, nodeId: lost[0] };
|
|
125
|
+
if (lost.length > 1) return { message: `${lost.length} steps are not connected: ${lost.map(quoted).join(', ')}. Connect them or remove them.`, nodeId: lost[0] };
|
|
126
|
+
return { message: 'Every step must be reachable from the starting step. Connect or remove the steps that are not.', nodeId: null };
|
|
127
|
+
}
|
|
128
|
+
if (/^include an End node$/.test(detail)) return { message: 'Add an End step, so the graph has somewhere to finish.', nodeId: null };
|
|
129
|
+
if (/^include between 2 and 100 nodes/.test(detail)) return { message: 'A graph has between 2 and 100 steps, plus the Orchestrator.', nodeId: null };
|
|
130
|
+
if (/^entry must reference an existing node$/.test(detail)) return { message: 'Choose a starting step in Graph settings.', nodeId: null };
|
|
131
|
+
if (/^every edge must connect existing nodes$/.test(detail)) return { message: 'A connection leads to a step that no longer exists. Remove it.', nodeId: null };
|
|
132
|
+
if (/^unlimited graph cycle/.test(detail)) return { message: 'This graph can loop back forever. Set Maximum visits per step or a run time limit in Graph settings.', nodeId: null };
|
|
133
|
+
if ((found = /^node (\S+): required outcome (\S+) has no route/.exec(detail))) return { message: `${name(found[1])}: the “${found[2]}” outcome is not connected. Connect it to a step.`, nodeId: found[1] };
|
|
134
|
+
if ((found = /^edge \S+: nonexistent outcome (\S+)/.exec(detail))) return { message: `A connection starts from the outcome “${found[1]}”, which its step no longer has. Remove it or pick another outcome.`, nodeId: null };
|
|
135
|
+
if (/^duplicate edge /.test(detail)) return { message: 'Two connections join the same outcome to the same step. Remove one of them.', nodeId: null };
|
|
136
|
+
if ((found = /^Join (\S+) needs an incoming branch$/.exec(detail))) return { message: `${name(found[1])}: connect at least one step into this Join.`, nodeId: found[1] };
|
|
137
|
+
// A message about one step: "node <id>: …", "node <id> must …", or "Join <id>: …", "Agent <id>: …".
|
|
138
|
+
if ((found = /^(?:node|Join|Condition|Loop|Agent) (\S+?)(:\s*| )([\s\S]*)$/.exec(detail)) && nodes[found[1]]) {
|
|
139
|
+
return { message: `${name(found[1])}: ${sentence(words(found[3]))}`, nodeId: found[1] };
|
|
140
|
+
}
|
|
141
|
+
return { message: sentence(words(detail)), nodeId: null };
|
|
142
|
+
}
|
|
82
143
|
function checkpoint() { state.undo.push(copy(state.graph)); if (state.undo.length > 80) state.undo.shift(); state.redo = []; }
|
|
83
|
-
|
|
144
|
+
// The comparison form of a graph: keys sorted at every depth, so an edit that is undone by hand
|
|
145
|
+
// (a field cleared and typed back) compares equal even when its key moved in the object, and
|
|
146
|
+
// without the draft-only provider marker, which is editor state rather than graph content.
|
|
147
|
+
function graphKey(graph) {
|
|
148
|
+
const sorted = value => Array.isArray(value) ? value.map(sorted)
|
|
149
|
+
: value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, sorted(value[key])]))
|
|
150
|
+
: value;
|
|
151
|
+
const { pendingProviderNodes, ...content } = graph;
|
|
152
|
+
return JSON.stringify(sorted(content));
|
|
153
|
+
}
|
|
154
|
+
// Remember the open graph as the saved state. `null` marks a graph with no saved form to return to
|
|
155
|
+
// (new, duplicated, recovered from a draft, migrated, or replaced by an import), which stays
|
|
156
|
+
// unsaved until it is saved.
|
|
157
|
+
function markSaved(graph) { state.savedKey = graph ? graphKey(graph) : null; }
|
|
158
|
+
// Unsaved means the open graph differs from the saved state, not that some edit happened: edits
|
|
159
|
+
// that are undone, or reverted by hand, leave nothing to save. Back at the saved state, an
|
|
160
|
+
// autosave still waiting would record an edit that no longer exists, so it is cancelled.
|
|
161
|
+
function refreshDirty() {
|
|
162
|
+
state.dirty = !!state.graph && (state.savedKey == null || graphKey(state.graph) !== state.savedKey);
|
|
163
|
+
if (!state.dirty && pendingDraft && pendingDraft.id === state.graph?.id) { pendingDraft = null; clearTimeout(draftTimer); }
|
|
164
|
+
}
|
|
165
|
+
function changed() { scheduleValidation(); refreshDirty(); renderCanvas(); renderHeading(); renderValidation(); status(state.dirty ? 'Unsaved changes' : 'No unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
|
|
166
|
+
// The save stamps metadata only the server writes; edits kept across a save take those stamps, so
|
|
167
|
+
// reverting the kept edits returns the graph to exactly the version just saved.
|
|
168
|
+
function adoptServerStamps(saved) {
|
|
169
|
+
for (const key of ['updatedAt', 'createdAt']) {
|
|
170
|
+
if (saved.metadata?.[key] !== undefined) state.graph.metadata = { ...state.graph.metadata, [key]: saved.metadata[key] };
|
|
171
|
+
else if (state.graph.metadata) delete state.graph.metadata[key];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
84
174
|
let draftTimer, pendingDraft, draftWrite;
|
|
85
175
|
// How long editing must pause before a draft is written. Every draft is a snapshot the account
|
|
86
176
|
// keeps, so a pause shorter than this would store one per keystroke burst.
|
|
@@ -135,9 +225,11 @@ function restoreImportRequirements(graph) {
|
|
|
135
225
|
if (owed.size) graph.pendingProviderNodes = [...owed]; else delete graph.pendingProviderNodes;
|
|
136
226
|
return owed.size ? owed : null;
|
|
137
227
|
}
|
|
138
|
-
|
|
228
|
+
/** Open a draft snapshot; `graphId` names the saved workflow it belongs to, refused when that one is locked. */
|
|
229
|
+
async function openDraft(snapshot, graphId) {
|
|
230
|
+
if (graphLocked(graphId)) { status(FREE_LOCKED_TIP, true); return; }
|
|
139
231
|
if (state.dirty && !await askConfirm({ title: 'Open the saved draft?', message: 'Current edits are retained in draft history.', confirmLabel: 'Open Draft' })) return;
|
|
140
|
-
try { const graph = foldGraphSubagentCaps(await api(`/api/drafts/${snapshot}`)); const owed = restoreImportRequirements(graph); state.graph = graph; state.dirty = true; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = owed; render(); fit(); status(owed ? 'Recovered imported draft. Assign a model profile to every outlined step, then save.' : 'Recovered draft. Save when valid, or duplicate if its base version changed.'); graphOpened('open'); }
|
|
232
|
+
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'); }
|
|
141
233
|
catch (error) { status(error.message, true); }
|
|
142
234
|
}
|
|
143
235
|
function mutate(action, inspector = false) { if (!state.graph) return; checkpoint(); action(); changed(); if (inspector) renderInspector(); }
|
|
@@ -307,13 +399,13 @@ function issues() {
|
|
|
307
399
|
const result = [], nodes = Object.values(graph.nodes);
|
|
308
400
|
if (nodes.length < 2 || nodes.length > nodeLimit(graph)) result.push({ message: `Use between 2 and ${nodeLimit(graph)} steps; remove extra steps before saving.` });
|
|
309
401
|
if (freeTier()) {
|
|
310
|
-
if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? 'On the free tier only your first custom
|
|
402
|
+
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 });
|
|
311
403
|
if (nodes.some(node => node.agentRole === 'orchestrator')) result.push({ message: FREE_ORCHESTRATOR_TIP });
|
|
312
404
|
if (countedNodes(graph) > state.plan.nodeLimit) result.push({ message: freeNodeTip() });
|
|
313
405
|
}
|
|
314
|
-
if (new TextEncoder().encode(JSON.stringify(graph)).byteLength > 512 * 1024) result.push({ message: '
|
|
315
|
-
if (!graph.name.trim()) result.push({ message: 'Give this
|
|
316
|
-
if (graph.name.length > 200) result.push({ message: 'Keep the
|
|
406
|
+
if (new TextEncoder().encode(JSON.stringify(graph)).byteLength > 512 * 1024) result.push({ message: 'Graph exceeds 512 KiB; shorten instructions or remove steps before saving.' });
|
|
407
|
+
if (!graph.name.trim()) result.push({ message: 'Give this graph a name.' });
|
|
408
|
+
if (graph.name.length > 200) result.push({ message: 'Keep the graph name to 200 characters or fewer.' });
|
|
317
409
|
if (graph.metadata?.description?.length > 2000) result.push({ message: 'Keep the description to 2000 characters or fewer.' });
|
|
318
410
|
if (Array.isArray(graph.widgets) && graph.widgets.length > 5) result.push({ message: 'Use at most 5 widgets.' });
|
|
319
411
|
const widgetIds = new Set();
|
|
@@ -353,12 +445,49 @@ function scheduleValidation() {
|
|
|
353
445
|
const snapshot = JSON.stringify(state.graph);
|
|
354
446
|
state.validationTimer = setTimeout(async () => {
|
|
355
447
|
try { await api('/api/validate', { graph: JSON.parse(snapshot) }); if (JSON.stringify(state.graph) === snapshot) { state.validated = true; state.validationErrors = []; renderValidation(); renderCanvas(); } }
|
|
356
|
-
catch (error) { if (JSON.stringify(state.graph) === snapshot) { state.validated = true; state.validationErrors = [error.message]; renderValidation(); renderCanvas(); } }
|
|
448
|
+
catch (error) { if (JSON.stringify(state.graph) === snapshot) { state.validated = true; state.validationErrors = [error.nodeId ? { message: error.message, nodeId: error.nodeId } : error.message]; renderValidation(); renderCanvas(); } }
|
|
357
449
|
}, 350);
|
|
358
450
|
}
|
|
451
|
+
// The workflow on the canvas, kept for this tab in session storage, so a reload of the editor — the
|
|
452
|
+
// desktop's Reload Editor, or the browser's — opens it again rather than the first in the list. An
|
|
453
|
+
// unsaved one is reopened from the draft the reload kept of it.
|
|
454
|
+
const OPEN_KEY = 'andorra-graph-open';
|
|
455
|
+
let rememberedOpen;
|
|
456
|
+
function rememberOpenGraph() {
|
|
457
|
+
// Before boot has opened anything there is nothing to remember, and the last value must survive
|
|
458
|
+
// until boot has read it.
|
|
459
|
+
if (!state.graph) return;
|
|
460
|
+
const value = JSON.stringify({ id: state.graph.id, unsaved: !!state.dirty });
|
|
461
|
+
if (value === rememberedOpen) return;
|
|
462
|
+
rememberedOpen = value;
|
|
463
|
+
try { sessionStorage.setItem(OPEN_KEY, value); } catch { /* Storage is unavailable; boot opens the first workflow. */ }
|
|
464
|
+
}
|
|
465
|
+
function rememberedGraph() {
|
|
466
|
+
try {
|
|
467
|
+
const value = JSON.parse(sessionStorage.getItem(OPEN_KEY) || 'null');
|
|
468
|
+
return value && typeof value.id === 'string' ? { id: value.id, unsaved: value.unsaved === true } : null;
|
|
469
|
+
} catch { return null; }
|
|
470
|
+
}
|
|
471
|
+
// Reopen what the tab had open before it reloaded: the newest draft of it when it held unsaved work
|
|
472
|
+
// (the reload kept that work as a draft first), else its saved version. False when there is nothing
|
|
473
|
+
// to reopen, and boot opens the first workflow as before.
|
|
474
|
+
async function reopenRemembered() {
|
|
475
|
+
const remembered = rememberedGraph();
|
|
476
|
+
if (!remembered || graphLocked(remembered.id)) return false;
|
|
477
|
+
const saved = state.graphs.some(graph => graph.id === remembered.id);
|
|
478
|
+
if (remembered.unsaved || !saved) {
|
|
479
|
+
try {
|
|
480
|
+
state.drafts = await api('/api/drafts');
|
|
481
|
+
const draft = state.drafts.find(item => item.graphId === remembered.id);
|
|
482
|
+
if (draft) { await openDraft(draft.snapshot, draft.graphId); return state.graph?.id === remembered.id; }
|
|
483
|
+
} catch { /* Fall back to the saved version. */ }
|
|
484
|
+
}
|
|
485
|
+
return saved && await openGraph(remembered.id);
|
|
486
|
+
}
|
|
359
487
|
function renderHeading() {
|
|
360
|
-
|
|
361
|
-
$('
|
|
488
|
+
rememberOpenGraph();
|
|
489
|
+
$('graph-title').textContent = state.graph?.name || 'Graph Editor';
|
|
490
|
+
$('revision').textContent = state.graph ? `${state.graph.revision ? `Version ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
|
|
362
491
|
$('save').disabled = state.saving || !state.graph || !state.dirty || state.graph.id === 'default';
|
|
363
492
|
$('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
|
|
364
493
|
$('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
|
|
@@ -373,14 +502,28 @@ function renderHeading() {
|
|
|
373
502
|
function graphOpened(reason) { state.openReason = reason; globalThis.AndorraManager?.graphOpened(reason); }
|
|
374
503
|
function renderList() {
|
|
375
504
|
$('new-graph').disabled = state.saving || !canCreateGraph();
|
|
376
|
-
$('new-graph').title = canCreateGraph() ? 'Create
|
|
505
|
+
$('new-graph').title = canCreateGraph() ? 'Create graph' : FREE_CREATE_TIP;
|
|
377
506
|
$('duplicate').disabled = state.saving || !state.graph || !canCreateGraph();
|
|
378
507
|
$('duplicate').title = canCreateGraph() ? '' : FREE_CREATE_TIP;
|
|
508
|
+
$('empty-create').disabled = state.saving || !canCreateGraph();
|
|
509
|
+
$('empty-create').title = canCreateGraph() ? '' : FREE_CREATE_TIP;
|
|
379
510
|
$('graphs').replaceChildren();
|
|
380
|
-
|
|
381
|
-
|
|
511
|
+
const query = $('search').value.toLowerCase();
|
|
512
|
+
const listed = state.graphs.filter(graph => graph.name.toLowerCase().includes(query));
|
|
513
|
+
for (const graph of listed) {
|
|
514
|
+
const locked = graphLocked(graph.id);
|
|
515
|
+
const button = el('button', undefined, `graph-row${state.graph?.id === graph.id ? ' active' : ''}${locked ? ' locked' : ''}`);
|
|
382
516
|
button.disabled = state.saving;
|
|
383
|
-
|
|
517
|
+
const tag = el('small', graph.id === 'default' ? 'Preset' : `v${graph.revision}`);
|
|
518
|
+
button.append(el('span', graph.name), tag);
|
|
519
|
+
// A locked row stays focusable so its tooltip and context menu (Export, Delete) still reach it;
|
|
520
|
+
// aria-disabled says it cannot be opened, and a click explains why instead.
|
|
521
|
+
if (locked) {
|
|
522
|
+
button.setAttribute('aria-disabled', 'true');
|
|
523
|
+
button.title = FREE_LOCKED_TIP;
|
|
524
|
+
const glyph = globalThis.AndorraIcons?.icon?.('lock', 12);
|
|
525
|
+
if (glyph) tag.prepend(glyph);
|
|
526
|
+
}
|
|
384
527
|
button.onclick = () => openGraph(graph.id);
|
|
385
528
|
button.oncontextmenu = event => { event.preventDefault(); showGraphMenu(graph, event.clientX, event.clientY); };
|
|
386
529
|
$('graphs').append(button);
|
|
@@ -400,14 +543,16 @@ function renderList() {
|
|
|
400
543
|
head.append(clear); $('graphs').append(head);
|
|
401
544
|
}
|
|
402
545
|
for (const draft of shown) {
|
|
403
|
-
const
|
|
546
|
+
const locked = graphLocked(draft.graphId);
|
|
547
|
+
const button = el('button', undefined, `graph-row draft-row${locked ? ' locked' : ''}`); button.disabled = state.saving;
|
|
404
548
|
const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
|
|
405
549
|
const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
|
|
406
|
-
button.title = `${draft.name} — draft saved ${saved}`;
|
|
550
|
+
button.title = locked ? FREE_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
|
|
551
|
+
if (locked) { button.setAttribute('aria-disabled', 'true'); const glyph = globalThis.AndorraIcons?.icon?.('lock', 12); if (glyph) when.prepend(glyph); }
|
|
407
552
|
button.append(el('span', draft.name), when);
|
|
408
|
-
button.onclick = () => openDraft(draft.snapshot);
|
|
553
|
+
button.onclick = () => openDraft(draft.snapshot, draft.graphId);
|
|
409
554
|
button.oncontextmenu = event => { event.preventDefault(); showMenuAt(event.clientX, event.clientY, `Actions for the draft of ${draft.name}`, [
|
|
410
|
-
{ label: 'Open Draft', icon: 'history', run: () => openDraft(draft.snapshot) },
|
|
555
|
+
...(locked ? [] : [{ label: 'Open Draft', icon: 'history', run: () => openDraft(draft.snapshot, draft.graphId) }]),
|
|
411
556
|
{ label: 'Clear Draft', icon: 'trash', danger: true, run: () => clearDrafts([draft]) },
|
|
412
557
|
]); };
|
|
413
558
|
$('graphs').append(button);
|
|
@@ -422,6 +567,20 @@ function renderList() {
|
|
|
422
567
|
history.append(el('span', state.showDraftHistory ? 'Draft history' : `Draft history (${matching.length})`));
|
|
423
568
|
history.onclick = () => { state.showDraftHistory = !state.showDraftHistory; renderList(); }; $('graphs').append(history);
|
|
424
569
|
}
|
|
570
|
+
// A filter that matches nothing says so, in the EmptyState's anatomy, rather than leaving a gap.
|
|
571
|
+
if (query && !listed.length && !matching.length) $('graphs').append(emptyState('search', 'No graphs match', 'Try another name, or clear the filter.'));
|
|
572
|
+
}
|
|
573
|
+
// The desktop's EmptyState (components/ui.tsx): a 16px mark, a 13/500 title, a 12px muted line and at
|
|
574
|
+
// most one button. In the rail's lists it is the compact kind.
|
|
575
|
+
function emptyState(icon, title, line, action) {
|
|
576
|
+
const box = el('div', undefined, 'empty-state empty-state-compact');
|
|
577
|
+
box.setAttribute('role', 'status');
|
|
578
|
+
const glyph = globalThis.AndorraIcons?.icon?.(icon);
|
|
579
|
+
if (glyph) { const mark = el('span', undefined, 'empty-state-icon'); mark.append(glyph); box.append(mark); }
|
|
580
|
+
box.append(el('p', title, 'empty-state-title'));
|
|
581
|
+
if (line) box.append(el('p', line, 'empty-state-line'));
|
|
582
|
+
if (action) { const row = el('div', undefined, 'empty-state-action'); row.append(action); box.append(row); }
|
|
583
|
+
return box;
|
|
425
584
|
}
|
|
426
585
|
// Clearing takes a graph's drafts off the list; saved graphs and their revisions are untouched.
|
|
427
586
|
// The open graph's edits are not lost: its next autosave is a new draft.
|
|
@@ -429,7 +588,7 @@ async function clearDrafts(drafts, all = false) {
|
|
|
429
588
|
const graphIds = [...new Set(drafts.map(draft => draft.graphId))];
|
|
430
589
|
if (!graphIds.length) return;
|
|
431
590
|
const one = graphIds.length === 1 && !all;
|
|
432
|
-
if (!await askConfirm({ title: one ? `Clear the draft of "${drafts[0].name}"?` : $('search').value ? 'Clear the matching drafts?' : 'Clear all drafts?', message: 'Cleared drafts leave this list, with their history. Saved
|
|
591
|
+
if (!await askConfirm({ title: one ? `Clear the draft of "${drafts[0].name}"?` : $('search').value ? 'Clear the matching drafts?' : 'Clear all drafts?', message: 'Cleared drafts leave this list, with their history. Saved graphs and their versions are not affected.', confirmLabel: 'Clear', tone: 'danger' })) return;
|
|
433
592
|
try { state.drafts = await api('/api/drafts/clear', { graphIds }); if (!state.drafts.length) state.showDraftHistory = false; renderList(); status(one ? 'Draft cleared' : 'Drafts cleared'); }
|
|
434
593
|
catch (error) { status('Drafts not cleared: ' + error.message, true); }
|
|
435
594
|
}
|
|
@@ -447,10 +606,12 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
447
606
|
menu.setAttribute('role', 'menu'); menu.setAttribute('aria-label', ariaLabel);
|
|
448
607
|
const buttons = [];
|
|
449
608
|
for (const item of items) {
|
|
450
|
-
|
|
609
|
+
// A destructive item is a neutral row below a divider (C7); its confirmation names the loss.
|
|
610
|
+
if (item.danger && buttons.length) { const rule = el('hr'); rule.setAttribute('role', 'separator'); menu.append(rule); }
|
|
611
|
+
const button = el('button', item.label);
|
|
451
612
|
button.type = 'button'; button.setAttribute('role', 'menuitem');
|
|
452
613
|
if (item.icon) button.setAttribute('data-icon', item.icon);
|
|
453
|
-
if (item.danger) button.
|
|
614
|
+
if (item.danger) button.setAttribute('data-destructive', 'true');
|
|
454
615
|
button.onclick = () => { closeGraphMenu(); item.run(); };
|
|
455
616
|
menu.append(button); buttons.push(button);
|
|
456
617
|
}
|
|
@@ -471,15 +632,15 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
471
632
|
};
|
|
472
633
|
const outside = event => { if (!menu.contains(event.target)) close(); };
|
|
473
634
|
// The toolbar overflow's menu-button pattern: the opening takes focus, arrows move between
|
|
474
|
-
// items, Escape
|
|
635
|
+
// items, Escape and Tab close it and hand focus back to where it was, so focus never falls to the
|
|
636
|
+
// page as the menu leaves.
|
|
475
637
|
menu.onkeydown = event => {
|
|
476
638
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
477
639
|
event.preventDefault();
|
|
478
640
|
const index = buttons.indexOf(document.activeElement);
|
|
479
641
|
buttons[(index + (event.key === 'ArrowDown' ? 1 : -1) + buttons.length) % buttons.length]?.focus();
|
|
480
642
|
}
|
|
481
|
-
else if (event.key === 'Escape') { event.preventDefault(); close(true); }
|
|
482
|
-
else if (event.key === 'Tab') close();
|
|
643
|
+
else if (event.key === 'Escape' || event.key === 'Tab') { event.preventDefault(); close(true); }
|
|
483
644
|
};
|
|
484
645
|
window.addEventListener?.('pointerdown', outside, true);
|
|
485
646
|
closeGraphMenuHandlers = close;
|
|
@@ -487,7 +648,8 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
487
648
|
}
|
|
488
649
|
function showGraphMenu(graph, x, y) {
|
|
489
650
|
const items = [
|
|
490
|
-
|
|
651
|
+
// A locked workflow cannot seed a copy: the copy would be a second custom workflow.
|
|
652
|
+
...(graphLocked(graph.id) ? [] : [{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) }]),
|
|
491
653
|
{ label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
|
|
492
654
|
];
|
|
493
655
|
// The preset is bundled with the CLI: it has no storage to remove, and hiding it would only
|
|
@@ -496,9 +658,9 @@ function showGraphMenu(graph, x, y) {
|
|
|
496
658
|
showMenuAt(x, y, `${graph.name} actions`, items);
|
|
497
659
|
}
|
|
498
660
|
function showNewGraphMenu(x, y) {
|
|
499
|
-
showMenuAt(x, y, 'Create a
|
|
500
|
-
{ label: 'New
|
|
501
|
-
{ label: 'Import
|
|
661
|
+
showMenuAt(x, y, 'Create a graph', [
|
|
662
|
+
{ label: 'New Graph', icon: 'plus', run: () => newGraph() },
|
|
663
|
+
{ label: 'Import Graph', icon: 'upload', run: () => { if (window.AndorraStudio?.openImport) window.AndorraStudio.openImport(); else status('The import dialog is still loading. Try again in a moment.', true); } },
|
|
502
664
|
]);
|
|
503
665
|
}
|
|
504
666
|
// The saved revision a row names is what a friend receives: the open draft's unsaved edits are
|
|
@@ -506,7 +668,7 @@ function showNewGraphMenu(x, y) {
|
|
|
506
668
|
// the file itself; a plain browser downloads the fetched revision directly.
|
|
507
669
|
async function exportGraph(graph) {
|
|
508
670
|
if (window.AndorraEmbed?.hostChrome?.() && window.AndorraEmbed.exportGraph) { window.AndorraEmbed.exportGraph(graph.id); return; }
|
|
509
|
-
if (state.saving) { status('Wait for the current save before exporting a
|
|
671
|
+
if (state.saving) { status('Wait for the current save before exporting a graph.'); return; }
|
|
510
672
|
downloadGraph(dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(graph.id)}`)));
|
|
511
673
|
}
|
|
512
674
|
function exportFileName(graph) {
|
|
@@ -520,14 +682,14 @@ function downloadJson(value, stem) {
|
|
|
520
682
|
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
521
683
|
}
|
|
522
684
|
async function duplicateGraph(source) {
|
|
523
|
-
if (state.saving) { status('Wait for the current save before duplicating a
|
|
685
|
+
if (state.saving) { status('Wait for the current save before duplicating a graph.'); return; }
|
|
524
686
|
state.saving = true; renderHeading(); renderList();
|
|
525
687
|
let created;
|
|
526
688
|
try {
|
|
527
689
|
const saved = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(source.id)}`));
|
|
528
690
|
// validateGraph caps names at 200 characters, so a near-limit source name must make room
|
|
529
691
|
// for the suffix or the save would be rejected with no way to rename the invisible copy.
|
|
530
|
-
const suffix = ' (Copy)', base = saved.name || 'Untitled
|
|
692
|
+
const suffix = ' (Copy)', base = saved.name || 'Untitled graph';
|
|
531
693
|
const name = base.length + suffix.length > 200 ? base.slice(0, 200 - suffix.length).trimEnd() + suffix : base + suffix;
|
|
532
694
|
const duplicate = { ...saved, id: newId(), name, revision: 0 };
|
|
533
695
|
const stored = await api('/api/graphs', duplicate);
|
|
@@ -541,13 +703,13 @@ async function duplicateGraph(source) {
|
|
|
541
703
|
if (!created) return;
|
|
542
704
|
if (state.dirty) { status(`Created "${created.name}". Open it from the list to rename it.`); return; }
|
|
543
705
|
await openGraph(created.id, { reason: 'duplicate' });
|
|
544
|
-
if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in
|
|
706
|
+
if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in Graph settings.`);
|
|
545
707
|
}
|
|
546
708
|
// Deleting removes the graph, its revisions and its draft history from this machine, and for a
|
|
547
709
|
// signed-in account the cloud copies stop restoring it. The confirm names that loss: there is no undo.
|
|
548
710
|
async function deleteGraph(graph) {
|
|
549
|
-
if (state.saving) { status('Wait for the current save before deleting a
|
|
550
|
-
if (!
|
|
711
|
+
if (state.saving) { status('Wait for the current save before deleting a graph.'); return; }
|
|
712
|
+
if (!await askConfirm({ title: `Delete “${graph.name}”?`, message: 'Its versions and drafts are removed from this machine.', confirmLabel: 'Delete', tone: 'danger' })) return;
|
|
551
713
|
state.saving = true; renderHeading(); renderList();
|
|
552
714
|
// The confirm accepted the loss of unsaved edits of the deleted graph, so no draft of it may
|
|
553
715
|
// outlive it: stop its queued write, and let an in-flight one land before the deletion's
|
|
@@ -629,7 +791,7 @@ function nodeSubtitle(node) {
|
|
|
629
791
|
const model = nodeModelLabel(node);
|
|
630
792
|
return node.agentRole === 'orchestrator' ? `Orchestrator${model ? ' · ' + model : ''}` : model;
|
|
631
793
|
}
|
|
632
|
-
if (node.type === 'end') return '
|
|
794
|
+
if (node.type === 'end') return 'Graph complete';
|
|
633
795
|
if (node.type === 'action') return node.action?.kind === 'tests' ? 'Run tests' : node.action?.kind === 'git' ? 'Git operation' : 'Run command';
|
|
634
796
|
return { join: 'Wait for branches', loop: 'Bounded repetition', condition: 'Branch on run state', parallel: 'Fan out', approval: 'Human approval' }[node.type] || 'Flow control';
|
|
635
797
|
}
|
|
@@ -826,7 +988,7 @@ function renderEdges() {
|
|
|
826
988
|
function removeNodes(ids) {
|
|
827
989
|
const graph = state.graph;
|
|
828
990
|
const remaining = Object.keys(graph.nodes).filter(id => !ids.has(id));
|
|
829
|
-
if (!remaining.length) { status('Keep at least one step as the
|
|
991
|
+
if (!remaining.length) { status('Keep at least one step as the graph start. Add a replacement before deleting all steps.', true); return; }
|
|
830
992
|
const nextEntry = ids.has(graph.entry)
|
|
831
993
|
? graph.edges.find(edge => edge.source === graph.entry && !ids.has(edge.target) && graph.nodes[edge.target])?.target ?? remaining[0]
|
|
832
994
|
: graph.entry;
|
|
@@ -877,7 +1039,7 @@ function nodeErrorIds() {
|
|
|
877
1039
|
}
|
|
878
1040
|
function renderValidation() {
|
|
879
1041
|
const container=$('validation');if(!container)return;container.replaceChildren();const errors=[...issues(),...state.validationErrors].map(errorEntry);
|
|
880
|
-
if(!errors.length)container.append(el('p',state.validated?'Validated · Ready to save':'Checking
|
|
1042
|
+
if(!errors.length)container.append(el('p',state.validated?'Validated · Ready to save':'Checking graph…',state.validated?'valid ok':'valid'));
|
|
881
1043
|
else {const list=el('ul',undefined,'validation');errors.forEach(({message,nodeId})=>{ const row=el('li',message); row.tabIndex=0; row.title='Click to focus the affected step'; row.onclick=()=>{if(nodeId){clearSelection();state.selected=nodeId;state.selectedIds=[nodeId];renderCanvas();renderInspector();}};row.onkeydown=e=>{if(e.key==='Enter'||e.key===' ')row.click();};list.append(row);});container.append(list);}
|
|
882
1044
|
}
|
|
883
1045
|
function disclosure(parent, title, open = false) { const item = el('details', undefined, 'section disclosure'); const key = `${state.selectedEdge?.id || state.selected || 'graph'}:${title}`; item.open = state.disclosures[key] ?? open; item.ontoggle = () => {state.disclosures[key] = item.open;}; item.append(el('summary', title)); const body = el('div'); item.append(body); parent.append(item); return body; }
|
|
@@ -1085,15 +1247,15 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1085
1247
|
const typeMismatch = claimed && !!recorded?.type && claimedProvider.type !== recorded.type;
|
|
1086
1248
|
const matches = !claimed && recorded?.type === 'codex' ? state.providers.filter(p => p.type === 'codex' && offers(p, requiredModels)) : [];
|
|
1087
1249
|
const refusalHint = typeMismatch
|
|
1088
|
-
? `Provider "${originalId}" is configured locally with type "${claimedProvider.type}", but this
|
|
1089
|
-
: `Provider "${originalId}" is configured locally but does not offer ${requiredModels.join(', ')}. Execution will refuse this
|
|
1250
|
+
? `Provider "${originalId}" is configured locally with type "${claimedProvider.type}", but this graph was published with type "${recorded.type}". Execution will refuse this graph; reconnect a provider of the recorded type.`
|
|
1251
|
+
: `Provider "${originalId}" is configured locally but does not offer ${requiredModels.join(', ')}. Execution will refuse this graph until that provider is configured with the model; another profile is never used as a substitute.`;
|
|
1090
1252
|
const hint = matches.length === 1
|
|
1091
1253
|
? `Will use local Codex OAuth profile "${idFor(matches[0])}" (${requiredModels.join(', ') || 'all referenced models'}). The OAuth connection is verified before execution.`
|
|
1092
1254
|
: matches.length > 1
|
|
1093
|
-
? `Multiple local Codex OAuth profiles (${matches.map(idFor).join(', ')}) each satisfy this
|
|
1255
|
+
? `Multiple local Codex OAuth profiles (${matches.map(idFor).join(', ')}) each satisfy this graph's requirements for "${originalId}". Execution needs exactly one; configure the original provider ID or keep a single compatible profile.`
|
|
1094
1256
|
: claimed
|
|
1095
1257
|
? refusalHint
|
|
1096
|
-
: `Provider "${originalId}"${requiredModels.length ? ` / ${requiredModels.join(', ')}` : ''} is not configured on this machine. This
|
|
1258
|
+
: `Provider "${originalId}"${requiredModels.length ? ` / ${requiredModels.join(', ')}` : ''} is not configured on this machine. This graph can be saved, but execution requires a compatible provider.`;
|
|
1097
1259
|
parent.append(el('p', hint, 'help'));
|
|
1098
1260
|
} else if (followsProvider && recorded?.model && recorded.model !== exact.model) {
|
|
1099
1261
|
parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
|
|
@@ -1335,7 +1497,7 @@ function routes(parent, node) {
|
|
|
1335
1497
|
function renderEdgeInspector(parent, edge) {
|
|
1336
1498
|
$('inspector-title').textContent = 'Connection';
|
|
1337
1499
|
parent.append(el('h3', `${state.graph.nodes[edge.source]?.name} - ${edgeOutcome(edge)}`), el('p', `To: ${state.graph.nodes[edge.target]?.name}`, 'help'));
|
|
1338
|
-
if (edge.bootstrap) parent.append(el('p', 'Initial connection: starts this updated
|
|
1500
|
+
if (edge.bootstrap) parent.append(el('p', 'Initial connection: starts this updated graph at its original Join. Later loop iterations wait for the other incoming branches. Removing this connection removes that initial-start behavior.', 'help'));
|
|
1339
1501
|
const mappings = section(parent, 'Input mapping'); mappings.append(el('p', 'Map validated outputs or run context into the destination named inputs. Constants must be valid JSON.', 'help'));
|
|
1340
1502
|
const targetSchema=state.graph.nodes[edge.target]?.inputSchema, sourceSchema=state.graph.nodes[edge.source]?.modifiers?.parallel?.mode === 'copies' ? {properties:{results:{type:'array'}}} : state.graph.nodes[edge.source]?.outputSchema; const targetKeys = Object.keys(targetSchema?.properties || {}), sourceKeys = Object.keys(sourceSchema?.properties || {}); if(targetKeys.length)mappings.append(el('p',`Destination inputs: ${targetKeys.map(key=>key+(targetSchema.required?.includes(key)?' (required)':'')).join(', ')}`,'help'));if(sourceKeys.length)mappings.append(el('p',`Available source outputs: ${sourceKeys.join(', ')}`,'help'));
|
|
1341
1503
|
for (const [key, value] of Object.entries(edge.inputMapping || {})) {
|
|
@@ -1415,7 +1577,7 @@ function renderSubagents(parent, node) {
|
|
|
1415
1577
|
const delegating = delegatesWriting(node);
|
|
1416
1578
|
explain(check(parent,'Allow subagents',policy.enabled,value=>{set({enabled:value});pruneRoutes(node);}), delegating
|
|
1417
1579
|
? 'Writing roles of an Orchestrator run in their own Git worktree with a shell. The shell is not sandboxed and follows your permission mode. The Orchestrator reviews each change and lands the ones it accepts into your working folder; it never writes code itself.'
|
|
1418
|
-
: 'Internal delegation returns observations to this Agent. Only this parent chooses its
|
|
1580
|
+
: 'Internal delegation returns observations to this Agent. Only this parent chooses its graph outcome. Active children finish or cancel before the parent can complete. Subagents of ordinary agents never receive the unsandboxed host shell. Read-only roles use filesystem tools and supported Git read operations.');
|
|
1419
1581
|
if (!policy.enabled) return;
|
|
1420
1582
|
// The server refuses writing roles on an Orchestrator outside separate worktrees, so the
|
|
1421
1583
|
// editor moves the policy there as soon as a role may write.
|
|
@@ -1534,7 +1696,7 @@ function hasRetryCycle(graph) {
|
|
|
1534
1696
|
function retryLimitHelp(parent, graph) {
|
|
1535
1697
|
if (!hasRetryCycle(graph) || graph.limits?.maxNodeVisits || graph.limits?.wallTimeMs) return;
|
|
1536
1698
|
const box = el('div', undefined, 'cycle-help');
|
|
1537
|
-
box.append(el('strong', 'This
|
|
1699
|
+
box.append(el('strong', 'This graph includes a retry cycle'), el('p', 'A return connection can run the same agents repeatedly, so the run needs a ceiling: set a maximum number of visits per step, or give the run a wall clock. Without one the cycle never ends.'));
|
|
1538
1700
|
const fix = el('button', 'Limit Each Step to 3 Visits');
|
|
1539
1701
|
fix.onclick = () => mutate(() => { graph.limits = {...graph.limits, maxNodeVisits:3}; }, true);
|
|
1540
1702
|
const clock = el('button', 'Give the Run 30 Minutes');
|
|
@@ -1544,16 +1706,16 @@ function retryLimitHelp(parent, graph) {
|
|
|
1544
1706
|
function renderInspector() {
|
|
1545
1707
|
// A redraw replaces a full-screen prompt editor, so its backdrop goes with it.
|
|
1546
1708
|
document.body?.classList?.remove?.('prompt-fullscreen'); for (const backdrop of document.querySelectorAll?.('.prompt-backdrop') ?? []) backdrop.remove();
|
|
1547
|
-
const parent = $('inspector-body'); parent.replaceChildren(); const graph = state.graph; if (!graph) { parent.append(el('p', 'Create a
|
|
1709
|
+
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; }
|
|
1548
1710
|
if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
|
|
1549
|
-
const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : '
|
|
1711
|
+
const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : 'Graph settings';
|
|
1550
1712
|
$('graph-settings').hidden = !node && !state.selectedEdge && selectedNodes().length <= 1;
|
|
1551
1713
|
retryLimitHelp(parent, graph);
|
|
1552
1714
|
if (state.selectedEdge) renderEdgeInspector(parent, state.selectedEdge);
|
|
1553
1715
|
else if (selectedNodes().length > 1) renderBulkInspector(parent,selectedNodes());
|
|
1554
1716
|
else if (!node) {
|
|
1555
1717
|
const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
|
|
1556
|
-
field(general, '
|
|
1718
|
+
field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
|
|
1557
1719
|
const meta = el('p', `${graph.id} · Version ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
|
|
1558
1720
|
if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
|
|
1559
1721
|
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.');
|
|
@@ -1572,10 +1734,10 @@ function renderInspector() {
|
|
|
1572
1734
|
const add = el('button','Add Widget');
|
|
1573
1735
|
add.onclick = () => mutate(() => { graph.widgets = [...(graph.widgets ?? []), { id: `widget-${crypto.randomUUID().slice(0,8)}`, name: '', description: '' }]; }, true);
|
|
1574
1736
|
widgetGroup.append(add);
|
|
1575
|
-
widgetGroup.append(el('p','Up to 5 widgets per
|
|
1737
|
+
widgetGroup.append(el('p','Up to 5 widgets per graph. Names and descriptions are required before saving.','help'));
|
|
1576
1738
|
} else widgetGroup.append(el('p','Widget limit reached (5).','help'));
|
|
1577
1739
|
const visits = field(panels.behavior, 'Maximum visits per step', graph.limits?.maxNodeVisits ?? 0, value => {graph.limits={...graph.limits}; if(value===undefined || value===0) delete graph.limits.maxNodeVisits; else graph.limits.maxNodeVisits=value;}, {type:'number',optional:true,min:0,max:100,refresh:true});
|
|
1578
|
-
explain(visits,'0 means unlimited, which is the default. A return connection repeats a step, so a
|
|
1740
|
+
explain(visits,'0 means unlimited, which is the default. A return connection repeats a step, so a graph with one needs a ceiling: a visit limit, or a wall clock. An agent Loop modifier has its own try limit.');
|
|
1579
1741
|
// Per-graph desktop settings render here; a browser-launched studio has no host bridge and skips them.
|
|
1580
1742
|
window.AndorraEmbed?.inspector?.(general);
|
|
1581
1743
|
const advanced = panels.advanced; jsonField(advanced, 'Run limits', graph.limits, value => {graph.limits=value;}); jsonField(advanced,'Run input schema',graph.inputSchema,value=>{graph.inputSchema=value;}); jsonField(advanced,'Run state schema',graph.stateSchema,value=>{graph.stateSchema=value;});
|
|
@@ -1585,14 +1747,14 @@ function renderInspector() {
|
|
|
1585
1747
|
if (node.type === 'agent') {
|
|
1586
1748
|
if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator: optional starting Agent for research, clarification and handing work on. Remove it to start directly at the next step.','help'));}
|
|
1587
1749
|
const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;}, { placeholder: 'Type / to add a skill' });
|
|
1588
|
-
explain(prompt, 'Edit the instructions for this agent. Save the
|
|
1750
|
+
explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this step\'s instructions; project guidance, advanced system instructions and runtime permissions still apply. Type / to add a skill: the step loads every /skill its prompt names when it runs. A skill this machine does not have is flagged here and skipped at run time; it never stops the graph.');
|
|
1589
1751
|
explain(check(general, 'Jev decisions', node.jevEnabled === true, value => { if (value) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists this agent with routing decisions. The coding model still implements the task; sign-in, quota and runtime permissions apply.');
|
|
1590
1752
|
const model = panels.model;
|
|
1591
1753
|
modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
|
|
1592
1754
|
const conversation = choice(model, 'Conversation', node.contextPolicy?.conversation ?? 'reuse', [{value:'reuse',label:'Reuse with the same provider and model'}, {value:'isolate',label:'Start an isolated conversation'}], value => {node.contextPolicy={...node.contextPolicy,conversation:value};});
|
|
1593
1755
|
explain(conversation, 'Reuse continues from the preceding Agent with this step\'s instructions and permissions. Different providers or models start fresh. Branches receive separate copies of their shared history. Provider caching and token savings depend on the model service.');
|
|
1594
|
-
const skills = choice(model, 'Skill inheritance', node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active
|
|
1595
|
-
explain(skills, 'Inherits skills activated earlier in this
|
|
1756
|
+
const skills = choice(model, 'Skill inheritance', node.contextPolicy?.skillInheritance ?? 'inherit', [{value:'inherit',label:'Inherit active graph skills'}, {value:'none',label:'Do not inherit skills'}], value => {node.contextPolicy={...node.contextPolicy,skillInheritance:value};});
|
|
1757
|
+
explain(skills, 'Inherits skills activated earlier in this graph, even when the conversation is isolated or the model changes. Each Agent loads the skill for its own role. Opting out also isolates predecessor conversation text to avoid leaking loaded skills; it never changes tool or approval permissions.');
|
|
1596
1758
|
renderCompletion(section(panels.behavior, node.agentRole === 'orchestrator' ? 'Routing' : 'Outcomes and conditions'), node);
|
|
1597
1759
|
renderModifiers(panels.behavior, node);
|
|
1598
1760
|
const advanced = panels.advanced;
|
|
@@ -1619,7 +1781,7 @@ function renderInspector() {
|
|
|
1619
1781
|
} else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
|
|
1620
1782
|
if (panels.behavior) routes(panels.behavior,node);
|
|
1621
1783
|
const layout = disclosure(panels.advanced,'Position'); const p=position(node,Object.keys(graph.nodes).indexOf(node.id)); field(layout,'X',p.x,value=>{node.position={...p,x:value};},{type:'number',min:-100000,max:100000,refresh:true});field(layout,'Y',p.y,value=>{node.position={...p,y:value};},{type:'number',min:-100000,max:100000,refresh:true});
|
|
1622
|
-
const remove=el('button','Remove Step','danger');remove.disabled=Object.keys(graph.nodes).length===1;remove.onclick=()=>{void askConfirm({title:`Remove ${node.name}?`,message:'The step and its connections are removed from this
|
|
1784
|
+
const remove=el('button','Remove Step','danger');remove.disabled=Object.keys(graph.nodes).length===1;remove.onclick=()=>{void askConfirm({title:`Remove ${node.name}?`,message:'The step and its connections are removed from this graph. Undo brings them back.',confirmLabel:'Remove Step',tone:'danger'}).then(confirmed=>{if(confirmed&&state.graph?.nodes?.[node.id])removeNodes(new Set([node.id]));});};panels.advanced.append(remove);
|
|
1623
1785
|
}
|
|
1624
1786
|
const validation=section(parent,'Validation');validation.id='validation';renderValidation();
|
|
1625
1787
|
window.AndorraStudio?.inspector?.(parent, node);
|
|
@@ -1629,14 +1791,15 @@ function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas
|
|
|
1629
1791
|
// established that loading loses nothing, or the user has asked for the load. Resolves to whether
|
|
1630
1792
|
// the graph was opened.
|
|
1631
1793
|
async function openGraph(id, options = {}) {
|
|
1632
|
-
if (state.saving) { status('Wait for the current save before opening another
|
|
1794
|
+
if (state.saving) { status('Wait for the current save before opening another graph.'); return false; }
|
|
1795
|
+
if (graphLocked(id)) { status(FREE_LOCKED_TIP, true); return false; }
|
|
1633
1796
|
if (state.dirty && !options.discard && !await askConfirm(DISCARD_QUESTION)) return false;
|
|
1634
1797
|
// A caller that already holds the graph (`options.fetched`) is applied without a request, so nothing can change the canvas between its own checks and this replacement.
|
|
1635
|
-
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; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(migrated ? 'This
|
|
1798
|
+
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; }
|
|
1636
1799
|
}
|
|
1637
1800
|
function newId() { return `graph-${crypto.randomUUID()}`; }
|
|
1638
1801
|
function newGraph(duplicate = false, discarded = false) {
|
|
1639
|
-
if (state.saving) { status('Wait for the current save before creating another
|
|
1802
|
+
if (state.saving) { status('Wait for the current save before creating another graph.'); return; }
|
|
1640
1803
|
if (!canCreateGraph()) { status(FREE_CREATE_TIP, true); return; }
|
|
1641
1804
|
// Unsaved edits are asked about first; a clean graph is replaced at once.
|
|
1642
1805
|
if (state.dirty && !discarded) { void askConfirm(DISCARD_QUESTION).then(discard => { if (discard) newGraph(duplicate, true); }); return; }
|
|
@@ -1644,25 +1807,25 @@ function newGraph(duplicate = false, discarded = false) {
|
|
|
1644
1807
|
else if (freeTier()) {
|
|
1645
1808
|
// A free graph starts from the Software Engineer alone: the Orchestrator is a Premium node.
|
|
1646
1809
|
const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
|
|
1647
|
-
if(!engineerPreset){status('Starting presets are unavailable. Reload the
|
|
1648
|
-
state.graph={schemaVersion:3,id:newId(),name:'Untitled
|
|
1810
|
+
if(!engineerPreset){status('Starting presets are unavailable. Reload the Graph Editor and try again.',true);return;}
|
|
1811
|
+
state.graph={schemaVersion:3,id:newId(),name:'Untitled graph',revision:0,entry:'engineer',nodes:{engineer:{...copy(engineerPreset),id:'engineer',position:{x:0,y:0}},done:{id:'done',name:'Done',type:'end',position:{x:320,y:0}}},edges:[{id:'engineer-done',source:'engineer',target:'done',outcome:'completed'}]};
|
|
1649
1812
|
}
|
|
1650
1813
|
else {
|
|
1651
1814
|
const orchestratorPreset=state.definitions.find(definition=>definition.node.agentRole==='orchestrator')?.node;
|
|
1652
1815
|
const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
|
|
1653
|
-
if(!orchestratorPreset || !engineerPreset){status('Starting presets are unavailable. Reload the
|
|
1816
|
+
if(!orchestratorPreset || !engineerPreset){status('Starting presets are unavailable. Reload the Graph Editor and try again.',true);return;}
|
|
1654
1817
|
const orchestrator={...copy(orchestratorPreset),id:'orchestrator',position:{x:0,y:0}};
|
|
1655
1818
|
const engineer={...copy(engineerPreset),id:'engineer',position:{x:320,y:0}};
|
|
1656
1819
|
const inputMapping={originalTask:'$run.input.task'};
|
|
1657
1820
|
for(const key of ['taskInstruction','requirements','acceptanceCriteria','designConsiderations','codebaseFindings']) inputMapping[key]=`$source.output.${key}`;
|
|
1658
|
-
state.graph={schemaVersion:3,id:newId(),name:'Untitled
|
|
1821
|
+
state.graph={schemaVersion:3,id:newId(),name:'Untitled graph',revision:0,entry:'orchestrator',nodes:{orchestrator,engineer,done:{id:'done',name:'Done',type:'end',position:{x:640,y:0}}},edges:[{id:'orchestrator-engineer',source:'orchestrator',target:'engineer',outcome:'completed',inputMapping},{id:'engineer-done',source:'engineer',target:'done',outcome:'completed'}]};
|
|
1659
1822
|
}
|
|
1660
1823
|
// A duplicate copies the open graph, providerless nodes included, so its unmet provider
|
|
1661
1824
|
// requirements travel with it; an unrelated new graph starts without any.
|
|
1662
|
-
state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
|
|
1825
|
+
markSaved(null); state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
|
|
1663
1826
|
state.untouched = JSON.stringify(state.graph);
|
|
1664
1827
|
state.pendingProviderNodes = duplicate ? new Set(state.pendingProviderNodes ?? []) : null;
|
|
1665
|
-
render(); fit(); status('New
|
|
1828
|
+
render(); fit(); status('New graph · Customize your agent, then save');
|
|
1666
1829
|
graphOpened(duplicate ? 'duplicate' : 'new');
|
|
1667
1830
|
}
|
|
1668
1831
|
// The settings a new Agent starts from, whether it is dropped on the canvas or added to the list.
|
|
@@ -1809,7 +1972,7 @@ function addAgent() {
|
|
|
1809
1972
|
libraryDialog('Add agent', [['Agent name', name], ['Description', description], ['Instructions', instruction]], async () => {
|
|
1810
1973
|
const agentName = requireAgentName(name);
|
|
1811
1974
|
await writeDefinition({schemaVersion:2, id, name:agentName, description:description.value.trim(), revision:0, node:{id:'agent', type:'agent', name:agentName, ...blankAgentSettings(), instruction:instruction.value.trim()}}, `Agent ${agentName} added`);
|
|
1812
|
-
}, 'Add
|
|
1975
|
+
}, 'Add Agent');
|
|
1813
1976
|
skillPrompt(instruction);
|
|
1814
1977
|
}
|
|
1815
1978
|
// The server's 512 KiB limit applies to the import request, not the file: Share pretty-prints its
|
|
@@ -1859,7 +2022,7 @@ async function shareAgent(definition) {
|
|
|
1859
2022
|
// Built-in Agents have no Delete. Graphs that already use a deleted Agent keep their own copy.
|
|
1860
2023
|
async function deleteAgent(definition) {
|
|
1861
2024
|
if (definition.preset) return;
|
|
1862
|
-
if (!
|
|
2025
|
+
if (!await askConfirm({ title: `Delete the Agent “${definition.name}”?`, message: 'Graphs that already use it keep their own copy. This cannot be undone.', confirmLabel: 'Delete', tone: 'danger' })) return;
|
|
1863
2026
|
try { await api(`/api/definitions/${encodeURIComponent(definition.id)}`, undefined, { method: 'DELETE' }); }
|
|
1864
2027
|
catch (error) {
|
|
1865
2028
|
// A lost response can still have deleted it, so the refreshed list decides what is reported.
|
|
@@ -1926,7 +2089,7 @@ function renderLibrary() {
|
|
|
1926
2089
|
const freeRefusal = freeNodeRefusal([{ type: item.type, agentRole: item.node?.agentRole }]);
|
|
1927
2090
|
if (freeRefusal) button.title = freeRefusal;
|
|
1928
2091
|
button.disabled = cannotAdd && !item.definition; button.draggable = !button.disabled && !freeRefusal;
|
|
1929
|
-
button.onclick = () => { if (cannotAdd) { status(state.graph ? '
|
|
2092
|
+
button.onclick = () => { if (cannotAdd) { status(state.graph ? 'Graph step limit reached.' : 'Open a graph to add this Agent.', true); return; } addNode(item.type, item.node); };
|
|
1930
2093
|
button.ondragstart = event => { event.dataTransfer.setData('application/andorra-node', JSON.stringify({name:item.name,type:item.type,node:item.node})); event.dataTransfer.effectAllowed = 'copy'; };
|
|
1931
2094
|
row.append(button);
|
|
1932
2095
|
// An Agent's actions are secondary, so they open from a right-click on the row (which the
|
|
@@ -1961,15 +2124,16 @@ function renderLibrary() {
|
|
|
1961
2124
|
parent.append(group); return group;
|
|
1962
2125
|
};
|
|
1963
2126
|
const agents = section(container, 'agents', 'Agents', [
|
|
1964
|
-
{id:'add', name:'Add
|
|
1965
|
-
{id:'import', name:'Import
|
|
2127
|
+
{id:'add', name:'Add Agent', description:'Create a new Agent in this list', icon:'plus', title:'Create a new Agent and add it to this list', action:addAgent},
|
|
2128
|
+
{id:'import', name:'Import Agent', description:'Add an Agent from a shared JSON file', icon:'upload', title:'Import an Agent shared from Andorra Code', action:importAgent, last:true},
|
|
1966
2129
|
...state.definitions.filter(d=>d.preset).map(definitionItem),
|
|
1967
2130
|
...state.definitions.filter(d=>!d.preset).map(definitionItem),
|
|
1968
2131
|
]);
|
|
1969
2132
|
if (agents) agents.append(el('p','Select an Agent to configure Condition, Loop, and Parallel modifiers.','help'));
|
|
1970
2133
|
section(container,'control','Control',['join'].map(type=>({name:type.charAt(0).toUpperCase()+type.slice(1),type,description:{condition:'Branch on run state',loop:'Bounded repetition',parallel:'Explicit fan-out',join:'Wait for all or any branches'}[type]})));
|
|
1971
2134
|
section(container,'actions','Actions',[{name:'Run command',type:'action',node:{name:'Run command',action:{kind:'command',command:''}},description:'Execute a shell command'},{name:'Run tests',type:'action',node:{name:'Run tests',action:{kind:'tests',command:'npm test'}},description:'Execute project tests'},{name:'Git operation',type:'action',node:{name:'Git operation',action:{kind:'git',command:'git status'}},description:'Run a Git operation'}]);
|
|
1972
|
-
section(container,'flow','Flow',[{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this
|
|
2135
|
+
section(container,'flow','Flow',[{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this graph path'}]);
|
|
2136
|
+
if (query && !container.children.length) container.append(emptyState('search', 'No steps match', 'Try another name, or clear the search.'));
|
|
1973
2137
|
}
|
|
1974
2138
|
// Fit, Arrange and the zoom buttons ease the view to where it is going, over --dur-3 on an ease-in-out
|
|
1975
2139
|
// with no overshoot, so the eye can follow the cards. A gesture (pan, pinch, wheel) stops the ease and
|
|
@@ -2017,12 +2181,12 @@ function zoomBy(factor) {
|
|
|
2017
2181
|
}
|
|
2018
2182
|
// A keyboard-activated click carries no pointer coordinates, so the menu falls back to the
|
|
2019
2183
|
// window corner rather than refusing to open.
|
|
2020
|
-
$('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
|
|
2184
|
+
$('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('empty-create').onclick = () => newGraph(); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
|
|
2021
2185
|
$('node-search').oninput = renderLibrary;
|
|
2022
2186
|
$('graph-settings').onclick = () => { clearSelection(); renderCanvas(); renderInspector(); };
|
|
2023
2187
|
$('toggle-inspector').onclick = () => { const hidden = $('inspector').classList.toggle('hidden'); $('toggle-inspector').setAttribute('aria-expanded', String(!hidden)); };
|
|
2024
|
-
$('undo').onclick = () => { if (!state.undo.length) return; state.redo.push(copy(state.graph)); state.graph = state.undo.pop(); clearSelection();
|
|
2025
|
-
$('redo').onclick = () => { if (!state.redo.length) return; state.undo.push(copy(state.graph)); state.graph = state.redo.pop(); clearSelection();
|
|
2188
|
+
$('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'); };
|
|
2189
|
+
$('redo').onclick = () => { if (!state.redo.length) return; state.undo.push(copy(state.graph)); state.graph = state.redo.pop(); clearSelection(); refreshDirty(); render(); status('Change restored'); };
|
|
2026
2190
|
// A refused Save briefly pulses the outlined nodes, so the eye finds the cards it must fix
|
|
2027
2191
|
// before the run can be saved. No re-render happens on that early return, so the class lives.
|
|
2028
2192
|
function pulseErrorNodes() {
|
|
@@ -2049,7 +2213,7 @@ $('save').onclick = async () => {
|
|
|
2049
2213
|
try { const submitted = dropLegacyTokenFields(copy(state.graph)); const graph = await api('/api/graphs', submitted); if (state.graph.id === submitted.id) {
|
|
2050
2214
|
// The draft marker is editor state, not graph content, so a difference in it alone is not an edit.
|
|
2051
2215
|
const liveView = { ...state.graph }; delete liveView.pendingProviderNodes;
|
|
2052
|
-
const edited = JSON.stringify(liveView) !== JSON.stringify(submitted); if (edited) { state.graph.revision = graph.revision; state.undo = []; state.redo = []; } 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); render(); status(`Saved version ${graph.revision}${state.dirty ? ' · You have newer unsaved changes' : ''}`); } catch (error) { status(error.message, true); } finally { state.saving = false; renderHeading(); renderList(); }
|
|
2216
|
+
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); render(); status(`Saved version ${graph.revision}${state.dirty ? ' · You have newer unsaved changes' : ''}`); } catch (error) { status(error.message, true); } finally { state.saving = false; renderHeading(); renderList(); }
|
|
2053
2217
|
};
|
|
2054
2218
|
$('canvas-hint-close').onclick = dismissCanvasHint;
|
|
2055
2219
|
$('fit').onclick = () => fit(true); $('zoom-in').onclick = () => zoomBy(1.2); $('zoom-out').onclick = () => zoomBy(1 / 1.2);
|
|
@@ -2122,13 +2286,16 @@ if (token) setTimeout(refreshCloudState, 1000);
|
|
|
2122
2286
|
system notification (a Windows toast) fire when the CLI waits on the user. Every browser
|
|
2123
2287
|
entry point is feature-detected because this module also loads into partial-DOM harnesses.
|
|
2124
2288
|
The idle favicon is the published Andorra Labs logo; the two busy states are status markers
|
|
2125
|
-
rather than the brand, so they keep their own artwork
|
|
2126
|
-
|
|
2289
|
+
rather than the brand, so they keep their own artwork, drawn in the theme's neutral inks when they
|
|
2290
|
+
are set: both stand on the neutral accent's tile, with the turning ring or the wait's mark in the
|
|
2291
|
+
ink that sits on it, so either reads on a light or a dark tab strip. The chrome keeps no amber
|
|
2292
|
+
(P-LNT-16). Each fallback is the dark token's own value, for a page without the stylesheet. */
|
|
2293
|
+
const baseTitle = document.title || 'Graph Editor · Andorra Code';
|
|
2127
2294
|
const faviconHref = svg => 'data:image/svg+xml,' + encodeURIComponent(svg);
|
|
2128
2295
|
const FAVICONS = {
|
|
2129
|
-
idle: '/andorra-logo.png',
|
|
2130
|
-
running: faviconHref(
|
|
2131
|
-
'awaiting-input': faviconHref(
|
|
2296
|
+
idle: () => '/andorra-logo.png',
|
|
2297
|
+
running: () => faviconHref(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="${themeColor('--accent', '#ececec')}"/><circle cx="16" cy="16" r="9" fill="none" stroke="${themeColor('--on-accent', '#141414')}" stroke-width="3.5" opacity="0.36"/><g><path d="M16 7a9 9 0 0 1 9 9" fill="none" stroke="${themeColor('--on-accent', '#141414')}" stroke-width="3.5" stroke-linecap="round"/><animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 16 16" to="360 16 16" dur="${themeColor('--loop-spin', '1s')}" repeatCount="indefinite"/></g></svg>`),
|
|
2298
|
+
'awaiting-input': () => faviconHref(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="${themeColor('--accent', '#ececec')}"/><rect x="14" y="7" width="4" height="13" rx="2" fill="${themeColor('--on-accent', '#141414')}"/><circle cx="16" cy="24.5" r="2.4" fill="${themeColor('--on-accent', '#141414')}"/></svg>`),
|
|
2132
2299
|
};
|
|
2133
2300
|
function setFavicon(activity) {
|
|
2134
2301
|
try {
|
|
@@ -2138,7 +2305,7 @@ function setFavicon(activity) {
|
|
|
2138
2305
|
link.setAttribute('rel', 'icon');
|
|
2139
2306
|
(document.head || document.body).append(link);
|
|
2140
2307
|
}
|
|
2141
|
-
const href = FAVICONS[activity] || FAVICONS.idle;
|
|
2308
|
+
const href = (FAVICONS[activity] || FAVICONS.idle)();
|
|
2142
2309
|
link.setAttribute('type', href.startsWith('data:') ? 'image/svg+xml' : 'image/png');
|
|
2143
2310
|
link.setAttribute('href', href);
|
|
2144
2311
|
} catch { /* A partial DOM cannot host a favicon. */ }
|
|
@@ -2151,14 +2318,16 @@ function applyActivity(value) {
|
|
|
2151
2318
|
if (typeof applyProviderRegistry === 'function') applyProviderRegistry(value);
|
|
2152
2319
|
if (!Object.hasOwn(FAVICONS, value.state)) return;
|
|
2153
2320
|
setFavicon(value.state);
|
|
2154
|
-
|
|
2321
|
+
// One phrase for a run waiting on the person, the desktop's (P-ATN-07): "Needs your input".
|
|
2322
|
+
document.title = value.state === 'running' ? `Running · ${baseTitle}` : value.state === 'awaiting-input' ? `Needs your input · ${baseTitle}` : baseTitle;
|
|
2155
2323
|
const activityKey = JSON.stringify([value.state, value.runId, value.updatedAt, value.kind, value.detail]);
|
|
2156
2324
|
// Native-app notifications are requested by the top-level Tauri window. Browsers
|
|
2157
2325
|
// deny permission requests from cross-origin iframes, so relay only safe status.
|
|
2158
2326
|
window.AndorraEmbed?.activity?.(value);
|
|
2159
2327
|
if ((!window.parent || window.parent === window) && value.state === 'awaiting-input' &&
|
|
2160
2328
|
lastActivityKey !== activityKey && typeof Notification === 'function' && Notification.permission === 'granted') {
|
|
2161
|
-
|
|
2329
|
+
// The desktop's own notice for the same state (desktop/src/engine/taskNotifications.ts).
|
|
2330
|
+
try { new Notification('Needs your input', { body: value.detail || 'A graph run is waiting for your answer in its terminal.', tag: 'andorra-activity' }); } catch { /* The favicon and title still changed. */ }
|
|
2162
2331
|
}
|
|
2163
2332
|
lastActivityKey = activityKey;
|
|
2164
2333
|
}
|
|
@@ -2208,4 +2377,4 @@ setFavicon('idle');
|
|
|
2208
2377
|
if (token) watchActivity();
|
|
2209
2378
|
try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { /* Partial DOM. */ }
|
|
2210
2379
|
|
|
2211
|
-
(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 (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
|
|
2380
|
+
(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()) { /* The graph this tab had open before it reloaded. */ } 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); } })();
|