@vitral/chat 0.2.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.
@@ -0,0 +1,164 @@
1
+ import type { Locale } from '@vitral/core';
2
+ import type { OverlayTarget } from '@vitral/controls';
3
+ import type { ClassEntry } from '@vitral/styles';
4
+ import type { PassThrough } from '@vitral/dom';
5
+ /** Anything a renderer can be handed for a slot: a string, a node, nothing. */
6
+ export type Content = string | Node | null | undefined;
7
+ /**
8
+ * Who said it. `system` is the note that is neither side of the conversation —
9
+ * a topic change, a model swap, the day turning over.
10
+ */
11
+ export type ChatRole = 'user' | 'assistant' | 'system';
12
+ /**
13
+ * What the chat is for, which decides its shape rather than its colours:
14
+ *
15
+ * - `basic`: the plain thread, for a page that is the conversation.
16
+ * - `messenger`: two people, so both sides get a bubble and an avatar.
17
+ * - `copilot`: a narrow column beside the work; no avatars, tighter rows.
18
+ * - `agent`: an assistant that uses tools, so the steps it took are shown.
19
+ * - `widget`: a launcher and a panel that opens over the page.
20
+ * - `captions`: a running transcript — no bubbles, the newest at the bottom,
21
+ * for speech as it is recognised.
22
+ */
23
+ export type ChatVariant = 'basic' | 'messenger' | 'copilot' | 'agent' | 'widget' | 'captions';
24
+ export interface ChatAttachment {
25
+ id?: string | number;
26
+ name: string;
27
+ /** Bytes. Shown beside the name when it is known. */
28
+ size?: number;
29
+ /** A media type, for the icon. */
30
+ type?: string;
31
+ url?: string;
32
+ }
33
+ /**
34
+ * A tool the assistant reached for. `status` is what to draw: still running,
35
+ * finished, or failed — which is the whole reason to show the step at all.
36
+ */
37
+ export interface ChatToolCall {
38
+ id?: string | number;
39
+ name: string;
40
+ /** What it was asked and what it answered, as text. */
41
+ input?: string;
42
+ output?: string;
43
+ status?: 'running' | 'done' | 'error';
44
+ }
45
+ /** Where an answer got something, shown under it. */
46
+ export interface ChatCitation {
47
+ title: string;
48
+ url?: string;
49
+ }
50
+ export interface ChatMessage {
51
+ id: string | number;
52
+ role: ChatRole;
53
+ content?: string;
54
+ /** A name beside the avatar, when the role does not say enough. */
55
+ author?: string;
56
+ /** An image for the avatar; `initials` stands in without one. */
57
+ avatar?: string;
58
+ initials?: string;
59
+ at?: Date | string | number;
60
+ /**
61
+ * Still arriving. The message grows in place, a caret follows the last
62
+ * character, and the log announces it once it settles rather than on every
63
+ * token — a screen reader cannot follow a stream and should not try.
64
+ */
65
+ streaming?: boolean;
66
+ /** What went wrong, shown in the message's place. */
67
+ error?: string;
68
+ /** The reader can ask for this one again. */
69
+ retryable?: boolean;
70
+ attachments?: ChatAttachment[];
71
+ toolCalls?: ChatToolCall[];
72
+ citations?: ChatCitation[];
73
+ }
74
+ export interface ChatSendPayload {
75
+ text: string;
76
+ attachments: ChatAttachment[];
77
+ }
78
+ export interface ChatEvents {
79
+ /** The composer was submitted. The message is not added for you: add it and answer it. */
80
+ send?: (payload: ChatSendPayload) => void;
81
+ /** The composer's text changed. */
82
+ 'draft-change'?: (text: string) => void;
83
+ /** A message's retry button was pressed. */
84
+ retry?: (message: ChatMessage) => void;
85
+ /** A prompt starter was pressed. Sent as well, unless `preventSend` is called. */
86
+ suggestion?: (text: string) => void;
87
+ /** Files were chosen. Turn them into attachments and hand them back through `attachments`. */
88
+ attach?: (files: File[]) => void;
89
+ /** An attachment in the composer was removed. */
90
+ detach?: (attachment: ChatAttachment, index: number) => void;
91
+ /** The widget's panel opened or shut. */
92
+ 'open-change'?: (open: boolean) => void;
93
+ /** The reader scrolled away from the newest message, or came back to it. */
94
+ 'at-bottom-change'?: (atBottom: boolean) => void;
95
+ }
96
+ export interface ChatSlots {
97
+ /** Over the thread: a title, a model picker, a close button. */
98
+ header?: () => Content;
99
+ /** Under the composer: a disclaimer, a token count. */
100
+ footer?: () => Content;
101
+ /** Replaces the whole of one message's body. */
102
+ message?: (context: {
103
+ message: ChatMessage;
104
+ index: number;
105
+ }) => Content;
106
+ /** Replaces what is shown when there are no messages. */
107
+ empty?: () => Content;
108
+ /** The widget's launcher. */
109
+ launcher?: (context: {
110
+ open: boolean;
111
+ }) => Content;
112
+ }
113
+ export interface ChatConfig {
114
+ messages?: ChatMessage[];
115
+ /** What the composer holds. Give it back on `draft-change` to control it. */
116
+ draft?: string;
117
+ variant?: ChatVariant;
118
+ /** Named for a screen reader; the header's words are not always the name. */
119
+ ariaLabel?: string;
120
+ placeholder?: string;
121
+ /** Prompt starters, shown while the thread is empty. */
122
+ suggestions?: string[];
123
+ emptyMessage?: string;
124
+ /**
125
+ * Someone is composing a reply: `true` for the plain three dots, or the
126
+ * words to show instead ("Searching the docs…").
127
+ */
128
+ typing?: boolean | string;
129
+ /** The composer is there but cannot be used. */
130
+ disabled?: boolean;
131
+ /** No composer at all: a transcript. */
132
+ readonly?: boolean;
133
+ /** Show the paperclip. */
134
+ allowAttachments?: boolean;
135
+ /** An `accept` for the file input. */
136
+ accept?: string;
137
+ /** Attachments waiting in the composer. */
138
+ attachments?: ChatAttachment[];
139
+ /** Rows the composer grows to before it scrolls. Defaults to 6. */
140
+ maxRows?: number;
141
+ /** Enter sends and Shift+Enter breaks the line. False swaps them. */
142
+ sendOnEnter?: boolean;
143
+ /** The widget's panel. */
144
+ open?: boolean;
145
+ /**
146
+ * Where the widget's panel is put. It is taken out of the page and hung
147
+ * from the launcher, because a panel that opens over the page cannot live
148
+ * inside whatever box the launcher was dropped into — the first container
149
+ * with a scrollbar or a hidden overflow would cut it in half.
150
+ */
151
+ overlayTarget?: OverlayTarget;
152
+ zIndex?: number;
153
+ /** Height of the thread's scroller. Defaults to `'28rem'`. */
154
+ height?: string;
155
+ locale?: Locale;
156
+ unstyled?: boolean;
157
+ classes?: Partial<Record<string, ClassEntry>>;
158
+ pt?: PassThrough;
159
+ nonce?: string;
160
+ cssLayer?: string | false;
161
+ id?: string;
162
+ on?: ChatEvents;
163
+ slots?: ChatSlots;
164
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `@vitral/chat`: a conversation with no framework in it.
3
+ *
4
+ * - the engine: the runs a thread groups into, the sides, the initials, the
5
+ * roving focus and what a screen reader is told (also at `@vitral/chat/engine`);
6
+ * - `createChat()`: a DOM renderer with streaming, attachments, tool calls,
7
+ * suggestions and the composer, which the framework components wrap;
8
+ * - the classes and tokens are `@vitral/styles`' `chatStyle`, so a thread
9
+ * follows whatever preset the page is themed with.
10
+ */
11
+ export * from './engine/index';
12
+ export { createChat, type ChatHandle } from './chat';
13
+ export { chatView, type ChatActions, type ViewContext } from './render/chat';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { announcementOf, formatSize, groupMessages, initialsOf, messageKeyTarget, showsAvatars, showsBubbles, sideOf } from "./engine/state.js";
2
+ import { chatView } from "./render/chat.js";
3
+ import { createChat } from "./chat.js";
4
+ export { announcementOf, chatView, createChat, formatSize, groupMessages, initialsOf, messageKeyTarget, showsAvatars, showsBubbles, sideOf };
@@ -0,0 +1,44 @@
1
+ import { type Locale } from '@vitral/core';
2
+ import { type Child, type Props } from '@vitral/dom';
3
+ import type { ChatAttachment, ChatConfig, ChatMessage, ChatVariant } from '../engine/types';
4
+ export interface ChatActions {
5
+ send: () => void;
6
+ draft: (text: string) => void;
7
+ inputKeydown: (event: KeyboardEvent) => void;
8
+ logKeydown: (event: KeyboardEvent) => void;
9
+ focusMessage: (index: number) => void;
10
+ retry: (message: ChatMessage) => void;
11
+ suggest: (text: string) => void;
12
+ pickFiles: () => void;
13
+ filesPicked: (files: File[]) => void;
14
+ detach: (attachment: ChatAttachment, index: number) => void;
15
+ scrolled: (element: HTMLElement) => void;
16
+ jump: () => void;
17
+ toggleOpen: () => void;
18
+ }
19
+ export interface ViewContext {
20
+ config: ChatConfig;
21
+ locale: Locale;
22
+ variant: ChatVariant;
23
+ messages: ChatMessage[];
24
+ ids: {
25
+ log: string;
26
+ input: string;
27
+ message: (index: number) => string;
28
+ };
29
+ part: (name: string, state?: unknown) => Props;
30
+ /** The message that holds the log's tab stop. */
31
+ tabIndex: number;
32
+ /** The reader has scrolled away from the newest message. */
33
+ away: boolean;
34
+ announcement: string;
35
+ on: ChatActions;
36
+ /** Keeps the log and the composer reachable from the handle. */
37
+ refs: {
38
+ log: (el: Element | null) => void;
39
+ input: (el: Element | null) => void;
40
+ file: (el: Element | null) => void;
41
+ };
42
+ }
43
+ /** The thread: the header, the log, the composer — everything but the widget's shell. */
44
+ export declare function chatView(context: ViewContext): Child[];
@@ -0,0 +1,197 @@
1
+ import { formatSize, groupMessages, initialsOf, showsAvatars, sideOf } from "../engine/state.js";
2
+ import { formatMessage } from "@vitral/core";
3
+ import { h, iconNode, mergeAttrs } from "@vitral/dom";
4
+ import { getIcon } from "@vitral/icons";
5
+ //#region src/render/chat.ts
6
+ /**
7
+ * The conversation as plain objects: a scrolling log of runs of messages and
8
+ * the box that adds to it. What is drawn is decided here; what happens when it
9
+ * is pressed is the handle's.
10
+ */
11
+ var icon = (name, props) => iconNode(getIcon(name), props);
12
+ var content = (value) => value === null || value === void 0 ? null : value;
13
+ /** The time a message carries, in the reader's own format. */
14
+ function timeText(at, locale) {
15
+ if (at === void 0 || at === null) return void 0;
16
+ const date = at instanceof Date ? at : new Date(at);
17
+ if (Number.isNaN(date.getTime())) return void 0;
18
+ return new Intl.DateTimeFormat(locale.code, {
19
+ hour: "2-digit",
20
+ minute: "2-digit"
21
+ }).format(date);
22
+ }
23
+ function attachmentView(context, attachment, index, removable) {
24
+ const { part, on, locale } = context;
25
+ const size = formatSize(attachment.size);
26
+ const body = [
27
+ icon("paperclip"),
28
+ h("span", part("attachmentName"), attachment.name),
29
+ size ? h("span", part("attachmentSize"), size) : null,
30
+ removable ? h("button", mergeAttrs({ type: "button" }, part("attachmentRemove"), {
31
+ "aria-label": formatMessage(locale.chat.removeAttachment, { name: attachment.name }),
32
+ onClick: () => on.detach(attachment, index)
33
+ }), icon("close")) : null
34
+ ];
35
+ return attachment.url && !removable ? h("a", mergeAttrs({
36
+ key: `a${index}`,
37
+ href: attachment.url,
38
+ target: "_blank",
39
+ rel: "noreferrer"
40
+ }, part("attachment")), ...body) : h("span", mergeAttrs({ key: `a${index}` }, part("attachment")), ...body);
41
+ }
42
+ function toolView(context, tool, index) {
43
+ const { part, locale } = context;
44
+ const status = tool.status ?? "done";
45
+ const words = status === "running" ? locale.chat.toolRunning : status === "error" ? locale.chat.toolFailed : locale.chat.toolDone;
46
+ const detail = [tool.input, tool.output].filter(Boolean).join("\n\n");
47
+ return h("details", mergeAttrs({ key: `t${index}` }, part("tool")), h("summary", part("toolSummary"), icon(status === "running" ? "spinner" : status === "error" ? "warning" : "check", status === "running" ? { spin: true } : void 0), h("span", part("toolName"), tool.name), h("span", part("toolStatus", { status }), words)), detail ? h("pre", part("toolBody"), detail) : null);
48
+ }
49
+ function messageView(context, message, index) {
50
+ const { part, locale, on, config, ids, tabIndex } = context;
51
+ const side = sideOf(message.role);
52
+ const custom = config.slots?.message?.({
53
+ message,
54
+ index
55
+ });
56
+ const time = timeText(message.at, locale);
57
+ const body = message.error ?? message.content ?? "";
58
+ return h("div", mergeAttrs({
59
+ key: String(message.id),
60
+ id: ids.message(index)
61
+ }, part("message", {
62
+ side,
63
+ role: message.role,
64
+ error: !!message.error,
65
+ streaming: !!message.streaming
66
+ }), {
67
+ role: "listitem",
68
+ tabindex: index === tabIndex ? 0 : -1,
69
+ onFocus: () => on.focusMessage(index)
70
+ }), custom !== null && custom !== void 0 ? content(custom) : [
71
+ message.toolCalls?.length ? h("div", mergeAttrs({ key: "tools" }, part("tools")), ...message.toolCalls.map((tool, i) => toolView(context, tool, i))) : null,
72
+ body || message.streaming ? h("div", mergeAttrs({ key: "bubble" }, part("bubble")), body, message.streaming ? h("span", mergeAttrs({
73
+ key: "caret",
74
+ "aria-hidden": "true"
75
+ }, part("caret"))) : null) : null,
76
+ message.attachments?.length ? h("div", mergeAttrs({ key: "files" }, part("attachments")), ...message.attachments.map((a, i) => attachmentView(context, a, i, false))) : null,
77
+ message.citations?.length ? h("div", mergeAttrs({ key: "cites" }, part("citations")), ...message.citations.map((c, i) => c.url ? h("a", mergeAttrs({
78
+ key: `c${i}`,
79
+ href: c.url,
80
+ target: "_blank",
81
+ rel: "noreferrer"
82
+ }, part("citation")), `${i + 1}. ${c.title}`) : h("span", mergeAttrs({ key: `c${i}` }, part("citation")), `${i + 1}. ${c.title}`))) : null,
83
+ time || message.retryable ? h("div", mergeAttrs({ key: "meta" }, part("meta")), time ? h("time", part("time"), time) : null, message.retryable ? h("button", mergeAttrs({ type: "button" }, part("retry"), { onClick: () => on.retry(message) }), icon("refresh"), locale.chat.retry) : null) : null
84
+ ]);
85
+ }
86
+ function groupView(context, group) {
87
+ const { part, variant } = context;
88
+ const first = group.messages[0];
89
+ const side = sideOf(first.role);
90
+ const withAvatar = showsAvatars(variant) && first.role !== "system";
91
+ const author = first.author ?? (first.role === "assistant" ? context.config.ariaLabel : void 0);
92
+ return h("div", mergeAttrs({ key: `g${group.start}` }, part("group", { side })), withAvatar ? h("span", mergeAttrs({
93
+ key: "avatar",
94
+ "aria-hidden": "true"
95
+ }, part("avatar", {})), first.avatar ? h("img", {
96
+ src: first.avatar,
97
+ alt: ""
98
+ }) : initialsOf(first)) : null, h("div", mergeAttrs({ key: "stack" }, part("stack")), author && first.role !== "system" ? h("span", mergeAttrs({ key: "author" }, part("author")), author) : null, ...group.messages.map((message, i) => messageView(context, message, group.start + i))));
99
+ }
100
+ function emptyView(context) {
101
+ const { part, config, locale, on } = context;
102
+ const custom = config.slots?.empty?.();
103
+ if (custom !== null && custom !== void 0) return h("div", mergeAttrs({ key: "empty" }, part("empty")), content(custom));
104
+ const suggestions = config.suggestions ?? [];
105
+ return h("div", mergeAttrs({ key: "empty" }, part("empty")), h("p", { key: "text" }, config.emptyMessage ?? locale.chat.empty), suggestions.length ? h("div", mergeAttrs({ key: "suggestions" }, part("suggestions")), ...suggestions.map((text, i) => h("button", mergeAttrs({
106
+ key: `s${i}`,
107
+ type: "button"
108
+ }, part("suggestion"), { onClick: () => on.suggest(text) }), text))) : null);
109
+ }
110
+ function typingView(context) {
111
+ const { part, config, locale } = context;
112
+ if (!config.typing) return null;
113
+ const words = typeof config.typing === "string" ? config.typing : locale.chat.typing;
114
+ return h("div", mergeAttrs({ key: "typing" }, part("typing")), h("span", mergeAttrs({
115
+ key: "dots",
116
+ "aria-hidden": "true"
117
+ }, part("typingDots")), h("span"), h("span"), h("span")), words);
118
+ }
119
+ function composerView(context) {
120
+ const { part, config, locale, on, ids, refs } = context;
121
+ if (config.readonly) return null;
122
+ const attachments = config.attachments ?? [];
123
+ const empty = !(config.draft ?? "").trim() && attachments.length === 0;
124
+ return h("div", mergeAttrs({ key: "composer" }, part("composer")), attachments.length ? h("div", mergeAttrs({ key: "staged" }, part("attachments")), ...attachments.map((a, i) => attachmentView(context, a, i, true))) : null, h("div", mergeAttrs({ key: "row" }, part("composerRow")), config.allowAttachments ? [h("input", mergeAttrs({
125
+ key: "file",
126
+ type: "file",
127
+ multiple: true,
128
+ accept: config.accept
129
+ }, part("file"), {
130
+ ref: refs.file,
131
+ onChange: (event) => on.filesPicked(Array.from(event.target.files ?? []))
132
+ })), h("button", mergeAttrs({
133
+ key: "attach",
134
+ type: "button"
135
+ }, part("attach"), {
136
+ "aria-label": locale.chat.attach,
137
+ disabled: config.disabled,
138
+ onClick: on.pickFiles
139
+ }), icon("paperclip"))] : null, h("textarea", mergeAttrs({
140
+ key: "input",
141
+ id: ids.input
142
+ }, part("input"), {
143
+ ref: refs.input,
144
+ rows: 1,
145
+ value: config.draft ?? "",
146
+ placeholder: config.placeholder ?? locale.chat.placeholder,
147
+ disabled: config.disabled,
148
+ "aria-label": locale.chat.message,
149
+ "aria-controls": ids.log,
150
+ onInput: (event) => on.draft(event.target.value),
151
+ onKeydown: on.inputKeydown
152
+ })), h("button", mergeAttrs({
153
+ key: "send",
154
+ type: "button"
155
+ }, part("send"), {
156
+ "aria-label": locale.chat.send,
157
+ disabled: config.disabled || empty,
158
+ onClick: on.send
159
+ }), icon("send"))));
160
+ }
161
+ /** The thread: the header, the log, the composer — everything but the widget's shell. */
162
+ function chatView(context) {
163
+ const { part, config, locale, messages, ids, on, refs, away, announcement } = context;
164
+ const header = config.slots?.header?.();
165
+ const footer = config.slots?.footer?.();
166
+ const groups = groupMessages(messages);
167
+ return [
168
+ header !== null && header !== void 0 ? h("div", mergeAttrs({ key: "header" }, part("header")), content(header)) : null,
169
+ h("div", mergeAttrs({
170
+ key: "log",
171
+ id: ids.log
172
+ }, part("log"), {
173
+ ref: refs.log,
174
+ role: "list",
175
+ "aria-label": config.ariaLabel ?? locale.chat.conversation,
176
+ tabindex: messages.length ? -1 : 0,
177
+ style: config.height ? { height: config.height } : void 0,
178
+ onKeydown: on.logKeydown,
179
+ onScroll: (event) => on.scrolled(event.target)
180
+ }), messages.length ? groups.map((group) => groupView(context, group)) : emptyView(context), typingView(context)),
181
+ away && messages.length ? h("button", mergeAttrs({
182
+ key: "jump",
183
+ type: "button"
184
+ }, part("jump"), { onClick: on.jump }), icon("chevronDown"), locale.chat.newest) : null,
185
+ composerView(context),
186
+ footer !== null && footer !== void 0 ? h("div", mergeAttrs({ key: "footer" }, part("footer")), content(footer)) : null,
187
+ h("div", mergeAttrs({
188
+ key: "status",
189
+ role: "status",
190
+ "aria-live": "polite"
191
+ }, part("status")), announcement)
192
+ ];
193
+ }
194
+ //#endregion
195
+ export { chatView };
196
+
197
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","names":[],"sources":["../../src/render/chat.ts"],"sourcesContent":["import { formatMessage, type Locale } from '@vitral/core';\nimport { h, iconNode, mergeAttrs, type Child, type Props } from '@vitral/dom';\nimport { getIcon } from '@vitral/icons';\nimport { formatSize, groupMessages, initialsOf, showsAvatars, sideOf, type ChatGroup } from '../engine/state';\nimport type { ChatAttachment, ChatConfig, ChatMessage, ChatToolCall, ChatVariant, Content } from '../engine/types';\n\n/**\n * The conversation as plain objects: a scrolling log of runs of messages and\n * the box that adds to it. What is drawn is decided here; what happens when it\n * is pressed is the handle's.\n */\n\nconst icon = (name: string, props?: Props): Child => iconNode(getIcon(name), props);\nconst content = (value: Content): Child => (value === null || value === undefined ? null : value);\n\nexport interface ChatActions {\n send: () => void;\n draft: (text: string) => void;\n inputKeydown: (event: KeyboardEvent) => void;\n logKeydown: (event: KeyboardEvent) => void;\n focusMessage: (index: number) => void;\n retry: (message: ChatMessage) => void;\n suggest: (text: string) => void;\n pickFiles: () => void;\n filesPicked: (files: File[]) => void;\n detach: (attachment: ChatAttachment, index: number) => void;\n scrolled: (element: HTMLElement) => void;\n jump: () => void;\n toggleOpen: () => void;\n}\n\nexport interface ViewContext {\n config: ChatConfig;\n locale: Locale;\n variant: ChatVariant;\n messages: ChatMessage[];\n ids: { log: string; input: string; message: (index: number) => string };\n part: (name: string, state?: unknown) => Props;\n /** The message that holds the log's tab stop. */\n tabIndex: number;\n /** The reader has scrolled away from the newest message. */\n away: boolean;\n announcement: string;\n on: ChatActions;\n /** Keeps the log and the composer reachable from the handle. */\n refs: { log: (el: Element | null) => void; input: (el: Element | null) => void; file: (el: Element | null) => void };\n}\n\n/** The time a message carries, in the reader's own format. */\nfunction timeText(at: ChatMessage['at'], locale: Locale): string | undefined {\n if (at === undefined || at === null) return undefined;\n const date = at instanceof Date ? at : new Date(at);\n if (Number.isNaN(date.getTime())) return undefined;\n return new Intl.DateTimeFormat(locale.code, { hour: '2-digit', minute: '2-digit' }).format(date);\n}\n\nfunction attachmentView(context: ViewContext, attachment: ChatAttachment, index: number, removable: boolean): Child {\n const { part, on, locale } = context;\n const size = formatSize(attachment.size);\n const body: Child[] = [\n icon('paperclip'),\n h('span', part('attachmentName'), attachment.name),\n size ? h('span', part('attachmentSize'), size) : null,\n removable\n ? h(\n 'button',\n mergeAttrs({ type: 'button' }, part('attachmentRemove'), {\n 'aria-label': formatMessage(locale.chat.removeAttachment, { name: attachment.name }),\n onClick: () => on.detach(attachment, index)\n }),\n icon('close')\n )\n : null\n ];\n // A file that has somewhere to go is a link; one that has not is a chip.\n return attachment.url && !removable\n ? h('a', mergeAttrs({ key: `a${index}`, href: attachment.url, target: '_blank', rel: 'noreferrer' }, part('attachment')), ...body)\n : h('span', mergeAttrs({ key: `a${index}` }, part('attachment')), ...body);\n}\n\nfunction toolView(context: ViewContext, tool: ChatToolCall, index: number): Child {\n const { part, locale } = context;\n const status = tool.status ?? 'done';\n const words = status === 'running' ? locale.chat.toolRunning : status === 'error' ? locale.chat.toolFailed : locale.chat.toolDone;\n const detail = [tool.input, tool.output].filter(Boolean).join('\\n\\n');\n return h(\n 'details',\n mergeAttrs({ key: `t${index}` }, part('tool')),\n h(\n 'summary',\n part('toolSummary'),\n icon(status === 'running' ? 'spinner' : status === 'error' ? 'warning' : 'check', status === 'running' ? { spin: true } : undefined),\n h('span', part('toolName'), tool.name),\n h('span', part('toolStatus', { status }), words)\n ),\n detail ? h('pre', part('toolBody'), detail) : null\n );\n}\n\nfunction messageView(context: ViewContext, message: ChatMessage, index: number): Child {\n const { part, locale, on, config, ids, tabIndex } = context;\n const side = sideOf(message.role);\n const custom = config.slots?.message?.({ message, index });\n const time = timeText(message.at, locale);\n const body = message.error ?? message.content ?? '';\n\n return h(\n 'div',\n mergeAttrs({ key: String(message.id), id: ids.message(index) }, part('message', { side, role: message.role, error: !!message.error, streaming: !!message.streaming }), {\n role: 'listitem',\n // One tab stop for the whole log; the arrows move within it, so a\n // long thread does not bury the composer behind a hundred tabs.\n tabindex: index === tabIndex ? 0 : -1,\n onFocus: () => on.focusMessage(index)\n }),\n custom !== null && custom !== undefined\n ? content(custom)\n : [\n message.toolCalls?.length ? h('div', mergeAttrs({ key: 'tools' }, part('tools')), ...message.toolCalls.map((tool, i) => toolView(context, tool, i))) : null,\n body || message.streaming\n ? h(\n 'div',\n mergeAttrs({ key: 'bubble' }, part('bubble')),\n body,\n // The caret follows the last character while the answer arrives.\n message.streaming ? h('span', mergeAttrs({ key: 'caret', 'aria-hidden': 'true' }, part('caret'))) : null\n )\n : null,\n message.attachments?.length\n ? h('div', mergeAttrs({ key: 'files' }, part('attachments')), ...message.attachments.map((a, i) => attachmentView(context, a, i, false)))\n : null,\n message.citations?.length\n ? h(\n 'div',\n mergeAttrs({ key: 'cites' }, part('citations')),\n ...message.citations.map((c, i) =>\n c.url\n ? h('a', mergeAttrs({ key: `c${i}`, href: c.url, target: '_blank', rel: 'noreferrer' }, part('citation')), `${i + 1}. ${c.title}`)\n : h('span', mergeAttrs({ key: `c${i}` }, part('citation')), `${i + 1}. ${c.title}`)\n )\n )\n : null,\n time || message.retryable\n ? h(\n 'div',\n mergeAttrs({ key: 'meta' }, part('meta')),\n time ? h('time', part('time'), time) : null,\n message.retryable\n ? h('button', mergeAttrs({ type: 'button' }, part('retry'), { onClick: () => on.retry(message) }), icon('refresh'), locale.chat.retry)\n : null\n )\n : null\n ]\n );\n}\n\nfunction groupView(context: ViewContext, group: ChatGroup): Child {\n const { part, variant } = context;\n const first = group.messages[0]!;\n const side = sideOf(first.role);\n const withAvatar = showsAvatars(variant) && first.role !== 'system';\n const author = first.author ?? (first.role === 'assistant' ? context.config.ariaLabel : undefined);\n\n return h(\n 'div',\n mergeAttrs({ key: `g${group.start}` }, part('group', { side })),\n withAvatar\n ? h(\n 'span',\n mergeAttrs({ key: 'avatar', 'aria-hidden': 'true' }, part('avatar', {})),\n first.avatar ? h('img', { src: first.avatar, alt: '' }) : initialsOf(first)\n )\n : null,\n h(\n 'div',\n mergeAttrs({ key: 'stack' }, part('stack')),\n // The name goes once a run, not once a message: that is what makes\n // a thread read as speech instead of as a list.\n author && first.role !== 'system' ? h('span', mergeAttrs({ key: 'author' }, part('author')), author) : null,\n ...group.messages.map((message, i) => messageView(context, message, group.start + i))\n )\n );\n}\n\nfunction emptyView(context: ViewContext): Child {\n const { part, config, locale, on } = context;\n const custom = config.slots?.empty?.();\n if (custom !== null && custom !== undefined) return h('div', mergeAttrs({ key: 'empty' }, part('empty')), content(custom));\n const suggestions = config.suggestions ?? [];\n return h(\n 'div',\n mergeAttrs({ key: 'empty' }, part('empty')),\n h('p', { key: 'text' }, config.emptyMessage ?? locale.chat.empty),\n suggestions.length\n ? h(\n 'div',\n mergeAttrs({ key: 'suggestions' }, part('suggestions')),\n ...suggestions.map((text, i) => h('button', mergeAttrs({ key: `s${i}`, type: 'button' }, part('suggestion'), { onClick: () => on.suggest(text) }), text))\n )\n : null\n );\n}\n\nfunction typingView(context: ViewContext): Child {\n const { part, config, locale } = context;\n if (!config.typing) return null;\n const words = typeof config.typing === 'string' ? config.typing : locale.chat.typing;\n return h(\n 'div',\n mergeAttrs({ key: 'typing' }, part('typing')),\n h('span', mergeAttrs({ key: 'dots', 'aria-hidden': 'true' }, part('typingDots')), h('span'), h('span'), h('span')),\n words\n );\n}\n\nfunction composerView(context: ViewContext): Child {\n const { part, config, locale, on, ids, refs } = context;\n if (config.readonly) return null;\n const attachments = config.attachments ?? [];\n const empty = !(config.draft ?? '').trim() && attachments.length === 0;\n return h(\n 'div',\n mergeAttrs({ key: 'composer' }, part('composer')),\n attachments.length ? h('div', mergeAttrs({ key: 'staged' }, part('attachments')), ...attachments.map((a, i) => attachmentView(context, a, i, true))) : null,\n h(\n 'div',\n mergeAttrs({ key: 'row' }, part('composerRow')),\n config.allowAttachments\n ? [\n h('input', mergeAttrs({ key: 'file', type: 'file', multiple: true, accept: config.accept }, part('file'), {\n ref: refs.file,\n onChange: (event: Event) => on.filesPicked(Array.from((event.target as HTMLInputElement).files ?? []))\n })),\n h('button', mergeAttrs({ key: 'attach', type: 'button' }, part('attach'), { 'aria-label': locale.chat.attach, disabled: config.disabled, onClick: on.pickFiles }), icon('paperclip'))\n ]\n : null,\n h('textarea', mergeAttrs({ key: 'input', id: ids.input }, part('input'), {\n ref: refs.input,\n rows: 1,\n value: config.draft ?? '',\n placeholder: config.placeholder ?? locale.chat.placeholder,\n disabled: config.disabled,\n 'aria-label': locale.chat.message,\n 'aria-controls': ids.log,\n onInput: (event: Event) => on.draft((event.target as HTMLTextAreaElement).value),\n onKeydown: on.inputKeydown\n })),\n h('button', mergeAttrs({ key: 'send', type: 'button' }, part('send'), { 'aria-label': locale.chat.send, disabled: config.disabled || empty, onClick: on.send }), icon('send'))\n )\n );\n}\n\n/** The thread: the header, the log, the composer — everything but the widget's shell. */\nexport function chatView(context: ViewContext): Child[] {\n const { part, config, locale, messages, ids, on, refs, away, announcement } = context;\n const header = config.slots?.header?.();\n const footer = config.slots?.footer?.();\n const groups = groupMessages(messages);\n\n return [\n header !== null && header !== undefined ? h('div', mergeAttrs({ key: 'header' }, part('header')), content(header)) : null,\n h(\n 'div',\n mergeAttrs({ key: 'log', id: ids.log }, part('log'), {\n ref: refs.log,\n role: 'list',\n 'aria-label': config.ariaLabel ?? locale.chat.conversation,\n tabindex: messages.length ? -1 : 0,\n style: config.height ? { height: config.height } : undefined,\n onKeydown: on.logKeydown,\n onScroll: (event: Event) => on.scrolled(event.target as HTMLElement)\n }),\n messages.length ? groups.map((group) => groupView(context, group)) : emptyView(context),\n typingView(context)\n ),\n // Going back to the newest message when the reader has scrolled off it,\n // which is the one thing an auto-scrolling log must never do for them.\n away && messages.length\n ? h('button', mergeAttrs({ key: 'jump', type: 'button' }, part('jump'), { onClick: on.jump }), icon('chevronDown'), locale.chat.newest)\n : null,\n composerView(context),\n footer !== null && footer !== undefined ? h('div', mergeAttrs({ key: 'footer' }, part('footer')), content(footer)) : null,\n // A message is announced once it has settled: a live region that changes\n // on every token of a stream says nothing anyone can follow.\n h('div', mergeAttrs({ key: 'status', role: 'status', 'aria-live': 'polite' }, part('status')), announcement)\n ];\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,QAAQ,MAAc,UAAyB,SAAS,QAAQ,IAAI,GAAG,KAAK;AAClF,IAAM,WAAW,UAA2B,UAAU,QAAQ,UAAU,KAAA,IAAY,OAAO;;AAoC3F,SAAS,SAAS,IAAuB,QAAoC;CACzE,IAAI,OAAO,KAAA,KAAa,OAAO,MAAM,OAAO,KAAA;CAC5C,MAAM,OAAO,cAAc,OAAO,KAAK,IAAI,KAAK,EAAE;CAClD,IAAI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,KAAK,KAAK;GACV,MAAM;GACN,cAAc,OAAO,aAAa,OAAO,KAAK;GAC9C,UAAU,SAAS,SAAS,KAAK;GACjC,OAAO,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,KAAA;GACnD,WAAW,GAAG;GACd,WAAW,UAAiB,GAAG,SAAS,MAAM,MAAqB;EACvE,CAAC,GACD,SAAS,SAAS,OAAO,KAAK,UAAU,UAAU,SAAS,KAAK,CAAC,IAAI,UAAU,OAAO,GACtF,WAAW,OAAO,CACtB;EAGA,QAAQ,SAAS,SACX,EAAE,UAAU,WAAW;GAAE,KAAK;GAAQ,MAAM;EAAS,GAAG,KAAK,MAAM,GAAG,EAAE,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,aAAa,GAAG,OAAO,KAAK,MAAM,IACpI;EACN,aAAa,OAAO;EACpB,WAAW,QAAQ,WAAW,KAAA,IAAY,EAAE,OAAO,WAAW,EAAE,KAAK,SAAS,GAAG,KAAK,QAAQ,CAAC,GAAG,QAAQ,MAAM,CAAC,IAAI;EAGrH,EAAE,OAAO,WAAW;GAAE,KAAK;GAAU,MAAM;GAAU,aAAa;EAAS,GAAG,KAAK,QAAQ,CAAC,GAAG,YAAY;CAC/G;AACJ"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@vitral/chat",
3
+ "version": "0.2.0",
4
+ "description": "Framework-free chat for Vitral: the engine (messages, grouping, streaming, the composer) and a DOM renderer with roving focus and live announcements, which the Vue, React and Angular components wrap.",
5
+ "keywords": [
6
+ "vitral",
7
+ "chat",
8
+ "chatbot",
9
+ "assistant",
10
+ "ai",
11
+ "copilot"
12
+ ],
13
+ "license": "LGPL-3.0-or-later",
14
+ "author": "Gustavo Will",
15
+ "homepage": "https://vitralui.github.io/vitral/",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/vitralui/vitral.git",
19
+ "directory": "packages/chat"
20
+ },
21
+ "bugs": "https://github.com/vitralui/vitral/issues",
22
+ "type": "module",
23
+ "sideEffects": [
24
+ "*.css"
25
+ ],
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./engine": {
35
+ "types": "./dist/engine/index.d.ts",
36
+ "import": "./dist/engine/index.js"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "LICENSE",
42
+ "LICENSE.GPL"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "dependencies": {
48
+ "@vitral/controls": "0.2.0",
49
+ "@vitral/icons": "0.2.0",
50
+ "@vitral/core": "0.2.0",
51
+ "@vitral/dom": "0.2.0",
52
+ "@vitral/styles": "0.2.0"
53
+ },
54
+ "scripts": {
55
+ "build": "vite build && tsc -p tsconfig.build.json"
56
+ }
57
+ }