@applica-software-guru/persona-sdk 0.1.80 → 0.1.83

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.
@@ -1,29 +1,89 @@
1
- import { ToolCallContentPartComponent } from '@assistant-ui/react';
2
- import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
3
- import { useState } from 'react';
4
- import { Button } from '../ui/button';
1
+ import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
2
+ import {
3
+ CheckIcon,
4
+ ChevronDownIcon,
5
+ ChevronUpIcon,
6
+ XCircleIcon,
7
+ } from "lucide-react";
8
+ import { useState } from "react";
9
+ import { Button } from "@/components/ui/button";
10
+ import { cn } from "@/lib/utils";
5
11
 
6
- export const ToolFallback: ToolCallContentPartComponent = ({ toolName, argsText, result }) => {
12
+ export const ToolFallback: ToolCallMessagePartComponent = ({
13
+ toolName,
14
+ argsText,
15
+ result,
16
+ status,
17
+ }) => {
7
18
  const [isCollapsed, setIsCollapsed] = useState(true);
19
+
20
+ const isCancelled =
21
+ status?.type === "incomplete" && status.reason === "cancelled";
22
+ const cancelledReason =
23
+ isCancelled && status.error
24
+ ? typeof status.error === "string"
25
+ ? status.error
26
+ : JSON.stringify(status.error)
27
+ : null;
28
+
8
29
  return (
9
- <div className="mb-4 flex w-full flex-col gap-3 rounded-lg border py-3">
10
- <div className="flex items-center gap-2 px-4">
11
- <CheckIcon className="size-4" />
12
- <p className="">
13
- Used tool: <b>{toolName}</b>
30
+ <div
31
+ className={cn(
32
+ "aui-tool-fallback-root mb-4 flex w-full flex-col gap-3 rounded-lg border py-3",
33
+ isCancelled && "border-muted-foreground/30 bg-muted/30",
34
+ )}
35
+ >
36
+ <div className="aui-tool-fallback-header flex items-center gap-2 px-4">
37
+ {isCancelled ? (
38
+ <XCircleIcon className="aui-tool-fallback-icon size-4 text-muted-foreground" />
39
+ ) : (
40
+ <CheckIcon className="aui-tool-fallback-icon size-4" />
41
+ )}
42
+ <p
43
+ className={cn(
44
+ "aui-tool-fallback-title grow",
45
+ isCancelled && "text-muted-foreground line-through",
46
+ )}
47
+ >
48
+ {isCancelled ? "Cancelled tool: " : "Used tool: "}
49
+ <b>{toolName}</b>
14
50
  </p>
15
- <div className="flex-grow" />
16
- <Button onClick={() => setIsCollapsed(!isCollapsed)}>{isCollapsed ? <ChevronUpIcon /> : <ChevronDownIcon />}</Button>
51
+ <Button onClick={() => setIsCollapsed(!isCollapsed)}>
52
+ {isCollapsed ? <ChevronUpIcon /> : <ChevronDownIcon />}
53
+ </Button>
17
54
  </div>
18
55
  {!isCollapsed && (
19
- <div className="flex flex-col gap-2 border-t pt-2">
20
- <div className="px-4">
21
- <pre className="whitespace-pre-wrap">{argsText}</pre>
56
+ <div className="aui-tool-fallback-content flex flex-col gap-2 border-t pt-2">
57
+ {cancelledReason && (
58
+ <div className="aui-tool-fallback-cancelled-root px-4">
59
+ <p className="aui-tool-fallback-cancelled-header font-semibold text-muted-foreground">
60
+ Cancelled reason:
61
+ </p>
62
+ <p className="aui-tool-fallback-cancelled-reason text-muted-foreground">
63
+ {cancelledReason}
64
+ </p>
65
+ </div>
66
+ )}
67
+ <div
68
+ className={cn(
69
+ "aui-tool-fallback-args-root px-4",
70
+ isCancelled && "opacity-60",
71
+ )}
72
+ >
73
+ <pre className="aui-tool-fallback-args-value whitespace-pre-wrap">
74
+ {argsText}
75
+ </pre>
22
76
  </div>
23
- {result !== undefined && (
24
- <div className="border-t border-dashed px-4 pt-2">
25
- <p className="font-semibold">Result:</p>
26
- <pre className="whitespace-pre-wrap">{typeof result === 'string' ? result : JSON.stringify(result, null, 2)}</pre>
77
+ {!isCancelled && result !== undefined && (
78
+ <div className="aui-tool-fallback-result-root border-t border-dashed px-4 pt-2">
79
+ <p className="aui-tool-fallback-result-header font-semibold">
80
+ Result:
81
+ </p>
82
+ <pre className="aui-tool-fallback-result-content whitespace-pre-wrap">
83
+ {typeof result === "string"
84
+ ? result
85
+ : JSON.stringify(result, null, 2)}
86
+ </pre>
27
87
  </div>
28
88
  )}
29
89
  </div>
@@ -1,38 +1,42 @@
1
- 'use client';
1
+ "use client";
2
2
 
3
- import { ComponentPropsWithoutRef, forwardRef } from 'react';
3
+ import { ComponentPropsWithRef, forwardRef } from "react";
4
+ import { Slottable } from "@radix-ui/react-slot";
4
5
 
5
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
6
- import { Button } from '@/components/ui/button';
7
- import { cn } from '@/lib/utils';
6
+ import {
7
+ Tooltip,
8
+ TooltipContent,
9
+ TooltipTrigger,
10
+ } from "@/components/ui/tooltip";
11
+ import { Button } from "@/components/ui/button";
12
+ import { cn } from "@/lib/utils";
8
13
 
9
- export type TooltipIconButtonProps = ComponentPropsWithoutRef<typeof Button> & {
14
+ export type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
10
15
  tooltip: string;
11
- side?: 'top' | 'bottom' | 'left' | 'right';
16
+ side?: "top" | "bottom" | "left" | "right";
12
17
  };
13
18
 
14
- export const TooltipIconButton = forwardRef<HTMLButtonElement, TooltipIconButtonProps>(
15
- ({ children, tooltip, side = 'bottom', className, ...rest }, ref) => {
16
- return (
17
- <TooltipProvider>
18
- <Tooltip>
19
- <TooltipTrigger asChild>
20
- <Button
21
- // variant="ghost"
22
- // size="icon"
23
- {...rest}
24
- className={cn('size-6 p-1', className)}
25
- ref={ref}
26
- >
27
- {children}
28
- <span className="sr-only">{tooltip}</span>
29
- </Button>
30
- </TooltipTrigger>
31
- <TooltipContent side={side}>{tooltip}</TooltipContent>
32
- </Tooltip>
33
- </TooltipProvider>
34
- );
35
- },
36
- );
19
+ export const TooltipIconButton = forwardRef<
20
+ HTMLButtonElement,
21
+ TooltipIconButtonProps
22
+ >(({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
23
+ return (
24
+ <Tooltip>
25
+ <TooltipTrigger asChild>
26
+ <Button
27
+ variant="ghost"
28
+ size="icon"
29
+ {...rest}
30
+ className={cn("aui-button-icon size-6 p-1", className)}
31
+ ref={ref}
32
+ >
33
+ <Slottable>{children}</Slottable>
34
+ <span className="aui-sr-only sr-only">{tooltip}</span>
35
+ </Button>
36
+ </TooltipTrigger>
37
+ <TooltipContent side={side}>{tooltip}</TooltipContent>
38
+ </Tooltip>
39
+ );
40
+ });
37
41
 
38
- TooltipIconButton.displayName = 'TooltipIconButton';
42
+ TooltipIconButton.displayName = "TooltipIconButton";
@@ -1,35 +1,51 @@
1
- 'use client';
1
+ import * as React from "react"
2
+ import * as AvatarPrimitive from "@radix-ui/react-avatar"
2
3
 
3
- import * as React from 'react';
4
- import * as AvatarPrimitive from '@radix-ui/react-avatar';
4
+ import { cn } from "@/lib/utils"
5
5
 
6
- import { cn } from '@/lib/utils';
6
+ function Avatar({
7
+ className,
8
+ ...props
9
+ }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
10
+ return (
11
+ <AvatarPrimitive.Root
12
+ data-slot="avatar"
13
+ className={cn(
14
+ "relative flex size-8 shrink-0 overflow-hidden rounded-full",
15
+ className
16
+ )}
17
+ {...props}
18
+ />
19
+ )
20
+ }
7
21
 
8
- const Avatar = React.forwardRef<React.ElementRef<typeof AvatarPrimitive.Root>, React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>>(
9
- ({ className, ...props }, ref) => (
10
- <AvatarPrimitive.Root ref={ref} className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)} {...props} />
11
- ),
12
- );
13
- Avatar.displayName = AvatarPrimitive.Root.displayName;
22
+ function AvatarImage({
23
+ className,
24
+ ...props
25
+ }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
26
+ return (
27
+ <AvatarPrimitive.Image
28
+ data-slot="avatar-image"
29
+ className={cn("aspect-square size-full", className)}
30
+ {...props}
31
+ />
32
+ )
33
+ }
14
34
 
15
- const AvatarImage = React.forwardRef<
16
- React.ElementRef<typeof AvatarPrimitive.Image>,
17
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
18
- >(({ className, ...props }, ref) => (
19
- <AvatarPrimitive.Image ref={ref} className={cn('aspect-square h-full w-full', className)} {...props} />
20
- ));
21
- AvatarImage.displayName = AvatarPrimitive.Image.displayName;
35
+ function AvatarFallback({
36
+ className,
37
+ ...props
38
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
39
+ return (
40
+ <AvatarPrimitive.Fallback
41
+ data-slot="avatar-fallback"
42
+ className={cn(
43
+ "bg-muted flex size-full items-center justify-center rounded-full",
44
+ className
45
+ )}
46
+ {...props}
47
+ />
48
+ )
49
+ }
22
50
 
23
- const AvatarFallback = React.forwardRef<
24
- React.ElementRef<typeof AvatarPrimitive.Fallback>,
25
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
26
- >(({ className, ...props }, ref) => (
27
- <AvatarPrimitive.Fallback
28
- ref={ref}
29
- className={cn('flex h-full w-full items-center justify-center rounded-full bg-muted', className)}
30
- {...props}
31
- />
32
- ));
33
- AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
34
-
35
- export { Avatar, AvatarImage, AvatarFallback };
51
+ export { Avatar, AvatarImage, AvatarFallback }
@@ -1,43 +1,60 @@
1
- import * as React from 'react';
2
- import { Slot } from '@radix-ui/react-slot';
3
- import { cva, type VariantProps } from 'class-variance-authority';
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
4
 
5
- import { cn } from '@/lib/utils';
5
+ import { cn } from "@/lib/utils"
6
6
 
7
7
  const buttonVariants = cva(
8
- 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
8
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
9
9
  {
10
10
  variants: {
11
11
  variant: {
12
- default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
13
- destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
14
- outline: 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
15
- secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
16
- ghost: 'hover:bg-accent hover:text-accent-foreground',
17
- link: 'text-primary underline-offset-4 hover:underline',
12
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
13
+ destructive:
14
+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
15
+ outline:
16
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
17
+ secondary:
18
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
19
+ ghost:
20
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
21
+ link: "text-primary underline-offset-4 hover:underline",
18
22
  },
19
23
  size: {
20
- default: 'h-9 px-4 py-2',
21
- sm: 'h-8 rounded-md px-3 text-xs',
22
- lg: 'h-10 rounded-md px-8',
23
- icon: 'h-9 w-9',
24
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
25
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
26
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
+ icon: "size-9",
28
+ "icon-sm": "size-8",
29
+ "icon-lg": "size-10",
24
30
  },
25
31
  },
26
32
  defaultVariants: {
27
- variant: 'default',
28
- size: 'default',
33
+ variant: "default",
34
+ size: "default",
29
35
  },
30
- },
31
- );
36
+ }
37
+ )
32
38
 
33
- export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
34
- asChild?: boolean;
35
- }
39
+ function Button({
40
+ className,
41
+ variant,
42
+ size,
43
+ asChild = false,
44
+ ...props
45
+ }: React.ComponentProps<"button"> &
46
+ VariantProps<typeof buttonVariants> & {
47
+ asChild?: boolean
48
+ }) {
49
+ const Comp = asChild ? Slot : "button"
36
50
 
37
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(({ className, variant, size, asChild = false, ...props }, ref) => {
38
- const Comp = asChild ? Slot : 'button';
39
- return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
40
- });
41
- Button.displayName = 'Button';
51
+ return (
52
+ <Comp
53
+ data-slot="button"
54
+ className={cn(buttonVariants({ variant, size, className }))}
55
+ {...props}
56
+ />
57
+ )
58
+ }
42
59
 
43
- export { Button, buttonVariants };
60
+ export { Button, buttonVariants }
@@ -47,8 +47,11 @@ function DialogOverlay({
47
47
  function DialogContent({
48
48
  className,
49
49
  children,
50
+ showCloseButton = true,
50
51
  ...props
51
- }: React.ComponentProps<typeof DialogPrimitive.Content>) {
52
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
53
+ showCloseButton?: boolean
54
+ }) {
52
55
  return (
53
56
  <DialogPortal data-slot="dialog-portal">
54
57
  <DialogOverlay />
@@ -61,10 +64,15 @@ function DialogContent({
61
64
  {...props}
62
65
  >
63
66
  {children}
64
- <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
65
- <XIcon />
66
- <span className="sr-only">Close</span>
67
- </DialogPrimitive.Close>
67
+ {showCloseButton && (
68
+ <DialogPrimitive.Close
69
+ data-slot="dialog-close"
70
+ className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
71
+ >
72
+ <XIcon />
73
+ <span className="sr-only">Close</span>
74
+ </DialogPrimitive.Close>
75
+ )}
68
76
  </DialogPrimitive.Content>
69
77
  </DialogPortal>
70
78
  )
@@ -1,32 +1,61 @@
1
- 'use client';
1
+ "use client"
2
2
 
3
- import * as React from 'react';
4
- import * as TooltipPrimitive from '@radix-ui/react-tooltip';
3
+ import * as React from "react"
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
5
5
 
6
- import { cn } from '@/lib/utils';
6
+ import { cn } from "@/lib/utils"
7
7
 
8
- const TooltipProvider = TooltipPrimitive.Provider;
8
+ function TooltipProvider({
9
+ delayDuration = 0,
10
+ ...props
11
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
12
+ return (
13
+ <TooltipPrimitive.Provider
14
+ data-slot="tooltip-provider"
15
+ delayDuration={delayDuration}
16
+ {...props}
17
+ />
18
+ )
19
+ }
9
20
 
10
- const Tooltip = TooltipPrimitive.Root;
21
+ function Tooltip({
22
+ ...props
23
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
24
+ return (
25
+ <TooltipProvider>
26
+ <TooltipPrimitive.Root data-slot="tooltip" {...props} />
27
+ </TooltipProvider>
28
+ )
29
+ }
11
30
 
12
- const TooltipTrigger = TooltipPrimitive.Trigger;
31
+ function TooltipTrigger({
32
+ ...props
33
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
34
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
35
+ }
13
36
 
14
- const TooltipContent = React.forwardRef<
15
- React.ElementRef<typeof TooltipPrimitive.Content>,
16
- React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
17
- >(({ className, sideOffset = 4, ...props }, ref) => (
18
- <TooltipPrimitive.Portal>
19
- <TooltipPrimitive.Content
20
- ref={ref}
21
- sideOffset={sideOffset}
22
- className={cn(
23
- 'z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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',
24
- className,
25
- )}
26
- {...props}
27
- />
28
- </TooltipPrimitive.Portal>
29
- ));
30
- TooltipContent.displayName = TooltipPrimitive.Content.displayName;
37
+ function TooltipContent({
38
+ className,
39
+ sideOffset = 0,
40
+ children,
41
+ ...props
42
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
43
+ return (
44
+ <TooltipPrimitive.Portal>
45
+ <TooltipPrimitive.Content
46
+ data-slot="tooltip-content"
47
+ sideOffset={sideOffset}
48
+ className={cn(
49
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
50
+ className
51
+ )}
52
+ {...props}
53
+ >
54
+ {children}
55
+ <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
56
+ </TooltipPrimitive.Content>
57
+ </TooltipPrimitive.Portal>
58
+ )
59
+ }
31
60
 
32
- export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
61
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
package/src/messages.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PersonaMessage } from './types';
2
- import { FileContentPart, ThreadMessageLike } from '@assistant-ui/react';
2
+ import { FileMessagePart, ThreadMessageLike } from '@assistant-ui/react';
3
3
 
4
4
  function removeEmptyMessages(messages: PersonaMessage[]): PersonaMessage[] {
5
5
  return messages.filter((message) => {
@@ -69,7 +69,7 @@ function convertMessage(message: PersonaMessage): ThreadMessageLike {
69
69
  type: 'file',
70
70
  data: message.file.url,
71
71
  mimeType: message.file.contentType,
72
- } as FileContentPart,
72
+ } as FileMessagePart,
73
73
  ]
74
74
  : [];
75
75