@ash-cloud/ash-ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design-tokens.cjs +20 -0
- package/dist/design-tokens.cjs.map +1 -1
- package/dist/design-tokens.d.cts +31 -1
- package/dist/design-tokens.d.ts +31 -1
- package/dist/design-tokens.js +20 -1
- package/dist/design-tokens.js.map +1 -1
- package/dist/icons.cjs +23 -0
- package/dist/icons.cjs.map +1 -1
- package/dist/icons.d.cts +4 -1
- package/dist/icons.d.ts +4 -1
- package/dist/icons.js +21 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.cjs +2416 -1955
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +840 -641
- package/dist/index.d.ts +840 -641
- package/dist/index.js +2360 -1930
- package/dist/index.js.map +1 -1
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.cjs +243 -6
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +197 -121
- package/dist/types.d.ts +197 -121
- package/dist/types.js +239 -6
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +0 -35
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -28
- package/dist/utils.d.ts +2 -28
- package/dist/utils.js +1 -34
- package/dist/utils.js.map +1 -1
- package/package.json +22 -16
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;AA4YO,SAAS,mBAAmB,MAAA,EAAgD;AACjF,EAAA,OAAO,OAAO,MAAA,KAAW,aAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,eAAe,MAAA,EAA4C;AACzE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA;AAC3B;AAEO,SAAS,aAAa,MAAA,EAA0C;AACrE,EAAA,OAAO,OAAO,MAAA,KAAW,MAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,MAAA,EAA6C;AAC3E,EAAA,OAAO,OAAO,MAAA,KAAW,UAAA;AAC3B;AAEO,SAAS,oBAAoB,MAAA,EAAiD;AACnF,EAAA,OAAO,OAAO,MAAA,KAAW,cAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,gBAAgB,KAAA,EAAoD;AAClF,EAAA,OAAO,MAAM,IAAA,KAAS,WAAA;AACxB;AAEO,SAAS,aAAa,KAAA,EAAiD;AAC5E,EAAA,OAAO,MAAM,IAAA,KAAS,OAAA;AACxB;AAEO,SAAS,cAAc,KAAA,EAAkD;AAC9E,EAAA,OAAO,MAAM,IAAA,KAAS,QAAA;AACxB;AAsIO,IAAM,sBAAA,GAA4C;AAAA,EACvD,IAAA,EAAM,QAAA;AAAA,EACN,oBAAA,EAAsB,CAAA;AAAA,EACtB,eAAA,EAAiB,KAAA;AAAA,EACjB,iBAAA,EAAmB;AACrB","file":"types.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 /** Number of lines read (for display) */\n linesRead?: number;\n}\n\n/**\n * File edit action\n */\nexport interface FileEditAction {\n action: 'file_edit';\n path: string;\n oldString?: string;\n newString?: string;\n replaceAll?: boolean;\n /** Number of lines added */\n linesAdded?: number;\n /** Number of lines removed */\n linesRemoved?: number;\n}\n\n/**\n * File write action\n */\nexport interface FileWriteAction {\n action: 'file_write';\n path: string;\n content?: string;\n /** Number of lines written */\n linesWritten?: number;\n}\n\n/**\n * Search/grep action\n */\nexport interface SearchAction {\n action: 'search';\n pattern: string;\n path?: string;\n glob?: string;\n type?: string;\n}\n\n/**\n * Glob/file pattern matching action\n */\nexport interface GlobAction {\n action: 'glob';\n pattern: string;\n path?: string;\n}\n\n/**\n * Web fetch action\n */\nexport interface WebFetchAction {\n action: 'web_fetch';\n url: string;\n prompt?: string;\n}\n\n/**\n * Web search action\n */\nexport interface WebSearchAction {\n action: 'web_search';\n query: string;\n}\n\n/**\n * MCP (Model Context Protocol) tool action\n */\nexport interface McpToolAction {\n action: 'mcp_tool';\n serverName: string;\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Generic/unknown tool action\n */\nexport interface GenericToolAction {\n action: 'generic_tool';\n toolName: string;\n arguments?: unknown;\n result?: ToolResult;\n}\n\n/**\n * Agent/Task tool action - represents a sub-agent that can have nested tool calls\n */\nexport interface AgentToolAction {\n action: 'agent_tool';\n /** Agent type (e.g., 'Explore', 'Plan', 'Bash', 'general-purpose') */\n agentType: string;\n /** Description of what the agent is doing */\n description: string;\n /** Full prompt given to the agent */\n prompt?: string;\n /** Nested tool calls made by this agent */\n nestedToolCalls?: NormalizedToolCall[];\n /** Current count of tool calls (updates during streaming) */\n toolCallCount?: number;\n /** When the agent started */\n startedAt?: string;\n /** When the agent completed */\n completedAt?: string;\n /** Result/output from the agent */\n result?: ToolResult;\n}\n\n// =============================================================================\n// Todo Types\n// =============================================================================\n\n/**\n * Status of a todo item\n */\nexport type TodoStatus = 'pending' | 'in_progress' | 'completed';\n\n/**\n * A single todo item from TodoWrite tool\n */\nexport interface TodoItem {\n /** Task content - imperative form (e.g., \"Run tests\") */\n content: string;\n /** Current status of the todo */\n status: TodoStatus;\n /** Active form shown during execution (e.g., \"Running tests\") */\n activeForm: string;\n}\n\n/**\n * TodoWrite tool action - tracks task progress\n */\nexport interface TodoWriteAction {\n action: 'todo_write';\n /** All todos in the current list */\n todos: TodoItem[];\n /** Summary statistics */\n stats?: {\n total: number;\n completed: number;\n inProgress: number;\n pending: number;\n };\n}\n\n/**\n * Discriminated union of all action types\n */\nexport type ActionType =\n | CommandRunAction\n | FileReadAction\n | FileEditAction\n | FileWriteAction\n | SearchAction\n | GlobAction\n | WebFetchAction\n | WebSearchAction\n | McpToolAction\n | GenericToolAction\n | TodoWriteAction\n | AgentToolAction;\n\n// =============================================================================\n// Normalized Tool Call\n// =============================================================================\n\n/**\n * A normalized tool call that combines tool_use and tool_result data\n */\nexport interface NormalizedToolCall {\n /** Unique ID from the tool_use block */\n id: string;\n\n /** Original tool name (e.g., 'Bash', 'Read', 'mcp__server__tool') */\n toolName: string;\n\n /** Parsed action type with structured arguments and result */\n actionType: ActionType;\n\n /** Current execution status */\n status: ToolStatus;\n\n /** Human-readable one-liner summary */\n summary: string;\n\n /** Raw input from tool_use event (for display in UI) */\n input?: unknown;\n\n /** Raw output/result from tool_result event (for display in UI) */\n output?: unknown;\n\n /** When the tool call started */\n startedAt?: string;\n\n /** When the tool call completed */\n completedAt?: string;\n\n /** Whether this tool call resulted in an error */\n isError?: boolean;\n\n /** Nested tool calls (for agent/sub-agent tools like Task) */\n nestedToolCalls?: NormalizedToolCall[];\n\n /** Current count of nested tool calls (updates during streaming) */\n nestedToolCallCount?: number;\n}\n\n// =============================================================================\n// Normalized Entry Types\n// =============================================================================\n\n/**\n * User message entry\n */\nexport interface UserMessageEntry {\n type: 'user_message';\n}\n\n/**\n * Assistant message entry\n */\nexport interface AssistantMessageEntry {\n type: 'assistant_message';\n}\n\n/**\n * Thinking/reasoning entry (extended thinking)\n */\nexport interface ThinkingEntry {\n type: 'thinking';\n}\n\n/**\n * Tool call entry with full tool call data\n */\nexport interface ToolCallEntry {\n type: 'tool_call';\n toolCall: NormalizedToolCall;\n}\n\n/**\n * Error entry\n */\nexport interface ErrorEntry {\n type: 'error';\n message: string;\n code?: string;\n}\n\n/**\n * Custom widget entry - rendered via consumer-provided render function\n *\n * Use this for interactive UI components like:\n * - Image grid selectors\n * - Product carousels\n * - Form inputs\n * - Data visualizations\n * - Any custom interactive widget\n *\n * @example\n * ```tsx\n * const entry: NormalizedEntry = {\n * id: 'widget-1',\n * entryType: {\n * type: 'widget',\n * widgetType: 'image-grid',\n * widgetData: { images: [...], selected: null },\n * },\n * content: 'Select an image',\n * };\n * ```\n */\nexport interface WidgetEntry {\n type: 'widget';\n /** Widget type identifier (e.g., 'image-grid', 'product-selector') */\n widgetType: string;\n /** Widget-specific data passed to the render function */\n widgetData: unknown;\n}\n\n/**\n * Discriminated union of all entry types\n */\nexport type NormalizedEntryType =\n | UserMessageEntry\n | AssistantMessageEntry\n | ThinkingEntry\n | ToolCallEntry\n | ErrorEntry\n | WidgetEntry;\n\n// =============================================================================\n// Normalized Entry\n// =============================================================================\n\n/**\n * A normalized conversation entry for display\n */\nexport interface NormalizedEntry {\n /** Unique entry ID */\n id: string;\n\n /** ISO timestamp */\n timestamp?: string;\n\n /** Entry type with type-specific data */\n entryType: NormalizedEntryType;\n\n /** Text content for display (plain text or markdown) */\n content: string;\n\n /**\n * Rich content segments (structured approach - preferred over regex transformers).\n * When provided, this takes precedence over `content` for rendering.\n *\n * @example\n * ```ts\n * richContent: [\n * { type: 'text', content: 'Analyzing ' },\n * { type: 'mention', name: 'Scene1', color: '#ff0' },\n * { type: 'text', content: ' for transitions.' },\n * ]\n * ```\n */\n richContent?: RichContent;\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\nexport function isCommandRunAction(action: ActionType): action is CommandRunAction {\n return action.action === 'command_run';\n}\n\nexport function isFileReadAction(action: ActionType): action is FileReadAction {\n return action.action === 'file_read';\n}\n\nexport function isFileEditAction(action: ActionType): action is FileEditAction {\n return action.action === 'file_edit';\n}\n\nexport function isFileWriteAction(action: ActionType): action is FileWriteAction {\n return action.action === 'file_write';\n}\n\nexport function isSearchAction(action: ActionType): action is SearchAction {\n return action.action === 'search';\n}\n\nexport function isGlobAction(action: ActionType): action is GlobAction {\n return action.action === 'glob';\n}\n\nexport function isWebFetchAction(action: ActionType): action is WebFetchAction {\n return action.action === 'web_fetch';\n}\n\nexport function isWebSearchAction(action: ActionType): action is WebSearchAction {\n return action.action === 'web_search';\n}\n\nexport function isMcpToolAction(action: ActionType): action is McpToolAction {\n return action.action === 'mcp_tool';\n}\n\nexport function isGenericToolAction(action: ActionType): action is GenericToolAction {\n return action.action === 'generic_tool';\n}\n\nexport function isTodoWriteAction(action: ActionType): action is TodoWriteAction {\n return action.action === 'todo_write';\n}\n\nexport function isAgentToolAction(action: ActionType): action is AgentToolAction {\n return action.action === 'agent_tool';\n}\n\nexport function isToolCallEntry(entry: NormalizedEntryType): entry is ToolCallEntry {\n return entry.type === 'tool_call';\n}\n\nexport function isErrorEntry(entry: NormalizedEntryType): entry is ErrorEntry {\n return entry.type === 'error';\n}\n\nexport function isWidgetEntry(entry: NormalizedEntryType): entry is WidgetEntry {\n return entry.type === 'widget';\n}\n\n// =============================================================================\n// Widget Rendering\n// =============================================================================\n\n/**\n * Props passed to the widget render function\n */\nexport interface WidgetRenderProps<T = unknown> {\n /** The widget entry being rendered */\n entry: NormalizedEntry;\n /** Widget type identifier */\n widgetType: string;\n /** Widget-specific data */\n widgetData: T;\n /** Callback for widget interactions (e.g., selection, submit) */\n onAction?: (action: WidgetAction) => void;\n}\n\n/**\n * Action dispatched from a widget interaction\n */\nexport interface WidgetAction {\n /** Action type (e.g., 'select', 'submit', 'cancel') */\n type: string;\n /** Widget type that dispatched the action */\n widgetType: string;\n /** Entry ID of the widget */\n entryId: string;\n /** Action-specific payload */\n payload?: unknown;\n}\n\n/**\n * Function type for rendering custom widgets\n *\n * @example\n * ```tsx\n * const renderWidget: WidgetRenderFunction = ({ widgetType, widgetData, onAction }) => {\n * switch (widgetType) {\n * case 'image-grid':\n * return (\n * <ImageGrid\n * images={widgetData.images}\n * onSelect={(id) => onAction?.({ type: 'select', widgetType, entryId, payload: { id } })}\n * />\n * );\n * case 'product-selector':\n * return <ProductSelector data={widgetData} onAction={onAction} />;\n * default:\n * return null;\n * }\n * };\n *\n * <MessageList entries={entries} renderWidget={renderWidget} />\n * ```\n */\nexport type WidgetRenderFunction = (props: WidgetRenderProps) => ReactNode;\n\n// =============================================================================\n// Log Types (for SandboxLogsPanel)\n// =============================================================================\n\nexport type LogLevel = 'info' | 'warn' | 'error' | 'debug';\nexport type LogCategory = 'setup' | 'skills' | 'execution' | 'process' | 'startup';\n\nexport interface LogEntry {\n timestamp: string;\n level: LogLevel;\n category: LogCategory;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// =============================================================================\n// File Attachment\n// =============================================================================\n\nexport interface FileAttachment {\n name: string;\n type: string;\n size: number;\n base64: string;\n}\n\n// =============================================================================\n// Display Mode Configuration\n// =============================================================================\n\n/**\n * Display mode for tool calls in the chat interface\n *\n * - 'inline': Each tool call rendered inline as expandable cards (current behavior)\n * - 'compact': Single animated status line that updates with each tool call,\n * with accordion to expand and see execution details. Text streams unbroken.\n * - 'accordion': Simpler step-based accordion list that accumulates tool calls\n * with icons, labels, and durations (like Vidra's ThinkingIndicator).\n */\nexport type ToolDisplayMode = 'inline' | 'compact' | 'accordion';\n\n/**\n * Configuration for tool display behavior\n */\nexport interface ToolDisplayConfig {\n /**\n * Display mode for tool calls\n * @default 'inline'\n */\n mode: ToolDisplayMode;\n\n /**\n * For 'compact' mode: break into a new group every N tool calls\n * Set to 0 or undefined to never break (all tool calls in single group)\n * @default 0\n */\n breakEveryNToolCalls?: number;\n\n /**\n * Whether tool call groups start expanded\n * @default false\n */\n defaultExpanded?: boolean;\n\n /**\n * Animation duration for status line transitions (ms)\n * @default 300\n */\n animationDuration?: number;\n}\n\n/**\n * Default display configuration\n */\nexport const DEFAULT_DISPLAY_CONFIG: ToolDisplayConfig = {\n mode: 'inline',\n breakEveryNToolCalls: 0,\n defaultExpanded: false,\n animationDuration: 300,\n};\n\n// =============================================================================\n// Rich Content (Structured Approach - Preferred)\n// =============================================================================\n\n/**\n * A text segment within rich content\n */\nexport interface RichTextSegment {\n type: 'text';\n /** Plain text or markdown content */\n content: string;\n}\n\n/**\n * A mention/reference segment within rich content\n */\nexport interface RichMentionSegment {\n type: 'mention';\n /** The mentioned entity name */\n name: string;\n /** Optional identifier for the entity */\n id?: string;\n /** Optional color for styling */\n color?: string;\n /** Optional additional data */\n data?: Record<string, unknown>;\n}\n\n/**\n * A custom component segment within rich content\n */\nexport interface RichComponentSegment {\n type: 'component';\n /** Component type identifier (consumer handles rendering) */\n componentType: string;\n /** Props to pass to the component */\n props: Record<string, unknown>;\n}\n\n/**\n * Union of all rich content segment types\n */\nexport type RichContentSegment =\n | RichTextSegment\n | RichMentionSegment\n | RichComponentSegment;\n\n/**\n * Rich content array - the preferred way to send structured content\n *\n * @example\n * ```ts\n * const content: RichContent = [\n * { type: 'text', content: 'Looking at ' },\n * { type: 'mention', name: 'Scene1', color: '#ff0', id: 'seq-1' },\n * { type: 'text', content: ' timeline for the transition.' },\n * ];\n * ```\n */\nexport type RichContent = RichContentSegment[];\n\n/**\n * Props for rendering a mention segment\n */\nexport interface MentionRenderProps {\n segment: RichMentionSegment;\n}\n\n/**\n * Props for rendering a custom component segment\n */\nexport interface ComponentRenderProps {\n segment: RichComponentSegment;\n}\n\n/**\n * Custom render functions for rich content segments\n */\nexport interface RichContentRenderers {\n /**\n * Render a mention segment. If not provided, renders as styled badge.\n */\n renderMention?: (props: MentionRenderProps) => ReactNode;\n /**\n * Render a custom component segment.\n */\n renderComponent?: (props: ComponentRenderProps) => ReactNode;\n}\n\n// =============================================================================\n// Tool Execution Group (for compact mode)\n// =============================================================================\n\n/**\n * A group of consecutive tool calls that are displayed together\n * in compact mode. Text content before/after flows around the group.\n */\nexport interface ToolExecutionGroup {\n /** Unique ID for the group */\n id: string;\n\n /** Tool calls in this group (in order) */\n toolCalls: NormalizedToolCall[];\n\n /** Index of the currently active/latest tool call for status display */\n activeIndex: number;\n\n /** Whether all tool calls in this group have completed */\n isComplete: boolean;\n\n /** Overall status of the group */\n status: 'pending' | 'success' | 'partial_failure' | 'failed';\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;AA6XO,SAAS,mBAAmB,MAAA,EAAgD;AACjF,EAAA,OAAO,OAAO,MAAA,KAAW,aAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,iBAAiB,MAAA,EAA8C;AAC7E,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA;AAC3B;AAEO,SAAS,kBAAkB,MAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,YAAA;AAC3B;AAEO,SAAS,eAAe,MAAA,EAA4C;AACzE,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I,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.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 /** 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// 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"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -287,20 +287,6 @@ interface NormalizedEntry {
|
|
|
287
287
|
entryType: NormalizedEntryType;
|
|
288
288
|
/** Text content for display (plain text or markdown) */
|
|
289
289
|
content: string;
|
|
290
|
-
/**
|
|
291
|
-
* Rich content segments (structured approach - preferred over regex transformers).
|
|
292
|
-
* When provided, this takes precedence over `content` for rendering.
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* ```ts
|
|
296
|
-
* richContent: [
|
|
297
|
-
* { type: 'text', content: 'Analyzing ' },
|
|
298
|
-
* { type: 'mention', name: 'Scene1', color: '#ff0' },
|
|
299
|
-
* { type: 'text', content: ' for transitions.' },
|
|
300
|
-
* ]
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
richContent?: RichContent;
|
|
304
290
|
}
|
|
305
291
|
declare function isCommandRunAction(action: ActionType): action is CommandRunAction;
|
|
306
292
|
declare function isFileReadAction(action: ActionType): action is FileReadAction;
|
|
@@ -384,134 +370,224 @@ interface FileAttachment {
|
|
|
384
370
|
base64: string;
|
|
385
371
|
}
|
|
386
372
|
/**
|
|
387
|
-
*
|
|
373
|
+
* Message visual style variant
|
|
388
374
|
*
|
|
389
|
-
* - '
|
|
390
|
-
* - '
|
|
391
|
-
*
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
*/
|
|
395
|
-
type ToolDisplayMode = 'inline' | 'compact' | 'accordion';
|
|
396
|
-
/**
|
|
397
|
-
* Configuration for tool display behavior
|
|
398
|
-
*/
|
|
399
|
-
interface ToolDisplayConfig {
|
|
400
|
-
/**
|
|
401
|
-
* Display mode for tool calls
|
|
402
|
-
* @default 'inline'
|
|
403
|
-
*/
|
|
404
|
-
mode: ToolDisplayMode;
|
|
405
|
-
/**
|
|
406
|
-
* For 'compact' mode: break into a new group every N tool calls
|
|
407
|
-
* Set to 0 or undefined to never break (all tool calls in single group)
|
|
408
|
-
* @default 0
|
|
409
|
-
*/
|
|
410
|
-
breakEveryNToolCalls?: number;
|
|
411
|
-
/**
|
|
412
|
-
* Whether tool call groups start expanded
|
|
413
|
-
* @default false
|
|
414
|
-
*/
|
|
415
|
-
defaultExpanded?: boolean;
|
|
416
|
-
/**
|
|
417
|
-
* Animation duration for status line transitions (ms)
|
|
418
|
-
* @default 300
|
|
419
|
-
*/
|
|
420
|
-
animationDuration?: number;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Default display configuration
|
|
424
|
-
*/
|
|
425
|
-
declare const DEFAULT_DISPLAY_CONFIG: ToolDisplayConfig;
|
|
426
|
-
/**
|
|
427
|
-
* A text segment within rich content
|
|
428
|
-
*/
|
|
429
|
-
interface RichTextSegment {
|
|
430
|
-
type: 'text';
|
|
431
|
-
/** Plain text or markdown content */
|
|
432
|
-
content: string;
|
|
433
|
-
}
|
|
375
|
+
* - 'bubble': Rounded card with padding and background (default for user messages)
|
|
376
|
+
* - 'plain': No background, just text with subtle styling
|
|
377
|
+
* - 'minimal': Bare text, no decoration
|
|
378
|
+
*/
|
|
379
|
+
type MessageVariant = 'bubble' | 'plain' | 'minimal';
|
|
434
380
|
/**
|
|
435
|
-
*
|
|
381
|
+
* Typography scale/density preset
|
|
382
|
+
*
|
|
383
|
+
* - 'dense': Minimal spacing, smallest fonts (12px base) - for maximum information density
|
|
384
|
+
* - 'compact': Tighter spacing, smaller fonts (13px base)
|
|
385
|
+
* - 'default': Standard sizing (14px base)
|
|
386
|
+
* - 'comfortable': More generous spacing (15px base)
|
|
436
387
|
*/
|
|
437
|
-
|
|
438
|
-
type: 'mention';
|
|
439
|
-
/** The mentioned entity name */
|
|
440
|
-
name: string;
|
|
441
|
-
/** Optional identifier for the entity */
|
|
442
|
-
id?: string;
|
|
443
|
-
/** Optional color for styling */
|
|
444
|
-
color?: string;
|
|
445
|
-
/** Optional additional data */
|
|
446
|
-
data?: Record<string, unknown>;
|
|
447
|
-
}
|
|
388
|
+
type TypographyScale = 'dense' | 'compact' | 'default' | 'comfortable';
|
|
448
389
|
/**
|
|
449
|
-
*
|
|
390
|
+
* Message role for data attribute targeting
|
|
450
391
|
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
392
|
+
type MessageRole = 'user' | 'assistant' | 'thinking' | 'tool' | 'error' | 'widget';
|
|
393
|
+
/**
|
|
394
|
+
* Metadata to display with a message
|
|
395
|
+
*/
|
|
396
|
+
interface MessageMetadata {
|
|
397
|
+
/** Timestamp to display */
|
|
398
|
+
timestamp?: string;
|
|
399
|
+
/** Model name/info to display */
|
|
400
|
+
model?: string;
|
|
401
|
+
/** Custom label */
|
|
402
|
+
label?: string;
|
|
403
|
+
/** Any additional metadata */
|
|
404
|
+
extra?: Record<string, unknown>;
|
|
457
405
|
}
|
|
458
406
|
/**
|
|
459
|
-
*
|
|
407
|
+
* Function to render custom message metadata
|
|
460
408
|
*/
|
|
461
|
-
type
|
|
409
|
+
type RenderMetadataFunction = (props: {
|
|
410
|
+
entry: NormalizedEntry;
|
|
411
|
+
metadata?: MessageMetadata;
|
|
412
|
+
}) => ReactNode;
|
|
462
413
|
/**
|
|
463
|
-
*
|
|
414
|
+
* Custom markdown component overrides
|
|
464
415
|
*
|
|
465
416
|
* @example
|
|
466
|
-
* ```
|
|
467
|
-
* const
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* ];
|
|
417
|
+
* ```tsx
|
|
418
|
+
* const components: MarkdownComponents = {
|
|
419
|
+
* h2: ({ children }) => <h2 className="custom-h2">{children}</h2>,
|
|
420
|
+
* code: ({ children, className }) => <CustomCode className={className}>{children}</CustomCode>,
|
|
421
|
+
* };
|
|
472
422
|
* ```
|
|
473
423
|
*/
|
|
474
|
-
|
|
424
|
+
interface MarkdownComponents {
|
|
425
|
+
h1?: React.ComponentType<{
|
|
426
|
+
children?: ReactNode;
|
|
427
|
+
}>;
|
|
428
|
+
h2?: React.ComponentType<{
|
|
429
|
+
children?: ReactNode;
|
|
430
|
+
}>;
|
|
431
|
+
h3?: React.ComponentType<{
|
|
432
|
+
children?: ReactNode;
|
|
433
|
+
}>;
|
|
434
|
+
h4?: React.ComponentType<{
|
|
435
|
+
children?: ReactNode;
|
|
436
|
+
}>;
|
|
437
|
+
h5?: React.ComponentType<{
|
|
438
|
+
children?: ReactNode;
|
|
439
|
+
}>;
|
|
440
|
+
h6?: React.ComponentType<{
|
|
441
|
+
children?: ReactNode;
|
|
442
|
+
}>;
|
|
443
|
+
p?: React.ComponentType<{
|
|
444
|
+
children?: ReactNode;
|
|
445
|
+
}>;
|
|
446
|
+
a?: React.ComponentType<{
|
|
447
|
+
children?: ReactNode;
|
|
448
|
+
href?: string;
|
|
449
|
+
}>;
|
|
450
|
+
ul?: React.ComponentType<{
|
|
451
|
+
children?: ReactNode;
|
|
452
|
+
}>;
|
|
453
|
+
ol?: React.ComponentType<{
|
|
454
|
+
children?: ReactNode;
|
|
455
|
+
}>;
|
|
456
|
+
li?: React.ComponentType<{
|
|
457
|
+
children?: ReactNode;
|
|
458
|
+
}>;
|
|
459
|
+
code?: React.ComponentType<{
|
|
460
|
+
children?: ReactNode;
|
|
461
|
+
className?: string;
|
|
462
|
+
}>;
|
|
463
|
+
pre?: React.ComponentType<{
|
|
464
|
+
children?: ReactNode;
|
|
465
|
+
}>;
|
|
466
|
+
blockquote?: React.ComponentType<{
|
|
467
|
+
children?: ReactNode;
|
|
468
|
+
}>;
|
|
469
|
+
strong?: React.ComponentType<{
|
|
470
|
+
children?: ReactNode;
|
|
471
|
+
}>;
|
|
472
|
+
em?: React.ComponentType<{
|
|
473
|
+
children?: ReactNode;
|
|
474
|
+
}>;
|
|
475
|
+
hr?: React.ComponentType<Record<string, never>>;
|
|
476
|
+
img?: React.ComponentType<{
|
|
477
|
+
src?: string;
|
|
478
|
+
alt?: string;
|
|
479
|
+
}>;
|
|
480
|
+
table?: React.ComponentType<{
|
|
481
|
+
children?: ReactNode;
|
|
482
|
+
}>;
|
|
483
|
+
thead?: React.ComponentType<{
|
|
484
|
+
children?: ReactNode;
|
|
485
|
+
}>;
|
|
486
|
+
tbody?: React.ComponentType<{
|
|
487
|
+
children?: ReactNode;
|
|
488
|
+
}>;
|
|
489
|
+
tr?: React.ComponentType<{
|
|
490
|
+
children?: ReactNode;
|
|
491
|
+
}>;
|
|
492
|
+
th?: React.ComponentType<{
|
|
493
|
+
children?: ReactNode;
|
|
494
|
+
}>;
|
|
495
|
+
td?: React.ComponentType<{
|
|
496
|
+
children?: ReactNode;
|
|
497
|
+
}>;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Style configuration for message display
|
|
501
|
+
*/
|
|
502
|
+
interface MessageStyleConfig {
|
|
503
|
+
/** Variant for user messages */
|
|
504
|
+
userVariant?: MessageVariant;
|
|
505
|
+
/** Variant for assistant messages */
|
|
506
|
+
assistantVariant?: MessageVariant;
|
|
507
|
+
/** Typography/density scale */
|
|
508
|
+
scale?: TypographyScale;
|
|
509
|
+
/** Show timestamps with messages */
|
|
510
|
+
showTimestamp?: boolean;
|
|
511
|
+
/** Show avatars */
|
|
512
|
+
showAvatars?: boolean;
|
|
513
|
+
/** Custom class name for messages */
|
|
514
|
+
messageClassName?: string;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Default style configuration
|
|
518
|
+
*/
|
|
519
|
+
declare const DEFAULT_STYLE_CONFIG: MessageStyleConfig;
|
|
520
|
+
/**
|
|
521
|
+
* Tool invocation status - matches AI SDK ToolInvocation
|
|
522
|
+
*/
|
|
523
|
+
type ToolInvocationState = 'partial-call' | 'call' | 'result';
|
|
524
|
+
/**
|
|
525
|
+
* Tool invocation - matches AI SDK ToolInvocation type
|
|
526
|
+
*/
|
|
527
|
+
interface ToolInvocation {
|
|
528
|
+
/** Tool invocation state */
|
|
529
|
+
state: ToolInvocationState;
|
|
530
|
+
/** Unique tool call ID */
|
|
531
|
+
toolCallId: string;
|
|
532
|
+
/** Tool name */
|
|
533
|
+
toolName: string;
|
|
534
|
+
/** Arguments passed to the tool (parsed JSON) */
|
|
535
|
+
args: Record<string, unknown>;
|
|
536
|
+
/** Result from tool execution (only present when state is 'result') */
|
|
537
|
+
result?: unknown;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* AI SDK message role - matches AI SDK Message role
|
|
541
|
+
*/
|
|
542
|
+
type AIMessageRole = 'user' | 'assistant' | 'system' | 'data';
|
|
475
543
|
/**
|
|
476
|
-
*
|
|
544
|
+
* AI SDK compatible message type
|
|
545
|
+
* This is the primary type used by the new useChat hook
|
|
477
546
|
*/
|
|
478
|
-
interface
|
|
479
|
-
|
|
547
|
+
interface Message {
|
|
548
|
+
/** Unique message ID */
|
|
549
|
+
id: string;
|
|
550
|
+
/** Message role */
|
|
551
|
+
role: AIMessageRole;
|
|
552
|
+
/** Message content (text) */
|
|
553
|
+
content: string;
|
|
554
|
+
/** Tool invocations for this message */
|
|
555
|
+
toolInvocations?: ToolInvocation[];
|
|
556
|
+
/** When the message was created */
|
|
557
|
+
createdAt?: Date;
|
|
558
|
+
/** Optional reasoning/thinking content */
|
|
559
|
+
reasoning?: string;
|
|
560
|
+
/** Experimental attachments (for file uploads) */
|
|
561
|
+
experimental_attachments?: MessageAttachment[];
|
|
480
562
|
}
|
|
481
563
|
/**
|
|
482
|
-
*
|
|
564
|
+
* Message attachment for file uploads
|
|
483
565
|
*/
|
|
484
|
-
interface
|
|
485
|
-
|
|
566
|
+
interface MessageAttachment {
|
|
567
|
+
/** Attachment name */
|
|
568
|
+
name: string;
|
|
569
|
+
/** MIME type */
|
|
570
|
+
contentType: string;
|
|
571
|
+
/** URL to the attachment */
|
|
572
|
+
url: string;
|
|
486
573
|
}
|
|
487
574
|
/**
|
|
488
|
-
*
|
|
575
|
+
* Convert a NormalizedEntry to an AI SDK Message
|
|
489
576
|
*/
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Render a mention segment. If not provided, renders as styled badge.
|
|
493
|
-
*/
|
|
494
|
-
renderMention?: (props: MentionRenderProps) => ReactNode;
|
|
495
|
-
/**
|
|
496
|
-
* Render a custom component segment.
|
|
497
|
-
*/
|
|
498
|
-
renderComponent?: (props: ComponentRenderProps) => ReactNode;
|
|
499
|
-
}
|
|
577
|
+
declare function normalizedEntryToMessage(entry: NormalizedEntry): Message | null;
|
|
500
578
|
/**
|
|
501
|
-
*
|
|
502
|
-
* in compact mode. Text content before/after flows around the group.
|
|
579
|
+
* Convert an AI SDK Message to a NormalizedEntry
|
|
503
580
|
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
581
|
+
declare function messageToNormalizedEntry(message: Message): NormalizedEntry;
|
|
582
|
+
/**
|
|
583
|
+
* Convert an array of NormalizedEntry to AI SDK Messages
|
|
584
|
+
* Merges consecutive assistant entries (text + tool calls) into single messages
|
|
585
|
+
*/
|
|
586
|
+
declare function normalizedEntriesToMessages(entries: NormalizedEntry[]): Message[];
|
|
587
|
+
/**
|
|
588
|
+
* Convert AI SDK Messages back to NormalizedEntry array
|
|
589
|
+
* Expands tool invocations into separate entries
|
|
590
|
+
*/
|
|
591
|
+
declare function messagesToNormalizedEntries(messages: Message[]): NormalizedEntry[];
|
|
516
592
|
|
|
517
|
-
export { type ActionType, type AgentToolAction, type AssistantMessageEntry, type CommandRunAction, type CommandRunResult,
|
|
593
|
+
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 Message, type MessageAttachment, type MessageMetadata, type MessageRole, type MessageStyleConfig, type MessageVariant, type NormalizedEntry, type NormalizedEntryType, type NormalizedToolCall, type RenderMetadataFunction, 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 };
|