@ash-cloud/ash-ui 0.0.4 → 0.0.5

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.cjs CHANGED
@@ -40,6 +40,9 @@ function isToolCallEntry(entry) {
40
40
  function isErrorEntry(entry) {
41
41
  return entry.type === "error";
42
42
  }
43
+ function isWidgetEntry(entry) {
44
+ return entry.type === "widget";
45
+ }
43
46
  var DEFAULT_DISPLAY_CONFIG = {
44
47
  mode: "inline",
45
48
  breakEveryNToolCalls: 0,
@@ -61,5 +64,6 @@ exports.isTodoWriteAction = isTodoWriteAction;
61
64
  exports.isToolCallEntry = isToolCallEntry;
62
65
  exports.isWebFetchAction = isWebFetchAction;
63
66
  exports.isWebSearchAction = isWebSearchAction;
67
+ exports.isWidgetEntry = isWidgetEntry;
64
68
  //# sourceMappingURL=types.cjs.map
65
69
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;AA+SO,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,gBAAgB,KAAA,EAAoD;AAClF,EAAA,OAAO,MAAM,IAAA,KAAS,WAAA;AACxB;AAEO,SAAS,aAAa,KAAA,EAAiD;AAC5E,EAAA,OAAO,MAAM,IAAA,KAAS,OAAA;AACxB;AA4EO,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.cjs","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\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}\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}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\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// 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\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 /** 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\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 * Discriminated union of all entry types\n */\nexport type NormalizedEntryType =\n | UserMessageEntry\n | AssistantMessageEntry\n | ThinkingEntry\n | ToolCallEntry\n | ErrorEntry;\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 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\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":";;;AAiVO,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,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.cjs","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}\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}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\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// 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\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 /** 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\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 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"]}
package/dist/types.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+
1
3
  /**
2
4
  * @ash-cloud/ash-ui - Types
3
5
  *
@@ -5,6 +7,7 @@
5
7
  * These types provide a unified representation for displaying tool calls
6
8
  * with their arguments and results together.
7
9
  */
10
+
8
11
  /**
9
12
  * Status of a tool call execution
10
13
  */
@@ -200,10 +203,40 @@ interface ErrorEntry {
200
203
  message: string;
201
204
  code?: string;
202
205
  }
206
+ /**
207
+ * Custom widget entry - rendered via consumer-provided render function
208
+ *
209
+ * Use this for interactive UI components like:
210
+ * - Image grid selectors
211
+ * - Product carousels
212
+ * - Form inputs
213
+ * - Data visualizations
214
+ * - Any custom interactive widget
215
+ *
216
+ * @example
217
+ * ```tsx
218
+ * const entry: NormalizedEntry = {
219
+ * id: 'widget-1',
220
+ * entryType: {
221
+ * type: 'widget',
222
+ * widgetType: 'image-grid',
223
+ * widgetData: { images: [...], selected: null },
224
+ * },
225
+ * content: 'Select an image',
226
+ * };
227
+ * ```
228
+ */
229
+ interface WidgetEntry {
230
+ type: 'widget';
231
+ /** Widget type identifier (e.g., 'image-grid', 'product-selector') */
232
+ widgetType: string;
233
+ /** Widget-specific data passed to the render function */
234
+ widgetData: unknown;
235
+ }
203
236
  /**
204
237
  * Discriminated union of all entry types
205
238
  */
206
- type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry;
239
+ type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
207
240
  /**
208
241
  * A normalized conversation entry for display
209
242
  */
@@ -230,6 +263,58 @@ declare function isGenericToolAction(action: ActionType): action is GenericToolA
230
263
  declare function isTodoWriteAction(action: ActionType): action is TodoWriteAction;
231
264
  declare function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry;
232
265
  declare function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry;
266
+ declare function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry;
267
+ /**
268
+ * Props passed to the widget render function
269
+ */
270
+ interface WidgetRenderProps<T = unknown> {
271
+ /** The widget entry being rendered */
272
+ entry: NormalizedEntry;
273
+ /** Widget type identifier */
274
+ widgetType: string;
275
+ /** Widget-specific data */
276
+ widgetData: T;
277
+ /** Callback for widget interactions (e.g., selection, submit) */
278
+ onAction?: (action: WidgetAction) => void;
279
+ }
280
+ /**
281
+ * Action dispatched from a widget interaction
282
+ */
283
+ interface WidgetAction {
284
+ /** Action type (e.g., 'select', 'submit', 'cancel') */
285
+ type: string;
286
+ /** Widget type that dispatched the action */
287
+ widgetType: string;
288
+ /** Entry ID of the widget */
289
+ entryId: string;
290
+ /** Action-specific payload */
291
+ payload?: unknown;
292
+ }
293
+ /**
294
+ * Function type for rendering custom widgets
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * const renderWidget: WidgetRenderFunction = ({ widgetType, widgetData, onAction }) => {
299
+ * switch (widgetType) {
300
+ * case 'image-grid':
301
+ * return (
302
+ * <ImageGrid
303
+ * images={widgetData.images}
304
+ * onSelect={(id) => onAction?.({ type: 'select', widgetType, entryId, payload: { id } })}
305
+ * />
306
+ * );
307
+ * case 'product-selector':
308
+ * return <ProductSelector data={widgetData} onAction={onAction} />;
309
+ * default:
310
+ * return null;
311
+ * }
312
+ * };
313
+ *
314
+ * <MessageList entries={entries} renderWidget={renderWidget} />
315
+ * ```
316
+ */
317
+ type WidgetRenderFunction = (props: WidgetRenderProps) => ReactNode;
233
318
  type LogLevel = 'info' | 'warn' | 'error' | 'debug';
234
319
  type LogCategory = 'setup' | 'skills' | 'execution' | 'process' | 'startup';
235
320
  interface LogEntry {
@@ -302,4 +387,4 @@ interface ToolExecutionGroup {
302
387
  status: 'pending' | 'success' | 'partial_failure' | 'failed';
303
388
  }
304
389
 
305
- export { type ActionType, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_DISPLAY_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type McpToolAction, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDisplayConfig, type ToolDisplayMode, type ToolExecutionGroup, type ToolResult, type ToolStatus, type UserMessageEntry, type WebFetchAction, type WebSearchAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction };
390
+ export { type ActionType, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_DISPLAY_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type McpToolAction, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDisplayConfig, type ToolDisplayMode, type ToolExecutionGroup, type ToolResult, type ToolStatus, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+
1
3
  /**
2
4
  * @ash-cloud/ash-ui - Types
3
5
  *
@@ -5,6 +7,7 @@
5
7
  * These types provide a unified representation for displaying tool calls
6
8
  * with their arguments and results together.
7
9
  */
10
+
8
11
  /**
9
12
  * Status of a tool call execution
10
13
  */
@@ -200,10 +203,40 @@ interface ErrorEntry {
200
203
  message: string;
201
204
  code?: string;
202
205
  }
206
+ /**
207
+ * Custom widget entry - rendered via consumer-provided render function
208
+ *
209
+ * Use this for interactive UI components like:
210
+ * - Image grid selectors
211
+ * - Product carousels
212
+ * - Form inputs
213
+ * - Data visualizations
214
+ * - Any custom interactive widget
215
+ *
216
+ * @example
217
+ * ```tsx
218
+ * const entry: NormalizedEntry = {
219
+ * id: 'widget-1',
220
+ * entryType: {
221
+ * type: 'widget',
222
+ * widgetType: 'image-grid',
223
+ * widgetData: { images: [...], selected: null },
224
+ * },
225
+ * content: 'Select an image',
226
+ * };
227
+ * ```
228
+ */
229
+ interface WidgetEntry {
230
+ type: 'widget';
231
+ /** Widget type identifier (e.g., 'image-grid', 'product-selector') */
232
+ widgetType: string;
233
+ /** Widget-specific data passed to the render function */
234
+ widgetData: unknown;
235
+ }
203
236
  /**
204
237
  * Discriminated union of all entry types
205
238
  */
206
- type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry;
239
+ type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
207
240
  /**
208
241
  * A normalized conversation entry for display
209
242
  */
@@ -230,6 +263,58 @@ declare function isGenericToolAction(action: ActionType): action is GenericToolA
230
263
  declare function isTodoWriteAction(action: ActionType): action is TodoWriteAction;
231
264
  declare function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry;
232
265
  declare function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry;
266
+ declare function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry;
267
+ /**
268
+ * Props passed to the widget render function
269
+ */
270
+ interface WidgetRenderProps<T = unknown> {
271
+ /** The widget entry being rendered */
272
+ entry: NormalizedEntry;
273
+ /** Widget type identifier */
274
+ widgetType: string;
275
+ /** Widget-specific data */
276
+ widgetData: T;
277
+ /** Callback for widget interactions (e.g., selection, submit) */
278
+ onAction?: (action: WidgetAction) => void;
279
+ }
280
+ /**
281
+ * Action dispatched from a widget interaction
282
+ */
283
+ interface WidgetAction {
284
+ /** Action type (e.g., 'select', 'submit', 'cancel') */
285
+ type: string;
286
+ /** Widget type that dispatched the action */
287
+ widgetType: string;
288
+ /** Entry ID of the widget */
289
+ entryId: string;
290
+ /** Action-specific payload */
291
+ payload?: unknown;
292
+ }
293
+ /**
294
+ * Function type for rendering custom widgets
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * const renderWidget: WidgetRenderFunction = ({ widgetType, widgetData, onAction }) => {
299
+ * switch (widgetType) {
300
+ * case 'image-grid':
301
+ * return (
302
+ * <ImageGrid
303
+ * images={widgetData.images}
304
+ * onSelect={(id) => onAction?.({ type: 'select', widgetType, entryId, payload: { id } })}
305
+ * />
306
+ * );
307
+ * case 'product-selector':
308
+ * return <ProductSelector data={widgetData} onAction={onAction} />;
309
+ * default:
310
+ * return null;
311
+ * }
312
+ * };
313
+ *
314
+ * <MessageList entries={entries} renderWidget={renderWidget} />
315
+ * ```
316
+ */
317
+ type WidgetRenderFunction = (props: WidgetRenderProps) => ReactNode;
233
318
  type LogLevel = 'info' | 'warn' | 'error' | 'debug';
234
319
  type LogCategory = 'setup' | 'skills' | 'execution' | 'process' | 'startup';
235
320
  interface LogEntry {
@@ -302,4 +387,4 @@ interface ToolExecutionGroup {
302
387
  status: 'pending' | 'success' | 'partial_failure' | 'failed';
303
388
  }
304
389
 
305
- export { type ActionType, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_DISPLAY_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type McpToolAction, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDisplayConfig, type ToolDisplayMode, type ToolExecutionGroup, type ToolResult, type ToolStatus, type UserMessageEntry, type WebFetchAction, type WebSearchAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction };
390
+ export { type ActionType, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_DISPLAY_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type McpToolAction, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDisplayConfig, type ToolDisplayMode, type ToolExecutionGroup, type ToolResult, type ToolStatus, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry };
package/dist/types.js CHANGED
@@ -38,6 +38,9 @@ function isToolCallEntry(entry) {
38
38
  function isErrorEntry(entry) {
39
39
  return entry.type === "error";
40
40
  }
41
+ function isWidgetEntry(entry) {
42
+ return entry.type === "widget";
43
+ }
41
44
  var DEFAULT_DISPLAY_CONFIG = {
42
45
  mode: "inline",
43
46
  breakEveryNToolCalls: 0,
@@ -45,6 +48,6 @@ var DEFAULT_DISPLAY_CONFIG = {
45
48
  animationDuration: 300
46
49
  };
47
50
 
48
- export { DEFAULT_DISPLAY_CONFIG, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction };
51
+ export { DEFAULT_DISPLAY_CONFIG, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry };
49
52
  //# sourceMappingURL=types.js.map
50
53
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AA+SO,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,gBAAgB,KAAA,EAAoD;AAClF,EAAA,OAAO,MAAM,IAAA,KAAS,WAAA;AACxB;AAEO,SAAS,aAAa,KAAA,EAAiD;AAC5E,EAAA,OAAO,MAAM,IAAA,KAAS,OAAA;AACxB;AA4EO,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\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}\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}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\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// 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\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 /** 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\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 * Discriminated union of all entry types\n */\nexport type NormalizedEntryType =\n | UserMessageEntry\n | AssistantMessageEntry\n | ThinkingEntry\n | ToolCallEntry\n | ErrorEntry;\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 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\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":";AAiVO,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,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}\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}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\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// 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\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 /** 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\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 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"]}
package/dist/utils.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ActionType, ToolResult, CommandRunResult, NormalizedToolCall, NormalizedEntry, ToolDisplayConfig } from './types.cjs';
2
+ import 'react';
2
3
 
3
4
  /**
4
5
  * @ash-cloud/ash-ui - Utilities
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ActionType, ToolResult, CommandRunResult, NormalizedToolCall, NormalizedEntry, ToolDisplayConfig } from './types.js';
2
+ import 'react';
2
3
 
3
4
  /**
4
5
  * @ash-cloud/ash-ui - Utilities
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ash-cloud/ash-ui",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "React UI components for building agentic interfaces - tool calls, streaming, status displays, and more",
5
5
  "repository": {
6
6
  "type": "git",