@aleph-alpha/chat-kit 0.1.0 → 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.
Files changed (46) hide show
  1. package/dist/{ChatInput.vue_vue_type_script_setup_true_lang-DVCUwptr.js → ChatInput.vue_vue_type_script_setup_true_lang-DaXHxshB.js} +159 -34
  2. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.vue.d.ts +1 -0
  3. package/dist/components/base/ChatConversationLayout/ChatConversationLayout.vue.d.ts.map +1 -1
  4. package/dist/components/base/MarkdownRenderer/MarkdownRenderer.stories.d.ts +13 -0
  5. package/dist/components/base/MarkdownRenderer/MarkdownRenderer.stories.d.ts.map +1 -0
  6. package/dist/components/base/MarkdownRenderer/MarkdownRenderer.vue.d.ts +38 -0
  7. package/dist/components/base/MarkdownRenderer/MarkdownRenderer.vue.d.ts.map +1 -0
  8. package/dist/components/base/MarkdownRenderer/index.d.ts +3 -0
  9. package/dist/components/base/MarkdownRenderer/index.d.ts.map +1 -0
  10. package/dist/components/base/MarkdownRenderer/types.d.ts +36 -0
  11. package/dist/components/base/MarkdownRenderer/types.d.ts.map +1 -0
  12. package/dist/components/base/PromptActionButton/PromptActionButton.vue.d.ts +1 -1
  13. package/dist/components/base/PromptActionButton/PromptActionButton.vue.d.ts.map +1 -1
  14. package/dist/components/base/UserMessage/UserMessage.vue.d.ts.map +1 -1
  15. package/dist/components/base/index.d.ts +2 -0
  16. package/dist/components/base/index.d.ts.map +1 -1
  17. package/dist/components/composed/ChatConversation/ChatConversation.stories.d.ts +2 -0
  18. package/dist/components/composed/ChatConversation/ChatConversation.stories.d.ts.map +1 -1
  19. package/dist/components/composed/ChatConversation/ChatConversation.vue.d.ts +10 -0
  20. package/dist/components/composed/ChatConversation/ChatConversation.vue.d.ts.map +1 -1
  21. package/dist/components/composed/ChatConversation/defaultAgentMarkdownClasses.d.ts +3 -0
  22. package/dist/components/composed/ChatConversation/defaultAgentMarkdownClasses.d.ts.map +1 -0
  23. package/dist/components/composed/ChatConversation/types.d.ts +5 -0
  24. package/dist/components/composed/ChatConversation/types.d.ts.map +1 -1
  25. package/dist/components/index.d.ts +2 -2
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/components/index.js +6 -5
  28. package/dist/composables/index.d.ts +1 -0
  29. package/dist/composables/index.d.ts.map +1 -1
  30. package/dist/composables/index.js +3 -2
  31. package/dist/composables/useChatKitLabels.d.ts +20 -8
  32. package/dist/composables/useChatKitLabels.d.ts.map +1 -1
  33. package/dist/composables/useMarkdownParser.d.ts +6 -0
  34. package/dist/composables/useMarkdownParser.d.ts.map +1 -0
  35. package/dist/handlers/index.js +1 -1
  36. package/dist/handlers/useMessageHandler.d.ts +1 -0
  37. package/dist/handlers/useMessageHandler.d.ts.map +1 -1
  38. package/dist/index.d.ts +3 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +10 -8
  41. package/dist/test-utils/createTextPlugin.d.ts +2 -0
  42. package/dist/test-utils/createTextPlugin.d.ts.map +1 -0
  43. package/dist/useChatKitLabels-xZXcnxZZ.js +13740 -0
  44. package/dist/{useMessageHandler-BdcOcw0w.js → useMessageHandler-Db-ywEa6.js} +15 -6
  45. package/package.json +19 -9
  46. package/dist/useChatKitLabels-Bi0szl2l.js +0 -18
@@ -1,4 +1,4 @@
1
- import type { InjectionKey } from 'vue';
1
+ import type { ComputedRef, InjectionKey, Ref } from 'vue';
2
2
  /**
3
3
  * All user-facing strings in ChatKit that may need translation.
4
4
  *
@@ -10,33 +10,45 @@ import type { InjectionKey } from 'vue';
10
10
  * import { provideChatKitLabels } from '@aleph-alpha/chat-kit';
11
11
  *
12
12
  * const { t } = useI18n();
13
- * provideChatKitLabels({
13
+ * provideChatKitLabels(() => ({
14
14
  * agentAvatarAlt: t('chat.agentAvatarAlt'),
15
15
  * inputPlaceholder: t('chat.inputPlaceholder'),
16
- * });
16
+ * }));
17
17
  * ```
18
18
  */
19
- export interface ChatKitLabels {
19
+ export type ChatKitLabels = {
20
20
  /** Alt text for the agent avatar image */
21
21
  agentAvatarAlt: string;
22
+ /** Alt text for the loading avatar image */
23
+ agentLoadingAvatarAlt: string;
22
24
  /** Placeholder text for the chat input field */
23
25
  inputPlaceholder: string;
24
- }
26
+ };
25
27
  /** English defaults used when no labels are provided by the consumer. */
26
28
  export declare const defaultChatKitLabels: ChatKitLabels;
27
29
  /** Vue injection key for ChatKit labels. */
28
- export declare const CHAT_KIT_LABELS: InjectionKey<ChatKitLabels>;
30
+ export declare const CHAT_KIT_LABELS: InjectionKey<ComputedRef<ChatKitLabels>>;
31
+ type PartialLabels = Partial<ChatKitLabels>;
32
+ /** Only accepts `Ref`, `ComputedRef`, or a getter returning `Partial<ChatKitLabels>`. */
33
+ type ReactiveLabels = Ref<PartialLabels> | ComputedRef<PartialLabels> | (() => PartialLabels);
29
34
  /**
30
35
  * Provide ChatKit labels to all descendant components.
31
36
  * Call this in a parent component's `setup()` to override default English strings.
32
37
  *
38
+ * Only reactive sources are accepted (`Ref`, `ComputedRef`, or a getter function)
39
+ * so that labels update automatically when the consumer's locale changes.
40
+ *
33
41
  * Partial overrides are merged with the defaults so consumers only need to
34
42
  * supply the keys they want to translate.
35
43
  */
36
- export declare function provideChatKitLabels(labels: Partial<ChatKitLabels>): void;
44
+ export declare function provideChatKitLabels(labels: ReactiveLabels): void;
37
45
  /**
38
46
  * Retrieve ChatKit labels inside any ChatKit component.
39
47
  * Falls back to `defaultChatKitLabels` when no ancestor has provided labels.
48
+ *
49
+ * Returns a `ComputedRef` so that template bindings update automatically
50
+ * when the provided labels change (e.g. on locale switch).
40
51
  */
41
- export declare function useChatKitLabels(): ChatKitLabels;
52
+ export declare function useChatKitLabels(): ComputedRef<ChatKitLabels>;
53
+ export {};
42
54
  //# sourceMappingURL=useChatKitLabels.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatKitLabels.d.ts","sourceRoot":"","sources":["../../src/composables/useChatKitLabels.ts"],"names":[],"mapp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AAE9F;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKjE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,aAAa,CAAC,CAK7D"}
@@ -0,0 +1,6 @@
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ import { type PluggableList } from 'unified';
3
+ export declare function useMarkdownParser(source: MaybeRefOrGetter<string>, plugins: MaybeRefOrGetter<PluggableList | undefined>): {
4
+ html: import("vue").ComputedRef<string>;
5
+ };
6
+ //# sourceMappingURL=useMarkdownParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarkdownParser.d.ts","sourceRoot":"","sources":["../../src/composables/useMarkdownParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,gBAAgB,EAAW,MAAM,KAAK,CAAC;AAC/D,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAiBtD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,gBAAgB,CAAC,aAAa,GAAG,SAAS,CAAC;;EAwBrD"}
@@ -1,4 +1,4 @@
1
- import { u } from "../useMessageHandler-BdcOcw0w.js";
1
+ import { u } from "../useMessageHandler-Db-ywEa6.js";
2
2
  export {
3
3
  u as useMessageHandler
4
4
  };
@@ -22,6 +22,7 @@ export declare const useMessageHandler: () => {
22
22
  setMessages: (list: BaseMessage[]) => void;
23
23
  removeMessage: (id: string) => void;
24
24
  getLastUserMessage: () => BaseMessage | undefined;
25
+ updateMessageId: (oldId: string, newId: string) => void;
25
26
  clearMessages: () => void;
26
27
  };
27
28
  //# sourceMappingURL=useMessageHandler.d.ts.map
@@ -1 +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"}
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;cAwEM,GAAG,CAAC,WAAW,EAAE,CAAC;;6BAhDpB;QAC9B,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,WAAW,CAAC;QAClB,MAAM,EAAE,aAAa,CAAC;KACvB;kCAzBoC,MAAM;yBA0Cf,MAAM;;;;;;;;6BAlCJ,WAAW;wBAsCd,WAAW,EAAE;wBAIb,MAAM;8BAIF,WAAW,GAAG,SAAS;6BAItB,MAAM,SAAS,MAAM;;CAuBtD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export { ChatService, type IChatService, type ChatConfig, type ChatMessage, type ChatResponse, type StreamEvent, } from './services';
2
- export { useChat } from './composables';
2
+ export { useChat, useMarkdownParser } from './composables';
3
3
  export { provideChatKitLabels, useChatKitLabels, defaultChatKitLabels, CHAT_KIT_LABELS, } from './composables';
4
4
  export type { ChatKitLabels, ChatActions, ChatState, UseChatReturn } from './composables';
5
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';
6
+ export { AgentMessage, ChatConversation, ChatConversationLayout, ChatInput, MarkdownRenderer, PromptActionButton, PromptInput, PromptInputDisclaimer, UserMessage, } from './components';
7
+ export type { ChatConversationLayoutProps, ChatConversationProps, MarkdownElementClasses, MarkdownRendererProps, UserMessageProps, } from './components';
8
8
  export type { BaseMessage, MessageRole, MessageStatus } from './types';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC3D,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,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,22 +1,24 @@
1
1
  import { C } from "./ChatService-LogwJNxh.js";
2
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";
3
+ import { C as C2, d, p, u as u2, a } from "./useChatKitLabels-xZXcnxZZ.js";
4
+ import { u as u3 } from "./useMessageHandler-Db-ywEa6.js";
5
+ import { A, _, a as a2, b, c, d as d2, e, f, g } from "./ChatInput.vue_vue_type_script_setup_true_lang-DaXHxshB.js";
6
6
  export {
7
7
  A as AgentMessage,
8
8
  C2 as CHAT_KIT_LABELS,
9
9
  _ as ChatConversation,
10
- a as ChatConversationLayout,
10
+ a2 as ChatConversationLayout,
11
11
  b as ChatInput,
12
12
  C as ChatService,
13
- c as PromptActionButton,
14
- d2 as PromptInput,
15
- e as PromptInputDisclaimer,
16
- f as UserMessage,
13
+ c as MarkdownRenderer,
14
+ d2 as PromptActionButton,
15
+ e as PromptInput,
16
+ f as PromptInputDisclaimer,
17
+ g as UserMessage,
17
18
  d as defaultChatKitLabels,
18
19
  p as provideChatKitLabels,
19
20
  u as useChat,
20
21
  u2 as useChatKitLabels,
22
+ a as useMarkdownParser,
21
23
  u3 as useMessageHandler
22
24
  };
@@ -0,0 +1,2 @@
1
+ export declare function createTextPlugin(transform: (text: string) => string): () => (tree: any) => void;
2
+ //# sourceMappingURL=createTextPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTextPlugin.d.ts","sourceRoot":"","sources":["../../src/test-utils/createTextPlugin.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,UACpD,MAAM,GAAG,UAOxB"}