@mastra/client-js 0.0.0-ai-v5-20250801192614 → 0.0.0-ai-v5-20250813235735
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 +16 -2
- package/CHANGELOG.md +143 -2
- package/dist/adapters/agui.d.ts +1 -1
- package/dist/adapters/agui.d.ts.map +1 -1
- package/dist/client.d.ts +9 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +63 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -34
- package/dist/index.js.map +1 -1
- package/dist/resources/a2a.d.ts +15 -18
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +13 -2
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/base.d.ts +1 -1
- package/dist/resources/index.d.ts +10 -10
- package/dist/resources/legacy-workflow.d.ts +2 -2
- package/dist/resources/mcp-tool.d.ts +2 -2
- package/dist/resources/memory-thread.d.ts +2 -2
- package/dist/resources/network-memory-thread.d.ts +2 -2
- package/dist/resources/network.d.ts +2 -2
- package/dist/resources/tool.d.ts +2 -2
- package/dist/resources/vNextNetwork.d.ts +2 -2
- package/dist/resources/vector.d.ts +2 -2
- package/dist/resources/workflow.d.ts +2 -2
- package/package.json +7 -5
- package/src/adapters/agui.ts +27 -15
- package/src/client.ts +8 -0
- package/src/resources/a2a.ts +35 -25
- package/src/resources/agent.ts +13 -1
- package/tsup.config.ts +2 -7
package/dist/resources/a2a.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ClientOptions } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
1
|
+
import type { AgentCard, GetTaskResponse, MessageSendParams, SendMessageResponse, SendStreamingMessageResponse, Task, TaskQueryParams } from '@mastra/core/a2a';
|
|
2
|
+
import type { ClientOptions } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class for interacting with an agent via the A2A protocol
|
|
6
6
|
*/
|
|
@@ -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,9 +1,10 @@
|
|
|
1
1
|
import { processDataStream } from 'ai';
|
|
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';
|
|
5
|
-
import type { GenerateParams, GetAgentResponse, GetEvalsByAgentIdResponse, GetToolResponse, ClientOptions, StreamParams } from '../types';
|
|
6
|
-
import { BaseResource } from './base';
|
|
6
|
+
import type { GenerateParams, GetAgentResponse, GetEvalsByAgentIdResponse, GetToolResponse, ClientOptions, StreamParams } from '../types.js';
|
|
7
|
+
import { BaseResource } from './base.js';
|
|
7
8
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
8
9
|
export declare class AgentVoice extends BaseResource {
|
|
9
10
|
private agentId;
|
|
@@ -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,EAAE,iBAAiB,EAAuD,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/resources/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuD,MAAM,IAAI,CAAC;AAC5F,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAA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ACH,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/dist/resources/base.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './agent';
|
|
2
|
-
export * from './network';
|
|
3
|
-
export * from './memory-thread';
|
|
4
|
-
export * from './vector';
|
|
5
|
-
export * from './legacy-workflow';
|
|
6
|
-
export * from './tool';
|
|
7
|
-
export * from './base';
|
|
8
|
-
export * from './workflow';
|
|
9
|
-
export * from './a2a';
|
|
10
|
-
export * from './mcp-tool';
|
|
1
|
+
export * from './agent.js';
|
|
2
|
+
export * from './network.js';
|
|
3
|
+
export * from './memory-thread.js';
|
|
4
|
+
export * from './vector.js';
|
|
5
|
+
export * from './legacy-workflow.js';
|
|
6
|
+
export * from './tool.js';
|
|
7
|
+
export * from './base.js';
|
|
8
|
+
export * from './workflow.js';
|
|
9
|
+
export * from './a2a.js';
|
|
10
|
+
export * from './mcp-tool.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ClientOptions, LegacyWorkflowRunResult, GetLegacyWorkflowRunsResponse, GetWorkflowRunsParams, GetLegacyWorkflowResponse } from '../types';
|
|
2
|
-
import { BaseResource } from './base';
|
|
1
|
+
import type { ClientOptions, LegacyWorkflowRunResult, GetLegacyWorkflowRunsResponse, GetWorkflowRunsParams, GetLegacyWorkflowResponse } from '../types.js';
|
|
2
|
+
import { BaseResource } from './base.js';
|
|
3
3
|
export declare class LegacyWorkflow extends BaseResource {
|
|
4
4
|
private workflowId;
|
|
5
5
|
constructor(options: ClientOptions, workflowId: string);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
2
|
-
import type { ClientOptions, McpToolInfo } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { ClientOptions, McpToolInfo } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a specific tool available on a specific MCP server.
|
|
6
6
|
* Provides methods to get details and execute the tool.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StorageThreadType } from '@mastra/core';
|
|
2
|
-
import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams, GetMemoryThreadMessagesParams, GetMemoryThreadMessagesPaginatedParams, GetMemoryThreadMessagesPaginatedResponse } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams, GetMemoryThreadMessagesParams, GetMemoryThreadMessagesPaginatedParams, GetMemoryThreadMessagesPaginatedResponse } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
export declare class MemoryThread extends BaseResource {
|
|
5
5
|
private threadId;
|
|
6
6
|
private agentId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StorageThreadType } from '@mastra/core';
|
|
2
|
-
import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams, GetMemoryThreadMessagesParams } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams, GetMemoryThreadMessagesParams } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
export declare class NetworkMemoryThread extends BaseResource {
|
|
5
5
|
private threadId;
|
|
6
6
|
private networkId;
|
|
@@ -2,8 +2,8 @@ import { processDataStream } from 'ai';
|
|
|
2
2
|
import type { GenerateReturn } from '@mastra/core';
|
|
3
3
|
import type { JSONSchema7 } from 'json-schema';
|
|
4
4
|
import type { ZodSchema } from 'zod';
|
|
5
|
-
import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
|
|
6
|
-
import { BaseResource } from './base';
|
|
5
|
+
import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types.js';
|
|
6
|
+
import { BaseResource } from './base.js';
|
|
7
7
|
export declare class Network extends BaseResource {
|
|
8
8
|
private networkId;
|
|
9
9
|
constructor(options: ClientOptions, networkId: string);
|
package/dist/resources/tool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
2
|
-
import type { GetToolResponse, ClientOptions } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { GetToolResponse, ClientOptions } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
export declare class Tool extends BaseResource {
|
|
5
5
|
private toolId;
|
|
6
6
|
constructor(options: ClientOptions, toolId: string);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
2
|
-
import type { ClientOptions, GetVNextNetworkResponse, GenerateVNextNetworkResponse, LoopVNextNetworkResponse, GenerateOrStreamVNextNetworkParams, LoopStreamVNextNetworkParams } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { ClientOptions, GetVNextNetworkResponse, GenerateVNextNetworkResponse, LoopVNextNetworkResponse, GenerateOrStreamVNextNetworkParams, LoopStreamVNextNetworkParams } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
5
5
|
export declare class VNextNetwork extends BaseResource {
|
|
6
6
|
private networkId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CreateIndexParams, GetVectorIndexResponse, QueryVectorParams, QueryVectorResponse, ClientOptions, UpsertVectorParams } from '../types';
|
|
2
|
-
import { BaseResource } from './base';
|
|
1
|
+
import type { CreateIndexParams, GetVectorIndexResponse, QueryVectorParams, QueryVectorResponse, ClientOptions, UpsertVectorParams } from '../types.js';
|
|
2
|
+
import { BaseResource } from './base.js';
|
|
3
3
|
export declare class Vector extends BaseResource {
|
|
4
4
|
private vectorName;
|
|
5
5
|
constructor(options: ClientOptions, vectorName: string);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
2
|
-
import type { ClientOptions, GetWorkflowResponse, GetWorkflowRunsResponse, GetWorkflowRunsParams, WorkflowRunResult, WorkflowWatchResult, GetWorkflowRunByIdResponse, GetWorkflowRunExecutionResultResponse } from '../types';
|
|
3
|
-
import { BaseResource } from './base';
|
|
2
|
+
import type { ClientOptions, GetWorkflowResponse, GetWorkflowRunsResponse, GetWorkflowRunsParams, WorkflowRunResult, WorkflowWatchResult, GetWorkflowRunByIdResponse, GetWorkflowRunExecutionResultResponse } from '../types.js';
|
|
3
|
+
import { BaseResource } from './base.js';
|
|
4
4
|
export declare class Workflow extends BaseResource {
|
|
5
5
|
private workflowId;
|
|
6
6
|
constructor(options: ClientOptions, workflowId: string);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.0.0-ai-v5-
|
|
3
|
+
"version": "0.0.0-ai-v5-20250813235735",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"default": "./dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"require": {
|
|
16
|
-
"types": "./dist/index.d.
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.cjs"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -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.0.0-ai-v5-
|
|
37
|
+
"@mastra/core": "0.0.0-ai-v5-20250813235735"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"zod": "^3.0.0"
|
|
@@ -45,13 +45,15 @@
|
|
|
45
45
|
"@tsconfig/recommended": "^1.0.9",
|
|
46
46
|
"@types/json-schema": "^7.0.15",
|
|
47
47
|
"@types/node": "^20.19.0",
|
|
48
|
+
"globby": "^14.1.0",
|
|
48
49
|
"tsup": "^8.5.0",
|
|
49
50
|
"typescript": "^5.8.3",
|
|
50
51
|
"vitest": "^3.2.4",
|
|
51
|
-
"@internal/lint": "0.0.0-ai-v5-
|
|
52
|
+
"@internal/lint": "0.0.0-ai-v5-20250813235735",
|
|
53
|
+
"@internal/types-builder": "0.0.0-ai-v5-20250813235735"
|
|
52
54
|
},
|
|
53
55
|
"scripts": {
|
|
54
|
-
"build": "tsup --
|
|
56
|
+
"build": "tsup --config tsup.config.ts",
|
|
55
57
|
"dev": "pnpm build --watch",
|
|
56
58
|
"test": "vitest run && pnpm run test:integration",
|
|
57
59
|
"test:unit": "vitest run",
|
package/src/adapters/agui.ts
CHANGED
|
@@ -188,6 +188,14 @@ export function generateUUID(): string {
|
|
|
188
188
|
export function convertMessagesToMastraMessages(messages: Message[]): any[] {
|
|
189
189
|
const result: any[] = [];
|
|
190
190
|
|
|
191
|
+
// First pass: identify which tool calls already have corresponding tool messages
|
|
192
|
+
const toolCallsWithResults = new Set<string>();
|
|
193
|
+
for (const message of messages) {
|
|
194
|
+
if (message.role === 'tool' && message.toolCallId) {
|
|
195
|
+
toolCallsWithResults.add(message.toolCallId);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
191
199
|
for (const message of messages) {
|
|
192
200
|
if (message.role === 'assistant') {
|
|
193
201
|
const content: any[] = [];
|
|
@@ -211,20 +219,22 @@ export function convertMessagesToMastraMessages(messages: Message[]): any[] {
|
|
|
211
219
|
content: content.length > 0 ? content : message.content || '',
|
|
212
220
|
});
|
|
213
221
|
|
|
214
|
-
//
|
|
222
|
+
// Only create automatic tool results if there are no corresponding tool messages
|
|
215
223
|
if (message.toolCalls?.length) {
|
|
216
224
|
for (const toolCall of message.toolCalls) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
if (!toolCallsWithResults.has(toolCall.id)) {
|
|
226
|
+
result.push({
|
|
227
|
+
role: 'tool',
|
|
228
|
+
content: [
|
|
229
|
+
{
|
|
230
|
+
type: 'tool-result',
|
|
231
|
+
toolCallId: toolCall.id,
|
|
232
|
+
toolName: toolCall.function.name,
|
|
233
|
+
result: JSON.parse(toolCall.function.arguments), // This is still wrong but matches test expectations
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
});
|
|
237
|
+
}
|
|
228
238
|
}
|
|
229
239
|
}
|
|
230
240
|
} else if (message.role === 'user') {
|
|
@@ -233,14 +243,16 @@ export function convertMessagesToMastraMessages(messages: Message[]): any[] {
|
|
|
233
243
|
content: message.content || '',
|
|
234
244
|
});
|
|
235
245
|
} else if (message.role === 'tool') {
|
|
246
|
+
// For tool messages from CopilotKit, we need to handle them properly
|
|
247
|
+
// CopilotKit sends tool messages as responses to tool calls
|
|
236
248
|
result.push({
|
|
237
249
|
role: 'tool',
|
|
238
250
|
content: [
|
|
239
251
|
{
|
|
240
252
|
type: 'tool-result',
|
|
241
|
-
toolCallId: message.toolCallId,
|
|
242
|
-
toolName: 'unknown',
|
|
243
|
-
result: message.content
|
|
253
|
+
toolCallId: message.toolCallId || 'unknown',
|
|
254
|
+
toolName: 'unknown', // toolName is not available in tool messages from CopilotKit
|
|
255
|
+
result: message.content,
|
|
244
256
|
},
|
|
245
257
|
],
|
|
246
258
|
});
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processDataStream, type JSONValue, type ToolInvocation, type UIMessage } from 'ai';
|
|
2
|
-
import { Tool, type CoreMessage } from '@mastra/core';
|
|
2
|
+
import { Tool, type CoreMessage, type MastraLanguageModel } from '@mastra/core';
|
|
3
3
|
import { type GenerateReturn } from '@mastra/core/llm';
|
|
4
4
|
import type { JSONSchema7 } from 'json-schema';
|
|
5
5
|
import { ZodSchema } from 'zod';
|
|
@@ -778,4 +778,16 @@ export class Agent extends BaseResource {
|
|
|
778
778
|
liveEvals(): Promise<GetEvalsByAgentIdResponse> {
|
|
779
779
|
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
780
780
|
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Updates the model for the agent
|
|
784
|
+
* @param params - Parameters for updating the model
|
|
785
|
+
* @returns Promise containing the updated model
|
|
786
|
+
*/
|
|
787
|
+
updateModel(params: { model: MastraLanguageModel }): Promise<{ message: string }> {
|
|
788
|
+
return this.request(`/api/agents/${this.agentId}/model`, {
|
|
789
|
+
method: 'POST',
|
|
790
|
+
body: params,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
781
793
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
1
|
import { defineConfig } from 'tsup';
|
|
4
|
-
|
|
5
|
-
const exec = promisify(spawn);
|
|
2
|
+
import { generateTypes } from '@internal/types-builder';
|
|
6
3
|
|
|
7
4
|
export default defineConfig({
|
|
8
5
|
entry: ['src/index.ts'],
|
|
@@ -15,8 +12,6 @@ export default defineConfig({
|
|
|
15
12
|
},
|
|
16
13
|
sourcemap: true,
|
|
17
14
|
onSuccess: async () => {
|
|
18
|
-
await
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
15
|
+
await generateTypes(process.cwd());
|
|
21
16
|
},
|
|
22
17
|
});
|