@andorra-labs/code 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acp-agent.d.ts +6 -0
- package/dist/src/acp-agent.js +15 -4
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +15 -10
- package/dist/src/agent-mcp-catalog.js +1 -0
- package/dist/src/agent-mcp.d.ts +4 -1
- package/dist/src/agent-mcp.js +46 -10
- package/dist/src/andorra/entry.d.ts +10 -0
- package/dist/src/andorra/entry.js +18 -4
- package/dist/src/andorra/hosted.d.ts +2 -1
- package/dist/src/andorra/hosted.js +2 -1
- package/dist/src/andorra/notices.d.ts +5 -0
- package/dist/src/andorra/notices.js +7 -0
- package/dist/src/andorra/state.d.ts +3 -2
- package/dist/src/andorra/state.js +4 -4
- package/dist/src/andorra/terminal.js +7 -2
- package/dist/src/anthropic-credentials.js +2 -0
- package/dist/src/app-server/error.d.ts +5 -0
- package/dist/src/app-server/error.js +7 -0
- package/dist/src/app-server/protocol.d.ts +22 -44
- package/dist/src/app-server/protocol.js +5 -1
- package/dist/src/app-server/workspace.d.ts +89 -0
- package/dist/src/app-server/workspace.js +457 -11
- package/dist/src/app-server.d.ts +465 -32
- package/dist/src/app-server.js +3308 -517
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/bridge/cloud.d.ts +27 -0
- package/dist/src/bridge/cloud.js +187 -0
- package/dist/src/bridge/command.d.ts +30 -0
- package/dist/src/bridge/command.js +347 -0
- package/dist/src/bridge/control.d.ts +68 -0
- package/dist/src/bridge/control.js +233 -0
- package/dist/src/bridge/engines.d.ts +90 -0
- package/dist/src/bridge/engines.js +601 -0
- package/dist/src/bridge/host-ops.d.ts +9 -0
- package/dist/src/bridge/host-ops.js +129 -0
- package/dist/src/bridge/host.d.ts +47 -0
- package/dist/src/bridge/host.js +540 -0
- package/dist/src/bridge/link.d.ts +38 -0
- package/dist/src/bridge/link.js +508 -0
- package/dist/src/bridge/login-link.d.ts +29 -0
- package/dist/src/bridge/login-link.js +54 -0
- package/dist/src/bridge/protocol.d.ts +136 -0
- package/dist/src/bridge/protocol.js +11 -0
- package/dist/src/bridge/store.d.ts +12 -0
- package/dist/src/bridge/store.js +61 -0
- package/dist/src/bridge/wording.d.ts +6 -0
- package/dist/src/bridge/wording.js +10 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.js +7 -1
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +28 -17
- package/dist/src/change-authors.d.ts +41 -0
- package/dist/src/change-authors.js +146 -0
- package/dist/src/claude-provider.js +3 -1
- package/dist/src/cli.js +202 -38
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +15 -15
- package/dist/src/command-screens.d.ts +6 -0
- package/dist/src/command-screens.js +19 -14
- package/dist/src/commands.d.ts +14 -1
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion.js +82 -5
- package/dist/src/config.d.ts +71 -3
- package/dist/src/config.js +202 -77
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/deadline.js +13 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +22 -0
- package/dist/src/default-graph.js +1 -1
- package/dist/src/file-diff.d.ts +4 -0
- package/dist/src/file-diff.js +2 -1
- package/dist/src/github-app/agent-writes.d.ts +102 -0
- package/dist/src/github-app/agent-writes.js +320 -0
- package/dist/src/github-app/client.d.ts +349 -0
- package/dist/src/github-app/client.js +810 -0
- package/dist/src/github-app/event-source.d.ts +208 -0
- package/dist/src/github-app/event-source.js +684 -0
- package/dist/src/github-app/metrics.d.ts +32 -0
- package/dist/src/github-app/metrics.js +49 -0
- package/dist/src/github-app/review-loop.d.ts +274 -0
- package/dist/src/github-app/review-loop.js +1177 -0
- package/dist/src/github-app/review-node.d.ts +81 -0
- package/dist/src/github-app/review-node.js +205 -0
- package/dist/src/github-app/review-post.d.ts +73 -0
- package/dist/src/github-app/review-post.js +139 -0
- package/dist/src/github-app/review-text.d.ts +107 -0
- package/dist/src/github-app/review-text.js +1133 -0
- package/dist/src/github-app/review-threads.d.ts +47 -0
- package/dist/src/github-app/review-threads.js +107 -0
- package/dist/src/github-app/reviewer.d.ts +121 -0
- package/dist/src/github-app/reviewer.js +598 -0
- package/dist/src/github-app/store.d.ts +59 -0
- package/dist/src/github-app/store.js +148 -0
- package/dist/src/github-app/triggers.d.ts +141 -0
- package/dist/src/github-app/triggers.js +441 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/github-names.d.ts +8 -0
- package/dist/src/github-names.js +8 -0
- package/dist/src/glob-search.d.ts +61 -0
- package/dist/src/glob-search.js +180 -0
- package/dist/src/graph-health.js +13 -4
- package/dist/src/graph-manager-chat.js +1 -1
- package/dist/src/graph-preview.d.ts +46 -0
- package/dist/src/graph-preview.js +55 -0
- package/dist/src/graph-provider-portability.js +34 -11
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +88 -10
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +11 -9
- package/dist/src/graph-sync.js +3 -3
- package/dist/src/graph-ui/app.js +201 -40
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +3 -1
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +26 -5
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +28 -20
- package/dist/src/graphs.d.ts +34 -1
- package/dist/src/graphs.js +162 -17
- package/dist/src/image-input.d.ts +16 -0
- package/dist/src/image-input.js +41 -0
- package/dist/src/membership.d.ts +30 -1
- package/dist/src/membership.js +48 -8
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +7 -1
- package/dist/src/model-metadata.js +39 -17
- package/dist/src/model-relay/local.d.ts +116 -0
- package/dist/src/model-relay/local.js +468 -0
- package/dist/src/model-relay/remote.d.ts +129 -0
- package/dist/src/model-relay/remote.js +252 -0
- package/dist/src/model-relay/runs.d.ts +34 -0
- package/dist/src/model-relay/runs.js +146 -0
- package/dist/src/model-relay/wire.d.ts +5 -0
- package/dist/src/model-relay/wire.js +5 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/project-registry.d.ts +21 -0
- package/dist/src/project-registry.js +74 -0
- package/dist/src/provider-engine.js +3 -0
- package/dist/src/provider-import.d.ts +0 -12
- package/dist/src/provider-import.js +7 -195
- package/dist/src/providers.d.ts +40 -2
- package/dist/src/providers.js +93 -23
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +87 -0
- package/dist/src/pull-request-logs.js +183 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +369 -8
- package/dist/src/pull-requests.js +524 -55
- package/dist/src/react-runtime.js +38 -5
- package/dist/src/remote/engine-pool.d.ts +88 -4
- package/dist/src/remote/engine-pool.js +379 -90
- package/dist/src/remote/roots.d.ts +19 -0
- package/dist/src/remote/roots.js +45 -7
- package/dist/src/remote/types.d.ts +0 -44
- package/dist/src/run-control.d.ts +17 -0
- package/dist/src/run-control.js +47 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +7 -2
- package/dist/src/run-records.js +71 -6
- package/dist/src/runtime.d.ts +9 -1
- package/dist/src/runtime.js +24 -4
- package/dist/src/session-changes.d.ts +35 -0
- package/dist/src/session-changes.js +194 -6
- package/dist/src/session-monitor.js +2 -1
- package/dist/src/session-reaper.d.ts +1 -1
- package/dist/src/session-reaper.js +6 -1
- package/dist/src/session-summary.d.ts +2 -1
- package/dist/src/session-summary.js +2 -1
- package/dist/src/sessions.d.ts +11 -1
- package/dist/src/sessions.js +17 -4
- package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
- package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/runtime-skills.js +1 -1
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +17 -0
- package/dist/src/telemetry/emitter.js +76 -5
- package/dist/src/telemetry/schema.d.ts +47 -2
- package/dist/src/telemetry/schema.js +120 -5
- package/dist/src/telemetry/surface.d.ts +3 -1
- package/dist/src/telemetry/surface.js +4 -1
- package/dist/src/telemetry/uploader.d.ts +6 -1
- package/dist/src/telemetry/uploader.js +22 -3
- package/dist/src/terminal-ui.d.ts +1 -0
- package/dist/src/terminal-ui.js +10 -3
- package/dist/src/test-edit-guard.d.ts +7 -0
- package/dist/src/test-edit-guard.js +49 -1
- package/dist/src/timers.d.ts +2 -0
- package/dist/src/tools.js +59 -9
- package/dist/src/transcript.js +8 -2
- package/dist/src/types.d.ts +7 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +6 -1
- package/dist/src/remote/cert.d.ts +0 -11
- package/dist/src/remote/cert.js +0 -87
- package/dist/src/remote/client.d.ts +0 -119
- package/dist/src/remote/client.js +0 -544
- package/dist/src/remote/command.d.ts +0 -4
- package/dist/src/remote/command.js +0 -194
- package/dist/src/remote/errors.d.ts +0 -11
- package/dist/src/remote/errors.js +0 -14
- package/dist/src/remote/network.d.ts +0 -22
- package/dist/src/remote/network.js +0 -102
- package/dist/src/remote/pairing.d.ts +0 -63
- package/dist/src/remote/pairing.js +0 -299
- package/dist/src/remote/pem.d.ts +0 -2
- package/dist/src/remote/pem.js +0 -7
- package/dist/src/remote/serve.d.ts +0 -68
- package/dist/src/remote/serve.js +0 -244
- package/dist/src/remote/server.d.ts +0 -21
- package/dist/src/remote/server.js +0 -406
|
@@ -6,4 +6,23 @@ export interface AuthorizedRoot {
|
|
|
6
6
|
kind: 'project' | 'share';
|
|
7
7
|
}
|
|
8
8
|
export declare function projectRootId(realPath: string): string;
|
|
9
|
+
/** Whether `path` is `folder` or lies inside it, compared by path segment (and without case on Windows). */
|
|
10
|
+
export declare function isInsideFolder(folder: string, path: string): boolean;
|
|
11
|
+
/** The folders this machine shares through `andorra bridge folders`, by real path; missing ones are left out. */
|
|
12
|
+
export declare function sharedFolders(config: Config): Promise<AuthorizedRoot[]>;
|
|
13
|
+
/**
|
|
14
|
+
* The real path of the directory at `path` when it lies inside a shared folder; `undefined` when it does not exist.
|
|
15
|
+
* Throws `outside` when the directory, or the path as written, is not inside any shared folder. Symbolic links are
|
|
16
|
+
* resolved first, so a link inside a folder that points out of it is outside.
|
|
17
|
+
*/
|
|
18
|
+
export declare function directoryInsideFolders(folders: AuthorizedRoot[], path: string): Promise<{
|
|
19
|
+
inside: true;
|
|
20
|
+
path: string;
|
|
21
|
+
} | {
|
|
22
|
+
inside: false;
|
|
23
|
+
} | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* What a desktop may reach on this machine: the shared folders, plus the configured projects whose real path lies
|
|
26
|
+
* inside one of them. With no folders shared, nothing.
|
|
27
|
+
*/
|
|
9
28
|
export declare function authorizedRoots(config: Config): Promise<AuthorizedRoot[]>;
|
package/dist/src/remote/roots.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { realpath, stat } from 'node:fs/promises';
|
|
3
|
-
import { basename } from 'node:path';
|
|
3
|
+
import { basename, isAbsolute, relative, sep } from 'node:path';
|
|
4
4
|
export function projectRootId(realPath) {
|
|
5
5
|
const canonical = process.platform === 'win32' ? realPath.toLowerCase() : realPath;
|
|
6
6
|
return `proj-${createHash('sha256').update(canonical).digest('hex').slice(0, 16)}`;
|
|
@@ -15,22 +15,60 @@ async function directoryAt(path) {
|
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/** Whether `path` is `folder` or lies inside it, compared by path segment (and without case on Windows). */
|
|
19
|
+
export function isInsideFolder(folder, path) {
|
|
20
|
+
const fold = (value) => process.platform === 'win32' ? value.toLowerCase() : value;
|
|
21
|
+
const rel = relative(fold(folder), fold(path));
|
|
22
|
+
if (rel === '')
|
|
23
|
+
return true;
|
|
24
|
+
return !isAbsolute(rel) && rel.split(sep)[0] !== '..';
|
|
25
|
+
}
|
|
26
|
+
/** The folders this machine shares through `andorra bridge folders`, by real path; missing ones are left out. */
|
|
27
|
+
export async function sharedFolders(config) {
|
|
28
|
+
const folders = [];
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
for (const share of config.bridge?.folders ?? []) {
|
|
31
|
+
const realPath = await directoryAt(share.path);
|
|
32
|
+
if (!realPath || seen.has(realPath))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(realPath);
|
|
35
|
+
folders.push({ id: `share-${share.id}`, label: share.label?.trim() || basename(realPath) || realPath, path: realPath, kind: 'share' });
|
|
36
|
+
}
|
|
37
|
+
return folders;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The real path of the directory at `path` when it lies inside a shared folder; `undefined` when it does not exist.
|
|
41
|
+
* Throws `outside` when the directory, or the path as written, is not inside any shared folder. Symbolic links are
|
|
42
|
+
* resolved first, so a link inside a folder that points out of it is outside.
|
|
43
|
+
*/
|
|
44
|
+
export async function directoryInsideFolders(folders, path) {
|
|
45
|
+
const actual = await directoryAt(path);
|
|
46
|
+
if (actual === undefined)
|
|
47
|
+
return folders.some(folder => isInsideFolder(folder.path, path)) ? undefined : { inside: false };
|
|
48
|
+
return folders.some(folder => isInsideFolder(folder.path, actual)) ? { inside: true, path: actual } : { inside: false };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What a desktop may reach on this machine: the shared folders, plus the configured projects whose real path lies
|
|
52
|
+
* inside one of them. With no folders shared, nothing.
|
|
53
|
+
*/
|
|
18
54
|
export async function authorizedRoots(config) {
|
|
55
|
+
const folders = await sharedFolders(config);
|
|
56
|
+
if (folders.length === 0)
|
|
57
|
+
return [];
|
|
19
58
|
const roots = [];
|
|
20
59
|
const seen = new Set();
|
|
21
60
|
for (const project of config.projects ?? []) {
|
|
22
61
|
const realPath = await directoryAt(project.path);
|
|
23
|
-
if (!realPath || seen.has(realPath))
|
|
62
|
+
if (!realPath || seen.has(realPath) || !folders.some(folder => isInsideFolder(folder.path, realPath)))
|
|
24
63
|
continue;
|
|
25
64
|
seen.add(realPath);
|
|
26
65
|
roots.push({ id: projectRootId(realPath), label: project.name?.trim() || basename(realPath) || realPath, path: realPath, kind: 'project' });
|
|
27
66
|
}
|
|
28
|
-
for (const
|
|
29
|
-
|
|
30
|
-
if (!realPath || seen.has(realPath))
|
|
67
|
+
for (const folder of folders) {
|
|
68
|
+
if (seen.has(folder.path))
|
|
31
69
|
continue;
|
|
32
|
-
seen.add(
|
|
33
|
-
roots.push(
|
|
70
|
+
seen.add(folder.path);
|
|
71
|
+
roots.push(folder);
|
|
34
72
|
}
|
|
35
73
|
return roots;
|
|
36
74
|
}
|
|
@@ -1,52 +1,8 @@
|
|
|
1
|
-
export type RemoteTransport = 'https' | 'http';
|
|
2
|
-
export type RemoteGrant = 'browse' | 'full';
|
|
3
|
-
export interface RemoteDevice {
|
|
4
|
-
id: string;
|
|
5
|
-
token: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
addedAt: string;
|
|
8
|
-
lastSeenAt?: string;
|
|
9
|
-
grant?: RemoteGrant;
|
|
10
|
-
}
|
|
11
|
-
export interface RemoteInvitation {
|
|
12
|
-
token: string;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
expiresAt: string;
|
|
15
|
-
redeemedAt?: string;
|
|
16
|
-
grant?: RemoteGrant;
|
|
17
|
-
}
|
|
18
1
|
export interface RemoteShare {
|
|
19
2
|
id: string;
|
|
20
3
|
path: string;
|
|
21
4
|
label?: string;
|
|
22
5
|
}
|
|
23
|
-
export interface RemoteHosting {
|
|
24
|
-
installId?: string;
|
|
25
|
-
port?: number;
|
|
26
|
-
transport?: RemoteTransport;
|
|
27
|
-
invitation?: RemoteInvitation | null;
|
|
28
|
-
devices?: RemoteDevice[];
|
|
29
|
-
shares?: RemoteShare[];
|
|
30
|
-
}
|
|
31
|
-
export interface RemoteWorkspace {
|
|
32
|
-
id: string;
|
|
33
|
-
nickname: string;
|
|
34
|
-
hosts: string[];
|
|
35
|
-
host?: string;
|
|
36
|
-
port: number;
|
|
37
|
-
transport: RemoteTransport;
|
|
38
|
-
fingerprint: string;
|
|
39
|
-
certPem: string;
|
|
40
|
-
token: string;
|
|
41
|
-
hostname?: string;
|
|
42
|
-
platform?: string;
|
|
43
|
-
version?: string;
|
|
44
|
-
addedAt: string;
|
|
45
|
-
}
|
|
46
|
-
export interface RemoteConfig {
|
|
47
|
-
hosting?: RemoteHosting;
|
|
48
|
-
workspaces?: RemoteWorkspace[];
|
|
49
|
-
}
|
|
50
6
|
export interface ProjectEntry {
|
|
51
7
|
path: string;
|
|
52
8
|
name?: string;
|
|
@@ -3,16 +3,33 @@ export declare class RunControl {
|
|
|
3
3
|
private paused;
|
|
4
4
|
private readonly listeners;
|
|
5
5
|
private readonly directions;
|
|
6
|
+
private compactionPending;
|
|
6
7
|
private readonly steerListeners;
|
|
8
|
+
private budgetHolds;
|
|
9
|
+
private readonly holdListeners;
|
|
7
10
|
yolo?: boolean;
|
|
8
11
|
permissions?: import('./permissions.js').PermissionMode;
|
|
9
12
|
get isPaused(): boolean;
|
|
10
13
|
get signal(): AbortSignal;
|
|
11
14
|
get revision(): number;
|
|
15
|
+
/** Whether the run's wall-time budgets are held, for example while a model request waits for a desktop to take it. */
|
|
16
|
+
get budgetsHeld(): boolean;
|
|
17
|
+
onBudgetHold(listener: (held: boolean) => void): () => void;
|
|
18
|
+
/** Holds every budget bound to this run until the returned function is called (once; holds nest). */
|
|
19
|
+
holdBudgets(): () => void;
|
|
20
|
+
/** Whether a /compact made during the run is still waiting for an agent to act on it. */
|
|
21
|
+
get compactionRequested(): boolean;
|
|
22
|
+
/** Hands a pending /compact to the agent that will act on it; true once per request (repeats before it is taken merge). */
|
|
23
|
+
takeCompactionRequest(): boolean;
|
|
12
24
|
messagesSince(revision: number): string[];
|
|
13
25
|
onChange(listener: (paused: boolean) => void): () => void;
|
|
14
26
|
onSteer(listener: () => void, subagentId?: string): () => void;
|
|
15
27
|
notifySteer(subagentId?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* /compact during a run: cuts the run's in-flight model request (as a steer does; tool calls finish) and
|
|
30
|
+
* continues a paused run without a direction. The agent summarizes its earlier messages before its next request.
|
|
31
|
+
*/
|
|
32
|
+
requestCompaction(): void;
|
|
16
33
|
pause(): boolean;
|
|
17
34
|
resume(direction: string): boolean;
|
|
18
35
|
wait(signal: AbortSignal): Promise<void>;
|
package/dist/src/run-control.js
CHANGED
|
@@ -3,12 +3,44 @@ export class RunControl {
|
|
|
3
3
|
paused = false;
|
|
4
4
|
listeners = new Set();
|
|
5
5
|
directions = [];
|
|
6
|
+
compactionPending = false;
|
|
6
7
|
steerListeners = new Map();
|
|
8
|
+
budgetHolds = 0;
|
|
9
|
+
holdListeners = new Set();
|
|
7
10
|
yolo;
|
|
8
11
|
permissions;
|
|
9
12
|
get isPaused() { return this.paused; }
|
|
10
13
|
get signal() { return this.controller.signal; }
|
|
11
14
|
get revision() { return this.directions.length; }
|
|
15
|
+
/** Whether the run's wall-time budgets are held, for example while a model request waits for a desktop to take it. */
|
|
16
|
+
get budgetsHeld() { return this.budgetHolds > 0; }
|
|
17
|
+
onBudgetHold(listener) {
|
|
18
|
+
this.holdListeners.add(listener);
|
|
19
|
+
return () => { this.holdListeners.delete(listener); };
|
|
20
|
+
}
|
|
21
|
+
/** Holds every budget bound to this run until the returned function is called (once; holds nest). */
|
|
22
|
+
holdBudgets() {
|
|
23
|
+
if (this.budgetHolds++ === 0)
|
|
24
|
+
for (const listener of [...this.holdListeners])
|
|
25
|
+
listener(true);
|
|
26
|
+
let released = false;
|
|
27
|
+
return () => {
|
|
28
|
+
if (released)
|
|
29
|
+
return;
|
|
30
|
+
released = true;
|
|
31
|
+
if (--this.budgetHolds === 0)
|
|
32
|
+
for (const listener of [...this.holdListeners])
|
|
33
|
+
listener(false);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Whether a /compact made during the run is still waiting for an agent to act on it. */
|
|
37
|
+
get compactionRequested() { return this.compactionPending; }
|
|
38
|
+
/** Hands a pending /compact to the agent that will act on it; true once per request (repeats before it is taken merge). */
|
|
39
|
+
takeCompactionRequest() {
|
|
40
|
+
const pending = this.compactionPending;
|
|
41
|
+
this.compactionPending = false;
|
|
42
|
+
return pending;
|
|
43
|
+
}
|
|
12
44
|
messagesSince(revision) { return this.directions.slice(revision); }
|
|
13
45
|
onChange(listener) {
|
|
14
46
|
this.listeners.add(listener);
|
|
@@ -25,6 +57,21 @@ export class RunControl {
|
|
|
25
57
|
if (target === subagentId)
|
|
26
58
|
listener();
|
|
27
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* /compact during a run: cuts the run's in-flight model request (as a steer does; tool calls finish) and
|
|
62
|
+
* continues a paused run without a direction. The agent summarizes its earlier messages before its next request.
|
|
63
|
+
*/
|
|
64
|
+
requestCompaction() {
|
|
65
|
+
this.compactionPending = true;
|
|
66
|
+
if (this.paused) {
|
|
67
|
+
this.controller = new AbortController();
|
|
68
|
+
this.paused = false;
|
|
69
|
+
for (const listener of this.listeners)
|
|
70
|
+
listener(false);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.notifySteer();
|
|
74
|
+
}
|
|
28
75
|
pause() {
|
|
29
76
|
if (this.paused)
|
|
30
77
|
return false;
|
|
@@ -54,7 +54,17 @@ export interface RunCheckpoint {
|
|
|
54
54
|
provider: string;
|
|
55
55
|
model?: string;
|
|
56
56
|
};
|
|
57
|
+
coveredThrough?: string;
|
|
57
58
|
}
|
|
59
|
+
export declare function toolBoundaryOpen(checkpoint: RunCheckpoint, progress: RunProgress): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* A checkpoint is saved once a model turn's tool calls have all returned, so an attempt that stops
|
|
62
|
+
* during the next turn leaves calls the saved conversation never mentions. The journal records each
|
|
63
|
+
* of them with its arguments and result, which is enough to append the missing turns: the resumed
|
|
64
|
+
* model then sees what already ran, and for a call that was cut off, that it did not finish.
|
|
65
|
+
* Returns undefined when the journal cannot name the calls (no ids, or a parallel copy's calls).
|
|
66
|
+
*/
|
|
67
|
+
export declare function coverUnsavedToolCalls(checkpoint: RunCheckpoint, journalLines: string[]): RunCheckpoint | undefined;
|
|
58
68
|
export declare function mergeRunProgress(older: RunProgress, newer: RunProgress): RunProgress;
|
|
59
69
|
export declare function replayRunJournal(lines: string[], graph: Graph, runScope?: {
|
|
60
70
|
input?: Record<string, unknown>;
|
package/dist/src/run-progress.js
CHANGED
|
@@ -13,6 +13,128 @@ const effectFreeToolNames = new Set([
|
|
|
13
13
|
export function isEffectfulToolCall(name) {
|
|
14
14
|
return name === undefined || !effectFreeToolNames.has(canonicalToolName(name));
|
|
15
15
|
}
|
|
16
|
+
export function toolBoundaryOpen(checkpoint, progress) {
|
|
17
|
+
const toolEvent = progress.lastEffectfulToolEvent?.[checkpoint.nodeId];
|
|
18
|
+
return toolEvent !== undefined && Date.parse(checkpoint.coveredThrough ?? checkpoint.savedAt) < Date.parse(toolEvent);
|
|
19
|
+
}
|
|
20
|
+
const INTERRUPTED_OUTPUT_TAIL = 8_000;
|
|
21
|
+
const ANSI_SEQUENCE = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
22
|
+
/**
|
|
23
|
+
* A checkpoint is saved once a model turn's tool calls have all returned, so an attempt that stops
|
|
24
|
+
* during the next turn leaves calls the saved conversation never mentions. The journal records each
|
|
25
|
+
* of them with its arguments and result, which is enough to append the missing turns: the resumed
|
|
26
|
+
* model then sees what already ran, and for a call that was cut off, that it did not finish.
|
|
27
|
+
* Returns undefined when the journal cannot name the calls (no ids, or a parallel copy's calls).
|
|
28
|
+
*/
|
|
29
|
+
export function coverUnsavedToolCalls(checkpoint, journalLines) {
|
|
30
|
+
if (Array.isArray(checkpoint.state.copies))
|
|
31
|
+
return undefined;
|
|
32
|
+
const known = new Set();
|
|
33
|
+
for (const message of checkpoint.messages) {
|
|
34
|
+
for (const call of message.toolCalls ?? [])
|
|
35
|
+
known.add(call.id);
|
|
36
|
+
if (message.role === 'tool' && message.toolCallId !== undefined)
|
|
37
|
+
known.add(message.toolCallId);
|
|
38
|
+
}
|
|
39
|
+
const toolEventTypes = new Set(['node.tool.started', 'node.tool.completed', 'node.tool.failed', 'node.tool.skipped']);
|
|
40
|
+
const events = [];
|
|
41
|
+
let coveredThrough = checkpoint.savedAt;
|
|
42
|
+
for (const line of journalLines) {
|
|
43
|
+
let event;
|
|
44
|
+
try {
|
|
45
|
+
event = JSON.parse(line);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const data = event.data ?? {};
|
|
51
|
+
if (data.nodeId !== checkpoint.nodeId || typeof event.time !== 'string')
|
|
52
|
+
continue;
|
|
53
|
+
if (toolEventTypes.has(event.type) && coveredThrough < event.time)
|
|
54
|
+
coveredThrough = event.time;
|
|
55
|
+
if (data.subagentId !== undefined)
|
|
56
|
+
continue;
|
|
57
|
+
events.push({ type: event.type, time: event.time, data });
|
|
58
|
+
}
|
|
59
|
+
let lastKnown = -1;
|
|
60
|
+
let lastSaved = -1;
|
|
61
|
+
events.forEach((event, index) => {
|
|
62
|
+
if (toolEventTypes.has(event.type) && typeof event.data.toolCallId === 'string' && known.has(event.data.toolCallId))
|
|
63
|
+
lastKnown = index;
|
|
64
|
+
if (event.time <= checkpoint.savedAt)
|
|
65
|
+
lastSaved = index;
|
|
66
|
+
});
|
|
67
|
+
const turns = [];
|
|
68
|
+
const results = new Map();
|
|
69
|
+
const partial = new Map();
|
|
70
|
+
const awaitingApproval = new Set();
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
let turn;
|
|
73
|
+
let text = '';
|
|
74
|
+
for (const { type, data } of events.slice((lastKnown >= 0 ? lastKnown : lastSaved) + 1)) {
|
|
75
|
+
const id = typeof data.toolCallId === 'string' ? data.toolCallId : undefined;
|
|
76
|
+
if (type === 'agent.turn.started') {
|
|
77
|
+
turn = undefined;
|
|
78
|
+
text = '';
|
|
79
|
+
}
|
|
80
|
+
else if (type === 'agent.message' && typeof data.text === 'string')
|
|
81
|
+
text = data.text;
|
|
82
|
+
else if (type === 'node.tool.started') {
|
|
83
|
+
if (data.copy !== undefined || id === undefined || typeof data.name !== 'string' || typeof data.arguments !== 'string')
|
|
84
|
+
return undefined;
|
|
85
|
+
if (known.has(id) || seen.has(id))
|
|
86
|
+
continue;
|
|
87
|
+
seen.add(id);
|
|
88
|
+
if (turn === undefined) {
|
|
89
|
+
turn = { text, calls: [] };
|
|
90
|
+
turns.push(turn);
|
|
91
|
+
text = '';
|
|
92
|
+
}
|
|
93
|
+
turn.calls.push({ id, name: data.name, arguments: data.arguments });
|
|
94
|
+
}
|
|
95
|
+
else if ((type === 'node.tool.completed' || type === 'node.tool.failed') && (id === undefined || !seen.has(id))
|
|
96
|
+
&& isEffectfulToolCall(typeof data.name === 'string' ? data.name : undefined)) {
|
|
97
|
+
// A call that ended here but whose start the journal lost cannot be shown to the model.
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
else if (id === undefined)
|
|
101
|
+
continue;
|
|
102
|
+
else if (type === 'node.tool.approval.requested')
|
|
103
|
+
awaitingApproval.add(id);
|
|
104
|
+
else if (type === 'node.tool.approval.decided')
|
|
105
|
+
awaitingApproval.delete(id);
|
|
106
|
+
else if (type === 'node.tool.output' && typeof data.output === 'string')
|
|
107
|
+
partial.set(id, ((partial.get(id) ?? '') + data.output).slice(-4 * INTERRUPTED_OUTPUT_TAIL));
|
|
108
|
+
else if ((type === 'node.tool.completed' || type === 'node.tool.failed' || type === 'node.tool.skipped') && typeof data.output === 'string')
|
|
109
|
+
results.set(id, data.output);
|
|
110
|
+
}
|
|
111
|
+
if (turns.length === 0)
|
|
112
|
+
return undefined;
|
|
113
|
+
const unfinished = (id) => {
|
|
114
|
+
if (awaitingApproval.has(id))
|
|
115
|
+
return 'Not executed: the run stopped while this call was waiting for approval. Run it again if it is still needed.';
|
|
116
|
+
const printed = (partial.get(id) ?? '').replace(ANSI_SEQUENCE, '').slice(-INTERRUPTED_OUTPUT_TAIL).trim();
|
|
117
|
+
return 'Interrupted: the run stopped while this call was running, so it did not finish. Anything it had already changed stays changed. Check the current state before running it again.'
|
|
118
|
+
+ (printed ? `\n\nOutput before it stopped:\n${printed}` : '');
|
|
119
|
+
};
|
|
120
|
+
const messages = [...checkpoint.messages];
|
|
121
|
+
let spent = 0;
|
|
122
|
+
for (const { text: content, calls } of turns) {
|
|
123
|
+
messages.push({ role: 'assistant', content, toolCalls: calls });
|
|
124
|
+
for (const call of calls) {
|
|
125
|
+
messages.push({ role: 'tool', toolCallId: call.id, content: results.get(call.id) ?? unfinished(call.id) });
|
|
126
|
+
if (!metadataToolNames.has(call.name))
|
|
127
|
+
spent += 1;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const remaining = checkpoint.state.remainingToolCalls;
|
|
131
|
+
return {
|
|
132
|
+
...checkpoint,
|
|
133
|
+
messages,
|
|
134
|
+
state: remaining === undefined ? checkpoint.state : { ...checkpoint.state, remainingToolCalls: Math.max(0, remaining - spent) },
|
|
135
|
+
coveredThrough,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
16
138
|
export function mergeRunProgress(older, newer) {
|
|
17
139
|
const pendingByNode = new Map();
|
|
18
140
|
const reentryByNode = new Map();
|
|
@@ -19,12 +19,12 @@ export interface OpenRunRecord {
|
|
|
19
19
|
permissions?: string;
|
|
20
20
|
resumedFrom?: string;
|
|
21
21
|
direction?: string;
|
|
22
|
-
wake?: 'timer' | 'auto-fix';
|
|
22
|
+
wake?: 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
|
|
23
23
|
pendingDirections?: {
|
|
24
24
|
runId: string;
|
|
25
25
|
direction: string;
|
|
26
26
|
id?: string;
|
|
27
|
-
wake?: 'timer' | 'auto-fix';
|
|
27
|
+
wake?: 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
|
|
28
28
|
node?: string;
|
|
29
29
|
}[];
|
|
30
30
|
directionNode?: string;
|
|
@@ -106,6 +106,11 @@ export declare function sessionsWithOpenRunClaims(directory: string, sessions?:
|
|
|
106
106
|
export declare function sessionHasOpenRun(directory: string, sessionId: string, options?: {
|
|
107
107
|
ignoreRunId?: string;
|
|
108
108
|
}): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Whether one run is still open: its claim is there and its process is live. Read only, unlike `sessionHasOpenRun`: a
|
|
111
|
+
* stale claim is left for that sweep. An unreadable claim counts as open.
|
|
112
|
+
*/
|
|
113
|
+
export declare function runIsOpen(directory: string, runId: string): Promise<boolean>;
|
|
109
114
|
export declare function sessionHasArmedWake(directory: string, sessionId: string): Promise<boolean>;
|
|
110
115
|
export declare function writeWakeClaim(directory: string, sessionId: string, timerId: string): Promise<void>;
|
|
111
116
|
export declare function clearWakeClaim(directory: string, sessionId: string, timerId: string): Promise<void>;
|
package/dist/src/run-records.js
CHANGED
|
@@ -232,7 +232,8 @@ async function markOpenRunsInterrupted(directory, onlyRunIds, skipOwnProcess = f
|
|
|
232
232
|
await unlock();
|
|
233
233
|
continue;
|
|
234
234
|
}
|
|
235
|
-
const
|
|
235
|
+
const measured = plainObject(current.usage) ? undefined : await journalRunUsage(directory, runId);
|
|
236
|
+
const interrupted = { ...current, status: 'interrupted', telemetryPending: true, reason: 'the engine stopped while this run was active', endedAt: new Date().toISOString(), ...(measured === undefined ? {} : { usage: measured }) };
|
|
236
237
|
try {
|
|
237
238
|
await writeSessionSnapshot(path, JSON.stringify(interrupted, null, 2) + '\n');
|
|
238
239
|
}
|
|
@@ -461,6 +462,24 @@ export async function sessionHasOpenRun(directory, sessionId, options = {}) {
|
|
|
461
462
|
}
|
|
462
463
|
return false;
|
|
463
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Whether one run is still open: its claim is there and its process is live. Read only, unlike `sessionHasOpenRun`: a
|
|
467
|
+
* stale claim is left for that sweep. An unreadable claim counts as open.
|
|
468
|
+
*/
|
|
469
|
+
export async function runIsOpen(directory, runId) {
|
|
470
|
+
let claim;
|
|
471
|
+
try {
|
|
472
|
+
claim = JSON.parse(await readFile(runRecordPath(directory, runId, 'open-run'), 'utf8'));
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
return error.code !== 'ENOENT';
|
|
476
|
+
}
|
|
477
|
+
if (!claim || typeof claim !== 'object' || claim.runId !== runId)
|
|
478
|
+
return true;
|
|
479
|
+
if (await claimOutlivedItsRun(directory, claim))
|
|
480
|
+
return false;
|
|
481
|
+
return claimOwnerIsLive(typeof claim.pid === 'number' ? claim.pid : undefined, claim.startedAt);
|
|
482
|
+
}
|
|
464
483
|
export async function sessionHasArmedWake(directory, sessionId) {
|
|
465
484
|
const runs = runRecordsDirectory(directory);
|
|
466
485
|
let names;
|
|
@@ -674,14 +693,21 @@ async function upgradeSessionMarkers(directory, only) {
|
|
|
674
693
|
}
|
|
675
694
|
if (known && !usageFolded.has(runId)) {
|
|
676
695
|
usageFolded.add(runId);
|
|
677
|
-
foldRecordUsage(session, record.usage);
|
|
696
|
+
foldRecordUsage(session, plainObject(record.usage) ? record.usage : await journalRunUsage(directory, runId));
|
|
678
697
|
}
|
|
679
698
|
}
|
|
680
699
|
else {
|
|
681
700
|
completion.summary = INTERRUPTED_TURN_SUMMARY;
|
|
682
701
|
completion.status = 'interrupted';
|
|
683
|
-
if (known)
|
|
684
|
-
|
|
702
|
+
if (known) {
|
|
703
|
+
// No finished record carries this run's usage, so the journal's last measurement stands in for it.
|
|
704
|
+
const measured = await journalRunUsage(directory, runId);
|
|
705
|
+
if (!usageFolded.has(runId)) {
|
|
706
|
+
usageFolded.add(runId);
|
|
707
|
+
foldRecordUsage(session, measured);
|
|
708
|
+
}
|
|
709
|
+
await synthesizeInterruptedRecord(directory, runId, typeof session.id === 'string' && validSessionFile(session.id) ? session.id : undefined, measured);
|
|
710
|
+
}
|
|
685
711
|
}
|
|
686
712
|
changed += 1;
|
|
687
713
|
}
|
|
@@ -722,7 +748,46 @@ async function readRunRecord(directory, runId) {
|
|
|
722
748
|
return undefined;
|
|
723
749
|
}
|
|
724
750
|
}
|
|
725
|
-
|
|
751
|
+
/**
|
|
752
|
+
* What a run had spent when its journal stopped: the run-wide total stamped on its last recorded model
|
|
753
|
+
* completion. An engine that dies mid-run never writes the finished record that normally carries this.
|
|
754
|
+
*/
|
|
755
|
+
async function journalRunUsage(directory, runId) {
|
|
756
|
+
let lines;
|
|
757
|
+
try {
|
|
758
|
+
lines = (await readFile(runRecordPath(directory, runId, 'jsonl'), 'utf8')).split('\n');
|
|
759
|
+
}
|
|
760
|
+
catch {
|
|
761
|
+
return undefined;
|
|
762
|
+
}
|
|
763
|
+
const count = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
764
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
765
|
+
const line = lines[index];
|
|
766
|
+
if (!line.includes('"agent.model.completed"'))
|
|
767
|
+
continue;
|
|
768
|
+
let total;
|
|
769
|
+
try {
|
|
770
|
+
const event = JSON.parse(line);
|
|
771
|
+
if (event.type !== 'agent.model.completed')
|
|
772
|
+
continue;
|
|
773
|
+
total = event.data?.graphUsage;
|
|
774
|
+
}
|
|
775
|
+
catch {
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (!plainObject(total))
|
|
779
|
+
continue;
|
|
780
|
+
const stamped = total;
|
|
781
|
+
const inputTokens = count(stamped.inputTokens), outputTokens = count(stamped.outputTokens);
|
|
782
|
+
if (inputTokens === undefined || outputTokens === undefined)
|
|
783
|
+
continue;
|
|
784
|
+
const cacheRead = count(stamped.cacheRead), cacheWrite = count(stamped.cacheWrite);
|
|
785
|
+
return { requests: count(stamped.requests) ?? 0, inputTokens, outputTokens,
|
|
786
|
+
...(cacheRead === undefined ? {} : { cacheRead }), ...(cacheWrite === undefined ? {} : { cacheWrite }) };
|
|
787
|
+
}
|
|
788
|
+
return undefined;
|
|
789
|
+
}
|
|
790
|
+
async function synthesizeInterruptedRecord(directory, runId, sessionId, usage) {
|
|
726
791
|
if (await readRunRecord(directory, runId) !== undefined)
|
|
727
792
|
return;
|
|
728
793
|
await mkdir(runRecordsDirectory(directory), { recursive: true, mode: 0o700 });
|
|
@@ -737,7 +802,7 @@ async function synthesizeInterruptedRecord(directory, runId, sessionId) {
|
|
|
737
802
|
try {
|
|
738
803
|
await writeSessionSnapshot(runRecordPath(directory, runId, 'json'), JSON.stringify({
|
|
739
804
|
id: runId, status: 'interrupted', reason: 'the engine stopped before the run was recorded', startedAt,
|
|
740
|
-
...(sessionId === undefined ? {} : { sessionId }), usage: { inputTokens: 0, outputTokens: 0, requests: 0 }, toolCalls: 0,
|
|
805
|
+
...(sessionId === undefined ? {} : { sessionId }), usage: usage ?? { inputTokens: 0, outputTokens: 0, requests: 0 }, toolCalls: 0,
|
|
741
806
|
}, null, 2) + '\n');
|
|
742
807
|
}
|
|
743
808
|
catch { }
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export interface InvocationBudget {
|
|
|
45
45
|
export interface RunResult {
|
|
46
46
|
providerRequestFailed?: boolean;
|
|
47
47
|
providerOverflow?: boolean;
|
|
48
|
+
/** The telemetry error code of the failure that ended the run, when one did. */
|
|
49
|
+
failureCode?: string;
|
|
48
50
|
telemetry?: import('./telemetry/capture.js').RunTelemetry;
|
|
49
51
|
id: string;
|
|
50
52
|
graph: typeof DEFAULT_GRAPH | Graph;
|
|
@@ -88,6 +90,8 @@ export interface AgentContinuationState {
|
|
|
88
90
|
failures: import('./tool-failure-tracker.js').ToolFailureTracker;
|
|
89
91
|
remainingToolCalls?: number;
|
|
90
92
|
remainingWallTimeMs?: number;
|
|
93
|
+
/** Set only on a checkpoint handed to a resume the user asked to compact (/compact during a run); never saved back. */
|
|
94
|
+
compactRequested?: true;
|
|
91
95
|
copies?: {
|
|
92
96
|
messages: Message[];
|
|
93
97
|
state: AgentContinuationState;
|
|
@@ -109,15 +113,17 @@ export interface AgentContinuationState {
|
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
export declare function timerReminderText(prompt: string): string;
|
|
112
|
-
type RetainedWake = 'timer' | 'auto-fix';
|
|
116
|
+
type RetainedWake = 'timer' | 'auto-fix' | 'fix-checks' | 'mention' | 'andorra-review';
|
|
113
117
|
export declare function wakeMessageText(wake: RetainedWake | undefined, message: string): string;
|
|
114
118
|
export declare function turnModelTask(turn: {
|
|
115
119
|
task: string;
|
|
120
|
+
note?: string;
|
|
116
121
|
direction?: string;
|
|
117
122
|
wake?: RetainedWake;
|
|
118
123
|
attachments?: readonly UserAttachmentRef[];
|
|
119
124
|
steers?: {
|
|
120
125
|
text: string;
|
|
126
|
+
note?: string;
|
|
121
127
|
attachments?: readonly UserAttachmentRef[];
|
|
122
128
|
wake?: RetainedWake;
|
|
123
129
|
subagentId?: string;
|
|
@@ -264,5 +270,7 @@ export interface GraphRunOptions extends RunOptions {
|
|
|
264
270
|
progress: import('./run-progress.js').RunProgress;
|
|
265
271
|
checkpoints?: import('./run-progress.js').RunCheckpoint[];
|
|
266
272
|
};
|
|
273
|
+
/** Runs an Andorra review node's rounds on the task's PR; without it such a node leaves through `stopped` (`unavailable`). */
|
|
274
|
+
reviewNode?: import('./github-app/review-node.js').ReviewNodeService;
|
|
267
275
|
}
|
|
268
276
|
export { runGraph } from './graph-runner.js';
|
package/dist/src/runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { attachmentReferenceBlock } from './attachments.js';
|
|
2
2
|
import { advertiseAvailableTools } from './tool-availability.js';
|
|
3
|
-
import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
|
|
3
|
+
import { createRunTelemetry, recordErrorOnce, recordModelUse, recordRunError } from './telemetry/capture.js';
|
|
4
|
+
import { runFailureCode } from './providers.js';
|
|
4
5
|
import { pricingFor } from './model-tiers.js';
|
|
5
6
|
import { bucketEndpoint } from './telemetry/schema.js';
|
|
6
7
|
export const DEFAULT_GRAPH = Object.freeze({
|
|
@@ -18,17 +19,28 @@ export function timerReminderText(prompt) {
|
|
|
18
19
|
export function wakeMessageText(wake, message) {
|
|
19
20
|
if (wake === 'auto-fix')
|
|
20
21
|
return `Delivered by Auto-fix (not a message from the user): ${message}`;
|
|
22
|
+
// The person pressed Fix with Agent in the PR tab; the text is the engine's, built from GitHub's checks.
|
|
23
|
+
if (wake === 'fix-checks')
|
|
24
|
+
return `Sent by the user with Fix with Agent in the PR tab: ${message}`;
|
|
25
|
+
// The person mentioned the App's bot on the task's PR; the text is the engine's, and the comment is read with gh.
|
|
26
|
+
if (wake === 'mention')
|
|
27
|
+
return `Delivered for a mention on GitHub (not typed in this chat): ${message}`;
|
|
28
|
+
// The review loop posted a round with findings; the text is the engine's, and the findings are read with gh.
|
|
29
|
+
if (wake === 'andorra-review')
|
|
30
|
+
return `Delivered by Andorra review (not a message from the user): ${message}`;
|
|
21
31
|
return wake === 'timer' ? timerReminderText(message) : message;
|
|
22
32
|
}
|
|
23
33
|
export function turnModelTask(turn) {
|
|
24
34
|
const woken = (message) => wakeMessageText(turn.wake ?? 'timer', message);
|
|
25
|
-
const
|
|
35
|
+
const said = turn.direction === undefined
|
|
26
36
|
? (turn.wake === undefined ? turn.task : woken(turn.task))
|
|
27
37
|
: `${turn.task}\n\n${turn.wake === undefined ? `Direction given when the attempt continued: ${turn.direction}` : `Delivered when the attempt continued: ${woken(turn.direction)}`}`;
|
|
38
|
+
// The turn's note (`run.note`) was given to the agent with the message, so later turns replay it too.
|
|
39
|
+
const text = turn.note ? `${said}\n\n${turn.note}` : said;
|
|
28
40
|
// A message the user sent to a subagent was never for this agent, so it is not replayed to it.
|
|
29
41
|
const withSteers = (turn.steers ?? []).filter(steer => steer.subagentId === undefined).reduce((text, steer) => {
|
|
30
42
|
const line = steer.wake === undefined
|
|
31
|
-
? `\n\nSteering message the user sent while this attempt ran: ${steer.text}`
|
|
43
|
+
? `\n\nSteering message the user sent while this attempt ran: ${steer.text}${steer.note ? `\n\n${steer.note}` : ''}`
|
|
32
44
|
: `\n\nRead while this attempt ran: ${timerReminderText(steer.text)}`;
|
|
33
45
|
const refs = steer.attachments?.length ? `\n\n${attachmentReferenceBlock(steer.attachments, { imagesIncluded: false })}` : '';
|
|
34
46
|
return `${text}${line}${refs}`;
|
|
@@ -60,10 +72,18 @@ export async function generateWithUsage(options, result, request) {
|
|
|
60
72
|
model: request.model,
|
|
61
73
|
role: options.telemetryIdentity?.role ?? (options.subagentId ? 'subagent' : 'other'),
|
|
62
74
|
};
|
|
75
|
+
// Every model request of the run goes through here (agent turns, compaction summaries, auxiliary calls), so this is
|
|
76
|
+
// where an error the provider recovered from is recorded: before the retry or resend, never only on failure.
|
|
77
|
+
const recordError = (code) => { recordRunError(result.telemetry ??= createRunTelemetry(), code ?? 'provider_error'); };
|
|
63
78
|
const response = await options.adapter.generate({ ...request, onRequest: () => {
|
|
64
79
|
recordedRequests++;
|
|
65
80
|
add({ inputTokens: 0, outputTokens: 0, requests: 1 });
|
|
66
|
-
}
|
|
81
|
+
}, onRetry: retry => { recordError(retry.code); return request.onRetry?.(retry); },
|
|
82
|
+
onRecoveredError: code => { recordError(code); request.onRecoveredError?.(code); } }).catch(error => {
|
|
83
|
+
// The failed request is recorded here, before a caller recovers from it (a verifier's failed verdict, a distiller's
|
|
84
|
+
// fallback, a compaction or image retry). Handlers further up reuse this record instead of counting it again.
|
|
85
|
+
if (!request.signal.aborted)
|
|
86
|
+
recordErrorOnce(result.telemetry ??= createRunTelemetry(), error, runFailureCode(error));
|
|
67
87
|
if (recordedRequests > 0) {
|
|
68
88
|
result.telemetry ??= createRunTelemetry();
|
|
69
89
|
recordModelUse(result.telemetry, { ...identity, usage: { requests: recordedRequests } });
|