@huyooo/ai-chat-frontend-react 0.1.4 → 0.1.8
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 +368 -0
- package/dist/index.css +2575 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +378 -135
- package/dist/index.js +3954 -1044
- package/dist/index.js.map +1 -1
- package/dist/style.css +48 -987
- package/package.json +7 -4
- package/src/adapter.ts +10 -70
- package/src/components/ChatPanel.tsx +373 -117
- package/src/components/common/ConfirmDialog.css +136 -0
- package/src/components/common/ConfirmDialog.tsx +91 -0
- package/src/components/common/CopyButton.css +22 -0
- package/src/components/common/CopyButton.tsx +46 -0
- package/src/components/common/IndexingSettings.css +207 -0
- package/src/components/common/IndexingSettings.tsx +398 -0
- package/src/components/common/SettingsPanel.css +256 -0
- package/src/components/common/SettingsPanel.tsx +120 -0
- package/src/components/common/Toast.css +50 -0
- package/src/components/common/Toast.tsx +38 -0
- package/src/components/common/ToggleSwitch.css +52 -0
- package/src/components/common/ToggleSwitch.tsx +20 -0
- package/src/components/header/ChatHeader.css +285 -0
- package/src/components/header/ChatHeader.tsx +376 -0
- package/src/components/input/AtFilePicker.css +147 -0
- package/src/components/input/AtFilePicker.tsx +519 -0
- package/src/components/input/ChatInput.css +204 -0
- package/src/components/input/ChatInput.tsx +506 -0
- package/src/components/input/DropdownSelector.css +159 -0
- package/src/components/input/DropdownSelector.tsx +195 -0
- package/src/components/input/ImagePreviewModal.css +124 -0
- package/src/components/input/ImagePreviewModal.tsx +118 -0
- package/src/components/input/at-views/AtBranchView.tsx +34 -0
- package/src/components/input/at-views/AtBrowserView.tsx +34 -0
- package/src/components/input/at-views/AtChatsView.tsx +34 -0
- package/src/components/input/at-views/AtDocsView.tsx +34 -0
- package/src/components/input/at-views/AtFilesView.tsx +168 -0
- package/src/components/input/at-views/AtTerminalsView.tsx +34 -0
- package/src/components/input/at-views/AtViewStyles.css +143 -0
- package/src/components/input/at-views/index.ts +9 -0
- package/src/components/message/ContentRenderer.css +9 -0
- package/src/components/message/ContentRenderer.tsx +63 -0
- package/src/components/message/MessageBubble.css +190 -0
- package/src/components/message/MessageBubble.tsx +231 -0
- package/src/components/message/PartsRenderer.css +4 -0
- package/src/components/message/PartsRenderer.tsx +114 -0
- package/src/components/message/ToolResultRenderer.tsx +21 -0
- package/src/components/message/WelcomeMessage.css +221 -0
- package/src/components/message/WelcomeMessage.tsx +93 -0
- package/src/components/message/blocks/CodeBlock.tsx +60 -0
- package/src/components/message/blocks/TextBlock.tsx +15 -0
- package/src/components/message/blocks/blocks.css +141 -0
- package/src/components/message/blocks/index.ts +6 -0
- package/src/components/message/parts/CollapsibleCard.css +78 -0
- package/src/components/message/parts/CollapsibleCard.tsx +77 -0
- package/src/components/message/parts/ErrorPart.css +9 -0
- package/src/components/message/parts/ErrorPart.tsx +40 -0
- package/src/components/message/parts/ImagePart.css +50 -0
- package/src/components/message/parts/ImagePart.tsx +54 -0
- package/src/components/message/parts/SearchPart.css +44 -0
- package/src/components/message/parts/SearchPart.tsx +63 -0
- package/src/components/message/parts/TextPart.css +10 -0
- package/src/components/message/parts/TextPart.tsx +20 -0
- package/src/components/message/parts/ThinkingPart.css +9 -0
- package/src/components/message/parts/ThinkingPart.tsx +48 -0
- package/src/components/message/parts/ToolCallPart.css +220 -0
- package/src/components/message/parts/ToolCallPart.tsx +285 -0
- package/src/components/message/parts/ToolResultPart.css +68 -0
- package/src/components/message/parts/ToolResultPart.tsx +96 -0
- package/src/components/message/parts/index.ts +11 -0
- package/src/components/message/tool-results/DefaultToolResult.tsx +26 -0
- package/src/components/message/tool-results/SearchResults.tsx +69 -0
- package/src/components/message/tool-results/WeatherCard.tsx +63 -0
- package/src/components/message/tool-results/index.ts +7 -0
- package/src/components/message/tool-results/tool-results.css +179 -0
- package/src/components/message/welcome-types.ts +46 -0
- package/src/context/AutoRunConfigContext.tsx +13 -0
- package/src/context/ChatAdapterContext.tsx +8 -0
- package/src/context/ChatInputContext.tsx +40 -0
- package/src/context/RenderersContext.tsx +41 -0
- package/src/hooks/useChat.ts +855 -237
- package/src/hooks/useImageUpload.ts +253 -0
- package/src/index.ts +99 -42
- package/src/styles.css +48 -987
- package/src/types/index.ts +172 -103
- package/src/utils/fileIcon.ts +49 -0
- package/src/components/ChatInput.tsx +0 -368
- package/src/components/chat/messages/ExecutionSteps.tsx +0 -234
- package/src/components/chat/messages/MessageBubble.tsx +0 -130
- package/src/components/chat/ui/ChatHeader.tsx +0 -301
- package/src/components/chat/ui/WelcomeMessage.tsx +0 -107
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huyooo/ai-chat-frontend-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "AI Chat Frontend - React components with adapter pattern",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,18 +20,21 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
+
"prebuild": "npm run clean",
|
|
23
24
|
"build": "tsup",
|
|
24
25
|
"dev": "tsup --watch",
|
|
25
26
|
"typecheck": "tsc --noEmit",
|
|
26
|
-
"clean": "rm -rf dist"
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"prepublishOnly": "npm run build && npm run typecheck"
|
|
27
29
|
},
|
|
28
30
|
"peerDependencies": {
|
|
29
31
|
"react": ">=18.0.0",
|
|
30
32
|
"react-dom": ">=18.0.0"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@huyooo/ai-chat-bridge-electron": "^0.1.
|
|
34
|
-
"
|
|
35
|
+
"@huyooo/ai-chat-bridge-electron": "^0.1.8",
|
|
36
|
+
"@huyooo/ai-chat-shared": "^0.1.0",
|
|
37
|
+
"@iconify/react": "^5.0.2"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"@types/node": "^22.0.0",
|
package/src/adapter.ts
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* 核心 ChatAdapter 接口从 bridge-electron 导入
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ChatAdapter, ChatMode, ThinkingMode } from '@huyooo/ai-chat-bridge-electron/renderer'
|
|
7
|
-
|
|
6
|
+
import type { ChatAdapter, ChatMode, ThinkingMode, FileInfo } from '@huyooo/ai-chat-bridge-electron/renderer'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 重新导出 ChatAdapter 类型供内部组件使用
|
|
10
|
+
*/
|
|
11
|
+
export type { ChatAdapter, FileInfo }
|
|
8
12
|
|
|
9
13
|
/** 思考数据 */
|
|
10
14
|
export interface ThinkingData {
|
|
@@ -35,6 +39,7 @@ export interface SendMessageOptions {
|
|
|
35
39
|
mode: ChatMode
|
|
36
40
|
model: string
|
|
37
41
|
enableWebSearch: boolean
|
|
42
|
+
/** 深度思考开关(每个 provider 内部使用最优参数) */
|
|
38
43
|
thinkingMode: ThinkingMode
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -57,72 +62,7 @@ export interface SaveMessageOptions {
|
|
|
57
62
|
sessionId: string
|
|
58
63
|
role: 'user' | 'assistant'
|
|
59
64
|
content: string
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 创建空 Adapter(用于测试或无后端场景)
|
|
67
|
-
* 返回一个最小实现的 ChatAdapter
|
|
68
|
-
*/
|
|
69
|
-
export function createNullAdapter(): ChatAdapter {
|
|
70
|
-
return {
|
|
71
|
-
async getModels() {
|
|
72
|
-
return []
|
|
73
|
-
},
|
|
74
|
-
async getSessions() {
|
|
75
|
-
return []
|
|
76
|
-
},
|
|
77
|
-
async getSession() {
|
|
78
|
-
return null
|
|
79
|
-
},
|
|
80
|
-
async createSession(params) {
|
|
81
|
-
return {
|
|
82
|
-
id: Date.now().toString(),
|
|
83
|
-
appId: null,
|
|
84
|
-
userId: null,
|
|
85
|
-
title: params?.title || '新对话',
|
|
86
|
-
model: params?.model || '',
|
|
87
|
-
mode: (params?.mode || 'agent') as ChatMode,
|
|
88
|
-
createdAt: new Date(),
|
|
89
|
-
updatedAt: new Date(),
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
async updateSession() {
|
|
93
|
-
return null
|
|
94
|
-
},
|
|
95
|
-
async deleteSession() {},
|
|
96
|
-
async getMessages() {
|
|
97
|
-
return []
|
|
98
|
-
},
|
|
99
|
-
async saveMessage(params) {
|
|
100
|
-
return {
|
|
101
|
-
id: Date.now().toString(),
|
|
102
|
-
sessionId: params.sessionId,
|
|
103
|
-
role: params.role,
|
|
104
|
-
content: params.content,
|
|
105
|
-
thinking: params.thinking || null,
|
|
106
|
-
toolCalls: params.toolCalls || null,
|
|
107
|
-
searchResults: params.searchResults || null,
|
|
108
|
-
operationIds: null,
|
|
109
|
-
timestamp: new Date(),
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
async deleteMessagesAfter() {},
|
|
113
|
-
async getOperations() {
|
|
114
|
-
return []
|
|
115
|
-
},
|
|
116
|
-
async getTrashItems() {
|
|
117
|
-
return []
|
|
118
|
-
},
|
|
119
|
-
async restoreFromTrash() {
|
|
120
|
-
return undefined
|
|
121
|
-
},
|
|
122
|
-
async *sendMessage() {
|
|
123
|
-
yield { type: 'text', data: '无可用的 Adapter' }
|
|
124
|
-
yield { type: 'done', data: '' }
|
|
125
|
-
},
|
|
126
|
-
cancel() {},
|
|
127
|
-
}
|
|
65
|
+
/** 执行步骤列表 JSON */
|
|
66
|
+
steps?: string
|
|
67
|
+
operationIds?: string
|
|
128
68
|
}
|