@mastra/client-js 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-generate-message-id-20250512171942
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/CHANGELOG.md +113 -2
- package/dist/index.cjs +158 -21
- package/dist/index.d.cts +68 -8
- package/dist/index.d.ts +68 -8
- package/dist/index.js +154 -21
- package/package.json +6 -6
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +10 -1
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +25 -33
- package/src/resources/index.ts +1 -0
- package/src/resources/network.ts +5 -11
- package/src/resources/tool.ts +8 -2
- package/src/resources/vnext-workflow.ts +9 -5
- package/src/types.ts +2 -2
- package/src/utils/zod-to-json-schema.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,105 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-generate-message-id-20250512171942
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- b4c6c87: fix: Specify $refStrategy: 'none' when calling zodToJsonSchema.
|
|
8
|
+
- 66a786d: Add support for experimental_generateMessageId and remove it from client-js types since it's not serializable
|
|
9
|
+
- c2b980b: Fix multiple too-calls in AGUI
|
|
10
|
+
- cb1f698: Set runtimeContext from playground for agents, tools, workflows
|
|
11
|
+
- 0b8b868: Added A2A support + streaming
|
|
12
|
+
- Updated dependencies [ab80e7e]
|
|
13
|
+
- Updated dependencies [66a786d]
|
|
14
|
+
- Updated dependencies [3171b5b]
|
|
15
|
+
- Updated dependencies [973e5ac]
|
|
16
|
+
- Updated dependencies [daf942f]
|
|
17
|
+
- Updated dependencies [0b8b868]
|
|
18
|
+
- Updated dependencies [9e1eff5]
|
|
19
|
+
- Updated dependencies [6fa1ad1]
|
|
20
|
+
- Updated dependencies [c28d7a0]
|
|
21
|
+
- Updated dependencies [edf1e88]
|
|
22
|
+
- @mastra/core@0.0.0-generate-message-id-20250512171942
|
|
23
|
+
|
|
24
|
+
## 0.1.22-alpha.2
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- b4c6c87: fix: Specify $refStrategy: 'none' when calling zodToJsonSchema.
|
|
29
|
+
- c2b980b: Fix multiple too-calls in AGUI
|
|
30
|
+
- Updated dependencies [3171b5b]
|
|
31
|
+
- Updated dependencies [973e5ac]
|
|
32
|
+
- Updated dependencies [9e1eff5]
|
|
33
|
+
- @mastra/core@0.9.4-alpha.2
|
|
34
|
+
|
|
35
|
+
## 0.1.22-alpha.1
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [ab80e7e]
|
|
40
|
+
- Updated dependencies [6fa1ad1]
|
|
41
|
+
- Updated dependencies [c28d7a0]
|
|
42
|
+
- Updated dependencies [edf1e88]
|
|
43
|
+
- @mastra/core@0.9.4-alpha.1
|
|
44
|
+
|
|
45
|
+
## 0.1.22-alpha.0
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- cb1f698: Set runtimeContext from playground for agents, tools, workflows
|
|
50
|
+
- 0b8b868: Added A2A support + streaming
|
|
51
|
+
- Updated dependencies [daf942f]
|
|
52
|
+
- Updated dependencies [0b8b868]
|
|
53
|
+
- @mastra/core@0.9.4-alpha.0
|
|
54
|
+
|
|
55
|
+
## 0.1.21
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
60
|
+
- 36eb1aa: Fix AGUI text part
|
|
61
|
+
- 62c9e7d: Fix disappearing tool calls in streaming
|
|
62
|
+
- Updated dependencies [e450778]
|
|
63
|
+
- Updated dependencies [8902157]
|
|
64
|
+
- Updated dependencies [ca0dc88]
|
|
65
|
+
- Updated dependencies [526c570]
|
|
66
|
+
- Updated dependencies [d7a6a33]
|
|
67
|
+
- Updated dependencies [9cd1a46]
|
|
68
|
+
- Updated dependencies [b5d2de0]
|
|
69
|
+
- Updated dependencies [644f8ad]
|
|
70
|
+
- Updated dependencies [70dbf51]
|
|
71
|
+
- @mastra/core@0.9.3
|
|
72
|
+
|
|
73
|
+
## 0.1.21-alpha.1
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- 36eb1aa: Fix AGUI text part
|
|
78
|
+
- 62c9e7d: Fix disappearing tool calls in streaming
|
|
79
|
+
- Updated dependencies [e450778]
|
|
80
|
+
- Updated dependencies [8902157]
|
|
81
|
+
- Updated dependencies [ca0dc88]
|
|
82
|
+
- Updated dependencies [9cd1a46]
|
|
83
|
+
- Updated dependencies [70dbf51]
|
|
84
|
+
- @mastra/core@0.9.3-alpha.1
|
|
85
|
+
|
|
86
|
+
## 0.1.21-alpha.0
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
91
|
+
- Updated dependencies [526c570]
|
|
92
|
+
- Updated dependencies [b5d2de0]
|
|
93
|
+
- Updated dependencies [644f8ad]
|
|
94
|
+
- @mastra/core@0.9.3-alpha.0
|
|
95
|
+
|
|
96
|
+
## 0.1.20
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- 2cf3b8f: dependencies updates:
|
|
101
|
+
- Updated dependency [`zod@^3.24.3` ↗︎](https://www.npmjs.com/package/zod/v/3.24.3) (from `^3.24.2`, in `dependencies`)
|
|
102
|
+
- Updated dependency [`zod-to-json-schema@^3.24.5` ↗︎](https://www.npmjs.com/package/zod-to-json-schema/v/3.24.5) (from `^3.24.3`, in `dependencies`)
|
|
7
103
|
- 4155f47: Add parameters to filter workflow runs
|
|
8
104
|
Add fromDate and toDate to telemetry parameters
|
|
9
105
|
- 254f5c3: Audit, cleanup MastraClient
|
|
@@ -12,6 +108,7 @@
|
|
|
12
108
|
Use serializedStepGraph in vNext workflow graph
|
|
13
109
|
- 2429c74: Add get workflow runs api to client-js
|
|
14
110
|
- 2e4f8e9: Agui client integration
|
|
111
|
+
- Updated dependencies [6052aa6]
|
|
15
112
|
- Updated dependencies [967b41c]
|
|
16
113
|
- Updated dependencies [3d2fb5c]
|
|
17
114
|
- Updated dependencies [26738f4]
|
|
@@ -23,9 +120,23 @@
|
|
|
23
120
|
- Updated dependencies [0097d50]
|
|
24
121
|
- Updated dependencies [7eeb2bc]
|
|
25
122
|
- Updated dependencies [17826a9]
|
|
123
|
+
- Updated dependencies [7d8b7c7]
|
|
26
124
|
- Updated dependencies [fba031f]
|
|
125
|
+
- Updated dependencies [3a5f1e1]
|
|
27
126
|
- Updated dependencies [51e6923]
|
|
28
|
-
|
|
127
|
+
- Updated dependencies [8398d89]
|
|
128
|
+
- @mastra/core@0.9.2
|
|
129
|
+
|
|
130
|
+
## 0.1.20-alpha.6
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- 2e4f8e9: Agui client integration
|
|
135
|
+
- Updated dependencies [6052aa6]
|
|
136
|
+
- Updated dependencies [7d8b7c7]
|
|
137
|
+
- Updated dependencies [3a5f1e1]
|
|
138
|
+
- Updated dependencies [8398d89]
|
|
139
|
+
- @mastra/core@0.9.2-alpha.6
|
|
29
140
|
|
|
30
141
|
## 0.1.20-alpha.5
|
|
31
142
|
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,11 @@ var client = require('@ag-ui/client');
|
|
|
4
4
|
var rxjs = require('rxjs');
|
|
5
5
|
var uiUtils = require('@ai-sdk/ui-utils');
|
|
6
6
|
var zod = require('zod');
|
|
7
|
-
var
|
|
7
|
+
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var originalZodToJsonSchema__default = /*#__PURE__*/_interopDefault(originalZodToJsonSchema);
|
|
8
12
|
|
|
9
13
|
// src/adapters/agui.ts
|
|
10
14
|
var AGUIAdapter = class extends client.AbstractAgent {
|
|
@@ -44,6 +48,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
|
|
|
44
48
|
)
|
|
45
49
|
}).then((response) => {
|
|
46
50
|
let currentMessageId = void 0;
|
|
51
|
+
let isInTextMessage = false;
|
|
47
52
|
return response.processDataStream({
|
|
48
53
|
onTextPart: (text) => {
|
|
49
54
|
if (currentMessageId === void 0) {
|
|
@@ -54,6 +59,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
|
|
|
54
59
|
role: "assistant"
|
|
55
60
|
};
|
|
56
61
|
subscriber.next(message2);
|
|
62
|
+
isInTextMessage = true;
|
|
57
63
|
}
|
|
58
64
|
const message = {
|
|
59
65
|
type: client.EventType.TEXT_MESSAGE_CONTENT,
|
|
@@ -62,14 +68,14 @@ var AGUIAdapter = class extends client.AbstractAgent {
|
|
|
62
68
|
};
|
|
63
69
|
subscriber.next(message);
|
|
64
70
|
},
|
|
65
|
-
onFinishMessagePart: (
|
|
66
|
-
console.log("onFinishMessagePart", message);
|
|
71
|
+
onFinishMessagePart: () => {
|
|
67
72
|
if (currentMessageId !== void 0) {
|
|
68
|
-
const
|
|
73
|
+
const message = {
|
|
69
74
|
type: client.EventType.TEXT_MESSAGE_END,
|
|
70
75
|
messageId: currentMessageId
|
|
71
76
|
};
|
|
72
|
-
subscriber.next(
|
|
77
|
+
subscriber.next(message);
|
|
78
|
+
isInTextMessage = false;
|
|
73
79
|
}
|
|
74
80
|
subscriber.next({
|
|
75
81
|
type: client.EventType.RUN_FINISHED,
|
|
@@ -80,6 +86,14 @@ var AGUIAdapter = class extends client.AbstractAgent {
|
|
|
80
86
|
},
|
|
81
87
|
onToolCallPart(streamPart) {
|
|
82
88
|
const parentMessageId = currentMessageId || generateUUID();
|
|
89
|
+
if (isInTextMessage) {
|
|
90
|
+
const message = {
|
|
91
|
+
type: client.EventType.TEXT_MESSAGE_END,
|
|
92
|
+
messageId: parentMessageId
|
|
93
|
+
};
|
|
94
|
+
subscriber.next(message);
|
|
95
|
+
isInTextMessage = false;
|
|
96
|
+
}
|
|
83
97
|
subscriber.next({
|
|
84
98
|
type: client.EventType.TOOL_CALL_START,
|
|
85
99
|
toolCallId: streamPart.toolCallId,
|
|
@@ -100,7 +114,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
|
|
|
100
114
|
}
|
|
101
115
|
});
|
|
102
116
|
}).catch((error) => {
|
|
103
|
-
console.
|
|
117
|
+
console.error("error", error);
|
|
104
118
|
subscriber.error(error);
|
|
105
119
|
});
|
|
106
120
|
return () => {
|
|
@@ -149,6 +163,17 @@ function convertMessagesToMastraMessages(messages) {
|
|
|
149
163
|
role: "assistant",
|
|
150
164
|
content: parts
|
|
151
165
|
});
|
|
166
|
+
if (message.toolCalls?.length) {
|
|
167
|
+
result.push({
|
|
168
|
+
role: "tool",
|
|
169
|
+
content: message.toolCalls.map((toolCall) => ({
|
|
170
|
+
type: "tool-result",
|
|
171
|
+
toolCallId: toolCall.id,
|
|
172
|
+
toolName: toolCall.function.name,
|
|
173
|
+
result: JSON.parse(toolCall.function.arguments)
|
|
174
|
+
}))
|
|
175
|
+
});
|
|
176
|
+
}
|
|
152
177
|
} else if (message.role === "user") {
|
|
153
178
|
result.push({
|
|
154
179
|
role: "user",
|
|
@@ -170,6 +195,12 @@ function convertMessagesToMastraMessages(messages) {
|
|
|
170
195
|
}
|
|
171
196
|
return result;
|
|
172
197
|
}
|
|
198
|
+
function zodToJsonSchema(zodSchema) {
|
|
199
|
+
if (!(zodSchema instanceof zod.ZodSchema)) {
|
|
200
|
+
return zodSchema;
|
|
201
|
+
}
|
|
202
|
+
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "none" });
|
|
203
|
+
}
|
|
173
204
|
|
|
174
205
|
// src/resources/base.ts
|
|
175
206
|
var BaseResource = class {
|
|
@@ -300,8 +331,9 @@ var Agent = class extends BaseResource {
|
|
|
300
331
|
generate(params) {
|
|
301
332
|
const processedParams = {
|
|
302
333
|
...params,
|
|
303
|
-
output:
|
|
304
|
-
experimental_output:
|
|
334
|
+
output: zodToJsonSchema(params.output),
|
|
335
|
+
experimental_output: zodToJsonSchema(params.experimental_output),
|
|
336
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
305
337
|
};
|
|
306
338
|
return this.request(`/api/agents/${this.agentId}/generate`, {
|
|
307
339
|
method: "POST",
|
|
@@ -316,8 +348,9 @@ var Agent = class extends BaseResource {
|
|
|
316
348
|
async stream(params) {
|
|
317
349
|
const processedParams = {
|
|
318
350
|
...params,
|
|
319
|
-
output:
|
|
320
|
-
experimental_output:
|
|
351
|
+
output: zodToJsonSchema(params.output),
|
|
352
|
+
experimental_output: zodToJsonSchema(params.experimental_output),
|
|
353
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
321
354
|
};
|
|
322
355
|
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
323
356
|
method: "POST",
|
|
@@ -343,6 +376,22 @@ var Agent = class extends BaseResource {
|
|
|
343
376
|
getTool(toolId) {
|
|
344
377
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
|
|
345
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Executes a tool for the agent
|
|
381
|
+
* @param toolId - ID of the tool to execute
|
|
382
|
+
* @param params - Parameters required for tool execution
|
|
383
|
+
* @returns Promise containing the tool execution results
|
|
384
|
+
*/
|
|
385
|
+
executeTool(toolId, params) {
|
|
386
|
+
const body = {
|
|
387
|
+
data: params.data,
|
|
388
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
389
|
+
};
|
|
390
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
391
|
+
method: "POST",
|
|
392
|
+
body
|
|
393
|
+
});
|
|
394
|
+
}
|
|
346
395
|
/**
|
|
347
396
|
* Retrieves evaluation results for the agent
|
|
348
397
|
* @returns Promise containing agent evaluations
|
|
@@ -378,8 +427,8 @@ var Network = class extends BaseResource {
|
|
|
378
427
|
generate(params) {
|
|
379
428
|
const processedParams = {
|
|
380
429
|
...params,
|
|
381
|
-
output:
|
|
382
|
-
experimental_output:
|
|
430
|
+
output: zodToJsonSchema(params.output),
|
|
431
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
383
432
|
};
|
|
384
433
|
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
385
434
|
method: "POST",
|
|
@@ -394,8 +443,8 @@ var Network = class extends BaseResource {
|
|
|
394
443
|
async stream(params) {
|
|
395
444
|
const processedParams = {
|
|
396
445
|
...params,
|
|
397
|
-
output:
|
|
398
|
-
experimental_output:
|
|
446
|
+
output: zodToJsonSchema(params.output),
|
|
447
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
399
448
|
};
|
|
400
449
|
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
401
450
|
method: "POST",
|
|
@@ -740,14 +789,16 @@ var Tool = class extends BaseResource {
|
|
|
740
789
|
if (params.runId) {
|
|
741
790
|
url.set("runId", params.runId);
|
|
742
791
|
}
|
|
792
|
+
const body = {
|
|
793
|
+
data: params.data,
|
|
794
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
795
|
+
};
|
|
743
796
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
744
797
|
method: "POST",
|
|
745
|
-
body
|
|
798
|
+
body
|
|
746
799
|
});
|
|
747
800
|
}
|
|
748
801
|
};
|
|
749
|
-
|
|
750
|
-
// src/resources/vnext-workflow.ts
|
|
751
802
|
var RECORD_SEPARATOR2 = "";
|
|
752
803
|
var VNextWorkflow = class extends BaseResource {
|
|
753
804
|
constructor(options, workflowId) {
|
|
@@ -854,9 +905,10 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
854
905
|
* @returns Promise containing success message
|
|
855
906
|
*/
|
|
856
907
|
start(params) {
|
|
908
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
857
909
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
858
910
|
method: "POST",
|
|
859
|
-
body: { inputData: params?.inputData, runtimeContext
|
|
911
|
+
body: { inputData: params?.inputData, runtimeContext }
|
|
860
912
|
});
|
|
861
913
|
}
|
|
862
914
|
/**
|
|
@@ -868,8 +920,9 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
868
920
|
step,
|
|
869
921
|
runId,
|
|
870
922
|
resumeData,
|
|
871
|
-
|
|
923
|
+
...rest
|
|
872
924
|
}) {
|
|
925
|
+
const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : void 0;
|
|
873
926
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
874
927
|
method: "POST",
|
|
875
928
|
stream: true,
|
|
@@ -890,9 +943,10 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
890
943
|
if (!!params?.runId) {
|
|
891
944
|
searchParams.set("runId", params.runId);
|
|
892
945
|
}
|
|
946
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
893
947
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
894
948
|
method: "POST",
|
|
895
|
-
body: { inputData: params.inputData, runtimeContext
|
|
949
|
+
body: { inputData: params.inputData, runtimeContext }
|
|
896
950
|
});
|
|
897
951
|
}
|
|
898
952
|
/**
|
|
@@ -901,12 +955,13 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
901
955
|
* @returns Promise containing the vNext workflow resume results
|
|
902
956
|
*/
|
|
903
957
|
resumeAsync(params) {
|
|
958
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
904
959
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
905
960
|
method: "POST",
|
|
906
961
|
body: {
|
|
907
962
|
step: params.step,
|
|
908
963
|
resumeData: params.resumeData,
|
|
909
|
-
runtimeContext
|
|
964
|
+
runtimeContext
|
|
910
965
|
}
|
|
911
966
|
});
|
|
912
967
|
}
|
|
@@ -931,6 +986,80 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
931
986
|
}
|
|
932
987
|
};
|
|
933
988
|
|
|
989
|
+
// src/resources/a2a.ts
|
|
990
|
+
var A2A = class extends BaseResource {
|
|
991
|
+
constructor(options, agentId) {
|
|
992
|
+
super(options);
|
|
993
|
+
this.agentId = agentId;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Get the agent card with metadata about the agent
|
|
997
|
+
* @returns Promise containing the agent card information
|
|
998
|
+
*/
|
|
999
|
+
async getCard() {
|
|
1000
|
+
return this.request(`/.well-known/${this.agentId}/agent.json`);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Send a message to the agent and get a response
|
|
1004
|
+
* @param params - Parameters for the task
|
|
1005
|
+
* @returns Promise containing the task response
|
|
1006
|
+
*/
|
|
1007
|
+
async sendMessage(params) {
|
|
1008
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1009
|
+
method: "POST",
|
|
1010
|
+
body: {
|
|
1011
|
+
method: "tasks/send",
|
|
1012
|
+
params
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
return { task: response.result };
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Get the status and result of a task
|
|
1019
|
+
* @param params - Parameters for querying the task
|
|
1020
|
+
* @returns Promise containing the task response
|
|
1021
|
+
*/
|
|
1022
|
+
async getTask(params) {
|
|
1023
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1024
|
+
method: "POST",
|
|
1025
|
+
body: {
|
|
1026
|
+
method: "tasks/get",
|
|
1027
|
+
params
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
return response.result;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Cancel a running task
|
|
1034
|
+
* @param params - Parameters identifying the task to cancel
|
|
1035
|
+
* @returns Promise containing the task response
|
|
1036
|
+
*/
|
|
1037
|
+
async cancelTask(params) {
|
|
1038
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1039
|
+
method: "POST",
|
|
1040
|
+
body: {
|
|
1041
|
+
method: "tasks/cancel",
|
|
1042
|
+
params
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
1048
|
+
* @param params - Parameters for the task
|
|
1049
|
+
* @returns Promise containing the task response
|
|
1050
|
+
*/
|
|
1051
|
+
async sendAndSubscribe(params) {
|
|
1052
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1053
|
+
method: "POST",
|
|
1054
|
+
body: {
|
|
1055
|
+
method: "tasks/sendSubscribe",
|
|
1056
|
+
params
|
|
1057
|
+
},
|
|
1058
|
+
stream: true
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
934
1063
|
// src/client.ts
|
|
935
1064
|
var MastraClient = class extends BaseResource {
|
|
936
1065
|
constructor(options) {
|
|
@@ -1141,6 +1270,14 @@ var MastraClient = class extends BaseResource {
|
|
|
1141
1270
|
getNetwork(networkId) {
|
|
1142
1271
|
return new Network(this.options, networkId);
|
|
1143
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
1275
|
+
* @param agentId - ID of the agent to interact with
|
|
1276
|
+
* @returns A2A client instance
|
|
1277
|
+
*/
|
|
1278
|
+
getA2A(agentId) {
|
|
1279
|
+
return new A2A(this.options, agentId);
|
|
1280
|
+
}
|
|
1144
1281
|
};
|
|
1145
1282
|
|
|
1146
1283
|
exports.MastraClient = MastraClient;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,9 @@ import { JSONSchema7 } from 'json-schema';
|
|
|
5
5
|
import { ZodSchema } from 'zod';
|
|
6
6
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
7
7
|
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
8
|
-
import { RuntimeContext } from '@mastra/core/
|
|
8
|
+
import { RuntimeContext } from '@mastra/core/di';
|
|
9
|
+
import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
|
|
10
|
+
import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
|
|
9
11
|
|
|
10
12
|
interface ClientOptions {
|
|
11
13
|
/** Base URL for API requests */
|
|
@@ -35,10 +37,10 @@ interface GetAgentResponse {
|
|
|
35
37
|
}
|
|
36
38
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
39
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
} & Partial<AgentGenerateOptions<T>>;
|
|
40
|
+
} & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
|
|
39
41
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
40
42
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
41
|
-
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
43
|
+
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
|
|
42
44
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
43
45
|
evals: any[];
|
|
44
46
|
instructions: string;
|
|
@@ -293,6 +295,16 @@ declare class Agent extends BaseResource {
|
|
|
293
295
|
* @returns Promise containing tool details
|
|
294
296
|
*/
|
|
295
297
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
298
|
+
/**
|
|
299
|
+
* Executes a tool for the agent
|
|
300
|
+
* @param toolId - ID of the tool to execute
|
|
301
|
+
* @param params - Parameters required for tool execution
|
|
302
|
+
* @returns Promise containing the tool execution results
|
|
303
|
+
*/
|
|
304
|
+
executeTool(toolId: string, params: {
|
|
305
|
+
data: any;
|
|
306
|
+
runtimeContext?: RuntimeContext;
|
|
307
|
+
}): Promise<any>;
|
|
296
308
|
/**
|
|
297
309
|
* Retrieves evaluation results for the agent
|
|
298
310
|
* @returns Promise containing agent evaluations
|
|
@@ -512,6 +524,7 @@ declare class Tool extends BaseResource {
|
|
|
512
524
|
execute(params: {
|
|
513
525
|
data: any;
|
|
514
526
|
runId?: string;
|
|
527
|
+
runtimeContext?: RuntimeContext;
|
|
515
528
|
}): Promise<any>;
|
|
516
529
|
}
|
|
517
530
|
|
|
@@ -555,7 +568,7 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
555
568
|
start(params: {
|
|
556
569
|
runId: string;
|
|
557
570
|
inputData: Record<string, any>;
|
|
558
|
-
runtimeContext?: RuntimeContext;
|
|
571
|
+
runtimeContext?: RuntimeContext$1;
|
|
559
572
|
}): Promise<{
|
|
560
573
|
message: string;
|
|
561
574
|
}>;
|
|
@@ -564,11 +577,11 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
564
577
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
565
578
|
* @returns Promise containing success message
|
|
566
579
|
*/
|
|
567
|
-
resume({ step, runId, resumeData,
|
|
580
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
568
581
|
step: string | string[];
|
|
569
582
|
runId: string;
|
|
570
583
|
resumeData?: Record<string, any>;
|
|
571
|
-
runtimeContext?: RuntimeContext;
|
|
584
|
+
runtimeContext?: RuntimeContext$1;
|
|
572
585
|
}): Promise<{
|
|
573
586
|
message: string;
|
|
574
587
|
}>;
|
|
@@ -580,7 +593,7 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
580
593
|
startAsync(params: {
|
|
581
594
|
runId?: string;
|
|
582
595
|
inputData: Record<string, any>;
|
|
583
|
-
runtimeContext?: RuntimeContext;
|
|
596
|
+
runtimeContext?: RuntimeContext$1;
|
|
584
597
|
}): Promise<VNextWorkflowRunResult>;
|
|
585
598
|
/**
|
|
586
599
|
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
@@ -591,7 +604,7 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
591
604
|
runId: string;
|
|
592
605
|
step: string | string[];
|
|
593
606
|
resumeData?: Record<string, any>;
|
|
594
|
-
runtimeContext?: RuntimeContext;
|
|
607
|
+
runtimeContext?: RuntimeContext$1;
|
|
595
608
|
}): Promise<VNextWorkflowRunResult>;
|
|
596
609
|
/**
|
|
597
610
|
* Watches vNext workflow transitions in real-time
|
|
@@ -603,6 +616,47 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
603
616
|
}, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
|
|
604
617
|
}
|
|
605
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Class for interacting with an agent via the A2A protocol
|
|
621
|
+
*/
|
|
622
|
+
declare class A2A extends BaseResource {
|
|
623
|
+
private agentId;
|
|
624
|
+
constructor(options: ClientOptions, agentId: string);
|
|
625
|
+
/**
|
|
626
|
+
* Get the agent card with metadata about the agent
|
|
627
|
+
* @returns Promise containing the agent card information
|
|
628
|
+
*/
|
|
629
|
+
getCard(): Promise<AgentCard>;
|
|
630
|
+
/**
|
|
631
|
+
* Send a message to the agent and get a response
|
|
632
|
+
* @param params - Parameters for the task
|
|
633
|
+
* @returns Promise containing the task response
|
|
634
|
+
*/
|
|
635
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
636
|
+
task: Task;
|
|
637
|
+
}>;
|
|
638
|
+
/**
|
|
639
|
+
* Get the status and result of a task
|
|
640
|
+
* @param params - Parameters for querying the task
|
|
641
|
+
* @returns Promise containing the task response
|
|
642
|
+
*/
|
|
643
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
644
|
+
/**
|
|
645
|
+
* Cancel a running task
|
|
646
|
+
* @param params - Parameters identifying the task to cancel
|
|
647
|
+
* @returns Promise containing the task response
|
|
648
|
+
*/
|
|
649
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
650
|
+
task: Task;
|
|
651
|
+
}>;
|
|
652
|
+
/**
|
|
653
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
654
|
+
* @param params - Parameters for the task
|
|
655
|
+
* @returns Promise containing the task response
|
|
656
|
+
*/
|
|
657
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
658
|
+
}
|
|
659
|
+
|
|
606
660
|
declare class MastraClient extends BaseResource {
|
|
607
661
|
constructor(options: ClientOptions);
|
|
608
662
|
/**
|
|
@@ -725,6 +779,12 @@ declare class MastraClient extends BaseResource {
|
|
|
725
779
|
* @returns Network instance
|
|
726
780
|
*/
|
|
727
781
|
getNetwork(networkId: string): Network;
|
|
782
|
+
/**
|
|
783
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
784
|
+
* @param agentId - ID of the agent to interact with
|
|
785
|
+
* @returns A2A client instance
|
|
786
|
+
*/
|
|
787
|
+
getA2A(agentId: string): A2A;
|
|
728
788
|
}
|
|
729
789
|
|
|
730
790
|
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
|