@andorra-labs/code 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +4 -2
- package/dist/src/agent-mcp.d.ts +1 -1
- package/dist/src/agent-mcp.js +13 -9
- package/dist/src/app-server/protocol.d.ts +4 -1
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server.d.ts +107 -0
- package/dist/src/app-server.js +893 -22
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +27 -16
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +22 -8
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/command-screens.js +5 -3
- package/dist/src/commands.d.ts +2 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +23 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/graph-health.js +7 -3
- package/dist/src/graph-provider-portability.js +32 -10
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +24 -7
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +9 -7
- package/dist/src/graph-ui/app.js +110 -33
- 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 +1 -0
- 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 +11 -4
- 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 +27 -19
- package/dist/src/graphs.js +4 -3
- package/dist/src/membership.d.ts +20 -1
- package/dist/src/membership.js +29 -4
- package/dist/src/model-metadata.d.ts +1 -1
- package/dist/src/model-metadata.js +4 -2
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/providers.d.ts +17 -0
- package/dist/src/providers.js +68 -19
- 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 +76 -0
- package/dist/src/pull-request-logs.js +172 -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 +43 -2
- package/dist/src/pull-requests.js +112 -21
- package/dist/src/react-runtime.js +37 -4
- package/dist/src/remote/engine-pool.js +16 -4
- package/dist/src/run-control.d.ts +10 -0
- package/dist/src/run-control.js +24 -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 +2 -2
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +14 -2
- 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 +2 -0
- package/dist/src/telemetry/emitter.js +42 -5
- package/dist/src/telemetry/schema.d.ts +22 -0
- package/dist/src/telemetry/schema.js +68 -1
- package/dist/src/telemetry/surface.d.ts +1 -0
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.js +1 -1
- 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 +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROVIDER_TYPES,
|
|
1
|
+
import { findProviderById, PROVIDER_TYPES, providerModelId } from './providers.js';
|
|
2
2
|
const profileKey = 'graphProviderProfilesV1';
|
|
3
3
|
export class GraphProviderUnavailableError extends Error {
|
|
4
4
|
constructor(message) {
|
|
@@ -51,11 +51,11 @@ export function stampGraphProviderProfiles(graph, config, selectedModels = {}) {
|
|
|
51
51
|
for (const reference of references(copy)) {
|
|
52
52
|
if (!reference.provider)
|
|
53
53
|
continue;
|
|
54
|
-
const provider = config.providers
|
|
54
|
+
const provider = findProviderById(config.providers, reference.provider);
|
|
55
55
|
if (!provider)
|
|
56
56
|
continue;
|
|
57
|
-
const selectedModel = Object.hasOwn(selectedModels, reference.provider)
|
|
58
|
-
? selectedModels[
|
|
57
|
+
const selectedModel = Object.hasOwn(selectedModels, reference.provider) ? selectedModels[reference.provider]
|
|
58
|
+
: Object.hasOwn(selectedModels, provider.id) ? selectedModels[provider.id] : undefined;
|
|
59
59
|
if (!selectedModel && Object.hasOwn(saved, reference.provider))
|
|
60
60
|
continue;
|
|
61
61
|
Object.defineProperty(saved, reference.provider, {
|
|
@@ -71,6 +71,9 @@ export function bindPortableGraphProviders(graph, config) {
|
|
|
71
71
|
const copy = structuredClone(graph);
|
|
72
72
|
const saved = profiles(copy);
|
|
73
73
|
const requirements = new Map();
|
|
74
|
+
// Subagent references without a provider of their own run on their node's provider; their model is respelled to it.
|
|
75
|
+
const inheritors = [];
|
|
76
|
+
const resolvedIds = new Map();
|
|
74
77
|
const add = (reference, inheritedModels = [], inheritsParentModel = false) => {
|
|
75
78
|
if (!reference.provider)
|
|
76
79
|
return;
|
|
@@ -100,8 +103,11 @@ export function bindPortableGraphProviders(graph, config) {
|
|
|
100
103
|
const children = policy.modelPolicy === 'per-role' ? policy.roles ?? []
|
|
101
104
|
: policy.modelPolicy === 'specific' ? [policy] : [];
|
|
102
105
|
for (const child of children) {
|
|
103
|
-
if (!child.provider && child.model)
|
|
106
|
+
if (!child.provider && child.model) {
|
|
104
107
|
inherited.push(child.model);
|
|
108
|
+
if (node.provider)
|
|
109
|
+
inheritors.push({ provider: node.provider, reference: child });
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
add(node, inherited);
|
|
@@ -118,13 +124,20 @@ export function bindPortableGraphProviders(graph, config) {
|
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
}
|
|
127
|
+
// A recorded profile is found under any spelling of its id, as the provider itself is.
|
|
128
|
+
const recorded = (id) => {
|
|
129
|
+
if (Object.hasOwn(saved, id))
|
|
130
|
+
return saved[id];
|
|
131
|
+
const matches = Object.keys(saved).filter(key => key.toLowerCase() === id.toLowerCase());
|
|
132
|
+
return matches.length === 1 ? saved[matches[0]] : undefined;
|
|
133
|
+
};
|
|
121
134
|
for (const [originalId, required] of requirements) {
|
|
122
|
-
const original =
|
|
135
|
+
const original = recorded(originalId);
|
|
123
136
|
const explicitModels = [...required.models];
|
|
124
137
|
const requiredModels = original && required.inheritsRecordedModel ? [...explicitModels, original.model] : explicitModels;
|
|
125
|
-
const offers = (provider, models) => models.every(model =>
|
|
138
|
+
const offers = (provider, models) => models.every(model => providerModelId(provider, model) !== undefined);
|
|
126
139
|
const sameType = (provider) => !original || provider.type === original.type;
|
|
127
|
-
const exact = config.providers
|
|
140
|
+
const exact = findProviderById(config.providers, originalId);
|
|
128
141
|
let resolved = exact && sameType(exact) && offers(exact, explicitModels) ? exact : undefined;
|
|
129
142
|
const exactResolved = resolved !== undefined;
|
|
130
143
|
if (!resolved && exact === undefined && original?.type === 'codex') {
|
|
@@ -144,15 +157,24 @@ export function bindPortableGraphProviders(graph, config) {
|
|
|
144
157
|
+ 'Connect the corresponding OAuth provider or configure the same provider ID and models in /providers, '
|
|
145
158
|
+ 'or start the task with a model override so every node runs on one provider.');
|
|
146
159
|
}
|
|
160
|
+
resolvedIds.set(originalId, resolved);
|
|
147
161
|
for (const tracked of required.references) {
|
|
148
162
|
tracked.reference.provider = resolved.id;
|
|
149
163
|
if (tracked.inheritsParentModel && !tracked.reference.model)
|
|
150
164
|
continue;
|
|
151
|
-
if (tracked.reference.model)
|
|
165
|
+
if (tracked.reference.model) {
|
|
166
|
+
// The request names the model as this machine's provider spells it.
|
|
167
|
+
tracked.reference.model = providerModelId(resolved, tracked.reference.model) ?? tracked.reference.model;
|
|
152
168
|
continue;
|
|
169
|
+
}
|
|
153
170
|
if (!exactResolved && original?.model)
|
|
154
|
-
tracked.reference.model = original.model;
|
|
171
|
+
tracked.reference.model = providerModelId(resolved, original.model) ?? original.model;
|
|
155
172
|
}
|
|
156
173
|
}
|
|
174
|
+
for (const { provider, reference } of inheritors) {
|
|
175
|
+
const resolved = resolvedIds.get(provider);
|
|
176
|
+
if (resolved && reference.model)
|
|
177
|
+
reference.model = providerModelId(resolved, reference.model) ?? reference.model;
|
|
178
|
+
}
|
|
157
179
|
return copy;
|
|
158
180
|
}
|
|
@@ -5,16 +5,43 @@ export declare const FREE_GRAPH_NODE_LIMIT = 3;
|
|
|
5
5
|
export declare const FREE_GRAPH_LIMIT_MESSAGE = "The free tier includes 1 custom graph. Upgrade to Premium to create more graphs.";
|
|
6
6
|
export declare const FREE_NODE_LIMIT_MESSAGE = "Free tier graphs can have up to 3 nodes, not counting Done. Upgrade to Premium for larger graphs.";
|
|
7
7
|
export declare const FREE_ORCHESTRATOR_MESSAGE = "The Orchestrator is a Premium feature. Free tier graphs can use the other agent nodes.";
|
|
8
|
-
export declare const FREE_LOCKED_GRAPH_MESSAGE = "
|
|
8
|
+
export declare 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.";
|
|
9
9
|
export declare function countedGraphNodes(graph: Pick<Graph, 'nodes'>): number;
|
|
10
10
|
export declare function freeTierGraphViolation(graph: Pick<Graph, 'nodes'>): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* A graph saved by a free account carries `metadata.freeTier: true`, and one saved by a Premium
|
|
13
|
+
* account carries `false`, so which plan made a graph travels with it to another machine.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isFreeTierGraph(graph: Pick<Graph, 'metadata'>): boolean;
|
|
11
16
|
export interface GraphQuota {
|
|
12
17
|
customGraphs: number;
|
|
18
|
+
/** The one graph a free account may change and run. Absent when every saved graph is view only. */
|
|
13
19
|
freeGraphId?: string;
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
/** Records that a Premium account used this graph folder, so its graphs lock when the account is later free. */
|
|
22
|
+
export declare function notePremiumGraphAccount(directory: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Which saved graph is the free account's own.
|
|
25
|
+
*
|
|
26
|
+
* It is the oldest graph that fits the free limits and either carries the free mark or is the one
|
|
27
|
+
* this folder recorded. A folder no Premium account has used, and that has recorded nothing, keeps
|
|
28
|
+
* its oldest graph that fits: that is the graph a free account owned before graphs carried a mark. `adopt`
|
|
29
|
+
* writes that choice down, so a later upgrade and downgrade does not lose it; pass it only for an
|
|
30
|
+
* account the service confirmed as free.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readGraphQuota(directory: string, graphs?: Graph[], options?: {
|
|
33
|
+
adopt?: boolean;
|
|
34
|
+
}): Promise<GraphQuota>;
|
|
16
35
|
export declare function assertFreeTierSave(graph: Graph, isNew: boolean, directory: string): Promise<void>;
|
|
17
36
|
export declare function saveFreeTierGraph(graph: Graph, expectedRevision: number | null, directory: string): Promise<Graph>;
|
|
37
|
+
/**
|
|
38
|
+
* Saves for a Premium account, marking the graph as made on Premium. The account's own free graph
|
|
39
|
+
* keeps its mark while it fits the free limits, so it is still the free graph after a downgrade.
|
|
40
|
+
* Growing it past the limits gives the mark up for good, as the storage service gives up its pin:
|
|
41
|
+
* shrinking it later must not take the allowance back from the graph that replaced it.
|
|
42
|
+
*/
|
|
43
|
+
export declare function savePremiumGraph(graph: Graph, expectedRevision: number | null, directory: string): Promise<Graph>;
|
|
44
|
+
/** The graph a free account may run: its own graph, within the free limits. Every other saved graph is view only. */
|
|
18
45
|
export declare function loadFreeTierGraph(id: string, directory: string): Promise<Graph>;
|
|
19
46
|
export declare class FreeTierLimitError extends PaidMembershipRequiredError {
|
|
20
47
|
readonly code = "FREE_TIER_LIMIT";
|
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
|
@@ -23,15 +23,23 @@ 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';
|
|
28
30
|
function absorbTelemetry(result, outcome) {
|
|
31
|
+
// Every branch's errors are kept; why the run stopped is taken from the one outcome it ends on (endOn).
|
|
29
32
|
if (outcome.telemetry)
|
|
30
33
|
mergeRunTelemetry(result.telemetry, outcome.telemetry);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
}
|
|
35
|
+
/** The run ends on this outcome: its error code and failure evidence, not another branch's, say why it stopped. */
|
|
36
|
+
function endOn(result, outcome) {
|
|
37
|
+
for (const field of ['failureCode', 'providerRequestFailed', 'providerOverflow']) {
|
|
38
|
+
if (outcome[field] === undefined)
|
|
39
|
+
delete result[field];
|
|
40
|
+
else
|
|
41
|
+
result[field] = outcome[field];
|
|
42
|
+
}
|
|
35
43
|
}
|
|
36
44
|
const freeze = (value) => {
|
|
37
45
|
for (const child of Object.values(value))
|
|
@@ -266,8 +274,7 @@ export async function runGraph(graph, options) {
|
|
|
266
274
|
?? { nodeId: checkpoint.nodeId, generation: checkpoint.generation ?? 0, path: [], inputs: {}, predecessors: {} };
|
|
267
275
|
if (!continuableByThisRun(checkpoint.nodeId, checkpoint))
|
|
268
276
|
continue;
|
|
269
|
-
|
|
270
|
-
if (toolEvent !== undefined && Date.parse(checkpoint.savedAt) < Date.parse(toolEvent)) {
|
|
277
|
+
if (toolBoundaryOpen(checkpoint, progress)) {
|
|
271
278
|
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
279
|
}
|
|
273
280
|
const routed = routedContinuation(checkpoint.nodeId, checkpoint);
|
|
@@ -741,6 +748,7 @@ export async function runGraph(graph, options) {
|
|
|
741
748
|
result.model = failed.model;
|
|
742
749
|
result.status = failed.status;
|
|
743
750
|
result.reason = failed.reason ?? failed.status;
|
|
751
|
+
endOn(result, failed);
|
|
744
752
|
if (failed.limits)
|
|
745
753
|
result.limits = runClockBounds(failed.limits, result.reason, failedActivation.nodeId);
|
|
746
754
|
break;
|
|
@@ -790,6 +798,7 @@ export async function runGraph(graph, options) {
|
|
|
790
798
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
791
799
|
result.status = cancelled ? 'cancelled' : budget.expired() ? 'exhausted' : outcome.status;
|
|
792
800
|
result.reason = cancelled ? 'cancelled' : budget.expired() ? 'wallTimeMs' : outcome.reason ?? outcome.status;
|
|
801
|
+
endOn(result, outcome);
|
|
793
802
|
if (outcome.limits)
|
|
794
803
|
result.limits = runClockBounds(outcome.limits, result.reason, nodeId);
|
|
795
804
|
break;
|
|
@@ -1007,6 +1016,7 @@ export async function runGraph(graph, options) {
|
|
|
1007
1016
|
if (continuation.status !== 'succeeded' || !continuation.completion) {
|
|
1008
1017
|
result.status = continuation.status;
|
|
1009
1018
|
result.reason = continuation.reason ?? continuation.status;
|
|
1019
|
+
endOn(result, continuation);
|
|
1010
1020
|
break;
|
|
1011
1021
|
}
|
|
1012
1022
|
const condition = pinned.nodes[lastAgentActivation.nodeId].modifiers?.condition;
|
|
@@ -1087,6 +1097,13 @@ export async function runGraph(graph, options) {
|
|
|
1087
1097
|
const deadline = budget.expired() || signal.aborted;
|
|
1088
1098
|
result.status = cancelled ? 'cancelled' : deadline ? 'exhausted' : 'infrastructure_error';
|
|
1089
1099
|
result.reason = cancelled ? 'cancelled' : deadline ? 'wallTimeMs' : error instanceof Error ? error.message : 'Graph runtime failure';
|
|
1100
|
+
if (cancelled || deadline)
|
|
1101
|
+
endOn(result, {});
|
|
1102
|
+
else
|
|
1103
|
+
endOn(result, {
|
|
1104
|
+
failureCode: recordErrorOnce(result.telemetry ??= createRunTelemetry(), error, runFailureCode(error)),
|
|
1105
|
+
...(error instanceof ProviderRequestError ? { providerRequestFailed: true, ...(error.contextOverflow ? { providerOverflow: true } : {}) } : {}),
|
|
1106
|
+
});
|
|
1090
1107
|
}
|
|
1091
1108
|
try {
|
|
1092
1109
|
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, GRAPH_MANAGER_GRAPH_ID, 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;
|
|
@@ -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);
|