@elqnt/workflow 1.0.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/index.mjs ADDED
@@ -0,0 +1,4808 @@
1
+ // components/dynamic-schema-form.tsx
2
+ import { useState } from "react";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ function DynamicSchemaForm({
5
+ schema,
6
+ value = {},
7
+ onChange,
8
+ disabled = false,
9
+ path = [],
10
+ components,
11
+ variables = [],
12
+ showVariablePicker = false
13
+ }) {
14
+ const [collapsedSections, setCollapsedSections] = useState(
15
+ /* @__PURE__ */ new Set()
16
+ );
17
+ const [openVariablePickers, setOpenVariablePickers] = useState(
18
+ /* @__PURE__ */ new Set()
19
+ );
20
+ const [openRichTextDialogs, setOpenRichTextDialogs] = useState(
21
+ /* @__PURE__ */ new Set()
22
+ );
23
+ const [richTextDraftValues, setRichTextDraftValues] = useState({});
24
+ const {
25
+ Input,
26
+ Label,
27
+ Textarea,
28
+ Checkbox,
29
+ Select,
30
+ SelectTrigger,
31
+ SelectValue,
32
+ SelectContent,
33
+ SelectItem,
34
+ Button,
35
+ Card,
36
+ PlusIcon,
37
+ TrashIcon,
38
+ ChevronDownIcon,
39
+ ChevronRightIcon,
40
+ VariableIcon,
41
+ CheckIcon,
42
+ EditIcon,
43
+ Popover,
44
+ PopoverTrigger,
45
+ PopoverContent,
46
+ Dialog,
47
+ DialogContent,
48
+ DialogHeader,
49
+ DialogTitle,
50
+ DialogFooter,
51
+ ScrollArea,
52
+ MarkdownEditor,
53
+ cn
54
+ } = components;
55
+ const isVariableReference = (val) => {
56
+ return typeof val === "string" && val.startsWith("{{") && val.endsWith("}}");
57
+ };
58
+ const getMatchingVariables = (fieldType) => {
59
+ if (!fieldType) return variables;
60
+ const compatibleTypes = {
61
+ string: ["string"],
62
+ number: ["number", "integer"],
63
+ integer: ["number", "integer"],
64
+ boolean: ["boolean"],
65
+ object: ["object"],
66
+ array: ["array"]
67
+ };
68
+ const compatible = compatibleTypes[fieldType] || [fieldType];
69
+ return variables.filter((v) => compatible.includes(v.type));
70
+ };
71
+ const toggleVariablePicker = (fieldPath) => {
72
+ setOpenVariablePickers((prev) => {
73
+ const next = new Set(prev);
74
+ if (next.has(fieldPath)) {
75
+ next.delete(fieldPath);
76
+ } else {
77
+ next.add(fieldPath);
78
+ }
79
+ return next;
80
+ });
81
+ };
82
+ const renderVariablePicker = (fieldName, fieldType, fieldPath, onSelect) => {
83
+ if (!showVariablePicker) {
84
+ return null;
85
+ }
86
+ if (!VariableIcon || !Popover || !PopoverTrigger || !PopoverContent) {
87
+ return null;
88
+ }
89
+ const matchingVars = getMatchingVariables(fieldType);
90
+ const isOpen = openVariablePickers.has(fieldPath);
91
+ const currentValue = value[fieldName];
92
+ const isVariable = isVariableReference(currentValue);
93
+ return /* @__PURE__ */ jsxs(
94
+ Popover,
95
+ {
96
+ open: isOpen,
97
+ onOpenChange: (open) => {
98
+ if (open) {
99
+ setOpenVariablePickers((prev) => new Set(prev).add(fieldPath));
100
+ } else {
101
+ setOpenVariablePickers((prev) => {
102
+ const next = new Set(prev);
103
+ next.delete(fieldPath);
104
+ return next;
105
+ });
106
+ }
107
+ },
108
+ children: [
109
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
110
+ Button,
111
+ {
112
+ type: "button",
113
+ variant: "outline",
114
+ size: "sm",
115
+ className: cn(
116
+ "h-8 px-2 shrink-0",
117
+ isVariable && "border-primary text-primary"
118
+ ),
119
+ disabled,
120
+ children: /* @__PURE__ */ jsx(VariableIcon, { className: "h-3.5 w-3.5" })
121
+ }
122
+ ) }),
123
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-56 p-1", align: "end", children: [
124
+ /* @__PURE__ */ jsxs("div", { className: "text-xs font-medium text-muted-foreground px-2 py-1.5", children: [
125
+ "Select Variable (",
126
+ fieldType || "any",
127
+ ")"
128
+ ] }),
129
+ /* @__PURE__ */ jsx("div", { className: "max-h-48 overflow-y-auto", children: matchingVars.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "px-2 py-3 text-xs text-muted-foreground text-center", children: [
130
+ "No variables available.",
131
+ /* @__PURE__ */ jsx("br", {}),
132
+ /* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Add variables in Workflow Settings \u2192 Variables" })
133
+ ] }) : matchingVars.map((variable) => {
134
+ const varRef = `{{${variable.path}}}`;
135
+ const isSelected = currentValue === varRef;
136
+ return /* @__PURE__ */ jsxs(
137
+ "button",
138
+ {
139
+ type: "button",
140
+ className: cn(
141
+ "w-full text-left px-2 py-1.5 text-xs rounded hover:bg-accent flex items-center justify-between",
142
+ isSelected && "bg-accent"
143
+ ),
144
+ onClick: () => {
145
+ onSelect(varRef);
146
+ setOpenVariablePickers((prev) => {
147
+ const next = new Set(prev);
148
+ next.delete(fieldPath);
149
+ return next;
150
+ });
151
+ },
152
+ children: [
153
+ /* @__PURE__ */ jsxs("div", { children: [
154
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: variable.title || variable.name }),
155
+ /* @__PURE__ */ jsx("div", { className: "text-[10px] text-muted-foreground font-mono", children: variable.path })
156
+ ] }),
157
+ isSelected && CheckIcon && /* @__PURE__ */ jsx(CheckIcon, { className: "h-3 w-3" })
158
+ ]
159
+ },
160
+ variable.path
161
+ );
162
+ }) })
163
+ ] })
164
+ ]
165
+ }
166
+ );
167
+ };
168
+ const toggleSection = (key) => {
169
+ setCollapsedSections((prev) => {
170
+ const next = new Set(prev);
171
+ if (next.has(key)) {
172
+ next.delete(key);
173
+ } else {
174
+ next.add(key);
175
+ }
176
+ return next;
177
+ });
178
+ };
179
+ const handleFieldChange = (fieldName, fieldValue) => {
180
+ onChange({
181
+ ...value,
182
+ [fieldName]: fieldValue
183
+ });
184
+ };
185
+ const renderField = (fieldSchema, fieldName, fieldValue) => {
186
+ const fieldPath = [...path, fieldName].join(".");
187
+ const isRequired = schema.required?.includes(fieldName);
188
+ if (fieldSchema.enum) {
189
+ const labels = fieldSchema["x-enumLabels"] || fieldSchema.enum;
190
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
191
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
192
+ fieldSchema.title || fieldName,
193
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
194
+ ] }),
195
+ /* @__PURE__ */ jsxs(
196
+ Select,
197
+ {
198
+ value: fieldValue || "",
199
+ onValueChange: (v) => handleFieldChange(fieldName, v),
200
+ disabled,
201
+ children: [
202
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsx(
203
+ SelectValue,
204
+ {
205
+ placeholder: `Select ${fieldSchema.title || fieldName}`
206
+ }
207
+ ) }),
208
+ /* @__PURE__ */ jsx(SelectContent, { children: fieldSchema.enum.map((option, idx) => /* @__PURE__ */ jsx(SelectItem, { value: option, className: "text-xs", children: labels[idx] || option }, option)) })
209
+ ]
210
+ }
211
+ ),
212
+ fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
213
+ ] }, fieldPath);
214
+ }
215
+ if (fieldSchema.type === "object" && fieldSchema.properties) {
216
+ const isCollapsed = collapsedSections.has(fieldPath);
217
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
218
+ /* @__PURE__ */ jsxs(
219
+ "button",
220
+ {
221
+ type: "button",
222
+ onClick: () => toggleSection(fieldPath),
223
+ className: "flex items-center gap-1 text-xs font-medium text-gray-700 hover:text-gray-900",
224
+ children: [
225
+ isCollapsed ? /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }),
226
+ fieldSchema.title || fieldName
227
+ ]
228
+ }
229
+ ),
230
+ !isCollapsed && /* @__PURE__ */ jsx(Card, { className: "p-3 bg-gray-50/50", children: /* @__PURE__ */ jsx(
231
+ DynamicSchemaForm,
232
+ {
233
+ schema: fieldSchema,
234
+ value: fieldValue || {},
235
+ onChange: (v) => handleFieldChange(fieldName, v),
236
+ disabled,
237
+ path: [...path, fieldName],
238
+ components,
239
+ variables,
240
+ showVariablePicker
241
+ }
242
+ ) })
243
+ ] }, fieldPath);
244
+ }
245
+ if (fieldSchema.type === "array" && fieldSchema.items) {
246
+ const arrayValue = Array.isArray(fieldValue) ? fieldValue : [];
247
+ const itemSchema = fieldSchema.items;
248
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
249
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
250
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
251
+ fieldSchema.title || fieldName,
252
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
253
+ ] }),
254
+ /* @__PURE__ */ jsxs(
255
+ Button,
256
+ {
257
+ type: "button",
258
+ variant: "outline",
259
+ size: "sm",
260
+ className: "h-6 text-xs px-2",
261
+ onClick: () => {
262
+ const newItem = itemSchema.type === "object" ? {} : "";
263
+ handleFieldChange(fieldName, [...arrayValue, newItem]);
264
+ },
265
+ disabled,
266
+ children: [
267
+ /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 mr-1" }),
268
+ "Add"
269
+ ]
270
+ }
271
+ )
272
+ ] }),
273
+ fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description }),
274
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: arrayValue.map((item, index) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-start", children: [
275
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: itemSchema.type === "object" ? /* @__PURE__ */ jsx(Card, { className: "p-2 bg-gray-50/50", children: /* @__PURE__ */ jsx(
276
+ DynamicSchemaForm,
277
+ {
278
+ schema: itemSchema,
279
+ value: item,
280
+ onChange: (v) => {
281
+ const newArray = [...arrayValue];
282
+ newArray[index] = v;
283
+ handleFieldChange(fieldName, newArray);
284
+ },
285
+ disabled,
286
+ path: [...path, fieldName, String(index)],
287
+ components,
288
+ variables,
289
+ showVariablePicker
290
+ }
291
+ ) }) : /* @__PURE__ */ jsx(
292
+ Input,
293
+ {
294
+ value: item || "",
295
+ onChange: (e) => {
296
+ const newArray = [...arrayValue];
297
+ newArray[index] = e.target.value;
298
+ handleFieldChange(fieldName, newArray);
299
+ },
300
+ disabled,
301
+ className: "h-8 text-xs"
302
+ }
303
+ ) }),
304
+ /* @__PURE__ */ jsx(
305
+ Button,
306
+ {
307
+ type: "button",
308
+ variant: "ghost",
309
+ size: "sm",
310
+ className: "h-8 w-8 p-0 text-red-500 hover:text-red-700",
311
+ onClick: () => {
312
+ const newArray = arrayValue.filter(
313
+ (_, i) => i !== index
314
+ );
315
+ handleFieldChange(fieldName, newArray);
316
+ },
317
+ disabled,
318
+ children: /* @__PURE__ */ jsx(TrashIcon, { className: "h-3 w-3" })
319
+ }
320
+ )
321
+ ] }, index)) })
322
+ ] }, fieldPath);
323
+ }
324
+ if (fieldSchema.type === "boolean") {
325
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
326
+ /* @__PURE__ */ jsx(
327
+ Checkbox,
328
+ {
329
+ id: fieldPath,
330
+ checked: !!fieldValue,
331
+ onCheckedChange: (checked) => handleFieldChange(fieldName, checked),
332
+ disabled
333
+ }
334
+ ),
335
+ /* @__PURE__ */ jsxs(Label, { htmlFor: fieldPath, className: "text-xs font-normal", children: [
336
+ fieldSchema.title || fieldName,
337
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
338
+ ] }),
339
+ fieldSchema.description && /* @__PURE__ */ jsxs("span", { className: "text-[10px] text-muted-foreground ml-2", children: [
340
+ "(",
341
+ fieldSchema.description,
342
+ ")"
343
+ ] })
344
+ ] }, fieldPath);
345
+ }
346
+ if (fieldSchema.type === "number" || fieldSchema.type === "integer") {
347
+ const isVarValue = isVariableReference(fieldValue);
348
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
349
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
350
+ fieldSchema.title || fieldName,
351
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
352
+ ] }),
353
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
354
+ /* @__PURE__ */ jsx(
355
+ Input,
356
+ {
357
+ type: isVarValue ? "text" : "number",
358
+ value: fieldValue ?? "",
359
+ onChange: (e) => {
360
+ if (isVariableReference(e.target.value)) {
361
+ handleFieldChange(fieldName, e.target.value);
362
+ } else {
363
+ const val = e.target.value === "" ? void 0 : Number(e.target.value);
364
+ handleFieldChange(fieldName, val);
365
+ }
366
+ },
367
+ min: fieldSchema.minimum,
368
+ max: fieldSchema.maximum,
369
+ step: fieldSchema.type === "integer" ? 1 : "any",
370
+ disabled,
371
+ className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary")
372
+ }
373
+ ),
374
+ renderVariablePicker(
375
+ fieldName,
376
+ fieldSchema.type,
377
+ fieldPath,
378
+ (varPath) => handleFieldChange(fieldName, varPath)
379
+ )
380
+ ] }),
381
+ fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
382
+ ] }, fieldPath);
383
+ }
384
+ if (fieldSchema.type === "string") {
385
+ if (fieldSchema.format === "richtext") {
386
+ const isDialogOpen = openRichTextDialogs.has(fieldPath);
387
+ const draftValue = richTextDraftValues[fieldPath] ?? fieldValue ?? "";
388
+ const previewText = (fieldValue || "").replace(/<[^>]*>/g, "").slice(0, 50);
389
+ const matchingVars = getMatchingVariables("string");
390
+ if (!Dialog || !DialogContent || !DialogHeader || !DialogTitle || !DialogFooter) {
391
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
392
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
393
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
394
+ fieldSchema.title || fieldName,
395
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
396
+ ] }),
397
+ renderVariablePicker(
398
+ fieldName,
399
+ "string",
400
+ fieldPath,
401
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
402
+ )
403
+ ] }),
404
+ /* @__PURE__ */ jsx(
405
+ Textarea,
406
+ {
407
+ value: fieldValue || "",
408
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
409
+ disabled,
410
+ rows: 3,
411
+ className: "text-xs",
412
+ placeholder: fieldSchema.description
413
+ }
414
+ )
415
+ ] }, fieldPath);
416
+ }
417
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
418
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
419
+ fieldSchema.title || fieldName,
420
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
421
+ ] }),
422
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
423
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0 px-2 py-1.5 bg-muted/50 rounded text-xs text-muted-foreground truncate border", children: previewText || /* @__PURE__ */ jsx("span", { className: "italic", children: "Click edit to add content..." }) }),
424
+ /* @__PURE__ */ jsx(
425
+ Button,
426
+ {
427
+ type: "button",
428
+ variant: "outline",
429
+ size: "sm",
430
+ className: "h-8 px-2 shrink-0",
431
+ onClick: () => {
432
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: fieldValue || "" }));
433
+ setOpenRichTextDialogs((prev) => new Set(prev).add(fieldPath));
434
+ },
435
+ disabled,
436
+ children: EditIcon ? /* @__PURE__ */ jsx(EditIcon, { className: "h-3.5 w-3.5" }) : "Edit"
437
+ }
438
+ )
439
+ ] }),
440
+ /* @__PURE__ */ jsx(
441
+ Dialog,
442
+ {
443
+ open: isDialogOpen,
444
+ onOpenChange: (open) => {
445
+ if (!open) {
446
+ setOpenRichTextDialogs((prev) => {
447
+ const next = new Set(prev);
448
+ next.delete(fieldPath);
449
+ return next;
450
+ });
451
+ }
452
+ },
453
+ children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-3xl max-h-[85vh] flex flex-col", children: [
454
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
455
+ "Edit ",
456
+ fieldSchema.title || fieldName
457
+ ] }) }),
458
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden flex flex-col min-h-0", children: MarkdownEditor ? /* @__PURE__ */ jsx(
459
+ MarkdownEditor,
460
+ {
461
+ content: draftValue,
462
+ onChange: (value2) => {
463
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: value2 }));
464
+ },
465
+ placeholder: "Enter content... Use {{variables.name}} for dynamic values",
466
+ minHeight: "300px",
467
+ variables: showVariablePicker ? matchingVars : []
468
+ }
469
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
470
+ /* @__PURE__ */ jsx(
471
+ Textarea,
472
+ {
473
+ value: draftValue,
474
+ onChange: (e) => {
475
+ setRichTextDraftValues((prev) => ({ ...prev, [fieldPath]: e.target.value }));
476
+ },
477
+ rows: 12,
478
+ className: "flex-1 text-sm font-mono resize-none",
479
+ placeholder: "Enter content... Use {{variables.name}} for dynamic values"
480
+ }
481
+ ),
482
+ showVariablePicker && matchingVars.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border rounded-md p-2 bg-muted/30 mt-3", children: [
483
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium mb-2", children: "Insert Variable:" }),
484
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: matchingVars.map((variable) => /* @__PURE__ */ jsx(
485
+ Button,
486
+ {
487
+ type: "button",
488
+ variant: "outline",
489
+ size: "sm",
490
+ className: "h-6 text-xs px-2",
491
+ onClick: () => {
492
+ const varRef = `{{${variable.path}}}`;
493
+ setRichTextDraftValues((prev) => ({
494
+ ...prev,
495
+ [fieldPath]: (prev[fieldPath] || "") + varRef
496
+ }));
497
+ },
498
+ children: variable.title || variable.name
499
+ },
500
+ variable.path
501
+ )) })
502
+ ] })
503
+ ] }) }),
504
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
505
+ /* @__PURE__ */ jsx(
506
+ Button,
507
+ {
508
+ type: "button",
509
+ variant: "outline",
510
+ onClick: () => {
511
+ setOpenRichTextDialogs((prev) => {
512
+ const next = new Set(prev);
513
+ next.delete(fieldPath);
514
+ return next;
515
+ });
516
+ },
517
+ children: "Cancel"
518
+ }
519
+ ),
520
+ /* @__PURE__ */ jsx(
521
+ Button,
522
+ {
523
+ type: "button",
524
+ onClick: () => {
525
+ handleFieldChange(fieldName, draftValue);
526
+ setOpenRichTextDialogs((prev) => {
527
+ const next = new Set(prev);
528
+ next.delete(fieldPath);
529
+ return next;
530
+ });
531
+ },
532
+ children: "Save"
533
+ }
534
+ )
535
+ ] })
536
+ ] })
537
+ }
538
+ )
539
+ ] }, fieldPath);
540
+ }
541
+ if (fieldSchema.format === "multiline" || fieldSchema.format === "textarea") {
542
+ const isVarValue2 = isVariableReference(fieldValue);
543
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
544
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
545
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
546
+ fieldSchema.title || fieldName,
547
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
548
+ ] }),
549
+ renderVariablePicker(
550
+ fieldName,
551
+ "string",
552
+ fieldPath,
553
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
554
+ )
555
+ ] }),
556
+ /* @__PURE__ */ jsx(
557
+ Textarea,
558
+ {
559
+ value: fieldValue || "",
560
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
561
+ disabled,
562
+ rows: 3,
563
+ className: cn("text-xs", isVarValue2 && "font-mono text-primary"),
564
+ placeholder: fieldSchema.description
565
+ }
566
+ ),
567
+ fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
568
+ ] }, fieldPath);
569
+ }
570
+ const inputType = fieldSchema.format === "email" ? "email" : fieldSchema.format === "uri" || fieldSchema.format === "url" ? "url" : fieldSchema.format === "password" ? "password" : "text";
571
+ const isVarValue = isVariableReference(fieldValue);
572
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
573
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
574
+ fieldSchema.title || fieldName,
575
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
576
+ ] }),
577
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
578
+ /* @__PURE__ */ jsx(
579
+ Input,
580
+ {
581
+ type: inputType,
582
+ value: fieldValue || "",
583
+ onChange: (e) => handleFieldChange(fieldName, e.target.value),
584
+ disabled,
585
+ className: cn("h-8 text-xs flex-1", isVarValue && "font-mono text-primary"),
586
+ placeholder: fieldSchema.description
587
+ }
588
+ ),
589
+ renderVariablePicker(
590
+ fieldName,
591
+ "string",
592
+ fieldPath,
593
+ (varPath) => handleFieldChange(fieldName, (fieldValue || "") + varPath)
594
+ )
595
+ ] }),
596
+ fieldSchema.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: fieldSchema.description })
597
+ ] }, fieldPath);
598
+ }
599
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
600
+ /* @__PURE__ */ jsxs(Label, { className: "text-xs font-medium", children: [
601
+ fieldSchema.title || fieldName,
602
+ isRequired && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
603
+ ] }),
604
+ /* @__PURE__ */ jsx(
605
+ Input,
606
+ {
607
+ value: typeof fieldValue === "object" ? JSON.stringify(fieldValue) : fieldValue || "",
608
+ onChange: (e) => {
609
+ try {
610
+ const parsed = JSON.parse(e.target.value);
611
+ handleFieldChange(fieldName, parsed);
612
+ } catch {
613
+ handleFieldChange(fieldName, e.target.value);
614
+ }
615
+ },
616
+ disabled,
617
+ className: "h-8 text-xs font-mono"
618
+ }
619
+ ),
620
+ /* @__PURE__ */ jsxs("p", { className: "text-[10px] text-muted-foreground", children: [
621
+ "Type: ",
622
+ fieldSchema.type || "unknown"
623
+ ] })
624
+ ] }, fieldPath);
625
+ };
626
+ if (schema.type === "object" && schema.properties) {
627
+ const sortedProperties = Object.entries(schema.properties).sort(
628
+ ([, a], [, b]) => {
629
+ const orderA = a["x-displayOrder"] ?? 999;
630
+ const orderB = b["x-displayOrder"] ?? 999;
631
+ return orderA - orderB;
632
+ }
633
+ );
634
+ return /* @__PURE__ */ jsx("div", { className: "space-y-3", children: sortedProperties.map(
635
+ ([fieldName, fieldSchema]) => renderField(fieldSchema, fieldName, value[fieldName])
636
+ ) });
637
+ }
638
+ return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground text-center py-4", children: "No configuration required for this node." });
639
+ }
640
+
641
+ // components/schema-builder.tsx
642
+ import { useState as useState2 } from "react";
643
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
644
+ var FIELD_TYPES = [
645
+ { value: "string", label: "Text" },
646
+ { value: "number", label: "Number" },
647
+ { value: "integer", label: "Integer" },
648
+ { value: "boolean", label: "Boolean" },
649
+ { value: "array", label: "Array" },
650
+ { value: "object", label: "Object" }
651
+ ];
652
+ var STRING_FORMATS = [
653
+ { value: "plain", label: "Plain Text" },
654
+ { value: "email", label: "Email" },
655
+ { value: "uri", label: "URL" },
656
+ { value: "date", label: "Date" },
657
+ { value: "date-time", label: "Date & Time" },
658
+ { value: "multiline", label: "Multiline Text" }
659
+ ];
660
+ function SchemaBuilder({
661
+ schema,
662
+ onChange,
663
+ disabled = false,
664
+ components
665
+ }) {
666
+ const [expandedFields, setExpandedFields] = useState2(/* @__PURE__ */ new Set());
667
+ const {
668
+ Input,
669
+ Label,
670
+ Checkbox,
671
+ Select,
672
+ SelectTrigger,
673
+ SelectValue,
674
+ SelectContent,
675
+ SelectItem,
676
+ Button,
677
+ Card,
678
+ PlusIcon,
679
+ TrashIcon,
680
+ GripVerticalIcon,
681
+ ChevronDownIcon,
682
+ ChevronRightIcon
683
+ } = components;
684
+ const getFieldsFromSchema = () => {
685
+ if (!schema?.properties) return [];
686
+ return Object.entries(schema.properties).map(([name, prop]) => {
687
+ const fieldSchema = prop;
688
+ return {
689
+ name,
690
+ type: fieldSchema.type || "string",
691
+ title: fieldSchema.title || name,
692
+ description: fieldSchema.description || "",
693
+ required: schema.required?.includes(name) || false,
694
+ format: fieldSchema.format,
695
+ enum: fieldSchema.enum,
696
+ items: fieldSchema.items
697
+ };
698
+ });
699
+ };
700
+ const fields = getFieldsFromSchema();
701
+ const updateSchema = (newFields) => {
702
+ const properties = {};
703
+ const required = [];
704
+ newFields.forEach((field) => {
705
+ if (!field.name) return;
706
+ const fieldSchema = {
707
+ type: field.type,
708
+ title: field.title || field.name
709
+ };
710
+ if (field.description) {
711
+ fieldSchema.description = field.description;
712
+ }
713
+ if (field.format && field.format !== "plain") {
714
+ fieldSchema.format = field.format;
715
+ }
716
+ if (field.enum && field.enum.length > 0) {
717
+ fieldSchema.enum = field.enum;
718
+ }
719
+ if (field.type === "array" && field.items) {
720
+ fieldSchema.items = field.items;
721
+ }
722
+ properties[field.name] = fieldSchema;
723
+ if (field.required) {
724
+ required.push(field.name);
725
+ }
726
+ });
727
+ onChange({
728
+ type: "object",
729
+ properties,
730
+ required: required.length > 0 ? required : void 0
731
+ });
732
+ };
733
+ const addField = () => {
734
+ const newFieldName = `field_${fields.length + 1}`;
735
+ const newFields = [
736
+ ...fields,
737
+ {
738
+ name: newFieldName,
739
+ type: "string",
740
+ title: "",
741
+ description: "",
742
+ required: false
743
+ }
744
+ ];
745
+ updateSchema(newFields);
746
+ setExpandedFields((prev) => /* @__PURE__ */ new Set([...prev, newFieldName]));
747
+ };
748
+ const updateField = (index, updates) => {
749
+ const newFields = [...fields];
750
+ newFields[index] = { ...newFields[index], ...updates };
751
+ updateSchema(newFields);
752
+ };
753
+ const removeField = (index) => {
754
+ const newFields = fields.filter((_, i) => i !== index);
755
+ updateSchema(newFields);
756
+ };
757
+ const toggleExpand = (name) => {
758
+ setExpandedFields((prev) => {
759
+ const next = new Set(prev);
760
+ if (next.has(name)) {
761
+ next.delete(name);
762
+ } else {
763
+ next.add(name);
764
+ }
765
+ return next;
766
+ });
767
+ };
768
+ return /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
769
+ fields.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "text-xs text-muted-foreground italic py-3", children: 'No fields defined. Click "Add Field" to create one.' }) : /* @__PURE__ */ jsx2("div", { className: "space-y-3", children: fields.map((field, index) => {
770
+ const isExpanded = expandedFields.has(field.name);
771
+ return /* @__PURE__ */ jsxs2(Card, { className: "p-3 bg-gray-50/50", children: [
772
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 mb-2", children: [
773
+ /* @__PURE__ */ jsx2(GripVerticalIcon, { className: "h-4 w-4 text-gray-300 flex-shrink-0 cursor-grab" }),
774
+ /* @__PURE__ */ jsx2(
775
+ "button",
776
+ {
777
+ type: "button",
778
+ onClick: () => toggleExpand(field.name),
779
+ className: "flex-shrink-0 p-1 hover:bg-gray-200 rounded",
780
+ children: isExpanded ? /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "h-4 w-4 text-gray-500" }) : /* @__PURE__ */ jsx2(ChevronRightIcon, { className: "h-4 w-4 text-gray-500" })
781
+ }
782
+ ),
783
+ /* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsx2(
784
+ Input,
785
+ {
786
+ value: field.name,
787
+ onChange: (e) => {
788
+ const oldName = field.name;
789
+ const newName = e.target.value.toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "");
790
+ updateField(index, { name: newName });
791
+ if (expandedFields.has(oldName)) {
792
+ setExpandedFields((prev) => {
793
+ const next = new Set(prev);
794
+ next.delete(oldName);
795
+ next.add(newName);
796
+ return next;
797
+ });
798
+ }
799
+ },
800
+ placeholder: "field_name",
801
+ className: "h-9 text-sm font-mono",
802
+ disabled
803
+ }
804
+ ) }),
805
+ /* @__PURE__ */ jsx2(
806
+ Button,
807
+ {
808
+ type: "button",
809
+ variant: "ghost",
810
+ size: "sm",
811
+ className: "h-9 w-9 p-0 text-red-500 hover:text-red-700 hover:bg-red-50 flex-shrink-0",
812
+ onClick: () => removeField(index),
813
+ disabled,
814
+ children: /* @__PURE__ */ jsx2(TrashIcon, { className: "h-4 w-4" })
815
+ }
816
+ )
817
+ ] }),
818
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3 pl-10", children: [
819
+ /* @__PURE__ */ jsx2("div", { className: "flex-1", children: /* @__PURE__ */ jsxs2(
820
+ Select,
821
+ {
822
+ value: field.type,
823
+ onValueChange: (v) => updateField(index, { type: v }),
824
+ disabled,
825
+ children: [
826
+ /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
827
+ /* @__PURE__ */ jsx2(SelectContent, { children: FIELD_TYPES.map((type) => /* @__PURE__ */ jsx2(SelectItem, { value: type.value, children: type.label }, type.value)) })
828
+ ]
829
+ }
830
+ ) }),
831
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 flex-shrink-0", children: [
832
+ /* @__PURE__ */ jsx2(
833
+ Checkbox,
834
+ {
835
+ id: `required-${index}`,
836
+ checked: field.required,
837
+ onCheckedChange: (checked) => updateField(index, { required: !!checked }),
838
+ disabled
839
+ }
840
+ ),
841
+ /* @__PURE__ */ jsx2(
842
+ Label,
843
+ {
844
+ htmlFor: `required-${index}`,
845
+ className: "text-sm text-muted-foreground",
846
+ children: "Required"
847
+ }
848
+ )
849
+ ] })
850
+ ] }),
851
+ isExpanded && /* @__PURE__ */ jsxs2("div", { className: "mt-3 pt-3 border-t space-y-3 pl-10", children: [
852
+ /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
853
+ /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Display Title" }),
854
+ /* @__PURE__ */ jsx2(
855
+ Input,
856
+ {
857
+ value: field.title,
858
+ onChange: (e) => updateField(index, { title: e.target.value }),
859
+ placeholder: "Human readable title",
860
+ className: "h-9 text-sm",
861
+ disabled
862
+ }
863
+ )
864
+ ] }),
865
+ /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
866
+ /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Description" }),
867
+ /* @__PURE__ */ jsx2(
868
+ Input,
869
+ {
870
+ value: field.description,
871
+ onChange: (e) => updateField(index, { description: e.target.value }),
872
+ placeholder: "Help text for this field",
873
+ className: "h-9 text-sm",
874
+ disabled
875
+ }
876
+ )
877
+ ] }),
878
+ field.type === "string" && /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
879
+ /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Format" }),
880
+ /* @__PURE__ */ jsxs2(
881
+ Select,
882
+ {
883
+ value: field.format || "plain",
884
+ onValueChange: (v) => updateField(index, { format: v }),
885
+ disabled,
886
+ children: [
887
+ /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
888
+ /* @__PURE__ */ jsx2(SelectContent, { children: STRING_FORMATS.map((format) => /* @__PURE__ */ jsx2(SelectItem, { value: format.value, children: format.label }, format.value)) })
889
+ ]
890
+ }
891
+ )
892
+ ] }),
893
+ field.type === "array" && /* @__PURE__ */ jsxs2("div", { className: "space-y-1", children: [
894
+ /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Item Type" }),
895
+ /* @__PURE__ */ jsxs2(
896
+ Select,
897
+ {
898
+ value: field.items?.type || "string",
899
+ onValueChange: (v) => updateField(index, { items: { type: v } }),
900
+ disabled,
901
+ children: [
902
+ /* @__PURE__ */ jsx2(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx2(SelectValue, {}) }),
903
+ /* @__PURE__ */ jsx2(SelectContent, { children: FIELD_TYPES.filter((t) => t.value !== "array").map(
904
+ (type) => /* @__PURE__ */ jsx2(SelectItem, { value: type.value, children: type.label }, type.value)
905
+ ) })
906
+ ]
907
+ }
908
+ )
909
+ ] }),
910
+ field.type === "string" && /* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
911
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between", children: [
912
+ /* @__PURE__ */ jsx2(Label, { className: "text-xs text-muted-foreground", children: "Dropdown Options (optional)" }),
913
+ /* @__PURE__ */ jsxs2(
914
+ Button,
915
+ {
916
+ type: "button",
917
+ variant: "outline",
918
+ size: "sm",
919
+ className: "h-7 text-xs",
920
+ onClick: () => {
921
+ const currentEnum = field.enum || [];
922
+ updateField(index, {
923
+ enum: [
924
+ ...currentEnum,
925
+ `option_${currentEnum.length + 1}`
926
+ ]
927
+ });
928
+ },
929
+ disabled,
930
+ children: [
931
+ /* @__PURE__ */ jsx2(PlusIcon, { className: "h-3 w-3 mr-1" }),
932
+ "Add Option"
933
+ ]
934
+ }
935
+ )
936
+ ] }),
937
+ field.enum && field.enum.length > 0 && /* @__PURE__ */ jsx2("div", { className: "space-y-2", children: field.enum.map((option, optIdx) => /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
938
+ /* @__PURE__ */ jsx2(
939
+ Input,
940
+ {
941
+ value: option,
942
+ onChange: (e) => {
943
+ const newEnum = [...field.enum || []];
944
+ newEnum[optIdx] = e.target.value;
945
+ updateField(index, { enum: newEnum });
946
+ },
947
+ placeholder: `Option ${optIdx + 1}`,
948
+ className: "h-8 text-sm flex-1",
949
+ disabled
950
+ }
951
+ ),
952
+ /* @__PURE__ */ jsx2(
953
+ Button,
954
+ {
955
+ type: "button",
956
+ variant: "ghost",
957
+ size: "sm",
958
+ className: "h-8 w-8 p-0 text-red-400 hover:text-red-600",
959
+ onClick: () => {
960
+ const newEnum = (field.enum || []).filter(
961
+ (_, i) => i !== optIdx
962
+ );
963
+ updateField(index, {
964
+ enum: newEnum.length > 0 ? newEnum : void 0
965
+ });
966
+ },
967
+ disabled,
968
+ children: /* @__PURE__ */ jsx2(TrashIcon, { className: "h-3 w-3" })
969
+ }
970
+ )
971
+ ] }, optIdx)) })
972
+ ] })
973
+ ] })
974
+ ] }, index);
975
+ }) }),
976
+ /* @__PURE__ */ jsxs2(
977
+ Button,
978
+ {
979
+ type: "button",
980
+ variant: "outline",
981
+ size: "sm",
982
+ className: "w-full h-9 text-sm",
983
+ onClick: addField,
984
+ disabled,
985
+ children: [
986
+ /* @__PURE__ */ jsx2(PlusIcon, { className: "h-4 w-4 mr-2" }),
987
+ "Add Field"
988
+ ]
989
+ }
990
+ )
991
+ ] });
992
+ }
993
+
994
+ // context/workflow-definition-context.tsx
995
+ import { createContext, useContext, useMemo as useMemo2 } from "react";
996
+
997
+ // hooks/use-workflow-definition.ts
998
+ import { useNatsContext } from "@elqnt/nats";
999
+ import { useCallback, useEffect } from "react";
1000
+ import { useDispatch, useSelector } from "react-redux";
1001
+
1002
+ // models/workflow.ts
1003
+ var NodeTypeTrigger = "trigger";
1004
+ var NodeTypeHumanAction = "humanAction";
1005
+ var NodeTypeAgent = "agent";
1006
+ var NodeTypeAction = "action";
1007
+ var NodeTypeLogic = "logic";
1008
+ var NodeTypeLoop = "loop";
1009
+ var NodeTypeParallel = "parallel";
1010
+ var NodeTypeDelay = "delay";
1011
+ var NodeTypeData = "data";
1012
+ var NodeTypeIntegration = "integration";
1013
+ var NodeTypeTimer = "timer";
1014
+ var NodeTypeSubflow = "subflow";
1015
+ var NodeTypeCustom = "custom";
1016
+ var NodeTypeAccounting = "accounting";
1017
+ var NodeSubTypeTriggerStart = "triggerStart";
1018
+ var NodeSubTypeTriggerEntityRecordCreated = "triggerEntityRecordCreated";
1019
+ var NodeSubTypeTriggerEntityRecordUpdated = "triggerEntityRecordUpdated";
1020
+ var NodeSubTypeTriggerEntityRecordDeleted = "triggerEntityRecordDeleted";
1021
+ var NodeSubTypeTriggerSLAWarning = "triggerSLAWarning";
1022
+ var NodeSubTypeTriggerSLABreach = "triggerSLABreach";
1023
+ var NodeSubTypeTriggerEscalation = "triggerEscalation";
1024
+ var NodeSubTypeTriggerWebhookReceived = "triggerWebhookReceived";
1025
+ var NodeSubTypeHumanActionReview = "humanActionReview";
1026
+ var NodeSubTypeHumanActionApproval = "humanActionApproval";
1027
+ var NodeSubTypeHumanActionDataEntry = "humanActionDataEntry";
1028
+ var NodeSubTypeHumanActionAssignment = "humanActionAssignment";
1029
+ var NodeSubTypeAgentChat = "agentChat";
1030
+ var NodeSubTypeAgentIntentDetector = "agentIntentDetector";
1031
+ var NodeSubTypeAgentKnowledgeGraph = "agentKnowledgeGraph";
1032
+ var NodeSubTypeAgentClientApiCall = "clientApiCall";
1033
+ var NodeSubTypeAgentTransferToHuman = "agentTransferToHuman";
1034
+ var NodeSubTypeAgentOpenTicket = "agentOpenTicket";
1035
+ var NodeSubTypeAgentApiIntegration = "agentApiIntegration";
1036
+ var NodeSubTypeAgentCustomResponse = "agentCustomResponse";
1037
+ var NodeSubTypeAgentStructuredOutput = "agentStructuredOutput";
1038
+ var NodeSubTypeActionApiCall = "actionApiCall";
1039
+ var NodeSubTypeActionDocumentExtraction = "actionDocumentExtraction";
1040
+ var NodeSubTypeActionSendEmail = "actionSendEmail";
1041
+ var NodeSubTypeActionSendSMS = "actionSendSMS";
1042
+ var NodeSubTypeActionGenerateDocument = "actionGenerateDocument";
1043
+ var NodeSubTypeActionProcessPayment = "actionProcessPayment";
1044
+ var NodeSubTypeActionCreateEntityRecord = "actionCreateEntityRecord";
1045
+ var NodeSubTypeActionUpdateEntityRecord = "actionUpdateEntityRecord";
1046
+ var NodeSubTypeActionDeleteEntityRecord = "actionDeleteEntityRecord";
1047
+ var NodeSubTypeActionMergeEntityRecords = "actionMergeEntityRecords";
1048
+ var NodeSubTypeActionAssignSLAPolicy = "actionAssignSLAPolicy";
1049
+ var NodeSubTypeActionChangeSLAStatus = "actionChangeSLAAssignmentStatus";
1050
+ var NodeSubTypeActionEscalateSLA = "actionEscalateSLAAssignment";
1051
+ var NodeSubTypeActionCSATSurvey = "actionCSATSurvey";
1052
+ var NodeSubTypeActionSetVariables = "actionSetVariables";
1053
+ var NodeSubTypeActionQueryEntityRecords = "actionQueryEntityRecords";
1054
+ var NodeSubTypeActionNatsRequest = "actionNatsRequest";
1055
+ var NodeSubTypeLogicIf = "logicIf";
1056
+ var NodeSubTypeLogicSwitch = "logicSwitch";
1057
+ var NodeSubTypeLogicFor = "logicFor";
1058
+ var NodeSubTypeLogicParallel = "logicParallel";
1059
+ var NodeSubTypeLoopData = "loopData";
1060
+ var NodeSubTypeDelay = "delay";
1061
+ var NodeSubTypeDataFilter = "dataFilter";
1062
+ var NodeSubTypeDataMap = "dataMap";
1063
+ var NodeSubTypeDataCalculate = "dataCalculate";
1064
+ var NodeSubTypeDataValidate = "dataValidate";
1065
+ var NodeSubTypeTimerDelay = "timerDelay";
1066
+ var NodeSubTypeTimerSchedule = "timerSchedule";
1067
+ var NodeSubTypeTimerBusinessHours = "timerBusinessHours";
1068
+ var ExpressionTypeFilter = "filter";
1069
+ var ExpressionTypeJavaScript = "javascript";
1070
+ var ExpressionTypeTemplate = "template";
1071
+ var ExpressionTypeDSL = "dsl";
1072
+ var ExpressionTypeRules = "rules";
1073
+ var EdgeTypeNormal = "normal";
1074
+ var EdgeTypeLoopBack = "loopBack";
1075
+ var EdgeTypeError = "error";
1076
+ var EdgeTypeDefault = "default";
1077
+ var EdgeTypeParallel = "parallel";
1078
+ var EdgeTypeConditional = "conditional";
1079
+ var EdgeTypeMerge = "merge";
1080
+ var EdgeTypeCompensation = "compensation";
1081
+ var EdgeTypeTimeout = "timeout";
1082
+ var WorkflowTypeEntity = "entity";
1083
+ var WorkflowTypeDocument = "document";
1084
+ var WorkflowTypeChat = "chat";
1085
+ var WorkflowTypeAgent = "agent";
1086
+ var WorkflowTypeProductivity = "productivity";
1087
+ var RuleLevelError = "error";
1088
+ var RuleLevelWarning = "warning";
1089
+ var RuleLevelInfo = "info";
1090
+ var PersistenceTypeEphemeral = "ephemeral";
1091
+ var PersistenceTypePermanent = "permanent";
1092
+ var TimeoutActionFail = "fail";
1093
+ var TimeoutActionSkip = "skip";
1094
+ var TimeoutActionRetry = "retry";
1095
+ var TimeoutActionAlt = "alt";
1096
+ var InstanceStatusNew = "NEW";
1097
+ var InstanceStatusRunning = "RUNNING";
1098
+ var InstanceStatusWaiting = "WAITING";
1099
+ var InstanceStatusPaused = "PAUSED";
1100
+ var InstanceStatusCompleted = "COMPLETED";
1101
+ var InstanceStatusFailed = "FAILED";
1102
+ var NodeStatusPending = "PENDING";
1103
+ var NodeStatusRunning = "RUNNING";
1104
+ var NodeStatusCompleted = "COMPLETED";
1105
+ var NodeStatusFailed = "FAILED";
1106
+ var NodeStatusWaiting = "WAITING";
1107
+ var NodeStatusSkipped = "SKIPPED";
1108
+ var EdgeStatusPending = "PENDING";
1109
+ var EdgeStatusCompleted = "COMPLETED";
1110
+ var EdgeStatusSkipped = "SKIPPED";
1111
+
1112
+ // models/subjects.ts
1113
+ var WorkflowDefinitionCreate = "workflow.definition.create";
1114
+ var WorkflowDefinitionCreated = "workflow.definition.created";
1115
+ var WorkflowDefinitionUpdate = "workflow.definition.update";
1116
+ var WorkflowDefinitionUpdated = "workflow.definition.updated";
1117
+ var WorkflowDefinitionGet = "workflow.definition.get";
1118
+ var WorkflowDefinitionGetServer = "workflow.definition.get.server";
1119
+ var WorkflowDefinitionGetByTitle = "workflow.definition.get.by.title";
1120
+ var WorkflowDefinitionList = "workflow.definition.list";
1121
+ var WorkflowDefinitionDelete = "workflow.definition.delete";
1122
+ var WorkflowDefinitionDeleted = "workflow.definition.deleted";
1123
+ var WorkflowInstanceCreate = "workflow.instance.create";
1124
+ var WorkflowInstanceExecuteNode = "workflow.instance.execute.node";
1125
+ var WorkflowInstanceResumeNode = "workflow.instance.resume.node";
1126
+ var WorkflowInstanceExecuteNodeServer = "workflow.instance.execute.node.server";
1127
+ var WorkflowInstanceResumeNodeServer = "workflow.instance.resume.node.server";
1128
+ var WorkflowInstanceExecuteNodeLean = "workflow.instance.execute.node.lean";
1129
+ var WorkflowInstanceExecuteNodeLeanServer = "workflow.instance.execute.node.lean.server";
1130
+ var WorkflowInstanceGet = "workflow.instance.get";
1131
+ var WorkflowInstanceList = "workflow.instance.list";
1132
+ var WorkflowInstanceUpdate = "workflow.instance.update";
1133
+ var WorkflowInstanceUpdated = "workflow.instance.updated";
1134
+ var WorkflowInstanceUpdateNodeMetadata = "workflow.instance.update.node.metadata";
1135
+ var WorkflowTemplateList = "workflow.template.list";
1136
+ var WorkflowTemplateGet = "workflow.template.get";
1137
+ var WorkflowTemplateInstantiate = "workflow.template.instantiate";
1138
+ var WorkflowScheduleCreate = "workflow.schedule.create";
1139
+ var WorkflowScheduleUpdate = "workflow.schedule.update";
1140
+ var WorkflowScheduleDelete = "workflow.schedule.delete";
1141
+ var WorkflowScheduleList = "workflow.schedule.list";
1142
+ var WorkflowSchedulePause = "workflow.schedule.pause";
1143
+ var WorkflowScheduleResume = "workflow.schedule.resume";
1144
+ var WorkflowTriggerRegister = "workflow.trigger.register";
1145
+ var WorkflowTriggerPause = "workflow.trigger.pause";
1146
+ var WorkflowTriggerResume = "workflow.trigger.resume";
1147
+ var WorkflowTriggerStatus = "workflow.trigger.status";
1148
+ var WorkflowTriggerFired = "workflow.trigger.fired";
1149
+ var WorkflowExecutionStarted = "workflow.execution.started";
1150
+ var WorkflowExecutionCompleted = "workflow.execution.completed";
1151
+ var WorkflowExecutionFailed = "workflow.execution.failed";
1152
+
1153
+ // store/workflow-definition-slice.ts
1154
+ import { createSlice } from "@reduxjs/toolkit";
1155
+ var initialState = {
1156
+ definitions: {},
1157
+ isLoading: false,
1158
+ loadingStates: {}
1159
+ };
1160
+ var workflowDefinitionSlice = createSlice({
1161
+ name: "workflowDefinition",
1162
+ initialState,
1163
+ reducers: {
1164
+ setLoading: (state, action) => {
1165
+ state.isLoading = action.payload;
1166
+ },
1167
+ setOperationLoading: (state, action) => {
1168
+ state.loadingStates[action.payload.operation] = action.payload.loading;
1169
+ },
1170
+ setError: (state, action) => {
1171
+ state.error = action.payload;
1172
+ },
1173
+ setDefinitions: (state, action) => {
1174
+ state.definitions = action.payload.reduce(
1175
+ (acc, def) => {
1176
+ if (def.id) {
1177
+ acc[def.id] = def;
1178
+ }
1179
+ return acc;
1180
+ },
1181
+ {}
1182
+ );
1183
+ },
1184
+ addDefinition: (state, action) => {
1185
+ const definition = action.payload;
1186
+ if (definition.id) {
1187
+ state.definitions[definition.id] = definition;
1188
+ }
1189
+ },
1190
+ updateDefinition: (state, action) => {
1191
+ const definition = action.payload;
1192
+ if (definition.id) {
1193
+ state.definitions[definition.id] = definition;
1194
+ }
1195
+ if (state.selectedDefinition?.id === definition.id) {
1196
+ state.selectedDefinition = definition;
1197
+ }
1198
+ },
1199
+ removeDefinition: (state, action) => {
1200
+ delete state.definitions[action.payload];
1201
+ if (state.selectedDefinition?.id === action.payload) {
1202
+ state.selectedDefinition = void 0;
1203
+ }
1204
+ },
1205
+ setSelectedDefinition: (state, action) => {
1206
+ state.selectedDefinition = action.payload;
1207
+ }
1208
+ }
1209
+ });
1210
+ var {
1211
+ setLoading,
1212
+ setOperationLoading,
1213
+ setError,
1214
+ setDefinitions,
1215
+ addDefinition,
1216
+ updateDefinition,
1217
+ removeDefinition,
1218
+ setSelectedDefinition
1219
+ } = workflowDefinitionSlice.actions;
1220
+ var workflowDefinitionReducer = workflowDefinitionSlice.reducer;
1221
+
1222
+ // hooks/use-workflow-definition.ts
1223
+ function useWorkflowDefinition(orgId, definitionId, options = {}) {
1224
+ const { autoLoad } = options;
1225
+ const { natsConnected, request } = useNatsContext();
1226
+ const dispatch = useDispatch();
1227
+ const definitions = useSelector(
1228
+ (state) => state.workflowDefinition.definitions
1229
+ );
1230
+ const selectedDefinition = useSelector(
1231
+ (state) => state.workflowDefinition.selectedDefinition
1232
+ );
1233
+ const isLoading = useSelector(
1234
+ (state) => state.workflowDefinition.isLoading
1235
+ );
1236
+ const loadingStates = useSelector(
1237
+ (state) => state.workflowDefinition.loadingStates
1238
+ );
1239
+ const error = useSelector(
1240
+ (state) => state.workflowDefinition.error
1241
+ );
1242
+ const loadDefinitions = useCallback(async () => {
1243
+ if (!natsConnected || !orgId) return;
1244
+ const loadingKey = "loadDefinitions";
1245
+ if (loadingStates[loadingKey]) return;
1246
+ dispatch(setOperationLoading({ operation: loadingKey, loading: true }));
1247
+ try {
1248
+ const response = await request(WorkflowDefinitionList, { orgId });
1249
+ if (response instanceof Error) {
1250
+ dispatch(setError(response.message));
1251
+ } else {
1252
+ dispatch(setDefinitions(response?.definitions ?? []));
1253
+ }
1254
+ } catch (err) {
1255
+ dispatch(setError(err instanceof Error ? err.message : "Unknown error"));
1256
+ } finally {
1257
+ dispatch(setOperationLoading({ operation: loadingKey, loading: false }));
1258
+ }
1259
+ }, [natsConnected, orgId, dispatch, request]);
1260
+ const loadDefinition = useCallback(
1261
+ async (id) => {
1262
+ if (!natsConnected || !orgId) return;
1263
+ dispatch(setOperationLoading({ operation: `load_${id}`, loading: true }));
1264
+ try {
1265
+ const response = await request(WorkflowDefinitionGet, { id, orgId });
1266
+ if (response instanceof Error) {
1267
+ dispatch(setError(response.message));
1268
+ return;
1269
+ }
1270
+ dispatch(setSelectedDefinition(response.definition));
1271
+ } finally {
1272
+ dispatch(
1273
+ setOperationLoading({ operation: `load_${id}`, loading: false })
1274
+ );
1275
+ }
1276
+ },
1277
+ [natsConnected, orgId, dispatch, request]
1278
+ );
1279
+ const resetSelectedDefinition = useCallback(() => {
1280
+ dispatch(setSelectedDefinition(void 0));
1281
+ }, [dispatch]);
1282
+ const createDefinition = async (definition) => {
1283
+ if (!natsConnected || !orgId) {
1284
+ throw new Error("Not connected or missing orgId");
1285
+ }
1286
+ dispatch(setOperationLoading({ operation: "create", loading: true }));
1287
+ try {
1288
+ const response = await request(WorkflowDefinitionCreate, { definition, orgId });
1289
+ if (response instanceof Error) {
1290
+ throw response;
1291
+ }
1292
+ if (response.metadata.success) {
1293
+ dispatch(addDefinition(response.definition));
1294
+ }
1295
+ return response;
1296
+ } finally {
1297
+ dispatch(setOperationLoading({ operation: "create", loading: false }));
1298
+ }
1299
+ };
1300
+ const updateDefinitionById = async (id, definition) => {
1301
+ if (!natsConnected || !orgId) {
1302
+ throw new Error("Not connected or missing orgId");
1303
+ }
1304
+ dispatch(setOperationLoading({ operation: `update_${id}`, loading: true }));
1305
+ try {
1306
+ const response = await request(WorkflowDefinitionUpdate, {
1307
+ definition,
1308
+ orgId
1309
+ });
1310
+ if (response instanceof Error) {
1311
+ throw response;
1312
+ }
1313
+ if (response.metadata.success) {
1314
+ dispatch(updateDefinition(response.definition));
1315
+ }
1316
+ return response;
1317
+ } finally {
1318
+ dispatch(
1319
+ setOperationLoading({ operation: `update_${id}`, loading: false })
1320
+ );
1321
+ }
1322
+ };
1323
+ const deleteDefinition = async (id) => {
1324
+ if (!natsConnected || !orgId) {
1325
+ throw new Error("Not connected or missing orgId");
1326
+ }
1327
+ dispatch(setOperationLoading({ operation: `delete_${id}`, loading: true }));
1328
+ try {
1329
+ const response = await request(WorkflowDefinitionDelete, { id, orgId });
1330
+ if (response instanceof Error) {
1331
+ throw response;
1332
+ }
1333
+ dispatch(removeDefinition(id));
1334
+ return response;
1335
+ } finally {
1336
+ dispatch(
1337
+ setOperationLoading({ operation: `delete_${id}`, loading: false })
1338
+ );
1339
+ }
1340
+ };
1341
+ const refresh = useCallback(() => {
1342
+ if (!natsConnected || !orgId) return;
1343
+ if (definitionId) {
1344
+ loadDefinition(definitionId);
1345
+ } else {
1346
+ dispatch(setLoading(true));
1347
+ loadDefinitions().finally(() => dispatch(setLoading(false)));
1348
+ }
1349
+ }, [natsConnected, orgId, definitionId, loadDefinition, dispatch]);
1350
+ useEffect(() => {
1351
+ let mounted = true;
1352
+ if (autoLoad && natsConnected && orgId && mounted) {
1353
+ loadDefinitions();
1354
+ }
1355
+ return () => {
1356
+ mounted = false;
1357
+ };
1358
+ }, [autoLoad, natsConnected, orgId]);
1359
+ useEffect(() => {
1360
+ if (natsConnected && orgId && definitionId) {
1361
+ loadDefinition(definitionId);
1362
+ }
1363
+ }, [natsConnected, orgId, definitionId, loadDefinition]);
1364
+ return {
1365
+ // State
1366
+ definitions,
1367
+ selectedDefinition,
1368
+ isLoading,
1369
+ loadingStates,
1370
+ error,
1371
+ // Operations
1372
+ loadDefinitions,
1373
+ loadDefinition,
1374
+ resetSelectedDefinition,
1375
+ createDefinition,
1376
+ updateDefinition: updateDefinitionById,
1377
+ deleteDefinition,
1378
+ // Utilities
1379
+ refresh
1380
+ };
1381
+ }
1382
+
1383
+ // hooks/use-workflow-instance.ts
1384
+ import { useNatsContext as useNatsContext2 } from "@elqnt/nats";
1385
+ import { useCallback as useCallback2, useEffect as useEffect2 } from "react";
1386
+ import { useDispatch as useDispatch2, useSelector as useSelector2 } from "react-redux";
1387
+
1388
+ // store/workflow-instance-slice.ts
1389
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
1390
+ var initialState2 = {
1391
+ instances: {},
1392
+ isLoading: false,
1393
+ loadingStates: {}
1394
+ };
1395
+ var workflowInstanceSlice = createSlice2({
1396
+ name: "workflowInstance",
1397
+ initialState: initialState2,
1398
+ reducers: {
1399
+ setLoading: (state, action) => {
1400
+ state.isLoading = action.payload;
1401
+ },
1402
+ setOperationLoading: (state, action) => {
1403
+ state.loadingStates[action.payload.operation] = action.payload.loading;
1404
+ },
1405
+ setError: (state, action) => {
1406
+ state.error = action.payload;
1407
+ },
1408
+ setInstances: (state, action) => {
1409
+ state.instances = action.payload.reduce(
1410
+ (acc, inst) => {
1411
+ if (inst.id) {
1412
+ acc[inst.id] = inst;
1413
+ }
1414
+ return acc;
1415
+ },
1416
+ {}
1417
+ );
1418
+ },
1419
+ updateInstance: (state, action) => {
1420
+ const instance = action.payload;
1421
+ if (instance.id) {
1422
+ state.instances[instance.id] = instance;
1423
+ }
1424
+ if (state.selectedInstance?.id === instance.id) {
1425
+ state.selectedInstance = instance;
1426
+ }
1427
+ },
1428
+ setSelectedInstance: (state, action) => {
1429
+ state.selectedInstance = action.payload;
1430
+ }
1431
+ }
1432
+ });
1433
+ var {
1434
+ setLoading: setLoading2,
1435
+ setOperationLoading: setOperationLoading2,
1436
+ setError: setError2,
1437
+ setInstances,
1438
+ updateInstance,
1439
+ setSelectedInstance
1440
+ } = workflowInstanceSlice.actions;
1441
+ var workflowInstanceReducer = workflowInstanceSlice.reducer;
1442
+
1443
+ // hooks/use-workflow-instance.ts
1444
+ function useWorkflowInstance(orgId, instanceId, definitionId, options = {}) {
1445
+ const { autoLoad } = options;
1446
+ const { natsConnected, request } = useNatsContext2();
1447
+ const dispatch = useDispatch2();
1448
+ const instances = useSelector2(
1449
+ (state) => state.workflowInstance.instances
1450
+ );
1451
+ const selectedInstance = useSelector2(
1452
+ (state) => state.workflowInstance.selectedInstance
1453
+ );
1454
+ const isLoading = useSelector2(
1455
+ (state) => state.workflowInstance.isLoading
1456
+ );
1457
+ const loadingStates = useSelector2(
1458
+ (state) => state.workflowInstance.loadingStates
1459
+ );
1460
+ const error = useSelector2(
1461
+ (state) => state.workflowInstance.error
1462
+ );
1463
+ const loadInstances = useCallback2(
1464
+ async (defId) => {
1465
+ if (!natsConnected || !orgId) return;
1466
+ const loadingKey = `loadInstances_${defId}`;
1467
+ if (loadingStates[loadingKey]) return;
1468
+ dispatch(setOperationLoading2({ operation: loadingKey, loading: true }));
1469
+ try {
1470
+ const response = await request(WorkflowInstanceList, {
1471
+ orgId,
1472
+ definitionId: defId
1473
+ });
1474
+ if (response instanceof Error) {
1475
+ dispatch(setError2(response.message));
1476
+ } else {
1477
+ dispatch(setInstances(response?.instances ?? []));
1478
+ }
1479
+ } catch (err) {
1480
+ dispatch(
1481
+ setError2(err instanceof Error ? err.message : "Unknown error")
1482
+ );
1483
+ } finally {
1484
+ dispatch(
1485
+ setOperationLoading2({ operation: loadingKey, loading: false })
1486
+ );
1487
+ }
1488
+ },
1489
+ [natsConnected, orgId, dispatch, request]
1490
+ );
1491
+ const loadInstance = useCallback2(
1492
+ async (id) => {
1493
+ if (!natsConnected || !orgId) return;
1494
+ dispatch(setOperationLoading2({ operation: `load_${id}`, loading: true }));
1495
+ try {
1496
+ const response = await request(WorkflowInstanceGet, {
1497
+ orgId,
1498
+ instanceId: id
1499
+ });
1500
+ if (response instanceof Error) {
1501
+ dispatch(setError2(response.message));
1502
+ return;
1503
+ }
1504
+ dispatch(setSelectedInstance(response.instance));
1505
+ } finally {
1506
+ dispatch(
1507
+ setOperationLoading2({ operation: `load_${id}`, loading: false })
1508
+ );
1509
+ }
1510
+ },
1511
+ [natsConnected, orgId, dispatch, request]
1512
+ );
1513
+ const doSetSelectedInstance = useCallback2(
1514
+ (instance) => {
1515
+ dispatch(setSelectedInstance(instance));
1516
+ },
1517
+ [dispatch]
1518
+ );
1519
+ const getInstance = async (id) => {
1520
+ const response = await request(WorkflowInstanceGet, {
1521
+ orgId: orgId ?? "",
1522
+ instanceId: id
1523
+ });
1524
+ return response;
1525
+ };
1526
+ const createInstance = async (defId, variables) => {
1527
+ if (!natsConnected || !orgId) {
1528
+ throw new Error("Not connected or missing orgId");
1529
+ }
1530
+ dispatch(setOperationLoading2({ operation: "create", loading: true }));
1531
+ try {
1532
+ const response = await request(WorkflowInstanceCreate, {
1533
+ orgId,
1534
+ definitionId: defId,
1535
+ variables: variables ?? {},
1536
+ autoExecute: true
1537
+ });
1538
+ if (response instanceof Error) {
1539
+ throw response;
1540
+ }
1541
+ if (response.metadata.success && response.instance) {
1542
+ dispatch(updateInstance(response.instance));
1543
+ }
1544
+ return response;
1545
+ } finally {
1546
+ dispatch(setOperationLoading2({ operation: "create", loading: false }));
1547
+ }
1548
+ };
1549
+ const executeNode = async (instId, nodeId, input) => {
1550
+ if (!natsConnected || !orgId) {
1551
+ throw new Error("Not connected or missing orgId");
1552
+ }
1553
+ dispatch(
1554
+ setOperationLoading2({ operation: `execute_${nodeId}`, loading: true })
1555
+ );
1556
+ try {
1557
+ const response = await request(WorkflowInstanceExecuteNode, {
1558
+ orgId,
1559
+ instanceId: instId,
1560
+ nodeId,
1561
+ input
1562
+ });
1563
+ if (response instanceof Error) {
1564
+ throw response;
1565
+ }
1566
+ if (response.metadata.success && response.instance) {
1567
+ dispatch(updateInstance(response.instance));
1568
+ }
1569
+ return response;
1570
+ } finally {
1571
+ dispatch(
1572
+ setOperationLoading2({ operation: `execute_${nodeId}`, loading: false })
1573
+ );
1574
+ }
1575
+ };
1576
+ const updateInstanceNodeMetadata = async (instanceId2, nodeId, metadataKey, payload) => {
1577
+ if (!natsConnected || !orgId) {
1578
+ throw new Error("Not connected or missing orgId");
1579
+ }
1580
+ dispatch(
1581
+ setOperationLoading2({ operation: `update_${nodeId}`, loading: true })
1582
+ );
1583
+ try {
1584
+ const response = await request(WorkflowInstanceUpdateNodeMetadata, {
1585
+ orgId,
1586
+ instanceId: instanceId2,
1587
+ nodeId,
1588
+ metadataKey,
1589
+ payload
1590
+ });
1591
+ if (response instanceof Error) {
1592
+ throw response;
1593
+ }
1594
+ if (response.metadata.success && response.instance) {
1595
+ dispatch(updateInstance(response.instance));
1596
+ }
1597
+ return response;
1598
+ } finally {
1599
+ dispatch(
1600
+ setOperationLoading2({ operation: `update_${nodeId}`, loading: false })
1601
+ );
1602
+ }
1603
+ };
1604
+ const resumeInstanceNode = async (instanceId2, nodeId, result) => {
1605
+ if (!natsConnected || !orgId) {
1606
+ throw new Error("Not connected or missing orgId");
1607
+ }
1608
+ dispatch(
1609
+ setOperationLoading2({ operation: `update_${nodeId}`, loading: true })
1610
+ );
1611
+ try {
1612
+ const response = await request(WorkflowInstanceResumeNode, {
1613
+ orgId,
1614
+ instanceId: instanceId2,
1615
+ nodeId,
1616
+ result
1617
+ });
1618
+ if (response instanceof Error) {
1619
+ throw response;
1620
+ }
1621
+ if (response.metadata.success && response.instance) {
1622
+ dispatch(updateInstance(response.instance));
1623
+ }
1624
+ return response;
1625
+ } finally {
1626
+ dispatch(
1627
+ setOperationLoading2({ operation: `update_${nodeId}`, loading: false })
1628
+ );
1629
+ }
1630
+ };
1631
+ const refresh = useCallback2(() => {
1632
+ if (!natsConnected || !orgId) return;
1633
+ if (instanceId) {
1634
+ loadInstance(instanceId);
1635
+ } else if (definitionId) {
1636
+ dispatch(setLoading2(true));
1637
+ loadInstances(definitionId).finally(() => dispatch(setLoading2(false)));
1638
+ }
1639
+ }, [natsConnected, orgId, instanceId, definitionId, loadInstance, dispatch]);
1640
+ useEffect2(() => {
1641
+ let mounted = true;
1642
+ if (autoLoad && natsConnected && orgId && mounted) {
1643
+ if (instanceId) {
1644
+ loadInstance(instanceId);
1645
+ } else if (definitionId) {
1646
+ loadInstances(definitionId);
1647
+ }
1648
+ }
1649
+ return () => {
1650
+ mounted = false;
1651
+ };
1652
+ }, [autoLoad, natsConnected, orgId, instanceId, definitionId]);
1653
+ return {
1654
+ // State
1655
+ instances,
1656
+ selectedInstance,
1657
+ doSetSelectedInstance,
1658
+ isLoading,
1659
+ loadingStates,
1660
+ error,
1661
+ // Operations
1662
+ loadInstances,
1663
+ loadInstance,
1664
+ getInstance,
1665
+ createInstance,
1666
+ executeNode,
1667
+ updateInstanceNodeMetadata,
1668
+ resumeInstanceNode,
1669
+ // Utilities
1670
+ refresh
1671
+ };
1672
+ }
1673
+
1674
+ // context/workflow-definition-context.tsx
1675
+ import { jsx as jsx3 } from "react/jsx-runtime";
1676
+ var WorkflowDefinitionContext = createContext(void 0);
1677
+ function WorkflowDefinitionProvider({
1678
+ children,
1679
+ orgId,
1680
+ definitionId,
1681
+ options = {}
1682
+ }) {
1683
+ const hookValue = useWorkflowDefinition(orgId, definitionId, options);
1684
+ const value = useMemo2(() => hookValue, [hookValue]);
1685
+ return /* @__PURE__ */ jsx3(WorkflowDefinitionContext.Provider, { value, children });
1686
+ }
1687
+ function useWorkflowDefinitionContext() {
1688
+ const context = useContext(WorkflowDefinitionContext);
1689
+ if (!context) {
1690
+ throw new Error(
1691
+ "useWorkflowDefinitionContext must be used within an WorkflowDefinitionProvider"
1692
+ );
1693
+ }
1694
+ return context;
1695
+ }
1696
+
1697
+ // context/workflow-instance-context.tsx
1698
+ import { createContext as createContext2, useContext as useContext2, useMemo as useMemo3 } from "react";
1699
+ import { jsx as jsx4 } from "react/jsx-runtime";
1700
+ var WorkflowInstanceContext = createContext2(void 0);
1701
+ function WorkflowInstanceProvider({
1702
+ children,
1703
+ orgId,
1704
+ instanceId,
1705
+ definitionId,
1706
+ options = {}
1707
+ }) {
1708
+ const hookValue = useWorkflowInstance(
1709
+ orgId,
1710
+ instanceId,
1711
+ definitionId,
1712
+ options
1713
+ );
1714
+ const value = useMemo3(() => hookValue, [hookValue]);
1715
+ return /* @__PURE__ */ jsx4(WorkflowInstanceContext.Provider, { value, children });
1716
+ }
1717
+ function useWorkflowInstanceContext() {
1718
+ const context = useContext2(WorkflowInstanceContext);
1719
+ if (!context) {
1720
+ throw new Error(
1721
+ "useWorkflowInstanceContext must be used within an WorkflowInstanceProvider"
1722
+ );
1723
+ }
1724
+ return context;
1725
+ }
1726
+
1727
+ // schema/schemas.ts
1728
+ var nodeDefinitions = {
1729
+ "actionAIClassify": {
1730
+ "type": "agent",
1731
+ "subType": "actionAIClassify",
1732
+ "label": "AI Classify",
1733
+ "icon": "Tags",
1734
+ "description": "Classify content into categories using AI",
1735
+ "category": "AI & Automation",
1736
+ "config": {
1737
+ "type": "object",
1738
+ "title": "AI Classify",
1739
+ "properties": {
1740
+ "categories": {
1741
+ "type": "array",
1742
+ "title": "Categories",
1743
+ "description": "List of possible categories",
1744
+ "items": {
1745
+ "type": "string"
1746
+ }
1747
+ },
1748
+ "content": {
1749
+ "type": "string",
1750
+ "title": "Content",
1751
+ "format": "multiline"
1752
+ },
1753
+ "instructions": {
1754
+ "type": "string",
1755
+ "title": "Additional Instructions",
1756
+ "format": "multiline"
1757
+ },
1758
+ "multiLabel": {
1759
+ "type": "boolean",
1760
+ "title": "Allow Multiple Labels",
1761
+ "description": "Can content belong to multiple categories?",
1762
+ "default": false
1763
+ }
1764
+ },
1765
+ "required": [
1766
+ "content",
1767
+ "categories"
1768
+ ]
1769
+ },
1770
+ "input": {
1771
+ "type": "object"
1772
+ },
1773
+ "output": {
1774
+ "type": "object",
1775
+ "properties": {
1776
+ "categories": {
1777
+ "type": "array",
1778
+ "title": "Categories",
1779
+ "items": {
1780
+ "type": "string"
1781
+ }
1782
+ },
1783
+ "category": {
1784
+ "type": "string",
1785
+ "title": "Primary Category"
1786
+ },
1787
+ "confidence": {
1788
+ "type": "number",
1789
+ "title": "Confidence",
1790
+ "minimum": 0,
1791
+ "maximum": 1
1792
+ },
1793
+ "reasoning": {
1794
+ "type": "string",
1795
+ "title": "Reasoning"
1796
+ }
1797
+ }
1798
+ }
1799
+ },
1800
+ "actionAIExtractData": {
1801
+ "type": "agent",
1802
+ "subType": "actionAIExtractData",
1803
+ "label": "AI Extract Data",
1804
+ "icon": "FileSearch",
1805
+ "description": "Extract structured data from unstructured content",
1806
+ "category": "AI & Automation",
1807
+ "config": {
1808
+ "type": "object",
1809
+ "title": "AI Extract Data",
1810
+ "properties": {
1811
+ "content": {
1812
+ "type": "string",
1813
+ "title": "Content",
1814
+ "format": "multiline"
1815
+ },
1816
+ "extractionSchema": {
1817
+ "type": "object",
1818
+ "title": "Extraction Schema",
1819
+ "description": "JSON Schema defining what to extract"
1820
+ },
1821
+ "instructions": {
1822
+ "type": "string",
1823
+ "title": "Instructions",
1824
+ "format": "multiline"
1825
+ }
1826
+ },
1827
+ "required": [
1828
+ "content",
1829
+ "extractionSchema"
1830
+ ]
1831
+ },
1832
+ "input": {
1833
+ "type": "object"
1834
+ },
1835
+ "output": {
1836
+ "type": "object",
1837
+ "description": "Extracted data matching the schema"
1838
+ }
1839
+ },
1840
+ "actionAISummarize": {
1841
+ "type": "agent",
1842
+ "subType": "actionAISummarize",
1843
+ "label": "AI Summarize",
1844
+ "icon": "FileText",
1845
+ "description": "Summarize text content using AI",
1846
+ "category": "AI & Automation",
1847
+ "config": {
1848
+ "type": "object",
1849
+ "title": "AI Summarize",
1850
+ "properties": {
1851
+ "content": {
1852
+ "type": "string",
1853
+ "title": "Content",
1854
+ "description": "Text to summarize (supports {{variables}})",
1855
+ "format": "multiline"
1856
+ },
1857
+ "focusOn": {
1858
+ "type": "string",
1859
+ "title": "Focus On",
1860
+ "description": "Optional: specific aspects to focus on"
1861
+ },
1862
+ "maxLength": {
1863
+ "type": "integer",
1864
+ "title": "Max Length (words)",
1865
+ "minimum": 10,
1866
+ "maximum": 1e3
1867
+ },
1868
+ "style": {
1869
+ "type": "string",
1870
+ "title": "Style",
1871
+ "default": "brief",
1872
+ "enum": [
1873
+ "brief",
1874
+ "detailed",
1875
+ "bullet_points",
1876
+ "executive"
1877
+ ],
1878
+ "x-enumLabels": [
1879
+ "Brief (1-2 sentences)",
1880
+ "Detailed",
1881
+ "Bullet Points",
1882
+ "Executive Summary"
1883
+ ]
1884
+ }
1885
+ },
1886
+ "required": [
1887
+ "content",
1888
+ "style"
1889
+ ]
1890
+ },
1891
+ "input": {
1892
+ "type": "object"
1893
+ },
1894
+ "output": {
1895
+ "type": "object",
1896
+ "properties": {
1897
+ "keyPoints": {
1898
+ "type": "array",
1899
+ "title": "Key Points",
1900
+ "items": {
1901
+ "type": "string"
1902
+ }
1903
+ },
1904
+ "summary": {
1905
+ "type": "string",
1906
+ "title": "Summary"
1907
+ },
1908
+ "wordCount": {
1909
+ "type": "integer",
1910
+ "title": "Word Count"
1911
+ }
1912
+ }
1913
+ }
1914
+ },
1915
+ "actionApiCall": {
1916
+ "type": "action",
1917
+ "subType": "actionApiCall",
1918
+ "label": "API Call",
1919
+ "icon": "Globe",
1920
+ "description": "Make HTTP API requests",
1921
+ "category": "Integration",
1922
+ "config": {
1923
+ "type": "object",
1924
+ "title": "API Call",
1925
+ "properties": {
1926
+ "authorization": {
1927
+ "type": "string",
1928
+ "title": "Authorization",
1929
+ "x-displayOrder": 5
1930
+ },
1931
+ "callbackTimeout": {
1932
+ "type": "integer",
1933
+ "title": "Callback Timeout (ms)",
1934
+ "description": "For async mode only",
1935
+ "x-displayOrder": 9
1936
+ },
1937
+ "headers": {
1938
+ "type": "object",
1939
+ "title": "Headers",
1940
+ "x-displayOrder": 4
1941
+ },
1942
+ "method": {
1943
+ "type": "string",
1944
+ "title": "HTTP Method",
1945
+ "enum": [
1946
+ "GET",
1947
+ "POST",
1948
+ "PUT",
1949
+ "DELETE",
1950
+ "PATCH"
1951
+ ],
1952
+ "x-displayOrder": 3
1953
+ },
1954
+ "mode": {
1955
+ "type": "string",
1956
+ "title": "Mode",
1957
+ "enum": [
1958
+ "sync",
1959
+ "async"
1960
+ ],
1961
+ "x-enumLabels": [
1962
+ "Synchronous",
1963
+ "Asynchronous (Callback)"
1964
+ ],
1965
+ "x-displayOrder": 1
1966
+ },
1967
+ "retryCount": {
1968
+ "type": "integer",
1969
+ "title": "Retry Count",
1970
+ "minimum": 0,
1971
+ "maximum": 5,
1972
+ "x-displayOrder": 7
1973
+ },
1974
+ "retryDelay": {
1975
+ "type": "integer",
1976
+ "title": "Retry Delay (ms)",
1977
+ "minimum": 100,
1978
+ "x-displayOrder": 8
1979
+ },
1980
+ "timeout": {
1981
+ "type": "integer",
1982
+ "title": "Timeout (ms)",
1983
+ "minimum": 1e3,
1984
+ "maximum": 3e5,
1985
+ "x-displayOrder": 6
1986
+ },
1987
+ "url": {
1988
+ "type": "string",
1989
+ "title": "URL",
1990
+ "x-displayOrder": 2
1991
+ }
1992
+ },
1993
+ "required": [
1994
+ "url",
1995
+ "method"
1996
+ ]
1997
+ },
1998
+ "input": {
1999
+ "type": "object"
2000
+ },
2001
+ "output": {
2002
+ "type": "object"
2003
+ }
2004
+ },
2005
+ "actionAssignSLAPolicy": {
2006
+ "type": "action",
2007
+ "subType": "actionAssignSLAPolicy",
2008
+ "label": "Assign SLA Policy",
2009
+ "icon": "Clock",
2010
+ "description": "Assign an SLA policy to a record",
2011
+ "category": "Data Operations",
2012
+ "config": {
2013
+ "type": "object",
2014
+ "title": "Assign SLA Policy",
2015
+ "properties": {
2016
+ "entityRecordIdExpr": {
2017
+ "type": "string",
2018
+ "title": "Entity Record ID"
2019
+ },
2020
+ "policyId": {
2021
+ "type": "string",
2022
+ "title": "Policy ID"
2023
+ }
2024
+ },
2025
+ "required": [
2026
+ "policyId"
2027
+ ]
2028
+ },
2029
+ "input": {
2030
+ "type": "object"
2031
+ },
2032
+ "output": {
2033
+ "type": "object",
2034
+ "properties": {
2035
+ "assignmentId": {
2036
+ "type": "string"
2037
+ }
2038
+ }
2039
+ }
2040
+ },
2041
+ "actionCreateEntityRecord": {
2042
+ "type": "action",
2043
+ "subType": "actionCreateEntityRecord",
2044
+ "label": "Create Entity Record",
2045
+ "icon": "FilePlus",
2046
+ "description": "Create a new entity record",
2047
+ "category": "Data Operations",
2048
+ "config": {
2049
+ "type": "object",
2050
+ "title": "Create Entity Record",
2051
+ "properties": {
2052
+ "entityName": {
2053
+ "type": "string",
2054
+ "title": "Entity Name"
2055
+ },
2056
+ "fields": {
2057
+ "type": "object",
2058
+ "title": "Field Values"
2059
+ }
2060
+ },
2061
+ "required": [
2062
+ "entityName"
2063
+ ]
2064
+ },
2065
+ "input": {
2066
+ "type": "object"
2067
+ },
2068
+ "output": {
2069
+ "type": "object",
2070
+ "properties": {
2071
+ "recordId": {
2072
+ "type": "string"
2073
+ }
2074
+ }
2075
+ }
2076
+ },
2077
+ "actionDeleteEntityRecord": {
2078
+ "type": "action",
2079
+ "subType": "actionDeleteEntityRecord",
2080
+ "label": "Delete Entity Record",
2081
+ "icon": "FileX",
2082
+ "description": "Delete an entity record",
2083
+ "category": "Data Operations",
2084
+ "config": {
2085
+ "type": "object",
2086
+ "title": "Delete Entity Record",
2087
+ "properties": {
2088
+ "entityName": {
2089
+ "type": "string",
2090
+ "title": "Entity Name"
2091
+ },
2092
+ "recordIdExpr": {
2093
+ "type": "string",
2094
+ "title": "Record ID Expression"
2095
+ }
2096
+ },
2097
+ "required": [
2098
+ "entityName",
2099
+ "recordIdExpr"
2100
+ ]
2101
+ },
2102
+ "input": {
2103
+ "type": "object"
2104
+ },
2105
+ "output": {
2106
+ "type": "object",
2107
+ "properties": {
2108
+ "deleted": {
2109
+ "type": "boolean"
2110
+ }
2111
+ }
2112
+ }
2113
+ },
2114
+ "actionDocumentExtraction": {
2115
+ "type": "action",
2116
+ "subType": "actionDocumentExtraction",
2117
+ "label": "Document Extraction",
2118
+ "icon": "FileSearch",
2119
+ "description": "Extract data from documents using AI",
2120
+ "category": "Data Processing",
2121
+ "config": {
2122
+ "type": "object",
2123
+ "title": "Document Extraction",
2124
+ "properties": {
2125
+ "documentType": {
2126
+ "type": "string",
2127
+ "title": "Document Type"
2128
+ },
2129
+ "instructions": {
2130
+ "type": "string",
2131
+ "title": "Instructions",
2132
+ "format": "multiline"
2133
+ }
2134
+ },
2135
+ "required": [
2136
+ "instructions",
2137
+ "documentType"
2138
+ ]
2139
+ },
2140
+ "input": {
2141
+ "type": "object",
2142
+ "properties": {
2143
+ "fileUrl": {
2144
+ "type": "string"
2145
+ }
2146
+ }
2147
+ },
2148
+ "output": {
2149
+ "type": "object"
2150
+ }
2151
+ },
2152
+ "actionNatsRequest": {
2153
+ "type": "action",
2154
+ "subType": "actionNatsRequest",
2155
+ "label": "NATS Request",
2156
+ "icon": "Send",
2157
+ "description": "Execute a NATS request-reply call with dynamic subject routing",
2158
+ "category": "Integration",
2159
+ "config": {
2160
+ "type": "object",
2161
+ "title": "NATS Request",
2162
+ "properties": {
2163
+ "actionTypeField": {
2164
+ "type": "string",
2165
+ "title": "Action Type Field",
2166
+ "description": 'Dot-notation path to get action type from input (e.g., "human_review.selectedAction.type")'
2167
+ },
2168
+ "payloadTemplate": {
2169
+ "type": "object",
2170
+ "title": "Payload Template",
2171
+ "description": "JSON payload with {{variable}} interpolation"
2172
+ },
2173
+ "subjectMapping": {
2174
+ "type": "object",
2175
+ "title": "Subject Mapping",
2176
+ "description": 'Map action types to NATS subjects (e.g., {"reply": "hub.integration.email.send"})'
2177
+ },
2178
+ "timeoutSeconds": {
2179
+ "type": "integer",
2180
+ "title": "Timeout (seconds)",
2181
+ "default": 30,
2182
+ "minimum": 1,
2183
+ "maximum": 300
2184
+ }
2185
+ }
2186
+ },
2187
+ "input": {
2188
+ "type": "object",
2189
+ "properties": {
2190
+ "subject": {
2191
+ "type": "string",
2192
+ "title": "NATS Subject",
2193
+ "description": "Direct NATS subject (alternative to subjectMapping)"
2194
+ }
2195
+ }
2196
+ },
2197
+ "output": {
2198
+ "type": "object",
2199
+ "description": "Response from NATS service",
2200
+ "properties": {
2201
+ "_actionType": {
2202
+ "type": "string",
2203
+ "title": "Action Type",
2204
+ "description": "The action type that was used (if subjectMapping was used)"
2205
+ },
2206
+ "_executedSubject": {
2207
+ "type": "string",
2208
+ "title": "Executed Subject",
2209
+ "description": "The NATS subject that was called"
2210
+ }
2211
+ }
2212
+ }
2213
+ },
2214
+ "actionQueryEntityRecords": {
2215
+ "type": "action",
2216
+ "subType": "actionQueryEntityRecords",
2217
+ "label": "Query Entity Records",
2218
+ "icon": "Search",
2219
+ "description": "Query entity records with filters",
2220
+ "category": "Data Operations",
2221
+ "config": {
2222
+ "type": "object",
2223
+ "title": "Query Entity Records",
2224
+ "properties": {
2225
+ "entityName": {
2226
+ "type": "string",
2227
+ "title": "Entity Name",
2228
+ "description": "Name of the entity to query"
2229
+ },
2230
+ "filters": {
2231
+ "type": "object",
2232
+ "title": "Filters",
2233
+ "description": 'Field filters (e.g., {"status": "open"})'
2234
+ },
2235
+ "page": {
2236
+ "type": "integer",
2237
+ "title": "Page",
2238
+ "description": "Page number (default: 1)",
2239
+ "minimum": 1
2240
+ },
2241
+ "pageSize": {
2242
+ "type": "integer",
2243
+ "title": "Page Size",
2244
+ "description": "Records per page (default: 10)",
2245
+ "minimum": 1,
2246
+ "maximum": 100
2247
+ },
2248
+ "sortBy": {
2249
+ "type": "string",
2250
+ "title": "Sort By",
2251
+ "description": "Field to sort by"
2252
+ },
2253
+ "sortOrder": {
2254
+ "type": "integer",
2255
+ "title": "Sort Order",
2256
+ "description": "1 for ascending, -1 for descending",
2257
+ "enum": [
2258
+ 1,
2259
+ -1
2260
+ ]
2261
+ }
2262
+ },
2263
+ "required": [
2264
+ "entityName"
2265
+ ]
2266
+ },
2267
+ "input": {
2268
+ "type": "object"
2269
+ },
2270
+ "output": {
2271
+ "type": "object",
2272
+ "properties": {
2273
+ "page": {
2274
+ "type": "integer",
2275
+ "title": "Current Page"
2276
+ },
2277
+ "pageSize": {
2278
+ "type": "integer",
2279
+ "title": "Page Size"
2280
+ },
2281
+ "records": {
2282
+ "type": "array",
2283
+ "title": "Records",
2284
+ "description": "Array of matching entity records",
2285
+ "items": {
2286
+ "type": "object"
2287
+ }
2288
+ },
2289
+ "totalCount": {
2290
+ "type": "integer",
2291
+ "title": "Total Count",
2292
+ "description": "Total number of matching records"
2293
+ },
2294
+ "totalPages": {
2295
+ "type": "integer",
2296
+ "title": "Total Pages"
2297
+ }
2298
+ }
2299
+ }
2300
+ },
2301
+ "actionSendEmail": {
2302
+ "type": "action",
2303
+ "subType": "actionSendEmail",
2304
+ "label": "Send Email",
2305
+ "icon": "Mail",
2306
+ "description": "Send an email notification",
2307
+ "category": "Communication",
2308
+ "config": {
2309
+ "type": "object",
2310
+ "title": "Send Email",
2311
+ "properties": {
2312
+ "bcc": {
2313
+ "type": "string",
2314
+ "title": "BCC"
2315
+ },
2316
+ "body": {
2317
+ "type": "string",
2318
+ "title": "Body",
2319
+ "format": "multiline"
2320
+ },
2321
+ "cc": {
2322
+ "type": "string",
2323
+ "title": "CC"
2324
+ },
2325
+ "from": {
2326
+ "type": "string",
2327
+ "title": "From",
2328
+ "description": "Sender email address (must be verified in SES)"
2329
+ },
2330
+ "subject": {
2331
+ "type": "string",
2332
+ "title": "Subject"
2333
+ },
2334
+ "template": {
2335
+ "type": "string",
2336
+ "title": "Template",
2337
+ "enum": [
2338
+ "welcome",
2339
+ "notification",
2340
+ "confirmation",
2341
+ "custom"
2342
+ ],
2343
+ "x-enumLabels": [
2344
+ "Welcome Email",
2345
+ "Notification",
2346
+ "Confirmation",
2347
+ "Custom"
2348
+ ]
2349
+ },
2350
+ "to": {
2351
+ "type": "string",
2352
+ "title": "To"
2353
+ }
2354
+ },
2355
+ "required": [
2356
+ "from",
2357
+ "to",
2358
+ "subject"
2359
+ ]
2360
+ },
2361
+ "input": {
2362
+ "type": "object"
2363
+ },
2364
+ "output": {
2365
+ "type": "object",
2366
+ "properties": {
2367
+ "emailSent": {
2368
+ "type": "boolean"
2369
+ }
2370
+ }
2371
+ }
2372
+ },
2373
+ "actionSendSMS": {
2374
+ "type": "action",
2375
+ "subType": "actionSendSMS",
2376
+ "label": "Send SMS",
2377
+ "icon": "Smartphone",
2378
+ "description": "Send an SMS message",
2379
+ "category": "Communication",
2380
+ "config": {
2381
+ "type": "object",
2382
+ "title": "Send SMS",
2383
+ "properties": {
2384
+ "message": {
2385
+ "type": "string",
2386
+ "title": "Message",
2387
+ "format": "multiline"
2388
+ },
2389
+ "to": {
2390
+ "type": "string",
2391
+ "title": "Phone Number"
2392
+ }
2393
+ },
2394
+ "required": [
2395
+ "to",
2396
+ "message"
2397
+ ]
2398
+ },
2399
+ "input": {
2400
+ "type": "object"
2401
+ },
2402
+ "output": {
2403
+ "type": "object",
2404
+ "properties": {
2405
+ "smsSent": {
2406
+ "type": "boolean"
2407
+ }
2408
+ }
2409
+ }
2410
+ },
2411
+ "actionSetVariables": {
2412
+ "type": "action",
2413
+ "subType": "actionSetVariables",
2414
+ "label": "Set Variables",
2415
+ "icon": "Variable",
2416
+ "description": "Set workflow variables",
2417
+ "category": "Data Operations",
2418
+ "config": {
2419
+ "type": "object",
2420
+ "title": "Set Variables"
2421
+ },
2422
+ "input": {
2423
+ "type": "object"
2424
+ },
2425
+ "output": {
2426
+ "type": "object"
2427
+ }
2428
+ },
2429
+ "actionUpdateEntityRecord": {
2430
+ "type": "action",
2431
+ "subType": "actionUpdateEntityRecord",
2432
+ "label": "Update Entity Record",
2433
+ "icon": "FileEdit",
2434
+ "description": "Update an existing entity record",
2435
+ "category": "Data Operations",
2436
+ "config": {
2437
+ "type": "object",
2438
+ "title": "Update Entity Record",
2439
+ "properties": {
2440
+ "entityName": {
2441
+ "type": "string",
2442
+ "title": "Entity Name"
2443
+ },
2444
+ "fields": {
2445
+ "type": "object",
2446
+ "title": "Field Updates"
2447
+ },
2448
+ "recordIdExpr": {
2449
+ "type": "string",
2450
+ "title": "Record ID Expression"
2451
+ }
2452
+ },
2453
+ "required": [
2454
+ "entityName",
2455
+ "recordIdExpr"
2456
+ ]
2457
+ },
2458
+ "input": {
2459
+ "type": "object"
2460
+ },
2461
+ "output": {
2462
+ "type": "object",
2463
+ "properties": {
2464
+ "updated": {
2465
+ "type": "boolean"
2466
+ }
2467
+ }
2468
+ }
2469
+ },
2470
+ "agentChat": {
2471
+ "type": "agent",
2472
+ "subType": "agentChat",
2473
+ "label": "Chat",
2474
+ "icon": "MessageSquare",
2475
+ "description": "AI chat interaction",
2476
+ "category": "AI & Automation",
2477
+ "config": {
2478
+ "type": "object",
2479
+ "title": "Chat",
2480
+ "properties": {
2481
+ "maxTokens": {
2482
+ "type": "integer",
2483
+ "title": "Max Tokens",
2484
+ "minimum": 1,
2485
+ "maximum": 4096
2486
+ },
2487
+ "model": {
2488
+ "type": "string",
2489
+ "title": "Model",
2490
+ "enum": [
2491
+ "gpt-4",
2492
+ "gpt-4-turbo",
2493
+ "gpt-3.5-turbo",
2494
+ "claude-3-opus",
2495
+ "claude-3-sonnet"
2496
+ ],
2497
+ "x-enumLabels": [
2498
+ "GPT-4",
2499
+ "GPT-4 Turbo",
2500
+ "GPT-3.5 Turbo",
2501
+ "Claude 3 Opus",
2502
+ "Claude 3 Sonnet"
2503
+ ]
2504
+ },
2505
+ "systemPrompt": {
2506
+ "type": "string",
2507
+ "title": "System Prompt",
2508
+ "format": "multiline"
2509
+ },
2510
+ "temperature": {
2511
+ "type": "number",
2512
+ "title": "Temperature",
2513
+ "minimum": 0,
2514
+ "maximum": 2
2515
+ }
2516
+ },
2517
+ "required": [
2518
+ "systemPrompt",
2519
+ "model"
2520
+ ]
2521
+ },
2522
+ "input": {
2523
+ "type": "object",
2524
+ "properties": {
2525
+ "message": {
2526
+ "type": "string"
2527
+ }
2528
+ }
2529
+ },
2530
+ "output": {
2531
+ "type": "object",
2532
+ "properties": {
2533
+ "message": {
2534
+ "type": "string"
2535
+ }
2536
+ }
2537
+ }
2538
+ },
2539
+ "agentCustomResponse": {
2540
+ "type": "agent",
2541
+ "subType": "agentCustomResponse",
2542
+ "label": "Custom Response",
2543
+ "icon": "MessageCircle",
2544
+ "description": "Send a custom response message",
2545
+ "category": "AI & Automation",
2546
+ "config": {
2547
+ "type": "object",
2548
+ "title": "Custom Response",
2549
+ "properties": {
2550
+ "message": {
2551
+ "type": "string",
2552
+ "title": "Response Message",
2553
+ "format": "multiline"
2554
+ }
2555
+ },
2556
+ "required": [
2557
+ "message"
2558
+ ]
2559
+ },
2560
+ "input": {
2561
+ "type": "object"
2562
+ },
2563
+ "output": {
2564
+ "type": "object"
2565
+ }
2566
+ },
2567
+ "agentIntentDetector": {
2568
+ "type": "agent",
2569
+ "subType": "agentIntentDetector",
2570
+ "label": "Intent Detector",
2571
+ "icon": "Target",
2572
+ "description": "Detect user intent from message",
2573
+ "category": "AI & Automation",
2574
+ "config": {
2575
+ "type": "object",
2576
+ "title": "Intent Detector",
2577
+ "properties": {
2578
+ "intents": {
2579
+ "type": "array",
2580
+ "title": "Intents",
2581
+ "items": {
2582
+ "type": "object",
2583
+ "properties": {
2584
+ "description": {
2585
+ "type": "string",
2586
+ "title": "Description"
2587
+ },
2588
+ "id": {
2589
+ "type": "string",
2590
+ "title": "ID"
2591
+ },
2592
+ "name": {
2593
+ "type": "string",
2594
+ "title": "Name"
2595
+ },
2596
+ "nodeId": {
2597
+ "type": "string",
2598
+ "title": "Target Node ID"
2599
+ }
2600
+ }
2601
+ }
2602
+ }
2603
+ },
2604
+ "required": [
2605
+ "intents"
2606
+ ]
2607
+ },
2608
+ "input": {
2609
+ "type": "object",
2610
+ "properties": {
2611
+ "message": {
2612
+ "type": "string"
2613
+ }
2614
+ }
2615
+ },
2616
+ "output": {
2617
+ "type": "object",
2618
+ "properties": {
2619
+ "confidence": {
2620
+ "type": "number"
2621
+ },
2622
+ "intent": {
2623
+ "type": "string"
2624
+ }
2625
+ }
2626
+ }
2627
+ },
2628
+ "agentKnowledgeGraph": {
2629
+ "type": "agent",
2630
+ "subType": "agentKnowledgeGraph",
2631
+ "label": "Knowledge Graph",
2632
+ "icon": "Network",
2633
+ "description": "Query knowledge graph for information",
2634
+ "category": "AI & Automation",
2635
+ "config": {
2636
+ "type": "object",
2637
+ "title": "Knowledge Graph",
2638
+ "properties": {
2639
+ "fields": {
2640
+ "type": "array",
2641
+ "title": "Fields",
2642
+ "items": {
2643
+ "type": "object"
2644
+ }
2645
+ },
2646
+ "label": {
2647
+ "type": "string",
2648
+ "title": "Label"
2649
+ }
2650
+ },
2651
+ "required": [
2652
+ "label"
2653
+ ]
2654
+ },
2655
+ "input": {
2656
+ "type": "object",
2657
+ "properties": {
2658
+ "query": {
2659
+ "type": "string"
2660
+ }
2661
+ }
2662
+ },
2663
+ "output": {
2664
+ "type": "object",
2665
+ "properties": {
2666
+ "kg_response": {
2667
+ "type": "array",
2668
+ "items": {
2669
+ "type": "object"
2670
+ }
2671
+ }
2672
+ }
2673
+ }
2674
+ },
2675
+ "agentOpenTicket": {
2676
+ "type": "agent",
2677
+ "subType": "agentOpenTicket",
2678
+ "label": "Open Ticket",
2679
+ "icon": "Ticket",
2680
+ "description": "Create a support ticket",
2681
+ "category": "AI & Automation",
2682
+ "config": {
2683
+ "type": "object",
2684
+ "title": "Open Ticket",
2685
+ "properties": {
2686
+ "priority": {
2687
+ "type": "string",
2688
+ "title": "Priority",
2689
+ "enum": [
2690
+ "low",
2691
+ "medium",
2692
+ "high",
2693
+ "urgent"
2694
+ ]
2695
+ },
2696
+ "ticketType": {
2697
+ "type": "string",
2698
+ "title": "Ticket Type"
2699
+ }
2700
+ }
2701
+ },
2702
+ "input": {
2703
+ "type": "object"
2704
+ },
2705
+ "output": {
2706
+ "type": "object",
2707
+ "properties": {
2708
+ "ticketId": {
2709
+ "type": "string"
2710
+ }
2711
+ }
2712
+ }
2713
+ },
2714
+ "agentStructuredOutput": {
2715
+ "type": "agent",
2716
+ "subType": "agentStructuredOutput",
2717
+ "label": "Structured Output",
2718
+ "icon": "Brain",
2719
+ "description": "AI-powered structured data extraction",
2720
+ "category": "AI & Automation",
2721
+ "config": {
2722
+ "type": "object",
2723
+ "title": "Structured Output",
2724
+ "properties": {
2725
+ "inputTemplate": {
2726
+ "type": "string",
2727
+ "title": "Input Template",
2728
+ "format": "multiline"
2729
+ },
2730
+ "instructions": {
2731
+ "type": "string",
2732
+ "title": "Instructions",
2733
+ "format": "multiline"
2734
+ },
2735
+ "model": {
2736
+ "type": "string",
2737
+ "title": "Model"
2738
+ },
2739
+ "systemPrompt": {
2740
+ "type": "string",
2741
+ "title": "System Prompt",
2742
+ "format": "multiline"
2743
+ },
2744
+ "temperature": {
2745
+ "type": "number",
2746
+ "title": "Temperature",
2747
+ "minimum": 0,
2748
+ "maximum": 2
2749
+ }
2750
+ }
2751
+ },
2752
+ "input": {
2753
+ "type": "object"
2754
+ },
2755
+ "output": {
2756
+ "type": "object"
2757
+ }
2758
+ },
2759
+ "agentTransferToHuman": {
2760
+ "type": "agent",
2761
+ "subType": "agentTransferToHuman",
2762
+ "label": "Transfer to Human",
2763
+ "icon": "UserCheck",
2764
+ "description": "Transfer conversation to human agent",
2765
+ "category": "AI & Automation",
2766
+ "config": {
2767
+ "type": "object",
2768
+ "title": "Transfer to Human",
2769
+ "properties": {
2770
+ "message": {
2771
+ "type": "string",
2772
+ "title": "Transfer Message",
2773
+ "format": "multiline"
2774
+ },
2775
+ "queueId": {
2776
+ "type": "string",
2777
+ "title": "Queue ID"
2778
+ }
2779
+ },
2780
+ "required": [
2781
+ "message",
2782
+ "queueId"
2783
+ ]
2784
+ },
2785
+ "input": {
2786
+ "type": "object"
2787
+ },
2788
+ "output": {
2789
+ "type": "object"
2790
+ }
2791
+ },
2792
+ "delay": {
2793
+ "type": "delay",
2794
+ "subType": "delay",
2795
+ "label": "Delay",
2796
+ "icon": "Clock",
2797
+ "description": "Wait for a specified duration",
2798
+ "category": "Time & Scheduling",
2799
+ "config": {
2800
+ "type": "object",
2801
+ "title": "Delay",
2802
+ "properties": {
2803
+ "duration": {
2804
+ "type": "integer",
2805
+ "title": "Duration",
2806
+ "minimum": 1
2807
+ },
2808
+ "unit": {
2809
+ "type": "string",
2810
+ "title": "Unit",
2811
+ "enum": [
2812
+ "seconds",
2813
+ "minutes",
2814
+ "hours",
2815
+ "days"
2816
+ ],
2817
+ "x-enumLabels": [
2818
+ "Seconds",
2819
+ "Minutes",
2820
+ "Hours",
2821
+ "Days"
2822
+ ]
2823
+ }
2824
+ },
2825
+ "required": [
2826
+ "duration",
2827
+ "unit"
2828
+ ]
2829
+ },
2830
+ "input": {
2831
+ "type": "object"
2832
+ },
2833
+ "output": {
2834
+ "type": "object"
2835
+ }
2836
+ },
2837
+ "humanActionApproval": {
2838
+ "type": "humanAction",
2839
+ "subType": "humanActionApproval",
2840
+ "label": "Approval",
2841
+ "icon": "CheckCircle",
2842
+ "description": "Request human approval",
2843
+ "category": "User Interaction",
2844
+ "config": {
2845
+ "type": "object",
2846
+ "title": "Approval",
2847
+ "properties": {
2848
+ "allowEdit": {
2849
+ "type": "boolean",
2850
+ "title": "Allow Edit"
2851
+ },
2852
+ "assignTo": {
2853
+ "type": "string",
2854
+ "title": "Assign To"
2855
+ },
2856
+ "dueInHours": {
2857
+ "type": "integer",
2858
+ "title": "Due In (Hours)",
2859
+ "minimum": 1
2860
+ },
2861
+ "instructions": {
2862
+ "type": "string",
2863
+ "title": "Instructions",
2864
+ "format": "multiline"
2865
+ }
2866
+ }
2867
+ },
2868
+ "input": {
2869
+ "type": "object"
2870
+ },
2871
+ "output": {
2872
+ "type": "object",
2873
+ "properties": {
2874
+ "decision": {
2875
+ "type": "string"
2876
+ }
2877
+ }
2878
+ }
2879
+ },
2880
+ "humanActionAssignment": {
2881
+ "type": "humanAction",
2882
+ "subType": "humanActionAssignment",
2883
+ "label": "Task Assignment",
2884
+ "icon": "UserPlus",
2885
+ "description": "Assign a task to a user",
2886
+ "category": "User Interaction",
2887
+ "config": {
2888
+ "type": "object",
2889
+ "title": "Task Assignment",
2890
+ "properties": {
2891
+ "assignTo": {
2892
+ "type": "string",
2893
+ "title": "Assign To"
2894
+ },
2895
+ "dueInHours": {
2896
+ "type": "integer",
2897
+ "title": "Due In (Hours)",
2898
+ "minimum": 1
2899
+ },
2900
+ "priority": {
2901
+ "type": "string",
2902
+ "title": "Priority",
2903
+ "enum": [
2904
+ "low",
2905
+ "medium",
2906
+ "high",
2907
+ "urgent"
2908
+ ],
2909
+ "x-enumLabels": [
2910
+ "Low",
2911
+ "Medium",
2912
+ "High",
2913
+ "Urgent"
2914
+ ]
2915
+ },
2916
+ "taskDescription": {
2917
+ "type": "string",
2918
+ "title": "Task Description",
2919
+ "format": "multiline"
2920
+ },
2921
+ "taskTitle": {
2922
+ "type": "string",
2923
+ "title": "Task Title"
2924
+ }
2925
+ }
2926
+ },
2927
+ "input": {
2928
+ "type": "object"
2929
+ },
2930
+ "output": {
2931
+ "type": "object"
2932
+ }
2933
+ },
2934
+ "humanActionDataEntry": {
2935
+ "type": "humanAction",
2936
+ "subType": "humanActionDataEntry",
2937
+ "label": "Data Entry",
2938
+ "icon": "FormInput",
2939
+ "description": "Request human data entry",
2940
+ "category": "User Interaction",
2941
+ "config": {
2942
+ "type": "object",
2943
+ "title": "Data Entry",
2944
+ "properties": {
2945
+ "assignTo": {
2946
+ "type": "string",
2947
+ "title": "Assign To"
2948
+ },
2949
+ "formSchema": {
2950
+ "type": "object",
2951
+ "title": "Form Schema"
2952
+ },
2953
+ "instructions": {
2954
+ "type": "string",
2955
+ "title": "Instructions",
2956
+ "format": "multiline"
2957
+ }
2958
+ }
2959
+ },
2960
+ "input": {
2961
+ "type": "object"
2962
+ },
2963
+ "output": {
2964
+ "type": "object"
2965
+ }
2966
+ },
2967
+ "humanActionReview": {
2968
+ "type": "humanAction",
2969
+ "subType": "humanActionReview",
2970
+ "label": "Review",
2971
+ "icon": "Eye",
2972
+ "description": "Request human review",
2973
+ "category": "User Interaction",
2974
+ "config": {
2975
+ "type": "object",
2976
+ "title": "Review",
2977
+ "properties": {
2978
+ "assignTo": {
2979
+ "type": "string",
2980
+ "title": "Assign To"
2981
+ },
2982
+ "dueInHours": {
2983
+ "type": "integer",
2984
+ "title": "Due In (Hours)",
2985
+ "minimum": 1
2986
+ },
2987
+ "editableFields": {
2988
+ "type": "array",
2989
+ "title": "Editable Fields",
2990
+ "items": {
2991
+ "type": "string"
2992
+ }
2993
+ },
2994
+ "instructions": {
2995
+ "type": "string",
2996
+ "title": "Instructions",
2997
+ "format": "multiline"
2998
+ }
2999
+ }
3000
+ },
3001
+ "input": {
3002
+ "type": "object"
3003
+ },
3004
+ "output": {
3005
+ "type": "object",
3006
+ "properties": {
3007
+ "decision": {
3008
+ "type": "string"
3009
+ }
3010
+ }
3011
+ }
3012
+ },
3013
+ "integrationCreateEvent": {
3014
+ "type": "integration",
3015
+ "subType": "integrationCreateEvent",
3016
+ "label": "Create Calendar Event",
3017
+ "icon": "CalendarPlus",
3018
+ "description": "Create event in user's calendar",
3019
+ "category": "Integration",
3020
+ "config": {
3021
+ "type": "object",
3022
+ "title": "Create Calendar Event",
3023
+ "properties": {
3024
+ "attendees": {
3025
+ "type": "string",
3026
+ "title": "Attendees",
3027
+ "description": "Comma-separated email addresses"
3028
+ },
3029
+ "description": {
3030
+ "type": "string",
3031
+ "title": "Description",
3032
+ "format": "multiline"
3033
+ },
3034
+ "endTime": {
3035
+ "type": "string",
3036
+ "title": "End Time",
3037
+ "format": "date-time"
3038
+ },
3039
+ "location": {
3040
+ "type": "string",
3041
+ "title": "Location"
3042
+ },
3043
+ "sendInvites": {
3044
+ "type": "boolean",
3045
+ "title": "Send Calendar Invites",
3046
+ "default": true
3047
+ },
3048
+ "startTime": {
3049
+ "type": "string",
3050
+ "title": "Start Time",
3051
+ "format": "date-time"
3052
+ },
3053
+ "title": {
3054
+ "type": "string",
3055
+ "title": "Title"
3056
+ }
3057
+ },
3058
+ "required": [
3059
+ "title",
3060
+ "startTime",
3061
+ "endTime"
3062
+ ]
3063
+ },
3064
+ "input": {
3065
+ "type": "object"
3066
+ },
3067
+ "output": {
3068
+ "type": "object",
3069
+ "properties": {
3070
+ "created": {
3071
+ "type": "boolean",
3072
+ "title": "Created"
3073
+ },
3074
+ "eventId": {
3075
+ "type": "string",
3076
+ "title": "Event ID"
3077
+ },
3078
+ "eventUrl": {
3079
+ "type": "string",
3080
+ "title": "Event URL"
3081
+ }
3082
+ }
3083
+ }
3084
+ },
3085
+ "integrationGetDriveFile": {
3086
+ "type": "integration",
3087
+ "subType": "integrationGetDriveFile",
3088
+ "label": "Get Drive File",
3089
+ "icon": "File",
3090
+ "description": "Get details of a specific file",
3091
+ "category": "Integration",
3092
+ "config": {
3093
+ "type": "object",
3094
+ "title": "Get Drive File",
3095
+ "properties": {
3096
+ "fileId": {
3097
+ "type": "string",
3098
+ "title": "File ID"
3099
+ }
3100
+ },
3101
+ "required": [
3102
+ "fileId"
3103
+ ]
3104
+ },
3105
+ "input": {
3106
+ "type": "object"
3107
+ },
3108
+ "output": {
3109
+ "type": "object",
3110
+ "properties": {
3111
+ "file": {
3112
+ "type": "object",
3113
+ "properties": {
3114
+ "downloadUrl": {
3115
+ "type": "string",
3116
+ "title": "Download URL"
3117
+ },
3118
+ "id": {
3119
+ "type": "string",
3120
+ "title": "File ID"
3121
+ },
3122
+ "mimeType": {
3123
+ "type": "string",
3124
+ "title": "MIME Type"
3125
+ },
3126
+ "name": {
3127
+ "type": "string",
3128
+ "title": "Name"
3129
+ },
3130
+ "size": {
3131
+ "type": "integer",
3132
+ "title": "Size (bytes)"
3133
+ },
3134
+ "webLink": {
3135
+ "type": "string",
3136
+ "title": "Web Link"
3137
+ }
3138
+ }
3139
+ }
3140
+ }
3141
+ }
3142
+ },
3143
+ "integrationSearchCalendar": {
3144
+ "type": "integration",
3145
+ "subType": "integrationSearchCalendar",
3146
+ "label": "Search Calendar",
3147
+ "icon": "CalendarSearch",
3148
+ "description": "Search calendar events",
3149
+ "category": "Integration",
3150
+ "config": {
3151
+ "type": "object",
3152
+ "title": "Search Calendar",
3153
+ "properties": {
3154
+ "maxResults": {
3155
+ "type": "integer",
3156
+ "title": "Max Results",
3157
+ "default": 20,
3158
+ "minimum": 1,
3159
+ "maximum": 100
3160
+ },
3161
+ "query": {
3162
+ "type": "string",
3163
+ "title": "Search Query",
3164
+ "description": "Search in event titles and descriptions"
3165
+ },
3166
+ "timeMax": {
3167
+ "type": "string",
3168
+ "title": "End Date",
3169
+ "description": "Search events before this date",
3170
+ "format": "date-time"
3171
+ },
3172
+ "timeMin": {
3173
+ "type": "string",
3174
+ "title": "Start Date",
3175
+ "description": "Search events after this date",
3176
+ "format": "date-time"
3177
+ }
3178
+ }
3179
+ },
3180
+ "input": {
3181
+ "type": "object"
3182
+ },
3183
+ "output": {
3184
+ "type": "object",
3185
+ "properties": {
3186
+ "events": {
3187
+ "type": "array",
3188
+ "title": "Events",
3189
+ "items": {
3190
+ "type": "object"
3191
+ }
3192
+ },
3193
+ "total": {
3194
+ "type": "integer",
3195
+ "title": "Total"
3196
+ }
3197
+ }
3198
+ }
3199
+ },
3200
+ "integrationSearchDrive": {
3201
+ "type": "integration",
3202
+ "subType": "integrationSearchDrive",
3203
+ "label": "Search Drive",
3204
+ "icon": "FolderSearch",
3205
+ "description": "Search files in user's Drive",
3206
+ "category": "Integration",
3207
+ "config": {
3208
+ "type": "object",
3209
+ "title": "Search Drive",
3210
+ "properties": {
3211
+ "folderId": {
3212
+ "type": "string",
3213
+ "title": "Folder ID",
3214
+ "description": "Search in specific folder"
3215
+ },
3216
+ "maxResults": {
3217
+ "type": "integer",
3218
+ "title": "Max Results",
3219
+ "default": 20,
3220
+ "minimum": 1,
3221
+ "maximum": 100
3222
+ },
3223
+ "mimeType": {
3224
+ "type": "string",
3225
+ "title": "File Type",
3226
+ "enum": [
3227
+ "",
3228
+ "document",
3229
+ "spreadsheet",
3230
+ "presentation",
3231
+ "pdf",
3232
+ "image",
3233
+ "folder"
3234
+ ],
3235
+ "x-enumLabels": [
3236
+ "Any",
3237
+ "Documents",
3238
+ "Spreadsheets",
3239
+ "Presentations",
3240
+ "PDFs",
3241
+ "Images",
3242
+ "Folders"
3243
+ ]
3244
+ },
3245
+ "query": {
3246
+ "type": "string",
3247
+ "title": "Search Query",
3248
+ "description": "Search in file names and content"
3249
+ }
3250
+ },
3251
+ "required": [
3252
+ "query"
3253
+ ]
3254
+ },
3255
+ "input": {
3256
+ "type": "object"
3257
+ },
3258
+ "output": {
3259
+ "type": "object",
3260
+ "properties": {
3261
+ "files": {
3262
+ "type": "array",
3263
+ "title": "Files",
3264
+ "items": {
3265
+ "type": "object"
3266
+ }
3267
+ },
3268
+ "total": {
3269
+ "type": "integer",
3270
+ "title": "Total"
3271
+ }
3272
+ }
3273
+ }
3274
+ },
3275
+ "integrationSearchEmails": {
3276
+ "type": "integration",
3277
+ "subType": "integrationSearchEmails",
3278
+ "label": "Search Emails",
3279
+ "icon": "MailSearch",
3280
+ "description": "Search user's emails",
3281
+ "category": "Integration",
3282
+ "config": {
3283
+ "type": "object",
3284
+ "title": "Search Emails",
3285
+ "properties": {
3286
+ "dateRange": {
3287
+ "type": "string",
3288
+ "title": "Date Range",
3289
+ "enum": [
3290
+ "1d",
3291
+ "7d",
3292
+ "30d",
3293
+ "90d",
3294
+ "all"
3295
+ ],
3296
+ "x-enumLabels": [
3297
+ "Last 24 hours",
3298
+ "Last 7 days",
3299
+ "Last 30 days",
3300
+ "Last 90 days",
3301
+ "All time"
3302
+ ]
3303
+ },
3304
+ "maxResults": {
3305
+ "type": "integer",
3306
+ "title": "Max Results",
3307
+ "default": 20,
3308
+ "minimum": 1,
3309
+ "maximum": 100
3310
+ },
3311
+ "query": {
3312
+ "type": "string",
3313
+ "title": "Search Query",
3314
+ "description": "Gmail/Outlook search query"
3315
+ }
3316
+ },
3317
+ "required": [
3318
+ "query"
3319
+ ]
3320
+ },
3321
+ "input": {
3322
+ "type": "object"
3323
+ },
3324
+ "output": {
3325
+ "type": "object",
3326
+ "properties": {
3327
+ "emails": {
3328
+ "type": "array",
3329
+ "title": "Emails",
3330
+ "items": {
3331
+ "type": "object"
3332
+ }
3333
+ },
3334
+ "total": {
3335
+ "type": "integer",
3336
+ "title": "Total"
3337
+ }
3338
+ }
3339
+ }
3340
+ },
3341
+ "integrationSendEmail": {
3342
+ "type": "integration",
3343
+ "subType": "integrationSendEmail",
3344
+ "label": "Send Email",
3345
+ "icon": "Send",
3346
+ "description": "Send email via user's connected account",
3347
+ "category": "Integration",
3348
+ "config": {
3349
+ "type": "object",
3350
+ "title": "Send Email",
3351
+ "properties": {
3352
+ "body": {
3353
+ "type": "string",
3354
+ "title": "Body",
3355
+ "format": "multiline"
3356
+ },
3357
+ "bodyType": {
3358
+ "type": "string",
3359
+ "title": "Body Type",
3360
+ "default": "text",
3361
+ "enum": [
3362
+ "text",
3363
+ "html"
3364
+ ],
3365
+ "x-enumLabels": [
3366
+ "Plain Text",
3367
+ "HTML"
3368
+ ]
3369
+ },
3370
+ "cc": {
3371
+ "type": "string",
3372
+ "title": "CC"
3373
+ },
3374
+ "replyToMessageId": {
3375
+ "type": "string",
3376
+ "title": "Reply To Message ID",
3377
+ "description": "Optional: message ID to reply to"
3378
+ },
3379
+ "subject": {
3380
+ "type": "string",
3381
+ "title": "Subject"
3382
+ },
3383
+ "to": {
3384
+ "type": "string",
3385
+ "title": "To"
3386
+ }
3387
+ },
3388
+ "required": [
3389
+ "to",
3390
+ "subject",
3391
+ "body"
3392
+ ]
3393
+ },
3394
+ "input": {
3395
+ "type": "object"
3396
+ },
3397
+ "output": {
3398
+ "type": "object",
3399
+ "properties": {
3400
+ "messageId": {
3401
+ "type": "string",
3402
+ "title": "Message ID"
3403
+ },
3404
+ "sent": {
3405
+ "type": "boolean",
3406
+ "title": "Sent"
3407
+ }
3408
+ }
3409
+ }
3410
+ },
3411
+ "logicFor": {
3412
+ "type": "logic",
3413
+ "subType": "logicFor",
3414
+ "label": "Loop",
3415
+ "icon": "Repeat",
3416
+ "description": "Iterate over a collection",
3417
+ "category": "Flow Control",
3418
+ "config": {
3419
+ "type": "object",
3420
+ "title": "Loop",
3421
+ "properties": {
3422
+ "collection": {
3423
+ "type": "string",
3424
+ "title": "Collection Expression"
3425
+ },
3426
+ "indexVariable": {
3427
+ "type": "string",
3428
+ "title": "Index Variable Name"
3429
+ },
3430
+ "itemVariable": {
3431
+ "type": "string",
3432
+ "title": "Item Variable Name"
3433
+ },
3434
+ "maxIterations": {
3435
+ "type": "integer",
3436
+ "title": "Max Iterations",
3437
+ "minimum": 1,
3438
+ "maximum": 1e4
3439
+ }
3440
+ },
3441
+ "required": [
3442
+ "collection"
3443
+ ]
3444
+ },
3445
+ "input": {
3446
+ "type": "object"
3447
+ },
3448
+ "output": {
3449
+ "type": "object"
3450
+ }
3451
+ },
3452
+ "logicIf": {
3453
+ "type": "logic",
3454
+ "subType": "logicIf",
3455
+ "label": "If Condition",
3456
+ "icon": "GitBranch",
3457
+ "description": "Conditional branching based on variables",
3458
+ "category": "Flow Control",
3459
+ "config": {
3460
+ "type": "object",
3461
+ "title": "If Condition Configuration",
3462
+ "properties": {
3463
+ "conditions": {
3464
+ "type": "array",
3465
+ "title": "Conditions",
3466
+ "description": "Define conditions to evaluate against workflow variables",
3467
+ "items": {
3468
+ "type": "object",
3469
+ "properties": {
3470
+ "field": {
3471
+ "type": "string",
3472
+ "title": "Variable",
3473
+ "description": "Variable path (e.g., emailSent, user.role)"
3474
+ },
3475
+ "operator": {
3476
+ "type": "string",
3477
+ "title": "Operator",
3478
+ "enum": [
3479
+ "eq",
3480
+ "neq",
3481
+ "gt",
3482
+ "gte",
3483
+ "lt",
3484
+ "lte",
3485
+ "contains",
3486
+ "startsWith",
3487
+ "endsWith",
3488
+ "isEmpty",
3489
+ "isNotEmpty"
3490
+ ]
3491
+ },
3492
+ "value": {
3493
+ "type": "string",
3494
+ "title": "Value",
3495
+ "description": "Value to compare against"
3496
+ }
3497
+ },
3498
+ "required": [
3499
+ "field",
3500
+ "operator"
3501
+ ]
3502
+ }
3503
+ },
3504
+ "defaultPath": {
3505
+ "type": "string",
3506
+ "title": "Default Path ID",
3507
+ "description": "Path to use if no condition matches"
3508
+ },
3509
+ "expression": {
3510
+ "type": "string",
3511
+ "title": "Advanced Expression",
3512
+ "description": "JavaScript expression for complex conditions (e.g., amount > 1000 && status === 'approved')",
3513
+ "format": "multiline"
3514
+ },
3515
+ "logic": {
3516
+ "type": "string",
3517
+ "title": "Logic",
3518
+ "description": "How to combine multiple conditions",
3519
+ "default": "and",
3520
+ "enum": [
3521
+ "and",
3522
+ "or"
3523
+ ]
3524
+ },
3525
+ "paths": {
3526
+ "type": "array",
3527
+ "title": "Paths",
3528
+ "description": "Define target nodes for true/false outcomes",
3529
+ "items": {
3530
+ "type": "object",
3531
+ "properties": {
3532
+ "condition": {
3533
+ "type": "string",
3534
+ "title": "Condition",
3535
+ "enum": [
3536
+ "true",
3537
+ "false"
3538
+ ]
3539
+ },
3540
+ "id": {
3541
+ "type": "string",
3542
+ "title": "Path ID"
3543
+ },
3544
+ "nodeId": {
3545
+ "type": "string",
3546
+ "title": "Target Node ID"
3547
+ }
3548
+ },
3549
+ "required": [
3550
+ "id",
3551
+ "condition"
3552
+ ]
3553
+ }
3554
+ }
3555
+ }
3556
+ },
3557
+ "input": {
3558
+ "type": "object"
3559
+ },
3560
+ "output": {
3561
+ "type": "object",
3562
+ "properties": {
3563
+ "conditionResult": {
3564
+ "type": "boolean"
3565
+ },
3566
+ "pathTaken": {
3567
+ "type": "string"
3568
+ }
3569
+ }
3570
+ }
3571
+ },
3572
+ "logicSwitch": {
3573
+ "type": "logic",
3574
+ "subType": "logicSwitch",
3575
+ "label": "Switch",
3576
+ "icon": "GitMerge",
3577
+ "description": "Multi-way branching based on value",
3578
+ "category": "Flow Control",
3579
+ "config": {
3580
+ "type": "object",
3581
+ "title": "Switch",
3582
+ "properties": {
3583
+ "cases": {
3584
+ "type": "array",
3585
+ "title": "Cases",
3586
+ "items": {
3587
+ "type": "object",
3588
+ "properties": {
3589
+ "nodeId": {
3590
+ "type": "string",
3591
+ "title": "Target Node ID"
3592
+ },
3593
+ "value": {
3594
+ "type": "string",
3595
+ "title": "Value"
3596
+ }
3597
+ }
3598
+ }
3599
+ },
3600
+ "expression": {
3601
+ "type": "string",
3602
+ "title": "Switch Expression"
3603
+ }
3604
+ },
3605
+ "required": [
3606
+ "expression"
3607
+ ]
3608
+ },
3609
+ "input": {
3610
+ "type": "object"
3611
+ },
3612
+ "output": {
3613
+ "type": "object"
3614
+ }
3615
+ },
3616
+ "triggerCalendarEvent": {
3617
+ "type": "trigger",
3618
+ "subType": "triggerCalendarEvent",
3619
+ "label": "Calendar Event",
3620
+ "icon": "CalendarClock",
3621
+ "description": "Trigger before or when calendar events occur",
3622
+ "category": "Triggers",
3623
+ "config": {
3624
+ "type": "object",
3625
+ "title": "Calendar Trigger",
3626
+ "properties": {
3627
+ "leadTime": {
3628
+ "type": "integer",
3629
+ "title": "Minutes Before",
3630
+ "description": "For reminder triggers",
3631
+ "default": 30,
3632
+ "minimum": 5,
3633
+ "maximum": 1440
3634
+ },
3635
+ "provider": {
3636
+ "type": "string",
3637
+ "title": "Provider",
3638
+ "enum": [
3639
+ "google",
3640
+ "microsoft"
3641
+ ],
3642
+ "x-enumLabels": [
3643
+ "Google Calendar",
3644
+ "Outlook Calendar"
3645
+ ]
3646
+ },
3647
+ "triggerType": {
3648
+ "type": "string",
3649
+ "title": "Trigger When",
3650
+ "enum": [
3651
+ "reminder",
3652
+ "event_start",
3653
+ "event_created"
3654
+ ],
3655
+ "x-enumLabels": [
3656
+ "Before Event (Reminder)",
3657
+ "Event Starts",
3658
+ "Event Created"
3659
+ ]
3660
+ }
3661
+ },
3662
+ "required": [
3663
+ "provider",
3664
+ "triggerType"
3665
+ ]
3666
+ },
3667
+ "input": {
3668
+ "type": "object"
3669
+ },
3670
+ "output": {
3671
+ "type": "object",
3672
+ "properties": {
3673
+ "event": {
3674
+ "type": "object",
3675
+ "properties": {
3676
+ "attendees": {
3677
+ "type": "array",
3678
+ "title": "Attendees",
3679
+ "items": {
3680
+ "type": "string"
3681
+ }
3682
+ },
3683
+ "description": {
3684
+ "type": "string",
3685
+ "title": "Description"
3686
+ },
3687
+ "endTime": {
3688
+ "type": "string",
3689
+ "title": "End Time",
3690
+ "format": "date-time"
3691
+ },
3692
+ "id": {
3693
+ "type": "string",
3694
+ "title": "Event ID"
3695
+ },
3696
+ "location": {
3697
+ "type": "string",
3698
+ "title": "Location"
3699
+ },
3700
+ "startTime": {
3701
+ "type": "string",
3702
+ "title": "Start Time",
3703
+ "format": "date-time"
3704
+ },
3705
+ "title": {
3706
+ "type": "string",
3707
+ "title": "Title"
3708
+ }
3709
+ }
3710
+ }
3711
+ }
3712
+ }
3713
+ },
3714
+ "triggerDriveFileChanged": {
3715
+ "type": "trigger",
3716
+ "subType": "triggerDriveFileChanged",
3717
+ "label": "File Changed",
3718
+ "icon": "FolderSync",
3719
+ "description": "Trigger when files are added or modified in Drive",
3720
+ "category": "Triggers",
3721
+ "config": {
3722
+ "type": "object",
3723
+ "title": "Drive Trigger",
3724
+ "properties": {
3725
+ "changeType": {
3726
+ "type": "string",
3727
+ "title": "Change Type",
3728
+ "enum": [
3729
+ "created",
3730
+ "modified",
3731
+ "any"
3732
+ ],
3733
+ "x-enumLabels": [
3734
+ "File Created",
3735
+ "File Modified",
3736
+ "Any Change"
3737
+ ]
3738
+ },
3739
+ "fileTypes": {
3740
+ "type": "array",
3741
+ "title": "File Types",
3742
+ "description": "Filter by extension (e.g., pdf, docx)",
3743
+ "items": {
3744
+ "type": "string"
3745
+ }
3746
+ },
3747
+ "folderId": {
3748
+ "type": "string",
3749
+ "title": "Folder ID",
3750
+ "description": "Watch specific folder (leave empty for all)"
3751
+ },
3752
+ "pollInterval": {
3753
+ "type": "integer",
3754
+ "title": "Poll Interval (minutes)",
3755
+ "default": 10,
3756
+ "minimum": 5
3757
+ },
3758
+ "provider": {
3759
+ "type": "string",
3760
+ "title": "Provider",
3761
+ "enum": [
3762
+ "google",
3763
+ "microsoft"
3764
+ ],
3765
+ "x-enumLabels": [
3766
+ "Google Drive",
3767
+ "OneDrive"
3768
+ ]
3769
+ }
3770
+ },
3771
+ "required": [
3772
+ "provider",
3773
+ "changeType"
3774
+ ]
3775
+ },
3776
+ "input": {
3777
+ "type": "object"
3778
+ },
3779
+ "output": {
3780
+ "type": "object",
3781
+ "properties": {
3782
+ "file": {
3783
+ "type": "object",
3784
+ "properties": {
3785
+ "createdAt": {
3786
+ "type": "string",
3787
+ "title": "Created At",
3788
+ "format": "date-time"
3789
+ },
3790
+ "id": {
3791
+ "type": "string",
3792
+ "title": "File ID"
3793
+ },
3794
+ "mimeType": {
3795
+ "type": "string",
3796
+ "title": "MIME Type"
3797
+ },
3798
+ "name": {
3799
+ "type": "string",
3800
+ "title": "Name"
3801
+ },
3802
+ "size": {
3803
+ "type": "integer",
3804
+ "title": "Size (bytes)"
3805
+ },
3806
+ "webLink": {
3807
+ "type": "string",
3808
+ "title": "Web Link"
3809
+ }
3810
+ }
3811
+ }
3812
+ }
3813
+ }
3814
+ },
3815
+ "triggerEmailReceived": {
3816
+ "type": "trigger",
3817
+ "subType": "triggerEmailReceived",
3818
+ "label": "Email Received",
3819
+ "icon": "Mail",
3820
+ "description": "Trigger when a new email matches filters",
3821
+ "category": "Triggers",
3822
+ "config": {
3823
+ "type": "object",
3824
+ "title": "Email Trigger",
3825
+ "properties": {
3826
+ "fromFilter": {
3827
+ "type": "string",
3828
+ "title": "From (contains)",
3829
+ "description": "Filter by sender email or name"
3830
+ },
3831
+ "hasAttachment": {
3832
+ "type": "boolean",
3833
+ "title": "Has Attachment"
3834
+ },
3835
+ "isUnread": {
3836
+ "type": "boolean",
3837
+ "title": "Unread Only",
3838
+ "default": true
3839
+ },
3840
+ "labelFilter": {
3841
+ "type": "string",
3842
+ "title": "Label/Folder",
3843
+ "description": "Gmail label or Outlook folder"
3844
+ },
3845
+ "pollInterval": {
3846
+ "type": "integer",
3847
+ "title": "Poll Interval (minutes)",
3848
+ "default": 5,
3849
+ "minimum": 1,
3850
+ "maximum": 60
3851
+ },
3852
+ "provider": {
3853
+ "type": "string",
3854
+ "title": "Provider",
3855
+ "enum": [
3856
+ "google",
3857
+ "microsoft"
3858
+ ],
3859
+ "x-enumLabels": [
3860
+ "Gmail",
3861
+ "Outlook"
3862
+ ]
3863
+ },
3864
+ "subjectFilter": {
3865
+ "type": "string",
3866
+ "title": "Subject (contains)"
3867
+ }
3868
+ },
3869
+ "required": [
3870
+ "provider"
3871
+ ]
3872
+ },
3873
+ "input": {
3874
+ "type": "object"
3875
+ },
3876
+ "output": {
3877
+ "type": "object",
3878
+ "properties": {
3879
+ "email": {
3880
+ "type": "object",
3881
+ "properties": {
3882
+ "body": {
3883
+ "type": "string",
3884
+ "title": "Body"
3885
+ },
3886
+ "date": {
3887
+ "type": "string",
3888
+ "title": "Date",
3889
+ "format": "date-time"
3890
+ },
3891
+ "from": {
3892
+ "type": "string",
3893
+ "title": "From"
3894
+ },
3895
+ "id": {
3896
+ "type": "string",
3897
+ "title": "Email ID"
3898
+ },
3899
+ "snippet": {
3900
+ "type": "string",
3901
+ "title": "Snippet"
3902
+ },
3903
+ "subject": {
3904
+ "type": "string",
3905
+ "title": "Subject"
3906
+ },
3907
+ "to": {
3908
+ "type": "string",
3909
+ "title": "To"
3910
+ }
3911
+ }
3912
+ }
3913
+ }
3914
+ }
3915
+ },
3916
+ "triggerEntityRecordCreated": {
3917
+ "type": "trigger",
3918
+ "subType": "triggerEntityRecordCreated",
3919
+ "label": "Entity Record Created",
3920
+ "icon": "Plus",
3921
+ "description": "Triggers when a new entity record is created",
3922
+ "category": "Triggers",
3923
+ "config": {
3924
+ "type": "object",
3925
+ "title": "Entity Record Created",
3926
+ "properties": {
3927
+ "entityName": {
3928
+ "type": "string",
3929
+ "title": "Entity Name"
3930
+ },
3931
+ "filters": {
3932
+ "type": "object",
3933
+ "title": "Filters"
3934
+ }
3935
+ },
3936
+ "required": [
3937
+ "entityName"
3938
+ ]
3939
+ },
3940
+ "input": {
3941
+ "type": "object",
3942
+ "properties": {
3943
+ "entityName": {
3944
+ "type": "string"
3945
+ },
3946
+ "entityRecordId": {
3947
+ "type": "string"
3948
+ }
3949
+ }
3950
+ },
3951
+ "output": {
3952
+ "type": "object",
3953
+ "properties": {
3954
+ "entityName": {
3955
+ "type": "string",
3956
+ "title": "Entity Name"
3957
+ },
3958
+ "entityRecordId": {
3959
+ "type": "string",
3960
+ "title": "Record ID"
3961
+ },
3962
+ "record": {
3963
+ "type": "object",
3964
+ "title": "Entity Record",
3965
+ "description": "The created entity record (fields vary by entity type)"
3966
+ }
3967
+ }
3968
+ }
3969
+ },
3970
+ "triggerEntityRecordDeleted": {
3971
+ "type": "trigger",
3972
+ "subType": "triggerEntityRecordDeleted",
3973
+ "label": "Entity Record Deleted",
3974
+ "icon": "Trash",
3975
+ "description": "Triggers when an entity record is deleted",
3976
+ "category": "Triggers",
3977
+ "config": {
3978
+ "type": "object",
3979
+ "title": "Entity Record Deleted",
3980
+ "properties": {
3981
+ "entityName": {
3982
+ "type": "string",
3983
+ "title": "Entity Name"
3984
+ }
3985
+ },
3986
+ "required": [
3987
+ "entityName"
3988
+ ]
3989
+ },
3990
+ "input": {
3991
+ "type": "object",
3992
+ "properties": {
3993
+ "entityName": {
3994
+ "type": "string"
3995
+ },
3996
+ "entityRecordId": {
3997
+ "type": "string"
3998
+ }
3999
+ }
4000
+ },
4001
+ "output": {
4002
+ "type": "object",
4003
+ "properties": {
4004
+ "entityName": {
4005
+ "type": "string",
4006
+ "title": "Entity Name"
4007
+ },
4008
+ "entityRecordId": {
4009
+ "type": "string",
4010
+ "title": "Record ID"
4011
+ },
4012
+ "record": {
4013
+ "type": "object",
4014
+ "title": "Entity Record",
4015
+ "description": "The deleted entity record (fields vary by entity type)"
4016
+ }
4017
+ }
4018
+ }
4019
+ },
4020
+ "triggerEntityRecordUpdated": {
4021
+ "type": "trigger",
4022
+ "subType": "triggerEntityRecordUpdated",
4023
+ "label": "Entity Record Updated",
4024
+ "icon": "Pencil",
4025
+ "description": "Triggers when an entity record is updated",
4026
+ "category": "Triggers",
4027
+ "config": {
4028
+ "type": "object",
4029
+ "title": "Entity Record Updated",
4030
+ "properties": {
4031
+ "entityName": {
4032
+ "type": "string",
4033
+ "title": "Entity Name"
4034
+ },
4035
+ "filters": {
4036
+ "type": "object",
4037
+ "title": "Filters"
4038
+ },
4039
+ "watchFields": {
4040
+ "type": "array",
4041
+ "title": "Watch Fields",
4042
+ "items": {
4043
+ "type": "string"
4044
+ }
4045
+ }
4046
+ },
4047
+ "required": [
4048
+ "entityName"
4049
+ ]
4050
+ },
4051
+ "input": {
4052
+ "type": "object",
4053
+ "properties": {
4054
+ "entityName": {
4055
+ "type": "string"
4056
+ },
4057
+ "entityRecordId": {
4058
+ "type": "string"
4059
+ }
4060
+ }
4061
+ },
4062
+ "output": {
4063
+ "type": "object",
4064
+ "properties": {
4065
+ "entityName": {
4066
+ "type": "string",
4067
+ "title": "Entity Name"
4068
+ },
4069
+ "entityRecordId": {
4070
+ "type": "string",
4071
+ "title": "Record ID"
4072
+ },
4073
+ "record": {
4074
+ "type": "object",
4075
+ "title": "Entity Record",
4076
+ "description": "The updated entity record (fields vary by entity type)"
4077
+ }
4078
+ }
4079
+ }
4080
+ },
4081
+ "triggerEscalation": {
4082
+ "type": "trigger",
4083
+ "subType": "triggerEscalation",
4084
+ "label": "Escalation",
4085
+ "icon": "ArrowUpRight",
4086
+ "description": "Triggers when an escalation occurs",
4087
+ "category": "Triggers",
4088
+ "config": {
4089
+ "type": "object",
4090
+ "title": "Escalation",
4091
+ "properties": {
4092
+ "escalationLevel": {
4093
+ "type": "integer",
4094
+ "title": "Escalation Level",
4095
+ "minimum": 1
4096
+ }
4097
+ }
4098
+ },
4099
+ "input": {
4100
+ "type": "object"
4101
+ },
4102
+ "output": {
4103
+ "type": "object"
4104
+ }
4105
+ },
4106
+ "triggerSLABreach": {
4107
+ "type": "trigger",
4108
+ "subType": "triggerSLABreach",
4109
+ "label": "SLA Breach",
4110
+ "icon": "TriangleAlert",
4111
+ "description": "Triggers when an SLA breach occurs",
4112
+ "category": "Triggers",
4113
+ "config": {
4114
+ "type": "object",
4115
+ "title": "SLA Breach",
4116
+ "properties": {
4117
+ "policyId": {
4118
+ "type": "string",
4119
+ "title": "SLA Policy ID"
4120
+ }
4121
+ }
4122
+ },
4123
+ "input": {
4124
+ "type": "object"
4125
+ },
4126
+ "output": {
4127
+ "type": "object"
4128
+ }
4129
+ },
4130
+ "triggerSLAWarning": {
4131
+ "type": "trigger",
4132
+ "subType": "triggerSLAWarning",
4133
+ "label": "SLA Warning",
4134
+ "icon": "Timer",
4135
+ "description": "Triggers when an SLA warning occurs",
4136
+ "category": "Triggers",
4137
+ "config": {
4138
+ "type": "object",
4139
+ "title": "SLA Warning",
4140
+ "properties": {
4141
+ "policyId": {
4142
+ "type": "string",
4143
+ "title": "SLA Policy ID"
4144
+ },
4145
+ "warningThreshold": {
4146
+ "type": "number",
4147
+ "title": "Warning Threshold (%)",
4148
+ "minimum": 0,
4149
+ "maximum": 100
4150
+ }
4151
+ }
4152
+ },
4153
+ "input": {
4154
+ "type": "object"
4155
+ },
4156
+ "output": {
4157
+ "type": "object"
4158
+ }
4159
+ },
4160
+ "triggerSchedule": {
4161
+ "type": "trigger",
4162
+ "subType": "triggerSchedule",
4163
+ "label": "Schedule",
4164
+ "icon": "Calendar",
4165
+ "description": "Trigger workflow on a schedule (cron expression)",
4166
+ "category": "Triggers",
4167
+ "config": {
4168
+ "type": "object",
4169
+ "title": "Schedule Trigger",
4170
+ "properties": {
4171
+ "description": {
4172
+ "type": "string",
4173
+ "title": "Description"
4174
+ },
4175
+ "schedule": {
4176
+ "type": "string",
4177
+ "title": "Cron Expression",
4178
+ "description": "e.g., '0 9 * * MON-FRI' for weekdays at 9am"
4179
+ },
4180
+ "timezone": {
4181
+ "type": "string",
4182
+ "title": "Timezone",
4183
+ "default": "UTC",
4184
+ "enum": [
4185
+ "UTC",
4186
+ "America/New_York",
4187
+ "America/Chicago",
4188
+ "America/Denver",
4189
+ "America/Los_Angeles",
4190
+ "Europe/London",
4191
+ "Europe/Paris",
4192
+ "Asia/Tokyo"
4193
+ ],
4194
+ "x-enumLabels": [
4195
+ "UTC",
4196
+ "Eastern Time",
4197
+ "Central Time",
4198
+ "Mountain Time",
4199
+ "Pacific Time",
4200
+ "London",
4201
+ "Paris",
4202
+ "Tokyo"
4203
+ ]
4204
+ }
4205
+ },
4206
+ "required": [
4207
+ "schedule"
4208
+ ]
4209
+ },
4210
+ "input": {
4211
+ "type": "object"
4212
+ },
4213
+ "output": {
4214
+ "type": "object",
4215
+ "properties": {
4216
+ "schedule": {
4217
+ "type": "string",
4218
+ "title": "Schedule"
4219
+ },
4220
+ "triggeredAt": {
4221
+ "type": "string",
4222
+ "title": "Triggered At",
4223
+ "format": "date-time"
4224
+ }
4225
+ }
4226
+ }
4227
+ },
4228
+ "triggerStart": {
4229
+ "type": "trigger",
4230
+ "subType": "triggerStart",
4231
+ "label": "Start",
4232
+ "icon": "Play",
4233
+ "description": "Workflow entry point - receives input and sets variables",
4234
+ "category": "Triggers",
4235
+ "config": {
4236
+ "type": "object"
4237
+ },
4238
+ "input": {
4239
+ "type": "object"
4240
+ },
4241
+ "output": {
4242
+ "type": "object"
4243
+ }
4244
+ },
4245
+ "triggerWebhookReceived": {
4246
+ "type": "trigger",
4247
+ "subType": "triggerWebhookReceived",
4248
+ "label": "Webhook",
4249
+ "icon": "Webhook",
4250
+ "description": "Triggers when a webhook is received",
4251
+ "category": "Triggers",
4252
+ "config": {
4253
+ "type": "object",
4254
+ "title": "Webhook Trigger",
4255
+ "properties": {
4256
+ "method": {
4257
+ "type": "string",
4258
+ "title": "HTTP Method",
4259
+ "enum": [
4260
+ "POST",
4261
+ "GET",
4262
+ "PUT"
4263
+ ]
4264
+ },
4265
+ "secret": {
4266
+ "type": "string",
4267
+ "title": "Secret",
4268
+ "format": "password"
4269
+ },
4270
+ "webhookPath": {
4271
+ "type": "string",
4272
+ "title": "Webhook Path"
4273
+ }
4274
+ },
4275
+ "required": [
4276
+ "webhookPath"
4277
+ ]
4278
+ },
4279
+ "input": {
4280
+ "type": "object"
4281
+ },
4282
+ "output": {
4283
+ "type": "object"
4284
+ }
4285
+ }
4286
+ };
4287
+ var nodeSchemas = Object.fromEntries(
4288
+ Object.entries(nodeDefinitions).map(([key, def]) => [key, def.config])
4289
+ );
4290
+ var TriggerNodeSubTypes = {
4291
+ "triggerCalendarEvent": {
4292
+ "value": "triggerCalendarEvent",
4293
+ "label": "Calendar Event",
4294
+ "icon": "CalendarClock",
4295
+ "description": "Trigger before or when calendar events occur"
4296
+ },
4297
+ "triggerDriveFileChanged": {
4298
+ "value": "triggerDriveFileChanged",
4299
+ "label": "File Changed",
4300
+ "icon": "FolderSync",
4301
+ "description": "Trigger when files are added or modified in Drive"
4302
+ },
4303
+ "triggerEmailReceived": {
4304
+ "value": "triggerEmailReceived",
4305
+ "label": "Email Received",
4306
+ "icon": "Mail",
4307
+ "description": "Trigger when a new email matches filters"
4308
+ },
4309
+ "triggerEntityRecordCreated": {
4310
+ "value": "triggerEntityRecordCreated",
4311
+ "label": "Entity Record Created",
4312
+ "icon": "Plus",
4313
+ "description": "Triggers when a new entity record is created"
4314
+ },
4315
+ "triggerEntityRecordDeleted": {
4316
+ "value": "triggerEntityRecordDeleted",
4317
+ "label": "Entity Record Deleted",
4318
+ "icon": "Trash",
4319
+ "description": "Triggers when an entity record is deleted"
4320
+ },
4321
+ "triggerEntityRecordUpdated": {
4322
+ "value": "triggerEntityRecordUpdated",
4323
+ "label": "Entity Record Updated",
4324
+ "icon": "Pencil",
4325
+ "description": "Triggers when an entity record is updated"
4326
+ },
4327
+ "triggerEscalation": {
4328
+ "value": "triggerEscalation",
4329
+ "label": "Escalation",
4330
+ "icon": "ArrowUpRight",
4331
+ "description": "Triggers when an escalation occurs"
4332
+ },
4333
+ "triggerSLABreach": {
4334
+ "value": "triggerSLABreach",
4335
+ "label": "SLA Breach",
4336
+ "icon": "TriangleAlert",
4337
+ "description": "Triggers when an SLA breach occurs"
4338
+ },
4339
+ "triggerSLAWarning": {
4340
+ "value": "triggerSLAWarning",
4341
+ "label": "SLA Warning",
4342
+ "icon": "Timer",
4343
+ "description": "Triggers when an SLA warning occurs"
4344
+ },
4345
+ "triggerSchedule": {
4346
+ "value": "triggerSchedule",
4347
+ "label": "Schedule",
4348
+ "icon": "Calendar",
4349
+ "description": "Trigger workflow on a schedule (cron expression)"
4350
+ },
4351
+ "triggerStart": {
4352
+ "value": "triggerStart",
4353
+ "label": "Start",
4354
+ "icon": "Play",
4355
+ "description": "Workflow entry point - receives input and sets variables"
4356
+ },
4357
+ "triggerWebhookReceived": {
4358
+ "value": "triggerWebhookReceived",
4359
+ "label": "Webhook",
4360
+ "icon": "Webhook",
4361
+ "description": "Triggers when a webhook is received"
4362
+ }
4363
+ };
4364
+ var HumanActionNodeSubTypes = {
4365
+ "humanActionApproval": {
4366
+ "value": "humanActionApproval",
4367
+ "label": "Approval",
4368
+ "icon": "CheckCircle",
4369
+ "description": "Request human approval"
4370
+ },
4371
+ "humanActionAssignment": {
4372
+ "value": "humanActionAssignment",
4373
+ "label": "Task Assignment",
4374
+ "icon": "UserPlus",
4375
+ "description": "Assign a task to a user"
4376
+ },
4377
+ "humanActionDataEntry": {
4378
+ "value": "humanActionDataEntry",
4379
+ "label": "Data Entry",
4380
+ "icon": "FormInput",
4381
+ "description": "Request human data entry"
4382
+ },
4383
+ "humanActionReview": {
4384
+ "value": "humanActionReview",
4385
+ "label": "Review",
4386
+ "icon": "Eye",
4387
+ "description": "Request human review"
4388
+ }
4389
+ };
4390
+ var AgentNodeSubTypes = {
4391
+ "actionAIClassify": {
4392
+ "value": "actionAIClassify",
4393
+ "label": "AI Classify",
4394
+ "icon": "Tags",
4395
+ "description": "Classify content into categories using AI"
4396
+ },
4397
+ "actionAIExtractData": {
4398
+ "value": "actionAIExtractData",
4399
+ "label": "AI Extract Data",
4400
+ "icon": "FileSearch",
4401
+ "description": "Extract structured data from unstructured content"
4402
+ },
4403
+ "actionAISummarize": {
4404
+ "value": "actionAISummarize",
4405
+ "label": "AI Summarize",
4406
+ "icon": "FileText",
4407
+ "description": "Summarize text content using AI"
4408
+ },
4409
+ "agentChat": {
4410
+ "value": "agentChat",
4411
+ "label": "Chat",
4412
+ "icon": "MessageSquare",
4413
+ "description": "AI chat interaction"
4414
+ },
4415
+ "agentCustomResponse": {
4416
+ "value": "agentCustomResponse",
4417
+ "label": "Custom Response",
4418
+ "icon": "MessageCircle",
4419
+ "description": "Send a custom response message"
4420
+ },
4421
+ "agentIntentDetector": {
4422
+ "value": "agentIntentDetector",
4423
+ "label": "Intent Detector",
4424
+ "icon": "Target",
4425
+ "description": "Detect user intent from message"
4426
+ },
4427
+ "agentKnowledgeGraph": {
4428
+ "value": "agentKnowledgeGraph",
4429
+ "label": "Knowledge Graph",
4430
+ "icon": "Network",
4431
+ "description": "Query knowledge graph for information"
4432
+ },
4433
+ "agentOpenTicket": {
4434
+ "value": "agentOpenTicket",
4435
+ "label": "Open Ticket",
4436
+ "icon": "Ticket",
4437
+ "description": "Create a support ticket"
4438
+ },
4439
+ "agentStructuredOutput": {
4440
+ "value": "agentStructuredOutput",
4441
+ "label": "Structured Output",
4442
+ "icon": "Brain",
4443
+ "description": "AI-powered structured data extraction"
4444
+ },
4445
+ "agentTransferToHuman": {
4446
+ "value": "agentTransferToHuman",
4447
+ "label": "Transfer to Human",
4448
+ "icon": "UserCheck",
4449
+ "description": "Transfer conversation to human agent"
4450
+ }
4451
+ };
4452
+ var ActionNodeSubTypes = {
4453
+ "actionApiCall": {
4454
+ "value": "actionApiCall",
4455
+ "label": "API Call",
4456
+ "icon": "Globe",
4457
+ "description": "Make HTTP API requests"
4458
+ },
4459
+ "actionAssignSLAPolicy": {
4460
+ "value": "actionAssignSLAPolicy",
4461
+ "label": "Assign SLA Policy",
4462
+ "icon": "Clock",
4463
+ "description": "Assign an SLA policy to a record"
4464
+ },
4465
+ "actionCreateEntityRecord": {
4466
+ "value": "actionCreateEntityRecord",
4467
+ "label": "Create Entity Record",
4468
+ "icon": "FilePlus",
4469
+ "description": "Create a new entity record"
4470
+ },
4471
+ "actionDeleteEntityRecord": {
4472
+ "value": "actionDeleteEntityRecord",
4473
+ "label": "Delete Entity Record",
4474
+ "icon": "FileX",
4475
+ "description": "Delete an entity record"
4476
+ },
4477
+ "actionDocumentExtraction": {
4478
+ "value": "actionDocumentExtraction",
4479
+ "label": "Document Extraction",
4480
+ "icon": "FileSearch",
4481
+ "description": "Extract data from documents using AI"
4482
+ },
4483
+ "actionNatsRequest": {
4484
+ "value": "actionNatsRequest",
4485
+ "label": "NATS Request",
4486
+ "icon": "Send",
4487
+ "description": "Execute a NATS request-reply call with dynamic subject routing"
4488
+ },
4489
+ "actionQueryEntityRecords": {
4490
+ "value": "actionQueryEntityRecords",
4491
+ "label": "Query Entity Records",
4492
+ "icon": "Search",
4493
+ "description": "Query entity records with filters"
4494
+ },
4495
+ "actionSendEmail": {
4496
+ "value": "actionSendEmail",
4497
+ "label": "Send Email",
4498
+ "icon": "Mail",
4499
+ "description": "Send an email notification"
4500
+ },
4501
+ "actionSendSMS": {
4502
+ "value": "actionSendSMS",
4503
+ "label": "Send SMS",
4504
+ "icon": "Smartphone",
4505
+ "description": "Send an SMS message"
4506
+ },
4507
+ "actionSetVariables": {
4508
+ "value": "actionSetVariables",
4509
+ "label": "Set Variables",
4510
+ "icon": "Variable",
4511
+ "description": "Set workflow variables"
4512
+ },
4513
+ "actionUpdateEntityRecord": {
4514
+ "value": "actionUpdateEntityRecord",
4515
+ "label": "Update Entity Record",
4516
+ "icon": "FileEdit",
4517
+ "description": "Update an existing entity record"
4518
+ }
4519
+ };
4520
+ var LogicNodeSubTypes = {
4521
+ "logicFor": {
4522
+ "value": "logicFor",
4523
+ "label": "Loop",
4524
+ "icon": "Repeat",
4525
+ "description": "Iterate over a collection"
4526
+ },
4527
+ "logicIf": {
4528
+ "value": "logicIf",
4529
+ "label": "If Condition",
4530
+ "icon": "GitBranch",
4531
+ "description": "Conditional branching based on variables"
4532
+ },
4533
+ "logicSwitch": {
4534
+ "value": "logicSwitch",
4535
+ "label": "Switch",
4536
+ "icon": "GitMerge",
4537
+ "description": "Multi-way branching based on value"
4538
+ }
4539
+ };
4540
+ var DelayNodeSubTypes = {
4541
+ "delay": {
4542
+ "value": "delay",
4543
+ "label": "Delay",
4544
+ "icon": "Clock",
4545
+ "description": "Wait for a specified duration"
4546
+ }
4547
+ };
4548
+ var ParallelNodeSubTypes = {};
4549
+ var DataNodeSubTypes = {};
4550
+ var TimerNodeSubTypes = {};
4551
+ var LoopNodeSubTypes = {};
4552
+ var AccountingNodeSubTypes = {};
4553
+ var WorkflowNodeTypes = {
4554
+ trigger: { value: "trigger", label: "Trigger", category: "Triggers" },
4555
+ humanAction: { value: "humanAction", label: "Human Action", category: "User Interaction" },
4556
+ agent: { value: "agent", label: "Agent", category: "Automation" },
4557
+ action: { value: "action", label: "Action", category: "Automation" },
4558
+ logic: { value: "logic", label: "Logic", category: "Flow Control" },
4559
+ data: { value: "data", label: "Data", category: "Data Processing" },
4560
+ integration: { value: "integration", label: "Integration", category: "Integration" },
4561
+ timer: { value: "timer", label: "Timer", category: "Time & Scheduling" },
4562
+ loop: { value: "loop", label: "Loop", category: "Flow Control" },
4563
+ parallel: { value: "parallel", label: "Parallel", category: "Flow Control" },
4564
+ delay: { value: "delay", label: "Delay", category: "Flow Control" },
4565
+ subflow: { value: "subflow", label: "Subflow", category: "Flow Control" },
4566
+ custom: { value: "custom", label: "Custom", category: "Custom" },
4567
+ documentExtraction: { value: "documentExtraction", label: "Document Extraction", category: "Data Processing" },
4568
+ apiCall: { value: "apiCall", label: "API Call", category: "Integration" },
4569
+ accounting: { value: "accounting", label: "Accounting", category: "Accounting" }
4570
+ };
4571
+ var WorkflowEdgeTypes = {
4572
+ "compensation": {
4573
+ "value": "compensation",
4574
+ "label": "Compensation"
4575
+ },
4576
+ "conditional": {
4577
+ "value": "conditional",
4578
+ "label": "Conditional"
4579
+ },
4580
+ "default": {
4581
+ "value": "default",
4582
+ "label": "Default"
4583
+ },
4584
+ "error": {
4585
+ "value": "error",
4586
+ "label": "Error"
4587
+ },
4588
+ "loopBack": {
4589
+ "value": "loopBack",
4590
+ "label": "Loop Back"
4591
+ },
4592
+ "merge": {
4593
+ "value": "merge",
4594
+ "label": "Merge"
4595
+ },
4596
+ "normal": {
4597
+ "value": "normal",
4598
+ "label": "Normal"
4599
+ },
4600
+ "parallel": {
4601
+ "value": "parallel",
4602
+ "label": "Parallel"
4603
+ },
4604
+ "timeout": {
4605
+ "value": "timeout",
4606
+ "label": "Timeout"
4607
+ }
4608
+ };
4609
+ var WorkflowTypes = {
4610
+ "agent": {
4611
+ "value": "agent",
4612
+ "label": "Agent"
4613
+ },
4614
+ "chat": {
4615
+ "value": "chat",
4616
+ "label": "Chat"
4617
+ },
4618
+ "document": {
4619
+ "value": "document",
4620
+ "label": "Document"
4621
+ },
4622
+ "entity": {
4623
+ "value": "entity",
4624
+ "label": "Entity"
4625
+ },
4626
+ "productivity": {
4627
+ "value": "productivity",
4628
+ "label": "Productivity"
4629
+ }
4630
+ };
4631
+ export {
4632
+ AccountingNodeSubTypes,
4633
+ ActionNodeSubTypes,
4634
+ AgentNodeSubTypes,
4635
+ DataNodeSubTypes,
4636
+ DelayNodeSubTypes,
4637
+ DynamicSchemaForm,
4638
+ EdgeStatusCompleted,
4639
+ EdgeStatusPending,
4640
+ EdgeStatusSkipped,
4641
+ EdgeTypeCompensation,
4642
+ EdgeTypeConditional,
4643
+ EdgeTypeDefault,
4644
+ EdgeTypeError,
4645
+ EdgeTypeLoopBack,
4646
+ EdgeTypeMerge,
4647
+ EdgeTypeNormal,
4648
+ EdgeTypeParallel,
4649
+ EdgeTypeTimeout,
4650
+ ExpressionTypeDSL,
4651
+ ExpressionTypeFilter,
4652
+ ExpressionTypeJavaScript,
4653
+ ExpressionTypeRules,
4654
+ ExpressionTypeTemplate,
4655
+ HumanActionNodeSubTypes,
4656
+ InstanceStatusCompleted,
4657
+ InstanceStatusFailed,
4658
+ InstanceStatusNew,
4659
+ InstanceStatusPaused,
4660
+ InstanceStatusRunning,
4661
+ InstanceStatusWaiting,
4662
+ LogicNodeSubTypes,
4663
+ LoopNodeSubTypes,
4664
+ NodeStatusCompleted,
4665
+ NodeStatusFailed,
4666
+ NodeStatusPending,
4667
+ NodeStatusRunning,
4668
+ NodeStatusSkipped,
4669
+ NodeStatusWaiting,
4670
+ NodeSubTypeActionApiCall,
4671
+ NodeSubTypeActionAssignSLAPolicy,
4672
+ NodeSubTypeActionCSATSurvey,
4673
+ NodeSubTypeActionChangeSLAStatus,
4674
+ NodeSubTypeActionCreateEntityRecord,
4675
+ NodeSubTypeActionDeleteEntityRecord,
4676
+ NodeSubTypeActionDocumentExtraction,
4677
+ NodeSubTypeActionEscalateSLA,
4678
+ NodeSubTypeActionGenerateDocument,
4679
+ NodeSubTypeActionMergeEntityRecords,
4680
+ NodeSubTypeActionNatsRequest,
4681
+ NodeSubTypeActionProcessPayment,
4682
+ NodeSubTypeActionQueryEntityRecords,
4683
+ NodeSubTypeActionSendEmail,
4684
+ NodeSubTypeActionSendSMS,
4685
+ NodeSubTypeActionSetVariables,
4686
+ NodeSubTypeActionUpdateEntityRecord,
4687
+ NodeSubTypeAgentApiIntegration,
4688
+ NodeSubTypeAgentChat,
4689
+ NodeSubTypeAgentClientApiCall,
4690
+ NodeSubTypeAgentCustomResponse,
4691
+ NodeSubTypeAgentIntentDetector,
4692
+ NodeSubTypeAgentKnowledgeGraph,
4693
+ NodeSubTypeAgentOpenTicket,
4694
+ NodeSubTypeAgentStructuredOutput,
4695
+ NodeSubTypeAgentTransferToHuman,
4696
+ NodeSubTypeDataCalculate,
4697
+ NodeSubTypeDataFilter,
4698
+ NodeSubTypeDataMap,
4699
+ NodeSubTypeDataValidate,
4700
+ NodeSubTypeDelay,
4701
+ NodeSubTypeHumanActionApproval,
4702
+ NodeSubTypeHumanActionAssignment,
4703
+ NodeSubTypeHumanActionDataEntry,
4704
+ NodeSubTypeHumanActionReview,
4705
+ NodeSubTypeLogicFor,
4706
+ NodeSubTypeLogicIf,
4707
+ NodeSubTypeLogicParallel,
4708
+ NodeSubTypeLogicSwitch,
4709
+ NodeSubTypeLoopData,
4710
+ NodeSubTypeTimerBusinessHours,
4711
+ NodeSubTypeTimerDelay,
4712
+ NodeSubTypeTimerSchedule,
4713
+ NodeSubTypeTriggerEntityRecordCreated,
4714
+ NodeSubTypeTriggerEntityRecordDeleted,
4715
+ NodeSubTypeTriggerEntityRecordUpdated,
4716
+ NodeSubTypeTriggerEscalation,
4717
+ NodeSubTypeTriggerSLABreach,
4718
+ NodeSubTypeTriggerSLAWarning,
4719
+ NodeSubTypeTriggerStart,
4720
+ NodeSubTypeTriggerWebhookReceived,
4721
+ NodeTypeAccounting,
4722
+ NodeTypeAction,
4723
+ NodeTypeAgent,
4724
+ NodeTypeCustom,
4725
+ NodeTypeData,
4726
+ NodeTypeDelay,
4727
+ NodeTypeHumanAction,
4728
+ NodeTypeIntegration,
4729
+ NodeTypeLogic,
4730
+ NodeTypeLoop,
4731
+ NodeTypeParallel,
4732
+ NodeTypeSubflow,
4733
+ NodeTypeTimer,
4734
+ NodeTypeTrigger,
4735
+ ParallelNodeSubTypes,
4736
+ PersistenceTypeEphemeral,
4737
+ PersistenceTypePermanent,
4738
+ RuleLevelError,
4739
+ RuleLevelInfo,
4740
+ RuleLevelWarning,
4741
+ SchemaBuilder,
4742
+ TimeoutActionAlt,
4743
+ TimeoutActionFail,
4744
+ TimeoutActionRetry,
4745
+ TimeoutActionSkip,
4746
+ TimerNodeSubTypes,
4747
+ TriggerNodeSubTypes,
4748
+ WorkflowDefinitionContext,
4749
+ WorkflowDefinitionCreate,
4750
+ WorkflowDefinitionCreated,
4751
+ WorkflowDefinitionDelete,
4752
+ WorkflowDefinitionDeleted,
4753
+ WorkflowDefinitionGet,
4754
+ WorkflowDefinitionGetByTitle,
4755
+ WorkflowDefinitionGetServer,
4756
+ WorkflowDefinitionList,
4757
+ WorkflowDefinitionProvider,
4758
+ WorkflowDefinitionUpdate,
4759
+ WorkflowDefinitionUpdated,
4760
+ WorkflowEdgeTypes,
4761
+ WorkflowExecutionCompleted,
4762
+ WorkflowExecutionFailed,
4763
+ WorkflowExecutionStarted,
4764
+ WorkflowInstanceContext,
4765
+ WorkflowInstanceCreate,
4766
+ WorkflowInstanceExecuteNode,
4767
+ WorkflowInstanceExecuteNodeLean,
4768
+ WorkflowInstanceExecuteNodeLeanServer,
4769
+ WorkflowInstanceExecuteNodeServer,
4770
+ WorkflowInstanceGet,
4771
+ WorkflowInstanceList,
4772
+ WorkflowInstanceProvider,
4773
+ WorkflowInstanceResumeNode,
4774
+ WorkflowInstanceResumeNodeServer,
4775
+ WorkflowInstanceUpdate,
4776
+ WorkflowInstanceUpdateNodeMetadata,
4777
+ WorkflowInstanceUpdated,
4778
+ WorkflowNodeTypes,
4779
+ WorkflowScheduleCreate,
4780
+ WorkflowScheduleDelete,
4781
+ WorkflowScheduleList,
4782
+ WorkflowSchedulePause,
4783
+ WorkflowScheduleResume,
4784
+ WorkflowScheduleUpdate,
4785
+ WorkflowTemplateGet,
4786
+ WorkflowTemplateInstantiate,
4787
+ WorkflowTemplateList,
4788
+ WorkflowTriggerFired,
4789
+ WorkflowTriggerPause,
4790
+ WorkflowTriggerRegister,
4791
+ WorkflowTriggerResume,
4792
+ WorkflowTriggerStatus,
4793
+ WorkflowTypeAgent,
4794
+ WorkflowTypeChat,
4795
+ WorkflowTypeDocument,
4796
+ WorkflowTypeEntity,
4797
+ WorkflowTypeProductivity,
4798
+ WorkflowTypes,
4799
+ nodeDefinitions,
4800
+ nodeSchemas,
4801
+ useWorkflowDefinition,
4802
+ useWorkflowDefinitionContext,
4803
+ useWorkflowInstance,
4804
+ useWorkflowInstanceContext,
4805
+ workflowDefinitionReducer,
4806
+ workflowInstanceReducer
4807
+ };
4808
+ //# sourceMappingURL=index.mjs.map