@mastra/client-js 0.12.3-alpha.0 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15,6 +15,12 @@ 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
+ }
18
24
  function isZodType(value) {
19
25
  return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
20
26
  }
@@ -273,17 +279,31 @@ var AgentVoice = class extends BaseResource {
273
279
  }
274
280
  /**
275
281
  * Get available speakers for the agent's voice provider
282
+ * @param runtimeContext - Optional runtime context to pass as query parameter
276
283
  * @returns Promise containing list of available speakers
277
284
  */
278
- getSpeakers() {
279
- return this.request(`/api/agents/${this.agentId}/voice/speakers`);
285
+ getSpeakers(runtimeContext) {
286
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
287
+ const searchParams = new URLSearchParams();
288
+ if (runtimeContextParam) {
289
+ searchParams.set("runtimeContext", runtimeContextParam);
290
+ }
291
+ const queryString = searchParams.toString();
292
+ return this.request(`/api/agents/${this.agentId}/voice/speakers${queryString ? `?${queryString}` : ""}`);
280
293
  }
281
294
  /**
282
295
  * Get the listener configuration for the agent's voice provider
296
+ * @param runtimeContext - Optional runtime context to pass as query parameter
283
297
  * @returns Promise containing a check if the agent has listening capabilities
284
298
  */
285
- getListener() {
286
- return this.request(`/api/agents/${this.agentId}/voice/listener`);
299
+ getListener(runtimeContext) {
300
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
301
+ const searchParams = new URLSearchParams();
302
+ if (runtimeContextParam) {
303
+ searchParams.set("runtimeContext", runtimeContextParam);
304
+ }
305
+ const queryString = searchParams.toString();
306
+ return this.request(`/api/agents/${this.agentId}/voice/listener${queryString ? `?${queryString}` : ""}`);
287
307
  }
288
308
  };
289
309
  var Agent = class extends BaseResource {
@@ -295,14 +315,21 @@ var Agent = class extends BaseResource {
295
315
  voice;
296
316
  /**
297
317
  * Retrieves details about the agent
318
+ * @param runtimeContext - Runtime context to use for the agent
298
319
  * @returns Promise containing agent details including model and instructions
299
320
  */
300
- details() {
301
- return this.request(`/api/agents/${this.agentId}`);
321
+ details(runtimeContext) {
322
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
323
+ const searchParams = new URLSearchParams();
324
+ if (runtimeContextParam) {
325
+ searchParams.set("runtimeContext", runtimeContextParam);
326
+ }
327
+ const queryString = searchParams.toString();
328
+ return this.request(`/api/agents/${this.agentId}${queryString ? `?${queryString}` : ""}`);
302
329
  }
303
330
  async generate(params) {
304
331
  console.warn(
305
- "Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 16th, 2025. Please use generateLegacy if you don't want to upgrade just yet."
332
+ "Deprecation NOTICE:Generate method will switch to use generateVNext implementation September 23rd, 2025. Please use generateLegacy if you don't want to upgrade just yet."
306
333
  );
307
334
  return this.generateLegacy(params);
308
335
  }
@@ -672,7 +699,7 @@ var Agent = class extends BaseResource {
672
699
  */
673
700
  async stream(params) {
674
701
  console.warn(
675
- "Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 16th, 2025. Please use streamLegacy if you don't want to upgrade just yet."
702
+ "Deprecation NOTICE:\nStream method will switch to use streamVNext implementation September 23rd, 2025. Please use streamLegacy if you don't want to upgrade just yet."
676
703
  );
677
704
  return this.streamLegacy(params);
678
705
  }
@@ -1245,10 +1272,17 @@ var Agent = class extends BaseResource {
1245
1272
  /**
1246
1273
  * Gets details about a specific tool available to the agent
1247
1274
  * @param toolId - ID of the tool to retrieve
1275
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1248
1276
  * @returns Promise containing tool details
1249
1277
  */
1250
- getTool(toolId) {
1251
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
1278
+ getTool(toolId, runtimeContext) {
1279
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1280
+ const searchParams = new URLSearchParams();
1281
+ if (runtimeContextParam) {
1282
+ searchParams.set("runtimeContext", runtimeContextParam);
1283
+ }
1284
+ const queryString = searchParams.toString();
1285
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}${queryString ? `?${queryString}` : ""}`);
1252
1286
  }
1253
1287
  /**
1254
1288
  * Executes a tool for the agent
@@ -1259,7 +1293,7 @@ var Agent = class extends BaseResource {
1259
1293
  executeTool(toolId, params) {
1260
1294
  const body = {
1261
1295
  data: params.data,
1262
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
1296
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1263
1297
  };
1264
1298
  return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
1265
1299
  method: "POST",
@@ -1268,17 +1302,31 @@ var Agent = class extends BaseResource {
1268
1302
  }
1269
1303
  /**
1270
1304
  * Retrieves evaluation results for the agent
1305
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1271
1306
  * @returns Promise containing agent evaluations
1272
1307
  */
1273
- evals() {
1274
- return this.request(`/api/agents/${this.agentId}/evals/ci`);
1308
+ evals(runtimeContext) {
1309
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1310
+ const searchParams = new URLSearchParams();
1311
+ if (runtimeContextParam) {
1312
+ searchParams.set("runtimeContext", runtimeContextParam);
1313
+ }
1314
+ const queryString = searchParams.toString();
1315
+ return this.request(`/api/agents/${this.agentId}/evals/ci${queryString ? `?${queryString}` : ""}`);
1275
1316
  }
1276
1317
  /**
1277
1318
  * Retrieves live evaluation results for the agent
1319
+ * @param runtimeContext - Optional runtime context to pass as query parameter
1278
1320
  * @returns Promise containing live agent evaluations
1279
1321
  */
1280
- liveEvals() {
1281
- return this.request(`/api/agents/${this.agentId}/evals/live`);
1322
+ liveEvals(runtimeContext) {
1323
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1324
+ const searchParams = new URLSearchParams();
1325
+ if (runtimeContextParam) {
1326
+ searchParams.set("runtimeContext", runtimeContextParam);
1327
+ }
1328
+ const queryString = searchParams.toString();
1329
+ return this.request(`/api/agents/${this.agentId}/evals/live${queryString ? `?${queryString}` : ""}`);
1282
1330
  }
1283
1331
  /**
1284
1332
  * Updates the model for the agent
@@ -2808,10 +2856,17 @@ var MastraClient = class extends BaseResource {
2808
2856
  }
2809
2857
  /**
2810
2858
  * Retrieves all available agents
2859
+ * @param runtimeContext - Runtime context to use for the agents
2811
2860
  * @returns Promise containing map of agent IDs to agent details
2812
2861
  */
2813
- getAgents() {
2814
- return this.request("/api/agents");
2862
+ getAgents(runtimeContext) {
2863
+ const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
2864
+ const searchParams = new URLSearchParams();
2865
+ if (runtimeContextParam) {
2866
+ searchParams.set("runtimeContext", runtimeContextParam);
2867
+ }
2868
+ const queryString = searchParams.toString();
2869
+ return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
2815
2870
  }
2816
2871
  /**
2817
2872
  * Gets an agent instance by ID