@inkeep/agents-ui 0.0.0-dev-20260313222128

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 (557) hide show
  1. package/LICENSE +64 -0
  2. package/README.md +1 -0
  3. package/dist/_virtual/index.cjs +1 -0
  4. package/dist/_virtual/index.js +4 -0
  5. package/dist/_virtual/use-sync-external-store-shim.development.cjs +1 -0
  6. package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
  7. package/dist/_virtual/use-sync-external-store-shim.production.cjs +1 -0
  8. package/dist/_virtual/use-sync-external-store-shim.production.js +5 -0
  9. package/dist/color-mode/index.cjs +1 -0
  10. package/dist/color-mode/index.d.ts +20 -0
  11. package/dist/color-mode/index.js +170 -0
  12. package/dist/index.cjs +1 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +238 -0
  15. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +9 -0
  16. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +68 -0
  17. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.cjs +9 -0
  18. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +56 -0
  19. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.cjs +1 -0
  20. package/dist/node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.js +8 -0
  21. package/dist/primitives/atoms/avatars/ai.cjs +1 -0
  22. package/dist/primitives/atoms/avatars/ai.d.ts +3 -0
  23. package/dist/primitives/atoms/avatars/ai.js +99 -0
  24. package/dist/primitives/atoms/avatars/user.cjs +1 -0
  25. package/dist/primitives/atoms/avatars/user.d.ts +3 -0
  26. package/dist/primitives/atoms/avatars/user.js +27 -0
  27. package/dist/primitives/atoms/cmdk/command-score.cjs +1 -0
  28. package/dist/primitives/atoms/cmdk/command-score.d.ts +1 -0
  29. package/dist/primitives/atoms/cmdk/command-score.js +46 -0
  30. package/dist/primitives/atoms/cmdk/index.cjs +1 -0
  31. package/dist/primitives/atoms/cmdk/index.d.ts +460 -0
  32. package/dist/primitives/atoms/cmdk/index.js +521 -0
  33. package/dist/primitives/atoms/codeblock/index.cjs +1 -0
  34. package/dist/primitives/atoms/codeblock/index.d.ts +10 -0
  35. package/dist/primitives/atoms/codeblock/index.js +40 -0
  36. package/dist/primitives/atoms/combobox.cjs +1 -0
  37. package/dist/primitives/atoms/combobox.js +275 -0
  38. package/dist/primitives/atoms/custom-styles.cjs +1 -0
  39. package/dist/primitives/atoms/custom-styles.d.ts +5 -0
  40. package/dist/primitives/atoms/custom-styles.js +57 -0
  41. package/dist/primitives/atoms/dialog.cjs +1 -0
  42. package/dist/primitives/atoms/dialog.d.ts +94 -0
  43. package/dist/primitives/atoms/dialog.js +227 -0
  44. package/dist/primitives/atoms/error-boundary.cjs +1 -0
  45. package/dist/primitives/atoms/error-boundary.d.ts +6 -0
  46. package/dist/primitives/atoms/error-boundary.js +9 -0
  47. package/dist/primitives/atoms/icons/built-in-icon-renderer.cjs +1 -0
  48. package/dist/primitives/atoms/icons/built-in-icon-renderer.d.ts +6 -0
  49. package/dist/primitives/atoms/icons/built-in-icon-renderer.js +51 -0
  50. package/dist/primitives/atoms/icons/built-in-icons.cjs +1 -0
  51. package/dist/primitives/atoms/icons/built-in-icons.d.ts +86 -0
  52. package/dist/primitives/atoms/icons/built-in-icons.js +89 -0
  53. package/dist/primitives/atoms/icons/checkbox-icon.cjs +1 -0
  54. package/dist/primitives/atoms/icons/checkbox-icon.d.ts +1 -0
  55. package/dist/primitives/atoms/icons/checkbox-icon.js +24 -0
  56. package/dist/primitives/atoms/icons/collections/bi.cjs +1 -0
  57. package/dist/primitives/atoms/icons/collections/bi.d.ts +4 -0
  58. package/dist/primitives/atoms/icons/collections/bi.js +49 -0
  59. package/dist/primitives/atoms/icons/collections/fi.cjs +1 -0
  60. package/dist/primitives/atoms/icons/collections/fi.d.ts +2 -0
  61. package/dist/primitives/atoms/icons/collections/fi.js +29 -0
  62. package/dist/primitives/atoms/icons/collections/gr.cjs +1 -0
  63. package/dist/primitives/atoms/icons/collections/gr.d.ts +2 -0
  64. package/dist/primitives/atoms/icons/collections/gr.js +21 -0
  65. package/dist/primitives/atoms/icons/collections/io5.cjs +1 -0
  66. package/dist/primitives/atoms/icons/collections/io5.d.ts +34 -0
  67. package/dist/primitives/atoms/icons/collections/io5.js +806 -0
  68. package/dist/primitives/atoms/icons/collections/pi.cjs +1 -0
  69. package/dist/primitives/atoms/icons/collections/pi.d.ts +4 -0
  70. package/dist/primitives/atoms/icons/collections/pi.js +49 -0
  71. package/dist/primitives/atoms/icons/custom-icon.cjs +1 -0
  72. package/dist/primitives/atoms/icons/custom-icon.d.ts +6 -0
  73. package/dist/primitives/atoms/icons/custom-icon.js +19 -0
  74. package/dist/primitives/atoms/icons/generate-icon.cjs +1 -0
  75. package/dist/primitives/atoms/icons/generate-icon.d.ts +28 -0
  76. package/dist/primitives/atoms/icons/generate-icon.js +56 -0
  77. package/dist/primitives/atoms/icons/index.cjs +1 -0
  78. package/dist/primitives/atoms/icons/index.d.ts +2 -0
  79. package/dist/primitives/atoms/icons/index.js +6 -0
  80. package/dist/primitives/atoms/icons/inkeep-default-icons.cjs +1 -0
  81. package/dist/primitives/atoms/icons/inkeep-default-icons.d.ts +2 -0
  82. package/dist/primitives/atoms/icons/inkeep-default-icons.js +28 -0
  83. package/dist/primitives/atoms/link.cjs +1 -0
  84. package/dist/primitives/atoms/link.d.ts +14 -0
  85. package/dist/primitives/atoms/link.js +35 -0
  86. package/dist/primitives/atoms/markdown/components.cjs +1 -0
  87. package/dist/primitives/atoms/markdown/components.d.ts +31 -0
  88. package/dist/primitives/atoms/markdown/components.js +76 -0
  89. package/dist/primitives/atoms/markdown/index.cjs +1 -0
  90. package/dist/primitives/atoms/markdown/index.d.ts +17 -0
  91. package/dist/primitives/atoms/markdown/index.js +121 -0
  92. package/dist/primitives/atoms/markdown/rehype-inline-code-property.cjs +1 -0
  93. package/dist/primitives/atoms/markdown/rehype-inline-code-property.d.ts +1 -0
  94. package/dist/primitives/atoms/markdown/rehype-inline-code-property.js +12 -0
  95. package/dist/primitives/atoms/portal-with-theme.cjs +1 -0
  96. package/dist/primitives/atoms/portal-with-theme.d.ts +2 -0
  97. package/dist/primitives/atoms/portal-with-theme.js +12 -0
  98. package/dist/primitives/atoms/portal.cjs +1 -0
  99. package/dist/primitives/atoms/portal.d.ts +8 -0
  100. package/dist/primitives/atoms/portal.js +19 -0
  101. package/dist/primitives/atoms/select.cjs +1 -0
  102. package/dist/primitives/atoms/select.d.ts +136 -0
  103. package/dist/primitives/atoms/select.js +785 -0
  104. package/dist/primitives/atoms/shadow/context.cjs +1 -0
  105. package/dist/primitives/atoms/shadow/context.d.ts +14 -0
  106. package/dist/primitives/atoms/shadow/context.js +54 -0
  107. package/dist/primitives/atoms/shadow/create.cjs +1 -0
  108. package/dist/primitives/atoms/shadow/create.d.ts +8 -0
  109. package/dist/primitives/atoms/shadow/create.js +56 -0
  110. package/dist/primitives/atoms/shadow/index.d.ts +1 -0
  111. package/dist/primitives/atoms/shadow/root.cjs +1 -0
  112. package/dist/primitives/atoms/shadow/root.d.ts +5 -0
  113. package/dist/primitives/atoms/shadow/root.js +22 -0
  114. package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.cjs +1 -0
  115. package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.d.ts +2 -0
  116. package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.js +11 -0
  117. package/dist/primitives/atoms/shadow/utils.cjs +1 -0
  118. package/dist/primitives/atoms/shadow/utils.d.ts +9 -0
  119. package/dist/primitives/atoms/shadow/utils.js +16 -0
  120. package/dist/primitives/components/chat-bubble/index.cjs +1 -0
  121. package/dist/primitives/components/chat-bubble/index.d.ts +10 -0
  122. package/dist/primitives/components/chat-bubble/index.js +38 -0
  123. package/dist/primitives/components/chat-button.cjs +1 -0
  124. package/dist/primitives/components/chat-button.d.ts +20 -0
  125. package/dist/primitives/components/chat-button.js +51 -0
  126. package/dist/primitives/components/chat-history/index.cjs +1 -0
  127. package/dist/primitives/components/chat-history/index.d.ts +27 -0
  128. package/dist/primitives/components/chat-history/index.js +105 -0
  129. package/dist/primitives/components/data-summaries.cjs +1 -0
  130. package/dist/primitives/components/data-summaries.d.ts +14 -0
  131. package/dist/primitives/components/data-summaries.js +38 -0
  132. package/dist/primitives/components/embedded-chat/chat-provider.cjs +1 -0
  133. package/dist/primitives/components/embedded-chat/chat-provider.d.ts +19 -0
  134. package/dist/primitives/components/embedded-chat/chat-provider.js +20 -0
  135. package/dist/primitives/components/embedded-chat/use-captcha.cjs +1 -0
  136. package/dist/primitives/components/embedded-chat/use-captcha.d.ts +30 -0
  137. package/dist/primitives/components/embedded-chat/use-captcha.js +67 -0
  138. package/dist/primitives/components/embedded-chat/use-chat-action.cjs +1 -0
  139. package/dist/primitives/components/embedded-chat/use-chat-action.d.ts +9 -0
  140. package/dist/primitives/components/embedded-chat/use-chat-action.js +41 -0
  141. package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +3 -0
  142. package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +57 -0
  143. package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +312 -0
  144. package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -0
  145. package/dist/primitives/components/embedded-chat/use-stream-processor.d.ts +30 -0
  146. package/dist/primitives/components/embedded-chat/use-stream-processor.js +159 -0
  147. package/dist/primitives/components/embedded-chat.cjs +11 -0
  148. package/dist/primitives/components/embedded-chat.d.ts +461 -0
  149. package/dist/primitives/components/embedded-chat.js +2051 -0
  150. package/dist/primitives/components/embedded-search/search-provider.cjs +1 -0
  151. package/dist/primitives/components/embedded-search/search-provider.d.ts +21 -0
  152. package/dist/primitives/components/embedded-search/search-provider.js +26 -0
  153. package/dist/primitives/components/embedded-search/transform-results.cjs +1 -0
  154. package/dist/primitives/components/embedded-search/transform-results.d.ts +3 -0
  155. package/dist/primitives/components/embedded-search/transform-results.js +47 -0
  156. package/dist/primitives/components/embedded-search/url-query.cjs +1 -0
  157. package/dist/primitives/components/embedded-search/url-query.d.ts +4 -0
  158. package/dist/primitives/components/embedded-search/url-query.js +12 -0
  159. package/dist/primitives/components/embedded-search/use-inkeep-search.cjs +1 -0
  160. package/dist/primitives/components/embedded-search/use-inkeep-search.d.ts +19 -0
  161. package/dist/primitives/components/embedded-search/use-inkeep-search.js +35 -0
  162. package/dist/primitives/components/embedded-search/use-search-filter.cjs +1 -0
  163. package/dist/primitives/components/embedded-search/use-search-filter.d.ts +1 -0
  164. package/dist/primitives/components/embedded-search/use-search-filter.js +77 -0
  165. package/dist/primitives/components/embedded-search.cjs +1 -0
  166. package/dist/primitives/components/embedded-search.d.ts +249 -0
  167. package/dist/primitives/components/embedded-search.js +628 -0
  168. package/dist/primitives/components/factory.cjs +1 -0
  169. package/dist/primitives/components/factory.d.ts +19 -0
  170. package/dist/primitives/components/factory.js +39 -0
  171. package/dist/primitives/components/index.cjs +1 -0
  172. package/dist/primitives/components/index.d.ts +13 -0
  173. package/dist/primitives/components/index.js +33 -0
  174. package/dist/primitives/components/modal/modal-provider.cjs +1 -0
  175. package/dist/primitives/components/modal/modal-provider.d.ts +12 -0
  176. package/dist/primitives/components/modal/modal-provider.js +8 -0
  177. package/dist/primitives/components/modal/use-inkeep-modal.cjs +1 -0
  178. package/dist/primitives/components/modal/use-inkeep-modal.d.ts +7 -0
  179. package/dist/primitives/components/modal/use-inkeep-modal.js +9 -0
  180. package/dist/primitives/components/modal/widget-auto-focus.cjs +1 -0
  181. package/dist/primitives/components/modal/widget-auto-focus.d.ts +2 -0
  182. package/dist/primitives/components/modal/widget-auto-focus.js +25 -0
  183. package/dist/primitives/components/modal.cjs +1 -0
  184. package/dist/primitives/components/modal.d.ts +18 -0
  185. package/dist/primitives/components/modal.js +40 -0
  186. package/dist/primitives/components/presence.cjs +1 -0
  187. package/dist/primitives/components/presence.d.ts +8 -0
  188. package/dist/primitives/components/presence.js +26 -0
  189. package/dist/primitives/components/searchbar.cjs +1 -0
  190. package/dist/primitives/components/searchbar.d.ts +23 -0
  191. package/dist/primitives/components/searchbar.js +54 -0
  192. package/dist/primitives/components/sidebar-chat/index.cjs +1 -0
  193. package/dist/primitives/components/sidebar-chat/index.d.ts +9 -0
  194. package/dist/primitives/components/sidebar-chat/index.js +67 -0
  195. package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.cjs +1 -0
  196. package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.d.ts +5 -0
  197. package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.js +34 -0
  198. package/dist/primitives/components/tagline-logo-icon.cjs +1 -0
  199. package/dist/primitives/components/tagline-logo-icon.d.ts +1 -0
  200. package/dist/primitives/components/tagline-logo-icon.js +26 -0
  201. package/dist/primitives/components/use-component-trigger.cjs +1 -0
  202. package/dist/primitives/components/use-component-trigger.d.ts +5 -0
  203. package/dist/primitives/components/use-component-trigger.js +17 -0
  204. package/dist/primitives/constants/search.cjs +1 -0
  205. package/dist/primitives/constants/search.d.ts +1 -0
  206. package/dist/primitives/constants/search.js +5 -0
  207. package/dist/primitives/hooks/index.cjs +1 -0
  208. package/dist/primitives/hooks/index.d.ts +12 -0
  209. package/dist/primitives/hooks/index.js +26 -0
  210. package/dist/primitives/hooks/use-anonymous-session.cjs +1 -0
  211. package/dist/primitives/hooks/use-anonymous-session.d.ts +12 -0
  212. package/dist/primitives/hooks/use-anonymous-session.js +82 -0
  213. package/dist/primitives/hooks/use-boolean.cjs +1 -0
  214. package/dist/primitives/hooks/use-boolean.d.ts +10 -0
  215. package/dist/primitives/hooks/use-boolean.js +17 -0
  216. package/dist/primitives/hooks/use-component-classnames.cjs +1 -0
  217. package/dist/primitives/hooks/use-component-classnames.d.ts +6 -0
  218. package/dist/primitives/hooks/use-component-classnames.js +14 -0
  219. package/dist/primitives/hooks/use-container-size.cjs +1 -0
  220. package/dist/primitives/hooks/use-container-size.d.ts +5 -0
  221. package/dist/primitives/hooks/use-container-size.js +18 -0
  222. package/dist/primitives/hooks/use-conversation-loader.cjs +1 -0
  223. package/dist/primitives/hooks/use-conversation-loader.d.ts +13 -0
  224. package/dist/primitives/hooks/use-conversation-loader.js +36 -0
  225. package/dist/primitives/hooks/use-copy-to-clipboard.cjs +1 -0
  226. package/dist/primitives/hooks/use-copy-to-clipboard.d.ts +3 -0
  227. package/dist/primitives/hooks/use-copy-to-clipboard.js +24 -0
  228. package/dist/primitives/hooks/use-debounce.cjs +1 -0
  229. package/dist/primitives/hooks/use-debounce.d.ts +1 -0
  230. package/dist/primitives/hooks/use-debounce.js +16 -0
  231. package/dist/primitives/hooks/use-inkeep-api-client.cjs +1 -0
  232. package/dist/primitives/hooks/use-inkeep-api-client.d.ts +33 -0
  233. package/dist/primitives/hooks/use-inkeep-api-client.js +87 -0
  234. package/dist/primitives/hooks/use-inkeep-open-state.cjs +1 -0
  235. package/dist/primitives/hooks/use-inkeep-open-state.d.ts +18 -0
  236. package/dist/primitives/hooks/use-inkeep-open-state.js +47 -0
  237. package/dist/primitives/hooks/use-instant-update.cjs +1 -0
  238. package/dist/primitives/hooks/use-instant-update.d.ts +16 -0
  239. package/dist/primitives/hooks/use-instant-update.js +16 -0
  240. package/dist/primitives/hooks/use-is-mounted.cjs +1 -0
  241. package/dist/primitives/hooks/use-is-mounted.d.ts +1 -0
  242. package/dist/primitives/hooks/use-is-mounted.js +11 -0
  243. package/dist/primitives/hooks/use-local-storage.cjs +1 -0
  244. package/dist/primitives/hooks/use-local-storage.d.ts +8 -0
  245. package/dist/primitives/hooks/use-local-storage.js +26 -0
  246. package/dist/primitives/hooks/use-media-query.cjs +1 -0
  247. package/dist/primitives/hooks/use-media-query.d.ts +1 -0
  248. package/dist/primitives/hooks/use-media-query.js +14 -0
  249. package/dist/primitives/hooks/use-resize-observer.cjs +1 -0
  250. package/dist/primitives/hooks/use-resize-observer.d.ts +12 -0
  251. package/dist/primitives/hooks/use-resize-observer.js +32 -0
  252. package/dist/primitives/hooks/use-scrolling-fades.cjs +1 -0
  253. package/dist/primitives/hooks/use-scrolling-fades.d.ts +2 -0
  254. package/dist/primitives/hooks/use-scrolling-fades.js +18 -0
  255. package/dist/primitives/hooks/use-settle-action.cjs +1 -0
  256. package/dist/primitives/hooks/use-settle-action.d.ts +3 -0
  257. package/dist/primitives/hooks/use-settle-action.js +11 -0
  258. package/dist/primitives/hooks/use-simple-scroll.cjs +1 -0
  259. package/dist/primitives/hooks/use-simple-scroll.d.ts +16 -0
  260. package/dist/primitives/hooks/use-simple-scroll.js +51 -0
  261. package/dist/primitives/hooks/use-streaming-events.cjs +1 -0
  262. package/dist/primitives/hooks/use-streaming-events.d.ts +8 -0
  263. package/dist/primitives/hooks/use-streaming-events.js +33 -0
  264. package/dist/primitives/index.cjs +1 -0
  265. package/dist/primitives/index.d.ts +13 -0
  266. package/dist/primitives/index.js +174 -0
  267. package/dist/primitives/providers/attachment-item-provider.cjs +1 -0
  268. package/dist/primitives/providers/attachment-item-provider.d.ts +9 -0
  269. package/dist/primitives/providers/attachment-item-provider.js +13 -0
  270. package/dist/primitives/providers/attachments-bar-provider.cjs +1 -0
  271. package/dist/primitives/providers/attachments-bar-provider.d.ts +30 -0
  272. package/dist/primitives/providers/attachments-bar-provider.js +57 -0
  273. package/dist/primitives/providers/base-events-provider.cjs +1 -0
  274. package/dist/primitives/providers/base-events-provider.d.ts +8 -0
  275. package/dist/primitives/providers/base-events-provider.js +37 -0
  276. package/dist/primitives/providers/chat-bubble-provider.cjs +1 -0
  277. package/dist/primitives/providers/chat-bubble-provider.d.ts +22 -0
  278. package/dist/primitives/providers/chat-bubble-provider.js +19 -0
  279. package/dist/primitives/providers/chat-form-provider.cjs +1 -0
  280. package/dist/primitives/providers/chat-form-provider.d.ts +26 -0
  281. package/dist/primitives/providers/chat-form-provider.js +109 -0
  282. package/dist/primitives/providers/chat-history-provider.cjs +1 -0
  283. package/dist/primitives/providers/chat-history-provider.d.ts +32 -0
  284. package/dist/primitives/providers/chat-history-provider.js +105 -0
  285. package/dist/primitives/providers/config-provider.cjs +1 -0
  286. package/dist/primitives/providers/config-provider.d.ts +24 -0
  287. package/dist/primitives/providers/config-provider.js +40 -0
  288. package/dist/primitives/providers/feedback-item-provider.cjs +1 -0
  289. package/dist/primitives/providers/feedback-item-provider.d.ts +10 -0
  290. package/dist/primitives/providers/feedback-item-provider.js +16 -0
  291. package/dist/primitives/providers/feedback-provider.cjs +1 -0
  292. package/dist/primitives/providers/feedback-provider.d.ts +16 -0
  293. package/dist/primitives/providers/feedback-provider.js +83 -0
  294. package/dist/primitives/providers/form-field-provider.cjs +1 -0
  295. package/dist/primitives/providers/form-field-provider.d.ts +15 -0
  296. package/dist/primitives/providers/form-field-provider.js +17 -0
  297. package/dist/primitives/providers/help-menu-provider.cjs +1 -0
  298. package/dist/primitives/providers/help-menu-provider.d.ts +11 -0
  299. package/dist/primitives/providers/help-menu-provider.js +19 -0
  300. package/dist/primitives/providers/hover-popover-provider.cjs +1 -0
  301. package/dist/primitives/providers/hover-popover-provider.d.ts +10 -0
  302. package/dist/primitives/providers/hover-popover-provider.js +13 -0
  303. package/dist/primitives/providers/index.cjs +1 -0
  304. package/dist/primitives/providers/index.d.ts +19 -0
  305. package/dist/primitives/providers/index.js +65 -0
  306. package/dist/primitives/providers/markdown-provider.cjs +1 -0
  307. package/dist/primitives/providers/markdown-provider.d.ts +9 -0
  308. package/dist/primitives/providers/markdown-provider.js +8 -0
  309. package/dist/primitives/providers/message-attachments-provider.cjs +1 -0
  310. package/dist/primitives/providers/message-attachments-provider.d.ts +13 -0
  311. package/dist/primitives/providers/message-attachments-provider.js +27 -0
  312. package/dist/primitives/providers/message-provider.cjs +1 -0
  313. package/dist/primitives/providers/message-provider.d.ts +10 -0
  314. package/dist/primitives/providers/message-provider.js +14 -0
  315. package/dist/primitives/providers/root-provider.cjs +1 -0
  316. package/dist/primitives/providers/root-provider.d.ts +8 -0
  317. package/dist/primitives/providers/root-provider.js +21 -0
  318. package/dist/primitives/providers/search-events-provider.cjs +1 -0
  319. package/dist/primitives/providers/search-events-provider.d.ts +8 -0
  320. package/dist/primitives/providers/search-events-provider.js +17 -0
  321. package/dist/primitives/providers/sidebar-chat-provider.cjs +1 -0
  322. package/dist/primitives/providers/sidebar-chat-provider.d.ts +61 -0
  323. package/dist/primitives/providers/sidebar-chat-provider.js +37 -0
  324. package/dist/primitives/providers/source-item-provider.cjs +1 -0
  325. package/dist/primitives/providers/source-item-provider.d.ts +12 -0
  326. package/dist/primitives/providers/source-item-provider.js +13 -0
  327. package/dist/primitives/providers/theme-provider.cjs +3 -0
  328. package/dist/primitives/providers/theme-provider.d.ts +3 -0
  329. package/dist/primitives/providers/theme-provider.js +79 -0
  330. package/dist/primitives/providers/widget-provider.cjs +1 -0
  331. package/dist/primitives/providers/widget-provider.d.ts +10 -0
  332. package/dist/primitives/providers/widget-provider.js +8 -0
  333. package/dist/primitives/utils/component-ids.cjs +1 -0
  334. package/dist/primitives/utils/component-ids.d.ts +662 -0
  335. package/dist/primitives/utils/component-ids.js +361 -0
  336. package/dist/primitives/utils/compose-event-handlers.cjs +1 -0
  337. package/dist/primitives/utils/compose-event-handlers.d.ts +3 -0
  338. package/dist/primitives/utils/compose-event-handlers.js +10 -0
  339. package/dist/primitives/utils/compose-refs.cjs +1 -0
  340. package/dist/primitives/utils/compose-refs.d.ts +5 -0
  341. package/dist/primitives/utils/compose-refs.js +30 -0
  342. package/dist/primitives/utils/default-settings.cjs +1 -0
  343. package/dist/primitives/utils/default-settings.d.ts +169 -0
  344. package/dist/primitives/utils/default-settings.js +52 -0
  345. package/dist/primitives/utils/form.cjs +1 -0
  346. package/dist/primitives/utils/form.d.ts +3 -0
  347. package/dist/primitives/utils/form.js +19 -0
  348. package/dist/primitives/utils/generate-uid.cjs +1 -0
  349. package/dist/primitives/utils/generate-uid.d.ts +2 -0
  350. package/dist/primitives/utils/generate-uid.js +14 -0
  351. package/dist/primitives/utils/get-message-metadata.d.ts +8 -0
  352. package/dist/primitives/utils/get-source-icon.cjs +1 -0
  353. package/dist/primitives/utils/get-source-icon.d.ts +2 -0
  354. package/dist/primitives/utils/get-source-icon.js +11 -0
  355. package/dist/primitives/utils/highlight-emphasis.cjs +1 -0
  356. package/dist/primitives/utils/highlight-emphasis.d.ts +4 -0
  357. package/dist/primitives/utils/highlight-emphasis.js +15 -0
  358. package/dist/primitives/utils/merge-props.cjs +1 -0
  359. package/dist/primitives/utils/merge-props.d.ts +7 -0
  360. package/dist/primitives/utils/merge-props.js +41 -0
  361. package/dist/primitives/utils/misc.cjs +1 -0
  362. package/dist/primitives/utils/misc.d.ts +12 -0
  363. package/dist/primitives/utils/misc.js +31 -0
  364. package/dist/primitives/utils/split-props.cjs +1 -0
  365. package/dist/primitives/utils/split-props.d.ts +14 -0
  366. package/dist/primitives/utils/split-props.js +10 -0
  367. package/dist/react/chat-button-modal.cjs +1 -0
  368. package/dist/react/chat-button-modal.d.ts +22 -0
  369. package/dist/react/chat-button-modal.js +41 -0
  370. package/dist/react/chat-button.cjs +1 -0
  371. package/dist/react/chat-button.d.ts +28 -0
  372. package/dist/react/chat-button.js +73 -0
  373. package/dist/react/embedded-chat.cjs +1 -0
  374. package/dist/react/embedded-chat.d.ts +15 -0
  375. package/dist/react/embedded-chat.js +431 -0
  376. package/dist/react/embedded-search-and-chat.cjs +1 -0
  377. package/dist/react/embedded-search-and-chat.d.ts +40 -0
  378. package/dist/react/embedded-search-and-chat.impl.cjs +1 -0
  379. package/dist/react/embedded-search-and-chat.impl.d.ts +9 -0
  380. package/dist/react/embedded-search-and-chat.impl.js +43 -0
  381. package/dist/react/embedded-search-and-chat.js +66 -0
  382. package/dist/react/embedded-search.cjs +1 -0
  383. package/dist/react/embedded-search.d.ts +17 -0
  384. package/dist/react/embedded-search.js +181 -0
  385. package/dist/react/index.cjs +1 -0
  386. package/dist/react/index.d.ts +13 -0
  387. package/dist/react/index.js +238 -0
  388. package/dist/react/modal.chat.cjs +1 -0
  389. package/dist/react/modal.chat.d.ts +9 -0
  390. package/dist/react/modal.chat.js +21 -0
  391. package/dist/react/modal.cjs +1 -0
  392. package/dist/react/modal.d.ts +23 -0
  393. package/dist/react/modal.js +27 -0
  394. package/dist/react/modal.search-and-chat.cjs +1 -0
  395. package/dist/react/modal.search-and-chat.d.ts +6 -0
  396. package/dist/react/modal.search-and-chat.js +27 -0
  397. package/dist/react/modal.search.cjs +1 -0
  398. package/dist/react/modal.search.d.ts +6 -0
  399. package/dist/react/modal.search.js +21 -0
  400. package/dist/react/searchbar.cjs +1 -0
  401. package/dist/react/searchbar.d.ts +13 -0
  402. package/dist/react/searchbar.js +68 -0
  403. package/dist/react/sidebar-chat.cjs +1 -0
  404. package/dist/react/sidebar-chat.d.ts +4 -0
  405. package/dist/react/sidebar-chat.js +53 -0
  406. package/dist/react/utils.cjs +1 -0
  407. package/dist/react/utils.d.ts +6 -0
  408. package/dist/react/utils.js +20 -0
  409. package/dist/react/widget-toggle.cjs +1 -0
  410. package/dist/react/widget-toggle.d.ts +14 -0
  411. package/dist/react/widget-toggle.js +65 -0
  412. package/dist/styled/components/chat-bubble.cjs +1 -0
  413. package/dist/styled/components/chat-bubble.d.ts +5 -0
  414. package/dist/styled/components/chat-bubble.js +70 -0
  415. package/dist/styled/components/chat-button.cjs +1 -0
  416. package/dist/styled/components/chat-button.d.ts +9 -0
  417. package/dist/styled/components/chat-button.js +60 -0
  418. package/dist/styled/components/chat-history.cjs +1 -0
  419. package/dist/styled/components/chat-history.d.ts +15 -0
  420. package/dist/styled/components/chat-history.js +197 -0
  421. package/dist/styled/components/data-summary-group.cjs +1 -0
  422. package/dist/styled/components/data-summary-group.d.ts +11 -0
  423. package/dist/styled/components/data-summary-group.js +96 -0
  424. package/dist/styled/components/embedded-chat/session-loading.cjs +1 -0
  425. package/dist/styled/components/embedded-chat/session-loading.d.ts +1 -0
  426. package/dist/styled/components/embedded-chat/session-loading.js +23 -0
  427. package/dist/styled/components/embedded-chat.cjs +1 -0
  428. package/dist/styled/components/embedded-chat.d.ts +211 -0
  429. package/dist/styled/components/embedded-chat.js +1997 -0
  430. package/dist/styled/components/embedded-search/results-loading.cjs +1 -0
  431. package/dist/styled/components/embedded-search/results-loading.d.ts +1 -0
  432. package/dist/styled/components/embedded-search/results-loading.js +39 -0
  433. package/dist/styled/components/embedded-search.cjs +1 -0
  434. package/dist/styled/components/embedded-search.d.ts +73 -0
  435. package/dist/styled/components/embedded-search.js +680 -0
  436. package/dist/styled/components/index.cjs +1 -0
  437. package/dist/styled/components/index.d.ts +13 -0
  438. package/dist/styled/components/index.js +28 -0
  439. package/dist/styled/components/loading-indicator.cjs +1 -0
  440. package/dist/styled/components/loading-indicator.d.ts +1 -0
  441. package/dist/styled/components/loading-indicator.js +36 -0
  442. package/dist/styled/components/message.cjs +1 -0
  443. package/dist/styled/components/message.d.ts +4 -0
  444. package/dist/styled/components/message.js +333 -0
  445. package/dist/styled/components/modal.cjs +1 -0
  446. package/dist/styled/components/modal.d.ts +6 -0
  447. package/dist/styled/components/modal.js +46 -0
  448. package/dist/styled/components/searchbar.cjs +1 -0
  449. package/dist/styled/components/searchbar.d.ts +11 -0
  450. package/dist/styled/components/searchbar.js +81 -0
  451. package/dist/styled/components/shadow.cjs +1 -0
  452. package/dist/styled/components/shadow.d.ts +3 -0
  453. package/dist/styled/components/shadow.js +8 -0
  454. package/dist/styled/components/sidebar-chat.cjs +1 -0
  455. package/dist/styled/components/sidebar-chat.d.ts +6 -0
  456. package/dist/styled/components/sidebar-chat.js +90 -0
  457. package/dist/styled/components/ui/markdown-styles.cjs +1 -0
  458. package/dist/styled/components/ui/markdown-styles.d.ts +23 -0
  459. package/dist/styled/components/ui/markdown-styles.js +39 -0
  460. package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.cjs +1 -0
  461. package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.d.ts +7 -0
  462. package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.js +33 -0
  463. package/dist/styled/components/ui/recipes/attachment.cjs +1 -0
  464. package/dist/styled/components/ui/recipes/attachment.d.ts +4 -0
  465. package/dist/styled/components/ui/recipes/attachment.js +28 -0
  466. package/dist/styled/components/ui/recipes/button.cjs +1 -0
  467. package/dist/styled/components/ui/recipes/button.d.ts +6 -0
  468. package/dist/styled/components/ui/recipes/button.js +87 -0
  469. package/dist/styled/components/ui/recipes/checkbox.cjs +1 -0
  470. package/dist/styled/components/ui/recipes/checkbox.d.ts +4 -0
  471. package/dist/styled/components/ui/recipes/checkbox.js +23 -0
  472. package/dist/styled/components/ui/recipes/citation.cjs +1 -0
  473. package/dist/styled/components/ui/recipes/citation.d.ts +4 -0
  474. package/dist/styled/components/ui/recipes/citation.js +75 -0
  475. package/dist/styled/components/ui/recipes/combobox.cjs +1 -0
  476. package/dist/styled/components/ui/recipes/combobox.d.ts +4 -0
  477. package/dist/styled/components/ui/recipes/combobox.js +57 -0
  478. package/dist/styled/components/ui/recipes/icon.cjs +1 -0
  479. package/dist/styled/components/ui/recipes/icon.d.ts +2 -0
  480. package/dist/styled/components/ui/recipes/icon.js +6 -0
  481. package/dist/styled/components/ui/recipes/index.cjs +1 -0
  482. package/dist/styled/components/ui/recipes/index.d.ts +16 -0
  483. package/dist/styled/components/ui/recipes/index.js +39 -0
  484. package/dist/styled/components/ui/recipes/input.cjs +1 -0
  485. package/dist/styled/components/ui/recipes/input.d.ts +5 -0
  486. package/dist/styled/components/ui/recipes/input.js +34 -0
  487. package/dist/styled/components/ui/recipes/link.cjs +1 -0
  488. package/dist/styled/components/ui/recipes/link.d.ts +2 -0
  489. package/dist/styled/components/ui/recipes/link.js +13 -0
  490. package/dist/styled/components/ui/recipes/markdown.cjs +1 -0
  491. package/dist/styled/components/ui/recipes/markdown.d.ts +16 -0
  492. package/dist/styled/components/ui/recipes/markdown.js +103 -0
  493. package/dist/styled/components/ui/recipes/modal.cjs +1 -0
  494. package/dist/styled/components/ui/recipes/modal.d.ts +4 -0
  495. package/dist/styled/components/ui/recipes/modal.js +59 -0
  496. package/dist/styled/components/ui/recipes/popover.cjs +1 -0
  497. package/dist/styled/components/ui/recipes/popover.d.ts +4 -0
  498. package/dist/styled/components/ui/recipes/popover.js +20 -0
  499. package/dist/styled/components/ui/recipes/scrollable.cjs +1 -0
  500. package/dist/styled/components/ui/recipes/scrollable.d.ts +4 -0
  501. package/dist/styled/components/ui/recipes/scrollable.js +15 -0
  502. package/dist/styled/components/ui/recipes/select.cjs +1 -0
  503. package/dist/styled/components/ui/recipes/select.d.ts +4 -0
  504. package/dist/styled/components/ui/recipes/select.js +38 -0
  505. package/dist/styled/components/ui/recipes/skeleton.cjs +1 -0
  506. package/dist/styled/components/ui/recipes/skeleton.d.ts +2 -0
  507. package/dist/styled/components/ui/recipes/skeleton.js +16 -0
  508. package/dist/styled/components/ui/recipes/widget-toggle.cjs +1 -0
  509. package/dist/styled/components/ui/recipes/widget-toggle.d.ts +4 -0
  510. package/dist/styled/components/ui/recipes/widget-toggle.js +35 -0
  511. package/dist/styled/index.cjs +1 -0
  512. package/dist/styled/index.d.ts +2 -0
  513. package/dist/styled/index.js +200 -0
  514. package/dist/styled/inkeep.css.cjs +4567 -0
  515. package/dist/styled/inkeep.css.js +4571 -0
  516. package/dist/styled/utils.cjs +1 -0
  517. package/dist/styled/utils.d.ts +4 -0
  518. package/dist/styled/utils.js +11 -0
  519. package/dist/theme/color-utils.cjs +1 -0
  520. package/dist/theme/color-utils.d.ts +1 -0
  521. package/dist/theme/color-utils.js +21 -0
  522. package/dist/theme/colors.cjs +1 -0
  523. package/dist/theme/colors.d.ts +104 -0
  524. package/dist/theme/colors.js +143 -0
  525. package/dist/theme/index.cjs +1 -0
  526. package/dist/theme/index.d.ts +125 -0
  527. package/dist/theme/index.js +58 -0
  528. package/dist/theme/utils/create-css-variables.cjs +1 -0
  529. package/dist/theme/utils/create-css-variables.d.ts +2 -0
  530. package/dist/theme/utils/create-css-variables.js +24 -0
  531. package/dist/theme/utils/generate-theme-variables.cjs +1 -0
  532. package/dist/theme/utils/generate-theme-variables.d.ts +3 -0
  533. package/dist/theme/utils/generate-theme-variables.js +34 -0
  534. package/dist/types/color-mode.d.ts +44 -0
  535. package/dist/types/config/ai.d.ts +269 -0
  536. package/dist/types/config/base.d.ts +358 -0
  537. package/dist/types/config/components.d.ts +16 -0
  538. package/dist/types/config/filters.d.ts +17 -0
  539. package/dist/types/config/index.d.ts +36 -0
  540. package/dist/types/config/open-settings.d.ts +70 -0
  541. package/dist/types/config/search.d.ts +95 -0
  542. package/dist/types/config/settings/actions.d.ts +112 -0
  543. package/dist/types/config/settings/form.d.ts +83 -0
  544. package/dist/types/config/settings/jsonschema.d.ts +105 -0
  545. package/dist/types/config/settings/workflow.d.ts +86 -0
  546. package/dist/types/events.d.ts +188 -0
  547. package/dist/types/icons/built-in.d.ts +1 -0
  548. package/dist/types/icons/custom.d.ts +33 -0
  549. package/dist/types/icons/index.d.ts +2 -0
  550. package/dist/types/index.d.ts +20 -0
  551. package/dist/types/js/index.d.ts +55 -0
  552. package/dist/types/message.d.ts +43 -0
  553. package/dist/types/shadow.d.ts +15 -0
  554. package/dist/types/sources.d.ts +100 -0
  555. package/dist/types/theme.d.ts +25 -0
  556. package/dist/types/widget.d.ts +27 -0
  557. package/package.json +140 -0
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { useContext as n, createContext as m } from "react";
4
+ import { useInkeepChat as s } from "./use-inkeep-chat.js";
5
+ import { FeedbackProvider as a } from "../../providers/feedback-provider.js";
6
+ import * as c from "@radix-ui/react-tooltip";
7
+ import { ChatFormProvider as h } from "../../providers/chat-form-provider.js";
8
+ const o = m(void 0), f = (r) => /* @__PURE__ */ t(h, { children: /* @__PURE__ */ t(d, { ...r }) }), d = ({ children: r, ...e }) => {
9
+ const i = s();
10
+ return /* @__PURE__ */ t(o.Provider, { value: { ...i, ...e }, children: /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(c.Provider, { children: r }) }) });
11
+ }, l = () => {
12
+ const r = n(o);
13
+ if (!r)
14
+ throw new Error("useChat must be used within a ChatProvider");
15
+ return r;
16
+ };
17
+ export {
18
+ f as ChatProvider,
19
+ l as useChat
20
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("altcha-lib"),c=require("react"),x=30*1e3;function b(l){const e=/[?&]expires=(\d+)/.exec(l);return e?Number.parseInt(e[1],10)*1e3:null}const p=async l=>{try{const e=await fetch(l,{method:"GET"});if(!e.ok)throw new Error(`Failed to fetch challenge: ${e.statusText}`);const i=await e.json(),{challenge:u,algorithm:n,salt:r,maxnumber:t}=i,{promise:g}=await w.solveChallenge(u,r,n,t),f=await g||void 0;if(!f)throw new Error("Challenge not solved");return{payload:{number:f.number,...i},expiresAt:b(r)}}catch(e){console.warn("[captcha] Error fetching/solving challenge:",e);return}},m=({baseUrl:l,shouldBypassCaptcha:e=!1,shouldMakeInitialRequest:i=!0})=>{const u=`${l}/run/auth/pow/challenge`,n=c.useRef(null),r=c.useRef(null),t=c.useCallback(()=>{const o=p(u);n.current=o,o.then(a=>{a&&(r.current=a.expiresAt)})},[u]),g=c.useCallback(async()=>{if(e)return{};n.current||t();const o=n.current;n.current=null,t();const a=n.current,h=await o;if(!h){const s=await a;return s?{"x-inkeep-challenge-solution":btoa(JSON.stringify(s.payload))}:{}}if(h.expiresAt!==null&&Date.now()>=h.expiresAt){const s=await a;return s?{"x-inkeep-challenge-solution":btoa(JSON.stringify(s.payload))}:{}}return{"x-inkeep-challenge-solution":btoa(JSON.stringify(h.payload))}},[e,t]),f=c.useCallback(()=>{e||t()},[e,t]);return c.useEffect(()=>{if(!i||e)return;const o=r.current!==null&&Date.now()>=r.current-x;(!n.current||o)&&t()},[i,e,t]),{getCaptchaHeader:g,invalidate:f}};exports.fetchAndSolveChallenge=p;exports.useCaptcha=m;
@@ -0,0 +1,30 @@
1
+ import { Payload } from 'altcha-lib/types';
2
+ interface UseCaptchaOptions {
3
+ baseUrl: string;
4
+ shouldBypassCaptcha?: boolean;
5
+ shouldMakeInitialRequest?: boolean;
6
+ }
7
+ interface SolvedEntry {
8
+ payload: Payload;
9
+ expiresAt: number | null;
10
+ }
11
+ export declare const fetchAndSolveChallenge: (fetchUrl: string) => Promise<SolvedEntry | undefined>;
12
+ /**
13
+ * Manages the PoW captcha lifecycle for /run/* API requests.
14
+ *
15
+ * - getCaptchaHeader(): atomically consumes the current pre-fetched challenge,
16
+ * immediately kicks off the next fetch so a fresh solution is always warm, and
17
+ * returns the ready-to-use `{ 'x-inkeep-challenge-solution': '...' }` header
18
+ * (or {} when bypassing or on failure). Checks token expiry and falls back to
19
+ * the already-started pre-fetch if the resolved token is stale.
20
+ *
21
+ * - invalidate(): discards any in-flight solution and starts a fresh fetch.
22
+ * Call this on request errors to recover from a rejected/stale challenge.
23
+ *
24
+ * All hooks are called unconditionally — bypass logic lives inside callbacks.
25
+ */
26
+ export declare const useCaptcha: ({ baseUrl, shouldBypassCaptcha, shouldMakeInitialRequest, }: UseCaptchaOptions) => {
27
+ getCaptchaHeader: () => Promise<Record<string, string>>;
28
+ invalidate: () => void;
29
+ };
30
+ export {};
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { solveChallenge as m } from "altcha-lib";
3
+ import { useRef as p, useCallback as h, useEffect as x } from "react";
4
+ const w = 30 * 1e3;
5
+ function E(i) {
6
+ const e = /[?&]expires=(\d+)/.exec(i);
7
+ return e ? Number.parseInt(e[1], 10) * 1e3 : null;
8
+ }
9
+ const y = async (i) => {
10
+ try {
11
+ const e = await fetch(i, { method: "GET" });
12
+ if (!e.ok)
13
+ throw new Error(`Failed to fetch challenge: ${e.statusText}`);
14
+ const c = await e.json(), { challenge: s, algorithm: t, salt: r, maxnumber: n } = c, { promise: g } = await m(
15
+ s,
16
+ r,
17
+ t,
18
+ n
19
+ ), u = await g || void 0;
20
+ if (!u)
21
+ throw new Error("Challenge not solved");
22
+ return {
23
+ payload: { number: u.number, ...c },
24
+ expiresAt: E(r)
25
+ };
26
+ } catch (e) {
27
+ console.warn("[captcha] Error fetching/solving challenge:", e);
28
+ return;
29
+ }
30
+ }, k = ({
31
+ baseUrl: i,
32
+ shouldBypassCaptcha: e = !1,
33
+ shouldMakeInitialRequest: c = !0
34
+ }) => {
35
+ const s = `${i}/run/auth/pow/challenge`, t = p(null), r = p(null), n = h(() => {
36
+ const o = y(s);
37
+ t.current = o, o.then((l) => {
38
+ l && (r.current = l.expiresAt);
39
+ });
40
+ }, [s]), g = h(async () => {
41
+ if (e) return {};
42
+ t.current || n();
43
+ const o = t.current;
44
+ t.current = null, n();
45
+ const l = t.current, f = await o;
46
+ if (!f) {
47
+ const a = await l;
48
+ return a ? { "x-inkeep-challenge-solution": btoa(JSON.stringify(a.payload)) } : {};
49
+ }
50
+ if (f.expiresAt !== null && Date.now() >= f.expiresAt) {
51
+ const a = await l;
52
+ return a ? { "x-inkeep-challenge-solution": btoa(JSON.stringify(a.payload)) } : {};
53
+ }
54
+ return { "x-inkeep-challenge-solution": btoa(JSON.stringify(f.payload)) };
55
+ }, [e, n]), u = h(() => {
56
+ e || n();
57
+ }, [e, n]);
58
+ return x(() => {
59
+ if (!c || e) return;
60
+ const o = r.current !== null && Date.now() >= r.current - w;
61
+ (!t.current || o) && n();
62
+ }, [c, e, n]), { getCaptchaHeader: g, invalidate: u };
63
+ };
64
+ export {
65
+ y as fetchAndSolveChallenge,
66
+ k as useCaptcha
67
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../../providers/base-events-provider.cjs"),c=require("../../providers/chat-form-provider.cjs"),d=require("../modal/modal-provider.cjs"),u=require("./chat-provider.cjs"),m=(e,s)=>{const{logEvent:t}=p.useBaseEvents(),{conversationId:n,messages:i}=u.useChat(),{openForm:a}=c.useChatForm(),r=d.useModal();return{handleAction:l=>{if(e.action.type==="open_form"){l?.onOpenForm?.();const o="name"in e?e:void 0;a?.(e.action.formSettings,o)}else if(e.action.type==="invoke_callback"||e.action.type==="invoke_message_callback"){const o={conversation:{id:n,messages:i}};e.action.type==="invoke_message_callback"?e.action.callback({...o,messageId:s}):e.action.callback({...o}),e.action.shouldCloseModal&&r?.setOpen(!1)}},logHelpAction:()=>{"name"in e&&(t({eventName:"get_help_option_clicked",properties:{getHelpOption:e,conversationId:n}}),e.action.type!=="open_form"&&t({eventName:"user_escalation_indicated",properties:{escalationType:"get_help_option",getHelpOption:e,conversationId:n}}))}}};exports.useChatAction=m;
@@ -0,0 +1,9 @@
1
+ import { IkpChatAction } from '../../../types/index.ts';
2
+ interface HandleAction {
3
+ onOpenForm?: Function;
4
+ }
5
+ export declare const useChatAction: (chatAction: IkpChatAction, messageId?: string) => {
6
+ handleAction: (opts?: HandleAction) => void;
7
+ logHelpAction: () => void;
8
+ };
9
+ export {};
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useBaseEvents as r } from "../../providers/base-events-provider.js";
3
+ import { useChatForm as m } from "../../providers/chat-form-provider.js";
4
+ import { useModal as c } from "../modal/modal-provider.js";
5
+ import { useChat as f } from "./chat-provider.js";
6
+ const y = (e, t) => {
7
+ const { logEvent: s } = r(), { conversationId: n, messages: i } = f(), { openForm: l } = m(), a = c();
8
+ return { handleAction: (p) => {
9
+ if (e.action.type === "open_form") {
10
+ p?.onOpenForm?.();
11
+ const o = "name" in e ? e : void 0;
12
+ l?.(e.action.formSettings, o);
13
+ } else if (e.action.type === "invoke_callback" || e.action.type === "invoke_message_callback") {
14
+ const o = {
15
+ conversation: {
16
+ id: n,
17
+ messages: i
18
+ }
19
+ };
20
+ e.action.type === "invoke_message_callback" ? e.action.callback({ ...o, messageId: t }) : e.action.callback({ ...o }), e.action.shouldCloseModal && a?.setOpen(!1);
21
+ }
22
+ }, logHelpAction: () => {
23
+ "name" in e && (s({
24
+ eventName: "get_help_option_clicked",
25
+ properties: {
26
+ getHelpOption: e,
27
+ conversationId: n
28
+ }
29
+ }), e.action.type !== "open_form" && s({
30
+ eventName: "user_escalation_indicated",
31
+ properties: {
32
+ escalationType: "get_help_option",
33
+ getHelpOption: e,
34
+ conversationId: n
35
+ }
36
+ }));
37
+ } };
38
+ };
39
+ export {
40
+ y as useChatAction
41
+ };
@@ -0,0 +1,3 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ne=require("@ai-sdk/react"),Oe=require("ai"),t=require("react"),Pe=require("../modal/modal-provider.cjs"),_e=require("../../providers/chat-bubble-provider.cjs"),Fe=require("../../providers/sidebar-chat-provider.cjs"),Be=require("../../providers/config-provider.cjs"),De=require("./use-captcha.cjs"),Ue=require("../../hooks/use-media-query.cjs"),Le=require("../../hooks/use-anonymous-session.cjs"),He=require("../../hooks/use-conversation-loader.cjs"),H=require("../../utils/generate-uid.cjs"),$e=require("../../providers/base-events-provider.cjs"),ze=require("../../providers/chat-form-provider.cjs"),We=require("../../providers/widget-provider.cjs"),Ke=require("@radix-ui/react-use-controllable-state"),je=require("../../hooks/use-streaming-events.cjs"),Ge=require("../../hooks/use-inkeep-api-client.cjs");function Je(f){const l=f.message??"";let r=Number(f.code)||Number(f.statusCode);if(Number.isNaN(r))try{r=Number(JSON.parse(l).status)}catch{}const d=Ge.parseAuthError(r,{detail:l});return d!==null?d:r===401?"session":null}const $=`Hmm..
2
+
3
+ It seems I might be having some issues right now. Please clear the chat and try again.`,Qe=()=>{const{baseSettings:f,aiChatSettings:l}=Be.useInkeepConfig(),[r="",d]=Ke.useControllableState({prop:l.conversationId,defaultProp:l.conversationId??""}),ce=Pe.useModal(),ue=_e.useOptionalChatBubble(),le=Fe.useOptionalSidebarChat(),{logEvent:h}=$e.useBaseEvents(),{setConversationId:de,emitToParent:C}=je.useStreamingEvents(),[v,k]=t.useState(""),pe=e=>k(e.target.value),{shouldBypassCaptcha:z,filters:W,privacyPreferences:fe}=f,{onInputMessageChange:ge,filters:K,baseUrl:S,agentUrl:me,context:j,headers:G,appId:y,apiKey:p}=l,he=ce?.isOpen??ue?.isOpen??le?.isOpen??!0,{getCaptchaHeader:b,invalidate:u}=De.useCaptcha({baseUrl:S,shouldBypassCaptcha:z||!!p,shouldMakeInitialRequest:he}),J=t.useRef(b);J.current=b;const Q=me||`${S}/run/api/chat`,{sessionToken:q,refreshSession:w}=Le.useAnonymousSession({baseUrl:S,appId:y,getCaptchaHeader:b,invalidateCaptcha:u,optOutAllAnalytics:fe?.optOutAllAnalytics}),{loadConversation:V}=He.useConversationLoader({baseUrl:S,appId:y,authToken:p??q,getCaptchaHeader:b,invalidateCaptcha:u,refreshSession:p?void 0:w}),[ve,Z]=t.useState(!1),R=t.useRef(null);R.current=q;const g=t.useRef(0),X=t.useRef(null),x=t.useRef(null),Y=t.useRef(G);Y.current=G;const T=t.useRef(void 0);T.current=W||K?JSON.stringify({...W,...K}):void 0;const ye=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${f.organizationDisplayName??"Administrator"}`;default:return $}},[be,I]=t.useState([]),[Ce,N]=t.useState(null),Se=t.useMemo(()=>new Oe.DefaultChatTransport({api:Q,headers:()=>({"x-inkeep-client-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone,"x-inkeep-client-timestamp":new Date().toISOString(),...y?{"x-inkeep-app-id":y}:{},...R.current?{Authorization:`Bearer ${R.current}`}:{},...p?{Authorization:`Bearer ${p}`}:{},...T.current?{"inkeep-filters":T.current}:{},...Y.current}),prepareSendMessagesRequest:async e=>{const s=await J.current();return{body:{...e.body,id:e.id,messages:e.messages,trigger:e.trigger,messageId:e.messageId},headers:{...e.headers,...s}}},body:{requestContext:j}}),[Q,j,y,p]),{messages:A,sendMessage:O,addToolApprovalResponse:P,status:ee,setMessages:m,stop:te,error:_}=Ne.useChat({transport:Se,onData(e){C(e.type,e.data)},async onFinish(){C("completion",{conversationId:r}),await h({eventName:"assistant_message_received",properties:{conversationId:r}}),h({eventName:"assistant_answer_displayed",properties:{conversationId:r}})},onError(e){console.error("onError",{code:e.code,message:e.message});const s=z||p?null:Je(e);if(s!==null&&g.current<1){g.current++;const i=x.current,a=X.current;(async()=>{if(s==="session"){const o=await w();o&&(R.current=o)}else u();if(i){P(i);return}a&&(m(o=>{let n=[...o];return n.at(-1)?.role==="assistant"&&(n=n.slice(0,-1)),n.at(-1)?.role==="user"&&(n=n.slice(0,-1)),n}),O({text:a.content},{body:a.body}))})().catch(()=>{g.current=0,u(),m(o=>{const n=[...o],L=n[n.length-1];if(!L)return n;const ie=$;return L.role==="user"?n.push({id:H.generateUid(16),role:"assistant",parts:[{type:"text",text:ie}]}):L.parts=[{type:"text",text:ie}],n})});return}g.current=0,s!==null&&u(),h({eventName:"chat_error",properties:{conversationId:r,error:e.message}}),m(i=>{const a=[...i],c=a[a.length-1];if(c){const o=ye(e);c.role==="user"?a.push({id:H.generateUid(16),role:"assistant",parts:[{type:"text",text:o}]}):c.parts=[{type:"text",text:o}]}return a})}}),se=ee==="submitted",F=ee==="streaming",Re=t.useMemo(()=>{const e=c=>{if(!c||typeof c!="object")return!1;const o=c;return typeof o.type=="string"&&o.type.startsWith("tool-")},i=[...A??[]].reverse().find(c=>c.role==="assistant");if(!i)return!1;const a=i.parts?.at(-1);return!(!e(a)||a.state!=="output-available"||!a.approval?.id||F)},[A,F]),re=F||Re,ne=se||re,Ie=A.length===0,B=!v.trim()||ne,Ae=Ue.useMediaQuery("(max-width: 768px)"),[Ee,E]=t.useState(null);t.useEffect(()=>{_&&E(_)},[_]);const Me=()=>E(null),ae=t.useRef(null);t.useEffect(()=>{ge?.(v)},[v]);const ke=e=>{e.key==="Enter"&&!e.shiftKey&&!B&&!e.nativeEvent.isComposing&&(e.preventDefault(),D())},D=async(e=v)=>{if(B&&(!e||e.trim().length===0))return;I([]),k(""),g.current=0,x.current=null,await h({eventName:"user_message_submitted",properties:{conversationId:r}});let s=r;s||(s=`conv_${H.generateUid(16)}`,d(s)),de(s),X.current={content:e,body:{conversationId:s}},O({text:e},{body:{conversationId:s}})},qe=t.useCallback(e=>{g.current=0,x.current=e,P(e)},[P]),U=t.useCallback(()=>{te().then(()=>{C("aborted",{conversationId:r})})},[te,r,C]),oe=()=>{Me(),m([]),d(""),I([]),N(null),u(),h({eventName:"chat_clear_button_clicked",properties:{conversationId:r}})},M=t.useCallback((e,s)=>{E(null),m(s),d(e),I([]),N(null),u()},[m,d,u]),we=t.useCallback(async(e,s)=>{U(),M(e,[]),Z(!0);try{const i=await V(e,s);i!==null&&M(e,i)}finally{s?.aborted||Z(!1)}},[M,V,U]),{openForm:xe}=ze.useChatForm(),Te=We.useWidget();return t.useImperativeHandle(l.chatFunctionsRef,()=>({submitMessage:D,updateInputMessage(e){k(e)},clearChat:oe,openForm:e=>{Te?.setView("chat"),xe(e,void 0)},focusInput:()=>{ae.current?.focus()}})),{messages:A,sendMessage:O,addToolApprovalResponse:qe,isLoading:se,isStreaming:re,isBusy:ne,error:Ee,setError:E,isSubmitDisabled:B,input:v,handleInputChange:pe,handleInputKeyDown:ke,handleSubmit:D,stop:U,clear:oe,inputRef:ae,isMobile:Ae,messageAttachments:be,setMessageAttachments:I,selectedWorkflow:Ce,setSelectedWorkflow:N,isNewChat:Ie,conversationId:r,restoreSession:M,loadAndRestoreSession:we,isSessionLoading:ve,sessionToken:q,refreshSession:w,getCaptchaHeader:b,invalidateCaptcha:u}};exports.DEFAULT_ERROR_MESSAGE=$;exports.useInkeepChat=Qe;
@@ -0,0 +1,57 @@
1
+ import { KeyboardEvent, Dispatch, SetStateAction, RefObject } from 'react';
2
+ import { Message, MessageAttachment, Workflow } from '../../../types/index.ts';
3
+ import { FileUIPart, ChatRequestOptions } from 'ai';
4
+ export declare const DEFAULT_ERROR_MESSAGE = "Hmm.. \n\nIt seems I might be having some issues right now. Please clear the chat and try again.";
5
+ export declare const useInkeepChat: () => {
6
+ messages: Message[];
7
+ sendMessage: (message?: (Omit<Message, "id" | "role"> & {
8
+ id?: string | undefined;
9
+ role?: "system" | "user" | "assistant" | undefined;
10
+ } & {
11
+ text?: never;
12
+ files?: never;
13
+ messageId?: string;
14
+ }) | {
15
+ text: string;
16
+ files?: FileList | FileUIPart[];
17
+ metadata?: unknown;
18
+ parts?: never;
19
+ messageId?: string;
20
+ } | {
21
+ files: FileList | FileUIPart[];
22
+ metadata?: unknown;
23
+ parts?: never;
24
+ messageId?: string;
25
+ } | undefined, options?: ChatRequestOptions) => Promise<void>;
26
+ addToolApprovalResponse: (approval: {
27
+ id: string;
28
+ approved: boolean;
29
+ }) => void;
30
+ isLoading: boolean;
31
+ isStreaming: boolean;
32
+ isBusy: boolean;
33
+ error: Error | null;
34
+ setError: Dispatch<SetStateAction<Error | null>>;
35
+ isSubmitDisabled: boolean;
36
+ input: string;
37
+ handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
38
+ handleInputKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
39
+ handleSubmit: (content?: string) => Promise<void>;
40
+ stop: () => void;
41
+ clear: () => void;
42
+ inputRef: RefObject<HTMLTextAreaElement | null>;
43
+ isMobile: boolean;
44
+ messageAttachments: MessageAttachment[];
45
+ setMessageAttachments: Dispatch<SetStateAction<MessageAttachment[]>>;
46
+ selectedWorkflow: Workflow | null;
47
+ setSelectedWorkflow: Dispatch<SetStateAction<Workflow | null>>;
48
+ isNewChat: boolean;
49
+ conversationId: string;
50
+ restoreSession: (sessionId: string, loadedMessages: Message[]) => void;
51
+ loadAndRestoreSession: (sessionId: string, signal?: AbortSignal) => Promise<void>;
52
+ isSessionLoading: boolean;
53
+ sessionToken: string | null;
54
+ refreshSession: () => Promise<string | null>;
55
+ getCaptchaHeader: () => Promise<Record<string, string>>;
56
+ invalidateCaptcha: () => void;
57
+ };
@@ -0,0 +1,312 @@
1
+ "use client";
2
+ import { useChat as De } from "@ai-sdk/react";
3
+ import { DefaultChatTransport as Pe } from "ai";
4
+ import { useState as C, useRef as l, useMemo as le, useEffect as ue, useCallback as x, useImperativeHandle as He } from "react";
5
+ import { useModal as Le } from "../modal/modal-provider.js";
6
+ import { useOptionalChatBubble as Ue } from "../../providers/chat-bubble-provider.js";
7
+ import { useOptionalSidebarChat as $e } from "../../providers/sidebar-chat-provider.js";
8
+ import { useInkeepConfig as ze } from "../../providers/config-provider.js";
9
+ import { useCaptcha as We } from "./use-captcha.js";
10
+ import { useMediaQuery as qe } from "../../hooks/use-media-query.js";
11
+ import { useAnonymousSession as Ke } from "../../hooks/use-anonymous-session.js";
12
+ import { useConversationLoader as Je } from "../../hooks/use-conversation-loader.js";
13
+ import { generateUid as W } from "../../utils/generate-uid.js";
14
+ import { useBaseEvents as je } from "../../providers/base-events-provider.js";
15
+ import { useChatForm as Ge } from "../../providers/chat-form-provider.js";
16
+ import { useWidget as Qe } from "../../providers/widget-provider.js";
17
+ import { useControllableState as Ve } from "@radix-ui/react-use-controllable-state";
18
+ import { useStreamingEvents as Ze } from "../../hooks/use-streaming-events.js";
19
+ import { parseAuthError as Xe } from "../../hooks/use-inkeep-api-client.js";
20
+ function Ye(d) {
21
+ const u = d.message ?? "";
22
+ let s = Number(d.code) || Number(d.statusCode);
23
+ if (Number.isNaN(s))
24
+ try {
25
+ s = Number(JSON.parse(u).status);
26
+ } catch {
27
+ }
28
+ const p = Xe(s, { detail: u });
29
+ return p !== null ? p : s === 401 ? "session" : null;
30
+ }
31
+ const pe = `Hmm..
32
+
33
+ It seems I might be having some issues right now. Please clear the chat and try again.`, vt = () => {
34
+ const { baseSettings: d, aiChatSettings: u } = ze(), [s = "", p] = Ve({
35
+ prop: u.conversationId,
36
+ defaultProp: u.conversationId ?? ""
37
+ }), me = Le(), de = Ue(), fe = $e(), { logEvent: h } = je(), { setConversationId: ge, emitToParent: S } = Ze(), [y, k] = C(""), he = (e) => k(e.target.value), { shouldBypassCaptcha: q, filters: K, privacyPreferences: ye } = d, {
38
+ onInputMessageChange: ve,
39
+ filters: J,
40
+ baseUrl: I,
41
+ agentUrl: be,
42
+ context: j,
43
+ headers: G,
44
+ appId: v,
45
+ apiKey: m
46
+ } = u, Ce = me?.isOpen ?? de?.isOpen ?? fe?.isOpen ?? !0, { getCaptchaHeader: b, invalidate: c } = We({
47
+ baseUrl: I,
48
+ shouldBypassCaptcha: q || !!m,
49
+ shouldMakeInitialRequest: Ce
50
+ }), Q = l(b);
51
+ Q.current = b;
52
+ const V = be || `${I}/run/api/chat`, { sessionToken: N, refreshSession: T } = Ke({
53
+ baseUrl: I,
54
+ appId: v,
55
+ getCaptchaHeader: b,
56
+ invalidateCaptcha: c,
57
+ optOutAllAnalytics: ye?.optOutAllAnalytics
58
+ }), { loadConversation: Z } = Je({
59
+ baseUrl: I,
60
+ appId: v,
61
+ authToken: m ?? N,
62
+ getCaptchaHeader: b,
63
+ invalidateCaptcha: c,
64
+ // Only pass refreshSession for anonymous-session flows; API key auth has no token to refresh.
65
+ refreshSession: m ? void 0 : T
66
+ }), [Se, X] = C(!1), A = l(null);
67
+ A.current = N;
68
+ const f = l(0), Y = l(null), O = l(null), ee = l(G);
69
+ ee.current = G;
70
+ const _ = l(void 0);
71
+ _.current = K || J ? JSON.stringify({ ...K, ...J }) : void 0;
72
+ const Ie = (e) => {
73
+ switch (e.code) {
74
+ case 400:
75
+ return e.message;
76
+ case 403:
77
+ return `There seems to be a configuration error. Please contact ${d.organizationDisplayName ?? "Administrator"}`;
78
+ default:
79
+ return pe;
80
+ }
81
+ }, [Ae, R] = C([]), [Re, F] = C(null), we = le(
82
+ () => new Pe({
83
+ api: V,
84
+ headers: () => ({
85
+ "x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
86
+ "x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
87
+ ...v ? { "x-inkeep-app-id": v } : {},
88
+ ...A.current ? { Authorization: `Bearer ${A.current}` } : {},
89
+ ...m ? { Authorization: `Bearer ${m}` } : {},
90
+ ..._.current ? { "inkeep-filters": _.current } : {},
91
+ ...ee.current
92
+ }),
93
+ prepareSendMessagesRequest: async (e) => {
94
+ const t = await Q.current();
95
+ return {
96
+ body: {
97
+ ...e.body,
98
+ id: e.id,
99
+ messages: e.messages,
100
+ trigger: e.trigger,
101
+ messageId: e.messageId
102
+ },
103
+ headers: {
104
+ ...e.headers,
105
+ ...t
106
+ }
107
+ };
108
+ },
109
+ body: {
110
+ requestContext: j
111
+ }
112
+ }),
113
+ [V, j, v, m]
114
+ ), {
115
+ messages: w,
116
+ sendMessage: B,
117
+ addToolApprovalResponse: D,
118
+ status: te,
119
+ setMessages: g,
120
+ stop: se,
121
+ error: P
122
+ } = De({
123
+ transport: we,
124
+ onData(e) {
125
+ S(e.type, e.data);
126
+ },
127
+ async onFinish() {
128
+ S("completion", { conversationId: s }), await h({
129
+ eventName: "assistant_message_received",
130
+ properties: {
131
+ conversationId: s
132
+ }
133
+ }), h({
134
+ eventName: "assistant_answer_displayed",
135
+ properties: {
136
+ conversationId: s
137
+ }
138
+ });
139
+ },
140
+ onError(e) {
141
+ console.error("onError", { code: e.code, message: e.message });
142
+ const t = q || m ? null : Ye(e);
143
+ if (t !== null && f.current < 1) {
144
+ f.current++;
145
+ const a = O.current, n = Y.current;
146
+ (async () => {
147
+ if (t === "session") {
148
+ const o = await T();
149
+ o && (A.current = o);
150
+ } else
151
+ c();
152
+ if (a) {
153
+ D(a);
154
+ return;
155
+ }
156
+ n && (g((o) => {
157
+ let r = [...o];
158
+ return r.at(-1)?.role === "assistant" && (r = r.slice(0, -1)), r.at(-1)?.role === "user" && (r = r.slice(0, -1)), r;
159
+ }), B({ text: n.content }, { body: n.body }));
160
+ })().catch(() => {
161
+ f.current = 0, c(), g((o) => {
162
+ const r = [...o], z = r[r.length - 1];
163
+ if (!z) return r;
164
+ const ce = pe;
165
+ return z.role === "user" ? r.push({
166
+ id: W(16),
167
+ role: "assistant",
168
+ parts: [{ type: "text", text: ce }]
169
+ }) : z.parts = [{ type: "text", text: ce }], r;
170
+ });
171
+ });
172
+ return;
173
+ }
174
+ f.current = 0, t !== null && c(), h({
175
+ eventName: "chat_error",
176
+ properties: {
177
+ conversationId: s,
178
+ error: e.message
179
+ }
180
+ }), g((a) => {
181
+ const n = [...a], i = n[n.length - 1];
182
+ if (i) {
183
+ const o = Ie(e);
184
+ i.role === "user" ? n.push({
185
+ id: W(16),
186
+ role: "assistant",
187
+ parts: [{ type: "text", text: o }]
188
+ }) : i.parts = [{ type: "text", text: o }];
189
+ }
190
+ return n;
191
+ });
192
+ }
193
+ }), re = te === "submitted", H = te === "streaming", Me = le(() => {
194
+ const e = (i) => {
195
+ if (!i || typeof i != "object") return !1;
196
+ const o = i;
197
+ return typeof o.type == "string" && o.type.startsWith("tool-");
198
+ }, a = [...w ?? []].reverse().find((i) => i.role === "assistant");
199
+ if (!a) return !1;
200
+ const n = a.parts?.at(-1);
201
+ return !(!e(n) || n.state !== "output-available" || !n.approval?.id || H);
202
+ }, [w, H]), ne = H || Me, oe = re || ne, Ee = w.length === 0, L = !y.trim() || oe, xe = qe("(max-width: 768px)"), [ke, M] = C(null);
203
+ ue(() => {
204
+ P && M(P);
205
+ }, [P]);
206
+ const Ne = () => M(null), ae = l(null);
207
+ ue(() => {
208
+ ve?.(y);
209
+ }, [y]);
210
+ const Te = (e) => {
211
+ e.key === "Enter" && !e.shiftKey && !L && !e.nativeEvent.isComposing && (e.preventDefault(), U());
212
+ }, U = async (e = y) => {
213
+ if (L && (!e || e.trim().length === 0)) return;
214
+ R([]), k(""), f.current = 0, O.current = null, await h({
215
+ eventName: "user_message_submitted",
216
+ properties: {
217
+ conversationId: s
218
+ }
219
+ });
220
+ let t = s;
221
+ t || (t = `conv_${W(16)}`, p(t)), ge(t), Y.current = {
222
+ content: e,
223
+ body: { conversationId: t }
224
+ }, B(
225
+ { text: e },
226
+ {
227
+ body: { conversationId: t }
228
+ }
229
+ );
230
+ }, Oe = x(
231
+ (e) => {
232
+ f.current = 0, O.current = e, D(e);
233
+ },
234
+ [D]
235
+ ), $ = x(() => {
236
+ se().then(() => {
237
+ S("aborted", { conversationId: s });
238
+ });
239
+ }, [se, s, S]), ie = () => {
240
+ Ne(), g([]), p(""), R([]), F(null), c(), h({
241
+ eventName: "chat_clear_button_clicked",
242
+ properties: {
243
+ conversationId: s
244
+ }
245
+ });
246
+ }, E = x(
247
+ (e, t) => {
248
+ M(null), g(t), p(e), R([]), F(null), c();
249
+ },
250
+ [g, p, c]
251
+ ), _e = x(
252
+ async (e, t) => {
253
+ $(), E(e, []), X(!0);
254
+ try {
255
+ const a = await Z(e, t);
256
+ a !== null && E(e, a);
257
+ } finally {
258
+ t?.aborted || X(!1);
259
+ }
260
+ },
261
+ [E, Z, $]
262
+ ), { openForm: Fe } = Ge(), Be = Qe();
263
+ return He(u.chatFunctionsRef, () => ({
264
+ submitMessage: U,
265
+ updateInputMessage(e) {
266
+ k(e);
267
+ },
268
+ clearChat: ie,
269
+ openForm: (e) => {
270
+ Be?.setView("chat"), Fe(e, void 0);
271
+ },
272
+ focusInput: () => {
273
+ ae.current?.focus();
274
+ }
275
+ })), {
276
+ messages: w,
277
+ sendMessage: B,
278
+ addToolApprovalResponse: Oe,
279
+ isLoading: re,
280
+ isStreaming: ne,
281
+ isBusy: oe,
282
+ error: ke,
283
+ setError: M,
284
+ isSubmitDisabled: L,
285
+ input: y,
286
+ handleInputChange: he,
287
+ handleInputKeyDown: Te,
288
+ handleSubmit: U,
289
+ stop: $,
290
+ clear: ie,
291
+ inputRef: ae,
292
+ isMobile: xe,
293
+ // Additional state for attachments and workflow
294
+ messageAttachments: Ae,
295
+ setMessageAttachments: R,
296
+ selectedWorkflow: Re,
297
+ setSelectedWorkflow: F,
298
+ isNewChat: Ee,
299
+ conversationId: s,
300
+ restoreSession: E,
301
+ loadAndRestoreSession: _e,
302
+ isSessionLoading: Se,
303
+ sessionToken: N,
304
+ refreshSession: T,
305
+ getCaptchaHeader: b,
306
+ invalidateCaptcha: c
307
+ };
308
+ };
309
+ export {
310
+ pe as DEFAULT_ERROR_MESSAGE,
311
+ vt as useInkeepChat
312
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),O=require("./use-inkeep-chat.cjs");function R(a,n){if(n)return a.findIndex(h=>h.type==="tool_call"&&h.toolCallId===n);const d=a.length-1;return d>=0&&a[d].type==="tool_call"?d:-1}function G(a){const n=a.ctx,h=a.details?.data,y=n?.toolCallId??n?.callId??a.toolCallId??h?.toolCallId;return typeof y=="string"?y:void 0}function q(a,n,d){const[h,y]=l.useState(!1),D=l.useRef(0),v=l.useRef(0),A=l.useRef(Date.now()),g=l.useRef(new Map),k=l.useRef(null),{processedParts:b,summaryTimings:P}=l.useMemo(()=>{const r=[];let t="",o=[],w=!1;a.length>D.current&&(A.current=Date.now(),D.current=a.length),v.current=0;const f=new Map,x=(s=!1)=>{if(o.length>0){const e=`group-${v.current++}`,u=g.current.get(e);u?f.set(e,{...u,isCompleted:s}):f.set(e,{isCompleted:s}),r.push({type:"summary-group",summaries:[...o],groupKey:e}),o=[]}};for(const s of a)if(s.type==="text")x(!0),t+=s.text||"";else if(s.type==="data-summary")t.trim()&&(r.push({type:"text",text:t}),t=""),o.push(s.data);else if(s.type==="data-operation"){t.trim()&&(r.push({type:"text",text:t}),t="");const e=s.data;if(e?.type){if((e.type==="tool_call"||e.type==="tool_result")&&e.details?.data?.inDelegatedAgent===!1)continue;switch(e.type){case"agent_initializing":break;case"completion":{const{type:i}=e;o.push({type:i,label:"Completed"}),x(!0);break}case"error":{const i=e.message||"Unknown error";if(console.warn("Data operation error:",i),!r.length)x(!0),k.current=i,w||(r.push({type:"text",text:O.DEFAULT_ERROR_MESSAGE}),w=!0);else{const{type:p,label:c}=e;o.push({type:p,label:c})}break}case"tool_call":{const{type:i,label:p}=e,c=G(e);o.push({type:i,label:p,...c&&{toolCallId:c}});break}case"tool_result":{const{type:i,label:p}=e,c=G(e),S={type:i,label:p},M=R(o,c);if(M>=0){o[M]=S;break}const T=r.filter(I=>I?.type==="summary-group");if(c){let I=!1;for(let m=T.length-1;m>=0;m--){const C=T[m].summaries;if(C?.length){const L=R(C,c);if(L>=0){C[L]=S,I=!0;break}}}if(I)break}else{const m=T[T.length-1]?.summaries;if(m?.length){const C=R(m,void 0);if(C>=0){m[C]=S;break}}}o.push(S);break}default:{const{type:i,label:p}=e;o.push({type:i,label:p});break}}}}else if(s.type==="data-artifact")if(s.data?.type?.toLowerCase()==="citation"){const e=s.data,u=e.artifactSummary||{title:e.name};t+=` ^${u?.title||e.name}^`}else t.trim()&&(r.push({type:"text",text:t}),t=""),r.push(s);else s.type==="data-component"?(t.trim()&&(r.push({type:"text",text:t}),t=""),x(!0),r.push(s)):(t.trim()&&(r.push({type:"text",text:t}),t=""),x(!0),r.push(s));if(x(!n),t.trim()&&r.push({type:"text",text:t}),!n)for(const[s,e]of f.entries())e.isCompleted||f.set(s,{...e,isCompleted:!0});const _=f.size!==g.current.size||Array.from(f.entries()).some(([s,e])=>{const u=g.current.get(s);return!u||u.isCompleted!==e.isCompleted})?f:g.current;return g.current=_,{processedParts:r,summaryTimings:_}},[a,n]);l.useEffect(()=>{k.current&&(d(new Error(k.current)),k.current=null)});const E=l.useCallback(()=>{const r=Date.now()-A.current,t=Array.from(g.current.values()).some(w=>!w.isCompleted),o=r>1e3&&!t;y(o)},[]);l.useEffect(()=>{if(!n){y(!1);return}if(!(b.length>0)){y(!1);return}const t=setInterval(E,200);return()=>clearInterval(t)},[n,E,b.length]);const z=l.useMemo(()=>!!(!(b.length>0)&&n),[b.length,n]);return{processedParts:b,summaryTimings:P,shouldShowInitialLoading:z,shouldShowStreamDelayLoading:h}}exports.useStreamProcessor=q;
@@ -0,0 +1,30 @@
1
+ import { Message } from '../../../types/index.ts';
2
+ interface SummaryTiming {
3
+ isCompleted: boolean;
4
+ }
5
+ interface DataSummary {
6
+ type: string;
7
+ label?: string;
8
+ details?: Record<string, unknown>;
9
+ /** Used to match tool_result to tool_call when they're in different groups (e.g. approval in between) or parallel */
10
+ toolCallId?: string;
11
+ }
12
+ interface TextPart {
13
+ type: 'text';
14
+ text?: string;
15
+ }
16
+ interface SummaryGroupPart {
17
+ type: 'summary-group';
18
+ summaries?: DataSummary[];
19
+ groupKey: string;
20
+ }
21
+ type SummaryPart = TextPart | SummaryGroupPart;
22
+ type ProcessedPart = SummaryPart | Message['parts'][number];
23
+ export interface UseStreamProcessorReturn {
24
+ processedParts: ProcessedPart[];
25
+ summaryTimings: Map<string, SummaryTiming>;
26
+ shouldShowInitialLoading: boolean;
27
+ shouldShowStreamDelayLoading: boolean;
28
+ }
29
+ export declare function useStreamProcessor(parts: Message['parts'], isStreaming: boolean, setError: (error: Error) => void): UseStreamProcessorReturn;
30
+ export {};