@voltagent/core 1.1.15 → 1.1.17

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