@codemation/core-nodes 0.0.25 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/index.cjs +267 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +252 -140
- package/dist/index.d.ts +252 -140
- package/dist/index.js +256 -137
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/index.ts +1 -0
- package/src/nodes/AIAgentConfig.ts +5 -10
- package/src/nodes/AIAgentNode.ts +7 -11
- package/src/nodes/AggregateNode.ts +6 -7
- package/src/nodes/CallbackNode.ts +18 -6
- package/src/nodes/CallbackNodeFactory.ts +31 -4
- package/src/nodes/CallbackResultNormalizerFactory.ts +7 -3
- package/src/nodes/ConnectionCredentialNode.ts +4 -4
- package/src/nodes/FilterNode.ts +6 -10
- package/src/nodes/HttpRequestNodeFactory.ts +4 -8
- package/src/nodes/IfNode.ts +15 -27
- package/src/nodes/MapDataNode.ts +3 -9
- package/src/nodes/NoOpNode.ts +4 -4
- package/src/nodes/NodeBackedToolRuntime.ts +40 -8
- package/src/nodes/SplitNode.ts +5 -15
- package/src/nodes/SubWorkflowNode.ts +43 -45
- package/src/nodes/SwitchNode.ts +29 -0
- package/src/nodes/WaitNode.ts +11 -9
- package/src/nodes/if.ts +1 -0
- package/src/nodes/mergeExecutionUtils.types.ts +31 -5
- package/src/nodes/switch.ts +33 -0
- package/src/register.types.ts +2 -0
- package/src/workflowAuthoring/WorkflowBranchBuilder.types.ts +108 -2
- package/src/workflowAuthoring/WorkflowChain.types.ts +207 -2
- package/src/workflowBuilder.types.ts +1 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry, ItemsInputNormalizer, NodeBackedToolConfig, RetryPolicy, WorkflowBuilder, chatModel, inject, injectable, node } from "@codemation/core";
|
|
1
|
+
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry, ItemValueResolver, ItemsInputNormalizer, NodeBackedToolConfig, NodeOutputNormalizer, RetryPolicy, WorkflowBuilder, chatModel, emitPorts, getOriginIndexFromItem, inject, injectable, isPortsEmission, node } from "@codemation/core";
|
|
2
2
|
import { ChatOpenAI } from "@langchain/openai";
|
|
3
3
|
import { AIMessage, HumanMessage, SystemMessage, ToolMessage } from "@langchain/core/messages";
|
|
4
4
|
import { isInteropZodSchema } from "@langchain/core/utils/types";
|
|
@@ -2491,9 +2491,12 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
2491
2491
|
|
|
2492
2492
|
//#endregion
|
|
2493
2493
|
//#region src/nodes/NodeBackedToolRuntime.ts
|
|
2494
|
+
var _ref$1, _ref2$1;
|
|
2494
2495
|
let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
2495
|
-
constructor(nodeResolver) {
|
|
2496
|
+
constructor(nodeResolver, itemValueResolver, outputNormalizer) {
|
|
2496
2497
|
this.nodeResolver = nodeResolver;
|
|
2498
|
+
this.itemValueResolver = itemValueResolver;
|
|
2499
|
+
this.outputNormalizer = outputNormalizer;
|
|
2497
2500
|
}
|
|
2498
2501
|
async execute(config$1, args) {
|
|
2499
2502
|
const nodeInput = config$1.toNodeItem({
|
|
@@ -2522,11 +2525,30 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
2522
2525
|
}
|
|
2523
2526
|
async executeResolvedNode(resolvedNode, nodeInput, ctx) {
|
|
2524
2527
|
if (this.isMultiInputNode(resolvedNode)) return await resolvedNode.executeMulti({ in: [nodeInput] }, ctx);
|
|
2525
|
-
if (this.
|
|
2528
|
+
if (this.isRunnableNode(resolvedNode)) {
|
|
2529
|
+
const runnable = resolvedNode;
|
|
2530
|
+
const runnableConfig = ctx.config;
|
|
2531
|
+
const carry = runnableConfig.lineageCarry ?? "emitOnly";
|
|
2532
|
+
const parsed = (runnable.inputSchema ?? runnableConfig.inputSchema ?? unknown()).parse(nodeInput.json);
|
|
2533
|
+
const items = [nodeInput];
|
|
2534
|
+
const execArgs = {
|
|
2535
|
+
input: parsed,
|
|
2536
|
+
item: nodeInput,
|
|
2537
|
+
itemIndex: 0,
|
|
2538
|
+
items,
|
|
2539
|
+
ctx: await this.itemValueResolver.resolveConfigForItem(ctx, nodeInput, 0, items)
|
|
2540
|
+
};
|
|
2541
|
+
const raw = await Promise.resolve(runnable.execute(execArgs));
|
|
2542
|
+
return this.outputNormalizer.normalizeExecuteResult({
|
|
2543
|
+
baseItem: nodeInput,
|
|
2544
|
+
raw,
|
|
2545
|
+
carry
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2526
2548
|
throw new Error(`Node-backed tool expected a runnable node instance for "${ctx.config.name ?? ctx.nodeId}".`);
|
|
2527
2549
|
}
|
|
2528
|
-
|
|
2529
|
-
return typeof value === "object" && value !== null && "execute"
|
|
2550
|
+
isRunnableNode(value) {
|
|
2551
|
+
return typeof value === "object" && value !== null && value.kind === "node" && typeof value.execute === "function" && typeof value.executeMulti !== "function";
|
|
2530
2552
|
}
|
|
2531
2553
|
isMultiInputNode(value) {
|
|
2532
2554
|
return typeof value === "object" && value !== null && "executeMulti" in value;
|
|
@@ -2535,7 +2557,13 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
2535
2557
|
NodeBackedToolRuntime = __decorate([
|
|
2536
2558
|
injectable(),
|
|
2537
2559
|
__decorateParam(0, inject(CoreTokens.NodeResolver)),
|
|
2538
|
-
|
|
2560
|
+
__decorateParam(1, inject(ItemValueResolver)),
|
|
2561
|
+
__decorateParam(2, inject(NodeOutputNormalizer)),
|
|
2562
|
+
__decorateMetadata("design:paramtypes", [
|
|
2563
|
+
Object,
|
|
2564
|
+
typeof (_ref$1 = typeof ItemValueResolver !== "undefined" && ItemValueResolver) === "function" ? _ref$1 : Object,
|
|
2565
|
+
typeof (_ref2$1 = typeof NodeOutputNormalizer !== "undefined" && NodeOutputNormalizer) === "function" ? _ref2$1 : Object
|
|
2566
|
+
])
|
|
2539
2567
|
], NodeBackedToolRuntime);
|
|
2540
2568
|
|
|
2541
2569
|
//#endregion
|
|
@@ -2553,8 +2581,9 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
2553
2581
|
kind = "node";
|
|
2554
2582
|
outputPorts = ["main"];
|
|
2555
2583
|
/**
|
|
2556
|
-
* Engine
|
|
2557
|
-
*
|
|
2584
|
+
* Engine validates {@link RunnableNodeConfig.inputSchema} (Zod) on {@code item.json} before enqueue, then resolves
|
|
2585
|
+
* per-item **`itemValue`** leaves on config before {@link #execute}. Prefer modeling prompts as
|
|
2586
|
+
* {@code { messages: [{ role, content }, ...] }} (on input or config) so persisted inputs are visible in the UI.
|
|
2558
2587
|
*/
|
|
2559
2588
|
inputSchema = unknown();
|
|
2560
2589
|
connectionCredentialExecutionContextFactory;
|
|
@@ -2566,7 +2595,7 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
2566
2595
|
this.executionHelpers = executionHelpers;
|
|
2567
2596
|
this.connectionCredentialExecutionContextFactory = this.executionHelpers.createConnectionCredentialExecutionContextFactory(credentialSessions);
|
|
2568
2597
|
}
|
|
2569
|
-
async
|
|
2598
|
+
async execute(args) {
|
|
2570
2599
|
const prepared = await this.getOrPrepareExecution(args.ctx);
|
|
2571
2600
|
const itemWithMappedJson = {
|
|
2572
2601
|
...args.item,
|
|
@@ -2914,7 +2943,6 @@ var AIAgent = class {
|
|
|
2914
2943
|
retryPolicy;
|
|
2915
2944
|
guardrails;
|
|
2916
2945
|
inputSchema;
|
|
2917
|
-
mapInput;
|
|
2918
2946
|
constructor(options) {
|
|
2919
2947
|
this.name = options.name;
|
|
2920
2948
|
this.messages = options.messages;
|
|
@@ -2924,15 +2952,15 @@ var AIAgent = class {
|
|
|
2924
2952
|
this.retryPolicy = options.retryPolicy ?? RetryPolicy.defaultForAiAgent;
|
|
2925
2953
|
this.guardrails = options.guardrails;
|
|
2926
2954
|
this.inputSchema = options.inputSchema;
|
|
2927
|
-
this.mapInput = options.mapInput;
|
|
2928
2955
|
}
|
|
2929
2956
|
};
|
|
2930
2957
|
|
|
2931
2958
|
//#endregion
|
|
2932
2959
|
//#region src/nodes/CallbackResultNormalizerFactory.ts
|
|
2933
2960
|
var CallbackResultNormalizer = class {
|
|
2934
|
-
static
|
|
2935
|
-
|
|
2961
|
+
static toPortsEmission(result, items) {
|
|
2962
|
+
if (isPortsEmission(result)) return result;
|
|
2963
|
+
return emitPorts({ main: result ?? items });
|
|
2936
2964
|
}
|
|
2937
2965
|
};
|
|
2938
2966
|
|
|
@@ -2941,9 +2969,18 @@ var CallbackResultNormalizer = class {
|
|
|
2941
2969
|
let CallbackNode = class CallbackNode$1 {
|
|
2942
2970
|
kind = "node";
|
|
2943
2971
|
outputPorts = ["main"];
|
|
2944
|
-
async execute(
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2972
|
+
async execute(args) {
|
|
2973
|
+
const items = args.items ?? [];
|
|
2974
|
+
const ctx = args.ctx;
|
|
2975
|
+
const config$1 = ctx.config;
|
|
2976
|
+
if (config$1 == null) throw new Error("CallbackNode: missing ctx.config (engine should always pass runnable config)");
|
|
2977
|
+
if (items.length === 0) {
|
|
2978
|
+
const result$1 = await config$1.callback(items, ctx);
|
|
2979
|
+
return CallbackResultNormalizer.toPortsEmission(result$1, items);
|
|
2980
|
+
}
|
|
2981
|
+
if (args.itemIndex !== items.length - 1) return [];
|
|
2982
|
+
const result = await config$1.callback(items, ctx);
|
|
2983
|
+
return CallbackResultNormalizer.toPortsEmission(result, items);
|
|
2947
2984
|
}
|
|
2948
2985
|
};
|
|
2949
2986
|
CallbackNode = __decorate([node({ packageName: "@codemation/core-nodes" })], CallbackNode);
|
|
@@ -2955,10 +2992,22 @@ var Callback = class Callback {
|
|
|
2955
2992
|
type = CallbackNode;
|
|
2956
2993
|
execution = { hint: "local" };
|
|
2957
2994
|
icon = "lucide:braces";
|
|
2958
|
-
|
|
2995
|
+
emptyBatchExecution = "runOnce";
|
|
2996
|
+
id;
|
|
2997
|
+
retryPolicy;
|
|
2998
|
+
nodeErrorHandler;
|
|
2999
|
+
declaredOutputPorts;
|
|
3000
|
+
constructor(name = "Callback", callback = Callback.defaultCallback, idOrOptions, options) {
|
|
2959
3001
|
this.name = name;
|
|
2960
3002
|
this.callback = callback;
|
|
2961
|
-
|
|
3003
|
+
const resolvedOptions = typeof idOrOptions === "string" ? {
|
|
3004
|
+
...options,
|
|
3005
|
+
id: idOrOptions
|
|
3006
|
+
} : idOrOptions;
|
|
3007
|
+
this.id = resolvedOptions?.id;
|
|
3008
|
+
this.retryPolicy = resolvedOptions?.retryPolicy;
|
|
3009
|
+
this.nodeErrorHandler = resolvedOptions?.nodeErrorHandler;
|
|
3010
|
+
this.declaredOutputPorts = resolvedOptions?.declaredOutputPorts;
|
|
2962
3011
|
}
|
|
2963
3012
|
static defaultCallback(items) {
|
|
2964
3013
|
return items;
|
|
@@ -2970,10 +3019,8 @@ var Callback = class Callback {
|
|
|
2970
3019
|
let HttpRequestNode = class HttpRequestNode$1 {
|
|
2971
3020
|
kind = "node";
|
|
2972
3021
|
outputPorts = ["main"];
|
|
2973
|
-
async execute(
|
|
2974
|
-
|
|
2975
|
-
for (const item of items) output.push(await this.executeItem(item, ctx));
|
|
2976
|
-
return { main: output };
|
|
3022
|
+
async execute(args) {
|
|
3023
|
+
return await this.executeItem(args.item, args.ctx);
|
|
2977
3024
|
}
|
|
2978
3025
|
async executeItem(item, ctx) {
|
|
2979
3026
|
const url = this.resolveUrl(item, ctx);
|
|
@@ -3080,9 +3127,9 @@ var HttpRequest = class {
|
|
|
3080
3127
|
let AggregateNode = class AggregateNode$1 {
|
|
3081
3128
|
kind = "node";
|
|
3082
3129
|
outputPorts = ["main"];
|
|
3083
|
-
async execute(
|
|
3084
|
-
if (items.length
|
|
3085
|
-
return
|
|
3130
|
+
async execute(args) {
|
|
3131
|
+
if (args.itemIndex !== args.items.length - 1) return [];
|
|
3132
|
+
return Promise.resolve(args.ctx.config.aggregate(args.items, args.ctx));
|
|
3086
3133
|
}
|
|
3087
3134
|
};
|
|
3088
3135
|
AggregateNode = __decorate([node({ packageName: "@codemation/core-nodes" })], AggregateNode);
|
|
@@ -3106,13 +3153,9 @@ var Aggregate = class {
|
|
|
3106
3153
|
let FilterNode = class FilterNode$1 {
|
|
3107
3154
|
kind = "node";
|
|
3108
3155
|
outputPorts = ["main"];
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
const item = items[i];
|
|
3113
|
-
if (ctx.config.predicate(item, i, items, ctx)) out.push(item);
|
|
3114
|
-
}
|
|
3115
|
-
return { main: out };
|
|
3156
|
+
execute(args) {
|
|
3157
|
+
if (args.ctx.config.predicate(args.item, args.itemIndex, args.items, args.ctx)) return args.item;
|
|
3158
|
+
return [];
|
|
3116
3159
|
}
|
|
3117
3160
|
};
|
|
3118
3161
|
FilterNode = __decorate([node({ packageName: "@codemation/core-nodes" })], FilterNode);
|
|
@@ -3131,40 +3174,57 @@ var Filter = class {
|
|
|
3131
3174
|
}
|
|
3132
3175
|
};
|
|
3133
3176
|
|
|
3177
|
+
//#endregion
|
|
3178
|
+
//#region src/nodes/mergeExecutionUtils.types.ts
|
|
3179
|
+
function getOriginIndex(item) {
|
|
3180
|
+
return getOriginIndexFromItem(item);
|
|
3181
|
+
}
|
|
3182
|
+
/**
|
|
3183
|
+
* Tags items routed to fan-in merge-by-origin (same contract as {@link IfNode} / {@link SwitchNode}).
|
|
3184
|
+
*/
|
|
3185
|
+
function tagItemForRouterFanIn(args) {
|
|
3186
|
+
const { item, itemIndex, nodeId, inputPortLabel = "$in" } = args;
|
|
3187
|
+
const metaBase = item.meta && typeof item.meta === "object" ? item.meta : {};
|
|
3188
|
+
const cmBase = metaBase._cm && typeof metaBase._cm === "object" ? metaBase._cm : {};
|
|
3189
|
+
const originIndex = typeof cmBase.originIndex === "number" ? cmBase.originIndex : itemIndex;
|
|
3190
|
+
return {
|
|
3191
|
+
...item,
|
|
3192
|
+
meta: {
|
|
3193
|
+
...metaBase,
|
|
3194
|
+
_cm: {
|
|
3195
|
+
...cmBase,
|
|
3196
|
+
originIndex
|
|
3197
|
+
}
|
|
3198
|
+
},
|
|
3199
|
+
paired: [{
|
|
3200
|
+
nodeId,
|
|
3201
|
+
output: inputPortLabel,
|
|
3202
|
+
itemIndex: originIndex
|
|
3203
|
+
}, ...item.paired ?? []]
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
function orderedInputs(inputsByPort, prefer) {
|
|
3207
|
+
const keys = Object.keys(inputsByPort);
|
|
3208
|
+
const preferred = (prefer ?? []).filter((k) => keys.includes(k));
|
|
3209
|
+
const rest = keys.filter((k) => !preferred.includes(k)).sort();
|
|
3210
|
+
return [...preferred, ...rest];
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3134
3213
|
//#endregion
|
|
3135
3214
|
//#region src/nodes/IfNode.ts
|
|
3136
3215
|
let IfNode = class IfNode$1 {
|
|
3137
3216
|
kind = "node";
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
meta: {
|
|
3150
|
-
...metaBase,
|
|
3151
|
-
_cm: {
|
|
3152
|
-
...cmBase,
|
|
3153
|
-
originIndex
|
|
3154
|
-
}
|
|
3155
|
-
},
|
|
3156
|
-
paired: [{
|
|
3157
|
-
nodeId: ctx.nodeId,
|
|
3158
|
-
output: "$in",
|
|
3159
|
-
itemIndex: originIndex
|
|
3160
|
-
}, ...item.paired ?? []]
|
|
3161
|
-
};
|
|
3162
|
-
(ctx.config.predicate(item, i, items, ctx) ? t : f).push(tagged);
|
|
3163
|
-
}
|
|
3164
|
-
return {
|
|
3165
|
-
true: t,
|
|
3166
|
-
false: f
|
|
3167
|
-
};
|
|
3217
|
+
execute(args) {
|
|
3218
|
+
const tagged = tagItemForRouterFanIn({
|
|
3219
|
+
item: args.item,
|
|
3220
|
+
itemIndex: args.itemIndex,
|
|
3221
|
+
nodeId: args.ctx.nodeId
|
|
3222
|
+
});
|
|
3223
|
+
const ok = args.ctx.config.predicate(args.item, args.itemIndex, args.items, args.ctx);
|
|
3224
|
+
return emitPorts({
|
|
3225
|
+
true: ok ? [tagged] : [],
|
|
3226
|
+
false: ok ? [] : [tagged]
|
|
3227
|
+
});
|
|
3168
3228
|
}
|
|
3169
3229
|
};
|
|
3170
3230
|
IfNode = __decorate([node({ packageName: "@codemation/core-nodes" })], IfNode);
|
|
@@ -3176,6 +3236,7 @@ var If = class {
|
|
|
3176
3236
|
type = IfNode;
|
|
3177
3237
|
execution = { hint: "local" };
|
|
3178
3238
|
icon = "lucide:split";
|
|
3239
|
+
declaredOutputPorts = ["true", "false"];
|
|
3179
3240
|
constructor(name, predicate, id) {
|
|
3180
3241
|
this.name = name;
|
|
3181
3242
|
this.predicate = predicate;
|
|
@@ -3183,22 +3244,47 @@ var If = class {
|
|
|
3183
3244
|
}
|
|
3184
3245
|
};
|
|
3185
3246
|
|
|
3247
|
+
//#endregion
|
|
3248
|
+
//#region src/nodes/SwitchNode.ts
|
|
3249
|
+
let SwitchNode = class SwitchNode$1 {
|
|
3250
|
+
kind = "node";
|
|
3251
|
+
async execute(args) {
|
|
3252
|
+
const tagged = tagItemForRouterFanIn({
|
|
3253
|
+
item: args.item,
|
|
3254
|
+
itemIndex: args.itemIndex,
|
|
3255
|
+
nodeId: args.ctx.nodeId
|
|
3256
|
+
});
|
|
3257
|
+
const key = await Promise.resolve(args.ctx.config.cfg.resolveCaseKey(args.item, args.itemIndex, args.items, args.ctx));
|
|
3258
|
+
const { cases, defaultCase } = args.ctx.config.cfg;
|
|
3259
|
+
return emitPorts({ [cases.includes(key) ? key : defaultCase]: [tagged] });
|
|
3260
|
+
}
|
|
3261
|
+
};
|
|
3262
|
+
SwitchNode = __decorate([node({ packageName: "@codemation/core-nodes" })], SwitchNode);
|
|
3263
|
+
|
|
3264
|
+
//#endregion
|
|
3265
|
+
//#region src/nodes/switch.ts
|
|
3266
|
+
var Switch = class {
|
|
3267
|
+
kind = "node";
|
|
3268
|
+
type = SwitchNode;
|
|
3269
|
+
execution = { hint: "local" };
|
|
3270
|
+
icon = "lucide:git-branch-plus";
|
|
3271
|
+
lineageCarry = "carryThrough";
|
|
3272
|
+
declaredOutputPorts;
|
|
3273
|
+
constructor(name, cfg, id) {
|
|
3274
|
+
this.name = name;
|
|
3275
|
+
this.cfg = cfg;
|
|
3276
|
+
this.id = id;
|
|
3277
|
+
this.declaredOutputPorts = [...new Set([...cfg.cases, cfg.defaultCase])].sort();
|
|
3278
|
+
}
|
|
3279
|
+
};
|
|
3280
|
+
|
|
3186
3281
|
//#endregion
|
|
3187
3282
|
//#region src/nodes/SplitNode.ts
|
|
3188
3283
|
let SplitNode = class SplitNode$1 {
|
|
3189
3284
|
kind = "node";
|
|
3190
3285
|
outputPorts = ["main"];
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
for (let i = 0; i < items.length; i++) {
|
|
3194
|
-
const item = items[i];
|
|
3195
|
-
const elements = ctx.config.getElements(item, ctx);
|
|
3196
|
-
for (let j = 0; j < elements.length; j++) out.push({
|
|
3197
|
-
...item,
|
|
3198
|
-
json: elements[j]
|
|
3199
|
-
});
|
|
3200
|
-
}
|
|
3201
|
-
return { main: out };
|
|
3286
|
+
execute(args) {
|
|
3287
|
+
return args.ctx.config.getElements(args.item, args.ctx);
|
|
3202
3288
|
}
|
|
3203
3289
|
};
|
|
3204
3290
|
SplitNode = __decorate([node({ packageName: "@codemation/core-nodes" })], SplitNode);
|
|
@@ -3271,7 +3357,7 @@ let MapDataNode = class MapDataNode$1 {
|
|
|
3271
3357
|
kind = "node";
|
|
3272
3358
|
outputPorts = ["main"];
|
|
3273
3359
|
inputSchema = unknown();
|
|
3274
|
-
async
|
|
3360
|
+
async execute(args) {
|
|
3275
3361
|
return args.ctx.config.map(args.item, args.ctx);
|
|
3276
3362
|
}
|
|
3277
3363
|
};
|
|
@@ -3292,19 +3378,6 @@ var MapData = class {
|
|
|
3292
3378
|
}
|
|
3293
3379
|
};
|
|
3294
3380
|
|
|
3295
|
-
//#endregion
|
|
3296
|
-
//#region src/nodes/mergeExecutionUtils.types.ts
|
|
3297
|
-
function getOriginIndex(item) {
|
|
3298
|
-
const v = (item.meta?._cm)?.originIndex;
|
|
3299
|
-
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
3300
|
-
}
|
|
3301
|
-
function orderedInputs(inputsByPort, prefer) {
|
|
3302
|
-
const keys = Object.keys(inputsByPort);
|
|
3303
|
-
const preferred = (prefer ?? []).filter((k) => keys.includes(k));
|
|
3304
|
-
const rest = keys.filter((k) => !preferred.includes(k)).sort();
|
|
3305
|
-
return [...preferred, ...rest];
|
|
3306
|
-
}
|
|
3307
|
-
|
|
3308
3381
|
//#endregion
|
|
3309
3382
|
//#region src/nodes/MergeNode.ts
|
|
3310
3383
|
let MergeNode = class MergeNode$1 {
|
|
@@ -3375,8 +3448,8 @@ var Merge = class {
|
|
|
3375
3448
|
let NoOpNode = class NoOpNode$1 {
|
|
3376
3449
|
kind = "node";
|
|
3377
3450
|
outputPorts = ["main"];
|
|
3378
|
-
|
|
3379
|
-
return
|
|
3451
|
+
execute(args) {
|
|
3452
|
+
return args.item;
|
|
3380
3453
|
}
|
|
3381
3454
|
};
|
|
3382
3455
|
NoOpNode = __decorate([node({ packageName: "@codemation/core-nodes" })], NoOpNode);
|
|
@@ -3401,44 +3474,42 @@ let SubWorkflowNode = class SubWorkflowNode$1 {
|
|
|
3401
3474
|
constructor(workflows) {
|
|
3402
3475
|
this.workflows = workflows;
|
|
3403
3476
|
}
|
|
3404
|
-
async execute(
|
|
3477
|
+
async execute(args) {
|
|
3478
|
+
const current = args.item;
|
|
3479
|
+
const metaBase = current.meta && typeof current.meta === "object" ? current.meta : {};
|
|
3480
|
+
const cmBase = metaBase._cm && typeof metaBase._cm === "object" ? metaBase._cm : {};
|
|
3481
|
+
const originIndex = typeof cmBase.originIndex === "number" ? cmBase.originIndex : void 0;
|
|
3482
|
+
const result = await this.workflows.runById({
|
|
3483
|
+
workflowId: args.ctx.config.workflowId,
|
|
3484
|
+
startAt: args.ctx.config.startAt,
|
|
3485
|
+
items: [current],
|
|
3486
|
+
parent: {
|
|
3487
|
+
runId: args.ctx.runId,
|
|
3488
|
+
workflowId: args.ctx.workflowId,
|
|
3489
|
+
nodeId: args.ctx.nodeId,
|
|
3490
|
+
subworkflowDepth: args.ctx.subworkflowDepth,
|
|
3491
|
+
engineMaxNodeActivations: args.ctx.engineMaxNodeActivations,
|
|
3492
|
+
engineMaxSubworkflowDepth: args.ctx.engineMaxSubworkflowDepth
|
|
3493
|
+
}
|
|
3494
|
+
});
|
|
3495
|
+
if (result.status !== "completed") throw new Error(`Subworkflow ${args.ctx.config.workflowId} did not complete (status=${result.status})`);
|
|
3405
3496
|
const out = [];
|
|
3406
|
-
for (
|
|
3407
|
-
const
|
|
3408
|
-
const
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
subworkflowDepth: ctx.subworkflowDepth,
|
|
3420
|
-
engineMaxNodeActivations: ctx.engineMaxNodeActivations,
|
|
3421
|
-
engineMaxSubworkflowDepth: ctx.engineMaxSubworkflowDepth
|
|
3422
|
-
}
|
|
3497
|
+
for (const produced of result.outputs) {
|
|
3498
|
+
const childMetaBase = produced.meta && typeof produced.meta === "object" ? produced.meta : {};
|
|
3499
|
+
const childCmBase = childMetaBase._cm && typeof childMetaBase._cm === "object" ? childMetaBase._cm : {};
|
|
3500
|
+
out.push({
|
|
3501
|
+
...produced,
|
|
3502
|
+
meta: originIndex === void 0 ? childMetaBase : {
|
|
3503
|
+
...childMetaBase,
|
|
3504
|
+
_cm: {
|
|
3505
|
+
...childCmBase,
|
|
3506
|
+
originIndex
|
|
3507
|
+
}
|
|
3508
|
+
},
|
|
3509
|
+
paired: current.paired ?? produced.paired
|
|
3423
3510
|
});
|
|
3424
|
-
if (result.status !== "completed") throw new Error(`Subworkflow ${ctx.config.workflowId} did not complete (status=${result.status})`);
|
|
3425
|
-
for (const produced of result.outputs) {
|
|
3426
|
-
const childMetaBase = produced.meta && typeof produced.meta === "object" ? produced.meta : {};
|
|
3427
|
-
const childCmBase = childMetaBase._cm && typeof childMetaBase._cm === "object" ? childMetaBase._cm : {};
|
|
3428
|
-
out.push({
|
|
3429
|
-
...produced,
|
|
3430
|
-
meta: originIndex === void 0 ? childMetaBase : {
|
|
3431
|
-
...childMetaBase,
|
|
3432
|
-
_cm: {
|
|
3433
|
-
...childCmBase,
|
|
3434
|
-
originIndex
|
|
3435
|
-
}
|
|
3436
|
-
},
|
|
3437
|
-
paired: current.paired ?? produced.paired
|
|
3438
|
-
});
|
|
3439
|
-
}
|
|
3440
3511
|
}
|
|
3441
|
-
return { main: out };
|
|
3512
|
+
return emitPorts({ main: out });
|
|
3442
3513
|
}
|
|
3443
3514
|
};
|
|
3444
3515
|
SubWorkflowNode = __decorate([
|
|
@@ -3474,12 +3545,14 @@ var WaitDuration = class {
|
|
|
3474
3545
|
let WaitNode = class WaitNode$1 {
|
|
3475
3546
|
kind = "node";
|
|
3476
3547
|
outputPorts = ["main"];
|
|
3477
|
-
async execute(
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3548
|
+
async execute(args) {
|
|
3549
|
+
if (args.itemIndex === 0) {
|
|
3550
|
+
const milliseconds = WaitDuration.normalize(args.ctx.config.milliseconds);
|
|
3551
|
+
if (milliseconds > 0) await new Promise((resolve) => {
|
|
3552
|
+
setTimeout(resolve, milliseconds);
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
return args.item;
|
|
3483
3556
|
}
|
|
3484
3557
|
};
|
|
3485
3558
|
WaitNode = __decorate([node({ packageName: "@codemation/core-nodes" })], WaitNode);
|
|
@@ -3572,8 +3645,8 @@ var WebhookTrigger = class WebhookTrigger {
|
|
|
3572
3645
|
let ConnectionCredentialNode = class ConnectionCredentialNode$1 {
|
|
3573
3646
|
kind = "node";
|
|
3574
3647
|
outputPorts = ["main"];
|
|
3575
|
-
|
|
3576
|
-
return
|
|
3648
|
+
execute(_args) {
|
|
3649
|
+
return [];
|
|
3577
3650
|
}
|
|
3578
3651
|
};
|
|
3579
3652
|
ConnectionCredentialNode = __decorate([node({ packageName: "@codemation/core-nodes" })], ConnectionCredentialNode);
|
|
@@ -3590,10 +3663,7 @@ function registerCoreNodes(container) {}
|
|
|
3590
3663
|
//#endregion
|
|
3591
3664
|
//#region src/workflowBuilder.types.ts
|
|
3592
3665
|
function createWorkflowBuilder(meta$2) {
|
|
3593
|
-
return new WorkflowBuilder(meta$2
|
|
3594
|
-
mode: "passThrough",
|
|
3595
|
-
prefer: ["true", "false"]
|
|
3596
|
-
}) });
|
|
3666
|
+
return new WorkflowBuilder(meta$2);
|
|
3597
3667
|
}
|
|
3598
3668
|
|
|
3599
3669
|
//#endregion
|
|
@@ -3675,6 +3745,21 @@ var WorkflowBranchBuilder = class WorkflowBranchBuilder {
|
|
|
3675
3745
|
const duration = durationOrUndefined ?? nameOrDuration;
|
|
3676
3746
|
return this.then(new Wait(name, WorkflowDurationParser.parse(duration), id));
|
|
3677
3747
|
}
|
|
3748
|
+
split(nameOrGetter, getElementsOrUndefined, id) {
|
|
3749
|
+
const name = typeof nameOrGetter === "string" ? nameOrGetter : "Split";
|
|
3750
|
+
const getElements = typeof nameOrGetter === "string" ? getElementsOrUndefined : nameOrGetter;
|
|
3751
|
+
return this.then(new Split(name, getElements, id));
|
|
3752
|
+
}
|
|
3753
|
+
filter(nameOrPredicate, predicateOrUndefined, id) {
|
|
3754
|
+
const name = typeof nameOrPredicate === "string" ? nameOrPredicate : "Filter";
|
|
3755
|
+
const predicate = typeof nameOrPredicate === "string" ? predicateOrUndefined : nameOrPredicate;
|
|
3756
|
+
return this.then(new Filter(name, predicate, id));
|
|
3757
|
+
}
|
|
3758
|
+
aggregate(nameOrFn, aggregateFnOrUndefined, id) {
|
|
3759
|
+
const name = typeof nameOrFn === "string" ? nameOrFn : "Aggregate";
|
|
3760
|
+
const aggregateFn = typeof nameOrFn === "string" ? aggregateFnOrUndefined : nameOrFn;
|
|
3761
|
+
return this.then(new Aggregate(name, aggregateFn, id));
|
|
3762
|
+
}
|
|
3678
3763
|
agent(nameOrOptions, optionsOrUndefined) {
|
|
3679
3764
|
return this.then(WorkflowAgentNodeFactory.create(nameOrOptions, optionsOrUndefined));
|
|
3680
3765
|
}
|
|
@@ -3706,6 +3791,27 @@ var WorkflowChain = class WorkflowChain {
|
|
|
3706
3791
|
const duration = durationOrUndefined ?? nameOrDuration;
|
|
3707
3792
|
return this.then(new Wait(name, WorkflowDurationParser.parse(duration), id));
|
|
3708
3793
|
}
|
|
3794
|
+
split(nameOrGetter, getElementsOrUndefined, id) {
|
|
3795
|
+
const name = typeof nameOrGetter === "string" ? nameOrGetter : "Split";
|
|
3796
|
+
const getElements = typeof nameOrGetter === "string" ? getElementsOrUndefined : nameOrGetter;
|
|
3797
|
+
return this.then(new Split(name, getElements, id));
|
|
3798
|
+
}
|
|
3799
|
+
filter(nameOrPredicate, predicateOrUndefined, id) {
|
|
3800
|
+
const name = typeof nameOrPredicate === "string" ? nameOrPredicate : "Filter";
|
|
3801
|
+
const predicate = typeof nameOrPredicate === "string" ? predicateOrUndefined : nameOrPredicate;
|
|
3802
|
+
return this.then(new Filter(name, predicate, id));
|
|
3803
|
+
}
|
|
3804
|
+
aggregate(nameOrFn, aggregateFnOrUndefined, id) {
|
|
3805
|
+
const name = typeof nameOrFn === "string" ? nameOrFn : "Aggregate";
|
|
3806
|
+
const aggregateFn = typeof nameOrFn === "string" ? aggregateFnOrUndefined : nameOrFn;
|
|
3807
|
+
return this.then(new Aggregate(name, aggregateFn, id));
|
|
3808
|
+
}
|
|
3809
|
+
merge(nameOrCfg, cfgOrId, id) {
|
|
3810
|
+
const name = typeof nameOrCfg === "string" ? nameOrCfg : "Merge";
|
|
3811
|
+
const cfg = typeof nameOrCfg === "string" ? (typeof cfgOrId === "string" ? void 0 : cfgOrId) ?? { mode: "passThrough" } : nameOrCfg ?? { mode: "passThrough" };
|
|
3812
|
+
const mergeId = typeof cfgOrId === "string" ? cfgOrId : id;
|
|
3813
|
+
return new WorkflowChain(this.chain.thenIntoInputHints(new Merge(name, cfg, mergeId)));
|
|
3814
|
+
}
|
|
3709
3815
|
if(nameOrPredicate, predicateOrBranches, branchesOrUndefined) {
|
|
3710
3816
|
const name = typeof nameOrPredicate === "string" ? nameOrPredicate : "If";
|
|
3711
3817
|
const predicate = typeof nameOrPredicate === "string" ? predicateOrBranches : nameOrPredicate;
|
|
@@ -3718,6 +3824,19 @@ var WorkflowChain = class WorkflowChain {
|
|
|
3718
3824
|
false: falseSteps
|
|
3719
3825
|
}));
|
|
3720
3826
|
}
|
|
3827
|
+
route(branches) {
|
|
3828
|
+
const mappedBranches = Object.fromEntries(Object.entries(branches).map(([port, branchFactory]) => [port, branchFactory ? (branch) => branchFactory(new WorkflowChain(branch)).chain : void 0]));
|
|
3829
|
+
return new WorkflowChain(this.chain.route(mappedBranches));
|
|
3830
|
+
}
|
|
3831
|
+
switch(nameOrCfg, cfgOrUndefined, id) {
|
|
3832
|
+
const name = typeof nameOrCfg === "string" ? nameOrCfg : "Switch";
|
|
3833
|
+
const cfg = typeof nameOrCfg === "string" ? cfgOrUndefined : nameOrCfg;
|
|
3834
|
+
return this.then(new Switch(name, {
|
|
3835
|
+
cases: cfg.cases,
|
|
3836
|
+
defaultCase: cfg.defaultCase,
|
|
3837
|
+
resolveCaseKey: (item) => cfg.resolveCaseKey(item.json)
|
|
3838
|
+
}, id)).route(cfg.branches);
|
|
3839
|
+
}
|
|
3721
3840
|
agent(nameOrOptions, optionsOrUndefined) {
|
|
3722
3841
|
return this.then(WorkflowAgentNodeFactory.create(nameOrOptions, optionsOrUndefined));
|
|
3723
3842
|
}
|
|
@@ -3852,5 +3971,5 @@ var ConnectionCredentialNodeConfigFactory = class {
|
|
|
3852
3971
|
};
|
|
3853
3972
|
|
|
3854
3973
|
//#endregion
|
|
3855
|
-
export { AIAgent, AIAgentConnectionWorkflowExpander, AIAgentExecutionHelpersFactory, AIAgentNode, AgentItemPortMap, AgentMessageFactory, AgentOutputFactory, AgentToolCallPortMap, Aggregate, AggregateNode, Callback, CallbackNode, CallbackResultNormalizer, ConnectionCredentialExecutionContextFactory, ConnectionCredentialNode, ConnectionCredentialNodeConfig, ConnectionCredentialNodeConfigFactory, Filter, FilterNode, HttpRequest, HttpRequestNode, If, IfNode, ManualTrigger, ManualTriggerNode, MapData, MapDataNode, Merge, MergeNode, NoOp, NoOpNode, OpenAIChatModelConfig, OpenAIChatModelFactory, OpenAiChatModelPresets, Split, SplitNode, SubWorkflow, SubWorkflowNode, Wait, WaitDuration, WaitNode, WebhookRespondNowAndContinueError, WebhookRespondNowError, WebhookTrigger, WebhookTriggerNode, WorkflowAuthoringBuilder, WorkflowBranchBuilder, WorkflowChain, createWorkflowBuilder, openAiChatModelPresets, registerCoreNodes, workflow };
|
|
3974
|
+
export { AIAgent, AIAgentConnectionWorkflowExpander, AIAgentExecutionHelpersFactory, AIAgentNode, AgentItemPortMap, AgentMessageFactory, AgentOutputFactory, AgentToolCallPortMap, Aggregate, AggregateNode, Callback, CallbackNode, CallbackResultNormalizer, ConnectionCredentialExecutionContextFactory, ConnectionCredentialNode, ConnectionCredentialNodeConfig, ConnectionCredentialNodeConfigFactory, Filter, FilterNode, HttpRequest, HttpRequestNode, If, IfNode, ManualTrigger, ManualTriggerNode, MapData, MapDataNode, Merge, MergeNode, NoOp, NoOpNode, OpenAIChatModelConfig, OpenAIChatModelFactory, OpenAiChatModelPresets, Split, SplitNode, SubWorkflow, SubWorkflowNode, Switch, SwitchNode, Wait, WaitDuration, WaitNode, WebhookRespondNowAndContinueError, WebhookRespondNowError, WebhookTrigger, WebhookTriggerNode, WorkflowAuthoringBuilder, WorkflowBranchBuilder, WorkflowChain, createWorkflowBuilder, openAiChatModelPresets, registerCoreNodes, workflow };
|
|
3856
3975
|
//# sourceMappingURL=index.js.map
|