@mastra/client-js 1.0.0-beta.1 → 1.0.0-beta.11
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 +200 -0
- package/README.md +2 -0
- package/dist/client.d.ts +28 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +315 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +315 -32
- package/dist/index.js.map +1 -1
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/agent-builder.d.ts +2 -8
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/stored-agent.d.ts +26 -0
- package/dist/resources/stored-agent.d.ts.map +1 -0
- package/dist/resources/workflow.d.ts +78 -7
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +124 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +1 -1
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/dist/utils/zod-to-json-schema.d.ts +9 -1
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
- package/package.json +9 -11
package/dist/index.cjs
CHANGED
|
@@ -5,12 +5,7 @@ var uuid = require('@lukeed/uuid');
|
|
|
5
5
|
var error = require('@mastra/core/error');
|
|
6
6
|
var requestContext = require('@mastra/core/request-context');
|
|
7
7
|
var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
|
|
8
|
-
var
|
|
9
|
-
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
10
|
-
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var originalZodToJsonSchema__default = /*#__PURE__*/_interopDefault(originalZodToJsonSchema);
|
|
8
|
+
var zodToJson = require('@mastra/schema-compat/zod-to-json');
|
|
14
9
|
|
|
15
10
|
// src/resources/agent.ts
|
|
16
11
|
function parseClientRequestContext(requestContext$1) {
|
|
@@ -43,11 +38,7 @@ function zodToJsonSchema(zodSchema) {
|
|
|
43
38
|
if (!isZodType(zodSchema)) {
|
|
44
39
|
return zodSchema;
|
|
45
40
|
}
|
|
46
|
-
|
|
47
|
-
const fn = "toJSONSchema";
|
|
48
|
-
return zod.z[fn].call(zod.z, zodSchema);
|
|
49
|
-
}
|
|
50
|
-
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "relative" });
|
|
41
|
+
return zodToJson.zodToJsonSchema(zodSchema);
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
// src/utils/process-client-tools.ts
|
|
@@ -150,11 +141,20 @@ var BaseResource = class {
|
|
|
150
141
|
*/
|
|
151
142
|
async request(path, options = {}) {
|
|
152
143
|
let lastError = null;
|
|
153
|
-
const {
|
|
144
|
+
const {
|
|
145
|
+
baseUrl,
|
|
146
|
+
retries = 3,
|
|
147
|
+
backoffMs = 100,
|
|
148
|
+
maxBackoffMs = 1e3,
|
|
149
|
+
headers = {},
|
|
150
|
+
credentials,
|
|
151
|
+
fetch: customFetch
|
|
152
|
+
} = this.options;
|
|
153
|
+
const fetchFn = customFetch || fetch;
|
|
154
154
|
let delay = backoffMs;
|
|
155
155
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
156
156
|
try {
|
|
157
|
-
const response = await
|
|
157
|
+
const response = await fetchFn(`${baseUrl.replace(/\/$/, "")}${path}`, {
|
|
158
158
|
...options,
|
|
159
159
|
headers: {
|
|
160
160
|
...options.body && !(options.body instanceof FormData) && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
|
|
@@ -793,7 +793,7 @@ var Agent = class extends BaseResource {
|
|
|
793
793
|
case "tripwire": {
|
|
794
794
|
message.parts.push({
|
|
795
795
|
type: "text",
|
|
796
|
-
text: chunk.payload.
|
|
796
|
+
text: chunk.payload.reason
|
|
797
797
|
});
|
|
798
798
|
execUpdate();
|
|
799
799
|
break;
|
|
@@ -1458,7 +1458,7 @@ var MemoryThread = class extends BaseResource {
|
|
|
1458
1458
|
if (include) queryParams.include = JSON.stringify(include);
|
|
1459
1459
|
const query = new URLSearchParams(queryParams);
|
|
1460
1460
|
const queryString = query.toString();
|
|
1461
|
-
const url = `/api/memory/threads/${this.threadId}/messages${queryString ?
|
|
1461
|
+
const url = `/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}${queryString ? `&${queryString}` : ""}${requestContextQueryString(requestContext, "&")}`;
|
|
1462
1462
|
return this.request(url);
|
|
1463
1463
|
}
|
|
1464
1464
|
/**
|
|
@@ -1617,15 +1617,21 @@ var Workflow = class extends BaseResource {
|
|
|
1617
1617
|
if (params?.toDate) {
|
|
1618
1618
|
searchParams.set("toDate", params.toDate.toISOString());
|
|
1619
1619
|
}
|
|
1620
|
-
if (params?.
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1620
|
+
if (params?.page !== void 0) {
|
|
1621
|
+
searchParams.set("page", String(params.page));
|
|
1622
|
+
}
|
|
1623
|
+
if (params?.perPage !== void 0) {
|
|
1624
|
+
searchParams.set("perPage", String(params.perPage));
|
|
1625
|
+
}
|
|
1626
|
+
if (params?.limit !== null && params?.limit !== void 0) {
|
|
1627
|
+
if (params.limit === false) {
|
|
1628
|
+
searchParams.set("limit", "false");
|
|
1629
|
+
} else if (typeof params.limit === "number" && params.limit > 0 && Number.isInteger(params.limit)) {
|
|
1630
|
+
searchParams.set("limit", String(params.limit));
|
|
1625
1631
|
}
|
|
1626
1632
|
}
|
|
1627
|
-
if (params?.
|
|
1628
|
-
searchParams.set("
|
|
1633
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
1634
|
+
searchParams.set("offset", String(params.offset));
|
|
1629
1635
|
}
|
|
1630
1636
|
if (params?.resourceId) {
|
|
1631
1637
|
searchParams.set("resourceId", params.resourceId);
|
|
@@ -1648,6 +1654,16 @@ var Workflow = class extends BaseResource {
|
|
|
1648
1654
|
runById(runId, requestContext) {
|
|
1649
1655
|
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}${requestContextQueryString(requestContext)}`);
|
|
1650
1656
|
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Deletes a specific workflow run by its ID
|
|
1659
|
+
* @param runId - The ID of the workflow run to delete
|
|
1660
|
+
* @returns Promise containing a success message
|
|
1661
|
+
*/
|
|
1662
|
+
deleteRunById(runId) {
|
|
1663
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`, {
|
|
1664
|
+
method: "DELETE"
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1651
1667
|
/**
|
|
1652
1668
|
* Retrieves the execution result for a specific workflow run by its ID
|
|
1653
1669
|
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
@@ -1692,6 +1708,7 @@ var Workflow = class extends BaseResource {
|
|
|
1692
1708
|
return this.start({
|
|
1693
1709
|
runId,
|
|
1694
1710
|
inputData: p.inputData,
|
|
1711
|
+
initialState: p.initialState,
|
|
1695
1712
|
requestContext: p.requestContext,
|
|
1696
1713
|
tracingOptions: p.tracingOptions
|
|
1697
1714
|
});
|
|
@@ -1700,12 +1717,18 @@ var Workflow = class extends BaseResource {
|
|
|
1700
1717
|
return this.startAsync({
|
|
1701
1718
|
runId,
|
|
1702
1719
|
inputData: p.inputData,
|
|
1720
|
+
initialState: p.initialState,
|
|
1703
1721
|
requestContext: p.requestContext,
|
|
1704
1722
|
tracingOptions: p.tracingOptions
|
|
1705
1723
|
});
|
|
1706
1724
|
},
|
|
1707
1725
|
stream: async (p) => {
|
|
1708
|
-
return this.stream({
|
|
1726
|
+
return this.stream({
|
|
1727
|
+
runId,
|
|
1728
|
+
inputData: p.inputData,
|
|
1729
|
+
initialState: p.initialState,
|
|
1730
|
+
requestContext: p.requestContext
|
|
1731
|
+
});
|
|
1709
1732
|
},
|
|
1710
1733
|
resume: async (p) => {
|
|
1711
1734
|
return this.resume({
|
|
@@ -1737,14 +1760,19 @@ var Workflow = class extends BaseResource {
|
|
|
1737
1760
|
}
|
|
1738
1761
|
/**
|
|
1739
1762
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1740
|
-
* @param params - Object containing the runId, inputData and requestContext
|
|
1763
|
+
* @param params - Object containing the runId, inputData, initialState and requestContext
|
|
1741
1764
|
* @returns Promise containing success message
|
|
1742
1765
|
*/
|
|
1743
1766
|
start(params) {
|
|
1744
1767
|
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1745
1768
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1746
1769
|
method: "POST",
|
|
1747
|
-
body: {
|
|
1770
|
+
body: {
|
|
1771
|
+
inputData: params?.inputData,
|
|
1772
|
+
initialState: params?.initialState,
|
|
1773
|
+
requestContext,
|
|
1774
|
+
tracingOptions: params.tracingOptions
|
|
1775
|
+
}
|
|
1748
1776
|
});
|
|
1749
1777
|
}
|
|
1750
1778
|
/**
|
|
@@ -1772,7 +1800,7 @@ var Workflow = class extends BaseResource {
|
|
|
1772
1800
|
}
|
|
1773
1801
|
/**
|
|
1774
1802
|
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
1775
|
-
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1803
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1776
1804
|
* @returns Promise containing the workflow execution results
|
|
1777
1805
|
*/
|
|
1778
1806
|
startAsync(params) {
|
|
@@ -1783,12 +1811,17 @@ var Workflow = class extends BaseResource {
|
|
|
1783
1811
|
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1784
1812
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1785
1813
|
method: "POST",
|
|
1786
|
-
body: {
|
|
1814
|
+
body: {
|
|
1815
|
+
inputData: params.inputData,
|
|
1816
|
+
initialState: params.initialState,
|
|
1817
|
+
requestContext,
|
|
1818
|
+
tracingOptions: params.tracingOptions
|
|
1819
|
+
}
|
|
1787
1820
|
});
|
|
1788
1821
|
}
|
|
1789
1822
|
/**
|
|
1790
1823
|
* Starts a workflow run and returns a stream
|
|
1791
|
-
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1824
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1792
1825
|
* @returns Promise containing the workflow execution results
|
|
1793
1826
|
*/
|
|
1794
1827
|
async stream(params) {
|
|
@@ -1801,7 +1834,12 @@ var Workflow = class extends BaseResource {
|
|
|
1801
1834
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1802
1835
|
{
|
|
1803
1836
|
method: "POST",
|
|
1804
|
-
body: {
|
|
1837
|
+
body: {
|
|
1838
|
+
inputData: params.inputData,
|
|
1839
|
+
initialState: params.initialState,
|
|
1840
|
+
requestContext,
|
|
1841
|
+
tracingOptions: params.tracingOptions
|
|
1842
|
+
},
|
|
1805
1843
|
stream: true
|
|
1806
1844
|
}
|
|
1807
1845
|
);
|
|
@@ -1886,7 +1924,7 @@ var Workflow = class extends BaseResource {
|
|
|
1886
1924
|
}
|
|
1887
1925
|
/**
|
|
1888
1926
|
* Starts a workflow run and returns a stream
|
|
1889
|
-
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1927
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1890
1928
|
* @returns Promise containing the workflow execution results
|
|
1891
1929
|
*/
|
|
1892
1930
|
async streamVNext(params) {
|
|
@@ -1901,6 +1939,7 @@ var Workflow = class extends BaseResource {
|
|
|
1901
1939
|
method: "POST",
|
|
1902
1940
|
body: {
|
|
1903
1941
|
inputData: params.inputData,
|
|
1942
|
+
initialState: params.initialState,
|
|
1904
1943
|
requestContext,
|
|
1905
1944
|
closeOnSuspend: params.closeOnSuspend,
|
|
1906
1945
|
tracingOptions: params.tracingOptions
|
|
@@ -2081,6 +2120,142 @@ var Workflow = class extends BaseResource {
|
|
|
2081
2120
|
}
|
|
2082
2121
|
});
|
|
2083
2122
|
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Restarts an active workflow run synchronously without waiting for the workflow to complete
|
|
2125
|
+
* @param params - Object containing the runId and requestContext
|
|
2126
|
+
* @returns Promise containing success message
|
|
2127
|
+
*/
|
|
2128
|
+
restart(params) {
|
|
2129
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2130
|
+
return this.request(`/api/workflows/${this.workflowId}/restart?runId=${params.runId}`, {
|
|
2131
|
+
method: "POST",
|
|
2132
|
+
body: {
|
|
2133
|
+
requestContext,
|
|
2134
|
+
tracingOptions: params.tracingOptions
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
/**
|
|
2139
|
+
* Restarts an active workflow run asynchronously
|
|
2140
|
+
* @param params - Object containing the runId and requestContext
|
|
2141
|
+
* @returns Promise containing the workflow restart results
|
|
2142
|
+
*/
|
|
2143
|
+
restartAsync(params) {
|
|
2144
|
+
const requestContext = parseClientRequestContext(params.requestContext);
|
|
2145
|
+
return this.request(`/api/workflows/${this.workflowId}/restart-async?runId=${params.runId}`, {
|
|
2146
|
+
method: "POST",
|
|
2147
|
+
body: {
|
|
2148
|
+
requestContext,
|
|
2149
|
+
tracingOptions: params.tracingOptions
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Restart all active workflow runs synchronously without waiting for the workflow to complete
|
|
2155
|
+
* @returns Promise containing success message
|
|
2156
|
+
*/
|
|
2157
|
+
restartAllActiveWorkflowRuns() {
|
|
2158
|
+
return this.request(`/api/workflows/${this.workflowId}/restart-all-active-workflow-runs`, {
|
|
2159
|
+
method: "POST"
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
/**
|
|
2163
|
+
* Restart all active workflow runs asynchronously
|
|
2164
|
+
* @returns Promise containing success message
|
|
2165
|
+
*/
|
|
2166
|
+
restartAllActiveWorkflowRunsAsync() {
|
|
2167
|
+
return this.request(`/api/workflows/${this.workflowId}/restart-all-active-workflow-runs-async`, {
|
|
2168
|
+
method: "POST"
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Time travels a workflow run synchronously without waiting for the workflow to complete
|
|
2173
|
+
* @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
|
|
2174
|
+
* @returns Promise containing success message
|
|
2175
|
+
*/
|
|
2176
|
+
timeTravel({
|
|
2177
|
+
runId,
|
|
2178
|
+
requestContext: paramsRequestContext,
|
|
2179
|
+
...params
|
|
2180
|
+
}) {
|
|
2181
|
+
const requestContext = parseClientRequestContext(paramsRequestContext);
|
|
2182
|
+
return this.request(`/api/workflows/${this.workflowId}/time-travel?runId=${runId}`, {
|
|
2183
|
+
method: "POST",
|
|
2184
|
+
body: {
|
|
2185
|
+
...params,
|
|
2186
|
+
requestContext
|
|
2187
|
+
}
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Time travels a workflow run asynchronously
|
|
2192
|
+
* @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
|
|
2193
|
+
* @returns Promise containing the workflow time travel results
|
|
2194
|
+
*/
|
|
2195
|
+
timeTravelAsync({
|
|
2196
|
+
runId,
|
|
2197
|
+
requestContext: paramsRequestContext,
|
|
2198
|
+
...params
|
|
2199
|
+
}) {
|
|
2200
|
+
const requestContext = parseClientRequestContext(paramsRequestContext);
|
|
2201
|
+
return this.request(`/api/workflows/${this.workflowId}/time-travel-async?runId=${runId}`, {
|
|
2202
|
+
method: "POST",
|
|
2203
|
+
body: {
|
|
2204
|
+
...params,
|
|
2205
|
+
requestContext
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Time travels a workflow run and returns a stream
|
|
2211
|
+
* @param params - Object containing the runId, step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
|
|
2212
|
+
* @returns Promise containing the workflow execution results
|
|
2213
|
+
*/
|
|
2214
|
+
async timeTravelStream({ runId, requestContext: paramsRequestContext, ...params }) {
|
|
2215
|
+
const requestContext = parseClientRequestContext(paramsRequestContext);
|
|
2216
|
+
const response = await this.request(
|
|
2217
|
+
`/api/workflows/${this.workflowId}/time-travel-stream?runId=${runId}`,
|
|
2218
|
+
{
|
|
2219
|
+
method: "POST",
|
|
2220
|
+
body: {
|
|
2221
|
+
...params,
|
|
2222
|
+
requestContext
|
|
2223
|
+
},
|
|
2224
|
+
stream: true
|
|
2225
|
+
}
|
|
2226
|
+
);
|
|
2227
|
+
if (!response.ok) {
|
|
2228
|
+
throw new Error(`Failed to time travel workflow: ${response.statusText}`);
|
|
2229
|
+
}
|
|
2230
|
+
if (!response.body) {
|
|
2231
|
+
throw new Error("Response body is null");
|
|
2232
|
+
}
|
|
2233
|
+
let failedChunk = void 0;
|
|
2234
|
+
const transformStream = new TransformStream({
|
|
2235
|
+
start() {
|
|
2236
|
+
},
|
|
2237
|
+
async transform(chunk, controller) {
|
|
2238
|
+
try {
|
|
2239
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2240
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2241
|
+
for (const chunk2 of chunks) {
|
|
2242
|
+
if (chunk2) {
|
|
2243
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2244
|
+
try {
|
|
2245
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2246
|
+
controller.enqueue(parsedChunk);
|
|
2247
|
+
failedChunk = void 0;
|
|
2248
|
+
} catch {
|
|
2249
|
+
failedChunk = newChunk;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
} catch {
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
});
|
|
2257
|
+
return response.body.pipeThrough(transformStream);
|
|
2258
|
+
}
|
|
2084
2259
|
};
|
|
2085
2260
|
|
|
2086
2261
|
// src/resources/a2a.ts
|
|
@@ -2123,7 +2298,8 @@ var A2A = class extends BaseResource {
|
|
|
2123
2298
|
body: {
|
|
2124
2299
|
method: "message/stream",
|
|
2125
2300
|
params
|
|
2126
|
-
}
|
|
2301
|
+
},
|
|
2302
|
+
stream: true
|
|
2127
2303
|
});
|
|
2128
2304
|
return response;
|
|
2129
2305
|
}
|
|
@@ -2554,6 +2730,16 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2554
2730
|
if (params?.page !== void 0) {
|
|
2555
2731
|
searchParams.set("page", String(params.page));
|
|
2556
2732
|
}
|
|
2733
|
+
if (params?.limit !== null && params?.limit !== void 0) {
|
|
2734
|
+
if (params.limit === false) {
|
|
2735
|
+
searchParams.set("limit", "false");
|
|
2736
|
+
} else if (typeof params.limit === "number" && params.limit > 0 && Number.isInteger(params.limit)) {
|
|
2737
|
+
searchParams.set("limit", String(params.limit));
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
2741
|
+
searchParams.set("offset", String(params.offset));
|
|
2742
|
+
}
|
|
2557
2743
|
if (params?.resourceId) {
|
|
2558
2744
|
searchParams.set("resourceId", params.resourceId);
|
|
2559
2745
|
}
|
|
@@ -2660,6 +2846,41 @@ var Observability = class extends BaseResource {
|
|
|
2660
2846
|
}
|
|
2661
2847
|
};
|
|
2662
2848
|
|
|
2849
|
+
// src/resources/stored-agent.ts
|
|
2850
|
+
var StoredAgent = class extends BaseResource {
|
|
2851
|
+
constructor(options, storedAgentId) {
|
|
2852
|
+
super(options);
|
|
2853
|
+
this.storedAgentId = storedAgentId;
|
|
2854
|
+
}
|
|
2855
|
+
/**
|
|
2856
|
+
* Retrieves details about the stored agent
|
|
2857
|
+
* @returns Promise containing stored agent details
|
|
2858
|
+
*/
|
|
2859
|
+
details() {
|
|
2860
|
+
return this.request(`/api/stored/agents/${encodeURIComponent(this.storedAgentId)}`);
|
|
2861
|
+
}
|
|
2862
|
+
/**
|
|
2863
|
+
* Updates the stored agent with the provided fields
|
|
2864
|
+
* @param params - Fields to update
|
|
2865
|
+
* @returns Promise containing the updated stored agent
|
|
2866
|
+
*/
|
|
2867
|
+
update(params) {
|
|
2868
|
+
return this.request(`/api/stored/agents/${encodeURIComponent(this.storedAgentId)}`, {
|
|
2869
|
+
method: "PATCH",
|
|
2870
|
+
body: params
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Deletes the stored agent
|
|
2875
|
+
* @returns Promise containing deletion confirmation
|
|
2876
|
+
*/
|
|
2877
|
+
delete() {
|
|
2878
|
+
return this.request(`/api/stored/agents/${encodeURIComponent(this.storedAgentId)}`, {
|
|
2879
|
+
method: "DELETE"
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2883
|
+
|
|
2663
2884
|
// src/client.ts
|
|
2664
2885
|
var MastraClient = class extends BaseResource {
|
|
2665
2886
|
observability;
|
|
@@ -2672,12 +2893,15 @@ var MastraClient = class extends BaseResource {
|
|
|
2672
2893
|
* @param requestContext - Optional request context to pass as query parameter
|
|
2673
2894
|
* @returns Promise containing map of agent IDs to agent details
|
|
2674
2895
|
*/
|
|
2675
|
-
listAgents(requestContext) {
|
|
2896
|
+
listAgents(requestContext, partial) {
|
|
2676
2897
|
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
2677
2898
|
const searchParams = new URLSearchParams();
|
|
2678
2899
|
if (requestContextParam) {
|
|
2679
2900
|
searchParams.set("requestContext", requestContextParam);
|
|
2680
2901
|
}
|
|
2902
|
+
if (partial) {
|
|
2903
|
+
searchParams.set("partial", "true");
|
|
2904
|
+
}
|
|
2681
2905
|
const queryString = searchParams.toString();
|
|
2682
2906
|
return this.request(`/api/agents${queryString ? `?${queryString}` : ""}`);
|
|
2683
2907
|
}
|
|
@@ -2819,12 +3043,15 @@ var MastraClient = class extends BaseResource {
|
|
|
2819
3043
|
* @param requestContext - Optional request context to pass as query parameter
|
|
2820
3044
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
2821
3045
|
*/
|
|
2822
|
-
listWorkflows(requestContext) {
|
|
3046
|
+
listWorkflows(requestContext, partial) {
|
|
2823
3047
|
const requestContextParam = base64RequestContext(parseClientRequestContext(requestContext));
|
|
2824
3048
|
const searchParams = new URLSearchParams();
|
|
2825
3049
|
if (requestContextParam) {
|
|
2826
3050
|
searchParams.set("requestContext", requestContextParam);
|
|
2827
3051
|
}
|
|
3052
|
+
if (partial) {
|
|
3053
|
+
searchParams.set("partial", "true");
|
|
3054
|
+
}
|
|
2828
3055
|
const queryString = searchParams.toString();
|
|
2829
3056
|
return this.request(`/api/workflows${queryString ? `?${queryString}` : ""}`);
|
|
2830
3057
|
}
|
|
@@ -2954,16 +3181,22 @@ var MastraClient = class extends BaseResource {
|
|
|
2954
3181
|
}
|
|
2955
3182
|
/**
|
|
2956
3183
|
* Retrieves a list of available MCP servers.
|
|
2957
|
-
* @param params - Optional parameters for pagination (perPage,
|
|
3184
|
+
* @param params - Optional parameters for pagination (page, perPage, or deprecated offset, limit).
|
|
2958
3185
|
* @returns Promise containing the list of MCP servers and pagination info.
|
|
2959
3186
|
*/
|
|
2960
3187
|
getMcpServers(params) {
|
|
2961
3188
|
const searchParams = new URLSearchParams();
|
|
3189
|
+
if (params?.page !== void 0) {
|
|
3190
|
+
searchParams.set("page", String(params.page));
|
|
3191
|
+
}
|
|
2962
3192
|
if (params?.perPage !== void 0) {
|
|
2963
3193
|
searchParams.set("perPage", String(params.perPage));
|
|
2964
3194
|
}
|
|
2965
|
-
if (params?.
|
|
2966
|
-
searchParams.set("
|
|
3195
|
+
if (params?.limit !== void 0) {
|
|
3196
|
+
searchParams.set("limit", String(params.limit));
|
|
3197
|
+
}
|
|
3198
|
+
if (params?.offset !== void 0) {
|
|
3199
|
+
searchParams.set("offset", String(params.offset));
|
|
2967
3200
|
}
|
|
2968
3201
|
const queryString = searchParams.toString();
|
|
2969
3202
|
return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ""}`);
|
|
@@ -3163,6 +3396,52 @@ var MastraClient = class extends BaseResource {
|
|
|
3163
3396
|
score(params) {
|
|
3164
3397
|
return this.observability.score(params);
|
|
3165
3398
|
}
|
|
3399
|
+
// ============================================================================
|
|
3400
|
+
// Stored Agents
|
|
3401
|
+
// ============================================================================
|
|
3402
|
+
/**
|
|
3403
|
+
* Lists all stored agents with optional pagination
|
|
3404
|
+
* @param params - Optional pagination and ordering parameters
|
|
3405
|
+
* @returns Promise containing paginated list of stored agents
|
|
3406
|
+
*/
|
|
3407
|
+
listStoredAgents(params) {
|
|
3408
|
+
const searchParams = new URLSearchParams();
|
|
3409
|
+
if (params?.page !== void 0) {
|
|
3410
|
+
searchParams.set("page", String(params.page));
|
|
3411
|
+
}
|
|
3412
|
+
if (params?.perPage !== void 0) {
|
|
3413
|
+
searchParams.set("perPage", String(params.perPage));
|
|
3414
|
+
}
|
|
3415
|
+
if (params?.orderBy) {
|
|
3416
|
+
if (params.orderBy.field) {
|
|
3417
|
+
searchParams.set("orderBy[field]", params.orderBy.field);
|
|
3418
|
+
}
|
|
3419
|
+
if (params.orderBy.direction) {
|
|
3420
|
+
searchParams.set("orderBy[direction]", params.orderBy.direction);
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
const queryString = searchParams.toString();
|
|
3424
|
+
return this.request(`/api/stored/agents${queryString ? `?${queryString}` : ""}`);
|
|
3425
|
+
}
|
|
3426
|
+
/**
|
|
3427
|
+
* Creates a new stored agent
|
|
3428
|
+
* @param params - Agent configuration including id, name, instructions, model, etc.
|
|
3429
|
+
* @returns Promise containing the created stored agent
|
|
3430
|
+
*/
|
|
3431
|
+
createStoredAgent(params) {
|
|
3432
|
+
return this.request("/api/stored/agents", {
|
|
3433
|
+
method: "POST",
|
|
3434
|
+
body: params
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3437
|
+
/**
|
|
3438
|
+
* Gets a stored agent instance by ID for further operations (details, update, delete)
|
|
3439
|
+
* @param storedAgentId - ID of the stored agent to retrieve
|
|
3440
|
+
* @returns StoredAgent instance
|
|
3441
|
+
*/
|
|
3442
|
+
getStoredAgent(storedAgentId) {
|
|
3443
|
+
return new StoredAgent(this.options, storedAgentId);
|
|
3444
|
+
}
|
|
3166
3445
|
};
|
|
3167
3446
|
|
|
3168
3447
|
// src/tools.ts
|