@mastra/client-js 0.0.0-message-ordering-20250415215612 → 0.0.0-redis-cloud-transporter-20250508191651
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 +319 -3
- package/dist/index.cjs +427 -8
- package/dist/index.d.cts +150 -5
- package/dist/index.d.ts +150 -5
- package/dist/index.js +427 -8
- package/package.json +11 -6
- package/src/adapters/agui.test.ts +167 -0
- package/src/adapters/agui.ts +219 -0
- package/src/client.ts +47 -11
- package/src/index.test.ts +4 -4
- package/src/resources/agent.ts +3 -2
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +1 -0
- package/src/resources/memory-thread.ts +1 -8
- 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 +40 -2
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,13 +738,201 @@ 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
|
};
|
|
552
751
|
|
|
752
|
+
// src/resources/vnext-workflow.ts
|
|
753
|
+
var RECORD_SEPARATOR2 = "";
|
|
754
|
+
var VNextWorkflow = class extends BaseResource {
|
|
755
|
+
constructor(options, workflowId) {
|
|
756
|
+
super(options);
|
|
757
|
+
this.workflowId = workflowId;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
761
|
+
* separated by the Record Separator character (\x1E)
|
|
762
|
+
*
|
|
763
|
+
* @param stream - The readable stream to process
|
|
764
|
+
* @returns An async generator that yields parsed records
|
|
765
|
+
*/
|
|
766
|
+
async *streamProcessor(stream) {
|
|
767
|
+
const reader = stream.getReader();
|
|
768
|
+
let doneReading = false;
|
|
769
|
+
let buffer = "";
|
|
770
|
+
try {
|
|
771
|
+
while (!doneReading) {
|
|
772
|
+
const { done, value } = await reader.read();
|
|
773
|
+
doneReading = done;
|
|
774
|
+
if (done && !value) continue;
|
|
775
|
+
try {
|
|
776
|
+
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
777
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
778
|
+
buffer = chunks.pop() || "";
|
|
779
|
+
for (const chunk of chunks) {
|
|
780
|
+
if (chunk) {
|
|
781
|
+
if (typeof chunk === "string") {
|
|
782
|
+
try {
|
|
783
|
+
const parsedChunk = JSON.parse(chunk);
|
|
784
|
+
yield parsedChunk;
|
|
785
|
+
} catch {
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
} catch {
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (buffer) {
|
|
794
|
+
try {
|
|
795
|
+
yield JSON.parse(buffer);
|
|
796
|
+
} catch {
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
} finally {
|
|
800
|
+
reader.cancel().catch(() => {
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Retrieves details about the vNext workflow
|
|
806
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
807
|
+
*/
|
|
808
|
+
details() {
|
|
809
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}`);
|
|
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
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Creates a new vNext workflow run
|
|
841
|
+
* @param params - Optional object containing the optional runId
|
|
842
|
+
* @returns Promise containing the runId of the created run
|
|
843
|
+
*/
|
|
844
|
+
createRun(params) {
|
|
845
|
+
const searchParams = new URLSearchParams();
|
|
846
|
+
if (!!params?.runId) {
|
|
847
|
+
searchParams.set("runId", params.runId);
|
|
848
|
+
}
|
|
849
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
850
|
+
method: "POST"
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
855
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
856
|
+
* @returns Promise containing success message
|
|
857
|
+
*/
|
|
858
|
+
start(params) {
|
|
859
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
860
|
+
method: "POST",
|
|
861
|
+
body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
866
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
867
|
+
* @returns Promise containing success message
|
|
868
|
+
*/
|
|
869
|
+
resume({
|
|
870
|
+
step,
|
|
871
|
+
runId,
|
|
872
|
+
resumeData,
|
|
873
|
+
runtimeContext
|
|
874
|
+
}) {
|
|
875
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
876
|
+
method: "POST",
|
|
877
|
+
stream: true,
|
|
878
|
+
body: {
|
|
879
|
+
step,
|
|
880
|
+
resumeData,
|
|
881
|
+
runtimeContext
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
887
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
888
|
+
* @returns Promise containing the vNext workflow execution results
|
|
889
|
+
*/
|
|
890
|
+
startAsync(params) {
|
|
891
|
+
const searchParams = new URLSearchParams();
|
|
892
|
+
if (!!params?.runId) {
|
|
893
|
+
searchParams.set("runId", params.runId);
|
|
894
|
+
}
|
|
895
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
896
|
+
method: "POST",
|
|
897
|
+
body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
902
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
903
|
+
* @returns Promise containing the vNext workflow resume results
|
|
904
|
+
*/
|
|
905
|
+
resumeAsync(params) {
|
|
906
|
+
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
907
|
+
method: "POST",
|
|
908
|
+
body: {
|
|
909
|
+
step: params.step,
|
|
910
|
+
resumeData: params.resumeData,
|
|
911
|
+
runtimeContext: params.runtimeContext
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Watches vNext workflow transitions in real-time
|
|
917
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
918
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
919
|
+
*/
|
|
920
|
+
async watch({ runId }, onRecord) {
|
|
921
|
+
const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
|
|
922
|
+
stream: true
|
|
923
|
+
});
|
|
924
|
+
if (!response.ok) {
|
|
925
|
+
throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
|
|
926
|
+
}
|
|
927
|
+
if (!response.body) {
|
|
928
|
+
throw new Error("Response body is null");
|
|
929
|
+
}
|
|
930
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
931
|
+
onRecord(record);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
|
|
553
936
|
// src/client.ts
|
|
554
937
|
var MastraClient = class extends BaseResource {
|
|
555
938
|
constructor(options) {
|
|
@@ -562,6 +945,21 @@ var MastraClient = class extends BaseResource {
|
|
|
562
945
|
getAgents() {
|
|
563
946
|
return this.request("/api/agents");
|
|
564
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
|
+
}
|
|
565
963
|
/**
|
|
566
964
|
* Gets an agent instance by ID
|
|
567
965
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -642,6 +1040,21 @@ var MastraClient = class extends BaseResource {
|
|
|
642
1040
|
getWorkflow(workflowId) {
|
|
643
1041
|
return new Workflow(this.options, workflowId);
|
|
644
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Retrieves all available vNext workflows
|
|
1045
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
1046
|
+
*/
|
|
1047
|
+
getVNextWorkflows() {
|
|
1048
|
+
return this.request("/api/workflows/v-next");
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Gets a vNext workflow instance by ID
|
|
1052
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
1053
|
+
* @returns vNext Workflow instance
|
|
1054
|
+
*/
|
|
1055
|
+
getVNextWorkflow(workflowId) {
|
|
1056
|
+
return new VNextWorkflow(this.options, workflowId);
|
|
1057
|
+
}
|
|
645
1058
|
/**
|
|
646
1059
|
* Gets a vector instance by name
|
|
647
1060
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -679,7 +1092,7 @@ var MastraClient = class extends BaseResource {
|
|
|
679
1092
|
* @returns Promise containing telemetry data
|
|
680
1093
|
*/
|
|
681
1094
|
getTelemetry(params) {
|
|
682
|
-
const { name, scope, page, perPage, attribute } = params || {};
|
|
1095
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
|
|
683
1096
|
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
684
1097
|
const searchParams = new URLSearchParams();
|
|
685
1098
|
if (name) {
|
|
@@ -703,6 +1116,12 @@ var MastraClient = class extends BaseResource {
|
|
|
703
1116
|
searchParams.set("attribute", _attribute);
|
|
704
1117
|
}
|
|
705
1118
|
}
|
|
1119
|
+
if (fromDate) {
|
|
1120
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1121
|
+
}
|
|
1122
|
+
if (toDate) {
|
|
1123
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1124
|
+
}
|
|
706
1125
|
if (searchParams.size) {
|
|
707
1126
|
return this.request(`/api/telemetry?${searchParams}`);
|
|
708
1127
|
} else {
|