'use client' import * as React from 'react' import { Wrench, AlertTriangle, Loader2, Check, X } from 'lucide-react' import { cn } from '@open-mercato/shared/lib/utils' import { Button } from '@open-mercato/ui/primitives/button' import type { PendingToolCall } from '../../types' interface ToolCallConfirmationProps { toolCall: PendingToolCall onApprove: () => void onReject: () => void } const DESTRUCTIVE_PATTERNS = [/^delete/i, /^remove/i, /\.delete$/i, /\.remove$/i] function isDestructive(toolName: string): boolean { return DESTRUCTIVE_PATTERNS.some((p) => p.test(toolName)) } export function ToolCallConfirmation({ toolCall, onApprove, onReject, }: ToolCallConfirmationProps) { const destructive = isDestructive(toolCall.toolName) // Show different UI based on status if (toolCall.status === 'executing') { return (
Executing {toolCall.toolName}...
) } if (toolCall.status === 'completed') { return (
{toolCall.toolName} completed successfully
) } if (toolCall.status === 'error') { return (
{toolCall.toolName} failed: {toolCall.error || 'Unknown error'}
) } if (toolCall.status === 'rejected') { return (
{toolCall.toolName} cancelled
) } // Pending state - show confirmation UI return (
{destructive ? ( ) : ( )} {destructive ? 'Destructive action requested' : 'AI wants to execute:'}
{toolCall.toolName}
{toolCall.args && Object.keys(toolCall.args).length > 0 && (
            {JSON.stringify(toolCall.args, null, 2)}
          
)}
{destructive && (

This action may not be reversible.

)}
) }