@andorra-labs/code 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +36 -0
- package/dist/src/app-server/protocol.d.ts +1 -0
- package/dist/src/app-server.d.ts +34 -1
- package/dist/src/app-server.js +264 -54
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +8 -0
- package/dist/src/completion.js +19 -1
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/graph-manager-chat.js +13 -13
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-server.js +9 -9
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +262 -93
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +4 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +11 -11
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +3 -2
- package/dist/src/graphs.js +3 -2
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/react-runtime.js +121 -14
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/terminal-ui.js +2 -2
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
package/dist/src/coding-tools.js
CHANGED
|
@@ -17,6 +17,7 @@ import { FileReadRequiredError } from './tool-errors.js';
|
|
|
17
17
|
import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
|
|
18
18
|
import { withGrepRegex } from './grep-regex.js';
|
|
19
19
|
import { claimReadImages, readImageObservation } from './read-image.js';
|
|
20
|
+
import { READ_PDF_RENDER_PAGES, legacyTextObservation, readDocumentObservation } from './read-document-tool.js';
|
|
20
21
|
const execFileAsync = promisify(execFile);
|
|
21
22
|
const excluded = new Set(['.git', 'node_modules', '.andorracode']);
|
|
22
23
|
const MAX_MODEL_OUTPUT = 24_000;
|
|
@@ -26,6 +27,31 @@ const READ_MAX_LINES = 2000;
|
|
|
26
27
|
const READ_MAX_LINE_CHARS = 2000;
|
|
27
28
|
const SEARCH_FILE_LIMIT = 262_144;
|
|
28
29
|
const SEARCH_SCAN_LIMIT = 16 * 1024 * 1024;
|
|
30
|
+
/**
|
|
31
|
+
* How long a foreground shell command may run when the call names no timeout.
|
|
32
|
+
*
|
|
33
|
+
* Thirty seconds, the earlier default, is shorter than an ordinary package install, compile or
|
|
34
|
+
* test run: the command was killed and the model had to notice, raise the timeout and start it
|
|
35
|
+
* again from nothing. Two minutes covers those without leaving a hung command unnoticed for long.
|
|
36
|
+
*/
|
|
37
|
+
export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
|
|
38
|
+
export const SHELL_MAX_TIMEOUT_MS = 600_000;
|
|
39
|
+
/**
|
|
40
|
+
* What a timed-out command's error tells the model to do next.
|
|
41
|
+
*
|
|
42
|
+
* The bare "timed out after N ms" says the command was stopped but not that the work is lost, nor
|
|
43
|
+
* which of the two ways forward fits: a longer timeout while one is left to ask for, or a
|
|
44
|
+
* background job once the ceiling is reached.
|
|
45
|
+
*/
|
|
46
|
+
export function shellTimeoutGuidance(message, timeout) {
|
|
47
|
+
const marker = /^Shell command timed out after \d+ ms/;
|
|
48
|
+
if (!marker.test(message))
|
|
49
|
+
return message;
|
|
50
|
+
const next = timeout < SHELL_MAX_TIMEOUT_MS
|
|
51
|
+
? `The command was stopped and its work is not finished. If it only needs more time, run it again with a larger timeout (up to ${SHELL_MAX_TIMEOUT_MS}); for work that can exceed that, start it with AsyncProcess and wait on the job.`
|
|
52
|
+
: 'The command was stopped at the largest foreground timeout and its work is not finished. Start it with AsyncProcess instead and wait on the job.';
|
|
53
|
+
return message.replace(marker, found => `${found}. ${next}`);
|
|
54
|
+
}
|
|
29
55
|
const sandboxFields = {
|
|
30
56
|
sandbox_permissions: { type: 'string', enum: ['use_default', 'require_escalated'], description: 'Use the workspace sandbox by default; require_escalated requests host/network access with approval.' },
|
|
31
57
|
justification: { type: 'string', description: 'Required explanation for an explicit escalation request.' },
|
|
@@ -221,8 +247,13 @@ async function requireFreshRead(policy, context, resolved, action) {
|
|
|
221
247
|
if (!previous?.complete) {
|
|
222
248
|
// A suggested offset is only meaningful for the content the model last saw. Re-read first so
|
|
223
249
|
// a file that changed (or shrank) since that page cannot send the model past its end.
|
|
224
|
-
if (!previous)
|
|
250
|
+
if (!previous) {
|
|
251
|
+
// A file the text tools cannot hold (a document, an image, text in another encoding) can be
|
|
252
|
+
// looked at with Read but never becomes a recorded read, so "Read it first" would send the
|
|
253
|
+
// model round in a circle. The strict reader's own refusal is the true answer for those.
|
|
254
|
+
await policy.read(context, resolved);
|
|
225
255
|
throw new FileReadRequiredError(`${action} requires a complete Read (or complete CodeGraph source) of the existing file first. Read ${path.relative(context.workspace, resolved) || resolved} before modifying it.`);
|
|
256
|
+
}
|
|
226
257
|
if (!matchesFileRead(previous, await policy.read(context, resolved))) {
|
|
227
258
|
throw new FileReadRequiredError(`${action} refused a stale file: it changed since the last Read/CodeGraph snapshot. Read it again before modifying.`);
|
|
228
259
|
}
|
|
@@ -444,23 +475,50 @@ export function createCodingTools(policy) {
|
|
|
444
475
|
} }),
|
|
445
476
|
};
|
|
446
477
|
}
|
|
447
|
-
const Read = { ...zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation. An image file (PNG, JPEG, GIF, WebP or BMP, up to 20 MiB) is returned as an image you can see, downscaled when large; use this to look at a rendered frame, plot or screenshot instead of inferring it from pixel statistics. offset and limit do not apply to images.`, { type: 'object', properties: {
|
|
478
|
+
const Read = { ...zTool('Read', `Read a UTF-8 workspace file up to 8 MiB with compact line numbers. One call returns at most ${READ_MAX_LINES} lines: for a longer file, continue with the offset the result reports until you have read the whole file. A complete Read — every line, across calls — is remembered so Write/Edit can reject stale or unseen existing files; do not re-read unchanged files after a successful mutation. An image file (PNG, JPEG, GIF, WebP or BMP, up to 20 MiB) is returned as an image you can see, downscaled when large; use this to look at a rendered frame, plot or screenshot instead of inferring it from pixel statistics. offset and limit do not apply to images. A PDF or Word file (.docx, .doc; up to 64 MiB) is returned as its extracted text with line numbers, paged by offset and limit like a text file; for a PDF, pages selects pages and render: true returns those pages as images, which is how to read a scan, a figure or a page with no text layer. A text file that is not UTF-8 (UTF-16, Windows-1252) is shown decoded. Documents and decoded text are read-only: they are not remembered as a Read, and Edit/Write cannot change them.`, { type: 'object', properties: {
|
|
448
479
|
file_path: { type: 'string', description: 'Workspace-relative or absolute path inside the workspace' },
|
|
449
480
|
offset: { type: 'integer', minimum: 0, description: '1-based starting line; 0 is accepted as line 1' },
|
|
450
481
|
limit: { type: 'integer', minimum: 1, maximum: READ_MAX_LINES, description: `Maximum lines to return, at most ${READ_MAX_LINES}` },
|
|
482
|
+
pages: { type: 'string', description: 'PDF only: the pages to read, such as "3", "2-5" or "1,4,7-9". Default: every page' },
|
|
483
|
+
render: { type: 'boolean', description: `PDF only: return the selected pages as images instead of their text, at most ${READ_PDF_RENDER_PAGES} pages per call. Use it for scans, figures, tables, forms and scores` },
|
|
451
484
|
}, required: ['file_path'], additionalProperties: false }, 'parallel', async (args, context) => {
|
|
452
|
-
if (Object.keys(args).some(key => !['file_path', 'offset', 'limit'].includes(key)))
|
|
485
|
+
if (Object.keys(args).some(key => !['file_path', 'offset', 'limit', 'pages', 'render'].includes(key)))
|
|
453
486
|
throw new Error('Unknown Read argument');
|
|
454
487
|
const filePath = stringArg(args, 'file_path');
|
|
455
488
|
const offset = intArg(args, 'offset', { min: 0, max: Number.MAX_SAFE_INTEGER });
|
|
456
489
|
const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
|
|
490
|
+
const pages = stringArg(args, 'pages', true), render = boolArg(args, 'render') ?? false;
|
|
457
491
|
const resolved = await policy.safePath(context, filePath);
|
|
458
492
|
// An image is recognized by its signature and shown as pixels. It is not recorded as a
|
|
459
493
|
// text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
|
|
460
494
|
const image = await policy.readImage?.(context, resolved);
|
|
461
495
|
if (image)
|
|
462
496
|
return readImageObservation(context, filePath, image);
|
|
463
|
-
|
|
497
|
+
// A PDF or Word file is likewise recognized by its leading bytes and returned as what it
|
|
498
|
+
// says: its text, or for a PDF its pages as images. Neither is recorded as a text read.
|
|
499
|
+
const documentOptions = { offset, limit, ...(pages === undefined ? {} : { pages }), render, maxOutput: MAX_MODEL_OUTPUT, maxLineChars: READ_MAX_LINE_CHARS };
|
|
500
|
+
const documentBytes = await policy.readDocument?.(context, resolved);
|
|
501
|
+
if (documentBytes) {
|
|
502
|
+
const observation = await readDocumentObservation(context, filePath, documentBytes, documentOptions);
|
|
503
|
+
if (observation !== undefined)
|
|
504
|
+
return observation;
|
|
505
|
+
}
|
|
506
|
+
let content;
|
|
507
|
+
try {
|
|
508
|
+
content = await policy.read(context, resolved);
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
// Text in an older encoding (UTF-16, Windows-1252) fails the strict UTF-8 reader that
|
|
512
|
+
// Edit depends on. It is still text a model can read, so it is shown decoded, read-only.
|
|
513
|
+
if (!(error instanceof Error) || !/not valid UTF-8|Binary files are not supported/.test(error.message))
|
|
514
|
+
throw error;
|
|
515
|
+
const decoded = await policy.readLegacyText?.(context, resolved);
|
|
516
|
+
if (!decoded)
|
|
517
|
+
throw error;
|
|
518
|
+
return legacyTextObservation(filePath, decoded, documentOptions);
|
|
519
|
+
}
|
|
520
|
+
if (pages !== undefined || render)
|
|
521
|
+
throw new Error('pages and render apply to PDF files only; page through a text file with offset and limit.');
|
|
464
522
|
const lines = content.split('\n');
|
|
465
523
|
if (content.endsWith('\n') || content === '')
|
|
466
524
|
lines.pop();
|
|
@@ -852,13 +910,13 @@ export function createCodingTools(policy) {
|
|
|
852
910
|
: 'Bash syntax (Git Bash on Windows).';
|
|
853
911
|
const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.`, { type: 'object', properties: {
|
|
854
912
|
command: { type: 'string', description: 'Command to execute' },
|
|
855
|
-
timeout: { type: 'integer', minimum: 1, maximum:
|
|
913
|
+
timeout: { type: 'integer', minimum: 1, maximum: SHELL_MAX_TIMEOUT_MS, description: `Timeout in milliseconds; default ${SHELL_DEFAULT_TIMEOUT_MS}, at most ${SHELL_MAX_TIMEOUT_MS}. Set it for a build, install, download or test run you expect to take longer than the default` },
|
|
856
914
|
description: { type: 'string', description: 'Short active-voice description of what the command does' },
|
|
857
915
|
...sandboxFields,
|
|
858
916
|
}, required: ['command'], additionalProperties: false }, 'sequential', async (args, context) => {
|
|
859
917
|
if (Object.keys(args).some(key => !['command', 'timeout', 'description', 'sandbox_permissions', 'justification'].includes(key)))
|
|
860
918
|
throw new Error(`Unknown ${name} argument`);
|
|
861
|
-
const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max:
|
|
919
|
+
const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: SHELL_MAX_TIMEOUT_MS }) ?? SHELL_DEFAULT_TIMEOUT_MS;
|
|
862
920
|
if (args.description !== undefined)
|
|
863
921
|
stringArg(args, 'description', true);
|
|
864
922
|
// Before any approval is asked for: no permission mode, full access included, makes ending
|
|
@@ -902,8 +960,13 @@ export function createCodingTools(policy) {
|
|
|
902
960
|
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
|
|
903
961
|
}
|
|
904
962
|
catch (error) {
|
|
905
|
-
if (error instanceof Error
|
|
906
|
-
throw
|
|
963
|
+
if (!(error instanceof Error))
|
|
964
|
+
throw error;
|
|
965
|
+
const message = shellTimeoutGuidance(error.message, timeout);
|
|
966
|
+
if (message.length > MAX_MODEL_OUTPUT)
|
|
967
|
+
throw new Error(nativeObservation(message, true));
|
|
968
|
+
if (message !== error.message)
|
|
969
|
+
throw new Error(message);
|
|
907
970
|
throw error;
|
|
908
971
|
}
|
|
909
972
|
});
|
|
@@ -317,7 +317,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
317
317
|
id: DEFAULT_GRAPH.id,
|
|
318
318
|
label: 'Default',
|
|
319
319
|
description: 'Andorra Agent only. Reads project instructions and completes the task without an Orchestrator.',
|
|
320
|
-
}, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium
|
|
320
|
+
}, { id: ANDORRA_GRAPH_SELECTION, label: 'Andorra', description: free ? 'Premium graph: Orchestrator -> Andorra Agent -> Done' : 'Paid graph: Orchestrator -> Andorra Agent -> Done' }, ...withoutDeletedGraphs(saved).filter(graph => graph.id !== 'default').map(graph => ({ id: graph.id, label: `${graph.name} (${graph.id}@${graph.revision})`, description: 'Saved custom graph' })), { id: ':divider', label: '', separator: true }, { id: ':create', label: 'Create new graph', description: atLimit ? 'Free tier includes 1 custom graph. Upgrade to Premium for more graphs.' : 'Open the web graph builder' }, { id: ':edit', label: 'Edit Graphs', bold: true, description: 'Open saved graphs in the web graph builder' }];
|
|
321
321
|
while (!signal.aborted) {
|
|
322
322
|
const selected = await ui.select('Graph', items, { selectedId: state.graph ?? DEFAULT_GRAPH.id, description: 'Choose and save your default graph for this account, or create one in the web builder. After saving, reopen /graph to select it.', signal });
|
|
323
323
|
if (selected === undefined || signal.aborted)
|
package/dist/src/commands.js
CHANGED
|
@@ -474,7 +474,7 @@ export function handleCommand(line, state) {
|
|
|
474
474
|
if (changed)
|
|
475
475
|
return { text: 'Graph: Default (Andorra Agent)', clear: true };
|
|
476
476
|
}
|
|
477
|
-
return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for the paid Andorra
|
|
477
|
+
return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for the paid Andorra graph or custom graphs.' };
|
|
478
478
|
case '/permissions':
|
|
479
479
|
if (!arg)
|
|
480
480
|
return { text: `Permissions: ${permissionLabel(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval'))}` };
|
|
@@ -8,28 +8,63 @@ import type { TodoItem } from './todos.js';
|
|
|
8
8
|
* turn read as a run cut off halfway. Both conditions are facts the host already holds, so they are
|
|
9
9
|
* checked in code rather than left to the prompt.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* never spends a completion repair and never fails the run
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* The `summary` and `todos` gates each send the handoff back at most `MAX_GATE_ASKS` times and are
|
|
12
|
+
* waived after that. A gate never spends a completion repair and never fails the run.
|
|
13
|
+
*
|
|
14
|
+
* The `unfinished` gate is different in kind. It fires when the completion itself says the task is
|
|
15
|
+
* not done: a non-empty `remaining` list, or a "Not done" section in the summary. A run must not end
|
|
16
|
+
* on its own with work it can still do. In a benchmark trial with a fifteen-minute limit the agent
|
|
17
|
+
* had a build that booted but drew no frame, was told a quarter of its time was left, and completed
|
|
18
|
+
* two steps later with "frame output still missing" in its own summary and two minutes unused; the
|
|
19
|
+
* host accepted it, and the trial failed. So a completion that reports unfinished work is sent back
|
|
20
|
+
* to keep working for as long as the agent does work in between, with no cap on how often. It is
|
|
21
|
+
* accepted only when sending it back cannot help: the agent has twice in a row answered the
|
|
22
|
+
* send-back with the same report and no tool call (there is nothing more it can do without the
|
|
23
|
+
* user), the attempt's clock has all but run out, or it is on its last allowed iteration. Each of
|
|
24
|
+
* those is recorded as a waiver with its reason.
|
|
25
|
+
*
|
|
26
|
+
* Earlier the "Not done" section was the way a completion with open plan items got through at once.
|
|
27
|
+
* That made the honest report an exit, and the trial above took it.
|
|
15
28
|
*/
|
|
16
|
-
export type FinalAnswerGateId = 'summary' | 'todos';
|
|
29
|
+
export type FinalAnswerGateId = 'summary' | 'todos' | 'unfinished';
|
|
17
30
|
export declare const MAX_GATE_ASKS = 2;
|
|
31
|
+
/** Consecutive send-backs the agent may answer with no tool call before an unfinished report is accepted. */
|
|
32
|
+
export declare const MAX_IDLE_UNFINISHED_ASKS = 2;
|
|
33
|
+
/** With less than this left on the attempt's clock, another turn could not do any work. */
|
|
34
|
+
export declare const UNFINISHED_MIN_TIME_MS = 20000;
|
|
35
|
+
export type UnfinishedWaiver = 'noFurtherWork' | 'outOfTime';
|
|
18
36
|
export interface FinalAnswerGateInput {
|
|
19
37
|
/** The envelope had no summary, so the serialized output is what the user would read. */
|
|
20
38
|
summaryStoodIn: boolean;
|
|
21
39
|
/** The run's plan as it stands after any update sent beside the completion. */
|
|
22
40
|
todos: readonly TodoItem[];
|
|
23
|
-
/**
|
|
41
|
+
/** The summary as the user will read it; a "Not done" section in it reports unfinished work. */
|
|
42
|
+
summary?: string;
|
|
43
|
+
/** The completion's own list of what the task still lacks; empty or absent when it claims to be done. */
|
|
44
|
+
remaining?: readonly string[];
|
|
45
|
+
/** How many times the summary and plan gates have already sent a handoff back in this run. */
|
|
24
46
|
asked?: Partial<Record<FinalAnswerGateId, number>>;
|
|
47
|
+
/** Send-backs for unfinished work, in a row, that the agent answered without running any tool. */
|
|
48
|
+
idleUnfinishedAsks?: number;
|
|
49
|
+
/** Time left on the attempt's wall clock; undefined when the attempt has none. */
|
|
50
|
+
timeLeftMs?: number;
|
|
25
51
|
}
|
|
26
52
|
export interface FinalAnswerGateResult {
|
|
27
53
|
/** Gates that send this handoff back. Empty when every failed gate is waived. */
|
|
28
54
|
gates: FinalAnswerGateId[];
|
|
29
|
-
/** Gates that failed
|
|
55
|
+
/** Gates that failed but let the handoff through; the handoff is accepted despite them. */
|
|
30
56
|
waived: FinalAnswerGateId[];
|
|
31
57
|
/** What the model is told. Empty when nothing is sent back. */
|
|
32
58
|
message: string;
|
|
59
|
+
/** Why an unfinished report was let through, when `waived` includes `unfinished`. */
|
|
60
|
+
unfinishedWaiver?: UnfinishedWaiver;
|
|
33
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether the summary has a section that reports unfinished work: a markdown heading, or a line
|
|
64
|
+
* that is only a bold or plain label, reading "Not done" (also "Not completed", "Not finished",
|
|
65
|
+
* "Unfinished", "Remaining work", "Incomplete"). A sentence that merely contains the words does not
|
|
66
|
+
* count: a summary may say "nothing was left not done".
|
|
67
|
+
*/
|
|
68
|
+
export declare function declaresUnfinishedWork(summary: string | undefined): boolean;
|
|
34
69
|
/** Undefined when the handoff passes every gate. */
|
|
35
70
|
export declare function finalAnswerGate(input: FinalAnswerGateInput): FinalAnswerGateResult | undefined;
|
|
@@ -1,25 +1,71 @@
|
|
|
1
1
|
export const MAX_GATE_ASKS = 2;
|
|
2
|
-
/**
|
|
2
|
+
/** Consecutive send-backs the agent may answer with no tool call before an unfinished report is accepted. */
|
|
3
|
+
export const MAX_IDLE_UNFINISHED_ASKS = 2;
|
|
4
|
+
/** With less than this left on the attempt's clock, another turn could not do any work. */
|
|
5
|
+
export const UNFINISHED_MIN_TIME_MS = 20_000;
|
|
6
|
+
/** Plan items and remaining items named in the message; a longer list is counted, not listed. */
|
|
3
7
|
const MAX_NAMED_TODOS = 8;
|
|
8
|
+
const MAX_NAMED_REMAINING = 5;
|
|
9
|
+
const MAX_REMAINING_CHARS = 160;
|
|
10
|
+
const UNFINISHED_SECTION = /^[ \t]*(?:#{1,6}[ \t]+|\*\*|__)?(?:not (?:done|completed?|finished)|unfinished(?: work)?|remaining work|incomplete)(?:\*\*|__)?[ \t]*:?[ \t]*(?:\*\*|__)?[ \t]*$/im;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the summary has a section that reports unfinished work: a markdown heading, or a line
|
|
13
|
+
* that is only a bold or plain label, reading "Not done" (also "Not completed", "Not finished",
|
|
14
|
+
* "Unfinished", "Remaining work", "Incomplete"). A sentence that merely contains the words does not
|
|
15
|
+
* count: a summary may say "nothing was left not done".
|
|
16
|
+
*/
|
|
17
|
+
export function declaresUnfinishedWork(summary) {
|
|
18
|
+
return !!summary && UNFINISHED_SECTION.test(summary);
|
|
19
|
+
}
|
|
20
|
+
function timeLeftPhrase(ms) {
|
|
21
|
+
const seconds = Math.round(ms / 1000);
|
|
22
|
+
if (seconds < 90)
|
|
23
|
+
return `about ${Math.max(5, Math.round(seconds / 5) * 5)} seconds`;
|
|
24
|
+
const minutes = Math.round(seconds / 60);
|
|
25
|
+
return minutes < 90 ? `about ${minutes} minutes` : `about ${Math.round(minutes / 6) / 10} hours`;
|
|
26
|
+
}
|
|
4
27
|
/** Undefined when the handoff passes every gate. */
|
|
5
28
|
export function finalAnswerGate(input) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
29
|
+
const open = input.todos.filter(todo => todo.status !== 'completed');
|
|
30
|
+
const remaining = (input.remaining ?? []).filter(item => item.trim());
|
|
31
|
+
// A stand-in summary is the serialized output, never the model's own account of the work.
|
|
32
|
+
const reportsUnfinished = !input.summaryStoodIn && (remaining.length > 0 || declaresUnfinishedWork(input.summary));
|
|
33
|
+
// Open plan items the completion accounts for as unfinished belong to the unfinished gate; the
|
|
34
|
+
// plan gate is for a plan left open under a completion that claims to be done.
|
|
35
|
+
const failed = [
|
|
36
|
+
...(input.summaryStoodIn ? ['summary'] : []),
|
|
37
|
+
...(reportsUnfinished ? ['unfinished'] : open.length ? ['todos'] : []),
|
|
38
|
+
];
|
|
8
39
|
if (!failed.length)
|
|
9
40
|
return undefined;
|
|
10
|
-
const
|
|
41
|
+
const unfinishedWaiver = !reportsUnfinished ? undefined
|
|
42
|
+
: input.timeLeftMs !== undefined && input.timeLeftMs < UNFINISHED_MIN_TIME_MS ? 'outOfTime'
|
|
43
|
+
: (input.idleUnfinishedAsks ?? 0) >= MAX_IDLE_UNFINISHED_ASKS ? 'noFurtherWork' : undefined;
|
|
44
|
+
const gates = failed.filter(gate => gate === 'unfinished' ? unfinishedWaiver === undefined : (input.asked?.[gate] ?? 0) < MAX_GATE_ASKS);
|
|
11
45
|
const waived = failed.filter(gate => !gates.includes(gate));
|
|
46
|
+
const waiver = unfinishedWaiver && waived.includes('unfinished') ? { unfinishedWaiver } : {};
|
|
12
47
|
if (!gates.length)
|
|
13
|
-
return { gates, waived, message: '' };
|
|
48
|
+
return { gates, waived, message: '', ...waiver };
|
|
14
49
|
const parts = [];
|
|
15
50
|
if (gates.includes('summary')) {
|
|
16
51
|
parts.push('It has no summary. The summary is the final answer the user reads; without one they see only the raw output object. Send summary as markdown (the outcome first, then what changed, how it was verified, and anything not done) and tests as one line per check that ran, or [] when none did, beside outcome and output.');
|
|
17
52
|
}
|
|
18
53
|
if (gates.includes('todos')) {
|
|
19
54
|
// Ids and statuses only: the plan's text is model-authored and is already in the todo snapshot.
|
|
20
|
-
const named =
|
|
21
|
-
const more =
|
|
22
|
-
parts.push(`The plan still lists ${
|
|
55
|
+
const named = open.slice(0, MAX_NAMED_TODOS).map(todo => `${todo.id} (${todo.status})`).join(', ');
|
|
56
|
+
const more = open.length > MAX_NAMED_TODOS ? `, and ${open.length - MAX_NAMED_TODOS} more` : '';
|
|
57
|
+
parts.push(`The plan still lists ${open.length} unfinished ${open.length === 1 ? 'item' : 'items'}: ${named}${more}. Do the work that is left, using tools. For work that is already done, send update_todos with the true statuses in the same batch as complete_agent. Do not close an item, or ship a change you do not believe in, only to make the plan read as finished.`);
|
|
58
|
+
}
|
|
59
|
+
if (gates.includes('unfinished')) {
|
|
60
|
+
const named = remaining.slice(0, MAX_NAMED_REMAINING).map(item => {
|
|
61
|
+
const line = item.replace(/\s+/g, ' ').trim();
|
|
62
|
+
return line.length > MAX_REMAINING_CHARS ? `${line.slice(0, MAX_REMAINING_CHARS)}…` : line;
|
|
63
|
+
});
|
|
64
|
+
const what = named.length
|
|
65
|
+
? ` (${named.join('; ')}${remaining.length > named.length ? `; and ${remaining.length - named.length} more` : ''})`
|
|
66
|
+
: '';
|
|
67
|
+
const time = input.timeLeftMs !== undefined ? ` ${timeLeftPhrase(input.timeLeftMs)} of this run's time limit remain, and time left unused is worth nothing.` : '';
|
|
68
|
+
parts.push(`You report the task as not finished${what}. A run does not end while there is work it can still do: stopping now leaves the task failed.${time} Keep working with tools on what is missing or failing, and if the current approach is stuck, try a different one instead of repeating it. Call complete_agent again when the task is done. Only if nothing more can be done without the user (a credential, a decision, access only they have), say exactly what you need from them under "## Not done" and call complete_agent again.`);
|
|
23
69
|
}
|
|
24
|
-
return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')} Then call complete_agent again
|
|
70
|
+
return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')}${gates.includes('unfinished') ? '' : ' Then call complete_agent again.'}`, ...waiver };
|
|
25
71
|
}
|
package/dist/src/completion.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ export declare const RESPONSE_STRUCTURE_GUIDANCE = "Write user-facing text, incl
|
|
|
14
14
|
* breaks are wanted, next to the value they shape.
|
|
15
15
|
*/
|
|
16
16
|
export declare const SUMMARY_DESCRIPTION = "Markdown shown to the user as the final answer. Write line breaks as \\n escapes: lead with the outcome, then short headings and bullet lists, and open and close each fenced code block on its own line. Never one unbroken paragraph.";
|
|
17
|
+
/** Entries kept from a completion's `remaining` list. */
|
|
18
|
+
export declare const REMAINING_LIMIT = 20;
|
|
19
|
+
/**
|
|
20
|
+
* The completion states, as data rather than somewhere in its prose, what the task still lacks.
|
|
21
|
+
* A summary that said "frame output still missing" ended a run with time on the clock, because
|
|
22
|
+
* nothing the host could read told it the task was unfinished (completion-gates.ts).
|
|
23
|
+
*/
|
|
24
|
+
export declare const REMAINING_DESCRIPTION = "Everything the task asks for that is still missing, failing or unverified, one short entry each. [] only when every requirement is met and you have checked it. Be exact: this is read by the runtime, not only by the user.";
|
|
17
25
|
export declare const COMPLETION_GUIDANCE = "Finish with complete_agent alone or final JSON. Todos/artifacts do not finish a node. Compare deliverables and verification evidence with acceptance criteria. Fulfill assigned requirements: intake/research nodes hand off downstream work; implementation nodes finish implementation and verification, not a progress checkpoint. Continue available work. For a concrete external blocker, report the blocker and unfinished work honestly. Use a blocked outcome if available; otherwise the sole outcome permits a terminal report, not a claim that the task is done. Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off. Preserve required fields and valid JSON; escape quotes and Windows backslashes or use C:/repo/file.ts, and write each summary line break as \\n rather than dropping it. Never claim unperformed work.";
|
|
18
26
|
/** Control-plane completion remains available when the execution-tool budget is exhausted. */
|
|
19
27
|
export declare function completionTool(options: RunOptions): ToolSchema;
|
package/dist/src/completion.js
CHANGED
|
@@ -14,6 +14,21 @@ export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including th
|
|
|
14
14
|
* breaks are wanted, next to the value they shape.
|
|
15
15
|
*/
|
|
16
16
|
export const SUMMARY_DESCRIPTION = 'Markdown shown to the user as the final answer. Write line breaks as \\n escapes: lead with the outcome, then short headings and bullet lists, and open and close each fenced code block on its own line. Never one unbroken paragraph.';
|
|
17
|
+
/** Entries kept from a completion's `remaining` list. */
|
|
18
|
+
export const REMAINING_LIMIT = 20;
|
|
19
|
+
/**
|
|
20
|
+
* The completion states, as data rather than somewhere in its prose, what the task still lacks.
|
|
21
|
+
* A summary that said "frame output still missing" ended a run with time on the clock, because
|
|
22
|
+
* nothing the host could read told it the task was unfinished (completion-gates.ts).
|
|
23
|
+
*/
|
|
24
|
+
export const REMAINING_DESCRIPTION = 'Everything the task asks for that is still missing, failing or unverified, one short entry each. [] only when every requirement is met and you have checked it. Be exact: this is read by the runtime, not only by the user.';
|
|
25
|
+
/** The `remaining` entries of a completion envelope: nonempty strings, bounded, or undefined when it has none. */
|
|
26
|
+
function remainingItems(value) {
|
|
27
|
+
if (!Array.isArray(value))
|
|
28
|
+
return undefined;
|
|
29
|
+
const items = value.filter((item) => typeof item === 'string' && item.trim().length > 0).slice(0, REMAINING_LIMIT).map(item => item.slice(0, 500));
|
|
30
|
+
return items.length ? items : undefined;
|
|
31
|
+
}
|
|
17
32
|
export const COMPLETION_GUIDANCE = `Finish with complete_agent alone or final JSON. Todos/artifacts do not finish a node. Compare deliverables and verification evidence with acceptance criteria. Fulfill assigned requirements: intake/research nodes hand off downstream work; implementation nodes finish implementation and verification, not a progress checkpoint. Continue available work. For a concrete external blocker, report the blocker and unfinished work honestly. Use a blocked outcome if available; otherwise the sole outcome permits a terminal report, not a claim that the task is done. ${FINAL_RESPONSE_GUIDANCE} Preserve required fields and valid JSON; escape quotes and Windows backslashes or use C:/repo/file.ts, and write each summary line break as \\n rather than dropping it. Never claim unperformed work.`;
|
|
18
33
|
/** Expand Andorra's artifact shorthand into provider-visible JSON Schema at every depth. */
|
|
19
34
|
function providerOutputSchema(schema) {
|
|
@@ -73,6 +88,9 @@ export function completionTool(options) {
|
|
|
73
88
|
type: 'object',
|
|
74
89
|
properties: {
|
|
75
90
|
summary: { type: 'string', description: SUMMARY_DESCRIPTION }, tests: { type: 'array', items: { type: 'string', description: 'One short line: the check that ran, then its outcome.' } },
|
|
91
|
+
// Only the completion that ends a run carries it: a node that hands off to another node
|
|
92
|
+
// reports through its outcome and output, and its schema stays as it was.
|
|
93
|
+
...(options.finalAnswerOutcomes?.length ? { remaining: { type: 'array', maxItems: REMAINING_LIMIT, items: { type: 'string' }, description: REMAINING_DESCRIPTION } } : {}),
|
|
76
94
|
...(outcomes ? { artifacts: { type: 'array', maxItems: 50, items: { type: 'object', properties: { type: { type: 'string' }, ref: { type: 'string' } }, required: ['type', 'ref'], additionalProperties: false } } } : {}),
|
|
77
95
|
...(outcomes ? { outcome: { type: 'string', enum: outcomes }, output: providerOutputSchema(options.outputSchema ?? { type: 'object' }) } : {}),
|
|
78
96
|
},
|
|
@@ -626,7 +644,7 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
|
|
|
626
644
|
const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes));
|
|
627
645
|
return { summary,
|
|
628
646
|
tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
|
|
629
|
-
artifacts: value.artifacts ?? [] };
|
|
647
|
+
artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
|
|
630
648
|
}
|
|
631
649
|
if (value && typeof value.summary === 'string' && value.summary.trim()
|
|
632
650
|
&& Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import stringWidth from 'string-width';
|
|
2
2
|
import { stripVTControlCharacters } from 'node:util';
|
|
3
|
-
import { DIM, FAINT, GRAY,
|
|
3
|
+
import { DIM, FAINT, GRAY, SUBTLE, WHITE, accentSgr } from './palette.js';
|
|
4
4
|
import { panelRowText } from './side-panel.js';
|
|
5
5
|
/**
|
|
6
6
|
* The dashboard (Ctrl+B): session tokens, task timing, the Todo list and the graph
|
|
@@ -202,7 +202,7 @@ export function dashboardRows(view, width, height) {
|
|
|
202
202
|
const active = view.todos.filter(todo => todo.status === 'in_progress').length;
|
|
203
203
|
const todoSummary = row(seg(`${done} done`, GRAY), seg(' · ', FAINT), seg(`${active} active`, GRAY), seg(' · ', FAINT), seg(`${view.todos.length - done - active} pending`, GRAY));
|
|
204
204
|
const todoItems = [...view.todos.filter(todo => todo.status !== 'completed'), ...view.todos.filter(todo => todo.status === 'completed')];
|
|
205
|
-
const todoRow = (todo) => todo.status === 'completed' ? row(seg('✓ ',
|
|
205
|
+
const todoRow = (todo) => todo.status === 'completed' ? row(seg('✓ ', SUBTLE), seg(todo.text, GRAY))
|
|
206
206
|
: todo.status === 'in_progress' ? row(seg('● ', accentSgr()), seg(todo.text, WHITE)) : row(seg('○ ', FAINT), seg(todo.text, GRAY));
|
|
207
207
|
const todoBody = (size) => {
|
|
208
208
|
const capacity = Math.max(0, size - 1);
|
package/dist/src/deadline.js
CHANGED
|
@@ -153,8 +153,12 @@ export function bindUserWaits(context, budget, signal = budget.signal) {
|
|
|
153
153
|
};
|
|
154
154
|
const askUser = context.askUser;
|
|
155
155
|
const approvePlan = context.approvePlan;
|
|
156
|
+
const waitOutside = context.waitOutside;
|
|
156
157
|
return {
|
|
157
158
|
...context,
|
|
159
|
+
// A wait on someone outside the run (a pull request's reviewer) is no more the run's work than an answer from
|
|
160
|
+
// the user is. Each enclosing budget wraps the one inside it, so every clock from the run's down is paused.
|
|
161
|
+
waitOutside: work => awaiting(() => waitOutside ? waitOutside(work) : work()),
|
|
158
162
|
signal,
|
|
159
163
|
userSignal: context.userSignal ?? context.signal,
|
|
160
164
|
approve: (name, args, promptSignal) => awaiting(() => context.approve(name, args, promptSignal)),
|
|
@@ -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 Code to use
|
|
19
|
-
const TOO_LARGE_MESSAGE = 'This
|
|
18
|
+
const UPDATE_MESSAGE = 'Update Andorra Code to use Graph Manager.';
|
|
19
|
+
const TOO_LARGE_MESSAGE = 'This graph is too large to send to Graph 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
|
|
74
|
+
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read graph', andorra_graph_guide: 'Read guide',
|
|
75
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
|
|
76
|
+
andorra_graph_edge_upsert: 'Connect', andorra_graph_edge_remove: 'Remove connection', andorra_graph_patch: 'Edit graph',
|
|
77
77
|
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save version', andorra_graph_discard: 'Discard draft',
|
|
78
|
-
andorra_graph_delete: 'Delete
|
|
78
|
+
andorra_graph_delete: 'Delete graph', andorra_graph_restore: 'Restore graph',
|
|
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 = 'Graph 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: `Graph 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: 'Graph 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 = `Graph 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('Graph 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('Graph 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: `Graph 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 : 'Graph 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-runner.js
CHANGED
|
@@ -247,12 +247,49 @@ export async function runGraph(graph, options) {
|
|
|
247
247
|
if (!(options.inheritedSkills ?? []).includes(skillId))
|
|
248
248
|
activeSkills.delete(skillId);
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
// A fresh run normally starts at the entry. A wake addressed to a node (an Auto-fix prompt goes to the node that
|
|
251
|
+
// switched Auto-fix on) starts at that node instead, when it is still an agent of this graph and can start with
|
|
252
|
+
// only what the run itself supplies: a node that needs its predecessor's handoff would fail its own input checks.
|
|
253
|
+
const startNode = (() => {
|
|
254
|
+
const requested = options.resumeFrom === undefined ? options.startNode : undefined;
|
|
255
|
+
const node = requested === undefined ? undefined : pinned.nodes[requested];
|
|
256
|
+
if (requested === undefined || node?.type !== 'agent')
|
|
257
|
+
return pinned.entry;
|
|
258
|
+
if (node.inputSchema) {
|
|
259
|
+
try {
|
|
260
|
+
validateValue(node.inputSchema, resolveMapping(node.inputs, { run: { input: runInput, state: runState, loop: { iteration: 1 } } }, node.inputSchema), `Node ${requested} inputs`);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return pinned.entry;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// A join that waits for every branch can complete only when each branch it waits for can run from here. A node
|
|
267
|
+
// on one branch of a fork reaches the join without its siblings, and the run would end at the join with the
|
|
268
|
+
// rest of the graph skipped; starting at the entry runs every branch, as before.
|
|
269
|
+
const reachable = new Set();
|
|
270
|
+
for (const frontier = [requested]; frontier.length > 0;) {
|
|
271
|
+
const nodeId = frontier.pop();
|
|
272
|
+
if (reachable.has(nodeId))
|
|
273
|
+
continue;
|
|
274
|
+
reachable.add(nodeId);
|
|
275
|
+
for (const edge of pinned.edges)
|
|
276
|
+
if (edge.source === nodeId)
|
|
277
|
+
frontier.push(edge.target);
|
|
278
|
+
}
|
|
279
|
+
const joinsComplete = [...reachable].every(nodeId => {
|
|
280
|
+
const join = pinned.nodes[nodeId];
|
|
281
|
+
if (join?.type !== 'join' || join.join?.mode === 'any')
|
|
282
|
+
return true;
|
|
283
|
+
return pinned.edges.every(edge => edge.target !== nodeId || edge.bootstrap || reachable.has(edge.source));
|
|
284
|
+
});
|
|
285
|
+
return joinsComplete ? requested : pinned.entry;
|
|
286
|
+
})();
|
|
287
|
+
const queue = [{ nodeId: startNode, generation: 0, path: [], inputs: {}, predecessors: {} }];
|
|
251
288
|
const visits = new Map();
|
|
252
289
|
const executed = new Set();
|
|
253
290
|
let nextGeneration = 0;
|
|
254
291
|
const pendingJoins = new Map();
|
|
255
|
-
let currentNode =
|
|
292
|
+
let currentNode = startNode;
|
|
256
293
|
let lastCompletion;
|
|
257
294
|
if (options.resumeFrom) {
|
|
258
295
|
// Rehydrate the scheduler from the journal replay of a stopped attempt. The frontier is
|