@mastra/client-js 0.0.0-fix-zod-to-json-schema-ref-strategy-20250910193441 → 0.0.0-fix-cloud-peer-deps-20250923194656
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 +217 -4
- package/README.md +2 -6
- package/dist/client.d.ts +36 -16
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +373 -135
- 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 +372 -136
- 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 +48 -12
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +0 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/legacy-workflow.d.ts +5 -2
- package/dist/resources/legacy-workflow.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 +10 -0
- 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/vNextNetwork.d.ts +2 -1
- package/dist/resources/vNextNetwork.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 +96 -11
- 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 +50 -22
- 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/network.d.ts +0 -30
- package/dist/resources/network.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
|
}
|
|
@@ -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,
|
|
@@ -261,17 +295,21 @@ var AgentVoice = class extends BaseResource {
|
|
|
261
295
|
}
|
|
262
296
|
/**
|
|
263
297
|
* Get available speakers for the agent's voice provider
|
|
298
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
299
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
264
300
|
* @returns Promise containing list of available speakers
|
|
265
301
|
*/
|
|
266
|
-
getSpeakers() {
|
|
267
|
-
return this.request(`/api/agents/${this.agentId}/voice/speakers`);
|
|
302
|
+
getSpeakers(runtimeContext) {
|
|
303
|
+
return this.request(`/api/agents/${this.agentId}/voice/speakers${runtimeContextQueryString(runtimeContext)}`);
|
|
268
304
|
}
|
|
269
305
|
/**
|
|
270
306
|
* Get the listener configuration for the agent's voice provider
|
|
307
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
308
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
271
309
|
* @returns Promise containing a check if the agent has listening capabilities
|
|
272
310
|
*/
|
|
273
|
-
getListener() {
|
|
274
|
-
return this.request(`/api/agents/${this.agentId}/voice/listener`);
|
|
311
|
+
getListener(runtimeContext) {
|
|
312
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener${runtimeContextQueryString(runtimeContext)}`);
|
|
275
313
|
}
|
|
276
314
|
};
|
|
277
315
|
var Agent = class extends BaseResource {
|
|
@@ -283,14 +321,15 @@ var Agent = class extends BaseResource {
|
|
|
283
321
|
voice;
|
|
284
322
|
/**
|
|
285
323
|
* Retrieves details about the agent
|
|
324
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
286
325
|
* @returns Promise containing agent details including model and instructions
|
|
287
326
|
*/
|
|
288
|
-
details() {
|
|
289
|
-
return this.request(`/api/agents/${this.agentId}`);
|
|
327
|
+
details(runtimeContext) {
|
|
328
|
+
return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
|
|
290
329
|
}
|
|
291
330
|
async generate(params) {
|
|
292
331
|
console.warn(
|
|
293
|
-
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September
|
|
332
|
+
"Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 30th, 2025. Please use generateLegacy if you don't want to upgrade just yet."
|
|
294
333
|
);
|
|
295
334
|
return this.generateLegacy(params);
|
|
296
335
|
}
|
|
@@ -325,7 +364,9 @@ var Agent = class extends BaseResource {
|
|
|
325
364
|
resourceId,
|
|
326
365
|
threadId,
|
|
327
366
|
runtimeContext,
|
|
328
|
-
tracingContext: { currentSpan: void 0 }
|
|
367
|
+
tracingContext: { currentSpan: void 0 },
|
|
368
|
+
suspend: async () => {
|
|
369
|
+
}
|
|
329
370
|
},
|
|
330
371
|
{
|
|
331
372
|
messages: response.messages,
|
|
@@ -359,7 +400,16 @@ var Agent = class extends BaseResource {
|
|
|
359
400
|
}
|
|
360
401
|
return response;
|
|
361
402
|
}
|
|
362
|
-
async generateVNext(
|
|
403
|
+
async generateVNext(messagesOrParams, options) {
|
|
404
|
+
let params;
|
|
405
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
406
|
+
params = messagesOrParams;
|
|
407
|
+
} else {
|
|
408
|
+
params = {
|
|
409
|
+
messages: messagesOrParams,
|
|
410
|
+
...options
|
|
411
|
+
};
|
|
412
|
+
}
|
|
363
413
|
const processedParams = {
|
|
364
414
|
...params,
|
|
365
415
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
@@ -660,7 +710,7 @@ var Agent = class extends BaseResource {
|
|
|
660
710
|
*/
|
|
661
711
|
async stream(params) {
|
|
662
712
|
console.warn(
|
|
663
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September
|
|
713
|
+
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 30th, 2025. Please use streamLegacy if you don't want to upgrade just yet."
|
|
664
714
|
);
|
|
665
715
|
return this.streamLegacy(params);
|
|
666
716
|
}
|
|
@@ -1009,7 +1059,9 @@ var Agent = class extends BaseResource {
|
|
|
1009
1059
|
threadId: processedParams.threadId,
|
|
1010
1060
|
runtimeContext: processedParams.runtimeContext,
|
|
1011
1061
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1012
|
-
tracingContext: { currentSpan: void 0 }
|
|
1062
|
+
tracingContext: { currentSpan: void 0 },
|
|
1063
|
+
suspend: async () => {
|
|
1064
|
+
}
|
|
1013
1065
|
},
|
|
1014
1066
|
{
|
|
1015
1067
|
messages: response.messages,
|
|
@@ -1064,7 +1116,40 @@ var Agent = class extends BaseResource {
|
|
|
1064
1116
|
}
|
|
1065
1117
|
return response;
|
|
1066
1118
|
}
|
|
1067
|
-
async
|
|
1119
|
+
async network(params) {
|
|
1120
|
+
const response = await this.request(`/api/agents/${this.agentId}/network`, {
|
|
1121
|
+
method: "POST",
|
|
1122
|
+
body: params,
|
|
1123
|
+
stream: true
|
|
1124
|
+
});
|
|
1125
|
+
if (!response.body) {
|
|
1126
|
+
throw new Error("No response body");
|
|
1127
|
+
}
|
|
1128
|
+
const streamResponse = new Response(response.body, {
|
|
1129
|
+
status: response.status,
|
|
1130
|
+
statusText: response.statusText,
|
|
1131
|
+
headers: response.headers
|
|
1132
|
+
});
|
|
1133
|
+
streamResponse.processDataStream = async ({
|
|
1134
|
+
onChunk
|
|
1135
|
+
}) => {
|
|
1136
|
+
await processMastraNetworkStream({
|
|
1137
|
+
stream: streamResponse.body,
|
|
1138
|
+
onChunk
|
|
1139
|
+
});
|
|
1140
|
+
};
|
|
1141
|
+
return streamResponse;
|
|
1142
|
+
}
|
|
1143
|
+
async streamVNext(messagesOrParams, options) {
|
|
1144
|
+
let params;
|
|
1145
|
+
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
1146
|
+
params = messagesOrParams;
|
|
1147
|
+
} else {
|
|
1148
|
+
params = {
|
|
1149
|
+
messages: messagesOrParams,
|
|
1150
|
+
...options
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1068
1153
|
const processedParams = {
|
|
1069
1154
|
...params,
|
|
1070
1155
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
@@ -1140,7 +1225,9 @@ var Agent = class extends BaseResource {
|
|
|
1140
1225
|
threadId: processedParams.threadId,
|
|
1141
1226
|
runtimeContext: processedParams.runtimeContext,
|
|
1142
1227
|
// TODO: Pass proper tracing context when client-js supports tracing
|
|
1143
|
-
tracingContext: { currentSpan: void 0 }
|
|
1228
|
+
tracingContext: { currentSpan: void 0 },
|
|
1229
|
+
suspend: async () => {
|
|
1230
|
+
}
|
|
1144
1231
|
},
|
|
1145
1232
|
{
|
|
1146
1233
|
messages: response.messages,
|
|
@@ -1209,10 +1296,11 @@ var Agent = class extends BaseResource {
|
|
|
1209
1296
|
/**
|
|
1210
1297
|
* Gets details about a specific tool available to the agent
|
|
1211
1298
|
* @param toolId - ID of the tool to retrieve
|
|
1299
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1212
1300
|
* @returns Promise containing tool details
|
|
1213
1301
|
*/
|
|
1214
|
-
getTool(toolId) {
|
|
1215
|
-
return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
|
|
1302
|
+
getTool(toolId, runtimeContext) {
|
|
1303
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1216
1304
|
}
|
|
1217
1305
|
/**
|
|
1218
1306
|
* Executes a tool for the agent
|
|
@@ -1223,7 +1311,7 @@ var Agent = class extends BaseResource {
|
|
|
1223
1311
|
executeTool(toolId, params) {
|
|
1224
1312
|
const body = {
|
|
1225
1313
|
data: params.data,
|
|
1226
|
-
runtimeContext:
|
|
1314
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1227
1315
|
};
|
|
1228
1316
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
1229
1317
|
method: "POST",
|
|
@@ -1232,17 +1320,19 @@ var Agent = class extends BaseResource {
|
|
|
1232
1320
|
}
|
|
1233
1321
|
/**
|
|
1234
1322
|
* Retrieves evaluation results for the agent
|
|
1323
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1235
1324
|
* @returns Promise containing agent evaluations
|
|
1236
1325
|
*/
|
|
1237
|
-
evals() {
|
|
1238
|
-
return this.request(`/api/agents/${this.agentId}/evals/ci`);
|
|
1326
|
+
evals(runtimeContext) {
|
|
1327
|
+
return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
|
|
1239
1328
|
}
|
|
1240
1329
|
/**
|
|
1241
1330
|
* Retrieves live evaluation results for the agent
|
|
1331
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1242
1332
|
* @returns Promise containing live agent evaluations
|
|
1243
1333
|
*/
|
|
1244
|
-
liveEvals() {
|
|
1245
|
-
return this.request(`/api/agents/${this.agentId}/evals/live`);
|
|
1334
|
+
liveEvals(runtimeContext) {
|
|
1335
|
+
return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
|
|
1246
1336
|
}
|
|
1247
1337
|
/**
|
|
1248
1338
|
* Updates the model for the agent
|
|
@@ -1255,61 +1345,27 @@ var Agent = class extends BaseResource {
|
|
|
1255
1345
|
body: params
|
|
1256
1346
|
});
|
|
1257
1347
|
}
|
|
1258
|
-
};
|
|
1259
|
-
var Network = class extends BaseResource {
|
|
1260
|
-
constructor(options, networkId) {
|
|
1261
|
-
super(options);
|
|
1262
|
-
this.networkId = networkId;
|
|
1263
|
-
}
|
|
1264
1348
|
/**
|
|
1265
|
-
*
|
|
1266
|
-
* @
|
|
1267
|
-
|
|
1268
|
-
details() {
|
|
1269
|
-
return this.request(`/api/networks/${this.networkId}`);
|
|
1270
|
-
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Generates a response from the agent
|
|
1273
|
-
* @param params - Generation parameters including prompt
|
|
1274
|
-
* @returns Promise containing the generated response
|
|
1349
|
+
* Updates the model for the agent in the model list
|
|
1350
|
+
* @param params - Parameters for updating the model
|
|
1351
|
+
* @returns Promise containing the updated model
|
|
1275
1352
|
*/
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
...params,
|
|
1279
|
-
output: zodToJsonSchema(params.output),
|
|
1280
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1281
|
-
};
|
|
1282
|
-
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
1353
|
+
updateModelInModelList({ modelConfigId, ...params }) {
|
|
1354
|
+
return this.request(`/api/agents/${this.agentId}/models/${modelConfigId}`, {
|
|
1283
1355
|
method: "POST",
|
|
1284
|
-
body:
|
|
1356
|
+
body: params
|
|
1285
1357
|
});
|
|
1286
1358
|
}
|
|
1287
1359
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
* @param params -
|
|
1290
|
-
* @returns Promise containing the
|
|
1360
|
+
* Reorders the models for the agent
|
|
1361
|
+
* @param params - Parameters for reordering the model list
|
|
1362
|
+
* @returns Promise containing the updated model list
|
|
1291
1363
|
*/
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
...params,
|
|
1295
|
-
output: zodToJsonSchema(params.output),
|
|
1296
|
-
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
1297
|
-
};
|
|
1298
|
-
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
1364
|
+
reorderModelList(params) {
|
|
1365
|
+
return this.request(`/api/agents/${this.agentId}/models/reorder`, {
|
|
1299
1366
|
method: "POST",
|
|
1300
|
-
body:
|
|
1301
|
-
stream: true
|
|
1367
|
+
body: params
|
|
1302
1368
|
});
|
|
1303
|
-
if (!response.body) {
|
|
1304
|
-
throw new Error("No response body");
|
|
1305
|
-
}
|
|
1306
|
-
response.processDataStream = async (options = {}) => {
|
|
1307
|
-
await uiUtils.processDataStream({
|
|
1308
|
-
stream: response.body,
|
|
1309
|
-
...options
|
|
1310
|
-
});
|
|
1311
|
-
};
|
|
1312
|
-
return response;
|
|
1313
1369
|
}
|
|
1314
1370
|
};
|
|
1315
1371
|
|
|
@@ -1400,10 +1456,13 @@ var Vector = class extends BaseResource {
|
|
|
1400
1456
|
/**
|
|
1401
1457
|
* Retrieves details about a specific vector index
|
|
1402
1458
|
* @param indexName - Name of the index to get details for
|
|
1459
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1403
1460
|
* @returns Promise containing vector index details
|
|
1404
1461
|
*/
|
|
1405
|
-
details(indexName) {
|
|
1406
|
-
return this.request(
|
|
1462
|
+
details(indexName, runtimeContext) {
|
|
1463
|
+
return this.request(
|
|
1464
|
+
`/api/vector/${this.vectorName}/indexes/${indexName}${runtimeContextQueryString(runtimeContext)}`
|
|
1465
|
+
);
|
|
1407
1466
|
}
|
|
1408
1467
|
/**
|
|
1409
1468
|
* Deletes a vector index
|
|
@@ -1417,10 +1476,11 @@ var Vector = class extends BaseResource {
|
|
|
1417
1476
|
}
|
|
1418
1477
|
/**
|
|
1419
1478
|
* Retrieves a list of all available indexes
|
|
1479
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1420
1480
|
* @returns Promise containing array of index names
|
|
1421
1481
|
*/
|
|
1422
|
-
getIndexes() {
|
|
1423
|
-
return this.request(`/api/vector/${this.vectorName}/indexes`);
|
|
1482
|
+
getIndexes(runtimeContext) {
|
|
1483
|
+
return this.request(`/api/vector/${this.vectorName}/indexes${runtimeContextQueryString(runtimeContext)}`);
|
|
1424
1484
|
}
|
|
1425
1485
|
/**
|
|
1426
1486
|
* Creates a new vector index
|
|
@@ -1466,17 +1526,20 @@ var LegacyWorkflow = class extends BaseResource {
|
|
|
1466
1526
|
}
|
|
1467
1527
|
/**
|
|
1468
1528
|
* Retrieves details about the legacy workflow
|
|
1529
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1469
1530
|
* @returns Promise containing legacy workflow details including steps and graphs
|
|
1470
1531
|
*/
|
|
1471
|
-
details() {
|
|
1472
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
1532
|
+
details(runtimeContext) {
|
|
1533
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1473
1534
|
}
|
|
1474
1535
|
/**
|
|
1475
1536
|
* Retrieves all runs for a legacy workflow
|
|
1476
1537
|
* @param params - Parameters for filtering runs
|
|
1538
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1477
1539
|
* @returns Promise containing legacy workflow runs array
|
|
1478
1540
|
*/
|
|
1479
|
-
runs(params) {
|
|
1541
|
+
runs(params, runtimeContext) {
|
|
1542
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1480
1543
|
const searchParams = new URLSearchParams();
|
|
1481
1544
|
if (params?.fromDate) {
|
|
1482
1545
|
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
@@ -1493,6 +1556,9 @@ var LegacyWorkflow = class extends BaseResource {
|
|
|
1493
1556
|
if (params?.resourceId) {
|
|
1494
1557
|
searchParams.set("resourceId", params.resourceId);
|
|
1495
1558
|
}
|
|
1559
|
+
if (runtimeContextParam) {
|
|
1560
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1561
|
+
}
|
|
1496
1562
|
if (searchParams.size) {
|
|
1497
1563
|
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
1498
1564
|
} else {
|
|
@@ -1646,10 +1712,11 @@ var Tool = class extends BaseResource {
|
|
|
1646
1712
|
}
|
|
1647
1713
|
/**
|
|
1648
1714
|
* Retrieves details about the tool
|
|
1715
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1649
1716
|
* @returns Promise containing tool details including description and schemas
|
|
1650
1717
|
*/
|
|
1651
|
-
details() {
|
|
1652
|
-
return this.request(`/api/tools/${this.toolId}`);
|
|
1718
|
+
details(runtimeContext) {
|
|
1719
|
+
return this.request(`/api/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1653
1720
|
}
|
|
1654
1721
|
/**
|
|
1655
1722
|
* Executes the tool with the provided parameters
|
|
@@ -1726,17 +1793,20 @@ var Workflow = class extends BaseResource {
|
|
|
1726
1793
|
}
|
|
1727
1794
|
/**
|
|
1728
1795
|
* Retrieves details about the workflow
|
|
1796
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1729
1797
|
* @returns Promise containing workflow details including steps and graphs
|
|
1730
1798
|
*/
|
|
1731
|
-
details() {
|
|
1732
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
1799
|
+
details(runtimeContext) {
|
|
1800
|
+
return this.request(`/api/workflows/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1733
1801
|
}
|
|
1734
1802
|
/**
|
|
1735
1803
|
* Retrieves all runs for a workflow
|
|
1736
1804
|
* @param params - Parameters for filtering runs
|
|
1805
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1737
1806
|
* @returns Promise containing workflow runs array
|
|
1738
1807
|
*/
|
|
1739
|
-
runs(params) {
|
|
1808
|
+
runs(params, runtimeContext) {
|
|
1809
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1740
1810
|
const searchParams = new URLSearchParams();
|
|
1741
1811
|
if (params?.fromDate) {
|
|
1742
1812
|
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
@@ -1753,6 +1823,9 @@ var Workflow = class extends BaseResource {
|
|
|
1753
1823
|
if (params?.resourceId) {
|
|
1754
1824
|
searchParams.set("resourceId", params.resourceId);
|
|
1755
1825
|
}
|
|
1826
|
+
if (runtimeContextParam) {
|
|
1827
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1828
|
+
}
|
|
1756
1829
|
if (searchParams.size) {
|
|
1757
1830
|
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
1758
1831
|
} else {
|
|
@@ -1762,18 +1835,22 @@ var Workflow = class extends BaseResource {
|
|
|
1762
1835
|
/**
|
|
1763
1836
|
* Retrieves a specific workflow run by its ID
|
|
1764
1837
|
* @param runId - The ID of the workflow run to retrieve
|
|
1838
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1765
1839
|
* @returns Promise containing the workflow run details
|
|
1766
1840
|
*/
|
|
1767
|
-
runById(runId) {
|
|
1768
|
-
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
|
|
1841
|
+
runById(runId, runtimeContext) {
|
|
1842
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1769
1843
|
}
|
|
1770
1844
|
/**
|
|
1771
1845
|
* Retrieves the execution result for a specific workflow run by its ID
|
|
1772
1846
|
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
1847
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1773
1848
|
* @returns Promise containing the workflow run execution result
|
|
1774
1849
|
*/
|
|
1775
|
-
runExecutionResult(runId) {
|
|
1776
|
-
return this.request(
|
|
1850
|
+
runExecutionResult(runId, runtimeContext) {
|
|
1851
|
+
return this.request(
|
|
1852
|
+
`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${runtimeContextQueryString(runtimeContext)}`
|
|
1853
|
+
);
|
|
1777
1854
|
}
|
|
1778
1855
|
/**
|
|
1779
1856
|
* Cancels a specific workflow run by its ID
|
|
@@ -1796,27 +1873,61 @@ var Workflow = class extends BaseResource {
|
|
|
1796
1873
|
body: { event: params.event, data: params.data }
|
|
1797
1874
|
});
|
|
1798
1875
|
}
|
|
1876
|
+
/**
|
|
1877
|
+
* @deprecated Use createRunAsync() instead.
|
|
1878
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
1879
|
+
*/
|
|
1880
|
+
async createRun(_params) {
|
|
1881
|
+
throw new Error(
|
|
1882
|
+
"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."
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1799
1885
|
/**
|
|
1800
1886
|
* Creates a new workflow run
|
|
1801
1887
|
* @param params - Optional object containing the optional runId
|
|
1802
|
-
* @returns Promise containing the runId of the created run
|
|
1888
|
+
* @returns Promise containing the runId of the created run with methods to control execution
|
|
1803
1889
|
*/
|
|
1804
|
-
|
|
1890
|
+
async createRunAsync(params) {
|
|
1805
1891
|
const searchParams = new URLSearchParams();
|
|
1806
1892
|
if (!!params?.runId) {
|
|
1807
1893
|
searchParams.set("runId", params.runId);
|
|
1808
1894
|
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1895
|
+
const res = await this.request(
|
|
1896
|
+
`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`,
|
|
1897
|
+
{
|
|
1898
|
+
method: "POST"
|
|
1899
|
+
}
|
|
1900
|
+
);
|
|
1901
|
+
const runId = res.runId;
|
|
1902
|
+
return {
|
|
1903
|
+
runId,
|
|
1904
|
+
start: async (p) => {
|
|
1905
|
+
return this.start({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1906
|
+
},
|
|
1907
|
+
startAsync: async (p) => {
|
|
1908
|
+
return this.startAsync({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1909
|
+
},
|
|
1910
|
+
watch: async (onRecord) => {
|
|
1911
|
+
return this.watch({ runId }, onRecord);
|
|
1912
|
+
},
|
|
1913
|
+
stream: async (p) => {
|
|
1914
|
+
return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1915
|
+
},
|
|
1916
|
+
resume: async (p) => {
|
|
1917
|
+
return this.resume({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
|
|
1918
|
+
},
|
|
1919
|
+
resumeAsync: async (p) => {
|
|
1920
|
+
return this.resumeAsync({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
|
|
1921
|
+
},
|
|
1922
|
+
resumeStreamVNext: async (p) => {
|
|
1923
|
+
return this.resumeStreamVNext({
|
|
1924
|
+
runId,
|
|
1925
|
+
step: p.step,
|
|
1926
|
+
resumeData: p.resumeData,
|
|
1927
|
+
runtimeContext: p.runtimeContext
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1820
1931
|
}
|
|
1821
1932
|
/**
|
|
1822
1933
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
@@ -1844,7 +1955,6 @@ var Workflow = class extends BaseResource {
|
|
|
1844
1955
|
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
1845
1956
|
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
1846
1957
|
method: "POST",
|
|
1847
|
-
stream: true,
|
|
1848
1958
|
body: {
|
|
1849
1959
|
step,
|
|
1850
1960
|
resumeData,
|
|
@@ -1888,7 +1998,54 @@ var Workflow = class extends BaseResource {
|
|
|
1888
1998
|
}
|
|
1889
1999
|
);
|
|
1890
2000
|
if (!response.ok) {
|
|
1891
|
-
throw new Error(`Failed to stream
|
|
2001
|
+
throw new Error(`Failed to stream workflow: ${response.statusText}`);
|
|
2002
|
+
}
|
|
2003
|
+
if (!response.body) {
|
|
2004
|
+
throw new Error("Response body is null");
|
|
2005
|
+
}
|
|
2006
|
+
let failedChunk = void 0;
|
|
2007
|
+
const transformStream = new TransformStream({
|
|
2008
|
+
start() {
|
|
2009
|
+
},
|
|
2010
|
+
async transform(chunk, controller) {
|
|
2011
|
+
try {
|
|
2012
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2013
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2014
|
+
for (const chunk2 of chunks) {
|
|
2015
|
+
if (chunk2) {
|
|
2016
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2017
|
+
try {
|
|
2018
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2019
|
+
controller.enqueue(parsedChunk);
|
|
2020
|
+
failedChunk = void 0;
|
|
2021
|
+
} catch {
|
|
2022
|
+
failedChunk = newChunk;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
} catch {
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2030
|
+
return response.body.pipeThrough(transformStream);
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Observes workflow stream for a workflow run
|
|
2034
|
+
* @param params - Object containing the runId
|
|
2035
|
+
* @returns Promise containing the workflow execution results
|
|
2036
|
+
*/
|
|
2037
|
+
async observeStream(params) {
|
|
2038
|
+
const searchParams = new URLSearchParams();
|
|
2039
|
+
searchParams.set("runId", params.runId);
|
|
2040
|
+
const response = await this.request(
|
|
2041
|
+
`/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
|
|
2042
|
+
{
|
|
2043
|
+
method: "POST",
|
|
2044
|
+
stream: true
|
|
2045
|
+
}
|
|
2046
|
+
);
|
|
2047
|
+
if (!response.ok) {
|
|
2048
|
+
throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
|
|
1892
2049
|
}
|
|
1893
2050
|
if (!response.body) {
|
|
1894
2051
|
throw new Error("Response body is null");
|
|
@@ -1934,7 +2091,7 @@ var Workflow = class extends BaseResource {
|
|
|
1934
2091
|
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
1935
2092
|
{
|
|
1936
2093
|
method: "POST",
|
|
1937
|
-
body: { inputData: params.inputData, runtimeContext },
|
|
2094
|
+
body: { inputData: params.inputData, runtimeContext, closeOnSuspend: params.closeOnSuspend },
|
|
1938
2095
|
stream: true
|
|
1939
2096
|
}
|
|
1940
2097
|
);
|
|
@@ -1986,6 +2143,22 @@ var Workflow = class extends BaseResource {
|
|
|
1986
2143
|
}
|
|
1987
2144
|
});
|
|
1988
2145
|
}
|
|
2146
|
+
/**
|
|
2147
|
+
* Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
|
|
2148
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
2149
|
+
* @returns Promise containing the workflow resume results
|
|
2150
|
+
*/
|
|
2151
|
+
resumeStreamVNext(params) {
|
|
2152
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2153
|
+
return this.request(`/api/workflows/${this.workflowId}/resume-stream?runId=${params.runId}`, {
|
|
2154
|
+
method: "POST",
|
|
2155
|
+
body: {
|
|
2156
|
+
step: params.step,
|
|
2157
|
+
resumeData: params.resumeData,
|
|
2158
|
+
runtimeContext
|
|
2159
|
+
}
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
1989
2162
|
/**
|
|
1990
2163
|
* Watches workflow transitions in real-time
|
|
1991
2164
|
* @param runId - Optional run ID to filter the watch stream
|
|
@@ -2120,10 +2293,11 @@ var MCPTool = class extends BaseResource {
|
|
|
2120
2293
|
}
|
|
2121
2294
|
/**
|
|
2122
2295
|
* Retrieves details about this specific tool from the MCP server.
|
|
2296
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2123
2297
|
* @returns Promise containing the tool's information (name, description, schema).
|
|
2124
2298
|
*/
|
|
2125
|
-
details() {
|
|
2126
|
-
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
|
|
2299
|
+
details(runtimeContext) {
|
|
2300
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2127
2301
|
}
|
|
2128
2302
|
/**
|
|
2129
2303
|
* Executes this specific tool on the MCP server.
|
|
@@ -2179,11 +2353,20 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2179
2353
|
};
|
|
2180
2354
|
}
|
|
2181
2355
|
}
|
|
2356
|
+
/**
|
|
2357
|
+
* @deprecated Use createRunAsync() instead.
|
|
2358
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
2359
|
+
*/
|
|
2360
|
+
async createRun(_params) {
|
|
2361
|
+
throw new Error(
|
|
2362
|
+
"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."
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2182
2365
|
/**
|
|
2183
2366
|
* Creates a new agent builder action run and returns the runId.
|
|
2184
2367
|
* This calls `/api/agent-builder/:actionId/create-run`.
|
|
2185
2368
|
*/
|
|
2186
|
-
async
|
|
2369
|
+
async createRunAsync(params) {
|
|
2187
2370
|
const searchParams = new URLSearchParams();
|
|
2188
2371
|
if (!!params?.runId) {
|
|
2189
2372
|
searchParams.set("runId", params.runId);
|
|
@@ -2193,14 +2376,6 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2193
2376
|
method: "POST"
|
|
2194
2377
|
});
|
|
2195
2378
|
}
|
|
2196
|
-
/**
|
|
2197
|
-
* Creates a new workflow run (alias for createRun)
|
|
2198
|
-
* @param params - Optional object containing the optional runId
|
|
2199
|
-
* @returns Promise containing the runId of the created run
|
|
2200
|
-
*/
|
|
2201
|
-
createRunAsync(params) {
|
|
2202
|
-
return this.createRun(params);
|
|
2203
|
-
}
|
|
2204
2379
|
/**
|
|
2205
2380
|
* Starts agent builder action asynchronously and waits for completion.
|
|
2206
2381
|
* This calls `/api/agent-builder/:actionId/start-async`.
|
|
@@ -2560,6 +2735,12 @@ var Observability = class extends BaseResource {
|
|
|
2560
2735
|
const queryString = searchParams.toString();
|
|
2561
2736
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2562
2737
|
}
|
|
2738
|
+
score(params) {
|
|
2739
|
+
return this.request(`/api/observability/traces/score`, {
|
|
2740
|
+
method: "POST",
|
|
2741
|
+
body: { ...params }
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2563
2744
|
};
|
|
2564
2745
|
|
|
2565
2746
|
// src/resources/network-memory-thread.ts
|
|
@@ -2634,10 +2815,11 @@ var VNextNetwork = class extends BaseResource {
|
|
|
2634
2815
|
}
|
|
2635
2816
|
/**
|
|
2636
2817
|
* Retrieves details about the network
|
|
2818
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2637
2819
|
* @returns Promise containing vNext network details
|
|
2638
2820
|
*/
|
|
2639
|
-
details() {
|
|
2640
|
-
return this.request(`/api/networks/v-next/${this.networkId}`);
|
|
2821
|
+
details(runtimeContext) {
|
|
2822
|
+
return this.request(`/api/networks/v-next/${this.networkId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2641
2823
|
}
|
|
2642
2824
|
/**
|
|
2643
2825
|
* Generates a response from the v-next network
|
|
@@ -2772,10 +2954,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2772
2954
|
}
|
|
2773
2955
|
/**
|
|
2774
2956
|
* Retrieves all available agents
|
|
2957
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2775
2958
|
* @returns Promise containing map of agent IDs to agent details
|
|
2776
2959
|
*/
|
|
2777
|
-
getAgents() {
|
|
2778
|
-
|
|
2960
|
+
getAgents(runtimeContext) {
|
|
2961
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
2962
|
+
const searchParams = new URLSearchParams();
|
|
2963
|
+
if (runtimeContextParam) {
|
|
2964
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
2965
|
+
}
|
|
2966
|
+
const queryString = searchParams.toString();
|
|
2967
|
+
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2779
2968
|
}
|
|
2780
2969
|
/**
|
|
2781
2970
|
* Gets an agent instance by ID
|
|
@@ -2793,6 +2982,14 @@ var MastraClient = class extends BaseResource {
|
|
|
2793
2982
|
getMemoryThreads(params) {
|
|
2794
2983
|
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
2795
2984
|
}
|
|
2985
|
+
/**
|
|
2986
|
+
* Retrieves memory config for a resource
|
|
2987
|
+
* @param params - Parameters containing the resource ID
|
|
2988
|
+
* @returns Promise containing array of memory threads
|
|
2989
|
+
*/
|
|
2990
|
+
getMemoryConfig(params) {
|
|
2991
|
+
return this.request(`/api/memory/config?agentId=${params.agentId}`);
|
|
2992
|
+
}
|
|
2796
2993
|
/**
|
|
2797
2994
|
* Creates a new memory thread
|
|
2798
2995
|
* @param params - Parameters for creating the memory thread
|
|
@@ -2809,6 +3006,24 @@ var MastraClient = class extends BaseResource {
|
|
|
2809
3006
|
getMemoryThread(threadId, agentId) {
|
|
2810
3007
|
return new MemoryThread(this.options, threadId, agentId);
|
|
2811
3008
|
}
|
|
3009
|
+
getThreadMessages(threadId, opts = {}) {
|
|
3010
|
+
let url = "";
|
|
3011
|
+
if (opts.agentId) {
|
|
3012
|
+
url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
|
|
3013
|
+
} else if (opts.networkId) {
|
|
3014
|
+
url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
|
|
3015
|
+
}
|
|
3016
|
+
return this.request(url);
|
|
3017
|
+
}
|
|
3018
|
+
deleteThread(threadId, opts = {}) {
|
|
3019
|
+
let url = "";
|
|
3020
|
+
if (opts.agentId) {
|
|
3021
|
+
url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
|
|
3022
|
+
} else if (opts.networkId) {
|
|
3023
|
+
url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
|
|
3024
|
+
}
|
|
3025
|
+
return this.request(url, { method: "DELETE" });
|
|
3026
|
+
}
|
|
2812
3027
|
/**
|
|
2813
3028
|
* Saves messages to memory
|
|
2814
3029
|
* @param params - Parameters containing messages to save
|
|
@@ -2871,10 +3086,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2871
3086
|
}
|
|
2872
3087
|
/**
|
|
2873
3088
|
* Retrieves all available tools
|
|
3089
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2874
3090
|
* @returns Promise containing map of tool IDs to tool details
|
|
2875
3091
|
*/
|
|
2876
|
-
getTools() {
|
|
2877
|
-
|
|
3092
|
+
getTools(runtimeContext) {
|
|
3093
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
3094
|
+
const searchParams = new URLSearchParams();
|
|
3095
|
+
if (runtimeContextParam) {
|
|
3096
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
3097
|
+
}
|
|
3098
|
+
const queryString = searchParams.toString();
|
|
3099
|
+
return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
|
|
2878
3100
|
}
|
|
2879
3101
|
/**
|
|
2880
3102
|
* Gets a tool instance by ID
|
|
@@ -2901,10 +3123,17 @@ var MastraClient = class extends BaseResource {
|
|
|
2901
3123
|
}
|
|
2902
3124
|
/**
|
|
2903
3125
|
* Retrieves all available workflows
|
|
3126
|
+
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2904
3127
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
2905
3128
|
*/
|
|
2906
|
-
getWorkflows() {
|
|
2907
|
-
|
|
3129
|
+
getWorkflows(runtimeContext) {
|
|
3130
|
+
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
3131
|
+
const searchParams = new URLSearchParams();
|
|
3132
|
+
if (runtimeContextParam) {
|
|
3133
|
+
searchParams.set("runtimeContext", runtimeContextParam);
|
|
3134
|
+
}
|
|
3135
|
+
const queryString = searchParams.toString();
|
|
3136
|
+
return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
|
|
2908
3137
|
}
|
|
2909
3138
|
/**
|
|
2910
3139
|
* Gets a workflow instance by ID
|
|
@@ -3072,13 +3301,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3072
3301
|
return this.request(`/api/telemetry`);
|
|
3073
3302
|
}
|
|
3074
3303
|
}
|
|
3075
|
-
/**
|
|
3076
|
-
* Retrieves all available networks
|
|
3077
|
-
* @returns Promise containing map of network IDs to network details
|
|
3078
|
-
*/
|
|
3079
|
-
getNetworks() {
|
|
3080
|
-
return this.request("/api/networks");
|
|
3081
|
-
}
|
|
3082
3304
|
/**
|
|
3083
3305
|
* Retrieves all available vNext networks
|
|
3084
3306
|
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
@@ -3086,14 +3308,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3086
3308
|
getVNextNetworks() {
|
|
3087
3309
|
return this.request("/api/networks/v-next");
|
|
3088
3310
|
}
|
|
3089
|
-
/**
|
|
3090
|
-
* Gets a network instance by ID
|
|
3091
|
-
* @param networkId - ID of the network to retrieve
|
|
3092
|
-
* @returns Network instance
|
|
3093
|
-
*/
|
|
3094
|
-
getNetwork(networkId) {
|
|
3095
|
-
return new Network(this.options, networkId);
|
|
3096
|
-
}
|
|
3097
3311
|
/**
|
|
3098
3312
|
* Gets a vNext network instance by ID
|
|
3099
3313
|
* @param networkId - ID of the vNext network to retrieve
|
|
@@ -3284,8 +3498,32 @@ var MastraClient = class extends BaseResource {
|
|
|
3284
3498
|
getAITraces(params) {
|
|
3285
3499
|
return this.observability.getTraces(params);
|
|
3286
3500
|
}
|
|
3501
|
+
score(params) {
|
|
3502
|
+
return this.observability.score(params);
|
|
3503
|
+
}
|
|
3504
|
+
};
|
|
3505
|
+
|
|
3506
|
+
// src/tools.ts
|
|
3507
|
+
var ClientTool = class {
|
|
3508
|
+
id;
|
|
3509
|
+
description;
|
|
3510
|
+
inputSchema;
|
|
3511
|
+
outputSchema;
|
|
3512
|
+
execute;
|
|
3513
|
+
constructor(opts) {
|
|
3514
|
+
this.id = opts.id;
|
|
3515
|
+
this.description = opts.description;
|
|
3516
|
+
this.inputSchema = opts.inputSchema;
|
|
3517
|
+
this.outputSchema = opts.outputSchema;
|
|
3518
|
+
this.execute = opts.execute;
|
|
3519
|
+
}
|
|
3287
3520
|
};
|
|
3521
|
+
function createTool(opts) {
|
|
3522
|
+
return new ClientTool(opts);
|
|
3523
|
+
}
|
|
3288
3524
|
|
|
3525
|
+
exports.ClientTool = ClientTool;
|
|
3289
3526
|
exports.MastraClient = MastraClient;
|
|
3527
|
+
exports.createTool = createTool;
|
|
3290
3528
|
//# sourceMappingURL=index.cjs.map
|
|
3291
3529
|
//# sourceMappingURL=index.cjs.map
|