@codemation/core-nodes 1.0.0 → 1.0.2
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 +45 -0
- package/dist/index.cjs +184 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -68
- package/dist/index.d.ts +170 -68
- package/dist/index.js +185 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/nodes/AIAgentNode.ts +101 -3
- package/src/nodes/AgentToolExecutionCoordinator.ts +29 -3
- package/src/nodes/NodeBackedToolRuntime.ts +40 -4
- package/src/nodes/WebhookTriggerFactory.ts +1 -1
- package/src/nodes/aggregate.ts +1 -1
- package/src/nodes/aiAgentSupport.types.ts +18 -3
- package/src/nodes/httpRequest.ts +1 -0
- package/src/nodes/if.ts +1 -1
- package/src/nodes/mapData.ts +1 -0
- package/src/nodes/merge.ts +1 -1
- package/src/nodes/noOp.ts +1 -0
- package/src/nodes/split.ts +1 -1
- package/src/nodes/wait.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, CallableToolConfig, CodemationTelemetryAttributeNames, CodemationTelemetryMetricNames, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry, GenAiTelemetryAttributeNames, ItemExprResolver, ItemsInputNormalizer, NodeBackedToolConfig, NodeOutputNormalizer, RetryPolicy, RunnableOutputBehaviorResolver, WorkflowBuilder, chatModel, emitPorts, getOriginIndexFromItem, inject, injectable, isPortsEmission, node } from "@codemation/core";
|
|
1
|
+
import { AgentConfigInspector, AgentConnectionNodeCollector, AgentGuardrailDefaults, AgentMessageConfigNormalizer, CallableToolConfig, ChildExecutionScopeFactory, CodemationTelemetryAttributeNames, CodemationTelemetryMetricNames, ConnectionInvocationIdFactory, ConnectionNodeIdFactory, CoreTokens, DefinedNodeRegistry, GenAiTelemetryAttributeNames, ItemExprResolver, ItemsInputNormalizer, NodeBackedToolConfig, NodeOutputNormalizer, RetryPolicy, RunnableOutputBehaviorResolver, WorkflowBuilder, chatModel, emitPorts, getOriginIndexFromItem, inject, injectable, isPortsEmission, node } from "@codemation/core";
|
|
2
2
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
3
3
|
import { CredentialResolverFactory } from "@codemation/core/bootstrap";
|
|
4
4
|
import { Output, generateText, jsonSchema } from "ai";
|
|
@@ -2856,7 +2856,7 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
|
|
|
2856
2856
|
async executePlannedToolCall(args) {
|
|
2857
2857
|
const { plannedToolCall, ctx } = args;
|
|
2858
2858
|
const toolCallInputsByPort = AgentToolCallPortMap.fromInput(plannedToolCall.toolCall.input ?? {});
|
|
2859
|
-
const invocationId =
|
|
2859
|
+
const invocationId = plannedToolCall.invocationId;
|
|
2860
2860
|
const startedAt = /* @__PURE__ */ new Date();
|
|
2861
2861
|
const span = ctx.telemetry.startChildSpan({
|
|
2862
2862
|
name: "agent.tool.call",
|
|
@@ -2864,7 +2864,10 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
|
|
|
2864
2864
|
startedAt,
|
|
2865
2865
|
attributes: {
|
|
2866
2866
|
[CodemationTelemetryAttributeNames.connectionInvocationId]: invocationId,
|
|
2867
|
-
[CodemationTelemetryAttributeNames.toolName]: plannedToolCall.binding.config.name
|
|
2867
|
+
[CodemationTelemetryAttributeNames.toolName]: plannedToolCall.binding.config.name,
|
|
2868
|
+
...ctx.iterationId ? { [CodemationTelemetryAttributeNames.iterationId]: ctx.iterationId } : {},
|
|
2869
|
+
...typeof ctx.itemIndex === "number" ? { [CodemationTelemetryAttributeNames.iterationIndex]: ctx.itemIndex } : {},
|
|
2870
|
+
...ctx.parentInvocationId ? { [CodemationTelemetryAttributeNames.parentInvocationId]: ctx.parentInvocationId } : {}
|
|
2868
2871
|
}
|
|
2869
2872
|
});
|
|
2870
2873
|
await ctx.nodeState?.markRunning({
|
|
@@ -2872,8 +2875,23 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
|
|
|
2872
2875
|
activationId: ctx.activationId,
|
|
2873
2876
|
inputsByPort: toolCallInputsByPort
|
|
2874
2877
|
});
|
|
2878
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
2879
|
+
invocationId,
|
|
2880
|
+
connectionNodeId: plannedToolCall.nodeId,
|
|
2881
|
+
parentAgentNodeId: ctx.nodeId,
|
|
2882
|
+
parentAgentActivationId: ctx.activationId,
|
|
2883
|
+
status: "running",
|
|
2884
|
+
managedInput: this.toJsonValue(plannedToolCall.toolCall.input),
|
|
2885
|
+
queuedAt: startedAt.toISOString(),
|
|
2886
|
+
startedAt: startedAt.toISOString(),
|
|
2887
|
+
iterationId: ctx.iterationId,
|
|
2888
|
+
parentInvocationId: ctx.parentInvocationId
|
|
2889
|
+
});
|
|
2875
2890
|
try {
|
|
2876
|
-
const result = await plannedToolCall.binding.execute(plannedToolCall.toolCall.input ?? {}
|
|
2891
|
+
const result = await plannedToolCall.binding.execute(plannedToolCall.toolCall.input ?? {}, {
|
|
2892
|
+
parentSpan: span,
|
|
2893
|
+
parentInvocationId: invocationId
|
|
2894
|
+
});
|
|
2877
2895
|
const serialized = typeof result === "string" ? result : JSON.stringify(result);
|
|
2878
2896
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
2879
2897
|
await ctx.nodeState?.markCompleted({
|
|
@@ -2906,7 +2924,9 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
|
|
|
2906
2924
|
managedOutput: this.toJsonValue(result),
|
|
2907
2925
|
queuedAt: startedAt.toISOString(),
|
|
2908
2926
|
startedAt: startedAt.toISOString(),
|
|
2909
|
-
finishedAt: finishedAt.toISOString()
|
|
2927
|
+
finishedAt: finishedAt.toISOString(),
|
|
2928
|
+
iterationId: ctx.iterationId,
|
|
2929
|
+
parentInvocationId: ctx.parentInvocationId
|
|
2910
2930
|
});
|
|
2911
2931
|
return {
|
|
2912
2932
|
toolName: plannedToolCall.binding.config.name,
|
|
@@ -3047,7 +3067,9 @@ let AgentToolExecutionCoordinator = class AgentToolExecutionCoordinator$1 {
|
|
|
3047
3067
|
},
|
|
3048
3068
|
queuedAt: args.startedAt.toISOString(),
|
|
3049
3069
|
startedAt: args.startedAt.toISOString(),
|
|
3050
|
-
finishedAt: finishedAt.toISOString()
|
|
3070
|
+
finishedAt: finishedAt.toISOString(),
|
|
3071
|
+
iterationId: args.ctx.iterationId,
|
|
3072
|
+
parentInvocationId: args.ctx.parentInvocationId
|
|
3051
3073
|
});
|
|
3052
3074
|
}
|
|
3053
3075
|
createRepairPayload(args) {
|
|
@@ -3108,13 +3130,14 @@ AgentToolExecutionCoordinator = __decorate([
|
|
|
3108
3130
|
|
|
3109
3131
|
//#endregion
|
|
3110
3132
|
//#region src/nodes/NodeBackedToolRuntime.ts
|
|
3111
|
-
var _ref$1, _ref2$1, _ref3$1;
|
|
3133
|
+
var _ref$1, _ref2$1, _ref3$1, _ref4$1;
|
|
3112
3134
|
let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
3113
|
-
constructor(nodeResolver, itemExprResolver, outputNormalizer, outputBehaviorResolver) {
|
|
3135
|
+
constructor(nodeResolver, itemExprResolver, outputNormalizer, outputBehaviorResolver, childExecutionScopeFactory) {
|
|
3114
3136
|
this.nodeResolver = nodeResolver;
|
|
3115
3137
|
this.itemExprResolver = itemExprResolver;
|
|
3116
3138
|
this.outputNormalizer = outputNormalizer;
|
|
3117
3139
|
this.outputBehaviorResolver = outputBehaviorResolver;
|
|
3140
|
+
this.childExecutionScopeFactory = childExecutionScopeFactory;
|
|
3118
3141
|
}
|
|
3119
3142
|
async execute(config$1, args) {
|
|
3120
3143
|
const nodeInput = config$1.toNodeItem({
|
|
@@ -3125,10 +3148,7 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
3125
3148
|
ctx: args.ctx,
|
|
3126
3149
|
node: config$1.node
|
|
3127
3150
|
});
|
|
3128
|
-
const nodeCtx =
|
|
3129
|
-
...args.ctx,
|
|
3130
|
-
config: config$1.node
|
|
3131
|
-
};
|
|
3151
|
+
const nodeCtx = this.resolveNodeCtx(config$1, args);
|
|
3132
3152
|
const resolvedNode = this.nodeResolver.resolve(config$1.node.type);
|
|
3133
3153
|
const outputs = await this.executeResolvedNode(resolvedNode, nodeInput, nodeCtx);
|
|
3134
3154
|
return config$1.toToolOutput({
|
|
@@ -3141,6 +3161,35 @@ let NodeBackedToolRuntime = class NodeBackedToolRuntime$1 {
|
|
|
3141
3161
|
outputs
|
|
3142
3162
|
});
|
|
3143
3163
|
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Returns a re-rooted child ctx for nested-agent tools (so their LLM/tool connection ids derive
|
|
3166
|
+
* from the tool connection node, telemetry parents under the tool-call span, and connection
|
|
3167
|
+
* invocations carry `parentInvocationId`). Plain runnable tools (non-agent) keep the orchestrator
|
|
3168
|
+
* ctx with only `config` swapped — no nesting concern.
|
|
3169
|
+
*
|
|
3170
|
+
* The caller (`AIAgentNode.createItemScopedTools`) already wraps the orchestrator ctx via
|
|
3171
|
+
* `ConnectionCredentialExecutionContextFactory.forConnectionNode`, so `args.ctx.nodeId` is the
|
|
3172
|
+
* tool's own connection node id (e.g. `AIAgentNode:2__conn__tool__searchInMail`). We pass that
|
|
3173
|
+
* through as the sub-agent's `nodeId`; deriving another `toolConnectionNodeId(args.ctx.nodeId,
|
|
3174
|
+
* config.name)` here would prepend a duplicate `__conn__tool__<name>` segment and exponentially
|
|
3175
|
+
* deepen ids on each invocation, which also breaks credential resolution because user-provided
|
|
3176
|
+
* bindings sit on the single-level connection node id.
|
|
3177
|
+
*/
|
|
3178
|
+
resolveNodeCtx(config$1, args) {
|
|
3179
|
+
const isNestedAgent = AgentConfigInspector.isAgentNodeConfig(config$1.node);
|
|
3180
|
+
const hooks = args.hooks;
|
|
3181
|
+
if (!isNestedAgent || !hooks?.parentSpan || !hooks.parentInvocationId) return {
|
|
3182
|
+
...args.ctx,
|
|
3183
|
+
config: config$1.node
|
|
3184
|
+
};
|
|
3185
|
+
return this.childExecutionScopeFactory.forSubAgent({
|
|
3186
|
+
parentCtx: args.ctx,
|
|
3187
|
+
childNodeId: args.ctx.nodeId,
|
|
3188
|
+
childConfig: config$1.node,
|
|
3189
|
+
parentInvocationId: hooks.parentInvocationId,
|
|
3190
|
+
parentSpan: hooks.parentSpan
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3144
3193
|
async executeResolvedNode(resolvedNode, nodeInput, ctx) {
|
|
3145
3194
|
if (this.isMultiInputNode(resolvedNode)) return await resolvedNode.executeMulti({ in: [nodeInput] }, ctx);
|
|
3146
3195
|
if (this.isRunnableNode(resolvedNode)) {
|
|
@@ -3178,11 +3227,13 @@ NodeBackedToolRuntime = __decorate([
|
|
|
3178
3227
|
__decorateParam(1, inject(ItemExprResolver)),
|
|
3179
3228
|
__decorateParam(2, inject(NodeOutputNormalizer)),
|
|
3180
3229
|
__decorateParam(3, inject(RunnableOutputBehaviorResolver)),
|
|
3230
|
+
__decorateParam(4, inject(ChildExecutionScopeFactory)),
|
|
3181
3231
|
__decorateMetadata("design:paramtypes", [
|
|
3182
3232
|
Object,
|
|
3183
3233
|
typeof (_ref$1 = typeof ItemExprResolver !== "undefined" && ItemExprResolver) === "function" ? _ref$1 : Object,
|
|
3184
3234
|
typeof (_ref2$1 = typeof NodeOutputNormalizer !== "undefined" && NodeOutputNormalizer) === "function" ? _ref2$1 : Object,
|
|
3185
|
-
typeof (_ref3$1 = typeof RunnableOutputBehaviorResolver !== "undefined" && RunnableOutputBehaviorResolver) === "function" ? _ref3$1 : Object
|
|
3235
|
+
typeof (_ref3$1 = typeof RunnableOutputBehaviorResolver !== "undefined" && RunnableOutputBehaviorResolver) === "function" ? _ref3$1 : Object,
|
|
3236
|
+
typeof (_ref4$1 = typeof ChildExecutionScopeFactory !== "undefined" && ChildExecutionScopeFactory) === "function" ? _ref4$1 : Object
|
|
3186
3237
|
])
|
|
3187
3238
|
], NodeBackedToolRuntime);
|
|
3188
3239
|
|
|
@@ -3385,7 +3436,7 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3385
3436
|
return {
|
|
3386
3437
|
config: entry.config,
|
|
3387
3438
|
inputSchema: entry.runtime.inputSchema,
|
|
3388
|
-
execute: async (input) => {
|
|
3439
|
+
execute: async (input, hooks) => {
|
|
3389
3440
|
const validated = entry.runtime.inputSchema.parse(input);
|
|
3390
3441
|
return await entry.runtime.execute({
|
|
3391
3442
|
config: entry.config,
|
|
@@ -3393,7 +3444,8 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3393
3444
|
ctx: toolCredentialContext,
|
|
3394
3445
|
item,
|
|
3395
3446
|
itemIndex,
|
|
3396
|
-
items
|
|
3447
|
+
items,
|
|
3448
|
+
hooks
|
|
3397
3449
|
});
|
|
3398
3450
|
}
|
|
3399
3451
|
};
|
|
@@ -3443,11 +3495,36 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3443
3495
|
activationId: ctx.activationId,
|
|
3444
3496
|
inputsByPort: itemInputsByPort
|
|
3445
3497
|
});
|
|
3498
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
3499
|
+
invocationId,
|
|
3500
|
+
connectionNodeId: languageModelConnectionNodeId,
|
|
3501
|
+
parentAgentNodeId: ctx.nodeId,
|
|
3502
|
+
parentAgentActivationId: ctx.activationId,
|
|
3503
|
+
status: "queued",
|
|
3504
|
+
managedInput: summarizedInput,
|
|
3505
|
+
queuedAt: startedAt.toISOString(),
|
|
3506
|
+
iterationId: ctx.iterationId,
|
|
3507
|
+
itemIndex: ctx.itemIndex,
|
|
3508
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3509
|
+
});
|
|
3446
3510
|
await ctx.nodeState?.markRunning({
|
|
3447
3511
|
nodeId: languageModelConnectionNodeId,
|
|
3448
3512
|
activationId: ctx.activationId,
|
|
3449
3513
|
inputsByPort: itemInputsByPort
|
|
3450
3514
|
});
|
|
3515
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
3516
|
+
invocationId,
|
|
3517
|
+
connectionNodeId: languageModelConnectionNodeId,
|
|
3518
|
+
parentAgentNodeId: ctx.nodeId,
|
|
3519
|
+
parentAgentActivationId: ctx.activationId,
|
|
3520
|
+
status: "running",
|
|
3521
|
+
managedInput: summarizedInput,
|
|
3522
|
+
queuedAt: startedAt.toISOString(),
|
|
3523
|
+
startedAt: startedAt.toISOString(),
|
|
3524
|
+
iterationId: ctx.iterationId,
|
|
3525
|
+
itemIndex: ctx.itemIndex,
|
|
3526
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3527
|
+
});
|
|
3451
3528
|
try {
|
|
3452
3529
|
const tools = this.buildToolSet(itemScopedTools);
|
|
3453
3530
|
const callOptions = this.resolveCallOptions(model, guardrails.modelInvocationOptions);
|
|
@@ -3463,11 +3540,12 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3463
3540
|
});
|
|
3464
3541
|
const turnResult = this.extractTurnResult(result);
|
|
3465
3542
|
const finishedAt = /* @__PURE__ */ new Date();
|
|
3543
|
+
const managedOutput = this.summarizeTurnOutput(turnResult);
|
|
3466
3544
|
await ctx.nodeState?.markCompleted({
|
|
3467
3545
|
nodeId: languageModelConnectionNodeId,
|
|
3468
3546
|
activationId: ctx.activationId,
|
|
3469
3547
|
inputsByPort: itemInputsByPort,
|
|
3470
|
-
outputs: AgentOutputFactory.fromUnknown(
|
|
3548
|
+
outputs: AgentOutputFactory.fromUnknown(managedOutput)
|
|
3471
3549
|
});
|
|
3472
3550
|
await span.attachArtifact({
|
|
3473
3551
|
kind: "ai.messages",
|
|
@@ -3491,10 +3569,13 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3491
3569
|
parentAgentActivationId: ctx.activationId,
|
|
3492
3570
|
status: "completed",
|
|
3493
3571
|
managedInput: summarizedInput,
|
|
3494
|
-
managedOutput
|
|
3572
|
+
managedOutput,
|
|
3495
3573
|
queuedAt: startedAt.toISOString(),
|
|
3496
3574
|
startedAt: startedAt.toISOString(),
|
|
3497
|
-
finishedAt: finishedAt.toISOString()
|
|
3575
|
+
finishedAt: finishedAt.toISOString(),
|
|
3576
|
+
iterationId: ctx.iterationId,
|
|
3577
|
+
itemIndex: ctx.itemIndex,
|
|
3578
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3498
3579
|
});
|
|
3499
3580
|
return turnResult;
|
|
3500
3581
|
} catch (error) {
|
|
@@ -3530,11 +3611,36 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3530
3611
|
activationId: ctx.activationId,
|
|
3531
3612
|
inputsByPort: itemInputsByPort
|
|
3532
3613
|
});
|
|
3614
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
3615
|
+
invocationId,
|
|
3616
|
+
connectionNodeId: languageModelConnectionNodeId,
|
|
3617
|
+
parentAgentNodeId: ctx.nodeId,
|
|
3618
|
+
parentAgentActivationId: ctx.activationId,
|
|
3619
|
+
status: "queued",
|
|
3620
|
+
managedInput: summarizedInput,
|
|
3621
|
+
queuedAt: startedAt.toISOString(),
|
|
3622
|
+
iterationId: ctx.iterationId,
|
|
3623
|
+
itemIndex: ctx.itemIndex,
|
|
3624
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3625
|
+
});
|
|
3533
3626
|
await ctx.nodeState?.markRunning({
|
|
3534
3627
|
nodeId: languageModelConnectionNodeId,
|
|
3535
3628
|
activationId: ctx.activationId,
|
|
3536
3629
|
inputsByPort: itemInputsByPort
|
|
3537
3630
|
});
|
|
3631
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
3632
|
+
invocationId,
|
|
3633
|
+
connectionNodeId: languageModelConnectionNodeId,
|
|
3634
|
+
parentAgentNodeId: ctx.nodeId,
|
|
3635
|
+
parentAgentActivationId: ctx.activationId,
|
|
3636
|
+
status: "running",
|
|
3637
|
+
managedInput: summarizedInput,
|
|
3638
|
+
queuedAt: startedAt.toISOString(),
|
|
3639
|
+
startedAt: startedAt.toISOString(),
|
|
3640
|
+
iterationId: ctx.iterationId,
|
|
3641
|
+
itemIndex: ctx.itemIndex,
|
|
3642
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3643
|
+
});
|
|
3538
3644
|
try {
|
|
3539
3645
|
const callOptions = this.resolveCallOptions(model, guardrails.modelInvocationOptions);
|
|
3540
3646
|
const outputSchema = structuredOptions?.strict && !this.isZodSchema(schema) ? Output.object({ schema: jsonSchema(schema) }) : Output.object({ schema });
|
|
@@ -3580,7 +3686,10 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3580
3686
|
managedOutput: this.resultToJsonValue(result.experimental_output),
|
|
3581
3687
|
queuedAt: startedAt.toISOString(),
|
|
3582
3688
|
startedAt: startedAt.toISOString(),
|
|
3583
|
-
finishedAt: finishedAt.toISOString()
|
|
3689
|
+
finishedAt: finishedAt.toISOString(),
|
|
3690
|
+
iterationId: ctx.iterationId,
|
|
3691
|
+
itemIndex: ctx.itemIndex,
|
|
3692
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3584
3693
|
});
|
|
3585
3694
|
return result.experimental_output;
|
|
3586
3695
|
} catch (error) {
|
|
@@ -3611,6 +3720,24 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3611
3720
|
providerOptions: overrides?.providerOptions ?? defaults.providerOptions
|
|
3612
3721
|
};
|
|
3613
3722
|
}
|
|
3723
|
+
/**
|
|
3724
|
+
* Build a no-code-friendly output payload for an LLM round.
|
|
3725
|
+
*
|
|
3726
|
+
* Always includes `content` (matching the canvas snapshot shape used elsewhere) and adds a
|
|
3727
|
+
* `toolCalls` array when the round produced tool calls so the execution inspector surfaces the
|
|
3728
|
+
* planned calls instead of just an empty `""` for tool-only rounds.
|
|
3729
|
+
*/
|
|
3730
|
+
summarizeTurnOutput(turnResult) {
|
|
3731
|
+
if (turnResult.toolCalls.length === 0) return { content: turnResult.text };
|
|
3732
|
+
const toolCalls = turnResult.toolCalls.map((toolCall) => ({
|
|
3733
|
+
name: toolCall.name,
|
|
3734
|
+
args: this.resultToJsonValue(toolCall.input) ?? null
|
|
3735
|
+
}));
|
|
3736
|
+
return {
|
|
3737
|
+
content: turnResult.text,
|
|
3738
|
+
toolCalls
|
|
3739
|
+
};
|
|
3740
|
+
}
|
|
3614
3741
|
extractTurnResult(result) {
|
|
3615
3742
|
const usage = this.extractUsageFromResult(result);
|
|
3616
3743
|
const text = result.text;
|
|
@@ -3654,7 +3781,10 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3654
3781
|
attributes: {
|
|
3655
3782
|
[CodemationTelemetryAttributeNames.connectionInvocationId]: invocationId,
|
|
3656
3783
|
[GenAiTelemetryAttributeNames.operationName]: "chat",
|
|
3657
|
-
[GenAiTelemetryAttributeNames.requestModel]: this.resolveChatModelName(ctx.config.chatModel)
|
|
3784
|
+
[GenAiTelemetryAttributeNames.requestModel]: this.resolveChatModelName(ctx.config.chatModel),
|
|
3785
|
+
...ctx.iterationId ? { [CodemationTelemetryAttributeNames.iterationId]: ctx.iterationId } : {},
|
|
3786
|
+
...typeof ctx.itemIndex === "number" ? { [CodemationTelemetryAttributeNames.iterationIndex]: ctx.itemIndex } : {},
|
|
3787
|
+
...ctx.parentInvocationId ? { [CodemationTelemetryAttributeNames.parentInvocationId]: ctx.parentInvocationId } : {}
|
|
3658
3788
|
}
|
|
3659
3789
|
});
|
|
3660
3790
|
}
|
|
@@ -3704,11 +3834,26 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3704
3834
|
return chatModel$1.modelName ?? chatModel$1.name;
|
|
3705
3835
|
}
|
|
3706
3836
|
async markQueuedTools(plannedToolCalls, ctx) {
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3837
|
+
const queuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3838
|
+
for (const plannedToolCall of plannedToolCalls) {
|
|
3839
|
+
await ctx.nodeState?.markQueued({
|
|
3840
|
+
nodeId: plannedToolCall.nodeId,
|
|
3841
|
+
activationId: ctx.activationId,
|
|
3842
|
+
inputsByPort: AgentToolCallPortMap.fromInput(plannedToolCall.toolCall.input ?? {})
|
|
3843
|
+
});
|
|
3844
|
+
await ctx.nodeState?.appendConnectionInvocation({
|
|
3845
|
+
invocationId: plannedToolCall.invocationId,
|
|
3846
|
+
connectionNodeId: plannedToolCall.nodeId,
|
|
3847
|
+
parentAgentNodeId: ctx.nodeId,
|
|
3848
|
+
parentAgentActivationId: ctx.activationId,
|
|
3849
|
+
status: "queued",
|
|
3850
|
+
managedInput: this.resultToJsonValue(plannedToolCall.toolCall.input),
|
|
3851
|
+
queuedAt,
|
|
3852
|
+
iterationId: ctx.iterationId,
|
|
3853
|
+
itemIndex: ctx.itemIndex,
|
|
3854
|
+
parentInvocationId: ctx.parentInvocationId
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3712
3857
|
}
|
|
3713
3858
|
planToolCalls(bindings, toolCalls, parentNodeId) {
|
|
3714
3859
|
const invocationCountByToolName = /* @__PURE__ */ new Map();
|
|
@@ -3721,7 +3866,8 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3721
3866
|
binding,
|
|
3722
3867
|
toolCall,
|
|
3723
3868
|
invocationIndex,
|
|
3724
|
-
nodeId: ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, binding.config.name)
|
|
3869
|
+
nodeId: ConnectionNodeIdFactory.toolConnectionNodeId(parentNodeId, binding.config.name),
|
|
3870
|
+
invocationId: ConnectionInvocationIdFactory.create()
|
|
3725
3871
|
};
|
|
3726
3872
|
});
|
|
3727
3873
|
}
|
|
@@ -3749,7 +3895,10 @@ let AIAgentNode = class AIAgentNode$1 {
|
|
|
3749
3895
|
},
|
|
3750
3896
|
queuedAt: args.startedAt.toISOString(),
|
|
3751
3897
|
startedAt: args.startedAt.toISOString(),
|
|
3752
|
-
finishedAt: finishedAt.toISOString()
|
|
3898
|
+
finishedAt: finishedAt.toISOString(),
|
|
3899
|
+
iterationId: args.ctx.iterationId,
|
|
3900
|
+
itemIndex: args.ctx.itemIndex,
|
|
3901
|
+
parentInvocationId: args.ctx.parentInvocationId
|
|
3753
3902
|
});
|
|
3754
3903
|
return effectiveError;
|
|
3755
3904
|
}
|
|
@@ -4022,6 +4171,7 @@ var HttpRequest = class {
|
|
|
4022
4171
|
kind = "node";
|
|
4023
4172
|
type = HttpRequestNode;
|
|
4024
4173
|
execution = { hint: "local" };
|
|
4174
|
+
icon = "lucide:globe";
|
|
4025
4175
|
constructor(name, args = {}, retryPolicy = RetryPolicy.defaultForHttp) {
|
|
4026
4176
|
this.name = name;
|
|
4027
4177
|
this.args = args;
|
|
@@ -4063,7 +4213,7 @@ var Aggregate = class {
|
|
|
4063
4213
|
type = AggregateNode;
|
|
4064
4214
|
execution = { hint: "local" };
|
|
4065
4215
|
keepBinaries = true;
|
|
4066
|
-
icon = "
|
|
4216
|
+
icon = "builtin:aggregate-rows";
|
|
4067
4217
|
constructor(name, aggregate, id) {
|
|
4068
4218
|
this.name = name;
|
|
4069
4219
|
this.aggregate = aggregate;
|
|
@@ -4158,7 +4308,7 @@ var If = class {
|
|
|
4158
4308
|
kind = "node";
|
|
4159
4309
|
type = IfNode;
|
|
4160
4310
|
execution = { hint: "local" };
|
|
4161
|
-
icon = "lucide:split";
|
|
4311
|
+
icon = "lucide:split@rot=90";
|
|
4162
4312
|
declaredOutputPorts = ["true", "false"];
|
|
4163
4313
|
constructor(name, predicate, id) {
|
|
4164
4314
|
this.name = name;
|
|
@@ -4223,7 +4373,7 @@ var Split = class {
|
|
|
4223
4373
|
* Mirrors {@link MapData}'s empty-output behavior.
|
|
4224
4374
|
*/
|
|
4225
4375
|
continueWhenEmptyOutput = true;
|
|
4226
|
-
icon = "
|
|
4376
|
+
icon = "builtin:split-rows";
|
|
4227
4377
|
constructor(name, getElements, id) {
|
|
4228
4378
|
this.name = name;
|
|
4229
4379
|
this.getElements = getElements;
|
|
@@ -4294,6 +4444,7 @@ var MapData = class {
|
|
|
4294
4444
|
execution = { hint: "local" };
|
|
4295
4445
|
/** Zero mapped items should still allow downstream nodes to run. */
|
|
4296
4446
|
continueWhenEmptyOutput = true;
|
|
4447
|
+
icon = "lucide:square-pen";
|
|
4297
4448
|
keepBinaries;
|
|
4298
4449
|
constructor(name, map, options = {}) {
|
|
4299
4450
|
this.name = name;
|
|
@@ -4363,7 +4514,7 @@ MergeNode = __decorate([node({ packageName: "@codemation/core-nodes" })], MergeN
|
|
|
4363
4514
|
var Merge = class {
|
|
4364
4515
|
kind = "node";
|
|
4365
4516
|
type = MergeNode;
|
|
4366
|
-
icon = "lucide:
|
|
4517
|
+
icon = "lucide:merge@rot=90";
|
|
4367
4518
|
constructor(name, cfg = { mode: "passThrough" }, id) {
|
|
4368
4519
|
this.name = name;
|
|
4369
4520
|
this.cfg = cfg;
|
|
@@ -4388,6 +4539,7 @@ var NoOp = class {
|
|
|
4388
4539
|
kind = "node";
|
|
4389
4540
|
type = NoOpNode;
|
|
4390
4541
|
execution = { hint: "local" };
|
|
4542
|
+
icon = "lucide:circle-dashed";
|
|
4391
4543
|
constructor(name = "NoOp", id) {
|
|
4392
4544
|
this.name = name;
|
|
4393
4545
|
this.id = id;
|
|
@@ -4493,6 +4645,7 @@ var Wait = class {
|
|
|
4493
4645
|
execution = { hint: "local" };
|
|
4494
4646
|
/** Pass-through empty batches should still advance to downstream nodes. */
|
|
4495
4647
|
continueWhenEmptyOutput = true;
|
|
4648
|
+
icon = "lucide:hourglass";
|
|
4496
4649
|
constructor(name, milliseconds, id) {
|
|
4497
4650
|
this.name = name;
|
|
4498
4651
|
this.milliseconds = milliseconds;
|
|
@@ -4543,7 +4696,7 @@ WebhookTriggerNode = __decorate([node({ packageName: "@codemation/core-nodes" })
|
|
|
4543
4696
|
var WebhookTrigger = class WebhookTrigger {
|
|
4544
4697
|
kind = "trigger";
|
|
4545
4698
|
type = WebhookTriggerNode;
|
|
4546
|
-
icon = "lucide:
|
|
4699
|
+
icon = "lucide:webhook";
|
|
4547
4700
|
constructor(name, args, handler = WebhookTrigger.defaultHandler, id) {
|
|
4548
4701
|
this.name = name;
|
|
4549
4702
|
this.args = args;
|