@mastra/react 0.2.18-alpha.7 → 0.2.18

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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # @mastra/react
2
2
 
3
+ ## 0.2.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Added requestContext support to tool approval and decline methods, ensuring agent version context is preserved when resuming after tool approval. ([#14847](https://github.com/mastra-ai/mastra/pull/14847))
8
+
9
+ - **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))
10
+
11
+ **Added** optional `credentials` prop when you want tighter control, for example same-origin-only requests:
12
+
13
+ ```tsx
14
+ <MastraReactProvider baseUrl="http://localhost:4000" credentials="same-origin">
15
+ {children}
16
+ </MastraReactProvider>
17
+ ```
18
+
19
+ **Added** `MastraClientCredentials` and `MastraClientProviderProps` type exports.
20
+
21
+ - 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))
22
+
23
+ - Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`dc9fc19`](https://github.com/mastra-ai/mastra/commit/dc9fc19da4437f6b508cc355f346a8856746a76b), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`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), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`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), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0), [`197daf0`](https://github.com/mastra-ai/mastra/commit/197daf03a33e4650bd90391eef0ec7d0392a6c9c), [`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), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`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), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
24
+ - @mastra/core@1.18.0
25
+ - @mastra/client-js@1.11.0
26
+
27
+ ## 0.2.18-alpha.8
28
+
29
+ ### Patch Changes
30
+
31
+ - Added requestContext support to tool approval and decline methods, ensuring agent version context is preserved when resuming after tool approval. ([#14847](https://github.com/mastra-ai/mastra/pull/14847))
32
+
33
+ - Updated dependencies [[`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a)]:
34
+ - @mastra/client-js@1.11.0-alpha.8
35
+ - @mastra/core@1.18.0-alpha.5
36
+
3
37
  ## 0.2.18-alpha.7
4
38
 
5
39
  ### Patch Changes
@@ -9,6 +9,8 @@ export interface MastraChatProps {
9
9
  agentId: string;
10
10
  resourceId?: string;
11
11
  initialMessages?: MastraUIMessage[];
12
+ /** Persistent request context used for tool approval/decline calls (e.g. agentVersionId). */
13
+ requestContext?: RequestContext;
12
14
  }
13
15
  interface SharedArgs {
14
16
  coreUserMessages: CoreUserMessage[];
@@ -39,7 +41,7 @@ export type StreamArgs = SharedArgs & {
39
41
  export type NetworkArgs = SharedArgs & {
40
42
  onNetworkChunk?: (chunk: NetworkChunkType) => Promise<void>;
41
43
  };
42
- export declare const useChat: ({ agentId, resourceId, initialMessages }: MastraChatProps) => {
44
+ export declare const useChat: ({ agentId, resourceId, initialMessages, requestContext: propsRequestContext, }: MastraChatProps) => {
43
45
  setMessages: import("react").Dispatch<import("react").SetStateAction<MastraUIMessage[]>>;
44
46
  sendMessage: ({ mode, ...args }: SendMessageArgs) => Promise<void>;
45
47
  isRunning: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/agent/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO7C,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,C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 @@ var extractRunIdFromMessages = (messages) => {
1690
1690
  }
1691
1691
  return void 0;
1692
1692
  };
1693
- var useChat = ({ agentId, resourceId, initialMessages }) => {
1693
+ var useChat = ({
1694
+ agentId,
1695
+ resourceId,
1696
+ initialMessages,
1697
+ requestContext: propsRequestContext
1698
+ }) => {
1694
1699
  const _currentRunId = react.useRef(void 0);
1695
1700
  const _onChunk = react.useRef(void 0);
1696
1701
  const _networkRunId = react.useRef(void 0);
1697
1702
  const _onNetworkChunk = react.useRef(void 0);
1703
+ const _requestContext = react.useRef(propsRequestContext);
1698
1704
  const [messages, setMessages] = react.useState([]);
1699
1705
  const [toolCallApprovals, setToolCallApprovals] = react.useState({});
1700
1706
  const [networkToolCallApprovals, setNetworkToolCallApprovals] = react.useState({});
@@ -1705,6 +1711,9 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1705
1711
  setMessages(formattedMessages);
1706
1712
  _currentRunId.current = extractRunIdFromMessages(formattedMessages);
1707
1713
  }, [initialMessages]);
1714
+ react.useEffect(() => {
1715
+ _requestContext.current = propsRequestContext;
1716
+ }, [propsRequestContext]);
1708
1717
  const generate = async ({
1709
1718
  coreUserMessages,
1710
1719
  requestContext,
@@ -1727,6 +1736,8 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1727
1736
  maxSteps,
1728
1737
  requireToolApproval
1729
1738
  } = modelSettings || {};
1739
+ const resolvedRequestContext = requestContext ?? propsRequestContext;
1740
+ _requestContext.current = resolvedRequestContext;
1730
1741
  setIsRunning(true);
1731
1742
  const clientWithAbort = new clientJs.MastraClient({
1732
1743
  ...baseClient.options,
@@ -1748,7 +1759,7 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1748
1759
  topP
1749
1760
  },
1750
1761
  instructions,
1751
- requestContext,
1762
+ requestContext: resolvedRequestContext,
1752
1763
  ...threadId ? { memory: { thread: threadId, resource: resourceId || agentId } } : {},
1753
1764
  providerOptions,
1754
1765
  tracingOptions,
@@ -1809,6 +1820,8 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1809
1820
  maxSteps,
1810
1821
  requireToolApproval
1811
1822
  } = modelSettings || {};
1823
+ const resolvedRequestContext = requestContext ?? propsRequestContext;
1824
+ _requestContext.current = resolvedRequestContext;
1812
1825
  setIsRunning(true);
1813
1826
  const clientWithAbort = new clientJs.MastraClient({
1814
1827
  ...baseClient.options,
@@ -1829,7 +1842,7 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1829
1842
  topP
1830
1843
  },
1831
1844
  instructions,
1832
- requestContext,
1845
+ requestContext: resolvedRequestContext,
1833
1846
  ...threadId ? { memory: { thread: threadId, resource: resourceId || agentId } } : {},
1834
1847
  providerOptions,
1835
1848
  requireToolApproval,
@@ -1855,6 +1868,8 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1855
1868
  tracingOptions
1856
1869
  }) => {
1857
1870
  const { frequencyPenalty, presencePenalty, maxRetries, maxTokens, temperature, topK, topP, maxSteps } = modelSettings || {};
1871
+ const resolvedRequestContext = requestContext ?? propsRequestContext;
1872
+ _requestContext.current = resolvedRequestContext;
1858
1873
  setIsRunning(true);
1859
1874
  const clientWithAbort = new clientJs.MastraClient({
1860
1875
  ...baseClient.options,
@@ -1874,7 +1889,7 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1874
1889
  topP
1875
1890
  },
1876
1891
  runId,
1877
- requestContext,
1892
+ requestContext: resolvedRequestContext,
1878
1893
  ...threadId ? { memory: { thread: threadId, resource: resourceId || agentId } } : {},
1879
1894
  tracingOptions
1880
1895
  });
@@ -1895,6 +1910,7 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1895
1910
  _onChunk.current = void 0;
1896
1911
  _networkRunId.current = void 0;
1897
1912
  _onNetworkChunk.current = void 0;
1913
+ _requestContext.current = void 0;
1898
1914
  };
1899
1915
  const approveToolCall = async (toolCallId) => {
1900
1916
  const onChunk = _onChunk.current;
@@ -1904,7 +1920,11 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1904
1920
  setIsRunning(true);
1905
1921
  setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "approved" } }));
1906
1922
  const agent = baseClient.getAgent(agentId);
1907
- const response = await agent.approveToolCall({ runId: currentRunId, toolCallId });
1923
+ const response = await agent.approveToolCall({
1924
+ runId: currentRunId,
1925
+ toolCallId,
1926
+ requestContext: _requestContext.current
1927
+ });
1908
1928
  await response.processDataStream({
1909
1929
  onChunk: async (chunk) => {
1910
1930
  setMessages((prev) => toUIMessage({ chunk, conversation: prev, metadata: { mode: "stream" } }));
@@ -1921,7 +1941,11 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1921
1941
  setIsRunning(true);
1922
1942
  setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "declined" } }));
1923
1943
  const agent = baseClient.getAgent(agentId);
1924
- const response = await agent.declineToolCall({ runId: currentRunId, toolCallId });
1944
+ const response = await agent.declineToolCall({
1945
+ runId: currentRunId,
1946
+ toolCallId,
1947
+ requestContext: _requestContext.current
1948
+ });
1925
1949
  await response.processDataStream({
1926
1950
  onChunk: async (chunk) => {
1927
1951
  setMessages((prev) => toUIMessage({ chunk, conversation: prev, metadata: { mode: "stream" } }));
@@ -1939,7 +1963,11 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1939
1963
  setIsRunning(true);
1940
1964
  setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "approved" } }));
1941
1965
  const agent = baseClient.getAgent(agentId);
1942
- const response = await agent.approveToolCallGenerate({ runId: currentRunId, toolCallId });
1966
+ const response = await agent.approveToolCallGenerate({
1967
+ runId: currentRunId,
1968
+ toolCallId,
1969
+ requestContext: _requestContext.current
1970
+ });
1943
1971
  if (response && "uiMessages" in response.response && response.response.uiMessages) {
1944
1972
  const mastraUIMessages = (response.response.uiMessages || []).map((message) => ({
1945
1973
  ...message,
@@ -1960,7 +1988,11 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1960
1988
  setIsRunning(true);
1961
1989
  setToolCallApprovals((prev) => ({ ...prev, [toolCallId]: { status: "declined" } }));
1962
1990
  const agent = baseClient.getAgent(agentId);
1963
- const response = await agent.declineToolCallGenerate({ runId: currentRunId, toolCallId });
1991
+ const response = await agent.declineToolCallGenerate({
1992
+ runId: currentRunId,
1993
+ toolCallId,
1994
+ requestContext: _requestContext.current
1995
+ });
1964
1996
  if (response && "uiMessages" in response.response && response.response.uiMessages) {
1965
1997
  const mastraUIMessages = (response.response.uiMessages || []).map((message) => ({
1966
1998
  ...message,
@@ -1985,7 +2017,10 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
1985
2017
  [runId ? `${runId}-${toolName}` : toolName]: { status: "approved" }
1986
2018
  }));
1987
2019
  const agent = baseClient.getAgent(agentId);
1988
- const response = await agent.approveNetworkToolCall({ runId: networkRunId });
2020
+ const response = await agent.approveNetworkToolCall({
2021
+ runId: networkRunId,
2022
+ requestContext: _requestContext.current
2023
+ });
1989
2024
  const transformer = new AISdkNetworkTransformer();
1990
2025
  await response.processDataStream({
1991
2026
  onChunk: async (chunk) => {
@@ -2008,7 +2043,10 @@ var useChat = ({ agentId, resourceId, initialMessages }) => {
2008
2043
  [runId ? `${runId}-${toolName}` : toolName]: { status: "declined" }
2009
2044
  }));
2010
2045
  const agent = baseClient.getAgent(agentId);
2011
- const response = await agent.declineNetworkToolCall({ runId: networkRunId });
2046
+ const response = await agent.declineNetworkToolCall({
2047
+ runId: networkRunId,
2048
+ requestContext: _requestContext.current
2049
+ });
2012
2050
  const transformer = new AISdkNetworkTransformer();
2013
2051
  await response.processDataStream({
2014
2052
  onChunk: async (chunk) => {