@aleph-alpha/chat-kit 0.0.1-alpha.28

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 (105) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +70 -0
  3. package/dist/ChatInput.vue_vue_type_script_setup_true_lang-DVCUwptr.js +554 -0
  4. package/dist/ChatService-LogwJNxh.js +9 -0
  5. package/dist/components/base/AgentMessage/AgentMessage.stories.d.ts +11 -0
  6. package/dist/components/base/AgentMessage/AgentMessage.stories.d.ts.map +1 -0
  7. package/dist/components/base/AgentMessage/AgentMessage.vue.d.ts +20 -0
  8. package/dist/components/base/AgentMessage/AgentMessage.vue.d.ts.map +1 -0
  9. package/dist/components/base/AgentMessage/index.d.ts +2 -0
  10. package/dist/components/base/AgentMessage/index.d.ts.map +1 -0
  11. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.stories.d.ts +10 -0
  12. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.stories.d.ts.map +1 -0
  13. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.vue.d.ts +30 -0
  14. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.vue.d.ts.map +1 -0
  15. package/dist/components/base/ChatConversationLayout/index.d.ts +3 -0
  16. package/dist/components/base/ChatConversationLayout/index.d.ts.map +1 -0
  17. package/dist/components/base/ChatConversationLayout/types.d.ts +14 -0
  18. package/dist/components/base/ChatConversationLayout/types.d.ts.map +1 -0
  19. package/dist/components/base/PromptActionButton/PromptActionButton.stories.d.ts +9 -0
  20. package/dist/components/base/PromptActionButton/PromptActionButton.stories.d.ts.map +1 -0
  21. package/dist/components/base/PromptActionButton/PromptActionButton.vue.d.ts +24 -0
  22. package/dist/components/base/PromptActionButton/PromptActionButton.vue.d.ts.map +1 -0
  23. package/dist/components/base/PromptActionButton/index.d.ts +2 -0
  24. package/dist/components/base/PromptActionButton/index.d.ts.map +1 -0
  25. package/dist/components/base/PromptInput/PromptInput.stories.d.ts +10 -0
  26. package/dist/components/base/PromptInput/PromptInput.stories.d.ts.map +1 -0
  27. package/dist/components/base/PromptInput/PromptInput.vue.d.ts +46 -0
  28. package/dist/components/base/PromptInput/PromptInput.vue.d.ts.map +1 -0
  29. package/dist/components/base/PromptInput/index.d.ts +2 -0
  30. package/dist/components/base/PromptInput/index.d.ts.map +1 -0
  31. package/dist/components/base/PromptInputDisclaimer/PromptInputDisclaimer.stories.d.ts +9 -0
  32. package/dist/components/base/PromptInputDisclaimer/PromptInputDisclaimer.stories.d.ts.map +1 -0
  33. package/dist/components/base/PromptInputDisclaimer/PromptInputDisclaimer.vue.d.ts +17 -0
  34. package/dist/components/base/PromptInputDisclaimer/PromptInputDisclaimer.vue.d.ts.map +1 -0
  35. package/dist/components/base/PromptInputDisclaimer/index.d.ts +2 -0
  36. package/dist/components/base/PromptInputDisclaimer/index.d.ts.map +1 -0
  37. package/dist/components/base/UserMessage/UserMessage.stories.d.ts +10 -0
  38. package/dist/components/base/UserMessage/UserMessage.stories.d.ts.map +1 -0
  39. package/dist/components/base/UserMessage/UserMessage.vue.d.ts +15 -0
  40. package/dist/components/base/UserMessage/UserMessage.vue.d.ts.map +1 -0
  41. package/dist/components/base/UserMessage/index.d.ts +3 -0
  42. package/dist/components/base/UserMessage/index.d.ts.map +1 -0
  43. package/dist/components/base/UserMessage/types.d.ts +8 -0
  44. package/dist/components/base/UserMessage/types.d.ts.map +1 -0
  45. package/dist/components/base/icons/SendIcon.vue.d.ts +4 -0
  46. package/dist/components/base/icons/SendIcon.vue.d.ts.map +1 -0
  47. package/dist/components/base/icons/index.d.ts +2 -0
  48. package/dist/components/base/icons/index.d.ts.map +1 -0
  49. package/dist/components/base/index.d.ts +9 -0
  50. package/dist/components/base/index.d.ts.map +1 -0
  51. package/dist/components/composed/ChatConversation/ChatConversation.stories.d.ts +16 -0
  52. package/dist/components/composed/ChatConversation/ChatConversation.stories.d.ts.map +1 -0
  53. package/dist/components/composed/ChatConversation/ChatConversation.vue.d.ts +45 -0
  54. package/dist/components/composed/ChatConversation/ChatConversation.vue.d.ts.map +1 -0
  55. package/dist/components/composed/ChatConversation/index.d.ts +3 -0
  56. package/dist/components/composed/ChatConversation/index.d.ts.map +1 -0
  57. package/dist/components/composed/ChatConversation/types.d.ts +13 -0
  58. package/dist/components/composed/ChatConversation/types.d.ts.map +1 -0
  59. package/dist/components/composed/ChatInput/ChatInput.stories.d.ts +13 -0
  60. package/dist/components/composed/ChatInput/ChatInput.stories.d.ts.map +1 -0
  61. package/dist/components/composed/ChatInput/ChatInput.vue.d.ts +52 -0
  62. package/dist/components/composed/ChatInput/ChatInput.vue.d.ts.map +1 -0
  63. package/dist/components/composed/ChatInput/index.d.ts +2 -0
  64. package/dist/components/composed/ChatInput/index.d.ts.map +1 -0
  65. package/dist/components/composed/index.d.ts +4 -0
  66. package/dist/components/composed/index.d.ts.map +1 -0
  67. package/dist/components/index.d.ts +5 -0
  68. package/dist/components/index.d.ts.map +1 -0
  69. package/dist/components/index.js +11 -0
  70. package/dist/composables/index.d.ts +5 -0
  71. package/dist/composables/index.d.ts.map +1 -0
  72. package/dist/composables/index.js +9 -0
  73. package/dist/composables/types.d.ts +31 -0
  74. package/dist/composables/types.d.ts.map +1 -0
  75. package/dist/composables/useChat.d.ts +19 -0
  76. package/dist/composables/useChat.d.ts.map +1 -0
  77. package/dist/composables/useChatKitLabels.d.ts +42 -0
  78. package/dist/composables/useChatKitLabels.d.ts.map +1 -0
  79. package/dist/handlers/index.d.ts +2 -0
  80. package/dist/handlers/index.d.ts.map +1 -0
  81. package/dist/handlers/index.js +4 -0
  82. package/dist/handlers/useMessageHandler.d.ts +27 -0
  83. package/dist/handlers/useMessageHandler.d.ts.map +1 -0
  84. package/dist/helpers/index.d.ts +2 -0
  85. package/dist/helpers/index.d.ts.map +1 -0
  86. package/dist/index.d.ts +9 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +22 -0
  89. package/dist/services/ChatService.d.ts +42 -0
  90. package/dist/services/ChatService.d.ts.map +1 -0
  91. package/dist/services/MockChatService.d.ts +10 -0
  92. package/dist/services/MockChatService.d.ts.map +1 -0
  93. package/dist/services/index.d.ts +4 -0
  94. package/dist/services/index.d.ts.map +1 -0
  95. package/dist/services/index.js +34 -0
  96. package/dist/services/types.d.ts +34 -0
  97. package/dist/services/types.d.ts.map +1 -0
  98. package/dist/test-setup.d.ts +6 -0
  99. package/dist/test-setup.d.ts.map +1 -0
  100. package/dist/types.d.ts +22 -0
  101. package/dist/types.d.ts.map +1 -0
  102. package/dist/useChat-CtN_iBTc.js +5 -0
  103. package/dist/useChatKitLabels-Bi0szl2l.js +18 -0
  104. package/dist/useMessageHandler-BdcOcw0w.js +73 -0
  105. package/package.json +93 -0
@@ -0,0 +1,42 @@
1
+ import type { InjectionKey } from 'vue';
2
+ /**
3
+ * All user-facing strings in ChatKit that may need translation.
4
+ *
5
+ * Consumers override these values by calling `provideChatKitLabels()`
6
+ * at the top of their component tree and passing translated strings.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { provideChatKitLabels } from '@aleph-alpha/chat-kit';
11
+ *
12
+ * const { t } = useI18n();
13
+ * provideChatKitLabels({
14
+ * agentAvatarAlt: t('chat.agentAvatarAlt'),
15
+ * inputPlaceholder: t('chat.inputPlaceholder'),
16
+ * });
17
+ * ```
18
+ */
19
+ export interface ChatKitLabels {
20
+ /** Alt text for the agent avatar image */
21
+ agentAvatarAlt: string;
22
+ /** Placeholder text for the chat input field */
23
+ inputPlaceholder: string;
24
+ }
25
+ /** English defaults used when no labels are provided by the consumer. */
26
+ export declare const defaultChatKitLabels: ChatKitLabels;
27
+ /** Vue injection key for ChatKit labels. */
28
+ export declare const CHAT_KIT_LABELS: InjectionKey<ChatKitLabels>;
29
+ /**
30
+ * Provide ChatKit labels to all descendant components.
31
+ * Call this in a parent component's `setup()` to override default English strings.
32
+ *
33
+ * Partial overrides are merged with the defaults so consumers only need to
34
+ * supply the keys they want to translate.
35
+ */
36
+ export declare function provideChatKitLabels(labels: Partial<ChatKitLabels>): void;
37
+ /**
38
+ * Retrieve ChatKit labels inside any ChatKit component.
39
+ * Falls back to `defaultChatKitLabels` when no ancestor has provided labels.
40
+ */
41
+ export declare function useChatKitLabels(): ChatKitLabels;
42
+ //# sourceMappingURL=useChatKitLabels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatKitLabels.d.ts","sourceRoot":"","sources":["../../src/composables/useChatKitLabels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAGxC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,aAGlC,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,aAAa,CAA6B,CAAC;AAEtF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAEzE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD"}
@@ -0,0 +1,2 @@
1
+ export { useMessageHandler } from './useMessageHandler';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { u } from "../useMessageHandler-BdcOcw0w.js";
2
+ export {
3
+ u as useMessageHandler
4
+ };
@@ -0,0 +1,27 @@
1
+ import type { BaseMessage, MessageRole, MessageStatus } from '../types';
2
+ import { Ref } from 'vue';
3
+ export declare const useMessageHandler: () => {
4
+ messages: Ref<BaseMessage[]>;
5
+ currentUserMessage: Readonly<Ref<string, string>>;
6
+ updateMessage: (message: {
7
+ id: string;
8
+ content: string;
9
+ role: MessageRole;
10
+ status: MessageStatus;
11
+ }) => void;
12
+ setCurrentUserMessage: (text: string) => void;
13
+ getMessageById: (id: string) => {
14
+ id: string;
15
+ role: MessageRole;
16
+ content: string;
17
+ createdAt: Date;
18
+ status: MessageStatus;
19
+ } | undefined;
20
+ clearCurrentUserMessage: () => void;
21
+ commitUserMessage: () => BaseMessage;
22
+ setMessages: (list: BaseMessage[]) => void;
23
+ removeMessage: (id: string) => void;
24
+ getLastUserMessage: () => BaseMessage | undefined;
25
+ clearMessages: () => void;
26
+ };
27
+ //# sourceMappingURL=useMessageHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMessageHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/useMessageHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAY,GAAG,EAAO,MAAM,KAAK,CAAC;AAwBzC,eAAO,MAAM,iBAAiB;cA6DM,GAAG,CAAC,WAAW,EAAE,CAAC;;6BArCpB;QAC9B,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,WAAW,CAAC;QAClB,MAAM,EAAE,aAAa,CAAC;KACvB;kCAzBoC,MAAM;yBAoCf,MAAM;;;;;;;;6BA5BJ,WAAW;wBAgCd,WAAW,EAAE;wBAIb,MAAM;8BAIF,WAAW,GAAG,SAAS;;CAqBvD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function generateId(): string;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,WAIzB"}
@@ -0,0 +1,9 @@
1
+ export { ChatService, type IChatService, type ChatConfig, type ChatMessage, type ChatResponse, type StreamEvent, } from './services';
2
+ export { useChat } from './composables';
3
+ export { provideChatKitLabels, useChatKitLabels, defaultChatKitLabels, CHAT_KIT_LABELS, } from './composables';
4
+ export type { ChatKitLabels, ChatActions, ChatState, UseChatReturn } from './composables';
5
+ export { useMessageHandler } from './handlers';
6
+ export { AgentMessage, ChatConversation, ChatConversationLayout, ChatInput, PromptActionButton, PromptInput, PromptInputDisclaimer, UserMessage, } from './components';
7
+ export type { ChatConversationLayoutProps, ChatConversationProps, UserMessageProps, } from './components';
8
+ export type { BaseMessage, MessageRole, MessageStatus } from './types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import { C } from "./ChatService-LogwJNxh.js";
2
+ import { u } from "./useChat-CtN_iBTc.js";
3
+ import { C as C2, d, p, u as u2 } from "./useChatKitLabels-Bi0szl2l.js";
4
+ import { u as u3 } from "./useMessageHandler-BdcOcw0w.js";
5
+ import { A, _, a, b, c, d as d2, e, f } from "./ChatInput.vue_vue_type_script_setup_true_lang-DVCUwptr.js";
6
+ export {
7
+ A as AgentMessage,
8
+ C2 as CHAT_KIT_LABELS,
9
+ _ as ChatConversation,
10
+ a as ChatConversationLayout,
11
+ b as ChatInput,
12
+ C as ChatService,
13
+ c as PromptActionButton,
14
+ d2 as PromptInput,
15
+ e as PromptInputDisclaimer,
16
+ f as UserMessage,
17
+ d as defaultChatKitLabels,
18
+ p as provideChatKitLabels,
19
+ u as useChat,
20
+ u2 as useChatKitLabels,
21
+ u3 as useMessageHandler
22
+ };
@@ -0,0 +1,42 @@
1
+ import type { ChatConfig, ChatMessage, ChatResponse, StreamEvent } from './types';
2
+ /**
3
+ * Interface for chat service implementations
4
+ *
5
+ * This is a skeleton interface that defines the contract for chat services.
6
+ * Implementations should provide concrete implementations of these methods.
7
+ */
8
+ export interface IChatService {
9
+ /**
10
+ * Send a message and receive a response
11
+ * @param message - The message to send
12
+ * @returns Promise resolving to the chat response
13
+ */
14
+ sendMessage(message: ChatMessage): Promise<ChatResponse>;
15
+ /**
16
+ * Get chat history
17
+ * @param limit - Maximum number of messages to retrieve
18
+ * @returns Promise resolving to an array of messages
19
+ */
20
+ getHistory(limit?: number): Promise<ChatMessage[]>;
21
+ /**
22
+ * Stream a message response
23
+ * @param message - The message to send
24
+ * @param onEvent - Callback for stream events
25
+ * @returns Promise that resolves when streaming is complete
26
+ */
27
+ streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
28
+ }
29
+ /**
30
+ * Abstract base class for chat service implementations
31
+ *
32
+ * This is a skeleton abstract class that can be extended to create
33
+ * concrete chat service implementations.
34
+ */
35
+ export declare abstract class ChatService implements IChatService {
36
+ protected config: ChatConfig;
37
+ constructor(config?: ChatConfig);
38
+ abstract sendMessage(message: ChatMessage): Promise<ChatResponse>;
39
+ abstract getHistory(limit?: number): Promise<ChatMessage[]>;
40
+ abstract streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
41
+ }
42
+ //# sourceMappingURL=ChatService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatService.d.ts","sourceRoot":"","sources":["../../src/services/ChatService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElF;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzD;;;;OAIG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3F;AAED;;;;;GAKG;AACH,8BAAsB,WAAY,YAAW,YAAY;IACvD,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEjB,MAAM,CAAC,EAAE,UAAU;IAI/B,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAC3D,QAAQ,CAAC,aAAa,CACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC;CACjB"}
@@ -0,0 +1,10 @@
1
+ import { ChatService, type IChatService } from './ChatService';
2
+ import type { ChatMessage, ChatResponse, StreamEvent } from './types';
3
+ export declare class MockChatService extends ChatService implements IChatService {
4
+ constructor();
5
+ sendMessage(message: ChatMessage): Promise<ChatResponse>;
6
+ getHistory(): Promise<ChatMessage[]>;
7
+ streamMessage(message: ChatMessage, onEvent: (event: StreamEvent) => void): Promise<void>;
8
+ private createBaseMessage;
9
+ }
10
+ //# sourceMappingURL=MockChatService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockChatService.d.ts","sourceRoot":"","sources":["../../src/services/MockChatService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,WAAY,YAAW,YAAY;;IAKhE,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IASxD,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAIpC,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/F,OAAO,CAAC,iBAAiB;CAS1B"}
@@ -0,0 +1,4 @@
1
+ export { ChatService, type IChatService } from './ChatService';
2
+ export { MockChatService } from './MockChatService';
3
+ export type { ChatConfig, ChatMessage, ChatResponse, StreamEvent } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { C as ChatService } from "../ChatService-LogwJNxh.js";
2
+ class MockChatService extends ChatService {
3
+ constructor() {
4
+ super({});
5
+ }
6
+ async sendMessage(message) {
7
+ const replyText = `Mock reply: ${message.content}`;
8
+ return {
9
+ message: this.createBaseMessage({ role: "assistant", content: replyText }),
10
+ metadata: { mock: true }
11
+ };
12
+ }
13
+ async getHistory() {
14
+ return [];
15
+ }
16
+ async streamMessage(message, onEvent) {
17
+ const response = await this.sendMessage(message);
18
+ onEvent({ type: "chunk", data: response.message.content });
19
+ onEvent({ type: "done" });
20
+ }
21
+ createBaseMessage(input) {
22
+ return {
23
+ id: crypto.randomUUID(),
24
+ role: input.role,
25
+ content: input.content,
26
+ createdAt: /* @__PURE__ */ new Date(),
27
+ status: "completed"
28
+ };
29
+ }
30
+ }
31
+ export {
32
+ ChatService,
33
+ MockChatService
34
+ };
@@ -0,0 +1,34 @@
1
+ import type { BaseMessage, MessageRole } from '../types';
2
+ /**
3
+ * Chat message sent to the service
4
+ */
5
+ export interface ChatMessage {
6
+ id: string;
7
+ role: MessageRole;
8
+ content: string;
9
+ }
10
+ /**
11
+ * Response from the chat service
12
+ */
13
+ export interface ChatResponse {
14
+ message: BaseMessage;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Stream event emitted during message streaming
19
+ */
20
+ export interface StreamEvent {
21
+ type: 'chunk' | 'done' | 'error';
22
+ data?: string;
23
+ error?: Error;
24
+ }
25
+ /**
26
+ * Configuration for the chat service
27
+ */
28
+ export interface ChatConfig {
29
+ apiEndpoint?: string;
30
+ timeout?: number;
31
+ retries?: number;
32
+ headers?: Record<string, string>;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Global test setup for JSDOM environment.
3
+ * Polyfills browser APIs not available in JSDOM.
4
+ */
5
+ import '@testing-library/jest-dom/vitest';
6
+ //# sourceMappingURL=test-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,kCAAkC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shared types used across the chat-kit package layers
3
+ */
4
+ /**
5
+ * Role of a message in a chat conversation
6
+ */
7
+ export type MessageRole = 'user' | 'assistant' | 'system';
8
+ /**
9
+ * Status of a message
10
+ */
11
+ export type MessageStatus = 'started' | 'sending' | 'completed' | 'error';
12
+ /**
13
+ * Base message structure
14
+ */
15
+ export interface BaseMessage {
16
+ id: string;
17
+ role: MessageRole;
18
+ content: string;
19
+ createdAt: Date;
20
+ status: MessageStatus;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;CACvB"}
@@ -0,0 +1,5 @@
1
+ function useChat() {
2
+ }
3
+ export {
4
+ useChat as u
5
+ };
@@ -0,0 +1,18 @@
1
+ import { provide, inject } from "vue";
2
+ const defaultChatKitLabels = {
3
+ agentAvatarAlt: "Agent avatar",
4
+ inputPlaceholder: "Type a message..."
5
+ };
6
+ const CHAT_KIT_LABELS = /* @__PURE__ */ Symbol("chat-kit-labels");
7
+ function provideChatKitLabels(labels) {
8
+ provide(CHAT_KIT_LABELS, { ...defaultChatKitLabels, ...labels });
9
+ }
10
+ function useChatKitLabels() {
11
+ return inject(CHAT_KIT_LABELS, defaultChatKitLabels);
12
+ }
13
+ export {
14
+ CHAT_KIT_LABELS as C,
15
+ defaultChatKitLabels as d,
16
+ provideChatKitLabels as p,
17
+ useChatKitLabels as u
18
+ };
@@ -0,0 +1,73 @@
1
+ import { ref, readonly } from "vue";
2
+ function generateId() {
3
+ return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : String(Date.now());
4
+ }
5
+ function createMessage(input) {
6
+ return {
7
+ id: input.id,
8
+ role: input.role,
9
+ content: input.content,
10
+ createdAt: /* @__PURE__ */ new Date(),
11
+ status: input.status
12
+ };
13
+ }
14
+ const useMessageHandler = () => {
15
+ const messages = ref([]);
16
+ const currentUserMessage = ref("");
17
+ function setCurrentUserMessage(text) {
18
+ currentUserMessage.value = text;
19
+ }
20
+ function clearCurrentUserMessage() {
21
+ currentUserMessage.value = "";
22
+ }
23
+ function commitUserMessage() {
24
+ const id = generateId();
25
+ const text = currentUserMessage.value.trim();
26
+ if (!text) throw new Error("No message");
27
+ const msg = createMessage({ id, role: "user", content: text, status: "completed" });
28
+ messages.value.push(msg);
29
+ clearCurrentUserMessage();
30
+ return msg;
31
+ }
32
+ function updateMessage(message) {
33
+ const messageToUpdate = messages.value.find((m) => m.id === message.id);
34
+ if (messageToUpdate) {
35
+ messageToUpdate.content = message.content;
36
+ messageToUpdate.role = message.role;
37
+ messageToUpdate.status = message.status;
38
+ } else {
39
+ messages.value.push(createMessage(message));
40
+ }
41
+ }
42
+ function getMessageById(id) {
43
+ return messages.value.find((m) => m.id === id);
44
+ }
45
+ function setMessages(list) {
46
+ messages.value = list;
47
+ }
48
+ function removeMessage(id) {
49
+ messages.value = messages.value.filter((m) => m.id !== id);
50
+ }
51
+ function getLastUserMessage() {
52
+ return [...messages.value].reverse().find((m) => m.role === "user");
53
+ }
54
+ function clearMessages() {
55
+ messages.value = [];
56
+ }
57
+ return {
58
+ messages: readonly(messages),
59
+ currentUserMessage: readonly(currentUserMessage),
60
+ updateMessage,
61
+ setCurrentUserMessage,
62
+ getMessageById,
63
+ clearCurrentUserMessage,
64
+ commitUserMessage,
65
+ setMessages,
66
+ removeMessage,
67
+ getLastUserMessage,
68
+ clearMessages
69
+ };
70
+ };
71
+ export {
72
+ useMessageHandler as u
73
+ };
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@aleph-alpha/chat-kit",
3
+ "version": "0.0.1-alpha.28",
4
+ "description": "Chat kit package for building chat interfaces with Vue",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./services": {
15
+ "import": "./dist/services/index.js",
16
+ "types": "./dist/services/index.d.ts"
17
+ },
18
+ "./composables": {
19
+ "import": "./dist/composables/index.js",
20
+ "types": "./dist/composables/index.d.ts"
21
+ },
22
+ "./components": {
23
+ "import": "./dist/components/index.js",
24
+ "types": "./dist/components/index.d.ts"
25
+ },
26
+ "./handlers": {
27
+ "import": "./dist/handlers/index.js",
28
+ "types": "./dist/handlers/index.d.ts"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "keywords": [
35
+ "chat",
36
+ "vue",
37
+ "typescript",
38
+ "kit"
39
+ ],
40
+ "author": "Pharia AI",
41
+ "license": "MIT",
42
+ "engines": {
43
+ "node": ">=20.19.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "registry": "https://npm.pkg.github.com"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/Aleph-Alpha/frontend-hub.git",
52
+ "directory": "packages/chat-kit"
53
+ },
54
+ "peerDependencies": {
55
+ "@aleph-alpha/ui-library": "*",
56
+ "pinia": "^3.0.0",
57
+ "vue": "^3.5.25"
58
+ },
59
+ "dependencies": {
60
+ "@aleph-alpha/ui-library": "1.15.0"
61
+ },
62
+ "devDependencies": {
63
+ "@storybook/addon-a11y": "^10.1.7",
64
+ "@storybook/addon-docs": "^10.1.7",
65
+ "@storybook/vue3-vite": "^10.1.7",
66
+ "@testing-library/jest-dom": "6.9.1",
67
+ "@testing-library/vue": "8.1.0",
68
+ "@types/node": "^25.1.0",
69
+ "@unocss/reset": "66.6.0",
70
+ "@vitejs/plugin-vue": "^6.0.3",
71
+ "@vue/test-utils": "^2.4.6",
72
+ "jsdom": "^25.0.1",
73
+ "storybook": "^10.2.10",
74
+ "pinia": "^3.0.3",
75
+ "typescript": "^5.9.3",
76
+ "unocss": "66.6.0",
77
+ "vite": "7.3.1",
78
+ "vitest": "^4.0.18",
79
+ "vue": "^3.5.25",
80
+ "vue-tsc": "^3.2.4",
81
+ "@aleph-alpha/config-css": "0.20.0"
82
+ },
83
+ "scripts": {
84
+ "build": "vite build && vue-tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir dist",
85
+ "dev": "vite build --watch",
86
+ "type-check": "vue-tsc --noEmit",
87
+ "test": "vitest run",
88
+ "format": "prettier --write .",
89
+ "lint": "prettier --check . && eslint --fix src",
90
+ "storybook": "storybook dev -p 6007",
91
+ "build-storybook": "storybook build"
92
+ }
93
+ }