@ash-cloud/ash-ui 0.2.5 → 0.2.6

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.d.cts CHANGED
@@ -220,6 +220,13 @@ interface UserMessageEntry {
220
220
  interface AssistantMessageEntry {
221
221
  type: 'assistant_message';
222
222
  }
223
+ /**
224
+ * System message entry (context injections, automated notifications)
225
+ * These are typically hidden in compact mode and shown in debug mode.
226
+ */
227
+ interface SystemMessageEntry {
228
+ type: 'system_message';
229
+ }
223
230
  /**
224
231
  * Thinking/reasoning entry (extended thinking)
225
232
  */
@@ -274,7 +281,7 @@ interface WidgetEntry {
274
281
  /**
275
282
  * Discriminated union of all entry types
276
283
  */
277
- type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
284
+ type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | SystemMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
278
285
  /**
279
286
  * A normalized conversation entry for display
280
287
  */
@@ -303,6 +310,7 @@ declare function isAgentToolAction(action: ActionType): action is AgentToolActio
303
310
  declare function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry;
304
311
  declare function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry;
305
312
  declare function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry;
313
+ declare function isSystemMessage(entry: NormalizedEntryType): entry is SystemMessageEntry;
306
314
  /**
307
315
  * Props passed to the widget render function
308
316
  */
@@ -420,6 +428,22 @@ interface MentionProps {
420
428
  /** Optional custom data (e.g., entity ID for click handling) */
421
429
  data?: Record<string, unknown>;
422
430
  }
431
+ /**
432
+ * Chat display mode
433
+ * - 'user': Concise, friendly view — hides thinking, system messages,
434
+ * shows tool calls as one-liner summaries
435
+ * - 'debug': Full verbose view — everything visible, tool args/output expanded
436
+ */
437
+ type ChatDisplayMode = 'user' | 'debug';
438
+ /**
439
+ * User-friendly tool description config provided by consumers.
440
+ * Maps tool name patterns to human-readable descriptions.
441
+ *
442
+ * The key can be an exact tool name or a substring pattern (matched via includes).
443
+ * The value can be a static string or a function that receives the tool's
444
+ * input and returns a dynamic description.
445
+ */
446
+ type ToolDescriptionMap = Record<string, string | ((input: unknown) => string)>;
423
447
  /**
424
448
  * Message visual style variant
425
449
  *
@@ -641,4 +665,4 @@ declare function normalizedEntriesToMessages(entries: NormalizedEntry[]): Messag
641
665
  */
642
666
  declare function messagesToNormalizedEntries(messages: Message[]): NormalizedEntry[];
643
667
 
644
- export { type AIMessageRole, type ActionType, type AgentToolAction, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_STYLE_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type MarkdownComponents, type McpToolAction, type MentionProps, type Message, type MessageAttachment, type MessageMetadata, type MessageRole, type MessageStyleConfig, type MessageVariant, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type RenderMetadataFunction, type RichContent, type RichContentSegment, type RichMentionSegment, type RichTextSegment, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolInvocation, type ToolInvocationState, type ToolResult, type ToolStatus, type TypographyScale, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
668
+ export { type AIMessageRole, type ActionType, type AgentToolAction, type AssistantMessageEntry, type ChatDisplayMode, type CommandRunAction, type CommandRunResult, DEFAULT_STYLE_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type MarkdownComponents, type McpToolAction, type MentionProps, type Message, type MessageAttachment, type MessageMetadata, type MessageRole, type MessageStyleConfig, type MessageVariant, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type RenderMetadataFunction, type RichContent, type RichContentSegment, type RichMentionSegment, type RichTextSegment, type SearchAction, type SystemMessageEntry, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDescriptionMap, type ToolInvocation, type ToolInvocationState, type ToolResult, type ToolStatus, type TypographyScale, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isSystemMessage, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
package/dist/types.d.ts CHANGED
@@ -220,6 +220,13 @@ interface UserMessageEntry {
220
220
  interface AssistantMessageEntry {
221
221
  type: 'assistant_message';
222
222
  }
223
+ /**
224
+ * System message entry (context injections, automated notifications)
225
+ * These are typically hidden in compact mode and shown in debug mode.
226
+ */
227
+ interface SystemMessageEntry {
228
+ type: 'system_message';
229
+ }
223
230
  /**
224
231
  * Thinking/reasoning entry (extended thinking)
225
232
  */
@@ -274,7 +281,7 @@ interface WidgetEntry {
274
281
  /**
275
282
  * Discriminated union of all entry types
276
283
  */
277
- type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
284
+ type NormalizedEntryType = UserMessageEntry | AssistantMessageEntry | SystemMessageEntry | ThinkingEntry | ToolCallEntry | ErrorEntry | WidgetEntry;
278
285
  /**
279
286
  * A normalized conversation entry for display
280
287
  */
@@ -303,6 +310,7 @@ declare function isAgentToolAction(action: ActionType): action is AgentToolActio
303
310
  declare function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry;
304
311
  declare function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry;
305
312
  declare function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry;
313
+ declare function isSystemMessage(entry: NormalizedEntryType): entry is SystemMessageEntry;
306
314
  /**
307
315
  * Props passed to the widget render function
308
316
  */
@@ -420,6 +428,22 @@ interface MentionProps {
420
428
  /** Optional custom data (e.g., entity ID for click handling) */
421
429
  data?: Record<string, unknown>;
422
430
  }
431
+ /**
432
+ * Chat display mode
433
+ * - 'user': Concise, friendly view — hides thinking, system messages,
434
+ * shows tool calls as one-liner summaries
435
+ * - 'debug': Full verbose view — everything visible, tool args/output expanded
436
+ */
437
+ type ChatDisplayMode = 'user' | 'debug';
438
+ /**
439
+ * User-friendly tool description config provided by consumers.
440
+ * Maps tool name patterns to human-readable descriptions.
441
+ *
442
+ * The key can be an exact tool name or a substring pattern (matched via includes).
443
+ * The value can be a static string or a function that receives the tool's
444
+ * input and returns a dynamic description.
445
+ */
446
+ type ToolDescriptionMap = Record<string, string | ((input: unknown) => string)>;
423
447
  /**
424
448
  * Message visual style variant
425
449
  *
@@ -641,4 +665,4 @@ declare function normalizedEntriesToMessages(entries: NormalizedEntry[]): Messag
641
665
  */
642
666
  declare function messagesToNormalizedEntries(messages: Message[]): NormalizedEntry[];
643
667
 
644
- export { type AIMessageRole, type ActionType, type AgentToolAction, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult, DEFAULT_STYLE_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type MarkdownComponents, type McpToolAction, type MentionProps, type Message, type MessageAttachment, type MessageMetadata, type MessageRole, type MessageStyleConfig, type MessageVariant, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type RenderMetadataFunction, type RichContent, type RichContentSegment, type RichMentionSegment, type RichTextSegment, type SearchAction, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolInvocation, type ToolInvocationState, type ToolResult, type ToolStatus, type TypographyScale, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
668
+ export { type AIMessageRole, type ActionType, type AgentToolAction, type AssistantMessageEntry, type ChatDisplayMode, type CommandRunAction, type CommandRunResult, DEFAULT_STYLE_CONFIG, type ErrorEntry, type FileAttachment, type FileEditAction, type FileReadAction, type FileWriteAction, type GenericToolAction, type GlobAction, type LogCategory, type LogEntry, type LogLevel, type MarkdownComponents, type McpToolAction, type MentionProps, type Message, type MessageAttachment, type MessageMetadata, type MessageRole, type MessageStyleConfig, type MessageVariant, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type RenderMetadataFunction, type RichContent, type RichContentSegment, type RichMentionSegment, type RichTextSegment, type SearchAction, type SystemMessageEntry, type ThinkingEntry, type TodoItem, type TodoStatus, type TodoWriteAction, type ToolCallEntry, type ToolDescriptionMap, type ToolInvocation, type ToolInvocationState, type ToolResult, type ToolStatus, type TypographyScale, type UserMessageEntry, type WebFetchAction, type WebSearchAction, type WidgetAction, type WidgetEntry, type WidgetRenderFunction, type WidgetRenderProps, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isSystemMessage, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
package/dist/types.js CHANGED
@@ -44,6 +44,9 @@ function isErrorEntry(entry) {
44
44
  function isWidgetEntry(entry) {
45
45
  return entry.type === "widget";
46
46
  }
47
+ function isSystemMessage(entry) {
48
+ return entry.type === "system_message";
49
+ }
47
50
  var DEFAULT_STYLE_CONFIG = {
48
51
  userVariant: "bubble",
49
52
  assistantVariant: "bubble",
@@ -177,7 +180,7 @@ function messageToNormalizedEntry(message) {
177
180
  return {
178
181
  id,
179
182
  timestamp,
180
- entryType: { type: "assistant_message" },
183
+ entryType: { type: "system_message" },
181
184
  content
182
185
  };
183
186
  }
@@ -284,6 +287,6 @@ function messagesToNormalizedEntries(messages) {
284
287
  return entries;
285
288
  }
286
289
 
287
- export { DEFAULT_STYLE_CONFIG, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
290
+ export { DEFAULT_STYLE_CONFIG, isAgentToolAction, isCommandRunAction, isErrorEntry, isFileEditAction, isFileReadAction, isFileWriteAction, isGenericToolAction, isGlobAction, isMcpToolAction, isSearchAction, isSystemMessage, isTodoWriteAction, isToolCallEntry, isWebFetchAction, isWebSearchAction, isWidgetEntry, messageToNormalizedEntry, messagesToNormalizedEntries, normalizedEntriesToMessages, normalizedEntryToMessage };
288
291
  //# sourceMappingURL=types.js.map
289
292
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AA6XO,SAAS,mBAAmB,MAAA,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AAU;AAE9B,IAAA,IAAI,QAAQ,SAAA,EAAW;AACrB,MAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,QACX,EAAA,EAAI,CAAA,EAAG,OAAA,CAAQ,EAAE,CAAA,SAAA,CAAA;AAAA,QACjB,SAAA,EAAW,OAAA,CAAQ,SAAA,EAAW,WAAA,EAAY;AAAA,QAC1C,SAAA,EAAW,EAAE,IAAA,EAAM,UAAA,EAAW;AAAA,QAC9B,SAAS,OAAA,CAAQ;AAAA,OAClB,CAAA;AAAA,IACH;AAGA,IAAA,IAAI,OAAA,CAAQ,OAAA,IAAW,CAAC,OAAA,CAAQ,iBAAiB,MAAA,EAAQ;AACvD,MAAA,OAAA,CAAQ,KAAK,wBAAA,CAAyB;AAAA,QACpC,GAAG,OAAA;AAAA,QACH,eAAA,EAAiB,MAAA;AAAA,QACjB,SAAA,EAAW;AAAA,OACZ,CAAC,CAAA;AAAA,IACJ;AAGA,IAAA,IAAI,QAAQ,eAAA,EAAiB;AAC3B,MAAA,KAAA,MAAW,GAAA,IAAO,QAAQ,eAAA,EAAiB;AACzC,QAAA,MAAM,WAAA,GAAuB;AAAA,UAC3B,IAAI,GAAA,CAAI,UAAA;AAAA,UACR,IAAA,EAAM,WAAA;AAAA,UACN,OAAA,EAAS,EAAA;AAAA,UACT,eAAA,EAAiB,CAAC,GAAG,CAAA;AAAA,UACrB,WAAW,OAAA,CAAQ;AAAA,SACrB;AACA,QAAA,OAAA,CAAQ,IAAA,CAAK,wBAAA,CAAyB,WAAW,CAAC,CAAA;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,OAAA;AACT","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// =============================================================================\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// Rich Content (Mention Rendering)\n// =============================================================================\n\n/**\n * A plain text segment in rich content\n */\nexport interface RichTextSegment {\n type: 'text';\n content: string;\n}\n\n/**\n * A mention segment in rich content (e.g., @ProductX, @JohnDoe)\n */\nexport interface RichMentionSegment {\n type: 'mention';\n /** Display name for the mention */\n name: string;\n /** Optional color for the mention badge */\n color?: string;\n /** Optional avatar/icon URL */\n url?: string;\n /** Optional custom data (e.g., entity ID for click handling) */\n data?: Record<string, unknown>;\n}\n\n/**\n * A single segment of rich content\n */\nexport type RichContentSegment = RichTextSegment | RichMentionSegment;\n\n/**\n * Pre-parsed rich content array for custom rendering\n *\n * @example\n * ```tsx\n * const richContent: RichContent = [\n * { type: 'text', content: 'Check out ' },\n * { type: 'mention', name: 'ProductX', color: '#f59e0b', data: { id: 123 } },\n * { type: 'text', content: ' for details' },\n * ];\n * ```\n */\nexport type RichContent = RichContentSegment[];\n\n/**\n * Props for rendering a mention component\n */\nexport interface MentionProps {\n /** Display name for the mention */\n name: string;\n /** Optional color for the mention badge */\n color?: string;\n /** Optional avatar/icon URL */\n url?: string;\n /** Optional custom data (e.g., entity ID for click handling) */\n data?: Record<string, unknown>;\n}\n\n// =============================================================================\n// Display Mode Configuration\n// =============================================================================\n\n// =============================================================================\n// Theming & Customization\n// =============================================================================\n\n/**\n * Message visual style variant\n *\n * - 'bubble': Rounded card with padding and background (default for user messages)\n * - 'plain': No background, just text with subtle styling\n * - 'minimal': Bare text, no decoration\n */\nexport type MessageVariant = 'bubble' | 'plain' | 'minimal';\n\n/**\n * Typography scale/density preset\n *\n * - 'dense': Minimal spacing, smallest fonts (12px base) - for maximum information density\n * - 'compact': Tighter spacing, smaller fonts (13px base)\n * - 'default': Standard sizing (14px base)\n * - 'comfortable': More generous spacing (15px base)\n */\nexport type TypographyScale = 'dense' | 'compact' | 'default' | 'comfortable';\n\n/**\n * Message role for data attribute targeting\n */\nexport type MessageRole = 'user' | 'assistant' | 'thinking' | 'tool' | 'error' | 'widget';\n\n/**\n * Metadata to display with a message\n */\nexport interface MessageMetadata {\n /** Timestamp to display */\n timestamp?: string;\n /** Model name/info to display */\n model?: string;\n /** Custom label */\n label?: string;\n /** Any additional metadata */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Function to render custom message metadata\n */\nexport type RenderMetadataFunction = (props: {\n entry: NormalizedEntry;\n metadata?: MessageMetadata;\n}) => ReactNode;\n\n/**\n * Custom markdown component overrides\n *\n * @example\n * ```tsx\n * const components: MarkdownComponents = {\n * h2: ({ children }) => <h2 className=\"custom-h2\">{children}</h2>,\n * code: ({ children, className }) => <CustomCode className={className}>{children}</CustomCode>,\n * };\n * ```\n */\nexport interface MarkdownComponents {\n h1?: React.ComponentType<{ children?: ReactNode }>;\n h2?: React.ComponentType<{ children?: ReactNode }>;\n h3?: React.ComponentType<{ children?: ReactNode }>;\n h4?: React.ComponentType<{ children?: ReactNode }>;\n h5?: React.ComponentType<{ children?: ReactNode }>;\n h6?: React.ComponentType<{ children?: ReactNode }>;\n p?: React.ComponentType<{ children?: ReactNode }>;\n a?: React.ComponentType<{ children?: ReactNode; href?: string }>;\n ul?: React.ComponentType<{ children?: ReactNode }>;\n ol?: React.ComponentType<{ children?: ReactNode }>;\n li?: React.ComponentType<{ children?: ReactNode }>;\n code?: React.ComponentType<{ children?: ReactNode; className?: string }>;\n pre?: React.ComponentType<{ children?: ReactNode }>;\n blockquote?: React.ComponentType<{ children?: ReactNode }>;\n strong?: React.ComponentType<{ children?: ReactNode }>;\n em?: React.ComponentType<{ children?: ReactNode }>;\n hr?: React.ComponentType<Record<string, never>>;\n img?: React.ComponentType<{ src?: string; alt?: string }>;\n table?: React.ComponentType<{ children?: ReactNode }>;\n thead?: React.ComponentType<{ children?: ReactNode }>;\n tbody?: React.ComponentType<{ children?: ReactNode }>;\n tr?: React.ComponentType<{ children?: ReactNode }>;\n th?: React.ComponentType<{ children?: ReactNode }>;\n td?: React.ComponentType<{ children?: ReactNode }>;\n}\n\n/**\n * Style configuration for message display\n */\nexport interface MessageStyleConfig {\n /** Variant for user messages */\n userVariant?: MessageVariant;\n /** Variant for assistant messages */\n assistantVariant?: MessageVariant;\n /** Typography/density scale */\n scale?: TypographyScale;\n /** Show timestamps with messages */\n showTimestamp?: boolean;\n /** Show avatars */\n showAvatars?: boolean;\n /** Custom class name for messages */\n messageClassName?: string;\n}\n\n/**\n * Default style configuration\n */\nexport const DEFAULT_STYLE_CONFIG: MessageStyleConfig = {\n userVariant: 'bubble',\n assistantVariant: 'bubble',\n scale: 'compact',\n showTimestamp: true,\n showAvatars: true,\n}\n\n// =============================================================================\n// AI SDK Compatible Types\n// =============================================================================\n\n/**\n * Tool invocation status - matches AI SDK ToolInvocation\n */\nexport type ToolInvocationState = 'partial-call' | 'call' | 'result';\n\n/**\n * Tool invocation - matches AI SDK ToolInvocation type\n */\nexport interface ToolInvocation {\n /** Tool invocation state */\n state: ToolInvocationState;\n /** Unique tool call ID */\n toolCallId: string;\n /** Tool name */\n toolName: string;\n /** Arguments passed to the tool (parsed JSON) */\n args: Record<string, unknown>;\n /** Result from tool execution (only present when state is 'result') */\n result?: unknown;\n}\n\n/**\n * AI SDK message role - matches AI SDK Message role\n */\nexport type AIMessageRole = 'user' | 'assistant' | 'system' | 'data';\n\n/**\n * AI SDK compatible message type\n * This is the primary type used by the new useChat hook\n */\nexport interface Message {\n /** Unique message ID */\n id: string;\n /** Message role */\n role: AIMessageRole;\n /** Message content (text) */\n content: string;\n /** Tool invocations for this message */\n toolInvocations?: ToolInvocation[];\n /** When the message was created */\n createdAt?: Date;\n /** Optional reasoning/thinking content */\n reasoning?: string;\n /** Experimental attachments (for file uploads) */\n experimental_attachments?: MessageAttachment[];\n}\n\n/**\n * Message attachment for file uploads\n */\nexport interface MessageAttachment {\n /** Attachment name */\n name: string;\n /** MIME type */\n contentType: string;\n /** URL to the attachment */\n url: string;\n}\n\n// =============================================================================\n// Type Conversion Functions\n// =============================================================================\n\n/**\n * Convert a NormalizedEntry to an AI SDK Message\n */\nexport function normalizedEntryToMessage(entry: NormalizedEntry): Message | null {\n const { id, entryType, content, timestamp } = entry;\n const createdAt = timestamp ? new Date(timestamp) : undefined;\n\n switch (entryType.type) {\n case 'user_message':\n return {\n id,\n role: 'user',\n content,\n createdAt,\n };\n\n case 'assistant_message':\n return {\n id,\n role: 'assistant',\n content,\n createdAt,\n };\n\n case 'thinking':\n // Thinking is represented as reasoning on the previous assistant message\n // Return as assistant message with reasoning\n return {\n id,\n role: 'assistant',\n content: '',\n reasoning: content,\n createdAt,\n };\n\n case 'tool_call': {\n const { toolCall } = entryType;\n const toolInvocation: ToolInvocation = {\n state: toolCall.status === 'pending' ? 'call' : 'result',\n toolCallId: toolCall.id,\n toolName: toolCall.toolName,\n args: (toolCall.input as Record<string, unknown>) || {},\n result: toolCall.output,\n };\n // Tool calls are attached to assistant messages\n return {\n id,\n role: 'assistant',\n content: '',\n toolInvocations: [toolInvocation],\n createdAt,\n };\n }\n\n case 'error':\n // Errors can be represented as system messages\n return {\n id,\n role: 'system',\n content: `Error: ${entryType.message}${entryType.code ? ` (${entryType.code})` : ''}`,\n createdAt,\n };\n\n case 'widget':\n // Widgets are data messages\n return {\n id,\n role: 'data',\n content: JSON.stringify({\n widgetType: entryType.widgetType,\n widgetData: entryType.widgetData,\n }),\n createdAt,\n };\n\n default:\n return null;\n }\n}\n\n/**\n * Convert an AI SDK Message to a NormalizedEntry\n */\nexport function messageToNormalizedEntry(message: Message): NormalizedEntry {\n const { id, role, content, createdAt, toolInvocations, reasoning } = message;\n const timestamp = createdAt?.toISOString();\n\n // If there are tool invocations, create tool call entries\n if (toolInvocations && toolInvocations.length > 0) {\n // For simplicity, take the first tool invocation\n // In practice, multiple tool invocations would need multiple entries\n const inv = toolInvocations[0]!;\n const toolCall: NormalizedToolCall = {\n id: inv.toolCallId,\n toolName: inv.toolName,\n actionType: {\n action: 'generic_tool',\n toolName: inv.toolName,\n arguments: inv.args,\n result: inv.result ? { type: 'json', value: inv.result } : undefined,\n },\n status: inv.state === 'result' ? 'success' : 'pending',\n summary: `${inv.toolName}(${Object.keys(inv.args).join(', ')})`,\n input: inv.args,\n output: inv.result,\n };\n\n return {\n id,\n timestamp,\n entryType: { type: 'tool_call', toolCall },\n content: toolCall.summary,\n };\n }\n\n // If there's reasoning, create a thinking entry\n if (reasoning) {\n return {\n id,\n timestamp,\n entryType: { type: 'thinking' },\n content: reasoning,\n };\n }\n\n // Standard message types based on role\n if (role === 'user') {\n return {\n id,\n timestamp,\n entryType: { type: 'user_message' },\n content,\n };\n }\n\n if (role === 'assistant') {\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n }\n\n if (role === 'system') {\n // System messages that look like errors\n if (content.startsWith('Error:')) {\n return {\n id,\n timestamp,\n entryType: { type: 'error', message: content.replace('Error: ', '') },\n content,\n };\n }\n // Otherwise treat as assistant message\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n }\n\n if (role === 'data') {\n // Try to parse as widget\n try {\n const data = JSON.parse(content);\n if (data.widgetType) {\n return {\n id,\n timestamp,\n entryType: {\n type: 'widget',\n widgetType: data.widgetType,\n widgetData: data.widgetData,\n },\n content: '',\n };\n }\n } catch {\n // Not valid JSON, treat as assistant message\n }\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n }\n\n // Default fallback\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n}\n\n/**\n * Convert an array of NormalizedEntry to AI SDK Messages\n * Merges consecutive assistant entries (text + tool calls) into single messages\n */\nexport function normalizedEntriesToMessages(entries: NormalizedEntry[]): Message[] {\n const messages: Message[] = [];\n let currentAssistantMessage: Message | null = null;\n\n for (const entry of entries) {\n const message = normalizedEntryToMessage(entry);\n if (!message) continue;\n\n if (message.role === 'assistant') {\n // Check if we should merge with current assistant message\n if (currentAssistantMessage) {\n // Merge tool invocations\n if (message.toolInvocations) {\n currentAssistantMessage.toolInvocations = [\n ...(currentAssistantMessage.toolInvocations || []),\n ...message.toolInvocations,\n ];\n }\n // Merge content\n if (message.content) {\n currentAssistantMessage.content = currentAssistantMessage.content\n ? `${currentAssistantMessage.content}\\n${message.content}`\n : message.content;\n }\n // Merge reasoning\n if (message.reasoning) {\n currentAssistantMessage.reasoning = currentAssistantMessage.reasoning\n ? `${currentAssistantMessage.reasoning}\\n${message.reasoning}`\n : message.reasoning;\n }\n } else {\n currentAssistantMessage = { ...message };\n }\n } else {\n // Flush current assistant message\n if (currentAssistantMessage) {\n messages.push(currentAssistantMessage);\n currentAssistantMessage = null;\n }\n messages.push(message);\n }\n }\n\n // Flush any remaining assistant message\n if (currentAssistantMessage) {\n messages.push(currentAssistantMessage);\n }\n\n return messages;\n}\n\n/**\n * Convert AI SDK Messages back to NormalizedEntry array\n * Expands tool invocations into separate entries\n */\nexport function messagesToNormalizedEntries(messages: Message[]): NormalizedEntry[] {\n const entries: NormalizedEntry[] = [];\n\n for (const message of messages) {\n // If message has reasoning, add thinking entry first\n if (message.reasoning) {\n entries.push({\n id: `${message.id}-thinking`,\n timestamp: message.createdAt?.toISOString(),\n entryType: { type: 'thinking' },\n content: message.reasoning,\n });\n }\n\n // If message has content, add the content entry\n if (message.content || !message.toolInvocations?.length) {\n entries.push(messageToNormalizedEntry({\n ...message,\n toolInvocations: undefined,\n reasoning: undefined,\n }));\n }\n\n // Add separate entries for each tool invocation\n if (message.toolInvocations) {\n for (const inv of message.toolInvocations) {\n const toolMessage: Message = {\n id: inv.toolCallId,\n role: 'assistant',\n content: '',\n toolInvocations: [inv],\n createdAt: message.createdAt,\n };\n entries.push(messageToNormalizedEntry(toolMessage));\n }\n }\n }\n\n return entries;\n}\n"]}
1
+ {"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AAsYO,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,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AAC,OAAA,CAAQ,iBAAiB,MAAA,EAAQ;AACvD,MAAA,OAAA,CAAQ,KAAK,wBAAA,CAAyB;AAAA,QACpC,GAAG,OAAA;AAAA,QACH,eAAA,EAAiB,MAAA;AAAA,QACjB,SAAA,EAAW;AAAA,OACZ,CAAC,CAAA;AAAA,IACJ;AAGA,IAAA,IAAI,QAAQ,eAAA,EAAiB;AAC3B,MAAA,KAAA,MAAW,GAAA,IAAO,QAAQ,eAAA,EAAiB;AACzC,QAAA,MAAM,WAAA,GAAuB;AAAA,UAC3B,IAAI,GAAA,CAAI,UAAA;AAAA,UACR,IAAA,EAAM,WAAA;AAAA,UACN,OAAA,EAAS,EAAA;AAAA,UACT,eAAA,EAAiB,CAAC,GAAG,CAAA;AAAA,UACrB,WAAW,OAAA,CAAQ;AAAA,SACrB;AACA,QAAA,OAAA,CAAQ,IAAA,CAAK,wBAAA,CAAyB,WAAW,CAAC,CAAA;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,OAAA;AACT","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 * System message entry (context injections, automated notifications)\n * These are typically hidden in compact mode and shown in debug mode.\n */\nexport interface SystemMessageEntry {\n type: 'system_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 | SystemMessageEntry\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// =============================================================================\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\nexport function isSystemMessage(entry: NormalizedEntryType): entry is SystemMessageEntry {\n return entry.type === 'system_message';\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// Rich Content (Mention Rendering)\n// =============================================================================\n\n/**\n * A plain text segment in rich content\n */\nexport interface RichTextSegment {\n type: 'text';\n content: string;\n}\n\n/**\n * A mention segment in rich content (e.g., @ProductX, @JohnDoe)\n */\nexport interface RichMentionSegment {\n type: 'mention';\n /** Display name for the mention */\n name: string;\n /** Optional color for the mention badge */\n color?: string;\n /** Optional avatar/icon URL */\n url?: string;\n /** Optional custom data (e.g., entity ID for click handling) */\n data?: Record<string, unknown>;\n}\n\n/**\n * A single segment of rich content\n */\nexport type RichContentSegment = RichTextSegment | RichMentionSegment;\n\n/**\n * Pre-parsed rich content array for custom rendering\n *\n * @example\n * ```tsx\n * const richContent: RichContent = [\n * { type: 'text', content: 'Check out ' },\n * { type: 'mention', name: 'ProductX', color: '#f59e0b', data: { id: 123 } },\n * { type: 'text', content: ' for details' },\n * ];\n * ```\n */\nexport type RichContent = RichContentSegment[];\n\n/**\n * Props for rendering a mention component\n */\nexport interface MentionProps {\n /** Display name for the mention */\n name: string;\n /** Optional color for the mention badge */\n color?: string;\n /** Optional avatar/icon URL */\n url?: string;\n /** Optional custom data (e.g., entity ID for click handling) */\n data?: Record<string, unknown>;\n}\n\n// =============================================================================\n// Display Mode Configuration\n// =============================================================================\n\n/**\n * Chat display mode\n * - 'user': Concise, friendly view — hides thinking, system messages,\n * shows tool calls as one-liner summaries\n * - 'debug': Full verbose view — everything visible, tool args/output expanded\n */\nexport type ChatDisplayMode = 'user' | 'debug';\n\n/**\n * User-friendly tool description config provided by consumers.\n * Maps tool name patterns to human-readable descriptions.\n *\n * The key can be an exact tool name or a substring pattern (matched via includes).\n * The value can be a static string or a function that receives the tool's\n * input and returns a dynamic description.\n */\nexport type ToolDescriptionMap = Record<\n string,\n string | ((input: unknown) => string)\n>;\n\n// =============================================================================\n// Theming & Customization\n// =============================================================================\n\n/**\n * Message visual style variant\n *\n * - 'bubble': Rounded card with padding and background (default for user messages)\n * - 'plain': No background, just text with subtle styling\n * - 'minimal': Bare text, no decoration\n */\nexport type MessageVariant = 'bubble' | 'plain' | 'minimal';\n\n/**\n * Typography scale/density preset\n *\n * - 'dense': Minimal spacing, smallest fonts (12px base) - for maximum information density\n * - 'compact': Tighter spacing, smaller fonts (13px base)\n * - 'default': Standard sizing (14px base)\n * - 'comfortable': More generous spacing (15px base)\n */\nexport type TypographyScale = 'dense' | 'compact' | 'default' | 'comfortable';\n\n/**\n * Message role for data attribute targeting\n */\nexport type MessageRole = 'user' | 'assistant' | 'thinking' | 'tool' | 'error' | 'widget';\n\n/**\n * Metadata to display with a message\n */\nexport interface MessageMetadata {\n /** Timestamp to display */\n timestamp?: string;\n /** Model name/info to display */\n model?: string;\n /** Custom label */\n label?: string;\n /** Any additional metadata */\n extra?: Record<string, unknown>;\n}\n\n/**\n * Function to render custom message metadata\n */\nexport type RenderMetadataFunction = (props: {\n entry: NormalizedEntry;\n metadata?: MessageMetadata;\n}) => ReactNode;\n\n/**\n * Custom markdown component overrides\n *\n * @example\n * ```tsx\n * const components: MarkdownComponents = {\n * h2: ({ children }) => <h2 className=\"custom-h2\">{children}</h2>,\n * code: ({ children, className }) => <CustomCode className={className}>{children}</CustomCode>,\n * };\n * ```\n */\nexport interface MarkdownComponents {\n h1?: React.ComponentType<{ children?: ReactNode }>;\n h2?: React.ComponentType<{ children?: ReactNode }>;\n h3?: React.ComponentType<{ children?: ReactNode }>;\n h4?: React.ComponentType<{ children?: ReactNode }>;\n h5?: React.ComponentType<{ children?: ReactNode }>;\n h6?: React.ComponentType<{ children?: ReactNode }>;\n p?: React.ComponentType<{ children?: ReactNode }>;\n a?: React.ComponentType<{ children?: ReactNode; href?: string }>;\n ul?: React.ComponentType<{ children?: ReactNode }>;\n ol?: React.ComponentType<{ children?: ReactNode }>;\n li?: React.ComponentType<{ children?: ReactNode }>;\n code?: React.ComponentType<{ children?: ReactNode; className?: string }>;\n pre?: React.ComponentType<{ children?: ReactNode }>;\n blockquote?: React.ComponentType<{ children?: ReactNode }>;\n strong?: React.ComponentType<{ children?: ReactNode }>;\n em?: React.ComponentType<{ children?: ReactNode }>;\n hr?: React.ComponentType<Record<string, never>>;\n img?: React.ComponentType<{ src?: string; alt?: string }>;\n table?: React.ComponentType<{ children?: ReactNode }>;\n thead?: React.ComponentType<{ children?: ReactNode }>;\n tbody?: React.ComponentType<{ children?: ReactNode }>;\n tr?: React.ComponentType<{ children?: ReactNode }>;\n th?: React.ComponentType<{ children?: ReactNode }>;\n td?: React.ComponentType<{ children?: ReactNode }>;\n}\n\n/**\n * Style configuration for message display\n */\nexport interface MessageStyleConfig {\n /** Variant for user messages */\n userVariant?: MessageVariant;\n /** Variant for assistant messages */\n assistantVariant?: MessageVariant;\n /** Typography/density scale */\n scale?: TypographyScale;\n /** Show timestamps with messages */\n showTimestamp?: boolean;\n /** Show avatars */\n showAvatars?: boolean;\n /** Custom class name for messages */\n messageClassName?: string;\n}\n\n/**\n * Default style configuration\n */\nexport const DEFAULT_STYLE_CONFIG: MessageStyleConfig = {\n userVariant: 'bubble',\n assistantVariant: 'bubble',\n scale: 'compact',\n showTimestamp: true,\n showAvatars: true,\n}\n\n// =============================================================================\n// AI SDK Compatible Types\n// =============================================================================\n\n/**\n * Tool invocation status - matches AI SDK ToolInvocation\n */\nexport type ToolInvocationState = 'partial-call' | 'call' | 'result';\n\n/**\n * Tool invocation - matches AI SDK ToolInvocation type\n */\nexport interface ToolInvocation {\n /** Tool invocation state */\n state: ToolInvocationState;\n /** Unique tool call ID */\n toolCallId: string;\n /** Tool name */\n toolName: string;\n /** Arguments passed to the tool (parsed JSON) */\n args: Record<string, unknown>;\n /** Result from tool execution (only present when state is 'result') */\n result?: unknown;\n}\n\n/**\n * AI SDK message role - matches AI SDK Message role\n */\nexport type AIMessageRole = 'user' | 'assistant' | 'system' | 'data';\n\n/**\n * AI SDK compatible message type\n * This is the primary type used by the new useChat hook\n */\nexport interface Message {\n /** Unique message ID */\n id: string;\n /** Message role */\n role: AIMessageRole;\n /** Message content (text) */\n content: string;\n /** Tool invocations for this message */\n toolInvocations?: ToolInvocation[];\n /** When the message was created */\n createdAt?: Date;\n /** Optional reasoning/thinking content */\n reasoning?: string;\n /** Experimental attachments (for file uploads) */\n experimental_attachments?: MessageAttachment[];\n}\n\n/**\n * Message attachment for file uploads\n */\nexport interface MessageAttachment {\n /** Attachment name */\n name: string;\n /** MIME type */\n contentType: string;\n /** URL to the attachment */\n url: string;\n}\n\n// =============================================================================\n// Type Conversion Functions\n// =============================================================================\n\n/**\n * Convert a NormalizedEntry to an AI SDK Message\n */\nexport function normalizedEntryToMessage(entry: NormalizedEntry): Message | null {\n const { id, entryType, content, timestamp } = entry;\n const createdAt = timestamp ? new Date(timestamp) : undefined;\n\n switch (entryType.type) {\n case 'user_message':\n return {\n id,\n role: 'user',\n content,\n createdAt,\n };\n\n case 'assistant_message':\n return {\n id,\n role: 'assistant',\n content,\n createdAt,\n };\n\n case 'thinking':\n // Thinking is represented as reasoning on the previous assistant message\n // Return as assistant message with reasoning\n return {\n id,\n role: 'assistant',\n content: '',\n reasoning: content,\n createdAt,\n };\n\n case 'tool_call': {\n const { toolCall } = entryType;\n const toolInvocation: ToolInvocation = {\n state: toolCall.status === 'pending' ? 'call' : 'result',\n toolCallId: toolCall.id,\n toolName: toolCall.toolName,\n args: (toolCall.input as Record<string, unknown>) || {},\n result: toolCall.output,\n };\n // Tool calls are attached to assistant messages\n return {\n id,\n role: 'assistant',\n content: '',\n toolInvocations: [toolInvocation],\n createdAt,\n };\n }\n\n case 'error':\n // Errors can be represented as system messages\n return {\n id,\n role: 'system',\n content: `Error: ${entryType.message}${entryType.code ? ` (${entryType.code})` : ''}`,\n createdAt,\n };\n\n case 'widget':\n // Widgets are data messages\n return {\n id,\n role: 'data',\n content: JSON.stringify({\n widgetType: entryType.widgetType,\n widgetData: entryType.widgetData,\n }),\n createdAt,\n };\n\n default:\n return null;\n }\n}\n\n/**\n * Convert an AI SDK Message to a NormalizedEntry\n */\nexport function messageToNormalizedEntry(message: Message): NormalizedEntry {\n const { id, role, content, createdAt, toolInvocations, reasoning } = message;\n const timestamp = createdAt?.toISOString();\n\n // If there are tool invocations, create tool call entries\n if (toolInvocations && toolInvocations.length > 0) {\n // For simplicity, take the first tool invocation\n // In practice, multiple tool invocations would need multiple entries\n const inv = toolInvocations[0]!;\n const toolCall: NormalizedToolCall = {\n id: inv.toolCallId,\n toolName: inv.toolName,\n actionType: {\n action: 'generic_tool',\n toolName: inv.toolName,\n arguments: inv.args,\n result: inv.result ? { type: 'json', value: inv.result } : undefined,\n },\n status: inv.state === 'result' ? 'success' : 'pending',\n summary: `${inv.toolName}(${Object.keys(inv.args).join(', ')})`,\n input: inv.args,\n output: inv.result,\n };\n\n return {\n id,\n timestamp,\n entryType: { type: 'tool_call', toolCall },\n content: toolCall.summary,\n };\n }\n\n // If there's reasoning, create a thinking entry\n if (reasoning) {\n return {\n id,\n timestamp,\n entryType: { type: 'thinking' },\n content: reasoning,\n };\n }\n\n // Standard message types based on role\n if (role === 'user') {\n return {\n id,\n timestamp,\n entryType: { type: 'user_message' },\n content,\n };\n }\n\n if (role === 'assistant') {\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n }\n\n if (role === 'system') {\n // System messages that look like errors\n if (content.startsWith('Error:')) {\n return {\n id,\n timestamp,\n entryType: { type: 'error', message: content.replace('Error: ', '') },\n content,\n };\n }\n return {\n id,\n timestamp,\n entryType: { type: 'system_message' },\n content,\n };\n }\n\n if (role === 'data') {\n // Try to parse as widget\n try {\n const data = JSON.parse(content);\n if (data.widgetType) {\n return {\n id,\n timestamp,\n entryType: {\n type: 'widget',\n widgetType: data.widgetType,\n widgetData: data.widgetData,\n },\n content: '',\n };\n }\n } catch {\n // Not valid JSON, treat as assistant message\n }\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n }\n\n // Default fallback\n return {\n id,\n timestamp,\n entryType: { type: 'assistant_message' },\n content,\n };\n}\n\n/**\n * Convert an array of NormalizedEntry to AI SDK Messages\n * Merges consecutive assistant entries (text + tool calls) into single messages\n */\nexport function normalizedEntriesToMessages(entries: NormalizedEntry[]): Message[] {\n const messages: Message[] = [];\n let currentAssistantMessage: Message | null = null;\n\n for (const entry of entries) {\n const message = normalizedEntryToMessage(entry);\n if (!message) continue;\n\n if (message.role === 'assistant') {\n // Check if we should merge with current assistant message\n if (currentAssistantMessage) {\n // Merge tool invocations\n if (message.toolInvocations) {\n currentAssistantMessage.toolInvocations = [\n ...(currentAssistantMessage.toolInvocations || []),\n ...message.toolInvocations,\n ];\n }\n // Merge content\n if (message.content) {\n currentAssistantMessage.content = currentAssistantMessage.content\n ? `${currentAssistantMessage.content}\\n${message.content}`\n : message.content;\n }\n // Merge reasoning\n if (message.reasoning) {\n currentAssistantMessage.reasoning = currentAssistantMessage.reasoning\n ? `${currentAssistantMessage.reasoning}\\n${message.reasoning}`\n : message.reasoning;\n }\n } else {\n currentAssistantMessage = { ...message };\n }\n } else {\n // Flush current assistant message\n if (currentAssistantMessage) {\n messages.push(currentAssistantMessage);\n currentAssistantMessage = null;\n }\n messages.push(message);\n }\n }\n\n // Flush any remaining assistant message\n if (currentAssistantMessage) {\n messages.push(currentAssistantMessage);\n }\n\n return messages;\n}\n\n/**\n * Convert AI SDK Messages back to NormalizedEntry array\n * Expands tool invocations into separate entries\n */\nexport function messagesToNormalizedEntries(messages: Message[]): NormalizedEntry[] {\n const entries: NormalizedEntry[] = [];\n\n for (const message of messages) {\n // If message has reasoning, add thinking entry first\n if (message.reasoning) {\n entries.push({\n id: `${message.id}-thinking`,\n timestamp: message.createdAt?.toISOString(),\n entryType: { type: 'thinking' },\n content: message.reasoning,\n });\n }\n\n // If message has content, add the content entry\n if (message.content || !message.toolInvocations?.length) {\n entries.push(messageToNormalizedEntry({\n ...message,\n toolInvocations: undefined,\n reasoning: undefined,\n }));\n }\n\n // Add separate entries for each tool invocation\n if (message.toolInvocations) {\n for (const inv of message.toolInvocations) {\n const toolMessage: Message = {\n id: inv.toolCallId,\n role: 'assistant',\n content: '',\n toolInvocations: [inv],\n createdAt: message.createdAt,\n };\n entries.push(messageToNormalizedEntry(toolMessage));\n }\n }\n }\n\n return entries;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ash-cloud/ash-ui",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "React UI components for building agentic interfaces - powered by AI SDK Elements",
5
5
  "repository": {
6
6
  "type": "git",