@mastra/react 0.4.3-alpha.9 → 0.5.0-alpha.0

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 (49) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/agent/extractRunIdFromMessages.d.ts +9 -2
  3. package/dist/agent/extractRunIdFromMessages.d.ts.map +1 -1
  4. package/dist/agent/hooks.d.ts +9 -11
  5. package/dist/agent/hooks.d.ts.map +1 -1
  6. package/dist/agent/types.d.ts +5 -1
  7. package/dist/agent/types.d.ts.map +1 -1
  8. package/dist/index.cjs +1342 -1476
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1342 -1476
  13. package/dist/index.js.map +1 -1
  14. package/dist/lib/mastra-db/accumulator.d.ts +48 -0
  15. package/dist/lib/mastra-db/accumulator.d.ts.map +1 -0
  16. package/dist/lib/mastra-db/formatCompletionFeedback.d.ts.map +1 -0
  17. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +11 -0
  18. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -0
  19. package/dist/lib/mastra-db/index.d.ts +5 -0
  20. package/dist/lib/mastra-db/index.d.ts.map +1 -0
  21. package/dist/lib/mastra-db/types.d.ts +156 -0
  22. package/dist/lib/mastra-db/types.d.ts.map +1 -0
  23. package/dist/ui/MessageFactory/MessageFactory.d.ts +22 -0
  24. package/dist/ui/MessageFactory/MessageFactory.d.ts.map +1 -0
  25. package/dist/ui/MessageFactory/index.d.ts +3 -0
  26. package/dist/ui/MessageFactory/index.d.ts.map +1 -0
  27. package/dist/ui/MessageFactory/types.d.ts +164 -0
  28. package/dist/ui/MessageFactory/types.d.ts.map +1 -0
  29. package/dist/ui/index.d.ts +1 -0
  30. package/dist/ui/index.d.ts.map +1 -1
  31. package/package.json +6 -10
  32. package/dist/lib/ai-sdk/index.d.ts +0 -5
  33. package/dist/lib/ai-sdk/index.d.ts.map +0 -1
  34. package/dist/lib/ai-sdk/memory/resolveInitialMessages.d.ts +0 -13
  35. package/dist/lib/ai-sdk/memory/resolveInitialMessages.d.ts.map +0 -1
  36. package/dist/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts +0 -11
  37. package/dist/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts.map +0 -1
  38. package/dist/lib/ai-sdk/transformers/types.d.ts +0 -11
  39. package/dist/lib/ai-sdk/transformers/types.d.ts.map +0 -1
  40. package/dist/lib/ai-sdk/types.d.ts +0 -145
  41. package/dist/lib/ai-sdk/types.d.ts.map +0 -1
  42. package/dist/lib/ai-sdk/utils/formatCompletionFeedback.d.ts.map +0 -1
  43. package/dist/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.d.ts +0 -11
  44. package/dist/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.d.ts.map +0 -1
  45. package/dist/lib/ai-sdk/utils/toAssistantUIMessage.d.ts +0 -15
  46. package/dist/lib/ai-sdk/utils/toAssistantUIMessage.d.ts.map +0 -1
  47. package/dist/lib/ai-sdk/utils/toUIMessage.d.ts +0 -20
  48. package/dist/lib/ai-sdk/utils/toUIMessage.d.ts.map +0 -1
  49. /package/dist/lib/{ai-sdk/utils → mastra-db}/formatCompletionFeedback.d.ts +0 -0
@@ -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,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B,IAAI,sBAAsB,EAAE,CAAC"}
@@ -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,11 @@
1
+ import type { MastraDBMessage } from '@mastra/core/agent/message-list';
2
+ import type { CoreUserMessage } from '@mastra/core/llm';
3
+ /**
4
+ * Convert a CoreUserMessage into a canonical `MastraDBMessage` (`format: 2`).
5
+ *
6
+ * Handles all CoreUserMessage content types:
7
+ * - String content → single text part
8
+ * - Array content with text/image/file parts → corresponding `MastraMessagePart`s
9
+ */
10
+ export declare const fromCoreUserMessageToMastraDBMessage: (coreUserMessage: CoreUserMessage) => MastraDBMessage;
11
+ //# 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;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC,GAAI,iBAAiB,eAAe,KAAG,eA8CvF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { accumulateChunk, accumulateNetworkChunk, finishStreamingAssistantMessage, mapWorkflowStreamChunkToWatchResult, } from './accumulator.js';
2
+ export type { AccumulateChunkArgs, AccumulateNetworkChunkArgs } from './accumulator.js';
3
+ export { fromCoreUserMessageToMastraDBMessage } from './fromCoreUserMessage.js';
4
+ export type { AccumulatorPart, BackgroundTaskEntry, CompletionResult, MastraDBMessageMetadata, MastraReasoningPart, MastraTextPart, PendingToolApprovalEntry, RequireApprovalEntry, SuspendedToolEntry, TripwireMetadata, } from './types.js';
5
+ //# 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,MAAM,uBAAuB,CAAC;AAC7E,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,156 @@
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
+ export type MastraDBMessageMetadata = {
47
+ /** Which run mode produced this message. */
48
+ mode?: 'generate' | 'stream' | 'network';
49
+ /** Streaming/abort/error/tripwire surface status. */
50
+ status?: 'warning' | 'error' | 'tripwire';
51
+ /** Reason recorded by the upstream stream when it finishes. */
52
+ finishReason?: string;
53
+ /** Tripwire metadata when status === 'tripwire'. */
54
+ tripwire?: TripwireMetadata;
55
+ /** Per-toolName approval requirements declared mid-stream. */
56
+ requireApprovalMetadata?: Record<string, RequireApprovalEntry>;
57
+ /** Per-toolName suspension records from suspended tool calls. */
58
+ suspendedTools?: Record<string, SuspendedToolEntry>;
59
+ /** Pending approvals keyed by toolCallId (for runtime resolution). */
60
+ pendingToolApprovals?: Record<string, PendingToolApprovalEntry>;
61
+ /** Per-toolCallId background-task bookkeeping. */
62
+ backgroundTasks?: Record<string, BackgroundTaskEntry>;
63
+ /** Number of background tasks currently executing for this message. */
64
+ runningBackgroundTasksCount?: number;
65
+ /** Task-completion result returned by the run (network mode). */
66
+ completionResult?: CompletionResult;
67
+ /**
68
+ * Task-completion verdict from the supervisor `isTaskComplete` path. Shares
69
+ * the `{ passed, suppressFeedback }` shape with `completionResult`; core
70
+ * persists it as an object and reads it back as one (see `MessageMerger`).
71
+ */
72
+ isTaskCompleteResult?: CompletionResult;
73
+ /** Signal-echo dedupe: signalId of the user message echoed back. */
74
+ signalEchoIds?: string[];
75
+ /** Network-mode bookkeeping. */
76
+ from?: 'AGENT' | 'WORKFLOW' | 'TOOL';
77
+ selectionReason?: string;
78
+ agentInput?: string | object | Array<object>;
79
+ hasMoreMessages?: boolean;
80
+ /**
81
+ * Structured decision emitted by the routing agent. Parsed from the
82
+ * routing-agent text stream when it forms a balanced JSON object so the
83
+ * raw payload never reaches the rendered thread.
84
+ */
85
+ routingDecision?: Record<string, unknown>;
86
+ /**
87
+ * Raw routing-agent text used when the stream did not parse as JSON. Kept
88
+ * out of the visible parts but exposed for downstream UI (badge tooltips,
89
+ * metadata dialogs, debugging).
90
+ */
91
+ routingDecisionText?: string;
92
+ /**
93
+ * Internal buffer for partial routing-agent text deltas. Cleared once the
94
+ * buffer parses as JSON and is promoted to `routingDecision`.
95
+ */
96
+ routingDecisionBuffer?: string;
97
+ };
98
+ /**
99
+ * Mastra-extended text part. Adds `textId` (per-stream identifier) and
100
+ * `state` (streaming/done) on top of the V4 text part shape, mirroring the
101
+ * `MastraStepStartPart` extension pattern in core.
102
+ */
103
+ export type MastraTextPart = {
104
+ type: 'text';
105
+ text: string;
106
+ textId?: string;
107
+ state?: 'streaming' | 'done';
108
+ providerMetadata?: MastraProviderMetadata;
109
+ createdAt?: number;
110
+ };
111
+ /**
112
+ * Mastra-extended reasoning part with per-stream identifier and streaming state.
113
+ * `redacted: true` indicates the upstream provider redacted the reasoning content.
114
+ */
115
+ export type MastraReasoningPart = {
116
+ type: 'reasoning';
117
+ reasoning: string;
118
+ reasoningId?: string;
119
+ state?: 'streaming' | 'done';
120
+ redacted?: boolean;
121
+ providerMetadata?: MastraProviderMetadata;
122
+ createdAt?: number;
123
+ };
124
+ /**
125
+ * Streaming buffer attached to a tool-invocation part while `tool-call-delta`
126
+ * fragments arrive. The accumulator concatenates JSON chunks into `argsText`
127
+ * and parses them on `tool-call-input-streaming-end`. Stored alongside the
128
+ * canonical `args` so the persisted shape still satisfies `MastraDBMessage`.
129
+ */
130
+ export type StreamingToolInvocationExtension = {
131
+ argsText?: string;
132
+ };
133
+ /**
134
+ * Custom `data-*` chunk part shape persisted on a `MastraDBMessage`. Mirrors
135
+ * AI SDK v5 `DataUIPart` structurally so it is structurally compatible with
136
+ * `MastraMessagePart`, while keeping the React-side accumulator independent
137
+ * of the v5 type machinery.
138
+ */
139
+ export type StreamingDataPart = {
140
+ type: `data-${string}`;
141
+ data: unknown;
142
+ id?: string;
143
+ };
144
+ /**
145
+ * Union of part types the accumulator emits. Compatible with `MastraMessagePart`
146
+ * at runtime; the extended text/reasoning parts add optional fields that
147
+ * downstream consumers (e.g. `AIV5Adapter.toUIMessage`) preserve via
148
+ * providerMetadata round-tripping.
149
+ *
150
+ * `AIV5Type.SourceUrlUIPart` is the flat `type: 'source-url'` shape the
151
+ * accumulator actually pushes for URL source citations (the typed
152
+ * `MastraMessagePart` only models the nested `type: 'source'` shape), so it is
153
+ * listed explicitly as a first-class member of the runtime union.
154
+ */
155
+ export type AccumulatorPart = MastraMessagePart | MastraTextPart | MastraReasoningPart | StreamingDataPart | AIV5Type.SourceUrlUIPart;
156
+ //# 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;AACn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MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,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,22 @@
1
+ import type { MastraDBMessage } from '@mastra/core/agent/message-list';
2
+ import type { ReactNode } from 'react';
3
+ import type { AccumulatorPart } from '../../lib/mastra-db/index.js';
4
+ import type { DynamicToolPart, MessageRenderers, MessageRoleRenderers, MessageStatusRenderers } from './types.js';
5
+ export interface MessageFactoryProps extends MessageRenderers {
6
+ /** The message whose `content.parts` are rendered. */
7
+ message: MastraDBMessage;
8
+ /** Optional wrappers keyed off `message.role`. */
9
+ roles?: MessageRoleRenderers;
10
+ /** Optional message-level slots dispatched off `message.content.metadata`. */
11
+ status?: MessageStatusRenderers;
12
+ /** Rendered for any part that has no matching renderer. Defaults to `null`. */
13
+ fallback?: (part: AccumulatorPart | DynamicToolPart) => ReactNode;
14
+ }
15
+ /**
16
+ * Renders a single {@link MastraDBMessage} by dispatching each part in
17
+ * `content.parts` to an optional, type-safe, per-part-type render function.
18
+ * Only the renderer matching a part's `type` is invoked, and each renderer
19
+ * receives fully narrowed props.
20
+ */
21
+ export declare const MessageFactory: import("react").MemoExoticComponent<({ message, roles, status, fallback, ...renderers }: MessageFactoryProps) => import("react/jsx-runtime").JSX.Element>;
22
+ //# sourceMappingURL=MessageFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageFactory.d.ts","sourceRoot":"","sources":["../../../src/ui/MessageFactory/MessageFactory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,EAEV,eAAe,EAEf,gBAAgB,EAEhB,oBAAoB,EACpB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,sDAAsD;IACtD,OAAO,EAAE,eAAe,CAAC;IACzB,kDAAkD;IAClD,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,KAAK,SAAS,CAAC;CACnE;AAyND;;;;;GAKG;AACH,eAAO,MAAM,cAAc,2FAxD0D,mBAAmB,6CAwD7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './MessageFactory.js';
2
+ export type { MessageRenderers, MessageRoleRenderers, MessageRoleRendererProps, MessageStatusRenderers, TripwireRendererProps, WarningRendererProps, ErrorRendererProps, TaskRendererProps, DynamicToolPart, MessageFactoryPart, DataPart, PartByType, TextPart, ReasoningPart, FilePart, StepStartPart, ToolInvocationPart, SourceDocumentPart, SourceUrlPart, } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/MessageFactory/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,SAAS,CAAC"}
@@ -0,0 +1,164 @@
1
+ import type { MastraDBMessage, AIV5Type } from '@mastra/core/agent/message-list';
2
+ import type { IsTaskCompletePayload } from '@mastra/core/stream';
3
+ import type { ReactNode } from 'react';
4
+ import type { AccumulatorPart, TripwireMetadata } from '../../lib/mastra-db/index.js';
5
+ /**
6
+ * Extract the concrete part shape for a given discriminant from the runtime
7
+ * accumulator union. Deriving from the already-concrete `AccumulatorPart`
8
+ * (rather than the deeply-generic v4/v5 types) keeps these helpers cheap and
9
+ * avoids TS2589 ("type instantiation is excessively deep") at the call sites.
10
+ */
11
+ export type PartByType<T extends string> = Extract<AccumulatorPart, {
12
+ type: T;
13
+ }>;
14
+ /** Narrowed part shape passed to the `Text` renderer. */
15
+ export type TextPart = PartByType<'text'>;
16
+ /** Narrowed part shape passed to the `Reasoning` renderer. */
17
+ export type ReasoningPart = PartByType<'reasoning'>;
18
+ /** Narrowed part shape passed to the `File` renderer. */
19
+ export type FilePart = PartByType<'file'>;
20
+ /** Narrowed part shape passed to the `StepStart` renderer. */
21
+ export type StepStartPart = PartByType<'step-start'>;
22
+ /** Narrowed part shape passed to the `ToolInvocation` renderer. */
23
+ export type ToolInvocationPart = PartByType<'tool-invocation'>;
24
+ /** Narrowed part shape passed to the `SourceDocument` renderer. */
25
+ export type SourceDocumentPart = PartByType<'source-document'>;
26
+ /**
27
+ * Flat `source-url` citation shape passed to the `SourceUrl` renderer. Both the
28
+ * runtime `type: 'source-url'` part and the legacy persisted `type: 'source'`
29
+ * part (normalized) are dispatched with this shape.
30
+ */
31
+ export type SourceUrlPart = AIV5Type.SourceUrlUIPart;
32
+ /**
33
+ * The `data-${string}` member of the accumulator union (e.g. `data-signal`,
34
+ * `data-om-observation`). Matched at runtime via `type.startsWith('data-')`.
35
+ */
36
+ export type DataPart = Extract<AccumulatorPart, {
37
+ type: `data-${string}`;
38
+ }>;
39
+ /**
40
+ * Runtime-only tool part shape. `dynamic-tool` and the AI SDK v5 `tool-${string}`
41
+ * streaming variant are NOT members of the typed `MastraMessagePart` /
42
+ * `AccumulatorPart` union — the accumulator stores them via a boundary cast
43
+ * during network/agent-execution and OM (observational memory) flows
44
+ * (`src/lib/mastra-db/accumulator.ts`). They share the same structural fields
45
+ * and are treated identically by the agent-builder playground, so a single
46
+ * `DynamicTool` renderer covers both. Declared here explicitly because
47
+ * `Extract<AccumulatorPart, { type: 'dynamic-tool' }>` resolves to `never`.
48
+ */
49
+ export type DynamicToolPart = {
50
+ type: 'dynamic-tool' | `tool-${string}`;
51
+ toolName?: string;
52
+ toolCallId?: string;
53
+ state?: string;
54
+ input?: unknown;
55
+ output?: unknown;
56
+ };
57
+ /**
58
+ * Every part shape `MessageFactory` can dispatch at runtime: the typed
59
+ * accumulator union plus the boundary-cast `dynamic-tool` / `tool-${string}`
60
+ * parts. This is the single source of truth for the factory's internal
61
+ * `RuntimePart` and the precise union consumers (e.g. Storybook) should type
62
+ * part arrays against instead of `unknown[]`.
63
+ */
64
+ export type MessageFactoryPart = AccumulatorPart | DynamicToolPart;
65
+ /**
66
+ * Optional, per-part-type render functions. Each renderer receives the exact
67
+ * narrowed part shape for its discriminant, so destructuring is fully
68
+ * type-checked and only the renderer matching a part's `type` is ever invoked.
69
+ */
70
+ export type MessageRenderers = {
71
+ Text?: (part: PartByType<'text'>) => ReactNode;
72
+ Reasoning?: (part: PartByType<'reasoning'>) => ReactNode;
73
+ File?: (part: PartByType<'file'>) => ReactNode;
74
+ StepStart?: (part: PartByType<'step-start'>) => ReactNode;
75
+ ToolInvocation?: (part: PartByType<'tool-invocation'>) => ReactNode;
76
+ /**
77
+ * Receives the flat `source-url` citation shape ({@link AIV5Type.SourceUrlUIPart}).
78
+ * Both the runtime `type: 'source-url'` part and the legacy persisted
79
+ * `type: 'source'` part (whose nested `source` is normalized to this shape)
80
+ * are dispatched here, so the renderer always gets `sourceId`/`url`/`title`.
81
+ */
82
+ SourceUrl?: (part: SourceUrlPart) => ReactNode;
83
+ SourceDocument?: (part: PartByType<'source-document'>) => ReactNode;
84
+ Data?: (part: DataPart) => ReactNode;
85
+ /** Covers runtime-only `dynamic-tool` and AI SDK v5 `tool-${string}` parts. */
86
+ DynamicTool?: (part: DynamicToolPart) => ReactNode;
87
+ };
88
+ /**
89
+ * Props passed to an optional role-level wrapper. `children` is the rendered
90
+ * list of parts; the wrapper decides how to frame them for the message role.
91
+ */
92
+ export type MessageRoleRendererProps = {
93
+ message: MastraDBMessage;
94
+ children: ReactNode;
95
+ };
96
+ /**
97
+ * Optional wrappers keyed off `message.role`. When omitted, parts render
98
+ * unwrapped (inside a fragment).
99
+ */
100
+ export type MessageRoleRenderers = {
101
+ User?: (props: MessageRoleRendererProps) => ReactNode;
102
+ Assistant?: (props: MessageRoleRendererProps) => ReactNode;
103
+ System?: (props: MessageRoleRendererProps) => ReactNode;
104
+ Signal?: (props: MessageRoleRendererProps) => ReactNode;
105
+ };
106
+ /**
107
+ * Props passed to the `Tripwire` status slot. Rendered *instead of* the parts
108
+ * walk when `message.content.metadata.status === 'tripwire'`. `text` is the
109
+ * message's joined text body (the reason a notice would display).
110
+ */
111
+ export type TripwireRendererProps = {
112
+ text: string;
113
+ tripwire?: TripwireMetadata;
114
+ message: MastraDBMessage;
115
+ };
116
+ /**
117
+ * Props passed to the `Warning` status slot. Rendered *instead of* the parts
118
+ * walk when `message.content.metadata.status === 'warning'`.
119
+ */
120
+ export type WarningRendererProps = {
121
+ text: string;
122
+ message: MastraDBMessage;
123
+ };
124
+ /**
125
+ * Props passed to the `Error` status slot. Rendered *instead of* the parts
126
+ * walk when `message.content.metadata.status === 'error'`.
127
+ */
128
+ export type ErrorRendererProps = {
129
+ text: string;
130
+ message: MastraDBMessage;
131
+ };
132
+ /**
133
+ * Props passed to the `Task` status slot. Rendered *alongside* (after) the
134
+ * parts walk when a task-completion verdict exists on the message metadata
135
+ * (`completionResult ?? isTaskCompleteResult`).
136
+ *
137
+ * Shaped as the persisted subset of {@link IsTaskCompletePayload}: only
138
+ * `passed` and `suppressFeedback` survive persistence (the accumulator writes
139
+ * `completionResult: { passed }`). The richer payload fields (`iteration`,
140
+ * `results`, `duration`, `reason`, ...) are not available from stored metadata.
141
+ */
142
+ export type TaskRendererProps = Pick<IsTaskCompletePayload, 'passed'> & Partial<Pick<IsTaskCompletePayload, 'suppressFeedback'>> & {
143
+ text: string;
144
+ message: MastraDBMessage;
145
+ };
146
+ /**
147
+ * Optional message-level slots dispatched off `message.content.metadata`.
148
+ *
149
+ * - `Tripwire` / `Warning` / `Error` are *replacement* slots: when
150
+ * `metadata.status` matches, the slot renders instead of the parts walk.
151
+ * - `Task` is an *adjacent* slot: when a completion verdict exists it renders
152
+ * alongside the parts.
153
+ *
154
+ * The factory only reads metadata and forwards it; it never filters (e.g. it
155
+ * still invokes `Task` when `suppressFeedback` is true). The consumer decides
156
+ * what to render or skip.
157
+ */
158
+ export type MessageStatusRenderers = {
159
+ Tripwire?: (props: TripwireRendererProps) => ReactNode;
160
+ Warning?: (props: WarningRendererProps) => ReactNode;
161
+ Error?: (props: ErrorRendererProps) => ReactNode;
162
+ Task?: (props: TaskRendererProps) => ReactNode;
163
+ };
164
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ui/MessageFactory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjF,yDAAyD;AACzD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAC1C,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AACpD,yDAAyD;AACzD,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAC1C,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AACrD,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAC/D,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAC/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,eAAe,CAAC;AAErD;;;GAGG;AAC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,KAAK,EAAE,qBAAqB,KAAK,SAAS,CAAC;IACvD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAC;IACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;IACjD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;CAChD,CAAC"}
@@ -5,4 +5,5 @@ export * from './IconButton/index.js';
5
5
  export * from './Icons/index.js';
6
6
  export * from './Tooltip/index.js';
7
7
  export * from './Message/index.js';
8
+ export * from './MessageFactory/index.js';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/react",
3
- "version": "0.4.3-alpha.9",
3
+ "version": "0.5.0-alpha.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/mastra-ai/mastra.git",
@@ -39,19 +39,15 @@
39
39
  "lucide-react": "^0.522.0",
40
40
  "shiki": "^1.29.2",
41
41
  "tailwind-merge": "^3.5.0",
42
- "@mastra/client-js": "1.22.0-alpha.9"
42
+ "@mastra/client-js": "1.23.0-alpha.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@mastra/core": ">=1.8.0-0 <2.0.0-0",
46
46
  "react": ">=19.0.0",
47
47
  "react-dom": ">=19.0.0",
48
- "zod": "^3.25.0 || ^4.0.0",
49
- "@ai-sdk/react": "^2.0.187",
50
- "@assistant-ui/react": "^0.14.0"
48
+ "zod": "^3.25.0 || ^4.0.0"
51
49
  },
52
50
  "devDependencies": {
53
- "@ai-sdk/react": "^2.0.187",
54
- "@assistant-ui/react": "^0.14.0",
55
51
  "@storybook/react-vite": "^9.1.20",
56
52
  "@tailwindcss/cli": "^4.2.2",
57
53
  "@tailwindcss/vite": "^4.2.2",
@@ -73,9 +69,9 @@
73
69
  "vite": "^7.3.1",
74
70
  "vitest": "4.1.5",
75
71
  "zod": "^3.25.76",
76
- "@internal/lint": "0.0.99",
77
- "@internal/types-builder": "0.0.74",
78
- "@mastra/core": "1.38.0-alpha.9"
72
+ "@internal/lint": "0.0.100",
73
+ "@internal/types-builder": "0.0.75",
74
+ "@mastra/core": "1.39.0-alpha.0"
79
75
  },
80
76
  "eslintConfig": {
81
77
  "extends": [
@@ -1,5 +0,0 @@
1
- export * from './types.js';
2
- export * from './utils/toUIMessage.js';
3
- export * from './utils/toAssistantUIMessage.js';
4
- export { resolveToChildMessages } from './memory/resolveInitialMessages.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/ai-sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { MastraUIMessage } from '../types.js';
2
- interface ChildMessage {
3
- type: 'tool' | 'text';
4
- toolCallId?: string;
5
- toolName?: string;
6
- args?: Record<string, unknown>;
7
- toolOutput?: Record<string, unknown>;
8
- content?: string;
9
- }
10
- export declare const resolveInitialMessages: (messages: MastraUIMessage[]) => MastraUIMessage[];
11
- export declare const resolveToChildMessages: (messages: MastraUIMessage[]) => ChildMessage[];
12
- export {};
13
- //# sourceMappingURL=resolveInitialMessages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveInitialMessages.d.ts","sourceRoot":"","sources":["../../../../src/lib/ai-sdk/memory/resolveInitialMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,eAAe,EAA2B,MAAM,UAAU,CAAC;AA6ClG,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,sBAAsB,GAAI,UAAU,eAAe,EAAE,KAAG,eAAe,EAqLnF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,eAAe,EAAE,KAAG,YAAY,EAgChF,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { NetworkChunkType } from '@mastra/core/stream';
2
- import type { MastraUIMessage } from '../types.js';
3
- import type { Transformer, TransformerArgs } from './types.js';
4
- export declare class AISdkNetworkTransformer implements Transformer<NetworkChunkType> {
5
- transform({ chunk, conversation, metadata }: TransformerArgs<NetworkChunkType>): MastraUIMessage[];
6
- private handleRoutingAgentConversation;
7
- private handleAgentConversation;
8
- private handleWorkflowConversation;
9
- private handleToolConversation;
10
- }
11
- //# sourceMappingURL=AISdkNetworkTransformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AISdkNetworkTransformer.d.ts","sourceRoot":"","sources":["../../../../src/lib/ai-sdk/transformers/AISdkNetworkTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,UAAU,CAAC;AAGzE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,qBAAa,uBAAwB,YAAW,WAAW,CAAC,gBAAgB,CAAC;IAC3E,SAAS,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAAG,eAAe,EAAE;IAmGlG,OAAO,CAAC,8BAA8B,CA4CpC;IAEF,OAAO,CAAC,uBAAuB,CA2O7B;IAEF,OAAO,CAAC,0BAA0B,CA0GhC;IAEF,OAAO,CAAC,sBAAsB,CAmJ5B;CACH"}
@@ -1,11 +0,0 @@
1
- import type { NetworkChunkType } from '@mastra/core/stream';
2
- import type { MastraUIMessage, MastraUIMessageMetadata } from '../types.js';
3
- export interface TransformerArgs<_T> {
4
- chunk: NetworkChunkType;
5
- conversation: MastraUIMessage[];
6
- metadata: MastraUIMessageMetadata;
7
- }
8
- export interface Transformer<T> {
9
- transform: (args: TransformerArgs<T>) => MastraUIMessage[];
10
- }
11
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/ai-sdk/transformers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEzE,MAAM,WAAW,eAAe,CAAC,EAAE;IACjC,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,eAAe,EAAE,CAAC;CAC5D"}