@mastra/client-js 0.0.0-custom-instrumentation-20250626084921 → 0.0.0-declaration-maps-20250729202623

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 (69) hide show
  1. package/.turbo/turbo-build.log +8 -10
  2. package/CHANGELOG.md +452 -2
  3. package/LICENSE.md +11 -42
  4. package/README.md +1 -0
  5. package/dist/adapters/agui.d.ts +23 -0
  6. package/dist/adapters/agui.d.ts.map +1 -0
  7. package/dist/client.d.ts +265 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/example.d.ts +2 -0
  10. package/dist/example.d.ts.map +1 -0
  11. package/dist/index.cjs +305 -69
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +4 -1126
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +304 -68
  16. package/dist/index.js.map +1 -0
  17. package/dist/resources/a2a.d.ts +44 -0
  18. package/dist/resources/a2a.d.ts.map +1 -0
  19. package/dist/resources/agent.d.ts +112 -0
  20. package/dist/resources/agent.d.ts.map +1 -0
  21. package/dist/resources/base.d.ts +13 -0
  22. package/dist/resources/base.d.ts.map +1 -0
  23. package/dist/resources/index.d.ts +11 -0
  24. package/dist/resources/index.d.ts.map +1 -0
  25. package/dist/resources/legacy-workflow.d.ts +87 -0
  26. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  27. package/dist/resources/mcp-tool.d.ts +27 -0
  28. package/dist/resources/mcp-tool.d.ts.map +1 -0
  29. package/dist/resources/memory-thread.d.ts +53 -0
  30. package/dist/resources/memory-thread.d.ts.map +1 -0
  31. package/dist/resources/network-memory-thread.d.ts +47 -0
  32. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  33. package/dist/resources/network.d.ts +30 -0
  34. package/dist/resources/network.d.ts.map +1 -0
  35. package/dist/resources/tool.d.ts +23 -0
  36. package/dist/resources/tool.d.ts.map +1 -0
  37. package/dist/resources/vNextNetwork.d.ts +42 -0
  38. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  39. package/dist/resources/vector.d.ts +48 -0
  40. package/dist/resources/vector.d.ts.map +1 -0
  41. package/dist/resources/workflow.d.ts +154 -0
  42. package/dist/resources/workflow.d.ts.map +1 -0
  43. package/dist/types.d.ts +422 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/utils/index.d.ts +3 -0
  46. package/dist/utils/index.d.ts.map +1 -0
  47. package/dist/utils/process-client-tools.d.ts +3 -0
  48. package/dist/utils/process-client-tools.d.ts.map +1 -0
  49. package/dist/utils/zod-to-json-schema.d.ts +105 -0
  50. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  51. package/package.json +8 -7
  52. package/src/client.ts +145 -2
  53. package/src/example.ts +45 -17
  54. package/src/index.test.ts +402 -6
  55. package/src/index.ts +1 -0
  56. package/src/resources/agent.ts +64 -24
  57. package/src/resources/base.ts +6 -1
  58. package/src/resources/memory-thread.test.ts +285 -0
  59. package/src/resources/memory-thread.ts +36 -0
  60. package/src/resources/network-memory-thread.test.ts +269 -0
  61. package/src/resources/network-memory-thread.ts +18 -0
  62. package/src/resources/network.ts +4 -3
  63. package/src/resources/vNextNetwork.ts +22 -5
  64. package/src/resources/workflow.ts +43 -6
  65. package/src/types.ts +105 -10
  66. package/src/utils/process-client-tools.ts +1 -1
  67. package/src/v2-messages.test.ts +180 -0
  68. package/tsconfig.build.json +9 -0
  69. package/dist/index.d.cts +0 -1126
package/dist/index.cjs CHANGED
@@ -5,7 +5,8 @@ var rxjs = require('rxjs');
5
5
  var uiUtils = require('@ai-sdk/ui-utils');
6
6
  var zod = require('zod');
7
7
  var originalZodToJsonSchema = require('zod-to-json-schema');
8
- var tools = require('@mastra/core/tools');
8
+ var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
9
+ var uuid = require('@lukeed/uuid');
9
10
  var runtimeContext = require('@mastra/core/runtime-context');
10
11
 
11
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -209,7 +210,7 @@ function processClientTools(clientTools) {
209
210
  }
210
211
  return Object.fromEntries(
211
212
  Object.entries(clientTools).map(([key, value]) => {
212
- if (tools.isVercelTool(value)) {
213
+ if (isVercelTool.isVercelTool(value)) {
213
214
  return [
214
215
  key,
215
216
  {
@@ -252,12 +253,13 @@ var BaseResource = class {
252
253
  const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
253
254
  ...options,
254
255
  headers: {
255
- ...options.method === "POST" || options.method === "PUT" ? { "content-type": "application/json" } : {},
256
+ ...options.body && !(options.body instanceof FormData) && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
256
257
  ...headers,
257
258
  ...options.headers
258
259
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
259
260
  // 'x-mastra-client-type': 'js',
260
261
  },
262
+ signal: this.options.abortSignal,
261
263
  body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
262
264
  });
263
265
  if (!response.ok) {
@@ -376,12 +378,19 @@ var Agent = class extends BaseResource {
376
378
  clientTools: processClientTools(params.clientTools)
377
379
  };
378
380
  const { runId, resourceId, threadId, runtimeContext } = processedParams;
379
- const response = await this.request(`/api/agents/${this.agentId}/generate`, {
380
- method: "POST",
381
- body: processedParams
382
- });
381
+ const response = await this.request(
382
+ `/api/agents/${this.agentId}/generate`,
383
+ {
384
+ method: "POST",
385
+ body: processedParams
386
+ }
387
+ );
383
388
  if (response.finishReason === "tool-calls") {
384
- for (const toolCall of response.toolCalls) {
389
+ const toolCalls = response.toolCalls;
390
+ if (!toolCalls || !Array.isArray(toolCalls)) {
391
+ return response;
392
+ }
393
+ for (const toolCall of toolCalls) {
385
394
  const clientTool = params.clientTools?.[toolCall.toolName];
386
395
  if (clientTool && clientTool.execute) {
387
396
  const result = await clientTool.execute(
@@ -432,7 +441,7 @@ var Agent = class extends BaseResource {
432
441
  return Math.max(max, toolInvocation.step ?? 0);
433
442
  }, 0) ?? 0) : 0;
434
443
  const message = replaceLastMessage ? structuredClone(lastMessage) : {
435
- id: crypto.randomUUID(),
444
+ id: uuid.v4(),
436
445
  createdAt: getCurrentDate(),
437
446
  role: "assistant",
438
447
  content: "",
@@ -477,7 +486,7 @@ var Agent = class extends BaseResource {
477
486
  // changes. This is why we need to add a revision id to ensure that the message
478
487
  // is updated with SWR (without it, the changes get stuck in SWR and are not
479
488
  // forwarded to rendering):
480
- revisionId: crypto.randomUUID()
489
+ revisionId: uuid.v4()
481
490
  };
482
491
  update({
483
492
  message: copiedMessage,
@@ -732,7 +741,12 @@ var Agent = class extends BaseResource {
732
741
  this.processChatResponse({
733
742
  stream: streamForProcessing,
734
743
  update: ({ message }) => {
735
- messages.push(message);
744
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
745
+ if (existingIndex !== -1) {
746
+ messages[existingIndex] = message;
747
+ } else {
748
+ messages.push(message);
749
+ }
736
750
  },
737
751
  onFinish: async ({ finishReason, message }) => {
738
752
  if (finishReason === "tool-calls") {
@@ -774,15 +788,30 @@ var Agent = class extends BaseResource {
774
788
  toolInvocation.state = "result";
775
789
  toolInvocation.result = result;
776
790
  }
791
+ const writer = writable.getWriter();
792
+ try {
793
+ await writer.write(
794
+ new TextEncoder().encode(
795
+ "a:" + JSON.stringify({
796
+ toolCallId: toolCall2.toolCallId,
797
+ result
798
+ }) + "\n"
799
+ )
800
+ );
801
+ } finally {
802
+ writer.releaseLock();
803
+ }
777
804
  const originalMessages = processedParams.messages;
778
805
  const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
779
806
  this.processStreamResponse(
780
807
  {
781
808
  ...processedParams,
782
- messages: [...messageArray, ...messages, lastMessage]
809
+ messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
783
810
  },
784
811
  writable
785
- );
812
+ ).catch((error) => {
813
+ console.error("Error processing stream response:", error);
814
+ });
786
815
  }
787
816
  }
788
817
  } else {
@@ -792,6 +821,8 @@ var Agent = class extends BaseResource {
792
821
  }
793
822
  },
794
823
  lastMessage: void 0
824
+ }).catch((error) => {
825
+ console.error("Error processing stream response:", error);
795
826
  });
796
827
  } catch (error) {
797
828
  console.error("Error processing stream response:", error);
@@ -940,6 +971,36 @@ var MemoryThread = class extends BaseResource {
940
971
  });
941
972
  return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
942
973
  }
974
+ /**
975
+ * Retrieves paginated messages associated with the thread with advanced filtering and selection options
976
+ * @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
977
+ * @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
978
+ */
979
+ getMessagesPaginated({
980
+ selectBy,
981
+ ...rest
982
+ }) {
983
+ const query = new URLSearchParams({
984
+ ...rest,
985
+ ...selectBy ? { selectBy: JSON.stringify(selectBy) } : {}
986
+ });
987
+ return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
988
+ }
989
+ /**
990
+ * Deletes one or more messages from the thread
991
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
992
+ * message object with id property, or array of message objects
993
+ * @returns Promise containing deletion result
994
+ */
995
+ deleteMessages(messageIds) {
996
+ const query = new URLSearchParams({
997
+ agentId: this.agentId
998
+ });
999
+ return this.request(`/api/memory/messages/delete?${query.toString()}`, {
1000
+ method: "POST",
1001
+ body: { messageIds }
1002
+ });
1003
+ }
943
1004
  };
944
1005
 
945
1006
  // src/resources/vector.ts
@@ -1295,10 +1356,10 @@ var Workflow = class extends BaseResource {
1295
1356
  if (params?.toDate) {
1296
1357
  searchParams.set("toDate", params.toDate.toISOString());
1297
1358
  }
1298
- if (params?.limit) {
1359
+ if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
1299
1360
  searchParams.set("limit", String(params.limit));
1300
1361
  }
1301
- if (params?.offset) {
1362
+ if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
1302
1363
  searchParams.set("offset", String(params.offset));
1303
1364
  }
1304
1365
  if (params?.resourceId) {
@@ -1326,6 +1387,27 @@ var Workflow = class extends BaseResource {
1326
1387
  runExecutionResult(runId) {
1327
1388
  return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
1328
1389
  }
1390
+ /**
1391
+ * Cancels a specific workflow run by its ID
1392
+ * @param runId - The ID of the workflow run to cancel
1393
+ * @returns Promise containing a success message
1394
+ */
1395
+ cancelRun(runId) {
1396
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
1397
+ method: "POST"
1398
+ });
1399
+ }
1400
+ /**
1401
+ * Sends an event to a specific workflow run by its ID
1402
+ * @param params - Object containing the runId, event and data
1403
+ * @returns Promise containing a success message
1404
+ */
1405
+ sendRunEvent(params) {
1406
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
1407
+ method: "POST",
1408
+ body: { event: params.event, data: params.data }
1409
+ });
1410
+ }
1329
1411
  /**
1330
1412
  * Creates a new workflow run
1331
1413
  * @param params - Optional object containing the optional runId
@@ -1340,6 +1422,14 @@ var Workflow = class extends BaseResource {
1340
1422
  method: "POST"
1341
1423
  });
1342
1424
  }
1425
+ /**
1426
+ * Creates a new workflow run (alias for createRun)
1427
+ * @param params - Optional object containing the optional runId
1428
+ * @returns Promise containing the runId of the created run
1429
+ */
1430
+ createRunAsync(params) {
1431
+ return this.createRun(params);
1432
+ }
1343
1433
  /**
1344
1434
  * Starts a workflow run synchronously without waiting for the workflow to complete
1345
1435
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -1415,6 +1505,7 @@ var Workflow = class extends BaseResource {
1415
1505
  if (!response.body) {
1416
1506
  throw new Error("Response body is null");
1417
1507
  }
1508
+ let failedChunk = void 0;
1418
1509
  const transformStream = new TransformStream({
1419
1510
  start() {
1420
1511
  },
@@ -1424,10 +1515,13 @@ var Workflow = class extends BaseResource {
1424
1515
  const chunks = decoded.split(RECORD_SEPARATOR2);
1425
1516
  for (const chunk2 of chunks) {
1426
1517
  if (chunk2) {
1518
+ const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
1427
1519
  try {
1428
- const parsedChunk = JSON.parse(chunk2);
1520
+ const parsedChunk = JSON.parse(newChunk);
1429
1521
  controller.enqueue(parsedChunk);
1430
- } catch {
1522
+ failedChunk = void 0;
1523
+ } catch (error) {
1524
+ failedChunk = newChunk;
1431
1525
  }
1432
1526
  }
1433
1527
  }
@@ -1609,6 +1703,69 @@ var MCPTool = class extends BaseResource {
1609
1703
  }
1610
1704
  };
1611
1705
 
1706
+ // src/resources/network-memory-thread.ts
1707
+ var NetworkMemoryThread = class extends BaseResource {
1708
+ constructor(options, threadId, networkId) {
1709
+ super(options);
1710
+ this.threadId = threadId;
1711
+ this.networkId = networkId;
1712
+ }
1713
+ /**
1714
+ * Retrieves the memory thread details
1715
+ * @returns Promise containing thread details including title and metadata
1716
+ */
1717
+ get() {
1718
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1719
+ }
1720
+ /**
1721
+ * Updates the memory thread properties
1722
+ * @param params - Update parameters including title and metadata
1723
+ * @returns Promise containing updated thread details
1724
+ */
1725
+ update(params) {
1726
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1727
+ method: "PATCH",
1728
+ body: params
1729
+ });
1730
+ }
1731
+ /**
1732
+ * Deletes the memory thread
1733
+ * @returns Promise containing deletion result
1734
+ */
1735
+ delete() {
1736
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1737
+ method: "DELETE"
1738
+ });
1739
+ }
1740
+ /**
1741
+ * Retrieves messages associated with the thread
1742
+ * @param params - Optional parameters including limit for number of messages to retrieve
1743
+ * @returns Promise containing thread messages and UI messages
1744
+ */
1745
+ getMessages(params) {
1746
+ const query = new URLSearchParams({
1747
+ networkId: this.networkId,
1748
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1749
+ });
1750
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1751
+ }
1752
+ /**
1753
+ * Deletes one or more messages from the thread
1754
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
1755
+ * message object with id property, or array of message objects
1756
+ * @returns Promise containing deletion result
1757
+ */
1758
+ deleteMessages(messageIds) {
1759
+ const query = new URLSearchParams({
1760
+ networkId: this.networkId
1761
+ });
1762
+ return this.request(`/api/memory/network/messages/delete?${query.toString()}`, {
1763
+ method: "POST",
1764
+ body: { messageIds }
1765
+ });
1766
+ }
1767
+ };
1768
+
1612
1769
  // src/resources/vNextNetwork.ts
1613
1770
  var RECORD_SEPARATOR3 = "";
1614
1771
  var VNextNetwork = class extends BaseResource {
@@ -1631,7 +1788,10 @@ var VNextNetwork = class extends BaseResource {
1631
1788
  generate(params) {
1632
1789
  return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1633
1790
  method: "POST",
1634
- body: params
1791
+ body: {
1792
+ ...params,
1793
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1794
+ }
1635
1795
  });
1636
1796
  }
1637
1797
  /**
@@ -1642,7 +1802,10 @@ var VNextNetwork = class extends BaseResource {
1642
1802
  loop(params) {
1643
1803
  return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1644
1804
  method: "POST",
1645
- body: params
1805
+ body: {
1806
+ ...params,
1807
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1808
+ }
1646
1809
  });
1647
1810
  }
1648
1811
  async *streamProcessor(stream) {
@@ -1691,7 +1854,10 @@ var VNextNetwork = class extends BaseResource {
1691
1854
  async stream(params, onRecord) {
1692
1855
  const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1693
1856
  method: "POST",
1694
- body: params,
1857
+ body: {
1858
+ ...params,
1859
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1860
+ },
1695
1861
  stream: true
1696
1862
  });
1697
1863
  if (!response.ok) {
@@ -1716,7 +1882,10 @@ var VNextNetwork = class extends BaseResource {
1716
1882
  async loopStream(params, onRecord) {
1717
1883
  const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
1718
1884
  method: "POST",
1719
- body: params,
1885
+ body: {
1886
+ ...params,
1887
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1888
+ },
1720
1889
  stream: true
1721
1890
  });
1722
1891
  if (!response.ok) {
@@ -1735,54 +1904,6 @@ var VNextNetwork = class extends BaseResource {
1735
1904
  }
1736
1905
  };
1737
1906
 
1738
- // src/resources/network-memory-thread.ts
1739
- var NetworkMemoryThread = class extends BaseResource {
1740
- constructor(options, threadId, networkId) {
1741
- super(options);
1742
- this.threadId = threadId;
1743
- this.networkId = networkId;
1744
- }
1745
- /**
1746
- * Retrieves the memory thread details
1747
- * @returns Promise containing thread details including title and metadata
1748
- */
1749
- get() {
1750
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1751
- }
1752
- /**
1753
- * Updates the memory thread properties
1754
- * @param params - Update parameters including title and metadata
1755
- * @returns Promise containing updated thread details
1756
- */
1757
- update(params) {
1758
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1759
- method: "PATCH",
1760
- body: params
1761
- });
1762
- }
1763
- /**
1764
- * Deletes the memory thread
1765
- * @returns Promise containing deletion result
1766
- */
1767
- delete() {
1768
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1769
- method: "DELETE"
1770
- });
1771
- }
1772
- /**
1773
- * Retrieves messages associated with the thread
1774
- * @param params - Optional parameters including limit for number of messages to retrieve
1775
- * @returns Promise containing thread messages and UI messages
1776
- */
1777
- getMessages(params) {
1778
- const query = new URLSearchParams({
1779
- networkId: this.networkId,
1780
- ...params?.limit ? { limit: params.limit.toString() } : {}
1781
- });
1782
- return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1783
- }
1784
- };
1785
-
1786
1907
  // src/client.ts
1787
1908
  var MastraClient = class extends BaseResource {
1788
1909
  constructor(options) {
@@ -2177,6 +2298,121 @@ var MastraClient = class extends BaseResource {
2177
2298
  getA2A(agentId) {
2178
2299
  return new A2A(this.options, agentId);
2179
2300
  }
2301
+ /**
2302
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
2303
+ * @param agentId - ID of the agent.
2304
+ * @param threadId - ID of the thread.
2305
+ * @param resourceId - Optional ID of the resource.
2306
+ * @returns Working memory for the specified thread or resource.
2307
+ */
2308
+ getWorkingMemory({
2309
+ agentId,
2310
+ threadId,
2311
+ resourceId
2312
+ }) {
2313
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
2314
+ }
2315
+ /**
2316
+ * Updates the working memory for a specific thread (optionally resource-scoped).
2317
+ * @param agentId - ID of the agent.
2318
+ * @param threadId - ID of the thread.
2319
+ * @param workingMemory - The new working memory content.
2320
+ * @param resourceId - Optional ID of the resource.
2321
+ */
2322
+ updateWorkingMemory({
2323
+ agentId,
2324
+ threadId,
2325
+ workingMemory,
2326
+ resourceId
2327
+ }) {
2328
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
2329
+ method: "POST",
2330
+ body: {
2331
+ workingMemory,
2332
+ resourceId
2333
+ }
2334
+ });
2335
+ }
2336
+ /**
2337
+ * Retrieves all available scorers
2338
+ * @returns Promise containing list of available scorers
2339
+ */
2340
+ getScorers() {
2341
+ return this.request("/api/scores/scorers");
2342
+ }
2343
+ /**
2344
+ * Retrieves a scorer by ID
2345
+ * @param scorerId - ID of the scorer to retrieve
2346
+ * @returns Promise containing the scorer
2347
+ */
2348
+ getScorer(scorerId) {
2349
+ return this.request(`/api/scores/scorers/${scorerId}`);
2350
+ }
2351
+ getScoresByScorerId(params) {
2352
+ const { page, perPage, scorerId, entityId, entityType } = params;
2353
+ const searchParams = new URLSearchParams();
2354
+ if (entityId) {
2355
+ searchParams.set("entityId", entityId);
2356
+ }
2357
+ if (entityType) {
2358
+ searchParams.set("entityType", entityType);
2359
+ }
2360
+ if (page !== void 0) {
2361
+ searchParams.set("page", String(page));
2362
+ }
2363
+ if (perPage !== void 0) {
2364
+ searchParams.set("perPage", String(perPage));
2365
+ }
2366
+ const queryString = searchParams.toString();
2367
+ return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
2368
+ }
2369
+ /**
2370
+ * Retrieves scores by run ID
2371
+ * @param params - Parameters containing run ID and pagination options
2372
+ * @returns Promise containing scores and pagination info
2373
+ */
2374
+ getScoresByRunId(params) {
2375
+ const { runId, page, perPage } = params;
2376
+ const searchParams = new URLSearchParams();
2377
+ if (page !== void 0) {
2378
+ searchParams.set("page", String(page));
2379
+ }
2380
+ if (perPage !== void 0) {
2381
+ searchParams.set("perPage", String(perPage));
2382
+ }
2383
+ const queryString = searchParams.toString();
2384
+ return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
2385
+ }
2386
+ /**
2387
+ * Retrieves scores by entity ID and type
2388
+ * @param params - Parameters containing entity ID, type, and pagination options
2389
+ * @returns Promise containing scores and pagination info
2390
+ */
2391
+ getScoresByEntityId(params) {
2392
+ const { entityId, entityType, page, perPage } = params;
2393
+ const searchParams = new URLSearchParams();
2394
+ if (page !== void 0) {
2395
+ searchParams.set("page", String(page));
2396
+ }
2397
+ if (perPage !== void 0) {
2398
+ searchParams.set("perPage", String(perPage));
2399
+ }
2400
+ const queryString = searchParams.toString();
2401
+ return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
2402
+ }
2403
+ /**
2404
+ * Saves a score
2405
+ * @param params - Parameters containing the score data to save
2406
+ * @returns Promise containing the saved score
2407
+ */
2408
+ saveScore(params) {
2409
+ return this.request("/api/scores", {
2410
+ method: "POST",
2411
+ body: params
2412
+ });
2413
+ }
2180
2414
  };
2181
2415
 
2182
2416
  exports.MastraClient = MastraClient;
2417
+ //# sourceMappingURL=index.cjs.map
2418
+ //# sourceMappingURL=index.cjs.map