@mastra/client-js 0.0.0-switch-to-core-20250424015131 → 0.0.0-vnext-inngest-20250506121901
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 +169 -2
- package/dist/index.cjs +423 -6
- package/dist/index.d.cts +148 -3
- package/dist/index.d.ts +148 -3
- package/dist/index.js +423 -6
- package/package.json +6 -4
- package/src/adapters/agui.test.ts +167 -0
- package/src/adapters/agui.ts +219 -0
- package/src/client.ts +47 -2
- package/src/index.test.ts +4 -4
- package/src/resources/agent.ts +1 -2
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +1 -0
- package/src/resources/network.ts +1 -1
- package/src/resources/tool.ts +9 -3
- package/src/resources/vnext-workflow.ts +257 -0
- package/src/resources/workflow.ts +38 -2
- package/src/types.ts +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,182 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-vnext-inngest-20250506121901
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
8
|
+
Add fromDate and toDate to telemetry parameters
|
|
9
|
+
- 254f5c3: Audit, cleanup MastraClient
|
|
10
|
+
- 0097d50: Add serializedStepGraph to vNext workflow
|
|
11
|
+
Return serializedStepGraph from vNext workflow
|
|
12
|
+
Use serializedStepGraph in vNext workflow graph
|
|
13
|
+
- 2429c74: Add get workflow runs api to client-js
|
|
14
|
+
- 2e4f8e9: Agui client integration
|
|
15
|
+
- Updated dependencies [967b41c]
|
|
16
|
+
- Updated dependencies [3d2fb5c]
|
|
17
|
+
- Updated dependencies [26738f4]
|
|
18
|
+
- Updated dependencies [4155f47]
|
|
19
|
+
- Updated dependencies [7eeb2bc]
|
|
20
|
+
- Updated dependencies [b804723]
|
|
21
|
+
- Updated dependencies [8607972]
|
|
22
|
+
- Updated dependencies [ccef9f9]
|
|
23
|
+
- Updated dependencies [0097d50]
|
|
24
|
+
- Updated dependencies [7eeb2bc]
|
|
25
|
+
- Updated dependencies [17826a9]
|
|
26
|
+
- Updated dependencies [fba031f]
|
|
27
|
+
- Updated dependencies [51e6923]
|
|
28
|
+
- @mastra/core@0.0.0-vnext-inngest-20250506121901
|
|
29
|
+
|
|
30
|
+
## 0.1.20-alpha.5
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [3d2fb5c]
|
|
35
|
+
- Updated dependencies [7eeb2bc]
|
|
36
|
+
- Updated dependencies [8607972]
|
|
37
|
+
- Updated dependencies [7eeb2bc]
|
|
38
|
+
- Updated dependencies [fba031f]
|
|
39
|
+
- @mastra/core@0.9.2-alpha.5
|
|
40
|
+
|
|
41
|
+
## 0.1.20-alpha.4
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [ccef9f9]
|
|
46
|
+
- Updated dependencies [51e6923]
|
|
47
|
+
- @mastra/core@0.9.2-alpha.4
|
|
48
|
+
|
|
49
|
+
## 0.1.20-alpha.3
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 4155f47: Add parameters to filter workflow runs
|
|
54
|
+
Add fromDate and toDate to telemetry parameters
|
|
55
|
+
- Updated dependencies [967b41c]
|
|
56
|
+
- Updated dependencies [4155f47]
|
|
57
|
+
- Updated dependencies [17826a9]
|
|
58
|
+
- @mastra/core@0.9.2-alpha.3
|
|
59
|
+
|
|
60
|
+
## 0.1.20-alpha.2
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [26738f4]
|
|
65
|
+
- @mastra/core@0.9.2-alpha.2
|
|
66
|
+
|
|
67
|
+
## 0.1.20-alpha.1
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- 254f5c3: Audit, cleanup MastraClient
|
|
72
|
+
- 2429c74: Add get workflow runs api to client-js
|
|
73
|
+
- Updated dependencies [b804723]
|
|
74
|
+
- @mastra/core@0.9.2-alpha.1
|
|
75
|
+
|
|
76
|
+
## 0.1.20-alpha.0
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- 0097d50: Add serializedStepGraph to vNext workflow
|
|
81
|
+
Return serializedStepGraph from vNext workflow
|
|
82
|
+
Use serializedStepGraph in vNext workflow graph
|
|
83
|
+
- Updated dependencies [0097d50]
|
|
84
|
+
- @mastra/core@0.9.2-alpha.0
|
|
85
|
+
|
|
86
|
+
## 0.1.19
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- b50b9b7: Add vNext workflow to client-js
|
|
91
|
+
- 11d4485: Show VNext workflows on the playground
|
|
92
|
+
Show running status for step in vNext workflowState
|
|
93
|
+
- Updated dependencies [405b63d]
|
|
7
94
|
- Updated dependencies [81fb7f6]
|
|
95
|
+
- Updated dependencies [20275d4]
|
|
96
|
+
- Updated dependencies [7d1892c]
|
|
97
|
+
- Updated dependencies [a90a082]
|
|
98
|
+
- Updated dependencies [2d17c73]
|
|
99
|
+
- Updated dependencies [61e92f5]
|
|
100
|
+
- Updated dependencies [35955b0]
|
|
101
|
+
- Updated dependencies [6262bd5]
|
|
102
|
+
- Updated dependencies [c1409ef]
|
|
103
|
+
- Updated dependencies [3e7b69d]
|
|
104
|
+
- Updated dependencies [e4943b8]
|
|
105
|
+
- Updated dependencies [11d4485]
|
|
106
|
+
- Updated dependencies [479f490]
|
|
107
|
+
- Updated dependencies [c23a81c]
|
|
108
|
+
- Updated dependencies [2d4001d]
|
|
109
|
+
- Updated dependencies [c71013a]
|
|
110
|
+
- Updated dependencies [1d3b1cd]
|
|
111
|
+
- @mastra/core@0.9.1
|
|
112
|
+
|
|
113
|
+
## 0.1.19-alpha.8
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [2d17c73]
|
|
118
|
+
- @mastra/core@0.9.1-alpha.8
|
|
119
|
+
|
|
120
|
+
## 0.1.19-alpha.7
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [1d3b1cd]
|
|
125
|
+
- @mastra/core@0.9.1-alpha.7
|
|
126
|
+
|
|
127
|
+
## 0.1.19-alpha.6
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Updated dependencies [c23a81c]
|
|
132
|
+
- @mastra/core@0.9.1-alpha.6
|
|
133
|
+
|
|
134
|
+
## 0.1.19-alpha.5
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [3e7b69d]
|
|
139
|
+
- @mastra/core@0.9.1-alpha.5
|
|
140
|
+
|
|
141
|
+
## 0.1.19-alpha.4
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [e4943b8]
|
|
146
|
+
- Updated dependencies [479f490]
|
|
147
|
+
- @mastra/core@0.9.1-alpha.4
|
|
148
|
+
|
|
149
|
+
## 0.1.19-alpha.3
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [6262bd5]
|
|
154
|
+
- @mastra/core@0.9.1-alpha.3
|
|
155
|
+
|
|
156
|
+
## 0.1.19-alpha.2
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [405b63d]
|
|
161
|
+
- Updated dependencies [61e92f5]
|
|
162
|
+
- Updated dependencies [c71013a]
|
|
163
|
+
- @mastra/core@0.9.1-alpha.2
|
|
164
|
+
|
|
165
|
+
## 0.1.19-alpha.1
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- b50b9b7: Add vNext workflow to client-js
|
|
170
|
+
- 11d4485: Show VNext workflows on the playground
|
|
171
|
+
Show running status for step in vNext workflowState
|
|
172
|
+
- Updated dependencies [20275d4]
|
|
8
173
|
- Updated dependencies [7d1892c]
|
|
9
174
|
- Updated dependencies [a90a082]
|
|
10
175
|
- Updated dependencies [35955b0]
|
|
176
|
+
- Updated dependencies [c1409ef]
|
|
177
|
+
- Updated dependencies [11d4485]
|
|
11
178
|
- Updated dependencies [2d4001d]
|
|
12
|
-
- @mastra/core@0.
|
|
179
|
+
- @mastra/core@0.9.1-alpha.1
|
|
13
180
|
|
|
14
181
|
## 0.1.19-alpha.0
|
|
15
182
|
|
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 {
|
|
@@ -373,6 +538,34 @@ var Workflow = class extends BaseResource {
|
|
|
373
538
|
details() {
|
|
374
539
|
return this.request(`/api/workflows/${this.workflowId}`);
|
|
375
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Retrieves all runs for a workflow
|
|
543
|
+
* @param params - Parameters for filtering runs
|
|
544
|
+
* @returns Promise containing workflow runs array
|
|
545
|
+
*/
|
|
546
|
+
runs(params) {
|
|
547
|
+
const searchParams = new URLSearchParams();
|
|
548
|
+
if (params?.fromDate) {
|
|
549
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
550
|
+
}
|
|
551
|
+
if (params?.toDate) {
|
|
552
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
553
|
+
}
|
|
554
|
+
if (params?.limit) {
|
|
555
|
+
searchParams.set("limit", String(params.limit));
|
|
556
|
+
}
|
|
557
|
+
if (params?.offset) {
|
|
558
|
+
searchParams.set("offset", String(params.offset));
|
|
559
|
+
}
|
|
560
|
+
if (params?.resourceId) {
|
|
561
|
+
searchParams.set("resourceId", params.resourceId);
|
|
562
|
+
}
|
|
563
|
+
if (searchParams.size) {
|
|
564
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
565
|
+
} else {
|
|
566
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
376
569
|
/**
|
|
377
570
|
* @deprecated Use `startAsync` instead
|
|
378
571
|
* Executes the workflow with the provided parameters
|
|
@@ -489,7 +682,7 @@ var Workflow = class extends BaseResource {
|
|
|
489
682
|
}
|
|
490
683
|
}
|
|
491
684
|
}
|
|
492
|
-
} catch
|
|
685
|
+
} catch {
|
|
493
686
|
}
|
|
494
687
|
}
|
|
495
688
|
if (buffer) {
|
|
@@ -543,13 +736,201 @@ var Tool = class extends BaseResource {
|
|
|
543
736
|
* @returns Promise containing the tool execution results
|
|
544
737
|
*/
|
|
545
738
|
execute(params) {
|
|
546
|
-
|
|
739
|
+
const url = new URLSearchParams();
|
|
740
|
+
if (params.runId) {
|
|
741
|
+
url.set("runId", params.runId);
|
|
742
|
+
}
|
|
743
|
+
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
547
744
|
method: "POST",
|
|
548
|
-
body: params
|
|
745
|
+
body: params.data
|
|
549
746
|
});
|
|
550
747
|
}
|
|
551
748
|
};
|
|
552
749
|
|
|
750
|
+
// src/resources/vnext-workflow.ts
|
|
751
|
+
var RECORD_SEPARATOR2 = "";
|
|
752
|
+
var VNextWorkflow = class extends BaseResource {
|
|
753
|
+
constructor(options, workflowId) {
|
|
754
|
+
super(options);
|
|
755
|
+
this.workflowId = workflowId;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
759
|
+
* separated by the Record Separator character (\x1E)
|
|
760
|
+
*
|
|
761
|
+
* @param stream - The readable stream to process
|
|
762
|
+
* @returns An async generator that yields parsed records
|
|
763
|
+
*/
|
|
764
|
+
async *streamProcessor(stream) {
|
|
765
|
+
const reader = stream.getReader();
|
|
766
|
+
let doneReading = false;
|
|
767
|
+
let buffer = "";
|
|
768
|
+
try {
|
|
769
|
+
while (!doneReading) {
|
|
770
|
+
const { done, value } = await reader.read();
|
|
771
|
+
doneReading = done;
|
|
772
|
+
if (done && !value) continue;
|
|
773
|
+
try {
|
|
774
|
+
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
775
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
776
|
+
buffer = chunks.pop() || "";
|
|
777
|
+
for (const chunk of chunks) {
|
|
778
|
+
if (chunk) {
|
|
779
|
+
if (typeof chunk === "string") {
|
|
780
|
+
try {
|
|
781
|
+
const parsedChunk = JSON.parse(chunk);
|
|
782
|
+
yield parsedChunk;
|
|
783
|
+
} catch {
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
if (buffer) {
|
|
792
|
+
try {
|
|
793
|
+
yield JSON.parse(buffer);
|
|
794
|
+
} catch {
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
} finally {
|
|
798
|
+
reader.cancel().catch(() => {
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Retrieves details about the vNext workflow
|
|
804
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
805
|
+
*/
|
|
806
|
+
details() {
|
|
807
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}`);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Retrieves all runs for a vNext workflow
|
|
811
|
+
* @param params - Parameters for filtering runs
|
|
812
|
+
* @returns Promise containing vNext workflow runs array
|
|
813
|
+
*/
|
|
814
|
+
runs(params) {
|
|
815
|
+
const searchParams = new URLSearchParams();
|
|
816
|
+
if (params?.fromDate) {
|
|
817
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
818
|
+
}
|
|
819
|
+
if (params?.toDate) {
|
|
820
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
821
|
+
}
|
|
822
|
+
if (params?.limit) {
|
|
823
|
+
searchParams.set("limit", String(params.limit));
|
|
824
|
+
}
|
|
825
|
+
if (params?.offset) {
|
|
826
|
+
searchParams.set("offset", String(params.offset));
|
|
827
|
+
}
|
|
828
|
+
if (params?.resourceId) {
|
|
829
|
+
searchParams.set("resourceId", params.resourceId);
|
|
830
|
+
}
|
|
831
|
+
if (searchParams.size) {
|
|
832
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
|
|
833
|
+
} else {
|
|
834
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Creates a new vNext workflow run
|
|
839
|
+
* @param params - Optional object containing the optional runId
|
|
840
|
+
* @returns Promise containing the runId of the created run
|
|
841
|
+
*/
|
|
842
|
+
createRun(params) {
|
|
843
|
+
const searchParams = new URLSearchParams();
|
|
844
|
+
if (!!params?.runId) {
|
|
845
|
+
searchParams.set("runId", params.runId);
|
|
846
|
+
}
|
|
847
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
848
|
+
method: "POST"
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
853
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
854
|
+
* @returns Promise containing success message
|
|
855
|
+
*/
|
|
856
|
+
start(params) {
|
|
857
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
858
|
+
method: "POST",
|
|
859
|
+
body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
864
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
865
|
+
* @returns Promise containing success message
|
|
866
|
+
*/
|
|
867
|
+
resume({
|
|
868
|
+
step,
|
|
869
|
+
runId,
|
|
870
|
+
resumeData,
|
|
871
|
+
runtimeContext
|
|
872
|
+
}) {
|
|
873
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
874
|
+
method: "POST",
|
|
875
|
+
stream: true,
|
|
876
|
+
body: {
|
|
877
|
+
step,
|
|
878
|
+
resumeData,
|
|
879
|
+
runtimeContext
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
885
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
886
|
+
* @returns Promise containing the vNext workflow execution results
|
|
887
|
+
*/
|
|
888
|
+
startAsync(params) {
|
|
889
|
+
const searchParams = new URLSearchParams();
|
|
890
|
+
if (!!params?.runId) {
|
|
891
|
+
searchParams.set("runId", params.runId);
|
|
892
|
+
}
|
|
893
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
894
|
+
method: "POST",
|
|
895
|
+
body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
900
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
901
|
+
* @returns Promise containing the vNext workflow resume results
|
|
902
|
+
*/
|
|
903
|
+
resumeAsync(params) {
|
|
904
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
905
|
+
method: "POST",
|
|
906
|
+
body: {
|
|
907
|
+
step: params.step,
|
|
908
|
+
resumeData: params.resumeData,
|
|
909
|
+
runtimeContext: params.runtimeContext
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Watches vNext workflow transitions in real-time
|
|
915
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
916
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
917
|
+
*/
|
|
918
|
+
async watch({ runId }, onRecord) {
|
|
919
|
+
const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
|
|
920
|
+
stream: true
|
|
921
|
+
});
|
|
922
|
+
if (!response.ok) {
|
|
923
|
+
throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
|
|
924
|
+
}
|
|
925
|
+
if (!response.body) {
|
|
926
|
+
throw new Error("Response body is null");
|
|
927
|
+
}
|
|
928
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
929
|
+
onRecord(record);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
553
934
|
// src/client.ts
|
|
554
935
|
var MastraClient = class extends BaseResource {
|
|
555
936
|
constructor(options) {
|
|
@@ -562,6 +943,21 @@ var MastraClient = class extends BaseResource {
|
|
|
562
943
|
getAgents() {
|
|
563
944
|
return this.request("/api/agents");
|
|
564
945
|
}
|
|
946
|
+
async getAGUI({ resourceId }) {
|
|
947
|
+
const agents = await this.getAgents();
|
|
948
|
+
return Object.entries(agents).reduce(
|
|
949
|
+
(acc, [agentId]) => {
|
|
950
|
+
const agent = this.getAgent(agentId);
|
|
951
|
+
acc[agentId] = new AGUIAdapter({
|
|
952
|
+
agentId,
|
|
953
|
+
agent,
|
|
954
|
+
resourceId
|
|
955
|
+
});
|
|
956
|
+
return acc;
|
|
957
|
+
},
|
|
958
|
+
{}
|
|
959
|
+
);
|
|
960
|
+
}
|
|
565
961
|
/**
|
|
566
962
|
* Gets an agent instance by ID
|
|
567
963
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -642,6 +1038,21 @@ var MastraClient = class extends BaseResource {
|
|
|
642
1038
|
getWorkflow(workflowId) {
|
|
643
1039
|
return new Workflow(this.options, workflowId);
|
|
644
1040
|
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Retrieves all available vNext workflows
|
|
1043
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
1044
|
+
*/
|
|
1045
|
+
getVNextWorkflows() {
|
|
1046
|
+
return this.request("/api/workflows/v-next");
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Gets a vNext workflow instance by ID
|
|
1050
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
1051
|
+
* @returns vNext Workflow instance
|
|
1052
|
+
*/
|
|
1053
|
+
getVNextWorkflow(workflowId) {
|
|
1054
|
+
return new VNextWorkflow(this.options, workflowId);
|
|
1055
|
+
}
|
|
645
1056
|
/**
|
|
646
1057
|
* Gets a vector instance by name
|
|
647
1058
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -679,7 +1090,7 @@ var MastraClient = class extends BaseResource {
|
|
|
679
1090
|
* @returns Promise containing telemetry data
|
|
680
1091
|
*/
|
|
681
1092
|
getTelemetry(params) {
|
|
682
|
-
const { name, scope, page, perPage, attribute } = params || {};
|
|
1093
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
|
|
683
1094
|
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
684
1095
|
const searchParams = new URLSearchParams();
|
|
685
1096
|
if (name) {
|
|
@@ -703,6 +1114,12 @@ var MastraClient = class extends BaseResource {
|
|
|
703
1114
|
searchParams.set("attribute", _attribute);
|
|
704
1115
|
}
|
|
705
1116
|
}
|
|
1117
|
+
if (fromDate) {
|
|
1118
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1119
|
+
}
|
|
1120
|
+
if (toDate) {
|
|
1121
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1122
|
+
}
|
|
706
1123
|
if (searchParams.size) {
|
|
707
1124
|
return this.request(`/api/telemetry?${searchParams}`);
|
|
708
1125
|
} else {
|