@goreal-ai/echo-pdk 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.
- package/dist/ai-judge/index.d.ts +177 -0
- package/dist/ai-judge/index.d.ts.map +1 -0
- package/dist/ai-judge/index.js +299 -0
- package/dist/ai-judge/index.js.map +1 -0
- package/dist/evaluator/evaluator.d.ts +136 -0
- package/dist/evaluator/evaluator.d.ts.map +1 -0
- package/dist/evaluator/evaluator.js +407 -0
- package/dist/evaluator/evaluator.js.map +1 -0
- package/dist/evaluator/index.d.ts +7 -0
- package/dist/evaluator/index.d.ts.map +1 -0
- package/dist/evaluator/index.js +8 -0
- package/dist/evaluator/index.js.map +1 -0
- package/dist/evaluator/operators.d.ts +105 -0
- package/dist/evaluator/operators.d.ts.map +1 -0
- package/dist/evaluator/operators.js +371 -0
- package/dist/evaluator/operators.js.map +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/ast.d.ts +106 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +260 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +13 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/lexer.d.ts +199 -0
- package/dist/parser/lexer.d.ts.map +1 -0
- package/dist/parser/lexer.js +491 -0
- package/dist/parser/lexer.js.map +1 -0
- package/dist/parser/parser.d.ts +49 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +615 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/plugins/index.d.ts +62 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +170 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +5 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/renderer.d.ts +97 -0
- package/dist/renderer/renderer.d.ts.map +1 -0
- package/dist/renderer/renderer.js +243 -0
- package/dist/renderer/renderer.js.map +1 -0
- package/dist/types.d.ts +255 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Echo Evaluator - Condition evaluation engine
|
|
3
|
+
*
|
|
4
|
+
* This file implements the evaluator for Echo DSL.
|
|
5
|
+
* The evaluator processes the AST and determines which nodes should be rendered
|
|
6
|
+
* based on the provided context and condition evaluation.
|
|
7
|
+
*
|
|
8
|
+
* KEY OPTIMIZATION: AI JUDGE PARALLELIZATION
|
|
9
|
+
* Before evaluating the AST, we:
|
|
10
|
+
* 1. Collect ALL #ai_judge conditions from the tree
|
|
11
|
+
* 2. Evaluate them in parallel using Promise.all
|
|
12
|
+
* 3. Cache the results
|
|
13
|
+
* 4. Use cached results during tree evaluation
|
|
14
|
+
*
|
|
15
|
+
* This prevents sequential blocking on AI calls.
|
|
16
|
+
*/
|
|
17
|
+
import { collectAiJudgeConditions } from '../parser/ast.js';
|
|
18
|
+
import { getOperator } from './operators.js';
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a variable path from context.
|
|
21
|
+
*
|
|
22
|
+
* Supports:
|
|
23
|
+
* - Simple: "name" -> context.name
|
|
24
|
+
* - Nested: "user.name" -> context.user.name
|
|
25
|
+
* - Array: "items[0]" -> context.items[0]
|
|
26
|
+
* - Mixed: "users[0].name" -> context.users[0].name
|
|
27
|
+
*
|
|
28
|
+
* @param path - The variable path
|
|
29
|
+
* @param context - The context object
|
|
30
|
+
* @param options - Resolution options
|
|
31
|
+
* @returns The resolved value or undefined
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const context = { user: { name: 'Alice' }, items: [1, 2, 3] };
|
|
36
|
+
* resolveVariable('user.name', context); // 'Alice'
|
|
37
|
+
* resolveVariable('items[0]', context); // 1
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function resolveVariable(path, context, options = {}) {
|
|
41
|
+
const { strict = false } = options;
|
|
42
|
+
// Handle array access within parts: "items[0].name" -> ["items[0]", "name"]
|
|
43
|
+
// Then further split "items[0]" into array access
|
|
44
|
+
const parts = path.split('.');
|
|
45
|
+
let current = context;
|
|
46
|
+
for (const part of parts) {
|
|
47
|
+
if (current === undefined || current === null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Validate array access patterns before splitting
|
|
51
|
+
// This catches malformed patterns like items[], items[abc], items[-1]
|
|
52
|
+
if (strict) {
|
|
53
|
+
validateArrayAccessPattern(part, path);
|
|
54
|
+
}
|
|
55
|
+
// Check for array access pattern: "items[0]" or "items[0][1]"
|
|
56
|
+
const segments = part.split(/(\[\d+\])/g).filter(Boolean);
|
|
57
|
+
for (const segment of segments) {
|
|
58
|
+
if (current === undefined || current === null) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const arrayMatch = segment.match(/^\[(\d+)\]$/);
|
|
62
|
+
if (arrayMatch && arrayMatch[1]) {
|
|
63
|
+
// Array index access
|
|
64
|
+
const index = parseInt(arrayMatch[1], 10);
|
|
65
|
+
if (Array.isArray(current)) {
|
|
66
|
+
current = current[index];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (strict) {
|
|
70
|
+
throw new Error(`Cannot access index [${index}] on non-array value in path "${path}"`);
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Property access
|
|
77
|
+
current = current[segment];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return current;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validate array access patterns in a path segment.
|
|
85
|
+
* Throws descriptive errors for malformed patterns in strict mode.
|
|
86
|
+
*
|
|
87
|
+
* @param segment - A single path segment (e.g., "items[0]" or "name")
|
|
88
|
+
* @param fullPath - The full path for error messages
|
|
89
|
+
*/
|
|
90
|
+
function validateArrayAccessPattern(segment, fullPath) {
|
|
91
|
+
// Find all bracket patterns in the segment
|
|
92
|
+
const bracketPattern = /\[([^\]]*)\]/g;
|
|
93
|
+
let match;
|
|
94
|
+
while ((match = bracketPattern.exec(segment)) !== null) {
|
|
95
|
+
const bracketContent = match[1] ?? '';
|
|
96
|
+
// Empty brackets: items[]
|
|
97
|
+
if (bracketContent === '') {
|
|
98
|
+
throw new Error(`Invalid array access "[]" in path "${fullPath}". Array index must be a non-negative integer.`);
|
|
99
|
+
}
|
|
100
|
+
// Non-numeric content: items[abc]
|
|
101
|
+
if (!/^\d+$/.test(bracketContent)) {
|
|
102
|
+
// Check for negative index
|
|
103
|
+
if (/^-\d+$/.test(bracketContent)) {
|
|
104
|
+
throw new Error(`Invalid array access "[${bracketContent}]" in path "${fullPath}". Negative indices are not supported.`);
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`Invalid array access "[${bracketContent}]" in path "${fullPath}". Array index must be a non-negative integer.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Check for unclosed brackets: items[0
|
|
110
|
+
const openBrackets = (segment.match(/\[/g) || []).length;
|
|
111
|
+
const closeBrackets = (segment.match(/\]/g) || []).length;
|
|
112
|
+
if (openBrackets !== closeBrackets) {
|
|
113
|
+
throw new Error(`Malformed array access in path "${fullPath}". Unclosed or unmatched brackets.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// =============================================================================
|
|
117
|
+
// CONDITION EVALUATION
|
|
118
|
+
// =============================================================================
|
|
119
|
+
/**
|
|
120
|
+
* Evaluate a condition expression.
|
|
121
|
+
*
|
|
122
|
+
* @param condition - The condition to evaluate
|
|
123
|
+
* @param ctx - The evaluation context
|
|
124
|
+
* @returns true if condition is satisfied
|
|
125
|
+
*/
|
|
126
|
+
export async function evaluateCondition(condition, ctx) {
|
|
127
|
+
// Get the variable value
|
|
128
|
+
const value = resolveVariable(condition.variable, ctx.variables, {
|
|
129
|
+
strict: ctx.config.strict,
|
|
130
|
+
});
|
|
131
|
+
// Check for pre-resolved AI judge result
|
|
132
|
+
if (condition.isAiJudge) {
|
|
133
|
+
const cacheKey = createAiJudgeCacheKey(condition.variable, value, condition.argument);
|
|
134
|
+
const cached = ctx.aiJudgeResults.get(cacheKey);
|
|
135
|
+
if (cached !== undefined) {
|
|
136
|
+
return cached;
|
|
137
|
+
}
|
|
138
|
+
// Fall through to operator evaluation if not cached
|
|
139
|
+
}
|
|
140
|
+
// Get the operator (strip # if present)
|
|
141
|
+
const operatorName = condition.operator.replace(/^#/, '');
|
|
142
|
+
const operator = ctx.operators.get(operatorName) ?? getOperator(operatorName);
|
|
143
|
+
if (!operator) {
|
|
144
|
+
// Unknown operator - treat as false in lenient mode, throw in strict
|
|
145
|
+
if (ctx.config.strict) {
|
|
146
|
+
throw new Error(`Unknown operator: #${operatorName}`);
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
// Evaluate the operator
|
|
151
|
+
try {
|
|
152
|
+
const result = await operator.handler(value, condition.argument);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (ctx.config.strict) {
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
// Lenient mode: treat errors as false
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Create a cache key for AI judge results.
|
|
165
|
+
*/
|
|
166
|
+
function createAiJudgeCacheKey(variable, value, argument) {
|
|
167
|
+
return JSON.stringify({ variable, value, argument });
|
|
168
|
+
}
|
|
169
|
+
// =============================================================================
|
|
170
|
+
// AI JUDGE PARALLEL EVALUATION
|
|
171
|
+
// =============================================================================
|
|
172
|
+
/**
|
|
173
|
+
* Pre-evaluate all AI judge conditions in parallel.
|
|
174
|
+
*
|
|
175
|
+
* This is the key optimization for performance.
|
|
176
|
+
* Call this before evaluating the AST to pre-resolve all AI conditions.
|
|
177
|
+
*
|
|
178
|
+
* @param ast - The AST to scan for AI judges
|
|
179
|
+
* @param ctx - The evaluation context (will be mutated with results)
|
|
180
|
+
*/
|
|
181
|
+
export async function preEvaluateAiJudges(ast, ctx) {
|
|
182
|
+
// Collect all AI judge conditions
|
|
183
|
+
const aiJudges = collectAiJudgeConditions(ast);
|
|
184
|
+
if (aiJudges.length === 0) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// Prepare evaluation promises
|
|
188
|
+
const evaluations = aiJudges.map(async ({ condition }) => {
|
|
189
|
+
const value = resolveVariable(condition.variable, ctx.variables, {
|
|
190
|
+
strict: ctx.config.strict,
|
|
191
|
+
});
|
|
192
|
+
const cacheKey = createAiJudgeCacheKey(condition.variable, value, condition.argument);
|
|
193
|
+
// Skip if already cached
|
|
194
|
+
if (ctx.aiJudgeResults.has(cacheKey)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
// Evaluate using the AI judge operator
|
|
198
|
+
const operator = ctx.operators.get('ai_judge') ?? getOperator('ai_judge');
|
|
199
|
+
if (!operator) {
|
|
200
|
+
throw new Error('AI Judge operator not available');
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const result = await operator.handler(value, condition.argument);
|
|
204
|
+
ctx.aiJudgeResults.set(cacheKey, result);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
// Handle AI evaluation error
|
|
208
|
+
if (ctx.config.strict) {
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
// Lenient: default to false
|
|
212
|
+
ctx.aiJudgeResults.set(cacheKey, false);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
// Evaluate all in parallel
|
|
216
|
+
await Promise.all(evaluations);
|
|
217
|
+
}
|
|
218
|
+
// =============================================================================
|
|
219
|
+
// AST EVALUATION
|
|
220
|
+
// =============================================================================
|
|
221
|
+
/**
|
|
222
|
+
* Evaluate a conditional node and determine which branch to render.
|
|
223
|
+
*
|
|
224
|
+
* @param node - The conditional node
|
|
225
|
+
* @param ctx - The evaluation context
|
|
226
|
+
* @returns The nodes to render (empty if condition is false with no else)
|
|
227
|
+
*/
|
|
228
|
+
export async function evaluateConditional(node, ctx) {
|
|
229
|
+
// Evaluate the main condition
|
|
230
|
+
const conditionResult = await evaluateCondition(node.condition, ctx);
|
|
231
|
+
if (conditionResult) {
|
|
232
|
+
return node.consequent;
|
|
233
|
+
}
|
|
234
|
+
// Check alternate (ELSE IF or ELSE)
|
|
235
|
+
if (node.alternate) {
|
|
236
|
+
if (Array.isArray(node.alternate)) {
|
|
237
|
+
// ELSE branch
|
|
238
|
+
return node.alternate;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// ELSE IF branch (recursive)
|
|
242
|
+
return evaluateConditional(node.alternate, ctx);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// No matching branch
|
|
246
|
+
return [];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Evaluate a single AST node.
|
|
250
|
+
*
|
|
251
|
+
* @param node - The node to evaluate
|
|
252
|
+
* @param ctx - The evaluation context
|
|
253
|
+
* @returns Array of nodes to render (may be empty, one, or many)
|
|
254
|
+
*/
|
|
255
|
+
async function evaluateNode(node, ctx) {
|
|
256
|
+
switch (node.type) {
|
|
257
|
+
case 'text':
|
|
258
|
+
// Text nodes pass through unchanged
|
|
259
|
+
return [node];
|
|
260
|
+
case 'variable':
|
|
261
|
+
// Variable nodes pass through unchanged (resolved during rendering)
|
|
262
|
+
return [node];
|
|
263
|
+
case 'conditional': {
|
|
264
|
+
// Evaluate condition and get selected branch
|
|
265
|
+
const branchNodes = await evaluateConditional(node, ctx);
|
|
266
|
+
// Recursively evaluate the selected branch
|
|
267
|
+
return evaluateNodes(branchNodes, ctx);
|
|
268
|
+
}
|
|
269
|
+
case 'section': {
|
|
270
|
+
// Store section in context for later [#INCLUDE] references
|
|
271
|
+
ctx.sections.set(node.name, node.body);
|
|
272
|
+
// Sections are not rendered inline
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
case 'import':
|
|
276
|
+
// Import handling: In a full implementation, we would:
|
|
277
|
+
// 1. Read the imported file
|
|
278
|
+
// 2. Parse it
|
|
279
|
+
// 3. Evaluate and inline the result
|
|
280
|
+
// For now, we pass through and let the renderer warn
|
|
281
|
+
return [node];
|
|
282
|
+
case 'include': {
|
|
283
|
+
// Include handling: inline the section content
|
|
284
|
+
const includeNode = node;
|
|
285
|
+
const sectionContent = ctx.sections.get(includeNode.name);
|
|
286
|
+
if (sectionContent) {
|
|
287
|
+
// Recursively evaluate the section content
|
|
288
|
+
return evaluateNodes(sectionContent, ctx);
|
|
289
|
+
}
|
|
290
|
+
// Section not found - pass through and let renderer warn
|
|
291
|
+
if (ctx.config.strict) {
|
|
292
|
+
throw new Error(`Section not found: ${includeNode.name}`);
|
|
293
|
+
}
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
default: {
|
|
297
|
+
// Exhaustiveness check
|
|
298
|
+
const _exhaustive = node;
|
|
299
|
+
throw new Error(`Unknown node type: ${_exhaustive.type}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Evaluate an array of AST nodes.
|
|
305
|
+
*
|
|
306
|
+
* @param nodes - The nodes to evaluate
|
|
307
|
+
* @param ctx - The evaluation context
|
|
308
|
+
* @returns Flattened array of nodes to render
|
|
309
|
+
*/
|
|
310
|
+
async function evaluateNodes(nodes, ctx) {
|
|
311
|
+
const results = [];
|
|
312
|
+
for (const node of nodes) {
|
|
313
|
+
const evaluated = await evaluateNode(node, ctx);
|
|
314
|
+
results.push(...evaluated);
|
|
315
|
+
}
|
|
316
|
+
return results;
|
|
317
|
+
}
|
|
318
|
+
// =============================================================================
|
|
319
|
+
// SECTION COLLECTION (First Pass)
|
|
320
|
+
// =============================================================================
|
|
321
|
+
/**
|
|
322
|
+
* Collect all section definitions from the AST.
|
|
323
|
+
* This is a first pass to ensure sections are available before includes.
|
|
324
|
+
*
|
|
325
|
+
* @param nodes - The AST nodes to scan
|
|
326
|
+
* @param sections - Map to store section definitions
|
|
327
|
+
*/
|
|
328
|
+
function collectSections(nodes, sections) {
|
|
329
|
+
for (const node of nodes) {
|
|
330
|
+
if (node.type === 'section') {
|
|
331
|
+
const sectionNode = node;
|
|
332
|
+
sections.set(sectionNode.name, sectionNode.body);
|
|
333
|
+
// Also scan inside the section for nested sections
|
|
334
|
+
collectSections(sectionNode.body, sections);
|
|
335
|
+
}
|
|
336
|
+
else if (node.type === 'conditional') {
|
|
337
|
+
const conditionalNode = node;
|
|
338
|
+
collectSections(conditionalNode.consequent, sections);
|
|
339
|
+
if (conditionalNode.alternate) {
|
|
340
|
+
if (Array.isArray(conditionalNode.alternate)) {
|
|
341
|
+
collectSections(conditionalNode.alternate, sections);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
collectSections([conditionalNode.alternate], sections);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// =============================================================================
|
|
351
|
+
// MAIN EVALUATE FUNCTION
|
|
352
|
+
// =============================================================================
|
|
353
|
+
/**
|
|
354
|
+
* Evaluate an AST with the given context.
|
|
355
|
+
*
|
|
356
|
+
* This is the main entry point for AST evaluation. It:
|
|
357
|
+
* 1. Collects section definitions (first pass)
|
|
358
|
+
* 2. Pre-evaluates AI judge conditions in parallel
|
|
359
|
+
* 3. Evaluates the AST and selects conditional branches
|
|
360
|
+
* 4. Returns a flattened AST ready for rendering
|
|
361
|
+
*
|
|
362
|
+
* @param ast - The AST to evaluate
|
|
363
|
+
* @param context - Variable context
|
|
364
|
+
* @param config - Echo configuration
|
|
365
|
+
* @param operators - Custom operators (from plugins)
|
|
366
|
+
* @returns Evaluated AST and section map
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```typescript
|
|
370
|
+
* const result = await evaluate(ast, { name: 'Alice', age: 25 });
|
|
371
|
+
* console.log(result.ast); // Flattened, evaluated AST
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
export async function evaluate(ast, context, config = {}, operators = new Map()) {
|
|
375
|
+
// Create evaluation context
|
|
376
|
+
const ctx = {
|
|
377
|
+
variables: context,
|
|
378
|
+
aiJudgeResults: new Map(),
|
|
379
|
+
config,
|
|
380
|
+
sections: new Map(),
|
|
381
|
+
operators,
|
|
382
|
+
};
|
|
383
|
+
// First pass: collect all section definitions
|
|
384
|
+
collectSections(ast, ctx.sections);
|
|
385
|
+
// Pre-evaluate AI judges in parallel (optimization!)
|
|
386
|
+
await preEvaluateAiJudges(ast, ctx);
|
|
387
|
+
// Second pass: evaluate the AST
|
|
388
|
+
const evaluatedAst = await evaluateNodes(ast, ctx);
|
|
389
|
+
return { ast: evaluatedAst, sections: ctx.sections };
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Create an evaluation context manually.
|
|
393
|
+
* Useful for advanced use cases where you need more control.
|
|
394
|
+
*
|
|
395
|
+
* @param options - Context options
|
|
396
|
+
* @returns A new EvaluationContext
|
|
397
|
+
*/
|
|
398
|
+
export function createEvaluationContext(options) {
|
|
399
|
+
return {
|
|
400
|
+
variables: options.variables,
|
|
401
|
+
aiJudgeResults: new Map(),
|
|
402
|
+
config: options.config ?? {},
|
|
403
|
+
sections: new Map(),
|
|
404
|
+
operators: options.operators ?? new Map(),
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/evaluator/evaluator.ts"],"names":[],"m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AC;IAEnD,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAIvC;IACC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,cAAc,EAAE,IAAI,GAAG,EAAE;QACzB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,GAAG,EAAE;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Evaluator module exports
|
|
3
|
+
*/
|
|
4
|
+
export { evaluate, evaluateCondition, evaluateConditional, resolveVariable, preEvaluateAiJudges, createEvaluationContext, } from './evaluator.js';
|
|
5
|
+
export type { EvaluationContext, EvaluatedNode } from './evaluator.js';
|
|
6
|
+
export { builtinOperators, getOperator, isAsyncOperator, equalsOperator, containsOperator, existsOperator, matchesOperator, gtOperator, gteOperator, ltOperator, lteOperator, inOperator, aiJudgeOperator, } from './operators.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluator/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe,EAEf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Evaluator module exports
|
|
3
|
+
*/
|
|
4
|
+
export { evaluate, evaluateCondition, evaluateConditional, resolveVariable, preEvaluateAiJudges, createEvaluationContext, } from './evaluator.js';
|
|
5
|
+
export { builtinOperators, getOperator, isAsyncOperator,
|
|
6
|
+
// Individual operators for testing
|
|
7
|
+
equalsOperator, containsOperator, existsOperator, matchesOperator, gtOperator, gteOperator, ltOperator, lteOperator, inOperator, aiJudgeOperator, } from './operators.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evaluator/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe;AACf,mCAAmC;AACnC,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Built-in Operators for Echo DSL
|
|
3
|
+
*
|
|
4
|
+
* This file implements all built-in operators for the Echo DSL.
|
|
5
|
+
* Operators are used in conditions: [#IF {{var}} #operator(arg)]
|
|
6
|
+
*
|
|
7
|
+
* IMPLEMENTATION GUIDE:
|
|
8
|
+
*
|
|
9
|
+
* Each operator is a function that:
|
|
10
|
+
* - Takes a value (the variable being tested)
|
|
11
|
+
* - Takes an optional argument (the operator parameter)
|
|
12
|
+
* - Returns a boolean (or Promise<boolean> for async operators)
|
|
13
|
+
*
|
|
14
|
+
* BUILT-IN OPERATORS:
|
|
15
|
+
* - #equals(value) - Exact equality
|
|
16
|
+
* - #contains(value) - String/array contains
|
|
17
|
+
* - #exists - Value is defined and not empty
|
|
18
|
+
* - #matches(regex) - Regex pattern match
|
|
19
|
+
* - #gt(n), #lt(n) - Greater than, less than
|
|
20
|
+
* - #gte(n), #lte(n) - Greater/less than or equal
|
|
21
|
+
* - #in(a,b,c) - Value is in list
|
|
22
|
+
* - #ai_judge(question) - LLM-evaluated condition
|
|
23
|
+
*/
|
|
24
|
+
import type { OperatorDefinition } from '../types.js';
|
|
25
|
+
/**
|
|
26
|
+
* #equals - Exact equality check
|
|
27
|
+
*
|
|
28
|
+
* @example {{genre}} #equals(Horror)
|
|
29
|
+
*/
|
|
30
|
+
export declare const equalsOperator: OperatorDefinition;
|
|
31
|
+
/**
|
|
32
|
+
* #contains - Check if string/array contains a value
|
|
33
|
+
*
|
|
34
|
+
* @example {{companions}} #contains(Shimon)
|
|
35
|
+
*/
|
|
36
|
+
export declare const containsOperator: OperatorDefinition;
|
|
37
|
+
/**
|
|
38
|
+
* #exists - Check if value is defined and not empty
|
|
39
|
+
*
|
|
40
|
+
* @example {{user.preferences}} #exists
|
|
41
|
+
*/
|
|
42
|
+
export declare const existsOperator: OperatorDefinition;
|
|
43
|
+
/**
|
|
44
|
+
* #matches - Regex pattern match
|
|
45
|
+
*
|
|
46
|
+
* @example {{email}} #matches(.*@.*)
|
|
47
|
+
*/
|
|
48
|
+
export declare const matchesOperator: OperatorDefinition;
|
|
49
|
+
/**
|
|
50
|
+
* #greater_than - Greater than (alias: #gt)
|
|
51
|
+
*
|
|
52
|
+
* @example {{age}} #greater_than(18)
|
|
53
|
+
*/
|
|
54
|
+
export declare const gtOperator: OperatorDefinition;
|
|
55
|
+
/**
|
|
56
|
+
* #greater_than_or_equal - Greater than or equal (alias: #gte)
|
|
57
|
+
*/
|
|
58
|
+
export declare const gteOperator: OperatorDefinition;
|
|
59
|
+
/**
|
|
60
|
+
* #less_than - Less than (alias: #lt)
|
|
61
|
+
*/
|
|
62
|
+
export declare const ltOperator: OperatorDefinition;
|
|
63
|
+
/**
|
|
64
|
+
* #less_than_or_equal - Less than or equal (alias: #lte)
|
|
65
|
+
*/
|
|
66
|
+
export declare const lteOperator: OperatorDefinition;
|
|
67
|
+
/**
|
|
68
|
+
* #one_of - Check if value is in a list (alias: #in)
|
|
69
|
+
*
|
|
70
|
+
* @example {{status}} #one_of(active,pending,completed)
|
|
71
|
+
*/
|
|
72
|
+
export declare const inOperator: OperatorDefinition;
|
|
73
|
+
/**
|
|
74
|
+
* #ai_judge - LLM-evaluated boolean condition
|
|
75
|
+
*
|
|
76
|
+
* This operator queries an LLM to evaluate a boolean condition.
|
|
77
|
+
* It's async and results are cached for performance.
|
|
78
|
+
*
|
|
79
|
+
* @example {{content}} #ai_judge(Is this appropriate for children?)
|
|
80
|
+
*/
|
|
81
|
+
export declare const aiJudgeOperator: OperatorDefinition;
|
|
82
|
+
/**
|
|
83
|
+
* All built-in operators.
|
|
84
|
+
*
|
|
85
|
+
* Operators have readable names for low-coders and short aliases for developers.
|
|
86
|
+
* Both forms work identically:
|
|
87
|
+
* - #greater_than(10) or #gt(10)
|
|
88
|
+
* - #one_of(a,b,c) or #in(a,b,c)
|
|
89
|
+
*/
|
|
90
|
+
export declare const builtinOperators: Record<string, OperatorDefinition>;
|
|
91
|
+
/**
|
|
92
|
+
* Get an operator by name.
|
|
93
|
+
*
|
|
94
|
+
* @param name - The operator name (without #)
|
|
95
|
+
* @returns The operator definition or undefined
|
|
96
|
+
*/
|
|
97
|
+
export declare function getOperator(name: string): OperatorDefinition | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Check if an operator is async (AI-based).
|
|
100
|
+
*
|
|
101
|
+
* @param name - The operator name
|
|
102
|
+
* @returns true if the operator is async
|
|
103
|
+
*/
|
|
104
|
+
export declare function isAsyncOperator(name: string): boolean;
|
|
105
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/evaluator/operators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAMtD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,kBAgB5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAsB9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,kBAe5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,kBAoB7B,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,kBAexB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,kBAezB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,kBAexB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,kBAezB,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,kBAuBxB,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,kBA+B7B,CAAC;AAMF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAmB/D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGrD"}
|