import React, { useMemo } from 'react'; import { Text, View } from 'react-native'; import { Clock, Database, Webhook, Zap, type LucideIcon } from 'lucide-react-native'; import { useConversationFeatureNavigation } from '../../featureNavigationContext'; import { themedColor } from '../../theme'; import type { SuperagentToolRendererProps } from '../../types'; import { describeTrigger, getAutomationType } from '../automationWidgetUtils'; import { ToolWidgetRow } from '../primitives/ToolWidgetRow'; import { WidgetCard } from '../primitives/WidgetCard'; import { toolWidgetStyles } from '../primitives/toolWidgetStyles'; import { getSettledWidgetStatus, getStringArg, parseToolArgs } from '../toolWidgetUtils'; import { ActiveBadge, AutomationCardFooter } from './automationCardParts'; const TYPE_ICONS: Record = { scheduled: Clock, entity: Database, connector: Webhook, }; /** * create_automation — native port of the web CreateAutomationWidget task card * (the agent-builder variant): name + Active/Paused badge, trigger summary, * description, and the "runs when triggered" / credits footer. The web card * navigates to the Tasks tab on tap. */ export function CreateAutomationWidget({ agent, isLastAssistantMessage, toolCall }: SuperagentToolRendererProps) { const openFeature = useConversationFeatureNavigation(); const args = useMemo(() => parseToolArgs(toolCall), [toolCall]); const status = getSettledWidgetStatus(toolCall, isLastAssistantMessage); const name = getStringArg(args, ['name']); if (status === 'running') { return ; } if (status === 'error' || status === 'stopped') { return ; } const trigger = describeTrigger(args); const description = getStringArg(args, ['description']); const TypeIcon = TYPE_ICONS[getAutomationType(args) ?? ''] ?? Zap; const isActive = args?.is_active !== false; return ( openFeature('automations') : undefined} > {name || 'Automation'} {trigger ? {trigger} : null} {description ? ( {description} ) : null} ); }