@mastra/client-js 0.0.0-mcp-changeset-20250707162621 → 0.0.0-message-list-update-20250715150321
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 +109 -2
- package/LICENSE.md +11 -42
- package/dist/index.cjs +349 -271
- package/dist/index.d.cts +69 -39
- package/dist/index.d.ts +69 -39
- package/dist/index.js +350 -272
- package/package.json +5 -4
- package/src/client.ts +48 -2
- package/src/example.ts +45 -17
- package/src/resources/agent.ts +291 -254
- package/src/resources/base.ts +1 -0
- package/src/resources/vNextNetwork.ts +22 -5
- package/src/types.ts +9 -3
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-message-list-update-20250715150321",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
"directory": "client-sdks/client-js"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/mastra-ai/mastra/tree/main/client-sdks/client-js#readme",
|
|
28
|
-
"license": "
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ag-ui/client": "^0.0.27",
|
|
31
31
|
"@ai-sdk/ui-utils": "^1.2.11",
|
|
32
|
+
"@lukeed/uuid": "^2.0.1",
|
|
32
33
|
"json-schema": "^0.4.0",
|
|
33
34
|
"rxjs": "7.8.1",
|
|
34
35
|
"zod": "^3.25.67",
|
|
35
36
|
"zod-to-json-schema": "^3.24.5",
|
|
36
|
-
"@mastra/core": "0.0.0-
|
|
37
|
+
"@mastra/core": "0.0.0-message-list-update-20250715150321"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"zod": "^3.0.0"
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"tsup": "^8.5.0",
|
|
48
49
|
"typescript": "^5.8.3",
|
|
49
50
|
"vitest": "^3.2.4",
|
|
50
|
-
"@internal/lint": "0.0.0-
|
|
51
|
+
"@internal/lint": "0.0.0-message-list-update-20250715150321"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
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,
|
|
@@ -38,8 +40,6 @@ import type {
|
|
|
38
40
|
CreateNetworkMemoryThreadParams,
|
|
39
41
|
SaveNetworkMessageToMemoryParams,
|
|
40
42
|
} from './types';
|
|
41
|
-
import { VNextNetwork } from './resources/vNextNetwork';
|
|
42
|
-
import { NetworkMemoryThread } from './resources/network-memory-thread';
|
|
43
43
|
|
|
44
44
|
export class MastraClient extends BaseResource {
|
|
45
45
|
constructor(options: ClientOptions) {
|
|
@@ -477,4 +477,50 @@ export class MastraClient extends BaseResource {
|
|
|
477
477
|
public getA2A(agentId: string) {
|
|
478
478
|
return new A2A(this.options, agentId);
|
|
479
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
|
+
}
|
|
480
526
|
}
|
package/src/example.ts
CHANGED
|
@@ -14,25 +14,53 @@ import z from 'zod';
|
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
// }
|
|
36
64
|
} catch (error) {
|
|
37
65
|
console.error(error);
|
|
38
66
|
}
|