@mastra/playground-ui 5.1.11-alpha.1 → 5.1.11-alpha.3
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 +417 -203
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +420 -206
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/attachments/attachment-preview-dialog.d.ts +31 -0
- package/dist/src/components/assistant-ui/attachments/attachment.d.ts +2 -0
- package/dist/src/components/assistant-ui/hooks/use-attachment-src.d.ts +1 -0
- package/dist/src/components/assistant-ui/hooks/use-file-src.d.ts +1 -0
- package/dist/src/components/assistant-ui/hooks/use-load-browser-file.d.ts +4 -0
- package/dist/src/components/assistant-ui/messages/assistant-message.d.ts +6 -0
- package/dist/src/components/assistant-ui/messages/markdown-text.d.ts +2 -0
- package/dist/src/components/assistant-ui/messages/user-messages.d.ts +9 -0
- package/dist/src/domains/workflows/workflow/workflow-input-data.d.ts +10 -0
- package/package.json +9 -9
- package/dist/src/components/assistant-ui/assistant-message.d.ts +0 -6
- package/dist/src/components/assistant-ui/assistant-modal.d.ts +0 -1
- package/dist/src/components/assistant-ui/attachment.d.ts +0 -5
- package/dist/src/components/assistant-ui/image-with-fallback.d.ts +0 -3
- package/dist/src/components/assistant-ui/markdown-text.d.ts +0 -2
- package/dist/src/components/assistant-ui/user-message.d.ts +0 -1
- /package/dist/src/components/assistant-ui/{attachment-adapters → attachments}/pdfs-adapter.d.ts +0 -0
- /package/dist/src/components/assistant-ui/{use-has-attachments.d.ts → hooks/use-has-attachments.d.ts} +0 -0
- /package/dist/src/components/assistant-ui/{tool-fallback.d.ts → tools/tool-fallback.d.ts} +0 -0
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { createContext, useContext, forwardRef, useState, useEffect,
|
|
3
|
+
import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Suspense, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { MastraClient } from '@mastra/client-js';
|
|
5
|
-
import { useMessage, MessagePrimitive, ActionBarPrimitive,
|
|
6
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText,
|
|
5
|
+
import { useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
6
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, FileText, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Braces, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause, StopCircle } 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';
|
|
@@ -18,8 +18,8 @@ import { tags } from '@lezer/highlight';
|
|
|
18
18
|
import { draculaInit } from '@uiw/codemirror-theme-dracula';
|
|
19
19
|
import CodeMirror from '@uiw/react-codemirror';
|
|
20
20
|
import { toast } from 'sonner';
|
|
21
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
22
21
|
import { useShallow } from 'zustand/shallow';
|
|
22
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
23
23
|
import { RuntimeContext } from '@mastra/core/di';
|
|
24
24
|
import { create } from 'zustand';
|
|
25
25
|
import { persist } from 'zustand/middleware';
|
|
@@ -3166,47 +3166,7 @@ const AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
3166
3166
|
));
|
|
3167
3167
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
3168
3168
|
|
|
3169
|
-
const
|
|
3170
|
-
const [error, setError] = useState(false);
|
|
3171
|
-
useEffect(() => {
|
|
3172
|
-
setError(false);
|
|
3173
|
-
}, [src]);
|
|
3174
|
-
return error || !src ? /* @__PURE__ */ jsxs("div", { children: [
|
|
3175
|
-
/* @__PURE__ */ jsx(
|
|
3176
|
-
"svg",
|
|
3177
|
-
{
|
|
3178
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3179
|
-
fill: "none",
|
|
3180
|
-
viewBox: "0 0 24 24",
|
|
3181
|
-
strokeWidth: "1.5",
|
|
3182
|
-
stroke: "currentColor",
|
|
3183
|
-
width: "150",
|
|
3184
|
-
height: "150",
|
|
3185
|
-
children: /* @__PURE__ */ jsx(
|
|
3186
|
-
"path",
|
|
3187
|
-
{
|
|
3188
|
-
strokeLinecap: "round",
|
|
3189
|
-
strokeLinejoin: "round",
|
|
3190
|
-
d: "m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"
|
|
3191
|
-
}
|
|
3192
|
-
)
|
|
3193
|
-
}
|
|
3194
|
-
),
|
|
3195
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground -mt-[0.625rem] mb-[0.625rem]", children: "Image link is broken" })
|
|
3196
|
-
] }) : /* @__PURE__ */ jsx(
|
|
3197
|
-
"img",
|
|
3198
|
-
{
|
|
3199
|
-
src,
|
|
3200
|
-
alt,
|
|
3201
|
-
...rest,
|
|
3202
|
-
onError: () => {
|
|
3203
|
-
setError(true);
|
|
3204
|
-
}
|
|
3205
|
-
}
|
|
3206
|
-
);
|
|
3207
|
-
};
|
|
3208
|
-
|
|
3209
|
-
const SyntaxHighlighter$2 = makePrismAsyncSyntaxHighlighter({
|
|
3169
|
+
const SyntaxHighlighter$3 = makePrismAsyncSyntaxHighlighter({
|
|
3210
3170
|
style: coldarkDark,
|
|
3211
3171
|
customStyle: {
|
|
3212
3172
|
margin: 0,
|
|
@@ -3278,6 +3238,45 @@ const useCopyToClipboard$1 = ({
|
|
|
3278
3238
|
};
|
|
3279
3239
|
return { isCopied, copyToClipboard };
|
|
3280
3240
|
};
|
|
3241
|
+
const ImageWithFallback = ({ alt, src, ...rest }) => {
|
|
3242
|
+
const [error, setError] = useState(false);
|
|
3243
|
+
useEffect(() => {
|
|
3244
|
+
setError(false);
|
|
3245
|
+
}, [src]);
|
|
3246
|
+
return error || !src ? /* @__PURE__ */ jsxs("div", { children: [
|
|
3247
|
+
/* @__PURE__ */ jsx(
|
|
3248
|
+
"svg",
|
|
3249
|
+
{
|
|
3250
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3251
|
+
fill: "none",
|
|
3252
|
+
viewBox: "0 0 24 24",
|
|
3253
|
+
strokeWidth: "1.5",
|
|
3254
|
+
stroke: "currentColor",
|
|
3255
|
+
width: "150",
|
|
3256
|
+
height: "150",
|
|
3257
|
+
children: /* @__PURE__ */ jsx(
|
|
3258
|
+
"path",
|
|
3259
|
+
{
|
|
3260
|
+
strokeLinecap: "round",
|
|
3261
|
+
strokeLinejoin: "round",
|
|
3262
|
+
d: "m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"
|
|
3263
|
+
}
|
|
3264
|
+
)
|
|
3265
|
+
}
|
|
3266
|
+
),
|
|
3267
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground -mt-[0.625rem] mb-[0.625rem]", children: "Image link is broken" })
|
|
3268
|
+
] }) : /* @__PURE__ */ jsx(
|
|
3269
|
+
"img",
|
|
3270
|
+
{
|
|
3271
|
+
src,
|
|
3272
|
+
alt,
|
|
3273
|
+
...rest,
|
|
3274
|
+
onError: () => {
|
|
3275
|
+
setError(true);
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
);
|
|
3279
|
+
};
|
|
3281
3280
|
const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
3282
3281
|
h1: ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
3283
3282
|
"h1",
|
|
@@ -3425,7 +3424,7 @@ const defaultComponents = unstable_memoizeMarkdownComponents({
|
|
|
3425
3424
|
);
|
|
3426
3425
|
},
|
|
3427
3426
|
CodeHeader,
|
|
3428
|
-
SyntaxHighlighter: SyntaxHighlighter$
|
|
3427
|
+
SyntaxHighlighter: SyntaxHighlighter$3,
|
|
3429
3428
|
img: ImageWithFallback
|
|
3430
3429
|
});
|
|
3431
3430
|
|
|
@@ -4304,7 +4303,7 @@ const useCodemirrorTheme$1 = () => {
|
|
|
4304
4303
|
[]
|
|
4305
4304
|
);
|
|
4306
4305
|
};
|
|
4307
|
-
const SyntaxHighlighter$
|
|
4306
|
+
const SyntaxHighlighter$2 = ({ data, className }) => {
|
|
4308
4307
|
const formattedCode = JSON.stringify(data, null, 2);
|
|
4309
4308
|
const theme = useCodemirrorTheme$1();
|
|
4310
4309
|
return /* @__PURE__ */ jsxs("div", { className: clsx("rounded-md bg-surface4 p-1 font-mono relative", className), children: [
|
|
@@ -4331,7 +4330,7 @@ const ToolFallback$1 = ({ toolName, argsText, result }) => {
|
|
|
4331
4330
|
let argSlot;
|
|
4332
4331
|
try {
|
|
4333
4332
|
const parsedArgs = JSON.parse(argsText);
|
|
4334
|
-
argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$
|
|
4333
|
+
argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: parsedArgs });
|
|
4335
4334
|
} catch {
|
|
4336
4335
|
argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: argsText });
|
|
4337
4336
|
}
|
|
@@ -4347,15 +4346,13 @@ const ToolFallback$1 = ({ toolName, argsText, result }) => {
|
|
|
4347
4346
|
] }),
|
|
4348
4347
|
result !== void 0 && /* @__PURE__ */ jsxs("div", { className: "px-4 py-2", children: [
|
|
4349
4348
|
/* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
|
|
4350
|
-
typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$
|
|
4349
|
+
typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result })
|
|
4351
4350
|
] })
|
|
4352
4351
|
] }) })
|
|
4353
4352
|
] });
|
|
4354
4353
|
};
|
|
4355
4354
|
|
|
4356
|
-
const AssistantMessage = ({
|
|
4357
|
-
ToolFallback: ToolFallbackCustom
|
|
4358
|
-
}) => {
|
|
4355
|
+
const AssistantMessage = ({ ToolFallback: ToolFallbackCustom }) => {
|
|
4359
4356
|
const data = useMessage();
|
|
4360
4357
|
const isSolelyToolCall = data.content.length === 1 && data.content[0].type === "tool-call";
|
|
4361
4358
|
return /* @__PURE__ */ jsxs(MessagePrimitive.Root, { className: "max-w-full", children: [
|
|
@@ -4387,8 +4384,36 @@ const AssistantActionBar$1 = () => {
|
|
|
4387
4384
|
);
|
|
4388
4385
|
};
|
|
4389
4386
|
|
|
4387
|
+
const useFileSrc = (file) => {
|
|
4388
|
+
const [src, setSrc] = useState(void 0);
|
|
4389
|
+
useEffect(() => {
|
|
4390
|
+
if (!file) {
|
|
4391
|
+
setSrc(void 0);
|
|
4392
|
+
return;
|
|
4393
|
+
}
|
|
4394
|
+
const objectUrl = URL.createObjectURL(file);
|
|
4395
|
+
setSrc(objectUrl);
|
|
4396
|
+
return () => {
|
|
4397
|
+
URL.revokeObjectURL(objectUrl);
|
|
4398
|
+
};
|
|
4399
|
+
}, [file]);
|
|
4400
|
+
return src;
|
|
4401
|
+
};
|
|
4402
|
+
|
|
4403
|
+
const useAttachmentSrc = () => {
|
|
4404
|
+
const { file, src } = useAttachment(
|
|
4405
|
+
useShallow((a) => {
|
|
4406
|
+
if (a.type !== "image") return {};
|
|
4407
|
+
if (a.file) return { file: a.file };
|
|
4408
|
+
const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
|
|
4409
|
+
if (!src2) return {};
|
|
4410
|
+
return { src: src2 };
|
|
4411
|
+
})
|
|
4412
|
+
);
|
|
4413
|
+
return useFileSrc(file) ?? src;
|
|
4414
|
+
};
|
|
4415
|
+
|
|
4390
4416
|
const Dialog = DialogPrimitive.Root;
|
|
4391
|
-
const DialogTrigger = DialogPrimitive.Trigger;
|
|
4392
4417
|
const DialogPortal = DialogPrimitive.Portal;
|
|
4393
4418
|
const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4394
4419
|
DialogPrimitive.Overlay,
|
|
@@ -4436,107 +4461,137 @@ DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
|
4436
4461
|
const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
4437
4462
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
4438
4463
|
|
|
4439
|
-
const
|
|
4440
|
-
const
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
setHasAttachments(attachments.length > 0);
|
|
4446
|
-
});
|
|
4447
|
-
}, [composer]);
|
|
4448
|
-
return hasAttachments;
|
|
4464
|
+
const PdfEntry = ({ data }) => {
|
|
4465
|
+
const [open, setOpen] = useState(false);
|
|
4466
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4467
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setOpen(true), className: "h-full w-full flex items-center justify-center", type: "button", children: /* @__PURE__ */ jsx(FileText, { className: "text-accent2" }) }),
|
|
4468
|
+
/* @__PURE__ */ jsx(PdfPreviewDialog, { data, open, onOpenChange: setOpen })
|
|
4469
|
+
] });
|
|
4449
4470
|
};
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
setSrc(void 0);
|
|
4456
|
-
return;
|
|
4457
|
-
}
|
|
4458
|
-
const objectUrl = URL.createObjectURL(file);
|
|
4459
|
-
setSrc(objectUrl);
|
|
4460
|
-
return () => {
|
|
4461
|
-
URL.revokeObjectURL(objectUrl);
|
|
4462
|
-
};
|
|
4463
|
-
}, [file]);
|
|
4464
|
-
return src;
|
|
4471
|
+
const PdfPreviewDialog = ({ data, open, onOpenChange }) => {
|
|
4472
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "max-w-4xl bg-surface2", children: /* @__PURE__ */ jsxs("div", { className: "h-full w-full", children: [
|
|
4473
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "pb-4", children: "PDF preview" }),
|
|
4474
|
+
open && /* @__PURE__ */ jsx("iframe", { src: data, width: "100%", height: "600px" })
|
|
4475
|
+
] }) }) });
|
|
4465
4476
|
};
|
|
4466
|
-
const
|
|
4467
|
-
const
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
if (!src2) return {};
|
|
4473
|
-
return { src: src2 };
|
|
4474
|
-
})
|
|
4475
|
-
);
|
|
4476
|
-
return useFileSrc(file) ?? src;
|
|
4477
|
+
const ImageEntry = ({ src }) => {
|
|
4478
|
+
const [open, setOpen] = useState(false);
|
|
4479
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4480
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setOpen(true), type: "button", className: "h-full w-full flex items-center justify-center", children: /* @__PURE__ */ jsx("img", { src, className: "object-cover aspect-ratio max-h-[140px] max-w-[320px]", alt: "Preview" }) }),
|
|
4481
|
+
/* @__PURE__ */ jsx(ImagePreviewDialog, { src, open, onOpenChange: setOpen })
|
|
4482
|
+
] });
|
|
4477
4483
|
};
|
|
4478
|
-
const
|
|
4479
|
-
return /* @__PURE__ */ jsx(
|
|
4484
|
+
const ImagePreviewDialog = ({ src, open, onOpenChange }) => {
|
|
4485
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "max-w-4xl bg-surface2", children: /* @__PURE__ */ jsxs("div", { className: "h-full w-full", children: [
|
|
4486
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "pb-4", children: "Image preview" }),
|
|
4487
|
+
open && /* @__PURE__ */ jsx("img", { src, alt: "Image" })
|
|
4488
|
+
] }) }) });
|
|
4480
4489
|
};
|
|
4481
|
-
const
|
|
4482
|
-
const
|
|
4483
|
-
|
|
4484
|
-
return /* @__PURE__ */ jsxs(
|
|
4485
|
-
/* @__PURE__ */ jsx(
|
|
4486
|
-
/* @__PURE__ */
|
|
4487
|
-
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
4488
|
-
/* @__PURE__ */ jsxs(DialogContent, { className: "max-w-5xl w-full max-h-[80%]", children: [
|
|
4489
|
-
/* @__PURE__ */ jsx(DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
|
|
4490
|
-
/* @__PURE__ */ jsx(AttachmentPreview, { src })
|
|
4491
|
-
] })
|
|
4492
|
-
] })
|
|
4490
|
+
const TxtEntry = ({ data }) => {
|
|
4491
|
+
const [open, setOpen] = useState(false);
|
|
4492
|
+
const formattedContent = data.replace(/<attachment[^>]*>/, "").replace(/<\/attachment>/g, "");
|
|
4493
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4494
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setOpen(true), className: "h-full w-full flex items-center justify-center", type: "button", children: /* @__PURE__ */ jsx(FileText, { className: "text-icon3" }) }),
|
|
4495
|
+
/* @__PURE__ */ jsx(TxtPreviewDialog, { data: formattedContent, open, onOpenChange: setOpen })
|
|
4493
4496
|
] });
|
|
4494
4497
|
};
|
|
4495
|
-
const
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
return /* @__PURE__ */ jsx(TooltipProvider$1, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4501
|
-
/* @__PURE__ */ jsxs(AttachmentPrimitive.Root, { className: "relative", children: [
|
|
4502
|
-
/* @__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 }) }) : document?.contentType === "application/pdf" ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsx(FileText, { className: "text-accent2" }) }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border-sm border-border1 flex items-center justify-center", children: /* @__PURE__ */ jsx(FileIcon, { className: "text-icon3" }) }) }) }) }),
|
|
4503
|
-
canRemove && /* @__PURE__ */ jsx(AttachmentRemove, {})
|
|
4504
|
-
] }),
|
|
4505
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) })
|
|
4506
|
-
] }) });
|
|
4498
|
+
const TxtPreviewDialog = ({ data, open, onOpenChange }) => {
|
|
4499
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsx(DialogContent, { className: "max-w-4xl bg-surface2 h-[80vh] overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "h-full w-full", children: [
|
|
4500
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "pb-4", children: "Text preview" }),
|
|
4501
|
+
open && /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: data })
|
|
4502
|
+
] }) }) });
|
|
4507
4503
|
};
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4504
|
+
|
|
4505
|
+
const InMessageContextWrapper = () => {
|
|
4506
|
+
return /* @__PURE__ */ jsx(AttachmentPrimitive.Root, { className: "pt-4", children: /* @__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(InMessageAttachmentWrapper, {}) }) });
|
|
4507
|
+
};
|
|
4508
|
+
const InMessageAttachmentWrapper = () => {
|
|
4509
|
+
const src = useAttachmentSrc();
|
|
4510
|
+
const attachment = useAttachment((a) => a);
|
|
4511
|
+
if (attachment.type === "image") {
|
|
4512
|
+
return /* @__PURE__ */ jsx(
|
|
4513
|
+
InMessageAttachment,
|
|
4514
|
+
{
|
|
4515
|
+
type: "image",
|
|
4516
|
+
contentType: void 0,
|
|
4517
|
+
nameSlot: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}),
|
|
4518
|
+
src,
|
|
4519
|
+
data: void 0
|
|
4520
|
+
}
|
|
4521
|
+
);
|
|
4522
|
+
}
|
|
4523
|
+
if (attachment.contentType === "application/pdf") {
|
|
4524
|
+
const pdfText = attachment.content?.[0]?.text;
|
|
4525
|
+
return /* @__PURE__ */ jsx(
|
|
4526
|
+
InMessageAttachment,
|
|
4527
|
+
{
|
|
4528
|
+
type: "document",
|
|
4529
|
+
contentType: attachment.contentType,
|
|
4530
|
+
nameSlot: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}),
|
|
4531
|
+
src,
|
|
4532
|
+
data: `data:application/pdf;base64,${pdfText}`
|
|
4533
|
+
}
|
|
4534
|
+
);
|
|
4535
|
+
}
|
|
4536
|
+
return /* @__PURE__ */ jsx(
|
|
4537
|
+
InMessageAttachment,
|
|
4511
4538
|
{
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4539
|
+
type: attachment.type,
|
|
4540
|
+
contentType: attachment.contentType,
|
|
4541
|
+
nameSlot: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}),
|
|
4542
|
+
src,
|
|
4543
|
+
data: attachment.content?.[0]?.text
|
|
4516
4544
|
}
|
|
4517
|
-
)
|
|
4518
|
-
};
|
|
4519
|
-
const UserMessageAttachments = () => {
|
|
4520
|
-
return /* @__PURE__ */ jsx(MessagePrimitive.Attachments, { components: { Attachment: InMessageAttachment } });
|
|
4545
|
+
);
|
|
4521
4546
|
};
|
|
4522
|
-
const InMessageAttachment = () => {
|
|
4523
|
-
const isImage = useAttachment((a) => a.type === "image");
|
|
4524
|
-
const document = useAttachment((a) => a.type === "document" ? a : void 0);
|
|
4525
|
-
const src = useAttachmentSrc();
|
|
4547
|
+
const InMessageAttachment = ({ type, contentType, nameSlot, src, data }) => {
|
|
4526
4548
|
return /* @__PURE__ */ jsx(TooltipProvider$1, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4527
|
-
/* @__PURE__ */ jsx(
|
|
4528
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children:
|
|
4549
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full overflow-hidden rounded-lg", children: type === "image" ? /* @__PURE__ */ jsx(ImageEntry, { src: src ?? "" }) : type === "document" && contentType === "application/pdf" ? /* @__PURE__ */ jsx(PdfEntry, { data: data ?? "" }) : /* @__PURE__ */ jsx(TxtEntry, { data: data ?? "" }) }) }),
|
|
4550
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: nameSlot })
|
|
4529
4551
|
] }) });
|
|
4530
4552
|
};
|
|
4531
|
-
const
|
|
4532
|
-
|
|
4533
|
-
if (!hasAttachments) return null;
|
|
4534
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-row items-center gap-4 h-24", children: /* @__PURE__ */ jsx(ComposerPrimitive.Attachments, { components: { Attachment: AttachmentThumbnail } }) });
|
|
4553
|
+
const UserMessageAttachments = () => {
|
|
4554
|
+
return /* @__PURE__ */ jsx(MessagePrimitive.Attachments, { components: { Attachment: InMessageContextWrapper } });
|
|
4535
4555
|
};
|
|
4536
|
-
|
|
4537
4556
|
const UserMessage = () => {
|
|
4538
4557
|
return /* @__PURE__ */ jsxs(MessagePrimitive.Root, { className: "w-full flex items-end pb-4 flex-col", children: [
|
|
4539
|
-
/* @__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(
|
|
4558
|
+
/* @__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(
|
|
4559
|
+
MessagePrimitive.Content,
|
|
4560
|
+
{
|
|
4561
|
+
components: {
|
|
4562
|
+
File: (p) => {
|
|
4563
|
+
return /* @__PURE__ */ jsx(
|
|
4564
|
+
InMessageAttachment,
|
|
4565
|
+
{
|
|
4566
|
+
type: "document",
|
|
4567
|
+
contentType: p.mimeType,
|
|
4568
|
+
nameSlot: "Unknown filename",
|
|
4569
|
+
src: void 0,
|
|
4570
|
+
data: p.image
|
|
4571
|
+
}
|
|
4572
|
+
);
|
|
4573
|
+
},
|
|
4574
|
+
Image: (p) => {
|
|
4575
|
+
return /* @__PURE__ */ jsx(InMessageAttachment, { type: "image", nameSlot: "Unknown filename", src: p.image });
|
|
4576
|
+
},
|
|
4577
|
+
Text: (p) => {
|
|
4578
|
+
if (p.text.includes("<attachment name=")) {
|
|
4579
|
+
return /* @__PURE__ */ jsx(
|
|
4580
|
+
InMessageAttachment,
|
|
4581
|
+
{
|
|
4582
|
+
type: "document",
|
|
4583
|
+
contentType: "text/plain",
|
|
4584
|
+
nameSlot: "Unknown filename",
|
|
4585
|
+
src: void 0,
|
|
4586
|
+
data: p.text
|
|
4587
|
+
}
|
|
4588
|
+
);
|
|
4589
|
+
}
|
|
4590
|
+
return p.text;
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
) }),
|
|
4540
4595
|
/* @__PURE__ */ jsx(UserMessageAttachments, {})
|
|
4541
4596
|
] });
|
|
4542
4597
|
};
|
|
@@ -4643,6 +4698,123 @@ const useSpeechRecognition = ({ language = "en-US" } = {}) => {
|
|
|
4643
4698
|
};
|
|
4644
4699
|
};
|
|
4645
4700
|
|
|
4701
|
+
const useHasAttachments = () => {
|
|
4702
|
+
const composer = useComposerRuntime();
|
|
4703
|
+
const [hasAttachments, setHasAttachments] = useState(false);
|
|
4704
|
+
useEffect(() => {
|
|
4705
|
+
composer.subscribe(() => {
|
|
4706
|
+
const attachments = composer.getState().attachments;
|
|
4707
|
+
setHasAttachments(attachments.length > 0);
|
|
4708
|
+
});
|
|
4709
|
+
}, [composer]);
|
|
4710
|
+
return hasAttachments;
|
|
4711
|
+
};
|
|
4712
|
+
|
|
4713
|
+
function Spinner({ color = "#fff", className }) {
|
|
4714
|
+
return /* @__PURE__ */ jsx(
|
|
4715
|
+
"svg",
|
|
4716
|
+
{
|
|
4717
|
+
className: cn("animate-spin duration-700", className),
|
|
4718
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4719
|
+
width: "24",
|
|
4720
|
+
height: "24",
|
|
4721
|
+
viewBox: "0 0 24 24",
|
|
4722
|
+
fill: "none",
|
|
4723
|
+
stroke: "currentColor",
|
|
4724
|
+
strokeWidth: "2",
|
|
4725
|
+
strokeLinecap: "round",
|
|
4726
|
+
strokeLinejoin: "round",
|
|
4727
|
+
children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", stroke: color })
|
|
4728
|
+
}
|
|
4729
|
+
);
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
const useLoadBrowserFile = (file) => {
|
|
4733
|
+
const [state, setState] = useState({ isLoading: false, text: "" });
|
|
4734
|
+
useEffect(() => {
|
|
4735
|
+
if (!file) return;
|
|
4736
|
+
const run = async () => {
|
|
4737
|
+
setState((s) => ({ ...s, isLoading: true }));
|
|
4738
|
+
const text = await file.text();
|
|
4739
|
+
setState((s) => ({ ...s, isLoading: false, text }));
|
|
4740
|
+
};
|
|
4741
|
+
run();
|
|
4742
|
+
}, [file]);
|
|
4743
|
+
return state;
|
|
4744
|
+
};
|
|
4745
|
+
|
|
4746
|
+
const fileToBase64 = async (file) => {
|
|
4747
|
+
return new Promise((resolve, reject) => {
|
|
4748
|
+
const reader = new FileReader();
|
|
4749
|
+
reader.onload = () => {
|
|
4750
|
+
const result = reader.result;
|
|
4751
|
+
if (typeof result === "string") {
|
|
4752
|
+
resolve(result);
|
|
4753
|
+
} else {
|
|
4754
|
+
reject(new Error("Failed to convert file to base64."));
|
|
4755
|
+
}
|
|
4756
|
+
};
|
|
4757
|
+
reader.onerror = (error) => {
|
|
4758
|
+
reject(error);
|
|
4759
|
+
};
|
|
4760
|
+
reader.readAsDataURL(file);
|
|
4761
|
+
});
|
|
4762
|
+
};
|
|
4763
|
+
|
|
4764
|
+
const ComposerTxtAttachment = ({ document }) => {
|
|
4765
|
+
const { isLoading, text } = useLoadBrowserFile(document.file);
|
|
4766
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full w-full", children: isLoading ? /* @__PURE__ */ jsx(Spinner, { className: "animate-spin" }) : /* @__PURE__ */ jsx(TxtEntry, { data: text }) });
|
|
4767
|
+
};
|
|
4768
|
+
const ComposerPdfAttachment = ({ document }) => {
|
|
4769
|
+
const [state, setState] = useState({ isLoading: false, text: "" });
|
|
4770
|
+
useEffect(() => {
|
|
4771
|
+
let isCanceled = false;
|
|
4772
|
+
const run = async () => {
|
|
4773
|
+
if (!document.file) return;
|
|
4774
|
+
setState((s) => ({ ...s, isLoading: true }));
|
|
4775
|
+
const text = await fileToBase64(document.file);
|
|
4776
|
+
if (isCanceled) {
|
|
4777
|
+
return;
|
|
4778
|
+
}
|
|
4779
|
+
setState((s) => ({ ...s, isLoading: false, text }));
|
|
4780
|
+
};
|
|
4781
|
+
run();
|
|
4782
|
+
return () => {
|
|
4783
|
+
isCanceled = true;
|
|
4784
|
+
};
|
|
4785
|
+
}, [document]);
|
|
4786
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full w-full", children: state.isLoading ? /* @__PURE__ */ jsx(Spinner, { className: "animate-spin" }) : /* @__PURE__ */ jsx(PdfEntry, { data: state.text }) });
|
|
4787
|
+
};
|
|
4788
|
+
const AttachmentThumbnail = () => {
|
|
4789
|
+
const isImage = useAttachment((a) => a.type === "image");
|
|
4790
|
+
const document = useAttachment((a) => a.type === "document" ? a : void 0);
|
|
4791
|
+
const src = useAttachmentSrc();
|
|
4792
|
+
const canRemove = useAttachment((a) => a.source !== "message");
|
|
4793
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4794
|
+
/* @__PURE__ */ jsx(TooltipProvider$1, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4795
|
+
/* @__PURE__ */ jsx(AttachmentPrimitive.Root, { children: /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden size-16 rounded-lg bg-surface3 border-sm border-border1 ", children: isImage ? /* @__PURE__ */ jsx(ImageEntry, { src: src ?? "" }) : document?.contentType === "application/pdf" ? /* @__PURE__ */ jsx(ComposerPdfAttachment, { document }) : document ? /* @__PURE__ */ jsx(ComposerTxtAttachment, { document }) : null }) }) }),
|
|
4796
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx(AttachmentPrimitive.Name, {}) })
|
|
4797
|
+
] }) }),
|
|
4798
|
+
canRemove && /* @__PURE__ */ jsx(AttachmentRemove, {})
|
|
4799
|
+
] }) });
|
|
4800
|
+
};
|
|
4801
|
+
const AttachmentRemove = () => {
|
|
4802
|
+
return /* @__PURE__ */ jsx(AttachmentPrimitive.Remove, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
4803
|
+
TooltipIconButton,
|
|
4804
|
+
{
|
|
4805
|
+
tooltip: "Remove file",
|
|
4806
|
+
className: "absolute -right-3 -top-3 text-icon3 hover:text-icon6 rounded-full bg-surface1 hover:bg-surface2 rounded-full p-1",
|
|
4807
|
+
side: "top",
|
|
4808
|
+
children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CircleXIcon, {}) })
|
|
4809
|
+
}
|
|
4810
|
+
) });
|
|
4811
|
+
};
|
|
4812
|
+
const ComposerAttachments = () => {
|
|
4813
|
+
const hasAttachments = useHasAttachments();
|
|
4814
|
+
if (!hasAttachments) return null;
|
|
4815
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-row items-center gap-4 pb-2", children: /* @__PURE__ */ jsx(ComposerPrimitive.Attachments, { components: { Attachment: AttachmentThumbnail } }) });
|
|
4816
|
+
};
|
|
4817
|
+
|
|
4646
4818
|
const Thread = ({ ToolFallback, agentName, hasMemory, showFileSupport }) => {
|
|
4647
4819
|
const areaRef = useRef(null);
|
|
4648
4820
|
useAutoscroll(areaRef, { enabled: true });
|
|
@@ -4689,7 +4861,7 @@ const ThreadWelcome$1 = ({ agentName }) => {
|
|
|
4689
4861
|
const Composer$1 = ({ hasMemory, showFileSupport }) => {
|
|
4690
4862
|
return /* @__PURE__ */ jsxs("div", { className: "mx-4", children: [
|
|
4691
4863
|
/* @__PURE__ */ jsxs(ComposerPrimitive.Root, { children: [
|
|
4692
|
-
/* @__PURE__ */ jsx("div", { className: "max-w-[568px] w-full mx-auto
|
|
4864
|
+
/* @__PURE__ */ jsx("div", { className: "max-w-[568px] w-full mx-auto pb-2", children: /* @__PURE__ */ jsx(ComposerAttachments, {}) }),
|
|
4693
4865
|
/* @__PURE__ */ jsxs("div", { className: "bg-surface3 rounded-lg border-sm border-border1 py-4 mt-auto max-w-[568px] w-full mx-auto px-4", children: [
|
|
4694
4866
|
/* @__PURE__ */ jsx(ComposerPrimitive.Input, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(
|
|
4695
4867
|
"textarea",
|
|
@@ -4728,7 +4900,7 @@ const SpeechInput$1 = () => {
|
|
|
4728
4900
|
variant: "ghost",
|
|
4729
4901
|
className: "rounded-full",
|
|
4730
4902
|
onClick: () => isListening ? stop() : start(),
|
|
4731
|
-
children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon$
|
|
4903
|
+
children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon$1, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4732
4904
|
}
|
|
4733
4905
|
);
|
|
4734
4906
|
};
|
|
@@ -4744,7 +4916,7 @@ const ComposerAction$1 = ({ showFileSupport }) => {
|
|
|
4744
4916
|
children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
4745
4917
|
}
|
|
4746
4918
|
) }) }),
|
|
4747
|
-
/* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon$
|
|
4919
|
+
/* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon$1, {}) }) }) })
|
|
4748
4920
|
] });
|
|
4749
4921
|
};
|
|
4750
4922
|
const EditComposer$1 = () => {
|
|
@@ -4756,28 +4928,10 @@ const EditComposer$1 = () => {
|
|
|
4756
4928
|
] })
|
|
4757
4929
|
] });
|
|
4758
4930
|
};
|
|
4759
|
-
const CircleStopIcon$
|
|
4931
|
+
const CircleStopIcon$1 = () => {
|
|
4760
4932
|
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
4761
4933
|
};
|
|
4762
4934
|
|
|
4763
|
-
const fileToBase64 = async (file) => {
|
|
4764
|
-
return new Promise((resolve, reject) => {
|
|
4765
|
-
const reader = new FileReader();
|
|
4766
|
-
reader.onload = () => {
|
|
4767
|
-
const result = reader.result;
|
|
4768
|
-
if (typeof result === "string") {
|
|
4769
|
-
resolve(result);
|
|
4770
|
-
} else {
|
|
4771
|
-
reject(new Error("Failed to convert file to base64."));
|
|
4772
|
-
}
|
|
4773
|
-
};
|
|
4774
|
-
reader.onerror = (error) => {
|
|
4775
|
-
reject(error);
|
|
4776
|
-
};
|
|
4777
|
-
reader.readAsDataURL(file);
|
|
4778
|
-
});
|
|
4779
|
-
};
|
|
4780
|
-
|
|
4781
4935
|
class PDFAttachmentAdapter {
|
|
4782
4936
|
accept = "application/pdf";
|
|
4783
4937
|
async add({ file }) {
|
|
@@ -4844,13 +4998,13 @@ const convertToAIAttachments = async (attachments) => {
|
|
|
4844
4998
|
const promises = attachments.filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
|
|
4845
4999
|
if (attachment.type === "document") {
|
|
4846
5000
|
if (attachment.contentType === "application/pdf") {
|
|
5001
|
+
const pdfText = attachment.content?.[0]?.text || "";
|
|
4847
5002
|
return {
|
|
4848
5003
|
role: "user",
|
|
4849
5004
|
content: [
|
|
4850
5005
|
{
|
|
4851
5006
|
type: "file",
|
|
4852
|
-
|
|
4853
|
-
data: attachment.content?.[0]?.text || "",
|
|
5007
|
+
data: `data:application/pdf;base64,${pdfText}`,
|
|
4854
5008
|
mimeType: attachment.contentType,
|
|
4855
5009
|
filename: attachment.name
|
|
4856
5010
|
}
|
|
@@ -5236,6 +5390,10 @@ function useAgentModelSettingsState({ agentId }) {
|
|
|
5236
5390
|
const resetAll = () => {
|
|
5237
5391
|
setModelSettingsState(defaultModelSettings$1);
|
|
5238
5392
|
setChatWithGenerate(false);
|
|
5393
|
+
localStorage.setItem(
|
|
5394
|
+
LOCAL_STORAGE_KEY,
|
|
5395
|
+
JSON.stringify({ modelSettings: defaultModelSettings$1, chatWithGenerate: false, agentId })
|
|
5396
|
+
);
|
|
5239
5397
|
};
|
|
5240
5398
|
return {
|
|
5241
5399
|
modelSettings,
|
|
@@ -6317,7 +6475,7 @@ const useCodemirrorTheme = () => {
|
|
|
6317
6475
|
[]
|
|
6318
6476
|
);
|
|
6319
6477
|
};
|
|
6320
|
-
const SyntaxHighlighter = ({ data }) => {
|
|
6478
|
+
const SyntaxHighlighter$1 = ({ data }) => {
|
|
6321
6479
|
const formattedCode = JSON.stringify(data, null, 2);
|
|
6322
6480
|
const theme = useCodemirrorTheme();
|
|
6323
6481
|
return /* @__PURE__ */ jsx("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: /* @__PURE__ */ jsx(CodeMirror, { value: formattedCode, theme, extensions: [jsonLanguage] }) });
|
|
@@ -6432,10 +6590,10 @@ const AttributeValue = ({ value }) => {
|
|
|
6432
6590
|
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
6433
6591
|
}
|
|
6434
6592
|
if (typeof value === "object") {
|
|
6435
|
-
return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: value });
|
|
6593
|
+
return /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: value });
|
|
6436
6594
|
}
|
|
6437
6595
|
try {
|
|
6438
|
-
return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: JSON.parse(value) });
|
|
6596
|
+
return /* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: JSON.parse(value) });
|
|
6439
6597
|
} catch {
|
|
6440
6598
|
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
6441
6599
|
}
|
|
@@ -7172,25 +7330,6 @@ const useVNextNetworkChat = () => {
|
|
|
7172
7330
|
return context;
|
|
7173
7331
|
};
|
|
7174
7332
|
|
|
7175
|
-
function Spinner({ color = "#fff", className }) {
|
|
7176
|
-
return /* @__PURE__ */ jsx(
|
|
7177
|
-
"svg",
|
|
7178
|
-
{
|
|
7179
|
-
className: cn("animate-spin duration-700", className),
|
|
7180
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
7181
|
-
width: "24",
|
|
7182
|
-
height: "24",
|
|
7183
|
-
viewBox: "0 0 24 24",
|
|
7184
|
-
fill: "none",
|
|
7185
|
-
stroke: "currentColor",
|
|
7186
|
-
strokeWidth: "2",
|
|
7187
|
-
strokeLinecap: "round",
|
|
7188
|
-
strokeLinejoin: "round",
|
|
7189
|
-
children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", stroke: color })
|
|
7190
|
-
}
|
|
7191
|
-
);
|
|
7192
|
-
}
|
|
7193
|
-
|
|
7194
7333
|
const Clock = ({ startedAt, endedAt }) => {
|
|
7195
7334
|
const [time, setTime] = useState(startedAt);
|
|
7196
7335
|
useEffect(() => {
|
|
@@ -9313,7 +9452,7 @@ const SpeechInput = () => {
|
|
|
9313
9452
|
variant: "ghost",
|
|
9314
9453
|
className: "rounded-full",
|
|
9315
9454
|
onClick: () => isListening ? stop() : start(),
|
|
9316
|
-
children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon
|
|
9455
|
+
children: isListening ? /* @__PURE__ */ jsx(CircleStopIcon, {}) : /* @__PURE__ */ jsx(Mic, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
9317
9456
|
}
|
|
9318
9457
|
);
|
|
9319
9458
|
};
|
|
@@ -9329,7 +9468,7 @@ const ComposerAction = ({ showFileSupport }) => {
|
|
|
9329
9468
|
children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-6 w-6 text-[#898989] hover:text-[#fff]" })
|
|
9330
9469
|
}
|
|
9331
9470
|
) }) }),
|
|
9332
|
-
/* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon
|
|
9471
|
+
/* @__PURE__ */ jsx(ThreadPrimitive.If, { running: true, children: /* @__PURE__ */ jsx(ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Cancel", variant: "default", children: /* @__PURE__ */ jsx(CircleStopIcon, {}) }) }) })
|
|
9333
9472
|
] });
|
|
9334
9473
|
};
|
|
9335
9474
|
const EditComposer = () => {
|
|
@@ -9341,7 +9480,7 @@ const EditComposer = () => {
|
|
|
9341
9480
|
] })
|
|
9342
9481
|
] });
|
|
9343
9482
|
};
|
|
9344
|
-
const CircleStopIcon
|
|
9483
|
+
const CircleStopIcon = () => {
|
|
9345
9484
|
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
9346
9485
|
};
|
|
9347
9486
|
|
|
@@ -11087,12 +11226,88 @@ const WorkflowStatus = ({ stepId, status, result }) => {
|
|
|
11087
11226
|
] }),
|
|
11088
11227
|
children: /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-surface4 p-1 font-mono relative", children: [
|
|
11089
11228
|
/* @__PURE__ */ jsx(CopyButton, { content: JSON.stringify(result, null, 2), className: "absolute top-2 right-2 z-10" }),
|
|
11090
|
-
/* @__PURE__ */ jsx(SyntaxHighlighter, { data: result })
|
|
11229
|
+
/* @__PURE__ */ jsx(SyntaxHighlighter$1, { data: result })
|
|
11091
11230
|
] })
|
|
11092
11231
|
}
|
|
11093
11232
|
);
|
|
11094
11233
|
};
|
|
11095
11234
|
|
|
11235
|
+
const WorkflowInputData = ({
|
|
11236
|
+
schema,
|
|
11237
|
+
defaultValues,
|
|
11238
|
+
isSubmitLoading,
|
|
11239
|
+
submitButtonLabel,
|
|
11240
|
+
onSubmit
|
|
11241
|
+
}) => {
|
|
11242
|
+
const [type, setType] = useState("form");
|
|
11243
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
11244
|
+
/* @__PURE__ */ jsx(RadioGroup, { value: type, onValueChange: (value) => setType(value), className: "pb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-4", children: [
|
|
11245
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
11246
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value: "form", id: "form" }),
|
|
11247
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "form", className: "!text-icon3 text-ui-sm", children: "Form" })
|
|
11248
|
+
] }),
|
|
11249
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
11250
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { value: "json", id: "json" }),
|
|
11251
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "json", className: "!text-icon3 text-ui-sm", children: "JSON" })
|
|
11252
|
+
] })
|
|
11253
|
+
] }) }),
|
|
11254
|
+
type === "form" ? /* @__PURE__ */ jsx(
|
|
11255
|
+
DynamicForm,
|
|
11256
|
+
{
|
|
11257
|
+
schema,
|
|
11258
|
+
defaultValues,
|
|
11259
|
+
isSubmitLoading,
|
|
11260
|
+
submitButtonLabel,
|
|
11261
|
+
onSubmit
|
|
11262
|
+
}
|
|
11263
|
+
) : /* @__PURE__ */ jsx(
|
|
11264
|
+
JSONInput,
|
|
11265
|
+
{
|
|
11266
|
+
schema,
|
|
11267
|
+
defaultValues,
|
|
11268
|
+
isSubmitLoading,
|
|
11269
|
+
submitButtonLabel,
|
|
11270
|
+
onSubmit
|
|
11271
|
+
}
|
|
11272
|
+
)
|
|
11273
|
+
] });
|
|
11274
|
+
};
|
|
11275
|
+
const JSONInput = ({ schema, defaultValues, isSubmitLoading, submitButtonLabel, onSubmit }) => {
|
|
11276
|
+
const [errors, setErrors] = useState([]);
|
|
11277
|
+
const [inputData, setInputData] = useState(JSON.stringify(defaultValues ?? {}, null, 2));
|
|
11278
|
+
const handleSubmit = () => {
|
|
11279
|
+
setErrors([]);
|
|
11280
|
+
try {
|
|
11281
|
+
const result = schema.safeParse(JSON.parse(inputData));
|
|
11282
|
+
if (!result.success) {
|
|
11283
|
+
setErrors(result.error.issues.map((e) => `[${e.path.join(".")}] ${e.message}`));
|
|
11284
|
+
} else {
|
|
11285
|
+
onSubmit(result.data);
|
|
11286
|
+
}
|
|
11287
|
+
} catch (e) {
|
|
11288
|
+
setErrors(["Invalid JSON provided"]);
|
|
11289
|
+
}
|
|
11290
|
+
};
|
|
11291
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11292
|
+
errors.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-sm border-accent2 rounded-lg p-2", children: [
|
|
11293
|
+
/* @__PURE__ */ jsxs(Txt, { as: "p", variant: "ui-md", className: "text-accent2 font-semibold", children: [
|
|
11294
|
+
errors.length,
|
|
11295
|
+
" errors found"
|
|
11296
|
+
] }),
|
|
11297
|
+
/* @__PURE__ */ jsx("ul", { className: "list-disc list-inside", children: errors.map((error, idx) => /* @__PURE__ */ jsx("li", { className: "text-ui-sm text-accent2", children: error }, idx)) })
|
|
11298
|
+
] }),
|
|
11299
|
+
/* @__PURE__ */ jsx(SyntaxHighlighter, { data: inputData, onChange: setInputData }),
|
|
11300
|
+
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleSubmit, className: "w-full", size: "lg", children: isSubmitLoading ? /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) : submitButtonLabel })
|
|
11301
|
+
] });
|
|
11302
|
+
};
|
|
11303
|
+
const SyntaxHighlighter = ({ data, onChange }) => {
|
|
11304
|
+
const theme = useCodemirrorTheme$1();
|
|
11305
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: [
|
|
11306
|
+
/* @__PURE__ */ jsx(CopyButton, { content: data, className: "absolute top-2 right-2 z-10" }),
|
|
11307
|
+
/* @__PURE__ */ jsx(CodeMirror, { value: data, theme, extensions: [jsonLanguage], onChange })
|
|
11308
|
+
] });
|
|
11309
|
+
};
|
|
11310
|
+
|
|
11096
11311
|
function WorkflowTrigger({
|
|
11097
11312
|
workflowId,
|
|
11098
11313
|
setRunId,
|
|
@@ -11178,24 +11393,12 @@ function WorkflowTrigger({
|
|
|
11178
11393
|
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
11179
11394
|
return /* @__PURE__ */ jsxs("div", { className: "h-full pt-3 pb-12", children: [
|
|
11180
11395
|
/* @__PURE__ */ jsxs("div", { className: "space-y-4 px-5 pb-5 border-b-sm border-border1", children: [
|
|
11181
|
-
result?.runId && /* @__PURE__ */ jsxs(
|
|
11182
|
-
Button,
|
|
11183
|
-
{
|
|
11184
|
-
variant: "light",
|
|
11185
|
-
onClick: handleCancelWorkflowRun,
|
|
11186
|
-
disabled: !!cancelResponse?.message || isCancellingWorkflowRun,
|
|
11187
|
-
children: [
|
|
11188
|
-
isCancellingWorkflowRun ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CircleStopIcon, {}) }),
|
|
11189
|
-
cancelResponse?.message || "Cancel Workflow Run"
|
|
11190
|
-
]
|
|
11191
|
-
}
|
|
11192
|
-
),
|
|
11193
11396
|
(isResumingWorkflow || isSuspendedSteps && isStreamingWorkflow) && /* @__PURE__ */ jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
11194
11397
|
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin text-icon6" }) }),
|
|
11195
11398
|
/* @__PURE__ */ jsx(Txt, { children: "Resuming workflow" })
|
|
11196
11399
|
] }),
|
|
11197
11400
|
!isSuspendedSteps && /* @__PURE__ */ jsx(Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsx(
|
|
11198
|
-
|
|
11401
|
+
WorkflowInputData,
|
|
11199
11402
|
{
|
|
11200
11403
|
schema: zodInputSchema,
|
|
11201
11404
|
defaultValues: payload,
|
|
@@ -11231,7 +11434,7 @@ function WorkflowTrigger({
|
|
|
11231
11434
|
}
|
|
11232
11435
|
) }),
|
|
11233
11436
|
/* @__PURE__ */ jsx(
|
|
11234
|
-
|
|
11437
|
+
WorkflowInputData,
|
|
11235
11438
|
{
|
|
11236
11439
|
schema: stepSchema,
|
|
11237
11440
|
isSubmitLoading: isResumingWorkflow,
|
|
@@ -11248,6 +11451,20 @@ function WorkflowTrigger({
|
|
|
11248
11451
|
)
|
|
11249
11452
|
] }, step.stepId);
|
|
11250
11453
|
}),
|
|
11454
|
+
result?.runId && /* @__PURE__ */ jsxs(
|
|
11455
|
+
Button,
|
|
11456
|
+
{
|
|
11457
|
+
variant: "light",
|
|
11458
|
+
className: "w-full",
|
|
11459
|
+
size: "lg",
|
|
11460
|
+
onClick: handleCancelWorkflowRun,
|
|
11461
|
+
disabled: !!cancelResponse?.message || isCancellingWorkflowRun,
|
|
11462
|
+
children: [
|
|
11463
|
+
isCancellingWorkflowRun ? /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(StopCircle, {}) }),
|
|
11464
|
+
cancelResponse?.message || "Cancel Workflow Run"
|
|
11465
|
+
]
|
|
11466
|
+
}
|
|
11467
|
+
),
|
|
11251
11468
|
hasWorkflowActivePaths && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11252
11469
|
/* @__PURE__ */ jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
11253
11470
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -11270,13 +11487,10 @@ const WorkflowJsonDialog = ({ result }) => {
|
|
|
11270
11487
|
] }),
|
|
11271
11488
|
/* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsx(DialogPortal, { children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-6xl max-h-[90vh] overflow-y-auto overflow-x-hidden bg-surface2", children: [
|
|
11272
11489
|
/* @__PURE__ */ jsx(DialogTitle, { children: "Workflow Execution (JSON)" }),
|
|
11273
|
-
/* @__PURE__ */ jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsx(SyntaxHighlighter$
|
|
11490
|
+
/* @__PURE__ */ jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result, className: "p-4" }) })
|
|
11274
11491
|
] }) }) })
|
|
11275
11492
|
] });
|
|
11276
11493
|
};
|
|
11277
|
-
const CircleStopIcon = () => {
|
|
11278
|
-
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
11279
|
-
};
|
|
11280
11494
|
|
|
11281
11495
|
const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
|
|
11282
11496
|
if (isLoading) {
|