@voltagent/core 0.1.80 → 0.1.82

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
@@ -271,7 +271,7 @@ interface WorkflowExecuteContext<INPUT, DATA, SUSPEND_DATA, RESUME_DATA> {
271
271
  logger: Logger;
272
272
  /**
273
273
  * Stream writer for emitting events during streaming execution.
274
- * Always available for writing custom events.
274
+ * Always available - uses NoOpWorkflowStreamWriter when not streaming
275
275
  */
276
276
  writer: WorkflowStreamWriter;
277
277
  }
@@ -421,9 +421,9 @@ interface WorkflowSuspendController {
421
421
  getReason: () => string | undefined;
422
422
  }
423
423
  /**
424
- * Result returned from workflow execution with suspend/resume capabilities
424
+ * Base result interface shared by all workflow execution results
425
425
  */
426
- interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> {
426
+ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> {
427
427
  /**
428
428
  * Unique execution ID for this workflow run
429
429
  */
@@ -439,30 +439,37 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
439
439
  /**
440
440
  * When the workflow execution ended (completed, suspended, or errored)
441
441
  */
442
- endAt: Date;
442
+ endAt: Date | Promise<Date>;
443
443
  /**
444
444
  * Current status of the workflow execution
445
445
  */
446
- status: "completed" | "suspended" | "error";
446
+ status: "completed" | "suspended" | "error" | Promise<"completed" | "suspended" | "error">;
447
447
  /**
448
448
  * The result data if workflow completed successfully
449
449
  */
450
- result: z.infer<RESULT_SCHEMA> | null;
451
- /**
452
- * Stream of workflow events for real-time monitoring
453
- */
454
- stream: AsyncIterableIterator<WorkflowStreamEvent>;
450
+ result: z.infer<RESULT_SCHEMA> | null | Promise<z.infer<RESULT_SCHEMA> | null>;
455
451
  /**
456
452
  * Suspension metadata if workflow was suspended
457
453
  */
458
- suspension?: WorkflowSuspensionMetadata;
454
+ suspension?: WorkflowSuspensionMetadata | Promise<WorkflowSuspensionMetadata | undefined>;
459
455
  /**
460
456
  * Error information if workflow failed
461
457
  */
462
- error?: unknown;
458
+ error?: unknown | Promise<unknown | undefined>;
463
459
  /**
464
460
  * Total token usage from all andAgent steps in the workflow
465
461
  */
462
+ usage: UsageInfo | Promise<UsageInfo>;
463
+ }
464
+ /**
465
+ * Result returned from workflow execution with suspend/resume capabilities
466
+ */
467
+ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA> {
468
+ endAt: Date;
469
+ status: "completed" | "suspended" | "error";
470
+ result: z.infer<RESULT_SCHEMA> | null;
471
+ suspension?: WorkflowSuspensionMetadata;
472
+ error?: unknown;
466
473
  usage: UsageInfo;
467
474
  /**
468
475
  * Resume a suspended workflow execution
@@ -474,6 +481,31 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
474
481
  stepId?: string;
475
482
  }) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
476
483
  }
484
+ /**
485
+ * Result returned from workflow stream execution
486
+ * Extends base with streaming capabilities and promise-based fields
487
+ */
488
+ interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA>, AsyncIterable<WorkflowStreamEvent> {
489
+ endAt: Promise<Date>;
490
+ status: Promise<"completed" | "suspended" | "error">;
491
+ result: Promise<z.infer<RESULT_SCHEMA> | null>;
492
+ suspension: Promise<WorkflowSuspensionMetadata | undefined>;
493
+ error: Promise<unknown | undefined>;
494
+ usage: Promise<UsageInfo>;
495
+ /**
496
+ * Resume a suspended workflow execution
497
+ * @param input - Optional new input data for resuming (validated against resumeSchema if provided)
498
+ * @param options - Optional options for resuming, including stepId to resume from a specific step
499
+ * @returns A new stream result that can also be resumed if suspended again
500
+ */
501
+ resume: (input: z.infer<RESUME_SCHEMA>, options?: {
502
+ stepId?: string;
503
+ }) => Promise<WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
504
+ /**
505
+ * Abort the workflow execution
506
+ */
507
+ abort: () => void;
508
+ }
477
509
  interface WorkflowRunOptions {
478
510
  /**
479
511
  * The active step, this can be used to track the current step in a workflow
@@ -666,9 +698,16 @@ type Workflow<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEM
666
698
  * Execute the workflow with the given input
667
699
  * @param input - The input to the workflow
668
700
  * @param options - Options for the workflow execution
669
- * @returns Execution result with stream and final result
701
+ * @returns Execution result with final result
670
702
  */
671
703
  run: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
704
+ /**
705
+ * Execute the workflow with streaming support
706
+ * @param input - The input to the workflow
707
+ * @param options - Options for the workflow execution
708
+ * @returns Stream result with real-time events and promise-based fields
709
+ */
710
+ stream: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>;
672
711
  /**
673
712
  * Create a WorkflowSuspendController that can be used to suspend the workflow
674
713
  * @returns A WorkflowSuspendController instance
@@ -934,7 +973,7 @@ interface WorkflowExecutionContext {
934
973
  logger: Logger;
935
974
  /**
936
975
  * Stream writer for emitting events during streaming execution
937
- * Always available for writing custom events
976
+ * Always available - uses NoOpWorkflowStreamWriter when not streaming
938
977
  */
939
978
  streamWriter: WorkflowStreamWriter;
940
979
  }
@@ -5013,12 +5052,20 @@ declare class Agent<TProvider extends {
5013
5052
  */
5014
5053
  isTelemetryConfigured(): boolean;
5015
5054
  /**
5055
+ * Add tools or toolkits to the agent dynamically.
5056
+ * @param tools Array of tools or toolkits to add to the agent
5057
+ * @returns Object containing added tools
5058
+ */
5059
+ addTools(tools: (Tool<any, any> | Toolkit)[]): {
5060
+ added: (Tool<any, any> | Toolkit)[];
5061
+ };
5062
+ /**
5063
+ * @deprecated Use addTools() instead. This method will be removed in a future version.
5016
5064
  * Add one or more tools or toolkits to the agent.
5017
- * Delegates to ToolManager's addItems method.
5018
- * @returns Object containing added items (difficult to track precisely here, maybe simplify return)
5065
+ * @returns Object containing added items
5019
5066
  */
5020
- addItems(items: (Tool<any> | Toolkit)[]): {
5021
- added: (Tool<any> | Toolkit)[];
5067
+ addItems(items: (Tool<any, any> | Toolkit)[]): {
5068
+ added: (Tool<any, any> | Toolkit)[];
5022
5069
  };
5023
5070
  /**
5024
5071
  * @internal
@@ -5946,6 +5993,10 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
5946
5993
  * Execute the workflow with the given input
5947
5994
  */
5948
5995
  run(input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions): Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
5996
+ /**
5997
+ * Execute the workflow with streaming support
5998
+ */
5999
+ stream(input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions): WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>;
5949
6000
  }
5950
6001
  /**
5951
6002
  * Creates a new workflow chain with the given configuration
@@ -6241,7 +6292,6 @@ declare class WorkflowRegistry extends EventEmitter {
6241
6292
  endAt: Date;
6242
6293
  status: "completed" | "suspended" | "error";
6243
6294
  result: any;
6244
- stream: AsyncIterableIterator<WorkflowStreamEvent>;
6245
6295
  usage: UsageInfo;
6246
6296
  suspension?: any;
6247
6297
  error?: unknown;
package/dist/index.d.ts CHANGED
@@ -271,7 +271,7 @@ interface WorkflowExecuteContext<INPUT, DATA, SUSPEND_DATA, RESUME_DATA> {
271
271
  logger: Logger;
272
272
  /**
273
273
  * Stream writer for emitting events during streaming execution.
274
- * Always available for writing custom events.
274
+ * Always available - uses NoOpWorkflowStreamWriter when not streaming
275
275
  */
276
276
  writer: WorkflowStreamWriter;
277
277
  }
@@ -421,9 +421,9 @@ interface WorkflowSuspendController {
421
421
  getReason: () => string | undefined;
422
422
  }
423
423
  /**
424
- * Result returned from workflow execution with suspend/resume capabilities
424
+ * Base result interface shared by all workflow execution results
425
425
  */
426
- interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> {
426
+ interface WorkflowExecutionResultBase<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> {
427
427
  /**
428
428
  * Unique execution ID for this workflow run
429
429
  */
@@ -439,30 +439,37 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
439
439
  /**
440
440
  * When the workflow execution ended (completed, suspended, or errored)
441
441
  */
442
- endAt: Date;
442
+ endAt: Date | Promise<Date>;
443
443
  /**
444
444
  * Current status of the workflow execution
445
445
  */
446
- status: "completed" | "suspended" | "error";
446
+ status: "completed" | "suspended" | "error" | Promise<"completed" | "suspended" | "error">;
447
447
  /**
448
448
  * The result data if workflow completed successfully
449
449
  */
450
- result: z.infer<RESULT_SCHEMA> | null;
451
- /**
452
- * Stream of workflow events for real-time monitoring
453
- */
454
- stream: AsyncIterableIterator<WorkflowStreamEvent>;
450
+ result: z.infer<RESULT_SCHEMA> | null | Promise<z.infer<RESULT_SCHEMA> | null>;
455
451
  /**
456
452
  * Suspension metadata if workflow was suspended
457
453
  */
458
- suspension?: WorkflowSuspensionMetadata;
454
+ suspension?: WorkflowSuspensionMetadata | Promise<WorkflowSuspensionMetadata | undefined>;
459
455
  /**
460
456
  * Error information if workflow failed
461
457
  */
462
- error?: unknown;
458
+ error?: unknown | Promise<unknown | undefined>;
463
459
  /**
464
460
  * Total token usage from all andAgent steps in the workflow
465
461
  */
462
+ usage: UsageInfo | Promise<UsageInfo>;
463
+ }
464
+ /**
465
+ * Result returned from workflow execution with suspend/resume capabilities
466
+ */
467
+ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA> {
468
+ endAt: Date;
469
+ status: "completed" | "suspended" | "error";
470
+ result: z.infer<RESULT_SCHEMA> | null;
471
+ suspension?: WorkflowSuspensionMetadata;
472
+ error?: unknown;
466
473
  usage: UsageInfo;
467
474
  /**
468
475
  * Resume a suspended workflow execution
@@ -474,6 +481,31 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
474
481
  stepId?: string;
475
482
  }) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
476
483
  }
484
+ /**
485
+ * Result returned from workflow stream execution
486
+ * Extends base with streaming capabilities and promise-based fields
487
+ */
488
+ interface WorkflowStreamResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> extends WorkflowExecutionResultBase<RESULT_SCHEMA, RESUME_SCHEMA>, AsyncIterable<WorkflowStreamEvent> {
489
+ endAt: Promise<Date>;
490
+ status: Promise<"completed" | "suspended" | "error">;
491
+ result: Promise<z.infer<RESULT_SCHEMA> | null>;
492
+ suspension: Promise<WorkflowSuspensionMetadata | undefined>;
493
+ error: Promise<unknown | undefined>;
494
+ usage: Promise<UsageInfo>;
495
+ /**
496
+ * Resume a suspended workflow execution
497
+ * @param input - Optional new input data for resuming (validated against resumeSchema if provided)
498
+ * @param options - Optional options for resuming, including stepId to resume from a specific step
499
+ * @returns A new stream result that can also be resumed if suspended again
500
+ */
501
+ resume: (input: z.infer<RESUME_SCHEMA>, options?: {
502
+ stepId?: string;
503
+ }) => Promise<WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
504
+ /**
505
+ * Abort the workflow execution
506
+ */
507
+ abort: () => void;
508
+ }
477
509
  interface WorkflowRunOptions {
478
510
  /**
479
511
  * The active step, this can be used to track the current step in a workflow
@@ -666,9 +698,16 @@ type Workflow<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEM
666
698
  * Execute the workflow with the given input
667
699
  * @param input - The input to the workflow
668
700
  * @param options - Options for the workflow execution
669
- * @returns Execution result with stream and final result
701
+ * @returns Execution result with final result
670
702
  */
671
703
  run: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
704
+ /**
705
+ * Execute the workflow with streaming support
706
+ * @param input - The input to the workflow
707
+ * @param options - Options for the workflow execution
708
+ * @returns Stream result with real-time events and promise-based fields
709
+ */
710
+ stream: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>;
672
711
  /**
673
712
  * Create a WorkflowSuspendController that can be used to suspend the workflow
674
713
  * @returns A WorkflowSuspendController instance
@@ -934,7 +973,7 @@ interface WorkflowExecutionContext {
934
973
  logger: Logger;
935
974
  /**
936
975
  * Stream writer for emitting events during streaming execution
937
- * Always available for writing custom events
976
+ * Always available - uses NoOpWorkflowStreamWriter when not streaming
938
977
  */
939
978
  streamWriter: WorkflowStreamWriter;
940
979
  }
@@ -5013,12 +5052,20 @@ declare class Agent<TProvider extends {
5013
5052
  */
5014
5053
  isTelemetryConfigured(): boolean;
5015
5054
  /**
5055
+ * Add tools or toolkits to the agent dynamically.
5056
+ * @param tools Array of tools or toolkits to add to the agent
5057
+ * @returns Object containing added tools
5058
+ */
5059
+ addTools(tools: (Tool<any, any> | Toolkit)[]): {
5060
+ added: (Tool<any, any> | Toolkit)[];
5061
+ };
5062
+ /**
5063
+ * @deprecated Use addTools() instead. This method will be removed in a future version.
5016
5064
  * Add one or more tools or toolkits to the agent.
5017
- * Delegates to ToolManager's addItems method.
5018
- * @returns Object containing added items (difficult to track precisely here, maybe simplify return)
5065
+ * @returns Object containing added items
5019
5066
  */
5020
- addItems(items: (Tool<any> | Toolkit)[]): {
5021
- added: (Tool<any> | Toolkit)[];
5067
+ addItems(items: (Tool<any, any> | Toolkit)[]): {
5068
+ added: (Tool<any, any> | Toolkit)[];
5022
5069
  };
5023
5070
  /**
5024
5071
  * @internal
@@ -5946,6 +5993,10 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
5946
5993
  * Execute the workflow with the given input
5947
5994
  */
5948
5995
  run(input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions): Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
5996
+ /**
5997
+ * Execute the workflow with streaming support
5998
+ */
5999
+ stream(input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions): WorkflowStreamResult<RESULT_SCHEMA, RESUME_SCHEMA>;
5949
6000
  }
5950
6001
  /**
5951
6002
  * Creates a new workflow chain with the given configuration
@@ -6241,7 +6292,6 @@ declare class WorkflowRegistry extends EventEmitter {
6241
6292
  endAt: Date;
6242
6293
  status: "completed" | "suspended" | "error";
6243
6294
  result: any;
6244
- stream: AsyncIterableIterator<WorkflowStreamEvent>;
6245
6295
  usage: UsageInfo;
6246
6296
  suspension?: any;
6247
6297
  error?: unknown;