@andorra-labs/code 0.1.16 → 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-execution.js +11 -8
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +3 -0
- package/dist/src/agent-mcp.js +33 -1
- 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 +19 -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 +358 -32
- package/dist/src/app-server.js +2429 -509
- 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-server.js +7 -1
- package/dist/src/browser-ui/tokens.css +1 -1
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/cli.js +182 -32
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +14 -11
- package/dist/src/commands.d.ts +14 -2
- package/dist/src/compaction-phrases.js +1 -1
- 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/deadline.js +13 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.js +0 -1
- 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-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 +6 -1
- 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 +2 -1
- package/dist/src/graph-runner.js +64 -3
- package/dist/src/graph-server.js +3 -3
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +91 -7
- package/dist/src/graph-ui/icons.js +2 -1
- package/dist/src/graph-ui/studio.js +15 -1
- package/dist/src/graph-ui/tokens.css +1 -1
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +158 -14
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +10 -0
- package/dist/src/membership.js +19 -4
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +6 -0
- package/dist/src/model-metadata.js +35 -15
- 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/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +23 -2
- package/dist/src/providers.js +25 -4
- package/dist/src/pull-request-logs.d.ts +12 -1
- package/dist/src/pull-request-logs.js +14 -3
- package/dist/src/pull-requests.d.ts +327 -7
- package/dist/src/pull-requests.js +429 -51
- package/dist/src/react-runtime.js +1 -1
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +366 -89
- 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 +7 -0
- package/dist/src/run-control.js +23 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +10 -2
- 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/telemetry/emitter.d.ts +15 -0
- package/dist/src/telemetry/emitter.js +35 -1
- package/dist/src/telemetry/schema.d.ts +25 -2
- package/dist/src/telemetry/schema.js +52 -4
- package/dist/src/telemetry/surface.d.ts +2 -1
- package/dist/src/telemetry/surface.js +4 -1
- 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/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
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
4
|
+
export const GLOB_LIST_LIMIT = 400_000;
|
|
5
|
+
export const GLOB_WALK_ENTRY_LIMIT = 200_000;
|
|
6
|
+
export const GLOB_TIME_MS = 20_000;
|
|
7
|
+
const MAGIC = /[*?[\]{}()!]/;
|
|
8
|
+
/**
|
|
9
|
+
* Splits a pattern into the directory its matches must lie in and the rest. `src/**\/*.ts` can only
|
|
10
|
+
* match under `src`, so the listing starts there instead of at the workspace root. A pattern with no
|
|
11
|
+
* slash matches a file name at any depth and has no such directory.
|
|
12
|
+
*/
|
|
13
|
+
export function splitGlobPrefix(pattern) {
|
|
14
|
+
const normal = (process.platform === 'win32' ? pattern.replace(/\\/g, '/') : pattern).replace(/^(?:\.\/)+/, '');
|
|
15
|
+
if (!normal.includes('/'))
|
|
16
|
+
return { prefix: '', rest: normal, anyDepth: true };
|
|
17
|
+
const segments = normal.split('/');
|
|
18
|
+
let literal = 0;
|
|
19
|
+
while (literal < segments.length - 1 && !MAGIC.test(segments[literal]))
|
|
20
|
+
literal++;
|
|
21
|
+
const prefix = segments.slice(0, literal).join('/') || (normal.startsWith('/') && literal > 0 ? '/' : '');
|
|
22
|
+
return { prefix, rest: segments.slice(literal).join('/'), anyDepth: false };
|
|
23
|
+
}
|
|
24
|
+
function listWithRipgrep(rg, cwd, includeIgnored, accept, input) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
// NUL-separated output: a file name may hold a newline or end in a carriage return.
|
|
27
|
+
// --no-config: a filter in the user's own ripgrep configuration would hide files with no notice.
|
|
28
|
+
const args = [...(input.rgPrefix ?? []), '--no-config', '--files', '--null', '--hidden', '--no-require-git', '--sort', 'path', '--glob', '!.git', '--glob', '!node_modules', '--glob', '!.andorracode'];
|
|
29
|
+
if (includeIgnored)
|
|
30
|
+
args.push('--no-ignore');
|
|
31
|
+
const child = spawn(rg, args, { cwd, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
|
|
32
|
+
const decoder = new StringDecoder('utf8');
|
|
33
|
+
const listing = { matches: [], more: false };
|
|
34
|
+
let listed = 0, settled = false, stopped = false, pending = '';
|
|
35
|
+
const stop = () => { stopped = true; if (child.exitCode === null)
|
|
36
|
+
child.kill(); };
|
|
37
|
+
const timer = setTimeout(() => { listing.incomplete = `stopped after ${(input.timeMs ?? GLOB_TIME_MS) / 1000} seconds with ${listed.toLocaleString('en-US')} files listed`; stop(); }, input.timeMs ?? GLOB_TIME_MS);
|
|
38
|
+
const onAbort = () => stop();
|
|
39
|
+
input.signal.addEventListener('abort', onAbort, { once: true });
|
|
40
|
+
const finish = (run) => {
|
|
41
|
+
if (settled)
|
|
42
|
+
return;
|
|
43
|
+
settled = true;
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
input.signal.removeEventListener('abort', onAbort);
|
|
46
|
+
run();
|
|
47
|
+
};
|
|
48
|
+
const take = (name) => {
|
|
49
|
+
if (stopped || !name)
|
|
50
|
+
return;
|
|
51
|
+
const relative = name.split(path.sep).join('/').replace(/^\.\//, '');
|
|
52
|
+
if (++listed > (input.listLimit ?? GLOB_LIST_LIMIT)) {
|
|
53
|
+
listing.incomplete = `stopped at the ${(input.listLimit ?? GLOB_LIST_LIMIT).toLocaleString('en-US')}-file listing limit`;
|
|
54
|
+
stop();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!accept(relative) || (input.keep && !input.keep([relative], cwd).length))
|
|
58
|
+
return;
|
|
59
|
+
listing.matches.push(path.join(cwd, relative));
|
|
60
|
+
if (listing.matches.length >= input.limit) {
|
|
61
|
+
listing.more = true;
|
|
62
|
+
stop();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
child.stdout.on('data', (chunk) => {
|
|
66
|
+
const parts = (pending + decoder.write(chunk)).split('\0');
|
|
67
|
+
pending = parts.pop() ?? '';
|
|
68
|
+
for (const part of parts)
|
|
69
|
+
take(part);
|
|
70
|
+
});
|
|
71
|
+
child.once('error', () => finish(() => resolve({ matches: [], more: false, failed: true })));
|
|
72
|
+
child.once('close', code => finish(() => {
|
|
73
|
+
if (input.signal.aborted) {
|
|
74
|
+
reject(input.signal.reason instanceof Error ? input.signal.reason : new Error('Operation aborted'));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!stopped && code !== 0 && code !== 1) {
|
|
78
|
+
// Exit 2 covers a directory ripgrep could not read. Nothing listed means it did not run usefully;
|
|
79
|
+
// otherwise what it listed is good, but the part it skipped may hold the file.
|
|
80
|
+
if (!listed) {
|
|
81
|
+
resolve({ matches: [], more: false, failed: true });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
listing.incomplete ??= 'ripgrep could not read part of the directory tree';
|
|
85
|
+
}
|
|
86
|
+
resolve(listing);
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function listWithWalk(cwd, accept, input) {
|
|
91
|
+
const listing = { matches: [], more: false };
|
|
92
|
+
const deadline = Date.now() + (input.timeMs ?? GLOB_TIME_MS);
|
|
93
|
+
const budget = { entries: 0, limit: GLOB_WALK_ENTRY_LIMIT };
|
|
94
|
+
try {
|
|
95
|
+
for await (const name of input.walk(cwd, budget)) {
|
|
96
|
+
input.signal.throwIfAborted();
|
|
97
|
+
if (Date.now() > deadline) {
|
|
98
|
+
listing.incomplete = `stopped after ${(input.timeMs ?? GLOB_TIME_MS) / 1000} seconds with ${budget.entries.toLocaleString('en-US')} entries scanned`;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
const relative = path.relative(cwd, name).split(path.sep).join('/');
|
|
102
|
+
if (!accept(relative))
|
|
103
|
+
continue;
|
|
104
|
+
listing.matches.push(name);
|
|
105
|
+
if (listing.matches.length >= input.limit) {
|
|
106
|
+
listing.more = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
input.signal.throwIfAborted();
|
|
113
|
+
if (!(error instanceof Error) || !/^Directory scan limit reached/.test(error.message))
|
|
114
|
+
throw error;
|
|
115
|
+
listing.incomplete = `stopped at the ${GLOB_WALK_ENTRY_LIMIT.toLocaleString('en-US')}-entry directory scan limit`;
|
|
116
|
+
}
|
|
117
|
+
return listing;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Finds files by glob. The listing starts in the directory the pattern names, leaves out what ignore
|
|
121
|
+
* rules exclude, and falls back to ignored files when nothing else matches, so a miss means the file
|
|
122
|
+
* is absent rather than hidden. A listing that stops early returns what it found and says so.
|
|
123
|
+
*/
|
|
124
|
+
export async function globSearch(input) {
|
|
125
|
+
input.signal.throwIfAborted();
|
|
126
|
+
const { prefix, rest, anyDepth } = splitGlobPrefix(input.pattern);
|
|
127
|
+
let cwd = input.root;
|
|
128
|
+
if (prefix) {
|
|
129
|
+
try {
|
|
130
|
+
cwd = await input.resolve(path.resolve(input.root, prefix));
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
input.signal.throwIfAborted();
|
|
134
|
+
if (error?.code === 'ENOENT' || /ENOENT|no such file or directory/i.test(error instanceof Error ? error.message : '')) {
|
|
135
|
+
return { matches: [], more: false, ignoredOnly: false, searchedIgnored: true };
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const accept = (relative) => path.matchesGlob(relative, rest) || (anyDepth && path.matchesGlob(path.posix.basename(relative), rest));
|
|
141
|
+
if (input.rg) {
|
|
142
|
+
const tracked = await listWithRipgrep(input.rg, cwd, false, accept, input);
|
|
143
|
+
if (!tracked.failed) {
|
|
144
|
+
if (tracked.matches.length)
|
|
145
|
+
return { matches: tracked.matches, more: tracked.more, ...(tracked.incomplete ? { incomplete: tracked.incomplete } : {}), ignoredOnly: false, searchedIgnored: false };
|
|
146
|
+
const everything = await listWithRipgrep(input.rg, cwd, true, accept, input);
|
|
147
|
+
if (!everything.failed) {
|
|
148
|
+
const incomplete = everything.incomplete ?? tracked.incomplete;
|
|
149
|
+
return { matches: everything.matches, more: everything.more, ...(incomplete ? { incomplete } : {}), ignoredOnly: everything.matches.length > 0, searchedIgnored: true };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const walked = await listWithWalk(cwd, accept, input);
|
|
154
|
+
return { matches: walked.matches, more: walked.more, ...(walked.incomplete ? { incomplete: walked.incomplete } : {}), ignoredOnly: false, searchedIgnored: true };
|
|
155
|
+
}
|
|
156
|
+
/** The text a model reads for a search: paths relative to root, then what it must know about their coverage. */
|
|
157
|
+
export function formatGlobResult(result, root, limit) {
|
|
158
|
+
const shown = result.matches.map(match => path.relative(root, match).split(path.sep).join('/') || path.basename(match));
|
|
159
|
+
const notices = [];
|
|
160
|
+
if (result.more)
|
|
161
|
+
notices.push(`[${limit} results limit reached: raise head_limit or narrow the pattern]`);
|
|
162
|
+
if (result.ignoredOnly)
|
|
163
|
+
notices.push('[Only ignored files match: nothing else in the search matched, so these come from paths that .gitignore or similar rules exclude.]');
|
|
164
|
+
if (result.incomplete)
|
|
165
|
+
notices.push(`[INCOMPLETE SEARCH: ${result.incomplete}. Files that were not listed may match, so this result does not show that the file is absent. Narrow it with path, or start the pattern with a directory.]`);
|
|
166
|
+
const body = shown.length ? shown.join('\n')
|
|
167
|
+
: result.incomplete ? 'No files found in the part that was listed before the search stopped.'
|
|
168
|
+
: `No files found matching pattern${result.searchedIgnored ? '' : ' outside ignored paths'}`;
|
|
169
|
+
return notices.length ? `${body}\n\n${notices.join('\n')}` : body;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The matches of a search for a caller that can only show a plain list of paths. Such a caller has nowhere to
|
|
173
|
+
* say that the listing stopped early, so an unfinished search fails, carrying what was found, instead of
|
|
174
|
+
* passing for a complete answer.
|
|
175
|
+
*/
|
|
176
|
+
export function completeGlobMatches(result, root, limit) {
|
|
177
|
+
if (result.incomplete)
|
|
178
|
+
throw new Error(formatGlobResult(result, root, limit));
|
|
179
|
+
return result.matches;
|
|
180
|
+
}
|
package/dist/src/graph-health.js
CHANGED
|
@@ -115,6 +115,11 @@ export async function checkGraphModelHealth(graph, config, signal, dependencies
|
|
|
115
115
|
failures[index] = { ...reference, reason: 'Provider is not configured.' };
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
+
// A relayed model is on the desktop: no probe is sent there, and its first real request shows its health.
|
|
119
|
+
if (provider.type === 'relayed') {
|
|
120
|
+
answered[index] = true;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
118
123
|
if (provider.type === 'andorra') {
|
|
119
124
|
// The client has the router's fresh answer (or asks it once now): no model request is sent to learn it again.
|
|
120
125
|
const known = await Promise.resolve(dependencies.andorra?.()).catch(() => undefined);
|
|
@@ -218,7 +223,7 @@ export async function checkSessionModelHealth(config, signal, dependencies = {})
|
|
|
218
223
|
const model = provider?.model ?? '(default model)';
|
|
219
224
|
if (!provider)
|
|
220
225
|
return { healthy: false, failures: [{ provider: config.provider, model, nodes, reason: 'Provider is not configured.' }] };
|
|
221
|
-
if (dependencies.verified?.has(provider, model))
|
|
226
|
+
if (provider.type === 'relayed' || dependencies.verified?.has(provider, model))
|
|
222
227
|
return { healthy: true, failures: [] };
|
|
223
228
|
const timeoutMs = dependencies.timeoutMs ?? 30_000;
|
|
224
229
|
// Andorra is asked once, by the probe: its refusals are sentences a model listing would not carry.
|
|
@@ -114,7 +114,7 @@ const GRAPH_ACTION_VERBS = {
|
|
|
114
114
|
andorra_graph_node_upsert: 'Set step', andorra_graph_node_patch: 'Edit step', andorra_graph_node_remove: 'Remove step',
|
|
115
115
|
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit graph',
|
|
116
116
|
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save version', andorra_graph_discard: 'Discard draft',
|
|
117
|
-
andorra_graph_delete: 'Delete graph', andorra_graph_restore: 'Restore graph',
|
|
117
|
+
andorra_graph_delete: 'Delete graph', andorra_graph_restore: 'Restore graph', andorra_graph_show: 'Show graph',
|
|
118
118
|
};
|
|
119
119
|
export function managerToolParts(name, value, openGraphId) {
|
|
120
120
|
const args = toolArguments(value);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Graph, type GraphNode } from './graphs.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the desktop app needs to draw a graph in a chat reply the way the Graph Editor draws it: each step's
|
|
4
|
+
* card (name, kind, model line, outcome ports, position) and each route. Instructions, schemas and every other
|
|
5
|
+
* setting stay out, so the preview stays small enough to travel in a tool reply.
|
|
6
|
+
*/
|
|
7
|
+
export interface GraphPreviewNode {
|
|
8
|
+
name: string;
|
|
9
|
+
type: GraphNode['type'];
|
|
10
|
+
agentRole?: 'orchestrator';
|
|
11
|
+
provider?: string;
|
|
12
|
+
model?: string;
|
|
13
|
+
/** Omitted when it is exactly ['completed'], the usual single port, to keep large previews small. */
|
|
14
|
+
outcomes?: string[];
|
|
15
|
+
/** An Action's kind, which names it on its card (Run command, Run tests, Git operation). */
|
|
16
|
+
action?: 'command' | 'tests' | 'git';
|
|
17
|
+
position?: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface GraphPreview {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
/** 'draft' for an unpublished draft, otherwise the published revision shown. */
|
|
26
|
+
revision: number | 'draft';
|
|
27
|
+
/** A soft-deleted graph's revision, shown read-only. */
|
|
28
|
+
deleted?: true;
|
|
29
|
+
entry: string;
|
|
30
|
+
nodes: Record<string, GraphPreviewNode>;
|
|
31
|
+
edges: {
|
|
32
|
+
source: string;
|
|
33
|
+
outcome: string;
|
|
34
|
+
target: string;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
/** The ports a step's card shows, as the editor lists them (src/graph-ui/app.js `outcomes`): an Action always shows its failed port. */
|
|
38
|
+
export declare function previewOutcomes(node: GraphNode): string[];
|
|
39
|
+
/**
|
|
40
|
+
* `modelOf` names a provider's default model; called with undefined for a step that names no provider, it answers
|
|
41
|
+
* for the active one, as the editor's card does (app.js `nodeModelLabel`). A step's own provider is kept only when
|
|
42
|
+
* no model could be named, since the card shows one or the other.
|
|
43
|
+
*/
|
|
44
|
+
export declare function graphPreview(graph: Graph, revision: number | 'draft', modelOf?: (provider: string | undefined) => string | undefined): GraphPreview;
|
|
45
|
+
/** The same graph as plain text, for a host that cannot draw it: one line per route, the entry first. */
|
|
46
|
+
export declare function graphSketch(preview: GraphPreview): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { nodeOutcomes, optionalOutcomes } from './graphs.js';
|
|
2
|
+
/** The ports a step's card shows, as the editor lists them (src/graph-ui/app.js `outcomes`): an Action always shows its failed port. */
|
|
3
|
+
export function previewOutcomes(node) {
|
|
4
|
+
const outcomes = nodeOutcomes(node);
|
|
5
|
+
return [...outcomes, ...optionalOutcomes(node).filter(outcome => !outcomes.includes(outcome))];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `modelOf` names a provider's default model; called with undefined for a step that names no provider, it answers
|
|
9
|
+
* for the active one, as the editor's card does (app.js `nodeModelLabel`). A step's own provider is kept only when
|
|
10
|
+
* no model could be named, since the card shows one or the other.
|
|
11
|
+
*/
|
|
12
|
+
export function graphPreview(graph, revision, modelOf = () => undefined) {
|
|
13
|
+
const nodes = {};
|
|
14
|
+
for (const [id, node] of Object.entries(graph.nodes)) {
|
|
15
|
+
const model = node.type === 'agent' ? node.model ?? modelOf(node.provider) : undefined;
|
|
16
|
+
const outcomes = previewOutcomes(node);
|
|
17
|
+
nodes[id] = {
|
|
18
|
+
name: node.name || id,
|
|
19
|
+
type: node.type,
|
|
20
|
+
...(node.agentRole === 'orchestrator' ? { agentRole: 'orchestrator' } : {}),
|
|
21
|
+
...(node.type === 'agent' && node.provider && !model ? { provider: node.provider } : {}),
|
|
22
|
+
...(model ? { model } : {}),
|
|
23
|
+
...(outcomes.length === 1 && outcomes[0] === 'completed' ? {} : { outcomes }),
|
|
24
|
+
...(node.type === 'action' && node.action?.kind ? { action: node.action.kind } : {}),
|
|
25
|
+
...(node.position && Number.isFinite(node.position.x) && Number.isFinite(node.position.y) ? { position: { x: node.position.x, y: node.position.y } } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
id: graph.id, name: graph.name, revision, entry: graph.entry, nodes,
|
|
30
|
+
edges: graph.edges.filter(edge => Object.hasOwn(nodes, edge.source) && Object.hasOwn(nodes, edge.target))
|
|
31
|
+
.map(edge => ({ source: edge.source, outcome: edge.outcome ?? 'completed', target: edge.target })),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** The same graph as plain text, for a host that cannot draw it: one line per route, the entry first. */
|
|
35
|
+
export function graphSketch(preview) {
|
|
36
|
+
const label = (id) => {
|
|
37
|
+
const node = preview.nodes[id];
|
|
38
|
+
if (!node)
|
|
39
|
+
return id;
|
|
40
|
+
const kind = node.agentRole === 'orchestrator' ? 'orchestrator' : node.type;
|
|
41
|
+
const detail = node.model ?? node.provider;
|
|
42
|
+
return `${id} (${kind}${detail ? `, ${detail}` : ''})`;
|
|
43
|
+
};
|
|
44
|
+
const order = [preview.entry, ...Object.keys(preview.nodes).filter(id => id !== preview.entry)];
|
|
45
|
+
const lines = [`${preview.name} (${preview.id}, ${preview.revision === 'draft' ? 'draft' : `revision ${preview.revision}`}${preview.deleted ? ', deleted' : ''}), starts at ${preview.entry || '(no entry)'}`];
|
|
46
|
+
for (const id of order) {
|
|
47
|
+
for (const edge of preview.edges.filter(item => item.source === id))
|
|
48
|
+
lines.push(`${label(edge.source)} --${edge.outcome}--> ${label(edge.target)}`);
|
|
49
|
+
}
|
|
50
|
+
const routed = new Set(preview.edges.flatMap(edge => [edge.source, edge.target]));
|
|
51
|
+
for (const id of order)
|
|
52
|
+
if (!routed.has(id))
|
|
53
|
+
lines.push(`${label(id)} (no routes)`);
|
|
54
|
+
return lines.join('\n');
|
|
55
|
+
}
|
|
@@ -136,7 +136,8 @@ export function bindPortableGraphProviders(graph, config) {
|
|
|
136
136
|
const explicitModels = [...required.models];
|
|
137
137
|
const requiredModels = original && required.inheritsRecordedModel ? [...explicitModels, original.model] : explicitModels;
|
|
138
138
|
const offers = (provider, models) => models.every(model => providerModelId(provider, model) !== undefined);
|
|
139
|
-
|
|
139
|
+
// A relayed provider is the desktop's own entry under its own id, whatever type the desktop saved it as.
|
|
140
|
+
const sameType = (provider) => !original || provider.type === 'relayed' || provider.type === original.type;
|
|
140
141
|
const exact = findProviderById(config.providers, originalId);
|
|
141
142
|
let resolved = exact && sameType(exact) && offers(exact, explicitModels) ? exact : undefined;
|
|
142
143
|
const exactResolved = resolved !== undefined;
|
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';
|
|
@@ -27,6 +27,7 @@ import { toolBoundaryOpen } from './run-progress.js';
|
|
|
27
27
|
import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordErrorOnce, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
|
|
28
28
|
import { ProviderRequestError, runFailureCode } from './providers.js';
|
|
29
29
|
import { isTestCommandLine } from './telemetry/classify.js';
|
|
30
|
+
import { reviewNodeUnavailable } from './github-app/review-node.js';
|
|
30
31
|
function absorbTelemetry(result, outcome) {
|
|
31
32
|
// Every branch's errors are kept; why the run stopped is taken from the one outcome it ends on (endOn).
|
|
32
33
|
if (outcome.telemetry)
|
|
@@ -62,7 +63,24 @@ function mergeInputs(target, incoming, nodeId) {
|
|
|
62
63
|
target[key] = value;
|
|
63
64
|
}
|
|
64
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
|
+
}
|
|
65
81
|
export async function runGraph(graph, options) {
|
|
82
|
+
if (isolatedGraph(graph.id))
|
|
83
|
+
options = await isolatedRunOptions(options);
|
|
66
84
|
if (options.goalCompletionVerification && !graphCanCheckGoal(graph))
|
|
67
85
|
throw new Error(GOAL_NEEDS_AGENT);
|
|
68
86
|
const removedMemorySettings = [];
|
|
@@ -930,13 +948,49 @@ export async function runGraph(graph, options) {
|
|
|
930
948
|
if (!interrupted && !exitFailure)
|
|
931
949
|
await emit('node.tool.completed', { nodeId, name: shellName, toolCallId, durationMs, output });
|
|
932
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
|
+
}
|
|
933
986
|
else if (node.type === 'parallel' || node.type === 'join')
|
|
934
987
|
completion.output = activation.inputs;
|
|
935
988
|
if (nodeOutputSchema(node))
|
|
936
989
|
validateValue(nodeOutputSchema(node), completion.output, `Node ${nodeId} output`);
|
|
937
990
|
signal.throwIfAborted();
|
|
938
991
|
result.nodeResults[nodeId] = completion;
|
|
939
|
-
|
|
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')
|
|
940
994
|
lastCompletion = completion;
|
|
941
995
|
if (!prefetchedCompleted.has(activation))
|
|
942
996
|
await emit('graph.node.completed', { nodeId, completion });
|
|
@@ -958,8 +1012,15 @@ export async function runGraph(graph, options) {
|
|
|
958
1012
|
continue;
|
|
959
1013
|
const inputs = resolveMapping(edge.inputMapping, { source: completion, run: { input: runInput, state: runState, loop: { iteration: count } } }, target.inputSchema);
|
|
960
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 } };
|
|
961
|
-
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') {
|
|
962
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;
|
|
963
1024
|
if (target.type === 'join' && target.join?.mode !== 'any' && !edge.bootstrap) {
|
|
964
1025
|
const pending = pendingJoins.get(targetKey) ?? new Map();
|
|
965
1026
|
pending.set(edgeIndex, incoming);
|
package/dist/src/graph-server.js
CHANGED
|
@@ -6,7 +6,7 @@ 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, saveGraphOrder, validateGraph, migrateGraphForEditor, deleteGraph, isDeletedGraph, withoutDeletedGraphs,
|
|
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';
|
|
@@ -504,7 +504,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
504
504
|
reply(res, 400, { error: 'The bundled default graph cannot be deleted.' });
|
|
505
505
|
return;
|
|
506
506
|
}
|
|
507
|
-
if (id
|
|
507
|
+
if (isReservedGraphId(id)) {
|
|
508
508
|
reply(res, 400, { error: reservedGraphId(id).message });
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
@@ -631,7 +631,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
631
631
|
} };
|
|
632
632
|
}
|
|
633
633
|
export async function deleteGraphWithTombstone(id, graphDirectory, directory, subject, sync) {
|
|
634
|
-
if (id
|
|
634
|
+
if (isReservedGraphId(id))
|
|
635
635
|
throw reservedGraphId(id);
|
|
636
636
|
const users = (await new AutomationStore(directory).list()).filter(job => job.execution?.graph === id);
|
|
637
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);
|