@mastra/client-js 0.0.0-custom-instrumentation-20250708222033 → 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.
- package/.turbo/turbo-build.log +8 -10
- package/CHANGELOG.md +292 -2
- 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 +268 -67
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -1165
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +267 -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/package.json +6 -5
- 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 +5 -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 +83 -7
- package/src/utils/process-client-tools.ts +1 -1
- package/src/v2-messages.test.ts +180 -0
- package/tsconfig.build.json +9 -0
- package/dist/index.d.cts +0 -1165
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,7 +253,7 @@ 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
|
|
@@ -377,12 +378,19 @@ var Agent = class extends BaseResource {
|
|
|
377
378
|
clientTools: processClientTools(params.clientTools)
|
|
378
379
|
};
|
|
379
380
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
380
|
-
const response = await this.request(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
const response = await this.request(
|
|
382
|
+
`/api/agents/${this.agentId}/generate`,
|
|
383
|
+
{
|
|
384
|
+
method: "POST",
|
|
385
|
+
body: processedParams
|
|
386
|
+
}
|
|
387
|
+
);
|
|
384
388
|
if (response.finishReason === "tool-calls") {
|
|
385
|
-
|
|
389
|
+
const toolCalls = response.toolCalls;
|
|
390
|
+
if (!toolCalls || !Array.isArray(toolCalls)) {
|
|
391
|
+
return response;
|
|
392
|
+
}
|
|
393
|
+
for (const toolCall of toolCalls) {
|
|
386
394
|
const clientTool = params.clientTools?.[toolCall.toolName];
|
|
387
395
|
if (clientTool && clientTool.execute) {
|
|
388
396
|
const result = await clientTool.execute(
|
|
@@ -433,7 +441,7 @@ var Agent = class extends BaseResource {
|
|
|
433
441
|
return Math.max(max, toolInvocation.step ?? 0);
|
|
434
442
|
}, 0) ?? 0) : 0;
|
|
435
443
|
const message = replaceLastMessage ? structuredClone(lastMessage) : {
|
|
436
|
-
id:
|
|
444
|
+
id: uuid.v4(),
|
|
437
445
|
createdAt: getCurrentDate(),
|
|
438
446
|
role: "assistant",
|
|
439
447
|
content: "",
|
|
@@ -478,7 +486,7 @@ var Agent = class extends BaseResource {
|
|
|
478
486
|
// changes. This is why we need to add a revision id to ensure that the message
|
|
479
487
|
// is updated with SWR (without it, the changes get stuck in SWR and are not
|
|
480
488
|
// forwarded to rendering):
|
|
481
|
-
revisionId:
|
|
489
|
+
revisionId: uuid.v4()
|
|
482
490
|
};
|
|
483
491
|
update({
|
|
484
492
|
message: copiedMessage,
|
|
@@ -733,7 +741,12 @@ var Agent = class extends BaseResource {
|
|
|
733
741
|
this.processChatResponse({
|
|
734
742
|
stream: streamForProcessing,
|
|
735
743
|
update: ({ message }) => {
|
|
736
|
-
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
|
+
}
|
|
737
750
|
},
|
|
738
751
|
onFinish: async ({ finishReason, message }) => {
|
|
739
752
|
if (finishReason === "tool-calls") {
|
|
@@ -793,10 +806,12 @@ var Agent = class extends BaseResource {
|
|
|
793
806
|
this.processStreamResponse(
|
|
794
807
|
{
|
|
795
808
|
...processedParams,
|
|
796
|
-
messages: [...messageArray, ...messages, lastMessage]
|
|
809
|
+
messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
797
810
|
},
|
|
798
811
|
writable
|
|
799
|
-
)
|
|
812
|
+
).catch((error) => {
|
|
813
|
+
console.error("Error processing stream response:", error);
|
|
814
|
+
});
|
|
800
815
|
}
|
|
801
816
|
}
|
|
802
817
|
} else {
|
|
@@ -806,6 +821,8 @@ var Agent = class extends BaseResource {
|
|
|
806
821
|
}
|
|
807
822
|
},
|
|
808
823
|
lastMessage: void 0
|
|
824
|
+
}).catch((error) => {
|
|
825
|
+
console.error("Error processing stream response:", error);
|
|
809
826
|
});
|
|
810
827
|
} catch (error) {
|
|
811
828
|
console.error("Error processing stream response:", error);
|
|
@@ -954,6 +971,36 @@ var MemoryThread = class extends BaseResource {
|
|
|
954
971
|
});
|
|
955
972
|
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
956
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
|
+
}
|
|
957
1004
|
};
|
|
958
1005
|
|
|
959
1006
|
// src/resources/vector.ts
|
|
@@ -1375,6 +1422,14 @@ var Workflow = class extends BaseResource {
|
|
|
1375
1422
|
method: "POST"
|
|
1376
1423
|
});
|
|
1377
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
|
+
}
|
|
1378
1433
|
/**
|
|
1379
1434
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1380
1435
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -1450,6 +1505,7 @@ var Workflow = class extends BaseResource {
|
|
|
1450
1505
|
if (!response.body) {
|
|
1451
1506
|
throw new Error("Response body is null");
|
|
1452
1507
|
}
|
|
1508
|
+
let failedChunk = void 0;
|
|
1453
1509
|
const transformStream = new TransformStream({
|
|
1454
1510
|
start() {
|
|
1455
1511
|
},
|
|
@@ -1459,10 +1515,13 @@ var Workflow = class extends BaseResource {
|
|
|
1459
1515
|
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
1460
1516
|
for (const chunk2 of chunks) {
|
|
1461
1517
|
if (chunk2) {
|
|
1518
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1462
1519
|
try {
|
|
1463
|
-
const parsedChunk = JSON.parse(
|
|
1520
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1464
1521
|
controller.enqueue(parsedChunk);
|
|
1465
|
-
|
|
1522
|
+
failedChunk = void 0;
|
|
1523
|
+
} catch (error) {
|
|
1524
|
+
failedChunk = newChunk;
|
|
1466
1525
|
}
|
|
1467
1526
|
}
|
|
1468
1527
|
}
|
|
@@ -1644,6 +1703,69 @@ var MCPTool = class extends BaseResource {
|
|
|
1644
1703
|
}
|
|
1645
1704
|
};
|
|
1646
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
|
+
|
|
1647
1769
|
// src/resources/vNextNetwork.ts
|
|
1648
1770
|
var RECORD_SEPARATOR3 = "";
|
|
1649
1771
|
var VNextNetwork = class extends BaseResource {
|
|
@@ -1666,7 +1788,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1666
1788
|
generate(params) {
|
|
1667
1789
|
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
1668
1790
|
method: "POST",
|
|
1669
|
-
body:
|
|
1791
|
+
body: {
|
|
1792
|
+
...params,
|
|
1793
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1794
|
+
}
|
|
1670
1795
|
});
|
|
1671
1796
|
}
|
|
1672
1797
|
/**
|
|
@@ -1677,7 +1802,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1677
1802
|
loop(params) {
|
|
1678
1803
|
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
1679
1804
|
method: "POST",
|
|
1680
|
-
body:
|
|
1805
|
+
body: {
|
|
1806
|
+
...params,
|
|
1807
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1808
|
+
}
|
|
1681
1809
|
});
|
|
1682
1810
|
}
|
|
1683
1811
|
async *streamProcessor(stream) {
|
|
@@ -1726,7 +1854,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1726
1854
|
async stream(params, onRecord) {
|
|
1727
1855
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
1728
1856
|
method: "POST",
|
|
1729
|
-
body:
|
|
1857
|
+
body: {
|
|
1858
|
+
...params,
|
|
1859
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1860
|
+
},
|
|
1730
1861
|
stream: true
|
|
1731
1862
|
});
|
|
1732
1863
|
if (!response.ok) {
|
|
@@ -1751,7 +1882,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1751
1882
|
async loopStream(params, onRecord) {
|
|
1752
1883
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
1753
1884
|
method: "POST",
|
|
1754
|
-
body:
|
|
1885
|
+
body: {
|
|
1886
|
+
...params,
|
|
1887
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1888
|
+
},
|
|
1755
1889
|
stream: true
|
|
1756
1890
|
});
|
|
1757
1891
|
if (!response.ok) {
|
|
@@ -1770,54 +1904,6 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1770
1904
|
}
|
|
1771
1905
|
};
|
|
1772
1906
|
|
|
1773
|
-
// src/resources/network-memory-thread.ts
|
|
1774
|
-
var NetworkMemoryThread = class extends BaseResource {
|
|
1775
|
-
constructor(options, threadId, networkId) {
|
|
1776
|
-
super(options);
|
|
1777
|
-
this.threadId = threadId;
|
|
1778
|
-
this.networkId = networkId;
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Retrieves the memory thread details
|
|
1782
|
-
* @returns Promise containing thread details including title and metadata
|
|
1783
|
-
*/
|
|
1784
|
-
get() {
|
|
1785
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1786
|
-
}
|
|
1787
|
-
/**
|
|
1788
|
-
* Updates the memory thread properties
|
|
1789
|
-
* @param params - Update parameters including title and metadata
|
|
1790
|
-
* @returns Promise containing updated thread details
|
|
1791
|
-
*/
|
|
1792
|
-
update(params) {
|
|
1793
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1794
|
-
method: "PATCH",
|
|
1795
|
-
body: params
|
|
1796
|
-
});
|
|
1797
|
-
}
|
|
1798
|
-
/**
|
|
1799
|
-
* Deletes the memory thread
|
|
1800
|
-
* @returns Promise containing deletion result
|
|
1801
|
-
*/
|
|
1802
|
-
delete() {
|
|
1803
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1804
|
-
method: "DELETE"
|
|
1805
|
-
});
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Retrieves messages associated with the thread
|
|
1809
|
-
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1810
|
-
* @returns Promise containing thread messages and UI messages
|
|
1811
|
-
*/
|
|
1812
|
-
getMessages(params) {
|
|
1813
|
-
const query = new URLSearchParams({
|
|
1814
|
-
networkId: this.networkId,
|
|
1815
|
-
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1816
|
-
});
|
|
1817
|
-
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1818
|
-
}
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
1907
|
// src/client.ts
|
|
1822
1908
|
var MastraClient = class extends BaseResource {
|
|
1823
1909
|
constructor(options) {
|
|
@@ -2212,6 +2298,121 @@ var MastraClient = class extends BaseResource {
|
|
|
2212
2298
|
getA2A(agentId) {
|
|
2213
2299
|
return new A2A(this.options, agentId);
|
|
2214
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
|
+
}
|
|
2215
2414
|
};
|
|
2216
2415
|
|
|
2217
2416
|
exports.MastraClient = MastraClient;
|
|
2417
|
+
//# sourceMappingURL=index.cjs.map
|
|
2418
|
+
//# sourceMappingURL=index.cjs.map
|