@claude-flow/cli 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +175 -1
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/eject.d.ts +33 -0
- package/dist/src/commands/eject.d.ts.map +1 -0
- package/dist/src/commands/eject.js +195 -0
- package/dist/src/commands/eject.js.map +1 -0
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +2 -1
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +3 -0
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/metaharness.d.ts +39 -0
- package/dist/src/commands/metaharness.d.ts.map +1 -0
- package/dist/src/commands/metaharness.js +194 -0
- package/dist/src/commands/metaharness.js.map +1 -0
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +4 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +1 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/metaharness-tools.d.ts +31 -0
- package/dist/src/mcp-tools/metaharness-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/metaharness-tools.js +372 -0
- package/dist/src/mcp-tools/metaharness-tools.js.map +1 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -1
- package/dist/src/plugins/store/discovery.js +3 -0
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +6 -1
- package/dist/src/plugins/store/types.d.ts.map +1 -1
- package/dist/src/ruvector/model-router.d.ts.map +1 -1
- package/dist/src/ruvector/model-router.js +37 -0
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/router-parallel-recorder.d.ts +127 -0
- package/dist/src/ruvector/router-parallel-recorder.d.ts.map +1 -0
- package/dist/src/ruvector/router-parallel-recorder.js +183 -0
- package/dist/src/ruvector/router-parallel-recorder.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -9
- package/dist/src/benchmarks/capability-tasks.d.ts +0 -126
- package/dist/src/benchmarks/capability-tasks.d.ts.map +0 -1
- package/dist/src/benchmarks/capability-tasks.js +0 -147
- package/dist/src/benchmarks/capability-tasks.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-contrastive.d.ts +0 -53
- package/dist/src/benchmarks/gaia-agent-contrastive.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-contrastive.js +0 -177
- package/dist/src/benchmarks/gaia-agent-contrastive.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-gemini.d.ts +0 -51
- package/dist/src/benchmarks/gaia-agent-gemini.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-gemini.js +0 -352
- package/dist/src/benchmarks/gaia-agent-gemini.js.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.d.ts +0 -105
- package/dist/src/benchmarks/gaia-claude-p.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.js +0 -269
- package/dist/src/benchmarks/gaia-claude-p.js.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.smoke.d.ts +0 -20
- package/dist/src/benchmarks/gaia-claude-p.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.smoke.js +0 -168
- package/dist/src/benchmarks/gaia-claude-p.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent-runner.py +0 -556
- package/dist/src/benchmarks/gaia-codeagent.d.ts +0 -129
- package/dist/src/benchmarks/gaia-codeagent.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.js +0 -590
- package/dist/src/benchmarks/gaia-codeagent.js.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.smoke.d.ts +0 -33
- package/dist/src/benchmarks/gaia-codeagent.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.smoke.js +0 -241
- package/dist/src/benchmarks/gaia-codeagent.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag-pilot.d.ts +0 -22
- package/dist/src/benchmarks/gaia-dag-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag-pilot.js +0 -158
- package/dist/src/benchmarks/gaia-dag-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag.d.ts +0 -110
- package/dist/src/benchmarks/gaia-dag.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag.js +0 -658
- package/dist/src/benchmarks/gaia-dag.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag.smoke.d.ts +0 -21
- package/dist/src/benchmarks/gaia-dag.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag.smoke.js +0 -290
- package/dist/src/benchmarks/gaia-dag.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble-pilot.d.ts +0 -17
- package/dist/src/benchmarks/gaia-ensemble-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble-pilot.js +0 -106
- package/dist/src/benchmarks/gaia-ensemble-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble.d.ts +0 -103
- package/dist/src/benchmarks/gaia-ensemble.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble.js +0 -462
- package/dist/src/benchmarks/gaia-ensemble.js.map +0 -1
- package/dist/src/benchmarks/gaia-gemini-pilot.d.ts +0 -17
- package/dist/src/benchmarks/gaia-gemini-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-gemini-pilot.js +0 -168
- package/dist/src/benchmarks/gaia-gemini-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.d.ts +0 -67
- package/dist/src/benchmarks/gaia-mode-router.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.js +0 -126
- package/dist/src/benchmarks/gaia-mode-router.js.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.smoke.d.ts +0 -15
- package/dist/src/benchmarks/gaia-mode-router.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.smoke.js +0 -131
- package/dist/src/benchmarks/gaia-mode-router.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.js +0 -276
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.d.ts +0 -45
- package/dist/src/benchmarks/gaia-tools/image_describe.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.js +0 -222
- package/dist/src/benchmarks/gaia-tools/image_describe.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.js +0 -169
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/pdf_read.d.ts +0 -27
- package/dist/src/benchmarks/gaia-tools/pdf_read.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/pdf_read.js +0 -226
- package/dist/src/benchmarks/gaia-tools/pdf_read.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.d.ts +0 -31
- package/dist/src/benchmarks/gaia-tools/python_exec.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.js +0 -94
- package/dist/src/benchmarks/gaia-tools/python_exec.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.d.ts +0 -13
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.js +0 -98
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/visit_webpage.d.ts +0 -52
- package/dist/src/benchmarks/gaia-tools/visit_webpage.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/visit_webpage.js +0 -304
- package/dist/src/benchmarks/gaia-tools/visit_webpage.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.d.ts +0 -61
- package/dist/src/benchmarks/gaia-tools/web_browse.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.js +0 -217
- package/dist/src/benchmarks/gaia-tools/web_browse.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.d.ts +0 -26
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.js +0 -152
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.js +0 -311
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.d.ts +0 -25
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.js +0 -304
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.js.map +0 -1
- package/dist/src/commands/performance-capability.d.ts +0 -30
- package/dist/src/commands/performance-capability.d.ts.map +0 -1
- package/dist/src/commands/performance-capability.js +0 -349
- package/dist/src/commands/performance-capability.js.map +0 -1
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GAIA Claude-p Wrapper — iter 54 (#2156)
|
|
3
|
-
*
|
|
4
|
-
* Delegates each GAIA question to `claude -p` (Claude Code headless mode),
|
|
5
|
-
* which gives us WebSearch, WebFetch, Read (multimodal incl. PDF/DOCX/images),
|
|
6
|
-
* and Bash (Python execution) for free — the same tools HAL uses.
|
|
7
|
-
*
|
|
8
|
-
* Why this approach over a native TS CodeAgent:
|
|
9
|
-
* - HAL gaps vs ruflo were: visit_webpage, file reading (PDF/DOCX/XLSX/images),
|
|
10
|
-
* Python execution. Claude Code's built-in tools solve ALL of these.
|
|
11
|
-
* - No wheel-reinvention: battle-tested tool infra, native multimodal, proper
|
|
12
|
-
* tool-budget management, Anthropic WebSearch API.
|
|
13
|
-
* - Baseline: 24/53 (45.3%). Target: ≥45/53 to surpass HAL's 82.07%.
|
|
14
|
-
*
|
|
15
|
-
* SECURITY NOTE on --dangerously-skip-permissions:
|
|
16
|
-
* This flag is ONLY used inside the GAIA harness context, which is a sandboxed
|
|
17
|
-
* benchmark evaluation environment. GAIA questions have no real-world
|
|
18
|
-
* side effects — they are read-only research questions. The flag lets Claude Code
|
|
19
|
-
* use its tools (WebSearch, WebFetch, Read, Bash) without per-tool permission
|
|
20
|
-
* prompts, which is required for unattended benchmark execution. It MUST NOT
|
|
21
|
-
* be used in production workflows where Claude Code could affect real systems.
|
|
22
|
-
*
|
|
23
|
-
* JSON output format from `claude -p --output-format json`:
|
|
24
|
-
* {
|
|
25
|
-
* type: "result",
|
|
26
|
-
* subtype: "success" | "error_max_budget_usd" | ...,
|
|
27
|
-
* is_error: boolean,
|
|
28
|
-
* result: string, // final assistant message text
|
|
29
|
-
* total_cost_usd: number,
|
|
30
|
-
* duration_ms: number,
|
|
31
|
-
* num_turns: number,
|
|
32
|
-
* ...
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* Refs: ADR-138 (reference, NOT implemented), iter 54, #2156
|
|
36
|
-
*/
|
|
37
|
-
import { spawn } from 'node:child_process';
|
|
38
|
-
import * as path from 'node:path';
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
// Constants
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
/** Default model for claude -p GAIA runs. Sonnet for quality parity with HAL. */
|
|
43
|
-
export const CLAUDE_P_DEFAULT_MODEL = 'claude-sonnet-4-6';
|
|
44
|
-
/** Per-question budget cap (USD). HAL uses Sonnet 4.5 so $0.30 headroom is safe. */
|
|
45
|
-
export const CLAUDE_P_PER_QUESTION_BUDGET_USD = 0.30;
|
|
46
|
-
/** Subprocess timeout: 5 minutes per question. */
|
|
47
|
-
export const CLAUDE_P_TIMEOUT_MS = 5 * 60 * 1000;
|
|
48
|
-
/** FINAL_ANSWER extraction pattern — same as gaia-agent.ts. */
|
|
49
|
-
const FINAL_ANSWER_RE = /FINAL_ANSWER:\s*(.+?)(?:\n|$)/i;
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
// Prompt builder
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
/**
|
|
54
|
-
* Build the prompt sent to claude -p for a GAIA question.
|
|
55
|
-
*
|
|
56
|
-
* Includes the question text, optional attachment path, and precise instructions
|
|
57
|
-
* for using available tools and producing FINAL_ANSWER: in the expected format.
|
|
58
|
-
*/
|
|
59
|
-
export function buildClaudePPrompt(question) {
|
|
60
|
-
const attachmentBlock = question.file_path
|
|
61
|
-
? [
|
|
62
|
-
'',
|
|
63
|
-
`Attachment file path: ${path.resolve(question.file_path)}`,
|
|
64
|
-
'You can use the Read tool to view this file directly.',
|
|
65
|
-
'For images, audio, PDF, spreadsheets — use Read (it handles multimodal formats natively).',
|
|
66
|
-
].join('\n')
|
|
67
|
-
: '';
|
|
68
|
-
return [
|
|
69
|
-
'You are answering a question from the GAIA benchmark.',
|
|
70
|
-
'',
|
|
71
|
-
`Question: ${question.question}`,
|
|
72
|
-
attachmentBlock,
|
|
73
|
-
'',
|
|
74
|
-
'Instructions:',
|
|
75
|
-
'1. Find the answer using your available tools:',
|
|
76
|
-
' - WebSearch: for current facts, people, events, statistics',
|
|
77
|
-
' - WebFetch: for full page content when a snippet is insufficient',
|
|
78
|
-
' - Read: for file attachments (PDF, DOCX, XLSX, images, audio transcripts)',
|
|
79
|
-
' - Bash: for computation, data processing, Python scripts',
|
|
80
|
-
'2. Be precise. If a number is asked, give just the number.',
|
|
81
|
-
' If a name is asked, give just the name.',
|
|
82
|
-
'3. Output your final answer on the last line as exactly:',
|
|
83
|
-
' FINAL_ANSWER: <your-answer>',
|
|
84
|
-
'4. Do NOT use commas in numbers (write 50000 not 50,000) unless explicitly required.',
|
|
85
|
-
'5. Do NOT include units (write "5" not "5 km") unless the question explicitly asks for them.',
|
|
86
|
-
'6. If you genuinely cannot find the answer after exhausting your tools, write:',
|
|
87
|
-
' FINAL_ANSWER: unknown',
|
|
88
|
-
'',
|
|
89
|
-
'Find the answer and commit it with FINAL_ANSWER: on the last line.',
|
|
90
|
-
].join('\n');
|
|
91
|
-
}
|
|
92
|
-
// ---------------------------------------------------------------------------
|
|
93
|
-
// Core runner
|
|
94
|
-
// ---------------------------------------------------------------------------
|
|
95
|
-
/**
|
|
96
|
-
* Run a single GAIA question via `claude -p` headless mode.
|
|
97
|
-
*
|
|
98
|
-
* Spawns a subprocess, captures JSON output, extracts the final answer.
|
|
99
|
-
*/
|
|
100
|
-
export async function runGaiaQuestionViaClaudeP(question, options = {}) {
|
|
101
|
-
const model = options.model ?? CLAUDE_P_DEFAULT_MODEL;
|
|
102
|
-
const budgetUsd = options.budgetUsd ?? CLAUDE_P_PER_QUESTION_BUDGET_USD;
|
|
103
|
-
const timeoutMs = options.timeoutMs ?? CLAUDE_P_TIMEOUT_MS;
|
|
104
|
-
const claudeBin = options.claudeBin ?? '/Users/cohen/.local/bin/claude';
|
|
105
|
-
const prompt = buildClaudePPrompt(question);
|
|
106
|
-
// Build claude -p arguments.
|
|
107
|
-
// --dangerously-skip-permissions: acceptable here because GAIA is a read-only
|
|
108
|
-
// sandboxed benchmark context with no real-world side effects. See module-level
|
|
109
|
-
// security note above.
|
|
110
|
-
const args = [
|
|
111
|
-
'-p',
|
|
112
|
-
prompt,
|
|
113
|
-
'--model', model,
|
|
114
|
-
'--max-budget-usd', String(budgetUsd),
|
|
115
|
-
'--output-format', 'json',
|
|
116
|
-
'--dangerously-skip-permissions',
|
|
117
|
-
];
|
|
118
|
-
const startMs = Date.now();
|
|
119
|
-
return new Promise((resolve) => {
|
|
120
|
-
let stdout = '';
|
|
121
|
-
let stderr = '';
|
|
122
|
-
let settled = false;
|
|
123
|
-
const child = spawn(claudeBin, args, {
|
|
124
|
-
env: { ...process.env },
|
|
125
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
126
|
-
});
|
|
127
|
-
child.stdout.on('data', (chunk) => {
|
|
128
|
-
stdout += chunk.toString('utf-8');
|
|
129
|
-
});
|
|
130
|
-
child.stderr.on('data', (chunk) => {
|
|
131
|
-
stderr += chunk.toString('utf-8');
|
|
132
|
-
});
|
|
133
|
-
const timer = setTimeout(() => {
|
|
134
|
-
if (!settled) {
|
|
135
|
-
settled = true;
|
|
136
|
-
child.kill('SIGTERM');
|
|
137
|
-
resolve({
|
|
138
|
-
finalAnswer: null,
|
|
139
|
-
rawResult: '',
|
|
140
|
-
isError: true,
|
|
141
|
-
errorMessage: `Timed out after ${timeoutMs}ms`,
|
|
142
|
-
costUsd: 0,
|
|
143
|
-
wallMs: Date.now() - startMs,
|
|
144
|
-
numTurns: 0,
|
|
145
|
-
stopReason: 'timeout',
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}, timeoutMs);
|
|
149
|
-
child.on('close', (code) => {
|
|
150
|
-
if (settled)
|
|
151
|
-
return;
|
|
152
|
-
settled = true;
|
|
153
|
-
clearTimeout(timer);
|
|
154
|
-
const wallMs = Date.now() - startMs;
|
|
155
|
-
// Parse JSON output from claude -p
|
|
156
|
-
const parsed = parseClaudePOutput(stdout, stderr, code ?? 1);
|
|
157
|
-
resolve({ ...parsed, wallMs });
|
|
158
|
-
});
|
|
159
|
-
child.on('error', (err) => {
|
|
160
|
-
if (settled)
|
|
161
|
-
return;
|
|
162
|
-
settled = true;
|
|
163
|
-
clearTimeout(timer);
|
|
164
|
-
resolve({
|
|
165
|
-
finalAnswer: null,
|
|
166
|
-
rawResult: '',
|
|
167
|
-
isError: true,
|
|
168
|
-
errorMessage: `Failed to spawn claude: ${err.message}`,
|
|
169
|
-
costUsd: 0,
|
|
170
|
-
wallMs: Date.now() - startMs,
|
|
171
|
-
numTurns: 0,
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function parseClaudePOutput(stdout, stderr, exitCode) {
|
|
177
|
-
const raw = stdout.trim();
|
|
178
|
-
// Attempt JSON parse
|
|
179
|
-
let parsed = null;
|
|
180
|
-
try {
|
|
181
|
-
parsed = JSON.parse(raw);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
// JSON parse failed — treat as error
|
|
185
|
-
return {
|
|
186
|
-
finalAnswer: null,
|
|
187
|
-
rawResult: raw || stderr.trim(),
|
|
188
|
-
isError: true,
|
|
189
|
-
errorMessage: `JSON parse failed (exitCode=${exitCode}): ${(raw || stderr).slice(0, 200)}`,
|
|
190
|
-
costUsd: 0,
|
|
191
|
-
numTurns: 0,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
const isError = parsed.is_error === true || exitCode !== 0;
|
|
195
|
-
const resultText = parsed.result ?? '';
|
|
196
|
-
const costUsd = parsed.total_cost_usd ?? 0;
|
|
197
|
-
const numTurns = parsed.num_turns ?? 0;
|
|
198
|
-
const stopReason = parsed.subtype ?? parsed.stop_reason ?? undefined;
|
|
199
|
-
if (isError) {
|
|
200
|
-
const errMsg = (parsed.errors ?? []).join('; ') || `subtype=${parsed.subtype}`;
|
|
201
|
-
return {
|
|
202
|
-
finalAnswer: null,
|
|
203
|
-
rawResult: resultText,
|
|
204
|
-
isError: true,
|
|
205
|
-
errorMessage: errMsg,
|
|
206
|
-
costUsd,
|
|
207
|
-
numTurns,
|
|
208
|
-
stopReason,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
// Extract FINAL_ANSWER from result text
|
|
212
|
-
const finalAnswer = extractFinalAnswer(resultText);
|
|
213
|
-
return {
|
|
214
|
-
finalAnswer,
|
|
215
|
-
rawResult: resultText,
|
|
216
|
-
isError: false,
|
|
217
|
-
costUsd,
|
|
218
|
-
numTurns,
|
|
219
|
-
stopReason,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
// ---------------------------------------------------------------------------
|
|
223
|
-
// Answer extraction
|
|
224
|
-
// ---------------------------------------------------------------------------
|
|
225
|
-
/**
|
|
226
|
-
* Extract the FINAL_ANSWER value from claude -p's result text.
|
|
227
|
-
*
|
|
228
|
-
* Primary: regex match on `FINAL_ANSWER: <value>`
|
|
229
|
-
* Fallback: last non-empty line if no FINAL_ANSWER marker found.
|
|
230
|
-
*/
|
|
231
|
-
export function extractFinalAnswer(text) {
|
|
232
|
-
if (!text || !text.trim())
|
|
233
|
-
return null;
|
|
234
|
-
// Primary: FINAL_ANSWER: pattern
|
|
235
|
-
const match = FINAL_ANSWER_RE.exec(text);
|
|
236
|
-
if (match && match[1]) {
|
|
237
|
-
return match[1].trim();
|
|
238
|
-
}
|
|
239
|
-
// Fallback: last meaningful line (heuristic)
|
|
240
|
-
const lines = text.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
241
|
-
const lastLine = lines[lines.length - 1];
|
|
242
|
-
if (lastLine && lastLine.length < 200) {
|
|
243
|
-
return lastLine;
|
|
244
|
-
}
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Run a batch of GAIA questions through the claude -p wrapper.
|
|
249
|
-
*
|
|
250
|
-
* Concurrency is limited (default 2) because each claude -p subprocess
|
|
251
|
-
* is heavyweight — it starts a full Claude Code session with LSP etc.
|
|
252
|
-
*/
|
|
253
|
-
export async function runGaiaQuestionsBatchViaClaudeP(questions, options = {}) {
|
|
254
|
-
const concurrency = options.concurrency ?? 2;
|
|
255
|
-
const results = new Array(questions.length);
|
|
256
|
-
for (let i = 0; i < questions.length; i += concurrency) {
|
|
257
|
-
const batch = questions.slice(i, Math.min(i + concurrency, questions.length));
|
|
258
|
-
const batchResults = await Promise.all(batch.map((q, batchIdx) => runGaiaQuestionViaClaudeP(q, options).then((r) => {
|
|
259
|
-
const globalIdx = i + batchIdx;
|
|
260
|
-
options.onProgress?.(globalIdx + 1, questions.length, q.task_id, r.finalAnswer, r.costUsd);
|
|
261
|
-
return r;
|
|
262
|
-
})));
|
|
263
|
-
for (let j = 0; j < batchResults.length; j++) {
|
|
264
|
-
results[i + j] = batchResults[j];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return results;
|
|
268
|
-
}
|
|
269
|
-
//# sourceMappingURL=gaia-claude-p.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gaia-claude-p.js","sourceRoot":"","sources":["../../../src/benchmarks/gaia-claude-p.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D,oFAAoF;AACpF,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;AAErD,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjD,+DAA+D;AAC/D,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAoCzD,8EAA8E;AAC9E,iBAAiB;AACjB,8E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C,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9E,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CACxB,yBAAyB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAC/C,MAAM,SAAS,GAAG,CAAC,GAAG,QAAQ,CAAC;YAC/B,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YAC3F,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CACH,CACF,CAAC;QACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smoke tests for gaia-claude-p.ts — iter 54 (#2156)
|
|
3
|
-
*
|
|
4
|
-
* Three minimal cases to verify the claude -p wrapper end-to-end:
|
|
5
|
-
* 1. Simple arithmetic: "what is 2+2" → expect "4"
|
|
6
|
-
* 2. Current fact: population of Tokyo → expect a large number
|
|
7
|
-
* 3. (Optional) Attachment path test — only runs when HF cache has a file
|
|
8
|
-
*
|
|
9
|
-
* Cost cap: ~$0.25 × 3 = $0.75 worst case at Sonnet rates, but using Haiku
|
|
10
|
-
* for smoke to keep it under $0.30 total.
|
|
11
|
-
*
|
|
12
|
-
* Run:
|
|
13
|
-
* npx ts-node src/benchmarks/gaia-claude-p.smoke.ts
|
|
14
|
-
* # or after build:
|
|
15
|
-
* node dist/src/benchmarks/gaia-claude-p.smoke.js
|
|
16
|
-
*
|
|
17
|
-
* Refs: iter 54, #2156
|
|
18
|
-
*/
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=gaia-claude-p.smoke.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gaia-claude-p.smoke.d.ts","sourceRoot":"","sources":["../../../src/benchmarks/gaia-claude-p.smoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smoke tests for gaia-claude-p.ts — iter 54 (#2156)
|
|
3
|
-
*
|
|
4
|
-
* Three minimal cases to verify the claude -p wrapper end-to-end:
|
|
5
|
-
* 1. Simple arithmetic: "what is 2+2" → expect "4"
|
|
6
|
-
* 2. Current fact: population of Tokyo → expect a large number
|
|
7
|
-
* 3. (Optional) Attachment path test — only runs when HF cache has a file
|
|
8
|
-
*
|
|
9
|
-
* Cost cap: ~$0.25 × 3 = $0.75 worst case at Sonnet rates, but using Haiku
|
|
10
|
-
* for smoke to keep it under $0.30 total.
|
|
11
|
-
*
|
|
12
|
-
* Run:
|
|
13
|
-
* npx ts-node src/benchmarks/gaia-claude-p.smoke.ts
|
|
14
|
-
* # or after build:
|
|
15
|
-
* node dist/src/benchmarks/gaia-claude-p.smoke.js
|
|
16
|
-
*
|
|
17
|
-
* Refs: iter 54, #2156
|
|
18
|
-
*/
|
|
19
|
-
import { runGaiaQuestionViaClaudeP, extractFinalAnswer, buildClaudePPrompt, CLAUDE_P_DEFAULT_MODEL, } from './gaia-claude-p.js';
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// Test helpers
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
let passed = 0;
|
|
24
|
-
let failed = 0;
|
|
25
|
-
function assert(condition, label, detail) {
|
|
26
|
-
if (condition) {
|
|
27
|
-
console.log(` PASS ${label}`);
|
|
28
|
-
passed++;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
console.error(` FAIL ${label}${detail ? ': ' + detail : ''}`);
|
|
32
|
-
failed++;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
// Unit tests (no claude -p invocation)
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
function testExtractFinalAnswer() {
|
|
39
|
-
console.log('\n-- Unit: extractFinalAnswer --');
|
|
40
|
-
assert(extractFinalAnswer('FINAL_ANSWER: 4') === '4', 'extracts plain number');
|
|
41
|
-
assert(extractFinalAnswer('Some reasoning...\nFINAL_ANSWER: Paris') === 'Paris', 'extracts after reasoning text');
|
|
42
|
-
assert(extractFinalAnswer('final_answer: 42') === '42', 'case-insensitive extraction');
|
|
43
|
-
assert(extractFinalAnswer('') === null, 'returns null for empty string');
|
|
44
|
-
assert(extractFinalAnswer('No answer marker here') !== null, 'fallback to last line when no marker');
|
|
45
|
-
}
|
|
46
|
-
function testBuildClaudePPrompt() {
|
|
47
|
-
console.log('\n-- Unit: buildClaudePPrompt --');
|
|
48
|
-
const q = {
|
|
49
|
-
task_id: 'test-001',
|
|
50
|
-
level: 1,
|
|
51
|
-
question: 'What is 2+2?',
|
|
52
|
-
final_answer: '4',
|
|
53
|
-
file_name: null,
|
|
54
|
-
file_path: null,
|
|
55
|
-
};
|
|
56
|
-
const prompt = buildClaudePPrompt(q);
|
|
57
|
-
assert(prompt.includes('What is 2+2?'), 'prompt contains question text');
|
|
58
|
-
assert(prompt.includes('FINAL_ANSWER:'), 'prompt instructs FINAL_ANSWER format');
|
|
59
|
-
assert(!prompt.includes('Attachment'), 'no attachment section for null file_path');
|
|
60
|
-
const qWithFile = { ...q, file_path: '/tmp/test.pdf' };
|
|
61
|
-
const promptWithFile = buildClaudePPrompt(qWithFile);
|
|
62
|
-
assert(promptWithFile.includes('/tmp/test.pdf'), 'attachment path included when present');
|
|
63
|
-
assert(promptWithFile.includes('Read tool'), 'mentions Read tool for attachments');
|
|
64
|
-
}
|
|
65
|
-
// ---------------------------------------------------------------------------
|
|
66
|
-
// Integration tests (invoke claude -p)
|
|
67
|
-
// ---------------------------------------------------------------------------
|
|
68
|
-
async function testArithmetic() {
|
|
69
|
-
console.log('\n-- Integration: arithmetic (2+2) --');
|
|
70
|
-
const q = {
|
|
71
|
-
task_id: 'smoke-arithmetic',
|
|
72
|
-
level: 1,
|
|
73
|
-
question: 'What is 2 + 2? Provide only the numeric answer.',
|
|
74
|
-
final_answer: '4',
|
|
75
|
-
file_name: null,
|
|
76
|
-
file_path: null,
|
|
77
|
-
};
|
|
78
|
-
console.log(' Spawning claude -p ...');
|
|
79
|
-
const result = await runGaiaQuestionViaClaudeP(q, {
|
|
80
|
-
model: 'claude-haiku-4-5',
|
|
81
|
-
budgetUsd: 0.25,
|
|
82
|
-
timeoutMs: 120_000,
|
|
83
|
-
});
|
|
84
|
-
console.log(` raw result: ${result.rawResult.slice(0, 100)}`);
|
|
85
|
-
console.log(` finalAnswer: ${result.finalAnswer}`);
|
|
86
|
-
console.log(` costUsd: $${result.costUsd.toFixed(4)}`);
|
|
87
|
-
console.log(` numTurns: ${result.numTurns}`);
|
|
88
|
-
console.log(` isError: ${result.isError}`);
|
|
89
|
-
assert(!result.isError, 'no error', result.errorMessage);
|
|
90
|
-
assert(result.finalAnswer !== null, 'finalAnswer is not null');
|
|
91
|
-
assert(result.finalAnswer === '4', `answer is "4"`, `got: "${result.finalAnswer}"`);
|
|
92
|
-
assert(result.costUsd > 0, 'cost is positive');
|
|
93
|
-
assert(result.wallMs > 0, 'wallMs is positive');
|
|
94
|
-
}
|
|
95
|
-
async function testCurrentFact() {
|
|
96
|
-
console.log('\n-- Integration: current fact (Tokyo population) --');
|
|
97
|
-
const q = {
|
|
98
|
-
task_id: 'smoke-tokyo-pop',
|
|
99
|
-
level: 1,
|
|
100
|
-
question: 'What is the approximate population of Tokyo (the city proper)? Give only a number in millions, rounded to the nearest million.',
|
|
101
|
-
final_answer: '14',
|
|
102
|
-
file_name: null,
|
|
103
|
-
file_path: null,
|
|
104
|
-
};
|
|
105
|
-
console.log(' Spawning claude -p ...');
|
|
106
|
-
const result = await runGaiaQuestionViaClaudeP(q, {
|
|
107
|
-
model: 'claude-haiku-4-5',
|
|
108
|
-
budgetUsd: 0.25,
|
|
109
|
-
timeoutMs: 120_000,
|
|
110
|
-
});
|
|
111
|
-
console.log(` raw result excerpt: ${result.rawResult.slice(0, 150)}`);
|
|
112
|
-
console.log(` finalAnswer: ${result.finalAnswer}`);
|
|
113
|
-
console.log(` costUsd: $${result.costUsd.toFixed(4)}`);
|
|
114
|
-
assert(!result.isError, 'no error', result.errorMessage);
|
|
115
|
-
assert(result.finalAnswer !== null, 'finalAnswer is not null');
|
|
116
|
-
// Tokyo metro area is ~37M, city proper is ~13-14M — any multi-digit number is reasonable
|
|
117
|
-
const numAnswer = result.finalAnswer ? parseFloat(result.finalAnswer.replace(/[^0-9.]/g, '')) : NaN;
|
|
118
|
-
assert(!isNaN(numAnswer) && numAnswer > 0, 'answer is a non-empty number', `got: "${result.finalAnswer}"`);
|
|
119
|
-
}
|
|
120
|
-
async function testAnswerFormat() {
|
|
121
|
-
console.log('\n-- Integration: answer format discipline --');
|
|
122
|
-
const q = {
|
|
123
|
-
task_id: 'smoke-format',
|
|
124
|
-
level: 1,
|
|
125
|
-
question: 'What is the capital of France? Give only the city name, nothing else.',
|
|
126
|
-
final_answer: 'Paris',
|
|
127
|
-
file_name: null,
|
|
128
|
-
file_path: null,
|
|
129
|
-
};
|
|
130
|
-
console.log(' Spawning claude -p ...');
|
|
131
|
-
const result = await runGaiaQuestionViaClaudeP(q, {
|
|
132
|
-
model: 'claude-haiku-4-5',
|
|
133
|
-
budgetUsd: 0.25,
|
|
134
|
-
timeoutMs: 120_000,
|
|
135
|
-
});
|
|
136
|
-
console.log(` raw result excerpt: ${result.rawResult.slice(0, 150)}`);
|
|
137
|
-
console.log(` finalAnswer: ${result.finalAnswer}`);
|
|
138
|
-
console.log(` costUsd: $${result.costUsd.toFixed(4)}`);
|
|
139
|
-
assert(!result.isError, 'no error', result.errorMessage);
|
|
140
|
-
assert(result.finalAnswer !== null, 'finalAnswer is not null');
|
|
141
|
-
assert(result.finalAnswer !== null && result.finalAnswer.toLowerCase().includes('paris'), 'answer contains "paris"', `got: "${result.finalAnswer}"`);
|
|
142
|
-
}
|
|
143
|
-
// ---------------------------------------------------------------------------
|
|
144
|
-
// Main
|
|
145
|
-
// ---------------------------------------------------------------------------
|
|
146
|
-
async function main() {
|
|
147
|
-
console.log('=== gaia-claude-p smoke tests ===');
|
|
148
|
-
console.log(`Model: claude-haiku-4-5 (smoke uses Haiku to minimize cost)`);
|
|
149
|
-
console.log(`Default production model: ${CLAUDE_P_DEFAULT_MODEL}`);
|
|
150
|
-
// Unit tests (no API calls)
|
|
151
|
-
testExtractFinalAnswer();
|
|
152
|
-
testBuildClaudePPrompt();
|
|
153
|
-
// Integration tests (invoke claude -p)
|
|
154
|
-
await testArithmetic();
|
|
155
|
-
await testCurrentFact();
|
|
156
|
-
await testAnswerFormat();
|
|
157
|
-
// Summary
|
|
158
|
-
const total = passed + failed;
|
|
159
|
-
console.log(`\n=== Results: ${passed}/${total} passed ===`);
|
|
160
|
-
if (failed > 0) {
|
|
161
|
-
process.exit(1);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
main().catch((err) => {
|
|
165
|
-
console.error('Smoke test runner error:', err);
|
|
166
|
-
process.exit(1);
|
|
167
|
-
});
|
|
168
|
-
//# sourceMappingURL=gaia-claude-p.smoke.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gaia-claude-p.smoke.js","sourceRoot":"","sources":["../../../src/benchmarks/gaia-claude-p.smoke.ts"],"names":[],"mappings":"AAAA;;;;;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