@nexface/chat 0.1.14 → 0.1.15-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.
Files changed (129) hide show
  1. package/dist/assistant-attachments.js +17 -60
  2. package/dist/assistant-attachments.js.map +1 -0
  3. package/dist/assistant-components.d.ts +3 -3
  4. package/dist/assistant-components.js +29 -77
  5. package/dist/assistant-components.js.map +1 -0
  6. package/dist/assistant-runtime.d.ts +1 -1
  7. package/dist/assistant-runtime.js +43 -100
  8. package/dist/assistant-runtime.js.map +1 -0
  9. package/dist/attachments.js +15 -36
  10. package/dist/attachments.js.map +1 -0
  11. package/dist/client.js +73 -312
  12. package/dist/client.js.map +1 -0
  13. package/dist/config.d.ts +1 -1
  14. package/dist/config.js +5 -4
  15. package/dist/config.js.map +1 -0
  16. package/dist/default-chat.d.ts +1 -1
  17. package/dist/default-chat.js +728 -2102
  18. package/dist/default-chat.js.map +7 -0
  19. package/dist/errors.js +18 -55
  20. package/dist/errors.js.map +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/messages.js +1 -0
  24. package/dist/messages.js.map +1 -0
  25. package/dist/page-confirmation.js +4 -3
  26. package/dist/page-confirmation.js.map +1 -0
  27. package/dist/protocol-messages.js +66 -290
  28. package/dist/protocol-messages.js.map +1 -0
  29. package/dist/protocol-response.js +18 -38
  30. package/dist/protocol-response.js.map +1 -0
  31. package/dist/react.js +50 -146
  32. package/dist/react.js.map +1 -0
  33. package/dist/shared/errors.d.ts +1 -1
  34. package/dist/shared/errors.js +1 -0
  35. package/dist/shared/errors.js.map +1 -0
  36. package/dist/shared/runtime-controller.d.ts +0 -1
  37. package/dist/shared/runtime-controller.js +1 -0
  38. package/dist/shared/runtime-controller.js.map +1 -0
  39. package/dist/shared/runtime-execution.js +1 -0
  40. package/dist/shared/runtime-execution.js.map +1 -0
  41. package/dist/shared/schema.js +19 -45
  42. package/dist/shared/schema.js.map +1 -0
  43. package/dist/storage.js +53 -130
  44. package/dist/storage.js.map +1 -0
  45. package/dist/styles.css +20 -99
  46. package/dist/tool-result.js +3 -7
  47. package/dist/tool-result.js.map +1 -0
  48. package/dist/types.js +1 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/ui/attachment.aui.d.ts +1 -1
  51. package/dist/ui/attachment.aui.js +20 -16
  52. package/dist/ui/attachment.aui.js.map +1 -0
  53. package/dist/ui/avatar.js +1 -0
  54. package/dist/ui/avatar.js.map +1 -0
  55. package/dist/ui/button.js +1 -0
  56. package/dist/ui/button.js.map +1 -0
  57. package/dist/ui/code-block.js +3 -2
  58. package/dist/ui/code-block.js.map +1 -0
  59. package/dist/ui/collapsible.js +3 -2
  60. package/dist/ui/collapsible.js.map +1 -0
  61. package/dist/ui/composer-voice.js +2 -3
  62. package/dist/ui/composer-voice.js.map +1 -0
  63. package/dist/ui/dialog.d.ts +1 -1
  64. package/dist/ui/dialog.js +4 -9
  65. package/dist/ui/dialog.js.map +1 -0
  66. package/dist/ui/dropdown-menu.js +3 -2
  67. package/dist/ui/dropdown-menu.js.map +1 -0
  68. package/dist/ui/home-demo/action-bar.js +1 -0
  69. package/dist/ui/home-demo/action-bar.js.map +1 -0
  70. package/dist/ui/home-demo/composer.js +4 -7
  71. package/dist/ui/home-demo/composer.js.map +1 -0
  72. package/dist/ui/home-demo/greeting.d.ts +1 -1
  73. package/dist/ui/home-demo/greeting.js +2 -1
  74. package/dist/ui/home-demo/greeting.js.map +1 -0
  75. package/dist/ui/home-demo/messages.d.ts +1 -1
  76. package/dist/ui/home-demo/messages.js +5 -4
  77. package/dist/ui/home-demo/messages.js.map +1 -0
  78. package/dist/ui/home-demo/styles.js +1 -0
  79. package/dist/ui/home-demo/styles.js.map +1 -0
  80. package/dist/ui/home-demo/suggestions.d.ts +1 -1
  81. package/dist/ui/home-demo/suggestions.js +3 -5
  82. package/dist/ui/home-demo/suggestions.js.map +1 -0
  83. package/dist/ui/home-demo/surfaces.js +2 -3
  84. package/dist/ui/home-demo/surfaces.js.map +1 -0
  85. package/dist/ui/home-demo/thread.d.ts +1 -1
  86. package/dist/ui/home-demo/thread.js +2 -1
  87. package/dist/ui/home-demo/thread.js.map +1 -0
  88. package/dist/ui/home-demo/trace-line.d.ts +1 -1
  89. package/dist/ui/home-demo/trace-line.js +3 -2
  90. package/dist/ui/home-demo/trace-line.js.map +1 -0
  91. package/dist/ui/home-demo/trace.d.ts +1 -1
  92. package/dist/ui/home-demo/trace.js +9 -28
  93. package/dist/ui/home-demo/trace.js.map +1 -0
  94. package/dist/ui/home-demo/type.js +1 -0
  95. package/dist/ui/home-demo/type.js.map +1 -0
  96. package/dist/ui/input.js +1 -0
  97. package/dist/ui/input.js.map +1 -0
  98. package/dist/ui/markdown-text.js +3 -2
  99. package/dist/ui/markdown-text.js.map +1 -0
  100. package/dist/ui/reasoning.aui.js +3 -2
  101. package/dist/ui/reasoning.aui.js.map +1 -0
  102. package/dist/ui/reasoning.d.ts +1 -1
  103. package/dist/ui/reasoning.js +9 -6
  104. package/dist/ui/reasoning.js.map +1 -0
  105. package/dist/ui/surface.js +8 -27
  106. package/dist/ui/surface.js.map +1 -0
  107. package/dist/ui/thread-list.aui.d.ts +2 -2
  108. package/dist/ui/thread-list.aui.js +12 -18
  109. package/dist/ui/thread-list.aui.js.map +1 -0
  110. package/dist/ui/tool-group.aui.js +3 -2
  111. package/dist/ui/tool-group.aui.js.map +1 -0
  112. package/dist/ui/tooltip-icon-button.js +2 -1
  113. package/dist/ui/tooltip-icon-button.js.map +1 -0
  114. package/dist/ui/tooltip.js +1 -0
  115. package/dist/ui/tooltip.js.map +1 -0
  116. package/dist/ui/use-attachment-src.js +2 -1
  117. package/dist/ui/use-attachment-src.js.map +1 -0
  118. package/dist/ui/use-copy-to-clipboard.d.ts +1 -1
  119. package/dist/ui/use-copy-to-clipboard.js +2 -1
  120. package/dist/ui/use-copy-to-clipboard.js.map +1 -0
  121. package/dist/ui/utils.js +3 -9
  122. package/dist/ui/utils.js.map +1 -0
  123. package/dist/use-next-message.js +4 -7
  124. package/dist/use-next-message.js.map +1 -0
  125. package/dist/voice/types.js +1 -0
  126. package/dist/voice/types.js.map +1 -0
  127. package/dist/voice/use-voice.js +13 -35
  128. package/dist/voice/use-voice.js.map +1 -0
  129. package/package.json +4 -8
@@ -698,9 +698,7 @@ var useSyncExternalStore = modern.useSyncExternalStore ?? subscribe;
698
698
  var useInsertionEffect = modern.useInsertionEffect ?? React.useLayoutEffect;
699
699
  var useDeferredValue = modern.useDeferredValue ?? ((value) => value);
700
700
  var useId = modern.useId ?? (() => {
701
- const [id] = React.useState(
702
- () => `nxf-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`
703
- );
701
+ const [id] = React.useState(() => `nxf-${globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`}`);
704
702
  return id;
705
703
  });
706
704
  var react_compat_default = { ...React, useSyncExternalStore, useInsertionEffect, useDeferredValue, useId };
@@ -28578,23 +28576,21 @@ function cn(...inputs) {
28578
28576
 
28579
28577
  // src/ui/input.tsx
28580
28578
  import { jsx as jsx63 } from "react/jsx-runtime";
28581
- var Input = React2.forwardRef(
28582
- function Input2({ className, type, ...props }, ref) {
28583
- return /* @__PURE__ */ jsx63(
28584
- "input",
28585
- {
28586
- ref,
28587
- type,
28588
- "data-slot": "input",
28589
- className: cn(
28590
- "file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 bg-muted/60 focus-visible:bg-background h-9 w-full min-w-0 rounded-lg border border-transparent px-3 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-sm",
28591
- className
28592
- ),
28593
- ...props
28594
- }
28595
- );
28596
- }
28597
- );
28579
+ var Input = React2.forwardRef(function Input2({ className, type, ...props }, ref) {
28580
+ return /* @__PURE__ */ jsx63(
28581
+ "input",
28582
+ {
28583
+ ref,
28584
+ type,
28585
+ "data-slot": "input",
28586
+ className: cn(
28587
+ "file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 bg-muted/60 focus-visible:bg-background h-9 w-full min-w-0 rounded-lg border border-transparent px-3 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-sm",
28588
+ className
28589
+ ),
28590
+ ...props
28591
+ }
28592
+ );
28593
+ });
28598
28594
 
28599
28595
  // src/ui/home-demo/styles.ts
28600
28596
  var actionButtonClass = "text-muted-foreground/70 hover:text-foreground disabled:pointer-events-none disabled:opacity-40 p-1 transition-colors";
@@ -28602,26 +28598,11 @@ var menuContentClass = "bg-popover text-popover-foreground border-foreground/10
28602
28598
  var menuItemClass = "hover:bg-muted focus:bg-muted flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-[13px] outline-none select-none";
28603
28599
 
28604
28600
  // src/ui/surface.tsx
28605
- import {
28606
- createContext as createContext5,
28607
- useContext as useContext6,
28608
- useLayoutEffect as useLayoutEffect8,
28609
- useRef as useRef25,
28610
- useState as useState24
28611
- } from "react";
28601
+ import { createContext as createContext5, useContext as useContext6, useLayoutEffect as useLayoutEffect8, useRef as useRef25, useState as useState24 } from "react";
28612
28602
  import { jsx as jsx64, jsxs as jsxs8 } from "react/jsx-runtime";
28613
28603
  var PortalContext = createContext5({ container: null, acquire: () => () => {
28614
28604
  } });
28615
- var tokens = [
28616
- "background",
28617
- "foreground",
28618
- "primary",
28619
- "primary-foreground",
28620
- "primary-hover",
28621
- "muted",
28622
- "muted-foreground",
28623
- "border"
28624
- ];
28605
+ var tokens = ["background", "foreground", "primary", "primary-foreground", "primary-hover", "muted", "muted-foreground", "border"];
28625
28606
  var DialogContainerContext = createContext5(null);
28626
28607
  function ChatSurface({ children, className, ...props }) {
28627
28608
  const root4 = useRef25(null);
@@ -28644,7 +28625,8 @@ function ChatSurface({ children, className, ...props }) {
28644
28625
  }, []);
28645
28626
  useLayoutEffect8(() => {
28646
28627
  const element2 = root4.current;
28647
- if (!element2 || !container) return;
28628
+ if (!element2 || !container)
28629
+ return;
28648
28630
  const sync = () => {
28649
28631
  const style = getComputedStyle(element2);
28650
28632
  for (const token of tokens)
@@ -28655,13 +28637,11 @@ function ChatSurface({ children, className, ...props }) {
28655
28637
  container.classList.toggle("nexface-dark", Boolean(element2.closest(".dark, .nexface-dark")));
28656
28638
  };
28657
28639
  sync();
28658
- if (!active) return;
28640
+ if (!active)
28641
+ return;
28659
28642
  const observer = new MutationObserver(sync);
28660
28643
  for (let node2 = element2; node2; node2 = node2.parentElement)
28661
- observer.observe(node2, {
28662
- attributes: true,
28663
- attributeFilter: ["class", "style", "dir", "data-theme"]
28664
- });
28644
+ observer.observe(node2, { attributes: true, attributeFilter: ["class", "style", "dir", "data-theme"] });
28665
28645
  const media = window.matchMedia?.("(prefers-color-scheme: dark)");
28666
28646
  media?.addEventListener("change", sync);
28667
28647
  return () => {
@@ -28695,113 +28675,37 @@ function DropdownMenu2({ ...props }) {
28695
28675
  var DropdownMenuTrigger3 = React3.forwardRef(function DropdownMenuTrigger4({ ...props }, ref) {
28696
28676
  return /* @__PURE__ */ jsx65(dist_exports10.Trigger, { "data-slot": "dropdown-menu-trigger", ref, ...props });
28697
28677
  });
28698
- function DropdownMenuContent3({
28699
- children,
28700
- className,
28701
- sideOffset = 4,
28702
- ...props
28703
- }) {
28678
+ function DropdownMenuContent3({ children, className, sideOffset = 4, ...props }) {
28704
28679
  const container = usePortalContainer();
28705
- if (!container) return null;
28706
- return /* @__PURE__ */ jsx65(dist_exports10.Portal, { container, children: /* @__PURE__ */ jsxs9(
28707
- dist_exports10.Content,
28708
- {
28709
- "data-slot": "dropdown-menu-content",
28710
- sideOffset,
28711
- className: cn(menuContentClass, className),
28712
- ...props,
28713
- children: [
28714
- /* @__PURE__ */ jsx65(PortalThemeSync, {}),
28715
- children
28716
- ]
28717
- }
28718
- ) });
28680
+ if (!container)
28681
+ return null;
28682
+ return /* @__PURE__ */ jsx65(dist_exports10.Portal, { container, children: /* @__PURE__ */ jsxs9(dist_exports10.Content, { "data-slot": "dropdown-menu-content", sideOffset, className: cn(menuContentClass, className), ...props, children: [
28683
+ /* @__PURE__ */ jsx65(PortalThemeSync, {}),
28684
+ children
28685
+ ] }) });
28719
28686
  }
28720
- function DropdownMenuItem3({
28721
- className,
28722
- inset,
28723
- variant = "default",
28724
- ...props
28725
- }) {
28726
- return /* @__PURE__ */ jsx65(
28727
- dist_exports10.Item,
28728
- {
28729
- "data-slot": "dropdown-menu-item",
28730
- "data-inset": inset,
28731
- "data-variant": variant,
28732
- className: cn(
28733
- menuItemClass,
28734
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[variant=destructive]:text-destructive",
28735
- className
28736
- ),
28737
- ...props
28738
- }
28739
- );
28687
+ function DropdownMenuItem3({ className, inset, variant = "default", ...props }) {
28688
+ return /* @__PURE__ */ jsx65(dist_exports10.Item, { "data-slot": "dropdown-menu-item", "data-inset": inset, "data-variant": variant, className: cn(menuItemClass, "data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[variant=destructive]:text-destructive", className), ...props });
28740
28689
  }
28741
28690
 
28742
28691
  // src/ui/thread-list.aui.tsx
28743
28692
  import { jsx as jsx66, jsxs as jsxs10 } from "react/jsx-runtime";
28744
- function ThreadListRoot({
28745
- className,
28746
- ...props
28747
- }) {
28748
- return /* @__PURE__ */ jsx66(
28749
- ThreadListPrimitiveRoot,
28750
- {
28751
- "data-slot": "aui_thread-list-root",
28752
- className: cn("flex flex-col gap-0.5", className),
28753
- ...props
28754
- }
28755
- );
28693
+ function ThreadListRoot({ className, ...props }) {
28694
+ return /* @__PURE__ */ jsx66(ThreadListPrimitiveRoot, { "data-slot": "aui_thread-list-root", className: cn("flex flex-col gap-0.5", className), ...props });
28756
28695
  }
28757
28696
  function ThreadListNew(props) {
28758
- return /* @__PURE__ */ jsx66(ThreadListPrimitiveNew, { asChild: true, children: /* @__PURE__ */ jsxs10(
28759
- "button",
28760
- {
28761
- type: "button",
28762
- "data-slot": "aui_thread-list-new",
28763
- className: cn(
28764
- "border-foreground/10 bg-background hover:border-foreground/25 rounded-control flex h-8 w-full shrink-0 items-center gap-2 border px-2.5 text-[13px] transition-colors"
28765
- ),
28766
- ...props,
28767
- children: [
28768
- /* @__PURE__ */ jsx66(Plus, { className: cn("size-4 shrink-0") }),
28769
- "\u65B0\u5EFA\u4F1A\u8BDD"
28770
- ]
28771
- }
28772
- ) });
28697
+ return /* @__PURE__ */ jsx66(ThreadListPrimitiveNew, { asChild: true, children: /* @__PURE__ */ jsxs10("button", { type: "button", "data-slot": "aui_thread-list-new", className: cn("border-foreground/10 bg-background hover:border-foreground/25 rounded-control flex h-8 w-full shrink-0 items-center gap-2 border px-2.5 text-[13px] transition-colors"), ...props, children: [
28698
+ /* @__PURE__ */ jsx66(Plus, { className: cn("size-4 shrink-0") }),
28699
+ "\u65B0\u5EFA\u4F1A\u8BDD"
28700
+ ] }) });
28773
28701
  }
28774
- function ThreadListSearch({
28775
- value,
28776
- onValueChange
28777
- }) {
28702
+ function ThreadListSearch({ value, onValueChange }) {
28778
28703
  return /* @__PURE__ */ jsxs10("div", { "data-slot": "aui_thread-list-search", className: cn("relative px-0.5 py-1"), children: [
28779
- /* @__PURE__ */ jsx66(
28780
- Search,
28781
- {
28782
- "data-slot": "aui_thread-list-search-icon",
28783
- className: cn(
28784
- "text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2"
28785
- )
28786
- }
28787
- ),
28788
- /* @__PURE__ */ jsx66(
28789
- Input,
28790
- {
28791
- type: "search",
28792
- value,
28793
- onChange: (event) => onValueChange(event.target.value),
28794
- "aria-label": "\u641C\u7D22\u4F1A\u8BDD",
28795
- placeholder: "\u641C\u7D22\u4F1A\u8BDD",
28796
- className: cn("border-foreground/10 bg-background h-8 ps-8 text-[13px] md:text-[13px]")
28797
- }
28798
- )
28704
+ /* @__PURE__ */ jsx66(Search, { "data-slot": "aui_thread-list-search-icon", className: cn("text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2") }),
28705
+ /* @__PURE__ */ jsx66(Input, { type: "search", value, onChange: (event) => onValueChange(event.target.value), "aria-label": "\u641C\u7D22\u4F1A\u8BDD", placeholder: "\u641C\u7D22\u4F1A\u8BDD", className: cn("border-foreground/10 bg-background h-8 ps-8 text-[13px] md:text-[13px]") })
28799
28706
  ] });
28800
28707
  }
28801
- function ThreadListItem({
28802
- disabled,
28803
- menu
28804
- }) {
28708
+ function ThreadListItem({ disabled, menu }) {
28805
28709
  const isRunning = useAuiState((s) => s.threadListItem.isRunning);
28806
28710
  const title = useAuiState((s) => s.threadListItem.title);
28807
28711
  const [isRenaming, setIsRenaming] = useState25(false);
@@ -28813,60 +28717,19 @@ function ThreadListItem({
28813
28717
  triggerRef.current?.focus();
28814
28718
  }
28815
28719
  }, [isRenaming]);
28816
- return /* @__PURE__ */ jsxs10(
28817
- ThreadListItemPrimitiveRoot,
28818
- {
28819
- "data-slot": "aui_thread-list-item",
28820
- className: cn(
28821
- "group data-active:bg-foreground/[0.06] hover:bg-foreground/[0.04] has-data-[state=open]:bg-foreground/[0.04] rounded-control relative flex h-8 shrink-0 items-center transition-colors"
28822
- ),
28823
- children: [
28824
- isRenaming ? /* @__PURE__ */ jsx66(
28825
- ThreadListItemRename,
28826
- {
28827
- onDone: (focus2) => {
28828
- restoreFocus.current = focus2;
28829
- setIsRenaming(false);
28830
- }
28831
- }
28832
- ) : /* @__PURE__ */ jsxs10(
28833
- ThreadListItemPrimitiveTrigger,
28834
- {
28835
- ref: triggerRef,
28836
- disabled,
28837
- "data-slot": "aui_thread-list-item-trigger",
28838
- className: cn(
28839
- "text-muted-foreground group-data-active:text-foreground hover:text-foreground flex h-full min-w-0 flex-1 items-center px-2 text-left text-[13px] transition-colors outline-none group-hover:pe-8 group-has-focus-visible:pe-8 group-has-data-[state=open]:pe-8 group-data-active:pe-8"
28840
- ),
28841
- children: [
28842
- isRunning && /* @__PURE__ */ jsx66(
28843
- LoaderCircle,
28844
- {
28845
- "aria-hidden": true,
28846
- className: cn("text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin")
28847
- }
28848
- ),
28849
- /* @__PURE__ */ jsx66("span", { className: cn("min-w-0 flex-1 truncate"), children: /* @__PURE__ */ jsx66(ThreadListItemPrimitiveTitle, { fallback: "\u65B0\u4F1A\u8BDD" }) })
28850
- ]
28851
- }
28852
- ),
28853
- /* @__PURE__ */ jsxs10(DropdownMenu2, { modal: false, children: [
28854
- /* @__PURE__ */ jsx66(DropdownMenuTrigger3, { asChild: true, children: /* @__PURE__ */ jsx66(
28855
- "button",
28856
- {
28857
- type: "button",
28858
- "aria-label": `\u7BA1\u7406 ${title}`,
28859
- className: cn(
28860
- "text-muted-foreground hover:text-foreground absolute end-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-sm opacity-0 transition-colors group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"
28861
- ),
28862
- children: /* @__PURE__ */ jsx66(Ellipsis, { className: cn("size-3.5") })
28863
- }
28864
- ) }),
28865
- /* @__PURE__ */ jsx66(DropdownMenuContent3, { side: "right", align: "start", sideOffset: 6, children: menu(() => setIsRenaming(true)) })
28866
- ] })
28867
- ]
28868
- }
28869
- );
28720
+ return /* @__PURE__ */ jsxs10(ThreadListItemPrimitiveRoot, { "data-slot": "aui_thread-list-item", className: cn("group data-active:bg-foreground/[0.06] hover:bg-foreground/[0.04] has-data-[state=open]:bg-foreground/[0.04] rounded-control relative flex h-8 shrink-0 items-center transition-colors"), children: [
28721
+ isRenaming ? /* @__PURE__ */ jsx66(ThreadListItemRename, { onDone: (focus2) => {
28722
+ restoreFocus.current = focus2;
28723
+ setIsRenaming(false);
28724
+ } }) : /* @__PURE__ */ jsxs10(ThreadListItemPrimitiveTrigger, { ref: triggerRef, disabled, "data-slot": "aui_thread-list-item-trigger", className: cn("text-muted-foreground group-data-active:text-foreground hover:text-foreground flex h-full min-w-0 flex-1 items-center px-2 text-left text-[13px] transition-colors outline-none group-hover:pe-8 group-has-focus-visible:pe-8 group-has-data-[state=open]:pe-8 group-data-active:pe-8"), children: [
28725
+ isRunning && /* @__PURE__ */ jsx66(LoaderCircle, { "aria-hidden": true, className: cn("text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin") }),
28726
+ /* @__PURE__ */ jsx66("span", { className: cn("min-w-0 flex-1 truncate"), children: /* @__PURE__ */ jsx66(ThreadListItemPrimitiveTitle, { fallback: "\u65B0\u4F1A\u8BDD" }) })
28727
+ ] }),
28728
+ /* @__PURE__ */ jsxs10(DropdownMenu2, { modal: false, children: [
28729
+ /* @__PURE__ */ jsx66(DropdownMenuTrigger3, { asChild: true, children: /* @__PURE__ */ jsx66("button", { type: "button", "aria-label": `\u7BA1\u7406 ${title}`, className: cn("text-muted-foreground hover:text-foreground absolute end-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-sm opacity-0 transition-colors group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"), children: /* @__PURE__ */ jsx66(Ellipsis, { className: cn("size-3.5") }) }) }),
28730
+ /* @__PURE__ */ jsx66(DropdownMenuContent3, { side: "right", align: "start", sideOffset: 6, children: menu(() => setIsRenaming(true)) })
28731
+ ] })
28732
+ ] });
28870
28733
  }
28871
28734
  function ThreadListItemRename({ onDone }) {
28872
28735
  const aui = useAui();
@@ -28885,13 +28748,10 @@ function ThreadListItemRename({ onDone }) {
28885
28748
  onDone(focus2);
28886
28749
  return;
28887
28750
  }
28888
- void Promise.resolve().then(() => aui.threadListItem.rename(next)).then(
28889
- () => onDone(focus2),
28890
- () => {
28891
- settled.current = false;
28892
- if (focus2) inputRef.current?.focus();
28893
- }
28894
- );
28751
+ void Promise.resolve().then(() => aui.threadListItem.rename(next)).then(() => onDone(focus2), () => {
28752
+ settled.current = false;
28753
+ if (focus2) inputRef.current?.focus();
28754
+ });
28895
28755
  };
28896
28756
  return /* @__PURE__ */ jsx66(
28897
28757
  Input,
@@ -28970,48 +28830,35 @@ var cva = (base, config) => (props) => {
28970
28830
 
28971
28831
  // src/ui/button.tsx
28972
28832
  import { jsx as jsx67 } from "react/jsx-runtime";
28973
- var buttonVariants = cva(
28974
- "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
28975
- {
28976
- variants: {
28977
- variant: {
28978
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
28979
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
28980
- outline: "border border-border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
28981
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
28982
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
28983
- link: "text-primary underline-offset-4 hover:underline"
28984
- },
28985
- size: {
28986
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
28987
- xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
28988
- sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
28989
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
28990
- icon: "size-9",
28991
- "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
28992
- "icon-sm": "size-8",
28993
- "icon-lg": "size-10"
28994
- }
28833
+ var buttonVariants = cva("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
28834
+ variants: {
28835
+ variant: {
28836
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
28837
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
28838
+ outline: "border border-border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
28839
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
28840
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
28841
+ link: "text-primary underline-offset-4 hover:underline"
28995
28842
  },
28996
- defaultVariants: {
28997
- variant: "default",
28998
- size: "default"
28843
+ size: {
28844
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
28845
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
28846
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
28847
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
28848
+ icon: "size-9",
28849
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
28850
+ "icon-sm": "size-8",
28851
+ "icon-lg": "size-10"
28999
28852
  }
28853
+ },
28854
+ defaultVariants: {
28855
+ variant: "default",
28856
+ size: "default"
29000
28857
  }
29001
- );
28858
+ });
29002
28859
  var Button = React4.forwardRef(function Button2({ className, variant = "default", size: size4 = "default", asChild = false, ...props }, ref) {
29003
28860
  const Comp = asChild ? dist_exports.Root : "button";
29004
- return /* @__PURE__ */ jsx67(
29005
- Comp,
29006
- {
29007
- ref,
29008
- "data-slot": "button",
29009
- "data-variant": variant,
29010
- "data-size": size4,
29011
- className: cn(buttonVariants({ variant, size: size4, className })),
29012
- ...props
29013
- }
29014
- );
28861
+ return /* @__PURE__ */ jsx67(Comp, { ref, "data-slot": "button", "data-variant": variant, "data-size": size4, className: cn(buttonVariants({ variant, size: size4, className })), ...props });
29015
28862
  });
29016
28863
 
29017
28864
  // src/ui/dialog.tsx
@@ -29024,15 +28871,14 @@ var DialogTrigger3 = React5.forwardRef(function DialogTrigger4({ ...props }, ref
29024
28871
  });
29025
28872
  function DialogPortal2({ ...props }) {
29026
28873
  const container = useDialogContainer();
29027
- if (!container) return null;
28874
+ if (!container)
28875
+ return null;
29028
28876
  return /* @__PURE__ */ jsx68(dist_exports8.Portal, { container, "data-slot": "dialog-portal", ...props });
29029
28877
  }
29030
28878
  function DialogBackgroundGuard() {
29031
28879
  const container = useDialogContainer();
29032
28880
  React5.useLayoutEffect(() => {
29033
- const siblings = Array.from(container?.parentElement?.children ?? []).filter(
29034
- (node2) => node2 instanceof HTMLElement && node2 !== container
29035
- );
28881
+ const siblings = Array.from(container?.parentElement?.children ?? []).filter((node2) => node2 instanceof HTMLElement && node2 !== container);
29036
28882
  const previous3 = siblings.map((node2) => node2.inert);
29037
28883
  siblings.forEach((node2) => {
29038
28884
  node2.inert = true;
@@ -29045,167 +28891,79 @@ function DialogBackgroundGuard() {
29045
28891
  }, [container]);
29046
28892
  return null;
29047
28893
  }
29048
- function DialogContent3({
29049
- className,
29050
- children,
29051
- showCloseButton = true,
29052
- onEscapeKeyDown,
29053
- ...props
29054
- }) {
28894
+ function DialogContent3({ className, children, showCloseButton = true, onEscapeKeyDown, ...props }) {
29055
28895
  const content3 = React5.useRef(null);
29056
- return /* @__PURE__ */ jsx68(DialogPortal2, { "data-slot": "dialog-portal", children: /* @__PURE__ */ jsxs11(
29057
- dist_exports8.Content,
29058
- {
29059
- ref: content3,
29060
- "data-slot": "dialog-content",
29061
- className: "nexface-chat__dialog-layer",
29062
- onInteractOutside: (event) => event.preventDefault(),
29063
- onEscapeKeyDown: (event) => {
29064
- if (!(event.target instanceof Node) || !content3.current?.contains(event.target)) {
29065
- event.preventDefault();
29066
- return;
29067
- }
29068
- onEscapeKeyDown?.(event);
29069
- },
29070
- ...props,
29071
- children: [
29072
- /* @__PURE__ */ jsx68(DialogBackgroundGuard, {}),
29073
- /* @__PURE__ */ jsxs11(
29074
- "div",
29075
- {
29076
- className: cn(
29077
- "relative grid w-full min-h-0 max-w-lg gap-4 overflow-y-auto rounded-lg border-0 bg-background p-6 shadow-lg outline-none",
29078
- className
29079
- ),
29080
- children: [
29081
- children,
29082
- showCloseButton && /* @__PURE__ */ jsxs11(
29083
- dist_exports8.Close,
29084
- {
29085
- "data-slot": "dialog-close",
29086
- className: cn(
29087
- "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
29088
- ),
29089
- children: [
29090
- /* @__PURE__ */ jsx68(X, {}),
29091
- /* @__PURE__ */ jsx68("span", { className: cn("sr-only"), children: "Close" })
29092
- ]
29093
- }
29094
- )
29095
- ]
29096
- }
29097
- )
29098
- ]
28896
+ return /* @__PURE__ */ jsx68(DialogPortal2, { "data-slot": "dialog-portal", children: /* @__PURE__ */ jsxs11(dist_exports8.Content, { ref: content3, "data-slot": "dialog-content", className: "nexface-chat__dialog-layer", onInteractOutside: (event) => event.preventDefault(), onEscapeKeyDown: (event) => {
28897
+ if (!(event.target instanceof Node) || !content3.current?.contains(event.target)) {
28898
+ event.preventDefault();
28899
+ return;
29099
28900
  }
29100
- ) });
28901
+ onEscapeKeyDown?.(event);
28902
+ }, ...props, children: [
28903
+ /* @__PURE__ */ jsx68(DialogBackgroundGuard, {}),
28904
+ /* @__PURE__ */ jsxs11("div", { className: cn("relative grid w-full min-h-0 max-w-lg gap-4 overflow-y-auto rounded-lg border-0 bg-background p-6 shadow-lg outline-none", className), children: [
28905
+ children,
28906
+ showCloseButton && /* @__PURE__ */ jsxs11(dist_exports8.Close, { "data-slot": "dialog-close", className: cn("absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"), children: [
28907
+ /* @__PURE__ */ jsx68(X, {}),
28908
+ /* @__PURE__ */ jsx68("span", { className: cn("sr-only"), children: "Close" })
28909
+ ] })
28910
+ ] })
28911
+ ] }) });
29101
28912
  }
29102
- function DialogFooter({
29103
- className,
29104
- showCloseButton = false,
29105
- children,
29106
- ...props
29107
- }) {
29108
- return /* @__PURE__ */ jsxs11(
29109
- "div",
29110
- {
29111
- "data-slot": "dialog-footer",
29112
- className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
29113
- ...props,
29114
- children: [
29115
- children,
29116
- showCloseButton && /* @__PURE__ */ jsx68(dist_exports8.Close, { asChild: true, children: /* @__PURE__ */ jsx68(Button, { variant: "outline", children: "Close" }) })
29117
- ]
29118
- }
29119
- );
28913
+ function DialogFooter({ className, showCloseButton = false, children, ...props }) {
28914
+ return /* @__PURE__ */ jsxs11("div", { "data-slot": "dialog-footer", className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className), ...props, children: [
28915
+ children,
28916
+ showCloseButton && /* @__PURE__ */ jsx68(dist_exports8.Close, { asChild: true, children: /* @__PURE__ */ jsx68(Button, { variant: "outline", children: "Close" }) })
28917
+ ] });
29120
28918
  }
29121
28919
  function DialogTitle3({ className, ...props }) {
29122
- return /* @__PURE__ */ jsx68(
29123
- dist_exports8.Title,
29124
- {
29125
- "data-slot": "dialog-title",
29126
- className: cn("text-lg leading-none font-semibold", className),
29127
- ...props
29128
- }
29129
- );
28920
+ return /* @__PURE__ */ jsx68(dist_exports8.Title, { "data-slot": "dialog-title", className: cn("text-lg leading-none font-semibold", className), ...props });
29130
28921
  }
29131
- function DialogDescription3({
29132
- className,
29133
- ...props
29134
- }) {
29135
- return /* @__PURE__ */ jsx68(
29136
- dist_exports8.Description,
29137
- {
29138
- "data-slot": "dialog-description",
29139
- className: cn("text-sm text-muted-foreground", className),
29140
- ...props
29141
- }
29142
- );
28922
+ function DialogDescription3({ className, ...props }) {
28923
+ return /* @__PURE__ */ jsx68(dist_exports8.Description, { "data-slot": "dialog-description", className: cn("text-sm text-muted-foreground", className), ...props });
29143
28924
  }
29144
28925
 
29145
28926
  // src/ui/home-demo/thread.tsx
29146
28927
  import { jsx as jsx69, jsxs as jsxs12 } from "react/jsx-runtime";
29147
- function Thread({
29148
- empty: isEmpty,
29149
- welcome,
29150
- suggestions,
29151
- composer,
29152
- footer: footer2,
29153
- children,
29154
- renderMessage
29155
- }) {
29156
- return /* @__PURE__ */ jsx69(
29157
- ThreadPrimitiveRoot,
28928
+ function Thread({ empty: isEmpty, welcome, suggestions, composer, footer: footer2, children, renderMessage }) {
28929
+ return /* @__PURE__ */ jsx69(ThreadPrimitiveRoot, { className: cn("flex h-full min-h-0 min-w-0 flex-1 flex-col"), style: { ["--nxf-thread-max-width"]: "42rem" }, children: /* @__PURE__ */ jsxs12(
28930
+ ThreadPrimitiveViewport,
29158
28931
  {
29159
- className: cn("flex h-full min-h-0 min-w-0 flex-1 flex-col"),
29160
- style: { ["--nxf-thread-max-width"]: "42rem" },
29161
- children: /* @__PURE__ */ jsxs12(
29162
- ThreadPrimitiveViewport,
29163
- {
29164
- turnAnchor: "top",
29165
- "data-slot": "aui_thread-viewport",
29166
- role: "log",
29167
- "aria-live": "polite",
29168
- className: cn(
29169
- // The gutter is reserved whether or not a scrollbar is showing, so the
29170
- // thread and its composer do not shift sideways on the first reply
29171
- // that overflows. Only classic scrollbars take layout space, so the
29172
- // jump appears on Windows and on macOS set to always show them.
29173
- "relative flex flex-1 [scrollbar-gutter:stable_both-edges] flex-col overflow-y-auto px-4 pt-6 md:px-6",
29174
- isEmpty && "justify-center"
29175
- ),
29176
- children: [
29177
- isEmpty ? welcome : null,
29178
- /* @__PURE__ */ jsxs12(
29179
- "div",
29180
- {
29181
- className: cn(
29182
- "mx-auto mb-12 flex w-full max-w-(--nxf-thread-max-width) flex-col gap-y-6 empty:hidden"
29183
- ),
29184
- children: [
29185
- /* @__PURE__ */ jsx69(ThreadPrimitiveMessages, { children: renderMessage }),
29186
- children
29187
- ]
29188
- }
28932
+ turnAnchor: "top",
28933
+ "data-slot": "aui_thread-viewport",
28934
+ role: "log",
28935
+ "aria-live": "polite",
28936
+ className: cn(
28937
+ // The gutter is reserved whether or not a scrollbar is showing, so the
28938
+ // thread and its composer do not shift sideways on the first reply
28939
+ // that overflows. Only classic scrollbars take layout space, so the
28940
+ // jump appears on Windows and on macOS set to always show them.
28941
+ "relative flex flex-1 [scrollbar-gutter:stable_both-edges] flex-col overflow-y-auto px-4 pt-6 md:px-6",
28942
+ isEmpty && "justify-center"
28943
+ ),
28944
+ children: [
28945
+ isEmpty ? welcome : null,
28946
+ /* @__PURE__ */ jsxs12("div", { className: cn("mx-auto mb-12 flex w-full max-w-(--nxf-thread-max-width) flex-col gap-y-6 empty:hidden"), children: [
28947
+ /* @__PURE__ */ jsx69(ThreadPrimitiveMessages, { children: renderMessage }),
28948
+ children
28949
+ ] }),
28950
+ /* @__PURE__ */ jsxs12(
28951
+ ThreadPrimitiveViewportFooter,
28952
+ {
28953
+ className: cn(
28954
+ "bg-background mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col gap-3 overflow-visible pb-5",
28955
+ !isEmpty && "sticky bottom-0 mt-auto"
29189
28956
  ),
29190
- /* @__PURE__ */ jsxs12(
29191
- ThreadPrimitiveViewportFooter,
29192
- {
29193
- className: cn(
29194
- "bg-background mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col gap-3 overflow-visible pb-5",
29195
- !isEmpty && "sticky bottom-0 mt-auto"
29196
- ),
29197
- children: [
29198
- footer2,
29199
- composer,
29200
- isEmpty ? suggestions : null
29201
- ]
29202
- }
29203
- )
29204
- ]
29205
- }
29206
- )
28957
+ children: [
28958
+ footer2,
28959
+ composer,
28960
+ isEmpty ? suggestions : null
28961
+ ]
28962
+ }
28963
+ )
28964
+ ]
29207
28965
  }
29208
- );
28966
+ ) });
29209
28967
  }
29210
28968
 
29211
28969
  // src/ui/home-demo/type.ts
@@ -29214,32 +28972,17 @@ var typeDeck = "text-muted-foreground max-w-[40ch] text-[15px] leading-relaxed t
29214
28972
 
29215
28973
  // src/ui/home-demo/greeting.tsx
29216
28974
  import { jsx as jsx70, jsxs as jsxs13 } from "react/jsx-runtime";
29217
- function Greeting({
29218
- title,
29219
- description
29220
- }) {
29221
- return /* @__PURE__ */ jsxs13(
29222
- "div",
29223
- {
29224
- className: cn(
29225
- "animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200"
29226
- ),
29227
- children: [
29228
- /* @__PURE__ */ jsx70("p", { className: cn(typeSection), children: title }),
29229
- description ? /* @__PURE__ */ jsx70("p", { className: cn(typeDeck), children: description }) : null
29230
- ]
29231
- }
29232
- );
28975
+ function Greeting({ title, description }) {
28976
+ return /* @__PURE__ */ jsxs13("div", { className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200"), children: [
28977
+ /* @__PURE__ */ jsx70("p", { className: cn(typeSection), children: title }),
28978
+ description ? /* @__PURE__ */ jsx70("p", { className: cn(typeDeck), children: description }) : null
28979
+ ] });
29233
28980
  }
29234
28981
 
29235
28982
  // src/ui/home-demo/suggestions.tsx
29236
28983
  import { jsx as jsx71 } from "react/jsx-runtime";
29237
28984
  var suggestionChipClass = "border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors";
29238
- function Suggestions2({
29239
- suggestions,
29240
- disabled,
29241
- onSend
29242
- }) {
28985
+ function Suggestions2({ suggestions, disabled, onSend }) {
29243
28986
  const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);
29244
28987
  const hidden = !isComposerEmpty || disabled;
29245
28988
  return (
@@ -29279,9 +29022,7 @@ import { useEffect as useEffect25, useLayoutEffect as useLayoutEffect10, useRef
29279
29022
  function suggestionMessages(messages) {
29280
29023
  const result = [];
29281
29024
  for (const message of messages) {
29282
- const parts = message.parts.flatMap(
29283
- (part) => part.type === "text" && part.text.trim() ? [{ type: "text", text: part.text }] : []
29284
- );
29025
+ const parts = message.parts.flatMap((part) => part.type === "text" && part.text.trim() ? [{ type: "text", text: part.text }] : []);
29285
29026
  if (message.role === "assistant" && !parts.length) continue;
29286
29027
  const previous3 = result.at(-1);
29287
29028
  if (message.role === "assistant" && previous3?.role === "assistant") {
@@ -29327,47 +29068,45 @@ function useNextMessage(chat, suggest, open) {
29327
29068
  // src/ui/home-demo/action-bar.tsx
29328
29069
  import { jsx as jsx72, jsxs as jsxs14 } from "react/jsx-runtime";
29329
29070
  function AssistantActionBar() {
29330
- return /* @__PURE__ */ jsx72(ActionBarPrimitiveRoot, { autohide: "never", className: cn("flex items-center gap-1.5"), children: /* @__PURE__ */ jsxs14(ActionBarPrimitiveCopy, { "aria-label": "\u590D\u5236\u56DE\u590D", className: cn(actionButtonClass), children: [
29331
- /* @__PURE__ */ jsx72(AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ jsx72(Check, { className: cn("size-4") }) }),
29332
- /* @__PURE__ */ jsx72(AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ jsx72(Copy, { className: cn("size-4") }) })
29333
- ] }) });
29071
+ return /* @__PURE__ */ jsx72(
29072
+ ActionBarPrimitiveRoot,
29073
+ {
29074
+ autohide: "never",
29075
+ className: cn("flex items-center gap-1.5"),
29076
+ children: /* @__PURE__ */ jsxs14(
29077
+ ActionBarPrimitiveCopy,
29078
+ {
29079
+ "aria-label": "\u590D\u5236\u56DE\u590D",
29080
+ className: cn(actionButtonClass),
29081
+ children: [
29082
+ /* @__PURE__ */ jsx72(AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ jsx72(Check, { className: cn("size-4") }) }),
29083
+ /* @__PURE__ */ jsx72(AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ jsx72(Copy, { className: cn("size-4") }) })
29084
+ ]
29085
+ }
29086
+ )
29087
+ }
29088
+ );
29334
29089
  }
29335
29090
 
29336
29091
  // src/ui/home-demo/messages.tsx
29337
29092
  import { jsx as jsx73, jsxs as jsxs15 } from "react/jsx-runtime";
29338
- function UserMessage({
29339
- children,
29340
- attachments,
29341
- actions
29342
- }) {
29093
+ function UserMessage({ children, attachments, actions }) {
29343
29094
  return /* @__PURE__ */ jsxs15(
29344
29095
  MessagePrimitiveRoot,
29345
29096
  {
29346
29097
  "data-role": "user",
29347
29098
  "data-slot": "aui_user-message-root",
29348
- className: cn(
29349
- "animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150"
29350
- ),
29099
+ className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150"),
29351
29100
  children: [
29352
29101
  /* @__PURE__ */ jsx73("div", { className: cn("w-full has-[.aui-attachment-root]:mb-2"), children: attachments }),
29353
29102
  /* @__PURE__ */ jsxs15("div", { className: cn("relative max-w-[80%]"), children: [
29354
- /* @__PURE__ */ jsx73(
29355
- "div",
29356
- {
29357
- className: cn(
29358
- "peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden"
29359
- ),
29360
- children
29361
- }
29362
- ),
29103
+ /* @__PURE__ */ jsx73("div", { className: cn("peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden"), children }),
29363
29104
  /* @__PURE__ */ jsx73(
29364
29105
  ActionBarPrimitiveRoot,
29365
29106
  {
29366
29107
  hideWhenRunning: true,
29367
29108
  autohide: "not-last",
29368
- className: cn(
29369
- "absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden"
29370
- ),
29109
+ className: cn("absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden"),
29371
29110
  children: actions
29372
29111
  }
29373
29112
  )
@@ -29382,50 +29121,26 @@ function AssistantMessage({ children }) {
29382
29121
  {
29383
29122
  "data-role": "assistant",
29384
29123
  "data-slot": "aui_assistant-message-root",
29385
- className: cn(
29386
- "animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150"
29387
- ),
29124
+ className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150"),
29388
29125
  children: [
29389
- /* @__PURE__ */ jsxs15(
29390
- "div",
29391
- {
29392
- "data-slot": "aui_assistant-message-content",
29393
- className: cn("text-[15px] leading-relaxed wrap-break-word"),
29394
- children: [
29395
- children,
29396
- /* @__PURE__ */ jsx73(MessageError, {})
29397
- ]
29398
- }
29399
- ),
29126
+ /* @__PURE__ */ jsxs15("div", { "data-slot": "aui_assistant-message-content", className: cn("text-[15px] leading-relaxed wrap-break-word"), children: [
29127
+ children,
29128
+ /* @__PURE__ */ jsx73(MessageError, {})
29129
+ ] }),
29400
29130
  /* @__PURE__ */ jsx73("div", { className: cn("mt-2 flex items-center gap-1.5 empty:hidden"), children: /* @__PURE__ */ jsx73(AssistantActionBar, {}) })
29401
29131
  ]
29402
29132
  }
29403
29133
  );
29404
29134
  }
29405
29135
  function MessageError() {
29406
- const cancelled = useAuiState(
29407
- (s) => s.message.status?.type === "incomplete" && s.message.status.reason === "cancelled"
29408
- );
29409
- if (cancelled)
29410
- return /* @__PURE__ */ jsx73("p", { role: "status", className: cn("mt-2 text-[13px] text-muted-foreground"), children: "Stopped" });
29411
- return /* @__PURE__ */ jsx73(MessagePrimitiveError, { children: /* @__PURE__ */ jsx73(
29412
- ErrorPrimitiveRoot,
29413
- {
29414
- role: "alert",
29415
- className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"),
29416
- children: /* @__PURE__ */ jsx73(ErrorPrimitiveMessage, { className: cn("line-clamp-2") })
29417
- }
29418
- ) });
29136
+ const cancelled = useAuiState((s) => s.message.status?.type === "incomplete" && s.message.status.reason === "cancelled");
29137
+ if (cancelled) return /* @__PURE__ */ jsx73("p", { role: "status", className: cn("mt-2 text-[13px] text-muted-foreground"), children: "Stopped" });
29138
+ return /* @__PURE__ */ jsx73(MessagePrimitiveError, { children: /* @__PURE__ */ jsx73(ErrorPrimitiveRoot, { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: /* @__PURE__ */ jsx73(ErrorPrimitiveMessage, { className: cn("line-clamp-2") }) }) });
29419
29139
  }
29420
29140
 
29421
29141
  // src/ui/home-demo/composer.tsx
29422
29142
  import { jsx as jsx74, jsxs as jsxs16 } from "react/jsx-runtime";
29423
- function Composer({
29424
- children,
29425
- inputProps,
29426
- actions,
29427
- ...props
29428
- }) {
29143
+ function Composer({ children, inputProps, actions, ...props }) {
29429
29144
  return /* @__PURE__ */ jsx74(ComposerPrimitiveRoot, { className: cn("relative w-full"), ...props, children: /* @__PURE__ */ jsx74(
29430
29145
  ComposerPrimitiveAttachmentDropzone,
29431
29146
  {
@@ -29437,91 +29152,52 @@ function Composer({
29437
29152
  onDragOverCapture: (event) => {
29438
29153
  if (inputProps.disabled) event.preventDefault();
29439
29154
  },
29440
- children: /* @__PURE__ */ jsxs16(
29441
- "div",
29442
- {
29443
- "data-slot": "aui_composer-shell",
29444
- className: cn(
29445
- "border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed"
29446
- ),
29447
- children: [
29448
- /* @__PURE__ */ jsx74("div", { className: cn("has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3"), children }),
29449
- /* @__PURE__ */ jsx74(ComposerPrimitiveInput, { asChild: true, ...inputProps, children: /* @__PURE__ */ jsx74(
29450
- "textarea",
29451
- {
29452
- "data-composer-input": true,
29453
- rows: 1,
29454
- className: cn(
29455
- "placeholder:text-muted-foreground field-sizing-content block max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none"
29456
- )
29457
- }
29458
- ) }),
29459
- /* @__PURE__ */ jsx74("div", { className: cn("flex items-center justify-between gap-2 px-2 pb-2"), children: actions })
29460
- ]
29461
- }
29462
- )
29155
+ children: /* @__PURE__ */ jsxs16("div", { "data-slot": "aui_composer-shell", className: cn("border-foreground/10 bg-muted/30 focus-within:border-foreground/25 data-[dragging=true]:border-foreground/40 rounded-thread flex flex-col border transition-colors data-[dragging=true]:border-dashed"), children: [
29156
+ /* @__PURE__ */ jsx74("div", { className: cn("has-[.aui-attachment-root]:px-3 has-[.aui-attachment-root]:pt-3"), children }),
29157
+ /* @__PURE__ */ jsx74(ComposerPrimitiveInput, { asChild: true, ...inputProps, children: /* @__PURE__ */ jsx74("textarea", { "data-composer-input": true, rows: 1, className: cn("placeholder:text-muted-foreground field-sizing-content block max-h-48 w-full resize-none bg-transparent px-4 pt-3 pb-2 text-base leading-6 focus:outline-none") }) }),
29158
+ /* @__PURE__ */ jsx74("div", { className: cn("flex items-center justify-between gap-2 px-2 pb-2"), children: actions })
29159
+ ] })
29463
29160
  }
29464
29161
  ) });
29465
29162
  }
29466
- function EditComposer({
29467
- children,
29468
- inputProps,
29469
- cancelProps,
29470
- sendProps,
29471
- ...props
29472
- }) {
29163
+ function EditComposer({ children, inputProps, cancelProps, sendProps, ...props }) {
29473
29164
  return /* @__PURE__ */ jsx74(
29474
29165
  MessagePrimitiveRoot,
29475
29166
  {
29476
29167
  "data-role": "user",
29477
29168
  "data-slot": "aui_edit-composer-wrapper",
29478
29169
  className: cn("mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end"),
29479
- children: /* @__PURE__ */ jsxs16(
29480
- ComposerPrimitiveRoot,
29481
- {
29482
- className: cn(
29483
- "border-foreground/10 bg-muted/30 focus-within:border-foreground/25 rounded-thread flex w-full max-w-[85%] flex-col border transition-colors"
29484
- ),
29485
- ...props,
29486
- children: [
29487
- /* @__PURE__ */ jsx74(ComposerPrimitiveInput, { asChild: true, ...inputProps, children: /* @__PURE__ */ jsx74(
29488
- "textarea",
29489
- {
29490
- autoFocus: true,
29491
- rows: 1,
29492
- className: cn(
29493
- "field-sizing-content max-h-48 min-h-12 w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[15px] leading-6 focus:outline-none"
29494
- )
29495
- }
29496
- ) }),
29497
- children,
29498
- /* @__PURE__ */ jsxs16("div", { className: cn("flex items-center justify-end gap-1.5 px-2.5 pb-2.5"), children: [
29499
- /* @__PURE__ */ jsx74(ComposerPrimitiveCancel, { asChild: true, children: /* @__PURE__ */ jsx74(
29500
- "button",
29501
- {
29502
- type: "button",
29503
- ...cancelProps,
29504
- className: cn(
29505
- "text-muted-foreground hover:text-foreground rounded-control h-8 px-3 text-[13px] transition-colors"
29506
- ),
29507
- children: "\u53D6\u6D88"
29508
- }
29509
- ) }),
29510
- /* @__PURE__ */ jsx74(ComposerPrimitiveSend, { asChild: true, children: /* @__PURE__ */ jsx74(
29511
- "button",
29512
- {
29513
- type: "button",
29514
- ...sendProps,
29515
- className: cn(
29516
- "bg-primary text-primary-foreground rounded-control h-8 px-3 text-[13px] font-medium transition-opacity disabled:opacity-40"
29517
- ),
29518
- children: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001"
29519
- }
29520
- ) })
29521
- ] })
29522
- ]
29523
- }
29524
- )
29170
+ children: /* @__PURE__ */ jsxs16(ComposerPrimitiveRoot, { className: cn("border-foreground/10 bg-muted/30 focus-within:border-foreground/25 rounded-thread flex w-full max-w-[85%] flex-col border transition-colors"), ...props, children: [
29171
+ /* @__PURE__ */ jsx74(ComposerPrimitiveInput, { asChild: true, ...inputProps, children: /* @__PURE__ */ jsx74(
29172
+ "textarea",
29173
+ {
29174
+ autoFocus: true,
29175
+ rows: 1,
29176
+ className: cn("field-sizing-content max-h-48 min-h-12 w-full resize-none bg-transparent px-4 pt-3.5 pb-1 text-[15px] leading-6 focus:outline-none")
29177
+ }
29178
+ ) }),
29179
+ children,
29180
+ /* @__PURE__ */ jsxs16("div", { className: cn("flex items-center justify-end gap-1.5 px-2.5 pb-2.5"), children: [
29181
+ /* @__PURE__ */ jsx74(ComposerPrimitiveCancel, { asChild: true, children: /* @__PURE__ */ jsx74(
29182
+ "button",
29183
+ {
29184
+ type: "button",
29185
+ ...cancelProps,
29186
+ className: cn("text-muted-foreground hover:text-foreground rounded-control h-8 px-3 text-[13px] transition-colors"),
29187
+ children: "\u53D6\u6D88"
29188
+ }
29189
+ ) }),
29190
+ /* @__PURE__ */ jsx74(ComposerPrimitiveSend, { asChild: true, children: /* @__PURE__ */ jsx74(
29191
+ "button",
29192
+ {
29193
+ type: "button",
29194
+ ...sendProps,
29195
+ className: cn("bg-primary text-primary-foreground rounded-control h-8 px-3 text-[13px] font-medium transition-opacity disabled:opacity-40"),
29196
+ children: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001"
29197
+ }
29198
+ ) })
29199
+ ] })
29200
+ ] })
29525
29201
  }
29526
29202
  );
29527
29203
  }
@@ -29532,18 +29208,8 @@ import { forwardRef as forwardRef29 } from "react";
29532
29208
  // src/ui/tooltip.tsx
29533
29209
  import * as React6 from "react";
29534
29210
  import { jsx as jsx75, jsxs as jsxs17 } from "react/jsx-runtime";
29535
- function TooltipProvider2({
29536
- delayDuration = 0,
29537
- ...props
29538
- }) {
29539
- return /* @__PURE__ */ jsx75(
29540
- dist_exports12.Provider,
29541
- {
29542
- "data-slot": "tooltip-provider",
29543
- delayDuration,
29544
- ...props
29545
- }
29546
- );
29211
+ function TooltipProvider2({ delayDuration = 0, ...props }) {
29212
+ return /* @__PURE__ */ jsx75(dist_exports12.Provider, { "data-slot": "tooltip-provider", delayDuration, ...props });
29547
29213
  }
29548
29214
  function Tooltip2({ ...props }) {
29549
29215
  return /* @__PURE__ */ jsx75(dist_exports12.Root, { "data-slot": "tooltip", ...props });
@@ -29551,132 +29217,51 @@ function Tooltip2({ ...props }) {
29551
29217
  var TooltipTrigger3 = React6.forwardRef(function TooltipTrigger4({ ...props }, ref) {
29552
29218
  return /* @__PURE__ */ jsx75(dist_exports12.Trigger, { "data-slot": "tooltip-trigger", ref, ...props });
29553
29219
  });
29554
- function TooltipContent3({
29555
- className,
29556
- sideOffset = 0,
29557
- children,
29558
- ...props
29559
- }) {
29220
+ function TooltipContent3({ className, sideOffset = 0, children, ...props }) {
29560
29221
  const container = usePortalContainer();
29561
- if (!container) return null;
29562
- return /* @__PURE__ */ jsx75(dist_exports12.Portal, { container, children: /* @__PURE__ */ jsxs17(
29563
- dist_exports12.Content,
29564
- {
29565
- "data-slot": "tooltip-content",
29566
- sideOffset,
29567
- className: cn(
29568
- "z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
29569
- className
29570
- ),
29571
- ...props,
29572
- children: [
29573
- /* @__PURE__ */ jsx75(PortalThemeSync, {}),
29574
- children,
29575
- /* @__PURE__ */ jsx75(
29576
- dist_exports12.Arrow,
29577
- {
29578
- className: cn(
29579
- "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"
29580
- )
29581
- }
29582
- )
29583
- ]
29584
- }
29585
- ) });
29222
+ if (!container)
29223
+ return null;
29224
+ return /* @__PURE__ */ jsx75(dist_exports12.Portal, { container, children: /* @__PURE__ */ jsxs17(dist_exports12.Content, { "data-slot": "tooltip-content", sideOffset, className: cn("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", className), ...props, children: [
29225
+ /* @__PURE__ */ jsx75(PortalThemeSync, {}),
29226
+ children,
29227
+ /* @__PURE__ */ jsx75(dist_exports12.Arrow, { className: cn("z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground") })
29228
+ ] }) });
29586
29229
  }
29587
29230
 
29588
29231
  // src/ui/tooltip-icon-button.tsx
29589
29232
  import { jsx as jsx76, jsxs as jsxs18 } from "react/jsx-runtime";
29590
- var TooltipIconButton = forwardRef29(
29591
- ({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
29592
- return /* @__PURE__ */ jsx76(TooltipProvider2, { delayDuration: 0, children: /* @__PURE__ */ jsxs18(Tooltip2, { children: [
29593
- /* @__PURE__ */ jsx76(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsxs18(
29594
- Button,
29595
- {
29596
- variant: "ghost",
29597
- size: "icon",
29598
- ...rest,
29599
- className: cn("aui-button-icon size-6 p-1 active:scale-90", className),
29600
- ref,
29601
- children: [
29602
- /* @__PURE__ */ jsx76(dist_exports.Slottable, { children }),
29603
- /* @__PURE__ */ jsx76("span", { className: cn("aui-sr-only sr-only"), children: tooltip })
29604
- ]
29605
- }
29606
- ) }),
29607
- /* @__PURE__ */ jsx76(TooltipContent3, { side, children: tooltip })
29608
- ] }) });
29609
- }
29610
- );
29233
+ var TooltipIconButton = forwardRef29(({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
29234
+ return /* @__PURE__ */ jsx76(TooltipProvider2, { delayDuration: 0, children: /* @__PURE__ */ jsxs18(Tooltip2, { children: [
29235
+ /* @__PURE__ */ jsx76(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsxs18(Button, { variant: "ghost", size: "icon", ...rest, className: cn("aui-button-icon size-6 p-1 active:scale-90", className), ref, children: [
29236
+ /* @__PURE__ */ jsx76(dist_exports.Slottable, { children }),
29237
+ /* @__PURE__ */ jsx76("span", { className: cn("aui-sr-only sr-only"), children: tooltip })
29238
+ ] }) }),
29239
+ /* @__PURE__ */ jsx76(TooltipContent3, { side, children: tooltip })
29240
+ ] }) });
29241
+ });
29611
29242
  TooltipIconButton.displayName = "TooltipIconButton";
29612
29243
 
29613
29244
  // src/ui/avatar.tsx
29614
29245
  import { jsx as jsx77 } from "react/jsx-runtime";
29615
- function Avatar3({
29616
- className,
29617
- size: size4 = "default",
29618
- ...props
29619
- }) {
29620
- return /* @__PURE__ */ jsx77(
29621
- dist_exports9.Root,
29622
- {
29623
- "data-slot": "avatar",
29624
- "data-size": size4,
29625
- className: cn(
29626
- "group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",
29627
- className
29628
- ),
29629
- ...props
29630
- }
29631
- );
29246
+ function Avatar3({ className, size: size4 = "default", ...props }) {
29247
+ return /* @__PURE__ */ jsx77(dist_exports9.Root, { "data-slot": "avatar", "data-size": size4, className: cn("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6", className), ...props });
29632
29248
  }
29633
29249
  function AvatarImage3({ className, ...props }) {
29634
- return /* @__PURE__ */ jsx77(
29635
- dist_exports9.Image,
29636
- {
29637
- "data-slot": "avatar-image",
29638
- className: cn("aspect-square size-full", className),
29639
- ...props
29640
- }
29641
- );
29250
+ return /* @__PURE__ */ jsx77(dist_exports9.Image, { "data-slot": "avatar-image", className: cn("aspect-square size-full", className), ...props });
29642
29251
  }
29643
- function AvatarFallback3({
29644
- className,
29645
- ...props
29646
- }) {
29647
- return /* @__PURE__ */ jsx77(
29648
- dist_exports9.Fallback,
29649
- {
29650
- "data-slot": "avatar-fallback",
29651
- className: cn(
29652
- "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
29653
- className
29654
- ),
29655
- ...props
29656
- }
29657
- );
29252
+ function AvatarFallback3({ className, ...props }) {
29253
+ return /* @__PURE__ */ jsx77(dist_exports9.Fallback, { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs", className), ...props });
29658
29254
  }
29659
29255
 
29660
29256
  // src/default-chat.tsx
29661
- import {
29662
- forwardRef as forwardRef33,
29663
- useEffect as useEffect34,
29664
- useLayoutEffect as useLayoutEffect14,
29665
- useMemo as useMemo13,
29666
- useRef as useRef39,
29667
- useState as useState39
29668
- } from "react";
29257
+ import { forwardRef as forwardRef33, useEffect as useEffect34, useLayoutEffect as useLayoutEffect14, useMemo as useMemo13, useRef as useRef39, useState as useState39 } from "react";
29669
29258
 
29670
29259
  // src/assistant-runtime.tsx
29671
29260
  import { useEffect as useEffect26, useLayoutEffect as useLayoutEffect12, useReducer as useReducer5, useRef as useRef30, useState as useState28 } from "react";
29672
29261
 
29673
29262
  // src/assistant-attachments.ts
29674
29263
  import { ImageInputContentSchema, TextInputContentSchema } from "@ag-ui/core";
29675
- import {
29676
- attachmentContent,
29677
- readAttachment,
29678
- validateAttachment
29679
- } from "./attachments.js";
29264
+ import { attachmentContent, readAttachment, validateAttachment } from "./attachments.js";
29680
29265
  var errorText = (error) => error instanceof Error ? error.message : String(error);
29681
29266
  var durablePreview = (preview) => preview?.startsWith("data:image/") ? preview : void 0;
29682
29267
  function abortable(signal, task) {
@@ -29690,18 +29275,9 @@ function abortable(signal, task) {
29690
29275
  function toAssistantAttachment(attachment) {
29691
29276
  const content3 = attachmentContent(attachment).map((part) => {
29692
29277
  if (part.type === "text") return part;
29693
- return {
29694
- type: "image",
29695
- image: part.source.type === "data" ? `data:${part.source.mimeType};base64,${part.source.value}` : part.source.value
29696
- };
29278
+ return { type: "image", image: part.source.type === "data" ? `data:${part.source.mimeType};base64,${part.source.value}` : part.source.value };
29697
29279
  });
29698
- return {
29699
- id: attachment.id,
29700
- name: attachment.name,
29701
- type: attachment.preview ? "image" : "document",
29702
- content: content3,
29703
- status: { type: "complete" }
29704
- };
29280
+ return { id: attachment.id, name: attachment.name, type: attachment.preview ? "image" : "document", content: content3, status: { type: "complete" } };
29705
29281
  }
29706
29282
  var AssistantAttachments = class {
29707
29283
  constructor(changed, notice) {
@@ -29732,30 +29308,15 @@ var AssistantAttachments = class {
29732
29308
  this.notice("\u9644\u4EF6\u6570\u91CF\u8D85\u51FA\u9650\u5236\u3002");
29733
29309
  throw new Error("\u9644\u4EF6\u6570\u91CF\u8D85\u51FA\u9650\u5236\u3002");
29734
29310
  }
29735
- const entry = {
29736
- id: crypto.randomUUID(),
29737
- file,
29738
- controller: new AbortController(),
29739
- adapter: options2.adapter,
29740
- adding: true
29741
- };
29311
+ const entry = { id: crypto.randomUUID(), file, controller: new AbortController(), adapter: options2.adapter, adding: true };
29742
29312
  this.entries.set(entry.id, entry);
29743
29313
  this.changed();
29744
- const base = {
29745
- id: entry.id,
29746
- file,
29747
- name: file.name,
29748
- contentType: file.type,
29749
- type: file.type.startsWith("image/") ? "image" : "document"
29750
- };
29314
+ const base = { id: entry.id, file, name: file.name, contentType: file.type, type: file.type.startsWith("image/") ? "image" : "document" };
29751
29315
  yield { ...base, status: { type: "running", reason: "uploading", progress: 0 } };
29752
29316
  try {
29753
29317
  if (entry.adapter) {
29754
29318
  validateAttachment(file, options2);
29755
- const result = await abortable(
29756
- entry.controller.signal,
29757
- entry.adapter.add({ id: entry.id, file, signal: entry.controller.signal })
29758
- );
29319
+ const result = await abortable(entry.controller.signal, entry.adapter.add({ id: entry.id, file, signal: entry.controller.signal }));
29759
29320
  this.assertLive(entry);
29760
29321
  entry.data = result.data;
29761
29322
  entry.preview = result.preview;
@@ -29782,18 +29343,9 @@ var AssistantAttachments = class {
29782
29343
  try {
29783
29344
  let content3;
29784
29345
  if (entry.adapter) {
29785
- const result = await abortable(
29786
- entry.controller.signal,
29787
- entry.adapter.send({
29788
- id: entry.id,
29789
- file: entry.file,
29790
- data: entry.data,
29791
- signal: entry.controller.signal
29792
- })
29793
- );
29346
+ const result = await abortable(entry.controller.signal, entry.adapter.send({ id: entry.id, file: entry.file, data: entry.data, signal: entry.controller.signal }));
29794
29347
  this.assertLive(entry);
29795
- if (!Array.isArray(result.content) || !result.content.length)
29796
- throw new Error("\u9644\u4EF6\u5904\u7406\u5FC5\u987B\u8FD4\u56DE\u6587\u672C\u6216\u5185\u8054\u56FE\u7247\u3002");
29348
+ if (!Array.isArray(result.content) || !result.content.length) throw new Error("\u9644\u4EF6\u5904\u7406\u5FC5\u987B\u8FD4\u56DE\u6587\u672C\u6216\u5185\u8054\u56FE\u7247\u3002");
29797
29349
  content3 = result.content.map((part) => {
29798
29350
  if (part.type === "text") return TextInputContentSchema.parse(part);
29799
29351
  const image3 = ImageInputContentSchema.parse(part);
@@ -29803,12 +29355,7 @@ var AssistantAttachments = class {
29803
29355
  } else content3 = attachmentContent(entry.local);
29804
29356
  this.assertLive(entry);
29805
29357
  const preview = durablePreview(entry.preview);
29806
- entry.result = {
29807
- id: entry.id,
29808
- name: entry.file.name,
29809
- content: content3,
29810
- ...preview ? { preview } : {}
29811
- };
29358
+ entry.result = { id: entry.id, name: entry.file.name, content: content3, ...preview ? { preview } : {} };
29812
29359
  return toAssistantAttachment(entry.result);
29813
29360
  } catch (error) {
29814
29361
  if (this.live(entry)) this.notice(errorText(error));
@@ -29866,150 +29413,136 @@ function useVoiceInput(options2) {
29866
29413
  owner.current?.();
29867
29414
  generation.current++;
29868
29415
  };
29869
- const dictation = useMemo10(
29870
- () => ({
29871
- disableInputDuringDictation: true,
29872
- listen() {
29873
- const config = latest.current;
29874
- if (!config.active || !config.open || config.blocked || !config.dictation || !source)
29875
- throw new Error("\u5F53\u524D\u65E0\u6CD5\u5F00\u59CB\u8BED\u97F3\u8F93\u5165\u3002");
29876
- cancel();
29877
- const token = ++generation.current;
29878
- const composer = config.composer();
29879
- const original = composer.getState().text;
29880
- const starts = /* @__PURE__ */ new Set();
29881
- const speeches = /* @__PURE__ */ new Set();
29882
- const ends = /* @__PURE__ */ new Set();
29883
- let input;
29884
- const subscriptions = [];
29885
- let confirmed = original;
29886
- let hasConfirmed = false;
29887
- let ended = false;
29888
- let status2 = { type: "starting" };
29889
- const emit = (listeners, value) => {
29890
- for (const callback of [...listeners]) callback(value);
29891
- };
29892
- const valid2 = () => !ended && generation.current === token;
29893
- const restore = () => {
29894
- try {
29895
- composer.setText(original);
29896
- } catch {
29897
- }
29898
- };
29899
- const finish = (reason) => {
29416
+ const dictation = useMemo10(() => ({
29417
+ disableInputDuringDictation: true,
29418
+ listen() {
29419
+ const config = latest.current;
29420
+ if (!config.active || !config.open || config.blocked || !config.dictation || !source) throw new Error("\u5F53\u524D\u65E0\u6CD5\u5F00\u59CB\u8BED\u97F3\u8F93\u5165\u3002");
29421
+ cancel();
29422
+ const token = ++generation.current;
29423
+ const composer = config.composer();
29424
+ const original = composer.getState().text;
29425
+ const starts = /* @__PURE__ */ new Set();
29426
+ const speeches = /* @__PURE__ */ new Set();
29427
+ const ends = /* @__PURE__ */ new Set();
29428
+ let input;
29429
+ const subscriptions = [];
29430
+ let confirmed = original;
29431
+ let hasConfirmed = false;
29432
+ let ended = false;
29433
+ let status2 = { type: "starting" };
29434
+ const emit = (listeners, value) => {
29435
+ for (const callback of [...listeners]) callback(value);
29436
+ };
29437
+ const valid2 = () => !ended && generation.current === token;
29438
+ const restore = () => {
29439
+ try {
29440
+ composer.setText(original);
29441
+ } catch {
29442
+ }
29443
+ };
29444
+ const finish = (reason) => {
29445
+ if (!valid2()) return;
29446
+ ended = true;
29447
+ status2 = { type: "ended", reason };
29448
+ owner.current = void 0;
29449
+ for (const unsubscribe of subscriptions.splice(0)) unsubscribe();
29450
+ if (reason !== "stopped" || !hasConfirmed) restore();
29451
+ else composer.setText(confirmed);
29452
+ emit(ends, { transcript: "", isFinal: true });
29453
+ if (reason === "stopped" && !hasConfirmed) latest.current.notice("\u672A\u8BC6\u522B\u5230\u8BED\u97F3\uFF0C\u8BF7\u91CD\u8BD5\u3002");
29454
+ setStatus("idle");
29455
+ };
29456
+ const terminate = () => {
29457
+ if (ended) return;
29458
+ if (valid2()) {
29459
+ finish("cancelled");
29460
+ generation.current++;
29461
+ }
29462
+ try {
29463
+ input?.cancel();
29464
+ } catch {
29465
+ }
29466
+ };
29467
+ const session = {
29468
+ get status() {
29469
+ if (!ended && input?.status.type === "ended") queueMicrotask(complete);
29470
+ return ended ? status2 : input?.status ?? status2;
29471
+ },
29472
+ stop: async () => {
29900
29473
  if (!valid2()) return;
29901
- ended = true;
29902
- status2 = { type: "ended", reason };
29903
- owner.current = void 0;
29904
- for (const unsubscribe of subscriptions.splice(0)) unsubscribe();
29905
- if (reason !== "stopped" || !hasConfirmed) restore();
29906
- else composer.setText(confirmed);
29907
- emit(ends, { transcript: "", isFinal: true });
29908
- if (reason === "stopped" && !hasConfirmed)
29909
- latest.current.notice("\u672A\u8BC6\u522B\u5230\u8BED\u97F3\uFF0C\u8BF7\u91CD\u8BD5\u3002");
29910
- setStatus("idle");
29911
- };
29912
- const terminate = () => {
29913
- if (ended) return;
29914
- if (valid2()) {
29915
- finish("cancelled");
29916
- generation.current++;
29917
- }
29474
+ setStatus("transcribing");
29918
29475
  try {
29919
- input?.cancel();
29920
- } catch {
29921
- }
29922
- };
29923
- const session = {
29924
- get status() {
29925
- if (!ended && input?.status.type === "ended") queueMicrotask(complete);
29926
- return ended ? status2 : input?.status ?? status2;
29927
- },
29928
- stop: async () => {
29929
- if (!valid2()) return;
29930
- setStatus("transcribing");
29931
- try {
29932
- await input?.stop();
29933
- if (valid2()) complete();
29934
- } catch (error) {
29935
- failure(error);
29936
- }
29937
- },
29938
- cancel: terminate,
29939
- onSpeechStart(callback) {
29940
- starts.add(callback);
29941
- return () => starts.delete(callback);
29942
- },
29943
- onSpeech(callback) {
29944
- speeches.add(callback);
29945
- return () => speeches.delete(callback);
29946
- },
29947
- onSpeechEnd(callback) {
29948
- ends.add(callback);
29949
- return () => ends.delete(callback);
29476
+ await input?.stop();
29477
+ if (valid2()) complete();
29478
+ } catch (error) {
29479
+ failure(error);
29950
29480
  }
29951
- };
29952
- owner.current = terminate;
29953
- config.notice("");
29954
- setStatus("starting");
29955
- const failure = (error) => {
29481
+ },
29482
+ cancel: terminate,
29483
+ onSpeechStart(callback) {
29484
+ starts.add(callback);
29485
+ return () => starts.delete(callback);
29486
+ },
29487
+ onSpeech(callback) {
29488
+ speeches.add(callback);
29489
+ return () => speeches.delete(callback);
29490
+ },
29491
+ onSpeechEnd(callback) {
29492
+ ends.add(callback);
29493
+ return () => ends.delete(callback);
29494
+ }
29495
+ };
29496
+ owner.current = terminate;
29497
+ config.notice("");
29498
+ setStatus("starting");
29499
+ const failure = (error) => {
29500
+ if (!valid2()) return;
29501
+ const cancelled = error instanceof DOMException && error.name === "AbortError";
29502
+ finish(cancelled ? "cancelled" : "error");
29503
+ try {
29504
+ input?.cancel();
29505
+ } catch {
29506
+ }
29507
+ if (!cancelled) latest.current.notice(error instanceof Error ? error.message : "\u8BED\u97F3\u8F93\u5165\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
29508
+ };
29509
+ const complete = () => {
29510
+ if (!valid2()) return;
29511
+ const reason = input?.status.type === "ended" ? input.status.reason : "stopped";
29512
+ if (reason === "error") failure(new Error("\u8BED\u97F3\u8F93\u5165\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6388\u6743\u3001\u9EA6\u514B\u98CE\u6743\u9650\u548C\u7F51\u7EDC\u3002"));
29513
+ else finish(reason);
29514
+ };
29515
+ try {
29516
+ input = source.listen();
29517
+ const started = () => {
29956
29518
  if (!valid2()) return;
29957
- const cancelled = error instanceof DOMException && error.name === "AbortError";
29958
- finish(cancelled ? "cancelled" : "error");
29959
- try {
29960
- input?.cancel();
29961
- } catch {
29962
- }
29963
- if (!cancelled)
29964
- latest.current.notice(
29965
- error instanceof Error ? error.message : "\u8BED\u97F3\u8F93\u5165\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
29966
- );
29519
+ status2 = { type: "running" };
29520
+ setStatus("recording");
29521
+ for (const callback of [...starts]) callback();
29967
29522
  };
29968
- const complete = () => {
29523
+ subscriptions.push(input.onSpeechStart(started));
29524
+ subscriptions.push(input.onSpeech((result) => {
29969
29525
  if (!valid2()) return;
29970
- const reason = input?.status.type === "ended" ? input.status.reason : "stopped";
29971
- if (reason === "error")
29972
- failure(new Error("\u8BED\u97F3\u8F93\u5165\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6388\u6743\u3001\u9EA6\u514B\u98CE\u6743\u9650\u548C\u7F51\u7EDC\u3002"));
29973
- else finish(reason);
29974
- };
29975
- try {
29976
- input = source.listen();
29977
- const started = () => {
29978
- if (!valid2()) return;
29979
- status2 = { type: "running" };
29980
- setStatus("recording");
29981
- for (const callback of [...starts]) callback();
29982
- };
29983
- subscriptions.push(input.onSpeechStart(started));
29984
- subscriptions.push(
29985
- input.onSpeech((result) => {
29986
- if (!valid2()) return;
29987
- emit(speeches, result);
29988
- if (result.isFinal !== false) {
29989
- confirmed = composer.getState().text;
29990
- hasConfirmed ||= Boolean(result.transcript.trim());
29991
- }
29992
- })
29993
- );
29994
- subscriptions.push(input.onSpeechEnd(complete));
29995
- if (input.status.type === "running") queueMicrotask(started);
29996
- if (input.status.type === "ended") queueMicrotask(complete);
29997
- } catch (error) {
29998
- queueMicrotask(() => failure(error));
29999
- }
30000
- return session;
29526
+ emit(speeches, result);
29527
+ if (result.isFinal !== false) {
29528
+ confirmed = composer.getState().text;
29529
+ hasConfirmed ||= Boolean(result.transcript.trim());
29530
+ }
29531
+ }));
29532
+ subscriptions.push(input.onSpeechEnd(complete));
29533
+ if (input.status.type === "running") queueMicrotask(started);
29534
+ if (input.status.type === "ended") queueMicrotask(complete);
29535
+ } catch (error) {
29536
+ queueMicrotask(() => failure(error));
30001
29537
  }
30002
- }),
30003
- [source]
30004
- );
29538
+ return session;
29539
+ }
29540
+ }), [source]);
30005
29541
  useLayoutEffect11(() => {
30006
29542
  if (!options2.active || !options2.open || options2.blocked || !enabled) cancel();
30007
29543
  }, [options2.active, options2.open, options2.blocked, enabled]);
30008
29544
  useLayoutEffect11(() => () => cancel(), [source, options2.sessionId]);
30009
- return {
30010
- dictation: enabled ? dictation : void 0,
30011
- state: { status, supported: enabled, cancel }
30012
- };
29545
+ return { dictation: enabled ? dictation : void 0, state: { status, supported: enabled, cancel } };
30013
29546
  }
30014
29547
 
30015
29548
  // src/assistant-runtime.tsx
@@ -30023,57 +29556,29 @@ function parseToolArgs(text7) {
30023
29556
  }
30024
29557
  }
30025
29558
  function convertMessage(message) {
30026
- const content3 = message.parts.map(
30027
- (part) => part.type !== "tool" ? part : {
30028
- type: "tool-call",
30029
- toolCallId: part.toolCallId,
30030
- toolName: part.name,
30031
- args: parseToolArgs(part.arguments),
30032
- argsText: part.arguments,
30033
- result: part.result,
30034
- isError: part.isError
30035
- }
30036
- );
30037
- if (message.role === "user")
30038
- return {
30039
- id: message.id,
30040
- role: "user",
30041
- content: content3,
30042
- attachments: message.attachments?.map(toAssistantAttachment)
30043
- };
30044
- return {
30045
- id: message.id,
30046
- role: "assistant",
30047
- content: content3,
30048
- status: message.error ? { type: "incomplete", reason: "error", error: message.error.userMessage } : message.state === "cancelled" ? { type: "incomplete", reason: "cancelled" } : message.state === "running" ? { type: "running" } : { type: "complete", reason: "stop" }
30049
- };
29559
+ const content3 = message.parts.map((part) => part.type !== "tool" ? part : {
29560
+ type: "tool-call",
29561
+ toolCallId: part.toolCallId,
29562
+ toolName: part.name,
29563
+ args: parseToolArgs(part.arguments),
29564
+ argsText: part.arguments,
29565
+ result: part.result,
29566
+ isError: part.isError
29567
+ });
29568
+ if (message.role === "user") return { id: message.id, role: "user", content: content3, attachments: message.attachments?.map(toAssistantAttachment) };
29569
+ return { id: message.id, role: "assistant", content: content3, status: message.error ? { type: "incomplete", reason: "error", error: message.error.userMessage } : message.state === "cancelled" ? { type: "incomplete", reason: "cancelled" } : message.state === "running" ? { type: "running" } : { type: "complete", reason: "stop" } };
30050
29570
  }
30051
29571
  function projectMessages(messages) {
30052
29572
  const projected = [];
30053
29573
  for (const message of messages) {
30054
29574
  const previous3 = projected.at(-1);
30055
29575
  if (message.role === "assistant" && previous3?.role === "assistant") {
30056
- projected[projected.length - 1] = {
30057
- ...previous3,
30058
- parts: [...previous3.parts, ...message.parts],
30059
- ...message.state ? { state: message.state } : {},
30060
- ...message.error ? { error: message.error } : {}
30061
- };
29576
+ projected[projected.length - 1] = { ...previous3, parts: [...previous3.parts, ...message.parts], ...message.state ? { state: message.state } : {}, ...message.error ? { error: message.error } : {} };
30062
29577
  } else projected.push(message);
30063
29578
  }
30064
29579
  return projected;
30065
29580
  }
30066
- function SessionRuntime({
30067
- id,
30068
- chat,
30069
- options: options2,
30070
- dictation,
30071
- open = true,
30072
- blocked,
30073
- active,
30074
- onEdit,
30075
- children
30076
- }) {
29581
+ function SessionRuntime({ id, chat, options: options2, dictation, open = true, blocked, active, onEdit, children }) {
30077
29582
  const latest = useRef30(chat);
30078
29583
  useLayoutEffect12(() => {
30079
29584
  latest.current = chat;
@@ -30111,8 +29616,7 @@ function SessionRuntime({
30111
29616
  isRunning: active && chat.status !== "idle" && chat.status !== "error" && chat.status !== "waiting",
30112
29617
  isSendDisabled: !active || blocked || attachments.blocked || voice.state.status !== "idle",
30113
29618
  onNew: async (message) => {
30114
- if (!alive.current || latest.current.activeSessionId !== id)
30115
- throw new MessageNotSentError("\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u8BF7\u8FD4\u56DE\u539F\u4F1A\u8BDD\u91CD\u65B0\u53D1\u9001\u3002");
29619
+ if (!alive.current || latest.current.activeSessionId !== id) throw new MessageNotSentError("\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u8BF7\u8FD4\u56DE\u539F\u4F1A\u8BDD\u91CD\u65B0\u53D1\u9001\u3002");
30116
29620
  const files = attachments.take(message.attachments ?? []);
30117
29621
  const text7 = message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
30118
29622
  attachments.commit(message.attachments ?? []);
@@ -30142,11 +29646,7 @@ function SessionRuntime({
30142
29646
  attachments: options2 === false ? void 0 : attachments,
30143
29647
  threadList: {
30144
29648
  threadId: id,
30145
- threads: chat.sessions.map((session) => ({
30146
- id: session.id,
30147
- title: session.title,
30148
- status: "regular"
30149
- })),
29649
+ threads: chat.sessions.map((session) => ({ id: session.id, title: session.title, status: "regular" })),
30150
29650
  onSwitchToNewThread: () => {
30151
29651
  latest.current.createSession();
30152
29652
  },
@@ -30158,31 +29658,24 @@ function SessionRuntime({
30158
29658
  });
30159
29659
  const send = async () => {
30160
29660
  const draft = runtime.thread.composer.getState();
30161
- if (!active || blocked || attachments.blocked || sendLock.current || voice.state.status !== "idle" || draft.isEmpty)
30162
- return;
29661
+ if (!active || blocked || attachments.blocked || sendLock.current || voice.state.status !== "idle" || draft.isEmpty) return;
30163
29662
  sendLock.current = true;
30164
29663
  setSending(true);
30165
29664
  setNotice("");
30166
29665
  try {
30167
- const results = await Promise.allSettled(
30168
- draft.attachments.map((attachment) => attachments.send(attachment))
30169
- );
29666
+ const results = await Promise.allSettled(draft.attachments.map((attachment) => attachments.send(attachment)));
30170
29667
  const failed = results.find((result) => result.status === "rejected");
30171
29668
  if (failed?.status === "rejected") throw failed.reason;
30172
29669
  if (!alive.current) return;
30173
- if (latest.current.activeSessionId !== id)
30174
- throw new Error("\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u8BF7\u8FD4\u56DE\u539F\u4F1A\u8BDD\u91CD\u65B0\u53D1\u9001\u3002");
29670
+ if (latest.current.activeSessionId !== id) throw new Error("\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u8BF7\u8FD4\u56DE\u539F\u4F1A\u8BDD\u91CD\u65B0\u53D1\u9001\u3002");
30175
29671
  assertChatSendable(latest.current, id);
30176
- const completed = results.flatMap(
30177
- (result) => result.status === "fulfilled" ? [result.value] : []
30178
- );
29672
+ const completed = results.flatMap((result) => result.status === "fulfilled" ? [result.value] : []);
30179
29673
  const files = attachments.take(completed);
30180
29674
  attachments.commit(completed);
30181
29675
  runtime.thread.composer.reset();
30182
29676
  void latest.current.sendMessage(draft.text, files).catch(() => void 0);
30183
29677
  } catch (error) {
30184
- if (alive.current && !(error instanceof DOMException && error.name === "AbortError"))
30185
- setNotice(error instanceof Error ? error.message : String(error));
29678
+ if (alive.current && !(error instanceof DOMException && error.name === "AbortError")) setNotice(error instanceof Error ? error.message : String(error));
30186
29679
  } finally {
30187
29680
  sendLock.current = false;
30188
29681
  if (alive.current) setSending(false);
@@ -30192,12 +29685,7 @@ function SessionRuntime({
30192
29685
  }
30193
29686
 
30194
29687
  // src/ui/attachment.aui.tsx
30195
- import {
30196
- useState as useState30,
30197
- isValidElement as isValidElement3,
30198
- createContext as createContext6,
30199
- useContext as useContext7
30200
- } from "react";
29688
+ import { useState as useState30, isValidElement as isValidElement3, createContext as createContext6, useContext as useContext7 } from "react";
30201
29689
 
30202
29690
  // src/ui/use-attachment-src.ts
30203
29691
  import { useEffect as useEffect27, useState as useState29 } from "react";
@@ -30218,9 +29706,7 @@ var useFileSrc = (file) => {
30218
29706
  };
30219
29707
  var useAttachmentSrc = () => {
30220
29708
  const file = useAuiState((s) => s.attachment.type === "image" ? s.attachment.file : void 0);
30221
- const src = useAuiState(
30222
- (s) => s.attachment.content?.find((part) => part.type === "image")?.image
30223
- );
29709
+ const src = useAuiState((s) => s.attachment.content?.find((part) => part.type === "image")?.image);
30224
29710
  return useFileSrc(file) ?? src;
30225
29711
  };
30226
29712
 
@@ -30233,69 +29719,26 @@ var usePreview = () => {
30233
29719
  };
30234
29720
  var AttachmentPreview = ({ src }) => {
30235
29721
  const [isLoaded, setIsLoaded] = useState30(false);
30236
- return /* @__PURE__ */ jsx79(
30237
- "img",
30238
- {
30239
- src,
30240
- alt: "\u9644\u4EF6\u9884\u89C8",
30241
- className: cn(
30242
- "block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none",
30243
- isLoaded ? "aui-attachment-preview-image-loaded opacity-100" : "aui-attachment-preview-image-loading opacity-0"
30244
- ),
30245
- onLoad: () => setIsLoaded(true)
30246
- }
30247
- );
29722
+ return /* @__PURE__ */ jsx79("img", { src, alt: "\u9644\u4EF6\u9884\u89C8", className: cn("block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none", isLoaded ? "aui-attachment-preview-image-loaded opacity-100" : "aui-attachment-preview-image-loading opacity-0"), onLoad: () => setIsLoaded(true) });
30248
29723
  };
30249
29724
  var AttachmentPreviewDialog = ({ children }) => {
30250
29725
  const src = usePreview();
30251
- if (!src) return /* @__PURE__ */ jsx79(Fragment9, { children });
29726
+ if (!src)
29727
+ return /* @__PURE__ */ jsx79(Fragment9, { children });
30252
29728
  return /* @__PURE__ */ jsxs19(Dialog2, { children: [
30253
29729
  /* @__PURE__ */ jsx79(DialogTrigger3, { className: cn("aui-attachment-preview-trigger cursor-zoom-in"), asChild: true, children: isValidElement3(children) ? children : /* @__PURE__ */ jsx79("button", { type: "button", children }) }),
30254
- /* @__PURE__ */ jsxs19(
30255
- DialogContent3,
30256
- {
30257
- className: cn(
30258
- "aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!"
30259
- ),
30260
- children: [
30261
- /* @__PURE__ */ jsx79(DialogTitle3, { className: cn("aui-sr-only sr-only"), children: "\u56FE\u7247\u9644\u4EF6\u9884\u89C8" }),
30262
- /* @__PURE__ */ jsx79(
30263
- "div",
30264
- {
30265
- className: cn(
30266
- "aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm"
30267
- ),
30268
- children: /* @__PURE__ */ jsx79(AttachmentPreview, { src })
30269
- }
30270
- )
30271
- ]
30272
- }
30273
- )
29730
+ /* @__PURE__ */ jsxs19(DialogContent3, { className: cn("aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!"), children: [
29731
+ /* @__PURE__ */ jsx79(DialogTitle3, { className: cn("aui-sr-only sr-only"), children: "\u56FE\u7247\u9644\u4EF6\u9884\u89C8" }),
29732
+ /* @__PURE__ */ jsx79("div", { className: cn("aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm"), children: /* @__PURE__ */ jsx79(AttachmentPreview, { src }) })
29733
+ ] })
30274
29734
  ] });
30275
29735
  };
30276
29736
  var AttachmentThumb = () => {
30277
29737
  const src = usePreview();
30278
29738
  const name2 = useAuiState((s) => s.attachment.name);
30279
- return /* @__PURE__ */ jsx79(Avatar3, { className: cn("aui-attachment-tile-avatar h-full w-full rounded-none"), children: src ? /* @__PURE__ */ jsx79(
30280
- "img",
30281
- {
30282
- src,
30283
- alt: name2,
30284
- className: cn("aui-attachment-tile-image h-full w-full rounded-none object-cover")
30285
- }
30286
- ) : /* @__PURE__ */ jsx79(AvatarFallback3, { children: /* @__PURE__ */ jsx79(
30287
- FileText,
30288
- {
30289
- className: cn(
30290
- "aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]"
30291
- )
30292
- }
30293
- ) }) });
29739
+ return /* @__PURE__ */ jsx79(Avatar3, { className: cn("aui-attachment-tile-avatar h-full w-full rounded-none"), children: src ? /* @__PURE__ */ jsx79("img", { src, alt: name2, className: cn("aui-attachment-tile-image h-full w-full rounded-none object-cover") }) : /* @__PURE__ */ jsx79(AvatarFallback3, { children: /* @__PURE__ */ jsx79(FileText, { className: cn("aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]") }) }) });
30294
29740
  };
30295
- function AttachmentUI({
30296
- preview,
30297
- children
30298
- }) {
29741
+ function AttachmentUI({ preview, children }) {
30299
29742
  return /* @__PURE__ */ jsx79(PreviewContext.Provider, { value: preview, children: /* @__PURE__ */ jsx79(AttachmentContent, { children }) });
30300
29743
  }
30301
29744
  var AttachmentContent = ({ children }) => {
@@ -30315,75 +29758,30 @@ var AttachmentContent = ({ children }) => {
30315
29758
  return type;
30316
29759
  }
30317
29760
  });
30318
- const uploadState = useAuiState(
30319
- (s) => s.attachment.status.type === "running" ? "uploading" : s.attachment.status.type === "incomplete" && s.attachment.status.reason === "error" ? "error" : void 0
30320
- );
29761
+ const uploadState = useAuiState((s) => s.attachment.status.type === "running" ? "uploading" : s.attachment.status.type === "incomplete" && s.attachment.status.reason === "error" ? "error" : void 0);
30321
29762
  const isUploading = uploadState === "uploading";
30322
29763
  const isError = uploadState === "error";
30323
- const errorMessage = useAuiState(
30324
- (s) => s.attachment.status.type === "incomplete" && s.attachment.status.reason === "error" ? s.attachment.status.message ?? "\u9644\u4EF6\u5904\u7406\u5931\u8D25" : void 0
30325
- );
29764
+ const errorMessage = useAuiState((s) => s.attachment.status.type === "incomplete" && s.attachment.status.reason === "error" ? s.attachment.status.message ?? "\u9644\u4EF6\u5904\u7406\u5931\u8D25" : void 0);
30326
29765
  return /* @__PURE__ */ jsx79(TooltipProvider2, { children: /* @__PURE__ */ jsxs19(Tooltip2, { children: [
30327
- /* @__PURE__ */ jsxs19(
30328
- AttachmentPrimitiveRoot,
30329
- {
30330
- className: cn(
30331
- "aui-attachment-root relative",
30332
- isComposer && "animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none",
30333
- isImage2 && !isComposer && "aui-attachment-root-message only:*:first:size-24"
30334
- ),
30335
- children: [
30336
- /* @__PURE__ */ jsx79(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx79(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsxs19(
30337
- "div",
30338
- {
30339
- className: cn(
30340
- "aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--nxf-composer-radius,1rem)-var(--nxf-composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10",
30341
- isError && "after:ring-destructive/60 dark:after:ring-destructive/60"
30342
- ),
30343
- role: "button",
30344
- tabIndex: 0,
30345
- onKeyDown: (e) => {
30346
- if (e.key === "Enter") {
30347
- e.preventDefault();
30348
- e.currentTarget.click();
30349
- } else if (e.key === " ") {
30350
- e.preventDefault();
30351
- }
30352
- },
30353
- onKeyUp: (e) => {
30354
- if (e.key === " ") e.currentTarget.click();
30355
- },
30356
- "aria-label": `${typeLabel}\u9644\u4EF6${isError ? "\uFF0C\u5904\u7406\u5931\u8D25" : isUploading ? "\uFF0C\u6B63\u5728\u5904\u7406" : ""}`,
30357
- children: [
30358
- /* @__PURE__ */ jsx79(AttachmentThumb, {}),
30359
- isUploading && /* @__PURE__ */ jsx79(
30360
- "div",
30361
- {
30362
- "aria-hidden": "true",
30363
- className: cn(
30364
- "aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none"
30365
- ),
30366
- children: /* @__PURE__ */ jsx79(LoaderCircle, { className: cn("text-muted-foreground size-4 animate-spin") })
30367
- }
30368
- ),
30369
- isError && /* @__PURE__ */ jsx79(
30370
- "div",
30371
- {
30372
- "aria-hidden": "true",
30373
- className: cn(
30374
- "aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none"
30375
- ),
30376
- children: /* @__PURE__ */ jsx79(CircleAlert, { className: cn("text-destructive size-4") })
30377
- }
30378
- )
30379
- ]
30380
- }
30381
- ) }) }),
30382
- isComposer && /* @__PURE__ */ jsx79(AttachmentRemove, {}),
30383
- children
30384
- ]
30385
- }
30386
- ),
29766
+ /* @__PURE__ */ jsxs19(AttachmentPrimitiveRoot, { className: cn("aui-attachment-root relative", isComposer && "animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none", isImage2 && !isComposer && "aui-attachment-root-message only:*:first:size-24"), children: [
29767
+ /* @__PURE__ */ jsx79(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx79(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsxs19("div", { className: cn("aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--nxf-composer-radius,1rem)-var(--nxf-composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10", isError && "after:ring-destructive/60 dark:after:ring-destructive/60"), role: "button", tabIndex: 0, onKeyDown: (e) => {
29768
+ if (e.key === "Enter") {
29769
+ e.preventDefault();
29770
+ e.currentTarget.click();
29771
+ } else if (e.key === " ") {
29772
+ e.preventDefault();
29773
+ }
29774
+ }, onKeyUp: (e) => {
29775
+ if (e.key === " ")
29776
+ e.currentTarget.click();
29777
+ }, "aria-label": `${typeLabel}\u9644\u4EF6${isError ? "\uFF0C\u5904\u7406\u5931\u8D25" : isUploading ? "\uFF0C\u6B63\u5728\u5904\u7406" : ""}`, children: [
29778
+ /* @__PURE__ */ jsx79(AttachmentThumb, {}),
29779
+ isUploading && /* @__PURE__ */ jsx79("div", { "aria-hidden": "true", className: cn("aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none"), children: /* @__PURE__ */ jsx79(LoaderCircle, { className: cn("text-muted-foreground size-4 animate-spin") }) }),
29780
+ isError && /* @__PURE__ */ jsx79("div", { "aria-hidden": "true", className: cn("aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none"), children: /* @__PURE__ */ jsx79(CircleAlert, { className: cn("text-destructive size-4") }) })
29781
+ ] }) }) }),
29782
+ isComposer && /* @__PURE__ */ jsx79(AttachmentRemove, {}),
29783
+ children
29784
+ ] }),
30387
29785
  /* @__PURE__ */ jsxs19(TooltipContent3, { side: "top", children: [
30388
29786
  /* @__PURE__ */ jsx79(AttachmentPrimitiveName, {}),
30389
29787
  errorMessage && /* @__PURE__ */ jsx79("p", { className: cn("aui-attachment-error-message"), children: errorMessage })
@@ -30392,18 +29790,7 @@ var AttachmentContent = ({ children }) => {
30392
29790
  };
30393
29791
  var AttachmentRemove = () => {
30394
29792
  const name2 = useAuiState((s) => s.attachment.name);
30395
- return /* @__PURE__ */ jsx79(AttachmentPrimitiveRemove, { asChild: true, children: /* @__PURE__ */ jsx79(
30396
- TooltipIconButton,
30397
- {
30398
- tooltip: "\u79FB\u9664\u9644\u4EF6",
30399
- "aria-label": `\u79FB\u9664 ${name2}`,
30400
- className: cn(
30401
- "aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none"
30402
- ),
30403
- side: "top",
30404
- children: /* @__PURE__ */ jsx79(X, { className: cn("aui-attachment-remove-icon size-3 stroke-[2.5]") })
30405
- }
30406
- ) });
29793
+ return /* @__PURE__ */ jsx79(AttachmentPrimitiveRemove, { asChild: true, children: /* @__PURE__ */ jsx79(TooltipIconButton, { tooltip: "\u79FB\u9664\u9644\u4EF6", "aria-label": `\u79FB\u9664 ${name2}`, className: cn("aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none"), side: "top", children: /* @__PURE__ */ jsx79(X, { className: cn("aui-attachment-remove-icon size-3 stroke-[2.5]") }) }) });
30407
29794
  };
30408
29795
 
30409
29796
  // src/assistant-components.tsx
@@ -45475,7 +44862,11 @@ function remarkGfm(options2) {
45475
44862
  import { memo as memo6, useRef as useRef33 } from "react";
45476
44863
 
45477
44864
  // src/ui/code-block.tsx
45478
- import { useEffect as useEffect29, useRef as useRef32, useState as useState32 } from "react";
44865
+ import {
44866
+ useEffect as useEffect29,
44867
+ useRef as useRef32,
44868
+ useState as useState32
44869
+ } from "react";
45479
44870
  import { jsx as jsx87, jsxs as jsxs23 } from "react/jsx-runtime";
45480
44871
  function CopyButton({
45481
44872
  getText,
@@ -45483,7 +44874,9 @@ function CopyButton({
45483
44874
  className
45484
44875
  }) {
45485
44876
  const [copied, setCopied] = useState32(false);
45486
- const copyTimer = useRef32(void 0);
44877
+ const copyTimer = useRef32(
44878
+ void 0
44879
+ );
45487
44880
  const unmounted = useRef32(false);
45488
44881
  useEffect29(() => {
45489
44882
  unmounted.current = false;
@@ -45539,33 +44932,15 @@ function CodeBlock({
45539
44932
  ),
45540
44933
  ...props,
45541
44934
  children: [
45542
- title ? /* @__PURE__ */ jsxs23(
45543
- "figcaption",
45544
- {
45545
- className: cn(
45546
- "border-foreground/10 flex h-9 shrink-0 items-center justify-between gap-2 border-b py-0 ps-3.5 pe-2"
45547
- ),
45548
- children: [
45549
- /* @__PURE__ */ jsx87(
45550
- "span",
45551
- {
45552
- className: cn(
45553
- "text-muted-foreground min-w-0 truncate font-mono text-[11px] font-medium tracking-wide"
45554
- ),
45555
- children: title
45556
- }
45557
- ),
45558
- /* @__PURE__ */ jsx87(CopyButton, { getText, onCopied })
45559
- ]
45560
- }
45561
- ) : /* @__PURE__ */ jsx87(
44935
+ title ? /* @__PURE__ */ jsxs23("figcaption", { className: cn("border-foreground/10 flex h-9 shrink-0 items-center justify-between gap-2 border-b py-0 ps-3.5 pe-2"), children: [
44936
+ /* @__PURE__ */ jsx87("span", { className: cn("text-muted-foreground min-w-0 truncate font-mono text-[11px] font-medium tracking-wide"), children: title }),
44937
+ /* @__PURE__ */ jsx87(CopyButton, { getText, onCopied })
44938
+ ] }) : /* @__PURE__ */ jsx87(
45562
44939
  CopyButton,
45563
44940
  {
45564
44941
  getText,
45565
44942
  onCopied,
45566
- className: cn(
45567
- "bg-background/80 absolute top-2 right-2 z-10 opacity-0 backdrop-blur-sm transition-opacity group-hover/code:opacity-100 focus-visible:opacity-100 [@media(pointer:coarse)]:opacity-100"
45568
- )
44943
+ className: cn("bg-background/80 absolute top-2 right-2 z-10 opacity-0 backdrop-blur-sm transition-opacity group-hover/code:opacity-100 focus-visible:opacity-100 [@media(pointer:coarse)]:opacity-100")
45569
44944
  }
45570
44945
  ),
45571
44946
  /* @__PURE__ */ jsx87(
@@ -45604,32 +44979,24 @@ var useCopyToClipboard = ({ copiedDuration = 3e3 } = {}) => {
45604
44979
  if (!value || typeof navigator === "undefined" || !navigator.clipboard) {
45605
44980
  return;
45606
44981
  }
45607
- navigator.clipboard.writeText(value).then(
45608
- () => {
45609
- setIsCopied(true);
45610
- setTimeout(() => setIsCopied(false), copiedDuration);
45611
- },
45612
- () => {
45613
- }
45614
- );
44982
+ navigator.clipboard.writeText(value).then(() => {
44983
+ setIsCopied(true);
44984
+ setTimeout(() => setIsCopied(false), copiedDuration);
44985
+ }, () => {
44986
+ });
45615
44987
  };
45616
44988
  return { isCopied, copyToClipboard };
45617
44989
  };
45618
44990
 
45619
44991
  // src/ui/markdown-text.tsx
45620
44992
  import { jsx as jsx88, jsxs as jsxs24 } from "react/jsx-runtime";
45621
- var MarkdownTextImpl = () => /* @__PURE__ */ jsx88(
45622
- MarkdownTextPrimitive,
45623
- {
45624
- remarkPlugins: [remarkGfm],
45625
- skipHtml: true,
45626
- className: cn("aui-md"),
45627
- components: defaultComponents2,
45628
- defer: true
45629
- }
45630
- );
44993
+ var MarkdownTextImpl = () => /* @__PURE__ */ jsx88(MarkdownTextPrimitive, { remarkPlugins: [remarkGfm], skipHtml: true, className: cn("aui-md"), components: defaultComponents2, defer: true });
45631
44994
  var MarkdownText = memo6(MarkdownTextImpl);
45632
- function MarkdownTable({ className, children, ...props }) {
44995
+ function MarkdownTable({
44996
+ className,
44997
+ children,
44998
+ ...props
44999
+ }) {
45633
45000
  const ref = useRef33(null);
45634
45001
  const { isCopied, copyToClipboard } = useCopyToClipboard();
45635
45002
  const copy = () => {
@@ -45653,37 +45020,19 @@ function MarkdownTable({ className, children, ...props }) {
45653
45020
  );
45654
45021
  };
45655
45022
  return /* @__PURE__ */ jsxs24("figure", { className: cn("border-foreground/10 rounded-document my-3 border"), children: [
45656
- /* @__PURE__ */ jsxs24(
45657
- "div",
45658
- {
45659
- className: cn(
45660
- "border-foreground/10 bg-foreground/[0.025] dark:bg-foreground/[0.04] rounded-t-document flex h-9 items-center justify-between border-b px-3"
45661
- ),
45662
- children: [
45663
- /* @__PURE__ */ jsx88(
45664
- "span",
45665
- {
45666
- className: cn(
45667
- "text-muted-foreground font-mono text-[11px] [font-variant-ligatures:none]"
45668
- ),
45669
- children: "\u8868\u683C"
45670
- }
45671
- ),
45672
- /* @__PURE__ */ jsx88(
45673
- "button",
45674
- {
45675
- type: "button",
45676
- onClick: copy,
45677
- "aria-label": "\u590D\u5236\u8868\u683C Markdown",
45678
- className: cn(
45679
- "text-muted-foreground hover:text-foreground rounded-control grid size-6 place-items-center transition-colors"
45680
- ),
45681
- children: isCopied ? /* @__PURE__ */ jsx88(Check, { className: cn("size-3.5") }) : /* @__PURE__ */ jsx88(Copy, { className: cn("size-3.5") })
45682
- }
45683
- )
45684
- ]
45685
- }
45686
- ),
45023
+ /* @__PURE__ */ jsxs24("div", { className: cn("border-foreground/10 bg-foreground/[0.025] dark:bg-foreground/[0.04] rounded-t-document flex h-9 items-center justify-between border-b px-3"), children: [
45024
+ /* @__PURE__ */ jsx88("span", { className: cn("text-muted-foreground font-mono text-[11px] [font-variant-ligatures:none]"), children: "\u8868\u683C" }),
45025
+ /* @__PURE__ */ jsx88(
45026
+ "button",
45027
+ {
45028
+ type: "button",
45029
+ onClick: copy,
45030
+ "aria-label": "\u590D\u5236\u8868\u683C Markdown",
45031
+ className: cn("text-muted-foreground hover:text-foreground rounded-control grid size-6 place-items-center transition-colors"),
45032
+ children: isCopied ? /* @__PURE__ */ jsx88(Check, { className: cn("size-3.5") }) : /* @__PURE__ */ jsx88(Copy, { className: cn("size-3.5") })
45033
+ }
45034
+ )
45035
+ ] }),
45687
45036
  /* @__PURE__ */ jsx88("div", { className: cn("overflow-x-auto"), children: /* @__PURE__ */ jsx88(
45688
45037
  "table",
45689
45038
  {
@@ -45701,149 +45050,29 @@ function MarkdownTable({ className, children, ...props }) {
45701
45050
  var SyntaxHighlighter = ({ language, code: code4 }) => /* @__PURE__ */ jsx88(CodeBlock, { title: language || void 0, copyText: code4, className: cn("my-3"), children: /* @__PURE__ */ jsx88("pre", { children: /* @__PURE__ */ jsx88("code", { children: code4 }) }) });
45702
45051
  var NoCodeHeader = () => null;
45703
45052
  var defaultComponents2 = memoizeMarkdownComponents({
45704
- h1: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45705
- "h1",
45706
- {
45707
- className: cn(
45708
- "aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0",
45709
- className
45710
- ),
45711
- ...props
45712
- }
45713
- ),
45714
- h2: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45715
- "h2",
45716
- {
45717
- className: cn(
45718
- "aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0",
45719
- className
45720
- ),
45721
- ...props
45722
- }
45723
- ),
45724
- h3: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45725
- "h3",
45726
- {
45727
- className: cn(
45728
- "aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0",
45729
- className
45730
- ),
45731
- ...props
45732
- }
45733
- ),
45734
- h4: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45735
- "h4",
45736
- {
45737
- className: cn(
45738
- "aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0",
45739
- className
45740
- ),
45741
- ...props
45742
- }
45743
- ),
45744
- h5: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45745
- "h5",
45746
- {
45747
- className: cn("aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0", className),
45748
- ...props
45749
- }
45750
- ),
45751
- h6: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45752
- "h6",
45753
- {
45754
- className: cn("aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0", className),
45755
- ...props
45756
- }
45757
- ),
45053
+ h1: ({ className, ...props }) => /* @__PURE__ */ jsx88("h1", { className: cn("aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0", className), ...props }),
45054
+ h2: ({ className, ...props }) => /* @__PURE__ */ jsx88("h2", { className: cn("aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0", className), ...props }),
45055
+ h3: ({ className, ...props }) => /* @__PURE__ */ jsx88("h3", { className: cn("aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0", className), ...props }),
45056
+ h4: ({ className, ...props }) => /* @__PURE__ */ jsx88("h4", { className: cn("aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0", className), ...props }),
45057
+ h5: ({ className, ...props }) => /* @__PURE__ */ jsx88("h5", { className: cn("aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0", className), ...props }),
45058
+ h6: ({ className, ...props }) => /* @__PURE__ */ jsx88("h6", { className: cn("aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0", className), ...props }),
45758
45059
  p: ({ className, ...props }) => /* @__PURE__ */ jsx88("p", { className: cn("aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0", className), ...props }),
45759
- a: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45760
- "a",
45761
- {
45762
- className: cn(
45763
- "aui-md-a text-primary hover:text-primary/80 underline underline-offset-2",
45764
- className
45765
- ),
45766
- ...props
45767
- }
45768
- ),
45769
- blockquote: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45770
- "blockquote",
45771
- {
45772
- className: cn(
45773
- "aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4",
45774
- className
45775
- ),
45776
- ...props
45777
- }
45778
- ),
45779
- ul: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45780
- "ul",
45781
- {
45782
- className: cn(
45783
- "aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1",
45784
- className
45785
- ),
45786
- ...props
45787
- }
45788
- ),
45789
- ol: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45790
- "ol",
45791
- {
45792
- className: cn(
45793
- "aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1",
45794
- className
45795
- ),
45796
- ...props
45797
- }
45798
- ),
45060
+ a: ({ className, ...props }) => /* @__PURE__ */ jsx88("a", { className: cn("aui-md-a text-primary hover:text-primary/80 underline underline-offset-2", className), ...props }),
45061
+ blockquote: ({ className, ...props }) => /* @__PURE__ */ jsx88("blockquote", { className: cn("aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4", className), ...props }),
45062
+ ul: ({ className, ...props }) => /* @__PURE__ */ jsx88("ul", { className: cn("aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1", className), ...props }),
45063
+ ol: ({ className, ...props }) => /* @__PURE__ */ jsx88("ol", { className: cn("aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1", className), ...props }),
45799
45064
  hr: ({ className, ...props }) => /* @__PURE__ */ jsx88("hr", { className: cn("aui-md-hr border-muted-foreground/20 my-3", className), ...props }),
45800
45065
  table: ({ className, ...props }) => /* @__PURE__ */ jsx88(MarkdownTable, { className, ...props }),
45801
- th: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45802
- "th",
45803
- {
45804
- className: cn(
45805
- "aui-md-th border-foreground/10 border-b px-3 py-1.5 text-start font-medium [[align=center]]:text-center [[align=right]]:text-right",
45806
- className
45807
- ),
45808
- ...props
45809
- }
45810
- ),
45811
- td: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45812
- "td",
45813
- {
45814
- className: cn(
45815
- "aui-md-td border-foreground/10 border-b px-3 py-1.5 text-start [[align=center]]:text-center [[align=right]]:text-right",
45816
- className
45817
- ),
45818
- ...props
45819
- }
45820
- ),
45066
+ th: ({ className, ...props }) => /* @__PURE__ */ jsx88("th", { className: cn("aui-md-th border-foreground/10 border-b px-3 py-1.5 text-start font-medium [[align=center]]:text-center [[align=right]]:text-right", className), ...props }),
45067
+ td: ({ className, ...props }) => /* @__PURE__ */ jsx88("td", { className: cn("aui-md-td border-foreground/10 border-b px-3 py-1.5 text-start [[align=center]]:text-center [[align=right]]:text-right", className), ...props }),
45821
45068
  tr: ({ className, ...props }) => /* @__PURE__ */ jsx88("tr", { className: cn("aui-md-tr m-0 p-0", className), ...props }),
45822
45069
  li: ({ className, ...props }) => /* @__PURE__ */ jsx88("li", { className: cn("aui-md-li leading-relaxed", className), ...props }),
45823
45070
  strong: ({ className, ...props }) => /* @__PURE__ */ jsx88("strong", { className: cn("aui-md-strong font-semibold", className), ...props }),
45824
45071
  sup: ({ className, ...props }) => /* @__PURE__ */ jsx88("sup", { className: cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline", className), ...props }),
45825
- pre: ({ className, ...props }) => /* @__PURE__ */ jsx88(
45826
- "pre",
45827
- {
45828
- className: cn(
45829
- "aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed",
45830
- className
45831
- ),
45832
- ...props
45833
- }
45834
- ),
45072
+ pre: ({ className, ...props }) => /* @__PURE__ */ jsx88("pre", { className: cn("aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed", className), ...props }),
45835
45073
  code: function Code({ className, ...props }) {
45836
45074
  const isCodeBlock = useIsMarkdownCodeBlock();
45837
- return /* @__PURE__ */ jsx88(
45838
- "code",
45839
- {
45840
- className: cn(
45841
- !isCodeBlock && "aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]",
45842
- className
45843
- ),
45844
- ...props
45845
- }
45846
- );
45075
+ return /* @__PURE__ */ jsx88("code", { className: cn(!isCodeBlock && "aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]", className), ...props });
45847
45076
  },
45848
45077
  CodeHeader: NoCodeHeader,
45849
45078
  SyntaxHighlighter
@@ -45860,38 +45089,22 @@ function ComposerVoice({ recording }) {
45860
45089
  const timer = setInterval(() => setTick((value) => value + 1), 100);
45861
45090
  return () => clearInterval(timer);
45862
45091
  }, [recording]);
45863
- return /* @__PURE__ */ jsx89(
45864
- "div",
45092
+ return /* @__PURE__ */ jsx89("div", { "data-slot": "composer-voice", "data-recording": recording || void 0, className: cn("flex h-7 min-w-0 flex-1 items-center overflow-hidden px-2"), children: /* @__PURE__ */ jsx89("div", { className: cn("flex h-6 w-full items-center justify-between overflow-hidden"), "aria-hidden": true, children: Array.from({ length: barCount }, (_, index5) => /* @__PURE__ */ jsx89(
45093
+ "span",
45865
45094
  {
45866
- "data-slot": "composer-voice",
45867
- "data-recording": recording || void 0,
45868
- className: cn("flex h-7 min-w-0 flex-1 items-center overflow-hidden px-2"),
45869
- children: /* @__PURE__ */ jsx89(
45870
- "div",
45871
- {
45872
- className: cn("flex h-6 w-full items-center justify-between overflow-hidden"),
45873
- "aria-hidden": true,
45874
- children: Array.from({ length: barCount }, (_, index5) => /* @__PURE__ */ jsx89(
45875
- "span",
45876
- {
45877
- className: cn(
45878
- "w-0.5 shrink-0 rounded-full transition-[height,background-color] duration-150 motion-reduce:transition-none",
45879
- recording ? "bg-foreground/50" : "bg-foreground/25"
45880
- ),
45881
- style: {
45882
- height: recording ? 5 + Math.abs(Math.sin(index5 * 1.35 + tick * 0.55)) * 13 : 3
45883
- }
45884
- },
45885
- index5
45886
- ))
45887
- }
45888
- )
45889
- }
45890
- );
45095
+ className: cn("w-0.5 shrink-0 rounded-full transition-[height,background-color] duration-150 motion-reduce:transition-none", recording ? "bg-foreground/50" : "bg-foreground/25"),
45096
+ style: { height: recording ? 5 + Math.abs(Math.sin(index5 * 1.35 + tick * 0.55)) * 13 : 3 }
45097
+ },
45098
+ index5
45099
+ )) }) });
45891
45100
  }
45892
45101
 
45893
45102
  // src/ui/tool-group.aui.tsx
45894
- import { useCallback as useCallback19, useRef as useRef34, useState as useState35 } from "react";
45103
+ import {
45104
+ useCallback as useCallback19,
45105
+ useRef as useRef34,
45106
+ useState as useState35
45107
+ } from "react";
45895
45108
 
45896
45109
  // src/ui/collapsible.tsx
45897
45110
  import { forwardRef as forwardRef31 } from "react";
@@ -45951,7 +45164,11 @@ function ToolGroupRoot({
45951
45164
  "data-variant": variant ?? "outline",
45952
45165
  open: isOpen,
45953
45166
  onOpenChange: handleOpenChange,
45954
- className: cn(toolGroupVariants({ variant }), "group/tool-group-root", className),
45167
+ className: cn(
45168
+ toolGroupVariants({ variant }),
45169
+ "group/tool-group-root",
45170
+ className
45171
+ ),
45955
45172
  style: {
45956
45173
  "--nxf-animation-duration": `${ANIMATION_DURATION}ms`
45957
45174
  },
@@ -46004,18 +45221,17 @@ function ToolGroupContent({
46004
45221
 
46005
45222
  // src/ui/home-demo/surfaces.tsx
46006
45223
  import { jsx as jsx92 } from "react/jsx-runtime";
46007
- function ShimmerLabel({
46008
- active = true,
46009
- className,
46010
- ...props
46011
- }) {
45224
+ function ShimmerLabel({ active = true, className, ...props }) {
46012
45225
  return /* @__PURE__ */ jsx92("span", { className: cn(active && "shimmer motion-reduce:animate-none", className), ...props });
46013
45226
  }
46014
45227
 
46015
45228
  // src/ui/home-demo/trace-line.tsx
46016
45229
  import { useEffect as useEffect31, useRef as useRef35, useState as useState36 } from "react";
46017
45230
  import { Fragment as Fragment13, jsx as jsx93, jsxs as jsxs25 } from "react/jsx-runtime";
46018
- function TraceMarker({ live, className }) {
45231
+ function TraceMarker({
45232
+ live,
45233
+ className
45234
+ }) {
46019
45235
  return /* @__PURE__ */ jsx93(
46020
45236
  "span",
46021
45237
  {
@@ -46053,25 +45269,17 @@ function TraceLine({
46053
45269
  detail,
46054
45270
  meta
46055
45271
  }) {
46056
- return /* @__PURE__ */ jsxs25(
46057
- "div",
46058
- {
46059
- className: cn(
46060
- "my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]"
46061
- ),
46062
- children: [
46063
- /* @__PURE__ */ jsx93(TraceMarker, { live }),
46064
- /* @__PURE__ */ jsx93("span", { className: cn("text-muted-foreground min-w-0 flex-1 truncate"), children: live ? /* @__PURE__ */ jsxs25(ShimmerLabel, { children: [
46065
- label,
46066
- detail ? ` ${detail}` : null
46067
- ] }) : /* @__PURE__ */ jsxs25(Fragment13, { children: [
46068
- label,
46069
- detail ? ` ${detail}` : null
46070
- ] }) }),
46071
- meta ? /* @__PURE__ */ jsx93("span", { className: cn("text-muted-foreground/50 shrink-0"), children: meta }) : null
46072
- ]
46073
- }
46074
- );
45272
+ return /* @__PURE__ */ jsxs25("div", { className: cn("my-1 flex items-baseline gap-2 font-mono text-[12px] [font-variant-ligatures:none]"), children: [
45273
+ /* @__PURE__ */ jsx93(TraceMarker, { live }),
45274
+ /* @__PURE__ */ jsx93("span", { className: cn("text-muted-foreground min-w-0 flex-1 truncate"), children: live ? /* @__PURE__ */ jsxs25(ShimmerLabel, { children: [
45275
+ label,
45276
+ detail ? ` ${detail}` : null
45277
+ ] }) : /* @__PURE__ */ jsxs25(Fragment13, { children: [
45278
+ label,
45279
+ detail ? ` ${detail}` : null
45280
+ ] }) }),
45281
+ meta ? /* @__PURE__ */ jsx93("span", { className: cn("text-muted-foreground/50 shrink-0"), children: meta }) : null
45282
+ ] });
46075
45283
  }
46076
45284
 
46077
45285
  // src/ui/home-demo/trace.tsx
@@ -46082,71 +45290,35 @@ function DisclosureTrigger({
46082
45290
  label,
46083
45291
  detail
46084
45292
  }) {
46085
- return /* @__PURE__ */ jsxs26(
46086
- CollapsibleTrigger3,
46087
- {
46088
- "data-slot": "tool-group-trigger",
46089
- className: cn(
46090
- "group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline"
46091
- ),
46092
- children: [
46093
- /* @__PURE__ */ jsx94(TraceMarker, { live, className: cn("group-data-[state=open]/trigger:rotate-90") }),
46094
- /* @__PURE__ */ jsx94(
46095
- "span",
46096
- {
46097
- className: cn(
46098
- "text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors"
46099
- ),
46100
- children: live ? /* @__PURE__ */ jsxs26(ShimmerLabel, { children: [
46101
- label,
46102
- detail ? ` ${detail}` : null
46103
- ] }) : /* @__PURE__ */ jsxs26(Fragment14, { children: [
46104
- label,
46105
- detail ? ` ${detail}` : null
46106
- ] })
46107
- }
46108
- )
46109
- ]
46110
- }
46111
- );
45293
+ return /* @__PURE__ */ jsxs26(CollapsibleTrigger3, { "data-slot": "tool-group-trigger", className: cn("group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline"), children: [
45294
+ /* @__PURE__ */ jsx94(
45295
+ TraceMarker,
45296
+ {
45297
+ live,
45298
+ className: cn("group-data-[state=open]/trigger:rotate-90")
45299
+ }
45300
+ ),
45301
+ /* @__PURE__ */ jsx94("span", { className: cn("text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors"), children: live ? /* @__PURE__ */ jsxs26(ShimmerLabel, { children: [
45302
+ label,
45303
+ detail ? ` ${detail}` : null
45304
+ ] }) : /* @__PURE__ */ jsxs26(Fragment14, { children: [
45305
+ label,
45306
+ detail ? ` ${detail}` : null
45307
+ ] }) })
45308
+ ] });
46112
45309
  }
46113
- function ToolCall({
46114
- toolName,
46115
- args,
46116
- argsText,
46117
- result,
46118
- status,
46119
- isError,
46120
- showDetails,
46121
- presentation
46122
- }) {
45310
+ function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }) {
46123
45311
  const tool2 = presentation?.type === "tool" ? presentation : void 0;
46124
45312
  const error = tool2?.error;
46125
45313
  const label = tool2?.toolState === "unknown" ? "Result unknown" : tool2?.toolState === "rejected" ? "Rejected" : tool2?.toolState === "cancelled" ? "Stopped" : tool2?.toolState === "not_started" ? "Not started" : tool2?.toolState === "failed" || isError ? "Failed" : void 0;
46126
45314
  const live = !label && status?.type === "running";
46127
45315
  const duration = useToolDuration(live);
46128
- const line = /* @__PURE__ */ jsx94(
46129
- TraceLine,
46130
- {
46131
- live,
46132
- label: label ?? (live ? "running" : "ran"),
46133
- detail: toolName,
46134
- ...duration === null ? {} : { meta: formatDuration(duration) }
46135
- }
46136
- );
46137
- const reason = error && !error.parentErrorId && error.scope === "tool" && error.execution !== "unknown" ? /* @__PURE__ */ jsx94(
46138
- "p",
46139
- {
46140
- role: "alert",
46141
- className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"),
46142
- children: error.userMessage
46143
- }
46144
- ) : null;
46145
- if (!showDetails)
46146
- return /* @__PURE__ */ jsxs26(Fragment14, { children: [
46147
- line,
46148
- reason
46149
- ] });
45316
+ const line = /* @__PURE__ */ jsx94(TraceLine, { live, label: label ?? (live ? "running" : "ran"), detail: toolName, ...duration === null ? {} : { meta: formatDuration(duration) } });
45317
+ const reason = error && !error.parentErrorId && error.scope === "tool" && error.execution !== "unknown" ? /* @__PURE__ */ jsx94("p", { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: error.userMessage }) : null;
45318
+ if (!showDetails) return /* @__PURE__ */ jsxs26(Fragment14, { children: [
45319
+ line,
45320
+ reason
45321
+ ] });
46150
45322
  return /* @__PURE__ */ jsxs26(Fragment14, { children: [
46151
45323
  line,
46152
45324
  reason,
@@ -46230,7 +45402,10 @@ var ReasoningRoot = forwardRef32(function ReasoningRoot2({
46230
45402
  "data-variant": variant,
46231
45403
  open: isOpen,
46232
45404
  onOpenChange: handleOpenChange,
46233
- className: cn("group/reasoning-root", reasoningVariants({ variant, className })),
45405
+ className: cn(
45406
+ "group/reasoning-root",
45407
+ reasoningVariants({ variant, className })
45408
+ ),
46234
45409
  style: {
46235
45410
  "--nxf-animation-duration": `${ANIMATION_DURATION2}ms`
46236
45411
  },
@@ -46307,7 +45482,11 @@ function ReasoningContent({
46307
45482
  }
46308
45483
  );
46309
45484
  }
46310
- function ReasoningText({ className, children, ...props }) {
45485
+ function ReasoningText({
45486
+ className,
45487
+ children,
45488
+ ...props
45489
+ }) {
46311
45490
  const isPreview = useContext10(ReasoningPreviewContext);
46312
45491
  const scrollRef = useRef36(null);
46313
45492
  const contentRef = useRef36(null);
@@ -46319,7 +45498,9 @@ function ReasoningText({ className, children, ...props }) {
46319
45498
  let pinned = true;
46320
45499
  let lastScrollTop = scrollEl.scrollTop;
46321
45500
  let lastScrollHeight = scrollEl.scrollHeight;
46322
- const isAtBottom = () => Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) <= 1 || scrollEl.scrollHeight <= scrollEl.clientHeight;
45501
+ const isAtBottom = () => Math.abs(
45502
+ scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight
45503
+ ) <= 1 || scrollEl.scrollHeight <= scrollEl.clientHeight;
46323
45504
  const pin = () => {
46324
45505
  if (!pinned) return;
46325
45506
  scrollEl.scrollTop = scrollEl.scrollHeight;
@@ -46371,7 +45552,11 @@ function ReasoningText({ className, children, ...props }) {
46371
45552
 
46372
45553
  // src/ui/reasoning.aui.tsx
46373
45554
  import { jsx as jsx96 } from "react/jsx-runtime";
46374
- function ReasoningRoot3({ ref, onAnimationStart, ...props }) {
45555
+ function ReasoningRoot3({
45556
+ ref,
45557
+ onAnimationStart,
45558
+ ...props
45559
+ }) {
46375
45560
  const collapsibleRef = useRef37(null);
46376
45561
  const lockScroll = useScrollLock(collapsibleRef, ANIMATION_DURATION2);
46377
45562
  const handleAnimationStart = useCallback21(() => {
@@ -46389,7 +45574,14 @@ function ReasoningRoot3({ ref, onAnimationStart, ...props }) {
46389
45574
  },
46390
45575
  [ref]
46391
45576
  );
46392
- return /* @__PURE__ */ jsx96(ReasoningRoot, { ref: composedRef, onAnimationStart: handleAnimationStart, ...props });
45577
+ return /* @__PURE__ */ jsx96(
45578
+ ReasoningRoot,
45579
+ {
45580
+ ref: composedRef,
45581
+ onAnimationStart: handleAnimationStart,
45582
+ ...props
45583
+ }
45584
+ );
46393
45585
  }
46394
45586
  var ReasoningImpl = () => /* @__PURE__ */ jsx96(MarkdownText, {});
46395
45587
  var Reasoning = memo7(ReasoningImpl);
@@ -46398,10 +45590,7 @@ Reasoning.displayName = "Reasoning";
46398
45590
  // src/assistant-components.tsx
46399
45591
  import { attachmentAccept } from "./attachments.js";
46400
45592
  import { Fragment as Fragment15, jsx as jsx97, jsxs as jsxs28 } from "react/jsx-runtime";
46401
- function AttachmentTile({
46402
- binding,
46403
- savedPreview
46404
- }) {
45593
+ function AttachmentTile({ binding, savedPreview }) {
46405
45594
  const attachment = useAuiState((s) => s.attachment);
46406
45595
  const preview = binding?.attachments.preview(attachment.id) ?? savedPreview ?? attachment.content?.find((part) => part.type === "image")?.image;
46407
45596
  return /* @__PURE__ */ jsx97(AttachmentUI, { preview, children: /* @__PURE__ */ jsxs28("div", { className: cn("flex max-w-40 flex-col text-xs wrap-anywhere"), children: [
@@ -46411,15 +45600,7 @@ function AttachmentTile({
46411
45600
  attachment.status.type === "incomplete" ? /* @__PURE__ */ jsx97("small", { className: cn("text-destructive"), role: "alert", children: attachment.status.message ?? "\u9644\u4EF6\u5904\u7406\u5931\u8D25" }) : null
46412
45601
  ] }) });
46413
45602
  }
46414
- function AssistantComposer({
46415
- binding,
46416
- options: options2,
46417
- placeholder,
46418
- suggestion,
46419
- busy,
46420
- cancelling,
46421
- cancel
46422
- }) {
45603
+ function AssistantComposer({ binding, options: options2, placeholder, suggestion, busy, cancelling, cancel }) {
46423
45604
  const input = useRef38(null);
46424
45605
  const sending = binding.sending;
46425
45606
  const voiceBusy = binding.voice.status !== "idle";
@@ -46427,14 +45608,9 @@ function AssistantComposer({
46427
45608
  const voiceDisabledReason = busy ? "\u4EFB\u52A1\u6267\u884C\u4E2D\uFF0C\u6682\u4E0D\u80FD\u5F55\u97F3" : sending ? "\u6B63\u5728\u5904\u7406\u9644\u4EF6\uFF0C\u6682\u4E0D\u80FD\u5F55\u97F3" : void 0;
46428
45609
  const empty3 = useAuiState((state) => state.composer.text.length === 0);
46429
45610
  const nextMessage = !busy && !inputDisabled && empty3 ? suggestion : void 0;
46430
- const showCancel = useAuiState(
46431
- (state) => busy && (state.thread.isRunning || state.composer.isEmpty)
46432
- );
45611
+ const showCancel = useAuiState((state) => busy && (state.thread.isRunning || state.composer.isEmpty));
46433
45612
  const addFiles = (files) => {
46434
- for (const file of files)
46435
- void binding.runtime.thread.composer.addAttachment(file).catch(
46436
- (error) => binding.setNotice(error instanceof Error ? error.message : String(error))
46437
- );
45613
+ for (const file of files) void binding.runtime.thread.composer.addAttachment(file).catch((error) => binding.setNotice(error instanceof Error ? error.message : String(error)));
46438
45614
  };
46439
45615
  return /* @__PURE__ */ jsxs28(
46440
45616
  Composer,
@@ -46462,16 +45638,7 @@ function AssistantComposer({
46462
45638
  },
46463
45639
  actions: /* @__PURE__ */ jsxs28(Fragment15, { children: [
46464
45640
  voiceBusy ? /* @__PURE__ */ jsx97("span", { role: "status", className: cn("sr-only"), children: binding.voice.status === "starting" ? "\u6B63\u5728\u51C6\u5907\u8BED\u97F3\u8F93\u5165\uFF0C\u8BF7\u786E\u8BA4\u9EA6\u514B\u98CE\u5DF2\u6388\u6743\u2026" : binding.voice.status === "transcribing" ? "\u6B63\u5728\u8BC6\u522B\uFF0C\u8BF7\u7A0D\u5019\u2026" : "\u6B63\u5728\u5F55\u97F3" }) : null,
46465
- voiceBusy ? /* @__PURE__ */ jsx97(
46466
- TooltipIconButton,
46467
- {
46468
- tooltip: "\u53D6\u6D88\u5F55\u97F3",
46469
- "aria-label": "\u53D6\u6D88\u8BED\u97F3\u8F93\u5165",
46470
- className: cn("size-7 shrink-0"),
46471
- onClick: binding.voice.cancel,
46472
- children: /* @__PURE__ */ jsx97(X, { className: cn("size-4") })
46473
- }
46474
- ) : options2 !== false ? /* @__PURE__ */ jsxs28(Fragment15, { children: [
45641
+ voiceBusy ? /* @__PURE__ */ jsx97(TooltipIconButton, { tooltip: "\u53D6\u6D88\u5F55\u97F3", "aria-label": "\u53D6\u6D88\u8BED\u97F3\u8F93\u5165", className: cn("size-7 shrink-0"), onClick: binding.voice.cancel, children: /* @__PURE__ */ jsx97(X, { className: cn("size-4") }) }) : options2 !== false ? /* @__PURE__ */ jsxs28(Fragment15, { children: [
46475
45642
  /* @__PURE__ */ jsx97(
46476
45643
  "input",
46477
45644
  {
@@ -46487,118 +45654,33 @@ function AssistantComposer({
46487
45654
  }
46488
45655
  }
46489
45656
  ),
46490
- /* @__PURE__ */ jsx97(
46491
- "button",
46492
- {
46493
- type: "button",
46494
- className: cn(
46495
- "text-muted-foreground hover:text-foreground rounded-control grid size-7 shrink-0 place-items-center transition-colors"
46496
- ),
46497
- "aria-label": "\u6DFB\u52A0\u9644\u4EF6",
46498
- disabled: inputDisabled,
46499
- onClick: () => input.current?.click(),
46500
- children: /* @__PURE__ */ jsx97(Plus, { className: cn("size-4") })
46501
- }
46502
- )
45657
+ /* @__PURE__ */ jsx97("button", { type: "button", className: cn("text-muted-foreground hover:text-foreground rounded-control grid size-7 shrink-0 place-items-center transition-colors"), "aria-label": "\u6DFB\u52A0\u9644\u4EF6", disabled: inputDisabled, onClick: () => input.current?.click(), children: /* @__PURE__ */ jsx97(Plus, { className: cn("size-4") }) })
46503
45658
  ] }) : /* @__PURE__ */ jsx97("span", {}),
46504
45659
  voiceBusy ? /* @__PURE__ */ jsx97(ComposerVoice, { recording: binding.voice.status === "recording" }) : null,
46505
45660
  /* @__PURE__ */ jsxs28("div", { className: cn("flex shrink-0 items-center gap-1"), children: [
46506
45661
  /* @__PURE__ */ jsxs28(AuiIf, { condition: (state) => state.thread.capabilities.dictation, children: [
46507
45662
  /* @__PURE__ */ jsx97(AuiIf, { condition: (state) => state.composer.dictation == null, children: /* @__PURE__ */ jsx97(TooltipProvider2, { delayDuration: 0, children: /* @__PURE__ */ jsxs28(Tooltip2, { children: [
46508
- /* @__PURE__ */ jsx97(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx97(
46509
- "span",
46510
- {
46511
- className: cn("inline-flex"),
46512
- tabIndex: voiceDisabledReason ? 0 : void 0,
46513
- "aria-label": voiceDisabledReason,
46514
- children: /* @__PURE__ */ jsx97(ComposerPrimitiveDictate, { asChild: true, disabled: busy || sending, children: /* @__PURE__ */ jsx97(
46515
- Button,
46516
- {
46517
- variant: "ghost",
46518
- size: "icon",
46519
- "aria-label": "\u5F00\u59CB\u8BED\u97F3\u8F93\u5165",
46520
- "aria-description": voiceDisabledReason,
46521
- className: cn("size-7 p-1"),
46522
- children: /* @__PURE__ */ jsx97(Mic, { className: cn("size-4") })
46523
- }
46524
- ) })
46525
- }
46526
- ) }),
45663
+ /* @__PURE__ */ jsx97(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx97("span", { className: cn("inline-flex"), tabIndex: voiceDisabledReason ? 0 : void 0, "aria-label": voiceDisabledReason, children: /* @__PURE__ */ jsx97(ComposerPrimitiveDictate, { asChild: true, disabled: busy || sending, children: /* @__PURE__ */ jsx97(Button, { variant: "ghost", size: "icon", "aria-label": "\u5F00\u59CB\u8BED\u97F3\u8F93\u5165", "aria-description": voiceDisabledReason, className: cn("size-7 p-1"), children: /* @__PURE__ */ jsx97(Mic, { className: cn("size-4") }) }) }) }) }),
46527
45664
  /* @__PURE__ */ jsx97(TooltipContent3, { children: voiceDisabledReason ?? "\u8BED\u97F3\u8F93\u5165" })
46528
45665
  ] }) }) }),
46529
- /* @__PURE__ */ jsx97(AuiIf, { condition: (state) => state.composer.dictation != null, children: /* @__PURE__ */ jsx97(
46530
- ComposerPrimitiveStopDictation,
46531
- {
46532
- asChild: true,
46533
- disabled: binding.voice.status !== "recording",
46534
- children: /* @__PURE__ */ jsx97(
46535
- "button",
46536
- {
46537
- type: "button",
46538
- "aria-label": "\u7ED3\u675F\u8BED\u97F3\u8F93\u5165",
46539
- title: "\u7ED3\u675F\u5F55\u97F3",
46540
- className: cn(
46541
- "text-destructive rounded-control grid size-7 place-items-center transition-colors disabled:opacity-50"
46542
- ),
46543
- children: /* @__PURE__ */ jsx97(Square, { className: cn("size-3 animate-pulse fill-current") })
46544
- }
46545
- )
46546
- }
46547
- ) })
45666
+ /* @__PURE__ */ jsx97(AuiIf, { condition: (state) => state.composer.dictation != null, children: /* @__PURE__ */ jsx97(ComposerPrimitiveStopDictation, { asChild: true, disabled: binding.voice.status !== "recording", children: /* @__PURE__ */ jsx97("button", { type: "button", "aria-label": "\u7ED3\u675F\u8BED\u97F3\u8F93\u5165", title: "\u7ED3\u675F\u5F55\u97F3", className: cn("text-destructive rounded-control grid size-7 place-items-center transition-colors disabled:opacity-50"), children: /* @__PURE__ */ jsx97(Square, { className: cn("size-3 animate-pulse fill-current") }) }) }) })
46548
45667
  ] }),
46549
- showCancel ? /* @__PURE__ */ jsx97(
46550
- "button",
46551
- {
46552
- type: "button",
46553
- "aria-label": "\u53D6\u6D88\u4EFB\u52A1",
46554
- className: cn(
46555
- "bg-primary text-primary-foreground rounded-control grid size-7 place-items-center"
46556
- ),
46557
- disabled: cancelling,
46558
- onClick: cancel,
46559
- children: /* @__PURE__ */ jsx97(Square, { className: cn("size-3 fill-current") })
46560
- }
46561
- ) : /* @__PURE__ */ jsx97(ComposerPrimitiveSend, { asChild: true, disabled: inputDisabled, children: /* @__PURE__ */ jsx97(
46562
- "button",
46563
- {
46564
- type: "button",
46565
- onClick: (event) => {
46566
- event.preventDefault();
46567
- void binding.send();
46568
- },
46569
- "aria-label": "\u53D1\u9001\u4EFB\u52A1",
46570
- className: cn(
46571
- "bg-primary text-primary-foreground rounded-control grid size-7 place-items-center transition-opacity disabled:opacity-40"
46572
- ),
46573
- children: /* @__PURE__ */ jsx97(ArrowUp, { className: cn("size-4") })
46574
- }
46575
- ) })
45668
+ showCancel ? /* @__PURE__ */ jsx97("button", { type: "button", "aria-label": "\u53D6\u6D88\u4EFB\u52A1", className: cn("bg-primary text-primary-foreground rounded-control grid size-7 place-items-center"), disabled: cancelling, onClick: cancel, children: /* @__PURE__ */ jsx97(Square, { className: cn("size-3 fill-current") }) }) : /* @__PURE__ */ jsx97(ComposerPrimitiveSend, { asChild: true, disabled: inputDisabled, children: /* @__PURE__ */ jsx97("button", { type: "button", onClick: (event) => {
45669
+ event.preventDefault();
45670
+ void binding.send();
45671
+ }, "aria-label": "\u53D1\u9001\u4EFB\u52A1", className: cn("bg-primary text-primary-foreground rounded-control grid size-7 place-items-center transition-opacity disabled:opacity-40"), children: /* @__PURE__ */ jsx97(ArrowUp, { className: cn("size-4") }) }) })
46576
45672
  ] })
46577
45673
  ] }),
46578
45674
  children: [
46579
- /* @__PURE__ */ jsx97(
46580
- "div",
46581
- {
46582
- ref: (element2) => {
46583
- element2?.toggleAttribute("inert", inputDisabled);
46584
- },
46585
- className: cn(
46586
- "aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden"
46587
- ),
46588
- children: /* @__PURE__ */ jsx97(ComposerPrimitiveAttachments, { children: () => /* @__PURE__ */ jsx97(AttachmentTile, { binding }) })
46589
- }
46590
- ),
45675
+ /* @__PURE__ */ jsx97("div", { ref: (element2) => {
45676
+ element2?.toggleAttribute("inert", inputDisabled);
45677
+ }, className: cn("aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden"), children: /* @__PURE__ */ jsx97(ComposerPrimitiveAttachments, { children: () => /* @__PURE__ */ jsx97(AttachmentTile, { binding }) }) }),
46591
45678
  sending ? /* @__PURE__ */ jsx97("small", { role: "status", children: "\u6B63\u5728\u5904\u7406\u9644\u4EF6\u2026" }) : null
46592
45679
  ]
46593
45680
  }
46594
45681
  );
46595
45682
  }
46596
- function ToolGroup({
46597
- tools,
46598
- running,
46599
- count: count3,
46600
- children
46601
- }) {
45683
+ function ToolGroup({ tools, running, count: count3, children }) {
46602
45684
  const errors = tools.flatMap((tool2) => tool2.type === "tool" && tool2.error ? [tool2.error] : []);
46603
45685
  const errorIds = JSON.stringify(errors.map((error) => error.id));
46604
45686
  const hasErrors = errors.length > 0;
@@ -46608,28 +45690,13 @@ function ToolGroup({
46608
45690
  }, [errorIds]);
46609
45691
  const unknown = hasErrors && errors.every((error) => error.scope === "tool" && error.execution === "unknown");
46610
45692
  return /* @__PURE__ */ jsxs28(ToolGroupRoot, { variant: "ghost", className: cn("my-1"), open, onOpenChange: setOpen, children: [
46611
- /* @__PURE__ */ jsx97(
46612
- DisclosureTrigger,
46613
- {
46614
- live: running && !hasErrors,
46615
- label: hasErrors ? unknown ? "Result unknown" : "Failed" : running ? "running" : "ran",
46616
- detail: `${count3} tools`
46617
- }
46618
- ),
45693
+ /* @__PURE__ */ jsx97(DisclosureTrigger, { live: running && !hasErrors, label: hasErrors ? unknown ? "Result unknown" : "Failed" : running ? "running" : "ran", detail: `${count3} tools` }),
46619
45694
  /* @__PURE__ */ jsx97(ToolGroupContent, { className: cn(disclosureContentClass), children })
46620
45695
  ] });
46621
45696
  }
46622
45697
  var GroupedParts = MessagePrimitiveGroupedParts;
46623
- var groupAssistantParts = groupPartByType({
46624
- reasoning: ["group-chainOfThought", "group-reasoning"],
46625
- source: ["group-chainOfThought", "group-source"],
46626
- "tool-call": ["group-chainOfThought", "group-tool"],
46627
- "standalone-tool-call": []
46628
- });
46629
- function AssistantParts({
46630
- showDetails,
46631
- tools = []
46632
- }) {
45698
+ var groupAssistantParts = groupPartByType({ reasoning: ["group-chainOfThought", "group-reasoning"], source: ["group-chainOfThought", "group-source"], "tool-call": ["group-chainOfThought", "group-tool"], "standalone-tool-call": [] });
45699
+ function AssistantParts({ showDetails, tools = [] }) {
46633
45700
  return /* @__PURE__ */ jsx97(Fragment15, { children: /* @__PURE__ */ jsx97(GroupedParts, { groupBy: groupAssistantParts, children: ({ part, children }) => {
46634
45701
  switch (part.type) {
46635
45702
  case "group-chainOfThought":
@@ -46645,31 +45712,10 @@ function AssistantParts({
46645
45712
  }
46646
45713
  );
46647
45714
  case "group-reasoning":
46648
- return /* @__PURE__ */ jsxs28(
46649
- ReasoningRoot3,
46650
- {
46651
- variant: "ghost",
46652
- streaming: part.status.type === "running",
46653
- className: cn("my-1"),
46654
- children: [
46655
- /* @__PURE__ */ jsx97(
46656
- DisclosureTrigger,
46657
- {
46658
- live: part.status.type === "running",
46659
- label: part.status.type === "running" ? "thinking" : "reasoning"
46660
- }
46661
- ),
46662
- /* @__PURE__ */ jsx97(
46663
- ReasoningContent,
46664
- {
46665
- "aria-busy": part.status.type === "running",
46666
- className: cn(disclosureContentClass),
46667
- children: /* @__PURE__ */ jsx97(ReasoningText, { className: cn("ps-0"), children })
46668
- }
46669
- )
46670
- ]
46671
- }
46672
- );
45715
+ return /* @__PURE__ */ jsxs28(ReasoningRoot3, { variant: "ghost", streaming: part.status.type === "running", className: cn("my-1"), children: [
45716
+ /* @__PURE__ */ jsx97(DisclosureTrigger, { live: part.status.type === "running", label: part.status.type === "running" ? "thinking" : "reasoning" }),
45717
+ /* @__PURE__ */ jsx97(ReasoningContent, { "aria-busy": part.status.type === "running", className: cn(disclosureContentClass), children: /* @__PURE__ */ jsx97(ReasoningText, { className: cn("ps-0"), children }) })
45718
+ ] });
46673
45719
  case "reasoning":
46674
45720
  return /* @__PURE__ */ jsx97(Reasoning, { ...part });
46675
45721
  case "group-source":
@@ -46680,16 +45726,7 @@ function AssistantParts({
46680
45726
  case "text":
46681
45727
  return part.text === "" && part.status?.type === "running" ? /* @__PURE__ */ jsx97(TraceLine, { live: true, label: "thinking" }) : /* @__PURE__ */ jsx97(MarkdownText, {});
46682
45728
  case "tool-call":
46683
- return part.toolUI ?? /* @__PURE__ */ jsx97(
46684
- ToolCall,
46685
- {
46686
- ...part,
46687
- showDetails,
46688
- presentation: tools.find(
46689
- (tool2) => tool2.type === "tool" && tool2.toolCallId === part.toolCallId
46690
- )
46691
- }
46692
- );
45729
+ return part.toolUI ?? /* @__PURE__ */ jsx97(ToolCall, { ...part, showDetails, presentation: tools.find((tool2) => tool2.type === "tool" && tool2.toolCallId === part.toolCallId) });
46693
45730
  case "indicator":
46694
45731
  return /* @__PURE__ */ jsx97(TraceLine, { live: true, label: "thinking" });
46695
45732
  default:
@@ -46704,31 +45741,9 @@ import { sendErrorNotice } from "./errors.js";
46704
45741
  import { Fragment as Fragment16, jsx as jsx98, jsxs as jsxs29 } from "react/jsx-runtime";
46705
45742
  var textOf = (message) => message.parts.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
46706
45743
  var Icon2 = forwardRef33(function Icon3({ label, children, className, ...props }, ref) {
46707
- return /* @__PURE__ */ jsx98(
46708
- "button",
46709
- {
46710
- ref,
46711
- type: "button",
46712
- "aria-label": label,
46713
- title: label,
46714
- className: cn(
46715
- "text-muted-foreground hover:text-foreground rounded-control grid size-7 place-items-center transition-colors [&>svg]:size-4",
46716
- className
46717
- ),
46718
- ...props,
46719
- children
46720
- }
46721
- );
45744
+ return /* @__PURE__ */ jsx98("button", { ref, type: "button", "aria-label": label, title: label, className: cn("text-muted-foreground hover:text-foreground rounded-control grid size-7 place-items-center transition-colors [&>svg]:size-4", className), ...props, children });
46722
45745
  });
46723
- function Resize({
46724
- label,
46725
- width,
46726
- onResize,
46727
- side = "left",
46728
- edge = "left",
46729
- min: min2,
46730
- max: max2
46731
- }) {
45746
+ function Resize({ label, width, onResize, side = "left", edge = "left", min: min2, max: max2 }) {
46732
45747
  const handle2 = useRef39(null);
46733
45748
  const drag = useRef39(null);
46734
45749
  const readWidth = () => handle2.current?.parentElement?.getBoundingClientRect().width || width;
@@ -46753,10 +45768,7 @@ function Resize({
46753
45768
  "div",
46754
45769
  {
46755
45770
  ref: handle2,
46756
- className: cn(
46757
- "absolute inset-y-0 z-3 w-1.5 cursor-col-resize touch-none max-sm:hidden",
46758
- edge === "left" ? "left-0" : "right-0"
46759
- ),
45771
+ className: cn("absolute inset-y-0 z-3 w-1.5 cursor-col-resize touch-none max-sm:hidden", edge === "left" ? "left-0" : "right-0"),
46760
45772
  role: "separator",
46761
45773
  "aria-label": label,
46762
45774
  "aria-orientation": "vertical",
@@ -46764,21 +45776,14 @@ function Resize({
46764
45776
  onKeyDown: (event) => {
46765
45777
  if (!["ArrowLeft", "ArrowRight"].includes(event.key)) return;
46766
45778
  event.preventDefault();
46767
- onResize(
46768
- clamp2(readWidth() + (event.key === "ArrowRight" ? 16 : -16) * (side === "left" ? 1 : -1))
46769
- );
45779
+ onResize(clamp2(readWidth() + (event.key === "ArrowRight" ? 16 : -16) * (side === "left" ? 1 : -1)));
46770
45780
  },
46771
45781
  onPointerDown: (event) => {
46772
45782
  drag.current = { x: event.clientX, width: readWidth() };
46773
45783
  event.currentTarget.setPointerCapture(event.pointerId);
46774
45784
  },
46775
45785
  onPointerMove: (event) => {
46776
- if (drag.current)
46777
- onResize(
46778
- clamp2(
46779
- drag.current.width + (event.clientX - drag.current.x) * (side === "left" ? 1 : -1)
46780
- )
46781
- );
45786
+ if (drag.current) onResize(clamp2(drag.current.width + (event.clientX - drag.current.x) * (side === "left" ? 1 : -1)));
46782
45787
  },
46783
45788
  onPointerUp: () => {
46784
45789
  drag.current = null;
@@ -46863,17 +45868,13 @@ function Chat({
46863
45868
  }
46864
45869
  updateDialog(next);
46865
45870
  };
46866
- const byId = useMemo13(
46867
- () => new Map(projectMessages(messages).map((message) => [message.id, message])),
46868
- [messages]
46869
- );
45871
+ const byId = useMemo13(() => new Map(projectMessages(messages).map((message) => [message.id, message])), [messages]);
46870
45872
  const visited = useRef39(/* @__PURE__ */ new Set());
46871
45873
  visited.current.add(sessionId);
46872
45874
  const activeTitle = messages.length ? chat.sessions.find((session) => session.id === sessionId)?.title || title : title;
46873
45875
  const latestUser = [...messages].reverse().find((message) => message.role === "user");
46874
45876
  useEffect34(() => {
46875
- if (chat.completed && chat.consumeCompletion(chat.completed.id))
46876
- onRunResult?.(chat.completed.result);
45877
+ if (chat.completed && chat.consumeCompletion(chat.completed.id)) onRunResult?.(chat.completed.result);
46877
45878
  }, [chat.completed, chat.consumeCompletion, onRunResult]);
46878
45879
  useLayoutEffect14(() => {
46879
45880
  dialog?.cancel?.();
@@ -46908,28 +45909,17 @@ function Chat({
46908
45909
  const files = editing?.id === sourceId ? editing.files : messages.find((message) => message.id === sourceId)?.attachments ?? [];
46909
45910
  const perform = () => {
46910
45911
  setNotice("");
46911
- void chat.sendMessage(text7, files, sourceId).then(
46912
- () => {
46913
- setEditing(void 0);
46914
- resolve();
46915
- },
46916
- (error) => {
46917
- setNotice(sendErrorNotice(error));
46918
- reject(error);
46919
- }
46920
- );
45912
+ void chat.sendMessage(text7, files, sourceId).then(() => {
45913
+ setEditing(void 0);
45914
+ resolve();
45915
+ }, (error) => {
45916
+ setNotice(sendErrorNotice(error));
45917
+ reject(error);
45918
+ });
46921
45919
  };
46922
45920
  const index5 = messages.findIndex((message) => message.id === sourceId);
46923
- const hasOperations = messages.slice(index5 + 1).some(
46924
- (message) => message.parts.some((part) => part.type === "tool" && part.result !== void 0)
46925
- );
46926
- if (hasOperations)
46927
- setDialog({
46928
- title: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001\uFF1F",
46929
- description: "\u4FEE\u6539\u540E\u5C06\u91CD\u65B0\u751F\u6210\u56DE\u7B54\u3002\u6B64\u524D\u5DF2\u6267\u884C\u7684\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u64A4\u9500\uFF0C\u91CD\u65B0\u53D1\u9001\u53EF\u80FD\u91CD\u590D\u6267\u884C\u3002",
46930
- action: perform,
46931
- cancel: () => reject(new Error("\u5DF2\u53D6\u6D88\u91CD\u65B0\u53D1\u9001\u3002"))
46932
- });
45921
+ const hasOperations = messages.slice(index5 + 1).some((message) => message.parts.some((part) => part.type === "tool" && part.result !== void 0));
45922
+ if (hasOperations) setDialog({ title: "\u4FDD\u5B58\u5E76\u91CD\u65B0\u53D1\u9001\uFF1F", description: "\u4FEE\u6539\u540E\u5C06\u91CD\u65B0\u751F\u6210\u56DE\u7B54\u3002\u6B64\u524D\u5DF2\u6267\u884C\u7684\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u64A4\u9500\uFF0C\u91CD\u65B0\u53D1\u9001\u53EF\u80FD\u91CD\u590D\u6267\u884C\u3002", action: perform, cancel: () => reject(new Error("\u5DF2\u53D6\u6D88\u91CD\u65B0\u53D1\u9001\u3002")) });
46933
45923
  else perform();
46934
45924
  });
46935
45925
  return /* @__PURE__ */ jsx98(Fragment16, { children: chat.sessions.filter((session) => visited.current.has(session.id)).map((session) => /* @__PURE__ */ jsx98(
@@ -46944,145 +45934,38 @@ function Chat({
46944
45934
  open,
46945
45935
  onEdit: editThroughRuntime,
46946
45936
  children: (binding) => {
46947
- const history = sidebarOpen ? /* @__PURE__ */ jsxs29(
46948
- "nav",
46949
- {
46950
- ref: sidebarNav,
46951
- onKeyDown: (event) => {
46952
- if (event.key === "Escape" && !event.nativeEvent.isComposing && !event.target.closest(
46953
- '[data-slot="aui_thread-list-item-rename"]'
46954
- )) {
46955
- event.preventDefault();
46956
- setSidebar(false);
46957
- }
46958
- },
46959
- onClick: (event) => {
46960
- if (event.target.closest(
46961
- '[data-slot="aui_thread-list-item-trigger"], [data-slot="aui_thread-list-new"]'
46962
- ))
46963
- setSidebar(false);
46964
- },
46965
- "data-slot": "nexface_session-sidebar",
46966
- "data-layout": sidebarLayout,
46967
- className: cn(
46968
- "nexface-chat__session-sidebar absolute inset-y-0 z-5 flex flex-col overflow-auto border-r border-foreground/10 bg-background shadow-lg"
46969
- ),
46970
- style: sidebarLayout === "overlay" && sidebarWidth !== void 0 ? { width: sidebarWidth } : void 0,
46971
- "aria-label": "\u4F1A\u8BDD\u5386\u53F2",
46972
- children: [
46973
- sidebarLayout === "overlay" ? /* @__PURE__ */ jsx98(
46974
- Resize,
46975
- {
46976
- label: "\u8C03\u6574\u4F1A\u8BDD\u5386\u53F2\u680F\u5BBD\u5EA6",
46977
- width: sidebarWidth ?? 240,
46978
- onResize: setSidebarWidth,
46979
- edge: "right",
46980
- min: 180,
46981
- max: 400
46982
- }
46983
- ) : null,
46984
- /* @__PURE__ */ jsxs29(
46985
- "div",
46986
- {
46987
- className: cn(
46988
- "flex h-12 shrink-0 items-center gap-2 border-b border-foreground/10 px-4 md:px-5"
46989
- ),
46990
- children: [
46991
- sidebarLayout === "overlay" ? /* @__PURE__ */ jsx98(
46992
- Icon2,
46993
- {
46994
- label: "\u6536\u8D77\u4F1A\u8BDD\u5386\u53F2",
46995
- "aria-expanded": sidebarOpen,
46996
- className: cn("size-7 shrink-0"),
46997
- onClick: () => setSidebar(false),
46998
- children: /* @__PURE__ */ jsx98(PanelLeft, { className: cn("size-4") })
46999
- }
47000
- ) : null,
47001
- /* @__PURE__ */ jsxs29(Avatar3, { children: [
47002
- avatar ? /* @__PURE__ */ jsx98(AvatarImage3, { src: avatar, alt: "" }) : null,
47003
- /* @__PURE__ */ jsx98(AvatarFallback3, { children: /* @__PURE__ */ jsx98(Bot, { size: 20 }) })
47004
- ] }),
47005
- /* @__PURE__ */ jsx98("strong", { className: cn("min-w-0 flex-1 truncate text-[13px] font-medium"), children: title })
47006
- ]
47007
- }
47008
- ),
47009
- /* @__PURE__ */ jsxs29("div", { className: cn("flex min-h-0 flex-1 flex-col p-3"), children: [
47010
- /* @__PURE__ */ jsx98(
47011
- ThreadListNew,
47012
- {
47013
- disabled: sessionBusy || binding.sending,
47014
- onClick: (event) => {
47015
- event.preventDefault();
47016
- safe(() => chat.createSession());
47017
- }
47018
- }
47019
- ),
47020
- /* @__PURE__ */ jsx98(ThreadListSearch, { value: threadSearch, onValueChange: setThreadSearch }),
47021
- /* @__PURE__ */ jsx98(
47022
- "small",
47023
- {
47024
- className: cn("text-muted-foreground mt-5 mb-1 px-2 text-xs font-medium"),
47025
- children: "\u6700\u8FD1\u4F1A\u8BDD"
47026
- }
47027
- ),
47028
- /* @__PURE__ */ jsx98(ThreadListRoot, { children: /* @__PURE__ */ jsx98(ThreadListPrimitiveItems, { children: ({ threadListItem: session2 }) => (session2.title ?? "\u65B0\u4F1A\u8BDD").toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase()) ? /* @__PURE__ */ jsx98(
47029
- ThreadListItem,
47030
- {
47031
- disabled: sessionBusy || binding.sending,
47032
- menu: (beginRename) => /* @__PURE__ */ jsxs29(Fragment16, { children: [
47033
- /* @__PURE__ */ jsx98(
47034
- DropdownMenuItem3,
47035
- {
47036
- disabled: sessionBusy || binding.sending,
47037
- onSelect: beginRename,
47038
- children: "\u91CD\u547D\u540D"
47039
- }
47040
- ),
47041
- /* @__PURE__ */ jsx98(
47042
- DropdownMenuItem3,
47043
- {
47044
- variant: "destructive",
47045
- disabled: busy || binding.sending,
47046
- onSelect: () => setDialog({
47047
- title: "\u6E05\u7A7A\u6D88\u606F\uFF1F",
47048
- description: "\u8BE5\u4F1A\u8BDD\u6D88\u606F\u5C06\u88AB\u6E05\u9664\uFF0C\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u56DE\u6EDA\u3002",
47049
- dangerous: true,
47050
- action: () => chat.clearSession(session2.id)
47051
- }),
47052
- children: "\u6E05\u7A7A\u6D88\u606F"
47053
- }
47054
- ),
47055
- /* @__PURE__ */ jsx98(
47056
- DropdownMenuItem3,
47057
- {
47058
- variant: "destructive",
47059
- disabled: busy || binding.sending,
47060
- onSelect: () => setDialog({
47061
- title: "\u5220\u9664\u4F1A\u8BDD\uFF1F",
47062
- description: "\u804A\u5929\u8BB0\u5F55\u5C06\u88AB\u5220\u9664\uFF0C\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002",
47063
- dangerous: true,
47064
- action: () => chat.deleteSession(session2.id)
47065
- }),
47066
- children: "\u5220\u9664\u4F1A\u8BDD"
47067
- }
47068
- )
47069
- ] })
47070
- }
47071
- ) : null }) }),
47072
- threadSearch.trim() && !chat.sessions.some(
47073
- (session2) => session2.title.toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase())
47074
- ) ? /* @__PURE__ */ jsx98(
47075
- "div",
47076
- {
47077
- "data-slot": "aui_thread-list-empty",
47078
- className: cn("text-muted-foreground px-2.5 py-4 text-sm"),
47079
- children: "\u672A\u627E\u5230\u4F1A\u8BDD"
47080
- }
47081
- ) : null
47082
- ] })
47083
- ]
45937
+ const history = sidebarOpen ? /* @__PURE__ */ jsxs29("nav", { ref: sidebarNav, onKeyDown: (event) => {
45938
+ if (event.key === "Escape" && !event.nativeEvent.isComposing && !event.target.closest('[data-slot="aui_thread-list-item-rename"]')) {
45939
+ event.preventDefault();
45940
+ setSidebar(false);
47084
45941
  }
47085
- ) : null;
45942
+ }, onClick: (event) => {
45943
+ if (event.target.closest('[data-slot="aui_thread-list-item-trigger"], [data-slot="aui_thread-list-new"]')) setSidebar(false);
45944
+ }, "data-slot": "nexface_session-sidebar", "data-layout": sidebarLayout, className: cn("nexface-chat__session-sidebar absolute inset-y-0 z-5 flex flex-col overflow-auto border-r border-foreground/10 bg-background shadow-lg"), style: sidebarLayout === "overlay" && sidebarWidth !== void 0 ? { width: sidebarWidth } : void 0, "aria-label": "\u4F1A\u8BDD\u5386\u53F2", children: [
45945
+ sidebarLayout === "overlay" ? /* @__PURE__ */ jsx98(Resize, { label: "\u8C03\u6574\u4F1A\u8BDD\u5386\u53F2\u680F\u5BBD\u5EA6", width: sidebarWidth ?? 240, onResize: setSidebarWidth, edge: "right", min: 180, max: 400 }) : null,
45946
+ /* @__PURE__ */ jsxs29("div", { className: cn("flex h-12 shrink-0 items-center gap-2 border-b border-foreground/10 px-4 md:px-5"), children: [
45947
+ sidebarLayout === "overlay" ? /* @__PURE__ */ jsx98(Icon2, { label: "\u6536\u8D77\u4F1A\u8BDD\u5386\u53F2", "aria-expanded": sidebarOpen, className: cn("size-7 shrink-0"), onClick: () => setSidebar(false), children: /* @__PURE__ */ jsx98(PanelLeft, { className: cn("size-4") }) }) : null,
45948
+ /* @__PURE__ */ jsxs29(Avatar3, { children: [
45949
+ avatar ? /* @__PURE__ */ jsx98(AvatarImage3, { src: avatar, alt: "" }) : null,
45950
+ /* @__PURE__ */ jsx98(AvatarFallback3, { children: /* @__PURE__ */ jsx98(Bot, { size: 20 }) })
45951
+ ] }),
45952
+ /* @__PURE__ */ jsx98("strong", { className: cn("min-w-0 flex-1 truncate text-[13px] font-medium"), children: title })
45953
+ ] }),
45954
+ /* @__PURE__ */ jsxs29("div", { className: cn("flex min-h-0 flex-1 flex-col p-3"), children: [
45955
+ /* @__PURE__ */ jsx98(ThreadListNew, { disabled: sessionBusy || binding.sending, onClick: (event) => {
45956
+ event.preventDefault();
45957
+ safe(() => chat.createSession());
45958
+ } }),
45959
+ /* @__PURE__ */ jsx98(ThreadListSearch, { value: threadSearch, onValueChange: setThreadSearch }),
45960
+ /* @__PURE__ */ jsx98("small", { className: cn("text-muted-foreground mt-5 mb-1 px-2 text-xs font-medium"), children: "\u6700\u8FD1\u4F1A\u8BDD" }),
45961
+ /* @__PURE__ */ jsx98(ThreadListRoot, { children: /* @__PURE__ */ jsx98(ThreadListPrimitiveItems, { children: ({ threadListItem: session2 }) => (session2.title ?? "\u65B0\u4F1A\u8BDD").toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase()) ? /* @__PURE__ */ jsx98(ThreadListItem, { disabled: sessionBusy || binding.sending, menu: (beginRename) => /* @__PURE__ */ jsxs29(Fragment16, { children: [
45962
+ /* @__PURE__ */ jsx98(DropdownMenuItem3, { disabled: sessionBusy || binding.sending, onSelect: beginRename, children: "\u91CD\u547D\u540D" }),
45963
+ /* @__PURE__ */ jsx98(DropdownMenuItem3, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "\u6E05\u7A7A\u6D88\u606F\uFF1F", description: "\u8BE5\u4F1A\u8BDD\u6D88\u606F\u5C06\u88AB\u6E05\u9664\uFF0C\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u56DE\u6EDA\u3002", dangerous: true, action: () => chat.clearSession(session2.id) }), children: "\u6E05\u7A7A\u6D88\u606F" }),
45964
+ /* @__PURE__ */ jsx98(DropdownMenuItem3, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "\u5220\u9664\u4F1A\u8BDD\uFF1F", description: "\u804A\u5929\u8BB0\u5F55\u5C06\u88AB\u5220\u9664\uFF0C\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002", dangerous: true, action: () => chat.deleteSession(session2.id) }), children: "\u5220\u9664\u4F1A\u8BDD" })
45965
+ ] }) }) : null }) }),
45966
+ threadSearch.trim() && !chat.sessions.some((session2) => session2.title.toLocaleLowerCase().includes(threadSearch.trim().toLocaleLowerCase())) ? /* @__PURE__ */ jsx98("div", { "data-slot": "aui_thread-list-empty", className: cn("text-muted-foreground px-2.5 py-4 text-sm"), children: "\u672A\u627E\u5230\u4F1A\u8BDD" }) : null
45967
+ ] })
45968
+ ] }) : null;
47086
45969
  return open ? /* @__PURE__ */ jsxs29(
47087
45970
  ChatSurface,
47088
45971
  {
@@ -47093,366 +45976,108 @@ function Chat({
47093
45976
  "data-fullscreen": fullscreen && open || void 0,
47094
45977
  "data-session-sidebar-open": sidebarOpen || void 0,
47095
45978
  "data-nexface-ignore": true,
47096
- style: {
47097
- "--nexface-chat-panel-width": `${width}px`,
47098
- ...style,
47099
- ...fullscreen ? { border: 0, borderRadius: 0 } : {}
47100
- },
45979
+ style: { "--nexface-chat-panel-width": `${width}px`, ...style, ...fullscreen ? { border: 0, borderRadius: 0 } : {} },
47101
45980
  children: [
47102
- layout === "docked" && !fullscreen ? /* @__PURE__ */ jsx98(
47103
- Resize,
47104
- {
47105
- label: "\u8C03\u6574\u804A\u5929\u5BBD\u5EA6",
47106
- width,
47107
- onResize: setWidth,
47108
- side,
47109
- edge: side === "left" ? "right" : "left",
47110
- min: 320,
47111
- max: 960
47112
- }
47113
- ) : null,
45981
+ layout === "docked" && !fullscreen ? /* @__PURE__ */ jsx98(Resize, { label: "\u8C03\u6574\u804A\u5929\u5BBD\u5EA6", width, onResize: setWidth, side, edge: side === "left" ? "right" : "left", min: 320, max: 960 }) : null,
47114
45982
  sidebarLayout === "outside" ? history : null,
47115
- /* @__PURE__ */ jsxs29(
47116
- "section",
47117
- {
47118
- ref: panel,
47119
- className: cn(
47120
- "nexface-chat__panel relative flex h-full min-h-0 overflow-hidden rounded-[inherit]"
47121
- ),
47122
- "aria-label": `${title} chat`,
47123
- children: [
47124
- sidebarOpen && sidebarLayout === "overlay" ? /* @__PURE__ */ jsxs29(Fragment16, { children: [
47125
- /* @__PURE__ */ jsx98(
47126
- "button",
47127
- {
47128
- type: "button",
47129
- tabIndex: -1,
47130
- "aria-label": "\u5173\u95ED\u4F1A\u8BDD\u5386\u53F2\u6D6E\u5C42",
47131
- className: cn("absolute inset-0 z-4 bg-black/10"),
47132
- onClick: () => setSidebar(false)
47133
- }
47134
- ),
47135
- history
47136
- ] }) : null,
47137
- /* @__PURE__ */ jsxs29(
47138
- "div",
47139
- {
47140
- ref: (element2) => {
47141
- element2?.toggleAttribute(
47142
- "inert",
47143
- sidebarOpen && sidebarLayout === "overlay"
47144
- );
47145
- },
47146
- className: cn("flex min-h-0 min-w-0 flex-1 flex-col"),
47147
- children: [
47148
- /* @__PURE__ */ jsxs29(
47149
- "header",
47150
- {
47151
- "data-slot": "nexface_chat_header",
47152
- className: cn(
47153
- "border-foreground/10 flex h-12 shrink-0 min-w-0 items-center gap-2 border-b px-4 md:px-5"
47154
- ),
47155
- children: [
47156
- /* @__PURE__ */ jsxs29(
47157
- "div",
47158
- {
47159
- className: cn("flex min-w-0 flex-1 items-center gap-2 whitespace-nowrap"),
47160
- children: [
47161
- sidebarEnabled && (sidebarLayout === "outside" || !sidebarOpen) ? /* @__PURE__ */ jsx98(
47162
- Icon2,
47163
- {
47164
- ref: sidebarTrigger,
47165
- label: sidebarOpen ? "\u6536\u8D77\u4F1A\u8BDD\u5386\u53F2" : "\u67E5\u770B\u4F1A\u8BDD\u5386\u53F2",
47166
- "aria-expanded": sidebarOpen,
47167
- className: cn("size-7 shrink-0"),
47168
- onClick: () => setSidebar((value) => !value),
47169
- children: /* @__PURE__ */ jsx98(PanelLeft, { className: cn("size-4") })
47170
- }
47171
- ) : null,
47172
- /* @__PURE__ */ jsx98("strong", { className: cn("truncate text-[13px] font-medium"), children: activeTitle })
47173
- ]
47174
- }
47175
- ),
47176
- /* @__PURE__ */ jsxs29("div", { className: cn("-me-1.5 ml-auto flex shrink-0 items-center gap-1.5"), children: [
47177
- /* @__PURE__ */ jsxs29(DropdownMenu2, { modal: false, children: [
47178
- /* @__PURE__ */ jsx98(DropdownMenuTrigger3, { asChild: true, children: /* @__PURE__ */ jsx98(Icon2, { label: "\u66F4\u591A\u4F1A\u8BDD\u64CD\u4F5C", children: /* @__PURE__ */ jsx98(Ellipsis, {}) }) }),
47179
- /* @__PURE__ */ jsx98(DropdownMenuContent3, { align: "end", children: /* @__PURE__ */ jsx98(
47180
- DropdownMenuItem3,
47181
- {
47182
- variant: "destructive",
47183
- disabled: busy || binding.sending,
47184
- onSelect: () => setDialog({
47185
- title: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2\uFF1F",
47186
- description: "\u6240\u6709\u804A\u5929\u8BB0\u5F55\u5C06\u88AB\u6E05\u9664\uFF0C\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u56DE\u6EDA\u3002",
47187
- dangerous: true,
47188
- action: chat.clearAllSessions
47189
- }),
47190
- children: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2"
47191
- }
47192
- ) })
47193
- ] }),
47194
- /* @__PURE__ */ jsx98(
47195
- Icon2,
47196
- {
47197
- label: "\u65B0\u5EFA\u804A\u5929\u4F1A\u8BDD",
47198
- disabled: sessionBusy || binding.sending,
47199
- onClick: () => safe(() => chat.createSession()),
47200
- children: /* @__PURE__ */ jsx98(Plus, {})
47201
- }
47202
- ),
47203
- /* @__PURE__ */ jsx98(
47204
- Icon2,
47205
- {
47206
- ref: headerFocusButton,
47207
- label: fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F",
47208
- onClick: () => changeFullscreen(!fullscreen),
47209
- children: fullscreen ? /* @__PURE__ */ jsx98(Minimize2, {}) : /* @__PURE__ */ jsx98(Maximize2, {})
47210
- }
47211
- ),
47212
- onOpenChange ? /* @__PURE__ */ jsx98(Icon2, { label: "\u5173\u95ED Agent \u5BF9\u8BDD", onClick: () => onOpenChange(false), children: /* @__PURE__ */ jsx98(X, {}) }) : null
47213
- ] })
47214
- ]
47215
- }
47216
- ),
47217
- /* @__PURE__ */ jsx98(
47218
- "div",
47219
- {
47220
- "data-slot": "nexface_chat_body",
47221
- className: cn("relative flex min-h-0 flex-1"),
47222
- children: /* @__PURE__ */ jsx98(
47223
- Thread,
47224
- {
47225
- empty: !messages.length,
47226
- welcome: /* @__PURE__ */ jsx98(Greeting, { title: welcomeMessage, description: welcomeDescription }),
47227
- suggestions: /* @__PURE__ */ jsx98(
47228
- Suggestions2,
47229
- {
47230
- suggestions,
47231
- disabled: busy || binding.sending || binding.voice.status !== "idle",
47232
- onSend: (prompt) => void execute(prompt)
47233
- }
47234
- ),
47235
- footer: /* @__PURE__ */ jsxs29(Fragment16, { children: [
47236
- chat.storageWarning ? /* @__PURE__ */ jsx98("div", { role: "alert", className: cn("text-muted-foreground text-xs"), children: chat.storageWarning }) : null,
47237
- notice ? /* @__PURE__ */ jsxs29("div", { role: "status", className: cn("text-muted-foreground text-xs"), children: [
47238
- notice,
47239
- /* @__PURE__ */ jsx98("button", { onClick: () => setNotice(""), children: "\xD7" })
47240
- ] }) : null,
47241
- binding.notice ? /* @__PURE__ */ jsxs29(
47242
- ErrorPrimitiveRoot,
47243
- {
47244
- className: cn(
47245
- "border-destructive/60 text-destructive flex items-start gap-3 border-l-2 pl-3 text-[13px] leading-relaxed"
47246
- ),
47247
- children: [
47248
- /* @__PURE__ */ jsx98("span", { className: cn("min-w-0 flex-1 break-words"), children: binding.notice }),
47249
- /* @__PURE__ */ jsx98(
47250
- Icon2,
47251
- {
47252
- label: "\u5173\u95ED\u63D0\u793A",
47253
- className: cn(
47254
- "text-destructive hover:text-destructive -mt-1 -mr-1 shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/30"
47255
- ),
47256
- onClick: () => binding.setNotice(""),
47257
- children: /* @__PURE__ */ jsx98(X, {})
47258
- }
47259
- )
47260
- ]
47261
- }
47262
- ) : null
47263
- ] }),
47264
- composer: /* @__PURE__ */ jsx98(
47265
- AssistantComposer,
47266
- {
47267
- binding,
47268
- options: attachments,
47269
- placeholder,
47270
- suggestion: nextMessage,
47271
- busy: busy || Boolean(interrupt),
47272
- cancelling: status === "cancelling",
47273
- cancel: chat.cancel
47274
- }
47275
- ),
47276
- renderMessage: ({ message: rendered }) => {
47277
- const message = byId.get(rendered.id);
47278
- return message ? /* @__PURE__ */ jsx98(Fragment16, { children: editing?.id === message.id ? /* @__PURE__ */ jsx98(
47279
- EditComposer,
47280
- {
47281
- onKeyDown: (event) => {
47282
- if (event.key === "Escape" && !event.nativeEvent.isComposing)
47283
- setEditing(void 0);
47284
- },
47285
- inputProps: {
47286
- "aria-label": "\u7F16\u8F91\u6D88\u606F\u5185\u5BB9",
47287
- value: editing.text,
47288
- disabled: busy || binding.sending || binding.voice.status !== "idle",
47289
- onChange: (event) => setEditing({ ...editing, text: event.target.value })
47290
- },
47291
- cancelProps: {
47292
- type: "button",
47293
- onClick: () => setEditing(void 0)
47294
- },
47295
- sendProps: {
47296
- type: "button",
47297
- disabled: busy || binding.sending || binding.voice.status !== "idle" || !editing.text.trim() && !editing.files.length
47298
- },
47299
- children: editing.files.map((file) => /* @__PURE__ */ jsxs29(
47300
- "div",
47301
- {
47302
- className: cn(
47303
- "bg-muted flex min-w-0 items-center gap-2 rounded-md px-3 py-2 text-sm"
47304
- ),
47305
- children: [
47306
- /* @__PURE__ */ jsx98(Paperclip, { className: cn("size-4 shrink-0") }),
47307
- /* @__PURE__ */ jsx98("span", { className: cn("min-w-0 flex-1 truncate"), children: file.name }),
47308
- /* @__PURE__ */ jsx98(
47309
- TooltipIconButton,
47310
- {
47311
- tooltip: "\u79FB\u9664\u9644\u4EF6",
47312
- type: "button",
47313
- disabled: busy || binding.sending || binding.voice.status !== "idle",
47314
- "aria-label": `\u79FB\u9664 ${file.name}`,
47315
- onClick: () => setEditing({
47316
- ...editing,
47317
- files: editing.files.filter(
47318
- (item) => item.id !== file.id
47319
- )
47320
- }),
47321
- children: /* @__PURE__ */ jsx98(X, {})
47322
- }
47323
- )
47324
- ]
47325
- },
47326
- file.id
47327
- ))
47328
- }
47329
- ) : /* @__PURE__ */ jsx98(Fragment16, { children: message.role === "user" ? /* @__PURE__ */ jsx98(
47330
- UserMessage,
47331
- {
47332
- attachments: /* @__PURE__ */ jsx98(
47333
- "div",
47334
- {
47335
- className: cn(
47336
- "aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row flex-wrap justify-end gap-2 empty:hidden"
47337
- ),
47338
- children: /* @__PURE__ */ jsx98(MessagePrimitiveAttachments, { children: ({ attachment }) => /* @__PURE__ */ jsx98(
47339
- AttachmentTile,
47340
- {
47341
- savedPreview: message.attachments?.find(
47342
- (file) => file.id === attachment.id
47343
- )?.preview
47344
- }
47345
- ) })
47346
- }
47347
- ),
47348
- actions: message.id === latestUser?.id ? /* @__PURE__ */ jsx98(ActionBarPrimitiveEdit, { asChild: true, children: /* @__PURE__ */ jsx98(
47349
- "button",
47350
- {
47351
- type: "button",
47352
- "aria-label": "\u7F16\u8F91\u6D88\u606F",
47353
- className: cn(actionButtonClass),
47354
- disabled: busy || binding.sending || binding.voice.status !== "idle",
47355
- onClick: () => setEditing({
47356
- id: message.id,
47357
- text: textOf(message),
47358
- files: message.attachments ?? []
47359
- }),
47360
- children: /* @__PURE__ */ jsx98(Pencil, { className: cn("size-4") })
47361
- }
47362
- ) }) : null,
47363
- children: /* @__PURE__ */ jsx98(MessagePrimitiveParts2, {})
47364
- }
47365
- ) : /* @__PURE__ */ jsx98(AssistantMessage, { children: /* @__PURE__ */ jsx98(
47366
- AssistantParts,
47367
- {
47368
- showDetails: showToolDetails,
47369
- tools: message.parts
47370
- }
47371
- ) }) }) }) : /* @__PURE__ */ jsx98(AssistantMessage, { children: /* @__PURE__ */ jsx98(AssistantParts, { showDetails: showToolDetails }) });
47372
- },
47373
- children: interrupt ? /* @__PURE__ */ jsxs29(
47374
- "section",
47375
- {
47376
- "aria-label": interrupt.title ?? `\u786E\u8BA4\u6267\u884C ${interrupt.toolName}\uFF1F`,
47377
- className: cn("rounded-lg bg-muted p-4"),
47378
- "data-mode": interrupt.mode,
47379
- children: [
47380
- /* @__PURE__ */ jsx98("strong", { children: interrupt.title ?? `\u786E\u8BA4\u6267\u884C ${interrupt.toolName}\uFF1F` }),
47381
- interrupt.description ? /* @__PURE__ */ jsx98("p", { className: cn("mt-1 text-muted-foreground"), children: interrupt.description }) : null,
47382
- interrupt.mode === "chat" ? /* @__PURE__ */ jsxs29("div", { className: cn("mt-3 flex gap-2"), children: [
47383
- /* @__PURE__ */ jsx98(Button, { onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "\u786E\u8BA4" }),
47384
- /* @__PURE__ */ jsx98(Button, { variant: "outline", onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "\u62D2\u7EDD" })
47385
- ] }) : /* @__PURE__ */ jsx98("p", { className: cn("mt-1 text-muted-foreground"), children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })
47386
- ]
47387
- }
47388
- ) : null
47389
- }
47390
- )
47391
- }
47392
- )
47393
- ]
47394
- }
47395
- ),
47396
- /* @__PURE__ */ jsx98(
47397
- Dialog2,
47398
- {
47399
- open: Boolean(dialog),
47400
- onOpenChange: (next) => {
47401
- if (!next) {
47402
- dialog?.cancel?.();
47403
- setDialog(void 0);
47404
- }
47405
- },
47406
- children: /* @__PURE__ */ jsxs29(
47407
- DialogContent3,
45983
+ /* @__PURE__ */ jsxs29("section", { ref: panel, className: cn("nexface-chat__panel relative flex h-full min-h-0 overflow-hidden rounded-[inherit]"), "aria-label": `${title} chat`, children: [
45984
+ sidebarOpen && sidebarLayout === "overlay" ? /* @__PURE__ */ jsxs29(Fragment16, { children: [
45985
+ /* @__PURE__ */ jsx98("button", { type: "button", tabIndex: -1, "aria-label": "\u5173\u95ED\u4F1A\u8BDD\u5386\u53F2\u6D6E\u5C42", className: cn("absolute inset-0 z-4 bg-black/10"), onClick: () => setSidebar(false) }),
45986
+ history
45987
+ ] }) : null,
45988
+ /* @__PURE__ */ jsxs29("div", { ref: (element2) => {
45989
+ element2?.toggleAttribute("inert", sidebarOpen && sidebarLayout === "overlay");
45990
+ }, className: cn("flex min-h-0 min-w-0 flex-1 flex-col"), children: [
45991
+ /* @__PURE__ */ jsxs29("header", { "data-slot": "nexface_chat_header", className: cn("border-foreground/10 flex h-12 shrink-0 min-w-0 items-center gap-2 border-b px-4 md:px-5"), children: [
45992
+ /* @__PURE__ */ jsxs29("div", { className: cn("flex min-w-0 flex-1 items-center gap-2 whitespace-nowrap"), children: [
45993
+ sidebarEnabled && (sidebarLayout === "outside" || !sidebarOpen) ? /* @__PURE__ */ jsx98(Icon2, { ref: sidebarTrigger, label: sidebarOpen ? "\u6536\u8D77\u4F1A\u8BDD\u5386\u53F2" : "\u67E5\u770B\u4F1A\u8BDD\u5386\u53F2", "aria-expanded": sidebarOpen, className: cn("size-7 shrink-0"), onClick: () => setSidebar((value) => !value), children: /* @__PURE__ */ jsx98(PanelLeft, { className: cn("size-4") }) }) : null,
45994
+ /* @__PURE__ */ jsx98("strong", { className: cn("truncate text-[13px] font-medium"), children: activeTitle })
45995
+ ] }),
45996
+ /* @__PURE__ */ jsxs29("div", { className: cn("-me-1.5 ml-auto flex shrink-0 items-center gap-1.5"), children: [
45997
+ /* @__PURE__ */ jsxs29(DropdownMenu2, { modal: false, children: [
45998
+ /* @__PURE__ */ jsx98(DropdownMenuTrigger3, { asChild: true, children: /* @__PURE__ */ jsx98(Icon2, { label: "\u66F4\u591A\u4F1A\u8BDD\u64CD\u4F5C", children: /* @__PURE__ */ jsx98(Ellipsis, {}) }) }),
45999
+ /* @__PURE__ */ jsx98(DropdownMenuContent3, { align: "end", children: /* @__PURE__ */ jsx98(DropdownMenuItem3, { variant: "destructive", disabled: busy || binding.sending, onSelect: () => setDialog({ title: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2\uFF1F", description: "\u6240\u6709\u804A\u5929\u8BB0\u5F55\u5C06\u88AB\u6E05\u9664\uFF0C\u4E1A\u52A1\u64CD\u4F5C\u4E0D\u4F1A\u56DE\u6EDA\u3002", dangerous: true, action: chat.clearAllSessions }), children: "\u6E05\u7A7A\u5168\u90E8\u5386\u53F2" }) })
46000
+ ] }),
46001
+ /* @__PURE__ */ jsx98(Icon2, { label: "\u65B0\u5EFA\u804A\u5929\u4F1A\u8BDD", disabled: sessionBusy || binding.sending, onClick: () => safe(() => chat.createSession()), children: /* @__PURE__ */ jsx98(Plus, {}) }),
46002
+ /* @__PURE__ */ jsx98(Icon2, { ref: headerFocusButton, label: fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F", onClick: () => changeFullscreen(!fullscreen), children: fullscreen ? /* @__PURE__ */ jsx98(Minimize2, {}) : /* @__PURE__ */ jsx98(Maximize2, {}) }),
46003
+ onOpenChange ? /* @__PURE__ */ jsx98(Icon2, { label: "\u5173\u95ED Agent \u5BF9\u8BDD", onClick: () => onOpenChange(false), children: /* @__PURE__ */ jsx98(X, {}) }) : null
46004
+ ] })
46005
+ ] }),
46006
+ /* @__PURE__ */ jsx98("div", { "data-slot": "nexface_chat_body", className: cn("relative flex min-h-0 flex-1"), children: /* @__PURE__ */ jsx98(
46007
+ Thread,
46008
+ {
46009
+ empty: !messages.length,
46010
+ welcome: /* @__PURE__ */ jsx98(Greeting, { title: welcomeMessage, description: welcomeDescription }),
46011
+ suggestions: /* @__PURE__ */ jsx98(Suggestions2, { suggestions, disabled: busy || binding.sending || binding.voice.status !== "idle", onSend: (prompt) => void execute(prompt) }),
46012
+ footer: /* @__PURE__ */ jsxs29(Fragment16, { children: [
46013
+ chat.storageWarning ? /* @__PURE__ */ jsx98("div", { role: "alert", className: cn("text-muted-foreground text-xs"), children: chat.storageWarning }) : null,
46014
+ notice ? /* @__PURE__ */ jsxs29("div", { role: "status", className: cn("text-muted-foreground text-xs"), children: [
46015
+ notice,
46016
+ /* @__PURE__ */ jsx98("button", { onClick: () => setNotice(""), children: "\xD7" })
46017
+ ] }) : null,
46018
+ binding.notice ? /* @__PURE__ */ jsxs29(ErrorPrimitiveRoot, { className: cn("border-destructive/60 text-destructive flex items-start gap-3 border-l-2 pl-3 text-[13px] leading-relaxed"), children: [
46019
+ /* @__PURE__ */ jsx98("span", { className: cn("min-w-0 flex-1 break-words"), children: binding.notice }),
46020
+ /* @__PURE__ */ jsx98(Icon2, { label: "\u5173\u95ED\u63D0\u793A", className: cn("text-destructive hover:text-destructive -mt-1 -mr-1 shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/30"), onClick: () => binding.setNotice(""), children: /* @__PURE__ */ jsx98(X, {}) })
46021
+ ] }) : null
46022
+ ] }),
46023
+ composer: /* @__PURE__ */ jsx98(AssistantComposer, { binding, options: attachments, placeholder, suggestion: nextMessage, busy: busy || Boolean(interrupt), cancelling: status === "cancelling", cancel: chat.cancel }),
46024
+ renderMessage: ({ message: rendered }) => {
46025
+ const message = byId.get(rendered.id);
46026
+ return message ? /* @__PURE__ */ jsx98(Fragment16, { children: editing?.id === message.id ? /* @__PURE__ */ jsx98(
46027
+ EditComposer,
47408
46028
  {
47409
- showCloseButton: false,
47410
- onCloseAutoFocus: (event) => {
47411
- event.preventDefault();
47412
- queueMicrotask(() => {
47413
- const target = dialogReturnFocus.current;
47414
- if (target?.isConnected && !target.closest("[inert]")) target.focus();
47415
- else
47416
- panel.current?.querySelector("header button:not(:disabled)")?.focus();
47417
- });
46029
+ onKeyDown: (event) => {
46030
+ if (event.key === "Escape" && !event.nativeEvent.isComposing) setEditing(void 0);
47418
46031
  },
47419
- children: [
47420
- /* @__PURE__ */ jsx98(DialogTitle3, { children: dialog?.title }),
47421
- /* @__PURE__ */ jsx98(DialogDescription3, { children: dialog?.description }),
47422
- /* @__PURE__ */ jsxs29(DialogFooter, { children: [
47423
- /* @__PURE__ */ jsx98(
47424
- Button,
47425
- {
47426
- variant: "outline",
47427
- autoFocus: true,
47428
- onClick: () => {
47429
- dialog?.cancel?.();
47430
- setDialog(void 0);
47431
- },
47432
- children: "\u53D6\u6D88"
47433
- }
47434
- ),
47435
- /* @__PURE__ */ jsx98(
47436
- Button,
47437
- {
47438
- variant: dialog?.dangerous ? "destructive" : "default",
47439
- disabled: busy,
47440
- onClick: () => {
47441
- safe(() => dialog?.action());
47442
- setDialog(void 0);
47443
- },
47444
- children: "\u786E\u5B9A"
47445
- }
47446
- )
47447
- ] })
47448
- ]
46032
+ inputProps: { "aria-label": "\u7F16\u8F91\u6D88\u606F\u5185\u5BB9", value: editing.text, disabled: busy || binding.sending || binding.voice.status !== "idle", onChange: (event) => setEditing({ ...editing, text: event.target.value }) },
46033
+ cancelProps: { type: "button", onClick: () => setEditing(void 0) },
46034
+ sendProps: { type: "button", disabled: busy || binding.sending || binding.voice.status !== "idle" || !editing.text.trim() && !editing.files.length },
46035
+ children: editing.files.map((file) => /* @__PURE__ */ jsxs29("div", { className: cn("bg-muted flex min-w-0 items-center gap-2 rounded-md px-3 py-2 text-sm"), children: [
46036
+ /* @__PURE__ */ jsx98(Paperclip, { className: cn("size-4 shrink-0") }),
46037
+ /* @__PURE__ */ jsx98("span", { className: cn("min-w-0 flex-1 truncate"), children: file.name }),
46038
+ /* @__PURE__ */ jsx98(TooltipIconButton, { tooltip: "\u79FB\u9664\u9644\u4EF6", type: "button", disabled: busy || binding.sending || binding.voice.status !== "idle", "aria-label": `\u79FB\u9664 ${file.name}`, onClick: () => setEditing({ ...editing, files: editing.files.filter((item) => item.id !== file.id) }), children: /* @__PURE__ */ jsx98(X, {}) })
46039
+ ] }, file.id))
47449
46040
  }
47450
- )
47451
- }
47452
- )
47453
- ]
47454
- }
47455
- )
46041
+ ) : /* @__PURE__ */ jsx98(Fragment16, { children: message.role === "user" ? /* @__PURE__ */ jsx98(UserMessage, { attachments: /* @__PURE__ */ jsx98("div", { className: cn("aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row flex-wrap justify-end gap-2 empty:hidden"), children: /* @__PURE__ */ jsx98(MessagePrimitiveAttachments, { children: ({ attachment }) => /* @__PURE__ */ jsx98(AttachmentTile, { savedPreview: message.attachments?.find((file) => file.id === attachment.id)?.preview }) }) }), actions: message.id === latestUser?.id ? /* @__PURE__ */ jsx98(ActionBarPrimitiveEdit, { asChild: true, children: /* @__PURE__ */ jsx98("button", { type: "button", "aria-label": "\u7F16\u8F91\u6D88\u606F", className: cn(actionButtonClass), disabled: busy || binding.sending || binding.voice.status !== "idle", onClick: () => setEditing({ id: message.id, text: textOf(message), files: message.attachments ?? [] }), children: /* @__PURE__ */ jsx98(Pencil, { className: cn("size-4") }) }) }) : null, children: /* @__PURE__ */ jsx98(MessagePrimitiveParts2, {}) }) : /* @__PURE__ */ jsx98(AssistantMessage, { children: /* @__PURE__ */ jsx98(AssistantParts, { showDetails: showToolDetails, tools: message.parts }) }) }) }) : /* @__PURE__ */ jsx98(AssistantMessage, { children: /* @__PURE__ */ jsx98(AssistantParts, { showDetails: showToolDetails }) });
46042
+ },
46043
+ children: interrupt ? /* @__PURE__ */ jsxs29("section", { "aria-label": interrupt.title ?? `\u786E\u8BA4\u6267\u884C ${interrupt.toolName}\uFF1F`, className: cn("rounded-lg bg-muted p-4"), "data-mode": interrupt.mode, children: [
46044
+ /* @__PURE__ */ jsx98("strong", { children: interrupt.title ?? `\u786E\u8BA4\u6267\u884C ${interrupt.toolName}\uFF1F` }),
46045
+ interrupt.description ? /* @__PURE__ */ jsx98("p", { className: cn("mt-1 text-muted-foreground"), children: interrupt.description }) : null,
46046
+ interrupt.mode === "chat" ? /* @__PURE__ */ jsxs29("div", { className: cn("mt-3 flex gap-2"), children: [
46047
+ /* @__PURE__ */ jsx98(Button, { onClick: chat.confirmInterrupt, children: interrupt.confirmLabel ?? "\u786E\u8BA4" }),
46048
+ /* @__PURE__ */ jsx98(Button, { variant: "outline", onClick: chat.rejectInterrupt, children: interrupt.rejectLabel ?? "\u62D2\u7EDD" })
46049
+ ] }) : /* @__PURE__ */ jsx98("p", { className: cn("mt-1 text-muted-foreground"), children: "\u8BF7\u5728\u4E1A\u52A1\u9875\u9762\u5B8C\u6210\u786E\u8BA4\u3002" })
46050
+ ] }) : null
46051
+ }
46052
+ ) })
46053
+ ] }),
46054
+ /* @__PURE__ */ jsx98(Dialog2, { open: Boolean(dialog), onOpenChange: (next) => {
46055
+ if (!next) {
46056
+ dialog?.cancel?.();
46057
+ setDialog(void 0);
46058
+ }
46059
+ }, children: /* @__PURE__ */ jsxs29(DialogContent3, { showCloseButton: false, onCloseAutoFocus: (event) => {
46060
+ event.preventDefault();
46061
+ queueMicrotask(() => {
46062
+ const target = dialogReturnFocus.current;
46063
+ if (target?.isConnected && !target.closest("[inert]")) target.focus();
46064
+ else panel.current?.querySelector("header button:not(:disabled)")?.focus();
46065
+ });
46066
+ }, children: [
46067
+ /* @__PURE__ */ jsx98(DialogTitle3, { children: dialog?.title }),
46068
+ /* @__PURE__ */ jsx98(DialogDescription3, { children: dialog?.description }),
46069
+ /* @__PURE__ */ jsxs29(DialogFooter, { children: [
46070
+ /* @__PURE__ */ jsx98(Button, { variant: "outline", autoFocus: true, onClick: () => {
46071
+ dialog?.cancel?.();
46072
+ setDialog(void 0);
46073
+ }, children: "\u53D6\u6D88" }),
46074
+ /* @__PURE__ */ jsx98(Button, { variant: dialog?.dangerous ? "destructive" : "default", disabled: busy, onClick: () => {
46075
+ safe(() => dialog?.action());
46076
+ setDialog(void 0);
46077
+ }, children: "\u786E\u5B9A" })
46078
+ ] })
46079
+ ] }) })
46080
+ ] })
47456
46081
  ]
47457
46082
  }
47458
46083
  ) : null;
@@ -47503,3 +46128,4 @@ lucide-react/dist/esm/lucide-react.js:
47503
46128
  * See the LICENSE file in the root directory of this source tree.
47504
46129
  *)
47505
46130
  */
46131
+ //# sourceMappingURL=default-chat.js.map