@mastra/client-js 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-update-scorers-api-20250801170445
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 +401 -2
- package/LICENSE.md +11 -42
- package/README.md +1 -0
- package/dist/adapters/agui.d.ts +23 -0
- package/dist/adapters/agui.d.ts.map +1 -0
- package/dist/client.d.ts +265 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/index.cjs +269 -67
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -1164
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +268 -66
- package/dist/index.js.map +1 -0
- package/dist/resources/a2a.d.ts +44 -0
- package/dist/resources/a2a.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +112 -0
- package/dist/resources/agent.d.ts.map +1 -0
- package/dist/resources/base.d.ts +13 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/index.d.ts +11 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/legacy-workflow.d.ts +87 -0
- package/dist/resources/legacy-workflow.d.ts.map +1 -0
- package/dist/resources/mcp-tool.d.ts +27 -0
- package/dist/resources/mcp-tool.d.ts.map +1 -0
- package/dist/resources/memory-thread.d.ts +53 -0
- package/dist/resources/memory-thread.d.ts.map +1 -0
- package/dist/resources/network-memory-thread.d.ts +47 -0
- package/dist/resources/network-memory-thread.d.ts.map +1 -0
- package/dist/resources/network.d.ts +30 -0
- package/dist/resources/network.d.ts.map +1 -0
- package/dist/resources/tool.d.ts +23 -0
- package/dist/resources/tool.d.ts.map +1 -0
- package/dist/resources/vNextNetwork.d.ts +42 -0
- package/dist/resources/vNextNetwork.d.ts.map +1 -0
- package/dist/resources/vector.d.ts +48 -0
- package/dist/resources/vector.d.ts.map +1 -0
- package/dist/resources/workflow.d.ts +154 -0
- package/dist/resources/workflow.d.ts.map +1 -0
- package/dist/types.d.ts +422 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/process-client-tools.d.ts +3 -0
- package/dist/utils/process-client-tools.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +105 -0
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
- package/integration-tests/agui-adapter.test.ts +122 -0
- package/integration-tests/package.json +18 -0
- package/integration-tests/src/mastra/index.ts +35 -0
- package/integration-tests/vitest.config.ts +9 -0
- package/package.json +12 -8
- package/src/adapters/agui.test.ts +145 -3
- package/src/client.ts +145 -2
- package/src/example.ts +45 -17
- package/src/index.test.ts +402 -6
- package/src/index.ts +1 -0
- package/src/resources/agent.ts +46 -24
- package/src/resources/base.ts +6 -1
- package/src/resources/memory-thread.test.ts +285 -0
- package/src/resources/memory-thread.ts +36 -0
- package/src/resources/network-memory-thread.test.ts +269 -0
- package/src/resources/network-memory-thread.ts +18 -0
- package/src/resources/network.ts +4 -3
- package/src/resources/vNextNetwork.ts +22 -5
- package/src/resources/workflow.ts +17 -3
- package/src/types.ts +90 -10
- package/src/utils/process-client-tools.ts +1 -1
- package/src/v2-messages.test.ts +180 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +22 -0
- package/.turbo/turbo-build.log +0 -19
- package/dist/index.d.cts +0 -1164
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,
|
|
@@ -732,7 +741,12 @@ var Agent = class extends BaseResource {
|
|
|
732
741
|
this.processChatResponse({
|
|
733
742
|
stream: streamForProcessing,
|
|
734
743
|
update: ({ message }) => {
|
|
735
|
-
messages.
|
|
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") {
|
|
@@ -792,10 +806,12 @@ var Agent = class extends BaseResource {
|
|
|
792
806
|
this.processStreamResponse(
|
|
793
807
|
{
|
|
794
808
|
...processedParams,
|
|
795
|
-
messages: [...messageArray, ...messages, lastMessage]
|
|
809
|
+
messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
796
810
|
},
|
|
797
811
|
writable
|
|
798
|
-
)
|
|
812
|
+
).catch((error) => {
|
|
813
|
+
console.error("Error processing stream response:", error);
|
|
814
|
+
});
|
|
799
815
|
}
|
|
800
816
|
}
|
|
801
817
|
} else {
|
|
@@ -805,6 +821,8 @@ var Agent = class extends BaseResource {
|
|
|
805
821
|
}
|
|
806
822
|
},
|
|
807
823
|
lastMessage: void 0
|
|
824
|
+
}).catch((error) => {
|
|
825
|
+
console.error("Error processing stream response:", error);
|
|
808
826
|
});
|
|
809
827
|
} catch (error) {
|
|
810
828
|
console.error("Error processing stream response:", error);
|
|
@@ -953,6 +971,36 @@ var MemoryThread = class extends BaseResource {
|
|
|
953
971
|
});
|
|
954
972
|
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
955
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
|
+
}
|
|
956
1004
|
};
|
|
957
1005
|
|
|
958
1006
|
// src/resources/vector.ts
|
|
@@ -1374,6 +1422,14 @@ var Workflow = class extends BaseResource {
|
|
|
1374
1422
|
method: "POST"
|
|
1375
1423
|
});
|
|
1376
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
|
+
}
|
|
1377
1433
|
/**
|
|
1378
1434
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1379
1435
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -1449,6 +1505,7 @@ var Workflow = class extends BaseResource {
|
|
|
1449
1505
|
if (!response.body) {
|
|
1450
1506
|
throw new Error("Response body is null");
|
|
1451
1507
|
}
|
|
1508
|
+
let failedChunk = void 0;
|
|
1452
1509
|
const transformStream = new TransformStream({
|
|
1453
1510
|
start() {
|
|
1454
1511
|
},
|
|
@@ -1458,10 +1515,13 @@ var Workflow = class extends BaseResource {
|
|
|
1458
1515
|
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
1459
1516
|
for (const chunk2 of chunks) {
|
|
1460
1517
|
if (chunk2) {
|
|
1518
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1461
1519
|
try {
|
|
1462
|
-
const parsedChunk = JSON.parse(
|
|
1520
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1463
1521
|
controller.enqueue(parsedChunk);
|
|
1464
|
-
|
|
1522
|
+
failedChunk = void 0;
|
|
1523
|
+
} catch (error) {
|
|
1524
|
+
failedChunk = newChunk;
|
|
1465
1525
|
}
|
|
1466
1526
|
}
|
|
1467
1527
|
}
|
|
@@ -1643,6 +1703,69 @@ var MCPTool = class extends BaseResource {
|
|
|
1643
1703
|
}
|
|
1644
1704
|
};
|
|
1645
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
|
+
|
|
1646
1769
|
// src/resources/vNextNetwork.ts
|
|
1647
1770
|
var RECORD_SEPARATOR3 = "";
|
|
1648
1771
|
var VNextNetwork = class extends BaseResource {
|
|
@@ -1665,7 +1788,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1665
1788
|
generate(params) {
|
|
1666
1789
|
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
1667
1790
|
method: "POST",
|
|
1668
|
-
body:
|
|
1791
|
+
body: {
|
|
1792
|
+
...params,
|
|
1793
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1794
|
+
}
|
|
1669
1795
|
});
|
|
1670
1796
|
}
|
|
1671
1797
|
/**
|
|
@@ -1676,7 +1802,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1676
1802
|
loop(params) {
|
|
1677
1803
|
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
1678
1804
|
method: "POST",
|
|
1679
|
-
body:
|
|
1805
|
+
body: {
|
|
1806
|
+
...params,
|
|
1807
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1808
|
+
}
|
|
1680
1809
|
});
|
|
1681
1810
|
}
|
|
1682
1811
|
async *streamProcessor(stream) {
|
|
@@ -1725,7 +1854,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1725
1854
|
async stream(params, onRecord) {
|
|
1726
1855
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
1727
1856
|
method: "POST",
|
|
1728
|
-
body:
|
|
1857
|
+
body: {
|
|
1858
|
+
...params,
|
|
1859
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1860
|
+
},
|
|
1729
1861
|
stream: true
|
|
1730
1862
|
});
|
|
1731
1863
|
if (!response.ok) {
|
|
@@ -1750,7 +1882,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1750
1882
|
async loopStream(params, onRecord) {
|
|
1751
1883
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
1752
1884
|
method: "POST",
|
|
1753
|
-
body:
|
|
1885
|
+
body: {
|
|
1886
|
+
...params,
|
|
1887
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1888
|
+
},
|
|
1754
1889
|
stream: true
|
|
1755
1890
|
});
|
|
1756
1891
|
if (!response.ok) {
|
|
@@ -1769,54 +1904,6 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1769
1904
|
}
|
|
1770
1905
|
};
|
|
1771
1906
|
|
|
1772
|
-
// src/resources/network-memory-thread.ts
|
|
1773
|
-
var NetworkMemoryThread = class extends BaseResource {
|
|
1774
|
-
constructor(options, threadId, networkId) {
|
|
1775
|
-
super(options);
|
|
1776
|
-
this.threadId = threadId;
|
|
1777
|
-
this.networkId = networkId;
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* Retrieves the memory thread details
|
|
1781
|
-
* @returns Promise containing thread details including title and metadata
|
|
1782
|
-
*/
|
|
1783
|
-
get() {
|
|
1784
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1785
|
-
}
|
|
1786
|
-
/**
|
|
1787
|
-
* Updates the memory thread properties
|
|
1788
|
-
* @param params - Update parameters including title and metadata
|
|
1789
|
-
* @returns Promise containing updated thread details
|
|
1790
|
-
*/
|
|
1791
|
-
update(params) {
|
|
1792
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1793
|
-
method: "PATCH",
|
|
1794
|
-
body: params
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
/**
|
|
1798
|
-
* Deletes the memory thread
|
|
1799
|
-
* @returns Promise containing deletion result
|
|
1800
|
-
*/
|
|
1801
|
-
delete() {
|
|
1802
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1803
|
-
method: "DELETE"
|
|
1804
|
-
});
|
|
1805
|
-
}
|
|
1806
|
-
/**
|
|
1807
|
-
* Retrieves messages associated with the thread
|
|
1808
|
-
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1809
|
-
* @returns Promise containing thread messages and UI messages
|
|
1810
|
-
*/
|
|
1811
|
-
getMessages(params) {
|
|
1812
|
-
const query = new URLSearchParams({
|
|
1813
|
-
networkId: this.networkId,
|
|
1814
|
-
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1815
|
-
});
|
|
1816
|
-
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1817
|
-
}
|
|
1818
|
-
};
|
|
1819
|
-
|
|
1820
1907
|
// src/client.ts
|
|
1821
1908
|
var MastraClient = class extends BaseResource {
|
|
1822
1909
|
constructor(options) {
|
|
@@ -2211,6 +2298,121 @@ var MastraClient = class extends BaseResource {
|
|
|
2211
2298
|
getA2A(agentId) {
|
|
2212
2299
|
return new A2A(this.options, agentId);
|
|
2213
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
|
+
}
|
|
2214
2414
|
};
|
|
2215
2415
|
|
|
2216
2416
|
exports.MastraClient = MastraClient;
|
|
2417
|
+
//# sourceMappingURL=index.cjs.map
|
|
2418
|
+
//# sourceMappingURL=index.cjs.map
|