@twentyfourg/chat-kit 1.0.0-beta.1

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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +222 -0
  3. package/dist/chat-kit.js +1914 -0
  4. package/dist/chat-kit.js.map +1 -0
  5. package/dist/components/AssistantMessage.vue.d.ts +35 -0
  6. package/dist/components/Chat.vue.d.ts +72 -0
  7. package/dist/components/CitationPopover.vue.d.ts +11 -0
  8. package/dist/components/FeedbackRow.vue.d.ts +11 -0
  9. package/dist/components/IconButton.vue.d.ts +17 -0
  10. package/dist/components/InputBar.vue.d.ts +16 -0
  11. package/dist/components/KitIcon.vue.d.ts +12 -0
  12. package/dist/components/MessageList.vue.d.ts +36 -0
  13. package/dist/components/PageImageModal.vue.d.ts +14 -0
  14. package/dist/components/SourceCard.vue.d.ts +21 -0
  15. package/dist/components/SourceList.vue.d.ts +7 -0
  16. package/dist/components/ThinkingAnimation.vue.d.ts +15 -0
  17. package/dist/components/ThinkingIndicator.vue.d.ts +13 -0
  18. package/dist/components/ThinkingProcess.vue.d.ts +8 -0
  19. package/dist/components/UserMessage.vue.d.ts +7 -0
  20. package/dist/composables/useAutoScroll.d.ts +36 -0
  21. package/dist/composables/useChatEngine.d.ts +335 -0
  22. package/dist/composables/useDictation.d.ts +29 -0
  23. package/dist/copy.d.ts +144 -0
  24. package/dist/index.css +1 -0
  25. package/dist/index.d.ts +18 -0
  26. package/dist/services/anonymous-auth.d.ts +63 -0
  27. package/dist/services/base-camp-client.d.ts +66 -0
  28. package/dist/services/citations.d.ts +18 -0
  29. package/dist/services/entities.d.ts +29 -0
  30. package/dist/services/markdown.d.ts +47 -0
  31. package/dist/services/math.d.ts +36 -0
  32. package/dist/services/streaming-message.d.ts +32 -0
  33. package/dist/services/streaming.service.d.ts +84 -0
  34. package/dist/services/typewriter.d.ts +54 -0
  35. package/dist/testing/mock-transport.d.ts +52 -0
  36. package/dist/testing/setup-tests.d.ts +8 -0
  37. package/dist/theme.css +122 -0
  38. package/dist/types.d.ts +389 -0
  39. package/package.json +76 -0
@@ -0,0 +1,35 @@
1
+ import type { ChatEngineMessage } from '../composables/useChatEngine';
2
+ import type { ChatCitation, CitationType, MessageFeedback, ThinkingVariant } from '../types';
3
+ type __VLS_Props = {
4
+ message: ChatEngineMessage;
5
+ citationType?: CitationType;
6
+ /** Offers the reasoning behind this reply in a folded panel. */
7
+ showThinking?: boolean;
8
+ /** Which animation plays beside the header while this reply is still arriving. */
9
+ thinkingVariant?: ThinkingVariant;
10
+ /** Offers a button that copies the answer. Off by default. */
11
+ showCopy?: boolean;
12
+ };
13
+ declare var __VLS_39: {
14
+ message: ChatEngineMessage;
15
+ };
16
+ type __VLS_Slots = {} & {
17
+ 'message-actions'?: (props: typeof __VLS_39) => any;
18
+ };
19
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
+ rate: (messageId: string, value: MessageFeedback) => any;
21
+ retry: () => any;
22
+ citationClick: (messageId: string, citation: ChatCitation) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
24
+ onRate?: ((messageId: string, value: MessageFeedback) => any) | undefined;
25
+ onRetry?: (() => any) | undefined;
26
+ onCitationClick?: ((messageId: string, citation: ChatCitation) => any) | undefined;
27
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
+ declare const _default: typeof __VLS_export;
30
+ export default _default;
31
+ type __VLS_WithSlots<T, S> = T & {
32
+ new (): {
33
+ $slots: S;
34
+ };
35
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The chat itself: the conversation on top, the question field at the bottom.
3
+ * The app creates the engine (see useChatEngine) and hands it in, which also
4
+ * lets the app drive the chat from outside, for example when a suggested
5
+ * question is clicked.
6
+ */
7
+ import { type ChatCopyInput } from '../copy';
8
+ import type { ChatEngine, ChatEngineMessage } from '../composables/useChatEngine';
9
+ import type { AutoScrollMode, CitationType, MessageFeedback, ThinkingVariant } from '../types';
10
+ type __VLS_Props = {
11
+ /**
12
+ * The conversation to render, from useChatEngine. Required, and not a
13
+ * setting: everything below is optional and defaults to the behaviour the
14
+ * kit had before that setting existed.
15
+ */
16
+ engine: ChatEngine;
17
+ /** All of the app's copy text. Anything missing falls back to its default. */
18
+ copy?: ChatCopyInput;
19
+ /** Offers voice dictation, in browsers with speech recognition. */
20
+ showMic?: boolean;
21
+ /**
22
+ * How sources are presented: 'inline' turns [^N] markers into numbered
23
+ * chips with a passage popover, 'list' shows the source documents under
24
+ * the answer. Defaults to 'inline'.
25
+ */
26
+ citationType?: CitationType;
27
+ /** Which thinking animation plays while retrieving: 'ring' (default) or 'sparkles'. */
28
+ thinkingVariant?: ThinkingVariant;
29
+ /**
30
+ * Steps the waiting label through `copy.status.thinkingSequence` instead of
31
+ * holding one line, so a long retrieval reads as progress. Off by default.
32
+ */
33
+ rotateThinkingLabel?: boolean;
34
+ /**
35
+ * Shows the model's reasoning in a collapsible panel: live while an answer
36
+ * is being retrieved, and folded on the finished reply. Off by default.
37
+ */
38
+ showThinking?: boolean;
39
+ /**
40
+ * How far the conversation follows a streaming answer. 'reply' (the
41
+ * default) stops once the answer's header reaches the top, so it can be
42
+ * read from the beginning; 'bottom' keeps the newest text in view; 'off'
43
+ * leaves the view to the reader.
44
+ */
45
+ autoScroll?: AutoScrollMode;
46
+ /**
47
+ * Offers a button under each finished answer that copies it. Off by
48
+ * default, since a client may not want the action at all.
49
+ */
50
+ showCopy?: boolean;
51
+ };
52
+ declare var __VLS_10: {
53
+ message: ChatEngineMessage;
54
+ }, __VLS_13: {};
55
+ type __VLS_Slots = {} & {
56
+ 'message-actions'?: (props: typeof __VLS_10) => any;
57
+ } & {
58
+ welcome?: (props: typeof __VLS_13) => any;
59
+ };
60
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
61
+ rated: (message: ChatEngineMessage, value: MessageFeedback | null) => any;
62
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
63
+ onRated?: ((message: ChatEngineMessage, value: MessageFeedback | null) => any) | undefined;
64
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
65
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
66
+ declare const _default: typeof __VLS_export;
67
+ export default _default;
68
+ type __VLS_WithSlots<T, S> = T & {
69
+ new (): {
70
+ $slots: S;
71
+ };
72
+ };
@@ -0,0 +1,11 @@
1
+ import type { ChatCitation } from '../types';
2
+ type __VLS_Props = {
3
+ citation: ChatCitation;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ close: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onClose?: (() => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { MessageFeedback } from '../types';
2
+ type __VLS_Props = {
3
+ feedback: MessageFeedback | null;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ rate: (value: MessageFeedback) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onRate?: ((value: MessageFeedback) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,17 @@
1
+ type __VLS_Props = {
2
+ /** What the button does, e.g. "Send". Shown in the chip on hover. */
3
+ label: string;
4
+ };
5
+ declare var __VLS_1: {};
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_1) => any;
8
+ };
9
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,16 @@
1
+ import type { ChatInputMode } from '../types';
2
+ type __VLS_Props = {
3
+ /** True while an answer is streaming. Swaps the send button for a stop button. */
4
+ busy?: boolean;
5
+ /** Offers voice dictation, in browsers with speech recognition. */
6
+ showMic?: boolean;
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ stop: () => any;
10
+ send: (text: string, mode: ChatInputMode) => any;
11
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ onStop?: (() => any) | undefined;
13
+ onSend?: ((text: string, mode: ChatInputMode) => any) | undefined;
14
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: typeof __VLS_export;
16
+ export default _default;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The kit's own small icon set, drawn inline so the package needs no icon
3
+ * library from the app. Shapes for send, mic, and thumbs come from the
4
+ * project's Figma file. Color always follows the surrounding text color.
5
+ */
6
+ type __VLS_Props = {
7
+ name: 'send' | 'mic' | 'stop' | 'thumb-up' | 'thumb-down' | 'warning' | 'sparkle' | 'copy' | 'external-link' | 'chevron-down';
8
+ size?: number;
9
+ };
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import type { ChatEngine, ChatEngineMessage } from '../composables/useChatEngine';
2
+ import type { AutoScrollMode, CitationType, MessageFeedback, ThinkingVariant } from '../types';
3
+ type __VLS_Props = {
4
+ engine: ChatEngine;
5
+ citationType?: CitationType;
6
+ thinkingVariant?: ThinkingVariant;
7
+ /** Steps the waiting label through the copy sequence; see ThinkingIndicator. */
8
+ rotateThinkingLabel?: boolean;
9
+ /** Renders the model's reasoning, live and on finished replies. */
10
+ showThinking?: boolean;
11
+ /** How far the conversation follows a streaming answer; see AutoScrollMode. */
12
+ autoScroll?: AutoScrollMode;
13
+ /** Offers a copy button under each finished answer. */
14
+ showCopy?: boolean;
15
+ };
16
+ declare var __VLS_1: {}, __VLS_19: {
17
+ message: ChatEngineMessage;
18
+ };
19
+ type __VLS_Slots = {} & {
20
+ welcome?: (props: typeof __VLS_1) => any;
21
+ } & {
22
+ 'message-actions'?: (props: typeof __VLS_19) => any;
23
+ };
24
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ rated: (message: ChatEngineMessage, value: MessageFeedback | null) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
+ onRated?: ((message: ChatEngineMessage, value: MessageFeedback | null) => any) | undefined;
28
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
30
+ declare const _default: typeof __VLS_export;
31
+ export default _default;
32
+ type __VLS_WithSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -0,0 +1,14 @@
1
+ type __VLS_Props = {
2
+ url: string;
3
+ /** The document's name, shown above the image. */
4
+ title: string;
5
+ /** The page line, as the card already displays it. Empty hides the line. */
6
+ detail?: string;
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ close: () => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ onClose?: (() => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import type { UsedSource } from '../types';
2
+ type __VLS_Props = {
3
+ source: UsedSource;
4
+ /** The card's position in the list, for its "Source N" heading. */
5
+ index: number;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ viewPage: (payload: {
9
+ url: string;
10
+ title: string;
11
+ detail: string;
12
+ }) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onViewPage?: ((payload: {
15
+ url: string;
16
+ title: string;
17
+ detail: string;
18
+ }) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { UsedSource } from '../types';
2
+ type __VLS_Props = {
3
+ sources: UsedSource[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The waiting animation on its own, with no wording around it.
3
+ *
4
+ * Used twice: ThinkingIndicator pairs it with a label while an answer is
5
+ * being retrieved, and the assistant's own header shows it bare while the
6
+ * answer is still being written.
7
+ */
8
+ import type { ThinkingVariant } from '../types';
9
+ type __VLS_Props = {
10
+ /** Which animation plays: the spinning ring (default), stars, or dots. */
11
+ variant?: ThinkingVariant;
12
+ };
13
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import type { ThinkingVariant } from '../types';
2
+ type __VLS_Props = {
3
+ /** Which animation plays: the spinning ring (default), stars, or dots. */
4
+ variant?: ThinkingVariant;
5
+ /**
6
+ * Steps through copy.status.thinkingSequence while waiting, instead of
7
+ * holding the single `thinking` label.
8
+ */
9
+ rotateLabel?: boolean;
10
+ };
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
@@ -0,0 +1,8 @@
1
+ type __VLS_Props = {
2
+ text: string;
3
+ /** True for the live panel, which starts open and follows the text as it grows. */
4
+ streaming?: boolean;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { ChatEngineMessage } from '../composables/useChatEngine';
2
+ type __VLS_Props = {
3
+ message: ChatEngineMessage;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Keeps a scrolling element following new content, without ever fighting the
3
+ * user.
4
+ *
5
+ * Two states. While 'following', new content pulls the element down with a
6
+ * small glide each frame, so a new line slides up instead of snapping. Any
7
+ * upward scroll switches to 'manual', which stops all movement until the user
8
+ * returns to the bottom on their own; that switches back to 'following'.
9
+ *
10
+ * Following stops early when an `anchor` is given: the glide will not carry
11
+ * that element above the top of the view. An answer longer than the window
12
+ * therefore settles with its own beginning in view and grows out of sight
13
+ * below, so the reader can start reading rather than chasing the last line.
14
+ * Reading on past that point hands the view over to them, and following only
15
+ * takes it back when they reach the bottom.
16
+ */
17
+ import { type Ref } from 'vue';
18
+ import type { AutoScrollMode } from '../types';
19
+ export interface AutoScrollOptions {
20
+ /**
21
+ * How far to follow. Read through a getter rather than taken once, so an
22
+ * app can change its mind, which is also why the listeners below stay
23
+ * attached even while following is off. Defaults to 'reply'.
24
+ */
25
+ mode?: () => AutoScrollMode;
26
+ /**
27
+ * Resolves the element that following must not carry off the top, checked
28
+ * fresh each frame because the answer it belongs to is still being built.
29
+ * Returning null follows the bottom, as it did before this existed.
30
+ */
31
+ anchor?: () => HTMLElement | null;
32
+ }
33
+ export default function useAutoScroll(elementRef: Ref<HTMLElement | null>, options?: AutoScrollOptions): {
34
+ glideToBottom: () => void;
35
+ resetToFollowing: () => void;
36
+ };