@contractspec/module.ai-chat 4.1.5 → 4.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/README.md +29 -3
- package/dist/browser/core/index.js +53 -17
- package/dist/browser/index.js +982 -426
- package/dist/browser/presentation/components/index.js +975 -419
- package/dist/browser/presentation/hooks/index.js +8 -1
- package/dist/browser/presentation/index.js +983 -427
- package/dist/core/create-chat-route.d.ts +14 -3
- package/dist/core/index.js +53 -17
- package/dist/core/message-types.d.ts +4 -0
- package/dist/index.js +982 -426
- package/dist/node/core/index.js +53 -17
- package/dist/node/index.js +982 -426
- package/dist/node/presentation/components/index.js +975 -419
- package/dist/node/presentation/hooks/index.js +8 -1
- package/dist/node/presentation/index.js +983 -427
- package/dist/presentation/components/ChainOfThought.d.ts +30 -0
- package/dist/presentation/components/ChatInput.d.ts +3 -4
- package/dist/presentation/components/ChatMessage.d.ts +6 -4
- package/dist/presentation/components/ChatWithExport.d.ts +14 -1
- package/dist/presentation/components/ChatWithSidebar.d.ts +12 -1
- package/dist/presentation/components/Reasoning.d.ts +24 -0
- package/dist/presentation/components/Sources.d.ts +22 -0
- package/dist/presentation/components/Suggestion.d.ts +12 -0
- package/dist/presentation/components/ToolResultRenderer.d.ts +20 -3
- package/dist/presentation/components/component-types.d.ts +52 -0
- package/dist/presentation/components/index.d.ts +6 -1
- package/dist/presentation/components/index.js +975 -419
- package/dist/presentation/hooks/index.js +8 -1
- package/dist/presentation/index.js +983 -427
- package/package.json +13 -13
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type LucideIcon } from 'lucide-react';
|
|
3
|
+
export type ChainOfThoughtStepStatus = 'complete' | 'active' | 'pending';
|
|
4
|
+
export interface ChainOfThoughtProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function ChainOfThought({ children, open, defaultOpen, onOpenChange, className, }: ChainOfThoughtProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export interface ChainOfThoughtHeaderProps {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function ChainOfThoughtHeader({ children, className, }: ChainOfThoughtHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export interface ChainOfThoughtStepProps {
|
|
18
|
+
label: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
status?: ChainOfThoughtStepStatus;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function ChainOfThoughtStep({ label, description, status, icon: Icon, children, className, }: ChainOfThoughtStepProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export interface ChainOfThoughtContentProps {
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function ChainOfThoughtContent({ children, className, }: ChainOfThoughtContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,8 +14,7 @@ export interface ChatInputProps {
|
|
|
14
14
|
showAttachments?: boolean;
|
|
15
15
|
/** Max attachments allowed */
|
|
16
16
|
maxAttachments?: number;
|
|
17
|
+
/** Max file size in bytes (default 5MB). Files exceeding this are rejected. */
|
|
18
|
+
maxFileSizeBytes?: number;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
* Chat input component with attachment support
|
|
20
|
-
*/
|
|
21
|
-
export declare function ChatInput({ onSend, disabled, isLoading, placeholder, className, showAttachments, maxAttachments, }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function ChatInput({ onSend, disabled, isLoading, placeholder, className, showAttachments, maxAttachments, maxFileSizeBytes, }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ChatMessage as ChatMessageType } from '../../core/message-types';
|
|
3
|
+
import type { ChatMessageComponents } from './component-types';
|
|
3
4
|
export interface ChatMessageProps {
|
|
4
5
|
message: ChatMessageType;
|
|
5
6
|
className?: string;
|
|
@@ -21,8 +22,9 @@ export interface ChatMessageProps {
|
|
|
21
22
|
presentationRenderer?: (key: string, data?: unknown) => React.ReactNode;
|
|
22
23
|
/** Host-provided renderer for tool results with formKey */
|
|
23
24
|
formRenderer?: (key: string, defaultValues?: Record<string, unknown>) => React.ReactNode;
|
|
25
|
+
/** Host-provided renderer for tool results with dataViewKey */
|
|
26
|
+
dataViewRenderer?: (key: string, items?: unknown[]) => React.ReactNode;
|
|
27
|
+
/** Override components (e.g. from ai-elements) for Reasoning, Sources, ChainOfThought */
|
|
28
|
+
components?: ChatMessageComponents;
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
* Chat message component
|
|
27
|
-
*/
|
|
28
|
-
export declare function ChatMessage({ message, className, showCopy, showAvatar, selectable, selected, onSelect, editable, onEdit, presentationRenderer, formRenderer, }: ChatMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function ChatMessage({ message, className, showCopy, showAvatar, selectable, selected, onSelect, editable, onEdit, presentationRenderer, formRenderer, dataViewRenderer, components: comps, }: ChatMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ChatMessage as ChatMessageType, ChatConversation } from '../../core/message-types';
|
|
3
3
|
import type { ThinkingLevel } from '../../core/thinking-levels';
|
|
4
|
+
import type { ChatMessageComponents, SuggestionComponents } from './component-types';
|
|
4
5
|
export interface ChatWithExportProps {
|
|
5
6
|
messages: ChatMessageType[];
|
|
6
7
|
conversation?: ChatConversation | null;
|
|
@@ -26,9 +27,21 @@ export interface ChatWithExportProps {
|
|
|
26
27
|
presentationRenderer?: (key: string, data?: unknown) => React.ReactNode;
|
|
27
28
|
/** Host-provided renderer for tool results with formKey */
|
|
28
29
|
formRenderer?: (key: string, defaultValues?: Record<string, unknown>) => React.ReactNode;
|
|
30
|
+
/** Host-provided renderer for tool results with dataViewKey */
|
|
31
|
+
dataViewRenderer?: (key: string, items?: unknown[]) => React.ReactNode;
|
|
32
|
+
/** Override components for ChatMessage (Reasoning, Sources, ChainOfThought) */
|
|
33
|
+
components?: ChatMessageComponents;
|
|
34
|
+
/** Clickable suggestion chips (e.g. empty state) */
|
|
35
|
+
suggestions?: string[];
|
|
36
|
+
/** Called when a suggestion is clicked */
|
|
37
|
+
onSuggestionClick?: (suggestion: string) => void;
|
|
38
|
+
/** Override Suggestion components */
|
|
39
|
+
suggestionComponents?: SuggestionComponents;
|
|
40
|
+
/** Show suggestions when no messages (default true when suggestions provided) */
|
|
41
|
+
showSuggestionsWhenEmpty?: boolean;
|
|
29
42
|
}
|
|
30
43
|
/**
|
|
31
44
|
* Chat container with export and message selection.
|
|
32
45
|
* Composes ChatContainer, ChatExportToolbar, and useMessageSelection.
|
|
33
46
|
*/
|
|
34
|
-
export declare function ChatWithExport({ messages, conversation, children, className, showExport, showMessageSelection, showScrollButton, onCreateNew, onFork, onEditMessage, thinkingLevel, onThinkingLevelChange, presentationRenderer, formRenderer, }: ChatWithExportProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare function ChatWithExport({ messages, conversation, children, className, showExport, showMessageSelection, showScrollButton, onCreateNew, onFork, onEditMessage, thinkingLevel, onThinkingLevelChange, presentationRenderer, formRenderer, dataViewRenderer, components, suggestions, onSuggestionClick, suggestionComponents: suggestionComps, showSuggestionsWhenEmpty, }: ChatWithExportProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ConversationStore } from '../../core/conversation-store';
|
|
3
3
|
import type { UseChatOptions } from '../hooks/useChat';
|
|
4
|
+
import type { ChatMessageComponents, SuggestionComponents } from './component-types';
|
|
4
5
|
export interface ChatWithSidebarProps extends Omit<UseChatOptions, 'store' | 'conversationId'> {
|
|
5
6
|
/** Optional store (defaults to LocalStorage) */
|
|
6
7
|
store?: ConversationStore;
|
|
@@ -11,9 +12,19 @@ export interface ChatWithSidebarProps extends Omit<UseChatOptions, 'store' | 'co
|
|
|
11
12
|
presentationRenderer?: (key: string, data?: unknown) => React.ReactNode;
|
|
12
13
|
/** Host-provided renderer for tool results with formKey */
|
|
13
14
|
formRenderer?: (key: string, defaultValues?: Record<string, unknown>) => React.ReactNode;
|
|
15
|
+
/** Host-provided renderer for tool results with dataViewKey */
|
|
16
|
+
dataViewRenderer?: (key: string, items?: unknown[]) => React.ReactNode;
|
|
17
|
+
/** Override components for ChatMessage */
|
|
18
|
+
components?: ChatMessageComponents;
|
|
19
|
+
/** Clickable suggestion chips */
|
|
20
|
+
suggestions?: string[];
|
|
21
|
+
/** Override Suggestion components */
|
|
22
|
+
suggestionComponents?: SuggestionComponents;
|
|
23
|
+
/** Show suggestions when chat has messages (default false) */
|
|
24
|
+
showSuggestionsWhenEmpty?: boolean;
|
|
14
25
|
}
|
|
15
26
|
/**
|
|
16
27
|
* Full chat layout with sidebar (conversation history) and main chat area.
|
|
17
28
|
* Uses a shared store for persistence.
|
|
18
29
|
*/
|
|
19
|
-
export declare function ChatWithSidebar({ store, projectId, tags, className, thinkingLevel: initialThinkingLevel, presentationRenderer, formRenderer, ...useChatOptions }: ChatWithSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function ChatWithSidebar({ store, projectId, tags, className, thinkingLevel: initialThinkingLevel, presentationRenderer, formRenderer, dataViewRenderer, components, suggestions, suggestionComponents, showSuggestionsWhenEmpty, ...useChatOptions }: ChatWithSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ReasoningProps {
|
|
3
|
+
isStreaming?: boolean;
|
|
4
|
+
open?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Collapsible reasoning display. Auto-opens during streaming, closes when done.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Reasoning({ isStreaming, open, defaultOpen, onOpenChange, children, className, }: ReasoningProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export interface ReasoningTriggerProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
isStreaming?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function ReasoningTrigger({ children, isStreaming, className, }: ReasoningTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export interface ReasoningContentProps {
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function ReasoningContent({ children, className, }: ReasoningContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SourcesProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function Sources({ children, className }: SourcesProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export interface SourcesTriggerProps {
|
|
8
|
+
count: number;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function SourcesTrigger({ count, children, className, }: SourcesTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export interface SourcesContentProps {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function SourcesContent({ children, className }: SourcesContentProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export interface SourceProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
19
|
+
href: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function Source({ href, title, className, children, ...props }: SourceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SuggestionsProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function Suggestions({ children, className }: SuggestionsProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export interface SuggestionProps {
|
|
8
|
+
suggestion: string;
|
|
9
|
+
onClick?: (suggestion: string) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Suggestion({ suggestion, onClick, className, }: SuggestionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/** UIMessage-like shape (subagent output with parts) */
|
|
3
|
+
export interface UIMessageLike {
|
|
4
|
+
parts?: unknown[];
|
|
5
|
+
}
|
|
6
|
+
/** Type guard for UIMessage-like (nested subagent output) */
|
|
7
|
+
export declare function isUIMessageLike(result: unknown): result is UIMessageLike;
|
|
2
8
|
/** Tool result shape for presentation rendering */
|
|
3
9
|
export interface PresentationToolResult {
|
|
4
10
|
presentationKey: string;
|
|
@@ -9,10 +15,17 @@ export interface FormToolResult {
|
|
|
9
15
|
formKey: string;
|
|
10
16
|
defaultValues?: Record<string, unknown>;
|
|
11
17
|
}
|
|
18
|
+
/** Tool result shape for data view rendering */
|
|
19
|
+
export interface DataViewToolResult {
|
|
20
|
+
dataViewKey: string;
|
|
21
|
+
items?: unknown[];
|
|
22
|
+
}
|
|
12
23
|
/** Type guard for presentation tool result */
|
|
13
24
|
export declare function isPresentationToolResult(result: unknown): result is PresentationToolResult;
|
|
14
25
|
/** Type guard for form tool result */
|
|
15
26
|
export declare function isFormToolResult(result: unknown): result is FormToolResult;
|
|
27
|
+
/** Type guard for data view tool result */
|
|
28
|
+
export declare function isDataViewToolResult(result: unknown): result is DataViewToolResult;
|
|
16
29
|
export interface ToolResultRendererProps {
|
|
17
30
|
/** Tool name */
|
|
18
31
|
toolName: string;
|
|
@@ -22,12 +35,16 @@ export interface ToolResultRendererProps {
|
|
|
22
35
|
presentationRenderer?: (key: string, data?: unknown) => React.ReactNode;
|
|
23
36
|
/** Host-provided form renderer */
|
|
24
37
|
formRenderer?: (key: string, defaultValues?: Record<string, unknown>) => React.ReactNode;
|
|
38
|
+
/** Host-provided data view renderer */
|
|
39
|
+
dataViewRenderer?: (key: string, items?: unknown[]) => React.ReactNode;
|
|
25
40
|
/** Fallback: render raw JSON when no custom renderer */
|
|
26
41
|
showRawFallback?: boolean;
|
|
42
|
+
/** Render nested UIMessage (subagent output) recursively */
|
|
43
|
+
renderNestedUIMessage?: boolean;
|
|
27
44
|
}
|
|
28
45
|
/**
|
|
29
|
-
* Renders tool results with optional host-driven presentation or
|
|
30
|
-
* When result has presentationKey/formKey and host provides a renderer, uses it.
|
|
46
|
+
* Renders tool results with optional host-driven presentation, form, or data view components.
|
|
47
|
+
* When result has presentationKey/formKey/dataViewKey and host provides a renderer, uses it.
|
|
31
48
|
* Otherwise falls back to raw JSON display.
|
|
32
49
|
*/
|
|
33
|
-
export declare function ToolResultRenderer({ toolName, result, presentationRenderer, formRenderer, showRawFallback, }: ToolResultRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
50
|
+
export declare function ToolResultRenderer({ toolName: _toolName, result, presentationRenderer, formRenderer, dataViewRenderer, showRawFallback, renderNestedUIMessage, }: ToolResultRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component override types for AI Elements-style UX.
|
|
3
|
+
* Hosts with ai-elements can pass enhanced components; otherwise native implementations are used.
|
|
4
|
+
*/
|
|
5
|
+
import type * as React from 'react';
|
|
6
|
+
export interface ReasoningComponentProps {
|
|
7
|
+
isStreaming?: boolean;
|
|
8
|
+
open?: boolean;
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface ChatMessageComponents {
|
|
14
|
+
Reasoning?: React.ComponentType<ReasoningComponentProps>;
|
|
15
|
+
ReasoningTrigger?: React.ComponentType<{
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}>;
|
|
18
|
+
ReasoningContent?: React.ComponentType<{
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
Sources?: React.ComponentType<{
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
SourcesTrigger?: React.ComponentType<{
|
|
25
|
+
count: number;
|
|
26
|
+
}>;
|
|
27
|
+
Source?: React.ComponentType<{
|
|
28
|
+
href: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
} & React.AnchorHTMLAttributes<HTMLAnchorElement>>;
|
|
31
|
+
ChainOfThought?: React.ComponentType<{
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
open?: boolean;
|
|
34
|
+
defaultOpen?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
}>;
|
|
37
|
+
ChainOfThoughtStep?: React.ComponentType<{
|
|
38
|
+
label: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
status?: 'complete' | 'active' | 'pending';
|
|
41
|
+
children?: React.ReactNode;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export interface SuggestionComponents {
|
|
45
|
+
Suggestions?: React.ComponentType<{
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
}>;
|
|
48
|
+
Suggestion?: React.ComponentType<{
|
|
49
|
+
suggestion: string;
|
|
50
|
+
onClick?: (suggestion: string) => void;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
@@ -12,4 +12,9 @@ export { ModelPicker } from './ModelPicker';
|
|
|
12
12
|
export { ThinkingLevelPicker } from './ThinkingLevelPicker';
|
|
13
13
|
export { ContextIndicator } from './ContextIndicator';
|
|
14
14
|
export { CodePreview } from './CodePreview';
|
|
15
|
-
export {
|
|
15
|
+
export { Reasoning, ReasoningTrigger, ReasoningContent } from './Reasoning';
|
|
16
|
+
export { Sources, SourcesTrigger, SourcesContent, Source } from './Sources';
|
|
17
|
+
export { Suggestions, Suggestion } from './Suggestion';
|
|
18
|
+
export { ChainOfThought, ChainOfThoughtHeader, ChainOfThoughtStep, ChainOfThoughtContent, } from './ChainOfThought';
|
|
19
|
+
export type { ChatMessageComponents, SuggestionComponents, } from './component-types';
|
|
20
|
+
export { ToolResultRenderer, isPresentationToolResult, isFormToolResult, isDataViewToolResult, type PresentationToolResult, type FormToolResult, type DataViewToolResult, } from './ToolResultRenderer';
|