@outputai/core 0.1.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 (114) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +11 -0
  3. package/bin/healthcheck.mjs +36 -0
  4. package/bin/healthcheck.spec.js +90 -0
  5. package/bin/worker.sh +26 -0
  6. package/package.json +67 -0
  7. package/src/activity_integration/context.d.ts +27 -0
  8. package/src/activity_integration/context.js +17 -0
  9. package/src/activity_integration/context.spec.js +42 -0
  10. package/src/activity_integration/events.d.ts +7 -0
  11. package/src/activity_integration/events.js +10 -0
  12. package/src/activity_integration/index.d.ts +9 -0
  13. package/src/activity_integration/index.js +3 -0
  14. package/src/activity_integration/tracing.d.ts +32 -0
  15. package/src/activity_integration/tracing.js +37 -0
  16. package/src/async_storage.js +19 -0
  17. package/src/bus.js +3 -0
  18. package/src/consts.js +32 -0
  19. package/src/errors.d.ts +15 -0
  20. package/src/errors.js +14 -0
  21. package/src/hooks/index.d.ts +28 -0
  22. package/src/hooks/index.js +32 -0
  23. package/src/index.d.ts +49 -0
  24. package/src/index.js +4 -0
  25. package/src/interface/evaluation_result.d.ts +173 -0
  26. package/src/interface/evaluation_result.js +215 -0
  27. package/src/interface/evaluator.d.ts +70 -0
  28. package/src/interface/evaluator.js +34 -0
  29. package/src/interface/evaluator.spec.js +565 -0
  30. package/src/interface/index.d.ts +9 -0
  31. package/src/interface/index.js +26 -0
  32. package/src/interface/step.d.ts +138 -0
  33. package/src/interface/step.js +22 -0
  34. package/src/interface/types.d.ts +27 -0
  35. package/src/interface/validations/runtime.js +20 -0
  36. package/src/interface/validations/runtime.spec.js +29 -0
  37. package/src/interface/validations/schema_utils.js +8 -0
  38. package/src/interface/validations/schema_utils.spec.js +67 -0
  39. package/src/interface/validations/static.js +136 -0
  40. package/src/interface/validations/static.spec.js +366 -0
  41. package/src/interface/webhook.d.ts +84 -0
  42. package/src/interface/webhook.js +64 -0
  43. package/src/interface/webhook.spec.js +122 -0
  44. package/src/interface/workflow.d.ts +273 -0
  45. package/src/interface/workflow.js +128 -0
  46. package/src/interface/workflow.spec.js +467 -0
  47. package/src/interface/workflow_context.js +31 -0
  48. package/src/interface/workflow_utils.d.ts +76 -0
  49. package/src/interface/workflow_utils.js +50 -0
  50. package/src/interface/workflow_utils.spec.js +190 -0
  51. package/src/interface/zod_integration.spec.js +646 -0
  52. package/src/internal_activities/index.js +66 -0
  53. package/src/internal_activities/index.spec.js +102 -0
  54. package/src/logger.js +73 -0
  55. package/src/tracing/internal_interface.js +71 -0
  56. package/src/tracing/processors/local/index.js +111 -0
  57. package/src/tracing/processors/local/index.spec.js +149 -0
  58. package/src/tracing/processors/s3/configs.js +31 -0
  59. package/src/tracing/processors/s3/configs.spec.js +64 -0
  60. package/src/tracing/processors/s3/index.js +114 -0
  61. package/src/tracing/processors/s3/index.spec.js +153 -0
  62. package/src/tracing/processors/s3/redis_client.js +62 -0
  63. package/src/tracing/processors/s3/redis_client.spec.js +185 -0
  64. package/src/tracing/processors/s3/s3_client.js +27 -0
  65. package/src/tracing/processors/s3/s3_client.spec.js +62 -0
  66. package/src/tracing/tools/build_trace_tree.js +83 -0
  67. package/src/tracing/tools/build_trace_tree.spec.js +135 -0
  68. package/src/tracing/tools/utils.js +21 -0
  69. package/src/tracing/tools/utils.spec.js +14 -0
  70. package/src/tracing/trace_engine.js +97 -0
  71. package/src/tracing/trace_engine.spec.js +199 -0
  72. package/src/utils/index.d.ts +134 -0
  73. package/src/utils/index.js +2 -0
  74. package/src/utils/resolve_invocation_dir.js +34 -0
  75. package/src/utils/resolve_invocation_dir.spec.js +102 -0
  76. package/src/utils/utils.js +211 -0
  77. package/src/utils/utils.spec.js +448 -0
  78. package/src/worker/bundler_options.js +43 -0
  79. package/src/worker/catalog_workflow/catalog.js +114 -0
  80. package/src/worker/catalog_workflow/index.js +54 -0
  81. package/src/worker/catalog_workflow/index.spec.js +196 -0
  82. package/src/worker/catalog_workflow/workflow.js +24 -0
  83. package/src/worker/configs.js +49 -0
  84. package/src/worker/configs.spec.js +130 -0
  85. package/src/worker/index.js +89 -0
  86. package/src/worker/index.spec.js +177 -0
  87. package/src/worker/interceptors/activity.js +62 -0
  88. package/src/worker/interceptors/activity.spec.js +212 -0
  89. package/src/worker/interceptors/workflow.js +70 -0
  90. package/src/worker/interceptors/workflow.spec.js +167 -0
  91. package/src/worker/interceptors.js +10 -0
  92. package/src/worker/loader.js +151 -0
  93. package/src/worker/loader.spec.js +236 -0
  94. package/src/worker/loader_tools.js +132 -0
  95. package/src/worker/loader_tools.spec.js +156 -0
  96. package/src/worker/log_hooks.js +95 -0
  97. package/src/worker/log_hooks.spec.js +217 -0
  98. package/src/worker/sandboxed_utils.js +18 -0
  99. package/src/worker/shutdown.js +26 -0
  100. package/src/worker/shutdown.spec.js +82 -0
  101. package/src/worker/sinks.js +74 -0
  102. package/src/worker/start_catalog.js +36 -0
  103. package/src/worker/start_catalog.spec.js +118 -0
  104. package/src/worker/webpack_loaders/consts.js +9 -0
  105. package/src/worker/webpack_loaders/tools.js +548 -0
  106. package/src/worker/webpack_loaders/tools.spec.js +330 -0
  107. package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.js +221 -0
  108. package/src/worker/webpack_loaders/workflow_rewriter/collect_target_imports.spec.js +336 -0
  109. package/src/worker/webpack_loaders/workflow_rewriter/index.mjs +61 -0
  110. package/src/worker/webpack_loaders/workflow_rewriter/index.spec.js +216 -0
  111. package/src/worker/webpack_loaders/workflow_rewriter/rewrite_fn_bodies.js +196 -0
  112. package/src/worker/webpack_loaders/workflow_rewriter/rewrite_fn_bodies.spec.js +123 -0
  113. package/src/worker/webpack_loaders/workflow_validator/index.mjs +205 -0
  114. package/src/worker/webpack_loaders/workflow_validator/index.spec.js +613 -0
@@ -0,0 +1,565 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ EvaluationResult,
4
+ EvaluationStringResult,
5
+ EvaluationNumberResult,
6
+ EvaluationBooleanResult,
7
+ EvaluationFeedback
8
+ } from './evaluation_result.js';
9
+ import { ValidationError } from '#errors';
10
+
11
+ describe( 'interface/evaluator - EvaluationResult classes', () => {
12
+ describe( 'class inheritance', () => {
13
+ it( 'subclasses extend EvaluationResult', () => {
14
+ const s = new EvaluationStringResult( { value: 'ok', confidence: 0.8 } );
15
+ const n = new EvaluationNumberResult( { value: 42, confidence: 1 } );
16
+ const b = new EvaluationBooleanResult( { value: true, confidence: 0.5 } );
17
+
18
+ expect( s ).toBeInstanceOf( EvaluationResult );
19
+ expect( n ).toBeInstanceOf( EvaluationResult );
20
+ expect( b ).toBeInstanceOf( EvaluationResult );
21
+ } );
22
+ } );
23
+
24
+ describe( 'constructor payload validation', () => {
25
+ it( 'base class validates presence and types of common fields', () => {
26
+ // valid
27
+ const base = new EvaluationResult( { value: { any: 'thing' }, confidence: 0.1 } );
28
+ expect( base.value ).toEqual( { any: 'thing' } );
29
+ expect( base.confidence ).toBe( 0.1 );
30
+ expect( base.reasoning ).toBeUndefined();
31
+
32
+ // invalid: missing confidence
33
+ expect( () => new EvaluationResult( { value: 1 } ) ).toThrow( ValidationError );
34
+
35
+ // invalid: confidence wrong type
36
+ expect( () => new EvaluationResult( { value: 'x', confidence: 'nope' } ) ).toThrow( ValidationError );
37
+
38
+ // invalid: reasoning wrong type
39
+ expect( () => new EvaluationResult( { value: 'x', confidence: 1, reasoning: 123 } ) ).toThrow( ValidationError );
40
+ } );
41
+
42
+ it( 'string subclass enforces string value', () => {
43
+ // valid
44
+ const r = new EvaluationStringResult( { value: 'hello', confidence: 0.9 } );
45
+ expect( r.value ).toBe( 'hello' );
46
+
47
+ // invalid
48
+ expect( () => new EvaluationStringResult( { value: 123, confidence: 0.2 } ) ).toThrow( ValidationError );
49
+ } );
50
+
51
+ it( 'number subclass enforces number value', () => {
52
+ // valid
53
+ const r = new EvaluationNumberResult( { value: 123, confidence: 0.2 } );
54
+ expect( r.value ).toBe( 123 );
55
+
56
+ // invalid
57
+ expect( () => new EvaluationNumberResult( { value: 'nope', confidence: 0.2 } ) ).toThrow( ValidationError );
58
+ } );
59
+
60
+ it( 'boolean subclass enforces boolean value', () => {
61
+ // valid
62
+ const r = new EvaluationBooleanResult( { value: true, confidence: 1 } );
63
+ expect( r.value ).toBe( true );
64
+
65
+ // invalid
66
+ expect( () => new EvaluationBooleanResult( { value: 'nope', confidence: 0.2 } ) ).toThrow( ValidationError );
67
+ } );
68
+ } );
69
+
70
+ describe( 'static schema getter', () => {
71
+ it( 'base schema accepts any value and optional reasoning', () => {
72
+ const ok = EvaluationResult.schema.safeParse( { value: 'x', confidence: 0.5, reasoning: 'why' } );
73
+ expect( ok.success ).toBe( true );
74
+
75
+ const ok2 = EvaluationResult.schema.safeParse( { value: 123, confidence: 0.5 } );
76
+ expect( ok2.success ).toBe( true );
77
+ } );
78
+
79
+ it( 'string schema requires value to be string', () => {
80
+ const ok = EvaluationStringResult.schema.safeParse( { value: 'x', confidence: 1 } );
81
+ expect( ok.success ).toBe( true );
82
+
83
+ const bad = EvaluationStringResult.schema.safeParse( { value: 123, confidence: 1 } );
84
+ expect( bad.success ).toBe( false );
85
+ } );
86
+
87
+ it( 'number schema requires value to be number', () => {
88
+ const ok = EvaluationNumberResult.schema.safeParse( { value: 10, confidence: 1 } );
89
+ expect( ok.success ).toBe( true );
90
+
91
+ const bad = EvaluationNumberResult.schema.safeParse( { value: '10', confidence: 1 } );
92
+ expect( bad.success ).toBe( false );
93
+ } );
94
+
95
+ it( 'boolean schema requires value to be boolean', () => {
96
+ const ok = EvaluationBooleanResult.schema.safeParse( { value: false, confidence: 1 } );
97
+ expect( ok.success ).toBe( true );
98
+
99
+ const bad = EvaluationBooleanResult.schema.safeParse( { value: 'false', confidence: 1 } );
100
+ expect( bad.success ).toBe( false );
101
+ } );
102
+
103
+ it( 'schema getter does not cause infinite recursion', () => {
104
+ // Access schema multiple times to ensure no stack overflow
105
+ const schema1 = EvaluationResult.schema;
106
+ const schema2 = EvaluationResult.schema;
107
+ const schema3 = EvaluationStringResult.schema;
108
+ const schema4 = EvaluationNumberResult.schema;
109
+ const schema5 = EvaluationBooleanResult.schema;
110
+
111
+ expect( schema1 ).toBeDefined();
112
+ expect( schema2 ).toBeDefined();
113
+ expect( schema3 ).toBeDefined();
114
+ expect( schema4 ).toBeDefined();
115
+ expect( schema5 ).toBeDefined();
116
+
117
+ // Verify schemas can be used for validation
118
+ const result = schema1.safeParse( {
119
+ value: 'test',
120
+ confidence: 0.8,
121
+ dimensions: [
122
+ { value: 'dim1', confidence: 0.9 },
123
+ { value: 42, confidence: 0.8 }
124
+ ]
125
+ } );
126
+ expect( result.success ).toBe( true );
127
+ } );
128
+
129
+ it( 'schema includes dimensions field', () => {
130
+ const schema = EvaluationResult.schema;
131
+ const result = schema.safeParse( {
132
+ value: 'test',
133
+ confidence: 0.8,
134
+ dimensions: [
135
+ { value: 'string-dim', confidence: 0.9 },
136
+ { value: 42, confidence: 0.8 },
137
+ { value: true, confidence: 0.7 }
138
+ ]
139
+ } );
140
+ expect( result.success ).toBe( true );
141
+ if ( result.success ) {
142
+ expect( result.data.dimensions ).toHaveLength( 3 );
143
+ }
144
+ } );
145
+
146
+ it( 'schema validates dimensions value types', () => {
147
+ const schema = EvaluationResult.schema;
148
+
149
+ // Valid: primitive value types
150
+ const valid = schema.safeParse( {
151
+ value: 'test',
152
+ confidence: 0.8,
153
+ dimensions: [
154
+ { value: 'string', confidence: 0.9 },
155
+ { value: 42, confidence: 0.8 },
156
+ { value: true, confidence: 0.7 }
157
+ ]
158
+ } );
159
+ expect( valid.success ).toBe( true );
160
+
161
+ // Invalid: non-primitive value type in dimensions
162
+ const invalid = schema.safeParse( {
163
+ value: 'test',
164
+ confidence: 0.8,
165
+ dimensions: [
166
+ { value: { object: 'not allowed' }, confidence: 0.9 }
167
+ ]
168
+ } );
169
+ expect( invalid.success ).toBe( false );
170
+ } );
171
+ } );
172
+
173
+ describe( 'new fields: name, dimensions, feedback', () => {
174
+ it( 'accepts optional name field', () => {
175
+ const result = new EvaluationResult( {
176
+ value: 'test',
177
+ confidence: 0.8,
178
+ name: 'test-evaluation'
179
+ } );
180
+ expect( result.name ).toBe( 'test-evaluation' );
181
+ } );
182
+
183
+ it( 'name defaults to undefined when not provided', () => {
184
+ const result = new EvaluationResult( {
185
+ value: 'test',
186
+ confidence: 0.8
187
+ } );
188
+ expect( result.name ).toBeUndefined();
189
+ } );
190
+
191
+ it( 'validates name must be string if provided', () => {
192
+ expect( () => new EvaluationResult( {
193
+ value: 'test',
194
+ confidence: 0.8,
195
+ name: 123
196
+ } ) ).toThrow( ValidationError );
197
+ } );
198
+
199
+ it( 'accepts dimensions array with EvaluationResult instances', () => {
200
+ const dim1 = new EvaluationStringResult( { value: 'dim1', confidence: 0.9 } );
201
+ const dim2 = new EvaluationNumberResult( { value: 42, confidence: 0.8 } );
202
+ const result = new EvaluationResult( {
203
+ value: 'main',
204
+ confidence: 0.7,
205
+ dimensions: [ dim1, dim2 ]
206
+ } );
207
+ expect( result.dimensions ).toHaveLength( 2 );
208
+ expect( result.dimensions[0] ).toBe( dim1 );
209
+ expect( result.dimensions[1] ).toBe( dim2 );
210
+ } );
211
+
212
+ it( 'dimensions defaults to empty array when not provided', () => {
213
+ const result = new EvaluationResult( {
214
+ value: 'test',
215
+ confidence: 0.8
216
+ } );
217
+ expect( result.dimensions ).toEqual( [] );
218
+ } );
219
+
220
+ it( 'validates dimensions must match subclass schema', () => {
221
+ expect( () => new EvaluationResult( {
222
+ value: 'test',
223
+ confidence: 0.8,
224
+ dimensions: [ { invalid: 'object' } ]
225
+ } ) ).toThrow( ValidationError );
226
+ } );
227
+
228
+ it( 'validates dimensions array structure', () => {
229
+ expect( () => new EvaluationResult( {
230
+ value: 'test',
231
+ confidence: 0.8,
232
+ dimensions: [
233
+ { value: 'valid', confidence: 0.9 },
234
+ { invalid: 'missing confidence' }
235
+ ]
236
+ } ) ).toThrow( ValidationError );
237
+ } );
238
+
239
+ it( 'accepts dimensions with all three subclass types', () => {
240
+ const result = new EvaluationResult( {
241
+ value: 'main',
242
+ confidence: 0.7,
243
+ dimensions: [
244
+ new EvaluationStringResult( { value: 'string-dim', confidence: 0.9 } ),
245
+ new EvaluationNumberResult( { value: 42, confidence: 0.8 } ),
246
+ new EvaluationBooleanResult( { value: true, confidence: 0.7 } )
247
+ ]
248
+ } );
249
+ expect( result.dimensions ).toHaveLength( 3 );
250
+ expect( result.dimensions[0] ).toBeInstanceOf( EvaluationStringResult );
251
+ expect( result.dimensions[1] ).toBeInstanceOf( EvaluationNumberResult );
252
+ expect( result.dimensions[2] ).toBeInstanceOf( EvaluationBooleanResult );
253
+ } );
254
+
255
+ it( 'accepts plain objects matching subclass schemas in dimensions', () => {
256
+ const result = new EvaluationResult( {
257
+ value: 'main',
258
+ confidence: 0.7,
259
+ dimensions: [
260
+ { value: 'string-dim', confidence: 0.9 },
261
+ { value: 42, confidence: 0.8 },
262
+ { value: true, confidence: 0.7 }
263
+ ]
264
+ } );
265
+ expect( result.dimensions ).toHaveLength( 3 );
266
+ expect( result.dimensions[0].value ).toBe( 'string-dim' );
267
+ expect( result.dimensions[1].value ).toBe( 42 );
268
+ expect( result.dimensions[2].value ).toBe( true );
269
+ } );
270
+
271
+ it( 'accepts string dimension value type', () => {
272
+ const result = new EvaluationResult( {
273
+ value: 'test',
274
+ confidence: 0.8,
275
+ dimensions: [
276
+ { value: 'string-value', confidence: 0.9 }
277
+ ]
278
+ } );
279
+ expect( result.dimensions[0].value ).toBe( 'string-value' );
280
+ } );
281
+
282
+ it( 'accepts number dimension value type', () => {
283
+ const result = new EvaluationResult( {
284
+ value: 'test',
285
+ confidence: 0.8,
286
+ dimensions: [
287
+ { value: 123, confidence: 0.9 }
288
+ ]
289
+ } );
290
+ expect( result.dimensions[0].value ).toBe( 123 );
291
+ } );
292
+
293
+ it( 'accepts boolean dimension value type', () => {
294
+ const result = new EvaluationResult( {
295
+ value: 'test',
296
+ confidence: 0.8,
297
+ dimensions: [
298
+ { value: true, confidence: 0.9 }
299
+ ]
300
+ } );
301
+ expect( result.dimensions[0].value ).toBe( true );
302
+ } );
303
+
304
+ it( 'rejects dimensions with non-primitive value types', () => {
305
+ expect( () => new EvaluationResult( {
306
+ value: 'test',
307
+ confidence: 0.8,
308
+ dimensions: [
309
+ { value: { object: 'not allowed' }, confidence: 0.9 }
310
+ ]
311
+ } ) ).toThrow( ValidationError );
312
+ } );
313
+
314
+ it( 'rejects dimensions with array value types', () => {
315
+ expect( () => new EvaluationResult( {
316
+ value: 'test',
317
+ confidence: 0.8,
318
+ dimensions: [
319
+ { value: [ 1, 2, 3 ], confidence: 0.9 }
320
+ ]
321
+ } ) ).toThrow( ValidationError );
322
+ } );
323
+
324
+ it( 'accepts nested dimensions (recursive)', () => {
325
+ const nestedDim = new EvaluationStringResult( {
326
+ value: 'nested',
327
+ confidence: 0.9,
328
+ dimensions: [
329
+ new EvaluationNumberResult( { value: 10, confidence: 0.8 } )
330
+ ]
331
+ } );
332
+ const result = new EvaluationResult( {
333
+ value: 'main',
334
+ confidence: 0.7,
335
+ dimensions: [ nestedDim ]
336
+ } );
337
+ expect( result.dimensions ).toHaveLength( 1 );
338
+ expect( result.dimensions[0].dimensions ).toHaveLength( 1 );
339
+ expect( result.dimensions[0].dimensions[0].value ).toBe( 10 );
340
+ } );
341
+
342
+ it( 'accepts nested dimensions with plain objects', () => {
343
+ const result = new EvaluationResult( {
344
+ value: 'main',
345
+ confidence: 0.7,
346
+ dimensions: [
347
+ {
348
+ value: 'nested',
349
+ confidence: 0.9,
350
+ dimensions: [
351
+ { value: 10, confidence: 0.8 }
352
+ ]
353
+ }
354
+ ]
355
+ } );
356
+ expect( result.dimensions ).toHaveLength( 1 );
357
+ expect( result.dimensions[0].dimensions ).toHaveLength( 1 );
358
+ expect( result.dimensions[0].dimensions[0].value ).toBe( 10 );
359
+ } );
360
+
361
+ it( 'accepts feedback array with EvaluationFeedback instances', () => {
362
+ const feedback1 = new EvaluationFeedback( {
363
+ issue: 'Issue 1',
364
+ suggestion: 'Fix this',
365
+ priority: 'high'
366
+ } );
367
+ const feedback2 = new EvaluationFeedback( {
368
+ issue: 'Issue 2',
369
+ reference: 'ref-123'
370
+ } );
371
+ const result = new EvaluationResult( {
372
+ value: 'test',
373
+ confidence: 0.8,
374
+ feedback: [ feedback1, feedback2 ]
375
+ } );
376
+ expect( result.feedback ).toHaveLength( 2 );
377
+ expect( result.feedback[0] ).toBe( feedback1 );
378
+ expect( result.feedback[1] ).toBe( feedback2 );
379
+ } );
380
+
381
+ it( 'accepts feedback array with plain objects matching schema', () => {
382
+ const result = new EvaluationResult( {
383
+ value: 'test',
384
+ confidence: 0.8,
385
+ feedback: [
386
+ { issue: 'Issue 1', suggestion: 'Fix', priority: 'high' },
387
+ { issue: 'Issue 2', reference: 'ref-123' }
388
+ ]
389
+ } );
390
+ expect( result.feedback ).toHaveLength( 2 );
391
+ expect( result.feedback[0].issue ).toBe( 'Issue 1' );
392
+ expect( result.feedback[1].issue ).toBe( 'Issue 2' );
393
+ } );
394
+
395
+ it( 'feedback defaults to empty array when not provided', () => {
396
+ const result = new EvaluationResult( {
397
+ value: 'test',
398
+ confidence: 0.8
399
+ } );
400
+ expect( result.feedback ).toEqual( [] );
401
+ } );
402
+
403
+ it( 'validates feedback must match EvaluationFeedback schema', () => {
404
+ expect( () => new EvaluationResult( {
405
+ value: 'test',
406
+ confidence: 0.8,
407
+ feedback: [ { invalid: 'object' } ]
408
+ } ) ).toThrow( ValidationError );
409
+ } );
410
+
411
+ it( 'validates feedback issue is required', () => {
412
+ expect( () => new EvaluationResult( {
413
+ value: 'test',
414
+ confidence: 0.8,
415
+ feedback: [ { suggestion: 'missing issue' } ]
416
+ } ) ).toThrow( ValidationError );
417
+ } );
418
+
419
+ it( 'validates feedback priority enum values', () => {
420
+ expect( () => new EvaluationResult( {
421
+ value: 'test',
422
+ confidence: 0.8,
423
+ feedback: [ { issue: 'test', priority: 'invalid' } ]
424
+ } ) ).toThrow( ValidationError );
425
+ } );
426
+
427
+ it( 'accepts all new fields together', () => {
428
+ const dim = new EvaluationStringResult( { value: 'dim', confidence: 0.9 } );
429
+ const feedback = new EvaluationFeedback( { issue: 'test issue', priority: 'medium' } );
430
+ const result = new EvaluationResult( {
431
+ value: 'main',
432
+ confidence: 0.8,
433
+ name: 'comprehensive-test',
434
+ dimensions: [ dim ],
435
+ feedback: [ feedback ],
436
+ reasoning: 'test reasoning'
437
+ } );
438
+ expect( result.name ).toBe( 'comprehensive-test' );
439
+ expect( result.dimensions ).toHaveLength( 1 );
440
+ expect( result.feedback ).toHaveLength( 1 );
441
+ expect( result.reasoning ).toBe( 'test reasoning' );
442
+ } );
443
+ } );
444
+ } );
445
+
446
+ describe( 'interface/evaluator - EvaluationFeedback class', () => {
447
+ describe( 'constructor', () => {
448
+ it( 'creates feedback with required issue', () => {
449
+ const feedback = new EvaluationFeedback( { issue: 'Test issue' } );
450
+ expect( feedback.issue ).toBe( 'Test issue' );
451
+ expect( feedback.suggestion ).toBeUndefined();
452
+ expect( feedback.reference ).toBeUndefined();
453
+ expect( feedback.priority ).toBeUndefined();
454
+ } );
455
+
456
+ it( 'creates feedback with all fields', () => {
457
+ const feedback = new EvaluationFeedback( {
458
+ issue: 'Critical bug',
459
+ suggestion: 'Fix immediately',
460
+ reference: 'BUG-123',
461
+ priority: 'critical'
462
+ } );
463
+ expect( feedback.issue ).toBe( 'Critical bug' );
464
+ expect( feedback.suggestion ).toBe( 'Fix immediately' );
465
+ expect( feedback.reference ).toBe( 'BUG-123' );
466
+ expect( feedback.priority ).toBe( 'critical' );
467
+ } );
468
+
469
+ it( 'accepts optional fields', () => {
470
+ const feedback = new EvaluationFeedback( {
471
+ issue: 'Minor issue',
472
+ suggestion: 'Consider fixing'
473
+ } );
474
+ expect( feedback.issue ).toBe( 'Minor issue' );
475
+ expect( feedback.suggestion ).toBe( 'Consider fixing' );
476
+ expect( feedback.reference ).toBeUndefined();
477
+ expect( feedback.priority ).toBeUndefined();
478
+ } );
479
+ } );
480
+
481
+ describe( 'static schema getter', () => {
482
+ it( 'validates required issue field', () => {
483
+ const ok = EvaluationFeedback.schema.safeParse( { issue: 'Test issue' } );
484
+ expect( ok.success ).toBe( true );
485
+
486
+ const bad = EvaluationFeedback.schema.safeParse( {} );
487
+ expect( bad.success ).toBe( false );
488
+ } );
489
+
490
+ it( 'validates issue must be string', () => {
491
+ const bad = EvaluationFeedback.schema.safeParse( { issue: 123 } );
492
+ expect( bad.success ).toBe( false );
493
+ } );
494
+
495
+ it( 'accepts optional suggestion field', () => {
496
+ const ok = EvaluationFeedback.schema.safeParse( {
497
+ issue: 'Test',
498
+ suggestion: 'Fix it'
499
+ } );
500
+ expect( ok.success ).toBe( true );
501
+ } );
502
+
503
+ it( 'validates suggestion must be string if provided', () => {
504
+ const bad = EvaluationFeedback.schema.safeParse( {
505
+ issue: 'Test',
506
+ suggestion: 123
507
+ } );
508
+ expect( bad.success ).toBe( false );
509
+ } );
510
+
511
+ it( 'accepts optional reference field', () => {
512
+ const ok = EvaluationFeedback.schema.safeParse( {
513
+ issue: 'Test',
514
+ reference: 'REF-123'
515
+ } );
516
+ expect( ok.success ).toBe( true );
517
+ } );
518
+
519
+ it( 'validates reference must be string if provided', () => {
520
+ const bad = EvaluationFeedback.schema.safeParse( {
521
+ issue: 'Test',
522
+ reference: 123
523
+ } );
524
+ expect( bad.success ).toBe( false );
525
+ } );
526
+
527
+ it( 'accepts valid priority enum values', () => {
528
+ const priorities = [ 'low', 'medium', 'high', 'critical' ];
529
+ for ( const priority of priorities ) {
530
+ const ok = EvaluationFeedback.schema.safeParse( {
531
+ issue: 'Test',
532
+ priority
533
+ } );
534
+ expect( ok.success ).toBe( true );
535
+ }
536
+ } );
537
+
538
+ it( 'rejects invalid priority values', () => {
539
+ const bad = EvaluationFeedback.schema.safeParse( {
540
+ issue: 'Test',
541
+ priority: 'invalid'
542
+ } );
543
+ expect( bad.success ).toBe( false );
544
+ } );
545
+
546
+ it( 'validates priority must be string if provided', () => {
547
+ const bad = EvaluationFeedback.schema.safeParse( {
548
+ issue: 'Test',
549
+ priority: 123
550
+ } );
551
+ expect( bad.success ).toBe( false );
552
+ } );
553
+
554
+ it( 'accepts all fields together', () => {
555
+ const ok = EvaluationFeedback.schema.safeParse( {
556
+ issue: 'Critical bug',
557
+ suggestion: 'Fix immediately',
558
+ reference: 'BUG-123',
559
+ priority: 'critical'
560
+ } );
561
+ expect( ok.success ).toBe( true );
562
+ } );
563
+ } );
564
+ } );
565
+
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Exports all public methods from the interface
3
+ */
4
+ export * from './webhook.d.ts';
5
+ export * from './workflow_utils.d.ts';
6
+ export * from './step.d.ts';
7
+ export * from './evaluator.d.ts';
8
+ export * from './workflow.d.ts';
9
+ export * from './evaluation_result.d.ts';
@@ -0,0 +1,26 @@
1
+ import {
2
+ EvaluationStringResult,
3
+ EvaluationNumberResult,
4
+ EvaluationBooleanResult,
5
+ EvaluationVerdictResult,
6
+ EvaluationFeedback
7
+ } from './evaluation_result.js';
8
+ import { evaluator } from './evaluator.js';
9
+ import { step } from './step.js';
10
+ import { workflow } from './workflow.js';
11
+ import { executeInParallel } from './workflow_utils.js';
12
+ import { sendHttpRequest, sendPostRequestAndAwaitWebhook } from './webhook.js';
13
+
14
+ export {
15
+ evaluator,
16
+ step,
17
+ workflow,
18
+ EvaluationNumberResult,
19
+ EvaluationStringResult,
20
+ EvaluationBooleanResult,
21
+ EvaluationVerdictResult,
22
+ EvaluationFeedback,
23
+ executeInParallel,
24
+ sendHttpRequest,
25
+ sendPostRequestAndAwaitWebhook
26
+ };