@mastra/react 0.4.1-alpha.7 → 0.4.1-alpha.9

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,24 @@
1
1
  # @mastra/react
2
2
 
3
+ ## 0.4.1-alpha.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`271d891`](https://github.com/mastra-ai/mastra/commit/271d8917e4323340f9fe549f3e8de55810dbbcbe)]:
8
+ - @mastra/client-js@1.21.0-alpha.9
9
+
10
+ ## 0.4.1-alpha.8
11
+
12
+ ### Patch Changes
13
+
14
+ - Fixed `clientTools` being silently dropped — and never executed — on thread-backed chats. When a chat had a `threadId`, the React `useChat` hook routed messages through the new agent signals path but did not pass the `clientTools` map into the signal startup flow, so client-side tools were unavailable when the model requested them. ([#16540](https://github.com/mastra-ai/mastra/pull/16540))
15
+
16
+ The signals path now carries `clientTools` and other per-send stream options on `sendSignal`. When the subscribed stream finishes with `tool-calls`, the client executes matching local tools with observability support, emits tool result chunks, and posts a continuation with the assistant tool-call messages plus tool-result messages so the run resumes on the same thread with the same per-send options.
17
+
18
+ - Updated dependencies [[`c35b962`](https://github.com/mastra-ai/mastra/commit/c35b9625c7e854fcfdeee226a3338a750d0ff211), [`c35b962`](https://github.com/mastra-ai/mastra/commit/c35b9625c7e854fcfdeee226a3338a750d0ff211), [`9be1545`](https://github.com/mastra-ai/mastra/commit/9be1545475eb81a716169bb1281a37853cc739e0), [`4084113`](https://github.com/mastra-ai/mastra/commit/408411370fc48a822e8b616b3b63f9409774e0e9), [`bc01b1b`](https://github.com/mastra-ai/mastra/commit/bc01b1bfafe381d90af909f8bce7eeb4eee779f2), [`1120b4f`](https://github.com/mastra-ai/mastra/commit/1120b4fa928552c6ee1751efa5603d955841e766)]:
19
+ - @mastra/core@1.37.0-alpha.8
20
+ - @mastra/client-js@1.21.0-alpha.8
21
+
3
22
  ## 0.4.1-alpha.7
4
23
 
5
24
  ### Patch Changes
@@ -13,6 +13,12 @@ export interface MastraChatProps {
13
13
  initialMessages?: MastraUIMessage[];
14
14
  /** Persistent request context used for tool approval/decline calls (e.g. agentVersionId). */
15
15
  requestContext?: RequestContext;
16
+ /**
17
+ * Client-side tool definitions. Forwarded once to `subscribeToThread` so
18
+ * the client-js subscription drives the full client-tool execution loop
19
+ * (execute, emit tool-result, continuation) without any logic in React.
20
+ */
21
+ clientTools?: Record<string, unknown>;
16
22
  onSignalSent?: (signalId: string, preview: string) => void;
17
23
  onSignalEcho?: (signalId: string) => void;
18
24
  onThreadSignalsUnsupported?: () => void;
@@ -55,7 +61,7 @@ export type StreamArgs = SharedArgs & {
55
61
  export type NetworkArgs = SharedArgs & {
56
62
  onNetworkChunk?: (chunk: NetworkChunkType) => Promise<void>;
57
63
  };
58
- export declare const useChat: ({ agentId, resourceId, threadId, initialMessages, requestContext: propsRequestContext, onSignalSent, onSignalEcho, onThreadSignalsUnsupported, enableThreadSignals, }: MastraChatProps) => {
64
+ export declare const useChat: ({ agentId, resourceId, threadId, initialMessages, requestContext: propsRequestContext, clientTools: hookClientTools, onSignalSent, onSignalEcho, onThreadSignalsUnsupported, enableThreadSignals, }: MastraChatProps) => {
59
65
  setMessages: import("react").Dispatch<import("react").SetStateAction<MastraUIMessage[]>>;
60
66
  sendMessage: ({ mode, ...args }: SendMessageArgs) => Promise<void>;
61
67
  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,gB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.cjs CHANGED
@@ -2036,6 +2036,7 @@ var useChat = ({
2036
2036
  threadId,
2037
2037
  initialMessages,
2038
2038
  requestContext: propsRequestContext,
2039
+ clientTools: hookClientTools,
2039
2040
  onSignalSent,
2040
2041
  onSignalEcho,
2041
2042
  onThreadSignalsUnsupported,
@@ -2229,6 +2230,7 @@ var useChat = ({
2229
2230
  requireToolApproval
2230
2231
  } = modelSettings || {};
2231
2232
  const resolvedRequestContext = requestContext ?? propsRequestContext;
2233
+ const resolvedClientTools = clientTools ?? hookClientTools;
2232
2234
  _requestContext.current = resolvedRequestContext;
2233
2235
  setIsRunning(true);
2234
2236
  const clientWithAbort = new clientJs.MastraClient({
@@ -2256,7 +2258,7 @@ var useChat = ({
2256
2258
  providerOptions,
2257
2259
  tracingOptions,
2258
2260
  requireToolApproval,
2259
- clientTools
2261
+ clientTools: resolvedClientTools
2260
2262
  });
2261
2263
  if (response.finishReason === "suspended" && response.suspendPayload) {
2262
2264
  const { toolCallId, toolName, args } = response.suspendPayload;
@@ -2316,6 +2318,23 @@ var useChat = ({
2316
2318
  requireToolApproval
2317
2319
  } = modelSettings || {};
2318
2320
  const resolvedRequestContext = requestContext ?? propsRequestContext;
2321
+ const resolvedClientTools = clientTools ?? hookClientTools;
2322
+ const signalContinuationOptions = {
2323
+ maxSteps,
2324
+ modelSettings: {
2325
+ frequencyPenalty,
2326
+ presencePenalty,
2327
+ maxRetries,
2328
+ maxOutputTokens: maxTokens,
2329
+ temperature,
2330
+ topK,
2331
+ topP
2332
+ },
2333
+ instructions,
2334
+ providerOptions,
2335
+ requireToolApproval,
2336
+ tracingOptions
2337
+ };
2319
2338
  _requestContext.current = resolvedRequestContext;
2320
2339
  setIsRunning(true);
2321
2340
  _streamAbortRef.current?.abort();
@@ -2350,7 +2369,7 @@ var useChat = ({
2350
2369
  providerOptions,
2351
2370
  requireToolApproval,
2352
2371
  tracingOptions,
2353
- clientTools
2372
+ clientTools: resolvedClientTools
2354
2373
  });
2355
2374
  _onChunk.current = onChunk;
2356
2375
  _currentRunId.current = runId;
@@ -2385,21 +2404,9 @@ var useChat = ({
2385
2404
  threadId: threadId2,
2386
2405
  ifIdle: {
2387
2406
  streamOptions: {
2388
- maxSteps,
2389
- modelSettings: {
2390
- frequencyPenalty,
2391
- presencePenalty,
2392
- maxRetries,
2393
- maxOutputTokens: maxTokens,
2394
- temperature,
2395
- topK,
2396
- topP
2397
- },
2398
- instructions,
2407
+ ...signalContinuationOptions,
2399
2408
  requestContext: resolvedRequestContext,
2400
- providerOptions,
2401
- requireToolApproval,
2402
- tracingOptions
2409
+ clientTools: resolvedClientTools
2403
2410
  }
2404
2411
  }
2405
2412
  });