@aleph-alpha/chat-kit 0.8.0 → 1.0.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 (154) hide show
  1. package/dist/{CkInput.vue_vue_type_script_setup_true_lang-Bpa5PJj-.js → CkInput.vue_vue_type_script_setup_true_lang-744ZHsQU.js} +562 -100
  2. package/dist/chat-kit.css +9 -14
  3. package/dist/components/base/CkAgentMessage/CkAgentMessage.stories.d.ts +20 -0
  4. package/dist/components/base/CkAgentMessage/CkAgentMessage.stories.d.ts.map +1 -1
  5. package/dist/components/base/CkAgentMessage/CkAgentMessage.vue.d.ts.map +1 -1
  6. package/dist/components/base/CkAgentMessage/index.d.ts +1 -0
  7. package/dist/components/base/CkAgentMessage/index.d.ts.map +1 -1
  8. package/dist/components/base/CkAgentMessage/types.d.ts +12 -0
  9. package/dist/components/base/CkAgentMessage/types.d.ts.map +1 -0
  10. package/dist/components/base/CkConversationLayout/CkConversationLayout.stories.d.ts +13 -0
  11. package/dist/components/base/CkConversationLayout/CkConversationLayout.stories.d.ts.map +1 -1
  12. package/dist/components/base/CkConversationLayout/CkConversationLayout.vue.d.ts.map +1 -1
  13. package/dist/components/base/CkConversationLayout/types.d.ts +9 -2
  14. package/dist/components/base/CkConversationLayout/types.d.ts.map +1 -1
  15. package/dist/components/base/CkCopyMessageActionButton/CkCopyMessageActionButton.stories.d.ts +8 -0
  16. package/dist/components/base/CkCopyMessageActionButton/CkCopyMessageActionButton.stories.d.ts.map +1 -1
  17. package/dist/components/base/CkCopyMessageActionButton/CkCopyMessageActionButton.vue.d.ts +3 -15
  18. package/dist/components/base/CkCopyMessageActionButton/CkCopyMessageActionButton.vue.d.ts.map +1 -1
  19. package/dist/components/base/CkCopyMessageActionButton/index.d.ts +1 -0
  20. package/dist/components/base/CkCopyMessageActionButton/index.d.ts.map +1 -1
  21. package/dist/components/base/CkCopyMessageActionButton/types.d.ts +45 -0
  22. package/dist/components/base/CkCopyMessageActionButton/types.d.ts.map +1 -0
  23. package/dist/components/base/CkHistoryItem/CkHistoryItem.stories.d.ts +31 -0
  24. package/dist/components/base/CkHistoryItem/CkHistoryItem.stories.d.ts.map +1 -0
  25. package/dist/components/base/CkHistoryItem/CkHistoryItem.vue.d.ts +32 -0
  26. package/dist/components/base/CkHistoryItem/CkHistoryItem.vue.d.ts.map +1 -0
  27. package/dist/components/base/CkHistoryItem/activeIndicator.d.ts +15 -0
  28. package/dist/components/base/CkHistoryItem/activeIndicator.d.ts.map +1 -0
  29. package/dist/components/base/CkHistoryItem/index.d.ts +3 -0
  30. package/dist/components/base/CkHistoryItem/index.d.ts.map +1 -0
  31. package/dist/components/base/CkHistoryItem/types.d.ts +95 -0
  32. package/dist/components/base/CkHistoryItem/types.d.ts.map +1 -0
  33. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.stories.d.ts +16 -0
  34. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.stories.d.ts.map +1 -0
  35. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.vue.d.ts +17 -0
  36. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.vue.d.ts.map +1 -0
  37. package/dist/components/base/CkHistoryWrapper/index.d.ts +3 -0
  38. package/dist/components/base/CkHistoryWrapper/index.d.ts.map +1 -0
  39. package/dist/components/base/CkHistoryWrapper/types.d.ts +17 -0
  40. package/dist/components/base/CkHistoryWrapper/types.d.ts.map +1 -0
  41. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts +28 -0
  42. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts.map +1 -1
  43. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue.d.ts.map +1 -1
  44. package/dist/components/base/CkMarkdownRenderer/index.d.ts +1 -1
  45. package/dist/components/base/CkMarkdownRenderer/index.d.ts.map +1 -1
  46. package/dist/components/base/CkMarkdownRenderer/types.d.ts +16 -0
  47. package/dist/components/base/CkMarkdownRenderer/types.d.ts.map +1 -1
  48. package/dist/components/base/CkMessageActionButton/CkMessageActionButton.stories.d.ts +4 -0
  49. package/dist/components/base/CkMessageActionButton/CkMessageActionButton.stories.d.ts.map +1 -1
  50. package/dist/components/base/CkMessageActionButton/CkMessageActionButton.vue.d.ts +2 -5
  51. package/dist/components/base/CkMessageActionButton/CkMessageActionButton.vue.d.ts.map +1 -1
  52. package/dist/components/base/CkMessageActionButton/index.d.ts +1 -0
  53. package/dist/components/base/CkMessageActionButton/index.d.ts.map +1 -1
  54. package/dist/components/base/CkMessageActionButton/types.d.ts +22 -0
  55. package/dist/components/base/CkMessageActionButton/types.d.ts.map +1 -0
  56. package/dist/components/base/CkPromptActionButton/CkPromptActionButton.stories.d.ts +12 -0
  57. package/dist/components/base/CkPromptActionButton/CkPromptActionButton.stories.d.ts.map +1 -1
  58. package/dist/components/base/CkPromptActionButton/CkPromptActionButton.vue.d.ts +2 -7
  59. package/dist/components/base/CkPromptActionButton/CkPromptActionButton.vue.d.ts.map +1 -1
  60. package/dist/components/base/CkPromptActionButton/index.d.ts +1 -0
  61. package/dist/components/base/CkPromptActionButton/index.d.ts.map +1 -1
  62. package/dist/components/base/CkPromptActionButton/types.d.ts +33 -0
  63. package/dist/components/base/CkPromptActionButton/types.d.ts.map +1 -0
  64. package/dist/components/base/CkPromptInput/CkPromptInput.stories.d.ts +17 -0
  65. package/dist/components/base/CkPromptInput/CkPromptInput.stories.d.ts.map +1 -1
  66. package/dist/components/base/CkPromptInput/CkPromptInput.vue.d.ts +3 -9
  67. package/dist/components/base/CkPromptInput/CkPromptInput.vue.d.ts.map +1 -1
  68. package/dist/components/base/CkPromptInput/index.d.ts +1 -0
  69. package/dist/components/base/CkPromptInput/index.d.ts.map +1 -1
  70. package/dist/components/base/CkPromptInput/types.d.ts +39 -0
  71. package/dist/components/base/CkPromptInput/types.d.ts.map +1 -0
  72. package/dist/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.stories.d.ts +12 -0
  73. package/dist/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.stories.d.ts.map +1 -1
  74. package/dist/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.vue.d.ts +2 -4
  75. package/dist/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.vue.d.ts.map +1 -1
  76. package/dist/components/base/CkPromptInputDisclaimer/index.d.ts +1 -0
  77. package/dist/components/base/CkPromptInputDisclaimer/index.d.ts.map +1 -1
  78. package/dist/components/base/CkPromptInputDisclaimer/types.d.ts +18 -0
  79. package/dist/components/base/CkPromptInputDisclaimer/types.d.ts.map +1 -0
  80. package/dist/components/base/CkPromptStopButton/CkPromptStopButton.stories.d.ts +8 -0
  81. package/dist/components/base/CkPromptStopButton/CkPromptStopButton.stories.d.ts.map +1 -1
  82. package/dist/components/base/CkPromptStopButton/CkPromptStopButton.vue.d.ts +3 -6
  83. package/dist/components/base/CkPromptStopButton/CkPromptStopButton.vue.d.ts.map +1 -1
  84. package/dist/components/base/CkPromptStopButton/index.d.ts +1 -0
  85. package/dist/components/base/CkPromptStopButton/index.d.ts.map +1 -1
  86. package/dist/components/base/CkPromptStopButton/types.d.ts +28 -0
  87. package/dist/components/base/CkPromptStopButton/types.d.ts.map +1 -0
  88. package/dist/components/base/CkUserMessage/CkUserMessage.stories.d.ts +15 -0
  89. package/dist/components/base/CkUserMessage/CkUserMessage.stories.d.ts.map +1 -1
  90. package/dist/components/base/CkUserMessage/CkUserMessage.vue.d.ts.map +1 -1
  91. package/dist/components/base/CkUserMessage/types.d.ts +9 -2
  92. package/dist/components/base/CkUserMessage/types.d.ts.map +1 -1
  93. package/dist/components/base/icons/CkStopIcon.vue.d.ts.map +1 -1
  94. package/dist/components/base/index.d.ts +5 -1
  95. package/dist/components/base/index.d.ts.map +1 -1
  96. package/dist/components/composed/CkConversation/CkConversation.stories.d.ts +55 -0
  97. package/dist/components/composed/CkConversation/CkConversation.stories.d.ts.map +1 -1
  98. package/dist/components/composed/CkConversation/CkConversation.vue.d.ts.map +1 -1
  99. package/dist/components/composed/CkConversation/types.d.ts +25 -6
  100. package/dist/components/composed/CkConversation/types.d.ts.map +1 -1
  101. package/dist/components/composed/CkHistory/CkHistory.stories.d.ts +33 -0
  102. package/dist/components/composed/CkHistory/CkHistory.stories.d.ts.map +1 -0
  103. package/dist/components/composed/CkHistory/CkHistory.vue.d.ts +50 -0
  104. package/dist/components/composed/CkHistory/CkHistory.vue.d.ts.map +1 -0
  105. package/dist/components/composed/CkHistory/index.d.ts +3 -0
  106. package/dist/components/composed/CkHistory/index.d.ts.map +1 -0
  107. package/dist/components/composed/CkHistory/types.d.ts +71 -0
  108. package/dist/components/composed/CkHistory/types.d.ts.map +1 -0
  109. package/dist/components/composed/CkInput/CkInput.stories.d.ts +31 -1
  110. package/dist/components/composed/CkInput/CkInput.stories.d.ts.map +1 -1
  111. package/dist/components/composed/CkInput/CkInput.vue.d.ts +3 -12
  112. package/dist/components/composed/CkInput/CkInput.vue.d.ts.map +1 -1
  113. package/dist/components/composed/CkInput/index.d.ts +1 -0
  114. package/dist/components/composed/CkInput/index.d.ts.map +1 -1
  115. package/dist/components/composed/CkInput/types.d.ts +60 -0
  116. package/dist/components/composed/CkInput/types.d.ts.map +1 -0
  117. package/dist/components/composed/index.d.ts +2 -0
  118. package/dist/components/composed/index.d.ts.map +1 -1
  119. package/dist/components/index.d.ts +4 -4
  120. package/dist/components/index.d.ts.map +1 -1
  121. package/dist/components/index.js +14 -11
  122. package/dist/composables/index.d.ts +2 -0
  123. package/dist/composables/index.d.ts.map +1 -1
  124. package/dist/composables/index.js +3 -3
  125. package/dist/composables/useConversations.d.ts +72 -0
  126. package/dist/composables/useConversations.d.ts.map +1 -0
  127. package/dist/generateId-BHf0W4Rq.js +6 -0
  128. package/dist/handlers/index.js +2 -2
  129. package/dist/handlers/useChatKitLabels.d.ts +12 -0
  130. package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
  131. package/dist/handlers/useMarkdownParser.d.ts.map +1 -1
  132. package/dist/helpers/conversationTree.d.ts.map +1 -1
  133. package/dist/helpers/index.d.ts +2 -0
  134. package/dist/helpers/index.d.ts.map +1 -1
  135. package/dist/helpers/secondsToDate.d.ts +6 -0
  136. package/dist/helpers/secondsToDate.d.ts.map +1 -0
  137. package/dist/helpers/toError.d.ts +7 -0
  138. package/dist/helpers/toError.d.ts.map +1 -0
  139. package/dist/index.d.ts +6 -6
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +20 -16
  142. package/dist/services/ChatService.d.ts.map +1 -1
  143. package/dist/services/MockChatService.d.ts.map +1 -1
  144. package/dist/services/index.d.ts +1 -1
  145. package/dist/services/index.d.ts.map +1 -1
  146. package/dist/services/index.js +4 -1
  147. package/dist/services/types.d.ts +53 -0
  148. package/dist/services/types.d.ts.map +1 -1
  149. package/dist/types.d.ts +13 -0
  150. package/dist/types.d.ts.map +1 -1
  151. package/dist/{useChatKitLabels-DOiK9ds0.js → useChatKitLabels-Dvi2FmjE.js} +10 -2
  152. package/dist/useConversations-Ca242D2P.js +195 -0
  153. package/dist/{useMessageHandler-D7OdrrcB.js → useMessageHandler-uLHNac39.js} +1 -3
  154. package/package.json +4 -3
@@ -0,0 +1,72 @@
1
+ import type { ConversationSummary, HttpClient } from '../services/types';
2
+ import { type Ref } from 'vue';
3
+ export interface UseConversationsOptions {
4
+ httpClient: HttpClient;
5
+ /** REST path for the conversations resource, e.g. `/conversations`. */
6
+ path: string;
7
+ /** Default page size for `fetch` / `fetchMore`. Default: 20. */
8
+ pageSize?: number;
9
+ }
10
+ export interface CreateConversationInput {
11
+ title?: string;
12
+ /**
13
+ * Extra fields merged into the request body's `metadata` object. chat-kit
14
+ * does not bake in any default metadata; pass anything the server expects
15
+ * here (e.g. `{ application: 'tiger-chat' }`).
16
+ */
17
+ metadata?: Record<string, unknown>;
18
+ }
19
+ export interface MutationOptions {
20
+ /**
21
+ * If `true`, mutate the local list before the network call and roll back
22
+ * on failure. Default: `false`.
23
+ */
24
+ optimistic?: boolean;
25
+ }
26
+ export interface UseConversationsReturn {
27
+ /**
28
+ * Reactive list. Readonly so callers cannot mutate the array itself */
29
+ conversations: Readonly<Ref<readonly ConversationSummary[]>>;
30
+ /**
31
+ * True while any fetch or mutation is in flight. Backed by an internal
32
+ * counter, so it stays `true` for the duration of overlapping operations
33
+ * and only flips back to `false` once every in-progress request has settled.
34
+ */
35
+ isLoading: Readonly<Ref<boolean>>;
36
+ /** True when the server reported another cursor on the last page. */
37
+ hasMore: Readonly<Ref<boolean>>;
38
+ /** Last error from any operation, or `null`. Cleared on the next call. */
39
+ error: Readonly<Ref<Error | null>>;
40
+ /** Load the first page. Replaces the list and resets the cursor. */
41
+ fetch(options?: {
42
+ limit?: number;
43
+ }): Promise<void>;
44
+ /** Load the next page using the cursor stored internally. No-op if `!hasMore`. */
45
+ fetchMore(): Promise<void>;
46
+ /**
47
+ * Fetch a single conversation by id from the server. Pure fetch: the list
48
+ * is not touched (no insert, no replace). Useful for resolving a
49
+ * conversation that isn't on the first page (e.g. deep-linked URL after a
50
+ * page reload) where the caller just needs its title or metadata.
51
+ */
52
+ fetchById(id: string): Promise<ConversationSummary>;
53
+ /** Create on the server and prepend to the list. */
54
+ create(input?: CreateConversationInput, options?: MutationOptions): Promise<ConversationSummary>;
55
+ /** Rename on the server and update the list entry in place. */
56
+ rename(id: string, title: string, options?: MutationOptions): Promise<ConversationSummary>;
57
+ /** Delete on the server and remove from the list. */
58
+ remove(id: string, options?: MutationOptions): Promise<void>;
59
+ /** Local lookup. Does not fetch — only checks the in-memory list. */
60
+ getById(id: string): ConversationSummary | undefined;
61
+ }
62
+ /**
63
+ * Reactive list of past conversations backed by an OpenAI-style REST API.
64
+ *
65
+ * Owns its own pagination cursor and exposes `hasMore` / `fetchMore` so
66
+ * callers don't manage paging state themselves. The raw server response
67
+ * (nested `metadata.title`, unix-second timestamps, `has_more` / `last_id`
68
+ * envelope) is mapped to the simpler `ConversationSummary` shape inside this
69
+ * composable; consumers never see the raw response.
70
+ */
71
+ export declare function useConversations(options: UseConversationsOptions): UseConversationsReturn;
72
+ //# sourceMappingURL=useConversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversations.d.ts","sourceRoot":"","sources":["../../src/composables/useConversations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EAGX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAuC,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAcpE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,UAAU,CAAC;IACvB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC;2EACuE;IACvE,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC,CAAC;IAC7D;;;;OAIG;IACH,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAClC,qEAAqE;IACrE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAChC,0EAA0E;IAC1E,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IACnC,oEAAoE;IACpE,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,kFAAkF;IAClF,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpD,oDAAoD;IACpD,MAAM,CACJ,KAAK,CAAC,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,+DAA+D;IAC/D,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,qDAAqD;IACrD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,qEAAqE;IACrE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;CACtD;AAID;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,sBAAsB,CAgMxB"}
@@ -0,0 +1,6 @@
1
+ function generateId() {
2
+ return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : String(Date.now());
3
+ }
4
+ export {
5
+ generateId as g
6
+ };
@@ -1,5 +1,5 @@
1
- import { u } from "../useMessageHandler-D7OdrrcB.js";
2
- import { C, d, p, u as u2, a } from "../useChatKitLabels-DOiK9ds0.js";
1
+ import { u } from "../useMessageHandler-uLHNac39.js";
2
+ import { C, d, p, u as u2, a } from "../useChatKitLabels-Dvi2FmjE.js";
3
3
  export {
4
4
  C as CHAT_KIT_LABELS,
5
5
  d as defaultChatKitLabels,
@@ -23,6 +23,18 @@ export type ChatKitLabels = {
23
23
  agentLoadingAvatarAlt: string;
24
24
  /** Placeholder text for the chat input field */
25
25
  inputPlaceholder: string;
26
+ /** Accessible label / tooltip for the copy-message action button in its idle state */
27
+ copyMessageAction: string;
28
+ /** Accessible label / tooltip for the copy-message action button after a successful copy */
29
+ copyMessageActionCopied: string;
30
+ /** Fallback title used by `CkHistory` when a conversation has no `title`. */
31
+ historyItemUntitled: string;
32
+ /** Accessible name for the trailing kebab trigger on each `CkHistory` row. */
33
+ historyItemActionAriaLabel: string;
34
+ /** Label for the "Edit" action in the `CkHistory` row popover menu. */
35
+ historyItemEditAction: string;
36
+ /** Label for the "Delete" action in the `CkHistory` row popover menu. */
37
+ historyItemDeleteAction: string;
26
38
  };
27
39
  /** English defaults used when no labels are provided by the consumer. */
28
40
  export declare const defaultChatKitLabels: ChatKitLabels;
@@ -1 +1 @@
1
- {"version":3,"file":"useChatKitLabels.d.ts","sourceRoot":"","sources":["../../src/handlers/useChatKitLabels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,aAIlC,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,CAAC,CAA6B,CAAC;AAEnG,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C,yFAAyF;AACzF,KAAK,cAAc,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;AAE9F;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKjE;AAED;;;;;;GAMG;AACH,wBAAg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1 +1 @@
1
- {"version":3,"file":"useMarkdownParser.d.ts","sourceRoot":"","sources":["../../src/handlers/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
+ {"version":3,"file":"useMarkdownParser.d.ts","sourceRoot":"","sources":["../../src/handlers/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;;EA0BrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"conversationTree.d.ts","sourceRoot":"","sources":["../../src/helpers/conversationTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3E,wBAAgB,eAAe,IAAI,gBAAgB,CAElD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,EAAE,CAkCnE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAYvE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,gBAAgB,EACtB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC,GACjE,IAAI,CAON;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAsBvF;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAWvE"}
1
+ {"version":3,"file":"conversationTree.d.ts","sourceRoot":"","sources":["../../src/helpers/conversationTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3E,wBAAgB,eAAe,IAAI,gBAAgB,CAElD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,EAAE,CAkCnE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAYvE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,gBAAgB,EACtB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC,GACjE,IAAI,CAON;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAWvE"}
@@ -1,3 +1,5 @@
1
1
  export * from './conversationTree';
2
2
  export * from './generateId';
3
+ export * from './secondsToDate';
4
+ export * from './toError';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Convert a unix timestamp in seconds to a `Date`. Useful when consuming
3
+ * APIs that return `created_at` / `updated_at` as integer seconds.
4
+ */
5
+ export declare function secondsToDate(seconds: number): Date;
6
+ //# sourceMappingURL=secondsToDate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondsToDate.d.ts","sourceRoot":"","sources":["../../src/helpers/secondsToDate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEnD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Normalise an unknown thrown value into an `Error` instance.
3
+ * Wraps non-Error values (strings, plain objects, etc.) so callers can
4
+ * always rely on `.message` and a stable type.
5
+ */
6
+ export declare function toError(value: unknown): Error;
7
+ //# sourceMappingURL=toError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toError.d.ts","sourceRoot":"","sources":["../../src/helpers/toError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE7C"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { ChatService, type IChatService, type ChatConfig, type ChatMessage, type ChatResponse, type StreamEvent, } from './services';
1
+ export { ChatService, type IChatService, type ChatConfig, type ChatMessage, type ChatResponse, type ConversationSummary, type HttpClient, type RawConversation, type RawConversationList, type StreamEvent, } from './services';
2
2
  export { useMessageHandler, useMarkdownParser, provideChatKitLabels, useChatKitLabels, defaultChatKitLabels, CHAT_KIT_LABELS, } from './handlers';
3
3
  export type { ChatKitLabels } from './handlers';
4
- export { useChat } from './composables';
5
- export type { ChatActions, ChatState, UseChatReturn } from './composables';
6
- export { CkAgentMessage, CkConversation, CkConversationLayout, CkInput, CkMarkdownRenderer, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, CkMessageActionButton, CkCopyMessageActionButton, } from './components';
7
- export type { CkConversationLayoutProps, CkConversationProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkUserMessageProps, } from './components';
8
- export type { BaseMessage, ConversationTree, MessageRole, MessageStatus, TreeMessage, } from './types';
4
+ export { useChat, useConversations } from './composables';
5
+ export type { ChatActions, ChatState, CreateConversationInput, MutationOptions, UseChatReturn, UseConversationsOptions, UseConversationsReturn, } from './composables';
6
+ export { CkAgentMessage, CkConversation, CkConversationLayout, CkCopyMessageActionButton, CkHistory, CkHistoryItem, CkHistoryWrapper, CkInput, CkMarkdownRenderer, CkMessageActionButton, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './components';
7
+ export type { CkConversationLayoutProps, CkConversationProps, CkHistoryEmits, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkUserMessageProps, } from './components';
8
+ export type { BaseMessage, Conversation, ConversationTree, MessageRole, MessageStatus, TreeMessage, } 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,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,GACZ,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,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EACV,WAAW,EACX,SAAS,EACT,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,29 +1,33 @@
1
1
  import { C } from "./ChatService-LogwJNxh.js";
2
- import { u } from "./useMessageHandler-D7OdrrcB.js";
3
- import { C as C2, d, p, u as u2, a } from "./useChatKitLabels-DOiK9ds0.js";
4
- import { useChat } from "./composables/index.js";
5
- import { _, a as a2, b, C as C3, c, d as d2, e, f, g, h, i, j, k, l } from "./CkInput.vue_vue_type_script_setup_true_lang-Bpa5PJj-.js";
2
+ import { u } from "./useMessageHandler-uLHNac39.js";
3
+ import { C as C2, d, p, u as u2, a } from "./useChatKitLabels-Dvi2FmjE.js";
4
+ import { u as u3, a as a2 } from "./useConversations-Ca242D2P.js";
5
+ import { _, a as a3, b, C as C3, c, d as d2, e, f, g, h, i, j, k, l, m, n, o } from "./CkInput.vue_vue_type_script_setup_true_lang-744ZHsQU.js";
6
6
  export {
7
7
  C2 as CHAT_KIT_LABELS,
8
8
  C as ChatService,
9
9
  _ as CkAgentMessage,
10
- a2 as CkConversation,
10
+ a3 as CkConversation,
11
11
  b as CkConversationLayout,
12
12
  C3 as CkCopyMessageActionButton,
13
- c as CkInput,
14
- d2 as CkMarkdownRenderer,
15
- e as CkMessageActionButton,
16
- f as CkPromptActionButton,
17
- g as CkPromptInput,
18
- h as CkPromptInputDisclaimer,
19
- i as CkPromptStopButton,
20
- j as CkSendIcon,
21
- k as CkStopIcon,
22
- l as CkUserMessage,
13
+ c as CkHistory,
14
+ d2 as CkHistoryItem,
15
+ e as CkHistoryWrapper,
16
+ f as CkInput,
17
+ g as CkMarkdownRenderer,
18
+ h as CkMessageActionButton,
19
+ i as CkPromptActionButton,
20
+ j as CkPromptInput,
21
+ k as CkPromptInputDisclaimer,
22
+ l as CkPromptStopButton,
23
+ m as CkSendIcon,
24
+ n as CkStopIcon,
25
+ o as CkUserMessage,
23
26
  d as defaultChatKitLabels,
24
27
  p as provideChatKitLabels,
25
- useChat,
28
+ u3 as useChat,
26
29
  u2 as useChatKitLabels,
30
+ a2 as useConversations,
27
31
  a as useMarkdownParser,
28
32
  u as useMessageHandler
29
33
  };
@@ -1 +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,C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Aa,CACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC;CACjB"}
@@ -1 +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"}
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;IAYxD,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAIpC,aAAa,CACjB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,OAAO,CAAC,IAAI,CAAC;IAMhB,OAAO,CAAC,iBAAiB;CAY1B"}
@@ -1,4 +1,4 @@
1
1
  export { ChatService, type IChatService } from './ChatService';
2
2
  export { MockChatService } from './MockChatService';
3
- export type { ChatConfig, ChatMessage, ChatResponse, StreamEvent } from './types';
3
+ export type { ChatConfig, ChatMessage, ChatResponse, ConversationSummary, HttpClient, RawConversation, RawConversationList, StreamEvent, } from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,WAAW,GACZ,MAAM,SAAS,CAAC"}
@@ -6,7 +6,10 @@ class MockChatService extends ChatService {
6
6
  async sendMessage(message) {
7
7
  const replyText = `Mock reply: ${message.content}`;
8
8
  return {
9
- message: this.createBaseMessage({ role: "assistant", content: replyText }),
9
+ message: this.createBaseMessage({
10
+ role: "assistant",
11
+ content: replyText
12
+ }),
10
13
  metadata: { mock: true }
11
14
  };
12
15
  }
@@ -1,4 +1,57 @@
1
1
  import type { BaseMessage, MessageRole } from '../types';
2
+ /**
3
+ * Minimal HTTP transport contract that chat-kit composables depend on.
4
+ *
5
+ * The app injects an implementation (typically a thin wrapper around
6
+ * `fetch`, `ofetch`, or `axios`). The app owns the base URL, auth headers,
7
+ * retries, and error shape normalisation. chat-kit only calls these methods
8
+ * with the path it was given and assumes the response is JSON.
9
+ */
10
+ export interface HttpClient {
11
+ get<T>(path: string, options?: {
12
+ params?: Record<string, unknown>;
13
+ }): Promise<T>;
14
+ post<T>(path: string, body?: unknown): Promise<T>;
15
+ delete(path: string): Promise<void>;
16
+ }
17
+ /**
18
+ * One past conversation, in the shape chat-kit consumers work with.
19
+ *
20
+ * This is the shape consumers work with. The raw server response is mapped
21
+ * into this internally by `useConversations`.
22
+ */
23
+ export interface ConversationSummary {
24
+ id: string;
25
+ title: string;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ }
29
+ /**
30
+ * Raw server response for a single conversation, in the OpenAI-style API
31
+ * shape. Consumers should not need to use this directly; `useConversations`
32
+ * maps it to `ConversationSummary`.
33
+ */
34
+ export interface RawConversation {
35
+ id: string;
36
+ object?: string;
37
+ metadata?: {
38
+ title?: string;
39
+ [key: string]: unknown;
40
+ } | null;
41
+ created_at: number;
42
+ updated_at: number;
43
+ }
44
+ /**
45
+ * Raw server response for a list of conversations, in the OpenAI-style API
46
+ * shape.
47
+ */
48
+ export interface RawConversationList {
49
+ object?: string;
50
+ data: RawConversation[];
51
+ has_more: boolean;
52
+ first_id?: string | null;
53
+ last_id?: string | null;
54
+ }
2
55
  /**
3
56
  * Chat message sent to the service
4
57
  */
@@ -1 +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,M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AAC;IAChB,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;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"}
package/dist/types.d.ts CHANGED
@@ -26,4 +26,17 @@ export interface ConversationTree {
26
26
  nodes: Record<string, TreeMessage>;
27
27
  rootId: string | null;
28
28
  }
29
+ /**
30
+ * High-level conversation record consumed by `CkHistory`.
31
+ *
32
+ * `createdAt` and `updatedAt` are expected to be **Unix seconds**.
33
+ * `title` is optional; `CkHistory` falls back to a localised "Untitled"
34
+ * label when it is missing or blank.
35
+ */
36
+ export interface Conversation {
37
+ id: string;
38
+ title?: string;
39
+ createdAt: number;
40
+ updatedAt: number;
41
+ }
29
42
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE1E,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;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE1E,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;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -13766,7 +13766,9 @@ function useMarkdownParser(source, plugins) {
13766
13766
  const markdown = toValue(source);
13767
13767
  if (!markdown) return "";
13768
13768
  try {
13769
- const raw2 = String(getProcessor(toValue(plugins) ?? []).processSync(markdown));
13769
+ const raw2 = String(
13770
+ getProcessor(toValue(plugins) ?? []).processSync(markdown)
13771
+ );
13770
13772
  return purify.sanitize(raw2);
13771
13773
  } catch {
13772
13774
  return purify.sanitize(markdown);
@@ -13777,7 +13779,13 @@ function useMarkdownParser(source, plugins) {
13777
13779
  const defaultChatKitLabels = {
13778
13780
  agentAvatarAlt: "Agent avatar",
13779
13781
  agentLoadingAvatarAlt: "Agent loading",
13780
- inputPlaceholder: "Type a message..."
13782
+ inputPlaceholder: "Type a message...",
13783
+ copyMessageAction: "Copy response",
13784
+ copyMessageActionCopied: "Copied!",
13785
+ historyItemUntitled: "Untitled conversation",
13786
+ historyItemActionAriaLabel: "Conversation options",
13787
+ historyItemEditAction: "Edit",
13788
+ historyItemDeleteAction: "Delete"
13781
13789
  };
13782
13790
  const CHAT_KIT_LABELS = /* @__PURE__ */ Symbol("chat-kit-labels");
13783
13791
  function provideChatKitLabels(labels) {
@@ -0,0 +1,195 @@
1
+ import { g as generateId } from "./generateId-BHf0W4Rq.js";
2
+ import { ref, shallowRef, computed, readonly } from "vue";
3
+ function secondsToDate(seconds) {
4
+ return new Date(seconds * 1e3);
5
+ }
6
+ function toError(value) {
7
+ return value instanceof Error ? value : new Error(String(value));
8
+ }
9
+ function useChat() {
10
+ }
11
+ const DEFAULT_PAGE_SIZE = 20;
12
+ function useConversations(options) {
13
+ const http = options.httpClient;
14
+ const path = options.path;
15
+ const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE;
16
+ const conversations = ref([]);
17
+ const inflightCount = shallowRef(0);
18
+ const isLoading = computed(() => inflightCount.value > 0);
19
+ const hasMore = shallowRef(false);
20
+ const error = shallowRef(null);
21
+ let nextCursor = null;
22
+ function beginRequest() {
23
+ inflightCount.value++;
24
+ error.value = null;
25
+ }
26
+ function endRequest() {
27
+ inflightCount.value--;
28
+ }
29
+ async function fetchPage(params) {
30
+ const query = {
31
+ limit: params.limit,
32
+ order: "desc"
33
+ };
34
+ if (params.cursor) query.after = params.cursor;
35
+ const raw = await http.get(path, { params: query });
36
+ return mapConversationList(raw);
37
+ }
38
+ async function fetch(opts) {
39
+ beginRequest();
40
+ try {
41
+ const page = await fetchPage({
42
+ limit: opts?.limit ?? pageSize,
43
+ cursor: null
44
+ });
45
+ conversations.value = page.items;
46
+ nextCursor = page.nextCursor;
47
+ hasMore.value = page.nextCursor !== null;
48
+ } catch (e) {
49
+ error.value = toError(e);
50
+ throw error.value;
51
+ } finally {
52
+ endRequest();
53
+ }
54
+ }
55
+ async function fetchMore() {
56
+ if (!hasMore.value || nextCursor === null) return;
57
+ beginRequest();
58
+ try {
59
+ const page = await fetchPage({ limit: pageSize, cursor: nextCursor });
60
+ conversations.value = [...conversations.value, ...page.items];
61
+ nextCursor = page.nextCursor;
62
+ hasMore.value = page.nextCursor !== null;
63
+ } catch (e) {
64
+ error.value = toError(e);
65
+ throw error.value;
66
+ } finally {
67
+ endRequest();
68
+ }
69
+ }
70
+ async function fetchById(id) {
71
+ beginRequest();
72
+ try {
73
+ const raw = await http.get(`${path}/${id}`);
74
+ return mapConversation(raw);
75
+ } catch (e) {
76
+ error.value = toError(e);
77
+ throw error.value;
78
+ } finally {
79
+ endRequest();
80
+ }
81
+ }
82
+ async function create(input, opts) {
83
+ const metadata = { ...input?.metadata ?? {} };
84
+ if (input?.title !== void 0) metadata.title = input.title;
85
+ const body = { metadata };
86
+ const previous = conversations.value;
87
+ let placeholder = null;
88
+ if (opts?.optimistic) {
89
+ placeholder = makePlaceholder(input?.title);
90
+ conversations.value = [placeholder, ...previous];
91
+ }
92
+ beginRequest();
93
+ try {
94
+ const raw = await http.post(path, body);
95
+ const created = mapConversation(raw);
96
+ conversations.value = placeholder ? conversations.value.map(
97
+ (c) => c.id === placeholder.id ? created : c
98
+ ) : [created, ...conversations.value];
99
+ return created;
100
+ } catch (e) {
101
+ if (placeholder) conversations.value = previous;
102
+ error.value = toError(e);
103
+ throw error.value;
104
+ } finally {
105
+ endRequest();
106
+ }
107
+ }
108
+ async function rename(id, title, opts) {
109
+ const previous = conversations.value;
110
+ if (opts?.optimistic) {
111
+ conversations.value = previous.map(
112
+ (c) => c.id === id ? { ...c, title, updatedAt: /* @__PURE__ */ new Date() } : c
113
+ );
114
+ }
115
+ beginRequest();
116
+ try {
117
+ const raw = await http.post(`${path}/${id}`, {
118
+ metadata: { title }
119
+ });
120
+ const updated = mapConversation(raw);
121
+ conversations.value = conversations.value.map(
122
+ (c) => c.id === id ? updated : c
123
+ );
124
+ return updated;
125
+ } catch (e) {
126
+ if (opts?.optimistic) conversations.value = previous;
127
+ error.value = toError(e);
128
+ throw error.value;
129
+ } finally {
130
+ endRequest();
131
+ }
132
+ }
133
+ async function remove(id, opts) {
134
+ const previous = conversations.value;
135
+ if (opts?.optimistic) {
136
+ conversations.value = previous.filter((c) => c.id !== id);
137
+ }
138
+ beginRequest();
139
+ try {
140
+ await http.delete(`${path}/${id}`);
141
+ if (!opts?.optimistic) {
142
+ conversations.value = previous.filter((c) => c.id !== id);
143
+ }
144
+ } catch (e) {
145
+ if (opts?.optimistic) conversations.value = previous;
146
+ error.value = toError(e);
147
+ throw error.value;
148
+ } finally {
149
+ endRequest();
150
+ }
151
+ }
152
+ function getById(id) {
153
+ return conversations.value.find((c) => c.id === id);
154
+ }
155
+ return {
156
+ conversations: readonly(conversations),
157
+ isLoading,
158
+ hasMore: readonly(hasMore),
159
+ error: readonly(error),
160
+ fetch,
161
+ fetchMore,
162
+ fetchById,
163
+ create,
164
+ rename,
165
+ remove,
166
+ getById
167
+ };
168
+ }
169
+ function mapConversation(raw) {
170
+ return {
171
+ id: raw.id,
172
+ title: raw.metadata?.title ?? "",
173
+ createdAt: secondsToDate(raw.created_at),
174
+ updatedAt: secondsToDate(raw.updated_at)
175
+ };
176
+ }
177
+ function mapConversationList(raw) {
178
+ return {
179
+ items: raw.data.map(mapConversation),
180
+ nextCursor: raw.has_more ? raw.last_id ?? null : null
181
+ };
182
+ }
183
+ function makePlaceholder(title) {
184
+ const now = /* @__PURE__ */ new Date();
185
+ return {
186
+ id: `pending-${generateId()}`,
187
+ title: title ?? "",
188
+ createdAt: now,
189
+ updatedAt: now
190
+ };
191
+ }
192
+ export {
193
+ useConversations as a,
194
+ useChat as u
195
+ };
@@ -1,3 +1,4 @@
1
+ import { g as generateId } from "./generateId-BHf0W4Rq.js";
1
2
  import { reactive, ref, computed, readonly } from "vue";
2
3
  function createEmptyTree() {
3
4
  return { nodes: {}, rootId: null };
@@ -77,9 +78,6 @@ function navigate(tree, targetId) {
77
78
  if (idx === -1) return;
78
79
  parent.activeChildIndex = idx;
79
80
  }
80
- function generateId() {
81
- return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : String(Date.now());
82
- }
83
81
  const useMessageHandler = () => {
84
82
  const tree = reactive(createEmptyTree());
85
83
  const currentUserMessage = ref("");