@mastra/client-js 0.0.0-pg-pool-options-20250428183821 → 0.0.0-redis-cloud-transporter-20250508194049
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 +178 -2
- package/dist/index.cjs +257 -9
- package/dist/index.d.cts +44 -5
- package/dist/index.d.ts +44 -5
- package/dist/index.js +257 -9
- package/package.json +8 -6
- package/src/adapters/agui.test.ts +167 -0
- package/src/adapters/agui.ts +219 -0
- package/src/client.ts +28 -1
- package/src/index.test.ts +4 -4
- package/src/resources/agent.ts +3 -2
- package/src/resources/base.ts +1 -1
- package/src/resources/network.ts +1 -1
- package/src/resources/tool.ts +9 -3
- package/src/resources/vnext-workflow.ts +33 -1
- package/src/resources/workflow.ts +38 -2
- package/src/types.ts +27 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,133 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-redis-cloud-transporter-20250508194049
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
8
|
+
- 62c9e7d: Fix disappearing tool calls in streaming
|
|
9
|
+
- Updated dependencies [e450778]
|
|
10
|
+
- Updated dependencies [8902157]
|
|
11
|
+
- Updated dependencies [ca0dc88]
|
|
12
|
+
- Updated dependencies [526c570]
|
|
13
|
+
- Updated dependencies [9cd1a46]
|
|
14
|
+
- Updated dependencies [b5d2de0]
|
|
15
|
+
- Updated dependencies [644f8ad]
|
|
16
|
+
- Updated dependencies [70dbf51]
|
|
17
|
+
- @mastra/core@0.0.0-redis-cloud-transporter-20250508194049
|
|
18
|
+
|
|
19
|
+
## 0.1.21-alpha.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 526c570: expose agent runtimeContext from clientSDK
|
|
24
|
+
- Updated dependencies [526c570]
|
|
25
|
+
- Updated dependencies [b5d2de0]
|
|
26
|
+
- Updated dependencies [644f8ad]
|
|
27
|
+
- @mastra/core@0.9.3-alpha.0
|
|
28
|
+
|
|
29
|
+
## 0.1.20
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 2cf3b8f: dependencies updates:
|
|
34
|
+
- Updated dependency [`zod@^3.24.3` ↗︎](https://www.npmjs.com/package/zod/v/3.24.3) (from `^3.24.2`, in `dependencies`)
|
|
35
|
+
- 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`)
|
|
36
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
37
|
+
Add fromDate and toDate to telemetry parameters
|
|
38
|
+
- 254f5c3: Audit, cleanup MastraClient
|
|
39
|
+
- 0097d50: Add serializedStepGraph to vNext workflow
|
|
40
|
+
Return serializedStepGraph from vNext workflow
|
|
41
|
+
Use serializedStepGraph in vNext workflow graph
|
|
42
|
+
- 2429c74: Add get workflow runs api to client-js
|
|
43
|
+
- 2e4f8e9: Agui client integration
|
|
44
|
+
- Updated dependencies [6052aa6]
|
|
45
|
+
- Updated dependencies [967b41c]
|
|
46
|
+
- Updated dependencies [3d2fb5c]
|
|
47
|
+
- Updated dependencies [26738f4]
|
|
48
|
+
- Updated dependencies [4155f47]
|
|
49
|
+
- Updated dependencies [7eeb2bc]
|
|
50
|
+
- Updated dependencies [b804723]
|
|
51
|
+
- Updated dependencies [8607972]
|
|
52
|
+
- Updated dependencies [ccef9f9]
|
|
53
|
+
- Updated dependencies [0097d50]
|
|
54
|
+
- Updated dependencies [7eeb2bc]
|
|
55
|
+
- Updated dependencies [17826a9]
|
|
56
|
+
- Updated dependencies [7d8b7c7]
|
|
57
|
+
- Updated dependencies [fba031f]
|
|
58
|
+
- Updated dependencies [3a5f1e1]
|
|
59
|
+
- Updated dependencies [51e6923]
|
|
60
|
+
- Updated dependencies [8398d89]
|
|
61
|
+
- @mastra/core@0.9.2
|
|
62
|
+
|
|
63
|
+
## 0.1.20-alpha.6
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 2e4f8e9: Agui client integration
|
|
68
|
+
- Updated dependencies [6052aa6]
|
|
69
|
+
- Updated dependencies [7d8b7c7]
|
|
70
|
+
- Updated dependencies [3a5f1e1]
|
|
71
|
+
- Updated dependencies [8398d89]
|
|
72
|
+
- @mastra/core@0.9.2-alpha.6
|
|
73
|
+
|
|
74
|
+
## 0.1.20-alpha.5
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [3d2fb5c]
|
|
79
|
+
- Updated dependencies [7eeb2bc]
|
|
80
|
+
- Updated dependencies [8607972]
|
|
81
|
+
- Updated dependencies [7eeb2bc]
|
|
82
|
+
- Updated dependencies [fba031f]
|
|
83
|
+
- @mastra/core@0.9.2-alpha.5
|
|
84
|
+
|
|
85
|
+
## 0.1.20-alpha.4
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [ccef9f9]
|
|
90
|
+
- Updated dependencies [51e6923]
|
|
91
|
+
- @mastra/core@0.9.2-alpha.4
|
|
92
|
+
|
|
93
|
+
## 0.1.20-alpha.3
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
98
|
+
Add fromDate and toDate to telemetry parameters
|
|
99
|
+
- Updated dependencies [967b41c]
|
|
100
|
+
- Updated dependencies [4155f47]
|
|
101
|
+
- Updated dependencies [17826a9]
|
|
102
|
+
- @mastra/core@0.9.2-alpha.3
|
|
103
|
+
|
|
104
|
+
## 0.1.20-alpha.2
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies [26738f4]
|
|
109
|
+
- @mastra/core@0.9.2-alpha.2
|
|
110
|
+
|
|
111
|
+
## 0.1.20-alpha.1
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- 254f5c3: Audit, cleanup MastraClient
|
|
116
|
+
- 2429c74: Add get workflow runs api to client-js
|
|
117
|
+
- Updated dependencies [b804723]
|
|
118
|
+
- @mastra/core@0.9.2-alpha.1
|
|
119
|
+
|
|
120
|
+
## 0.1.20-alpha.0
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- 0097d50: Add serializedStepGraph to vNext workflow
|
|
125
|
+
Return serializedStepGraph from vNext workflow
|
|
126
|
+
Use serializedStepGraph in vNext workflow graph
|
|
127
|
+
- Updated dependencies [0097d50]
|
|
128
|
+
- @mastra/core@0.9.2-alpha.0
|
|
129
|
+
|
|
130
|
+
## 0.1.19
|
|
4
131
|
|
|
5
132
|
### Patch Changes
|
|
6
133
|
|
|
@@ -12,14 +139,63 @@
|
|
|
12
139
|
- Updated dependencies [20275d4]
|
|
13
140
|
- Updated dependencies [7d1892c]
|
|
14
141
|
- Updated dependencies [a90a082]
|
|
142
|
+
- Updated dependencies [2d17c73]
|
|
15
143
|
- Updated dependencies [61e92f5]
|
|
16
144
|
- Updated dependencies [35955b0]
|
|
17
145
|
- Updated dependencies [6262bd5]
|
|
18
146
|
- Updated dependencies [c1409ef]
|
|
147
|
+
- Updated dependencies [3e7b69d]
|
|
148
|
+
- Updated dependencies [e4943b8]
|
|
19
149
|
- Updated dependencies [11d4485]
|
|
150
|
+
- Updated dependencies [479f490]
|
|
151
|
+
- Updated dependencies [c23a81c]
|
|
20
152
|
- Updated dependencies [2d4001d]
|
|
21
153
|
- Updated dependencies [c71013a]
|
|
22
|
-
|
|
154
|
+
- Updated dependencies [1d3b1cd]
|
|
155
|
+
- @mastra/core@0.9.1
|
|
156
|
+
|
|
157
|
+
## 0.1.19-alpha.8
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [2d17c73]
|
|
162
|
+
- @mastra/core@0.9.1-alpha.8
|
|
163
|
+
|
|
164
|
+
## 0.1.19-alpha.7
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [1d3b1cd]
|
|
169
|
+
- @mastra/core@0.9.1-alpha.7
|
|
170
|
+
|
|
171
|
+
## 0.1.19-alpha.6
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- Updated dependencies [c23a81c]
|
|
176
|
+
- @mastra/core@0.9.1-alpha.6
|
|
177
|
+
|
|
178
|
+
## 0.1.19-alpha.5
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [3e7b69d]
|
|
183
|
+
- @mastra/core@0.9.1-alpha.5
|
|
184
|
+
|
|
185
|
+
## 0.1.19-alpha.4
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies [e4943b8]
|
|
190
|
+
- Updated dependencies [479f490]
|
|
191
|
+
- @mastra/core@0.9.1-alpha.4
|
|
192
|
+
|
|
193
|
+
## 0.1.19-alpha.3
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies [6262bd5]
|
|
198
|
+
- @mastra/core@0.9.1-alpha.3
|
|
23
199
|
|
|
24
200
|
## 0.1.19-alpha.2
|
|
25
201
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,175 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var client = require('@ag-ui/client');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
5
|
+
var uiUtils = require('@ai-sdk/ui-utils');
|
|
3
6
|
var zod = require('zod');
|
|
4
7
|
var zodToJsonSchema = require('zod-to-json-schema');
|
|
5
|
-
var uiUtils = require('@ai-sdk/ui-utils');
|
|
6
8
|
|
|
7
|
-
// src/
|
|
9
|
+
// src/adapters/agui.ts
|
|
10
|
+
var AGUIAdapter = class extends client.AbstractAgent {
|
|
11
|
+
agent;
|
|
12
|
+
resourceId;
|
|
13
|
+
constructor({ agent, agentId, resourceId, ...rest }) {
|
|
14
|
+
super({
|
|
15
|
+
agentId,
|
|
16
|
+
...rest
|
|
17
|
+
});
|
|
18
|
+
this.agent = agent;
|
|
19
|
+
this.resourceId = resourceId;
|
|
20
|
+
}
|
|
21
|
+
run(input) {
|
|
22
|
+
return new rxjs.Observable((subscriber) => {
|
|
23
|
+
const convertedMessages = convertMessagesToMastraMessages(input.messages);
|
|
24
|
+
subscriber.next({
|
|
25
|
+
type: client.EventType.RUN_STARTED,
|
|
26
|
+
threadId: input.threadId,
|
|
27
|
+
runId: input.runId
|
|
28
|
+
});
|
|
29
|
+
this.agent.stream({
|
|
30
|
+
threadId: input.threadId,
|
|
31
|
+
resourceId: this.resourceId ?? "",
|
|
32
|
+
runId: input.runId,
|
|
33
|
+
messages: convertedMessages,
|
|
34
|
+
clientTools: input.tools.reduce(
|
|
35
|
+
(acc, tool) => {
|
|
36
|
+
acc[tool.name] = {
|
|
37
|
+
id: tool.name,
|
|
38
|
+
description: tool.description,
|
|
39
|
+
inputSchema: tool.parameters
|
|
40
|
+
};
|
|
41
|
+
return acc;
|
|
42
|
+
},
|
|
43
|
+
{}
|
|
44
|
+
)
|
|
45
|
+
}).then((response) => {
|
|
46
|
+
let currentMessageId = void 0;
|
|
47
|
+
return response.processDataStream({
|
|
48
|
+
onTextPart: (text) => {
|
|
49
|
+
if (currentMessageId === void 0) {
|
|
50
|
+
currentMessageId = generateUUID();
|
|
51
|
+
const message2 = {
|
|
52
|
+
type: client.EventType.TEXT_MESSAGE_START,
|
|
53
|
+
messageId: currentMessageId,
|
|
54
|
+
role: "assistant"
|
|
55
|
+
};
|
|
56
|
+
subscriber.next(message2);
|
|
57
|
+
}
|
|
58
|
+
const message = {
|
|
59
|
+
type: client.EventType.TEXT_MESSAGE_CONTENT,
|
|
60
|
+
messageId: currentMessageId,
|
|
61
|
+
delta: text
|
|
62
|
+
};
|
|
63
|
+
subscriber.next(message);
|
|
64
|
+
},
|
|
65
|
+
onFinishMessagePart: (message) => {
|
|
66
|
+
console.log("onFinishMessagePart", message);
|
|
67
|
+
if (currentMessageId !== void 0) {
|
|
68
|
+
const message2 = {
|
|
69
|
+
type: client.EventType.TEXT_MESSAGE_END,
|
|
70
|
+
messageId: currentMessageId
|
|
71
|
+
};
|
|
72
|
+
subscriber.next(message2);
|
|
73
|
+
}
|
|
74
|
+
subscriber.next({
|
|
75
|
+
type: client.EventType.RUN_FINISHED,
|
|
76
|
+
threadId: input.threadId,
|
|
77
|
+
runId: input.runId
|
|
78
|
+
});
|
|
79
|
+
subscriber.complete();
|
|
80
|
+
},
|
|
81
|
+
onToolCallPart(streamPart) {
|
|
82
|
+
const parentMessageId = currentMessageId || generateUUID();
|
|
83
|
+
subscriber.next({
|
|
84
|
+
type: client.EventType.TOOL_CALL_START,
|
|
85
|
+
toolCallId: streamPart.toolCallId,
|
|
86
|
+
toolCallName: streamPart.toolName,
|
|
87
|
+
parentMessageId
|
|
88
|
+
});
|
|
89
|
+
subscriber.next({
|
|
90
|
+
type: client.EventType.TOOL_CALL_ARGS,
|
|
91
|
+
toolCallId: streamPart.toolCallId,
|
|
92
|
+
delta: JSON.stringify(streamPart.args),
|
|
93
|
+
parentMessageId
|
|
94
|
+
});
|
|
95
|
+
subscriber.next({
|
|
96
|
+
type: client.EventType.TOOL_CALL_END,
|
|
97
|
+
toolCallId: streamPart.toolCallId,
|
|
98
|
+
parentMessageId
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}).catch((error) => {
|
|
103
|
+
console.log("error", error);
|
|
104
|
+
subscriber.error(error);
|
|
105
|
+
});
|
|
106
|
+
return () => {
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
function generateUUID() {
|
|
112
|
+
if (typeof crypto !== "undefined") {
|
|
113
|
+
if (typeof crypto.randomUUID === "function") {
|
|
114
|
+
return crypto.randomUUID();
|
|
115
|
+
}
|
|
116
|
+
if (typeof crypto.getRandomValues === "function") {
|
|
117
|
+
const buffer = new Uint8Array(16);
|
|
118
|
+
crypto.getRandomValues(buffer);
|
|
119
|
+
buffer[6] = buffer[6] & 15 | 64;
|
|
120
|
+
buffer[8] = buffer[8] & 63 | 128;
|
|
121
|
+
let hex = "";
|
|
122
|
+
for (let i = 0; i < 16; i++) {
|
|
123
|
+
hex += buffer[i].toString(16).padStart(2, "0");
|
|
124
|
+
if (i === 3 || i === 5 || i === 7 || i === 9) hex += "-";
|
|
125
|
+
}
|
|
126
|
+
return hex;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
130
|
+
const r = Math.random() * 16 | 0;
|
|
131
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
132
|
+
return v.toString(16);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function convertMessagesToMastraMessages(messages) {
|
|
136
|
+
const result = [];
|
|
137
|
+
for (const message of messages) {
|
|
138
|
+
if (message.role === "assistant") {
|
|
139
|
+
const parts = message.content ? [{ type: "text", text: message.content }] : [];
|
|
140
|
+
for (const toolCall of message.toolCalls ?? []) {
|
|
141
|
+
parts.push({
|
|
142
|
+
type: "tool-call",
|
|
143
|
+
toolCallId: toolCall.id,
|
|
144
|
+
toolName: toolCall.function.name,
|
|
145
|
+
args: JSON.parse(toolCall.function.arguments)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
result.push({
|
|
149
|
+
role: "assistant",
|
|
150
|
+
content: parts
|
|
151
|
+
});
|
|
152
|
+
} else if (message.role === "user") {
|
|
153
|
+
result.push({
|
|
154
|
+
role: "user",
|
|
155
|
+
content: message.content || ""
|
|
156
|
+
});
|
|
157
|
+
} else if (message.role === "tool") {
|
|
158
|
+
result.push({
|
|
159
|
+
role: "tool",
|
|
160
|
+
content: [
|
|
161
|
+
{
|
|
162
|
+
type: "tool-result",
|
|
163
|
+
toolCallId: message.toolCallId,
|
|
164
|
+
toolName: "unknown",
|
|
165
|
+
result: message.content
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
8
173
|
|
|
9
174
|
// src/resources/base.ts
|
|
10
175
|
var BaseResource = class {
|
|
@@ -136,7 +301,8 @@ var Agent = class extends BaseResource {
|
|
|
136
301
|
const processedParams = {
|
|
137
302
|
...params,
|
|
138
303
|
output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
|
|
139
|
-
experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
|
|
304
|
+
experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output,
|
|
305
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
140
306
|
};
|
|
141
307
|
return this.request(`/api/agents/${this.agentId}/generate`, {
|
|
142
308
|
method: "POST",
|
|
@@ -152,7 +318,8 @@ var Agent = class extends BaseResource {
|
|
|
152
318
|
const processedParams = {
|
|
153
319
|
...params,
|
|
154
320
|
output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
|
|
155
|
-
experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
|
|
321
|
+
experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output,
|
|
322
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
156
323
|
};
|
|
157
324
|
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
158
325
|
method: "POST",
|
|
@@ -373,6 +540,34 @@ var Workflow = class extends BaseResource {
|
|
|
373
540
|
details() {
|
|
374
541
|
return this.request(`/api/workflows/${this.workflowId}`);
|
|
375
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Retrieves all runs for a workflow
|
|
545
|
+
* @param params - Parameters for filtering runs
|
|
546
|
+
* @returns Promise containing workflow runs array
|
|
547
|
+
*/
|
|
548
|
+
runs(params) {
|
|
549
|
+
const searchParams = new URLSearchParams();
|
|
550
|
+
if (params?.fromDate) {
|
|
551
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
552
|
+
}
|
|
553
|
+
if (params?.toDate) {
|
|
554
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
555
|
+
}
|
|
556
|
+
if (params?.limit) {
|
|
557
|
+
searchParams.set("limit", String(params.limit));
|
|
558
|
+
}
|
|
559
|
+
if (params?.offset) {
|
|
560
|
+
searchParams.set("offset", String(params.offset));
|
|
561
|
+
}
|
|
562
|
+
if (params?.resourceId) {
|
|
563
|
+
searchParams.set("resourceId", params.resourceId);
|
|
564
|
+
}
|
|
565
|
+
if (searchParams.size) {
|
|
566
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
567
|
+
} else {
|
|
568
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
376
571
|
/**
|
|
377
572
|
* @deprecated Use `startAsync` instead
|
|
378
573
|
* Executes the workflow with the provided parameters
|
|
@@ -489,7 +684,7 @@ var Workflow = class extends BaseResource {
|
|
|
489
684
|
}
|
|
490
685
|
}
|
|
491
686
|
}
|
|
492
|
-
} catch
|
|
687
|
+
} catch {
|
|
493
688
|
}
|
|
494
689
|
}
|
|
495
690
|
if (buffer) {
|
|
@@ -543,9 +738,13 @@ var Tool = class extends BaseResource {
|
|
|
543
738
|
* @returns Promise containing the tool execution results
|
|
544
739
|
*/
|
|
545
740
|
execute(params) {
|
|
546
|
-
|
|
741
|
+
const url = new URLSearchParams();
|
|
742
|
+
if (params.runId) {
|
|
743
|
+
url.set("runId", params.runId);
|
|
744
|
+
}
|
|
745
|
+
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
547
746
|
method: "POST",
|
|
548
|
-
body: params
|
|
747
|
+
body: params.data
|
|
549
748
|
});
|
|
550
749
|
}
|
|
551
750
|
};
|
|
@@ -588,7 +787,7 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
588
787
|
}
|
|
589
788
|
}
|
|
590
789
|
}
|
|
591
|
-
} catch
|
|
790
|
+
} catch {
|
|
592
791
|
}
|
|
593
792
|
}
|
|
594
793
|
if (buffer) {
|
|
@@ -609,6 +808,34 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
609
808
|
details() {
|
|
610
809
|
return this.request(`/api/workflows/v-next/${this.workflowId}`);
|
|
611
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* Retrieves all runs for a vNext workflow
|
|
813
|
+
* @param params - Parameters for filtering runs
|
|
814
|
+
* @returns Promise containing vNext workflow runs array
|
|
815
|
+
*/
|
|
816
|
+
runs(params) {
|
|
817
|
+
const searchParams = new URLSearchParams();
|
|
818
|
+
if (params?.fromDate) {
|
|
819
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
820
|
+
}
|
|
821
|
+
if (params?.toDate) {
|
|
822
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
823
|
+
}
|
|
824
|
+
if (params?.limit) {
|
|
825
|
+
searchParams.set("limit", String(params.limit));
|
|
826
|
+
}
|
|
827
|
+
if (params?.offset) {
|
|
828
|
+
searchParams.set("offset", String(params.offset));
|
|
829
|
+
}
|
|
830
|
+
if (params?.resourceId) {
|
|
831
|
+
searchParams.set("resourceId", params.resourceId);
|
|
832
|
+
}
|
|
833
|
+
if (searchParams.size) {
|
|
834
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
|
|
835
|
+
} else {
|
|
836
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
612
839
|
/**
|
|
613
840
|
* Creates a new vNext workflow run
|
|
614
841
|
* @param params - Optional object containing the optional runId
|
|
@@ -718,6 +945,21 @@ var MastraClient = class extends BaseResource {
|
|
|
718
945
|
getAgents() {
|
|
719
946
|
return this.request("/api/agents");
|
|
720
947
|
}
|
|
948
|
+
async getAGUI({ resourceId }) {
|
|
949
|
+
const agents = await this.getAgents();
|
|
950
|
+
return Object.entries(agents).reduce(
|
|
951
|
+
(acc, [agentId]) => {
|
|
952
|
+
const agent = this.getAgent(agentId);
|
|
953
|
+
acc[agentId] = new AGUIAdapter({
|
|
954
|
+
agentId,
|
|
955
|
+
agent,
|
|
956
|
+
resourceId
|
|
957
|
+
});
|
|
958
|
+
return acc;
|
|
959
|
+
},
|
|
960
|
+
{}
|
|
961
|
+
);
|
|
962
|
+
}
|
|
721
963
|
/**
|
|
722
964
|
* Gets an agent instance by ID
|
|
723
965
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -850,7 +1092,7 @@ var MastraClient = class extends BaseResource {
|
|
|
850
1092
|
* @returns Promise containing telemetry data
|
|
851
1093
|
*/
|
|
852
1094
|
getTelemetry(params) {
|
|
853
|
-
const { name, scope, page, perPage, attribute } = params || {};
|
|
1095
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
|
|
854
1096
|
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
855
1097
|
const searchParams = new URLSearchParams();
|
|
856
1098
|
if (name) {
|
|
@@ -874,6 +1116,12 @@ var MastraClient = class extends BaseResource {
|
|
|
874
1116
|
searchParams.set("attribute", _attribute);
|
|
875
1117
|
}
|
|
876
1118
|
}
|
|
1119
|
+
if (fromDate) {
|
|
1120
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1121
|
+
}
|
|
1122
|
+
if (toDate) {
|
|
1123
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1124
|
+
}
|
|
877
1125
|
if (searchParams.size) {
|
|
878
1126
|
return this.request(`/api/telemetry?${searchParams}`);
|
|
879
1127
|
} else {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
3
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
4
|
import { JSONSchema7 } from 'json-schema';
|
|
3
5
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
6
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
6
7
|
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
7
8
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
@@ -40,6 +41,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
|
40
41
|
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
41
42
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
42
43
|
evals: any[];
|
|
44
|
+
instructions: string;
|
|
45
|
+
name: string;
|
|
46
|
+
id: string;
|
|
43
47
|
}
|
|
44
48
|
interface GetToolResponse {
|
|
45
49
|
id: string;
|
|
@@ -55,6 +59,14 @@ interface GetWorkflowResponse {
|
|
|
55
59
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
56
60
|
workflowId?: string;
|
|
57
61
|
}
|
|
62
|
+
interface GetWorkflowRunsParams {
|
|
63
|
+
fromDate?: Date;
|
|
64
|
+
toDate?: Date;
|
|
65
|
+
limit?: number;
|
|
66
|
+
offset?: number;
|
|
67
|
+
resourceId?: string;
|
|
68
|
+
}
|
|
69
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
58
70
|
type WorkflowRunResult = {
|
|
59
71
|
activePaths: Record<string, {
|
|
60
72
|
status: string;
|
|
@@ -67,8 +79,17 @@ type WorkflowRunResult = {
|
|
|
67
79
|
};
|
|
68
80
|
interface GetVNextWorkflowResponse {
|
|
69
81
|
name: string;
|
|
70
|
-
steps:
|
|
71
|
-
|
|
82
|
+
steps: {
|
|
83
|
+
[key: string]: {
|
|
84
|
+
id: string;
|
|
85
|
+
description: string;
|
|
86
|
+
inputSchema: string;
|
|
87
|
+
outputSchema: string;
|
|
88
|
+
resumeSchema: string;
|
|
89
|
+
suspendSchema: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
stepGraph: NewWorkflow['serializedStepGraph'];
|
|
72
93
|
inputSchema: string;
|
|
73
94
|
outputSchema: string;
|
|
74
95
|
}
|
|
@@ -184,6 +205,8 @@ interface GetTelemetryParams {
|
|
|
184
205
|
page?: number;
|
|
185
206
|
perPage?: number;
|
|
186
207
|
attribute?: Record<string, string>;
|
|
208
|
+
fromDate?: Date;
|
|
209
|
+
toDate?: Date;
|
|
187
210
|
}
|
|
188
211
|
interface GetNetworkResponse {
|
|
189
212
|
name: string;
|
|
@@ -389,6 +412,12 @@ declare class Workflow extends BaseResource {
|
|
|
389
412
|
* @returns Promise containing workflow details including steps and graphs
|
|
390
413
|
*/
|
|
391
414
|
details(): Promise<GetWorkflowResponse>;
|
|
415
|
+
/**
|
|
416
|
+
* Retrieves all runs for a workflow
|
|
417
|
+
* @param params - Parameters for filtering runs
|
|
418
|
+
* @returns Promise containing workflow runs array
|
|
419
|
+
*/
|
|
420
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
392
421
|
/**
|
|
393
422
|
* @deprecated Use `startAsync` instead
|
|
394
423
|
* Executes the workflow with the provided parameters
|
|
@@ -482,6 +511,7 @@ declare class Tool extends BaseResource {
|
|
|
482
511
|
*/
|
|
483
512
|
execute(params: {
|
|
484
513
|
data: any;
|
|
514
|
+
runId?: string;
|
|
485
515
|
}): Promise<any>;
|
|
486
516
|
}
|
|
487
517
|
|
|
@@ -501,6 +531,12 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
501
531
|
* @returns Promise containing vNext workflow details including steps and graphs
|
|
502
532
|
*/
|
|
503
533
|
details(): Promise<GetVNextWorkflowResponse>;
|
|
534
|
+
/**
|
|
535
|
+
* Retrieves all runs for a vNext workflow
|
|
536
|
+
* @param params - Parameters for filtering runs
|
|
537
|
+
* @returns Promise containing vNext workflow runs array
|
|
538
|
+
*/
|
|
539
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
504
540
|
/**
|
|
505
541
|
* Creates a new vNext workflow run
|
|
506
542
|
* @param params - Optional object containing the optional runId
|
|
@@ -574,6 +610,9 @@ declare class MastraClient extends BaseResource {
|
|
|
574
610
|
* @returns Promise containing map of agent IDs to agent details
|
|
575
611
|
*/
|
|
576
612
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
613
|
+
getAGUI({ resourceId }: {
|
|
614
|
+
resourceId: string;
|
|
615
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
577
616
|
/**
|
|
578
617
|
* Gets an agent instance by ID
|
|
579
618
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -688,4 +727,4 @@ declare class MastraClient extends BaseResource {
|
|
|
688
727
|
getNetwork(networkId: string): Network;
|
|
689
728
|
}
|
|
690
729
|
|
|
691
|
-
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, 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 };
|
|
730
|
+
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 };
|