@galaxycore/ai-chat 0.7.0 → 0.9.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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/appearance-CCOHF5L-.d.ts +19 -0
- package/dist/appearance.d.ts +2 -1
- package/dist/appearance.js +1 -1
- package/dist/branches-Dvdv5ug7.d.ts +398 -0
- package/dist/branches-M2XjURF5.js +539 -0
- package/dist/branches-M2XjURF5.js.map +1 -0
- package/dist/context.js +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/icons-CZZENm5N.d.ts +20 -0
- package/dist/index.d.ts +55 -3
- package/dist/index.js +874 -293
- package/dist/index.js.map +1 -1
- package/dist/styles.css +33 -0
- package/dist/{ui-primitives-BCbe9Ds8.js → ui-primitives-BzbdVU2_.js} +12 -2
- package/dist/ui-primitives-BzbdVU2_.js.map +1 -0
- package/docs/publishing.md +5 -5
- package/package.json +1 -1
- package/dist/appearance-BUtKwRL5.d.ts +0 -34
- package/dist/labels-BM5o9a9K.js +0 -116
- package/dist/labels-BM5o9a9K.js.map +0 -1
- package/dist/labels-a_-_yLBi.d.ts +0 -195
- package/dist/ui-primitives-BCbe9Ds8.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
- Add slash-command skills, `@` page-element mention triggers, and a Gemini-style `+` composer menu (`detectComposerTrigger`, `replaceComposerTrigger`, `filterSkills`, `filterMentions`, `parseSkillMarkdown`, `slugifySkillName`, `useComposerTrigger`, `ChatSlashMenu`, `ChatMentionMenu`, `ChatPlusMenu`).
|
|
6
|
+
- Wire optional `skills`, `onSelectSkill`, `onAddSkill`, `onBrowseSkills`, `mentions`, `onSelectMention`, and `plusMenuActions` props into `ChatComposer` with bilingual labels (`zhCN` / `enUS`) and icons (`compass`, `scan`, `paperclip`, `layers`, `at`, `sliders`, `zap`).
|
|
7
|
+
|
|
8
|
+
## 0.8.0
|
|
9
|
+
|
|
10
|
+
- Add Cursor-style message branching and checkpoint revert primitives (`projectChatBranches`, `useChatBranches`, `ChatBranchSwitcher`, `ChatCheckpointBanner`), exported from both the root package and `/headless` (headless helpers).
|
|
11
|
+
- Add `branches`, `onSelectBranch`, `onRevertMessage`, `onBranchMessage`, and `renderUserMessageFooter` on `ChatMessages` / `ChatPanel`, along with bilingual labels (`zhCN` / `enUS`) and `chevronLeft` / `undo` / `branch` icons.
|
|
12
|
+
|
|
3
13
|
## 0.7.0
|
|
4
14
|
|
|
5
15
|
- Keep following streamed replies through consecutive layout changes. Deliberate upward scrolling still pauses following.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
GalaxyCore 通用 React AI 聊天组件。默认界面借鉴 Chrome AI 侧栏和 Codex 的消息阅读、工具状态与输入区布局,使用 Lucide 图标;支持完整面板、组合组件和 headless Hook。不同业务系统可分别适配文档、表格、图表或编辑器上下文,也可以使用自己的主题与组件库。
|
|
4
4
|
|
|
5
|
-
**当前版本:UI 包 0.
|
|
5
|
+
**当前版本:UI 包 0.8.0,网关包 0.2.0。** UI 提供平滑流式展示、历史会话菜单、消息撤回与分支切换、页面指向、语音输入、可部署示例和交互文档站。独立 Node 网关通过 pi core 实现流式文本、服务端工具调用、停止和持久化会话恢复。Codex 已预留运行时扩展接口,尚未实现其桥接。发布验收与真实模型联调状态见 [验证记录](docs/validation.md)。
|
|
6
6
|
|
|
7
7
|
## 本地运行
|
|
8
8
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { r as ChatIconName } from "./icons-CZZENm5N.js";
|
|
3
|
+
import { ButtonHTMLAttributes, ReactNode } from "react";
|
|
4
|
+
//#region src/ui-primitives.d.ts
|
|
5
|
+
interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
6
|
+
/** Accessible name; also used as the default tooltip. */
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: ChatIconName;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
size?: 'sm' | 'md';
|
|
11
|
+
variant?: 'ghost' | 'filled';
|
|
12
|
+
/** Set false to suppress the visual tooltip, or pass a more descriptive label. */
|
|
13
|
+
tooltip?: boolean | string;
|
|
14
|
+
}
|
|
15
|
+
/** Labelled native button with a viewport-safe tooltip. No wrapper affects host flex layouts. */
|
|
16
|
+
declare const ChatIconButton: import("react").ForwardRefExoticComponent<ChatIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ChatIconButtonProps as n, ChatIconButton as t };
|
|
19
|
+
//# sourceMappingURL=appearance-CCOHF5L-.d.ts.map
|
package/dist/appearance.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as ChatIconProps, i as ChatIconOverrides, n as ChatAppearanceProviderProps, o as Icon, r as ChatIconName, t as ChatAppearanceProvider } from "./icons-CZZENm5N.js";
|
|
3
|
+
import { n as ChatIconButtonProps, t as ChatIconButton } from "./appearance-CCOHF5L-.js";
|
|
3
4
|
export { ChatAppearanceProvider, type ChatAppearanceProviderProps, Icon as ChatIcon, ChatIconButton, type ChatIconButtonProps, type ChatIconName, type ChatIconOverrides, type ChatIconProps };
|
package/dist/appearance.js
CHANGED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
|
|
2
|
+
import { r as ChatIconName } from "./icons-CZZENm5N.js";
|
|
3
|
+
import { SpeechInputOptions } from "./voice.js";
|
|
4
|
+
import { UseChatHelpers, UseChatOptions } from "@ai-sdk/react";
|
|
5
|
+
import { HTMLAttributes, KeyboardEvent, ReactNode, Ref } from "react";
|
|
6
|
+
import { ChatRequestOptions, FileUIPart, UIMessage } from "ai";
|
|
7
|
+
//#region src/composer-triggers.d.ts
|
|
8
|
+
type ComposerTriggerKind = '/' | '@';
|
|
9
|
+
interface ComposerTriggerMatch {
|
|
10
|
+
trigger: ComposerTriggerKind;
|
|
11
|
+
query: string;
|
|
12
|
+
/** Inclusive index of the trigger character (`/` or `@`) in the draft string. */
|
|
13
|
+
start: number;
|
|
14
|
+
/** Exclusive end index (typically the current caret position). */
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
interface ChatSkillItem {
|
|
18
|
+
id: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
prompt: string;
|
|
23
|
+
/** Optional short emoji or ChatIconName displayed beside the skill name. */
|
|
24
|
+
icon?: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
sourceUrl?: string;
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
builtin?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface ParsedSkillMarkdown {
|
|
31
|
+
slug: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
prompt: string;
|
|
35
|
+
icon?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ChatMentionItem {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
group?: string;
|
|
42
|
+
kind?: string;
|
|
43
|
+
badge?: string;
|
|
44
|
+
keywords?: readonly string[];
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface ChatComposerMenuAction {
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
icon?: ChatIconName;
|
|
52
|
+
badge?: string;
|
|
53
|
+
trailing?: 'chevron' | 'check' | 'toggle';
|
|
54
|
+
checked?: boolean;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
section?: string;
|
|
57
|
+
onSelect?: () => void;
|
|
58
|
+
onToggle?: (next: boolean) => void;
|
|
59
|
+
}
|
|
60
|
+
declare function slugifySkillName(input: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Parse a SKILL.md document (YAML frontmatter + Markdown body) into editable skill fields.
|
|
63
|
+
* Never executes code; treats every field as plain text data.
|
|
64
|
+
*/
|
|
65
|
+
declare function parseSkillMarkdown(raw: string, fallbackName?: string): ParsedSkillMarkdown;
|
|
66
|
+
/**
|
|
67
|
+
* Detect an active `/` or `@` trigger immediately preceding `cursor`.
|
|
68
|
+
* Requires the trigger to appear at index 0 or immediately after whitespace so URLs and
|
|
69
|
+
* email addresses (e.g. `https://a/b`, `user@example.com`) do not open a popup.
|
|
70
|
+
*/
|
|
71
|
+
declare function detectComposerTrigger(value: string, cursor: number, triggers?: readonly ComposerTriggerKind[]): ComposerTriggerMatch | null;
|
|
72
|
+
declare function replaceComposerTrigger(value: string, match: ComposerTriggerMatch, replacement: string): {
|
|
73
|
+
value: string;
|
|
74
|
+
cursor: number;
|
|
75
|
+
};
|
|
76
|
+
declare function filterSkills(skills: readonly ChatSkillItem[], query: string): ChatSkillItem[];
|
|
77
|
+
declare function filterMentions(mentions: readonly ChatMentionItem[], query: string): ChatMentionItem[];
|
|
78
|
+
interface UseComposerTriggerOptions {
|
|
79
|
+
value: string;
|
|
80
|
+
cursor: number;
|
|
81
|
+
triggers?: readonly ComposerTriggerKind[];
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
itemCount: number;
|
|
84
|
+
onCommit?: (index: number, match: ComposerTriggerMatch) => void;
|
|
85
|
+
}
|
|
86
|
+
interface ComposerTriggerController {
|
|
87
|
+
match: ComposerTriggerMatch | null;
|
|
88
|
+
open: boolean;
|
|
89
|
+
activeIndex: number;
|
|
90
|
+
setActiveIndex: (index: number) => void;
|
|
91
|
+
dismiss: () => void;
|
|
92
|
+
/** Returns true when the trigger menu consumed the key event. */
|
|
93
|
+
handleKeyDown: (event: KeyboardEvent<HTMLTextAreaElement>) => boolean;
|
|
94
|
+
}
|
|
95
|
+
declare function useComposerTrigger({ value, cursor, triggers, enabled, itemCount, onCommit }: UseComposerTriggerOptions): ComposerTriggerController;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/types.d.ts
|
|
98
|
+
type AiChatController<M extends UIMessage = UIMessage> = UseChatHelpers<M> & {
|
|
99
|
+
isBusy: boolean;
|
|
100
|
+
};
|
|
101
|
+
type AiChatOptions<M extends UIMessage = UIMessage> = UseChatOptions<M>;
|
|
102
|
+
interface ChatLabels {
|
|
103
|
+
title: string;
|
|
104
|
+
assistant: string;
|
|
105
|
+
user: string;
|
|
106
|
+
placeholder: string;
|
|
107
|
+
send: string;
|
|
108
|
+
stop: string;
|
|
109
|
+
attach: string;
|
|
110
|
+
removeAttachment: string;
|
|
111
|
+
uploading: string;
|
|
112
|
+
uploadFailed: string;
|
|
113
|
+
tooManyFiles: string;
|
|
114
|
+
fileTooLarge: string;
|
|
115
|
+
fileNotAccepted: string;
|
|
116
|
+
emptyTitle: string;
|
|
117
|
+
emptyDescription: string;
|
|
118
|
+
thinking: string;
|
|
119
|
+
reasoning: string;
|
|
120
|
+
sources: string;
|
|
121
|
+
copy: string;
|
|
122
|
+
copied: string;
|
|
123
|
+
regenerate: string;
|
|
124
|
+
retry: string;
|
|
125
|
+
error: string;
|
|
126
|
+
dismiss: string;
|
|
127
|
+
jumpToLatest: string;
|
|
128
|
+
approve: string;
|
|
129
|
+
reject: string;
|
|
130
|
+
tool: string;
|
|
131
|
+
toolInput: string;
|
|
132
|
+
toolOutput: string;
|
|
133
|
+
toolPending: string;
|
|
134
|
+
toolRunning: string;
|
|
135
|
+
toolComplete: string;
|
|
136
|
+
toolFailed: string;
|
|
137
|
+
toolDenied: string;
|
|
138
|
+
toolApproval: string;
|
|
139
|
+
unsupportedPart: string;
|
|
140
|
+
disclaimer: string;
|
|
141
|
+
/** Optional additions keep existing complete locale objects compatible. */
|
|
142
|
+
toolWaiting?: string;
|
|
143
|
+
toolDetails?: string;
|
|
144
|
+
toolHideDetails?: string;
|
|
145
|
+
suggestions?: string;
|
|
146
|
+
composerHint?: string;
|
|
147
|
+
revert?: string;
|
|
148
|
+
branch?: string;
|
|
149
|
+
previousBranch?: string;
|
|
150
|
+
nextBranch?: string;
|
|
151
|
+
branchPosition?: string;
|
|
152
|
+
revertedBanner?: string;
|
|
153
|
+
restoreBranch?: string;
|
|
154
|
+
skillsMenu?: string;
|
|
155
|
+
addSkill?: string;
|
|
156
|
+
browseSkills?: string;
|
|
157
|
+
noMatchingSkills?: string;
|
|
158
|
+
mentionMenu?: string;
|
|
159
|
+
noMatchingMentions?: string;
|
|
160
|
+
plusMenu?: string;
|
|
161
|
+
}
|
|
162
|
+
interface ChatBranchInfo {
|
|
163
|
+
/** 1-based position among sibling branches at this point. */
|
|
164
|
+
index: number;
|
|
165
|
+
/** Total number of sibling branches at this point. */
|
|
166
|
+
count: number;
|
|
167
|
+
/** Previous sibling message or turn ID, if any. */
|
|
168
|
+
prevId?: string;
|
|
169
|
+
/** Next sibling message or turn ID, if any. */
|
|
170
|
+
nextId?: string;
|
|
171
|
+
}
|
|
172
|
+
type TextRenderer = (props: {
|
|
173
|
+
text: string;
|
|
174
|
+
isStreaming: boolean;
|
|
175
|
+
}) => ReactNode;
|
|
176
|
+
interface PartRendererProps<M extends UIMessage = UIMessage, P = M['parts'][number]> {
|
|
177
|
+
part: P;
|
|
178
|
+
message: M;
|
|
179
|
+
isStreaming: boolean;
|
|
180
|
+
chat: AiChatController<M>;
|
|
181
|
+
}
|
|
182
|
+
type PartRenderers<M extends UIMessage = UIMessage> = Partial<{ [T in M['parts'][number]['type']]: (props: PartRendererProps<M, Extract<M['parts'][number], {
|
|
183
|
+
type: T;
|
|
184
|
+
}>>) => ReactNode; }>;
|
|
185
|
+
type ToolPart<M extends UIMessage = UIMessage> = Extract<M['parts'][number], {
|
|
186
|
+
type: `tool-${string}` | 'dynamic-tool';
|
|
187
|
+
}>;
|
|
188
|
+
type ToolRenderers<M extends UIMessage = UIMessage> = Record<string, (props: PartRendererProps<M, ToolPart<M>>) => ReactNode>;
|
|
189
|
+
/** Customize the default activity row without replacing its states, details or approval controls. */
|
|
190
|
+
interface ToolPresentation {
|
|
191
|
+
title?: string;
|
|
192
|
+
/** Decorative, non-interactive icon. Runtime state indicators remain visible separately. */
|
|
193
|
+
icon?: ReactNode;
|
|
194
|
+
/** Short, host-authored context such as a file name or result count. Never HTML. */
|
|
195
|
+
summary?: string;
|
|
196
|
+
}
|
|
197
|
+
type ToolPresentationResolver<M extends UIMessage = UIMessage> = (props: PartRendererProps<M, ToolPart<M>>) => ToolPresentation | undefined;
|
|
198
|
+
interface ChatMessageActionContext<M extends UIMessage = UIMessage> {
|
|
199
|
+
message: M;
|
|
200
|
+
chat: AiChatController<M>;
|
|
201
|
+
/** Focus this panel's input without changing or sending its draft. */
|
|
202
|
+
focusComposer: () => void;
|
|
203
|
+
}
|
|
204
|
+
/** Host-authored actions; labels never become prompts automatically. */
|
|
205
|
+
interface ChatSuggestedAction<M extends UIMessage = UIMessage> {
|
|
206
|
+
id: string;
|
|
207
|
+
label: string;
|
|
208
|
+
icon?: ReactNode;
|
|
209
|
+
trailingIcon?: ReactNode;
|
|
210
|
+
emphasis?: 'recommended' | 'secondary' | 'quiet';
|
|
211
|
+
pendingLabel?: string;
|
|
212
|
+
disabled?: boolean;
|
|
213
|
+
onSelect: (context: ChatMessageActionContext<M>) => void | Promise<void>;
|
|
214
|
+
}
|
|
215
|
+
interface AttachmentOptions {
|
|
216
|
+
upload: (file: File, context: {
|
|
217
|
+
signal: AbortSignal;
|
|
218
|
+
}) => Promise<FileUIPart>;
|
|
219
|
+
/** Defaults to 5. */
|
|
220
|
+
maxFiles?: number;
|
|
221
|
+
/** Defaults to 10 MiB per file. */
|
|
222
|
+
maxSize?: number;
|
|
223
|
+
/** Same comma-separated syntax as an HTML file input's accept. */
|
|
224
|
+
accept?: string;
|
|
225
|
+
}
|
|
226
|
+
interface ChatComposerProps<M extends UIMessage = UIMessage> {
|
|
227
|
+
chat: AiChatController<M>;
|
|
228
|
+
labels?: Partial<ChatLabels>;
|
|
229
|
+
attachments?: AttachmentOptions;
|
|
230
|
+
/** Optional dictation adapter; transcripts are editable and never auto-sent. */
|
|
231
|
+
speech?: SpeechInputOptions;
|
|
232
|
+
/** Slash-triggered skills shown when typing `/` in the composer. */
|
|
233
|
+
skills?: readonly ChatSkillItem[];
|
|
234
|
+
onSelectSkill?: (skill: ChatSkillItem) => void;
|
|
235
|
+
onAddSkill?: () => void;
|
|
236
|
+
onBrowseSkills?: () => void;
|
|
237
|
+
/** `@`-triggered page/tab/element mentions shown when typing `@` in the composer. */
|
|
238
|
+
mentions?: readonly ChatMentionItem[];
|
|
239
|
+
onSelectMention?: (item: ChatMentionItem) => void;
|
|
240
|
+
/** Optional grouped actions opened from the composer `+` button instead of immediate file upload. */
|
|
241
|
+
plusMenuActions?: readonly ChatComposerMenuAction[];
|
|
242
|
+
toolbar?: ReactNode;
|
|
243
|
+
context?: ReactNode;
|
|
244
|
+
requestOptions?: ChatRequestOptions;
|
|
245
|
+
disabled?: boolean;
|
|
246
|
+
className?: string;
|
|
247
|
+
onActionError?: (error: Error) => void;
|
|
248
|
+
}
|
|
249
|
+
interface ChatScrollHandle {
|
|
250
|
+
/** Reveal a transcript target, pausing follow only when the message viewport moves. */
|
|
251
|
+
reveal(target: Element | Range): boolean;
|
|
252
|
+
}
|
|
253
|
+
interface ChatMessagesProps<M extends UIMessage = UIMessage> {
|
|
254
|
+
chat: AiChatController<M>;
|
|
255
|
+
labels?: Partial<ChatLabels>;
|
|
256
|
+
/** Overrides default assistant Markdown and literal user text rendering. */
|
|
257
|
+
renderText?: TextRenderer;
|
|
258
|
+
/** Smooth append-only assistant text in a short display buffer. Defaults to true.
|
|
259
|
+
* Does not change messages or tool events. Stop/completion and reduced motion flush immediately.
|
|
260
|
+
* Custom part renderers retain control of their own presentation. */
|
|
261
|
+
smoothStreaming?: boolean;
|
|
262
|
+
/** Optional access to programmatic navigation inside the message viewport. */
|
|
263
|
+
scrollRef?: Ref<ChatScrollHandle>;
|
|
264
|
+
renderers?: PartRenderers<M>;
|
|
265
|
+
tools?: ToolRenderers<M>;
|
|
266
|
+
toolPresentation?: ToolPresentationResolver<M>;
|
|
267
|
+
/** Only shown below the latest completed assistant message. At most three. */
|
|
268
|
+
suggestedActions?: readonly ChatSuggestedAction<M>[];
|
|
269
|
+
suggestionsTitle?: ReactNode;
|
|
270
|
+
suggestionsDescription?: ReactNode;
|
|
271
|
+
/** Inline confirmation/clarification content in the latest assistant turn. */
|
|
272
|
+
renderMessageActions?: (context: ChatMessageActionContext<M>) => ReactNode;
|
|
273
|
+
/** Custom footer rendered below each user message, replacing the default user action bar when set. */
|
|
274
|
+
renderUserMessageFooter?: (context: ChatMessageActionContext<M>) => ReactNode;
|
|
275
|
+
/** Sibling-branch metadata keyed by message ID for `< 1/2 >` navigation. */
|
|
276
|
+
branches?: Readonly<Record<string, ChatBranchInfo>>;
|
|
277
|
+
/** Called when the user switches to a sibling branch via `< 1/2 >`. */
|
|
278
|
+
onSelectBranch?: (messageId: string) => void;
|
|
279
|
+
/** Revert conversation checkpoint to immediately before this user message. */
|
|
280
|
+
onRevertMessage?: (message: M) => void | Promise<void>;
|
|
281
|
+
/** Fork or branch conversation from this message. */
|
|
282
|
+
onBranchMessage?: (message: M) => void | Promise<void>;
|
|
283
|
+
/** Return null to hide the default assistant identity; timestamps remain host-owned. */
|
|
284
|
+
renderMessageHeader?: (context: {
|
|
285
|
+
message: M;
|
|
286
|
+
isStreaming: boolean;
|
|
287
|
+
chat: AiChatController<M>;
|
|
288
|
+
}) => ReactNode;
|
|
289
|
+
empty?: ReactNode;
|
|
290
|
+
className?: string;
|
|
291
|
+
requestOptions?: ChatRequestOptions;
|
|
292
|
+
onActionError?: (error: Error) => void;
|
|
293
|
+
/** Hide operations unsupported by the connected runtime. */
|
|
294
|
+
capabilities?: {
|
|
295
|
+
regenerate?: boolean;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
interface ChatPanelProps<M extends UIMessage = UIMessage> extends Omit<HTMLAttributes<HTMLElement>, 'children'>, ChatMessagesProps<M> {
|
|
299
|
+
title?: string;
|
|
300
|
+
subtitle?: ReactNode;
|
|
301
|
+
headerIcon?: ReactNode;
|
|
302
|
+
header?: ReactNode;
|
|
303
|
+
headerActions?: ReactNode;
|
|
304
|
+
footer?: ReactNode;
|
|
305
|
+
composer?: ReactNode;
|
|
306
|
+
composerProps?: Omit<ChatComposerProps<M>, 'chat' | 'labels' | 'requestOptions' | 'onActionError'>;
|
|
307
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
308
|
+
variant?: 'panel' | 'sidebar' | 'embedded';
|
|
309
|
+
density?: 'comfortable' | 'compact';
|
|
310
|
+
}
|
|
311
|
+
interface AiChatProps<M extends UIMessage = UIMessage> extends Omit<ChatPanelProps<M>, 'chat'> {
|
|
312
|
+
options?: AiChatOptions<M>;
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/use-ai-chat.d.ts
|
|
316
|
+
/** Preserves the SDK's typed contract and throttles visual stream updates to 25 fps. */
|
|
317
|
+
declare function useAiChat<M extends UIMessage = UIMessage>(options?: AiChatOptions<M>): AiChatController<M>;
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/utils.d.ts
|
|
320
|
+
declare function getMessageText(message: UIMessage): string;
|
|
321
|
+
/** Only web URLs and same-origin paths. Never render model-supplied javascript/data links. */
|
|
322
|
+
declare function safeUrl(value: string | undefined): string | undefined;
|
|
323
|
+
declare function acceptsFile(file: Pick<File, 'name' | 'type'>, accept?: string): boolean;
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/labels.d.ts
|
|
326
|
+
declare const zhCN: Required<ChatLabels>;
|
|
327
|
+
declare const enUS: Required<ChatLabels>;
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/branches.d.ts
|
|
330
|
+
interface ProjectChatBranchesOptions<T extends {
|
|
331
|
+
id: string;
|
|
332
|
+
}> {
|
|
333
|
+
/**
|
|
334
|
+
* Resolve an item's parent ID:
|
|
335
|
+
* - `string`: explicit parent item ID
|
|
336
|
+
* - `null`: explicit root item (starts a root-level branch)
|
|
337
|
+
* - `undefined`: legacy linear item (chains after `items[index - 1]`)
|
|
338
|
+
*/
|
|
339
|
+
getParentId?: (item: T, index: number, items: readonly T[]) => string | null | undefined;
|
|
340
|
+
/** Selected child ID keyed by parent ID (`'__root__'` for root-level siblings). */
|
|
341
|
+
selections?: Readonly<Record<string, string>>;
|
|
342
|
+
/**
|
|
343
|
+
* Active head or checkpoint stop position:
|
|
344
|
+
* - `undefined`: follow selected/latest children to a leaf
|
|
345
|
+
* - `null`: reverted to the empty root before the first message
|
|
346
|
+
* - `string`: follow ancestors of this item, stopping at it when `stopAtHead` is true
|
|
347
|
+
*/
|
|
348
|
+
headId?: string | null;
|
|
349
|
+
/** When true and `headId` is provided, stop at `headId` instead of descending to its leaf. */
|
|
350
|
+
stopAtHead?: boolean;
|
|
351
|
+
}
|
|
352
|
+
interface ChatBranchProjection<T extends {
|
|
353
|
+
id: string;
|
|
354
|
+
}> {
|
|
355
|
+
messages: T[];
|
|
356
|
+
branches: Record<string, ChatBranchInfo>;
|
|
357
|
+
/** Last visible item ID on the active path, or `null` when empty / reverted to root. */
|
|
358
|
+
headId: string | null;
|
|
359
|
+
/** Root-level branch navigation when reverted before the first message. */
|
|
360
|
+
rootBranches?: ChatBranchInfo;
|
|
361
|
+
}
|
|
362
|
+
declare function projectChatBranches<T extends {
|
|
363
|
+
id: string;
|
|
364
|
+
}>(items: readonly T[], options?: ProjectChatBranchesOptions<T>): ChatBranchProjection<T>;
|
|
365
|
+
interface ChatBranchesState {
|
|
366
|
+
selections: Record<string, string>;
|
|
367
|
+
checkpoint?: {
|
|
368
|
+
afterId: string | null;
|
|
369
|
+
revertedMessageId?: string;
|
|
370
|
+
restoreLeafId: string | null;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
interface ChatBranchesController<T extends {
|
|
374
|
+
id: string;
|
|
375
|
+
}> extends ChatBranchProjection<T> {
|
|
376
|
+
/** Parent ID to attach to the next newly submitted user message (`null` when starting at root). */
|
|
377
|
+
nextParentId: string | null;
|
|
378
|
+
/** Message ID that was reverted to create the current checkpoint, if any. */
|
|
379
|
+
revertedMessageId?: string;
|
|
380
|
+
/** Whether a previous branch leaf can be restored after a revert/checkpoint action. */
|
|
381
|
+
canRestore: boolean;
|
|
382
|
+
/** Switch to the branch containing `messageId` and follow it to its leaf. */
|
|
383
|
+
selectBranch: (messageId: string) => void;
|
|
384
|
+
/** Revert the active view to immediately before `messageId`, keeping the old branch restorable. */
|
|
385
|
+
revertBefore: (messageId: string) => T | undefined;
|
|
386
|
+
/** Position the active view right after `messageId` so the next message branches from there. */
|
|
387
|
+
branchFrom: (messageId: string) => boolean;
|
|
388
|
+
/** Restore the branch leaf that was active before `revertBefore` or `branchFrom`. */
|
|
389
|
+
restore: () => void;
|
|
390
|
+
/** Clear any active checkpoint (call when submitting a new message from the checkpoint). */
|
|
391
|
+
commitFromCheckpoint: () => string | null;
|
|
392
|
+
}
|
|
393
|
+
declare function useChatBranches<T extends {
|
|
394
|
+
id: string;
|
|
395
|
+
}>(items: readonly T[], options?: Omit<ProjectChatBranchesOptions<T>, 'selections' | 'headId' | 'stopAtHead'>): ChatBranchesController<T>;
|
|
396
|
+
//#endregion
|
|
397
|
+
export { ToolPresentationResolver as A, detectComposerTrigger as B, ChatScrollHandle as C, TextRenderer as D, PartRenderers as E, ComposerTriggerController as F, slugifySkillName as G, filterSkills as H, ComposerTriggerKind as I, useComposerTrigger as K, ComposerTriggerMatch as L, ChatComposerMenuAction as M, ChatMentionItem as N, ToolPart as O, ChatSkillItem as P, ParsedSkillMarkdown as R, ChatPanelProps as S, PartRendererProps as T, parseSkillMarkdown as U, filterMentions as V, replaceComposerTrigger as W, ChatBranchInfo as _, projectChatBranches as a, ChatMessageActionContext as b, zhCN as c, safeUrl as d, useAiChat as f, AttachmentOptions as g, AiChatProps as h, ProjectChatBranchesOptions as i, ToolRenderers as j, ToolPresentation as k, acceptsFile as l, AiChatOptions as m, ChatBranchesController as n, useChatBranches as o, AiChatController as p, ChatBranchesState as r, enUS as s, ChatBranchProjection as t, getMessageText as u, ChatComposerProps as v, ChatSuggestedAction as w, ChatMessagesProps as x, ChatLabels as y, UseComposerTriggerOptions as z };
|
|
398
|
+
//# sourceMappingURL=branches-Dvdv5ug7.d.ts.map
|