@marktoflow/core 2.0.0-alpha.12 → 2.0.0-alpha.13
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 +147 -4
- package/dist/built-in-operations.d.ts +140 -0
- package/dist/built-in-operations.d.ts.map +1 -0
- package/dist/built-in-operations.js +414 -0
- package/dist/built-in-operations.js.map +1 -0
- package/dist/engine.d.ts +11 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +76 -42
- package/dist/engine.js.map +1 -1
- package/dist/file-operations.d.ts +86 -0
- package/dist/file-operations.d.ts.map +1 -0
- package/dist/file-operations.js +363 -0
- package/dist/file-operations.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +40 -2
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js +166 -13
- package/dist/logging.js.map +1 -1
- package/dist/models.d.ts +144 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +15 -1
- package/dist/models.js.map +1 -1
- package/dist/nunjucks-filters.d.ts +271 -0
- package/dist/nunjucks-filters.d.ts.map +1 -0
- package/dist/nunjucks-filters.js +648 -0
- package/dist/nunjucks-filters.js.map +1 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +16 -2
- package/dist/parser.js.map +1 -1
- package/dist/prompt-loader.d.ts +8 -2
- package/dist/prompt-loader.d.ts.map +1 -1
- package/dist/prompt-loader.js +26 -89
- package/dist/prompt-loader.js.map +1 -1
- package/dist/scheduler.d.ts +22 -3
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +72 -73
- package/dist/scheduler.js.map +1 -1
- package/dist/script-executor.d.ts +65 -0
- package/dist/script-executor.d.ts.map +1 -0
- package/dist/script-executor.js +261 -0
- package/dist/script-executor.js.map +1 -0
- package/dist/template-engine.d.ts +51 -0
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/template-engine.js +227 -0
- package/dist/template-engine.js.map +1 -0
- package/dist/templates.d.ts +10 -0
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +21 -17
- package/dist/templates.js.map +1 -1
- package/package.json +16 -2
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Operations for marktoflow
|
|
3
|
+
*
|
|
4
|
+
* Provides common operations that eliminate the need for verbose script blocks:
|
|
5
|
+
* - core.set: Simple variable assignment
|
|
6
|
+
* - core.transform: Map/filter/reduce transformations
|
|
7
|
+
* - core.extract: Nested path access
|
|
8
|
+
* - core.format: Date/number/string formatting
|
|
9
|
+
* - file.read: Read files with format conversion (docx, pdf, xlsx)
|
|
10
|
+
* - file.write: Write files (text or binary)
|
|
11
|
+
*/
|
|
12
|
+
import { resolveTemplates, resolveVariablePath } from './engine.js';
|
|
13
|
+
import { executeFileOperation, isFileOperation } from './file-operations.js';
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// core.set - Simple Variable Assignment
|
|
16
|
+
// ============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Set multiple variables at once with expression resolution.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
* ```yaml
|
|
22
|
+
* action: core.set
|
|
23
|
+
* inputs:
|
|
24
|
+
* owner: "{{ inputs.repo =~ /^([^\/]+)\// }}"
|
|
25
|
+
* repo_name: "{{ inputs.repo =~ /\/(.+)$/ }}"
|
|
26
|
+
* timestamp: "{{ now() }}"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function executeSet(inputs, context) {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [key, value] of Object.entries(inputs)) {
|
|
32
|
+
const resolved = resolveTemplates(value, context);
|
|
33
|
+
result[key] = resolved;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// core.transform - Array Transformations
|
|
39
|
+
// ============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Transform arrays using common operations like map, filter, reduce.
|
|
42
|
+
*
|
|
43
|
+
* Examples:
|
|
44
|
+
*
|
|
45
|
+
* Map:
|
|
46
|
+
* ```yaml
|
|
47
|
+
* action: core.transform
|
|
48
|
+
* inputs:
|
|
49
|
+
* input: "{{ oncall_response.data.oncalls }}"
|
|
50
|
+
* operation: map
|
|
51
|
+
* expression: "@{{ item.user.name }}"
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Filter:
|
|
55
|
+
* ```yaml
|
|
56
|
+
* action: core.transform
|
|
57
|
+
* inputs:
|
|
58
|
+
* input: "{{ issues }}"
|
|
59
|
+
* operation: filter
|
|
60
|
+
* condition: "item.priority == 'high'"
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Reduce:
|
|
64
|
+
* ```yaml
|
|
65
|
+
* action: core.transform
|
|
66
|
+
* inputs:
|
|
67
|
+
* input: "{{ numbers }}"
|
|
68
|
+
* operation: reduce
|
|
69
|
+
* expression: "{{ accumulator + item }}"
|
|
70
|
+
* initialValue: 0
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function executeTransform(rawInputs, resolvedInputs, context) {
|
|
74
|
+
// Use resolved input array
|
|
75
|
+
const input = resolvedInputs.input;
|
|
76
|
+
if (!Array.isArray(input)) {
|
|
77
|
+
throw new Error('Transform input must be an array');
|
|
78
|
+
}
|
|
79
|
+
// Use raw (unresolved) expression and condition to preserve templates
|
|
80
|
+
const operation = rawInputs.operation;
|
|
81
|
+
switch (operation) {
|
|
82
|
+
case 'map':
|
|
83
|
+
return transformMap(input, rawInputs.expression || '{{ item }}', context);
|
|
84
|
+
case 'filter':
|
|
85
|
+
return transformFilter(input, rawInputs.condition || 'item', context);
|
|
86
|
+
case 'reduce':
|
|
87
|
+
return transformReduce(input, rawInputs.expression || '{{ accumulator }}', resolvedInputs.initialValue, // Resolve initialValue upfront
|
|
88
|
+
context);
|
|
89
|
+
case 'find':
|
|
90
|
+
return transformFind(input, rawInputs.condition || 'item', context);
|
|
91
|
+
case 'group_by':
|
|
92
|
+
if (!rawInputs.key) {
|
|
93
|
+
throw new Error('group_by operation requires "key" parameter');
|
|
94
|
+
}
|
|
95
|
+
return transformGroupBy(input, rawInputs.key, context);
|
|
96
|
+
case 'unique':
|
|
97
|
+
return transformUnique(input, rawInputs.key, context);
|
|
98
|
+
case 'sort':
|
|
99
|
+
return transformSort(input, rawInputs.key, resolvedInputs.reverse || false, context);
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Unknown transform operation: ${operation}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Map transformation - transform each item in an array
|
|
106
|
+
*/
|
|
107
|
+
function transformMap(items, expression, context) {
|
|
108
|
+
return items.map((item) => {
|
|
109
|
+
const itemContext = { ...context, variables: { ...context.variables, item } };
|
|
110
|
+
return resolveTemplates(expression, itemContext);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Filter transformation - keep items that match a condition
|
|
115
|
+
*/
|
|
116
|
+
function transformFilter(items, condition, context) {
|
|
117
|
+
return items.filter((item) => {
|
|
118
|
+
const itemContext = { ...context, variables: { ...context.variables, item } };
|
|
119
|
+
const resolved = resolveTemplates(condition, itemContext);
|
|
120
|
+
return Boolean(resolved);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reduce transformation - aggregate items to a single value
|
|
125
|
+
*/
|
|
126
|
+
function transformReduce(items, expression, initialValue, context) {
|
|
127
|
+
let accumulator = initialValue !== undefined ? initialValue : null;
|
|
128
|
+
for (const item of items) {
|
|
129
|
+
const reduceContext = {
|
|
130
|
+
...context,
|
|
131
|
+
variables: { ...context.variables, item, accumulator },
|
|
132
|
+
};
|
|
133
|
+
accumulator = resolveTemplates(expression, reduceContext);
|
|
134
|
+
}
|
|
135
|
+
return accumulator;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Find transformation - find first item that matches condition
|
|
139
|
+
*/
|
|
140
|
+
function transformFind(items, condition, context) {
|
|
141
|
+
for (const item of items) {
|
|
142
|
+
const itemContext = { ...context, variables: { ...context.variables, item } };
|
|
143
|
+
const resolved = resolveTemplates(condition, itemContext);
|
|
144
|
+
if (Boolean(resolved)) {
|
|
145
|
+
return item;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Group by transformation - group items by a key
|
|
152
|
+
*/
|
|
153
|
+
function transformGroupBy(items, key, context) {
|
|
154
|
+
const groups = {};
|
|
155
|
+
for (const item of items) {
|
|
156
|
+
const itemContext = { ...context, variables: { ...context.variables, item } };
|
|
157
|
+
const groupKey = String(resolveVariablePath(key, itemContext));
|
|
158
|
+
if (!groups[groupKey]) {
|
|
159
|
+
groups[groupKey] = [];
|
|
160
|
+
}
|
|
161
|
+
groups[groupKey].push(item);
|
|
162
|
+
}
|
|
163
|
+
return groups;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Unique transformation - remove duplicates
|
|
167
|
+
*/
|
|
168
|
+
function transformUnique(items, key, context) {
|
|
169
|
+
if (!key) {
|
|
170
|
+
// Simple unique for primitive values
|
|
171
|
+
return Array.from(new Set(items));
|
|
172
|
+
}
|
|
173
|
+
// Unique based on key
|
|
174
|
+
const seen = new Set();
|
|
175
|
+
const result = [];
|
|
176
|
+
for (const item of items) {
|
|
177
|
+
const itemContext = { ...context, variables: { ...context.variables, item } };
|
|
178
|
+
const keyValue = String(resolveVariablePath(key, itemContext));
|
|
179
|
+
if (!seen.has(keyValue)) {
|
|
180
|
+
seen.add(keyValue);
|
|
181
|
+
result.push(item);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sort transformation - sort items by key or value
|
|
188
|
+
*/
|
|
189
|
+
function transformSort(items, key, reverse, context) {
|
|
190
|
+
const sorted = [...items];
|
|
191
|
+
sorted.sort((a, b) => {
|
|
192
|
+
let aVal = a;
|
|
193
|
+
let bVal = b;
|
|
194
|
+
if (key) {
|
|
195
|
+
const aContext = { ...context, variables: { ...context.variables, item: a } };
|
|
196
|
+
const bContext = { ...context, variables: { ...context.variables, item: b } };
|
|
197
|
+
aVal = resolveVariablePath(key, aContext);
|
|
198
|
+
bVal = resolveVariablePath(key, bContext);
|
|
199
|
+
}
|
|
200
|
+
// Handle different types
|
|
201
|
+
if (typeof aVal === 'number' && typeof bVal === 'number') {
|
|
202
|
+
return aVal - bVal;
|
|
203
|
+
}
|
|
204
|
+
if (typeof aVal === 'string' && typeof bVal === 'string') {
|
|
205
|
+
return aVal.localeCompare(bVal);
|
|
206
|
+
}
|
|
207
|
+
// Fall back to string comparison
|
|
208
|
+
return String(aVal).localeCompare(String(bVal));
|
|
209
|
+
});
|
|
210
|
+
return reverse ? sorted.reverse() : sorted;
|
|
211
|
+
}
|
|
212
|
+
// ============================================================================
|
|
213
|
+
// core.extract - Nested Path Access
|
|
214
|
+
// ============================================================================
|
|
215
|
+
/**
|
|
216
|
+
* Extract values from nested objects safely.
|
|
217
|
+
*
|
|
218
|
+
* Example:
|
|
219
|
+
* ```yaml
|
|
220
|
+
* action: core.extract
|
|
221
|
+
* inputs:
|
|
222
|
+
* input: "{{ api_response }}"
|
|
223
|
+
* path: "data.users[0].email"
|
|
224
|
+
* default: "unknown@example.com"
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export function executeExtract(inputs, context) {
|
|
228
|
+
const input = resolveTemplates(inputs.input, context);
|
|
229
|
+
const path = inputs.path;
|
|
230
|
+
const defaultValue = inputs.default;
|
|
231
|
+
// Create a temporary context with the input as a variable
|
|
232
|
+
const tempContext = {
|
|
233
|
+
...context,
|
|
234
|
+
variables: { ...context.variables, __extract_input: input },
|
|
235
|
+
};
|
|
236
|
+
const result = resolveVariablePath(`__extract_input.${path}`, tempContext);
|
|
237
|
+
if (result === undefined) {
|
|
238
|
+
return defaultValue !== undefined ? defaultValue : null;
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
// ============================================================================
|
|
243
|
+
// core.format - Value Formatting
|
|
244
|
+
// ============================================================================
|
|
245
|
+
/**
|
|
246
|
+
* Format values for display (dates, numbers, strings, currency).
|
|
247
|
+
*
|
|
248
|
+
* Examples:
|
|
249
|
+
*
|
|
250
|
+
* Date:
|
|
251
|
+
* ```yaml
|
|
252
|
+
* action: core.format
|
|
253
|
+
* inputs:
|
|
254
|
+
* value: "{{ now() }}"
|
|
255
|
+
* type: date
|
|
256
|
+
* format: "YYYY-MM-DD HH:mm:ss"
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* Number:
|
|
260
|
+
* ```yaml
|
|
261
|
+
* action: core.format
|
|
262
|
+
* inputs:
|
|
263
|
+
* value: 1234.56
|
|
264
|
+
* type: number
|
|
265
|
+
* precision: 2
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* Currency:
|
|
269
|
+
* ```yaml
|
|
270
|
+
* action: core.format
|
|
271
|
+
* inputs:
|
|
272
|
+
* value: 1234.56
|
|
273
|
+
* type: currency
|
|
274
|
+
* currency: USD
|
|
275
|
+
* locale: en-US
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export function executeFormat(inputs, context) {
|
|
279
|
+
const value = resolveTemplates(inputs.value, context);
|
|
280
|
+
switch (inputs.type) {
|
|
281
|
+
case 'date':
|
|
282
|
+
return formatDate(value, inputs.format);
|
|
283
|
+
case 'number':
|
|
284
|
+
return formatNumber(value, inputs.precision, inputs.locale);
|
|
285
|
+
case 'currency':
|
|
286
|
+
return formatCurrency(value, inputs.currency || 'USD', inputs.locale);
|
|
287
|
+
case 'string':
|
|
288
|
+
return formatString(value, inputs.format);
|
|
289
|
+
case 'json':
|
|
290
|
+
return JSON.stringify(value, null, 2);
|
|
291
|
+
default:
|
|
292
|
+
throw new Error(`Unknown format type: ${inputs.type}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Format a date value
|
|
297
|
+
* Supports simple format tokens: YYYY, MM, DD, HH, mm, ss
|
|
298
|
+
*/
|
|
299
|
+
function formatDate(value, format) {
|
|
300
|
+
let date;
|
|
301
|
+
if (value instanceof Date) {
|
|
302
|
+
date = value;
|
|
303
|
+
}
|
|
304
|
+
else if (typeof value === 'string' || typeof value === 'number') {
|
|
305
|
+
date = new Date(value);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
date = new Date();
|
|
309
|
+
}
|
|
310
|
+
if (isNaN(date.getTime())) {
|
|
311
|
+
throw new Error('Invalid date value');
|
|
312
|
+
}
|
|
313
|
+
if (!format) {
|
|
314
|
+
return date.toISOString();
|
|
315
|
+
}
|
|
316
|
+
// Simple date formatting (basic implementation)
|
|
317
|
+
let formatted = format;
|
|
318
|
+
formatted = formatted.replace('YYYY', date.getFullYear().toString());
|
|
319
|
+
formatted = formatted.replace('MM', String(date.getMonth() + 1).padStart(2, '0'));
|
|
320
|
+
formatted = formatted.replace('DD', String(date.getDate()).padStart(2, '0'));
|
|
321
|
+
formatted = formatted.replace('HH', String(date.getHours()).padStart(2, '0'));
|
|
322
|
+
formatted = formatted.replace('mm', String(date.getMinutes()).padStart(2, '0'));
|
|
323
|
+
formatted = formatted.replace('ss', String(date.getSeconds()).padStart(2, '0'));
|
|
324
|
+
return formatted;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Format a number value
|
|
328
|
+
*/
|
|
329
|
+
function formatNumber(value, precision, locale) {
|
|
330
|
+
const num = Number(value);
|
|
331
|
+
if (isNaN(num)) {
|
|
332
|
+
throw new Error('Invalid number value');
|
|
333
|
+
}
|
|
334
|
+
if (precision !== undefined) {
|
|
335
|
+
return num.toFixed(precision);
|
|
336
|
+
}
|
|
337
|
+
if (locale) {
|
|
338
|
+
return num.toLocaleString(locale);
|
|
339
|
+
}
|
|
340
|
+
return num.toString();
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Format a currency value
|
|
344
|
+
*/
|
|
345
|
+
function formatCurrency(value, currency, locale) {
|
|
346
|
+
const num = Number(value);
|
|
347
|
+
if (isNaN(num)) {
|
|
348
|
+
throw new Error('Invalid currency value');
|
|
349
|
+
}
|
|
350
|
+
return num.toLocaleString(locale || 'en-US', {
|
|
351
|
+
style: 'currency',
|
|
352
|
+
currency,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Format a string value
|
|
357
|
+
* Supports: upper, lower, title, capitalize, trim
|
|
358
|
+
*/
|
|
359
|
+
function formatString(value, format) {
|
|
360
|
+
let str = String(value);
|
|
361
|
+
if (!format) {
|
|
362
|
+
return str;
|
|
363
|
+
}
|
|
364
|
+
switch (format.toLowerCase()) {
|
|
365
|
+
case 'upper':
|
|
366
|
+
case 'uppercase':
|
|
367
|
+
return str.toUpperCase();
|
|
368
|
+
case 'lower':
|
|
369
|
+
case 'lowercase':
|
|
370
|
+
return str.toLowerCase();
|
|
371
|
+
case 'title':
|
|
372
|
+
case 'titlecase':
|
|
373
|
+
return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase());
|
|
374
|
+
case 'capitalize':
|
|
375
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
376
|
+
case 'trim':
|
|
377
|
+
return str.trim();
|
|
378
|
+
default:
|
|
379
|
+
return str;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// ============================================================================
|
|
383
|
+
// Helper Functions
|
|
384
|
+
// ============================================================================
|
|
385
|
+
/**
|
|
386
|
+
* Execute a built-in operation based on action name
|
|
387
|
+
*/
|
|
388
|
+
export function executeBuiltInOperation(action, rawInputs, resolvedInputs, context) {
|
|
389
|
+
switch (action) {
|
|
390
|
+
case 'core.set':
|
|
391
|
+
return executeSet(resolvedInputs, context);
|
|
392
|
+
case 'core.transform':
|
|
393
|
+
// For transform operations, use raw inputs to preserve template expressions
|
|
394
|
+
return executeTransform(rawInputs, resolvedInputs, context);
|
|
395
|
+
case 'core.extract':
|
|
396
|
+
return executeExtract(resolvedInputs, context);
|
|
397
|
+
case 'core.format':
|
|
398
|
+
return executeFormat(resolvedInputs, context);
|
|
399
|
+
default:
|
|
400
|
+
// Check if it's a file operation
|
|
401
|
+
if (isFileOperation(action)) {
|
|
402
|
+
return executeFileOperation(action, resolvedInputs, context);
|
|
403
|
+
}
|
|
404
|
+
return null; // Not a built-in operation
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Check if an action is a built-in operation
|
|
409
|
+
*/
|
|
410
|
+
export function isBuiltInOperation(action) {
|
|
411
|
+
const builtInActions = ['core.set', 'core.transform', 'core.extract', 'core.format'];
|
|
412
|
+
return builtInActions.includes(action) || isFileOperation(action);
|
|
413
|
+
}
|
|
414
|
+
//# sourceMappingURL=built-in-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in-operations.js","sourceRoot":"","sources":["../src/built-in-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAmC7E,+EAA+E;AAC/E,wCAAwC;AACxC,+EAA+E;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACxB,MAA0B,EAC1B,OAAyB;IAEzB,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC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C,cAAmD,EAAE,OAAO,CAAC,CAAC;QAEtF,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC,cAAkD,EAAE,OAAO,CAAC,CAAC;QAEpF;YACE,iCAAiC;YACjC,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5B,OAAO,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;YAC/D,CAAC;YACD,OAAO,IAAI,CAAC,CAAC,2BAA2B;IAC5C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;IACrF,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/engine.d.ts
CHANGED
|
@@ -85,7 +85,12 @@ export declare class CircuitBreaker {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Resolve template variables in a value.
|
|
88
|
-
* Supports {{variable}}
|
|
88
|
+
* Supports {{variable}}, {{inputs.name}}, and Nunjucks filters.
|
|
89
|
+
*
|
|
90
|
+
* Uses Nunjucks as the template engine with:
|
|
91
|
+
* - Legacy regex operator support (=~, !~, //) converted to filters
|
|
92
|
+
* - Custom filters for string, array, object, date operations
|
|
93
|
+
* - Jinja2-style control flow ({% for %}, {% if %}, etc.)
|
|
89
94
|
*/
|
|
90
95
|
export declare function resolveTemplates(value: unknown, context: ExecutionContext): unknown;
|
|
91
96
|
/**
|
|
@@ -177,6 +182,7 @@ export declare class WorkflowEngine {
|
|
|
177
182
|
/**
|
|
178
183
|
* Resolve a condition value with support for nested properties.
|
|
179
184
|
* Handles direct variable references and nested paths.
|
|
185
|
+
* Uses Nunjucks for template expressions with filters/regex.
|
|
180
186
|
*/
|
|
181
187
|
private resolveConditionValue;
|
|
182
188
|
/**
|
|
@@ -227,6 +233,10 @@ export declare class WorkflowEngine {
|
|
|
227
233
|
* Execute try/catch/finally step.
|
|
228
234
|
*/
|
|
229
235
|
private executeTryStep;
|
|
236
|
+
/**
|
|
237
|
+
* Execute a script step (inline JavaScript).
|
|
238
|
+
*/
|
|
239
|
+
private executeScriptStep;
|
|
230
240
|
/**
|
|
231
241
|
* Clone execution context for parallel branches.
|
|
232
242
|
*/
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,cAAc,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,cAAc,EA8Bf,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAEL,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AA6BjD,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gDAAgD;I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lC;;OAEG;YACW,oBAAoB;IAkKlC;;OAEG;YACW,uBAAuB;IAqErC;;OAEG;YACW,kBAAkB;IAShC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAyCzB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAwB7B;;OAEG;IACH,OAAO,CAAC,UAAU;IAsBlB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAU5B;;OAEG;YACW,aAAa;IAiD3B;;OAEG;YACW,iBAAiB;IAiD/B;;OAEG;YACW,kBAAkB;IA2FhC;;OAEG;YACW,gBAAgB;IAwD9B;;OAEG;YACW,cAAc;IA6C5B;;OAEG;YACW,iBAAiB;IA6C/B;;OAEG;YACW,iBAAiB;IAiD/B;;OAEG;YACW,mBAAmB;IA2DjC;;OAEG;YACW,cAAc;IAmG5B;;OAEG;YACW,iBAAiB;IAsD/B;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;YACW,4BAA4B;CA0B3C"}
|
package/dist/engine.js
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
* Executes workflow steps with retry logic, variable resolution,
|
|
5
5
|
* and SDK invocation.
|
|
6
6
|
*/
|
|
7
|
-
import { StepStatus, WorkflowStatus, createExecutionContext, createStepResult, isActionStep, isSubWorkflowStep, isIfStep, isSwitchStep, isForEachStep, isWhileStep, isMapStep, isFilterStep, isReduceStep, isParallelStep, isTryStep, } from './models.js';
|
|
7
|
+
import { StepStatus, WorkflowStatus, createExecutionContext, createStepResult, isActionStep, isSubWorkflowStep, isIfStep, isSwitchStep, isForEachStep, isWhileStep, isMapStep, isFilterStep, isReduceStep, isParallelStep, isTryStep, isScriptStep, } from './models.js';
|
|
8
8
|
import { mergePermissions, toSecurityPolicy, } from './permissions.js';
|
|
9
9
|
import { loadPromptFile, resolvePromptTemplate, validatePromptInputs, } from './prompt-loader.js';
|
|
10
10
|
import { DEFAULT_FAILOVER_CONFIG, AgentHealthTracker, FailoverReason, } from './failover.js';
|
|
11
11
|
import { parseFile } from './parser.js';
|
|
12
12
|
import { resolve, dirname } from 'node:path';
|
|
13
|
+
import { executeBuiltInOperation, isBuiltInOperation } from './built-in-operations.js';
|
|
14
|
+
import { renderTemplate } from './template-engine.js';
|
|
15
|
+
import { executeScriptAsync } from './script-executor.js';
|
|
13
16
|
// ============================================================================
|
|
14
17
|
// Helper Functions
|
|
15
18
|
// ============================================================================
|
|
@@ -112,50 +115,27 @@ export class CircuitBreaker {
|
|
|
112
115
|
// ============================================================================
|
|
113
116
|
// Variable Resolution
|
|
114
117
|
// ============================================================================
|
|
115
|
-
/**
|
|
116
|
-
* Smart serialization for template interpolation.
|
|
117
|
-
* Converts values to strings in a meaningful way for different types.
|
|
118
|
-
*/
|
|
119
|
-
function serializeValue(value) {
|
|
120
|
-
if (value === undefined || value === null) {
|
|
121
|
-
return '';
|
|
122
|
-
}
|
|
123
|
-
// For primitives, use standard string conversion
|
|
124
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
125
|
-
return String(value);
|
|
126
|
-
}
|
|
127
|
-
// For objects and arrays, use JSON serialization for readability
|
|
128
|
-
// This makes them useful in prompts and messages instead of "[object Object]"
|
|
129
|
-
try {
|
|
130
|
-
return JSON.stringify(value, null, 2);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
// Fallback to string conversion if JSON serialization fails
|
|
134
|
-
return String(value);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
118
|
/**
|
|
138
119
|
* Resolve template variables in a value.
|
|
139
|
-
* Supports {{variable}}
|
|
120
|
+
* Supports {{variable}}, {{inputs.name}}, and Nunjucks filters.
|
|
121
|
+
*
|
|
122
|
+
* Uses Nunjucks as the template engine with:
|
|
123
|
+
* - Legacy regex operator support (=~, !~, //) converted to filters
|
|
124
|
+
* - Custom filters for string, array, object, date operations
|
|
125
|
+
* - Jinja2-style control flow ({% for %}, {% if %}, etc.)
|
|
140
126
|
*/
|
|
141
127
|
export function resolveTemplates(value, context) {
|
|
142
128
|
if (typeof value === 'string') {
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// Otherwise, do string interpolation with smart serialization
|
|
154
|
-
return value.replace(/\{\{([^}]+)\}\}/g, (_, varPath) => {
|
|
155
|
-
const path = varPath.trim();
|
|
156
|
-
const resolved = resolveVariablePath(path, context);
|
|
157
|
-
return serializeValue(resolved);
|
|
158
|
-
});
|
|
129
|
+
// Build the template context with all available variables
|
|
130
|
+
// Spread inputs first, then variables (variables override inputs if same key)
|
|
131
|
+
// Also keep inputs accessible via inputs.* for explicit access
|
|
132
|
+
const templateContext = {
|
|
133
|
+
...context.inputs, // Spread inputs at root level for direct access ({{ path }})
|
|
134
|
+
...context.variables, // Variables override inputs if same key
|
|
135
|
+
inputs: context.inputs, // Also keep inputs accessible as inputs.*
|
|
136
|
+
};
|
|
137
|
+
// Use the new Nunjucks-based template engine with legacy syntax support
|
|
138
|
+
return renderTemplate(value, templateContext);
|
|
159
139
|
}
|
|
160
140
|
if (Array.isArray(value)) {
|
|
161
141
|
return value.map((v) => resolveTemplates(v, context));
|
|
@@ -185,6 +165,11 @@ export function resolveVariablePath(path, context) {
|
|
|
185
165
|
if (fromVars !== undefined) {
|
|
186
166
|
return fromVars;
|
|
187
167
|
}
|
|
168
|
+
// Check inputs (for bare variable names like "value" instead of "inputs.value")
|
|
169
|
+
const fromInputs = getNestedValue(context.inputs, path);
|
|
170
|
+
if (fromInputs !== undefined) {
|
|
171
|
+
return fromInputs;
|
|
172
|
+
}
|
|
188
173
|
// Check step metadata (for status checks like: step_id.status)
|
|
189
174
|
const fromStepMeta = getNestedValue(context.stepMetadata, path);
|
|
190
175
|
if (fromStepMeta !== undefined) {
|
|
@@ -317,6 +302,9 @@ export class WorkflowEngine {
|
|
|
317
302
|
if (isTryStep(step)) {
|
|
318
303
|
return this.executeTryStep(step, context, sdkRegistry, stepExecutor);
|
|
319
304
|
}
|
|
305
|
+
if (isScriptStep(step)) {
|
|
306
|
+
return this.executeScriptStep(step, context);
|
|
307
|
+
}
|
|
320
308
|
// Default: action or workflow step
|
|
321
309
|
return this.executeStepWithFailover(step, context, sdkRegistry, stepExecutor);
|
|
322
310
|
}
|
|
@@ -834,8 +822,19 @@ Execute the workflow steps in order and return the final outputs as JSON.`;
|
|
|
834
822
|
resolvedInputs = resolveTemplates(step.inputs, context);
|
|
835
823
|
}
|
|
836
824
|
const stepWithResolvedInputs = { ...step, inputs: resolvedInputs };
|
|
837
|
-
//
|
|
838
|
-
|
|
825
|
+
// Check if this is a built-in operation
|
|
826
|
+
let output;
|
|
827
|
+
if (isBuiltInOperation(step.action)) {
|
|
828
|
+
// Execute built-in operation directly (no timeout, no SDK executor needed)
|
|
829
|
+
// For built-in operations, pass both resolved and unresolved inputs
|
|
830
|
+
// to allow selective resolution of template expressions
|
|
831
|
+
// Await in case operation is async (e.g., file operations)
|
|
832
|
+
output = await executeBuiltInOperation(step.action, step.inputs, resolvedInputs, context);
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
// Execute step with executor context
|
|
836
|
+
output = await this.executeWithTimeout(() => stepExecutor(stepWithResolvedInputs, context, sdkRegistry, executorContext), step.timeout ?? this.config.defaultTimeout);
|
|
837
|
+
}
|
|
839
838
|
circuitBreaker.recordSuccess();
|
|
840
839
|
const result = createStepResult(step.id, StepStatus.COMPLETED, output, startedAt, attempt);
|
|
841
840
|
this.events.onStepComplete?.(step, result);
|
|
@@ -977,8 +976,18 @@ Execute the workflow steps in order and return the final outputs as JSON.`;
|
|
|
977
976
|
/**
|
|
978
977
|
* Resolve a condition value with support for nested properties.
|
|
979
978
|
* Handles direct variable references and nested paths.
|
|
979
|
+
* Uses Nunjucks for template expressions with filters/regex.
|
|
980
980
|
*/
|
|
981
981
|
resolveConditionValue(path, context) {
|
|
982
|
+
// If it looks like a template expression, resolve it
|
|
983
|
+
if (path.includes('|') || path.includes('=~') || path.includes('!~')) {
|
|
984
|
+
// Build template context
|
|
985
|
+
const templateContext = {
|
|
986
|
+
inputs: context.inputs,
|
|
987
|
+
...context.variables,
|
|
988
|
+
};
|
|
989
|
+
return renderTemplate(`{{ ${path} }}`, templateContext);
|
|
990
|
+
}
|
|
982
991
|
// First try to parse as a literal value (true, false, numbers, etc.)
|
|
983
992
|
const parsedValue = this.parseValue(path);
|
|
984
993
|
// If parseValue returned the same string, try to resolve as a variable
|
|
@@ -1401,6 +1410,31 @@ Execute the workflow steps in order and return the final outputs as JSON.`;
|
|
|
1401
1410
|
return createStepResult(step.id, StepStatus.FAILED, null, startedAt, 0, error instanceof Error ? error.message : String(error));
|
|
1402
1411
|
}
|
|
1403
1412
|
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Execute a script step (inline JavaScript).
|
|
1415
|
+
*/
|
|
1416
|
+
async executeScriptStep(step, context) {
|
|
1417
|
+
const startedAt = new Date();
|
|
1418
|
+
try {
|
|
1419
|
+
// Resolve any templates in the code
|
|
1420
|
+
const resolvedInputs = resolveTemplates(step.inputs, context);
|
|
1421
|
+
// Execute the script with the workflow context
|
|
1422
|
+
const result = await executeScriptAsync(resolvedInputs.code, {
|
|
1423
|
+
variables: context.variables,
|
|
1424
|
+
inputs: context.inputs,
|
|
1425
|
+
steps: context.stepMetadata,
|
|
1426
|
+
}, {
|
|
1427
|
+
timeout: resolvedInputs.timeout ?? 5000,
|
|
1428
|
+
});
|
|
1429
|
+
if (!result.success) {
|
|
1430
|
+
return createStepResult(step.id, StepStatus.FAILED, null, startedAt, 0, result.error ?? 'Script execution failed');
|
|
1431
|
+
}
|
|
1432
|
+
return createStepResult(step.id, StepStatus.COMPLETED, result.value, startedAt);
|
|
1433
|
+
}
|
|
1434
|
+
catch (error) {
|
|
1435
|
+
return createStepResult(step.id, StepStatus.FAILED, null, startedAt, 0, error instanceof Error ? error.message : String(error));
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1404
1438
|
// ============================================================================
|
|
1405
1439
|
// Helper Methods for Control Flow
|
|
1406
1440
|
// ============================================================================
|