@vercel/agent-eval 0.0.6 → 0.0.9
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 +26 -2
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/lib/agents/ai-sdk-agent.d.ts +10 -0
- package/dist/lib/agents/ai-sdk-agent.d.ts.map +1 -0
- package/dist/lib/agents/ai-sdk-agent.js +427 -0
- package/dist/lib/agents/ai-sdk-agent.js.map +1 -0
- package/dist/lib/agents/codex.d.ts.map +1 -1
- package/dist/lib/agents/codex.js +13 -25
- package/dist/lib/agents/codex.js.map +1 -1
- package/dist/lib/agents/index.d.ts.map +1 -1
- package/dist/lib/agents/index.js +2 -0
- package/dist/lib/agents/index.js.map +1 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/init.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,6 +208,7 @@ Choose your agent and authentication method:
|
|
|
208
208
|
agent: 'vercel-ai-gateway/claude-code' // Claude Code via AI Gateway
|
|
209
209
|
agent: 'vercel-ai-gateway/codex' // OpenAI Codex via AI Gateway
|
|
210
210
|
agent: 'vercel-ai-gateway/opencode' // OpenCode via AI Gateway
|
|
211
|
+
agent: 'vercel-ai-gateway/ai-sdk-harness' // Simple AI SDK harness (any model)
|
|
211
212
|
|
|
212
213
|
// Direct API (uses provider keys directly)
|
|
213
214
|
agent: 'claude-code' // requires ANTHROPIC_API_KEY
|
|
@@ -261,6 +262,28 @@ Under the hood, the agent creates an `opencode.json` config file that configures
|
|
|
261
262
|
|
|
262
263
|
And runs: `opencode run "<prompt>" --model {provider}/{model} --format json`
|
|
263
264
|
|
|
265
|
+
### AI SDK Harness Model Configuration
|
|
266
|
+
|
|
267
|
+
The AI SDK harness (`vercel-ai-gateway/ai-sdk-harness`) is a lightweight agent that works with **any model** available on Vercel AI Gateway. Unlike OpenCode, it uses the standard `{provider}/{model}` format without a `vercel/` prefix:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// Anthropic models
|
|
271
|
+
model: 'anthropic/claude-sonnet-4'
|
|
272
|
+
model: 'anthropic/claude-opus-4'
|
|
273
|
+
|
|
274
|
+
// Moonshot AI (Kimi) models
|
|
275
|
+
model: 'moonshotai/kimi-k2.5'
|
|
276
|
+
model: 'moonshotai/kimi-k2-thinking'
|
|
277
|
+
|
|
278
|
+
// Minimax models
|
|
279
|
+
model: 'minimax/minimax-m2.1'
|
|
280
|
+
|
|
281
|
+
// OpenAI models
|
|
282
|
+
model: 'openai/gpt-4o'
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
The AI SDK harness includes these tools: `readFile`, `writeFile`, `editFile`, `listFiles`, `glob`, `grep`, and `bash`. It's ideal for evaluating models that may not be fully compatible with OpenCode.
|
|
286
|
+
|
|
264
287
|
### Full Configuration
|
|
265
288
|
|
|
266
289
|
```typescript
|
|
@@ -274,6 +297,7 @@ const config: ExperimentConfig = {
|
|
|
274
297
|
// - claude-code: 'opus'
|
|
275
298
|
// - codex: 'openai/gpt-5.2-codex'
|
|
276
299
|
// - opencode: 'vercel/anthropic/claude-sonnet-4' (note: vercel/ prefix required)
|
|
300
|
+
// - ai-sdk-harness: 'anthropic/claude-sonnet-4' (works with any AI Gateway model)
|
|
277
301
|
model: 'opus',
|
|
278
302
|
|
|
279
303
|
// How many times to run each eval
|
|
@@ -285,8 +309,8 @@ const config: ExperimentConfig = {
|
|
|
285
309
|
// npm scripts that must pass after agent finishes
|
|
286
310
|
scripts: ['build', 'lint'],
|
|
287
311
|
|
|
288
|
-
// Timeout per run in seconds
|
|
289
|
-
timeout:
|
|
312
|
+
// Timeout per run in seconds (default: 600)
|
|
313
|
+
timeout: 600,
|
|
290
314
|
|
|
291
315
|
// Filter which evals to run (pick one)
|
|
292
316
|
evals: '*', // all (default)
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import { config as dotenvConfig } from 'dotenv';
|
|
7
7
|
import { resolve, dirname, basename } from 'path';
|
|
8
|
-
import { existsSync } from 'fs';
|
|
8
|
+
import { existsSync, readFileSync } from 'fs';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
9
10
|
import chalk from 'chalk';
|
|
10
11
|
import { loadConfig, resolveEvalNames } from './lib/config.js';
|
|
11
12
|
import { loadAllFixtures } from './lib/fixture.js';
|
|
@@ -13,13 +14,17 @@ import { runExperiment } from './lib/runner.js';
|
|
|
13
14
|
import { initProject, getPostInitInstructions } from './lib/init.js';
|
|
14
15
|
import { getAgent } from './lib/agents/index.js';
|
|
15
16
|
import { getSandboxBackendInfo } from './lib/sandbox.js';
|
|
16
|
-
// Load environment variables
|
|
17
|
+
// Load environment variables (.env.local first, then .env as fallback)
|
|
18
|
+
dotenvConfig({ path: '.env.local' });
|
|
17
19
|
dotenvConfig();
|
|
20
|
+
// Read version from package.json
|
|
21
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const pkg = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8'));
|
|
18
23
|
const program = new Command();
|
|
19
24
|
program
|
|
20
25
|
.name('agent-eval')
|
|
21
26
|
.description('Framework for testing AI coding agents in isolated sandboxes')
|
|
22
|
-
.version(
|
|
27
|
+
.version(pkg.version);
|
|
23
28
|
/**
|
|
24
29
|
* Resolve config path shorthand.
|
|
25
30
|
* - "cc" -> "experiments/cc.ts"
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MA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AAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL;;;GAGG;AACH,OAAO;KACJ,QAAQ,CAAC,UAAU,EAAE,sCAAsC,CAAC;KAC5D,MAAM,CAAC,OAAO,EAAE,0CAA0C,CAAC;KAC3D,MAAM,CAAC,KAAK,EAAE,WAA+B,EAAE,OAA0B,EAAE,EAAE;IAC5E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,MAAM,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Agent - A simple coding agent using the Vercel AI SDK.
|
|
3
|
+
* Works with any model available on Vercel AI Gateway.
|
|
4
|
+
*/
|
|
5
|
+
import type { Agent } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create AI SDK agent with Vercel AI Gateway authentication.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAiSdkAgent(): Agent;
|
|
10
|
+
//# sourceMappingURL=ai-sdk-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk-agent.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/ai-sdk-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,YAAY,CAAC;AA8QzE;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,KAAK,CAiMxC"}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Agent - A simple coding agent using the Vercel AI SDK.
|
|
3
|
+
* Works with any model available on Vercel AI Gateway.
|
|
4
|
+
*/
|
|
5
|
+
import { createSandbox, collectLocalFiles, splitTestFiles, verifyNoTestFiles, } from '../sandbox.js';
|
|
6
|
+
import { runValidation, captureGeneratedFiles, createVitestConfig, AI_GATEWAY, } from './shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* The CLI script source code that runs inside the sandbox.
|
|
9
|
+
* This is a self-contained script that uses the AI SDK.
|
|
10
|
+
*/
|
|
11
|
+
const CLI_SCRIPT = `
|
|
12
|
+
import { generateText, tool, stepCountIs } from 'ai';
|
|
13
|
+
import { createGateway } from '@ai-sdk/gateway';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { readFileSync, writeFileSync, readdirSync, existsSync, statSync } from 'fs';
|
|
16
|
+
import { execSync } from 'child_process';
|
|
17
|
+
import { join, dirname } from 'path';
|
|
18
|
+
import { mkdirSync } from 'fs';
|
|
19
|
+
|
|
20
|
+
// Parse command line arguments
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
let prompt = '';
|
|
23
|
+
let model = '';
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < args.length; i++) {
|
|
26
|
+
if (args[i] === '--prompt' && args[i + 1]) {
|
|
27
|
+
prompt = args[++i];
|
|
28
|
+
} else if (args[i] === '--model' && args[i + 1]) {
|
|
29
|
+
model = args[++i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!prompt || !model) {
|
|
34
|
+
console.error('Usage: ai-sdk-agent --prompt "..." --model "provider/model"');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Create AI Gateway client
|
|
39
|
+
const gateway = createGateway({
|
|
40
|
+
apiKey: process.env.AI_GATEWAY_API_KEY,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Transcript events
|
|
44
|
+
const events = [];
|
|
45
|
+
|
|
46
|
+
function logEvent(type, data) {
|
|
47
|
+
const event = { type, timestamp: Date.now(), ...data };
|
|
48
|
+
events.push(event);
|
|
49
|
+
console.log(JSON.stringify(event));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Define coding tools
|
|
53
|
+
const tools = {
|
|
54
|
+
readFile: tool({
|
|
55
|
+
description: 'Read the contents of a file at the given path',
|
|
56
|
+
inputSchema: z.object({
|
|
57
|
+
path: z.string().describe('The file path to read'),
|
|
58
|
+
}),
|
|
59
|
+
execute: async ({ path }) => {
|
|
60
|
+
try {
|
|
61
|
+
const content = readFileSync(path, 'utf-8');
|
|
62
|
+
logEvent('tool_result', { tool: 'readFile', path, success: true });
|
|
63
|
+
return content;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
logEvent('tool_result', { tool: 'readFile', path, success: false, error: error.message });
|
|
66
|
+
return \`Error reading file: \${error.message}\`;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
|
|
71
|
+
writeFile: tool({
|
|
72
|
+
description: 'Write content to a file at the given path. Creates directories if needed.',
|
|
73
|
+
inputSchema: z.object({
|
|
74
|
+
path: z.string().describe('The file path to write'),
|
|
75
|
+
content: z.string().describe('The content to write'),
|
|
76
|
+
}),
|
|
77
|
+
execute: async ({ path, content }) => {
|
|
78
|
+
try {
|
|
79
|
+
const dir = dirname(path);
|
|
80
|
+
if (dir && dir !== '.') {
|
|
81
|
+
mkdirSync(dir, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
writeFileSync(path, content);
|
|
84
|
+
logEvent('tool_result', { tool: 'writeFile', path, success: true });
|
|
85
|
+
return 'File written successfully';
|
|
86
|
+
} catch (error) {
|
|
87
|
+
logEvent('tool_result', { tool: 'writeFile', path, success: false, error: error.message });
|
|
88
|
+
return \`Error writing file: \${error.message}\`;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
|
|
93
|
+
editFile: tool({
|
|
94
|
+
description: 'Edit a file by replacing a specific string with new content',
|
|
95
|
+
inputSchema: z.object({
|
|
96
|
+
path: z.string().describe('The file path to edit'),
|
|
97
|
+
oldString: z.string().describe('The exact string to find and replace'),
|
|
98
|
+
newString: z.string().describe('The replacement string'),
|
|
99
|
+
}),
|
|
100
|
+
execute: async ({ path, oldString, newString }) => {
|
|
101
|
+
try {
|
|
102
|
+
const content = readFileSync(path, 'utf-8');
|
|
103
|
+
if (!content.includes(oldString)) {
|
|
104
|
+
logEvent('tool_result', { tool: 'editFile', path, success: false, error: 'String not found' });
|
|
105
|
+
return 'Error: The specified string was not found in the file';
|
|
106
|
+
}
|
|
107
|
+
const newContent = content.replace(oldString, newString);
|
|
108
|
+
writeFileSync(path, newContent);
|
|
109
|
+
logEvent('tool_result', { tool: 'editFile', path, success: true });
|
|
110
|
+
return 'File edited successfully';
|
|
111
|
+
} catch (error) {
|
|
112
|
+
logEvent('tool_result', { tool: 'editFile', path, success: false, error: error.message });
|
|
113
|
+
return \`Error editing file: \${error.message}\`;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
|
|
118
|
+
listFiles: tool({
|
|
119
|
+
description: 'List files in a directory. Call with path="." to list current directory.',
|
|
120
|
+
inputSchema: z.object({
|
|
121
|
+
path: z.string().describe('The directory path to list (use "." for current directory)'),
|
|
122
|
+
recursive: z.boolean().describe('Whether to list recursively').optional(),
|
|
123
|
+
}),
|
|
124
|
+
execute: async ({ path, recursive }) => {
|
|
125
|
+
const targetPath = path || '.';
|
|
126
|
+
const isRecursive = recursive || false;
|
|
127
|
+
try {
|
|
128
|
+
if (isRecursive) {
|
|
129
|
+
const result = execSync(\`find \${targetPath} -type f | head -100\`, { encoding: 'utf-8' });
|
|
130
|
+
logEvent('tool_result', { tool: 'listFiles', path: targetPath, recursive: isRecursive, success: true });
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
const files = readdirSync(targetPath);
|
|
134
|
+
logEvent('tool_result', { tool: 'listFiles', path: targetPath, recursive: isRecursive, success: true });
|
|
135
|
+
return files.join('\\n');
|
|
136
|
+
} catch (error) {
|
|
137
|
+
logEvent('tool_result', { tool: 'listFiles', path: targetPath, success: false, error: error.message });
|
|
138
|
+
return \`Error listing files: \${error.message}\`;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
|
|
143
|
+
glob: tool({
|
|
144
|
+
description: 'Find files matching a pattern (e.g., "*.ts" for TypeScript files)',
|
|
145
|
+
inputSchema: z.object({
|
|
146
|
+
pattern: z.string().describe('The file pattern (e.g., "*.ts", "*.js")'),
|
|
147
|
+
}),
|
|
148
|
+
execute: async ({ pattern }) => {
|
|
149
|
+
try {
|
|
150
|
+
// Extract just the file pattern, remove any path prefix
|
|
151
|
+
const filePattern = pattern.replace(/^\\*\\*\\//, '').replace(/^\\.\\//, '');
|
|
152
|
+
const result = execSync(\`find . -name "\${filePattern}" -type f 2>/dev/null | grep -v node_modules | head -50\`, { encoding: 'utf-8' });
|
|
153
|
+
logEvent('tool_result', { tool: 'glob', pattern, success: true });
|
|
154
|
+
return result.trim() || 'No files found';
|
|
155
|
+
} catch (error) {
|
|
156
|
+
logEvent('tool_result', { tool: 'glob', pattern, success: false, error: error.message });
|
|
157
|
+
return 'No files found';
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
}),
|
|
161
|
+
|
|
162
|
+
grep: tool({
|
|
163
|
+
description: 'Search for a text pattern in files',
|
|
164
|
+
inputSchema: z.object({
|
|
165
|
+
pattern: z.string().describe('The search pattern'),
|
|
166
|
+
path: z.string().describe('The file or directory to search in').optional(),
|
|
167
|
+
}),
|
|
168
|
+
execute: async ({ pattern, path }) => {
|
|
169
|
+
const targetPath = path || '.';
|
|
170
|
+
try {
|
|
171
|
+
const result = execSync(\`grep -rn "\${pattern}" \${targetPath} 2>/dev/null | grep -v node_modules | head -50\`, { encoding: 'utf-8' });
|
|
172
|
+
logEvent('tool_result', { tool: 'grep', pattern, path: targetPath, success: true });
|
|
173
|
+
return result.trim() || 'No matches found';
|
|
174
|
+
} catch (error) {
|
|
175
|
+
logEvent('tool_result', { tool: 'grep', pattern, path: targetPath, success: false });
|
|
176
|
+
return 'No matches found';
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
|
|
181
|
+
bash: tool({
|
|
182
|
+
description: 'Run a bash command',
|
|
183
|
+
inputSchema: z.object({
|
|
184
|
+
command: z.string().describe('The command to run'),
|
|
185
|
+
}),
|
|
186
|
+
execute: async ({ command }) => {
|
|
187
|
+
try {
|
|
188
|
+
const result = execSync(command, { encoding: 'utf-8', timeout: 30000 });
|
|
189
|
+
logEvent('tool_result', { tool: 'bash', command, success: true });
|
|
190
|
+
return result;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
logEvent('tool_result', { tool: 'bash', command, success: false, error: error.message });
|
|
193
|
+
return \`Error: \${error.message}\\n\${error.stdout || ''}\\n\${error.stderr || ''}\`;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// System prompt for the coding agent
|
|
200
|
+
const systemPrompt = \`You are an expert coding agent. Your job is to complete programming tasks by reading, writing, and modifying files.
|
|
201
|
+
|
|
202
|
+
Available tools:
|
|
203
|
+
- readFile(path): Read a file's contents
|
|
204
|
+
- writeFile(path, content): Write/create a file (creates directories if needed)
|
|
205
|
+
- editFile(path, oldString, newString): Replace a specific string in a file
|
|
206
|
+
- listFiles(path): List files in a directory (use path="." for current directory)
|
|
207
|
+
- glob(pattern): Find files by pattern (e.g., "*.ts")
|
|
208
|
+
- grep(pattern, path): Search for text in files
|
|
209
|
+
- bash(command): Run shell commands
|
|
210
|
+
|
|
211
|
+
IMPORTANT WORKFLOW:
|
|
212
|
+
1. First, list files to understand the project structure: listFiles(path=".")
|
|
213
|
+
2. Read any relevant existing files to understand the context
|
|
214
|
+
3. Make the necessary code changes using writeFile or editFile
|
|
215
|
+
4. If needed, run build/test commands with bash to verify
|
|
216
|
+
|
|
217
|
+
RULES:
|
|
218
|
+
- Always check what files exist before modifying them
|
|
219
|
+
- Create complete, working code - not placeholders
|
|
220
|
+
- Put files in the correct directories (e.g., src/ for source files)
|
|
221
|
+
- Be thorough but efficient\`;
|
|
222
|
+
|
|
223
|
+
// Run the agent
|
|
224
|
+
async function main() {
|
|
225
|
+
logEvent('start', { model, prompt });
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
const result = await generateText({
|
|
229
|
+
model: gateway(model),
|
|
230
|
+
tools,
|
|
231
|
+
stopWhen: stepCountIs(100), // Allow up to 100 steps
|
|
232
|
+
system: systemPrompt,
|
|
233
|
+
prompt,
|
|
234
|
+
onStepFinish: ({ stepType, text, toolCalls, toolResults }) => {
|
|
235
|
+
logEvent('step', { stepType, text, toolCalls: toolCalls?.length, toolResults: toolResults?.length });
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
logEvent('complete', {
|
|
240
|
+
success: true,
|
|
241
|
+
steps: result.steps.length,
|
|
242
|
+
text: result.text,
|
|
243
|
+
});
|
|
244
|
+
} catch (error) {
|
|
245
|
+
logEvent('error', {
|
|
246
|
+
success: false,
|
|
247
|
+
error: error.message,
|
|
248
|
+
name: error.name,
|
|
249
|
+
});
|
|
250
|
+
process.exit(1);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
main();
|
|
255
|
+
`;
|
|
256
|
+
/**
|
|
257
|
+
* Create AI SDK agent with Vercel AI Gateway authentication.
|
|
258
|
+
*/
|
|
259
|
+
export function createAiSdkAgent() {
|
|
260
|
+
return {
|
|
261
|
+
name: 'vercel-ai-gateway/ai-sdk-harness',
|
|
262
|
+
displayName: 'AI SDK Harness (Vercel AI Gateway)',
|
|
263
|
+
getApiKeyEnvVar() {
|
|
264
|
+
return AI_GATEWAY.apiKeyEnvVar;
|
|
265
|
+
},
|
|
266
|
+
getDefaultModel() {
|
|
267
|
+
return 'anthropic/claude-sonnet-4';
|
|
268
|
+
},
|
|
269
|
+
async run(fixturePath, options) {
|
|
270
|
+
const startTime = Date.now();
|
|
271
|
+
let sandbox = null;
|
|
272
|
+
let agentOutput = '';
|
|
273
|
+
let aborted = false;
|
|
274
|
+
let sandboxStopped = false;
|
|
275
|
+
// Handle abort signal
|
|
276
|
+
const abortHandler = () => {
|
|
277
|
+
aborted = true;
|
|
278
|
+
if (sandbox && !sandboxStopped) {
|
|
279
|
+
sandboxStopped = true;
|
|
280
|
+
sandbox.stop().catch(() => { });
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
if (options.signal) {
|
|
284
|
+
if (options.signal.aborted) {
|
|
285
|
+
return {
|
|
286
|
+
success: false,
|
|
287
|
+
output: '',
|
|
288
|
+
error: 'Aborted before start',
|
|
289
|
+
duration: 0,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
options.signal.addEventListener('abort', abortHandler);
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
// Collect files from fixture
|
|
296
|
+
const allFiles = await collectLocalFiles(fixturePath);
|
|
297
|
+
const { workspaceFiles, testFiles } = splitTestFiles(allFiles);
|
|
298
|
+
// Check for abort before expensive operations
|
|
299
|
+
if (aborted) {
|
|
300
|
+
return {
|
|
301
|
+
success: false,
|
|
302
|
+
output: '',
|
|
303
|
+
error: 'Aborted',
|
|
304
|
+
duration: Date.now() - startTime,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
// Create sandbox
|
|
308
|
+
sandbox = await createSandbox({
|
|
309
|
+
timeout: options.timeout,
|
|
310
|
+
runtime: 'node24',
|
|
311
|
+
backend: options.sandbox,
|
|
312
|
+
});
|
|
313
|
+
// Check for abort after sandbox creation
|
|
314
|
+
if (aborted) {
|
|
315
|
+
return {
|
|
316
|
+
success: false,
|
|
317
|
+
output: '',
|
|
318
|
+
error: 'Aborted',
|
|
319
|
+
duration: Date.now() - startTime,
|
|
320
|
+
sandboxId: sandbox.sandboxId,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
// Upload workspace files (excluding tests)
|
|
324
|
+
await sandbox.uploadFiles(workspaceFiles);
|
|
325
|
+
// Run setup function if provided
|
|
326
|
+
if (options.setup) {
|
|
327
|
+
await options.setup(sandbox);
|
|
328
|
+
}
|
|
329
|
+
// Install dependencies
|
|
330
|
+
const installResult = await sandbox.runCommand('npm', ['install']);
|
|
331
|
+
if (installResult.exitCode !== 0) {
|
|
332
|
+
throw new Error(`npm install failed: ${installResult.stderr}`);
|
|
333
|
+
}
|
|
334
|
+
// Install AI SDK dependencies
|
|
335
|
+
const aiInstall = await sandbox.runCommand('npm', [
|
|
336
|
+
'install',
|
|
337
|
+
'ai@^5.0.11',
|
|
338
|
+
'@ai-sdk/gateway@^1.0.0',
|
|
339
|
+
'zod@^3.23.8',
|
|
340
|
+
]);
|
|
341
|
+
if (aiInstall.exitCode !== 0) {
|
|
342
|
+
throw new Error(`AI SDK install failed: ${aiInstall.stderr}`);
|
|
343
|
+
}
|
|
344
|
+
// Write the CLI script to the sandbox
|
|
345
|
+
await sandbox.writeFiles({
|
|
346
|
+
'ai-sdk-agent.mjs': CLI_SCRIPT,
|
|
347
|
+
});
|
|
348
|
+
// Verify no test files in sandbox
|
|
349
|
+
await verifyNoTestFiles(sandbox);
|
|
350
|
+
// Run the AI SDK agent
|
|
351
|
+
const agentResult = await sandbox.runCommand('node', [
|
|
352
|
+
'ai-sdk-agent.mjs',
|
|
353
|
+
'--prompt',
|
|
354
|
+
options.prompt,
|
|
355
|
+
'--model',
|
|
356
|
+
options.model,
|
|
357
|
+
], {
|
|
358
|
+
env: {
|
|
359
|
+
[AI_GATEWAY.apiKeyEnvVar]: options.apiKey,
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
agentOutput = agentResult.stdout + agentResult.stderr;
|
|
363
|
+
if (agentResult.exitCode !== 0) {
|
|
364
|
+
// Extract meaningful error from output
|
|
365
|
+
const errorLines = agentOutput.trim().split('\n').slice(-5).join('\n');
|
|
366
|
+
return {
|
|
367
|
+
success: false,
|
|
368
|
+
output: agentOutput,
|
|
369
|
+
error: errorLines || `AI SDK agent exited with code ${agentResult.exitCode}`,
|
|
370
|
+
duration: Date.now() - startTime,
|
|
371
|
+
sandboxId: sandbox.sandboxId,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
// Upload test files for validation
|
|
375
|
+
await sandbox.uploadFiles(testFiles);
|
|
376
|
+
// Create vitest config for EVAL.ts/tsx
|
|
377
|
+
await createVitestConfig(sandbox);
|
|
378
|
+
// The agent outputs JSON events, use that as transcript
|
|
379
|
+
const transcript = agentOutput;
|
|
380
|
+
// Run validation scripts
|
|
381
|
+
const validationResults = await runValidation(sandbox, options.scripts ?? []);
|
|
382
|
+
// Capture generated files
|
|
383
|
+
const generatedFiles = await captureGeneratedFiles(sandbox);
|
|
384
|
+
return {
|
|
385
|
+
success: validationResults.allPassed,
|
|
386
|
+
output: agentOutput,
|
|
387
|
+
transcript,
|
|
388
|
+
duration: Date.now() - startTime,
|
|
389
|
+
testResult: validationResults.test,
|
|
390
|
+
scriptsResults: validationResults.scripts,
|
|
391
|
+
sandboxId: sandbox.sandboxId,
|
|
392
|
+
generatedFiles,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
// Check if this was an abort
|
|
397
|
+
if (aborted) {
|
|
398
|
+
return {
|
|
399
|
+
success: false,
|
|
400
|
+
output: agentOutput,
|
|
401
|
+
error: 'Aborted',
|
|
402
|
+
duration: Date.now() - startTime,
|
|
403
|
+
sandboxId: sandbox?.sandboxId,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
success: false,
|
|
408
|
+
output: agentOutput,
|
|
409
|
+
error: error instanceof Error ? error.message : String(error),
|
|
410
|
+
duration: Date.now() - startTime,
|
|
411
|
+
sandboxId: sandbox?.sandboxId,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
finally {
|
|
415
|
+
// Clean up abort listener
|
|
416
|
+
if (options.signal) {
|
|
417
|
+
options.signal.removeEventListener('abort', abortHandler);
|
|
418
|
+
}
|
|
419
|
+
if (sandbox && !sandboxStopped) {
|
|
420
|
+
sandboxStopped = true;
|
|
421
|
+
await sandbox.stop();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
//# sourceMappingURL=ai-sdk-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk-agent.js","sourceRoot":"","sources":["../../../src/lib/agents/ai-sdk-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AAKrB;;;GAGG;AACH,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoPlB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,kCAAkC;QACxC,WAAW,EAAE,oCAAoC;QAEjD,eAAe;YACb,OAAO,UAAU,CAAC,YAAY,CAAC;QACjC,CAAC;QAED,eAAe;YACb,OAAO,2BAA2B,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,WAAmB,EAAE,OAAwB;YACrD,MAAM,SAAS,GAAG,IAAI,CA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,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,YAAY,CAAC;AAmFzE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,EAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CA2L/F"}
|
package/dist/lib/agents/codex.js
CHANGED
|
@@ -25,11 +25,11 @@ function extractTranscriptFromOutput(output) {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Generate Codex config.toml content.
|
|
28
|
-
* For direct mode, we embed the API key directly since env_key doesn't work reliably in the sandbox.
|
|
29
28
|
*/
|
|
30
|
-
function generateCodexConfig(model, useVercelAiGateway
|
|
31
|
-
const fullModel = model.includes('/') ? model : `openai/${model}`;
|
|
29
|
+
function generateCodexConfig(model, useVercelAiGateway) {
|
|
32
30
|
if (useVercelAiGateway) {
|
|
31
|
+
// AI Gateway uses prefixed model names like "openai/gpt-5.2-codex"
|
|
32
|
+
const fullModel = model.includes('/') ? model : `openai/${model}`;
|
|
33
33
|
return `# Codex configuration for Vercel AI Gateway
|
|
34
34
|
profile = "default"
|
|
35
35
|
|
|
@@ -37,7 +37,7 @@ profile = "default"
|
|
|
37
37
|
name = "Vercel AI Gateway"
|
|
38
38
|
base_url = "${AI_GATEWAY.openAiBaseUrl}"
|
|
39
39
|
env_key = "${AI_GATEWAY.apiKeyEnvVar}"
|
|
40
|
-
wire_api = "
|
|
40
|
+
wire_api = "responses"
|
|
41
41
|
|
|
42
42
|
[profiles.default]
|
|
43
43
|
model_provider = "vercel"
|
|
@@ -45,20 +45,20 @@ model = "${fullModel}"
|
|
|
45
45
|
`;
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
//
|
|
49
|
-
|
|
48
|
+
// Direct OpenAI API uses unprefixed model names like "gpt-5.2-codex"
|
|
49
|
+
const directModel = model.includes('/') ? model.split('/').pop() : model;
|
|
50
50
|
return `# Direct OpenAI API configuration
|
|
51
51
|
profile = "default"
|
|
52
52
|
|
|
53
53
|
[model_providers.openai]
|
|
54
54
|
name = "OpenAI"
|
|
55
55
|
base_url = "${OPENAI_DIRECT.baseUrl}"
|
|
56
|
-
|
|
57
|
-
wire_api = "
|
|
56
|
+
env_key = "${OPENAI_DIRECT.apiKeyEnvVar}"
|
|
57
|
+
wire_api = "responses"
|
|
58
58
|
|
|
59
59
|
[profiles.default]
|
|
60
60
|
model_provider = "openai"
|
|
61
|
-
model = "${
|
|
61
|
+
model = "${directModel}"
|
|
62
62
|
`;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -151,7 +151,7 @@ export function createCodexAgent({ useVercelAiGateway }) {
|
|
|
151
151
|
}
|
|
152
152
|
// Create Codex config directory and config file
|
|
153
153
|
await sandbox.runShell('mkdir -p ~/.codex');
|
|
154
|
-
const configContent = generateCodexConfig(options.model, useVercelAiGateway
|
|
154
|
+
const configContent = generateCodexConfig(options.model, useVercelAiGateway);
|
|
155
155
|
await sandbox.runShell(`cat > ~/.codex/config.toml << 'EOF'
|
|
156
156
|
${configContent}
|
|
157
157
|
EOF`);
|
|
@@ -161,21 +161,9 @@ EOF`);
|
|
|
161
161
|
// Use --dangerously-bypass-approvals-and-sandbox since Vercel sandbox provides isolation
|
|
162
162
|
// Use --json for structured output and --skip-git-repo-check since sandbox is not a git repo
|
|
163
163
|
// Model is configured in config.toml, so we don't pass --model here
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
'--json',
|
|
168
|
-
'--skip-git-repo-check',
|
|
169
|
-
options.prompt,
|
|
170
|
-
], {
|
|
171
|
-
env: useVercelAiGateway
|
|
172
|
-
? {
|
|
173
|
-
[AI_GATEWAY.apiKeyEnvVar]: options.apiKey,
|
|
174
|
-
}
|
|
175
|
-
: {
|
|
176
|
-
[OPENAI_DIRECT.apiKeyEnvVar]: options.apiKey,
|
|
177
|
-
},
|
|
178
|
-
});
|
|
164
|
+
// First login with API key, then run exec
|
|
165
|
+
const envVarToSet = useVercelAiGateway ? AI_GATEWAY.apiKeyEnvVar : OPENAI_DIRECT.apiKeyEnvVar;
|
|
166
|
+
const codexResult = await sandbox.runShell(`echo '${options.apiKey}' | codex login --with-api-key && export ${envVarToSet}='${options.apiKey}' && codex exec --dangerously-bypass-approvals-and-sandbox --json --skip-git-repo-check '${options.prompt.replace(/'/g, "'\\''")}'`);
|
|
179
167
|
agentOutput = codexResult.stdout + codexResult.stderr;
|
|
180
168
|
if (codexResult.exitCode !== 0) {
|
|
181
169
|
// Extract meaningful error from output (last few lines usually contain the error)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../src/lib/agents/codex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAKrB;;;GAGG;AACH,SAAS,2BAA2B,CAAC,MAAc;IACjD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8DAA8D;IAC9D,2DAA2D;IAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC7C,M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AI,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;oBAC/B,cAAc,GAAG,IAAI,CAAC;oBACtB,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAe9E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAGzD,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lib/agents/index.js
CHANGED
|
@@ -5,12 +5,14 @@ import { registerAgent, getAgent, listAgents, hasAgent } from './registry.js';
|
|
|
5
5
|
import { createClaudeCodeAgent } from './claude-code.js';
|
|
6
6
|
import { createCodexAgent } from './codex.js';
|
|
7
7
|
import { createOpenCodeAgent } from './opencode.js';
|
|
8
|
+
import { createAiSdkAgent } from './ai-sdk-agent.js';
|
|
8
9
|
// Register all agent variants (Vercel AI Gateway + Direct API)
|
|
9
10
|
registerAgent(createClaudeCodeAgent({ useVercelAiGateway: true })); // vercel-ai-gateway/claude-code
|
|
10
11
|
registerAgent(createClaudeCodeAgent({ useVercelAiGateway: false })); // claude-code
|
|
11
12
|
registerAgent(createCodexAgent({ useVercelAiGateway: true })); // vercel-ai-gateway/codex
|
|
12
13
|
registerAgent(createCodexAgent({ useVercelAiGateway: false })); // codex
|
|
13
14
|
registerAgent(createOpenCodeAgent()); // vercel-ai-gateway/opencode
|
|
15
|
+
registerAgent(createAiSdkAgent()); // vercel-ai-gateway/ai-sdk-harness
|
|
14
16
|
// Re-export registry functions
|
|
15
17
|
export { registerAgent, getAgent, listAgents, hasAgent };
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,+DAA+D;AAC/D,aAAa,CAAC,qBAAqB,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAG,gCAAgC;AACtG,aAAa,CAAC,qBAAqB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAE,cAAc;AACpF,aAAa,CAAC,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAQ,0BAA0B;AAChG,aAAa,CAAC,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAO,QAAQ;AAC9E,aAAa,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAiC,6BAA6B;AACnG,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAoC,mCAAmC;AAEzG,+BAA+B;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/lib/config.js
CHANGED
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAe;IACtB,KAAK,EAAE,GAAY;IACnB,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,EAAc;IACvB,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAe;IACtB,KAAK,EAAE,GAAY;IACnB,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,EAAc;IACvB,OAAO,EAAE,GAAG,EAAE,aAAa;IAC3B,OAAO,EAAE,MAAe;CACz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BAAsB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxF,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB,OAAO,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/lib/init.js
CHANGED
|
@@ -64,7 +64,7 @@ const config: ExperimentConfig = {
|
|
|
64
64
|
runs: 1,
|
|
65
65
|
earlyExit: true,
|
|
66
66
|
scripts: ['build'],
|
|
67
|
-
timeout:
|
|
67
|
+
timeout: 600,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
export default config;
|
|
@@ -81,7 +81,7 @@ const config: ExperimentConfig = {
|
|
|
81
81
|
runs: 1,
|
|
82
82
|
earlyExit: true,
|
|
83
83
|
scripts: ['build'],
|
|
84
|
-
timeout:
|
|
84
|
+
timeout: 600,
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
export default config;
|