@andorra-labs/code 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +56 -0
- package/dist/src/app-server/protocol.d.ts +109 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server.d.ts +59 -1
- package/dist/src/app-server.js +418 -63
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +255 -33
- package/dist/src/browser-ui/index.html +9 -9
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/cli.js +10 -5
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -2
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +9 -1
- package/dist/src/completion.js +20 -2
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.js +4 -4
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +303 -129
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +56 -7
- package/dist/src/graph-ui/icons.js +5 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +5 -5
- package/dist/src/graph-ui/skill-picker.js +5 -5
- package/dist/src/graph-ui/studio-canvas.js +16 -16
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +99 -42
- package/dist/src/graph-ui/style.css +125 -80
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +10 -3
- package/dist/src/graphs.js +15 -4
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/guidance.js +6 -19
- package/dist/src/qa/index.d.ts +0 -2
- package/dist/src/qa/index.js +0 -2
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.js +134 -16
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/remote/engine-pool.js +18 -6
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +122 -0
- package/dist/src/session-changes.js +804 -0
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +15 -0
- package/dist/src/stall-recovery.js +17 -0
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +64 -20
- package/dist/src/terminal-ui.js +312 -82
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +118 -9
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +15 -3
- package/dist/src/types.d.ts +12 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a model working under a wall-clock limit is told about it.
|
|
3
|
+
*
|
|
4
|
+
* The runtime has always enforced `limits.wallTimeMs`: when the clock runs out the attempt is
|
|
5
|
+
* stopped where it stands. The model was never told there was a clock. In a benchmark run with a
|
|
6
|
+
* fifteen-minute limit the agent spent the whole allowance at full reasoning effort on one build,
|
|
7
|
+
* was stopped with nothing usable on disk, and never knew the end was near; the trials that
|
|
8
|
+
* survived a stop did so only because their output happened to be written already.
|
|
9
|
+
*
|
|
10
|
+
* So a bounded attempt is told three things: that there is a limit and what it means for how to
|
|
11
|
+
* work (once, in the system prompt, where it never changes and so never disturbs the cached
|
|
12
|
+
* prefix), and how much time is left as it runs down (a short runtime message when half, a quarter
|
|
13
|
+
* and a tenth remain, appended at the tail of the conversation). An unbounded attempt, which is the
|
|
14
|
+
* default, is told nothing.
|
|
15
|
+
* @module time-limit
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Below this a limit is too short for a notice to be acted on; the prompt line still applies.
|
|
19
|
+
* A node inside a graph is handed what is left of the graph's limit, a few milliseconds under the
|
|
20
|
+
* configured figure, so a configured two minutes must sit clear of this floor.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TIME_NOTICE_MIN_LIMIT_MS = 90000;
|
|
23
|
+
interface Stage {
|
|
24
|
+
id: 'half' | 'quarter' | 'tenth';
|
|
25
|
+
remaining: number;
|
|
26
|
+
text: (left: string) => string;
|
|
27
|
+
}
|
|
28
|
+
/** "about 7 minutes" or "about 40 seconds": the model plans in round figures, not milliseconds. */
|
|
29
|
+
export declare function formatTimeLeft(ms: number): string;
|
|
30
|
+
/** The system-prompt paragraph for an attempt that has `limitMs` of wall-clock time. */
|
|
31
|
+
export declare function timeLimitPrompt(limitMs: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* A system prompt with the time-limit paragraph for `limitMs`, replacing any it already holds.
|
|
34
|
+
*
|
|
35
|
+
* A resumed attempt restores the stopped attempt's conversation, system message included, while
|
|
36
|
+
* its limit is narrowed to what was left of the clock. Left alone, the restored prompt would still
|
|
37
|
+
* promise the original fifteen minutes to a run that has one; and with less than the notice floor
|
|
38
|
+
* left, no later notice would correct it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function withTimeLimitPrompt(system: string, limitMs: number | undefined): string;
|
|
41
|
+
export interface TimeLimitNotice {
|
|
42
|
+
stage: Stage['id'];
|
|
43
|
+
text: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The notices for one attempt. `next` is asked before each model request with the time still
|
|
47
|
+
* left; it answers at most once per stage, and when several stages passed during one long step it
|
|
48
|
+
* answers only for the most urgent, since the earlier ones describe a moment that is gone.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTimeLimitNotices(limitMs: number): {
|
|
51
|
+
next(remainingMs: number | undefined): TimeLimitNotice | undefined;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a model working under a wall-clock limit is told about it.
|
|
3
|
+
*
|
|
4
|
+
* The runtime has always enforced `limits.wallTimeMs`: when the clock runs out the attempt is
|
|
5
|
+
* stopped where it stands. The model was never told there was a clock. In a benchmark run with a
|
|
6
|
+
* fifteen-minute limit the agent spent the whole allowance at full reasoning effort on one build,
|
|
7
|
+
* was stopped with nothing usable on disk, and never knew the end was near; the trials that
|
|
8
|
+
* survived a stop did so only because their output happened to be written already.
|
|
9
|
+
*
|
|
10
|
+
* So a bounded attempt is told three things: that there is a limit and what it means for how to
|
|
11
|
+
* work (once, in the system prompt, where it never changes and so never disturbs the cached
|
|
12
|
+
* prefix), and how much time is left as it runs down (a short runtime message when half, a quarter
|
|
13
|
+
* and a tenth remain, appended at the tail of the conversation). An unbounded attempt, which is the
|
|
14
|
+
* default, is told nothing.
|
|
15
|
+
* @module time-limit
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Below this a limit is too short for a notice to be acted on; the prompt line still applies.
|
|
19
|
+
* A node inside a graph is handed what is left of the graph's limit, a few milliseconds under the
|
|
20
|
+
* configured figure, so a configured two minutes must sit clear of this floor.
|
|
21
|
+
*/
|
|
22
|
+
export const TIME_NOTICE_MIN_LIMIT_MS = 90_000;
|
|
23
|
+
/** Most urgent last, so the stage that applies is the last one whose share has been reached. */
|
|
24
|
+
const STAGES = [
|
|
25
|
+
{ id: 'half', remaining: 0.5, text: left => `Runtime: half of this run's time limit is used; ${left} remain. Check that every output the task requires already exists in a usable form, write any that does not, then keep going.` },
|
|
26
|
+
{ id: 'quarter', remaining: 0.25, text: left => `Runtime: ${left} remain of this run's time limit. Put the best version you have of every required output on disk now, then keep working on what is still missing or failing. Do not finish early: time left unused is worth nothing, and a task reported as unfinished is not accepted while time remains.` },
|
|
27
|
+
{ id: 'tenth', remaining: 0.1, text: left => `Runtime: ${left} remain and the run is stopped when the time is up. Keep the required outputs on disk in their best state at every moment from here on, and spend what is left on small, quick fixes to what is still failing. Finish only if the task is done.` },
|
|
28
|
+
];
|
|
29
|
+
/** "about 7 minutes" or "about 40 seconds": the model plans in round figures, not milliseconds. */
|
|
30
|
+
export function formatTimeLeft(ms) {
|
|
31
|
+
const seconds = Math.max(0, Math.round(ms / 1000));
|
|
32
|
+
if (seconds < 90)
|
|
33
|
+
return `about ${Math.max(5, Math.round(seconds / 5) * 5)} seconds`;
|
|
34
|
+
const minutes = Math.round(seconds / 60);
|
|
35
|
+
if (minutes < 90)
|
|
36
|
+
return `about ${minutes} minutes`;
|
|
37
|
+
const hours = Math.round(minutes / 6) / 10;
|
|
38
|
+
return `about ${hours} hours`;
|
|
39
|
+
}
|
|
40
|
+
/** The system-prompt paragraph for an attempt that has `limitMs` of wall-clock time. */
|
|
41
|
+
export function timeLimitPrompt(limitMs) {
|
|
42
|
+
return `This run has a wall-clock limit of ${formatTimeLeft(limitMs)}. When the time is up the run is stopped where it stands and only what is already on disk counts, so write a working version of every required output early and improve it afterwards rather than saving it for the end. Size commands, installs and your own deliberation to the time available. Use all of it: do not end the run early with the task unfinished. The runtime tells you when half, a quarter and a tenth of the time remain.`;
|
|
43
|
+
}
|
|
44
|
+
const PROMPT_LINE = /\nThis run has a wall-clock limit of [^\n]*/g;
|
|
45
|
+
/**
|
|
46
|
+
* A system prompt with the time-limit paragraph for `limitMs`, replacing any it already holds.
|
|
47
|
+
*
|
|
48
|
+
* A resumed attempt restores the stopped attempt's conversation, system message included, while
|
|
49
|
+
* its limit is narrowed to what was left of the clock. Left alone, the restored prompt would still
|
|
50
|
+
* promise the original fifteen minutes to a run that has one; and with less than the notice floor
|
|
51
|
+
* left, no later notice would correct it.
|
|
52
|
+
*/
|
|
53
|
+
export function withTimeLimitPrompt(system, limitMs) {
|
|
54
|
+
const stripped = system.replace(PROMPT_LINE, '');
|
|
55
|
+
return limitMs ? `${stripped}\n${timeLimitPrompt(limitMs)}` : stripped;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The notices for one attempt. `next` is asked before each model request with the time still
|
|
59
|
+
* left; it answers at most once per stage, and when several stages passed during one long step it
|
|
60
|
+
* answers only for the most urgent, since the earlier ones describe a moment that is gone.
|
|
61
|
+
*/
|
|
62
|
+
export function createTimeLimitNotices(limitMs) {
|
|
63
|
+
let announced = -1;
|
|
64
|
+
return {
|
|
65
|
+
next(remainingMs) {
|
|
66
|
+
if (remainingMs === undefined || limitMs < TIME_NOTICE_MIN_LIMIT_MS)
|
|
67
|
+
return undefined;
|
|
68
|
+
let reached = -1;
|
|
69
|
+
for (const [index, stage] of STAGES.entries())
|
|
70
|
+
if (remainingMs <= limitMs * stage.remaining)
|
|
71
|
+
reached = index;
|
|
72
|
+
if (reached <= announced)
|
|
73
|
+
return undefined;
|
|
74
|
+
announced = reached;
|
|
75
|
+
const stage = STAGES[reached];
|
|
76
|
+
return { stage: stage.id, text: stage.text(formatTimeLeft(remainingMs)) };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FileDiff } from './file-diff.js';
|
|
1
2
|
export interface LineDiffStats {
|
|
2
3
|
linesAdded: number;
|
|
3
4
|
linesRemoved: number;
|
|
@@ -22,3 +23,11 @@ export declare function fileDiffTarget(name: string, args: Record<string, unknow
|
|
|
22
23
|
export declare function readFileSnapshot(target: string): Promise<string | null | undefined>;
|
|
23
24
|
/** The added/removed line counts for a snapshot pair; nothing when either half was unmeasurable. */
|
|
24
25
|
export declare function diffLineStats(before: string | null | undefined, after: string | null | undefined): LineDiffStats | undefined;
|
|
26
|
+
/** Diff lines a completed call's event carries: a row shows the start and says how many more there are. */
|
|
27
|
+
export declare const CALL_DIFF_LINES = 200;
|
|
28
|
+
/**
|
|
29
|
+
* One call's change to its file as numbered hunks, for the `fileDiff` of its `node.tool.completed` event: what
|
|
30
|
+
* the file held before the call against what it holds after, so a Write over an existing file shows the lines
|
|
31
|
+
* it really changed and every line carries its number. Nothing for a call that changed nothing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function callFileDiff(before: string | null, after: string | null): Pick<FileDiff, 'hunks' | 'hiddenLines'> | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { canonicalCodingToolName } from './tool-names.js';
|
|
4
|
+
import { textDiff } from './file-diff.js';
|
|
4
5
|
/**
|
|
5
6
|
* The line counts behind a successful file mutation, reported on its `node.tool.completed` event.
|
|
6
7
|
*
|
|
@@ -120,3 +121,22 @@ function countDiff(oldLines, newLines) {
|
|
|
120
121
|
const common = previous[midOld.length];
|
|
121
122
|
return [midNew.length - common, midOld.length - common];
|
|
122
123
|
}
|
|
124
|
+
/** Diff lines a completed call's event carries: a row shows the start and says how many more there are. */
|
|
125
|
+
export const CALL_DIFF_LINES = 200;
|
|
126
|
+
/** Characters of diff text a completed call's event carries, so one minified line cannot fill the journal. */
|
|
127
|
+
const CALL_DIFF_CHARS = 24_000;
|
|
128
|
+
const CALL_DIFF_LINE_CHARS = 400;
|
|
129
|
+
/**
|
|
130
|
+
* One call's change to its file as numbered hunks, for the `fileDiff` of its `node.tool.completed` event: what
|
|
131
|
+
* the file held before the call against what it holds after, so a Write over an existing file shows the lines
|
|
132
|
+
* it really changed and every line carries its number. Nothing for a call that changed nothing.
|
|
133
|
+
*/
|
|
134
|
+
export function callFileDiff(before, after) {
|
|
135
|
+
// A NUL byte is a binary file read as text: its "lines" are not something a reader can check.
|
|
136
|
+
if (before?.includes('\0') || after?.includes('\0'))
|
|
137
|
+
return undefined;
|
|
138
|
+
const diff = textDiff(before ?? '', after ?? '', { maxLines: CALL_DIFF_LINES, maxChars: CALL_DIFF_CHARS, lineChars: CALL_DIFF_LINE_CHARS });
|
|
139
|
+
if (diff.coarse || !diff.hunks.length)
|
|
140
|
+
return undefined;
|
|
141
|
+
return { hunks: diff.hunks, hiddenLines: diff.hiddenLines };
|
|
142
|
+
}
|
package/dist/src/tool-names.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare function toolNameMatches(configured: string, actual: string): boo
|
|
|
13
13
|
export declare function canonicalizeToolList(names: readonly string[] | undefined): string[] | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* Rewrites the tool names one provider request sees and restores Andorra's names on everything
|
|
16
|
-
* that comes back. Canonical Andorra tool names use dots (`qa.
|
|
16
|
+
* that comes back. Canonical Andorra tool names use dots (`qa.terminal`, `browser.panel`), while
|
|
17
17
|
* strict providers validate `function.name` against `^[a-zA-Z0-9_-]+$` and reject the whole
|
|
18
18
|
* request with an HTTP 400. The provider-side names are a pure transport encoding: journals,
|
|
19
19
|
* the executor and the desktop keep the canonical spellings.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @module tool-result-filter
|
|
17
17
|
*/
|
|
18
18
|
import { canonicalToolName } from './tool-names.js';
|
|
19
|
-
const SHELL_TOOLS = new Set(['Bash', 'PowerShell', 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'shell', 'bash', 'powershell', 'qa.
|
|
19
|
+
const SHELL_TOOLS = new Set(['Bash', 'PowerShell', 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'shell', 'bash', 'powershell', 'qa.terminal']);
|
|
20
20
|
const SEARCH_TOOLS = new Set(['Grep', 'grep', 'search_files']);
|
|
21
21
|
const LISTING_TOOLS = new Set(['Glob', 'find', 'ls', 'list_files']);
|
|
22
22
|
/** A shell command that prints source or a patch is a read, whatever its size. */
|
package/dist/src/tools.js
CHANGED
|
@@ -14,6 +14,8 @@ import { andorraCreateWriteTool } from '../vendor/engine/runtime/coding-agent/co
|
|
|
14
14
|
import { andorraWithFileMutationQueue } from '../vendor/engine/runtime/coding-agent/core/tools/file-mutation-queue.js';
|
|
15
15
|
import { andorraDetectSupportedImageMimeType } from '../vendor/engine/runtime/coding-agent/utils/mime.js';
|
|
16
16
|
import { READ_IMAGE_FILE_LIMIT } from './read-image.js';
|
|
17
|
+
import { decodeLegacyText, sniffDocument } from './read-document.js';
|
|
18
|
+
import { READ_DOCUMENT_FILE_LIMIT } from './read-document-tool.js';
|
|
17
19
|
import { clipText } from './text.js';
|
|
18
20
|
import { pullRequestSettings } from './pull-requests.js';
|
|
19
21
|
import { approveOperation } from './capabilities.js';
|
|
@@ -244,6 +246,56 @@ async function readImage(context, name) {
|
|
|
244
246
|
await handle.close();
|
|
245
247
|
}
|
|
246
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* The whole of a regular file whose leading bytes `accept` recognizes, or undefined when they are
|
|
251
|
+
* not recognized or the path is not a regular file. Same guards as the text and image readers:
|
|
252
|
+
* the path policy, a non-blocking open, the size bound checked on the open handle, and one byte
|
|
253
|
+
* past the bound read so a file that grows mid-read is refused rather than truncated.
|
|
254
|
+
*/
|
|
255
|
+
async function readRecognized(context, name, limit, what, accept) {
|
|
256
|
+
const resolved = await safePath(context, name);
|
|
257
|
+
if (!(await stat(resolved)).isFile())
|
|
258
|
+
return undefined;
|
|
259
|
+
context.signal.throwIfAborted();
|
|
260
|
+
const handle = await open(resolved, constants.O_RDONLY | (process.platform === 'win32' ? 0 : constants.O_NONBLOCK));
|
|
261
|
+
try {
|
|
262
|
+
const info = await handle.stat();
|
|
263
|
+
if (!info.isFile())
|
|
264
|
+
return undefined;
|
|
265
|
+
const head = Buffer.alloc(4100);
|
|
266
|
+
const sniffed = await handle.read(head, 0, head.length, 0);
|
|
267
|
+
if (!accept(head.subarray(0, sniffed.bytesRead)))
|
|
268
|
+
return undefined;
|
|
269
|
+
if (info.size > limit)
|
|
270
|
+
throw new Error(`${what} exceeds the ${limit / (1024 * 1024)} MiB read limit`);
|
|
271
|
+
const chunks = [];
|
|
272
|
+
let size = 0;
|
|
273
|
+
while (size <= limit) {
|
|
274
|
+
context.signal.throwIfAborted();
|
|
275
|
+
const chunk = Buffer.alloc(Math.min(256 * 1024, limit + 1 - size));
|
|
276
|
+
const result = await handle.read(chunk, 0, chunk.length, size);
|
|
277
|
+
if (!result.bytesRead)
|
|
278
|
+
break;
|
|
279
|
+
size += result.bytesRead;
|
|
280
|
+
chunks.push(chunk.subarray(0, result.bytesRead));
|
|
281
|
+
}
|
|
282
|
+
if (size > limit)
|
|
283
|
+
throw new Error(`${what} grew beyond the read limit`);
|
|
284
|
+
return Buffer.concat(chunks, size);
|
|
285
|
+
}
|
|
286
|
+
finally {
|
|
287
|
+
await handle.close();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/** The bytes of a file that opens like a PDF, a zip (docx) or a compound file (doc); undefined otherwise. */
|
|
291
|
+
function readDocument(context, name) {
|
|
292
|
+
return readRecognized(context, name, READ_DOCUMENT_FILE_LIMIT, 'File', head => sniffDocument(head) !== undefined);
|
|
293
|
+
}
|
|
294
|
+
/** A text file in an older encoding, decoded; undefined when the bytes do not look like text. */
|
|
295
|
+
async function readLegacyText(context, name) {
|
|
296
|
+
const bytes = await readRecognized(context, name, FILE_LIMIT, 'File', () => true);
|
|
297
|
+
return bytes ? decodeLegacyText(bytes) : undefined;
|
|
298
|
+
}
|
|
247
299
|
function assertMutationPermission(context) {
|
|
248
300
|
if (!context.pinFilePaths && !context.fileMutationApproval?.explicit && (permissionMode(context) === 'read-only' || permissionMode(context) === 'plan'))
|
|
249
301
|
throw new Error('Permission denied: file mutation grant was revoked');
|
|
@@ -265,6 +317,10 @@ async function atomicWrite(context, name, content, expectedContent) {
|
|
|
265
317
|
const resolved = await safePath(context, name, true);
|
|
266
318
|
await mutationPermission(context, name);
|
|
267
319
|
assertMutationPermission(context);
|
|
320
|
+
// The review record (Keep / Undo) notes the folders this write will create before any is made. Its lock
|
|
321
|
+
// is held from just before the rename until the write is recorded (see the rename below). It never fails
|
|
322
|
+
// the write: a recorder that cannot keep the file answers nothing.
|
|
323
|
+
const recording = await context.fileChanges?.beforeWrite(resolved).catch(() => undefined);
|
|
268
324
|
await mkdir(path.dirname(resolved), { recursive: true });
|
|
269
325
|
if (!samePath(await safePath(context, name, true), resolved))
|
|
270
326
|
throw new Error('File path changed before write; retry');
|
|
@@ -281,7 +337,12 @@ async function atomicWrite(context, name, content, expectedContent) {
|
|
|
281
337
|
context.signal.throwIfAborted();
|
|
282
338
|
await mutationPermission(context, name);
|
|
283
339
|
assertMutationPermission(context);
|
|
284
|
-
|
|
340
|
+
// A replacement starts private and takes the old file's mode below, so its content is never
|
|
341
|
+
// briefly more readable than the file it replaces. A new file has no mode to inherit: it is
|
|
342
|
+
// created like any other program creates one (0666 narrowed by the process umask), not 0600,
|
|
343
|
+
// which left files the agent wrote unreadable to a web server, a test runner or any other
|
|
344
|
+
// account that was meant to use them.
|
|
345
|
+
const handle = await open(temporary, 'wx', existing ? 0o600 : 0o666);
|
|
285
346
|
created = true;
|
|
286
347
|
try {
|
|
287
348
|
await mutationPermission(context, name);
|
|
@@ -303,8 +364,28 @@ async function atomicWrite(context, name, content, expectedContent) {
|
|
|
303
364
|
context.signal.throwIfAborted();
|
|
304
365
|
await mutationPermission(context, name);
|
|
305
366
|
assertMutationPermission(context);
|
|
306
|
-
|
|
307
|
-
|
|
367
|
+
// From here to the record the session's review lock is held, so a Keep or Undo can neither run between
|
|
368
|
+
// the freshness check and the rename nor overwrite the write before it is recorded. Nothing in the window
|
|
369
|
+
// waits on a person. A lock that cannot be taken leaves the write unrecorded rather than failing it.
|
|
370
|
+
const locked = recording ? await recording.begin().then(() => true, () => false) : false;
|
|
371
|
+
try {
|
|
372
|
+
// Re-checked inside the window: an Undo that finished just before it may have restored the file.
|
|
373
|
+
if (locked && expectedContent !== undefined && await read(context, name) !== expectedContent)
|
|
374
|
+
throw new Error('File changed while writing; retry');
|
|
375
|
+
// Taking the lock can wait behind an Undo or another write, and a stop or a live permission change in
|
|
376
|
+
// that wait still decides: both are checked again with nothing awaited between them and the rename.
|
|
377
|
+
context.signal.throwIfAborted();
|
|
378
|
+
assertMutationPermission(context);
|
|
379
|
+
await rename(temporary, resolved);
|
|
380
|
+
created = false;
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
if (locked)
|
|
384
|
+
await recording.abort().catch(() => { });
|
|
385
|
+
throw error;
|
|
386
|
+
}
|
|
387
|
+
if (locked)
|
|
388
|
+
await recording.commit().catch(() => { });
|
|
308
389
|
}
|
|
309
390
|
finally {
|
|
310
391
|
if (created) {
|
|
@@ -613,6 +694,21 @@ function qaPermissionTool(tool) {
|
|
|
613
694
|
return tool.execute(args, context);
|
|
614
695
|
} };
|
|
615
696
|
}
|
|
697
|
+
const AWAIT_REVIEW_DEFAULT_MINUTES = 360;
|
|
698
|
+
/** What a review wait tells the agent to do next. */
|
|
699
|
+
function reviewWaitAnswer(ended, minutes, signal) {
|
|
700
|
+
switch (ended.kind) {
|
|
701
|
+
case 'comments': return `${ended.prompt}
|
|
702
|
+
|
|
703
|
+
When this round is pushed and its threads are answered, call pull_request with action await_review again to wait for the next review.`;
|
|
704
|
+
case 'finished': return `${ended.pullRequest.url} is ${ended.pullRequest.state}, so Auto-fix is off and there is no review left to wait for. Finish your work and report.`;
|
|
705
|
+
case 'off': return `Auto-fix is off for ${ended.pullRequest.url}, so no review will be waited for. Finish your work and report; switch Auto-fix on only if the user asks.`;
|
|
706
|
+
case 'none': return 'No pull request is tracked for this session, so there is no review to wait for.';
|
|
707
|
+
case 'timeout': return `No new review arrived in ${minutes} minute${minutes === 1 ? '' : 's'}. Call await_review again to keep waiting, or finish and report.`;
|
|
708
|
+
case 'steered': return 'The user sent you a message while you were waiting for a review. Read and answer it; call await_review again afterwards if the review loop should continue.';
|
|
709
|
+
case 'aborted': throw signal.reason instanceof Error ? signal.reason : new Error('The run was stopped while it waited for a review.');
|
|
710
|
+
}
|
|
711
|
+
}
|
|
616
712
|
export function createTools() {
|
|
617
713
|
return [
|
|
618
714
|
createAutomationTool(),
|
|
@@ -754,12 +850,13 @@ export function createTools() {
|
|
|
754
850
|
context.wakesArmed?.push(timer.id);
|
|
755
851
|
return `Timer ${timer.id.slice(0, 8)} armed: your prompt will be delivered in ${args.seconds} second${args.seconds === 1 ? '' : 's'}, at ${new Date(timer.fireAt).toISOString()}. It fires once.`;
|
|
756
852
|
}),
|
|
757
|
-
{ ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. dismiss removes it from the card. Only change a setting the user asked you to change.', {
|
|
758
|
-
action: { type: 'string', enum: ['status', 'attach', 'update', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; dismiss stops tracking' },
|
|
853
|
+
{ ...tool('pull_request', 'Show or change the pull request this session tracks in the desktop Plan card. A PR you open with `gh pr create` is attached automatically; use attach for one opened another way. update changes its settings when the user asks: mergeWhenReady enables GitHub auto-merge (gh pr merge --auto), draft converts to a draft or marks it ready, autoFix wakes you with a prompt when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments and switches itself off once the PR is merged or closed. await_review keeps you in this run while Auto-fix is on: it waits, without using the model, until new review comments arrive (and returns them), the PR is merged or closed, the user messages you, or timeoutMinutes pass. Use it to own the review loop: fix a round, push, resolve the threads you fixed, then call await_review again, until the PR is merged or closed. Never wait for a review with sleep, a shell loop or set_timer. dismiss removes it from the card. Only change a setting the user asked you to change.', {
|
|
854
|
+
action: { type: 'string', enum: ['status', 'attach', 'update', 'await_review', 'dismiss'], description: 'status shows the tracked PR; attach starts tracking url; update changes settings; await_review waits for the next review round; dismiss stops tracking' },
|
|
759
855
|
url: property('The GitHub pull request URL (attach only)'),
|
|
760
856
|
autoFix: { type: 'boolean', description: 'Wake this session when a code-review bot (Codex, CodeRabbit, Greptile, Copilot) comments, until the PR is merged or closed' },
|
|
761
857
|
mergeWhenReady: { type: 'boolean', description: 'GitHub auto-merge once checks and reviews pass' },
|
|
762
858
|
draft: { type: 'boolean', description: 'true converts to a draft, false marks it ready for review' },
|
|
859
|
+
timeoutMinutes: { type: 'integer', minimum: 1, maximum: 1440, description: `How long await_review waits for a review before returning (1 to 1440, default ${AWAIT_REVIEW_DEFAULT_MINUTES})` },
|
|
763
860
|
}, ['action'], async (args, context) => {
|
|
764
861
|
const control = context.pullRequests;
|
|
765
862
|
if (!control)
|
|
@@ -779,21 +876,33 @@ export function createTools() {
|
|
|
779
876
|
const url = string(args, 'url');
|
|
780
877
|
if (Object.keys(settings).length)
|
|
781
878
|
await approve();
|
|
782
|
-
return `Tracking ${describe(await control.attach(url, settings))}`;
|
|
879
|
+
return `Tracking ${describe(await control.attach(url, settings, context.wakeOrigin))}`;
|
|
783
880
|
}
|
|
784
881
|
case 'update': {
|
|
785
882
|
if (!Object.keys(settings).length)
|
|
786
883
|
throw new Error('update needs at least one of autoFix, mergeWhenReady, draft');
|
|
787
884
|
await approve();
|
|
788
|
-
return `Updated ${describe(await control.update(settings))}`;
|
|
885
|
+
return `Updated ${describe(await control.update(settings, context.wakeOrigin))}`;
|
|
886
|
+
}
|
|
887
|
+
case 'await_review': {
|
|
888
|
+
if (!control.awaitReview)
|
|
889
|
+
throw new Error('await_review is unavailable here; this surface cannot hold a run open for a review. End your turn: Auto-fix wakes you when comments arrive.');
|
|
890
|
+
const minutes = args.timeoutMinutes === undefined ? AWAIT_REVIEW_DEFAULT_MINUTES : args.timeoutMinutes;
|
|
891
|
+
if (typeof minutes !== 'number' || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 1_440)
|
|
892
|
+
throw new Error('timeoutMinutes must be an integer from 1 to 1440');
|
|
893
|
+
const awaitReview = control.awaitReview.bind(control);
|
|
894
|
+
const wait = () => awaitReview(context.signal, minutes * 60_000, context.wakeOrigin);
|
|
895
|
+
// Waiting on a reviewer is not the run's work: its time limits are paused for as long as this waits.
|
|
896
|
+
const ended = await (context.waitOutside ? context.waitOutside(wait) : wait());
|
|
897
|
+
return reviewWaitAnswer(ended, minutes, context.signal);
|
|
789
898
|
}
|
|
790
899
|
case 'dismiss':
|
|
791
900
|
await control.dismiss();
|
|
792
901
|
return 'The pull request is no longer tracked for this session.';
|
|
793
|
-
default: throw new Error('action must be status, attach, update, or dismiss');
|
|
902
|
+
default: throw new Error('action must be status, attach, update, await_review, or dismiss');
|
|
794
903
|
}
|
|
795
904
|
}), family: 'git', executionMode: 'sequential' },
|
|
796
|
-
...createCodingTools({ safePath, read, readImage, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
|
|
905
|
+
...createCodingTools({ safePath, read, readImage, readDocument, readLegacyText, atomicWrite, authorize, files, fileLimit: FILE_LIMIT }),
|
|
797
906
|
...createQaTools().map(qaPermissionTool),
|
|
798
907
|
createBrowserSessionTool(authorize),
|
|
799
908
|
createSolveCaptchaTool(authorize),
|
package/dist/src/transcript.d.ts
CHANGED
|
@@ -24,6 +24,17 @@ export interface TranscriptEntry {
|
|
|
24
24
|
* @returns a paint color: a palette index or an SGR parameter string.
|
|
25
25
|
*/
|
|
26
26
|
export declare function transcriptColor(text: string): number | string;
|
|
27
|
+
/**
|
|
28
|
+
* Render an agent's answer on its own: markdown drawn the way a live message is, with a
|
|
29
|
+
* collapsed code block's full text as `detail` for Ctrl+O.
|
|
30
|
+
*
|
|
31
|
+
* A resumed session replays its saved answers through this, so a restored conversation reads
|
|
32
|
+
* the same as it did when the answers were first printed instead of showing raw `**` and `##`.
|
|
33
|
+
* Only outer blank lines are stripped; leading spaces can be a fenced block's indentation.
|
|
34
|
+
* @param summary - the answer's markdown source.
|
|
35
|
+
* @returns the rendered entry.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatAnswer(summary: string): TranscriptEntry;
|
|
27
38
|
export interface RunResultView {
|
|
28
39
|
id: string;
|
|
29
40
|
status: string;
|
package/dist/src/transcript.js
CHANGED
|
@@ -93,6 +93,19 @@ export function transcriptColor(text) {
|
|
|
93
93
|
return GRAY;
|
|
94
94
|
return DIM;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Render an agent's answer on its own: markdown drawn the way a live message is, with a
|
|
98
|
+
* collapsed code block's full text as `detail` for Ctrl+O.
|
|
99
|
+
*
|
|
100
|
+
* A resumed session replays its saved answers through this, so a restored conversation reads
|
|
101
|
+
* the same as it did when the answers were first printed instead of showing raw `**` and `##`.
|
|
102
|
+
* Only outer blank lines are stripped; leading spaces can be a fenced block's indentation.
|
|
103
|
+
* @param summary - the answer's markdown source.
|
|
104
|
+
* @returns the rendered entry.
|
|
105
|
+
*/
|
|
106
|
+
export function formatAnswer(summary) {
|
|
107
|
+
return renderMarkdown(clean(summary).replace(/^(?:[ \t]*\n)+/, '').replace(/\s+$/, ''));
|
|
108
|
+
}
|
|
96
109
|
/**
|
|
97
110
|
* Render a finished run for the transcript: the completion summary as rendered markdown, the
|
|
98
111
|
* checks the agent reports under their own heading, and the run line last.
|
|
@@ -105,8 +118,7 @@ export function transcriptColor(text) {
|
|
|
105
118
|
* shows the whole answer in place.
|
|
106
119
|
*/
|
|
107
120
|
export function formatRunResult(result) {
|
|
108
|
-
const
|
|
109
|
-
const rendered = renderMarkdown(summary);
|
|
121
|
+
const rendered = formatAnswer(result.summary);
|
|
110
122
|
const checks = (result.tests ?? []).map(check => line(check)).filter(Boolean);
|
|
111
123
|
const trailer = [
|
|
112
124
|
...(checks.length ? ['', `${HEADING_PREFIX} Checks`, ...checks.map(check => ` • ${check}`)] : []),
|
|
@@ -148,7 +160,7 @@ export function formatEvent(event) {
|
|
|
148
160
|
if (event.type === 'agent.model.retry')
|
|
149
161
|
return { text: `\u2022 ${actor}Provider request retry ${line(data.retry)}/${line(data.maxRetries)} in ${formatRetryDelay(data.delayMs)}: ${line(data.reason)}` };
|
|
150
162
|
if (event.type === 'graph.node.started')
|
|
151
|
-
return { text: `
|
|
163
|
+
return { text: `Step: ${line(data.nodeName ?? data.nodeId)}${Number(data.visit) > 1 ? ` (visit ${line(data.visit)})` : ''}` };
|
|
152
164
|
if (event.type === 'agent.modifier.iteration.started' && Number(data.maxIterations) > 1)
|
|
153
165
|
return { text: `${line(data.nodeName ?? data.nodeId)} - loop ${line(data.iteration)}/${line(data.maxIterations)}` };
|
|
154
166
|
if (event.type === 'agent.modifier.copy.started' && Number(data.copies) > 1)
|
package/dist/src/types.d.ts
CHANGED
|
@@ -211,6 +211,12 @@ export interface ToolContext {
|
|
|
211
211
|
* surfaces with no live permission control, where presenting a plan cannot proceed.
|
|
212
212
|
*/
|
|
213
213
|
approvePlan?: () => Promise<import('./permissions.js').PermissionMode>;
|
|
214
|
+
/**
|
|
215
|
+
* Run `work` as a wait on something outside the run (a reviewer on GitHub, say), with every enclosing wall-time
|
|
216
|
+
* budget suspended for its duration, the way a question to the user is. Set by `bindUserWaits`; a surface with no
|
|
217
|
+
* budget leaves it unset and the caller runs the work directly.
|
|
218
|
+
*/
|
|
219
|
+
waitOutside?: <T>(work: () => Promise<T>) => Promise<T>;
|
|
214
220
|
onApprovalEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
|
|
215
221
|
/** Browser lifecycle observations, scoped to the current coding session, never a tool-supplied identity. */
|
|
216
222
|
onBrowserEvent?: (type: string, data: Record<string, unknown>) => void | Promise<void>;
|
|
@@ -264,6 +270,12 @@ export interface ToolContext {
|
|
|
264
270
|
sessionScope?: string;
|
|
265
271
|
/** The session's pull request backing `pull_request`; absent means the tool reports itself unavailable. */
|
|
266
272
|
pullRequests?: import('./pull-requests.js').PullRequestControl;
|
|
273
|
+
/**
|
|
274
|
+
* Where the run's file writes are reported for review (Keep / Undo). Every agent write to a workspace
|
|
275
|
+
* file reports its path just before it lands and again once it has; a subagent's context inherits the
|
|
276
|
+
* recorder. Absent where no session keeps a review record, which writes exactly as before.
|
|
277
|
+
*/
|
|
278
|
+
fileChanges?: import('./session-changes.js').FileChangeRecorder;
|
|
267
279
|
}
|
|
268
280
|
export type ToolFamily = 'filesystem-read' | 'filesystem-write' | 'code-search' | 'codegraph' | 'git' | 'shell' | 'qa' | 'memory' | 'web' | 'browser' | 'subagents' | 'artifact';
|
|
269
281
|
export interface Tool extends ToolSchema {
|
|
@@ -29,7 +29,8 @@ export interface UsageAnalytics {
|
|
|
29
29
|
* `jevInputTokens`/`jevOutputTokens` are the measured tokens of the run/nodes Jev was enabled on
|
|
30
30
|
* — the only usage a bypass could have replaced, and so the base of the avoidance rate.
|
|
31
31
|
* `contextEstimatedTurns` counts the bypasses whose input came from the journaled context size
|
|
32
|
-
* rather than the last-measured-input fallback.
|
|
32
|
+
* rather than the last-measured-input fallback. `jevCalls` counts the requests Jev answered
|
|
33
|
+
* (`decision.completed`) — most shape a request rather than replace one, so it is not `bypassedTurns`.
|
|
33
34
|
*/
|
|
34
35
|
totals: {
|
|
35
36
|
inputTokens: number;
|
|
@@ -38,6 +39,7 @@ export interface UsageAnalytics {
|
|
|
38
39
|
savedInputEstimate: number;
|
|
39
40
|
savedOutputEstimate: number;
|
|
40
41
|
bypassedTurns: number;
|
|
42
|
+
jevCalls: number;
|
|
41
43
|
unestimatedTurns: number;
|
|
42
44
|
contextEstimatedTurns: number;
|
|
43
45
|
jevInputTokens: number;
|
|
@@ -57,6 +57,7 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
57
57
|
const jevNodes = new Set();
|
|
58
58
|
let unestimatedTurns = 0;
|
|
59
59
|
let contextEstimatedTurns = 0;
|
|
60
|
+
let jevCalls = 0;
|
|
60
61
|
const dayFor = (date) => {
|
|
61
62
|
let day = days.get(date);
|
|
62
63
|
if (!day) {
|
|
@@ -128,6 +129,13 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
128
129
|
// Jev was enabled there. Run-level notices carry no node and mark nothing.
|
|
129
130
|
if (typeof data?.runId === 'string' && typeof data.nodeId === 'string')
|
|
130
131
|
jevNodes.add(JSON.stringify([data.runId, data.nodeId]));
|
|
132
|
+
// An answered Jev request. Counted apart from the bypasses: a preflight answer picks tools and
|
|
133
|
+
// skills for a call that is still made, so most Jev calls skip nothing.
|
|
134
|
+
if (event.type === 'decision.completed') {
|
|
135
|
+
if (date >= cutoff)
|
|
136
|
+
jevCalls++;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
131
139
|
if (event.type !== 'decision.turn_bypassed')
|
|
132
140
|
return;
|
|
133
141
|
const identity = typeof data?.runId === 'string' && typeof data.nodeId === 'string' ? JSON.stringify([data.runId, data.nodeId]) : undefined;
|
|
@@ -174,6 +182,7 @@ export function createUsageCollector(windowDays, now = new Date(), resolveProvid
|
|
|
174
182
|
savedInputEstimate: orderedModels.reduce((sum, row) => sum + row.savedInputEstimate, 0),
|
|
175
183
|
savedOutputEstimate: orderedModels.reduce((sum, row) => sum + row.savedOutputEstimate, 0),
|
|
176
184
|
bypassedTurns: orderedDays.reduce((sum, day) => sum + day.bypassedTurns, 0),
|
|
185
|
+
jevCalls,
|
|
177
186
|
unestimatedTurns,
|
|
178
187
|
contextEstimatedTurns,
|
|
179
188
|
jevInputTokens: 0,
|
|
@@ -200,8 +209,9 @@ const MAX_CACHE_RECORDS_TOTAL = 250_000;
|
|
|
200
209
|
/**
|
|
201
210
|
* 2: files are re-read once to capture the `j` markers version 1 never stored.
|
|
202
211
|
* 3: and again for the bypass accounting fields (`i`, `p`, `m` on `b`) version 2 never stored.
|
|
212
|
+
* 4: and again for the answered Jev calls (`d`), which earlier versions folded into one `j` marker.
|
|
203
213
|
*/
|
|
204
|
-
const CACHE_VERSION =
|
|
214
|
+
const CACHE_VERSION = 4;
|
|
205
215
|
const NAME_PATTERN = /^[a-zA-Z0-9_-]{1,64}\.jsonl$/;
|
|
206
216
|
/** The largest window the collector accepts; files older than its bound are never replayed. */
|
|
207
217
|
const MAX_WINDOW_DAYS = 365;
|
|
@@ -242,6 +252,8 @@ const slimOf = (record) => {
|
|
|
242
252
|
if (typeof event?.type !== 'string' || !event.type.startsWith('decision.'))
|
|
243
253
|
return undefined;
|
|
244
254
|
const data = asObject(event.data);
|
|
255
|
+
if (event.type === 'decision.completed')
|
|
256
|
+
return { k: 'd', t: item.time, ...(typeof data?.runId === 'string' ? { r: data.runId } : {}), ...(typeof data?.nodeId === 'string' ? { n: data.nodeId } : {}) };
|
|
245
257
|
if (event.type !== 'decision.turn_bypassed')
|
|
246
258
|
return typeof data?.runId === 'string' && typeof data.nodeId === 'string'
|
|
247
259
|
? { k: 'j', t: item.time, r: data.runId, n: data.nodeId } : undefined;
|
|
@@ -265,7 +277,7 @@ const replayOf = (slim) => slim.k === 'r'
|
|
|
265
277
|
: {
|
|
266
278
|
type: 'runtime.event', time: slim.t,
|
|
267
279
|
// The collector reads a marker's run and node only, so one type stands in for all of them.
|
|
268
|
-
event: { type: slim.k === 'b' ? 'decision.turn_bypassed' : 'decision.ready', data: {
|
|
280
|
+
event: { type: slim.k === 'b' ? 'decision.turn_bypassed' : slim.k === 'd' ? 'decision.completed' : 'decision.ready', data: {
|
|
269
281
|
...(slim.r === undefined ? {} : { runId: slim.r }), ...(slim.n === undefined ? {} : { nodeId: slim.n }),
|
|
270
282
|
...(slim.k === 'b' && slim.i !== undefined ? { estimatedInputTokens: slim.i } : {}),
|
|
271
283
|
...(slim.k === 'b' && slim.p !== undefined ? { providerId: slim.p } : {}),
|
|
@@ -290,6 +302,8 @@ const validSlim = (value) => {
|
|
|
290
302
|
&& (item.p === undefined || typeof item.p === 'string') && (item.m === undefined || typeof item.m === 'string');
|
|
291
303
|
if (item.k === 'j')
|
|
292
304
|
return typeof item.r === 'string' && typeof item.n === 'string';
|
|
305
|
+
if (item.k === 'd')
|
|
306
|
+
return true;
|
|
293
307
|
if (item.k !== 'r')
|
|
294
308
|
return false;
|
|
295
309
|
if (typeof item.p !== 'string' || typeof item.m !== 'string')
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andorra-labs/code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Terminal-first coding agent with a ReAct graph runtime",
|
|
5
|
+
"homepage": "https://andorracode.com",
|
|
5
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"bin": {
|
|
@@ -10,34 +11,12 @@
|
|
|
10
11
|
},
|
|
11
12
|
"files": [
|
|
12
13
|
"dist/src",
|
|
13
|
-
"
|
|
14
|
+
"dist/vendor/engine",
|
|
15
|
+
"dist/vendor/zcode",
|
|
14
16
|
"LICENSE.md",
|
|
15
17
|
"THIRD_PARTY_NOTICES.md",
|
|
16
18
|
"licenses/ZCODE-APACHE-2.0.txt",
|
|
17
|
-
"licenses/GEIST-OFL-1.1.txt"
|
|
18
|
-
"docs",
|
|
19
|
-
"tests/decision-engine-test-plan.md",
|
|
20
|
-
"tests/jev-efficiency-test-plan.md",
|
|
21
|
-
"tests/jev-efficiency/workloads.mjs",
|
|
22
|
-
"tests/jev-efficiency/criteria.json",
|
|
23
|
-
"scripts/jev-efficiency-eval.mjs",
|
|
24
|
-
"scripts/jev-efficiency-live.mjs",
|
|
25
|
-
"tests/default-active-jev-test-plan.md",
|
|
26
|
-
"tests/jev-all-decisions-test-plan.md",
|
|
27
|
-
"tests/permissions-test-plan.md",
|
|
28
|
-
"tests/permissions-sandbox-probe.mjs",
|
|
29
|
-
"tests/thinking-stream-preview-test-plan.md",
|
|
30
|
-
"dist/vendor/engine",
|
|
31
|
-
"dist/vendor/zcode",
|
|
32
|
-
"tests/browser-test-plan.md",
|
|
33
|
-
"tests/browser-cli-smoke.mjs",
|
|
34
|
-
"scripts/zcode-engine-replay.mjs",
|
|
35
|
-
"tests/zcode-react-engine-test-plan.md",
|
|
36
|
-
"tests/harness-extensions-test-plan.md",
|
|
37
|
-
"tests/chat-side-panel-test-plan.md",
|
|
38
|
-
"tests/agent-centric-mcp-test-plan.md",
|
|
39
|
-
"tests/analytics-settings-test-plan.md",
|
|
40
|
-
"tests/product-telemetry-test-plan.md"
|
|
19
|
+
"licenses/GEIST-OFL-1.1.txt"
|
|
41
20
|
],
|
|
42
21
|
"engines": {
|
|
43
22
|
"node": ">=22.19.0"
|
|
@@ -77,6 +56,7 @@
|
|
|
77
56
|
"@anthropic-ai/sdk": "0.124.0",
|
|
78
57
|
"@colbymchenry/codegraph": "^1.6.0",
|
|
79
58
|
"@google/genai": "2.21.0",
|
|
59
|
+
"@hyzyla/pdfium": "3.0.0",
|
|
80
60
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
81
61
|
"@napi-rs/keyring": "^2.1.0",
|
|
82
62
|
"@peculiar/x509": "2.1.0",
|