@mastra/playground-ui 5.1.1-alpha.1 → 5.1.1-alpha.4
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/colors-CBG_Mm7P.js +26 -0
- package/dist/colors-CBG_Mm7P.js.map +1 -0
- package/dist/colors-Du4i-E0i.cjs +30 -0
- package/dist/colors-Du4i-E0i.cjs.map +1 -0
- package/dist/index.cjs.js +694 -123
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +693 -126
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/thread.d.ts +2 -1
- package/dist/src/components/assistant-ui/use-has-attachments.d.ts +1 -0
- package/dist/src/components/ui/slider.d.ts +4 -0
- package/dist/src/domains/agents/agent/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/agent/context/agent-context.d.ts +4 -1
- package/dist/src/domains/workflows/context/use-current-run.d.ts +14 -0
- package/dist/src/domains/workflows/context/workflow-run-context.d.ts +3 -1
- package/dist/src/domains/workflows/index.d.ts +1 -0
- package/dist/src/domains/workflows/utils.d.ts +4 -0
- package/dist/src/domains/workflows/workflow/zoom-slider.d.ts +4 -0
- package/dist/src/ds/components/Button/Button.d.ts +1 -0
- package/dist/src/ds/icons/AgentNetworkCoinIcon.d.ts +1 -0
- package/dist/src/ds/icons/ToolCoinIcon.d.ts +3 -0
- package/dist/src/ds/icons/index.d.ts +2 -0
- package/dist/src/hooks/use-speech-recognition.d.ts +15 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/file.d.ts +1 -0
- package/dist/src/store/agent-store.d.ts +2 -2
- package/dist/src/types.d.ts +1 -0
- package/dist/tokens.cjs.js +5 -27
- package/dist/tokens.cjs.js.map +1 -1
- package/dist/tokens.es.js +3 -25
- package/dist/tokens.es.js.map +1 -1
- package/package.json +4 -3
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useMessage, MessagePrimitive, ActionBarPrimitive,
|
|
3
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc,
|
|
2
|
+
import { useMessage, MessagePrimitive, ActionBarPrimitive, useComposerRuntime, ComposerPrimitive, useAttachment, AttachmentPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
3
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, X, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Check, ChevronUp, ChevronDown, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, PauseIcon, Loader2, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Braces, Brackets, TrashIcon, Plus, Minus, Maximize, CirclePause } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { forwardRef, useState, useEffect, memo, useMemo, useRef, createContext, useContext, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
8
|
+
import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
|
|
8
9
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
9
10
|
import { unstable_memoizeMarkdownComponents, useIsMarkdownCodeBlock, MarkdownTextPrimitive } from '@assistant-ui/react-markdown';
|
|
10
11
|
import '@assistant-ui/react-markdown/styles/dot.css';
|
|
@@ -15,6 +16,8 @@ import { jsonLanguage } from '@codemirror/lang-json';
|
|
|
15
16
|
import { tags } from '@lezer/highlight';
|
|
16
17
|
import { draculaInit } from '@uiw/codemirror-theme-dracula';
|
|
17
18
|
import CodeMirror from '@uiw/react-codemirror';
|
|
19
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
20
|
+
import { useShallow } from 'zustand/shallow';
|
|
18
21
|
import { RuntimeContext } from '@mastra/core/di';
|
|
19
22
|
import { MastraClient } from '@mastra/client-js';
|
|
20
23
|
import { create } from 'zustand';
|
|
@@ -23,16 +26,16 @@ import { format, formatDistanceToNow, isValid } from 'date-fns';
|
|
|
23
26
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
24
27
|
import { toast } from 'sonner';
|
|
25
28
|
import { AnimatePresence } from 'motion/react';
|
|
29
|
+
import { C as Colors } from './colors-CBG_Mm7P.js';
|
|
26
30
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
27
31
|
import Markdown from 'react-markdown';
|
|
28
32
|
import { useDebouncedCallback } from 'use-debounce';
|
|
29
33
|
import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
|
|
30
|
-
import { MarkerType, Handle, Position, useNodesState, useEdgesState, ReactFlow, Controls, MiniMap, Background, BackgroundVariant, ReactFlowProvider } from '@xyflow/react';
|
|
34
|
+
import { MarkerType, Handle, Position, useNodesState, useEdgesState, ReactFlow, Controls, MiniMap, Background, BackgroundVariant, ReactFlowProvider, useViewport, useReactFlow, Panel } from '@xyflow/react';
|
|
31
35
|
import '@xyflow/react/dist/style.css';
|
|
32
36
|
import Dagre from '@dagrejs/dagre';
|
|
33
37
|
import { Highlight, themes } from 'prism-react-renderer';
|
|
34
38
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
35
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
36
39
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
37
40
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
38
41
|
import { parse } from 'superjson';
|
|
@@ -46,6 +49,7 @@ import { v4 } from '@lukeed/uuid';
|
|
|
46
49
|
import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod';
|
|
47
50
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
48
51
|
import { CodeBlock as CodeBlock$1 } from 'react-code-block';
|
|
52
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
49
53
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
50
54
|
|
|
51
55
|
import './index.css';function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
@@ -3893,6 +3897,83 @@ const McpCoinIcon = (props) => /* @__PURE__ */ jsxs("svg", { width: "126", heigh
|
|
|
3893
3897
|
)
|
|
3894
3898
|
] });
|
|
3895
3899
|
|
|
3900
|
+
const ToolCoinIcon = (props) => /* @__PURE__ */ jsxs("svg", { width: "126", height: "85", viewBox: "0 0 126 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
3901
|
+
/* @__PURE__ */ jsx(
|
|
3902
|
+
"path",
|
|
3903
|
+
{
|
|
3904
|
+
d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641V49.8368C6.67773 65.0327 31.894 77.3514 62.9998 77.3514C94.1055 77.3514 119.322 65.0327 119.322 49.8368V35.1641Z",
|
|
3905
|
+
fill: "#2E2E2E",
|
|
3906
|
+
fillOpacity: "0.9"
|
|
3907
|
+
}
|
|
3908
|
+
),
|
|
3909
|
+
/* @__PURE__ */ jsx(
|
|
3910
|
+
"path",
|
|
3911
|
+
{
|
|
3912
|
+
d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641M119.322 35.1641C119.322 19.9681 94.1055 7.64941 62.9998 7.64941C31.894 7.64941 6.67773 19.9681 6.67773 35.1641M119.322 35.1641V49.8368C119.322 65.0327 94.1055 77.3514 62.9998 77.3514C31.894 77.3514 6.67773 65.0327 6.67773 49.8368V35.1641",
|
|
3913
|
+
stroke: "#424242"
|
|
3914
|
+
}
|
|
3915
|
+
),
|
|
3916
|
+
/* @__PURE__ */ jsx(
|
|
3917
|
+
"path",
|
|
3918
|
+
{
|
|
3919
|
+
d: "M63.0002 0.96875C28.5152 0.96875 0.55957 15.6489 0.55957 33.7578V51.2433C0.55957 69.3522 28.5152 84.0323 63.0002 84.0323C97.4853 84.0323 125.441 69.3522 125.441 51.2433V33.7578C125.441 15.6489 97.4853 0.96875 63.0002 0.96875Z",
|
|
3920
|
+
stroke: "#707070"
|
|
3921
|
+
}
|
|
3922
|
+
),
|
|
3923
|
+
/* @__PURE__ */ jsx(
|
|
3924
|
+
"path",
|
|
3925
|
+
{
|
|
3926
|
+
fillRule: "evenodd",
|
|
3927
|
+
clipRule: "evenodd",
|
|
3928
|
+
d: "M95.8997 32.6647C98.4806 33.9355 98.4744 36.0012 95.8997 37.2689L89.6657 40.3384C87.0848 41.6091 82.8892 41.6061 80.3146 40.3384L74.0805 37.2689C71.4996 35.9981 71.5059 33.9324 74.0805 32.6647L80.3146 29.5952C82.8955 28.3244 87.091 28.3275 89.6657 29.5952L95.8997 32.6647ZM74.0805 21.9215C76.6614 23.1923 76.6552 25.258 74.0805 26.5257L67.8465 29.5952C65.2656 30.866 61.0701 30.8629 58.4954 29.5952L52.2613 26.5257C49.6804 25.255 49.6867 23.1892 52.2613 21.9215L58.4954 18.852C61.0763 17.5813 65.2718 17.5843 67.8465 18.852L74.0805 21.9215ZM74.0805 43.4079C76.6614 44.6786 76.6552 46.7444 74.0805 48.0121L67.8465 51.0816C65.2656 52.3523 61.0701 52.3493 58.4954 51.0816L52.2613 48.0121C49.6804 46.7413 49.6867 44.6756 52.2613 43.4079L58.4954 40.3384C61.0763 39.0676 65.2718 39.0707 67.8465 40.3384L74.0805 43.4079ZM52.2613 32.6647C54.8422 33.9355 54.836 36.0012 52.2613 37.2689L46.0273 40.3384C43.4464 41.6091 39.2509 41.6061 36.6762 40.3384L30.4422 37.2689C27.8613 35.9981 27.8675 33.9324 30.4422 32.6647L36.6762 29.5952C39.2571 28.3244 43.4526 28.3275 46.0273 29.5952L52.2613 32.6647Z",
|
|
3929
|
+
fill: "#A9A9A9"
|
|
3930
|
+
}
|
|
3931
|
+
)
|
|
3932
|
+
] });
|
|
3933
|
+
|
|
3934
|
+
const AgentNetworkCoinIcon = (props) => /* @__PURE__ */ jsxs("svg", { width: "126", height: "85", viewBox: "0 0 126 85", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
3935
|
+
/* @__PURE__ */ jsx(
|
|
3936
|
+
"path",
|
|
3937
|
+
{
|
|
3938
|
+
d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641V49.8368C6.67773 65.0327 31.894 77.3514 62.9998 77.3514C94.1055 77.3514 119.322 65.0327 119.322 49.8368V35.1641Z",
|
|
3939
|
+
fill: "#2E2E2E",
|
|
3940
|
+
fillOpacity: "0.9"
|
|
3941
|
+
}
|
|
3942
|
+
),
|
|
3943
|
+
/* @__PURE__ */ jsx(
|
|
3944
|
+
"path",
|
|
3945
|
+
{
|
|
3946
|
+
d: "M119.322 35.1641C119.322 50.36 94.1055 62.6787 62.9998 62.6787C31.894 62.6787 6.67773 50.36 6.67773 35.1641M119.322 35.1641C119.322 19.9681 94.1055 7.64941 62.9998 7.64941C31.894 7.64941 6.67773 19.9681 6.67773 35.1641M119.322 35.1641V49.8368C119.322 65.0327 94.1055 77.3514 62.9998 77.3514C31.894 77.3514 6.67773 65.0327 6.67773 49.8368V35.1641",
|
|
3947
|
+
stroke: "#424242"
|
|
3948
|
+
}
|
|
3949
|
+
),
|
|
3950
|
+
/* @__PURE__ */ jsx(
|
|
3951
|
+
"path",
|
|
3952
|
+
{
|
|
3953
|
+
d: "M63.0002 0.96875C28.5152 0.96875 0.55957 15.6489 0.55957 33.7578V51.2433C0.55957 69.3522 28.5152 84.0323 63.0002 84.0323C97.4853 84.0323 125.441 69.3522 125.441 51.2433V33.7578C125.441 15.6489 97.4853 0.96875 63.0002 0.96875Z",
|
|
3954
|
+
stroke: "#707070"
|
|
3955
|
+
}
|
|
3956
|
+
),
|
|
3957
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_23333_14744)", children: /* @__PURE__ */ jsx(
|
|
3958
|
+
"path",
|
|
3959
|
+
{
|
|
3960
|
+
fillRule: "evenodd",
|
|
3961
|
+
clipRule: "evenodd",
|
|
3962
|
+
d: "M79.2946 17.9539C83.0143 19.7854 83.016 22.7559 79.2979 24.5879C77.0214 25.7087 73.8794 26.1385 70.9301 25.8878L67.5296 30.2202C68.0944 30.3987 68.6321 30.6075 69.1262 30.8507C71.0847 31.815 72.0009 33.0948 71.8979 34.3581L77.2504 35.1977C77.6452 34.8727 78.1174 34.5635 78.6856 34.2835C82.4066 32.4514 88.4403 32.4485 92.1623 34.2803C95.8842 36.1128 95.8805 39.0851 92.159 40.9175C88.4373 42.7488 82.4002 42.7513 78.679 40.9191C76.7415 39.9647 75.8248 38.7009 75.9073 37.4506L70.5219 36.6045C70.1354 36.9168 69.6777 37.2145 69.1295 37.4846C68.345 37.8708 67.4527 38.1705 66.5059 38.3939L67.9312 41.984C70.1507 42.0573 72.3276 42.5087 74.0244 43.3438C77.7444 45.1754 77.7467 48.1458 74.0277 49.9778C70.3071 51.8092 64.2712 51.8095 60.551 49.9778C56.8323 48.1459 56.8351 45.1755 60.5543 43.3438C61.3581 42.9482 62.2741 42.6414 63.247 42.4167L61.8282 38.8428C59.5803 38.7777 57.3696 38.3299 55.6527 37.4846C54.1264 36.7327 53.2395 35.7882 52.9666 34.8103L43.924 34.0469C43.4596 34.6259 42.7547 35.1702 41.8041 35.6385C38.0834 37.4696 32.0473 37.4701 28.3273 35.6385C24.6089 33.8068 24.6123 30.8363 28.3306 29.0046C32.0508 27.1737 38.0806 27.1737 41.8008 29.0046C43.3459 29.7653 44.2412 30.7224 44.5033 31.7129L53.5098 32.4747C53.9742 31.8832 54.6868 31.3279 55.656 30.8507C57.6687 29.8601 60.357 29.4079 62.9902 29.4892L66.5783 24.9218C66.3174 24.8179 66.0637 24.7073 65.8212 24.5879C62.1022 22.7559 62.1045 19.7856 65.8245 17.9539C69.5447 16.1235 75.5747 16.1232 79.2946 17.9539ZM38.4299 30.6643C36.5715 29.75 33.5599 29.75 31.7015 30.6643C29.8447 31.5793 29.8414 33.0638 31.6982 33.9788C33.5565 34.8938 36.5742 34.8933 38.4332 33.9788C40.2906 33.0635 40.2883 31.5793 38.4299 30.6643ZM70.6536 45.0035C68.7951 44.0893 65.7836 44.0893 63.9251 45.0035C62.0676 45.9185 62.0647 47.4029 63.9218 48.318C65.7804 49.2332 68.7979 49.2329 70.6569 48.3181C72.5142 47.4027 72.5119 45.9185 70.6536 45.0035ZM65.7553 32.5104C63.8969 31.5961 60.8853 31.5961 59.0269 32.5104C57.1685 33.4254 57.1662 34.9096 59.0236 35.8249C60.8824 36.7402 63.8998 36.7402 65.7586 35.8249C67.616 34.9096 67.6137 33.4254 65.7553 32.5104ZM88.7915 35.94C86.9338 35.0261 83.9184 35.0264 82.0564 35.9432C80.1965 36.8601 80.1945 38.3451 82.0498 39.2594C83.9067 40.1736 86.9255 40.1738 88.7882 39.2578C90.6507 38.3407 90.649 36.8546 88.7915 35.94ZM75.9238 19.6136C74.0656 18.6995 71.0538 18.6998 69.1953 19.6136C67.3369 20.5286 67.3347 22.0129 69.192 22.9282C71.0509 23.8434 74.0682 23.8434 75.9271 22.9282C77.7836 22.0128 77.7818 20.5285 75.9238 19.6136Z",
|
|
3963
|
+
fill: "#A9A9A9"
|
|
3964
|
+
}
|
|
3965
|
+
) }),
|
|
3966
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_23333_14744", children: /* @__PURE__ */ jsx(
|
|
3967
|
+
"rect",
|
|
3968
|
+
{
|
|
3969
|
+
width: "59.3185",
|
|
3970
|
+
height: "59.3185",
|
|
3971
|
+
fill: "white",
|
|
3972
|
+
transform: "matrix(0.897148 0.441731 -0.897148 0.441731 65.3042 6.51953)"
|
|
3973
|
+
}
|
|
3974
|
+
) }) })
|
|
3975
|
+
] });
|
|
3976
|
+
|
|
3896
3977
|
const useCodemirrorTheme$1 = () => {
|
|
3897
3978
|
return useMemo(
|
|
3898
3979
|
() => draculaInit({
|
|
@@ -3989,8 +4070,156 @@ const AssistantActionBar = () => {
|
|
|
3989
4070
|
);
|
|
3990
4071
|
};
|
|
3991
4072
|
|
|
4073
|
+
const Dialog = DialogPrimitive.Root;
|
|
4074
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
4075
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
4076
|
+
const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4077
|
+
DialogPrimitive.Overlay,
|
|
4078
|
+
{
|
|
4079
|
+
ref,
|
|
4080
|
+
className: cn(
|
|
4081
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
4082
|
+
className
|
|
4083
|
+
),
|
|
4084
|
+
...props
|
|
4085
|
+
}
|
|
4086
|
+
));
|
|
4087
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
4088
|
+
const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
4089
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
4090
|
+
/* @__PURE__ */ jsxs(
|
|
4091
|
+
DialogPrimitive.Content,
|
|
4092
|
+
{
|
|
4093
|
+
ref,
|
|
4094
|
+
className: cn(
|
|
4095
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
4096
|
+
className
|
|
4097
|
+
),
|
|
4098
|
+
...props,
|
|
4099
|
+
children: [
|
|
4100
|
+
children,
|
|
4101
|
+
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
4102
|
+
/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
|
|
4103
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
4104
|
+
] })
|
|
4105
|
+
]
|
|
4106
|
+
}
|
|
4107
|
+
)
|
|
4108
|
+
] }));
|
|
4109
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
4110
|
+
const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4111
|
+
DialogPrimitive.Title,
|
|
4112
|
+
{
|
|
4113
|
+
ref,
|
|
4114
|
+
className: clsx("text-lg font-semibold leading-none tracking-tight", className),
|
|
4115
|
+
...props
|
|
4116
|
+
}
|
|
4117
|
+
));
|
|
4118
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
4119
|
+
const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
4120
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
4121
|
+
|
|
4122
|
+
const useHasAttachments = () => {
|
|
4123
|
+
const composer = useComposerRuntime();
|
|
4124
|
+
const [hasAttachments, setHasAttachments] = useState(false);
|
|
4125
|
+
useEffect(() => {
|
|
4126
|
+
composer.subscribe(() => {
|
|
4127
|
+
const attachments = composer.getState().attachments;
|
|
4128
|
+
setHasAttachments(attachments.length > 0);
|
|
4129
|
+
});
|
|
4130
|
+
}, [composer]);
|
|
4131
|
+
return hasAttachments;
|
|
4132
|
+
};
|
|
4133
|
+
|
|
4134
|
+
const useFileSrc = (file) => {
|
|
4135
|
+
const [src, setSrc] = useState(void 0);
|
|
4136
|
+
useEffect(() => {
|
|
4137
|
+
if (!file) {
|
|
4138
|
+
setSrc(void 0);
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
const objectUrl = URL.createObjectURL(file);
|
|
4142
|
+
setSrc(objectUrl);
|
|
4143
|
+
return () => {
|
|
4144
|
+
URL.revokeObjectURL(objectUrl);
|
|
4145
|
+
};
|
|
4146
|
+
}, [file]);
|
|
4147
|
+
return src;
|
|
4148
|
+
};
|
|
4149
|
+
const useAttachmentSrc = () => {
|
|
4150
|
+
const { file, src } = useAttachment(
|
|
4151
|
+
useShallow((a) => {
|
|
4152
|
+
if (a.type !== "image") return {};
|
|
4153
|
+
if (a.file) return { file: a.file };
|
|
4154
|
+
const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
|
|
4155
|
+
if (!src2) return {};
|
|
4156
|
+
return { src: src2 };
|
|
4157
|
+
})
|
|
4158
|
+
);
|
|
4159
|
+
return useFileSrc(file) ?? src;
|
|
4160
|
+
};
|
|
4161
|
+
const AttachmentPreview = ({ src }) => {
|
|
4162
|
+
return /* @__PURE__ */ jsx("div", { className: "overflow-hidden w-full", children: /* @__PURE__ */ jsx("img", { src, className: "object-contain aspect-ratio h-full w-full", alt: "Preview" }) });
|
|
4163
|
+
};
|
|
4164
|
+
const AttachmentPreviewDialog = ({ children }) => {
|
|
4165
|
+
const src = useAttachmentSrc();
|
|
4166
|
+
if (!src) return children;
|
|
4167
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [
|
|
4168
|
+
/* @__PURE__ */ jsx(DialogTrigger, { className: "hover:bg-accent/50 cursor-pointer transition-colors", asChild: true, children }),
|
|
4169
|
+
/* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
4170
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
4171
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: "max-w-5xl w-full max-h-[80%]", children: [
|
|
4172
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
|
|
4173
|
+
/* @__PURE__ */ jsx(AttachmentPreview, { src })
|
|
4174
|
+
] })
|
|
4175
|
+
] })
|
|
4176
|
+
] });
|
|
4177
|
+
};
|
|
4178
|
+
const AttachmentThumbnail = () => {
|
|
4179
|
+
const isImage = useAttachment((a) => a.type === "image");
|
|
4180
|
+
const src = useAttachmentSrc();
|
|
4181
|
+
const canRemove = useAttachment((a) => a.source !== "message");
|
|
4182
|
+
return /* @__PURE__ */ jsx(TooltipProvider$1, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4183
|
+
/* @__PURE__ */ jsxs(AttachmentPrimitive.Root, { className: "relative", children: [
|
|
4184
|
+
/* @__PURE__ */ jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsx("img", { src, className: "object-cover aspect-ratio size-16", alt: "Preview", height: 64, width: 64 }) }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsx(FileIcon, { className: "text-icon3" }) }) }) }) }),
|
|
4185
|
+
canRemove && /* @__PURE__ */ jsx(AttachmentRemove, {})
|
|
4186
|
+
] }),
|
|
4187
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) })
|
|
4188
|
+
] }) });
|
|
4189
|
+
};
|
|
4190
|
+
const AttachmentRemove = () => {
|
|
4191
|
+
return /* @__PURE__ */ jsx(AttachmentPrimitive.Remove, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
4192
|
+
TooltipIconButton,
|
|
4193
|
+
{
|
|
4194
|
+
tooltip: "Remove file",
|
|
4195
|
+
className: "absolute -right-3 -top-3 hover:bg-transparent rounded-full bg-surface1 rounded-full p-1",
|
|
4196
|
+
side: "top",
|
|
4197
|
+
children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CircleXIcon, {}) })
|
|
4198
|
+
}
|
|
4199
|
+
) });
|
|
4200
|
+
};
|
|
4201
|
+
const UserMessageAttachments = () => {
|
|
4202
|
+
return /* @__PURE__ */ jsx(MessagePrimitive.Attachments, { components: { Attachment: InMessageAttachment } });
|
|
4203
|
+
};
|
|
4204
|
+
const InMessageAttachment = () => {
|
|
4205
|
+
const isImage = useAttachment((a) => a.type === "image");
|
|
4206
|
+
const src = useAttachmentSrc();
|
|
4207
|
+
return /* @__PURE__ */ jsx(TooltipProvider$1, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4208
|
+
/* @__PURE__ */ jsx(AttachmentPrimitive.Root, { className: "relative pt-4", children: /* @__PURE__ */ jsx(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full aspect-ratio overflow-hidden rounded-lg", children: isImage ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 overflow-hidden", children: /* @__PURE__ */ jsx("img", { src, className: "object-cover aspect-ratio max-h-[140px] max-w-[320px]", alt: "Preview" }) }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsx(FileIcon, { className: "text-icon3" }) }) }) }) }) }),
|
|
4209
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) })
|
|
4210
|
+
] }) });
|
|
4211
|
+
};
|
|
4212
|
+
const ComposerAttachments = () => {
|
|
4213
|
+
const hasAttachments = useHasAttachments();
|
|
4214
|
+
if (!hasAttachments) return null;
|
|
4215
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-row items-center gap-4 h-24", children: /* @__PURE__ */ jsx(ComposerPrimitive.Attachments, { components: { Attachment: AttachmentThumbnail } }) });
|
|
4216
|
+
};
|
|
4217
|
+
|
|
3992
4218
|
const UserMessage = () => {
|
|
3993
|
-
return /* @__PURE__ */
|
|
4219
|
+
return /* @__PURE__ */ jsxs(MessagePrimitive.Root, { className: "w-full flex items-end pb-4 flex-col", children: [
|
|
4220
|
+
/* @__PURE__ */ jsx("div", { className: "max-w-[366px] px-5 py-3 text-icon6 text-ui-lg leading-ui-lg rounded-lg bg-surface3", children: /* @__PURE__ */ jsx(MessagePrimitive.Content, {}) }),
|
|
4221
|
+
/* @__PURE__ */ jsx(UserMessageAttachments, {})
|
|
4222
|
+
] });
|
|
3994
4223
|
};
|
|
3995
4224
|
|
|
3996
4225
|
const useAutoscroll = (ref, { enabled = true }) => {
|
|
@@ -4045,13 +4274,63 @@ const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) =
|
|
|
4045
4274
|
return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
4046
4275
|
};
|
|
4047
4276
|
|
|
4048
|
-
const
|
|
4277
|
+
const useSpeechRecognition = ({ language = "en-US" } = {}) => {
|
|
4278
|
+
const speechRecognitionRef = useRef(null);
|
|
4279
|
+
const [state, setState] = useState({
|
|
4280
|
+
isListening: false,
|
|
4281
|
+
transcript: "",
|
|
4282
|
+
error: null
|
|
4283
|
+
});
|
|
4284
|
+
const start = () => {
|
|
4285
|
+
if (!speechRecognitionRef.current) return;
|
|
4286
|
+
speechRecognitionRef.current.start();
|
|
4287
|
+
};
|
|
4288
|
+
const stop = () => {
|
|
4289
|
+
if (!speechRecognitionRef.current) return;
|
|
4290
|
+
speechRecognitionRef.current.stop();
|
|
4291
|
+
};
|
|
4292
|
+
useEffect(() => {
|
|
4293
|
+
if (!("webkitSpeechRecognition" in window) && !("SpeechRecognition" in window)) {
|
|
4294
|
+
setState((prev) => ({ ...prev, error: "Speech Recognition not supported in this browser" }));
|
|
4295
|
+
return;
|
|
4296
|
+
}
|
|
4297
|
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
4298
|
+
const recognition = new SpeechRecognition();
|
|
4299
|
+
speechRecognitionRef.current = recognition;
|
|
4300
|
+
recognition.continuous = true;
|
|
4301
|
+
recognition.lang = language;
|
|
4302
|
+
recognition.onstart = () => {
|
|
4303
|
+
setState((prev) => ({ ...prev, isListening: true }));
|
|
4304
|
+
};
|
|
4305
|
+
recognition.onresult = (event) => {
|
|
4306
|
+
let finalTranscript = "";
|
|
4307
|
+
for (let i = event.resultIndex; i < event.results.length; i++) {
|
|
4308
|
+
const transcript = event.results[i][0].transcript;
|
|
4309
|
+
if (event.results[i].isFinal) {
|
|
4310
|
+
finalTranscript += transcript + " ";
|
|
4311
|
+
}
|
|
4312
|
+
}
|
|
4313
|
+
setState((prev) => ({ ...prev, transcript: finalTranscript }));
|
|
4314
|
+
};
|
|
4315
|
+
recognition.onerror = (event) => {
|
|
4316
|
+
setState((prev) => ({ ...prev, error: `Error: ${event.error}` }));
|
|
4317
|
+
};
|
|
4318
|
+
recognition.onend = () => setState((prev) => ({ ...prev, isListening: false }));
|
|
4319
|
+
}, [language]);
|
|
4320
|
+
return {
|
|
4321
|
+
...state,
|
|
4322
|
+
start,
|
|
4323
|
+
stop
|
|
4324
|
+
};
|
|
4325
|
+
};
|
|
4326
|
+
|
|
4327
|
+
const Thread = ({ ToolFallback, agentName, hasMemory, showFileSupport }) => {
|
|
4049
4328
|
const areaRef = useRef(null);
|
|
4050
4329
|
useAutoscroll(areaRef, { enabled: true });
|
|
4051
4330
|
const WrappedAssistantMessage = (props) => {
|
|
4052
4331
|
return /* @__PURE__ */ jsx(AssistantMessage, { ...props, ToolFallback });
|
|
4053
4332
|
};
|
|
4054
|
-
return /* @__PURE__ */ jsxs(
|
|
4333
|
+
return /* @__PURE__ */ jsxs(ThreadWrapper, { children: [
|
|
4055
4334
|
/* @__PURE__ */ jsxs(ThreadPrimitive.Viewport, { className: "py-10 overflow-y-auto scroll-smooth h-full", ref: areaRef, autoScroll: false, children: [
|
|
4056
4335
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
4057
4336
|
/* @__PURE__ */ jsx(ThreadWelcome, { agentName }),
|
|
@@ -4068,9 +4347,22 @@ const Thread = ({ ToolFallback, agentName, hasMemory }) => {
|
|
|
4068
4347
|
] }),
|
|
4069
4348
|
/* @__PURE__ */ jsx(ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsx("div", {}) })
|
|
4070
4349
|
] }),
|
|
4071
|
-
/* @__PURE__ */ jsx(Composer, { hasMemory })
|
|
4350
|
+
/* @__PURE__ */ jsx(Composer, { hasMemory, showFileSupport })
|
|
4072
4351
|
] });
|
|
4073
4352
|
};
|
|
4353
|
+
const ThreadWrapper = ({ children }) => {
|
|
4354
|
+
const hasAttachments = useHasAttachments();
|
|
4355
|
+
return /* @__PURE__ */ jsx(
|
|
4356
|
+
ThreadPrimitive.Root,
|
|
4357
|
+
{
|
|
4358
|
+
className: clsx(
|
|
4359
|
+
"max-w-[568px] w-full mx-auto px-4",
|
|
4360
|
+
hasAttachments ? "h-[calc(100%-208px)]" : "h-[calc(100%-112px)]"
|
|
4361
|
+
),
|
|
4362
|
+
children
|
|
4363
|
+
}
|
|
4364
|
+
);
|
|
4365
|
+
};
|
|
4074
4366
|
const ThreadWelcome = ({ agentName }) => {
|
|
4075
4367
|
const safeAgentName = agentName ?? "";
|
|
4076
4368
|
const words = safeAgentName.split(" ") ?? [];
|
|
@@ -4087,20 +4379,26 @@ const ThreadWelcome = ({ agentName }) => {
|
|
|
4087
4379
|
/* @__PURE__ */ jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
|
|
4088
4380
|
] }) });
|
|
4089
4381
|
};
|
|
4090
|
-
const Composer = ({ hasMemory }) => {
|
|
4382
|
+
const Composer = ({ hasMemory, showFileSupport }) => {
|
|
4091
4383
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4092
|
-
/* @__PURE__ */ jsxs(ComposerPrimitive.Root, {
|
|
4093
|
-
/* @__PURE__ */ jsx(
|
|
4094
|
-
|
|
4095
|
-
{
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4384
|
+
/* @__PURE__ */ jsxs(ComposerPrimitive.Root, { children: [
|
|
4385
|
+
/* @__PURE__ */ jsx(ComposerAttachments, {}),
|
|
4386
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full bg-surface3 rounded-lg border-sm border-border1 px-3 py-4 mt-auto h-[100px]", children: [
|
|
4387
|
+
/* @__PURE__ */ jsx(ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(
|
|
4388
|
+
"textarea",
|
|
4389
|
+
{
|
|
4390
|
+
className: "text-ui-lg leading-ui-lg placeholder:text-icon3 text-icon6 bg-transparent focus:outline-none resize-none",
|
|
4391
|
+
autoFocus: true,
|
|
4392
|
+
placeholder: "Enter your message...",
|
|
4393
|
+
name: "",
|
|
4394
|
+
id: ""
|
|
4395
|
+
}
|
|
4396
|
+
) }),
|
|
4397
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
4398
|
+
/* @__PURE__ */ jsx(SpeechInput, {}),
|
|
4399
|
+
/* @__PURE__ */ jsx(ComposerAction, { showFileSupport })
|
|
4400
|
+
] })
|
|
4401
|
+
] })
|
|
4104
4402
|
] }),
|
|
4105
4403
|
!hasMemory && /* @__PURE__ */ jsxs(Txt, { variant: "ui-sm", className: "text-icon3 flex items-center gap-2 pt-0.5", children: [
|
|
4106
4404
|
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(InfoIcon, {}) }),
|
|
@@ -4108,8 +4406,28 @@ const Composer = ({ hasMemory }) => {
|
|
|
4108
4406
|
] })
|
|
4109
4407
|
] });
|
|
4110
4408
|
};
|
|
4111
|
-
const
|
|
4409
|
+
const SpeechInput = () => {
|
|
4410
|
+
const composerRuntime = useComposerRuntime();
|
|
4411
|
+
const { start, stop, isListening, transcript } = useSpeechRecognition();
|
|
4412
|
+
useEffect(() => {
|
|
4413
|
+
if (!transcript) return;
|
|
4414
|
+
composerRuntime.setText(transcript);
|
|
4415
|
+
}, [composerRuntime, transcript]);
|
|
4416
|
+
return /* @__PURE__ */ jsx(
|
|
4417
|
+
TooltipIconButton,
|
|
4418
|
+
{
|
|
4419
|
+
type: "button",
|
|
4420
|
+
tooltip: isListening ? "Stop dictation" : "Start dictation",
|
|
4421
|
+
variant: "ghost",
|
|
4422
|
+
className: "rounded-full",
|
|
4423
|
+
onClick: () => isListening ? stop() : start(),
|
|
4424
|
+
children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4425
|
+
}
|
|
4426
|
+
);
|
|
4427
|
+
};
|
|
4428
|
+
const ComposerAction = ({ showFileSupport }) => {
|
|
4112
4429
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4430
|
+
showFileSupport && /* @__PURE__ */ jsx(ComposerPrimitive.AddAttachment, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Add attachment", variant: "ghost", className: "rounded-full", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" }) }) }),
|
|
4113
4431
|
/* @__PURE__ */ jsx(ThreadPrimitive.If, { running: false, children: /* @__PURE__ */ jsx(ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
4114
4432
|
TooltipIconButton,
|
|
4115
4433
|
{
|
|
@@ -4143,9 +4461,40 @@ const createMastraClient = (baseUrl) => {
|
|
|
4143
4461
|
});
|
|
4144
4462
|
};
|
|
4145
4463
|
|
|
4464
|
+
const fileToBase64 = async (file) => {
|
|
4465
|
+
return new Promise((resolve, reject) => {
|
|
4466
|
+
const reader = new FileReader();
|
|
4467
|
+
reader.onload = () => {
|
|
4468
|
+
const result = reader.result;
|
|
4469
|
+
if (typeof result === "string") {
|
|
4470
|
+
resolve(result);
|
|
4471
|
+
} else {
|
|
4472
|
+
reject(new Error("Failed to convert file to base64."));
|
|
4473
|
+
}
|
|
4474
|
+
};
|
|
4475
|
+
reader.onerror = (error) => {
|
|
4476
|
+
reject(error);
|
|
4477
|
+
};
|
|
4478
|
+
reader.readAsDataURL(file);
|
|
4479
|
+
});
|
|
4480
|
+
};
|
|
4481
|
+
|
|
4146
4482
|
const convertMessage$1 = (message) => {
|
|
4147
4483
|
return message;
|
|
4148
4484
|
};
|
|
4485
|
+
const convertToAIAttachments = async (attachments) => {
|
|
4486
|
+
const promises = attachments.filter((attachment) => attachment.file).map(async (attachment) => ({
|
|
4487
|
+
role: "user",
|
|
4488
|
+
content: [
|
|
4489
|
+
{
|
|
4490
|
+
type: "image",
|
|
4491
|
+
image: await fileToBase64(attachment.file),
|
|
4492
|
+
mimeType: attachment.file.type
|
|
4493
|
+
}
|
|
4494
|
+
]
|
|
4495
|
+
}));
|
|
4496
|
+
return Promise.all(promises);
|
|
4497
|
+
};
|
|
4149
4498
|
function MastraRuntimeProvider({
|
|
4150
4499
|
children,
|
|
4151
4500
|
agentId,
|
|
@@ -4198,8 +4547,12 @@ function MastraRuntimeProvider({
|
|
|
4198
4547
|
const agent = mastra.getAgent(agentId);
|
|
4199
4548
|
const onNew = async (message) => {
|
|
4200
4549
|
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
4550
|
+
const attachments = await convertToAIAttachments(message.attachments);
|
|
4201
4551
|
const input = message.content[0].text;
|
|
4202
|
-
setMessages((currentConversation) => [
|
|
4552
|
+
setMessages((currentConversation) => [
|
|
4553
|
+
...currentConversation,
|
|
4554
|
+
{ role: "user", content: input, attachments: message.attachments }
|
|
4555
|
+
]);
|
|
4203
4556
|
setIsRunning(true);
|
|
4204
4557
|
try {
|
|
4205
4558
|
if (chatWithGenerate) {
|
|
@@ -4208,7 +4561,8 @@ function MastraRuntimeProvider({
|
|
|
4208
4561
|
{
|
|
4209
4562
|
role: "user",
|
|
4210
4563
|
content: input
|
|
4211
|
-
}
|
|
4564
|
+
},
|
|
4565
|
+
...attachments
|
|
4212
4566
|
],
|
|
4213
4567
|
runId: agentId,
|
|
4214
4568
|
frequencyPenalty,
|
|
@@ -4317,7 +4671,8 @@ function MastraRuntimeProvider({
|
|
|
4317
4671
|
{
|
|
4318
4672
|
role: "user",
|
|
4319
4673
|
content: input
|
|
4320
|
-
}
|
|
4674
|
+
},
|
|
4675
|
+
...attachments
|
|
4321
4676
|
],
|
|
4322
4677
|
runId: agentId,
|
|
4323
4678
|
frequencyPenalty,
|
|
@@ -4438,7 +4793,10 @@ function MastraRuntimeProvider({
|
|
|
4438
4793
|
isRunning,
|
|
4439
4794
|
messages,
|
|
4440
4795
|
convertMessage: convertMessage$1,
|
|
4441
|
-
onNew
|
|
4796
|
+
onNew,
|
|
4797
|
+
adapters: {
|
|
4798
|
+
attachments: new CompositeAttachmentAdapter([new SimpleImageAttachmentAdapter()])
|
|
4799
|
+
}
|
|
4442
4800
|
});
|
|
4443
4801
|
return /* @__PURE__ */ jsxs(AssistantRuntimeProvider, { runtime, children: [
|
|
4444
4802
|
" ",
|
|
@@ -4468,23 +4826,47 @@ const defaultModelSettings$1 = {
|
|
|
4468
4826
|
topP: 1
|
|
4469
4827
|
};
|
|
4470
4828
|
const AgentContext = createContext({});
|
|
4471
|
-
function AgentProvider({
|
|
4829
|
+
function AgentProvider({
|
|
4830
|
+
agentId,
|
|
4831
|
+
defaultGenerateOptions,
|
|
4832
|
+
defaultStreamOptions,
|
|
4833
|
+
children
|
|
4834
|
+
}) {
|
|
4472
4835
|
const {
|
|
4473
4836
|
modelSettings: modelSettingsStore,
|
|
4474
4837
|
setModelSettings: setModelSettingsStore,
|
|
4475
4838
|
chatWithGenerate: chatWithGenerateStore,
|
|
4476
4839
|
setChatWithGenerate: setChatWithGenerateStore
|
|
4477
4840
|
} = useAgentStore();
|
|
4478
|
-
const
|
|
4841
|
+
const chatWithGenerate = chatWithGenerateStore[agentId] || false;
|
|
4842
|
+
const setChatWithGenerate = (chatWithGenerate2) => {
|
|
4843
|
+
setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
|
|
4844
|
+
};
|
|
4845
|
+
const modelSettings = useMemo(() => {
|
|
4846
|
+
if (modelSettingsStore[agentId]) return modelSettingsStore[agentId];
|
|
4847
|
+
if (chatWithGenerate) {
|
|
4848
|
+
return {
|
|
4849
|
+
maxRetries: defaultGenerateOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
|
|
4850
|
+
maxSteps: defaultGenerateOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
|
|
4851
|
+
temperature: defaultGenerateOptions?.temperature ?? defaultModelSettings$1.temperature,
|
|
4852
|
+
topP: defaultGenerateOptions?.topP ?? defaultModelSettings$1.topP,
|
|
4853
|
+
...defaultGenerateOptions
|
|
4854
|
+
};
|
|
4855
|
+
} else {
|
|
4856
|
+
return {
|
|
4857
|
+
maxRetries: defaultStreamOptions?.maxRetries ?? defaultModelSettings$1.maxRetries,
|
|
4858
|
+
maxSteps: defaultStreamOptions?.maxSteps ?? defaultModelSettings$1.maxSteps,
|
|
4859
|
+
temperature: defaultStreamOptions?.temperature ?? defaultModelSettings$1.temperature,
|
|
4860
|
+
topP: defaultStreamOptions?.topP ?? defaultModelSettings$1.topP,
|
|
4861
|
+
...defaultStreamOptions
|
|
4862
|
+
};
|
|
4863
|
+
}
|
|
4864
|
+
}, [agentId, defaultGenerateOptions, defaultStreamOptions, chatWithGenerate, modelSettingsStore]);
|
|
4479
4865
|
const setModelSettings = (modelSettings2) => {
|
|
4480
4866
|
setModelSettingsStore({ [agentId]: modelSettings2 });
|
|
4481
4867
|
};
|
|
4482
4868
|
const resetModelSettings = () => {
|
|
4483
|
-
|
|
4484
|
-
};
|
|
4485
|
-
const chatWithGenerate = chatWithGenerateStore[agentId] || false;
|
|
4486
|
-
const setChatWithGenerate = (chatWithGenerate2) => {
|
|
4487
|
-
setChatWithGenerateStore({ [agentId]: chatWithGenerate2 });
|
|
4869
|
+
setModelSettingsStore({ [agentId]: null });
|
|
4488
4870
|
};
|
|
4489
4871
|
return /* @__PURE__ */ jsx(
|
|
4490
4872
|
AgentContext.Provider,
|
|
@@ -4520,7 +4902,8 @@ const AgentChat = ({
|
|
|
4520
4902
|
initialMessages,
|
|
4521
4903
|
memory,
|
|
4522
4904
|
baseUrl,
|
|
4523
|
-
refreshThreadList
|
|
4905
|
+
refreshThreadList,
|
|
4906
|
+
showFileSupport
|
|
4524
4907
|
}) => {
|
|
4525
4908
|
const { modelSettings, chatWithGenerate } = useContext(AgentContext);
|
|
4526
4909
|
const { runtimeContext } = usePlaygroundStore();
|
|
@@ -4537,7 +4920,7 @@ const AgentChat = ({
|
|
|
4537
4920
|
modelSettings,
|
|
4538
4921
|
chatWithGenerate,
|
|
4539
4922
|
runtimeContext,
|
|
4540
|
-
children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory }) })
|
|
4923
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4 bg-surface1", children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, showFileSupport }) })
|
|
4541
4924
|
}
|
|
4542
4925
|
);
|
|
4543
4926
|
};
|
|
@@ -5589,7 +5972,7 @@ const useCodemirrorTheme = () => {
|
|
|
5589
5972
|
fontSize: "0.8rem",
|
|
5590
5973
|
lineHighlight: "transparent",
|
|
5591
5974
|
gutterBackground: "transparent",
|
|
5592
|
-
gutterForeground:
|
|
5975
|
+
gutterForeground: Colors.surface3,
|
|
5593
5976
|
background: "transparent"
|
|
5594
5977
|
},
|
|
5595
5978
|
styles: [{ tag: [tags.className, tags.propertyName] }]
|
|
@@ -7199,54 +7582,6 @@ const Collapsible = CollapsiblePrimitive.Root;
|
|
|
7199
7582
|
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
7200
7583
|
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
7201
7584
|
|
|
7202
|
-
const Dialog = DialogPrimitive.Root;
|
|
7203
|
-
const DialogPortal = DialogPrimitive.Portal;
|
|
7204
|
-
const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7205
|
-
DialogPrimitive.Overlay,
|
|
7206
|
-
{
|
|
7207
|
-
ref,
|
|
7208
|
-
className: cn(
|
|
7209
|
-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
7210
|
-
className
|
|
7211
|
-
),
|
|
7212
|
-
...props
|
|
7213
|
-
}
|
|
7214
|
-
));
|
|
7215
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
7216
|
-
const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
7217
|
-
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
7218
|
-
/* @__PURE__ */ jsxs(
|
|
7219
|
-
DialogPrimitive.Content,
|
|
7220
|
-
{
|
|
7221
|
-
ref,
|
|
7222
|
-
className: cn(
|
|
7223
|
-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
7224
|
-
className
|
|
7225
|
-
),
|
|
7226
|
-
...props,
|
|
7227
|
-
children: [
|
|
7228
|
-
children,
|
|
7229
|
-
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
7230
|
-
/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
|
|
7231
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
7232
|
-
] })
|
|
7233
|
-
]
|
|
7234
|
-
}
|
|
7235
|
-
)
|
|
7236
|
-
] }));
|
|
7237
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
7238
|
-
const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7239
|
-
DialogPrimitive.Title,
|
|
7240
|
-
{
|
|
7241
|
-
ref,
|
|
7242
|
-
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
7243
|
-
...props
|
|
7244
|
-
}
|
|
7245
|
-
));
|
|
7246
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
7247
|
-
const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
7248
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
7249
|
-
|
|
7250
7585
|
const ScrollArea = React.forwardRef(
|
|
7251
7586
|
({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
|
|
7252
7587
|
const areaRef = React.useRef(null);
|
|
@@ -7383,18 +7718,222 @@ function WorkflowConditionNode({ data }) {
|
|
|
7383
7718
|
);
|
|
7384
7719
|
}
|
|
7385
7720
|
|
|
7721
|
+
function convertWorkflowRunStateToWatchResult(runState) {
|
|
7722
|
+
const runId = runState.runId;
|
|
7723
|
+
const steps = {};
|
|
7724
|
+
const context = runState.context || {};
|
|
7725
|
+
Object.entries(context).forEach(([stepId, stepResult]) => {
|
|
7726
|
+
if (stepId !== "input" && "status" in stepResult) {
|
|
7727
|
+
const result = stepResult;
|
|
7728
|
+
steps[stepId] = {
|
|
7729
|
+
status: result.status,
|
|
7730
|
+
output: "output" in result ? result.output : void 0,
|
|
7731
|
+
payload: "payload" in result ? result.payload : void 0,
|
|
7732
|
+
resumePayload: "resumePayload" in result ? result.resumePayload : void 0,
|
|
7733
|
+
error: "error" in result ? result.error : void 0,
|
|
7734
|
+
startedAt: "startedAt" in result ? result.startedAt : Date.now(),
|
|
7735
|
+
endedAt: "endedAt" in result ? result.endedAt : void 0,
|
|
7736
|
+
suspendedAt: "suspendedAt" in result ? result.suspendedAt : void 0,
|
|
7737
|
+
resumedAt: "resumedAt" in result ? result.resumedAt : void 0
|
|
7738
|
+
};
|
|
7739
|
+
}
|
|
7740
|
+
});
|
|
7741
|
+
const status = determineWorkflowStatus(steps);
|
|
7742
|
+
return {
|
|
7743
|
+
type: "watch",
|
|
7744
|
+
payload: {
|
|
7745
|
+
workflowState: {
|
|
7746
|
+
status,
|
|
7747
|
+
steps,
|
|
7748
|
+
output: runState.value,
|
|
7749
|
+
payload: context.input,
|
|
7750
|
+
error: void 0
|
|
7751
|
+
}
|
|
7752
|
+
},
|
|
7753
|
+
eventTimestamp: new Date(runState.timestamp),
|
|
7754
|
+
runId
|
|
7755
|
+
};
|
|
7756
|
+
}
|
|
7757
|
+
function determineWorkflowStatus(steps) {
|
|
7758
|
+
const stepStatuses = Object.values(steps).map((step) => step.status);
|
|
7759
|
+
if (stepStatuses.includes("failed")) {
|
|
7760
|
+
return "failed";
|
|
7761
|
+
}
|
|
7762
|
+
if (stepStatuses.includes("suspended")) {
|
|
7763
|
+
return "suspended";
|
|
7764
|
+
}
|
|
7765
|
+
if (stepStatuses.every((status) => status === "success")) {
|
|
7766
|
+
return "success";
|
|
7767
|
+
}
|
|
7768
|
+
return "running";
|
|
7769
|
+
}
|
|
7770
|
+
|
|
7771
|
+
const WorkflowRunContext = createContext({});
|
|
7772
|
+
function WorkflowRunProvider({
|
|
7773
|
+
children,
|
|
7774
|
+
snapshot
|
|
7775
|
+
}) {
|
|
7776
|
+
const [legacyResult, setLegacyResult] = useState(null);
|
|
7777
|
+
const [result, setResult] = useState(
|
|
7778
|
+
() => snapshot ? convertWorkflowRunStateToWatchResult(snapshot) : null
|
|
7779
|
+
);
|
|
7780
|
+
const [payload, setPayload] = useState(null);
|
|
7781
|
+
const clearData = () => {
|
|
7782
|
+
setLegacyResult(null);
|
|
7783
|
+
setResult(null);
|
|
7784
|
+
setPayload(null);
|
|
7785
|
+
};
|
|
7786
|
+
useEffect(() => {
|
|
7787
|
+
if (snapshot?.runId) {
|
|
7788
|
+
setResult(convertWorkflowRunStateToWatchResult(snapshot));
|
|
7789
|
+
} else {
|
|
7790
|
+
setResult(null);
|
|
7791
|
+
}
|
|
7792
|
+
}, [snapshot?.runId ?? ""]);
|
|
7793
|
+
return /* @__PURE__ */ jsx(
|
|
7794
|
+
WorkflowRunContext.Provider,
|
|
7795
|
+
{
|
|
7796
|
+
value: {
|
|
7797
|
+
legacyResult,
|
|
7798
|
+
setLegacyResult,
|
|
7799
|
+
result,
|
|
7800
|
+
setResult,
|
|
7801
|
+
payload,
|
|
7802
|
+
setPayload,
|
|
7803
|
+
clearData
|
|
7804
|
+
},
|
|
7805
|
+
children
|
|
7806
|
+
}
|
|
7807
|
+
);
|
|
7808
|
+
}
|
|
7809
|
+
|
|
7810
|
+
const useCurrentRun = () => {
|
|
7811
|
+
const context = useContext(WorkflowRunContext);
|
|
7812
|
+
const workflowCurrentSteps = context.result?.payload?.workflowState?.steps ?? {};
|
|
7813
|
+
const steps = Object.entries(workflowCurrentSteps).reduce((acc, [key, value]) => {
|
|
7814
|
+
return {
|
|
7815
|
+
...acc,
|
|
7816
|
+
[key]: {
|
|
7817
|
+
error: value.error,
|
|
7818
|
+
startedAt: value.startedAt,
|
|
7819
|
+
endedAt: value.endedAt,
|
|
7820
|
+
status: value.status,
|
|
7821
|
+
output: value.output,
|
|
7822
|
+
input: value.payload
|
|
7823
|
+
}
|
|
7824
|
+
};
|
|
7825
|
+
}, {});
|
|
7826
|
+
return { steps, isRunning: Boolean(context.payload) };
|
|
7827
|
+
};
|
|
7828
|
+
|
|
7386
7829
|
function WorkflowDefaultNode({ data }) {
|
|
7830
|
+
const [isInputOpen, setIsInputOpen] = useState(false);
|
|
7831
|
+
const [isOutputOpen, setIsOutputOpen] = useState(false);
|
|
7832
|
+
const [isErrorOpen, setIsErrorOpen] = useState(false);
|
|
7833
|
+
const { steps, isRunning } = useCurrentRun();
|
|
7387
7834
|
const { label, description, withoutTopHandle, withoutBottomHandle } = data;
|
|
7388
|
-
|
|
7835
|
+
const step = steps[label];
|
|
7836
|
+
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
7837
|
+
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
7838
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7389
7839
|
!withoutTopHandle && /* @__PURE__ */ jsx(Handle, { type: "target", position: Position.Top, style: { visibility: "hidden" } }),
|
|
7390
|
-
/* @__PURE__ */
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7840
|
+
/* @__PURE__ */ jsxs(
|
|
7841
|
+
"div",
|
|
7842
|
+
{
|
|
7843
|
+
className: clsx(
|
|
7844
|
+
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
7845
|
+
step?.status === "success" && "ring-2 ring-accent1",
|
|
7846
|
+
step?.status === "failed" && "ring-2 ring-accent2"
|
|
7847
|
+
),
|
|
7848
|
+
children: [
|
|
7849
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3", children: [
|
|
7850
|
+
isRunning && /* @__PURE__ */ jsxs(Icon, { children: [
|
|
7851
|
+
step?.status === "failed" && /* @__PURE__ */ jsx(CrossIcon, { className: "text-accent2" }),
|
|
7852
|
+
step?.status === "success" && /* @__PURE__ */ jsx(CheckIcon, { className: "text-accent1" }),
|
|
7853
|
+
step?.status === "suspended" && /* @__PURE__ */ jsx(PauseIcon, { className: "text-icon3" }),
|
|
7854
|
+
step?.status === "running" && /* @__PURE__ */ jsx(Loader2, { className: "text-icon6 animate-spin" }),
|
|
7855
|
+
!step && /* @__PURE__ */ jsx(CircleDashed, { className: "text-icon2" })
|
|
7856
|
+
] }),
|
|
7857
|
+
/* @__PURE__ */ jsxs(Txt, { variant: "ui-lg", className: "text-icon6 font-medium inline-flex items-center gap-1 justify-between w-full", children: [
|
|
7858
|
+
label,
|
|
7859
|
+
" ",
|
|
7860
|
+
step?.startedAt && /* @__PURE__ */ jsx(Clock, { startedAt: step.startedAt, endedAt: step.endedAt })
|
|
7861
|
+
] })
|
|
7862
|
+
] }),
|
|
7863
|
+
description && /* @__PURE__ */ jsx(Txt, { variant: "ui-sm", className: "text-icon3 px-3 pb-2", children: description }),
|
|
7864
|
+
(step?.input || step?.output) && /* @__PURE__ */ jsxs("div", { className: "flex items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2", children: [
|
|
7865
|
+
step?.input && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7866
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
|
|
7867
|
+
/* @__PURE__ */ jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
7868
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
7869
|
+
label,
|
|
7870
|
+
" input"
|
|
7871
|
+
] }),
|
|
7872
|
+
/* @__PURE__ */ jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsx(CodeDialogContent, { data: step.input }) })
|
|
7873
|
+
] }) })
|
|
7874
|
+
] }),
|
|
7875
|
+
step?.output && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7876
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
7877
|
+
/* @__PURE__ */ jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
7878
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
7879
|
+
label,
|
|
7880
|
+
" output"
|
|
7881
|
+
] }),
|
|
7882
|
+
/* @__PURE__ */ jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsx(CodeDialogContent, { data: step.output }) })
|
|
7883
|
+
] }) })
|
|
7884
|
+
] }),
|
|
7885
|
+
step?.error && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7886
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
|
|
7887
|
+
/* @__PURE__ */ jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
7888
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
7889
|
+
label,
|
|
7890
|
+
" error"
|
|
7891
|
+
] }),
|
|
7892
|
+
/* @__PURE__ */ jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsx(CodeDialogContent, { data: step?.error }) })
|
|
7893
|
+
] }) })
|
|
7894
|
+
] })
|
|
7895
|
+
] })
|
|
7896
|
+
]
|
|
7897
|
+
}
|
|
7898
|
+
),
|
|
7899
|
+
!withoutBottomHandle && /* @__PURE__ */ jsx(Handle, { type: "source", position: Position.Bottom, style: { visibility: "hidden", color: "red" } })
|
|
7396
7900
|
] });
|
|
7397
7901
|
}
|
|
7902
|
+
const CodeDialogContent = ({ data }) => {
|
|
7903
|
+
const theme = useCodemirrorTheme();
|
|
7904
|
+
if (typeof data !== "string") {
|
|
7905
|
+
return /* @__PURE__ */ jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
|
|
7906
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsx(CopyButton, { content: JSON.stringify(data, null, 2) }) }),
|
|
7907
|
+
/* @__PURE__ */ jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsx(CodeMirror, { value: JSON.stringify(data, null, 2), theme, extensions: [jsonLanguage] }) })
|
|
7908
|
+
] });
|
|
7909
|
+
}
|
|
7910
|
+
try {
|
|
7911
|
+
const json = JSON.parse(data);
|
|
7912
|
+
return /* @__PURE__ */ jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
|
|
7913
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsx(CopyButton, { content: data }) }),
|
|
7914
|
+
/* @__PURE__ */ jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsx(CodeMirror, { value: json, theme, extensions: [jsonLanguage] }) })
|
|
7915
|
+
] });
|
|
7916
|
+
} catch (error) {
|
|
7917
|
+
return /* @__PURE__ */ jsxs("div", { className: "max-h-[500px] overflow-auto relative p-4", children: [
|
|
7918
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-2 top-2 bg-surface4 rounded-full z-10", children: /* @__PURE__ */ jsx(CopyButton, { content: data }) }),
|
|
7919
|
+
/* @__PURE__ */ jsx("div", { className: "bg-surface4 rounded-lg p-4", children: /* @__PURE__ */ jsx(CodeMirror, { value: data, theme, extensions: [] }) })
|
|
7920
|
+
] });
|
|
7921
|
+
}
|
|
7922
|
+
};
|
|
7923
|
+
const Clock = ({ startedAt, endedAt }) => {
|
|
7924
|
+
const [time, setTime] = useState(startedAt);
|
|
7925
|
+
useEffect(() => {
|
|
7926
|
+
const interval = setInterval(() => {
|
|
7927
|
+
setTime(Date.now());
|
|
7928
|
+
}, 100);
|
|
7929
|
+
return () => clearInterval(interval);
|
|
7930
|
+
}, [startedAt]);
|
|
7931
|
+
const timeDiff = endedAt ? endedAt - startedAt : time - startedAt;
|
|
7932
|
+
return /* @__PURE__ */ jsxs("span", { className: "text-xs text-icon3", children: [
|
|
7933
|
+
toSigFigs(timeDiff, 3),
|
|
7934
|
+
"ms"
|
|
7935
|
+
] });
|
|
7936
|
+
};
|
|
7398
7937
|
|
|
7399
7938
|
function WorkflowAfterNode({ data }) {
|
|
7400
7939
|
const { steps } = data;
|
|
@@ -8428,33 +8967,6 @@ function CodeBlockDemo({
|
|
|
8428
8967
|
] });
|
|
8429
8968
|
}
|
|
8430
8969
|
|
|
8431
|
-
const WorkflowRunContext = createContext({});
|
|
8432
|
-
function WorkflowRunProvider({ children }) {
|
|
8433
|
-
const [legacyResult, setLegacyResult] = useState(null);
|
|
8434
|
-
const [result, setResult] = useState(null);
|
|
8435
|
-
const [payload, setPayload] = useState(null);
|
|
8436
|
-
const clearData = () => {
|
|
8437
|
-
setLegacyResult(null);
|
|
8438
|
-
setResult(null);
|
|
8439
|
-
setPayload(null);
|
|
8440
|
-
};
|
|
8441
|
-
return /* @__PURE__ */ jsx(
|
|
8442
|
-
WorkflowRunContext.Provider,
|
|
8443
|
-
{
|
|
8444
|
-
value: {
|
|
8445
|
-
legacyResult,
|
|
8446
|
-
setLegacyResult,
|
|
8447
|
-
result,
|
|
8448
|
-
setResult,
|
|
8449
|
-
payload,
|
|
8450
|
-
setPayload,
|
|
8451
|
-
clearData
|
|
8452
|
-
},
|
|
8453
|
-
children
|
|
8454
|
-
}
|
|
8455
|
-
);
|
|
8456
|
-
}
|
|
8457
|
-
|
|
8458
8970
|
const WorkflowCard = ({ header, children, footer }) => {
|
|
8459
8971
|
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border-sm border-border1 bg-surface4", children: [
|
|
8460
8972
|
/* @__PURE__ */ jsx("div", { className: "py-1 px-2 flex items-center gap-3", children: header }),
|
|
@@ -8662,6 +9174,48 @@ function LegacyWorkflowTrigger({
|
|
|
8662
9174
|
] }) });
|
|
8663
9175
|
}
|
|
8664
9176
|
|
|
9177
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
9178
|
+
SliderPrimitive.Root,
|
|
9179
|
+
{
|
|
9180
|
+
ref,
|
|
9181
|
+
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
9182
|
+
...props,
|
|
9183
|
+
children: [
|
|
9184
|
+
/* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: "absolute h-full bg-primary/50" }) }),
|
|
9185
|
+
/* @__PURE__ */ jsx(SliderPrimitive.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
|
|
9186
|
+
]
|
|
9187
|
+
}
|
|
9188
|
+
));
|
|
9189
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
9190
|
+
|
|
9191
|
+
const ZoomSlider = forwardRef(({ className, ...props }) => {
|
|
9192
|
+
const { zoom } = useViewport();
|
|
9193
|
+
const { zoomTo, zoomIn, zoomOut, fitView } = useReactFlow();
|
|
9194
|
+
return /* @__PURE__ */ jsxs(Panel, { className: cn("flex gap-1 rounded-md bg-primary-foreground p-1 text-foreground", className), ...props, children: [
|
|
9195
|
+
/* @__PURE__ */ jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomOut({ duration: 300 }), children: /* @__PURE__ */ jsx(Minus, { className: "h-4 w-4" }) }),
|
|
9196
|
+
/* @__PURE__ */ jsx(
|
|
9197
|
+
Slider,
|
|
9198
|
+
{
|
|
9199
|
+
className: "w-[140px]",
|
|
9200
|
+
value: [zoom],
|
|
9201
|
+
min: 0.01,
|
|
9202
|
+
max: 1,
|
|
9203
|
+
step: 0.01,
|
|
9204
|
+
onValueChange: (values) => {
|
|
9205
|
+
zoomTo(values[0]);
|
|
9206
|
+
}
|
|
9207
|
+
}
|
|
9208
|
+
),
|
|
9209
|
+
/* @__PURE__ */ jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => zoomIn({ duration: 300 }), children: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }) }),
|
|
9210
|
+
/* @__PURE__ */ jsxs(Button$1, { className: "min-w-20 tabular-nums", variant: "ghost", onClick: () => zoomTo(1, { duration: 300 }), children: [
|
|
9211
|
+
(100 * zoom).toFixed(0),
|
|
9212
|
+
"%"
|
|
9213
|
+
] }),
|
|
9214
|
+
/* @__PURE__ */ jsx(Button$1, { variant: "ghost", size: "icon", onClick: () => fitView({ duration: 300, maxZoom: 1 }), children: /* @__PURE__ */ jsx(Maximize, { className: "h-4 w-4" }) })
|
|
9215
|
+
] });
|
|
9216
|
+
});
|
|
9217
|
+
ZoomSlider.displayName = "ZoomSlider";
|
|
9218
|
+
|
|
8665
9219
|
function WorkflowNestedGraph({ stepGraph, open }) {
|
|
8666
9220
|
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges({
|
|
8667
9221
|
stepGraph
|
|
@@ -8689,11 +9243,15 @@ function WorkflowNestedGraph({ stepGraph, open }) {
|
|
|
8689
9243
|
nodes,
|
|
8690
9244
|
edges,
|
|
8691
9245
|
fitView: true,
|
|
8692
|
-
fitViewOptions: {
|
|
9246
|
+
fitViewOptions: {
|
|
9247
|
+
maxZoom: 1
|
|
9248
|
+
},
|
|
9249
|
+
minZoom: 0.01,
|
|
9250
|
+
maxZoom: 1,
|
|
8693
9251
|
nodeTypes,
|
|
8694
9252
|
onNodesChange,
|
|
8695
9253
|
children: [
|
|
8696
|
-
/* @__PURE__ */ jsx(
|
|
9254
|
+
/* @__PURE__ */ jsx(ZoomSlider, { position: "bottom-left" }),
|
|
8697
9255
|
/* @__PURE__ */ jsx(MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
8698
9256
|
/* @__PURE__ */ jsx(Background, { variant: BackgroundVariant.Lines, gap: 12, size: 0.5 })
|
|
8699
9257
|
]
|
|
@@ -8750,7 +9308,7 @@ function WorkflowNestedGraphProvider({ children }) {
|
|
|
8750
9308
|
},
|
|
8751
9309
|
children: [
|
|
8752
9310
|
children,
|
|
8753
|
-
/* @__PURE__ */ jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsx(DialogPortal, { children: /* @__PURE__ */ jsxs(DialogContent, { className: "w-[
|
|
9311
|
+
/* @__PURE__ */ jsx(Dialog, { open: openDialog, onOpenChange: closeNestedGraph, children: /* @__PURE__ */ jsx(DialogPortal, { children: /* @__PURE__ */ jsxs(DialogContent, { className: "w-[45rem] h-[45rem] max-w-[unset] bg-[#121212] p-[0.5rem]", children: [
|
|
8754
9312
|
/* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-1.5 absolute top-2.5 left-2.5", children: [
|
|
8755
9313
|
/* @__PURE__ */ jsx(Workflow, { className: "text-current w-4 h-4" }),
|
|
8756
9314
|
/* @__PURE__ */ jsxs(Text, { size: "xs", weight: "medium", className: "text-mastra-el-6 capitalize", children: [
|
|
@@ -8782,6 +9340,7 @@ function WorkflowGraphInner({ workflow }) {
|
|
|
8782
9340
|
const { nodes: initialNodes, edges: initialEdges } = constructNodesAndEdges(workflow);
|
|
8783
9341
|
const [nodes, _, onNodesChange] = useNodesState(initialNodes);
|
|
8784
9342
|
const [edges] = useEdgesState(initialEdges);
|
|
9343
|
+
const { steps } = useCurrentRun();
|
|
8785
9344
|
const nodeTypes = {
|
|
8786
9345
|
"default-node": WorkflowDefaultNode,
|
|
8787
9346
|
"condition-node": WorkflowConditionNode,
|
|
@@ -8789,19 +9348,27 @@ function WorkflowGraphInner({ workflow }) {
|
|
|
8789
9348
|
"loop-result-node": WorkflowLoopResultNode,
|
|
8790
9349
|
"nested-node": WorkflowNestedNode
|
|
8791
9350
|
};
|
|
8792
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full h-full", children: /* @__PURE__ */ jsxs(
|
|
9351
|
+
return /* @__PURE__ */ jsx("div", { className: "w-full h-full bg-surface1", children: /* @__PURE__ */ jsxs(
|
|
8793
9352
|
ReactFlow,
|
|
8794
9353
|
{
|
|
8795
9354
|
nodes,
|
|
8796
|
-
edges
|
|
9355
|
+
edges: edges.map((e) => ({
|
|
9356
|
+
...e,
|
|
9357
|
+
style: {
|
|
9358
|
+
...e.style,
|
|
9359
|
+
stroke: steps[e.source]?.status === "success" ? "#22c55e" : void 0
|
|
9360
|
+
}
|
|
9361
|
+
})),
|
|
8797
9362
|
nodeTypes,
|
|
8798
9363
|
onNodesChange,
|
|
8799
9364
|
fitView: true,
|
|
8800
9365
|
fitViewOptions: {
|
|
8801
|
-
maxZoom:
|
|
9366
|
+
maxZoom: 1
|
|
8802
9367
|
},
|
|
9368
|
+
minZoom: 0.01,
|
|
9369
|
+
maxZoom: 1,
|
|
8803
9370
|
children: [
|
|
8804
|
-
/* @__PURE__ */ jsx(
|
|
9371
|
+
/* @__PURE__ */ jsx(ZoomSlider, { position: "bottom-left" }),
|
|
8805
9372
|
/* @__PURE__ */ jsx(MiniMap, { pannable: true, zoomable: true, maskColor: "#121212", bgColor: "#171717", nodeColor: "#2c2c2c" }),
|
|
8806
9373
|
/* @__PURE__ */ jsx(Background, { variant: BackgroundVariant.Dots, gap: 12, size: 0.5 })
|
|
8807
9374
|
]
|
|
@@ -9391,5 +9958,5 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
|
9391
9958
|
return { traces, firstCallLoading, error };
|
|
9392
9959
|
};
|
|
9393
9960
|
|
|
9394
|
-
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LogsIcon, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolsIcon, TraceContext, TraceIcon, TraceProvider, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, refineTraces, usePlaygroundStore, usePolling, useTraces };
|
|
9961
|
+
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentNetworkCoinIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LogsIcon, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolsIcon, TraceContext, TraceIcon, TraceProvider, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, refineTraces, useCurrentRun, usePlaygroundStore, usePolling, useSpeechRecognition, useTraces };
|
|
9395
9962
|
//# sourceMappingURL=index.es.js.map
|