@andorra-labs/code 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -205
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/src/agent-execution.js +50 -2
- package/dist/src/agent-mcp.js +5 -0
- package/dist/src/app-server/protocol.d.ts +9 -1
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server.d.ts +49 -1
- package/dist/src/app-server.js +353 -64
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-panel-tool.d.ts +24 -3
- package/dist/src/browser-panel-tool.js +80 -6
- package/dist/src/browser-runner.js +3 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +38 -2
- package/dist/src/claude-provider.js +15 -2
- package/dist/src/cli.d.ts +2 -1
- package/dist/src/cli.js +175 -43
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +1 -1
- package/dist/src/codex-provider.js +6 -3
- package/dist/src/coding-tools.d.ts +26 -1
- package/dist/src/coding-tools.js +104 -33
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +51 -1
- package/dist/src/completion.js +164 -5
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +2 -0
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/delegation-changes.js +19 -2
- package/dist/src/diff-preview.d.ts +1 -0
- package/dist/src/diff-preview.js +12 -3
- package/dist/src/engine-streams.d.ts +22 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.js +17 -6
- package/dist/src/file-read-key.d.ts +8 -0
- package/dist/src/file-read-key.js +12 -0
- package/dist/src/graph-editor-session.js +2 -1
- package/dist/src/graph-health.d.ts +21 -0
- package/dist/src/graph-health.js +46 -0
- package/dist/src/graph-manager-chat.d.ts +52 -3
- package/dist/src/graph-manager-chat.js +62 -17
- package/dist/src/graph-runner.js +62 -5
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +48 -27
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +362 -123
- package/dist/src/graph-ui/controls.css +95 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +7 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/manager-state.js +143 -5
- package/dist/src/graph-ui/manager.css +21 -20
- package/dist/src/graph-ui/manager.js +337 -75
- package/dist/src/graph-ui/model-picker.js +279 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +5 -2
- package/dist/src/graphs.js +10 -9
- package/dist/src/mcp.d.ts +52 -14
- package/dist/src/mcp.js +285 -128
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/memory/ProjectMemory.d.ts +77 -0
- package/dist/src/memory/ProjectMemory.js +310 -0
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- package/dist/src/opencode-provider.js +5 -6
- package/dist/src/package-name.d.ts +3 -0
- package/dist/src/package-name.js +3 -0
- package/dist/src/provider-engine.js +2 -2
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/runtime/PtyManager.js +2 -1
- package/dist/src/react-runtime.js +137 -22
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/remote/cert.d.ts +1 -1
- package/dist/src/remote/cert.js +2 -7
- package/dist/src/remote/client.js +1 -1
- package/dist/src/remote/pem.d.ts +6 -0
- package/dist/src/remote/pem.js +11 -0
- package/dist/src/run-records.js +49 -10
- package/dist/src/runtime.d.ts +21 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/sessions.d.ts +3 -1
- package/dist/src/sessions.js +5 -3
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/sign-in-detection.d.ts +82 -0
- package/dist/src/sign-in-detection.js +197 -0
- package/dist/src/sign-in-offer.d.ts +35 -0
- package/dist/src/sign-in-offer.js +116 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +59 -7
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.d.ts +6 -0
- package/dist/src/skills/runtime-skills.js +16 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/stray-files.d.ts +14 -0
- package/dist/src/stray-files.js +81 -0
- package/dist/src/subagent-run.js +6 -1
- package/dist/src/terminal-ui.d.ts +1 -1
- package/dist/src/terminal-ui.js +11 -5
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-activity.js +1 -1
- package/dist/src/tool-schema-compatibility.d.ts +7 -2
- package/dist/src/tool-schema-compatibility.js +8 -4
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.d.ts +5 -0
- package/dist/src/transcript.js +12 -4
- package/dist/src/types.d.ts +8 -0
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +125 -0
- package/dist/src/update-check.js +1 -1
- package/dist/src/update.d.ts +11 -1
- package/dist/src/update.js +27 -5
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/dist/src/workspace-git-metadata.d.ts +15 -0
- package/dist/src/workspace-git-metadata.js +50 -1
- package/dist/src/workspace-instructions.js +1 -1
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -79,9 +79,12 @@ export type ManagerEvent = {
|
|
|
79
79
|
} | {
|
|
80
80
|
type: 'state';
|
|
81
81
|
state: ManagerState;
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
|
+
/** `warning` marks a report that refused nothing: the message it follows was delivered. */
|
|
84
|
+
| {
|
|
83
85
|
type: 'error';
|
|
84
86
|
message: string;
|
|
87
|
+
warning?: true;
|
|
85
88
|
} | {
|
|
86
89
|
type: 'graph.saved';
|
|
87
90
|
graphId: string;
|
|
@@ -92,6 +95,36 @@ export type ManagerEvent = {
|
|
|
92
95
|
| {
|
|
93
96
|
type: 'graph.deleted';
|
|
94
97
|
graphId: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* One change the agent made to its draft of a graph, for the canvas to show as it happens. It is
|
|
101
|
+
* not a save: the draft is saved only by a publish, which asks the user first. Sent live and never
|
|
102
|
+
* kept in the transcript, so a panel that connects later is not handed edits to apply twice.
|
|
103
|
+
*/
|
|
104
|
+
| {
|
|
105
|
+
type: 'graph.edit';
|
|
106
|
+
graphId: string;
|
|
107
|
+
edit: ManagerGraphEdit;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A draft change in the canvas's own terms: a node or connection set to what the draft now holds
|
|
111
|
+
* (placement and generated ids included), one removed, or graph fields replaced.
|
|
112
|
+
*/
|
|
113
|
+
export type ManagerGraphEdit = {
|
|
114
|
+
kind: 'node';
|
|
115
|
+
node: Record<string, unknown>;
|
|
116
|
+
} | {
|
|
117
|
+
kind: 'node.remove';
|
|
118
|
+
nodeId: string;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'edge';
|
|
121
|
+
edge: Record<string, unknown>;
|
|
122
|
+
} | {
|
|
123
|
+
kind: 'edge.remove';
|
|
124
|
+
edgeId: string;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'graph';
|
|
127
|
+
patch: Record<string, unknown>;
|
|
95
128
|
};
|
|
96
129
|
/** A graph's latest stored revision. Deleting a graph publishes one more, marked `metadata.deletedAt`. */
|
|
97
130
|
export interface ManagerGraphRevision {
|
|
@@ -112,6 +145,8 @@ export interface EngineChild {
|
|
|
112
145
|
export interface GraphManagerChatOptions {
|
|
113
146
|
/** The config directory (ANDORRACODE_HOME) the engine runs against. */
|
|
114
147
|
directory: string;
|
|
148
|
+
/** The empty folder the engine starts in. Default `managerWorkspace(directory)`. */
|
|
149
|
+
workspace?: string;
|
|
115
150
|
/** Starts the engine in `cwd`. The default spawns this build's `app-server --stdio`. */
|
|
116
151
|
spawnEngine?: (cwd: string) => EngineChild;
|
|
117
152
|
/** The latest stored revision of a graph and whether it is a deletion, or undefined when it has none. */
|
|
@@ -123,6 +158,12 @@ export interface GraphManagerChatOptions {
|
|
|
123
158
|
}
|
|
124
159
|
/** Mirrors `MAX_TASK_CHARS` in `app-server.ts`: the engine refuses a longer `run.start` task or `run.steer` text. */
|
|
125
160
|
export declare const MANAGER_TASK_MAX_CHARS = 100000;
|
|
161
|
+
/**
|
|
162
|
+
* The change a successful draft call made, read from its reply where the backend decided something
|
|
163
|
+
* (a new card's placement, a connection's generated id) and from its arguments otherwise. Undefined
|
|
164
|
+
* when the reply cannot be read, so the canvas is never shown a guess.
|
|
165
|
+
*/
|
|
166
|
+
export declare function draftEdit(action: string, args: Record<string, unknown>, output: unknown): ManagerGraphEdit | undefined;
|
|
126
167
|
/**
|
|
127
168
|
* One line saying what a tool call or an approval is about, for the tools Graph Manager works with:
|
|
128
169
|
* the `graphs` action and the graph it names, the skill being read, the server being connected.
|
|
@@ -157,6 +198,13 @@ export declare function managerToolParts(name: string, value: unknown, openGraph
|
|
|
157
198
|
* the scope the parent reads.
|
|
158
199
|
*/
|
|
159
200
|
export declare function managerEngineEnvironment(directory: string, environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
201
|
+
/**
|
|
202
|
+
* The empty folder Graph Manager's engine runs in: one per config home, outside it. The config home
|
|
203
|
+
* is protected runtime metadata, so a workspace inside it made every read the agent tried (a Grep, a
|
|
204
|
+
* Glob) ask the user for approval. Outside it, reads run freely in an empty folder and the only
|
|
205
|
+
* prompts left are the ones that change something: publishing, deleting or restoring a graph.
|
|
206
|
+
*/
|
|
207
|
+
export declare function managerWorkspace(directory: string): string;
|
|
160
208
|
/**
|
|
161
209
|
* What the agent is given with every message: which graph is open, the canvas as the user sees it
|
|
162
210
|
* now (unsaved edits included), the model the panel has selected, and the user's own words.
|
|
@@ -167,8 +215,9 @@ export declare function managerTask(turn: ManagerTurn): string;
|
|
|
167
215
|
*
|
|
168
216
|
* The engine that hosts Graph Studio may be busy with the user's task and runs one task at a time,
|
|
169
217
|
* so the chat spawns a dedicated `app-server --stdio` child in an empty workspace and speaks the
|
|
170
|
-
* same line protocol the automation runner does.
|
|
171
|
-
*
|
|
218
|
+
* same line protocol the automation runner does. The graph server keeps one chat per graph, and every
|
|
219
|
+
* panel open on that graph shares it: each subscriber is caught up with a snapshot and then receives
|
|
220
|
+
* the stream.
|
|
172
221
|
*
|
|
173
222
|
* Failures on the engine's side are reported as `error` events rather than rejections, because the
|
|
174
223
|
* message that failed is already on every panel's transcript and the stream is where panels listen.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
2
3
|
import { mkdir } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
3
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
4
6
|
import { createInterface } from 'node:readline';
|
|
5
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -15,14 +17,40 @@ const RESET_WAIT_MS = 10_000;
|
|
|
15
17
|
const ENDING_WAIT_MS = 30_000;
|
|
16
18
|
/** Mirrors `MAX_TASK_CHARS` in `app-server.ts`: the engine refuses a longer `run.start` task or `run.steer` text. */
|
|
17
19
|
export const MANAGER_TASK_MAX_CHARS = 100_000;
|
|
18
|
-
const UPDATE_MESSAGE = 'Update Andorra Code to use
|
|
19
|
-
const TOO_LARGE_MESSAGE = 'This
|
|
20
|
+
const UPDATE_MESSAGE = 'Update Andorra Code to use Graph Manager.';
|
|
21
|
+
const TOO_LARGE_MESSAGE = 'This graph is too large to send to Graph Manager.';
|
|
20
22
|
/** The longest tool or approval line the panel is given. */
|
|
21
23
|
const TOOL_LINE_MAX = 120;
|
|
22
24
|
/** How many draft-to-graph pairings are remembered; an agent holds a handful of drafts at most. */
|
|
23
25
|
const DRAFTS_MAX = 64;
|
|
24
26
|
/** The bundled preset every installation has. Nothing can be saved under its id. */
|
|
25
27
|
const BUNDLED_GRAPH_ID = 'default';
|
|
28
|
+
/** The draft actions that change what the canvas shows. */
|
|
29
|
+
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']);
|
|
30
|
+
/**
|
|
31
|
+
* The change a successful draft call made, read from its reply where the backend decided something
|
|
32
|
+
* (a new card's placement, a connection's generated id) and from its arguments otherwise. Undefined
|
|
33
|
+
* when the reply cannot be read, so the canvas is never shown a guess.
|
|
34
|
+
*/
|
|
35
|
+
export function draftEdit(action, args, output) {
|
|
36
|
+
let reply = {};
|
|
37
|
+
try {
|
|
38
|
+
reply = record(record(JSON.parse(String(output ?? ''))).data);
|
|
39
|
+
}
|
|
40
|
+
catch { /* A clipped reply has nothing to read. */ }
|
|
41
|
+
const node = record(reply.node), edge = record(reply.edge), patch = record(args.patch);
|
|
42
|
+
if (action === 'andorra_graph_node_upsert' || action === 'andorra_graph_node_patch')
|
|
43
|
+
return typeof node.id === 'string' ? { kind: 'node', node } : undefined;
|
|
44
|
+
if (action === 'andorra_graph_edge_upsert')
|
|
45
|
+
return typeof edge.id === 'string' && typeof edge.source === 'string' && typeof edge.target === 'string' ? { kind: 'edge', edge } : undefined;
|
|
46
|
+
if (action === 'andorra_graph_node_remove')
|
|
47
|
+
return typeof args.nodeId === 'string' && args.nodeId ? { kind: 'node.remove', nodeId: args.nodeId } : undefined;
|
|
48
|
+
if (action === 'andorra_graph_edge_remove')
|
|
49
|
+
return typeof args.edgeId === 'string' && args.edgeId ? { kind: 'edge.remove', edgeId: args.edgeId } : undefined;
|
|
50
|
+
if (action === 'andorra_graph_patch')
|
|
51
|
+
return Object.keys(patch).length ? { kind: 'graph', patch } : undefined;
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
26
54
|
/** The engine went away, deliberately or not; whoever stopped it has already said what there is to say. */
|
|
27
55
|
class EngineStopped extends Error {
|
|
28
56
|
}
|
|
@@ -71,11 +99,11 @@ export function describeManagerTool(name, value, graphOfDraft = () => undefined)
|
|
|
71
99
|
}
|
|
72
100
|
/** What each `graphs` action does, as the row's verb. An action not named here shows its own name. */
|
|
73
101
|
const GRAPH_ACTION_VERBS = {
|
|
74
|
-
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read
|
|
102
|
+
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read graph', andorra_graph_guide: 'Read guide',
|
|
75
103
|
andorra_graph_node_upsert: 'Set step', andorra_graph_node_patch: 'Edit step', andorra_graph_node_remove: 'Remove step',
|
|
76
|
-
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit
|
|
104
|
+
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit graph',
|
|
77
105
|
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save version', andorra_graph_discard: 'Discard draft',
|
|
78
|
-
andorra_graph_delete: 'Delete
|
|
106
|
+
andorra_graph_delete: 'Delete graph', andorra_graph_restore: 'Restore graph',
|
|
79
107
|
};
|
|
80
108
|
/**
|
|
81
109
|
* A tool call split the way the app's transcript draws it: the verb, and the thing it acted on.
|
|
@@ -118,7 +146,7 @@ export function managerToolParts(name, value, openGraphId) {
|
|
|
118
146
|
}
|
|
119
147
|
/** Bookkeeping calls the runtime handles itself; a conversation shows what the agent did, not these. */
|
|
120
148
|
const HIDDEN_TOOLS = new Set(['update_todos', 'update_widget', 'prepare_steps', 'restore_tools', 'complete_agent']);
|
|
121
|
-
const STOPPED_UNREAD_MESSAGE = '
|
|
149
|
+
const STOPPED_UNREAD_MESSAGE = 'Graph Manager was stopped before it read your last message. Send it again to continue.';
|
|
122
150
|
/**
|
|
123
151
|
* The environment the chat's engine starts in: the parent's own, so the engine is signed in as the
|
|
124
152
|
* parent is. Stored credentials are scoped to an explicitly named home (`credentialIdentity`), so
|
|
@@ -142,6 +170,15 @@ export function managerEngineEnvironment(directory, environment = process.env) {
|
|
|
142
170
|
return worker;
|
|
143
171
|
return { ...worker, ANDORRACODE_HOME: resolve(directory) };
|
|
144
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* The empty folder Graph Manager's engine runs in: one per config home, outside it. The config home
|
|
175
|
+
* is protected runtime metadata, so a workspace inside it made every read the agent tried (a Grep, a
|
|
176
|
+
* Glob) ask the user for approval. Outside it, reads run freely in an empty folder and the only
|
|
177
|
+
* prompts left are the ones that change something: publishing, deleting or restoring a graph.
|
|
178
|
+
*/
|
|
179
|
+
export function managerWorkspace(directory) {
|
|
180
|
+
return join(tmpdir(), 'andorra-graph-manager', createHash('sha256').update(resolve(directory)).digest('hex').slice(0, 16));
|
|
181
|
+
}
|
|
145
182
|
/**
|
|
146
183
|
* What the agent is given with every message: which graph is open, the canvas as the user sees it
|
|
147
184
|
* now (unsaved edits included), the model the panel has selected, and the user's own words.
|
|
@@ -170,8 +207,9 @@ export function managerTask(turn) {
|
|
|
170
207
|
*
|
|
171
208
|
* The engine that hosts Graph Studio may be busy with the user's task and runs one task at a time,
|
|
172
209
|
* so the chat spawns a dedicated `app-server --stdio` child in an empty workspace and speaks the
|
|
173
|
-
* same line protocol the automation runner does.
|
|
174
|
-
*
|
|
210
|
+
* same line protocol the automation runner does. The graph server keeps one chat per graph, and every
|
|
211
|
+
* panel open on that graph shares it: each subscriber is caught up with a snapshot and then receives
|
|
212
|
+
* the stream.
|
|
175
213
|
*
|
|
176
214
|
* Failures on the engine's side are reported as `error` events rather than rejections, because the
|
|
177
215
|
* message that failed is already on every panel's transcript and the stream is where panels listen.
|
|
@@ -224,7 +262,7 @@ export class GraphManagerChat {
|
|
|
224
262
|
this.options = options;
|
|
225
263
|
// Resolved now: the engine is started in another working directory.
|
|
226
264
|
this.directory = resolve(options.directory);
|
|
227
|
-
this.workspace =
|
|
265
|
+
this.workspace = resolve(options.workspace ?? managerWorkspace(this.directory));
|
|
228
266
|
this.idleMs = options.idleMs ?? 600_000;
|
|
229
267
|
this.now = options.now ?? Date.now;
|
|
230
268
|
}
|
|
@@ -349,7 +387,7 @@ export class GraphManagerChat {
|
|
|
349
387
|
try {
|
|
350
388
|
await this.request(engine, 'run.steer', { runId, sessionId: this.sessionId, text: task });
|
|
351
389
|
if (keptModel !== undefined)
|
|
352
|
-
this.emit({ type: 'error', message: `
|
|
390
|
+
this.emit({ type: 'error', message: `Graph Manager could not switch to ${turn.provider}/${turn.model}, so this run keeps its model: ${keptModel.reason}`, warning: true });
|
|
353
391
|
return;
|
|
354
392
|
}
|
|
355
393
|
catch (error) {
|
|
@@ -374,7 +412,7 @@ export class GraphManagerChat {
|
|
|
374
412
|
return;
|
|
375
413
|
}
|
|
376
414
|
if (!this.isIdle()) {
|
|
377
|
-
this.emit({ type: 'error', message: '
|
|
415
|
+
this.emit({ type: 'error', message: 'Graph Manager is still finishing its last run. Send your message again.' });
|
|
378
416
|
return;
|
|
379
417
|
}
|
|
380
418
|
}
|
|
@@ -473,11 +511,11 @@ export class GraphManagerChat {
|
|
|
473
511
|
try {
|
|
474
512
|
const engine = await this.ensureEngine();
|
|
475
513
|
if (this.sessionId === undefined) {
|
|
476
|
-
const title = `
|
|
514
|
+
const title = `Graph Manager: ${name}`.slice(0, 200);
|
|
477
515
|
const created = await this.request(engine, 'sessions.create', { workspace: this.workspace, name: title });
|
|
478
516
|
const id = record(created.session).id;
|
|
479
517
|
if (typeof id !== 'string')
|
|
480
|
-
throw new Error('
|
|
518
|
+
throw new Error('Graph Manager could not start its conversation.');
|
|
481
519
|
// The rename pins the name, so the engine's automatic titling leaves it alone.
|
|
482
520
|
await this.request(engine, 'sessions.rename', { id, name: title });
|
|
483
521
|
this.sessionId = id;
|
|
@@ -546,7 +584,7 @@ export class GraphManagerChat {
|
|
|
546
584
|
failReady(new Error(reason));
|
|
547
585
|
void this.stopEngine(engine);
|
|
548
586
|
};
|
|
549
|
-
const startup = setTimeout(() => refuse('
|
|
587
|
+
const startup = setTimeout(() => refuse('Graph Manager did not start within 60 seconds.'), STARTUP_MS);
|
|
550
588
|
startup.unref();
|
|
551
589
|
const gone = (detail) => {
|
|
552
590
|
if (engine.gone)
|
|
@@ -568,7 +606,7 @@ export class GraphManagerChat {
|
|
|
568
606
|
// message begins a new session on a new engine.
|
|
569
607
|
this.sessionId = undefined;
|
|
570
608
|
const tail = engine.stderr.trim().split('\n').at(-1)?.trim();
|
|
571
|
-
this.emit({ type: 'error', message: `
|
|
609
|
+
this.emit({ type: 'error', message: `Graph Manager stopped unexpectedly (${detail}). Send your message again to restart it.${tail ? `\n${tail}` : ''}` });
|
|
572
610
|
this.finish(this.runId);
|
|
573
611
|
};
|
|
574
612
|
child.stderr.on('data', chunk => { engine.stderr = (engine.stderr + String(chunk)).slice(-8_192); });
|
|
@@ -590,7 +628,7 @@ export class GraphManagerChat {
|
|
|
590
628
|
const waiter = engine.pending.get(message.id);
|
|
591
629
|
engine.pending.delete(message.id);
|
|
592
630
|
if (message.error)
|
|
593
|
-
waiter?.reject(new EngineRefusal(typeof message.error.message === 'string' ? message.error.message : '
|
|
631
|
+
waiter?.reject(new EngineRefusal(typeof message.error.message === 'string' ? message.error.message : 'Graph Manager refused the request.', typeof message.error.code === 'string' ? message.error.code : undefined));
|
|
594
632
|
else
|
|
595
633
|
waiter?.resolve(record(message.result));
|
|
596
634
|
return;
|
|
@@ -698,7 +736,9 @@ export class GraphManagerChat {
|
|
|
698
736
|
const begins = args.action === 'andorra_graph_begin' && typeof input.id === 'string' ? { id: input.id, ...(name ? { name } : {}) } : undefined;
|
|
699
737
|
const publishes = args.action === 'andorra_graph_publish' && typeof input.draftId === 'string' ? this.drafts.get(input.draftId) : undefined;
|
|
700
738
|
const removes = (args.action === 'andorra_graph_delete' || args.action === 'andorra_graph_restore') && typeof input.id === 'string' ? { id: input.id } : undefined;
|
|
701
|
-
|
|
739
|
+
const edited = DRAFT_EDIT_ACTIONS.has(String(args.action)) && typeof input.draftId === 'string' ? this.drafts.get(input.draftId) : undefined;
|
|
740
|
+
const edits = edited ? { graphId: edited.id, action: String(args.action), args: input } : undefined;
|
|
741
|
+
this.graphCalls.set(data.toolCallId, { line, ...(begins ? { begins } : {}), ...(publishes ? { publishes } : {}), ...(removes ? { removes } : {}), ...(edits ? { edits } : {}) });
|
|
702
742
|
}
|
|
703
743
|
}
|
|
704
744
|
else if (event.type === 'node.tool.failed') {
|
|
@@ -720,6 +760,11 @@ export class GraphManagerChat {
|
|
|
720
760
|
if (this.drafts.size > DRAFTS_MAX)
|
|
721
761
|
this.drafts.delete(this.drafts.keys().next().value);
|
|
722
762
|
}
|
|
763
|
+
if (call?.edits) {
|
|
764
|
+
const edit = draftEdit(call.edits.action, call.edits.args, data.output);
|
|
765
|
+
if (edit)
|
|
766
|
+
this.broadcast({ type: 'graph.edit', graphId: call.edits.graphId, edit });
|
|
767
|
+
}
|
|
723
768
|
this.checkRevision(call?.publishes ?? call?.removes);
|
|
724
769
|
}
|
|
725
770
|
}
|
package/dist/src/graph-runner.js
CHANGED
|
@@ -199,6 +199,23 @@ export async function runGraph(graph, options) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
const budget = createRuntimeBudget(options.context.signal, limits.wallTimeMs, options.context.runControl);
|
|
202
|
+
// A node is handed only the run's remaining time, so its own wall bound is a slice of the run's.
|
|
203
|
+
// When the run's clock is what ran out, the stop names the run's limit: a node that started with a
|
|
204
|
+
// minute left otherwise reports a two-hour run as having "run out of time after about 1 minute".
|
|
205
|
+
// Ownership is decided from what the node was handed when it STARTED, not from the bound its last
|
|
206
|
+
// inner invocation reports: the slice and the run's clock share one deadline, so either timer can
|
|
207
|
+
// be the one that notices, and a node with loop or copy modifiers hands each later pass only the
|
|
208
|
+
// time it has left, so its final slice is smaller than its own limit even when that limit expired.
|
|
209
|
+
const handedWallMs = new Map();
|
|
210
|
+
const runClockBounds = (bounds, reason, nodeId) => {
|
|
211
|
+
if (reason !== 'wallTimeMs')
|
|
212
|
+
return bounds;
|
|
213
|
+
const own = pinned.nodes[nodeId]?.limits?.wallTimeMs || undefined;
|
|
214
|
+
const handed = handedWallMs.get(nodeId);
|
|
215
|
+
if (own !== undefined && (handed === undefined || own <= handed))
|
|
216
|
+
return { ...bounds, wallTimeMs: own };
|
|
217
|
+
return limits.wallTimeMs ? { ...bounds, wallTimeMs: limits.wallTimeMs } : bounds;
|
|
218
|
+
};
|
|
202
219
|
const signal = budget.signal;
|
|
203
220
|
const confirmedClarifications = [];
|
|
204
221
|
// Bind before queueing: the queue must serialize the budget-aware `approve`, or a wait
|
|
@@ -247,12 +264,49 @@ export async function runGraph(graph, options) {
|
|
|
247
264
|
if (!(options.inheritedSkills ?? []).includes(skillId))
|
|
248
265
|
activeSkills.delete(skillId);
|
|
249
266
|
}
|
|
250
|
-
|
|
267
|
+
// A fresh run normally starts at the entry. A wake addressed to a node (an Auto-fix prompt goes to the node that
|
|
268
|
+
// switched Auto-fix on) starts at that node instead, when it is still an agent of this graph and can start with
|
|
269
|
+
// only what the run itself supplies: a node that needs its predecessor's handoff would fail its own input checks.
|
|
270
|
+
const startNode = (() => {
|
|
271
|
+
const requested = options.resumeFrom === undefined ? options.startNode : undefined;
|
|
272
|
+
const node = requested === undefined ? undefined : pinned.nodes[requested];
|
|
273
|
+
if (requested === undefined || node?.type !== 'agent')
|
|
274
|
+
return pinned.entry;
|
|
275
|
+
if (node.inputSchema) {
|
|
276
|
+
try {
|
|
277
|
+
validateValue(node.inputSchema, resolveMapping(node.inputs, { run: { input: runInput, state: runState, loop: { iteration: 1 } } }, node.inputSchema), `Node ${requested} inputs`);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
return pinned.entry;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// A join that waits for every branch can complete only when each branch it waits for can run from here. A node
|
|
284
|
+
// on one branch of a fork reaches the join without its siblings, and the run would end at the join with the
|
|
285
|
+
// rest of the graph skipped; starting at the entry runs every branch, as before.
|
|
286
|
+
const reachable = new Set();
|
|
287
|
+
for (const frontier = [requested]; frontier.length > 0;) {
|
|
288
|
+
const nodeId = frontier.pop();
|
|
289
|
+
if (reachable.has(nodeId))
|
|
290
|
+
continue;
|
|
291
|
+
reachable.add(nodeId);
|
|
292
|
+
for (const edge of pinned.edges)
|
|
293
|
+
if (edge.source === nodeId)
|
|
294
|
+
frontier.push(edge.target);
|
|
295
|
+
}
|
|
296
|
+
const joinsComplete = [...reachable].every(nodeId => {
|
|
297
|
+
const join = pinned.nodes[nodeId];
|
|
298
|
+
if (join?.type !== 'join' || join.join?.mode === 'any')
|
|
299
|
+
return true;
|
|
300
|
+
return pinned.edges.every(edge => edge.target !== nodeId || edge.bootstrap || reachable.has(edge.source));
|
|
301
|
+
});
|
|
302
|
+
return joinsComplete ? requested : pinned.entry;
|
|
303
|
+
})();
|
|
304
|
+
const queue = [{ nodeId: startNode, generation: 0, path: [], inputs: {}, predecessors: {} }];
|
|
251
305
|
const visits = new Map();
|
|
252
306
|
const executed = new Set();
|
|
253
307
|
let nextGeneration = 0;
|
|
254
308
|
const pendingJoins = new Map();
|
|
255
|
-
let currentNode =
|
|
309
|
+
let currentNode = startNode;
|
|
256
310
|
let lastCompletion;
|
|
257
311
|
if (options.resumeFrom) {
|
|
258
312
|
// Rehydrate the scheduler from the journal replay of a stopped attempt. The frontier is
|
|
@@ -673,6 +727,7 @@ export async function runGraph(graph, options) {
|
|
|
673
727
|
const narrow = (run, remaining) => remaining === undefined ? run : run === undefined ? remaining : Math.min(run, remaining);
|
|
674
728
|
maxToolCalls = narrow(maxToolCalls, continuation?.state.remainingToolCalls);
|
|
675
729
|
wallTimeMs = narrow(wallTimeMs, continuation?.state.remainingWallTimeMs);
|
|
730
|
+
handedWallMs.set(nodeId, wallTimeMs);
|
|
676
731
|
if (wallTimeMs !== undefined && wallTimeMs <= 0)
|
|
677
732
|
return { id: result.id, graph: pinned, provider: result.provider, model: result.model, status: 'exhausted', reason: 'wallTimeMs', toolCalls: 0, usage: { inputTokens: 0, outputTokens: 0, requests: 0 } };
|
|
678
733
|
const branchTodos = new TodoStore();
|
|
@@ -704,7 +759,9 @@ export async function runGraph(graph, options) {
|
|
|
704
759
|
? await readWhileRunning(operationSignal => runMemory.retrieve({ task: memoryTask, nodeId, runId: result.id, signal: operationSignal }))
|
|
705
760
|
: undefined;
|
|
706
761
|
const invocationTools = runMemory ? [...options.tools, memorySearchTool(runMemory, result.id)] : options.tools;
|
|
707
|
-
const
|
|
762
|
+
const projectMemory = options.projectMemory && node.contextPolicy?.projectMemory !== false
|
|
763
|
+
? await readWhileRunning(() => options.projectMemory.context()) : undefined;
|
|
764
|
+
const invocationTask = [options.task, memory?.block, options.commandMemory?.context(), projectMemory].filter(Boolean).join('\n\n');
|
|
708
765
|
const instrument = (provider, resolved) => ({
|
|
709
766
|
...resolved, adapter: dashboardAdapter(resolved.adapter, provider, event => options.onEvent?.(event), { runId: result.id, nodeId, nodeName: node.name, nodeType: node.type }),
|
|
710
767
|
});
|
|
@@ -968,7 +1025,7 @@ export async function runGraph(graph, options) {
|
|
|
968
1025
|
result.reason = failed.reason ?? failed.status;
|
|
969
1026
|
// Report the failing branch's effective bounds, which a node limit can tighten.
|
|
970
1027
|
if (failed.limits)
|
|
971
|
-
result.limits = failed.limits;
|
|
1028
|
+
result.limits = runClockBounds(failed.limits, result.reason, failedActivation.nodeId);
|
|
972
1029
|
break;
|
|
973
1030
|
}
|
|
974
1031
|
}
|
|
@@ -1034,7 +1091,7 @@ export async function runGraph(graph, options) {
|
|
|
1034
1091
|
result.reason = cancelled ? 'cancelled' : budget.expired() ? 'wallTimeMs' : outcome.reason ?? outcome.status;
|
|
1035
1092
|
// Report the node's effective bounds, which a node limit can tighten.
|
|
1036
1093
|
if (outcome.limits)
|
|
1037
|
-
result.limits = outcome.limits;
|
|
1094
|
+
result.limits = runClockBounds(outcome.limits, result.reason, nodeId);
|
|
1038
1095
|
break;
|
|
1039
1096
|
}
|
|
1040
1097
|
if (!outcome.completion)
|
|
@@ -14,7 +14,7 @@ export declare function requireGraphProviders(directory?: string): Promise<Confi
|
|
|
14
14
|
export declare function startGraphServer(directory?: string, checkMembership?: () => Promise<unknown>, options?: {
|
|
15
15
|
membership?: () => Promise<Membership>;
|
|
16
16
|
sync?: GraphSync;
|
|
17
|
-
managerChat?: (directory: string) => GraphManagerChatSession;
|
|
17
|
+
managerChat?: (directory: string, graphId: string) => GraphManagerChatSession;
|
|
18
18
|
}): Promise<{
|
|
19
19
|
url: string;
|
|
20
20
|
origin: string;
|
package/dist/src/graph-server.js
CHANGED
|
@@ -30,9 +30,14 @@ import { GraphManagerChat } from './graph-manager-chat.js';
|
|
|
30
30
|
export function readManagerGraphRevision(id, graphDirectory) {
|
|
31
31
|
return loadGraph(id, undefined, graphDirectory).then(graph => ({ revision: graph.revision, deleted: isDeletedGraph(graph) }), () => undefined);
|
|
32
32
|
}
|
|
33
|
+
/** The ids a graph can have in the editor; a Graph Manager conversation is named by one. */
|
|
34
|
+
const MANAGER_GRAPH_ID = /^[\w-]{1,120}$/;
|
|
33
35
|
/** The largest request body the editor accepts for a graph, whether it is being saved or sent to Graph Manager. */
|
|
34
36
|
const GRAPH_BODY_LIMIT = 512 * 1024;
|
|
35
|
-
|
|
37
|
+
// The vendor marks the editor's model picker can draw (model-picker.js `logoFor`): the desktop's
|
|
38
|
+
// glyph files (desktop/src/assets/providers/glyphs), which build-assets.mjs copies beside the editor.
|
|
39
|
+
const PROVIDER_GLYPHS = ['alibaba-cloud', 'anthropic', 'aws-bedrock', 'claude', 'deepseek', 'fireworks', 'kimi', 'minimax', 'openai', 'opencode', 'openrouter', 'xai', 'xiaomi-mimo', 'zai'];
|
|
40
|
+
const MANAGER_TOO_LARGE = 'This graph is too large to send to Graph Manager.';
|
|
36
41
|
const MANAGER_PING_MS = 15_000;
|
|
37
42
|
/**
|
|
38
43
|
* Reads a request body of at most `limit` bytes; undefined when it is larger. An oversized body is
|
|
@@ -132,17 +137,26 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
132
137
|
const token = randomBytes(32).toString('hex');
|
|
133
138
|
// The Graph Manager chat owns a child engine, so it exists only once a panel asks for it. Revisions
|
|
134
139
|
// are read from the folder this account's graphs are saved in, which is where the agent's saves land.
|
|
135
|
-
const createManagerChat = options.managerChat ?? ((home) => new GraphManagerChat({
|
|
140
|
+
const createManagerChat = options.managerChat ?? ((home, _graphId) => new GraphManagerChat({
|
|
136
141
|
directory: home,
|
|
137
142
|
readRevision: id => readManagerGraphRevision(id, graphDirectory),
|
|
138
143
|
}));
|
|
139
|
-
|
|
144
|
+
// Each graph has a conversation of its own, so one graph's requests and edits never reach the
|
|
145
|
+
// agent working on another. A chat's engine stops on its own once nobody is listening to it.
|
|
146
|
+
const managers = new Map();
|
|
140
147
|
let closing = false;
|
|
141
|
-
const managerChat = () => {
|
|
148
|
+
const managerChat = (graph) => {
|
|
142
149
|
// A request that outlives close() must not start an engine nothing would stop.
|
|
143
150
|
if (closing)
|
|
144
151
|
throw new Error('The editor is closing.');
|
|
145
|
-
|
|
152
|
+
if (typeof graph !== 'string' || !MANAGER_GRAPH_ID.test(graph))
|
|
153
|
+
throw new Error('Graph Manager needs the id of the open graph.');
|
|
154
|
+
let chat = managers.get(graph);
|
|
155
|
+
if (!chat) {
|
|
156
|
+
chat = createManagerChat(directory, graph);
|
|
157
|
+
managers.set(graph, chat);
|
|
158
|
+
}
|
|
159
|
+
return chat;
|
|
146
160
|
};
|
|
147
161
|
/** Ends each open Graph Manager stream, so closing the server never waits on one. */
|
|
148
162
|
const managerStreams = new Set();
|
|
@@ -165,6 +179,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
165
179
|
'/icons.js': ['icons.js', 'text/javascript; charset=utf-8'],
|
|
166
180
|
'/controls.js': ['controls.js', 'text/javascript; charset=utf-8'],
|
|
167
181
|
'/skill-picker.js': ['skill-picker.js', 'text/javascript; charset=utf-8'],
|
|
182
|
+
'/model-picker.js': ['model-picker.js', 'text/javascript; charset=utf-8'],
|
|
168
183
|
'/controls.css': ['controls.css', 'text/css; charset=utf-8'],
|
|
169
184
|
'/style.css': ['style.css', 'text/css; charset=utf-8'],
|
|
170
185
|
'/library.css': ['library.css', 'text/css; charset=utf-8'],
|
|
@@ -177,6 +192,10 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
177
192
|
'/fonts/geist-mono-latin-400-normal.woff2': ['fonts/geist-mono-latin-400-normal.woff2', 'font/woff2'],
|
|
178
193
|
'/andorra-logo.png': ['andorra-logo.png', 'image/png'],
|
|
179
194
|
};
|
|
195
|
+
// The provider marks the model picker draws: the desktop's own glyphs, copied beside the editor
|
|
196
|
+
// by build-assets.mjs.
|
|
197
|
+
for (const logo of PROVIDER_GLYPHS)
|
|
198
|
+
assets[`/provider-glyphs/${logo}.png`] = [`provider-glyphs/${logo}.png`, 'image/png'];
|
|
180
199
|
const reply = (res, status, value) => {
|
|
181
200
|
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
182
201
|
res.end(JSON.stringify(value));
|
|
@@ -290,7 +309,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
290
309
|
return;
|
|
291
310
|
}
|
|
292
311
|
if (req.method === 'GET' && path === '/api/manager/stream') {
|
|
293
|
-
const chat = managerChat();
|
|
312
|
+
const chat = managerChat(new URL(req.url, origin).searchParams.get('graph'));
|
|
294
313
|
res.writeHead(200, { 'Content-Type': 'text/event-stream; charset=utf-8', 'Cache-Control': 'no-store' });
|
|
295
314
|
res.flushHeaders?.();
|
|
296
315
|
let open = true;
|
|
@@ -329,15 +348,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
329
348
|
// The chat reports what goes wrong on the engine's side as an `error` event on the stream,
|
|
330
349
|
// and a message can take as long as an engine start, so no route waits for its outcome.
|
|
331
350
|
const accepted = (work) => { void work.catch(() => { }); reply(res, 200, { ok: true }); };
|
|
332
|
-
if (action === 'cancel') {
|
|
333
|
-
accepted(managerChat().cancel());
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
if (action === 'reset') {
|
|
337
|
-
accepted(managerChat().reset());
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
if (action === 'message' || action === 'approve' || action === 'answer') {
|
|
351
|
+
if (action === 'cancel' || action === 'reset' || action === 'message' || action === 'approve' || action === 'answer') {
|
|
341
352
|
if (!req.headers['content-type']?.startsWith('application/json')) {
|
|
342
353
|
reply(res, 415, { error: 'Expected application/json' });
|
|
343
354
|
return;
|
|
@@ -349,26 +360,36 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
349
360
|
}
|
|
350
361
|
const parsed = JSON.parse(body.toString('utf8'));
|
|
351
362
|
const value = parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
363
|
+
// Every request names the graph whose conversation it belongs to; a message names it by its canvas.
|
|
364
|
+
const graphId = action === 'message' ? value.graph?.id : value.graphId;
|
|
365
|
+
if (action === 'cancel') {
|
|
366
|
+
accepted(managerChat(graphId).cancel());
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (action === 'reset') {
|
|
370
|
+
accepted(managerChat(graphId).reset());
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
352
373
|
if (action === 'approve') {
|
|
353
374
|
if (!filled(value.id) || typeof value.approved !== 'boolean')
|
|
354
375
|
throw new Error('An approval needs its id and a decision.');
|
|
355
|
-
accepted(managerChat().approve(value.id, value.approved));
|
|
376
|
+
accepted(managerChat(graphId).approve(value.id, value.approved));
|
|
356
377
|
return;
|
|
357
378
|
}
|
|
358
379
|
if (action === 'answer') {
|
|
359
380
|
if (!filled(value.id) || typeof value.value !== 'string')
|
|
360
381
|
throw new Error('An answer needs the question id and a value.');
|
|
361
|
-
accepted(managerChat().answer(value.id, value.value));
|
|
382
|
+
accepted(managerChat(graphId).answer(value.id, value.value));
|
|
362
383
|
return;
|
|
363
384
|
}
|
|
364
385
|
const graph = value.graph;
|
|
365
386
|
if (!filled(value.provider) || !filled(value.model))
|
|
366
|
-
throw new Error('Choose a model for
|
|
387
|
+
throw new Error('Choose a model for Graph Manager.');
|
|
367
388
|
if (!filled(value.text))
|
|
368
|
-
throw new Error('Write a message for
|
|
389
|
+
throw new Error('Write a message for Graph Manager.');
|
|
369
390
|
if (graph === null || typeof graph !== 'object' || Array.isArray(graph) || typeof graph.id !== 'string' || typeof graph.name !== 'string')
|
|
370
|
-
throw new Error('A message to
|
|
371
|
-
accepted(managerChat().send({
|
|
391
|
+
throw new Error('A message to Graph Manager needs the open graph.');
|
|
392
|
+
accepted(managerChat(graphId).send({
|
|
372
393
|
provider: value.provider, model: value.model, text: value.text,
|
|
373
394
|
graph: graph, saved: value.saved === true,
|
|
374
395
|
...(typeof value.revision === 'number' && Number.isInteger(value.revision) && value.revision >= 0 ? { revision: value.revision } : {}),
|
|
@@ -465,7 +486,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
465
486
|
const graphs = [];
|
|
466
487
|
const graphMigrationErrors = [];
|
|
467
488
|
const savedGraphs = await listGraphs(graphDirectory, (id, error) => {
|
|
468
|
-
graphMigrationErrors.push({ id, name: id, error: error instanceof Error ? error.message : '
|
|
489
|
+
graphMigrationErrors.push({ id, name: id, error: error instanceof Error ? error.message : 'Graph load failed' });
|
|
469
490
|
});
|
|
470
491
|
const free = await freeTier();
|
|
471
492
|
// Deleted graphs stay out of the editor; restoring one goes through the graph MCP server.
|
|
@@ -520,7 +541,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
520
541
|
// The preset is bundled with the CLI: it has no storage to remove, and hiding it would
|
|
521
542
|
// only last until the next launch.
|
|
522
543
|
if (id === 'default') {
|
|
523
|
-
reply(res, 400, { error: 'The bundled default
|
|
544
|
+
reply(res, 400, { error: 'The bundled default graph cannot be deleted.' });
|
|
524
545
|
return;
|
|
525
546
|
}
|
|
526
547
|
if (id === GRAPH_MANAGER_GRAPH_ID) {
|
|
@@ -550,7 +571,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
550
571
|
}
|
|
551
572
|
const body = await readBody(req, GRAPH_BODY_LIMIT);
|
|
552
573
|
if (!body) {
|
|
553
|
-
reply(res, 413, { error: '
|
|
574
|
+
reply(res, 413, { error: 'Graph exceeds 512 KiB' });
|
|
554
575
|
return;
|
|
555
576
|
}
|
|
556
577
|
const value = JSON.parse(body.toString('utf8'));
|
|
@@ -605,7 +626,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
605
626
|
// Stamping can add profile entries after the streamed body already passed the limit.
|
|
606
627
|
const stamped = stampGraphProviderProfiles(graph, config);
|
|
607
628
|
if (Buffer.byteLength(JSON.stringify(stamped)) > GRAPH_BODY_LIMIT) {
|
|
608
|
-
reply(res, 413, { error: '
|
|
629
|
+
reply(res, 413, { error: 'Graph exceeds 512 KiB' });
|
|
609
630
|
return;
|
|
610
631
|
}
|
|
611
632
|
const expected = graph.revision === 0 ? null : graph.revision;
|
|
@@ -651,7 +672,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
651
672
|
end();
|
|
652
673
|
// The server goes down even when the chat's engine does not stop cleanly.
|
|
653
674
|
try {
|
|
654
|
-
await
|
|
675
|
+
await Promise.all([...managers.values()].map(chat => chat.close()));
|
|
655
676
|
}
|
|
656
677
|
finally {
|
|
657
678
|
await sync?.close();
|
|
@@ -672,7 +693,7 @@ export async function deleteGraphWithTombstone(id, graphDirectory, directory, su
|
|
|
672
693
|
// MCP server's delete tool applies the same check, so the editor cannot bypass it.
|
|
673
694
|
const users = (await new AutomationStore(directory).list()).filter(job => job.execution?.graph === id);
|
|
674
695
|
if (users.length)
|
|
675
|
-
throw new Error('
|
|
696
|
+
throw new Error('Graph ' + id + ' is run by automation'
|
|
676
697
|
+ (users.length === 1 ? ' ' : 's ') + users.map(job => '"' + job.name + '"').join(', ')
|
|
677
698
|
+ '. Change or remove ' + (users.length === 1 ? 'it' : 'them') + ' first.');
|
|
678
699
|
if (sync) {
|
package/dist/src/graph-sync.d.ts
CHANGED
|
@@ -111,6 +111,14 @@ export declare class GraphSync {
|
|
|
111
111
|
private request;
|
|
112
112
|
private perform;
|
|
113
113
|
private restoreDraft;
|
|
114
|
+
/**
|
|
115
|
+
* Whether this exact snapshot is already published here, read without the save lock. Revision
|
|
116
|
+
* files are immutable, so a published one cannot change under the read; anything less than a
|
|
117
|
+
* published copy with these exact contents — a missing or different file, an unpublished one past
|
|
118
|
+
* the latest pointer, a conflict — is left to the locked restore, which decides it. The conflict
|
|
119
|
+
* copy's id is derived from this snapshot's hash, so its receipt can only be this snapshot's.
|
|
120
|
+
*/
|
|
121
|
+
private alreadyRestored;
|
|
114
122
|
private restoreSnapshot;
|
|
115
123
|
}
|
|
116
124
|
/** What a caller needs from a sync it owns; a test supplies its own in place of a real one. */
|