@galaxycore/ai-chat 0.10.0 → 0.11.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 +12 -0
- package/dist/{appearance-Dpvr1osR.d.ts → appearance-CdnhPTwk.d.ts} +2 -2
- package/dist/appearance.d.ts +2 -2
- package/dist/appearance.js +1 -1
- package/dist/{branches-CUAJceMN.d.ts → branches-CZkkLIra.d.ts} +117 -3
- package/dist/{branches-CRxWPjfD.js → branches-asMPZLXd.js} +89 -2
- package/dist/branches-asMPZLXd.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-BkHI--R-.d.ts → icons-iagkwNls.d.ts} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +301 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +117 -1
- package/dist/{ui-primitives-XhFvDm8o.js → ui-primitives-CV3lrveW.js} +4 -2
- package/dist/ui-primitives-CV3lrveW.js.map +1 -0
- package/docs/api-reference.md +10 -2
- package/docs/publishing.md +5 -5
- package/package.json +1 -1
- package/dist/branches-CRxWPjfD.js.map +0 -1
- package/dist/ui-primitives-XhFvDm8o.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
- Add Cursor-style context-window utilization UI and inline context-compaction divider (`ChatContextUsage`, `ChatCompactionNotice`, `CHAT_CONTEXT_USAGE_TONES`, `formatChatTokens`, `resolveChatContextUsage`), exported from both the root package and `/headless` (headless helpers).
|
|
6
|
+
- Wire optional `contextUsage` prop into `ChatComposer` (and `ChatPanel` via `composerProps`), add optional `contextWindowTokens` on `ChatModelOption`, bilingual labels (`zhCN` / `enUS`), and `minus` / `minimize` icons.
|
|
7
|
+
|
|
8
|
+
## 0.10.1
|
|
9
|
+
|
|
10
|
+
- Ignore horizontal-dominant wheel gestures and sub-2px vertical jitter in `useMessageScroll`, and re-attach auto-follow on downward wheel/touch gestures when already at the bottom.
|
|
11
|
+
- Prevent scrollbar drags back to the bottom from re-pausing when a static jump-to-latest bar unmounts and clamps `scrollTop`.
|
|
12
|
+
- Anchor `appendedUser` detection on the last shared message ID and resume following when a run starts (`isBusy` transitions `false -> true`), so sending after transient tail cards disappear or retrying/regenerating reliably scrolls to the latest message.
|
|
13
|
+
- Expose `scrollToLatest()` on `ChatScrollHandle` alongside `reveal()`.
|
|
14
|
+
|
|
3
15
|
## 0.10.0
|
|
4
16
|
|
|
5
17
|
- Add reusable inline model and reasoning-effort selector (`ChatModelPicker`, `CHAT_REASONING_EFFORTS`, `isChatReasoningEffort`, `resolveChatModelSelection`, `selectChatModel`) exported from both the root package and `/headless` (headless helpers).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { r as ChatIconName } from "./icons-
|
|
2
|
+
import { r as ChatIconName } from "./icons-iagkwNls.js";
|
|
3
3
|
import { ButtonHTMLAttributes, ReactNode } from "react";
|
|
4
4
|
//#region src/ui-primitives.d.ts
|
|
5
5
|
interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
@@ -16,4 +16,4 @@ interface ChatIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
16
16
|
declare const ChatIconButton: import("react").ForwardRefExoticComponent<ChatIconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { ChatIconButtonProps as n, ChatIconButton as t };
|
|
19
|
-
//# sourceMappingURL=appearance-
|
|
19
|
+
//# sourceMappingURL=appearance-CdnhPTwk.d.ts.map
|
package/dist/appearance.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as ChatIconProps, i as ChatIconOverrides, n as ChatAppearanceProviderProps, o as Icon, r as ChatIconName, t as ChatAppearanceProvider } from "./icons-
|
|
3
|
-
import { n as ChatIconButtonProps, t as ChatIconButton } from "./appearance-
|
|
2
|
+
import { a as ChatIconProps, i as ChatIconOverrides, n as ChatAppearanceProviderProps, o as Icon, r as ChatIconName, t as ChatAppearanceProvider } from "./icons-iagkwNls.js";
|
|
3
|
+
import { n as ChatIconButtonProps, t as ChatIconButton } from "./appearance-CdnhPTwk.js";
|
|
4
4
|
export { ChatAppearanceProvider, type ChatAppearanceProviderProps, Icon as ChatIcon, ChatIconButton, type ChatIconButtonProps, type ChatIconName, type ChatIconOverrides, type ChatIconProps };
|
package/dist/appearance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { r as ChatIconName } from "./icons-
|
|
2
|
+
import { r as ChatIconName } from "./icons-iagkwNls.js";
|
|
3
3
|
import { SpeechInputOptions } from "./voice.js";
|
|
4
4
|
import { UseChatHelpers, UseChatOptions } from "@ai-sdk/react";
|
|
5
5
|
import { HTMLAttributes, KeyboardEvent, ReactNode, Ref } from "react";
|
|
@@ -94,6 +94,103 @@ interface ComposerTriggerController {
|
|
|
94
94
|
}
|
|
95
95
|
declare function useComposerTrigger({ value, cursor, triggers, enabled, itemCount, onCommit }: UseComposerTriggerOptions): ComposerTriggerController;
|
|
96
96
|
//#endregion
|
|
97
|
+
//#region src/context-usage.d.ts
|
|
98
|
+
declare const CHAT_CONTEXT_USAGE_TONES: readonly ['slate', 'violet', 'green', 'amber', 'magenta', 'blue', 'orange', 'teal'];
|
|
99
|
+
type ChatContextUsageTone = (typeof CHAT_CONTEXT_USAGE_TONES)[number];
|
|
100
|
+
type ChatContextUsageLevel = 'normal' | 'warn' | 'high';
|
|
101
|
+
interface ChatContextUsageSegment {
|
|
102
|
+
id: string;
|
|
103
|
+
label: string;
|
|
104
|
+
tokens: number;
|
|
105
|
+
tone?: ChatContextUsageTone;
|
|
106
|
+
}
|
|
107
|
+
interface ChatContextUsageData {
|
|
108
|
+
usedTokens: number;
|
|
109
|
+
contextWindowTokens: number;
|
|
110
|
+
/** Prefix displayed usage with `~` when the count is estimated. Defaults to true. */
|
|
111
|
+
estimated?: boolean;
|
|
112
|
+
/** Optional active model display label shown subtly beside the heading. */
|
|
113
|
+
modelLabel?: string;
|
|
114
|
+
/** Whether automatic context compaction occurred. */
|
|
115
|
+
compacted?: boolean;
|
|
116
|
+
/** Approximate tokens freed by automatic compaction. */
|
|
117
|
+
compactedSavedTokens?: number;
|
|
118
|
+
/** Number of compactions recorded in this turn or conversation. */
|
|
119
|
+
compactionCount?: number;
|
|
120
|
+
/** Per-category token breakdown displayed in the segmented meter and legend. */
|
|
121
|
+
segments?: readonly ChatContextUsageSegment[];
|
|
122
|
+
}
|
|
123
|
+
interface ResolveChatContextUsageOptions {
|
|
124
|
+
/** Percentage threshold at which usage switches to the warning tone. Defaults to 60. */
|
|
125
|
+
warnThreshold?: number;
|
|
126
|
+
/** Percentage threshold at which usage switches to the high/danger tone. Defaults to 85. */
|
|
127
|
+
highThreshold?: number;
|
|
128
|
+
}
|
|
129
|
+
interface ResolvedChatContextUsageSegment extends ChatContextUsageSegment {
|
|
130
|
+
tone: ChatContextUsageTone;
|
|
131
|
+
}
|
|
132
|
+
interface ResolvedChatContextUsage {
|
|
133
|
+
usedTokens: number;
|
|
134
|
+
contextWindowTokens: number;
|
|
135
|
+
ratio: number;
|
|
136
|
+
percent: number;
|
|
137
|
+
fillPercent: number;
|
|
138
|
+
level: ChatContextUsageLevel;
|
|
139
|
+
estimated: boolean;
|
|
140
|
+
usedFormatted: string;
|
|
141
|
+
windowFormatted: string;
|
|
142
|
+
usedDisplay: string;
|
|
143
|
+
visibleSegments: readonly ResolvedChatContextUsageSegment[];
|
|
144
|
+
compacted: boolean;
|
|
145
|
+
compactedSavedTokens: number;
|
|
146
|
+
compactionCount: number;
|
|
147
|
+
modelLabel?: string;
|
|
148
|
+
}
|
|
149
|
+
/** Compact human-readable token count (e.g. `1.6K`, `103.5K`, `256K`, `1M`). */
|
|
150
|
+
declare function formatChatTokens(tokens: number): string;
|
|
151
|
+
/**
|
|
152
|
+
* Normalizes raw context-window utilization numbers into bounded display metrics, warning
|
|
153
|
+
* levels, and tone-resolved visible segments for `ChatContextUsage` or custom headless UIs.
|
|
154
|
+
*/
|
|
155
|
+
declare function resolveChatContextUsage(usage: ChatContextUsageData, options?: ResolveChatContextUsageOptions): ResolvedChatContextUsage;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/context-usage-control.d.ts
|
|
158
|
+
interface ChatContextUsageProps extends ChatContextUsageData {
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
/** Percentage threshold for warning color. Defaults to 60. */
|
|
161
|
+
warnThreshold?: number;
|
|
162
|
+
/** Percentage threshold for high/danger color. Defaults to 85. */
|
|
163
|
+
highThreshold?: number;
|
|
164
|
+
/** Optional secondary action rendered beside the title in the popover header. */
|
|
165
|
+
headerAction?: ReactNode;
|
|
166
|
+
/** Controlled popover open state. */
|
|
167
|
+
open?: boolean;
|
|
168
|
+
/** Initial popover open state when uncontrolled. */
|
|
169
|
+
defaultOpen?: boolean;
|
|
170
|
+
onOpenChange?: (open: boolean) => void;
|
|
171
|
+
labels?: Partial<ChatLabels>;
|
|
172
|
+
className?: string;
|
|
173
|
+
popoverClassName?: string;
|
|
174
|
+
}
|
|
175
|
+
interface ChatCompactionNoticeProps {
|
|
176
|
+
status: 'running' | 'done';
|
|
177
|
+
beforeTokens?: number;
|
|
178
|
+
afterTokens?: number;
|
|
179
|
+
savedTokens?: number;
|
|
180
|
+
labels?: Partial<ChatLabels>;
|
|
181
|
+
className?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Circular context-window utilization indicator for chat composers, opening a Cursor-style
|
|
185
|
+
* segmented per-category token breakdown panel anchored above the composer.
|
|
186
|
+
*/
|
|
187
|
+
declare function ChatContextUsage({ usedTokens, contextWindowTokens, estimated, modelLabel, compacted, compactedSavedTokens, compactionCount, segments, disabled, warnThreshold, highThreshold, headerAction, open: controlledOpen, defaultOpen, onOpenChange, labels: overrides, className, popoverClassName }: ChatContextUsageProps): import("react").JSX.Element;
|
|
188
|
+
/**
|
|
189
|
+
* Calm inline horizontal divider rendered in the conversation stream when automatic
|
|
190
|
+
* context compaction is running or completed on a turn.
|
|
191
|
+
*/
|
|
192
|
+
declare function ChatCompactionNotice({ status, beforeTokens, afterTokens, savedTokens, labels: overrides, className }: ChatCompactionNoticeProps): import("react").JSX.Element;
|
|
193
|
+
//#endregion
|
|
97
194
|
//#region src/model-picker.d.ts
|
|
98
195
|
declare const CHAT_REASONING_EFFORTS: readonly ['none', 'low', 'medium', 'high', 'xhigh'];
|
|
99
196
|
type ChatReasoningEffort = (typeof CHAT_REASONING_EFFORTS)[number];
|
|
@@ -111,6 +208,8 @@ interface ChatModelOption {
|
|
|
111
208
|
reasoningEfforts?: readonly ChatReasoningEffort[];
|
|
112
209
|
/** Default reasoning effort when switching to this model without an explicit effort. */
|
|
113
210
|
defaultReasoningEffort?: ChatReasoningEffort;
|
|
211
|
+
/** Optional context-window size in tokens, useful when pairing with `ChatContextUsage`. */
|
|
212
|
+
contextWindowTokens?: number;
|
|
114
213
|
disabled?: boolean;
|
|
115
214
|
}
|
|
116
215
|
interface ChatModelSelection {
|
|
@@ -222,6 +321,17 @@ interface ChatLabels {
|
|
|
222
321
|
reasoningMedium?: string;
|
|
223
322
|
reasoningHigh?: string;
|
|
224
323
|
reasoningXhigh?: string;
|
|
324
|
+
contextUsage?: string;
|
|
325
|
+
contextUsageClose?: string;
|
|
326
|
+
contextUsagePercent?: string;
|
|
327
|
+
contextUsageTokens?: string;
|
|
328
|
+
contextUsageEmpty?: string;
|
|
329
|
+
contextUsageTrigger?: string;
|
|
330
|
+
contextUsageSegment?: string;
|
|
331
|
+
contextCompacting?: string;
|
|
332
|
+
contextCompacted?: string;
|
|
333
|
+
contextCompactedSaved?: string;
|
|
334
|
+
contextCompactedRange?: string;
|
|
225
335
|
}
|
|
226
336
|
interface ChatBranchInfo {
|
|
227
337
|
/** 1-based position among sibling branches at this point. */
|
|
@@ -305,6 +415,8 @@ interface ChatComposerProps<M extends UIMessage = UIMessage> {
|
|
|
305
415
|
plusMenuActions?: readonly ChatComposerMenuAction[];
|
|
306
416
|
/** Optional inline model and reasoning-effort selector rendered beside composer actions. */
|
|
307
417
|
modelPicker?: Omit<ChatModelPickerProps, 'labels'>;
|
|
418
|
+
/** Optional circular context-window utilization indicator and breakdown popover. */
|
|
419
|
+
contextUsage?: Omit<ChatContextUsageProps, 'labels'>;
|
|
308
420
|
toolbar?: ReactNode;
|
|
309
421
|
context?: ReactNode;
|
|
310
422
|
requestOptions?: ChatRequestOptions;
|
|
@@ -315,6 +427,8 @@ interface ChatComposerProps<M extends UIMessage = UIMessage> {
|
|
|
315
427
|
interface ChatScrollHandle {
|
|
316
428
|
/** Reveal a transcript target, pausing follow only when the message viewport moves. */
|
|
317
429
|
reveal(target: Element | Range): boolean;
|
|
430
|
+
/** Resume following and scroll immediately to the latest message. */
|
|
431
|
+
scrollToLatest(): void;
|
|
318
432
|
}
|
|
319
433
|
interface ChatMessagesProps<M extends UIMessage = UIMessage> {
|
|
320
434
|
chat: AiChatController<M>;
|
|
@@ -460,5 +574,5 @@ declare function useChatBranches<T extends {
|
|
|
460
574
|
id: string;
|
|
461
575
|
}>(items: readonly T[], options?: Omit<ProjectChatBranchesOptions<T>, 'selections' | 'headId' | 'stopAtHead'>): ChatBranchesController<T>;
|
|
462
576
|
//#endregion
|
|
463
|
-
export {
|
|
464
|
-
//# sourceMappingURL=branches-
|
|
577
|
+
export { ResolvedChatContextUsageSegment as $, ToolPresentationResolver as A, resolveChatModelSelection as B, ChatScrollHandle as C, TextRenderer as D, PartRenderers as E, ChatModelOption as F, ChatContextUsageProps as G, ChatCompactionNotice as H, ChatModelSelection as I, ChatContextUsageLevel as J, CHAT_CONTEXT_USAGE_TONES as K, ChatReasoningEffort as L, ChatModelPicker as M, ChatModelPickerProps as N, ToolPart as O, CHAT_REASONING_EFFORTS as P, ResolvedChatContextUsage as Q, ResolvedChatModelSelection as R, ChatPanelProps as S, PartRendererProps as T, ChatCompactionNoticeProps as U, selectChatModel as V, ChatContextUsage as W, ChatContextUsageTone as X, ChatContextUsageSegment as Y, ResolveChatContextUsageOptions as Z, ChatBranchInfo as _, projectChatBranches as a, ComposerTriggerController as at, ChatMessageActionContext as b, zhCN as c, ParsedSkillMarkdown as ct, safeUrl as d, filterMentions as dt, formatChatTokens as et, useAiChat as f, filterSkills as ft, AttachmentOptions as g, useComposerTrigger as gt, AiChatProps as h, slugifySkillName as ht, ProjectChatBranchesOptions as i, ChatSkillItem as it, ToolRenderers as j, ToolPresentation as k, acceptsFile as l, UseComposerTriggerOptions as lt, AiChatOptions as m, replaceComposerTrigger as mt, ChatBranchesController as n, ChatComposerMenuAction as nt, useChatBranches as o, ComposerTriggerKind as ot, AiChatController as p, parseSkillMarkdown as pt, ChatContextUsageData as q, ChatBranchesState as r, ChatMentionItem as rt, enUS as s, ComposerTriggerMatch as st, ChatBranchProjection as t, resolveChatContextUsage as tt, getMessageText as u, detectComposerTrigger as ut, ChatComposerProps as v, ChatSuggestedAction as w, ChatMessagesProps as x, ChatLabels as y, isChatReasoningEffort as z };
|
|
578
|
+
//# sourceMappingURL=branches-CZkkLIra.d.ts.map
|
|
@@ -79,6 +79,17 @@ const zhCN = {
|
|
|
79
79
|
reasoningMedium: "中",
|
|
80
80
|
reasoningHigh: "高",
|
|
81
81
|
reasoningXhigh: "极高",
|
|
82
|
+
contextUsage: "上下文使用情况",
|
|
83
|
+
contextUsageClose: "关闭上下文使用情况",
|
|
84
|
+
contextUsagePercent: "已使用 {percent}%",
|
|
85
|
+
contextUsageTokens: "{used} / {window} Tokens",
|
|
86
|
+
contextUsageEmpty: "发送首条消息后将展示各部分上下文占用明细。",
|
|
87
|
+
contextUsageTrigger: "上下文使用情况:已占用 {percent}%({used} / {window} Tokens)",
|
|
88
|
+
contextUsageSegment: "{label}:{tokens} Tokens",
|
|
89
|
+
contextCompacting: "正在自动压缩对话上下文…",
|
|
90
|
+
contextCompacted: "已自动压缩上下文",
|
|
91
|
+
contextCompactedSaved: "已自动压缩上下文 · 释放约 {saved} Tokens",
|
|
92
|
+
contextCompactedRange: "已自动压缩上下文 · {before} → {after}",
|
|
82
93
|
unsupportedPart: "此内容需要自定义渲染器",
|
|
83
94
|
disclaimer: "AI 生成的内容可能不准确,请核实重要信息。"
|
|
84
95
|
};
|
|
@@ -146,6 +157,17 @@ const enUS = {
|
|
|
146
157
|
reasoningMedium: "Med",
|
|
147
158
|
reasoningHigh: "High",
|
|
148
159
|
reasoningXhigh: "Max",
|
|
160
|
+
contextUsage: "Context Usage",
|
|
161
|
+
contextUsageClose: "Close context usage",
|
|
162
|
+
contextUsagePercent: "{percent}% Full",
|
|
163
|
+
contextUsageTokens: "{used} / {window} Tokens",
|
|
164
|
+
contextUsageEmpty: "Context breakdown will appear after the first reply.",
|
|
165
|
+
contextUsageTrigger: "Context usage: {percent}% full ({used} / {window} tokens)",
|
|
166
|
+
contextUsageSegment: "{label}: {tokens} tokens",
|
|
167
|
+
contextCompacting: "Compacting conversation context…",
|
|
168
|
+
contextCompacted: "Context automatically compacted",
|
|
169
|
+
contextCompactedSaved: "Context compacted · Freed ~{saved} tokens",
|
|
170
|
+
contextCompactedRange: "Context compacted · {before} → {after}",
|
|
149
171
|
unsupportedPart: "This content requires a custom renderer",
|
|
150
172
|
disclaimer: "AI can make mistakes. Verify important information."
|
|
151
173
|
};
|
|
@@ -349,6 +371,71 @@ function useComposerTrigger({ value, cursor, triggers = ["/", "@"], enabled = tr
|
|
|
349
371
|
};
|
|
350
372
|
}
|
|
351
373
|
//#endregion
|
|
374
|
+
//#region src/context-usage.ts
|
|
375
|
+
const CHAT_CONTEXT_USAGE_TONES = [
|
|
376
|
+
"slate",
|
|
377
|
+
"violet",
|
|
378
|
+
"green",
|
|
379
|
+
"amber",
|
|
380
|
+
"magenta",
|
|
381
|
+
"blue",
|
|
382
|
+
"orange",
|
|
383
|
+
"teal"
|
|
384
|
+
];
|
|
385
|
+
/** Compact human-readable token count (e.g. `1.6K`, `103.5K`, `256K`, `1M`). */
|
|
386
|
+
function formatChatTokens(tokens) {
|
|
387
|
+
const safe = Number.isFinite(tokens) ? Math.max(0, Math.round(tokens)) : 0;
|
|
388
|
+
if (safe >= 1e6) return `${(safe / 1e6).toFixed(1).replace(/\.0$/, "")}M`;
|
|
389
|
+
if (safe >= 1e3) return `${(safe / 1e3).toFixed(1).replace(/\.0$/, "")}K`;
|
|
390
|
+
return String(safe);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Normalizes raw context-window utilization numbers into bounded display metrics, warning
|
|
394
|
+
* levels, and tone-resolved visible segments for `ChatContextUsage` or custom headless UIs.
|
|
395
|
+
*/
|
|
396
|
+
function resolveChatContextUsage(usage, options = {}) {
|
|
397
|
+
const warnThreshold = options.warnThreshold ?? 60;
|
|
398
|
+
const highThreshold = options.highThreshold ?? 85;
|
|
399
|
+
const contextWindowTokens = Number.isFinite(usage.contextWindowTokens) && usage.contextWindowTokens > 0 ? Math.round(usage.contextWindowTokens) : 1;
|
|
400
|
+
const usedTokens = Number.isFinite(usage.usedTokens) && usage.usedTokens > 0 ? Math.round(usage.usedTokens) : 0;
|
|
401
|
+
const ratio = Math.min(1, usedTokens / contextWindowTokens);
|
|
402
|
+
const fillPercent = ratio * 100;
|
|
403
|
+
const percent = Math.min(100, Math.round(fillPercent));
|
|
404
|
+
const level = percent >= highThreshold ? "high" : percent >= warnThreshold ? "warn" : "normal";
|
|
405
|
+
const estimated = usage.estimated ?? true;
|
|
406
|
+
const usedFormatted = formatChatTokens(usedTokens);
|
|
407
|
+
const windowFormatted = formatChatTokens(contextWindowTokens);
|
|
408
|
+
const usedDisplay = estimated && usedTokens > 0 ? `~${usedFormatted}` : usedFormatted;
|
|
409
|
+
const visibleSegments = [];
|
|
410
|
+
(usage.segments ?? []).forEach((segment, index) => {
|
|
411
|
+
const tokens = Number.isFinite(segment.tokens) ? Math.round(segment.tokens) : 0;
|
|
412
|
+
if (tokens <= 0) return;
|
|
413
|
+
visibleSegments.push({
|
|
414
|
+
id: segment.id,
|
|
415
|
+
label: segment.label,
|
|
416
|
+
tokens,
|
|
417
|
+
tone: segment.tone ?? CHAT_CONTEXT_USAGE_TONES[index % CHAT_CONTEXT_USAGE_TONES.length]
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
return {
|
|
421
|
+
usedTokens,
|
|
422
|
+
contextWindowTokens,
|
|
423
|
+
ratio,
|
|
424
|
+
percent,
|
|
425
|
+
fillPercent,
|
|
426
|
+
level,
|
|
427
|
+
estimated,
|
|
428
|
+
usedFormatted,
|
|
429
|
+
windowFormatted,
|
|
430
|
+
usedDisplay,
|
|
431
|
+
visibleSegments,
|
|
432
|
+
compacted: Boolean(usage.compacted),
|
|
433
|
+
compactedSavedTokens: Number.isFinite(usage.compactedSavedTokens) && (usage.compactedSavedTokens ?? 0) > 0 ? Math.round(usage.compactedSavedTokens) : 0,
|
|
434
|
+
compactionCount: Number.isFinite(usage.compactionCount) && (usage.compactionCount ?? 0) > 0 ? Math.round(usage.compactionCount) : 0,
|
|
435
|
+
modelLabel: usage.modelLabel
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
352
439
|
//#region src/model-picker.ts
|
|
353
440
|
const CHAT_REASONING_EFFORTS = [
|
|
354
441
|
"none",
|
|
@@ -598,6 +685,6 @@ function useChatBranches(items, options = {}) {
|
|
|
598
685
|
};
|
|
599
686
|
}
|
|
600
687
|
//#endregion
|
|
601
|
-
export {
|
|
688
|
+
export { enUS as _, resolveChatModelSelection as a, useAiChat as b, formatChatTokens as c, filterMentions as d, filterSkills as f, useComposerTrigger as g, slugifySkillName as h, isChatReasoningEffort as i, resolveChatContextUsage as l, replaceComposerTrigger as m, useChatBranches as n, selectChatModel as o, parseSkillMarkdown as p, CHAT_REASONING_EFFORTS as r, CHAT_CONTEXT_USAGE_TONES as s, projectChatBranches as t, detectComposerTrigger as u, resolveLabels as v, zhCN as y };
|
|
602
689
|
|
|
603
|
-
//# sourceMappingURL=branches-
|
|
690
|
+
//# sourceMappingURL=branches-asMPZLXd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branches-asMPZLXd.js","names":[],"sources":["../src/use-ai-chat.ts","../src/labels.ts","../src/composer-triggers.ts","../src/context-usage.ts","../src/model-picker.ts","../src/branches.ts"],"sourcesContent":["\"use client\";\n\nimport { useChat } from '@ai-sdk/react';\nimport type { UIMessage } from 'ai';\nimport type { AiChatController, AiChatOptions } from './types';\n\n/** Preserves the SDK's typed contract and throttles visual stream updates to 25 fps. */\nexport function useAiChat<M extends UIMessage = UIMessage>(options: AiChatOptions<M> = {}): AiChatController<M> {\n const chat = useChat<M>({ throttle: 40, ...options });\n return { ...chat, isBusy: chat.status === 'submitted' || chat.status === 'streaming' };\n}\n","import type { ChatLabels } from './types';\n\nexport const zhCN: Required<ChatLabels> = {\n title: 'AI 助手', assistant: '助手', user: '你', placeholder: '输入消息,与 AI 一起探索',\n send: '发送消息', stop: '停止生成', attach: '添加附件', removeAttachment: '移除附件',\n uploading: '上传中', uploadFailed: '附件上传失败,请重新添加', tooManyFiles: '附件数量超过限制',\n fileTooLarge: '文件大小超过限制', fileNotAccepted: '不支持此文件类型',\n emptyTitle: '有什么可以帮你?', emptyDescription: '整理思路、理解资料,或从一个问题开始。',\n thinking: '正在思考', reasoning: '思考过程', sources: '参考来源', copy: '复制回答', copied: '已复制',\n regenerate: '重新生成', retry: '重试', error: '暂时无法完成回答,请重试。', dismiss: '关闭提示',\n jumpToLatest: '回到最新消息', approve: '允许', reject: '拒绝', tool: '工具调用', toolInput: '输入',\n toolOutput: '结果', toolPending: '准备中', toolRunning: '执行中', toolComplete: '已完成',\n toolFailed: '执行失败', toolDenied: '已拒绝', toolApproval: '等待你的确认',\n toolWaiting: '等待结果', toolDetails: '展开详情', toolHideDetails: '收起详情',\n suggestions: '接下来可以', composerHint: 'Enter 发送 · Shift + Enter 换行',\n revert: '撤回', branch: '分支对话',\n previousBranch: '上一分支', nextBranch: '下一分支', branchPosition: '分支 {current}/{total}',\n revertedBanner: '已撤回到此消息之前', restoreBranch: '恢复',\n skillsMenu: '技能菜单', addSkill: '添加技能', browseSkills: '浏览与管理技能',\n noMatchingSkills: '没有匹配的技能',\n mentionMenu: '提及页面元素', noMatchingMentions: '没有匹配的页面元素',\n plusMenu: '添加内容与工具',\n selectModel: '选择模型', reasoningEffort: '推理能力', reasoningDefault: '默认',\n reasoningNone: '关闭', reasoningLow: '低', reasoningMedium: '中', reasoningHigh: '高', reasoningXhigh: '极高',\n contextUsage: '上下文使用情况', contextUsageClose: '关闭上下文使用情况',\n contextUsagePercent: '已使用 {percent}%', contextUsageTokens: '{used} / {window} Tokens',\n contextUsageEmpty: '发送首条消息后将展示各部分上下文占用明细。',\n contextUsageTrigger: '上下文使用情况:已占用 {percent}%({used} / {window} Tokens)',\n contextUsageSegment: '{label}:{tokens} Tokens',\n contextCompacting: '正在自动压缩对话上下文…',\n contextCompacted: '已自动压缩上下文',\n contextCompactedSaved: '已自动压缩上下文 · 释放约 {saved} Tokens',\n contextCompactedRange: '已自动压缩上下文 · {before} → {after}',\n unsupportedPart: '此内容需要自定义渲染器', disclaimer: 'AI 生成的内容可能不准确,请核实重要信息。',\n};\n\nexport const enUS: Required<ChatLabels> = {\n title: 'AI assistant', assistant: 'Assistant', user: 'You', placeholder: 'Ask a question or explore an idea',\n send: 'Send message', stop: 'Stop generating', attach: 'Attach files', removeAttachment: 'Remove attachment',\n uploading: 'Uploading', uploadFailed: 'Upload failed. Please attach the file again.', tooManyFiles: 'Too many attachments',\n fileTooLarge: 'File exceeds the size limit', fileNotAccepted: 'File type is not supported',\n emptyTitle: 'How can I help?', emptyDescription: 'Make sense of your documents, explore ideas, or start with a question.',\n thinking: 'Thinking', reasoning: 'Reasoning', sources: 'Sources', copy: 'Copy response', copied: 'Copied',\n regenerate: 'Regenerate', retry: 'Retry', error: 'Unable to complete the response. Please try again.', dismiss: 'Dismiss',\n jumpToLatest: 'Jump to latest', approve: 'Approve', reject: 'Deny', tool: 'Tool call', toolInput: 'Input',\n toolOutput: 'Result', toolPending: 'Preparing', toolRunning: 'Running', toolComplete: 'Completed',\n toolFailed: 'Failed', toolDenied: 'Denied', toolApproval: 'Waiting for your approval',\n toolWaiting: 'Awaiting result', toolDetails: 'Show details', toolHideDetails: 'Hide details',\n suggestions: 'Suggested next steps', composerHint: 'Enter to send · Shift + Enter for a new line',\n revert: 'Revert', branch: 'Branch chat',\n previousBranch: 'Previous branch', nextBranch: 'Next branch', branchPosition: 'Branch {current} of {total}',\n revertedBanner: 'Reverted before this message', restoreBranch: 'Restore',\n skillsMenu: 'Skills menu', addSkill: 'Add skill', browseSkills: 'Browse & manage skills',\n noMatchingSkills: 'No matching skills',\n mentionMenu: 'Mention page elements', noMatchingMentions: 'No matching page elements',\n plusMenu: 'Add context and tools',\n selectModel: 'Model', reasoningEffort: 'Reasoning', reasoningDefault: 'Auto',\n reasoningNone: 'Off', reasoningLow: 'Low', reasoningMedium: 'Med', reasoningHigh: 'High', reasoningXhigh: 'Max',\n contextUsage: 'Context Usage', contextUsageClose: 'Close context usage',\n contextUsagePercent: '{percent}% Full', contextUsageTokens: '{used} / {window} Tokens',\n contextUsageEmpty: 'Context breakdown will appear after the first reply.',\n contextUsageTrigger: 'Context usage: {percent}% full ({used} / {window} tokens)',\n contextUsageSegment: '{label}: {tokens} tokens',\n contextCompacting: 'Compacting conversation context…',\n contextCompacted: 'Context automatically compacted',\n contextCompactedSaved: 'Context compacted · Freed ~{saved} tokens',\n contextCompactedRange: 'Context compacted · {before} → {after}',\n unsupportedPart: 'This content requires a custom renderer', disclaimer: 'AI can make mistakes. Verify important information.',\n};\n\nexport function resolveLabels(overrides?: Partial<ChatLabels>): Required<ChatLabels> {\n return { ...zhCN, ...overrides };\n}\n","import { useCallback, useEffect, useState } from 'react';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport type { ChatIconName } from './icons';\n\nexport type ComposerTriggerKind = '/' | '@';\n\nexport interface ComposerTriggerMatch {\n trigger: ComposerTriggerKind;\n query: string;\n /** Inclusive index of the trigger character (`/` or `@`) in the draft string. */\n start: number;\n /** Exclusive end index (typically the current caret position). */\n end: number;\n}\n\nexport interface ChatSkillItem {\n id: string;\n slug: string;\n name: string;\n description?: string;\n prompt: string;\n /** Optional short emoji or ChatIconName displayed beside the skill name. */\n icon?: string;\n source?: string;\n sourceUrl?: string;\n enabled?: boolean;\n builtin?: boolean;\n}\n\nexport interface ParsedSkillMarkdown {\n slug: string;\n name: string;\n description: string;\n prompt: string;\n icon?: string;\n}\n\nexport interface ChatMentionItem {\n id: string;\n label: string;\n description?: string;\n group?: string;\n kind?: string;\n badge?: string;\n keywords?: readonly string[];\n disabled?: boolean;\n}\n\nexport interface ChatComposerMenuAction {\n id: string;\n label: string;\n description?: string;\n icon?: ChatIconName;\n badge?: string;\n trailing?: 'chevron' | 'check' | 'toggle';\n checked?: boolean;\n disabled?: boolean;\n section?: string;\n onSelect?: () => void;\n onToggle?: (next: boolean) => void;\n}\n\nexport function slugifySkillName(input: string): string {\n const ascii = input\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 48);\n return ascii || 'custom-skill';\n}\n\nfunction unquoteYaml(raw: string): string {\n const trimmed = raw.trim();\n if (trimmed.length >= 2) {\n const first = trimmed[0];\n const last = trimmed[trimmed.length - 1];\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return trimmed.slice(1, -1).trim();\n }\n }\n return trimmed;\n}\n\n/**\n * Parse a SKILL.md document (YAML frontmatter + Markdown body) into editable skill fields.\n * Never executes code; treats every field as plain text data.\n */\nexport function parseSkillMarkdown(raw: string, fallbackName?: string): ParsedSkillMarkdown {\n const normalized = raw.replace(/\\r\\n?/g, '\\n').trim();\n const fields: Record<string, string> = {};\n let body = normalized;\n\n const frontmatter = /^---\\n([\\s\\S]*?)\\n---\\n?([\\s\\S]*)$/.exec(normalized);\n if (frontmatter) {\n const head = frontmatter[1] ?? '';\n body = (frontmatter[2] ?? '').trim();\n for (const line of head.split('\\n')) {\n const separator = line.indexOf(':');\n if (separator <= 0) continue;\n const key = line.slice(0, separator).trim().toLowerCase();\n const value = unquoteYaml(line.slice(separator + 1));\n if (key && value && !(key in fields)) fields[key] = value;\n }\n }\n\n let headingTitle = '';\n if (!fields.title && !fields.name) {\n const heading = /^#\\s+(.+)$/m.exec(body);\n if (heading?.[1]) headingTitle = heading[1].trim();\n }\n\n const rawName = fields.title || fields.name || headingTitle || fallbackName?.trim() || 'Custom skill';\n const slugSource = fields.slug || fields.name || rawName;\n const description = fields.description || '';\n const prompt = (body || normalized).slice(0, 4000);\n const icon = fields.icon ? fields.icon.slice(0, 16) : undefined;\n\n return {\n slug: slugifySkillName(slugSource),\n name: rawName.slice(0, 80),\n description: description.slice(0, 240),\n prompt,\n ...(icon ? { icon } : {}),\n };\n}\n\n/**\n * Detect an active `/` or `@` trigger immediately preceding `cursor`.\n * Requires the trigger to appear at index 0 or immediately after whitespace so URLs and\n * email addresses (e.g. `https://a/b`, `user@example.com`) do not open a popup.\n */\nexport function detectComposerTrigger(\n value: string,\n cursor: number,\n triggers: readonly ComposerTriggerKind[] = ['/', '@'],\n): ComposerTriggerMatch | null {\n if (!triggers.length || cursor <= 0 || cursor > value.length) return null;\n const before = value.slice(0, cursor);\n for (let index = before.length - 1; index >= 0; index -= 1) {\n const char = before[index];\n if (char === undefined) break;\n if (/\\s/.test(char)) return null;\n if ((char === '/' || char === '@') && triggers.includes(char)) {\n if (index > 0 && !/\\s/.test(before[index - 1] ?? '')) return null;\n return {\n trigger: char,\n query: before.slice(index + 1),\n start: index,\n end: cursor,\n };\n }\n }\n return null;\n}\n\nexport function replaceComposerTrigger(\n value: string,\n match: ComposerTriggerMatch,\n replacement: string,\n): { value: string; cursor: number } {\n const prefix = value.slice(0, match.start);\n const suffix = value.slice(match.end);\n const nextValue = `${prefix}${replacement}${suffix}`;\n return { value: nextValue, cursor: prefix.length + replacement.length };\n}\n\nexport function filterSkills(skills: readonly ChatSkillItem[], query: string): ChatSkillItem[] {\n const needle = query.trim().toLowerCase();\n const enabled = skills.filter((skill) => skill.enabled !== false);\n if (!needle) return enabled;\n const scored: Array<{ skill: ChatSkillItem; rank: number }> = [];\n for (const skill of enabled) {\n const slug = skill.slug.toLowerCase();\n const name = skill.name.toLowerCase();\n const desc = (skill.description ?? '').toLowerCase();\n if (slug.startsWith(needle) || name.startsWith(needle)) scored.push({ skill, rank: 0 });\n else if (slug.includes(needle) || name.includes(needle)) scored.push({ skill, rank: 1 });\n else if (desc.includes(needle)) scored.push({ skill, rank: 2 });\n }\n return scored.sort((a, b) => a.rank - b.rank).map((entry) => entry.skill);\n}\n\nexport function filterMentions(\n mentions: readonly ChatMentionItem[],\n query: string,\n): ChatMentionItem[] {\n const needle = query.trim().toLowerCase();\n if (!needle) return [...mentions];\n const scored: Array<{ item: ChatMentionItem; rank: number }> = [];\n for (const item of mentions) {\n const label = item.label.toLowerCase();\n const desc = (item.description ?? '').toLowerCase();\n const group = (item.group ?? '').toLowerCase();\n const keywords = (item.keywords ?? []).join(' ').toLowerCase();\n if (label.startsWith(needle)) scored.push({ item, rank: 0 });\n else if (label.includes(needle)) scored.push({ item, rank: 1 });\n else if (desc.includes(needle) || keywords.includes(needle) || group.includes(needle)) {\n scored.push({ item, rank: 2 });\n }\n }\n return scored.sort((a, b) => a.rank - b.rank).map((entry) => entry.item);\n}\n\nexport interface UseComposerTriggerOptions {\n value: string;\n cursor: number;\n triggers?: readonly ComposerTriggerKind[];\n enabled?: boolean;\n itemCount: number;\n onCommit?: (index: number, match: ComposerTriggerMatch) => void;\n}\n\nexport interface ComposerTriggerController {\n match: ComposerTriggerMatch | null;\n open: boolean;\n activeIndex: number;\n setActiveIndex: (index: number) => void;\n dismiss: () => void;\n /** Returns true when the trigger menu consumed the key event. */\n handleKeyDown: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => boolean;\n}\n\nexport function useComposerTrigger({\n value,\n cursor,\n triggers = ['/', '@'],\n enabled = true,\n itemCount,\n onCommit,\n}: UseComposerTriggerOptions): ComposerTriggerController {\n const rawMatch = enabled ? detectComposerTrigger(value, cursor, triggers) : null;\n const tokenKey = rawMatch ? `${rawMatch.trigger}:${rawMatch.start}` : null;\n const [dismissedKey, setDismissedKey] = useState<string | null>(null);\n const [activeIndex, setActiveIndex] = useState(0);\n\n useEffect(() => {\n if (!tokenKey) setDismissedKey(null);\n }, [tokenKey]);\n\n const open = Boolean(rawMatch && tokenKey !== dismissedKey);\n const safeIndex = itemCount > 0 ? Math.min(activeIndex, itemCount - 1) : 0;\n\n useEffect(() => {\n setActiveIndex(0);\n }, [rawMatch?.trigger, rawMatch?.start, rawMatch?.query]);\n\n const dismiss = useCallback(() => {\n if (tokenKey) setDismissedKey(tokenKey);\n }, [tokenKey]);\n\n const handleKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLTextAreaElement>): boolean => {\n if (!open || !rawMatch) return false;\n if (event.nativeEvent.isComposing || event.keyCode === 229) return false;\n if (event.key === 'Escape') {\n event.preventDefault();\n dismiss();\n return true;\n }\n if (itemCount <= 0) return false;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n setActiveIndex((current) => (current + 1) % itemCount);\n return true;\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n setActiveIndex((current) => (current - 1 + itemCount) % itemCount);\n return true;\n }\n if ((event.key === 'Enter' && !event.shiftKey) || event.key === 'Tab') {\n event.preventDefault();\n onCommit?.(safeIndex, rawMatch);\n return true;\n }\n return false;\n },\n [open, rawMatch, itemCount, safeIndex, onCommit, dismiss],\n );\n\n return {\n match: open ? rawMatch : null,\n open,\n activeIndex: safeIndex,\n setActiveIndex,\n dismiss,\n handleKeyDown,\n };\n}\n","export const CHAT_CONTEXT_USAGE_TONES = [\n 'slate',\n 'violet',\n 'green',\n 'amber',\n 'magenta',\n 'blue',\n 'orange',\n 'teal',\n] as const;\n\nexport type ChatContextUsageTone = (typeof CHAT_CONTEXT_USAGE_TONES)[number];\nexport type ChatContextUsageLevel = 'normal' | 'warn' | 'high';\n\nexport interface ChatContextUsageSegment {\n id: string;\n label: string;\n tokens: number;\n tone?: ChatContextUsageTone;\n}\n\nexport interface ChatContextUsageData {\n usedTokens: number;\n contextWindowTokens: number;\n /** Prefix displayed usage with `~` when the count is estimated. Defaults to true. */\n estimated?: boolean;\n /** Optional active model display label shown subtly beside the heading. */\n modelLabel?: string;\n /** Whether automatic context compaction occurred. */\n compacted?: boolean;\n /** Approximate tokens freed by automatic compaction. */\n compactedSavedTokens?: number;\n /** Number of compactions recorded in this turn or conversation. */\n compactionCount?: number;\n /** Per-category token breakdown displayed in the segmented meter and legend. */\n segments?: readonly ChatContextUsageSegment[];\n}\n\nexport interface ResolveChatContextUsageOptions {\n /** Percentage threshold at which usage switches to the warning tone. Defaults to 60. */\n warnThreshold?: number;\n /** Percentage threshold at which usage switches to the high/danger tone. Defaults to 85. */\n highThreshold?: number;\n}\n\nexport interface ResolvedChatContextUsageSegment extends ChatContextUsageSegment {\n tone: ChatContextUsageTone;\n}\n\nexport interface ResolvedChatContextUsage {\n usedTokens: number;\n contextWindowTokens: number;\n ratio: number;\n percent: number;\n fillPercent: number;\n level: ChatContextUsageLevel;\n estimated: boolean;\n usedFormatted: string;\n windowFormatted: string;\n usedDisplay: string;\n visibleSegments: readonly ResolvedChatContextUsageSegment[];\n compacted: boolean;\n compactedSavedTokens: number;\n compactionCount: number;\n modelLabel?: string;\n}\n\n/** Compact human-readable token count (e.g. `1.6K`, `103.5K`, `256K`, `1M`). */\nexport function formatChatTokens(tokens: number): string {\n const safe = Number.isFinite(tokens) ? Math.max(0, Math.round(tokens)) : 0;\n if (safe >= 1_000_000) {\n const value = (safe / 1_000_000).toFixed(1).replace(/\\.0$/, '');\n return `${value}M`;\n }\n if (safe >= 1000) {\n const value = (safe / 1000).toFixed(1).replace(/\\.0$/, '');\n return `${value}K`;\n }\n return String(safe);\n}\n\n/**\n * Normalizes raw context-window utilization numbers into bounded display metrics, warning\n * levels, and tone-resolved visible segments for `ChatContextUsage` or custom headless UIs.\n */\nexport function resolveChatContextUsage(\n usage: ChatContextUsageData,\n options: ResolveChatContextUsageOptions = {},\n): ResolvedChatContextUsage {\n const warnThreshold = options.warnThreshold ?? 60;\n const highThreshold = options.highThreshold ?? 85;\n const contextWindowTokens =\n Number.isFinite(usage.contextWindowTokens) && usage.contextWindowTokens > 0\n ? Math.round(usage.contextWindowTokens)\n : 1;\n const usedTokens =\n Number.isFinite(usage.usedTokens) && usage.usedTokens > 0 ? Math.round(usage.usedTokens) : 0;\n const ratio = Math.min(1, usedTokens / contextWindowTokens);\n const fillPercent = ratio * 100;\n const percent = Math.min(100, Math.round(fillPercent));\n const level: ChatContextUsageLevel =\n percent >= highThreshold ? 'high' : percent >= warnThreshold ? 'warn' : 'normal';\n const estimated = usage.estimated ?? true;\n const usedFormatted = formatChatTokens(usedTokens);\n const windowFormatted = formatChatTokens(contextWindowTokens);\n const usedDisplay = estimated && usedTokens > 0 ? `~${usedFormatted}` : usedFormatted;\n\n const visibleSegments: ResolvedChatContextUsageSegment[] = [];\n (usage.segments ?? []).forEach((segment, index) => {\n const tokens = Number.isFinite(segment.tokens) ? Math.round(segment.tokens) : 0;\n if (tokens <= 0) return;\n visibleSegments.push({\n id: segment.id,\n label: segment.label,\n tokens,\n tone: segment.tone ?? CHAT_CONTEXT_USAGE_TONES[index % CHAT_CONTEXT_USAGE_TONES.length]!,\n });\n });\n\n return {\n usedTokens,\n contextWindowTokens,\n ratio,\n percent,\n fillPercent,\n level,\n estimated,\n usedFormatted,\n windowFormatted,\n usedDisplay,\n visibleSegments,\n compacted: Boolean(usage.compacted),\n compactedSavedTokens:\n Number.isFinite(usage.compactedSavedTokens) && (usage.compactedSavedTokens ?? 0) > 0\n ? Math.round(usage.compactedSavedTokens!)\n : 0,\n compactionCount:\n Number.isFinite(usage.compactionCount) && (usage.compactionCount ?? 0) > 0\n ? Math.round(usage.compactionCount!)\n : 0,\n modelLabel: usage.modelLabel,\n };\n}\n","import type { ReactNode } from 'react';\n\nexport const CHAT_REASONING_EFFORTS = ['none', 'low', 'medium', 'high', 'xhigh'] as const;\nexport type ChatReasoningEffort = (typeof CHAT_REASONING_EFFORTS)[number];\n\nexport interface ChatModelOption {\n id: string;\n label: string;\n /** Underlying model identifier when distinct from the display label. */\n model?: string;\n /** Optional provider or vendor key for display or grouping. */\n provider?: string;\n description?: string;\n badge?: string;\n icon?: ReactNode;\n /** Supported reasoning effort levels for this model; omit or pass empty to hide the effort picker. */\n reasoningEfforts?: readonly ChatReasoningEffort[];\n /** Default reasoning effort when switching to this model without an explicit effort. */\n defaultReasoningEffort?: ChatReasoningEffort;\n /** Optional context-window size in tokens, useful when pairing with `ChatContextUsage`. */\n contextWindowTokens?: number;\n disabled?: boolean;\n}\n\nexport interface ChatModelSelection {\n modelId: string;\n reasoningEffort?: ChatReasoningEffort;\n}\n\nexport interface ResolvedChatModelSelection {\n model: ChatModelOption | undefined;\n modelId: string | undefined;\n reasoningEffort: ChatReasoningEffort | undefined;\n supportedEfforts: readonly ChatReasoningEffort[];\n}\n\nexport function isChatReasoningEffort(value: unknown): value is ChatReasoningEffort {\n return typeof value === 'string' && (CHAT_REASONING_EFFORTS as readonly string[]).includes(value);\n}\n\n/**\n * Reconciles a requested or persisted selection against the currently available model list.\n * Falls back cleanly to the first enabled model and its default reasoning effort when stale.\n */\nexport function resolveChatModelSelection(\n models: readonly ChatModelOption[],\n selection?: Partial<ChatModelSelection> | null,\n): ResolvedChatModelSelection {\n const enabledModels = models.filter((item) => !item.disabled);\n const matched = selection?.modelId\n ? enabledModels.find((item) => item.id === selection.modelId)\n : undefined;\n const chosen = matched ?? enabledModels[0] ?? models[0];\n\n if (!chosen) {\n return { model: undefined, modelId: undefined, reasoningEffort: undefined, supportedEfforts: [] };\n }\n\n const supported = (chosen.reasoningEfforts ?? []).filter(isChatReasoningEffort);\n // Only honor the persisted effort when it belongs to the matched model (or no modelId was stored).\n const requestedEffort = matched || !selection?.modelId ? selection?.reasoningEffort : undefined;\n const reasoningEffort =\n requestedEffort && supported.includes(requestedEffort)\n ? requestedEffort\n : chosen.defaultReasoningEffort && supported.includes(chosen.defaultReasoningEffort)\n ? chosen.defaultReasoningEffort\n : undefined;\n\n return {\n model: chosen,\n modelId: chosen.id,\n reasoningEffort,\n supportedEfforts: supported,\n };\n}\n\n/**\n * Computes the next selection when the user switches models, preserving the current\n * reasoning effort when supported by the new model and otherwise using its default.\n */\nexport function selectChatModel(\n nextModel: ChatModelOption,\n currentEffort?: ChatReasoningEffort,\n): ChatModelSelection {\n const supported = (nextModel.reasoningEfforts ?? []).filter(isChatReasoningEffort);\n const reasoningEffort =\n currentEffort && supported.includes(currentEffort)\n ? currentEffort\n : nextModel.defaultReasoningEffort && supported.includes(nextModel.defaultReasoningEffort)\n ? nextModel.defaultReasoningEffort\n : undefined;\n return {\n modelId: nextModel.id,\n ...(reasoningEffort !== undefined ? { reasoningEffort } : {}),\n };\n}\n","\"use client\";\n\nimport { useCallback, useMemo, useState } from 'react';\nimport type { ChatBranchInfo } from './types';\n\nconst ROOT_KEY = '__root__';\n\nexport interface ProjectChatBranchesOptions<T extends { id: string }> {\n /**\n * Resolve an item's parent ID:\n * - `string`: explicit parent item ID\n * - `null`: explicit root item (starts a root-level branch)\n * - `undefined`: legacy linear item (chains after `items[index - 1]`)\n */\n getParentId?: (item: T, index: number, items: readonly T[]) => string | null | undefined;\n /** Selected child ID keyed by parent ID (`'__root__'` for root-level siblings). */\n selections?: Readonly<Record<string, string>>;\n /**\n * Active head or checkpoint stop position:\n * - `undefined`: follow selected/latest children to a leaf\n * - `null`: reverted to the empty root before the first message\n * - `string`: follow ancestors of this item, stopping at it when `stopAtHead` is true\n */\n headId?: string | null;\n /** When true and `headId` is provided, stop at `headId` instead of descending to its leaf. */\n stopAtHead?: boolean;\n}\n\nexport interface ChatBranchProjection<T extends { id: string }> {\n messages: T[];\n branches: Record<string, ChatBranchInfo>;\n /** Last visible item ID on the active path, or `null` when empty / reverted to root. */\n headId: string | null;\n /** Root-level branch navigation when reverted before the first message. */\n rootBranches?: ChatBranchInfo;\n}\n\nfunction parentKey(parentId: string | null): string {\n return parentId === null ? ROOT_KEY : `p:${parentId}`;\n}\n\nexport function projectChatBranches<T extends { id: string }>(\n items: readonly T[],\n options: ProjectChatBranchesOptions<T> = {},\n): ChatBranchProjection<T> {\n const { getParentId, selections, headId, stopAtHead = false } = options;\n if (items.length === 0) {\n return { messages: [], branches: {}, headId: null };\n }\n\n const byId = new Map<string, T>();\n for (const item of items) byId.set(item.id, item);\n\n const parentOf = new Map<string, string | null>();\n const childrenOf = new Map<string, T[]>();\n\n items.forEach((item, index) => {\n const raw = getParentId ? getParentId(item, index, items) : undefined;\n const resolved =\n raw === undefined\n ? (index > 0 ? items[index - 1]!.id : null)\n : raw !== null && byId.has(raw)\n ? raw\n : null;\n const safeParent = resolved === item.id ? null : resolved;\n parentOf.set(item.id, safeParent);\n const key = parentKey(safeParent);\n const group = childrenOf.get(key);\n if (group) group.push(item);\n else childrenOf.set(key, [item]);\n });\n\n const effectiveSelections: Record<string, string> = { ...selections };\n if (typeof headId === 'string' && byId.has(headId)) {\n let cursor: string | null = headId;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentOf.get(cursor) ?? null;\n effectiveSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n }\n\n const toBranchInfo = (siblings: readonly T[], activeIndex: number): ChatBranchInfo | undefined => {\n if (siblings.length <= 1 || activeIndex < 0) return undefined;\n return {\n index: activeIndex + 1,\n count: siblings.length,\n prevId: activeIndex > 0 ? siblings[activeIndex - 1]!.id : undefined,\n nextId: activeIndex + 1 < siblings.length ? siblings[activeIndex + 1]!.id : undefined,\n };\n };\n\n if (headId === null) {\n const roots = childrenOf.get(ROOT_KEY) ?? [];\n const chosenId = effectiveSelections[ROOT_KEY];\n const idx = chosenId ? roots.findIndex(item => item.id === chosenId) : roots.length - 1;\n return {\n messages: [],\n branches: {},\n headId: null,\n rootBranches: toBranchInfo(roots, idx >= 0 ? idx : roots.length - 1),\n };\n }\n\n const messages: T[] = [];\n const branches: Record<string, ChatBranchInfo> = {};\n const visited = new Set<string>();\n let currentParent: string | null = null;\n\n while (true) {\n const siblings: T[] | undefined = childrenOf.get(parentKey(currentParent));\n if (!siblings || siblings.length === 0) break;\n const preferredId: string | undefined = effectiveSelections[parentKey(currentParent)];\n let index: number = preferredId ? siblings.findIndex(item => item.id === preferredId) : -1;\n if (index < 0) index = siblings.length - 1;\n const chosen: T = siblings[index]!;\n if (visited.has(chosen.id)) break;\n visited.add(chosen.id);\n messages.push(chosen);\n const info = toBranchInfo(siblings, index);\n if (info) branches[chosen.id] = info;\n if (stopAtHead && headId === chosen.id) break;\n currentParent = chosen.id;\n }\n\n return {\n messages,\n branches,\n headId: messages.at(-1)?.id ?? null,\n };\n}\n\nexport interface ChatBranchesState {\n selections: Record<string, string>;\n checkpoint?: {\n afterId: string | null;\n revertedMessageId?: string;\n restoreLeafId: string | null;\n };\n}\n\nexport interface ChatBranchesController<T extends { id: string }> extends ChatBranchProjection<T> {\n /** Parent ID to attach to the next newly submitted user message (`null` when starting at root). */\n nextParentId: string | null;\n /** Message ID that was reverted to create the current checkpoint, if any. */\n revertedMessageId?: string;\n /** Whether a previous branch leaf can be restored after a revert/checkpoint action. */\n canRestore: boolean;\n /** Switch to the branch containing `messageId` and follow it to its leaf. */\n selectBranch: (messageId: string) => void;\n /** Revert the active view to immediately before `messageId`, keeping the old branch restorable. */\n revertBefore: (messageId: string) => T | undefined;\n /** Position the active view right after `messageId` so the next message branches from there. */\n branchFrom: (messageId: string) => boolean;\n /** Restore the branch leaf that was active before `revertBefore` or `branchFrom`. */\n restore: () => void;\n /** Clear any active checkpoint (call when submitting a new message from the checkpoint). */\n commitFromCheckpoint: () => string | null;\n}\n\nexport function useChatBranches<T extends { id: string }>(\n items: readonly T[],\n options: Omit<ProjectChatBranchesOptions<T>, 'selections' | 'headId' | 'stopAtHead'> = {},\n): ChatBranchesController<T> {\n const { getParentId } = options;\n const [state, setState] = useState<ChatBranchesState>({ selections: {} });\n\n const parentMap = useMemo(() => {\n const byId = new Set(items.map(item => item.id));\n const map = new Map<string, string | null>();\n items.forEach((item, index) => {\n const raw = getParentId ? getParentId(item, index, items) : undefined;\n const resolved =\n raw === undefined\n ? (index > 0 ? items[index - 1]!.id : null)\n : raw !== null && byId.has(raw)\n ? raw\n : null;\n map.set(item.id, resolved === item.id ? null : resolved);\n });\n return map;\n }, [items, getParentId]);\n\n const projection = useMemo(\n () =>\n projectChatBranches(items, {\n getParentId,\n selections: state.selections,\n headId: state.checkpoint ? state.checkpoint.afterId : undefined,\n stopAtHead: state.checkpoint !== undefined,\n }),\n [items, getParentId, state],\n );\n\n const selectBranch = useCallback(\n (messageId: string) => {\n if (!parentMap.has(messageId)) return;\n setState(current => {\n const nextSelections = { ...current.selections };\n let cursor: string | null = messageId;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentMap.get(cursor) ?? null;\n nextSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n return { selections: nextSelections, checkpoint: undefined };\n });\n },\n [parentMap],\n );\n\n const revertBefore = useCallback(\n (messageId: string): T | undefined => {\n const target = items.find(item => item.id === messageId);\n if (!target) return undefined;\n const afterId = parentMap.get(messageId) ?? null;\n const currentLeaf = projection.headId;\n setState(current => ({\n selections: current.selections,\n checkpoint: {\n afterId,\n revertedMessageId: messageId,\n restoreLeafId: current.checkpoint?.restoreLeafId ?? currentLeaf,\n },\n }));\n return target;\n },\n [items, parentMap, projection.headId],\n );\n\n const branchFrom = useCallback(\n (messageId: string): boolean => {\n if (!parentMap.has(messageId)) return false;\n const currentLeaf = projection.headId;\n setState(current => ({\n selections: current.selections,\n checkpoint: {\n afterId: messageId,\n restoreLeafId: current.checkpoint?.restoreLeafId ?? currentLeaf,\n },\n }));\n return true;\n },\n [parentMap, projection.headId],\n );\n\n const restore = useCallback(() => {\n setState(current => {\n const leaf = current.checkpoint?.restoreLeafId;\n if (!leaf || !parentMap.has(leaf)) return { ...current, checkpoint: undefined };\n const nextSelections = { ...current.selections };\n let cursor: string | null = leaf;\n const seen = new Set<string>();\n while (cursor !== null && !seen.has(cursor)) {\n seen.add(cursor);\n const p: string | null = parentMap.get(cursor) ?? null;\n nextSelections[parentKey(p)] = cursor;\n cursor = p;\n }\n return { selections: nextSelections, checkpoint: undefined };\n });\n }, [parentMap]);\n\n const commitFromCheckpoint = useCallback(() => {\n const parentId = projection.headId;\n setState(current => {\n const nextSelections = { ...current.selections };\n delete nextSelections[parentKey(parentId)];\n return { selections: nextSelections, checkpoint: undefined };\n });\n return parentId;\n }, [projection.headId]);\n\n return {\n ...projection,\n nextParentId: projection.headId,\n revertedMessageId: state.checkpoint?.revertedMessageId,\n canRestore: Boolean(state.checkpoint?.restoreLeafId && parentMap.has(state.checkpoint.restoreLeafId)),\n selectBranch,\n revertBefore,\n branchFrom,\n restore,\n commitFromCheckpoint,\n };\n}\n"],"mappings":";;;;;AAOA,SAAgB,UAA2C,UAA4B,CAAC,GAAwB;CAC9G,MAAM,OAAO,QAAW;EAAE,UAAU;EAAI,GAAG;CAAQ,CAAC;CACpD,OAAO;EAAE,GAAG;EAAM,QAAQ,KAAK,WAAW,eAAe,KAAK,WAAW;CAAY;AACvF;;;ACRA,MAAa,OAA6B;CACxC,OAAO;CAAS,WAAW;CAAM,MAAM;CAAK,aAAa;CACzD,MAAM;CAAQ,MAAM;CAAQ,QAAQ;CAAQ,kBAAkB;CAC9D,WAAW;CAAO,cAAc;CAAgB,cAAc;CAC9D,cAAc;CAAY,iBAAiB;CAC3C,YAAY;CAAY,kBAAkB;CAC1C,UAAU;CAAQ,WAAW;CAA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MAAM,iBAAiB,EAAE,GAAG,QAAQ,WAAW;GAC/C,IAAI,SAAwB;GAC5B,MAAM,uBAAO,IAAI,IAAY;GAC7B,OAAO,WAAW,QAAQ,CAAC,KAAK,IAAI,MAAM,GAAG;IAC3C,KAAK,IAAI,MAAM;IACf,MAAM,IAAmB,UAAU,IAAI,MAAM,KAAK;IAClD,eAAe,UAAU,CAAC,KAAK;IAC/B,SAAS;GACX;GACA,OAAO;IAAE,YAAY;IAAgB,YAAY,KAAA;GAAU;EAC7D,CAAC;CACH,GAAG,CAAC,SAAS,CAAC;CAEd,MAAM,uBAAuB,kBAAkB;EAC7C,MAAM,WAAW,WAAW;EAC5B,UAAS,YAAW;GAClB,MAAM,iBAAiB,EAAE,GAAG,QAAQ,WAAW;GAC/C,OAAO,eAAe,UAAU,QAAQ;GACxC,OAAO;IAAE,YAAY;IAAgB,YAAY,KAAA;GAAU;EAC7D,CAAC;EACD,OAAO;CACT,GAAG,CAAC,WAAW,MAAM,CAAC;CAEtB,OAAO;EACL,GAAG;EACH,cAAc,WAAW;EACzB,mBAAmB,MAAM,YAAY;EACrC,YAAY,QAAQ,MAAM,YAAY,iBAAiB,UAAU,IAAI,MAAM,WAAW,aAAa,CAAC;EACpG;EACA;EACA;EACA;EACA;CACF;AACF"}
|
package/dist/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { r as Icon, t as ChatIconButton } from "./ui-primitives-
|
|
3
|
+
import { r as Icon, t as ChatIconButton } from "./ui-primitives-CV3lrveW.js";
|
|
4
4
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/context.tsx
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
import { ChatContextAdapter, ChatContextController, ChatContextItem, ChatContextOptions, ChatContextValue, ChatRequestContext, SelectedChatContextItem, TextSelectionAdapterOptions, createTextSelectionAdapter, useChatContext } from "./context.js";
|
|
3
3
|
import { SpeechInputAdapter, SpeechInputController, SpeechInputError, SpeechInputOptions, SpeechInputResult, SpeechInputSession, SpeechInputStartOptions, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
|
|
4
|
-
import { $ as
|
|
5
|
-
export { type AiChatController, type AiChatOptions, type AiChatProps, type AttachmentOptions, CHAT_REASONING_EFFORTS, type ChatBranchInfo, type ChatBranchProjection, type ChatBranchesController, type ChatBranchesState, type ChatComposerMenuAction, type ChatComposerProps, type ChatContextAdapter, type ChatContextController, type ChatContextItem, type ChatContextOptions, type ChatContextValue, type ChatLabels, type ChatMentionItem, type ChatMessageActionContext, type ChatMessagesProps, type ChatModelOption, type ChatModelSelection, type ChatPanelProps, type ChatReasoningEffort, type ChatRequestContext, type ChatScrollHandle, type ChatSkillItem, type ChatSuggestedAction, type ComposerTriggerController, type ComposerTriggerKind, type ComposerTriggerMatch, type ParsedSkillMarkdown, type PartRendererProps, type PartRenderers, type ProjectChatBranchesOptions, type ResolvedChatModelSelection, type SelectedChatContextItem, type SpeechInputAdapter, type SpeechInputController, SpeechInputError, type SpeechInputOptions, type SpeechInputResult, type SpeechInputSession, type SpeechInputStartOptions, type TextRenderer, type TextSelectionAdapterOptions, type ToolPart, type ToolPresentation, type ToolPresentationResolver, type ToolRenderers, type UseComposerTriggerOptions, acceptsFile, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, filterMentions, filterSkills, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatModelSelection, safeUrl, selectChatModel, slugifySkillName, useAiChat, useChatBranches, useChatContext, useComposerTrigger, useSpeechInput, zhCN };
|
|
4
|
+
import { $ as ResolvedChatContextUsageSegment, A as ToolPresentationResolver, B as resolveChatModelSelection, C as ChatScrollHandle, D as TextRenderer, E as PartRenderers, F as ChatModelOption, I as ChatModelSelection, J as ChatContextUsageLevel, K as CHAT_CONTEXT_USAGE_TONES, L as ChatReasoningEffort, O as ToolPart, P as CHAT_REASONING_EFFORTS, Q as ResolvedChatContextUsage, R as ResolvedChatModelSelection, S as ChatPanelProps, T as PartRendererProps, V as selectChatModel, X as ChatContextUsageTone, Y as ChatContextUsageSegment, Z as ResolveChatContextUsageOptions, _ as ChatBranchInfo, a as projectChatBranches, at as ComposerTriggerController, b as ChatMessageActionContext, c as zhCN, ct as ParsedSkillMarkdown, d as safeUrl, dt as filterMentions, et as formatChatTokens, f as useAiChat, ft as filterSkills, g as AttachmentOptions, gt as useComposerTrigger, h as AiChatProps, ht as slugifySkillName, i as ProjectChatBranchesOptions, it as ChatSkillItem, j as ToolRenderers, k as ToolPresentation, l as acceptsFile, lt as UseComposerTriggerOptions, m as AiChatOptions, mt as replaceComposerTrigger, n as ChatBranchesController, nt as ChatComposerMenuAction, o as useChatBranches, ot as ComposerTriggerKind, p as AiChatController, pt as parseSkillMarkdown, q as ChatContextUsageData, r as ChatBranchesState, rt as ChatMentionItem, s as enUS, st as ComposerTriggerMatch, t as ChatBranchProjection, tt as resolveChatContextUsage, u as getMessageText, ut as detectComposerTrigger, v as ChatComposerProps, w as ChatSuggestedAction, x as ChatMessagesProps, y as ChatLabels, z as isChatReasoningEffort } from "./branches-CZkkLIra.js";
|
|
5
|
+
export { type AiChatController, type AiChatOptions, type AiChatProps, type AttachmentOptions, CHAT_CONTEXT_USAGE_TONES, CHAT_REASONING_EFFORTS, type ChatBranchInfo, type ChatBranchProjection, type ChatBranchesController, type ChatBranchesState, type ChatComposerMenuAction, type ChatComposerProps, type ChatContextAdapter, type ChatContextController, type ChatContextItem, type ChatContextOptions, type ChatContextUsageData, type ChatContextUsageLevel, type ChatContextUsageSegment, type ChatContextUsageTone, type ChatContextValue, type ChatLabels, type ChatMentionItem, type ChatMessageActionContext, type ChatMessagesProps, type ChatModelOption, type ChatModelSelection, type ChatPanelProps, type ChatReasoningEffort, type ChatRequestContext, type ChatScrollHandle, type ChatSkillItem, type ChatSuggestedAction, type ComposerTriggerController, type ComposerTriggerKind, type ComposerTriggerMatch, type ParsedSkillMarkdown, type PartRendererProps, type PartRenderers, type ProjectChatBranchesOptions, type ResolveChatContextUsageOptions, type ResolvedChatContextUsage, type ResolvedChatContextUsageSegment, type ResolvedChatModelSelection, type SelectedChatContextItem, type SpeechInputAdapter, type SpeechInputController, SpeechInputError, type SpeechInputOptions, type SpeechInputResult, type SpeechInputSession, type SpeechInputStartOptions, type TextRenderer, type TextSelectionAdapterOptions, type ToolPart, type ToolPresentation, type ToolPresentationResolver, type ToolRenderers, type UseComposerTriggerOptions, acceptsFile, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, filterMentions, filterSkills, formatChatTokens, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatContextUsage, resolveChatModelSelection, safeUrl, selectChatModel, slugifySkillName, useAiChat, useChatBranches, useChatContext, useComposerTrigger, useSpeechInput, zhCN };
|
package/dist/headless.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { _ as
|
|
3
|
+
import { _ as enUS, a as resolveChatModelSelection, b as useAiChat, c as formatChatTokens, d as filterMentions, f as filterSkills, g as useComposerTrigger, h as slugifySkillName, i as isChatReasoningEffort, l as resolveChatContextUsage, m as replaceComposerTrigger, n as useChatBranches, o as selectChatModel, p as parseSkillMarkdown, r as CHAT_REASONING_EFFORTS, s as CHAT_CONTEXT_USAGE_TONES, t as projectChatBranches, u as detectComposerTrigger, y as zhCN } from "./branches-asMPZLXd.js";
|
|
4
4
|
import { i as safeUrl, r as getMessageText, t as acceptsFile } from "./utils-DqBGBYA1.js";
|
|
5
5
|
import { SpeechInputError, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
|
|
6
6
|
import { createTextSelectionAdapter, useChatContext } from "./context.js";
|
|
7
|
-
export { CHAT_REASONING_EFFORTS, SpeechInputError, acceptsFile, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, filterMentions, filterSkills, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatModelSelection, safeUrl, selectChatModel, slugifySkillName, useAiChat, useChatBranches, useChatContext, useComposerTrigger, useSpeechInput, zhCN };
|
|
7
|
+
export { CHAT_CONTEXT_USAGE_TONES, CHAT_REASONING_EFFORTS, SpeechInputError, acceptsFile, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, filterMentions, filterSkills, formatChatTokens, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatContextUsage, resolveChatModelSelection, safeUrl, selectChatModel, slugifySkillName, useAiChat, useChatBranches, useChatContext, useComposerTrigger, useSpeechInput, zhCN };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
3
|
import { LucideProps } from "lucide-react";
|
|
4
4
|
//#region src/icons.d.ts
|
|
5
|
-
type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'chevronDown' | 'chevronLeft' | 'undo' | 'branch' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search' | 'compass' | 'scan' | 'paperclip' | 'layers' | 'at' | 'sliders' | 'zap';
|
|
5
|
+
type ChatIconName = 'send' | 'stop' | 'plus' | 'close' | 'copy' | 'check' | 'refresh' | 'down' | 'file' | 'sparkle' | 'more' | 'edit' | 'chevron' | 'chevronDown' | 'chevronLeft' | 'undo' | 'branch' | 'link' | 'tool' | 'thinking' | 'warning' | 'blocked' | 'loader' | 'mic' | 'audio' | 'text' | 'table' | 'chart' | 'page' | 'target' | 'external' | 'search' | 'compass' | 'scan' | 'paperclip' | 'layers' | 'at' | 'sliders' | 'zap' | 'minus' | 'minimize';
|
|
6
6
|
type ChatIconProps = Omit<LucideProps, 'ref'>;
|
|
7
7
|
type ChatIconOverrides = Partial<Record<ChatIconName, ComponentType<ChatIconProps>>>;
|
|
8
8
|
interface ChatAppearanceProviderProps {
|
|
@@ -17,4 +17,4 @@ declare function Icon({ name, ...props }: ChatIconProps & {
|
|
|
17
17
|
}): import("react").JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { ChatIconProps as a, ChatIconOverrides as i, ChatAppearanceProviderProps as n, Icon as o, ChatIconName as r, ChatAppearanceProvider as t };
|
|
20
|
-
//# sourceMappingURL=icons-
|
|
20
|
+
//# sourceMappingURL=icons-iagkwNls.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as ChatIconProps, i as ChatIconOverrides, n as ChatAppearanceProviderProps, o as Icon, r as ChatIconName, t as ChatAppearanceProvider } from "./icons-
|
|
3
|
-
import { n as ChatIconButtonProps, t as ChatIconButton } from "./appearance-
|
|
2
|
+
import { a as ChatIconProps, i as ChatIconOverrides, n as ChatAppearanceProviderProps, o as Icon, r as ChatIconName, t as ChatAppearanceProvider } from "./icons-iagkwNls.js";
|
|
3
|
+
import { n as ChatIconButtonProps, t as ChatIconButton } from "./appearance-CdnhPTwk.js";
|
|
4
4
|
import { ChatContextAdapter, ChatContextController, ChatContextItem, ChatContextOptions, ChatContextValue, ChatRequestContext, ContextTray, ContextTrayLabels, ContextTrayProps, SelectedChatContextItem, TextSelectionAdapterOptions, createTextSelectionAdapter, useChatContext } from "./context.js";
|
|
5
5
|
import { SpeechInputAdapter, SpeechInputController, SpeechInputError, SpeechInputErrorCode, SpeechInputLabels, SpeechInputOptions, SpeechInputResult, SpeechInputSession, SpeechInputStartOptions, SpeechInputState, SpeechInputSupport, UseSpeechInputOptions, createBrowserSpeechAdapter, defaultSpeechInputLabels, useSpeechInput } from "./voice.js";
|
|
6
|
-
import { $ as
|
|
6
|
+
import { $ as ResolvedChatContextUsageSegment, A as ToolPresentationResolver, B as resolveChatModelSelection, C as ChatScrollHandle, D as TextRenderer, E as PartRenderers, F as ChatModelOption, G as ChatContextUsageProps, H as ChatCompactionNotice, I as ChatModelSelection, J as ChatContextUsageLevel, K as CHAT_CONTEXT_USAGE_TONES, L as ChatReasoningEffort, M as ChatModelPicker, N as ChatModelPickerProps, O as ToolPart, P as CHAT_REASONING_EFFORTS, Q as ResolvedChatContextUsage, R as ResolvedChatModelSelection, S as ChatPanelProps, T as PartRendererProps, U as ChatCompactionNoticeProps, V as selectChatModel, W as ChatContextUsage, X as ChatContextUsageTone, Y as ChatContextUsageSegment, Z as ResolveChatContextUsageOptions, _ as ChatBranchInfo, a as projectChatBranches, at as ComposerTriggerController, b as ChatMessageActionContext, c as zhCN, ct as ParsedSkillMarkdown, dt as filterMentions, et as formatChatTokens, f as useAiChat, ft as filterSkills, g as AttachmentOptions, gt as useComposerTrigger, h as AiChatProps, ht as slugifySkillName, i as ProjectChatBranchesOptions, it as ChatSkillItem, j as ToolRenderers, k as ToolPresentation, lt as UseComposerTriggerOptions, m as AiChatOptions, mt as replaceComposerTrigger, n as ChatBranchesController, nt as ChatComposerMenuAction, o as useChatBranches, ot as ComposerTriggerKind, p as AiChatController, pt as parseSkillMarkdown, q as ChatContextUsageData, r as ChatBranchesState, rt as ChatMentionItem, s as enUS, st as ComposerTriggerMatch, t as ChatBranchProjection, tt as resolveChatContextUsage, u as getMessageText, ut as detectComposerTrigger, v as ChatComposerProps, w as ChatSuggestedAction, x as ChatMessagesProps, y as ChatLabels, z as isChatReasoningEffort } from "./branches-CZkkLIra.js";
|
|
7
7
|
import { ActiveMarquee, ChatTargetHit, ChatTargetKind, ChatTargetRect, ChatTargetingController, ChatTargetingLabels, ChatTargetingOverlay, ChatTargetingOverlayProps, PendingChatTarget, UseChatTargetingOptions, enUSTargetingLabels, toChatContextItem, useChatTargeting, zhCNTargetingLabels } from "./targeting.js";
|
|
8
8
|
import { HTMLAttributes, ReactNode } from "react";
|
|
9
9
|
import { UIMessage } from "ai";
|
|
@@ -112,5 +112,5 @@ interface ChatPlusMenuProps {
|
|
|
112
112
|
}
|
|
113
113
|
export declare function ChatPlusMenu({ open, onClose, actions, labels: overrides, className }: ChatPlusMenuProps): import("react").JSX.Element | null;
|
|
114
114
|
//#endregion
|
|
115
|
-
export { type ActiveMarquee, type AiChatController, type AiChatOptions, type AiChatProps, type AttachmentOptions, CHAT_REASONING_EFFORTS, ChatAppearanceProvider, type ChatAppearanceProviderProps, type ChatBranchInfo, type ChatBranchProjection, type ChatBranchSwitcherProps, type ChatBranchesController, type ChatBranchesState, type ChatCheckpointBannerProps, type ChatComposerMenuAction, type ChatComposerProps, type ChatContextAdapter, type ChatContextController, type ChatContextItem, type ChatContextOptions, type ChatContextValue, type ChatHistoryItem, type ChatHistoryLabels, type ChatHistoryMenuProps, Icon as ChatIcon, ChatIconButton, type ChatIconButtonProps, type ChatIconName, type ChatIconOverrides, type ChatIconProps, type ChatLabels, type ChatMentionItem, type ChatMentionMenuProps, type ChatMessageActionContext, type ChatMessagesProps, type ChatModelOption, ChatModelPicker, type ChatModelPickerProps, type ChatModelSelection, type ChatPanelProps, type ChatPlusMenuProps, type ChatReasoningEffort, type ChatRequestContext, type ChatScrollHandle, type ChatSkillItem, type ChatSlashMenuProps, type ChatSuggestedAction, type ChatTargetHit, type ChatTargetKind, type ChatTargetRect, type ChatTargetingController, type ChatTargetingLabels, ChatTargetingOverlay, type ChatTargetingOverlayProps, type ComposerTriggerController, type ComposerTriggerKind, type ComposerTriggerMatch, ContextTray, type ContextTrayLabels, type ContextTrayProps, type ParsedSkillMarkdown, type PartRendererProps, type PartRenderers, type PendingChatTarget, type ProjectChatBranchesOptions, type ResolvedChatModelSelection, type SelectedChatContextItem, type SpeechInputAdapter, type SpeechInputController, SpeechInputError, type SpeechInputErrorCode, type SpeechInputLabels, type SpeechInputOptions, type SpeechInputResult, type SpeechInputSession, type SpeechInputStartOptions, type SpeechInputState, type SpeechInputSupport, type TextRenderer, type TextSelectionAdapterOptions, type ToolPart, type ToolPresentation, type ToolPresentationResolver, type ToolRenderers, type UseChatTargetingOptions, type UseComposerTriggerOptions, type UseSpeechInputOptions, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, enUSTargetingLabels, filterMentions, filterSkills, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatModelSelection, selectChatModel, slugifySkillName, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useComposerTrigger, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
115
|
+
export { type ActiveMarquee, type AiChatController, type AiChatOptions, type AiChatProps, type AttachmentOptions, CHAT_CONTEXT_USAGE_TONES, CHAT_REASONING_EFFORTS, ChatAppearanceProvider, type ChatAppearanceProviderProps, type ChatBranchInfo, type ChatBranchProjection, type ChatBranchSwitcherProps, type ChatBranchesController, type ChatBranchesState, type ChatCheckpointBannerProps, ChatCompactionNotice, type ChatCompactionNoticeProps, type ChatComposerMenuAction, type ChatComposerProps, type ChatContextAdapter, type ChatContextController, type ChatContextItem, type ChatContextOptions, ChatContextUsage, type ChatContextUsageData, type ChatContextUsageLevel, type ChatContextUsageProps, type ChatContextUsageSegment, type ChatContextUsageTone, type ChatContextValue, type ChatHistoryItem, type ChatHistoryLabels, type ChatHistoryMenuProps, Icon as ChatIcon, ChatIconButton, type ChatIconButtonProps, type ChatIconName, type ChatIconOverrides, type ChatIconProps, type ChatLabels, type ChatMentionItem, type ChatMentionMenuProps, type ChatMessageActionContext, type ChatMessagesProps, type ChatModelOption, ChatModelPicker, type ChatModelPickerProps, type ChatModelSelection, type ChatPanelProps, type ChatPlusMenuProps, type ChatReasoningEffort, type ChatRequestContext, type ChatScrollHandle, type ChatSkillItem, type ChatSlashMenuProps, type ChatSuggestedAction, type ChatTargetHit, type ChatTargetKind, type ChatTargetRect, type ChatTargetingController, type ChatTargetingLabels, ChatTargetingOverlay, type ChatTargetingOverlayProps, type ComposerTriggerController, type ComposerTriggerKind, type ComposerTriggerMatch, ContextTray, type ContextTrayLabels, type ContextTrayProps, type ParsedSkillMarkdown, type PartRendererProps, type PartRenderers, type PendingChatTarget, type ProjectChatBranchesOptions, type ResolveChatContextUsageOptions, type ResolvedChatContextUsage, type ResolvedChatContextUsageSegment, type ResolvedChatModelSelection, type SelectedChatContextItem, type SpeechInputAdapter, type SpeechInputController, SpeechInputError, type SpeechInputErrorCode, type SpeechInputLabels, type SpeechInputOptions, type SpeechInputResult, type SpeechInputSession, type SpeechInputStartOptions, type SpeechInputState, type SpeechInputSupport, type TextRenderer, type TextSelectionAdapterOptions, type ToolPart, type ToolPresentation, type ToolPresentationResolver, type ToolRenderers, type UseChatTargetingOptions, type UseComposerTriggerOptions, type UseSpeechInputOptions, createBrowserSpeechAdapter, createTextSelectionAdapter, defaultSpeechInputLabels, detectComposerTrigger, enUS, enUSTargetingLabels, filterMentions, filterSkills, formatChatTokens, getMessageText, isChatReasoningEffort, parseSkillMarkdown, projectChatBranches, replaceComposerTrigger, resolveChatContextUsage, resolveChatModelSelection, selectChatModel, slugifySkillName, toChatContextItem, useAiChat, useChatBranches, useChatContext, useChatTargeting, useComposerTrigger, useSpeechInput, zhCN, zhCNTargetingLabels };
|
|
116
116
|
//# sourceMappingURL=index.d.ts.map
|