@mastra/client-js 0.0.0-cli-debug-2-20250611100354 → 0.0.0-cloudflare-deployer-dont-install-deps-20250714111754
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 +397 -2
- package/LICENSE.md +11 -42
- package/README.md +1 -1
- package/dist/index.cjs +769 -22
- package/dist/index.d.cts +268 -12
- package/dist/index.d.ts +268 -12
- package/dist/index.js +770 -23
- package/package.json +19 -13
- package/src/client.ts +117 -1
- package/src/example.ts +46 -15
- package/src/resources/agent.ts +604 -21
- package/src/resources/base.ts +2 -0
- package/src/resources/network-memory-thread.ts +63 -0
- package/src/resources/network.ts +2 -3
- package/src/resources/vNextNetwork.ts +194 -0
- package/src/resources/workflow.ts +49 -6
- package/src/types.ts +97 -3
- package/src/utils/process-client-tools.ts +3 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { StorageThreadType } from '@mastra/core';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
GetMemoryThreadMessagesResponse,
|
|
5
|
+
ClientOptions,
|
|
6
|
+
UpdateMemoryThreadParams,
|
|
7
|
+
GetMemoryThreadMessagesParams,
|
|
8
|
+
} from '../types';
|
|
9
|
+
|
|
10
|
+
import { BaseResource } from './base';
|
|
11
|
+
|
|
12
|
+
export class NetworkMemoryThread extends BaseResource {
|
|
13
|
+
constructor(
|
|
14
|
+
options: ClientOptions,
|
|
15
|
+
private threadId: string,
|
|
16
|
+
private networkId: string,
|
|
17
|
+
) {
|
|
18
|
+
super(options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the memory thread details
|
|
23
|
+
* @returns Promise containing thread details including title and metadata
|
|
24
|
+
*/
|
|
25
|
+
get(): Promise<StorageThreadType> {
|
|
26
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Updates the memory thread properties
|
|
31
|
+
* @param params - Update parameters including title and metadata
|
|
32
|
+
* @returns Promise containing updated thread details
|
|
33
|
+
*/
|
|
34
|
+
update(params: UpdateMemoryThreadParams): Promise<StorageThreadType> {
|
|
35
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
36
|
+
method: 'PATCH',
|
|
37
|
+
body: params,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Deletes the memory thread
|
|
43
|
+
* @returns Promise containing deletion result
|
|
44
|
+
*/
|
|
45
|
+
delete(): Promise<{ result: string }> {
|
|
46
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
47
|
+
method: 'DELETE',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves messages associated with the thread
|
|
53
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
54
|
+
* @returns Promise containing thread messages and UI messages
|
|
55
|
+
*/
|
|
56
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse> {
|
|
57
|
+
const query = new URLSearchParams({
|
|
58
|
+
networkId: this.networkId,
|
|
59
|
+
...(params?.limit ? { limit: params.limit.toString() } : {}),
|
|
60
|
+
});
|
|
61
|
+
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/resources/network.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
2
2
|
import type { GenerateReturn } from '@mastra/core';
|
|
3
3
|
import type { JSONSchema7 } from 'json-schema';
|
|
4
|
-
import { ZodSchema } from 'zod';
|
|
5
|
-
import { zodToJsonSchema } from '../utils/zod-to-json-schema';
|
|
6
|
-
|
|
4
|
+
import type { ZodSchema } from 'zod';
|
|
7
5
|
import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
|
|
6
|
+
import { zodToJsonSchema } from '../utils/zod-to-json-schema';
|
|
8
7
|
|
|
9
8
|
import { BaseResource } from './base';
|
|
10
9
|
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { WatchEvent } from '@mastra/core/workflows';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ClientOptions,
|
|
5
|
+
GetVNextNetworkResponse,
|
|
6
|
+
GenerateVNextNetworkResponse,
|
|
7
|
+
LoopVNextNetworkResponse,
|
|
8
|
+
GenerateOrStreamVNextNetworkParams,
|
|
9
|
+
LoopStreamVNextNetworkParams,
|
|
10
|
+
} from '../types';
|
|
11
|
+
|
|
12
|
+
import { BaseResource } from './base';
|
|
13
|
+
import { parseClientRuntimeContext } from '../utils';
|
|
14
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
15
|
+
|
|
16
|
+
const RECORD_SEPARATOR = '\x1E';
|
|
17
|
+
|
|
18
|
+
export class VNextNetwork extends BaseResource {
|
|
19
|
+
constructor(
|
|
20
|
+
options: ClientOptions,
|
|
21
|
+
private networkId: string,
|
|
22
|
+
) {
|
|
23
|
+
super(options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves details about the network
|
|
28
|
+
* @returns Promise containing vNext network details
|
|
29
|
+
*/
|
|
30
|
+
details(): Promise<GetVNextNetworkResponse> {
|
|
31
|
+
return this.request(`/api/networks/v-next/${this.networkId}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generates a response from the v-next network
|
|
36
|
+
* @param params - Generation parameters including message
|
|
37
|
+
* @returns Promise containing the generated response
|
|
38
|
+
*/
|
|
39
|
+
generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse> {
|
|
40
|
+
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: {
|
|
43
|
+
...params,
|
|
44
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generates a response from the v-next network using multiple primitives
|
|
51
|
+
* @param params - Generation parameters including message
|
|
52
|
+
* @returns Promise containing the generated response
|
|
53
|
+
*/
|
|
54
|
+
loop(params: {
|
|
55
|
+
message: string;
|
|
56
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
57
|
+
}): Promise<LoopVNextNetworkResponse> {
|
|
58
|
+
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
body: {
|
|
61
|
+
...params,
|
|
62
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private async *streamProcessor(stream: ReadableStream): AsyncGenerator<WatchEvent, void, unknown> {
|
|
68
|
+
const reader = stream.getReader();
|
|
69
|
+
|
|
70
|
+
// Track if we've finished reading from the stream
|
|
71
|
+
let doneReading = false;
|
|
72
|
+
// Buffer to accumulate partial chunks
|
|
73
|
+
let buffer = '';
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
while (!doneReading) {
|
|
77
|
+
// Read the next chunk from the stream
|
|
78
|
+
const { done, value } = await reader.read();
|
|
79
|
+
doneReading = done;
|
|
80
|
+
|
|
81
|
+
// Skip processing if we're done and there's no value
|
|
82
|
+
if (done && !value) continue;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// Decode binary data to text
|
|
86
|
+
const decoded = value ? new TextDecoder().decode(value) : '';
|
|
87
|
+
|
|
88
|
+
// Split the combined buffer and new data by record separator
|
|
89
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
|
|
90
|
+
|
|
91
|
+
// The last chunk might be incomplete, so save it for the next iteration
|
|
92
|
+
buffer = chunks.pop() || '';
|
|
93
|
+
|
|
94
|
+
// Process complete chunks
|
|
95
|
+
for (const chunk of chunks) {
|
|
96
|
+
if (chunk) {
|
|
97
|
+
// Only process non-empty chunks
|
|
98
|
+
if (typeof chunk === 'string') {
|
|
99
|
+
try {
|
|
100
|
+
const parsedChunk = JSON.parse(chunk);
|
|
101
|
+
yield parsedChunk;
|
|
102
|
+
} catch {
|
|
103
|
+
// Silently ignore parsing errors to maintain stream processing
|
|
104
|
+
// This allows the stream to continue even if one record is malformed
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} catch {
|
|
110
|
+
// Silently ignore parsing errors to maintain stream processing
|
|
111
|
+
// This allows the stream to continue even if one record is malformed
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Process any remaining data in the buffer after stream is done
|
|
116
|
+
if (buffer) {
|
|
117
|
+
try {
|
|
118
|
+
yield JSON.parse(buffer);
|
|
119
|
+
} catch {
|
|
120
|
+
// Ignore parsing error for final chunk
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} finally {
|
|
124
|
+
// Always ensure we clean up the reader
|
|
125
|
+
reader.cancel().catch(() => {
|
|
126
|
+
// Ignore cancel errors
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Streams a response from the v-next network
|
|
133
|
+
* @param params - Stream parameters including message
|
|
134
|
+
* @returns Promise containing the results
|
|
135
|
+
*/
|
|
136
|
+
async stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
|
|
137
|
+
const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
body: {
|
|
140
|
+
...params,
|
|
141
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
142
|
+
},
|
|
143
|
+
stream: true,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!response.body) {
|
|
151
|
+
throw new Error('Response body is null');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
155
|
+
if (typeof record === 'string') {
|
|
156
|
+
onRecord(JSON.parse(record));
|
|
157
|
+
} else {
|
|
158
|
+
onRecord(record);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Streams a response from the v-next network loop
|
|
165
|
+
* @param params - Stream parameters including message
|
|
166
|
+
* @returns Promise containing the results
|
|
167
|
+
*/
|
|
168
|
+
async loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
|
|
169
|
+
const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
body: {
|
|
172
|
+
...params,
|
|
173
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
174
|
+
},
|
|
175
|
+
stream: true,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
if (!response.ok) {
|
|
179
|
+
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!response.body) {
|
|
183
|
+
throw new Error('Response body is null');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
187
|
+
if (typeof record === 'string') {
|
|
188
|
+
onRecord(JSON.parse(record));
|
|
189
|
+
} else {
|
|
190
|
+
onRecord(record);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
GetWorkflowRunsParams,
|
|
7
7
|
WorkflowRunResult,
|
|
8
8
|
WorkflowWatchResult,
|
|
9
|
+
GetWorkflowRunByIdResponse,
|
|
10
|
+
GetWorkflowRunExecutionResultResponse,
|
|
9
11
|
} from '../types';
|
|
10
12
|
|
|
11
13
|
import { parseClientRuntimeContext } from '../utils';
|
|
@@ -113,10 +115,10 @@ export class Workflow extends BaseResource {
|
|
|
113
115
|
if (params?.toDate) {
|
|
114
116
|
searchParams.set('toDate', params.toDate.toISOString());
|
|
115
117
|
}
|
|
116
|
-
if (params?.limit) {
|
|
118
|
+
if (params?.limit !== null && params?.limit !== undefined && !isNaN(Number(params?.limit))) {
|
|
117
119
|
searchParams.set('limit', String(params.limit));
|
|
118
120
|
}
|
|
119
|
-
if (params?.offset) {
|
|
121
|
+
if (params?.offset !== null && params?.offset !== undefined && !isNaN(Number(params?.offset))) {
|
|
120
122
|
searchParams.set('offset', String(params.offset));
|
|
121
123
|
}
|
|
122
124
|
if (params?.resourceId) {
|
|
@@ -130,6 +132,47 @@ export class Workflow extends BaseResource {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves a specific workflow run by its ID
|
|
137
|
+
* @param runId - The ID of the workflow run to retrieve
|
|
138
|
+
* @returns Promise containing the workflow run details
|
|
139
|
+
*/
|
|
140
|
+
runById(runId: string): Promise<GetWorkflowRunByIdResponse> {
|
|
141
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves the execution result for a specific workflow run by its ID
|
|
146
|
+
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
147
|
+
* @returns Promise containing the workflow run execution result
|
|
148
|
+
*/
|
|
149
|
+
runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse> {
|
|
150
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Cancels a specific workflow run by its ID
|
|
155
|
+
* @param runId - The ID of the workflow run to cancel
|
|
156
|
+
* @returns Promise containing a success message
|
|
157
|
+
*/
|
|
158
|
+
cancelRun(runId: string): Promise<{ message: string }> {
|
|
159
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Sends an event to a specific workflow run by its ID
|
|
166
|
+
* @param params - Object containing the runId, event and data
|
|
167
|
+
* @returns Promise containing a success message
|
|
168
|
+
*/
|
|
169
|
+
sendRunEvent(params: { runId: string; event: string; data: unknown }): Promise<{ message: string }> {
|
|
170
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
|
|
171
|
+
method: 'POST',
|
|
172
|
+
body: { event: params.event, data: params.data },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
133
176
|
/**
|
|
134
177
|
* Creates a new workflow run
|
|
135
178
|
* @param params - Optional object containing the optional runId
|
|
@@ -217,9 +260,9 @@ export class Workflow extends BaseResource {
|
|
|
217
260
|
}
|
|
218
261
|
|
|
219
262
|
/**
|
|
220
|
-
* Starts a
|
|
263
|
+
* Starts a workflow run and returns a stream
|
|
221
264
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
222
|
-
* @returns Promise containing the
|
|
265
|
+
* @returns Promise containing the workflow execution results
|
|
223
266
|
*/
|
|
224
267
|
async stream(params: { runId?: string; inputData: Record<string, any>; runtimeContext?: RuntimeContext }) {
|
|
225
268
|
const searchParams = new URLSearchParams();
|
|
@@ -228,7 +271,7 @@ export class Workflow extends BaseResource {
|
|
|
228
271
|
searchParams.set('runId', params.runId);
|
|
229
272
|
}
|
|
230
273
|
|
|
231
|
-
const runtimeContext =
|
|
274
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
232
275
|
const response: Response = await this.request(
|
|
233
276
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
234
277
|
{
|
|
@@ -247,7 +290,7 @@ export class Workflow extends BaseResource {
|
|
|
247
290
|
}
|
|
248
291
|
|
|
249
292
|
// Create a transform stream that processes the response body
|
|
250
|
-
const transformStream = new TransformStream<ArrayBuffer,
|
|
293
|
+
const transformStream = new TransformStream<ArrayBuffer, { type: string; payload: any }>({
|
|
251
294
|
start() {},
|
|
252
295
|
async transform(chunk, controller) {
|
|
253
296
|
try {
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
QueryResult,
|
|
6
6
|
StorageThreadType,
|
|
7
7
|
WorkflowRuns,
|
|
8
|
+
WorkflowRun,
|
|
8
9
|
LegacyWorkflowRuns,
|
|
9
10
|
} from '@mastra/core';
|
|
10
11
|
import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
@@ -33,6 +34,7 @@ export interface ClientOptions {
|
|
|
33
34
|
/** Custom headers to include with requests */
|
|
34
35
|
headers?: Record<string, string>;
|
|
35
36
|
/** Abort signal for request */
|
|
37
|
+
abortSignal?: AbortSignal;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export interface RequestOptions {
|
|
@@ -40,7 +42,6 @@ export interface RequestOptions {
|
|
|
40
42
|
headers?: Record<string, string>;
|
|
41
43
|
body?: any;
|
|
42
44
|
stream?: boolean;
|
|
43
|
-
signal?: AbortSignal;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
type WithoutMethods<T> = {
|
|
@@ -70,7 +71,9 @@ export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undef
|
|
|
70
71
|
experimental_output?: T;
|
|
71
72
|
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
72
73
|
clientTools?: ToolsInput;
|
|
73
|
-
} & WithoutMethods<
|
|
74
|
+
} & WithoutMethods<
|
|
75
|
+
Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
76
|
+
>;
|
|
74
77
|
|
|
75
78
|
export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
76
79
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
@@ -78,7 +81,9 @@ export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefin
|
|
|
78
81
|
experimental_output?: T;
|
|
79
82
|
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
80
83
|
clientTools?: ToolsInput;
|
|
81
|
-
} & WithoutMethods<
|
|
84
|
+
} & WithoutMethods<
|
|
85
|
+
Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
86
|
+
>;
|
|
82
87
|
|
|
83
88
|
export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
84
89
|
evals: any[];
|
|
@@ -115,6 +120,10 @@ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
|
115
120
|
|
|
116
121
|
export type GetWorkflowRunsResponse = WorkflowRuns;
|
|
117
122
|
|
|
123
|
+
export type GetWorkflowRunByIdResponse = WorkflowRun;
|
|
124
|
+
|
|
125
|
+
export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
|
|
126
|
+
|
|
118
127
|
export type LegacyWorkflowRunResult = {
|
|
119
128
|
activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
|
|
120
129
|
results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
|
|
@@ -135,6 +144,17 @@ export interface GetWorkflowResponse {
|
|
|
135
144
|
suspendSchema: string;
|
|
136
145
|
};
|
|
137
146
|
};
|
|
147
|
+
allSteps: {
|
|
148
|
+
[key: string]: {
|
|
149
|
+
id: string;
|
|
150
|
+
description: string;
|
|
151
|
+
inputSchema: string;
|
|
152
|
+
outputSchema: string;
|
|
153
|
+
resumeSchema: string;
|
|
154
|
+
suspendSchema: string;
|
|
155
|
+
isWorkflow: boolean;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
138
158
|
stepGraph: Workflow['serializedStepGraph'];
|
|
139
159
|
inputSchema: string;
|
|
140
160
|
outputSchema: string;
|
|
@@ -178,6 +198,11 @@ export interface SaveMessageToMemoryParams {
|
|
|
178
198
|
agentId: string;
|
|
179
199
|
}
|
|
180
200
|
|
|
201
|
+
export interface SaveNetworkMessageToMemoryParams {
|
|
202
|
+
messages: MastraMessageV1[];
|
|
203
|
+
networkId: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
181
206
|
export type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
182
207
|
|
|
183
208
|
export interface CreateMemoryThreadParams {
|
|
@@ -188,6 +213,14 @@ export interface CreateMemoryThreadParams {
|
|
|
188
213
|
agentId: string;
|
|
189
214
|
}
|
|
190
215
|
|
|
216
|
+
export interface CreateNetworkMemoryThreadParams {
|
|
217
|
+
title?: string;
|
|
218
|
+
metadata?: Record<string, any>;
|
|
219
|
+
resourceId: string;
|
|
220
|
+
threadId?: string;
|
|
221
|
+
networkId: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
191
224
|
export type CreateMemoryThreadResponse = StorageThreadType;
|
|
192
225
|
|
|
193
226
|
export interface GetMemoryThreadParams {
|
|
@@ -195,6 +228,11 @@ export interface GetMemoryThreadParams {
|
|
|
195
228
|
agentId: string;
|
|
196
229
|
}
|
|
197
230
|
|
|
231
|
+
export interface GetNetworkMemoryThreadParams {
|
|
232
|
+
resourceId: string;
|
|
233
|
+
networkId: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
198
236
|
export type GetMemoryThreadResponse = StorageThreadType[];
|
|
199
237
|
|
|
200
238
|
export interface UpdateMemoryThreadParams {
|
|
@@ -301,6 +339,7 @@ export interface GetTelemetryParams {
|
|
|
301
339
|
}
|
|
302
340
|
|
|
303
341
|
export interface GetNetworkResponse {
|
|
342
|
+
id: string;
|
|
304
343
|
name: string;
|
|
305
344
|
instructions: string;
|
|
306
345
|
agents: Array<{
|
|
@@ -315,6 +354,61 @@ export interface GetNetworkResponse {
|
|
|
315
354
|
state?: Record<string, any>;
|
|
316
355
|
}
|
|
317
356
|
|
|
357
|
+
export interface GetVNextNetworkResponse {
|
|
358
|
+
id: string;
|
|
359
|
+
name: string;
|
|
360
|
+
instructions: string;
|
|
361
|
+
agents: Array<{
|
|
362
|
+
name: string;
|
|
363
|
+
provider: string;
|
|
364
|
+
modelId: string;
|
|
365
|
+
}>;
|
|
366
|
+
routingModel: {
|
|
367
|
+
provider: string;
|
|
368
|
+
modelId: string;
|
|
369
|
+
};
|
|
370
|
+
workflows: Array<{
|
|
371
|
+
name: string;
|
|
372
|
+
description: string;
|
|
373
|
+
inputSchema: string | undefined;
|
|
374
|
+
outputSchema: string | undefined;
|
|
375
|
+
}>;
|
|
376
|
+
tools: Array<{
|
|
377
|
+
id: string;
|
|
378
|
+
description: string;
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export interface GenerateVNextNetworkResponse {
|
|
383
|
+
task: string;
|
|
384
|
+
result: string;
|
|
385
|
+
resourceId: string;
|
|
386
|
+
resourceType: 'none' | 'tool' | 'agent' | 'workflow';
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface GenerateOrStreamVNextNetworkParams {
|
|
390
|
+
message: string;
|
|
391
|
+
threadId?: string;
|
|
392
|
+
resourceId?: string;
|
|
393
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface LoopStreamVNextNetworkParams {
|
|
397
|
+
message: string;
|
|
398
|
+
threadId?: string;
|
|
399
|
+
resourceId?: string;
|
|
400
|
+
maxIterations?: number;
|
|
401
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface LoopVNextNetworkResponse {
|
|
405
|
+
status: 'success';
|
|
406
|
+
result: {
|
|
407
|
+
text: string;
|
|
408
|
+
};
|
|
409
|
+
steps: WorkflowResult<any, any>['steps'];
|
|
410
|
+
}
|
|
411
|
+
|
|
318
412
|
export interface McpServerListResponse {
|
|
319
413
|
servers: ServerInfo[];
|
|
320
414
|
next: string | null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isVercelTool } from '@mastra/core/tools';
|
|
2
2
|
import { zodToJsonSchema } from './zod-to-json-schema';
|
|
3
|
+
import type { ToolsInput } from '@mastra/core/agent';
|
|
3
4
|
|
|
4
|
-
export function processClientTools(clientTools:
|
|
5
|
+
export function processClientTools(clientTools: ToolsInput | undefined): ToolsInput | undefined {
|
|
5
6
|
if (!clientTools) {
|
|
6
7
|
return undefined;
|
|
7
8
|
}
|
|
@@ -27,5 +28,5 @@ export function processClientTools(clientTools: Record<string, any> | undefined)
|
|
|
27
28
|
];
|
|
28
29
|
}
|
|
29
30
|
}),
|
|
30
|
-
)
|
|
31
|
+
);
|
|
31
32
|
}
|