@mastra/client-js 0.13.2 → 0.14.0-alpha.1

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.cjs CHANGED
@@ -229,11 +229,7 @@ async function executeToolCallAndRespond({
229
229
  }
230
230
  );
231
231
  const updatedMessages = [
232
- {
233
- role: "user",
234
- content: params.messages
235
- },
236
- ...response.response.messages,
232
+ ...response.response.messages || [],
237
233
  {
238
234
  role: "tool",
239
235
  content: [
@@ -374,10 +370,6 @@ var Agent = class extends BaseResource {
374
370
  }
375
371
  );
376
372
  const updatedMessages = [
377
- {
378
- role: "user",
379
- content: params.messages
380
- },
381
373
  ...response.response.messages,
382
374
  {
383
375
  role: "tool",
@@ -1048,9 +1040,11 @@ var Agent = class extends BaseResource {
1048
1040
  if (toolCall) {
1049
1041
  toolCalls.push(toolCall);
1050
1042
  }
1043
+ let shouldExecuteClientTool = false;
1051
1044
  for (const toolCall2 of toolCalls) {
1052
1045
  const clientTool = processedParams.clientTools?.[toolCall2.toolName];
1053
1046
  if (clientTool && clientTool.execute) {
1047
+ shouldExecuteClientTool = true;
1054
1048
  const result = await clientTool.execute(
1055
1049
  {
1056
1050
  context: toolCall2?.args,
@@ -1087,9 +1081,7 @@ var Agent = class extends BaseResource {
1087
1081
  toolInvocation.state = "result";
1088
1082
  toolInvocation.result = result;
1089
1083
  }
1090
- const originalMessages = processedParams.messages;
1091
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1092
- const updatedMessages = lastMessage != null ? [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messageArray, ...messages];
1084
+ const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
1093
1085
  this.processStreamResponse_vNext(
1094
1086
  {
1095
1087
  ...processedParams,
@@ -1101,6 +1093,11 @@ var Agent = class extends BaseResource {
1101
1093
  });
1102
1094
  }
1103
1095
  }
1096
+ if (!shouldExecuteClientTool) {
1097
+ setTimeout(() => {
1098
+ writable.close();
1099
+ }, 0);
1100
+ }
1104
1101
  } else {
1105
1102
  setTimeout(() => {
1106
1103
  writable.close();
@@ -1265,12 +1262,10 @@ var Agent = class extends BaseResource {
1265
1262
  } finally {
1266
1263
  writer.releaseLock();
1267
1264
  }
1268
- const originalMessages = processedParams.messages;
1269
- const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
1270
1265
  this.processStreamResponse(
1271
1266
  {
1272
1267
  ...processedParams,
1273
- messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1268
+ messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
1274
1269
  },
1275
1270
  writable
1276
1271
  ).catch((error) => {
@@ -1517,193 +1512,6 @@ var Vector = class extends BaseResource {
1517
1512
  }
1518
1513
  };
1519
1514
 
1520
- // src/resources/legacy-workflow.ts
1521
- var RECORD_SEPARATOR = "";
1522
- var LegacyWorkflow = class extends BaseResource {
1523
- constructor(options, workflowId) {
1524
- super(options);
1525
- this.workflowId = workflowId;
1526
- }
1527
- /**
1528
- * Retrieves details about the legacy workflow
1529
- * @param runtimeContext - Optional runtime context to pass as query parameter
1530
- * @returns Promise containing legacy workflow details including steps and graphs
1531
- */
1532
- details(runtimeContext) {
1533
- return this.request(`/api/workflows/legacy/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
1534
- }
1535
- /**
1536
- * Retrieves all runs for a legacy workflow
1537
- * @param params - Parameters for filtering runs
1538
- * @param runtimeContext - Optional runtime context to pass as query parameter
1539
- * @returns Promise containing legacy workflow runs array
1540
- */
1541
- runs(params, runtimeContext) {
1542
- const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
1543
- const searchParams = new URLSearchParams();
1544
- if (params?.fromDate) {
1545
- searchParams.set("fromDate", params.fromDate.toISOString());
1546
- }
1547
- if (params?.toDate) {
1548
- searchParams.set("toDate", params.toDate.toISOString());
1549
- }
1550
- if (params?.limit) {
1551
- searchParams.set("limit", String(params.limit));
1552
- }
1553
- if (params?.offset) {
1554
- searchParams.set("offset", String(params.offset));
1555
- }
1556
- if (params?.resourceId) {
1557
- searchParams.set("resourceId", params.resourceId);
1558
- }
1559
- if (runtimeContextParam) {
1560
- searchParams.set("runtimeContext", runtimeContextParam);
1561
- }
1562
- if (searchParams.size) {
1563
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
1564
- } else {
1565
- return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
1566
- }
1567
- }
1568
- /**
1569
- * Creates a new legacy workflow run
1570
- * @returns Promise containing the generated run ID
1571
- */
1572
- createRun(params) {
1573
- const searchParams = new URLSearchParams();
1574
- if (!!params?.runId) {
1575
- searchParams.set("runId", params.runId);
1576
- }
1577
- return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
1578
- method: "POST"
1579
- });
1580
- }
1581
- /**
1582
- * Starts a legacy workflow run synchronously without waiting for the workflow to complete
1583
- * @param params - Object containing the runId and triggerData
1584
- * @returns Promise containing success message
1585
- */
1586
- start(params) {
1587
- return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
1588
- method: "POST",
1589
- body: params?.triggerData
1590
- });
1591
- }
1592
- /**
1593
- * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
1594
- * @param stepId - ID of the step to resume
1595
- * @param runId - ID of the legacy workflow run
1596
- * @param context - Context to resume the legacy workflow with
1597
- * @returns Promise containing the legacy workflow resume results
1598
- */
1599
- resume({
1600
- stepId,
1601
- runId,
1602
- context
1603
- }) {
1604
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
1605
- method: "POST",
1606
- body: {
1607
- stepId,
1608
- context
1609
- }
1610
- });
1611
- }
1612
- /**
1613
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
1614
- * @param params - Object containing the optional runId and triggerData
1615
- * @returns Promise containing the workflow execution results
1616
- */
1617
- startAsync(params) {
1618
- const searchParams = new URLSearchParams();
1619
- if (!!params?.runId) {
1620
- searchParams.set("runId", params.runId);
1621
- }
1622
- return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
1623
- method: "POST",
1624
- body: params?.triggerData
1625
- });
1626
- }
1627
- /**
1628
- * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
1629
- * @param params - Object containing the runId, stepId, and context
1630
- * @returns Promise containing the workflow resume results
1631
- */
1632
- resumeAsync(params) {
1633
- return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
1634
- method: "POST",
1635
- body: {
1636
- stepId: params.stepId,
1637
- context: params.context
1638
- }
1639
- });
1640
- }
1641
- /**
1642
- * Creates an async generator that processes a readable stream and yields records
1643
- * separated by the Record Separator character (\x1E)
1644
- *
1645
- * @param stream - The readable stream to process
1646
- * @returns An async generator that yields parsed records
1647
- */
1648
- async *streamProcessor(stream) {
1649
- const reader = stream.getReader();
1650
- let doneReading = false;
1651
- let buffer = "";
1652
- try {
1653
- while (!doneReading) {
1654
- const { done, value } = await reader.read();
1655
- doneReading = done;
1656
- if (done && !value) continue;
1657
- try {
1658
- const decoded = value ? new TextDecoder().decode(value) : "";
1659
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1660
- buffer = chunks.pop() || "";
1661
- for (const chunk of chunks) {
1662
- if (chunk) {
1663
- if (typeof chunk === "string") {
1664
- try {
1665
- const parsedChunk = JSON.parse(chunk);
1666
- yield parsedChunk;
1667
- } catch {
1668
- }
1669
- }
1670
- }
1671
- }
1672
- } catch {
1673
- }
1674
- }
1675
- if (buffer) {
1676
- try {
1677
- yield JSON.parse(buffer);
1678
- } catch {
1679
- }
1680
- }
1681
- } finally {
1682
- reader.cancel().catch(() => {
1683
- });
1684
- }
1685
- }
1686
- /**
1687
- * Watches legacy workflow transitions in real-time
1688
- * @param runId - Optional run ID to filter the watch stream
1689
- * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
1690
- */
1691
- async watch({ runId }, onRecord) {
1692
- const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
1693
- stream: true
1694
- });
1695
- if (!response.ok) {
1696
- throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
1697
- }
1698
- if (!response.body) {
1699
- throw new Error("Response body is null");
1700
- }
1701
- for await (const record of this.streamProcessor(response.body)) {
1702
- onRecord(record);
1703
- }
1704
- }
1705
- };
1706
-
1707
1515
  // src/resources/tool.ts
1708
1516
  var Tool = class extends BaseResource {
1709
1517
  constructor(options, toolId) {
@@ -1740,7 +1548,7 @@ var Tool = class extends BaseResource {
1740
1548
  };
1741
1549
 
1742
1550
  // src/resources/workflow.ts
1743
- var RECORD_SEPARATOR2 = "";
1551
+ var RECORD_SEPARATOR = "";
1744
1552
  var Workflow = class extends BaseResource {
1745
1553
  constructor(options, workflowId) {
1746
1554
  super(options);
@@ -1764,7 +1572,7 @@ var Workflow = class extends BaseResource {
1764
1572
  if (done && !value) continue;
1765
1573
  try {
1766
1574
  const decoded = value ? new TextDecoder().decode(value) : "";
1767
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
1575
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
1768
1576
  buffer = chunks.pop() || "";
1769
1577
  for (const chunk of chunks) {
1770
1578
  if (chunk) {
@@ -1902,10 +1710,20 @@ var Workflow = class extends BaseResource {
1902
1710
  return {
1903
1711
  runId,
1904
1712
  start: async (p) => {
1905
- return this.start({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1713
+ return this.start({
1714
+ runId,
1715
+ inputData: p.inputData,
1716
+ runtimeContext: p.runtimeContext,
1717
+ tracingOptions: p.tracingOptions
1718
+ });
1906
1719
  },
1907
1720
  startAsync: async (p) => {
1908
- return this.startAsync({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1721
+ return this.startAsync({
1722
+ runId,
1723
+ inputData: p.inputData,
1724
+ runtimeContext: p.runtimeContext,
1725
+ tracingOptions: p.tracingOptions
1726
+ });
1909
1727
  },
1910
1728
  watch: async (onRecord) => {
1911
1729
  return this.watch({ runId }, onRecord);
@@ -1914,10 +1732,22 @@ var Workflow = class extends BaseResource {
1914
1732
  return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
1915
1733
  },
1916
1734
  resume: async (p) => {
1917
- return this.resume({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
1735
+ return this.resume({
1736
+ runId,
1737
+ step: p.step,
1738
+ resumeData: p.resumeData,
1739
+ runtimeContext: p.runtimeContext,
1740
+ tracingOptions: p.tracingOptions
1741
+ });
1918
1742
  },
1919
1743
  resumeAsync: async (p) => {
1920
- return this.resumeAsync({ runId, step: p.step, resumeData: p.resumeData, runtimeContext: p.runtimeContext });
1744
+ return this.resumeAsync({
1745
+ runId,
1746
+ step: p.step,
1747
+ resumeData: p.resumeData,
1748
+ runtimeContext: p.runtimeContext,
1749
+ tracingOptions: p.tracingOptions
1750
+ });
1921
1751
  },
1922
1752
  resumeStreamVNext: async (p) => {
1923
1753
  return this.resumeStreamVNext({
@@ -1938,7 +1768,7 @@ var Workflow = class extends BaseResource {
1938
1768
  const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1939
1769
  return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
1940
1770
  method: "POST",
1941
- body: { inputData: params?.inputData, runtimeContext }
1771
+ body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
1942
1772
  });
1943
1773
  }
1944
1774
  /**
@@ -1950,6 +1780,7 @@ var Workflow = class extends BaseResource {
1950
1780
  step,
1951
1781
  runId,
1952
1782
  resumeData,
1783
+ tracingOptions,
1953
1784
  ...rest
1954
1785
  }) {
1955
1786
  const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
@@ -1958,7 +1789,8 @@ var Workflow = class extends BaseResource {
1958
1789
  body: {
1959
1790
  step,
1960
1791
  resumeData,
1961
- runtimeContext
1792
+ runtimeContext,
1793
+ tracingOptions
1962
1794
  }
1963
1795
  });
1964
1796
  }
@@ -1975,7 +1807,7 @@ var Workflow = class extends BaseResource {
1975
1807
  const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1976
1808
  return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
1977
1809
  method: "POST",
1978
- body: { inputData: params.inputData, runtimeContext }
1810
+ body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
1979
1811
  });
1980
1812
  }
1981
1813
  /**
@@ -1993,7 +1825,7 @@ var Workflow = class extends BaseResource {
1993
1825
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
1994
1826
  {
1995
1827
  method: "POST",
1996
- body: { inputData: params.inputData, runtimeContext },
1828
+ body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
1997
1829
  stream: true
1998
1830
  }
1999
1831
  );
@@ -2010,7 +1842,7 @@ var Workflow = class extends BaseResource {
2010
1842
  async transform(chunk, controller) {
2011
1843
  try {
2012
1844
  const decoded = new TextDecoder().decode(chunk);
2013
- const chunks = decoded.split(RECORD_SEPARATOR2);
1845
+ const chunks = decoded.split(RECORD_SEPARATOR);
2014
1846
  for (const chunk2 of chunks) {
2015
1847
  if (chunk2) {
2016
1848
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2057,7 +1889,7 @@ var Workflow = class extends BaseResource {
2057
1889
  async transform(chunk, controller) {
2058
1890
  try {
2059
1891
  const decoded = new TextDecoder().decode(chunk);
2060
- const chunks = decoded.split(RECORD_SEPARATOR2);
1892
+ const chunks = decoded.split(RECORD_SEPARATOR);
2061
1893
  for (const chunk2 of chunks) {
2062
1894
  if (chunk2) {
2063
1895
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2091,7 +1923,12 @@ var Workflow = class extends BaseResource {
2091
1923
  `/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
2092
1924
  {
2093
1925
  method: "POST",
2094
- body: { inputData: params.inputData, runtimeContext, closeOnSuspend: params.closeOnSuspend },
1926
+ body: {
1927
+ inputData: params.inputData,
1928
+ runtimeContext,
1929
+ closeOnSuspend: params.closeOnSuspend,
1930
+ tracingOptions: params.tracingOptions
1931
+ },
2095
1932
  stream: true
2096
1933
  }
2097
1934
  );
@@ -2108,7 +1945,7 @@ var Workflow = class extends BaseResource {
2108
1945
  async transform(chunk, controller) {
2109
1946
  try {
2110
1947
  const decoded = new TextDecoder().decode(chunk);
2111
- const chunks = decoded.split(RECORD_SEPARATOR2);
1948
+ const chunks = decoded.split(RECORD_SEPARATOR);
2112
1949
  for (const chunk2 of chunks) {
2113
1950
  if (chunk2) {
2114
1951
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2139,7 +1976,8 @@ var Workflow = class extends BaseResource {
2139
1976
  body: {
2140
1977
  step: params.step,
2141
1978
  resumeData: params.resumeData,
2142
- runtimeContext
1979
+ runtimeContext,
1980
+ tracingOptions: params.tracingOptions
2143
1981
  }
2144
1982
  });
2145
1983
  }
@@ -2155,7 +1993,8 @@ var Workflow = class extends BaseResource {
2155
1993
  body: {
2156
1994
  step: params.step,
2157
1995
  resumeData: params.resumeData,
2158
- runtimeContext
1996
+ runtimeContext,
1997
+ tracingOptions: params.tracingOptions
2159
1998
  }
2160
1999
  });
2161
2000
  }
@@ -2195,7 +2034,7 @@ var Workflow = class extends BaseResource {
2195
2034
  async start(controller) {
2196
2035
  try {
2197
2036
  for await (const record of records) {
2198
- const json = JSON.stringify(record) + RECORD_SEPARATOR2;
2037
+ const json = JSON.stringify(record) + RECORD_SEPARATOR;
2199
2038
  controller.enqueue(encoder.encode(json));
2200
2039
  }
2201
2040
  controller.close();
@@ -2318,7 +2157,7 @@ var MCPTool = class extends BaseResource {
2318
2157
  };
2319
2158
 
2320
2159
  // src/resources/agent-builder.ts
2321
- var RECORD_SEPARATOR3 = "";
2160
+ var RECORD_SEPARATOR2 = "";
2322
2161
  var AgentBuilder = class extends BaseResource {
2323
2162
  constructor(options, actionId) {
2324
2163
  super(options);
@@ -2458,7 +2297,7 @@ var AgentBuilder = class extends BaseResource {
2458
2297
  if (done && !value) continue;
2459
2298
  try {
2460
2299
  const decoded = value ? new TextDecoder().decode(value) : "";
2461
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
2300
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
2462
2301
  buffer = chunks.pop() || "";
2463
2302
  for (const chunk of chunks) {
2464
2303
  if (chunk) {
@@ -2515,7 +2354,7 @@ var AgentBuilder = class extends BaseResource {
2515
2354
  async transform(chunk, controller) {
2516
2355
  try {
2517
2356
  const decoded = new TextDecoder().decode(chunk);
2518
- const chunks = decoded.split(RECORD_SEPARATOR3);
2357
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2519
2358
  for (const chunk2 of chunks) {
2520
2359
  if (chunk2) {
2521
2360
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2564,7 +2403,7 @@ var AgentBuilder = class extends BaseResource {
2564
2403
  async transform(chunk, controller) {
2565
2404
  try {
2566
2405
  const decoded = new TextDecoder().decode(chunk);
2567
- const chunks = decoded.split(RECORD_SEPARATOR3);
2406
+ const chunks = decoded.split(RECORD_SEPARATOR2);
2568
2407
  for (const chunk2 of chunks) {
2569
2408
  if (chunk2) {
2570
2409
  const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
@@ -2735,6 +2574,25 @@ var Observability = class extends BaseResource {
2735
2574
  const queryString = searchParams.toString();
2736
2575
  return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
2737
2576
  }
2577
+ /**
2578
+ * Retrieves scores by trace ID and span ID
2579
+ * @param params - Parameters containing trace ID, span ID, and pagination options
2580
+ * @returns Promise containing scores and pagination info
2581
+ */
2582
+ getScoresBySpan(params) {
2583
+ const { traceId, spanId, page, perPage } = params;
2584
+ const searchParams = new URLSearchParams();
2585
+ if (page !== void 0) {
2586
+ searchParams.set("page", String(page));
2587
+ }
2588
+ if (perPage !== void 0) {
2589
+ searchParams.set("perPage", String(perPage));
2590
+ }
2591
+ const queryString = searchParams.toString();
2592
+ return this.request(
2593
+ `/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
2594
+ );
2595
+ }
2738
2596
  score(params) {
2739
2597
  return this.request(`/api/observability/traces/score`, {
2740
2598
  method: "POST",
@@ -2807,7 +2665,7 @@ var NetworkMemoryThread = class extends BaseResource {
2807
2665
  };
2808
2666
 
2809
2667
  // src/resources/vNextNetwork.ts
2810
- var RECORD_SEPARATOR4 = "";
2668
+ var RECORD_SEPARATOR3 = "";
2811
2669
  var VNextNetwork = class extends BaseResource {
2812
2670
  constructor(options, networkId) {
2813
2671
  super(options);
@@ -2860,7 +2718,7 @@ var VNextNetwork = class extends BaseResource {
2860
2718
  if (done && !value) continue;
2861
2719
  try {
2862
2720
  const decoded = value ? new TextDecoder().decode(value) : "";
2863
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR4);
2721
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
2864
2722
  buffer = chunks.pop() || "";
2865
2723
  for (const chunk of chunks) {
2866
2724
  if (chunk) {
@@ -3106,21 +2964,6 @@ var MastraClient = class extends BaseResource {
3106
2964
  getTool(toolId) {
3107
2965
  return new Tool(this.options, toolId);
3108
2966
  }
3109
- /**
3110
- * Retrieves all available legacy workflows
3111
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
3112
- */
3113
- getLegacyWorkflows() {
3114
- return this.request("/api/workflows/legacy");
3115
- }
3116
- /**
3117
- * Gets a legacy workflow instance by ID
3118
- * @param workflowId - ID of the legacy workflow to retrieve
3119
- * @returns Legacy Workflow instance
3120
- */
3121
- getLegacyWorkflow(workflowId) {
3122
- return new LegacyWorkflow(this.options, workflowId);
3123
- }
3124
2967
  /**
3125
2968
  * Retrieves all available workflows
3126
2969
  * @param runtimeContext - Optional runtime context to pass as query parameter
@@ -3420,7 +3263,7 @@ var MastraClient = class extends BaseResource {
3420
3263
  * @returns Promise containing the scorer
3421
3264
  */
3422
3265
  getScorer(scorerId) {
3423
- return this.request(`/api/scores/scorers/${scorerId}`);
3266
+ return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
3424
3267
  }
3425
3268
  getScoresByScorerId(params) {
3426
3269
  const { page, perPage, scorerId, entityId, entityType } = params;
@@ -3438,7 +3281,7 @@ var MastraClient = class extends BaseResource {
3438
3281
  searchParams.set("perPage", String(perPage));
3439
3282
  }
3440
3283
  const queryString = searchParams.toString();
3441
- return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
3284
+ return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
3442
3285
  }
3443
3286
  /**
3444
3287
  * Retrieves scores by run ID
@@ -3455,7 +3298,7 @@ var MastraClient = class extends BaseResource {
3455
3298
  searchParams.set("perPage", String(perPage));
3456
3299
  }
3457
3300
  const queryString = searchParams.toString();
3458
- return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
3301
+ return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
3459
3302
  }
3460
3303
  /**
3461
3304
  * Retrieves scores by entity ID and type
@@ -3472,7 +3315,9 @@ var MastraClient = class extends BaseResource {
3472
3315
  searchParams.set("perPage", String(perPage));
3473
3316
  }
3474
3317
  const queryString = searchParams.toString();
3475
- return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
3318
+ return this.request(
3319
+ `/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
3320
+ );
3476
3321
  }
3477
3322
  /**
3478
3323
  * Saves a score
@@ -3498,6 +3343,9 @@ var MastraClient = class extends BaseResource {
3498
3343
  getAITraces(params) {
3499
3344
  return this.observability.getTraces(params);
3500
3345
  }
3346
+ getScoresBySpan(params) {
3347
+ return this.observability.getScoresBySpan(params);
3348
+ }
3501
3349
  score(params) {
3502
3350
  return this.observability.score(params);
3503
3351
  }