@huyooo/ai-chat-frontend-react 0.2.44 → 0.3.4
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/adapter.d.ts +58 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/components/ChatPanel.d.ts +71 -0
- package/dist/components/ChatPanel.d.ts.map +1 -0
- package/dist/components/common/ConfirmDialog.d.ts +27 -0
- package/dist/components/common/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/common/CopyButton.d.ts +15 -0
- package/dist/components/common/CopyButton.d.ts.map +1 -0
- package/dist/components/common/IndexingSettings.d.ts +3 -0
- package/dist/components/common/IndexingSettings.d.ts.map +1 -0
- package/dist/components/common/Toast.d.ts +12 -0
- package/dist/components/common/Toast.d.ts.map +1 -0
- package/dist/components/common/ToggleSwitch.d.ts +9 -0
- package/dist/components/common/ToggleSwitch.d.ts.map +1 -0
- package/dist/components/header/ChatHeader.d.ts +42 -0
- package/dist/components/header/ChatHeader.d.ts.map +1 -0
- package/dist/components/input/AtFilePicker.d.ts +16 -0
- package/dist/components/input/AtFilePicker.d.ts.map +1 -0
- package/dist/components/input/ChatInput.d.ts +49 -0
- package/dist/components/input/ChatInput.d.ts.map +1 -0
- package/dist/components/input/DropdownSelector.d.ts +46 -0
- package/dist/components/input/DropdownSelector.d.ts.map +1 -0
- package/dist/components/input/ImagePreviewModal.d.ts +11 -0
- package/dist/components/input/ImagePreviewModal.d.ts.map +1 -0
- package/dist/components/input/QueuedMessageList.d.ts +11 -0
- package/dist/components/input/QueuedMessageList.d.ts.map +1 -0
- package/dist/components/input/at-views/AtChatsView.d.ts +17 -0
- package/dist/components/input/at-views/AtChatsView.d.ts.map +1 -0
- package/dist/components/input/at-views/AtDocsView.d.ts +17 -0
- package/dist/components/input/at-views/AtDocsView.d.ts.map +1 -0
- package/dist/components/input/at-views/AtFilesView.d.ts +26 -0
- package/dist/components/input/at-views/AtFilesView.d.ts.map +1 -0
- package/dist/components/input/at-views/AtTerminalsView.d.ts +17 -0
- package/dist/components/input/at-views/AtTerminalsView.d.ts.map +1 -0
- package/dist/components/input/at-views/index.d.ts +9 -0
- package/dist/components/input/at-views/index.d.ts.map +1 -0
- package/dist/components/input/at-views/useAtViewTooltip.d.ts +12 -0
- package/dist/components/input/at-views/useAtViewTooltip.d.ts.map +1 -0
- package/dist/components/input/atContextItems.d.ts +9 -0
- package/dist/components/input/atContextItems.d.ts.map +1 -0
- package/dist/components/input/atContextToolHints.d.ts +2 -0
- package/dist/components/input/atContextToolHints.d.ts.map +1 -0
- package/dist/components/message/MessageBubble.d.ts +69 -0
- package/dist/components/message/MessageBubble.d.ts.map +1 -0
- package/dist/components/message/PartsRenderer.d.ts +22 -0
- package/dist/components/message/PartsRenderer.d.ts.map +1 -0
- package/dist/components/message/WelcomeMessage.d.ts +16 -0
- package/dist/components/message/WelcomeMessage.d.ts.map +1 -0
- package/dist/components/message/parts/CollapsibleCard.d.ts +29 -0
- package/dist/components/message/parts/CollapsibleCard.d.ts.map +1 -0
- package/dist/components/message/parts/CompactPart.d.ts +14 -0
- package/dist/components/message/parts/CompactPart.d.ts.map +1 -0
- package/dist/components/message/parts/ContentCompressPart.d.ts +13 -0
- package/dist/components/message/parts/ContentCompressPart.d.ts.map +1 -0
- package/dist/components/message/parts/ErrorPart.d.ts +10 -0
- package/dist/components/message/parts/ErrorPart.d.ts.map +1 -0
- package/dist/components/message/parts/ExtensionPartHost.d.ts +15 -0
- package/dist/components/message/parts/ExtensionPartHost.d.ts.map +1 -0
- package/dist/components/message/parts/ImagePart.d.ts +9 -0
- package/dist/components/message/parts/ImagePart.d.ts.map +1 -0
- package/dist/components/message/parts/PlanPart.d.ts +11 -0
- package/dist/components/message/parts/PlanPart.d.ts.map +1 -0
- package/dist/components/message/parts/TavilySearchPart.d.ts +18 -0
- package/dist/components/message/parts/TavilySearchPart.d.ts.map +1 -0
- package/dist/components/message/parts/TextPart.d.ts +9 -0
- package/dist/components/message/parts/TextPart.d.ts.map +1 -0
- package/dist/components/message/parts/ThinkingPart.d.ts +12 -0
- package/dist/components/message/parts/ThinkingPart.d.ts.map +1 -0
- package/dist/components/message/parts/ToolCallPart.d.ts +35 -0
- package/dist/components/message/parts/ToolCallPart.d.ts.map +1 -0
- package/dist/components/message/parts/ZhipuSearchPart.d.ts +20 -0
- package/dist/components/message/parts/ZhipuSearchPart.d.ts.map +1 -0
- package/dist/components/message/parts/index.d.ts +20 -0
- package/dist/components/message/parts/index.d.ts.map +1 -0
- package/dist/components/message/parts/tool-call-display.d.ts +26 -0
- package/dist/components/message/parts/tool-call-display.d.ts.map +1 -0
- package/dist/components/message/parts/visual-predicate.d.ts +7 -0
- package/dist/components/message/parts/visual-predicate.d.ts.map +1 -0
- package/dist/components/message/parts/visual-render.d.ts +2 -0
- package/dist/components/message/parts/visual-render.d.ts.map +1 -0
- package/dist/components/message/parts/visual.d.ts +3 -0
- package/dist/components/message/parts/visual.d.ts.map +1 -0
- package/dist/components/message/welcome-types.d.ts +28 -0
- package/dist/components/message/welcome-types.d.ts.map +1 -0
- package/dist/context/AutoRunConfigContext.d.ts +8 -0
- package/dist/context/AutoRunConfigContext.d.ts.map +1 -0
- package/dist/context/ChatAdapterContext.d.ts +4 -0
- package/dist/context/ChatAdapterContext.d.ts.map +1 -0
- package/dist/context/ChatInputContext.d.ts +51 -0
- package/dist/context/ChatInputContext.d.ts.map +1 -0
- package/dist/context/PartLoaderContext.d.ts +25 -0
- package/dist/context/PartLoaderContext.d.ts.map +1 -0
- package/dist/context/RenderersContext.d.ts +22 -0
- package/dist/context/RenderersContext.d.ts.map +1 -0
- package/dist/hooks/chat/types.d.ts +109 -0
- package/dist/hooks/chat/types.d.ts.map +1 -0
- package/dist/hooks/chat/useCapabilityConfig.d.ts +35 -0
- package/dist/hooks/chat/useCapabilityConfig.d.ts.map +1 -0
- package/dist/hooks/chat/useMessageActions.d.ts +13 -0
- package/dist/hooks/chat/useMessageActions.d.ts.map +1 -0
- package/dist/hooks/chat/useMessageSender.d.ts +15 -0
- package/dist/hooks/chat/useMessageSender.d.ts.map +1 -0
- package/dist/hooks/chat/useSessionManager.d.ts +18 -0
- package/dist/hooks/chat/useSessionManager.d.ts.map +1 -0
- package/dist/hooks/chat/utils.d.ts +20 -0
- package/dist/hooks/chat/utils.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +105 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useImageUpload.d.ts +56 -0
- package/dist/hooks/useImageUpload.d.ts.map +1 -0
- package/dist/hooks/useVoiceInput.d.ts +26 -0
- package/dist/hooks/useVoiceInput.d.ts.map +1 -0
- package/dist/hooks/useVoiceToTextInput.d.ts +22 -0
- package/dist/hooks/useVoiceToTextInput.d.ts.map +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/index.d.ts +55 -684
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -1
- package/dist/style.css +103 -0
- package/dist/types/index.d.ts +251 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/applyToolCallResult.d.ts +8 -0
- package/dist/utils/applyToolCallResult.d.ts.map +1 -0
- package/dist/utils/applyToolCallResult.test.d.ts +2 -0
- package/dist/utils/applyToolCallResult.test.d.ts.map +1 -0
- package/package.json +19 -11
- package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/index.css +0 -4017
package/dist/index.d.ts
CHANGED
|
@@ -1,689 +1,60 @@
|
|
|
1
|
-
import * as _huyooo_ai_chat_types from '@huyooo/ai-chat-types';
|
|
2
|
-
import { SkillRecord } from '@huyooo/ai-chat-types';
|
|
3
|
-
export { ChatAdapter, ChatEvent, ChatEventType, ChatMode, ChatOptions, MessageRecord, ModelOption, ProviderType, SessionRecord, ThinkingMode } from '@huyooo/ai-chat-types';
|
|
4
|
-
import { ChatMode as ChatMode$1, ThinkingMode, ModelOption as ModelOption$1, SessionRecord as SessionRecord$1, ChatAdapter, AutoRunConfig } from '@huyooo/ai-chat-bridge-electron/renderer';
|
|
5
|
-
import * as react from 'react';
|
|
6
|
-
import { FC, ReactNode, ComponentType } from 'react';
|
|
7
|
-
export { CodeBlock as CodeBlockType, ContentBlock, ContentBlockType, SearchResultItem, TextBlock as TextBlockType, WeatherData, getLanguageDisplayName, highlightCode, parseContent, renderMarkdown } from '@huyooo/ai-chat-shared';
|
|
8
|
-
|
|
9
1
|
/**
|
|
10
|
-
*
|
|
11
|
-
* 核心 ChatAdapter 接口从 bridge-electron 导入
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** 思考数据 */
|
|
15
|
-
interface ThinkingData {
|
|
16
|
-
content: string;
|
|
17
|
-
isComplete: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** 工具调用数据 */
|
|
20
|
-
interface ToolCallData {
|
|
21
|
-
name: string;
|
|
22
|
-
args: Record<string, unknown>;
|
|
23
|
-
}
|
|
24
|
-
/** 工具结果数据 */
|
|
25
|
-
interface ToolResultData {
|
|
26
|
-
name: string;
|
|
27
|
-
result: string;
|
|
28
|
-
}
|
|
29
|
-
/** 图片数据 */
|
|
30
|
-
interface ImageData {
|
|
31
|
-
base64: string;
|
|
32
|
-
mimeType: string;
|
|
33
|
-
}
|
|
34
|
-
/** 发送消息选项 */
|
|
35
|
-
interface SendMessageOptions {
|
|
36
|
-
mode: ChatMode$1;
|
|
37
|
-
model: string;
|
|
38
|
-
enableWebSearch: boolean;
|
|
39
|
-
/** 深度思考开关(每个 provider 内部使用最优参数) */
|
|
40
|
-
thinkingMode: ThinkingMode;
|
|
41
|
-
}
|
|
42
|
-
/** 创建会话选项 */
|
|
43
|
-
interface CreateSessionOptions {
|
|
44
|
-
title: string;
|
|
45
|
-
model: string;
|
|
46
|
-
mode: ChatMode$1;
|
|
47
|
-
}
|
|
48
|
-
/** 更新会话选项 */
|
|
49
|
-
interface UpdateSessionOptions {
|
|
50
|
-
title?: string;
|
|
51
|
-
model?: string;
|
|
52
|
-
mode?: ChatMode$1;
|
|
53
|
-
}
|
|
54
|
-
/** 保存消息选项 */
|
|
55
|
-
interface SaveMessageOptions {
|
|
56
|
-
sessionId: string;
|
|
57
|
-
role: 'user' | 'assistant';
|
|
58
|
-
content: string;
|
|
59
|
-
/** 执行步骤列表 JSON */
|
|
60
|
-
steps?: string;
|
|
61
|
-
operationIds?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
type ChatMode = ChatMode$1;
|
|
65
|
-
type SessionRecord = SessionRecord$1;
|
|
66
|
-
type ModelOption = ModelOption$1;
|
|
67
|
-
/** 搜索结果 */
|
|
68
|
-
interface SearchResult {
|
|
69
|
-
title: string;
|
|
70
|
-
url: string;
|
|
71
|
-
snippet: string;
|
|
72
|
-
}
|
|
73
|
-
/** 文本内容 Part */
|
|
74
|
-
interface TextPart$1 {
|
|
75
|
-
type: 'text';
|
|
76
|
-
text: string;
|
|
77
|
-
}
|
|
78
|
-
/** 代码块 Part(从 text 中解析,或直接返回)*/
|
|
79
|
-
interface CodePart {
|
|
80
|
-
type: 'code';
|
|
81
|
-
content: string;
|
|
82
|
-
language?: string;
|
|
83
|
-
}
|
|
84
|
-
/** 思考过程 Part */
|
|
85
|
-
interface ThinkingPart$1 {
|
|
86
|
-
type: 'thinking';
|
|
87
|
-
text: string;
|
|
88
|
-
status: 'running' | 'done';
|
|
89
|
-
duration?: number;
|
|
90
|
-
}
|
|
91
|
-
/** 搜索 Part */
|
|
92
|
-
interface SearchPart$1 {
|
|
93
|
-
type: 'search';
|
|
94
|
-
query?: string;
|
|
95
|
-
results?: SearchResult[];
|
|
96
|
-
status: 'running' | 'done';
|
|
97
|
-
}
|
|
98
|
-
/** 工具调用 Part(仅展示执行过程,结果由具体类型 Part 渲染)*/
|
|
99
|
-
interface ToolCallPart$1 {
|
|
100
|
-
type: 'tool_call';
|
|
101
|
-
id: string;
|
|
102
|
-
name: string;
|
|
103
|
-
args?: Record<string, unknown>;
|
|
104
|
-
status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
|
|
105
|
-
/** 工具执行输出(用于 execute_command 等需要展示 stdout/stderr 的工具) */
|
|
106
|
-
output?: {
|
|
107
|
-
stdout?: string;
|
|
108
|
-
stderr?: string;
|
|
109
|
-
};
|
|
110
|
-
/** 错误信息(status 为 error 时) */
|
|
111
|
-
error?: string;
|
|
112
|
-
/** 结构化错误(便于展示建议、重试按钮) */
|
|
113
|
-
toolError?: _huyooo_ai_chat_types.ToolErrorShape;
|
|
114
|
-
}
|
|
115
|
-
/** 图片 Part */
|
|
116
|
-
interface ImagePart$1 {
|
|
117
|
-
type: 'image';
|
|
118
|
-
url: string;
|
|
119
|
-
}
|
|
120
|
-
/** 错误 Part */
|
|
121
|
-
interface ErrorPart$1 {
|
|
122
|
-
type: 'error';
|
|
123
|
-
message: string;
|
|
124
|
-
category?: string;
|
|
125
|
-
retryable?: boolean;
|
|
126
|
-
}
|
|
127
|
-
/** 计划步骤 */
|
|
128
|
-
interface PlanStepItem {
|
|
129
|
-
id: string;
|
|
130
|
-
title: string;
|
|
131
|
-
status: 'pending' | 'in_progress' | 'done' | 'failed';
|
|
132
|
-
}
|
|
133
|
-
/** 计划进度 Part(由 update_plan 工具的 ui: { type: 'render', name: 'plan' } 生成) */
|
|
134
|
-
interface PlanPart {
|
|
135
|
-
type: 'plan';
|
|
136
|
-
steps: PlanStepItem[];
|
|
137
|
-
status: 'running' | 'done';
|
|
138
|
-
}
|
|
139
|
-
/** 上下文压缩 Part(AI 总结对话历史) */
|
|
140
|
-
interface CompactPart {
|
|
141
|
-
type: 'compact';
|
|
142
|
-
status: 'running' | 'done' | 'failed';
|
|
143
|
-
/** 压缩前估算 token 数 */
|
|
144
|
-
estimatedTokens?: number;
|
|
145
|
-
/** 可用 prompt token 预算 */
|
|
146
|
-
budget?: number;
|
|
147
|
-
/** 压缩后估算 token 数 */
|
|
148
|
-
compressedTokens?: number;
|
|
149
|
-
/** 压缩前消息数 */
|
|
150
|
-
originalMessageCount?: number;
|
|
151
|
-
/** 压缩后消息数 */
|
|
152
|
-
compressedMessageCount?: number;
|
|
153
|
-
/** 耗时(秒) */
|
|
154
|
-
duration?: number;
|
|
155
|
-
}
|
|
156
|
-
/** 天气 Part(由 get_weather 工具生成)*/
|
|
157
|
-
interface WeatherPart {
|
|
158
|
-
type: 'weather';
|
|
159
|
-
city: string;
|
|
160
|
-
temperature: number;
|
|
161
|
-
condition: string;
|
|
162
|
-
humidity: number;
|
|
163
|
-
wind: string;
|
|
164
|
-
reportTime?: string;
|
|
165
|
-
province?: string;
|
|
166
|
-
}
|
|
167
|
-
/** 自定义 Part 基础接口(用于扩展)*/
|
|
168
|
-
interface CustomPart {
|
|
169
|
-
type: string;
|
|
170
|
-
[key: string]: unknown;
|
|
171
|
-
}
|
|
172
|
-
/** 内置 Part 联合类型 */
|
|
173
|
-
type BuiltinPart = TextPart$1 | CodePart | ThinkingPart$1 | SearchPart$1 | ToolCallPart$1 | ImagePart$1 | ErrorPart$1 | PlanPart | CompactPart;
|
|
174
|
-
/** 内容 Part 联合类型(包含内置和扩展类型)*/
|
|
175
|
-
type ContentPart = BuiltinPart | WeatherPart | CustomPart;
|
|
176
|
-
/** 内容 Part 类型字符串 */
|
|
177
|
-
type ContentPartType = string;
|
|
178
|
-
/** 步骤折叠模式 */
|
|
179
|
-
type StepsExpandedType = 'open' | 'close' | 'auto';
|
|
180
|
-
/** 错误详情(结构化错误信息) */
|
|
181
|
-
interface ErrorDetails {
|
|
182
|
-
category?: string;
|
|
183
|
-
message: string;
|
|
184
|
-
code?: string;
|
|
185
|
-
statusCode?: number;
|
|
186
|
-
retryable?: boolean;
|
|
187
|
-
retryAfter?: number;
|
|
188
|
-
}
|
|
189
|
-
/** 聊天消息(前端显示用)- 新架构:基于 parts 数组 */
|
|
190
|
-
interface ChatMessage {
|
|
191
|
-
id: string;
|
|
192
|
-
role: 'user' | 'assistant';
|
|
193
|
-
/** 内容 parts 数组 - 核心渲染数据 */
|
|
194
|
-
parts: ContentPart[];
|
|
195
|
-
/** 生成此消息时使用的模型 */
|
|
196
|
-
model?: string;
|
|
197
|
-
/** 生成此消息时使用的模式 (ask/agent) */
|
|
198
|
-
mode?: string;
|
|
199
|
-
/** 生成此消息时是否启用 web 搜索 */
|
|
200
|
-
webSearchEnabled?: boolean;
|
|
201
|
-
/** 生成此消息时是否启用深度思考 */
|
|
202
|
-
thinkingEnabled?: boolean;
|
|
203
|
-
/** 用户上传的图片(仅用户消息) */
|
|
204
|
-
images?: string[];
|
|
205
|
-
/** 是否正在加载 */
|
|
206
|
-
loading?: boolean;
|
|
207
|
-
/** Agent 当前阶段(后端通过 agent_status 事件推送,thinking=显示 loading) */
|
|
208
|
-
agentPhase?: 'thinking';
|
|
209
|
-
/** 是否已复制 */
|
|
210
|
-
copied?: boolean;
|
|
211
|
-
/** 消息时间戳 */
|
|
212
|
-
timestamp?: number;
|
|
213
|
-
/** 错误详情(如果有错误) */
|
|
214
|
-
error?: ErrorDetails;
|
|
215
|
-
/** 是否被用户中止 */
|
|
216
|
-
aborted?: boolean;
|
|
217
|
-
/** Token 使用统计(done 事件携带) */
|
|
218
|
-
usage?: {
|
|
219
|
-
promptTokens: number;
|
|
220
|
-
completionTokens: number;
|
|
221
|
-
totalTokens: number;
|
|
222
|
-
reasoningTokens?: number;
|
|
223
|
-
cachedTokens?: number;
|
|
224
|
-
};
|
|
225
|
-
/** 响应耗时(毫秒) */
|
|
226
|
-
duration?: number;
|
|
227
|
-
/** 计费信息(云端模式,done 后由 ai-server 返回) */
|
|
228
|
-
billing?: {
|
|
229
|
-
pointsConsumed: number;
|
|
230
|
-
remainingPoints: number;
|
|
231
|
-
costYuan?: number;
|
|
232
|
-
model?: string;
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
/** 获取消息的纯文本内容(用于复制、保存等) */
|
|
236
|
-
declare function getMessageText(message: ChatMessage): string;
|
|
237
|
-
/** 输入区配置快照(用于历史回溯/重发) */
|
|
238
|
-
interface ChatInputOptions {
|
|
239
|
-
mode: ChatMode;
|
|
240
|
-
model: string;
|
|
241
|
-
webSearchEnabled: boolean;
|
|
242
|
-
thinkingEnabled: boolean;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* useChat Hook
|
|
247
|
-
* 管理聊天状态和与后端的通信
|
|
2
|
+
* @huyooo/ai-chat-frontend-react
|
|
248
3
|
*
|
|
249
|
-
*
|
|
250
|
-
* - 使用 Map 存储每个会话的独立状态
|
|
251
|
-
* - 多会话可同时进行,互不干扰
|
|
252
|
-
* - 切换 tab 不会停止正在进行的请求
|
|
253
|
-
* - ContentPart 数组存储消息内容,支持流式渲染和自定义 UI
|
|
254
|
-
*/
|
|
255
|
-
|
|
256
|
-
/** 工具 UI 声明 */
|
|
257
|
-
interface ToolUIShape {
|
|
258
|
-
type: 'render' | 'action';
|
|
259
|
-
name: string;
|
|
260
|
-
props?: Record<string, unknown>;
|
|
261
|
-
}
|
|
262
|
-
/** 工具完成事件数据 */
|
|
263
|
-
interface ToolCompleteEvent {
|
|
264
|
-
name: string;
|
|
265
|
-
result: unknown;
|
|
266
|
-
/** 工具声明的 UI(render 或 action) */
|
|
267
|
-
ui?: ToolUIShape;
|
|
268
|
-
}
|
|
269
|
-
interface UseChatOptions {
|
|
270
|
-
adapter: ChatAdapter;
|
|
271
|
-
defaultModel?: string;
|
|
272
|
-
defaultMode?: ChatMode$1;
|
|
273
|
-
onToolComplete?: (event: ToolCompleteEvent) => void;
|
|
274
|
-
autoRunConfig?: AutoRunConfig;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* 聊天状态管理 Hook
|
|
4
|
+
* AI Chat 前端组件库 - React 版本
|
|
278
5
|
*
|
|
279
|
-
* 核心架构:
|
|
280
|
-
* - sessionStatesRef: Map<sessionId, SessionState> 存储每个会话的独立状态
|
|
281
|
-
* - 多会话可同时进行请求,互不干扰
|
|
282
|
-
* - 切换 tab 不会停止任何正在进行的请求
|
|
283
|
-
*/
|
|
284
|
-
declare function useChat(options: UseChatOptions): {
|
|
285
|
-
sessions: SessionRecord$1[];
|
|
286
|
-
currentSessionId: string | null;
|
|
287
|
-
messages: ChatMessage[];
|
|
288
|
-
isLoading: boolean;
|
|
289
|
-
mode: ChatMode$1;
|
|
290
|
-
model: string;
|
|
291
|
-
webSearch: boolean;
|
|
292
|
-
thinking: boolean;
|
|
293
|
-
loadSessions: () => Promise<void>;
|
|
294
|
-
switchSession: (sessionId: string) => Promise<void>;
|
|
295
|
-
createNewSession: () => Promise<void>;
|
|
296
|
-
deleteSession: (sessionId: string) => Promise<void>;
|
|
297
|
-
deleteCurrentSession: () => Promise<void>;
|
|
298
|
-
hideSession: (sessionId: string, hidden: boolean) => Promise<void>;
|
|
299
|
-
clearAllSessions: () => Promise<void>;
|
|
300
|
-
hideOtherSessions: () => Promise<void>;
|
|
301
|
-
exportCurrentSession: () => string | null;
|
|
302
|
-
sendMessage: (text: string, images?: string[]) => Promise<void>;
|
|
303
|
-
cancelRequest: () => void;
|
|
304
|
-
copyMessage: (messageId: string) => Promise<void>;
|
|
305
|
-
regenerateMessage: (messageIndex: number) => void;
|
|
306
|
-
resendFromIndex: (index: number, text: string) => Promise<void>;
|
|
307
|
-
setMode: (value: ChatMode$1) => void;
|
|
308
|
-
setModel: (value: string) => void;
|
|
309
|
-
setWebSearch: (value: boolean) => void;
|
|
310
|
-
setThinking: (value: boolean) => void;
|
|
311
|
-
setWorkingDirectory: (dir: string) => void;
|
|
312
|
-
autoRunConfig: AutoRunConfig;
|
|
313
|
-
loadAutoRunConfig: () => Promise<void>;
|
|
314
|
-
saveAutoRunConfig: (config: AutoRunConfig) => Promise<void>;
|
|
315
|
-
enabledTools: string[] | undefined;
|
|
316
|
-
allTools: {
|
|
317
|
-
name: string;
|
|
318
|
-
description: string;
|
|
319
|
-
}[];
|
|
320
|
-
saveEnabledTools: (tools: string[] | undefined) => Promise<void>;
|
|
321
|
-
skills: SkillRecord[];
|
|
322
|
-
loadSkills: () => Promise<void>;
|
|
323
|
-
toggleSkill: (id: string) => Promise<void>;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* 全局 ChatInput 状态 Context
|
|
328
|
-
* 用于在 MessageBubble 中的 ChatInput 共享和修改全局状态
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
interface ChatInputContextValue {
|
|
332
|
-
mode: ChatMode;
|
|
333
|
-
model: string;
|
|
334
|
-
models: ModelOption[];
|
|
335
|
-
webSearch: boolean;
|
|
336
|
-
thinking: boolean;
|
|
337
|
-
isLoading: boolean;
|
|
338
|
-
/** Electron adapter(用于 @ 文件选择) */
|
|
339
|
-
adapter?: ChatAdapter;
|
|
340
|
-
/** Skills 列表(用于 @ 选择器 Skills 视图) */
|
|
341
|
-
skills?: SkillRecord[];
|
|
342
|
-
/** 切换 Skill 启用状态 */
|
|
343
|
-
toggleSkill?: (id: string) => void;
|
|
344
|
-
setMode: (value: ChatMode) => void;
|
|
345
|
-
setModel: (value: string) => void;
|
|
346
|
-
setWebSearch: (value: boolean) => void;
|
|
347
|
-
setThinking: (value: boolean) => void;
|
|
348
|
-
}
|
|
349
|
-
interface ChatInputProviderProps {
|
|
350
|
-
value: ChatInputContextValue;
|
|
351
|
-
children: ReactNode;
|
|
352
|
-
}
|
|
353
|
-
declare const ChatInputProvider: FC<ChatInputProviderProps>;
|
|
354
|
-
declare function useChatInputContext(): ChatInputContextValue | null;
|
|
355
|
-
|
|
356
|
-
/** Part 渲染器 Props(每个自定义渲染器接收的 props) */
|
|
357
|
-
interface PartRendererProps {
|
|
358
|
-
[key: string]: unknown;
|
|
359
|
-
}
|
|
360
|
-
/** Part 渲染器映射(key: part.type, value: 渲染组件) */
|
|
361
|
-
type PartRenderers$1 = Record<string, ComponentType<PartRendererProps>>;
|
|
362
|
-
/** Part 渲染器上下文 */
|
|
363
|
-
declare const PartRenderersContext: react.Context<PartRenderers$1>;
|
|
364
|
-
/** Part 渲染器 Provider Props */
|
|
365
|
-
interface PartRenderersProviderProps {
|
|
366
|
-
partRenderers?: PartRenderers$1;
|
|
367
|
-
children: ReactNode;
|
|
368
|
-
}
|
|
369
|
-
/** Part 渲染器 Provider */
|
|
370
|
-
declare const PartRenderersProvider: FC<PartRenderersProviderProps>;
|
|
371
|
-
|
|
372
|
-
/** 功能项 */
|
|
373
|
-
interface WelcomeFeature {
|
|
374
|
-
name: string;
|
|
375
|
-
icon: string;
|
|
376
|
-
}
|
|
377
|
-
/** 快捷任务 */
|
|
378
|
-
interface WelcomeTask {
|
|
379
|
-
name: string;
|
|
380
|
-
desc: string;
|
|
381
|
-
prompt: string;
|
|
382
|
-
icon: string;
|
|
383
|
-
}
|
|
384
|
-
/** 欢迎页配置 */
|
|
385
|
-
interface WelcomeConfig {
|
|
386
|
-
/** 标题 */
|
|
387
|
-
title: string;
|
|
388
|
-
/** 副标题 */
|
|
389
|
-
subtitle: string;
|
|
390
|
-
/** 图标 */
|
|
391
|
-
icon: string;
|
|
392
|
-
/** 功能列表 */
|
|
393
|
-
features: WelcomeFeature[];
|
|
394
|
-
/** 快捷任务 */
|
|
395
|
-
tasks: WelcomeTask[];
|
|
396
|
-
}
|
|
397
|
-
/** 默认配置 */
|
|
398
|
-
declare const defaultWelcomeConfig: WelcomeConfig;
|
|
399
|
-
|
|
400
|
-
/** ChatPanel 暴露给外部的方法 */
|
|
401
|
-
interface ChatPanelHandle {
|
|
402
|
-
/** 设置输入框内容 */
|
|
403
|
-
setInputText: (text: string) => void;
|
|
404
|
-
/** 在光标位置插入文本(用于 @ 上下文) */
|
|
405
|
-
insertInputText: (text: string) => void;
|
|
406
|
-
/** 聚焦输入框 */
|
|
407
|
-
focusInput: () => void;
|
|
408
|
-
/** 发送消息 */
|
|
409
|
-
sendMessage: (text: string) => void;
|
|
410
|
-
/** 设置当前工作目录 */
|
|
411
|
-
setCwd: (dir: string) => void;
|
|
412
|
-
/** 重新加载 Skills 列表 */
|
|
413
|
-
loadSkills: () => Promise<void>;
|
|
414
|
-
}
|
|
415
|
-
interface ChatPanelProps {
|
|
416
|
-
/** Adapter 实例 */
|
|
417
|
-
adapter: ChatAdapter;
|
|
418
|
-
/** 默认模型 */
|
|
419
|
-
defaultModel?: string;
|
|
420
|
-
/** 默认模式 */
|
|
421
|
-
defaultMode?: ChatMode$1;
|
|
422
|
-
/** 可用模型列表 */
|
|
423
|
-
models?: ModelOption$1[];
|
|
424
|
-
/** 隐藏标题栏 */
|
|
425
|
-
hideHeader?: boolean;
|
|
426
|
-
/** 关闭回调(有此属性时显示关闭按钮) */
|
|
427
|
-
onClose?: () => void;
|
|
428
|
-
/** 工具执行完成回调 */
|
|
429
|
-
onToolComplete?: (event: ToolCompleteEvent) => void;
|
|
430
|
-
/** 自定义类名 */
|
|
431
|
-
className?: string;
|
|
432
|
-
/** 欢迎页配置 */
|
|
433
|
-
welcomeConfig?: Partial<WelcomeConfig>;
|
|
434
|
-
/** 自定义 Part 渲染器 - 根据 part.type 选择渲染组件(如 weather, stock 等) */
|
|
435
|
-
partRenderers?: PartRenderers$1;
|
|
436
|
-
/**
|
|
437
|
-
* 执行步骤折叠模式
|
|
438
|
-
* - 'open': 始终展开
|
|
439
|
-
* - 'close': 始终折叠
|
|
440
|
-
* - 'auto': 执行时展开,完成后折叠
|
|
441
|
-
*/
|
|
442
|
-
stepsExpandedType?: 'open' | 'close' | 'auto';
|
|
443
|
-
/** 打开 Skills 目录回调(宿主应用处理) */
|
|
444
|
-
onOpenSkillsDir?: () => void;
|
|
445
|
-
}
|
|
446
|
-
declare const ChatPanel: react.ForwardRefExoticComponent<ChatPanelProps & react.RefAttributes<ChatPanelHandle>>;
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* MessageBubble Component
|
|
450
6
|
* 新架构:使用 ContentPart 数组渲染消息内容
|
|
7
|
+
* - 支持流式渲染
|
|
8
|
+
* - 支持自定义 Part 类型渲染(如 weather, stock)
|
|
9
|
+
* - 支持思考、搜索、工具调用等多种内容类型
|
|
10
|
+
*/
|
|
11
|
+
import './styles.css';
|
|
12
|
+
export type { ChatAdapter, ChatEvent, ChatEventType, ChatOptions, ChatMode, ThinkingMode, SessionRecord, MessageRecord, ModelOption, } from '@huyooo/ai-chat-types';
|
|
13
|
+
export type { ThinkingData, ToolCallData, ToolResultData, ImageData, SendMessageOptions, CreateSessionOptions, UpdateSessionOptions, SaveMessageOptions, } from './adapter';
|
|
14
|
+
export type { ChatMessage, ProtocolId, ContentPart, ContentPartType, TextPart, ThinkingPart, TavilySearchPart, ZhipuSearchPart, ToolCallPart, ImagePart, ErrorPart, ErrorDetails, ChatInputOptions, } from './types';
|
|
15
|
+
export { getMessageText } from './types';
|
|
16
|
+
export { useChat } from './hooks/useChat';
|
|
17
|
+
export type { ChatRuntime, UseChatOptions, ToolCompleteEvent, ToolUI } from './hooks/useChat';
|
|
18
|
+
export { ChatInputProvider, useChatInputContext } from './context/ChatInputContext';
|
|
19
|
+
export type { ChatInputContextValue } from './context/ChatInputContext';
|
|
20
|
+
export { PartRenderersProvider, PartRenderersContext } from './context/RenderersContext';
|
|
21
|
+
export type { PartRenderers, PartRendererProps } from './context/RenderersContext';
|
|
22
|
+
export { PartAssetNamesContext, PartLoaderContext, PartLoaderProvider, usePartAssetNames, usePartLoader, } from './context/PartLoaderContext';
|
|
23
|
+
export type { LoadPartCodeFn, LoadedPartPayload } from './context/PartLoaderContext';
|
|
24
|
+
export { ChatPanel } from './components/ChatPanel';
|
|
25
|
+
export type { ChatPanelHandle } from './components/ChatPanel';
|
|
26
|
+
export { MessageBubble } from './components/message/MessageBubble';
|
|
27
|
+
export { PartsRenderer } from './components/message/PartsRenderer';
|
|
28
|
+
export { TextPart as TextPartComponent, ThinkingPart as ThinkingPartComponent, TavilySearchPart as TavilySearchPartComponent, ZhipuSearchPart as ZhipuSearchPartComponent, ToolCallPart as ToolCallPartComponent, ImagePart as ImagePartComponent, ErrorPart as ErrorPartComponent, CollapsibleCard, ExtensionPartHost, } from './components/message/parts';
|
|
29
|
+
export type { ExtensionPartHostProps } from './components/message/parts';
|
|
30
|
+
export { ChatInput } from './components/input/ChatInput';
|
|
31
|
+
export { ChatHeader } from './components/header/ChatHeader';
|
|
32
|
+
export { WelcomeMessage } from './components/message/WelcomeMessage';
|
|
33
|
+
export type { WelcomeConfig, WelcomeFeature, WelcomeTask } from './components/message/welcome-types';
|
|
34
|
+
export { defaultWelcomeConfig } from './components/message/welcome-types';
|
|
35
|
+
export { ConfirmDialog } from './components/common/ConfirmDialog';
|
|
36
|
+
export { Toast } from './components/common/Toast';
|
|
37
|
+
export type { ContentBlockType, ContentBlock, TextBlock as TextBlockType, CodeBlock as CodeBlockType, WeatherData, SearchResultItem, } from '@huyooo/ai-chat-shared';
|
|
38
|
+
export { parseContent, highlightCode, getLanguageDisplayName, renderMarkdown } from '@huyooo/ai-chat-shared';
|
|
39
|
+
/**
|
|
40
|
+
* 使用说明:
|
|
41
|
+
*
|
|
42
|
+
* 1. 导入样式:
|
|
43
|
+
* import '@huyooo/ai-chat-frontend-react/style.css'
|
|
44
|
+
*
|
|
45
|
+
* 2. 基本使用:
|
|
46
|
+
* import { ChatPanel } from '@huyooo/ai-chat-frontend-react'
|
|
47
|
+
* import { createElectronAdapter } from '@huyooo/ai-chat-bridge-electron/renderer'
|
|
48
|
+
* const adapter = createElectronAdapter()
|
|
49
|
+
* <ChatPanel adapter={adapter} cwd="/path/to/dir" />
|
|
50
|
+
*
|
|
51
|
+
* 3. 自定义 Part 渲染器(新架构):
|
|
52
|
+
* import WeatherCard from './WeatherCard'
|
|
53
|
+
* const partRenderers = { weather: WeatherCard }
|
|
54
|
+
* <ChatPanel adapter={adapter} partRenderers={partRenderers} />
|
|
55
|
+
*
|
|
56
|
+
* 4. 使用 useChat hook 自定义 UI:
|
|
57
|
+
* import { useChat } from '@huyooo/ai-chat-frontend-react'
|
|
58
|
+
* const { messages, sendMessage, ... } = useChat({ adapter })
|
|
451
59
|
*/
|
|
452
|
-
|
|
453
|
-
/** Token 使用统计 */
|
|
454
|
-
interface TokenUsage {
|
|
455
|
-
promptTokens: number;
|
|
456
|
-
completionTokens: number;
|
|
457
|
-
totalTokens: number;
|
|
458
|
-
reasoningTokens?: number;
|
|
459
|
-
cachedTokens?: number;
|
|
460
|
-
}
|
|
461
|
-
interface MessageBubbleProps {
|
|
462
|
-
role: 'user' | 'assistant';
|
|
463
|
-
/** 内容 parts 数组 - 新架构核心 */
|
|
464
|
-
parts: ContentPart[];
|
|
465
|
-
/** 生成此消息时使用的模型 */
|
|
466
|
-
model?: string;
|
|
467
|
-
/** 生成此消息时使用的模式 (ask/agent) */
|
|
468
|
-
mode?: string;
|
|
469
|
-
/** 用户上传的图片 */
|
|
470
|
-
images?: string[];
|
|
471
|
-
/** 是否正在加载 */
|
|
472
|
-
loading?: boolean;
|
|
473
|
-
/** Agent 当前阶段(后端推送,thinking=显示 loading) */
|
|
474
|
-
agentPhase?: 'thinking';
|
|
475
|
-
/** 是否已复制 */
|
|
476
|
-
copied?: boolean;
|
|
477
|
-
/** 消息时间戳 */
|
|
478
|
-
timestamp?: Date | string | number;
|
|
479
|
-
/** Token 使用统计 */
|
|
480
|
-
usage?: TokenUsage;
|
|
481
|
-
/** 响应耗时(毫秒) */
|
|
482
|
-
duration?: number;
|
|
483
|
-
/** 计费信息(云端模式) */
|
|
484
|
-
billing?: {
|
|
485
|
-
pointsConsumed: number;
|
|
486
|
-
remainingPoints: number;
|
|
487
|
-
costYuan?: number;
|
|
488
|
-
model?: string;
|
|
489
|
-
};
|
|
490
|
-
onCopy?: () => void;
|
|
491
|
-
onRegenerate?: () => void;
|
|
492
|
-
/** 编辑用户消息后重新发送 */
|
|
493
|
-
onSend?: (text: string) => void;
|
|
494
|
-
/** 步骤折叠模式 */
|
|
495
|
-
stepsExpandedType?: 'open' | 'close' | 'auto';
|
|
496
|
-
/** 工具调用相关 - 通过 props 传递 */
|
|
497
|
-
adapter?: ChatAdapter;
|
|
498
|
-
/** 取消工具调用(通常会中止当前请求/流式输出) */
|
|
499
|
-
onCancelToolCall?: (toolCallId: string) => void;
|
|
500
|
-
autoRunConfig?: AutoRunConfig;
|
|
501
|
-
onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
|
|
502
|
-
}
|
|
503
|
-
declare const MessageBubble: FC<MessageBubbleProps>;
|
|
504
|
-
|
|
505
|
-
/** Part 渲染器映射类型 */
|
|
506
|
-
type PartRenderers = Record<string, ComponentType<Record<string, unknown>>>;
|
|
507
|
-
interface PartsRendererProps {
|
|
508
|
-
parts: ContentPart[];
|
|
509
|
-
expandedType?: StepsExpandedType;
|
|
510
|
-
/** 自定义 Part 渲染器(props 传入优先级高于 context) */
|
|
511
|
-
partRenderers?: PartRenderers;
|
|
512
|
-
adapter?: ChatAdapter;
|
|
513
|
-
onCancelToolCall?: (toolCallId: string) => void;
|
|
514
|
-
autoRunConfig?: AutoRunConfig;
|
|
515
|
-
onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
|
|
516
|
-
}
|
|
517
|
-
declare const PartsRenderer: FC<PartsRendererProps>;
|
|
518
|
-
|
|
519
|
-
interface TextPartProps {
|
|
520
|
-
text: string;
|
|
521
|
-
}
|
|
522
|
-
declare const TextPart: FC<TextPartProps>;
|
|
523
|
-
|
|
524
|
-
interface ThinkingPartProps {
|
|
525
|
-
text: string;
|
|
526
|
-
status: 'running' | 'done';
|
|
527
|
-
duration?: number;
|
|
528
|
-
expandedType?: StepsExpandedType;
|
|
529
|
-
}
|
|
530
|
-
declare const ThinkingPart: FC<ThinkingPartProps>;
|
|
531
|
-
|
|
532
|
-
interface SearchPartProps {
|
|
533
|
-
query?: string;
|
|
534
|
-
results?: SearchResult[];
|
|
535
|
-
status: 'running' | 'done';
|
|
536
|
-
expandedType?: StepsExpandedType;
|
|
537
|
-
}
|
|
538
|
-
declare const SearchPart: FC<SearchPartProps>;
|
|
539
|
-
|
|
540
|
-
interface ToolCallPartProps {
|
|
541
|
-
id: string;
|
|
542
|
-
name: string;
|
|
543
|
-
args?: Record<string, unknown>;
|
|
544
|
-
output?: {
|
|
545
|
-
stdout?: string;
|
|
546
|
-
stderr?: string;
|
|
547
|
-
};
|
|
548
|
-
status: 'pending' | 'running' | 'done' | 'error' | 'cancelled' | 'skipped';
|
|
549
|
-
expandedType?: StepsExpandedType;
|
|
550
|
-
adapter?: ChatAdapter;
|
|
551
|
-
onCancelToolCall?: (toolCallId: string) => void;
|
|
552
|
-
autoRunConfig?: AutoRunConfig;
|
|
553
|
-
onSaveConfig?: (config: AutoRunConfig) => Promise<void>;
|
|
554
|
-
}
|
|
555
|
-
declare const ToolCallPart: FC<ToolCallPartProps>;
|
|
556
|
-
|
|
557
|
-
interface ImagePartProps {
|
|
558
|
-
url: string;
|
|
559
|
-
alt?: string;
|
|
560
|
-
}
|
|
561
|
-
declare const ImagePart: FC<ImagePartProps>;
|
|
562
|
-
|
|
563
|
-
interface ErrorPartProps {
|
|
564
|
-
message: string;
|
|
565
|
-
category?: string;
|
|
566
|
-
retryable?: boolean;
|
|
567
|
-
}
|
|
568
|
-
declare const ErrorPart: FC<ErrorPartProps>;
|
|
569
|
-
|
|
570
|
-
/** ChatInput 暴露给外部的方法 */
|
|
571
|
-
interface ChatInputHandle {
|
|
572
|
-
/** 设置输入框内容 */
|
|
573
|
-
setText: (text: string) => void;
|
|
574
|
-
/** 聚焦输入框 */
|
|
575
|
-
focus: () => void;
|
|
576
|
-
/** 清空输入框 */
|
|
577
|
-
clear: () => void;
|
|
578
|
-
/** 在光标位置插入文本(用于 @ 上下文) */
|
|
579
|
-
insertText: (text: string) => void;
|
|
580
|
-
/** 添加图片 */
|
|
581
|
-
addImages: (files: File[]) => void;
|
|
582
|
-
}
|
|
583
|
-
interface ChatInputProps {
|
|
584
|
-
/** 变体模式:input-底部输入框,message-历史消息 */
|
|
585
|
-
variant?: 'input' | 'message';
|
|
586
|
-
/** 受控值(用于历史消息编辑) */
|
|
587
|
-
value?: string;
|
|
588
|
-
/** 图片数据(用于历史消息编辑) */
|
|
589
|
-
images?: string[];
|
|
590
|
-
isLoading?: boolean;
|
|
591
|
-
mode?: ChatMode;
|
|
592
|
-
model?: string;
|
|
593
|
-
/** 模型列表(tooltip 由后端下发,前端仅透传渲染) */
|
|
594
|
-
models?: ModelOption[];
|
|
595
|
-
webSearchEnabled?: boolean;
|
|
596
|
-
thinkingEnabled?: boolean;
|
|
597
|
-
onSend?: (text: string, images?: ImageData[]) => void;
|
|
598
|
-
onCancel?: () => void;
|
|
599
|
-
onAtContext?: () => void;
|
|
600
|
-
onModeChange?: (mode: ChatMode) => void;
|
|
601
|
-
onModelChange?: (model: string) => void;
|
|
602
|
-
onWebSearchChange?: (enabled: boolean) => void;
|
|
603
|
-
onThinkingChange?: (enabled: boolean) => void;
|
|
604
|
-
}
|
|
605
|
-
declare const ChatInput: react.ForwardRefExoticComponent<ChatInputProps & react.RefAttributes<ChatInputHandle>>;
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* ChatHeader Component
|
|
609
|
-
* 与 Vue 版本 ChatHeader.vue 保持一致
|
|
610
|
-
*/
|
|
611
|
-
|
|
612
|
-
interface ChatHeaderProps {
|
|
613
|
-
/** 当前会话列表 */
|
|
614
|
-
sessions: SessionRecord[];
|
|
615
|
-
/** 当前会话 ID */
|
|
616
|
-
currentSessionId?: string | null;
|
|
617
|
-
/** 是否显示关闭按钮 */
|
|
618
|
-
showClose?: boolean;
|
|
619
|
-
/** 创建新会话 */
|
|
620
|
-
onNewSession?: () => void;
|
|
621
|
-
/** 切换会话 */
|
|
622
|
-
onSwitchSession?: (sessionId: string) => void;
|
|
623
|
-
/** 删除会话 */
|
|
624
|
-
onDeleteSession?: (sessionId: string) => void;
|
|
625
|
-
/** 隐藏/显示会话(在 tab 栏关闭但不删除) */
|
|
626
|
-
onHideSession?: (sessionId: string, hidden: boolean) => void;
|
|
627
|
-
/** 关闭面板 */
|
|
628
|
-
onClose?: () => void;
|
|
629
|
-
/** 清空所有对话 */
|
|
630
|
-
onClearAll?: () => void;
|
|
631
|
-
/** 关闭其他对话 */
|
|
632
|
-
onCloseOthers?: () => void;
|
|
633
|
-
/** 导出对话 */
|
|
634
|
-
onExport?: () => void;
|
|
635
|
-
/** 复制请求 ID */
|
|
636
|
-
onCopyId?: () => void;
|
|
637
|
-
/** 反馈 */
|
|
638
|
-
onFeedback?: () => void;
|
|
639
|
-
}
|
|
640
|
-
declare const ChatHeader: FC<ChatHeaderProps>;
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* WelcomeMessage Component
|
|
644
|
-
* 与 Vue 版本 WelcomeMessage.vue 保持一致
|
|
645
|
-
*/
|
|
646
|
-
|
|
647
|
-
interface WelcomeMessageProps {
|
|
648
|
-
/** 欢迎页配置(可部分配置,未配置项使用默认值) */
|
|
649
|
-
config?: Partial<WelcomeConfig>;
|
|
650
|
-
/** 快捷操作回调 */
|
|
651
|
-
onQuickAction: (text: string) => void;
|
|
652
|
-
}
|
|
653
|
-
declare const WelcomeMessage: FC<WelcomeMessageProps>;
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* ConfirmDialog Component
|
|
657
|
-
* 自定义确认弹窗组件
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
|
-
interface ConfirmDialogProps {
|
|
661
|
-
/** 是否显示 */
|
|
662
|
-
visible: boolean;
|
|
663
|
-
/** 标题 */
|
|
664
|
-
title?: string;
|
|
665
|
-
/** 消息内容 */
|
|
666
|
-
message: string;
|
|
667
|
-
/** 类型:info | warning | danger */
|
|
668
|
-
type?: 'info' | 'warning' | 'danger';
|
|
669
|
-
/** 确认按钮文字 */
|
|
670
|
-
confirmText?: string;
|
|
671
|
-
/** 取消按钮文字 */
|
|
672
|
-
cancelText?: string;
|
|
673
|
-
/** 确认回调 */
|
|
674
|
-
onConfirm?: () => void;
|
|
675
|
-
/** 取消回调 */
|
|
676
|
-
onCancel?: () => void;
|
|
677
|
-
}
|
|
678
|
-
declare const ConfirmDialog: FC<ConfirmDialogProps>;
|
|
679
|
-
|
|
680
|
-
interface ToastProps {
|
|
681
|
-
visible: boolean;
|
|
682
|
-
message: string;
|
|
683
|
-
type?: 'info' | 'success' | 'warning' | 'error';
|
|
684
|
-
duration?: number;
|
|
685
|
-
onClose: () => void;
|
|
686
|
-
}
|
|
687
|
-
declare const Toast: FC<ToastProps>;
|
|
688
|
-
|
|
689
|
-
export { ChatHeader, ChatInput, type ChatInputContextValue, type ChatInputOptions, ChatInputProvider, type ChatMessage, ChatPanel, type ChatPanelHandle, ConfirmDialog, type ContentPart, type ContentPartType, type CreateSessionOptions, type ErrorDetails, type ErrorPart$1 as ErrorPart, ErrorPart as ErrorPartComponent, type ImageData, type ImagePart$1 as ImagePart, ImagePart as ImagePartComponent, MessageBubble, type PartRendererProps, type PartRenderers$1 as PartRenderers, PartRenderersContext, PartRenderersProvider, PartsRenderer, type SaveMessageOptions, type SearchPart$1 as SearchPart, SearchPart as SearchPartComponent, type SearchResult, type SendMessageOptions, type TextPart$1 as TextPart, TextPart as TextPartComponent, type ThinkingData, type ThinkingPart$1 as ThinkingPart, ThinkingPart as ThinkingPartComponent, Toast, type ToolCallData, type ToolCallPart$1 as ToolCallPart, ToolCallPart as ToolCallPartComponent, type ToolCompleteEvent, type ToolResultData, type ToolUIShape, type UpdateSessionOptions, type UseChatOptions, type WelcomeConfig, type WelcomeFeature, WelcomeMessage, type WelcomeTask, defaultWelcomeConfig, getMessageText, useChat, useChatInputContext };
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|