ai-evaluate 2.1.8 → 2.3.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/README.md +16 -0
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +10 -10
- package/dist/evaluate.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/miniflare-pool.d.ts.map +1 -1
- package/dist/miniflare-pool.js +1 -1
- package/dist/miniflare-pool.js.map +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js.map +1 -1
- package/dist/repl.js +6 -6
- package/dist/repl.js.map +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +5 -2
- package/dist/shared.js.map +1 -1
- package/dist/static/index.d.ts +111 -0
- package/dist/static/index.d.ts.map +1 -0
- package/dist/static/index.js +347 -0
- package/dist/static/index.js.map +1 -0
- package/dist/type-guards.d.ts.map +1 -1
- package/dist/type-guards.js +64 -62
- package/dist/type-guards.js.map +1 -1
- package/dist/worker-template/core.d.ts.map +1 -1
- package/dist/worker-template/core.js +1 -1
- package/dist/worker-template/core.js.map +1 -1
- package/package.json +19 -6
- package/public/capnweb.mjs +220 -0
- package/public/index.mjs +426 -0
- package/public/scaffold.mjs +198 -0
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-test.log +0 -54
- package/.turbo/turbo-typecheck.log +0 -4
- package/CHANGELOG.md +0 -48
- package/dist/worker-template.d.ts +0 -41
- package/dist/worker-template.d.ts.map +0 -1
- package/dist/worker-template.js +0 -3748
- package/dist/worker-template.js.map +0 -1
- package/example/package.json +0 -20
- package/example/src/index.ts +0 -221
- package/example/wrangler.jsonc +0 -25
- package/src/capnweb-bundle.ts +0 -2596
- package/src/evaluate.ts +0 -329
- package/src/index.ts +0 -23
- package/src/miniflare-pool.ts +0 -395
- package/src/node.ts +0 -245
- package/src/repl.ts +0 -228
- package/src/shared.ts +0 -186
- package/src/type-guards.ts +0 -323
- package/src/types.ts +0 -196
- package/src/validation.ts +0 -120
- package/src/worker-template/code-transforms.ts +0 -32
- package/src/worker-template/core.ts +0 -557
- package/src/worker-template/helpers.ts +0 -90
- package/src/worker-template/index.ts +0 -23
- package/src/worker-template/sdk-generator.ts +0 -2515
- package/src/worker-template/test-generator.ts +0 -358
- package/test/evaluate-extended.test.js +0 -429
- package/test/evaluate-extended.test.ts +0 -469
- package/test/evaluate.test.js +0 -235
- package/test/evaluate.test.ts +0 -253
- package/test/index.test.js +0 -77
- package/test/index.test.ts +0 -95
- package/test/miniflare-pool.test.ts +0 -246
- package/test/node.test.ts +0 -467
- package/test/security.test.ts +0 -1009
- package/test/shared.test.ts +0 -105
- package/test/type-guards.test.ts +0 -303
- package/test/validation.test.ts +0 -240
- package/test/worker-template.test.js +0 -365
- package/test/worker-template.test.ts +0 -432
- package/tsconfig.json +0 -22
- package/vitest.config.js +0 -21
- package/vitest.config.ts +0 -28
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static worker template exports for ai-evaluate
|
|
3
|
+
*
|
|
4
|
+
* This module exports pre-built templates and builder functions
|
|
5
|
+
* for creating worker code with capnweb RPC support.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { WORKER_TEMPLATE, CAPNWEB_BUNDLE, buildWorkerTemplate } from 'ai-evaluate/static'
|
|
10
|
+
*
|
|
11
|
+
* // Use pre-built full template
|
|
12
|
+
* const workerCode = WORKER_TEMPLATE
|
|
13
|
+
*
|
|
14
|
+
* // Or build a custom template
|
|
15
|
+
* const customWorker = buildWorkerTemplate({
|
|
16
|
+
* module: 'export const add = (a, b) => a + b',
|
|
17
|
+
* tests: 'it("adds", () => expect(add(1, 2)).toBe(3))'
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import { CAPNWEB_SOURCE } from '../capnweb-bundle.js';
|
|
22
|
+
import { generateWorkerCode, generateDevWorkerCode } from '../worker-template/index.js';
|
|
23
|
+
import { generateTestFrameworkCode, generateTestRunnerCode, } from '../worker-template/test-generator.js';
|
|
24
|
+
import { generateSDKCode, generateShouldCode } from '../worker-template/sdk-generator.js';
|
|
25
|
+
import { generateDomainCheckCode } from '../shared.js';
|
|
26
|
+
/**
|
|
27
|
+
* Version of the static assets
|
|
28
|
+
*/
|
|
29
|
+
export const VERSION = '2.1.8';
|
|
30
|
+
/**
|
|
31
|
+
* The bundled capnweb RPC library source code
|
|
32
|
+
* This is the full capnweb library for Cloudflare Workers
|
|
33
|
+
*/
|
|
34
|
+
export const CAPNWEB_BUNDLE = CAPNWEB_SOURCE;
|
|
35
|
+
/**
|
|
36
|
+
* Base scaffold template without capnweb or user code
|
|
37
|
+
* This is the minimal worker structure with console capture and test framework
|
|
38
|
+
*/
|
|
39
|
+
export const SCAFFOLD_TEMPLATE = `// Sandbox Worker Scaffold
|
|
40
|
+
// Version: ${VERSION}
|
|
41
|
+
|
|
42
|
+
const logs = [];
|
|
43
|
+
|
|
44
|
+
// Capture console output
|
|
45
|
+
const originalConsole = { ...console };
|
|
46
|
+
const captureConsole = (level) => (...args) => {
|
|
47
|
+
logs.push({
|
|
48
|
+
level,
|
|
49
|
+
message: args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '),
|
|
50
|
+
timestamp: Date.now()
|
|
51
|
+
});
|
|
52
|
+
originalConsole[level](...args);
|
|
53
|
+
};
|
|
54
|
+
console.log = captureConsole('log');
|
|
55
|
+
console.warn = captureConsole('warn');
|
|
56
|
+
console.error = captureConsole('error');
|
|
57
|
+
console.info = captureConsole('info');
|
|
58
|
+
console.debug = captureConsole('debug');
|
|
59
|
+
|
|
60
|
+
${generateTestFrameworkCode()}
|
|
61
|
+
|
|
62
|
+
// Module exports object
|
|
63
|
+
const exports = {};
|
|
64
|
+
|
|
65
|
+
// ============================================================
|
|
66
|
+
// USER CODE PLACEHOLDER
|
|
67
|
+
// Replace this section with module, test, and script code
|
|
68
|
+
// ============================================================
|
|
69
|
+
|
|
70
|
+
// USER_MODULE_CODE
|
|
71
|
+
// USER_TEST_CODE
|
|
72
|
+
// USER_SCRIPT_CODE
|
|
73
|
+
|
|
74
|
+
// ============================================================
|
|
75
|
+
// WORKER ENTRY POINT
|
|
76
|
+
// ============================================================
|
|
77
|
+
export default {
|
|
78
|
+
async fetch(request, env) {
|
|
79
|
+
const url = new URL(request.url);
|
|
80
|
+
|
|
81
|
+
// Route: GET / - Return info
|
|
82
|
+
if (request.method === 'GET' && url.pathname === '/') {
|
|
83
|
+
return Response.json({
|
|
84
|
+
exports: Object.keys(exports),
|
|
85
|
+
rpc: '/rpc',
|
|
86
|
+
execute: '/execute'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Route: /execute - Run tests and scripts
|
|
91
|
+
let scriptResult = undefined;
|
|
92
|
+
let scriptError = null;
|
|
93
|
+
const testResults = { total: 0, passed: 0, failed: 0, skipped: 0, tests: [], duration: 0 };
|
|
94
|
+
const pendingTests = [];
|
|
95
|
+
|
|
96
|
+
${generateTestRunnerCode()}
|
|
97
|
+
|
|
98
|
+
const hasTests = pendingTests.length > 0;
|
|
99
|
+
const success = scriptError === null && (!hasTests || testResults.failed === 0);
|
|
100
|
+
|
|
101
|
+
return Response.json({
|
|
102
|
+
success,
|
|
103
|
+
value: scriptResult,
|
|
104
|
+
logs,
|
|
105
|
+
testResults: hasTests ? testResults : undefined,
|
|
106
|
+
error: scriptError || undefined,
|
|
107
|
+
duration: 0
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
`;
|
|
112
|
+
/**
|
|
113
|
+
* Full worker template with capnweb RPC support
|
|
114
|
+
* This is a complete worker ready to be deployed
|
|
115
|
+
*/
|
|
116
|
+
export const WORKER_TEMPLATE = `// Sandbox Worker Template with capnweb RPC
|
|
117
|
+
// Version: ${VERSION}
|
|
118
|
+
// ai-evaluate static export
|
|
119
|
+
|
|
120
|
+
import { RpcTarget, newWorkersRpcResponse } from 'capnweb.js';
|
|
121
|
+
|
|
122
|
+
const logs = [];
|
|
123
|
+
|
|
124
|
+
${generateShouldCode()}
|
|
125
|
+
|
|
126
|
+
// Capture console output
|
|
127
|
+
const originalConsole = { ...console };
|
|
128
|
+
const captureConsole = (level) => (...args) => {
|
|
129
|
+
logs.push({
|
|
130
|
+
level,
|
|
131
|
+
message: args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '),
|
|
132
|
+
timestamp: Date.now()
|
|
133
|
+
});
|
|
134
|
+
originalConsole[level](...args);
|
|
135
|
+
};
|
|
136
|
+
console.log = captureConsole('log');
|
|
137
|
+
console.warn = captureConsole('warn');
|
|
138
|
+
console.error = captureConsole('error');
|
|
139
|
+
console.info = captureConsole('info');
|
|
140
|
+
console.debug = captureConsole('debug');
|
|
141
|
+
|
|
142
|
+
${generateTestFrameworkCode()}
|
|
143
|
+
|
|
144
|
+
// Module exports object
|
|
145
|
+
const exports = {};
|
|
146
|
+
|
|
147
|
+
// ============================================================
|
|
148
|
+
// USER CODE PLACEHOLDER
|
|
149
|
+
// Replace this section with module, test, and script code
|
|
150
|
+
// ============================================================
|
|
151
|
+
|
|
152
|
+
// USER_MODULE_CODE
|
|
153
|
+
// USER_TEST_CODE
|
|
154
|
+
|
|
155
|
+
// ============================================================
|
|
156
|
+
// RPC SERVER - Expose exports via capnweb
|
|
157
|
+
// ============================================================
|
|
158
|
+
class ExportsRpcTarget extends RpcTarget {
|
|
159
|
+
constructor() {
|
|
160
|
+
super();
|
|
161
|
+
for (const [key, value] of Object.entries(exports)) {
|
|
162
|
+
if (typeof value === 'function') {
|
|
163
|
+
this[key] = value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
list() {
|
|
169
|
+
return Object.keys(exports);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get(name) {
|
|
173
|
+
return exports[name];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ============================================================
|
|
178
|
+
// WORKER ENTRY POINT
|
|
179
|
+
// ============================================================
|
|
180
|
+
export default {
|
|
181
|
+
async fetch(request, env) {
|
|
182
|
+
const url = new URL(request.url);
|
|
183
|
+
|
|
184
|
+
// Route: GET / - Return info about exports
|
|
185
|
+
if (request.method === 'GET' && url.pathname === '/') {
|
|
186
|
+
return Response.json({
|
|
187
|
+
exports: Object.keys(exports),
|
|
188
|
+
rpc: '/rpc',
|
|
189
|
+
execute: '/execute'
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Route: /rpc - capnweb RPC to module exports
|
|
194
|
+
if (url.pathname === '/rpc') {
|
|
195
|
+
return newWorkersRpcResponse(request, new ExportsRpcTarget());
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Route: GET /:name - Simple JSON endpoint to access exports
|
|
199
|
+
if (request.method === 'GET' && url.pathname !== '/execute') {
|
|
200
|
+
const name = url.pathname.slice(1);
|
|
201
|
+
const value = exports[name];
|
|
202
|
+
|
|
203
|
+
if (!(name in exports)) {
|
|
204
|
+
return Response.json({ error: \`Export "\${name}" not found\` }, { status: 404 });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (typeof value !== 'function') {
|
|
208
|
+
return Response.json({ result: value });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
const args = [];
|
|
213
|
+
const argsParam = url.searchParams.get('args');
|
|
214
|
+
if (argsParam) {
|
|
215
|
+
try {
|
|
216
|
+
const parsed = JSON.parse(argsParam);
|
|
217
|
+
if (Array.isArray(parsed)) args.push(...parsed);
|
|
218
|
+
else args.push(parsed);
|
|
219
|
+
} catch {
|
|
220
|
+
args.push(argsParam);
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
const params = Object.fromEntries(url.searchParams.entries());
|
|
224
|
+
if (Object.keys(params).length > 0) {
|
|
225
|
+
for (const [key, val] of Object.entries(params)) {
|
|
226
|
+
const num = Number(val);
|
|
227
|
+
params[key] = !isNaN(num) && val !== '' ? num : val;
|
|
228
|
+
}
|
|
229
|
+
args.push(params);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const result = await value(...args);
|
|
233
|
+
return Response.json({ result });
|
|
234
|
+
} catch (e) {
|
|
235
|
+
return Response.json({ error: e.message }, { status: 500 });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Route: /execute - Run tests and scripts
|
|
240
|
+
let scriptResult = undefined;
|
|
241
|
+
let scriptError = null;
|
|
242
|
+
const testResults = { total: 0, passed: 0, failed: 0, skipped: 0, tests: [], duration: 0 };
|
|
243
|
+
const pendingTests = [];
|
|
244
|
+
|
|
245
|
+
// USER_SCRIPT_CODE
|
|
246
|
+
|
|
247
|
+
${generateTestRunnerCode()}
|
|
248
|
+
|
|
249
|
+
const hasTests = pendingTests.length > 0;
|
|
250
|
+
const success = scriptError === null && (!hasTests || testResults.failed === 0);
|
|
251
|
+
|
|
252
|
+
return Response.json({
|
|
253
|
+
success,
|
|
254
|
+
value: scriptResult,
|
|
255
|
+
logs,
|
|
256
|
+
testResults: hasTests ? testResults : undefined,
|
|
257
|
+
error: scriptError || undefined,
|
|
258
|
+
duration: 0
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
`;
|
|
263
|
+
/**
|
|
264
|
+
* Build a complete worker template with user code embedded
|
|
265
|
+
*
|
|
266
|
+
* @param options - Worker configuration
|
|
267
|
+
* @returns Complete worker source code
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const worker = buildWorkerTemplate({
|
|
272
|
+
* module: 'export const add = (a, b) => a + b',
|
|
273
|
+
* tests: 'it("adds numbers", () => expect(add(1, 2)).toBe(3))',
|
|
274
|
+
* sdk: true
|
|
275
|
+
* })
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export function buildWorkerTemplate(options = {}) {
|
|
279
|
+
if (options.dev) {
|
|
280
|
+
return generateDevWorkerCode({
|
|
281
|
+
...(options.module !== undefined && { module: options.module }),
|
|
282
|
+
...(options.tests !== undefined && { tests: options.tests }),
|
|
283
|
+
...(options.script !== undefined && { script: options.script }),
|
|
284
|
+
...(options.sdk !== undefined && { sdk: options.sdk }),
|
|
285
|
+
...(options.imports !== undefined && { imports: options.imports }),
|
|
286
|
+
...(options.fetch !== undefined && { fetch: options.fetch }),
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return generateWorkerCode({
|
|
290
|
+
...(options.module !== undefined && { module: options.module }),
|
|
291
|
+
...(options.tests !== undefined && { tests: options.tests }),
|
|
292
|
+
...(options.script !== undefined && { script: options.script }),
|
|
293
|
+
...(options.sdk !== undefined && { sdk: options.sdk }),
|
|
294
|
+
...(options.imports !== undefined && { imports: options.imports }),
|
|
295
|
+
...(options.fetch !== undefined && { fetch: options.fetch }),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Build a worker module bundle including capnweb
|
|
300
|
+
* Returns an object with mainModule and modules for worker_loaders
|
|
301
|
+
*
|
|
302
|
+
* @param options - Worker configuration
|
|
303
|
+
* @returns Worker code configuration for worker_loaders
|
|
304
|
+
*/
|
|
305
|
+
export function buildWorkerBundle(options = {}) {
|
|
306
|
+
const mainModule = buildWorkerTemplate(options);
|
|
307
|
+
return {
|
|
308
|
+
mainModule,
|
|
309
|
+
modules: {
|
|
310
|
+
'capnweb.js': CAPNWEB_BUNDLE,
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get the test framework code for embedding
|
|
316
|
+
* This is the vitest-compatible test API (describe, it, expect)
|
|
317
|
+
*/
|
|
318
|
+
export function getTestFrameworkCode() {
|
|
319
|
+
return generateTestFrameworkCode();
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get the test runner code for embedding
|
|
323
|
+
* This executes the pending tests registered by the test framework
|
|
324
|
+
*/
|
|
325
|
+
export function getTestRunnerCode() {
|
|
326
|
+
return generateTestRunnerCode();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get the SDK code for embedding
|
|
330
|
+
* This provides the $, db, ai, api globals
|
|
331
|
+
*/
|
|
332
|
+
export function getSDKCode(config) {
|
|
333
|
+
return generateSDKCode(config);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get the .should chainable assertions code
|
|
337
|
+
*/
|
|
338
|
+
export function getShouldCode() {
|
|
339
|
+
return generateShouldCode();
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Get domain check code for fetch allowlisting
|
|
343
|
+
*/
|
|
344
|
+
export function getDomainCheckCode(allowedDomains) {
|
|
345
|
+
return generateDomainCheckCode(allowedDomains);
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/static/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAGtD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;cACnB,OAAO;;;;;;;;;;;;;;;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AED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,cAAwB;IACzD,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAqC,MAAM,YAAY,CAAA;AA2GnF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAuCxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAqC,MAAM,YAAY,CAAA;AA2GnF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAuCxE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,CAsLpF"}
|
package/dist/type-guards.js
CHANGED
|
@@ -11,15 +11,15 @@ function isLogEntry(value) {
|
|
|
11
11
|
const obj = value;
|
|
12
12
|
// Check level is one of the allowed values
|
|
13
13
|
const validLevels = ['log', 'warn', 'error', 'info', 'debug'];
|
|
14
|
-
if (typeof obj
|
|
14
|
+
if (typeof obj['level'] !== 'string' || !validLevels.includes(obj['level'])) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
// Check message is a string
|
|
18
|
-
if (typeof obj
|
|
18
|
+
if (typeof obj['message'] !== 'string') {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
// Check timestamp is a number
|
|
22
|
-
if (typeof obj
|
|
22
|
+
if (typeof obj['timestamp'] !== 'number') {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
25
|
return true;
|
|
@@ -33,17 +33,17 @@ function isTestResult(value) {
|
|
|
33
33
|
}
|
|
34
34
|
const obj = value;
|
|
35
35
|
// Check required fields
|
|
36
|
-
if (typeof obj
|
|
36
|
+
if (typeof obj['name'] !== 'string') {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
if (typeof obj
|
|
39
|
+
if (typeof obj['passed'] !== 'boolean') {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
if (typeof obj
|
|
42
|
+
if (typeof obj['duration'] !== 'number') {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
// Check optional error field
|
|
46
|
-
if (obj
|
|
46
|
+
if (obj['error'] !== undefined && typeof obj['error'] !== 'string') {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
return true;
|
|
@@ -57,26 +57,26 @@ function isTestResults(value) {
|
|
|
57
57
|
}
|
|
58
58
|
const obj = value;
|
|
59
59
|
// Check required numeric fields
|
|
60
|
-
if (typeof obj
|
|
60
|
+
if (typeof obj['total'] !== 'number') {
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
|
-
if (typeof obj
|
|
63
|
+
if (typeof obj['passed'] !== 'number') {
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
-
if (typeof obj
|
|
66
|
+
if (typeof obj['failed'] !== 'number') {
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
|
-
if (typeof obj
|
|
69
|
+
if (typeof obj['skipped'] !== 'number') {
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
|
-
if (typeof obj
|
|
72
|
+
if (typeof obj['duration'] !== 'number') {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
// Check tests array
|
|
76
|
-
if (!Array.isArray(obj
|
|
76
|
+
if (!Array.isArray(obj['tests'])) {
|
|
77
77
|
return false;
|
|
78
78
|
}
|
|
79
|
-
for (const test of obj
|
|
79
|
+
for (const test of obj['tests']) {
|
|
80
80
|
if (!isTestResult(test)) {
|
|
81
81
|
return false;
|
|
82
82
|
}
|
|
@@ -97,26 +97,26 @@ export function isEvaluateResult(value) {
|
|
|
97
97
|
}
|
|
98
98
|
const obj = value;
|
|
99
99
|
// Check required fields
|
|
100
|
-
if (typeof obj
|
|
100
|
+
if (typeof obj['success'] !== 'boolean') {
|
|
101
101
|
return false;
|
|
102
102
|
}
|
|
103
|
-
if (typeof obj
|
|
103
|
+
if (typeof obj['duration'] !== 'number') {
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
// Check logs is an array of valid LogEntry objects
|
|
107
|
-
if (!Array.isArray(obj
|
|
107
|
+
if (!Array.isArray(obj['logs'])) {
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
|
-
for (const log of obj
|
|
110
|
+
for (const log of obj['logs']) {
|
|
111
111
|
if (!isLogEntry(log)) {
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
// Check optional fields have correct types if present
|
|
116
|
-
if (obj
|
|
116
|
+
if (obj['error'] !== undefined && typeof obj['error'] !== 'string') {
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
|
-
if (obj
|
|
119
|
+
if (obj['testResults'] !== undefined && !isTestResults(obj['testResults'])) {
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
122
|
// value can be any type, so no validation needed for it
|
|
@@ -134,81 +134,83 @@ export function assertEvaluateResult(value) {
|
|
|
134
134
|
}
|
|
135
135
|
const obj = value;
|
|
136
136
|
// Validate required field: success
|
|
137
|
-
if (typeof obj
|
|
138
|
-
throw new Error(`Invalid EvaluateResult: 'success' must be a boolean, got ${typeof obj
|
|
137
|
+
if (typeof obj['success'] !== 'boolean') {
|
|
138
|
+
throw new Error(`Invalid EvaluateResult: 'success' must be a boolean, got ${typeof obj['success']}`);
|
|
139
139
|
}
|
|
140
140
|
// Validate required field: duration
|
|
141
|
-
if (typeof obj
|
|
142
|
-
throw new Error(`Invalid EvaluateResult: 'duration' must be a number, got ${typeof obj
|
|
141
|
+
if (typeof obj['duration'] !== 'number') {
|
|
142
|
+
throw new Error(`Invalid EvaluateResult: 'duration' must be a number, got ${typeof obj['duration']}`);
|
|
143
143
|
}
|
|
144
144
|
// Validate required field: logs
|
|
145
|
-
if (!Array.isArray(obj
|
|
146
|
-
throw new Error(`Invalid EvaluateResult: 'logs' must be an array, got ${typeof obj
|
|
145
|
+
if (!Array.isArray(obj['logs'])) {
|
|
146
|
+
throw new Error(`Invalid EvaluateResult: 'logs' must be an array, got ${typeof obj['logs']}`);
|
|
147
147
|
}
|
|
148
148
|
// Validate each log entry
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
const logs = obj['logs'];
|
|
150
|
+
for (let i = 0; i < logs.length; i++) {
|
|
151
|
+
const log = logs[i];
|
|
151
152
|
if (typeof log !== 'object' || log === null) {
|
|
152
153
|
throw new Error(`Invalid EvaluateResult: logs[${i}] must be an object, got ${log === null ? 'null' : typeof log}`);
|
|
153
154
|
}
|
|
154
155
|
const logObj = log;
|
|
155
156
|
const validLevels = ['log', 'warn', 'error', 'info', 'debug'];
|
|
156
|
-
if (typeof logObj
|
|
157
|
-
throw new Error(`Invalid EvaluateResult: logs[${i}].level must be one of ${validLevels.join(', ')}, got '${logObj
|
|
157
|
+
if (typeof logObj['level'] !== 'string' || !validLevels.includes(logObj['level'])) {
|
|
158
|
+
throw new Error(`Invalid EvaluateResult: logs[${i}].level must be one of ${validLevels.join(', ')}, got '${logObj['level']}'`);
|
|
158
159
|
}
|
|
159
|
-
if (typeof logObj
|
|
160
|
-
throw new Error(`Invalid EvaluateResult: logs[${i}].message must be a string, got ${typeof logObj
|
|
160
|
+
if (typeof logObj['message'] !== 'string') {
|
|
161
|
+
throw new Error(`Invalid EvaluateResult: logs[${i}].message must be a string, got ${typeof logObj['message']}`);
|
|
161
162
|
}
|
|
162
|
-
if (typeof logObj
|
|
163
|
-
throw new Error(`Invalid EvaluateResult: logs[${i}].timestamp must be a number, got ${typeof logObj
|
|
163
|
+
if (typeof logObj['timestamp'] !== 'number') {
|
|
164
|
+
throw new Error(`Invalid EvaluateResult: logs[${i}].timestamp must be a number, got ${typeof logObj['timestamp']}`);
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
// Validate optional field: error
|
|
167
|
-
if (obj
|
|
168
|
-
throw new Error(`Invalid EvaluateResult: 'error' must be a string if present, got ${typeof obj
|
|
168
|
+
if (obj['error'] !== undefined && typeof obj['error'] !== 'string') {
|
|
169
|
+
throw new Error(`Invalid EvaluateResult: 'error' must be a string if present, got ${typeof obj['error']}`);
|
|
169
170
|
}
|
|
170
171
|
// Validate optional field: testResults
|
|
171
|
-
if (obj
|
|
172
|
-
if (typeof obj
|
|
173
|
-
throw new Error(`Invalid EvaluateResult: 'testResults' must be an object if present, got ${obj
|
|
172
|
+
if (obj['testResults'] !== undefined) {
|
|
173
|
+
if (typeof obj['testResults'] !== 'object' || obj['testResults'] === null) {
|
|
174
|
+
throw new Error(`Invalid EvaluateResult: 'testResults' must be an object if present, got ${obj['testResults'] === null ? 'null' : typeof obj['testResults']}`);
|
|
174
175
|
}
|
|
175
|
-
const testResults = obj
|
|
176
|
-
if (typeof testResults
|
|
177
|
-
throw new Error(`Invalid EvaluateResult: testResults.total must be a number, got ${typeof testResults
|
|
176
|
+
const testResults = obj['testResults'];
|
|
177
|
+
if (typeof testResults['total'] !== 'number') {
|
|
178
|
+
throw new Error(`Invalid EvaluateResult: testResults.total must be a number, got ${typeof testResults['total']}`);
|
|
178
179
|
}
|
|
179
|
-
if (typeof testResults
|
|
180
|
-
throw new Error(`Invalid EvaluateResult: testResults.passed must be a number, got ${typeof testResults
|
|
180
|
+
if (typeof testResults['passed'] !== 'number') {
|
|
181
|
+
throw new Error(`Invalid EvaluateResult: testResults.passed must be a number, got ${typeof testResults['passed']}`);
|
|
181
182
|
}
|
|
182
|
-
if (typeof testResults
|
|
183
|
-
throw new Error(`Invalid EvaluateResult: testResults.failed must be a number, got ${typeof testResults
|
|
183
|
+
if (typeof testResults['failed'] !== 'number') {
|
|
184
|
+
throw new Error(`Invalid EvaluateResult: testResults.failed must be a number, got ${typeof testResults['failed']}`);
|
|
184
185
|
}
|
|
185
|
-
if (typeof testResults
|
|
186
|
-
throw new Error(`Invalid EvaluateResult: testResults.skipped must be a number, got ${typeof testResults
|
|
186
|
+
if (typeof testResults['skipped'] !== 'number') {
|
|
187
|
+
throw new Error(`Invalid EvaluateResult: testResults.skipped must be a number, got ${typeof testResults['skipped']}`);
|
|
187
188
|
}
|
|
188
|
-
if (typeof testResults
|
|
189
|
-
throw new Error(`Invalid EvaluateResult: testResults.duration must be a number, got ${typeof testResults
|
|
189
|
+
if (typeof testResults['duration'] !== 'number') {
|
|
190
|
+
throw new Error(`Invalid EvaluateResult: testResults.duration must be a number, got ${typeof testResults['duration']}`);
|
|
190
191
|
}
|
|
191
|
-
if (!Array.isArray(testResults
|
|
192
|
-
throw new Error(`Invalid EvaluateResult: testResults.tests must be an array, got ${typeof testResults
|
|
192
|
+
if (!Array.isArray(testResults['tests'])) {
|
|
193
|
+
throw new Error(`Invalid EvaluateResult: testResults.tests must be an array, got ${typeof testResults['tests']}`);
|
|
193
194
|
}
|
|
194
195
|
// Validate each test result
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
const tests = testResults['tests'];
|
|
197
|
+
for (let i = 0; i < tests.length; i++) {
|
|
198
|
+
const test = tests[i];
|
|
197
199
|
if (typeof test !== 'object' || test === null) {
|
|
198
200
|
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}] must be an object, got ${test === null ? 'null' : typeof test}`);
|
|
199
201
|
}
|
|
200
202
|
const testObj = test;
|
|
201
|
-
if (typeof testObj
|
|
202
|
-
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].name must be a string, got ${typeof testObj
|
|
203
|
+
if (typeof testObj['name'] !== 'string') {
|
|
204
|
+
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].name must be a string, got ${typeof testObj['name']}`);
|
|
203
205
|
}
|
|
204
|
-
if (typeof testObj
|
|
205
|
-
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].passed must be a boolean, got ${typeof testObj
|
|
206
|
+
if (typeof testObj['passed'] !== 'boolean') {
|
|
207
|
+
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].passed must be a boolean, got ${typeof testObj['passed']}`);
|
|
206
208
|
}
|
|
207
|
-
if (typeof testObj
|
|
208
|
-
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].duration must be a number, got ${typeof testObj
|
|
209
|
+
if (typeof testObj['duration'] !== 'number') {
|
|
210
|
+
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].duration must be a number, got ${typeof testObj['duration']}`);
|
|
209
211
|
}
|
|
210
|
-
if (testObj
|
|
211
|
-
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].error must be a string if present, got ${typeof testObj
|
|
212
|
+
if (testObj['error'] !== undefined && typeof testObj['error'] !== 'string') {
|
|
213
|
+
throw new Error(`Invalid EvaluateResult: testResults.tests[${i}].error must be a string if present, got ${typeof testObj['error']}`);
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
216
|
}
|
package/dist/type-guards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-guards.js","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,GAAG,GAAG,KAAgC,CAAA;IAE5C,2CAA2C;IAC3C,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,O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AE,CACJ,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/worker-template/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAOzD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,GAAG,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/worker-template/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAOzD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,GAAG,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB,GAAG,MAAM,CAiRT;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,GAAG,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IAC9B,KAAK,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,SAAS,CAAA;CACvC,GAAG,MAAM,CAoPT"}
|
|
@@ -13,7 +13,7 @@ import { generateDomainCheckCode } from '../shared.js';
|
|
|
13
13
|
* Generate worker code for production (uses RPC to ai-tests)
|
|
14
14
|
*/
|
|
15
15
|
export function generateWorkerCode(options) {
|
|
16
|
-
const { module: rawModule = '', tests = '', script: rawScript = '', sdk, imports = [], fetch: fetchOption } = options;
|
|
16
|
+
const { module: rawModule = '', tests = '', script: rawScript = '', sdk, imports = [], fetch: fetchOption, } = options;
|
|
17
17
|
const sdkConfig = sdk === true ? {} : sdk || null;
|
|
18
18
|
const module = rawModule ? transformModuleCode(rawModule) : '';
|
|
19
19
|
const script = rawScript ? wrapScriptForReturn(rawScript) : '';
|