@andorra-labs/code 0.1.13 → 0.1.14
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/account-presentation.js +4 -1
- package/dist/src/agent-execution.js +300 -140
- package/dist/src/agent-mcp.js +2 -2
- package/dist/src/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +100 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +52 -0
- package/dist/src/andorra/hosted.js +126 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +7 -0
- package/dist/src/andorra/notices.js +15 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +68 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- package/dist/src/anthropic-credentials.js +9 -1
- package/dist/src/app-server/protocol.d.ts +6 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server.d.ts +27 -0
- package/dist/src/app-server.js +292 -85
- package/dist/src/auth/AuthManager.d.ts +9 -0
- package/dist/src/auth/AuthManager.js +161 -21
- package/dist/src/auth/deployment.d.ts +1 -0
- package/dist/src/auth/deployment.js +1 -0
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +26 -0
- package/dist/src/auth/store.js +34 -1
- package/dist/src/browser-runner.js +1 -1
- package/dist/src/browser-stealth.d.ts +19 -1
- package/dist/src/browser-stealth.js +23 -3
- package/dist/src/browser-ui/tokens.css +4 -4
- package/dist/src/browser-view.d.ts +65 -0
- package/dist/src/browser-view.js +229 -16
- package/dist/src/cli.js +43 -26
- package/dist/src/command-screens.d.ts +17 -1
- package/dist/src/command-screens.js +192 -21
- package/dist/src/commands.d.ts +7 -1
- package/dist/src/commands.js +78 -27
- package/dist/src/config.d.ts +6 -1
- package/dist/src/config.js +86 -3
- package/dist/src/dashboard-view.d.ts +2 -0
- package/dist/src/dashboard-view.js +11 -2
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/decision/applyToolMenu.js +1 -1
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +1 -0
- package/dist/src/graph-health.d.ts +11 -0
- package/dist/src/graph-health.js +36 -4
- package/dist/src/graph-manager-chat.d.ts +33 -0
- package/dist/src/graph-manager-chat.js +159 -5
- package/dist/src/graph-runner.js +27 -0
- package/dist/src/graph-selection.js +2 -1
- package/dist/src/graph-ui/app.js +25 -2
- package/dist/src/graph-ui/manager.js +40 -5
- package/dist/src/graph-ui/style.css +5 -2
- package/dist/src/graph-ui/tokens.css +4 -4
- package/dist/src/graphs.js +1 -3
- package/dist/src/hardened-runtime.js +1 -1
- package/dist/src/membership-errors.js +1 -1
- package/dist/src/membership.d.ts +10 -2
- package/dist/src/membership.js +20 -6
- package/dist/src/model-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +1 -0
- package/dist/src/model-metadata.js +40 -3
- package/dist/src/palette.d.ts +1 -0
- package/dist/src/palette.js +1 -1
- package/dist/src/permissions.js +17 -4
- package/dist/src/provider-connection.js +15 -0
- package/dist/src/provider-settings.d.ts +16 -1
- package/dist/src/provider-settings.js +36 -20
- package/dist/src/providers.d.ts +14 -2
- package/dist/src/providers.js +69 -11
- package/dist/src/react-runtime.js +12 -7
- package/dist/src/remote/engine-pool.js +5 -4
- package/dist/src/run-control.d.ts +2 -2
- package/dist/src/run-control.js +9 -6
- package/dist/src/runtime.d.ts +2 -0
- package/dist/src/runtime.js +2 -1
- package/dist/src/sessions.d.ts +1 -0
- package/dist/src/sessions.js +4 -2
- package/dist/src/skills/bundled/graph-manager/errors.md +1 -1
- package/dist/src/skills/bundled/provenance.json +738 -738
- package/dist/src/subagent-run.d.ts +2 -0
- package/dist/src/subagent-run.js +14 -3
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +2 -2
- package/dist/src/terminal-ui.d.ts +21 -0
- package/dist/src/terminal-ui.js +73 -10
- package/dist/src/transcript.js +3 -0
- package/dist/src/types.d.ts +3 -0
- package/dist/src/workspace-instructions.js +1 -1
- package/package.json +12 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import { mkdir } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
@@ -18,7 +18,39 @@ const UPDATE_MESSAGE = 'Update Andorra Code to use Graph Manager.';
|
|
|
18
18
|
const TOO_LARGE_MESSAGE = 'This graph is too large to send to Graph Manager.';
|
|
19
19
|
const TOOL_LINE_MAX = 120;
|
|
20
20
|
const DRAFTS_MAX = 64;
|
|
21
|
+
const LIVE_EDITS_MAX = 500;
|
|
21
22
|
const BUNDLED_GRAPH_ID = 'default';
|
|
23
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
24
|
+
const clone = (value) => JSON.parse(JSON.stringify(value));
|
|
25
|
+
/** `current` with the named fields, and those that changed between `before` and `after`, taken from `after`. */
|
|
26
|
+
function overlay(current, before, after, named) {
|
|
27
|
+
const out = clone(current);
|
|
28
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(after), ...named])) {
|
|
29
|
+
if (!named.includes(key) && same(before[key], after[key]))
|
|
30
|
+
continue;
|
|
31
|
+
if (Object.hasOwn(after, key))
|
|
32
|
+
out[key] = clone(after[key]);
|
|
33
|
+
else
|
|
34
|
+
delete out[key];
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function draftState(output) {
|
|
39
|
+
try {
|
|
40
|
+
const graph = record(record(record(JSON.parse(String(output ?? ''))).data).graph);
|
|
41
|
+
const nodes = record(graph.nodes);
|
|
42
|
+
if (graph.nodes !== nodes || !Array.isArray(graph.edges))
|
|
43
|
+
return undefined;
|
|
44
|
+
const edges = new Map();
|
|
45
|
+
for (const edge of graph.edges)
|
|
46
|
+
if (typeof record(edge).id === 'string')
|
|
47
|
+
edges.set(record(edge).id, clone(record(edge)));
|
|
48
|
+
return { nodes: clone(nodes), edges };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
22
54
|
const DRAFT_EDIT_ACTIONS = new Set(['andorra_graph_node_upsert', 'andorra_graph_node_patch', 'andorra_graph_node_remove', 'andorra_graph_edge_upsert', 'andorra_graph_edge_remove', 'andorra_graph_patch']);
|
|
23
55
|
export function draftEdit(action, args, output) {
|
|
24
56
|
let reply = {};
|
|
@@ -134,7 +166,7 @@ export function managerTask(turn) {
|
|
|
134
166
|
`You are helping in Graph Studio. Open graph: "${graphName(turn.graph)}", id ${graphId(turn.graph)} (${saved}).`,
|
|
135
167
|
graphId(turn.graph) === BUNDLED_GRAPH_ID
|
|
136
168
|
? `The open graph is the bundled preset, which cannot be changed: nothing can be saved under the id "${BUNDLED_GRAPH_ID}". The canvas below is what the user sees now. Do not edit this graph; create a new graph with a new id and its own name (mode "create"), based on the canvas, and make your changes there.`
|
|
137
|
-
: 'The canvas below is what the user sees now, including edits not yet saved. Work from it
|
|
169
|
+
: 'The canvas below is what the user sees now, including edits not yet saved. Work from it: open a draft of this same graph id (mode "create" when it is not saved yet, "edit" otherwise) and make the changes there, upserting from the canvas anything the draft lacks. Each draft edit shows on the canvas at once as an unsaved change. Do not publish this graph: the user reviews your changes and saves them from the editor, and a publish of it is declined.',
|
|
138
170
|
`Selected model: ${turn.provider}/${turn.model}. Use it for new agent nodes unless the user asks otherwise.`,
|
|
139
171
|
'',
|
|
140
172
|
'Canvas:',
|
|
@@ -176,6 +208,13 @@ export class GraphManagerChat {
|
|
|
176
208
|
idleWaiters = [];
|
|
177
209
|
now;
|
|
178
210
|
toolRows = 0;
|
|
211
|
+
liveEdits = [];
|
|
212
|
+
editSeq = 0;
|
|
213
|
+
/** Names this chat's edit numbering, so a panel never compares numbers from two conversations. */
|
|
214
|
+
editStream = randomUUID();
|
|
215
|
+
/** The open graph as the panel holds it: the canvas sent with the last message plus the edits since. */
|
|
216
|
+
canvas;
|
|
217
|
+
draftStates = new Map();
|
|
179
218
|
constructor(options) {
|
|
180
219
|
this.options = options;
|
|
181
220
|
this.directory = resolve(options.directory);
|
|
@@ -186,7 +225,7 @@ export class GraphManagerChat {
|
|
|
186
225
|
subscribe(listener) {
|
|
187
226
|
this.listeners.add(listener);
|
|
188
227
|
this.armIdleStop();
|
|
189
|
-
this.deliverTo(listener, { type: 'snapshot', events: [...this.transcript], state: this.state });
|
|
228
|
+
this.deliverTo(listener, { type: 'snapshot', events: [...this.transcript], state: this.state, edits: [...this.liveEdits], stream: this.editStream });
|
|
190
229
|
return () => { this.listeners.delete(listener); this.armIdleStop(); };
|
|
191
230
|
}
|
|
192
231
|
send(turn) {
|
|
@@ -235,6 +274,9 @@ export class GraphManagerChat {
|
|
|
235
274
|
this.graphCalls.clear();
|
|
236
275
|
this.drafts.clear();
|
|
237
276
|
this.otherRevisions.clear();
|
|
277
|
+
this.liveEdits = [];
|
|
278
|
+
this.draftStates.clear();
|
|
279
|
+
this.canvas = undefined;
|
|
238
280
|
this.openGraphId = undefined;
|
|
239
281
|
this.lastRevision = 0;
|
|
240
282
|
const snapshot = { type: 'snapshot', events: [], state: this.state };
|
|
@@ -273,6 +315,10 @@ export class GraphManagerChat {
|
|
|
273
315
|
const known = turn.saved ? turn.revision ?? 0 : 0;
|
|
274
316
|
this.lastRevision = id === this.openGraphId ? Math.max(this.lastRevision, known) : known;
|
|
275
317
|
this.openGraphId = id;
|
|
318
|
+
const nodes = record(turn.graph.nodes);
|
|
319
|
+
this.canvas = turn.graph.nodes === nodes && Array.isArray(turn.graph.edges)
|
|
320
|
+
? { nodes: clone(nodes), edges: clone(turn.graph.edges), fields: clone(turn.graph) }
|
|
321
|
+
: undefined;
|
|
276
322
|
this.lastModel = { provider: turn.provider, model: turn.model };
|
|
277
323
|
const task = managerTask(turn);
|
|
278
324
|
if (task.length > MANAGER_TASK_MAX_CHARS) {
|
|
@@ -538,6 +584,12 @@ export class GraphManagerChat {
|
|
|
538
584
|
else if (event === 'run.event')
|
|
539
585
|
this.onRunEvent(record(data.event));
|
|
540
586
|
else if (event === 'run.approval' && typeof data.id === 'string') {
|
|
587
|
+
if (this.publishesOpenGraph(data)) {
|
|
588
|
+
// In the editor Graph Manager's edits stay on the canvas unsaved; the user saves them.
|
|
589
|
+
if (this.engine)
|
|
590
|
+
void this.request(this.engine, 'run.approve', { id: data.id, approved: false }).catch(() => { });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
541
593
|
this.prompts.add(data.id);
|
|
542
594
|
this.emit({ type: 'approval', id: data.id, text: this.describe(String(data.name), data.arguments) });
|
|
543
595
|
}
|
|
@@ -617,15 +669,117 @@ export class GraphManagerChat {
|
|
|
617
669
|
this.drafts.set(draft, call.begins);
|
|
618
670
|
if (this.drafts.size > DRAFTS_MAX)
|
|
619
671
|
this.drafts.delete(this.drafts.keys().next().value);
|
|
672
|
+
const known = draftState(data.output);
|
|
673
|
+
this.draftStates.delete(draft);
|
|
674
|
+
if (known)
|
|
675
|
+
this.draftStates.set(draft, known);
|
|
676
|
+
if (this.draftStates.size > DRAFTS_MAX)
|
|
677
|
+
this.draftStates.delete(this.draftStates.keys().next().value);
|
|
620
678
|
}
|
|
621
679
|
if (call?.edits) {
|
|
622
|
-
const edit = draftEdit(call.edits.action, call.edits.args, data.output);
|
|
680
|
+
const edit = draftEdit(call.edits.action, call.edits.args, data.output) ?? this.editFromArguments(call.edits.action, call.edits.args);
|
|
623
681
|
if (edit)
|
|
624
|
-
this.
|
|
682
|
+
this.liveEdit(call.edits.graphId, call.edits.action, call.edits.args, edit);
|
|
625
683
|
}
|
|
626
684
|
this.checkRevision(call?.publishes ?? call?.removes);
|
|
627
685
|
}
|
|
628
686
|
}
|
|
687
|
+
publishesOpenGraph(data) {
|
|
688
|
+
if (data.name !== 'graphs' || !this.openGraphId || this.openGraphId === BUNDLED_GRAPH_ID)
|
|
689
|
+
return false;
|
|
690
|
+
const args = toolArguments(data.arguments);
|
|
691
|
+
if (args.action !== 'andorra_graph_publish')
|
|
692
|
+
return false;
|
|
693
|
+
const draftId = record(args.args).draftId;
|
|
694
|
+
return typeof draftId === 'string' && this.drafts.get(draftId)?.id === this.openGraphId;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* The engine clips a tool's output at 24,000 characters, so the reply to a call that set a long prompt
|
|
698
|
+
* is not readable JSON. The call succeeded, so its own arguments say what the draft now holds: an
|
|
699
|
+
* upsert's whole node or connection, or a patch over the draft's (or else the canvas's) copy of the step.
|
|
700
|
+
*/
|
|
701
|
+
editFromArguments(action, args) {
|
|
702
|
+
const node = record(args.node), edge = record(args.edge), patch = record(args.patch);
|
|
703
|
+
if (action === 'andorra_graph_node_upsert')
|
|
704
|
+
return typeof node.id === 'string' && node.id ? { kind: 'node', node: clone(node) } : undefined;
|
|
705
|
+
if (action === 'andorra_graph_edge_upsert')
|
|
706
|
+
return typeof edge.id === 'string' && typeof edge.source === 'string' && typeof edge.target === 'string' ? { kind: 'edge', edge: clone(edge) } : undefined;
|
|
707
|
+
if (action !== 'andorra_graph_node_patch' || typeof args.nodeId !== 'string' || !Object.keys(patch).length)
|
|
708
|
+
return undefined;
|
|
709
|
+
const draftId = typeof args.draftId === 'string' ? args.draftId : '';
|
|
710
|
+
const base = this.draftStates.get(draftId)?.nodes[args.nodeId] ?? this.canvas?.nodes[args.nodeId];
|
|
711
|
+
return base ? { kind: 'node', node: { ...clone(base), ...clone(patch), id: args.nodeId } } : undefined;
|
|
712
|
+
}
|
|
713
|
+
liveEdit(graphId, action, args, edit) {
|
|
714
|
+
const patched = action === 'andorra_graph_node_patch' ? Object.keys(record(args.patch)) : undefined;
|
|
715
|
+
const shown = graphId === this.openGraphId ? this.reconcile(typeof args.draftId === 'string' ? args.draftId : '', edit, patched) : edit;
|
|
716
|
+
if (!shown)
|
|
717
|
+
return;
|
|
718
|
+
const entry = { seq: ++this.editSeq, graphId, edit: shown, stream: this.editStream };
|
|
719
|
+
this.liveEdits.push(entry);
|
|
720
|
+
if (this.liveEdits.length > LIVE_EDITS_MAX)
|
|
721
|
+
this.liveEdits.splice(0, this.liveEdits.length - LIVE_EDITS_MAX);
|
|
722
|
+
this.broadcast({ type: 'graph.edit', ...entry });
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* A draft opened in edit mode starts from the latest saved revision, which lacks the unsaved changes on
|
|
726
|
+
* the canvas. A patched node from that draft would put stale fields back, so a patch of a step the
|
|
727
|
+
* canvas holds carries only the fields it names, plus any the backend changed with them. An upsert
|
|
728
|
+
* states the whole step or connection, so it is shown as given.
|
|
729
|
+
*/
|
|
730
|
+
reconcile(draftId, edit, patched) {
|
|
731
|
+
const draft = this.draftStates.get(draftId), canvas = this.canvas;
|
|
732
|
+
if (edit.kind === 'node') {
|
|
733
|
+
const id = String(edit.node.id);
|
|
734
|
+
const before = draft?.nodes[id], current = canvas?.nodes[id];
|
|
735
|
+
if (draft)
|
|
736
|
+
draft.nodes[id] = clone(edit.node);
|
|
737
|
+
let node = edit.node;
|
|
738
|
+
if (patched) {
|
|
739
|
+
// The draft still had a step the canvas no longer has: it was removed after the draft opened.
|
|
740
|
+
if (canvas && !current)
|
|
741
|
+
return undefined;
|
|
742
|
+
if (current)
|
|
743
|
+
node = overlay(current, before ?? edit.node, edit.node, patched);
|
|
744
|
+
}
|
|
745
|
+
if (canvas)
|
|
746
|
+
canvas.nodes[id] = clone(node);
|
|
747
|
+
return { kind: 'node', node };
|
|
748
|
+
}
|
|
749
|
+
if (edit.kind === 'edge') {
|
|
750
|
+
const id = String(edit.edge.id);
|
|
751
|
+
draft?.edges.set(id, clone(edit.edge));
|
|
752
|
+
if (canvas) {
|
|
753
|
+
const index = canvas.edges.findIndex(item => record(item).id === id);
|
|
754
|
+
if (index >= 0)
|
|
755
|
+
canvas.edges[index] = clone(edit.edge);
|
|
756
|
+
else
|
|
757
|
+
canvas.edges.push(clone(edit.edge));
|
|
758
|
+
}
|
|
759
|
+
return edit;
|
|
760
|
+
}
|
|
761
|
+
if (edit.kind === 'node.remove') {
|
|
762
|
+
const touches = (item) => item.source === edit.nodeId || item.target === edit.nodeId;
|
|
763
|
+
if (draft) {
|
|
764
|
+
delete draft.nodes[edit.nodeId];
|
|
765
|
+
for (const [key, item] of draft.edges)
|
|
766
|
+
if (touches(item))
|
|
767
|
+
draft.edges.delete(key);
|
|
768
|
+
}
|
|
769
|
+
if (canvas) {
|
|
770
|
+
delete canvas.nodes[edit.nodeId];
|
|
771
|
+
canvas.edges = canvas.edges.filter(item => !touches(item));
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else if (edit.kind === 'edge.remove') {
|
|
775
|
+
draft?.edges.delete(edit.edgeId);
|
|
776
|
+
if (canvas)
|
|
777
|
+
canvas.edges = canvas.edges.filter(item => record(item).id !== edit.edgeId);
|
|
778
|
+
}
|
|
779
|
+
else if (canvas)
|
|
780
|
+
Object.assign(canvas.fields, clone(edit.patch));
|
|
781
|
+
return edit;
|
|
782
|
+
}
|
|
629
783
|
settleTool(toolCallId, status, reason) {
|
|
630
784
|
if (typeof toolCallId !== 'string' || !toolCallId)
|
|
631
785
|
return;
|
package/dist/src/graph-runner.js
CHANGED
|
@@ -397,6 +397,10 @@ export async function runGraph(graph, options) {
|
|
|
397
397
|
}
|
|
398
398
|
const liveUsage = { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
399
399
|
const nodeUsageTotals = new Map();
|
|
400
|
+
// A node's total includes what its subagents spent, so a subagent's own figures are kept apart: usage
|
|
401
|
+
// arrives per model invocation, and the events that name both ids say which invocations are whose.
|
|
402
|
+
const invocationUsageTotals = new Map();
|
|
403
|
+
const subagentInvocations = new Map();
|
|
400
404
|
const addUsage = (target, delta) => {
|
|
401
405
|
target.inputTokens += delta.inputTokens;
|
|
402
406
|
target.outputTokens += delta.outputTokens;
|
|
@@ -571,14 +575,37 @@ export async function runGraph(graph, options) {
|
|
|
571
575
|
const total = nodeUsageTotals.get(nodeId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
572
576
|
addMeasuredUsage(total, usage);
|
|
573
577
|
nodeUsageTotals.set(nodeId, total);
|
|
578
|
+
if (origin?.invocationId) {
|
|
579
|
+
const own = invocationUsageTotals.get(origin.invocationId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
580
|
+
addMeasuredUsage(own, usage);
|
|
581
|
+
invocationUsageTotals.set(origin.invocationId, own);
|
|
582
|
+
}
|
|
574
583
|
options.onUsage?.(usage, origin);
|
|
575
584
|
},
|
|
576
585
|
onEvent: async (event) => {
|
|
577
586
|
event = { ...event, data: { runId: result.id, ...event.data, nodeName: node.name, nodeType: node.type } };
|
|
587
|
+
const { subagentId, invocationId } = event.data;
|
|
588
|
+
if (typeof subagentId === 'string' && subagentId && typeof invocationId === 'string' && invocationId) {
|
|
589
|
+
const own = subagentInvocations.get(subagentId) ?? new Set();
|
|
590
|
+
own.add(invocationId);
|
|
591
|
+
subagentInvocations.set(subagentId, own);
|
|
592
|
+
}
|
|
578
593
|
if (event.type === 'agent.model.completed') {
|
|
579
594
|
const { measuredOutputTokens: _chipsOnly, ...runUsage } = liveUsage;
|
|
580
595
|
event = { ...event, data: { ...event.data, graphUsage: runUsage,
|
|
581
596
|
nodeUsage: { ...(nodeUsageTotals.get(nodeId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 }) } } };
|
|
597
|
+
if (typeof subagentId === 'string' && subagentId) {
|
|
598
|
+
const subagentUsage = { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
599
|
+
for (const id of subagentInvocations.get(subagentId) ?? []) {
|
|
600
|
+
const part = invocationUsageTotals.get(id);
|
|
601
|
+
if (part === undefined)
|
|
602
|
+
continue;
|
|
603
|
+
addUsage(subagentUsage, part);
|
|
604
|
+
if (part.measuredOutputTokens !== undefined)
|
|
605
|
+
subagentUsage.measuredOutputTokens = (subagentUsage.measuredOutputTokens ?? 0) + part.measuredOutputTokens;
|
|
606
|
+
}
|
|
607
|
+
event = { ...event, data: { ...event.data, subagentUsage } };
|
|
608
|
+
}
|
|
582
609
|
}
|
|
583
610
|
if (activation.parallelGroup && event.type === 'graph.todos.updated')
|
|
584
611
|
event = { ...event, type: 'agent.modifier.todos.updated' };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getAuthStatus } from './auth/index.js';
|
|
2
|
+
import { currentGraphSelection } from './membership.js';
|
|
2
3
|
export async function currentGraphSubject() {
|
|
3
4
|
const status = await getAuthStatus().catch(() => ({ signedIn: false, subject: undefined }));
|
|
4
5
|
return status.signedIn && status.subject && /^[A-Za-z0-9-]{1,128}$/.test(status.subject) ? status.subject : undefined;
|
|
@@ -11,7 +12,7 @@ export function identityStillHolds(declared, current) {
|
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
13
14
|
export function configuredGraphSelection(config, subject) {
|
|
14
|
-
return subject && Object.hasOwn(config.graphSelections ?? {}, subject) ? config.graphSelections[subject] : 'default';
|
|
15
|
+
return subject && Object.hasOwn(config.graphSelections ?? {}, subject) ? currentGraphSelection(config.graphSelections[subject]) : 'default';
|
|
15
16
|
}
|
|
16
17
|
export function saveGraphSelection(config, graph, subject) {
|
|
17
18
|
if (graph !== 'default' && !subject)
|
package/dist/src/graph-ui/app.js
CHANGED
|
@@ -966,12 +966,33 @@ function inspectorTabs(parent, ids) {
|
|
|
966
966
|
if (remembered !== undefined && !ids.includes(remembered)) state.inspectorTab = remembered;
|
|
967
967
|
return panels;
|
|
968
968
|
}
|
|
969
|
+
const promptHeights = new Map();
|
|
969
970
|
function promptField(parent, label, value, onChange, options = {}) {
|
|
970
971
|
const input = field(parent, label, value, onChange, { multiline: true, maxLength: 100000, ...options });
|
|
971
972
|
const wrapper = input.parentElement; wrapper.className = 'field prompt-field';
|
|
972
973
|
const isFullscreen = () => !!wrapper.classList.contains?.('fullscreen');
|
|
973
|
-
|
|
974
|
+
// Typing grows the field up to 60% of the window; dragging its corner sets a height that typing no
|
|
975
|
+
// longer overrides, kept for this label while the editor stays open so another step opens at that size.
|
|
976
|
+
const grow = () => { try {
|
|
977
|
+
if (isFullscreen()) return;
|
|
978
|
+
const kept = promptHeights.get(label); if (kept) { input.style.height = kept; return; }
|
|
979
|
+
if (!input.scrollHeight) return;
|
|
980
|
+
const cap = Math.round((globalThis.innerHeight || 0) * 0.6);
|
|
981
|
+
input.style.height = 'auto'; input.style.height = `${cap ? Math.min(input.scrollHeight + 2, cap) : input.scrollHeight + 2}px`;
|
|
982
|
+
} catch { } };
|
|
974
983
|
input.addEventListener?.('input', grow);
|
|
984
|
+
input.addEventListener?.('pointerdown', () => {
|
|
985
|
+
if (isFullscreen()) return;
|
|
986
|
+
const before = input.offsetHeight;
|
|
987
|
+
const settle = () => { if (input.offsetHeight && input.offsetHeight !== before) promptHeights.set(label, `${input.offsetHeight}px`); };
|
|
988
|
+
document.addEventListener?.('pointerup', settle, { once: true });
|
|
989
|
+
});
|
|
990
|
+
input.addEventListener?.('dblclick', event => {
|
|
991
|
+
// Double-clicking the resize corner returns the field to sizing itself to its text.
|
|
992
|
+
if (!promptHeights.has(label) || isFullscreen()) return;
|
|
993
|
+
const rect = input.getBoundingClientRect?.(); if (!rect || event.clientX < rect.right - 16 || event.clientY < rect.bottom - 16) return;
|
|
994
|
+
promptHeights.delete(label); grow();
|
|
995
|
+
});
|
|
975
996
|
const expand = el('button', undefined, 'icon-button btn-small prompt-expand'); expand.type = 'button';
|
|
976
997
|
let backdrop;
|
|
977
998
|
const setFullscreen = on => {
|
|
@@ -1294,7 +1315,9 @@ function renderCompletion(parent, node) {
|
|
|
1294
1315
|
graph.edges = graph.edges.filter(edge => edge.source !== node.id || outcomes(node).includes(edgeOutcome(edge)));
|
|
1295
1316
|
});
|
|
1296
1317
|
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.');
|
|
1297
|
-
if (delegatesWriting(node)
|
|
1318
|
+
if (delegatesWriting(node)) parent.append(el('p', node.completion?.mode === 'outcomes'
|
|
1319
|
+
? 'An Orchestrator with a writing role picks one of these outcomes whether or not its subagents implemented the work, so name a route for each case, such as release, QA or no QA.'
|
|
1320
|
+
: 'An Orchestrator with a writing role completes by passing work on, or delivers landed changes through its delivered port. Choose outcomes to route delivered work yourself.', 'help'));
|
|
1298
1321
|
if (node.completion?.mode === 'outcomes') {
|
|
1299
1322
|
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'));
|
|
1300
1323
|
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'));
|
|
@@ -46,6 +46,9 @@ globalThis.AndorraManager = (() => {
|
|
|
46
46
|
agentFields = { ...saved.fields };
|
|
47
47
|
}
|
|
48
48
|
let deferredEdits = [];
|
|
49
|
+
// The newest live edit this page has received, per graph. Kept across panel close and graph
|
|
50
|
+
// switches, so a snapshot after reconnecting applies only the edits made while nobody listened.
|
|
51
|
+
const editsSeen = new Map();
|
|
49
52
|
let shownGraphId = null;
|
|
50
53
|
let choice;
|
|
51
54
|
let providersSeen = '';
|
|
@@ -83,15 +86,22 @@ globalThis.AndorraManager = (() => {
|
|
|
83
86
|
if (open) fillModels();
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
// What each graph's conversation last sent, kept while another graph is open: edits that arrive
|
|
90
|
+
// after coming back are merged against the canvas that conversation's message carried.
|
|
91
|
+
const baselines = new Map();
|
|
86
92
|
function switchConversation(graphId) {
|
|
87
93
|
disconnect();
|
|
94
|
+
if (streamGraphId) baselines.set(streamGraphId, { merge: mergeState(), latestUserSeen, sentCanvas, chatGraphId });
|
|
95
|
+
const kept = baselines.get(graphId);
|
|
96
|
+
baselines.delete(graphId);
|
|
88
97
|
streamGraphId = graphId;
|
|
89
|
-
chatGraphId = graphId;
|
|
98
|
+
chatGraphId = kept?.chatGraphId ?? graphId;
|
|
90
99
|
transcript = []; runState = 'idle';
|
|
91
|
-
posted = []; sentCanvas = null; beforeLastMessage = null; unsureCanvas = false;
|
|
100
|
+
posted = []; sentCanvas = kept?.sentCanvas ?? null; beforeLastMessage = null; unsureCanvas = false;
|
|
92
101
|
offeredRevision = null; createdOffer = null; localError = '';
|
|
93
102
|
decisions.clear(); answering.clear(); openRows.clear();
|
|
94
|
-
|
|
103
|
+
if (kept) restoreMerge(kept.merge); else rebase(null);
|
|
104
|
+
latestUserSeen = kept?.latestUserSeen ?? null; mergeBeforeMessage = null; deferredEdits = [];
|
|
95
105
|
rendered = [];
|
|
96
106
|
if (open) { connect(); render(); }
|
|
97
107
|
}
|
|
@@ -203,6 +213,7 @@ globalThis.AndorraManager = (() => {
|
|
|
203
213
|
if (missed && !deleted.has(missed.graphId) && missed.revision > (state.graph.revision || 0)) offeredRevision = missed.revision;
|
|
204
214
|
const created = transcript.map(entry => logic.createdGraph(state.graph?.id, entry)).filter(Boolean).pop();
|
|
205
215
|
if (created && !deleted.has(created.id)) createdOffer = created;
|
|
216
|
+
replayEdits(event);
|
|
206
217
|
} else if (event.type === 'user') {
|
|
207
218
|
latestUserSeen = event.text;
|
|
208
219
|
accepted(event.text);
|
|
@@ -296,7 +307,31 @@ globalThis.AndorraManager = (() => {
|
|
|
296
307
|
return Object.fromEntries(keys.map(key => [key, Object.hasOwn(agentFields, key) ? JSON.parse(agentFields[key]) : sent[key]]));
|
|
297
308
|
}
|
|
298
309
|
|
|
310
|
+
// Each conversation numbers its own edits, so a watermark belongs to a conversation and a graph.
|
|
311
|
+
const editKey = (stream, graphId) => `${typeof stream === 'string' ? stream : ''}\n${graphId}`;
|
|
312
|
+
function replayEdits(snapshot) {
|
|
313
|
+
const stream = typeof snapshot.stream === 'string' ? snapshot.stream : '';
|
|
314
|
+
const edits = (Array.isArray(snapshot.edits) ? snapshot.edits : [])
|
|
315
|
+
.filter(entry => entry && Number.isSafeInteger(entry.seq) && typeof entry.graphId === 'string')
|
|
316
|
+
.map(entry => ({ ...entry, key: editKey(entry.stream ?? stream, entry.graphId) }));
|
|
317
|
+
const newest = new Map();
|
|
318
|
+
for (const entry of edits) newest.set(entry.key, Math.max(newest.get(entry.key) ?? 0, entry.seq));
|
|
319
|
+
const own = streamGraphId ? editKey(stream, streamGraphId) : null;
|
|
320
|
+
if (own && !newest.has(own)) newest.set(own, 0);
|
|
321
|
+
// The first snapshot this page sees for a conversation only marks its edits: they predate this page's canvas.
|
|
322
|
+
const first = new Set([...newest.keys()].filter(key => !editsSeen.has(key)));
|
|
323
|
+
for (const key of first) editsSeen.set(key, newest.get(key));
|
|
324
|
+
for (const entry of edits) {
|
|
325
|
+
if (first.has(entry.key) || !(entry.seq > (editsSeen.get(entry.key) ?? 0))) continue;
|
|
326
|
+
liveEdit({ type: 'graph.edit', graphId: entry.graphId, edit: entry.edit, seq: entry.seq, stream: entry.stream ?? stream });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
299
330
|
function liveEdit(event) {
|
|
331
|
+
if (Number.isSafeInteger(event.seq) && typeof event.graphId === 'string') {
|
|
332
|
+
const key = editKey(event.stream, event.graphId);
|
|
333
|
+
editsSeen.set(key, Math.max(editsSeen.get(key) ?? 0, event.seq));
|
|
334
|
+
}
|
|
300
335
|
if (!state.graph || event.graphId !== state.graph.id || !logic.soundEdit(event.edit)) return;
|
|
301
336
|
if (typingInEditor()) {
|
|
302
337
|
deferredEdits.push(event);
|
|
@@ -377,7 +412,7 @@ globalThis.AndorraManager = (() => {
|
|
|
377
412
|
if (event.edit.kind === 'edge.remove') agentEdges.set(event.edit.edgeId, 'null');
|
|
378
413
|
if (event.edit.kind === 'graph') for (const [key, value] of Object.entries(event.edit.patch)) agentFields[key] = JSON.stringify(value);
|
|
379
414
|
if (!edit) {
|
|
380
|
-
if (kept.length) { sentCanvas = null; status('Graph Manager changed
|
|
415
|
+
if (kept.length) { sentCanvas = null; status('Graph Manager changed something you also edited; your own edits were kept.'); }
|
|
381
416
|
return;
|
|
382
417
|
}
|
|
383
418
|
const trial = JSON.parse(JSON.stringify(graph));
|
|
@@ -401,7 +436,7 @@ globalThis.AndorraManager = (() => {
|
|
|
401
436
|
return;
|
|
402
437
|
}
|
|
403
438
|
if (followed) sentCanvas = JSON.stringify(state.graph);
|
|
404
|
-
status(kept.length ? 'Graph Manager changed the
|
|
439
|
+
status(kept.length ? 'Graph Manager changed the graph; your own edits were kept. Save to keep its changes.' : 'Graph Manager changed the graph. Save to keep it.');
|
|
405
440
|
}
|
|
406
441
|
function graphDeleted(event) {
|
|
407
442
|
if (state.graphs.some(entry => entry.id === event.graphId)) {
|
|
@@ -234,10 +234,13 @@ main { display: flex; flex: 1; min-width: 0; flex-direction: column; }
|
|
|
234
234
|
|
|
235
235
|
#canvas {
|
|
236
236
|
flex: 1; position: relative; overflow: hidden; min-width: 0; touch-action: none;
|
|
237
|
+
/* Panning and dragging steps would otherwise select node, edge and group text. */
|
|
238
|
+
user-select: none; -webkit-user-select: none;
|
|
237
239
|
background-color: var(--canvas-bg);
|
|
238
240
|
background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1.2px);
|
|
239
241
|
background-size: 20px 20px; background-position: -10px -10px;
|
|
240
242
|
}
|
|
243
|
+
#canvas :is(input, textarea, [contenteditable]) { user-select: text; -webkit-user-select: text; }
|
|
241
244
|
#scene { position: absolute; transform-origin: 0 0; }
|
|
242
245
|
#edges { position: absolute; overflow: visible; width: 1px; height: 1px; pointer-events: none; }
|
|
243
246
|
#nodes { position: absolute; }
|
|
@@ -340,14 +343,14 @@ main { display: flex; flex: 1; min-width: 0; flex-direction: column; }
|
|
|
340
343
|
.tool-label { display: flex; align-items: center; gap: var(--space-2); padding: 6px 0; }
|
|
341
344
|
.tool-label input { width: auto; min-height: 0; }
|
|
342
345
|
|
|
343
|
-
.prompt-field > textarea { min-height: 120px;
|
|
346
|
+
.prompt-field > textarea { min-height: 120px; resize: vertical; overflow-y: auto; padding-right: 40px; }
|
|
344
347
|
.prompt-field > .prompt-expand { grid-column: 2; grid-row: 2; justify-self: end; align-self: start; z-index: 1; margin: var(--space-1); min-width: var(--control-height); }
|
|
345
348
|
.prompt-field.fullscreen {
|
|
346
349
|
position: fixed; z-index: var(--z-raised); inset: var(--space-5); margin: 0; grid-template-rows: auto 1fr;
|
|
347
350
|
padding: var(--space-4); background: var(--bg-surface); border: 1px solid var(--border);
|
|
348
351
|
border-radius: var(--card-radius); box-shadow: var(--shadow-menu);
|
|
349
352
|
}
|
|
350
|
-
.prompt-field.fullscreen > textarea { height: 100%;
|
|
353
|
+
.prompt-field.fullscreen > textarea { height: 100%; resize: none; font-size: var(--type-sm); }
|
|
351
354
|
body.prompt-fullscreen #inspector { z-index: calc(var(--z-dialog) + 1); }
|
|
352
355
|
.prompt-backdrop { position: fixed; inset: 0; z-index: var(--z-dialog); background: var(--overlay); }
|
|
353
356
|
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
--accent-hover: #ffffff; --accent-ring: rgba(245,245,245,.36);
|
|
53
53
|
--accent-fill: #1372da; --accent-fill-hover: #2a7fdd; --on-accent-fill: #f5f5f5;
|
|
54
54
|
--accent-text: #71aeff; --focus: #1f87fc;
|
|
55
|
-
--ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9;
|
|
56
|
-
--ok-text: #7cc79a; --err-text: #f47174; --warn-text: #ececec; --merged-text: #bba4f2;
|
|
55
|
+
--ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9; --caution: #d9a520; --caution-text: #f2c94c;
|
|
56
|
+
--ok-text: #7cc79a; --err-text: #f47174; --warn-text: #ececec; --merged-text: #bba4f2; --draft-text: #f0a35e;
|
|
57
57
|
--skill: #aab8ff; --skill-wash: rgba(120,140,255,.18);
|
|
58
58
|
--ok-wash: rgba(47,158,106,.14); --err-wash: rgba(229,72,77,.14); --merged-wash: rgba(142,110,224,.14);
|
|
59
59
|
--add-wash: rgba(47,158,106,.16); --del-wash: rgba(229,72,77,.16);
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
--accent-hover: #333333; --accent-ring: rgba(28,28,28,.48);
|
|
100
100
|
--accent-fill: #1680f3; --accent-fill-hover: #1776dd; --on-accent-fill: #ffffff;
|
|
101
101
|
--accent-text: #0b6dd3; --focus: #1680f3;
|
|
102
|
-
--ok: #3d7a5c; --err: #d13438; --warn: #45464b;
|
|
103
|
-
--ok-text: #36704f; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4;
|
|
102
|
+
--ok: #3d7a5c; --err: #d13438; --warn: #45464b; --caution: #b8860b; --caution-text: #8a6100;
|
|
103
|
+
--ok-text: #36704f; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4; --draft-text: #b35a0e;
|
|
104
104
|
--skill: #3b4fc4; --skill-wash: rgba(59,79,196,.10);
|
|
105
105
|
--ok-wash: rgba(61,122,92,.08); --err-wash: rgba(209,52,56,.08); --merged-wash: rgba(106,79,196,.08);
|
|
106
106
|
--add-wash: rgba(61,122,92,.14); --del-wash: rgba(209,52,56,.13);
|
package/dist/src/graphs.js
CHANGED
|
@@ -746,9 +746,7 @@ function validateGraphInternal(value, options = {}) {
|
|
|
746
746
|
const delegated = node.agentRole === 'orchestrator' && spawningEnabled && isWritingRole(r);
|
|
747
747
|
if (delegated && (s.workspace ?? 'shared-read-only') !== 'worktree')
|
|
748
748
|
fail(`${label}: writing roles on an Orchestrator require separate worktrees; set subagents.workspace to "worktree" (Separate Git worktree)`);
|
|
749
|
-
if (delegated && node.completion?.mode === 'outcomes')
|
|
750
|
-
fail(`${label}: Orchestrator delegation needs a single completion outcome; remove declared outcomes or the writing roles`);
|
|
751
|
-
if (delegated && node.completion?.mode === 'single' && node.completion.outcome === DELIVERED_OUTCOME)
|
|
749
|
+
if (delegated && (node.completion?.mode === 'outcomes' ? node.completion.outcomes.includes(DELIVERED_OUTCOME) : node.completion?.outcome === DELIVERED_OUTCOME))
|
|
752
750
|
fail(`${label}: the outcome name ${DELIVERED_OUTCOME} is reserved for Orchestrator delegation; rename the completion outcome`);
|
|
753
751
|
const parent = node.agentRole === 'orchestrator' && spawningEnabled && !delegated ? intakeCapabilities(node) : effectiveCapabilities(node);
|
|
754
752
|
const child = r.capabilities ?? { ...parent, ...((s.workspace ?? 'shared-read-only') === 'shared-read-only' ? { filesystem: parent.filesystem === 'none' ? 'none' : 'read', git: parent.git === 'none' ? 'none' : 'read', shell: 'disabled' } : {}) };
|
|
@@ -103,7 +103,7 @@ export class AndorraAgentEngine {
|
|
|
103
103
|
catalog: name => { const t = catalog(name); return t ? { family: toolFamily(t), readOnly: retrySafe(t) } : undefined; },
|
|
104
104
|
fact: (input, signal) => !remoteFactsEnabled || !manager ? Promise.resolve(undefined) : manager.fact(input.id === 'task_needs_checks'
|
|
105
105
|
? { ...input, state: { task: factTaskText(redactSecrets(task).text, options.nodeInstruction ? redactSecrets(options.nodeInstruction).text : undefined) } }
|
|
106
|
-
: input, { runId, nodeId, invocationId }, signal, options.onEvent),
|
|
106
|
+
: input, { runId, nodeId, invocationId, ...(options.subagentId ? { subagentId: options.subagentId } : {}) }, signal, options.onEvent),
|
|
107
107
|
emit,
|
|
108
108
|
});
|
|
109
109
|
const shell = permitted.find(t => t.exitZeroOnReturn)?.name ?? catalog('shell')?.name;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const FEATURES = '
|
|
1
|
+
const FEATURES = 'custom graphs and the Graph Editor';
|
|
2
2
|
const REASONS = {
|
|
3
3
|
tls: 'a secure connection to the account service could not be verified',
|
|
4
4
|
dns: 'the account service address could not be resolved',
|
package/dist/src/membership.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Graph } from './graphs.js';
|
|
2
2
|
import type { TelemetryPlan } from './telemetry/schema.js';
|
|
3
3
|
export declare const SOFTWARE_ENGINEER_HARNESS: Graph;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare function
|
|
4
|
+
export declare const RETIRED_ANDORRA_SELECTION = ":andorra";
|
|
5
|
+
export declare function currentGraphSelection(id: string): string;
|
|
6
6
|
export type MembershipFailureReason = 'tls' | 'dns' | 'network';
|
|
7
7
|
export type MembershipTier = 'free' | 'legacy' | 'paid';
|
|
8
8
|
export declare const MEMBERSHIP_TIERS: readonly MembershipTier[];
|
|
@@ -18,11 +18,18 @@ export interface Membership {
|
|
|
18
18
|
dailyDecisionUsed?: number;
|
|
19
19
|
dailyDecisionResetsAt?: string;
|
|
20
20
|
decisionsSinceRollout?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The rolling allowance: Free accounts get `windowDecisionLimit` decisions per `windowDays` UTC days;
|
|
23
|
+
* Legacy accounts are unlimited under fair use (`fairUse`), with a daily and a window cap.
|
|
24
|
+
* `windowDecisionResetsAt` is when the oldest counted decision leaves the window.
|
|
25
|
+
*/
|
|
21
26
|
fairUse?: boolean;
|
|
22
27
|
windowDays?: number;
|
|
23
28
|
windowDecisionLimit?: number;
|
|
24
29
|
windowDecisionUsed?: number;
|
|
25
30
|
windowDecisionResetsAt?: string;
|
|
31
|
+
/** Uncapped Paid account: no daily, window or global cap applies. The service answers `unlimited: true` and omits every allowance field. */
|
|
32
|
+
unlimited?: boolean;
|
|
26
33
|
billingUrl?: string;
|
|
27
34
|
}
|
|
28
35
|
export declare function membershipPlanLabel(tier: MembershipTier | undefined, paid: boolean): string;
|
|
@@ -47,4 +54,5 @@ export declare function readGraphMembership(signal?: AbortSignal): Promise<Membe
|
|
|
47
54
|
export declare function loadAccessibleGraph(id?: string, signal?: AbortSignal, membership?: (signal?: AbortSignal, home?: string) => Promise<Membership>, options?: {
|
|
48
55
|
bindProviders?: boolean;
|
|
49
56
|
allowDeleted?: boolean;
|
|
57
|
+
allowRetired?: boolean;
|
|
50
58
|
}): Promise<Graph>;
|
package/dist/src/membership.js
CHANGED
|
@@ -12,14 +12,21 @@ export const SOFTWARE_ENGINEER_HARNESS = {
|
|
|
12
12
|
schemaVersion: 2, id: 'software-engineer', name: DEFAULT_AGENT_GRAPH.name, revision: 1, entry: DEFAULT_AGENT_GRAPH.entry,
|
|
13
13
|
nodes: structuredClone(DEFAULT_AGENT_GRAPH.nodes), edges: structuredClone(DEFAULT_AGENT_GRAPH.edges),
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// The built-in paid "Andorra" preset (Orchestrator -> Andorra Agent) was removed: the only built-in
|
|
16
|
+
// graph is Default. A selection saved while the preset existed runs the Default graph.
|
|
17
|
+
export const RETIRED_ANDORRA_SELECTION = ':andorra';
|
|
18
|
+
// What the preset ran. Kept only so an attempt that stopped on it can be resumed against the nodes its
|
|
19
|
+
// journal and checkpoints name; nothing offers it for a new task.
|
|
20
|
+
function retiredAndorraHarness() {
|
|
17
21
|
const graph = { ...structuredClone(DEFAULT_HARNESS), id: 'andorra', name: 'Andorra' };
|
|
18
22
|
for (const node of Object.values(graph.nodes))
|
|
19
23
|
if (node.type === 'agent')
|
|
20
24
|
node.jevEnabled = true;
|
|
21
25
|
return graph;
|
|
22
26
|
}
|
|
27
|
+
export function currentGraphSelection(id) {
|
|
28
|
+
return id === RETIRED_ANDORRA_SELECTION ? 'default' : id;
|
|
29
|
+
}
|
|
23
30
|
export const MEMBERSHIP_TIERS = ['free', 'legacy', 'paid'];
|
|
24
31
|
export function windowFields(result) {
|
|
25
32
|
const positive = (value) => Number.isSafeInteger(value) && value > 0;
|
|
@@ -137,6 +144,7 @@ export function createMembershipClient(deps) {
|
|
|
137
144
|
const observedAt = new Date().toISOString();
|
|
138
145
|
await (deps.recordPlan ?? recordPlanConfirmation)({ subject: result.subject, tier: analyticsPlanFromMembership(tier, result.paid), observedAt }, home).catch(() => { });
|
|
139
146
|
const windowed = windowFields(result);
|
|
147
|
+
const unlimited = typeof result.unlimited === 'boolean' ? result.unlimited : undefined;
|
|
140
148
|
const lifetime = Number.isSafeInteger(result.decisionsSinceRollout) && result.decisionsSinceRollout >= 0
|
|
141
149
|
? result.decisionsSinceRollout : undefined;
|
|
142
150
|
const billing = typeof result.billingUrl === 'string' && /^https:\/\//.test(result.billingUrl) && result.billingUrl.length <= 2048
|
|
@@ -145,6 +153,7 @@ export function createMembershipClient(deps) {
|
|
|
145
153
|
...(validUsage ? { dailyDecisionUsed: result.dailyDecisionUsed, dailyDecisionResetsAt: reset } : {}),
|
|
146
154
|
...(lifetime === undefined ? {} : { decisionsSinceRollout: lifetime }),
|
|
147
155
|
...windowed,
|
|
156
|
+
...(unlimited === undefined ? {} : { unlimited }),
|
|
148
157
|
...(billing === undefined ? {} : { billingUrl: billing }) };
|
|
149
158
|
}
|
|
150
159
|
catch (error) {
|
|
@@ -177,16 +186,21 @@ export async function readGraphMembership(signal) {
|
|
|
177
186
|
}
|
|
178
187
|
export async function loadAccessibleGraph(id = 'default', signal, membership = getMembership, options = {}) {
|
|
179
188
|
signal?.throwIfAborted();
|
|
180
|
-
if (id ===
|
|
189
|
+
if (id === RETIRED_ANDORRA_SELECTION && options.allowRetired) {
|
|
190
|
+
const access = await membership(signal);
|
|
191
|
+
signal?.throwIfAborted();
|
|
192
|
+
if (!access.paid)
|
|
193
|
+
throw PaidMembershipRequiredError.for(access);
|
|
194
|
+
return retiredAndorraHarness();
|
|
195
|
+
}
|
|
196
|
+
if (currentGraphSelection(id) === 'default')
|
|
181
197
|
return structuredClone(SOFTWARE_ENGINEER_HARNESS);
|
|
182
198
|
if (id === GRAPH_MANAGER_GRAPH_ID)
|
|
183
199
|
return structuredClone(GRAPH_MANAGER_HARNESS);
|
|
184
200
|
const access = await membership(signal);
|
|
185
201
|
signal?.throwIfAborted();
|
|
186
|
-
if (!access.paid &&
|
|
202
|
+
if (!access.paid && access.unavailable)
|
|
187
203
|
throw PaidMembershipRequiredError.for(access);
|
|
188
|
-
if (id === ANDORRA_GRAPH_SELECTION)
|
|
189
|
-
return getAndorraHarness();
|
|
190
204
|
if (!access.subject)
|
|
191
205
|
throw PaidMembershipRequiredError.for(access);
|
|
192
206
|
if (!/^[A-Za-z0-9-]{1,128}$/.test(access.subject))
|