@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.cjs
CHANGED
|
@@ -21,6 +21,20 @@ function parseClientRuntimeContext(runtimeContext$1) {
|
|
|
21
21
|
}
|
|
22
22
|
return void 0;
|
|
23
23
|
}
|
|
24
|
+
function base64RuntimeContext(runtimeContext) {
|
|
25
|
+
if (runtimeContext) {
|
|
26
|
+
return btoa(JSON.stringify(runtimeContext));
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
function runtimeContextQueryString(runtimeContext) {
|
|
31
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
32
|
+
if (!runtimeContextParam) return "";
|
|
33
|
+
const searchParams = new URLSearchParams();
|
|
34
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
35
|
+
const queryString = searchParams.toString();
|
|
36
|
+
return queryString ? `?${queryString}` : "";
|
|
37
|
+
}
|
|
24
38
|
function isZodType(value) {
|
|
25
39
|
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
26
40
|
}
|
|
@@ -32,7 +46,7 @@ function zodToJsonSchema(zodSchema) {
|
|
|
32
46
|
const fn = "toJSONSchema";
|
|
33
47
|
return zod.z[fn].call(zod.z, zodSchema);
|
|
34
48
|
}
|
|
35
|
-
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "
|
|
49
|
+
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "relative" });
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
// src/utils/process-client-tools.ts
|
|
@@ -65,7 +79,7 @@ function processClientTools(clientTools) {
|
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
// src/utils/process-mastra-stream.ts
|
|
68
|
-
async function
|
|
82
|
+
async function sharedProcessMastraStream({
|
|
69
83
|
stream,
|
|
70
84
|
onChunk
|
|
71
85
|
}) {
|
|
@@ -83,7 +97,7 @@ async function processMastraStream({
|
|
|
83
97
|
if (line.startsWith("data: ")) {
|
|
84
98
|
const data = line.slice(6);
|
|
85
99
|
if (data === "[DONE]") {
|
|
86
|
-
console.
|
|
100
|
+
console.info("\u{1F3C1} Stream finished");
|
|
87
101
|
return;
|
|
88
102
|
}
|
|
89
103
|
try {
|
|
@@ -99,6 +113,24 @@ async function processMastraStream({
|
|
|
99
113
|
reader.releaseLock();
|
|
100
114
|
}
|
|
101
115
|
}
|
|
116
|
+
async function processMastraNetworkStream({
|
|
117
|
+
stream,
|
|
118
|
+
onChunk
|
|
119
|
+
}) {
|
|
120
|
+
return sharedProcessMastraStream({
|
|
121
|
+
stream,
|
|
122
|
+
onChunk
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async function processMastraStream({
|
|
126
|
+
stream,
|
|
127
|
+
onChunk
|
|
128
|
+
}) {
|
|
129
|
+
return sharedProcessMastraStream({
|
|
130
|
+
stream,
|
|
131
|
+
onChunk
|
|
132
|
+
});
|
|
133
|
+
}
|
|
102
134
|
|
|
103
135
|
// src/resources/base.ts
|
|
104
136
|
var BaseResource = class {
|
|
@@ -187,7 +219,9 @@ async function executeToolCallAndRespond({
|
|
|
187
219
|
resourceId,
|
|
188
220
|
threadId,
|
|
189
221
|
runtimeContext,
|
|
190
|
-
tracingContext: { currentSpan: void 0 }
|
|
222
|
+
tracingContext: { currentSpan: void 0 },
|
|
223
|
+
suspend: async () => {
|
|
224
|
+
}
|
|
191
225
|
},
|
|
192
226
|
{
|
|
193
227
|
messages: response.messages,
|
|
@@ -195,11 +229,7 @@ async function executeToolCallAndRespond({
|
|
|
195
229
|
}
|
|
196
230
|
);
|
|
197
231
|
const updatedMessages = [
|
|
198
|
-
|
|
199
|
-
role: "user",
|
|
200
|
-
content: params.messages
|
|
201
|
-
},
|
|
202
|
-
...response.response.messages,
|
|
232
|
+
...response.response.messages || [],
|
|
203
233
|
{
|
|
204
234
|
role: "tool",
|
|
205
235
|
content: [
|
|
@@ -261,17 +291,21 @@ var AgentVoice = class extends BaseResource {
|
|
|
261
291
|
}
|
|
262
292
|
/**
|
|
263
293
|
* Get available speakers for the agent's voice provider
|
|
294
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
295
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
264
296
|
* @returns Promise containing list of available speakers
|
|
265
297
|
*/
|
|
266
|
-
getSpeakers() {
|
|
267
|
-
return this.request(`/api/agents/${this.agentId}/voice/speakers`);
|
|
298
|
+
getSpeakers(runtimeContext) {
|
|
299
|
+
return this.request(`/api/agents/${this.agentId}/voice/speakers${runtimeContextQueryString(runtimeContext)}`);
|
|
268
300
|
}
|
|
269
301
|
/**
|
|
270
302
|
* Get the listener configuration for the agent's voice provider
|
|
303
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
304
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
271
305
|
* @returns Promise containing a check if the agent has listening capabilities
|
|
272
306
|
*/
|
|
273
|
-
getListener() {
|
|
274
|
-
return this.request(`/api/agents/${this.agentId}/voice/listener`);
|
|
307
|
+
getListener(runtimeContext) {
|
|
308
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener${runtimeContextQueryString(runtimeContext)}`);
|
|
275
309
|
}
|
|
276
310
|
};
|
|
277
311
|
var Agent = class extends BaseResource {
|
|
@@ -283,16 +317,11 @@ var Agent = class extends BaseResource {
|
|
|
283
317
|
voice;
|
|
284
318
|
/**
|
|
285
319
|
* Retrieves details about the agent
|
|
320
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
286
321
|
* @returns Promise containing agent details including model and instructions
|
|
287
322
|
*/
|
|
288
|
-
details() {
|
|
289
|
-
return this.request(`/api/agents/${this.agentId}`);
|
|
290
|
-
}
|
|
291
|
-
async generate(params) {
|
|
292
|
-
console.warn(
|
|
293
|
-
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet."
|
|
294
|
-
);
|
|
295
|
-
return this.generateLegacy(params);
|
|
323
|
+
details(runtimeContext) {
|
|
324
|
+
return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
|
|
296
325
|
}
|
|
297
326
|
async generateLegacy(params) {
|
|
298
327
|
const processedParams = {
|
|
@@ -325,7 +354,9 @@ var Agent = class extends BaseResource {
|
|
|
325
354
|
resourceId,
|
|
326
355
|
threadId,
|
|
327
356
|
runtimeContext,
|
|
328
|
-
tracingContext: { currentSpan: void 0 }
|
|
357
|
+
tracingContext: { currentSpan: void 0 },
|
|
358
|
+
suspend: async () => {
|
|
359
|
+
}
|
|
329
360
|
},
|
|
330
361
|
{
|
|
331
362
|
messages: response.messages,
|
|
@@ -333,10 +364,6 @@ var Agent = class extends BaseResource {
|
|
|
333
364
|
}
|
|
334
365
|
);
|
|
335
366
|
const updatedMessages = [
|
|
336
|
-
{
|
|
337
|
-
role: "user",
|
|
338
|
-
content: params.messages
|
|
339
|
-
},
|
|
340
367
|
...response.response.messages,
|
|
341
368
|
{
|
|
342
369
|
role: "tool",
|
|
@@ -359,16 +386,29 @@ var Agent = class extends BaseResource {
|
|
|
359
386
|
}
|
|
360
387
|
return response;
|
|
361
388
|
}
|
|
362
|
-
async
|
|
389
|
+
async generate(messagesOrParams, options) {
|
|
390
|
+
let params;
|
|
391
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
392
|
+
params = messagesOrParams;
|
|
393
|
+
} else {
|
|
394
|
+
params = {
|
|
395
|
+
messages: messagesOrParams,
|
|
396
|
+
...options
|
|
397
|
+
};
|
|
398
|
+
}
|
|
363
399
|
const processedParams = {
|
|
364
400
|
...params,
|
|
365
401
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
366
402
|
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
367
|
-
clientTools: processClientTools(params.clientTools)
|
|
403
|
+
clientTools: processClientTools(params.clientTools),
|
|
404
|
+
structuredOutput: params.structuredOutput ? {
|
|
405
|
+
...params.structuredOutput,
|
|
406
|
+
schema: zodToJsonSchema(params.structuredOutput.schema)
|
|
407
|
+
} : void 0
|
|
368
408
|
};
|
|
369
409
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
370
410
|
const response = await this.request(
|
|
371
|
-
`/api/agents/${this.agentId}/generate
|
|
411
|
+
`/api/agents/${this.agentId}/generate`,
|
|
372
412
|
{
|
|
373
413
|
method: "POST",
|
|
374
414
|
body: processedParams
|
|
@@ -382,7 +422,7 @@ var Agent = class extends BaseResource {
|
|
|
382
422
|
resourceId,
|
|
383
423
|
threadId,
|
|
384
424
|
runtimeContext,
|
|
385
|
-
respondFn: this.
|
|
425
|
+
respondFn: this.generate.bind(this)
|
|
386
426
|
});
|
|
387
427
|
}
|
|
388
428
|
return response;
|
|
@@ -649,17 +689,6 @@ var Agent = class extends BaseResource {
|
|
|
649
689
|
});
|
|
650
690
|
onFinish?.({ message, finishReason, usage });
|
|
651
691
|
}
|
|
652
|
-
/**
|
|
653
|
-
* Streams a response from the agent
|
|
654
|
-
* @param params - Stream parameters including prompt
|
|
655
|
-
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
656
|
-
*/
|
|
657
|
-
async stream(params) {
|
|
658
|
-
console.warn(
|
|
659
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet."
|
|
660
|
-
);
|
|
661
|
-
return this.streamLegacy(params);
|
|
662
|
-
}
|
|
663
692
|
/**
|
|
664
693
|
* Streams a response from the agent
|
|
665
694
|
* @param params - Stream parameters including prompt
|
|
@@ -869,7 +898,7 @@ var Agent = class extends BaseResource {
|
|
|
869
898
|
step,
|
|
870
899
|
toolCallId: chunk.payload.toolCallId,
|
|
871
900
|
toolName: chunk.payload.toolName,
|
|
872
|
-
args:
|
|
901
|
+
args: chunk.payload.args
|
|
873
902
|
};
|
|
874
903
|
message.toolInvocations.push(invocation);
|
|
875
904
|
updateToolInvocationPart(chunk.payload.toolCallId, invocation);
|
|
@@ -923,14 +952,14 @@ var Agent = class extends BaseResource {
|
|
|
923
952
|
}
|
|
924
953
|
case "step-finish": {
|
|
925
954
|
step += 1;
|
|
926
|
-
currentTextPart = chunk.payload.isContinued ? currentTextPart : void 0;
|
|
955
|
+
currentTextPart = chunk.payload.stepResult.isContinued ? currentTextPart : void 0;
|
|
927
956
|
currentReasoningPart = void 0;
|
|
928
957
|
currentReasoningTextDetail = void 0;
|
|
929
958
|
execUpdate();
|
|
930
959
|
break;
|
|
931
960
|
}
|
|
932
961
|
case "finish": {
|
|
933
|
-
finishReason = chunk.payload.
|
|
962
|
+
finishReason = chunk.payload.stepResult.reason;
|
|
934
963
|
if (chunk.payload.usage != null) {
|
|
935
964
|
usage = chunk.payload.usage;
|
|
936
965
|
}
|
|
@@ -942,7 +971,7 @@ var Agent = class extends BaseResource {
|
|
|
942
971
|
onFinish?.({ message, finishReason, usage });
|
|
943
972
|
}
|
|
944
973
|
async processStreamResponse_vNext(processedParams, writable) {
|
|
945
|
-
const response = await this.request(`/api/agents/${this.agentId}/stream
|
|
974
|
+
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
946
975
|
method: "POST",
|
|
947
976
|
body: processedParams,
|
|
948
977
|
stream: true
|
|
@@ -954,9 +983,28 @@ var Agent = class extends BaseResource {
|
|
|
954
983
|
let toolCalls = [];
|
|
955
984
|
let messages = [];
|
|
956
985
|
const [streamForWritable, streamForProcessing] = response.body.tee();
|
|
957
|
-
streamForWritable.pipeTo(
|
|
958
|
-
|
|
959
|
-
|
|
986
|
+
streamForWritable.pipeTo(
|
|
987
|
+
new WritableStream({
|
|
988
|
+
async write(chunk) {
|
|
989
|
+
try {
|
|
990
|
+
const text = new TextDecoder().decode(chunk);
|
|
991
|
+
if (text.includes("[DONE]")) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
} catch {
|
|
995
|
+
}
|
|
996
|
+
const writer = writable.getWriter();
|
|
997
|
+
try {
|
|
998
|
+
await writer.write(chunk);
|
|
999
|
+
} finally {
|
|
1000
|
+
writer.releaseLock();
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}),
|
|
1004
|
+
{
|
|
1005
|
+
preventClose: true
|
|
1006
|
+
}
|
|
1007
|
+
).catch((error) => {
|
|
960
1008
|
console.error("Error piping to writable stream:", error);
|
|
961
1009
|
});
|
|
962
1010
|
this.processChatResponse_vNext({
|
|
@@ -975,9 +1023,11 @@ var Agent = class extends BaseResource {
|
|
|
975
1023
|
if (toolCall) {
|
|
976
1024
|
toolCalls.push(toolCall);
|
|
977
1025
|
}
|
|
1026
|
+
let shouldExecuteClientTool = false;
|
|
978
1027
|
for (const toolCall2 of toolCalls) {
|
|
979
1028
|
const clientTool = processedParams.clientTools?.[toolCall2.toolName];
|
|
980
1029
|
if (clientTool && clientTool.execute) {
|
|
1030
|
+
shouldExecuteClientTool = true;
|
|
981
1031
|
const result = await clientTool.execute(
|
|
982
1032
|
{
|
|
983
1033
|
context: toolCall2?.args,
|
|
@@ -986,14 +1036,17 @@ var Agent = class extends BaseResource {
|
|
|
986
1036
|
threadId: processedParams.threadId,
|
|
987
1037
|
runtimeContext: processedParams.runtimeContext,
|
|
988
1038
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
989
|
-
tracingContext: { currentSpan: void 0 }
|
|
1039
|
+
tracingContext: { currentSpan: void 0 },
|
|
1040
|
+
suspend: async () => {
|
|
1041
|
+
}
|
|
990
1042
|
},
|
|
991
1043
|
{
|
|
992
1044
|
messages: response.messages,
|
|
993
1045
|
toolCallId: toolCall2?.toolCallId
|
|
994
1046
|
}
|
|
995
1047
|
);
|
|
996
|
-
const
|
|
1048
|
+
const lastMessageRaw = messages[messages.length - 1];
|
|
1049
|
+
const lastMessage = lastMessageRaw != null ? JSON.parse(JSON.stringify(lastMessageRaw)) : void 0;
|
|
997
1050
|
const toolInvocationPart = lastMessage?.parts?.find(
|
|
998
1051
|
(part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall2.toolCallId
|
|
999
1052
|
);
|
|
@@ -1011,25 +1064,11 @@ var Agent = class extends BaseResource {
|
|
|
1011
1064
|
toolInvocation.state = "result";
|
|
1012
1065
|
toolInvocation.result = result;
|
|
1013
1066
|
}
|
|
1014
|
-
const
|
|
1015
|
-
try {
|
|
1016
|
-
await writer.write(
|
|
1017
|
-
new TextEncoder().encode(
|
|
1018
|
-
"a:" + JSON.stringify({
|
|
1019
|
-
toolCallId: toolCall2.toolCallId,
|
|
1020
|
-
result
|
|
1021
|
-
}) + "\n"
|
|
1022
|
-
)
|
|
1023
|
-
);
|
|
1024
|
-
} finally {
|
|
1025
|
-
writer.releaseLock();
|
|
1026
|
-
}
|
|
1027
|
-
const originalMessages = processedParams.messages;
|
|
1028
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1067
|
+
const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
|
|
1029
1068
|
this.processStreamResponse_vNext(
|
|
1030
1069
|
{
|
|
1031
1070
|
...processedParams,
|
|
1032
|
-
messages:
|
|
1071
|
+
messages: updatedMessages
|
|
1033
1072
|
},
|
|
1034
1073
|
writable
|
|
1035
1074
|
).catch((error) => {
|
|
@@ -1037,6 +1076,11 @@ var Agent = class extends BaseResource {
|
|
|
1037
1076
|
});
|
|
1038
1077
|
}
|
|
1039
1078
|
}
|
|
1079
|
+
if (!shouldExecuteClientTool) {
|
|
1080
|
+
setTimeout(() => {
|
|
1081
|
+
writable.close();
|
|
1082
|
+
}, 0);
|
|
1083
|
+
}
|
|
1040
1084
|
} else {
|
|
1041
1085
|
setTimeout(() => {
|
|
1042
1086
|
writable.close();
|
|
@@ -1052,12 +1096,49 @@ var Agent = class extends BaseResource {
|
|
|
1052
1096
|
}
|
|
1053
1097
|
return response;
|
|
1054
1098
|
}
|
|
1055
|
-
async
|
|
1099
|
+
async network(params) {
|
|
1100
|
+
const response = await this.request(`/api/agents/${this.agentId}/network`, {
|
|
1101
|
+
method: "POST",
|
|
1102
|
+
body: params,
|
|
1103
|
+
stream: true
|
|
1104
|
+
});
|
|
1105
|
+
if (!response.body) {
|
|
1106
|
+
throw new Error("No response body");
|
|
1107
|
+
}
|
|
1108
|
+
const streamResponse = new Response(response.body, {
|
|
1109
|
+
status: response.status,
|
|
1110
|
+
statusText: response.statusText,
|
|
1111
|
+
headers: response.headers
|
|
1112
|
+
});
|
|
1113
|
+
streamResponse.processDataStream = async ({
|
|
1114
|
+
onChunk
|
|
1115
|
+
}) => {
|
|
1116
|
+
await processMastraNetworkStream({
|
|
1117
|
+
stream: streamResponse.body,
|
|
1118
|
+
onChunk
|
|
1119
|
+
});
|
|
1120
|
+
};
|
|
1121
|
+
return streamResponse;
|
|
1122
|
+
}
|
|
1123
|
+
async stream(messagesOrParams, options) {
|
|
1124
|
+
let params;
|
|
1125
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
1126
|
+
params = messagesOrParams;
|
|
1127
|
+
} else {
|
|
1128
|
+
params = {
|
|
1129
|
+
messages: messagesOrParams,
|
|
1130
|
+
...options
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1056
1133
|
const processedParams = {
|
|
1057
1134
|
...params,
|
|
1058
1135
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
1059
1136
|
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
1060
|
-
clientTools: processClientTools(params.clientTools)
|
|
1137
|
+
clientTools: processClientTools(params.clientTools),
|
|
1138
|
+
structuredOutput: params.structuredOutput ? {
|
|
1139
|
+
...params.structuredOutput,
|
|
1140
|
+
schema: zodToJsonSchema(params.structuredOutput.schema)
|
|
1141
|
+
} : void 0
|
|
1061
1142
|
};
|
|
1062
1143
|
const { readable, writable } = new TransformStream();
|
|
1063
1144
|
const response = await this.processStreamResponse_vNext(processedParams, writable);
|
|
@@ -1124,7 +1205,9 @@ var Agent = class extends BaseResource {
|
|
|
1124
1205
|
threadId: processedParams.threadId,
|
|
1125
1206
|
runtimeContext: processedParams.runtimeContext,
|
|
1126
1207
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1127
|
-
tracingContext: { currentSpan: void 0 }
|
|
1208
|
+
tracingContext: { currentSpan: void 0 },
|
|
1209
|
+
suspend: async () => {
|
|
1210
|
+
}
|
|
1128
1211
|
},
|
|
1129
1212
|
{
|
|
1130
1213
|
messages: response.messages,
|
|
@@ -1162,12 +1245,10 @@ var Agent = class extends BaseResource {
|
|
|
1162
1245
|
} finally {
|
|
1163
1246
|
writer.releaseLock();
|
|
1164
1247
|
}
|
|
1165
|
-
const originalMessages = processedParams.messages;
|
|
1166
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1167
1248
|
this.processStreamResponse(
|
|
1168
1249
|
{
|
|
1169
1250
|
...processedParams,
|
|
1170
|
-
messages: [...
|
|
1251
|
+
messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
1171
1252
|
},
|
|
1172
1253
|
writable
|
|
1173
1254
|
).catch((error) => {
|
|
@@ -1193,10 +1274,11 @@ var Agent = class extends BaseResource {
|
|
|
1193
1274
|
/**
|
|
1194
1275
|
* Gets details about a specific tool available to the agent
|
|
1195
1276
|
* @param toolId - ID of the tool to retrieve
|
|
1277
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1196
1278
|
* @returns Promise containing tool details
|
|
1197
1279
|
*/
|
|
1198
|
-
getTool(toolId) {
|
|
1199
|
-
return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
|
|
1280
|
+
getTool(toolId, runtimeContext) {
|
|
1281
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1200
1282
|
}
|
|
1201
1283
|
/**
|
|
1202
1284
|
* Executes a tool for the agent
|
|
@@ -1207,7 +1289,7 @@ var Agent = class extends BaseResource {
|
|
|
1207
1289
|
executeTool(toolId, params) {
|
|
1208
1290
|
const body = {
|
|
1209
1291
|
data: params.data,
|
|
1210
|
-
runtimeContext:
|
|
1292
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1211
1293
|
};
|
|
1212
1294
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
1213
1295
|
method: "POST",
|
|
@@ -1216,17 +1298,19 @@ var Agent = class extends BaseResource {
|
|
|
1216
1298
|
}
|
|
1217
1299
|
/**
|
|
1218
1300
|
* Retrieves evaluation results for the agent
|
|
1301
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1219
1302
|
* @returns Promise containing agent evaluations
|
|
1220
1303
|
*/
|
|
1221
|
-
evals() {
|
|
1222
|
-
return this.request(`/api/agents/${this.agentId}/evals/ci`);
|
|
1304
|
+
evals(runtimeContext) {
|
|
1305
|
+
return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
|
|
1223
1306
|
}
|
|
1224
1307
|
/**
|
|
1225
1308
|
* Retrieves live evaluation results for the agent
|
|
1309
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1226
1310
|
* @returns Promise containing live agent evaluations
|
|
1227
1311
|
*/
|
|
1228
|
-
liveEvals() {
|
|
1229
|
-
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
1312
|
+
liveEvals(runtimeContext) {
|
|
1313
|
+
return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
|
|
1230
1314
|
}
|
|
1231
1315
|
/**
|
|
1232
1316
|
* Updates the model for the agent
|
|
@@ -1239,61 +1323,33 @@ var Agent = class extends BaseResource {
|
|
|
1239
1323
|
body: params
|
|
1240
1324
|
});
|
|
1241
1325
|
}
|
|
1242
|
-
};
|
|
1243
|
-
var Network = class extends BaseResource {
|
|
1244
|
-
constructor(options, networkId) {
|
|
1245
|
-
super(options);
|
|
1246
|
-
this.networkId = networkId;
|
|
1247
|
-
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Retrieves details about the network
|
|
1250
|
-
* @returns Promise containing network details
|
|
1251
|
-
*/
|
|
1252
|
-
details() {
|
|
1253
|
-
return this.request(`/api/networks/${this.networkId}`);
|
|
1254
|
-
}
|
|
1255
1326
|
/**
|
|
1256
|
-
*
|
|
1257
|
-
* @param params -
|
|
1258
|
-
* @returns Promise containing the
|
|
1327
|
+
* Updates the model for the agent in the model list
|
|
1328
|
+
* @param params - Parameters for updating the model
|
|
1329
|
+
* @returns Promise containing the updated model
|
|
1259
1330
|
*/
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
...params,
|
|
1263
|
-
output: zodToJsonSchema(params.output),
|
|
1264
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1265
|
-
};
|
|
1266
|
-
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
1331
|
+
updateModelInModelList({ modelConfigId, ...params }) {
|
|
1332
|
+
return this.request(`/api/agents/${this.agentId}/models/${modelConfigId}`, {
|
|
1267
1333
|
method: "POST",
|
|
1268
|
-
body:
|
|
1334
|
+
body: params
|
|
1269
1335
|
});
|
|
1270
1336
|
}
|
|
1271
1337
|
/**
|
|
1272
|
-
*
|
|
1273
|
-
* @param params -
|
|
1274
|
-
* @returns Promise containing the
|
|
1338
|
+
* Reorders the models for the agent
|
|
1339
|
+
* @param params - Parameters for reordering the model list
|
|
1340
|
+
* @returns Promise containing the updated model list
|
|
1275
1341
|
*/
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
...params,
|
|
1279
|
-
output: zodToJsonSchema(params.output),
|
|
1280
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1281
|
-
};
|
|
1282
|
-
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
1342
|
+
reorderModelList(params) {
|
|
1343
|
+
return this.request(`/api/agents/${this.agentId}/models/reorder`, {
|
|
1283
1344
|
method: "POST",
|
|
1284
|
-
body:
|
|
1285
|
-
stream: true
|
|
1345
|
+
body: params
|
|
1286
1346
|
});
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
...options
|
|
1294
|
-
});
|
|
1295
|
-
};
|
|
1296
|
-
return response;
|
|
1347
|
+
}
|
|
1348
|
+
async generateVNext(_messagesOrParams, _options) {
|
|
1349
|
+
throw new Error("generateVNext has been renamed to generate. Please use generate instead.");
|
|
1350
|
+
}
|
|
1351
|
+
async streamVNext(_messagesOrParams, _options) {
|
|
1352
|
+
throw new Error("streamVNext has been renamed to stream. Please use stream instead.");
|
|
1297
1353
|
}
|
|
1298
1354
|
};
|
|
1299
1355
|
|
|
@@ -1384,10 +1440,13 @@ var Vector = class extends BaseResource {
|
|
|
1384
1440
|
/**
|
|
1385
1441
|
* Retrieves details about a specific vector index
|
|
1386
1442
|
* @param indexName - Name of the index to get details for
|
|
1443
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1387
1444
|
* @returns Promise containing vector index details
|
|
1388
1445
|
*/
|
|
1389
|
-
details(indexName) {
|
|
1390
|
-
return this.request(
|
|
1446
|
+
details(indexName, runtimeContext) {
|
|
1447
|
+
return this.request(
|
|
1448
|
+
`/api/vector/${this.vectorName}/indexes/${indexName}${runtimeContextQueryString(runtimeContext)}`
|
|
1449
|
+
);
|
|
1391
1450
|
}
|
|
1392
1451
|
/**
|
|
1393
1452
|
* Deletes a vector index
|
|
@@ -1401,10 +1460,11 @@ var Vector = class extends BaseResource {
|
|
|
1401
1460
|
}
|
|
1402
1461
|
/**
|
|
1403
1462
|
* Retrieves a list of all available indexes
|
|
1463
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1404
1464
|
* @returns Promise containing array of index names
|
|
1405
1465
|
*/
|
|
1406
|
-
getIndexes() {
|
|
1407
|
-
return this.request(`/api/vector/${this.vectorName}/indexes`);
|
|
1466
|
+
getIndexes(runtimeContext) {
|
|
1467
|
+
return this.request(`/api/vector/${this.vectorName}/indexes${runtimeContextQueryString(runtimeContext)}`);
|
|
1408
1468
|
}
|
|
1409
1469
|
/**
|
|
1410
1470
|
* Creates a new vector index
|
|
@@ -1441,123 +1501,50 @@ var Vector = class extends BaseResource {
|
|
|
1441
1501
|
}
|
|
1442
1502
|
};
|
|
1443
1503
|
|
|
1444
|
-
// src/resources/
|
|
1445
|
-
var
|
|
1446
|
-
|
|
1447
|
-
constructor(options, workflowId) {
|
|
1504
|
+
// src/resources/tool.ts
|
|
1505
|
+
var Tool = class extends BaseResource {
|
|
1506
|
+
constructor(options, toolId) {
|
|
1448
1507
|
super(options);
|
|
1449
|
-
this.
|
|
1450
|
-
}
|
|
1451
|
-
/**
|
|
1452
|
-
* Retrieves details about the legacy workflow
|
|
1453
|
-
* @returns Promise containing legacy workflow details including steps and graphs
|
|
1454
|
-
*/
|
|
1455
|
-
details() {
|
|
1456
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
* Retrieves all runs for a legacy workflow
|
|
1460
|
-
* @param params - Parameters for filtering runs
|
|
1461
|
-
* @returns Promise containing legacy workflow runs array
|
|
1462
|
-
*/
|
|
1463
|
-
runs(params) {
|
|
1464
|
-
const searchParams = new URLSearchParams();
|
|
1465
|
-
if (params?.fromDate) {
|
|
1466
|
-
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1467
|
-
}
|
|
1468
|
-
if (params?.toDate) {
|
|
1469
|
-
searchParams.set("toDate", params.toDate.toISOString());
|
|
1470
|
-
}
|
|
1471
|
-
if (params?.limit) {
|
|
1472
|
-
searchParams.set("limit", String(params.limit));
|
|
1473
|
-
}
|
|
1474
|
-
if (params?.offset) {
|
|
1475
|
-
searchParams.set("offset", String(params.offset));
|
|
1476
|
-
}
|
|
1477
|
-
if (params?.resourceId) {
|
|
1478
|
-
searchParams.set("resourceId", params.resourceId);
|
|
1479
|
-
}
|
|
1480
|
-
if (searchParams.size) {
|
|
1481
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
1482
|
-
} else {
|
|
1483
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
/**
|
|
1487
|
-
* Creates a new legacy workflow run
|
|
1488
|
-
* @returns Promise containing the generated run ID
|
|
1489
|
-
*/
|
|
1490
|
-
createRun(params) {
|
|
1491
|
-
const searchParams = new URLSearchParams();
|
|
1492
|
-
if (!!params?.runId) {
|
|
1493
|
-
searchParams.set("runId", params.runId);
|
|
1494
|
-
}
|
|
1495
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
1496
|
-
method: "POST"
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
/**
|
|
1500
|
-
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
1501
|
-
* @param params - Object containing the runId and triggerData
|
|
1502
|
-
* @returns Promise containing success message
|
|
1503
|
-
*/
|
|
1504
|
-
start(params) {
|
|
1505
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1506
|
-
method: "POST",
|
|
1507
|
-
body: params?.triggerData
|
|
1508
|
-
});
|
|
1508
|
+
this.toolId = toolId;
|
|
1509
1509
|
}
|
|
1510
1510
|
/**
|
|
1511
|
-
*
|
|
1512
|
-
* @param
|
|
1513
|
-
* @
|
|
1514
|
-
* @param context - Context to resume the legacy workflow with
|
|
1515
|
-
* @returns Promise containing the legacy workflow resume results
|
|
1511
|
+
* Retrieves details about the tool
|
|
1512
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1513
|
+
* @returns Promise containing tool details including description and schemas
|
|
1516
1514
|
*/
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
runId,
|
|
1520
|
-
context
|
|
1521
|
-
}) {
|
|
1522
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
1523
|
-
method: "POST",
|
|
1524
|
-
body: {
|
|
1525
|
-
stepId,
|
|
1526
|
-
context
|
|
1527
|
-
}
|
|
1528
|
-
});
|
|
1515
|
+
details(runtimeContext) {
|
|
1516
|
+
return this.request(`/api/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1529
1517
|
}
|
|
1530
1518
|
/**
|
|
1531
|
-
*
|
|
1532
|
-
* @param params -
|
|
1533
|
-
* @returns Promise containing the
|
|
1519
|
+
* Executes the tool with the provided parameters
|
|
1520
|
+
* @param params - Parameters required for tool execution
|
|
1521
|
+
* @returns Promise containing the tool execution results
|
|
1534
1522
|
*/
|
|
1535
|
-
|
|
1536
|
-
const
|
|
1537
|
-
if (
|
|
1538
|
-
|
|
1523
|
+
execute(params) {
|
|
1524
|
+
const url = new URLSearchParams();
|
|
1525
|
+
if (params.runId) {
|
|
1526
|
+
url.set("runId", params.runId);
|
|
1539
1527
|
}
|
|
1540
|
-
|
|
1528
|
+
const body = {
|
|
1529
|
+
data: params.data,
|
|
1530
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1531
|
+
};
|
|
1532
|
+
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
1541
1533
|
method: "POST",
|
|
1542
|
-
body
|
|
1534
|
+
body
|
|
1543
1535
|
});
|
|
1544
1536
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
body: {
|
|
1554
|
-
stepId: params.stepId,
|
|
1555
|
-
context: params.context
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1539
|
+
// src/resources/workflow.ts
|
|
1540
|
+
var RECORD_SEPARATOR = "";
|
|
1541
|
+
var Workflow = class extends BaseResource {
|
|
1542
|
+
constructor(options, workflowId) {
|
|
1543
|
+
super(options);
|
|
1544
|
+
this.workflowId = workflowId;
|
|
1558
1545
|
}
|
|
1559
1546
|
/**
|
|
1560
|
-
* Creates an async generator that processes a readable stream and yields records
|
|
1547
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
1561
1548
|
* separated by the Record Separator character (\x1E)
|
|
1562
1549
|
*
|
|
1563
1550
|
* @param stream - The readable stream to process
|
|
@@ -1602,162 +1589,65 @@ var LegacyWorkflow = class extends BaseResource {
|
|
|
1602
1589
|
}
|
|
1603
1590
|
}
|
|
1604
1591
|
/**
|
|
1605
|
-
*
|
|
1606
|
-
* @param
|
|
1607
|
-
* @returns
|
|
1592
|
+
* Retrieves details about the workflow
|
|
1593
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1594
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
1608
1595
|
*/
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1596
|
+
details(runtimeContext) {
|
|
1597
|
+
return this.request(`/api/workflows/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Retrieves all runs for a workflow
|
|
1601
|
+
* @param params - Parameters for filtering runs
|
|
1602
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1603
|
+
* @returns Promise containing workflow runs array
|
|
1604
|
+
*/
|
|
1605
|
+
runs(params, runtimeContext) {
|
|
1606
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1607
|
+
const searchParams = new URLSearchParams();
|
|
1608
|
+
if (params?.fromDate) {
|
|
1609
|
+
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1615
1610
|
}
|
|
1616
|
-
if (
|
|
1617
|
-
|
|
1611
|
+
if (params?.toDate) {
|
|
1612
|
+
searchParams.set("toDate", params.toDate.toISOString());
|
|
1618
1613
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
details() {
|
|
1636
|
-
return this.request(`/api/tools/${this.toolId}`);
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Executes the tool with the provided parameters
|
|
1640
|
-
* @param params - Parameters required for tool execution
|
|
1641
|
-
* @returns Promise containing the tool execution results
|
|
1642
|
-
*/
|
|
1643
|
-
execute(params) {
|
|
1644
|
-
const url = new URLSearchParams();
|
|
1645
|
-
if (params.runId) {
|
|
1646
|
-
url.set("runId", params.runId);
|
|
1647
|
-
}
|
|
1648
|
-
const body = {
|
|
1649
|
-
data: params.data,
|
|
1650
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1651
|
-
};
|
|
1652
|
-
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
1653
|
-
method: "POST",
|
|
1654
|
-
body
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
};
|
|
1658
|
-
|
|
1659
|
-
// src/resources/workflow.ts
|
|
1660
|
-
var RECORD_SEPARATOR2 = "";
|
|
1661
|
-
var Workflow = class extends BaseResource {
|
|
1662
|
-
constructor(options, workflowId) {
|
|
1663
|
-
super(options);
|
|
1664
|
-
this.workflowId = workflowId;
|
|
1665
|
-
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Creates an async generator that processes a readable stream and yields workflow records
|
|
1668
|
-
* separated by the Record Separator character (\x1E)
|
|
1669
|
-
*
|
|
1670
|
-
* @param stream - The readable stream to process
|
|
1671
|
-
* @returns An async generator that yields parsed records
|
|
1672
|
-
*/
|
|
1673
|
-
async *streamProcessor(stream) {
|
|
1674
|
-
const reader = stream.getReader();
|
|
1675
|
-
let doneReading = false;
|
|
1676
|
-
let buffer = "";
|
|
1677
|
-
try {
|
|
1678
|
-
while (!doneReading) {
|
|
1679
|
-
const { done, value } = await reader.read();
|
|
1680
|
-
doneReading = done;
|
|
1681
|
-
if (done && !value) continue;
|
|
1682
|
-
try {
|
|
1683
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
1684
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
1685
|
-
buffer = chunks.pop() || "";
|
|
1686
|
-
for (const chunk of chunks) {
|
|
1687
|
-
if (chunk) {
|
|
1688
|
-
if (typeof chunk === "string") {
|
|
1689
|
-
try {
|
|
1690
|
-
const parsedChunk = JSON.parse(chunk);
|
|
1691
|
-
yield parsedChunk;
|
|
1692
|
-
} catch {
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
} catch {
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
if (buffer) {
|
|
1701
|
-
try {
|
|
1702
|
-
yield JSON.parse(buffer);
|
|
1703
|
-
} catch {
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
} finally {
|
|
1707
|
-
reader.cancel().catch(() => {
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Retrieves details about the workflow
|
|
1713
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
1714
|
-
*/
|
|
1715
|
-
details() {
|
|
1716
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* Retrieves all runs for a workflow
|
|
1720
|
-
* @param params - Parameters for filtering runs
|
|
1721
|
-
* @returns Promise containing workflow runs array
|
|
1722
|
-
*/
|
|
1723
|
-
runs(params) {
|
|
1724
|
-
const searchParams = new URLSearchParams();
|
|
1725
|
-
if (params?.fromDate) {
|
|
1726
|
-
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1727
|
-
}
|
|
1728
|
-
if (params?.toDate) {
|
|
1729
|
-
searchParams.set("toDate", params.toDate.toISOString());
|
|
1730
|
-
}
|
|
1731
|
-
if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
|
|
1732
|
-
searchParams.set("limit", String(params.limit));
|
|
1733
|
-
}
|
|
1734
|
-
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
1735
|
-
searchParams.set("offset", String(params.offset));
|
|
1736
|
-
}
|
|
1737
|
-
if (params?.resourceId) {
|
|
1738
|
-
searchParams.set("resourceId", params.resourceId);
|
|
1739
|
-
}
|
|
1740
|
-
if (searchParams.size) {
|
|
1741
|
-
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
1742
|
-
} else {
|
|
1743
|
-
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
1614
|
+
if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
|
|
1615
|
+
searchParams.set("limit", String(params.limit));
|
|
1616
|
+
}
|
|
1617
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
1618
|
+
searchParams.set("offset", String(params.offset));
|
|
1619
|
+
}
|
|
1620
|
+
if (params?.resourceId) {
|
|
1621
|
+
searchParams.set("resourceId", params.resourceId);
|
|
1622
|
+
}
|
|
1623
|
+
if (runtimeContextParam) {
|
|
1624
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1625
|
+
}
|
|
1626
|
+
if (searchParams.size) {
|
|
1627
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
1628
|
+
} else {
|
|
1629
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
1744
1630
|
}
|
|
1745
1631
|
}
|
|
1746
1632
|
/**
|
|
1747
1633
|
* Retrieves a specific workflow run by its ID
|
|
1748
1634
|
* @param runId - The ID of the workflow run to retrieve
|
|
1635
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1749
1636
|
* @returns Promise containing the workflow run details
|
|
1750
1637
|
*/
|
|
1751
|
-
runById(runId) {
|
|
1752
|
-
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
|
|
1638
|
+
runById(runId, runtimeContext) {
|
|
1639
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1753
1640
|
}
|
|
1754
1641
|
/**
|
|
1755
1642
|
* Retrieves the execution result for a specific workflow run by its ID
|
|
1756
1643
|
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
1644
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1757
1645
|
* @returns Promise containing the workflow run execution result
|
|
1758
1646
|
*/
|
|
1759
|
-
runExecutionResult(runId) {
|
|
1760
|
-
return this.request(
|
|
1647
|
+
runExecutionResult(runId, runtimeContext) {
|
|
1648
|
+
return this.request(
|
|
1649
|
+
`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${runtimeContextQueryString(runtimeContext)}`
|
|
1650
|
+
);
|
|
1761
1651
|
}
|
|
1762
1652
|
/**
|
|
1763
1653
|
* Cancels a specific workflow run by its ID
|
|
@@ -1780,27 +1670,83 @@ var Workflow = class extends BaseResource {
|
|
|
1780
1670
|
body: { event: params.event, data: params.data }
|
|
1781
1671
|
});
|
|
1782
1672
|
}
|
|
1673
|
+
/**
|
|
1674
|
+
* @deprecated Use createRunAsync() instead.
|
|
1675
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
1676
|
+
*/
|
|
1677
|
+
async createRun(_params) {
|
|
1678
|
+
throw new Error(
|
|
1679
|
+
"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."
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1783
1682
|
/**
|
|
1784
1683
|
* Creates a new workflow run
|
|
1785
1684
|
* @param params - Optional object containing the optional runId
|
|
1786
|
-
* @returns Promise containing the runId of the created run
|
|
1685
|
+
* @returns Promise containing the runId of the created run with methods to control execution
|
|
1787
1686
|
*/
|
|
1788
|
-
|
|
1687
|
+
async createRunAsync(params) {
|
|
1789
1688
|
const searchParams = new URLSearchParams();
|
|
1790
1689
|
if (!!params?.runId) {
|
|
1791
1690
|
searchParams.set("runId", params.runId);
|
|
1792
1691
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1692
|
+
const res = await this.request(
|
|
1693
|
+
`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`,
|
|
1694
|
+
{
|
|
1695
|
+
method: "POST"
|
|
1696
|
+
}
|
|
1697
|
+
);
|
|
1698
|
+
const runId = res.runId;
|
|
1699
|
+
return {
|
|
1700
|
+
runId,
|
|
1701
|
+
start: async (p) => {
|
|
1702
|
+
return this.start({
|
|
1703
|
+
runId,
|
|
1704
|
+
inputData: p.inputData,
|
|
1705
|
+
runtimeContext: p.runtimeContext,
|
|
1706
|
+
tracingOptions: p.tracingOptions
|
|
1707
|
+
});
|
|
1708
|
+
},
|
|
1709
|
+
startAsync: async (p) => {
|
|
1710
|
+
return this.startAsync({
|
|
1711
|
+
runId,
|
|
1712
|
+
inputData: p.inputData,
|
|
1713
|
+
runtimeContext: p.runtimeContext,
|
|
1714
|
+
tracingOptions: p.tracingOptions
|
|
1715
|
+
});
|
|
1716
|
+
},
|
|
1717
|
+
watch: async (onRecord) => {
|
|
1718
|
+
return this.watch({ runId }, onRecord);
|
|
1719
|
+
},
|
|
1720
|
+
stream: async (p) => {
|
|
1721
|
+
return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1722
|
+
},
|
|
1723
|
+
resume: async (p) => {
|
|
1724
|
+
return this.resume({
|
|
1725
|
+
runId,
|
|
1726
|
+
step: p.step,
|
|
1727
|
+
resumeData: p.resumeData,
|
|
1728
|
+
runtimeContext: p.runtimeContext,
|
|
1729
|
+
tracingOptions: p.tracingOptions
|
|
1730
|
+
});
|
|
1731
|
+
},
|
|
1732
|
+
resumeAsync: async (p) => {
|
|
1733
|
+
return this.resumeAsync({
|
|
1734
|
+
runId,
|
|
1735
|
+
step: p.step,
|
|
1736
|
+
resumeData: p.resumeData,
|
|
1737
|
+
runtimeContext: p.runtimeContext,
|
|
1738
|
+
tracingOptions: p.tracingOptions
|
|
1739
|
+
});
|
|
1740
|
+
},
|
|
1741
|
+
resumeStreamVNext: async (p) => {
|
|
1742
|
+
return this.resumeStreamVNext({
|
|
1743
|
+
runId,
|
|
1744
|
+
step: p.step,
|
|
1745
|
+
resumeData: p.resumeData,
|
|
1746
|
+
runtimeContext: p.runtimeContext
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1804
1750
|
}
|
|
1805
1751
|
/**
|
|
1806
1752
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
@@ -1811,7 +1757,7 @@ var Workflow = class extends BaseResource {
|
|
|
1811
1757
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1812
1758
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1813
1759
|
method: "POST",
|
|
1814
|
-
body: { inputData: params?.inputData, runtimeContext }
|
|
1760
|
+
body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1815
1761
|
});
|
|
1816
1762
|
}
|
|
1817
1763
|
/**
|
|
@@ -1823,16 +1769,17 @@ var Workflow = class extends BaseResource {
|
|
|
1823
1769
|
step,
|
|
1824
1770
|
runId,
|
|
1825
1771
|
resumeData,
|
|
1772
|
+
tracingOptions,
|
|
1826
1773
|
...rest
|
|
1827
1774
|
}) {
|
|
1828
1775
|
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
1829
1776
|
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
1830
1777
|
method: "POST",
|
|
1831
|
-
stream: true,
|
|
1832
1778
|
body: {
|
|
1833
1779
|
step,
|
|
1834
1780
|
resumeData,
|
|
1835
|
-
runtimeContext
|
|
1781
|
+
runtimeContext,
|
|
1782
|
+
tracingOptions
|
|
1836
1783
|
}
|
|
1837
1784
|
});
|
|
1838
1785
|
}
|
|
@@ -1849,7 +1796,7 @@ var Workflow = class extends BaseResource {
|
|
|
1849
1796
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1850
1797
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1851
1798
|
method: "POST",
|
|
1852
|
-
body: { inputData: params.inputData, runtimeContext }
|
|
1799
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1853
1800
|
});
|
|
1854
1801
|
}
|
|
1855
1802
|
/**
|
|
@@ -1867,7 +1814,110 @@ var Workflow = class extends BaseResource {
|
|
|
1867
1814
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1868
1815
|
{
|
|
1869
1816
|
method: "POST",
|
|
1870
|
-
body: { inputData: params.inputData, runtimeContext },
|
|
1817
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
|
|
1818
|
+
stream: true
|
|
1819
|
+
}
|
|
1820
|
+
);
|
|
1821
|
+
if (!response.ok) {
|
|
1822
|
+
throw new Error(`Failed to stream workflow: ${response.statusText}`);
|
|
1823
|
+
}
|
|
1824
|
+
if (!response.body) {
|
|
1825
|
+
throw new Error("Response body is null");
|
|
1826
|
+
}
|
|
1827
|
+
let failedChunk = void 0;
|
|
1828
|
+
const transformStream = new TransformStream({
|
|
1829
|
+
start() {
|
|
1830
|
+
},
|
|
1831
|
+
async transform(chunk, controller) {
|
|
1832
|
+
try {
|
|
1833
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1834
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1835
|
+
for (const chunk2 of chunks) {
|
|
1836
|
+
if (chunk2) {
|
|
1837
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1838
|
+
try {
|
|
1839
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1840
|
+
controller.enqueue(parsedChunk);
|
|
1841
|
+
failedChunk = void 0;
|
|
1842
|
+
} catch {
|
|
1843
|
+
failedChunk = newChunk;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
} catch {
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
return response.body.pipeThrough(transformStream);
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Observes workflow stream for a workflow run
|
|
1855
|
+
* @param params - Object containing the runId
|
|
1856
|
+
* @returns Promise containing the workflow execution results
|
|
1857
|
+
*/
|
|
1858
|
+
async observeStream(params) {
|
|
1859
|
+
const searchParams = new URLSearchParams();
|
|
1860
|
+
searchParams.set("runId", params.runId);
|
|
1861
|
+
const response = await this.request(
|
|
1862
|
+
`/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
|
|
1863
|
+
{
|
|
1864
|
+
method: "POST",
|
|
1865
|
+
stream: true
|
|
1866
|
+
}
|
|
1867
|
+
);
|
|
1868
|
+
if (!response.ok) {
|
|
1869
|
+
throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
|
|
1870
|
+
}
|
|
1871
|
+
if (!response.body) {
|
|
1872
|
+
throw new Error("Response body is null");
|
|
1873
|
+
}
|
|
1874
|
+
let failedChunk = void 0;
|
|
1875
|
+
const transformStream = new TransformStream({
|
|
1876
|
+
start() {
|
|
1877
|
+
},
|
|
1878
|
+
async transform(chunk, controller) {
|
|
1879
|
+
try {
|
|
1880
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1881
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1882
|
+
for (const chunk2 of chunks) {
|
|
1883
|
+
if (chunk2) {
|
|
1884
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1885
|
+
try {
|
|
1886
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1887
|
+
controller.enqueue(parsedChunk);
|
|
1888
|
+
failedChunk = void 0;
|
|
1889
|
+
} catch {
|
|
1890
|
+
failedChunk = newChunk;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
} catch {
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1898
|
+
return response.body.pipeThrough(transformStream);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Starts a workflow run and returns a stream
|
|
1902
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
1903
|
+
* @returns Promise containing the workflow execution results
|
|
1904
|
+
*/
|
|
1905
|
+
async streamVNext(params) {
|
|
1906
|
+
const searchParams = new URLSearchParams();
|
|
1907
|
+
if (!!params?.runId) {
|
|
1908
|
+
searchParams.set("runId", params.runId);
|
|
1909
|
+
}
|
|
1910
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1911
|
+
const response = await this.request(
|
|
1912
|
+
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
1913
|
+
{
|
|
1914
|
+
method: "POST",
|
|
1915
|
+
body: {
|
|
1916
|
+
inputData: params.inputData,
|
|
1917
|
+
runtimeContext,
|
|
1918
|
+
closeOnSuspend: params.closeOnSuspend,
|
|
1919
|
+
tracingOptions: params.tracingOptions
|
|
1920
|
+
},
|
|
1871
1921
|
stream: true
|
|
1872
1922
|
}
|
|
1873
1923
|
);
|
|
@@ -1884,7 +1934,54 @@ var Workflow = class extends BaseResource {
|
|
|
1884
1934
|
async transform(chunk, controller) {
|
|
1885
1935
|
try {
|
|
1886
1936
|
const decoded = new TextDecoder().decode(chunk);
|
|
1887
|
-
const chunks = decoded.split(
|
|
1937
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1938
|
+
for (const chunk2 of chunks) {
|
|
1939
|
+
if (chunk2) {
|
|
1940
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1941
|
+
try {
|
|
1942
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1943
|
+
controller.enqueue(parsedChunk);
|
|
1944
|
+
failedChunk = void 0;
|
|
1945
|
+
} catch {
|
|
1946
|
+
failedChunk = newChunk;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
} catch {
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
return response.body.pipeThrough(transformStream);
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Observes workflow vNext stream for a workflow run
|
|
1958
|
+
* @param params - Object containing the runId
|
|
1959
|
+
* @returns Promise containing the workflow execution results
|
|
1960
|
+
*/
|
|
1961
|
+
async observeStreamVNext(params) {
|
|
1962
|
+
const searchParams = new URLSearchParams();
|
|
1963
|
+
searchParams.set("runId", params.runId);
|
|
1964
|
+
const response = await this.request(
|
|
1965
|
+
`/api/workflows/${this.workflowId}/observe-streamVNext?${searchParams.toString()}`,
|
|
1966
|
+
{
|
|
1967
|
+
method: "POST",
|
|
1968
|
+
stream: true
|
|
1969
|
+
}
|
|
1970
|
+
);
|
|
1971
|
+
if (!response.ok) {
|
|
1972
|
+
throw new Error(`Failed to observe stream vNext workflow: ${response.statusText}`);
|
|
1973
|
+
}
|
|
1974
|
+
if (!response.body) {
|
|
1975
|
+
throw new Error("Response body is null");
|
|
1976
|
+
}
|
|
1977
|
+
let failedChunk = void 0;
|
|
1978
|
+
const transformStream = new TransformStream({
|
|
1979
|
+
start() {
|
|
1980
|
+
},
|
|
1981
|
+
async transform(chunk, controller) {
|
|
1982
|
+
try {
|
|
1983
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1984
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1888
1985
|
for (const chunk2 of chunks) {
|
|
1889
1986
|
if (chunk2) {
|
|
1890
1987
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -1915,10 +2012,65 @@ var Workflow = class extends BaseResource {
|
|
|
1915
2012
|
body: {
|
|
1916
2013
|
step: params.step,
|
|
1917
2014
|
resumeData: params.resumeData,
|
|
1918
|
-
runtimeContext
|
|
2015
|
+
runtimeContext,
|
|
2016
|
+
tracingOptions: params.tracingOptions
|
|
1919
2017
|
}
|
|
1920
2018
|
});
|
|
1921
2019
|
}
|
|
2020
|
+
/**
|
|
2021
|
+
* Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
|
|
2022
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
2023
|
+
* @returns Promise containing the workflow resume results
|
|
2024
|
+
*/
|
|
2025
|
+
async resumeStreamVNext(params) {
|
|
2026
|
+
const searchParams = new URLSearchParams();
|
|
2027
|
+
searchParams.set("runId", params.runId);
|
|
2028
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2029
|
+
const response = await this.request(
|
|
2030
|
+
`/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
|
|
2031
|
+
{
|
|
2032
|
+
method: "POST",
|
|
2033
|
+
body: {
|
|
2034
|
+
step: params.step,
|
|
2035
|
+
resumeData: params.resumeData,
|
|
2036
|
+
runtimeContext,
|
|
2037
|
+
tracingOptions: params.tracingOptions
|
|
2038
|
+
},
|
|
2039
|
+
stream: true
|
|
2040
|
+
}
|
|
2041
|
+
);
|
|
2042
|
+
if (!response.ok) {
|
|
2043
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
2044
|
+
}
|
|
2045
|
+
if (!response.body) {
|
|
2046
|
+
throw new Error("Response body is null");
|
|
2047
|
+
}
|
|
2048
|
+
let failedChunk = void 0;
|
|
2049
|
+
const transformStream = new TransformStream({
|
|
2050
|
+
start() {
|
|
2051
|
+
},
|
|
2052
|
+
async transform(chunk, controller) {
|
|
2053
|
+
try {
|
|
2054
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2055
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2056
|
+
for (const chunk2 of chunks) {
|
|
2057
|
+
if (chunk2) {
|
|
2058
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2059
|
+
try {
|
|
2060
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2061
|
+
controller.enqueue(parsedChunk);
|
|
2062
|
+
failedChunk = void 0;
|
|
2063
|
+
} catch {
|
|
2064
|
+
failedChunk = newChunk;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
} catch {
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
return response.body.pipeThrough(transformStream);
|
|
2073
|
+
}
|
|
1922
2074
|
/**
|
|
1923
2075
|
* Watches workflow transitions in real-time
|
|
1924
2076
|
* @param runId - Optional run ID to filter the watch stream
|
|
@@ -1955,7 +2107,7 @@ var Workflow = class extends BaseResource {
|
|
|
1955
2107
|
async start(controller) {
|
|
1956
2108
|
try {
|
|
1957
2109
|
for await (const record of records) {
|
|
1958
|
-
const json = JSON.stringify(record) +
|
|
2110
|
+
const json = JSON.stringify(record) + RECORD_SEPARATOR;
|
|
1959
2111
|
controller.enqueue(encoder.encode(json));
|
|
1960
2112
|
}
|
|
1961
2113
|
controller.close();
|
|
@@ -2053,10 +2205,11 @@ var MCPTool = class extends BaseResource {
|
|
|
2053
2205
|
}
|
|
2054
2206
|
/**
|
|
2055
2207
|
* Retrieves details about this specific tool from the MCP server.
|
|
2208
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2056
2209
|
* @returns Promise containing the tool's information (name, description, schema).
|
|
2057
2210
|
*/
|
|
2058
|
-
details() {
|
|
2059
|
-
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
|
|
2211
|
+
details(runtimeContext) {
|
|
2212
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2060
2213
|
}
|
|
2061
2214
|
/**
|
|
2062
2215
|
* Executes this specific tool on the MCP server.
|
|
@@ -2077,7 +2230,7 @@ var MCPTool = class extends BaseResource {
|
|
|
2077
2230
|
};
|
|
2078
2231
|
|
|
2079
2232
|
// src/resources/agent-builder.ts
|
|
2080
|
-
var
|
|
2233
|
+
var RECORD_SEPARATOR2 = "";
|
|
2081
2234
|
var AgentBuilder = class extends BaseResource {
|
|
2082
2235
|
constructor(options, actionId) {
|
|
2083
2236
|
super(options);
|
|
@@ -2112,11 +2265,20 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2112
2265
|
};
|
|
2113
2266
|
}
|
|
2114
2267
|
}
|
|
2268
|
+
/**
|
|
2269
|
+
* @deprecated Use createRunAsync() instead.
|
|
2270
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
2271
|
+
*/
|
|
2272
|
+
async createRun(_params) {
|
|
2273
|
+
throw new Error(
|
|
2274
|
+
"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."
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2115
2277
|
/**
|
|
2116
2278
|
* Creates a new agent builder action run and returns the runId.
|
|
2117
2279
|
* This calls `/api/agent-builder/:actionId/create-run`.
|
|
2118
2280
|
*/
|
|
2119
|
-
async
|
|
2281
|
+
async createRunAsync(params) {
|
|
2120
2282
|
const searchParams = new URLSearchParams();
|
|
2121
2283
|
if (!!params?.runId) {
|
|
2122
2284
|
searchParams.set("runId", params.runId);
|
|
@@ -2126,14 +2288,6 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2126
2288
|
method: "POST"
|
|
2127
2289
|
});
|
|
2128
2290
|
}
|
|
2129
|
-
/**
|
|
2130
|
-
* Creates a new workflow run (alias for createRun)
|
|
2131
|
-
* @param params - Optional object containing the optional runId
|
|
2132
|
-
* @returns Promise containing the runId of the created run
|
|
2133
|
-
*/
|
|
2134
|
-
createRunAsync(params) {
|
|
2135
|
-
return this.createRun(params);
|
|
2136
|
-
}
|
|
2137
2291
|
/**
|
|
2138
2292
|
* Starts agent builder action asynchronously and waits for completion.
|
|
2139
2293
|
* This calls `/api/agent-builder/:actionId/start-async`.
|
|
@@ -2216,7 +2370,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2216
2370
|
if (done && !value) continue;
|
|
2217
2371
|
try {
|
|
2218
2372
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2219
|
-
const chunks = (buffer + decoded).split(
|
|
2373
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
2220
2374
|
buffer = chunks.pop() || "";
|
|
2221
2375
|
for (const chunk of chunks) {
|
|
2222
2376
|
if (chunk) {
|
|
@@ -2273,7 +2427,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2273
2427
|
async transform(chunk, controller) {
|
|
2274
2428
|
try {
|
|
2275
2429
|
const decoded = new TextDecoder().decode(chunk);
|
|
2276
|
-
const chunks = decoded.split(
|
|
2430
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2277
2431
|
for (const chunk2 of chunks) {
|
|
2278
2432
|
if (chunk2) {
|
|
2279
2433
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2322,7 +2476,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2322
2476
|
async transform(chunk, controller) {
|
|
2323
2477
|
try {
|
|
2324
2478
|
const decoded = new TextDecoder().decode(chunk);
|
|
2325
|
-
const chunks = decoded.split(
|
|
2479
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2326
2480
|
for (const chunk2 of chunks) {
|
|
2327
2481
|
if (chunk2) {
|
|
2328
2482
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2493,6 +2647,31 @@ var Observability = class extends BaseResource {
|
|
|
2493
2647
|
const queryString = searchParams.toString();
|
|
2494
2648
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2495
2649
|
}
|
|
2650
|
+
/**
|
|
2651
|
+
* Retrieves scores by trace ID and span ID
|
|
2652
|
+
* @param params - Parameters containing trace ID, span ID, and pagination options
|
|
2653
|
+
* @returns Promise containing scores and pagination info
|
|
2654
|
+
*/
|
|
2655
|
+
getScoresBySpan(params) {
|
|
2656
|
+
const { traceId, spanId, page, perPage } = params;
|
|
2657
|
+
const searchParams = new URLSearchParams();
|
|
2658
|
+
if (page !== void 0) {
|
|
2659
|
+
searchParams.set("page", String(page));
|
|
2660
|
+
}
|
|
2661
|
+
if (perPage !== void 0) {
|
|
2662
|
+
searchParams.set("perPage", String(perPage));
|
|
2663
|
+
}
|
|
2664
|
+
const queryString = searchParams.toString();
|
|
2665
|
+
return this.request(
|
|
2666
|
+
`/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
|
|
2667
|
+
);
|
|
2668
|
+
}
|
|
2669
|
+
score(params) {
|
|
2670
|
+
return this.request(`/api/observability/traces/score`, {
|
|
2671
|
+
method: "POST",
|
|
2672
|
+
body: { ...params }
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2496
2675
|
};
|
|
2497
2676
|
|
|
2498
2677
|
// src/resources/network-memory-thread.ts
|
|
@@ -2558,144 +2737,6 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2558
2737
|
}
|
|
2559
2738
|
};
|
|
2560
2739
|
|
|
2561
|
-
// src/resources/vNextNetwork.ts
|
|
2562
|
-
var RECORD_SEPARATOR4 = "";
|
|
2563
|
-
var VNextNetwork = class extends BaseResource {
|
|
2564
|
-
constructor(options, networkId) {
|
|
2565
|
-
super(options);
|
|
2566
|
-
this.networkId = networkId;
|
|
2567
|
-
}
|
|
2568
|
-
/**
|
|
2569
|
-
* Retrieves details about the network
|
|
2570
|
-
* @returns Promise containing vNext network details
|
|
2571
|
-
*/
|
|
2572
|
-
details() {
|
|
2573
|
-
return this.request(`/api/networks/v-next/${this.networkId}`);
|
|
2574
|
-
}
|
|
2575
|
-
/**
|
|
2576
|
-
* Generates a response from the v-next network
|
|
2577
|
-
* @param params - Generation parameters including message
|
|
2578
|
-
* @returns Promise containing the generated response
|
|
2579
|
-
*/
|
|
2580
|
-
generate(params) {
|
|
2581
|
-
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
2582
|
-
method: "POST",
|
|
2583
|
-
body: {
|
|
2584
|
-
...params,
|
|
2585
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2586
|
-
}
|
|
2587
|
-
});
|
|
2588
|
-
}
|
|
2589
|
-
/**
|
|
2590
|
-
* Generates a response from the v-next network using multiple primitives
|
|
2591
|
-
* @param params - Generation parameters including message
|
|
2592
|
-
* @returns Promise containing the generated response
|
|
2593
|
-
*/
|
|
2594
|
-
loop(params) {
|
|
2595
|
-
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
2596
|
-
method: "POST",
|
|
2597
|
-
body: {
|
|
2598
|
-
...params,
|
|
2599
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2603
|
-
async *streamProcessor(stream) {
|
|
2604
|
-
const reader = stream.getReader();
|
|
2605
|
-
let doneReading = false;
|
|
2606
|
-
let buffer = "";
|
|
2607
|
-
try {
|
|
2608
|
-
while (!doneReading) {
|
|
2609
|
-
const { done, value } = await reader.read();
|
|
2610
|
-
doneReading = done;
|
|
2611
|
-
if (done && !value) continue;
|
|
2612
|
-
try {
|
|
2613
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2614
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
|
|
2615
|
-
buffer = chunks.pop() || "";
|
|
2616
|
-
for (const chunk of chunks) {
|
|
2617
|
-
if (chunk) {
|
|
2618
|
-
if (typeof chunk === "string") {
|
|
2619
|
-
try {
|
|
2620
|
-
const parsedChunk = JSON.parse(chunk);
|
|
2621
|
-
yield parsedChunk;
|
|
2622
|
-
} catch {
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
} catch {
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
if (buffer) {
|
|
2631
|
-
try {
|
|
2632
|
-
yield JSON.parse(buffer);
|
|
2633
|
-
} catch {
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
} finally {
|
|
2637
|
-
reader.cancel().catch(() => {
|
|
2638
|
-
});
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
/**
|
|
2642
|
-
* Streams a response from the v-next network
|
|
2643
|
-
* @param params - Stream parameters including message
|
|
2644
|
-
* @returns Promise containing the results
|
|
2645
|
-
*/
|
|
2646
|
-
async stream(params, onRecord) {
|
|
2647
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
2648
|
-
method: "POST",
|
|
2649
|
-
body: {
|
|
2650
|
-
...params,
|
|
2651
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2652
|
-
},
|
|
2653
|
-
stream: true
|
|
2654
|
-
});
|
|
2655
|
-
if (!response.ok) {
|
|
2656
|
-
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
2657
|
-
}
|
|
2658
|
-
if (!response.body) {
|
|
2659
|
-
throw new Error("Response body is null");
|
|
2660
|
-
}
|
|
2661
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2662
|
-
if (typeof record === "string") {
|
|
2663
|
-
onRecord(JSON.parse(record));
|
|
2664
|
-
} else {
|
|
2665
|
-
onRecord(record);
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
/**
|
|
2670
|
-
* Streams a response from the v-next network loop
|
|
2671
|
-
* @param params - Stream parameters including message
|
|
2672
|
-
* @returns Promise containing the results
|
|
2673
|
-
*/
|
|
2674
|
-
async loopStream(params, onRecord) {
|
|
2675
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
2676
|
-
method: "POST",
|
|
2677
|
-
body: {
|
|
2678
|
-
...params,
|
|
2679
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2680
|
-
},
|
|
2681
|
-
stream: true
|
|
2682
|
-
});
|
|
2683
|
-
if (!response.ok) {
|
|
2684
|
-
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
2685
|
-
}
|
|
2686
|
-
if (!response.body) {
|
|
2687
|
-
throw new Error("Response body is null");
|
|
2688
|
-
}
|
|
2689
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2690
|
-
if (typeof record === "string") {
|
|
2691
|
-
onRecord(JSON.parse(record));
|
|
2692
|
-
} else {
|
|
2693
|
-
onRecord(record);
|
|
2694
|
-
}
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
};
|
|
2698
|
-
|
|
2699
2740
|
// src/client.ts
|
|
2700
2741
|
var MastraClient = class extends BaseResource {
|
|
2701
2742
|
observability;
|
|
@@ -2705,10 +2746,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2705
2746
|
}
|
|
2706
2747
|
/**
|
|
2707
2748
|
* Retrieves all available agents
|
|
2749
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2708
2750
|
* @returns Promise containing map of agent IDs to agent details
|
|
2709
2751
|
*/
|
|
2710
|
-
getAgents() {
|
|
2711
|
-
|
|
2752
|
+
getAgents(runtimeContext) {
|
|
2753
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2754
|
+
const searchParams = new URLSearchParams();
|
|
2755
|
+
if (runtimeContextParam) {
|
|
2756
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2757
|
+
}
|
|
2758
|
+
const queryString = searchParams.toString();
|
|
2759
|
+
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2712
2760
|
}
|
|
2713
2761
|
/**
|
|
2714
2762
|
* Gets an agent instance by ID
|
|
@@ -2726,6 +2774,14 @@ var MastraClient = class extends BaseResource {
|
|
|
2726
2774
|
getMemoryThreads(params) {
|
|
2727
2775
|
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
2728
2776
|
}
|
|
2777
|
+
/**
|
|
2778
|
+
* Retrieves memory config for a resource
|
|
2779
|
+
* @param params - Parameters containing the resource ID
|
|
2780
|
+
* @returns Promise containing array of memory threads
|
|
2781
|
+
*/
|
|
2782
|
+
getMemoryConfig(params) {
|
|
2783
|
+
return this.request(`/api/memory/config?agentId=${params.agentId}`);
|
|
2784
|
+
}
|
|
2729
2785
|
/**
|
|
2730
2786
|
* Creates a new memory thread
|
|
2731
2787
|
* @param params - Parameters for creating the memory thread
|
|
@@ -2742,6 +2798,24 @@ var MastraClient = class extends BaseResource {
|
|
|
2742
2798
|
getMemoryThread(threadId, agentId) {
|
|
2743
2799
|
return new MemoryThread(this.options, threadId, agentId);
|
|
2744
2800
|
}
|
|
2801
|
+
getThreadMessages(threadId, opts = {}) {
|
|
2802
|
+
let url = "";
|
|
2803
|
+
if (opts.agentId) {
|
|
2804
|
+
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
|
|
2805
|
+
} else if (opts.networkId) {
|
|
2806
|
+
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
|
|
2807
|
+
}
|
|
2808
|
+
return this.request(url);
|
|
2809
|
+
}
|
|
2810
|
+
deleteThread(threadId, opts = {}) {
|
|
2811
|
+
let url = "";
|
|
2812
|
+
if (opts.agentId) {
|
|
2813
|
+
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
|
|
2814
|
+
} else if (opts.networkId) {
|
|
2815
|
+
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
|
|
2816
|
+
}
|
|
2817
|
+
return this.request(url, { method: "DELETE" });
|
|
2818
|
+
}
|
|
2745
2819
|
/**
|
|
2746
2820
|
* Saves messages to memory
|
|
2747
2821
|
* @param params - Parameters containing messages to save
|
|
@@ -2804,10 +2878,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2804
2878
|
}
|
|
2805
2879
|
/**
|
|
2806
2880
|
* Retrieves all available tools
|
|
2881
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2807
2882
|
* @returns Promise containing map of tool IDs to tool details
|
|
2808
2883
|
*/
|
|
2809
|
-
getTools() {
|
|
2810
|
-
|
|
2884
|
+
getTools(runtimeContext) {
|
|
2885
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2886
|
+
const searchParams = new URLSearchParams();
|
|
2887
|
+
if (runtimeContextParam) {
|
|
2888
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2889
|
+
}
|
|
2890
|
+
const queryString = searchParams.toString();
|
|
2891
|
+
return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
|
|
2811
2892
|
}
|
|
2812
2893
|
/**
|
|
2813
2894
|
* Gets a tool instance by ID
|
|
@@ -2817,27 +2898,19 @@ var MastraClient = class extends BaseResource {
|
|
|
2817
2898
|
getTool(toolId) {
|
|
2818
2899
|
return new Tool(this.options, toolId);
|
|
2819
2900
|
}
|
|
2820
|
-
/**
|
|
2821
|
-
* Retrieves all available legacy workflows
|
|
2822
|
-
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
2823
|
-
*/
|
|
2824
|
-
getLegacyWorkflows() {
|
|
2825
|
-
return this.request("/api/workflows/legacy");
|
|
2826
|
-
}
|
|
2827
|
-
/**
|
|
2828
|
-
* Gets a legacy workflow instance by ID
|
|
2829
|
-
* @param workflowId - ID of the legacy workflow to retrieve
|
|
2830
|
-
* @returns Legacy Workflow instance
|
|
2831
|
-
*/
|
|
2832
|
-
getLegacyWorkflow(workflowId) {
|
|
2833
|
-
return new LegacyWorkflow(this.options, workflowId);
|
|
2834
|
-
}
|
|
2835
2901
|
/**
|
|
2836
2902
|
* Retrieves all available workflows
|
|
2903
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2837
2904
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
2838
2905
|
*/
|
|
2839
|
-
getWorkflows() {
|
|
2840
|
-
|
|
2906
|
+
getWorkflows(runtimeContext) {
|
|
2907
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2908
|
+
const searchParams = new URLSearchParams();
|
|
2909
|
+
if (runtimeContextParam) {
|
|
2910
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2911
|
+
}
|
|
2912
|
+
const queryString = searchParams.toString();
|
|
2913
|
+
return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
|
|
2841
2914
|
}
|
|
2842
2915
|
/**
|
|
2843
2916
|
* Gets a workflow instance by ID
|
|
@@ -3005,36 +3078,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3005
3078
|
return this.request(`/api/telemetry`);
|
|
3006
3079
|
}
|
|
3007
3080
|
}
|
|
3008
|
-
/**
|
|
3009
|
-
* Retrieves all available networks
|
|
3010
|
-
* @returns Promise containing map of network IDs to network details
|
|
3011
|
-
*/
|
|
3012
|
-
getNetworks() {
|
|
3013
|
-
return this.request("/api/networks");
|
|
3014
|
-
}
|
|
3015
|
-
/**
|
|
3016
|
-
* Retrieves all available vNext networks
|
|
3017
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
3018
|
-
*/
|
|
3019
|
-
getVNextNetworks() {
|
|
3020
|
-
return this.request("/api/networks/v-next");
|
|
3021
|
-
}
|
|
3022
|
-
/**
|
|
3023
|
-
* Gets a network instance by ID
|
|
3024
|
-
* @param networkId - ID of the network to retrieve
|
|
3025
|
-
* @returns Network instance
|
|
3026
|
-
*/
|
|
3027
|
-
getNetwork(networkId) {
|
|
3028
|
-
return new Network(this.options, networkId);
|
|
3029
|
-
}
|
|
3030
|
-
/**
|
|
3031
|
-
* Gets a vNext network instance by ID
|
|
3032
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
3033
|
-
* @returns vNext Network instance
|
|
3034
|
-
*/
|
|
3035
|
-
getVNextNetwork(networkId) {
|
|
3036
|
-
return new VNextNetwork(this.options, networkId);
|
|
3037
|
-
}
|
|
3038
3081
|
/**
|
|
3039
3082
|
* Retrieves a list of available MCP servers.
|
|
3040
3083
|
* @param params - Optional parameters for pagination (limit, offset).
|
|
@@ -3139,7 +3182,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3139
3182
|
* @returns Promise containing the scorer
|
|
3140
3183
|
*/
|
|
3141
3184
|
getScorer(scorerId) {
|
|
3142
|
-
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
3185
|
+
return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
|
|
3143
3186
|
}
|
|
3144
3187
|
getScoresByScorerId(params) {
|
|
3145
3188
|
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
@@ -3157,7 +3200,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3157
3200
|
searchParams.set("perPage", String(perPage));
|
|
3158
3201
|
}
|
|
3159
3202
|
const queryString = searchParams.toString();
|
|
3160
|
-
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
3203
|
+
return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
|
|
3161
3204
|
}
|
|
3162
3205
|
/**
|
|
3163
3206
|
* Retrieves scores by run ID
|
|
@@ -3174,7 +3217,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3174
3217
|
searchParams.set("perPage", String(perPage));
|
|
3175
3218
|
}
|
|
3176
3219
|
const queryString = searchParams.toString();
|
|
3177
|
-
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
3220
|
+
return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
|
|
3178
3221
|
}
|
|
3179
3222
|
/**
|
|
3180
3223
|
* Retrieves scores by entity ID and type
|
|
@@ -3191,7 +3234,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3191
3234
|
searchParams.set("perPage", String(perPage));
|
|
3192
3235
|
}
|
|
3193
3236
|
const queryString = searchParams.toString();
|
|
3194
|
-
return this.request(
|
|
3237
|
+
return this.request(
|
|
3238
|
+
`/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
|
|
3239
|
+
);
|
|
3195
3240
|
}
|
|
3196
3241
|
/**
|
|
3197
3242
|
* Saves a score
|
|
@@ -3217,8 +3262,35 @@ var MastraClient = class extends BaseResource {
|
|
|
3217
3262
|
getAITraces(params) {
|
|
3218
3263
|
return this.observability.getTraces(params);
|
|
3219
3264
|
}
|
|
3265
|
+
getScoresBySpan(params) {
|
|
3266
|
+
return this.observability.getScoresBySpan(params);
|
|
3267
|
+
}
|
|
3268
|
+
score(params) {
|
|
3269
|
+
return this.observability.score(params);
|
|
3270
|
+
}
|
|
3220
3271
|
};
|
|
3221
3272
|
|
|
3273
|
+
// src/tools.ts
|
|
3274
|
+
var ClientTool = class {
|
|
3275
|
+
id;
|
|
3276
|
+
description;
|
|
3277
|
+
inputSchema;
|
|
3278
|
+
outputSchema;
|
|
3279
|
+
execute;
|
|
3280
|
+
constructor(opts) {
|
|
3281
|
+
this.id = opts.id;
|
|
3282
|
+
this.description = opts.description;
|
|
3283
|
+
this.inputSchema = opts.inputSchema;
|
|
3284
|
+
this.outputSchema = opts.outputSchema;
|
|
3285
|
+
this.execute = opts.execute;
|
|
3286
|
+
}
|
|
3287
|
+
};
|
|
3288
|
+
function createTool(opts) {
|
|
3289
|
+
return new ClientTool(opts);
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
exports.ClientTool = ClientTool;
|
|
3222
3293
|
exports.MastraClient = MastraClient;
|
|
3294
|
+
exports.createTool = createTool;
|
|
3223
3295
|
//# sourceMappingURL=index.cjs.map
|
|
3224
3296
|
//# sourceMappingURL=index.cjs.map
|