@mastra/client-js 0.0.0-ai-telementry-ui-20250908102126 → 0.0.0-break-rename-vnext-legacy-20251002212351
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 +366 -10
- package/README.md +6 -10
- package/dist/client.d.ts +37 -39
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +674 -602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +655 -585
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +5 -6
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +66 -37
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +0 -2
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/mcp-tool.d.ts +2 -1
- package/dist/resources/mcp-tool.d.ts.map +1 -1
- package/dist/resources/observability.d.ts +17 -1
- package/dist/resources/observability.d.ts.map +1 -1
- package/dist/resources/tool.d.ts +2 -1
- package/dist/resources/tool.d.ts.map +1 -1
- package/dist/resources/vector.d.ts +5 -2
- package/dist/resources/vector.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +128 -13
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/types.d.ts +66 -43
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +5 -1
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/package.json +5 -6
- package/dist/resources/legacy-workflow.d.ts +0 -87
- package/dist/resources/legacy-workflow.d.ts.map +0 -1
- package/dist/resources/network.d.ts +0 -30
- package/dist/resources/network.d.ts.map +0 -1
- package/dist/resources/vNextNetwork.d.ts +0 -42
- package/dist/resources/vNextNetwork.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -15,6 +15,20 @@ function parseClientRuntimeContext(runtimeContext) {
|
|
|
15
15
|
}
|
|
16
16
|
return void 0;
|
|
17
17
|
}
|
|
18
|
+
function base64RuntimeContext(runtimeContext) {
|
|
19
|
+
if (runtimeContext) {
|
|
20
|
+
return btoa(JSON.stringify(runtimeContext));
|
|
21
|
+
}
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
function runtimeContextQueryString(runtimeContext) {
|
|
25
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
26
|
+
if (!runtimeContextParam) return "";
|
|
27
|
+
const searchParams = new URLSearchParams();
|
|
28
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
29
|
+
const queryString = searchParams.toString();
|
|
30
|
+
return queryString ? `?${queryString}` : "";
|
|
31
|
+
}
|
|
18
32
|
function isZodType(value) {
|
|
19
33
|
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
20
34
|
}
|
|
@@ -26,7 +40,7 @@ function zodToJsonSchema(zodSchema) {
|
|
|
26
40
|
const fn = "toJSONSchema";
|
|
27
41
|
return z[fn].call(z, zodSchema);
|
|
28
42
|
}
|
|
29
|
-
return originalZodToJsonSchema(zodSchema, { $refStrategy: "
|
|
43
|
+
return originalZodToJsonSchema(zodSchema, { $refStrategy: "relative" });
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
// src/utils/process-client-tools.ts
|
|
@@ -59,7 +73,7 @@ function processClientTools(clientTools) {
|
|
|
59
73
|
}
|
|
60
74
|
|
|
61
75
|
// src/utils/process-mastra-stream.ts
|
|
62
|
-
async function
|
|
76
|
+
async function sharedProcessMastraStream({
|
|
63
77
|
stream,
|
|
64
78
|
onChunk
|
|
65
79
|
}) {
|
|
@@ -77,7 +91,7 @@ async function processMastraStream({
|
|
|
77
91
|
if (line.startsWith("data: ")) {
|
|
78
92
|
const data = line.slice(6);
|
|
79
93
|
if (data === "[DONE]") {
|
|
80
|
-
console.
|
|
94
|
+
console.info("\u{1F3C1} Stream finished");
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
83
97
|
try {
|
|
@@ -93,6 +107,24 @@ async function processMastraStream({
|
|
|
93
107
|
reader.releaseLock();
|
|
94
108
|
}
|
|
95
109
|
}
|
|
110
|
+
async function processMastraNetworkStream({
|
|
111
|
+
stream,
|
|
112
|
+
onChunk
|
|
113
|
+
}) {
|
|
114
|
+
return sharedProcessMastraStream({
|
|
115
|
+
stream,
|
|
116
|
+
onChunk
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function processMastraStream({
|
|
120
|
+
stream,
|
|
121
|
+
onChunk
|
|
122
|
+
}) {
|
|
123
|
+
return sharedProcessMastraStream({
|
|
124
|
+
stream,
|
|
125
|
+
onChunk
|
|
126
|
+
});
|
|
127
|
+
}
|
|
96
128
|
|
|
97
129
|
// src/resources/base.ts
|
|
98
130
|
var BaseResource = class {
|
|
@@ -181,7 +213,9 @@ async function executeToolCallAndRespond({
|
|
|
181
213
|
resourceId,
|
|
182
214
|
threadId,
|
|
183
215
|
runtimeContext,
|
|
184
|
-
tracingContext: { currentSpan: void 0 }
|
|
216
|
+
tracingContext: { currentSpan: void 0 },
|
|
217
|
+
suspend: async () => {
|
|
218
|
+
}
|
|
185
219
|
},
|
|
186
220
|
{
|
|
187
221
|
messages: response.messages,
|
|
@@ -189,11 +223,7 @@ async function executeToolCallAndRespond({
|
|
|
189
223
|
}
|
|
190
224
|
);
|
|
191
225
|
const updatedMessages = [
|
|
192
|
-
|
|
193
|
-
role: "user",
|
|
194
|
-
content: params.messages
|
|
195
|
-
},
|
|
196
|
-
...response.response.messages,
|
|
226
|
+
...response.response.messages || [],
|
|
197
227
|
{
|
|
198
228
|
role: "tool",
|
|
199
229
|
content: [
|
|
@@ -255,17 +285,21 @@ var AgentVoice = class extends BaseResource {
|
|
|
255
285
|
}
|
|
256
286
|
/**
|
|
257
287
|
* Get available speakers for the agent's voice provider
|
|
288
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
289
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
258
290
|
* @returns Promise containing list of available speakers
|
|
259
291
|
*/
|
|
260
|
-
getSpeakers() {
|
|
261
|
-
return this.request(`/api/agents/${this.agentId}/voice/speakers`);
|
|
292
|
+
getSpeakers(runtimeContext) {
|
|
293
|
+
return this.request(`/api/agents/${this.agentId}/voice/speakers${runtimeContextQueryString(runtimeContext)}`);
|
|
262
294
|
}
|
|
263
295
|
/**
|
|
264
296
|
* Get the listener configuration for the agent's voice provider
|
|
297
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
298
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
265
299
|
* @returns Promise containing a check if the agent has listening capabilities
|
|
266
300
|
*/
|
|
267
|
-
getListener() {
|
|
268
|
-
return this.request(`/api/agents/${this.agentId}/voice/listener`);
|
|
301
|
+
getListener(runtimeContext) {
|
|
302
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener${runtimeContextQueryString(runtimeContext)}`);
|
|
269
303
|
}
|
|
270
304
|
};
|
|
271
305
|
var Agent = class extends BaseResource {
|
|
@@ -277,16 +311,11 @@ var Agent = class extends BaseResource {
|
|
|
277
311
|
voice;
|
|
278
312
|
/**
|
|
279
313
|
* Retrieves details about the agent
|
|
314
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
280
315
|
* @returns Promise containing agent details including model and instructions
|
|
281
316
|
*/
|
|
282
|
-
details() {
|
|
283
|
-
return this.request(`/api/agents/${this.agentId}`);
|
|
284
|
-
}
|
|
285
|
-
async generate(params) {
|
|
286
|
-
console.warn(
|
|
287
|
-
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet."
|
|
288
|
-
);
|
|
289
|
-
return this.generateLegacy(params);
|
|
317
|
+
details(runtimeContext) {
|
|
318
|
+
return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
|
|
290
319
|
}
|
|
291
320
|
async generateLegacy(params) {
|
|
292
321
|
const processedParams = {
|
|
@@ -319,7 +348,9 @@ var Agent = class extends BaseResource {
|
|
|
319
348
|
resourceId,
|
|
320
349
|
threadId,
|
|
321
350
|
runtimeContext,
|
|
322
|
-
tracingContext: { currentSpan: void 0 }
|
|
351
|
+
tracingContext: { currentSpan: void 0 },
|
|
352
|
+
suspend: async () => {
|
|
353
|
+
}
|
|
323
354
|
},
|
|
324
355
|
{
|
|
325
356
|
messages: response.messages,
|
|
@@ -327,10 +358,6 @@ var Agent = class extends BaseResource {
|
|
|
327
358
|
}
|
|
328
359
|
);
|
|
329
360
|
const updatedMessages = [
|
|
330
|
-
{
|
|
331
|
-
role: "user",
|
|
332
|
-
content: params.messages
|
|
333
|
-
},
|
|
334
361
|
...response.response.messages,
|
|
335
362
|
{
|
|
336
363
|
role: "tool",
|
|
@@ -353,16 +380,29 @@ var Agent = class extends BaseResource {
|
|
|
353
380
|
}
|
|
354
381
|
return response;
|
|
355
382
|
}
|
|
356
|
-
async
|
|
383
|
+
async generate(messagesOrParams, options) {
|
|
384
|
+
let params;
|
|
385
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
386
|
+
params = messagesOrParams;
|
|
387
|
+
} else {
|
|
388
|
+
params = {
|
|
389
|
+
messages: messagesOrParams,
|
|
390
|
+
...options
|
|
391
|
+
};
|
|
392
|
+
}
|
|
357
393
|
const processedParams = {
|
|
358
394
|
...params,
|
|
359
395
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
360
396
|
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
361
|
-
clientTools: processClientTools(params.clientTools)
|
|
397
|
+
clientTools: processClientTools(params.clientTools),
|
|
398
|
+
structuredOutput: params.structuredOutput ? {
|
|
399
|
+
...params.structuredOutput,
|
|
400
|
+
schema: zodToJsonSchema(params.structuredOutput.schema)
|
|
401
|
+
} : void 0
|
|
362
402
|
};
|
|
363
403
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
364
404
|
const response = await this.request(
|
|
365
|
-
`/api/agents/${this.agentId}/generate
|
|
405
|
+
`/api/agents/${this.agentId}/generate`,
|
|
366
406
|
{
|
|
367
407
|
method: "POST",
|
|
368
408
|
body: processedParams
|
|
@@ -376,7 +416,7 @@ var Agent = class extends BaseResource {
|
|
|
376
416
|
resourceId,
|
|
377
417
|
threadId,
|
|
378
418
|
runtimeContext,
|
|
379
|
-
respondFn: this.
|
|
419
|
+
respondFn: this.generate.bind(this)
|
|
380
420
|
});
|
|
381
421
|
}
|
|
382
422
|
return response;
|
|
@@ -643,17 +683,6 @@ var Agent = class extends BaseResource {
|
|
|
643
683
|
});
|
|
644
684
|
onFinish?.({ message, finishReason, usage });
|
|
645
685
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Streams a response from the agent
|
|
648
|
-
* @param params - Stream parameters including prompt
|
|
649
|
-
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
650
|
-
*/
|
|
651
|
-
async stream(params) {
|
|
652
|
-
console.warn(
|
|
653
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet."
|
|
654
|
-
);
|
|
655
|
-
return this.streamLegacy(params);
|
|
656
|
-
}
|
|
657
686
|
/**
|
|
658
687
|
* Streams a response from the agent
|
|
659
688
|
* @param params - Stream parameters including prompt
|
|
@@ -863,7 +892,7 @@ var Agent = class extends BaseResource {
|
|
|
863
892
|
step,
|
|
864
893
|
toolCallId: chunk.payload.toolCallId,
|
|
865
894
|
toolName: chunk.payload.toolName,
|
|
866
|
-
args:
|
|
895
|
+
args: chunk.payload.args
|
|
867
896
|
};
|
|
868
897
|
message.toolInvocations.push(invocation);
|
|
869
898
|
updateToolInvocationPart(chunk.payload.toolCallId, invocation);
|
|
@@ -917,14 +946,14 @@ var Agent = class extends BaseResource {
|
|
|
917
946
|
}
|
|
918
947
|
case "step-finish": {
|
|
919
948
|
step += 1;
|
|
920
|
-
currentTextPart = chunk.payload.isContinued ? currentTextPart : void 0;
|
|
949
|
+
currentTextPart = chunk.payload.stepResult.isContinued ? currentTextPart : void 0;
|
|
921
950
|
currentReasoningPart = void 0;
|
|
922
951
|
currentReasoningTextDetail = void 0;
|
|
923
952
|
execUpdate();
|
|
924
953
|
break;
|
|
925
954
|
}
|
|
926
955
|
case "finish": {
|
|
927
|
-
finishReason = chunk.payload.
|
|
956
|
+
finishReason = chunk.payload.stepResult.reason;
|
|
928
957
|
if (chunk.payload.usage != null) {
|
|
929
958
|
usage = chunk.payload.usage;
|
|
930
959
|
}
|
|
@@ -936,7 +965,7 @@ var Agent = class extends BaseResource {
|
|
|
936
965
|
onFinish?.({ message, finishReason, usage });
|
|
937
966
|
}
|
|
938
967
|
async processStreamResponse_vNext(processedParams, writable) {
|
|
939
|
-
const response = await this.request(`/api/agents/${this.agentId}/stream
|
|
968
|
+
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
940
969
|
method: "POST",
|
|
941
970
|
body: processedParams,
|
|
942
971
|
stream: true
|
|
@@ -948,9 +977,28 @@ var Agent = class extends BaseResource {
|
|
|
948
977
|
let toolCalls = [];
|
|
949
978
|
let messages = [];
|
|
950
979
|
const [streamForWritable, streamForProcessing] = response.body.tee();
|
|
951
|
-
streamForWritable.pipeTo(
|
|
952
|
-
|
|
953
|
-
|
|
980
|
+
streamForWritable.pipeTo(
|
|
981
|
+
new WritableStream({
|
|
982
|
+
async write(chunk) {
|
|
983
|
+
try {
|
|
984
|
+
const text = new TextDecoder().decode(chunk);
|
|
985
|
+
if (text.includes("[DONE]")) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
} catch {
|
|
989
|
+
}
|
|
990
|
+
const writer = writable.getWriter();
|
|
991
|
+
try {
|
|
992
|
+
await writer.write(chunk);
|
|
993
|
+
} finally {
|
|
994
|
+
writer.releaseLock();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}),
|
|
998
|
+
{
|
|
999
|
+
preventClose: true
|
|
1000
|
+
}
|
|
1001
|
+
).catch((error) => {
|
|
954
1002
|
console.error("Error piping to writable stream:", error);
|
|
955
1003
|
});
|
|
956
1004
|
this.processChatResponse_vNext({
|
|
@@ -969,9 +1017,11 @@ var Agent = class extends BaseResource {
|
|
|
969
1017
|
if (toolCall) {
|
|
970
1018
|
toolCalls.push(toolCall);
|
|
971
1019
|
}
|
|
1020
|
+
let shouldExecuteClientTool = false;
|
|
972
1021
|
for (const toolCall2 of toolCalls) {
|
|
973
1022
|
const clientTool = processedParams.clientTools?.[toolCall2.toolName];
|
|
974
1023
|
if (clientTool && clientTool.execute) {
|
|
1024
|
+
shouldExecuteClientTool = true;
|
|
975
1025
|
const result = await clientTool.execute(
|
|
976
1026
|
{
|
|
977
1027
|
context: toolCall2?.args,
|
|
@@ -980,14 +1030,17 @@ var Agent = class extends BaseResource {
|
|
|
980
1030
|
threadId: processedParams.threadId,
|
|
981
1031
|
runtimeContext: processedParams.runtimeContext,
|
|
982
1032
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
983
|
-
tracingContext: { currentSpan: void 0 }
|
|
1033
|
+
tracingContext: { currentSpan: void 0 },
|
|
1034
|
+
suspend: async () => {
|
|
1035
|
+
}
|
|
984
1036
|
},
|
|
985
1037
|
{
|
|
986
1038
|
messages: response.messages,
|
|
987
1039
|
toolCallId: toolCall2?.toolCallId
|
|
988
1040
|
}
|
|
989
1041
|
);
|
|
990
|
-
const
|
|
1042
|
+
const lastMessageRaw = messages[messages.length - 1];
|
|
1043
|
+
const lastMessage = lastMessageRaw != null ? JSON.parse(JSON.stringify(lastMessageRaw)) : void 0;
|
|
991
1044
|
const toolInvocationPart = lastMessage?.parts?.find(
|
|
992
1045
|
(part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall2.toolCallId
|
|
993
1046
|
);
|
|
@@ -1005,25 +1058,11 @@ var Agent = class extends BaseResource {
|
|
|
1005
1058
|
toolInvocation.state = "result";
|
|
1006
1059
|
toolInvocation.result = result;
|
|
1007
1060
|
}
|
|
1008
|
-
const
|
|
1009
|
-
try {
|
|
1010
|
-
await writer.write(
|
|
1011
|
-
new TextEncoder().encode(
|
|
1012
|
-
"a:" + JSON.stringify({
|
|
1013
|
-
toolCallId: toolCall2.toolCallId,
|
|
1014
|
-
result
|
|
1015
|
-
}) + "\n"
|
|
1016
|
-
)
|
|
1017
|
-
);
|
|
1018
|
-
} finally {
|
|
1019
|
-
writer.releaseLock();
|
|
1020
|
-
}
|
|
1021
|
-
const originalMessages = processedParams.messages;
|
|
1022
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1061
|
+
const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
|
|
1023
1062
|
this.processStreamResponse_vNext(
|
|
1024
1063
|
{
|
|
1025
1064
|
...processedParams,
|
|
1026
|
-
messages:
|
|
1065
|
+
messages: updatedMessages
|
|
1027
1066
|
},
|
|
1028
1067
|
writable
|
|
1029
1068
|
).catch((error) => {
|
|
@@ -1031,6 +1070,11 @@ var Agent = class extends BaseResource {
|
|
|
1031
1070
|
});
|
|
1032
1071
|
}
|
|
1033
1072
|
}
|
|
1073
|
+
if (!shouldExecuteClientTool) {
|
|
1074
|
+
setTimeout(() => {
|
|
1075
|
+
writable.close();
|
|
1076
|
+
}, 0);
|
|
1077
|
+
}
|
|
1034
1078
|
} else {
|
|
1035
1079
|
setTimeout(() => {
|
|
1036
1080
|
writable.close();
|
|
@@ -1046,12 +1090,49 @@ var Agent = class extends BaseResource {
|
|
|
1046
1090
|
}
|
|
1047
1091
|
return response;
|
|
1048
1092
|
}
|
|
1049
|
-
async
|
|
1093
|
+
async network(params) {
|
|
1094
|
+
const response = await this.request(`/api/agents/${this.agentId}/network`, {
|
|
1095
|
+
method: "POST",
|
|
1096
|
+
body: params,
|
|
1097
|
+
stream: true
|
|
1098
|
+
});
|
|
1099
|
+
if (!response.body) {
|
|
1100
|
+
throw new Error("No response body");
|
|
1101
|
+
}
|
|
1102
|
+
const streamResponse = new Response(response.body, {
|
|
1103
|
+
status: response.status,
|
|
1104
|
+
statusText: response.statusText,
|
|
1105
|
+
headers: response.headers
|
|
1106
|
+
});
|
|
1107
|
+
streamResponse.processDataStream = async ({
|
|
1108
|
+
onChunk
|
|
1109
|
+
}) => {
|
|
1110
|
+
await processMastraNetworkStream({
|
|
1111
|
+
stream: streamResponse.body,
|
|
1112
|
+
onChunk
|
|
1113
|
+
});
|
|
1114
|
+
};
|
|
1115
|
+
return streamResponse;
|
|
1116
|
+
}
|
|
1117
|
+
async stream(messagesOrParams, options) {
|
|
1118
|
+
let params;
|
|
1119
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
1120
|
+
params = messagesOrParams;
|
|
1121
|
+
} else {
|
|
1122
|
+
params = {
|
|
1123
|
+
messages: messagesOrParams,
|
|
1124
|
+
...options
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1050
1127
|
const processedParams = {
|
|
1051
1128
|
...params,
|
|
1052
1129
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
1053
1130
|
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
1054
|
-
clientTools: processClientTools(params.clientTools)
|
|
1131
|
+
clientTools: processClientTools(params.clientTools),
|
|
1132
|
+
structuredOutput: params.structuredOutput ? {
|
|
1133
|
+
...params.structuredOutput,
|
|
1134
|
+
schema: zodToJsonSchema(params.structuredOutput.schema)
|
|
1135
|
+
} : void 0
|
|
1055
1136
|
};
|
|
1056
1137
|
const { readable, writable } = new TransformStream();
|
|
1057
1138
|
const response = await this.processStreamResponse_vNext(processedParams, writable);
|
|
@@ -1118,7 +1199,9 @@ var Agent = class extends BaseResource {
|
|
|
1118
1199
|
threadId: processedParams.threadId,
|
|
1119
1200
|
runtimeContext: processedParams.runtimeContext,
|
|
1120
1201
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1121
|
-
tracingContext: { currentSpan: void 0 }
|
|
1202
|
+
tracingContext: { currentSpan: void 0 },
|
|
1203
|
+
suspend: async () => {
|
|
1204
|
+
}
|
|
1122
1205
|
},
|
|
1123
1206
|
{
|
|
1124
1207
|
messages: response.messages,
|
|
@@ -1156,12 +1239,10 @@ var Agent = class extends BaseResource {
|
|
|
1156
1239
|
} finally {
|
|
1157
1240
|
writer.releaseLock();
|
|
1158
1241
|
}
|
|
1159
|
-
const originalMessages = processedParams.messages;
|
|
1160
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1161
1242
|
this.processStreamResponse(
|
|
1162
1243
|
{
|
|
1163
1244
|
...processedParams,
|
|
1164
|
-
messages: [...
|
|
1245
|
+
messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
1165
1246
|
},
|
|
1166
1247
|
writable
|
|
1167
1248
|
).catch((error) => {
|
|
@@ -1187,10 +1268,11 @@ var Agent = class extends BaseResource {
|
|
|
1187
1268
|
/**
|
|
1188
1269
|
* Gets details about a specific tool available to the agent
|
|
1189
1270
|
* @param toolId - ID of the tool to retrieve
|
|
1271
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1190
1272
|
* @returns Promise containing tool details
|
|
1191
1273
|
*/
|
|
1192
|
-
getTool(toolId) {
|
|
1193
|
-
return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
|
|
1274
|
+
getTool(toolId, runtimeContext) {
|
|
1275
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1194
1276
|
}
|
|
1195
1277
|
/**
|
|
1196
1278
|
* Executes a tool for the agent
|
|
@@ -1201,7 +1283,7 @@ var Agent = class extends BaseResource {
|
|
|
1201
1283
|
executeTool(toolId, params) {
|
|
1202
1284
|
const body = {
|
|
1203
1285
|
data: params.data,
|
|
1204
|
-
runtimeContext:
|
|
1286
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1205
1287
|
};
|
|
1206
1288
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
1207
1289
|
method: "POST",
|
|
@@ -1210,17 +1292,19 @@ var Agent = class extends BaseResource {
|
|
|
1210
1292
|
}
|
|
1211
1293
|
/**
|
|
1212
1294
|
* Retrieves evaluation results for the agent
|
|
1295
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1213
1296
|
* @returns Promise containing agent evaluations
|
|
1214
1297
|
*/
|
|
1215
|
-
evals() {
|
|
1216
|
-
return this.request(`/api/agents/${this.agentId}/evals/ci`);
|
|
1298
|
+
evals(runtimeContext) {
|
|
1299
|
+
return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
|
|
1217
1300
|
}
|
|
1218
1301
|
/**
|
|
1219
1302
|
* Retrieves live evaluation results for the agent
|
|
1303
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1220
1304
|
* @returns Promise containing live agent evaluations
|
|
1221
1305
|
*/
|
|
1222
|
-
liveEvals() {
|
|
1223
|
-
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
1306
|
+
liveEvals(runtimeContext) {
|
|
1307
|
+
return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
|
|
1224
1308
|
}
|
|
1225
1309
|
/**
|
|
1226
1310
|
* Updates the model for the agent
|
|
@@ -1233,61 +1317,33 @@ var Agent = class extends BaseResource {
|
|
|
1233
1317
|
body: params
|
|
1234
1318
|
});
|
|
1235
1319
|
}
|
|
1236
|
-
};
|
|
1237
|
-
var Network = class extends BaseResource {
|
|
1238
|
-
constructor(options, networkId) {
|
|
1239
|
-
super(options);
|
|
1240
|
-
this.networkId = networkId;
|
|
1241
|
-
}
|
|
1242
1320
|
/**
|
|
1243
|
-
*
|
|
1244
|
-
* @
|
|
1245
|
-
|
|
1246
|
-
details() {
|
|
1247
|
-
return this.request(`/api/networks/${this.networkId}`);
|
|
1248
|
-
}
|
|
1249
|
-
/**
|
|
1250
|
-
* Generates a response from the agent
|
|
1251
|
-
* @param params - Generation parameters including prompt
|
|
1252
|
-
* @returns Promise containing the generated response
|
|
1321
|
+
* Updates the model for the agent in the model list
|
|
1322
|
+
* @param params - Parameters for updating the model
|
|
1323
|
+
* @returns Promise containing the updated model
|
|
1253
1324
|
*/
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
...params,
|
|
1257
|
-
output: zodToJsonSchema(params.output),
|
|
1258
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1259
|
-
};
|
|
1260
|
-
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
1325
|
+
updateModelInModelList({ modelConfigId, ...params }) {
|
|
1326
|
+
return this.request(`/api/agents/${this.agentId}/models/${modelConfigId}`, {
|
|
1261
1327
|
method: "POST",
|
|
1262
|
-
body:
|
|
1328
|
+
body: params
|
|
1263
1329
|
});
|
|
1264
1330
|
}
|
|
1265
1331
|
/**
|
|
1266
|
-
*
|
|
1267
|
-
* @param params -
|
|
1268
|
-
* @returns Promise containing the
|
|
1332
|
+
* Reorders the models for the agent
|
|
1333
|
+
* @param params - Parameters for reordering the model list
|
|
1334
|
+
* @returns Promise containing the updated model list
|
|
1269
1335
|
*/
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
...params,
|
|
1273
|
-
output: zodToJsonSchema(params.output),
|
|
1274
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1275
|
-
};
|
|
1276
|
-
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
1336
|
+
reorderModelList(params) {
|
|
1337
|
+
return this.request(`/api/agents/${this.agentId}/models/reorder`, {
|
|
1277
1338
|
method: "POST",
|
|
1278
|
-
body:
|
|
1279
|
-
stream: true
|
|
1339
|
+
body: params
|
|
1280
1340
|
});
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
...options
|
|
1288
|
-
});
|
|
1289
|
-
};
|
|
1290
|
-
return response;
|
|
1341
|
+
}
|
|
1342
|
+
async generateVNext(_messagesOrParams, _options) {
|
|
1343
|
+
throw new Error("generateVNext has been renamed to generate. Please use generate instead.");
|
|
1344
|
+
}
|
|
1345
|
+
async streamVNext(_messagesOrParams, _options) {
|
|
1346
|
+
throw new Error("streamVNext has been renamed to stream. Please use stream instead.");
|
|
1291
1347
|
}
|
|
1292
1348
|
};
|
|
1293
1349
|
|
|
@@ -1378,10 +1434,13 @@ var Vector = class extends BaseResource {
|
|
|
1378
1434
|
/**
|
|
1379
1435
|
* Retrieves details about a specific vector index
|
|
1380
1436
|
* @param indexName - Name of the index to get details for
|
|
1437
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1381
1438
|
* @returns Promise containing vector index details
|
|
1382
1439
|
*/
|
|
1383
|
-
details(indexName) {
|
|
1384
|
-
return this.request(
|
|
1440
|
+
details(indexName, runtimeContext) {
|
|
1441
|
+
return this.request(
|
|
1442
|
+
`/api/vector/${this.vectorName}/indexes/${indexName}${runtimeContextQueryString(runtimeContext)}`
|
|
1443
|
+
);
|
|
1385
1444
|
}
|
|
1386
1445
|
/**
|
|
1387
1446
|
* Deletes a vector index
|
|
@@ -1395,10 +1454,11 @@ var Vector = class extends BaseResource {
|
|
|
1395
1454
|
}
|
|
1396
1455
|
/**
|
|
1397
1456
|
* Retrieves a list of all available indexes
|
|
1457
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1398
1458
|
* @returns Promise containing array of index names
|
|
1399
1459
|
*/
|
|
1400
|
-
getIndexes() {
|
|
1401
|
-
return this.request(`/api/vector/${this.vectorName}/indexes`);
|
|
1460
|
+
getIndexes(runtimeContext) {
|
|
1461
|
+
return this.request(`/api/vector/${this.vectorName}/indexes${runtimeContextQueryString(runtimeContext)}`);
|
|
1402
1462
|
}
|
|
1403
1463
|
/**
|
|
1404
1464
|
* Creates a new vector index
|
|
@@ -1435,123 +1495,50 @@ var Vector = class extends BaseResource {
|
|
|
1435
1495
|
}
|
|
1436
1496
|
};
|
|
1437
1497
|
|
|
1438
|
-
// src/resources/
|
|
1439
|
-
var
|
|
1440
|
-
|
|
1441
|
-
constructor(options, workflowId) {
|
|
1498
|
+
// src/resources/tool.ts
|
|
1499
|
+
var Tool = class extends BaseResource {
|
|
1500
|
+
constructor(options, toolId) {
|
|
1442
1501
|
super(options);
|
|
1443
|
-
this.
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Retrieves details about the legacy workflow
|
|
1447
|
-
* @returns Promise containing legacy workflow details including steps and graphs
|
|
1448
|
-
*/
|
|
1449
|
-
details() {
|
|
1450
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
* Retrieves all runs for a legacy workflow
|
|
1454
|
-
* @param params - Parameters for filtering runs
|
|
1455
|
-
* @returns Promise containing legacy workflow runs array
|
|
1456
|
-
*/
|
|
1457
|
-
runs(params) {
|
|
1458
|
-
const searchParams = new URLSearchParams();
|
|
1459
|
-
if (params?.fromDate) {
|
|
1460
|
-
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1461
|
-
}
|
|
1462
|
-
if (params?.toDate) {
|
|
1463
|
-
searchParams.set("toDate", params.toDate.toISOString());
|
|
1464
|
-
}
|
|
1465
|
-
if (params?.limit) {
|
|
1466
|
-
searchParams.set("limit", String(params.limit));
|
|
1467
|
-
}
|
|
1468
|
-
if (params?.offset) {
|
|
1469
|
-
searchParams.set("offset", String(params.offset));
|
|
1470
|
-
}
|
|
1471
|
-
if (params?.resourceId) {
|
|
1472
|
-
searchParams.set("resourceId", params.resourceId);
|
|
1473
|
-
}
|
|
1474
|
-
if (searchParams.size) {
|
|
1475
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
1476
|
-
} else {
|
|
1477
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
/**
|
|
1481
|
-
* Creates a new legacy workflow run
|
|
1482
|
-
* @returns Promise containing the generated run ID
|
|
1483
|
-
*/
|
|
1484
|
-
createRun(params) {
|
|
1485
|
-
const searchParams = new URLSearchParams();
|
|
1486
|
-
if (!!params?.runId) {
|
|
1487
|
-
searchParams.set("runId", params.runId);
|
|
1488
|
-
}
|
|
1489
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
1490
|
-
method: "POST"
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
1495
|
-
* @param params - Object containing the runId and triggerData
|
|
1496
|
-
* @returns Promise containing success message
|
|
1497
|
-
*/
|
|
1498
|
-
start(params) {
|
|
1499
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1500
|
-
method: "POST",
|
|
1501
|
-
body: params?.triggerData
|
|
1502
|
-
});
|
|
1502
|
+
this.toolId = toolId;
|
|
1503
1503
|
}
|
|
1504
1504
|
/**
|
|
1505
|
-
*
|
|
1506
|
-
* @param
|
|
1507
|
-
* @
|
|
1508
|
-
* @param context - Context to resume the legacy workflow with
|
|
1509
|
-
* @returns Promise containing the legacy workflow resume results
|
|
1505
|
+
* Retrieves details about the tool
|
|
1506
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1507
|
+
* @returns Promise containing tool details including description and schemas
|
|
1510
1508
|
*/
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
runId,
|
|
1514
|
-
context
|
|
1515
|
-
}) {
|
|
1516
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
1517
|
-
method: "POST",
|
|
1518
|
-
body: {
|
|
1519
|
-
stepId,
|
|
1520
|
-
context
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1509
|
+
details(runtimeContext) {
|
|
1510
|
+
return this.request(`/api/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1523
1511
|
}
|
|
1524
1512
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
* @param params -
|
|
1527
|
-
* @returns Promise containing the
|
|
1513
|
+
* Executes the tool with the provided parameters
|
|
1514
|
+
* @param params - Parameters required for tool execution
|
|
1515
|
+
* @returns Promise containing the tool execution results
|
|
1528
1516
|
*/
|
|
1529
|
-
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1517
|
+
execute(params) {
|
|
1518
|
+
const url = new URLSearchParams();
|
|
1519
|
+
if (params.runId) {
|
|
1520
|
+
url.set("runId", params.runId);
|
|
1533
1521
|
}
|
|
1534
|
-
|
|
1522
|
+
const body = {
|
|
1523
|
+
data: params.data,
|
|
1524
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1525
|
+
};
|
|
1526
|
+
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
1535
1527
|
method: "POST",
|
|
1536
|
-
body
|
|
1528
|
+
body
|
|
1537
1529
|
});
|
|
1538
1530
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
body: {
|
|
1548
|
-
stepId: params.stepId,
|
|
1549
|
-
context: params.context
|
|
1550
|
-
}
|
|
1551
|
-
});
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
// src/resources/workflow.ts
|
|
1534
|
+
var RECORD_SEPARATOR = "";
|
|
1535
|
+
var Workflow = class extends BaseResource {
|
|
1536
|
+
constructor(options, workflowId) {
|
|
1537
|
+
super(options);
|
|
1538
|
+
this.workflowId = workflowId;
|
|
1552
1539
|
}
|
|
1553
1540
|
/**
|
|
1554
|
-
* Creates an async generator that processes a readable stream and yields records
|
|
1541
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
1555
1542
|
* separated by the Record Separator character (\x1E)
|
|
1556
1543
|
*
|
|
1557
1544
|
* @param stream - The readable stream to process
|
|
@@ -1596,128 +1583,24 @@ var LegacyWorkflow = class extends BaseResource {
|
|
|
1596
1583
|
}
|
|
1597
1584
|
}
|
|
1598
1585
|
/**
|
|
1599
|
-
*
|
|
1600
|
-
* @param
|
|
1601
|
-
* @returns
|
|
1602
|
-
*/
|
|
1603
|
-
async watch({ runId }, onRecord) {
|
|
1604
|
-
const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
|
|
1605
|
-
stream: true
|
|
1606
|
-
});
|
|
1607
|
-
if (!response.ok) {
|
|
1608
|
-
throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
|
|
1609
|
-
}
|
|
1610
|
-
if (!response.body) {
|
|
1611
|
-
throw new Error("Response body is null");
|
|
1612
|
-
}
|
|
1613
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
1614
|
-
onRecord(record);
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
};
|
|
1618
|
-
|
|
1619
|
-
// src/resources/tool.ts
|
|
1620
|
-
var Tool = class extends BaseResource {
|
|
1621
|
-
constructor(options, toolId) {
|
|
1622
|
-
super(options);
|
|
1623
|
-
this.toolId = toolId;
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
* Retrieves details about the tool
|
|
1627
|
-
* @returns Promise containing tool details including description and schemas
|
|
1586
|
+
* Retrieves details about the workflow
|
|
1587
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1588
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
1628
1589
|
*/
|
|
1629
|
-
details() {
|
|
1630
|
-
return this.request(`/api/
|
|
1590
|
+
details(runtimeContext) {
|
|
1591
|
+
return this.request(`/api/workflows/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1631
1592
|
}
|
|
1632
1593
|
/**
|
|
1633
|
-
*
|
|
1634
|
-
* @param params - Parameters
|
|
1635
|
-
* @
|
|
1594
|
+
* Retrieves all runs for a workflow
|
|
1595
|
+
* @param params - Parameters for filtering runs
|
|
1596
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1597
|
+
* @returns Promise containing workflow runs array
|
|
1636
1598
|
*/
|
|
1637
|
-
|
|
1638
|
-
const
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
const body = {
|
|
1643
|
-
data: params.data,
|
|
1644
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1645
|
-
};
|
|
1646
|
-
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
1647
|
-
method: "POST",
|
|
1648
|
-
body
|
|
1649
|
-
});
|
|
1650
|
-
}
|
|
1651
|
-
};
|
|
1652
|
-
|
|
1653
|
-
// src/resources/workflow.ts
|
|
1654
|
-
var RECORD_SEPARATOR2 = "";
|
|
1655
|
-
var Workflow = class extends BaseResource {
|
|
1656
|
-
constructor(options, workflowId) {
|
|
1657
|
-
super(options);
|
|
1658
|
-
this.workflowId = workflowId;
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* Creates an async generator that processes a readable stream and yields workflow records
|
|
1662
|
-
* separated by the Record Separator character (\x1E)
|
|
1663
|
-
*
|
|
1664
|
-
* @param stream - The readable stream to process
|
|
1665
|
-
* @returns An async generator that yields parsed records
|
|
1666
|
-
*/
|
|
1667
|
-
async *streamProcessor(stream) {
|
|
1668
|
-
const reader = stream.getReader();
|
|
1669
|
-
let doneReading = false;
|
|
1670
|
-
let buffer = "";
|
|
1671
|
-
try {
|
|
1672
|
-
while (!doneReading) {
|
|
1673
|
-
const { done, value } = await reader.read();
|
|
1674
|
-
doneReading = done;
|
|
1675
|
-
if (done && !value) continue;
|
|
1676
|
-
try {
|
|
1677
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
1678
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
1679
|
-
buffer = chunks.pop() || "";
|
|
1680
|
-
for (const chunk of chunks) {
|
|
1681
|
-
if (chunk) {
|
|
1682
|
-
if (typeof chunk === "string") {
|
|
1683
|
-
try {
|
|
1684
|
-
const parsedChunk = JSON.parse(chunk);
|
|
1685
|
-
yield parsedChunk;
|
|
1686
|
-
} catch {
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
} catch {
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
if (buffer) {
|
|
1695
|
-
try {
|
|
1696
|
-
yield JSON.parse(buffer);
|
|
1697
|
-
} catch {
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
} finally {
|
|
1701
|
-
reader.cancel().catch(() => {
|
|
1702
|
-
});
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Retrieves details about the workflow
|
|
1707
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
1708
|
-
*/
|
|
1709
|
-
details() {
|
|
1710
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
1711
|
-
}
|
|
1712
|
-
/**
|
|
1713
|
-
* Retrieves all runs for a workflow
|
|
1714
|
-
* @param params - Parameters for filtering runs
|
|
1715
|
-
* @returns Promise containing workflow runs array
|
|
1716
|
-
*/
|
|
1717
|
-
runs(params) {
|
|
1718
|
-
const searchParams = new URLSearchParams();
|
|
1719
|
-
if (params?.fromDate) {
|
|
1720
|
-
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1599
|
+
runs(params, runtimeContext) {
|
|
1600
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1601
|
+
const searchParams = new URLSearchParams();
|
|
1602
|
+
if (params?.fromDate) {
|
|
1603
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1721
1604
|
}
|
|
1722
1605
|
if (params?.toDate) {
|
|
1723
1606
|
searchParams.set("toDate", params.toDate.toISOString());
|
|
@@ -1731,6 +1614,9 @@ var Workflow = class extends BaseResource {
|
|
|
1731
1614
|
if (params?.resourceId) {
|
|
1732
1615
|
searchParams.set("resourceId", params.resourceId);
|
|
1733
1616
|
}
|
|
1617
|
+
if (runtimeContextParam) {
|
|
1618
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1619
|
+
}
|
|
1734
1620
|
if (searchParams.size) {
|
|
1735
1621
|
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
1736
1622
|
} else {
|
|
@@ -1740,18 +1626,22 @@ var Workflow = class extends BaseResource {
|
|
|
1740
1626
|
/**
|
|
1741
1627
|
* Retrieves a specific workflow run by its ID
|
|
1742
1628
|
* @param runId - The ID of the workflow run to retrieve
|
|
1629
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1743
1630
|
* @returns Promise containing the workflow run details
|
|
1744
1631
|
*/
|
|
1745
|
-
runById(runId) {
|
|
1746
|
-
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
|
|
1632
|
+
runById(runId, runtimeContext) {
|
|
1633
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1747
1634
|
}
|
|
1748
1635
|
/**
|
|
1749
1636
|
* Retrieves the execution result for a specific workflow run by its ID
|
|
1750
1637
|
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
1638
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1751
1639
|
* @returns Promise containing the workflow run execution result
|
|
1752
1640
|
*/
|
|
1753
|
-
runExecutionResult(runId) {
|
|
1754
|
-
return this.request(
|
|
1641
|
+
runExecutionResult(runId, runtimeContext) {
|
|
1642
|
+
return this.request(
|
|
1643
|
+
`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${runtimeContextQueryString(runtimeContext)}`
|
|
1644
|
+
);
|
|
1755
1645
|
}
|
|
1756
1646
|
/**
|
|
1757
1647
|
* Cancels a specific workflow run by its ID
|
|
@@ -1774,27 +1664,83 @@ var Workflow = class extends BaseResource {
|
|
|
1774
1664
|
body: { event: params.event, data: params.data }
|
|
1775
1665
|
});
|
|
1776
1666
|
}
|
|
1667
|
+
/**
|
|
1668
|
+
* @deprecated Use createRunAsync() instead.
|
|
1669
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
1670
|
+
*/
|
|
1671
|
+
async createRun(_params) {
|
|
1672
|
+
throw new Error(
|
|
1673
|
+
"createRun() has been deprecated. Please use createRunAsync() instead.\n\nMigration guide:\n Before: const run = workflow.createRun();\n After: const run = await workflow.createRunAsync();\n\nNote: createRunAsync() is an async method, so make sure your calling function is async."
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1777
1676
|
/**
|
|
1778
1677
|
* Creates a new workflow run
|
|
1779
1678
|
* @param params - Optional object containing the optional runId
|
|
1780
|
-
* @returns Promise containing the runId of the created run
|
|
1679
|
+
* @returns Promise containing the runId of the created run with methods to control execution
|
|
1781
1680
|
*/
|
|
1782
|
-
|
|
1681
|
+
async createRunAsync(params) {
|
|
1783
1682
|
const searchParams = new URLSearchParams();
|
|
1784
1683
|
if (!!params?.runId) {
|
|
1785
1684
|
searchParams.set("runId", params.runId);
|
|
1786
1685
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1686
|
+
const res = await this.request(
|
|
1687
|
+
`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`,
|
|
1688
|
+
{
|
|
1689
|
+
method: "POST"
|
|
1690
|
+
}
|
|
1691
|
+
);
|
|
1692
|
+
const runId = res.runId;
|
|
1693
|
+
return {
|
|
1694
|
+
runId,
|
|
1695
|
+
start: async (p) => {
|
|
1696
|
+
return this.start({
|
|
1697
|
+
runId,
|
|
1698
|
+
inputData: p.inputData,
|
|
1699
|
+
runtimeContext: p.runtimeContext,
|
|
1700
|
+
tracingOptions: p.tracingOptions
|
|
1701
|
+
});
|
|
1702
|
+
},
|
|
1703
|
+
startAsync: async (p) => {
|
|
1704
|
+
return this.startAsync({
|
|
1705
|
+
runId,
|
|
1706
|
+
inputData: p.inputData,
|
|
1707
|
+
runtimeContext: p.runtimeContext,
|
|
1708
|
+
tracingOptions: p.tracingOptions
|
|
1709
|
+
});
|
|
1710
|
+
},
|
|
1711
|
+
watch: async (onRecord) => {
|
|
1712
|
+
return this.watch({ runId }, onRecord);
|
|
1713
|
+
},
|
|
1714
|
+
stream: async (p) => {
|
|
1715
|
+
return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1716
|
+
},
|
|
1717
|
+
resume: async (p) => {
|
|
1718
|
+
return this.resume({
|
|
1719
|
+
runId,
|
|
1720
|
+
step: p.step,
|
|
1721
|
+
resumeData: p.resumeData,
|
|
1722
|
+
runtimeContext: p.runtimeContext,
|
|
1723
|
+
tracingOptions: p.tracingOptions
|
|
1724
|
+
});
|
|
1725
|
+
},
|
|
1726
|
+
resumeAsync: async (p) => {
|
|
1727
|
+
return this.resumeAsync({
|
|
1728
|
+
runId,
|
|
1729
|
+
step: p.step,
|
|
1730
|
+
resumeData: p.resumeData,
|
|
1731
|
+
runtimeContext: p.runtimeContext,
|
|
1732
|
+
tracingOptions: p.tracingOptions
|
|
1733
|
+
});
|
|
1734
|
+
},
|
|
1735
|
+
resumeStreamVNext: async (p) => {
|
|
1736
|
+
return this.resumeStreamVNext({
|
|
1737
|
+
runId,
|
|
1738
|
+
step: p.step,
|
|
1739
|
+
resumeData: p.resumeData,
|
|
1740
|
+
runtimeContext: p.runtimeContext
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1798
1744
|
}
|
|
1799
1745
|
/**
|
|
1800
1746
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
@@ -1805,7 +1751,7 @@ var Workflow = class extends BaseResource {
|
|
|
1805
1751
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1806
1752
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1807
1753
|
method: "POST",
|
|
1808
|
-
body: { inputData: params?.inputData, runtimeContext }
|
|
1754
|
+
body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1809
1755
|
});
|
|
1810
1756
|
}
|
|
1811
1757
|
/**
|
|
@@ -1817,16 +1763,17 @@ var Workflow = class extends BaseResource {
|
|
|
1817
1763
|
step,
|
|
1818
1764
|
runId,
|
|
1819
1765
|
resumeData,
|
|
1766
|
+
tracingOptions,
|
|
1820
1767
|
...rest
|
|
1821
1768
|
}) {
|
|
1822
1769
|
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
1823
1770
|
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
1824
1771
|
method: "POST",
|
|
1825
|
-
stream: true,
|
|
1826
1772
|
body: {
|
|
1827
1773
|
step,
|
|
1828
1774
|
resumeData,
|
|
1829
|
-
runtimeContext
|
|
1775
|
+
runtimeContext,
|
|
1776
|
+
tracingOptions
|
|
1830
1777
|
}
|
|
1831
1778
|
});
|
|
1832
1779
|
}
|
|
@@ -1843,7 +1790,7 @@ var Workflow = class extends BaseResource {
|
|
|
1843
1790
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1844
1791
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1845
1792
|
method: "POST",
|
|
1846
|
-
body: { inputData: params.inputData, runtimeContext }
|
|
1793
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1847
1794
|
});
|
|
1848
1795
|
}
|
|
1849
1796
|
/**
|
|
@@ -1861,7 +1808,110 @@ var Workflow = class extends BaseResource {
|
|
|
1861
1808
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1862
1809
|
{
|
|
1863
1810
|
method: "POST",
|
|
1864
|
-
body: { inputData: params.inputData, runtimeContext },
|
|
1811
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
|
|
1812
|
+
stream: true
|
|
1813
|
+
}
|
|
1814
|
+
);
|
|
1815
|
+
if (!response.ok) {
|
|
1816
|
+
throw new Error(`Failed to stream workflow: ${response.statusText}`);
|
|
1817
|
+
}
|
|
1818
|
+
if (!response.body) {
|
|
1819
|
+
throw new Error("Response body is null");
|
|
1820
|
+
}
|
|
1821
|
+
let failedChunk = void 0;
|
|
1822
|
+
const transformStream = new TransformStream({
|
|
1823
|
+
start() {
|
|
1824
|
+
},
|
|
1825
|
+
async transform(chunk, controller) {
|
|
1826
|
+
try {
|
|
1827
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1828
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1829
|
+
for (const chunk2 of chunks) {
|
|
1830
|
+
if (chunk2) {
|
|
1831
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1832
|
+
try {
|
|
1833
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1834
|
+
controller.enqueue(parsedChunk);
|
|
1835
|
+
failedChunk = void 0;
|
|
1836
|
+
} catch {
|
|
1837
|
+
failedChunk = newChunk;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
} catch {
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
return response.body.pipeThrough(transformStream);
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Observes workflow stream for a workflow run
|
|
1849
|
+
* @param params - Object containing the runId
|
|
1850
|
+
* @returns Promise containing the workflow execution results
|
|
1851
|
+
*/
|
|
1852
|
+
async observeStream(params) {
|
|
1853
|
+
const searchParams = new URLSearchParams();
|
|
1854
|
+
searchParams.set("runId", params.runId);
|
|
1855
|
+
const response = await this.request(
|
|
1856
|
+
`/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
|
|
1857
|
+
{
|
|
1858
|
+
method: "POST",
|
|
1859
|
+
stream: true
|
|
1860
|
+
}
|
|
1861
|
+
);
|
|
1862
|
+
if (!response.ok) {
|
|
1863
|
+
throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
|
|
1864
|
+
}
|
|
1865
|
+
if (!response.body) {
|
|
1866
|
+
throw new Error("Response body is null");
|
|
1867
|
+
}
|
|
1868
|
+
let failedChunk = void 0;
|
|
1869
|
+
const transformStream = new TransformStream({
|
|
1870
|
+
start() {
|
|
1871
|
+
},
|
|
1872
|
+
async transform(chunk, controller) {
|
|
1873
|
+
try {
|
|
1874
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1875
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1876
|
+
for (const chunk2 of chunks) {
|
|
1877
|
+
if (chunk2) {
|
|
1878
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1879
|
+
try {
|
|
1880
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1881
|
+
controller.enqueue(parsedChunk);
|
|
1882
|
+
failedChunk = void 0;
|
|
1883
|
+
} catch {
|
|
1884
|
+
failedChunk = newChunk;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
} catch {
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
return response.body.pipeThrough(transformStream);
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Starts a workflow run and returns a stream
|
|
1896
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
1897
|
+
* @returns Promise containing the workflow execution results
|
|
1898
|
+
*/
|
|
1899
|
+
async streamVNext(params) {
|
|
1900
|
+
const searchParams = new URLSearchParams();
|
|
1901
|
+
if (!!params?.runId) {
|
|
1902
|
+
searchParams.set("runId", params.runId);
|
|
1903
|
+
}
|
|
1904
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1905
|
+
const response = await this.request(
|
|
1906
|
+
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
1907
|
+
{
|
|
1908
|
+
method: "POST",
|
|
1909
|
+
body: {
|
|
1910
|
+
inputData: params.inputData,
|
|
1911
|
+
runtimeContext,
|
|
1912
|
+
closeOnSuspend: params.closeOnSuspend,
|
|
1913
|
+
tracingOptions: params.tracingOptions
|
|
1914
|
+
},
|
|
1865
1915
|
stream: true
|
|
1866
1916
|
}
|
|
1867
1917
|
);
|
|
@@ -1878,7 +1928,54 @@ var Workflow = class extends BaseResource {
|
|
|
1878
1928
|
async transform(chunk, controller) {
|
|
1879
1929
|
try {
|
|
1880
1930
|
const decoded = new TextDecoder().decode(chunk);
|
|
1881
|
-
const chunks = decoded.split(
|
|
1931
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1932
|
+
for (const chunk2 of chunks) {
|
|
1933
|
+
if (chunk2) {
|
|
1934
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1935
|
+
try {
|
|
1936
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1937
|
+
controller.enqueue(parsedChunk);
|
|
1938
|
+
failedChunk = void 0;
|
|
1939
|
+
} catch {
|
|
1940
|
+
failedChunk = newChunk;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
} catch {
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
1948
|
+
return response.body.pipeThrough(transformStream);
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Observes workflow vNext stream for a workflow run
|
|
1952
|
+
* @param params - Object containing the runId
|
|
1953
|
+
* @returns Promise containing the workflow execution results
|
|
1954
|
+
*/
|
|
1955
|
+
async observeStreamVNext(params) {
|
|
1956
|
+
const searchParams = new URLSearchParams();
|
|
1957
|
+
searchParams.set("runId", params.runId);
|
|
1958
|
+
const response = await this.request(
|
|
1959
|
+
`/api/workflows/${this.workflowId}/observe-streamVNext?${searchParams.toString()}`,
|
|
1960
|
+
{
|
|
1961
|
+
method: "POST",
|
|
1962
|
+
stream: true
|
|
1963
|
+
}
|
|
1964
|
+
);
|
|
1965
|
+
if (!response.ok) {
|
|
1966
|
+
throw new Error(`Failed to observe stream vNext workflow: ${response.statusText}`);
|
|
1967
|
+
}
|
|
1968
|
+
if (!response.body) {
|
|
1969
|
+
throw new Error("Response body is null");
|
|
1970
|
+
}
|
|
1971
|
+
let failedChunk = void 0;
|
|
1972
|
+
const transformStream = new TransformStream({
|
|
1973
|
+
start() {
|
|
1974
|
+
},
|
|
1975
|
+
async transform(chunk, controller) {
|
|
1976
|
+
try {
|
|
1977
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1978
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1882
1979
|
for (const chunk2 of chunks) {
|
|
1883
1980
|
if (chunk2) {
|
|
1884
1981
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -1909,9 +2006,64 @@ var Workflow = class extends BaseResource {
|
|
|
1909
2006
|
body: {
|
|
1910
2007
|
step: params.step,
|
|
1911
2008
|
resumeData: params.resumeData,
|
|
1912
|
-
runtimeContext
|
|
2009
|
+
runtimeContext,
|
|
2010
|
+
tracingOptions: params.tracingOptions
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
|
|
2016
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
2017
|
+
* @returns Promise containing the workflow resume results
|
|
2018
|
+
*/
|
|
2019
|
+
async resumeStreamVNext(params) {
|
|
2020
|
+
const searchParams = new URLSearchParams();
|
|
2021
|
+
searchParams.set("runId", params.runId);
|
|
2022
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2023
|
+
const response = await this.request(
|
|
2024
|
+
`/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
|
|
2025
|
+
{
|
|
2026
|
+
method: "POST",
|
|
2027
|
+
body: {
|
|
2028
|
+
step: params.step,
|
|
2029
|
+
resumeData: params.resumeData,
|
|
2030
|
+
runtimeContext,
|
|
2031
|
+
tracingOptions: params.tracingOptions
|
|
2032
|
+
},
|
|
2033
|
+
stream: true
|
|
2034
|
+
}
|
|
2035
|
+
);
|
|
2036
|
+
if (!response.ok) {
|
|
2037
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
2038
|
+
}
|
|
2039
|
+
if (!response.body) {
|
|
2040
|
+
throw new Error("Response body is null");
|
|
2041
|
+
}
|
|
2042
|
+
let failedChunk = void 0;
|
|
2043
|
+
const transformStream = new TransformStream({
|
|
2044
|
+
start() {
|
|
2045
|
+
},
|
|
2046
|
+
async transform(chunk, controller) {
|
|
2047
|
+
try {
|
|
2048
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2049
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2050
|
+
for (const chunk2 of chunks) {
|
|
2051
|
+
if (chunk2) {
|
|
2052
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2053
|
+
try {
|
|
2054
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2055
|
+
controller.enqueue(parsedChunk);
|
|
2056
|
+
failedChunk = void 0;
|
|
2057
|
+
} catch {
|
|
2058
|
+
failedChunk = newChunk;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
} catch {
|
|
2063
|
+
}
|
|
1913
2064
|
}
|
|
1914
2065
|
});
|
|
2066
|
+
return response.body.pipeThrough(transformStream);
|
|
1915
2067
|
}
|
|
1916
2068
|
/**
|
|
1917
2069
|
* Watches workflow transitions in real-time
|
|
@@ -1949,7 +2101,7 @@ var Workflow = class extends BaseResource {
|
|
|
1949
2101
|
async start(controller) {
|
|
1950
2102
|
try {
|
|
1951
2103
|
for await (const record of records) {
|
|
1952
|
-
const json = JSON.stringify(record) +
|
|
2104
|
+
const json = JSON.stringify(record) + RECORD_SEPARATOR;
|
|
1953
2105
|
controller.enqueue(encoder.encode(json));
|
|
1954
2106
|
}
|
|
1955
2107
|
controller.close();
|
|
@@ -2047,10 +2199,11 @@ var MCPTool = class extends BaseResource {
|
|
|
2047
2199
|
}
|
|
2048
2200
|
/**
|
|
2049
2201
|
* Retrieves details about this specific tool from the MCP server.
|
|
2202
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2050
2203
|
* @returns Promise containing the tool's information (name, description, schema).
|
|
2051
2204
|
*/
|
|
2052
|
-
details() {
|
|
2053
|
-
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
|
|
2205
|
+
details(runtimeContext) {
|
|
2206
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2054
2207
|
}
|
|
2055
2208
|
/**
|
|
2056
2209
|
* Executes this specific tool on the MCP server.
|
|
@@ -2071,7 +2224,7 @@ var MCPTool = class extends BaseResource {
|
|
|
2071
2224
|
};
|
|
2072
2225
|
|
|
2073
2226
|
// src/resources/agent-builder.ts
|
|
2074
|
-
var
|
|
2227
|
+
var RECORD_SEPARATOR2 = "";
|
|
2075
2228
|
var AgentBuilder = class extends BaseResource {
|
|
2076
2229
|
constructor(options, actionId) {
|
|
2077
2230
|
super(options);
|
|
@@ -2106,11 +2259,20 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2106
2259
|
};
|
|
2107
2260
|
}
|
|
2108
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* @deprecated Use createRunAsync() instead.
|
|
2264
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
2265
|
+
*/
|
|
2266
|
+
async createRun(_params) {
|
|
2267
|
+
throw new Error(
|
|
2268
|
+
"createRun() has been deprecated. Please use createRunAsync() instead.\n\nMigration guide:\n Before: const run = agentBuilder.createRun();\n After: const run = await agentBuilder.createRunAsync();\n\nNote: createRunAsync() is an async method, so make sure your calling function is async."
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2109
2271
|
/**
|
|
2110
2272
|
* Creates a new agent builder action run and returns the runId.
|
|
2111
2273
|
* This calls `/api/agent-builder/:actionId/create-run`.
|
|
2112
2274
|
*/
|
|
2113
|
-
async
|
|
2275
|
+
async createRunAsync(params) {
|
|
2114
2276
|
const searchParams = new URLSearchParams();
|
|
2115
2277
|
if (!!params?.runId) {
|
|
2116
2278
|
searchParams.set("runId", params.runId);
|
|
@@ -2120,14 +2282,6 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2120
2282
|
method: "POST"
|
|
2121
2283
|
});
|
|
2122
2284
|
}
|
|
2123
|
-
/**
|
|
2124
|
-
* Creates a new workflow run (alias for createRun)
|
|
2125
|
-
* @param params - Optional object containing the optional runId
|
|
2126
|
-
* @returns Promise containing the runId of the created run
|
|
2127
|
-
*/
|
|
2128
|
-
createRunAsync(params) {
|
|
2129
|
-
return this.createRun(params);
|
|
2130
|
-
}
|
|
2131
2285
|
/**
|
|
2132
2286
|
* Starts agent builder action asynchronously and waits for completion.
|
|
2133
2287
|
* This calls `/api/agent-builder/:actionId/start-async`.
|
|
@@ -2210,7 +2364,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2210
2364
|
if (done && !value) continue;
|
|
2211
2365
|
try {
|
|
2212
2366
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2213
|
-
const chunks = (buffer + decoded).split(
|
|
2367
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
2214
2368
|
buffer = chunks.pop() || "";
|
|
2215
2369
|
for (const chunk of chunks) {
|
|
2216
2370
|
if (chunk) {
|
|
@@ -2267,7 +2421,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2267
2421
|
async transform(chunk, controller) {
|
|
2268
2422
|
try {
|
|
2269
2423
|
const decoded = new TextDecoder().decode(chunk);
|
|
2270
|
-
const chunks = decoded.split(
|
|
2424
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2271
2425
|
for (const chunk2 of chunks) {
|
|
2272
2426
|
if (chunk2) {
|
|
2273
2427
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2316,7 +2470,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2316
2470
|
async transform(chunk, controller) {
|
|
2317
2471
|
try {
|
|
2318
2472
|
const decoded = new TextDecoder().decode(chunk);
|
|
2319
|
-
const chunks = decoded.split(
|
|
2473
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2320
2474
|
for (const chunk2 of chunks) {
|
|
2321
2475
|
if (chunk2) {
|
|
2322
2476
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2487,6 +2641,31 @@ var Observability = class extends BaseResource {
|
|
|
2487
2641
|
const queryString = searchParams.toString();
|
|
2488
2642
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2489
2643
|
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Retrieves scores by trace ID and span ID
|
|
2646
|
+
* @param params - Parameters containing trace ID, span ID, and pagination options
|
|
2647
|
+
* @returns Promise containing scores and pagination info
|
|
2648
|
+
*/
|
|
2649
|
+
getScoresBySpan(params) {
|
|
2650
|
+
const { traceId, spanId, page, perPage } = params;
|
|
2651
|
+
const searchParams = new URLSearchParams();
|
|
2652
|
+
if (page !== void 0) {
|
|
2653
|
+
searchParams.set("page", String(page));
|
|
2654
|
+
}
|
|
2655
|
+
if (perPage !== void 0) {
|
|
2656
|
+
searchParams.set("perPage", String(perPage));
|
|
2657
|
+
}
|
|
2658
|
+
const queryString = searchParams.toString();
|
|
2659
|
+
return this.request(
|
|
2660
|
+
`/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
|
|
2661
|
+
);
|
|
2662
|
+
}
|
|
2663
|
+
score(params) {
|
|
2664
|
+
return this.request(`/api/observability/traces/score`, {
|
|
2665
|
+
method: "POST",
|
|
2666
|
+
body: { ...params }
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2490
2669
|
};
|
|
2491
2670
|
|
|
2492
2671
|
// src/resources/network-memory-thread.ts
|
|
@@ -2552,144 +2731,6 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2552
2731
|
}
|
|
2553
2732
|
};
|
|
2554
2733
|
|
|
2555
|
-
// src/resources/vNextNetwork.ts
|
|
2556
|
-
var RECORD_SEPARATOR4 = "";
|
|
2557
|
-
var VNextNetwork = class extends BaseResource {
|
|
2558
|
-
constructor(options, networkId) {
|
|
2559
|
-
super(options);
|
|
2560
|
-
this.networkId = networkId;
|
|
2561
|
-
}
|
|
2562
|
-
/**
|
|
2563
|
-
* Retrieves details about the network
|
|
2564
|
-
* @returns Promise containing vNext network details
|
|
2565
|
-
*/
|
|
2566
|
-
details() {
|
|
2567
|
-
return this.request(`/api/networks/v-next/${this.networkId}`);
|
|
2568
|
-
}
|
|
2569
|
-
/**
|
|
2570
|
-
* Generates a response from the v-next network
|
|
2571
|
-
* @param params - Generation parameters including message
|
|
2572
|
-
* @returns Promise containing the generated response
|
|
2573
|
-
*/
|
|
2574
|
-
generate(params) {
|
|
2575
|
-
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
2576
|
-
method: "POST",
|
|
2577
|
-
body: {
|
|
2578
|
-
...params,
|
|
2579
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2580
|
-
}
|
|
2581
|
-
});
|
|
2582
|
-
}
|
|
2583
|
-
/**
|
|
2584
|
-
* Generates a response from the v-next network using multiple primitives
|
|
2585
|
-
* @param params - Generation parameters including message
|
|
2586
|
-
* @returns Promise containing the generated response
|
|
2587
|
-
*/
|
|
2588
|
-
loop(params) {
|
|
2589
|
-
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
2590
|
-
method: "POST",
|
|
2591
|
-
body: {
|
|
2592
|
-
...params,
|
|
2593
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2594
|
-
}
|
|
2595
|
-
});
|
|
2596
|
-
}
|
|
2597
|
-
async *streamProcessor(stream) {
|
|
2598
|
-
const reader = stream.getReader();
|
|
2599
|
-
let doneReading = false;
|
|
2600
|
-
let buffer = "";
|
|
2601
|
-
try {
|
|
2602
|
-
while (!doneReading) {
|
|
2603
|
-
const { done, value } = await reader.read();
|
|
2604
|
-
doneReading = done;
|
|
2605
|
-
if (done && !value) continue;
|
|
2606
|
-
try {
|
|
2607
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2608
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
|
|
2609
|
-
buffer = chunks.pop() || "";
|
|
2610
|
-
for (const chunk of chunks) {
|
|
2611
|
-
if (chunk) {
|
|
2612
|
-
if (typeof chunk === "string") {
|
|
2613
|
-
try {
|
|
2614
|
-
const parsedChunk = JSON.parse(chunk);
|
|
2615
|
-
yield parsedChunk;
|
|
2616
|
-
} catch {
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
} catch {
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
if (buffer) {
|
|
2625
|
-
try {
|
|
2626
|
-
yield JSON.parse(buffer);
|
|
2627
|
-
} catch {
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
} finally {
|
|
2631
|
-
reader.cancel().catch(() => {
|
|
2632
|
-
});
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
/**
|
|
2636
|
-
* Streams a response from the v-next network
|
|
2637
|
-
* @param params - Stream parameters including message
|
|
2638
|
-
* @returns Promise containing the results
|
|
2639
|
-
*/
|
|
2640
|
-
async stream(params, onRecord) {
|
|
2641
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
2642
|
-
method: "POST",
|
|
2643
|
-
body: {
|
|
2644
|
-
...params,
|
|
2645
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2646
|
-
},
|
|
2647
|
-
stream: true
|
|
2648
|
-
});
|
|
2649
|
-
if (!response.ok) {
|
|
2650
|
-
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
2651
|
-
}
|
|
2652
|
-
if (!response.body) {
|
|
2653
|
-
throw new Error("Response body is null");
|
|
2654
|
-
}
|
|
2655
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2656
|
-
if (typeof record === "string") {
|
|
2657
|
-
onRecord(JSON.parse(record));
|
|
2658
|
-
} else {
|
|
2659
|
-
onRecord(record);
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
/**
|
|
2664
|
-
* Streams a response from the v-next network loop
|
|
2665
|
-
* @param params - Stream parameters including message
|
|
2666
|
-
* @returns Promise containing the results
|
|
2667
|
-
*/
|
|
2668
|
-
async loopStream(params, onRecord) {
|
|
2669
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
2670
|
-
method: "POST",
|
|
2671
|
-
body: {
|
|
2672
|
-
...params,
|
|
2673
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2674
|
-
},
|
|
2675
|
-
stream: true
|
|
2676
|
-
});
|
|
2677
|
-
if (!response.ok) {
|
|
2678
|
-
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
2679
|
-
}
|
|
2680
|
-
if (!response.body) {
|
|
2681
|
-
throw new Error("Response body is null");
|
|
2682
|
-
}
|
|
2683
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2684
|
-
if (typeof record === "string") {
|
|
2685
|
-
onRecord(JSON.parse(record));
|
|
2686
|
-
} else {
|
|
2687
|
-
onRecord(record);
|
|
2688
|
-
}
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
};
|
|
2692
|
-
|
|
2693
2734
|
// src/client.ts
|
|
2694
2735
|
var MastraClient = class extends BaseResource {
|
|
2695
2736
|
observability;
|
|
@@ -2699,10 +2740,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2699
2740
|
}
|
|
2700
2741
|
/**
|
|
2701
2742
|
* Retrieves all available agents
|
|
2743
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2702
2744
|
* @returns Promise containing map of agent IDs to agent details
|
|
2703
2745
|
*/
|
|
2704
|
-
getAgents() {
|
|
2705
|
-
|
|
2746
|
+
getAgents(runtimeContext) {
|
|
2747
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2748
|
+
const searchParams = new URLSearchParams();
|
|
2749
|
+
if (runtimeContextParam) {
|
|
2750
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2751
|
+
}
|
|
2752
|
+
const queryString = searchParams.toString();
|
|
2753
|
+
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2706
2754
|
}
|
|
2707
2755
|
/**
|
|
2708
2756
|
* Gets an agent instance by ID
|
|
@@ -2720,6 +2768,14 @@ var MastraClient = class extends BaseResource {
|
|
|
2720
2768
|
getMemoryThreads(params) {
|
|
2721
2769
|
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
2722
2770
|
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Retrieves memory config for a resource
|
|
2773
|
+
* @param params - Parameters containing the resource ID
|
|
2774
|
+
* @returns Promise containing array of memory threads
|
|
2775
|
+
*/
|
|
2776
|
+
getMemoryConfig(params) {
|
|
2777
|
+
return this.request(`/api/memory/config?agentId=${params.agentId}`);
|
|
2778
|
+
}
|
|
2723
2779
|
/**
|
|
2724
2780
|
* Creates a new memory thread
|
|
2725
2781
|
* @param params - Parameters for creating the memory thread
|
|
@@ -2736,6 +2792,24 @@ var MastraClient = class extends BaseResource {
|
|
|
2736
2792
|
getMemoryThread(threadId, agentId) {
|
|
2737
2793
|
return new MemoryThread(this.options, threadId, agentId);
|
|
2738
2794
|
}
|
|
2795
|
+
getThreadMessages(threadId, opts = {}) {
|
|
2796
|
+
let url = "";
|
|
2797
|
+
if (opts.agentId) {
|
|
2798
|
+
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
|
|
2799
|
+
} else if (opts.networkId) {
|
|
2800
|
+
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
|
|
2801
|
+
}
|
|
2802
|
+
return this.request(url);
|
|
2803
|
+
}
|
|
2804
|
+
deleteThread(threadId, opts = {}) {
|
|
2805
|
+
let url = "";
|
|
2806
|
+
if (opts.agentId) {
|
|
2807
|
+
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
|
|
2808
|
+
} else if (opts.networkId) {
|
|
2809
|
+
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
|
|
2810
|
+
}
|
|
2811
|
+
return this.request(url, { method: "DELETE" });
|
|
2812
|
+
}
|
|
2739
2813
|
/**
|
|
2740
2814
|
* Saves messages to memory
|
|
2741
2815
|
* @param params - Parameters containing messages to save
|
|
@@ -2798,10 +2872,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2798
2872
|
}
|
|
2799
2873
|
/**
|
|
2800
2874
|
* Retrieves all available tools
|
|
2875
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2801
2876
|
* @returns Promise containing map of tool IDs to tool details
|
|
2802
2877
|
*/
|
|
2803
|
-
getTools() {
|
|
2804
|
-
|
|
2878
|
+
getTools(runtimeContext) {
|
|
2879
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2880
|
+
const searchParams = new URLSearchParams();
|
|
2881
|
+
if (runtimeContextParam) {
|
|
2882
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2883
|
+
}
|
|
2884
|
+
const queryString = searchParams.toString();
|
|
2885
|
+
return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
|
|
2805
2886
|
}
|
|
2806
2887
|
/**
|
|
2807
2888
|
* Gets a tool instance by ID
|
|
@@ -2811,27 +2892,19 @@ var MastraClient = class extends BaseResource {
|
|
|
2811
2892
|
getTool(toolId) {
|
|
2812
2893
|
return new Tool(this.options, toolId);
|
|
2813
2894
|
}
|
|
2814
|
-
/**
|
|
2815
|
-
* Retrieves all available legacy workflows
|
|
2816
|
-
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
2817
|
-
*/
|
|
2818
|
-
getLegacyWorkflows() {
|
|
2819
|
-
return this.request("/api/workflows/legacy");
|
|
2820
|
-
}
|
|
2821
|
-
/**
|
|
2822
|
-
* Gets a legacy workflow instance by ID
|
|
2823
|
-
* @param workflowId - ID of the legacy workflow to retrieve
|
|
2824
|
-
* @returns Legacy Workflow instance
|
|
2825
|
-
*/
|
|
2826
|
-
getLegacyWorkflow(workflowId) {
|
|
2827
|
-
return new LegacyWorkflow(this.options, workflowId);
|
|
2828
|
-
}
|
|
2829
2895
|
/**
|
|
2830
2896
|
* Retrieves all available workflows
|
|
2897
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2831
2898
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
2832
2899
|
*/
|
|
2833
|
-
getWorkflows() {
|
|
2834
|
-
|
|
2900
|
+
getWorkflows(runtimeContext) {
|
|
2901
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2902
|
+
const searchParams = new URLSearchParams();
|
|
2903
|
+
if (runtimeContextParam) {
|
|
2904
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2905
|
+
}
|
|
2906
|
+
const queryString = searchParams.toString();
|
|
2907
|
+
return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
|
|
2835
2908
|
}
|
|
2836
2909
|
/**
|
|
2837
2910
|
* Gets a workflow instance by ID
|
|
@@ -2999,36 +3072,6 @@ var MastraClient = class extends BaseResource {
|
|
|
2999
3072
|
return this.request(`/api/telemetry`);
|
|
3000
3073
|
}
|
|
3001
3074
|
}
|
|
3002
|
-
/**
|
|
3003
|
-
* Retrieves all available networks
|
|
3004
|
-
* @returns Promise containing map of network IDs to network details
|
|
3005
|
-
*/
|
|
3006
|
-
getNetworks() {
|
|
3007
|
-
return this.request("/api/networks");
|
|
3008
|
-
}
|
|
3009
|
-
/**
|
|
3010
|
-
* Retrieves all available vNext networks
|
|
3011
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
3012
|
-
*/
|
|
3013
|
-
getVNextNetworks() {
|
|
3014
|
-
return this.request("/api/networks/v-next");
|
|
3015
|
-
}
|
|
3016
|
-
/**
|
|
3017
|
-
* Gets a network instance by ID
|
|
3018
|
-
* @param networkId - ID of the network to retrieve
|
|
3019
|
-
* @returns Network instance
|
|
3020
|
-
*/
|
|
3021
|
-
getNetwork(networkId) {
|
|
3022
|
-
return new Network(this.options, networkId);
|
|
3023
|
-
}
|
|
3024
|
-
/**
|
|
3025
|
-
* Gets a vNext network instance by ID
|
|
3026
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
3027
|
-
* @returns vNext Network instance
|
|
3028
|
-
*/
|
|
3029
|
-
getVNextNetwork(networkId) {
|
|
3030
|
-
return new VNextNetwork(this.options, networkId);
|
|
3031
|
-
}
|
|
3032
3075
|
/**
|
|
3033
3076
|
* Retrieves a list of available MCP servers.
|
|
3034
3077
|
* @param params - Optional parameters for pagination (limit, offset).
|
|
@@ -3133,7 +3176,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3133
3176
|
* @returns Promise containing the scorer
|
|
3134
3177
|
*/
|
|
3135
3178
|
getScorer(scorerId) {
|
|
3136
|
-
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
3179
|
+
return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
|
|
3137
3180
|
}
|
|
3138
3181
|
getScoresByScorerId(params) {
|
|
3139
3182
|
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
@@ -3151,7 +3194,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3151
3194
|
searchParams.set("perPage", String(perPage));
|
|
3152
3195
|
}
|
|
3153
3196
|
const queryString = searchParams.toString();
|
|
3154
|
-
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
3197
|
+
return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
|
|
3155
3198
|
}
|
|
3156
3199
|
/**
|
|
3157
3200
|
* Retrieves scores by run ID
|
|
@@ -3168,7 +3211,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3168
3211
|
searchParams.set("perPage", String(perPage));
|
|
3169
3212
|
}
|
|
3170
3213
|
const queryString = searchParams.toString();
|
|
3171
|
-
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
3214
|
+
return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
|
|
3172
3215
|
}
|
|
3173
3216
|
/**
|
|
3174
3217
|
* Retrieves scores by entity ID and type
|
|
@@ -3185,7 +3228,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3185
3228
|
searchParams.set("perPage", String(perPage));
|
|
3186
3229
|
}
|
|
3187
3230
|
const queryString = searchParams.toString();
|
|
3188
|
-
return this.request(
|
|
3231
|
+
return this.request(
|
|
3232
|
+
`/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
|
|
3233
|
+
);
|
|
3189
3234
|
}
|
|
3190
3235
|
/**
|
|
3191
3236
|
* Saves a score
|
|
@@ -3211,8 +3256,33 @@ var MastraClient = class extends BaseResource {
|
|
|
3211
3256
|
getAITraces(params) {
|
|
3212
3257
|
return this.observability.getTraces(params);
|
|
3213
3258
|
}
|
|
3259
|
+
getScoresBySpan(params) {
|
|
3260
|
+
return this.observability.getScoresBySpan(params);
|
|
3261
|
+
}
|
|
3262
|
+
score(params) {
|
|
3263
|
+
return this.observability.score(params);
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
// src/tools.ts
|
|
3268
|
+
var ClientTool = class {
|
|
3269
|
+
id;
|
|
3270
|
+
description;
|
|
3271
|
+
inputSchema;
|
|
3272
|
+
outputSchema;
|
|
3273
|
+
execute;
|
|
3274
|
+
constructor(opts) {
|
|
3275
|
+
this.id = opts.id;
|
|
3276
|
+
this.description = opts.description;
|
|
3277
|
+
this.inputSchema = opts.inputSchema;
|
|
3278
|
+
this.outputSchema = opts.outputSchema;
|
|
3279
|
+
this.execute = opts.execute;
|
|
3280
|
+
}
|
|
3214
3281
|
};
|
|
3282
|
+
function createTool(opts) {
|
|
3283
|
+
return new ClientTool(opts);
|
|
3284
|
+
}
|
|
3215
3285
|
|
|
3216
|
-
export { MastraClient };
|
|
3286
|
+
export { ClientTool, MastraClient, createTool };
|
|
3217
3287
|
//# sourceMappingURL=index.js.map
|
|
3218
3288
|
//# sourceMappingURL=index.js.map
|