@mastra/playground-ui 0.0.0-zod-v4-compat-part-2-20250820135355 → 0.0.0-zod-v4-stuff-20250825154219
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 +1000 -298
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1006 -304
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/ui/autoform/zodProvider/field-type-inference.d.ts +3 -0
- package/dist/src/components/ui/autoform/zodProvider/index.d.ts +10 -0
- package/dist/src/components/ui/elements/buttons/button.d.ts +12 -0
- package/dist/src/components/ui/elements/buttons/button.stories.d.ts +13 -0
- package/dist/src/components/ui/elements/buttons/index.d.ts +1 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-cell.d.ts +3 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-item.d.ts +8 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-page-header.d.ts +8 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-toolbar.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list.d.ts +15 -0
- package/dist/src/components/ui/elements/entry-list/index.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/shared.d.ts +6 -0
- package/dist/src/components/ui/elements/form-fields/form-actions.d.ts +12 -0
- package/dist/src/components/ui/elements/form-fields/index.d.ts +7 -0
- package/dist/src/components/ui/elements/form-fields/input-field.d.ts +14 -0
- package/dist/src/components/ui/elements/form-fields/input-field.stories.d.ts +15 -0
- package/dist/src/components/ui/elements/form-fields/radio-group-field.d.ts +21 -0
- package/dist/src/components/ui/elements/form-fields/search-field.d.ts +2 -0
- package/dist/src/components/ui/elements/form-fields/select-field.d.ts +19 -0
- package/dist/src/components/ui/elements/form-fields/select-field.stories.d.ts +13 -0
- package/dist/src/components/ui/elements/form-fields/slider-field.d.ts +15 -0
- package/dist/src/components/ui/elements/form-fields/textarea-field.d.ts +11 -0
- package/dist/src/components/ui/elements/headers/entity-main-header.d.ts +11 -0
- package/dist/src/components/ui/elements/headers/index.d.ts +1 -0
- package/dist/src/components/ui/elements/index.d.ts +2 -0
- package/dist/src/components/ui/elements/key-value-list/index.d.ts +1 -0
- package/dist/src/components/ui/elements/key-value-list/key-value-list.d.ts +24 -0
- package/dist/src/components/ui/elements/key-value-list/key-value-list.stories.d.ts +12 -0
- package/dist/src/components/ui/elements/select/index.d.ts +1 -0
- package/dist/src/components/ui/elements/select/select.d.ts +10 -0
- package/dist/src/components/ui/elements/side-dialog/index.d.ts +5 -0
- package/dist/src/components/ui/elements/side-dialog/side-dialog-content.d.ts +21 -0
- package/dist/src/components/ui/elements/side-dialog/side-dialog-footer.d.ts +10 -0
- package/dist/src/components/ui/elements/side-dialog/side-dialog-header.d.ts +5 -0
- package/dist/src/components/ui/elements/side-dialog/side-dialog-top.d.ts +7 -0
- package/dist/src/components/ui/elements/side-dialog/side-dialog.d.ts +10 -0
- package/dist/src/components/ui/elements/tabs/index.d.ts +1 -0
- package/dist/src/components/ui/elements/tabs/tabs.d.ts +40 -0
- package/dist/src/domains/agents/components/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata-model-switcher.d.ts +11 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata.d.ts +4 -1
- package/dist/src/domains/agents/components/agent-metadata/models.d.ts +5 -0
- package/dist/src/domains/agents/components/agent-settings.d.ts +3 -1
- package/dist/src/services/mastra-runtime-provider.d.ts +1 -1
- package/dist/src/types.d.ts +5 -19
- package/package.json +18 -11
package/dist/index.es.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Suspense, Fragment as Fragment$1, startTransition } from 'react';
|
|
4
4
|
import { MastraClient } from '@mastra/client-js';
|
|
5
5
|
import { useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, ThreadPrimitive, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechSynthesisAdapter, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
6
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, BrainIcon, AudioLinesIcon, StopCircleIcon, X, FileText, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Circle, ChevronDown, Braces, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, GaugeIcon, Plus, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints,
|
|
6
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, BrainIcon, AudioLinesIcon, StopCircleIcon, X, FileText, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Circle, ChevronDown, Braces, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, GaugeIcon, CircleCheck, EditIcon, Plus, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleX, Minus, Maximize, Workflow, AlertCircleIcon, Users, Brain, NetworkIcon, SearchIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause, StopCircle, ChevronUp } from 'lucide-react';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
8
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
9
9
|
import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
|
|
@@ -35,6 +35,8 @@ import prettierPluginBabel from 'prettier/plugins/babel';
|
|
|
35
35
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
36
36
|
import { C as Colors } from './colors-DrbbnW3f.js';
|
|
37
37
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
38
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
39
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
38
40
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
39
41
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
40
42
|
import Markdown from 'react-markdown';
|
|
@@ -48,13 +50,12 @@ import { v4 } from '@lukeed/uuid';
|
|
|
48
50
|
import { RuntimeContext as RuntimeContext$2 } from '@mastra/core/runtime-context';
|
|
49
51
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
50
52
|
import { parse } from 'superjson';
|
|
51
|
-
import z, {
|
|
53
|
+
import z$2, { z, ZodObject } from 'zod';
|
|
52
54
|
import { AutoForm as AutoForm$1, buildZodFieldConfig } from '@autoform/react';
|
|
53
55
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
54
56
|
import { DayPicker } from 'react-day-picker';
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import { ZodProvider } from '@autoform/zod/v4';
|
|
57
|
+
import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod/v4';
|
|
58
|
+
import { z as z$1 } from 'zod/v3';
|
|
58
59
|
import { CodeBlock as CodeBlock$1 } from 'react-code-block';
|
|
59
60
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
60
61
|
import './index.css';export * from '@tanstack/react-query';
|
|
@@ -5361,7 +5362,8 @@ function MastraRuntimeProvider({
|
|
|
5361
5362
|
threadId,
|
|
5362
5363
|
refreshThreadList,
|
|
5363
5364
|
settings,
|
|
5364
|
-
runtimeContext
|
|
5365
|
+
runtimeContext,
|
|
5366
|
+
modelVersion
|
|
5365
5367
|
}) {
|
|
5366
5368
|
const [isRunning, setIsRunning] = useState(false);
|
|
5367
5369
|
const [messages, setMessages] = useState([]);
|
|
@@ -5379,6 +5381,8 @@ function MastraRuntimeProvider({
|
|
|
5379
5381
|
topP,
|
|
5380
5382
|
instructions,
|
|
5381
5383
|
chatWithGenerate,
|
|
5384
|
+
chatWithGenerateVNext,
|
|
5385
|
+
chatWithStreamVNext,
|
|
5382
5386
|
providerOptions
|
|
5383
5387
|
} = settings?.modelSettings ?? {};
|
|
5384
5388
|
const toolCallIdToName = useRef({});
|
|
@@ -5391,27 +5395,46 @@ function MastraRuntimeProvider({
|
|
|
5391
5395
|
if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
|
|
5392
5396
|
if (initialMessages && threadId && memory) {
|
|
5393
5397
|
const convertedMessages = initialMessages?.map((message) => {
|
|
5394
|
-
const toolInvocationsAsContentParts = (message.toolInvocations || []).map((toolInvocation) => ({
|
|
5395
|
-
type: "tool-call",
|
|
5396
|
-
toolCallId: toolInvocation?.toolCallId,
|
|
5397
|
-
toolName: toolInvocation?.toolName,
|
|
5398
|
-
args: toolInvocation?.args,
|
|
5399
|
-
result: toolInvocation?.result
|
|
5400
|
-
}));
|
|
5401
5398
|
const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
|
|
5402
5399
|
type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
|
|
5403
5400
|
mimeType: image.contentType,
|
|
5404
5401
|
image: image.url
|
|
5405
5402
|
}));
|
|
5406
|
-
const
|
|
5403
|
+
const formattedParts = (message.parts || []).map((part) => {
|
|
5404
|
+
if (part.type === "reasoning") {
|
|
5405
|
+
return {
|
|
5406
|
+
type: "reasoning",
|
|
5407
|
+
text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
|
|
5408
|
+
};
|
|
5409
|
+
}
|
|
5410
|
+
if (part.type === "tool-invocation") {
|
|
5411
|
+
if (part.toolInvocation.state === "result") {
|
|
5412
|
+
return {
|
|
5413
|
+
type: "tool-call",
|
|
5414
|
+
toolCallId: part.toolInvocation.toolCallId,
|
|
5415
|
+
toolName: part.toolInvocation.toolName,
|
|
5416
|
+
args: part.toolInvocation.args,
|
|
5417
|
+
result: part.toolInvocation.result
|
|
5418
|
+
};
|
|
5419
|
+
}
|
|
5420
|
+
}
|
|
5421
|
+
if (part.type === "file") {
|
|
5422
|
+
return {
|
|
5423
|
+
type: "file",
|
|
5424
|
+
mimeType: part.mimeType,
|
|
5425
|
+
data: part.data
|
|
5426
|
+
};
|
|
5427
|
+
}
|
|
5428
|
+
if (part.type === "text") {
|
|
5429
|
+
return {
|
|
5430
|
+
type: "text",
|
|
5431
|
+
text: part.text
|
|
5432
|
+
};
|
|
5433
|
+
}
|
|
5434
|
+
}).filter(Boolean);
|
|
5407
5435
|
return {
|
|
5408
5436
|
...message,
|
|
5409
|
-
content: [
|
|
5410
|
-
...reasoning ? [{ type: "reasoning", text: reasoning }] : [],
|
|
5411
|
-
...typeof message.content === "string" ? [{ type: "text", text: message.content }] : [],
|
|
5412
|
-
...toolInvocationsAsContentParts,
|
|
5413
|
-
...attachmentsAsContentParts
|
|
5414
|
-
]
|
|
5437
|
+
content: [...formattedParts, ...attachmentsAsContentParts]
|
|
5415
5438
|
};
|
|
5416
5439
|
}).filter(Boolean);
|
|
5417
5440
|
setMessages(convertedMessages);
|
|
@@ -5437,31 +5460,9 @@ function MastraRuntimeProvider({
|
|
|
5437
5460
|
});
|
|
5438
5461
|
const agent = clientWithAbort.getAgent(agentId);
|
|
5439
5462
|
try {
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
messages
|
|
5443
|
-
{
|
|
5444
|
-
role: "user",
|
|
5445
|
-
content: input
|
|
5446
|
-
},
|
|
5447
|
-
...attachments
|
|
5448
|
-
],
|
|
5449
|
-
runId: agentId,
|
|
5450
|
-
frequencyPenalty,
|
|
5451
|
-
presencePenalty,
|
|
5452
|
-
maxRetries,
|
|
5453
|
-
maxSteps,
|
|
5454
|
-
maxTokens,
|
|
5455
|
-
temperature,
|
|
5456
|
-
topK,
|
|
5457
|
-
topP,
|
|
5458
|
-
instructions,
|
|
5459
|
-
runtimeContext: runtimeContextInstance,
|
|
5460
|
-
...memory ? { threadId, resourceId: agentId } : {},
|
|
5461
|
-
providerOptions
|
|
5462
|
-
});
|
|
5463
|
-
if (generateResponse.response && "messages" in generateResponse.response) {
|
|
5464
|
-
const latestMessage = generateResponse.response.messages.reduce(
|
|
5463
|
+
let handleGenerateResponse = function(generatedResponse) {
|
|
5464
|
+
if (generatedResponse.response && "messages" in generatedResponse.response) {
|
|
5465
|
+
const latestMessage = generatedResponse.response.messages.reduce(
|
|
5465
5466
|
(acc, message2) => {
|
|
5466
5467
|
const _content = Array.isArray(acc.content) ? acc.content : [];
|
|
5467
5468
|
if (typeof message2.content === "string") {
|
|
@@ -5469,7 +5470,7 @@ function MastraRuntimeProvider({
|
|
|
5469
5470
|
...acc,
|
|
5470
5471
|
content: [
|
|
5471
5472
|
..._content,
|
|
5472
|
-
...
|
|
5473
|
+
...generatedResponse.reasoning ? [{ type: "reasoning", text: generatedResponse.reasoning }] : [],
|
|
5473
5474
|
{
|
|
5474
5475
|
type: "text",
|
|
5475
5476
|
text: message2.content
|
|
@@ -5481,9 +5482,14 @@ function MastraRuntimeProvider({
|
|
|
5481
5482
|
const toolCallContent = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "tool-call") : void 0;
|
|
5482
5483
|
const reasoningContent = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "reasoning") : void 0;
|
|
5483
5484
|
if (toolCallContent) {
|
|
5484
|
-
const newContent =
|
|
5485
|
+
const newContent = message2.content.map((c) => {
|
|
5485
5486
|
if (c.type === "tool-call" && c.toolCallId === toolCallContent?.toolCallId) {
|
|
5486
|
-
return {
|
|
5487
|
+
return {
|
|
5488
|
+
...c,
|
|
5489
|
+
toolCallId: toolCallContent.toolCallId,
|
|
5490
|
+
toolName: toolCallContent.toolName,
|
|
5491
|
+
args: toolCallContent.input
|
|
5492
|
+
};
|
|
5487
5493
|
}
|
|
5488
5494
|
return c;
|
|
5489
5495
|
});
|
|
@@ -5506,7 +5512,7 @@ function MastraRuntimeProvider({
|
|
|
5506
5512
|
if (toolResult) {
|
|
5507
5513
|
const newContent = _content.map((c) => {
|
|
5508
5514
|
if (c.type === "tool-call" && c.toolCallId === toolResult?.toolCallId) {
|
|
5509
|
-
return { ...c, result: toolResult.
|
|
5515
|
+
return { ...c, result: toolResult.output?.value };
|
|
5510
5516
|
}
|
|
5511
5517
|
return c;
|
|
5512
5518
|
});
|
|
@@ -5515,7 +5521,7 @@ function MastraRuntimeProvider({
|
|
|
5515
5521
|
...acc,
|
|
5516
5522
|
content: containsToolCall ? newContent : [
|
|
5517
5523
|
..._content,
|
|
5518
|
-
{ type: "tool-result", toolCallId: toolResult.toolCallId, result: toolResult.
|
|
5524
|
+
{ type: "tool-result", toolCallId: toolResult.toolCallId, result: toolResult.output?.value }
|
|
5519
5525
|
]
|
|
5520
5526
|
};
|
|
5521
5527
|
}
|
|
@@ -5529,84 +5535,418 @@ function MastraRuntimeProvider({
|
|
|
5529
5535
|
{ role: "assistant", content: [] }
|
|
5530
5536
|
);
|
|
5531
5537
|
setMessages((currentConversation) => [...currentConversation, latestMessage]);
|
|
5532
|
-
|
|
5538
|
+
if (generatedResponse.finishReason) {
|
|
5539
|
+
handleFinishReason(generatedResponse.finishReason);
|
|
5540
|
+
}
|
|
5533
5541
|
}
|
|
5534
|
-
}
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5542
|
+
};
|
|
5543
|
+
if (modelVersion === "v2") {
|
|
5544
|
+
if (chatWithGenerateVNext) {
|
|
5545
|
+
const response = await agent.generateVNext({
|
|
5546
|
+
messages: [
|
|
5547
|
+
{
|
|
5548
|
+
role: "user",
|
|
5549
|
+
content: input
|
|
5550
|
+
},
|
|
5551
|
+
...attachments
|
|
5552
|
+
],
|
|
5553
|
+
runId: agentId,
|
|
5554
|
+
modelSettings: {
|
|
5555
|
+
frequencyPenalty,
|
|
5556
|
+
presencePenalty,
|
|
5557
|
+
maxRetries,
|
|
5558
|
+
temperature,
|
|
5559
|
+
topK,
|
|
5560
|
+
topP,
|
|
5561
|
+
maxOutputTokens: maxTokens
|
|
5562
|
+
},
|
|
5563
|
+
providerOptions,
|
|
5564
|
+
instructions,
|
|
5565
|
+
runtimeContext: runtimeContextInstance,
|
|
5566
|
+
...memory ? { threadId, resourceId: agentId } : {}
|
|
5567
|
+
});
|
|
5568
|
+
handleGenerateResponse(response);
|
|
5569
|
+
setIsRunning(false);
|
|
5570
|
+
return;
|
|
5571
|
+
} else {
|
|
5572
|
+
let updater = function() {
|
|
5573
|
+
setMessages((currentConversation) => {
|
|
5574
|
+
const message2 = {
|
|
5575
|
+
role: "assistant",
|
|
5576
|
+
content: [{ type: "text", text: content }]
|
|
5577
|
+
};
|
|
5578
|
+
if (!assistantMessageAdded) {
|
|
5579
|
+
assistantMessageAdded = true;
|
|
5580
|
+
if (assistantToolCallAddedForUpdater) {
|
|
5581
|
+
assistantToolCallAddedForUpdater = false;
|
|
5582
|
+
}
|
|
5583
|
+
return [...currentConversation, message2];
|
|
5584
|
+
}
|
|
5543
5585
|
if (assistantToolCallAddedForUpdater) {
|
|
5544
5586
|
assistantToolCallAddedForUpdater = false;
|
|
5587
|
+
return [...currentConversation, message2];
|
|
5588
|
+
}
|
|
5589
|
+
return [...currentConversation.slice(0, -1), message2];
|
|
5590
|
+
});
|
|
5591
|
+
};
|
|
5592
|
+
const response = await agent.streamVNext({
|
|
5593
|
+
messages: [
|
|
5594
|
+
{
|
|
5595
|
+
role: "user",
|
|
5596
|
+
content: input
|
|
5597
|
+
},
|
|
5598
|
+
...attachments
|
|
5599
|
+
],
|
|
5600
|
+
runId: agentId,
|
|
5601
|
+
modelSettings: {
|
|
5602
|
+
frequencyPenalty,
|
|
5603
|
+
presencePenalty,
|
|
5604
|
+
maxRetries,
|
|
5605
|
+
maxOutputTokens: maxTokens,
|
|
5606
|
+
temperature,
|
|
5607
|
+
topK,
|
|
5608
|
+
topP
|
|
5609
|
+
},
|
|
5610
|
+
instructions,
|
|
5611
|
+
runtimeContext: runtimeContextInstance,
|
|
5612
|
+
...memory ? { threadId, resourceId: agentId } : {},
|
|
5613
|
+
providerOptions
|
|
5614
|
+
});
|
|
5615
|
+
if (!response.body) {
|
|
5616
|
+
throw new Error("No response body");
|
|
5617
|
+
}
|
|
5618
|
+
let content = "";
|
|
5619
|
+
let assistantMessageAdded = false;
|
|
5620
|
+
let assistantToolCallAddedForUpdater = false;
|
|
5621
|
+
let assistantToolCallAddedForContent = false;
|
|
5622
|
+
await response.processDataStream({
|
|
5623
|
+
onChunk: async (chunk) => {
|
|
5624
|
+
switch (chunk.type) {
|
|
5625
|
+
case "text-delta": {
|
|
5626
|
+
if (assistantToolCallAddedForContent) {
|
|
5627
|
+
assistantToolCallAddedForContent = false;
|
|
5628
|
+
content = chunk.payload.text;
|
|
5629
|
+
} else {
|
|
5630
|
+
content += chunk.payload.text;
|
|
5631
|
+
}
|
|
5632
|
+
console.log(chunk.payload.text, "VALUE");
|
|
5633
|
+
updater();
|
|
5634
|
+
break;
|
|
5635
|
+
}
|
|
5636
|
+
case "tool-call": {
|
|
5637
|
+
setMessages((currentConversation) => {
|
|
5638
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5639
|
+
if (lastMessage && lastMessage.role === "assistant") {
|
|
5640
|
+
const updatedMessage = {
|
|
5641
|
+
...lastMessage,
|
|
5642
|
+
content: Array.isArray(lastMessage.content) ? [
|
|
5643
|
+
...lastMessage.content,
|
|
5644
|
+
{
|
|
5645
|
+
type: "tool-call",
|
|
5646
|
+
toolCallId: chunk.payload.toolCallId,
|
|
5647
|
+
toolName: chunk.payload.toolName,
|
|
5648
|
+
args: chunk.payload.args
|
|
5649
|
+
}
|
|
5650
|
+
] : [
|
|
5651
|
+
...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
|
|
5652
|
+
{
|
|
5653
|
+
type: "tool-call",
|
|
5654
|
+
toolCallId: chunk.payload.toolCallId,
|
|
5655
|
+
toolName: chunk.payload.toolName,
|
|
5656
|
+
args: chunk.payload.args
|
|
5657
|
+
}
|
|
5658
|
+
]
|
|
5659
|
+
};
|
|
5660
|
+
assistantToolCallAddedForUpdater = true;
|
|
5661
|
+
assistantToolCallAddedForContent = true;
|
|
5662
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5663
|
+
}
|
|
5664
|
+
const newMessage = {
|
|
5665
|
+
role: "assistant",
|
|
5666
|
+
content: [
|
|
5667
|
+
{ type: "text", text: content },
|
|
5668
|
+
{
|
|
5669
|
+
type: "tool-call",
|
|
5670
|
+
toolCallId: chunk.payload.toolCallId,
|
|
5671
|
+
toolName: chunk.payload.toolName,
|
|
5672
|
+
args: chunk.payload.args
|
|
5673
|
+
}
|
|
5674
|
+
]
|
|
5675
|
+
};
|
|
5676
|
+
assistantToolCallAddedForUpdater = true;
|
|
5677
|
+
assistantToolCallAddedForContent = true;
|
|
5678
|
+
return [...currentConversation, newMessage];
|
|
5679
|
+
});
|
|
5680
|
+
toolCallIdToName.current[chunk.payload.toolCallId] = chunk.payload.toolName;
|
|
5681
|
+
break;
|
|
5682
|
+
}
|
|
5683
|
+
case "tool-result": {
|
|
5684
|
+
setMessages((currentConversation) => {
|
|
5685
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5686
|
+
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
5687
|
+
const updatedContent = lastMessage.content.map((part) => {
|
|
5688
|
+
if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
|
|
5689
|
+
return {
|
|
5690
|
+
...part,
|
|
5691
|
+
result: chunk.payload.result
|
|
5692
|
+
};
|
|
5693
|
+
}
|
|
5694
|
+
return part;
|
|
5695
|
+
});
|
|
5696
|
+
const updatedMessage = {
|
|
5697
|
+
...lastMessage,
|
|
5698
|
+
content: updatedContent
|
|
5699
|
+
};
|
|
5700
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5701
|
+
}
|
|
5702
|
+
return currentConversation;
|
|
5703
|
+
});
|
|
5704
|
+
try {
|
|
5705
|
+
const toolName = toolCallIdToName.current[chunk.payload.toolCallId];
|
|
5706
|
+
if (toolName === "updateWorkingMemory" && chunk.payload.result?.success) {
|
|
5707
|
+
await refreshWorkingMemory?.();
|
|
5708
|
+
}
|
|
5709
|
+
} finally {
|
|
5710
|
+
delete toolCallIdToName.current[chunk.payload.toolCallId];
|
|
5711
|
+
}
|
|
5712
|
+
break;
|
|
5713
|
+
}
|
|
5714
|
+
case "error": {
|
|
5715
|
+
if (typeof chunk.payload.error === "string") {
|
|
5716
|
+
throw new Error(chunk.payload.error);
|
|
5717
|
+
}
|
|
5718
|
+
break;
|
|
5719
|
+
}
|
|
5720
|
+
case "finish": {
|
|
5721
|
+
handleFinishReason(chunk.payload.finishReason);
|
|
5722
|
+
break;
|
|
5723
|
+
}
|
|
5724
|
+
case "reasoning-delta": {
|
|
5725
|
+
setMessages((currentConversation) => {
|
|
5726
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5727
|
+
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
5728
|
+
const updatedContent = lastMessage.content.map((part) => {
|
|
5729
|
+
if (typeof part === "object" && part.type === "reasoning") {
|
|
5730
|
+
return {
|
|
5731
|
+
...part,
|
|
5732
|
+
text: part.text + chunk.payload.text
|
|
5733
|
+
};
|
|
5734
|
+
}
|
|
5735
|
+
return part;
|
|
5736
|
+
});
|
|
5737
|
+
const updatedMessage = {
|
|
5738
|
+
...lastMessage,
|
|
5739
|
+
content: updatedContent
|
|
5740
|
+
};
|
|
5741
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5742
|
+
}
|
|
5743
|
+
const newMessage = {
|
|
5744
|
+
role: "assistant",
|
|
5745
|
+
content: [
|
|
5746
|
+
{
|
|
5747
|
+
type: "reasoning",
|
|
5748
|
+
text: chunk.payload.text
|
|
5749
|
+
},
|
|
5750
|
+
{ type: "text", text: content }
|
|
5751
|
+
]
|
|
5752
|
+
};
|
|
5753
|
+
return [...currentConversation, newMessage];
|
|
5754
|
+
});
|
|
5755
|
+
break;
|
|
5756
|
+
}
|
|
5545
5757
|
}
|
|
5546
|
-
return [...currentConversation, message2];
|
|
5547
|
-
}
|
|
5548
|
-
if (assistantToolCallAddedForUpdater) {
|
|
5549
|
-
assistantToolCallAddedForUpdater = false;
|
|
5550
|
-
return [...currentConversation, message2];
|
|
5551
5758
|
}
|
|
5552
|
-
return [...currentConversation.slice(0, -1), message2];
|
|
5553
5759
|
});
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
messages: [
|
|
5557
|
-
{
|
|
5558
|
-
role: "user",
|
|
5559
|
-
content: input
|
|
5560
|
-
},
|
|
5561
|
-
...attachments
|
|
5562
|
-
],
|
|
5563
|
-
runId: agentId,
|
|
5564
|
-
frequencyPenalty,
|
|
5565
|
-
presencePenalty,
|
|
5566
|
-
maxRetries,
|
|
5567
|
-
maxSteps,
|
|
5568
|
-
maxTokens,
|
|
5569
|
-
temperature,
|
|
5570
|
-
topK,
|
|
5571
|
-
topP,
|
|
5572
|
-
instructions,
|
|
5573
|
-
runtimeContext: runtimeContextInstance,
|
|
5574
|
-
...memory ? { threadId, resourceId: agentId } : {},
|
|
5575
|
-
providerOptions
|
|
5576
|
-
});
|
|
5577
|
-
if (!response.body) {
|
|
5578
|
-
throw new Error("No response body");
|
|
5760
|
+
setIsRunning(false);
|
|
5761
|
+
return;
|
|
5579
5762
|
}
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5763
|
+
} else {
|
|
5764
|
+
if (chatWithGenerate) {
|
|
5765
|
+
const generateResponse = await agent.generate({
|
|
5766
|
+
messages: [
|
|
5767
|
+
{
|
|
5768
|
+
role: "user",
|
|
5769
|
+
content: input
|
|
5770
|
+
},
|
|
5771
|
+
...attachments
|
|
5772
|
+
],
|
|
5773
|
+
runId: agentId,
|
|
5774
|
+
frequencyPenalty,
|
|
5775
|
+
presencePenalty,
|
|
5776
|
+
maxRetries,
|
|
5777
|
+
maxSteps,
|
|
5778
|
+
maxTokens,
|
|
5779
|
+
temperature,
|
|
5780
|
+
topK,
|
|
5781
|
+
topP,
|
|
5782
|
+
instructions,
|
|
5783
|
+
runtimeContext: runtimeContextInstance,
|
|
5784
|
+
...memory ? { threadId, resourceId: agentId } : {},
|
|
5785
|
+
providerOptions
|
|
5786
|
+
});
|
|
5787
|
+
if (generateResponse.response && "messages" in generateResponse.response) {
|
|
5788
|
+
const latestMessage = generateResponse.response.messages.reduce(
|
|
5789
|
+
(acc, message2) => {
|
|
5790
|
+
const _content = Array.isArray(acc.content) ? acc.content : [];
|
|
5791
|
+
if (typeof message2.content === "string") {
|
|
5792
|
+
return {
|
|
5793
|
+
...acc,
|
|
5794
|
+
content: [
|
|
5795
|
+
..._content,
|
|
5796
|
+
...generateResponse.reasoning ? [{ type: "reasoning", text: generateResponse.reasoning }] : [],
|
|
5797
|
+
{
|
|
5798
|
+
type: "text",
|
|
5799
|
+
text: message2.content
|
|
5800
|
+
}
|
|
5801
|
+
]
|
|
5802
|
+
};
|
|
5803
|
+
}
|
|
5804
|
+
if (message2.role === "assistant") {
|
|
5805
|
+
const toolCallContent = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "tool-call") : void 0;
|
|
5806
|
+
const reasoningContent = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "reasoning") : void 0;
|
|
5807
|
+
if (toolCallContent) {
|
|
5808
|
+
const newContent = _content.map((c) => {
|
|
5809
|
+
if (c.type === "tool-call" && c.toolCallId === toolCallContent?.toolCallId) {
|
|
5810
|
+
return { ...c, ...toolCallContent };
|
|
5811
|
+
}
|
|
5812
|
+
return c;
|
|
5813
|
+
});
|
|
5814
|
+
const containsToolCall = newContent.some((c) => c.type === "tool-call");
|
|
5815
|
+
return {
|
|
5816
|
+
...acc,
|
|
5817
|
+
content: containsToolCall ? [...reasoningContent ? [reasoningContent] : [], ...newContent] : [..._content, ...reasoningContent ? [reasoningContent] : [], toolCallContent]
|
|
5818
|
+
};
|
|
5819
|
+
}
|
|
5820
|
+
const textContent = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "text" && content.text) : void 0;
|
|
5821
|
+
if (textContent) {
|
|
5822
|
+
return {
|
|
5823
|
+
...acc,
|
|
5824
|
+
content: [..._content, ...reasoningContent ? [reasoningContent] : [], textContent]
|
|
5825
|
+
};
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5828
|
+
if (message2.role === "tool") {
|
|
5829
|
+
const toolResult = Array.isArray(message2.content) ? message2.content.find((content) => content.type === "tool-result") : void 0;
|
|
5830
|
+
if (toolResult) {
|
|
5831
|
+
const newContent = _content.map((c) => {
|
|
5832
|
+
if (c.type === "tool-call" && c.toolCallId === toolResult?.toolCallId) {
|
|
5833
|
+
return { ...c, result: toolResult.result };
|
|
5834
|
+
}
|
|
5835
|
+
return c;
|
|
5836
|
+
});
|
|
5837
|
+
const containsToolCall = newContent.some((c) => c.type === "tool-call");
|
|
5838
|
+
return {
|
|
5839
|
+
...acc,
|
|
5840
|
+
content: containsToolCall ? newContent : [
|
|
5841
|
+
..._content,
|
|
5842
|
+
{ type: "tool-result", toolCallId: toolResult.toolCallId, result: toolResult.result }
|
|
5843
|
+
]
|
|
5844
|
+
};
|
|
5845
|
+
}
|
|
5846
|
+
return {
|
|
5847
|
+
...acc,
|
|
5848
|
+
content: [..._content, toolResult]
|
|
5849
|
+
};
|
|
5850
|
+
}
|
|
5851
|
+
return acc;
|
|
5852
|
+
},
|
|
5853
|
+
{ role: "assistant", content: [] }
|
|
5854
|
+
);
|
|
5855
|
+
setMessages((currentConversation) => [...currentConversation, latestMessage]);
|
|
5856
|
+
handleFinishReason(generateResponse.finishReason);
|
|
5857
|
+
}
|
|
5858
|
+
} else {
|
|
5859
|
+
let updater = function() {
|
|
5595
5860
|
setMessages((currentConversation) => {
|
|
5596
|
-
const
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5861
|
+
const message2 = {
|
|
5862
|
+
role: "assistant",
|
|
5863
|
+
content: [{ type: "text", text: content }]
|
|
5864
|
+
};
|
|
5865
|
+
if (!assistantMessageAdded) {
|
|
5866
|
+
assistantMessageAdded = true;
|
|
5867
|
+
if (assistantToolCallAddedForUpdater) {
|
|
5868
|
+
assistantToolCallAddedForUpdater = false;
|
|
5869
|
+
}
|
|
5870
|
+
return [...currentConversation, message2];
|
|
5871
|
+
}
|
|
5872
|
+
if (assistantToolCallAddedForUpdater) {
|
|
5873
|
+
assistantToolCallAddedForUpdater = false;
|
|
5874
|
+
return [...currentConversation, message2];
|
|
5875
|
+
}
|
|
5876
|
+
return [...currentConversation.slice(0, -1), message2];
|
|
5877
|
+
});
|
|
5878
|
+
};
|
|
5879
|
+
const response = await agent.stream({
|
|
5880
|
+
messages: [
|
|
5881
|
+
{
|
|
5882
|
+
role: "user",
|
|
5883
|
+
content: input
|
|
5884
|
+
},
|
|
5885
|
+
...attachments
|
|
5886
|
+
],
|
|
5887
|
+
runId: agentId,
|
|
5888
|
+
frequencyPenalty,
|
|
5889
|
+
presencePenalty,
|
|
5890
|
+
maxRetries,
|
|
5891
|
+
maxSteps,
|
|
5892
|
+
maxTokens,
|
|
5893
|
+
temperature,
|
|
5894
|
+
topK,
|
|
5895
|
+
topP,
|
|
5896
|
+
instructions,
|
|
5897
|
+
runtimeContext: runtimeContextInstance,
|
|
5898
|
+
...memory ? { threadId, resourceId: agentId } : {},
|
|
5899
|
+
providerOptions
|
|
5900
|
+
});
|
|
5901
|
+
if (!response.body) {
|
|
5902
|
+
throw new Error("No response body");
|
|
5903
|
+
}
|
|
5904
|
+
let content = "";
|
|
5905
|
+
let assistantMessageAdded = false;
|
|
5906
|
+
let assistantToolCallAddedForUpdater = false;
|
|
5907
|
+
let assistantToolCallAddedForContent = false;
|
|
5908
|
+
await response.processDataStream({
|
|
5909
|
+
onTextPart(value) {
|
|
5910
|
+
if (assistantToolCallAddedForContent) {
|
|
5911
|
+
assistantToolCallAddedForContent = false;
|
|
5912
|
+
content = value;
|
|
5913
|
+
} else {
|
|
5914
|
+
content += value;
|
|
5915
|
+
}
|
|
5916
|
+
updater();
|
|
5917
|
+
},
|
|
5918
|
+
async onToolCallPart(value) {
|
|
5919
|
+
setMessages((currentConversation) => {
|
|
5920
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5921
|
+
if (lastMessage && lastMessage.role === "assistant") {
|
|
5922
|
+
const updatedMessage = {
|
|
5923
|
+
...lastMessage,
|
|
5924
|
+
content: Array.isArray(lastMessage.content) ? [
|
|
5925
|
+
...lastMessage.content,
|
|
5926
|
+
{
|
|
5927
|
+
type: "tool-call",
|
|
5928
|
+
toolCallId: value.toolCallId,
|
|
5929
|
+
toolName: value.toolName,
|
|
5930
|
+
args: value.args
|
|
5931
|
+
}
|
|
5932
|
+
] : [
|
|
5933
|
+
...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
|
|
5934
|
+
{
|
|
5935
|
+
type: "tool-call",
|
|
5936
|
+
toolCallId: value.toolCallId,
|
|
5937
|
+
toolName: value.toolName,
|
|
5938
|
+
args: value.args
|
|
5939
|
+
}
|
|
5940
|
+
]
|
|
5941
|
+
};
|
|
5942
|
+
assistantToolCallAddedForUpdater = true;
|
|
5943
|
+
assistantToolCallAddedForContent = true;
|
|
5944
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5945
|
+
}
|
|
5946
|
+
const newMessage = {
|
|
5947
|
+
role: "assistant",
|
|
5948
|
+
content: [
|
|
5949
|
+
{ type: "text", text: content },
|
|
5610
5950
|
{
|
|
5611
5951
|
type: "tool-call",
|
|
5612
5952
|
toolCallId: value.toolCallId,
|
|
@@ -5617,95 +5957,80 @@ function MastraRuntimeProvider({
|
|
|
5617
5957
|
};
|
|
5618
5958
|
assistantToolCallAddedForUpdater = true;
|
|
5619
5959
|
assistantToolCallAddedForContent = true;
|
|
5620
|
-
return [...currentConversation
|
|
5960
|
+
return [...currentConversation, newMessage];
|
|
5961
|
+
});
|
|
5962
|
+
toolCallIdToName.current[value.toolCallId] = value.toolName;
|
|
5963
|
+
},
|
|
5964
|
+
async onToolResultPart(value) {
|
|
5965
|
+
setMessages((currentConversation) => {
|
|
5966
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5967
|
+
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
5968
|
+
const updatedContent = lastMessage.content.map((part) => {
|
|
5969
|
+
if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === value.toolCallId) {
|
|
5970
|
+
return {
|
|
5971
|
+
...part,
|
|
5972
|
+
result: value.result
|
|
5973
|
+
};
|
|
5974
|
+
}
|
|
5975
|
+
return part;
|
|
5976
|
+
});
|
|
5977
|
+
const updatedMessage = {
|
|
5978
|
+
...lastMessage,
|
|
5979
|
+
content: updatedContent
|
|
5980
|
+
};
|
|
5981
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5982
|
+
}
|
|
5983
|
+
return currentConversation;
|
|
5984
|
+
});
|
|
5985
|
+
try {
|
|
5986
|
+
const toolName = toolCallIdToName.current[value.toolCallId];
|
|
5987
|
+
if (toolName === "updateWorkingMemory" && value.result?.success) {
|
|
5988
|
+
await refreshWorkingMemory?.();
|
|
5989
|
+
}
|
|
5990
|
+
} finally {
|
|
5991
|
+
delete toolCallIdToName.current[value.toolCallId];
|
|
5621
5992
|
}
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5993
|
+
},
|
|
5994
|
+
onErrorPart(error) {
|
|
5995
|
+
throw new Error(error);
|
|
5996
|
+
},
|
|
5997
|
+
onFinishMessagePart({ finishReason }) {
|
|
5998
|
+
handleFinishReason(finishReason);
|
|
5999
|
+
},
|
|
6000
|
+
onReasoningPart(value) {
|
|
6001
|
+
setMessages((currentConversation) => {
|
|
6002
|
+
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
6003
|
+
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
6004
|
+
const updatedContent = lastMessage.content.map((part) => {
|
|
6005
|
+
if (typeof part === "object" && part.type === "reasoning") {
|
|
6006
|
+
return {
|
|
6007
|
+
...part,
|
|
6008
|
+
text: part.text + value
|
|
6009
|
+
};
|
|
6010
|
+
}
|
|
6011
|
+
return part;
|
|
6012
|
+
});
|
|
6013
|
+
const updatedMessage = {
|
|
6014
|
+
...lastMessage,
|
|
6015
|
+
content: updatedContent
|
|
6016
|
+
};
|
|
6017
|
+
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
6018
|
+
}
|
|
6019
|
+
const newMessage = {
|
|
6020
|
+
role: "assistant",
|
|
6021
|
+
content: [
|
|
6022
|
+
{
|
|
6023
|
+
type: "reasoning",
|
|
6024
|
+
text: value
|
|
6025
|
+
},
|
|
6026
|
+
{ type: "text", text: content }
|
|
6027
|
+
]
|
|
5656
6028
|
};
|
|
5657
|
-
return [...currentConversation
|
|
5658
|
-
}
|
|
5659
|
-
return currentConversation;
|
|
5660
|
-
});
|
|
5661
|
-
try {
|
|
5662
|
-
const toolName = toolCallIdToName.current[value.toolCallId];
|
|
5663
|
-
if (toolName === "updateWorkingMemory" && value.result?.success) {
|
|
5664
|
-
await refreshWorkingMemory?.();
|
|
5665
|
-
}
|
|
5666
|
-
} finally {
|
|
5667
|
-
delete toolCallIdToName.current[value.toolCallId];
|
|
6029
|
+
return [...currentConversation, newMessage];
|
|
6030
|
+
});
|
|
5668
6031
|
}
|
|
5669
|
-
}
|
|
5670
|
-
|
|
5671
|
-
throw new Error(error);
|
|
5672
|
-
},
|
|
5673
|
-
onFinishMessagePart({ finishReason }) {
|
|
5674
|
-
handleFinishReason(finishReason);
|
|
5675
|
-
},
|
|
5676
|
-
onReasoningPart(value) {
|
|
5677
|
-
setMessages((currentConversation) => {
|
|
5678
|
-
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
5679
|
-
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
5680
|
-
const updatedContent = lastMessage.content.map((part) => {
|
|
5681
|
-
if (typeof part === "object" && part.type === "reasoning") {
|
|
5682
|
-
return {
|
|
5683
|
-
...part,
|
|
5684
|
-
text: part.text + value
|
|
5685
|
-
};
|
|
5686
|
-
}
|
|
5687
|
-
return part;
|
|
5688
|
-
});
|
|
5689
|
-
const updatedMessage = {
|
|
5690
|
-
...lastMessage,
|
|
5691
|
-
content: updatedContent
|
|
5692
|
-
};
|
|
5693
|
-
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
5694
|
-
}
|
|
5695
|
-
const newMessage = {
|
|
5696
|
-
role: "assistant",
|
|
5697
|
-
content: [
|
|
5698
|
-
{
|
|
5699
|
-
type: "reasoning",
|
|
5700
|
-
text: value
|
|
5701
|
-
},
|
|
5702
|
-
{ type: "text", text: content }
|
|
5703
|
-
]
|
|
5704
|
-
};
|
|
5705
|
-
return [...currentConversation, newMessage];
|
|
5706
|
-
});
|
|
5707
|
-
}
|
|
5708
|
-
});
|
|
6032
|
+
});
|
|
6033
|
+
}
|
|
5709
6034
|
}
|
|
5710
6035
|
setIsRunning(false);
|
|
5711
6036
|
setTimeout(() => {
|
|
@@ -5755,7 +6080,8 @@ const defaultSettings = {
|
|
|
5755
6080
|
maxSteps: 5,
|
|
5756
6081
|
temperature: 0.5,
|
|
5757
6082
|
topP: 1,
|
|
5758
|
-
chatWithGenerate: false
|
|
6083
|
+
chatWithGenerate: false,
|
|
6084
|
+
chatWithGenerateVNext: false
|
|
5759
6085
|
}
|
|
5760
6086
|
};
|
|
5761
6087
|
function useAgentSettingsState({ agentId }) {
|
|
@@ -5827,7 +6153,8 @@ const AgentChat = ({
|
|
|
5827
6153
|
initialMessages,
|
|
5828
6154
|
memory,
|
|
5829
6155
|
refreshThreadList,
|
|
5830
|
-
onInputChange
|
|
6156
|
+
onInputChange,
|
|
6157
|
+
modelVersion
|
|
5831
6158
|
}) => {
|
|
5832
6159
|
const { settings } = useAgentSettings();
|
|
5833
6160
|
const { runtimeContext } = usePlaygroundStore();
|
|
@@ -5836,6 +6163,7 @@ const AgentChat = ({
|
|
|
5836
6163
|
{
|
|
5837
6164
|
agentId,
|
|
5838
6165
|
agentName,
|
|
6166
|
+
modelVersion,
|
|
5839
6167
|
threadId,
|
|
5840
6168
|
initialMessages,
|
|
5841
6169
|
memory,
|
|
@@ -6603,28 +6931,47 @@ const AgentAdvancedSettings = () => {
|
|
|
6603
6931
|
] }) });
|
|
6604
6932
|
};
|
|
6605
6933
|
|
|
6606
|
-
const AgentSettings = () => {
|
|
6934
|
+
const AgentSettings = ({ modelVersion }) => {
|
|
6607
6935
|
const { settings, setSettings, resetAll } = useAgentSettings();
|
|
6936
|
+
let radioValue;
|
|
6937
|
+
if (modelVersion === "v2") {
|
|
6938
|
+
radioValue = settings?.modelSettings?.chatWithGenerateVNext ? "generateVNext" : "streamVNext";
|
|
6939
|
+
} else {
|
|
6940
|
+
radioValue = settings?.modelSettings?.chatWithGenerate ? "generate" : "stream";
|
|
6941
|
+
}
|
|
6608
6942
|
return /* @__PURE__ */ jsxs("div", { className: "px-5 text-xs py-2 pb-4", children: [
|
|
6609
6943
|
/* @__PURE__ */ jsxs("section", { className: "space-y-7", children: [
|
|
6610
6944
|
/* @__PURE__ */ jsx(Entry, { label: "Chat Method", children: /* @__PURE__ */ jsxs(
|
|
6611
6945
|
RadioGroup,
|
|
6612
6946
|
{
|
|
6613
6947
|
orientation: "horizontal",
|
|
6614
|
-
value:
|
|
6948
|
+
value: radioValue,
|
|
6615
6949
|
onValueChange: (value) => setSettings({
|
|
6616
6950
|
...settings,
|
|
6617
|
-
modelSettings: {
|
|
6951
|
+
modelSettings: {
|
|
6952
|
+
...settings?.modelSettings,
|
|
6953
|
+
chatWithGenerate: value === "generate",
|
|
6954
|
+
chatWithGenerateVNext: value === "generateVNext",
|
|
6955
|
+
chatWithStreamVNext: value === "streamVNext"
|
|
6956
|
+
}
|
|
6618
6957
|
}),
|
|
6619
6958
|
className: "flex flex-row gap-4",
|
|
6620
6959
|
children: [
|
|
6621
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6960
|
+
modelVersion !== "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6622
6961
|
/* @__PURE__ */ jsx(RadioGroupItem, { value: "generate", id: "generate", className: "text-icon6" }),
|
|
6623
6962
|
/* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "generate", children: "Generate" })
|
|
6624
6963
|
] }),
|
|
6625
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6964
|
+
modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6965
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value: "generateVNext", id: "generateVNext", className: "text-icon6" }),
|
|
6966
|
+
/* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "generateVNext", children: "Generate vNext" })
|
|
6967
|
+
] }),
|
|
6968
|
+
modelVersion !== "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6626
6969
|
/* @__PURE__ */ jsx(RadioGroupItem, { value: "stream", id: "stream", className: "text-icon6" }),
|
|
6627
6970
|
/* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "stream", children: "Stream" })
|
|
6971
|
+
] }),
|
|
6972
|
+
modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
6973
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value: "streamVNext", id: "streamVNext", className: "text-icon6" }),
|
|
6974
|
+
/* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "streamVNext", children: "Stream vNext" })
|
|
6628
6975
|
] })
|
|
6629
6976
|
]
|
|
6630
6977
|
}
|
|
@@ -7761,8 +8108,8 @@ const ScorerEntity = ({ scorer }) => {
|
|
|
7761
8108
|
return /* @__PURE__ */ jsxs(Entity, { onClick: () => linkRef.current?.click(), children: [
|
|
7762
8109
|
/* @__PURE__ */ jsx(EntityIcon, { children: /* @__PURE__ */ jsx(GaugeIcon, { className: "group-hover/entity:text-accent3" }) }),
|
|
7763
8110
|
/* @__PURE__ */ jsxs(EntityContent, { children: [
|
|
7764
|
-
/* @__PURE__ */ jsx(EntityName, { children: /* @__PURE__ */ jsx(Link, { ref: linkRef, href: `/scorers/${scorer.id}`, children: scorer.scorer.name }) }),
|
|
7765
|
-
/* @__PURE__ */ jsx(EntityDescription, { children: scorer.scorer.description }),
|
|
8111
|
+
/* @__PURE__ */ jsx(EntityName, { children: /* @__PURE__ */ jsx(Link, { ref: linkRef, href: `/scorers/${scorer.id}`, children: scorer.scorer.config.name }) }),
|
|
8112
|
+
/* @__PURE__ */ jsx(EntityDescription, { children: scorer.scorer.config.description }),
|
|
7766
8113
|
scorer.sampling?.type === "ratio" && /* @__PURE__ */ jsxs(Badge$1, { children: [
|
|
7767
8114
|
/* @__PURE__ */ jsx("span", { className: "text-icon3", children: "Sample rate:" }),
|
|
7768
8115
|
/* @__PURE__ */ jsx("span", { className: "text-icon6", children: scorer.sampling.rate })
|
|
@@ -7771,20 +8118,365 @@ const ScorerEntity = ({ scorer }) => {
|
|
|
7771
8118
|
] });
|
|
7772
8119
|
};
|
|
7773
8120
|
|
|
8121
|
+
const openaiModels = [
|
|
8122
|
+
"o1",
|
|
8123
|
+
"o1-2024-12-17",
|
|
8124
|
+
"o3-mini",
|
|
8125
|
+
"o3-mini-2025-01-31",
|
|
8126
|
+
"o3",
|
|
8127
|
+
"o3-2025-04-16",
|
|
8128
|
+
"o4-mini",
|
|
8129
|
+
"o4-mini-2025-04-16",
|
|
8130
|
+
"codex-mini-latest",
|
|
8131
|
+
"computer-use-preview",
|
|
8132
|
+
"gpt-4.1",
|
|
8133
|
+
"gpt-4.1-2025-04-14",
|
|
8134
|
+
"gpt-4.1-mini",
|
|
8135
|
+
"gpt-4.1-mini-2025-04-14",
|
|
8136
|
+
"gpt-4.1-nano",
|
|
8137
|
+
"gpt-4.1-nano-2025-04-14",
|
|
8138
|
+
"gpt-4o",
|
|
8139
|
+
"gpt-4o-2024-05-13",
|
|
8140
|
+
"gpt-4o-2024-08-06",
|
|
8141
|
+
"gpt-4o-2024-11-20",
|
|
8142
|
+
"gpt-4o-audio-preview",
|
|
8143
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
8144
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
8145
|
+
"gpt-4o-search-preview",
|
|
8146
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
8147
|
+
"gpt-4o-mini-search-preview",
|
|
8148
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
8149
|
+
"gpt-4o-mini",
|
|
8150
|
+
"gpt-4o-mini-2024-07-18",
|
|
8151
|
+
"gpt-4-turbo",
|
|
8152
|
+
"gpt-4-turbo-2024-04-09",
|
|
8153
|
+
"gpt-4-turbo-preview",
|
|
8154
|
+
"gpt-4-0125-preview",
|
|
8155
|
+
"gpt-4-1106-preview",
|
|
8156
|
+
"gpt-4",
|
|
8157
|
+
"gpt-4-0613",
|
|
8158
|
+
"gpt-4.5-preview",
|
|
8159
|
+
"gpt-4.5-preview-2025-02-27",
|
|
8160
|
+
"gpt-3.5-turbo-0125",
|
|
8161
|
+
"gpt-3.5-turbo",
|
|
8162
|
+
"gpt-3.5-turbo-1106",
|
|
8163
|
+
"chatgpt-4o-latest",
|
|
8164
|
+
"gpt-5",
|
|
8165
|
+
"gpt-5-2025-08-07",
|
|
8166
|
+
"gpt-5-mini",
|
|
8167
|
+
"gpt-5-mini-2025-08-07",
|
|
8168
|
+
"gpt-5-nano",
|
|
8169
|
+
"gpt-5-nano-2025-08-07",
|
|
8170
|
+
"gpt-5-chat-latest"
|
|
8171
|
+
];
|
|
8172
|
+
const anthropicModels = [
|
|
8173
|
+
"claude-opus-4-20250514",
|
|
8174
|
+
"claude-sonnet-4-20250514",
|
|
8175
|
+
"claude-3-7-sonnet-20250219",
|
|
8176
|
+
"claude-3-5-sonnet-latest",
|
|
8177
|
+
"claude-3-5-sonnet-20241022",
|
|
8178
|
+
"claude-3-5-sonnet-20240620",
|
|
8179
|
+
"claude-3-5-haiku-latest",
|
|
8180
|
+
"claude-3-5-haiku-20241022",
|
|
8181
|
+
"claude-3-opus-latest",
|
|
8182
|
+
"claude-3-opus-20240229",
|
|
8183
|
+
"claude-3-sonnet-20240229",
|
|
8184
|
+
"claude-3-haiku-20240307"
|
|
8185
|
+
];
|
|
8186
|
+
const googleModels = [
|
|
8187
|
+
"gemini-1.5-flash",
|
|
8188
|
+
"gemini-1.5-flash-latest",
|
|
8189
|
+
"gemini-1.5-flash-001",
|
|
8190
|
+
"gemini-1.5-flash-002",
|
|
8191
|
+
"gemini-1.5-flash-8b",
|
|
8192
|
+
"gemini-1.5-flash-8b-latest",
|
|
8193
|
+
"gemini-1.5-flash-8b-001",
|
|
8194
|
+
"gemini-1.5-pro",
|
|
8195
|
+
"gemini-1.5-pro-latest",
|
|
8196
|
+
"gemini-1.5-pro-001",
|
|
8197
|
+
"gemini-1.5-pro-002",
|
|
8198
|
+
"gemini-2.0-flash",
|
|
8199
|
+
"gemini-2.0-flash-001",
|
|
8200
|
+
"gemini-2.0-flash-live-001",
|
|
8201
|
+
"gemini-2.0-flash-lite",
|
|
8202
|
+
"gemini-2.0-pro-exp-02-05",
|
|
8203
|
+
"gemini-2.0-flash-thinking-exp-01-21",
|
|
8204
|
+
"gemini-2.0-flash-exp",
|
|
8205
|
+
"gemini-2.5-pro",
|
|
8206
|
+
"gemini-2.5-flash",
|
|
8207
|
+
"gemini-2.5-flash-lite",
|
|
8208
|
+
"gemini-2.5-pro-exp-03-25",
|
|
8209
|
+
"gemini-2.5-flash-preview-04-17",
|
|
8210
|
+
"gemini-exp-1206",
|
|
8211
|
+
"gemma-3-12b-it",
|
|
8212
|
+
"gemma-3-27b-it"
|
|
8213
|
+
];
|
|
8214
|
+
const xAIModels = [
|
|
8215
|
+
"grok-4",
|
|
8216
|
+
"grok-4-0709",
|
|
8217
|
+
"grok-4-latest",
|
|
8218
|
+
"grok-3",
|
|
8219
|
+
"grok-3-latest",
|
|
8220
|
+
"grok-3-fast",
|
|
8221
|
+
"grok-3-fast-latest",
|
|
8222
|
+
"grok-3-mini",
|
|
8223
|
+
"grok-3-mini-latest",
|
|
8224
|
+
"grok-3-mini-fast",
|
|
8225
|
+
"grok-3-mini-fast-latest",
|
|
8226
|
+
"grok-2-vision-1212",
|
|
8227
|
+
"grok-2-vision",
|
|
8228
|
+
"grok-2-vision-latest",
|
|
8229
|
+
"grok-2-image-1212",
|
|
8230
|
+
"grok-2-image",
|
|
8231
|
+
"grok-2-image-latest",
|
|
8232
|
+
"grok-2-1212",
|
|
8233
|
+
"grok-2",
|
|
8234
|
+
"grok-2-latest",
|
|
8235
|
+
"grok-vision-beta",
|
|
8236
|
+
"grok-beta"
|
|
8237
|
+
];
|
|
8238
|
+
const groqModels = [
|
|
8239
|
+
"gemma2-9b-it",
|
|
8240
|
+
"llama-3.1-8b-instant",
|
|
8241
|
+
"llama-3.3-70b-versatile",
|
|
8242
|
+
"meta-llama/llama-guard-4-12b",
|
|
8243
|
+
"openai/gpt-oss-120b",
|
|
8244
|
+
"openai/gpt-oss-20b",
|
|
8245
|
+
"deepseek-r1-distill-llama-70b",
|
|
8246
|
+
"meta-llama/llama-4-maverick-17b-128e-instruct",
|
|
8247
|
+
"meta-llama/llama-4-scout-17b-16e-instruct",
|
|
8248
|
+
"meta-llama/llama-prompt-guard-2-22m",
|
|
8249
|
+
"meta-llama/llama-prompt-guard-2-86m",
|
|
8250
|
+
"mistral-saba-24b",
|
|
8251
|
+
"moonshotai/kimi-k2-instruct",
|
|
8252
|
+
"qwen/qwen3-32b",
|
|
8253
|
+
"llama-guard-3-8b",
|
|
8254
|
+
"llama3-70b-8192",
|
|
8255
|
+
"llama3-8b-8192",
|
|
8256
|
+
"mixtral-8x7b-32768",
|
|
8257
|
+
"qwen-qwq-32b",
|
|
8258
|
+
"qwen-2.5-32b",
|
|
8259
|
+
"deepseek-r1-distill-qwen-32b"
|
|
8260
|
+
];
|
|
8261
|
+
|
|
8262
|
+
const Select = SelectPrimitive.Root;
|
|
8263
|
+
const SelectValue = SelectPrimitive.Value;
|
|
8264
|
+
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
8265
|
+
SelectPrimitive.Trigger,
|
|
8266
|
+
{
|
|
8267
|
+
ref,
|
|
8268
|
+
className: cn(
|
|
8269
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
8270
|
+
className
|
|
8271
|
+
),
|
|
8272
|
+
...props,
|
|
8273
|
+
children: [
|
|
8274
|
+
children,
|
|
8275
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
8276
|
+
]
|
|
8277
|
+
}
|
|
8278
|
+
));
|
|
8279
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
8280
|
+
const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
8281
|
+
SelectPrimitive.Content,
|
|
8282
|
+
{
|
|
8283
|
+
ref,
|
|
8284
|
+
className: cn(
|
|
8285
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
8286
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
8287
|
+
className
|
|
8288
|
+
),
|
|
8289
|
+
position,
|
|
8290
|
+
...props,
|
|
8291
|
+
children: /* @__PURE__ */ jsx(
|
|
8292
|
+
SelectPrimitive.Viewport,
|
|
8293
|
+
{
|
|
8294
|
+
className: cn(
|
|
8295
|
+
"p-1",
|
|
8296
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
8297
|
+
),
|
|
8298
|
+
children
|
|
8299
|
+
}
|
|
8300
|
+
)
|
|
8301
|
+
}
|
|
8302
|
+
) }));
|
|
8303
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
8304
|
+
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
8305
|
+
SelectPrimitive.Item,
|
|
8306
|
+
{
|
|
8307
|
+
ref,
|
|
8308
|
+
className: cn(
|
|
8309
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-mastra-el-5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
8310
|
+
className
|
|
8311
|
+
),
|
|
8312
|
+
...props,
|
|
8313
|
+
children: [
|
|
8314
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
8315
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
8316
|
+
]
|
|
8317
|
+
}
|
|
8318
|
+
));
|
|
8319
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
8320
|
+
|
|
8321
|
+
const Popover = PopoverPrimitive.Root;
|
|
8322
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
8323
|
+
const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
8324
|
+
PopoverPrimitive.Content,
|
|
8325
|
+
{
|
|
8326
|
+
ref,
|
|
8327
|
+
align,
|
|
8328
|
+
sideOffset,
|
|
8329
|
+
className: cn(
|
|
8330
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
8331
|
+
className
|
|
8332
|
+
),
|
|
8333
|
+
...props
|
|
8334
|
+
}
|
|
8335
|
+
) }));
|
|
8336
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
8337
|
+
|
|
8338
|
+
const Models = {
|
|
8339
|
+
openai: {
|
|
8340
|
+
models: openaiModels?.map((model) => ({ provider: "openai", model, icon: "openai.chat" })),
|
|
8341
|
+
icon: "openai.chat"
|
|
8342
|
+
},
|
|
8343
|
+
anthropic: {
|
|
8344
|
+
models: anthropicModels?.map((model) => ({ provider: "anthropic", model, icon: "anthropic.messages" })),
|
|
8345
|
+
icon: "anthropic.messages"
|
|
8346
|
+
},
|
|
8347
|
+
google: {
|
|
8348
|
+
models: googleModels?.map((model) => ({ provider: "google", model, icon: "GOOGLE" })),
|
|
8349
|
+
icon: "GOOGLE"
|
|
8350
|
+
},
|
|
8351
|
+
xAi: {
|
|
8352
|
+
models: xAIModels?.map((model) => ({ provider: "xai", model, icon: "X_GROK" })),
|
|
8353
|
+
icon: "X_GROK"
|
|
8354
|
+
},
|
|
8355
|
+
groq: {
|
|
8356
|
+
models: groqModels?.map((model) => ({ provider: "groq", model, icon: "GROQ" })),
|
|
8357
|
+
icon: "GROQ"
|
|
8358
|
+
}
|
|
8359
|
+
};
|
|
8360
|
+
const AgentMetadataModelSwitcher = ({
|
|
8361
|
+
defaultProvider,
|
|
8362
|
+
defaultModel,
|
|
8363
|
+
updateModel,
|
|
8364
|
+
closeEditor,
|
|
8365
|
+
modelProviders
|
|
8366
|
+
}) => {
|
|
8367
|
+
const [selectedModel, setSelectedModel] = useState(defaultModel);
|
|
8368
|
+
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
8369
|
+
const [selectedProvider, setSelectedProvider] = useState(() => {
|
|
8370
|
+
if (defaultProvider) {
|
|
8371
|
+
const providerOnly = defaultProvider.split(".")[0];
|
|
8372
|
+
return providerOnly;
|
|
8373
|
+
}
|
|
8374
|
+
return "";
|
|
8375
|
+
});
|
|
8376
|
+
const [loading, setLoading] = useState(false);
|
|
8377
|
+
const modelsList = Object.entries(Models).filter(([provider]) => modelProviders.includes(provider));
|
|
8378
|
+
const allModels = modelsList.flatMap(([_, { models }]) => models);
|
|
8379
|
+
const providersList = modelsList.map(([provider, { icon }]) => ({ provider, icon }));
|
|
8380
|
+
const model = allModels.find((model2) => model2.model === selectedModel);
|
|
8381
|
+
const handleSave = async () => {
|
|
8382
|
+
setLoading(true);
|
|
8383
|
+
const providerToUse = model?.provider ?? selectedProvider;
|
|
8384
|
+
await updateModel({ provider: providerToUse, modelId: selectedModel });
|
|
8385
|
+
setLoading(false);
|
|
8386
|
+
closeEditor();
|
|
8387
|
+
};
|
|
8388
|
+
const filteredModels = allModels.filter((model2) => model2.model.includes(selectedModel));
|
|
8389
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8390
|
+
/* @__PURE__ */ jsxs(
|
|
8391
|
+
Select,
|
|
8392
|
+
{
|
|
8393
|
+
value: model?.provider ?? selectedProvider,
|
|
8394
|
+
onValueChange: setSelectedProvider,
|
|
8395
|
+
disabled: !!model?.provider,
|
|
8396
|
+
children: [
|
|
8397
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "max-w-[150px]", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select provider" }) }),
|
|
8398
|
+
/* @__PURE__ */ jsx(SelectContent, { children: providersList.map((provider) => /* @__PURE__ */ jsx(SelectItem, { value: provider.provider, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8399
|
+
/* @__PURE__ */ jsx(Icon, { children: providerMapToIcon[provider.icon] }),
|
|
8400
|
+
provider.provider
|
|
8401
|
+
] }) }, provider.provider)) })
|
|
8402
|
+
]
|
|
8403
|
+
}
|
|
8404
|
+
),
|
|
8405
|
+
/* @__PURE__ */ jsxs(Popover, { open: showSuggestions, children: [
|
|
8406
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
8407
|
+
Input,
|
|
8408
|
+
{
|
|
8409
|
+
id: "model-input",
|
|
8410
|
+
list: "model-suggestions",
|
|
8411
|
+
className: "flex-1",
|
|
8412
|
+
type: "text",
|
|
8413
|
+
value: selectedModel,
|
|
8414
|
+
onChange: (e) => {
|
|
8415
|
+
setSelectedModel(e.target.value);
|
|
8416
|
+
setShowSuggestions(true);
|
|
8417
|
+
},
|
|
8418
|
+
placeholder: "Enter model name or select from suggestions..."
|
|
8419
|
+
}
|
|
8420
|
+
) }),
|
|
8421
|
+
filteredModels.length > 0 && /* @__PURE__ */ jsx(
|
|
8422
|
+
PopoverContent,
|
|
8423
|
+
{
|
|
8424
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
8425
|
+
className: "flex flex-col gap-2 w-[var(--radix-popover-trigger-width)] max-h-[calc(var(--radix-popover-content-available-height)-50px)] overflow-y-auto",
|
|
8426
|
+
children: filteredModels.map((model2) => /* @__PURE__ */ jsxs(
|
|
8427
|
+
"div",
|
|
8428
|
+
{
|
|
8429
|
+
className: "flex items-center gap-2 cursor-pointer hover:bg-surface5 p-2",
|
|
8430
|
+
onClick: () => {
|
|
8431
|
+
setSelectedModel(model2.model);
|
|
8432
|
+
setShowSuggestions(false);
|
|
8433
|
+
},
|
|
8434
|
+
children: [
|
|
8435
|
+
/* @__PURE__ */ jsx(Icon, { children: providerMapToIcon[model2.icon] }),
|
|
8436
|
+
model2.model
|
|
8437
|
+
]
|
|
8438
|
+
},
|
|
8439
|
+
model2.provider + model2.model
|
|
8440
|
+
))
|
|
8441
|
+
}
|
|
8442
|
+
)
|
|
8443
|
+
] }),
|
|
8444
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8445
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleSave, className: "text-icon3 hover:text-icon6", children: /* @__PURE__ */ jsx(Icon, { children: loading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CircleCheck, {}) }) }) }),
|
|
8446
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: loading ? "Saving..." : "Save new model" })
|
|
8447
|
+
] })
|
|
8448
|
+
] }) });
|
|
8449
|
+
};
|
|
8450
|
+
|
|
7774
8451
|
const AgentMetadata = ({
|
|
7775
8452
|
agent,
|
|
7776
8453
|
promptSlot,
|
|
7777
8454
|
hasMemoryEnabled,
|
|
7778
8455
|
computeToolLink,
|
|
7779
|
-
computeWorkflowLink
|
|
8456
|
+
computeWorkflowLink,
|
|
8457
|
+
updateModel,
|
|
8458
|
+
modelProviders
|
|
7780
8459
|
}) => {
|
|
8460
|
+
const [isEditingModel, setIsEditingModel] = useState(false);
|
|
7781
8461
|
const providerIcon = providerMapToIcon[agent.provider || "openai.chat"];
|
|
7782
8462
|
const agentTools = agent.tools ?? {};
|
|
7783
8463
|
const tools = Object.keys(agentTools).map((key) => agentTools[key]);
|
|
7784
8464
|
const agentWorkflows = agent.workflows ?? {};
|
|
7785
8465
|
const workflows = Object.keys(agentWorkflows).map((key) => agentWorkflows[key]);
|
|
7786
8466
|
return /* @__PURE__ */ jsxs(AgentMetadataWrapper, { children: [
|
|
7787
|
-
/* @__PURE__ */ jsx(AgentMetadataSection, { title: "Model", children: /* @__PURE__ */ jsx(
|
|
8467
|
+
/* @__PURE__ */ jsx(AgentMetadataSection, { title: "Model", children: isEditingModel ? /* @__PURE__ */ jsx(
|
|
8468
|
+
AgentMetadataModelSwitcher,
|
|
8469
|
+
{
|
|
8470
|
+
defaultProvider: agent.provider,
|
|
8471
|
+
defaultModel: agent.modelId,
|
|
8472
|
+
updateModel,
|
|
8473
|
+
closeEditor: () => setIsEditingModel(false),
|
|
8474
|
+
modelProviders
|
|
8475
|
+
}
|
|
8476
|
+
) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8477
|
+
/* @__PURE__ */ jsx(Badge$1, { icon: providerIcon, className: "font-medium", children: agent.modelId || "N/A" }),
|
|
8478
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setIsEditingModel(true), className: "text-icon3 hover:text-icon6", children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(EditIcon, {}) }) })
|
|
8479
|
+
] }) }),
|
|
7788
8480
|
/* @__PURE__ */ jsx(
|
|
7789
8481
|
AgentMetadataSection,
|
|
7790
8482
|
{
|
|
@@ -11855,23 +12547,6 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }) {
|
|
|
11855
12547
|
}
|
|
11856
12548
|
Calendar.displayName = "Calendar";
|
|
11857
12549
|
|
|
11858
|
-
const Popover = PopoverPrimitive.Root;
|
|
11859
|
-
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
11860
|
-
const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
11861
|
-
PopoverPrimitive.Content,
|
|
11862
|
-
{
|
|
11863
|
-
ref,
|
|
11864
|
-
align,
|
|
11865
|
-
sideOffset,
|
|
11866
|
-
className: cn(
|
|
11867
|
-
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
11868
|
-
className
|
|
11869
|
-
),
|
|
11870
|
-
...props
|
|
11871
|
-
}
|
|
11872
|
-
) }));
|
|
11873
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
11874
|
-
|
|
11875
12550
|
const DatePicker = ({
|
|
11876
12551
|
value,
|
|
11877
12552
|
setValue,
|
|
@@ -12056,65 +12731,6 @@ const DateField = ({ inputProps, field, error, id }) => {
|
|
|
12056
12731
|
);
|
|
12057
12732
|
};
|
|
12058
12733
|
|
|
12059
|
-
const Select = SelectPrimitive.Root;
|
|
12060
|
-
const SelectValue = SelectPrimitive.Value;
|
|
12061
|
-
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
12062
|
-
SelectPrimitive.Trigger,
|
|
12063
|
-
{
|
|
12064
|
-
ref,
|
|
12065
|
-
className: cn(
|
|
12066
|
-
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
12067
|
-
className
|
|
12068
|
-
),
|
|
12069
|
-
...props,
|
|
12070
|
-
children: [
|
|
12071
|
-
children,
|
|
12072
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
12073
|
-
]
|
|
12074
|
-
}
|
|
12075
|
-
));
|
|
12076
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
12077
|
-
const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
12078
|
-
SelectPrimitive.Content,
|
|
12079
|
-
{
|
|
12080
|
-
ref,
|
|
12081
|
-
className: cn(
|
|
12082
|
-
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
12083
|
-
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
12084
|
-
className
|
|
12085
|
-
),
|
|
12086
|
-
position,
|
|
12087
|
-
...props,
|
|
12088
|
-
children: /* @__PURE__ */ jsx(
|
|
12089
|
-
SelectPrimitive.Viewport,
|
|
12090
|
-
{
|
|
12091
|
-
className: cn(
|
|
12092
|
-
"p-1",
|
|
12093
|
-
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
12094
|
-
),
|
|
12095
|
-
children
|
|
12096
|
-
}
|
|
12097
|
-
)
|
|
12098
|
-
}
|
|
12099
|
-
) }));
|
|
12100
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
12101
|
-
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
12102
|
-
SelectPrimitive.Item,
|
|
12103
|
-
{
|
|
12104
|
-
ref,
|
|
12105
|
-
className: cn(
|
|
12106
|
-
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-mastra-el-5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
12107
|
-
className
|
|
12108
|
-
),
|
|
12109
|
-
...props,
|
|
12110
|
-
children: [
|
|
12111
|
-
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
12112
|
-
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
12113
|
-
]
|
|
12114
|
-
}
|
|
12115
|
-
));
|
|
12116
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
12117
|
-
|
|
12118
12734
|
const SelectField = ({ field, inputProps, error, id, value }) => {
|
|
12119
12735
|
const { key, ...props } = inputProps;
|
|
12120
12736
|
return /* @__PURE__ */ jsxs(
|
|
@@ -12316,6 +12932,92 @@ function AutoForm({
|
|
|
12316
12932
|
|
|
12317
12933
|
buildZodFieldConfig();
|
|
12318
12934
|
|
|
12935
|
+
function inferFieldType(schema, fieldConfig) {
|
|
12936
|
+
if (fieldConfig?.fieldType) {
|
|
12937
|
+
return fieldConfig.fieldType;
|
|
12938
|
+
}
|
|
12939
|
+
if (schema instanceof z.ZodObject) return "object";
|
|
12940
|
+
if (schema instanceof z.ZodNumber) return "number";
|
|
12941
|
+
if (schema instanceof z.ZodBoolean) return "boolean";
|
|
12942
|
+
if (schema instanceof z.ZodString) {
|
|
12943
|
+
const checks = schema._zod.def.checks || [];
|
|
12944
|
+
const hasDateTimeCheck = checks.some(
|
|
12945
|
+
//@ts-expect-error - zod string_format check has format property
|
|
12946
|
+
(check) => check._zod.def.check === "string_format" && check._zod.def.format === "datetime"
|
|
12947
|
+
);
|
|
12948
|
+
if (hasDateTimeCheck) return "date";
|
|
12949
|
+
return "string";
|
|
12950
|
+
}
|
|
12951
|
+
if (schema instanceof z.ZodEnum) return "select";
|
|
12952
|
+
if (schema instanceof z$1.ZodNativeEnum) return "select";
|
|
12953
|
+
if (schema instanceof z.ZodArray) return "array";
|
|
12954
|
+
if (schema instanceof z.ZodRecord) return "record";
|
|
12955
|
+
return "string";
|
|
12956
|
+
}
|
|
12957
|
+
|
|
12958
|
+
function parseField(key, schema) {
|
|
12959
|
+
const baseSchema = getBaseSchema(schema);
|
|
12960
|
+
const fieldConfig = getFieldConfigInZodStack(schema);
|
|
12961
|
+
const type = inferFieldType(baseSchema, fieldConfig);
|
|
12962
|
+
const defaultValue = getDefaultValueInZodStack(schema);
|
|
12963
|
+
console.log({ baseSchema });
|
|
12964
|
+
const options = baseSchema._zod.def?.entries;
|
|
12965
|
+
let optionValues = [];
|
|
12966
|
+
if (options) {
|
|
12967
|
+
if (!Array.isArray(options)) {
|
|
12968
|
+
optionValues = Object.entries(options);
|
|
12969
|
+
} else {
|
|
12970
|
+
optionValues = options.map((value) => [value, value]);
|
|
12971
|
+
}
|
|
12972
|
+
}
|
|
12973
|
+
let subSchema = [];
|
|
12974
|
+
if (baseSchema instanceof z$1.ZodObject || baseSchema instanceof z.ZodObject) {
|
|
12975
|
+
subSchema = Object.entries(baseSchema.shape).map(([key2, field]) => parseField(key2, field));
|
|
12976
|
+
}
|
|
12977
|
+
if (baseSchema instanceof z$1.ZodArray || baseSchema instanceof z.ZodArray) {
|
|
12978
|
+
subSchema = [parseField("0", baseSchema._zod.def.element)];
|
|
12979
|
+
}
|
|
12980
|
+
return {
|
|
12981
|
+
key,
|
|
12982
|
+
type,
|
|
12983
|
+
required: !schema.optional(),
|
|
12984
|
+
default: defaultValue,
|
|
12985
|
+
description: baseSchema.description,
|
|
12986
|
+
fieldConfig,
|
|
12987
|
+
options: optionValues,
|
|
12988
|
+
schema: subSchema
|
|
12989
|
+
};
|
|
12990
|
+
}
|
|
12991
|
+
function getBaseSchema(schema) {
|
|
12992
|
+
if ("innerType" in schema._zod.def) {
|
|
12993
|
+
return getBaseSchema(schema._zod.def.innerType);
|
|
12994
|
+
}
|
|
12995
|
+
if ("schema" in schema._zod.def) {
|
|
12996
|
+
return getBaseSchema(schema._zod.def.schema);
|
|
12997
|
+
}
|
|
12998
|
+
return schema;
|
|
12999
|
+
}
|
|
13000
|
+
function parseSchema(schema) {
|
|
13001
|
+
const shape = schema.shape;
|
|
13002
|
+
const fields = Object.entries(shape).map(([key, field]) => parseField(key, field));
|
|
13003
|
+
return { fields };
|
|
13004
|
+
}
|
|
13005
|
+
class CustomZodProvider extends ZodProvider {
|
|
13006
|
+
_schema;
|
|
13007
|
+
constructor(schema) {
|
|
13008
|
+
super(schema);
|
|
13009
|
+
this._schema = schema;
|
|
13010
|
+
}
|
|
13011
|
+
validateSchema(values) {
|
|
13012
|
+
const result = super.validateSchema(values);
|
|
13013
|
+
console.log({ result });
|
|
13014
|
+
return result;
|
|
13015
|
+
}
|
|
13016
|
+
parseSchema() {
|
|
13017
|
+
return parseSchema(this._schema);
|
|
13018
|
+
}
|
|
13019
|
+
}
|
|
13020
|
+
|
|
12319
13021
|
function isEmptyZodObject(schema) {
|
|
12320
13022
|
if (schema instanceof ZodObject) {
|
|
12321
13023
|
return Object.keys(schema.shape).length === 0;
|
|
@@ -12338,16 +13040,16 @@ function DynamicForm({
|
|
|
12338
13040
|
}
|
|
12339
13041
|
const normalizedSchema = (schema2) => {
|
|
12340
13042
|
if (isEmptyZodObject(schema2)) {
|
|
12341
|
-
return z.object({});
|
|
13043
|
+
return z$2.object({});
|
|
12342
13044
|
}
|
|
12343
13045
|
if (isNotZodObject) {
|
|
12344
|
-
return z.object({
|
|
13046
|
+
return z$2.object({
|
|
12345
13047
|
"": schema2
|
|
12346
13048
|
});
|
|
12347
13049
|
}
|
|
12348
13050
|
return schema2;
|
|
12349
13051
|
};
|
|
12350
|
-
const schemaProvider = new
|
|
13052
|
+
const schemaProvider = new CustomZodProvider(normalizedSchema(schema));
|
|
12351
13053
|
const formProps = {
|
|
12352
13054
|
schema: schemaProvider,
|
|
12353
13055
|
onSubmit: async (values) => {
|
|
@@ -12369,7 +13071,7 @@ function DynamicForm({
|
|
|
12369
13071
|
}
|
|
12370
13072
|
|
|
12371
13073
|
function resolveSerializedZodOutput(obj) {
|
|
12372
|
-
return Function("z", `"use strict";return (${obj});`)(z
|
|
13074
|
+
return Function("z", `"use strict";return (${obj});`)(z);
|
|
12373
13075
|
}
|
|
12374
13076
|
|
|
12375
13077
|
function CodeBlockDemo({
|
|
@@ -12559,7 +13261,7 @@ function LegacyWorkflowTrigger({
|
|
|
12559
13261
|
) }),
|
|
12560
13262
|
isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
12561
13263
|
const stepDefinition = workflow.steps[step.stepId];
|
|
12562
|
-
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.inputSchema))) : z
|
|
13264
|
+
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.inputSchema))) : z.record(z.string(), z.any());
|
|
12563
13265
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-4", children: [
|
|
12564
13266
|
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
12565
13267
|
step.suspendPayload && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
@@ -12833,7 +13535,7 @@ function WorkflowTrigger({
|
|
|
12833
13535
|
!isStreamingWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
12834
13536
|
const stepDefinition = workflow.allSteps[step.stepId];
|
|
12835
13537
|
if (!stepDefinition || stepDefinition.isWorkflow) return null;
|
|
12836
|
-
const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.resumeSchema))) : z
|
|
13538
|
+
const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.resumeSchema))) : z.record(z.string(), z.any());
|
|
12837
13539
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-4", children: [
|
|
12838
13540
|
/* @__PURE__ */ jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
12839
13541
|
step.suspendPayload && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
@@ -13119,7 +13821,7 @@ const TracesTableError = ({ error, colsCount }) => {
|
|
|
13119
13821
|
};
|
|
13120
13822
|
const TraceRow = ({ trace, index, isActive }) => {
|
|
13121
13823
|
const { openTrace } = useOpenTrace();
|
|
13122
|
-
const hasFailure = trace.trace.some((span) => span.status.code
|
|
13824
|
+
const hasFailure = trace.trace.some((span) => span.status.code === 2);
|
|
13123
13825
|
return /* @__PURE__ */ jsxs(Row, { className: isActive ? "bg-surface4" : "", onClick: () => openTrace(trace.trace, index), children: [
|
|
13124
13826
|
/* @__PURE__ */ jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
|
|
13125
13827
|
/* @__PURE__ */ jsxs(TxtCell, { title: trace.traceId, children: [
|
|
@@ -13490,7 +14192,7 @@ function TraceDetails() {
|
|
|
13490
14192
|
const { trace, currentTraceIndex, prevTrace, nextTrace, traces } = useContext(TraceContext);
|
|
13491
14193
|
const actualTrace = traces[currentTraceIndex];
|
|
13492
14194
|
if (!actualTrace || !trace) return null;
|
|
13493
|
-
const hasFailure = trace.some((span) => span.status.code
|
|
14195
|
+
const hasFailure = trace.some((span) => span.status.code === 2);
|
|
13494
14196
|
return /* @__PURE__ */ jsxs("aside", { children: [
|
|
13495
14197
|
/* @__PURE__ */ jsxs(Header, { children: [
|
|
13496
14198
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
@@ -13612,11 +14314,11 @@ function SpanDetail() {
|
|
|
13612
14314
|
/* @__PURE__ */ jsx(Icon, { size: "lg", className: "bg-surface4 p-1 rounded-md", children: /* @__PURE__ */ jsx(SpanIcon, { className: variantClass }) }),
|
|
13613
14315
|
span.name
|
|
13614
14316
|
] }),
|
|
13615
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code ===
|
|
14317
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code === 2 ? /* @__PURE__ */ jsxs(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsx(X, {}), children: [
|
|
14318
|
+
"Failed in ",
|
|
13616
14319
|
toSigFigs(span.duration, 3),
|
|
13617
14320
|
"ms"
|
|
13618
|
-
] }) : /* @__PURE__ */ jsxs(Badge$1, {
|
|
13619
|
-
"Failed in ",
|
|
14321
|
+
] }) : /* @__PURE__ */ jsxs(Badge$1, { icon: /* @__PURE__ */ jsx(LatencyIcon, {}), variant: "success", children: [
|
|
13620
14322
|
toSigFigs(span.duration, 3),
|
|
13621
14323
|
"ms"
|
|
13622
14324
|
] }) }),
|