@q1k-oss/behaviour-tree-workflows 0.0.4 → 0.0.6
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.cjs +708 -51
- package/dist/index.d.cts +244 -1
- package/dist/index.d.ts +244 -1
- package/dist/index.js +702 -51
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ActionNode: () => ActionNode,
|
|
34
|
+
Aggregate: () => Aggregate,
|
|
34
35
|
AlwaysCondition: () => AlwaysCondition,
|
|
36
|
+
ArrayFilter: () => ArrayFilter,
|
|
35
37
|
BaseNode: () => BaseNode,
|
|
36
38
|
BehaviorTree: () => BehaviorTree,
|
|
37
39
|
BrowserAgent: () => BrowserAgent,
|
|
@@ -44,6 +46,7 @@ __export(index_exports, {
|
|
|
44
46
|
ConfigValidationError: () => ConfigValidationError,
|
|
45
47
|
ConfigurationError: () => ConfigurationError,
|
|
46
48
|
CounterAction: () => CounterAction,
|
|
49
|
+
DataTransform: () => DataTransform,
|
|
47
50
|
DecoratorNode: () => DecoratorNode,
|
|
48
51
|
Delay: () => Delay,
|
|
49
52
|
ExecutionTracker: () => ExecutionTracker,
|
|
@@ -62,6 +65,7 @@ __export(index_exports, {
|
|
|
62
65
|
LLMChat: () => LLMChat,
|
|
63
66
|
LLMToolCall: () => LLMToolCall,
|
|
64
67
|
LogMessage: () => LogMessage,
|
|
68
|
+
MathOp: () => MathOp,
|
|
65
69
|
MemoryDataStore: () => MemoryDataStore,
|
|
66
70
|
MemorySequence: () => MemorySequence,
|
|
67
71
|
MockAction: () => MockAction,
|
|
@@ -93,6 +97,7 @@ __export(index_exports, {
|
|
|
93
97
|
StructureValidationError: () => StructureValidationError,
|
|
94
98
|
SubTree: () => SubTree,
|
|
95
99
|
SuccessNode: () => SuccessNode,
|
|
100
|
+
ThresholdCheck: () => ThresholdCheck,
|
|
96
101
|
Timeout: () => Timeout,
|
|
97
102
|
ToolExecutor: () => ToolExecutor,
|
|
98
103
|
ToolRouter: () => ToolRouter,
|
|
@@ -123,6 +128,7 @@ __export(index_exports, {
|
|
|
123
128
|
registerStandardNodes: () => registerStandardNodes,
|
|
124
129
|
resolveString: () => resolveString,
|
|
125
130
|
resolveValue: () => resolveValue,
|
|
131
|
+
safeEvaluate: () => safeEvaluate,
|
|
126
132
|
safeValidateConfiguration: () => safeValidateConfiguration,
|
|
127
133
|
schemaRegistry: () => schemaRegistry,
|
|
128
134
|
semanticValidator: () => semanticValidator,
|
|
@@ -1187,6 +1193,21 @@ var Conditional = class extends CompositeNode {
|
|
|
1187
1193
|
};
|
|
1188
1194
|
|
|
1189
1195
|
// src/composites/for-each.ts
|
|
1196
|
+
function resolveFromBlackboard(blackboard, path2) {
|
|
1197
|
+
const parts = path2.split(".");
|
|
1198
|
+
const firstPart = parts[0];
|
|
1199
|
+
if (!firstPart) return void 0;
|
|
1200
|
+
let value = blackboard.get(firstPart);
|
|
1201
|
+
for (let i = 1; i < parts.length && value != null; i++) {
|
|
1202
|
+
const part = parts[i];
|
|
1203
|
+
if (part && typeof value === "object") {
|
|
1204
|
+
value = value[part];
|
|
1205
|
+
} else {
|
|
1206
|
+
return void 0;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return value;
|
|
1210
|
+
}
|
|
1190
1211
|
var ForEach = class extends CompositeNode {
|
|
1191
1212
|
collectionKey;
|
|
1192
1213
|
itemKey;
|
|
@@ -1210,7 +1231,7 @@ var ForEach = class extends CompositeNode {
|
|
|
1210
1231
|
"ForEach requires at least one child (body)"
|
|
1211
1232
|
);
|
|
1212
1233
|
}
|
|
1213
|
-
const collection = context.blackboard.get(this.collectionKey);
|
|
1234
|
+
const collection = this.collectionKey.includes(".") ? resolveFromBlackboard(context.blackboard, this.collectionKey) : context.blackboard.get(this.collectionKey);
|
|
1214
1235
|
if (!collection) {
|
|
1215
1236
|
this.log(`Collection '${this.collectionKey}' not found in blackboard`);
|
|
1216
1237
|
this._status = "FAILURE" /* FAILURE */;
|
|
@@ -2690,74 +2711,153 @@ var setVariableSchema = createNodeSchema("SetVariable", {
|
|
|
2690
2711
|
value: import_zod6.z.unknown()
|
|
2691
2712
|
});
|
|
2692
2713
|
|
|
2693
|
-
// src/
|
|
2714
|
+
// src/utilities/math-op.schema.ts
|
|
2694
2715
|
var import_zod7 = require("zod");
|
|
2695
|
-
var
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2716
|
+
var mathOpSchema = createNodeSchema("MathOp", {
|
|
2717
|
+
expression: import_zod7.z.string().min(1, "expression is required"),
|
|
2718
|
+
outputKey: import_zod7.z.string().min(1, "outputKey is required"),
|
|
2719
|
+
round: import_zod7.z.enum(["none", "round", "floor", "ceil"]).optional(),
|
|
2720
|
+
precision: import_zod7.z.number().int().nonnegative().optional()
|
|
2721
|
+
});
|
|
2722
|
+
|
|
2723
|
+
// src/utilities/array-filter.schema.ts
|
|
2724
|
+
var import_zod8 = require("zod");
|
|
2725
|
+
var filterConditionSchema = import_zod8.z.object({
|
|
2726
|
+
field: import_zod8.z.string().min(1),
|
|
2727
|
+
operator: import_zod8.z.enum([
|
|
2728
|
+
"eq",
|
|
2729
|
+
"ne",
|
|
2730
|
+
"gt",
|
|
2731
|
+
"lt",
|
|
2732
|
+
"gte",
|
|
2733
|
+
"lte",
|
|
2734
|
+
"in",
|
|
2735
|
+
"nin",
|
|
2736
|
+
"exists",
|
|
2737
|
+
"regex",
|
|
2738
|
+
"between",
|
|
2739
|
+
"contains"
|
|
2740
|
+
]),
|
|
2741
|
+
value: import_zod8.z.unknown().optional(),
|
|
2742
|
+
range: import_zod8.z.tuple([import_zod8.z.unknown(), import_zod8.z.unknown()]).optional()
|
|
2743
|
+
});
|
|
2744
|
+
var arrayFilterSchema = createNodeSchema("ArrayFilter", {
|
|
2745
|
+
input: import_zod8.z.string().min(1, "input is required"),
|
|
2746
|
+
outputKey: import_zod8.z.string().min(1, "outputKey is required"),
|
|
2747
|
+
conditions: import_zod8.z.array(filterConditionSchema).min(1, "at least one condition is required"),
|
|
2748
|
+
logic: import_zod8.z.enum(["and", "or"]).optional()
|
|
2749
|
+
});
|
|
2750
|
+
|
|
2751
|
+
// src/utilities/aggregate.schema.ts
|
|
2752
|
+
var import_zod9 = require("zod");
|
|
2753
|
+
var aggregateOperationSchema = import_zod9.z.object({
|
|
2754
|
+
type: import_zod9.z.enum(["count", "sum", "avg", "min", "max"]),
|
|
2755
|
+
field: import_zod9.z.string().optional(),
|
|
2756
|
+
as: import_zod9.z.string().optional()
|
|
2757
|
+
});
|
|
2758
|
+
var aggregateSchema = createNodeSchema("Aggregate", {
|
|
2759
|
+
input: import_zod9.z.string().min(1, "input is required"),
|
|
2760
|
+
outputKey: import_zod9.z.string().min(1, "outputKey is required"),
|
|
2761
|
+
operations: import_zod9.z.array(aggregateOperationSchema).min(1, "at least one operation is required"),
|
|
2762
|
+
groupBy: import_zod9.z.string().optional()
|
|
2763
|
+
});
|
|
2764
|
+
|
|
2765
|
+
// src/utilities/threshold-check.schema.ts
|
|
2766
|
+
var import_zod10 = require("zod");
|
|
2767
|
+
var thresholdLevelSchema = import_zod10.z.object({
|
|
2768
|
+
operator: import_zod10.z.enum(["lte", "lt", "gte", "gt", "eq", "ne", "between"]),
|
|
2769
|
+
value: import_zod10.z.unknown().optional(),
|
|
2770
|
+
range: import_zod10.z.tuple([import_zod10.z.unknown(), import_zod10.z.unknown()]).optional(),
|
|
2771
|
+
label: import_zod10.z.string().min(1, "label is required")
|
|
2772
|
+
});
|
|
2773
|
+
var thresholdCheckSchema = createNodeSchema("ThresholdCheck", {
|
|
2774
|
+
value: import_zod10.z.unknown(),
|
|
2775
|
+
thresholds: import_zod10.z.array(thresholdLevelSchema).min(1, "at least one threshold is required"),
|
|
2776
|
+
outputKey: import_zod10.z.string().optional(),
|
|
2777
|
+
failOn: import_zod10.z.array(import_zod10.z.string()).optional()
|
|
2778
|
+
});
|
|
2779
|
+
|
|
2780
|
+
// src/utilities/data-transform.schema.ts
|
|
2781
|
+
var import_zod11 = require("zod");
|
|
2782
|
+
var transformMappingSchema = import_zod11.z.object({
|
|
2783
|
+
target: import_zod11.z.string().min(1, "target is required"),
|
|
2784
|
+
value: import_zod11.z.unknown(),
|
|
2785
|
+
coerce: import_zod11.z.enum(["string", "number", "boolean"]).optional()
|
|
2786
|
+
});
|
|
2787
|
+
var dataTransformSchema = createNodeSchema("DataTransform", {
|
|
2788
|
+
outputKey: import_zod11.z.string().min(1, "outputKey is required"),
|
|
2789
|
+
mappings: import_zod11.z.array(transformMappingSchema).min(1, "at least one mapping is required"),
|
|
2790
|
+
wrapInArray: import_zod11.z.boolean().optional()
|
|
2791
|
+
});
|
|
2792
|
+
|
|
2793
|
+
// src/actions/llm-tool-call.schema.ts
|
|
2794
|
+
var import_zod12 = require("zod");
|
|
2795
|
+
var toolDefinitionSchema = import_zod12.z.object({
|
|
2796
|
+
name: import_zod12.z.string().min(1),
|
|
2797
|
+
description: import_zod12.z.string().min(1),
|
|
2798
|
+
inputSchema: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.unknown())
|
|
2699
2799
|
});
|
|
2700
2800
|
var llmToolCallSchema = createNodeSchema("LLMToolCall", {
|
|
2701
|
-
provider:
|
|
2702
|
-
model:
|
|
2703
|
-
systemPrompt:
|
|
2704
|
-
messagesKey:
|
|
2705
|
-
userMessageKey:
|
|
2706
|
-
toolsKey:
|
|
2707
|
-
tools:
|
|
2708
|
-
temperature:
|
|
2709
|
-
maxTokens:
|
|
2710
|
-
outputKey:
|
|
2801
|
+
provider: import_zod12.z.enum(["anthropic", "openai", "google", "ollama"]),
|
|
2802
|
+
model: import_zod12.z.string().min(1, "Model is required"),
|
|
2803
|
+
systemPrompt: import_zod12.z.string().optional(),
|
|
2804
|
+
messagesKey: import_zod12.z.string().min(1, "messagesKey is required"),
|
|
2805
|
+
userMessageKey: import_zod12.z.string().optional(),
|
|
2806
|
+
toolsKey: import_zod12.z.string().optional(),
|
|
2807
|
+
tools: import_zod12.z.array(toolDefinitionSchema).optional(),
|
|
2808
|
+
temperature: import_zod12.z.number().min(0).max(2).optional(),
|
|
2809
|
+
maxTokens: import_zod12.z.number().int().positive().optional(),
|
|
2810
|
+
outputKey: import_zod12.z.string().min(1, "outputKey is required")
|
|
2711
2811
|
});
|
|
2712
2812
|
|
|
2713
2813
|
// src/actions/tool-executor.schema.ts
|
|
2714
|
-
var
|
|
2814
|
+
var import_zod13 = require("zod");
|
|
2715
2815
|
var toolExecutorSchema = createNodeSchema("ToolExecutor", {
|
|
2716
|
-
responseKey:
|
|
2717
|
-
messagesKey:
|
|
2718
|
-
outputKey:
|
|
2816
|
+
responseKey: import_zod13.z.string().min(1, "responseKey is required"),
|
|
2817
|
+
messagesKey: import_zod13.z.string().min(1, "messagesKey is required"),
|
|
2818
|
+
outputKey: import_zod13.z.string().optional()
|
|
2719
2819
|
});
|
|
2720
2820
|
|
|
2721
2821
|
// src/actions/wait-for-signal.schema.ts
|
|
2722
|
-
var
|
|
2822
|
+
var import_zod14 = require("zod");
|
|
2723
2823
|
var waitForSignalSchema = createNodeSchema("WaitForSignal", {
|
|
2724
|
-
signalName:
|
|
2725
|
-
signalKey:
|
|
2726
|
-
timeoutMs:
|
|
2727
|
-
outputKey:
|
|
2824
|
+
signalName: import_zod14.z.string().min(1, "signalName is required"),
|
|
2825
|
+
signalKey: import_zod14.z.string().optional(),
|
|
2826
|
+
timeoutMs: import_zod14.z.number().int().positive().optional().default(864e5),
|
|
2827
|
+
outputKey: import_zod14.z.string().min(1, "outputKey is required")
|
|
2728
2828
|
});
|
|
2729
2829
|
|
|
2730
2830
|
// src/actions/tool-router.schema.ts
|
|
2731
|
-
var
|
|
2732
|
-
var toolDefinitionSchema2 =
|
|
2733
|
-
name:
|
|
2734
|
-
description:
|
|
2735
|
-
inputSchema:
|
|
2831
|
+
var import_zod15 = require("zod");
|
|
2832
|
+
var toolDefinitionSchema2 = import_zod15.z.object({
|
|
2833
|
+
name: import_zod15.z.string().min(1),
|
|
2834
|
+
description: import_zod15.z.string().min(1),
|
|
2835
|
+
inputSchema: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.unknown())
|
|
2736
2836
|
});
|
|
2737
|
-
var ruleSchema =
|
|
2738
|
-
pattern:
|
|
2739
|
-
toolSets:
|
|
2837
|
+
var ruleSchema = import_zod15.z.object({
|
|
2838
|
+
pattern: import_zod15.z.string().min(1),
|
|
2839
|
+
toolSets: import_zod15.z.array(import_zod15.z.string().min(1)).min(1)
|
|
2740
2840
|
});
|
|
2741
2841
|
var toolRouterSchema = createNodeSchema("ToolRouter", {
|
|
2742
|
-
intentKey:
|
|
2743
|
-
toolSets:
|
|
2744
|
-
defaultTools:
|
|
2745
|
-
rules:
|
|
2746
|
-
outputKey:
|
|
2842
|
+
intentKey: import_zod15.z.string().min(1, "intentKey is required"),
|
|
2843
|
+
toolSets: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.array(toolDefinitionSchema2)),
|
|
2844
|
+
defaultTools: import_zod15.z.array(import_zod15.z.string()).optional(),
|
|
2845
|
+
rules: import_zod15.z.array(ruleSchema).optional(),
|
|
2846
|
+
outputKey: import_zod15.z.string().min(1, "outputKey is required")
|
|
2747
2847
|
});
|
|
2748
2848
|
|
|
2749
2849
|
// src/decorators/streaming-sink.schema.ts
|
|
2750
|
-
var
|
|
2850
|
+
var import_zod16 = require("zod");
|
|
2751
2851
|
var streamingSinkSchema = createNodeSchema("StreamingSink", {
|
|
2752
|
-
channelId:
|
|
2753
|
-
channelKey:
|
|
2852
|
+
channelId: import_zod16.z.string().optional(),
|
|
2853
|
+
channelKey: import_zod16.z.string().optional()
|
|
2754
2854
|
}).refine(
|
|
2755
2855
|
(data) => data.channelId || data.channelKey,
|
|
2756
2856
|
{ message: "Either channelId or channelKey must be provided" }
|
|
2757
2857
|
);
|
|
2758
2858
|
|
|
2759
2859
|
// src/schemas/validation.ts
|
|
2760
|
-
var
|
|
2860
|
+
var import_zod17 = require("zod");
|
|
2761
2861
|
function zodErrorToConfigurationError(error, nodeType, nodeId) {
|
|
2762
2862
|
const nodeIdentifier = nodeId ? `${nodeType}:${nodeId}` : nodeType;
|
|
2763
2863
|
const issues = error.issues.map((issue) => {
|
|
@@ -2773,7 +2873,7 @@ function validateConfiguration(schema, config, nodeType, nodeId) {
|
|
|
2773
2873
|
try {
|
|
2774
2874
|
return schema.parse(config);
|
|
2775
2875
|
} catch (error) {
|
|
2776
|
-
if (error instanceof
|
|
2876
|
+
if (error instanceof import_zod17.z.ZodError) {
|
|
2777
2877
|
throw zodErrorToConfigurationError(error, nodeType, nodeId);
|
|
2778
2878
|
}
|
|
2779
2879
|
throw error;
|
|
@@ -2792,14 +2892,14 @@ function safeValidateConfiguration(schema, config, nodeType, nodeId) {
|
|
|
2792
2892
|
}
|
|
2793
2893
|
|
|
2794
2894
|
// src/schemas/tree-definition.schema.ts
|
|
2795
|
-
var
|
|
2796
|
-
var treeDefSchemaObject =
|
|
2797
|
-
type:
|
|
2798
|
-
id:
|
|
2799
|
-
name:
|
|
2800
|
-
props:
|
|
2801
|
-
children:
|
|
2802
|
-
|
|
2895
|
+
var import_zod18 = require("zod");
|
|
2896
|
+
var treeDefSchemaObject = import_zod18.z.object({
|
|
2897
|
+
type: import_zod18.z.string().min(1, "Node type is required"),
|
|
2898
|
+
id: import_zod18.z.string().optional(),
|
|
2899
|
+
name: import_zod18.z.string().optional(),
|
|
2900
|
+
props: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown()).optional(),
|
|
2901
|
+
children: import_zod18.z.array(
|
|
2902
|
+
import_zod18.z.lazy(() => treeDefinitionSchema)
|
|
2803
2903
|
).optional()
|
|
2804
2904
|
});
|
|
2805
2905
|
var treeDefinitionSchema = treeDefSchemaObject;
|
|
@@ -2882,6 +2982,11 @@ var SchemaRegistry = class {
|
|
|
2882
2982
|
this.register("BrowserAgent", browserAgentSchema);
|
|
2883
2983
|
this.register("HumanTask", humanTaskSchema);
|
|
2884
2984
|
this.register("SetVariable", setVariableSchema);
|
|
2985
|
+
this.register("MathOp", mathOpSchema);
|
|
2986
|
+
this.register("ArrayFilter", arrayFilterSchema);
|
|
2987
|
+
this.register("Aggregate", aggregateSchema);
|
|
2988
|
+
this.register("ThresholdCheck", thresholdCheckSchema);
|
|
2989
|
+
this.register("DataTransform", dataTransformSchema);
|
|
2885
2990
|
this.register("LLMToolCall", llmToolCallSchema);
|
|
2886
2991
|
this.register("ToolExecutor", toolExecutorSchema);
|
|
2887
2992
|
this.register("WaitForSignal", waitForSignalSchema);
|
|
@@ -3602,6 +3707,547 @@ var SetVariable = class extends ActionNode {
|
|
|
3602
3707
|
}
|
|
3603
3708
|
};
|
|
3604
3709
|
|
|
3710
|
+
// src/utilities/math-op.ts
|
|
3711
|
+
function tokenize(expr) {
|
|
3712
|
+
const tokens = [];
|
|
3713
|
+
let i = 0;
|
|
3714
|
+
while (i < expr.length) {
|
|
3715
|
+
const ch = expr[i];
|
|
3716
|
+
if (ch === " " || ch === " ") {
|
|
3717
|
+
i++;
|
|
3718
|
+
continue;
|
|
3719
|
+
}
|
|
3720
|
+
if (ch === "(" || ch === ")") {
|
|
3721
|
+
tokens.push({ type: ch === "(" ? "lparen" : "rparen", value: ch });
|
|
3722
|
+
i++;
|
|
3723
|
+
continue;
|
|
3724
|
+
}
|
|
3725
|
+
if (ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%") {
|
|
3726
|
+
const prev = tokens.length > 0 ? tokens[tokens.length - 1] : void 0;
|
|
3727
|
+
const isUnary = ch === "-" && (tokens.length === 0 || prev?.type === "op" || prev?.type === "lparen");
|
|
3728
|
+
if (isUnary) {
|
|
3729
|
+
let numStr = "-";
|
|
3730
|
+
i++;
|
|
3731
|
+
while (i < expr.length && isDigitOrDot(expr[i])) {
|
|
3732
|
+
numStr += expr[i];
|
|
3733
|
+
i++;
|
|
3734
|
+
}
|
|
3735
|
+
if (numStr === "-") {
|
|
3736
|
+
tokens.push({ type: "number", value: -1 });
|
|
3737
|
+
tokens.push({ type: "op", value: "*" });
|
|
3738
|
+
} else {
|
|
3739
|
+
const num = parseFloat(numStr);
|
|
3740
|
+
if (isNaN(num)) throw new Error(`Invalid number: ${numStr}`);
|
|
3741
|
+
tokens.push({ type: "number", value: num });
|
|
3742
|
+
}
|
|
3743
|
+
continue;
|
|
3744
|
+
}
|
|
3745
|
+
tokens.push({ type: "op", value: ch });
|
|
3746
|
+
i++;
|
|
3747
|
+
continue;
|
|
3748
|
+
}
|
|
3749
|
+
if (isDigitOrDot(ch)) {
|
|
3750
|
+
let numStr = "";
|
|
3751
|
+
while (i < expr.length && isDigitOrDot(expr[i])) {
|
|
3752
|
+
numStr += expr[i];
|
|
3753
|
+
i++;
|
|
3754
|
+
}
|
|
3755
|
+
const num = parseFloat(numStr);
|
|
3756
|
+
if (isNaN(num)) throw new Error(`Invalid number: ${numStr}`);
|
|
3757
|
+
tokens.push({ type: "number", value: num });
|
|
3758
|
+
continue;
|
|
3759
|
+
}
|
|
3760
|
+
throw new Error(`Unexpected character: '${ch}' at position ${i}`);
|
|
3761
|
+
}
|
|
3762
|
+
return tokens;
|
|
3763
|
+
}
|
|
3764
|
+
function isDigitOrDot(ch) {
|
|
3765
|
+
return ch >= "0" && ch <= "9" || ch === ".";
|
|
3766
|
+
}
|
|
3767
|
+
function evaluate(tokens) {
|
|
3768
|
+
let pos = 0;
|
|
3769
|
+
function current() {
|
|
3770
|
+
return tokens[pos];
|
|
3771
|
+
}
|
|
3772
|
+
function parseExpr() {
|
|
3773
|
+
let left = parseTerm();
|
|
3774
|
+
let tok = current();
|
|
3775
|
+
while (tok && tok.type === "op" && (tok.value === "+" || tok.value === "-")) {
|
|
3776
|
+
const op = tok.value;
|
|
3777
|
+
pos++;
|
|
3778
|
+
const right = parseTerm();
|
|
3779
|
+
left = op === "+" ? left + right : left - right;
|
|
3780
|
+
tok = current();
|
|
3781
|
+
}
|
|
3782
|
+
return left;
|
|
3783
|
+
}
|
|
3784
|
+
function parseTerm() {
|
|
3785
|
+
let left = parseFactor();
|
|
3786
|
+
let tok = current();
|
|
3787
|
+
while (tok && tok.type === "op" && (tok.value === "*" || tok.value === "/" || tok.value === "%")) {
|
|
3788
|
+
const op = tok.value;
|
|
3789
|
+
pos++;
|
|
3790
|
+
const right = parseFactor();
|
|
3791
|
+
if ((op === "/" || op === "%") && right === 0) {
|
|
3792
|
+
throw new Error("Division by zero");
|
|
3793
|
+
}
|
|
3794
|
+
if (op === "*") left = left * right;
|
|
3795
|
+
else if (op === "/") left = left / right;
|
|
3796
|
+
else left = left % right;
|
|
3797
|
+
tok = current();
|
|
3798
|
+
}
|
|
3799
|
+
return left;
|
|
3800
|
+
}
|
|
3801
|
+
function parseFactor() {
|
|
3802
|
+
const tok = current();
|
|
3803
|
+
if (!tok) {
|
|
3804
|
+
throw new Error("Unexpected end of expression");
|
|
3805
|
+
}
|
|
3806
|
+
if (tok.type === "number") {
|
|
3807
|
+
pos++;
|
|
3808
|
+
return tok.value;
|
|
3809
|
+
}
|
|
3810
|
+
if (tok.type === "lparen") {
|
|
3811
|
+
pos++;
|
|
3812
|
+
const val = parseExpr();
|
|
3813
|
+
const closing = current();
|
|
3814
|
+
if (!closing || closing.type !== "rparen") {
|
|
3815
|
+
throw new Error("Missing closing parenthesis");
|
|
3816
|
+
}
|
|
3817
|
+
pos++;
|
|
3818
|
+
return val;
|
|
3819
|
+
}
|
|
3820
|
+
throw new Error(`Unexpected token: ${JSON.stringify(tok)}`);
|
|
3821
|
+
}
|
|
3822
|
+
const result = parseExpr();
|
|
3823
|
+
const remaining = current();
|
|
3824
|
+
if (remaining) {
|
|
3825
|
+
throw new Error(`Unexpected token after expression: ${JSON.stringify(remaining)}`);
|
|
3826
|
+
}
|
|
3827
|
+
return result;
|
|
3828
|
+
}
|
|
3829
|
+
function safeEvaluate(expression) {
|
|
3830
|
+
const tokens = tokenize(expression);
|
|
3831
|
+
if (tokens.length === 0) {
|
|
3832
|
+
throw new Error("Empty expression");
|
|
3833
|
+
}
|
|
3834
|
+
return evaluate(tokens);
|
|
3835
|
+
}
|
|
3836
|
+
function applyRounding(value, round, precision) {
|
|
3837
|
+
if (round === "none") return value;
|
|
3838
|
+
const factor = Math.pow(10, precision);
|
|
3839
|
+
const scaled = value * factor;
|
|
3840
|
+
switch (round) {
|
|
3841
|
+
case "round":
|
|
3842
|
+
return Math.round(scaled) / factor;
|
|
3843
|
+
case "floor":
|
|
3844
|
+
return Math.floor(scaled) / factor;
|
|
3845
|
+
case "ceil":
|
|
3846
|
+
return Math.ceil(scaled) / factor;
|
|
3847
|
+
default:
|
|
3848
|
+
return value;
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
var MathOp = class extends ActionNode {
|
|
3852
|
+
expression;
|
|
3853
|
+
outputKey;
|
|
3854
|
+
round;
|
|
3855
|
+
precision;
|
|
3856
|
+
constructor(config) {
|
|
3857
|
+
super(config);
|
|
3858
|
+
this.expression = config.expression;
|
|
3859
|
+
this.outputKey = config.outputKey;
|
|
3860
|
+
this.round = config.round ?? "none";
|
|
3861
|
+
this.precision = config.precision ?? 0;
|
|
3862
|
+
}
|
|
3863
|
+
async executeTick(context) {
|
|
3864
|
+
try {
|
|
3865
|
+
const varCtx = {
|
|
3866
|
+
blackboard: context.blackboard,
|
|
3867
|
+
input: context.input,
|
|
3868
|
+
testData: context.testData
|
|
3869
|
+
};
|
|
3870
|
+
const resolved = resolveString(this.expression, varCtx);
|
|
3871
|
+
let result;
|
|
3872
|
+
if (typeof resolved === "number") {
|
|
3873
|
+
result = resolved;
|
|
3874
|
+
} else if (typeof resolved === "string") {
|
|
3875
|
+
result = safeEvaluate(resolved);
|
|
3876
|
+
} else {
|
|
3877
|
+
throw new Error(`Expression resolved to non-numeric type: ${typeof resolved}`);
|
|
3878
|
+
}
|
|
3879
|
+
if (!isFinite(result)) {
|
|
3880
|
+
throw new Error(`Expression result is not finite: ${result}`);
|
|
3881
|
+
}
|
|
3882
|
+
result = applyRounding(result, this.round, this.precision);
|
|
3883
|
+
context.blackboard.set(this.outputKey, result);
|
|
3884
|
+
this.log(`${this.expression} = ${result}`);
|
|
3885
|
+
return "SUCCESS" /* SUCCESS */;
|
|
3886
|
+
} catch (error) {
|
|
3887
|
+
this._lastError = error instanceof Error ? error.message : String(error);
|
|
3888
|
+
this.log(`MathOp failed: ${this._lastError}`);
|
|
3889
|
+
return "FAILURE" /* FAILURE */;
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
};
|
|
3893
|
+
|
|
3894
|
+
// src/utilities/array-filter.ts
|
|
3895
|
+
function getFieldValue(item, path2) {
|
|
3896
|
+
if (item === null || item === void 0) return void 0;
|
|
3897
|
+
const parts = path2.split(".");
|
|
3898
|
+
let current = item;
|
|
3899
|
+
for (const part of parts) {
|
|
3900
|
+
if (current === null || current === void 0) return void 0;
|
|
3901
|
+
if (typeof current !== "object") return void 0;
|
|
3902
|
+
current = current[part];
|
|
3903
|
+
}
|
|
3904
|
+
return current;
|
|
3905
|
+
}
|
|
3906
|
+
function evaluateCondition(item, condition, resolvedValue, resolvedRange) {
|
|
3907
|
+
const fieldVal = getFieldValue(item, condition.field);
|
|
3908
|
+
switch (condition.operator) {
|
|
3909
|
+
case "eq":
|
|
3910
|
+
return fieldVal === resolvedValue;
|
|
3911
|
+
case "ne":
|
|
3912
|
+
return fieldVal !== resolvedValue;
|
|
3913
|
+
case "gt":
|
|
3914
|
+
return fieldVal > resolvedValue;
|
|
3915
|
+
case "lt":
|
|
3916
|
+
return fieldVal < resolvedValue;
|
|
3917
|
+
case "gte":
|
|
3918
|
+
return fieldVal >= resolvedValue;
|
|
3919
|
+
case "lte":
|
|
3920
|
+
return fieldVal <= resolvedValue;
|
|
3921
|
+
case "in":
|
|
3922
|
+
if (!Array.isArray(resolvedValue)) return false;
|
|
3923
|
+
return resolvedValue.includes(fieldVal);
|
|
3924
|
+
case "nin":
|
|
3925
|
+
if (!Array.isArray(resolvedValue)) return true;
|
|
3926
|
+
return !resolvedValue.includes(fieldVal);
|
|
3927
|
+
case "exists":
|
|
3928
|
+
const shouldExist = resolvedValue !== false;
|
|
3929
|
+
const exists = fieldVal !== null && fieldVal !== void 0;
|
|
3930
|
+
return shouldExist ? exists : !exists;
|
|
3931
|
+
case "regex": {
|
|
3932
|
+
if (typeof fieldVal !== "string" || typeof resolvedValue !== "string") return false;
|
|
3933
|
+
try {
|
|
3934
|
+
return new RegExp(resolvedValue).test(fieldVal);
|
|
3935
|
+
} catch {
|
|
3936
|
+
return false;
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
case "between": {
|
|
3940
|
+
if (!resolvedRange) return false;
|
|
3941
|
+
const [min, max] = resolvedRange;
|
|
3942
|
+
return fieldVal >= min && fieldVal <= max;
|
|
3943
|
+
}
|
|
3944
|
+
case "contains": {
|
|
3945
|
+
if (typeof fieldVal === "string" && typeof resolvedValue === "string") {
|
|
3946
|
+
return fieldVal.includes(resolvedValue);
|
|
3947
|
+
}
|
|
3948
|
+
if (Array.isArray(fieldVal)) {
|
|
3949
|
+
return fieldVal.includes(resolvedValue);
|
|
3950
|
+
}
|
|
3951
|
+
return false;
|
|
3952
|
+
}
|
|
3953
|
+
default:
|
|
3954
|
+
return false;
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
var ArrayFilter = class extends ActionNode {
|
|
3958
|
+
input;
|
|
3959
|
+
outputKey;
|
|
3960
|
+
conditions;
|
|
3961
|
+
logic;
|
|
3962
|
+
constructor(config) {
|
|
3963
|
+
super(config);
|
|
3964
|
+
this.input = config.input;
|
|
3965
|
+
this.outputKey = config.outputKey;
|
|
3966
|
+
this.conditions = config.conditions;
|
|
3967
|
+
this.logic = config.logic ?? "and";
|
|
3968
|
+
}
|
|
3969
|
+
async executeTick(context) {
|
|
3970
|
+
try {
|
|
3971
|
+
const varCtx = {
|
|
3972
|
+
blackboard: context.blackboard,
|
|
3973
|
+
input: context.input,
|
|
3974
|
+
testData: context.testData
|
|
3975
|
+
};
|
|
3976
|
+
const inputResolved = typeof this.input === "string" ? resolveValue(this.input, varCtx) : this.input;
|
|
3977
|
+
if (!Array.isArray(inputResolved)) {
|
|
3978
|
+
throw new Error(
|
|
3979
|
+
`Input is not an array: got ${inputResolved === null ? "null" : typeof inputResolved}`
|
|
3980
|
+
);
|
|
3981
|
+
}
|
|
3982
|
+
const resolvedConditions = this.conditions.map((c) => ({
|
|
3983
|
+
condition: c,
|
|
3984
|
+
value: c.value !== void 0 ? resolveValue(c.value, varCtx) : void 0,
|
|
3985
|
+
range: c.range ? [resolveValue(c.range[0], varCtx), resolveValue(c.range[1], varCtx)] : void 0
|
|
3986
|
+
}));
|
|
3987
|
+
const result = inputResolved.filter((item) => {
|
|
3988
|
+
const results = resolvedConditions.map(
|
|
3989
|
+
({ condition, value, range }) => evaluateCondition(item, condition, value, range)
|
|
3990
|
+
);
|
|
3991
|
+
return this.logic === "and" ? results.every(Boolean) : results.some(Boolean);
|
|
3992
|
+
});
|
|
3993
|
+
context.blackboard.set(this.outputKey, result);
|
|
3994
|
+
this.log(`Filtered ${inputResolved.length} \u2192 ${result.length} items`);
|
|
3995
|
+
return "SUCCESS" /* SUCCESS */;
|
|
3996
|
+
} catch (error) {
|
|
3997
|
+
this._lastError = error instanceof Error ? error.message : String(error);
|
|
3998
|
+
this.log(`ArrayFilter failed: ${this._lastError}`);
|
|
3999
|
+
return "FAILURE" /* FAILURE */;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
};
|
|
4003
|
+
|
|
4004
|
+
// src/utilities/aggregate.ts
|
|
4005
|
+
function getFieldValue2(item, path2) {
|
|
4006
|
+
if (item === null || item === void 0) return void 0;
|
|
4007
|
+
const parts = path2.split(".");
|
|
4008
|
+
let current = item;
|
|
4009
|
+
for (const part of parts) {
|
|
4010
|
+
if (current === null || current === void 0) return void 0;
|
|
4011
|
+
if (typeof current !== "object") return void 0;
|
|
4012
|
+
current = current[part];
|
|
4013
|
+
}
|
|
4014
|
+
return current;
|
|
4015
|
+
}
|
|
4016
|
+
function computeAggregations(items, operations) {
|
|
4017
|
+
const result = {};
|
|
4018
|
+
for (const op of operations) {
|
|
4019
|
+
const key = op.as ?? (op.field ? `${op.type}_${op.field}` : op.type);
|
|
4020
|
+
if (op.type === "count") {
|
|
4021
|
+
result[key] = items.length;
|
|
4022
|
+
continue;
|
|
4023
|
+
}
|
|
4024
|
+
if (!op.field) {
|
|
4025
|
+
result[key] = null;
|
|
4026
|
+
continue;
|
|
4027
|
+
}
|
|
4028
|
+
const values = [];
|
|
4029
|
+
for (const item of items) {
|
|
4030
|
+
const raw = getFieldValue2(item, op.field);
|
|
4031
|
+
const num = typeof raw === "number" ? raw : parseFloat(String(raw));
|
|
4032
|
+
if (!isNaN(num)) values.push(num);
|
|
4033
|
+
}
|
|
4034
|
+
switch (op.type) {
|
|
4035
|
+
case "sum":
|
|
4036
|
+
result[key] = values.reduce((a, b) => a + b, 0);
|
|
4037
|
+
break;
|
|
4038
|
+
case "avg":
|
|
4039
|
+
result[key] = values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : 0;
|
|
4040
|
+
break;
|
|
4041
|
+
case "min":
|
|
4042
|
+
result[key] = values.length > 0 ? Math.min(...values) : null;
|
|
4043
|
+
break;
|
|
4044
|
+
case "max":
|
|
4045
|
+
result[key] = values.length > 0 ? Math.max(...values) : null;
|
|
4046
|
+
break;
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
return result;
|
|
4050
|
+
}
|
|
4051
|
+
var Aggregate = class extends ActionNode {
|
|
4052
|
+
input;
|
|
4053
|
+
outputKey;
|
|
4054
|
+
operations;
|
|
4055
|
+
groupBy;
|
|
4056
|
+
constructor(config) {
|
|
4057
|
+
super(config);
|
|
4058
|
+
this.input = config.input;
|
|
4059
|
+
this.outputKey = config.outputKey;
|
|
4060
|
+
this.operations = config.operations;
|
|
4061
|
+
this.groupBy = config.groupBy;
|
|
4062
|
+
}
|
|
4063
|
+
async executeTick(context) {
|
|
4064
|
+
try {
|
|
4065
|
+
const varCtx = {
|
|
4066
|
+
blackboard: context.blackboard,
|
|
4067
|
+
input: context.input,
|
|
4068
|
+
testData: context.testData
|
|
4069
|
+
};
|
|
4070
|
+
const inputResolved = typeof this.input === "string" ? resolveValue(this.input, varCtx) : this.input;
|
|
4071
|
+
if (!Array.isArray(inputResolved)) {
|
|
4072
|
+
throw new Error(
|
|
4073
|
+
`Input is not an array: got ${inputResolved === null ? "null" : typeof inputResolved}`
|
|
4074
|
+
);
|
|
4075
|
+
}
|
|
4076
|
+
if (!this.groupBy) {
|
|
4077
|
+
const result = computeAggregations(inputResolved, this.operations);
|
|
4078
|
+
context.blackboard.set(this.outputKey, result);
|
|
4079
|
+
this.log(`Aggregated ${inputResolved.length} items \u2192 ${JSON.stringify(result)}`);
|
|
4080
|
+
} else {
|
|
4081
|
+
const groups = {};
|
|
4082
|
+
for (const item of inputResolved) {
|
|
4083
|
+
const groupVal = getFieldValue2(item, this.groupBy);
|
|
4084
|
+
const groupKey = groupVal === null || groupVal === void 0 ? "__null__" : String(groupVal);
|
|
4085
|
+
if (!groups[groupKey]) groups[groupKey] = [];
|
|
4086
|
+
groups[groupKey].push(item);
|
|
4087
|
+
}
|
|
4088
|
+
const result = {};
|
|
4089
|
+
for (const [groupKey, groupItems] of Object.entries(groups)) {
|
|
4090
|
+
result[groupKey] = computeAggregations(groupItems, this.operations);
|
|
4091
|
+
}
|
|
4092
|
+
context.blackboard.set(this.outputKey, result);
|
|
4093
|
+
this.log(
|
|
4094
|
+
`Aggregated ${inputResolved.length} items into ${Object.keys(groups).length} groups`
|
|
4095
|
+
);
|
|
4096
|
+
}
|
|
4097
|
+
return "SUCCESS" /* SUCCESS */;
|
|
4098
|
+
} catch (error) {
|
|
4099
|
+
this._lastError = error instanceof Error ? error.message : String(error);
|
|
4100
|
+
this.log(`Aggregate failed: ${this._lastError}`);
|
|
4101
|
+
return "FAILURE" /* FAILURE */;
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
};
|
|
4105
|
+
|
|
4106
|
+
// src/utilities/threshold-check.ts
|
|
4107
|
+
function evaluateThreshold(val, threshold, resolvedValue, resolvedRange) {
|
|
4108
|
+
switch (threshold.operator) {
|
|
4109
|
+
case "lte":
|
|
4110
|
+
return val <= resolvedValue;
|
|
4111
|
+
case "lt":
|
|
4112
|
+
return val < resolvedValue;
|
|
4113
|
+
case "gte":
|
|
4114
|
+
return val >= resolvedValue;
|
|
4115
|
+
case "gt":
|
|
4116
|
+
return val > resolvedValue;
|
|
4117
|
+
case "eq":
|
|
4118
|
+
return val === resolvedValue;
|
|
4119
|
+
case "ne":
|
|
4120
|
+
return val !== resolvedValue;
|
|
4121
|
+
case "between": {
|
|
4122
|
+
if (!resolvedRange) return false;
|
|
4123
|
+
return val >= resolvedRange[0] && val <= resolvedRange[1];
|
|
4124
|
+
}
|
|
4125
|
+
default:
|
|
4126
|
+
return false;
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
var ThresholdCheck = class extends ActionNode {
|
|
4130
|
+
valueRef;
|
|
4131
|
+
thresholds;
|
|
4132
|
+
outputKey;
|
|
4133
|
+
failOn;
|
|
4134
|
+
constructor(config) {
|
|
4135
|
+
super(config);
|
|
4136
|
+
this.valueRef = config.value;
|
|
4137
|
+
this.thresholds = config.thresholds;
|
|
4138
|
+
this.outputKey = config.outputKey;
|
|
4139
|
+
this.failOn = config.failOn ?? [];
|
|
4140
|
+
}
|
|
4141
|
+
async executeTick(context) {
|
|
4142
|
+
try {
|
|
4143
|
+
const varCtx = {
|
|
4144
|
+
blackboard: context.blackboard,
|
|
4145
|
+
input: context.input,
|
|
4146
|
+
testData: context.testData
|
|
4147
|
+
};
|
|
4148
|
+
const resolved = typeof this.valueRef === "string" ? resolveValue(this.valueRef, varCtx) : this.valueRef;
|
|
4149
|
+
const numValue = typeof resolved === "number" ? resolved : parseFloat(String(resolved));
|
|
4150
|
+
if (isNaN(numValue)) {
|
|
4151
|
+
throw new Error(`Value is not numeric: ${JSON.stringify(resolved)}`);
|
|
4152
|
+
}
|
|
4153
|
+
let matchedLabel = "normal";
|
|
4154
|
+
for (const threshold of this.thresholds) {
|
|
4155
|
+
const thresholdValue = threshold.value !== void 0 ? resolveValue(threshold.value, varCtx) : void 0;
|
|
4156
|
+
const thresholdRange = threshold.range ? [resolveValue(threshold.range[0], varCtx), resolveValue(threshold.range[1], varCtx)] : void 0;
|
|
4157
|
+
if (evaluateThreshold(numValue, threshold, thresholdValue, thresholdRange)) {
|
|
4158
|
+
matchedLabel = threshold.label;
|
|
4159
|
+
break;
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
if (this.outputKey) {
|
|
4163
|
+
context.blackboard.set(this.outputKey, matchedLabel);
|
|
4164
|
+
}
|
|
4165
|
+
this.log(`Value ${numValue} \u2192 ${matchedLabel}`);
|
|
4166
|
+
if (this.failOn.includes(matchedLabel)) {
|
|
4167
|
+
this._lastError = `Threshold breach: ${matchedLabel} (value: ${numValue})`;
|
|
4168
|
+
return "FAILURE" /* FAILURE */;
|
|
4169
|
+
}
|
|
4170
|
+
return "SUCCESS" /* SUCCESS */;
|
|
4171
|
+
} catch (error) {
|
|
4172
|
+
this._lastError = error instanceof Error ? error.message : String(error);
|
|
4173
|
+
this.log(`ThresholdCheck failed: ${this._lastError}`);
|
|
4174
|
+
return "FAILURE" /* FAILURE */;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
};
|
|
4178
|
+
|
|
4179
|
+
// src/utilities/data-transform.ts
|
|
4180
|
+
function setNestedValue(obj, path2, value) {
|
|
4181
|
+
const parts = path2.split(".");
|
|
4182
|
+
let current = obj;
|
|
4183
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
4184
|
+
const part = parts[i];
|
|
4185
|
+
if (current[part] === void 0 || current[part] === null || typeof current[part] !== "object") {
|
|
4186
|
+
current[part] = {};
|
|
4187
|
+
}
|
|
4188
|
+
current = current[part];
|
|
4189
|
+
}
|
|
4190
|
+
const lastPart = parts[parts.length - 1];
|
|
4191
|
+
if (lastPart !== void 0) {
|
|
4192
|
+
current[lastPart] = value;
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
function coerceValue(value, coerce) {
|
|
4196
|
+
switch (coerce) {
|
|
4197
|
+
case "string":
|
|
4198
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
4199
|
+
case "number": {
|
|
4200
|
+
if (typeof value === "number") return value;
|
|
4201
|
+
const num = parseFloat(String(value));
|
|
4202
|
+
if (isNaN(num)) throw new Error(`Cannot coerce "${value}" to number`);
|
|
4203
|
+
return num;
|
|
4204
|
+
}
|
|
4205
|
+
case "boolean":
|
|
4206
|
+
if (typeof value === "boolean") return value;
|
|
4207
|
+
if (value === "true" || value === 1) return true;
|
|
4208
|
+
if (value === "false" || value === 0 || value === "" || value === null || value === void 0) return false;
|
|
4209
|
+
return Boolean(value);
|
|
4210
|
+
default:
|
|
4211
|
+
return value;
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
var DataTransform = class extends ActionNode {
|
|
4215
|
+
outputKey;
|
|
4216
|
+
mappings;
|
|
4217
|
+
wrapInArray;
|
|
4218
|
+
constructor(config) {
|
|
4219
|
+
super(config);
|
|
4220
|
+
this.outputKey = config.outputKey;
|
|
4221
|
+
this.mappings = config.mappings;
|
|
4222
|
+
this.wrapInArray = config.wrapInArray ?? false;
|
|
4223
|
+
}
|
|
4224
|
+
async executeTick(context) {
|
|
4225
|
+
try {
|
|
4226
|
+
const varCtx = {
|
|
4227
|
+
blackboard: context.blackboard,
|
|
4228
|
+
input: context.input,
|
|
4229
|
+
testData: context.testData
|
|
4230
|
+
};
|
|
4231
|
+
const result = {};
|
|
4232
|
+
for (const mapping of this.mappings) {
|
|
4233
|
+
let resolved = resolveValue(mapping.value, varCtx);
|
|
4234
|
+
if (mapping.coerce) {
|
|
4235
|
+
resolved = coerceValue(resolved, mapping.coerce);
|
|
4236
|
+
}
|
|
4237
|
+
setNestedValue(result, mapping.target, resolved);
|
|
4238
|
+
}
|
|
4239
|
+
const output = this.wrapInArray ? [result] : result;
|
|
4240
|
+
context.blackboard.set(this.outputKey, output);
|
|
4241
|
+
this.log(`Built object with ${this.mappings.length} fields \u2192 ${this.outputKey}`);
|
|
4242
|
+
return "SUCCESS" /* SUCCESS */;
|
|
4243
|
+
} catch (error) {
|
|
4244
|
+
this._lastError = error instanceof Error ? error.message : String(error);
|
|
4245
|
+
this.log(`DataTransform failed: ${this._lastError}`);
|
|
4246
|
+
return "FAILURE" /* FAILURE */;
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
};
|
|
4250
|
+
|
|
3605
4251
|
// src/integrations/piece-executor.ts
|
|
3606
4252
|
var PROVIDER_TO_PIECE = {
|
|
3607
4253
|
// Google services
|
|
@@ -5130,6 +5776,11 @@ function registerStandardNodes(registry) {
|
|
|
5130
5776
|
registry.register("LogMessage", LogMessage, { category: "action" });
|
|
5131
5777
|
registry.register("RegexExtract", RegexExtract, { category: "action" });
|
|
5132
5778
|
registry.register("SetVariable", SetVariable, { category: "action" });
|
|
5779
|
+
registry.register("MathOp", MathOp, { category: "action" });
|
|
5780
|
+
registry.register("ArrayFilter", ArrayFilter, { category: "action" });
|
|
5781
|
+
registry.register("Aggregate", Aggregate, { category: "action" });
|
|
5782
|
+
registry.register("ThresholdCheck", ThresholdCheck, { category: "action" });
|
|
5783
|
+
registry.register("DataTransform", DataTransform, { category: "action" });
|
|
5133
5784
|
registry.register("IntegrationAction", IntegrationAction, { category: "action" });
|
|
5134
5785
|
registry.register("PythonScript", PythonScript, { category: "action" });
|
|
5135
5786
|
registry.register("ParseFile", ParseFile, { category: "action" });
|
|
@@ -5980,7 +6631,9 @@ function createObservabilitySinkHandler(config = {}) {
|
|
|
5980
6631
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5981
6632
|
0 && (module.exports = {
|
|
5982
6633
|
ActionNode,
|
|
6634
|
+
Aggregate,
|
|
5983
6635
|
AlwaysCondition,
|
|
6636
|
+
ArrayFilter,
|
|
5984
6637
|
BaseNode,
|
|
5985
6638
|
BehaviorTree,
|
|
5986
6639
|
BrowserAgent,
|
|
@@ -5993,6 +6646,7 @@ function createObservabilitySinkHandler(config = {}) {
|
|
|
5993
6646
|
ConfigValidationError,
|
|
5994
6647
|
ConfigurationError,
|
|
5995
6648
|
CounterAction,
|
|
6649
|
+
DataTransform,
|
|
5996
6650
|
DecoratorNode,
|
|
5997
6651
|
Delay,
|
|
5998
6652
|
ExecutionTracker,
|
|
@@ -6011,6 +6665,7 @@ function createObservabilitySinkHandler(config = {}) {
|
|
|
6011
6665
|
LLMChat,
|
|
6012
6666
|
LLMToolCall,
|
|
6013
6667
|
LogMessage,
|
|
6668
|
+
MathOp,
|
|
6014
6669
|
MemoryDataStore,
|
|
6015
6670
|
MemorySequence,
|
|
6016
6671
|
MockAction,
|
|
@@ -6042,6 +6697,7 @@ function createObservabilitySinkHandler(config = {}) {
|
|
|
6042
6697
|
StructureValidationError,
|
|
6043
6698
|
SubTree,
|
|
6044
6699
|
SuccessNode,
|
|
6700
|
+
ThresholdCheck,
|
|
6045
6701
|
Timeout,
|
|
6046
6702
|
ToolExecutor,
|
|
6047
6703
|
ToolRouter,
|
|
@@ -6072,6 +6728,7 @@ function createObservabilitySinkHandler(config = {}) {
|
|
|
6072
6728
|
registerStandardNodes,
|
|
6073
6729
|
resolveString,
|
|
6074
6730
|
resolveValue,
|
|
6731
|
+
safeEvaluate,
|
|
6075
6732
|
safeValidateConfiguration,
|
|
6076
6733
|
schemaRegistry,
|
|
6077
6734
|
semanticValidator,
|