@evalgate/sdk 2.0.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +638 -0
  2. package/README.md +398 -0
  3. package/dist/assertions.d.ts +189 -0
  4. package/dist/assertions.js +662 -0
  5. package/dist/batch.d.ts +68 -0
  6. package/dist/batch.js +179 -0
  7. package/dist/cache.d.ts +65 -0
  8. package/dist/cache.js +131 -0
  9. package/dist/cli/api.d.ts +108 -0
  10. package/dist/cli/api.js +132 -0
  11. package/dist/cli/baseline.d.ts +10 -0
  12. package/dist/cli/baseline.js +172 -0
  13. package/dist/cli/check.d.ts +73 -0
  14. package/dist/cli/check.js +355 -0
  15. package/dist/cli/ci-context.d.ts +6 -0
  16. package/dist/cli/ci-context.js +112 -0
  17. package/dist/cli/ci.d.ts +45 -0
  18. package/dist/cli/ci.js +192 -0
  19. package/dist/cli/config.d.ts +30 -0
  20. package/dist/cli/config.js +230 -0
  21. package/dist/cli/constants.d.ts +15 -0
  22. package/dist/cli/constants.js +18 -0
  23. package/dist/cli/diff.d.ts +173 -0
  24. package/dist/cli/diff.js +685 -0
  25. package/dist/cli/discover.d.ts +84 -0
  26. package/dist/cli/discover.js +419 -0
  27. package/dist/cli/doctor.d.ts +88 -0
  28. package/dist/cli/doctor.js +675 -0
  29. package/dist/cli/env.d.ts +21 -0
  30. package/dist/cli/env.js +42 -0
  31. package/dist/cli/explain.d.ts +58 -0
  32. package/dist/cli/explain.js +561 -0
  33. package/dist/cli/formatters/github.d.ts +8 -0
  34. package/dist/cli/formatters/github.js +135 -0
  35. package/dist/cli/formatters/human.d.ts +6 -0
  36. package/dist/cli/formatters/human.js +110 -0
  37. package/dist/cli/formatters/json.d.ts +6 -0
  38. package/dist/cli/formatters/json.js +10 -0
  39. package/dist/cli/formatters/pr-comment.d.ts +12 -0
  40. package/dist/cli/formatters/pr-comment.js +103 -0
  41. package/dist/cli/formatters/types.d.ts +103 -0
  42. package/dist/cli/formatters/types.js +8 -0
  43. package/dist/cli/gate.d.ts +21 -0
  44. package/dist/cli/gate.js +179 -0
  45. package/dist/cli/impact-analysis.d.ts +63 -0
  46. package/dist/cli/impact-analysis.js +252 -0
  47. package/dist/cli/index.d.ts +9 -0
  48. package/dist/cli/index.js +332 -0
  49. package/dist/cli/init.d.ts +16 -0
  50. package/dist/cli/init.js +292 -0
  51. package/dist/cli/manifest.d.ts +103 -0
  52. package/dist/cli/manifest.js +282 -0
  53. package/dist/cli/migrate.d.ts +41 -0
  54. package/dist/cli/migrate.js +349 -0
  55. package/dist/cli/policy-packs.d.ts +23 -0
  56. package/dist/cli/policy-packs.js +89 -0
  57. package/dist/cli/print-config.d.ts +29 -0
  58. package/dist/cli/print-config.js +270 -0
  59. package/dist/cli/profiles.d.ts +28 -0
  60. package/dist/cli/profiles.js +30 -0
  61. package/dist/cli/reason-codes.d.ts +17 -0
  62. package/dist/cli/reason-codes.js +19 -0
  63. package/dist/cli/regression-gate.d.ts +15 -0
  64. package/dist/cli/regression-gate.js +341 -0
  65. package/dist/cli/render/snippet.d.ts +5 -0
  66. package/dist/cli/render/snippet.js +15 -0
  67. package/dist/cli/render/sort.d.ts +10 -0
  68. package/dist/cli/render/sort.js +24 -0
  69. package/dist/cli/report/build-check-report.d.ts +19 -0
  70. package/dist/cli/report/build-check-report.js +132 -0
  71. package/dist/cli/run.d.ts +101 -0
  72. package/dist/cli/run.js +395 -0
  73. package/dist/cli/share.d.ts +17 -0
  74. package/dist/cli/share.js +91 -0
  75. package/dist/cli/upgrade.d.ts +15 -0
  76. package/dist/cli/upgrade.js +492 -0
  77. package/dist/cli/workspace.d.ts +31 -0
  78. package/dist/cli/workspace.js +68 -0
  79. package/dist/client.d.ts +368 -0
  80. package/dist/client.js +893 -0
  81. package/dist/client.request.test.d.ts +1 -0
  82. package/dist/client.request.test.js +232 -0
  83. package/dist/context.d.ts +134 -0
  84. package/dist/context.js +215 -0
  85. package/dist/errors.d.ts +82 -0
  86. package/dist/errors.js +298 -0
  87. package/dist/export.d.ts +195 -0
  88. package/dist/export.js +344 -0
  89. package/dist/index.d.ts +44 -0
  90. package/dist/index.js +153 -0
  91. package/dist/integrations/anthropic.d.ts +91 -0
  92. package/dist/integrations/anthropic.js +163 -0
  93. package/dist/integrations/openai-eval.d.ts +57 -0
  94. package/dist/integrations/openai-eval.js +232 -0
  95. package/dist/integrations/openai.d.ts +92 -0
  96. package/dist/integrations/openai.js +160 -0
  97. package/dist/local.d.ts +39 -0
  98. package/dist/local.js +148 -0
  99. package/dist/logger.d.ts +128 -0
  100. package/dist/logger.js +227 -0
  101. package/dist/matchers/index.d.ts +1 -0
  102. package/dist/matchers/index.js +6 -0
  103. package/dist/matchers/to-pass-gate.d.ts +29 -0
  104. package/dist/matchers/to-pass-gate.js +35 -0
  105. package/dist/pagination.d.ts +74 -0
  106. package/dist/pagination.js +139 -0
  107. package/dist/regression.d.ts +100 -0
  108. package/dist/regression.js +44 -0
  109. package/dist/runtime/adapters/config-to-dsl.d.ts +33 -0
  110. package/dist/runtime/adapters/config-to-dsl.js +400 -0
  111. package/dist/runtime/adapters/testsuite-to-dsl.d.ts +63 -0
  112. package/dist/runtime/adapters/testsuite-to-dsl.js +276 -0
  113. package/dist/runtime/context.d.ts +26 -0
  114. package/dist/runtime/context.js +74 -0
  115. package/dist/runtime/eval.d.ts +46 -0
  116. package/dist/runtime/eval.js +244 -0
  117. package/dist/runtime/execution-mode.d.ts +80 -0
  118. package/dist/runtime/execution-mode.js +357 -0
  119. package/dist/runtime/executor.d.ts +16 -0
  120. package/dist/runtime/executor.js +152 -0
  121. package/dist/runtime/registry.d.ts +78 -0
  122. package/dist/runtime/registry.js +403 -0
  123. package/dist/runtime/run-report.d.ts +200 -0
  124. package/dist/runtime/run-report.js +222 -0
  125. package/dist/runtime/types.d.ts +356 -0
  126. package/dist/runtime/types.js +76 -0
  127. package/dist/snapshot.d.ts +176 -0
  128. package/dist/snapshot.js +322 -0
  129. package/dist/streaming.d.ts +173 -0
  130. package/dist/streaming.js +268 -0
  131. package/dist/testing.d.ts +273 -0
  132. package/dist/testing.js +317 -0
  133. package/dist/types.d.ts +754 -0
  134. package/dist/types.js +54 -0
  135. package/dist/utils/input-hash.d.ts +8 -0
  136. package/dist/utils/input-hash.js +41 -0
  137. package/dist/version.d.ts +7 -0
  138. package/dist/version.js +10 -0
  139. package/dist/workflows.d.ts +389 -0
  140. package/dist/workflows.js +671 -0
  141. package/package.json +117 -0
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ /**
3
+ * Config → DSL Adapter - LAYER 2 Compatibility Bridge
4
+ *
5
+ * Migrates existing evalgate.config.json and TestSuite configurations
6
+ * to the new defineEval() DSL without breaking user workflows.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.migrateTestSuiteToDSL = migrateTestSuiteToDSL;
43
+ exports.migrateConfigToDSL = migrateConfigToDSL;
44
+ exports.migrateProjectToDSL = migrateProjectToDSL;
45
+ const fs = __importStar(require("node:fs"));
46
+ const path = __importStar(require("node:path"));
47
+ const registry_1 = require("../registry");
48
+ /**
49
+ * Convert TestSuite to defineEval() specifications
50
+ */
51
+ function migrateTestSuiteToDSL(testSuite, outputPath) {
52
+ const result = {
53
+ success: true,
54
+ specsGenerated: 0,
55
+ errors: [],
56
+ warnings: [],
57
+ outputPath,
58
+ };
59
+ try {
60
+ // Create isolated runtime for migration
61
+ const _runtime = (0, registry_1.createEvalRuntime)();
62
+ // Use the runtime handle to define specs
63
+ const _boundDefineEval = (nameOrConfig, executor, options) => {
64
+ // The runtime handle manages the active runtime internally
65
+ const { defineEval } = require("../eval");
66
+ return defineEval(nameOrConfig, executor, options);
67
+ };
68
+ // Get test suite data via public methods
69
+ // Note: We need to access the internal data structure for migration
70
+ // This is a limitation of the current TestSuite design
71
+ const suiteData = extractTestSuiteData(testSuite);
72
+ // Generate DSL file content
73
+ const dslContent = generateDSLFromTestSuiteData(suiteData);
74
+ // Write DSL file
75
+ fs.writeFileSync(outputPath, dslContent, "utf-8");
76
+ result.specsGenerated = suiteData.cases.length;
77
+ result.warnings.push(`Migrated ${suiteData.cases.length} test cases from TestSuite to defineEval() DSL`);
78
+ // Cleanup runtime
79
+ (0, registry_1.disposeActiveRuntime)();
80
+ }
81
+ catch (error) {
82
+ result.success = false;
83
+ result.errors.push(`Migration failed: ${error instanceof Error ? error.message : String(error)}`);
84
+ }
85
+ return result;
86
+ }
87
+ /**
88
+ * Extract data from TestSuite instance
89
+ * This is a workaround for the private properties
90
+ */
91
+ function extractTestSuiteData(_testSuite) {
92
+ // Since TestSuite properties are private, we need to reconstruct from usage
93
+ // This is a limitation that should be addressed in a future version
94
+ // For now, we'll create a basic structure and warn the user
95
+ return {
96
+ name: "test-suite", // Can't access private name
97
+ cases: [], // Can't access private config
98
+ config: {
99
+ cases: [],
100
+ timeout: 30000,
101
+ parallel: true,
102
+ stopOnFailure: false,
103
+ retries: 0,
104
+ },
105
+ };
106
+ }
107
+ /**
108
+ * Convert evalgate.config.json to DSL specifications
109
+ */
110
+ function migrateConfigToDSL(configPath, outputPath) {
111
+ const result = {
112
+ success: true,
113
+ specsGenerated: 0,
114
+ errors: [],
115
+ warnings: [],
116
+ outputPath,
117
+ };
118
+ try {
119
+ if (!fs.existsSync(configPath)) {
120
+ result.success = false;
121
+ result.errors.push(`Configuration file not found: ${configPath}`);
122
+ return result;
123
+ }
124
+ const configContent = fs.readFileSync(configPath, "utf-8");
125
+ const config = JSON.parse(configContent);
126
+ // Create isolated runtime for migration
127
+ const _runtime = (0, registry_1.createEvalRuntime)();
128
+ // Use the runtime handle to define specs
129
+ const _boundDefineEval = (nameOrConfig, executor, options) => {
130
+ // The runtime handle manages the active runtime internally
131
+ const { defineEval } = require("../eval");
132
+ return defineEval(nameOrConfig, executor, options);
133
+ };
134
+ // Generate basic DSL structure from config
135
+ const dslContent = generateDSLFromConfig(config);
136
+ // Write DSL file
137
+ fs.writeFileSync(outputPath, dslContent, "utf-8");
138
+ result.specsGenerated = 1; // Basic structure generated
139
+ result.warnings.push("Generated basic DSL structure from evalgate.config.json. Manual completion required.");
140
+ // Cleanup runtime
141
+ (0, registry_1.disposeActiveRuntime)();
142
+ }
143
+ catch (error) {
144
+ result.success = false;
145
+ result.errors.push(`Config migration failed: ${error instanceof Error ? error.message : String(error)}`);
146
+ }
147
+ return result;
148
+ }
149
+ /**
150
+ * Generate DSL code from TestSuite data
151
+ */
152
+ function generateDSLFromTestSuiteData(suiteData) {
153
+ const imports = [
154
+ `// Auto-generated from TestSuite: ${suiteData.name}`,
155
+ `// Generated at: ${new Date().toISOString()}`,
156
+ `// This file replaces the old TestSuite configuration`,
157
+ "",
158
+ `import { defineEval, createResult } from '@evalgate/sdk';`,
159
+ "",
160
+ ];
161
+ const specs = suiteData.cases.map((testCase, index) => {
162
+ const specName = testCase.id || `${suiteData.name}-case-${index + 1}`;
163
+ // Generate assertion code
164
+ const assertionCode = testCase.assertions
165
+ ? generateAssertionCode(testCase.assertions)
166
+ : "// No assertions defined";
167
+ return [
168
+ `defineEval("${specName}", async (context) => {`,
169
+ ` // Original input: ${testCase.input}`,
170
+ ` const input = context.input;`,
171
+ ` `,
172
+ ` // TODO: Replace with your actual agent/LLM call`,
173
+ ` const output = await simulateAgent(input);`,
174
+ ` `,
175
+ ` // Assertions:`,
176
+ assertionCode,
177
+ ` `,
178
+ ` return createResult({`,
179
+ ` pass: allAssertionsPassed,`,
180
+ ` score: allAssertionsPassed ? 100 : 0,`,
181
+ ` assertions: assertionResults,`,
182
+ ` metadata: {`,
183
+ ` originalInput: ${JSON.stringify(testCase.input)},`,
184
+ ` originalExpected: ${testCase.expected ? JSON.stringify(testCase.expected) : "undefined"},`,
185
+ ` },`,
186
+ ` });`,
187
+ `}, {`,
188
+ ` description: "Migrated from TestSuite case",`,
189
+ ` tags: ["migrated", "testsuite"],`,
190
+ `});`,
191
+ "",
192
+ ].join("\n");
193
+ });
194
+ const helperFunctions = [
195
+ `// Helper function to simulate your agent/LLM`,
196
+ `// Replace this with your actual implementation`,
197
+ `async function simulateAgent(input: string): Promise<string> {`,
198
+ ` // TODO: Implement your actual agent/LLM call here`,
199
+ ` // For now, return a simple echo as placeholder`,
200
+ ` return \`Agent response to: \${input}\`;`,
201
+ `}`,
202
+ "",
203
+ ];
204
+ return [...imports, ...helperFunctions, ...specs].join("\n");
205
+ }
206
+ /**
207
+ * Generate DSL code from configuration
208
+ */
209
+ function generateDSLFromConfig(config) {
210
+ return [
211
+ `// Auto-generated from evalgate.config.json`,
212
+ `// Generated at: ${new Date().toISOString()}`,
213
+ `// This is a basic DSL structure - complete with your actual evaluations`,
214
+ "",
215
+ `import { defineEval, createResult } from '@evalgate/sdk';`,
216
+ "",
217
+ `defineEval("basic-evaluation", async (context) => {`,
218
+ ` const input = context.input;`,
219
+ ` `,
220
+ ` // TODO: Replace with your actual agent/LLM call`,
221
+ ` const output = await simulateAgent(input);`,
222
+ ` `,
223
+ ` // TODO: Add your actual evaluation logic`,
224
+ ` const pass = output.length > 0;`,
225
+ ` const score = pass ? 100 : 0;`,
226
+ ` `,
227
+ ` return createResult({`,
228
+ ` pass,`,
229
+ ` score,`,
230
+ ` metadata: {`,
231
+ ` evaluationId: ${config.evaluationId ? JSON.stringify(config.evaluationId) : "undefined"},`,
232
+ ` input,`,
233
+ ` output,`,
234
+ ` },`,
235
+ ` });`,
236
+ `}, {`,
237
+ ` description: "Basic evaluation migrated from evalgate.config.json",`,
238
+ ` tags: ["migrated", "config"],`,
239
+ `});`,
240
+ "",
241
+ `// Helper function to simulate your agent/LLM`,
242
+ `// Replace this with your actual implementation`,
243
+ `async function simulateAgent(input: string): Promise<string> {`,
244
+ ` // TODO: Implement your actual agent/LLM call here`,
245
+ ` return \`Agent response to: \${input}\`;`,
246
+ `}`,
247
+ "",
248
+ ].join("\n");
249
+ }
250
+ /**
251
+ * Generate assertion code from TestSuite assertions
252
+ */
253
+ function generateAssertionCode(assertions) {
254
+ // Since we can't analyze the assertion functions at runtime,
255
+ // we generate placeholder code that users need to complete
256
+ return [
257
+ ` // Original assertions: ${assertions.length} defined`,
258
+ ` // TODO: Manually convert these assertions to evaluation logic:`,
259
+ ...assertions.map((_, index) => ` // assertion ${index + 1}: <convert to evaluation logic>`),
260
+ ` `,
261
+ ` const assertionResults = [];`,
262
+ ` let allAssertionsPassed = true;`,
263
+ ` `,
264
+ ` // TODO: Add your actual assertion logic here`,
265
+ ` // Example:`,
266
+ ` // const containsExpected = output.includes(expected);`,
267
+ ` // assertionResults.push({ name: "contains-expected", passed: containsExpected });`,
268
+ ` // if (!containsExpected) allAssertionsPassed = false;`,
269
+ ].join("\n");
270
+ }
271
+ /**
272
+ * Discover and migrate all TestSuite configurations in a project
273
+ */
274
+ function migrateProjectToDSL(projectRoot, options = {}) {
275
+ const result = {
276
+ success: true,
277
+ specsGenerated: 0,
278
+ errors: [],
279
+ warnings: [],
280
+ outputPath: options.outputDir || path.join(projectRoot, ".evalgate", "migrated"),
281
+ };
282
+ try {
283
+ // Find evalgate.config.json or evalai.config.json
284
+ const evalgatePath = path.join(projectRoot, "evalgate.config.json");
285
+ const legacyPath = path.join(projectRoot, "evalai.config.json");
286
+ const configPath = fs.existsSync(evalgatePath)
287
+ ? evalgatePath
288
+ : fs.existsSync(legacyPath)
289
+ ? legacyPath
290
+ : null;
291
+ if (configPath) {
292
+ const outputPath = path.join(result.outputPath, "evalgate.config.migrated.ts");
293
+ if (!options.dryRun) {
294
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
295
+ const configResult = migrateConfigToDSL(configPath, outputPath);
296
+ result.specsGenerated += configResult.specsGenerated;
297
+ result.errors.push(...configResult.errors);
298
+ result.warnings.push(...configResult.warnings);
299
+ }
300
+ else {
301
+ result.warnings.push(`Would migrate evalgate.config.json to ${outputPath}`);
302
+ }
303
+ }
304
+ // Look for TestSuite usage in TypeScript/JavaScript files
305
+ const testFiles = findTestSuiteFiles(projectRoot);
306
+ for (const testFile of testFiles) {
307
+ const outputPath = path.join(result.outputPath, path.basename(testFile).replace(/\.(ts|js)$/, ".migrated.ts"));
308
+ if (!options.dryRun) {
309
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
310
+ // Note: Actual TestSuite parsing would require AST analysis
311
+ // For now, we create placeholder files
312
+ const placeholderContent = generatePlaceholderDSL(testFile);
313
+ fs.writeFileSync(outputPath, placeholderContent, "utf-8");
314
+ result.specsGenerated += 1;
315
+ result.warnings.push(`Created migration placeholder for ${testFile}`);
316
+ }
317
+ else {
318
+ result.warnings.push(`Would migrate ${testFile} to ${outputPath}`);
319
+ }
320
+ }
321
+ if (result.specsGenerated === 0) {
322
+ result.warnings.push("No TestSuite configurations found to migrate");
323
+ }
324
+ }
325
+ catch (error) {
326
+ result.success = false;
327
+ result.errors.push(`Project migration failed: ${error instanceof Error ? error.message : String(error)}`);
328
+ }
329
+ return result;
330
+ }
331
+ /**
332
+ * Find files that might contain TestSuite usage
333
+ */
334
+ function findTestSuiteFiles(projectRoot) {
335
+ const testFiles = [];
336
+ function scanDirectory(dir) {
337
+ if (!fs.existsSync(dir))
338
+ return;
339
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
340
+ for (const entry of entries) {
341
+ const fullPath = path.join(dir, entry.name);
342
+ if (entry.isDirectory() &&
343
+ !entry.name.startsWith(".") &&
344
+ entry.name !== "node_modules") {
345
+ scanDirectory(fullPath);
346
+ }
347
+ else if (entry.isFile() && /\.(ts|js)$/.test(entry.name)) {
348
+ try {
349
+ const content = fs.readFileSync(fullPath, "utf-8");
350
+ if (content.includes("createTestSuite") ||
351
+ content.includes("TestSuite")) {
352
+ testFiles.push(fullPath);
353
+ }
354
+ }
355
+ catch {
356
+ // Skip files that can't be read
357
+ }
358
+ }
359
+ }
360
+ }
361
+ scanDirectory(projectRoot);
362
+ return testFiles;
363
+ }
364
+ /**
365
+ * Generate placeholder DSL for files that need manual migration
366
+ */
367
+ function generatePlaceholderDSL(originalFile) {
368
+ return [
369
+ `// Migration placeholder for: ${originalFile}`,
370
+ `// Generated at: ${new Date().toISOString()}`,
371
+ `// This file contains TestSuite usage that needs manual migration`,
372
+ "",
373
+ `import { defineEval, createResult } from '@evalgate/sdk';`,
374
+ "",
375
+ `defineEval("placeholder-from-${path.basename(originalFile)}", async (context) => {`,
376
+ ` // TODO: Manually migrate TestSuite from ${originalFile}`,
377
+ ` const input = context.input;`,
378
+ ` `,
379
+ ` // Replace with your actual evaluation logic`,
380
+ ` const output = await simulateAgent(input);`,
381
+ ` `,
382
+ ` return createResult({`,
383
+ ` pass: output.length > 0,`,
384
+ ` score: output.length > 0 ? 100 : 0,`,
385
+ ` metadata: {`,
386
+ ` migratedFrom: ${JSON.stringify(originalFile)},`,
387
+ ` },`,
388
+ ` });`,
389
+ `}, {`,
390
+ ` description: "Placeholder - complete migration manually",`,
391
+ ` tags: ["placeholder", "needs-migration"],`,
392
+ `});`,
393
+ "",
394
+ `async function simulateAgent(input: string): Promise<string> {`,
395
+ ` // TODO: Implement your actual agent/LLM call`,
396
+ ` return \`Response to: \${input}\`;`,
397
+ `}`,
398
+ "",
399
+ ].join("\n");
400
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * COMPAT-202: Legacy TestSuite → defineEval adapter
3
+ *
4
+ * Converts legacy TestSuite instances to defineEval specifications
5
+ * without forcing migration. Enables lossless where possible.
6
+ */
7
+ import type { TestSuite } from "../../testing";
8
+ import type { EvalSpec } from "../types";
9
+ /**
10
+ * Adapter configuration options
11
+ */
12
+ export interface TestSuiteAdapterOptions {
13
+ /** Include provenance metadata in generated specs */
14
+ includeProvenance?: boolean;
15
+ /** Preserve original test IDs */
16
+ preserveIds?: boolean;
17
+ /** Generate helper functions for assertions */
18
+ generateHelpers?: boolean;
19
+ }
20
+ /**
21
+ * Convert TestSuite to defineEval specifications
22
+ *
23
+ * @param suite - Legacy TestSuite instance
24
+ * @param options - Adapter configuration options
25
+ * @returns Array of EvalSpec definitions
26
+ */
27
+ export declare function adaptTestSuite(suite: TestSuite, options?: Partial<TestSuiteOptions>): EvalSpec[];
28
+ /**
29
+ * Generate defineEval code from TestSuite
30
+ *
31
+ * @param suite - Legacy TestSuite instance
32
+ * @param options - Code generation options
33
+ * @returns Generated TypeScript code
34
+ */
35
+ export declare function generateDefineEvalCode(suite: TestSuite, options?: Partial<TestSuiteOptions>): string;
36
+ /**
37
+ * Create adapter configuration for TestSuite
38
+ */
39
+ export interface TestSuiteConfig {
40
+ /** Test cases to run */
41
+ cases: unknown[];
42
+ /** Function that generates output from input */
43
+ executor?: (input: string) => Promise<string>;
44
+ /** Run tests in parallel (default: true) */
45
+ parallel?: boolean;
46
+ /** Stop on first failure (default: false) */
47
+ stopOnFailure?: boolean;
48
+ /** Timeout per test case in ms (default: 30000) */
49
+ timeout?: number;
50
+ /** Retry failing cases N times (default: 0) */
51
+ retries?: number;
52
+ }
53
+ /**
54
+ * TestSuite options (alias for compatibility)
55
+ */
56
+ export interface TestSuiteOptions extends TestSuiteConfig {
57
+ /** Include provenance metadata in generated specs */
58
+ includeProvenance?: boolean;
59
+ /** Preserve original test IDs */
60
+ preserveIds?: boolean;
61
+ /** Generate helper functions for assertions */
62
+ generateHelpers?: boolean;
63
+ }