teodor-new-chat-ui 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chat/ChatProvider.d.ts +3 -1
- package/dist/components/chat/ChatWidget.d.ts +20 -0
- package/dist/components/chat/index.d.ts +5 -0
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/hooks/useChatMessages.d.ts +65 -0
- package/dist/hooks/useStreamMonitor.d.ts +75 -0
- package/dist/index.esm.js +2225 -1834
- package/dist/index.umd.js +5 -5
- package/dist/lib/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -53,7 +53,9 @@ interface ChatProviderProps {
|
|
|
53
53
|
children: React.ReactNode;
|
|
54
54
|
apiBaseUrl?: string;
|
|
55
55
|
enableUrlSync?: boolean;
|
|
56
|
+
getAuthHeaders?: () => Record<string, string>;
|
|
57
|
+
authToken?: string;
|
|
56
58
|
}
|
|
57
|
-
export declare function ChatProvider({ children, apiBaseUrl, enableUrlSync }: ChatProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export declare function ChatProvider({ children, apiBaseUrl, enableUrlSync, getAuthHeaders, authToken }: ChatProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
58
60
|
export declare function useChat(): ChatState & ChatActions;
|
|
59
61
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface ChatWidgetProps {
|
|
2
|
+
apiBaseUrl?: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
getAuthHeaders?: () => Record<string, string>;
|
|
7
|
+
authToken?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
theme?: 'light' | 'dark';
|
|
12
|
+
enableUrlSync?: boolean;
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
showThreadHistory?: boolean;
|
|
15
|
+
onMessageSent?: (message: string) => void;
|
|
16
|
+
onThreadChanged?: (threadId: string) => void;
|
|
17
|
+
onToggle?: (isOpen: boolean) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function ChatWidget({ apiBaseUrl, title, subtitle, placeholder, getAuthHeaders, authToken, className, position, size, theme, enableUrlSync, defaultOpen, showThreadHistory, onMessageSent, onThreadChanged, onToggle }: ChatWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -3,4 +3,9 @@ export { ChatProvider, useChat } from './ChatProvider';
|
|
|
3
3
|
export { ThreadManager } from './ThreadManager';
|
|
4
4
|
export { ChatInterface } from './ChatInterface';
|
|
5
5
|
export { MessageComponent } from './MessageComponent';
|
|
6
|
+
export { ChatWidget } from './ChatWidget';
|
|
7
|
+
export { useChatMessages, useToolMessages, useChatActions } from '../../hooks/useChatMessages';
|
|
8
|
+
export { useStreamMonitor, useToolExtractor, useSearchResults, useFileContents, useCodeExecution } from '../../hooks/useStreamMonitor';
|
|
6
9
|
export type { Message, Thread, Branch } from './ChatProvider';
|
|
10
|
+
export type { ToolMessage, ProcessedToolMessage } from '../../hooks/useChatMessages';
|
|
11
|
+
export type { StreamEvent, StreamState } from '../../hooks/useStreamMonitor';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ResizablePrimitive from "react-resizable-panels";
|
|
2
2
|
declare const ResizablePanelGroup: ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
declare const ResizablePanel: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLButtonElement | HTMLElement | HTMLTextAreaElement | HTMLDivElement | HTMLSpanElement | HTMLFormElement | HTMLInputElement |
|
|
3
|
+
declare const ResizablePanel: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLButtonElement | HTMLElement | HTMLTextAreaElement | HTMLDivElement | HTMLSpanElement | HTMLFormElement | HTMLInputElement | HTMLHeadingElement | HTMLParagraphElement | HTMLLabelElement | HTMLObjectElement | HTMLProgressElement | HTMLSelectElement | HTMLMapElement | HTMLLinkElement | HTMLSlotElement | HTMLStyleElement | HTMLTitleElement | HTMLDialogElement | HTMLImageElement | HTMLOptionElement | HTMLTableElement | HTMLOutputElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLLegendElement | HTMLLIElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLPreElement | HTMLScriptElement | HTMLSourceElement | HTMLTemplateElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTimeElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement | HTMLTableCaptionElement | HTMLMenuElement | HTMLPictureElement>, "id" | "onResize"> & {
|
|
4
4
|
className?: string | undefined;
|
|
5
5
|
collapsedSize?: number | undefined;
|
|
6
6
|
collapsible?: boolean | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Message } from '../components/chat/ChatProvider';
|
|
2
|
+
export interface ToolMessage extends Message {
|
|
3
|
+
role: 'tool';
|
|
4
|
+
name: string;
|
|
5
|
+
tool_call_id: string;
|
|
6
|
+
args: any;
|
|
7
|
+
content: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ProcessedToolMessage {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
tool_call_id: string;
|
|
13
|
+
args: any;
|
|
14
|
+
content: any;
|
|
15
|
+
timestamp?: string;
|
|
16
|
+
textContent: string;
|
|
17
|
+
jsonContent: any;
|
|
18
|
+
isJson: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook to easily extract and work with chat messages
|
|
22
|
+
*/
|
|
23
|
+
export declare function useChatMessages(): {
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
error: string;
|
|
26
|
+
refresh: () => Promise<void>;
|
|
27
|
+
all: Message[];
|
|
28
|
+
human: Message[];
|
|
29
|
+
ai: Message[];
|
|
30
|
+
tool: ToolMessage[];
|
|
31
|
+
latest: Message;
|
|
32
|
+
latestHuman: Message;
|
|
33
|
+
latestAI: Message;
|
|
34
|
+
latestTool: ToolMessage | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Hook specifically for working with tool messages and their content
|
|
38
|
+
*/
|
|
39
|
+
export declare function useToolMessages(): {
|
|
40
|
+
all: ProcessedToolMessage[];
|
|
41
|
+
raw: ToolMessage[];
|
|
42
|
+
byToolName: Record<string, ProcessedToolMessage[]>;
|
|
43
|
+
toolNames: string[];
|
|
44
|
+
getLatestByTool: (toolName: string) => ProcessedToolMessage | undefined;
|
|
45
|
+
getContentByTool: (toolName: string) => any[];
|
|
46
|
+
getAllContent: () => any[];
|
|
47
|
+
latest: ProcessedToolMessage;
|
|
48
|
+
count: number;
|
|
49
|
+
hasToolMessages: boolean;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Hook for managing chat state and actions with simplified API
|
|
53
|
+
*/
|
|
54
|
+
export declare function useChatActions(): {
|
|
55
|
+
currentThread: string;
|
|
56
|
+
isLoading: boolean;
|
|
57
|
+
error: string;
|
|
58
|
+
sendMessage: (content: string) => Promise<void>;
|
|
59
|
+
createThread: () => Promise<string>;
|
|
60
|
+
selectThread: (threadId: string | null) => void;
|
|
61
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
62
|
+
clearError: () => void;
|
|
63
|
+
stop: () => void;
|
|
64
|
+
refresh: () => Promise<void>;
|
|
65
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ProcessedToolMessage } from './useChatMessages';
|
|
2
|
+
export interface StreamEvent {
|
|
3
|
+
type: 'message' | 'tool' | 'error' | 'complete';
|
|
4
|
+
data: any;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
7
|
+
export interface StreamState {
|
|
8
|
+
isStreaming: boolean;
|
|
9
|
+
events: StreamEvent[];
|
|
10
|
+
latestEvent: StreamEvent | null;
|
|
11
|
+
error: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook for real-time stream monitoring and tool message extraction
|
|
15
|
+
*/
|
|
16
|
+
export declare function useStreamMonitor(): {
|
|
17
|
+
getEventsByType: (type: StreamEvent["type"]) => StreamEvent[];
|
|
18
|
+
getLatestEventByType: (type: StreamEvent["type"]) => StreamEvent;
|
|
19
|
+
getToolEvents: () => (StreamEvent & {
|
|
20
|
+
data: ProcessedToolMessage;
|
|
21
|
+
})[];
|
|
22
|
+
clearEvents: () => void;
|
|
23
|
+
messageEvents: StreamEvent[];
|
|
24
|
+
toolEvents: (StreamEvent & {
|
|
25
|
+
data: ProcessedToolMessage;
|
|
26
|
+
})[];
|
|
27
|
+
latestToolEvent: StreamEvent;
|
|
28
|
+
hasNewEvents: boolean;
|
|
29
|
+
isStreaming: boolean;
|
|
30
|
+
events: StreamEvent[];
|
|
31
|
+
latestEvent: StreamEvent | null;
|
|
32
|
+
error: string | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Hook for extracting specific tool data with real-time updates
|
|
36
|
+
*/
|
|
37
|
+
export declare function useToolExtractor<T = any>(toolName: string, parser?: (content: any) => T): {
|
|
38
|
+
data: T[];
|
|
39
|
+
latest: T;
|
|
40
|
+
count: number;
|
|
41
|
+
hasData: boolean;
|
|
42
|
+
hasNewData: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Preset extractors for common tool patterns
|
|
46
|
+
*/
|
|
47
|
+
export declare const useSearchResults: (toolName?: string) => {
|
|
48
|
+
data: any[];
|
|
49
|
+
latest: any;
|
|
50
|
+
count: number;
|
|
51
|
+
hasData: boolean;
|
|
52
|
+
hasNewData: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare const useFileContents: (toolName?: string) => {
|
|
55
|
+
data: any[];
|
|
56
|
+
latest: any;
|
|
57
|
+
count: number;
|
|
58
|
+
hasData: boolean;
|
|
59
|
+
hasNewData: boolean;
|
|
60
|
+
};
|
|
61
|
+
export declare const useCodeExecution: (toolName?: string) => {
|
|
62
|
+
data: {
|
|
63
|
+
output: any;
|
|
64
|
+
error: any;
|
|
65
|
+
exitCode: any;
|
|
66
|
+
}[];
|
|
67
|
+
latest: {
|
|
68
|
+
output: any;
|
|
69
|
+
error: any;
|
|
70
|
+
exitCode: any;
|
|
71
|
+
};
|
|
72
|
+
count: number;
|
|
73
|
+
hasData: boolean;
|
|
74
|
+
hasNewData: boolean;
|
|
75
|
+
};
|