@mastra/client-js 0.0.0-agui-20250501191909 → 0.0.0-cloud-transporter-20250513033346
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 +160 -2
- package/dist/index.cjs +218 -28
- package/dist/index.d.cts +97 -29
- package/dist/index.d.ts +97 -29
- package/dist/index.js +214 -28
- package/package.json +6 -6
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +20 -4
- package/src/index.test.ts +30 -0
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +26 -34
- package/src/resources/index.ts +1 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/network.ts +5 -11
- package/src/resources/tool.ts +8 -2
- package/src/resources/vnext-workflow.ts +34 -7
- package/src/resources/workflow.ts +31 -3
- package/src/types.ts +20 -2
- package/src/utils/zod-to-json-schema.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,177 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-cloud-transporter-20250513033346
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- c2f9e60: Resolves type issue and listen response string wrapped in text object twice
|
|
8
|
+
- b4c6c87: fix: Specify $refStrategy: 'none' when calling zodToJsonSchema.
|
|
9
|
+
- 0c3d117: Add workflows to agent server handlers
|
|
10
|
+
- a5810ce: Add support for experimental_generateMessageId and remove it from client-js types since it's not serializable
|
|
11
|
+
- c2b980b: Fix multiple too-calls in AGUI
|
|
12
|
+
- cb1f698: Set runtimeContext from playground for agents, tools, workflows
|
|
13
|
+
- 0b8b868: Added A2A support + streaming
|
|
14
|
+
- Updated dependencies [396be50]
|
|
15
|
+
- Updated dependencies [ab80e7e]
|
|
16
|
+
- Updated dependencies [c3bd795]
|
|
17
|
+
- Updated dependencies [da082f8]
|
|
18
|
+
- Updated dependencies [a5810ce]
|
|
19
|
+
- Updated dependencies [3171b5b]
|
|
20
|
+
- Updated dependencies [973e5ac]
|
|
21
|
+
- Updated dependencies [daf942f]
|
|
22
|
+
- Updated dependencies [0b8b868]
|
|
23
|
+
- Updated dependencies [9e1eff5]
|
|
24
|
+
- Updated dependencies [6fa1ad1]
|
|
25
|
+
- Updated dependencies [c28d7a0]
|
|
26
|
+
- Updated dependencies [edf1e88]
|
|
27
|
+
- @mastra/core@0.0.0-cloud-transporter-20250513033346
|
|
28
|
+
|
|
29
|
+
## 0.1.22-alpha.2
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- b4c6c87: fix: Specify $refStrategy: 'none' when calling zodToJsonSchema.
|
|
34
|
+
- c2b980b: Fix multiple too-calls in AGUI
|
|
35
|
+
- Updated dependencies [3171b5b]
|
|
36
|
+
- Updated dependencies [973e5ac]
|
|
37
|
+
- Updated dependencies [9e1eff5]
|
|
38
|
+
- @mastra/core@0.9.4-alpha.2
|
|
39
|
+
|
|
40
|
+
## 0.1.22-alpha.1
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [ab80e7e]
|
|
45
|
+
- Updated dependencies [6fa1ad1]
|
|
46
|
+
- Updated dependencies [c28d7a0]
|
|
47
|
+
- Updated dependencies [edf1e88]
|
|
48
|
+
- @mastra/core@0.9.4-alpha.1
|
|
49
|
+
|
|
50
|
+
## 0.1.22-alpha.0
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- cb1f698: Set runtimeContext from playground for agents, tools, workflows
|
|
55
|
+
- 0b8b868: Added A2A support + streaming
|
|
56
|
+
- Updated dependencies [daf942f]
|
|
57
|
+
- Updated dependencies [0b8b868]
|
|
58
|
+
- @mastra/core@0.9.4-alpha.0
|
|
59
|
+
|
|
60
|
+
## 0.1.21
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
65
|
+
- 36eb1aa: Fix AGUI text part
|
|
66
|
+
- 62c9e7d: Fix disappearing tool calls in streaming
|
|
67
|
+
- Updated dependencies [e450778]
|
|
68
|
+
- Updated dependencies [8902157]
|
|
69
|
+
- Updated dependencies [ca0dc88]
|
|
70
|
+
- Updated dependencies [526c570]
|
|
71
|
+
- Updated dependencies [d7a6a33]
|
|
72
|
+
- Updated dependencies [9cd1a46]
|
|
73
|
+
- Updated dependencies [b5d2de0]
|
|
74
|
+
- Updated dependencies [644f8ad]
|
|
75
|
+
- Updated dependencies [70dbf51]
|
|
76
|
+
- @mastra/core@0.9.3
|
|
77
|
+
|
|
78
|
+
## 0.1.21-alpha.1
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- 36eb1aa: Fix AGUI text part
|
|
83
|
+
- 62c9e7d: Fix disappearing tool calls in streaming
|
|
84
|
+
- Updated dependencies [e450778]
|
|
85
|
+
- Updated dependencies [8902157]
|
|
86
|
+
- Updated dependencies [ca0dc88]
|
|
87
|
+
- Updated dependencies [9cd1a46]
|
|
88
|
+
- Updated dependencies [70dbf51]
|
|
89
|
+
- @mastra/core@0.9.3-alpha.1
|
|
90
|
+
|
|
91
|
+
## 0.1.21-alpha.0
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
96
|
+
- Updated dependencies [526c570]
|
|
97
|
+
- Updated dependencies [b5d2de0]
|
|
98
|
+
- Updated dependencies [644f8ad]
|
|
99
|
+
- @mastra/core@0.9.3-alpha.0
|
|
100
|
+
|
|
101
|
+
## 0.1.20
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- 2cf3b8f: dependencies updates:
|
|
106
|
+
- Updated dependency [`zod@^3.24.3` ↗︎](https://www.npmjs.com/package/zod/v/3.24.3) (from `^3.24.2`, in `dependencies`)
|
|
107
|
+
- 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`)
|
|
108
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
109
|
+
Add fromDate and toDate to telemetry parameters
|
|
7
110
|
- 254f5c3: Audit, cleanup MastraClient
|
|
8
111
|
- 0097d50: Add serializedStepGraph to vNext workflow
|
|
9
112
|
Return serializedStepGraph from vNext workflow
|
|
10
113
|
Use serializedStepGraph in vNext workflow graph
|
|
11
114
|
- 2429c74: Add get workflow runs api to client-js
|
|
115
|
+
- 2e4f8e9: Agui client integration
|
|
116
|
+
- Updated dependencies [6052aa6]
|
|
12
117
|
- Updated dependencies [967b41c]
|
|
118
|
+
- Updated dependencies [3d2fb5c]
|
|
13
119
|
- Updated dependencies [26738f4]
|
|
120
|
+
- Updated dependencies [4155f47]
|
|
121
|
+
- Updated dependencies [7eeb2bc]
|
|
14
122
|
- Updated dependencies [b804723]
|
|
123
|
+
- Updated dependencies [8607972]
|
|
124
|
+
- Updated dependencies [ccef9f9]
|
|
15
125
|
- Updated dependencies [0097d50]
|
|
16
|
-
|
|
126
|
+
- Updated dependencies [7eeb2bc]
|
|
127
|
+
- Updated dependencies [17826a9]
|
|
128
|
+
- Updated dependencies [7d8b7c7]
|
|
129
|
+
- Updated dependencies [fba031f]
|
|
130
|
+
- Updated dependencies [3a5f1e1]
|
|
131
|
+
- Updated dependencies [51e6923]
|
|
132
|
+
- Updated dependencies [8398d89]
|
|
133
|
+
- @mastra/core@0.9.2
|
|
134
|
+
|
|
135
|
+
## 0.1.20-alpha.6
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- 2e4f8e9: Agui client integration
|
|
140
|
+
- Updated dependencies [6052aa6]
|
|
141
|
+
- Updated dependencies [7d8b7c7]
|
|
142
|
+
- Updated dependencies [3a5f1e1]
|
|
143
|
+
- Updated dependencies [8398d89]
|
|
144
|
+
- @mastra/core@0.9.2-alpha.6
|
|
145
|
+
|
|
146
|
+
## 0.1.20-alpha.5
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- Updated dependencies [3d2fb5c]
|
|
151
|
+
- Updated dependencies [7eeb2bc]
|
|
152
|
+
- Updated dependencies [8607972]
|
|
153
|
+
- Updated dependencies [7eeb2bc]
|
|
154
|
+
- Updated dependencies [fba031f]
|
|
155
|
+
- @mastra/core@0.9.2-alpha.5
|
|
156
|
+
|
|
157
|
+
## 0.1.20-alpha.4
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [ccef9f9]
|
|
162
|
+
- Updated dependencies [51e6923]
|
|
163
|
+
- @mastra/core@0.9.2-alpha.4
|
|
164
|
+
|
|
165
|
+
## 0.1.20-alpha.3
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
170
|
+
Add fromDate and toDate to telemetry parameters
|
|
171
|
+
- Updated dependencies [967b41c]
|
|
172
|
+
- Updated dependencies [4155f47]
|
|
173
|
+
- Updated dependencies [17826a9]
|
|
174
|
+
- @mastra/core@0.9.2-alpha.3
|
|
17
175
|
|
|
18
176
|
## 0.1.20-alpha.2
|
|
19
177
|
|
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",
|
|
@@ -451,10 +500,15 @@ var MemoryThread = class extends BaseResource {
|
|
|
451
500
|
}
|
|
452
501
|
/**
|
|
453
502
|
* Retrieves messages associated with the thread
|
|
503
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
454
504
|
* @returns Promise containing thread messages and UI messages
|
|
455
505
|
*/
|
|
456
|
-
getMessages() {
|
|
457
|
-
|
|
506
|
+
getMessages(params) {
|
|
507
|
+
const query = new URLSearchParams({
|
|
508
|
+
agentId: this.agentId,
|
|
509
|
+
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
510
|
+
});
|
|
511
|
+
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
458
512
|
}
|
|
459
513
|
};
|
|
460
514
|
|
|
@@ -540,10 +594,31 @@ var Workflow = class extends BaseResource {
|
|
|
540
594
|
}
|
|
541
595
|
/**
|
|
542
596
|
* Retrieves all runs for a workflow
|
|
597
|
+
* @param params - Parameters for filtering runs
|
|
543
598
|
* @returns Promise containing workflow runs array
|
|
544
599
|
*/
|
|
545
|
-
runs() {
|
|
546
|
-
|
|
600
|
+
runs(params) {
|
|
601
|
+
const searchParams = new URLSearchParams();
|
|
602
|
+
if (params?.fromDate) {
|
|
603
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
604
|
+
}
|
|
605
|
+
if (params?.toDate) {
|
|
606
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
607
|
+
}
|
|
608
|
+
if (params?.limit) {
|
|
609
|
+
searchParams.set("limit", String(params.limit));
|
|
610
|
+
}
|
|
611
|
+
if (params?.offset) {
|
|
612
|
+
searchParams.set("offset", String(params.offset));
|
|
613
|
+
}
|
|
614
|
+
if (params?.resourceId) {
|
|
615
|
+
searchParams.set("resourceId", params.resourceId);
|
|
616
|
+
}
|
|
617
|
+
if (searchParams.size) {
|
|
618
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
619
|
+
} else {
|
|
620
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
621
|
+
}
|
|
547
622
|
}
|
|
548
623
|
/**
|
|
549
624
|
* @deprecated Use `startAsync` instead
|
|
@@ -719,14 +794,16 @@ var Tool = class extends BaseResource {
|
|
|
719
794
|
if (params.runId) {
|
|
720
795
|
url.set("runId", params.runId);
|
|
721
796
|
}
|
|
797
|
+
const body = {
|
|
798
|
+
data: params.data,
|
|
799
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
800
|
+
};
|
|
722
801
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
723
802
|
method: "POST",
|
|
724
|
-
body
|
|
803
|
+
body
|
|
725
804
|
});
|
|
726
805
|
}
|
|
727
806
|
};
|
|
728
|
-
|
|
729
|
-
// src/resources/vnext-workflow.ts
|
|
730
807
|
var RECORD_SEPARATOR2 = "";
|
|
731
808
|
var VNextWorkflow = class extends BaseResource {
|
|
732
809
|
constructor(options, workflowId) {
|
|
@@ -787,10 +864,31 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
787
864
|
}
|
|
788
865
|
/**
|
|
789
866
|
* Retrieves all runs for a vNext workflow
|
|
867
|
+
* @param params - Parameters for filtering runs
|
|
790
868
|
* @returns Promise containing vNext workflow runs array
|
|
791
869
|
*/
|
|
792
|
-
runs() {
|
|
793
|
-
|
|
870
|
+
runs(params) {
|
|
871
|
+
const searchParams = new URLSearchParams();
|
|
872
|
+
if (params?.fromDate) {
|
|
873
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
874
|
+
}
|
|
875
|
+
if (params?.toDate) {
|
|
876
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
877
|
+
}
|
|
878
|
+
if (params?.limit) {
|
|
879
|
+
searchParams.set("limit", String(params.limit));
|
|
880
|
+
}
|
|
881
|
+
if (params?.offset) {
|
|
882
|
+
searchParams.set("offset", String(params.offset));
|
|
883
|
+
}
|
|
884
|
+
if (params?.resourceId) {
|
|
885
|
+
searchParams.set("resourceId", params.resourceId);
|
|
886
|
+
}
|
|
887
|
+
if (searchParams.size) {
|
|
888
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
|
|
889
|
+
} else {
|
|
890
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
|
|
891
|
+
}
|
|
794
892
|
}
|
|
795
893
|
/**
|
|
796
894
|
* Creates a new vNext workflow run
|
|
@@ -812,9 +910,10 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
812
910
|
* @returns Promise containing success message
|
|
813
911
|
*/
|
|
814
912
|
start(params) {
|
|
913
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
815
914
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
816
915
|
method: "POST",
|
|
817
|
-
body: { inputData: params?.inputData, runtimeContext
|
|
916
|
+
body: { inputData: params?.inputData, runtimeContext }
|
|
818
917
|
});
|
|
819
918
|
}
|
|
820
919
|
/**
|
|
@@ -826,8 +925,9 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
826
925
|
step,
|
|
827
926
|
runId,
|
|
828
927
|
resumeData,
|
|
829
|
-
|
|
928
|
+
...rest
|
|
830
929
|
}) {
|
|
930
|
+
const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : void 0;
|
|
831
931
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
832
932
|
method: "POST",
|
|
833
933
|
stream: true,
|
|
@@ -848,9 +948,10 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
848
948
|
if (!!params?.runId) {
|
|
849
949
|
searchParams.set("runId", params.runId);
|
|
850
950
|
}
|
|
951
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
851
952
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
852
953
|
method: "POST",
|
|
853
|
-
body: { inputData: params.inputData, runtimeContext
|
|
954
|
+
body: { inputData: params.inputData, runtimeContext }
|
|
854
955
|
});
|
|
855
956
|
}
|
|
856
957
|
/**
|
|
@@ -859,12 +960,13 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
859
960
|
* @returns Promise containing the vNext workflow resume results
|
|
860
961
|
*/
|
|
861
962
|
resumeAsync(params) {
|
|
963
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
|
|
862
964
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
863
965
|
method: "POST",
|
|
864
966
|
body: {
|
|
865
967
|
step: params.step,
|
|
866
968
|
resumeData: params.resumeData,
|
|
867
|
-
runtimeContext
|
|
969
|
+
runtimeContext
|
|
868
970
|
}
|
|
869
971
|
});
|
|
870
972
|
}
|
|
@@ -889,6 +991,80 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
889
991
|
}
|
|
890
992
|
};
|
|
891
993
|
|
|
994
|
+
// src/resources/a2a.ts
|
|
995
|
+
var A2A = class extends BaseResource {
|
|
996
|
+
constructor(options, agentId) {
|
|
997
|
+
super(options);
|
|
998
|
+
this.agentId = agentId;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Get the agent card with metadata about the agent
|
|
1002
|
+
* @returns Promise containing the agent card information
|
|
1003
|
+
*/
|
|
1004
|
+
async getCard() {
|
|
1005
|
+
return this.request(`/.well-known/${this.agentId}/agent.json`);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Send a message to the agent and get a response
|
|
1009
|
+
* @param params - Parameters for the task
|
|
1010
|
+
* @returns Promise containing the task response
|
|
1011
|
+
*/
|
|
1012
|
+
async sendMessage(params) {
|
|
1013
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1014
|
+
method: "POST",
|
|
1015
|
+
body: {
|
|
1016
|
+
method: "tasks/send",
|
|
1017
|
+
params
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
return { task: response.result };
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Get the status and result of a task
|
|
1024
|
+
* @param params - Parameters for querying the task
|
|
1025
|
+
* @returns Promise containing the task response
|
|
1026
|
+
*/
|
|
1027
|
+
async getTask(params) {
|
|
1028
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1029
|
+
method: "POST",
|
|
1030
|
+
body: {
|
|
1031
|
+
method: "tasks/get",
|
|
1032
|
+
params
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
return response.result;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Cancel a running task
|
|
1039
|
+
* @param params - Parameters identifying the task to cancel
|
|
1040
|
+
* @returns Promise containing the task response
|
|
1041
|
+
*/
|
|
1042
|
+
async cancelTask(params) {
|
|
1043
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1044
|
+
method: "POST",
|
|
1045
|
+
body: {
|
|
1046
|
+
method: "tasks/cancel",
|
|
1047
|
+
params
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
1053
|
+
* @param params - Parameters for the task
|
|
1054
|
+
* @returns Promise containing the task response
|
|
1055
|
+
*/
|
|
1056
|
+
async sendAndSubscribe(params) {
|
|
1057
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1058
|
+
method: "POST",
|
|
1059
|
+
body: {
|
|
1060
|
+
method: "tasks/sendSubscribe",
|
|
1061
|
+
params
|
|
1062
|
+
},
|
|
1063
|
+
stream: true
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
892
1068
|
// src/client.ts
|
|
893
1069
|
var MastraClient = class extends BaseResource {
|
|
894
1070
|
constructor(options) {
|
|
@@ -1048,7 +1224,7 @@ var MastraClient = class extends BaseResource {
|
|
|
1048
1224
|
* @returns Promise containing telemetry data
|
|
1049
1225
|
*/
|
|
1050
1226
|
getTelemetry(params) {
|
|
1051
|
-
const { name, scope, page, perPage, attribute } = params || {};
|
|
1227
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
|
|
1052
1228
|
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
1053
1229
|
const searchParams = new URLSearchParams();
|
|
1054
1230
|
if (name) {
|
|
@@ -1072,6 +1248,12 @@ var MastraClient = class extends BaseResource {
|
|
|
1072
1248
|
searchParams.set("attribute", _attribute);
|
|
1073
1249
|
}
|
|
1074
1250
|
}
|
|
1251
|
+
if (fromDate) {
|
|
1252
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1253
|
+
}
|
|
1254
|
+
if (toDate) {
|
|
1255
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1256
|
+
}
|
|
1075
1257
|
if (searchParams.size) {
|
|
1076
1258
|
return this.request(`/api/telemetry?${searchParams}`);
|
|
1077
1259
|
} else {
|
|
@@ -1093,6 +1275,14 @@ var MastraClient = class extends BaseResource {
|
|
|
1093
1275
|
getNetwork(networkId) {
|
|
1094
1276
|
return new Network(this.options, networkId);
|
|
1095
1277
|
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
1280
|
+
* @param agentId - ID of the agent to interact with
|
|
1281
|
+
* @returns A2A client instance
|
|
1282
|
+
*/
|
|
1283
|
+
getA2A(agentId) {
|
|
1284
|
+
return new A2A(this.options, agentId);
|
|
1285
|
+
}
|
|
1096
1286
|
};
|
|
1097
1287
|
|
|
1098
1288
|
exports.MastraClient = MastraClient;
|