@aomi-labs/widget-lib 0.2.0 → 1.0.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.
@@ -0,0 +1,302 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React$1 from 'react';
3
+ import { CSSProperties, ReactNode, FC, ComponentPropsWithRef } from 'react';
4
+ import { ThreadMessageLike, ToolCallMessagePartComponent } from '@assistant-ui/react';
5
+ import * as class_variance_authority_types from 'class-variance-authority/types';
6
+ import { VariantProps } from 'class-variance-authority';
7
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
8
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
9
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
10
+ import * as AvatarPrimitive from '@radix-ui/react-avatar';
11
+ import { ClassValue } from 'clsx';
12
+
13
+ type WalletButtonState = {
14
+ address?: string;
15
+ chainId?: number;
16
+ isConnected: boolean;
17
+ ensName?: string;
18
+ };
19
+ type WalletFooterProps = {
20
+ wallet: WalletButtonState;
21
+ setWallet: (data: Partial<WalletButtonState>) => void;
22
+ };
23
+ /**
24
+ * Get network name from chainId
25
+ */
26
+ declare const getNetworkName: (chainId: number | string | undefined) => string;
27
+ /**
28
+ * Format wallet address for display (0x1234...5678)
29
+ */
30
+ declare const formatAddress: (addr?: string) => string;
31
+
32
+ type AomiFrameProps = {
33
+ width?: CSSProperties["width"];
34
+ height?: CSSProperties["height"];
35
+ className?: string;
36
+ style?: CSSProperties;
37
+ /** Render prop for wallet footer - receives wallet state and setter from lib */
38
+ walletFooter?: (props: WalletFooterProps) => ReactNode;
39
+ /** Additional content to render inside the frame */
40
+ children?: ReactNode;
41
+ };
42
+ declare const AomiFrame: ({ width, height, className, style, walletFooter, children, }: AomiFrameProps) => react_jsx_runtime.JSX.Element;
43
+
44
+ type RuntimeActions = {
45
+ sendSystemMessage: (message: string) => Promise<void>;
46
+ };
47
+ declare const useRuntimeActions: () => RuntimeActions;
48
+ declare function AomiRuntimeProvider({ children, backendUrl, publicKey, }: Readonly<{
49
+ children: ReactNode;
50
+ backendUrl?: string;
51
+ publicKey?: string;
52
+ }>): react_jsx_runtime.JSX.Element;
53
+
54
+ /**
55
+ * Thread Context Value
56
+ *
57
+ * Manages global state for multi-thread support:
58
+ * - Current active thread ID
59
+ * - Message history for all threads
60
+ * - Thread metadata (title, archived status)
61
+ */
62
+ type ThreadContextValue = {
63
+ currentThreadId: string;
64
+ setCurrentThreadId: (id: string) => void;
65
+ threadViewKey: number;
66
+ bumpThreadViewKey: () => void;
67
+ threads: Map<string, ThreadMessageLike[]>;
68
+ setThreads: React.Dispatch<React.SetStateAction<Map<string, ThreadMessageLike[]>>>;
69
+ threadMetadata: Map<string, ThreadMetadata>;
70
+ setThreadMetadata: React.Dispatch<React.SetStateAction<Map<string, ThreadMetadata>>>;
71
+ threadCnt: number;
72
+ setThreadCnt: React.Dispatch<React.SetStateAction<number>>;
73
+ getThreadMessages: (threadId: string) => ThreadMessageLike[];
74
+ setThreadMessages: (threadId: string, messages: ThreadMessageLike[]) => void;
75
+ getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
76
+ updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
77
+ };
78
+ type ThreadMetadata = {
79
+ title: string;
80
+ status: "regular" | "archived" | "pending";
81
+ lastActiveAt?: string | number;
82
+ };
83
+ /**
84
+ * Hook to access Thread Context
85
+ *
86
+ * Must be used within a ThreadContextProvider
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * const { currentThreadId, setCurrentThreadId } = useThreadContext();
91
+ * ```
92
+ */
93
+ declare function useThreadContext(): ThreadContextValue;
94
+ /**
95
+ * Thread Context Provider Props
96
+ */
97
+ type ThreadContextProviderProps = {
98
+ children: ReactNode;
99
+ /**
100
+ * Initial thread ID to set as current
101
+ * @default Generated UUID v4 (matches backend's generate_session_id)
102
+ */
103
+ initialThreadId?: string;
104
+ };
105
+ /**
106
+ * Thread Context Provider
107
+ *
108
+ * Provides global state for multi-thread management.
109
+ * Should be placed high in your component tree, typically in your root layout.
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * // app/layout.tsx
114
+ * export default function Layout({ children }) {
115
+ * return (
116
+ * <ThreadContextProvider>
117
+ * <AomiRuntimeProvider>
118
+ * {children}
119
+ * </AomiRuntimeProvider>
120
+ * </ThreadContextProvider>
121
+ * );
122
+ * }
123
+ * ```
124
+ */
125
+ declare function ThreadContextProvider({ children, initialThreadId, }: ThreadContextProviderProps): react_jsx_runtime.JSX.Element;
126
+
127
+ declare const Thread: FC;
128
+
129
+ declare const ThreadList: FC;
130
+
131
+ declare const buttonVariants: (props?: ({
132
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
133
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
134
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
135
+ declare function Button({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
136
+ asChild?: boolean;
137
+ }): react_jsx_runtime.JSX.Element;
138
+
139
+ declare function Input({ className, type, ...props }: React$1.ComponentProps<"input">): react_jsx_runtime.JSX.Element;
140
+
141
+ declare function Separator({ className, orientation, decorative, ...props }: React$1.ComponentProps<typeof SeparatorPrimitive.Root>): react_jsx_runtime.JSX.Element;
142
+
143
+ declare function TooltipProvider({ delayDuration, ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime.JSX.Element;
144
+ declare function Tooltip({ ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime.JSX.Element;
145
+ declare function TooltipTrigger({ ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
146
+ declare function TooltipContent({ className, sideOffset, children, ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
147
+
148
+ type SidebarContextProps = {
149
+ state: "expanded" | "collapsed";
150
+ open: boolean;
151
+ setOpen: (open: boolean) => void;
152
+ openMobile: boolean;
153
+ setOpenMobile: (open: boolean) => void;
154
+ isMobile: boolean;
155
+ toggleSidebar: () => void;
156
+ sidebarWidth: number;
157
+ setSidebarWidth: (width: number) => void;
158
+ };
159
+ declare function useSidebar(): SidebarContextProps;
160
+ declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React$1.ComponentProps<"div"> & {
161
+ defaultOpen?: boolean;
162
+ open?: boolean;
163
+ onOpenChange?: (open: boolean) => void;
164
+ }): react_jsx_runtime.JSX.Element;
165
+ declare function Sidebar({ side, variant, collapsible, className, children, ...props }: React$1.ComponentProps<"div"> & {
166
+ side?: "left" | "right";
167
+ variant?: "sidebar" | "floating" | "inset";
168
+ collapsible?: "offcanvas" | "icon" | "none";
169
+ }): react_jsx_runtime.JSX.Element;
170
+ declare function SidebarTrigger({ className, onClick, ...props }: React$1.ComponentProps<typeof Button>): react_jsx_runtime.JSX.Element;
171
+ declare function SidebarRail({ className, ...props }: React$1.ComponentProps<"button">): react_jsx_runtime.JSX.Element;
172
+ declare function SidebarInset({ className, ...props }: React$1.ComponentProps<"main">): react_jsx_runtime.JSX.Element;
173
+ declare function SidebarHeader({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
174
+ declare function SidebarFooter({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
175
+ declare function SidebarSeparator({ className, ...props }: React$1.ComponentProps<typeof Separator>): react_jsx_runtime.JSX.Element;
176
+ declare function SidebarContent({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
177
+ declare function SidebarGroup({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
178
+ declare function SidebarGroupLabel({ className, asChild, ...props }: React$1.ComponentProps<"div"> & {
179
+ asChild?: boolean;
180
+ }): react_jsx_runtime.JSX.Element;
181
+ declare function SidebarGroupAction({ className, asChild, ...props }: React$1.ComponentProps<"button"> & {
182
+ asChild?: boolean;
183
+ }): react_jsx_runtime.JSX.Element;
184
+ declare function SidebarGroupContent({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
185
+ declare function SidebarMenu({ className, ...props }: React$1.ComponentProps<"ul">): react_jsx_runtime.JSX.Element;
186
+ declare function SidebarMenuItem({ className, ...props }: React$1.ComponentProps<"li">): react_jsx_runtime.JSX.Element;
187
+ declare const sidebarMenuButtonVariants: (props?: ({
188
+ variant?: "default" | "outline" | null | undefined;
189
+ size?: "default" | "sm" | "lg" | null | undefined;
190
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
191
+ declare function SidebarMenuButton({ asChild, isActive, variant, size, tooltip, className, ...props }: React$1.ComponentProps<"button"> & {
192
+ asChild?: boolean;
193
+ isActive?: boolean;
194
+ tooltip?: string | React$1.ComponentProps<typeof TooltipContent>;
195
+ } & VariantProps<typeof sidebarMenuButtonVariants>): react_jsx_runtime.JSX.Element;
196
+ declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: React$1.ComponentProps<"button"> & {
197
+ asChild?: boolean;
198
+ showOnHover?: boolean;
199
+ }): react_jsx_runtime.JSX.Element;
200
+ declare function SidebarMenuBadge({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
201
+ declare function SidebarMenuSub({ className, ...props }: React$1.ComponentProps<"ul">): react_jsx_runtime.JSX.Element;
202
+ declare function SidebarMenuSubItem({ className, ...props }: React$1.ComponentProps<"li">): react_jsx_runtime.JSX.Element;
203
+ declare function SidebarMenuSubButton({ asChild, size, isActive, className, ...props }: React$1.ComponentProps<"a"> & {
204
+ asChild?: boolean;
205
+ size?: "sm" | "md";
206
+ isActive?: boolean;
207
+ }): react_jsx_runtime.JSX.Element;
208
+
209
+ type BaseSidebarProps = React$1.ComponentProps<typeof Sidebar> & {
210
+ /** Label to display on the footer button */
211
+ footerLabel?: string;
212
+ /** Secondary label (e.g., network name) */
213
+ footerSecondaryLabel?: string;
214
+ /** Click handler for footer button */
215
+ onFooterClick?: () => void;
216
+ /** Logo URL (defaults to aomi logo) */
217
+ logoUrl?: string;
218
+ /** Logo link href */
219
+ logoHref?: string;
220
+ };
221
+ declare function BaseSidebar({ footerLabel, footerSecondaryLabel, onFooterClick, logoUrl, logoHref, ...props }: BaseSidebarProps): react_jsx_runtime.JSX.Element;
222
+
223
+ type ThreadListSidebarProps = React$1.ComponentProps<typeof Sidebar> & {
224
+ /** Optional footer component (e.g., WalletFooter from consumer app) */
225
+ footer?: React$1.ReactNode;
226
+ };
227
+ declare function ThreadListSidebar({ footer, ...props }: ThreadListSidebarProps): react_jsx_runtime.JSX.Element;
228
+
229
+ declare const MarkdownText: React$1.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
230
+
231
+ declare const ToolFallback: ToolCallMessagePartComponent;
232
+
233
+ type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
234
+ tooltip: string;
235
+ side?: "top" | "bottom" | "left" | "right";
236
+ };
237
+ declare const TooltipIconButton: React$1.ForwardRefExoticComponent<Omit<TooltipIconButtonProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
238
+
239
+ declare const UserMessageAttachments: FC;
240
+ declare const ComposerAttachments: FC;
241
+
242
+ declare const Card: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
243
+ declare const CardHeader: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
244
+ declare const CardTitle: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLHeadingElement> & React$1.RefAttributes<HTMLParagraphElement>>;
245
+ declare const CardDescription: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLParagraphElement> & React$1.RefAttributes<HTMLParagraphElement>>;
246
+ declare const CardContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
247
+ declare const CardFooter: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
248
+
249
+ declare function Dialog({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
250
+ declare function DialogTrigger({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
251
+ declare function DialogPortal({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Portal>): react_jsx_runtime.JSX.Element;
252
+ declare function DialogClose({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
253
+ declare function DialogOverlay({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Overlay>): react_jsx_runtime.JSX.Element;
254
+ declare function DialogContent({ className, children, showCloseButton, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Content> & {
255
+ showCloseButton?: boolean;
256
+ }): react_jsx_runtime.JSX.Element;
257
+ declare function DialogHeader({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
258
+ declare function DialogFooter({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
259
+ declare function DialogTitle({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
260
+ declare function DialogDescription({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
261
+
262
+ declare function Avatar({ className, ...props }: React$1.ComponentProps<typeof AvatarPrimitive.Root>): react_jsx_runtime.JSX.Element;
263
+ declare function AvatarImage({ className, ...props }: React$1.ComponentProps<typeof AvatarPrimitive.Image>): react_jsx_runtime.JSX.Element;
264
+ declare function AvatarFallback({ className, ...props }: React$1.ComponentProps<typeof AvatarPrimitive.Fallback>): react_jsx_runtime.JSX.Element;
265
+
266
+ declare const badgeVariants: (props?: ({
267
+ variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
268
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
269
+ interface BadgeProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
270
+ }
271
+ declare function Badge({ className, variant, ...props }: BadgeProps): react_jsx_runtime.JSX.Element;
272
+
273
+ declare const Label: React$1.ForwardRefExoticComponent<React$1.LabelHTMLAttributes<HTMLLabelElement> & React$1.RefAttributes<HTMLLabelElement>>;
274
+
275
+ declare function Skeleton({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
276
+
277
+ declare function Breadcrumb({ ...props }: React$1.ComponentProps<"nav">): react_jsx_runtime.JSX.Element;
278
+ declare function BreadcrumbList({ className, ...props }: React$1.ComponentProps<"ol">): react_jsx_runtime.JSX.Element;
279
+ declare function BreadcrumbItem({ className, ...props }: React$1.ComponentProps<"li">): react_jsx_runtime.JSX.Element;
280
+ declare function BreadcrumbLink({ asChild, className, ...props }: React$1.ComponentProps<"a"> & {
281
+ asChild?: boolean;
282
+ }): react_jsx_runtime.JSX.Element;
283
+ declare function BreadcrumbPage({ className, ...props }: React$1.ComponentProps<"span">): react_jsx_runtime.JSX.Element;
284
+ declare function BreadcrumbSeparator({ children, className, ...props }: React$1.ComponentProps<"li">): react_jsx_runtime.JSX.Element;
285
+ declare function BreadcrumbEllipsis({ className, ...props }: React$1.ComponentProps<"span">): react_jsx_runtime.JSX.Element;
286
+
287
+ declare function Sheet({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
288
+ declare function SheetTrigger({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
289
+ declare function SheetClose({ ...props }: React$1.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
290
+ declare function SheetContent({ className, children, side, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Content> & {
291
+ side?: "top" | "right" | "bottom" | "left";
292
+ }): react_jsx_runtime.JSX.Element;
293
+ declare function SheetHeader({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
294
+ declare function SheetFooter({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
295
+ declare function SheetTitle({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
296
+ declare function SheetDescription({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
297
+
298
+ declare function useIsMobile(): boolean;
299
+
300
+ declare function cn(...inputs: ClassValue[]): string;
301
+
302
+ export { AomiFrame, AomiRuntimeProvider, Avatar, AvatarFallback, AvatarImage, Badge, BaseSidebar, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ComposerAttachments, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Input, Label, MarkdownText, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Thread, ThreadContextProvider, ThreadList, ThreadListSidebar, ToolFallback, Tooltip, TooltipContent, TooltipIconButton, TooltipProvider, TooltipTrigger, UserMessageAttachments, type WalletButtonState, type WalletFooterProps, badgeVariants, buttonVariants, cn, formatAddress, getNetworkName, useIsMobile, useRuntimeActions, useSidebar, useThreadContext };