@mastra/client-js 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-tool-call-parts-20250630193309
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 +9 -9
- package/CHANGELOG.md +322 -2
- package/README.md +1 -1
- package/dist/index.cjs +754 -23
- package/dist/index.d.cts +239 -13
- package/dist/index.d.ts +239 -13
- package/dist/index.js +755 -24
- package/package.json +20 -16
- package/src/client.ts +149 -3
- package/src/example.ts +4 -1
- package/src/resources/agent.ts +550 -10
- package/src/resources/base.ts +1 -0
- package/src/resources/network-memory-thread.ts +63 -0
- package/src/resources/network.ts +2 -3
- package/src/resources/vNextNetwork.ts +177 -0
- package/src/resources/workflow.ts +24 -4
- package/src/types.ts +102 -5
- package/src/utils/process-client-tools.ts +32 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-tool-call-parts-20250630193309",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -19,31 +19,35 @@
|
|
|
19
19
|
},
|
|
20
20
|
"./package.json": "./package.json"
|
|
21
21
|
},
|
|
22
|
-
"repository":
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/mastra-ai/mastra.git",
|
|
25
|
+
"directory": "client-sdks/client-js"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/mastra-ai/mastra/tree/main/client-sdks/client-js#readme",
|
|
23
28
|
"license": "Elastic-2.0",
|
|
24
29
|
"dependencies": {
|
|
25
30
|
"@ag-ui/client": "^0.0.27",
|
|
26
|
-
"@ai-sdk/ui-utils": "^1.
|
|
31
|
+
"@ai-sdk/ui-utils": "^1.2.11",
|
|
27
32
|
"json-schema": "^0.4.0",
|
|
28
33
|
"rxjs": "7.8.1",
|
|
29
|
-
"zod": "^3.
|
|
30
|
-
"zod-to-json-schema": "^3.24.5"
|
|
34
|
+
"zod": "^3.25.67",
|
|
35
|
+
"zod-to-json-schema": "^3.24.5",
|
|
36
|
+
"@mastra/core": "0.0.0-tool-call-parts-20250630193309"
|
|
31
37
|
},
|
|
32
38
|
"peerDependencies": {
|
|
33
|
-
"zod": "^3.0.0"
|
|
34
|
-
"@mastra/core": "^0.10.0-alpha.0"
|
|
39
|
+
"zod": "^3.0.0"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
|
-
"@babel/preset-env": "^7.
|
|
38
|
-
"@babel/preset-typescript": "^7.27.
|
|
39
|
-
"@tsconfig/recommended": "^1.0.
|
|
42
|
+
"@babel/preset-env": "^7.27.2",
|
|
43
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
44
|
+
"@tsconfig/recommended": "^1.0.9",
|
|
40
45
|
"@types/json-schema": "^7.0.15",
|
|
41
|
-
"@types/node": "^20.
|
|
42
|
-
"tsup": "^8.
|
|
43
|
-
"typescript": "^5.8.
|
|
44
|
-
"vitest": "^3.
|
|
45
|
-
"@internal/lint": "0.0.0-
|
|
46
|
-
"@mastra/core": "0.0.0-taofeeqInngest-20250603090617"
|
|
46
|
+
"@types/node": "^20.19.0",
|
|
47
|
+
"tsup": "^8.5.0",
|
|
48
|
+
"typescript": "^5.8.3",
|
|
49
|
+
"vitest": "^3.2.3",
|
|
50
|
+
"@internal/lint": "0.0.0-tool-call-parts-20250630193309"
|
|
47
51
|
},
|
|
48
52
|
"scripts": {
|
|
49
53
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
|
package/src/client.ts
CHANGED
|
@@ -33,7 +33,13 @@ import type {
|
|
|
33
33
|
McpServerListResponse,
|
|
34
34
|
McpServerToolListResponse,
|
|
35
35
|
GetLegacyWorkflowResponse,
|
|
36
|
+
GetVNextNetworkResponse,
|
|
37
|
+
GetNetworkMemoryThreadParams,
|
|
38
|
+
CreateNetworkMemoryThreadParams,
|
|
39
|
+
SaveNetworkMessageToMemoryParams,
|
|
36
40
|
} from './types';
|
|
41
|
+
import { VNextNetwork } from './resources/vNextNetwork';
|
|
42
|
+
import { NetworkMemoryThread } from './resources/network-memory-thread';
|
|
37
43
|
|
|
38
44
|
export class MastraClient extends BaseResource {
|
|
39
45
|
constructor(options: ClientOptions) {
|
|
@@ -123,6 +129,53 @@ export class MastraClient extends BaseResource {
|
|
|
123
129
|
return this.request(`/api/memory/status?agentId=${agentId}`);
|
|
124
130
|
}
|
|
125
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Retrieves memory threads for a resource
|
|
134
|
+
* @param params - Parameters containing the resource ID
|
|
135
|
+
* @returns Promise containing array of memory threads
|
|
136
|
+
*/
|
|
137
|
+
public getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse> {
|
|
138
|
+
return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new memory thread
|
|
143
|
+
* @param params - Parameters for creating the memory thread
|
|
144
|
+
* @returns Promise containing the created memory thread
|
|
145
|
+
*/
|
|
146
|
+
public createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
|
|
147
|
+
return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: 'POST', body: params });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets a memory thread instance by ID
|
|
152
|
+
* @param threadId - ID of the memory thread to retrieve
|
|
153
|
+
* @returns MemoryThread instance
|
|
154
|
+
*/
|
|
155
|
+
public getNetworkMemoryThread(threadId: string, networkId: string) {
|
|
156
|
+
return new NetworkMemoryThread(this.options, threadId, networkId);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Saves messages to memory
|
|
161
|
+
* @param params - Parameters containing messages to save
|
|
162
|
+
* @returns Promise containing the saved messages
|
|
163
|
+
*/
|
|
164
|
+
public saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
|
|
165
|
+
return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
|
|
166
|
+
method: 'POST',
|
|
167
|
+
body: params,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Gets the status of the memory system
|
|
173
|
+
* @returns Promise containing memory system status
|
|
174
|
+
*/
|
|
175
|
+
public getNetworkMemoryStatus(networkId: string): Promise<{ result: boolean }> {
|
|
176
|
+
return this.request(`/api/memory/network/status?networkId=${networkId}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
126
179
|
/**
|
|
127
180
|
* Retrieves all available tools
|
|
128
181
|
* @returns Promise containing map of tool IDs to tool details
|
|
@@ -189,7 +242,43 @@ export class MastraClient extends BaseResource {
|
|
|
189
242
|
* @returns Promise containing array of log messages
|
|
190
243
|
*/
|
|
191
244
|
public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
|
|
192
|
-
|
|
245
|
+
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
246
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
247
|
+
|
|
248
|
+
const searchParams = new URLSearchParams();
|
|
249
|
+
if (transportId) {
|
|
250
|
+
searchParams.set('transportId', transportId);
|
|
251
|
+
}
|
|
252
|
+
if (fromDate) {
|
|
253
|
+
searchParams.set('fromDate', fromDate.toISOString());
|
|
254
|
+
}
|
|
255
|
+
if (toDate) {
|
|
256
|
+
searchParams.set('toDate', toDate.toISOString());
|
|
257
|
+
}
|
|
258
|
+
if (logLevel) {
|
|
259
|
+
searchParams.set('logLevel', logLevel);
|
|
260
|
+
}
|
|
261
|
+
if (page) {
|
|
262
|
+
searchParams.set('page', String(page));
|
|
263
|
+
}
|
|
264
|
+
if (perPage) {
|
|
265
|
+
searchParams.set('perPage', String(perPage));
|
|
266
|
+
}
|
|
267
|
+
if (_filters) {
|
|
268
|
+
if (Array.isArray(_filters)) {
|
|
269
|
+
for (const filter of _filters) {
|
|
270
|
+
searchParams.append('filters', filter);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
searchParams.set('filters', _filters);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (searchParams.size) {
|
|
278
|
+
return this.request(`/api/logs?${searchParams}`);
|
|
279
|
+
} else {
|
|
280
|
+
return this.request(`/api/logs`);
|
|
281
|
+
}
|
|
193
282
|
}
|
|
194
283
|
|
|
195
284
|
/**
|
|
@@ -198,7 +287,47 @@ export class MastraClient extends BaseResource {
|
|
|
198
287
|
* @returns Promise containing array of log messages
|
|
199
288
|
*/
|
|
200
289
|
public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
|
|
201
|
-
|
|
290
|
+
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
291
|
+
|
|
292
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
293
|
+
const searchParams = new URLSearchParams();
|
|
294
|
+
if (runId) {
|
|
295
|
+
searchParams.set('runId', runId);
|
|
296
|
+
}
|
|
297
|
+
if (transportId) {
|
|
298
|
+
searchParams.set('transportId', transportId);
|
|
299
|
+
}
|
|
300
|
+
if (fromDate) {
|
|
301
|
+
searchParams.set('fromDate', fromDate.toISOString());
|
|
302
|
+
}
|
|
303
|
+
if (toDate) {
|
|
304
|
+
searchParams.set('toDate', toDate.toISOString());
|
|
305
|
+
}
|
|
306
|
+
if (logLevel) {
|
|
307
|
+
searchParams.set('logLevel', logLevel);
|
|
308
|
+
}
|
|
309
|
+
if (page) {
|
|
310
|
+
searchParams.set('page', String(page));
|
|
311
|
+
}
|
|
312
|
+
if (perPage) {
|
|
313
|
+
searchParams.set('perPage', String(perPage));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (_filters) {
|
|
317
|
+
if (Array.isArray(_filters)) {
|
|
318
|
+
for (const filter of _filters) {
|
|
319
|
+
searchParams.append('filters', filter);
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
searchParams.set('filters', _filters);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (searchParams.size) {
|
|
327
|
+
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
328
|
+
} else {
|
|
329
|
+
return this.request(`/api/logs/${runId}`);
|
|
330
|
+
}
|
|
202
331
|
}
|
|
203
332
|
|
|
204
333
|
/**
|
|
@@ -258,10 +387,18 @@ export class MastraClient extends BaseResource {
|
|
|
258
387
|
* Retrieves all available networks
|
|
259
388
|
* @returns Promise containing map of network IDs to network details
|
|
260
389
|
*/
|
|
261
|
-
public getNetworks(): Promise<
|
|
390
|
+
public getNetworks(): Promise<Array<GetNetworkResponse>> {
|
|
262
391
|
return this.request('/api/networks');
|
|
263
392
|
}
|
|
264
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Retrieves all available vNext networks
|
|
396
|
+
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
397
|
+
*/
|
|
398
|
+
public getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>> {
|
|
399
|
+
return this.request('/api/networks/v-next');
|
|
400
|
+
}
|
|
401
|
+
|
|
265
402
|
/**
|
|
266
403
|
* Gets a network instance by ID
|
|
267
404
|
* @param networkId - ID of the network to retrieve
|
|
@@ -271,6 +408,15 @@ export class MastraClient extends BaseResource {
|
|
|
271
408
|
return new Network(this.options, networkId);
|
|
272
409
|
}
|
|
273
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Gets a vNext network instance by ID
|
|
413
|
+
* @param networkId - ID of the vNext network to retrieve
|
|
414
|
+
* @returns vNext Network instance
|
|
415
|
+
*/
|
|
416
|
+
public getVNextNetwork(networkId: string) {
|
|
417
|
+
return new VNextNetwork(this.options, networkId);
|
|
418
|
+
}
|
|
419
|
+
|
|
274
420
|
/**
|
|
275
421
|
* Retrieves a list of available MCP servers.
|
|
276
422
|
* @param params - Optional parameters for pagination (limit, offset).
|
package/src/example.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MastraClient } from './client';
|
|
2
|
+
import z from 'zod';
|
|
2
3
|
// import type { WorkflowRunResult } from './types';
|
|
3
4
|
|
|
4
5
|
// Agent
|
|
5
|
-
|
|
6
6
|
(async () => {
|
|
7
7
|
const client = new MastraClient({
|
|
8
8
|
baseUrl: 'http://localhost:4111',
|
|
@@ -29,6 +29,9 @@ import { MastraClient } from './client';
|
|
|
29
29
|
onErrorPart: error => {
|
|
30
30
|
console.error(error);
|
|
31
31
|
},
|
|
32
|
+
onToolCallPart(streamPart) {
|
|
33
|
+
console.log(streamPart);
|
|
34
|
+
},
|
|
32
35
|
});
|
|
33
36
|
} catch (error) {
|
|
34
37
|
console.error(error);
|