"use client"; import { makeAssistantToolUI } from "@assistant-ui/react"; import { z } from "zod"; import { cn } from "@/lib/utils"; import { CheckCircle, Star, Bell, Trash2, Eye, Settings } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; // Schema for action confirmation tool arguments export const ActionConfirmationArgsSchema = z.object({ actionType: z.enum(["watchlist_add", "watchlist_remove", "alert_set", "alert_delete"]), tokenSymbol: z.string(), details: z.array(z.string()).optional(), }); export type ActionConfirmationArgs = z.infer; // Schema for action confirmation result export const ActionConfirmationResultSchema = z.object({ success: z.boolean(), message: z.string().optional(), }); export type ActionConfirmationResult = z.infer; const ACTION_CONFIG = { watchlist_add: { icon: Star, title: "Added to Watchlist", iconColor: "text-yellow-500", bgColor: "bg-yellow-500/10", }, watchlist_remove: { icon: Trash2, title: "Removed from Watchlist", iconColor: "text-red-500", bgColor: "bg-red-500/10", }, alert_set: { icon: Bell, title: "Alert Created", iconColor: "text-blue-500", bgColor: "bg-blue-500/10", }, alert_delete: { icon: Trash2, title: "Alert Deleted", iconColor: "text-red-500", bgColor: "bg-red-500/10", }, }; /** * ActionConfirmationToolUI - Shows confirmation when AI executes actions * Used for watchlist add/remove, alert set/delete confirmations */ export const ActionConfirmationToolUI = makeAssistantToolUI({ toolName: "confirm_action", render: ({ args, result, status }) => { const isLoading = status.type === "running"; const config = ACTION_CONFIG[args.actionType]; const Icon = config.icon; return (
{/* Icon */}
{isLoading ? (
) : ( )}
{/* Content */}
{config.title} {args.tokenSymbol}
{/* Details */} {args.details && args.details.length > 0 && (

Default monitoring enabled:

    {args.details.map((detail, i) => (
  • {detail}
  • ))}
)} {/* Result message */} {result?.message && (

{result.message}

)}
{/* Action buttons */}
{(args.actionType === "watchlist_add" || args.actionType === "alert_set") && ( )}
); }, });