@mastra/react 1.3.5-alpha.3 → 1.4.0-alpha.5
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 +47 -0
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
- package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts +1 -1
- package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts.map +1 -1
- package/dist/workflows/WorkflowStepFactory/types.d.ts +21 -3
- package/dist/workflows/WorkflowStepFactory/types.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @mastra/react
|
|
2
2
|
|
|
3
|
+
## 1.4.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`db4e6ff`](https://github.com/mastra-ai/mastra/commit/db4e6ff744503112eb64deeaf6c2b54bf26a54c7), [`6d19a65`](https://github.com/mastra-ai/mastra/commit/6d19a6517f5da3911023d446b7e2d5dad8adb1cb)]:
|
|
8
|
+
- @mastra/core@1.56.0-alpha.5
|
|
9
|
+
- @mastra/client-js@1.37.0-alpha.5
|
|
10
|
+
|
|
11
|
+
## 1.4.0-alpha.4
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- `WorkflowStepFactory` understands the new declarative step entries. ([#20471](https://github.com/mastra-ai/mastra/pull/20471))
|
|
16
|
+
|
|
17
|
+
**New resolved kinds.** `agent-step` and `tool-step` with matching `AgentStep` / `ToolStep` renderer slots. Entries without a dedicated renderer still fall back to `UnknownStep`.
|
|
18
|
+
|
|
19
|
+
**`map-step` resolves from the dedicated `type: 'mapping'` entry.** Previously a generic `type: 'step'` entry carrying `mapConfig`. `ResolvedWorkflowMapStep['flow']` is a union of both shapes — narrow on `flow.type` before reading the mapping code (`flow.mapConfig` for `'mapping'` entries, `flow.step.mapConfig` for legacy `'step'` entries).
|
|
20
|
+
|
|
21
|
+
**`nested-workflow-step` also resolves from the first-class `type: 'workflow'` entry** emitted for `.then(subWorkflow)`, which carries `workflowId` and the nested `serializedStepFlow`.
|
|
22
|
+
|
|
23
|
+
**Usage.** Pass a `ResolvedWorkflowStep` and the renderer slots you care about; unhandled kinds fall through to `UnknownStep`:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { WorkflowStepFactory } from '@mastra/react';
|
|
27
|
+
import type { ResolvedWorkflowStep } from '@mastra/react';
|
|
28
|
+
|
|
29
|
+
function StepNode({ step }: { step: ResolvedWorkflowStep }) {
|
|
30
|
+
return (
|
|
31
|
+
<WorkflowStepFactory
|
|
32
|
+
step={step}
|
|
33
|
+
AgentStep={s => <AgentCard agentId={s.flow.agentId} result={s.result} />}
|
|
34
|
+
ToolStep={s => <ToolCard toolId={s.flow.toolId} result={s.result} />}
|
|
35
|
+
MapStep={s => <MapCard code={s.flow.type === 'mapping' ? s.flow.mapConfig : s.flow.step.mapConfig} />}
|
|
36
|
+
UnknownStep={s => <GenericCard id={s.id} />}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Fixed streamed assistant messages in `useChat`-style threads being keyed by a stale message id when observational memory rotates the response message id during a run. The accumulator now follows the rotated id carried by `step-start`, so streamed messages always match the ids they are persisted under and no longer disappear or duplicate after a refresh. Part of the fix for [#19810](https://github.com/mastra-ai/mastra/issues/19810) ([#20084](https://github.com/mastra-ai/mastra/pull/20084))
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`a1cb98d`](https://github.com/mastra-ai/mastra/commit/a1cb98d11990b560b98482292a1f34aa1a2d9092), [`598ad82`](https://github.com/mastra-ai/mastra/commit/598ad82d41c41389a686338a1d0e50b7400e1938), [`1fd6aad`](https://github.com/mastra-ai/mastra/commit/1fd6aad1ea4a9d32f65efa832307c35e981a4c0a), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2)]:
|
|
47
|
+
- @mastra/core@1.56.0-alpha.4
|
|
48
|
+
- @mastra/client-js@1.37.0-alpha.4
|
|
49
|
+
|
|
3
50
|
## 1.3.5-alpha.3
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1048,7 +1048,18 @@ const accumulateChunk = ({ chunk, conversation, metadata }) => {
|
|
|
1048
1048
|
});
|
|
1049
1049
|
return [...result, newMessage];
|
|
1050
1050
|
}
|
|
1051
|
-
case "step-start":
|
|
1051
|
+
case "step-start": {
|
|
1052
|
+
const stepMessageId = typeof chunk.payload?.messageId === "string" ? chunk.payload.messageId : void 0;
|
|
1053
|
+
if (!stepMessageId) return result;
|
|
1054
|
+
const lastMessage = result[result.length - 1];
|
|
1055
|
+
if (!lastMessage || lastMessage.role !== "assistant") return result;
|
|
1056
|
+
if (result.some((message) => message.id === stepMessageId)) return result;
|
|
1057
|
+
if (!lastMessage.content.parts.some((part) => !String(part.type).startsWith("data-"))) return replaceLast(result, {
|
|
1058
|
+
...lastMessage,
|
|
1059
|
+
id: stepMessageId
|
|
1060
|
+
});
|
|
1061
|
+
return appendAssistantMessage(finishStreamingAssistantMessage(result), stepMessageId, [], metadata);
|
|
1062
|
+
}
|
|
1052
1063
|
case "step-finish":
|
|
1053
1064
|
case "step-output":
|
|
1054
1065
|
case "raw":
|
|
@@ -2971,10 +2982,12 @@ function useCancelWorkflowRun() {
|
|
|
2971
2982
|
//#endregion
|
|
2972
2983
|
//#region src/workflows/WorkflowStepFactory/WorkflowStepFactory.tsx
|
|
2973
2984
|
const renderUnknown = (step, UnknownStep) => UnknownStep?.(step) ?? null;
|
|
2974
|
-
const WorkflowStepFactoryComponent = ({ step, Step, MapStep, ForEachStep, ParallelStep, Conditional, LoopStep, SleepStep, SleepUntilStep, NestedWorkflowStep, UnknownStep }) => {
|
|
2985
|
+
const WorkflowStepFactoryComponent = ({ step, Step, MapStep, AgentStep, ToolStep, ForEachStep, ParallelStep, Conditional, LoopStep, SleepStep, SleepUntilStep, NestedWorkflowStep, UnknownStep }) => {
|
|
2975
2986
|
switch (step.kind) {
|
|
2976
2987
|
case "step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Step?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2977
2988
|
case "map-step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: MapStep?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2989
|
+
case "agent-step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: AgentStep?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2990
|
+
case "tool-step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: ToolStep?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2978
2991
|
case "foreach-step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: ForEachStep?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2979
2992
|
case "parallel-step": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: ParallelStep?.(step) ?? renderUnknown(step, UnknownStep) });
|
|
2980
2993
|
case "conditional": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Conditional?.(step) ?? renderUnknown(step, UnknownStep) });
|