@huyooo/ai-chat-frontend-react 0.2.40 → 0.2.42
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/index.css +19 -0
- package/dist/index.d.ts +32 -21
- package/dist/index.js +1 -1
- package/package.json +7 -5
package/dist/index.css
CHANGED
|
@@ -3212,6 +3212,25 @@ body {
|
|
|
3212
3212
|
}
|
|
3213
3213
|
}
|
|
3214
3214
|
|
|
3215
|
+
/* src/components/message/parts/CompactPart.css */
|
|
3216
|
+
.compact-detail {
|
|
3217
|
+
display: flex;
|
|
3218
|
+
flex-direction: column;
|
|
3219
|
+
gap: 4px;
|
|
3220
|
+
font-size: 12px;
|
|
3221
|
+
color: var(--chat-text-muted, #999);
|
|
3222
|
+
}
|
|
3223
|
+
.compact-row {
|
|
3224
|
+
display: flex;
|
|
3225
|
+
justify-content: space-between;
|
|
3226
|
+
}
|
|
3227
|
+
.compact-label {
|
|
3228
|
+
opacity: 0.7;
|
|
3229
|
+
}
|
|
3230
|
+
.compact-value {
|
|
3231
|
+
font-variant-numeric: tabular-nums;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3215
3234
|
/* src/components/message/PartsRenderer.css */
|
|
3216
3235
|
.parts-renderer {
|
|
3217
3236
|
display: flex;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _huyooo_ai_chat_types from '@huyooo/ai-chat-types';
|
|
1
2
|
import { SkillRecord } from '@huyooo/ai-chat-types';
|
|
2
3
|
export { ChatAdapter, ChatEvent, ChatEventType, ChatMode, ChatOptions, MessageRecord, ModelOption, ProviderType, SessionRecord, ThinkingMode } from '@huyooo/ai-chat-types';
|
|
3
4
|
import { ChatMode as ChatMode$1, ThinkingMode, ModelOption as ModelOption$1, SessionRecord as SessionRecord$1, ChatAdapter, AutoRunConfig } from '@huyooo/ai-chat-bridge-electron/renderer';
|
|
@@ -60,13 +61,6 @@ interface SaveMessageOptions {
|
|
|
60
61
|
operationIds?: string;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
/**
|
|
64
|
-
* AI Chat 前端类型定义
|
|
65
|
-
* 核心类型从 bridge-electron 导出,保持类型一致性
|
|
66
|
-
*
|
|
67
|
-
* 架构:消息内容使用 ContentPart 数组,支持流式渲染和自定义 UI
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
64
|
type ChatMode = ChatMode$1;
|
|
71
65
|
type SessionRecord = SessionRecord$1;
|
|
72
66
|
type ModelOption = ModelOption$1;
|
|
@@ -113,6 +107,10 @@ interface ToolCallPart$1 {
|
|
|
113
107
|
stdout?: string;
|
|
114
108
|
stderr?: string;
|
|
115
109
|
};
|
|
110
|
+
/** 错误信息(status 为 error 时) */
|
|
111
|
+
error?: string;
|
|
112
|
+
/** 结构化错误(便于展示建议、重试按钮) */
|
|
113
|
+
toolError?: _huyooo_ai_chat_types.ToolErrorShape;
|
|
116
114
|
}
|
|
117
115
|
/** 图片 Part */
|
|
118
116
|
interface ImagePart$1 {
|
|
@@ -132,12 +130,29 @@ interface PlanStepItem {
|
|
|
132
130
|
title: string;
|
|
133
131
|
status: 'pending' | 'in_progress' | 'done' | 'failed';
|
|
134
132
|
}
|
|
135
|
-
/** 计划进度 Part(由 update_plan 工具的
|
|
133
|
+
/** 计划进度 Part(由 update_plan 工具的 ui: { type: 'render', name: 'plan' } 生成) */
|
|
136
134
|
interface PlanPart {
|
|
137
135
|
type: 'plan';
|
|
138
136
|
steps: PlanStepItem[];
|
|
139
137
|
status: 'running' | 'done';
|
|
140
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
|
+
}
|
|
141
156
|
/** 天气 Part(由 get_weather 工具生成)*/
|
|
142
157
|
interface WeatherPart {
|
|
143
158
|
type: 'weather';
|
|
@@ -155,7 +170,7 @@ interface CustomPart {
|
|
|
155
170
|
[key: string]: unknown;
|
|
156
171
|
}
|
|
157
172
|
/** 内置 Part 联合类型 */
|
|
158
|
-
type BuiltinPart = TextPart$1 | CodePart | ThinkingPart$1 | SearchPart$1 | ToolCallPart$1 | ImagePart$1 | ErrorPart$1 | PlanPart;
|
|
173
|
+
type BuiltinPart = TextPart$1 | CodePart | ThinkingPart$1 | SearchPart$1 | ToolCallPart$1 | ImagePart$1 | ErrorPart$1 | PlanPart | CompactPart;
|
|
159
174
|
/** 内容 Part 联合类型(包含内置和扩展类型)*/
|
|
160
175
|
type ContentPart = BuiltinPart | WeatherPart | CustomPart;
|
|
161
176
|
/** 内容 Part 类型字符串 */
|
|
@@ -238,22 +253,18 @@ interface ChatInputOptions {
|
|
|
238
253
|
* - ContentPart 数组存储消息内容,支持流式渲染和自定义 UI
|
|
239
254
|
*/
|
|
240
255
|
|
|
241
|
-
/**
|
|
242
|
-
interface
|
|
243
|
-
type:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
message?: string;
|
|
256
|
+
/** 工具 UI 声明 */
|
|
257
|
+
interface ToolUIShape {
|
|
258
|
+
type: 'render' | 'action';
|
|
259
|
+
name: string;
|
|
260
|
+
props?: Record<string, unknown>;
|
|
247
261
|
}
|
|
248
262
|
/** 工具完成事件数据 */
|
|
249
263
|
interface ToolCompleteEvent {
|
|
250
264
|
name: string;
|
|
251
265
|
result: unknown;
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
* 前端可根据此字段处理通知、刷新文件列表等
|
|
255
|
-
*/
|
|
256
|
-
sideEffects?: SideEffect[];
|
|
266
|
+
/** 工具声明的 UI(render 或 action) */
|
|
267
|
+
ui?: ToolUIShape;
|
|
257
268
|
}
|
|
258
269
|
interface UseChatOptions {
|
|
259
270
|
adapter: ChatAdapter;
|
|
@@ -675,4 +686,4 @@ interface ToastProps {
|
|
|
675
686
|
}
|
|
676
687
|
declare const Toast: FC<ToastProps>;
|
|
677
688
|
|
|
678
|
-
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
|
|
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 };
|