@mastra/react 1.0.0-beta.25 → 1.0.2

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.
Files changed (156) hide show
  1. package/CHANGELOG.md +2763 -3
  2. package/LICENSE.md +15 -0
  3. package/dist/agent/extractRunIdFromMessages.d.ts +10 -0
  4. package/dist/agent/extractRunIdFromMessages.d.ts.map +1 -0
  5. package/dist/agent/hooks.d.ts +91 -0
  6. package/dist/agent/hooks.d.ts.map +1 -0
  7. package/dist/agent/signal-data.d.ts +2 -0
  8. package/dist/agent/signal-data.d.ts.map +1 -0
  9. package/dist/{src/agent → agent}/types.d.ts +6 -1
  10. package/dist/agent/types.d.ts.map +1 -0
  11. package/dist/index.cjs +3743 -63
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +11 -2
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +3676 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/lib/mastra-db/accumulator.d.ts +48 -0
  18. package/dist/lib/mastra-db/accumulator.d.ts.map +1 -0
  19. package/dist/lib/mastra-db/formatCompletionFeedback.d.ts +19 -0
  20. package/dist/lib/mastra-db/formatCompletionFeedback.d.ts.map +1 -0
  21. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +14 -0
  22. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -0
  23. package/dist/lib/mastra-db/index.d.ts +6 -0
  24. package/dist/lib/mastra-db/index.d.ts.map +1 -0
  25. package/dist/lib/mastra-db/types.d.ts +171 -0
  26. package/dist/lib/mastra-db/types.d.ts.map +1 -0
  27. package/dist/lib/use-mutation.d.ts +28 -0
  28. package/dist/lib/use-mutation.d.ts.map +1 -0
  29. package/dist/mastra-client-context.d.ts +26 -0
  30. package/dist/mastra-client-context.d.ts.map +1 -0
  31. package/dist/mastra-react-provider.d.ts +5 -0
  32. package/dist/mastra-react-provider.d.ts.map +1 -0
  33. package/dist/react.css +184 -322
  34. package/dist/{src/ui → ui}/Code/Code.d.ts +2 -1
  35. package/dist/ui/Code/Code.d.ts.map +1 -0
  36. package/dist/ui/Code/highlight.d.ts +4 -0
  37. package/dist/ui/Code/highlight.d.ts.map +1 -0
  38. package/dist/ui/Code/index.d.ts +2 -0
  39. package/dist/ui/Code/index.d.ts.map +1 -0
  40. package/dist/{src/ui → ui}/Entity/Entity.d.ts +2 -1
  41. package/dist/ui/Entity/Entity.d.ts.map +1 -0
  42. package/dist/{src/ui → ui}/Entity/Entry.d.ts +2 -1
  43. package/dist/ui/Entity/Entry.d.ts.map +1 -0
  44. package/dist/{src/ui → ui}/Entity/ToolApproval.d.ts +1 -0
  45. package/dist/ui/Entity/ToolApproval.d.ts.map +1 -0
  46. package/dist/{src/ui → ui}/Entity/context.d.ts +4 -3
  47. package/dist/ui/Entity/context.d.ts.map +1 -0
  48. package/dist/ui/Entity/index.d.ts +5 -0
  49. package/dist/ui/Entity/index.d.ts.map +1 -0
  50. package/dist/{src/ui → ui}/Entity/types.d.ts +1 -0
  51. package/dist/ui/Entity/types.d.ts.map +1 -0
  52. package/dist/{src/ui → ui}/Icon/Icon.d.ts +2 -1
  53. package/dist/ui/Icon/Icon.d.ts.map +1 -0
  54. package/dist/ui/Icon/index.d.ts +2 -0
  55. package/dist/ui/Icon/index.d.ts.map +1 -0
  56. package/dist/{src/ui → ui}/IconButton/IconButton.d.ts +2 -1
  57. package/dist/ui/IconButton/IconButton.d.ts.map +1 -0
  58. package/dist/ui/IconButton/index.d.ts +2 -0
  59. package/dist/ui/IconButton/index.d.ts.map +1 -0
  60. package/dist/{src/ui → ui}/Icons/AgentIcon.d.ts +2 -1
  61. package/dist/ui/Icons/AgentIcon.d.ts.map +1 -0
  62. package/dist/{src/ui → ui}/Icons/ToolsIcon.d.ts +2 -1
  63. package/dist/ui/Icons/ToolsIcon.d.ts.map +1 -0
  64. package/dist/{src/ui → ui}/Icons/WorkflowIcon.d.ts +2 -1
  65. package/dist/ui/Icons/WorkflowIcon.d.ts.map +1 -0
  66. package/dist/ui/Icons/index.d.ts +4 -0
  67. package/dist/ui/Icons/index.d.ts.map +1 -0
  68. package/dist/{src/ui → ui}/Message/Message.d.ts +2 -1
  69. package/dist/ui/Message/Message.d.ts.map +1 -0
  70. package/dist/ui/Message/index.d.ts +2 -0
  71. package/dist/ui/Message/index.d.ts.map +1 -0
  72. package/dist/ui/MessageFactory/MessageFactory.d.ts +22 -0
  73. package/dist/ui/MessageFactory/MessageFactory.d.ts.map +1 -0
  74. package/dist/ui/MessageFactory/index.d.ts +3 -0
  75. package/dist/ui/MessageFactory/index.d.ts.map +1 -0
  76. package/dist/ui/MessageFactory/types.d.ts +181 -0
  77. package/dist/ui/MessageFactory/types.d.ts.map +1 -0
  78. package/dist/{src/ui → ui}/Tooltip/Tooltip.d.ts +2 -1
  79. package/dist/ui/Tooltip/Tooltip.d.ts.map +1 -0
  80. package/dist/ui/Tooltip/index.d.ts +2 -0
  81. package/dist/ui/Tooltip/index.d.ts.map +1 -0
  82. package/dist/ui/index.d.ts +9 -0
  83. package/dist/ui/index.d.ts.map +1 -0
  84. package/dist/voice/index.d.ts +5 -0
  85. package/dist/voice/index.d.ts.map +1 -0
  86. package/dist/voice/play-stream-with-web-audio.d.ts +2 -0
  87. package/dist/voice/play-stream-with-web-audio.d.ts.map +1 -0
  88. package/dist/voice/record-mic-to-file.d.ts +2 -0
  89. package/dist/voice/record-mic-to-file.d.ts.map +1 -0
  90. package/dist/voice/use-speech-recognition.d.ts +20 -0
  91. package/dist/voice/use-speech-recognition.d.ts.map +1 -0
  92. package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts +8 -0
  93. package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts.map +1 -0
  94. package/dist/workflows/WorkflowStepFactory/index.d.ts +3 -0
  95. package/dist/workflows/WorkflowStepFactory/index.d.ts.map +1 -0
  96. package/dist/workflows/WorkflowStepFactory/types.d.ts +72 -0
  97. package/dist/workflows/WorkflowStepFactory/types.d.ts.map +1 -0
  98. package/dist/workflows/hooks.d.ts +34 -0
  99. package/dist/workflows/hooks.d.ts.map +1 -0
  100. package/dist/workflows/index.d.ts +4 -0
  101. package/dist/workflows/index.d.ts.map +1 -0
  102. package/dist/workflows/types.d.ts +122 -0
  103. package/dist/workflows/types.d.ts.map +1 -0
  104. package/dist/workflows/use-stream-workflow.d.ts +39 -0
  105. package/dist/workflows/use-stream-workflow.d.ts.map +1 -0
  106. package/package.json +35 -31
  107. package/dist/chunk-55VPMN3N-Ax1F4Y75.js +0 -249
  108. package/dist/chunk-55VPMN3N-Ax1F4Y75.js.map +0 -1
  109. package/dist/chunk-55VPMN3N-BHqoDkCq.cjs +0 -251
  110. package/dist/chunk-55VPMN3N-BHqoDkCq.cjs.map +0 -1
  111. package/dist/index-BaK_Y6TP.cjs +0 -185
  112. package/dist/index-BaK_Y6TP.cjs.map +0 -1
  113. package/dist/index-C1OzXW5i.js +0 -180
  114. package/dist/index-C1OzXW5i.js.map +0 -1
  115. package/dist/index-ChvWx-iU.cjs +0 -20711
  116. package/dist/index-ChvWx-iU.cjs.map +0 -1
  117. package/dist/index-D3JtF_Zl.js +0 -20628
  118. package/dist/index-D3JtF_Zl.js.map +0 -1
  119. package/dist/src/agent/hooks.d.ts +0 -65
  120. package/dist/src/index.d.ts +0 -6
  121. package/dist/src/lib/ai-sdk/index.d.ts +0 -4
  122. package/dist/src/lib/ai-sdk/memory/resolveInitialMessages.d.ts +0 -12
  123. package/dist/src/lib/ai-sdk/memory/resolveInitialMessages.test.d.ts +0 -1
  124. package/dist/src/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts +0 -10
  125. package/dist/src/lib/ai-sdk/transformers/AISdkNetworkTransformer.test.d.ts +0 -1
  126. package/dist/src/lib/ai-sdk/transformers/types.d.ts +0 -10
  127. package/dist/src/lib/ai-sdk/types.d.ts +0 -106
  128. package/dist/src/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.d.ts +0 -10
  129. package/dist/src/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.test.d.ts +0 -1
  130. package/dist/src/lib/ai-sdk/utils/toAssistantUIMessage.d.ts +0 -14
  131. package/dist/src/lib/ai-sdk/utils/toAssistantUIMessage.test.d.ts +0 -1
  132. package/dist/src/lib/ai-sdk/utils/toUIMessage.d.ts +0 -17
  133. package/dist/src/lib/ai-sdk/utils/toUIMessage.test.d.ts +0 -1
  134. package/dist/src/mastra-client-context.d.ts +0 -10
  135. package/dist/src/mastra-react-provider.d.ts +0 -4
  136. package/dist/src/ui/Code/highlight.d.ts +0 -3
  137. package/dist/src/ui/Code/index.d.ts +0 -1
  138. package/dist/src/ui/Entity/Entity.stories.d.ts +0 -22
  139. package/dist/src/ui/Entity/index.d.ts +0 -4
  140. package/dist/src/ui/Icon/index.d.ts +0 -1
  141. package/dist/src/ui/IconButton/IconButton.stories.d.ts +0 -12
  142. package/dist/src/ui/IconButton/index.d.ts +0 -1
  143. package/dist/src/ui/Icons/index.d.ts +0 -3
  144. package/dist/src/ui/Message/Message.stories.d.ts +0 -13
  145. package/dist/src/ui/Message/index.d.ts +0 -1
  146. package/dist/src/ui/Tooltip/Tooltip.stories.d.ts +0 -12
  147. package/dist/src/ui/Tooltip/index.d.ts +0 -1
  148. package/dist/src/ui/index.d.ts +0 -7
  149. package/dist/token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs +0 -64
  150. package/dist/token-6GSAFR2W-SPYPLMBM-CWoxKwfk.cjs.map +0 -1
  151. package/dist/token-6GSAFR2W-SPYPLMBM-ChURikIE.js +0 -60
  152. package/dist/token-6GSAFR2W-SPYPLMBM-ChURikIE.js.map +0 -1
  153. package/dist/token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs +0 -11
  154. package/dist/token-util-NEHG7TUY-JRJTGTAB-BU9ZxL1w.cjs.map +0 -1
  155. package/dist/token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js +0 -7
  156. package/dist/token-util-NEHG7TUY-JRJTGTAB-hEay2AHp.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ import type { MastraDBMessage, MastraMessagePart } from '@mastra/core/agent/message-list';
2
+ import type { ChunkType, NetworkChunkType } from '@mastra/core/stream';
3
+ import type { WorkflowStreamResult } from '@mastra/core/workflows';
4
+ import type { MastraDBMessageMetadata } from './types.js';
5
+ type StreamChunk = {
6
+ type: string;
7
+ payload: any;
8
+ runId: string;
9
+ from: 'AGENT' | 'WORKFLOW';
10
+ };
11
+ declare const partProviderMetadata: (part: MastraMessagePart) => Record<string, unknown> | undefined;
12
+ /**
13
+ * Set any streaming text/reasoning parts on the trailing assistant message to
14
+ * `state: 'done'`. Mirrors the previous `finishStreamingAssistantMessage` from
15
+ * the AI-SDK accumulator.
16
+ */
17
+ export declare const finishStreamingAssistantMessage: (conversation: MastraDBMessage[]) => MastraDBMessage[];
18
+ /**
19
+ * Workflow chunk accumulation. Mirrors
20
+ * `mapWorkflowStreamChunkToWatchResult` from the previous accumulator.
21
+ */
22
+ export declare const mapWorkflowStreamChunkToWatchResult: (prev: WorkflowStreamResult<any, any, any, any>, chunk: StreamChunk) => WorkflowStreamResult<any, any, any, any>;
23
+ export interface AccumulateChunkArgs {
24
+ chunk: ChunkType;
25
+ conversation: MastraDBMessage[];
26
+ metadata: MastraDBMessageMetadata;
27
+ }
28
+ /**
29
+ * Reduce a single stream chunk into the running `MastraDBMessage[]`
30
+ * conversation. The accumulator owns the entire chunk→DB mapping for the
31
+ * React SDK; consumers downstream (e.g. `toAISdkV5Messages` in the playground)
32
+ * translate the result into AI SDK / assistant-ui shapes as needed.
33
+ */
34
+ export declare const accumulateChunk: ({ chunk, conversation, metadata }: AccumulateChunkArgs) => MastraDBMessage[];
35
+ export interface AccumulateNetworkChunkArgs {
36
+ chunk: NetworkChunkType;
37
+ conversation: MastraDBMessage[];
38
+ metadata: MastraDBMessageMetadata;
39
+ }
40
+ /**
41
+ * Reduce a single network-mode chunk into the running `MastraDBMessage[]`
42
+ * conversation. Ports the historical `AISdkNetworkTransformer` so the playground
43
+ * keeps rendering network badges (routing text, agent/workflow/tool execution,
44
+ * suspensions, approvals, completion feedback) until the next major.
45
+ */
46
+ export declare const accumulateNetworkChunk: ({ chunk, conversation, metadata, }: AccumulateNetworkChunkArgs) => MastraDBMessage[];
47
+ export { partProviderMetadata as __partProviderMetadata };
48
+ //# sourceMappingURL=accumulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accumulator.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/accumulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EAIlB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAkB,SAAS,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,wBAAwB,CAAC;AAG/E,OAAO,KAAK,EAEV,uBAAuB,EAIxB,MAAM,SAAS,CAAC;AAiBjB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;CAC5B,CAAC;AA+EF,QAAA,MAAM,oBAAoB,GAAI,MAAM,iBAAiB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SACP,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAAI,cAAc,eAAe,EAAE,KAAG,eAAe,EAgBhG,CAAC;AAqFF;;;GAGG;AACH,eAAO,MAAM,mCAAmC,GAC9C,MAAM,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,OAAO,WAAW,KACjB,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAoFzC,CAAC;AA2GF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,mCAAmC,mBAAmB,KAAG,eAAe,EAsgCvG,CAAC;AAuJF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAwZD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,oCAIpC,0BAA0B,KAAG,eAAe,EAuE9C,CAAC;AAGF,OAAO,EAAE,oBAAoB,IAAI,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ type CompletionScorerResult = {
2
+ duration?: number;
3
+ passed: boolean;
4
+ reason?: string;
5
+ score: number;
6
+ scorerId: string;
7
+ scorerName: string;
8
+ };
9
+ type CompletionResult = {
10
+ complete: boolean;
11
+ completionReason?: string;
12
+ scorers: CompletionScorerResult[];
13
+ timedOut: boolean;
14
+ totalDuration: number;
15
+ };
16
+ export declare const formatCompletionFeedback: (result: CompletionResult, maxIterationReached: boolean) => string;
17
+ export declare const formatStreamCompletionFeedback: (result: CompletionResult, maxIterationReached: boolean) => string;
18
+ export {};
19
+ //# sourceMappingURL=formatCompletionFeedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatCompletionFeedback.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/formatCompletionFeedback.ts"],"names":[],"mappings":"AAAA,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAyCF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,gBAAgB,EAAE,qBAAqB,OAAO,KAAG,MAOjG,CAAC;AAEF,eAAO,MAAM,8BAA8B,GAAI,QAAQ,gBAAgB,EAAE,qBAAqB,OAAO,KAAG,MAOvG,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { MastraDBMessage } from '@mastra/core/agent/message-list';
2
+ import type { CoreUserMessage } from '@mastra/core/llm';
3
+ export declare const fromCoreUserMessageToMastraDBMessage: (coreUserMessage: CoreUserMessage) => MastraDBMessage;
4
+ /**
5
+ * Merge multiple `CoreUserMessage`s into a single canonical `MastraDBMessage`.
6
+ *
7
+ * A user turn that carries attachments arrives as several `CoreUserMessage`s
8
+ * (one for the text, one per attachment). Memory/reload persists and resolves
9
+ * that whole turn as a single multi-part user message, so the optimistic
10
+ * streaming display must do the same — flatten every message's parts into one
11
+ * `parts` array — to render identically (one bubble, not one per message).
12
+ */
13
+ export declare const fromCoreUserMessagesToMastraDBMessage: (coreUserMessages: CoreUserMessage[]) => MastraDBMessage;
14
+ //# sourceMappingURL=fromCoreUserMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fromCoreUserMessage.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/fromCoreUserMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,iCAAiC,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAyDxD,eAAO,MAAM,oCAAoC,GAAI,iBAAiB,eAAe,KAAG,eAC/B,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,qCAAqC,GAAI,kBAAkB,eAAe,EAAE,KAAG,eAC1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { accumulateChunk, accumulateNetworkChunk, finishStreamingAssistantMessage, mapWorkflowStreamChunkToWatchResult, } from './accumulator.js';
2
+ export type { AccumulateChunkArgs, AccumulateNetworkChunkArgs } from './accumulator.js';
3
+ export { fromCoreUserMessageToMastraDBMessage, fromCoreUserMessagesToMastraDBMessage } from './fromCoreUserMessage.js';
4
+ export { CLIENT_MESSAGE_ID_KEY } from './types.js';
5
+ export type { AccumulatorPart, BackgroundTaskEntry, CompletionResult, MastraDBMessageMetadata, MastraReasoningPart, MastraTextPart, PendingToolApprovalEntry, RequireApprovalEntry, SuspendedToolEntry, TripwireMetadata, } from './types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,mCAAmC,GACpC,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,oCAAoC,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,171 @@
1
+ import type { MastraMessagePart, AIV5Type } from '@mastra/core/agent/message-list';
2
+ import type { TripwirePayload } from '@mastra/core/stream';
3
+ export type MastraProviderMetadata = Record<string, Record<string, unknown>>;
4
+ /**
5
+ * Tripwire metadata included when a processor triggers a tripwire.
6
+ * Canonical shape sourced from core's `tripwire` stream-chunk payload.
7
+ */
8
+ export type TripwireMetadata = TripwirePayload;
9
+ export type ToolApprovalArgs = Record<string, unknown>;
10
+ export type RequireApprovalEntry = {
11
+ toolCallId: string;
12
+ toolName: string;
13
+ args: ToolApprovalArgs;
14
+ runId?: string;
15
+ };
16
+ export type SuspendedToolEntry = {
17
+ toolCallId: string;
18
+ toolName: string;
19
+ args: ToolApprovalArgs;
20
+ suspendPayload: unknown;
21
+ runId?: string;
22
+ };
23
+ export type PendingToolApprovalEntry = {
24
+ toolCallId: string;
25
+ toolName: string;
26
+ args: ToolApprovalArgs;
27
+ runId?: string;
28
+ };
29
+ export type BackgroundTaskEntry = {
30
+ startedAt: Date;
31
+ completedAt?: Date;
32
+ suspendedAt?: Date;
33
+ taskId: string;
34
+ };
35
+ export type CompletionResult = {
36
+ passed: boolean;
37
+ suppressFeedback?: boolean;
38
+ };
39
+ /**
40
+ * Canonical metadata block stored under `MastraDBMessage.content.metadata`.
41
+ *
42
+ * Every UX hint the React accumulator needs to surface lives here. Mode-specific
43
+ * fields are all optional so a single record can carry the union without forcing
44
+ * narrowing on the consumer side.
45
+ */
46
+ /**
47
+ * Metadata key carrying a client-generated correlation id. The optimistic
48
+ * pending user bubble and the outgoing `sendMessage` request both stamp this
49
+ * id; the server echoes it back on the `data-user-message` data part so the
50
+ * accumulator can reconcile the pending bubble deterministically (decoupled
51
+ * from the server-assigned signal id). This is transient client state and is
52
+ * stripped once the echo is reconciled and on reload.
53
+ */
54
+ export declare const CLIENT_MESSAGE_ID_KEY = "clientMessageId";
55
+ export type MastraDBMessageMetadata = {
56
+ /** Which run mode produced this message. */
57
+ mode?: 'generate' | 'stream' | 'network';
58
+ /** Client-generated correlation id (see {@link CLIENT_MESSAGE_ID_KEY}). */
59
+ clientMessageId?: string;
60
+ /**
61
+ * Streaming/abort/error/tripwire surface status. `'pending'` marks an
62
+ * optimistically-appended user message that is awaiting its server signal
63
+ * echo; it is cleared once the echo arrives and is stripped on reload.
64
+ */
65
+ status?: 'warning' | 'error' | 'tripwire' | 'pending';
66
+ /** Reason recorded by the upstream stream when it finishes. */
67
+ finishReason?: string;
68
+ /** Tripwire metadata when status === 'tripwire'. */
69
+ tripwire?: TripwireMetadata;
70
+ /** Per-toolName approval requirements declared mid-stream. */
71
+ requireApprovalMetadata?: Record<string, RequireApprovalEntry>;
72
+ /** Per-toolName suspension records from suspended tool calls. */
73
+ suspendedTools?: Record<string, SuspendedToolEntry>;
74
+ /** Pending approvals keyed by toolCallId (for runtime resolution). */
75
+ pendingToolApprovals?: Record<string, PendingToolApprovalEntry>;
76
+ /** Per-toolCallId background-task bookkeeping. */
77
+ backgroundTasks?: Record<string, BackgroundTaskEntry>;
78
+ /** Number of background tasks currently executing for this message. */
79
+ runningBackgroundTasksCount?: number;
80
+ /** Task-completion result returned by the run (network mode). */
81
+ completionResult?: CompletionResult;
82
+ /**
83
+ * Task-completion verdict from the supervisor `isTaskComplete` path. Shares
84
+ * the `{ passed, suppressFeedback }` shape with `completionResult`; core
85
+ * persists it as an object and reads it back as one (see `MessageMerger`).
86
+ */
87
+ isTaskCompleteResult?: CompletionResult;
88
+ /** Signal-echo dedupe: signalId of the user message echoed back. */
89
+ signalEchoIds?: string[];
90
+ /** Network-mode bookkeeping. */
91
+ from?: 'AGENT' | 'WORKFLOW' | 'TOOL';
92
+ selectionReason?: string;
93
+ agentInput?: string | object | Array<object>;
94
+ hasMoreMessages?: boolean;
95
+ /**
96
+ * Structured decision emitted by the routing agent. Parsed from the
97
+ * routing-agent text stream when it forms a balanced JSON object so the
98
+ * raw payload never reaches the rendered thread.
99
+ */
100
+ routingDecision?: Record<string, unknown>;
101
+ /**
102
+ * Raw routing-agent text used when the stream did not parse as JSON. Kept
103
+ * out of the visible parts but exposed for downstream UI (badge tooltips,
104
+ * metadata dialogs, debugging).
105
+ */
106
+ routingDecisionText?: string;
107
+ /**
108
+ * Internal buffer for partial routing-agent text deltas. Cleared once the
109
+ * buffer parses as JSON and is promoted to `routingDecision`.
110
+ */
111
+ routingDecisionBuffer?: string;
112
+ };
113
+ /**
114
+ * Mastra-extended text part. Adds `textId` (per-stream identifier) and
115
+ * `state` (streaming/done) on top of the V4 text part shape, mirroring the
116
+ * `MastraStepStartPart` extension pattern in core.
117
+ */
118
+ export type MastraTextPart = {
119
+ type: 'text';
120
+ text: string;
121
+ textId?: string;
122
+ state?: 'streaming' | 'done';
123
+ providerMetadata?: MastraProviderMetadata;
124
+ createdAt?: number;
125
+ };
126
+ /**
127
+ * Mastra-extended reasoning part with per-stream identifier and streaming state.
128
+ * `redacted: true` indicates the upstream provider redacted the reasoning content.
129
+ */
130
+ export type MastraReasoningPart = {
131
+ type: 'reasoning';
132
+ reasoning: string;
133
+ reasoningId?: string;
134
+ state?: 'streaming' | 'done';
135
+ redacted?: boolean;
136
+ providerMetadata?: MastraProviderMetadata;
137
+ createdAt?: number;
138
+ };
139
+ /**
140
+ * Streaming buffer attached to a tool-invocation part while `tool-call-delta`
141
+ * fragments arrive. The accumulator concatenates JSON chunks into `argsText`
142
+ * and parses them on `tool-call-input-streaming-end`. Stored alongside the
143
+ * canonical `args` so the persisted shape still satisfies `MastraDBMessage`.
144
+ */
145
+ export type StreamingToolInvocationExtension = {
146
+ argsText?: string;
147
+ };
148
+ /**
149
+ * Custom `data-*` chunk part shape persisted on a `MastraDBMessage`. Mirrors
150
+ * AI SDK v5 `DataUIPart` structurally so it is structurally compatible with
151
+ * `MastraMessagePart`, while keeping the React-side accumulator independent
152
+ * of the v5 type machinery.
153
+ */
154
+ export type StreamingDataPart = {
155
+ type: `data-${string}`;
156
+ data: unknown;
157
+ id?: string;
158
+ };
159
+ /**
160
+ * Union of part types the accumulator emits. Compatible with `MastraMessagePart`
161
+ * at runtime; the extended text/reasoning parts add optional fields that
162
+ * downstream consumers (e.g. `AIV5Adapter.toUIMessage`) preserve via
163
+ * providerMetadata round-tripping.
164
+ *
165
+ * `AIV5Type.SourceUrlUIPart` is the flat `type: 'source-url'` shape the
166
+ * accumulator actually pushes for URL source citations (the typed
167
+ * `MastraMessagePart` only models the nested `type: 'source'` shape), so it is
168
+ * listed explicitly as a first-class member of the runtime union.
169
+ */
170
+ export type AccumulatorPart = MastraMessagePart | MastraTextPart | MastraReasoningPart | StreamingDataPart | AIV5Type.SourceUrlUIPart;
171
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CA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B,IAAI,EAAE,QAAQ,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,cAAc,GACd,mBAAmB,GACnB,iBAAiB,GACjB,QAAQ,CAAC,eAAe,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Represents the state of a mutation operation.
3
+ * Mimics the essential return type of react-query's useMutation.
4
+ */
5
+ export interface MutationState<TData, TError extends Error, TVariables> {
6
+ /** Execute the mutation without waiting for the result */
7
+ mutate: (variables: TVariables) => void;
8
+ /** Execute the mutation and return a promise with the result */
9
+ mutateAsync: (variables: TVariables) => Promise<TData>;
10
+ /** Whether the mutation is currently executing */
11
+ isPending: boolean;
12
+ /** Whether the mutation completed successfully */
13
+ isSuccess: boolean;
14
+ /** Whether the mutation failed with an error */
15
+ isError: boolean;
16
+ /** The error if the mutation failed, null otherwise */
17
+ error: TError | null;
18
+ /** The data returned by the mutation if successful */
19
+ data: TData | undefined;
20
+ /** Reset the mutation state to initial values */
21
+ reset: () => void;
22
+ }
23
+ /**
24
+ * Internal helper hook that provides mutation-like functionality without react-query.
25
+ * Tracks pending, success, and error states for async operations.
26
+ */
27
+ export declare function useMutation<TData, TError extends Error, TVariables>(mutationFn: (variables: TVariables) => Promise<TData>): MutationState<TData, TError, TVariables>;
28
+ //# sourceMappingURL=use-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mutation.d.ts","sourceRoot":"","sources":["../../src/lib/use-mutation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,EAAE,MAAM,SAAS,KAAK,EAAE,UAAU;IACpE,0DAA0D;IAC1D,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,gEAAgE;IAChE,WAAW,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACvD,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,sDAAsD;IACtD,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,iDAAiD;IACjD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,SAAS,KAAK,EAAE,UAAU,EACjE,UAAU,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,KAAK,CAAC,GACpD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CA0D1C"}
@@ -0,0 +1,26 @@
1
+ import { MastraClient } from '@mastra/client-js';
2
+ import type { ReactNode } from 'react';
3
+ export type MastraClientContextType = MastraClient;
4
+ /** Passed through to `fetch` / `MastraClient`. Default `include` sends cookies on cross-origin Studio → API requests. */
5
+ export type MastraClientCredentials = 'omit' | 'same-origin' | 'include';
6
+ export interface MastraClientProviderProps {
7
+ children: ReactNode;
8
+ baseUrl?: string;
9
+ headers?: Record<string, string>;
10
+ /** API route prefix. Defaults to '/api'. Set this to match your server's apiPrefix configuration. */
11
+ apiPrefix?: string;
12
+ /**
13
+ * Credentials mode for API requests. Defaults to `include` so session cookies reach a custom server when Studio and API differ by origin/port.
14
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials
15
+ */
16
+ credentials?: MastraClientCredentials;
17
+ /**
18
+ * Custom fetch function for HTTP requests. Useful for adding middleware like auth refresh.
19
+ * When provided, this overrides the default fetch behavior.
20
+ */
21
+ customFetch?: typeof fetch;
22
+ }
23
+ export declare const MastraClientProvider: ({ children, baseUrl, headers, apiPrefix, credentials, customFetch, }: MastraClientProviderProps) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const useMastraClient: () => MastraClient;
25
+ export declare const isLocalUrl: (url?: string) => boolean;
26
+ //# sourceMappingURL=mastra-client-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra-client-context.d.ts","sourceRoot":"","sources":["../src/mastra-client-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAInD,yHAAyH;AACzH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,qGAAqG;IACrG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AAED,eAAO,MAAM,oBAAoB,GAAI,sEAOlC,yBAAyB,4CAI3B,CAAC;AAEF,eAAO,MAAM,eAAe,oBAAwC,CAAC;AAUrE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,OAczC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { MastraClientProviderProps } from './mastra-client-context.js';
2
+ type MastraReactProviderProps = MastraClientProviderProps;
3
+ export declare const MastraReactProvider: ({ children, baseUrl, headers, apiPrefix, credentials, customFetch, }: MastraReactProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ export {};
5
+ //# sourceMappingURL=mastra-react-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra-react-provider.d.ts","sourceRoot":"","sources":["../src/mastra-react-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,KAAK,wBAAwB,GAAG,yBAAyB,CAAC;AAE1D,eAAO,MAAM,mBAAmB,GAAI,sEAOjC,wBAAwB,4CAY1B,CAAC"}