@andorra-labs/code 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agent-execution.js +404 -25
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +19 -3
- package/dist/src/agent-mcp.js +18 -44
- package/dist/src/app-server/protocol.d.ts +25 -3
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +8 -1
- package/dist/src/app-server/workspace.js +43 -2
- package/dist/src/app-server.js +88 -3
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-tool.js +10 -2
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +10 -0
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +7 -3
- package/dist/src/cli.js +31 -4
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +54 -48
- package/dist/src/commands.d.ts +5 -1
- package/dist/src/commands.js +7 -6
- package/dist/src/completion.js +46 -0
- package/dist/src/config.d.ts +48 -0
- package/dist/src/config.js +248 -10
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/graph-server.d.ts +1 -0
- package/dist/src/graph-server.js +15 -3
- package/dist/src/graph-sync.d.ts +15 -0
- package/dist/src/graph-sync.js +50 -1
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +212 -43
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +46 -12
- package/dist/src/graphs.d.ts +15 -2
- package/dist/src/graphs.js +42 -13
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/powershell-pool.d.ts +9 -0
- package/dist/src/powershell-pool.js +16 -0
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/pull-requests.d.ts +14 -5
- package/dist/src/pull-requests.js +28 -10
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +30 -2
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +4 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +14 -11
- package/dist/src/skills/bundled/provenance.json +1 -1
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -1
- package/dist/src/terminal-ui.d.ts +9 -0
- package/dist/src/terminal-ui.js +14 -0
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +116 -11
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +13 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +15 -2
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +2 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +1 -1
- package/docs/guides/README.md +1 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +1 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +3 -3
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
package/dist/src/graph-ui/app.js
CHANGED
|
@@ -58,7 +58,7 @@ function freeNodeRefusal(added) {
|
|
|
58
58
|
return counted && countedNodes(state.graph) + counted > state.plan.nodeLimit ? freeNodeTip() : undefined;
|
|
59
59
|
}
|
|
60
60
|
async function api(path, body, options = {}) {
|
|
61
|
-
const response = await fetch(path, { method: options.method || (body ? 'POST' : 'GET'), headers: { Authorization: `Bearer ${token || ''}`, ...(body ? { 'Content-Type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}), ...(options.signal ? { signal: options.signal } : {}) });
|
|
61
|
+
const response = await fetch(path, { method: options.method || (body ? 'POST' : 'GET'), headers: { Authorization: `Bearer ${token || ''}`, ...(body ? { 'Content-Type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}), ...(options.signal ? { signal: options.signal } : {}), ...(options.keepalive ? { keepalive: true } : {}) });
|
|
62
62
|
const data = await response.json();
|
|
63
63
|
if (!response.ok) throw new Error(typeof data.error === 'string' ? data.error : JSON.stringify(data.error || data));
|
|
64
64
|
return data;
|
|
@@ -66,18 +66,33 @@ async function api(path, body, options = {}) {
|
|
|
66
66
|
function checkpoint() { state.undo.push(copy(state.graph)); if (state.undo.length > 80) state.undo.shift(); state.redo = []; }
|
|
67
67
|
function changed() { scheduleValidation(); state.dirty = true; renderCanvas(); renderHeading(); renderValidation(); status('Unsaved changes'); syncImportRequirementsMarker(); queueDraft(); }
|
|
68
68
|
let draftTimer, pendingDraft, draftWrite;
|
|
69
|
-
|
|
69
|
+
// How long editing must pause before a draft is written. Every draft is a snapshot the account
|
|
70
|
+
// keeps, so a pause shorter than this would store one per keystroke burst.
|
|
71
|
+
const DRAFT_PAUSE_MS = 2000;
|
|
72
|
+
function flushDraft(leaving = false) {
|
|
70
73
|
clearTimeout(draftTimer);
|
|
71
74
|
const graph = pendingDraft; pendingDraft = null;
|
|
72
|
-
if (graph) return draftWrite = api('/api/drafts', graph).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
|
|
75
|
+
if (graph) return draftWrite = api('/api/drafts', graph, leaving ? { keepalive: true } : {}).then(refreshDrafts).catch(error => status('Draft not saved: ' + error.message, true));
|
|
76
|
+
}
|
|
77
|
+
// Whether the open graph holds edits a draft should keep. A graph that is still exactly what New
|
|
78
|
+
// or Duplicate made holds nothing to recover, so it gets no draft until an edit makes it differ.
|
|
79
|
+
// Without this every New graph left a draft behind, from the autosave and from the embedded
|
|
80
|
+
// editor's flush on leaving alike.
|
|
81
|
+
function hasDraftableEdits() {
|
|
82
|
+
if (!state.graph || !state.dirty) return false;
|
|
83
|
+
if (state.untouched) {
|
|
84
|
+
if (globalThis.AndorraDrafts && !globalThis.AndorraDrafts.worthSaving(state.graph, state.untouched)) return false;
|
|
85
|
+
state.untouched = null;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
73
88
|
}
|
|
74
89
|
function queueDraft() {
|
|
75
|
-
if (!
|
|
90
|
+
if (!hasDraftableEdits()) return;
|
|
76
91
|
if (pendingDraft && pendingDraft.id !== state.graph.id) void flushDraft();
|
|
77
92
|
pendingDraft = copy(state.graph);
|
|
78
93
|
if ($('sync-status')) $('sync-status').textContent = 'Saving draft locally…';
|
|
79
94
|
clearTimeout(draftTimer);
|
|
80
|
-
draftTimer = setTimeout(flushDraft,
|
|
95
|
+
draftTimer = setTimeout(flushDraft, DRAFT_PAUSE_MS);
|
|
81
96
|
}
|
|
82
97
|
async function refreshDrafts() {
|
|
83
98
|
state.drafts = await api('/api/drafts'); renderList();
|
|
@@ -106,15 +121,46 @@ function restoreImportRequirements(graph) {
|
|
|
106
121
|
}
|
|
107
122
|
async function openDraft(snapshot) {
|
|
108
123
|
if (state.dirty && !await askConfirm({ title: 'Open the saved draft?', message: 'Current edits are retained in draft history.', confirmLabel: 'Open draft' })) return;
|
|
109
|
-
try { const graph = await api(`/api/drafts/${snapshot}`); const owed = restoreImportRequirements(graph); state.graph = graph; state.dirty = true; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = owed; render(); fit(); status(owed ? 'Recovered imported draft. Assign a model profile to every outlined node, then save.' : 'Recovered draft. Save a revision when valid, or duplicate if its base revision changed.'); }
|
|
124
|
+
try { const graph = foldGraphSubagentCaps(await api(`/api/drafts/${snapshot}`)); const owed = restoreImportRequirements(graph); state.graph = graph; state.dirty = true; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = owed; render(); fit(); status(owed ? 'Recovered imported draft. Assign a model profile to every outlined node, then save.' : 'Recovered draft. Save a revision when valid, or duplicate if its base revision changed.'); }
|
|
110
125
|
catch (error) { status(error.message, true); }
|
|
111
126
|
}
|
|
112
127
|
function mutate(action, inspector = false) { if (!state.graph) return; checkpoint(); action(); changed(); if (inspector) renderInspector(); }
|
|
128
|
+
/**
|
|
129
|
+
* Fold an Orchestrator's legacy `maxSubagents` cap into its subagent policy, the same way
|
|
130
|
+
* migrateGraphToOrchestrator does in src/graphs.ts. The editor no longer shows that field: it
|
|
131
|
+
* duplicated "Max total per node run" and silently lowered or disabled the Subagents settings.
|
|
132
|
+
* The runtime still honours the field, so a saved value must not stay hidden; folding it keeps
|
|
133
|
+
* the run identical (the runtime uses the smaller of the two) and makes Advanced the only place
|
|
134
|
+
* the limits live. Zero turns subagents off; a node without a policy has nothing to cap.
|
|
135
|
+
*/
|
|
136
|
+
function foldSubagentCap(node) {
|
|
137
|
+
if (!node || typeof node !== 'object' || node.maxSubagents === undefined) return node;
|
|
138
|
+
const cap = node.maxSubagents; const policy = node.subagents;
|
|
139
|
+
delete node.maxSubagents;
|
|
140
|
+
if (!policy || typeof policy !== 'object' || typeof cap !== 'number') return node;
|
|
141
|
+
if (cap === 0) { policy.enabled = false; return node; }
|
|
142
|
+
policy.maxTotal = Math.min(policy.maxTotal ?? 8, cap);
|
|
143
|
+
policy.maxConcurrent = Math.min(policy.maxConcurrent ?? 3, policy.maxTotal);
|
|
144
|
+
policy.maxDepth = Math.min(policy.maxDepth ?? 1, policy.maxConcurrent);
|
|
145
|
+
return node;
|
|
146
|
+
}
|
|
147
|
+
function foldDefinitionCaps(definitions) {
|
|
148
|
+
for (const definition of definitions || []) foldSubagentCap(definition?.node);
|
|
149
|
+
return definitions || [];
|
|
150
|
+
}
|
|
151
|
+
function hasSubagentCap(graph) {
|
|
152
|
+
return Object.values(graph?.nodes || {}).some(node => node && typeof node === 'object' && node.maxSubagents !== undefined);
|
|
153
|
+
}
|
|
154
|
+
function foldGraphSubagentCaps(graph) {
|
|
155
|
+
for (const node of Object.values(graph?.nodes || {})) foldSubagentCap(node);
|
|
156
|
+
return graph;
|
|
157
|
+
}
|
|
113
158
|
/**
|
|
114
159
|
* Drop settings the runtime no longer defines. `maxTokens` and the subagent token pair were
|
|
115
160
|
* removed with the cumulative token ceiling; the server still accepts them so old graphs keep
|
|
116
161
|
* loading, but hiding their controls alone would not remove them from a saved revision because
|
|
117
162
|
* the editor serializes the whole graph. Removing them here makes the next save authoritative.
|
|
163
|
+
* An Orchestrator's hidden `maxSubagents` cap is folded into its policy for the same reason.
|
|
118
164
|
* The import-requirements marker (`pendingProviderNodes`) is stripped here too: it is editor
|
|
119
165
|
* state riding on draft snapshots, not graph content, so it never reaches a saved revision, an
|
|
120
166
|
* export or a reopened saved graph. Only the draft round-trip keeps it (queueDraft and
|
|
@@ -128,6 +174,7 @@ function dropLegacyTokenFields(graph) {
|
|
|
128
174
|
if (!node || typeof node !== 'object') continue;
|
|
129
175
|
if (node.limits && typeof node.limits === 'object') delete node.limits.maxTokens;
|
|
130
176
|
if (node.subagents && typeof node.subagents === 'object') { delete node.subagents.maxTokensPerSubagent; delete node.subagents.maxCombinedTokens; }
|
|
177
|
+
foldSubagentCap(node);
|
|
131
178
|
}
|
|
132
179
|
return graph;
|
|
133
180
|
}
|
|
@@ -165,6 +212,14 @@ function applyProviderRegistry(value) {
|
|
|
165
212
|
}
|
|
166
213
|
return true;
|
|
167
214
|
}
|
|
215
|
+
// Browser copies of isWritingRole and delegatesWriting in src/graphs.ts. The server decides which
|
|
216
|
+
// ports a node has and whether it delegates; these must agree with it exactly, or the canvas
|
|
217
|
+
// shows a port the server does not know, or hides one it offers.
|
|
218
|
+
function isWritingRole(role) { return role?.capabilities?.filesystem === 'read-write' || role?.capabilities?.git === 'write'; }
|
|
219
|
+
function delegatesWriting(node) {
|
|
220
|
+
return node?.type === 'agent' && node.agentRole === 'orchestrator' && node.subagents?.enabled === true && node.maxSubagents !== 0
|
|
221
|
+
&& (node.subagents.roles ?? []).some(isWritingRole);
|
|
222
|
+
}
|
|
168
223
|
function outcomes(node) {
|
|
169
224
|
if (node.type === 'end') return [];
|
|
170
225
|
if (node.type === 'agent' && node.modifiers?.condition) return ['true', 'false'];
|
|
@@ -172,9 +227,17 @@ function outcomes(node) {
|
|
|
172
227
|
if (node.type === 'condition') return ['true', 'false'];
|
|
173
228
|
if (node.type === 'loop') return ['body', 'done'];
|
|
174
229
|
if (node.type === 'approval') return ['approved', 'rejected'];
|
|
175
|
-
|
|
230
|
+
if (node.completion?.mode === 'outcomes') return node.completion.outcomes;
|
|
231
|
+
const outcome = node.completion?.outcome ?? 'completed';
|
|
232
|
+
// Mirrors nodeOutcomes: a delegating Orchestrator also ends as delivered once it has landed
|
|
233
|
+
// accepted changes. The server accepts delivered without an edge, so the port needs no route.
|
|
234
|
+
return delegatesWriting(node) ? [outcome, 'delivered'] : [outcome];
|
|
176
235
|
}
|
|
177
236
|
function edgeOutcome(edge) { return edge.outcome || 'completed'; }
|
|
237
|
+
// Drops this node's connections whose outcome it no longer has. Called inside the mutate that
|
|
238
|
+
// changed its outcomes, so undo restores the routes together with the setting. An edge left on a
|
|
239
|
+
// vanished port is refused by the server and is drawn as if it left the first port.
|
|
240
|
+
function pruneRoutes(node) { state.graph.edges = state.graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge))); }
|
|
178
241
|
function selectedNodes() { return (state.selectedIds.length ? state.selectedIds : state.selected ? [state.selected] : []).map(id => state.graph?.nodes[id]).filter(Boolean); }
|
|
179
242
|
function selectionType(node) { return `${node.type}:${node.agentRole || 'regular'}`; }
|
|
180
243
|
function clearSelection() { state.selectedIds = []; state.selected = null; state.selectedEdge = null; state.routePick = null; state.bulkOutcome = null; }
|
|
@@ -279,7 +342,7 @@ function scheduleValidation() {
|
|
|
279
342
|
}
|
|
280
343
|
function renderHeading() {
|
|
281
344
|
$('graph-title').textContent = state.graph?.name || 'Graph studio';
|
|
282
|
-
$('revision').textContent = state.graph ? `${state.graph.revision ? `Revision ${state.graph.revision}` : 'New graph'}${state.dirty ? '
|
|
345
|
+
$('revision').textContent = state.graph ? `${state.graph.revision ? `Revision ${state.graph.revision}` : 'New graph'}${state.dirty ? ' · Unsaved' : ''}` : '';
|
|
283
346
|
$('save').disabled = state.saving || !state.graph || !state.dirty || state.graph.id === 'default';
|
|
284
347
|
$('save').title = state.graph?.id === 'default' ? 'Duplicate the preset to save your customization' : '';
|
|
285
348
|
$('undo').disabled = !state.undo.length; $('redo').disabled = !state.redo.length;
|
|
@@ -302,19 +365,49 @@ function renderList() {
|
|
|
302
365
|
button.oncontextmenu = event => { event.preventDefault(); showGraphMenu(graph, event.clientX, event.clientY); };
|
|
303
366
|
$('graphs').append(button);
|
|
304
367
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
368
|
+
// Drafts sit under their own heading, below the saved graphs. By default only the ones still
|
|
369
|
+
// holding unsaved work are listed (the newest per graph, and not one a later revision
|
|
370
|
+
// overtook); the history toggle lists every snapshot.
|
|
371
|
+
const matching = (state.drafts || []).filter(draft => draft.name.toLowerCase().includes($('search').value.toLowerCase()));
|
|
372
|
+
const latest = () => { const seen = new Set(); return matching.filter(draft => !seen.has(draft.graphId) && seen.add(draft.graphId)); };
|
|
373
|
+
const current = globalThis.AndorraDrafts ? globalThis.AndorraDrafts.currentDrafts(matching, state.graphs) : latest();
|
|
374
|
+
const shown = state.showDraftHistory ? matching : current;
|
|
375
|
+
if (shown.length) {
|
|
376
|
+
const head = el('div', undefined, 'graph-drafts-head');
|
|
377
|
+
head.append(el('span', state.showDraftHistory ? 'Draft history' : 'Unsaved drafts'));
|
|
378
|
+
const clear = el('button', 'Clear', 'graph-drafts-clear'); clear.type = 'button'; clear.disabled = state.saving;
|
|
379
|
+
clear.title = 'Remove these drafts and their history from the list'; clear.onclick = () => clearDrafts(matching, true);
|
|
380
|
+
head.append(clear); $('graphs').append(head);
|
|
312
381
|
}
|
|
313
|
-
|
|
314
|
-
const
|
|
382
|
+
for (const draft of shown) {
|
|
383
|
+
const button = el('button', undefined, 'graph-row draft-row'); button.disabled = state.saving;
|
|
384
|
+
const saved = draft.updatedAt ? new Date(draft.updatedAt).toLocaleString() : '(date unknown)';
|
|
385
|
+
const when = el('small', globalThis.AndorraDrafts?.age(draft.updatedAt) || 'Draft');
|
|
386
|
+
button.title = `${draft.name} — draft saved ${saved}`;
|
|
387
|
+
button.append(el('span', draft.name), when);
|
|
388
|
+
button.onclick = () => openDraft(draft.snapshot);
|
|
389
|
+
button.oncontextmenu = event => { event.preventDefault(); showMenuAt(event.clientX, event.clientY, `Actions for the draft of ${draft.name}`, [
|
|
390
|
+
{ label: 'Open draft', icon: 'history', run: () => openDraft(draft.snapshot) },
|
|
391
|
+
{ label: 'Clear draft', icon: 'trash', danger: true, run: () => clearDrafts([draft]) },
|
|
392
|
+
]); };
|
|
393
|
+
$('graphs').append(button);
|
|
394
|
+
}
|
|
395
|
+
if (state.showDraftHistory || matching.length > current.length) {
|
|
396
|
+
const history = el('button', state.showDraftHistory ? 'Show latest drafts' : `Show draft history (${matching.length})`, 'graph-drafts-toggle');
|
|
397
|
+
history.type = 'button';
|
|
315
398
|
history.onclick = () => { state.showDraftHistory = !state.showDraftHistory; renderList(); }; $('graphs').append(history);
|
|
316
399
|
}
|
|
317
400
|
}
|
|
401
|
+
// Clearing takes a graph's drafts off the list; saved graphs and their revisions are untouched.
|
|
402
|
+
// The open graph's edits are not lost: its next autosave is a new draft.
|
|
403
|
+
async function clearDrafts(drafts, all = false) {
|
|
404
|
+
const graphIds = [...new Set(drafts.map(draft => draft.graphId))];
|
|
405
|
+
if (!graphIds.length) return;
|
|
406
|
+
const one = graphIds.length === 1 && !all;
|
|
407
|
+
if (!await askConfirm({ title: one ? `Clear the draft of "${drafts[0].name}"?` : $('search').value ? 'Clear the matching drafts?' : 'Clear all drafts?', message: 'Cleared drafts leave this list, with their history. Saved graphs and their revisions are not affected.', confirmLabel: 'Clear', tone: 'danger' })) return;
|
|
408
|
+
try { state.drafts = await api('/api/drafts/clear', { graphIds }); if (!state.drafts.length) state.showDraftHistory = false; renderList(); status(one ? 'Draft cleared' : 'Drafts cleared'); }
|
|
409
|
+
catch (error) { status('Drafts not cleared: ' + error.message, true); }
|
|
410
|
+
}
|
|
318
411
|
// Right-click actions for a saved graph row, and the Plus button's New/Import choices. The menu
|
|
319
412
|
// floats at the pointer as a body-level overlay, so a list re-render cannot tear it down
|
|
320
413
|
// mid-choice; a pointerdown outside it or Escape closes it.
|
|
@@ -498,7 +591,7 @@ function nodeSubtitle(node) {
|
|
|
498
591
|
const nodeIconElement = node => globalThis.AndorraIcons?.icon?.(globalThis.AndorraIcons.nodeIcon(node));
|
|
499
592
|
function renderCanvas() {
|
|
500
593
|
$('nodes').replaceChildren(); $('edges').replaceChildren(); $('canvas').classList.toggle('picking-destination',!!state.routePick);
|
|
501
|
-
const hintText = state.routePick ? 'Click a destination node
|
|
594
|
+
const hintText = state.routePick ? 'Click a destination node · Escape cancels' : 'Ctrl/Cmd-click same-type nodes to select together · Drag to pan · Scroll to zoom';
|
|
502
595
|
$('canvas-hint-text').textContent = hintText; $('canvas-hint').hidden = !state.routePick && canvasHintDismissed(); $('canvas-hint-close').hidden = !!state.routePick;
|
|
503
596
|
$('empty').hidden = !!state.graph;
|
|
504
597
|
if (!state.graph) return;
|
|
@@ -657,7 +750,7 @@ function nodeErrorIds() {
|
|
|
657
750
|
}
|
|
658
751
|
function renderValidation() {
|
|
659
752
|
const container=$('validation');if(!container)return;container.replaceChildren();const errors=[...issues(),...state.validationErrors].map(errorEntry);
|
|
660
|
-
if(!errors.length)container.append(el('p',state.validated?'Validated
|
|
753
|
+
if(!errors.length)container.append(el('p',state.validated?'Validated · Ready to save':'Checking graph…',state.validated?'valid ok':'valid'));
|
|
661
754
|
else {const list=el('ul',undefined,'validation');errors.forEach(({message,nodeId})=>{ const row=el('li',message); row.tabIndex=0; row.title='Click to focus the affected node'; row.onclick=()=>{if(nodeId){clearSelection();state.selected=nodeId;state.selectedIds=[nodeId];renderCanvas();renderInspector();}};row.onkeydown=e=>{if(e.key==='Enter'||e.key===' ')row.click();};list.append(row);});container.append(list);}
|
|
662
755
|
}
|
|
663
756
|
function disclosure(parent, title, open = false) { const item = el('details', undefined, 'section disclosure'); const key = `${state.selectedEdge?.id || state.selected || 'graph'}:${title}`; item.open = state.disclosures[key] ?? open; item.ontoggle = () => {state.disclosures[key] = item.open;}; item.append(el('summary', title)); const body = el('div'); item.append(body); parent.append(item); return body; }
|
|
@@ -781,10 +874,38 @@ function capabilities(parent, policy, update, ceiling) {
|
|
|
781
874
|
}
|
|
782
875
|
let modelSuggestionSeq = 0;
|
|
783
876
|
function modelFields(parent, target, update, parentModel, inheritedProvider, fallbackProvider) {
|
|
784
|
-
|
|
877
|
+
// The provider dropdown lists every configured provider by name; the Model dropdown under it
|
|
878
|
+
// lists every model the chosen provider serves. Labelling each provider with its one active
|
|
879
|
+
// model made the provider list read as the whole model list.
|
|
880
|
+
const providers = state.providers.map(p => ({value: idFor(p), label: titleFor(p)}));
|
|
785
881
|
if (target.provider && !providers.some(p => p.value === target.provider)) providers.push({value: target.provider, label: target.provider + ' (unavailable)'});
|
|
786
|
-
|
|
882
|
+
const defaultProviderLabel = inheritedProvider ? `Same as parent node (${inheritedProvider})` : state.defaultProvider ? `Use configured default (${state.defaultProvider})` : 'Use configured default';
|
|
883
|
+
choice(parent, 'Provider', target.provider || '', [{value:'', label: defaultProviderLabel}, ...providers], value => update({ ...target, provider: value || undefined, model: undefined }));
|
|
787
884
|
if (target.provider && !state.providers.some(p => idFor(p) === target.provider)) providerWarning(parent, target.provider);
|
|
885
|
+
// A providerless subagent child inherits the parent node's provider at execution
|
|
886
|
+
// (bindPortableGraphProviders adds its model to the parent's requirements), so the suggestions
|
|
887
|
+
// shown here and the recording that makes a discovered pick runnable must resolve against that
|
|
888
|
+
// inherited provider, not the machine default, or the selection lands on the wrong provider.
|
|
889
|
+
const listingProvider = target.provider || inheritedProvider || state.defaultProvider || '';
|
|
890
|
+
const provider = state.providers.find(p => idFor(p) === listingProvider);
|
|
891
|
+
const activeName = provider?.model?.trim() || '';
|
|
892
|
+
// Every model the resolved provider serves: its configured models first, then whatever its
|
|
893
|
+
// endpoint lists once discovery answers (filled in by addModelOption below). Picking one commits
|
|
894
|
+
// through the custom-name field so a discovered pick is recorded exactly as a typed one is.
|
|
895
|
+
const picker = field(parent, 'Model', '', () => {}, { options: [] });
|
|
896
|
+
const pickerModels = [];
|
|
897
|
+
const inheritedModel = parentModel?.trim() || activeName;
|
|
898
|
+
const renderPicker = () => {
|
|
899
|
+
picker.replaceChildren();
|
|
900
|
+
const rows = [{ value: '', label: inheritedModel ? `${parentModel ? 'Same as parent' : 'Provider default'} (${inheritedModel})` : 'Provider default' },
|
|
901
|
+
...pickerModels.map(name => ({ value: name, label: name === activeName ? `${name} (active)` : name }))];
|
|
902
|
+
for (const row of rows) { const option = el('option', row.label); option.value = row.value; picker.append(option); }
|
|
903
|
+
picker.value = target.model?.trim() || '';
|
|
904
|
+
// Discovery can answer while the list is open; the branded panel copies the options when it
|
|
905
|
+
// opens, so redraw it or the newly served models stay out of reach until it is reopened.
|
|
906
|
+
window.AndorraControls?.refreshSelect?.(picker);
|
|
907
|
+
};
|
|
908
|
+
renderPicker();
|
|
788
909
|
// Surface portability without rewriting the synced revision or local credentials. The alias must
|
|
789
910
|
// satisfy every reference to the original provider graph-wide (bindPortableGraphProviders groups
|
|
790
911
|
// them), so the hint mirrors that grouping instead of promising an alias execution would refuse.
|
|
@@ -851,12 +972,6 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
851
972
|
parent.append(el('p', `This selection follows "${originalId}"'s current model, ${exact.model}.`, 'help'));
|
|
852
973
|
}
|
|
853
974
|
}
|
|
854
|
-
// A providerless subagent child inherits the parent node's provider at execution
|
|
855
|
-
// (bindPortableGraphProviders adds its model to the parent's requirements), so the suggestions
|
|
856
|
-
// shown here and the recording that makes a discovered pick runnable must resolve against that
|
|
857
|
-
// inherited provider, not the machine default, or the selection lands on the wrong provider.
|
|
858
|
-
const listingProvider = target.provider || inheritedProvider || state.defaultProvider || '';
|
|
859
|
-
const provider = state.providers.find(p => idFor(p) === listingProvider);
|
|
860
975
|
const info = el('p', 'Context window: detecting from model...', 'help model-context'); parent.append(info);
|
|
861
976
|
const key = JSON.stringify([target.provider || '', target.model || '', provider?.model || '']);
|
|
862
977
|
// Capture the registry generation before any discovery request starts: a callback resolving
|
|
@@ -868,8 +983,8 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
868
983
|
if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
|
|
869
984
|
info.textContent = data.contextWindow ? `Context window: ${data.contextWindow.toLocaleString()} tokens (automatic)` : 'Context window: not reported by this model. Runtime uses its default budget.';
|
|
870
985
|
});
|
|
871
|
-
const override = disclosure(parent, '
|
|
872
|
-
const model = field(override, '
|
|
986
|
+
const override = disclosure(parent, 'Custom model name');
|
|
987
|
+
const model = field(override, 'Custom model name (optional)', target.model, value => update({...target, model: value.trim() || undefined}), {maxLength:500,refresh:true}); model.placeholder = provider?.model || 'Configured profile model';
|
|
873
988
|
// The override stays free-text so a graph can name a model this machine has never seen, but the
|
|
874
989
|
// provider's catalog is offered alongside it: the configured models first, then everything the
|
|
875
990
|
// endpoint itself lists, so a provider that serves several models is selectable here rather than
|
|
@@ -888,21 +1003,27 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
888
1003
|
if (!value || displayed.has(value)) return;
|
|
889
1004
|
displayed.add(value);
|
|
890
1005
|
const option = el('option'); option.value = value; if (label) option.label = label; datalist.append(option);
|
|
1006
|
+
// The picker is rebuilt once per batch by the caller: rebuilding per model is quadratic for a
|
|
1007
|
+
// large catalog, and an open panel would be redrawn and re-measured for every entry.
|
|
1008
|
+
pickerModels.push(value);
|
|
1009
|
+
return true;
|
|
891
1010
|
};
|
|
892
|
-
const activeName = provider?.model?.trim() || '';
|
|
893
1011
|
for (const name of [activeName, ...(provider?.models || [])]) addModelOption(name, name?.trim() === activeName && name ? '(active)' : undefined);
|
|
894
1012
|
if (target.model) addModelOption(target.model, target.model.trim() === activeName ? '(active)' : undefined);
|
|
1013
|
+
renderPicker();
|
|
895
1014
|
// Keyed by the resolved provider: a node using the configured default must follow that default's
|
|
896
1015
|
// identity, not share a blank key that survives a default switch.
|
|
897
1016
|
state.providerModelRequests ||= new Map();
|
|
898
1017
|
if (!state.providerModelRequests.has(listingProvider)) state.providerModelRequests.set(listingProvider, api(`/api/provider-models?provider=${encodeURIComponent(listingProvider)}`).catch(() => ({ models: [] })));
|
|
899
1018
|
state.providerModelRequests.get(listingProvider).then(data => {
|
|
900
1019
|
if ((state.providerRegistryGeneration || 0) !== registryGeneration) return;
|
|
1020
|
+
let added = false;
|
|
901
1021
|
for (const name of data.models || []) {
|
|
902
1022
|
const value = name?.trim();
|
|
903
1023
|
if (value) offered.add(value);
|
|
904
|
-
addModelOption(name, name === activeName ? '(active)' : undefined);
|
|
1024
|
+
if (addModelOption(name, name === activeName ? '(active)' : undefined)) added = true;
|
|
905
1025
|
}
|
|
1026
|
+
if (added) renderPicker();
|
|
906
1027
|
});
|
|
907
1028
|
// Committing one of the discovered suggestions records it with the provider, the way /model does:
|
|
908
1029
|
// execution validates a node's explicit model against the provider's configured models, so an
|
|
@@ -981,6 +1102,7 @@ function modelFields(parent, target, update, parentModel, inheritedProvider, fal
|
|
|
981
1102
|
const initialWarning = state.providerModelWarnings?.get(warningKey(target.model?.trim() || ''));
|
|
982
1103
|
if (initialWarning) override.append(el('p', initialWarning, 'help'));
|
|
983
1104
|
}
|
|
1105
|
+
picker.onchange = () => { model.value = picker.value; model.onchange(); };
|
|
984
1106
|
model.onchange = () => {
|
|
985
1107
|
committed?.();
|
|
986
1108
|
// Recording eligibility keys on whether the model still needs recording, not on whether the
|
|
@@ -1006,6 +1128,9 @@ function renderCompletion(parent, node) {
|
|
|
1006
1128
|
graph.edges = graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge)));
|
|
1007
1129
|
});
|
|
1008
1130
|
explain(behavior, 'Outcome names are short phrases such as DONE, PASS, FAILED TESTING or BLOCKED. Describe when the agent should choose each one; for a single outcome, describe when the work is considered achieved, for example "This is considered DONE when xyz is finished". The agent evaluates these written criteria using its evidence; they are not automatic checks. Connect outcomes to destinations under Connections.');
|
|
1131
|
+
// The server refuses written criteria on a delegating Orchestrator, so the option is withheld
|
|
1132
|
+
// rather than offered and then rejected on save.
|
|
1133
|
+
if (delegatesWriting(node) && node.completion?.mode !== 'outcomes') { for (const option of behavior.options) option.disabled = option.value === 'outcomes'; parent.append(el('p', 'An Orchestrator with a writing role keeps a single outcome: it completes with a handoff, or delivers landed changes through its delivered port.', 'help')); }
|
|
1009
1134
|
if (node.completion?.mode === 'outcomes') {
|
|
1010
1135
|
parent.append(el('p', 'Criteria are optional; blank rows use the agent prompt. Removing or renaming an outcome removes its old routes. Undo restores routes and criteria.', 'help'));
|
|
1011
1136
|
if (node.modifiers?.condition || node.modifiers?.loop?.until.outcome !== undefined) parent.append(el('p', 'Modifiers control the final connections: a Condition routes to true/false; an outcome Loop exposes its exit outcome.', 'help'));
|
|
@@ -1120,7 +1245,32 @@ function displayToolName(name) { return TOOL_ALIASES[name] || name; }
|
|
|
1120
1245
|
// Permission comparison spelling: folds the whole shell family onto one token so the server's
|
|
1121
1246
|
// platform-dependent resolution of 'shell' cannot change which tools the editor offers.
|
|
1122
1247
|
function canonicalToolName(name) { const d = displayToolName(name); return SHELL_TOOLS.includes(d) ? 'shell' : d; }
|
|
1248
|
+
// Browser copy of permitsBuiltInTool in src/graphs.ts for a delegated worktree child, the one
|
|
1249
|
+
// kind of subagent that runs commands. The server validates a writing role's tools with that rule,
|
|
1250
|
+
// so a tool offered here that it refuses could be ticked and then fail validation.
|
|
1251
|
+
const QA_TOOL_NAMES = ['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser'];
|
|
1252
|
+
function delegatedRolePermits(caps, name) {
|
|
1253
|
+
const display = displayToolName(name);
|
|
1254
|
+
const commands = caps.shell === 'allowed' && caps.filesystem === 'read-write' && caps.git === 'write';
|
|
1255
|
+
if (name === 'qa.browser_session' || name === 'browser.solve_captcha' || name === 'web_search') return caps.browser === 'playwright';
|
|
1256
|
+
if (['Read', 'Glob', 'Grep', 'repo_explore', 'read_skill_resource'].includes(display)) return caps.filesystem !== 'none';
|
|
1257
|
+
if (['Write', 'Edit'].includes(display)) return caps.filesystem === 'read-write';
|
|
1258
|
+
if ([...SHELL_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast'].includes(display) || QA_TOOL_NAMES.includes(name)) return commands;
|
|
1259
|
+
if (name === 'ShellMetrics') return caps.filesystem !== 'none';
|
|
1260
|
+
if (name === 'git_read') return caps.git !== 'none';
|
|
1261
|
+
return name === 'read_artifact' || name === 'write_artifact';
|
|
1262
|
+
}
|
|
1123
1263
|
function roleToolOptions(node, role, policy) {
|
|
1264
|
+
// A writing role of an Orchestrator is a delegated one. The runtime builds its tools from the
|
|
1265
|
+
// node's capabilities, for a child that works in its own worktree with a shell, and ignores both
|
|
1266
|
+
// the node's tool list (the Orchestrator's read-only intake kit) and the tool-inheritance
|
|
1267
|
+
// setting. So do the tools offered here; a role with no list of its own gets all of them.
|
|
1268
|
+
if (delegatesWriting(node) && isWritingRole(role)) {
|
|
1269
|
+
const ceiling = effectiveCaps(node), own = role.capabilities || ceiling;
|
|
1270
|
+
const available = state.tools.map(t => displayToolName(typeof t === 'string' ? t : t.name || t.id)).filter((name, index, array) => array.indexOf(name) === index)
|
|
1271
|
+
.filter(name => delegatedRolePermits(ceiling, name) && delegatedRolePermits(own, name));
|
|
1272
|
+
return {available, selected: role.tools?.map(displayToolName) ?? available, delegated: true};
|
|
1273
|
+
}
|
|
1124
1274
|
const parent = effectiveCaps(node);
|
|
1125
1275
|
const child = role.capabilities || {...parent,...((policy.workspace || 'shared-read-only') === 'shared-read-only' ? {filesystem:parent.filesystem === 'none' ? 'none' : 'read',git:parent.git === 'none' ? 'none' : 'read',shell:'disabled'} : {})};
|
|
1126
1276
|
const canonical = canonicalToolName;
|
|
@@ -1132,15 +1282,24 @@ function roleToolOptions(node, role, policy) {
|
|
|
1132
1282
|
}
|
|
1133
1283
|
function renderSubagents(parent, node) {
|
|
1134
1284
|
const policy = node.subagents || {enabled:false}; const set = patch => {Object.assign(policy,patch);node.subagents=policy;};
|
|
1135
|
-
|
|
1285
|
+
// The server rule that adds the delivered port (delegatesWriting) also decides this text: once
|
|
1286
|
+
// a role on an Orchestrator may write, its children run commands in their own worktrees.
|
|
1287
|
+
const delegating = delegatesWriting(node);
|
|
1288
|
+
explain(check(parent,'Allow subagents',policy.enabled,value=>{set({enabled:value});pruneRoutes(node);}), delegating
|
|
1289
|
+
? 'Writing roles of an Orchestrator run in their own Git worktree with a shell. The shell is not sandboxed and follows your permission mode. The Orchestrator reviews each change and lands the ones it accepts into your working folder; it never writes code itself.'
|
|
1290
|
+
: 'Internal delegation returns observations to this Agent. Only this parent chooses its graph outcome. Active children finish or cancel before the parent can complete. Subagents of ordinary agents never receive the unsandboxed host shell. Read-only roles use filesystem tools and supported Git read operations.');
|
|
1136
1291
|
if (!policy.enabled) return;
|
|
1292
|
+
// The server refuses writing roles on an Orchestrator outside separate worktrees, so the
|
|
1293
|
+
// editor moves the policy there as soon as a role may write.
|
|
1294
|
+
const requireWorktree = () => { if (node.agentRole === 'orchestrator' && (policy.roles || []).some(isWritingRole)) set({workspace:'worktree'}); };
|
|
1137
1295
|
for (const [key,label,fallback] of [['maxConcurrent','Max concurrent',3],['maxTotal','Max total per node run',8],['maxDepth','Max nesting depth',1]]) field(parent,label,policy[key]??fallback,value=>set({[key]:value}),{type:'number',min:1,max:key==='maxDepth'?3:key==='maxConcurrent'?16:1000});
|
|
1138
1296
|
choice(parent,'Model policy',policy.modelPolicy||'inherit',[{value:'inherit',label:'Inherit parent model'},{value:'specific',label:'Use specific model'},{value:'per-role',label:'Per-role model'}],value=>set({modelPolicy:value}));
|
|
1139
1297
|
// Mirrors bindPortableGraphProviders: enabled retry attempts may spawn providerless children on
|
|
1140
1298
|
// the fallback provider, so a discovered child pick must be recorded there as well.
|
|
1141
1299
|
const childFallbackProvider = node.retry?.fallback && node.retry.maxAttempts > 1 ? node.retry.fallback.provider : '';
|
|
1142
1300
|
if(policy.modelPolicy==='specific') modelFields(parent,policy,value=>set({provider:value.provider,model:value.model}),undefined,node.provider,childFallbackProvider);
|
|
1143
|
-
choice(parent,'Workspace policy',policy.workspace||'shared-read-only',[{value:'shared-read-only',label:'Shared workspace, read only'},{value:'shared-write',label:'Shared workspace, write allowed'},{value:'worktree',label:'Separate Git worktree'}],value=>set({workspace:value}));
|
|
1301
|
+
const workspace = choice(parent,'Workspace policy',policy.workspace||'shared-read-only',[{value:'shared-read-only',label:'Shared workspace, read only'},{value:'shared-write',label:'Shared workspace, write allowed'},{value:'worktree',label:'Separate Git worktree'}],value=>set({workspace:value}));
|
|
1302
|
+
if (delegating) { for (const option of workspace.options) option.disabled = option.value !== 'worktree'; explain(workspace, 'A writing role on an Orchestrator requires separate worktrees: each child edits its own copy, and the Orchestrator lands accepted changes into your working folder.'); }
|
|
1144
1303
|
choice(parent,'Tool inheritance',policy.toolInheritance||'restricted',[{value:'restricted',label:'Restricted subset'},{value:'inherit',label:'Inherit parent allowlist'}],value=>set({toolInheritance:value}));
|
|
1145
1304
|
choice(parent,'Context',policy.context||'selected',[{value:'selected',label:'Selected context only'},{value:'task-only',label:'Task only'}],value=>set({context:value}));
|
|
1146
1305
|
// The runtime no longer invents a child deadline, so this field must not display one: blank
|
|
@@ -1152,17 +1311,22 @@ function renderSubagents(parent, node) {
|
|
|
1152
1311
|
for(const role of policy.roles||[]) {
|
|
1153
1312
|
const body=disclosure(roles,role.name||'New role',true);
|
|
1154
1313
|
field(body,'Role ID',role.id,value=>{role.id=value;}); field(body,'Name',role.name,value=>{role.name=value;});field(body,'Instruction',role.instruction,value=>{role.instruction=value;},{multiline:true,maxLength:100000});
|
|
1155
|
-
if(policy.modelPolicy==='per-role')modelFields(body,role,value=>{role.provider=value.provider;role.model=value.model;}
|
|
1156
|
-
|
|
1314
|
+
if(policy.modelPolicy==='per-role')modelFields(body,role,value=>{role.provider=value.provider;role.model=value.model;},// A per-role child with no provider of its own runs on the parent's provider and inherits the
|
|
1315
|
+
// parent's model there (agent-execution resolves `role.model ?? model`), so its default row must
|
|
1316
|
+
// name that model, not the provider's active one.
|
|
1317
|
+
// Both sides are compared as execution resolves them: an unset parent provider is the machine
|
|
1318
|
+
// default, so a role naming that default explicitly still inherits the parent's model.
|
|
1319
|
+
(role.provider||node.provider||state.defaultProvider)===(node.provider||state.defaultProvider)?node.model:undefined,node.provider,childFallbackProvider);
|
|
1320
|
+
capabilities(disclosure(body,'Role capabilities'),role.capabilities||effectiveCaps(node),value=>{role.capabilities=value;requireWorktree();pruneRoutes(node);},effectiveCaps(node));
|
|
1157
1321
|
const allowedTools=disclosure(body,'Role tools'); const toolOptions=roleToolOptions(node,role,policy);
|
|
1158
1322
|
for(const name of new Set([...toolOptions.available,...toolOptions.selected])) {
|
|
1159
1323
|
const available=toolOptions.available.includes(name);
|
|
1160
|
-
check(allowedTools,available?name:`${name} (unavailable — remove to repair)`,toolOptions.selected.includes(name),enabled=>{role.tools=enabled?[...new Set([...toolOptions.selected,name])]:toolOptions.selected.filter(t=>t!==name);policy.toolInheritance='restricted';});
|
|
1324
|
+
check(allowedTools,available?name:`${name} (unavailable — remove to repair)`,toolOptions.selected.includes(name),enabled=>{role.tools=enabled?[...new Set([...toolOptions.selected,name])]:toolOptions.selected.filter(t=>t!==name);if(!toolOptions.delegated)policy.toolInheritance='restricted';});
|
|
1161
1325
|
}
|
|
1162
1326
|
const contracts=disclosure(body,'Role contracts');jsonField(contracts,'Input schema',role.inputSchema,value=>{role.inputSchema=value;});jsonField(contracts,'Output schema',role.outputSchema,value=>{role.outputSchema=value;});
|
|
1163
|
-
const remove=el('button','Remove role');remove.onclick=()=>mutate(()=>{set({roles:policy.roles.filter(r=>r!==role)});},true);body.append(remove);
|
|
1327
|
+
const remove=el('button','Remove role');remove.onclick=()=>mutate(()=>{set({roles:policy.roles.filter(r=>r!==role)});pruneRoutes(node);},true);body.append(remove);
|
|
1164
1328
|
}
|
|
1165
|
-
const add=el('button','Add role');add.onclick=()=>mutate(()=>{set({roles:[...(policy.roles||[]),{id:`role-${crypto.randomUUID().slice(0,8)}`,name:'Repository Researcher',instruction:'Research the bounded task and return findings.',capabilities:{...effectiveCaps(node),filesystem:effectiveCaps(node).filesystem==='none'?'none':'read',shell:effectiveCaps(node).shell==='disabled'?'disabled':'read-only',git:effectiveCaps(node).git==='none'?'none':'read'}}]});},true);roles.append(add);
|
|
1329
|
+
const add=el('button','Add role');add.onclick=()=>mutate(()=>{set({roles:[...(policy.roles||[]),{id:`role-${crypto.randomUUID().slice(0,8)}`,name:'Repository Researcher',instruction:'Research the bounded task and return findings.',capabilities:{...effectiveCaps(node),filesystem:effectiveCaps(node).filesystem==='none'?'none':'read',shell:effectiveCaps(node).shell==='disabled'?'disabled':'read-only',git:effectiveCaps(node).git==='none'?'none':'read'}}]});requireWorktree();},true);roles.append(add);
|
|
1166
1330
|
}
|
|
1167
1331
|
function renderControlInspector(parent,node) {
|
|
1168
1332
|
if(node.type==='join')choice(parent,'Wait for branches',node.join?.mode||'all',['all','any'],value=>{node.join={mode:value};});
|
|
@@ -1255,13 +1419,14 @@ function renderInspector() {
|
|
|
1255
1419
|
const parent = $('inspector-body'); parent.replaceChildren(); const graph = state.graph; if (!graph) { parent.append(el('p', 'Create a graph or choose a preset.', 'help')); return; }
|
|
1256
1420
|
if (state.selectedEdge && !graph.edges.includes(state.selectedEdge)) state.selectedEdge = null;
|
|
1257
1421
|
const node = graph.nodes[state.selected]; $('inspector-title').textContent = node ? 'Node settings' : 'Graph settings';
|
|
1422
|
+
$('graph-settings').hidden = !node && !state.selectedEdge && selectedNodes().length <= 1;
|
|
1258
1423
|
retryLimitHelp(parent, graph);
|
|
1259
1424
|
if (state.selectedEdge) renderEdgeInspector(parent, state.selectedEdge);
|
|
1260
1425
|
else if (selectedNodes().length > 1) renderBulkInspector(parent,selectedNodes());
|
|
1261
1426
|
else if (!node) {
|
|
1262
1427
|
const panels = inspectorTabs(parent, ['general', 'behavior', 'advanced']); const general = panels.general;
|
|
1263
1428
|
field(general, 'Graph name', graph.name, value => { graph.name = value; renderList(); }, {maxLength:200});
|
|
1264
|
-
|
|
1429
|
+
const meta = el('p', `${graph.id} · Revision ${graph.revision}`, 'mono graph-meta'); meta.title = graph.id; general.append(meta);
|
|
1265
1430
|
if (graph.id === 'default') general.append(el('p', 'Duplicate this bundled preset to save your customization.', 'help'));
|
|
1266
1431
|
const start = field(general,'Starting node',graph.nodes[graph.entry]?.name || '',()=>{}); start.disabled=true; explain(start,'The Orchestrator is optional. Deleting the starting node promotes its first remaining connected successor, or the first remaining node if none is connected.');
|
|
1267
1432
|
field(general, 'Description', graph.metadata?.description, value => {graph.metadata={...graph.metadata,description:value};}, {multiline:true,maxLength:2000});
|
|
@@ -1290,7 +1455,7 @@ function renderInspector() {
|
|
|
1290
1455
|
const panels = inspectorTabs(parent, node.type === 'agent' ? ['general', 'model', 'behavior', 'advanced'] : outcomes(node).length ? ['general', 'behavior', 'advanced'] : ['general', 'advanced']);
|
|
1291
1456
|
const general = panels.general; field(general, 'Name', node.name, value => {node.name=value;}, {maxLength:200});
|
|
1292
1457
|
if (node.type === 'agent') {
|
|
1293
|
-
if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator - optional starting Agent for research, clarification and handoff. Remove it to start directly at the next node.','help'));
|
|
1458
|
+
if(node.agentRole==='orchestrator'){general.append(el('p','Orchestrator - optional starting Agent for research, clarification and handoff. Remove it to start directly at the next node.','help'));}
|
|
1294
1459
|
const prompt = promptField(general, 'Prompt', node.instruction ?? node.prompt ?? '', value => {node.instruction=value; delete node.prompt;}, { placeholder: 'Type / to add a skill' });
|
|
1295
1460
|
explain(prompt, 'Edit the instructions for this agent. Save the graph to use this prompt in future runs. This replaces this node\'s instructions; project guidance, advanced system instructions and runtime permissions still apply. Type / to add a skill: the node loads every /skill its prompt names when it runs. A skill this machine does not have is flagged here and skipped at run time; it never stops the graph.');
|
|
1296
1461
|
explain(check(general, 'Jev decisions', node.jevEnabled === true, value => { if (value) node.jevEnabled = true; else delete node.jevEnabled; }), 'Off unless ticked. When Jev is on, it assists this agent with routing decisions. The coding model still implements the task; sign-in, quota and runtime permissions apply.');
|
|
@@ -1335,7 +1500,7 @@ function render() { renderHeading(); renderList(); renderLibrary(); renderCanvas
|
|
|
1335
1500
|
async function openGraph(id) {
|
|
1336
1501
|
if (state.saving) { status('Wait for the current save before opening another graph.'); return; }
|
|
1337
1502
|
if (state.dirty && !await askConfirm(DISCARD_QUESTION)) return;
|
|
1338
|
-
try {
|
|
1503
|
+
try { const opened = await api(`/api/graphs/${encodeURIComponent(id)}`); const capMoved = hasSubagentCap(opened); state.graph = dropLegacyTokenFields(opened); const migrated = state.graph.editorMigration === true; state.dirty = migrated || capMoved; delete state.graph.editorMigration; clearSelection(); state.undo = []; state.redo = []; state.pendingProviderNodes = null; render(); fit(); status(migrated ? 'Legacy graph upgraded in editor - Save to persist a new revision' : capMoved ? 'Orchestrator Max subagents moved to Advanced > Subagents - Save to persist a new revision' : 'Graph loaded'); } catch (error) { status(error.message, true); }
|
|
1339
1504
|
}
|
|
1340
1505
|
function newId() { return `graph-${crypto.randomUUID()}`; }
|
|
1341
1506
|
function newGraph(duplicate = false, discarded = false) {
|
|
@@ -1363,6 +1528,7 @@ function newGraph(duplicate = false, discarded = false) {
|
|
|
1363
1528
|
// A duplicate copies the open graph, providerless nodes included, so its unmet provider
|
|
1364
1529
|
// requirements travel with it; an unrelated new graph starts without any.
|
|
1365
1530
|
state.dirty = true; clearSelection(); state.undo = []; state.redo = [];
|
|
1531
|
+
state.untouched = JSON.stringify(state.graph);
|
|
1366
1532
|
state.pendingProviderNodes = duplicate ? new Set(state.pendingProviderNodes ?? []) : null;
|
|
1367
1533
|
render(); fit(); status('New graph - Customize your agent and save your first revision');
|
|
1368
1534
|
}
|
|
@@ -1581,7 +1747,7 @@ function showAgentMenu(definition, use, x, y) {
|
|
|
1581
1747
|
]);
|
|
1582
1748
|
}
|
|
1583
1749
|
async function readDefinitions() {
|
|
1584
|
-
const data = await api('/api/bootstrap'); state.definitions = data.definitions
|
|
1750
|
+
const data = await api('/api/bootstrap'); state.definitions = foldDefinitionCaps(data.definitions); return state.definitions;
|
|
1585
1751
|
}
|
|
1586
1752
|
// The id is fixed for the dialog's lifetime and a committed write is confirmed from the store
|
|
1587
1753
|
// before any failure is reported: a dropped response or a failed refresh must not turn the
|
|
@@ -1747,6 +1913,9 @@ $('export').onclick = () => { if (!state.graph) return; downloadGraph(state.grap
|
|
|
1747
1913
|
if (typeof document.addEventListener === 'function') {
|
|
1748
1914
|
document.addEventListener('andorra:themechange', () => { if (state.graph) renderCanvas(); });
|
|
1749
1915
|
}
|
|
1916
|
+
// A draft still waiting out its pause is written as the page goes, so closing the tab right after
|
|
1917
|
+
// an edit does not lose it.
|
|
1918
|
+
window.addEventListener('pagehide', () => { void flushDraft(true); });
|
|
1750
1919
|
window.addEventListener('beforeunload', event => { document.activeElement?.blur(); if (state.dirty) { event.preventDefault(); event.returnValue = ''; } });
|
|
1751
1920
|
window.addEventListener('keydown', event => { if(event.key==='Delete' && !document.querySelector('dialog[open]') && !event.target?.closest('input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])') && !event.isComposing) {event.preventDefault();deleteSelection();return;} if(event.key==='Escape' && state.routePick){event.preventDefault();cancelRoutePick();return;} if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') { event.preventDefault(); document.activeElement?.blur(); if (!$('save').disabled) $('save').click(); } });
|
|
1752
1921
|
async function refreshCloudState() {
|
|
@@ -1853,4 +2022,4 @@ setFavicon('idle');
|
|
|
1853
2022
|
if (token) watchActivity();
|
|
1854
2023
|
try { if ((!window.parent || window.parent === window) && typeof Notification === 'function' && Notification.permission === 'default') { window.addEventListener('pointerdown', requestActivityNotifications); window.addEventListener('keydown', requestActivityNotifications); } } catch { /* Partial DOM. */ }
|
|
1855
2024
|
|
|
1856
|
-
(async () => { renderHeading(); if (!token) { status('Session token missing. Open this app using andorra graph.', true); return; } try { const data = await api('/api/bootstrap'); state.plan = data.plan; state.graphs = data.graphs; applyProviderRegistry(data); state.tools = data.tools || []; state.definitions = data.definitions
|
|
2025
|
+
(async () => { renderHeading(); if (!token) { status('Session token missing. Open this app using andorra graph.', true); return; } try { const data = await api('/api/bootstrap'); state.plan = data.plan; state.graphs = data.graphs; applyProviderRegistry(data); state.tools = data.tools || []; state.definitions = foldDefinitionCaps(data.definitions); renderLibrary(); renderList(); const wantsNew = new URLSearchParams(location.search).get('new') === '1'; if (wantsNew && canCreateGraph()) newGraph(); else if (state.graphs.length) { await openGraph((freeTier() && state.plan.freeGraphId) || state.graphs[0].id); if (wantsNew) status(FREE_CREATE_TIP, true); } else { render(); status('Create your first graph'); } window.AndorraEmbed?.ready?.(); if (data.graphMigrationErrors?.length) status('Some saved graphs could not be opened: ' + data.graphMigrationErrors.map(item => item.name + ' (' + item.id + '): ' + item.error).join('; ') + '. Their saved revisions are unchanged.', true); } catch (error) { status(error.message, true); } })();
|
|
@@ -368,6 +368,11 @@
|
|
|
368
368
|
current?.close();
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/** Redraw an open panel after its select's options changed; a closed select needs nothing. */
|
|
372
|
+
function refreshSelect(select) {
|
|
373
|
+
if (openSelect?.select === select && select.isConnected) openPanel(select);
|
|
374
|
+
}
|
|
375
|
+
|
|
371
376
|
function installSelects() {
|
|
372
377
|
// The platform opens its list on the press itself, so the press is where it is stopped.
|
|
373
378
|
document.addEventListener('mousedown', event => {
|
|
@@ -563,5 +568,6 @@
|
|
|
563
568
|
prompt: promptDialog,
|
|
564
569
|
filePicker,
|
|
565
570
|
closeSelect: closePanel,
|
|
571
|
+
refreshSelect,
|
|
566
572
|
});
|
|
567
573
|
})();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Which autosaved drafts the sidebar offers, and how a draft's age reads; no DOM dependencies. */
|
|
2
|
+
'use strict';
|
|
3
|
+
globalThis.AndorraDrafts = (() => {
|
|
4
|
+
/**
|
|
5
|
+
* The drafts worth a row: for each graph its newest one, and only while it still holds work the
|
|
6
|
+
* saved graph does not. A draft made from a revision older than the graph's saved one was either
|
|
7
|
+
* saved since or overtaken, so it is history, not something waiting to be picked up. `drafts`
|
|
8
|
+
* arrives newest first.
|
|
9
|
+
*/
|
|
10
|
+
function currentDrafts(drafts, graphs) {
|
|
11
|
+
const saved = new Map((graphs || []).map(graph => [graph.id, graph.revision]));
|
|
12
|
+
const seen = new Set(), current = [];
|
|
13
|
+
for (const draft of drafts || []) {
|
|
14
|
+
if (seen.has(draft.graphId)) continue;
|
|
15
|
+
seen.add(draft.graphId);
|
|
16
|
+
if (saved.has(draft.graphId) && draft.revision < saved.get(draft.graphId)) continue;
|
|
17
|
+
current.push(draft);
|
|
18
|
+
}
|
|
19
|
+
return current;
|
|
20
|
+
}
|
|
21
|
+
/** "now", "5m", "3h", "2d", then a short date: a row has room for a glance, not a timestamp. */
|
|
22
|
+
function age(updatedAt, now = Date.now()) {
|
|
23
|
+
if (!updatedAt) return '';
|
|
24
|
+
const minutes = Math.floor(Math.max(0, now - updatedAt) / 60_000);
|
|
25
|
+
if (minutes < 1) return 'now';
|
|
26
|
+
if (minutes < 60) return `${minutes}m`;
|
|
27
|
+
if (minutes < 60 * 24) return `${Math.floor(minutes / 60)}h`;
|
|
28
|
+
if (minutes < 60 * 24 * 7) return `${Math.floor(minutes / (60 * 24))}d`;
|
|
29
|
+
return new Date(updatedAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether an edit is worth a draft. A graph that is exactly what New or Duplicate produced holds
|
|
33
|
+
* nothing a click cannot make again, so it is not saved until it differs from that start.
|
|
34
|
+
*/
|
|
35
|
+
function worthSaving(graph, untouched) {
|
|
36
|
+
return !untouched || JSON.stringify(graph) !== untouched;
|
|
37
|
+
}
|
|
38
|
+
return { currentDrafts, age, worthSaving };
|
|
39
|
+
})();
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
// Text fields commit through onchange, usually on blur. Flush the current edited
|
|
308
308
|
// graph rather than the debounce's potentially older pending snapshot.
|
|
309
309
|
document.activeElement?.blur();
|
|
310
|
-
if (state.dirty && state.graph) {
|
|
310
|
+
if (typeof hasDraftableEdits === 'function' ? hasDraftableEdits() : state.dirty && state.graph) {
|
|
311
311
|
const snapshot = copy(state.graph);
|
|
312
312
|
await api('/api/drafts', snapshot);
|
|
313
313
|
if (JSON.stringify(state.graph) !== JSON.stringify(snapshot)) {
|