@voltagent/core 2.0.11 → 2.0.12

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
@@ -5689,9 +5689,10 @@ declare class Agent {
5689
5689
  */
5690
5690
  private calculateMaxSteps;
5691
5691
  /**
5692
- * Get the model name
5692
+ * Get the model name.
5693
+ * Pass a resolved model to return its modelId (useful for dynamic models).
5693
5694
  */
5694
- getModelName(): string;
5695
+ getModelName(model?: LanguageModel | string): string;
5695
5696
  /**
5696
5697
  * Get full agent state
5697
5698
  */
@@ -6822,6 +6823,7 @@ type ExtractExecuteResult<T> = T extends {
6822
6823
  type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOptions & {
6823
6824
  schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<INPUT, DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
6824
6825
  };
6826
+ type AgentResultMapper<INPUT, DATA, SCHEMA extends z.ZodTypeAny, RESULT> = (output: z.infer<SCHEMA>, context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<RESULT> | RESULT;
6825
6827
  /**
6826
6828
  * Creates an agent step for a workflow
6827
6829
  *
@@ -6843,15 +6845,16 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOpt
6843
6845
  * @param task - The task (prompt) to execute for the agent, can be a string or a function that returns a string
6844
6846
  * @param agent - The agent to execute the task using `generateText`
6845
6847
  * @param config - The config for the agent (schema) `generateText` call
6848
+ * @param map - Optional mapper to shape or merge the agent output with existing data
6846
6849
  * @returns A workflow step that executes the agent with the task
6847
6850
  */
6848
- declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>): {
6851
+ declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny, RESULT = z.infer<SCHEMA>>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>, map?: AgentResultMapper<INPUT, DATA, SCHEMA, RESULT>): {
6849
6852
  type: "agent";
6850
6853
  id: string;
6851
6854
  name: string;
6852
6855
  purpose: string | null;
6853
6856
  agent: Agent;
6854
- execute: (context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<z.TypeOf<SCHEMA>>;
6857
+ execute: (context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<RESULT>;
6855
6858
  };
6856
6859
 
6857
6860
  interface WorkflowStepAgent<INPUT, DATA, RESULT> extends InternalBaseWorkflowStep<INPUT, DATA, RESULT, any, any> {
@@ -7572,9 +7575,11 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7572
7575
  * @param task - The task (prompt) to execute for the agent, can be a string or a function that returns a string
7573
7576
  * @param agent - The agent to execute the task using `generateText`
7574
7577
  * @param config - The config for the agent (schema) `generateText` call
7578
+ * @param map - Optional mapper to shape or merge the agent output with existing data
7575
7579
  * @returns A workflow step that executes the agent with the task
7576
7580
  */
7577
7581
  andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7582
+ andAgent<SCHEMA extends z.ZodTypeAny, NEW_DATA>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>, map: (output: z.infer<SCHEMA>, context: WorkflowExecuteContext<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, any, any>) => Promise<NEW_DATA> | NEW_DATA): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7578
7583
  /**
7579
7584
  * Add a function step to the workflow with both input and output schemas
7580
7585
  * @param config - Step configuration with schemas
@@ -7591,12 +7596,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7591
7596
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7592
7597
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7593
7598
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7599
+ retryCount?: number;
7594
7600
  logger: Logger;
7595
7601
  writer: WorkflowStreamWriter;
7596
7602
  }) => Promise<z.infer<OS>>;
7597
7603
  id: string;
7598
7604
  name?: string;
7599
7605
  purpose?: string;
7606
+ retries?: number;
7600
7607
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7601
7608
  /**
7602
7609
  * Add a function step to the workflow with only input schema
@@ -7614,12 +7621,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7614
7621
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7615
7622
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7616
7623
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7624
+ retryCount?: number;
7617
7625
  logger: Logger;
7618
7626
  writer: WorkflowStreamWriter;
7619
7627
  }) => Promise<NEW_DATA>;
7620
7628
  id: string;
7621
7629
  name?: string;
7622
7630
  purpose?: string;
7631
+ retries?: number;
7623
7632
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7624
7633
  /**
7625
7634
  * Add a function step to the workflow with only output schema
@@ -7637,12 +7646,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7637
7646
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7638
7647
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7639
7648
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7649
+ retryCount?: number;
7640
7650
  logger: Logger;
7641
7651
  writer: WorkflowStreamWriter;
7642
7652
  }) => Promise<z.infer<OS>>;
7643
7653
  id: string;
7644
7654
  name?: string;
7645
7655
  purpose?: string;
7656
+ retries?: number;
7646
7657
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7647
7658
  /**
7648
7659
  * Add a function step to the workflow with only resumeSchema
@@ -7660,12 +7671,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7660
7671
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7661
7672
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7662
7673
  resumeData?: z.infer<RS>;
7674
+ retryCount?: number;
7663
7675
  logger: Logger;
7664
7676
  writer: WorkflowStreamWriter;
7665
7677
  }) => Promise<NEW_DATA>;
7666
7678
  id: string;
7667
7679
  name?: string;
7668
7680
  purpose?: string;
7681
+ retries?: number;
7669
7682
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7670
7683
  /**
7671
7684
  * Add a function step to the workflow
@@ -7699,12 +7712,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7699
7712
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7700
7713
  suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7701
7714
  resumeData?: z.infer<RESUME_SCHEMA>;
7715
+ retryCount?: number;
7702
7716
  logger: Logger;
7703
7717
  writer: WorkflowStreamWriter;
7704
7718
  }) => Promise<NEW_DATA>;
7705
7719
  id: string;
7706
7720
  name?: string;
7707
7721
  purpose?: string;
7722
+ retries?: number;
7708
7723
  inputSchema?: never;
7709
7724
  outputSchema?: never;
7710
7725
  suspendSchema?: z.ZodTypeAny;
@@ -7784,12 +7799,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7784
7799
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7785
7800
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7786
7801
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7802
+ retryCount?: number;
7787
7803
  logger: Logger;
7788
7804
  writer: WorkflowStreamWriter;
7789
7805
  }) => Promise<void>;
7790
7806
  id: string;
7791
7807
  name?: string;
7792
7808
  purpose?: string;
7809
+ retries?: number;
7793
7810
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, CURRENT_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7794
7811
  /**
7795
7812
  * Add a tap step to the workflow
@@ -7822,12 +7839,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7822
7839
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7823
7840
  suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7824
7841
  resumeData?: z.infer<RESUME_SCHEMA>;
7842
+ retryCount?: number;
7825
7843
  logger: Logger;
7826
7844
  writer: WorkflowStreamWriter;
7827
7845
  }) => Promise<void>;
7828
7846
  id: string;
7829
7847
  name?: string;
7830
7848
  purpose?: string;
7849
+ retries?: number;
7831
7850
  inputSchema?: never;
7832
7851
  suspendSchema?: z.ZodTypeAny;
7833
7852
  resumeSchema?: z.ZodTypeAny;
package/dist/index.d.ts CHANGED
@@ -5689,9 +5689,10 @@ declare class Agent {
5689
5689
  */
5690
5690
  private calculateMaxSteps;
5691
5691
  /**
5692
- * Get the model name
5692
+ * Get the model name.
5693
+ * Pass a resolved model to return its modelId (useful for dynamic models).
5693
5694
  */
5694
- getModelName(): string;
5695
+ getModelName(model?: LanguageModel | string): string;
5695
5696
  /**
5696
5697
  * Get full agent state
5697
5698
  */
@@ -6822,6 +6823,7 @@ type ExtractExecuteResult<T> = T extends {
6822
6823
  type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOptions & {
6823
6824
  schema: SCHEMA | ((context: Omit<WorkflowExecuteContext<INPUT, DATA, any, any>, "suspend" | "writer">) => SCHEMA | Promise<SCHEMA>);
6824
6825
  };
6826
+ type AgentResultMapper<INPUT, DATA, SCHEMA extends z.ZodTypeAny, RESULT> = (output: z.infer<SCHEMA>, context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<RESULT> | RESULT;
6825
6827
  /**
6826
6828
  * Creates an agent step for a workflow
6827
6829
  *
@@ -6843,15 +6845,16 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny, INPUT, DATA> = BaseGenerationOpt
6843
6845
  * @param task - The task (prompt) to execute for the agent, can be a string or a function that returns a string
6844
6846
  * @param agent - The agent to execute the task using `generateText`
6845
6847
  * @param config - The config for the agent (schema) `generateText` call
6848
+ * @param map - Optional mapper to shape or merge the agent output with existing data
6846
6849
  * @returns A workflow step that executes the agent with the task
6847
6850
  */
6848
- declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>): {
6851
+ declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny, RESULT = z.infer<SCHEMA>>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA, INPUT, DATA>, map?: AgentResultMapper<INPUT, DATA, SCHEMA, RESULT>): {
6849
6852
  type: "agent";
6850
6853
  id: string;
6851
6854
  name: string;
6852
6855
  purpose: string | null;
6853
6856
  agent: Agent;
6854
- execute: (context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<z.TypeOf<SCHEMA>>;
6857
+ execute: (context: WorkflowExecuteContext<INPUT, DATA, any, any>) => Promise<RESULT>;
6855
6858
  };
6856
6859
 
6857
6860
  interface WorkflowStepAgent<INPUT, DATA, RESULT> extends InternalBaseWorkflowStep<INPUT, DATA, RESULT, any, any> {
@@ -7572,9 +7575,11 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7572
7575
  * @param task - The task (prompt) to execute for the agent, can be a string or a function that returns a string
7573
7576
  * @param agent - The agent to execute the task using `generateText`
7574
7577
  * @param config - The config for the agent (schema) `generateText` call
7578
+ * @param map - Optional mapper to shape or merge the agent output with existing data
7575
7579
  * @returns A workflow step that executes the agent with the task
7576
7580
  */
7577
7581
  andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7582
+ andAgent<SCHEMA extends z.ZodTypeAny, NEW_DATA>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA, INPUT_SCHEMA, CURRENT_DATA>, map: (output: z.infer<SCHEMA>, context: WorkflowExecuteContext<WorkflowInput<INPUT_SCHEMA>, CURRENT_DATA, any, any>) => Promise<NEW_DATA> | NEW_DATA): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7578
7583
  /**
7579
7584
  * Add a function step to the workflow with both input and output schemas
7580
7585
  * @param config - Step configuration with schemas
@@ -7591,12 +7596,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7591
7596
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7592
7597
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7593
7598
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7599
+ retryCount?: number;
7594
7600
  logger: Logger;
7595
7601
  writer: WorkflowStreamWriter;
7596
7602
  }) => Promise<z.infer<OS>>;
7597
7603
  id: string;
7598
7604
  name?: string;
7599
7605
  purpose?: string;
7606
+ retries?: number;
7600
7607
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7601
7608
  /**
7602
7609
  * Add a function step to the workflow with only input schema
@@ -7614,12 +7621,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7614
7621
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7615
7622
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7616
7623
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7624
+ retryCount?: number;
7617
7625
  logger: Logger;
7618
7626
  writer: WorkflowStreamWriter;
7619
7627
  }) => Promise<NEW_DATA>;
7620
7628
  id: string;
7621
7629
  name?: string;
7622
7630
  purpose?: string;
7631
+ retries?: number;
7623
7632
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7624
7633
  /**
7625
7634
  * Add a function step to the workflow with only output schema
@@ -7637,12 +7646,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7637
7646
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7638
7647
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7639
7648
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7649
+ retryCount?: number;
7640
7650
  logger: Logger;
7641
7651
  writer: WorkflowStreamWriter;
7642
7652
  }) => Promise<z.infer<OS>>;
7643
7653
  id: string;
7644
7654
  name?: string;
7645
7655
  purpose?: string;
7656
+ retries?: number;
7646
7657
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7647
7658
  /**
7648
7659
  * Add a function step to the workflow with only resumeSchema
@@ -7660,12 +7671,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7660
7671
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7661
7672
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7662
7673
  resumeData?: z.infer<RS>;
7674
+ retryCount?: number;
7663
7675
  logger: Logger;
7664
7676
  writer: WorkflowStreamWriter;
7665
7677
  }) => Promise<NEW_DATA>;
7666
7678
  id: string;
7667
7679
  name?: string;
7668
7680
  purpose?: string;
7681
+ retries?: number;
7669
7682
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, NEW_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7670
7683
  /**
7671
7684
  * Add a function step to the workflow
@@ -7699,12 +7712,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7699
7712
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7700
7713
  suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7701
7714
  resumeData?: z.infer<RESUME_SCHEMA>;
7715
+ retryCount?: number;
7702
7716
  logger: Logger;
7703
7717
  writer: WorkflowStreamWriter;
7704
7718
  }) => Promise<NEW_DATA>;
7705
7719
  id: string;
7706
7720
  name?: string;
7707
7721
  purpose?: string;
7722
+ retries?: number;
7708
7723
  inputSchema?: never;
7709
7724
  outputSchema?: never;
7710
7725
  suspendSchema?: z.ZodTypeAny;
@@ -7784,12 +7799,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7784
7799
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7785
7800
  suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7786
7801
  resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
7802
+ retryCount?: number;
7787
7803
  logger: Logger;
7788
7804
  writer: WorkflowStreamWriter;
7789
7805
  }) => Promise<void>;
7790
7806
  id: string;
7791
7807
  name?: string;
7792
7808
  purpose?: string;
7809
+ retries?: number;
7793
7810
  }): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, CURRENT_DATA, SUSPEND_SCHEMA, RESUME_SCHEMA>;
7794
7811
  /**
7795
7812
  * Add a tap step to the workflow
@@ -7822,12 +7839,14 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
7822
7839
  getStepData: (stepId: string) => WorkflowStepData | undefined;
7823
7840
  suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
7824
7841
  resumeData?: z.infer<RESUME_SCHEMA>;
7842
+ retryCount?: number;
7825
7843
  logger: Logger;
7826
7844
  writer: WorkflowStreamWriter;
7827
7845
  }) => Promise<void>;
7828
7846
  id: string;
7829
7847
  name?: string;
7830
7848
  purpose?: string;
7849
+ retries?: number;
7831
7850
  inputSchema?: never;
7832
7851
  suspendSchema?: z.ZodTypeAny;
7833
7852
  resumeSchema?: z.ZodTypeAny;
package/dist/index.js CHANGED
@@ -399,7 +399,7 @@ function convertUsage(usage) {
399
399
  __name(convertUsage, "convertUsage");
400
400
 
401
401
  // src/workflow/steps/and-agent.ts
402
- function andAgent(task, agent, config) {
402
+ function andAgent(task, agent, config, map) {
403
403
  return {
404
404
  type: "agent",
405
405
  id: agent.id,
@@ -412,6 +412,12 @@ function andAgent(task, agent, config) {
412
412
  const finalTask = typeof task === "function" ? await task(context8) : task;
413
413
  const finalSchema = typeof schema === "function" ? await schema(context8) : schema;
414
414
  const output = import_ai.Output.object({ schema: finalSchema });
415
+ const mapOutput = /* @__PURE__ */ __name(async (outputValue) => {
416
+ if (map) {
417
+ return await map(outputValue, context8);
418
+ }
419
+ return outputValue;
420
+ }, "mapOutput");
415
421
  if (!state.workflowContext) {
416
422
  const result = await agent.generateText(finalTask, {
417
423
  ...restConfig,
@@ -433,7 +439,7 @@ function andAgent(task, agent, config) {
433
439
  }
434
440
  state.usage.totalTokens += convertedUsage?.totalTokens || 0;
435
441
  }
436
- return result.output;
442
+ return mapOutput(result.output);
437
443
  }
438
444
  try {
439
445
  const result = await agent.generateText(finalTask, {
@@ -457,7 +463,7 @@ function andAgent(task, agent, config) {
457
463
  }
458
464
  state.usage.totalTokens += convertedUsage?.totalTokens || 0;
459
465
  }
460
- return result.output;
466
+ return mapOutput(result.output);
461
467
  } catch (error) {
462
468
  if (error instanceof Error && (error.message === "WORKFLOW_SUSPENDED" || error.message === "WORKFLOW_CANCELLED")) {
463
469
  throw error;
@@ -9151,34 +9157,8 @@ var WorkflowChain = class {
9151
9157
  constructor(config) {
9152
9158
  this.config = config;
9153
9159
  }
9154
- /**
9155
- * Creates an agent step for a workflow
9156
- *
9157
- * @example
9158
- * ```ts
9159
- * const w = createWorkflowChain({
9160
- * id: "greeting-workflow",
9161
- * input: z.object({ name: z.string() }),
9162
- * result: z.string()
9163
- * })
9164
- * .andAgent(
9165
- * ({ data }) => `Generate a greeting for the user ${data.name}`,
9166
- * agent,
9167
- * { schema: z.object({ greeting: z.string() }) }
9168
- * )
9169
- * .andThen({
9170
- * id: "extract-greeting",
9171
- * execute: async ({ data }) => data.greeting
9172
- * })
9173
- * ```
9174
- *
9175
- * @param task - The task (prompt) to execute for the agent, can be a string or a function that returns a string
9176
- * @param agent - The agent to execute the task using `generateText`
9177
- * @param config - The config for the agent (schema) `generateText` call
9178
- * @returns A workflow step that executes the agent with the task
9179
- */
9180
- andAgent(task, agent, config) {
9181
- const step = andAgent(task, agent, config);
9160
+ andAgent(task, agent, config, map) {
9161
+ const step = andAgent(task, agent, config, map);
9182
9162
  this.steps.push(step);
9183
9163
  return this;
9184
9164
  }
@@ -19515,7 +19495,7 @@ var Agent = class {
19515
19495
  oc,
19516
19496
  options
19517
19497
  );
19518
- const modelName = this.getModelName();
19498
+ const modelName = this.getModelName(model);
19519
19499
  const contextLimit = options?.contextLimit;
19520
19500
  addModelAttributesToSpan(
19521
19501
  rootSpan,
@@ -19837,7 +19817,7 @@ var Agent = class {
19837
19817
  oc,
19838
19818
  options
19839
19819
  );
19840
- const modelName = this.getModelName();
19820
+ const modelName = this.getModelName(model);
19841
19821
  const contextLimit = options?.contextLimit;
19842
19822
  if (oc.traceContext) {
19843
19823
  const rootSpan2 = oc.traceContext.getRootSpan();
@@ -19942,7 +19922,7 @@ var Agent = class {
19942
19922
  methodLogger.error("Stream error occurred", {
19943
19923
  error: actualError,
19944
19924
  agentName: this.name,
19945
- modelName: this.getModelName()
19925
+ modelName
19946
19926
  });
19947
19927
  finalizeLLMSpan(import_api15.SpanStatusCode.ERROR, { message: actualError?.message });
19948
19928
  this.getMergedHooks(options).onError?.({
@@ -20361,7 +20341,7 @@ var Agent = class {
20361
20341
  oc,
20362
20342
  options
20363
20343
  );
20364
- const modelName = this.getModelName();
20344
+ const modelName = this.getModelName(model);
20365
20345
  const schemaName = schema.description || "unknown";
20366
20346
  addModelAttributesToSpan(
20367
20347
  rootSpan,
@@ -20546,7 +20526,7 @@ var Agent = class {
20546
20526
  oc,
20547
20527
  options
20548
20528
  );
20549
- const modelName = this.getModelName();
20529
+ const modelName = this.getModelName(model);
20550
20530
  const schemaName = schema.description || "unknown";
20551
20531
  addModelAttributesToSpan(
20552
20532
  rootSpan,
@@ -20617,7 +20597,7 @@ var Agent = class {
20617
20597
  methodLogger.error("Stream object error occurred", {
20618
20598
  error: actualError,
20619
20599
  agentName: this.name,
20620
- modelName: this.getModelName(),
20600
+ modelName,
20621
20601
  schemaName
20622
20602
  });
20623
20603
  this.getMergedHooks(options).onError?.({
@@ -22246,9 +22226,16 @@ ${retrieverContext}`;
22246
22226
  return this.subAgentManager.calculateMaxSteps(this.maxSteps);
22247
22227
  }
22248
22228
  /**
22249
- * Get the model name
22229
+ * Get the model name.
22230
+ * Pass a resolved model to return its modelId (useful for dynamic models).
22250
22231
  */
22251
- getModelName() {
22232
+ getModelName(model) {
22233
+ if (model) {
22234
+ if (typeof model === "string") {
22235
+ return model;
22236
+ }
22237
+ return model.modelId || "unknown";
22238
+ }
22252
22239
  if (typeof this.model === "function") {
22253
22240
  return "dynamic";
22254
22241
  }