@fromsko/chat-ui 0.0.0-stage → 0.1.6
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/LICENSE +21 -0
- package/README.md +100 -2
- package/lib/adapters/event-bus.d.ts +80 -0
- package/lib/adapters/event-bus.js +73 -0
- package/lib/adapters/index.d.ts +3 -0
- package/lib/adapters/index.js +3 -0
- package/lib/adapters/labels.d.ts +6 -0
- package/lib/adapters/labels.js +17 -0
- package/lib/adapters/stream-bridge.d.ts +9 -0
- package/lib/adapters/stream-bridge.js +7 -0
- package/lib/blocks/cards/AskCard.d.ts +8 -0
- package/lib/blocks/cards/AskCard.js +97 -0
- package/lib/blocks/cards/CompactionCard.d.ts +5 -0
- package/lib/blocks/cards/CompactionCard.js +5 -0
- package/lib/blocks/cards/ContextUsage.d.ts +14 -0
- package/lib/blocks/cards/ContextUsage.js +136 -0
- package/lib/blocks/cards/DisplayCard.d.ts +7 -0
- package/lib/blocks/cards/DisplayCard.js +27 -0
- package/lib/blocks/cards/MemoryPill.d.ts +5 -0
- package/lib/blocks/cards/MemoryPill.js +5 -0
- package/lib/blocks/cards/OutputCard.d.ts +5 -0
- package/lib/blocks/cards/OutputCard.js +13 -0
- package/lib/blocks/cards/PermissionCard.d.ts +21 -0
- package/lib/blocks/cards/PermissionCard.js +26 -0
- package/lib/blocks/cards/SpringCheck.d.ts +9 -0
- package/lib/blocks/cards/SpringCheck.js +17 -0
- package/lib/blocks/cards/TodoCard.d.ts +19 -0
- package/lib/blocks/cards/TodoCard.js +28 -0
- package/lib/blocks/cards/index.d.ts +10 -0
- package/lib/blocks/cards/index.js +10 -0
- package/lib/blocks/composer/Composer.d.ts +66 -0
- package/lib/blocks/composer/Composer.js +73 -0
- package/lib/blocks/composer/ComposerAttachments.d.ts +17 -0
- package/lib/blocks/composer/ComposerAttachments.js +10 -0
- package/lib/blocks/composer/ComposerGrip.d.ts +1 -0
- package/lib/blocks/composer/ComposerGrip.js +39 -0
- package/lib/blocks/composer/ComposerInput.d.ts +18 -0
- package/lib/blocks/composer/ComposerInput.js +60 -0
- package/lib/blocks/composer/ComposerMenus.d.ts +10 -0
- package/lib/blocks/composer/ComposerMenus.js +78 -0
- package/lib/blocks/composer/ComposerToolbar.d.ts +27 -0
- package/lib/blocks/composer/ComposerToolbar.js +16 -0
- package/lib/blocks/composer/MentionPicker.d.ts +13 -0
- package/lib/blocks/composer/MentionPicker.js +71 -0
- package/lib/blocks/composer/PromptPop.d.ts +7 -0
- package/lib/blocks/composer/PromptPop.js +40 -0
- package/lib/blocks/composer/QueuedPrompts.d.ts +14 -0
- package/lib/blocks/composer/QueuedPrompts.js +21 -0
- package/lib/blocks/composer/SlingButton.d.ts +10 -0
- package/lib/blocks/composer/SlingButton.js +112 -0
- package/lib/blocks/composer/index.d.ts +7 -0
- package/lib/blocks/composer/index.js +1 -0
- package/lib/blocks/conversation/ChatEmptyScene.d.ts +4 -0
- package/lib/blocks/conversation/ChatEmptyScene.js +21 -0
- package/lib/blocks/conversation/ChatHeader.d.ts +13 -0
- package/lib/blocks/conversation/ChatHeader.js +20 -0
- package/lib/blocks/conversation/ChatPane.d.ts +90 -0
- package/lib/blocks/conversation/ChatPane.js +60 -0
- package/lib/blocks/conversation/Conversation.d.ts +11 -0
- package/lib/blocks/conversation/Conversation.js +41 -0
- package/lib/blocks/conversation/LineSidebar.d.ts +14 -0
- package/lib/blocks/conversation/LineSidebar.js +42 -0
- package/lib/blocks/conversation/index.d.ts +5 -0
- package/lib/blocks/conversation/index.js +5 -0
- package/lib/blocks/index.d.ts +9 -0
- package/lib/blocks/index.js +9 -0
- package/lib/blocks/message/DayDivider.d.ts +10 -0
- package/lib/blocks/message/DayDivider.js +29 -0
- package/lib/blocks/message/DiffView.d.ts +5 -0
- package/lib/blocks/message/DiffView.js +18 -0
- package/lib/blocks/message/MermaidDiagram.d.ts +4 -0
- package/lib/blocks/message/MermaidDiagram.js +43 -0
- package/lib/blocks/message/Message.d.ts +17 -0
- package/lib/blocks/message/Message.js +45 -0
- package/lib/blocks/message/MessageActionBar.d.ts +18 -0
- package/lib/blocks/message/MessageActionBar.js +15 -0
- package/lib/blocks/message/MessageArtifacts.d.ts +13 -0
- package/lib/blocks/message/MessageArtifacts.js +9 -0
- package/lib/blocks/message/MessageAttachments.d.ts +5 -0
- package/lib/blocks/message/MessageAttachments.js +28 -0
- package/lib/blocks/message/MessageBubble.d.ts +11 -0
- package/lib/blocks/message/MessageBubble.js +31 -0
- package/lib/blocks/message/MessageRow.d.ts +20 -0
- package/lib/blocks/message/MessageRow.js +49 -0
- package/lib/blocks/message/MessageStream.d.ts +23 -0
- package/lib/blocks/message/MessageStream.js +80 -0
- package/lib/blocks/message/MessageTrace.d.ts +16 -0
- package/lib/blocks/message/MessageTrace.js +39 -0
- package/lib/blocks/message/PartView.d.ts +10 -0
- package/lib/blocks/message/PartView.js +29 -0
- package/lib/blocks/message/code-text.d.ts +15 -0
- package/lib/blocks/message/code-text.js +17 -0
- package/lib/blocks/message/index.d.ts +12 -0
- package/lib/blocks/message/index.js +12 -0
- package/lib/blocks/reasoning/Reasoning.d.ts +7 -0
- package/lib/blocks/reasoning/Reasoning.js +26 -0
- package/lib/blocks/reasoning/ReasoningBlock.d.ts +6 -0
- package/lib/blocks/reasoning/ReasoningBlock.js +5 -0
- package/lib/blocks/reasoning/index.d.ts +2 -0
- package/lib/blocks/reasoning/index.js +2 -0
- package/lib/blocks/selection/SelectionActions.d.ts +12 -0
- package/lib/blocks/selection/SelectionActions.js +29 -0
- package/lib/blocks/selection/SelectionBar.d.ts +10 -0
- package/lib/blocks/selection/SelectionBar.js +6 -0
- package/lib/blocks/selection/index.d.ts +2 -0
- package/lib/blocks/selection/index.js +2 -0
- package/lib/blocks/settings/DisplaySettingsPanel.d.ts +5 -0
- package/lib/blocks/settings/DisplaySettingsPanel.js +33 -0
- package/lib/blocks/settings/SquishSwitch.d.ts +8 -0
- package/lib/blocks/settings/SquishSwitch.js +21 -0
- package/lib/blocks/settings/index.d.ts +2 -0
- package/lib/blocks/settings/index.js +2 -0
- package/lib/blocks/status/LatticeLoader.d.ts +12 -0
- package/lib/blocks/status/LatticeLoader.js +22 -0
- package/lib/blocks/status/TypingIndicator.d.ts +5 -0
- package/lib/blocks/status/TypingIndicator.js +5 -0
- package/lib/blocks/status/index.d.ts +2 -0
- package/lib/blocks/status/index.js +2 -0
- package/lib/blocks/tool/SandboxCard.d.ts +5 -0
- package/lib/blocks/tool/SandboxCard.js +10 -0
- package/lib/blocks/tool/ToolCard.d.ts +10 -0
- package/lib/blocks/tool/ToolCard.js +32 -0
- package/lib/blocks/tool/ToolGroup.d.ts +6 -0
- package/lib/blocks/tool/ToolGroup.js +23 -0
- package/lib/blocks/tool/exec-envelope.d.ts +7 -0
- package/lib/blocks/tool/exec-envelope.js +43 -0
- package/lib/blocks/tool/index.d.ts +4 -0
- package/lib/blocks/tool/index.js +4 -0
- package/lib/domain/ask.d.ts +14 -0
- package/lib/domain/ask.js +50 -0
- package/lib/domain/attachments.d.ts +16 -0
- package/lib/domain/attachments.js +126 -0
- package/lib/domain/attribution.d.ts +4 -0
- package/lib/domain/attribution.js +11 -0
- package/lib/domain/composer-palette.d.ts +15 -0
- package/lib/domain/composer-palette.js +131 -0
- package/lib/domain/index.d.ts +12 -0
- package/lib/domain/index.js +12 -0
- package/lib/domain/mention.d.ts +17 -0
- package/lib/domain/mention.js +95 -0
- package/lib/domain/message-blocks.d.ts +29 -0
- package/lib/domain/message-blocks.js +63 -0
- package/lib/domain/message-menu.d.ts +4 -0
- package/lib/domain/message-menu.js +46 -0
- package/lib/domain/queue.d.ts +23 -0
- package/lib/domain/queue.js +52 -0
- package/lib/domain/reducer.d.ts +137 -0
- package/lib/domain/reducer.js +442 -0
- package/lib/domain/selection-actions.d.ts +13 -0
- package/lib/domain/selection-actions.js +56 -0
- package/lib/domain/selection-gates.d.ts +6 -0
- package/lib/domain/selection-gates.js +36 -0
- package/lib/domain/slash-commands.d.ts +16 -0
- package/lib/domain/slash-commands.js +142 -0
- package/lib/hooks/index.d.ts +8 -0
- package/lib/hooks/index.js +8 -0
- package/lib/hooks/useComposerPalette.d.ts +35 -0
- package/lib/hooks/useComposerPalette.js +120 -0
- package/lib/hooks/useComposerSubmit.d.ts +31 -0
- package/lib/hooks/useComposerSubmit.js +135 -0
- package/lib/hooks/useInputHistory.d.ts +14 -0
- package/lib/hooks/useInputHistory.js +52 -0
- package/lib/hooks/usePendingAsk.d.ts +11 -0
- package/lib/hooks/usePendingAsk.js +33 -0
- package/lib/hooks/usePendingPermissions.d.ts +10 -0
- package/lib/hooks/usePendingPermissions.js +26 -0
- package/lib/hooks/useQueuedPrompts.d.ts +12 -0
- package/lib/hooks/useQueuedPrompts.js +91 -0
- package/lib/hooks/useSelectionPop.d.ts +13 -0
- package/lib/hooks/useSelectionPop.js +130 -0
- package/lib/hooks/useStreamBridge.d.ts +1 -0
- package/lib/hooks/useStreamBridge.js +23 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +10 -0
- package/lib/primitives/Badge.d.ts +7 -0
- package/lib/primitives/Badge.js +13 -0
- package/lib/primitives/Button.d.ts +9 -0
- package/lib/primitives/Button.js +21 -0
- package/lib/primitives/Collapsible.d.ts +12 -0
- package/lib/primitives/Collapsible.js +14 -0
- package/lib/primitives/Dialog.d.ts +10 -0
- package/lib/primitives/Dialog.js +19 -0
- package/lib/primitives/DropdownMenu.d.ts +28 -0
- package/lib/primitives/DropdownMenu.js +37 -0
- package/lib/primitives/Empty.d.ts +8 -0
- package/lib/primitives/Empty.js +6 -0
- package/lib/primitives/Input.d.ts +3 -0
- package/lib/primitives/Input.js +6 -0
- package/lib/primitives/Kbd.d.ts +2 -0
- package/lib/primitives/Kbd.js +5 -0
- package/lib/primitives/Popover.d.ts +15 -0
- package/lib/primitives/Popover.js +32 -0
- package/lib/primitives/ScrollArea.d.ts +5 -0
- package/lib/primitives/ScrollArea.js +5 -0
- package/lib/primitives/Separator.d.ts +5 -0
- package/lib/primitives/Separator.js +5 -0
- package/lib/primitives/Spinner.d.ts +5 -0
- package/lib/primitives/Spinner.js +5 -0
- package/lib/primitives/Textarea.d.ts +3 -0
- package/lib/primitives/Textarea.js +6 -0
- package/lib/primitives/Tooltip.d.ts +8 -0
- package/lib/primitives/Tooltip.js +7 -0
- package/lib/primitives/index.d.ts +14 -0
- package/lib/primitives/index.js +14 -0
- package/lib/reactbits/Motion.d.ts +24 -0
- package/lib/reactbits/Motion.js +52 -0
- package/lib/reactbits/index.d.ts +1 -0
- package/lib/reactbits/index.js +1 -0
- package/lib/stores/chat-store.d.ts +33 -0
- package/lib/stores/chat-store.js +93 -0
- package/lib/stores/display-store.d.ts +15 -0
- package/lib/stores/display-store.js +116 -0
- package/lib/stores/index.d.ts +3 -0
- package/lib/stores/index.js +3 -0
- package/lib/stores/theme-store.d.ts +8 -0
- package/lib/stores/theme-store.js +29 -0
- package/lib/tokens/index.d.ts +21 -0
- package/lib/tokens/index.js +66 -0
- package/lib/types/agent.d.ts +62 -0
- package/lib/types/agent.js +1 -0
- package/lib/types/callbacks.d.ts +55 -0
- package/lib/types/callbacks.js +1 -0
- package/lib/types/composer.d.ts +116 -0
- package/lib/types/composer.js +1 -0
- package/lib/types/conversation.d.ts +54 -0
- package/lib/types/conversation.js +1 -0
- package/lib/types/display.d.ts +25 -0
- package/lib/types/display.js +40 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/index.js +8 -0
- package/lib/types/message.d.ts +100 -0
- package/lib/types/message.js +1 -0
- package/lib/types/selection.d.ts +60 -0
- package/lib/types/selection.js +1 -0
- package/lib/types/theme.d.ts +100 -0
- package/lib/types/theme.js +1 -0
- package/lib/utils/clipboard.d.ts +4 -0
- package/lib/utils/clipboard.js +41 -0
- package/lib/utils/cn.d.ts +2 -0
- package/lib/utils/cn.js +14 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/storage.d.ts +11 -0
- package/lib/utils/storage.js +48 -0
- package/package.json +93 -4
- package/src/styles/blocks.css +2439 -0
- package/src/styles/index.css +3 -0
- package/src/tokens/theme.css +464 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
|
+
import type { Agent } from "./agent";
|
|
3
|
+
import type { QueuedPrompt } from "./conversation";
|
|
4
|
+
export type SlashCommandKind = "insert" | "action";
|
|
5
|
+
export type SlashCommandSource = "builtin" | "skill" | "custom";
|
|
6
|
+
export interface SlashCommand {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
description: string;
|
|
10
|
+
trigger: string;
|
|
11
|
+
kind: SlashCommandKind;
|
|
12
|
+
icon: LucideIcon;
|
|
13
|
+
source?: SlashCommandSource;
|
|
14
|
+
insert?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SlashCommandContext {
|
|
17
|
+
streaming: boolean;
|
|
18
|
+
hasDraft: boolean;
|
|
19
|
+
wiredActions: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface SlashPickPlan {
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
insert: string;
|
|
25
|
+
}
|
|
26
|
+
export type ComposerTrigger = "@" | "/";
|
|
27
|
+
export interface TriggerToken {
|
|
28
|
+
trigger: ComposerTrigger;
|
|
29
|
+
start: number;
|
|
30
|
+
query: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PaletteFileEntry {
|
|
33
|
+
path: string;
|
|
34
|
+
entryKind: "file" | "dir";
|
|
35
|
+
}
|
|
36
|
+
export type PaletteItem = {
|
|
37
|
+
kind: "all";
|
|
38
|
+
} | {
|
|
39
|
+
kind: "agent";
|
|
40
|
+
agent: Agent;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "command";
|
|
43
|
+
command: SlashCommand;
|
|
44
|
+
} | ({
|
|
45
|
+
kind: "file";
|
|
46
|
+
} & PaletteFileEntry);
|
|
47
|
+
export type PaletteKeyAction = "move-next" | "move-prev" | "accept" | "close" | "newline";
|
|
48
|
+
export interface PaletteSource {
|
|
49
|
+
members: Agent[];
|
|
50
|
+
commands: readonly SlashCommand[];
|
|
51
|
+
files?: readonly PaletteFileEntry[];
|
|
52
|
+
}
|
|
53
|
+
export interface PickedFile {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly size: number;
|
|
56
|
+
readonly type: string;
|
|
57
|
+
}
|
|
58
|
+
export interface AttachmentRejection {
|
|
59
|
+
name: string;
|
|
60
|
+
reason: string;
|
|
61
|
+
}
|
|
62
|
+
export interface IncomingPlan<T extends PickedFile = PickedFile> {
|
|
63
|
+
images: T[];
|
|
64
|
+
videos: T[];
|
|
65
|
+
texts: T[];
|
|
66
|
+
rejected: AttachmentRejection[];
|
|
67
|
+
}
|
|
68
|
+
export type SubmitDecision = "send" | "enqueue" | "reject-full";
|
|
69
|
+
export type EnqueueOutcome = "queued" | "rejected-full" | "not-streaming";
|
|
70
|
+
export interface ComposerModelOption {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
hint?: string;
|
|
74
|
+
badge?: string;
|
|
75
|
+
badgeTone?: "neutral" | "warn" | "accent" | "danger";
|
|
76
|
+
multiplier?: string;
|
|
77
|
+
group?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ComposerModelSwitch {
|
|
80
|
+
value: string | null;
|
|
81
|
+
options: ComposerModelOption[];
|
|
82
|
+
onPick: (model: string | null) => void;
|
|
83
|
+
onConfigureCustom?: () => void;
|
|
84
|
+
}
|
|
85
|
+
export interface PermissionModeSwitch {
|
|
86
|
+
value: "ask" | "auto" | "yolo";
|
|
87
|
+
onChange: (mode: "ask" | "auto" | "yolo") => void;
|
|
88
|
+
}
|
|
89
|
+
export interface ComposerSubmitApi {
|
|
90
|
+
pick: (item: PaletteItem) => void;
|
|
91
|
+
submitOrQueue: () => void;
|
|
92
|
+
}
|
|
93
|
+
export interface QueuedPromptsApi {
|
|
94
|
+
items: QueuedPrompt[];
|
|
95
|
+
full: boolean;
|
|
96
|
+
enqueue: (text: string, attachments?: import("./message").Attachment[]) => EnqueueOutcome;
|
|
97
|
+
remove: (id: string) => void;
|
|
98
|
+
moveUp: (id: string) => void;
|
|
99
|
+
moveDown: (id: string) => void;
|
|
100
|
+
edit: (id: string) => string | null;
|
|
101
|
+
sendNow: (id: string) => void;
|
|
102
|
+
}
|
|
103
|
+
export interface ComposerPaletteLike {
|
|
104
|
+
open: boolean;
|
|
105
|
+
token: TriggerToken | null;
|
|
106
|
+
items: PaletteItem[];
|
|
107
|
+
index: number;
|
|
108
|
+
selectedAgent: {
|
|
109
|
+
name: string;
|
|
110
|
+
} | null;
|
|
111
|
+
sync: (field: HTMLTextAreaElement, next: string) => void;
|
|
112
|
+
move: (delta: number) => void;
|
|
113
|
+
escape: () => void;
|
|
114
|
+
close: () => void;
|
|
115
|
+
}
|
|
116
|
+
export type { QueuedPrompt };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type ConversationId = string;
|
|
2
|
+
export type AgentId = string;
|
|
3
|
+
export type ConversationKind = "direct" | "group";
|
|
4
|
+
export type ConversationStatus = "idle" | "loading" | "streaming" | "error";
|
|
5
|
+
export interface Conversation {
|
|
6
|
+
id: ConversationId;
|
|
7
|
+
kind: ConversationKind;
|
|
8
|
+
title: string;
|
|
9
|
+
memberIds: AgentId[];
|
|
10
|
+
autoRespond: boolean;
|
|
11
|
+
unread: number;
|
|
12
|
+
pinned: boolean;
|
|
13
|
+
muted: boolean;
|
|
14
|
+
lastPreview: string;
|
|
15
|
+
timeLabel: string;
|
|
16
|
+
}
|
|
17
|
+
export interface PendingPermission {
|
|
18
|
+
permissionId: string;
|
|
19
|
+
tool: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
detail?: string;
|
|
22
|
+
risk?: "low" | "medium" | "high";
|
|
23
|
+
requestId?: string;
|
|
24
|
+
agentId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PendingAskQuestion {
|
|
27
|
+
id: string;
|
|
28
|
+
prompt: string;
|
|
29
|
+
choices: string[];
|
|
30
|
+
default: string | null;
|
|
31
|
+
multiSelect?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface PendingAsk {
|
|
34
|
+
turnId: string;
|
|
35
|
+
callId: string;
|
|
36
|
+
prompt: string;
|
|
37
|
+
choices: string[];
|
|
38
|
+
default: string | null;
|
|
39
|
+
agent: string | null;
|
|
40
|
+
questions: PendingAskQuestion[];
|
|
41
|
+
}
|
|
42
|
+
export type PermissionMode = "ask" | "auto" | "yolo";
|
|
43
|
+
export interface QueuedPrompt {
|
|
44
|
+
id: string;
|
|
45
|
+
text: string;
|
|
46
|
+
attachments?: import("./message").Attachment[];
|
|
47
|
+
}
|
|
48
|
+
export interface SessionSearchHit {
|
|
49
|
+
session_id: string;
|
|
50
|
+
title?: string;
|
|
51
|
+
snippet?: string;
|
|
52
|
+
timestamp?: string;
|
|
53
|
+
score?: number;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type RadiusMode = "rounded" | "square";
|
|
2
|
+
export type DensityMode = "comfortable" | "compact";
|
|
3
|
+
export type MessageStyleMode = "seamless" | "bubble";
|
|
4
|
+
export type BlockVisibilityKey = "reasoning" | "tool" | "sandbox" | "memory" | "compaction" | "usage" | "attachments" | "todo";
|
|
5
|
+
export type BlockVisibility = Record<BlockVisibilityKey, boolean>;
|
|
6
|
+
export type WidthPreset = "narrow" | "standard" | "wide" | "full";
|
|
7
|
+
export declare const WIDTH_PRESET_VALUES: Record<WidthPreset, number>;
|
|
8
|
+
export declare const WIDTH_MIN = 520;
|
|
9
|
+
export declare const WIDTH_MAX = 1600;
|
|
10
|
+
export declare function presetWidth(preset: WidthPreset, viewport?: number): number;
|
|
11
|
+
export interface DisplayConfig {
|
|
12
|
+
radius: RadiusMode;
|
|
13
|
+
density: DensityMode;
|
|
14
|
+
messageStyle: MessageStyleMode;
|
|
15
|
+
streamWidth: WidthPreset;
|
|
16
|
+
composerWidth: WidthPreset;
|
|
17
|
+
streamWidthPx: number | null;
|
|
18
|
+
composerWidthPx: number | null;
|
|
19
|
+
hidden: BlockVisibility;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_DISPLAY_CONFIG: DisplayConfig;
|
|
22
|
+
export declare const BLOCK_VISIBILITY_ORDER: {
|
|
23
|
+
key: BlockVisibilityKey;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const WIDTH_PRESET_VALUES = {
|
|
2
|
+
narrow: 560,
|
|
3
|
+
standard: 720,
|
|
4
|
+
wide: 880,
|
|
5
|
+
full: 0,
|
|
6
|
+
};
|
|
7
|
+
export const WIDTH_MIN = 520;
|
|
8
|
+
export const WIDTH_MAX = 1600;
|
|
9
|
+
export function presetWidth(preset, viewport = 1440) {
|
|
10
|
+
return preset === "full" ? viewport : WIDTH_PRESET_VALUES[preset];
|
|
11
|
+
}
|
|
12
|
+
export const DEFAULT_DISPLAY_CONFIG = {
|
|
13
|
+
radius: "rounded",
|
|
14
|
+
density: "comfortable",
|
|
15
|
+
messageStyle: "seamless",
|
|
16
|
+
streamWidth: "standard",
|
|
17
|
+
composerWidth: "standard",
|
|
18
|
+
streamWidthPx: null,
|
|
19
|
+
composerWidthPx: null,
|
|
20
|
+
hidden: {
|
|
21
|
+
reasoning: false,
|
|
22
|
+
tool: false,
|
|
23
|
+
sandbox: false,
|
|
24
|
+
memory: false,
|
|
25
|
+
compaction: false,
|
|
26
|
+
usage: false,
|
|
27
|
+
attachments: false,
|
|
28
|
+
todo: false,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export const BLOCK_VISIBILITY_ORDER = [
|
|
32
|
+
{ key: "reasoning", label: "深度思考" },
|
|
33
|
+
{ key: "tool", label: "工具调用" },
|
|
34
|
+
{ key: "sandbox", label: "沙箱执行" },
|
|
35
|
+
{ key: "memory", label: "记忆落库" },
|
|
36
|
+
{ key: "compaction", label: "上下文压缩" },
|
|
37
|
+
{ key: "usage", label: "上下文用量" },
|
|
38
|
+
{ key: "attachments", label: "消息附件" },
|
|
39
|
+
{ key: "todo", label: "任务清单" },
|
|
40
|
+
];
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type MessageRole = "user" | "assistant" | "system" | "tool";
|
|
2
|
+
export type MessageState = "streaming" | "done" | "error";
|
|
3
|
+
export type ToolCallState = "running" | "finished" | "error";
|
|
4
|
+
export interface Attachment {
|
|
5
|
+
media_type: string;
|
|
6
|
+
data_base64: string;
|
|
7
|
+
filename?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolCall {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
args?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface ToolCallPart {
|
|
15
|
+
kind: "tool";
|
|
16
|
+
toolCallId?: string;
|
|
17
|
+
tool: string;
|
|
18
|
+
state: ToolCallState;
|
|
19
|
+
args?: unknown;
|
|
20
|
+
result?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SandboxPart {
|
|
23
|
+
kind: "sandbox";
|
|
24
|
+
title: string;
|
|
25
|
+
state: ToolCallState;
|
|
26
|
+
output: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ReasoningPart {
|
|
29
|
+
kind: "reasoning";
|
|
30
|
+
text: string;
|
|
31
|
+
streaming: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface CompactionPart {
|
|
34
|
+
kind: "compact";
|
|
35
|
+
beforeTokens: number;
|
|
36
|
+
afterTokens: number;
|
|
37
|
+
reason: string;
|
|
38
|
+
requestId?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MemoryPart {
|
|
41
|
+
kind: "memory";
|
|
42
|
+
count: number;
|
|
43
|
+
excerpt: string;
|
|
44
|
+
requestId?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface DisplayPart {
|
|
47
|
+
kind: "display";
|
|
48
|
+
view: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
payload?: unknown;
|
|
51
|
+
requestId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface OutputPart {
|
|
54
|
+
kind: "output";
|
|
55
|
+
outputKind: "text" | "file" | "link" | "json";
|
|
56
|
+
label?: string;
|
|
57
|
+
value: string;
|
|
58
|
+
requestId?: string;
|
|
59
|
+
}
|
|
60
|
+
export type MessagePart = ToolCallPart | SandboxPart | ReasoningPart | CompactionPart | MemoryPart | DisplayPart | OutputPart;
|
|
61
|
+
export interface ContextUsageStat {
|
|
62
|
+
input: number;
|
|
63
|
+
output: number;
|
|
64
|
+
window: number;
|
|
65
|
+
breakdown?: ContextUsageSegment[];
|
|
66
|
+
windowPresets?: ContextWindowPreset[];
|
|
67
|
+
}
|
|
68
|
+
export interface ContextUsageSegment {
|
|
69
|
+
label: string;
|
|
70
|
+
tokens: number;
|
|
71
|
+
color: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ContextWindowPreset {
|
|
74
|
+
label: string;
|
|
75
|
+
window: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ChatMessage {
|
|
78
|
+
id: string;
|
|
79
|
+
role: MessageRole;
|
|
80
|
+
sourceId?: string;
|
|
81
|
+
agentId?: string;
|
|
82
|
+
text: string;
|
|
83
|
+
toolCalls?: ToolCall[];
|
|
84
|
+
createdAt?: string;
|
|
85
|
+
mentions?: string[];
|
|
86
|
+
attachments?: Attachment[];
|
|
87
|
+
parts?: MessagePart[];
|
|
88
|
+
contextUsage?: ContextUsageStat;
|
|
89
|
+
state?: MessageState;
|
|
90
|
+
requestId?: string;
|
|
91
|
+
timeLabel: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ExecEnvelope {
|
|
94
|
+
exit_code: number;
|
|
95
|
+
stdout: string;
|
|
96
|
+
stderr: string;
|
|
97
|
+
duration_ms?: number;
|
|
98
|
+
timed_out?: boolean;
|
|
99
|
+
truncated?: boolean;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ChatMessage } from "./message";
|
|
2
|
+
export type SelectionActionId = "copy" | "addToConversation" | "followup" | "breakdown" | "favorite";
|
|
3
|
+
export type SelectionScaffold = Exclude<SelectionActionId, "favorite" | "copy" | "addToConversation">;
|
|
4
|
+
export interface SelectionActionSpec {
|
|
5
|
+
id: SelectionActionId;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectionFacts {
|
|
9
|
+
raw: string;
|
|
10
|
+
blocked: boolean;
|
|
11
|
+
bubbleRole: string | null;
|
|
12
|
+
agentId: string | null;
|
|
13
|
+
}
|
|
14
|
+
export type SelectionActionPayload = {
|
|
15
|
+
kind: "insert";
|
|
16
|
+
text: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "copy";
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "favorite";
|
|
22
|
+
agentId: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export interface SelectionCapabilities {
|
|
26
|
+
copy: boolean;
|
|
27
|
+
remove: boolean;
|
|
28
|
+
reason: Partial<Record<"copy" | "remove", string>>;
|
|
29
|
+
}
|
|
30
|
+
export type MessageMenuItemId = "copy-text" | "quote" | "multi-select" | "copy-selection" | "trace" | "delete-message";
|
|
31
|
+
export interface MessageMenuItem {
|
|
32
|
+
id: MessageMenuItemId | string;
|
|
33
|
+
label: string;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
danger?: boolean;
|
|
36
|
+
separatorBefore?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface MessageMenuInput {
|
|
39
|
+
role: string;
|
|
40
|
+
text: string;
|
|
41
|
+
selection: string;
|
|
42
|
+
id?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface RectLike {
|
|
45
|
+
left: number;
|
|
46
|
+
top: number;
|
|
47
|
+
right: number;
|
|
48
|
+
bottom: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
}
|
|
52
|
+
export interface PopSize {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}
|
|
56
|
+
export interface PopPosition {
|
|
57
|
+
left: number;
|
|
58
|
+
top: number;
|
|
59
|
+
}
|
|
60
|
+
export type { ChatMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type ThemeName = "dark" | "light" | "glass";
|
|
2
|
+
export interface SemanticPalette {
|
|
3
|
+
appBg: string;
|
|
4
|
+
primary: string;
|
|
5
|
+
primaryForeground: string;
|
|
6
|
+
surface950: string;
|
|
7
|
+
surface900: string;
|
|
8
|
+
surface800: string;
|
|
9
|
+
surface700: string;
|
|
10
|
+
surface600: string;
|
|
11
|
+
surface500: string;
|
|
12
|
+
surfaceOverlay: string;
|
|
13
|
+
surfaceSheet: string;
|
|
14
|
+
text100: string;
|
|
15
|
+
text200: string;
|
|
16
|
+
text300: string;
|
|
17
|
+
text400: string;
|
|
18
|
+
text500: string;
|
|
19
|
+
text600: string;
|
|
20
|
+
text700: string;
|
|
21
|
+
border800: string;
|
|
22
|
+
border700: string;
|
|
23
|
+
border600: string;
|
|
24
|
+
border500: string;
|
|
25
|
+
accentPrimary: string;
|
|
26
|
+
accentPrimaryHover: string;
|
|
27
|
+
accentPrimaryLight: string;
|
|
28
|
+
accentPrimaryBorder: string;
|
|
29
|
+
accentSuccess: string;
|
|
30
|
+
accentWarning: string;
|
|
31
|
+
accentDanger: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ControlScale {
|
|
34
|
+
xs: number;
|
|
35
|
+
sm: number;
|
|
36
|
+
md: number;
|
|
37
|
+
lg: number;
|
|
38
|
+
}
|
|
39
|
+
export interface TypeScale {
|
|
40
|
+
micro: {
|
|
41
|
+
size: number;
|
|
42
|
+
lineHeight: number;
|
|
43
|
+
};
|
|
44
|
+
meta: {
|
|
45
|
+
size: number;
|
|
46
|
+
lineHeight: number;
|
|
47
|
+
};
|
|
48
|
+
body: {
|
|
49
|
+
size: number;
|
|
50
|
+
lineHeight: number;
|
|
51
|
+
};
|
|
52
|
+
label: {
|
|
53
|
+
size: number;
|
|
54
|
+
lineHeight: number;
|
|
55
|
+
};
|
|
56
|
+
title: {
|
|
57
|
+
size: number;
|
|
58
|
+
lineHeight: number;
|
|
59
|
+
};
|
|
60
|
+
heading: {
|
|
61
|
+
size: number;
|
|
62
|
+
lineHeight: number;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface GapScale {
|
|
66
|
+
xs: number;
|
|
67
|
+
sm: number;
|
|
68
|
+
md: number;
|
|
69
|
+
lg: number;
|
|
70
|
+
xl: number;
|
|
71
|
+
xxl: number;
|
|
72
|
+
stream: number;
|
|
73
|
+
bubbleX: number;
|
|
74
|
+
bubbleY: number;
|
|
75
|
+
}
|
|
76
|
+
export interface RadiusScale {
|
|
77
|
+
sm: string;
|
|
78
|
+
md: string;
|
|
79
|
+
lg: string;
|
|
80
|
+
xl: string;
|
|
81
|
+
pill: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ZIndexScale {
|
|
84
|
+
underCanvas: number;
|
|
85
|
+
sticky: number;
|
|
86
|
+
canvasOverlay: number;
|
|
87
|
+
panel: number;
|
|
88
|
+
tooltip: number;
|
|
89
|
+
modal: number;
|
|
90
|
+
top: number;
|
|
91
|
+
}
|
|
92
|
+
export interface DesignTokens {
|
|
93
|
+
theme: ThemeName;
|
|
94
|
+
palette: SemanticPalette;
|
|
95
|
+
control: ControlScale;
|
|
96
|
+
type: TypeScale;
|
|
97
|
+
gaps: GapScale;
|
|
98
|
+
radius: RadiusScale;
|
|
99
|
+
z: ZIndexScale;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function writeClipboard(text: string): Promise<boolean>;
|
|
2
|
+
export declare function readClipboard(): Promise<string | null>;
|
|
3
|
+
export declare const CLIPBOARD_COPY_FAIL = "\u590D\u5236\u5931\u8D25\uFF1A\u65E0\u6CD5\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u6539\u7528 Ctrl+C";
|
|
4
|
+
export declare const CLIPBOARD_READ_FAIL = "\u65E0\u6CD5\u8BFB\u53D6\u526A\u8D34\u677F\uFF1A\u8BF7\u6539\u7528 Ctrl+V \u7C98\u8D34";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export async function writeClipboard(text) {
|
|
2
|
+
try {
|
|
3
|
+
if (navigator.clipboard?.writeText) {
|
|
4
|
+
await navigator.clipboard.writeText(text);
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return legacyCopy(text);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return legacyCopy(text);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function readClipboard() {
|
|
14
|
+
try {
|
|
15
|
+
if (navigator.clipboard?.readText) {
|
|
16
|
+
return await navigator.clipboard.readText();
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function legacyCopy(text) {
|
|
25
|
+
try {
|
|
26
|
+
const ta = document.createElement("textarea");
|
|
27
|
+
ta.value = text;
|
|
28
|
+
ta.style.position = "fixed";
|
|
29
|
+
ta.style.opacity = "0";
|
|
30
|
+
document.body.appendChild(ta);
|
|
31
|
+
ta.select();
|
|
32
|
+
const ok = document.execCommand("copy");
|
|
33
|
+
document.body.removeChild(ta);
|
|
34
|
+
return ok;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const CLIPBOARD_COPY_FAIL = "复制失败:无法写入剪贴板,请改用 Ctrl+C";
|
|
41
|
+
export const CLIPBOARD_READ_FAIL = "无法读取剪贴板:请改用 Ctrl+V 粘贴";
|
package/lib/utils/cn.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
|
+
const twMerge = extendTailwindMerge({
|
|
4
|
+
extend: {
|
|
5
|
+
classGroups: {
|
|
6
|
+
"font-size": [
|
|
7
|
+
{ text: ["micro", "meta", "body", "label", "title", "heading"] },
|
|
8
|
+
],
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export function cn(...inputs) {
|
|
13
|
+
return twMerge(clsx(inputs));
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function loadJSON<T>(key: string, fallback: T): T;
|
|
2
|
+
export declare function saveJSON(key: string, value: unknown): void;
|
|
3
|
+
export declare function removeKey(key: string): void;
|
|
4
|
+
export declare const LS_KEYS: {
|
|
5
|
+
readonly inputHistory: "chat-ui.composer.input-history";
|
|
6
|
+
readonly queuedPrompts: "chat-ui.queued-prompts";
|
|
7
|
+
readonly composerHeight: "chat-ui.composer-height";
|
|
8
|
+
readonly paletteRecency: "chat-ui.palette-recency";
|
|
9
|
+
readonly displayConfig: "chat-ui.display-config";
|
|
10
|
+
readonly theme: "chat-ui.theme";
|
|
11
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const memory = new Map();
|
|
2
|
+
function available() {
|
|
3
|
+
try {
|
|
4
|
+
const k = "__chat_ui_probe__";
|
|
5
|
+
window.localStorage.setItem(k, "1");
|
|
6
|
+
window.localStorage.removeItem(k);
|
|
7
|
+
return window.localStorage;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function loadJSON(key, fallback) {
|
|
14
|
+
try {
|
|
15
|
+
const s = available()?.getItem(key) ?? memory.get(key) ?? null;
|
|
16
|
+
if (s == null)
|
|
17
|
+
return fallback;
|
|
18
|
+
return JSON.parse(s);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function saveJSON(key, value) {
|
|
25
|
+
const s = JSON.stringify(value);
|
|
26
|
+
try {
|
|
27
|
+
available()?.setItem(key, s);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
memory.set(key, s);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function removeKey(key) {
|
|
34
|
+
try {
|
|
35
|
+
available()?.removeItem(key);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
memory.delete(key);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const LS_KEYS = {
|
|
42
|
+
inputHistory: "chat-ui.composer.input-history",
|
|
43
|
+
queuedPrompts: "chat-ui.queued-prompts",
|
|
44
|
+
composerHeight: "chat-ui.composer-height",
|
|
45
|
+
paletteRecency: "chat-ui.palette-recency",
|
|
46
|
+
displayConfig: "chat-ui.display-config",
|
|
47
|
+
theme: "chat-ui.theme",
|
|
48
|
+
};
|