@andorra-labs/code 0.1.9 → 0.1.10
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-execution.js +20 -0
- package/dist/src/app-server/protocol.d.ts +108 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server.d.ts +25 -0
- package/dist/src/app-server.js +156 -11
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/browser-ui/app.js +19 -19
- package/dist/src/browser-ui/index.html +7 -7
- package/dist/src/cli.js +10 -5
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.js +1 -1
- package/dist/src/completion.d.ts +1 -1
- package/dist/src/completion.js +1 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.js +15 -15
- package/dist/src/graph-server.js +9 -9
- package/dist/src/graph-ui/app.js +123 -118
- package/dist/src/graph-ui/embed.js +9 -9
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +3 -3
- package/dist/src/graph-ui/manager.js +14 -14
- package/dist/src/graph-ui/skill-picker.js +6 -6
- package/dist/src/graph-ui/studio-canvas.js +15 -15
- package/dist/src/graph-ui/studio.js +40 -40
- package/dist/src/graph-ui/style.css +3 -1
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graphs.d.ts +7 -1
- package/dist/src/graphs.js +12 -2
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.js +1 -1
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/qa/guidance.js +6 -19
- package/dist/src/qa/index.d.ts +0 -2
- package/dist/src/qa/index.js +0 -2
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.js +13 -2
- package/dist/src/remote/engine-pool.js +18 -6
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +117 -0
- package/dist/src/session-changes.js +796 -0
- package/dist/src/stall-recovery.d.ts +11 -0
- package/dist/src/stall-recovery.js +12 -0
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +64 -20
- package/dist/src/terminal-ui.js +310 -80
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +26 -2
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +14 -2
- package/dist/src/types.d.ts +6 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/tui.md +9 -9
- package/package.json +1 -1
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { diffArrays } from 'diff';
|
|
2
|
+
/** Past this size a side is not line-diffed: the write limit of the file tools. */
|
|
3
|
+
export const DIFF_BYTE_LIMIT = 8 * 1024 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* Past this many lines on either side a text is not split into lines: a newline-dense file inside the byte
|
|
6
|
+
* limit would otherwise cost one string per line before any bound applies.
|
|
7
|
+
*/
|
|
8
|
+
export const DIFF_LINE_LIMIT = 200_000;
|
|
9
|
+
/** How long the exact match may take before the changed middle is shown as a replacement. */
|
|
10
|
+
const MATCH_TIMEOUT_MS = 250;
|
|
11
|
+
/** The edit distance the exact match gives up at, whatever the time. */
|
|
12
|
+
const MATCH_EDIT_LIMIT = 4_000;
|
|
13
|
+
const DEFAULT_CONTEXT = 3;
|
|
14
|
+
const DEFAULT_MAX_LINES = 2_000;
|
|
15
|
+
const DEFAULT_MAX_CHARS = 512 * 1024;
|
|
16
|
+
const DEFAULT_LINE_CHARS = 2_000;
|
|
17
|
+
/** The text a side holds, `null` for an absent file, or `undefined` for content that is not UTF-8 text. */
|
|
18
|
+
export function decodeText(side) {
|
|
19
|
+
if (side === null)
|
|
20
|
+
return null;
|
|
21
|
+
if (typeof side === 'string')
|
|
22
|
+
return side.includes('\0') ? undefined : side;
|
|
23
|
+
if (side.includes(0))
|
|
24
|
+
return undefined;
|
|
25
|
+
try {
|
|
26
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(side);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function byteLength(side) {
|
|
33
|
+
if (side === null)
|
|
34
|
+
return 0;
|
|
35
|
+
return typeof side === 'string' ? Buffer.byteLength(side) : side.length;
|
|
36
|
+
}
|
|
37
|
+
/** A text's lines, each keeping its terminator so that a final line without one compares as different. */
|
|
38
|
+
function tokens(text) {
|
|
39
|
+
return text === '' ? [] : text.split(/(?<=\n)/);
|
|
40
|
+
}
|
|
41
|
+
/** How many lines a text has, without splitting it: a final line without a terminator counts. */
|
|
42
|
+
export function lineCount(text) {
|
|
43
|
+
if (text === '')
|
|
44
|
+
return 0;
|
|
45
|
+
let count = 0;
|
|
46
|
+
for (let at = text.indexOf('\n'); at >= 0; at = text.indexOf('\n', at + 1))
|
|
47
|
+
count++;
|
|
48
|
+
return text.endsWith('\n') ? count : count + 1;
|
|
49
|
+
}
|
|
50
|
+
function display(token) {
|
|
51
|
+
return token.endsWith('\r\n') ? token.slice(0, -2) : token.endsWith('\n') ? token.slice(0, -1) : token;
|
|
52
|
+
}
|
|
53
|
+
/** The diff between two sides of one file. */
|
|
54
|
+
export function fileDiff(before, after, options = {}) {
|
|
55
|
+
const oldText = decodeText(before);
|
|
56
|
+
const newText = decodeText(after);
|
|
57
|
+
if (oldText === undefined || newText === undefined)
|
|
58
|
+
return { kind: 'binary' };
|
|
59
|
+
if (byteLength(before) > DIFF_BYTE_LIMIT || byteLength(after) > DIFF_BYTE_LIMIT) {
|
|
60
|
+
return { kind: 'too-large', ...coarseCounts(oldText ?? '', newText ?? '') };
|
|
61
|
+
}
|
|
62
|
+
const diff = textDiff(oldText ?? '', newText ?? '', options);
|
|
63
|
+
if (diff.coarse)
|
|
64
|
+
return { kind: 'too-large', linesAdded: diff.linesAdded, linesRemoved: diff.linesRemoved };
|
|
65
|
+
return { kind: 'text', diff };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The diff of two texts, as `fileDiff` returns it for text sides.
|
|
69
|
+
*
|
|
70
|
+
* Work and memory are bounded by the change, not the file: the shared head and tail are trimmed before the
|
|
71
|
+
* match, the result is kept as stretches rather than one record per line, and lines past the output bound
|
|
72
|
+
* are counted without being built. A side with more than `DIFF_LINE_LIMIT` lines is not split into lines at
|
|
73
|
+
* all: the counts come from a scan of the shared ends, and `coarse` says there are no hunks for that reason.
|
|
74
|
+
*/
|
|
75
|
+
export function textDiff(oldText, newText, options = {}) {
|
|
76
|
+
const context = Math.max(0, options.context ?? DEFAULT_CONTEXT);
|
|
77
|
+
const maxLines = Math.max(0, options.maxLines ?? DEFAULT_MAX_LINES);
|
|
78
|
+
const maxChars = Math.max(0, options.maxChars ?? DEFAULT_MAX_CHARS);
|
|
79
|
+
const lineChars = Math.max(1, options.lineChars ?? DEFAULT_LINE_CHARS);
|
|
80
|
+
if (lineCount(oldText) > DIFF_LINE_LIMIT || lineCount(newText) > DIFF_LINE_LIMIT) {
|
|
81
|
+
return { hunks: [], ...coarseCounts(oldText, newText), hiddenLines: 0, coarse: true };
|
|
82
|
+
}
|
|
83
|
+
const a = tokens(oldText);
|
|
84
|
+
const b = tokens(newText);
|
|
85
|
+
let head = 0;
|
|
86
|
+
while (head < a.length && head < b.length && a[head] === b[head])
|
|
87
|
+
head += 1;
|
|
88
|
+
let tail = 0;
|
|
89
|
+
while (tail < a.length - head && tail < b.length - head && a[a.length - 1 - tail] === b[b.length - 1 - tail])
|
|
90
|
+
tail += 1;
|
|
91
|
+
const midA = a.slice(head, a.length - tail);
|
|
92
|
+
const midB = b.slice(head, b.length - tail);
|
|
93
|
+
// The exact match runs on the changed middle only, bounded in time and edit distance; past either bound
|
|
94
|
+
// the middle is shown as removed then added, which is still a true diff.
|
|
95
|
+
let changes = midA.length && midB.length
|
|
96
|
+
? diffArrays(midA, midB, { timeout: MATCH_TIMEOUT_MS, maxEditLength: MATCH_EDIT_LIMIT })
|
|
97
|
+
: undefined;
|
|
98
|
+
changes ??= [
|
|
99
|
+
...(midA.length ? [{ value: midA, added: false, removed: true }] : []),
|
|
100
|
+
...(midB.length ? [{ value: midB, added: true, removed: false }] : []),
|
|
101
|
+
];
|
|
102
|
+
const runs = [];
|
|
103
|
+
if (head)
|
|
104
|
+
runs.push({ kind: 'context', oldStart: 1, newStart: 1, count: head, lines: a, offset: 0 });
|
|
105
|
+
let oldPos = head + 1, newPos = head + 1;
|
|
106
|
+
let linesAdded = 0, linesRemoved = 0;
|
|
107
|
+
for (const change of changes) {
|
|
108
|
+
const kind = change.added ? 'add' : change.removed ? 'del' : 'context';
|
|
109
|
+
runs.push({ kind, oldStart: oldPos, newStart: newPos, count: change.value.length, lines: change.value, offset: 0 });
|
|
110
|
+
if (kind !== 'add')
|
|
111
|
+
oldPos += change.value.length;
|
|
112
|
+
if (kind !== 'del')
|
|
113
|
+
newPos += change.value.length;
|
|
114
|
+
if (kind === 'add')
|
|
115
|
+
linesAdded += change.value.length;
|
|
116
|
+
else if (kind === 'del')
|
|
117
|
+
linesRemoved += change.value.length;
|
|
118
|
+
}
|
|
119
|
+
if (tail)
|
|
120
|
+
runs.push({ kind: 'context', oldStart: oldPos, newStart: newPos, count: tail, lines: a, offset: a.length - tail });
|
|
121
|
+
// Hunks: every changed stretch with `context` kept lines on each side, merged when the kept lines between
|
|
122
|
+
// two changes are no more than twice the context.
|
|
123
|
+
const grouped = [];
|
|
124
|
+
for (let index = 0; index < runs.length;) {
|
|
125
|
+
if (runs[index].kind === 'context') {
|
|
126
|
+
index++;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const parts = [];
|
|
130
|
+
const before = runs[index - 1];
|
|
131
|
+
if (before && context)
|
|
132
|
+
parts.push({ run: before, from: Math.max(0, before.count - context), to: before.count });
|
|
133
|
+
let at = index;
|
|
134
|
+
for (;;) {
|
|
135
|
+
parts.push({ run: runs[at], from: 0, to: runs[at].count });
|
|
136
|
+
const next = runs[at + 1];
|
|
137
|
+
if (!next) {
|
|
138
|
+
at += 1;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (next.kind !== 'context') {
|
|
142
|
+
at += 1;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (runs[at + 2] && next.count <= 2 * context) {
|
|
146
|
+
parts.push({ run: next, from: 0, to: next.count });
|
|
147
|
+
at += 2;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (context)
|
|
151
|
+
parts.push({ run: next, from: 0, to: Math.min(context, next.count) });
|
|
152
|
+
at += 2;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
grouped.push(parts);
|
|
156
|
+
index = at;
|
|
157
|
+
}
|
|
158
|
+
const hunks = [];
|
|
159
|
+
let emitted = 0, chars = 0, hidden = 0, full = maxLines === 0;
|
|
160
|
+
for (const parts of grouped) {
|
|
161
|
+
let oldLines = 0, newLines = 0;
|
|
162
|
+
for (const part of parts) {
|
|
163
|
+
if (part.run.kind !== 'add')
|
|
164
|
+
oldLines += part.to - part.from;
|
|
165
|
+
if (part.run.kind !== 'del')
|
|
166
|
+
newLines += part.to - part.from;
|
|
167
|
+
}
|
|
168
|
+
const first = parts[0];
|
|
169
|
+
const firstOld = parts.find(part => part.run.kind !== 'add');
|
|
170
|
+
const firstNew = parts.find(part => part.run.kind !== 'del');
|
|
171
|
+
// An empty side starts at the line before the change, as unified diff headers do.
|
|
172
|
+
const oldStart = firstOld ? firstOld.run.oldStart + firstOld.from : first.run.oldStart - 1;
|
|
173
|
+
const newStart = firstNew ? firstNew.run.newStart + firstNew.from : first.run.newStart - 1;
|
|
174
|
+
const lines = [];
|
|
175
|
+
for (const part of parts) {
|
|
176
|
+
if (full) {
|
|
177
|
+
hidden += part.to - part.from;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
for (let k = part.from; k < part.to; k++) {
|
|
181
|
+
const token = part.run.lines[part.run.offset + k];
|
|
182
|
+
const whole = display(token);
|
|
183
|
+
const text = whole.length > lineChars ? whole.slice(0, lineChars) : whole;
|
|
184
|
+
if (emitted >= maxLines || chars + text.length > maxChars) {
|
|
185
|
+
full = true;
|
|
186
|
+
hidden += part.to - k;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
const line = { kind: part.run.kind, text };
|
|
190
|
+
if (part.run.kind !== 'add')
|
|
191
|
+
line.oldLine = part.run.oldStart + k;
|
|
192
|
+
if (part.run.kind !== 'del')
|
|
193
|
+
line.newLine = part.run.newStart + k;
|
|
194
|
+
if (!token.endsWith('\n'))
|
|
195
|
+
line.noNewline = true;
|
|
196
|
+
if (text.length < whole.length)
|
|
197
|
+
line.clipped = true;
|
|
198
|
+
lines.push(line);
|
|
199
|
+
emitted++;
|
|
200
|
+
chars += text.length;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (lines.length)
|
|
204
|
+
hunks.push({ oldStart, oldLines, newStart, newLines, lines });
|
|
205
|
+
}
|
|
206
|
+
return { hunks, linesAdded, linesRemoved, hiddenLines: hidden };
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Added and removed counts without splitting either text: the shared head and tail (whole lines) are found
|
|
210
|
+
* by scanning characters from each end, and every line between them counts as changed. Memory is the two
|
|
211
|
+
* strings; time is one pass over them.
|
|
212
|
+
*/
|
|
213
|
+
export function coarseCounts(oldText, newText) {
|
|
214
|
+
if (oldText === newText)
|
|
215
|
+
return { linesAdded: 0, linesRemoved: 0 };
|
|
216
|
+
const a = oldText, b = newText;
|
|
217
|
+
const min = Math.min(a.length, b.length);
|
|
218
|
+
let prefix = 0;
|
|
219
|
+
while (prefix < min && a.charCodeAt(prefix) === b.charCodeAt(prefix))
|
|
220
|
+
prefix++;
|
|
221
|
+
// Whole lines of the shared prefix: a line is shared only with its terminator.
|
|
222
|
+
let head = 0, headEnd = 0;
|
|
223
|
+
for (let at = a.indexOf('\n'); at >= 0 && at < prefix; at = a.indexOf('\n', at + 1)) {
|
|
224
|
+
head++;
|
|
225
|
+
headEnd = at + 1;
|
|
226
|
+
}
|
|
227
|
+
// The shared suffix, never reaching back into the shared head.
|
|
228
|
+
const room = Math.min(a.length - headEnd, b.length - headEnd);
|
|
229
|
+
let suffix = 0;
|
|
230
|
+
while (suffix < room && a.charCodeAt(a.length - 1 - suffix) === b.charCodeAt(b.length - 1 - suffix))
|
|
231
|
+
suffix++;
|
|
232
|
+
// Whole lines of the shared suffix: the lines that start inside it on both sides.
|
|
233
|
+
const startA = a.length - suffix, startB = b.length - suffix;
|
|
234
|
+
let tail = 0;
|
|
235
|
+
if (suffix > 0) {
|
|
236
|
+
for (let at = a.indexOf('\n', startA); at >= 0 && at < a.length - 1; at = a.indexOf('\n', at + 1))
|
|
237
|
+
tail++;
|
|
238
|
+
const lineStartA = startA === 0 || a.charCodeAt(startA - 1) === 10;
|
|
239
|
+
const lineStartB = startB === 0 || b.charCodeAt(startB - 1) === 10;
|
|
240
|
+
if (lineStartA && lineStartB)
|
|
241
|
+
tail++;
|
|
242
|
+
}
|
|
243
|
+
return { linesAdded: Math.max(0, lineCount(b) - head - tail), linesRemoved: Math.max(0, lineCount(a) - head - tail) };
|
|
244
|
+
}
|
|
@@ -15,8 +15,8 @@ const RESET_WAIT_MS = 10_000;
|
|
|
15
15
|
const ENDING_WAIT_MS = 30_000;
|
|
16
16
|
/** Mirrors `MAX_TASK_CHARS` in `app-server.ts`: the engine refuses a longer `run.start` task or `run.steer` text. */
|
|
17
17
|
export const MANAGER_TASK_MAX_CHARS = 100_000;
|
|
18
|
-
const UPDATE_MESSAGE = 'Update Andorra to use
|
|
19
|
-
const TOO_LARGE_MESSAGE = 'This
|
|
18
|
+
const UPDATE_MESSAGE = 'Update Andorra Code to use Workflow Manager.';
|
|
19
|
+
const TOO_LARGE_MESSAGE = 'This workflow is too large to send to Workflow Manager.';
|
|
20
20
|
/** The longest tool or approval line the panel is given. */
|
|
21
21
|
const TOOL_LINE_MAX = 120;
|
|
22
22
|
/** How many draft-to-graph pairings are remembered; an agent holds a handful of drafts at most. */
|
|
@@ -71,11 +71,11 @@ export function describeManagerTool(name, value, graphOfDraft = () => undefined)
|
|
|
71
71
|
}
|
|
72
72
|
/** What each `graphs` action does, as the row's verb. An action not named here shows its own name. */
|
|
73
73
|
const GRAPH_ACTION_VERBS = {
|
|
74
|
-
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read
|
|
75
|
-
andorra_graph_node_upsert: 'Set
|
|
76
|
-
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit
|
|
77
|
-
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save
|
|
78
|
-
andorra_graph_delete: 'Delete
|
|
74
|
+
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read workflow', andorra_graph_guide: 'Read guide',
|
|
75
|
+
andorra_graph_node_upsert: 'Set step', andorra_graph_node_patch: 'Edit step', andorra_graph_node_remove: 'Remove step',
|
|
76
|
+
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit workflow',
|
|
77
|
+
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save version', andorra_graph_discard: 'Discard draft',
|
|
78
|
+
andorra_graph_delete: 'Delete workflow', andorra_graph_restore: 'Restore workflow',
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
81
|
* A tool call split the way the app's transcript draws it: the verb, and the thing it acted on.
|
|
@@ -118,7 +118,7 @@ export function managerToolParts(name, value, openGraphId) {
|
|
|
118
118
|
}
|
|
119
119
|
/** Bookkeeping calls the runtime handles itself; a conversation shows what the agent did, not these. */
|
|
120
120
|
const HIDDEN_TOOLS = new Set(['update_todos', 'update_widget', 'prepare_steps', 'restore_tools', 'complete_agent']);
|
|
121
|
-
const STOPPED_UNREAD_MESSAGE = '
|
|
121
|
+
const STOPPED_UNREAD_MESSAGE = 'Workflow Manager was stopped before it read your last message. Send it again to continue.';
|
|
122
122
|
/**
|
|
123
123
|
* The environment the chat's engine starts in: the parent's own, so the engine is signed in as the
|
|
124
124
|
* parent is. Stored credentials are scoped to an explicitly named home (`credentialIdentity`), so
|
|
@@ -349,7 +349,7 @@ export class GraphManagerChat {
|
|
|
349
349
|
try {
|
|
350
350
|
await this.request(engine, 'run.steer', { runId, sessionId: this.sessionId, text: task });
|
|
351
351
|
if (keptModel !== undefined)
|
|
352
|
-
this.emit({ type: 'error', message: `
|
|
352
|
+
this.emit({ type: 'error', message: `Workflow Manager could not switch to ${turn.provider}/${turn.model}, so this run keeps its model: ${keptModel.reason}` });
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
catch (error) {
|
|
@@ -374,7 +374,7 @@ export class GraphManagerChat {
|
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
376
|
if (!this.isIdle()) {
|
|
377
|
-
this.emit({ type: 'error', message: '
|
|
377
|
+
this.emit({ type: 'error', message: 'Workflow Manager is still finishing its last run. Send your message again.' });
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -473,11 +473,11 @@ export class GraphManagerChat {
|
|
|
473
473
|
try {
|
|
474
474
|
const engine = await this.ensureEngine();
|
|
475
475
|
if (this.sessionId === undefined) {
|
|
476
|
-
const title = `
|
|
476
|
+
const title = `Workflow Manager: ${name}`.slice(0, 200);
|
|
477
477
|
const created = await this.request(engine, 'sessions.create', { workspace: this.workspace, name: title });
|
|
478
478
|
const id = record(created.session).id;
|
|
479
479
|
if (typeof id !== 'string')
|
|
480
|
-
throw new Error('
|
|
480
|
+
throw new Error('Workflow Manager could not start its conversation.');
|
|
481
481
|
// The rename pins the name, so the engine's automatic titling leaves it alone.
|
|
482
482
|
await this.request(engine, 'sessions.rename', { id, name: title });
|
|
483
483
|
this.sessionId = id;
|
|
@@ -546,7 +546,7 @@ export class GraphManagerChat {
|
|
|
546
546
|
failReady(new Error(reason));
|
|
547
547
|
void this.stopEngine(engine);
|
|
548
548
|
};
|
|
549
|
-
const startup = setTimeout(() => refuse('
|
|
549
|
+
const startup = setTimeout(() => refuse('Workflow Manager did not start within 60 seconds.'), STARTUP_MS);
|
|
550
550
|
startup.unref();
|
|
551
551
|
const gone = (detail) => {
|
|
552
552
|
if (engine.gone)
|
|
@@ -568,7 +568,7 @@ export class GraphManagerChat {
|
|
|
568
568
|
// message begins a new session on a new engine.
|
|
569
569
|
this.sessionId = undefined;
|
|
570
570
|
const tail = engine.stderr.trim().split('\n').at(-1)?.trim();
|
|
571
|
-
this.emit({ type: 'error', message: `
|
|
571
|
+
this.emit({ type: 'error', message: `Workflow Manager stopped unexpectedly (${detail}). Send your message again to restart it.${tail ? `\n${tail}` : ''}` });
|
|
572
572
|
this.finish(this.runId);
|
|
573
573
|
};
|
|
574
574
|
child.stderr.on('data', chunk => { engine.stderr = (engine.stderr + String(chunk)).slice(-8_192); });
|
|
@@ -590,7 +590,7 @@ export class GraphManagerChat {
|
|
|
590
590
|
const waiter = engine.pending.get(message.id);
|
|
591
591
|
engine.pending.delete(message.id);
|
|
592
592
|
if (message.error)
|
|
593
|
-
waiter?.reject(new EngineRefusal(typeof message.error.message === 'string' ? message.error.message : '
|
|
593
|
+
waiter?.reject(new EngineRefusal(typeof message.error.message === 'string' ? message.error.message : 'Workflow Manager refused the request.', typeof message.error.code === 'string' ? message.error.code : undefined));
|
|
594
594
|
else
|
|
595
595
|
waiter?.resolve(record(message.result));
|
|
596
596
|
return;
|
package/dist/src/graph-server.js
CHANGED
|
@@ -32,7 +32,7 @@ export function readManagerGraphRevision(id, graphDirectory) {
|
|
|
32
32
|
}
|
|
33
33
|
/** The largest request body the editor accepts for a graph, whether it is being saved or sent to Graph Manager. */
|
|
34
34
|
const GRAPH_BODY_LIMIT = 512 * 1024;
|
|
35
|
-
const MANAGER_TOO_LARGE = 'This
|
|
35
|
+
const MANAGER_TOO_LARGE = 'This workflow is too large to send to Workflow Manager.';
|
|
36
36
|
const MANAGER_PING_MS = 15_000;
|
|
37
37
|
/**
|
|
38
38
|
* Reads a request body of at most `limit` bytes; undefined when it is larger. An oversized body is
|
|
@@ -363,11 +363,11 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
363
363
|
}
|
|
364
364
|
const graph = value.graph;
|
|
365
365
|
if (!filled(value.provider) || !filled(value.model))
|
|
366
|
-
throw new Error('Choose a model for
|
|
366
|
+
throw new Error('Choose a model for Workflow Manager.');
|
|
367
367
|
if (!filled(value.text))
|
|
368
|
-
throw new Error('Write a message for
|
|
368
|
+
throw new Error('Write a message for Workflow Manager.');
|
|
369
369
|
if (graph === null || typeof graph !== 'object' || Array.isArray(graph) || typeof graph.id !== 'string' || typeof graph.name !== 'string')
|
|
370
|
-
throw new Error('A message to
|
|
370
|
+
throw new Error('A message to Workflow Manager needs the open workflow.');
|
|
371
371
|
accepted(managerChat().send({
|
|
372
372
|
provider: value.provider, model: value.model, text: value.text,
|
|
373
373
|
graph: graph, saved: value.saved === true,
|
|
@@ -465,7 +465,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
465
465
|
const graphs = [];
|
|
466
466
|
const graphMigrationErrors = [];
|
|
467
467
|
const savedGraphs = await listGraphs(graphDirectory, (id, error) => {
|
|
468
|
-
graphMigrationErrors.push({ id, name: id, error: error instanceof Error ? error.message : '
|
|
468
|
+
graphMigrationErrors.push({ id, name: id, error: error instanceof Error ? error.message : 'Workflow load failed' });
|
|
469
469
|
});
|
|
470
470
|
const free = await freeTier();
|
|
471
471
|
// Deleted graphs stay out of the editor; restoring one goes through the graph MCP server.
|
|
@@ -520,7 +520,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
520
520
|
// The preset is bundled with the CLI: it has no storage to remove, and hiding it would
|
|
521
521
|
// only last until the next launch.
|
|
522
522
|
if (id === 'default') {
|
|
523
|
-
reply(res, 400, { error: 'The bundled default
|
|
523
|
+
reply(res, 400, { error: 'The bundled default workflow cannot be deleted.' });
|
|
524
524
|
return;
|
|
525
525
|
}
|
|
526
526
|
if (id === GRAPH_MANAGER_GRAPH_ID) {
|
|
@@ -550,7 +550,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
550
550
|
}
|
|
551
551
|
const body = await readBody(req, GRAPH_BODY_LIMIT);
|
|
552
552
|
if (!body) {
|
|
553
|
-
reply(res, 413, { error: '
|
|
553
|
+
reply(res, 413, { error: 'Workflow exceeds 512 KiB' });
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
556
|
const value = JSON.parse(body.toString('utf8'));
|
|
@@ -605,7 +605,7 @@ export async function startGraphServer(directory = configDirectory(), checkMembe
|
|
|
605
605
|
// Stamping can add profile entries after the streamed body already passed the limit.
|
|
606
606
|
const stamped = stampGraphProviderProfiles(graph, config);
|
|
607
607
|
if (Buffer.byteLength(JSON.stringify(stamped)) > GRAPH_BODY_LIMIT) {
|
|
608
|
-
reply(res, 413, { error: '
|
|
608
|
+
reply(res, 413, { error: 'Workflow exceeds 512 KiB' });
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
611
|
const expected = graph.revision === 0 ? null : graph.revision;
|
|
@@ -672,7 +672,7 @@ export async function deleteGraphWithTombstone(id, graphDirectory, directory, su
|
|
|
672
672
|
// MCP server's delete tool applies the same check, so the editor cannot bypass it.
|
|
673
673
|
const users = (await new AutomationStore(directory).list()).filter(job => job.execution?.graph === id);
|
|
674
674
|
if (users.length)
|
|
675
|
-
throw new Error('
|
|
675
|
+
throw new Error('Workflow ' + id + ' is run by automation'
|
|
676
676
|
+ (users.length === 1 ? ' ' : 's ') + users.map(job => '"' + job.name + '"').join(', ')
|
|
677
677
|
+ '. Change or remove ' + (users.length === 1 ? 'it' : 'them') + ' first.');
|
|
678
678
|
if (sync) {
|