@andorra-labs/code 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acp-agent.d.ts +54 -0
- package/dist/src/acp-agent.js +991 -0
- package/dist/src/agent-definitions.js +29 -6
- package/dist/src/agent-execution.js +8 -2
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +3 -1
- package/dist/src/agent-mcp.js +97 -11
- package/dist/src/andorra/entry.js +21 -3
- package/dist/src/andorra/hosted.d.ts +3 -0
- package/dist/src/andorra/hosted.js +5 -1
- package/dist/src/andorra/notices.d.ts +10 -1
- package/dist/src/andorra/notices.js +25 -2
- package/dist/src/andorra/terminal.d.ts +2 -0
- package/dist/src/andorra/terminal.js +2 -2
- package/dist/src/app-server/protocol.d.ts +9 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +141 -10
- package/dist/src/app-server.d.ts +115 -0
- package/dist/src/app-server.js +980 -63
- package/dist/src/auth/AuthManager.js +4 -4
- package/dist/src/auth/deployment.js +2 -2
- package/dist/src/browser-bridge.d.ts +1 -0
- package/dist/src/browser-bridge.js +5 -2
- package/dist/src/browser-external-app.d.ts +27 -0
- package/dist/src/browser-external-app.js +60 -0
- package/dist/src/browser-panel-tool.d.ts +6 -0
- package/dist/src/browser-panel-tool.js +36 -0
- package/dist/src/browser-runner.js +1 -0
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-ui/style.css +3 -3
- package/dist/src/browser-ui/tokens.css +27 -16
- package/dist/src/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +60 -2
- package/dist/src/bug-report.d.ts +81 -0
- package/dist/src/bug-report.js +235 -0
- package/dist/src/claude-provider.d.ts +2 -1
- package/dist/src/claude-provider.js +13 -9
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +184 -40
- package/dist/src/codex-errors.js +4 -1
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +9 -2
- package/dist/src/command-screens.js +166 -97
- package/dist/src/commands.d.ts +3 -2
- package/dist/src/commands.js +1 -0
- package/dist/src/compaction-phrases.d.ts +4 -0
- package/dist/src/compaction-phrases.js +20 -0
- package/dist/src/completion-gates.d.ts +22 -0
- package/dist/src/completion-gates.js +11 -0
- package/dist/src/config.d.ts +5 -0
- package/dist/src/config.js +48 -0
- package/dist/src/context-compaction.js +2 -1
- package/dist/src/decision/DecisionManager.js +3 -2
- package/dist/src/decision/requestPhrases.d.ts +4 -0
- package/dist/src/decision/requestPhrases.js +23 -0
- package/dist/src/github-inbox.d.ts +55 -0
- package/dist/src/github-inbox.js +153 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.js +8 -4
- package/dist/src/graph-manager-chat.js +6 -1
- package/dist/src/graph-provider-portability.js +32 -10
- package/dist/src/graph-quota.d.ts +29 -2
- package/dist/src/graph-quota.js +68 -10
- package/dist/src/graph-runner.js +24 -7
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +9 -7
- package/dist/src/graph-sync.d.ts +1 -0
- package/dist/src/graph-sync.js +93 -34
- package/dist/src/graph-tool.d.ts +2 -0
- package/dist/src/graph-tool.js +2 -2
- package/dist/src/graph-ui/app.js +177 -41
- package/dist/src/graph-ui/controls.css +1 -0
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-ui/embed.js +2 -2
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graph-ui/manager.css +1 -1
- package/dist/src/graph-ui/manager.js +2 -2
- package/dist/src/graph-ui/sidebar.js +30 -0
- package/dist/src/graph-ui/studio-canvas.js +26 -13
- package/dist/src/graph-ui/studio.css +15 -7
- package/dist/src/graph-ui/studio.js +11 -4
- package/dist/src/graph-ui/style.css +77 -45
- package/dist/src/graph-ui/theme.js +3 -36
- package/dist/src/graph-ui/tokens.css +27 -19
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/graphs.js +4 -3
- package/dist/src/live-model.d.ts +24 -0
- package/dist/src/live-model.js +37 -0
- package/dist/src/managed-sign-in.d.ts +1 -0
- package/dist/src/managed-sign-in.js +13 -0
- package/dist/src/membership-errors.d.ts +2 -0
- package/dist/src/membership-errors.js +5 -1
- package/dist/src/membership.d.ts +23 -1
- package/dist/src/membership.js +48 -6
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +1 -1
- package/dist/src/model-metadata.js +12 -3
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/plan-pass.d.ts +59 -0
- package/dist/src/plan-pass.js +165 -0
- package/dist/src/provider-connection.js +17 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +6 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.js +14 -2
- package/dist/src/providers.d.ts +33 -2
- package/dist/src/providers.js +101 -28
- package/dist/src/pull-request-checks.d.ts +26 -0
- package/dist/src/pull-request-checks.js +56 -0
- package/dist/src/pull-request-conversation.d.ts +134 -0
- package/dist/src/pull-request-conversation.js +221 -0
- package/dist/src/pull-request-create.d.ts +175 -0
- package/dist/src/pull-request-create.js +392 -0
- package/dist/src/pull-request-details.d.ts +242 -0
- package/dist/src/pull-request-details.js +614 -0
- package/dist/src/pull-request-edit.d.ts +23 -0
- package/dist/src/pull-request-edit.js +91 -0
- package/dist/src/pull-request-logs.d.ts +76 -0
- package/dist/src/pull-request-logs.js +172 -0
- package/dist/src/pull-request-merge.d.ts +112 -0
- package/dist/src/pull-request-merge.js +258 -0
- package/dist/src/pull-request-review.d.ts +137 -0
- package/dist/src/pull-request-review.js +401 -0
- package/dist/src/pull-requests.d.ts +43 -2
- package/dist/src/pull-requests.js +112 -21
- package/dist/src/react-runtime.js +58 -9
- package/dist/src/read-document-tool.d.ts +2 -0
- package/dist/src/read-document-tool.js +6 -6
- package/dist/src/remote/engine-pool.js +42 -6
- package/dist/src/run-control.d.ts +10 -0
- package/dist/src/run-control.js +24 -0
- package/dist/src/run-progress.d.ts +10 -0
- package/dist/src/run-progress.js +122 -0
- package/dist/src/run-records.d.ts +2 -2
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/runtime.d.ts +5 -1
- package/dist/src/runtime.js +14 -2
- package/dist/src/save-lock.js +14 -7
- package/dist/src/session-title.d.ts +3 -0
- package/dist/src/session-title.js +5 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +10 -3
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
- package/dist/src/skills/bundled/provenance.json +7 -2
- package/dist/src/skills/runtime-skills.js +1 -0
- package/dist/src/subagent-run.js +1 -0
- package/dist/src/telemetry/capture-core.d.ts +17 -0
- package/dist/src/telemetry/capture-core.js +59 -1
- package/dist/src/telemetry/classify.d.ts +3 -1
- package/dist/src/telemetry/classify.js +37 -0
- package/dist/src/telemetry/emitter.d.ts +2 -0
- package/dist/src/telemetry/emitter.js +42 -5
- package/dist/src/telemetry/schema.d.ts +22 -0
- package/dist/src/telemetry/schema.js +68 -1
- package/dist/src/telemetry/surface.d.ts +1 -0
- package/dist/src/telemetry/uploader.d.ts +12 -1
- package/dist/src/telemetry/uploader.js +30 -2
- package/dist/src/terminal-links.d.ts +16 -0
- package/dist/src/terminal-links.js +113 -0
- package/dist/src/terminal-ui.d.ts +8 -1
- package/dist/src/terminal-ui.js +40 -14
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/trajectory.js +6 -1
- package/dist/src/transcript.d.ts +2 -0
- package/dist/src/transcript.js +10 -3
- package/dist/src/types.d.ts +9 -0
- package/dist/src/usage-analytics.js +18 -10
- package/package.json +2 -1
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';
|
|
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';
|
|
28
28
|
node?: string;
|
|
29
29
|
}[];
|
|
30
30
|
directionNode?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runtimeEnvironmentNote(platform?: NodeJS.Platform, arch?: string, release?: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
// One line in the system message naming the host the tools run on, so the model picks commands
|
|
3
|
+
// for this operating system instead of guessing (a run on Linux once reached for powershell).
|
|
4
|
+
// It stays constant for the life of the process, so it does not disturb prompt caching.
|
|
5
|
+
export function runtimeEnvironmentNote(platform = process.platform, arch = process.arch, release = os.release()) {
|
|
6
|
+
if (platform === 'win32') {
|
|
7
|
+
return `Environment: the tools run on Windows (${arch}). The shell tool runs PowerShell; use PowerShell syntax and Windows paths.`;
|
|
8
|
+
}
|
|
9
|
+
const system = platform === 'darwin' ? 'macOS' : platform === 'linux' ? 'Linux' : platform;
|
|
10
|
+
const detail = platform === 'linux' && /microsoft|wsl/i.test(release) ? `WSL, ${arch}` : arch;
|
|
11
|
+
const userland = platform === 'darwin' ? ' with the BSD userland' : '';
|
|
12
|
+
return `Environment: the tools run on ${system} (${detail}). The shell tool runs Bash${userland}; use POSIX commands and paths. PowerShell and cmd.exe are not available.`;
|
|
13
|
+
}
|
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,7 +113,7 @@ 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';
|
|
113
117
|
export declare function wakeMessageText(wake: RetainedWake | undefined, message: string): string;
|
|
114
118
|
export declare function turnModelTask(turn: {
|
|
115
119
|
task: string;
|
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,6 +19,9 @@ 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}`;
|
|
21
25
|
return wake === 'timer' ? timerReminderText(message) : message;
|
|
22
26
|
}
|
|
23
27
|
export function turnModelTask(turn) {
|
|
@@ -60,10 +64,18 @@ export async function generateWithUsage(options, result, request) {
|
|
|
60
64
|
model: request.model,
|
|
61
65
|
role: options.telemetryIdentity?.role ?? (options.subagentId ? 'subagent' : 'other'),
|
|
62
66
|
};
|
|
67
|
+
// Every model request of the run goes through here (agent turns, compaction summaries, auxiliary calls), so this is
|
|
68
|
+
// where an error the provider recovered from is recorded: before the retry or resend, never only on failure.
|
|
69
|
+
const recordError = (code) => { recordRunError(result.telemetry ??= createRunTelemetry(), code ?? 'provider_error'); };
|
|
63
70
|
const response = await options.adapter.generate({ ...request, onRequest: () => {
|
|
64
71
|
recordedRequests++;
|
|
65
72
|
add({ inputTokens: 0, outputTokens: 0, requests: 1 });
|
|
66
|
-
}
|
|
73
|
+
}, onRetry: retry => { recordError(retry.code); return request.onRetry?.(retry); },
|
|
74
|
+
onRecoveredError: code => { recordError(code); request.onRecoveredError?.(code); } }).catch(error => {
|
|
75
|
+
// The failed request is recorded here, before a caller recovers from it (a verifier's failed verdict, a distiller's
|
|
76
|
+
// fallback, a compaction or image retry). Handlers further up reuse this record instead of counting it again.
|
|
77
|
+
if (!request.signal.aborted)
|
|
78
|
+
recordErrorOnce(result.telemetry ??= createRunTelemetry(), error, runFailureCode(error));
|
|
67
79
|
if (recordedRequests > 0) {
|
|
68
80
|
result.telemetry ??= createRunTelemetry();
|
|
69
81
|
recordModelUse(result.telemetry, { ...identity, usage: { requests: recordedRequests } });
|
package/dist/src/save-lock.js
CHANGED
|
@@ -146,13 +146,20 @@ export async function acquireSaveLock(folder, options = {}) {
|
|
|
146
146
|
}
|
|
147
147
|
export async function removeLockedFolder(folder, onDetached) {
|
|
148
148
|
const detached = join(dirname(folder), `.removing-${basename(folder)}-${randomUUID()}`);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
// Windows refuses to rename a folder while any file in it is open, and a sync pass opens them briefly.
|
|
150
|
+
for (let attempt = 0;; attempt++) {
|
|
151
|
+
try {
|
|
152
|
+
await rename(folder, detached);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const code = error.code;
|
|
157
|
+
if (code === 'ENOENT')
|
|
158
|
+
return;
|
|
159
|
+
if (attempt >= 4 || !['EPERM', 'EACCES', 'EBUSY'].includes(code ?? ''))
|
|
160
|
+
throw error;
|
|
161
|
+
await new Promise(resolve => setTimeout(resolve, 25 * (attempt + 1)));
|
|
162
|
+
}
|
|
156
163
|
}
|
|
157
164
|
try {
|
|
158
165
|
await onDetached?.();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export type TabState = 'idle' | 'working' | 'input';
|
|
2
|
+
/** The working spinner: the terminal title while a run works, and the TUI's inline loading rows. */
|
|
3
|
+
export declare const WORKING_SPINNER_FRAMES: string[];
|
|
4
|
+
export declare const WORKING_SPINNER_TICK_MS = 125;
|
|
2
5
|
export declare class SessionTitle {
|
|
3
6
|
private readonly output;
|
|
4
7
|
private name;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
-
|
|
2
|
+
/** The working spinner: the terminal title while a run works, and the TUI's inline loading rows. */
|
|
3
|
+
export const WORKING_SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
4
|
+
export const WORKING_SPINNER_TICK_MS = 125;
|
|
5
|
+
const workingFrames = WORKING_SPINNER_FRAMES;
|
|
3
6
|
export class SessionTitle {
|
|
4
7
|
output;
|
|
5
8
|
name = '';
|
|
@@ -31,7 +34,7 @@ export class SessionTitle {
|
|
|
31
34
|
}
|
|
32
35
|
this.render();
|
|
33
36
|
if (state !== 'idle') {
|
|
34
|
-
this.timer = setInterval(() => { this.frame++; this.render(); }, state === 'input' ? 500 :
|
|
37
|
+
this.timer = setInterval(() => { this.frame++; this.render(); }, state === 'input' ? 500 : WORKING_SPINNER_TICK_MS);
|
|
35
38
|
this.timer.unref?.();
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from './config.js';
|
|
2
2
|
import type { ProviderConfig } from './providers.js';
|
|
3
|
-
export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"];
|
|
3
|
+
export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode", "google"];
|
|
4
4
|
export type DetectableSignInType = typeof DETECTABLE_SIGN_IN_TYPES[number];
|
|
5
5
|
export declare function isDetectableSignInType(value: unknown): value is DetectableSignInType;
|
|
6
6
|
export interface DetectedSignIn {
|
|
@@ -4,19 +4,20 @@ import { resolveCliExecutable } from './cli-executable.js';
|
|
|
4
4
|
import { readCodexModels } from './codex-auth.js';
|
|
5
5
|
import { resolveCodexExecutable } from './codex-executable.js';
|
|
6
6
|
import { connectCodex } from './codex-rpc.js';
|
|
7
|
+
import { GOOGLE_BASE_URL, GOOGLE_EXECUTABLE, readGoogleCatalog } from './google-provider.js';
|
|
7
8
|
import { GROK_BASE_URL, GROK_EXECUTABLE, readGrokCatalog } from './grok-provider.js';
|
|
8
9
|
import { OPENCODE_BASE_URL, OPENCODE_EXECUTABLE, readOpenCodeCatalog, sharedOpenCodeServer } from './opencode-cli-provider.js';
|
|
9
10
|
import { uniqueProviderId } from './provider-import.js';
|
|
10
|
-
export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode'];
|
|
11
|
+
export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode', 'google'];
|
|
11
12
|
export function isDetectableSignInType(value) {
|
|
12
13
|
return DETECTABLE_SIGN_IN_TYPES.includes(value);
|
|
13
14
|
}
|
|
14
15
|
const SIGNED_OUT = { signedIn: false, models: [] };
|
|
15
16
|
const MAX_MODELS = 5000;
|
|
16
17
|
const FIXED_BASE_URL = {
|
|
17
|
-
claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
|
|
18
|
+
claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL, google: GOOGLE_BASE_URL,
|
|
18
19
|
};
|
|
19
|
-
const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
20
|
+
const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode', google: 'Google' };
|
|
20
21
|
export function defaultSignInProbes() {
|
|
21
22
|
const present = async (resolve) => { try {
|
|
22
23
|
await resolve();
|
|
@@ -59,6 +60,12 @@ export function defaultSignInProbes() {
|
|
|
59
60
|
const catalog = await readGrokCatalog(signal);
|
|
60
61
|
return { signedIn: catalog.signedIn, models: catalog.models, ...(catalog.email ? { email: catalog.email } : {}) };
|
|
61
62
|
},
|
|
63
|
+
google: async (signal) => {
|
|
64
|
+
if (!await present(() => resolveCliExecutable(GOOGLE_EXECUTABLE)))
|
|
65
|
+
return SIGNED_OUT;
|
|
66
|
+
const catalog = await readGoogleCatalog(signal);
|
|
67
|
+
return { signedIn: catalog.signedIn, models: catalog.models };
|
|
68
|
+
},
|
|
62
69
|
opencode: async (signal) => {
|
|
63
70
|
if (!await present(() => resolveCliExecutable(OPENCODE_EXECUTABLE)))
|
|
64
71
|
return SIGNED_OUT;
|
|
@@ -5,7 +5,7 @@ import { changeConfigFile, configDirectory, loadConfig } from './config.js';
|
|
|
5
5
|
import { applySignInImports, detectSignIns } from './sign-in-detection.js';
|
|
6
6
|
const DETECT_TIMEOUT_MS = 8_000;
|
|
7
7
|
const MAX_ATTEMPTS = 3;
|
|
8
|
-
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
8
|
+
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode', google: 'Google' };
|
|
9
9
|
const statePath = (home) => join(home, 'sign-in-offer.json');
|
|
10
10
|
export async function readSignInOfferState(home = configDirectory()) {
|
|
11
11
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const BUILTIN_COMMANDS = new Set([
|
|
2
|
-
'browser', 'session', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
|
|
2
|
+
'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
|
|
3
3
|
'graph', 'codegraph', 'dashboard', 'attach', 'usage', 'permissions', 'jev',
|
|
4
4
|
'feedback', 'yolo', 'tools', 'skill', 'skills', 'plugins', 'mcp', 'logout', 'status',
|
|
5
5
|
'clear', 'compact', 'goal', 'help', 'exit', 'quit',
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-report
|
|
3
|
+
description: "Report a bug in Andorra Code to the Andorra team: ask the user what went wrong, write it up, and send it once they approve. Use when the user types /bug-report or says something in Andorra Code itself is broken and wants it reported."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Report a bug in Andorra Code
|
|
7
|
+
|
|
8
|
+
This sends a bug report about **Andorra Code itself** (the terminal app, the desktop app, sign-in, graphs,
|
|
9
|
+
models, tools) to the Andorra team. It is not for bugs in the user's own project: if that is what they
|
|
10
|
+
describe, say so and help with the project instead.
|
|
11
|
+
|
|
12
|
+
You send the report with the `submit_bug_report` tool. The tool shows the user the exact text and sends it
|
|
13
|
+
only when they choose **Send report**, so you never send anything they have not read.
|
|
14
|
+
|
|
15
|
+
## Before you ask anything
|
|
16
|
+
|
|
17
|
+
- The report needs a signed-in Andorra account. Any plan can report, Free included. If you already know
|
|
18
|
+
the user is signed out (an earlier error said so, or `andorra auth status` reports it), tell them to sign
|
|
19
|
+
in first (`andorra login`, `/login`, or Account in the desktop app) and stop. Otherwise carry on: the
|
|
20
|
+
tool checks, and tells you if they are signed out.
|
|
21
|
+
- If `submit_bug_report` is not among your tools, this run cannot send reports. Say so and ask the user to
|
|
22
|
+
type `/bug-report` at the start of a new message.
|
|
23
|
+
- Use what the user already told you, in this message and earlier in the conversation. Do not ask again
|
|
24
|
+
for something they have said.
|
|
25
|
+
|
|
26
|
+
## The interview
|
|
27
|
+
|
|
28
|
+
Ask one question at a time, in plain words, and wait for each answer. Use `ask_user` when you have it;
|
|
29
|
+
otherwise ask in your reply and continue when they answer. Skip a question whose answer you already have.
|
|
30
|
+
|
|
31
|
+
1. **What went wrong?** What they were trying to do and what happened. Ask for the exact error text if
|
|
32
|
+
there was one.
|
|
33
|
+
2. **How to make it happen again.** The steps, from a known starting point. "I don't know" or "it happened
|
|
34
|
+
once" is a fine answer: record it as that.
|
|
35
|
+
3. **What they expected** to happen instead.
|
|
36
|
+
4. **How often and since when**, if it is not already clear: every time or sometimes, and whether it
|
|
37
|
+
worked before (an update, a new setting, a different model).
|
|
38
|
+
5. **Anything else that helps**: which model or graph, the terminal app or the desktop app, a screenshot
|
|
39
|
+
described in words.
|
|
40
|
+
|
|
41
|
+
Stop asking once you can write a report someone else could act on. Three or four questions is usual; do
|
|
42
|
+
not go through the list for its own sake, and do not ask for the app version or operating system (the
|
|
43
|
+
tool attaches those).
|
|
44
|
+
|
|
45
|
+
## Write the report
|
|
46
|
+
|
|
47
|
+
- `title`: one line naming the problem, specific enough to tell it from other reports ("Desktop: Send does
|
|
48
|
+
nothing after attaching a PDF"), at most 120 characters.
|
|
49
|
+
- `description`: what happened, in the user's words, with the error text. Add "Happens every time" or
|
|
50
|
+
"Happened once", and what changed recently if they said.
|
|
51
|
+
- `steps`: numbered steps. Leave it out if the user does not know them.
|
|
52
|
+
- `expected` and `actual`: one or two sentences each.
|
|
53
|
+
|
|
54
|
+
Rules for the text:
|
|
55
|
+
|
|
56
|
+
- Report what the user said. Do not add steps, causes or details they did not give you, and do not guess
|
|
57
|
+
at a diagnosis. If you looked something up yourself (a log line, a version), say that it is your
|
|
58
|
+
observation.
|
|
59
|
+
- **Leave private material out**: no API keys, tokens or passwords, no file contents or source code from
|
|
60
|
+
their project, no prompts or conversation text, no personal data about other people. Describe instead
|
|
61
|
+
("a 40-line TypeScript file"). If the user pasted a secret, do not repeat it, and tell them it was left
|
|
62
|
+
out.
|
|
63
|
+
- Keep it short. The limits are 4,000 bytes for the description, 2,000 for steps and actual, 1,000 for
|
|
64
|
+
expected.
|
|
65
|
+
|
|
66
|
+
## Send it
|
|
67
|
+
|
|
68
|
+
Call `submit_bug_report` once with the fields above. Then:
|
|
69
|
+
|
|
70
|
+
- `sent: true`: give the user the `reference` (for example `BR-1234`) and thank them. There is no page to
|
|
71
|
+
open: the tracker is private, so do not offer a link or promise a reply.
|
|
72
|
+
- `sent: false` with a `userReply`: they want a change. Make it and call the tool again so they confirm
|
|
73
|
+
the new text.
|
|
74
|
+
- `sent: false` without one: they chose not to send. Say nothing was sent and stop.
|
|
75
|
+
- An error: tell the user what it said in plain words. Signed out: they sign in and run `/bug-report`
|
|
76
|
+
again. Daily limit reached: say when they can send it. Service unavailable: say so; do not retry in a
|
|
77
|
+
loop.
|
|
78
|
+
|
|
79
|
+
Send one report per problem. If the user describes two separate bugs, finish the first, then ask whether
|
|
80
|
+
to report the second.
|
|
@@ -139,6 +139,13 @@ and the upsert reply's `placed` says where it went.
|
|
|
139
139
|
3. `andorra_graph_publish`. A `REVISION_CONFLICT` means someone saved a newer revision: begin a new edit draft
|
|
140
140
|
from the latest, reapply your changes, validate and publish again.
|
|
141
141
|
4. If the user stops partway, `andorra_graph_discard` the draft.
|
|
142
|
+
5. If the user said which projects should offer the graph ("only this project", "only in X"), set it right after
|
|
143
|
+
publishing with `andorra_graph_visibility_set`: `projects: "this"` for the project the task runs in, a list of
|
|
144
|
+
registered project paths for named projects (`andorra_graph_visibility_get` lists them in `registeredProjects`;
|
|
145
|
+
in the Graph Builder the task does not run in the user's project, so name it this way), or `"all"` to list it
|
|
146
|
+
everywhere again.
|
|
147
|
+
`andorra_graph_visibility_get` reads the current setting. Never record visibility in graph metadata, which
|
|
148
|
+
nothing reads. If the call fails (for example `PROJECT_NOT_REGISTERED`), tell the user it was not applied.
|
|
142
149
|
|
|
143
150
|
## 6. Delete or restore
|
|
144
151
|
|
|
@@ -158,5 +165,6 @@ it can be restored.
|
|
|
158
165
|
## 7. Report
|
|
159
166
|
|
|
160
167
|
The graph id and revision, what changed, how to run it (`/graph` in the terminal to select it, the desktop's
|
|
161
|
-
graph picker, or `andorra --graph <id>`), and that cloud sync may still be pending.
|
|
168
|
+
graph picker, or `andorra --graph <id>`), and that cloud sync may still be pending. Say which projects list the graph
|
|
169
|
+
when you set it. Name anything you could not
|
|
162
170
|
validate.
|
|
@@ -24,6 +24,7 @@ validation error.
|
|
|
24
24
|
| `DRAFT_NOT_FOUND` / `DRAFT_BUSY` | The draft expired (one hour), was discarded, or is publishing. | Begin a new draft; wait for a publish to finish. |
|
|
25
25
|
| `DRAFT_LIMIT` | 24 drafts are open. | Discard unused drafts. |
|
|
26
26
|
| `FREE_TIER_LIMIT` | A free account's limit: one custom graph, at most 3 nodes, no Orchestrator. | Stay within it, or tell the user a paid plan lifts it. |
|
|
27
|
+
| `MEMBERSHIP_UNAVAILABLE` | The account service did not answer the membership check. Not an account or plan problem. | Wait a few seconds and retry the same call; the draft is kept. Do not ask the user to sign in or question their subscription. Tell the user only if retries keep failing. |
|
|
27
28
|
| `AUTH_REQUIRED` / `MEMBERSHIP_REQUIRED` / `AUTH_CHANGED` | Not signed in, no membership, or the account changed mid-edit. | Ask the user to sign in (`andorra login`); retry with the current account. |
|
|
28
29
|
| `DEFAULT_GRAPH` | Deleting or restoring the Default graph. | Not allowed. |
|
|
29
30
|
| `CONFIRMATION_MISMATCH` | `confirm` is not the graph id. | Ask the user to confirm, then pass the id in `confirm`. |
|
|
@@ -714,18 +714,23 @@
|
|
|
714
714
|
{
|
|
715
715
|
"source": "src/skills/bundled/graph-manager/SKILL.md",
|
|
716
716
|
"asset": "graph-manager/SKILL.md",
|
|
717
|
-
"sha256": "
|
|
717
|
+
"sha256": "fcb0b27d6db360f402b2f6cb4a4bbecbfe7f670eec6b91ccb74aedaf21bfcb91"
|
|
718
718
|
},
|
|
719
719
|
{
|
|
720
720
|
"source": "src/skills/bundled/graph-manager/errors.md",
|
|
721
721
|
"asset": "graph-manager/errors.md",
|
|
722
|
-
"sha256": "
|
|
722
|
+
"sha256": "5e084ffffcc69e0d8c405a27428763f743431e3db6d704f369c01f0893e6db04"
|
|
723
723
|
},
|
|
724
724
|
{
|
|
725
725
|
"source": "src/skills/bundled/graph-manager/patterns.md",
|
|
726
726
|
"asset": "graph-manager/patterns.md",
|
|
727
727
|
"sha256": "bf57e2421697360cc293109b5eaa84ecff0d93fc5dcd957a34d8173ca91b1e2c"
|
|
728
728
|
},
|
|
729
|
+
{
|
|
730
|
+
"source": "src/skills/bundled/bug-report/SKILL.md",
|
|
731
|
+
"asset": "bug-report/SKILL.md",
|
|
732
|
+
"sha256": "20777e7df3e9a93e2062f681069d09a090b487268cf12a2f5359f989ab809e2d"
|
|
733
|
+
},
|
|
729
734
|
{
|
|
730
735
|
"source": "src/skills/bundled/diagram/SKILL.md",
|
|
731
736
|
"asset": "diagram/SKILL.md",
|
|
@@ -19,6 +19,7 @@ const bundled = [
|
|
|
19
19
|
{ id: 'andorra:manage-skills', path: 'manage-skills/SKILL.md', description: "List, install, turn on or off, and remove Andorra Code skills and plugins. Use when the user asks what skills they have, wants to add a skill from GitHub or a folder, disable one, or clean up skills they no longer use.", source: 'bundled', loadWhen: 'before installing, copying, listing, turning on or off, or removing a skill or plugin' },
|
|
20
20
|
{ id: 'andorra:create-agent', path: 'create-agent/SKILL.md', description: "Design a reusable Andorra Code Agent (a role with its own instructions, model, capabilities and input/output contract) and produce a file the user imports into their Agent library. Use when the user wants a custom reviewer, tester, researcher or other role to reuse across graphs.", source: 'bundled' },
|
|
21
21
|
{ id: 'andorra:doctor', path: 'doctor/SKILL.md', description: "Check that Andorra Code is set up and healthy: Node, sign-in, configuration, providers, MCP servers, disk space. Use when something does not work (no models, tools missing, sign-in errors, tasks failing at start) or the user asks to check their setup.", source: 'bundled' },
|
|
22
|
+
{ id: 'andorra:bug-report', path: 'bug-report/SKILL.md', description: "Report a bug in Andorra Code to the Andorra team: ask the user what went wrong, write it up, and send it once they approve. Use when the user types /bug-report or says something in Andorra Code itself is broken and wants it reported.", source: 'bundled' },
|
|
22
23
|
{ id: 'andorra:write-instructions', path: 'write-instructions/SKILL.md', description: "Create or improve a repository's agent instructions (ANDORRA.md or AGENTS.md): build and test commands, conventions, and rules agents must follow. Use when the user wants agents to work the way their team does, or asks to set up or tighten project instructions.", source: 'bundled' },
|
|
23
24
|
{ id: 'andorra:graph-manager', path: 'graph-manager/SKILL.md', description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent pipelines) from the user's requirements, through Andorra's graph tools. Use when the user wants a new graph, wants to change how an existing graph routes work, or wants a graph removed or brought back.", source: 'bundled' },
|
|
24
25
|
{ id: 'andorra:diagram', path: 'diagram/SKILL.md', description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, process, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph.", source: 'bundled', loadWhen: 'before describing or explaining a graph, workflow, state machine, call sequence or code structure to the user' },
|
package/dist/src/subagent-run.js
CHANGED
|
@@ -467,6 +467,7 @@ export class SubagentRunner {
|
|
|
467
467
|
status: settled, ...(why === undefined ? {} : { reason: why }),
|
|
468
468
|
...(result?.providerRequestFailed || run.healthProviderFailed ? { providerRequestFailed: true } : {}),
|
|
469
469
|
...(result?.providerOverflow ? { providerOverflow: true } : {}),
|
|
470
|
+
...(result?.failureCode === undefined ? {} : { errorCode: result.failureCode }),
|
|
470
471
|
...(result?.telemetry !== undefined || run.probeModels.size > 0 ? { telemetry: finishedTelemetry } : {}),
|
|
471
472
|
...(result?.toolCalls === undefined ? {} : { toolCalls: result.toolCalls }),
|
|
472
473
|
})).catch(() => { });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Usage } from '../types.js';
|
|
2
|
+
import { type TelemetryErrorRecord, type TelemetrySavings } from './schema.js';
|
|
2
3
|
import type { ModelTuple } from './aggregate.js';
|
|
3
4
|
import type { ModelPricing } from '../efficiency.js';
|
|
4
5
|
export interface JevTally {
|
|
@@ -76,6 +77,12 @@ export interface RunTelemetry {
|
|
|
76
77
|
models: ModelTuple[];
|
|
77
78
|
jev: JevTally;
|
|
78
79
|
providerOverflow?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Every error the run met, in the order each code was first seen, including the ones it recovered from
|
|
82
|
+
* (a provider retry that later succeeded, an attempt the engine ran again). Append-only: a later error or
|
|
83
|
+
* a run that carries on never removes or replaces an earlier entry.
|
|
84
|
+
*/
|
|
85
|
+
errors?: TelemetryErrorRecord[];
|
|
79
86
|
pendingQuestions: number;
|
|
80
87
|
pendingByInvocation: Record<string, number>;
|
|
81
88
|
pendingDecisions?: Promise<unknown>[];
|
|
@@ -95,6 +102,16 @@ export declare function recordModelUse(telemetry: RunTelemetry, input: {
|
|
|
95
102
|
pricing?: ModelPricing;
|
|
96
103
|
}): void;
|
|
97
104
|
export declare function recordToolUse(telemetry: RunTelemetry, name: string, failed: boolean): void;
|
|
105
|
+
export declare function recordRunError(telemetry: RunTelemetry, code: unknown, count?: number): void;
|
|
106
|
+
/**
|
|
107
|
+
* Records a thrown error once, however many handlers see it on its way up (the request path, then a compactor, the
|
|
108
|
+
* agent loop or a graph). Returns the code it was recorded under, which later handlers reuse.
|
|
109
|
+
*/
|
|
110
|
+
export declare function recordErrorOnce(telemetry: RunTelemetry, error: unknown, code: string): string;
|
|
111
|
+
/** The code an error was already recorded under, if any handler recorded it. */
|
|
112
|
+
export declare function recordedErrorCode(error: unknown): string | undefined;
|
|
113
|
+
/** The measured savings a run's efficiency tally holds, as sent in run.finished; undefined when nothing was tallied. */
|
|
114
|
+
export declare function savingsFrom(telemetry: RunTelemetry): TelemetrySavings | undefined;
|
|
98
115
|
export declare function recordAttempt(telemetry: RunTelemetry, retry: boolean): void;
|
|
99
116
|
export declare function recordEdit(telemetry: RunTelemetry, filePath: string, created: boolean): void;
|
|
100
117
|
export declare function recordTestCommand(telemetry: RunTelemetry): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bucketEndpoint, bucketModel, bucketProviderType, bucketToolName } from './schema.js';
|
|
1
|
+
import { TELEMETRY_ERROR_KINDS, bucketEndpoint, bucketErrorCode, bucketModel, bucketProviderType, bucketToolName, } from './schema.js';
|
|
2
2
|
import { isDocumentationPath, isTestPath } from './classify.js';
|
|
3
3
|
import { usageCostMicroUsd } from '../model-tiers.js';
|
|
4
4
|
export function createEfficiencyTally() {
|
|
@@ -171,6 +171,62 @@ export function recordToolUse(telemetry, name, failed) {
|
|
|
171
171
|
telemetry.toolFailures += 1;
|
|
172
172
|
telemetry.task.activity = true;
|
|
173
173
|
}
|
|
174
|
+
export function recordRunError(telemetry, code, count = 1) {
|
|
175
|
+
if (!Number.isSafeInteger(count) || count < 1)
|
|
176
|
+
return;
|
|
177
|
+
const errors = telemetry.errors ??= [];
|
|
178
|
+
let bucket = bucketErrorCode(code);
|
|
179
|
+
// At most fifteen named codes are kept; every later new code is counted under `other`, so no count is lost.
|
|
180
|
+
const named = errors.filter(record => record.code !== 'other').length;
|
|
181
|
+
if (bucket !== 'other' && !errors.some(record => record.code === bucket) && named >= TELEMETRY_ERROR_KINDS - 1)
|
|
182
|
+
bucket = 'other';
|
|
183
|
+
const entry = errors.find(record => record.code === bucket);
|
|
184
|
+
if (entry)
|
|
185
|
+
entry.count += count;
|
|
186
|
+
else
|
|
187
|
+
errors.push({ code: bucket, count });
|
|
188
|
+
}
|
|
189
|
+
const recordedFailures = new WeakMap();
|
|
190
|
+
/**
|
|
191
|
+
* Records a thrown error once, however many handlers see it on its way up (the request path, then a compactor, the
|
|
192
|
+
* agent loop or a graph). Returns the code it was recorded under, which later handlers reuse.
|
|
193
|
+
*/
|
|
194
|
+
export function recordErrorOnce(telemetry, error, code) {
|
|
195
|
+
if (error === null || (typeof error !== 'object' && typeof error !== 'function')) {
|
|
196
|
+
recordRunError(telemetry, code);
|
|
197
|
+
return code;
|
|
198
|
+
}
|
|
199
|
+
const previous = recordedFailures.get(error);
|
|
200
|
+
if (previous !== undefined)
|
|
201
|
+
return previous;
|
|
202
|
+
recordedFailures.set(error, code);
|
|
203
|
+
recordRunError(telemetry, code);
|
|
204
|
+
return code;
|
|
205
|
+
}
|
|
206
|
+
/** The code an error was already recorded under, if any handler recorded it. */
|
|
207
|
+
export function recordedErrorCode(error) {
|
|
208
|
+
return error !== null && (typeof error === 'object' || typeof error === 'function') ? recordedFailures.get(error) : undefined;
|
|
209
|
+
}
|
|
210
|
+
/** The measured savings a run's efficiency tally holds, as sent in run.finished; undefined when nothing was tallied. */
|
|
211
|
+
export function savingsFrom(telemetry) {
|
|
212
|
+
const tally = telemetry.efficiency;
|
|
213
|
+
if (!tally)
|
|
214
|
+
return undefined;
|
|
215
|
+
return {
|
|
216
|
+
toolResultsFiltered: tally.toolResults.filtered,
|
|
217
|
+
toolResultOriginalChars: tally.toolResults.originalChars,
|
|
218
|
+
toolResultKeptChars: tally.toolResults.keptChars,
|
|
219
|
+
toolResultExpandedChars: tally.toolResults.expandedChars,
|
|
220
|
+
schemaCharsBefore: tally.catalog.schemaCharsBefore,
|
|
221
|
+
schemaCharsAfter: tally.catalog.schemaCharsAfter,
|
|
222
|
+
contextOmittedChars: tally.context.omittedChars,
|
|
223
|
+
contextDuplicates: tally.context.duplicates,
|
|
224
|
+
preparedSteps: tally.prepared.steps,
|
|
225
|
+
preparedExecuted: tally.prepared.executed,
|
|
226
|
+
deterministicSteps: tally.prepared.deterministic,
|
|
227
|
+
postflightSkipped: tally.postflight.skipped,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
174
230
|
export function recordAttempt(telemetry, retry) {
|
|
175
231
|
telemetry.attempts += 1;
|
|
176
232
|
if (retry)
|
|
@@ -299,6 +355,8 @@ export function mergeRunTelemetry(into, from) {
|
|
|
299
355
|
into.task.testCommand ||= from.task.testCommand;
|
|
300
356
|
into.task.activity ||= from.task.activity;
|
|
301
357
|
into.providerOverflow ||= from.providerOverflow;
|
|
358
|
+
for (const record of from.errors ?? [])
|
|
359
|
+
recordRunError(into, record.code, record.count);
|
|
302
360
|
for (const [invocation, questions] of Object.entries(from.pendingByInvocation))
|
|
303
361
|
into.pendingByInvocation[invocation] = questions;
|
|
304
362
|
const keyedPending = Object.values(into.pendingByInvocation).reduce((sum, questions) => sum + questions, 0);
|