@q1k-oss/behaviour-tree-workflows 0.0.2 → 0.0.4

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 CHANGED
@@ -60,6 +60,7 @@ __export(index_exports, {
60
60
  Invert: () => Invert,
61
61
  KeepRunningUntilFailure: () => KeepRunningUntilFailure,
62
62
  LLMChat: () => LLMChat,
63
+ LLMToolCall: () => LLMToolCall,
63
64
  LogMessage: () => LogMessage,
64
65
  MemoryDataStore: () => MemoryDataStore,
65
66
  MemorySequence: () => MemorySequence,
@@ -86,14 +87,19 @@ __export(index_exports, {
86
87
  SemanticValidationError: () => SemanticValidationError,
87
88
  Sequence: () => Sequence,
88
89
  SequenceWithMemory: () => SequenceWithMemory,
90
+ SetVariable: () => SetVariable,
89
91
  SoftAssert: () => SoftAssert,
92
+ StreamingSink: () => StreamingSink,
90
93
  StructureValidationError: () => StructureValidationError,
91
94
  SubTree: () => SubTree,
92
95
  SuccessNode: () => SuccessNode,
93
96
  Timeout: () => Timeout,
97
+ ToolExecutor: () => ToolExecutor,
98
+ ToolRouter: () => ToolRouter,
94
99
  ValidationError: () => ValidationError,
95
100
  ValidationErrors: () => ValidationErrors,
96
101
  WaitAction: () => WaitAction,
102
+ WaitForSignal: () => WaitForSignal,
97
103
  While: () => While,
98
104
  YamlSyntaxError: () => YamlSyntaxError,
99
105
  clearPieceCache: () => clearPieceCache,
@@ -2354,6 +2360,52 @@ var SoftAssert = class extends DecoratorNode {
2354
2360
  }
2355
2361
  };
2356
2362
 
2363
+ // src/decorators/streaming-sink.ts
2364
+ var StreamingSink = class extends DecoratorNode {
2365
+ channelId;
2366
+ channelKey;
2367
+ constructor(config) {
2368
+ super(config);
2369
+ if (!config.channelId && !config.channelKey) {
2370
+ throw new ConfigurationError(
2371
+ "StreamingSink requires either channelId or channelKey"
2372
+ );
2373
+ }
2374
+ this.channelId = config.channelId;
2375
+ this.channelKey = config.channelKey;
2376
+ }
2377
+ async executeTick(context) {
2378
+ if (!this.child) {
2379
+ throw new ConfigurationError(
2380
+ `${this.name}: Decorator must have a child`
2381
+ );
2382
+ }
2383
+ let resolvedChannelId = this.channelId;
2384
+ if (this.channelKey) {
2385
+ const varCtx = {
2386
+ blackboard: context.blackboard,
2387
+ input: context.input,
2388
+ testData: context.testData
2389
+ };
2390
+ resolvedChannelId = resolveValue(this.channelKey, varCtx);
2391
+ }
2392
+ const previousValue = context.blackboard.get("__streamChannelId");
2393
+ context.blackboard.set("__streamChannelId", resolvedChannelId);
2394
+ this.log(`Set streaming channel: ${resolvedChannelId}`);
2395
+ try {
2396
+ const childStatus = await this.child.tick(context);
2397
+ this._status = childStatus;
2398
+ return childStatus;
2399
+ } finally {
2400
+ if (previousValue !== void 0) {
2401
+ context.blackboard.set("__streamChannelId", previousValue);
2402
+ } else {
2403
+ context.blackboard.delete("__streamChannelId");
2404
+ }
2405
+ }
2406
+ }
2407
+ };
2408
+
2357
2409
  // src/decorators/timeout.ts
2358
2410
  var import_workflow2 = require("@temporalio/workflow");
2359
2411
  var Timeout = class extends DecoratorNode {
@@ -2631,8 +2683,81 @@ var humanTaskSchema = createNodeSchema("HumanTask", {
2631
2683
  outputKey: import_zod5.z.string().optional()
2632
2684
  });
2633
2685
 
2634
- // src/schemas/validation.ts
2686
+ // src/utilities/set-variable.schema.ts
2635
2687
  var import_zod6 = require("zod");
2688
+ var setVariableSchema = createNodeSchema("SetVariable", {
2689
+ key: import_zod6.z.string().min(1, "key is required"),
2690
+ value: import_zod6.z.unknown()
2691
+ });
2692
+
2693
+ // src/actions/llm-tool-call.schema.ts
2694
+ var import_zod7 = require("zod");
2695
+ var toolDefinitionSchema = import_zod7.z.object({
2696
+ name: import_zod7.z.string().min(1),
2697
+ description: import_zod7.z.string().min(1),
2698
+ inputSchema: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown())
2699
+ });
2700
+ var llmToolCallSchema = createNodeSchema("LLMToolCall", {
2701
+ provider: import_zod7.z.enum(["anthropic", "openai", "google", "ollama"]),
2702
+ model: import_zod7.z.string().min(1, "Model is required"),
2703
+ systemPrompt: import_zod7.z.string().optional(),
2704
+ messagesKey: import_zod7.z.string().min(1, "messagesKey is required"),
2705
+ userMessageKey: import_zod7.z.string().optional(),
2706
+ toolsKey: import_zod7.z.string().optional(),
2707
+ tools: import_zod7.z.array(toolDefinitionSchema).optional(),
2708
+ temperature: import_zod7.z.number().min(0).max(2).optional(),
2709
+ maxTokens: import_zod7.z.number().int().positive().optional(),
2710
+ outputKey: import_zod7.z.string().min(1, "outputKey is required")
2711
+ });
2712
+
2713
+ // src/actions/tool-executor.schema.ts
2714
+ var import_zod8 = require("zod");
2715
+ var toolExecutorSchema = createNodeSchema("ToolExecutor", {
2716
+ responseKey: import_zod8.z.string().min(1, "responseKey is required"),
2717
+ messagesKey: import_zod8.z.string().min(1, "messagesKey is required"),
2718
+ outputKey: import_zod8.z.string().optional()
2719
+ });
2720
+
2721
+ // src/actions/wait-for-signal.schema.ts
2722
+ var import_zod9 = require("zod");
2723
+ var waitForSignalSchema = createNodeSchema("WaitForSignal", {
2724
+ signalName: import_zod9.z.string().min(1, "signalName is required"),
2725
+ signalKey: import_zod9.z.string().optional(),
2726
+ timeoutMs: import_zod9.z.number().int().positive().optional().default(864e5),
2727
+ outputKey: import_zod9.z.string().min(1, "outputKey is required")
2728
+ });
2729
+
2730
+ // src/actions/tool-router.schema.ts
2731
+ var import_zod10 = require("zod");
2732
+ var toolDefinitionSchema2 = import_zod10.z.object({
2733
+ name: import_zod10.z.string().min(1),
2734
+ description: import_zod10.z.string().min(1),
2735
+ inputSchema: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.unknown())
2736
+ });
2737
+ var ruleSchema = import_zod10.z.object({
2738
+ pattern: import_zod10.z.string().min(1),
2739
+ toolSets: import_zod10.z.array(import_zod10.z.string().min(1)).min(1)
2740
+ });
2741
+ var toolRouterSchema = createNodeSchema("ToolRouter", {
2742
+ intentKey: import_zod10.z.string().min(1, "intentKey is required"),
2743
+ toolSets: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.array(toolDefinitionSchema2)),
2744
+ defaultTools: import_zod10.z.array(import_zod10.z.string()).optional(),
2745
+ rules: import_zod10.z.array(ruleSchema).optional(),
2746
+ outputKey: import_zod10.z.string().min(1, "outputKey is required")
2747
+ });
2748
+
2749
+ // src/decorators/streaming-sink.schema.ts
2750
+ var import_zod11 = require("zod");
2751
+ var streamingSinkSchema = createNodeSchema("StreamingSink", {
2752
+ channelId: import_zod11.z.string().optional(),
2753
+ channelKey: import_zod11.z.string().optional()
2754
+ }).refine(
2755
+ (data) => data.channelId || data.channelKey,
2756
+ { message: "Either channelId or channelKey must be provided" }
2757
+ );
2758
+
2759
+ // src/schemas/validation.ts
2760
+ var import_zod12 = require("zod");
2636
2761
  function zodErrorToConfigurationError(error, nodeType, nodeId) {
2637
2762
  const nodeIdentifier = nodeId ? `${nodeType}:${nodeId}` : nodeType;
2638
2763
  const issues = error.issues.map((issue) => {
@@ -2648,7 +2773,7 @@ function validateConfiguration(schema, config, nodeType, nodeId) {
2648
2773
  try {
2649
2774
  return schema.parse(config);
2650
2775
  } catch (error) {
2651
- if (error instanceof import_zod6.z.ZodError) {
2776
+ if (error instanceof import_zod12.z.ZodError) {
2652
2777
  throw zodErrorToConfigurationError(error, nodeType, nodeId);
2653
2778
  }
2654
2779
  throw error;
@@ -2667,14 +2792,14 @@ function safeValidateConfiguration(schema, config, nodeType, nodeId) {
2667
2792
  }
2668
2793
 
2669
2794
  // src/schemas/tree-definition.schema.ts
2670
- var import_zod7 = require("zod");
2671
- var treeDefSchemaObject = import_zod7.z.object({
2672
- type: import_zod7.z.string().min(1, "Node type is required"),
2673
- id: import_zod7.z.string().optional(),
2674
- name: import_zod7.z.string().optional(),
2675
- props: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).optional(),
2676
- children: import_zod7.z.array(
2677
- import_zod7.z.lazy(() => treeDefinitionSchema)
2795
+ var import_zod13 = require("zod");
2796
+ var treeDefSchemaObject = import_zod13.z.object({
2797
+ type: import_zod13.z.string().min(1, "Node type is required"),
2798
+ id: import_zod13.z.string().optional(),
2799
+ name: import_zod13.z.string().optional(),
2800
+ props: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional(),
2801
+ children: import_zod13.z.array(
2802
+ import_zod13.z.lazy(() => treeDefinitionSchema)
2678
2803
  ).optional()
2679
2804
  });
2680
2805
  var treeDefinitionSchema = treeDefSchemaObject;
@@ -2756,6 +2881,12 @@ var SchemaRegistry = class {
2756
2881
  this.register("LLMChat", llmChatSchema);
2757
2882
  this.register("BrowserAgent", browserAgentSchema);
2758
2883
  this.register("HumanTask", humanTaskSchema);
2884
+ this.register("SetVariable", setVariableSchema);
2885
+ this.register("LLMToolCall", llmToolCallSchema);
2886
+ this.register("ToolExecutor", toolExecutorSchema);
2887
+ this.register("WaitForSignal", waitForSignalSchema);
2888
+ this.register("ToolRouter", toolRouterSchema);
2889
+ this.register("StreamingSink", streamingSinkSchema);
2759
2890
  }
2760
2891
  /**
2761
2892
  * Register a validation schema for a node type
@@ -3225,8 +3356,32 @@ var CheckCondition = class extends ConditionNode {
3225
3356
  this.operator = config.operator || "==";
3226
3357
  this.value = config.value;
3227
3358
  }
3359
+ /**
3360
+ * Resolve a potentially dotted key from the blackboard.
3361
+ * Tries exact key first (backward compatible), then dotted path traversal.
3362
+ */
3363
+ resolveBlackboardValue(context) {
3364
+ const exact = context.blackboard.get(this.key);
3365
+ if (exact !== void 0) {
3366
+ return exact;
3367
+ }
3368
+ if (this.key.includes(".")) {
3369
+ const segments = this.key.split(".");
3370
+ const rootKey = segments[0];
3371
+ let current = context.blackboard.get(rootKey);
3372
+ for (let i = 1; i < segments.length; i++) {
3373
+ if (current == null || typeof current !== "object") {
3374
+ return void 0;
3375
+ }
3376
+ const segment = segments[i];
3377
+ current = current[segment];
3378
+ }
3379
+ return current;
3380
+ }
3381
+ return void 0;
3382
+ }
3228
3383
  async executeTick(context) {
3229
- const actualValue = context.blackboard.get(this.key);
3384
+ const actualValue = this.resolveBlackboardValue(context);
3230
3385
  let result = false;
3231
3386
  switch (this.operator) {
3232
3387
  case "==":
@@ -3418,6 +3573,35 @@ var RegexExtract = class extends ActionNode {
3418
3573
  }
3419
3574
  };
3420
3575
 
3576
+ // src/utilities/set-variable.ts
3577
+ var SetVariable = class extends ActionNode {
3578
+ key;
3579
+ value;
3580
+ constructor(config) {
3581
+ super(config);
3582
+ this.key = config.key;
3583
+ this.value = config.value;
3584
+ }
3585
+ async executeTick(context) {
3586
+ try {
3587
+ const varCtx = {
3588
+ blackboard: context.blackboard,
3589
+ input: context.input,
3590
+ testData: context.testData
3591
+ };
3592
+ const resolvedKey = typeof this.key === "string" ? resolveValue(this.key, varCtx) : String(this.key);
3593
+ const resolvedValue = typeof this.value === "string" ? resolveValue(this.value, varCtx) : this.value;
3594
+ context.blackboard.set(resolvedKey, resolvedValue);
3595
+ this.log(`Set ${resolvedKey} = ${JSON.stringify(resolvedValue)}`);
3596
+ return "SUCCESS" /* SUCCESS */;
3597
+ } catch (error) {
3598
+ this._lastError = error instanceof Error ? error.message : String(error);
3599
+ this.log(`SetVariable failed: ${this._lastError}`);
3600
+ return "FAILURE" /* FAILURE */;
3601
+ }
3602
+ }
3603
+ };
3604
+
3421
3605
  // src/integrations/piece-executor.ts
3422
3606
  var PROVIDER_TO_PIECE = {
3423
3607
  // Google services
@@ -3467,7 +3651,8 @@ var PIECE_EXPORT_NAMES = {
3467
3651
  "@activepieces/piece-discord": "discord",
3468
3652
  "@activepieces/piece-notion": "notion",
3469
3653
  "@activepieces/piece-github": "github",
3470
- "@activepieces/piece-http": "http"
3654
+ "@activepieces/piece-http": "http",
3655
+ "@activepieces/piece-shopify": "shopify"
3471
3656
  };
3472
3657
  async function loadPiece(packageName) {
3473
3658
  if (pieceCache.has(packageName)) {
@@ -4584,6 +4769,313 @@ function setNestedPath(obj, path2, value) {
4584
4769
  }
4585
4770
  }
4586
4771
 
4772
+ // src/actions/llm-tool-call.ts
4773
+ var LLMToolCall = class extends ActionNode {
4774
+ provider;
4775
+ model;
4776
+ systemPrompt;
4777
+ messagesKey;
4778
+ userMessageKey;
4779
+ toolsKey;
4780
+ tools;
4781
+ temperature;
4782
+ maxTokens;
4783
+ outputKey;
4784
+ constructor(config) {
4785
+ super(config);
4786
+ if (!config.provider) {
4787
+ throw new ConfigurationError("LLMToolCall requires provider");
4788
+ }
4789
+ if (!config.model) {
4790
+ throw new ConfigurationError("LLMToolCall requires model");
4791
+ }
4792
+ if (!config.messagesKey) {
4793
+ throw new ConfigurationError("LLMToolCall requires messagesKey");
4794
+ }
4795
+ if (!config.outputKey) {
4796
+ throw new ConfigurationError("LLMToolCall requires outputKey");
4797
+ }
4798
+ this.provider = config.provider;
4799
+ this.model = config.model;
4800
+ this.systemPrompt = config.systemPrompt;
4801
+ this.messagesKey = config.messagesKey;
4802
+ this.userMessageKey = config.userMessageKey;
4803
+ this.toolsKey = config.toolsKey;
4804
+ this.tools = config.tools;
4805
+ this.temperature = config.temperature;
4806
+ this.maxTokens = config.maxTokens;
4807
+ this.outputKey = config.outputKey;
4808
+ }
4809
+ async executeTick(context) {
4810
+ if (!context.activities?.agentLoopTurn) {
4811
+ this._lastError = "LLMToolCall requires activities.agentLoopTurn to be configured.";
4812
+ this.log(`Error: ${this._lastError}`);
4813
+ return "FAILURE" /* FAILURE */;
4814
+ }
4815
+ try {
4816
+ const varCtx = {
4817
+ blackboard: context.blackboard,
4818
+ input: context.input,
4819
+ testData: context.testData
4820
+ };
4821
+ let messages = context.blackboard.get(this.messagesKey) || [];
4822
+ if (this.userMessageKey) {
4823
+ const userMsg = context.blackboard.get(this.userMessageKey);
4824
+ if (userMsg !== void 0 && userMsg !== null) {
4825
+ const content = typeof userMsg === "string" ? userMsg : String(userMsg);
4826
+ messages = [...messages, { role: "user", content }];
4827
+ context.blackboard.set(this.userMessageKey, null);
4828
+ }
4829
+ }
4830
+ const tools = this.toolsKey ? context.blackboard.get(this.toolsKey) || [] : this.tools || [];
4831
+ const resolvedModel = resolveValue(this.model, varCtx);
4832
+ const resolvedSystemPrompt = this.systemPrompt ? resolveValue(this.systemPrompt, varCtx) : void 0;
4833
+ const streamChannelId = context.blackboard.get("__streamChannelId");
4834
+ const request = {
4835
+ provider: this.provider,
4836
+ model: resolvedModel,
4837
+ systemPrompt: resolvedSystemPrompt,
4838
+ messages,
4839
+ tools: tools.length > 0 ? tools : void 0,
4840
+ temperature: this.temperature,
4841
+ maxTokens: this.maxTokens,
4842
+ streamChannelId: streamChannelId || void 0
4843
+ };
4844
+ this.log(
4845
+ `LLMToolCall ${this.provider}/${resolvedModel} - ${messages.length} messages, ${tools.length} tools`
4846
+ );
4847
+ const result = await context.activities.agentLoopTurn(request);
4848
+ if (result.toolCalls && result.toolCalls.length > 0) {
4849
+ const contentBlocks = [];
4850
+ if (result.content) {
4851
+ contentBlocks.push({ type: "text", text: result.content });
4852
+ }
4853
+ for (const tc of result.toolCalls) {
4854
+ contentBlocks.push({
4855
+ type: "tool_use",
4856
+ id: tc.id,
4857
+ name: tc.name,
4858
+ input: tc.input
4859
+ });
4860
+ }
4861
+ messages = [...messages, { role: "assistant", content: contentBlocks }];
4862
+ } else {
4863
+ messages = [...messages, { role: "assistant", content: result.content }];
4864
+ }
4865
+ context.blackboard.set(this.messagesKey, messages);
4866
+ context.blackboard.set(this.outputKey, {
4867
+ content: result.content,
4868
+ toolCalls: result.toolCalls,
4869
+ stopReason: result.stopReason,
4870
+ usage: result.usage
4871
+ });
4872
+ this.log(
4873
+ `LLMToolCall completed: stopReason=${result.stopReason}, tools=${result.toolCalls?.length || 0}, tokens=${result.usage.totalTokens}`
4874
+ );
4875
+ return "SUCCESS" /* SUCCESS */;
4876
+ } catch (error) {
4877
+ this._lastError = error instanceof Error ? error.message : String(error);
4878
+ this.log(`LLMToolCall failed: ${this._lastError}`);
4879
+ return "FAILURE" /* FAILURE */;
4880
+ }
4881
+ }
4882
+ };
4883
+
4884
+ // src/actions/tool-executor.ts
4885
+ var ToolExecutor = class extends ActionNode {
4886
+ responseKey;
4887
+ messagesKey;
4888
+ outputKey;
4889
+ constructor(config) {
4890
+ super(config);
4891
+ if (!config.responseKey) {
4892
+ throw new ConfigurationError("ToolExecutor requires responseKey");
4893
+ }
4894
+ if (!config.messagesKey) {
4895
+ throw new ConfigurationError("ToolExecutor requires messagesKey");
4896
+ }
4897
+ this.responseKey = config.responseKey;
4898
+ this.messagesKey = config.messagesKey;
4899
+ this.outputKey = config.outputKey;
4900
+ }
4901
+ async executeTick(context) {
4902
+ if (!context.activities?.executeAgentTool) {
4903
+ this._lastError = "ToolExecutor requires activities.executeAgentTool to be configured.";
4904
+ this.log(`Error: ${this._lastError}`);
4905
+ return "FAILURE" /* FAILURE */;
4906
+ }
4907
+ try {
4908
+ const response = context.blackboard.get(this.responseKey);
4909
+ const toolCalls = response?.toolCalls;
4910
+ if (!toolCalls || toolCalls.length === 0) {
4911
+ this.log("No tool calls to execute");
4912
+ return "SUCCESS" /* SUCCESS */;
4913
+ }
4914
+ const toolResults = [];
4915
+ for (const tc of toolCalls) {
4916
+ this.log(`Executing tool: ${tc.name} (${tc.id})`);
4917
+ const result = await context.activities.executeAgentTool({
4918
+ toolName: tc.name,
4919
+ toolInput: tc.input
4920
+ });
4921
+ toolResults.push({
4922
+ toolUseId: tc.id,
4923
+ toolName: tc.name,
4924
+ content: result.content,
4925
+ isError: result.isError
4926
+ });
4927
+ this.log(
4928
+ `Tool ${tc.name} ${result.isError ? "errored" : "completed"}: ${result.content.substring(0, 100)}`
4929
+ );
4930
+ }
4931
+ const resultBlocks = toolResults.map((tr) => ({
4932
+ type: "tool_result",
4933
+ tool_use_id: tr.toolUseId,
4934
+ content: tr.content,
4935
+ is_error: tr.isError
4936
+ }));
4937
+ const messages = context.blackboard.get(this.messagesKey) || [];
4938
+ const updatedMessages = [
4939
+ ...messages,
4940
+ { role: "user", content: resultBlocks }
4941
+ ];
4942
+ context.blackboard.set(this.messagesKey, updatedMessages);
4943
+ if (this.outputKey) {
4944
+ context.blackboard.set(this.outputKey, toolResults);
4945
+ }
4946
+ this.log(`Executed ${toolResults.length} tool(s), results appended to conversation`);
4947
+ return "SUCCESS" /* SUCCESS */;
4948
+ } catch (error) {
4949
+ this._lastError = error instanceof Error ? error.message : String(error);
4950
+ this.log(`ToolExecutor failed: ${this._lastError}`);
4951
+ return "FAILURE" /* FAILURE */;
4952
+ }
4953
+ }
4954
+ };
4955
+
4956
+ // src/actions/wait-for-signal.ts
4957
+ var WaitForSignal = class extends ActionNode {
4958
+ signalName;
4959
+ signalKey;
4960
+ timeoutMs;
4961
+ outputKey;
4962
+ constructor(config) {
4963
+ super(config);
4964
+ if (!config.signalName) {
4965
+ throw new ConfigurationError("WaitForSignal requires signalName");
4966
+ }
4967
+ if (!config.outputKey) {
4968
+ throw new ConfigurationError("WaitForSignal requires outputKey");
4969
+ }
4970
+ this.signalName = config.signalName;
4971
+ this.signalKey = config.signalKey;
4972
+ this.timeoutMs = config.timeoutMs ?? 864e5;
4973
+ this.outputKey = config.outputKey;
4974
+ }
4975
+ async executeTick(context) {
4976
+ if (!context.activities?.waitForSignal) {
4977
+ this._lastError = "WaitForSignal requires activities.waitForSignal to be configured. This is implemented as a Temporal condition in the workflow layer.";
4978
+ this.log(`Error: ${this._lastError}`);
4979
+ return "FAILURE" /* FAILURE */;
4980
+ }
4981
+ try {
4982
+ const varCtx = {
4983
+ blackboard: context.blackboard,
4984
+ input: context.input,
4985
+ testData: context.testData
4986
+ };
4987
+ const resolvedSignalKey = this.signalKey ? resolveValue(this.signalKey, varCtx) : void 0;
4988
+ this.log(
4989
+ `Waiting for signal "${this.signalName}"${resolvedSignalKey ? `:${resolvedSignalKey}` : ""} (timeout: ${this.timeoutMs}ms)`
4990
+ );
4991
+ const result = await context.activities.waitForSignal({
4992
+ signalName: this.signalName,
4993
+ signalKey: resolvedSignalKey,
4994
+ timeoutMs: this.timeoutMs
4995
+ });
4996
+ if (result.timedOut) {
4997
+ this._lastError = `Signal "${this.signalName}" timed out after ${this.timeoutMs}ms`;
4998
+ this.log(this._lastError);
4999
+ return "FAILURE" /* FAILURE */;
5000
+ }
5001
+ context.blackboard.set(this.outputKey, result.data);
5002
+ this.log(`Signal received, data stored at "${this.outputKey}"`);
5003
+ return "SUCCESS" /* SUCCESS */;
5004
+ } catch (error) {
5005
+ this._lastError = error instanceof Error ? error.message : String(error);
5006
+ this.log(`WaitForSignal failed: ${this._lastError}`);
5007
+ return "FAILURE" /* FAILURE */;
5008
+ }
5009
+ }
5010
+ };
5011
+
5012
+ // src/actions/tool-router.ts
5013
+ var ToolRouter = class extends ActionNode {
5014
+ intentKey;
5015
+ toolSets;
5016
+ defaultTools;
5017
+ rules;
5018
+ outputKey;
5019
+ constructor(config) {
5020
+ super(config);
5021
+ if (!config.intentKey) {
5022
+ throw new ConfigurationError("ToolRouter requires intentKey");
5023
+ }
5024
+ if (!config.toolSets || Object.keys(config.toolSets).length === 0) {
5025
+ throw new ConfigurationError("ToolRouter requires at least one toolSet");
5026
+ }
5027
+ if (!config.outputKey) {
5028
+ throw new ConfigurationError("ToolRouter requires outputKey");
5029
+ }
5030
+ this.intentKey = config.intentKey;
5031
+ this.toolSets = config.toolSets;
5032
+ this.defaultTools = config.defaultTools || [];
5033
+ this.rules = config.rules || [];
5034
+ this.outputKey = config.outputKey;
5035
+ }
5036
+ async executeTick(context) {
5037
+ try {
5038
+ const varCtx = {
5039
+ blackboard: context.blackboard,
5040
+ input: context.input,
5041
+ testData: context.testData
5042
+ };
5043
+ const intentRaw = context.blackboard.get(this.intentKey);
5044
+ const intent = typeof intentRaw === "string" ? intentRaw : "";
5045
+ const selectedSetNames = new Set(this.defaultTools);
5046
+ for (const rule of this.rules) {
5047
+ const regex = new RegExp(rule.pattern, "i");
5048
+ if (regex.test(intent)) {
5049
+ for (const setName of rule.toolSets) {
5050
+ selectedSetNames.add(setName);
5051
+ }
5052
+ }
5053
+ }
5054
+ const toolsByName = /* @__PURE__ */ new Map();
5055
+ for (const setName of selectedSetNames) {
5056
+ const tools = this.toolSets[setName];
5057
+ if (tools) {
5058
+ for (const tool of tools) {
5059
+ if (!toolsByName.has(tool.name)) {
5060
+ toolsByName.set(tool.name, tool);
5061
+ }
5062
+ }
5063
+ }
5064
+ }
5065
+ const selectedTools = Array.from(toolsByName.values());
5066
+ context.blackboard.set(this.outputKey, selectedTools);
5067
+ this.log(
5068
+ `Selected ${selectedTools.length} tools from sets [${Array.from(selectedSetNames).join(", ")}] for intent "${intent.substring(0, 50)}"`
5069
+ );
5070
+ return "SUCCESS" /* SUCCESS */;
5071
+ } catch (error) {
5072
+ this._lastError = error instanceof Error ? error.message : String(error);
5073
+ this.log(`ToolRouter failed: ${this._lastError}`);
5074
+ return "FAILURE" /* FAILURE */;
5075
+ }
5076
+ }
5077
+ };
5078
+
4587
5079
  // src/registry-utils.ts
4588
5080
  function registerStandardNodes(registry) {
4589
5081
  registry.register("Sequence", Sequence, { category: "composite" });
@@ -4637,6 +5129,7 @@ function registerStandardNodes(registry) {
4637
5129
  registry.register("WaitAction", WaitAction, { category: "action" });
4638
5130
  registry.register("LogMessage", LogMessage, { category: "action" });
4639
5131
  registry.register("RegexExtract", RegexExtract, { category: "action" });
5132
+ registry.register("SetVariable", SetVariable, { category: "action" });
4640
5133
  registry.register("IntegrationAction", IntegrationAction, { category: "action" });
4641
5134
  registry.register("PythonScript", PythonScript, { category: "action" });
4642
5135
  registry.register("ParseFile", ParseFile, { category: "action" });
@@ -4648,6 +5141,11 @@ function registerStandardNodes(registry) {
4648
5141
  registry.register("ClaudeAgent", ClaudeAgent, { category: "action" });
4649
5142
  registry.register("GitHubAction", GitHubAction, { category: "action" });
4650
5143
  registry.register("HumanTask", HumanTask, { category: "action" });
5144
+ registry.register("LLMToolCall", LLMToolCall, { category: "action" });
5145
+ registry.register("ToolExecutor", ToolExecutor, { category: "action" });
5146
+ registry.register("WaitForSignal", WaitForSignal, { category: "action" });
5147
+ registry.register("ToolRouter", ToolRouter, { category: "action" });
5148
+ registry.register("StreamingSink", StreamingSink, { category: "decorator" });
4651
5149
  }
4652
5150
 
4653
5151
  // src/data-store/memory-store.ts
@@ -5511,6 +6009,7 @@ function createObservabilitySinkHandler(config = {}) {
5511
6009
  Invert,
5512
6010
  KeepRunningUntilFailure,
5513
6011
  LLMChat,
6012
+ LLMToolCall,
5514
6013
  LogMessage,
5515
6014
  MemoryDataStore,
5516
6015
  MemorySequence,
@@ -5537,14 +6036,19 @@ function createObservabilitySinkHandler(config = {}) {
5537
6036
  SemanticValidationError,
5538
6037
  Sequence,
5539
6038
  SequenceWithMemory,
6039
+ SetVariable,
5540
6040
  SoftAssert,
6041
+ StreamingSink,
5541
6042
  StructureValidationError,
5542
6043
  SubTree,
5543
6044
  SuccessNode,
5544
6045
  Timeout,
6046
+ ToolExecutor,
6047
+ ToolRouter,
5545
6048
  ValidationError,
5546
6049
  ValidationErrors,
5547
6050
  WaitAction,
6051
+ WaitForSignal,
5548
6052
  While,
5549
6053
  YamlSyntaxError,
5550
6054
  clearPieceCache,