@mastra/react 0.2.18-alpha.5 → 0.2.18-alpha.7
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 +30 -0
- package/dist/index.cjs +36 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/ai-sdk/memory/resolveInitialMessages.d.ts.map +1 -1
- package/dist/lib/ai-sdk/utils/toUIMessage.d.ts.map +1 -1
- package/dist/mastra-client-context.d.ts +8 -1
- package/dist/mastra-client-context.d.ts.map +1 -1
- package/dist/mastra-react-provider.d.ts +1 -1
- package/dist/mastra-react-provider.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @mastra/react
|
|
2
2
|
|
|
3
|
+
## 0.2.18-alpha.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85)]:
|
|
8
|
+
- @mastra/core@1.18.0-alpha.4
|
|
9
|
+
- @mastra/client-js@1.11.0-alpha.7
|
|
10
|
+
|
|
11
|
+
## 0.2.18-alpha.6
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- **Fixed** React UIs getting `401` from Mastra after a successful cookie login when the app and API run on different hosts or ports (for example Mastra Studio against a custom server). API calls from `MastraReactProvider` now include session cookies by default ([#14770](https://github.com/mastra-ai/mastra/issues/14770)). ([#14777](https://github.com/mastra-ai/mastra/pull/14777))
|
|
16
|
+
|
|
17
|
+
**Added** optional `credentials` prop when you want tighter control, for example same-origin-only requests:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<MastraReactProvider baseUrl="http://localhost:4000" credentials="same-origin">
|
|
21
|
+
{children}
|
|
22
|
+
</MastraReactProvider>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Added** `MastraClientCredentials` and `MastraClientProviderProps` type exports.
|
|
26
|
+
|
|
27
|
+
- Fix restored subagent tool results so approval cards and nested tool state appear correctly in the dev server. ([#14348](https://github.com/mastra-ai/mastra/pull/14348))
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`d084b66`](https://github.com/mastra-ai/mastra/commit/d084b6692396057e83c086b954c1857d20b58a14), [`79c699a`](https://github.com/mastra-ai/mastra/commit/79c699acf3cd8a77e11c55530431f48eb48456e9), [`62757b6`](https://github.com/mastra-ai/mastra/commit/62757b6db6e8bb86569d23ad0b514178f57053f8), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
|
|
30
|
+
- @mastra/client-js@1.11.0-alpha.6
|
|
31
|
+
- @mastra/core@1.18.0-alpha.3
|
|
32
|
+
|
|
3
33
|
## 0.2.18-alpha.5
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -12,8 +12,14 @@ var web = require('shiki/bundle/web');
|
|
|
12
12
|
|
|
13
13
|
// src/mastra-client-context.tsx
|
|
14
14
|
var MastraClientContext = react.createContext({});
|
|
15
|
-
var MastraClientProvider = ({
|
|
16
|
-
|
|
15
|
+
var MastraClientProvider = ({
|
|
16
|
+
children,
|
|
17
|
+
baseUrl,
|
|
18
|
+
headers,
|
|
19
|
+
apiPrefix,
|
|
20
|
+
credentials = "include"
|
|
21
|
+
}) => {
|
|
22
|
+
const client = createMastraClient(baseUrl, headers, apiPrefix, credentials);
|
|
17
23
|
return /* @__PURE__ */ jsxRuntime.jsx(MastraClientContext.Provider, { value: client, children });
|
|
18
24
|
};
|
|
19
25
|
var useMastraClient = () => react.useContext(MastraClientContext);
|
|
@@ -32,15 +38,22 @@ var isLocalUrl = (url) => {
|
|
|
32
38
|
return false;
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
|
-
var createMastraClient = (baseUrl, mastraClientHeaders = {}, apiPrefix) => {
|
|
41
|
+
var createMastraClient = (baseUrl, mastraClientHeaders = {}, apiPrefix, credentials = "include") => {
|
|
36
42
|
return new clientJs.MastraClient({
|
|
37
43
|
baseUrl: baseUrl || "",
|
|
38
44
|
headers: isLocalUrl(baseUrl) ? { ...mastraClientHeaders, "x-mastra-dev-playground": "true" } : mastraClientHeaders,
|
|
39
|
-
apiPrefix
|
|
45
|
+
apiPrefix,
|
|
46
|
+
credentials
|
|
40
47
|
});
|
|
41
48
|
};
|
|
42
|
-
var MastraReactProvider = ({
|
|
43
|
-
|
|
49
|
+
var MastraReactProvider = ({
|
|
50
|
+
children,
|
|
51
|
+
baseUrl,
|
|
52
|
+
headers,
|
|
53
|
+
apiPrefix,
|
|
54
|
+
credentials
|
|
55
|
+
}) => {
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MastraClientProvider, { baseUrl, headers, apiPrefix, credentials, children });
|
|
44
57
|
};
|
|
45
58
|
|
|
46
59
|
// src/lib/ai-sdk/utils/formatCompletionFeedback.ts
|
|
@@ -424,7 +437,11 @@ var toUIMessage = ({ chunk, conversation, metadata }) => {
|
|
|
424
437
|
if (isWorkflow) {
|
|
425
438
|
output = chunk.payload.result?.result;
|
|
426
439
|
} else if (isAgent) {
|
|
427
|
-
|
|
440
|
+
const existingOutput = parts[toolPartIndex].output;
|
|
441
|
+
output = existingOutput ? {
|
|
442
|
+
...chunk.payload.result,
|
|
443
|
+
childMessages: existingOutput.childMessages?.length ? existingOutput.childMessages : chunk.payload.result?.childMessages
|
|
444
|
+
} : chunk.payload.result;
|
|
428
445
|
} else {
|
|
429
446
|
output = chunk.payload.result;
|
|
430
447
|
}
|
|
@@ -1020,12 +1037,23 @@ var resolveInitialMessages = (messages) => {
|
|
|
1020
1037
|
const extendedMessage = message;
|
|
1021
1038
|
const pendingToolApprovals = extendedMessage.metadata?.pendingToolApprovals;
|
|
1022
1039
|
if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
|
|
1040
|
+
const stillPending = Object.fromEntries(
|
|
1041
|
+
Object.entries(pendingToolApprovals).filter(([_, approval]) => {
|
|
1042
|
+
if (!approval || typeof approval !== "object" || !("toolCallId" in approval)) {
|
|
1043
|
+
return false;
|
|
1044
|
+
}
|
|
1045
|
+
const toolCallId = approval.toolCallId;
|
|
1046
|
+
return !message.parts.some(
|
|
1047
|
+
(part) => part.toolCallId === toolCallId && (part.state === "output-available" || part.output != null)
|
|
1048
|
+
);
|
|
1049
|
+
})
|
|
1050
|
+
);
|
|
1023
1051
|
return {
|
|
1024
1052
|
...message,
|
|
1025
1053
|
metadata: {
|
|
1026
1054
|
...message.metadata,
|
|
1027
1055
|
mode: "stream",
|
|
1028
|
-
requireApprovalMetadata:
|
|
1056
|
+
...Object.keys(stillPending).length > 0 ? { requireApprovalMetadata: stillPending } : {}
|
|
1029
1057
|
}
|
|
1030
1058
|
};
|
|
1031
1059
|
}
|