@mastra/client-js 0.0.0-default-storage-virtual-file-20250410035748 → 0.0.0-expose-more-playground-ui-20250502050852
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/CHANGELOG.md +292 -2
- package/{LICENSE → LICENSE.md} +3 -1
- package/dist/index.cjs +193 -4
- package/dist/index.d.cts +136 -8
- package/dist/index.d.ts +136 -8
- package/dist/index.js +193 -4
- package/package.json +8 -5
- package/src/client.ts +19 -10
- package/src/index.test.ts +4 -4
- package/src/resources/agent.ts +1 -2
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +1 -0
- package/src/resources/memory-thread.ts +1 -8
- package/src/resources/network.ts +1 -1
- package/src/resources/tool.ts +9 -3
- package/src/resources/vnext-workflow.ts +234 -0
- package/src/resources/workflow.ts +10 -2
- package/src/types.ts +31 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
2
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
3
|
import { JSONSchema7 } from 'json-schema';
|
|
3
4
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
5
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
6
|
+
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
7
|
+
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
6
8
|
|
|
7
9
|
interface ClientOptions {
|
|
8
10
|
/** Base URL for API requests */
|
|
@@ -38,6 +40,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
|
38
40
|
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
39
41
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
42
|
evals: any[];
|
|
43
|
+
instructions: string;
|
|
44
|
+
name: string;
|
|
45
|
+
id: string;
|
|
41
46
|
}
|
|
42
47
|
interface GetToolResponse {
|
|
43
48
|
id: string;
|
|
@@ -53,6 +58,7 @@ interface GetWorkflowResponse {
|
|
|
53
58
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
59
|
workflowId?: string;
|
|
55
60
|
}
|
|
61
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
56
62
|
type WorkflowRunResult = {
|
|
57
63
|
activePaths: Record<string, {
|
|
58
64
|
status: string;
|
|
@@ -63,6 +69,26 @@ type WorkflowRunResult = {
|
|
|
63
69
|
timestamp: number;
|
|
64
70
|
runId: string;
|
|
65
71
|
};
|
|
72
|
+
interface GetVNextWorkflowResponse {
|
|
73
|
+
name: string;
|
|
74
|
+
steps: {
|
|
75
|
+
[key: string]: {
|
|
76
|
+
id: string;
|
|
77
|
+
description: string;
|
|
78
|
+
inputSchema: string;
|
|
79
|
+
outputSchema: string;
|
|
80
|
+
resumeSchema: string;
|
|
81
|
+
suspendSchema: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
stepGraph: NewWorkflow['serializedStepGraph'];
|
|
85
|
+
inputSchema: string;
|
|
86
|
+
outputSchema: string;
|
|
87
|
+
}
|
|
88
|
+
type VNextWorkflowWatchResult = WatchEvent & {
|
|
89
|
+
runId: string;
|
|
90
|
+
};
|
|
91
|
+
type VNextWorkflowRunResult = WorkflowResult<any, any>;
|
|
66
92
|
interface UpsertVectorParams {
|
|
67
93
|
indexName: string;
|
|
68
94
|
vectors: number[][];
|
|
@@ -97,7 +123,7 @@ type SaveMessageToMemoryResponse = MessageType[];
|
|
|
97
123
|
interface CreateMemoryThreadParams {
|
|
98
124
|
title: string;
|
|
99
125
|
metadata: Record<string, any>;
|
|
100
|
-
|
|
126
|
+
resourceId: string;
|
|
101
127
|
threadId: string;
|
|
102
128
|
agentId: string;
|
|
103
129
|
}
|
|
@@ -110,7 +136,7 @@ type GetMemoryThreadResponse = StorageThreadType[];
|
|
|
110
136
|
interface UpdateMemoryThreadParams {
|
|
111
137
|
title: string;
|
|
112
138
|
metadata: Record<string, any>;
|
|
113
|
-
|
|
139
|
+
resourceId: string;
|
|
114
140
|
}
|
|
115
141
|
interface GetMemoryThreadMessagesResponse {
|
|
116
142
|
messages: CoreMessage[];
|
|
@@ -163,9 +189,7 @@ type Span = {
|
|
|
163
189
|
createdAt: string;
|
|
164
190
|
};
|
|
165
191
|
interface GetTelemetryResponse {
|
|
166
|
-
traces:
|
|
167
|
-
traces: Span[];
|
|
168
|
-
};
|
|
192
|
+
traces: Span[];
|
|
169
193
|
}
|
|
170
194
|
interface GetTelemetryParams {
|
|
171
195
|
name?: string;
|
|
@@ -378,6 +402,11 @@ declare class Workflow extends BaseResource {
|
|
|
378
402
|
* @returns Promise containing workflow details including steps and graphs
|
|
379
403
|
*/
|
|
380
404
|
details(): Promise<GetWorkflowResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Retrieves all runs for a workflow
|
|
407
|
+
* @returns Promise containing workflow runs array
|
|
408
|
+
*/
|
|
409
|
+
runs(): Promise<GetWorkflowRunsResponse>;
|
|
381
410
|
/**
|
|
382
411
|
* @deprecated Use `startAsync` instead
|
|
383
412
|
* Executes the workflow with the provided parameters
|
|
@@ -471,9 +500,97 @@ declare class Tool extends BaseResource {
|
|
|
471
500
|
*/
|
|
472
501
|
execute(params: {
|
|
473
502
|
data: any;
|
|
503
|
+
runId?: string;
|
|
474
504
|
}): Promise<any>;
|
|
475
505
|
}
|
|
476
506
|
|
|
507
|
+
declare class VNextWorkflow extends BaseResource {
|
|
508
|
+
private workflowId;
|
|
509
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
510
|
+
/**
|
|
511
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
512
|
+
* separated by the Record Separator character (\x1E)
|
|
513
|
+
*
|
|
514
|
+
* @param stream - The readable stream to process
|
|
515
|
+
* @returns An async generator that yields parsed records
|
|
516
|
+
*/
|
|
517
|
+
private streamProcessor;
|
|
518
|
+
/**
|
|
519
|
+
* Retrieves details about the vNext workflow
|
|
520
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
521
|
+
*/
|
|
522
|
+
details(): Promise<GetVNextWorkflowResponse>;
|
|
523
|
+
/**
|
|
524
|
+
* Retrieves all runs for a vNext workflow
|
|
525
|
+
* @returns Promise containing vNext workflow runs array
|
|
526
|
+
*/
|
|
527
|
+
runs(): Promise<GetWorkflowRunsResponse>;
|
|
528
|
+
/**
|
|
529
|
+
* Creates a new vNext workflow run
|
|
530
|
+
* @param params - Optional object containing the optional runId
|
|
531
|
+
* @returns Promise containing the runId of the created run
|
|
532
|
+
*/
|
|
533
|
+
createRun(params?: {
|
|
534
|
+
runId?: string;
|
|
535
|
+
}): Promise<{
|
|
536
|
+
runId: string;
|
|
537
|
+
}>;
|
|
538
|
+
/**
|
|
539
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
540
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
541
|
+
* @returns Promise containing success message
|
|
542
|
+
*/
|
|
543
|
+
start(params: {
|
|
544
|
+
runId: string;
|
|
545
|
+
inputData: Record<string, any>;
|
|
546
|
+
runtimeContext?: RuntimeContext;
|
|
547
|
+
}): Promise<{
|
|
548
|
+
message: string;
|
|
549
|
+
}>;
|
|
550
|
+
/**
|
|
551
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
552
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
553
|
+
* @returns Promise containing success message
|
|
554
|
+
*/
|
|
555
|
+
resume({ step, runId, resumeData, runtimeContext, }: {
|
|
556
|
+
step: string | string[];
|
|
557
|
+
runId: string;
|
|
558
|
+
resumeData?: Record<string, any>;
|
|
559
|
+
runtimeContext?: RuntimeContext;
|
|
560
|
+
}): Promise<{
|
|
561
|
+
message: string;
|
|
562
|
+
}>;
|
|
563
|
+
/**
|
|
564
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
565
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
566
|
+
* @returns Promise containing the vNext workflow execution results
|
|
567
|
+
*/
|
|
568
|
+
startAsync(params: {
|
|
569
|
+
runId?: string;
|
|
570
|
+
inputData: Record<string, any>;
|
|
571
|
+
runtimeContext?: RuntimeContext;
|
|
572
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
573
|
+
/**
|
|
574
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
575
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
576
|
+
* @returns Promise containing the vNext workflow resume results
|
|
577
|
+
*/
|
|
578
|
+
resumeAsync(params: {
|
|
579
|
+
runId: string;
|
|
580
|
+
step: string | string[];
|
|
581
|
+
resumeData?: Record<string, any>;
|
|
582
|
+
runtimeContext?: RuntimeContext;
|
|
583
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
584
|
+
/**
|
|
585
|
+
* Watches vNext workflow transitions in real-time
|
|
586
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
587
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
588
|
+
*/
|
|
589
|
+
watch({ runId }: {
|
|
590
|
+
runId?: string;
|
|
591
|
+
}, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
|
|
592
|
+
}
|
|
593
|
+
|
|
477
594
|
declare class MastraClient extends BaseResource {
|
|
478
595
|
constructor(options: ClientOptions);
|
|
479
596
|
/**
|
|
@@ -540,6 +657,17 @@ declare class MastraClient extends BaseResource {
|
|
|
540
657
|
* @returns Workflow instance
|
|
541
658
|
*/
|
|
542
659
|
getWorkflow(workflowId: string): Workflow;
|
|
660
|
+
/**
|
|
661
|
+
* Retrieves all available vNext workflows
|
|
662
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
663
|
+
*/
|
|
664
|
+
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
665
|
+
/**
|
|
666
|
+
* Gets a vNext workflow instance by ID
|
|
667
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
668
|
+
* @returns vNext Workflow instance
|
|
669
|
+
*/
|
|
670
|
+
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
543
671
|
/**
|
|
544
672
|
* Gets a vector instance by name
|
|
545
673
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -584,4 +712,4 @@ declare class MastraClient extends BaseResource {
|
|
|
584
712
|
getNetwork(networkId: string): Network;
|
|
585
713
|
}
|
|
586
714
|
|
|
587
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
|
|
715
|
+
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
2
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
3
|
import { JSONSchema7 } from 'json-schema';
|
|
3
4
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
5
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
6
|
+
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
7
|
+
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
6
8
|
|
|
7
9
|
interface ClientOptions {
|
|
8
10
|
/** Base URL for API requests */
|
|
@@ -38,6 +40,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
|
38
40
|
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
39
41
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
42
|
evals: any[];
|
|
43
|
+
instructions: string;
|
|
44
|
+
name: string;
|
|
45
|
+
id: string;
|
|
41
46
|
}
|
|
42
47
|
interface GetToolResponse {
|
|
43
48
|
id: string;
|
|
@@ -53,6 +58,7 @@ interface GetWorkflowResponse {
|
|
|
53
58
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
59
|
workflowId?: string;
|
|
55
60
|
}
|
|
61
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
56
62
|
type WorkflowRunResult = {
|
|
57
63
|
activePaths: Record<string, {
|
|
58
64
|
status: string;
|
|
@@ -63,6 +69,26 @@ type WorkflowRunResult = {
|
|
|
63
69
|
timestamp: number;
|
|
64
70
|
runId: string;
|
|
65
71
|
};
|
|
72
|
+
interface GetVNextWorkflowResponse {
|
|
73
|
+
name: string;
|
|
74
|
+
steps: {
|
|
75
|
+
[key: string]: {
|
|
76
|
+
id: string;
|
|
77
|
+
description: string;
|
|
78
|
+
inputSchema: string;
|
|
79
|
+
outputSchema: string;
|
|
80
|
+
resumeSchema: string;
|
|
81
|
+
suspendSchema: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
stepGraph: NewWorkflow['serializedStepGraph'];
|
|
85
|
+
inputSchema: string;
|
|
86
|
+
outputSchema: string;
|
|
87
|
+
}
|
|
88
|
+
type VNextWorkflowWatchResult = WatchEvent & {
|
|
89
|
+
runId: string;
|
|
90
|
+
};
|
|
91
|
+
type VNextWorkflowRunResult = WorkflowResult<any, any>;
|
|
66
92
|
interface UpsertVectorParams {
|
|
67
93
|
indexName: string;
|
|
68
94
|
vectors: number[][];
|
|
@@ -97,7 +123,7 @@ type SaveMessageToMemoryResponse = MessageType[];
|
|
|
97
123
|
interface CreateMemoryThreadParams {
|
|
98
124
|
title: string;
|
|
99
125
|
metadata: Record<string, any>;
|
|
100
|
-
|
|
126
|
+
resourceId: string;
|
|
101
127
|
threadId: string;
|
|
102
128
|
agentId: string;
|
|
103
129
|
}
|
|
@@ -110,7 +136,7 @@ type GetMemoryThreadResponse = StorageThreadType[];
|
|
|
110
136
|
interface UpdateMemoryThreadParams {
|
|
111
137
|
title: string;
|
|
112
138
|
metadata: Record<string, any>;
|
|
113
|
-
|
|
139
|
+
resourceId: string;
|
|
114
140
|
}
|
|
115
141
|
interface GetMemoryThreadMessagesResponse {
|
|
116
142
|
messages: CoreMessage[];
|
|
@@ -163,9 +189,7 @@ type Span = {
|
|
|
163
189
|
createdAt: string;
|
|
164
190
|
};
|
|
165
191
|
interface GetTelemetryResponse {
|
|
166
|
-
traces:
|
|
167
|
-
traces: Span[];
|
|
168
|
-
};
|
|
192
|
+
traces: Span[];
|
|
169
193
|
}
|
|
170
194
|
interface GetTelemetryParams {
|
|
171
195
|
name?: string;
|
|
@@ -378,6 +402,11 @@ declare class Workflow extends BaseResource {
|
|
|
378
402
|
* @returns Promise containing workflow details including steps and graphs
|
|
379
403
|
*/
|
|
380
404
|
details(): Promise<GetWorkflowResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Retrieves all runs for a workflow
|
|
407
|
+
* @returns Promise containing workflow runs array
|
|
408
|
+
*/
|
|
409
|
+
runs(): Promise<GetWorkflowRunsResponse>;
|
|
381
410
|
/**
|
|
382
411
|
* @deprecated Use `startAsync` instead
|
|
383
412
|
* Executes the workflow with the provided parameters
|
|
@@ -471,9 +500,97 @@ declare class Tool extends BaseResource {
|
|
|
471
500
|
*/
|
|
472
501
|
execute(params: {
|
|
473
502
|
data: any;
|
|
503
|
+
runId?: string;
|
|
474
504
|
}): Promise<any>;
|
|
475
505
|
}
|
|
476
506
|
|
|
507
|
+
declare class VNextWorkflow extends BaseResource {
|
|
508
|
+
private workflowId;
|
|
509
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
510
|
+
/**
|
|
511
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
512
|
+
* separated by the Record Separator character (\x1E)
|
|
513
|
+
*
|
|
514
|
+
* @param stream - The readable stream to process
|
|
515
|
+
* @returns An async generator that yields parsed records
|
|
516
|
+
*/
|
|
517
|
+
private streamProcessor;
|
|
518
|
+
/**
|
|
519
|
+
* Retrieves details about the vNext workflow
|
|
520
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
521
|
+
*/
|
|
522
|
+
details(): Promise<GetVNextWorkflowResponse>;
|
|
523
|
+
/**
|
|
524
|
+
* Retrieves all runs for a vNext workflow
|
|
525
|
+
* @returns Promise containing vNext workflow runs array
|
|
526
|
+
*/
|
|
527
|
+
runs(): Promise<GetWorkflowRunsResponse>;
|
|
528
|
+
/**
|
|
529
|
+
* Creates a new vNext workflow run
|
|
530
|
+
* @param params - Optional object containing the optional runId
|
|
531
|
+
* @returns Promise containing the runId of the created run
|
|
532
|
+
*/
|
|
533
|
+
createRun(params?: {
|
|
534
|
+
runId?: string;
|
|
535
|
+
}): Promise<{
|
|
536
|
+
runId: string;
|
|
537
|
+
}>;
|
|
538
|
+
/**
|
|
539
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
540
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
541
|
+
* @returns Promise containing success message
|
|
542
|
+
*/
|
|
543
|
+
start(params: {
|
|
544
|
+
runId: string;
|
|
545
|
+
inputData: Record<string, any>;
|
|
546
|
+
runtimeContext?: RuntimeContext;
|
|
547
|
+
}): Promise<{
|
|
548
|
+
message: string;
|
|
549
|
+
}>;
|
|
550
|
+
/**
|
|
551
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
552
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
553
|
+
* @returns Promise containing success message
|
|
554
|
+
*/
|
|
555
|
+
resume({ step, runId, resumeData, runtimeContext, }: {
|
|
556
|
+
step: string | string[];
|
|
557
|
+
runId: string;
|
|
558
|
+
resumeData?: Record<string, any>;
|
|
559
|
+
runtimeContext?: RuntimeContext;
|
|
560
|
+
}): Promise<{
|
|
561
|
+
message: string;
|
|
562
|
+
}>;
|
|
563
|
+
/**
|
|
564
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
565
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
566
|
+
* @returns Promise containing the vNext workflow execution results
|
|
567
|
+
*/
|
|
568
|
+
startAsync(params: {
|
|
569
|
+
runId?: string;
|
|
570
|
+
inputData: Record<string, any>;
|
|
571
|
+
runtimeContext?: RuntimeContext;
|
|
572
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
573
|
+
/**
|
|
574
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
575
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
576
|
+
* @returns Promise containing the vNext workflow resume results
|
|
577
|
+
*/
|
|
578
|
+
resumeAsync(params: {
|
|
579
|
+
runId: string;
|
|
580
|
+
step: string | string[];
|
|
581
|
+
resumeData?: Record<string, any>;
|
|
582
|
+
runtimeContext?: RuntimeContext;
|
|
583
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
584
|
+
/**
|
|
585
|
+
* Watches vNext workflow transitions in real-time
|
|
586
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
587
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
588
|
+
*/
|
|
589
|
+
watch({ runId }: {
|
|
590
|
+
runId?: string;
|
|
591
|
+
}, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
|
|
592
|
+
}
|
|
593
|
+
|
|
477
594
|
declare class MastraClient extends BaseResource {
|
|
478
595
|
constructor(options: ClientOptions);
|
|
479
596
|
/**
|
|
@@ -540,6 +657,17 @@ declare class MastraClient extends BaseResource {
|
|
|
540
657
|
* @returns Workflow instance
|
|
541
658
|
*/
|
|
542
659
|
getWorkflow(workflowId: string): Workflow;
|
|
660
|
+
/**
|
|
661
|
+
* Retrieves all available vNext workflows
|
|
662
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
663
|
+
*/
|
|
664
|
+
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
665
|
+
/**
|
|
666
|
+
* Gets a vNext workflow instance by ID
|
|
667
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
668
|
+
* @returns vNext Workflow instance
|
|
669
|
+
*/
|
|
670
|
+
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
543
671
|
/**
|
|
544
672
|
* Gets a vector instance by name
|
|
545
673
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -584,4 +712,4 @@ declare class MastraClient extends BaseResource {
|
|
|
584
712
|
getNetwork(networkId: string): Network;
|
|
585
713
|
}
|
|
586
714
|
|
|
587
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
|
|
715
|
+
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
1
2
|
import { ZodSchema } from 'zod';
|
|
2
3
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
4
4
|
|
|
5
5
|
// src/resources/agent.ts
|
|
6
6
|
|
|
@@ -371,6 +371,13 @@ var Workflow = class extends BaseResource {
|
|
|
371
371
|
details() {
|
|
372
372
|
return this.request(`/api/workflows/${this.workflowId}`);
|
|
373
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Retrieves all runs for a workflow
|
|
376
|
+
* @returns Promise containing workflow runs array
|
|
377
|
+
*/
|
|
378
|
+
runs() {
|
|
379
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
380
|
+
}
|
|
374
381
|
/**
|
|
375
382
|
* @deprecated Use `startAsync` instead
|
|
376
383
|
* Executes the workflow with the provided parameters
|
|
@@ -487,7 +494,7 @@ var Workflow = class extends BaseResource {
|
|
|
487
494
|
}
|
|
488
495
|
}
|
|
489
496
|
}
|
|
490
|
-
} catch
|
|
497
|
+
} catch {
|
|
491
498
|
}
|
|
492
499
|
}
|
|
493
500
|
if (buffer) {
|
|
@@ -541,13 +548,180 @@ var Tool = class extends BaseResource {
|
|
|
541
548
|
* @returns Promise containing the tool execution results
|
|
542
549
|
*/
|
|
543
550
|
execute(params) {
|
|
544
|
-
|
|
551
|
+
const url = new URLSearchParams();
|
|
552
|
+
if (params.runId) {
|
|
553
|
+
url.set("runId", params.runId);
|
|
554
|
+
}
|
|
555
|
+
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
545
556
|
method: "POST",
|
|
546
|
-
body: params
|
|
557
|
+
body: params.data
|
|
547
558
|
});
|
|
548
559
|
}
|
|
549
560
|
};
|
|
550
561
|
|
|
562
|
+
// src/resources/vnext-workflow.ts
|
|
563
|
+
var RECORD_SEPARATOR2 = "";
|
|
564
|
+
var VNextWorkflow = class extends BaseResource {
|
|
565
|
+
constructor(options, workflowId) {
|
|
566
|
+
super(options);
|
|
567
|
+
this.workflowId = workflowId;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
571
|
+
* separated by the Record Separator character (\x1E)
|
|
572
|
+
*
|
|
573
|
+
* @param stream - The readable stream to process
|
|
574
|
+
* @returns An async generator that yields parsed records
|
|
575
|
+
*/
|
|
576
|
+
async *streamProcessor(stream) {
|
|
577
|
+
const reader = stream.getReader();
|
|
578
|
+
let doneReading = false;
|
|
579
|
+
let buffer = "";
|
|
580
|
+
try {
|
|
581
|
+
while (!doneReading) {
|
|
582
|
+
const { done, value } = await reader.read();
|
|
583
|
+
doneReading = done;
|
|
584
|
+
if (done && !value) continue;
|
|
585
|
+
try {
|
|
586
|
+
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
587
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
588
|
+
buffer = chunks.pop() || "";
|
|
589
|
+
for (const chunk of chunks) {
|
|
590
|
+
if (chunk) {
|
|
591
|
+
if (typeof chunk === "string") {
|
|
592
|
+
try {
|
|
593
|
+
const parsedChunk = JSON.parse(chunk);
|
|
594
|
+
yield parsedChunk;
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
} catch {
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if (buffer) {
|
|
604
|
+
try {
|
|
605
|
+
yield JSON.parse(buffer);
|
|
606
|
+
} catch {
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} finally {
|
|
610
|
+
reader.cancel().catch(() => {
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Retrieves details about the vNext workflow
|
|
616
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
617
|
+
*/
|
|
618
|
+
details() {
|
|
619
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}`);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Retrieves all runs for a vNext workflow
|
|
623
|
+
* @returns Promise containing vNext workflow runs array
|
|
624
|
+
*/
|
|
625
|
+
runs() {
|
|
626
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Creates a new vNext workflow run
|
|
630
|
+
* @param params - Optional object containing the optional runId
|
|
631
|
+
* @returns Promise containing the runId of the created run
|
|
632
|
+
*/
|
|
633
|
+
createRun(params) {
|
|
634
|
+
const searchParams = new URLSearchParams();
|
|
635
|
+
if (!!params?.runId) {
|
|
636
|
+
searchParams.set("runId", params.runId);
|
|
637
|
+
}
|
|
638
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
639
|
+
method: "POST"
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
644
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
645
|
+
* @returns Promise containing success message
|
|
646
|
+
*/
|
|
647
|
+
start(params) {
|
|
648
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
649
|
+
method: "POST",
|
|
650
|
+
body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
655
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
656
|
+
* @returns Promise containing success message
|
|
657
|
+
*/
|
|
658
|
+
resume({
|
|
659
|
+
step,
|
|
660
|
+
runId,
|
|
661
|
+
resumeData,
|
|
662
|
+
runtimeContext
|
|
663
|
+
}) {
|
|
664
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
665
|
+
method: "POST",
|
|
666
|
+
stream: true,
|
|
667
|
+
body: {
|
|
668
|
+
step,
|
|
669
|
+
resumeData,
|
|
670
|
+
runtimeContext
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
676
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
677
|
+
* @returns Promise containing the vNext workflow execution results
|
|
678
|
+
*/
|
|
679
|
+
startAsync(params) {
|
|
680
|
+
const searchParams = new URLSearchParams();
|
|
681
|
+
if (!!params?.runId) {
|
|
682
|
+
searchParams.set("runId", params.runId);
|
|
683
|
+
}
|
|
684
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
685
|
+
method: "POST",
|
|
686
|
+
body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
691
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
692
|
+
* @returns Promise containing the vNext workflow resume results
|
|
693
|
+
*/
|
|
694
|
+
resumeAsync(params) {
|
|
695
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
696
|
+
method: "POST",
|
|
697
|
+
body: {
|
|
698
|
+
step: params.step,
|
|
699
|
+
resumeData: params.resumeData,
|
|
700
|
+
runtimeContext: params.runtimeContext
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Watches vNext workflow transitions in real-time
|
|
706
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
707
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
708
|
+
*/
|
|
709
|
+
async watch({ runId }, onRecord) {
|
|
710
|
+
const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
|
|
711
|
+
stream: true
|
|
712
|
+
});
|
|
713
|
+
if (!response.ok) {
|
|
714
|
+
throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
|
|
715
|
+
}
|
|
716
|
+
if (!response.body) {
|
|
717
|
+
throw new Error("Response body is null");
|
|
718
|
+
}
|
|
719
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
720
|
+
onRecord(record);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
|
|
551
725
|
// src/client.ts
|
|
552
726
|
var MastraClient = class extends BaseResource {
|
|
553
727
|
constructor(options) {
|
|
@@ -640,6 +814,21 @@ var MastraClient = class extends BaseResource {
|
|
|
640
814
|
getWorkflow(workflowId) {
|
|
641
815
|
return new Workflow(this.options, workflowId);
|
|
642
816
|
}
|
|
817
|
+
/**
|
|
818
|
+
* Retrieves all available vNext workflows
|
|
819
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
820
|
+
*/
|
|
821
|
+
getVNextWorkflows() {
|
|
822
|
+
return this.request("/api/workflows/v-next");
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Gets a vNext workflow instance by ID
|
|
826
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
827
|
+
* @returns vNext Workflow instance
|
|
828
|
+
*/
|
|
829
|
+
getVNextWorkflow(workflowId) {
|
|
830
|
+
return new VNextWorkflow(this.options, workflowId);
|
|
831
|
+
}
|
|
643
832
|
/**
|
|
644
833
|
* Gets a vector instance by name
|
|
645
834
|
* @param vectorName - Name of the vector to retrieve
|