@andorra-labs/code 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +22 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +13 -4
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
package/dist/src/graph-quota.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
4
|
import { GraphConflictError, listGraphs, loadGraph, saveGraph } from './graphs.js';
|
|
@@ -9,7 +9,7 @@ export const FREE_GRAPH_NODE_LIMIT = 3;
|
|
|
9
9
|
export const FREE_GRAPH_LIMIT_MESSAGE = 'The free tier includes 1 custom graph. Upgrade to Premium to create more graphs.';
|
|
10
10
|
export const FREE_NODE_LIMIT_MESSAGE = `Free tier graphs can have up to ${FREE_GRAPH_NODE_LIMIT} nodes, not counting Done. Upgrade to Premium for larger graphs.`;
|
|
11
11
|
export const FREE_ORCHESTRATOR_MESSAGE = 'The Orchestrator is a Premium feature. Free tier graphs can use the other agent nodes.';
|
|
12
|
-
export const FREE_LOCKED_GRAPH_MESSAGE = '
|
|
12
|
+
export const FREE_LOCKED_GRAPH_MESSAGE = 'This graph is view only on the free tier. Duplicate it to make a copy you can change, or upgrade to Premium to use it.';
|
|
13
13
|
export function countedGraphNodes(graph) {
|
|
14
14
|
return Object.values(graph.nodes).filter(node => node.type !== 'end').length;
|
|
15
15
|
}
|
|
@@ -20,6 +20,13 @@ export function freeTierGraphViolation(graph) {
|
|
|
20
20
|
return FREE_NODE_LIMIT_MESSAGE;
|
|
21
21
|
return undefined;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A graph saved by a free account carries `metadata.freeTier: true`, and one saved by a Premium
|
|
25
|
+
* account carries `false`, so which plan made a graph travels with it to another machine.
|
|
26
|
+
*/
|
|
27
|
+
export function isFreeTierGraph(graph) {
|
|
28
|
+
return graph.metadata?.freeTier === true;
|
|
29
|
+
}
|
|
23
30
|
async function graphCreatedAt(graph, directory) {
|
|
24
31
|
if (typeof graph.metadata?.createdAt === 'string')
|
|
25
32
|
return graph.metadata.createdAt;
|
|
@@ -32,18 +39,57 @@ async function graphCreatedAt(graph, directory) {
|
|
|
32
39
|
return typeof graph.metadata?.updatedAt === 'string' ? graph.metadata.updatedAt : '';
|
|
33
40
|
}
|
|
34
41
|
const RECOVERY_COPY = /^cloud-[a-f0-9]{40}$/;
|
|
35
|
-
|
|
42
|
+
const PREMIUM_SEEN = 'graph-premium-seen.json';
|
|
43
|
+
const FREE_GRAPH_RECORD = 'graph-free.json';
|
|
44
|
+
/** Records that a Premium account used this graph folder, so its graphs lock when the account is later free. */
|
|
45
|
+
export async function notePremiumGraphAccount(directory) {
|
|
46
|
+
try {
|
|
47
|
+
await writeFile(join(directory, PREMIUM_SEEN), 'true', { flag: 'wx', mode: 0o600 });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.code !== 'EEXIST' && error.code !== 'ENOENT')
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function readJson(path) {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(await readFile(path, 'utf8'));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Which saved graph is the free account's own.
|
|
64
|
+
*
|
|
65
|
+
* It is the oldest graph that fits the free limits and either carries the free mark or is the one
|
|
66
|
+
* this folder recorded. A folder no Premium account has used, and that has recorded nothing, keeps
|
|
67
|
+
* its oldest graph that fits: that is the graph a free account owned before graphs carried a mark. `adopt`
|
|
68
|
+
* writes that choice down, so a later upgrade and downgrade does not lose it; pass it only for an
|
|
69
|
+
* account the service confirmed as free.
|
|
70
|
+
*/
|
|
71
|
+
export async function readGraphQuota(directory, graphs, options = {}) {
|
|
36
72
|
const custom = (graphs ?? await listGraphs(directory)).filter(graph => graph.id !== 'default');
|
|
37
73
|
if (!custom.length)
|
|
38
74
|
return { customGraphs: 0 };
|
|
39
|
-
const dated = await Promise.all(custom.map(async (graph) => ({
|
|
75
|
+
const dated = await Promise.all(custom.map(async (graph) => ({ graph, recovery: RECOVERY_COPY.test(graph.id), created: await graphCreatedAt(graph, directory) })));
|
|
40
76
|
dated.sort((a, b) => Number(a.recovery) - Number(b.recovery)
|
|
41
|
-
|| (a.created === b.created ? 0 : !a.created ? 1 : !b.created ? -1 : a.created < b.created ? -1 : 1) || a.id.localeCompare(b.id));
|
|
42
|
-
|
|
77
|
+
|| (a.created === b.created ? 0 : !a.created ? 1 : !b.created ? -1 : a.created < b.created ? -1 : 1) || a.graph.id.localeCompare(b.graph.id));
|
|
78
|
+
const fits = (graph) => freeTierGraphViolation(graph) === undefined;
|
|
79
|
+
const recorded = await readJson(join(directory, FREE_GRAPH_RECORD));
|
|
80
|
+
const recordedId = typeof recorded === 'string' ? recorded : undefined;
|
|
81
|
+
let free = dated.find(({ graph }) => fits(graph) && (isFreeTierGraph(graph) || (graph.id === recordedId && graph.metadata?.freeTier !== false)))?.graph.id;
|
|
82
|
+
if (free === undefined && recorded === undefined && await readJson(join(directory, PREMIUM_SEEN)) === undefined) {
|
|
83
|
+
// A graph a Premium account saved says so itself, on any machine it was synced to.
|
|
84
|
+
free = dated.find(({ graph }) => fits(graph) && graph.metadata?.freeTier !== false)?.graph.id;
|
|
85
|
+
if (free !== undefined && options.adopt)
|
|
86
|
+
await writeFile(join(directory, FREE_GRAPH_RECORD), JSON.stringify(free), { mode: 0o600 }).catch(() => { });
|
|
87
|
+
}
|
|
88
|
+
return { customGraphs: custom.length, ...(free === undefined ? {} : { freeGraphId: free }) };
|
|
43
89
|
}
|
|
44
90
|
export async function assertFreeTierSave(graph, isNew, directory) {
|
|
45
|
-
const quota = await readGraphQuota(directory);
|
|
46
|
-
if (isNew ? quota.
|
|
91
|
+
const quota = await readGraphQuota(directory, undefined, { adopt: true });
|
|
92
|
+
if (isNew ? quota.freeGraphId !== undefined : quota.freeGraphId !== graph.id) {
|
|
47
93
|
throw new FreeTierLimitError(isNew ? FREE_GRAPH_LIMIT_MESSAGE : FREE_LOCKED_GRAPH_MESSAGE);
|
|
48
94
|
}
|
|
49
95
|
const violation = freeTierGraphViolation(graph);
|
|
@@ -66,14 +112,26 @@ export async function saveFreeTierGraph(graph, expectedRevision, directory) {
|
|
|
66
112
|
}
|
|
67
113
|
try {
|
|
68
114
|
await assertFreeTierSave(graph, expectedRevision === null, directory);
|
|
69
|
-
return await saveGraph(graph, expectedRevision, directory);
|
|
115
|
+
return await saveGraph({ ...graph, metadata: { ...graph.metadata, freeTier: true } }, expectedRevision, directory);
|
|
70
116
|
}
|
|
71
117
|
finally {
|
|
72
118
|
await release();
|
|
73
119
|
}
|
|
74
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Saves for a Premium account, marking the graph as made on Premium. The account's own free graph
|
|
123
|
+
* keeps its mark while it fits the free limits, so it is still the free graph after a downgrade.
|
|
124
|
+
* Growing it past the limits gives the mark up for good, as the storage service gives up its pin:
|
|
125
|
+
* shrinking it later must not take the allowance back from the graph that replaced it.
|
|
126
|
+
*/
|
|
127
|
+
export async function savePremiumGraph(graph, expectedRevision, directory) {
|
|
128
|
+
const own = expectedRevision !== null && freeTierGraphViolation(graph) === undefined
|
|
129
|
+
&& (isFreeTierGraph(graph) || (graph.metadata?.freeTier !== false && graph.id === await readJson(join(directory, FREE_GRAPH_RECORD))));
|
|
130
|
+
return saveGraph({ ...graph, metadata: { ...graph.metadata, freeTier: own } }, expectedRevision, directory);
|
|
131
|
+
}
|
|
132
|
+
/** The graph a free account may run: its own graph, within the free limits. Every other saved graph is view only. */
|
|
75
133
|
export async function loadFreeTierGraph(id, directory) {
|
|
76
|
-
const quota = await readGraphQuota(directory);
|
|
134
|
+
const quota = await readGraphQuota(directory, undefined, { adopt: true });
|
|
77
135
|
const graph = await loadGraph(id, undefined, directory);
|
|
78
136
|
if (quota.freeGraphId !== id)
|
|
79
137
|
throw new FreeTierLimitError(FREE_LOCKED_GRAPH_MESSAGE);
|
package/dist/src/graph-runner.js
CHANGED
|
@@ -4,7 +4,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
4
4
|
import { TodoStore } from './todos.js';
|
|
5
5
|
import { WidgetStore } from './widgets.js';
|
|
6
6
|
import { isDeepStrictEqual } from 'node:util';
|
|
7
|
-
import { validateGraph, nodeOutcomes, maxNodeVisitsOf, ACTION_FAILED_OUTCOME } from './graphs.js';
|
|
7
|
+
import { validateGraph, nodeOutcomes, maxNodeVisitsOf, ACTION_FAILED_OUTCOME, isolatedGraph } from './graphs.js';
|
|
8
8
|
import { CommandExitError } from './tool-errors.js';
|
|
9
9
|
import { executeModifiedAgent, matchesOutput } from './agent-modifiers.js';
|
|
10
10
|
import { GOAL_NEEDS_AGENT, graphCanCheckGoal } from './session-goal.js';
|
|
@@ -23,15 +23,24 @@ import { loadConfig, resolveMemoryConfig } from './config.js';
|
|
|
23
23
|
import { advertiseAvailableTools } from './tool-availability.js';
|
|
24
24
|
import { elapsedMs, monotonicNow } from './duration.js';
|
|
25
25
|
import { dashboardAdapter } from './dashboard.js';
|
|
26
|
-
import {
|
|
26
|
+
import { toolBoundaryOpen } from './run-progress.js';
|
|
27
|
+
import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordErrorOnce, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
|
|
28
|
+
import { ProviderRequestError, runFailureCode } from './providers.js';
|
|
27
29
|
import { isTestCommandLine } from './telemetry/classify.js';
|
|
30
|
+
import { reviewNodeUnavailable } from './github-app/review-node.js';
|
|
28
31
|
function absorbTelemetry(result, outcome) {
|
|
32
|
+
// Every branch's errors are kept; why the run stopped is taken from the one outcome it ends on (endOn).
|
|
29
33
|
if (outcome.telemetry)
|
|
30
34
|
mergeRunTelemetry(result.telemetry, outcome.telemetry);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
}
|
|
36
|
+
/** The run ends on this outcome: its error code and failure evidence, not another branch's, say why it stopped. */
|
|
37
|
+
function endOn(result, outcome) {
|
|
38
|
+
for (const field of ['failureCode', 'providerRequestFailed', 'providerOverflow']) {
|
|
39
|
+
if (outcome[field] === undefined)
|
|
40
|
+
delete result[field];
|
|
41
|
+
else
|
|
42
|
+
result[field] = outcome[field];
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
const freeze = (value) => {
|
|
37
46
|
for (const child of Object.values(value))
|
|
@@ -54,7 +63,24 @@ function mergeInputs(target, incoming, nodeId) {
|
|
|
54
63
|
target[key] = value;
|
|
55
64
|
}
|
|
56
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The options of an isolated graph's run (the review loop's reviewer): its output is posted publicly, so none of the
|
|
68
|
+
* person's private context reaches it, whatever the surface that started it passed in. Gone are the persistent, command
|
|
69
|
+
* and project memories (with their distillation and tools), the project and user instructions and the skill catalog,
|
|
70
|
+
* the skills a session carries, the session history, CodeGraph and Jev. The efficiency settings fall back to their
|
|
71
|
+
* defaults too, so the reviewer gets exactly its own tools and the model the loop chose.
|
|
72
|
+
*/
|
|
73
|
+
async function isolatedRunOptions(options) {
|
|
74
|
+
const { memory: _memory, commandMemory: _commandMemory, projectMemory: _projectMemory, instructions: _instructions, skillInvocationInstruction: _skillInstruction, history: _history, codeIntel: _codeIntel, decisionPreflight: _preflight, goalCompletionVerification: _goal, efficiency: _efficiency, ...rest } = options;
|
|
75
|
+
return {
|
|
76
|
+
...rest, inheritedSkills: [], entryHistory: false, decisionNodeOptIn: true,
|
|
77
|
+
decisionManager: new DecisionManager({ config: { mode: 'off', provider: 'none' } }),
|
|
78
|
+
memory: await MemoryManager.create({ config: { enabled: false }, workspace: options.context.workspace, onEvent: options.onEvent }),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
57
81
|
export async function runGraph(graph, options) {
|
|
82
|
+
if (isolatedGraph(graph.id))
|
|
83
|
+
options = await isolatedRunOptions(options);
|
|
58
84
|
if (options.goalCompletionVerification && !graphCanCheckGoal(graph))
|
|
59
85
|
throw new Error(GOAL_NEEDS_AGENT);
|
|
60
86
|
const removedMemorySettings = [];
|
|
@@ -266,8 +292,7 @@ export async function runGraph(graph, options) {
|
|
|
266
292
|
?? { nodeId: checkpoint.nodeId, generation: checkpoint.generation ?? 0, path: [], inputs: {}, predecessors: {} };
|
|
267
293
|
if (!continuableByThisRun(checkpoint.nodeId, checkpoint))
|
|
268
294
|
continue;
|
|
269
|
-
|
|
270
|
-
if (toolEvent !== undefined && Date.parse(checkpoint.savedAt) < Date.parse(toolEvent)) {
|
|
295
|
+
if (toolBoundaryOpen(checkpoint, progress)) {
|
|
271
296
|
throw new Error(`Cannot resume the "${pinned.nodes[checkpoint.nodeId]?.name ?? checkpoint.nodeId}" node: the stopped attempt ran a tool call after the conversation this checkpoint saved, so re-entering it could repeat an effect the checkpoint does not cover. Check what the call changed, then start a new run.`);
|
|
272
297
|
}
|
|
273
298
|
const routed = routedContinuation(checkpoint.nodeId, checkpoint);
|
|
@@ -741,6 +766,7 @@ export async function runGraph(graph, options) {
|
|
|
741
766
|
result.model = failed.model;
|
|
742
767
|
result.status = failed.status;
|
|
743
768
|
result.reason = failed.reason ?? failed.status;
|
|
769
|
+
endOn(result, failed);
|
|
744
770
|
if (failed.limits)
|
|
745
771
|
result.limits = runClockBounds(failed.limits, result.reason, failedActivation.nodeId);
|
|
746
772
|
break;
|
|
@@ -790,6 +816,7 @@ export async function runGraph(graph, options) {
|
|
|
790
816
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
791
817
|
result.status = cancelled ? 'cancelled' : budget.expired() ? 'exhausted' : outcome.status;
|
|
792
818
|
result.reason = cancelled ? 'cancelled' : budget.expired() ? 'wallTimeMs' : outcome.reason ?? outcome.status;
|
|
819
|
+
endOn(result, outcome);
|
|
793
820
|
if (outcome.limits)
|
|
794
821
|
result.limits = runClockBounds(outcome.limits, result.reason, nodeId);
|
|
795
822
|
break;
|
|
@@ -921,13 +948,49 @@ export async function runGraph(graph, options) {
|
|
|
921
948
|
if (!interrupted && !exitFailure)
|
|
922
949
|
await emit('node.tool.completed', { nodeId, name: shellName, toolCallId, durationMs, output });
|
|
923
950
|
}
|
|
951
|
+
else if (node.type === 'review') {
|
|
952
|
+
// An Andorra review round: the service runs it on the task's PR (src/github-app/review-node.ts). A run without one,
|
|
953
|
+
// such as a preview, leaves through `stopped`.
|
|
954
|
+
const reviewSignal = context.runControl ? AbortSignal.any([signal, context.runControl.signal]) : signal;
|
|
955
|
+
const answer = options.reviewNode
|
|
956
|
+
? await options.reviewNode.round({
|
|
957
|
+
nodeId, name: node.name, settings: node.review, signal: reviewSignal,
|
|
958
|
+
approve: async (question) => {
|
|
959
|
+
if (context.runControl?.yolo ?? context.yolo)
|
|
960
|
+
return true;
|
|
961
|
+
if (context.approvalMode === 'headless')
|
|
962
|
+
return false;
|
|
963
|
+
for (;;) {
|
|
964
|
+
await context.runControl?.wait(signal);
|
|
965
|
+
const promptSignal = context.runControl ? AbortSignal.any([context.userSignal ?? signal, context.runControl.signal]) : context.userSignal ?? signal;
|
|
966
|
+
try {
|
|
967
|
+
const answer = await context.approve('graph.review', { nodeId, name: node.name, question }, promptSignal);
|
|
968
|
+
if (answer === 'policy-changed')
|
|
969
|
+
continue;
|
|
970
|
+
if (promptSignal.aborted && !signal.aborted)
|
|
971
|
+
continue;
|
|
972
|
+
return answer === true;
|
|
973
|
+
}
|
|
974
|
+
catch (error) {
|
|
975
|
+
if (!promptSignal.aborted || signal.aborted)
|
|
976
|
+
throw error;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
emit: (type, data) => emit(type, { nodeId, ...data }),
|
|
981
|
+
})
|
|
982
|
+
: reviewNodeUnavailable(node.review);
|
|
983
|
+
signal.throwIfAborted();
|
|
984
|
+
completion = { ...completion, outcome: answer.outcome, output: { ...answer.output }, summary: answer.summary };
|
|
985
|
+
}
|
|
924
986
|
else if (node.type === 'parallel' || node.type === 'join')
|
|
925
987
|
completion.output = activation.inputs;
|
|
926
988
|
if (nodeOutputSchema(node))
|
|
927
989
|
validateValue(nodeOutputSchema(node), completion.output, `Node ${nodeId} output`);
|
|
928
990
|
signal.throwIfAborted();
|
|
929
991
|
result.nodeResults[nodeId] = completion;
|
|
930
|
-
|
|
992
|
+
// A review node's line is not the run's answer: the engineer's summary and tests stay the run's.
|
|
993
|
+
if (node.type !== 'end' && node.type !== 'review')
|
|
931
994
|
lastCompletion = completion;
|
|
932
995
|
if (!prefetchedCompleted.has(activation))
|
|
933
996
|
await emit('graph.node.completed', { nodeId, completion });
|
|
@@ -949,8 +1012,15 @@ export async function runGraph(graph, options) {
|
|
|
949
1012
|
continue;
|
|
950
1013
|
const inputs = resolveMapping(edge.inputMapping, { source: completion, run: { input: runInput, state: runState, loop: { iteration: count } } }, target.inputSchema);
|
|
951
1014
|
const incoming = { ...(node.modifiers?.parallel?.mode === 'branches' ? { parallelGroup: `${nodeId}:${activation.generation}:${count}`, concurrency: node.modifiers.parallel.maxConcurrent } : {}), nodeId: edge.target, generation, path, inputs, source: completion, predecessors: { [nodeId]: completion } };
|
|
952
|
-
if (node.type === 'agent' && target.type === 'agent' && node.contextPolicy?.conversation !== 'isolate')
|
|
1015
|
+
if (node.type === 'agent' && (target.type === 'agent' || target.type === 'review') && node.contextPolicy?.conversation !== 'isolate') {
|
|
953
1016
|
incoming.conversation = conversations.get(activation);
|
|
1017
|
+
if (target.type === 'review')
|
|
1018
|
+
incoming.conversationOwner = nodeId;
|
|
1019
|
+
}
|
|
1020
|
+
// The fixer a review node hands its findings to continues its own context: the conversation goes back only to the
|
|
1021
|
+
// agent it came from (that agent's own isolate policy still wins where it runs).
|
|
1022
|
+
if (node.type === 'review' && target.type === 'agent' && activation.conversation !== undefined && activation.conversationOwner === edge.target)
|
|
1023
|
+
incoming.conversation = activation.conversation;
|
|
954
1024
|
if (target.type === 'join' && target.join?.mode !== 'any' && !edge.bootstrap) {
|
|
955
1025
|
const pending = pendingJoins.get(targetKey) ?? new Map();
|
|
956
1026
|
pending.set(edgeIndex, incoming);
|
|
@@ -1007,6 +1077,7 @@ export async function runGraph(graph, options) {
|
|
|
1007
1077
|
if (continuation.status !== 'succeeded' || !continuation.completion) {
|
|
1008
1078
|
result.status = continuation.status;
|
|
1009
1079
|
result.reason = continuation.reason ?? continuation.status;
|
|
1080
|
+
endOn(result, continuation);
|
|
1010
1081
|
break;
|
|
1011
1082
|
}
|
|
1012
1083
|
const condition = pinned.nodes[lastAgentActivation.nodeId].modifiers?.condition;
|
|
@@ -1087,6 +1158,13 @@ export async function runGraph(graph, options) {
|
|
|
1087
1158
|
const deadline = budget.expired() || signal.aborted;
|
|
1088
1159
|
result.status = cancelled ? 'cancelled' : deadline ? 'exhausted' : 'infrastructure_error';
|
|
1089
1160
|
result.reason = cancelled ? 'cancelled' : deadline ? 'wallTimeMs' : error instanceof Error ? error.message : 'Graph runtime failure';
|
|
1161
|
+
if (cancelled || deadline)
|
|
1162
|
+
endOn(result, {});
|
|
1163
|
+
else
|
|
1164
|
+
endOn(result, {
|
|
1165
|
+
failureCode: recordErrorOnce(result.telemetry ??= createRunTelemetry(), error, runFailureCode(error)),
|
|
1166
|
+
...(error instanceof ProviderRequestError ? { providerRequestFailed: true, ...(error.contextOverflow ? { providerOverflow: true } : {}) } : {}),
|
|
1167
|
+
});
|
|
1090
1168
|
}
|
|
1091
1169
|
try {
|
|
1092
1170
|
await options.commandMemory?.flush(options.context.userSignal ?? options.context.signal);
|
|
@@ -4,7 +4,7 @@ import { GraphSync } from './graph-sync.js';
|
|
|
4
4
|
import { GraphManagerChat, type ManagerGraphRevision } from './graph-manager-chat.js';
|
|
5
5
|
export declare function readManagerGraphRevision(id: string, graphDirectory: string): Promise<ManagerGraphRevision | undefined>;
|
|
6
6
|
export type GraphManagerChatSession = Pick<GraphManagerChat, 'subscribe' | 'send' | 'approve' | 'answer' | 'cancel' | 'reset' | 'close'>;
|
|
7
|
-
export declare function createGraphSessionCheck(subject: string | undefined, status?: (signal?: AbortSignal) => Promise<import("./auth/types.js").AuthStatus>, membership?: (
|
|
7
|
+
export declare function createGraphSessionCheck(subject: string | undefined, status?: (signal?: AbortSignal) => Promise<import("./auth/types.js").AuthStatus>, membership?: () => Promise<Membership>): () => Promise<void>;
|
|
8
8
|
export declare const EDITOR_MEMBERSHIP_TTL_MS = 30000;
|
|
9
9
|
export declare function sharedRead<T>(read: () => Promise<T>, ttlMs: number, now?: () => number): () => Promise<T>;
|
|
10
10
|
export declare function requireGraphProviders(directory?: string): Promise<Config>;
|
package/dist/src/graph-server.js
CHANGED
|
@@ -6,15 +6,15 @@ import { execFile } from 'node:child_process';
|
|
|
6
6
|
import { changeConfigFile, configDirectory, loadConfig, validateConfig } from './config.js';
|
|
7
7
|
import { stampGraphProviderProfiles } from './graph-provider-portability.js';
|
|
8
8
|
import { resetDeletedGraphSelection } from './graph-selection.js';
|
|
9
|
-
import { listGraphs, loadGraph,
|
|
9
|
+
import { listGraphs, loadGraph, saveGraphOrder, validateGraph, migrateGraphForEditor, deleteGraph, isDeletedGraph, withoutDeletedGraphs, isReservedGraphId, reservedGraphId } from './graphs.js';
|
|
10
10
|
import { createTools } from './tools.js';
|
|
11
11
|
import { AutomationStore } from './automations.js';
|
|
12
12
|
import { deleteAgentDefinition, exportAgentDefinition, importAgentDefinition, listAgentDefinitions, readAgentDefinition, saveAgentDefinition, validateAgentDefinition } from './agent-definitions.js';
|
|
13
13
|
import { discoverModelMetadata, resolveModelContext } from './model-metadata.js';
|
|
14
14
|
import { MODEL_LISTING_TIMEOUT_MS, providerLabel, providerModels, recordProviderModel } from './providers.js';
|
|
15
15
|
import { PaidMembershipRequiredError, readGraphMembership } from './membership.js';
|
|
16
|
-
import {
|
|
17
|
-
import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_NODE_LIMIT, FreeTierLimitError, readGraphQuota, saveFreeTierGraph } from './graph-quota.js';
|
|
16
|
+
import { getGraphMembership } from './membership.js';
|
|
17
|
+
import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_NODE_LIMIT, FreeTierLimitError, notePremiumGraphAccount, readGraphQuota, saveFreeTierGraph, savePremiumGraph } from './graph-quota.js';
|
|
18
18
|
import { getAuthStatus } from './auth/index.js';
|
|
19
19
|
import { readActivity } from './activity.js';
|
|
20
20
|
import { graphStorageDirectory } from './graph-account.js';
|
|
@@ -43,7 +43,7 @@ async function readBody(req, limit) {
|
|
|
43
43
|
}
|
|
44
44
|
const filled = (value) => typeof value === 'string' && value.trim() !== '';
|
|
45
45
|
const setupMessage = 'No providers configured. Run `andorra` and open `/providers` first, then retry `andorra graph`.';
|
|
46
|
-
export function createGraphSessionCheck(subject, status = getAuthStatus, membership =
|
|
46
|
+
export function createGraphSessionCheck(subject, status = getAuthStatus, membership = getGraphMembership) {
|
|
47
47
|
let revoked = false;
|
|
48
48
|
return async () => {
|
|
49
49
|
const current = await status();
|
|
@@ -112,7 +112,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
112
112
|
await sync?.start();
|
|
113
113
|
// The sign-in state is local and read on every request, so signing out or switching accounts
|
|
114
114
|
// ends the session at once; the account service's answer is a network call and is reused briefly.
|
|
115
|
-
const sessionMembership = sharedRead(() =>
|
|
115
|
+
const sessionMembership = sharedRead(() => getGraphMembership(), EDITOR_MEMBERSHIP_TTL_MS);
|
|
116
116
|
const checkSession = checkMembership === readGraphMembership
|
|
117
117
|
? createGraphSessionCheck(account.subject, sharedRead(() => getAuthStatus(), 0), sessionMembership)
|
|
118
118
|
: checkMembership;
|
|
@@ -125,6 +125,8 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
125
125
|
const access = await readMembership();
|
|
126
126
|
if (!access.unavailable)
|
|
127
127
|
lastPaid = access.paid;
|
|
128
|
+
if (!access.unavailable && access.paid)
|
|
129
|
+
await notePremiumGraphAccount(graphDirectory);
|
|
128
130
|
return lastPaid !== true;
|
|
129
131
|
};
|
|
130
132
|
await freeTier();
|
|
@@ -447,7 +449,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
451
|
const plan = free
|
|
450
|
-
? { paid: false, customGraphLimit: FREE_CUSTOM_GRAPH_LIMIT, nodeLimit: FREE_GRAPH_NODE_LIMIT, ...await readGraphQuota(graphDirectory, savedGraphs) }
|
|
452
|
+
? { paid: false, customGraphLimit: FREE_CUSTOM_GRAPH_LIMIT, nodeLimit: FREE_GRAPH_NODE_LIMIT, ...await readGraphQuota(graphDirectory, savedGraphs, { adopt: true }) }
|
|
451
453
|
: { paid: true };
|
|
452
454
|
reply(res, 200, { plan, graphs, graphMigrationErrors, definitions: await listAgentDefinitions(directory), defaultProvider: config.provider, providers: providerRegistryPayload(config.providers), tools: [...createTools().filter(tool => tool.providerVisible !== false).map(tool => tool.name), 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'read_skill_resource', 'browser.panel', 'browser.incognito', 'browser.extensions'], runtime: { spawnAvailable: true, rawShellForSubagents: false, browser: true, deployment: false } });
|
|
453
455
|
return;
|
|
@@ -502,7 +504,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
502
504
|
reply(res, 400, { error: 'The bundled default graph cannot be deleted.' });
|
|
503
505
|
return;
|
|
504
506
|
}
|
|
505
|
-
if (id
|
|
507
|
+
if (isReservedGraphId(id)) {
|
|
506
508
|
reply(res, 400, { error: reservedGraphId(id).message });
|
|
507
509
|
return;
|
|
508
510
|
}
|
|
@@ -582,7 +584,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
582
584
|
return;
|
|
583
585
|
}
|
|
584
586
|
const expected = graph.revision === 0 ? null : graph.revision;
|
|
585
|
-
const saved = await freeTier() ? await saveFreeTierGraph(stamped, expected, graphDirectory) : await
|
|
587
|
+
const saved = await freeTier() ? await saveFreeTierGraph(stamped, expected, graphDirectory) : await savePremiumGraph(stamped, expected, graphDirectory);
|
|
586
588
|
await sync?.reviveGraph(saved.id);
|
|
587
589
|
void sync?.sync();
|
|
588
590
|
reply(res, 200, saved);
|
|
@@ -629,7 +631,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
629
631
|
} };
|
|
630
632
|
}
|
|
631
633
|
export async function deleteGraphWithTombstone(id, graphDirectory, directory, subject, sync) {
|
|
632
|
-
if (id
|
|
634
|
+
if (isReservedGraphId(id))
|
|
633
635
|
throw reservedGraphId(id);
|
|
634
636
|
const users = (await new AutomationStore(directory).list()).filter(job => job.execution?.graph === id);
|
|
635
637
|
if (users.length)
|
package/dist/src/graph-sync.js
CHANGED
|
@@ -4,7 +4,7 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
4
4
|
import { join, relative } from 'node:path';
|
|
5
5
|
import { AUTH_REFRESH_BUDGET_MS, getAccessToken, getAuthConfiguration, getAuthStatus } from './auth/index.js';
|
|
6
6
|
import { decodeJwt } from 'jose';
|
|
7
|
-
import {
|
|
7
|
+
import { GraphConflictError, isReservedGraphId, reservedGraphId, restoreGraphRevision, validateGraph } from './graphs.js';
|
|
8
8
|
import { acquireSaveLock, removeLockedFolder, SaveLockBusyError } from './save-lock.js';
|
|
9
9
|
import { readGraphQuota } from './graph-quota.js';
|
|
10
10
|
const MAX_BYTES = 600 * 1024;
|
|
@@ -307,7 +307,7 @@ export class GraphSync {
|
|
|
307
307
|
async forgetGraph(id) {
|
|
308
308
|
if (!safeId(id) || id === 'default')
|
|
309
309
|
throw new Error('Invalid graph id');
|
|
310
|
-
if (id
|
|
310
|
+
if (isReservedGraphId(id))
|
|
311
311
|
throw reservedGraphId(id);
|
|
312
312
|
await mkdir(this.folder, { recursive: true });
|
|
313
313
|
const folder = join(this.directory, 'graphs', id);
|
|
@@ -383,7 +383,7 @@ export class GraphSync {
|
|
|
383
383
|
this.lastDraft.delete(id);
|
|
384
384
|
}
|
|
385
385
|
async reviveGraph(id) {
|
|
386
|
-
if (!safeId(id) || id === 'default' || id
|
|
386
|
+
if (!safeId(id) || id === 'default' || isReservedGraphId(id))
|
|
387
387
|
return;
|
|
388
388
|
await this.updateDeletionState((deleted, _floors, pending) => {
|
|
389
389
|
const changed = deleted.delete(id) || Object.hasOwn(pending, id);
|