@voltagent/core 1.1.15 → 1.1.16

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.d.mts CHANGED
@@ -655,7 +655,7 @@ interface WorkflowStateEntry {
655
655
  /** Workflow name for reference */
656
656
  workflowName: string;
657
657
  /** Current status */
658
- status: "running" | "suspended" | "completed" | "error";
658
+ status: "running" | "suspended" | "completed" | "cancelled" | "error";
659
659
  /** Original input to the workflow */
660
660
  input?: unknown;
661
661
  /** Execution context */
@@ -3579,7 +3579,7 @@ declare class Agent {
3579
3579
  private createWorkingMemoryTools;
3580
3580
  }
3581
3581
 
3582
- type WorkflowStateStatus = "pending" | "running" | "completed" | "failed" | "suspended";
3582
+ type WorkflowStateStatus = "pending" | "running" | "completed" | "failed" | "suspended" | "cancelled";
3583
3583
  type WorkflowState<INPUT, RESULT> = {
3584
3584
  executionId: string;
3585
3585
  conversationId?: string;
@@ -3598,6 +3598,8 @@ type WorkflowState<INPUT, RESULT> = {
3598
3598
  error: Error | null;
3599
3599
  /** suspension metadata when workflow is suspended */
3600
3600
  suspension?: WorkflowSuspensionMetadata;
3601
+ /** cancellation metadata when workflow is cancelled */
3602
+ cancellation?: WorkflowCancellationMetadata;
3601
3603
  /** accumulated usage from andAgent calls */
3602
3604
  usage: UsageInfo;
3603
3605
  };
@@ -3621,6 +3623,12 @@ interface WorkflowSuspensionMetadata<SUSPEND_DATA = DangerouslyAllowAny> {
3621
3623
  completedStepsData?: DangerouslyAllowAny[];
3622
3624
  };
3623
3625
  }
3626
+ interface WorkflowCancellationMetadata {
3627
+ /** Timestamp when the workflow was cancelled */
3628
+ cancelledAt: Date;
3629
+ /** Reason for cancellation */
3630
+ reason?: string;
3631
+ }
3624
3632
  /**
3625
3633
  * Custom abort controller for workflow suspension with reason tracking
3626
3634
  */
@@ -3633,14 +3641,26 @@ interface WorkflowSuspendController {
3633
3641
  * Suspend the workflow with a reason
3634
3642
  */
3635
3643
  suspend: (reason?: string) => void;
3644
+ /**
3645
+ * Cancel the workflow with a reason
3646
+ */
3647
+ cancel: (reason?: string) => void;
3636
3648
  /**
3637
3649
  * Check if the workflow has been suspended
3638
3650
  */
3639
3651
  isSuspended: () => boolean;
3640
3652
  /**
3641
- * Get the suspension reason
3653
+ * Check if the workflow has been cancelled
3654
+ */
3655
+ isCancelled: () => boolean;
3656
+ /**
3657
+ * Get the suspension or cancellation reason
3642
3658
  */
3643
3659
  getReason: () => string | undefined;
3660
+ /**
3661
+ * Get the cancellation reason if cancellation was requested
3662
+ */
3663
+ getCancelReason: () => string | undefined;
3644
3664
  }
3645
3665
  /**
3646
3666
  * Base result interface shared by all workflow execution results
@@ -3665,7 +3685,7 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3665
3685
  /**
3666
3686
  * Current status of the workflow execution
3667
3687
  */
3668
- status: "completed" | "suspended" | "error" | Promise<"completed" | "suspended" | "error">;
3688
+ status: "completed" | "suspended" | "cancelled" | "error" | Promise<"completed" | "suspended" | "cancelled" | "error">;
3669
3689
  /**
3670
3690
  * The result data if workflow completed successfully
3671
3691
  */
@@ -3674,6 +3694,10 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3674
3694
  * Suspension metadata if workflow was suspended
3675
3695
  */
3676
3696
  suspension?: WorkflowSuspensionMetadata | Promise<WorkflowSuspensionMetadata | undefined>;
3697
+ /**
3698
+ * Cancellation metadata if workflow was cancelled
3699
+ */
3700
+ cancellation?: WorkflowCancellationMetadata | Promise<WorkflowCancellationMetadata | undefined>;
3677
3701
  /**
3678
3702
  * Error information if workflow failed
3679
3703
  */
@@ -3688,9 +3712,10 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3688
3712
  */
3689
3713
  interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA> {
3690
3714
  endAt: Date;
3691
- status: "completed" | "suspended" | "error";
3715
+ status: "completed" | "suspended" | "cancelled" | "error";
3692
3716
  result: z.infer<RESULT_SCHEMA> | null;
3693
3717
  suspension?: WorkflowSuspensionMetadata;
3718
+ cancellation?: WorkflowCancellationMetadata;
3694
3719
  error?: unknown;
3695
3720
  usage: UsageInfo;
3696
3721
  /**
@@ -3709,9 +3734,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
3709
3734
  */
3710
3735
  interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA>, AsyncIterable<WorkflowStreamEvent> {
3711
3736
  endAt: Promise<Date>;
3712
- status: Promise<"completed" | "suspended" | "error">;
3737
+ status: Promise<"completed" | "suspended" | "cancelled" | "error">;
3713
3738
  result: Promise<z.infer<RESULT_SCHEMA> | null>;
3714
3739
  suspension: Promise<WorkflowSuspensionMetadata | undefined>;
3740
+ cancellation: Promise<WorkflowCancellationMetadata | undefined>;
3715
3741
  error: Promise<unknown | undefined>;
3716
3742
  usage: Promise<UsageInfo>;
3717
3743
  /**
@@ -3723,6 +3749,14 @@ interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA
3723
3749
  resume: (input: z.infer<RESUME_SCHEMA>, options?: {
3724
3750
  stepId?: string;
3725
3751
  }) => Promise<WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
3752
+ /**
3753
+ * Request workflow suspension
3754
+ */
3755
+ suspend: (reason?: string) => void;
3756
+ /**
3757
+ * Cancel the workflow execution
3758
+ */
3759
+ cancel: (reason?: string) => void;
3726
3760
  /**
3727
3761
  * Abort the workflow execution
3728
3762
  */
@@ -4018,7 +4052,7 @@ interface WorkflowStreamEvent {
4018
4052
  /**
4019
4053
  * Current status of the step/event
4020
4054
  */
4021
- status: "pending" | "running" | "success" | "error" | "suspended";
4055
+ status: "pending" | "running" | "success" | "error" | "suspended" | "cancelled";
4022
4056
  /**
4023
4057
  * User context passed through the workflow
4024
4058
  */
@@ -4124,6 +4158,10 @@ declare class WorkflowTraceContext {
4124
4158
  * Record a suspension event on the workflow
4125
4159
  */
4126
4160
  recordSuspension(stepIndex: number, reason: string, suspendData?: any, checkpoint?: any): void;
4161
+ /**
4162
+ * Record a cancellation event on the workflow
4163
+ */
4164
+ recordCancellation(reason?: string): void;
4127
4165
  /**
4128
4166
  * Record a resume event on the workflow
4129
4167
  */
@@ -4147,16 +4185,17 @@ declare class WorkflowTraceContext {
4147
4185
  /**
4148
4186
  * End the root span with a status
4149
4187
  */
4150
- end(status: "completed" | "suspended" | "error", error?: Error | any): void;
4188
+ end(status: "completed" | "suspended" | "cancelled" | "error", error?: Error | any): void;
4151
4189
  /**
4152
4190
  * End a step span with proper status
4153
4191
  */
4154
- endStepSpan(span: Span, status: "completed" | "skipped" | "suspended" | "error", options?: {
4192
+ endStepSpan(span: Span, status: "completed" | "skipped" | "suspended" | "cancelled" | "error", options?: {
4155
4193
  output?: any;
4156
4194
  error?: Error | any;
4157
4195
  attributes?: Record<string, any>;
4158
4196
  skippedReason?: string;
4159
4197
  suspensionReason?: string;
4198
+ cancellationReason?: string;
4160
4199
  }): void;
4161
4200
  /**
4162
4201
  * Get the active context for manual context propagation
@@ -5382,16 +5421,7 @@ declare class WorkflowRegistry extends EventEmitter {
5382
5421
  /**
5383
5422
  * Resume a suspended workflow execution
5384
5423
  */
5385
- resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, resumeStepId?: string): Promise<{
5386
- executionId: string;
5387
- startAt: Date;
5388
- endAt: Date;
5389
- status: "completed" | "suspended" | "error";
5390
- result: any;
5391
- usage: UsageInfo;
5392
- suspension?: any;
5393
- error?: unknown;
5394
- } | null>;
5424
+ resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, resumeStepId?: string): Promise<WorkflowExecutionResult<any, any> | null>;
5395
5425
  /**
5396
5426
  * Get all suspended workflow executions
5397
5427
  */
package/dist/index.d.ts CHANGED
@@ -655,7 +655,7 @@ interface WorkflowStateEntry {
655
655
  /** Workflow name for reference */
656
656
  workflowName: string;
657
657
  /** Current status */
658
- status: "running" | "suspended" | "completed" | "error";
658
+ status: "running" | "suspended" | "completed" | "cancelled" | "error";
659
659
  /** Original input to the workflow */
660
660
  input?: unknown;
661
661
  /** Execution context */
@@ -3579,7 +3579,7 @@ declare class Agent {
3579
3579
  private createWorkingMemoryTools;
3580
3580
  }
3581
3581
 
3582
- type WorkflowStateStatus = "pending" | "running" | "completed" | "failed" | "suspended";
3582
+ type WorkflowStateStatus = "pending" | "running" | "completed" | "failed" | "suspended" | "cancelled";
3583
3583
  type WorkflowState<INPUT, RESULT> = {
3584
3584
  executionId: string;
3585
3585
  conversationId?: string;
@@ -3598,6 +3598,8 @@ type WorkflowState<INPUT, RESULT> = {
3598
3598
  error: Error | null;
3599
3599
  /** suspension metadata when workflow is suspended */
3600
3600
  suspension?: WorkflowSuspensionMetadata;
3601
+ /** cancellation metadata when workflow is cancelled */
3602
+ cancellation?: WorkflowCancellationMetadata;
3601
3603
  /** accumulated usage from andAgent calls */
3602
3604
  usage: UsageInfo;
3603
3605
  };
@@ -3621,6 +3623,12 @@ interface WorkflowSuspensionMetadata<SUSPEND_DATA = DangerouslyAllowAny> {
3621
3623
  completedStepsData?: DangerouslyAllowAny[];
3622
3624
  };
3623
3625
  }
3626
+ interface WorkflowCancellationMetadata {
3627
+ /** Timestamp when the workflow was cancelled */
3628
+ cancelledAt: Date;
3629
+ /** Reason for cancellation */
3630
+ reason?: string;
3631
+ }
3624
3632
  /**
3625
3633
  * Custom abort controller for workflow suspension with reason tracking
3626
3634
  */
@@ -3633,14 +3641,26 @@ interface WorkflowSuspendController {
3633
3641
  * Suspend the workflow with a reason
3634
3642
  */
3635
3643
  suspend: (reason?: string) => void;
3644
+ /**
3645
+ * Cancel the workflow with a reason
3646
+ */
3647
+ cancel: (reason?: string) => void;
3636
3648
  /**
3637
3649
  * Check if the workflow has been suspended
3638
3650
  */
3639
3651
  isSuspended: () => boolean;
3640
3652
  /**
3641
- * Get the suspension reason
3653
+ * Check if the workflow has been cancelled
3654
+ */
3655
+ isCancelled: () => boolean;
3656
+ /**
3657
+ * Get the suspension or cancellation reason
3642
3658
  */
3643
3659
  getReason: () => string | undefined;
3660
+ /**
3661
+ * Get the cancellation reason if cancellation was requested
3662
+ */
3663
+ getCancelReason: () => string | undefined;
3644
3664
  }
3645
3665
  /**
3646
3666
  * Base result interface shared by all workflow execution results
@@ -3665,7 +3685,7 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3665
3685
  /**
3666
3686
  * Current status of the workflow execution
3667
3687
  */
3668
- status: "completed" | "suspended" | "error" | Promise<"completed" | "suspended" | "error">;
3688
+ status: "completed" | "suspended" | "cancelled" | "error" | Promise<"completed" | "suspended" | "cancelled" | "error">;
3669
3689
  /**
3670
3690
  * The result data if workflow completed successfully
3671
3691
  */
@@ -3674,6 +3694,10 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3674
3694
  * Suspension metadata if workflow was suspended
3675
3695
  */
3676
3696
  suspension?: WorkflowSuspensionMetadata | Promise<WorkflowSuspensionMetadata | undefined>;
3697
+ /**
3698
+ * Cancellation metadata if workflow was cancelled
3699
+ */
3700
+ cancellation?: WorkflowCancellationMetadata | Promise<WorkflowCancellationMetadata | undefined>;
3677
3701
  /**
3678
3702
  * Error information if workflow failed
3679
3703
  */
@@ -3688,9 +3712,10 @@ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME
3688
3712
  */
3689
3713
  interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA> {
3690
3714
  endAt: Date;
3691
- status: "completed" | "suspended" | "error";
3715
+ status: "completed" | "suspended" | "cancelled" | "error";
3692
3716
  result: z.infer<RESULT_SCHEMA> | null;
3693
3717
  suspension?: WorkflowSuspensionMetadata;
3718
+ cancellation?: WorkflowCancellationMetadata;
3694
3719
  error?: unknown;
3695
3720
  usage: UsageInfo;
3696
3721
  /**
@@ -3709,9 +3734,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
3709
3734
  */
3710
3735
  interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA>, AsyncIterable<WorkflowStreamEvent> {
3711
3736
  endAt: Promise<Date>;
3712
- status: Promise<"completed" | "suspended" | "error">;
3737
+ status: Promise<"completed" | "suspended" | "cancelled" | "error">;
3713
3738
  result: Promise<z.infer<RESULT_SCHEMA> | null>;
3714
3739
  suspension: Promise<WorkflowSuspensionMetadata | undefined>;
3740
+ cancellation: Promise<WorkflowCancellationMetadata | undefined>;
3715
3741
  error: Promise<unknown | undefined>;
3716
3742
  usage: Promise<UsageInfo>;
3717
3743
  /**
@@ -3723,6 +3749,14 @@ interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA
3723
3749
  resume: (input: z.infer<RESUME_SCHEMA>, options?: {
3724
3750
  stepId?: string;
3725
3751
  }) => Promise<WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
3752
+ /**
3753
+ * Request workflow suspension
3754
+ */
3755
+ suspend: (reason?: string) => void;
3756
+ /**
3757
+ * Cancel the workflow execution
3758
+ */
3759
+ cancel: (reason?: string) => void;
3726
3760
  /**
3727
3761
  * Abort the workflow execution
3728
3762
  */
@@ -4018,7 +4052,7 @@ interface WorkflowStreamEvent {
4018
4052
  /**
4019
4053
  * Current status of the step/event
4020
4054
  */
4021
- status: "pending" | "running" | "success" | "error" | "suspended";
4055
+ status: "pending" | "running" | "success" | "error" | "suspended" | "cancelled";
4022
4056
  /**
4023
4057
  * User context passed through the workflow
4024
4058
  */
@@ -4124,6 +4158,10 @@ declare class WorkflowTraceContext {
4124
4158
  * Record a suspension event on the workflow
4125
4159
  */
4126
4160
  recordSuspension(stepIndex: number, reason: string, suspendData?: any, checkpoint?: any): void;
4161
+ /**
4162
+ * Record a cancellation event on the workflow
4163
+ */
4164
+ recordCancellation(reason?: string): void;
4127
4165
  /**
4128
4166
  * Record a resume event on the workflow
4129
4167
  */
@@ -4147,16 +4185,17 @@ declare class WorkflowTraceContext {
4147
4185
  /**
4148
4186
  * End the root span with a status
4149
4187
  */
4150
- end(status: "completed" | "suspended" | "error", error?: Error | any): void;
4188
+ end(status: "completed" | "suspended" | "cancelled" | "error", error?: Error | any): void;
4151
4189
  /**
4152
4190
  * End a step span with proper status
4153
4191
  */
4154
- endStepSpan(span: Span, status: "completed" | "skipped" | "suspended" | "error", options?: {
4192
+ endStepSpan(span: Span, status: "completed" | "skipped" | "suspended" | "cancelled" | "error", options?: {
4155
4193
  output?: any;
4156
4194
  error?: Error | any;
4157
4195
  attributes?: Record<string, any>;
4158
4196
  skippedReason?: string;
4159
4197
  suspensionReason?: string;
4198
+ cancellationReason?: string;
4160
4199
  }): void;
4161
4200
  /**
4162
4201
  * Get the active context for manual context propagation
@@ -5382,16 +5421,7 @@ declare class WorkflowRegistry extends EventEmitter {
5382
5421
  /**
5383
5422
  * Resume a suspended workflow execution
5384
5423
  */
5385
- resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, resumeStepId?: string): Promise<{
5386
- executionId: string;
5387
- startAt: Date;
5388
- endAt: Date;
5389
- status: "completed" | "suspended" | "error";
5390
- result: any;
5391
- usage: UsageInfo;
5392
- suspension?: any;
5393
- error?: unknown;
5394
- } | null>;
5424
+ resumeSuspendedWorkflow(workflowId: string, executionId: string, resumeData?: any, resumeStepId?: string): Promise<WorkflowExecutionResult<any, any> | null>;
5395
5425
  /**
5396
5426
  * Get all suspended workflow executions
5397
5427
  */