@xto/chat 1.0.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.
@@ -0,0 +1 @@
1
+ export { default as ChatContainer } from './index.vue';
@@ -0,0 +1,45 @@
1
+ import { Message } from '../types';
2
+ export interface ChatContainerProps {
3
+ messages?: Message[];
4
+ loading?: boolean;
5
+ readonly?: boolean;
6
+ showAvatar?: boolean;
7
+ showTimestamp?: boolean;
8
+ showFeedback?: boolean;
9
+ suggestedQuestions?: string[];
10
+ placeholder?: string;
11
+ maxLength?: number;
12
+ enableFileUpload?: boolean;
13
+ }
14
+ declare const _default: import('vue').DefineComponent<ChatContainerProps, {
15
+ clearMessages: () => void;
16
+ scrollToBottom: () => void;
17
+ appendMessage: (msg: Message) => void;
18
+ updateLastMessage: (msg: Message) => void;
19
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
20
+ stop: () => any;
21
+ feedback: (messageId: string, rating: "like" | "dislike") => any;
22
+ send: (content: string, attachments?: File[] | undefined) => any;
23
+ regenerate: () => any;
24
+ selectQuestion: (question: string) => any;
25
+ }, string, import('vue').PublicProps, Readonly<ChatContainerProps> & Readonly<{
26
+ onStop?: (() => any) | undefined;
27
+ onFeedback?: ((messageId: string, rating: "like" | "dislike") => any) | undefined;
28
+ onSend?: ((content: string, attachments?: File[] | undefined) => any) | undefined;
29
+ onRegenerate?: (() => any) | undefined;
30
+ onSelectQuestion?: ((question: string) => any) | undefined;
31
+ }>, {
32
+ showAvatar: boolean;
33
+ showTimestamp: boolean;
34
+ showFeedback: boolean;
35
+ placeholder: string;
36
+ messages: Message[];
37
+ loading: boolean;
38
+ maxLength: number;
39
+ enableFileUpload: boolean;
40
+ readonly: boolean;
41
+ suggestedQuestions: string[];
42
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
43
+ containerRef: HTMLDivElement;
44
+ }, HTMLDivElement>;
45
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import { Message } from '../types';
2
+ export { default as ChatContainer } from './index.vue';
3
+ export interface ChatContainerProps {
4
+ messages?: Message[];
5
+ loading?: boolean;
6
+ readonly?: boolean;
7
+ showAvatar?: boolean;
8
+ showTimestamp?: boolean;
9
+ showFeedback?: boolean;
10
+ suggestedQuestions?: string[];
11
+ placeholder?: string;
12
+ maxLength?: number;
13
+ enableFileUpload?: boolean;
14
+ }
15
+ export interface ChatContainerEmits {
16
+ 'send': [content: string, attachments?: File[]];
17
+ 'stop': [];
18
+ 'regenerate': [];
19
+ 'feedback': [messageId: string, rating: 'like' | 'dislike'];
20
+ 'selectQuestion': [question: string];
21
+ }
22
+ export interface ChatContainerExpose {
23
+ clearMessages: () => void;
24
+ scrollToBottom: () => void;
25
+ appendMessage: (msg: Message) => void;
26
+ updateLastMessage: (msg: Message) => void;
27
+ }
@@ -0,0 +1 @@
1
+ export { default as CodeBlock } from './index.vue';
@@ -0,0 +1,10 @@
1
+ export interface CodeBlockProps {
2
+ code: string;
3
+ language?: string;
4
+ showCopy?: boolean;
5
+ }
6
+ declare const _default: import('vue').DefineComponent<CodeBlockProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CodeBlockProps> & Readonly<{}>, {
7
+ language: string;
8
+ showCopy: boolean;
9
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
10
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as FeedbackButtons } from './index.vue';
@@ -0,0 +1,11 @@
1
+ export interface FeedbackButtonsProps {
2
+ current?: 'like' | 'dislike' | null;
3
+ }
4
+ declare const _default: import('vue').DefineComponent<FeedbackButtonsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
5
+ feedback: (rating: "like" | "dislike") => any;
6
+ }, string, import('vue').PublicProps, Readonly<FeedbackButtonsProps> & Readonly<{
7
+ onFeedback?: ((rating: "like" | "dislike") => any) | undefined;
8
+ }>, {
9
+ current: "like" | "dislike" | null;
10
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
11
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as FileUpload } from './index.vue';
@@ -0,0 +1,42 @@
1
+ export interface FileUploadProps {
2
+ accept?: string;
3
+ multiple?: boolean;
4
+ maxSize?: number;
5
+ }
6
+ declare const _default: import('vue').DefineComponent<FileUploadProps, {
7
+ files: import('vue').Ref<{
8
+ readonly lastModified: number;
9
+ readonly name: string;
10
+ readonly webkitRelativePath: string;
11
+ readonly size: number;
12
+ readonly type: string;
13
+ arrayBuffer: () => Promise<ArrayBuffer>;
14
+ bytes: () => Promise<Uint8Array<ArrayBuffer>>;
15
+ slice: (start?: number, end?: number, contentType?: string) => Blob;
16
+ stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
17
+ text: () => Promise<string>;
18
+ }[], File[] | {
19
+ readonly lastModified: number;
20
+ readonly name: string;
21
+ readonly webkitRelativePath: string;
22
+ readonly size: number;
23
+ readonly type: string;
24
+ arrayBuffer: () => Promise<ArrayBuffer>;
25
+ bytes: () => Promise<Uint8Array<ArrayBuffer>>;
26
+ slice: (start?: number, end?: number, contentType?: string) => Blob;
27
+ stream: () => ReadableStream<Uint8Array<ArrayBuffer>>;
28
+ text: () => Promise<string>;
29
+ }[]>;
30
+ clear: () => void;
31
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
32
+ change: (files: File[]) => any;
33
+ exceed: (file: File) => any;
34
+ }, string, import('vue').PublicProps, Readonly<FileUploadProps> & Readonly<{
35
+ onChange?: ((files: File[]) => any) | undefined;
36
+ onExceed?: ((file: File) => any) | undefined;
37
+ }>, {
38
+ multiple: boolean;
39
+ accept: string;
40
+ maxSize: number;
41
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
42
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as MarkdownRenderer } from './index.vue';
@@ -0,0 +1,9 @@
1
+ export interface MarkdownRendererProps {
2
+ content: string;
3
+ enableHighlight?: boolean;
4
+ }
5
+ declare const _default: import('vue').DefineComponent<MarkdownRendererProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MarkdownRendererProps> & Readonly<{}>, {
6
+ content: string;
7
+ enableHighlight: boolean;
8
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
9
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as MessageInput } from './index.vue';
@@ -0,0 +1,25 @@
1
+ export interface MessageInputProps {
2
+ placeholder?: string;
3
+ maxLength?: number;
4
+ disabled?: boolean;
5
+ loading?: boolean;
6
+ enableFileUpload?: boolean;
7
+ }
8
+ declare const _default: import('vue').DefineComponent<MessageInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ stop: () => any;
10
+ send: (content: string, attachments?: File[] | undefined) => any;
11
+ regenerate: () => any;
12
+ }, string, import('vue').PublicProps, Readonly<MessageInputProps> & Readonly<{
13
+ onStop?: (() => any) | undefined;
14
+ onSend?: ((content: string, attachments?: File[] | undefined) => any) | undefined;
15
+ onRegenerate?: (() => any) | undefined;
16
+ }>, {
17
+ placeholder: string;
18
+ loading: boolean;
19
+ maxLength: number;
20
+ disabled: boolean;
21
+ enableFileUpload: boolean;
22
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
23
+ textareaRef: HTMLTextAreaElement;
24
+ }, HTMLDivElement>;
25
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as MessageItem } from './index.vue';
@@ -0,0 +1,17 @@
1
+ import { Message } from '../types';
2
+ export interface MessageItemProps {
3
+ message: Message;
4
+ showAvatar?: boolean;
5
+ showTimestamp?: boolean;
6
+ showFeedback?: boolean;
7
+ }
8
+ declare const _default: import('vue').DefineComponent<MessageItemProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ feedback: (messageId: string, rating: "like" | "dislike") => any;
10
+ }, string, import('vue').PublicProps, Readonly<MessageItemProps> & Readonly<{
11
+ onFeedback?: ((messageId: string, rating: "like" | "dislike") => any) | undefined;
12
+ }>, {
13
+ showAvatar: boolean;
14
+ showTimestamp: boolean;
15
+ showFeedback: boolean;
16
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
17
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as MessageList } from './index.vue';
@@ -0,0 +1,20 @@
1
+ import { Message } from '../types';
2
+ export interface MessageListProps {
3
+ messages?: Message[];
4
+ loading?: boolean;
5
+ showAvatar?: boolean;
6
+ showTimestamp?: boolean;
7
+ showFeedback?: boolean;
8
+ }
9
+ declare const _default: import('vue').DefineComponent<MessageListProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
10
+ feedback: (messageId: string, rating: "like" | "dislike") => any;
11
+ }, string, import('vue').PublicProps, Readonly<MessageListProps> & Readonly<{
12
+ onFeedback?: ((messageId: string, rating: "like" | "dislike") => any) | undefined;
13
+ }>, {
14
+ showAvatar: boolean;
15
+ showTimestamp: boolean;
16
+ showFeedback: boolean;
17
+ messages: Message[];
18
+ loading: boolean;
19
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
20
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as SuggestedQuestions } from './index.vue';
@@ -0,0 +1,11 @@
1
+ export interface SuggestedQuestionsProps {
2
+ questions?: string[];
3
+ }
4
+ declare const _default: import('vue').DefineComponent<SuggestedQuestionsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
5
+ select: (question: string) => any;
6
+ }, string, import('vue').PublicProps, Readonly<SuggestedQuestionsProps> & Readonly<{
7
+ onSelect?: ((question: string) => any) | undefined;
8
+ }>, {
9
+ questions: string[];
10
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
11
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as ThinkingChain } from './index.vue';
@@ -0,0 +1,10 @@
1
+ import { ThinkingStep } from '../types';
2
+ export interface ThinkingChainProps {
3
+ steps?: ThinkingStep[];
4
+ collapsed?: boolean;
5
+ }
6
+ declare const _default: import('vue').DefineComponent<ThinkingChainProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ThinkingChainProps> & Readonly<{}>, {
7
+ steps: ThinkingStep[];
8
+ collapsed: boolean;
9
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
10
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as ToolCallDisplay } from './index.vue';
@@ -0,0 +1,8 @@
1
+ import { ToolCall } from '../types';
2
+ export interface ToolCallDisplayProps {
3
+ toolCalls?: ToolCall[];
4
+ }
5
+ declare const _default: import('vue').DefineComponent<ToolCallDisplayProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ToolCallDisplayProps> & Readonly<{}>, {
6
+ toolCalls: ToolCall[];
7
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
8
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * 自动滚动组合式函数。
4
+ *
5
+ * 用户向上滚动时暂停自动滚动,滚动到底部时恢复。
6
+ */
7
+ export declare function useAutoScroll(containerRef: Ref<HTMLElement | null>): {
8
+ autoScroll: Ref<boolean, boolean>;
9
+ scrollToBottom: () => void;
10
+ enableAutoScroll: () => void;
11
+ };
@@ -0,0 +1,83 @@
1
+ import { Message, ChatEvent } from '../types';
2
+ /**
3
+ * 对话管理组合式函数。
4
+ *
5
+ * 使用方注入 sendMessage 函数实现消息发送。
6
+ */
7
+ export declare function useChat(options?: {
8
+ sendMessage?: (message: string) => Promise<Message> | ReadableStream<Message>;
9
+ onEvent?: (event: ChatEvent) => void;
10
+ }): {
11
+ messages: import('vue').Ref<{
12
+ id?: string | undefined;
13
+ role: import('..').MessageRole;
14
+ content: string;
15
+ status?: import('..').MessageStatus | undefined;
16
+ thinkingChain?: {
17
+ thought?: string | undefined;
18
+ action?: string | undefined;
19
+ actionInput?: string | undefined;
20
+ observation?: string | undefined;
21
+ timestamp?: number | undefined;
22
+ }[] | undefined;
23
+ toolCalls?: {
24
+ id?: string | undefined;
25
+ name: string;
26
+ arguments?: Record<string, unknown> | undefined;
27
+ result?: unknown;
28
+ elapsedMs?: number | undefined;
29
+ success?: boolean | undefined;
30
+ errorMessage?: string | undefined;
31
+ }[] | undefined;
32
+ tokenUsage?: number | undefined;
33
+ latency?: number | undefined;
34
+ attachments?: {
35
+ referenceId: string;
36
+ fileName: string;
37
+ mimeType: string;
38
+ size: number;
39
+ }[] | undefined;
40
+ feedback?: "like" | "dislike" | null | undefined;
41
+ timestamp?: number | undefined;
42
+ toolCallId?: string | undefined;
43
+ toolName?: string | undefined;
44
+ }[], Message[] | {
45
+ id?: string | undefined;
46
+ role: import('..').MessageRole;
47
+ content: string;
48
+ status?: import('..').MessageStatus | undefined;
49
+ thinkingChain?: {
50
+ thought?: string | undefined;
51
+ action?: string | undefined;
52
+ actionInput?: string | undefined;
53
+ observation?: string | undefined;
54
+ timestamp?: number | undefined;
55
+ }[] | undefined;
56
+ toolCalls?: {
57
+ id?: string | undefined;
58
+ name: string;
59
+ arguments?: Record<string, unknown> | undefined;
60
+ result?: unknown;
61
+ elapsedMs?: number | undefined;
62
+ success?: boolean | undefined;
63
+ errorMessage?: string | undefined;
64
+ }[] | undefined;
65
+ tokenUsage?: number | undefined;
66
+ latency?: number | undefined;
67
+ attachments?: {
68
+ referenceId: string;
69
+ fileName: string;
70
+ mimeType: string;
71
+ size: number;
72
+ }[] | undefined;
73
+ feedback?: "like" | "dislike" | null | undefined;
74
+ timestamp?: number | undefined;
75
+ toolCallId?: string | undefined;
76
+ toolName?: string | undefined;
77
+ }[]>;
78
+ loading: import('vue').Ref<boolean, boolean>;
79
+ error: import('vue').Ref<string | null, string | null>;
80
+ send: (content: string) => Promise<void>;
81
+ stop: () => void;
82
+ clear: () => void;
83
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SSE 流式输出组合式函数。
3
+ */
4
+ export declare function useSSE(): {
5
+ isConnected: import('vue').Ref<boolean, boolean>;
6
+ connect: (url: string, onMessage: (data: string) => void, onError?: (err: Event) => void) => void;
7
+ disconnect: () => void;
8
+ };
9
+ /**
10
+ * 通过 fetch + ReadableStream 接收 SSE 数据(更灵活)。
11
+ */
12
+ export declare function streamSSE(url: string, options?: RequestInit): AsyncGenerator<string>;
package/es/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { App } from 'vue';
2
+ import { default as ChatContainer } from './ChatContainer/index.vue';
3
+ import { default as MessageList } from './MessageList/index.vue';
4
+ import { default as MessageItem } from './MessageItem/index.vue';
5
+ import { default as MessageInput } from './MessageInput/index.vue';
6
+ import { default as ThinkingChain } from './ThinkingChain/index.vue';
7
+ import { default as ToolCallDisplay } from './ToolCallDisplay/index.vue';
8
+ import { default as MarkdownRenderer } from './MarkdownRenderer/index.vue';
9
+ import { default as CodeBlock } from './CodeBlock/index.vue';
10
+ import { default as SuggestedQuestions } from './SuggestedQuestions/index.vue';
11
+ import { default as FileUpload } from './FileUpload/index.vue';
12
+ import { default as FeedbackButtons } from './FeedbackButtons/index.vue';
13
+ export { ChatContainer, MessageList, MessageItem, MessageInput, ThinkingChain, ToolCallDisplay, MarkdownRenderer, CodeBlock, SuggestedQuestions, FileUpload, FeedbackButtons };
14
+ export type { ChatContainerProps, ChatContainerEmits, ChatContainerExpose } from './ChatContainer/types';
15
+ export { useChat } from './composables/useChat';
16
+ export { useSSE } from './composables/useSSE';
17
+ export { useAutoScroll } from './composables/useAutoScroll';
18
+ export type { Message, ChatSession, ChatEvent, ToolCall, ThinkingStep, MessageRole, MessageStatus } from './types';
19
+ declare const _default: {
20
+ install(app: App): void;
21
+ };
22
+ export default _default;