@mastra/client-js 0.1.23-alpha.0 → 0.2.0-alpha.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/index.d.cts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
+ import { ServerInfo, ServerDetailInfo } from '@mastra/core/mcp';
2
3
  import { processDataStream } from '@ai-sdk/ui-utils';
3
- import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, VNextWorkflowRuns, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
4
+ import { CoreMessage, AiMessageType, StorageThreadType, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
4
5
  import { JSONSchema7 } from 'json-schema';
5
6
  import { ZodSchema } from 'zod';
7
+ import { BaseLogMessage } from '@mastra/core/logger';
6
8
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
7
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
8
- import { ServerInfo, ServerDetailInfo } from '@mastra/core/mcp';
9
- import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
10
- import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/di';
10
+ import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
11
+ import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
11
12
  import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
12
13
 
13
14
  interface ClientOptions {
@@ -46,13 +47,13 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
46
47
  messages: string | string[] | CoreMessage[] | AiMessageType[];
47
48
  output?: T;
48
49
  experimental_output?: T;
49
- runtimeContext?: RuntimeContext;
50
+ runtimeContext?: RuntimeContext | Record<string, any>;
50
51
  } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
51
52
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
52
53
  messages: string | string[] | CoreMessage[] | AiMessageType[];
53
54
  output?: T;
54
55
  experimental_output?: T;
55
- runtimeContext?: RuntimeContext;
56
+ runtimeContext?: RuntimeContext | Record<string, any>;
56
57
  } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
57
58
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
58
59
  evals: any[];
@@ -66,7 +67,7 @@ interface GetToolResponse {
66
67
  inputSchema: string;
67
68
  outputSchema: string;
68
69
  }
69
- interface GetWorkflowResponse {
70
+ interface GetLegacyWorkflowResponse {
70
71
  name: string;
71
72
  triggerSchema: string;
72
73
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -81,20 +82,21 @@ interface GetWorkflowRunsParams {
81
82
  offset?: number;
82
83
  resourceId?: string;
83
84
  }
85
+ type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
84
86
  type GetWorkflowRunsResponse = WorkflowRuns;
85
- type GetVNextWorkflowRunsResponse = VNextWorkflowRuns;
86
- type WorkflowRunResult = {
87
+ type LegacyWorkflowRunResult = {
87
88
  activePaths: Record<string, {
88
89
  status: string;
89
90
  suspendPayload?: any;
90
91
  stepPath: string[];
91
92
  }>;
92
- results: WorkflowRunResult$1<any, any, any>['results'];
93
+ results: LegacyWorkflowRunResult$1<any, any, any>['results'];
93
94
  timestamp: number;
94
95
  runId: string;
95
96
  };
96
- interface GetVNextWorkflowResponse {
97
+ interface GetWorkflowResponse {
97
98
  name: string;
99
+ description?: string;
98
100
  steps: {
99
101
  [key: string]: {
100
102
  id: string;
@@ -105,14 +107,14 @@ interface GetVNextWorkflowResponse {
105
107
  suspendSchema: string;
106
108
  };
107
109
  };
108
- stepGraph: NewWorkflow['serializedStepGraph'];
110
+ stepGraph: Workflow$1['serializedStepGraph'];
109
111
  inputSchema: string;
110
112
  outputSchema: string;
111
113
  }
112
- type VNextWorkflowWatchResult = WatchEvent & {
114
+ type WorkflowWatchResult = WatchEvent & {
113
115
  runId: string;
114
116
  };
115
- type VNextWorkflowRunResult = WorkflowResult<any, any>;
117
+ type WorkflowRunResult = WorkflowResult<any, any>;
116
118
  interface UpsertVectorParams {
117
119
  indexName: string;
118
120
  vectors: number[][];
@@ -339,7 +341,7 @@ declare class Agent extends BaseResource {
339
341
  */
340
342
  executeTool(toolId: string, params: {
341
343
  data: any;
342
- runtimeContext?: RuntimeContext$1;
344
+ runtimeContext?: RuntimeContext;
343
345
  }): Promise<any>;
344
346
  /**
345
347
  * Retrieves evaluation results for the agent
@@ -453,29 +455,22 @@ declare class Vector extends BaseResource {
453
455
  query(params: QueryVectorParams): Promise<QueryVectorResponse>;
454
456
  }
455
457
 
456
- declare class Workflow extends BaseResource {
458
+ declare class LegacyWorkflow extends BaseResource {
457
459
  private workflowId;
458
460
  constructor(options: ClientOptions, workflowId: string);
459
461
  /**
460
- * Retrieves details about the workflow
461
- * @returns Promise containing workflow details including steps and graphs
462
+ * Retrieves details about the legacy workflow
463
+ * @returns Promise containing legacy workflow details including steps and graphs
462
464
  */
463
- details(): Promise<GetWorkflowResponse>;
465
+ details(): Promise<GetLegacyWorkflowResponse>;
464
466
  /**
465
- * Retrieves all runs for a workflow
467
+ * Retrieves all runs for a legacy workflow
466
468
  * @param params - Parameters for filtering runs
467
- * @returns Promise containing workflow runs array
468
- */
469
- runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
470
- /**
471
- * @deprecated Use `startAsync` instead
472
- * Executes the workflow with the provided parameters
473
- * @param params - Parameters required for workflow execution
474
- * @returns Promise containing the workflow execution results
469
+ * @returns Promise containing legacy workflow runs array
475
470
  */
476
- execute(params: Record<string, any>): Promise<WorkflowRunResult>;
471
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
477
472
  /**
478
- * Creates a new workflow run
473
+ * Creates a new legacy workflow run
479
474
  * @returns Promise containing the generated run ID
480
475
  */
481
476
  createRun(params?: {
@@ -484,7 +479,7 @@ declare class Workflow extends BaseResource {
484
479
  runId: string;
485
480
  }>;
486
481
  /**
487
- * Starts a workflow run synchronously without waiting for the workflow to complete
482
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
488
483
  * @param params - Object containing the runId and triggerData
489
484
  * @returns Promise containing success message
490
485
  */
@@ -495,11 +490,11 @@ declare class Workflow extends BaseResource {
495
490
  message: string;
496
491
  }>;
497
492
  /**
498
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
493
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
499
494
  * @param stepId - ID of the step to resume
500
- * @param runId - ID of the workflow run
501
- * @param context - Context to resume the workflow with
502
- * @returns Promise containing the workflow resume results
495
+ * @param runId - ID of the legacy workflow run
496
+ * @param context - Context to resume the legacy workflow with
497
+ * @returns Promise containing the legacy workflow resume results
503
498
  */
504
499
  resume({ stepId, runId, context, }: {
505
500
  stepId: string;
@@ -516,9 +511,9 @@ declare class Workflow extends BaseResource {
516
511
  startAsync(params: {
517
512
  runId?: string;
518
513
  triggerData: Record<string, any>;
519
- }): Promise<WorkflowRunResult>;
514
+ }): Promise<LegacyWorkflowRunResult>;
520
515
  /**
521
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
516
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
522
517
  * @param params - Object containing the runId, stepId, and context
523
518
  * @returns Promise containing the workflow resume results
524
519
  */
@@ -526,7 +521,7 @@ declare class Workflow extends BaseResource {
526
521
  runId: string;
527
522
  stepId: string;
528
523
  context: Record<string, any>;
529
- }): Promise<WorkflowRunResult>;
524
+ }): Promise<LegacyWorkflowRunResult>;
530
525
  /**
531
526
  * Creates an async generator that processes a readable stream and yields records
532
527
  * separated by the Record Separator character (\x1E)
@@ -536,13 +531,13 @@ declare class Workflow extends BaseResource {
536
531
  */
537
532
  private streamProcessor;
538
533
  /**
539
- * Watches workflow transitions in real-time
534
+ * Watches legacy workflow transitions in real-time
540
535
  * @param runId - Optional run ID to filter the watch stream
541
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
536
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
542
537
  */
543
538
  watch({ runId }: {
544
539
  runId?: string;
545
- }, onRecord: (record: WorkflowRunResult) => void): Promise<void>;
540
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
546
541
  }
547
542
 
548
543
  declare class Tool extends BaseResource {
@@ -561,15 +556,15 @@ declare class Tool extends BaseResource {
561
556
  execute(params: {
562
557
  data: any;
563
558
  runId?: string;
564
- runtimeContext?: RuntimeContext$1;
559
+ runtimeContext?: RuntimeContext | Record<string, any>;
565
560
  }): Promise<any>;
566
561
  }
567
562
 
568
- declare class VNextWorkflow extends BaseResource {
563
+ declare class Workflow extends BaseResource {
569
564
  private workflowId;
570
565
  constructor(options: ClientOptions, workflowId: string);
571
566
  /**
572
- * Creates an async generator that processes a readable stream and yields vNext workflow records
567
+ * Creates an async generator that processes a readable stream and yields workflow records
573
568
  * separated by the Record Separator character (\x1E)
574
569
  *
575
570
  * @param stream - The readable stream to process
@@ -577,18 +572,18 @@ declare class VNextWorkflow extends BaseResource {
577
572
  */
578
573
  private streamProcessor;
579
574
  /**
580
- * Retrieves details about the vNext workflow
581
- * @returns Promise containing vNext workflow details including steps and graphs
575
+ * Retrieves details about the workflow
576
+ * @returns Promise containing workflow details including steps and graphs
582
577
  */
583
- details(): Promise<GetVNextWorkflowResponse>;
578
+ details(): Promise<GetWorkflowResponse>;
584
579
  /**
585
- * Retrieves all runs for a vNext workflow
580
+ * Retrieves all runs for a workflow
586
581
  * @param params - Parameters for filtering runs
587
- * @returns Promise containing vNext workflow runs array
582
+ * @returns Promise containing workflow runs array
588
583
  */
589
- runs(params?: GetWorkflowRunsParams): Promise<GetVNextWorkflowRunsResponse>;
584
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
590
585
  /**
591
- * Creates a new vNext workflow run
586
+ * Creates a new workflow run
592
587
  * @param params - Optional object containing the optional runId
593
588
  * @returns Promise containing the runId of the created run
594
589
  */
@@ -598,19 +593,19 @@ declare class VNextWorkflow extends BaseResource {
598
593
  runId: string;
599
594
  }>;
600
595
  /**
601
- * Starts a vNext workflow run synchronously without waiting for the workflow to complete
596
+ * Starts a workflow run synchronously without waiting for the workflow to complete
602
597
  * @param params - Object containing the runId, inputData and runtimeContext
603
598
  * @returns Promise containing success message
604
599
  */
605
600
  start(params: {
606
601
  runId: string;
607
602
  inputData: Record<string, any>;
608
- runtimeContext?: RuntimeContext;
603
+ runtimeContext?: RuntimeContext | Record<string, any>;
609
604
  }): Promise<{
610
605
  message: string;
611
606
  }>;
612
607
  /**
613
- * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
608
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
614
609
  * @param params - Object containing the runId, step, resumeData and runtimeContext
615
610
  * @returns Promise containing success message
616
611
  */
@@ -618,39 +613,39 @@ declare class VNextWorkflow extends BaseResource {
618
613
  step: string | string[];
619
614
  runId: string;
620
615
  resumeData?: Record<string, any>;
621
- runtimeContext?: RuntimeContext;
616
+ runtimeContext?: RuntimeContext | Record<string, any>;
622
617
  }): Promise<{
623
618
  message: string;
624
619
  }>;
625
620
  /**
626
- * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
621
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
627
622
  * @param params - Object containing the optional runId, inputData and runtimeContext
628
- * @returns Promise containing the vNext workflow execution results
623
+ * @returns Promise containing the workflow execution results
629
624
  */
630
625
  startAsync(params: {
631
626
  runId?: string;
632
627
  inputData: Record<string, any>;
633
- runtimeContext?: RuntimeContext;
634
- }): Promise<VNextWorkflowRunResult>;
628
+ runtimeContext?: RuntimeContext | Record<string, any>;
629
+ }): Promise<WorkflowRunResult>;
635
630
  /**
636
- * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
631
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
637
632
  * @param params - Object containing the runId, step, resumeData and runtimeContext
638
- * @returns Promise containing the vNext workflow resume results
633
+ * @returns Promise containing the workflow resume results
639
634
  */
640
635
  resumeAsync(params: {
641
636
  runId: string;
642
637
  step: string | string[];
643
638
  resumeData?: Record<string, any>;
644
- runtimeContext?: RuntimeContext;
645
- }): Promise<VNextWorkflowRunResult>;
639
+ runtimeContext?: RuntimeContext | Record<string, any>;
640
+ }): Promise<WorkflowRunResult>;
646
641
  /**
647
- * Watches vNext workflow transitions in real-time
642
+ * Watches workflow transitions in real-time
648
643
  * @param runId - Optional run ID to filter the watch stream
649
- * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
644
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
650
645
  */
651
646
  watch({ runId }: {
652
647
  runId?: string;
653
- }, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
648
+ }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
654
649
  }
655
650
 
656
651
  /**
@@ -776,6 +771,17 @@ declare class MastraClient extends BaseResource {
776
771
  * @returns Tool instance
777
772
  */
778
773
  getTool(toolId: string): Tool;
774
+ /**
775
+ * Retrieves all available legacy workflows
776
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
777
+ */
778
+ getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
779
+ /**
780
+ * Gets a legacy workflow instance by ID
781
+ * @param workflowId - ID of the legacy workflow to retrieve
782
+ * @returns Legacy Workflow instance
783
+ */
784
+ getLegacyWorkflow(workflowId: string): LegacyWorkflow;
779
785
  /**
780
786
  * Retrieves all available workflows
781
787
  * @returns Promise containing map of workflow IDs to workflow details
@@ -787,17 +793,6 @@ declare class MastraClient extends BaseResource {
787
793
  * @returns Workflow instance
788
794
  */
789
795
  getWorkflow(workflowId: string): Workflow;
790
- /**
791
- * Retrieves all available vNext workflows
792
- * @returns Promise containing map of vNext workflow IDs to vNext workflow details
793
- */
794
- getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
795
- /**
796
- * Gets a vNext workflow instance by ID
797
- * @param workflowId - ID of the vNext workflow to retrieve
798
- * @returns vNext Workflow instance
799
- */
800
- getVNextWorkflow(workflowId: string): VNextWorkflow;
801
796
  /**
802
797
  * Gets a vector instance by name
803
798
  * @param vectorName - Name of the vector to retrieve
@@ -880,4 +875,4 @@ declare class MastraClient extends BaseResource {
880
875
  getA2A(agentId: string): A2A;
881
876
  }
882
877
 
883
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVNextWorkflowRunsResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
878
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };