@mastra/client-js 0.0.0-remove-unused-import-20250909212718 → 0.0.0-roamin-openaivoice-speak-options-passing-20250926163614

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +270 -3
  2. package/README.md +2 -6
  3. package/dist/client.d.ts +36 -27
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/index.cjs +379 -355
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +378 -356
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/agent-builder.d.ts +5 -6
  12. package/dist/resources/agent-builder.d.ts.map +1 -1
  13. package/dist/resources/agent.d.ts +48 -12
  14. package/dist/resources/agent.d.ts.map +1 -1
  15. package/dist/resources/index.d.ts +0 -2
  16. package/dist/resources/index.d.ts.map +1 -1
  17. package/dist/resources/mcp-tool.d.ts +2 -1
  18. package/dist/resources/mcp-tool.d.ts.map +1 -1
  19. package/dist/resources/observability.d.ts +10 -0
  20. package/dist/resources/observability.d.ts.map +1 -1
  21. package/dist/resources/tool.d.ts +2 -1
  22. package/dist/resources/tool.d.ts.map +1 -1
  23. package/dist/resources/vNextNetwork.d.ts +2 -1
  24. package/dist/resources/vNextNetwork.d.ts.map +1 -1
  25. package/dist/resources/vector.d.ts +5 -2
  26. package/dist/resources/vector.d.ts.map +1 -1
  27. package/dist/resources/workflow.d.ts +96 -11
  28. package/dist/resources/workflow.d.ts.map +1 -1
  29. package/dist/tools.d.ts +22 -0
  30. package/dist/tools.d.ts.map +1 -0
  31. package/dist/types.d.ts +51 -43
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/utils/index.d.ts +2 -0
  34. package/dist/utils/index.d.ts.map +1 -1
  35. package/dist/utils/process-mastra-stream.d.ts +5 -1
  36. package/dist/utils/process-mastra-stream.d.ts.map +1 -1
  37. package/package.json +5 -6
  38. package/dist/resources/legacy-workflow.d.ts +0 -87
  39. package/dist/resources/legacy-workflow.d.ts.map +0 -1
  40. package/dist/resources/network.d.ts +0 -30
  41. package/dist/resources/network.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -15,6 +15,20 @@ function parseClientRuntimeContext(runtimeContext) {
15
15
  }
16
16
  return void 0;
17
17
  }
18
+ function base64RuntimeContext(runtimeContext) {
19
+ if (runtimeContext) {
20
+ return btoa(JSON.stringify(runtimeContext));
21
+ }
22
+ return void 0;
23
+ }
24
+ function runtimeContextQueryString(runtimeContext) {
25
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
26
+ if (!runtimeContextParam) return "";
27
+ const searchParams = new URLSearchParams();
28
+ searchParams.set("runtimeContext", runtimeContextParam);
29
+ const queryString = searchParams.toString();
30
+ return queryString ? `?${queryString}` : "";
31
+ }
18
32
  function isZodType(value) {
19
33
  return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
20
34
  }
@@ -26,7 +40,7 @@ function zodToJsonSchema(zodSchema) {
26
40
  const fn = "toJSONSchema";
27
41
  return z[fn].call(z, zodSchema);
28
42
  }
29
- return originalZodToJsonSchema(zodSchema, { $refStrategy: "none" });
43
+ return originalZodToJsonSchema(zodSchema, { $refStrategy: "relative" });
30
44
  }
31
45
 
32
46
  // src/utils/process-client-tools.ts
@@ -59,7 +73,7 @@ function processClientTools(clientTools) {
59
73
  }
60
74
 
61
75
  // src/utils/process-mastra-stream.ts
62
- async function processMastraStream({
76
+ async function sharedProcessMastraStream({
63
77
  stream,
64
78
  onChunk
65
79
  }) {
@@ -77,7 +91,7 @@ async function processMastraStream({
77
91
  if (line.startsWith("data: ")) {
78
92
  const data = line.slice(6);
79
93
  if (data === "[DONE]") {
80
- console.log("\u{1F3C1} Stream finished");
94
+ console.info("\u{1F3C1} Stream finished");
81
95
  return;
82
96
  }
83
97
  try {
@@ -93,6 +107,24 @@ async function processMastraStream({
93
107
  reader.releaseLock();
94
108
  }
95
109
  }
110
+ async function processMastraNetworkStream({
111
+ stream,
112
+ onChunk
113
+ }) {
114
+ return sharedProcessMastraStream({
115
+ stream,
116
+ onChunk
117
+ });
118
+ }
119
+ async function processMastraStream({
120
+ stream,
121
+ onChunk
122
+ }) {
123
+ return sharedProcessMastraStream({
124
+ stream,
125
+ onChunk
126
+ });
127
+ }
96
128
 
97
129
  // src/resources/base.ts
98
130
  var BaseResource = class {
@@ -181,7 +213,9 @@ async function executeToolCallAndRespond({
181
213
  resourceId,
182
214
  threadId,
183
215
  runtimeContext,
184
- tracingContext: { currentSpan: void 0 }
216
+ tracingContext: { currentSpan: void 0 },
217
+ suspend: async () => {
218
+ }
185
219
  },
186
220
  {
187
221
  messages: response.messages,
@@ -189,11 +223,7 @@ async function executeToolCallAndRespond({
189
223
  }
190
224
  );
191
225
  const updatedMessages = [
192
- {
193
- role: "user",
194
- content: params.messages
195
- },
196
- ...response.response.messages,
226
+ ...response.response.messages || [],
197
227
  {
198
228
  role: "tool",
199
229
  content: [
@@ -255,17 +285,21 @@ var AgentVoice = class extends BaseResource {
255
285
  }
256
286
  /**
257
287
  * Get available speakers for the agent's voice provider
288
+ * @param runtimeContext - Optional runtime context to pass as query parameter
289
+ * @param runtimeContext - Optional runtime context to pass as query parameter
258
290
  * @returns Promise containing list of available speakers
259
291
  */
260
- getSpeakers() {
261
- return this.request(`/api/agents/${this.agentId}/voice/speakers`);
292
+ getSpeakers(runtimeContext) {
293
+ return this.request(`/api/agents/${this.agentId}/voice/speakers${runtimeContextQueryString(runtimeContext)}`);
262
294
  }
263
295
  /**
264
296
  * Get the listener configuration for the agent's voice provider
297
+ * @param runtimeContext - Optional runtime context to pass as query parameter
298
+ * @param runtimeContext - Optional runtime context to pass as query parameter
265
299
  * @returns Promise containing a check if the agent has listening capabilities
266
300
  */
267
- getListener() {
268
- return this.request(`/api/agents/${this.agentId}/voice/listener`);
301
+ getListener(runtimeContext) {
302
+ return this.request(`/api/agents/${this.agentId}/voice/listener${runtimeContextQueryString(runtimeContext)}`);
269
303
  }
270
304
  };
271
305
  var Agent = class extends BaseResource {
@@ -277,14 +311,15 @@ var Agent = class extends BaseResource {
277
311
  voice;
278
312
  /**
279
313
  * Retrieves details about the agent
314
+ * @param runtimeContext - Optional runtime context to pass as query parameter
280
315
  * @returns Promise containing agent details including model and instructions
281
316
  */
282
- details() {
283
- return this.request(`/api/agents/${this.agentId}`);
317
+ details(runtimeContext) {
318
+ return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
284
319
  }
285
320
  async generate(params) {
286
321
  console.warn(
287
- "Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet."
322
+ "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."
288
323
  );
289
324
  return this.generateLegacy(params);
290
325
  }
@@ -319,7 +354,9 @@ var Agent = class extends BaseResource {
319
354
  resourceId,
320
355
  threadId,
321
356
  runtimeContext,
322
- tracingContext: { currentSpan: void 0 }
357
+ tracingContext: { currentSpan: void 0 },
358
+ suspend: async () => {
359
+ }
323
360
  },
324
361
  {
325
362
  messages: response.messages,
@@ -327,10 +364,6 @@ var Agent = class extends BaseResource {
327
364
  }
328
365
  );
329
366
  const updatedMessages = [
330
- {
331
- role: "user",
332
- content: params.messages
333
- },
334
367
  ...response.response.messages,
335
368
  {
336
369
  role: "tool",
@@ -353,7 +386,16 @@ var Agent = class extends BaseResource {
353
386
  }
354
387
  return response;
355
388
  }
356
- async generateVNext(params) {
389
+ async generateVNext(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
+ }
357
399
  const processedParams = {
358
400
  ...params,
359
401
  output: params.output ? zodToJsonSchema(params.output) : void 0,
@@ -654,7 +696,7 @@ var Agent = class extends BaseResource {
654
696
  */
655
697
  async stream(params) {
656
698
  console.warn(
657
- "Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet."
699
+ "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."
658
700
  );
659
701
  return this.streamLegacy(params);
660
702
  }
@@ -1003,7 +1045,9 @@ var Agent = class extends BaseResource {
1003
1045
  threadId: processedParams.threadId,
1004
1046
  runtimeContext: processedParams.runtimeContext,
1005
1047
  // TODO: Pass proper tracing context when client-js supports tracing
1006
- tracingContext: { currentSpan: void 0 }
1048
+ tracingContext: { currentSpan: void 0 },
1049
+ suspend: async () => {
1050
+ }
1007
1051
  },
1008
1052
  {
1009
1053
  messages: response.messages,
@@ -1029,9 +1073,7 @@ var Agent = class extends BaseResource {
1029
1073
  toolInvocation.state = "result";
1030
1074
  toolInvocation.result = result;
1031
1075
  }
1032
- const originalMessages = processedParams.messages;
1033
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1034
- const updatedMessages = lastMessage != null ? [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messageArray, ...messages];
1076
+ const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
1035
1077
  this.processStreamResponse_vNext(
1036
1078
  {
1037
1079
  ...processedParams,
@@ -1058,7 +1100,40 @@ var Agent = class extends BaseResource {
1058
1100
  }
1059
1101
  return response;
1060
1102
  }
1061
- async streamVNext(params) {
1103
+ async network(params) {
1104
+ const response = await this.request(`/api/agents/${this.agentId}/network`, {
1105
+ method: "POST",
1106
+ body: params,
1107
+ stream: true
1108
+ });
1109
+ if (!response.body) {
1110
+ throw new Error("No response body");
1111
+ }
1112
+ const streamResponse = new Response(response.body, {
1113
+ status: response.status,
1114
+ statusText: response.statusText,
1115
+ headers: response.headers
1116
+ });
1117
+ streamResponse.processDataStream = async ({
1118
+ onChunk
1119
+ }) => {
1120
+ await processMastraNetworkStream({
1121
+ stream: streamResponse.body,
1122
+ onChunk
1123
+ });
1124
+ };
1125
+ return streamResponse;
1126
+ }
1127
+ async streamVNext(messagesOrParams, options) {
1128
+ let params;
1129
+ if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
1130
+ params = messagesOrParams;
1131
+ } else {
1132
+ params = {
1133
+ messages: messagesOrParams,
1134
+ ...options
1135
+ };
1136
+ }
1062
1137
  const processedParams = {
1063
1138
  ...params,
1064
1139
  output: params.output ? zodToJsonSchema(params.output) : void 0,
@@ -1134,7 +1209,9 @@ var Agent = class extends BaseResource {
1134
1209
  threadId: processedParams.threadId,
1135
1210
  runtimeContext: processedParams.runtimeContext,
1136
1211
  // TODO: Pass proper tracing context when client-js supports tracing
1137
- tracingContext: { currentSpan: void 0 }
1212
+ tracingContext: { currentSpan: void 0 },
1213
+ suspend: async () => {
1214
+ }
1138
1215
  },
1139
1216
  {
1140
1217
  messages: response.messages,
@@ -1172,12 +1249,10 @@ var Agent = class extends BaseResource {
1172
1249
  } finally {
1173
1250
  writer.releaseLock();
1174
1251
  }
1175
- const originalMessages = processedParams.messages;
1176
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1177
1252
  this.processStreamResponse(
1178
1253
  {
1179
1254
  ...processedParams,
1180
- messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1255
+ messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1181
1256
  },
1182
1257
  writable
1183
1258
  ).catch((error) => {
@@ -1203,10 +1278,11 @@ var Agent = class extends BaseResource {
1203
1278
  /**
1204
1279
  * Gets details about a specific tool available to the agent
1205
1280
  * @param toolId - ID of the tool to retrieve
1281
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1206
1282
  * @returns Promise containing tool details
1207
1283
  */
1208
- getTool(toolId) {
1209
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
1284
+ getTool(toolId, runtimeContext) {
1285
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}${runtimeContextQueryString(runtimeContext)}`);
1210
1286
  }
1211
1287
  /**
1212
1288
  * Executes a tool for the agent
@@ -1217,7 +1293,7 @@ var Agent = class extends BaseResource {
1217
1293
  executeTool(toolId, params) {
1218
1294
  const body = {
1219
1295
  data: params.data,
1220
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
1296
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1221
1297
  };
1222
1298
  return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
1223
1299
  method: "POST",
@@ -1226,17 +1302,19 @@ var Agent = class extends BaseResource {
1226
1302
  }
1227
1303
  /**
1228
1304
  * Retrieves evaluation results for the agent
1305
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1229
1306
  * @returns Promise containing agent evaluations
1230
1307
  */
1231
- evals() {
1232
- return this.request(`/api/agents/${this.agentId}/evals/ci`);
1308
+ evals(runtimeContext) {
1309
+ return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
1233
1310
  }
1234
1311
  /**
1235
1312
  * Retrieves live evaluation results for the agent
1313
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1236
1314
  * @returns Promise containing live agent evaluations
1237
1315
  */
1238
- liveEvals() {
1239
- return this.request(`/api/agents/${this.agentId}/evals/live`);
1316
+ liveEvals(runtimeContext) {
1317
+ return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
1240
1318
  }
1241
1319
  /**
1242
1320
  * Updates the model for the agent
@@ -1249,61 +1327,27 @@ var Agent = class extends BaseResource {
1249
1327
  body: params
1250
1328
  });
1251
1329
  }
1252
- };
1253
- var Network = class extends BaseResource {
1254
- constructor(options, networkId) {
1255
- super(options);
1256
- this.networkId = networkId;
1257
- }
1258
1330
  /**
1259
- * Retrieves details about the network
1260
- * @returns Promise containing network details
1261
- */
1262
- details() {
1263
- return this.request(`/api/networks/${this.networkId}`);
1264
- }
1265
- /**
1266
- * Generates a response from the agent
1267
- * @param params - Generation parameters including prompt
1268
- * @returns Promise containing the generated response
1331
+ * Updates the model for the agent in the model list
1332
+ * @param params - Parameters for updating the model
1333
+ * @returns Promise containing the updated model
1269
1334
  */
1270
- generate(params) {
1271
- const processedParams = {
1272
- ...params,
1273
- output: zodToJsonSchema(params.output),
1274
- experimental_output: zodToJsonSchema(params.experimental_output)
1275
- };
1276
- return this.request(`/api/networks/${this.networkId}/generate`, {
1335
+ updateModelInModelList({ modelConfigId, ...params }) {
1336
+ return this.request(`/api/agents/${this.agentId}/models/${modelConfigId}`, {
1277
1337
  method: "POST",
1278
- body: processedParams
1338
+ body: params
1279
1339
  });
1280
1340
  }
1281
1341
  /**
1282
- * Streams a response from the agent
1283
- * @param params - Stream parameters including prompt
1284
- * @returns Promise containing the enhanced Response object with processDataStream method
1342
+ * Reorders the models for the agent
1343
+ * @param params - Parameters for reordering the model list
1344
+ * @returns Promise containing the updated model list
1285
1345
  */
1286
- async stream(params) {
1287
- const processedParams = {
1288
- ...params,
1289
- output: zodToJsonSchema(params.output),
1290
- experimental_output: zodToJsonSchema(params.experimental_output)
1291
- };
1292
- const response = await this.request(`/api/networks/${this.networkId}/stream`, {
1346
+ reorderModelList(params) {
1347
+ return this.request(`/api/agents/${this.agentId}/models/reorder`, {
1293
1348
  method: "POST",
1294
- body: processedParams,
1295
- stream: true
1349
+ body: params
1296
1350
  });
1297
- if (!response.body) {
1298
- throw new Error("No response body");
1299
- }
1300
- response.processDataStream = async (options = {}) => {
1301
- await processDataStream({
1302
- stream: response.body,
1303
- ...options
1304
- });
1305
- };
1306
- return response;
1307
1351
  }
1308
1352
  };
1309
1353
 
@@ -1394,10 +1438,13 @@ var Vector = class extends BaseResource {
1394
1438
  /**
1395
1439
  * Retrieves details about a specific vector index
1396
1440
  * @param indexName - Name of the index to get details for
1441
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1397
1442
  * @returns Promise containing vector index details
1398
1443
  */
1399
- details(indexName) {
1400
- return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`);
1444
+ details(indexName, runtimeContext) {
1445
+ return this.request(
1446
+ `/api/vector/${this.vectorName}/indexes/${indexName}${runtimeContextQueryString(runtimeContext)}`
1447
+ );
1401
1448
  }
1402
1449
  /**
1403
1450
  * Deletes a vector index
@@ -1411,10 +1458,11 @@ var Vector = class extends BaseResource {
1411
1458
  }
1412
1459
  /**
1413
1460
  * Retrieves a list of all available indexes
1461
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1414
1462
  * @returns Promise containing array of index names
1415
1463
  */
1416
- getIndexes() {
1417
- return this.request(`/api/vector/${this.vectorName}/indexes`);
1464
+ getIndexes(runtimeContext) {
1465
+ return this.request(`/api/vector/${this.vectorName}/indexes${runtimeContextQueryString(runtimeContext)}`);
1418
1466
  }
1419
1467
  /**
1420
1468
  * Creates a new vector index
@@ -1451,187 +1499,6 @@ var Vector = class extends BaseResource {
1451
1499
  }
1452
1500
  };
1453
1501
 
1454
- // src/resources/legacy-workflow.ts
1455
- var RECORD_SEPARATOR = "";
1456
- var LegacyWorkflow = class extends BaseResource {
1457
- constructor(options, workflowId) {
1458
- super(options);
1459
- this.workflowId = workflowId;
1460
- }
1461
- /**
1462
- * Retrieves details about the legacy workflow
1463
- * @returns Promise containing legacy workflow details including steps and graphs
1464
- */
1465
- details() {
1466
- return this.request(`/api/workflows/legacy/${this.workflowId}`);
1467
- }
1468
- /**
1469
- * Retrieves all runs for a legacy workflow
1470
- * @param params - Parameters for filtering runs
1471
- * @returns Promise containing legacy workflow runs array
1472
- */
1473
- runs(params) {
1474
- const searchParams = new URLSearchParams();
1475
- if (params?.fromDate) {
1476
- searchParams.set("fromDate", params.fromDate.toISOString());
1477
- }
1478
- if (params?.toDate) {
1479
- searchParams.set("toDate", params.toDate.toISOString());
1480
- }
1481
- if (params?.limit) {
1482
- searchParams.set("limit", String(params.limit));
1483
- }
1484
- if (params?.offset) {
1485
- searchParams.set("offset", String(params.offset));
1486
- }
1487
- if (params?.resourceId) {
1488
- searchParams.set("resourceId", params.resourceId);
1489
- }
1490
- if (searchParams.size) {
1491
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
1492
- } else {
1493
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
1494
- }
1495
- }
1496
- /**
1497
- * Creates a new legacy workflow run
1498
- * @returns Promise containing the generated run ID
1499
- */
1500
- createRun(params) {
1501
- const searchParams = new URLSearchParams();
1502
- if (!!params?.runId) {
1503
- searchParams.set("runId", params.runId);
1504
- }
1505
- return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
1506
- method: "POST"
1507
- });
1508
- }
1509
- /**
1510
- * Starts a legacy workflow run synchronously without waiting for the workflow to complete
1511
- * @param params - Object containing the runId and triggerData
1512
- * @returns Promise containing success message
1513
- */
1514
- start(params) {
1515
- return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
1516
- method: "POST",
1517
- body: params?.triggerData
1518
- });
1519
- }
1520
- /**
1521
- * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
1522
- * @param stepId - ID of the step to resume
1523
- * @param runId - ID of the legacy workflow run
1524
- * @param context - Context to resume the legacy workflow with
1525
- * @returns Promise containing the legacy workflow resume results
1526
- */
1527
- resume({
1528
- stepId,
1529
- runId,
1530
- context
1531
- }) {
1532
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
1533
- method: "POST",
1534
- body: {
1535
- stepId,
1536
- context
1537
- }
1538
- });
1539
- }
1540
- /**
1541
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
1542
- * @param params - Object containing the optional runId and triggerData
1543
- * @returns Promise containing the workflow execution results
1544
- */
1545
- startAsync(params) {
1546
- const searchParams = new URLSearchParams();
1547
- if (!!params?.runId) {
1548
- searchParams.set("runId", params.runId);
1549
- }
1550
- return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
1551
- method: "POST",
1552
- body: params?.triggerData
1553
- });
1554
- }
1555
- /**
1556
- * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
1557
- * @param params - Object containing the runId, stepId, and context
1558
- * @returns Promise containing the workflow resume results
1559
- */
1560
- resumeAsync(params) {
1561
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
1562
- method: "POST",
1563
- body: {
1564
- stepId: params.stepId,
1565
- context: params.context
1566
- }
1567
- });
1568
- }
1569
- /**
1570
- * Creates an async generator that processes a readable stream and yields records
1571
- * separated by the Record Separator character (\x1E)
1572
- *
1573
- * @param stream - The readable stream to process
1574
- * @returns An async generator that yields parsed records
1575
- */
1576
- async *streamProcessor(stream) {
1577
- const reader = stream.getReader();
1578
- let doneReading = false;
1579
- let buffer = "";
1580
- try {
1581
- while (!doneReading) {
1582
- const { done, value } = await reader.read();
1583
- doneReading = done;
1584
- if (done && !value) continue;
1585
- try {
1586
- const decoded = value ? new TextDecoder().decode(value) : "";
1587
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1588
- buffer = chunks.pop() || "";
1589
- for (const chunk of chunks) {
1590
- if (chunk) {
1591
- if (typeof chunk === "string") {
1592
- try {
1593
- const parsedChunk = JSON.parse(chunk);
1594
- yield parsedChunk;
1595
- } catch {
1596
- }
1597
- }
1598
- }
1599
- }
1600
- } catch {
1601
- }
1602
- }
1603
- if (buffer) {
1604
- try {
1605
- yield JSON.parse(buffer);
1606
- } catch {
1607
- }
1608
- }
1609
- } finally {
1610
- reader.cancel().catch(() => {
1611
- });
1612
- }
1613
- }
1614
- /**
1615
- * Watches legacy workflow transitions in real-time
1616
- * @param runId - Optional run ID to filter the watch stream
1617
- * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
1618
- */
1619
- async watch({ runId }, onRecord) {
1620
- const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
1621
- stream: true
1622
- });
1623
- if (!response.ok) {
1624
- throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
1625
- }
1626
- if (!response.body) {
1627
- throw new Error("Response body is null");
1628
- }
1629
- for await (const record of this.streamProcessor(response.body)) {
1630
- onRecord(record);
1631
- }
1632
- }
1633
- };
1634
-
1635
1502
  // src/resources/tool.ts
1636
1503
  var Tool = class extends BaseResource {
1637
1504
  constructor(options, toolId) {
@@ -1640,10 +1507,11 @@ var Tool = class extends BaseResource {
1640
1507
  }
1641
1508
  /**
1642
1509
  * Retrieves details about the tool
1510
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1643
1511
  * @returns Promise containing tool details including description and schemas
1644
1512
  */
1645
- details() {
1646
- return this.request(`/api/tools/${this.toolId}`);
1513
+ details(runtimeContext) {
1514
+ return this.request(`/api/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
1647
1515
  }
1648
1516
  /**
1649
1517
  * Executes the tool with the provided parameters
@@ -1667,7 +1535,7 @@ var Tool = class extends BaseResource {
1667
1535
  };
1668
1536
 
1669
1537
  // src/resources/workflow.ts
1670
- var RECORD_SEPARATOR2 = "";
1538
+ var RECORD_SEPARATOR = "";
1671
1539
  var Workflow = class extends BaseResource {
1672
1540
  constructor(options, workflowId) {
1673
1541
  super(options);
@@ -1691,7 +1559,7 @@ var Workflow = class extends BaseResource {
1691
1559
  if (done && !value) continue;
1692
1560
  try {
1693
1561
  const decoded = value ? new TextDecoder().decode(value) : "";
1694
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
1562
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1695
1563
  buffer = chunks.pop() || "";
1696
1564
  for (const chunk of chunks) {
1697
1565
  if (chunk) {
@@ -1720,17 +1588,20 @@ var Workflow = class extends BaseResource {
1720
1588
  }
1721
1589
  /**
1722
1590
  * Retrieves details about the workflow
1591
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1723
1592
  * @returns Promise containing workflow details including steps and graphs
1724
1593
  */
1725
- details() {
1726
- return this.request(`/api/workflows/${this.workflowId}`);
1594
+ details(runtimeContext) {
1595
+ return this.request(`/api/workflows/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
1727
1596
  }
1728
1597
  /**
1729
1598
  * Retrieves all runs for a workflow
1730
1599
  * @param params - Parameters for filtering runs
1600
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1731
1601
  * @returns Promise containing workflow runs array
1732
1602
  */
1733
- runs(params) {
1603
+ runs(params, runtimeContext) {
1604
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1734
1605
  const searchParams = new URLSearchParams();
1735
1606
  if (params?.fromDate) {
1736
1607
  searchParams.set("fromDate", params.fromDate.toISOString());
@@ -1747,6 +1618,9 @@ var Workflow = class extends BaseResource {
1747
1618
  if (params?.resourceId) {
1748
1619
  searchParams.set("resourceId", params.resourceId);
1749
1620
  }
1621
+ if (runtimeContextParam) {
1622
+ searchParams.set("runtimeContext", runtimeContextParam);
1623
+ }
1750
1624
  if (searchParams.size) {
1751
1625
  return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
1752
1626
  } else {
@@ -1756,18 +1630,22 @@ var Workflow = class extends BaseResource {
1756
1630
  /**
1757
1631
  * Retrieves a specific workflow run by its ID
1758
1632
  * @param runId - The ID of the workflow run to retrieve
1633
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1759
1634
  * @returns Promise containing the workflow run details
1760
1635
  */
1761
- runById(runId) {
1762
- return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
1636
+ runById(runId, runtimeContext) {
1637
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${runtimeContextQueryString(runtimeContext)}`);
1763
1638
  }
1764
1639
  /**
1765
1640
  * Retrieves the execution result for a specific workflow run by its ID
1766
1641
  * @param runId - The ID of the workflow run to retrieve the execution result for
1642
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1767
1643
  * @returns Promise containing the workflow run execution result
1768
1644
  */
1769
- runExecutionResult(runId) {
1770
- return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
1645
+ runExecutionResult(runId, runtimeContext) {
1646
+ return this.request(
1647
+ `/api/workflows/${this.workflowId}/runs/${runId}/execution-result${runtimeContextQueryString(runtimeContext)}`
1648
+ );
1771
1649
  }
1772
1650
  /**
1773
1651
  * Cancels a specific workflow run by its ID
@@ -1790,27 +1668,61 @@ var Workflow = class extends BaseResource {
1790
1668
  body: { event: params.event, data: params.data }
1791
1669
  });
1792
1670
  }
1671
+ /**
1672
+ * @deprecated Use createRunAsync() instead.
1673
+ * @throws {Error} Always throws an error directing users to use createRunAsync()
1674
+ */
1675
+ async createRun(_params) {
1676
+ throw new Error(
1677
+ "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."
1678
+ );
1679
+ }
1793
1680
  /**
1794
1681
  * Creates a new workflow run
1795
1682
  * @param params - Optional object containing the optional runId
1796
- * @returns Promise containing the runId of the created run
1683
+ * @returns Promise containing the runId of the created run with methods to control execution
1797
1684
  */
1798
- createRun(params) {
1685
+ async createRunAsync(params) {
1799
1686
  const searchParams = new URLSearchParams();
1800
1687
  if (!!params?.runId) {
1801
1688
  searchParams.set("runId", params.runId);
1802
1689
  }
1803
- return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
1804
- method: "POST"
1805
- });
1806
- }
1807
- /**
1808
- * Creates a new workflow run (alias for createRun)
1809
- * @param params - Optional object containing the optional runId
1810
- * @returns Promise containing the runId of the created run
1811
- */
1812
- createRunAsync(params) {
1813
- return this.createRun(params);
1690
+ const res = await this.request(
1691
+ `/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`,
1692
+ {
1693
+ method: "POST"
1694
+ }
1695
+ );
1696
+ const runId = res.runId;
1697
+ return {
1698
+ runId,
1699
+ start: async (p) => {
1700
+ return this.start({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1701
+ },
1702
+ startAsync: async (p) => {
1703
+ return this.startAsync({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1704
+ },
1705
+ watch: async (onRecord) => {
1706
+ return this.watch({ runId }, onRecord);
1707
+ },
1708
+ stream: async (p) => {
1709
+ return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1710
+ },
1711
+ resume: async (p) => {
1712
+ return this.resume({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
1713
+ },
1714
+ resumeAsync: async (p) => {
1715
+ return this.resumeAsync({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
1716
+ },
1717
+ resumeStreamVNext: async (p) => {
1718
+ return this.resumeStreamVNext({
1719
+ runId,
1720
+ step: p.step,
1721
+ resumeData: p.resumeData,
1722
+ runtimeContext: p.runtimeContext
1723
+ });
1724
+ }
1725
+ };
1814
1726
  }
1815
1727
  /**
1816
1728
  * Starts a workflow run synchronously without waiting for the workflow to complete
@@ -1838,7 +1750,6 @@ var Workflow = class extends BaseResource {
1838
1750
  const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
1839
1751
  return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
1840
1752
  method: "POST",
1841
- stream: true,
1842
1753
  body: {
1843
1754
  step,
1844
1755
  resumeData,
@@ -1882,7 +1793,7 @@ var Workflow = class extends BaseResource {
1882
1793
  }
1883
1794
  );
1884
1795
  if (!response.ok) {
1885
- throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
1796
+ throw new Error(`Failed to stream workflow: ${response.statusText}`);
1886
1797
  }
1887
1798
  if (!response.body) {
1888
1799
  throw new Error("Response body is null");
@@ -1894,7 +1805,54 @@ var Workflow = class extends BaseResource {
1894
1805
  async transform(chunk, controller) {
1895
1806
  try {
1896
1807
  const decoded = new TextDecoder().decode(chunk);
1897
- const chunks = decoded.split(RECORD_SEPARATOR2);
1808
+ const chunks = decoded.split(RECORD_SEPARATOR);
1809
+ for (const chunk2 of chunks) {
1810
+ if (chunk2) {
1811
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
1812
+ try {
1813
+ const parsedChunk = JSON.parse(newChunk);
1814
+ controller.enqueue(parsedChunk);
1815
+ failedChunk = void 0;
1816
+ } catch {
1817
+ failedChunk = newChunk;
1818
+ }
1819
+ }
1820
+ }
1821
+ } catch {
1822
+ }
1823
+ }
1824
+ });
1825
+ return response.body.pipeThrough(transformStream);
1826
+ }
1827
+ /**
1828
+ * Observes workflow stream for a workflow run
1829
+ * @param params - Object containing the runId
1830
+ * @returns Promise containing the workflow execution results
1831
+ */
1832
+ async observeStream(params) {
1833
+ const searchParams = new URLSearchParams();
1834
+ searchParams.set("runId", params.runId);
1835
+ const response = await this.request(
1836
+ `/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
1837
+ {
1838
+ method: "POST",
1839
+ stream: true
1840
+ }
1841
+ );
1842
+ if (!response.ok) {
1843
+ throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
1844
+ }
1845
+ if (!response.body) {
1846
+ throw new Error("Response body is null");
1847
+ }
1848
+ let failedChunk = void 0;
1849
+ const transformStream = new TransformStream({
1850
+ start() {
1851
+ },
1852
+ async transform(chunk, controller) {
1853
+ try {
1854
+ const decoded = new TextDecoder().decode(chunk);
1855
+ const chunks = decoded.split(RECORD_SEPARATOR);
1898
1856
  for (const chunk2 of chunks) {
1899
1857
  if (chunk2) {
1900
1858
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -1928,7 +1886,7 @@ var Workflow = class extends BaseResource {
1928
1886
  `/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
1929
1887
  {
1930
1888
  method: "POST",
1931
- body: { inputData: params.inputData, runtimeContext },
1889
+ body: { inputData: params.inputData, runtimeContext, closeOnSuspend: params.closeOnSuspend },
1932
1890
  stream: true
1933
1891
  }
1934
1892
  );
@@ -1945,7 +1903,7 @@ var Workflow = class extends BaseResource {
1945
1903
  async transform(chunk, controller) {
1946
1904
  try {
1947
1905
  const decoded = new TextDecoder().decode(chunk);
1948
- const chunks = decoded.split(RECORD_SEPARATOR2);
1906
+ const chunks = decoded.split(RECORD_SEPARATOR);
1949
1907
  for (const chunk2 of chunks) {
1950
1908
  if (chunk2) {
1951
1909
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -1980,6 +1938,22 @@ var Workflow = class extends BaseResource {
1980
1938
  }
1981
1939
  });
1982
1940
  }
1941
+ /**
1942
+ * Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
1943
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
1944
+ * @returns Promise containing the workflow resume results
1945
+ */
1946
+ resumeStreamVNext(params) {
1947
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1948
+ return this.request(`/api/workflows/${this.workflowId}/resume-stream?runId=${params.runId}`, {
1949
+ method: "POST",
1950
+ body: {
1951
+ step: params.step,
1952
+ resumeData: params.resumeData,
1953
+ runtimeContext
1954
+ }
1955
+ });
1956
+ }
1983
1957
  /**
1984
1958
  * Watches workflow transitions in real-time
1985
1959
  * @param runId - Optional run ID to filter the watch stream
@@ -2016,7 +1990,7 @@ var Workflow = class extends BaseResource {
2016
1990
  async start(controller) {
2017
1991
  try {
2018
1992
  for await (const record of records) {
2019
- const json = JSON.stringify(record) + RECORD_SEPARATOR2;
1993
+ const json = JSON.stringify(record) + RECORD_SEPARATOR;
2020
1994
  controller.enqueue(encoder.encode(json));
2021
1995
  }
2022
1996
  controller.close();
@@ -2114,10 +2088,11 @@ var MCPTool = class extends BaseResource {
2114
2088
  }
2115
2089
  /**
2116
2090
  * Retrieves details about this specific tool from the MCP server.
2091
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2117
2092
  * @returns Promise containing the tool's information (name, description, schema).
2118
2093
  */
2119
- details() {
2120
- return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
2094
+ details(runtimeContext) {
2095
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
2121
2096
  }
2122
2097
  /**
2123
2098
  * Executes this specific tool on the MCP server.
@@ -2138,7 +2113,7 @@ var MCPTool = class extends BaseResource {
2138
2113
  };
2139
2114
 
2140
2115
  // src/resources/agent-builder.ts
2141
- var RECORD_SEPARATOR3 = "";
2116
+ var RECORD_SEPARATOR2 = "";
2142
2117
  var AgentBuilder = class extends BaseResource {
2143
2118
  constructor(options, actionId) {
2144
2119
  super(options);
@@ -2173,11 +2148,20 @@ var AgentBuilder = class extends BaseResource {
2173
2148
  };
2174
2149
  }
2175
2150
  }
2151
+ /**
2152
+ * @deprecated Use createRunAsync() instead.
2153
+ * @throws {Error} Always throws an error directing users to use createRunAsync()
2154
+ */
2155
+ async createRun(_params) {
2156
+ throw new Error(
2157
+ "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."
2158
+ );
2159
+ }
2176
2160
  /**
2177
2161
  * Creates a new agent builder action run and returns the runId.
2178
2162
  * This calls `/api/agent-builder/:actionId/create-run`.
2179
2163
  */
2180
- async createRun(params) {
2164
+ async createRunAsync(params) {
2181
2165
  const searchParams = new URLSearchParams();
2182
2166
  if (!!params?.runId) {
2183
2167
  searchParams.set("runId", params.runId);
@@ -2187,14 +2171,6 @@ var AgentBuilder = class extends BaseResource {
2187
2171
  method: "POST"
2188
2172
  });
2189
2173
  }
2190
- /**
2191
- * Creates a new workflow run (alias for createRun)
2192
- * @param params - Optional object containing the optional runId
2193
- * @returns Promise containing the runId of the created run
2194
- */
2195
- createRunAsync(params) {
2196
- return this.createRun(params);
2197
- }
2198
2174
  /**
2199
2175
  * Starts agent builder action asynchronously and waits for completion.
2200
2176
  * This calls `/api/agent-builder/:actionId/start-async`.
@@ -2277,7 +2253,7 @@ var AgentBuilder = class extends BaseResource {
2277
2253
  if (done && !value) continue;
2278
2254
  try {
2279
2255
  const decoded = value ? new TextDecoder().decode(value) : "";
2280
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
2256
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
2281
2257
  buffer = chunks.pop() || "";
2282
2258
  for (const chunk of chunks) {
2283
2259
  if (chunk) {
@@ -2334,7 +2310,7 @@ var AgentBuilder = class extends BaseResource {
2334
2310
  async transform(chunk, controller) {
2335
2311
  try {
2336
2312
  const decoded = new TextDecoder().decode(chunk);
2337
- const chunks = decoded.split(RECORD_SEPARATOR3);
2313
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2338
2314
  for (const chunk2 of chunks) {
2339
2315
  if (chunk2) {
2340
2316
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2383,7 +2359,7 @@ var AgentBuilder = class extends BaseResource {
2383
2359
  async transform(chunk, controller) {
2384
2360
  try {
2385
2361
  const decoded = new TextDecoder().decode(chunk);
2386
- const chunks = decoded.split(RECORD_SEPARATOR3);
2362
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2387
2363
  for (const chunk2 of chunks) {
2388
2364
  if (chunk2) {
2389
2365
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2554,6 +2530,12 @@ var Observability = class extends BaseResource {
2554
2530
  const queryString = searchParams.toString();
2555
2531
  return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
2556
2532
  }
2533
+ score(params) {
2534
+ return this.request(`/api/observability/traces/score`, {
2535
+ method: "POST",
2536
+ body: { ...params }
2537
+ });
2538
+ }
2557
2539
  };
2558
2540
 
2559
2541
  // src/resources/network-memory-thread.ts
@@ -2620,7 +2602,7 @@ var NetworkMemoryThread = class extends BaseResource {
2620
2602
  };
2621
2603
 
2622
2604
  // src/resources/vNextNetwork.ts
2623
- var RECORD_SEPARATOR4 = "";
2605
+ var RECORD_SEPARATOR3 = "";
2624
2606
  var VNextNetwork = class extends BaseResource {
2625
2607
  constructor(options, networkId) {
2626
2608
  super(options);
@@ -2628,10 +2610,11 @@ var VNextNetwork = class extends BaseResource {
2628
2610
  }
2629
2611
  /**
2630
2612
  * Retrieves details about the network
2613
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2631
2614
  * @returns Promise containing vNext network details
2632
2615
  */
2633
- details() {
2634
- return this.request(`/api/networks/v-next/${this.networkId}`);
2616
+ details(runtimeContext) {
2617
+ return this.request(`/api/networks/v-next/${this.networkId}${runtimeContextQueryString(runtimeContext)}`);
2635
2618
  }
2636
2619
  /**
2637
2620
  * Generates a response from the v-next network
@@ -2672,7 +2655,7 @@ var VNextNetwork = class extends BaseResource {
2672
2655
  if (done && !value) continue;
2673
2656
  try {
2674
2657
  const decoded = value ? new TextDecoder().decode(value) : "";
2675
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
2658
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
2676
2659
  buffer = chunks.pop() || "";
2677
2660
  for (const chunk of chunks) {
2678
2661
  if (chunk) {
@@ -2766,10 +2749,17 @@ var MastraClient = class extends BaseResource {
2766
2749
  }
2767
2750
  /**
2768
2751
  * Retrieves all available agents
2752
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2769
2753
  * @returns Promise containing map of agent IDs to agent details
2770
2754
  */
2771
- getAgents() {
2772
- return this.request("/api/agents");
2755
+ getAgents(runtimeContext) {
2756
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2757
+ const searchParams = new URLSearchParams();
2758
+ if (runtimeContextParam) {
2759
+ searchParams.set("runtimeContext", runtimeContextParam);
2760
+ }
2761
+ const queryString = searchParams.toString();
2762
+ return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
2773
2763
  }
2774
2764
  /**
2775
2765
  * Gets an agent instance by ID
@@ -2787,6 +2777,14 @@ var MastraClient = class extends BaseResource {
2787
2777
  getMemoryThreads(params) {
2788
2778
  return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
2789
2779
  }
2780
+ /**
2781
+ * Retrieves memory config for a resource
2782
+ * @param params - Parameters containing the resource ID
2783
+ * @returns Promise containing array of memory threads
2784
+ */
2785
+ getMemoryConfig(params) {
2786
+ return this.request(`/api/memory/config?agentId=${params.agentId}`);
2787
+ }
2790
2788
  /**
2791
2789
  * Creates a new memory thread
2792
2790
  * @param params - Parameters for creating the memory thread
@@ -2803,6 +2801,24 @@ var MastraClient = class extends BaseResource {
2803
2801
  getMemoryThread(threadId, agentId) {
2804
2802
  return new MemoryThread(this.options, threadId, agentId);
2805
2803
  }
2804
+ getThreadMessages(threadId, opts = {}) {
2805
+ let url = "";
2806
+ if (opts.agentId) {
2807
+ url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
2808
+ } else if (opts.networkId) {
2809
+ url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
2810
+ }
2811
+ return this.request(url);
2812
+ }
2813
+ deleteThread(threadId, opts = {}) {
2814
+ let url = "";
2815
+ if (opts.agentId) {
2816
+ url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
2817
+ } else if (opts.networkId) {
2818
+ url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
2819
+ }
2820
+ return this.request(url, { method: "DELETE" });
2821
+ }
2806
2822
  /**
2807
2823
  * Saves messages to memory
2808
2824
  * @param params - Parameters containing messages to save
@@ -2865,10 +2881,17 @@ var MastraClient = class extends BaseResource {
2865
2881
  }
2866
2882
  /**
2867
2883
  * Retrieves all available tools
2884
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2868
2885
  * @returns Promise containing map of tool IDs to tool details
2869
2886
  */
2870
- getTools() {
2871
- return this.request("/api/tools");
2887
+ getTools(runtimeContext) {
2888
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2889
+ const searchParams = new URLSearchParams();
2890
+ if (runtimeContextParam) {
2891
+ searchParams.set("runtimeContext", runtimeContextParam);
2892
+ }
2893
+ const queryString = searchParams.toString();
2894
+ return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
2872
2895
  }
2873
2896
  /**
2874
2897
  * Gets a tool instance by ID
@@ -2878,27 +2901,19 @@ var MastraClient = class extends BaseResource {
2878
2901
  getTool(toolId) {
2879
2902
  return new Tool(this.options, toolId);
2880
2903
  }
2881
- /**
2882
- * Retrieves all available legacy workflows
2883
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
2884
- */
2885
- getLegacyWorkflows() {
2886
- return this.request("/api/workflows/legacy");
2887
- }
2888
- /**
2889
- * Gets a legacy workflow instance by ID
2890
- * @param workflowId - ID of the legacy workflow to retrieve
2891
- * @returns Legacy Workflow instance
2892
- */
2893
- getLegacyWorkflow(workflowId) {
2894
- return new LegacyWorkflow(this.options, workflowId);
2895
- }
2896
2904
  /**
2897
2905
  * Retrieves all available workflows
2906
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2898
2907
  * @returns Promise containing map of workflow IDs to workflow details
2899
2908
  */
2900
- getWorkflows() {
2901
- return this.request("/api/workflows");
2909
+ getWorkflows(runtimeContext) {
2910
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2911
+ const searchParams = new URLSearchParams();
2912
+ if (runtimeContextParam) {
2913
+ searchParams.set("runtimeContext", runtimeContextParam);
2914
+ }
2915
+ const queryString = searchParams.toString();
2916
+ return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
2902
2917
  }
2903
2918
  /**
2904
2919
  * Gets a workflow instance by ID
@@ -3066,13 +3081,6 @@ var MastraClient = class extends BaseResource {
3066
3081
  return this.request(`/api/telemetry`);
3067
3082
  }
3068
3083
  }
3069
- /**
3070
- * Retrieves all available networks
3071
- * @returns Promise containing map of network IDs to network details
3072
- */
3073
- getNetworks() {
3074
- return this.request("/api/networks");
3075
- }
3076
3084
  /**
3077
3085
  * Retrieves all available vNext networks
3078
3086
  * @returns Promise containing map of vNext network IDs to vNext network details
@@ -3080,14 +3088,6 @@ var MastraClient = class extends BaseResource {
3080
3088
  getVNextNetworks() {
3081
3089
  return this.request("/api/networks/v-next");
3082
3090
  }
3083
- /**
3084
- * Gets a network instance by ID
3085
- * @param networkId - ID of the network to retrieve
3086
- * @returns Network instance
3087
- */
3088
- getNetwork(networkId) {
3089
- return new Network(this.options, networkId);
3090
- }
3091
3091
  /**
3092
3092
  * Gets a vNext network instance by ID
3093
3093
  * @param networkId - ID of the vNext network to retrieve
@@ -3278,8 +3278,30 @@ var MastraClient = class extends BaseResource {
3278
3278
  getAITraces(params) {
3279
3279
  return this.observability.getTraces(params);
3280
3280
  }
3281
+ score(params) {
3282
+ return this.observability.score(params);
3283
+ }
3281
3284
  };
3282
3285
 
3283
- export { MastraClient };
3286
+ // src/tools.ts
3287
+ var ClientTool = class {
3288
+ id;
3289
+ description;
3290
+ inputSchema;
3291
+ outputSchema;
3292
+ execute;
3293
+ constructor(opts) {
3294
+ this.id = opts.id;
3295
+ this.description = opts.description;
3296
+ this.inputSchema = opts.inputSchema;
3297
+ this.outputSchema = opts.outputSchema;
3298
+ this.execute = opts.execute;
3299
+ }
3300
+ };
3301
+ function createTool(opts) {
3302
+ return new ClientTool(opts);
3303
+ }
3304
+
3305
+ export { ClientTool, MastraClient, createTool };
3284
3306
  //# sourceMappingURL=index.js.map
3285
3307
  //# sourceMappingURL=index.js.map