@ai-setting/roy-agent-core 1.4.13 → 1.4.15

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.
Files changed (102) hide show
  1. package/dist/config/index.js +32 -0
  2. package/dist/env/agent/index.js +24 -0
  3. package/dist/env/commands/index.js +14 -0
  4. package/dist/env/debug/formatters/index.js +11 -0
  5. package/dist/env/debug/index.js +26 -0
  6. package/dist/env/hook/index.js +29 -0
  7. package/dist/env/index.js +81 -0
  8. package/dist/env/llm/index.js +40 -0
  9. package/dist/env/log-trace/index.js +83 -0
  10. package/dist/env/mcp/index.js +39 -0
  11. package/dist/env/mcp/tool/index.js +14 -0
  12. package/dist/env/memory/built-in/index.js +11 -0
  13. package/dist/env/memory/index.js +56 -0
  14. package/dist/env/memory/plugin/index.js +36 -0
  15. package/dist/env/prompt/index.js +20 -0
  16. package/dist/env/session/index.js +25 -0
  17. package/dist/env/session/storage/index.js +18 -0
  18. package/dist/env/skill/index.js +34 -0
  19. package/dist/env/skill/tool/index.js +9 -0
  20. package/dist/env/task/delegate/index.js +18 -0
  21. package/dist/env/task/hooks/index.js +7 -0
  22. package/dist/env/task/index.js +30 -0
  23. package/dist/env/task/plugins/index.js +23 -0
  24. package/dist/env/task/storage/index.js +14 -0
  25. package/dist/env/task/tools/index.js +17 -0
  26. package/dist/env/task/tools/operation/index.js +15 -0
  27. package/dist/{shared/chunk-1d4rwms4.js → env/tool/built-in/index.js} +4 -4
  28. package/dist/env/tool/index.js +39 -0
  29. package/dist/env/workflow/decorators/index.js +27 -0
  30. package/dist/env/workflow/engine/index.js +28 -0
  31. package/dist/env/workflow/index.js +132 -0
  32. package/dist/env/workflow/nodes/index.js +19 -0
  33. package/dist/env/workflow/service/index.js +13 -0
  34. package/dist/env/workflow/storage/index.js +27 -0
  35. package/dist/env/workflow/tools/index.js +159 -0
  36. package/dist/env/workflow/types/index.js +94 -0
  37. package/dist/env/workflow/utils/index.js +637 -0
  38. package/dist/index.js +233 -16386
  39. package/dist/shared/{chunk-2b5kbhx3.js → @ai-setting/roy-agent-core-0rtxwr28.js} +6 -114
  40. package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +36 -0
  41. package/dist/shared/@ai-setting/roy-agent-core-12zkpda2.js +393 -0
  42. package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +117 -0
  43. package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +11 -0
  44. package/dist/shared/@ai-setting/roy-agent-core-2kg2wma8.js +620 -0
  45. package/dist/shared/@ai-setting/roy-agent-core-2x0m2p66.js +851 -0
  46. package/dist/shared/@ai-setting/roy-agent-core-35x0wrtt.js +172 -0
  47. package/dist/shared/{chunk-1pf5mfgd.js → @ai-setting/roy-agent-core-37e4tep3.js} +2 -2
  48. package/dist/shared/@ai-setting/roy-agent-core-3agad0d9.js +603 -0
  49. package/dist/shared/@ai-setting/roy-agent-core-4arba14a.js +419 -0
  50. package/dist/shared/@ai-setting/roy-agent-core-4rqmfr7t.js +266 -0
  51. package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +206 -0
  52. package/dist/shared/@ai-setting/roy-agent-core-561b1c4p.js +377 -0
  53. package/dist/shared/@ai-setting/roy-agent-core-5xf65pz6.js +1305 -0
  54. package/dist/shared/@ai-setting/roy-agent-core-6a72jfdy.js +303 -0
  55. package/dist/shared/{chunk-1aakcfp1.js → @ai-setting/roy-agent-core-7f303ffd.js} +3 -3
  56. package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +284 -0
  57. package/dist/shared/{chunk-t1rh6jtm.js → @ai-setting/roy-agent-core-7n436rb4.js} +7 -12
  58. package/dist/shared/@ai-setting/roy-agent-core-7r85t0qn.js +492 -0
  59. package/dist/shared/@ai-setting/roy-agent-core-7rewcey6.js +862 -0
  60. package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +14 -0
  61. package/dist/shared/@ai-setting/roy-agent-core-9qwp5qkz.js +1387 -0
  62. package/dist/shared/{chunk-mf5xqbdh.js → @ai-setting/roy-agent-core-9yxb3ty9.js} +3 -2
  63. package/dist/shared/@ai-setting/roy-agent-core-anwsxdds.js +1205 -0
  64. package/dist/shared/{chunk-1qwabsm0.js → @ai-setting/roy-agent-core-bncgx3gb.js} +1 -1
  65. package/dist/shared/@ai-setting/roy-agent-core-cd00w5mb.js +762 -0
  66. package/dist/shared/@ai-setting/roy-agent-core-cgs0j60t.js +442 -0
  67. package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +93 -0
  68. package/dist/shared/@ai-setting/roy-agent-core-dbsk841j.js +286 -0
  69. package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +64 -0
  70. package/dist/shared/{chunk-yqmx37vm.js → @ai-setting/roy-agent-core-e5jcp24a.js} +2 -2
  71. package/dist/shared/@ai-setting/roy-agent-core-e62e2a5a.js +204 -0
  72. package/dist/shared/{chunk-g6j5n3gv.js → @ai-setting/roy-agent-core-ewrj1c4k.js} +2 -2
  73. package/dist/shared/{chunk-rncy3rtd.js → @ai-setting/roy-agent-core-fdb6m4e4.js} +119 -1113
  74. package/dist/shared/{chunk-q9j99fsm.js → @ai-setting/roy-agent-core-fv32jaa8.js} +3 -3
  75. package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +171 -0
  76. package/dist/shared/@ai-setting/roy-agent-core-gmnkza34.js +202 -0
  77. package/dist/shared/@ai-setting/roy-agent-core-hz7rr4yx.js +513 -0
  78. package/dist/shared/@ai-setting/roy-agent-core-j3bbr2n0.js +378 -0
  79. package/dist/shared/{chunk-a9qmy3sc.js → @ai-setting/roy-agent-core-j3wc4465.js} +6 -3
  80. package/dist/shared/@ai-setting/roy-agent-core-jj79gszx.js +1130 -0
  81. package/dist/shared/@ai-setting/roy-agent-core-mwwk6req.js +913 -0
  82. package/dist/shared/{chunk-0q6s9wm6.js → @ai-setting/roy-agent-core-pc9g3962.js} +6 -50
  83. package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +60 -0
  84. package/dist/shared/@ai-setting/roy-agent-core-pzsg9pvf.js +393 -0
  85. package/dist/shared/{chunk-91bas8w5.js → @ai-setting/roy-agent-core-q779wnwm.js} +5 -5
  86. package/dist/shared/{chunk-25x2pdtp.js → @ai-setting/roy-agent-core-qw0ebh1d.js} +1 -1
  87. package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +57 -0
  88. package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +66 -0
  89. package/dist/shared/@ai-setting/roy-agent-core-qya7seh6.js +408 -0
  90. package/dist/shared/@ai-setting/roy-agent-core-rbetrphj.js +97 -0
  91. package/dist/shared/@ai-setting/roy-agent-core-re1wjfw7.js +587 -0
  92. package/dist/shared/@ai-setting/roy-agent-core-rft3fmp0.js +14 -0
  93. package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +584 -0
  94. package/dist/shared/{chunk-ze20rksg.js → @ai-setting/roy-agent-core-rvxg1wps.js} +1 -1
  95. package/dist/shared/@ai-setting/roy-agent-core-rzp9kxne.js +341 -0
  96. package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +213 -0
  97. package/dist/shared/@ai-setting/roy-agent-core-w78syn7w.js +788 -0
  98. package/dist/shared/{chunk-9qzt1v1p.js → @ai-setting/roy-agent-core-z2t8hse8.js} +3 -2
  99. package/package.json +8 -7
  100. package/dist/index.d.ts +0 -7825
  101. package/dist/shared/chunk-hs7tbmje.js +0 -24
  102. /package/dist/shared/{chunk-wbkh7wat.js → @ai-setting/roy-agent-core-fs0mn2jk.js} +0 -0
@@ -1,26 +1,39 @@
1
1
  import {
2
2
  AgentComponentAdapter,
3
+ init_agent_component_adapter
4
+ } from "./roy-agent-core-pc9g3962.js";
5
+ import {
6
+ SkillNode,
7
+ ToolNode,
8
+ WorkflowNode,
9
+ init_skill_node,
10
+ init_tool_node,
11
+ init_workflow_node
12
+ } from "./roy-agent-core-3agad0d9.js";
13
+ import {
14
+ createWorkflowEvent,
15
+ init_event,
16
+ init_types
17
+ } from "./roy-agent-core-rzp9kxne.js";
18
+ import {
3
19
  AskUserError,
4
20
  createNodeInterruptEvent,
5
- init_agent_component_adapter,
6
21
  init_workflow_hil
7
- } from "./chunk-0q6s9wm6.js";
22
+ } from "./roy-agent-core-e25xkv53.js";
8
23
  import {
9
- createLogger,
10
- getMaxOutput,
11
- init_logger,
12
- simplifyFilePath
13
- } from "./chunk-a9qmy3sc.js";
24
+ TracedAs,
25
+ init_decorator
26
+ } from "./roy-agent-core-35x0wrtt.js";
14
27
  import {
15
- getTracerProvider,
16
- init_tracer_provider
17
- } from "./chunk-q9j99fsm.js";
28
+ createLogger,
29
+ init_logger
30
+ } from "./roy-agent-core-j3wc4465.js";
18
31
  import {
19
32
  __esm,
20
33
  __export,
21
34
  __legacyDecorateClassTS,
22
35
  __require
23
- } from "./chunk-wbkh7wat.js";
36
+ } from "./roy-agent-core-fs0mn2jk.js";
24
37
 
25
38
  // src/env/workflow/engine/event-bus.ts
26
39
  class EventBus {
@@ -606,415 +619,6 @@ class Scheduler {
606
619
  }
607
620
  var init_scheduler = () => {};
608
621
 
609
- // src/env/workflow/types/event.ts
610
- import { z } from "zod";
611
- function createWorkflowEvent(type, runId, data) {
612
- return {
613
- type,
614
- run_id: runId,
615
- timestamp: Date.now(),
616
- ...data
617
- };
618
- }
619
- var BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema;
620
- var init_event = __esm(() => {
621
- BaseEventSchema = z.object({
622
- type: z.string(),
623
- run_id: z.string(),
624
- timestamp: z.number()
625
- });
626
- WorkflowStartedEventSchema = BaseEventSchema.extend({
627
- type: z.literal("workflow.started"),
628
- workflow_name: z.string(),
629
- input: z.record(z.string(), z.unknown()).optional()
630
- });
631
- WorkflowPausedEventSchema = BaseEventSchema.extend({
632
- type: z.literal("workflow.paused")
633
- });
634
- WorkflowResumedEventSchema = BaseEventSchema.extend({
635
- type: z.literal("workflow.resumed")
636
- });
637
- WorkflowStoppedEventSchema = BaseEventSchema.extend({
638
- type: z.literal("workflow.stopped"),
639
- reason: z.string()
640
- });
641
- WorkflowCompletedEventSchema = BaseEventSchema.extend({
642
- type: z.literal("workflow.completed"),
643
- result: z.record(z.string(), z.unknown()).optional(),
644
- duration_ms: z.number()
645
- });
646
- WorkflowFailedEventSchema = BaseEventSchema.extend({
647
- type: z.literal("workflow.failed"),
648
- error: z.object({
649
- message: z.string(),
650
- stack: z.string().optional()
651
- }),
652
- failed_at: z.string()
653
- });
654
- WorkflowOutputEventSchema = BaseEventSchema.extend({
655
- type: z.literal("workflow.output"),
656
- output: z.record(z.string(), z.unknown())
657
- });
658
- NodeScheduledEventSchema = BaseEventSchema.extend({
659
- type: z.literal("node.scheduled"),
660
- node_id: z.string()
661
- });
662
- NodeStartedEventSchema = BaseEventSchema.extend({
663
- type: z.literal("node.started"),
664
- node_id: z.string(),
665
- input: z.any(),
666
- agentSessionId: z.string().optional(),
667
- userResponse: z.string().optional()
668
- });
669
- NodeProgressEventSchema = BaseEventSchema.extend({
670
- type: z.literal("node.progress"),
671
- node_id: z.string(),
672
- progress: z.number(),
673
- message: z.string().optional()
674
- });
675
- NodeCompletedEventSchema = BaseEventSchema.extend({
676
- type: z.literal("node.completed"),
677
- node_id: z.string(),
678
- output: z.any(),
679
- duration_ms: z.number()
680
- });
681
- NodeFailedEventSchema = BaseEventSchema.extend({
682
- type: z.literal("node.failed"),
683
- node_id: z.string(),
684
- error: z.object({
685
- message: z.string(),
686
- stack: z.string().optional()
687
- })
688
- });
689
- NodeSkippedEventSchema = BaseEventSchema.extend({
690
- type: z.literal("node.skipped"),
691
- node_id: z.string(),
692
- reason: z.string()
693
- });
694
- NodeDataEventSchema = BaseEventSchema.extend({
695
- type: z.literal("node.data"),
696
- from_node: z.string(),
697
- to_node: z.string(),
698
- data: z.any()
699
- });
700
- NodeAddedEventSchema = BaseEventSchema.extend({
701
- type: z.literal("node.added"),
702
- node_id: z.string(),
703
- node: z.any()
704
- });
705
- NodeRemovedEventSchema = BaseEventSchema.extend({
706
- type: z.literal("node.removed"),
707
- node_id: z.string()
708
- });
709
- ControlPauseEventSchema = BaseEventSchema.extend({
710
- type: z.literal("control.pause")
711
- });
712
- ControlResumeEventSchema = BaseEventSchema.extend({
713
- type: z.literal("control.resume")
714
- });
715
- ControlStopEventSchema = BaseEventSchema.extend({
716
- type: z.literal("control.stop")
717
- });
718
- NodeInterruptEventSchema = BaseEventSchema.extend({
719
- type: z.literal("node.interrupt"),
720
- node_id: z.string(),
721
- node_type: z.string(),
722
- query: z.string()
723
- });
724
- WorkflowAskUserEventSchema = BaseEventSchema.extend({
725
- type: z.literal("workflow.ask-user"),
726
- session_id: z.string(),
727
- node_id: z.string(),
728
- node_type: z.string(),
729
- query: z.string()
730
- });
731
- WorkflowEventSchema = z.union([
732
- WorkflowStartedEventSchema,
733
- WorkflowPausedEventSchema,
734
- WorkflowResumedEventSchema,
735
- WorkflowStoppedEventSchema,
736
- WorkflowCompletedEventSchema,
737
- WorkflowFailedEventSchema,
738
- WorkflowOutputEventSchema,
739
- NodeScheduledEventSchema,
740
- NodeStartedEventSchema,
741
- NodeProgressEventSchema,
742
- NodeCompletedEventSchema,
743
- NodeFailedEventSchema,
744
- NodeSkippedEventSchema,
745
- NodeDataEventSchema,
746
- NodeAddedEventSchema,
747
- NodeRemovedEventSchema,
748
- ControlPauseEventSchema,
749
- ControlResumeEventSchema,
750
- ControlStopEventSchema,
751
- NodeInterruptEventSchema,
752
- WorkflowAskUserEventSchema
753
- ]);
754
- });
755
-
756
- // src/env/workflow/types/workflow.ts
757
- import { z as z2 } from "zod";
758
- var DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema;
759
- var init_workflow = __esm(() => {
760
- DependsOnSchema = z2.array(z2.string());
761
- RetryConfigSchema = z2.object({
762
- max_attempts: z2.number().min(1).default(1),
763
- backoff: z2.enum(["fixed", "exponential"]).default("exponential"),
764
- initial_delay: z2.number().min(0).default(1000)
765
- });
766
- NodeDefinitionSchema = z2.object({
767
- id: z2.string().min(1, "Node ID is required"),
768
- type: z2.string().min(1, "Node type is required"),
769
- name: z2.string().optional(),
770
- config: z2.record(z2.string(), z2.unknown()).optional().default({}),
771
- depends_on: z2.array(z2.string()).optional(),
772
- condition: z2.string().optional(),
773
- retry: RetryConfigSchema.optional(),
774
- timeout: z2.number().optional()
775
- });
776
- WorkflowConfigSchema = z2.object({
777
- parallel_limit: z2.number().nullable().optional(),
778
- timeout: z2.number().nullable().optional(),
779
- retry: RetryConfigSchema.optional(),
780
- debug: z2.boolean().optional()
781
- });
782
- OutputDefinitionSchema = z2.object({
783
- name: z2.string(),
784
- source: z2.string(),
785
- path: z2.string()
786
- });
787
- WorkflowMetadataSchema = z2.object({
788
- author: z2.string().optional(),
789
- taskId: z2.number().optional(),
790
- tags: z2.array(z2.string()).optional().default([]),
791
- created_at: z2.string().optional(),
792
- updated_at: z2.string().optional()
793
- });
794
- WorkflowDefinitionSchema = z2.object({
795
- name: z2.string().min(1, "Workflow name is required"),
796
- version: z2.string().default("1.0"),
797
- description: z2.string().optional(),
798
- config: WorkflowConfigSchema.optional().default({}),
799
- nodes: z2.array(NodeDefinitionSchema).min(1, "At least one node is required"),
800
- entry: z2.union([z2.string(), z2.array(z2.string())]).default("__default_entry__"),
801
- outputs: z2.array(OutputDefinitionSchema).optional().default([]),
802
- metadata: WorkflowMetadataSchema.optional().default({})
803
- });
804
- });
805
-
806
- // src/env/workflow/types/workflow-message.ts
807
- import { z as z3 } from "zod";
808
- var WorkflowMessageRoleSchema;
809
- var init_workflow_message = __esm(() => {
810
- init_workflow_hil();
811
- WorkflowMessageRoleSchema = z3.enum([
812
- "workflow.node.call",
813
- "workflow.node.interrupt",
814
- "workflow.node.result",
815
- "workflow.node.resume"
816
- ]);
817
- });
818
-
819
- // src/env/workflow/types/workflow-session.ts
820
- var init_workflow_session = () => {};
821
-
822
- // src/env/workflow/types/context.ts
823
- var init_context = () => {};
824
-
825
- // src/env/workflow/types/run.ts
826
- import { z as z4 } from "zod";
827
- var RunStatusSchema, NodeStatusSchema;
828
- var init_run = __esm(() => {
829
- init_workflow_message();
830
- RunStatusSchema = z4.enum([
831
- "idle",
832
- "running",
833
- "paused",
834
- "stopped",
835
- "completed",
836
- "failed"
837
- ]);
838
- NodeStatusSchema = z4.enum([
839
- "pending",
840
- "scheduled",
841
- "started",
842
- "running",
843
- "completed",
844
- "failed",
845
- "skipped"
846
- ]);
847
- });
848
-
849
- // src/env/workflow/types/index.ts
850
- var init_types = __esm(() => {
851
- init_run();
852
- init_workflow();
853
- init_workflow_message();
854
- init_workflow_session();
855
- init_context();
856
- init_workflow_hil();
857
- init_event();
858
- init_run();
859
- });
860
-
861
- // src/env/log-trace/decorator.ts
862
- function Traced(options) {
863
- return function(target, propertyKey, descriptor) {
864
- const originalFn = descriptor.value;
865
- const spanName = options?.name || propertyKey;
866
- descriptor.value = wrapFunction(originalFn, spanName, {
867
- recordParams: options?.recordParams ?? true,
868
- recordResult: options?.recordResult ?? false,
869
- recordError: options?.recordError ?? true,
870
- log: options?.log ?? false,
871
- maxLogSize: options?.maxLogSize,
872
- paramFilter: options?.paramFilter
873
- });
874
- return descriptor;
875
- };
876
- }
877
- function TracedAs(name, options) {
878
- return Traced({ name, ...options });
879
- }
880
- function TracedLightweight(options) {
881
- return Traced({ recordParams: false, recordResult: false, log: options?.log ?? false, maxLogSize: options?.maxLogSize });
882
- }
883
- function wrapFunction(fn, name, options) {
884
- const shouldLog = options?.log ?? false;
885
- const getMaxLogSize = () => {
886
- if (options?.maxLogSize !== undefined) {
887
- return options.maxLogSize;
888
- }
889
- const configMaxOutput = getMaxOutput();
890
- return configMaxOutput !== undefined ? configMaxOutput : 500;
891
- };
892
- const truncate = (obj) => {
893
- if (obj === undefined)
894
- return;
895
- if (obj === null)
896
- return null;
897
- const maxLogSize = getMaxLogSize();
898
- let str;
899
- try {
900
- str = typeof obj === "string" ? obj : JSON.stringify(obj, null, 0).replace(/\n/g, "");
901
- } catch (e) {
902
- str = `[Object with circular reference: ${e instanceof Error ? e.message : String(e)}]`;
903
- }
904
- if (maxLogSize > 0 && str.length > maxLogSize) {
905
- return str.slice(0, maxLogSize) + " [TRUNCATED]";
906
- }
907
- try {
908
- return JSON.parse(str);
909
- } catch {
910
- return str;
911
- }
912
- };
913
- const truncateString = (obj) => {
914
- if (obj === undefined)
915
- return "undefined";
916
- if (obj === null)
917
- return "null";
918
- const maxLogSize = getMaxLogSize();
919
- let str;
920
- try {
921
- str = typeof obj === "string" ? obj : JSON.stringify(obj, null, 0).replace(/\n/g, "");
922
- } catch (e) {
923
- str = `[Object with circular reference: ${e instanceof Error ? e.message : String(e)}]`;
924
- }
925
- return maxLogSize > 0 && str.length > maxLogSize ? str.slice(0, maxLogSize) + " [TRUNCATED]" : str;
926
- };
927
- const TRACE_LOG_PREFIX = "[TRACE]";
928
- const getCallerLocation = () => {
929
- const originalLimit = Error.stackTraceLimit;
930
- Error.stackTraceLimit = 15;
931
- const err = new Error;
932
- Error.captureStackTrace(err, getCallerLocation);
933
- const stack = err.stack?.split(`
934
- `) || [];
935
- Error.stackTraceLimit = originalLimit;
936
- for (let i = 1;i < stack.length; i++) {
937
- const line = stack[i];
938
- if (line.includes("decorator.ts") || line.includes("decorator.js") || line.includes("logFn") || line.includes("getCallerLocation"))
939
- continue;
940
- const match = line.match(/at\s+.+\s+\((.+):(\d+):\d+\)/) || line.match(/at\s+(.+):(\d+):\d+/);
941
- if (match) {
942
- const filePath = match[1];
943
- if (!filePath || filePath === "native")
944
- continue;
945
- const relativePath = simplifyFilePath(filePath);
946
- return `${relativePath}:${match[2]}`;
947
- }
948
- }
949
- return "";
950
- };
951
- const logFn = (event2, argsOrData, callerLocation) => {
952
- if (!shouldLog)
953
- return;
954
- const logger = createLogger("traced:" + name);
955
- const tag = event2 === "enter" ? ">>>" : event2 === "quit" ? "<<<" : "!!!";
956
- const prefix = `${TRACE_LOG_PREFIX} ${tag} ${name}`;
957
- const originalFnLocation = callerLocation || getCallerLocation();
958
- const logMessage = (msg, data) => {
959
- if (data !== undefined) {
960
- logger.info(`${prefix} ${msg}: ${truncateString(data)}`, { callerLocation: originalFnLocation });
961
- } else {
962
- logger.info(`${prefix} ${msg}`, { callerLocation: originalFnLocation });
963
- }
964
- };
965
- if (event2 === "enter") {
966
- logMessage("enter", argsOrData);
967
- } else if (event2 === "quit") {
968
- logMessage("quit", options?.recordResult ? argsOrData : undefined);
969
- } else {
970
- logMessage("error", argsOrData);
971
- }
972
- };
973
- return function(...args) {
974
- const tracer = getTracerProvider().getTracer("roy-tracer");
975
- const attributes = {};
976
- if (options?.recordParams !== false) {
977
- if (options?.paramFilter) {
978
- attributes["params"] = truncate(options.paramFilter(args));
979
- } else {
980
- attributes["params"] = truncate(args);
981
- }
982
- }
983
- const callerLocation = getCallerLocation();
984
- logFn("enter", args, callerLocation);
985
- const span = tracer.startSpan(name, { attributes });
986
- try {
987
- const result = fn.call(this, ...args);
988
- if (result && typeof result === "object" && typeof result.then === "function") {
989
- return result.then((resolved) => {
990
- span.setAttribute("result", JSON.stringify(truncate(resolved)));
991
- span.end(resolved);
992
- logFn("quit", options?.recordResult ? resolved : undefined, callerLocation);
993
- return resolved;
994
- }, (rejected) => {
995
- span.setAttribute("error", String(rejected));
996
- span.end(undefined, rejected instanceof Error ? rejected : new Error(String(rejected)));
997
- logFn("error", rejected.message, callerLocation);
998
- throw rejected;
999
- });
1000
- }
1001
- span.setAttribute("result", JSON.stringify(truncate(result)));
1002
- span.end(result);
1003
- logFn("quit", options?.recordResult ? result : undefined, callerLocation);
1004
- return result;
1005
- } catch (error) {
1006
- span.setAttribute("error", String(error));
1007
- span.end(undefined, error instanceof Error ? error : new Error(String(error)));
1008
- logFn("error", error.message, callerLocation);
1009
- throw error;
1010
- }
1011
- };
1012
- }
1013
- var init_decorator = __esm(() => {
1014
- init_tracer_provider();
1015
- init_logger();
1016
- });
1017
-
1018
622
  // src/env/workflow/engine/executor.ts
1019
623
  var Executor;
1020
624
  var init_executor = __esm(() => {
@@ -1033,15 +637,15 @@ var init_executor = __esm(() => {
1033
637
  this.options = options;
1034
638
  this.sessionComponent = sessionComponent;
1035
639
  }
1036
- async executeNode(definition, context2) {
640
+ async executeNode(definition, context) {
1037
641
  const nodeId = definition.id;
1038
642
  const nodeType = definition.type;
1039
- const agentSessionId = context2.agentSessionId;
1040
- await this.eventBus.publish(createWorkflowEvent("node.started", context2.runId, {
643
+ const agentSessionId = context.agentSessionId;
644
+ await this.eventBus.publish(createWorkflowEvent("node.started", context.runId, {
1041
645
  node_id: nodeId,
1042
- input: context2.input
646
+ input: context.input
1043
647
  }));
1044
- await this.writeNodeCall(context2.sessionId, nodeId, nodeType, context2.input, agentSessionId);
648
+ await this.writeNodeCall(context.sessionId, nodeId, nodeType, context.input, agentSessionId);
1045
649
  const abortController = new AbortController;
1046
650
  this.abortControllers.set(nodeId, abortController);
1047
651
  const timeout = definition.timeout ?? this.options.globalTimeout ?? undefined;
@@ -1049,47 +653,47 @@ var init_executor = __esm(() => {
1049
653
  try {
1050
654
  let result;
1051
655
  if (retryConfig && retryConfig.max_attempts > 1) {
1052
- result = await this.executeWithRetry(definition, context2, abortController.signal, timeout);
656
+ result = await this.executeWithRetry(definition, context, abortController.signal, timeout);
1053
657
  } else {
1054
- result = await this.executeWithTimeout(definition, context2, abortController.signal, timeout);
658
+ result = await this.executeWithTimeout(definition, context, abortController.signal, timeout);
1055
659
  }
1056
660
  if (result.error instanceof AskUserError) {
1057
- const interruptEvent = createNodeInterruptEvent(context2.runId, nodeId, nodeType, result.error.query, result.error.agentSessionId || agentSessionId);
661
+ const interruptEvent = createNodeInterruptEvent(context.runId, nodeId, nodeType, result.error.query, result.error.agentSessionId || agentSessionId);
1058
662
  await this.eventBus.publish(interruptEvent);
1059
- await this.writeNodeInterrupt(context2.sessionId, nodeId, nodeType, result.error.query, result.error.agentSessionId || agentSessionId);
663
+ await this.writeNodeInterrupt(context.sessionId, nodeId, nodeType, result.error.query, result.error.agentSessionId || agentSessionId);
1060
664
  throw result.error;
1061
665
  }
1062
666
  if (result.error) {
1063
667
  const errorMessage = result.error instanceof Error ? result.error.message : String(result.error);
1064
668
  const errorStack = result.error instanceof Error ? result.error.stack : undefined;
1065
- await this.eventBus.publish(createWorkflowEvent("node.failed", context2.runId, {
669
+ await this.eventBus.publish(createWorkflowEvent("node.failed", context.runId, {
1066
670
  node_id: nodeId,
1067
671
  error: {
1068
672
  message: errorMessage,
1069
673
  stack: errorStack
1070
674
  }
1071
675
  }));
1072
- await this.writeNodeResult(context2.sessionId, nodeId, nodeType, result.output, errorMessage, result.durationMs ?? 0);
676
+ await this.writeNodeResult(context.sessionId, nodeId, nodeType, result.output, errorMessage, result.durationMs ?? 0);
1073
677
  } else {
1074
- await this.eventBus.publish(createWorkflowEvent("node.completed", context2.runId, {
678
+ await this.eventBus.publish(createWorkflowEvent("node.completed", context.runId, {
1075
679
  node_id: nodeId,
1076
680
  output: result.output,
1077
681
  duration_ms: result.durationMs ?? 0
1078
682
  }));
1079
- await this.writeNodeResult(context2.sessionId, nodeId, nodeType, result.output, undefined, result.durationMs ?? 0);
683
+ await this.writeNodeResult(context.sessionId, nodeId, nodeType, result.output, undefined, result.durationMs ?? 0);
1080
684
  }
1081
685
  return result;
1082
686
  } finally {
1083
687
  this.abortControllers.delete(nodeId);
1084
688
  }
1085
689
  }
1086
- async executeWithTimeout(definition, context2, signal, timeout) {
690
+ async executeWithTimeout(definition, context, signal, timeout) {
1087
691
  const startTime = Date.now();
1088
692
  const nodeContext = {
1089
- runId: context2.runId,
1090
- workflowName: context2.workflowName,
693
+ runId: context.runId,
694
+ workflowName: context.workflowName,
1091
695
  eventBus: this.eventBus,
1092
- debug: context2.debug
696
+ debug: context.debug
1093
697
  };
1094
698
  const node = this.nodeRegistry.createNode(definition, nodeContext);
1095
699
  if (timeout) {
@@ -1101,7 +705,7 @@ var init_executor = __esm(() => {
1101
705
  });
1102
706
  try {
1103
707
  const result = await Promise.race([
1104
- node.execute(context2),
708
+ node.execute(context),
1105
709
  timeoutPromise
1106
710
  ]);
1107
711
  return {
@@ -1121,7 +725,7 @@ var init_executor = __esm(() => {
1121
725
  }
1122
726
  } else {
1123
727
  try {
1124
- const result = await node.execute(context2);
728
+ const result = await node.execute(context);
1125
729
  return {
1126
730
  output: result.output,
1127
731
  durationMs: Date.now() - startTime
@@ -1138,7 +742,7 @@ var init_executor = __esm(() => {
1138
742
  }
1139
743
  }
1140
744
  }
1141
- async executeWithRetry(definition, context2, signal, timeout) {
745
+ async executeWithRetry(definition, context, signal, timeout) {
1142
746
  const retryConfig = definition.retry;
1143
747
  let lastError;
1144
748
  let delay = retryConfig.initial_delay;
@@ -1153,7 +757,7 @@ var init_executor = __esm(() => {
1153
757
  const attemptAbort = new AbortController;
1154
758
  const combinedSignal = this.combineAbortSignals(signal, attemptAbort.signal);
1155
759
  try {
1156
- const result = await this.executeWithTimeout(definition, context2, combinedSignal, timeout);
760
+ const result = await this.executeWithTimeout(definition, context, combinedSignal, timeout);
1157
761
  if (!result.error) {
1158
762
  return result;
1159
763
  }
@@ -1342,469 +946,6 @@ var init_executor = __esm(() => {
1342
946
  ], Executor.prototype, "writeNodeResume", null);
1343
947
  });
1344
948
 
1345
- // src/env/workflow/nodes/tool-node.ts
1346
- class ToolNode {
1347
- definition;
1348
- toolRegistry;
1349
- type = "tool";
1350
- id;
1351
- constructor(definition, toolRegistry) {
1352
- this.definition = definition;
1353
- this.toolRegistry = toolRegistry;
1354
- this.id = definition.id;
1355
- }
1356
- async execute(context2) {
1357
- const startTime = Date.now();
1358
- try {
1359
- const toolName = this.definition.config?.tool ?? this.definition.config?.toolName;
1360
- if (!toolName) {
1361
- throw new Error("Tool name is required. Please specify config.tool or config.toolName in the node definition.");
1362
- }
1363
- let tool;
1364
- if (this.toolRegistry.getTool) {
1365
- const result = this.toolRegistry.getTool(toolName);
1366
- if (!result) {
1367
- throw new Error(`Tool not found: ${toolName}`);
1368
- }
1369
- if ("tool" in result) {
1370
- tool = result.tool;
1371
- } else {
1372
- tool = result;
1373
- }
1374
- } else if (this.toolRegistry.getToolByName) {
1375
- tool = this.toolRegistry.getToolByName(toolName);
1376
- }
1377
- if (!tool) {
1378
- throw new Error(`Tool not found: ${toolName}`);
1379
- }
1380
- let input;
1381
- if (this.definition.config?.command !== undefined) {
1382
- const commandTemplate = this.definition.config.command;
1383
- const resolvedCommand = this.resolveTemplateReferences(commandTemplate, context2.previousOutputs, context2.input);
1384
- input = { command: resolvedCommand };
1385
- console.log(`[ToolNode] command input: ${resolvedCommand}`);
1386
- } else if (this.definition.config?.message !== undefined && Object.keys(this.definition.config).length === 1) {
1387
- const messageTemplate = this.definition.config.message;
1388
- const resolvedMessage = this.resolveTemplateReferences(messageTemplate, context2.previousOutputs, context2.input);
1389
- input = { message: resolvedMessage };
1390
- console.log(`[ToolNode] message input: ${resolvedMessage}`);
1391
- } else {
1392
- input = this.definition.config?.input ?? this.definition.config?.args ?? {};
1393
- input = this.resolveTemplateReferences(input, context2.previousOutputs, context2.input);
1394
- }
1395
- let output;
1396
- try {
1397
- const toolContext = {
1398
- session_id: context2.sessionId || `workflow_${context2.runId}`,
1399
- message_id: context2.nodeId,
1400
- metadata: {
1401
- workflowRunId: context2.runId,
1402
- workflowName: context2.workflowName,
1403
- nodeId: context2.nodeId
1404
- }
1405
- };
1406
- const executePromise = tool.execute(input, toolContext);
1407
- const timeoutPromise = new Promise((_, reject) => {
1408
- setTimeout(() => reject(new Error(`Tool ${toolName} execution timeout after 30s`)), 30000);
1409
- });
1410
- output = await Promise.race([executePromise, timeoutPromise]);
1411
- } catch (err) {
1412
- console.log(`[ToolNode] Tool ${toolName} doesn't support context, retrying without context...`);
1413
- output = await tool.execute(input);
1414
- }
1415
- return {
1416
- output,
1417
- error: undefined,
1418
- durationMs: Date.now() - startTime
1419
- };
1420
- } catch (error) {
1421
- return {
1422
- output: undefined,
1423
- error: error instanceof Error ? error : new Error(String(error)),
1424
- durationMs: Date.now() - startTime
1425
- };
1426
- }
1427
- }
1428
- resolveTemplateReferences(input, previousOutputs, workflowInput) {
1429
- if (typeof input === "string") {
1430
- const pureTemplate = this.extractPureTemplate(input) || this.extractDollarTemplate(input);
1431
- if (pureTemplate) {
1432
- return this.resolvePureTemplate(pureTemplate, previousOutputs, workflowInput);
1433
- }
1434
- return this.resolveStringTemplate(input, previousOutputs, workflowInput);
1435
- }
1436
- if (Array.isArray(input)) {
1437
- return input.map((item) => this.resolveTemplateReferences(item, previousOutputs, workflowInput));
1438
- }
1439
- if (input !== null && typeof input === "object") {
1440
- const resolved = {};
1441
- for (const [key, value] of Object.entries(input)) {
1442
- resolved[key] = this.resolveTemplateReferences(value, previousOutputs, workflowInput);
1443
- }
1444
- return resolved;
1445
- }
1446
- return input;
1447
- }
1448
- extractPureTemplate(str) {
1449
- const trimmed = str.trim();
1450
- if (trimmed.startsWith("{{") && trimmed.endsWith("}}") && trimmed.length > 4) {
1451
- const content = trimmed.slice(2, -2).trim();
1452
- if (!content.includes("{{") && !content.includes("}}")) {
1453
- return content;
1454
- }
1455
- }
1456
- return null;
1457
- }
1458
- extractDollarTemplate(str) {
1459
- const trimmed = str.trim();
1460
- if (trimmed.startsWith("${") && trimmed.endsWith("}") && trimmed.length > 3) {
1461
- const content = trimmed.slice(2, -1).trim();
1462
- if (!content.includes("${") && !content.includes("}")) {
1463
- return content;
1464
- }
1465
- }
1466
- return null;
1467
- }
1468
- resolvePureTemplate(templateContent, previousOutputs, workflowInput) {
1469
- const trimmed = templateContent.trim();
1470
- const originalTemplate = `{{${templateContent}}}`;
1471
- if (trimmed.startsWith("input.")) {
1472
- const value = this.getNestedValue(workflowInput, trimmed.slice(6));
1473
- return value !== undefined ? value : originalTemplate;
1474
- }
1475
- if (trimmed.startsWith("nodes.")) {
1476
- const path = trimmed.slice(6);
1477
- const segments = path.split(".");
1478
- const nodeId = segments[0];
1479
- const restPath = segments.slice(1).join(".") || undefined;
1480
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1481
- return value !== undefined ? value : originalTemplate;
1482
- }
1483
- if (trimmed !== "input" && trimmed !== "nodes") {
1484
- const segments = trimmed.split(".");
1485
- const nodeId = segments[0];
1486
- const restPath = segments.slice(1).join(".") || undefined;
1487
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1488
- return value !== undefined ? value : originalTemplate;
1489
- }
1490
- return originalTemplate;
1491
- }
1492
- resolveStringTemplate(template, previousOutputs, workflowInput) {
1493
- let resolved = template;
1494
- resolved = resolved.replace(/\{\{input\.([^}]+)\}\}/g, (match, path) => {
1495
- const value = this.getNestedValue(workflowInput, path.trim());
1496
- return this.stringifyValue(value, match);
1497
- });
1498
- resolved = resolved.replace(/\$\{input\.([^}]+)\}/g, (match, path) => {
1499
- const value = this.getNestedValue(workflowInput, path.trim());
1500
- return this.stringifyValue(value, match);
1501
- });
1502
- resolved = resolved.replace(/\{\{([^:.{}][^}]*?)\}\}/g, (match, path) => {
1503
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
1504
- return match;
1505
- }
1506
- const segments = path.trim().split(".");
1507
- const nodeId = segments[0];
1508
- const restPath = segments.slice(1).join(".") || undefined;
1509
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1510
- return this.stringifyValue(value, match);
1511
- });
1512
- resolved = resolved.replace(/\$\{([^}]+)\}/g, (match, path) => {
1513
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
1514
- return match;
1515
- }
1516
- const segments = path.trim().split(".");
1517
- const nodeId = segments[0];
1518
- const restPath = segments.slice(1).join(".") || undefined;
1519
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1520
- return this.stringifyValue(value, match);
1521
- });
1522
- resolved = resolved.replace(/\{\{nodes\.([^}]+)\}\}/g, (match, path) => {
1523
- const segments = path.trim().split(".");
1524
- const nodeId = segments[0];
1525
- const restPath = segments.slice(1).join(".") || undefined;
1526
- const nodeOutput = this.resolvePath(nodeId, undefined, previousOutputs);
1527
- let extractedValue = this.extractFromWrapper(nodeOutput);
1528
- if (typeof extractedValue === "string" && restPath === "output") {
1529
- return this.stringifyValue(extractedValue, match);
1530
- }
1531
- if (restPath) {
1532
- const value = this.getNestedValue(extractedValue, restPath);
1533
- return this.stringifyValue(value, match);
1534
- } else {
1535
- return this.stringifyValue(extractedValue, match);
1536
- }
1537
- });
1538
- return resolved;
1539
- }
1540
- resolvePath(nodeId, path, previousOutputs) {
1541
- let nodeOutput = previousOutputs.get(nodeId);
1542
- if (nodeOutput === undefined) {
1543
- const normalizedUnderscore = nodeId.replace(/-/g, "_");
1544
- const normalizedHyphen = nodeId.replace(/_/g, "-");
1545
- if (normalizedUnderscore !== nodeId) {
1546
- nodeOutput = previousOutputs.get(normalizedUnderscore);
1547
- }
1548
- if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
1549
- nodeOutput = previousOutputs.get(normalizedHyphen);
1550
- }
1551
- }
1552
- if (nodeOutput === undefined) {
1553
- return;
1554
- }
1555
- if (path === undefined || path === "") {
1556
- return nodeOutput;
1557
- }
1558
- return this.getNestedValue(nodeOutput, path);
1559
- }
1560
- getNestedValue(obj, path) {
1561
- if (obj === null || obj === undefined) {
1562
- return;
1563
- }
1564
- const segments = path.split(".");
1565
- let current = obj;
1566
- for (const segment of segments) {
1567
- if (current === null || current === undefined) {
1568
- return;
1569
- }
1570
- current = current[segment];
1571
- }
1572
- return current;
1573
- }
1574
- extractFromWrapper(value) {
1575
- if (value === null || value === undefined) {
1576
- return value;
1577
- }
1578
- if (typeof value !== "object") {
1579
- return value;
1580
- }
1581
- let result;
1582
- if ("output" in value) {
1583
- result = value.output;
1584
- } else if ("result" in value && !("output" in value)) {
1585
- result = value.result;
1586
- } else {
1587
- return value;
1588
- }
1589
- if (typeof result === "string") {
1590
- return result.trimEnd();
1591
- }
1592
- return result;
1593
- }
1594
- stringifyValue(value, fallback) {
1595
- if (value === undefined || value === null) {
1596
- return fallback;
1597
- }
1598
- let str;
1599
- if (typeof value === "object") {
1600
- str = JSON.stringify(value);
1601
- } else {
1602
- str = String(value);
1603
- }
1604
- return str.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/"/g, "\\\"").replace(/`/g, "\\`").replace(/\$/g, "\\$");
1605
- }
1606
- }
1607
- var init_tool_node = () => {};
1608
-
1609
- // src/env/workflow/nodes/skill-node.ts
1610
- class SkillNode {
1611
- definition;
1612
- skillRegistry;
1613
- type = "skill";
1614
- id;
1615
- constructor(definition, skillRegistry) {
1616
- this.definition = definition;
1617
- this.skillRegistry = skillRegistry;
1618
- this.id = definition.id;
1619
- }
1620
- async execute(context2) {
1621
- const startTime = Date.now();
1622
- try {
1623
- const skillName = this.definition.config?.skill;
1624
- if (!skillName) {
1625
- throw new Error("Skill name is required. Please specify config.skill in the node definition.");
1626
- }
1627
- const skill = this.skillRegistry.getSkill(skillName);
1628
- if (!skill) {
1629
- throw new Error(`Skill not found: ${skillName}`);
1630
- }
1631
- const input = this.definition.config?.input ?? {};
1632
- const resolvedInput = this.resolveTemplateReferences(input, context2.previousOutputs, context2.input);
1633
- const skillContext = {
1634
- runId: context2.runId,
1635
- workflowName: context2.workflowName,
1636
- nodeId: context2.nodeId,
1637
- debug: context2.debug
1638
- };
1639
- const output = await skill.invoke(resolvedInput, skillContext);
1640
- return {
1641
- output,
1642
- error: undefined,
1643
- durationMs: Date.now() - startTime
1644
- };
1645
- } catch (error) {
1646
- return {
1647
- output: undefined,
1648
- error: error instanceof Error ? error : new Error(String(error)),
1649
- durationMs: Date.now() - startTime
1650
- };
1651
- }
1652
- }
1653
- resolveTemplateReferences(input, previousOutputs, workflowInput) {
1654
- if (typeof input === "string") {
1655
- const pureTemplate = this.extractPureTemplate(input);
1656
- if (pureTemplate) {
1657
- return this.resolvePureTemplate(pureTemplate, previousOutputs, workflowInput);
1658
- }
1659
- return this.resolveStringTemplate(input, previousOutputs, workflowInput);
1660
- }
1661
- if (Array.isArray(input)) {
1662
- return input.map((item) => this.resolveTemplateReferences(item, previousOutputs, workflowInput));
1663
- }
1664
- if (input !== null && typeof input === "object") {
1665
- const resolved = {};
1666
- for (const [key, value] of Object.entries(input)) {
1667
- resolved[key] = this.resolveTemplateReferences(value, previousOutputs, workflowInput);
1668
- }
1669
- return resolved;
1670
- }
1671
- return input;
1672
- }
1673
- extractPureTemplate(str) {
1674
- const trimmed = str.trim();
1675
- if (trimmed.startsWith("{{") && trimmed.endsWith("}}") && trimmed.length > 4) {
1676
- const content = trimmed.slice(2, -2).trim();
1677
- if (!content.includes("{{") && !content.includes("}}")) {
1678
- return content;
1679
- }
1680
- }
1681
- return null;
1682
- }
1683
- resolvePureTemplate(templateContent, previousOutputs, workflowInput) {
1684
- const trimmed = templateContent.trim();
1685
- const originalTemplate = `{{${templateContent}}}`;
1686
- if (trimmed.startsWith("input.")) {
1687
- const value = this.getNestedValue(workflowInput, trimmed.slice(6));
1688
- return value !== undefined ? value : originalTemplate;
1689
- }
1690
- if (trimmed.startsWith("nodes.")) {
1691
- const path = trimmed.slice(6);
1692
- const segments = path.split(".");
1693
- const nodeId = segments[0];
1694
- const restPath = segments.slice(1).join(".") || undefined;
1695
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1696
- return value !== undefined ? value : originalTemplate;
1697
- }
1698
- if (trimmed !== "input" && trimmed !== "nodes") {
1699
- const segments = trimmed.split(".");
1700
- const nodeId = segments[0];
1701
- const restPath = segments.slice(1).join(".") || undefined;
1702
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1703
- return value !== undefined ? value : originalTemplate;
1704
- }
1705
- return originalTemplate;
1706
- }
1707
- resolveStringTemplate(template, previousOutputs, workflowInput) {
1708
- let resolved = template;
1709
- resolved = resolved.replace(/\{\{input\.([^}]+)\}\}/g, (match, path) => {
1710
- const value = this.getNestedValue(workflowInput, path.trim());
1711
- return this.stringifyValue(value, match);
1712
- });
1713
- resolved = resolved.replace(/\{\{([^:.{}][^}]*?)\}\}/g, (match, path) => {
1714
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
1715
- return match;
1716
- }
1717
- const segments = path.trim().split(".");
1718
- const nodeId = segments[0];
1719
- const restPath = segments.slice(1).join(".") || undefined;
1720
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1721
- return this.stringifyValue(value, match);
1722
- });
1723
- resolved = resolved.replace(/\{\{nodes\.([^}]+)\}\}/g, (match, path) => {
1724
- const segments = path.trim().split(".");
1725
- const nodeId = segments[0];
1726
- const restPath = segments.slice(1).join(".") || undefined;
1727
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
1728
- return this.stringifyValue(value, match);
1729
- });
1730
- return resolved;
1731
- }
1732
- resolvePath(nodeId, path, previousOutputs) {
1733
- let nodeOutput = previousOutputs.get(nodeId);
1734
- if (nodeOutput === undefined) {
1735
- const normalizedUnderscore = nodeId.replace(/-/g, "_");
1736
- const normalizedHyphen = nodeId.replace(/_/g, "-");
1737
- if (normalizedUnderscore !== nodeId) {
1738
- nodeOutput = previousOutputs.get(normalizedUnderscore);
1739
- }
1740
- if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
1741
- nodeOutput = previousOutputs.get(normalizedHyphen);
1742
- }
1743
- }
1744
- if (nodeOutput === undefined) {
1745
- return;
1746
- }
1747
- let value = this.extractFromWrapper(nodeOutput);
1748
- if (!path) {
1749
- return value;
1750
- }
1751
- let segments = path.split(".");
1752
- if (segments.length > 1 && (segments[0] === "output" || segments[0] === "result" || segments[0] === "metadata")) {
1753
- segments = segments.slice(1);
1754
- }
1755
- let current = value;
1756
- for (const segment of segments) {
1757
- if (current === null || current === undefined) {
1758
- return;
1759
- }
1760
- current = current[segment];
1761
- }
1762
- return current;
1763
- }
1764
- extractFromWrapper(value) {
1765
- if (value === null || value === undefined) {
1766
- return value;
1767
- }
1768
- if (typeof value !== "object") {
1769
- return value;
1770
- }
1771
- if ("result" in value && "metadata" in value) {
1772
- return value.result;
1773
- }
1774
- if ("output" in value) {
1775
- return value.output;
1776
- }
1777
- return value;
1778
- }
1779
- getNestedValue(obj, path) {
1780
- if (!obj) {
1781
- return;
1782
- }
1783
- if ("input" in obj && path in obj["input"]) {
1784
- return obj["input"][path];
1785
- }
1786
- return path.split(".").reduce((current, key) => {
1787
- if (current && typeof current === "object") {
1788
- return current[key];
1789
- }
1790
- return;
1791
- }, obj);
1792
- }
1793
- stringifyValue(value, originalTemplate) {
1794
- if (value === undefined) {
1795
- return originalTemplate;
1796
- }
1797
- if (value === null) {
1798
- return "null";
1799
- }
1800
- if (typeof value === "string") {
1801
- return value;
1802
- }
1803
- return JSON.stringify(value);
1804
- }
1805
- }
1806
- var init_skill_node = () => {};
1807
-
1808
949
  // src/env/workflow/nodes/agent-node.ts
1809
950
  var AgentNode;
1810
951
  var init_agent_node = __esm(() => {
@@ -1820,14 +961,14 @@ var init_agent_node = __esm(() => {
1820
961
  this.agentRunner = agentRunner;
1821
962
  this.id = definition.id;
1822
963
  }
1823
- async execute(context2) {
964
+ async execute(context) {
1824
965
  const startTime = Date.now();
1825
966
  try {
1826
967
  const config = this.definition.config || {};
1827
968
  const agentType = config.agent_type || "general";
1828
969
  const promptTemplate = config.prompt || "";
1829
970
  const options = config.options || {};
1830
- const resolvedPrompt = this.resolveTemplate(promptTemplate, context2);
971
+ const resolvedPrompt = this.resolveTemplate(promptTemplate, context);
1831
972
  if (this.agentRunner.registerAgent && this.agentRunner.hasAgent) {
1832
973
  if (!this.agentRunner.hasAgent(agentType)) {
1833
974
  this.agentRunner.registerAgent(agentType, {
@@ -1837,11 +978,11 @@ var init_agent_node = __esm(() => {
1837
978
  });
1838
979
  }
1839
980
  }
1840
- const userResponse = context2.userResponse;
1841
- let agentSessionId = context2.agentSessionId;
1842
- if (!userResponse && context2.sessionComponent && !agentSessionId) {
1843
- agentSessionId = await this.createAgentSubSession(context2);
1844
- context2.agentSessionId = agentSessionId;
981
+ const userResponse = context.userResponse;
982
+ let agentSessionId = context.agentSessionId;
983
+ if (!userResponse && context.sessionComponent && !agentSessionId) {
984
+ agentSessionId = await this.createAgentSubSession(context);
985
+ context.agentSessionId = agentSessionId;
1845
986
  }
1846
987
  const agentConfig = {
1847
988
  type: agentType,
@@ -1851,7 +992,7 @@ var init_agent_node = __esm(() => {
1851
992
  model: options.model,
1852
993
  allowedTools: ["ask_user"]
1853
994
  },
1854
- workflowHistory: context2.workflowHistory,
995
+ workflowHistory: context.workflowHistory,
1855
996
  nodeId: this.definition.id,
1856
997
  agentSessionId
1857
998
  };
@@ -1869,7 +1010,7 @@ var init_agent_node = __esm(() => {
1869
1010
  };
1870
1011
  } catch (error) {
1871
1012
  if (error instanceof AskUserError) {
1872
- const contextAgentSessionId = context2.agentSessionId;
1013
+ const contextAgentSessionId = context.agentSessionId;
1873
1014
  if (contextAgentSessionId && !error.agentSessionId) {
1874
1015
  throw new AskUserError(error.runId, error.sessionId, error.nodeId, error.nodeType, error.query, contextAgentSessionId, error.timestamp);
1875
1016
  }
@@ -1884,8 +1025,8 @@ var init_agent_node = __esm(() => {
1884
1025
  };
1885
1026
  }
1886
1027
  }
1887
- async createAgentSubSession(context2) {
1888
- const sessionComponent = context2.sessionComponent;
1028
+ async createAgentSubSession(context) {
1029
+ const sessionComponent = context.sessionComponent;
1889
1030
  if (!sessionComponent) {
1890
1031
  return "";
1891
1032
  }
@@ -1895,12 +1036,12 @@ var init_agent_node = __esm(() => {
1895
1036
  title: `Agent: ${this.definition.id}`,
1896
1037
  metadata: {
1897
1038
  type: "agent",
1898
- parentSessionId: context2.sessionId,
1039
+ parentSessionId: context.sessionId,
1899
1040
  nodeId: this.definition.id,
1900
- workflowName: context2.workflowName
1041
+ workflowName: context.workflowName
1901
1042
  }
1902
1043
  });
1903
- const workflowSession = await sessionComponent.get(context2.sessionId);
1044
+ const workflowSession = await sessionComponent.get(context.sessionId);
1904
1045
  if (workflowSession) {
1905
1046
  const metadata = workflowSession.metadata || {};
1906
1047
  const agentSessions = metadata.agentSessions || [];
@@ -1920,7 +1061,7 @@ var init_agent_node = __esm(() => {
1920
1061
  createdAt: Date.now()
1921
1062
  });
1922
1063
  }
1923
- await sessionComponent.update(context2.sessionId, {
1064
+ await sessionComponent.update(context.sessionId, {
1924
1065
  metadata: {
1925
1066
  ...metadata,
1926
1067
  agentSessions
@@ -1929,27 +1070,27 @@ var init_agent_node = __esm(() => {
1929
1070
  }
1930
1071
  return agentSessionId;
1931
1072
  }
1932
- resolveTemplate(template, context2) {
1073
+ resolveTemplate(template, context) {
1933
1074
  if (!template) {
1934
1075
  return "";
1935
1076
  }
1936
1077
  let resolved = template;
1937
1078
  resolved = resolved.replace(/\{\{input\.([^}]+)\}\}/g, (match, path) => {
1938
- const value = this.getNestedValue(context2.input, path);
1079
+ const value = this.getNestedValue(context.input, path);
1939
1080
  return this.stringifyValue(value, match);
1940
1081
  });
1941
1082
  resolved = resolved.replace(/\{\{nodes\.([^}]+)\}\}/g, (match, path) => {
1942
1083
  const segments = path.split(".");
1943
1084
  const nodeId = segments[0];
1944
- let nodeOutput = context2.previousOutputs.get(nodeId);
1085
+ let nodeOutput = context.previousOutputs.get(nodeId);
1945
1086
  if (nodeOutput === undefined) {
1946
1087
  const normalizedUnderscore = nodeId.replace(/-/g, "_");
1947
1088
  const normalizedHyphen = nodeId.replace(/_/g, "-");
1948
1089
  if (normalizedUnderscore !== nodeId) {
1949
- nodeOutput = context2.previousOutputs.get(normalizedUnderscore);
1090
+ nodeOutput = context.previousOutputs.get(normalizedUnderscore);
1950
1091
  }
1951
1092
  if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
1952
- nodeOutput = context2.previousOutputs.get(normalizedHyphen);
1093
+ nodeOutput = context.previousOutputs.get(normalizedHyphen);
1953
1094
  }
1954
1095
  }
1955
1096
  if (nodeOutput === undefined) {
@@ -1978,15 +1119,15 @@ var init_agent_node = __esm(() => {
1978
1119
  }
1979
1120
  const segments = path.split(".");
1980
1121
  const nodeId = segments[0];
1981
- let nodeOutput = context2.previousOutputs.get(nodeId);
1122
+ let nodeOutput = context.previousOutputs.get(nodeId);
1982
1123
  if (nodeOutput === undefined) {
1983
1124
  const normalizedUnderscore = nodeId.replace(/-/g, "_");
1984
1125
  const normalizedHyphen = nodeId.replace(/_/g, "-");
1985
1126
  if (normalizedUnderscore !== nodeId) {
1986
- nodeOutput = context2.previousOutputs.get(normalizedUnderscore);
1127
+ nodeOutput = context.previousOutputs.get(normalizedUnderscore);
1987
1128
  }
1988
1129
  if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
1989
- nodeOutput = context2.previousOutputs.get(normalizedHyphen);
1130
+ nodeOutput = context.previousOutputs.get(normalizedHyphen);
1990
1131
  }
1991
1132
  }
1992
1133
  if (nodeOutput === undefined) {
@@ -2061,141 +1202,6 @@ var init_agent_node = __esm(() => {
2061
1202
  ], AgentNode.prototype, "createAgentSubSession", null);
2062
1203
  });
2063
1204
 
2064
- // src/env/workflow/nodes/workflow-node.ts
2065
- class WorkflowNode {
2066
- workflowRunner;
2067
- type = "workflow";
2068
- id;
2069
- config;
2070
- constructor(definition, workflowRunner) {
2071
- this.workflowRunner = workflowRunner;
2072
- this.id = definition.id;
2073
- this.config = definition.config ?? {};
2074
- }
2075
- async execute(context2) {
2076
- const startTime = Date.now();
2077
- try {
2078
- const workflowName = this.config.workflow_name;
2079
- if (!workflowName) {
2080
- throw new Error("workflow_name is required in config. Please specify config.workflow_name in the node definition.");
2081
- }
2082
- const previousOutputs = context2.previousOutputs ?? this.convertToMap(context2.nodeOutputs ?? {});
2083
- const resolvedInput = this.resolveInput(this.config.input ?? {}, previousOutputs);
2084
- const result = await this.workflowRunner.run(workflowName, resolvedInput);
2085
- const success = result.status === "completed";
2086
- return {
2087
- success,
2088
- output: result.output,
2089
- error: success ? undefined : result.error,
2090
- duration: Date.now() - startTime
2091
- };
2092
- } catch (error) {
2093
- return {
2094
- success: false,
2095
- output: undefined,
2096
- error: error instanceof Error ? error : new Error(String(error)),
2097
- duration: Date.now() - startTime
2098
- };
2099
- }
2100
- }
2101
- convertToMap(nodeOutputs) {
2102
- const map = new Map;
2103
- for (const [nodeId, result] of Object.entries(nodeOutputs)) {
2104
- map.set(nodeId, result.output);
2105
- }
2106
- return map;
2107
- }
2108
- resolveInput(input, previousOutputs) {
2109
- const resolved = {};
2110
- for (const [key, value] of Object.entries(input)) {
2111
- resolved[key] = this.resolveValue(value, previousOutputs);
2112
- }
2113
- return resolved;
2114
- }
2115
- resolveValue(value, previousOutputs) {
2116
- if (typeof value === "string") {
2117
- return this.resolveStringTemplate(value, previousOutputs);
2118
- }
2119
- if (Array.isArray(value)) {
2120
- return value.map((item) => this.resolveValue(item, previousOutputs));
2121
- }
2122
- if (value !== null && typeof value === "object") {
2123
- const resolved = {};
2124
- for (const [k, v] of Object.entries(value)) {
2125
- resolved[k] = this.resolveValue(v, previousOutputs);
2126
- }
2127
- return resolved;
2128
- }
2129
- return value;
2130
- }
2131
- resolveStringTemplate(template, previousOutputs) {
2132
- const templatePattern = /\{\{([^}]+)\}\}/g;
2133
- return template.replace(templatePattern, (match, path) => {
2134
- const trimmedPath = path.trim();
2135
- const value = this.resolvePath(trimmedPath, previousOutputs);
2136
- if (value !== undefined) {
2137
- return this.stringifyValue(value, match);
2138
- }
2139
- return match;
2140
- });
2141
- }
2142
- resolvePath(path, previousOutputs) {
2143
- const segments = path.split(".");
2144
- if (segments.length === 0) {
2145
- return;
2146
- }
2147
- const nodeId = segments[0];
2148
- let nodeOutput = previousOutputs.get(nodeId);
2149
- if (nodeOutput === undefined) {
2150
- return;
2151
- }
2152
- nodeOutput = this.extractFromWrapper(nodeOutput);
2153
- if (segments.length === 1) {
2154
- return nodeOutput;
2155
- }
2156
- let current = nodeOutput;
2157
- let startIndex = 1;
2158
- if (segments.length > 1 && (segments[1] === "output" || segments[1] === "result" || segments[1] === "metadata")) {
2159
- startIndex = 2;
2160
- }
2161
- for (let i = startIndex;i < segments.length; i++) {
2162
- if (current === null || current === undefined) {
2163
- return;
2164
- }
2165
- current = current[segments[i]];
2166
- }
2167
- return current;
2168
- }
2169
- extractFromWrapper(value) {
2170
- if (value === null || value === undefined) {
2171
- return value;
2172
- }
2173
- if (typeof value !== "object") {
2174
- return value;
2175
- }
2176
- if ("result" in value && "metadata" in value) {
2177
- return value.result;
2178
- }
2179
- if ("output" in value) {
2180
- return value.output;
2181
- }
2182
- return value;
2183
- }
2184
- stringifyValue(value, originalTemplate) {
2185
- if (value === undefined) {
2186
- return originalTemplate;
2187
- }
2188
- if (value === null) {
2189
- return "null";
2190
- }
2191
- if (typeof value === "string") {
2192
- return value;
2193
- }
2194
- return JSON.stringify(value);
2195
- }
2196
- }
2197
- var init_workflow_node = () => {};
2198
-
2199
1205
  // src/env/workflow/nodes/ask-user-node.ts
2200
1206
  class AskUserNode {
2201
1207
  type = "ask_user";
@@ -2205,12 +1211,12 @@ class AskUserNode {
2205
1211
  this.id = definition.id;
2206
1212
  this.config = definition.config || {};
2207
1213
  }
2208
- async execute(context2) {
1214
+ async execute(context) {
2209
1215
  const query = this.config.query || "确认继续吗?";
2210
1216
  const options = this.config.options;
2211
1217
  const fullQuery = options ? `${query} (选项: ${options.join(", ")})` : query;
2212
- await context2.eventBus.publish(createNodeInterruptEvent(context2.runId, this.id, this.type, fullQuery));
2213
- throw new AskUserError(context2.runId, context2.sessionId, this.id, this.type, query);
1218
+ await context.eventBus.publish(createNodeInterruptEvent(context.runId, this.id, this.type, fullQuery));
1219
+ throw new AskUserError(context.runId, context.sessionId, this.id, this.type, query);
2214
1220
  }
2215
1221
  validateConfig(_config) {
2216
1222
  return true;
@@ -2300,13 +1306,13 @@ class NodeRegistry {
2300
1306
  list() {
2301
1307
  return Array.from(this.factories.keys());
2302
1308
  }
2303
- createNode(definition, context2) {
1309
+ createNode(definition, context) {
2304
1310
  const factory = this.factories.get(definition.type);
2305
1311
  if (!factory) {
2306
1312
  const availableTypes = this.list().join(", ");
2307
1313
  throw new Error(`Unknown node type: ${definition.type}. Available types: ${availableTypes}`);
2308
1314
  }
2309
- return factory(definition, context2);
1315
+ return factory(definition, context);
2310
1316
  }
2311
1317
  }
2312
1318
  var init_node_registry = __esm(() => {
@@ -2366,9 +1372,9 @@ var init_engine = __esm(() => {
2366
1372
  getSessionId(runId) {
2367
1373
  return `workflow_${runId}`;
2368
1374
  }
2369
- async createSession(workflow2, options) {
2370
- const definition = "definition" in workflow2 ? workflow2.definition : workflow2;
2371
- const workflowId = "id" in workflow2 ? workflow2.id : `inline_${definition.name}`;
1375
+ async createSession(workflow, options) {
1376
+ const definition = "definition" in workflow ? workflow.definition : workflow;
1377
+ const workflowId = "id" in workflow ? workflow.id : `inline_${definition.name}`;
2372
1378
  const workflowName = definition.name;
2373
1379
  const runId = this.generateRunId();
2374
1380
  const sessionId = this.getSessionId(runId);
@@ -2445,7 +1451,7 @@ var init_engine = __esm(() => {
2445
1451
  return { runId: this.getRunIdFromSessionId(sessionId), status: "failed" };
2446
1452
  }
2447
1453
  const messages = this.sessionComponent ? await this.sessionComponent.getMessages(sessionId) : [];
2448
- const { inferNextNode } = await import("./chunk-25x2pdtp.js");
1454
+ const { inferNextNode } = await import("./roy-agent-core-qw0ebh1d.js");
2449
1455
  const entry = workflowDef.entry;
2450
1456
  const entryNode = Array.isArray(entry) ? entry[0] : entry;
2451
1457
  const resumePoint = inferNextNode(messages, {
@@ -2544,11 +1550,11 @@ var init_engine = __esm(() => {
2544
1550
  }
2545
1551
  return { runId, status: "running" };
2546
1552
  }
2547
- async runWorkflow(workflow2, options) {
2548
- const definition = "definition" in workflow2 ? workflow2.definition : workflow2;
2549
- const workflowId = "id" in workflow2 ? workflow2.id : `inline_${definition.name}`;
1553
+ async runWorkflow(workflow, options) {
1554
+ const definition = "definition" in workflow ? workflow.definition : workflow;
1555
+ const workflowId = "id" in workflow ? workflow.id : `inline_${definition.name}`;
2550
1556
  const workflowName = definition.name;
2551
- const sessionId = await this.createSession(workflow2, options);
1557
+ const sessionId = await this.createSession(workflow, options);
2552
1558
  const sessionState = await this.initializeSessionState(sessionId, definition, workflowId, workflowName, options);
2553
1559
  this.activeSessions.set(sessionId, sessionState);
2554
1560
  return this.runWithResume(sessionId, { type: "entry_node" }, options);
@@ -2718,29 +1724,29 @@ var init_engine = __esm(() => {
2718
1724
  setupEventHandlers(sessionState) {
2719
1725
  const { sessionId, eventBus, scheduler } = sessionState;
2720
1726
  const runId = this.getRunIdFromSessionId(sessionId);
2721
- eventBus.on("node.completed", async (event2) => {
2722
- if (event2.type !== "node.completed")
1727
+ eventBus.on("node.completed", async (event) => {
1728
+ if (event.type !== "node.completed")
2723
1729
  return;
2724
- sessionState.nodeOutputs.set(event2.node_id, event2.output);
2725
- scheduler.markCompleted(event2.node_id);
2726
- if (event2.output && typeof event2.output === "object" && "workflowHistory" in event2.output) {
2727
- const messages = event2.output.workflowHistory;
1730
+ sessionState.nodeOutputs.set(event.node_id, event.output);
1731
+ scheduler.markCompleted(event.node_id);
1732
+ if (event.output && typeof event.output === "object" && "workflowHistory" in event.output) {
1733
+ const messages = event.output.workflowHistory;
2728
1734
  if (Array.isArray(messages)) {
2729
1735
  sessionState.workflowHistory.push(...messages);
2730
1736
  }
2731
1737
  }
2732
1738
  this.checkAndFinalize(sessionState);
2733
1739
  });
2734
- eventBus.on("node.failed", async (event2) => {
2735
- if (event2.type !== "node.failed")
1740
+ eventBus.on("node.failed", async (event) => {
1741
+ if (event.type !== "node.failed")
2736
1742
  return;
2737
- scheduler.markFailed(event2.node_id);
2738
- await this.failWorkflow(sessionState, new Error(event2.error.message));
1743
+ scheduler.markFailed(event.node_id);
1744
+ await this.failWorkflow(sessionState, new Error(event.error.message));
2739
1745
  });
2740
- eventBus.on("node.interrupt", async (event2) => {
2741
- if (event2.type !== "node.interrupt")
1746
+ eventBus.on("node.interrupt", async (event) => {
1747
+ if (event.type !== "node.interrupt")
2742
1748
  return;
2743
- logger.info(`Workflow paused at node "${event2.node_id}" - ask_user pending`);
1749
+ logger.info(`Workflow paused at node "${event.node_id}" - ask_user pending`);
2744
1750
  sessionState.status = "paused";
2745
1751
  sessionState.abortController.abort();
2746
1752
  if (this.sessionComponent) {
@@ -2750,16 +1756,16 @@ var init_engine = __esm(() => {
2750
1756
  });
2751
1757
  }
2752
1758
  await eventBus.publish(createWorkflowEvent("workflow.paused", runId, {
2753
- pendingNodeId: event2.node_id,
2754
- query: event2.query
1759
+ pendingNodeId: event.node_id,
1760
+ query: event.query
2755
1761
  }));
2756
- await this.writeNodeInterrupt(sessionId, event2.node_id, event2.node_type, event2.query, event2.agent_session_id);
1762
+ await this.writeNodeInterrupt(sessionId, event.node_id, event.node_type, event.query, event.agent_session_id);
2757
1763
  sessionState.resolveCompleted({
2758
1764
  runId,
2759
1765
  status: "paused",
2760
- pendingNodeId: event2.node_id,
2761
- query: event2.query,
2762
- agentSessionId: event2.agent_session_id
1766
+ pendingNodeId: event.node_id,
1767
+ query: event.query,
1768
+ agentSessionId: event.agent_session_id
2763
1769
  });
2764
1770
  });
2765
1771
  }
@@ -2838,14 +1844,14 @@ var init_engine = __esm(() => {
2838
1844
  sessionState.eventBus.off("node.completed", onCompleted);
2839
1845
  sessionState.eventBus.off("node.failed", onFailed);
2840
1846
  };
2841
- const onCompleted = (event2) => {
2842
- if (event2.type === "node.completed") {
1847
+ const onCompleted = (event) => {
1848
+ if (event.type === "node.completed") {
2843
1849
  cleanup();
2844
1850
  resolve();
2845
1851
  }
2846
1852
  };
2847
- const onFailed = (event2) => {
2848
- if (event2.type === "node.failed") {
1853
+ const onFailed = (event) => {
1854
+ if (event.type === "node.failed") {
2849
1855
  cleanup();
2850
1856
  resolve();
2851
1857
  }
@@ -2872,8 +1878,8 @@ var init_engine = __esm(() => {
2872
1878
  return;
2873
1879
  }
2874
1880
  await this.writeNodeCall(sessionId, nodeId, nodeDef.type, input);
2875
- const context2 = this.createExecutionContext(sessionState, nodeId, input);
2876
- executor.executeNode(nodeDef, context2).catch(async (error) => {
1881
+ const context = this.createExecutionContext(sessionState, nodeId, input);
1882
+ executor.executeNode(nodeDef, context).catch(async (error) => {
2877
1883
  if (error instanceof AskUserError) {
2878
1884
  await eventBus.publish(createNodeInterruptEvent(runId, nodeId, nodeDef.type, error.query, error.agentSessionId));
2879
1885
  return;
@@ -2910,15 +1916,15 @@ var init_engine = __esm(() => {
2910
1916
  scheduler.markFailed(nodeId);
2911
1917
  return;
2912
1918
  }
2913
- const context2 = this.createExecutionContext(sessionState, nodeId, undefined);
1919
+ const context = this.createExecutionContext(sessionState, nodeId, undefined);
2914
1920
  if (options?.agentSessionId || options?.userResponse) {
2915
- context2.agentSessionId = options.agentSessionId;
2916
- context2.userResponse = options.userResponse;
1921
+ context.agentSessionId = options.agentSessionId;
1922
+ context.userResponse = options.userResponse;
2917
1923
  }
2918
- executor.executeNode(nodeDef, context2).catch((error) => {
1924
+ executor.executeNode(nodeDef, context).catch((error) => {
2919
1925
  if (error instanceof AskUserError) {
2920
- const event2 = createNodeInterruptEvent(runId, nodeId, nodeDef.type, error.query, error.agentSessionId);
2921
- eventBus.publish(event2);
1926
+ const event = createNodeInterruptEvent(runId, nodeId, nodeDef.type, error.query, error.agentSessionId);
1927
+ eventBus.publish(event);
2922
1928
  return;
2923
1929
  }
2924
1930
  scheduler.markFailed(nodeId);
@@ -3048,12 +2054,12 @@ var init_engine = __esm(() => {
3048
2054
  if (!this.workflowRepository) {
3049
2055
  return null;
3050
2056
  }
3051
- let workflow2 = this.workflowRepository.getById(workflowIdOrName);
3052
- if (workflow2)
3053
- return workflow2.definition;
3054
- workflow2 = this.workflowRepository.getByName(workflowIdOrName);
3055
- if (workflow2)
3056
- return workflow2.definition;
2057
+ let workflow = this.workflowRepository.getById(workflowIdOrName);
2058
+ if (workflow)
2059
+ return workflow.definition;
2060
+ workflow = this.workflowRepository.getByName(workflowIdOrName);
2061
+ if (workflow)
2062
+ return workflow.definition;
3057
2063
  return null;
3058
2064
  }
3059
2065
  };
@@ -3137,4 +2143,4 @@ var init_engine2 = __esm(() => {
3137
2143
  init_node_registry();
3138
2144
  });
3139
2145
 
3140
- export { Traced, TracedAs, TracedLightweight, wrapFunction, init_decorator, EventBus, DAGManager, Scheduler, Executor, NodeRegistry, WorkflowEngine, exports_engine, init_engine2 as init_engine };
2146
+ export { EventBus, DAGManager, Scheduler, Executor, NodeRegistry, WorkflowEngine, exports_engine, init_engine2 as init_engine };