@mastra/client-js 0.10.21-alpha.0 → 0.10.21-alpha.2
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 +7 -7
- package/CHANGELOG.md +22 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +40 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/dist/resources/a2a.d.ts +13 -16
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +11 -0
- package/dist/resources/agent.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +8 -0
- package/src/resources/a2a.ts +35 -25
- package/src/resources/agent.ts +13 -1
package/dist/resources/a2a.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentCard, GetTaskResponse, MessageSendParams, SendMessageResponse, SendStreamingMessageResponse, Task, TaskQueryParams } from '@mastra/core/a2a';
|
|
2
2
|
import type { ClientOptions } from '../types.js';
|
|
3
3
|
import { BaseResource } from './base.js';
|
|
4
4
|
/**
|
|
@@ -13,32 +13,29 @@ export declare class A2A extends BaseResource {
|
|
|
13
13
|
*/
|
|
14
14
|
getCard(): Promise<AgentCard>;
|
|
15
15
|
/**
|
|
16
|
-
* Send a message to the agent and
|
|
16
|
+
* Send a message to the agent and gets a message or task response
|
|
17
17
|
* @param params - Parameters for the task
|
|
18
|
-
* @returns Promise containing the
|
|
18
|
+
* @returns Promise containing the response
|
|
19
|
+
*/
|
|
20
|
+
sendMessage(params: MessageSendParams): Promise<SendMessageResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Sends a message to an agent to initiate/continue a task and subscribes
|
|
23
|
+
* the client to real-time updates for that task via Server-Sent Events (SSE).
|
|
24
|
+
* @param params - Parameters for the task
|
|
25
|
+
* @returns A stream of Server-Sent Events. Each SSE `data` field contains a `SendStreamingMessageResponse`
|
|
19
26
|
*/
|
|
20
|
-
|
|
21
|
-
task: Task;
|
|
22
|
-
}>;
|
|
27
|
+
sendStreamingMessage(params: MessageSendParams): Promise<AsyncIterable<SendStreamingMessageResponse>>;
|
|
23
28
|
/**
|
|
24
29
|
* Get the status and result of a task
|
|
25
30
|
* @param params - Parameters for querying the task
|
|
26
31
|
* @returns Promise containing the task response
|
|
27
32
|
*/
|
|
28
|
-
getTask(params: TaskQueryParams): Promise<
|
|
33
|
+
getTask(params: TaskQueryParams): Promise<GetTaskResponse>;
|
|
29
34
|
/**
|
|
30
35
|
* Cancel a running task
|
|
31
36
|
* @param params - Parameters identifying the task to cancel
|
|
32
37
|
* @returns Promise containing the task response
|
|
33
38
|
*/
|
|
34
|
-
cancelTask(params:
|
|
35
|
-
task: Task;
|
|
36
|
-
}>;
|
|
37
|
-
/**
|
|
38
|
-
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
39
|
-
* @param params - Parameters for the task
|
|
40
|
-
* @returns Promise containing the task response
|
|
41
|
-
*/
|
|
42
|
-
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
39
|
+
cancelTask(params: TaskQueryParams): Promise<Task>;
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=a2a.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../src/resources/a2a.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../src/resources/a2a.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,IAAI,EACJ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC;;GAEG;AACH,qBAAa,GAAI,SAAQ,YAAY;IAGjC,OAAO,CAAC,OAAO;gBADf,OAAO,EAAE,aAAa,EACd,OAAO,EAAE,MAAM;IAKzB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;IAInC;;;;OAIG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAY1E;;;;;OAKG;IACG,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC;IAY3G;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAYhE;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CASzD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
2
|
+
import { type MastraLanguageModel } from '@mastra/core';
|
|
2
3
|
import { type GenerateReturn } from '@mastra/core/llm';
|
|
3
4
|
import type { JSONSchema7 } from 'json-schema';
|
|
4
5
|
import { ZodSchema } from 'zod';
|
|
@@ -108,5 +109,15 @@ export declare class Agent extends BaseResource {
|
|
|
108
109
|
* @returns Promise containing live agent evaluations
|
|
109
110
|
*/
|
|
110
111
|
liveEvals(): Promise<GetEvalsByAgentIdResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Updates the model for the agent
|
|
114
|
+
* @param params - Parameters for updating the model
|
|
115
|
+
* @returns Promise containing the updated model
|
|
116
|
+
*/
|
|
117
|
+
updateModel(params: {
|
|
118
|
+
model: MastraLanguageModel;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
message: string;
|
|
121
|
+
}>;
|
|
111
122
|
}
|
|
112
123
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/resources/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAQlB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/resources/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAQlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAKhC,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,aAAa,EACb,YAAY,EACb,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,qBAAa,UAAW,SAAQ,YAAY;IAGxC,OAAO,CAAC,OAAO;gBADf,OAAO,EAAE,aAAa,EACd,OAAO,EAAE,MAAM;IAMzB;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWhG;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAc7E;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MA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Y,CAAC,CAAC,CAAC,GACtB,OAAO,CACR,QAAQ,GAAG;QACT,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACzG,CACF;IAmCD;;OAEG;YACW,qBAAqB;IAgJnC;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIjD;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,IAAI,EAAE,GAAG,CAAC;QAAC,cAAc,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAWjG;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAI3C;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAI/C;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAMlF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.10.21-alpha.
|
|
3
|
+
"version": "0.10.21-alpha.2",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"rxjs": "7.8.1",
|
|
35
35
|
"zod": "^3.25.67",
|
|
36
36
|
"zod-to-json-schema": "^3.24.5",
|
|
37
|
-
"@mastra/core": "0.13.2-alpha.
|
|
37
|
+
"@mastra/core": "0.13.2-alpha.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"zod": "^3.0.0"
|
package/src/client.ts
CHANGED
|
@@ -620,4 +620,12 @@ export class MastraClient extends BaseResource {
|
|
|
620
620
|
body: params,
|
|
621
621
|
});
|
|
622
622
|
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Retrieves model providers with available keys
|
|
626
|
+
* @returns Promise containing model providers with available keys
|
|
627
|
+
*/
|
|
628
|
+
getModelProviders(): Promise<string[]> {
|
|
629
|
+
return this.request(`/api/model-providers`);
|
|
630
|
+
}
|
|
623
631
|
}
|
package/src/resources/a2a.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AgentCard,
|
|
3
|
+
GetTaskResponse,
|
|
4
|
+
MessageSendParams,
|
|
5
|
+
SendMessageResponse,
|
|
6
|
+
SendStreamingMessageResponse,
|
|
7
|
+
Task,
|
|
8
|
+
TaskQueryParams,
|
|
9
|
+
} from '@mastra/core/a2a';
|
|
2
10
|
import type { ClientOptions } from '../types';
|
|
3
11
|
import { BaseResource } from './base';
|
|
4
12
|
|
|
@@ -18,71 +26,73 @@ export class A2A extends BaseResource {
|
|
|
18
26
|
* @returns Promise containing the agent card information
|
|
19
27
|
*/
|
|
20
28
|
async getCard(): Promise<AgentCard> {
|
|
21
|
-
return this.request(`/.well-known/${this.agentId}/agent.json`);
|
|
29
|
+
return this.request(`/.well-known/${this.agentId}/agent-card.json`);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
|
-
* Send a message to the agent and
|
|
33
|
+
* Send a message to the agent and gets a message or task response
|
|
26
34
|
* @param params - Parameters for the task
|
|
27
|
-
* @returns Promise containing the
|
|
35
|
+
* @returns Promise containing the response
|
|
28
36
|
*/
|
|
29
|
-
async sendMessage(params:
|
|
30
|
-
const response = await this.request<
|
|
37
|
+
async sendMessage(params: MessageSendParams): Promise<SendMessageResponse> {
|
|
38
|
+
const response = await this.request<SendMessageResponse>(`/a2a/${this.agentId}`, {
|
|
31
39
|
method: 'POST',
|
|
32
40
|
body: {
|
|
33
|
-
method: '
|
|
41
|
+
method: 'message/send',
|
|
34
42
|
params,
|
|
35
43
|
},
|
|
36
44
|
});
|
|
37
45
|
|
|
38
|
-
return
|
|
46
|
+
return response;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
50
|
+
* Sends a message to an agent to initiate/continue a task and subscribes
|
|
51
|
+
* the client to real-time updates for that task via Server-Sent Events (SSE).
|
|
52
|
+
* @param params - Parameters for the task
|
|
53
|
+
* @returns A stream of Server-Sent Events. Each SSE `data` field contains a `SendStreamingMessageResponse`
|
|
45
54
|
*/
|
|
46
|
-
async
|
|
47
|
-
const response = await this.request<
|
|
55
|
+
async sendStreamingMessage(params: MessageSendParams): Promise<AsyncIterable<SendStreamingMessageResponse>> {
|
|
56
|
+
const response = await this.request<AsyncIterable<SendStreamingMessageResponse>>(`/a2a/${this.agentId}`, {
|
|
48
57
|
method: 'POST',
|
|
49
58
|
body: {
|
|
50
|
-
method: '
|
|
59
|
+
method: 'message/stream',
|
|
51
60
|
params,
|
|
52
61
|
},
|
|
53
62
|
});
|
|
54
63
|
|
|
55
|
-
return response
|
|
64
|
+
return response;
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param params - Parameters
|
|
68
|
+
* Get the status and result of a task
|
|
69
|
+
* @param params - Parameters for querying the task
|
|
61
70
|
* @returns Promise containing the task response
|
|
62
71
|
*/
|
|
63
|
-
async
|
|
64
|
-
|
|
72
|
+
async getTask(params: TaskQueryParams): Promise<GetTaskResponse> {
|
|
73
|
+
const response = await this.request<GetTaskResponse>(`/a2a/${this.agentId}`, {
|
|
65
74
|
method: 'POST',
|
|
66
75
|
body: {
|
|
67
|
-
method: 'tasks/
|
|
76
|
+
method: 'tasks/get',
|
|
68
77
|
params,
|
|
69
78
|
},
|
|
70
79
|
});
|
|
80
|
+
|
|
81
|
+
return response;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param params - Parameters
|
|
85
|
+
* Cancel a running task
|
|
86
|
+
* @param params - Parameters identifying the task to cancel
|
|
76
87
|
* @returns Promise containing the task response
|
|
77
88
|
*/
|
|
78
|
-
async
|
|
89
|
+
async cancelTask(params: TaskQueryParams): Promise<Task> {
|
|
79
90
|
return this.request(`/a2a/${this.agentId}`, {
|
|
80
91
|
method: 'POST',
|
|
81
92
|
body: {
|
|
82
|
-
method: 'tasks/
|
|
93
|
+
method: 'tasks/cancel',
|
|
83
94
|
params,
|
|
84
95
|
},
|
|
85
|
-
stream: true,
|
|
86
96
|
});
|
|
87
97
|
}
|
|
88
98
|
}
|
package/src/resources/agent.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type UIMessage,
|
|
10
10
|
type UseChatOptions,
|
|
11
11
|
} from '@ai-sdk/ui-utils';
|
|
12
|
-
import { Tool, type CoreMessage } from '@mastra/core';
|
|
12
|
+
import { Tool, type CoreMessage, type MastraLanguageModel } from '@mastra/core';
|
|
13
13
|
import { type GenerateReturn } from '@mastra/core/llm';
|
|
14
14
|
import type { JSONSchema7 } from 'json-schema';
|
|
15
15
|
import { ZodSchema } from 'zod';
|
|
@@ -782,4 +782,16 @@ export class Agent extends BaseResource {
|
|
|
782
782
|
liveEvals(): Promise<GetEvalsByAgentIdResponse> {
|
|
783
783
|
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
784
784
|
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Updates the model for the agent
|
|
788
|
+
* @param params - Parameters for updating the model
|
|
789
|
+
* @returns Promise containing the updated model
|
|
790
|
+
*/
|
|
791
|
+
updateModel(params: { model: MastraLanguageModel }): Promise<{ message: string }> {
|
|
792
|
+
return this.request(`/api/agents/${this.agentId}/model`, {
|
|
793
|
+
method: 'POST',
|
|
794
|
+
body: params,
|
|
795
|
+
});
|
|
796
|
+
}
|
|
785
797
|
}
|