@andorra-labs/code 0.1.8 → 0.1.9
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/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/src/account-presentation.d.ts +11 -0
- package/dist/src/account-presentation.js +29 -2
- package/dist/src/agent-execution.js +37 -4
- package/dist/src/agent-mcp.d.ts +12 -0
- package/dist/src/agent-mcp.js +81 -2
- package/dist/src/app-server/protocol.d.ts +12 -0
- package/dist/src/app-server/reasoning.d.ts +0 -8
- package/dist/src/app-server/reasoning.js +15 -28
- package/dist/src/app-server.d.ts +7 -0
- package/dist/src/app-server.js +59 -11
- package/dist/src/auth/AuthManager.d.ts +15 -0
- package/dist/src/auth/AuthManager.js +66 -7
- package/dist/src/browser-runner.js +1 -2
- package/dist/src/browser-server.js +10 -2
- package/dist/src/browser-session.js +6 -2
- package/dist/src/browser-stealth.d.ts +29 -0
- package/dist/src/browser-stealth.js +166 -0
- package/dist/src/browser-ui/app.js +108 -13
- package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
- package/dist/src/browser-ui/index.html +8 -8
- package/dist/src/browser-ui/style.css +199 -171
- package/dist/src/browser-ui/tokens.css +198 -0
- package/dist/src/browser-view.d.ts +57 -9
- package/dist/src/browser-view.js +187 -36
- package/dist/src/cli.js +21 -4
- package/dist/src/coding-tools.js +9 -5
- package/dist/src/command-screens.js +4 -4
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -1
- package/dist/src/completion-gates.d.ts +35 -0
- package/dist/src/completion-gates.js +25 -0
- package/dist/src/completion.d.ts +6 -0
- package/dist/src/completion.js +36 -3
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/context-budget.d.ts +11 -0
- package/dist/src/context-budget.js +13 -0
- package/dist/src/decision/DecisionEngine.d.ts +5 -1
- package/dist/src/decision/DecisionManager.d.ts +1 -0
- package/dist/src/decision/DecisionManager.js +14 -3
- package/dist/src/decision/FactContinuations.d.ts +6 -0
- package/dist/src/decision/FactContinuations.js +9 -1
- package/dist/src/decision/FactServiceGate.js +1 -1
- package/dist/src/decision/hostedSkills.d.ts +37 -0
- package/dist/src/decision/hostedSkills.js +64 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
- package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
- package/dist/src/default-graph.d.ts +11 -0
- package/dist/src/default-graph.js +20 -0
- package/dist/src/duration.d.ts +13 -2
- package/dist/src/duration.js +27 -3
- package/dist/src/graph-manager-chat.d.ts +302 -0
- package/dist/src/graph-manager-chat.js +940 -0
- package/dist/src/graph-runner.js +6 -0
- package/dist/src/graph-server.d.ts +9 -0
- package/dist/src/graph-server.js +167 -16
- package/dist/src/graph-studio-features.js +2 -2
- package/dist/src/graph-sync.js +5 -2
- package/dist/src/graph-ui/app.js +252 -71
- package/dist/src/graph-ui/controls.css +55 -32
- package/dist/src/graph-ui/controls.js +85 -9
- package/dist/src/graph-ui/edge-router.js +114 -13
- package/dist/src/graph-ui/embed.js +23 -8
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/library.css +4 -10
- package/dist/src/graph-ui/manager-markdown.js +155 -0
- package/dist/src/graph-ui/manager-state.js +191 -0
- package/dist/src/graph-ui/manager.css +161 -0
- package/dist/src/graph-ui/manager.js +700 -0
- package/dist/src/graph-ui/studio-canvas.js +2 -0
- package/dist/src/graph-ui/studio.css +24 -23
- package/dist/src/graph-ui/studio.js +29 -8
- package/dist/src/graph-ui/style.css +125 -92
- package/dist/src/graph-ui/tokens.css +217 -151
- package/dist/src/graphs.d.ts +69 -1
- package/dist/src/graphs.js +160 -7
- package/dist/src/hardened-runtime.js +8 -2
- package/dist/src/membership-errors.d.ts +14 -0
- package/dist/src/membership-errors.js +24 -1
- package/dist/src/membership.d.ts +20 -0
- package/dist/src/membership.js +45 -16
- package/dist/src/palette.d.ts +25 -8
- package/dist/src/palette.js +26 -8
- package/dist/src/provider-engine.d.ts +4 -4
- package/dist/src/provider-engine.js +39 -22
- package/dist/src/providers.d.ts +24 -0
- package/dist/src/providers.js +47 -2
- package/dist/src/qa/guidance.d.ts +26 -0
- package/dist/src/qa/guidance.js +59 -0
- package/dist/src/qa/index.d.ts +1 -6
- package/dist/src/qa/index.js +1 -14
- package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
- package/dist/src/qa/runtime/ProcessManager.js +69 -13
- package/dist/src/react-runtime.d.ts +11 -0
- package/dist/src/react-runtime.js +190 -51
- package/dist/src/remote/engine-pool.js +4 -1
- package/dist/src/run-progress.d.ts +6 -0
- package/dist/src/run-progress.js +7 -0
- package/dist/src/runtime.d.ts +8 -0
- package/dist/src/session-skills.d.ts +75 -0
- package/dist/src/session-skills.js +151 -0
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +6 -12
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
- package/dist/src/stall-recovery.d.ts +22 -0
- package/dist/src/stall-recovery.js +71 -0
- package/dist/src/subagent-run.js +1 -2
- package/dist/src/terminal-ui.d.ts +2 -2
- package/dist/src/terminal-ui.js +18 -13
- package/dist/src/transcript.js +9 -1
- package/dist/src/types.d.ts +18 -4
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +55 -15
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/limits.md +9 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +16 -1
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
- package/package.json +1 -1
- package/tests/chat-side-panel-test-plan.md +1 -1
package/dist/src/transcript.js
CHANGED
|
@@ -122,12 +122,16 @@ export function formatEvent(event) {
|
|
|
122
122
|
// Decision calls have their own actor; originating graph names and provider payloads stay private.
|
|
123
123
|
if (event.type === 'decision.requested')
|
|
124
124
|
return { text: '• [Jev] Evaluating context needs' };
|
|
125
|
+
if (event.type === 'decision.skills_truncated')
|
|
126
|
+
return typeof data.text === 'string' && data.text ? { text: ` ⚠ ${data.text}` } : undefined;
|
|
125
127
|
if (event.type === 'decision.completed')
|
|
126
128
|
return { text: ` └ [Jev] Decisions received${formatDurationSuffix({ durationMs: data.latencyMs })}` };
|
|
127
129
|
if (event.type === 'decision.fallback' && data.reason !== 'low_confidence') {
|
|
128
130
|
const reasons = {
|
|
129
131
|
authentication_required: 'Sign in required', decision_daily_limit_reached: 'Daily quota reached',
|
|
132
|
+
decision_window_limit_reached: '30-day Jev limit reached',
|
|
130
133
|
decision_service_unavailable: 'Service unavailable', invalid_response: 'Invalid response',
|
|
134
|
+
decision_protocol_unsupported: 'Request not accepted by the service',
|
|
131
135
|
decision_input_too_large: 'Context exceeds hosted size limits; evaluation skipped locally',
|
|
132
136
|
timeout: 'Request timed out', cancelled: 'Request cancelled',
|
|
133
137
|
};
|
|
@@ -194,7 +198,11 @@ export function formatEvent(event) {
|
|
|
194
198
|
...(shortened ? { detail: indent(output) + suffix } : {}) };
|
|
195
199
|
}
|
|
196
200
|
if (event.type === 'agent.turn.continued')
|
|
197
|
-
return { text:
|
|
201
|
+
return { text: data.toolCallDropped === true
|
|
202
|
+
? `? ${actor}Continuing: the reply's tool call never arrived, likely a tool this node does not have; the next reply must call one of its tools.`
|
|
203
|
+
: data.forcedToolCall === true
|
|
204
|
+
? `? ${actor}Continuing: the reply had no tool call or handoff; the next reply must call one of this node's tools.`
|
|
205
|
+
: `? ${actor}Continuing: graph stop hook requested more work or a structured handoff.` };
|
|
198
206
|
if (event.type === 'agent.completion.rejected')
|
|
199
207
|
return { text: `• ${actor}Retrying: ${data.reason === 'truncatedResponse' ? 'model response was truncated; no tools executed' : data.reason === 'outputTokenLimit' ? 'output token limit reached; continuing the response' : data.reason === 'duplicateToolCallIds' ? 'model reused a tool-call ID; no tools executed' : 'model response did not meet the completion contract'}.` };
|
|
200
208
|
if (event.type === 'subagent.started')
|
package/dist/src/types.d.ts
CHANGED
|
@@ -90,13 +90,27 @@ export interface GenerateRequest {
|
|
|
90
90
|
/** Explicit bounded auxiliary output (for example semantic summaries); absent for ordinary inference. */
|
|
91
91
|
maxTokens?: number;
|
|
92
92
|
/**
|
|
93
|
-
* How many trailing messages are
|
|
94
|
-
*
|
|
95
|
-
* its conversation breakpoint on the last committed message in front of
|
|
96
|
-
* request can reuse the cached history even though
|
|
93
|
+
* How many trailing messages are rewritten before the next request: post-tool guidance, or
|
|
94
|
+
* a message added for this one request. A provider that caches only up to explicit
|
|
95
|
+
* breakpoints places its conversation breakpoint on the last committed message in front of
|
|
96
|
+
* them, so the next request can reuse the cached history even though they change. Run
|
|
97
|
+
* snapshots (todo list, widget values) are not counted: once sent they are committed history.
|
|
97
98
|
*/
|
|
98
99
|
mutableTail?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Require a tool call in this one response. Sent where the protocol has it (OpenAI-compatible
|
|
102
|
+
* `tool_choice: "required"`; Anthropic `{ type: "any" }` while thinking is off) and ignored by
|
|
103
|
+
* every other adapter. A server that rejects the field is asked again without it, so a provider
|
|
104
|
+
* that cannot honor it answers the request as if it had never been set.
|
|
105
|
+
*/
|
|
106
|
+
toolChoice?: 'required';
|
|
99
107
|
context?: ModelRequestContext;
|
|
108
|
+
/**
|
|
109
|
+
* The input this request would cost, anchored to the last provider-measured input. Lazy, so an
|
|
110
|
+
* ordinary turn never pays for it: a wrapper that answers the request without calling the model
|
|
111
|
+
* (a Jev bypass) reads it to journal what the skipped call would have sent.
|
|
112
|
+
*/
|
|
113
|
+
estimateInputTokens?: () => number;
|
|
100
114
|
onRetry?: (retry: ModelRetry) => void | Promise<void>;
|
|
101
115
|
onRequest?: () => void;
|
|
102
116
|
/**
|
|
@@ -8,6 +8,8 @@ export interface UsageModelRow {
|
|
|
8
8
|
outputTokens: number;
|
|
9
9
|
cacheRead: number;
|
|
10
10
|
savedInputEstimate: number;
|
|
11
|
+
/** Estimated output of the bypassed calls: the run/node's mean measured output per call. */
|
|
12
|
+
savedOutputEstimate: number;
|
|
11
13
|
bypassedTurns: number;
|
|
12
14
|
}
|
|
13
15
|
export interface UsageDayRow {
|
|
@@ -16,6 +18,7 @@ export interface UsageDayRow {
|
|
|
16
18
|
outputTokens: number;
|
|
17
19
|
cacheRead: number;
|
|
18
20
|
savedInputEstimate: number;
|
|
21
|
+
savedOutputEstimate: number;
|
|
19
22
|
bypassedTurns: number;
|
|
20
23
|
models: UsageModelRow[];
|
|
21
24
|
}
|
|
@@ -25,14 +28,18 @@ export interface UsageAnalytics {
|
|
|
25
28
|
/**
|
|
26
29
|
* `jevInputTokens`/`jevOutputTokens` are the measured tokens of the run/nodes Jev was enabled on
|
|
27
30
|
* — the only usage a bypass could have replaced, and so the base of the avoidance rate.
|
|
31
|
+
* `contextEstimatedTurns` counts the bypasses whose input came from the journaled context size
|
|
32
|
+
* rather than the last-measured-input fallback.
|
|
28
33
|
*/
|
|
29
34
|
totals: {
|
|
30
35
|
inputTokens: number;
|
|
31
36
|
outputTokens: number;
|
|
32
37
|
cacheRead: number;
|
|
33
38
|
savedInputEstimate: number;
|
|
39
|
+
savedOutputEstimate: number;
|
|
34
40
|
bypassedTurns: number;
|
|
35
41
|
unestimatedTurns: number;
|
|
42
|
+
contextEstimatedTurns: number;
|
|
36
43
|
jevInputTokens: number;
|
|
37
44
|
jevOutputTokens: number;
|
|
38
45
|
};
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
* Local Usage dashboard accounting from trajectory JSONL.
|
|
3
3
|
*
|
|
4
4
|
* Model usage is provider-reported and counted once per model.response. A Jev bypass has no
|
|
5
|
-
* provider usage:
|
|
6
|
-
*
|
|
5
|
+
* provider usage, so the call it skipped is estimated: its input is the context the runtime would
|
|
6
|
+
* have sent, journaled on the event as `estimatedInputTokens` (anchored to the node's last measured
|
|
7
|
+
* request), and its output is the mean output of that run/node's measured calls so far. A bypass
|
|
8
|
+
* journaled before the runtime recorded the context falls back to the node's last measured input,
|
|
9
|
+
* and one with neither is counted as unestimated. This is a counterfactual estimate, never billed
|
|
10
|
+
* or actually saved tokens.
|
|
7
11
|
* Measured tokens are also totalled for the run/nodes Jev was enabled on — the ones that journaled
|
|
8
12
|
* a `decision.*` event — so the avoidance rate is taken over usage Jev could have affected and a
|
|
9
13
|
* node without Jev does not dilute it.
|
|
@@ -34,8 +38,8 @@ const dateOf = (time) => {
|
|
|
34
38
|
return Number.isFinite(instant.getTime()) ? instant.toISOString().slice(0, 10) : undefined;
|
|
35
39
|
};
|
|
36
40
|
const keyOf = (providerId, model) => JSON.stringify([providerId, model]);
|
|
37
|
-
const emptyModel = (providerId, provider, model) => ({ providerId, provider, model, inputTokens: 0, outputTokens: 0, cacheRead: 0, savedInputEstimate: 0, bypassedTurns: 0 });
|
|
38
|
-
const emptyDay = (date) => ({ date, inputTokens: 0, outputTokens: 0, cacheRead: 0, savedInputEstimate: 0, bypassedTurns: 0, models: [] });
|
|
41
|
+
const emptyModel = (providerId, provider, model) => ({ providerId, provider, model, inputTokens: 0, outputTokens: 0, cacheRead: 0, savedInputEstimate: 0, savedOutputEstimate: 0, bypassedTurns: 0 });
|
|
42
|
+
const emptyDay = (date) => ({ date, inputTokens: 0, outputTokens: 0, cacheRead: 0, savedInputEstimate: 0, savedOutputEstimate: 0, bypassedTurns: 0, models: [] });
|
|
39
43
|
/** A streaming collector, also usable with synthetic records in regression tests. */
|
|
40
44
|
export function createUsageCollector(windowDays, now = new Date(), resolveProvider = provider => provider) {
|
|
41
45
|
if (![7, 30, 365].includes(windowDays))
|
|
@@ -46,10 +50,13 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
46
50
|
const days = new Map();
|
|
47
51
|
const models = new Map();
|
|
48
52
|
const baselines = new Map();
|
|
53
|
+
/** Every measured call's output per run/node, including those before the window: the output estimate. */
|
|
54
|
+
const outputs = new Map();
|
|
49
55
|
/** In-window measured tokens per run/node, and the run/nodes a `decision.*` event named. */
|
|
50
56
|
const nodeTokens = new Map();
|
|
51
57
|
const jevNodes = new Set();
|
|
52
58
|
let unestimatedTurns = 0;
|
|
59
|
+
let contextEstimatedTurns = 0;
|
|
53
60
|
const dayFor = (date) => {
|
|
54
61
|
let day = days.get(date);
|
|
55
62
|
if (!day) {
|
|
@@ -87,8 +94,13 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
87
94
|
const cache = Math.min(input, nonnegative(usage?.cacheRead) ?? 0);
|
|
88
95
|
const identity = JSON.stringify([item.runId, item.nodeId]);
|
|
89
96
|
// Keep an observed baseline even when it predates the displayed date range.
|
|
90
|
-
if (typeof item.runId === 'string' && typeof item.nodeId === 'string')
|
|
97
|
+
if (typeof item.runId === 'string' && typeof item.nodeId === 'string') {
|
|
91
98
|
baselines.set(identity, { providerId, model, inputTokens: input });
|
|
99
|
+
const history = outputs.get(identity) ?? { tokens: 0, calls: 0 };
|
|
100
|
+
history.tokens += output;
|
|
101
|
+
history.calls++;
|
|
102
|
+
outputs.set(identity, history);
|
|
103
|
+
}
|
|
92
104
|
if (date < cutoff)
|
|
93
105
|
return;
|
|
94
106
|
const day = dayFor(date);
|
|
@@ -118,19 +130,32 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
118
130
|
jevNodes.add(JSON.stringify([data.runId, data.nodeId]));
|
|
119
131
|
if (event.type !== 'decision.turn_bypassed')
|
|
120
132
|
return;
|
|
121
|
-
const
|
|
122
|
-
|
|
133
|
+
const identity = typeof data?.runId === 'string' && typeof data.nodeId === 'string' ? JSON.stringify([data.runId, data.nodeId]) : undefined;
|
|
134
|
+
const baseline = identity === undefined ? undefined : baselines.get(identity);
|
|
135
|
+
const history = identity === undefined ? undefined : outputs.get(identity);
|
|
123
136
|
if (date < cutoff)
|
|
124
137
|
return;
|
|
125
138
|
const day = dayFor(date);
|
|
126
139
|
day.row.bypassedTurns++;
|
|
127
|
-
|
|
140
|
+
// The context the skipped call would have sent; a zero reading is no reading.
|
|
141
|
+
const journaled = nonnegative(data?.estimatedInputTokens) || undefined;
|
|
142
|
+
const input = journaled ?? baseline?.inputTokens;
|
|
143
|
+
if (input === undefined) {
|
|
128
144
|
unestimatedTurns++;
|
|
129
145
|
return;
|
|
130
146
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
147
|
+
if (journaled !== undefined)
|
|
148
|
+
contextEstimatedTurns++;
|
|
149
|
+
const output = history?.calls ? Math.round(history.tokens / history.calls) : 0;
|
|
150
|
+
// The call would have gone where the event says; an older event names neither, and the node's
|
|
151
|
+
// last measured call is the best record of where it was going.
|
|
152
|
+
const providerId = typeof data?.providerId === 'string' && data.providerId ? data.providerId : baseline?.providerId ?? 'unknown';
|
|
153
|
+
const model = typeof data?.model === 'string' && data.model ? data.model : baseline?.model ?? 'unknown';
|
|
154
|
+
day.row.savedInputEstimate += input;
|
|
155
|
+
day.row.savedOutputEstimate += output;
|
|
156
|
+
for (const target of [modelFor(day.models, providerId, model), modelFor(models, providerId, model)]) {
|
|
157
|
+
target.savedInputEstimate += input;
|
|
158
|
+
target.savedOutputEstimate += output;
|
|
134
159
|
target.bypassedTurns++;
|
|
135
160
|
}
|
|
136
161
|
};
|
|
@@ -147,8 +172,10 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
147
172
|
outputTokens: orderedModels.reduce((sum, row) => sum + row.outputTokens, 0),
|
|
148
173
|
cacheRead: orderedModels.reduce((sum, row) => sum + row.cacheRead, 0),
|
|
149
174
|
savedInputEstimate: orderedModels.reduce((sum, row) => sum + row.savedInputEstimate, 0),
|
|
175
|
+
savedOutputEstimate: orderedModels.reduce((sum, row) => sum + row.savedOutputEstimate, 0),
|
|
150
176
|
bypassedTurns: orderedDays.reduce((sum, day) => sum + day.bypassedTurns, 0),
|
|
151
177
|
unestimatedTurns,
|
|
178
|
+
contextEstimatedTurns,
|
|
152
179
|
jevInputTokens: 0,
|
|
153
180
|
jevOutputTokens: 0,
|
|
154
181
|
};
|
|
@@ -170,8 +197,11 @@ const MAX_CACHE_BYTES = 64 * 1024 * 1024;
|
|
|
170
197
|
const MAX_CACHE_RECORDS = 500_000;
|
|
171
198
|
/** Retained records across the whole home; past this, further files are excluded, not read. */
|
|
172
199
|
const MAX_CACHE_RECORDS_TOTAL = 250_000;
|
|
173
|
-
/**
|
|
174
|
-
|
|
200
|
+
/**
|
|
201
|
+
* 2: files are re-read once to capture the `j` markers version 1 never stored.
|
|
202
|
+
* 3: and again for the bypass accounting fields (`i`, `p`, `m` on `b`) version 2 never stored.
|
|
203
|
+
*/
|
|
204
|
+
const CACHE_VERSION = 3;
|
|
175
205
|
const NAME_PATTERN = /^[a-zA-Z0-9_-]{1,64}\.jsonl$/;
|
|
176
206
|
/** The largest window the collector accepts; files older than its bound are never replayed. */
|
|
177
207
|
const MAX_WINDOW_DAYS = 365;
|
|
@@ -215,10 +245,14 @@ const slimOf = (record) => {
|
|
|
215
245
|
if (event.type !== 'decision.turn_bypassed')
|
|
216
246
|
return typeof data?.runId === 'string' && typeof data.nodeId === 'string'
|
|
217
247
|
? { k: 'j', t: item.time, r: data.runId, n: data.nodeId } : undefined;
|
|
248
|
+
const wouldSend = nonnegative(data?.estimatedInputTokens);
|
|
218
249
|
return {
|
|
219
250
|
k: 'b', t: item.time,
|
|
220
251
|
...(typeof data?.runId === 'string' ? { r: data.runId } : {}),
|
|
221
252
|
...(typeof data?.nodeId === 'string' ? { n: data.nodeId } : {}),
|
|
253
|
+
...(wouldSend ? { i: wouldSend } : {}),
|
|
254
|
+
...(typeof data?.providerId === 'string' && data.providerId ? { p: data.providerId } : {}),
|
|
255
|
+
...(typeof data?.model === 'string' && data.model ? { m: data.model } : {}),
|
|
222
256
|
};
|
|
223
257
|
};
|
|
224
258
|
/** Rebuild a collector-shaped record from its slim capture; absent optional fields stay absent. */
|
|
@@ -231,7 +265,12 @@ const replayOf = (slim) => slim.k === 'r'
|
|
|
231
265
|
: {
|
|
232
266
|
type: 'runtime.event', time: slim.t,
|
|
233
267
|
// The collector reads a marker's run and node only, so one type stands in for all of them.
|
|
234
|
-
event: { type: slim.k === 'b' ? 'decision.turn_bypassed' : 'decision.ready', data: {
|
|
268
|
+
event: { type: slim.k === 'b' ? 'decision.turn_bypassed' : 'decision.ready', data: {
|
|
269
|
+
...(slim.r === undefined ? {} : { runId: slim.r }), ...(slim.n === undefined ? {} : { nodeId: slim.n }),
|
|
270
|
+
...(slim.k === 'b' && slim.i !== undefined ? { estimatedInputTokens: slim.i } : {}),
|
|
271
|
+
...(slim.k === 'b' && slim.p !== undefined ? { providerId: slim.p } : {}),
|
|
272
|
+
...(slim.k === 'b' && slim.m !== undefined ? { model: slim.m } : {}),
|
|
273
|
+
} },
|
|
235
274
|
};
|
|
236
275
|
/**
|
|
237
276
|
* Validate one loaded slim record. Anything malformed is dropped rather than trusted: the cache is
|
|
@@ -247,7 +286,8 @@ const validSlim = (value) => {
|
|
|
247
286
|
if (item.n !== undefined && typeof item.n !== 'string')
|
|
248
287
|
return false;
|
|
249
288
|
if (item.k === 'b')
|
|
250
|
-
return
|
|
289
|
+
return (item.i === undefined || nonnegative(item.i) !== undefined)
|
|
290
|
+
&& (item.p === undefined || typeof item.p === 'string') && (item.m === undefined || typeof item.m === 'string');
|
|
251
291
|
if (item.k === 'j')
|
|
252
292
|
return typeof item.r === 'string' && typeof item.n === 'string';
|
|
253
293
|
if (item.k !== 'r')
|
package/docs/concepts/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Edges carry explicit input mappings — `$source.output.field` or `$run.input.ta
|
|
|
36
36
|
|
|
37
37
|
### Revisions
|
|
38
38
|
|
|
39
|
-
Saved graphs are immutable revisions. A published revision is never rewritten: a pinned run keeps describing the graph it started with, and editing produces the next revision. Selecting `default` always runs the single Andorra Agent harness, signed in or not; the Orchestrator → Andorra Agent workflow is the paid `:andorra` graph, and older bundled default revisions (1–
|
|
39
|
+
Saved graphs are immutable revisions. A published revision is never rewritten: a pinned run keeps describing the graph it started with, and editing produces the next revision. Selecting `default` always runs the single Andorra Agent harness, signed in or not; the Orchestrator → Andorra Agent workflow is the paid `:andorra` graph, and older bundled default revisions (1–6) remain available for compatibility. Graph Studio shows `default` at its latest revision (7), the same single Andorra Agent that Default runs; revision 6 is the Orchestrator workflow the `:andorra` preset uses.
|
|
40
40
|
|
|
41
41
|
## How a task actually runs
|
|
42
42
|
|
package/docs/concepts/limits.md
CHANGED
|
@@ -30,6 +30,15 @@ A graph carries its own `limits` block, and its `maxNodeVisits` is the ceiling o
|
|
|
30
30
|
|
|
31
31
|
A graph or node limit can tighten whatever the configuration sets but never loosen it.
|
|
32
32
|
|
|
33
|
+
## Checks on the completion that ends a run
|
|
34
|
+
|
|
35
|
+
An agent ends its node by calling `complete_agent`. When that completion ends the run (a root agent whose outcome leads straight to an End node) and the agent has acted (it ran at least one tool or wrote the plan), the host checks two things before accepting it:
|
|
36
|
+
|
|
37
|
+
- **A written summary.** The summary is the answer you read. A completion that carries only `outcome` and `output` is sent back for one.
|
|
38
|
+
- **A finished plan.** If the run's todo list still has an item that is not completed, the completion is sent back. The agent finishes the work, corrects the list, or leaves the item open and names it under `## Not done`.
|
|
39
|
+
|
|
40
|
+
Each check sends a completion back at most twice, then lets it through and records the waiver (`agent.completion.gate.waived` in the run log). On the last iteration `maxIterations` allows, both checks are waived at once, because a completion sent back there would end the run with no answer. These checks are separate from `maxCompletionRepairs`: they never spend a repair and never fail a run. Not checked: a subagent, an Orchestrator (its `delivered` outcome has its own checks), a node that hands off to another node, one iteration or copy of a loop or parallel modifier, and a node that answers without running any tool, such as a classifier or a structured step whose output is its product.
|
|
41
|
+
|
|
33
42
|
## Request-level bounds
|
|
34
43
|
|
|
35
44
|
- **File reads** return at most 2,000 lines per call, truncate any single displayed line beyond 2,000 characters, and always stay inside the 24,000-character tool-output budget — a page with long lines stops at the last whole line that fits. A longer file is read by following the `Use offset=N to continue` line each page reports until the whole file has been read; `Write` and `Edit` accept an existing file only after that complete read, so an agent that stops half-way is told which lines are still unread. Those offsets are only suggested while the file still matches the last read; a file that changed means reading it again. The window is fixed, not a configuration key.
|
|
@@ -33,7 +33,7 @@ macOS and Linux bundles have no installer step.
|
|
|
33
33
|
**The check at startup (every platform).** Before the window starts an engine it reads the
|
|
34
34
|
installed CLI's `package.json` (it does not run it). A missing CLI, or one from another version,
|
|
35
35
|
stops at the startup screen with the reason and the command that fixes it, for example
|
|
36
|
-
`npm install -g @andorra-labs/code@0.1.
|
|
36
|
+
`npm install -g @andorra-labs/code@0.1.9`; **Check again** retries after you run it. This is what
|
|
37
37
|
you see after an in-app update on macOS or Linux, where nothing installs the new CLI for you, and
|
|
38
38
|
after updating or removing the CLI by hand. An `andorra` launcher on `PATH` whose package cannot
|
|
39
39
|
be located is started without a version check.
|
|
@@ -83,11 +83,26 @@ Select **Do not inherit skills** on a node to keep that node's skill context ind
|
|
|
83
83
|
- The **Agents** section lists built-in presets first and saved variants after, all at one level. **Copy** on any Agent row creates a new Agent starting from that row's settings under a name you choose.
|
|
84
84
|
- Library changes save independently of graph revisions and do not change nodes already on the canvas. Save a selected node as a named variant from the Agent inspector.
|
|
85
85
|
- Select a node or connection and press Delete to remove it, then Undo to restore. Delete inside a text field edits text. Deleting every remaining node is prevented so the draft retains a start.
|
|
86
|
-
- Connections use orthogonal routes around node cards and indicate direction with arrowheads. Separate overlapping cards when their ports are enclosed by another card. If a return edge creates an unbounded cycle, the inspector explains it and offers a finite visit limit.
|
|
86
|
+
- Connections use orthogonal routes around node cards and indicate direction with arrowheads. Every connection is the same neutral line whatever its outcome; the outcome rides it as a label, and hovering or selecting a connection traces it. Separate overlapping cards when their ports are enclosed by another card. If a return edge creates an unbounded cycle, the inspector explains it and offers a finite visit limit.
|
|
87
|
+
- Move around the canvas by dragging its background or scrolling (two fingers on a trackpad; Shift + mouse wheel scrolls sideways). Pinch, or hold Ctrl (Cmd on macOS) while scrolling, to zoom about the pointer. The dot grid moves and scales with the cards, and with **Snap to grid** on a dragged card lands on a dot. Zoom in, Zoom out, Fit graph and Arrange ease the view to where it is going.
|
|
88
|
+
- Inside the desktop client, the window's own shortcuts work while the editor has focus: Ctrl/Cmd+K opens the command palette, Ctrl/Cmd+N starts a new task and Ctrl/Cmd+, opens Settings (each saves the graph draft first when it leaves the editor).
|
|
87
89
|
- Ctrl-click (Cmd-click on macOS) matching node types to select several nodes. Under Output Node, select their shared outcome and use Route all N to, then click the destination.
|
|
88
90
|
|
|
89
91
|
Schema versions 1/2 remain executable with their original semantics; opening them in the editor adds an Orchestrator before the existing entry, and saving creates a version 3+ revision without rewriting history.
|
|
90
92
|
|
|
93
|
+
## Graph Manager
|
|
94
|
+
|
|
95
|
+
Graph Manager is an assistant that sits beside the graph you have open and builds or changes it with you. It is the same graph-design skill an agent uses in a regular task, placed next to the canvas.
|
|
96
|
+
|
|
97
|
+
- **Opening it.** A **Graph Manager** button is in the toolbar, beside **Save Revision**, whenever a graph is open. Click it to open a chat panel on the right; the canvas narrows to make room. Drag the panel's left edge to resize it. The first time you create a new graph, a tip beside the button reminds you it is there; close the tip or open the panel and it does not come back.
|
|
98
|
+
- **Choosing a provider and model.** The two selects at the top of the panel choose the provider and model Graph Manager itself runs on. They start on your last choice, or on the model of the graph's first agent. Graph Manager also uses that model for new agent nodes unless you ask for another. A change applies from your next message.
|
|
99
|
+
- **What it sees.** Every message carries the open graph's name and id and the canvas exactly as it is on your screen, including edits you have not saved. You can change something by hand and ask about it straight away. A very large graph cannot be sent; the panel says so and nothing is started.
|
|
100
|
+
- **Approvals.** Graph Manager asks before anything lasting happens. Publishing a revision, deleting a graph and restoring a graph each show a card with **Approve** and **Deny**, and nothing is saved until you approve. It does not connect your MCP servers. **Stop** ends what it is doing.
|
|
101
|
+
- **When it saves.** If the canvas has not changed since your message, the new revision opens in place. If you edited the canvas in the meantime, or the message came from another window, a bar asks "Graph Manager saved revision N. Load it?" and your edits stay until you click **Load**. Nothing on the canvas is replaced without that click.
|
|
102
|
+
- **The bundled preset.** The built-in default graph cannot be changed, so there Graph Manager creates a new graph based on what you see and a bar offers to open it: "Graph Manager created <name>. Open it?". The preset stays open until you click **Open**; the conversation then continues on the new graph.
|
|
103
|
+
- **Conversations.** One conversation is shared by every window of the same editor, and a reload brings it back. **New Chat** starts a fresh one. Opening another graph offers to start a new chat about it and keeps the current one until you agree.
|
|
104
|
+
- **Where it runs.** Graph Manager works in a folder of its own, `<home>/graph-manager/workspace` (`<home>` is `~/.andorracode`, or `ANDORRACODE_HOME`). Its sessions are named `Graph Manager: <graph name>` and are filed under that folder, so they stay out of your projects' task lists. It runs on a separate engine that stops with the editor, and after ten minutes with the panel closed and nothing pending, so a task you have running elsewhere is not held up.
|
|
105
|
+
|
|
91
106
|
## Cloud backup and draft recovery
|
|
92
107
|
|
|
93
108
|
For paid accounts, the graph builder saves revisions and drafts locally, then automatically synchronizes them to your Andorra account. The sidebar reports cloud status separately from local save success; connection failures retain the local queue and retry every 30 seconds while the builder is open. Open the Graph Builder to refresh cloud graphs on another installation; in the desktop app, opening a task's graph list does the same, so a graph saved on another machine is listed there without opening the builder first.
|
|
@@ -25,7 +25,8 @@ Slash commands run inside the interactive TUI. Type `/` as the first character t
|
|
|
25
25
|
| `/yolo <on\|off>` | Turn session-wide Full Access (host files and network) on or off. Never persisted. Without an argument it reports the current state and changes nothing. |
|
|
26
26
|
| `/tools` | List available coding tools and the approval policy. |
|
|
27
27
|
| `/skills` | List, install, enable, disable or remove skills. See [Extensions](../guides/extensions.md). |
|
|
28
|
-
| `/<skillname> [args]` | Apply an enabled imported skill; qualify duplicate names by catalog ID. |
|
|
28
|
+
| `/<skillname> [args]` | Apply an enabled imported skill; qualify duplicate names by catalog ID. The skill stays active for every later message in the session until you pause it, remove it, or invoke another skill (which replaces it). In the desktop app the Plan card shows it with Pause, Resume and Remove. |
|
|
29
|
+
| `/skill [on\|off\|remove]` | Show the session's active skill, pause it (`off`), resume it (`on`) or end it (`remove`). Changes apply from the next message. `/clear` also ends it. A skill named `skill` stays reachable as `/skill::skill`. |
|
|
29
30
|
| `/plugins` | List, install, enable, disable or remove plugins. See [Extensions](../guides/extensions.md). |
|
|
30
31
|
| `/mcp` | Add, edit, enable, disable or delete MCP servers. See [Extensions](../guides/extensions.md). |
|
|
31
32
|
| `/logout` | Sign out of your Andorra account on this machine (same as `/auth logout`). Run `/login` afterwards to sign in, or to switch to another account. |
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Graph Manager Chat Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** A Graph Manager button, first-graph tip and side chat in Graph Studio that runs the `andorra:graph-manager` skill on a dedicated engine, with the open graph's canvas as context.
|
|
6
|
+
|
|
7
|
+
**Architecture:** The graph server (`src/graph-server.ts`) lazily owns a `GraphManagerChat` (`src/graph-manager-chat.ts`) that spawns `andorra app-server --stdio` (pattern: `src/automation-runner.ts`) and relays one session over new `/api/manager/*` routes and a server-sent-events stream. Graph Studio (`src/graph-ui/`) gets a pure logic module (`manager-state.js`, testable in `node:vm`) and a DOM module (`manager.js` + `manager.css`). The run uses a hidden built-in single-agent graph so the agent holds the `graphs` tool and no Orchestrator intake runs.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** TypeScript (Node, ESM), plain browser JS without a bundler, `node:test`.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Works identically in the desktop iframe and a browser tab; no desktop (`desktop/`) code changes.
|
|
16
|
+
- Run permissions are fixed: `runPermissions: "ask-for-approval"`.
|
|
17
|
+
- Chat workspace: `<config directory>/graph-manager/workspace`, created on first use.
|
|
18
|
+
- Session name: `Graph Manager: <graph name>`, pinned (create with `sessions.create { name }`, which the engine records; then keep it with `sessions.rename` so `renamed: true` blocks automatic titling).
|
|
19
|
+
- Idle engine stop: 10 minutes (`600_000` ms) with no stream client, and only while no run is working and nothing is pending.
|
|
20
|
+
- Tip storage key: `andorra.graphManager.tipDismissed` (`localStorage`); last model key: `andorra.graphManager.model`.
|
|
21
|
+
- Tip copy: "Let Graph Manager build this graph with you."
|
|
22
|
+
- Load bar copy: "Graph Manager saved revision N. Load it?"
|
|
23
|
+
- Graph-switch copy: "Start a new chat about <name>?"
|
|
24
|
+
- All `/api/manager/*` routes sit behind the existing bearer-token and session checks; the stream also accepts `?token=` like `/api/activity/stream`.
|
|
25
|
+
- Bind only ephemeral ports in tests (`listen(0)`); every spawned child and timer is stopped by `close()`.
|
|
26
|
+
- Repository rules (AGENTS.md): QA plan at `tests/graph-manager-chat-test-plan.md`; do not run whole suites; run the targeted test files below via `node scripts/run-tests.mjs dist/test/<file>.test.js` after `npm run build`.
|
|
27
|
+
|
|
28
|
+
## Review Focus
|
|
29
|
+
|
|
30
|
+
1. **Engine exits mid-chat (crash, killed, update):** the panel shows an error state and the next message starts a fresh engine and session instead of hanging. → Task 2 test `restarts the engine after it exits`.
|
|
31
|
+
2. **The graph server closes while a run or approval is pending:** the child is cancelled and killed; no orphan process. → Task 3 test `close stops the chat engine`.
|
|
32
|
+
3. **The user keeps editing while the agent works:** the agent's revision never replaces those edits without the Load click. → Task 4 test `offers instead of loading when the canvas changed`.
|
|
33
|
+
4. **A canvas larger than the request body limit:** refused with a readable message, never truncated. → Task 3 test `refuses an oversized canvas`.
|
|
34
|
+
5. **Two panels (desktop + browser) on one server:** both receive the same events; the second connection gets a `snapshot` first. → Task 3 test `a second stream client receives the snapshot`.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### Task 1: Hidden built-in Graph Manager graph
|
|
39
|
+
|
|
40
|
+
**Files:**
|
|
41
|
+
- Modify: `src/graphs.ts` (next to `DEFAULT_HARNESS`, `loadGraph` at ~876, `listGraphs` ~891, `saveGraph` ~903, `deleteGraph`)
|
|
42
|
+
- Test: `test/graph-manager-harness.test.ts`
|
|
43
|
+
|
|
44
|
+
**Interfaces:**
|
|
45
|
+
- Produces: `export const GRAPH_MANAGER_GRAPH_ID = 'andorra-graph-manager'`; `export const GRAPH_MANAGER_HARNESS: Graph` (schemaVersion 3, one agent node `manager` named "Graph Manager", `executor: 'react-basic'`, edge `completed` → end node `done`); `loadGraph(GRAPH_MANAGER_GRAPH_ID)` returns a clone of it.
|
|
46
|
+
- The `manager` node's `instruction`: "You are Graph Manager inside Graph Studio. Before acting, load the bundled skill andorra:graph-manager with read_skill_resource and follow it. Work only through the graphs tool; never write graph files. Reply to the user in the conversation and ask with ask_user when a choice is theirs." Its tool and permission fields copy the default harness's engineer node so `graphs`, `read_skill_resource` and `ask_user` are available.
|
|
47
|
+
|
|
48
|
+
- [ ] **Step 1: Write the failing tests** — `loads the hidden graph manager graph` (`loadGraph(GRAPH_MANAGER_GRAPH_ID, undefined, tmp)` has `entry === 'manager'` and `nodes.manager.type === 'agent'`); `does not list it` (`listGraphs(tmp)` ids exclude it, both with and without a `graphs/` folder); `refuses to save or delete over it` (`saveGraph({...GRAPH_MANAGER_HARNESS}, null, tmp)` and `deleteGraph(GRAPH_MANAGER_GRAPH_ID, …)` reject with a message containing "reserved").
|
|
49
|
+
- [ ] **Step 2:** `npm run build && node scripts/run-tests.mjs dist/test/graph-manager-harness.test.js` → FAIL (export missing).
|
|
50
|
+
- [ ] **Step 3: Implement** the constant, the `loadGraph` branch (before the filesystem read, like `'default'`), the `listGraphs` filter, and the reserved-id refusals.
|
|
51
|
+
- [ ] **Step 4:** Re-run → PASS. Also run `dist/test/graph-tool.test.js` and `dist/test/graph-selection.test.js` → same results as on `main`.
|
|
52
|
+
- [ ] **Step 5: Commit** `feat(graphs): hidden built-in Graph Manager graph`.
|
|
53
|
+
|
|
54
|
+
### Task 2: Engine-backed chat (`GraphManagerChat`)
|
|
55
|
+
|
|
56
|
+
**Files:**
|
|
57
|
+
- Create: `src/graph-manager-chat.ts`
|
|
58
|
+
- Test: `test/graph-manager-chat.test.ts`
|
|
59
|
+
|
|
60
|
+
**Interfaces:**
|
|
61
|
+
- Consumes: `GRAPH_MANAGER_GRAPH_ID` (Task 1); `describeTool(name, args)` from `src/transcript.ts`; `stopAutomationWorker(child, closed)` from `src/automation-worker-shutdown.js` for shutdown.
|
|
62
|
+
- Produces:
|
|
63
|
+
```ts
|
|
64
|
+
export interface ManagerGraphContext { graph: Record<string, unknown>; saved: boolean; revision?: number }
|
|
65
|
+
export interface ManagerTurn extends ManagerGraphContext { provider: string; model: string; text: string }
|
|
66
|
+
export type ManagerEvent =
|
|
67
|
+
| { type: 'snapshot'; events: ManagerEvent[]; state: ManagerState }
|
|
68
|
+
| { type: 'user'; text: string }
|
|
69
|
+
| { type: 'assistant'; text: string }
|
|
70
|
+
| { type: 'tool'; text: string; failed?: boolean }
|
|
71
|
+
| { type: 'approval'; id: string; text: string }
|
|
72
|
+
| { type: 'question'; id: string; question: string; choices?: string[] }
|
|
73
|
+
| { type: 'resolved'; id: string }
|
|
74
|
+
| { type: 'state'; state: ManagerState }
|
|
75
|
+
| { type: 'error'; message: string }
|
|
76
|
+
| { type: 'graph.saved'; graphId: string; revision: number };
|
|
77
|
+
export type ManagerState = 'idle' | 'starting' | 'working' | 'awaiting';
|
|
78
|
+
export interface EngineChild { stdin: Writable; stdout: Readable; stderr: Readable; once(event: 'close', fn: (code: number | null) => void): unknown; on(event: 'error', fn: (e: Error) => void): unknown; kill(): boolean }
|
|
79
|
+
export interface GraphManagerChatOptions {
|
|
80
|
+
directory: string; // config directory (ANDORRACODE_HOME)
|
|
81
|
+
spawnEngine?: (cwd: string) => EngineChild; // default: spawn(process.execPath, [cli, 'app-server', '--stdio'], { cwd, env: { ...process.env, ANDORRACODE_HOME: directory }, windowsHide: true })
|
|
82
|
+
readRevision: (graphId: string) => Promise<number | undefined>;
|
|
83
|
+
idleMs?: number; // default 600_000
|
|
84
|
+
}
|
|
85
|
+
export function managerTask(turn: ManagerTurn): string;
|
|
86
|
+
export class GraphManagerChat {
|
|
87
|
+
constructor(options: GraphManagerChatOptions);
|
|
88
|
+
subscribe(listener: (event: ManagerEvent) => void): () => void; // first call delivers a snapshot
|
|
89
|
+
send(turn: ManagerTurn): Promise<void>; // start, continue, or steer
|
|
90
|
+
approve(id: string, approved: boolean): Promise<void>;
|
|
91
|
+
answer(id: string, value: string): Promise<void>;
|
|
92
|
+
cancel(): Promise<void>;
|
|
93
|
+
reset(): Promise<void>; // forget sessionId and transcript; engine stays
|
|
94
|
+
close(): Promise<void>; // cancel run, stop child, clear timers
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
- `managerTask` text, exactly:
|
|
98
|
+
```
|
|
99
|
+
You are helping in Graph Studio. Open graph: "<name>", id <id> (saved revision <N> | not saved yet).
|
|
100
|
+
The canvas below is what the user sees now, including edits not yet saved. Work from it, and save your changes under this same graph id (mode "create" when it is not saved yet, "edit" otherwise).
|
|
101
|
+
Selected model: <provider>/<model>. Use it for new agent nodes unless the user asks otherwise.
|
|
102
|
+
|
|
103
|
+
Canvas:
|
|
104
|
+
```json
|
|
105
|
+
<JSON.stringify(graph, null, 2)>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
User message:
|
|
109
|
+
<text>
|
|
110
|
+
```
|
|
111
|
+
- Protocol (same framing as `automation-runner.ts`: one JSON object per line, `{ id, method, params }` out; `{ id, result | error }` and `{ event, data }` in). On `ready`: require capability `run.start.runPermissions`, else emit `error` "Update Andorra to use Graph Manager." First `send`: `sessions.create { workspace, name }` then `sessions.rename { id, name }`, then `run.start { workspace, sessionId, task, provider, model, graph: GRAPH_MANAGER_GRAPH_ID, runPermissions: 'ask-for-approval' }`. Later `send` while idle: `run.start` with the same `sessionId` and `continueSession: true`; while working: `run.steer { sessionId, text: managerTask(turn) }`.
|
|
112
|
+
- Event mapping: `run.event` with `agent.message` → `assistant`; `node.tool.started` → `tool` (`describeTool`); `node.tool.failed` → `tool` with `failed: true`; `node.tool.completed` with `name === 'graphs'` → `readRevision(current graph id)` and emit `graph.saved` when it is higher than the last known revision; `run.approval` → `approval` (`describeTool(name, arguments)`); `run.question` → `question`; `run.state` `awaiting-*` → `awaiting`; `run.completed`/`run.failed` → `state idle` (+ `error` with the failure message).
|
|
113
|
+
- The transcript kept for snapshots holds every non-snapshot event, cleared by `reset()`.
|
|
114
|
+
|
|
115
|
+
- [ ] **Step 1: Write the failing tests** with a fake `EngineChild` (two `PassThrough` streams; the test reads lines the chat writes and writes engine lines back):
|
|
116
|
+
- `managerTask includes name, id, revision state, model, canvas and message` (saved and unsaved variants).
|
|
117
|
+
- `first send creates a named session and starts the hidden graph` — asserts methods in order `sessions.create`, `sessions.rename`, `run.start` and the `run.start` params above.
|
|
118
|
+
- `a send while working steers; a send while idle continues the session`.
|
|
119
|
+
- `maps engine events to panel events` — feeds `agent.message`, `node.tool.started`, `run.approval`, `run.question`, `run.completed`; asserts the emitted `ManagerEvent`s.
|
|
120
|
+
- `emits graph.saved only when the revision rises` (`readRevision` stub returns 1, then 2).
|
|
121
|
+
- `restarts the engine after it exits` — fake child closes; the next `send` spawns a second child and creates a new session; the panel got `error` and `state idle`.
|
|
122
|
+
- `stops the idle engine only when nothing is pending` — `idleMs: 20`; with a pending approval the child is not killed; after `run.completed` and no subscribers it is.
|
|
123
|
+
- `close cancels and stops the child`.
|
|
124
|
+
- [ ] **Step 2:** Build, run `dist/test/graph-manager-chat.test.js` → FAIL.
|
|
125
|
+
- [ ] **Step 3: Implement** `src/graph-manager-chat.ts` to the interface above. The workspace folder is created with `mkdir(join(directory, 'graph-manager', 'workspace'), { recursive: true })` before the first spawn.
|
|
126
|
+
- [ ] **Step 4:** Re-run → PASS.
|
|
127
|
+
- [ ] **Step 5: Commit** `feat(graph-manager): engine-backed chat session`.
|
|
128
|
+
|
|
129
|
+
### Task 3: Graph server routes
|
|
130
|
+
|
|
131
|
+
**Files:**
|
|
132
|
+
- Modify: `src/graph-server.ts` (`startGraphServer` options, `/api/` router, stream token check ~line 150, `close()` ~line 375, asset map)
|
|
133
|
+
- Test: `test/graph-manager-routes.test.ts` (setup copied from `test/graph-server.test.ts`: temp home, `startGraphServer(dir, async () => {}, { … })`, `t.after` close)
|
|
134
|
+
|
|
135
|
+
**Interfaces:**
|
|
136
|
+
- Consumes: `GraphManagerChat`, `ManagerTurn`, `ManagerEvent` (Task 2).
|
|
137
|
+
- Produces: `startGraphServer(..., options: { …existing, managerChat?: (directory: string) => Pick<GraphManagerChat, 'subscribe'|'send'|'approve'|'answer'|'cancel'|'reset'|'close'> })`; default factory builds `GraphManagerChat` with `readRevision: id => loadGraph(id, undefined, graphDirectory).then(g => g.revision, () => undefined)`. Created lazily on the first `/api/manager/*` request.
|
|
138
|
+
- Routes (JSON bodies; replies `{ ok: true }` unless noted):
|
|
139
|
+
- `POST /api/manager/message` `{ provider, model, text, graph, saved, revision? }` → `send`. Validation: non-empty strings for provider, model, text; `graph` an object with string `id` and `name`. 400 on failure.
|
|
140
|
+
- `POST /api/manager/approve` `{ id, approved }`, `POST /api/manager/answer` `{ id, value }`, `POST /api/manager/cancel`, `POST /api/manager/reset`.
|
|
141
|
+
- `GET /api/manager/stream` → `text/event-stream`; each `ManagerEvent` as `data: <json>\n\n`; `: ping` every 15 s; unsubscribes on close.
|
|
142
|
+
- Requests to the manager routes count as their own body-size budget: reuse the server's existing body reader and limit; a body over it gets 413 `{ error: 'This graph is too large to send to Graph Manager.' }`.
|
|
143
|
+
|
|
144
|
+
- [ ] **Step 1: Write the failing tests** using a fake `managerChat` that records calls and lets the test push events:
|
|
145
|
+
- `forwards a message with the canvas`; `rejects a message without a graph` (400).
|
|
146
|
+
- `stream requires the token` (401 without, 200 with `?token=`).
|
|
147
|
+
- `a second stream client receives the snapshot` (fake `subscribe` delivers a snapshot first; both clients then get a pushed event).
|
|
148
|
+
- `refuses an oversized canvas` (413 and the copy above).
|
|
149
|
+
- `close stops the chat engine` (fake `close` called once by server `close()`).
|
|
150
|
+
- `serves manager.js, manager-state.js and manager.css`.
|
|
151
|
+
- [ ] **Step 2:** Build, run `dist/test/graph-manager-routes.test.js` → FAIL.
|
|
152
|
+
- [ ] **Step 3: Implement** the option, routes, stream, `close()` hook and the three asset entries.
|
|
153
|
+
- [ ] **Step 4:** Re-run → PASS; also run `dist/test/graph-server.test.js` and `dist/test/graph-studio-editor-api.test.js` → same as `main`.
|
|
154
|
+
- [ ] **Step 5: Commit** `feat(graph-server): Graph Manager chat routes`.
|
|
155
|
+
|
|
156
|
+
### Task 4: Editor logic (`manager-state.js`)
|
|
157
|
+
|
|
158
|
+
**Files:**
|
|
159
|
+
- Create: `src/graph-ui/manager-state.js` (assigns `globalThis.AndorraManagerState`; no DOM access)
|
|
160
|
+
- Test: `test/graph-ui-manager-state.test.ts` (loads the file with `node:vm` like `test/graph-ui-sidebar.test.ts`)
|
|
161
|
+
|
|
162
|
+
**Interfaces:**
|
|
163
|
+
- Produces on `globalThis.AndorraManagerState`:
|
|
164
|
+
- `shouldShowTip(storage, reason) → boolean` — `reason` is `'new' | 'duplicate' | 'import' | 'open'`; true only for `'new'` when the storage key is unset; storage read errors count as unset.
|
|
165
|
+
- `dismissTip(storage) → void` (swallows storage errors).
|
|
166
|
+
- `initialModel(storage, graph, providers) → { provider, model } | undefined` — saved choice if that provider/model is still listed, else the graph's first agent node's `provider`/`model`, else the first provider's default model.
|
|
167
|
+
- `applyDecision({ sentCanvas, currentCanvas, untouched }) → 'load' | 'offer'` — `'load'` when `currentCanvas === sentCanvas` or `currentCanvas === untouched` (all JSON strings), else `'offer'`.
|
|
168
|
+
- `reduce(transcript, event) → transcript` — appends events; `snapshot` replaces; `resolved` marks the matching approval/question answered.
|
|
169
|
+
|
|
170
|
+
- [ ] **Step 1: Write the failing tests** — `shows the tip only after New graph, once`; `tip survives blocked storage`; `initial model prefers the saved choice, then the graph, then the provider default`; `loads when the canvas is unchanged or untouched`; `offers instead of loading when the canvas changed`; `snapshot replaces the transcript and resolved closes a card`.
|
|
171
|
+
- [ ] **Step 2:** Build, run `dist/test/graph-ui-manager-state.test.js` → FAIL.
|
|
172
|
+
- [ ] **Step 3: Implement** `manager-state.js`.
|
|
173
|
+
- [ ] **Step 4:** Re-run → PASS.
|
|
174
|
+
- [ ] **Step 5: Commit** `feat(graph-ui): Graph Manager panel logic`.
|
|
175
|
+
|
|
176
|
+
### Task 5: Editor UI (button, tip, panel)
|
|
177
|
+
|
|
178
|
+
**Files:**
|
|
179
|
+
- Create: `src/graph-ui/manager.js`, `src/graph-ui/manager.css`
|
|
180
|
+
- Modify: `src/graph-ui/index.html` (button in `#chrome-actions` before `#save`; `<aside id="manager-panel" hidden>` after `#inspector` inside `.workspace`; stylesheet and `defer` scripts `manager-state.js` then `manager.js` after `app.js`), `src/graph-ui/app.js` (`newGraph` and `openGraph` call `globalThis.AndorraManager?.graphOpened(reason)`; expose `globalThis.AndorraStudio = { currentGraph: () => state.graph, isSaved, revision, untouched: () => state.untouched, reopen: id => openGraph(id) }` if no equivalent exists), `scripts/ci-local-groups.mjs` (add the four new test files to the groups that list graph-ui and graph-server tests)
|
|
181
|
+
- Test: `test/graph-ui-manager.test.ts` (static checks on `index.html` and `manager.js` like `test/graph-studio-editor-api.test.ts`)
|
|
182
|
+
|
|
183
|
+
**Interfaces:**
|
|
184
|
+
- Consumes: Task 3 routes; Task 4 functions; `api(path, body)`, `status(message, error)` from `app.js`; `ProviderModelPicker`-equivalent data from `/api/provider-models` already loaded into `state.providers`.
|
|
185
|
+
- Behaviour: button `#graph-manager` (label "Graph Manager", hidden when `state.graph` is null); tip popover anchored to it with a close button (`aria-label="Dismiss"`); panel header with provider and model `<select>`s and New chat; transcript (assistant text through the existing Markdown-safe renderer, tool lines, approval cards with Approve/Deny, question cards with choices or a text box); footer textarea with Send (Enter) and Stop. Opening the panel or closing the tip calls `dismissTip`. One `EventSource('/api/manager/stream?token=…')` while the panel is open, reconnecting with the snapshot. Each send posts the current canvas (`JSON.stringify(state.graph)`) and stores it as `sentCanvas`. On `graph.saved` for the open graph id, `applyDecision` → `reopen(id)` or the Load bar. Switching graphs with a non-empty transcript shows the graph-switch prompt; agreeing calls `/api/manager/reset`. Styling uses `studio.css` tokens; the panel narrows the canvas (it is a flex sibling, like `#inspector`).
|
|
186
|
+
|
|
187
|
+
- [ ] **Step 1: Write the failing tests** — `index.html has the Graph Manager button and panel and loads both scripts in order`; `manager.js posts the canvas with each message`; `manager.js never assigns innerHTML from engine text` (assert the file has no `innerHTML =` on transcript paths, using the same check style other graph-ui tests use).
|
|
188
|
+
- [ ] **Step 2:** Build, run `dist/test/graph-ui-manager.test.js` → FAIL.
|
|
189
|
+
- [ ] **Step 3: Implement** the files and hooks above.
|
|
190
|
+
- [ ] **Step 4:** Re-run → PASS; also run `dist/test/graph-ui.test.js`, `dist/test/graph-ui-modern.test.js` and `node --test scripts/ci-local.test.mjs` → same as `main`.
|
|
191
|
+
- [ ] **Step 5: Commit** `feat(graph-ui): Graph Manager button, tip and chat panel`.
|
|
192
|
+
|
|
193
|
+
### Task 6: Run verification, QA plan, docs, PR
|
|
194
|
+
|
|
195
|
+
**Files:**
|
|
196
|
+
- Create: `tests/graph-manager-chat-test-plan.md`
|
|
197
|
+
- Modify: `docs/guides/graph-builder.md` (a "Graph Manager" section: button, tip, what the agent sees, approvals)
|
|
198
|
+
|
|
199
|
+
- [ ] **Step 1: Run it in a browser.** `npm run build`, then `node dist/src/cli.js graph` (real signed-in home, per the user's live-testing practice) and open the printed URL in the built-in browser. Check: New graph shows the tip once; Graph Manager opens the panel; choose a cheap model; ask "Add a review step after the agent that loops back on fail"; approve the publish card; the canvas loads the new revision. Edit the canvas during a second request and confirm the Load bar appears instead.
|
|
200
|
+
- [ ] **Step 2: Run it in the desktop path** by starting the graph server through `node dist/src/cli.js app-server --stdio` (the engine's editor command) and opening its URL in the built-in browser, or the dev desktop if available; confirm the same panel loads inside the iframe CSP.
|
|
201
|
+
- [ ] **Step 3: Leave no state.** Close the editor; `tasklist`/`ps` shows no leftover `app-server --stdio` child from the graph server; `git status --short` shows only intended changes.
|
|
202
|
+
- [ ] **Step 4: Write the QA plan** covering the cases above, the Review Focus items, and gaps (desktop iframe verified only as described in Step 2).
|
|
203
|
+
- [ ] **Step 5: Commit, push (`GH_TOKEN=$(gh auth token -u mchang-andorra)`), open a ready PR to `main`** with `.github/PULL_REQUEST_TEMPLATE.md`, Validation listing exactly what ran.
|