@andorra-labs/code 0.1.10 → 0.1.12
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 +31 -205
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/src/agent-execution.js +50 -2
- package/dist/src/agent-mcp.js +5 -0
- package/dist/src/app-server/protocol.d.ts +9 -1
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server.d.ts +49 -1
- package/dist/src/app-server.js +353 -64
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-panel-tool.d.ts +24 -3
- package/dist/src/browser-panel-tool.js +80 -6
- package/dist/src/browser-runner.js +3 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +38 -2
- package/dist/src/claude-provider.js +15 -2
- package/dist/src/cli.d.ts +2 -1
- package/dist/src/cli.js +175 -43
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +1 -1
- package/dist/src/codex-provider.js +6 -3
- package/dist/src/coding-tools.d.ts +26 -1
- package/dist/src/coding-tools.js +104 -33
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +51 -1
- package/dist/src/completion.js +164 -5
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +2 -0
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/delegation-changes.js +19 -2
- package/dist/src/diff-preview.d.ts +1 -0
- package/dist/src/diff-preview.js +12 -3
- package/dist/src/engine-streams.d.ts +22 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.js +17 -6
- package/dist/src/file-read-key.d.ts +8 -0
- package/dist/src/file-read-key.js +12 -0
- package/dist/src/graph-editor-session.js +2 -1
- package/dist/src/graph-health.d.ts +21 -0
- package/dist/src/graph-health.js +46 -0
- package/dist/src/graph-manager-chat.d.ts +52 -3
- package/dist/src/graph-manager-chat.js +62 -17
- package/dist/src/graph-runner.js +62 -5
- package/dist/src/graph-server.d.ts +1 -1
- package/dist/src/graph-server.js +48 -27
- 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 +362 -123
- package/dist/src/graph-ui/controls.css +95 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +7 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/manager-state.js +143 -5
- package/dist/src/graph-ui/manager.css +21 -20
- package/dist/src/graph-ui/manager.js +337 -75
- package/dist/src/graph-ui/model-picker.js +279 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +5 -2
- package/dist/src/graphs.js +10 -9
- package/dist/src/mcp.d.ts +52 -14
- package/dist/src/mcp.js +285 -128
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/memory/ProjectMemory.d.ts +77 -0
- package/dist/src/memory/ProjectMemory.js +310 -0
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- package/dist/src/opencode-provider.js +5 -6
- package/dist/src/package-name.d.ts +3 -0
- package/dist/src/package-name.js +3 -0
- package/dist/src/provider-engine.js +2 -2
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/qa/runtime/PtyManager.js +2 -1
- package/dist/src/react-runtime.js +137 -22
- 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/cert.d.ts +1 -1
- package/dist/src/remote/cert.js +2 -7
- package/dist/src/remote/client.js +1 -1
- package/dist/src/remote/pem.d.ts +6 -0
- package/dist/src/remote/pem.js +11 -0
- package/dist/src/run-records.js +49 -10
- package/dist/src/runtime.d.ts +21 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/sessions.d.ts +3 -1
- package/dist/src/sessions.js +5 -3
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/sign-in-detection.d.ts +82 -0
- package/dist/src/sign-in-detection.js +197 -0
- package/dist/src/sign-in-offer.d.ts +35 -0
- package/dist/src/sign-in-offer.js +116 -0
- 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 +59 -7
- 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.d.ts +6 -0
- package/dist/src/skills/runtime-skills.js +16 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/stray-files.d.ts +14 -0
- package/dist/src/stray-files.js +81 -0
- package/dist/src/subagent-run.js +6 -1
- package/dist/src/terminal-ui.d.ts +1 -1
- package/dist/src/terminal-ui.js +11 -5
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tool-activity.js +1 -1
- package/dist/src/tool-schema-compatibility.d.ts +7 -2
- package/dist/src/tool-schema-compatibility.js +8 -4
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.d.ts +5 -0
- package/dist/src/transcript.js +12 -4
- package/dist/src/types.d.ts +8 -0
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +125 -0
- package/dist/src/update-check.js +1 -1
- package/dist/src/update.d.ts +11 -1
- package/dist/src/update.js +27 -5
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/dist/src/workspace-git-metadata.d.ts +15 -0
- package/dist/src/workspace-git-metadata.js +50 -1
- package/dist/src/workspace-instructions.js +1 -1
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Optional paired live evaluation of the efficiency switches against the configured provider.
|
|
3
|
-
//
|
|
4
|
-
// ANDORRA_LIVE_EVAL=1 ANDORRA_LIVE_EVAL_HOME=<signed-in evaluation home> node scripts/jev-efficiency-live.mjs [--pairs N] [--feature <name>|all] [--task-file <file>] [--budget-minutes M] [--out <dir>]
|
|
5
|
-
//
|
|
6
|
-
// Runs the built CLI headlessly (`node dist/src/cli.js --prompt ... --json --yolo`) in matched pairs:
|
|
7
|
-
// a baseline run and a candidate run with one efficiency switch (or every switch) turned on, each
|
|
8
|
-
// from a fresh copy of the same empty workspace, with the same provider, model, permissions and
|
|
9
|
-
// limits. The order alternates within each pair to spread warm-up and cache effects. Every run's
|
|
10
|
-
// result, run log and output tree are kept under the output directory; nothing is averaged away.
|
|
11
|
-
//
|
|
12
|
-
// The runs use one dedicated evaluation home, named by ANDORRA_LIVE_EVAL_HOME, for every run. The
|
|
13
|
-
// hosted decision service only answers a signed-in account, and credentials are scoped to the exact
|
|
14
|
-
// home they were created under (`credentialIdentity` in src/auth/AuthManager.ts), so a throwaway
|
|
15
|
-
// home would run every pair anonymously, with the decision manager disabled, and measure the
|
|
16
|
-
// prepared-continuation and postflight switches as if they did nothing. The evaluation home must
|
|
17
|
-
// therefore be signed in on its own (`ANDORRACODE_HOME=<home> andorra login`), with its own
|
|
18
|
-
// evaluation account rather than the user's day-to-day one; the script never copies credentials
|
|
19
|
-
// between homes. Only the home's `efficiency` block changes between runs, and it is restored
|
|
20
|
-
// afterwards. Before any pair is spent, one probe run confirms that decisions are actually
|
|
21
|
-
// requested under this home; without that evidence the script stops and reports why. Every child
|
|
22
|
-
// process — the probe, each paired CLI run and its executable check — is terminated at the
|
|
23
|
-
// remaining evaluation deadline, and a run the deadline killed is recorded as timed out.
|
|
24
|
-
//
|
|
25
|
-
// It refuses to run without ANDORRA_LIVE_EVAL=1, the evaluation home and a configured provider —
|
|
26
|
-
// and, when measuring `adaptiveRouting`, with that switch enabled and its tiers resolvable in the
|
|
27
|
-
// home, because the candidate is the home's own routing configuration. It writes no claim it did
|
|
28
|
-
// not measure, and never fabricates a result for a run that failed. Quality
|
|
29
|
-
// is judged by the executable check the task file names (`check` field), not by the model's own
|
|
30
|
-
// report.
|
|
31
|
-
import { cp, mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
32
|
-
import { spawn } from 'node:child_process';
|
|
33
|
-
import { tmpdir } from 'node:os';
|
|
34
|
-
import { dirname, join, resolve } from 'node:path';
|
|
35
|
-
import { fileURLToPath } from 'node:url';
|
|
36
|
-
|
|
37
|
-
const args = process.argv.slice(2);
|
|
38
|
-
const option = (name, fallback) => { const index = args.indexOf(name); return index >= 0 ? args[index + 1] : fallback; };
|
|
39
|
-
if (process.env.ANDORRA_LIVE_EVAL !== '1') {
|
|
40
|
-
process.stderr.write('Live evaluation is opt-in: set ANDORRA_LIVE_EVAL=1. It spends provider credit and time.\n');
|
|
41
|
-
process.exit(2);
|
|
42
|
-
}
|
|
43
|
-
const evalHome = process.env.ANDORRA_LIVE_EVAL_HOME;
|
|
44
|
-
if (!evalHome) {
|
|
45
|
-
process.stderr.write('Set ANDORRA_LIVE_EVAL_HOME to a dedicated evaluation home that is signed in (ANDORRACODE_HOME=<home> andorra login) with an evaluation account. The user\'s own home is not used, and credentials are never copied between homes.\n');
|
|
46
|
-
process.exit(2);
|
|
47
|
-
}
|
|
48
|
-
// `fileURLToPath` decodes the percent escapes a raw `URL.pathname` keeps, so a checkout path with
|
|
49
|
-
// spaces resolves to the directory that exists instead of its percent-encoded ghost.
|
|
50
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
51
|
-
const configPath = join(evalHome, 'config.json');
|
|
52
|
-
const originalConfigText = await readFile(configPath, 'utf8').catch(() => undefined);
|
|
53
|
-
if (originalConfigText === undefined) { process.stderr.write(`${configPath} does not exist; the evaluation home must be configured first.\n`); process.exit(2); }
|
|
54
|
-
const config = JSON.parse(originalConfigText);
|
|
55
|
-
if (!config.providers?.length) { process.stderr.write('No provider is configured in the evaluation home; nothing to evaluate.\n'); process.exit(2); }
|
|
56
|
-
if (config.jevEnabled === false) { process.stderr.write('jevEnabled is false in the evaluation home; the decision-dependent switches cannot be measured.\n'); process.exit(2); }
|
|
57
|
-
const pairs = Number(option('--pairs', '2'));
|
|
58
|
-
const feature = option('--feature', 'all');
|
|
59
|
-
const budgetMinutes = Number(option('--budget-minutes', '30'));
|
|
60
|
-
const out = resolve(option('--out', join(root, 'tests/jev-efficiency/results/live')));
|
|
61
|
-
const taskFile = option('--task-file');
|
|
62
|
-
const tasks = taskFile ? JSON.parse(await readFile(taskFile, 'utf8')) : [
|
|
63
|
-
{ id: 'greenfield-page', prompt: 'Create index.html: a single-file page with a heading "Hello" and a button that toggles the text between "Hello" and "Goodbye". Do not use any build step. Verify the file parses by running node -e "require(\'fs\').readFileSync(\'index.html\',\'utf8\')" and report what you created.', check: 'node -e "const s=require(\'fs\').readFileSync(\'index.html\',\'utf8\'); if(!/<button/i.test(s)||!/Hello/.test(s)) process.exit(1)"' },
|
|
64
|
-
];
|
|
65
|
-
const FEATURES = ['preparedContinuations', 'postflightOnlyWithCandidates', 'toolResultFiltering', 'contextSelection', 'catalogSelection'];
|
|
66
|
-
// Adaptive routing is measured with the evaluation home's own configuration: its tiers and prices
|
|
67
|
-
// are the thing under test, and a synthetic `{ adaptiveRouting: true }` would be rejected outright.
|
|
68
|
-
const homeRouting = config.efficiency?.adaptiveRouting;
|
|
69
|
-
const routingUsable = !!homeRouting && typeof homeRouting === 'object' && homeRouting.enabled === true
|
|
70
|
-
&& !!homeRouting.tiers && Object.keys(homeRouting.tiers).length > 0;
|
|
71
|
-
if (feature === 'adaptiveRouting' && !routingUsable) {
|
|
72
|
-
process.stderr.write('Measuring adaptiveRouting requires the evaluation home to configure efficiency.adaptiveRouting with enabled: true and tiers; the script measures that configuration as the candidate.\n');
|
|
73
|
-
process.exit(2);
|
|
74
|
-
}
|
|
75
|
-
if (routingUsable && (feature === 'adaptiveRouting' || feature === 'all')) {
|
|
76
|
-
for (const [tier, target] of Object.entries(homeRouting.tiers)) {
|
|
77
|
-
const provider = (config.providers ?? []).find(item => item?.id === target?.provider);
|
|
78
|
-
const model = target?.model ?? provider?.model;
|
|
79
|
-
if (!provider || !model || (target.model !== undefined && provider.models?.length && !provider.models.includes(target.model) && provider.model !== target.model)) {
|
|
80
|
-
process.stderr.write(`efficiency.adaptiveRouting.tiers.${tier} names ${target?.provider ?? '?'}/${target?.model ?? '?'} which the evaluation home does not configure; routing would treat it as unconfigured and the measurement would be void.\n`);
|
|
81
|
-
process.exit(2);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const candidateConfig = feature === 'all'
|
|
86
|
-
? { ...Object.fromEntries(FEATURES.map(name => [name, true])), ...(routingUsable ? { adaptiveRouting: homeRouting } : {}) }
|
|
87
|
-
: feature === 'adaptiveRouting' ? { adaptiveRouting: homeRouting } : { [feature]: true };
|
|
88
|
-
// Prices belong to both variants: the runtime's accounting reads them from the efficiency block, so a
|
|
89
|
-
// baseline run without the block would report every cost as unavailable and the pair could not
|
|
90
|
-
// compare spending. The baseline carries the prices with routing off; a candidate that does not
|
|
91
|
-
// measure routing carries them the same way.
|
|
92
|
-
const pricing = homeRouting && typeof homeRouting === 'object' && homeRouting.pricing ? homeRouting.pricing : undefined;
|
|
93
|
-
const baselineConfig = pricing ? { adaptiveRouting: { enabled: false, pricing } } : undefined;
|
|
94
|
-
if (pricing && !candidateConfig.adaptiveRouting) candidateConfig.adaptiveRouting = { enabled: false, pricing };
|
|
95
|
-
|
|
96
|
-
// One child process under the remaining evaluation budget: the spawn `timeout` terminates it at
|
|
97
|
-
// the deadline and `close` still awaits it, so a hung run or check can hold neither the budget
|
|
98
|
-
// nor the configuration restoration below. `signal` is set when the deadline killed it.
|
|
99
|
-
const run = (command, commandArgs, options, timeoutMs) => new Promise(resolveRun => {
|
|
100
|
-
const child = spawn(command, commandArgs, { ...options, windowsHide: true, ...(Number.isFinite(timeoutMs) && timeoutMs > 0 ? { timeout: timeoutMs } : {}) });
|
|
101
|
-
let stdout = '', stderr = '';
|
|
102
|
-
child.stdout.on('data', chunk => { stdout += chunk; });
|
|
103
|
-
child.stderr.on('data', chunk => { stderr += chunk; });
|
|
104
|
-
child.on('close', (code, signal) => resolveRun({ code, stdout, stderr, ...(signal ? { signal } : {}) }));
|
|
105
|
-
});
|
|
106
|
-
const runLogs = async () => new Set((await readdir(join(evalHome, 'runs')).catch(() => [])).filter(name => name.endsWith('.jsonl')));
|
|
107
|
-
const eventTypes = async names => {
|
|
108
|
-
const types = [];
|
|
109
|
-
for (const name of names) for (const line of (await readFile(join(evalHome, 'runs', name), 'utf8')).split('\n')) { if (!line.trim()) continue; try { types.push(JSON.parse(line).type); } catch { /* partial line */ } }
|
|
110
|
-
return types;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// One CLI run under the evaluation home with the given efficiency block; returns the outcome and the
|
|
114
|
-
// run logs it produced. The home's config is rewritten for the run and restored by the caller.
|
|
115
|
-
async function evaluate(task, efficiency, label) {
|
|
116
|
-
if (deadline - Date.now() <= 0) return { exitCode: null, durationMs: 0, checkPassed: null, usage: null, status: null, decisionsRequested: 0, efficiencyEvents: 0, timedOut: true };
|
|
117
|
-
await writeFile(configPath, JSON.stringify({ ...config, ...(efficiency ? { efficiency } : {}) }, null, 2));
|
|
118
|
-
if (!efficiency) { const cleared = { ...config }; delete cleared.efficiency; await writeFile(configPath, JSON.stringify(cleared, null, 2)); }
|
|
119
|
-
const workspace = await mkdtemp(join(tmpdir(), 'andorra-live-eval-ws-'));
|
|
120
|
-
const before = await runLogs();
|
|
121
|
-
try {
|
|
122
|
-
const remainingMs = deadline - Date.now();
|
|
123
|
-
const startedAt = Date.now();
|
|
124
|
-
const cli = await run(process.execPath, [join(root, 'dist/src/cli.js'), '--cwd', workspace, '--prompt', task.prompt, '--json', '--yolo'], { cwd: workspace, env: { ...process.env, ANDORRACODE_HOME: evalHome } }, remainingMs);
|
|
125
|
-
const durationMs = Date.now() - startedAt;
|
|
126
|
-
// A run the deadline killed still reports its partial output; the executable check is not
|
|
127
|
-
// spent on a CLI run that never finished.
|
|
128
|
-
const timedOut = cli.signal !== undefined;
|
|
129
|
-
const check = !timedOut && task.check ? await run(process.platform === 'win32' ? 'cmd' : 'sh', process.platform === 'win32' ? ['/c', task.check] : ['-c', task.check], { cwd: workspace }, deadline - Date.now()) : undefined;
|
|
130
|
-
let summary;
|
|
131
|
-
try { summary = JSON.parse(cli.stdout.trim().split('\n').at(-1)); } catch { summary = undefined; }
|
|
132
|
-
// The runtime applies the home's configured routing prices to its own usage, so the run
|
|
133
|
-
// summary's per-model tuples carry the cost. The capture's completeness rule applies here too:
|
|
134
|
-
// a tuple counts only when every request in it was priced, and the run reports a total only
|
|
135
|
-
// when every model it used was priced — a partial sum would quietly omit a model's spend.
|
|
136
|
-
const modelTuples = summary?.telemetry?.models ?? [];
|
|
137
|
-
const costMicroUsd = modelTuples.length && modelTuples.every(tuple => typeof tuple.costMicroUsd === 'number' && tuple.reported?.cost === tuple.requests)
|
|
138
|
-
? modelTuples.reduce((total, tuple) => total + tuple.costMicroUsd, 0)
|
|
139
|
-
: null;
|
|
140
|
-
const produced = [...await runLogs()].filter(name => !before.has(name));
|
|
141
|
-
await mkdir(join(out, label), { recursive: true });
|
|
142
|
-
await writeFile(join(out, label, 'cli-stdout.json'), cli.stdout);
|
|
143
|
-
await writeFile(join(out, label, 'cli-stderr.txt'), cli.stderr);
|
|
144
|
-
for (const name of produced) await cp(join(evalHome, 'runs', name), join(out, label, 'runs', name)).catch(() => {});
|
|
145
|
-
await cp(workspace, join(out, label, 'output'), { recursive: true }).catch(() => {});
|
|
146
|
-
const types = await eventTypes(produced);
|
|
147
|
-
return { exitCode: cli.code, durationMs, checkPassed: check ? check.code === 0 : null, usage: summary?.usage ?? null, costMicroUsd, status: summary?.status ?? null, decisionsRequested: types.filter(type => type === 'decision.requested').length, efficiencyEvents: types.filter(type => type.startsWith('efficiency.')).length, ...(timedOut ? { timedOut: true } : {}) };
|
|
148
|
-
} finally {
|
|
149
|
-
await rm(workspace, { recursive: true, force: true });
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const started = Date.now();
|
|
154
|
-
// The whole evaluation, probe included, ends by this clock: every child process it spawns is
|
|
155
|
-
// handed the remaining allowance as its timeout, so no single run can spend past the budget.
|
|
156
|
-
const deadline = started + budgetMinutes * 60_000;
|
|
157
|
-
await mkdir(out, { recursive: true });
|
|
158
|
-
const results = [];
|
|
159
|
-
let aborted;
|
|
160
|
-
try {
|
|
161
|
-
// The probe: a candidate run must show the decision service answering under this home, or the
|
|
162
|
-
// decision-dependent switches would be measured while disabled and the comparison would be void.
|
|
163
|
-
const probe = await evaluate(tasks[0], candidateConfig, 'probe-candidate');
|
|
164
|
-
if (probe.timedOut) {
|
|
165
|
-
aborted = `the probe run hit the ${budgetMinutes}-minute evaluation budget before it finished; no pair was spent. Raise --budget-minutes or shorten the task.`;
|
|
166
|
-
} else if (probe.decisionsRequested === 0) {
|
|
167
|
-
aborted = `the probe run under ${evalHome} requested no decision (exit ${probe.exitCode}, status ${probe.status}); the home is not signed in to the decision service or decisions are disabled, so the comparison would measure disabled switches. Sign in under this home (ANDORRACODE_HOME=${evalHome} andorra login) and retry.`;
|
|
168
|
-
}
|
|
169
|
-
for (let pair = 1; pair <= pairs && !aborted; pair++) {
|
|
170
|
-
for (const task of tasks) {
|
|
171
|
-
const order = pair % 2 === 1 ? ['baseline', 'candidate'] : ['candidate', 'baseline'];
|
|
172
|
-
for (const variant of order) {
|
|
173
|
-
if (Date.now() - started > budgetMinutes * 60_000) { process.stderr.write('Time budget exhausted; stopping.\n'); break; }
|
|
174
|
-
const label = `${task.id}-pair${pair}-${variant}`;
|
|
175
|
-
const outcome = await evaluate(task, variant === 'candidate' ? candidateConfig : baselineConfig, label);
|
|
176
|
-
results.push({ task: task.id, pair, variant, order: order.indexOf(variant) + 1, label, ...outcome });
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
} finally {
|
|
181
|
-
await writeFile(configPath, originalConfigText);
|
|
182
|
-
}
|
|
183
|
-
const report = { feature, candidateConfig, evaluationHome: evalHome, pairs, sampleSize: results.length, aborted: aborted ?? null, results, caveats: [
|
|
184
|
-
'Each run is a separate process against the live provider; run-to-run variation is not attributable to the efficiency switches alone.',
|
|
185
|
-
'Prompt-cache state is not controlled beyond alternating order within a pair.',
|
|
186
|
-
'Usage figures are provider-reported where present; a run that reports none is left null, not zero.',
|
|
187
|
-
'costMicroUsd is the evaluation home\'s configured efficiency.adaptiveRouting.pricing applied by the runtime to its own usage; a run whose models were not all priced reports null, not a partial sum.',
|
|
188
|
-
'decisionsRequested counts decision.requested events in the run log; a candidate run with zero requested decisions did not exercise the decision-dependent switches.',
|
|
189
|
-
] };
|
|
190
|
-
await writeFile(join(out, 'summary.json'), JSON.stringify(report, null, 2) + '\n');
|
|
191
|
-
if (aborted) { process.stderr.write(`Aborted before the paired runs: ${aborted}\n`); process.exit(3); }
|
|
192
|
-
process.stdout.write(`${results.length} run(s) recorded under ${out}\n`);
|
|
193
|
-
for (const row of results) process.stdout.write(`${row.label}: exit ${row.exitCode}, status ${row.status}, check ${row.checkPassed}, ${row.durationMs} ms, decisions ${row.decisionsRequested}, usage ${JSON.stringify(row.usage)}, cost ${row.costMicroUsd === null || row.costMicroUsd === undefined ? 'unavailable' : `$${(row.costMicroUsd / 1_000_000).toFixed(4)}`}${row.timedOut ? ', killed at the evaluation deadline' : ''}\n`);
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
// Matched, offline historical-payload fixture. Never calls a configured provider.
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { createReadStream } from 'node:fs';
|
|
4
|
-
import { createInterface } from 'node:readline';
|
|
5
|
-
import { createHash } from 'node:crypto';
|
|
6
|
-
import { resolve, join } from 'node:path';
|
|
7
|
-
import { pathToFileURL } from 'node:url';
|
|
8
|
-
|
|
9
|
-
const [checkout = '.', trajectory, countArgument = '100'] = process.argv.slice(2);
|
|
10
|
-
if (!trajectory) throw new Error('Usage: node scripts/zcode-engine-replay.mjs <built-checkout> <V3-trajectory-jsonl> [tool-response-count=100]');
|
|
11
|
-
const count = Number(countArgument);
|
|
12
|
-
if (!Number.isInteger(count) || count < 20 || count > 200) throw new Error('Choose 20–200 historical tool responses');
|
|
13
|
-
const root = resolve(checkout);
|
|
14
|
-
const { AndorraAgentEngine } = await import(pathToFileURL(join(root, 'dist/src/hardened-runtime.js')).href);
|
|
15
|
-
const invocations = new Map();
|
|
16
|
-
const sourceHash = createHash('sha256');
|
|
17
|
-
const input = createReadStream(trajectory);
|
|
18
|
-
input.on('data', chunk => sourceHash.update(chunk));
|
|
19
|
-
let runId;
|
|
20
|
-
let invocationId;
|
|
21
|
-
let ordinal = 0;
|
|
22
|
-
for await (const line of createInterface({ input })) {
|
|
23
|
-
if (!line.trim()) continue;
|
|
24
|
-
const event = JSON.parse(line);
|
|
25
|
-
event.ordinal = ordinal++;
|
|
26
|
-
if (!['model.request', 'model.response', 'runtime.event'].includes(event.type)) continue;
|
|
27
|
-
if (event.type === 'runtime.event' && !['node.tool.completed', 'node.tool.failed'].includes(event.event?.type)) continue;
|
|
28
|
-
const eventRunId = event.type === 'runtime.event' ? event.event?.data?.runId : event.runId;
|
|
29
|
-
if (runId !== undefined && eventRunId !== runId) continue;
|
|
30
|
-
if (typeof eventRunId !== 'string' || !eventRunId) continue;
|
|
31
|
-
const identity = event.type === 'runtime.event' ? event.event?.data : event;
|
|
32
|
-
const eventInvocationId = identity?.invocationId;
|
|
33
|
-
const eligible = event.type === 'model.response' && event.toolCalls?.length
|
|
34
|
-
&& !event.toolCalls.some(call => ['complete_agent', 'update_todos'].includes(call.name));
|
|
35
|
-
if (invocationId !== undefined && eventInvocationId !== invocationId) continue;
|
|
36
|
-
if (typeof eventInvocationId !== 'string' || !eventInvocationId) {
|
|
37
|
-
assert.ok(!eligible, 'Exact visible-payload replay is unavailable: legacy evidence lacks an unambiguous agent invocation identity');
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const key = JSON.stringify([eventRunId, eventInvocationId]);
|
|
41
|
-
let run = invocations.get(key);
|
|
42
|
-
if (!run) {
|
|
43
|
-
run = { requests: new Map(), responses: [], observations: new Map(), latestToolResponses: new Map(),
|
|
44
|
-
identity: JSON.stringify([identity.nodeId ?? null, identity.subagentId ?? null]),
|
|
45
|
-
recordedUsage: { inputTokens: 0, outputTokens: 0, mainRequests: 0, auxiliaryRequests: 0 } };
|
|
46
|
-
invocations.set(key, run);
|
|
47
|
-
}
|
|
48
|
-
assert.equal(JSON.stringify([identity.nodeId ?? null, identity.subagentId ?? null]), run.identity,
|
|
49
|
-
'Exact visible-payload replay requires consistent node/subagent identity within an invocation');
|
|
50
|
-
const { requests, responses, observations, latestToolResponses, recordedUsage } = run;
|
|
51
|
-
if (event.type === 'model.request') {
|
|
52
|
-
assert.ok(!requests.has(event.requestId), 'Exact visible-payload replay requires unique request ids within its invocation');
|
|
53
|
-
requests.set(event.requestId, event);
|
|
54
|
-
}
|
|
55
|
-
if (eligible) {
|
|
56
|
-
responses.push(event);
|
|
57
|
-
runId ??= event.runId;
|
|
58
|
-
invocationId ??= eventInvocationId;
|
|
59
|
-
// Request and tool ids may repeat across graph nodes, retries and copies.
|
|
60
|
-
for (const otherKey of invocations.keys()) if (otherKey !== key) invocations.delete(otherKey);
|
|
61
|
-
}
|
|
62
|
-
if (event.type === 'model.response') {
|
|
63
|
-
// Call ids can recur later in the same run. Bind status events to their
|
|
64
|
-
// preceding response occurrence, including responses outside the selection.
|
|
65
|
-
for (const call of event.toolCalls ?? []) latestToolResponses.set(call.id, event.ordinal);
|
|
66
|
-
recordedUsage.inputTokens += event.usage?.inputTokens ?? 0;
|
|
67
|
-
recordedUsage.outputTokens += event.usage?.outputTokens ?? 0;
|
|
68
|
-
if (requests.get(event.requestId)?.tools?.length) recordedUsage.mainRequests++;
|
|
69
|
-
else recordedUsage.auxiliaryRequests++;
|
|
70
|
-
}
|
|
71
|
-
if (event.type === 'runtime.event' && ['node.tool.completed', 'node.tool.failed'].includes(event.event.type)) {
|
|
72
|
-
const data = event.event.data;
|
|
73
|
-
// Runtime outputs are public projections, not necessarily model observations.
|
|
74
|
-
const responseOrdinal = latestToolResponses.get(data.toolCallId);
|
|
75
|
-
if (responseOrdinal !== undefined) {
|
|
76
|
-
const batch = observations.get(responseOrdinal) ?? new Map();
|
|
77
|
-
const recorded = batch.get(data.toolCallId);
|
|
78
|
-
if (recorded) recorded.statusCount++;
|
|
79
|
-
else batch.set(data.toolCallId, { failed: event.event.type === 'node.tool.failed', statusCount: 1 });
|
|
80
|
-
observations.set(responseOrdinal, batch);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
assert.ok(runId !== undefined, 'Historical fixture must contain a tool-bearing response with a run id');
|
|
85
|
-
const { requests, responses, observations: responseObservations, recordedUsage } = invocations.get(JSON.stringify([runId, invocationId]));
|
|
86
|
-
const observations = new Map();
|
|
87
|
-
assert.ok(responses.length >= count, 'Historical fixture must contain the requested calls');
|
|
88
|
-
const selected = responses.slice(0, count);
|
|
89
|
-
const firstRequest = requests.get(selected[0].requestId);
|
|
90
|
-
assert.ok(firstRequest, 'The selected invocation must contain the request for its first selected response');
|
|
91
|
-
const expectedCalls = selected.reduce((total, response) => total + response.toolCalls.length, 0);
|
|
92
|
-
const assertRecoverable = value => assert.ok(!JSON.stringify(value).includes('[REDACTED'), 'Exact visible-payload replay is unavailable: selected evidence was sanitized');
|
|
93
|
-
assertRecoverable(firstRequest.messages.filter(message => message.role === 'user'));
|
|
94
|
-
const schemas = new Map();
|
|
95
|
-
const selectedIds = new Set();
|
|
96
|
-
const observationHash = createHash('sha256');
|
|
97
|
-
const matchingCalls = (left, right) => left?.length === right.length && left.every((call, index) =>
|
|
98
|
-
call.id === right[index].id && call.name === right[index].name && call.arguments === right[index].arguments);
|
|
99
|
-
for (const response of selected) {
|
|
100
|
-
const matchingRequest = requests.get(response.requestId);
|
|
101
|
-
assert.ok(matchingRequest && matchingRequest.ordinal < response.ordinal, 'Every selected response must have its matching preceding request');
|
|
102
|
-
assertRecoverable({ text: response.text, toolCalls: response.toolCalls });
|
|
103
|
-
// Locate the first subsequent request carrying this exact assistant exchange.
|
|
104
|
-
// Matching the entire batch avoids borrowing feedback from another invocation.
|
|
105
|
-
let feedback;
|
|
106
|
-
for (const subsequent of requests.values()) {
|
|
107
|
-
if (subsequent.ordinal <= response.ordinal) continue;
|
|
108
|
-
const messages = subsequent.messages ?? [];
|
|
109
|
-
const assistantIndex = messages.findIndex(message => message.role === 'assistant' && matchingCalls(message.toolCalls, response.toolCalls));
|
|
110
|
-
if (assistantIndex < 0) continue;
|
|
111
|
-
const batch = messages.slice(assistantIndex + 1, assistantIndex + 1 + response.toolCalls.length);
|
|
112
|
-
if (batch.length === response.toolCalls.length && batch.every(message => message.role === 'tool')
|
|
113
|
-
&& response.toolCalls.every(call => batch.filter(message => message.toolCallId === call.id).length === 1)) {
|
|
114
|
-
feedback = batch;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
assert.ok(feedback, 'Exact visible-payload replay is unavailable: no subsequent matching model request contains complete tool feedback');
|
|
119
|
-
for (const call of response.toolCalls) {
|
|
120
|
-
assert.ok(!selectedIds.has(call.id), 'Exact visible-payload replay requires unique selected tool call ids within its invocation');
|
|
121
|
-
selectedIds.add(call.id);
|
|
122
|
-
const schema = matchingRequest.tools?.find(tool => tool.name === call.name);
|
|
123
|
-
assert.ok(schema, 'Every historical call must be advertised by its own matching request');
|
|
124
|
-
assertRecoverable(schema);
|
|
125
|
-
const existing = schemas.get(call.name);
|
|
126
|
-
if (existing) {
|
|
127
|
-
assert.ok(JSON.stringify(existing.parameters) === JSON.stringify(schema.parameters)
|
|
128
|
-
&& existing.executionMode === schema.executionMode, 'Exact replay does not support changing schemas for the same tool name');
|
|
129
|
-
} else schemas.set(call.name, schema);
|
|
130
|
-
const message = feedback.find(message => message.toolCallId === call.id);
|
|
131
|
-
assert.ok(typeof message.content === 'string', 'Exact visible-payload replay requires recorded textual feedback');
|
|
132
|
-
assertRecoverable(message.content);
|
|
133
|
-
// Trajectories intentionally omit native images. Never reconstruct or expose them.
|
|
134
|
-
assert.ok(!message.images?.length && !/"screenshotId"\s*:/.test(message.content), 'Exact visible-payload replay is unavailable: native image evidence is omitted or unsupported');
|
|
135
|
-
const recorded = responseObservations.get(response.ordinal)?.get(call.id);
|
|
136
|
-
assert.ok(recorded, 'Every selected historical call has a recorded completion status');
|
|
137
|
-
assert.equal(recorded.statusCount, 1, 'Exact visible-payload replay requires one unambiguous completion status for each selected call occurrence');
|
|
138
|
-
recorded.output = message.content;
|
|
139
|
-
observations.set(call.id, recorded);
|
|
140
|
-
observationHash.update(JSON.stringify([call.id, message.content]) + '\n');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const names = new Set(selected.flatMap(response => response.toolCalls.map(call => call.name)));
|
|
144
|
-
const queues = new Map();
|
|
145
|
-
const keyFor = (name, args) => name + ':' + JSON.stringify(args);
|
|
146
|
-
for (const response of selected) for (const call of response.toolCalls) {
|
|
147
|
-
const args = JSON.parse(call.arguments);
|
|
148
|
-
const key = keyFor(call.name, args);
|
|
149
|
-
const queue = queues.get(key) ?? [];
|
|
150
|
-
queue.push(observations.get(call.id));
|
|
151
|
-
queues.set(key, queue);
|
|
152
|
-
}
|
|
153
|
-
let executed = 0, recordedFailures = 0;
|
|
154
|
-
const tools = [...names].map(name => {
|
|
155
|
-
const schema = schemas.get(name);
|
|
156
|
-
assert.ok(schema, 'Only actually advertised historical tools are replayed');
|
|
157
|
-
return { name, description: schema.description, parameters: schema.parameters, executionMode: schema.executionMode ?? 'sequential',
|
|
158
|
-
execute: async args => {
|
|
159
|
-
const recorded = queues.get(keyFor(name, args))?.shift();
|
|
160
|
-
assert.ok(recorded, 'Scripted tool arguments match the selected historical payload');
|
|
161
|
-
executed++;
|
|
162
|
-
if (recorded.failed) { recordedFailures++; throw new Error(recorded.output.replace(/^Tool error:\s*/, '')); }
|
|
163
|
-
return recorded.output;
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
let cursor = 0, mainRequests = 0, auxiliaryRequests = 0;
|
|
168
|
-
let mainMessageBytes = 0, auxiliaryMessageBytes = 0, replayedArgumentBytes = 0;
|
|
169
|
-
const events = [];
|
|
170
|
-
const failedIds = new Set();
|
|
171
|
-
const marker = 'OFFLINE_FIXTURE_CHECKPOINT';
|
|
172
|
-
const result = await new AndorraAgentEngine().execute({
|
|
173
|
-
task: firstRequest.messages.filter(message => message.role === 'user').map(message => message.content).join('\n'),
|
|
174
|
-
provider: 'offline', model: 'historical-payload-fixture', contextWindow: 128_000,
|
|
175
|
-
subagentId: 'offline-payload-fixture', tools,
|
|
176
|
-
limits: { maxIterations: count + 20, maxToolCalls: expectedCalls + 20, maxContextChars: 2_000_000 },
|
|
177
|
-
context: { workspace: root, signal: new AbortController().signal, yolo: true, approve: async () => { throw new Error('No real mutations or approvals occur in this fixture'); } },
|
|
178
|
-
onEvent: event => {
|
|
179
|
-
if (event.type === 'node.tool.failed') failedIds.add(event.data.toolCallId);
|
|
180
|
-
if (['agent.context.compacted', 'agent.context.microcompacted', 'agent.context.compaction.started', 'agent.session.completed'].includes(event.type)) events.push({ type: event.type, data: event.data });
|
|
181
|
-
},
|
|
182
|
-
adapter: { generate: async request => {
|
|
183
|
-
const bytes = Buffer.byteLength(JSON.stringify(request.messages));
|
|
184
|
-
if (!request.tools.length) {
|
|
185
|
-
auxiliaryRequests++;
|
|
186
|
-
auxiliaryMessageBytes += bytes;
|
|
187
|
-
// Constant fake summary isolates retirement/prefix mechanics. Its quality
|
|
188
|
-
// is neither a historical summary nor a measured model-generated result.
|
|
189
|
-
return { text: marker + ': Historical scripted prefix retired. Continue the fixed replay; task quality is not evaluated.', toolCalls: [] };
|
|
190
|
-
}
|
|
191
|
-
mainRequests++;
|
|
192
|
-
mainMessageBytes += bytes;
|
|
193
|
-
if (cursor > 0) for (const call of selected[cursor - 1].toolCalls) {
|
|
194
|
-
const message = request.messages.find(message => message.role === 'tool' && message.toolCallId === call.id);
|
|
195
|
-
assert.ok(message?.content === observations.get(call.id).output, 'Exact visible-payload replay failed: engine feedback differs from the recorded model observation');
|
|
196
|
-
}
|
|
197
|
-
for (const message of request.messages) for (const call of message.toolCalls ?? []) replayedArgumentBytes += Buffer.byteLength(call.arguments);
|
|
198
|
-
assert.ok(request.messages.some(message => message.role === 'user' && message.content.includes('Begin implementation now')), 'Original task stays pinned');
|
|
199
|
-
const callIds = request.messages.flatMap(message => message.toolCalls ?? []).map(call => call.id).sort();
|
|
200
|
-
assert.deepEqual(request.messages.filter(message => message.role === 'tool').map(message => message.toolCallId).sort(), callIds, 'Every tool call/result pair remains intact');
|
|
201
|
-
if (cursor === selected.length) return { text: JSON.stringify({ summary: 'Offline historical payload fixture completed; original task was not rerun.', tests: [] }), toolCalls: [] };
|
|
202
|
-
const response = selected[cursor++];
|
|
203
|
-
return { text: response.text ?? '', toolCalls: response.toolCalls.map(call => ({ ...call })) };
|
|
204
|
-
} },
|
|
205
|
-
});
|
|
206
|
-
assert.equal(result.status, 'succeeded', result.reason);
|
|
207
|
-
assert.equal(cursor, selected.length);
|
|
208
|
-
assert.equal(mainRequests, count + 1);
|
|
209
|
-
assert.ok([...queues.values()].flat().every(recorded => recorded.failed), 'Only historically invalid calls can be rejected before fake execution');
|
|
210
|
-
assert.deepEqual([...failedIds].sort(), selected.flatMap(response => response.toolCalls).filter(call => observations.get(call.id).failed).map(call => call.id).sort(), 'Recorded failures remain failures; the fixture does not conceal historical invalid calls');
|
|
211
|
-
process.stdout.write(JSON.stringify({
|
|
212
|
-
fixture: 'matched offline historical visible-payload replay; no provider-token or task-quality measurement',
|
|
213
|
-
sourceSha256: sourceHash.digest('hex'), sourceRunId: runId, sourceInvocationId: invocationId,
|
|
214
|
-
modelVisibleObservationSha256: observationHash.digest('hex'),
|
|
215
|
-
historicalRecordedUsage: { ...recordedUsage, totalTokens: recordedUsage.inputTokens + recordedUsage.outputTokens },
|
|
216
|
-
firstSelectedResponse: selected[0].time, lastSelectedResponse: selected.at(-1).time,
|
|
217
|
-
scriptedHistoricalResponses: count, scriptedHistoricalToolCalls: expectedCalls,
|
|
218
|
-
executedToolObservations: executed, hostRejectedBeforeFakeExecution: expectedCalls - executed, recordedToolFailures: recordedFailures,
|
|
219
|
-
status: result.status, mainRequests, auxiliaryRequests,
|
|
220
|
-
cumulativeMainMessageBytes: mainMessageBytes, cumulativeAuxiliaryMessageBytes: auxiliaryMessageBytes,
|
|
221
|
-
cumulativeToolArgumentReplayBytes: replayedArgumentBytes,
|
|
222
|
-
contextEvents: events.map(event => ({ type: event.type, ...Object.fromEntries(Object.entries(event.data).filter(([key]) => ['executor', 'removedExchanges', 'contextChars', 'reason', 'beforeTokens', 'afterTokens', 'threshold', 'observations', 'removedChars', 'batch'].includes(key))) })),
|
|
223
|
-
}, null, 2) + '\n');
|