@mastra/client-js 0.1.23-alpha.0 → 0.10.0
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +61 -0
- package/dist/index.cjs +83 -85
- package/dist/index.d.cts +73 -78
- package/dist/index.d.ts +73 -78
- package/dist/index.js +83 -85
- package/package.json +6 -5
- package/src/client.ts +20 -21
- package/src/resources/agent.ts +4 -3
- package/src/resources/index.ts +2 -2
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -143
- package/src/resources/tool.ts +4 -3
- package/src/resources/workflow.ts +121 -109
- package/src/types.ts +21 -18
- package/src/utils/index.ts +11 -0
package/dist/index.d.ts
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 {
|
|
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 {
|
|
9
|
-
import {
|
|
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
|
|
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
|
|
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:
|
|
93
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
93
94
|
timestamp: number;
|
|
94
95
|
runId: string;
|
|
95
96
|
};
|
|
96
|
-
interface
|
|
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:
|
|
110
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
109
111
|
inputSchema: string;
|
|
110
112
|
outputSchema: string;
|
|
111
113
|
}
|
|
112
|
-
type
|
|
114
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
113
115
|
runId: string;
|
|
114
116
|
};
|
|
115
|
-
type
|
|
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
|
|
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
|
|
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<
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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:
|
|
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
|
|
559
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
565
560
|
}): Promise<any>;
|
|
566
561
|
}
|
|
567
562
|
|
|
568
|
-
declare class
|
|
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
|
|
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
|
|
581
|
-
* @returns Promise containing
|
|
575
|
+
* Retrieves details about the workflow
|
|
576
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
582
577
|
*/
|
|
583
|
-
details(): Promise<
|
|
578
|
+
details(): Promise<GetWorkflowResponse>;
|
|
584
579
|
/**
|
|
585
|
-
* Retrieves all runs for a
|
|
580
|
+
* Retrieves all runs for a workflow
|
|
586
581
|
* @param params - Parameters for filtering runs
|
|
587
|
-
* @returns Promise containing
|
|
582
|
+
* @returns Promise containing workflow runs array
|
|
588
583
|
*/
|
|
589
|
-
runs(params?: GetWorkflowRunsParams): Promise<
|
|
584
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
590
585
|
/**
|
|
591
|
-
* Creates a new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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<
|
|
628
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
629
|
+
}): Promise<WorkflowRunResult>;
|
|
635
630
|
/**
|
|
636
|
-
* Resumes a suspended
|
|
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
|
|
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<
|
|
639
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
640
|
+
}): Promise<WorkflowRunResult>;
|
|
646
641
|
/**
|
|
647
|
-
* Watches
|
|
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
|
|
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:
|
|
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
|
|
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 };
|