@mastra/playground-ui 5.0.4-alpha.4 → 5.0.5-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.
- package/dist/index.cjs.js +161 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.es.js +157 -44
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/agents/agent/context/agent-context.d.ts +4 -3
- package/dist/src/domains/traces/types.d.ts +9 -4
- package/dist/src/domains/traces/utils/createSpanTree.d.ts +3 -0
- package/dist/src/ds/components/Entity/Entity.d.ts +10 -0
- package/dist/src/ds/components/Entity/index.d.ts +1 -0
- package/dist/src/ds/components/TraceTree/Span.d.ts +3 -1
- package/dist/src/ds/components/TraceTree/Time.d.ts +2 -1
- package/dist/src/ds/components/TraceTree/Trace.d.ts +2 -1
- package/dist/src/ds/icons/Icon.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/store/agent-store.d.ts +20 -0
- package/dist/src/types.d.ts +1 -4
- package/package.json +3 -3
- package/dist/src/ds/components/TraceTree/Trace.context.d.ts +0 -9
package/dist/index.cjs.js
CHANGED
|
@@ -3145,6 +3145,7 @@ const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
|
|
|
3145
3145
|
});
|
|
3146
3146
|
|
|
3147
3147
|
const sizes = {
|
|
3148
|
+
sm: "[&>svg]:h-icon-sm [&>svg]:w-icon-sm",
|
|
3148
3149
|
default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
|
|
3149
3150
|
lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
|
|
3150
3151
|
};
|
|
@@ -4348,6 +4349,20 @@ function MastraRuntimeProvider({
|
|
|
4348
4349
|
] });
|
|
4349
4350
|
}
|
|
4350
4351
|
|
|
4352
|
+
const useAgentStore = zustand.create()(
|
|
4353
|
+
middleware.persist(
|
|
4354
|
+
(set) => ({
|
|
4355
|
+
modelSettings: {},
|
|
4356
|
+
setModelSettings: (modelSettings) => set((state) => ({ modelSettings: { ...state.modelSettings, ...modelSettings } })),
|
|
4357
|
+
chatWithGenerate: {},
|
|
4358
|
+
setChatWithGenerate: (chatWithGenerate) => set((state) => ({ chatWithGenerate: { ...state.chatWithGenerate, ...chatWithGenerate } }))
|
|
4359
|
+
}),
|
|
4360
|
+
{
|
|
4361
|
+
name: "mastra-agent-store"
|
|
4362
|
+
}
|
|
4363
|
+
)
|
|
4364
|
+
);
|
|
4365
|
+
|
|
4351
4366
|
const defaultModelSettings$1 = {
|
|
4352
4367
|
maxRetries: 2,
|
|
4353
4368
|
maxSteps: 5,
|
|
@@ -4355,12 +4370,24 @@ const defaultModelSettings$1 = {
|
|
|
4355
4370
|
topP: 1
|
|
4356
4371
|
};
|
|
4357
4372
|
const AgentContext = React.createContext({});
|
|
4358
|
-
function AgentProvider({ children }) {
|
|
4359
|
-
const
|
|
4360
|
-
|
|
4373
|
+
function AgentProvider({ agentId, children }) {
|
|
4374
|
+
const {
|
|
4375
|
+
modelSettings: modelSettingsStore,
|
|
4376
|
+
setModelSettings: setModelSettingsStore,
|
|
4377
|
+
chatWithGenerate: chatWithGenerateStore,
|
|
4378
|
+
setChatWithGenerate: setChatWithGenerateStore
|
|
4379
|
+
} = useAgentStore();
|
|
4380
|
+
const modelSettings = modelSettingsStore[agentId] || defaultModelSettings$1;
|
|
4381
|
+
const setModelSettings = (modelSettings2) => {
|
|
4382
|
+
setModelSettingsStore({ [agentId]: modelSettings2 });
|
|
4383
|
+
};
|
|
4361
4384
|
const resetModelSettings = () => {
|
|
4362
4385
|
setModelSettings(defaultModelSettings$1);
|
|
4363
4386
|
};
|
|
4387
|
+
const chatWithGenerate = chatWithGenerateStore[agentId] || false;
|
|
4388
|
+
const setChatWithGenerate = (chatWithGenerate2) => {
|
|
4389
|
+
setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
|
|
4390
|
+
};
|
|
4364
4391
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4365
4392
|
AgentContext.Provider,
|
|
4366
4393
|
{
|
|
@@ -4412,7 +4439,7 @@ const AgentChat = ({
|
|
|
4412
4439
|
modelSettings,
|
|
4413
4440
|
chatWithGenerate,
|
|
4414
4441
|
runtimeContext,
|
|
4415
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "" }) })
|
|
4442
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "" }) })
|
|
4416
4443
|
}
|
|
4417
4444
|
);
|
|
4418
4445
|
};
|
|
@@ -5198,11 +5225,17 @@ const TraceTree = ({ children }) => {
|
|
|
5198
5225
|
const variantClasses = {
|
|
5199
5226
|
agent: "bg-accent1"
|
|
5200
5227
|
};
|
|
5201
|
-
const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
|
|
5228
|
+
const Time = ({ durationMs, tokenCount, variant, progressPercent, offsetPercent }) => {
|
|
5202
5229
|
const variantClass = variant ? variantClasses[variant] : "bg-accent3";
|
|
5203
5230
|
const percent = Math.min(100, progressPercent);
|
|
5204
5231
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[80px] xl:w-[166px] shrink-0", children: [
|
|
5205
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5232
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5233
|
+
"div",
|
|
5234
|
+
{
|
|
5235
|
+
className: clsx("absolute h-1 rounded-full", variantClass),
|
|
5236
|
+
style: { width: `${percent}%`, left: `${offsetPercent}%` }
|
|
5237
|
+
}
|
|
5238
|
+
) }),
|
|
5206
5239
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
|
|
5207
5240
|
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
5208
5241
|
toSigFigs(durationMs, 3),
|
|
@@ -5216,14 +5249,6 @@ const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
|
|
|
5216
5249
|
] });
|
|
5217
5250
|
};
|
|
5218
5251
|
|
|
5219
|
-
const TraceDurationContext = React.createContext(0);
|
|
5220
|
-
const useTraceDuration = () => {
|
|
5221
|
-
return React.useContext(TraceDurationContext);
|
|
5222
|
-
};
|
|
5223
|
-
const TraceDurationProvider = ({ children, durationMs }) => {
|
|
5224
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TraceDurationContext.Provider, { value: durationMs, children });
|
|
5225
|
-
};
|
|
5226
|
-
|
|
5227
5252
|
const spanIconMap = {
|
|
5228
5253
|
tool: ToolsIcon,
|
|
5229
5254
|
agent: AgentIcon,
|
|
@@ -5244,14 +5269,25 @@ const spanVariantClasses = {
|
|
|
5244
5269
|
eval: "text-accent4",
|
|
5245
5270
|
other: "text-icon6"
|
|
5246
5271
|
};
|
|
5247
|
-
const Span = ({
|
|
5272
|
+
const Span = ({
|
|
5273
|
+
children,
|
|
5274
|
+
durationMs,
|
|
5275
|
+
variant,
|
|
5276
|
+
tokenCount,
|
|
5277
|
+
spans,
|
|
5278
|
+
isRoot,
|
|
5279
|
+
onClick,
|
|
5280
|
+
isActive,
|
|
5281
|
+
offsetMs,
|
|
5282
|
+
totalDurationMs
|
|
5283
|
+
}) => {
|
|
5248
5284
|
const [isExpanded, setIsExpanded] = React.useState(true);
|
|
5249
|
-
const traceDuration = useTraceDuration();
|
|
5250
5285
|
const VariantIcon = spanIconMap[variant];
|
|
5251
5286
|
const variantClass = spanVariantClasses[variant];
|
|
5252
|
-
const progressPercent = durationMs /
|
|
5287
|
+
const progressPercent = durationMs / totalDurationMs * 100;
|
|
5288
|
+
const offsetPercent = offsetMs / totalDurationMs * 100;
|
|
5253
5289
|
const TextEl = onClick ? "button" : "div";
|
|
5254
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
5290
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
5255
5291
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
|
|
5256
5292
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
|
|
5257
5293
|
spans ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5276,20 +5312,30 @@ const Span = ({ children, durationMs, variant, tokenCount, spans, isRoot, onClic
|
|
|
5276
5312
|
durationMs,
|
|
5277
5313
|
tokenCount,
|
|
5278
5314
|
variant: variant === "agent" ? "agent" : void 0,
|
|
5279
|
-
progressPercent
|
|
5315
|
+
progressPercent,
|
|
5316
|
+
offsetPercent
|
|
5280
5317
|
}
|
|
5281
5318
|
)
|
|
5282
5319
|
] }),
|
|
5283
5320
|
isExpanded && spans && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: spans })
|
|
5284
|
-
] })
|
|
5321
|
+
] });
|
|
5285
5322
|
};
|
|
5286
5323
|
|
|
5287
5324
|
const Spans = ({ children }) => {
|
|
5288
5325
|
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
5289
5326
|
};
|
|
5290
5327
|
|
|
5291
|
-
const Trace = ({
|
|
5292
|
-
|
|
5328
|
+
const Trace = ({
|
|
5329
|
+
name,
|
|
5330
|
+
spans,
|
|
5331
|
+
durationMs,
|
|
5332
|
+
tokenCount,
|
|
5333
|
+
onClick,
|
|
5334
|
+
variant,
|
|
5335
|
+
isActive,
|
|
5336
|
+
totalDurationMs
|
|
5337
|
+
}) => {
|
|
5338
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5293
5339
|
Span,
|
|
5294
5340
|
{
|
|
5295
5341
|
isRoot: true,
|
|
@@ -5298,9 +5344,11 @@ const Trace = ({ name, spans, durationMs, tokenCount, onClick, variant, isActive
|
|
|
5298
5344
|
spans: /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spans }),
|
|
5299
5345
|
onClick,
|
|
5300
5346
|
isActive,
|
|
5347
|
+
offsetMs: 0,
|
|
5348
|
+
totalDurationMs,
|
|
5301
5349
|
children: name
|
|
5302
5350
|
}
|
|
5303
|
-
)
|
|
5351
|
+
);
|
|
5304
5352
|
};
|
|
5305
5353
|
|
|
5306
5354
|
const getSpanVariant = (span) => {
|
|
@@ -5325,40 +5373,71 @@ const getSpanVariant = (span) => {
|
|
|
5325
5373
|
return "other";
|
|
5326
5374
|
};
|
|
5327
5375
|
|
|
5328
|
-
function buildTree(
|
|
5329
|
-
return
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5376
|
+
function buildTree(spans, minStartTime, totalDurationMs, parentSpanId = null) {
|
|
5377
|
+
return spans.filter((span) => span.parentSpanId === parentSpanId).map((span) => {
|
|
5378
|
+
return {
|
|
5379
|
+
...span,
|
|
5380
|
+
children: buildTree(spans, minStartTime, totalDurationMs, span.id),
|
|
5381
|
+
offset: (span.startTime - minStartTime) / 1e3,
|
|
5382
|
+
// ns to ms
|
|
5383
|
+
duration: span.duration / 1e3,
|
|
5384
|
+
totalDurationMs
|
|
5385
|
+
};
|
|
5386
|
+
});
|
|
5333
5387
|
}
|
|
5334
|
-
const
|
|
5388
|
+
const createSpanTree = (spans) => {
|
|
5389
|
+
if (spans.length === 0) return [];
|
|
5390
|
+
let minStartTime;
|
|
5391
|
+
let maxEndTime;
|
|
5392
|
+
const orderedTree = [];
|
|
5393
|
+
const listSize = spans.length;
|
|
5394
|
+
for (let i = listSize - 1; i >= 0; i--) {
|
|
5395
|
+
const span = spans[i];
|
|
5396
|
+
if (!minStartTime || span.startTime < minStartTime) {
|
|
5397
|
+
minStartTime = span.startTime;
|
|
5398
|
+
}
|
|
5399
|
+
if (!maxEndTime || span.endTime > maxEndTime) {
|
|
5400
|
+
maxEndTime = span.endTime;
|
|
5401
|
+
}
|
|
5402
|
+
if (span.name !== ".insert" && span.name !== "mastra.getStorage") {
|
|
5403
|
+
orderedTree.push(span);
|
|
5404
|
+
}
|
|
5405
|
+
}
|
|
5406
|
+
if (!minStartTime || !maxEndTime) return [];
|
|
5407
|
+
const totalDurationMs = (maxEndTime - minStartTime) / 1e3;
|
|
5408
|
+
return buildTree(orderedTree, minStartTime, totalDurationMs);
|
|
5409
|
+
};
|
|
5410
|
+
|
|
5411
|
+
const NestedSpans = ({ spanNodes }) => {
|
|
5335
5412
|
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
5336
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Spans, { children:
|
|
5337
|
-
const isActive =
|
|
5413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spanNodes.map((spanNode) => {
|
|
5414
|
+
const isActive = spanNode.id === activeSpan?.id;
|
|
5338
5415
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5339
5416
|
Span,
|
|
5340
5417
|
{
|
|
5341
|
-
spans:
|
|
5342
|
-
durationMs:
|
|
5343
|
-
|
|
5418
|
+
spans: spanNode.children.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: spanNode.children }),
|
|
5419
|
+
durationMs: spanNode.duration,
|
|
5420
|
+
offsetMs: spanNode.offset,
|
|
5421
|
+
variant: getSpanVariant(spanNode),
|
|
5344
5422
|
isActive,
|
|
5345
|
-
onClick: () => setSpan(
|
|
5346
|
-
|
|
5423
|
+
onClick: () => setSpan(spanNode),
|
|
5424
|
+
totalDurationMs: spanNode.totalDurationMs,
|
|
5425
|
+
children: spanNode.name
|
|
5347
5426
|
},
|
|
5348
|
-
|
|
5427
|
+
spanNode.id
|
|
5349
5428
|
);
|
|
5350
5429
|
}) });
|
|
5351
5430
|
};
|
|
5352
5431
|
function SpanView({ trace }) {
|
|
5353
|
-
const shallowCopy = [...trace];
|
|
5354
|
-
const tree = buildTree(shallowCopy.reverse());
|
|
5355
5432
|
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
5433
|
+
const tree = createSpanTree(trace);
|
|
5356
5434
|
return /* @__PURE__ */ jsxRuntime.jsx(TraceTree, { children: tree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5357
5435
|
Trace,
|
|
5358
5436
|
{
|
|
5359
5437
|
name: node.name,
|
|
5360
|
-
durationMs: node.duration
|
|
5361
|
-
|
|
5438
|
+
durationMs: node.duration,
|
|
5439
|
+
totalDurationMs: node.totalDurationMs,
|
|
5440
|
+
spans: /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: node.children }),
|
|
5362
5441
|
variant: getSpanVariant(node),
|
|
5363
5442
|
isActive: node.id === activeSpan?.id,
|
|
5364
5443
|
onClick: () => setSpan(node)
|
|
@@ -5494,8 +5573,7 @@ const refineTraces = (traces, isWorkflow = false) => {
|
|
|
5494
5573
|
const parentSpan = value.find((span) => !span.parentSpanId || !listOfSpanIds.has(span.parentSpanId));
|
|
5495
5574
|
const enrichedSpans = value.map((span) => ({
|
|
5496
5575
|
...span,
|
|
5497
|
-
parentSpanId: parentSpan?.id === span.id ? null : span?.parentSpanId
|
|
5498
|
-
relativePercentage: parentSpan ? span.duration / parentSpan.duration : 0
|
|
5576
|
+
parentSpanId: parentSpan?.id === span.id ? null : span?.parentSpanId
|
|
5499
5577
|
}));
|
|
5500
5578
|
const failedStatus = value.find((span) => span.status.code !== 0)?.status;
|
|
5501
5579
|
return {
|
|
@@ -8943,6 +9021,41 @@ const DarkLogo = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "100
|
|
|
8943
9021
|
)
|
|
8944
9022
|
] });
|
|
8945
9023
|
|
|
9024
|
+
const Entity = ({ children, className, onClick }) => {
|
|
9025
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9026
|
+
"div",
|
|
9027
|
+
{
|
|
9028
|
+
tabIndex: onClick ? 0 : void 0,
|
|
9029
|
+
onKeyDown: (e) => {
|
|
9030
|
+
if (!onClick) return;
|
|
9031
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9032
|
+
e.preventDefault();
|
|
9033
|
+
onClick?.();
|
|
9034
|
+
}
|
|
9035
|
+
},
|
|
9036
|
+
className: clsx(
|
|
9037
|
+
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
9038
|
+
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
9039
|
+
className
|
|
9040
|
+
),
|
|
9041
|
+
onClick,
|
|
9042
|
+
children
|
|
9043
|
+
}
|
|
9044
|
+
);
|
|
9045
|
+
};
|
|
9046
|
+
const EntityIcon = ({ children, className }) => {
|
|
9047
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
9048
|
+
};
|
|
9049
|
+
const EntityName = ({ children, className }) => {
|
|
9050
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
9051
|
+
};
|
|
9052
|
+
const EntityDescription = ({ children, className }) => {
|
|
9053
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
9054
|
+
};
|
|
9055
|
+
const EntityContent = ({ children, className }) => {
|
|
9056
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children });
|
|
9057
|
+
};
|
|
9058
|
+
|
|
8946
9059
|
function usePolling({
|
|
8947
9060
|
fetchFn,
|
|
8948
9061
|
interval = 3e3,
|
|
@@ -9125,6 +9238,11 @@ exports.DeploymentIcon = DeploymentIcon;
|
|
|
9125
9238
|
exports.DividerIcon = DividerIcon;
|
|
9126
9239
|
exports.DocsIcon = DocsIcon;
|
|
9127
9240
|
exports.DynamicForm = DynamicForm;
|
|
9241
|
+
exports.Entity = Entity;
|
|
9242
|
+
exports.EntityContent = EntityContent;
|
|
9243
|
+
exports.EntityDescription = EntityDescription;
|
|
9244
|
+
exports.EntityIcon = EntityIcon;
|
|
9245
|
+
exports.EntityName = EntityName;
|
|
9128
9246
|
exports.EntryCell = EntryCell;
|
|
9129
9247
|
exports.EnvIcon = EnvIcon;
|
|
9130
9248
|
exports.EvaluatorCoinIcon = EvaluatorCoinIcon;
|