@andorra-labs/code 0.1.10 → 0.1.12
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 +31 -205
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/src/agent-execution.js +50 -2
- package/dist/src/agent-mcp.js +5 -0
- package/dist/src/app-server/protocol.d.ts +9 -1
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server.d.ts +49 -1
- package/dist/src/app-server.js +353 -64
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-panel-tool.d.ts +24 -3
- package/dist/src/browser-panel-tool.js +80 -6
- package/dist/src/browser-runner.js +3 -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/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +38 -2
- package/dist/src/claude-provider.js +15 -2
- package/dist/src/cli.d.ts +2 -1
- package/dist/src/cli.js +175 -43
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +1 -1
- package/dist/src/codex-provider.js +6 -3
- package/dist/src/coding-tools.d.ts +26 -1
- package/dist/src/coding-tools.js +104 -33
- 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 +51 -1
- package/dist/src/completion.js +164 -5
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +2 -0
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/delegation-changes.js +19 -2
- package/dist/src/diff-preview.d.ts +1 -0
- package/dist/src/diff-preview.js +12 -3
- package/dist/src/engine-streams.d.ts +22 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.js +17 -6
- package/dist/src/file-read-key.d.ts +8 -0
- package/dist/src/file-read-key.js +12 -0
- package/dist/src/graph-editor-session.js +2 -1
- package/dist/src/graph-health.d.ts +21 -0
- package/dist/src/graph-health.js +46 -0
- package/dist/src/graph-manager-chat.d.ts +52 -3
- package/dist/src/graph-manager-chat.js +62 -17
- package/dist/src/graph-runner.js +62 -5
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +48 -27
- 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 +362 -123
- package/dist/src/graph-ui/controls.css +95 -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 +7 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/manager-state.js +143 -5
- package/dist/src/graph-ui/manager.css +21 -20
- package/dist/src/graph-ui/manager.js +337 -75
- package/dist/src/graph-ui/model-picker.js +279 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- 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 +5 -2
- package/dist/src/graphs.js +10 -9
- package/dist/src/mcp.d.ts +52 -14
- package/dist/src/mcp.js +285 -128
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/memory/ProjectMemory.d.ts +77 -0
- package/dist/src/memory/ProjectMemory.js +310 -0
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- package/dist/src/opencode-provider.js +5 -6
- package/dist/src/package-name.d.ts +3 -0
- package/dist/src/package-name.js +3 -0
- package/dist/src/provider-engine.js +2 -2
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/runtime/PtyManager.js +2 -1
- package/dist/src/react-runtime.js +137 -22
- 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/remote/cert.d.ts +1 -1
- package/dist/src/remote/cert.js +2 -7
- package/dist/src/remote/client.js +1 -1
- package/dist/src/remote/pem.d.ts +6 -0
- package/dist/src/remote/pem.js +11 -0
- package/dist/src/run-records.js +49 -10
- package/dist/src/runtime.d.ts +21 -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/sessions.d.ts +3 -1
- package/dist/src/sessions.js +5 -3
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/sign-in-detection.d.ts +82 -0
- package/dist/src/sign-in-detection.js +197 -0
- package/dist/src/sign-in-offer.d.ts +35 -0
- package/dist/src/sign-in-offer.js +116 -0
- 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 +59 -7
- 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.d.ts +6 -0
- package/dist/src/skills/runtime-skills.js +16 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/stray-files.d.ts +14 -0
- package/dist/src/stray-files.js +81 -0
- package/dist/src/subagent-run.js +6 -1
- package/dist/src/terminal-ui.d.ts +1 -1
- package/dist/src/terminal-ui.js +11 -5
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-activity.js +1 -1
- package/dist/src/tool-schema-compatibility.d.ts +7 -2
- package/dist/src/tool-schema-compatibility.js +8 -4
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.d.ts +5 -0
- package/dist/src/transcript.js +12 -4
- package/dist/src/types.d.ts +8 -0
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +125 -0
- package/dist/src/update-check.js +1 -1
- package/dist/src/update.d.ts +11 -1
- package/dist/src/update.js +27 -5
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/dist/src/workspace-git-metadata.d.ts +15 -0
- package/dist/src/workspace-git-metadata.js +50 -1
- package/dist/src/workspace-instructions.js +1 -1
- 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(); }
|
|
@@ -207,6 +299,7 @@ function applyProviderRegistry(value) {
|
|
|
207
299
|
// A changed registry can move the default provider or the endpoint's catalog, so discovered
|
|
208
300
|
// suggestions must not survive it; the next inspector render rediscovers against live config.
|
|
209
301
|
state.providerModelRequests = new Map();
|
|
302
|
+
state.providerModelCatalogs = new Map();
|
|
210
303
|
// The same reasoning applies to the record-on-commit dedupe: a model that was recorded under
|
|
211
304
|
// the previous registry may have been removed from the provider's configured list since, and
|
|
212
305
|
// a stale entry would suppress the re-POST that makes such a selection runnable again.
|
|
@@ -307,13 +400,13 @@ function issues() {
|
|
|
307
400
|
const result = [], nodes = Object.values(graph.nodes);
|
|
308
401
|
if (nodes.length < 2 || nodes.length > nodeLimit(graph)) result.push({ message: `Use between 2 and ${nodeLimit(graph)} steps; remove extra steps before saving.` });
|
|
309
402
|
if (freeTier()) {
|
|
310
|
-
if (!freeGraphEditable(graph)) result.push({ message: graph.revision ? 'On the free tier only your first custom
|
|
403
|
+
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
404
|
if (nodes.some(node => node.agentRole === 'orchestrator')) result.push({ message: FREE_ORCHESTRATOR_TIP });
|
|
312
405
|
if (countedNodes(graph) > state.plan.nodeLimit) result.push({ message: freeNodeTip() });
|
|
313
406
|
}
|
|
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
|
|
407
|
+
if (new TextEncoder().encode(JSON.stringify(graph)).byteLength > 512 * 1024) result.push({ message: 'Graph exceeds 512 KiB; shorten instructions or remove steps before saving.' });
|
|
408
|
+
if (!graph.name.trim()) result.push({ message: 'Give this graph a name.' });
|
|
409
|
+
if (graph.name.length > 200) result.push({ message: 'Keep the graph name to 200 characters or fewer.' });
|
|
317
410
|
if (graph.metadata?.description?.length > 2000) result.push({ message: 'Keep the description to 2000 characters or fewer.' });
|
|
318
411
|
if (Array.isArray(graph.widgets) && graph.widgets.length > 5) result.push({ message: 'Use at most 5 widgets.' });
|
|
319
412
|
const widgetIds = new Set();
|
|
@@ -353,12 +446,49 @@ function scheduleValidation() {
|
|
|
353
446
|
const snapshot = JSON.stringify(state.graph);
|
|
354
447
|
state.validationTimer = setTimeout(async () => {
|
|
355
448
|
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(); } }
|
|
449
|
+
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
450
|
}, 350);
|
|
358
451
|
}
|
|
452
|
+
// The workflow on the canvas, kept for this tab in session storage, so a reload of the editor — the
|
|
453
|
+
// desktop's Reload Editor, or the browser's — opens it again rather than the first in the list. An
|
|
454
|
+
// unsaved one is reopened from the draft the reload kept of it.
|
|
455
|
+
const OPEN_KEY = 'andorra-graph-open';
|
|
456
|
+
let rememberedOpen;
|
|
457
|
+
function rememberOpenGraph() {
|
|
458
|
+
// Before boot has opened anything there is nothing to remember, and the last value must survive
|
|
459
|
+
// until boot has read it.
|
|
460
|
+
if (!state.graph) return;
|
|
461
|
+
const value = JSON.stringify({ id: state.graph.id, unsaved: !!state.dirty });
|
|
462
|
+
if (value === rememberedOpen) return;
|
|
463
|
+
rememberedOpen = value;
|
|
464
|
+
try { sessionStorage.setItem(OPEN_KEY, value); } catch { /* Storage is unavailable; boot opens the first workflow. */ }
|
|
465
|
+
}
|
|
466
|
+
function rememberedGraph() {
|
|
467
|
+
try {
|
|
468
|
+
const value = JSON.parse(sessionStorage.getItem(OPEN_KEY) || 'null');
|
|
469
|
+
return value && typeof value.id === 'string' ? { id: value.id, unsaved: value.unsaved === true } : null;
|
|
470
|
+
} catch { return null; }
|
|
471
|
+
}
|
|
472
|
+
// Reopen what the tab had open before it reloaded: the newest draft of it when it held unsaved work
|
|
473
|
+
// (the reload kept that work as a draft first), else its saved version. False when there is nothing
|
|
474
|
+
// to reopen, and boot opens the first workflow as before.
|
|
475
|
+
async function reopenRemembered() {
|
|
476
|
+
const remembered = rememberedGraph();
|
|
477
|
+
if (!remembered || graphLocked(remembered.id)) return false;
|
|
478
|
+
const saved = state.graphs.some(graph => graph.id === remembered.id);
|
|
479
|
+
if (remembered.unsaved || !saved) {
|
|
480
|
+
try {
|
|
481
|
+
state.drafts = await api('/api/drafts');
|
|
482
|
+
const draft = state.drafts.find(item => item.graphId === remembered.id);
|
|
483
|
+
if (draft) { await openDraft(draft.snapshot, draft.graphId); return state.graph?.id === remembered.id; }
|
|
484
|
+
} catch { /* Fall back to the saved version. */ }
|
|
485
|
+
}
|
|
486
|
+
return saved && await openGraph(remembered.id);
|
|
487
|
+
}
|
|
359
488
|
function renderHeading() {
|
|
360
|
-
|
|
361
|
-
$('
|
|
489
|
+
rememberOpenGraph();
|
|
490
|
+
$('graph-title').textContent = state.graph?.name || 'Graph Editor';
|
|
491
|
+
$('revision').textContent = state.graph ? `${state.graph.revision ? `Version ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
|
|
362
492
|
$('save').disabled = state.saving || !state.graph || !state.dirty || state.graph.id === 'default';
|
|
363
493
|
$('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
|
|
364
494
|
$('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
|
|
@@ -373,14 +503,28 @@ function renderHeading() {
|
|
|
373
503
|
function graphOpened(reason) { state.openReason = reason; globalThis.AndorraManager?.graphOpened(reason); }
|
|
374
504
|
function renderList() {
|
|
375
505
|
$('new-graph').disabled = state.saving || !canCreateGraph();
|
|
376
|
-
$('new-graph').title = canCreateGraph() ? 'Create
|
|
506
|
+
$('new-graph').title = canCreateGraph() ? 'Create graph' : FREE_CREATE_TIP;
|
|
377
507
|
$('duplicate').disabled = state.saving || !state.graph || !canCreateGraph();
|
|
378
508
|
$('duplicate').title = canCreateGraph() ? '' : FREE_CREATE_TIP;
|
|
509
|
+
$('empty-create').disabled = state.saving || !canCreateGraph();
|
|
510
|
+
$('empty-create').title = canCreateGraph() ? '' : FREE_CREATE_TIP;
|
|
379
511
|
$('graphs').replaceChildren();
|
|
380
|
-
|
|
381
|
-
|
|
512
|
+
const query = $('search').value.toLowerCase();
|
|
513
|
+
const listed = state.graphs.filter(graph => graph.name.toLowerCase().includes(query));
|
|
514
|
+
for (const graph of listed) {
|
|
515
|
+
const locked = graphLocked(graph.id);
|
|
516
|
+
const button = el('button', undefined, `graph-row${state.graph?.id === graph.id ? ' active' : ''}${locked ? ' locked' : ''}`);
|
|
382
517
|
button.disabled = state.saving;
|
|
383
|
-
|
|
518
|
+
const tag = el('small', graph.id === 'default' ? 'Preset' : `v${graph.revision}`);
|
|
519
|
+
button.append(el('span', graph.name), tag);
|
|
520
|
+
// A locked row stays focusable so its tooltip and context menu (Export, Delete) still reach it;
|
|
521
|
+
// aria-disabled says it cannot be opened, and a click explains why instead.
|
|
522
|
+
if (locked) {
|
|
523
|
+
button.setAttribute('aria-disabled', 'true');
|
|
524
|
+
button.title = FREE_LOCKED_TIP;
|
|
525
|
+
const glyph = globalThis.AndorraIcons?.icon?.('lock', 12);
|
|
526
|
+
if (glyph) tag.prepend(glyph);
|
|
527
|
+
}
|
|
384
528
|
button.onclick = () => openGraph(graph.id);
|
|
385
529
|
button.oncontextmenu = event => { event.preventDefault(); showGraphMenu(graph, event.clientX, event.clientY); };
|
|
386
530
|
$('graphs').append(button);
|
|
@@ -400,14 +544,16 @@ function renderList() {
|
|
|
400
544
|
head.append(clear); $('graphs').append(head);
|
|
401
545
|
}
|
|
402
546
|
for (const draft of shown) {
|
|
403
|
-
const
|
|
547
|
+
const locked = graphLocked(draft.graphId);
|
|
548
|
+
const button = el('button', undefined, `graph-row draft-row${locked ? ' locked' : ''}`); button.disabled = state.saving;
|
|
404
549
|
const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
|
|
405
550
|
const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
|
|
406
|
-
button.title = `${draft.name} — draft saved ${saved}`;
|
|
551
|
+
button.title = locked ? FREE_LOCKED_TIP : `${draft.name} — draft saved ${saved}`;
|
|
552
|
+
if (locked) { button.setAttribute('aria-disabled', 'true'); const glyph = globalThis.AndorraIcons?.icon?.('lock', 12); if (glyph) when.prepend(glyph); }
|
|
407
553
|
button.append(el('span', draft.name), when);
|
|
408
|
-
button.onclick = () => openDraft(draft.snapshot);
|
|
554
|
+
button.onclick = () => openDraft(draft.snapshot, draft.graphId);
|
|
409
555
|
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) },
|
|
556
|
+
...(locked ? [] : [{ label: 'Open Draft', icon: 'history', run: () => openDraft(draft.snapshot, draft.graphId) }]),
|
|
411
557
|
{ label: 'Clear Draft', icon: 'trash', danger: true, run: () => clearDrafts([draft]) },
|
|
412
558
|
]); };
|
|
413
559
|
$('graphs').append(button);
|
|
@@ -422,6 +568,20 @@ function renderList() {
|
|
|
422
568
|
history.append(el('span', state.showDraftHistory ? 'Draft history' : `Draft history (${matching.length})`));
|
|
423
569
|
history.onclick = () => { state.showDraftHistory = !state.showDraftHistory; renderList(); }; $('graphs').append(history);
|
|
424
570
|
}
|
|
571
|
+
// A filter that matches nothing says so, in the EmptyState's anatomy, rather than leaving a gap.
|
|
572
|
+
if (query && !listed.length && !matching.length) $('graphs').append(emptyState('search', 'No graphs match', 'Try another name, or clear the filter.'));
|
|
573
|
+
}
|
|
574
|
+
// The desktop's EmptyState (components/ui.tsx): a 16px mark, a 13/500 title, a 12px muted line and at
|
|
575
|
+
// most one button. In the rail's lists it is the compact kind.
|
|
576
|
+
function emptyState(icon, title, line, action) {
|
|
577
|
+
const box = el('div', undefined, 'empty-state empty-state-compact');
|
|
578
|
+
box.setAttribute('role', 'status');
|
|
579
|
+
const glyph = globalThis.AndorraIcons?.icon?.(icon);
|
|
580
|
+
if (glyph) { const mark = el('span', undefined, 'empty-state-icon'); mark.append(glyph); box.append(mark); }
|
|
581
|
+
box.append(el('p', title, 'empty-state-title'));
|
|
582
|
+
if (line) box.append(el('p', line, 'empty-state-line'));
|
|
583
|
+
if (action) { const row = el('div', undefined, 'empty-state-action'); row.append(action); box.append(row); }
|
|
584
|
+
return box;
|
|
425
585
|
}
|
|
426
586
|
// Clearing takes a graph's drafts off the list; saved graphs and their revisions are untouched.
|
|
427
587
|
// The open graph's edits are not lost: its next autosave is a new draft.
|
|
@@ -429,7 +589,7 @@ async function clearDrafts(drafts, all = false) {
|
|
|
429
589
|
const graphIds = [...new Set(drafts.map(draft => draft.graphId))];
|
|
430
590
|
if (!graphIds.length) return;
|
|
431
591
|
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
|
|
592
|
+
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
593
|
try { state.drafts = await api('/api/drafts/clear', { graphIds }); if (!state.drafts.length) state.showDraftHistory = false; renderList(); status(one ? 'Draft cleared' : 'Drafts cleared'); }
|
|
434
594
|
catch (error) { status('Drafts not cleared: ' + error.message, true); }
|
|
435
595
|
}
|
|
@@ -447,10 +607,12 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
447
607
|
menu.setAttribute('role', 'menu'); menu.setAttribute('aria-label', ariaLabel);
|
|
448
608
|
const buttons = [];
|
|
449
609
|
for (const item of items) {
|
|
450
|
-
|
|
610
|
+
// A destructive item is a neutral row below a divider (C7); its confirmation names the loss.
|
|
611
|
+
if (item.danger && buttons.length) { const rule = el('hr'); rule.setAttribute('role', 'separator'); menu.append(rule); }
|
|
612
|
+
const button = el('button', item.label);
|
|
451
613
|
button.type = 'button'; button.setAttribute('role', 'menuitem');
|
|
452
614
|
if (item.icon) button.setAttribute('data-icon', item.icon);
|
|
453
|
-
if (item.danger) button.
|
|
615
|
+
if (item.danger) button.setAttribute('data-destructive', 'true');
|
|
454
616
|
button.onclick = () => { closeGraphMenu(); item.run(); };
|
|
455
617
|
menu.append(button); buttons.push(button);
|
|
456
618
|
}
|
|
@@ -471,15 +633,15 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
471
633
|
};
|
|
472
634
|
const outside = event => { if (!menu.contains(event.target)) close(); };
|
|
473
635
|
// The toolbar overflow's menu-button pattern: the opening takes focus, arrows move between
|
|
474
|
-
// items, Escape
|
|
636
|
+
// items, Escape and Tab close it and hand focus back to where it was, so focus never falls to the
|
|
637
|
+
// page as the menu leaves.
|
|
475
638
|
menu.onkeydown = event => {
|
|
476
639
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
477
640
|
event.preventDefault();
|
|
478
641
|
const index = buttons.indexOf(document.activeElement);
|
|
479
642
|
buttons[(index + (event.key === 'ArrowDown' ? 1 : -1) + buttons.length) % buttons.length]?.focus();
|
|
480
643
|
}
|
|
481
|
-
else if (event.key === 'Escape') { event.preventDefault(); close(true); }
|
|
482
|
-
else if (event.key === 'Tab') close();
|
|
644
|
+
else if (event.key === 'Escape' || event.key === 'Tab') { event.preventDefault(); close(true); }
|
|
483
645
|
};
|
|
484
646
|
window.addEventListener?.('pointerdown', outside, true);
|
|
485
647
|
closeGraphMenuHandlers = close;
|
|
@@ -487,7 +649,8 @@ function showMenuAt(x, y, ariaLabel, items) {
|
|
|
487
649
|
}
|
|
488
650
|
function showGraphMenu(graph, x, y) {
|
|
489
651
|
const items = [
|
|
490
|
-
|
|
652
|
+
// A locked workflow cannot seed a copy: the copy would be a second custom workflow.
|
|
653
|
+
...(graphLocked(graph.id) ? [] : [{ label: 'Duplicate', icon: 'copy', run: () => duplicateGraph(graph) }]),
|
|
491
654
|
{ label: 'Export JSON', icon: 'download', run: () => { exportGraph(graph).catch(error => status(error.message, true)); } },
|
|
492
655
|
];
|
|
493
656
|
// The preset is bundled with the CLI: it has no storage to remove, and hiding it would only
|
|
@@ -496,9 +659,9 @@ function showGraphMenu(graph, x, y) {
|
|
|
496
659
|
showMenuAt(x, y, `${graph.name} actions`, items);
|
|
497
660
|
}
|
|
498
661
|
function showNewGraphMenu(x, y) {
|
|
499
|
-
showMenuAt(x, y, 'Create a
|
|
500
|
-
{ label: 'New
|
|
501
|
-
{ label: 'Import
|
|
662
|
+
showMenuAt(x, y, 'Create a graph', [
|
|
663
|
+
{ label: 'New Graph', icon: 'plus', run: () => newGraph() },
|
|
664
|
+
{ 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
665
|
]);
|
|
503
666
|
}
|
|
504
667
|
// The saved revision a row names is what a friend receives: the open draft's unsaved edits are
|
|
@@ -506,7 +669,7 @@ function showNewGraphMenu(x, y) {
|
|
|
506
669
|
// the file itself; a plain browser downloads the fetched revision directly.
|
|
507
670
|
async function exportGraph(graph) {
|
|
508
671
|
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
|
|
672
|
+
if (state.saving) { status('Wait for the current save before exporting a graph.'); return; }
|
|
510
673
|
downloadGraph(dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(graph.id)}`)));
|
|
511
674
|
}
|
|
512
675
|
function exportFileName(graph) {
|
|
@@ -520,14 +683,14 @@ function downloadJson(value, stem) {
|
|
|
520
683
|
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
521
684
|
}
|
|
522
685
|
async function duplicateGraph(source) {
|
|
523
|
-
if (state.saving) { status('Wait for the current save before duplicating a
|
|
686
|
+
if (state.saving) { status('Wait for the current save before duplicating a graph.'); return; }
|
|
524
687
|
state.saving = true; renderHeading(); renderList();
|
|
525
688
|
let created;
|
|
526
689
|
try {
|
|
527
690
|
const saved = dropLegacyTokenFields(await api(`/api/graphs/${encodeURIComponent(source.id)}`));
|
|
528
691
|
// validateGraph caps names at 200 characters, so a near-limit source name must make room
|
|
529
692
|
// 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
|
|
693
|
+
const suffix = ' (Copy)', base = saved.name || 'Untitled graph';
|
|
531
694
|
const name = base.length + suffix.length > 200 ? base.slice(0, 200 - suffix.length).trimEnd() + suffix : base + suffix;
|
|
532
695
|
const duplicate = { ...saved, id: newId(), name, revision: 0 };
|
|
533
696
|
const stored = await api('/api/graphs', duplicate);
|
|
@@ -541,13 +704,13 @@ async function duplicateGraph(source) {
|
|
|
541
704
|
if (!created) return;
|
|
542
705
|
if (state.dirty) { status(`Created "${created.name}". Open it from the list to rename it.`); return; }
|
|
543
706
|
await openGraph(created.id, { reason: 'duplicate' });
|
|
544
|
-
if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in
|
|
707
|
+
if (state.graph?.id === created.id) status(`Duplicated "${source.name}". Rename it in Graph settings.`);
|
|
545
708
|
}
|
|
546
709
|
// Deleting removes the graph, its revisions and its draft history from this machine, and for a
|
|
547
710
|
// signed-in account the cloud copies stop restoring it. The confirm names that loss: there is no undo.
|
|
548
711
|
async function deleteGraph(graph) {
|
|
549
|
-
if (state.saving) { status('Wait for the current save before deleting a
|
|
550
|
-
if (!
|
|
712
|
+
if (state.saving) { status('Wait for the current save before deleting a graph.'); return; }
|
|
713
|
+
if (!await askConfirm({ title: `Delete “${graph.name}”?`, message: 'Its versions and drafts are removed from this machine.', confirmLabel: 'Delete', tone: 'danger' })) return;
|
|
551
714
|
state.saving = true; renderHeading(); renderList();
|
|
552
715
|
// The confirm accepted the loss of unsaved edits of the deleted graph, so no draft of it may
|
|
553
716
|
// outlive it: stop its queued write, and let an in-flight one land before the deletion's
|
|
@@ -629,7 +792,7 @@ function nodeSubtitle(node) {
|
|
|
629
792
|
const model = nodeModelLabel(node);
|
|
630
793
|
return node.agentRole === 'orchestrator' ? `Orchestrator${model ? ' · ' + model : ''}` : model;
|
|
631
794
|
}
|
|
632
|
-
if (node.type === 'end') return '
|
|
795
|
+
if (node.type === 'end') return 'Graph complete';
|
|
633
796
|
if (node.type === 'action') return node.action?.kind === 'tests' ? 'Run tests' : node.action?.kind === 'git' ? 'Git operation' : 'Run command';
|
|
634
797
|
return { join: 'Wait for branches', loop: 'Bounded repetition', condition: 'Branch on run state', parallel: 'Fan out', approval: 'Human approval' }[node.type] || 'Flow control';
|
|
635
798
|
}
|
|
@@ -826,7 +989,7 @@ function renderEdges() {
|
|
|
826
989
|
function removeNodes(ids) {
|
|
827
990
|
const graph = state.graph;
|
|
828
991
|
const remaining = Object.keys(graph.nodes).filter(id => !ids.has(id));
|
|
829
|
-
if (!remaining.length) { status('Keep at least one step as the
|
|
992
|
+
if (!remaining.length) { status('Keep at least one step as the graph start. Add a replacement before deleting all steps.', true); return; }
|
|
830
993
|
const nextEntry = ids.has(graph.entry)
|
|
831
994
|
? graph.edges.find(edge => edge.source === graph.entry && !ids.has(edge.target) && graph.nodes[edge.target])?.target ?? remaining[0]
|
|
832
995
|
: graph.entry;
|
|
@@ -877,7 +1040,7 @@ function nodeErrorIds() {
|
|
|
877
1040
|
}
|
|
878
1041
|
function renderValidation() {
|
|
879
1042
|
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
|
|
1043
|
+
if(!errors.length)container.append(el('p',state.validated?'Validated · Ready to save':'Checking graph…',state.validated?'valid ok':'valid'));
|
|
881
1044
|
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
1045
|
}
|
|
883
1046
|
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; }
|
|
@@ -1000,15 +1163,49 @@ function capabilities(parent, policy, update, ceiling) {
|
|
|
1000
1163
|
}
|
|
1001
1164
|
}
|
|
1002
1165
|
let modelSuggestionSeq = 0;
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* The closed model control (model-picker.js draws the column it opens): the model's name, its
|
|
1168
|
+
* provider's mark and name, and a chevron. `spec.current()` names what it shows; the rest of the
|
|
1169
|
+
* spec is what the panel reads each time it draws.
|
|
1170
|
+
*/
|
|
1171
|
+
function modelPickerButton(spec) {
|
|
1172
|
+
const button = el('button', undefined, 'model-picker-trigger'); button.type = 'button';
|
|
1173
|
+
button.setAttribute('aria-haspopup', 'dialog'); button.setAttribute('aria-expanded', 'false');
|
|
1174
|
+
button.modelPicker = spec;
|
|
1175
|
+
button.redraw = () => {
|
|
1176
|
+
const { model, provider, entry, note } = spec.current();
|
|
1177
|
+
button.replaceChildren();
|
|
1178
|
+
const mark = globalThis.AndorraModelPicker?.mark?.(entry);
|
|
1179
|
+
if (mark) button.append(mark);
|
|
1180
|
+
button.append(el('span', model, 'model-picker-trigger-name'));
|
|
1181
|
+
// An unpinned selection says so, so a model the step follows is not mistaken for one it names.
|
|
1182
|
+
if (note) button.append(el('span', note, 'model-picker-trigger-note'));
|
|
1183
|
+
if (provider) button.append(el('span', provider, 'model-picker-trigger-provider'));
|
|
1184
|
+
const chevron = el('span', undefined, 'model-picker-trigger-chevron'); const glyph = globalThis.AndorraIcons?.icon?.('chevron-down', 14); if (glyph) chevron.append(glyph);
|
|
1185
|
+
button.append(chevron);
|
|
1186
|
+
button.setAttribute('aria-label', `${spec.ariaLabel}: ${model}${note ? ` (${note})` : ''}${provider ? `, ${provider}` : ''}`);
|
|
1187
|
+
button.title = [model + (note ? ` (${note})` : ''), provider].filter(Boolean).join(' · ');
|
|
1188
|
+
};
|
|
1189
|
+
button.redraw();
|
|
1190
|
+
button.onclick = () => globalThis.AndorraModelPicker?.toggle(button);
|
|
1191
|
+
return button;
|
|
1192
|
+
}
|
|
1193
|
+
// Every provider's models for the picker: what it has configured, then what its endpoint lists.
|
|
1194
|
+
// Discovery is requested once per provider and kept until the provider registry changes.
|
|
1195
|
+
function discoverProviderModels(providerId) {
|
|
1196
|
+
state.providerModelRequests ||= new Map();
|
|
1197
|
+
state.providerModelCatalogs ||= new Map();
|
|
1198
|
+
const registryGeneration = state.providerRegistryGeneration || 0;
|
|
1199
|
+
if (!state.providerModelRequests.has(providerId)) state.providerModelRequests.set(providerId, api(`/api/provider-models?provider=${encodeURIComponent(providerId)}`).catch(() => ({ models: [] })));
|
|
1200
|
+
return state.providerModelRequests.get(providerId).then(data => {
|
|
1201
|
+
if ((state.providerRegistryGeneration || 0) !== registryGeneration) return data;
|
|
1202
|
+
state.providerModelCatalogs.set(providerId, (data.models || []).map(name => name?.trim()).filter(Boolean));
|
|
1203
|
+
return data;
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
function modelFields(parent, target, update, parentModel, inheritedProvider, fallbackProvider, options = {}) {
|
|
1207
|
+
// One control in the chat's model picker format: every configured provider's models, grouped
|
|
1208
|
+
// under the provider's name, with the step's own default pinned at the top.
|
|
1012
1209
|
// A providerless subagent child inherits the parent node's provider at execution
|
|
1013
1210
|
// (bindPortableGraphProviders adds its model to the parent's requirements), so the suggestions
|
|
1014
1211
|
// shown here and the recording that makes a discovered pick runnable must resolve against that
|
|
@@ -1019,20 +1216,56 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1019
1216
|
// Every model the resolved provider serves: its configured models first, then whatever its
|
|
1020
1217
|
// endpoint lists once discovery answers (filled in by addModelOption below). Picking one commits
|
|
1021
1218
|
// through the custom-name field so a discovered pick is recorded exactly as a typed one is.
|
|
1022
|
-
const picker = field(parent, 'Model', '', () => {}, { options: [] });
|
|
1023
|
-
const pickerModels = [];
|
|
1024
1219
|
const inheritedModel = parentModel?.trim() || activeName;
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1220
|
+
const effectiveProvider = target.provider || listingProvider;
|
|
1221
|
+
const entryFor = id => { const p = state.providers.find(item => idFor(item) === id); return p ? { id, label: titleFor(p), type: p.type, baseUrl: p.baseUrl } : id ? { id, label: `${id} (unavailable)` } : undefined; };
|
|
1222
|
+
const configuredOn = id => { const p = state.providers.find(item => idFor(item) === id); return [p?.model, ...(p?.models || [])].map(name => name?.trim()).filter(Boolean); };
|
|
1223
|
+
const pickerModels = [];
|
|
1224
|
+
const defaultLabel = options.defaultLabel || (inheritedProvider || parentModel ? 'Same as parent agent' : 'Use configured default');
|
|
1225
|
+
// The default row clears both overrides, so its hint names what applies afterwards: the inherited
|
|
1226
|
+
// or configured default provider and the parent's model or that provider's active one, never the
|
|
1227
|
+
// explicit selection it is about to replace.
|
|
1228
|
+
const clearedProvider = inheritedProvider || state.defaultProvider || '';
|
|
1229
|
+
const clearedModel = parentModel?.trim() || state.providers.find(p => idFor(p) === clearedProvider)?.model?.trim() || '';
|
|
1230
|
+
const defaultHint = options.defaultLabel ? '' : [clearedProvider ? entryFor(clearedProvider)?.label : '', clearedModel].filter(Boolean).join(' · ');
|
|
1231
|
+
const pickerButton = modelPickerButton({
|
|
1232
|
+
ariaLabel: 'Model',
|
|
1233
|
+
current: () => {
|
|
1234
|
+
const pinned = target.model?.trim();
|
|
1235
|
+
const entry = entryFor(effectiveProvider);
|
|
1236
|
+
if (!pinned && !target.provider && options.defaultLabel) return { model: options.defaultLabel, provider: '', entry: undefined };
|
|
1237
|
+
return { model: pinned || inheritedModel || 'Provider default', note: pinned || !inheritedModel ? '' : 'default', provider: entry?.label || '', entry };
|
|
1238
|
+
},
|
|
1239
|
+
groups: () => {
|
|
1240
|
+
const ids = state.providers.map(idFor);
|
|
1241
|
+
if (target.provider && !ids.includes(target.provider)) ids.push(target.provider);
|
|
1242
|
+
return ids.map(id => {
|
|
1243
|
+
const active = state.providers.find(item => idFor(item) === id)?.model?.trim() || '';
|
|
1244
|
+
const names = [...configuredOn(id), ...(state.providerModelCatalogs?.get(id) || [])];
|
|
1245
|
+
if (id === effectiveProvider) names.push(...pickerModels);
|
|
1246
|
+
return { provider: entryFor(id), models: [...new Set(names)].map(model => ({ model, note: model === active ? 'active' : '' })) };
|
|
1247
|
+
});
|
|
1248
|
+
},
|
|
1249
|
+
selected: () => target.model?.trim() ? { provider: effectiveProvider, model: target.model.trim() } : null,
|
|
1250
|
+
defaultRow: () => options.noDefault ? undefined : ({ label: defaultLabel, hint: defaultHint, selected: !target.provider && !target.model?.trim() }),
|
|
1251
|
+
pickDefault: () => mutate(() => update({ ...target, provider: undefined, model: undefined }), true),
|
|
1252
|
+
pick: ({ provider: chosenProvider, model: chosenModel }) => {
|
|
1253
|
+
// A model of the provider this selection already resolves to commits through the custom-name
|
|
1254
|
+
// field, as a typed name does, so a providerless child keeps inheriting its parent's provider
|
|
1255
|
+
// and a discovered pick is recorded (on the retry fallback too) the way it always was.
|
|
1256
|
+
if (chosenProvider === effectiveProvider && !(options.requireProvider && !target.provider)) { model.value = chosenModel; model.onchange(); return; }
|
|
1257
|
+
mutate(() => update({ ...target, provider: chosenProvider, model: chosenModel }), true);
|
|
1258
|
+
// Execution validates an explicit model against the provider's configured list, so a model only
|
|
1259
|
+
// its endpoint lists is recorded with that provider, as /model does.
|
|
1260
|
+
if (!configuredOn(chosenProvider).includes(chosenModel) && state.providerModelCatalogs?.get(chosenProvider)?.includes(chosenModel)) recordWith(chosenProvider, chosenModel);
|
|
1261
|
+
},
|
|
1262
|
+
onOpen: () => {
|
|
1263
|
+
for (const p of state.providers) discoverProviderModels(idFor(p)).then(() => globalThis.AndorraModelPicker?.refresh?.(pickerButton));
|
|
1264
|
+
},
|
|
1265
|
+
});
|
|
1266
|
+
const pickerField = el('div', undefined, 'field model-picker-field'); pickerField.append(el('span', 'Model'), pickerButton); parent.append(pickerField);
|
|
1267
|
+
const renderPicker = () => { pickerButton.redraw(); globalThis.AndorraModelPicker?.refresh?.(pickerButton); };
|
|
1268
|
+
if (target.provider && !state.providers.some(p => idFor(p) === target.provider)) providerWarning(parent, target.provider);
|
|
1036
1269
|
// Surface portability without rewriting the synced revision or local credentials. The alias must
|
|
1037
1270
|
// satisfy every reference to the original provider graph-wide (bindPortableGraphProviders groups
|
|
1038
1271
|
// them), so the hint mirrors that grouping instead of promising an alias execution would refuse.
|
|
@@ -1085,15 +1318,15 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1085
1318
|
const typeMismatch = claimed && !!recorded?.type && claimedProvider.type !== recorded.type;
|
|
1086
1319
|
const matches = !claimed && recorded?.type === 'codex' ? state.providers.filter(p => p.type === 'codex' && offers(p, requiredModels)) : [];
|
|
1087
1320
|
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
|
|
1321
|
+
? `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.`
|
|
1322
|
+
: `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
1323
|
const hint = matches.length === 1
|
|
1091
1324
|
? `Will use local Codex OAuth profile "${idFor(matches[0])}" (${requiredModels.join(', ') || 'all referenced models'}). The OAuth connection is verified before execution.`
|
|
1092
1325
|
: matches.length > 1
|
|
1093
|
-
? `Multiple local Codex OAuth profiles (${matches.map(idFor).join(', ')}) each satisfy this
|
|
1326
|
+
? `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
1327
|
: claimed
|
|
1095
1328
|
? refusalHint
|
|
1096
|
-
: `Provider "${originalId}"${requiredModels.length ? ` / ${requiredModels.join(', ')}` : ''} is not configured on this machine. This
|
|
1329
|
+
: `Provider "${originalId}"${requiredModels.length ? ` / ${requiredModels.join(', ')}` : ''} is not configured on this machine. This graph can be saved, but execution requires a compatible provider.`;
|
|
1097
1330
|
parent.append(el('p', hint, 'help'));
|
|
1098
1331
|
} else if (followsProvider && recorded?.model && recorded.model !== exact.model) {
|
|
1099
1332
|
parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
|
|
@@ -1130,8 +1363,8 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1130
1363
|
if (!value || displayed.has(value)) return;
|
|
1131
1364
|
displayed.add(value);
|
|
1132
1365
|
const option = el('option'); option.value = value; if (label) option.label = label; datalist.append(option);
|
|
1133
|
-
//
|
|
1134
|
-
// large catalog, and
|
|
1366
|
+
// An open panel is redrawn once per batch by the caller: redrawing per model is quadratic for a
|
|
1367
|
+
// large catalog, and the panel would be re-measured for every entry.
|
|
1135
1368
|
pickerModels.push(value);
|
|
1136
1369
|
return true;
|
|
1137
1370
|
};
|
|
@@ -1140,9 +1373,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1140
1373
|
renderPicker();
|
|
1141
1374
|
// Keyed by the resolved provider: a node using the configured default must follow that default's
|
|
1142
1375
|
// identity, not share a blank key that survives a default switch.
|
|
1143
|
-
|
|
1144
|
-
if (!state.providerModelRequests.has(listingProvider)) state.providerModelRequests.set(listingProvider, api(`/api/provider-models?provider=${encodeURIComponent(listingProvider)}`).catch(() => ({ models: [] })));
|
|
1145
|
-
state.providerModelRequests.get(listingProvider).then(data => {
|
|
1376
|
+
discoverProviderModels(listingProvider).then(data => {
|
|
1146
1377
|
if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
|
|
1147
1378
|
let added = false;
|
|
1148
1379
|
for (const name of data.models || []) {
|
|
@@ -1229,7 +1460,6 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
1229
1460
|
const initialWarning = state.providerModelWarnings?.get(warningKey(target.model?.trim() || ''));
|
|
1230
1461
|
if (initialWarning) override.append(el('p', initialWarning, 'help'));
|
|
1231
1462
|
}
|
|
1232
|
-
picker.onchange = () => { model.value = picker.value; model.onchange(); };
|
|
1233
1463
|
model.onchange = () => {
|
|
1234
1464
|
committed?.();
|
|
1235
1465
|
// Recording eligibility keys on whether the model still needs recording, not on whether the
|
|
@@ -1335,7 +1565,7 @@ function routes(parent, node) {
|
|
|
1335
1565
|
function renderEdgeInspector(parent, edge) {
|
|
1336
1566
|
$('inspector-title').textContent = 'Connection';
|
|
1337
1567
|
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
|
|
1568
|
+
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
1569
|
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
1570
|
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
1571
|
for (const [key, value] of Object.entries(edge.inputMapping || {})) {
|
|
@@ -1415,7 +1645,7 @@ function renderSubagents(parent, node) {
|
|
|
1415
1645
|
const delegating = delegatesWriting(node);
|
|
1416
1646
|
explain(check(parent,'Allow subagents',policy.enabled,value=>{set({enabled:value});pruneRoutes(node);}), delegating
|
|
1417
1647
|
? '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
|
|
1648
|
+
: '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
1649
|
if (!policy.enabled) return;
|
|
1420
1650
|
// The server refuses writing roles on an Orchestrator outside separate worktrees, so the
|
|
1421
1651
|
// editor moves the policy there as soon as a role may write.
|
|
@@ -1425,7 +1655,9 @@ function renderSubagents(parent, node) {
|
|
|
1425
1655
|
// Mirrors bindPortableGraphProviders: enabled retry attempts may spawn providerless children on
|
|
1426
1656
|
// the fallback provider, so a discovered child pick must be recorded there as well.
|
|
1427
1657
|
const childFallbackProvider = node.retry?.fallback && node.retry.maxAttempts > 1 ? node.retry.fallback.provider : '';
|
|
1428
|
-
|
|
1658
|
+
// Validation refuses a specific subagent model without a provider, so every pick names one and
|
|
1659
|
+
// there is no default row to clear it.
|
|
1660
|
+
if(policy.modelPolicy==='specific') modelFields(parent,policy,value=>set({provider:value.provider,model:value.model}),undefined,node.provider,childFallbackProvider,{requireProvider:true,noDefault:true});
|
|
1429
1661
|
const workspace = choice(parent,'Workspace policy',policy.workspace||'shared-read-only',[{value:'shared-read-only',label:'Shared workspace, read only'},{value:'shared-write',label:'Shared workspace, write allowed'},{value:'worktree',label:'Separate Git worktree'}],value=>set({workspace:value}));
|
|
1430
1662
|
if (delegating) { for (const option of workspace.options) option.disabled = option.value !== 'worktree'; explain(workspace, 'A writing role on an Orchestrator requires separate worktrees: each child edits its own copy, and the Orchestrator lands accepted changes into your working folder.'); }
|
|
1431
1663
|
choice(parent,'Tool inheritance',policy.toolInheritance||'restricted',[{value:'restricted',label:'Restricted subset'},{value:'inherit',label:'Inherit parent allowlist'}],value=>set({toolInheritance:value}));
|
|
@@ -1534,7 +1766,7 @@ function hasRetryCycle(graph) {
|
|
|
1534
1766
|
function retryLimitHelp(parent, graph) {
|
|
1535
1767
|
if (!hasRetryCycle(graph) || graph.limits?.maxNodeVisits || graph.limits?.wallTimeMs) return;
|
|
1536
1768
|
const box = el('div', undefined, 'cycle-help');
|
|
1537
|
-
box.append(el('strong', 'This
|
|
1769
|
+
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
1770
|
const fix = el('button', 'Limit Each Step to 3 Visits');
|
|
1539
1771
|
fix.onclick = () => mutate(() => { graph.limits = {...graph.limits, maxNodeVisits:3}; }, true);
|
|
1540
1772
|
const clock = el('button', 'Give the Run 30 Minutes');
|
|
@@ -1544,16 +1776,16 @@ function retryLimitHelp(parent, graph) {
|
|
|
1544
1776
|
function renderInspector() {
|
|
1545
1777
|
// A redraw replaces a full-screen prompt editor, so its backdrop goes with it.
|
|
1546
1778
|
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
|
|
1779
|
+
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
1780
|
if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
|
|
1549
|
-
const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : '
|
|
1781
|
+
const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Step settings' : 'Graph settings';
|
|
1550
1782
|
$('graph-settings').hidden = !node && !state.selectedEdge && selectedNodes().length <= 1;
|
|
1551
1783
|
retryLimitHelp(parent, graph);
|
|
1552
1784
|
if (state.selectedEdge) renderEdgeInspector(parent, state.selectedEdge);
|
|
1553
1785
|
else if (selectedNodes().length > 1) renderBulkInspector(parent,selectedNodes());
|
|
1554
1786
|
else if (!node) {
|
|
1555
1787
|
const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
|
|
1556
|
-
field(general, '
|
|
1788
|
+
field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
|
|
1557
1789
|
const meta = el('p', `${graph.id} · Version ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
|
|
1558
1790
|
if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
|
|
1559
1791
|
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 +1804,10 @@ function renderInspector() {
|
|
|
1572
1804
|
const add = el('button','Add Widget');
|
|
1573
1805
|
add.onclick = () => mutate(() => { graph.widgets = [...(graph.widgets ?? []), { id: `widget-${crypto.randomUUID().slice(0,8)}`, name: '', description: '' }]; }, true);
|
|
1574
1806
|
widgetGroup.append(add);
|
|
1575
|
-
widgetGroup.append(el('p','Up to 5 widgets per
|
|
1807
|
+
widgetGroup.append(el('p','Up to 5 widgets per graph. Names and descriptions are required before saving.','help'));
|
|
1576
1808
|
} else widgetGroup.append(el('p','Widget limit reached (5).','help'));
|
|
1577
1809
|
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
|
|
1810
|
+
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
1811
|
// Per-graph desktop settings render here; a browser-launched studio has no host bridge and skips them.
|
|
1580
1812
|
window.AndorraEmbed?.inspector?.(general);
|
|
1581
1813
|
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 +1817,14 @@ function renderInspector() {
|
|
|
1585
1817
|
if (node.type === 'agent') {
|
|
1586
1818
|
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
1819
|
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
|
|
1820
|
+
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
1821
|
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
1822
|
const model = panels.model;
|
|
1591
1823
|
modelFields(model, node, value => {node.provider=value.provider; node.model=value.model;});
|
|
1592
1824
|
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
1825
|
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
|
|
1826
|
+
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};});
|
|
1827
|
+
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
1828
|
renderCompletion(section(panels.behavior, node.agentRole === 'orchestrator' ? 'Routing' : 'Outcomes and conditions'), node);
|
|
1597
1829
|
renderModifiers(panels.behavior, node);
|
|
1598
1830
|
const advanced = panels.advanced;
|
|
@@ -1611,7 +1843,7 @@ function renderInspector() {
|
|
|
1611
1843
|
// Tool calls default to blank, and blank means unlimited: an absent limit is only
|
|
1612
1844
|
// written when the field is cleared, so a node keeps its ceiling once one is set.
|
|
1613
1845
|
field(limits,'Tool calls (blank = unlimited)',node.limits?.maxToolCalls,value=>{node.limits={...node.limits,maxToolCalls:value}; if(value===undefined)delete node.limits.maxToolCalls;},{type:'number',min:0,optional:true,placeholder:'Unlimited'});
|
|
1614
|
-
skillPrompt(field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000})); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retries',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};});
|
|
1846
|
+
skillPrompt(field(advanced,'System prompt',node.systemPrompt ?? node.prompt,value=>{node.systemPrompt=value; delete node.prompt;},{multiline:true,maxLength:100000})); jsonField(advanced,'Input schema (JSON Schema)',node.inputSchema,value=>{node.inputSchema=value;}); jsonField(advanced,'Output schema (JSON Schema)',node.outputSchema,value=>{node.outputSchema=value;}); field(advanced,'Retries',node.retry?.maxAttempts??1,value=>{node.retry={...node.retry,maxAttempts:value};},{type:'number',min:1}); const fallback=disclosure(advanced,'Fallback model'); modelFields(fallback,node.retry?.fallback||{},value=>{node.retry={maxAttempts:1,...node.retry,fallback:value.provider?{provider:value.provider,model:value.model}:undefined};},undefined,undefined,undefined,{requireProvider:true,defaultLabel:'No fallback model'});
|
|
1615
1847
|
field(advanced,'Executor','react-basic',()=>{}).disabled=true;
|
|
1616
1848
|
const tools = disclosure(advanced,'Tool allowlist');
|
|
1617
1849
|
for (const name of [...new Set([...state.tools.map(t=>typeof t==='string'?t:t.name||t.id),...(node.tools||[])])]) check(tools,name,node.tools===undefined||node.tools.includes(name),enabled=>{const all=state.tools.map(t=>typeof t==='string'?t:t.name||t.id); node.tools=enabled?[...new Set([...(node.tools??all),name])]:(node.tools??all).filter(t=>t!==name);});
|
|
@@ -1619,7 +1851,7 @@ function renderInspector() {
|
|
|
1619
1851
|
} else { general.append(el('p', 'This control step does not call a model and has no agent prompt.', 'help')); renderControlInspector(general,node); }
|
|
1620
1852
|
if (panels.behavior) routes(panels.behavior,node);
|
|
1621
1853
|
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
|
|
1854
|
+
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
1855
|
}
|
|
1624
1856
|
const validation=section(parent,'Validation');validation.id='validation';renderValidation();
|
|
1625
1857
|
window.AndorraStudio?.inspector?.(parent, node);
|
|
@@ -1629,14 +1861,15 @@ function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas
|
|
|
1629
1861
|
// established that loading loses nothing, or the user has asked for the load. Resolves to whether
|
|
1630
1862
|
// the graph was opened.
|
|
1631
1863
|
async function openGraph(id, options = {}) {
|
|
1632
|
-
if (state.saving) { status('Wait for the current save before opening another
|
|
1864
|
+
if (state.saving) { status('Wait for the current save before opening another graph.'); return false; }
|
|
1865
|
+
if (graphLocked(id)) { status(FREE_LOCKED_TIP, true); return false; }
|
|
1633
1866
|
if (state.dirty && !options.discard && !await askConfirm(DISCARD_QUESTION)) return false;
|
|
1634
1867
|
// 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
|
|
1868
|
+
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
1869
|
}
|
|
1637
1870
|
function newId() { return `graph-${crypto.randomUUID()}`; }
|
|
1638
1871
|
function newGraph(duplicate = false, discarded = false) {
|
|
1639
|
-
if (state.saving) { status('Wait for the current save before creating another
|
|
1872
|
+
if (state.saving) { status('Wait for the current save before creating another graph.'); return; }
|
|
1640
1873
|
if (!canCreateGraph()) { status(FREE_CREATE_TIP, true); return; }
|
|
1641
1874
|
// Unsaved edits are asked about first; a clean graph is replaced at once.
|
|
1642
1875
|
if (state.dirty && !discarded) { void askConfirm(DISCARD_QUESTION).then(discard => { if (discard) newGraph(duplicate, true); }); return; }
|
|
@@ -1644,25 +1877,25 @@ function newGraph(duplicate = false, discarded = false) {
|
|
|
1644
1877
|
else if (freeTier()) {
|
|
1645
1878
|
// A free graph starts from the Software Engineer alone: the Orchestrator is a Premium node.
|
|
1646
1879
|
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
|
|
1880
|
+
if(!engineerPreset){status('Starting presets are unavailable. Reload the Graph Editor and try again.',true);return;}
|
|
1881
|
+
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
1882
|
}
|
|
1650
1883
|
else {
|
|
1651
1884
|
const orchestratorPreset=state.definitions.find(definition=>definition.node.agentRole==='orchestrator')?.node;
|
|
1652
1885
|
const engineerPreset=state.definitions.find(definition=>definition.id==='software-engineer')?.node;
|
|
1653
|
-
if(!orchestratorPreset || !engineerPreset){status('Starting presets are unavailable. Reload the
|
|
1886
|
+
if(!orchestratorPreset || !engineerPreset){status('Starting presets are unavailable. Reload the Graph Editor and try again.',true);return;}
|
|
1654
1887
|
const orchestrator={...copy(orchestratorPreset),id:'orchestrator',position:{x:0,y:0}};
|
|
1655
1888
|
const engineer={...copy(engineerPreset),id:'engineer',position:{x:320,y:0}};
|
|
1656
1889
|
const inputMapping={originalTask:'$run.input.task'};
|
|
1657
1890
|
for(const key of ['taskInstruction','requirements','acceptanceCriteria','designConsiderations','codebaseFindings']) inputMapping[key]=`$source.output.${key}`;
|
|
1658
|
-
state.graph={schemaVersion:3,id:newId(),name:'Untitled
|
|
1891
|
+
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
1892
|
}
|
|
1660
1893
|
// A duplicate copies the open graph, providerless nodes included, so its unmet provider
|
|
1661
1894
|
// requirements travel with it; an unrelated new graph starts without any.
|
|
1662
|
-
state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
|
|
1895
|
+
markSaved(null); state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
|
|
1663
1896
|
state.untouched = JSON.stringify(state.graph);
|
|
1664
1897
|
state.pendingProviderNodes = duplicate ? new Set(state.pendingProviderNodes ?? []) : null;
|
|
1665
|
-
render(); fit(); status('New
|
|
1898
|
+
render(); fit(); status('New graph · Customize your agent, then save');
|
|
1666
1899
|
graphOpened(duplicate ? 'duplicate' : 'new');
|
|
1667
1900
|
}
|
|
1668
1901
|
// The settings a new Agent starts from, whether it is dropped on the canvas or added to the list.
|
|
@@ -1809,7 +2042,7 @@ function addAgent() {
|
|
|
1809
2042
|
libraryDialog('Add agent', [['Agent name', name], ['Description', description], ['Instructions', instruction]], async () => {
|
|
1810
2043
|
const agentName = requireAgentName(name);
|
|
1811
2044
|
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
|
|
2045
|
+
}, 'Add Agent');
|
|
1813
2046
|
skillPrompt(instruction);
|
|
1814
2047
|
}
|
|
1815
2048
|
// The server's 512 KiB limit applies to the import request, not the file: Share pretty-prints its
|
|
@@ -1859,7 +2092,7 @@ async function shareAgent(definition) {
|
|
|
1859
2092
|
// Built-in Agents have no Delete. Graphs that already use a deleted Agent keep their own copy.
|
|
1860
2093
|
async function deleteAgent(definition) {
|
|
1861
2094
|
if (definition.preset) return;
|
|
1862
|
-
if (!
|
|
2095
|
+
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
2096
|
try { await api(`/api/definitions/${encodeURIComponent(definition.id)}`, undefined, { method: 'DELETE' }); }
|
|
1864
2097
|
catch (error) {
|
|
1865
2098
|
// A lost response can still have deleted it, so the refreshed list decides what is reported.
|
|
@@ -1926,7 +2159,7 @@ function renderLibrary() {
|
|
|
1926
2159
|
const freeRefusal = freeNodeRefusal([{ type: item.type, agentRole: item.node?.agentRole }]);
|
|
1927
2160
|
if (freeRefusal) button.title = freeRefusal;
|
|
1928
2161
|
button.disabled = cannotAdd && !item.definition; button.draggable = !button.disabled && !freeRefusal;
|
|
1929
|
-
button.onclick = () => { if (cannotAdd) { status(state.graph ? '
|
|
2162
|
+
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
2163
|
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
2164
|
row.append(button);
|
|
1932
2165
|
// An Agent's actions are secondary, so they open from a right-click on the row (which the
|
|
@@ -1961,15 +2194,16 @@ function renderLibrary() {
|
|
|
1961
2194
|
parent.append(group); return group;
|
|
1962
2195
|
};
|
|
1963
2196
|
const agents = section(container, 'agents', 'Agents', [
|
|
1964
|
-
{id:'add', name:'Add
|
|
1965
|
-
{id:'import', name:'Import
|
|
2197
|
+
{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},
|
|
2198
|
+
{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
2199
|
...state.definitions.filter(d=>d.preset).map(definitionItem),
|
|
1967
2200
|
...state.definitions.filter(d=>!d.preset).map(definitionItem),
|
|
1968
2201
|
]);
|
|
1969
2202
|
if (agents) agents.append(el('p','Select an Agent to configure Condition, Loop, and Parallel modifiers.','help'));
|
|
1970
2203
|
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
2204
|
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
|
|
2205
|
+
section(container,'flow','Flow',[{name:'Human approval',type:'approval',description:'Pause for a decision'},{name:'End',type:'end',description:'Finish this graph path'}]);
|
|
2206
|
+
if (query && !container.children.length) container.append(emptyState('search', 'No steps match', 'Try another name, or clear the search.'));
|
|
1973
2207
|
}
|
|
1974
2208
|
// Fit, Arrange and the zoom buttons ease the view to where it is going, over --dur-3 on an ease-in-out
|
|
1975
2209
|
// with no overshoot, so the eye can follow the cards. A gesture (pan, pinch, wheel) stops the ease and
|
|
@@ -2017,12 +2251,12 @@ function zoomBy(factor) {
|
|
|
2017
2251
|
}
|
|
2018
2252
|
// A keyboard-activated click carries no pointer coordinates, so the menu falls back to the
|
|
2019
2253
|
// 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;
|
|
2254
|
+
$('new-graph').onclick = event => showNewGraphMenu(event?.clientX ?? 0, event?.clientY ?? 0); $('empty-create').onclick = () => newGraph(); $('duplicate').onclick = () => newGraph(true); $('search').oninput = renderList;
|
|
2021
2255
|
$('node-search').oninput = renderLibrary;
|
|
2022
2256
|
$('graph-settings').onclick = () => { clearSelection(); renderCanvas(); renderInspector(); };
|
|
2023
2257
|
$('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();
|
|
2258
|
+
$('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'); };
|
|
2259
|
+
$('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
2260
|
// A refused Save briefly pulses the outlined nodes, so the eye finds the cards it must fix
|
|
2027
2261
|
// before the run can be saved. No re-render happens on that early return, so the class lives.
|
|
2028
2262
|
function pulseErrorNodes() {
|
|
@@ -2049,7 +2283,7 @@ $('save').onclick = async () => {
|
|
|
2049
2283
|
try { const submitted = dropLegacyTokenFields(copy(state.graph)); const graph = await api('/api/graphs', submitted); if (state.graph.id === submitted.id) {
|
|
2050
2284
|
// The draft marker is editor state, not graph content, so a difference in it alone is not an edit.
|
|
2051
2285
|
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(); }
|
|
2286
|
+
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
2287
|
};
|
|
2054
2288
|
$('canvas-hint-close').onclick = dismissCanvasHint;
|
|
2055
2289
|
$('fit').onclick = () => fit(true); $('zoom-in').onclick = () => zoomBy(1.2); $('zoom-out').onclick = () => zoomBy(1 / 1.2);
|
|
@@ -2122,13 +2356,16 @@ if (token) setTimeout(refreshCloudState, 1000);
|
|
|
2122
2356
|
system notification (a Windows toast) fire when the CLI waits on the user. Every browser
|
|
2123
2357
|
entry point is feature-detected because this module also loads into partial-DOM harnesses.
|
|
2124
2358
|
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
|
-
|
|
2359
|
+
rather than the brand, so they keep their own artwork, drawn in the theme's neutral inks when they
|
|
2360
|
+
are set: both stand on the neutral accent's tile, with the turning ring or the wait's mark in the
|
|
2361
|
+
ink that sits on it, so either reads on a light or a dark tab strip. The chrome keeps no amber
|
|
2362
|
+
(P-LNT-16). Each fallback is the dark token's own value, for a page without the stylesheet. */
|
|
2363
|
+
const baseTitle = document.title || 'Graph Editor · Andorra Code';
|
|
2127
2364
|
const faviconHref = svg => 'data:image/svg+xml,' + encodeURIComponent(svg);
|
|
2128
2365
|
const FAVICONS = {
|
|
2129
|
-
idle: '/andorra-logo.png',
|
|
2130
|
-
running: faviconHref(
|
|
2131
|
-
'awaiting-input': faviconHref(
|
|
2366
|
+
idle: () => '/andorra-logo.png',
|
|
2367
|
+
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>`),
|
|
2368
|
+
'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
2369
|
};
|
|
2133
2370
|
function setFavicon(activity) {
|
|
2134
2371
|
try {
|
|
@@ -2138,7 +2375,7 @@ function setFavicon(activity) {
|
|
|
2138
2375
|
link.setAttribute('rel', 'icon');
|
|
2139
2376
|
(document.head || document.body).append(link);
|
|
2140
2377
|
}
|
|
2141
|
-
const href = FAVICONS[activity] || FAVICONS.idle;
|
|
2378
|
+
const href = (FAVICONS[activity] || FAVICONS.idle)();
|
|
2142
2379
|
link.setAttribute('type', href.startsWith('data:') ? 'image/svg+xml' : 'image/png');
|
|
2143
2380
|
link.setAttribute('href', href);
|
|
2144
2381
|
} catch { /* A partial DOM cannot host a favicon. */ }
|
|
@@ -2151,14 +2388,16 @@ function applyActivity(value) {
|
|
|
2151
2388
|
if (typeof applyProviderRegistry === 'function') applyProviderRegistry(value);
|
|
2152
2389
|
if (!Object.hasOwn(FAVICONS, value.state)) return;
|
|
2153
2390
|
setFavicon(value.state);
|
|
2154
|
-
|
|
2391
|
+
// One phrase for a run waiting on the person, the desktop's (P-ATN-07): "Needs your input".
|
|
2392
|
+
document.title = value.state === 'running' ? `Running · ${baseTitle}` : value.state === 'awaiting-input' ? `Needs your input · ${baseTitle}` : baseTitle;
|
|
2155
2393
|
const activityKey = JSON.stringify([value.state, value.runId, value.updatedAt, value.kind, value.detail]);
|
|
2156
2394
|
// Native-app notifications are requested by the top-level Tauri window. Browsers
|
|
2157
2395
|
// deny permission requests from cross-origin iframes, so relay only safe status.
|
|
2158
2396
|
window.AndorraEmbed?.activity?.(value);
|
|
2159
2397
|
if ((!window.parent || window.parent === window) && value.state === 'awaiting-input' &&
|
|
2160
2398
|
lastActivityKey !== activityKey && typeof Notification === 'function' && Notification.permission === 'granted') {
|
|
2161
|
-
|
|
2399
|
+
// The desktop's own notice for the same state (desktop/src/engine/taskNotifications.ts).
|
|
2400
|
+
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
2401
|
}
|
|
2163
2402
|
lastActivityKey = activityKey;
|
|
2164
2403
|
}
|
|
@@ -2208,4 +2447,4 @@ setFavicon('idle');
|
|
|
2208
2447
|
if (token) watchActivity();
|
|
2209
2448
|
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
2449
|
|
|
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
|
|
2450
|
+
(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); } })();
|