@mastra/client-js 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250730132657
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/CHANGELOG.md +318 -3
- package/LICENSE.md +11 -42
- package/README.md +1 -0
- package/dist/index.cjs +261 -66
- package/dist/index.d.cts +211 -45
- package/dist/index.d.ts +211 -45
- package/dist/index.js +260 -65
- package/package.json +6 -5
- package/src/client.ts +145 -2
- package/src/example.ts +45 -17
- package/src/index.test.ts +294 -6
- package/src/resources/agent.ts +51 -21
- package/src/resources/base.ts +6 -1
- package/src/resources/memory-thread.ts +18 -0
- package/src/resources/network.ts +4 -3
- package/src/resources/vNextNetwork.ts +22 -5
- package/src/resources/workflow.ts +42 -5
- package/src/types.ts +95 -4
- package/src/utils/process-client-tools.ts +1 -1
- package/.turbo/turbo-build.log +0 -19
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
|
|
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 (
|
|
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(
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
489
|
+
revisionId: uuid.v4()
|
|
481
490
|
};
|
|
482
491
|
update({
|
|
483
492
|
message: copiedMessage,
|
|
@@ -774,6 +783,19 @@ var Agent = class extends BaseResource {
|
|
|
774
783
|
toolInvocation.state = "result";
|
|
775
784
|
toolInvocation.result = result;
|
|
776
785
|
}
|
|
786
|
+
const writer = writable.getWriter();
|
|
787
|
+
try {
|
|
788
|
+
await writer.write(
|
|
789
|
+
new TextEncoder().encode(
|
|
790
|
+
"a:" + JSON.stringify({
|
|
791
|
+
toolCallId: toolCall2.toolCallId,
|
|
792
|
+
result
|
|
793
|
+
}) + "\n"
|
|
794
|
+
)
|
|
795
|
+
);
|
|
796
|
+
} finally {
|
|
797
|
+
writer.releaseLock();
|
|
798
|
+
}
|
|
777
799
|
const originalMessages = processedParams.messages;
|
|
778
800
|
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
779
801
|
this.processStreamResponse(
|
|
@@ -940,6 +962,21 @@ var MemoryThread = class extends BaseResource {
|
|
|
940
962
|
});
|
|
941
963
|
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
942
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Retrieves paginated messages associated with the thread with advanced filtering and selection options
|
|
967
|
+
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
|
|
968
|
+
* @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
|
|
969
|
+
*/
|
|
970
|
+
getMessagesPaginated({
|
|
971
|
+
selectBy,
|
|
972
|
+
...rest
|
|
973
|
+
}) {
|
|
974
|
+
const query = new URLSearchParams({
|
|
975
|
+
...rest,
|
|
976
|
+
...selectBy ? { selectBy: JSON.stringify(selectBy) } : {}
|
|
977
|
+
});
|
|
978
|
+
return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
|
|
979
|
+
}
|
|
943
980
|
};
|
|
944
981
|
|
|
945
982
|
// src/resources/vector.ts
|
|
@@ -1295,10 +1332,10 @@ var Workflow = class extends BaseResource {
|
|
|
1295
1332
|
if (params?.toDate) {
|
|
1296
1333
|
searchParams.set("toDate", params.toDate.toISOString());
|
|
1297
1334
|
}
|
|
1298
|
-
if (params?.limit) {
|
|
1335
|
+
if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
|
|
1299
1336
|
searchParams.set("limit", String(params.limit));
|
|
1300
1337
|
}
|
|
1301
|
-
if (params?.offset) {
|
|
1338
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
1302
1339
|
searchParams.set("offset", String(params.offset));
|
|
1303
1340
|
}
|
|
1304
1341
|
if (params?.resourceId) {
|
|
@@ -1326,6 +1363,27 @@ var Workflow = class extends BaseResource {
|
|
|
1326
1363
|
runExecutionResult(runId) {
|
|
1327
1364
|
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
|
|
1328
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Cancels a specific workflow run by its ID
|
|
1368
|
+
* @param runId - The ID of the workflow run to cancel
|
|
1369
|
+
* @returns Promise containing a success message
|
|
1370
|
+
*/
|
|
1371
|
+
cancelRun(runId) {
|
|
1372
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
|
|
1373
|
+
method: "POST"
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Sends an event to a specific workflow run by its ID
|
|
1378
|
+
* @param params - Object containing the runId, event and data
|
|
1379
|
+
* @returns Promise containing a success message
|
|
1380
|
+
*/
|
|
1381
|
+
sendRunEvent(params) {
|
|
1382
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
|
|
1383
|
+
method: "POST",
|
|
1384
|
+
body: { event: params.event, data: params.data }
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1329
1387
|
/**
|
|
1330
1388
|
* Creates a new workflow run
|
|
1331
1389
|
* @param params - Optional object containing the optional runId
|
|
@@ -1340,6 +1398,14 @@ var Workflow = class extends BaseResource {
|
|
|
1340
1398
|
method: "POST"
|
|
1341
1399
|
});
|
|
1342
1400
|
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Creates a new workflow run (alias for createRun)
|
|
1403
|
+
* @param params - Optional object containing the optional runId
|
|
1404
|
+
* @returns Promise containing the runId of the created run
|
|
1405
|
+
*/
|
|
1406
|
+
createRunAsync(params) {
|
|
1407
|
+
return this.createRun(params);
|
|
1408
|
+
}
|
|
1343
1409
|
/**
|
|
1344
1410
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1345
1411
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -1415,6 +1481,7 @@ var Workflow = class extends BaseResource {
|
|
|
1415
1481
|
if (!response.body) {
|
|
1416
1482
|
throw new Error("Response body is null");
|
|
1417
1483
|
}
|
|
1484
|
+
let failedChunk = void 0;
|
|
1418
1485
|
const transformStream = new TransformStream({
|
|
1419
1486
|
start() {
|
|
1420
1487
|
},
|
|
@@ -1424,10 +1491,13 @@ var Workflow = class extends BaseResource {
|
|
|
1424
1491
|
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
1425
1492
|
for (const chunk2 of chunks) {
|
|
1426
1493
|
if (chunk2) {
|
|
1494
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1427
1495
|
try {
|
|
1428
|
-
const parsedChunk = JSON.parse(
|
|
1496
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1429
1497
|
controller.enqueue(parsedChunk);
|
|
1430
|
-
|
|
1498
|
+
failedChunk = void 0;
|
|
1499
|
+
} catch (error) {
|
|
1500
|
+
failedChunk = newChunk;
|
|
1431
1501
|
}
|
|
1432
1502
|
}
|
|
1433
1503
|
}
|
|
@@ -1609,6 +1679,54 @@ var MCPTool = class extends BaseResource {
|
|
|
1609
1679
|
}
|
|
1610
1680
|
};
|
|
1611
1681
|
|
|
1682
|
+
// src/resources/network-memory-thread.ts
|
|
1683
|
+
var NetworkMemoryThread = class extends BaseResource {
|
|
1684
|
+
constructor(options, threadId, networkId) {
|
|
1685
|
+
super(options);
|
|
1686
|
+
this.threadId = threadId;
|
|
1687
|
+
this.networkId = networkId;
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Retrieves the memory thread details
|
|
1691
|
+
* @returns Promise containing thread details including title and metadata
|
|
1692
|
+
*/
|
|
1693
|
+
get() {
|
|
1694
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Updates the memory thread properties
|
|
1698
|
+
* @param params - Update parameters including title and metadata
|
|
1699
|
+
* @returns Promise containing updated thread details
|
|
1700
|
+
*/
|
|
1701
|
+
update(params) {
|
|
1702
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1703
|
+
method: "PATCH",
|
|
1704
|
+
body: params
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Deletes the memory thread
|
|
1709
|
+
* @returns Promise containing deletion result
|
|
1710
|
+
*/
|
|
1711
|
+
delete() {
|
|
1712
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1713
|
+
method: "DELETE"
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Retrieves messages associated with the thread
|
|
1718
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1719
|
+
* @returns Promise containing thread messages and UI messages
|
|
1720
|
+
*/
|
|
1721
|
+
getMessages(params) {
|
|
1722
|
+
const query = new URLSearchParams({
|
|
1723
|
+
networkId: this.networkId,
|
|
1724
|
+
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1725
|
+
});
|
|
1726
|
+
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1612
1730
|
// src/resources/vNextNetwork.ts
|
|
1613
1731
|
var RECORD_SEPARATOR3 = "";
|
|
1614
1732
|
var VNextNetwork = class extends BaseResource {
|
|
@@ -1631,7 +1749,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1631
1749
|
generate(params) {
|
|
1632
1750
|
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
1633
1751
|
method: "POST",
|
|
1634
|
-
body:
|
|
1752
|
+
body: {
|
|
1753
|
+
...params,
|
|
1754
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1755
|
+
}
|
|
1635
1756
|
});
|
|
1636
1757
|
}
|
|
1637
1758
|
/**
|
|
@@ -1642,7 +1763,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1642
1763
|
loop(params) {
|
|
1643
1764
|
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
1644
1765
|
method: "POST",
|
|
1645
|
-
body:
|
|
1766
|
+
body: {
|
|
1767
|
+
...params,
|
|
1768
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1769
|
+
}
|
|
1646
1770
|
});
|
|
1647
1771
|
}
|
|
1648
1772
|
async *streamProcessor(stream) {
|
|
@@ -1691,7 +1815,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1691
1815
|
async stream(params, onRecord) {
|
|
1692
1816
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
1693
1817
|
method: "POST",
|
|
1694
|
-
body:
|
|
1818
|
+
body: {
|
|
1819
|
+
...params,
|
|
1820
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1821
|
+
},
|
|
1695
1822
|
stream: true
|
|
1696
1823
|
});
|
|
1697
1824
|
if (!response.ok) {
|
|
@@ -1716,7 +1843,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1716
1843
|
async loopStream(params, onRecord) {
|
|
1717
1844
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
1718
1845
|
method: "POST",
|
|
1719
|
-
body:
|
|
1846
|
+
body: {
|
|
1847
|
+
...params,
|
|
1848
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1849
|
+
},
|
|
1720
1850
|
stream: true
|
|
1721
1851
|
});
|
|
1722
1852
|
if (!response.ok) {
|
|
@@ -1735,54 +1865,6 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1735
1865
|
}
|
|
1736
1866
|
};
|
|
1737
1867
|
|
|
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
1868
|
// src/client.ts
|
|
1787
1869
|
var MastraClient = class extends BaseResource {
|
|
1788
1870
|
constructor(options) {
|
|
@@ -2177,6 +2259,119 @@ var MastraClient = class extends BaseResource {
|
|
|
2177
2259
|
getA2A(agentId) {
|
|
2178
2260
|
return new A2A(this.options, agentId);
|
|
2179
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Retrieves the working memory for a specific thread (optionally resource-scoped).
|
|
2264
|
+
* @param agentId - ID of the agent.
|
|
2265
|
+
* @param threadId - ID of the thread.
|
|
2266
|
+
* @param resourceId - Optional ID of the resource.
|
|
2267
|
+
* @returns Working memory for the specified thread or resource.
|
|
2268
|
+
*/
|
|
2269
|
+
getWorkingMemory({
|
|
2270
|
+
agentId,
|
|
2271
|
+
threadId,
|
|
2272
|
+
resourceId
|
|
2273
|
+
}) {
|
|
2274
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Updates the working memory for a specific thread (optionally resource-scoped).
|
|
2278
|
+
* @param agentId - ID of the agent.
|
|
2279
|
+
* @param threadId - ID of the thread.
|
|
2280
|
+
* @param workingMemory - The new working memory content.
|
|
2281
|
+
* @param resourceId - Optional ID of the resource.
|
|
2282
|
+
*/
|
|
2283
|
+
updateWorkingMemory({
|
|
2284
|
+
agentId,
|
|
2285
|
+
threadId,
|
|
2286
|
+
workingMemory,
|
|
2287
|
+
resourceId
|
|
2288
|
+
}) {
|
|
2289
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
|
|
2290
|
+
method: "POST",
|
|
2291
|
+
body: {
|
|
2292
|
+
workingMemory,
|
|
2293
|
+
resourceId
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
/**
|
|
2298
|
+
* Retrieves all available scorers
|
|
2299
|
+
* @returns Promise containing list of available scorers
|
|
2300
|
+
*/
|
|
2301
|
+
getScorers() {
|
|
2302
|
+
return this.request("/api/scores/scorers");
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Retrieves a scorer by ID
|
|
2306
|
+
* @param scorerId - ID of the scorer to retrieve
|
|
2307
|
+
* @returns Promise containing the scorer
|
|
2308
|
+
*/
|
|
2309
|
+
getScorer(scorerId) {
|
|
2310
|
+
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
2311
|
+
}
|
|
2312
|
+
getScoresByScorerId(params) {
|
|
2313
|
+
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
2314
|
+
const searchParams = new URLSearchParams();
|
|
2315
|
+
if (entityId) {
|
|
2316
|
+
searchParams.set("entityId", entityId);
|
|
2317
|
+
}
|
|
2318
|
+
if (entityType) {
|
|
2319
|
+
searchParams.set("entityType", entityType);
|
|
2320
|
+
}
|
|
2321
|
+
if (page !== void 0) {
|
|
2322
|
+
searchParams.set("page", String(page));
|
|
2323
|
+
}
|
|
2324
|
+
if (perPage !== void 0) {
|
|
2325
|
+
searchParams.set("perPage", String(perPage));
|
|
2326
|
+
}
|
|
2327
|
+
const queryString = searchParams.toString();
|
|
2328
|
+
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Retrieves scores by run ID
|
|
2332
|
+
* @param params - Parameters containing run ID and pagination options
|
|
2333
|
+
* @returns Promise containing scores and pagination info
|
|
2334
|
+
*/
|
|
2335
|
+
getScoresByRunId(params) {
|
|
2336
|
+
const { runId, page, perPage } = params;
|
|
2337
|
+
const searchParams = new URLSearchParams();
|
|
2338
|
+
if (page !== void 0) {
|
|
2339
|
+
searchParams.set("page", String(page));
|
|
2340
|
+
}
|
|
2341
|
+
if (perPage !== void 0) {
|
|
2342
|
+
searchParams.set("perPage", String(perPage));
|
|
2343
|
+
}
|
|
2344
|
+
const queryString = searchParams.toString();
|
|
2345
|
+
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Retrieves scores by entity ID and type
|
|
2349
|
+
* @param params - Parameters containing entity ID, type, and pagination options
|
|
2350
|
+
* @returns Promise containing scores and pagination info
|
|
2351
|
+
*/
|
|
2352
|
+
getScoresByEntityId(params) {
|
|
2353
|
+
const { entityId, entityType, page, perPage } = params;
|
|
2354
|
+
const searchParams = new URLSearchParams();
|
|
2355
|
+
if (page !== void 0) {
|
|
2356
|
+
searchParams.set("page", String(page));
|
|
2357
|
+
}
|
|
2358
|
+
if (perPage !== void 0) {
|
|
2359
|
+
searchParams.set("perPage", String(perPage));
|
|
2360
|
+
}
|
|
2361
|
+
const queryString = searchParams.toString();
|
|
2362
|
+
return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
|
|
2363
|
+
}
|
|
2364
|
+
/**
|
|
2365
|
+
* Saves a score
|
|
2366
|
+
* @param params - Parameters containing the score data to save
|
|
2367
|
+
* @returns Promise containing the saved score
|
|
2368
|
+
*/
|
|
2369
|
+
saveScore(params) {
|
|
2370
|
+
return this.request("/api/scores", {
|
|
2371
|
+
method: "POST",
|
|
2372
|
+
body: params
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2180
2375
|
};
|
|
2181
2376
|
|
|
2182
2377
|
exports.MastraClient = MastraClient;
|