"use client"; import { Confirmation, ConfirmationAccepted, ConfirmationAction, ConfirmationActions, ConfirmationRejected, ConfirmationRequest, ConfirmationTitle, } from "@/components/ai-elements/confirmation"; import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput, } from "@/components/ai-elements/tool"; import type { ToolUIPart } from "ai"; import { CheckIcon, XIcon } from "lucide-react"; import { nanoid } from "nanoid"; const handleReject = () => { // In production, call addConfirmationResponse }; const handleAccept = () => { // In production, call addConfirmationResponse }; const toolCall: ToolUIPart = { errorText: undefined, input: { database: "analytics", params: ["2024-01-01"], query: "SELECT COUNT(*) FROM users WHERE created_at >= ?", }, output: `| User ID | Name | Email | Created At | |---------|------|-------|------------| | 1 | John Doe | john@example.com | 2024-01-15 | | 2 | Jane Smith | jane@example.com | 2024-01-20 | | 3 | Bob Wilson | bob@example.com | 2024-02-01 | | 4 | Alice Brown | alice@example.com | 2024-02-10 | | 5 | Charlie Davis | charlie@example.com | 2024-02-15 |`, state: "output-available" as const, toolCallId: nanoid(), type: "tool-database_query" as const, }; const Example = () => (
{/* 1. input-streaming: Pending */} {/* 2. approval-requested: Awaiting Approval */} This tool will execute a query on the production database. Accepted Rejected Reject Accept {/* 3. approval-responded: Responded */} This tool will execute a query on the production database. Accepted Rejected {/* 4. input-available: Running */} {/* 5. output-available: Completed */} This tool will execute a query on the production database. Accepted Rejected {toolCall.state === "output-available" && ( )} {/* 6. output-error: Error */} {/* 7. output-denied: Denied */} This tool will execute a query on the production database. Accepted Rejected: Query could impact production performance
); export default Example;