@ash-cloud/ash-ui 0.0.9 → 0.1.0

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.
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AA6XO,SAAS,mBAAmB,MAAA,EAAgD;AACjF,EAAA,OAAO,OAAO,MAAA,KAAW,aAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,eAAe,MAAA,EAA4C;AACzE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA;AAC3B;AAEO,SAAS,aAAa,MAAA,EAA0C;AACrE,EAAA,OAAO,OAAO,MAAA,KAAW,MAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,OAAO,OAAO,MAAA,KAAW,UAAA;AAC3B;AAEO,SAAS,oBAAoB,MAAA,EAAiD;AACnF,EAAA,OAAO,OAAO,MAAA,KAAW,cAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,KAAA,EAAoD;AAClF,EAAA,OAAO,MAAM,IAAA,KAAS,WAAA;AACxB;AAEO,SAAS,aAAa,KAAA,EAAiD;AAC5E,EAAA,OAAO,MAAM,IAAA,KAAS,OAAA;AACxB;AAEO,SAAS,cAAc,KAAA,EAAkD;AAC9E,EAAA,OAAO,MAAM,IAAA,KAAS,QAAA;AACxB;AAsIO,IAAM,sBAAA,GAA4C;AAAA,EACvD,IAAA,EAAM,QAAA;AAAA,EACN,oBAAA,EAAsB,CAAA;AAAA,EACtB,eAAA,EAAiB,KAAA;AAAA,EACjB,iBAAA,EAAmB;AACrB","file":"types.js","sourcesContent":["/**\n * @ash-cloud/ash-ui - Types\n *\n * Normalized types for structured tool call display in agentic UIs.\n * These types provide a unified representation for displaying tool calls\n * with their arguments and results together.\n */\n\nimport type { ReactNode } from 'react';\n\n// =============================================================================\n// Tool Status\n// =============================================================================\n\n/**\n * Status of a tool call execution\n */\nexport type ToolStatus = 'pending' | 'success' | 'failed';\n\n// =============================================================================\n// Action-Specific Result Types\n// =============================================================================\n\n/**\n * Result from a command/bash execution\n */\nexport interface CommandRunResult {\n exitCode?: number;\n success?: boolean;\n output?: string;\n}\n\n/**\n * Generic tool result that can be markdown or structured JSON\n */\nexport interface ToolResult {\n type: 'markdown' | 'json';\n value: unknown;\n}\n\n// =============================================================================\n// Action Types (Discriminated Union)\n// =============================================================================\n\n/**\n * Bash/command execution action\n */\nexport interface CommandRunAction {\n action: 'command_run';\n command: string;\n description?: string;\n result?: CommandRunResult;\n}\n\n/**\n * File read action\n */\nexport interface FileReadAction {\n action: 'file_read';\n path: string;\n offset?: number;\n limit?: number;\n /** Number of lines read (for display) */\n linesRead?: number;\n}\n\n/**\n * File edit action\n */\nexport interface FileEditAction {\n action: 'file_edit';\n path: string;\n oldString?: string;\n newString?: string;\n replaceAll?: boolean;\n /** Number of lines added */\n linesAdded?: number;\n /** Number of lines removed */\n linesRemoved?: number;\n}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\n /** Number of lines written */\n linesWritten?: number;\n}\n\n/**\n * Search/grep action\n */\nexport interface SearchAction {\n action: 'search';\n pattern: string;\n path?: string;\n glob?: string;\n type?: string;\n}\n\n/**\n * Glob/file pattern matching action\n */\nexport interface GlobAction {\n action: 'glob';\n pattern: string;\n path?: string;\n}\n\n/**\n * Web fetch action\n */\nexport interface WebFetchAction {\n action: 'web_fetch';\n url: string;\n prompt?: string;\n}\n\n/**\n * Web search action\n */\nexport interface WebSearchAction {\n action: 'web_search';\n query: string;\n}\n\n/**\n * MCP (Model Context Protocol) tool action\n */\nexport interface McpToolAction {\n action: 'mcp_tool';\n serverName: string;\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Generic/unknown tool action\n */\nexport interface GenericToolAction {\n action: 'generic_tool';\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Agent/Task tool action - represents a sub-agent that can have nested tool calls\n */\nexport interface AgentToolAction {\n action: 'agent_tool';\n /** Agent type (e.g., 'Explore', 'Plan', 'Bash', 'general-purpose') */\n agentType: string;\n /** Description of what the agent is doing */\n description: string;\n /** Full prompt given to the agent */\n prompt?: string;\n /** Nested tool calls made by this agent */\n nestedToolCalls?: NormalizedToolCall[];\n /** Current count of tool calls (updates during streaming) */\n toolCallCount?: number;\n /** When the agent started */\n startedAt?: string;\n /** When the agent completed */\n completedAt?: string;\n /** Result/output from the agent */\n result?: ToolResult;\n}\n\n// =============================================================================\n// Todo Types\n// =============================================================================\n\n/**\n * Status of a todo item\n */\nexport type TodoStatus = 'pending' | 'in_progress' | 'completed';\n\n/**\n * A single todo item from TodoWrite tool\n */\nexport interface TodoItem {\n /** Task content - imperative form (e.g., \"Run tests\") */\n content: string;\n /** Current status of the todo */\n status: TodoStatus;\n /** Active form shown during execution (e.g., \"Running tests\") */\n activeForm: string;\n}\n\n/**\n * TodoWrite tool action - tracks task progress\n */\nexport interface TodoWriteAction {\n action: 'todo_write';\n /** All todos in the current list */\n todos: TodoItem[];\n /** Summary statistics */\n stats?: {\n total: number;\n completed: number;\n inProgress: number;\n pending: number;\n };\n}\n\n/**\n * Discriminated union of all action types\n */\nexport type ActionType =\n | CommandRunAction\n | FileReadAction\n | FileEditAction\n | FileWriteAction\n | SearchAction\n | GlobAction\n | WebFetchAction\n | WebSearchAction\n | McpToolAction\n | GenericToolAction\n | TodoWriteAction\n | AgentToolAction;\n\n// =============================================================================\n// Normalized Tool Call\n// =============================================================================\n\n/**\n * A normalized tool call that combines tool_use and tool_result data\n */\nexport interface NormalizedToolCall {\n /** Unique ID from the tool_use block */\n id: string;\n\n /** Original tool name (e.g., 'Bash', 'Read', 'mcp__server__tool') */\n toolName: string;\n\n /** Parsed action type with structured arguments and result */\n actionType: ActionType;\n\n /** Current execution status */\n status: ToolStatus;\n\n /** Human-readable one-liner summary */\n summary: string;\n\n /** Raw input from tool_use event (for display in UI) */\n input?: unknown;\n\n /** Raw output/result from tool_result event (for display in UI) */\n output?: unknown;\n\n /** When the tool call started */\n startedAt?: string;\n\n /** When the tool call completed */\n completedAt?: string;\n\n /** Whether this tool call resulted in an error */\n isError?: boolean;\n\n /** Nested tool calls (for agent/sub-agent tools like Task) */\n nestedToolCalls?: NormalizedToolCall[];\n\n /** Current count of nested tool calls (updates during streaming) */\n nestedToolCallCount?: number;\n}\n\n// =============================================================================\n// Normalized Entry Types\n// =============================================================================\n\n/**\n * User message entry\n */\nexport interface UserMessageEntry {\n type: 'user_message';\n}\n\n/**\n * Assistant message entry\n */\nexport interface AssistantMessageEntry {\n type: 'assistant_message';\n}\n\n/**\n * Thinking/reasoning entry (extended thinking)\n */\nexport interface ThinkingEntry {\n type: 'thinking';\n}\n\n/**\n * Tool call entry with full tool call data\n */\nexport interface ToolCallEntry {\n type: 'tool_call';\n toolCall: NormalizedToolCall;\n}\n\n/**\n * Error entry\n */\nexport interface ErrorEntry {\n type: 'error';\n message: string;\n code?: string;\n}\n\n/**\n * Custom widget entry - rendered via consumer-provided render function\n *\n * Use this for interactive UI components like:\n * - Image grid selectors\n * - Product carousels\n * - Form inputs\n * - Data visualizations\n * - Any custom interactive widget\n *\n * @example\n * ```tsx\n * const entry: NormalizedEntry = {\n * id: 'widget-1',\n * entryType: {\n * type: 'widget',\n * widgetType: 'image-grid',\n * widgetData: { images: [...], selected: null },\n * },\n * content: 'Select an image',\n * };\n * ```\n */\nexport interface WidgetEntry {\n type: 'widget';\n /** Widget type identifier (e.g., 'image-grid', 'product-selector') */\n widgetType: string;\n /** Widget-specific data passed to the render function */\n widgetData: unknown;\n}\n\n/**\n * Discriminated union of all entry types\n */\nexport type NormalizedEntryType =\n | UserMessageEntry\n | AssistantMessageEntry\n | ThinkingEntry\n | ToolCallEntry\n | ErrorEntry\n | WidgetEntry;\n\n// =============================================================================\n// Normalized Entry\n// =============================================================================\n\n/**\n * A normalized conversation entry for display\n */\nexport interface NormalizedEntry {\n /** Unique entry ID */\n id: string;\n\n /** ISO timestamp */\n timestamp?: string;\n\n /** Entry type with type-specific data */\n entryType: NormalizedEntryType;\n\n /** Text content for display */\n content: string;\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\nexport function isCommandRunAction(action: ActionType): action is CommandRunAction {\n return action.action === 'command_run';\n}\n\nexport function isFileReadAction(action: ActionType): action is FileReadAction {\n return action.action === 'file_read';\n}\n\nexport function isFileEditAction(action: ActionType): action is FileEditAction {\n return action.action === 'file_edit';\n}\n\nexport function isFileWriteAction(action: ActionType): action is FileWriteAction {\n return action.action === 'file_write';\n}\n\nexport function isSearchAction(action: ActionType): action is SearchAction {\n return action.action === 'search';\n}\n\nexport function isGlobAction(action: ActionType): action is GlobAction {\n return action.action === 'glob';\n}\n\nexport function isWebFetchAction(action: ActionType): action is WebFetchAction {\n return action.action === 'web_fetch';\n}\n\nexport function isWebSearchAction(action: ActionType): action is WebSearchAction {\n return action.action === 'web_search';\n}\n\nexport function isMcpToolAction(action: ActionType): action is McpToolAction {\n return action.action === 'mcp_tool';\n}\n\nexport function isGenericToolAction(action: ActionType): action is GenericToolAction {\n return action.action === 'generic_tool';\n}\n\nexport function isTodoWriteAction(action: ActionType): action is TodoWriteAction {\n return action.action === 'todo_write';\n}\n\nexport function isAgentToolAction(action: ActionType): action is AgentToolAction {\n return action.action === 'agent_tool';\n}\n\nexport function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry {\n return entry.type === 'tool_call';\n}\n\nexport function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry {\n return entry.type === 'error';\n}\n\nexport function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry {\n return entry.type === 'widget';\n}\n\n// =============================================================================\n// Widget Rendering\n// =============================================================================\n\n/**\n * Props passed to the widget render function\n */\nexport interface WidgetRenderProps<T = unknown> {\n /** The widget entry being rendered */\n entry: NormalizedEntry;\n /** Widget type identifier */\n widgetType: string;\n /** Widget-specific data */\n widgetData: T;\n /** Callback for widget interactions (e.g., selection, submit) */\n onAction?: (action: WidgetAction) => void;\n}\n\n/**\n * Action dispatched from a widget interaction\n */\nexport interface WidgetAction {\n /** Action type (e.g., 'select', 'submit', 'cancel') */\n type: string;\n /** Widget type that dispatched the action */\n widgetType: string;\n /** Entry ID of the widget */\n entryId: string;\n /** Action-specific payload */\n payload?: unknown;\n}\n\n/**\n * Function type for rendering custom widgets\n *\n * @example\n * ```tsx\n * const renderWidget: WidgetRenderFunction = ({ widgetType, widgetData, onAction }) => {\n * switch (widgetType) {\n * case 'image-grid':\n * return (\n * <ImageGrid\n * images={widgetData.images}\n * onSelect={(id) => onAction?.({ type: 'select', widgetType, entryId, payload: { id } })}\n * />\n * );\n * case 'product-selector':\n * return <ProductSelector data={widgetData} onAction={onAction} />;\n * default:\n * return null;\n * }\n * };\n *\n * <MessageList entries={entries} renderWidget={renderWidget} />\n * ```\n */\nexport type WidgetRenderFunction = (props: WidgetRenderProps) => ReactNode;\n\n// =============================================================================\n// Log Types (for SandboxLogsPanel)\n// =============================================================================\n\nexport type LogLevel = 'info' | 'warn' | 'error' | 'debug';\nexport type LogCategory = 'setup' | 'skills' | 'execution' | 'process' | 'startup';\n\nexport interface LogEntry {\n timestamp: string;\n level: LogLevel;\n category: LogCategory;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// =============================================================================\n// File Attachment\n// =============================================================================\n\nexport interface FileAttachment {\n name: string;\n type: string;\n size: number;\n base64: string;\n}\n\n// =============================================================================\n// Display Mode Configuration\n// =============================================================================\n\n/**\n * Display mode for tool calls in the chat interface\n *\n * - 'inline': Each tool call rendered inline as expandable cards (current behavior)\n * - 'compact': Single animated status line that updates with each tool call,\n * with accordion to expand and see execution details. Text streams unbroken.\n * - 'accordion': Simpler step-based accordion list that accumulates tool calls\n * with icons, labels, and durations (like Vidra's ThinkingIndicator).\n */\nexport type ToolDisplayMode = 'inline' | 'compact' | 'accordion';\n\n/**\n * Configuration for tool display behavior\n */\nexport interface ToolDisplayConfig {\n /**\n * Display mode for tool calls\n * @default 'inline'\n */\n mode: ToolDisplayMode;\n\n /**\n * For 'compact' mode: break into a new group every N tool calls\n * Set to 0 or undefined to never break (all tool calls in single group)\n * @default 0\n */\n breakEveryNToolCalls?: number;\n\n /**\n * Whether tool call groups start expanded\n * @default false\n */\n defaultExpanded?: boolean;\n\n /**\n * Animation duration for status line transitions (ms)\n * @default 300\n */\n animationDuration?: number;\n}\n\n/**\n * Default display configuration\n */\nexport const DEFAULT_DISPLAY_CONFIG: ToolDisplayConfig = {\n mode: 'inline',\n breakEveryNToolCalls: 0,\n defaultExpanded: false,\n animationDuration: 300,\n};\n\n// =============================================================================\n// Tool Execution Group (for compact mode)\n// =============================================================================\n\n/**\n * A group of consecutive tool calls that are displayed together\n * in compact mode. Text content before/after flows around the group.\n */\nexport interface ToolExecutionGroup {\n /** Unique ID for the group */\n id: string;\n\n /** Tool calls in this group (in order) */\n toolCalls: NormalizedToolCall[];\n\n /** Index of the currently active/latest tool call for status display */\n activeIndex: number;\n\n /** Whether all tool calls in this group have completed */\n isComplete: boolean;\n\n /** Overall status of the group */\n status: 'pending' | 'success' | 'partial_failure' | 'failed';\n}\n"]}
1
+ {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AA4YO,SAAS,mBAAmB,MAAA,EAAgD;AACjF,EAAA,OAAO,OAAO,MAAA,KAAW,aAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,eAAe,MAAA,EAA4C;AACzE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA;AAC3B;AAEO,SAAS,aAAa,MAAA,EAA0C;AACrE,EAAA,OAAO,OAAO,MAAA,KAAW,MAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,OAAO,OAAO,MAAA,KAAW,UAAA;AAC3B;AAEO,SAAS,oBAAoB,MAAA,EAAiD;AACnF,EAAA,OAAO,OAAO,MAAA,KAAW,cAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,KAAA,EAAoD;AAClF,EAAA,OAAO,MAAM,IAAA,KAAS,WAAA;AACxB;AAEO,SAAS,aAAa,KAAA,EAAiD;AAC5E,EAAA,OAAO,MAAM,IAAA,KAAS,OAAA;AACxB;AAEO,SAAS,cAAc,KAAA,EAAkD;AAC9E,EAAA,OAAO,MAAM,IAAA,KAAS,QAAA;AACxB;AAsIO,IAAM,sBAAA,GAA4C;AAAA,EACvD,IAAA,EAAM,QAAA;AAAA,EACN,oBAAA,EAAsB,CAAA;AAAA,EACtB,eAAA,EAAiB,KAAA;AAAA,EACjB,iBAAA,EAAmB;AACrB","file":"types.js","sourcesContent":["/**\n * @ash-cloud/ash-ui - Types\n *\n * Normalized types for structured tool call display in agentic UIs.\n * These types provide a unified representation for displaying tool calls\n * with their arguments and results together.\n */\n\nimport type { ReactNode } from 'react';\n\n// =============================================================================\n// Tool Status\n// =============================================================================\n\n/**\n * Status of a tool call execution\n */\nexport type ToolStatus = 'pending' | 'success' | 'failed';\n\n// =============================================================================\n// Action-Specific Result Types\n// =============================================================================\n\n/**\n * Result from a command/bash execution\n */\nexport interface CommandRunResult {\n exitCode?: number;\n success?: boolean;\n output?: string;\n}\n\n/**\n * Generic tool result that can be markdown or structured JSON\n */\nexport interface ToolResult {\n type: 'markdown' | 'json';\n value: unknown;\n}\n\n// =============================================================================\n// Action Types (Discriminated Union)\n// =============================================================================\n\n/**\n * Bash/command execution action\n */\nexport interface CommandRunAction {\n action: 'command_run';\n command: string;\n description?: string;\n result?: CommandRunResult;\n}\n\n/**\n * File read action\n */\nexport interface FileReadAction {\n action: 'file_read';\n path: string;\n offset?: number;\n limit?: number;\n /** Number of lines read (for display) */\n linesRead?: number;\n}\n\n/**\n * File edit action\n */\nexport interface FileEditAction {\n action: 'file_edit';\n path: string;\n oldString?: string;\n newString?: string;\n replaceAll?: boolean;\n /** Number of lines added */\n linesAdded?: number;\n /** Number of lines removed */\n linesRemoved?: number;\n}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\n /** Number of lines written */\n linesWritten?: number;\n}\n\n/**\n * Search/grep action\n */\nexport interface SearchAction {\n action: 'search';\n pattern: string;\n path?: string;\n glob?: string;\n type?: string;\n}\n\n/**\n * Glob/file pattern matching action\n */\nexport interface GlobAction {\n action: 'glob';\n pattern: string;\n path?: string;\n}\n\n/**\n * Web fetch action\n */\nexport interface WebFetchAction {\n action: 'web_fetch';\n url: string;\n prompt?: string;\n}\n\n/**\n * Web search action\n */\nexport interface WebSearchAction {\n action: 'web_search';\n query: string;\n}\n\n/**\n * MCP (Model Context Protocol) tool action\n */\nexport interface McpToolAction {\n action: 'mcp_tool';\n serverName: string;\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Generic/unknown tool action\n */\nexport interface GenericToolAction {\n action: 'generic_tool';\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Agent/Task tool action - represents a sub-agent that can have nested tool calls\n */\nexport interface AgentToolAction {\n action: 'agent_tool';\n /** Agent type (e.g., 'Explore', 'Plan', 'Bash', 'general-purpose') */\n agentType: string;\n /** Description of what the agent is doing */\n description: string;\n /** Full prompt given to the agent */\n prompt?: string;\n /** Nested tool calls made by this agent */\n nestedToolCalls?: NormalizedToolCall[];\n /** Current count of tool calls (updates during streaming) */\n toolCallCount?: number;\n /** When the agent started */\n startedAt?: string;\n /** When the agent completed */\n completedAt?: string;\n /** Result/output from the agent */\n result?: ToolResult;\n}\n\n// =============================================================================\n// Todo Types\n// =============================================================================\n\n/**\n * Status of a todo item\n */\nexport type TodoStatus = 'pending' | 'in_progress' | 'completed';\n\n/**\n * A single todo item from TodoWrite tool\n */\nexport interface TodoItem {\n /** Task content - imperative form (e.g., \"Run tests\") */\n content: string;\n /** Current status of the todo */\n status: TodoStatus;\n /** Active form shown during execution (e.g., \"Running tests\") */\n activeForm: string;\n}\n\n/**\n * TodoWrite tool action - tracks task progress\n */\nexport interface TodoWriteAction {\n action: 'todo_write';\n /** All todos in the current list */\n todos: TodoItem[];\n /** Summary statistics */\n stats?: {\n total: number;\n completed: number;\n inProgress: number;\n pending: number;\n };\n}\n\n/**\n * Discriminated union of all action types\n */\nexport type ActionType =\n | CommandRunAction\n | FileReadAction\n | FileEditAction\n | FileWriteAction\n | SearchAction\n | GlobAction\n | WebFetchAction\n | WebSearchAction\n | McpToolAction\n | GenericToolAction\n | TodoWriteAction\n | AgentToolAction;\n\n// =============================================================================\n// Normalized Tool Call\n// =============================================================================\n\n/**\n * A normalized tool call that combines tool_use and tool_result data\n */\nexport interface NormalizedToolCall {\n /** Unique ID from the tool_use block */\n id: string;\n\n /** Original tool name (e.g., 'Bash', 'Read', 'mcp__server__tool') */\n toolName: string;\n\n /** Parsed action type with structured arguments and result */\n actionType: ActionType;\n\n /** Current execution status */\n status: ToolStatus;\n\n /** Human-readable one-liner summary */\n summary: string;\n\n /** Raw input from tool_use event (for display in UI) */\n input?: unknown;\n\n /** Raw output/result from tool_result event (for display in UI) */\n output?: unknown;\n\n /** When the tool call started */\n startedAt?: string;\n\n /** When the tool call completed */\n completedAt?: string;\n\n /** Whether this tool call resulted in an error */\n isError?: boolean;\n\n /** Nested tool calls (for agent/sub-agent tools like Task) */\n nestedToolCalls?: NormalizedToolCall[];\n\n /** Current count of nested tool calls (updates during streaming) */\n nestedToolCallCount?: number;\n}\n\n// =============================================================================\n// Normalized Entry Types\n// =============================================================================\n\n/**\n * User message entry\n */\nexport interface UserMessageEntry {\n type: 'user_message';\n}\n\n/**\n * Assistant message entry\n */\nexport interface AssistantMessageEntry {\n type: 'assistant_message';\n}\n\n/**\n * Thinking/reasoning entry (extended thinking)\n */\nexport interface ThinkingEntry {\n type: 'thinking';\n}\n\n/**\n * Tool call entry with full tool call data\n */\nexport interface ToolCallEntry {\n type: 'tool_call';\n toolCall: NormalizedToolCall;\n}\n\n/**\n * Error entry\n */\nexport interface ErrorEntry {\n type: 'error';\n message: string;\n code?: string;\n}\n\n/**\n * Custom widget entry - rendered via consumer-provided render function\n *\n * Use this for interactive UI components like:\n * - Image grid selectors\n * - Product carousels\n * - Form inputs\n * - Data visualizations\n * - Any custom interactive widget\n *\n * @example\n * ```tsx\n * const entry: NormalizedEntry = {\n * id: 'widget-1',\n * entryType: {\n * type: 'widget',\n * widgetType: 'image-grid',\n * widgetData: { images: [...], selected: null },\n * },\n * content: 'Select an image',\n * };\n * ```\n */\nexport interface WidgetEntry {\n type: 'widget';\n /** Widget type identifier (e.g., 'image-grid', 'product-selector') */\n widgetType: string;\n /** Widget-specific data passed to the render function */\n widgetData: unknown;\n}\n\n/**\n * Discriminated union of all entry types\n */\nexport type NormalizedEntryType =\n | UserMessageEntry\n | AssistantMessageEntry\n | ThinkingEntry\n | ToolCallEntry\n | ErrorEntry\n | WidgetEntry;\n\n// =============================================================================\n// Normalized Entry\n// =============================================================================\n\n/**\n * A normalized conversation entry for display\n */\nexport interface NormalizedEntry {\n /** Unique entry ID */\n id: string;\n\n /** ISO timestamp */\n timestamp?: string;\n\n /** Entry type with type-specific data */\n entryType: NormalizedEntryType;\n\n /** Text content for display (plain text or markdown) */\n content: string;\n\n /**\n * Rich content segments (structured approach - preferred over regex transformers).\n * When provided, this takes precedence over `content` for rendering.\n *\n * @example\n * ```ts\n * richContent: [\n * { type: 'text', content: 'Analyzing ' },\n * { type: 'mention', name: 'Scene1', color: '#ff0' },\n * { type: 'text', content: ' for transitions.' },\n * ]\n * ```\n */\n richContent?: RichContent;\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\nexport function isCommandRunAction(action: ActionType): action is CommandRunAction {\n return action.action === 'command_run';\n}\n\nexport function isFileReadAction(action: ActionType): action is FileReadAction {\n return action.action === 'file_read';\n}\n\nexport function isFileEditAction(action: ActionType): action is FileEditAction {\n return action.action === 'file_edit';\n}\n\nexport function isFileWriteAction(action: ActionType): action is FileWriteAction {\n return action.action === 'file_write';\n}\n\nexport function isSearchAction(action: ActionType): action is SearchAction {\n return action.action === 'search';\n}\n\nexport function isGlobAction(action: ActionType): action is GlobAction {\n return action.action === 'glob';\n}\n\nexport function isWebFetchAction(action: ActionType): action is WebFetchAction {\n return action.action === 'web_fetch';\n}\n\nexport function isWebSearchAction(action: ActionType): action is WebSearchAction {\n return action.action === 'web_search';\n}\n\nexport function isMcpToolAction(action: ActionType): action is McpToolAction {\n return action.action === 'mcp_tool';\n}\n\nexport function isGenericToolAction(action: ActionType): action is GenericToolAction {\n return action.action === 'generic_tool';\n}\n\nexport function isTodoWriteAction(action: ActionType): action is TodoWriteAction {\n return action.action === 'todo_write';\n}\n\nexport function isAgentToolAction(action: ActionType): action is AgentToolAction {\n return action.action === 'agent_tool';\n}\n\nexport function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry {\n return entry.type === 'tool_call';\n}\n\nexport function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry {\n return entry.type === 'error';\n}\n\nexport function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry {\n return entry.type === 'widget';\n}\n\n// =============================================================================\n// Widget Rendering\n// =============================================================================\n\n/**\n * Props passed to the widget render function\n */\nexport interface WidgetRenderProps<T = unknown> {\n /** The widget entry being rendered */\n entry: NormalizedEntry;\n /** Widget type identifier */\n widgetType: string;\n /** Widget-specific data */\n widgetData: T;\n /** Callback for widget interactions (e.g., selection, submit) */\n onAction?: (action: WidgetAction) => void;\n}\n\n/**\n * Action dispatched from a widget interaction\n */\nexport interface WidgetAction {\n /** Action type (e.g., 'select', 'submit', 'cancel') */\n type: string;\n /** Widget type that dispatched the action */\n widgetType: string;\n /** Entry ID of the widget */\n entryId: string;\n /** Action-specific payload */\n payload?: unknown;\n}\n\n/**\n * Function type for rendering custom widgets\n *\n * @example\n * ```tsx\n * const renderWidget: WidgetRenderFunction = ({ widgetType, widgetData, onAction }) => {\n * switch (widgetType) {\n * case 'image-grid':\n * return (\n * <ImageGrid\n * images={widgetData.images}\n * onSelect={(id) => onAction?.({ type: 'select', widgetType, entryId, payload: { id } })}\n * />\n * );\n * case 'product-selector':\n * return <ProductSelector data={widgetData} onAction={onAction} />;\n * default:\n * return null;\n * }\n * };\n *\n * <MessageList entries={entries} renderWidget={renderWidget} />\n * ```\n */\nexport type WidgetRenderFunction = (props: WidgetRenderProps) => ReactNode;\n\n// =============================================================================\n// Log Types (for SandboxLogsPanel)\n// =============================================================================\n\nexport type LogLevel = 'info' | 'warn' | 'error' | 'debug';\nexport type LogCategory = 'setup' | 'skills' | 'execution' | 'process' | 'startup';\n\nexport interface LogEntry {\n timestamp: string;\n level: LogLevel;\n category: LogCategory;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// =============================================================================\n// File Attachment\n// =============================================================================\n\nexport interface FileAttachment {\n name: string;\n type: string;\n size: number;\n base64: string;\n}\n\n// =============================================================================\n// Display Mode Configuration\n// =============================================================================\n\n/**\n * Display mode for tool calls in the chat interface\n *\n * - 'inline': Each tool call rendered inline as expandable cards (current behavior)\n * - 'compact': Single animated status line that updates with each tool call,\n * with accordion to expand and see execution details. Text streams unbroken.\n * - 'accordion': Simpler step-based accordion list that accumulates tool calls\n * with icons, labels, and durations (like Vidra's ThinkingIndicator).\n */\nexport type ToolDisplayMode = 'inline' | 'compact' | 'accordion';\n\n/**\n * Configuration for tool display behavior\n */\nexport interface ToolDisplayConfig {\n /**\n * Display mode for tool calls\n * @default 'inline'\n */\n mode: ToolDisplayMode;\n\n /**\n * For 'compact' mode: break into a new group every N tool calls\n * Set to 0 or undefined to never break (all tool calls in single group)\n * @default 0\n */\n breakEveryNToolCalls?: number;\n\n /**\n * Whether tool call groups start expanded\n * @default false\n */\n defaultExpanded?: boolean;\n\n /**\n * Animation duration for status line transitions (ms)\n * @default 300\n */\n animationDuration?: number;\n}\n\n/**\n * Default display configuration\n */\nexport const DEFAULT_DISPLAY_CONFIG: ToolDisplayConfig = {\n mode: 'inline',\n breakEveryNToolCalls: 0,\n defaultExpanded: false,\n animationDuration: 300,\n};\n\n// =============================================================================\n// Rich Content (Structured Approach - Preferred)\n// =============================================================================\n\n/**\n * A text segment within rich content\n */\nexport interface RichTextSegment {\n type: 'text';\n /** Plain text or markdown content */\n content: string;\n}\n\n/**\n * A mention/reference segment within rich content\n */\nexport interface RichMentionSegment {\n type: 'mention';\n /** The mentioned entity name */\n name: string;\n /** Optional identifier for the entity */\n id?: string;\n /** Optional color for styling */\n color?: string;\n /** Optional additional data */\n data?: Record<string, unknown>;\n}\n\n/**\n * A custom component segment within rich content\n */\nexport interface RichComponentSegment {\n type: 'component';\n /** Component type identifier (consumer handles rendering) */\n componentType: string;\n /** Props to pass to the component */\n props: Record<string, unknown>;\n}\n\n/**\n * Union of all rich content segment types\n */\nexport type RichContentSegment =\n | RichTextSegment\n | RichMentionSegment\n | RichComponentSegment;\n\n/**\n * Rich content array - the preferred way to send structured content\n *\n * @example\n * ```ts\n * const content: RichContent = [\n * { type: 'text', content: 'Looking at ' },\n * { type: 'mention', name: 'Scene1', color: '#ff0', id: 'seq-1' },\n * { type: 'text', content: ' timeline for the transition.' },\n * ];\n * ```\n */\nexport type RichContent = RichContentSegment[];\n\n/**\n * Props for rendering a mention segment\n */\nexport interface MentionRenderProps {\n segment: RichMentionSegment;\n}\n\n/**\n * Props for rendering a custom component segment\n */\nexport interface ComponentRenderProps {\n segment: RichComponentSegment;\n}\n\n/**\n * Custom render functions for rich content segments\n */\nexport interface RichContentRenderers {\n /**\n * Render a mention segment. If not provided, renders as styled badge.\n */\n renderMention?: (props: MentionRenderProps) => ReactNode;\n /**\n * Render a custom component segment.\n */\n renderComponent?: (props: ComponentRenderProps) => ReactNode;\n}\n\n// =============================================================================\n// Tool Execution Group (for compact mode)\n// =============================================================================\n\n/**\n * A group of consecutive tool calls that are displayed together\n * in compact mode. Text content before/after flows around the group.\n */\nexport interface ToolExecutionGroup {\n /** Unique ID for the group */\n id: string;\n\n /** Tool calls in this group (in order) */\n toolCalls: NormalizedToolCall[];\n\n /** Index of the currently active/latest tool call for status display */\n activeIndex: number;\n\n /** Whether all tool calls in this group have completed */\n isComplete: boolean;\n\n /** Overall status of the group */\n status: 'pending' | 'success' | 'partial_failure' | 'failed';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ash-cloud/ash-ui",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "React UI components for building agentic interfaces - tool calls, streaming, status displays, and more",
5
5
  "repository": {
6
6
  "type": "git",