@mastra/client-js 1.0.0-beta.5 → 1.0.0-beta.6
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 +52 -0
- package/README.md +2 -0
- package/dist/index.cjs +53 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -25
- package/dist/index.js.map +1 -1
- package/dist/resources/a2a.d.ts.map +1 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +11 -4
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +6 -2
- 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 +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add support for custom fetch function in MastraClient to enable environments like Tauri that require custom fetch implementations to avoid timeout errors. ([#10677](https://github.com/mastra-ai/mastra/pull/10677))
|
|
8
|
+
|
|
9
|
+
You can now pass a custom fetch function when creating a MastraClient:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { MastraClient } from '@mastra/client-js';
|
|
13
|
+
|
|
14
|
+
// Before: Only global fetch was available
|
|
15
|
+
const client = new MastraClient({
|
|
16
|
+
baseUrl: 'http://your-api-url',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// After: Custom fetch can be passed
|
|
20
|
+
const client = new MastraClient({
|
|
21
|
+
baseUrl: 'http://your-api-url',
|
|
22
|
+
fetch: customFetch, // Your custom fetch implementation
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If no custom fetch is provided, it falls back to the global fetch function, maintaining backward compatibility.
|
|
27
|
+
|
|
28
|
+
Fixes #10673
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- The client-js package had its own simpler zodToJsonSchema implementation that was missing critical features from schema-compat. This could cause issues when users pass Zod schemas with `z.record()` or `z.date()` through the MastraClient. ([#10730](https://github.com/mastra-ai/mastra/pull/10730))
|
|
33
|
+
|
|
34
|
+
Now the client uses the same implementation as the rest of the codebase, which includes the Zod v4 `z.record()` bug fix, date-time format conversion for `z.date()`, and proper handling of unrepresentable types.
|
|
35
|
+
|
|
36
|
+
Also removes the now-unused `zod-to-json-schema` dependency from client-js.
|
|
37
|
+
|
|
38
|
+
- Fix wrong arguments type in list workflow runs ([#10755](https://github.com/mastra-ai/mastra/pull/10755))
|
|
39
|
+
|
|
40
|
+
- Adjust the generate / stream types to accept tracingOptions ([#10742](https://github.com/mastra-ai/mastra/pull/10742))
|
|
41
|
+
|
|
42
|
+
- fix(a2a): fix streaming and memory support for A2A protocol ([#10653](https://github.com/mastra-ai/mastra/pull/10653))
|
|
43
|
+
|
|
44
|
+
**Client (`@mastra/client-js`):**
|
|
45
|
+
- Fixed `sendStreamingMessage` to properly return a streaming response instead of attempting to parse it as JSON
|
|
46
|
+
|
|
47
|
+
**Server (`@mastra/server`):**
|
|
48
|
+
- Fixed A2A message handler to pass `contextId` as `threadId` for memory persistence across conversations
|
|
49
|
+
- Added support for user-provided `resourceId` via `params.metadata.resourceId` or `message.metadata.resourceId`, falling back to `agentId`
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
52
|
+
- @mastra/core@1.0.0-beta.6
|
|
53
|
+
- @mastra/schema-compat@1.0.0-beta.2
|
|
54
|
+
|
|
3
55
|
## 1.0.0-beta.5
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ const client = new MastraClient({
|
|
|
68
68
|
- `getMemoryThread({ threadId, agentId })`: Get a memory thread instance
|
|
69
69
|
- `saveMessageToMemory(params)`: Save messages to memory
|
|
70
70
|
- `getMemoryStatus()`: Get memory system status
|
|
71
|
+
- `getWorkingMemory({ agentId, threadId, resourceId? })`: Get working memory for a thread
|
|
72
|
+
- `updateWorkingMemory({ agentId, threadId, workingMemory, resourceId? })`: Update working memory for a thread
|
|
71
73
|
|
|
72
74
|
### Tools
|
|
73
75
|
|
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" } : {},
|
|
@@ -1617,15 +1617,15 @@ var Workflow = class extends BaseResource {
|
|
|
1617
1617
|
if (params?.toDate) {
|
|
1618
1618
|
searchParams.set("toDate", params.toDate.toISOString());
|
|
1619
1619
|
}
|
|
1620
|
-
if (params?.
|
|
1621
|
-
if (params.
|
|
1622
|
-
searchParams.set("
|
|
1623
|
-
} else if (typeof params.
|
|
1624
|
-
searchParams.set("
|
|
1620
|
+
if (params?.limit !== null && params?.limit !== void 0) {
|
|
1621
|
+
if (params.limit === false) {
|
|
1622
|
+
searchParams.set("limit", "false");
|
|
1623
|
+
} else if (typeof params.limit === "number" && params.limit > 0 && Number.isInteger(params.limit)) {
|
|
1624
|
+
searchParams.set("limit", String(params.limit));
|
|
1625
1625
|
}
|
|
1626
1626
|
}
|
|
1627
|
-
if (params?.
|
|
1628
|
-
searchParams.set("
|
|
1627
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
1628
|
+
searchParams.set("offset", String(params.offset));
|
|
1629
1629
|
}
|
|
1630
1630
|
if (params?.resourceId) {
|
|
1631
1631
|
searchParams.set("resourceId", params.resourceId);
|
|
@@ -1692,6 +1692,7 @@ var Workflow = class extends BaseResource {
|
|
|
1692
1692
|
return this.start({
|
|
1693
1693
|
runId,
|
|
1694
1694
|
inputData: p.inputData,
|
|
1695
|
+
initialState: p.initialState,
|
|
1695
1696
|
requestContext: p.requestContext,
|
|
1696
1697
|
tracingOptions: p.tracingOptions
|
|
1697
1698
|
});
|
|
@@ -1700,12 +1701,18 @@ var Workflow = class extends BaseResource {
|
|
|
1700
1701
|
return this.startAsync({
|
|
1701
1702
|
runId,
|
|
1702
1703
|
inputData: p.inputData,
|
|
1704
|
+
initialState: p.initialState,
|
|
1703
1705
|
requestContext: p.requestContext,
|
|
1704
1706
|
tracingOptions: p.tracingOptions
|
|
1705
1707
|
});
|
|
1706
1708
|
},
|
|
1707
1709
|
stream: async (p) => {
|
|
1708
|
-
return this.stream({
|
|
1710
|
+
return this.stream({
|
|
1711
|
+
runId,
|
|
1712
|
+
inputData: p.inputData,
|
|
1713
|
+
initialState: p.initialState,
|
|
1714
|
+
requestContext: p.requestContext
|
|
1715
|
+
});
|
|
1709
1716
|
},
|
|
1710
1717
|
resume: async (p) => {
|
|
1711
1718
|
return this.resume({
|
|
@@ -1737,14 +1744,19 @@ var Workflow = class extends BaseResource {
|
|
|
1737
1744
|
}
|
|
1738
1745
|
/**
|
|
1739
1746
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1740
|
-
* @param params - Object containing the runId, inputData and requestContext
|
|
1747
|
+
* @param params - Object containing the runId, inputData, initialState and requestContext
|
|
1741
1748
|
* @returns Promise containing success message
|
|
1742
1749
|
*/
|
|
1743
1750
|
start(params) {
|
|
1744
1751
|
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1745
1752
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1746
1753
|
method: "POST",
|
|
1747
|
-
body: {
|
|
1754
|
+
body: {
|
|
1755
|
+
inputData: params?.inputData,
|
|
1756
|
+
initialState: params?.initialState,
|
|
1757
|
+
requestContext,
|
|
1758
|
+
tracingOptions: params.tracingOptions
|
|
1759
|
+
}
|
|
1748
1760
|
});
|
|
1749
1761
|
}
|
|
1750
1762
|
/**
|
|
@@ -1772,7 +1784,7 @@ var Workflow = class extends BaseResource {
|
|
|
1772
1784
|
}
|
|
1773
1785
|
/**
|
|
1774
1786
|
* 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
|
|
1787
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1776
1788
|
* @returns Promise containing the workflow execution results
|
|
1777
1789
|
*/
|
|
1778
1790
|
startAsync(params) {
|
|
@@ -1783,12 +1795,17 @@ var Workflow = class extends BaseResource {
|
|
|
1783
1795
|
const requestContext = parseClientRequestContext(params.requestContext);
|
|
1784
1796
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1785
1797
|
method: "POST",
|
|
1786
|
-
body: {
|
|
1798
|
+
body: {
|
|
1799
|
+
inputData: params.inputData,
|
|
1800
|
+
initialState: params.initialState,
|
|
1801
|
+
requestContext,
|
|
1802
|
+
tracingOptions: params.tracingOptions
|
|
1803
|
+
}
|
|
1787
1804
|
});
|
|
1788
1805
|
}
|
|
1789
1806
|
/**
|
|
1790
1807
|
* Starts a workflow run and returns a stream
|
|
1791
|
-
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1808
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1792
1809
|
* @returns Promise containing the workflow execution results
|
|
1793
1810
|
*/
|
|
1794
1811
|
async stream(params) {
|
|
@@ -1801,7 +1818,12 @@ var Workflow = class extends BaseResource {
|
|
|
1801
1818
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1802
1819
|
{
|
|
1803
1820
|
method: "POST",
|
|
1804
|
-
body: {
|
|
1821
|
+
body: {
|
|
1822
|
+
inputData: params.inputData,
|
|
1823
|
+
initialState: params.initialState,
|
|
1824
|
+
requestContext,
|
|
1825
|
+
tracingOptions: params.tracingOptions
|
|
1826
|
+
},
|
|
1805
1827
|
stream: true
|
|
1806
1828
|
}
|
|
1807
1829
|
);
|
|
@@ -1886,7 +1908,7 @@ var Workflow = class extends BaseResource {
|
|
|
1886
1908
|
}
|
|
1887
1909
|
/**
|
|
1888
1910
|
* Starts a workflow run and returns a stream
|
|
1889
|
-
* @param params - Object containing the optional runId, inputData and requestContext
|
|
1911
|
+
* @param params - Object containing the optional runId, inputData, initialState and requestContext
|
|
1890
1912
|
* @returns Promise containing the workflow execution results
|
|
1891
1913
|
*/
|
|
1892
1914
|
async streamVNext(params) {
|
|
@@ -1901,6 +1923,7 @@ var Workflow = class extends BaseResource {
|
|
|
1901
1923
|
method: "POST",
|
|
1902
1924
|
body: {
|
|
1903
1925
|
inputData: params.inputData,
|
|
1926
|
+
initialState: params.initialState,
|
|
1904
1927
|
requestContext,
|
|
1905
1928
|
closeOnSuspend: params.closeOnSuspend,
|
|
1906
1929
|
tracingOptions: params.tracingOptions
|
|
@@ -2259,7 +2282,8 @@ var A2A = class extends BaseResource {
|
|
|
2259
2282
|
body: {
|
|
2260
2283
|
method: "message/stream",
|
|
2261
2284
|
params
|
|
2262
|
-
}
|
|
2285
|
+
},
|
|
2286
|
+
stream: true
|
|
2263
2287
|
});
|
|
2264
2288
|
return response;
|
|
2265
2289
|
}
|