@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { processDataStream, parsePartialJson } from '@ai-sdk/ui-utils';
|
|
4
4
|
import { ZodSchema } from 'zod';
|
|
5
5
|
import originalZodToJsonSchema from 'zod-to-json-schema';
|
|
6
|
-
import { isVercelTool } from '@mastra/core/tools';
|
|
6
|
+
import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
|
|
7
|
+
import { v4 } from '@lukeed/uuid';
|
|
7
8
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
8
9
|
|
|
9
10
|
// src/adapters/agui.ts
|
|
@@ -246,12 +247,13 @@ var BaseResource = class {
|
|
|
246
247
|
const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
|
|
247
248
|
...options,
|
|
248
249
|
headers: {
|
|
249
|
-
...options.method === "POST" || options.method === "PUT" ? { "content-type": "application/json" } : {},
|
|
250
|
+
...options.body && !(options.body instanceof FormData) && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
|
|
250
251
|
...headers,
|
|
251
252
|
...options.headers
|
|
252
253
|
// TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
|
|
253
254
|
// 'x-mastra-client-type': 'js',
|
|
254
255
|
},
|
|
256
|
+
signal: this.options.abortSignal,
|
|
255
257
|
body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
|
|
256
258
|
});
|
|
257
259
|
if (!response.ok) {
|
|
@@ -370,12 +372,19 @@ var Agent = class extends BaseResource {
|
|
|
370
372
|
clientTools: processClientTools(params.clientTools)
|
|
371
373
|
};
|
|
372
374
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
373
|
-
const response = await this.request(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
375
|
+
const response = await this.request(
|
|
376
|
+
`/api/agents/${this.agentId}/generate`,
|
|
377
|
+
{
|
|
378
|
+
method: "POST",
|
|
379
|
+
body: processedParams
|
|
380
|
+
}
|
|
381
|
+
);
|
|
377
382
|
if (response.finishReason === "tool-calls") {
|
|
378
|
-
|
|
383
|
+
const toolCalls = response.toolCalls;
|
|
384
|
+
if (!toolCalls || !Array.isArray(toolCalls)) {
|
|
385
|
+
return response;
|
|
386
|
+
}
|
|
387
|
+
for (const toolCall of toolCalls) {
|
|
379
388
|
const clientTool = params.clientTools?.[toolCall.toolName];
|
|
380
389
|
if (clientTool && clientTool.execute) {
|
|
381
390
|
const result = await clientTool.execute(
|
|
@@ -426,7 +435,7 @@ var Agent = class extends BaseResource {
|
|
|
426
435
|
return Math.max(max, toolInvocation.step ?? 0);
|
|
427
436
|
}, 0) ?? 0) : 0;
|
|
428
437
|
const message = replaceLastMessage ? structuredClone(lastMessage) : {
|
|
429
|
-
id:
|
|
438
|
+
id: v4(),
|
|
430
439
|
createdAt: getCurrentDate(),
|
|
431
440
|
role: "assistant",
|
|
432
441
|
content: "",
|
|
@@ -471,7 +480,7 @@ var Agent = class extends BaseResource {
|
|
|
471
480
|
// changes. This is why we need to add a revision id to ensure that the message
|
|
472
481
|
// is updated with SWR (without it, the changes get stuck in SWR and are not
|
|
473
482
|
// forwarded to rendering):
|
|
474
|
-
revisionId:
|
|
483
|
+
revisionId: v4()
|
|
475
484
|
};
|
|
476
485
|
update({
|
|
477
486
|
message: copiedMessage,
|
|
@@ -726,7 +735,12 @@ var Agent = class extends BaseResource {
|
|
|
726
735
|
this.processChatResponse({
|
|
727
736
|
stream: streamForProcessing,
|
|
728
737
|
update: ({ message }) => {
|
|
729
|
-
messages.
|
|
738
|
+
const existingIndex = messages.findIndex((m) => m.id === message.id);
|
|
739
|
+
if (existingIndex !== -1) {
|
|
740
|
+
messages[existingIndex] = message;
|
|
741
|
+
} else {
|
|
742
|
+
messages.push(message);
|
|
743
|
+
}
|
|
730
744
|
},
|
|
731
745
|
onFinish: async ({ finishReason, message }) => {
|
|
732
746
|
if (finishReason === "tool-calls") {
|
|
@@ -786,10 +800,12 @@ var Agent = class extends BaseResource {
|
|
|
786
800
|
this.processStreamResponse(
|
|
787
801
|
{
|
|
788
802
|
...processedParams,
|
|
789
|
-
messages: [...messageArray, ...messages, lastMessage]
|
|
803
|
+
messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
790
804
|
},
|
|
791
805
|
writable
|
|
792
|
-
)
|
|
806
|
+
).catch((error) => {
|
|
807
|
+
console.error("Error processing stream response:", error);
|
|
808
|
+
});
|
|
793
809
|
}
|
|
794
810
|
}
|
|
795
811
|
} else {
|
|
@@ -799,6 +815,8 @@ var Agent = class extends BaseResource {
|
|
|
799
815
|
}
|
|
800
816
|
},
|
|
801
817
|
lastMessage: void 0
|
|
818
|
+
}).catch((error) => {
|
|
819
|
+
console.error("Error processing stream response:", error);
|
|
802
820
|
});
|
|
803
821
|
} catch (error) {
|
|
804
822
|
console.error("Error processing stream response:", error);
|
|
@@ -947,6 +965,36 @@ var MemoryThread = class extends BaseResource {
|
|
|
947
965
|
});
|
|
948
966
|
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
949
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* Retrieves paginated messages associated with the thread with advanced filtering and selection options
|
|
970
|
+
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
|
|
971
|
+
* @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
|
|
972
|
+
*/
|
|
973
|
+
getMessagesPaginated({
|
|
974
|
+
selectBy,
|
|
975
|
+
...rest
|
|
976
|
+
}) {
|
|
977
|
+
const query = new URLSearchParams({
|
|
978
|
+
...rest,
|
|
979
|
+
...selectBy ? { selectBy: JSON.stringify(selectBy) } : {}
|
|
980
|
+
});
|
|
981
|
+
return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Deletes one or more messages from the thread
|
|
985
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
986
|
+
* message object with id property, or array of message objects
|
|
987
|
+
* @returns Promise containing deletion result
|
|
988
|
+
*/
|
|
989
|
+
deleteMessages(messageIds) {
|
|
990
|
+
const query = new URLSearchParams({
|
|
991
|
+
agentId: this.agentId
|
|
992
|
+
});
|
|
993
|
+
return this.request(`/api/memory/messages/delete?${query.toString()}`, {
|
|
994
|
+
method: "POST",
|
|
995
|
+
body: { messageIds }
|
|
996
|
+
});
|
|
997
|
+
}
|
|
950
998
|
};
|
|
951
999
|
|
|
952
1000
|
// src/resources/vector.ts
|
|
@@ -1368,6 +1416,14 @@ var Workflow = class extends BaseResource {
|
|
|
1368
1416
|
method: "POST"
|
|
1369
1417
|
});
|
|
1370
1418
|
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Creates a new workflow run (alias for createRun)
|
|
1421
|
+
* @param params - Optional object containing the optional runId
|
|
1422
|
+
* @returns Promise containing the runId of the created run
|
|
1423
|
+
*/
|
|
1424
|
+
createRunAsync(params) {
|
|
1425
|
+
return this.createRun(params);
|
|
1426
|
+
}
|
|
1371
1427
|
/**
|
|
1372
1428
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1373
1429
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -1443,6 +1499,7 @@ var Workflow = class extends BaseResource {
|
|
|
1443
1499
|
if (!response.body) {
|
|
1444
1500
|
throw new Error("Response body is null");
|
|
1445
1501
|
}
|
|
1502
|
+
let failedChunk = void 0;
|
|
1446
1503
|
const transformStream = new TransformStream({
|
|
1447
1504
|
start() {
|
|
1448
1505
|
},
|
|
@@ -1452,10 +1509,13 @@ var Workflow = class extends BaseResource {
|
|
|
1452
1509
|
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
1453
1510
|
for (const chunk2 of chunks) {
|
|
1454
1511
|
if (chunk2) {
|
|
1512
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1455
1513
|
try {
|
|
1456
|
-
const parsedChunk = JSON.parse(
|
|
1514
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1457
1515
|
controller.enqueue(parsedChunk);
|
|
1458
|
-
|
|
1516
|
+
failedChunk = void 0;
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
failedChunk = newChunk;
|
|
1459
1519
|
}
|
|
1460
1520
|
}
|
|
1461
1521
|
}
|
|
@@ -1637,6 +1697,69 @@ var MCPTool = class extends BaseResource {
|
|
|
1637
1697
|
}
|
|
1638
1698
|
};
|
|
1639
1699
|
|
|
1700
|
+
// src/resources/network-memory-thread.ts
|
|
1701
|
+
var NetworkMemoryThread = class extends BaseResource {
|
|
1702
|
+
constructor(options, threadId, networkId) {
|
|
1703
|
+
super(options);
|
|
1704
|
+
this.threadId = threadId;
|
|
1705
|
+
this.networkId = networkId;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Retrieves the memory thread details
|
|
1709
|
+
* @returns Promise containing thread details including title and metadata
|
|
1710
|
+
*/
|
|
1711
|
+
get() {
|
|
1712
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Updates the memory thread properties
|
|
1716
|
+
* @param params - Update parameters including title and metadata
|
|
1717
|
+
* @returns Promise containing updated thread details
|
|
1718
|
+
*/
|
|
1719
|
+
update(params) {
|
|
1720
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1721
|
+
method: "PATCH",
|
|
1722
|
+
body: params
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Deletes the memory thread
|
|
1727
|
+
* @returns Promise containing deletion result
|
|
1728
|
+
*/
|
|
1729
|
+
delete() {
|
|
1730
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1731
|
+
method: "DELETE"
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Retrieves messages associated with the thread
|
|
1736
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1737
|
+
* @returns Promise containing thread messages and UI messages
|
|
1738
|
+
*/
|
|
1739
|
+
getMessages(params) {
|
|
1740
|
+
const query = new URLSearchParams({
|
|
1741
|
+
networkId: this.networkId,
|
|
1742
|
+
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1743
|
+
});
|
|
1744
|
+
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Deletes one or more messages from the thread
|
|
1748
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
1749
|
+
* message object with id property, or array of message objects
|
|
1750
|
+
* @returns Promise containing deletion result
|
|
1751
|
+
*/
|
|
1752
|
+
deleteMessages(messageIds) {
|
|
1753
|
+
const query = new URLSearchParams({
|
|
1754
|
+
networkId: this.networkId
|
|
1755
|
+
});
|
|
1756
|
+
return this.request(`/api/memory/network/messages/delete?${query.toString()}`, {
|
|
1757
|
+
method: "POST",
|
|
1758
|
+
body: { messageIds }
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1640
1763
|
// src/resources/vNextNetwork.ts
|
|
1641
1764
|
var RECORD_SEPARATOR3 = "";
|
|
1642
1765
|
var VNextNetwork = class extends BaseResource {
|
|
@@ -1659,7 +1782,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1659
1782
|
generate(params) {
|
|
1660
1783
|
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
1661
1784
|
method: "POST",
|
|
1662
|
-
body:
|
|
1785
|
+
body: {
|
|
1786
|
+
...params,
|
|
1787
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1788
|
+
}
|
|
1663
1789
|
});
|
|
1664
1790
|
}
|
|
1665
1791
|
/**
|
|
@@ -1670,7 +1796,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1670
1796
|
loop(params) {
|
|
1671
1797
|
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
1672
1798
|
method: "POST",
|
|
1673
|
-
body:
|
|
1799
|
+
body: {
|
|
1800
|
+
...params,
|
|
1801
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1802
|
+
}
|
|
1674
1803
|
});
|
|
1675
1804
|
}
|
|
1676
1805
|
async *streamProcessor(stream) {
|
|
@@ -1719,7 +1848,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1719
1848
|
async stream(params, onRecord) {
|
|
1720
1849
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
1721
1850
|
method: "POST",
|
|
1722
|
-
body:
|
|
1851
|
+
body: {
|
|
1852
|
+
...params,
|
|
1853
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1854
|
+
},
|
|
1723
1855
|
stream: true
|
|
1724
1856
|
});
|
|
1725
1857
|
if (!response.ok) {
|
|
@@ -1744,7 +1876,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1744
1876
|
async loopStream(params, onRecord) {
|
|
1745
1877
|
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
1746
1878
|
method: "POST",
|
|
1747
|
-
body:
|
|
1879
|
+
body: {
|
|
1880
|
+
...params,
|
|
1881
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1882
|
+
},
|
|
1748
1883
|
stream: true
|
|
1749
1884
|
});
|
|
1750
1885
|
if (!response.ok) {
|
|
@@ -1763,54 +1898,6 @@ var VNextNetwork = class extends BaseResource {
|
|
|
1763
1898
|
}
|
|
1764
1899
|
};
|
|
1765
1900
|
|
|
1766
|
-
// src/resources/network-memory-thread.ts
|
|
1767
|
-
var NetworkMemoryThread = class extends BaseResource {
|
|
1768
|
-
constructor(options, threadId, networkId) {
|
|
1769
|
-
super(options);
|
|
1770
|
-
this.threadId = threadId;
|
|
1771
|
-
this.networkId = networkId;
|
|
1772
|
-
}
|
|
1773
|
-
/**
|
|
1774
|
-
* Retrieves the memory thread details
|
|
1775
|
-
* @returns Promise containing thread details including title and metadata
|
|
1776
|
-
*/
|
|
1777
|
-
get() {
|
|
1778
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Updates the memory thread properties
|
|
1782
|
-
* @param params - Update parameters including title and metadata
|
|
1783
|
-
* @returns Promise containing updated thread details
|
|
1784
|
-
*/
|
|
1785
|
-
update(params) {
|
|
1786
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1787
|
-
method: "PATCH",
|
|
1788
|
-
body: params
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
/**
|
|
1792
|
-
* Deletes the memory thread
|
|
1793
|
-
* @returns Promise containing deletion result
|
|
1794
|
-
*/
|
|
1795
|
-
delete() {
|
|
1796
|
-
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1797
|
-
method: "DELETE"
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
/**
|
|
1801
|
-
* Retrieves messages associated with the thread
|
|
1802
|
-
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1803
|
-
* @returns Promise containing thread messages and UI messages
|
|
1804
|
-
*/
|
|
1805
|
-
getMessages(params) {
|
|
1806
|
-
const query = new URLSearchParams({
|
|
1807
|
-
networkId: this.networkId,
|
|
1808
|
-
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1809
|
-
});
|
|
1810
|
-
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1811
|
-
}
|
|
1812
|
-
};
|
|
1813
|
-
|
|
1814
1901
|
// src/client.ts
|
|
1815
1902
|
var MastraClient = class extends BaseResource {
|
|
1816
1903
|
constructor(options) {
|
|
@@ -2205,6 +2292,121 @@ var MastraClient = class extends BaseResource {
|
|
|
2205
2292
|
getA2A(agentId) {
|
|
2206
2293
|
return new A2A(this.options, agentId);
|
|
2207
2294
|
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Retrieves the working memory for a specific thread (optionally resource-scoped).
|
|
2297
|
+
* @param agentId - ID of the agent.
|
|
2298
|
+
* @param threadId - ID of the thread.
|
|
2299
|
+
* @param resourceId - Optional ID of the resource.
|
|
2300
|
+
* @returns Working memory for the specified thread or resource.
|
|
2301
|
+
*/
|
|
2302
|
+
getWorkingMemory({
|
|
2303
|
+
agentId,
|
|
2304
|
+
threadId,
|
|
2305
|
+
resourceId
|
|
2306
|
+
}) {
|
|
2307
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Updates the working memory for a specific thread (optionally resource-scoped).
|
|
2311
|
+
* @param agentId - ID of the agent.
|
|
2312
|
+
* @param threadId - ID of the thread.
|
|
2313
|
+
* @param workingMemory - The new working memory content.
|
|
2314
|
+
* @param resourceId - Optional ID of the resource.
|
|
2315
|
+
*/
|
|
2316
|
+
updateWorkingMemory({
|
|
2317
|
+
agentId,
|
|
2318
|
+
threadId,
|
|
2319
|
+
workingMemory,
|
|
2320
|
+
resourceId
|
|
2321
|
+
}) {
|
|
2322
|
+
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
|
|
2323
|
+
method: "POST",
|
|
2324
|
+
body: {
|
|
2325
|
+
workingMemory,
|
|
2326
|
+
resourceId
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Retrieves all available scorers
|
|
2332
|
+
* @returns Promise containing list of available scorers
|
|
2333
|
+
*/
|
|
2334
|
+
getScorers() {
|
|
2335
|
+
return this.request("/api/scores/scorers");
|
|
2336
|
+
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Retrieves a scorer by ID
|
|
2339
|
+
* @param scorerId - ID of the scorer to retrieve
|
|
2340
|
+
* @returns Promise containing the scorer
|
|
2341
|
+
*/
|
|
2342
|
+
getScorer(scorerId) {
|
|
2343
|
+
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
2344
|
+
}
|
|
2345
|
+
getScoresByScorerId(params) {
|
|
2346
|
+
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
2347
|
+
const searchParams = new URLSearchParams();
|
|
2348
|
+
if (entityId) {
|
|
2349
|
+
searchParams.set("entityId", entityId);
|
|
2350
|
+
}
|
|
2351
|
+
if (entityType) {
|
|
2352
|
+
searchParams.set("entityType", entityType);
|
|
2353
|
+
}
|
|
2354
|
+
if (page !== void 0) {
|
|
2355
|
+
searchParams.set("page", String(page));
|
|
2356
|
+
}
|
|
2357
|
+
if (perPage !== void 0) {
|
|
2358
|
+
searchParams.set("perPage", String(perPage));
|
|
2359
|
+
}
|
|
2360
|
+
const queryString = searchParams.toString();
|
|
2361
|
+
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
2362
|
+
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Retrieves scores by run ID
|
|
2365
|
+
* @param params - Parameters containing run ID and pagination options
|
|
2366
|
+
* @returns Promise containing scores and pagination info
|
|
2367
|
+
*/
|
|
2368
|
+
getScoresByRunId(params) {
|
|
2369
|
+
const { runId, page, perPage } = params;
|
|
2370
|
+
const searchParams = new URLSearchParams();
|
|
2371
|
+
if (page !== void 0) {
|
|
2372
|
+
searchParams.set("page", String(page));
|
|
2373
|
+
}
|
|
2374
|
+
if (perPage !== void 0) {
|
|
2375
|
+
searchParams.set("perPage", String(perPage));
|
|
2376
|
+
}
|
|
2377
|
+
const queryString = searchParams.toString();
|
|
2378
|
+
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Retrieves scores by entity ID and type
|
|
2382
|
+
* @param params - Parameters containing entity ID, type, and pagination options
|
|
2383
|
+
* @returns Promise containing scores and pagination info
|
|
2384
|
+
*/
|
|
2385
|
+
getScoresByEntityId(params) {
|
|
2386
|
+
const { entityId, entityType, page, perPage } = params;
|
|
2387
|
+
const searchParams = new URLSearchParams();
|
|
2388
|
+
if (page !== void 0) {
|
|
2389
|
+
searchParams.set("page", String(page));
|
|
2390
|
+
}
|
|
2391
|
+
if (perPage !== void 0) {
|
|
2392
|
+
searchParams.set("perPage", String(perPage));
|
|
2393
|
+
}
|
|
2394
|
+
const queryString = searchParams.toString();
|
|
2395
|
+
return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Saves a score
|
|
2399
|
+
* @param params - Parameters containing the score data to save
|
|
2400
|
+
* @returns Promise containing the saved score
|
|
2401
|
+
*/
|
|
2402
|
+
saveScore(params) {
|
|
2403
|
+
return this.request("/api/scores", {
|
|
2404
|
+
method: "POST",
|
|
2405
|
+
body: params
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2208
2408
|
};
|
|
2209
2409
|
|
|
2210
2410
|
export { MastraClient };
|
|
2411
|
+
//# sourceMappingURL=index.js.map
|
|
2412
|
+
//# sourceMappingURL=index.js.map
|