@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
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-cloudflare-deployer-dont-install-deps-20250714111754",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -19,30 +19,36 @@
|
|
|
19
19
|
},
|
|
20
20
|
"./package.json": "./package.json"
|
|
21
21
|
},
|
|
22
|
-
"repository":
|
|
23
|
-
|
|
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",
|
|
28
|
+
"license": "Apache-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",
|
|
32
|
+
"@lukeed/uuid": "^2.0.1",
|
|
27
33
|
"json-schema": "^0.4.0",
|
|
28
34
|
"rxjs": "7.8.1",
|
|
29
|
-
"zod": "^3.25.
|
|
35
|
+
"zod": "^3.25.67",
|
|
30
36
|
"zod-to-json-schema": "^3.24.5",
|
|
31
|
-
"@mastra/core": "0.0.0-
|
|
37
|
+
"@mastra/core": "0.0.0-cloudflare-deployer-dont-install-deps-20250714111754"
|
|
32
38
|
},
|
|
33
39
|
"peerDependencies": {
|
|
34
40
|
"zod": "^3.0.0"
|
|
35
41
|
},
|
|
36
42
|
"devDependencies": {
|
|
37
|
-
"@babel/preset-env": "^7.
|
|
38
|
-
"@babel/preset-typescript": "^7.27.
|
|
39
|
-
"@tsconfig/recommended": "^1.0.
|
|
43
|
+
"@babel/preset-env": "^7.27.2",
|
|
44
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
45
|
+
"@tsconfig/recommended": "^1.0.9",
|
|
40
46
|
"@types/json-schema": "^7.0.15",
|
|
41
|
-
"@types/node": "^20.
|
|
47
|
+
"@types/node": "^20.19.0",
|
|
42
48
|
"tsup": "^8.5.0",
|
|
43
|
-
"typescript": "^5.8.
|
|
44
|
-
"vitest": "^3.2.
|
|
45
|
-
"@internal/lint": "0.0.0-
|
|
49
|
+
"typescript": "^5.8.3",
|
|
50
|
+
"vitest": "^3.2.4",
|
|
51
|
+
"@internal/lint": "0.0.0-cloudflare-deployer-dont-install-deps-20250714111754"
|
|
46
52
|
},
|
|
47
53
|
"scripts": {
|
|
48
54
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
|
package/src/client.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
MCPTool,
|
|
14
14
|
LegacyWorkflow,
|
|
15
15
|
} from './resources';
|
|
16
|
+
import { NetworkMemoryThread } from './resources/network-memory-thread';
|
|
17
|
+
import { VNextNetwork } from './resources/vNextNetwork';
|
|
16
18
|
import type {
|
|
17
19
|
ClientOptions,
|
|
18
20
|
CreateMemoryThreadParams,
|
|
@@ -33,6 +35,10 @@ import type {
|
|
|
33
35
|
McpServerListResponse,
|
|
34
36
|
McpServerToolListResponse,
|
|
35
37
|
GetLegacyWorkflowResponse,
|
|
38
|
+
GetVNextNetworkResponse,
|
|
39
|
+
GetNetworkMemoryThreadParams,
|
|
40
|
+
CreateNetworkMemoryThreadParams,
|
|
41
|
+
SaveNetworkMessageToMemoryParams,
|
|
36
42
|
} from './types';
|
|
37
43
|
|
|
38
44
|
export class MastraClient extends BaseResource {
|
|
@@ -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
|
|
@@ -334,10 +387,18 @@ export class MastraClient extends BaseResource {
|
|
|
334
387
|
* Retrieves all available networks
|
|
335
388
|
* @returns Promise containing map of network IDs to network details
|
|
336
389
|
*/
|
|
337
|
-
public getNetworks(): Promise<
|
|
390
|
+
public getNetworks(): Promise<Array<GetNetworkResponse>> {
|
|
338
391
|
return this.request('/api/networks');
|
|
339
392
|
}
|
|
340
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
|
+
|
|
341
402
|
/**
|
|
342
403
|
* Gets a network instance by ID
|
|
343
404
|
* @param networkId - ID of the network to retrieve
|
|
@@ -347,6 +408,15 @@ export class MastraClient extends BaseResource {
|
|
|
347
408
|
return new Network(this.options, networkId);
|
|
348
409
|
}
|
|
349
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
|
+
|
|
350
420
|
/**
|
|
351
421
|
* Retrieves a list of available MCP servers.
|
|
352
422
|
* @param params - Optional parameters for pagination (limit, offset).
|
|
@@ -407,4 +477,50 @@ export class MastraClient extends BaseResource {
|
|
|
407
477
|
public getA2A(agentId: string) {
|
|
408
478
|
return new A2A(this.options, agentId);
|
|
409
479
|
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Retrieves the working memory for a specific thread (optionally resource-scoped).
|
|
483
|
+
* @param agentId - ID of the agent.
|
|
484
|
+
* @param threadId - ID of the thread.
|
|
485
|
+
* @param resourceId - Optional ID of the resource.
|
|
486
|
+
* @returns Working memory for the specified thread or resource.
|
|
487
|
+
*/
|
|
488
|
+
public getWorkingMemory({
|
|
489
|
+
agentId,
|
|
490
|
+
threadId,
|
|
491
|
+
resourceId,
|
|
492
|
+
}: {
|
|
493
|
+
agentId: string;
|
|
494
|
+
threadId: string;
|
|
495
|
+
resourceId?: string;
|
|
496
|
+
}) {
|
|
497
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Updates the working memory for a specific thread (optionally resource-scoped).
|
|
502
|
+
* @param agentId - ID of the agent.
|
|
503
|
+
* @param threadId - ID of the thread.
|
|
504
|
+
* @param workingMemory - The new working memory content.
|
|
505
|
+
* @param resourceId - Optional ID of the resource.
|
|
506
|
+
*/
|
|
507
|
+
public updateWorkingMemory({
|
|
508
|
+
agentId,
|
|
509
|
+
threadId,
|
|
510
|
+
workingMemory,
|
|
511
|
+
resourceId,
|
|
512
|
+
}: {
|
|
513
|
+
agentId: string;
|
|
514
|
+
threadId: string;
|
|
515
|
+
workingMemory: string;
|
|
516
|
+
resourceId?: string;
|
|
517
|
+
}) {
|
|
518
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
|
|
519
|
+
method: 'POST',
|
|
520
|
+
body: {
|
|
521
|
+
workingMemory,
|
|
522
|
+
resourceId,
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
}
|
|
410
526
|
}
|
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',
|
|
@@ -14,22 +14,53 @@ import { MastraClient } from './client';
|
|
|
14
14
|
const agent = client.getAgent('weatherAgent');
|
|
15
15
|
const response = await agent.stream({
|
|
16
16
|
messages: 'what is the weather in new york?',
|
|
17
|
+
output: z.object({
|
|
18
|
+
weather: z.string(),
|
|
19
|
+
temperature: z.number(),
|
|
20
|
+
humidity: z.number(),
|
|
21
|
+
windSpeed: z.number(),
|
|
22
|
+
windDirection: z.string(),
|
|
23
|
+
windGust: z.number(),
|
|
24
|
+
windChill: z.number(),
|
|
25
|
+
}),
|
|
17
26
|
});
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// Process data stream - unstructured output
|
|
29
|
+
|
|
30
|
+
// response.processDataStream({
|
|
31
|
+
// onTextPart: text => {
|
|
32
|
+
// process.stdout.write(text);
|
|
33
|
+
// },
|
|
34
|
+
// onFilePart: file => {
|
|
35
|
+
// console.log(file);
|
|
36
|
+
// },
|
|
37
|
+
// onDataPart: data => {
|
|
38
|
+
// console.log(data);
|
|
39
|
+
// },
|
|
40
|
+
// onErrorPart: error => {
|
|
41
|
+
// console.error(error);
|
|
42
|
+
// },
|
|
43
|
+
// onToolCallPart(streamPart) {
|
|
44
|
+
// console.log(streamPart);
|
|
45
|
+
// },
|
|
46
|
+
// });
|
|
47
|
+
|
|
48
|
+
// Process text stream - structured output
|
|
49
|
+
|
|
50
|
+
// response.processTextStream({
|
|
51
|
+
// onTextPart: text => {
|
|
52
|
+
// process.stdout.write(text);
|
|
53
|
+
// },
|
|
54
|
+
// });
|
|
55
|
+
|
|
56
|
+
// read the response body directly
|
|
57
|
+
|
|
58
|
+
// const reader = response.body!.getReader();
|
|
59
|
+
// while (true) {
|
|
60
|
+
// const { done, value } = await reader.read();
|
|
61
|
+
// if (done) break;
|
|
62
|
+
// console.log(new TextDecoder().decode(value));
|
|
63
|
+
// }
|
|
33
64
|
} catch (error) {
|
|
34
65
|
console.error(error);
|
|
35
66
|
}
|