@juspay/neurolink 9.3.0 → 9.5.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 (128) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +8 -8
  3. package/dist/cli/commands/config.d.ts +3 -3
  4. package/dist/cli/index.js +1 -0
  5. package/dist/index.d.ts +35 -0
  6. package/dist/index.js +17 -0
  7. package/dist/lib/agent/directTools.d.ts +5 -5
  8. package/dist/lib/index.d.ts +35 -0
  9. package/dist/lib/index.js +17 -0
  10. package/dist/lib/neurolink.d.ts +12 -1
  11. package/dist/lib/neurolink.js +265 -4
  12. package/dist/lib/server/utils/validation.d.ts +8 -8
  13. package/dist/lib/types/generateTypes.d.ts +28 -0
  14. package/dist/lib/types/index.d.ts +6 -0
  15. package/dist/lib/types/index.js +12 -0
  16. package/dist/lib/types/modelTypes.d.ts +2 -2
  17. package/dist/lib/types/streamTypes.d.ts +35 -0
  18. package/dist/lib/types/workflowTypes.d.ts +558 -0
  19. package/dist/lib/types/workflowTypes.js +32 -0
  20. package/dist/lib/workflow/LAYER-EXAMPLES.d.ts +13 -0
  21. package/dist/lib/workflow/LAYER-EXAMPLES.js +312 -0
  22. package/dist/lib/workflow/PROMPT-EXAMPLES.d.ts +117 -0
  23. package/dist/lib/workflow/PROMPT-EXAMPLES.js +246 -0
  24. package/dist/lib/workflow/config.d.ts +1569 -0
  25. package/dist/lib/workflow/config.js +399 -0
  26. package/dist/lib/workflow/core/ensembleExecutor.d.ts +56 -0
  27. package/dist/lib/workflow/core/ensembleExecutor.js +398 -0
  28. package/dist/lib/workflow/core/judgeScorer.d.ts +26 -0
  29. package/dist/lib/workflow/core/judgeScorer.js +527 -0
  30. package/dist/lib/workflow/core/responseConditioner.d.ts +22 -0
  31. package/dist/lib/workflow/core/responseConditioner.js +226 -0
  32. package/dist/lib/workflow/core/types/conditionerTypes.d.ts +7 -0
  33. package/dist/lib/workflow/core/types/conditionerTypes.js +8 -0
  34. package/dist/lib/workflow/core/types/ensembleTypes.d.ts +7 -0
  35. package/dist/lib/workflow/core/types/ensembleTypes.js +8 -0
  36. package/dist/lib/workflow/core/types/index.d.ts +7 -0
  37. package/dist/lib/workflow/core/types/index.js +8 -0
  38. package/dist/lib/workflow/core/types/judgeTypes.d.ts +7 -0
  39. package/dist/lib/workflow/core/types/judgeTypes.js +8 -0
  40. package/dist/lib/workflow/core/types/layerTypes.d.ts +7 -0
  41. package/dist/lib/workflow/core/types/layerTypes.js +8 -0
  42. package/dist/lib/workflow/core/types/registryTypes.d.ts +7 -0
  43. package/dist/lib/workflow/core/types/registryTypes.js +8 -0
  44. package/dist/lib/workflow/core/workflowRegistry.d.ts +73 -0
  45. package/dist/lib/workflow/core/workflowRegistry.js +305 -0
  46. package/dist/lib/workflow/core/workflowRunner.d.ts +115 -0
  47. package/dist/lib/workflow/core/workflowRunner.js +554 -0
  48. package/dist/lib/workflow/index.d.ts +36 -0
  49. package/dist/lib/workflow/index.js +51 -0
  50. package/dist/lib/workflow/types.d.ts +19 -0
  51. package/dist/lib/workflow/types.js +10 -0
  52. package/dist/lib/workflow/utils/types/index.d.ts +7 -0
  53. package/dist/lib/workflow/utils/types/index.js +8 -0
  54. package/dist/lib/workflow/utils/types/metricsTypes.d.ts +7 -0
  55. package/dist/lib/workflow/utils/types/metricsTypes.js +8 -0
  56. package/dist/lib/workflow/utils/types/validationTypes.d.ts +7 -0
  57. package/dist/lib/workflow/utils/types/validationTypes.js +8 -0
  58. package/dist/lib/workflow/utils/workflowMetrics.d.ts +76 -0
  59. package/dist/lib/workflow/utils/workflowMetrics.js +312 -0
  60. package/dist/lib/workflow/utils/workflowValidation.d.ts +29 -0
  61. package/dist/lib/workflow/utils/workflowValidation.js +421 -0
  62. package/dist/lib/workflow/workflows/adaptiveWorkflow.d.ts +72 -0
  63. package/dist/lib/workflow/workflows/adaptiveWorkflow.js +367 -0
  64. package/dist/lib/workflow/workflows/consensusWorkflow.d.ts +69 -0
  65. package/dist/lib/workflow/workflows/consensusWorkflow.js +193 -0
  66. package/dist/lib/workflow/workflows/fallbackWorkflow.d.ts +49 -0
  67. package/dist/lib/workflow/workflows/fallbackWorkflow.js +226 -0
  68. package/dist/lib/workflow/workflows/multiJudgeWorkflow.d.ts +70 -0
  69. package/dist/lib/workflow/workflows/multiJudgeWorkflow.js +352 -0
  70. package/dist/neurolink.d.ts +12 -1
  71. package/dist/neurolink.js +265 -4
  72. package/dist/types/generateTypes.d.ts +28 -0
  73. package/dist/types/index.d.ts +6 -0
  74. package/dist/types/index.js +12 -0
  75. package/dist/types/streamTypes.d.ts +35 -0
  76. package/dist/types/workflowTypes.d.ts +558 -0
  77. package/dist/types/workflowTypes.js +31 -0
  78. package/dist/workflow/LAYER-EXAMPLES.d.ts +13 -0
  79. package/dist/workflow/LAYER-EXAMPLES.js +311 -0
  80. package/dist/workflow/PROMPT-EXAMPLES.d.ts +117 -0
  81. package/dist/workflow/PROMPT-EXAMPLES.js +245 -0
  82. package/dist/workflow/config.d.ts +1569 -0
  83. package/dist/workflow/config.js +398 -0
  84. package/dist/workflow/core/ensembleExecutor.d.ts +56 -0
  85. package/dist/workflow/core/ensembleExecutor.js +397 -0
  86. package/dist/workflow/core/judgeScorer.d.ts +26 -0
  87. package/dist/workflow/core/judgeScorer.js +526 -0
  88. package/dist/workflow/core/responseConditioner.d.ts +22 -0
  89. package/dist/workflow/core/responseConditioner.js +225 -0
  90. package/dist/workflow/core/types/conditionerTypes.d.ts +7 -0
  91. package/dist/workflow/core/types/conditionerTypes.js +7 -0
  92. package/dist/workflow/core/types/ensembleTypes.d.ts +7 -0
  93. package/dist/workflow/core/types/ensembleTypes.js +7 -0
  94. package/dist/workflow/core/types/index.d.ts +7 -0
  95. package/dist/workflow/core/types/index.js +7 -0
  96. package/dist/workflow/core/types/judgeTypes.d.ts +7 -0
  97. package/dist/workflow/core/types/judgeTypes.js +7 -0
  98. package/dist/workflow/core/types/layerTypes.d.ts +7 -0
  99. package/dist/workflow/core/types/layerTypes.js +7 -0
  100. package/dist/workflow/core/types/registryTypes.d.ts +7 -0
  101. package/dist/workflow/core/types/registryTypes.js +7 -0
  102. package/dist/workflow/core/workflowRegistry.d.ts +73 -0
  103. package/dist/workflow/core/workflowRegistry.js +304 -0
  104. package/dist/workflow/core/workflowRunner.d.ts +115 -0
  105. package/dist/workflow/core/workflowRunner.js +553 -0
  106. package/dist/workflow/index.d.ts +36 -0
  107. package/dist/workflow/index.js +50 -0
  108. package/dist/workflow/types.d.ts +19 -0
  109. package/dist/workflow/types.js +9 -0
  110. package/dist/workflow/utils/types/index.d.ts +7 -0
  111. package/dist/workflow/utils/types/index.js +7 -0
  112. package/dist/workflow/utils/types/metricsTypes.d.ts +7 -0
  113. package/dist/workflow/utils/types/metricsTypes.js +7 -0
  114. package/dist/workflow/utils/types/validationTypes.d.ts +7 -0
  115. package/dist/workflow/utils/types/validationTypes.js +7 -0
  116. package/dist/workflow/utils/workflowMetrics.d.ts +76 -0
  117. package/dist/workflow/utils/workflowMetrics.js +311 -0
  118. package/dist/workflow/utils/workflowValidation.d.ts +29 -0
  119. package/dist/workflow/utils/workflowValidation.js +420 -0
  120. package/dist/workflow/workflows/adaptiveWorkflow.d.ts +72 -0
  121. package/dist/workflow/workflows/adaptiveWorkflow.js +366 -0
  122. package/dist/workflow/workflows/consensusWorkflow.d.ts +69 -0
  123. package/dist/workflow/workflows/consensusWorkflow.js +192 -0
  124. package/dist/workflow/workflows/fallbackWorkflow.d.ts +49 -0
  125. package/dist/workflow/workflows/fallbackWorkflow.js +225 -0
  126. package/dist/workflow/workflows/multiJudgeWorkflow.d.ts +70 -0
  127. package/dist/workflow/workflows/multiJudgeWorkflow.js +351 -0
  128. package/package.json +3 -2
@@ -0,0 +1,558 @@
1
+ /**
2
+ * types/workflowTypes.ts
3
+ * Core type definitions for the Workflow Engine
4
+ *
5
+ * Testing Phase: Focuses on original output + evaluation metrics for AB testing
6
+ */
7
+ import type { AnalyticsData } from "./analytics.js";
8
+ import { AIProviderName } from "../constants/enums.js";
9
+ import type { JsonValue } from "./common.js";
10
+ /**
11
+ * Workflow type enumeration
12
+ */
13
+ export type WorkflowType = "ensemble" | "chain" | "adaptive" | "custom";
14
+ /**
15
+ * Judge output format options
16
+ */
17
+ export type JudgeOutputFormat = "scores" | "ranking" | "best" | "detailed";
18
+ /**
19
+ * Tone adjustment strategy (for future conditioning phase)
20
+ */
21
+ export type ToneAdjustment = "soften" | "strengthen" | "neutral";
22
+ /**
23
+ * Execution strategy for model groups
24
+ */
25
+ export type ExecutionStrategy = "parallel" | "sequential";
26
+ /**
27
+ * Model group for layer-based execution
28
+ * Enables sequential vs parallel control at group level
29
+ */
30
+ export type ModelGroup = {
31
+ id: string;
32
+ name?: string;
33
+ description?: string;
34
+ models: WorkflowModelConfig[];
35
+ executionStrategy: ExecutionStrategy;
36
+ continueOnFailure?: boolean;
37
+ minSuccessful?: number;
38
+ parallelism?: number;
39
+ timeout?: number;
40
+ metadata?: Record<string, JsonValue>;
41
+ };
42
+ /**
43
+ * Workflow configuration
44
+ */
45
+ export type WorkflowConfig = {
46
+ id: string;
47
+ name: string;
48
+ description?: string;
49
+ version?: string;
50
+ type: WorkflowType;
51
+ models: WorkflowModelConfig[];
52
+ modelGroups?: ModelGroup[];
53
+ defaultSystemPrompt?: string;
54
+ defaultJudgePrompt?: string;
55
+ judge?: JudgeConfig;
56
+ judges?: JudgeConfig[];
57
+ conditioning?: ConditioningConfig;
58
+ execution?: ExecutionConfig;
59
+ tags?: string[];
60
+ metadata?: Record<string, JsonValue>;
61
+ createdAt?: string;
62
+ updatedAt?: string;
63
+ };
64
+ /**
65
+ * Model configuration for ensemble
66
+ * Named WorkflowModelConfig to avoid conflict with modelTypes.ModelConfig
67
+ */
68
+ export type WorkflowModelConfig = {
69
+ provider: AIProviderName;
70
+ model: string;
71
+ weight?: number;
72
+ temperature?: number;
73
+ maxTokens?: number;
74
+ systemPrompt?: string;
75
+ timeout?: number;
76
+ topP?: number;
77
+ topK?: number;
78
+ presencePenalty?: number;
79
+ frequencyPenalty?: number;
80
+ label?: string;
81
+ metadata?: Record<string, JsonValue>;
82
+ };
83
+ /**
84
+ * Judge model configuration
85
+ * NOTE: Testing phase uses fixed 0-100 scoring scale
86
+ */
87
+ export type JudgeConfig = {
88
+ provider: AIProviderName;
89
+ model: string;
90
+ criteria: string[];
91
+ outputFormat: JudgeOutputFormat;
92
+ customPrompt?: string;
93
+ systemPrompt?: string;
94
+ temperature?: number;
95
+ maxTokens?: number;
96
+ timeout?: number;
97
+ blindEvaluation?: boolean;
98
+ includeReasoning: boolean;
99
+ synthesizeImprovedResponse?: boolean;
100
+ scoreScale: {
101
+ min: 0;
102
+ max: 100;
103
+ };
104
+ label?: string;
105
+ metadata?: Record<string, JsonValue>;
106
+ };
107
+ /**
108
+ * Response conditioning configuration
109
+ * NOTE: Testing phase - stub only, no actual conditioning
110
+ */
111
+ export type ConditioningConfig = {
112
+ enabled?: boolean;
113
+ useConfidence: boolean;
114
+ confidenceThresholds?: {
115
+ high: number;
116
+ medium: number;
117
+ low: number;
118
+ };
119
+ synthesisModel?: {
120
+ provider: string;
121
+ model: string;
122
+ temperature?: number;
123
+ };
124
+ toneAdjustment?: ToneAdjustment;
125
+ includeMetadata?: boolean;
126
+ metadataFields?: string[];
127
+ addConfidenceStatement?: boolean;
128
+ addModelAttribution?: boolean;
129
+ addExecutionTime?: boolean;
130
+ metadata?: Record<string, JsonValue>;
131
+ };
132
+ /**
133
+ * Workflow execution configuration
134
+ */
135
+ export type ExecutionConfig = {
136
+ timeout?: number;
137
+ modelTimeout?: number;
138
+ judgeTimeout?: number;
139
+ retries?: number;
140
+ retryDelay?: number;
141
+ retryableErrors?: string[];
142
+ parallelism?: number;
143
+ earlyTermination?: boolean;
144
+ minResponses?: number;
145
+ maxCost?: number;
146
+ costThreshold?: number;
147
+ enableMetrics?: boolean;
148
+ enableTracing?: boolean;
149
+ metadata?: Record<string, JsonValue>;
150
+ };
151
+ /**
152
+ * Input for workflow execution
153
+ */
154
+ export type WorkflowInput = {
155
+ text: string;
156
+ context?: Record<string, JsonValue>;
157
+ metadata?: Record<string, JsonValue>;
158
+ };
159
+ /**
160
+ * Options for workflow execution
161
+ */
162
+ export type WorkflowGenerateOptions = {
163
+ workflowId: string;
164
+ input: WorkflowInput;
165
+ overrides?: Partial<WorkflowConfig>;
166
+ timeout?: number;
167
+ enableAnalytics?: boolean;
168
+ enableEvaluation?: boolean;
169
+ context?: Record<string, JsonValue>;
170
+ };
171
+ /**
172
+ * Complete workflow execution result
173
+ * Returns both original and conditioned responses for comparison
174
+ */
175
+ export type WorkflowResult = {
176
+ content: string;
177
+ originalContent?: string;
178
+ score: number;
179
+ reasoning: string;
180
+ ensembleResponses: EnsembleResponse[];
181
+ judgeScores?: JudgeScores;
182
+ selectedResponse?: EnsembleResponse;
183
+ confidence: number;
184
+ consensus?: number;
185
+ totalTime: number;
186
+ ensembleTime: number;
187
+ judgeTime?: number;
188
+ conditioningTime?: number;
189
+ workflow: string;
190
+ workflowName: string;
191
+ workflowVersion?: string;
192
+ usage?: AggregatedUsage;
193
+ cost?: number;
194
+ analytics?: WorkflowAnalytics;
195
+ evaluation?: WorkflowEvaluationData;
196
+ metadata?: Record<string, JsonValue>;
197
+ timestamp: string;
198
+ };
199
+ /**
200
+ * Single ensemble model response
201
+ */
202
+ export type EnsembleResponse = {
203
+ provider: string;
204
+ model: string;
205
+ modelLabel?: string;
206
+ content: string;
207
+ responseTime: number;
208
+ usage?: {
209
+ inputTokens: number;
210
+ outputTokens: number;
211
+ totalTokens: number;
212
+ };
213
+ status: "success" | "failure" | "timeout" | "partial";
214
+ error?: string;
215
+ metadata?: Record<string, JsonValue>;
216
+ timestamp: string;
217
+ };
218
+ /**
219
+ * Judge scoring results
220
+ * NOTE: Scores are 0-100 for standardized evaluation
221
+ */
222
+ export type JudgeScores = {
223
+ judgeProvider: string;
224
+ judgeModel: string;
225
+ scores: Record<string, number>;
226
+ ranking?: string[];
227
+ bestResponse?: string;
228
+ criteria: string[];
229
+ reasoning?: string;
230
+ synthesizedResponse?: string;
231
+ confidenceInJudgment?: number;
232
+ judgeTime: number;
233
+ metadata?: Record<string, JsonValue>;
234
+ timestamp: string;
235
+ };
236
+ /**
237
+ * Multi-judge voting results
238
+ */
239
+ export type MultiJudgeScores = {
240
+ judges: JudgeScores[];
241
+ averageScores: Record<string, number>;
242
+ aggregatedRanking: string[];
243
+ consensusLevel: number;
244
+ bestResponse: string;
245
+ confidence: number;
246
+ votingStrategy: "average" | "median" | "majority";
247
+ metadata?: Record<string, JsonValue>;
248
+ judgeProvider?: string;
249
+ judgeModel?: string;
250
+ scores: Record<string, number>;
251
+ ranking?: string[];
252
+ reasoning?: string;
253
+ confidenceInJudgment?: number;
254
+ criteria: string[];
255
+ judgeTime: number;
256
+ timestamp: string;
257
+ };
258
+ /**
259
+ * Aggregated token usage across all models
260
+ */
261
+ export type AggregatedUsage = {
262
+ totalInputTokens: number;
263
+ totalOutputTokens: number;
264
+ totalTokens: number;
265
+ byModel: Array<{
266
+ provider: string;
267
+ model: string;
268
+ inputTokens: number;
269
+ outputTokens: number;
270
+ totalTokens: number;
271
+ cost?: number;
272
+ }>;
273
+ judgeUsage?: {
274
+ inputTokens: number;
275
+ outputTokens: number;
276
+ totalTokens: number;
277
+ cost?: number;
278
+ };
279
+ };
280
+ /**
281
+ * Workflow-specific analytics
282
+ */
283
+ export type WorkflowAnalytics = AnalyticsData & {
284
+ workflowId: string;
285
+ workflowType: WorkflowType;
286
+ modelsExecuted: number;
287
+ modelsSuccessful: number;
288
+ modelsFailed: number;
289
+ averageConfidence: number;
290
+ consensusLevel?: number;
291
+ modelResponseTimes: Record<string, number>;
292
+ fastestModel?: string;
293
+ slowestModel?: string;
294
+ totalCost: number;
295
+ costByModel: Record<string, number>;
296
+ costEfficiency?: number;
297
+ };
298
+ /**
299
+ * Evaluation data type for workflows
300
+ * Named WorkflowEvaluationData to avoid conflict with evaluation.EvaluationData
301
+ */
302
+ export type WorkflowEvaluationData = {
303
+ relevance: number;
304
+ accuracy: number;
305
+ completeness: number;
306
+ overall: number;
307
+ reasoning?: string;
308
+ };
309
+ /**
310
+ * Workflow validation result
311
+ */
312
+ export type WorkflowValidationResult = {
313
+ valid: boolean;
314
+ errors: WorkflowValidationError[];
315
+ warnings: WorkflowValidationWarning[];
316
+ };
317
+ /**
318
+ * Validation error
319
+ */
320
+ export type WorkflowValidationError = {
321
+ field: string;
322
+ message: string;
323
+ code: string;
324
+ severity: "error" | "critical";
325
+ };
326
+ /**
327
+ * Validation warning
328
+ */
329
+ export type WorkflowValidationWarning = {
330
+ field: string;
331
+ message: string;
332
+ code: string;
333
+ recommendation?: string;
334
+ };
335
+ /**
336
+ * Workflow execution error details
337
+ */
338
+ export type WorkflowErrorDetails = {
339
+ code: string;
340
+ workflowId: string;
341
+ phase: "ensemble" | "judge" | "conditioning" | "validation";
342
+ details?: Record<string, JsonValue>;
343
+ retryable: boolean;
344
+ originalError?: Error;
345
+ };
346
+ /**
347
+ * Workflow execution error class
348
+ */
349
+ export declare class WorkflowError extends Error {
350
+ readonly details: WorkflowErrorDetails;
351
+ constructor(message: string, details: WorkflowErrorDetails);
352
+ }
353
+ /**
354
+ * Options for ensemble execution
355
+ */
356
+ export type ExecuteEnsembleOptions = {
357
+ prompt: string;
358
+ models: WorkflowModelConfig[];
359
+ executionConfig?: ExecutionConfig;
360
+ systemPrompt?: string;
361
+ workflowDefaults?: {
362
+ systemPrompt?: string;
363
+ };
364
+ };
365
+ /**
366
+ * Result of ensemble execution
367
+ */
368
+ export type EnsembleExecutionResult = {
369
+ responses: EnsembleResponse[];
370
+ totalTime: number;
371
+ successCount: number;
372
+ failureCount: number;
373
+ errors: WorkflowError[];
374
+ };
375
+ /**
376
+ * Options for single model execution (internal)
377
+ */
378
+ export type ExecuteModelOptions = {
379
+ model: WorkflowModelConfig;
380
+ prompt: string;
381
+ systemPrompt?: string;
382
+ timeout: number;
383
+ };
384
+ /**
385
+ * Options for judge scoring
386
+ */
387
+ export type ScoreOptions = {
388
+ judges: JudgeConfig[];
389
+ responses: EnsembleResponse[];
390
+ originalPrompt: string;
391
+ systemPrompt?: string;
392
+ timeout?: number;
393
+ workflowDefaults?: {
394
+ judgePrompt?: string;
395
+ };
396
+ };
397
+ /**
398
+ * Result of judge scoring
399
+ */
400
+ export type ScoreResult = {
401
+ scores: JudgeScores | MultiJudgeScores;
402
+ judgeTime: number;
403
+ error?: WorkflowError;
404
+ };
405
+ /**
406
+ * Parsed judge response (internal)
407
+ */
408
+ export type ParsedJudgeResponse = {
409
+ scores: Record<string, number>;
410
+ ranking?: string[];
411
+ bestResponse?: string;
412
+ reasoning?: string;
413
+ synthesizedResponse?: string;
414
+ confidenceInJudgment?: number;
415
+ };
416
+ /**
417
+ * Options for response conditioning
418
+ */
419
+ export type ConditionOptions = {
420
+ content: string;
421
+ selectedResponse: EnsembleResponse;
422
+ allResponses: EnsembleResponse[];
423
+ judgeScores?: JudgeScores | MultiJudgeScores;
424
+ config?: ConditioningConfig;
425
+ originalPrompt?: string;
426
+ };
427
+ /**
428
+ * Result of response conditioning
429
+ */
430
+ export type ConditionResult = {
431
+ content: string;
432
+ conditioningTime: number;
433
+ metadata?: {
434
+ conditioningApplied: boolean;
435
+ originalLength: number;
436
+ finalLength: number;
437
+ confidenceStatementAdded?: boolean;
438
+ modelAttributionAdded?: boolean;
439
+ executionTimeAdded?: boolean;
440
+ synthesisApplied?: boolean;
441
+ };
442
+ };
443
+ /**
444
+ * Result of executing a single layer/group
445
+ */
446
+ export type LayerExecutionResult = {
447
+ groupId: string;
448
+ responses: EnsembleResponse[];
449
+ successCount: number;
450
+ failureCount: number;
451
+ executionTime: number;
452
+ shouldContinue: boolean;
453
+ };
454
+ /**
455
+ * Options for layer execution
456
+ */
457
+ export type ExecuteLayerOptions = {
458
+ group: ModelGroup;
459
+ prompt: string;
460
+ systemPrompt?: string;
461
+ workflowDefaultSystemPrompt?: string;
462
+ };
463
+ /**
464
+ * Registry entry with metadata (internal)
465
+ */
466
+ export type RegistryEntry = {
467
+ config: WorkflowConfig;
468
+ registeredAt: string;
469
+ lastUsed?: string;
470
+ usageCount: number;
471
+ };
472
+ /**
473
+ * Options for workflow registration
474
+ */
475
+ export type RegisterOptions = {
476
+ validateBeforeRegister?: boolean;
477
+ allowOverwrite?: boolean;
478
+ };
479
+ /**
480
+ * Result of registration operation
481
+ */
482
+ export type RegisterResult = {
483
+ success: boolean;
484
+ workflowId: string;
485
+ validation?: WorkflowValidationResult;
486
+ error?: string;
487
+ };
488
+ /**
489
+ * Options for workflow listing
490
+ */
491
+ export type ListOptions = {
492
+ type?: string;
493
+ tags?: string[];
494
+ limit?: number;
495
+ offset?: number;
496
+ };
497
+ /**
498
+ * Workflow metadata
499
+ */
500
+ export type WorkflowMetadata = {
501
+ registeredAt: string;
502
+ lastUsed?: string;
503
+ usageCount: number;
504
+ };
505
+ /**
506
+ * Registry statistics
507
+ */
508
+ export type RegistryStats = {
509
+ totalWorkflows: number;
510
+ byType: Record<string, number>;
511
+ totalUsage: number;
512
+ mostUsed?: {
513
+ id: string;
514
+ name: string;
515
+ count: number;
516
+ };
517
+ };
518
+ /**
519
+ * Workflow execution metrics (internal)
520
+ */
521
+ export type WorkflowExecutionMetrics = {
522
+ workflowId: string;
523
+ executionCount: number;
524
+ successCount: number;
525
+ failureCount: number;
526
+ averageExecutionTime: number;
527
+ averageScore: number;
528
+ averageConfidence: number;
529
+ totalCost: number;
530
+ lastExecutionTime: string;
531
+ };
532
+ /**
533
+ * Summary statistics for workflow executions
534
+ */
535
+ export type SummaryStats = {
536
+ totalExecutions: number;
537
+ averageScore: number;
538
+ averageConfidence: number;
539
+ averageExecutionTime: number;
540
+ successRate: number;
541
+ totalCost: number;
542
+ };
543
+ /**
544
+ * Result of comparing two workflows
545
+ */
546
+ export type WorkflowComparison = {
547
+ workflow1: SummaryStats;
548
+ workflow2: SummaryStats;
549
+ winner: "workflow1" | "workflow2" | "tie";
550
+ reasoning: string;
551
+ };
552
+ /**
553
+ * Validation result containing errors and warnings
554
+ */
555
+ export type ValidationIssues = {
556
+ errors: WorkflowValidationError[];
557
+ warnings: WorkflowValidationWarning[];
558
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * types/workflowTypes.ts
3
+ * Core type definitions for the Workflow Engine
4
+ *
5
+ * Testing Phase: Focuses on original output + evaluation metrics for AB testing
6
+ */
7
+ import { AIProviderName } from "../constants/enums.js";
8
+ /**
9
+ * Workflow execution error class
10
+ */
11
+ export class WorkflowError extends Error {
12
+ details;
13
+ constructor(message, details) {
14
+ super(message);
15
+ this.name = "WorkflowError";
16
+ this.details = details;
17
+ // Maintain proper stack trace for V8 engines
18
+ if ("captureStackTrace" in Error &&
19
+ typeof Error.captureStackTrace === "function") {
20
+ Error.captureStackTrace(this, WorkflowError);
21
+ }
22
+ }
23
+ }
24
+ // ============================================================================
25
+ // TYPE ALIASES FOR BACKWARD COMPATIBILITY (internal to workflow module only)
26
+ // ============================================================================
27
+ // Note: ModelConfig and EvaluationData aliases are NOT exported from this file
28
+ // to avoid conflicts with modelTypes.ModelConfig and evaluation.EvaluationData.
29
+ // Use WorkflowModelConfig and WorkflowEvaluationData when importing from this file.
30
+ // The workflow/types.ts re-exports these aliases for backward compatibility
31
+ // within the workflow module only.
32
+ //# sourceMappingURL=workflowTypes.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * LAYER-BASED EXECUTION - USAGE EXAMPLES
3
+ * ======================================
4
+ *
5
+ * Demonstrates ModelGroup-based execution with sequential and parallel strategies
6
+ */
7
+ import type { WorkflowConfig } from "./types.js";
8
+ declare const simpleParallelWorkflow: WorkflowConfig;
9
+ declare const fastThenPremiumWorkflow: WorkflowConfig;
10
+ declare const fallbackChainWorkflow: WorkflowConfig;
11
+ declare const mixedStrategyWorkflow: WorkflowConfig;
12
+ declare const costOptimizedWorkflow: WorkflowConfig;
13
+ export { simpleParallelWorkflow, fastThenPremiumWorkflow, fallbackChainWorkflow, mixedStrategyWorkflow, costOptimizedWorkflow, };