@mastra/client-js 0.0.0-issue-7087-20250910004053 → 0.0.0-just-snapshot-20251014192224

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 +431 -3
  2. package/README.md +6 -10
  3. package/dist/client.d.ts +37 -39
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/index.cjs +559 -547
  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 +558 -548
  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 +72 -43
  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 +17 -1
  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/vector.d.ts +5 -2
  24. package/dist/resources/vector.d.ts.map +1 -1
  25. package/dist/resources/workflow.d.ts +119 -19
  26. package/dist/resources/workflow.d.ts.map +1 -1
  27. package/dist/tools.d.ts +22 -0
  28. package/dist/tools.d.ts.map +1 -0
  29. package/dist/types.d.ts +65 -48
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/utils/index.d.ts +2 -0
  32. package/dist/utils/index.d.ts.map +1 -1
  33. package/dist/utils/process-mastra-stream.d.ts +5 -1
  34. package/dist/utils/process-mastra-stream.d.ts.map +1 -1
  35. package/package.json +5 -6
  36. package/dist/resources/legacy-workflow.d.ts +0 -87
  37. package/dist/resources/legacy-workflow.d.ts.map +0 -1
  38. package/dist/resources/network.d.ts +0 -30
  39. package/dist/resources/network.d.ts.map +0 -1
  40. package/dist/resources/vNextNetwork.d.ts +0 -42
  41. package/dist/resources/vNextNetwork.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -21,6 +21,20 @@ function parseClientRuntimeContext(runtimeContext$1) {
21
21
  }
22
22
  return void 0;
23
23
  }
24
+ function base64RuntimeContext(runtimeContext) {
25
+ if (runtimeContext) {
26
+ return btoa(JSON.stringify(runtimeContext));
27
+ }
28
+ return void 0;
29
+ }
30
+ function runtimeContextQueryString(runtimeContext) {
31
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
32
+ if (!runtimeContextParam) return "";
33
+ const searchParams = new URLSearchParams();
34
+ searchParams.set("runtimeContext", runtimeContextParam);
35
+ const queryString = searchParams.toString();
36
+ return queryString ? `?${queryString}` : "";
37
+ }
24
38
  function isZodType(value) {
25
39
  return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
26
40
  }
@@ -32,7 +46,7 @@ function zodToJsonSchema(zodSchema) {
32
46
  const fn = "toJSONSchema";
33
47
  return zod.z[fn].call(zod.z, zodSchema);
34
48
  }
35
- return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "none" });
49
+ return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "relative" });
36
50
  }
37
51
 
38
52
  // src/utils/process-client-tools.ts
@@ -65,7 +79,7 @@ function processClientTools(clientTools) {
65
79
  }
66
80
 
67
81
  // src/utils/process-mastra-stream.ts
68
- async function processMastraStream({
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.log("\u{1F3C1} Stream finished");
100
+ console.info("\u{1F3C1} Stream finished");
87
101
  return;
88
102
  }
89
103
  try {
@@ -99,6 +113,24 @@ async function processMastraStream({
99
113
  reader.releaseLock();
100
114
  }
101
115
  }
116
+ async function processMastraNetworkStream({
117
+ stream,
118
+ onChunk
119
+ }) {
120
+ return sharedProcessMastraStream({
121
+ stream,
122
+ onChunk
123
+ });
124
+ }
125
+ async function processMastraStream({
126
+ stream,
127
+ onChunk
128
+ }) {
129
+ return sharedProcessMastraStream({
130
+ stream,
131
+ onChunk
132
+ });
133
+ }
102
134
 
103
135
  // src/resources/base.ts
104
136
  var BaseResource = class {
@@ -187,7 +219,9 @@ async function executeToolCallAndRespond({
187
219
  resourceId,
188
220
  threadId,
189
221
  runtimeContext,
190
- tracingContext: { currentSpan: void 0 }
222
+ tracingContext: { currentSpan: void 0 },
223
+ suspend: async () => {
224
+ }
191
225
  },
192
226
  {
193
227
  messages: response.messages,
@@ -195,11 +229,7 @@ async function executeToolCallAndRespond({
195
229
  }
196
230
  );
197
231
  const updatedMessages = [
198
- {
199
- role: "user",
200
- content: params.messages
201
- },
202
- ...response.response.messages,
232
+ ...response.response.messages || [],
203
233
  {
204
234
  role: "tool",
205
235
  content: [
@@ -261,17 +291,21 @@ var AgentVoice = class extends BaseResource {
261
291
  }
262
292
  /**
263
293
  * Get available speakers for the agent's voice provider
294
+ * @param runtimeContext - Optional runtime context to pass as query parameter
295
+ * @param runtimeContext - Optional runtime context to pass as query parameter
264
296
  * @returns Promise containing list of available speakers
265
297
  */
266
- getSpeakers() {
267
- return this.request(`/api/agents/${this.agentId}/voice/speakers`);
298
+ getSpeakers(runtimeContext) {
299
+ return this.request(`/api/agents/${this.agentId}/voice/speakers${runtimeContextQueryString(runtimeContext)}`);
268
300
  }
269
301
  /**
270
302
  * Get the listener configuration for the agent's voice provider
303
+ * @param runtimeContext - Optional runtime context to pass as query parameter
304
+ * @param runtimeContext - Optional runtime context to pass as query parameter
271
305
  * @returns Promise containing a check if the agent has listening capabilities
272
306
  */
273
- getListener() {
274
- return this.request(`/api/agents/${this.agentId}/voice/listener`);
307
+ getListener(runtimeContext) {
308
+ return this.request(`/api/agents/${this.agentId}/voice/listener${runtimeContextQueryString(runtimeContext)}`);
275
309
  }
276
310
  };
277
311
  var Agent = class extends BaseResource {
@@ -283,16 +317,11 @@ var Agent = class extends BaseResource {
283
317
  voice;
284
318
  /**
285
319
  * Retrieves details about the agent
320
+ * @param runtimeContext - Optional runtime context to pass as query parameter
286
321
  * @returns Promise containing agent details including model and instructions
287
322
  */
288
- details() {
289
- return this.request(`/api/agents/${this.agentId}`);
290
- }
291
- async generate(params) {
292
- console.warn(
293
- "Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th. Please use generateLegacy if you don't want to upgrade just yet."
294
- );
295
- return this.generateLegacy(params);
323
+ details(runtimeContext) {
324
+ return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
296
325
  }
297
326
  async generateLegacy(params) {
298
327
  const processedParams = {
@@ -325,7 +354,9 @@ var Agent = class extends BaseResource {
325
354
  resourceId,
326
355
  threadId,
327
356
  runtimeContext,
328
- tracingContext: { currentSpan: void 0 }
357
+ tracingContext: { currentSpan: void 0 },
358
+ suspend: async () => {
359
+ }
329
360
  },
330
361
  {
331
362
  messages: response.messages,
@@ -333,10 +364,6 @@ var Agent = class extends BaseResource {
333
364
  }
334
365
  );
335
366
  const updatedMessages = [
336
- {
337
- role: "user",
338
- content: params.messages
339
- },
340
367
  ...response.response.messages,
341
368
  {
342
369
  role: "tool",
@@ -359,7 +386,16 @@ var Agent = class extends BaseResource {
359
386
  }
360
387
  return response;
361
388
  }
362
- async generateVNext(params) {
389
+ async generate(messagesOrParams, options) {
390
+ let params;
391
+ if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
392
+ params = messagesOrParams;
393
+ } else {
394
+ params = {
395
+ messages: messagesOrParams,
396
+ ...options
397
+ };
398
+ }
363
399
  const processedParams = {
364
400
  ...params,
365
401
  output: params.output ? zodToJsonSchema(params.output) : void 0,
@@ -372,7 +408,7 @@ var Agent = class extends BaseResource {
372
408
  };
373
409
  const { runId, resourceId, threadId, runtimeContext } = processedParams;
374
410
  const response = await this.request(
375
- `/api/agents/${this.agentId}/generate/vnext`,
411
+ `/api/agents/${this.agentId}/generate`,
376
412
  {
377
413
  method: "POST",
378
414
  body: processedParams
@@ -386,7 +422,7 @@ var Agent = class extends BaseResource {
386
422
  resourceId,
387
423
  threadId,
388
424
  runtimeContext,
389
- respondFn: this.generateVNext.bind(this)
425
+ respondFn: this.generate.bind(this)
390
426
  });
391
427
  }
392
428
  return response;
@@ -653,17 +689,6 @@ var Agent = class extends BaseResource {
653
689
  });
654
690
  onFinish?.({ message, finishReason, usage });
655
691
  }
656
- /**
657
- * Streams a response from the agent
658
- * @param params - Stream parameters including prompt
659
- * @returns Promise containing the enhanced Response object with processDataStream method
660
- */
661
- async stream(params) {
662
- console.warn(
663
- "Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th. Please use streamLegacy if you don't want to upgrade just yet."
664
- );
665
- return this.streamLegacy(params);
666
- }
667
692
  /**
668
693
  * Streams a response from the agent
669
694
  * @param params - Stream parameters including prompt
@@ -678,7 +703,7 @@ var Agent = class extends BaseResource {
678
703
  clientTools: processClientTools(params.clientTools)
679
704
  };
680
705
  const { readable, writable } = new TransformStream();
681
- const response = await this.processStreamResponse(processedParams, writable);
706
+ const response = await this.processStreamResponseLegacy(processedParams, writable);
682
707
  const streamResponse = new Response(readable, {
683
708
  status: response.status,
684
709
  statusText: response.statusText,
@@ -765,6 +790,14 @@ var Agent = class extends BaseResource {
765
790
  // but this is completely wrong and this fn is probably broken. Remove ":any" and you'll see a bunch of type errors
766
791
  onChunk: async (chunk) => {
767
792
  switch (chunk.type) {
793
+ case "tripwire": {
794
+ message.parts.push({
795
+ type: "text",
796
+ text: chunk.payload.tripwireReason
797
+ });
798
+ execUpdate();
799
+ break;
800
+ }
768
801
  case "step-start": {
769
802
  if (!replaceLastMessage) {
770
803
  message.id = chunk.payload.messageId;
@@ -945,8 +978,8 @@ var Agent = class extends BaseResource {
945
978
  });
946
979
  onFinish?.({ message, finishReason, usage });
947
980
  }
948
- async processStreamResponse_vNext(processedParams, writable) {
949
- const response = await this.request(`/api/agents/${this.agentId}/stream/vnext`, {
981
+ async processStreamResponse(processedParams, writable) {
982
+ const response = await this.request(`/api/agents/${this.agentId}/stream`, {
950
983
  method: "POST",
951
984
  body: processedParams,
952
985
  stream: true
@@ -961,18 +994,17 @@ var Agent = class extends BaseResource {
961
994
  streamForWritable.pipeTo(
962
995
  new WritableStream({
963
996
  async write(chunk) {
997
+ let writer;
964
998
  try {
999
+ writer = writable.getWriter();
965
1000
  const text = new TextDecoder().decode(chunk);
966
- if (text.includes("[DONE]")) {
967
- return;
968
- }
1001
+ const lines = text.split("\n\n");
1002
+ const readableLines = lines.filter((line) => line !== "[DONE]").join("\n\n");
1003
+ await writer.write(new TextEncoder().encode(readableLines));
969
1004
  } catch {
970
- }
971
- const writer = writable.getWriter();
972
- try {
973
- await writer.write(chunk);
1005
+ await writer?.write(chunk);
974
1006
  } finally {
975
- writer.releaseLock();
1007
+ writer?.releaseLock();
976
1008
  }
977
1009
  }
978
1010
  }),
@@ -998,9 +1030,11 @@ var Agent = class extends BaseResource {
998
1030
  if (toolCall) {
999
1031
  toolCalls.push(toolCall);
1000
1032
  }
1033
+ let shouldExecuteClientTool = false;
1001
1034
  for (const toolCall2 of toolCalls) {
1002
1035
  const clientTool = processedParams.clientTools?.[toolCall2.toolName];
1003
1036
  if (clientTool && clientTool.execute) {
1037
+ shouldExecuteClientTool = true;
1004
1038
  const result = await clientTool.execute(
1005
1039
  {
1006
1040
  context: toolCall2?.args,
@@ -1009,7 +1043,9 @@ var Agent = class extends BaseResource {
1009
1043
  threadId: processedParams.threadId,
1010
1044
  runtimeContext: processedParams.runtimeContext,
1011
1045
  // TODO: Pass proper tracing context when client-js supports tracing
1012
- tracingContext: { currentSpan: void 0 }
1046
+ tracingContext: { currentSpan: void 0 },
1047
+ suspend: async () => {
1048
+ }
1013
1049
  },
1014
1050
  {
1015
1051
  messages: response.messages,
@@ -1035,10 +1071,8 @@ var Agent = class extends BaseResource {
1035
1071
  toolInvocation.state = "result";
1036
1072
  toolInvocation.result = result;
1037
1073
  }
1038
- const originalMessages = processedParams.messages;
1039
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1040
- const updatedMessages = lastMessage != null ? [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messageArray, ...messages];
1041
- this.processStreamResponse_vNext(
1074
+ const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
1075
+ this.processStreamResponse(
1042
1076
  {
1043
1077
  ...processedParams,
1044
1078
  messages: updatedMessages
@@ -1049,6 +1083,11 @@ var Agent = class extends BaseResource {
1049
1083
  });
1050
1084
  }
1051
1085
  }
1086
+ if (!shouldExecuteClientTool) {
1087
+ setTimeout(() => {
1088
+ writable.close();
1089
+ }, 0);
1090
+ }
1052
1091
  } else {
1053
1092
  setTimeout(() => {
1054
1093
  writable.close();
@@ -1064,7 +1103,40 @@ var Agent = class extends BaseResource {
1064
1103
  }
1065
1104
  return response;
1066
1105
  }
1067
- async streamVNext(params) {
1106
+ async network(params) {
1107
+ const response = await this.request(`/api/agents/${this.agentId}/network`, {
1108
+ method: "POST",
1109
+ body: params,
1110
+ stream: true
1111
+ });
1112
+ if (!response.body) {
1113
+ throw new Error("No response body");
1114
+ }
1115
+ const streamResponse = new Response(response.body, {
1116
+ status: response.status,
1117
+ statusText: response.statusText,
1118
+ headers: response.headers
1119
+ });
1120
+ streamResponse.processDataStream = async ({
1121
+ onChunk
1122
+ }) => {
1123
+ await processMastraNetworkStream({
1124
+ stream: streamResponse.body,
1125
+ onChunk
1126
+ });
1127
+ };
1128
+ return streamResponse;
1129
+ }
1130
+ async stream(messagesOrParams, options) {
1131
+ let params;
1132
+ if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
1133
+ params = messagesOrParams;
1134
+ } else {
1135
+ params = {
1136
+ messages: messagesOrParams,
1137
+ ...options
1138
+ };
1139
+ }
1068
1140
  const processedParams = {
1069
1141
  ...params,
1070
1142
  output: params.output ? zodToJsonSchema(params.output) : void 0,
@@ -1076,7 +1148,7 @@ var Agent = class extends BaseResource {
1076
1148
  } : void 0
1077
1149
  };
1078
1150
  const { readable, writable } = new TransformStream();
1079
- const response = await this.processStreamResponse_vNext(processedParams, writable);
1151
+ const response = await this.processStreamResponse(processedParams, writable);
1080
1152
  const streamResponse = new Response(readable, {
1081
1153
  status: response.status,
1082
1154
  statusText: response.statusText,
@@ -1095,7 +1167,7 @@ var Agent = class extends BaseResource {
1095
1167
  /**
1096
1168
  * Processes the stream response and handles tool calls
1097
1169
  */
1098
- async processStreamResponse(processedParams, writable) {
1170
+ async processStreamResponseLegacy(processedParams, writable) {
1099
1171
  const response = await this.request(`/api/agents/${this.agentId}/stream-legacy`, {
1100
1172
  method: "POST",
1101
1173
  body: processedParams,
@@ -1140,7 +1212,9 @@ var Agent = class extends BaseResource {
1140
1212
  threadId: processedParams.threadId,
1141
1213
  runtimeContext: processedParams.runtimeContext,
1142
1214
  // TODO: Pass proper tracing context when client-js supports tracing
1143
- tracingContext: { currentSpan: void 0 }
1215
+ tracingContext: { currentSpan: void 0 },
1216
+ suspend: async () => {
1217
+ }
1144
1218
  },
1145
1219
  {
1146
1220
  messages: response.messages,
@@ -1178,12 +1252,10 @@ var Agent = class extends BaseResource {
1178
1252
  } finally {
1179
1253
  writer.releaseLock();
1180
1254
  }
1181
- const originalMessages = processedParams.messages;
1182
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1183
- this.processStreamResponse(
1255
+ this.processStreamResponseLegacy(
1184
1256
  {
1185
1257
  ...processedParams,
1186
- messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1258
+ messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1187
1259
  },
1188
1260
  writable
1189
1261
  ).catch((error) => {
@@ -1209,10 +1281,11 @@ var Agent = class extends BaseResource {
1209
1281
  /**
1210
1282
  * Gets details about a specific tool available to the agent
1211
1283
  * @param toolId - ID of the tool to retrieve
1284
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1212
1285
  * @returns Promise containing tool details
1213
1286
  */
1214
- getTool(toolId) {
1215
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
1287
+ getTool(toolId, runtimeContext) {
1288
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}${runtimeContextQueryString(runtimeContext)}`);
1216
1289
  }
1217
1290
  /**
1218
1291
  * Executes a tool for the agent
@@ -1223,7 +1296,7 @@ var Agent = class extends BaseResource {
1223
1296
  executeTool(toolId, params) {
1224
1297
  const body = {
1225
1298
  data: params.data,
1226
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
1299
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1227
1300
  };
1228
1301
  return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
1229
1302
  method: "POST",
@@ -1232,17 +1305,19 @@ var Agent = class extends BaseResource {
1232
1305
  }
1233
1306
  /**
1234
1307
  * Retrieves evaluation results for the agent
1308
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1235
1309
  * @returns Promise containing agent evaluations
1236
1310
  */
1237
- evals() {
1238
- return this.request(`/api/agents/${this.agentId}/evals/ci`);
1311
+ evals(runtimeContext) {
1312
+ return this.request(`/api/agents/${this.agentId}/evals/ci${runtimeContextQueryString(runtimeContext)}`);
1239
1313
  }
1240
1314
  /**
1241
1315
  * Retrieves live evaluation results for the agent
1316
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1242
1317
  * @returns Promise containing live agent evaluations
1243
1318
  */
1244
- liveEvals() {
1245
- return this.request(`/api/agents/${this.agentId}/evals/live`);
1319
+ liveEvals(runtimeContext) {
1320
+ return this.request(`/api/agents/${this.agentId}/evals/live${runtimeContextQueryString(runtimeContext)}`);
1246
1321
  }
1247
1322
  /**
1248
1323
  * Updates the model for the agent
@@ -1255,61 +1330,33 @@ var Agent = class extends BaseResource {
1255
1330
  body: params
1256
1331
  });
1257
1332
  }
1258
- };
1259
- var Network = class extends BaseResource {
1260
- constructor(options, networkId) {
1261
- super(options);
1262
- this.networkId = networkId;
1263
- }
1264
- /**
1265
- * Retrieves details about the network
1266
- * @returns Promise containing network details
1267
- */
1268
- details() {
1269
- return this.request(`/api/networks/${this.networkId}`);
1270
- }
1271
1333
  /**
1272
- * Generates a response from the agent
1273
- * @param params - Generation parameters including prompt
1274
- * @returns Promise containing the generated response
1334
+ * Updates the model for the agent in the model list
1335
+ * @param params - Parameters for updating the model
1336
+ * @returns Promise containing the updated model
1275
1337
  */
1276
- generate(params) {
1277
- const processedParams = {
1278
- ...params,
1279
- output: zodToJsonSchema(params.output),
1280
- experimental_output: zodToJsonSchema(params.experimental_output)
1281
- };
1282
- return this.request(`/api/networks/${this.networkId}/generate`, {
1338
+ updateModelInModelList({ modelConfigId, ...params }) {
1339
+ return this.request(`/api/agents/${this.agentId}/models/${modelConfigId}`, {
1283
1340
  method: "POST",
1284
- body: processedParams
1341
+ body: params
1285
1342
  });
1286
1343
  }
1287
1344
  /**
1288
- * Streams a response from the agent
1289
- * @param params - Stream parameters including prompt
1290
- * @returns Promise containing the enhanced Response object with processDataStream method
1345
+ * Reorders the models for the agent
1346
+ * @param params - Parameters for reordering the model list
1347
+ * @returns Promise containing the updated model list
1291
1348
  */
1292
- async stream(params) {
1293
- const processedParams = {
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`, {
1349
+ reorderModelList(params) {
1350
+ return this.request(`/api/agents/${this.agentId}/models/reorder`, {
1299
1351
  method: "POST",
1300
- body: processedParams,
1301
- stream: true
1352
+ body: params
1302
1353
  });
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;
1354
+ }
1355
+ async generateVNext(_messagesOrParams, _options) {
1356
+ throw new Error("generateVNext has been renamed to generate. Please use generate instead.");
1357
+ }
1358
+ async streamVNext(_messagesOrParams, _options) {
1359
+ throw new Error("streamVNext has been renamed to stream. Please use stream instead.");
1313
1360
  }
1314
1361
  };
1315
1362
 
@@ -1400,10 +1447,13 @@ var Vector = class extends BaseResource {
1400
1447
  /**
1401
1448
  * Retrieves details about a specific vector index
1402
1449
  * @param indexName - Name of the index to get details for
1450
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1403
1451
  * @returns Promise containing vector index details
1404
1452
  */
1405
- details(indexName) {
1406
- return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`);
1453
+ details(indexName, runtimeContext) {
1454
+ return this.request(
1455
+ `/api/vector/${this.vectorName}/indexes/${indexName}${runtimeContextQueryString(runtimeContext)}`
1456
+ );
1407
1457
  }
1408
1458
  /**
1409
1459
  * Deletes a vector index
@@ -1417,10 +1467,11 @@ var Vector = class extends BaseResource {
1417
1467
  }
1418
1468
  /**
1419
1469
  * Retrieves a list of all available indexes
1470
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1420
1471
  * @returns Promise containing array of index names
1421
1472
  */
1422
- getIndexes() {
1423
- return this.request(`/api/vector/${this.vectorName}/indexes`);
1473
+ getIndexes(runtimeContext) {
1474
+ return this.request(`/api/vector/${this.vectorName}/indexes${runtimeContextQueryString(runtimeContext)}`);
1424
1475
  }
1425
1476
  /**
1426
1477
  * Creates a new vector index
@@ -1457,187 +1508,6 @@ var Vector = class extends BaseResource {
1457
1508
  }
1458
1509
  };
1459
1510
 
1460
- // src/resources/legacy-workflow.ts
1461
- var RECORD_SEPARATOR = "";
1462
- var LegacyWorkflow = class extends BaseResource {
1463
- constructor(options, workflowId) {
1464
- super(options);
1465
- this.workflowId = workflowId;
1466
- }
1467
- /**
1468
- * Retrieves details about the legacy workflow
1469
- * @returns Promise containing legacy workflow details including steps and graphs
1470
- */
1471
- details() {
1472
- return this.request(`/api/workflows/legacy/${this.workflowId}`);
1473
- }
1474
- /**
1475
- * Retrieves all runs for a legacy workflow
1476
- * @param params - Parameters for filtering runs
1477
- * @returns Promise containing legacy workflow runs array
1478
- */
1479
- runs(params) {
1480
- const searchParams = new URLSearchParams();
1481
- if (params?.fromDate) {
1482
- searchParams.set("fromDate", params.fromDate.toISOString());
1483
- }
1484
- if (params?.toDate) {
1485
- searchParams.set("toDate", params.toDate.toISOString());
1486
- }
1487
- if (params?.limit) {
1488
- searchParams.set("limit", String(params.limit));
1489
- }
1490
- if (params?.offset) {
1491
- searchParams.set("offset", String(params.offset));
1492
- }
1493
- if (params?.resourceId) {
1494
- searchParams.set("resourceId", params.resourceId);
1495
- }
1496
- if (searchParams.size) {
1497
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
1498
- } else {
1499
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
1500
- }
1501
- }
1502
- /**
1503
- * Creates a new legacy workflow run
1504
- * @returns Promise containing the generated run ID
1505
- */
1506
- createRun(params) {
1507
- const searchParams = new URLSearchParams();
1508
- if (!!params?.runId) {
1509
- searchParams.set("runId", params.runId);
1510
- }
1511
- return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
1512
- method: "POST"
1513
- });
1514
- }
1515
- /**
1516
- * Starts a legacy workflow run synchronously without waiting for the workflow to complete
1517
- * @param params - Object containing the runId and triggerData
1518
- * @returns Promise containing success message
1519
- */
1520
- start(params) {
1521
- return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
1522
- method: "POST",
1523
- body: params?.triggerData
1524
- });
1525
- }
1526
- /**
1527
- * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
1528
- * @param stepId - ID of the step to resume
1529
- * @param runId - ID of the legacy workflow run
1530
- * @param context - Context to resume the legacy workflow with
1531
- * @returns Promise containing the legacy workflow resume results
1532
- */
1533
- resume({
1534
- stepId,
1535
- runId,
1536
- context
1537
- }) {
1538
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
1539
- method: "POST",
1540
- body: {
1541
- stepId,
1542
- context
1543
- }
1544
- });
1545
- }
1546
- /**
1547
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
1548
- * @param params - Object containing the optional runId and triggerData
1549
- * @returns Promise containing the workflow execution results
1550
- */
1551
- startAsync(params) {
1552
- const searchParams = new URLSearchParams();
1553
- if (!!params?.runId) {
1554
- searchParams.set("runId", params.runId);
1555
- }
1556
- return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
1557
- method: "POST",
1558
- body: params?.triggerData
1559
- });
1560
- }
1561
- /**
1562
- * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
1563
- * @param params - Object containing the runId, stepId, and context
1564
- * @returns Promise containing the workflow resume results
1565
- */
1566
- resumeAsync(params) {
1567
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
1568
- method: "POST",
1569
- body: {
1570
- stepId: params.stepId,
1571
- context: params.context
1572
- }
1573
- });
1574
- }
1575
- /**
1576
- * Creates an async generator that processes a readable stream and yields records
1577
- * separated by the Record Separator character (\x1E)
1578
- *
1579
- * @param stream - The readable stream to process
1580
- * @returns An async generator that yields parsed records
1581
- */
1582
- async *streamProcessor(stream) {
1583
- const reader = stream.getReader();
1584
- let doneReading = false;
1585
- let buffer = "";
1586
- try {
1587
- while (!doneReading) {
1588
- const { done, value } = await reader.read();
1589
- doneReading = done;
1590
- if (done && !value) continue;
1591
- try {
1592
- const decoded = value ? new TextDecoder().decode(value) : "";
1593
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1594
- buffer = chunks.pop() || "";
1595
- for (const chunk of chunks) {
1596
- if (chunk) {
1597
- if (typeof chunk === "string") {
1598
- try {
1599
- const parsedChunk = JSON.parse(chunk);
1600
- yield parsedChunk;
1601
- } catch {
1602
- }
1603
- }
1604
- }
1605
- }
1606
- } catch {
1607
- }
1608
- }
1609
- if (buffer) {
1610
- try {
1611
- yield JSON.parse(buffer);
1612
- } catch {
1613
- }
1614
- }
1615
- } finally {
1616
- reader.cancel().catch(() => {
1617
- });
1618
- }
1619
- }
1620
- /**
1621
- * Watches legacy workflow transitions in real-time
1622
- * @param runId - Optional run ID to filter the watch stream
1623
- * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
1624
- */
1625
- async watch({ runId }, onRecord) {
1626
- const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
1627
- stream: true
1628
- });
1629
- if (!response.ok) {
1630
- throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
1631
- }
1632
- if (!response.body) {
1633
- throw new Error("Response body is null");
1634
- }
1635
- for await (const record of this.streamProcessor(response.body)) {
1636
- onRecord(record);
1637
- }
1638
- }
1639
- };
1640
-
1641
1511
  // src/resources/tool.ts
1642
1512
  var Tool = class extends BaseResource {
1643
1513
  constructor(options, toolId) {
@@ -1646,10 +1516,11 @@ var Tool = class extends BaseResource {
1646
1516
  }
1647
1517
  /**
1648
1518
  * Retrieves details about the tool
1519
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1649
1520
  * @returns Promise containing tool details including description and schemas
1650
1521
  */
1651
- details() {
1652
- return this.request(`/api/tools/${this.toolId}`);
1522
+ details(runtimeContext) {
1523
+ return this.request(`/api/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
1653
1524
  }
1654
1525
  /**
1655
1526
  * Executes the tool with the provided parameters
@@ -1673,7 +1544,7 @@ var Tool = class extends BaseResource {
1673
1544
  };
1674
1545
 
1675
1546
  // src/resources/workflow.ts
1676
- var RECORD_SEPARATOR2 = "";
1547
+ var RECORD_SEPARATOR = "";
1677
1548
  var Workflow = class extends BaseResource {
1678
1549
  constructor(options, workflowId) {
1679
1550
  super(options);
@@ -1697,7 +1568,7 @@ var Workflow = class extends BaseResource {
1697
1568
  if (done && !value) continue;
1698
1569
  try {
1699
1570
  const decoded = value ? new TextDecoder().decode(value) : "";
1700
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
1571
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1701
1572
  buffer = chunks.pop() || "";
1702
1573
  for (const chunk of chunks) {
1703
1574
  if (chunk) {
@@ -1726,17 +1597,20 @@ var Workflow = class extends BaseResource {
1726
1597
  }
1727
1598
  /**
1728
1599
  * Retrieves details about the workflow
1600
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1729
1601
  * @returns Promise containing workflow details including steps and graphs
1730
1602
  */
1731
- details() {
1732
- return this.request(`/api/workflows/${this.workflowId}`);
1603
+ details(runtimeContext) {
1604
+ return this.request(`/api/workflows/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
1733
1605
  }
1734
1606
  /**
1735
1607
  * Retrieves all runs for a workflow
1736
1608
  * @param params - Parameters for filtering runs
1609
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1737
1610
  * @returns Promise containing workflow runs array
1738
1611
  */
1739
- runs(params) {
1612
+ runs(params, runtimeContext) {
1613
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1740
1614
  const searchParams = new URLSearchParams();
1741
1615
  if (params?.fromDate) {
1742
1616
  searchParams.set("fromDate", params.fromDate.toISOString());
@@ -1753,6 +1627,9 @@ var Workflow = class extends BaseResource {
1753
1627
  if (params?.resourceId) {
1754
1628
  searchParams.set("resourceId", params.resourceId);
1755
1629
  }
1630
+ if (runtimeContextParam) {
1631
+ searchParams.set("runtimeContext", runtimeContextParam);
1632
+ }
1756
1633
  if (searchParams.size) {
1757
1634
  return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
1758
1635
  } else {
@@ -1762,18 +1639,22 @@ var Workflow = class extends BaseResource {
1762
1639
  /**
1763
1640
  * Retrieves a specific workflow run by its ID
1764
1641
  * @param runId - The ID of the workflow run to retrieve
1642
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1765
1643
  * @returns Promise containing the workflow run details
1766
1644
  */
1767
- runById(runId) {
1768
- return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
1645
+ runById(runId, runtimeContext) {
1646
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${runtimeContextQueryString(runtimeContext)}`);
1769
1647
  }
1770
1648
  /**
1771
1649
  * Retrieves the execution result for a specific workflow run by its ID
1772
1650
  * @param runId - The ID of the workflow run to retrieve the execution result for
1651
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1773
1652
  * @returns Promise containing the workflow run execution result
1774
1653
  */
1775
- runExecutionResult(runId) {
1776
- return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
1654
+ runExecutionResult(runId, runtimeContext) {
1655
+ return this.request(
1656
+ `/api/workflows/${this.workflowId}/runs/${runId}/execution-result${runtimeContextQueryString(runtimeContext)}`
1657
+ );
1777
1658
  }
1778
1659
  /**
1779
1660
  * Cancels a specific workflow run by its ID
@@ -1797,26 +1678,82 @@ var Workflow = class extends BaseResource {
1797
1678
  });
1798
1679
  }
1799
1680
  /**
1800
- * Creates a new workflow run
1801
- * @param params - Optional object containing the optional runId
1802
- * @returns Promise containing the runId of the created run
1681
+ * @deprecated Use createRunAsync() instead.
1682
+ * @throws {Error} Always throws an error directing users to use createRunAsync()
1803
1683
  */
1804
- createRun(params) {
1805
- const searchParams = new URLSearchParams();
1806
- if (!!params?.runId) {
1807
- searchParams.set("runId", params.runId);
1808
- }
1809
- return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
1810
- method: "POST"
1811
- });
1684
+ async createRun(_params) {
1685
+ throw new Error(
1686
+ "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."
1687
+ );
1812
1688
  }
1813
1689
  /**
1814
- * Creates a new workflow run (alias for createRun)
1690
+ * Creates a new workflow run
1815
1691
  * @param params - Optional object containing the optional runId
1816
- * @returns Promise containing the runId of the created run
1692
+ * @returns Promise containing the runId of the created run with methods to control execution
1817
1693
  */
1818
- createRunAsync(params) {
1819
- return this.createRun(params);
1694
+ async createRunAsync(params) {
1695
+ const searchParams = new URLSearchParams();
1696
+ if (!!params?.runId) {
1697
+ searchParams.set("runId", params.runId);
1698
+ }
1699
+ const res = await this.request(
1700
+ `/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`,
1701
+ {
1702
+ method: "POST"
1703
+ }
1704
+ );
1705
+ const runId = res.runId;
1706
+ return {
1707
+ runId,
1708
+ start: async (p) => {
1709
+ return this.start({
1710
+ runId,
1711
+ inputData: p.inputData,
1712
+ runtimeContext: p.runtimeContext,
1713
+ tracingOptions: p.tracingOptions
1714
+ });
1715
+ },
1716
+ startAsync: async (p) => {
1717
+ return this.startAsync({
1718
+ runId,
1719
+ inputData: p.inputData,
1720
+ runtimeContext: p.runtimeContext,
1721
+ tracingOptions: p.tracingOptions
1722
+ });
1723
+ },
1724
+ watch: async (onRecord) => {
1725
+ return this.watch({ runId }, onRecord);
1726
+ },
1727
+ stream: async (p) => {
1728
+ return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1729
+ },
1730
+ resume: async (p) => {
1731
+ return this.resume({
1732
+ runId,
1733
+ step: p.step,
1734
+ resumeData: p.resumeData,
1735
+ runtimeContext: p.runtimeContext,
1736
+ tracingOptions: p.tracingOptions
1737
+ });
1738
+ },
1739
+ resumeAsync: async (p) => {
1740
+ return this.resumeAsync({
1741
+ runId,
1742
+ step: p.step,
1743
+ resumeData: p.resumeData,
1744
+ runtimeContext: p.runtimeContext,
1745
+ tracingOptions: p.tracingOptions
1746
+ });
1747
+ },
1748
+ resumeStreamVNext: async (p) => {
1749
+ return this.resumeStreamVNext({
1750
+ runId,
1751
+ step: p.step,
1752
+ resumeData: p.resumeData,
1753
+ runtimeContext: p.runtimeContext
1754
+ });
1755
+ }
1756
+ };
1820
1757
  }
1821
1758
  /**
1822
1759
  * Starts a workflow run synchronously without waiting for the workflow to complete
@@ -1827,7 +1764,7 @@ var Workflow = class extends BaseResource {
1827
1764
  const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1828
1765
  return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
1829
1766
  method: "POST",
1830
- body: { inputData: params?.inputData, runtimeContext }
1767
+ body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
1831
1768
  });
1832
1769
  }
1833
1770
  /**
@@ -1839,16 +1776,17 @@ var Workflow = class extends BaseResource {
1839
1776
  step,
1840
1777
  runId,
1841
1778
  resumeData,
1779
+ tracingOptions,
1842
1780
  ...rest
1843
1781
  }) {
1844
1782
  const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
1845
1783
  return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
1846
1784
  method: "POST",
1847
- stream: true,
1848
1785
  body: {
1849
1786
  step,
1850
1787
  resumeData,
1851
- runtimeContext
1788
+ runtimeContext,
1789
+ tracingOptions
1852
1790
  }
1853
1791
  });
1854
1792
  }
@@ -1865,7 +1803,7 @@ var Workflow = class extends BaseResource {
1865
1803
  const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1866
1804
  return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
1867
1805
  method: "POST",
1868
- body: { inputData: params.inputData, runtimeContext }
1806
+ body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
1869
1807
  });
1870
1808
  }
1871
1809
  /**
@@ -1883,12 +1821,12 @@ var Workflow = class extends BaseResource {
1883
1821
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
1884
1822
  {
1885
1823
  method: "POST",
1886
- body: { inputData: params.inputData, runtimeContext },
1824
+ body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
1887
1825
  stream: true
1888
1826
  }
1889
1827
  );
1890
1828
  if (!response.ok) {
1891
- throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
1829
+ throw new Error(`Failed to stream workflow: ${response.statusText}`);
1892
1830
  }
1893
1831
  if (!response.body) {
1894
1832
  throw new Error("Response body is null");
@@ -1900,7 +1838,54 @@ var Workflow = class extends BaseResource {
1900
1838
  async transform(chunk, controller) {
1901
1839
  try {
1902
1840
  const decoded = new TextDecoder().decode(chunk);
1903
- const chunks = decoded.split(RECORD_SEPARATOR2);
1841
+ const chunks = decoded.split(RECORD_SEPARATOR);
1842
+ for (const chunk2 of chunks) {
1843
+ if (chunk2) {
1844
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
1845
+ try {
1846
+ const parsedChunk = JSON.parse(newChunk);
1847
+ controller.enqueue(parsedChunk);
1848
+ failedChunk = void 0;
1849
+ } catch {
1850
+ failedChunk = newChunk;
1851
+ }
1852
+ }
1853
+ }
1854
+ } catch {
1855
+ }
1856
+ }
1857
+ });
1858
+ return response.body.pipeThrough(transformStream);
1859
+ }
1860
+ /**
1861
+ * Observes workflow stream for a workflow run
1862
+ * @param params - Object containing the runId
1863
+ * @returns Promise containing the workflow execution results
1864
+ */
1865
+ async observeStream(params) {
1866
+ const searchParams = new URLSearchParams();
1867
+ searchParams.set("runId", params.runId);
1868
+ const response = await this.request(
1869
+ `/api/workflows/${this.workflowId}/observe-stream?${searchParams.toString()}`,
1870
+ {
1871
+ method: "POST",
1872
+ stream: true
1873
+ }
1874
+ );
1875
+ if (!response.ok) {
1876
+ throw new Error(`Failed to observe workflow stream: ${response.statusText}`);
1877
+ }
1878
+ if (!response.body) {
1879
+ throw new Error("Response body is null");
1880
+ }
1881
+ let failedChunk = void 0;
1882
+ const transformStream = new TransformStream({
1883
+ start() {
1884
+ },
1885
+ async transform(chunk, controller) {
1886
+ try {
1887
+ const decoded = new TextDecoder().decode(chunk);
1888
+ const chunks = decoded.split(RECORD_SEPARATOR);
1904
1889
  for (const chunk2 of chunks) {
1905
1890
  if (chunk2) {
1906
1891
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -1934,7 +1919,12 @@ var Workflow = class extends BaseResource {
1934
1919
  `/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
1935
1920
  {
1936
1921
  method: "POST",
1937
- body: { inputData: params.inputData, runtimeContext },
1922
+ body: {
1923
+ inputData: params.inputData,
1924
+ runtimeContext,
1925
+ closeOnSuspend: params.closeOnSuspend,
1926
+ tracingOptions: params.tracingOptions
1927
+ },
1938
1928
  stream: true
1939
1929
  }
1940
1930
  );
@@ -1951,7 +1941,54 @@ var Workflow = class extends BaseResource {
1951
1941
  async transform(chunk, controller) {
1952
1942
  try {
1953
1943
  const decoded = new TextDecoder().decode(chunk);
1954
- const chunks = decoded.split(RECORD_SEPARATOR2);
1944
+ const chunks = decoded.split(RECORD_SEPARATOR);
1945
+ for (const chunk2 of chunks) {
1946
+ if (chunk2) {
1947
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
1948
+ try {
1949
+ const parsedChunk = JSON.parse(newChunk);
1950
+ controller.enqueue(parsedChunk);
1951
+ failedChunk = void 0;
1952
+ } catch {
1953
+ failedChunk = newChunk;
1954
+ }
1955
+ }
1956
+ }
1957
+ } catch {
1958
+ }
1959
+ }
1960
+ });
1961
+ return response.body.pipeThrough(transformStream);
1962
+ }
1963
+ /**
1964
+ * Observes workflow vNext stream for a workflow run
1965
+ * @param params - Object containing the runId
1966
+ * @returns Promise containing the workflow execution results
1967
+ */
1968
+ async observeStreamVNext(params) {
1969
+ const searchParams = new URLSearchParams();
1970
+ searchParams.set("runId", params.runId);
1971
+ const response = await this.request(
1972
+ `/api/workflows/${this.workflowId}/observe-streamVNext?${searchParams.toString()}`,
1973
+ {
1974
+ method: "POST",
1975
+ stream: true
1976
+ }
1977
+ );
1978
+ if (!response.ok) {
1979
+ throw new Error(`Failed to observe stream vNext workflow: ${response.statusText}`);
1980
+ }
1981
+ if (!response.body) {
1982
+ throw new Error("Response body is null");
1983
+ }
1984
+ let failedChunk = void 0;
1985
+ const transformStream = new TransformStream({
1986
+ start() {
1987
+ },
1988
+ async transform(chunk, controller) {
1989
+ try {
1990
+ const decoded = new TextDecoder().decode(chunk);
1991
+ const chunks = decoded.split(RECORD_SEPARATOR);
1955
1992
  for (const chunk2 of chunks) {
1956
1993
  if (chunk2) {
1957
1994
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -1982,9 +2019,64 @@ var Workflow = class extends BaseResource {
1982
2019
  body: {
1983
2020
  step: params.step,
1984
2021
  resumeData: params.resumeData,
1985
- runtimeContext
2022
+ runtimeContext,
2023
+ tracingOptions: params.tracingOptions
2024
+ }
2025
+ });
2026
+ }
2027
+ /**
2028
+ * Resumes a suspended workflow step that uses streamVNext asynchronously and returns a promise that resolves when the workflow is complete
2029
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
2030
+ * @returns Promise containing the workflow resume results
2031
+ */
2032
+ async resumeStreamVNext(params) {
2033
+ const searchParams = new URLSearchParams();
2034
+ searchParams.set("runId", params.runId);
2035
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
2036
+ const response = await this.request(
2037
+ `/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
2038
+ {
2039
+ method: "POST",
2040
+ body: {
2041
+ step: params.step,
2042
+ resumeData: params.resumeData,
2043
+ runtimeContext,
2044
+ tracingOptions: params.tracingOptions
2045
+ },
2046
+ stream: true
2047
+ }
2048
+ );
2049
+ if (!response.ok) {
2050
+ throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
2051
+ }
2052
+ if (!response.body) {
2053
+ throw new Error("Response body is null");
2054
+ }
2055
+ let failedChunk = void 0;
2056
+ const transformStream = new TransformStream({
2057
+ start() {
2058
+ },
2059
+ async transform(chunk, controller) {
2060
+ try {
2061
+ const decoded = new TextDecoder().decode(chunk);
2062
+ const chunks = decoded.split(RECORD_SEPARATOR);
2063
+ for (const chunk2 of chunks) {
2064
+ if (chunk2) {
2065
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
2066
+ try {
2067
+ const parsedChunk = JSON.parse(newChunk);
2068
+ controller.enqueue(parsedChunk);
2069
+ failedChunk = void 0;
2070
+ } catch {
2071
+ failedChunk = newChunk;
2072
+ }
2073
+ }
2074
+ }
2075
+ } catch {
2076
+ }
1986
2077
  }
1987
2078
  });
2079
+ return response.body.pipeThrough(transformStream);
1988
2080
  }
1989
2081
  /**
1990
2082
  * Watches workflow transitions in real-time
@@ -2022,7 +2114,7 @@ var Workflow = class extends BaseResource {
2022
2114
  async start(controller) {
2023
2115
  try {
2024
2116
  for await (const record of records) {
2025
- const json = JSON.stringify(record) + RECORD_SEPARATOR2;
2117
+ const json = JSON.stringify(record) + RECORD_SEPARATOR;
2026
2118
  controller.enqueue(encoder.encode(json));
2027
2119
  }
2028
2120
  controller.close();
@@ -2120,10 +2212,11 @@ var MCPTool = class extends BaseResource {
2120
2212
  }
2121
2213
  /**
2122
2214
  * Retrieves details about this specific tool from the MCP server.
2215
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2123
2216
  * @returns Promise containing the tool's information (name, description, schema).
2124
2217
  */
2125
- details() {
2126
- return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
2218
+ details(runtimeContext) {
2219
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}${runtimeContextQueryString(runtimeContext)}`);
2127
2220
  }
2128
2221
  /**
2129
2222
  * Executes this specific tool on the MCP server.
@@ -2144,7 +2237,7 @@ var MCPTool = class extends BaseResource {
2144
2237
  };
2145
2238
 
2146
2239
  // src/resources/agent-builder.ts
2147
- var RECORD_SEPARATOR3 = "";
2240
+ var RECORD_SEPARATOR2 = "";
2148
2241
  var AgentBuilder = class extends BaseResource {
2149
2242
  constructor(options, actionId) {
2150
2243
  super(options);
@@ -2179,11 +2272,20 @@ var AgentBuilder = class extends BaseResource {
2179
2272
  };
2180
2273
  }
2181
2274
  }
2275
+ /**
2276
+ * @deprecated Use createRunAsync() instead.
2277
+ * @throws {Error} Always throws an error directing users to use createRunAsync()
2278
+ */
2279
+ async createRun(_params) {
2280
+ throw new Error(
2281
+ "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."
2282
+ );
2283
+ }
2182
2284
  /**
2183
2285
  * Creates a new agent builder action run and returns the runId.
2184
2286
  * This calls `/api/agent-builder/:actionId/create-run`.
2185
2287
  */
2186
- async createRun(params) {
2288
+ async createRunAsync(params) {
2187
2289
  const searchParams = new URLSearchParams();
2188
2290
  if (!!params?.runId) {
2189
2291
  searchParams.set("runId", params.runId);
@@ -2193,14 +2295,6 @@ var AgentBuilder = class extends BaseResource {
2193
2295
  method: "POST"
2194
2296
  });
2195
2297
  }
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
2298
  /**
2205
2299
  * Starts agent builder action asynchronously and waits for completion.
2206
2300
  * This calls `/api/agent-builder/:actionId/start-async`.
@@ -2283,7 +2377,7 @@ var AgentBuilder = class extends BaseResource {
2283
2377
  if (done && !value) continue;
2284
2378
  try {
2285
2379
  const decoded = value ? new TextDecoder().decode(value) : "";
2286
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
2380
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
2287
2381
  buffer = chunks.pop() || "";
2288
2382
  for (const chunk of chunks) {
2289
2383
  if (chunk) {
@@ -2340,7 +2434,7 @@ var AgentBuilder = class extends BaseResource {
2340
2434
  async transform(chunk, controller) {
2341
2435
  try {
2342
2436
  const decoded = new TextDecoder().decode(chunk);
2343
- const chunks = decoded.split(RECORD_SEPARATOR3);
2437
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2344
2438
  for (const chunk2 of chunks) {
2345
2439
  if (chunk2) {
2346
2440
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2389,7 +2483,7 @@ var AgentBuilder = class extends BaseResource {
2389
2483
  async transform(chunk, controller) {
2390
2484
  try {
2391
2485
  const decoded = new TextDecoder().decode(chunk);
2392
- const chunks = decoded.split(RECORD_SEPARATOR3);
2486
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2393
2487
  for (const chunk2 of chunks) {
2394
2488
  if (chunk2) {
2395
2489
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2560,6 +2654,31 @@ var Observability = class extends BaseResource {
2560
2654
  const queryString = searchParams.toString();
2561
2655
  return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
2562
2656
  }
2657
+ /**
2658
+ * Retrieves scores by trace ID and span ID
2659
+ * @param params - Parameters containing trace ID, span ID, and pagination options
2660
+ * @returns Promise containing scores and pagination info
2661
+ */
2662
+ getScoresBySpan(params) {
2663
+ const { traceId, spanId, page, perPage } = params;
2664
+ const searchParams = new URLSearchParams();
2665
+ if (page !== void 0) {
2666
+ searchParams.set("page", String(page));
2667
+ }
2668
+ if (perPage !== void 0) {
2669
+ searchParams.set("perPage", String(perPage));
2670
+ }
2671
+ const queryString = searchParams.toString();
2672
+ return this.request(
2673
+ `/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
2674
+ );
2675
+ }
2676
+ score(params) {
2677
+ return this.request(`/api/observability/traces/score`, {
2678
+ method: "POST",
2679
+ body: { ...params }
2680
+ });
2681
+ }
2563
2682
  };
2564
2683
 
2565
2684
  // src/resources/network-memory-thread.ts
@@ -2625,144 +2744,6 @@ var NetworkMemoryThread = class extends BaseResource {
2625
2744
  }
2626
2745
  };
2627
2746
 
2628
- // src/resources/vNextNetwork.ts
2629
- var RECORD_SEPARATOR4 = "";
2630
- var VNextNetwork = class extends BaseResource {
2631
- constructor(options, networkId) {
2632
- super(options);
2633
- this.networkId = networkId;
2634
- }
2635
- /**
2636
- * Retrieves details about the network
2637
- * @returns Promise containing vNext network details
2638
- */
2639
- details() {
2640
- return this.request(`/api/networks/v-next/${this.networkId}`);
2641
- }
2642
- /**
2643
- * Generates a response from the v-next network
2644
- * @param params - Generation parameters including message
2645
- * @returns Promise containing the generated response
2646
- */
2647
- generate(params) {
2648
- return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
2649
- method: "POST",
2650
- body: {
2651
- ...params,
2652
- runtimeContext: parseClientRuntimeContext(params.runtimeContext)
2653
- }
2654
- });
2655
- }
2656
- /**
2657
- * Generates a response from the v-next network using multiple primitives
2658
- * @param params - Generation parameters including message
2659
- * @returns Promise containing the generated response
2660
- */
2661
- loop(params) {
2662
- return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
2663
- method: "POST",
2664
- body: {
2665
- ...params,
2666
- runtimeContext: parseClientRuntimeContext(params.runtimeContext)
2667
- }
2668
- });
2669
- }
2670
- async *streamProcessor(stream) {
2671
- const reader = stream.getReader();
2672
- let doneReading = false;
2673
- let buffer = "";
2674
- try {
2675
- while (!doneReading) {
2676
- const { done, value } = await reader.read();
2677
- doneReading = done;
2678
- if (done && !value) continue;
2679
- try {
2680
- const decoded = value ? new TextDecoder().decode(value) : "";
2681
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
2682
- buffer = chunks.pop() || "";
2683
- for (const chunk of chunks) {
2684
- if (chunk) {
2685
- if (typeof chunk === "string") {
2686
- try {
2687
- const parsedChunk = JSON.parse(chunk);
2688
- yield parsedChunk;
2689
- } catch {
2690
- }
2691
- }
2692
- }
2693
- }
2694
- } catch {
2695
- }
2696
- }
2697
- if (buffer) {
2698
- try {
2699
- yield JSON.parse(buffer);
2700
- } catch {
2701
- }
2702
- }
2703
- } finally {
2704
- reader.cancel().catch(() => {
2705
- });
2706
- }
2707
- }
2708
- /**
2709
- * Streams a response from the v-next network
2710
- * @param params - Stream parameters including message
2711
- * @returns Promise containing the results
2712
- */
2713
- async stream(params, onRecord) {
2714
- const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
2715
- method: "POST",
2716
- body: {
2717
- ...params,
2718
- runtimeContext: parseClientRuntimeContext(params.runtimeContext)
2719
- },
2720
- stream: true
2721
- });
2722
- if (!response.ok) {
2723
- throw new Error(`Failed to stream vNext network: ${response.statusText}`);
2724
- }
2725
- if (!response.body) {
2726
- throw new Error("Response body is null");
2727
- }
2728
- for await (const record of this.streamProcessor(response.body)) {
2729
- if (typeof record === "string") {
2730
- onRecord(JSON.parse(record));
2731
- } else {
2732
- onRecord(record);
2733
- }
2734
- }
2735
- }
2736
- /**
2737
- * Streams a response from the v-next network loop
2738
- * @param params - Stream parameters including message
2739
- * @returns Promise containing the results
2740
- */
2741
- async loopStream(params, onRecord) {
2742
- const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
2743
- method: "POST",
2744
- body: {
2745
- ...params,
2746
- runtimeContext: parseClientRuntimeContext(params.runtimeContext)
2747
- },
2748
- stream: true
2749
- });
2750
- if (!response.ok) {
2751
- throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
2752
- }
2753
- if (!response.body) {
2754
- throw new Error("Response body is null");
2755
- }
2756
- for await (const record of this.streamProcessor(response.body)) {
2757
- if (typeof record === "string") {
2758
- onRecord(JSON.parse(record));
2759
- } else {
2760
- onRecord(record);
2761
- }
2762
- }
2763
- }
2764
- };
2765
-
2766
2747
  // src/client.ts
2767
2748
  var MastraClient = class extends BaseResource {
2768
2749
  observability;
@@ -2772,10 +2753,17 @@ var MastraClient = class extends BaseResource {
2772
2753
  }
2773
2754
  /**
2774
2755
  * Retrieves all available agents
2756
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2775
2757
  * @returns Promise containing map of agent IDs to agent details
2776
2758
  */
2777
- getAgents() {
2778
- return this.request("/api/agents");
2759
+ getAgents(runtimeContext) {
2760
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2761
+ const searchParams = new URLSearchParams();
2762
+ if (runtimeContextParam) {
2763
+ searchParams.set("runtimeContext", runtimeContextParam);
2764
+ }
2765
+ const queryString = searchParams.toString();
2766
+ return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
2779
2767
  }
2780
2768
  /**
2781
2769
  * Gets an agent instance by ID
@@ -2793,6 +2781,14 @@ var MastraClient = class extends BaseResource {
2793
2781
  getMemoryThreads(params) {
2794
2782
  return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
2795
2783
  }
2784
+ /**
2785
+ * Retrieves memory config for a resource
2786
+ * @param params - Parameters containing the resource ID
2787
+ * @returns Promise containing array of memory threads
2788
+ */
2789
+ getMemoryConfig(params) {
2790
+ return this.request(`/api/memory/config?agentId=${params.agentId}`);
2791
+ }
2796
2792
  /**
2797
2793
  * Creates a new memory thread
2798
2794
  * @param params - Parameters for creating the memory thread
@@ -2809,6 +2805,24 @@ var MastraClient = class extends BaseResource {
2809
2805
  getMemoryThread(threadId, agentId) {
2810
2806
  return new MemoryThread(this.options, threadId, agentId);
2811
2807
  }
2808
+ getThreadMessages(threadId, opts = {}) {
2809
+ let url = "";
2810
+ if (opts.agentId) {
2811
+ url = `/api/memory/threads/${threadId}/messages?agentId=${opts.agentId}`;
2812
+ } else if (opts.networkId) {
2813
+ url = `/api/memory/network/threads/${threadId}/messages?networkId=${opts.networkId}`;
2814
+ }
2815
+ return this.request(url);
2816
+ }
2817
+ deleteThread(threadId, opts = {}) {
2818
+ let url = "";
2819
+ if (opts.agentId) {
2820
+ url = `/api/memory/threads/${threadId}?agentId=${opts.agentId}`;
2821
+ } else if (opts.networkId) {
2822
+ url = `/api/memory/network/threads/${threadId}?networkId=${opts.networkId}`;
2823
+ }
2824
+ return this.request(url, { method: "DELETE" });
2825
+ }
2812
2826
  /**
2813
2827
  * Saves messages to memory
2814
2828
  * @param params - Parameters containing messages to save
@@ -2871,10 +2885,17 @@ var MastraClient = class extends BaseResource {
2871
2885
  }
2872
2886
  /**
2873
2887
  * Retrieves all available tools
2888
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2874
2889
  * @returns Promise containing map of tool IDs to tool details
2875
2890
  */
2876
- getTools() {
2877
- return this.request("/api/tools");
2891
+ getTools(runtimeContext) {
2892
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2893
+ const searchParams = new URLSearchParams();
2894
+ if (runtimeContextParam) {
2895
+ searchParams.set("runtimeContext", runtimeContextParam);
2896
+ }
2897
+ const queryString = searchParams.toString();
2898
+ return this.request(`/api/tools${queryString ? `?${queryString}` : ""}`);
2878
2899
  }
2879
2900
  /**
2880
2901
  * Gets a tool instance by ID
@@ -2884,27 +2905,19 @@ var MastraClient = class extends BaseResource {
2884
2905
  getTool(toolId) {
2885
2906
  return new Tool(this.options, toolId);
2886
2907
  }
2887
- /**
2888
- * Retrieves all available legacy workflows
2889
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
2890
- */
2891
- getLegacyWorkflows() {
2892
- return this.request("/api/workflows/legacy");
2893
- }
2894
- /**
2895
- * Gets a legacy workflow instance by ID
2896
- * @param workflowId - ID of the legacy workflow to retrieve
2897
- * @returns Legacy Workflow instance
2898
- */
2899
- getLegacyWorkflow(workflowId) {
2900
- return new LegacyWorkflow(this.options, workflowId);
2901
- }
2902
2908
  /**
2903
2909
  * Retrieves all available workflows
2910
+ * @param runtimeContext - Optional runtime context to pass as query parameter
2904
2911
  * @returns Promise containing map of workflow IDs to workflow details
2905
2912
  */
2906
- getWorkflows() {
2907
- return this.request("/api/workflows");
2913
+ getWorkflows(runtimeContext) {
2914
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2915
+ const searchParams = new URLSearchParams();
2916
+ if (runtimeContextParam) {
2917
+ searchParams.set("runtimeContext", runtimeContextParam);
2918
+ }
2919
+ const queryString = searchParams.toString();
2920
+ return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
2908
2921
  }
2909
2922
  /**
2910
2923
  * Gets a workflow instance by ID
@@ -3072,36 +3085,6 @@ var MastraClient = class extends BaseResource {
3072
3085
  return this.request(`/api/telemetry`);
3073
3086
  }
3074
3087
  }
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
- /**
3083
- * Retrieves all available vNext networks
3084
- * @returns Promise containing map of vNext network IDs to vNext network details
3085
- */
3086
- getVNextNetworks() {
3087
- return this.request("/api/networks/v-next");
3088
- }
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
- /**
3098
- * Gets a vNext network instance by ID
3099
- * @param networkId - ID of the vNext network to retrieve
3100
- * @returns vNext Network instance
3101
- */
3102
- getVNextNetwork(networkId) {
3103
- return new VNextNetwork(this.options, networkId);
3104
- }
3105
3088
  /**
3106
3089
  * Retrieves a list of available MCP servers.
3107
3090
  * @param params - Optional parameters for pagination (limit, offset).
@@ -3206,7 +3189,7 @@ var MastraClient = class extends BaseResource {
3206
3189
  * @returns Promise containing the scorer
3207
3190
  */
3208
3191
  getScorer(scorerId) {
3209
- return this.request(`/api/scores/scorers/${scorerId}`);
3192
+ return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
3210
3193
  }
3211
3194
  getScoresByScorerId(params) {
3212
3195
  const { page, perPage, scorerId, entityId, entityType } = params;
@@ -3224,7 +3207,7 @@ var MastraClient = class extends BaseResource {
3224
3207
  searchParams.set("perPage", String(perPage));
3225
3208
  }
3226
3209
  const queryString = searchParams.toString();
3227
- return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
3210
+ return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
3228
3211
  }
3229
3212
  /**
3230
3213
  * Retrieves scores by run ID
@@ -3241,7 +3224,7 @@ var MastraClient = class extends BaseResource {
3241
3224
  searchParams.set("perPage", String(perPage));
3242
3225
  }
3243
3226
  const queryString = searchParams.toString();
3244
- return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
3227
+ return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
3245
3228
  }
3246
3229
  /**
3247
3230
  * Retrieves scores by entity ID and type
@@ -3258,7 +3241,9 @@ var MastraClient = class extends BaseResource {
3258
3241
  searchParams.set("perPage", String(perPage));
3259
3242
  }
3260
3243
  const queryString = searchParams.toString();
3261
- return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
3244
+ return this.request(
3245
+ `/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
3246
+ );
3262
3247
  }
3263
3248
  /**
3264
3249
  * Saves a score
@@ -3284,8 +3269,35 @@ var MastraClient = class extends BaseResource {
3284
3269
  getAITraces(params) {
3285
3270
  return this.observability.getTraces(params);
3286
3271
  }
3272
+ getScoresBySpan(params) {
3273
+ return this.observability.getScoresBySpan(params);
3274
+ }
3275
+ score(params) {
3276
+ return this.observability.score(params);
3277
+ }
3287
3278
  };
3288
3279
 
3280
+ // src/tools.ts
3281
+ var ClientTool = class {
3282
+ id;
3283
+ description;
3284
+ inputSchema;
3285
+ outputSchema;
3286
+ execute;
3287
+ constructor(opts) {
3288
+ this.id = opts.id;
3289
+ this.description = opts.description;
3290
+ this.inputSchema = opts.inputSchema;
3291
+ this.outputSchema = opts.outputSchema;
3292
+ this.execute = opts.execute;
3293
+ }
3294
+ };
3295
+ function createTool(opts) {
3296
+ return new ClientTool(opts);
3297
+ }
3298
+
3299
+ exports.ClientTool = ClientTool;
3289
3300
  exports.MastraClient = MastraClient;
3301
+ exports.createTool = createTool;
3290
3302
  //# sourceMappingURL=index.cjs.map
3291
3303
  //# sourceMappingURL=index.cjs.map