@malette/agent-sdk 0.1.0 → 0.1.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,10 +2,10 @@ import Cookies2 from 'js-cookie';
2
2
  import OSS from 'ali-oss';
3
3
  import { create } from 'zustand';
4
4
  import { devtools } from 'zustand/middleware';
5
- import * as React21 from 'react';
6
- import React21__default, { memo, useState, useMemo, useEffect, createContext, useCallback, useRef, useImperativeHandle, useContext } from 'react';
7
- import ReactMarkdown from 'react-markdown';
5
+ import * as React20 from 'react';
6
+ import React20__default, { memo, useState, useMemo, useEffect, createContext, useCallback, useRef, useImperativeHandle, useContext } from 'react';
8
7
  import { Loader2, Check, AlertCircle, ChevronUp, ChevronDown, ExternalLink, Download, Bot, Users, X, Copy, Image, Maximize2, Clock, Sparkles, AlertTriangle, Play, Pencil, Square, RotateCcw, SkipForward, FileText, Code2, FileJson, FileCode, CheckCheck, Eye, Zap, ChevronRight, Lightbulb, RefreshCw, Trash2, ImageIcon, GripVertical, Minimize2, Smartphone, Tablet, Monitor, Globe, PanelLeft, ArrowLeft, Settings, CheckCircle2, Brain, UserCheck, Shield, User, Plus, PanelLeftClose, Search, MessageSquare, ImagePlus, Send, HelpCircle, Lock, Calendar, Link, Share2, Wand2, LayoutGrid, Mic, CheckCircle, ListOrdered, Ban, Pause, Save, Tag, Folder, EyeOff, FileEdit, BookOpen, Edit, XCircle, ArrowRight } from 'lucide-react';
8
+ import ReactMarkdown from 'react-markdown';
9
9
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
10
10
  import { useShallow } from 'zustand/react/shallow';
11
11
  import * as DialogPrimitive from '@radix-ui/react-dialog';
@@ -6499,75 +6499,6 @@ function remarkGfm(options) {
6499
6499
  fromMarkdownExtensions.push(gfmFromMarkdown());
6500
6500
  toMarkdownExtensions.push(gfmToMarkdown(settings));
6501
6501
  }
6502
-
6503
- // src/utils/asset.ts
6504
- var isHttpUrl = (value) => {
6505
- if (!value) return false;
6506
- try {
6507
- const url = new URL(value);
6508
- return url.protocol === "http:" || url.protocol === "https:";
6509
- } catch {
6510
- return false;
6511
- }
6512
- };
6513
- var isVideoUrl = (url) => {
6514
- if (!url) return false;
6515
- try {
6516
- const urlObj = new URL(url, "http://dummy");
6517
- const pathname = urlObj.pathname.toLowerCase();
6518
- return /\.(mp4|mov|webm|avi|mkv|m4v)$/i.test(pathname);
6519
- } catch {
6520
- const lower = url.toLowerCase();
6521
- return /\.(mp4|mov|webm|avi|mkv|m4v)(\?|#|$)/i.test(lower);
6522
- }
6523
- };
6524
- var inferAssetTypeFromFile = (file) => {
6525
- if (!file) return "file";
6526
- if (file.type?.startsWith("video/")) return "video";
6527
- if (file.type?.startsWith("image/")) return "image";
6528
- return "file";
6529
- };
6530
- var inferAssetTypeFromUrl = (url) => {
6531
- if (!url) return "file";
6532
- return isVideoUrl(url) ? "video" : "image";
6533
- };
6534
- var createAssetFromSource = (options) => {
6535
- const { fileId, fileUrl, type } = options;
6536
- if (!fileId && !fileUrl) return null;
6537
- const url = fileUrl && isHttpUrl(fileUrl) ? fileUrl : void 0;
6538
- const inferredFileId = fileId || (!url && fileUrl ? fileUrl : void 0);
6539
- const assetType = type || (url ? inferAssetTypeFromUrl(url) : "image");
6540
- return {
6541
- type: assetType,
6542
- fileId: inferredFileId,
6543
- url
6544
- };
6545
- };
6546
- var resolveAssetForDisplay = async (asset, config) => {
6547
- let working = asset;
6548
- const strategy = config?.asset;
6549
- if (strategy?.resolve && !working.url) {
6550
- working = await strategy.resolve(working);
6551
- }
6552
- if (strategy?.transform) {
6553
- working = strategy.transform(working);
6554
- }
6555
- if (strategy?.render) {
6556
- return strategy.render(working);
6557
- }
6558
- if (working.url) {
6559
- return {
6560
- url: working.url,
6561
- hdUrl: working.url,
6562
- isVideo: working.type === "video" || inferAssetTypeFromUrl(working.url) === "video"
6563
- };
6564
- }
6565
- if (working.fileId) {
6566
- const resolved = resolveMediaUrl({ fileId: working.fileId });
6567
- if (resolved) return resolved;
6568
- }
6569
- return null;
6570
- };
6571
6502
  function formatTime(timestamp) {
6572
6503
  const date = new Date(timestamp);
6573
6504
  return date.toLocaleTimeString("zh-CN", {
@@ -6933,6 +6864,76 @@ var MultiAgentThoughts = memo(function MultiAgentThoughts2({
6933
6864
  });
6934
6865
  var MultiAgentThoughts_default = MultiAgentThoughts;
6935
6866
 
6867
+ // src/utils/asset.ts
6868
+ var isHttpUrl = (value) => {
6869
+ if (!value) return false;
6870
+ try {
6871
+ const url = new URL(value);
6872
+ return url.protocol === "http:" || url.protocol === "https:";
6873
+ } catch {
6874
+ return false;
6875
+ }
6876
+ };
6877
+ var isVideoUrl = (url) => {
6878
+ if (!url) return false;
6879
+ try {
6880
+ const urlObj = new URL(url, "http://dummy");
6881
+ const pathname = urlObj.pathname.toLowerCase();
6882
+ return /\.(mp4|mov|webm|avi|mkv|m4v)$/i.test(pathname);
6883
+ } catch {
6884
+ const lower = url.toLowerCase();
6885
+ return /\.(mp4|mov|webm|avi|mkv|m4v)(\?|#|$)/i.test(lower);
6886
+ }
6887
+ };
6888
+ var inferAssetTypeFromFile = (file) => {
6889
+ if (!file) return "file";
6890
+ if (file.type?.startsWith("video/")) return "video";
6891
+ if (file.type?.startsWith("image/")) return "image";
6892
+ return "file";
6893
+ };
6894
+ var inferAssetTypeFromUrl = (url) => {
6895
+ if (!url) return "file";
6896
+ return isVideoUrl(url) ? "video" : "image";
6897
+ };
6898
+ var createAssetFromSource = (options) => {
6899
+ const { fileId, fileUrl, type } = options;
6900
+ if (!fileId && !fileUrl) return null;
6901
+ const url = fileUrl && isHttpUrl(fileUrl) ? fileUrl : void 0;
6902
+ const inferredFileId = fileId || (!url && fileUrl ? fileUrl : void 0);
6903
+ const assetType = type || (url ? inferAssetTypeFromUrl(url) : "image");
6904
+ return {
6905
+ type: assetType,
6906
+ fileId: inferredFileId,
6907
+ url
6908
+ };
6909
+ };
6910
+ var resolveAssetForDisplay = async (asset, config) => {
6911
+ let working = asset;
6912
+ const strategy = config?.asset;
6913
+ console.log("Resolving asset for display:", asset, "with strategy:", strategy);
6914
+ if (strategy?.resolve && !working.url) {
6915
+ working = await strategy.resolve(working);
6916
+ }
6917
+ if (strategy?.transform) {
6918
+ working = strategy.transform(working);
6919
+ }
6920
+ if (strategy?.render) {
6921
+ return strategy.render(working);
6922
+ }
6923
+ if (working.fileId) {
6924
+ const resolved = resolveMediaUrl({ fileId: working.fileId });
6925
+ if (resolved) return resolved;
6926
+ }
6927
+ if (working.url) {
6928
+ return {
6929
+ url: working.url,
6930
+ hdUrl: working.url,
6931
+ isVideo: working.type === "video" || inferAssetTypeFromUrl(working.url) === "video"
6932
+ };
6933
+ }
6934
+ return null;
6935
+ };
6936
+
6936
6937
  // ../../node_modules/clsx/dist/clsx.mjs
6937
6938
  function r(e) {
6938
6939
  var t, f, n = "";
@@ -7302,7 +7303,7 @@ var fractionRegex = /^\d+\/\d+$/;
7302
7303
  var stringLengths = /* @__PURE__ */ new Set(["px", "full", "screen"]);
7303
7304
  var tshirtUnitRegex = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/;
7304
7305
  var lengthUnitRegex = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/;
7305
- var colorFunctionRegex = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/;
7306
+ var colorFunctionRegex = /^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/;
7306
7307
  var shadowRegex = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;
7307
7308
  var imageRegex = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;
7308
7309
  var isLength = (value) => isNumber(value) || stringLengths.has(value) || fractionRegex.test(value);
@@ -9969,7 +9970,7 @@ var StepResultRenderer = memo(function StepResultRenderer2({
9969
9970
  className: "relative group/plan-img cursor-zoom-in",
9970
9971
  onClick: () => setPreviewImage(item.hdUrl),
9971
9972
  children: [
9972
- !imgLoaded[i] && !imgError[i] && /* @__PURE__ */ jsx("div", { className: "w-20 h-20 rounded-lg bg-zinc-800 flex items-center justify-center", children: /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 text-zinc-600 animate-spin" }) }),
9973
+ !imgLoaded[i] && !imgError[i] && /* @__PURE__ */ jsx("div", { className: "w-20 h-20 rounded-lg bg-zinc-800 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-[#d8ff00]" }) }),
9973
9974
  imgError[i] && /* @__PURE__ */ jsx("div", { className: "w-20 h-20 rounded-lg bg-zinc-800 flex items-center justify-center border border-zinc-700", children: /* @__PURE__ */ jsx(Image, { className: "w-5 h-5 text-zinc-600" }) }),
9974
9975
  /* @__PURE__ */ jsx(
9975
9976
  "img",
@@ -10503,7 +10504,7 @@ var MessageImageInternal = memo(function MessageImageInternal2({ src, alt, class
10503
10504
  const cachedStatus = imageLoadedCache.get(src);
10504
10505
  const [loaded, setLoaded] = useState(cachedStatus === "loaded");
10505
10506
  const [error, setError] = useState(cachedStatus === "error");
10506
- const imgRef = React21__default.useRef(null);
10507
+ const imgRef = React20__default.useRef(null);
10507
10508
  const [previewUrl, setPreviewUrl] = useState(null);
10508
10509
  const ImagePreviewComp = useComponent("ImagePreview") || ImagePreviewInternal;
10509
10510
  useEffect(() => {
@@ -11833,13 +11834,13 @@ var ContentPreviewModal = memo(function ContentPreviewModal2({
11833
11834
  } catch {
11834
11835
  }
11835
11836
  }, [parsed.content]);
11836
- React21__default.useEffect(() => {
11837
+ React20__default.useEffect(() => {
11837
11838
  document.body.style.overflow = "hidden";
11838
11839
  return () => {
11839
11840
  document.body.style.overflow = "";
11840
11841
  };
11841
11842
  }, []);
11842
- React21__default.useEffect(() => {
11843
+ React20__default.useEffect(() => {
11843
11844
  const handleKeyDown = (e) => {
11844
11845
  if (e.key === "Escape") {
11845
11846
  onClose();
@@ -11938,13 +11939,13 @@ var ContentPreviewRenderer = memo(function ContentPreviewRenderer2({
11938
11939
  return /* @__PURE__ */ jsx(SourceCodeViewer, { content: parsed.content, language: parsed.language || parsed.type });
11939
11940
  });
11940
11941
  var HtmlPreview = memo(function HtmlPreview2({ content }) {
11941
- const iframeRef = React21__default.useRef(null);
11942
+ const iframeRef = React20__default.useRef(null);
11942
11943
  const [scale, setScale] = useState(0.5);
11943
11944
  const blobUrl = useMemo(() => {
11944
11945
  const blob = new Blob([content], { type: "text/html" });
11945
11946
  return URL.createObjectURL(blob);
11946
11947
  }, [content]);
11947
- React21__default.useEffect(() => {
11948
+ React20__default.useEffect(() => {
11948
11949
  return () => {
11949
11950
  URL.revokeObjectURL(blobUrl);
11950
11951
  };
@@ -12300,7 +12301,7 @@ var ToolResultRenderer = memo(function ToolResultRenderer2({
12300
12301
  }
12301
12302
  ) }, `video-${i}`)) }),
12302
12303
  imageUrls.length > 0 && /* @__PURE__ */ jsx("div", { children: imageUrls.map((img, i) => /* @__PURE__ */ jsxs("div", { className: `relative group/img overflow-hidden ${imageUrls.length > 1 ? "aspect-square bg-black" : ""}`, children: [
12303
- !imgLoaded[i] && /* @__PURE__ */ jsx("div", { className: `bg-zinc-800 animate-pulse flex items-center justify-center`, children: /* @__PURE__ */ jsx(Loader2, { className: "w-5 h-5 text-zinc-600 animate-spin" }) }),
12304
+ !imgLoaded[i] && /* @__PURE__ */ jsx("div", { className: `bg-zinc-800 animate-pulse flex items-center justify-center`, children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-5 w-5 border-b-2 border-[#d8ff00]" }) }),
12304
12305
  /* @__PURE__ */ jsx(
12305
12306
  "img",
12306
12307
  {
@@ -12366,7 +12367,7 @@ var SkillLoadCard = memo(function SkillLoadCard2({ toolCall }) {
12366
12367
  const skillName = toolCall.arguments?.skill_name || "\u6280\u80FD";
12367
12368
  const actionText = toolCall.name === "load_skill" ? "\u542F\u7528" : toolCall.name === "unload_skill" ? "\u505C\u7528" : toolCall.name === "switch_skill" ? "\u5207\u6362" : "\u52A0\u8F7D";
12368
12369
  return /* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-violet-500/10 to-purple-500/10 border border-violet-500/20 rounded-full text-sm", children: [
12369
- isPending ? /* @__PURE__ */ jsx(Loader2, { size: 14, className: "text-violet-400 animate-spin" }) : isSuccess ? /* @__PURE__ */ jsx(Zap, { size: 14, className: "text-violet-400" }) : /* @__PURE__ */ jsx(Zap, { size: 14, className: "text-red-400" }),
12370
+ isPending ? /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-3.5 w-3.5 border-b-2 border-violet-400" }) : isSuccess ? /* @__PURE__ */ jsx(Zap, { size: 14, className: "text-violet-400" }) : /* @__PURE__ */ jsx(Zap, { size: 14, className: "text-red-400" }),
12370
12371
  /* @__PURE__ */ jsx("span", { className: "text-zinc-300", children: isPending ? `\u6B63\u5728${actionText}` : isSuccess ? `\u5DF2${actionText}` : `${actionText}\u5931\u8D25` }),
12371
12372
  /* @__PURE__ */ jsx("span", { className: "font-medium text-violet-300", children: skillName }),
12372
12373
  isSuccess && /* @__PURE__ */ jsx("span", { className: "text-zinc-500", children: "\u6280\u80FD" })
@@ -12450,7 +12451,7 @@ var ToolCallCard3 = memo(function ToolCallCard4({
12450
12451
  className: "flex items-center justify-between cursor-pointer",
12451
12452
  onClick: () => setHeaderExpanded(!headerExpanded),
12452
12453
  children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12453
- /* @__PURE__ */ jsx("div", { className: `w-5 h-5 rounded flex items-center justify-center ${isPending ? "bg-amber-500/20" : isSuccess ? "bg-green-500/20" : "bg-red-500/20"}`, children: isPending ? /* @__PURE__ */ jsx(Loader2, { size: 12, className: "text-amber-400 animate-spin" }) : isSuccess ? /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }) : /* @__PURE__ */ jsx(Zap, { size: 12, className: "text-red-400" }) }),
12454
+ /* @__PURE__ */ jsx("div", { className: `w-5 h-5 rounded flex items-center justify-center ${isPending ? "bg-amber-500/20" : isSuccess ? "bg-green-500/20" : "bg-red-500/20"}`, children: isPending ? /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-3 w-3 border-b-2 border-amber-400" }) : isSuccess ? /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }) : /* @__PURE__ */ jsx(Zap, { size: 12, className: "text-red-400" }) }),
12454
12455
  /* @__PURE__ */ jsx("span", { className: "agent-toolcall-title text-xs text-zinc-400", children: toolDisplayName }),
12455
12456
  /* @__PURE__ */ jsx("span", { className: `text-[10px] px-1.5 py-0.5 rounded ${isPending ? "bg-amber-500/10 text-amber-400" : isSuccess ? "bg-green-500/10 text-green-400" : "bg-red-500/10 text-red-400"}`, children: isPending ? "\u6267\u884C\u4E2D" : isSuccess ? "\u5DF2\u5B8C\u6210" : "\u5931\u8D25" }),
12456
12457
  headerExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: "text-zinc-500" }) : /* @__PURE__ */ jsx(ChevronRight, { size: 14, className: "text-zinc-500" })
@@ -12536,7 +12537,7 @@ var StreamingToolCard = memo(function StreamingToolCard2({ toolCall }) {
12536
12537
  const errorMessage = toolCall.result?.error || toolCall.error;
12537
12538
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-3 py-2 bg-zinc-900/60 rounded-lg border border-zinc-700/40", children: [
12538
12539
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12539
- /* @__PURE__ */ jsx("div", { className: `w-5 h-5 rounded flex items-center justify-center ${isPending ? "bg-amber-500/20" : isSuccess ? "bg-green-500/20" : "bg-red-500/20"}`, children: isPending ? /* @__PURE__ */ jsx(Loader2, { size: 12, className: "text-amber-400 animate-spin" }) : isSuccess ? /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }) : /* @__PURE__ */ jsx(Zap, { size: 12, className: "text-red-400" }) }),
12540
+ /* @__PURE__ */ jsx("div", { className: `w-5 h-5 rounded flex items-center justify-center ${isPending ? "bg-amber-500/20" : isSuccess ? "bg-green-500/20" : "bg-red-500/20"}`, children: isPending ? /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-3 w-3 border-b-2 border-[#d8ff00]" }) : isSuccess ? /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }) : /* @__PURE__ */ jsx(Zap, { size: 12, className: "text-red-400" }) }),
12540
12541
  /* @__PURE__ */ jsx("span", { className: "text-xs text-zinc-300 truncate flex-1", children: toolName }),
12541
12542
  /* @__PURE__ */ jsx("span", { className: `text-[10px] px-1.5 py-0.5 rounded ${isPending ? "bg-amber-500/10 text-amber-400" : isSuccess ? "bg-green-500/10 text-green-400" : "bg-red-500/10 text-red-400"}`, children: isPending ? "\u6267\u884C\u4E2D" : isSuccess ? "\u5B8C\u6210" : "\u5931\u8D25" })
12542
12543
  ] }),
@@ -14282,274 +14283,7 @@ var EmptyState = memo(function EmptyState2() {
14282
14283
  ] }) });
14283
14284
  });
14284
14285
  var LoadingState = memo(function LoadingState2() {
14285
- return /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-center h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
14286
- /* @__PURE__ */ jsx(Loader2, { className: "w-8 h-8 text-[#d8ff00] animate-spin mx-auto mb-3" }),
14287
- /* @__PURE__ */ jsx("p", { className: "text-zinc-500 text-sm", children: "\u52A0\u8F7D\u6D88\u606F\u4E2D..." })
14288
- ] }) });
14289
- });
14290
- var CodeBlock3 = memo(function CodeBlock4({ children, className }) {
14291
- const [copied, setCopied] = useState(false);
14292
- const language = className?.replace("language-", "") || "text";
14293
- const handleCopy = async () => {
14294
- await navigator.clipboard.writeText(children);
14295
- setCopied(true);
14296
- setTimeout(() => setCopied(false), 2e3);
14297
- };
14298
- return /* @__PURE__ */ jsxs("div", { className: "relative group my-2 rounded-lg overflow-hidden bg-zinc-900 border border-zinc-800", children: [
14299
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1.5 bg-zinc-800/50 border-b border-zinc-800", children: [
14300
- /* @__PURE__ */ jsx("span", { className: "text-xs text-zinc-500 font-mono", children: language }),
14301
- /* @__PURE__ */ jsxs("button", { onClick: handleCopy, className: "flex items-center gap-1 text-xs text-zinc-500 hover:text-zinc-300 transition-colors", children: [
14302
- copied ? /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }) : /* @__PURE__ */ jsx(Copy, { size: 12 }),
14303
- copied ? "\u5DF2\u590D\u5236" : "\u590D\u5236"
14304
- ] })
14305
- ] }),
14306
- /* @__PURE__ */ jsx("pre", { className: "p-3 overflow-x-auto text-xs", children: /* @__PURE__ */ jsx("code", { className: `${className} text-zinc-300`, children }) })
14307
- ] });
14308
- });
14309
- var ResolvedMarkdownMedia3 = memo(function ResolvedMarkdownMedia4({
14310
- src,
14311
- alt,
14312
- config
14313
- }) {
14314
- const [media, setMedia] = useState(null);
14315
- useEffect(() => {
14316
- let active = true;
14317
- const load = async () => {
14318
- if (!src) {
14319
- if (active) setMedia(null);
14320
- return;
14321
- }
14322
- const asset = createAssetFromSource({
14323
- fileUrl: src,
14324
- fileId: isHttpUrl(src) ? void 0 : src,
14325
- type: inferAssetTypeFromUrl(src)
14326
- });
14327
- if (!asset) {
14328
- if (active) setMedia(null);
14329
- return;
14330
- }
14331
- const resolved = await resolveAssetForDisplay(asset, config);
14332
- if (active) setMedia(resolved);
14333
- };
14334
- load();
14335
- return () => {
14336
- active = false;
14337
- };
14338
- }, [src, config]);
14339
- if (!media) return null;
14340
- if (media.isVideo) {
14341
- return /* @__PURE__ */ jsx(
14342
- "video",
14343
- {
14344
- src: media.url,
14345
- controls: true,
14346
- className: "max-w-full rounded-lg max-h-[320px] w-full my-2",
14347
- preload: "metadata"
14348
- }
14349
- );
14350
- }
14351
- return /* @__PURE__ */ jsx(
14352
- "img",
14353
- {
14354
- src: media.url,
14355
- alt: alt || "image",
14356
- className: "max-w-full rounded-lg max-h-[320px] w-full my-2 object-contain"
14357
- }
14358
- );
14359
- });
14360
- var MarkdownContent3 = memo(function MarkdownContent4({ content, config }) {
14361
- return /* @__PURE__ */ jsx(
14362
- ReactMarkdown,
14363
- {
14364
- remarkPlugins: [remarkGfm],
14365
- components: {
14366
- code({ className, children, ...props }) {
14367
- const codeString = String(children).replace(/\n$/, "");
14368
- const isBlock = className || codeString.includes("\n");
14369
- if (isBlock) return /* @__PURE__ */ jsx(CodeBlock3, { className, children: codeString });
14370
- return /* @__PURE__ */ jsx("code", { className: "px-1 py-0.5 bg-zinc-800 rounded text-[#d8ff00] text-xs font-mono", ...props, children });
14371
- },
14372
- p: ({ children }) => /* @__PURE__ */ jsx("p", { className: "mb-2 last:mb-0 leading-relaxed", children }),
14373
- h1: ({ children }) => /* @__PURE__ */ jsx("h1", { className: "text-base font-bold mb-2 mt-3 first:mt-0", children }),
14374
- h2: ({ children }) => /* @__PURE__ */ jsx("h2", { className: "text-sm font-bold mb-2 mt-3 first:mt-0", children }),
14375
- h3: ({ children }) => /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold mb-1 mt-2 first:mt-0", children }),
14376
- ul: ({ children }) => /* @__PURE__ */ jsx("ul", { className: "list-disc list-inside mb-2 space-y-0.5", children }),
14377
- ol: ({ children }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal list-inside mb-2 space-y-0.5", children }),
14378
- li: ({ children }) => /* @__PURE__ */ jsx("li", { className: "leading-relaxed", children }),
14379
- blockquote: ({ children }) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-2 border-[#d8ff00]/50 pl-2 my-2 text-zinc-400 italic", children }),
14380
- img: ({ src, alt }) => /* @__PURE__ */ jsx(ResolvedMarkdownMedia3, { src, alt, config }),
14381
- a: ({ href, children }) => {
14382
- const link2 = href || "";
14383
- const isMediaLink = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(link2) || isVideoUrl(link2);
14384
- if (isMediaLink) {
14385
- return /* @__PURE__ */ jsx(ResolvedMarkdownMedia3, { src: link2, alt: typeof children === "string" ? children : void 0, config });
14386
- }
14387
- return /* @__PURE__ */ jsx("a", { href, target: "_blank", rel: "noopener noreferrer", className: "text-[#d8ff00] hover:underline", children });
14388
- },
14389
- strong: ({ children }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold text-white", children }),
14390
- em: ({ children }) => /* @__PURE__ */ jsx("em", { className: "italic", children })
14391
- },
14392
- children: content
14393
- }
14394
- );
14395
- });
14396
- var ToolCallCard5 = memo(function ToolCallCard6({ toolCall }) {
14397
- const [expanded, setExpanded] = useState(false);
14398
- console.log("[UI] \u{1F527} ToolCallCard \u6536\u5230 toolCall:", { id: toolCall.id, status: toolCall.status });
14399
- if (toolCall.status === "waiting_confirmation") {
14400
- console.log("[UI] \u2705 \u6E32\u67D3 ToolConfirmCard (waiting_confirmation)");
14401
- return /* @__PURE__ */ jsx(ToolConfirmCard, { toolCall, compact: true });
14402
- }
14403
- console.log("[UI] \u26A0\uFE0F \u6E32\u67D3\u666E\u901A\u5361\u7247\uFF0Cstatus =", toolCall.status);
14404
- const getStatusConfig = () => {
14405
- switch (toolCall.status) {
14406
- case "completed":
14407
- return {
14408
- bgColor: "bg-green-500/20",
14409
- textColor: "text-green-400",
14410
- borderColor: "border-green-500/30",
14411
- icon: /* @__PURE__ */ jsx(Check, { size: 12, className: "text-green-400" }),
14412
- label: "\u5B8C\u6210"
14413
- };
14414
- case "failed":
14415
- return {
14416
- bgColor: "bg-red-500/20",
14417
- textColor: "text-red-400",
14418
- borderColor: "border-red-500/30",
14419
- icon: /* @__PURE__ */ jsx(Lightbulb, { size: 12, className: "text-red-400" }),
14420
- label: "\u5931\u8D25"
14421
- };
14422
- case "rejected":
14423
- return {
14424
- bgColor: "bg-zinc-500/20",
14425
- textColor: "text-zinc-400",
14426
- borderColor: "border-zinc-500/30",
14427
- icon: /* @__PURE__ */ jsx(Lightbulb, { size: 12, className: "text-zinc-400" }),
14428
- label: "\u5DF2\u62D2\u7EDD"
14429
- };
14430
- case "confirmed":
14431
- case "executing":
14432
- return {
14433
- bgColor: "bg-blue-500/20",
14434
- textColor: "text-blue-400",
14435
- borderColor: "border-blue-500/30",
14436
- icon: /* @__PURE__ */ jsx(Loader2, { size: 12, className: "text-blue-400 animate-spin" }),
14437
- label: "\u6267\u884C\u4E2D"
14438
- };
14439
- default:
14440
- return {
14441
- bgColor: "bg-amber-500/20",
14442
- textColor: "text-amber-400",
14443
- borderColor: "border-amber-500/30",
14444
- icon: /* @__PURE__ */ jsx(Loader2, { size: 12, className: "text-amber-400 animate-spin" }),
14445
- label: "\u6267\u884C\u4E2D"
14446
- };
14447
- }
14448
- };
14449
- const statusConfig = getStatusConfig();
14450
- const hasArguments = toolCall.arguments && Object.keys(toolCall.arguments).length > 0;
14451
- const hasResult = toolCall.result || toolCall.error;
14452
- const canExpand = hasArguments || hasResult;
14453
- return /* @__PURE__ */ jsxs("div", { className: `rounded-lg border ${statusConfig.borderColor} overflow-hidden bg-zinc-900/60`, children: [
14454
- /* @__PURE__ */ jsxs(
14455
- "button",
14456
- {
14457
- onClick: () => canExpand && setExpanded(!expanded),
14458
- disabled: !canExpand,
14459
- className: `w-full flex items-center gap-2 px-3 py-2 ${canExpand ? "hover:bg-zinc-800/50 cursor-pointer" : "cursor-default"} transition-colors`,
14460
- children: [
14461
- /* @__PURE__ */ jsx("div", { className: `w-5 h-5 rounded flex items-center justify-center ${statusConfig.bgColor}`, children: statusConfig.icon }),
14462
- /* @__PURE__ */ jsx("span", { className: "text-xs text-zinc-300 truncate flex-1 text-left", children: toolCall.displayName || toolCall.name?.replace("comfy_", "") || "Tool" }),
14463
- /* @__PURE__ */ jsx("span", { className: `text-[10px] px-1.5 py-0.5 rounded ${statusConfig.bgColor} ${statusConfig.textColor}`, children: statusConfig.label }),
14464
- canExpand && (expanded ? /* @__PURE__ */ jsx(ChevronUp, { size: 12, className: "text-zinc-500" }) : /* @__PURE__ */ jsx(ChevronDown, { size: 12, className: "text-zinc-500" }))
14465
- ]
14466
- }
14467
- ),
14468
- expanded && /* @__PURE__ */ jsxs("div", { className: "border-t border-zinc-700/50 px-3 py-2 space-y-2", children: [
14469
- hasArguments && /* @__PURE__ */ jsxs("div", { children: [
14470
- /* @__PURE__ */ jsx("div", { className: "text-[10px] text-zinc-500 uppercase tracking-wide mb-1", children: "\u53C2\u6570" }),
14471
- /* @__PURE__ */ jsx("pre", { className: "text-[11px] text-zinc-400 bg-zinc-800/50 rounded p-2 overflow-x-auto font-mono", children: JSON.stringify(toolCall.arguments, null, 2) })
14472
- ] }),
14473
- toolCall.result && /* @__PURE__ */ jsxs("div", { children: [
14474
- /* @__PURE__ */ jsx("div", { className: "text-[10px] text-zinc-500 uppercase tracking-wide mb-1", children: "\u7ED3\u679C" }),
14475
- /* @__PURE__ */ jsx("div", { className: "text-[11px] text-zinc-300 bg-zinc-800/50 rounded p-2 overflow-x-auto max-h-40 overflow-y-auto", children: typeof toolCall.result === "string" ? toolCall.result.length > 500 ? /* @__PURE__ */ jsxs("pre", { className: "font-mono whitespace-pre-wrap break-words", children: [
14476
- toolCall.result.slice(0, 500),
14477
- "..."
14478
- ] }) : /* @__PURE__ */ jsx("pre", { className: "font-mono whitespace-pre-wrap break-words", children: toolCall.result }) : /* @__PURE__ */ jsx("pre", { className: "font-mono", children: JSON.stringify(toolCall.result, null, 2) }) })
14479
- ] }),
14480
- toolCall.error && /* @__PURE__ */ jsxs("div", { children: [
14481
- /* @__PURE__ */ jsx("div", { className: "text-[10px] text-red-400 uppercase tracking-wide mb-1", children: "\u9519\u8BEF" }),
14482
- /* @__PURE__ */ jsx("div", { className: "text-[11px] text-red-300 bg-red-500/10 rounded p-2 overflow-x-auto", children: toolCall.error })
14483
- ] })
14484
- ] })
14485
- ] });
14486
- });
14487
- var ThinkingBubble = memo(function ThinkingBubble2({
14488
- thoughts,
14489
- pendingToolCalls = [],
14490
- config
14491
- }) {
14492
- const [expanded, setExpanded] = useState(true);
14493
- const { content: thinkingContent, toolCalls: thoughtToolCalls, isThinking } = useMemo(
14494
- () => parseThoughts(thoughts),
14495
- [thoughts]
14496
- );
14497
- const toolCalls = useMemo(() => {
14498
- const toolCallMap = /* @__PURE__ */ new Map();
14499
- thoughtToolCalls.forEach((tc) => {
14500
- toolCallMap.set(tc.id, tc);
14501
- });
14502
- console.log("[UI] \u{1F3A8} thoughtToolCalls:", thoughtToolCalls.map((tc) => ({ id: tc.id, status: tc.status })));
14503
- console.log("[UI] \u{1F3A8} pendingToolCalls:", pendingToolCalls.map((tc) => ({ id: tc.id, status: tc.status })));
14504
- pendingToolCalls.forEach((tc) => {
14505
- const existing = toolCallMap.get(tc.id);
14506
- if (existing) {
14507
- const existingPriority = getToolCallStatusPriority(existing.status);
14508
- const tcPriority = getToolCallStatusPriority(tc.status);
14509
- console.log(`[UI] \u{1F3A8} \u5408\u5E76 id=${tc.id}: existing.status=${existing.status}(${existingPriority}), pending.status=${tc.status}(${tcPriority})`);
14510
- if (tcPriority >= existingPriority) {
14511
- toolCallMap.set(tc.id, { ...existing, ...tc });
14512
- } else {
14513
- toolCallMap.set(tc.id, { ...tc, ...existing });
14514
- }
14515
- } else {
14516
- toolCallMap.set(tc.id, tc);
14517
- }
14518
- });
14519
- const result = Array.from(toolCallMap.values());
14520
- console.log("[UI] \u{1F3A8} \u6700\u7EC8 toolCalls:", result.map((tc) => ({ id: tc.id, status: tc.status })));
14521
- return result;
14522
- }, [thoughtToolCalls, pendingToolCalls]);
14523
- return /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
14524
- /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg bg-[#d8ff00] flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx(Bot, { size: 16, className: "text-black" }) }),
14525
- /* @__PURE__ */ jsx("div", { className: "flex flex-col items-start max-w-[75%] min-w-0", children: /* @__PURE__ */ jsxs("div", { className: "bg-zinc-800/80 text-zinc-100 rounded-2xl rounded-tl-sm overflow-hidden w-full", children: [
14526
- /* @__PURE__ */ jsxs("button", { onClick: () => setExpanded(!expanded), className: "w-full flex items-center justify-between px-4 py-3 hover:bg-zinc-700/30 transition-colors", children: [
14527
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
14528
- /* @__PURE__ */ jsx(Loader2, { size: 16, className: "text-[#d8ff00] animate-spin" }),
14529
- /* @__PURE__ */ jsx("span", { className: "text-sm text-zinc-200", children: "\u6B63\u5728\u601D\u8003..." }),
14530
- toolCalls.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-xs text-zinc-500", children: [
14531
- toolCalls.length,
14532
- " \u6B21\u5DE5\u5177\u8C03\u7528"
14533
- ] })
14534
- ] }),
14535
- expanded ? /* @__PURE__ */ jsx(ChevronUp, { size: 14, className: "text-zinc-500" }) : /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: "text-zinc-500" })
14536
- ] }),
14537
- expanded && /* @__PURE__ */ jsxs("div", { className: "px-4 pb-4 space-y-3 border-t border-zinc-700/50 overflow-hidden", children: [
14538
- thinkingContent ? /* @__PURE__ */ jsxs("div", { className: "text-sm text-zinc-400 leading-relaxed pt-3 prose prose-invert prose-sm max-w-none [&_*]:break-words", children: [
14539
- /* @__PURE__ */ jsx(MarkdownContent3, { content: thinkingContent, config }),
14540
- isThinking && /* @__PURE__ */ jsx("span", { className: "inline-block w-0.5 h-4 bg-[#d8ff00] animate-pulse ml-1 align-middle" })
14541
- ] }) : isThinking && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-zinc-500 pt-3", children: [
14542
- /* @__PURE__ */ jsxs("span", { className: "flex gap-1", children: [
14543
- /* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-[#d8ff00] rounded-full animate-bounce", style: { animationDelay: "0ms" } }),
14544
- /* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-[#d8ff00] rounded-full animate-bounce", style: { animationDelay: "150ms" } }),
14545
- /* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-[#d8ff00] rounded-full animate-bounce", style: { animationDelay: "300ms" } })
14546
- ] }),
14547
- /* @__PURE__ */ jsx("span", { children: "\u6B63\u5728\u5206\u6790..." })
14548
- ] }),
14549
- toolCalls.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-2 pt-2", children: toolCalls.map((tc) => /* @__PURE__ */ jsx(ToolCallCard5, { toolCall: tc }, tc.id)) })
14550
- ] })
14551
- ] }) })
14552
- ] });
14286
+ return /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-center h-full", children: /* @__PURE__ */ jsx("div", { className: "text-center", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-[#d8ff00]" }) }) });
14553
14287
  });
14554
14288
  function ChatWindow({
14555
14289
  sessionId,
@@ -14775,7 +14509,6 @@ function ChatWindow({
14775
14509
  message.messageId
14776
14510
  );
14777
14511
  }),
14778
- isThinking && isCurrentSessionStreaming && !streamingMessage && (sessionCurrentThoughts.length > 0 || sessionPendingToolCalls.length > 0) && /* @__PURE__ */ jsx(ThinkingBubble, { thoughts: sessionCurrentThoughts, pendingToolCalls: sessionPendingToolCalls, config }),
14779
14512
  isThinking && isCurrentSessionStreaming && !streamingMessage && sessionCurrentThoughts.length === 0 && sessionPendingToolCalls.length === 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
14780
14513
  /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg bg-[#d8ff00] flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx(Bot, { size: 16, className: "text-black" }) }),
14781
14514
  /* @__PURE__ */ jsx("div", { className: "bg-zinc-800/80 rounded-2xl rounded-tl-sm px-4 py-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-zinc-400 text-sm", children: [
@@ -15052,7 +14785,7 @@ function CompactThinking({ thoughts }) {
15052
14785
  toolCalls.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-1.5 pt-1", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx(ToolCallCardCompact, { toolCall: tc, isStreaming: isThinking }, tc.id || i)) })
15053
14786
  ] });
15054
14787
  }
15055
- function ToolCallCard7({ toolCall }) {
14788
+ function ToolCallCard5({ toolCall }) {
15056
14789
  const [showDetails, setShowDetails] = useState(false);
15057
14790
  const isPending = !toolCall.result && toolCall.status !== "completed";
15058
14791
  toolCall.status === "completed" || toolCall.result;
@@ -15119,7 +14852,7 @@ function FullThinking({ thoughts }) {
15119
14852
  " \u6B21"
15120
14853
  ] })
15121
14854
  ] }),
15122
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx(ToolCallCard7, { toolCall: tc }, tc.id || i)) })
14855
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx(ToolCallCard5, { toolCall: tc }, tc.id || i)) })
15123
14856
  ] }),
15124
14857
  errorThought && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 p-3 bg-red-500/10 border border-red-500/20 rounded-lg", children: [
15125
14858
  /* @__PURE__ */ jsx(AlertCircle, { size: 16, className: "text-red-400 mt-0.5 flex-shrink-0" }),
@@ -15329,7 +15062,7 @@ function ToolConfirmDialog({ toolCall }) {
15329
15062
  }
15330
15063
  var Dialog = DialogPrimitive.Root;
15331
15064
  var DialogPortal = DialogPrimitive.Portal;
15332
- var DialogOverlay = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15065
+ var DialogOverlay = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15333
15066
  DialogPrimitive.Overlay,
15334
15067
  {
15335
15068
  ref,
@@ -15341,7 +15074,7 @@ var DialogOverlay = React21.forwardRef(({ className, ...props }, ref) => /* @__P
15341
15074
  }
15342
15075
  ));
15343
15076
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
15344
- var DialogContent = React21.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
15077
+ var DialogContent = React20.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
15345
15078
  /* @__PURE__ */ jsx(DialogOverlay, {}),
15346
15079
  /* @__PURE__ */ jsxs(
15347
15080
  DialogPrimitive.Content,
@@ -15391,7 +15124,7 @@ var DialogFooter = ({
15391
15124
  }
15392
15125
  );
15393
15126
  DialogFooter.displayName = "DialogFooter";
15394
- var DialogTitle = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15127
+ var DialogTitle = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15395
15128
  DialogPrimitive.Title,
15396
15129
  {
15397
15130
  ref,
@@ -15403,7 +15136,7 @@ var DialogTitle = React21.forwardRef(({ className, ...props }, ref) => /* @__PUR
15403
15136
  }
15404
15137
  ));
15405
15138
  DialogTitle.displayName = DialogPrimitive.Title.displayName;
15406
- var DialogDescription = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15139
+ var DialogDescription = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15407
15140
  DialogPrimitive.Description,
15408
15141
  {
15409
15142
  ref,
@@ -15479,7 +15212,7 @@ var buttonVariants = cva(
15479
15212
  }
15480
15213
  }
15481
15214
  );
15482
- var Button = React21.forwardRef(
15215
+ var Button = React20.forwardRef(
15483
15216
  ({ className, variant, size, asChild = false, ...props }, ref) => {
15484
15217
  const Comp = asChild ? Slot : "button";
15485
15218
  return /* @__PURE__ */ jsx(
@@ -15496,7 +15229,7 @@ Button.displayName = "Button";
15496
15229
  var Badge = ({ children, className }) => {
15497
15230
  return /* @__PURE__ */ jsx("div", { className: cn("inline-flex items-center rounded-md bg-muted px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", className), children });
15498
15231
  };
15499
- var Card = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15232
+ var Card = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15500
15233
  "div",
15501
15234
  {
15502
15235
  ref,
@@ -15508,7 +15241,7 @@ var Card = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
15508
15241
  }
15509
15242
  ));
15510
15243
  Card.displayName = "Card";
15511
- var CardHeader = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15244
+ var CardHeader = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15512
15245
  "div",
15513
15246
  {
15514
15247
  ref,
@@ -15517,7 +15250,7 @@ var CardHeader = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE
15517
15250
  }
15518
15251
  ));
15519
15252
  CardHeader.displayName = "CardHeader";
15520
- var CardTitle = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15253
+ var CardTitle = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15521
15254
  "h3",
15522
15255
  {
15523
15256
  ref,
@@ -15529,7 +15262,7 @@ var CardTitle = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE_
15529
15262
  }
15530
15263
  ));
15531
15264
  CardTitle.displayName = "CardTitle";
15532
- var CardDescription = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15265
+ var CardDescription = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15533
15266
  "p",
15534
15267
  {
15535
15268
  ref,
@@ -15538,9 +15271,9 @@ var CardDescription = React21.forwardRef(({ className, ...props }, ref) => /* @_
15538
15271
  }
15539
15272
  ));
15540
15273
  CardDescription.displayName = "CardDescription";
15541
- var CardContent = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
15274
+ var CardContent = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
15542
15275
  CardContent.displayName = "CardContent";
15543
- var CardFooter = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15276
+ var CardFooter = React20.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
15544
15277
  "div",
15545
15278
  {
15546
15279
  ref,
@@ -15562,7 +15295,7 @@ var Separator = ({ className, orientation = "horizontal", decorative = true }) =
15562
15295
  }
15563
15296
  );
15564
15297
  };
15565
- var ScrollArea = React21.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
15298
+ var ScrollArea = React20.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
15566
15299
  ScrollAreaPrimitive.Root,
15567
15300
  {
15568
15301
  ref,
@@ -15576,7 +15309,7 @@ var ScrollArea = React21.forwardRef(({ className, children, ...props }, ref) =>
15576
15309
  }
15577
15310
  ));
15578
15311
  ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
15579
- var ScrollBar = React21.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
15312
+ var ScrollBar = React20.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
15580
15313
  ScrollAreaPrimitive.ScrollAreaScrollbar,
15581
15314
  {
15582
15315
  ref,
@@ -15870,7 +15603,7 @@ var PlanProgressPanel = ({
15870
15603
  ] });
15871
15604
  };
15872
15605
  var PlanProgressPanel_default = PlanProgressPanel;
15873
- var Textarea = React21.forwardRef(
15606
+ var Textarea = React20.forwardRef(
15874
15607
  ({ className, theme, ...props }, ref) => {
15875
15608
  const themeClass = theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-black";
15876
15609
  return /* @__PURE__ */ jsx(
@@ -16144,7 +15877,7 @@ var Observer = class {
16144
15877
  "resolve",
16145
15878
  response
16146
15879
  ];
16147
- const isReactElementResponse = React21__default.isValidElement(response);
15880
+ const isReactElementResponse = React20__default.isValidElement(response);
16148
15881
  if (isReactElementResponse) {
16149
15882
  shouldDismiss = false;
16150
15883
  this.create({
@@ -16156,7 +15889,7 @@ var Observer = class {
16156
15889
  shouldDismiss = false;
16157
15890
  const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
16158
15891
  const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
16159
- const isExtendedResult = typeof promiseData === "object" && !React21__default.isValidElement(promiseData);
15892
+ const isExtendedResult = typeof promiseData === "object" && !React20__default.isValidElement(promiseData);
16160
15893
  const toastSettings = isExtendedResult ? promiseData : {
16161
15894
  message: promiseData
16162
15895
  };
@@ -16170,7 +15903,7 @@ var Observer = class {
16170
15903
  shouldDismiss = false;
16171
15904
  const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
16172
15905
  const description = typeof data.description === "function" ? await data.description(response) : data.description;
16173
- const isExtendedResult = typeof promiseData === "object" && !React21__default.isValidElement(promiseData);
15906
+ const isExtendedResult = typeof promiseData === "object" && !React20__default.isValidElement(promiseData);
16174
15907
  const toastSettings = isExtendedResult ? promiseData : {
16175
15908
  message: promiseData
16176
15909
  };
@@ -16184,7 +15917,7 @@ var Observer = class {
16184
15917
  shouldDismiss = false;
16185
15918
  const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
16186
15919
  const description = typeof data.description === "function" ? await data.description(response) : data.description;
16187
- const isExtendedResult = typeof promiseData === "object" && !React21__default.isValidElement(promiseData);
15920
+ const isExtendedResult = typeof promiseData === "object" && !React20__default.isValidElement(promiseData);
16188
15921
  const toastSettings = isExtendedResult ? promiseData : {
16189
15922
  message: promiseData
16190
15923
  };
@@ -16204,7 +15937,7 @@ var Observer = class {
16204
15937
  shouldDismiss = false;
16205
15938
  const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
16206
15939
  const description = typeof data.description === "function" ? await data.description(error) : data.description;
16207
- const isExtendedResult = typeof promiseData === "object" && !React21__default.isValidElement(promiseData);
15940
+ const isExtendedResult = typeof promiseData === "object" && !React20__default.isValidElement(promiseData);
16208
15941
  const toastSettings = isExtendedResult ? promiseData : {
16209
15942
  message: promiseData
16210
15943
  };
@@ -17699,6 +17432,14 @@ var createWebSpeechProvider = (config) => {
17699
17432
  if (!checkBrowserSupport()) {
17700
17433
  throw new Error("Browser does not support speech recognition");
17701
17434
  }
17435
+ if (typeof window !== "undefined" && !window.isSecureContext && location.protocol !== "https:") {
17436
+ handleError({
17437
+ code: "INSECURE_CONTEXT",
17438
+ message: "\u8BED\u97F3\u8BC6\u522B\u9700\u8981 HTTPS \u6216 localhost \u73AF\u5883",
17439
+ type: "permission"
17440
+ });
17441
+ return;
17442
+ }
17702
17443
  setStatus("requesting");
17703
17444
  try {
17704
17445
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
@@ -17714,6 +17455,7 @@ var createWebSpeechProvider = (config) => {
17714
17455
  }
17715
17456
  const SpeechRecognition = getSpeechRecognition();
17716
17457
  recognition = new SpeechRecognition();
17458
+ let hasResult = false;
17717
17459
  recognition.lang = language;
17718
17460
  recognition.continuous = continuous;
17719
17461
  recognition.interimResults = interimResults;
@@ -17743,6 +17485,8 @@ var createWebSpeechProvider = (config) => {
17743
17485
  const fullText = accumulatedFinalText + interimTranscript;
17744
17486
  const hasNewFinal = !!newFinalTranscript;
17745
17487
  const confidence = event.results[event.results.length - 1]?.[0]?.confidence || 0;
17488
+ hasResult = true;
17489
+ setStatus("recognizing");
17746
17490
  resultCallback?.({
17747
17491
  text: fullText,
17748
17492
  isFinal: hasNewFinal && !interimTranscript,
@@ -17802,6 +17546,15 @@ var createWebSpeechProvider = (config) => {
17802
17546
  };
17803
17547
  recognition.onend = () => {
17804
17548
  clearTimers();
17549
+ if (!hasResult) {
17550
+ errorCallback?.({
17551
+ code: "NO_SPEECH",
17552
+ message: "\u672A\u68C0\u6D4B\u5230\u6709\u6548\u8BED\u97F3\uFF0C\u8BF7\u91CD\u8BD5",
17553
+ type: "unknown"
17554
+ });
17555
+ setStatus("error");
17556
+ return;
17557
+ }
17805
17558
  setStatus("completed");
17806
17559
  };
17807
17560
  recognition.start();
@@ -18717,7 +18470,7 @@ var ToolbarButton = memo(function ToolbarButton2({
18717
18470
  }
18718
18471
  );
18719
18472
  });
18720
- var CodeBlock5 = memo(function CodeBlock6({
18473
+ var CodeBlock3 = memo(function CodeBlock4({
18721
18474
  code: code3,
18722
18475
  language,
18723
18476
  showLineNumbers = true
@@ -19003,7 +18756,7 @@ memo(function JsonPreview2({ content }) {
19003
18756
  /* @__PURE__ */ jsx("pre", { className: "mt-2 text-xs text-zinc-500 agent-sdk-light:text-zinc-600 whitespace-pre-wrap", children: content })
19004
18757
  ] }) }) });
19005
18758
  }
19006
- return /* @__PURE__ */ jsx(CodeBlock5, { code: formattedJson, language: "json" });
18759
+ return /* @__PURE__ */ jsx(CodeBlock3, { code: formattedJson, language: "json" });
19007
18760
  });
19008
18761
  var artifactTypeConfig = {
19009
18762
  html: {
@@ -19063,7 +18816,7 @@ var ArtifactViewer = memo(function ArtifactViewer2({
19063
18816
  const renderContent = () => {
19064
18817
  if (viewMode === "code" || !canPreview) {
19065
18818
  return /* @__PURE__ */ jsx(
19066
- CodeBlock5,
18819
+ CodeBlock3,
19067
18820
  {
19068
18821
  code: artifact.content,
19069
18822
  language: artifact.language || artifact.type
@@ -19077,7 +18830,7 @@ var ArtifactViewer = memo(function ArtifactViewer2({
19077
18830
  return /* @__PURE__ */ jsx(MarkdownPreview, { content: artifact.content, config });
19078
18831
  default:
19079
18832
  return /* @__PURE__ */ jsx(
19080
- CodeBlock5,
18833
+ CodeBlock3,
19081
18834
  {
19082
18835
  code: artifact.content,
19083
18836
  language: artifact.language || artifact.type
@@ -19198,7 +18951,7 @@ function InformationSupplement({
19198
18951
  referenceImage,
19199
18952
  qrCode
19200
18953
  }) {
19201
- const [open, setOpen] = React21__default.useState(!confirmed);
18954
+ const [open, setOpen] = React20__default.useState(!confirmed);
19202
18955
  const resolvedMain = main_image || mainImage;
19203
18956
  const resolvedRef = reference_image || referenceImage;
19204
18957
  const resolvedQr = qrcode || qrCode;
@@ -19430,7 +19183,7 @@ function Sidebar({
19430
19183
  ] });
19431
19184
  }
19432
19185
  function WelcomePage({ agentName, welcomeMessage, tools, onNew, onPrompt }) {
19433
- const quickPrompts = React21__default.useMemo(() => {
19186
+ const quickPrompts = React20__default.useMemo(() => {
19434
19187
  const prompts = [];
19435
19188
  const hasImageTool = tools?.some(
19436
19189
  (t) => t.name?.toLowerCase().includes("image") || t.name?.toLowerCase().includes("\u56FE\u7247") || t.type === "COMFY_APP"
@@ -19717,7 +19470,7 @@ function ChatInputArea({
19717
19470
  ] })
19718
19471
  ] }) });
19719
19472
  }
19720
- var DragHandle = React21__default.memo(function DragHandle2({
19473
+ var DragHandle = React20__default.memo(function DragHandle2({
19721
19474
  artifactPanelWidth,
19722
19475
  isDragging,
19723
19476
  onMouseDown
@@ -19757,7 +19510,7 @@ var DragHandle = React21__default.memo(function DragHandle2({
19757
19510
  }
19758
19511
  );
19759
19512
  });
19760
- var AgentChat = React21__default.forwardRef(({
19513
+ var AgentChat = React20__default.forwardRef(({
19761
19514
  agentId,
19762
19515
  projectId,
19763
19516
  agentName,
@@ -19785,7 +19538,7 @@ var AgentChat = React21__default.forwardRef(({
19785
19538
  const showSidebar = !embedded && !hideSidebar;
19786
19539
  const showHeader = !embedded && !hideHeader;
19787
19540
  const outerComponents = useComponents();
19788
- const mergedComponents = React21__default.useMemo(() => {
19541
+ const mergedComponents = React20__default.useMemo(() => {
19789
19542
  const configComponents = config?.components || {};
19790
19543
  const mergedRegistry = {
19791
19544
  InformationSupplement,
@@ -20267,7 +20020,7 @@ var AgentChat = React21__default.forwardRef(({
20267
20020
  }
20268
20021
  }, [handleAbortMessage, abort]);
20269
20022
  if (loading) {
20270
- return /* @__PURE__ */ jsx("div", { className: `agent-sdk-theme h-screen flex items-center justify-center bg-black ${themeClass} ${className || ""}`, children: /* @__PURE__ */ jsx(Loader2, { className: "w-6 h-6 text-[#d8ff00] animate-spin" }) });
20023
+ return /* @__PURE__ */ jsx("div", { className: `agent-sdk-theme h-screen flex items-center justify-center bg-black ${themeClass} ${className || ""}`, children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-[#d8ff00]" }) });
20271
20024
  }
20272
20025
  return /* @__PURE__ */ jsx(ComponentProvider, { components: mergedComponents, children: /* @__PURE__ */ jsxs(
20273
20026
  "div",