@cadenza.io/core 3.28.0 → 3.28.1

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/cli.js CHANGED
@@ -2559,6 +2559,38 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2559
2559
  getTag() {
2560
2560
  return this.task.getTag(this.context);
2561
2561
  }
2562
+ classifyBusinessRoutineLifecycle() {
2563
+ const fullContext = this.context?.getFullContext?.() ?? {};
2564
+ const metadata = fullContext.__metadata && typeof fullContext.__metadata === "object" ? fullContext.__metadata : {};
2565
+ if (this.task.isMeta || this.task.isSubMeta || this.task.isHidden) {
2566
+ return false;
2567
+ }
2568
+ if (fullContext.__isInquiry === true || fullContext.__isDeputy === true || metadata.__isInquiry === true || metadata.__isDeputy === true || metadata.__isSubMeta === true) {
2569
+ return false;
2570
+ }
2571
+ return true;
2572
+ }
2573
+ getBusinessRoutineLifecycleDecision() {
2574
+ const fullContext = this.context?.getFullContext?.() ?? {};
2575
+ const metadata = this.context?.getMetadata?.() ?? {};
2576
+ if (typeof metadata.__emitBusinessRoutineLifecycle === "boolean") {
2577
+ return metadata.__emitBusinessRoutineLifecycle;
2578
+ }
2579
+ if (typeof fullContext.__emitBusinessRoutineLifecycle === "boolean") {
2580
+ return fullContext.__emitBusinessRoutineLifecycle;
2581
+ }
2582
+ return this.classifyBusinessRoutineLifecycle();
2583
+ }
2584
+ rememberBusinessRoutineLifecycleDecision(value) {
2585
+ const fullContext = this.context?.getFullContext?.();
2586
+ const metadata = this.context?.getMetadata?.();
2587
+ if (fullContext && typeof fullContext === "object") {
2588
+ fullContext.__emitBusinessRoutineLifecycle = value;
2589
+ }
2590
+ if (metadata && typeof metadata === "object") {
2591
+ metadata.__emitBusinessRoutineLifecycle = value;
2592
+ }
2593
+ }
2562
2594
  /**
2563
2595
  * Schedules the current node/task on the specified graph layer if applicable.
2564
2596
  *
@@ -2684,17 +2716,23 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2684
2716
  this.executionStart = Date.now();
2685
2717
  }
2686
2718
  if (this.previousNodes.length === 0) {
2687
- this.emitMetricsWithMetadata(
2688
- "meta.node.started_routine_execution",
2689
- {
2690
- data: {
2691
- isRunning: true,
2692
- started: formatTimestamp(this.executionStart)
2693
- },
2694
- filter: { uuid: this.routineExecId }
2695
- },
2696
- { squash: true, squashId: this.routineExecId }
2719
+ const shouldEmitBusinessRoutineLifecycle = this.getBusinessRoutineLifecycleDecision();
2720
+ this.rememberBusinessRoutineLifecycleDecision(
2721
+ shouldEmitBusinessRoutineLifecycle
2697
2722
  );
2723
+ if (shouldEmitBusinessRoutineLifecycle) {
2724
+ this.emitMetricsWithMetadata(
2725
+ "meta.node.started_routine_execution",
2726
+ {
2727
+ data: {
2728
+ isRunning: true,
2729
+ started: formatTimestamp(this.executionStart)
2730
+ },
2731
+ filter: { uuid: this.routineExecId }
2732
+ },
2733
+ { squash: true, squashId: this.routineExecId }
2734
+ );
2735
+ }
2698
2736
  }
2699
2737
  if (this.debug && !this.task.isSubMeta && !this.context.getMetadata().__isSubMeta || this.verbose) {
2700
2738
  this.log();
@@ -2763,21 +2801,23 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2763
2801
  `meta.node.graph_completed:${this.routineExecId}`,
2764
2802
  context2
2765
2803
  );
2766
- this.emitMetricsWithMetadata(
2767
- "meta.node.ended_routine_execution",
2768
- {
2769
- data: {
2770
- isRunning: false,
2771
- isComplete: true,
2772
- resultContext: this.context.getContext(),
2773
- metaResultContext: this.context.getMetadata(),
2774
- progress: 1,
2775
- ended: formatTimestamp(end)
2804
+ if (this.getBusinessRoutineLifecycleDecision()) {
2805
+ this.emitMetricsWithMetadata(
2806
+ "meta.node.ended_routine_execution",
2807
+ {
2808
+ data: {
2809
+ isRunning: false,
2810
+ isComplete: true,
2811
+ resultContext: this.context.getContext(),
2812
+ metaResultContext: this.context.getMetadata(),
2813
+ progress: 1,
2814
+ ended: formatTimestamp(end)
2815
+ },
2816
+ filter: { uuid: this.routineExecId }
2776
2817
  },
2777
- filter: { uuid: this.routineExecId }
2778
- },
2779
- { squash: true, squashId: this.routineExecId }
2780
- );
2818
+ { squash: true, squashId: this.routineExecId }
2819
+ );
2820
+ }
2781
2821
  }
2782
2822
  return end;
2783
2823
  }
@@ -3664,7 +3704,7 @@ var GraphRunner = class extends SignalEmitter {
3664
3704
  allTasks
3665
3705
  );
3666
3706
  const ctx = new GraphContext(context || {});
3667
- if (!isSubMeta) {
3707
+ if (!isSubMeta && (!isMeta || this.debug)) {
3668
3708
  if (isNewTrace) {
3669
3709
  this.emitMetrics("meta.runner.new_trace", {
3670
3710
  data: {
@@ -4083,7 +4123,13 @@ var Actor = class {
4083
4123
  inquire: (inquiryName, inquiryContext = {}, options = {}) => inquire(inquiryName, inquiryContext, options),
4084
4124
  tools: resolvedTools
4085
4125
  };
4086
- const handlerResult = await handler(actorContext);
4126
+ const handlerResult = await handler(
4127
+ actorContext,
4128
+ actorContext.emit,
4129
+ actorContext.inquire,
4130
+ resolvedTools,
4131
+ resolvedProgressCallback
4132
+ );
4087
4133
  if (invocationOptions.writeContract === "reducer" && typeof handlerResult === "function") {
4088
4134
  reduceDurableState(handlerResult);
4089
4135
  }