@inkeep/agents-ui 0.0.0-rc-20260310051343
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.
- package/LICENSE +64 -0
- package/README.md +1 -0
- package/dist/_virtual/index.cjs +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.development.cjs +1 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/_virtual/use-sync-external-store-shim.production.cjs +1 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +5 -0
- package/dist/color-mode/index.cjs +1 -0
- package/dist/color-mode/index.d.ts +20 -0
- package/dist/color-mode/index.js +170 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +238 -0
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/primitives/atoms/avatars/ai.cjs +1 -0
- package/dist/primitives/atoms/avatars/ai.d.ts +3 -0
- package/dist/primitives/atoms/avatars/ai.js +99 -0
- package/dist/primitives/atoms/avatars/user.cjs +1 -0
- package/dist/primitives/atoms/avatars/user.d.ts +3 -0
- package/dist/primitives/atoms/avatars/user.js +27 -0
- package/dist/primitives/atoms/cmdk/command-score.cjs +1 -0
- package/dist/primitives/atoms/cmdk/command-score.d.ts +1 -0
- package/dist/primitives/atoms/cmdk/command-score.js +46 -0
- package/dist/primitives/atoms/cmdk/index.cjs +1 -0
- package/dist/primitives/atoms/cmdk/index.d.ts +460 -0
- package/dist/primitives/atoms/cmdk/index.js +521 -0
- package/dist/primitives/atoms/codeblock/index.cjs +1 -0
- package/dist/primitives/atoms/codeblock/index.d.ts +10 -0
- package/dist/primitives/atoms/codeblock/index.js +40 -0
- package/dist/primitives/atoms/combobox.cjs +1 -0
- package/dist/primitives/atoms/combobox.js +275 -0
- package/dist/primitives/atoms/custom-styles.cjs +1 -0
- package/dist/primitives/atoms/custom-styles.d.ts +5 -0
- package/dist/primitives/atoms/custom-styles.js +57 -0
- package/dist/primitives/atoms/dialog.cjs +1 -0
- package/dist/primitives/atoms/dialog.d.ts +94 -0
- package/dist/primitives/atoms/dialog.js +227 -0
- package/dist/primitives/atoms/error-boundary.cjs +1 -0
- package/dist/primitives/atoms/error-boundary.d.ts +6 -0
- package/dist/primitives/atoms/error-boundary.js +9 -0
- package/dist/primitives/atoms/icons/built-in-icon-renderer.cjs +1 -0
- package/dist/primitives/atoms/icons/built-in-icon-renderer.d.ts +6 -0
- package/dist/primitives/atoms/icons/built-in-icon-renderer.js +51 -0
- package/dist/primitives/atoms/icons/built-in-icons.cjs +1 -0
- package/dist/primitives/atoms/icons/built-in-icons.d.ts +86 -0
- package/dist/primitives/atoms/icons/built-in-icons.js +89 -0
- package/dist/primitives/atoms/icons/checkbox-icon.cjs +1 -0
- package/dist/primitives/atoms/icons/checkbox-icon.d.ts +1 -0
- package/dist/primitives/atoms/icons/checkbox-icon.js +24 -0
- package/dist/primitives/atoms/icons/collections/bi.cjs +1 -0
- package/dist/primitives/atoms/icons/collections/bi.d.ts +4 -0
- package/dist/primitives/atoms/icons/collections/bi.js +49 -0
- package/dist/primitives/atoms/icons/collections/fi.cjs +1 -0
- package/dist/primitives/atoms/icons/collections/fi.d.ts +2 -0
- package/dist/primitives/atoms/icons/collections/fi.js +29 -0
- package/dist/primitives/atoms/icons/collections/gr.cjs +1 -0
- package/dist/primitives/atoms/icons/collections/gr.d.ts +2 -0
- package/dist/primitives/atoms/icons/collections/gr.js +21 -0
- package/dist/primitives/atoms/icons/collections/io5.cjs +1 -0
- package/dist/primitives/atoms/icons/collections/io5.d.ts +34 -0
- package/dist/primitives/atoms/icons/collections/io5.js +806 -0
- package/dist/primitives/atoms/icons/collections/pi.cjs +1 -0
- package/dist/primitives/atoms/icons/collections/pi.d.ts +4 -0
- package/dist/primitives/atoms/icons/collections/pi.js +49 -0
- package/dist/primitives/atoms/icons/custom-icon.cjs +1 -0
- package/dist/primitives/atoms/icons/custom-icon.d.ts +6 -0
- package/dist/primitives/atoms/icons/custom-icon.js +19 -0
- package/dist/primitives/atoms/icons/generate-icon.cjs +1 -0
- package/dist/primitives/atoms/icons/generate-icon.d.ts +28 -0
- package/dist/primitives/atoms/icons/generate-icon.js +56 -0
- package/dist/primitives/atoms/icons/index.cjs +1 -0
- package/dist/primitives/atoms/icons/index.d.ts +2 -0
- package/dist/primitives/atoms/icons/index.js +6 -0
- package/dist/primitives/atoms/icons/inkeep-default-icons.cjs +1 -0
- package/dist/primitives/atoms/icons/inkeep-default-icons.d.ts +2 -0
- package/dist/primitives/atoms/icons/inkeep-default-icons.js +28 -0
- package/dist/primitives/atoms/link.cjs +1 -0
- package/dist/primitives/atoms/link.d.ts +14 -0
- package/dist/primitives/atoms/link.js +35 -0
- package/dist/primitives/atoms/markdown/components.cjs +1 -0
- package/dist/primitives/atoms/markdown/components.d.ts +31 -0
- package/dist/primitives/atoms/markdown/components.js +76 -0
- package/dist/primitives/atoms/markdown/index.cjs +1 -0
- package/dist/primitives/atoms/markdown/index.d.ts +17 -0
- package/dist/primitives/atoms/markdown/index.js +121 -0
- package/dist/primitives/atoms/markdown/rehype-inline-code-property.cjs +1 -0
- package/dist/primitives/atoms/markdown/rehype-inline-code-property.d.ts +1 -0
- package/dist/primitives/atoms/markdown/rehype-inline-code-property.js +12 -0
- package/dist/primitives/atoms/portal-with-theme.cjs +1 -0
- package/dist/primitives/atoms/portal-with-theme.d.ts +2 -0
- package/dist/primitives/atoms/portal-with-theme.js +12 -0
- package/dist/primitives/atoms/portal.cjs +1 -0
- package/dist/primitives/atoms/portal.d.ts +8 -0
- package/dist/primitives/atoms/portal.js +19 -0
- package/dist/primitives/atoms/select.cjs +1 -0
- package/dist/primitives/atoms/select.d.ts +136 -0
- package/dist/primitives/atoms/select.js +785 -0
- package/dist/primitives/atoms/shadow/context.cjs +1 -0
- package/dist/primitives/atoms/shadow/context.d.ts +14 -0
- package/dist/primitives/atoms/shadow/context.js +54 -0
- package/dist/primitives/atoms/shadow/create.cjs +1 -0
- package/dist/primitives/atoms/shadow/create.d.ts +8 -0
- package/dist/primitives/atoms/shadow/create.js +56 -0
- package/dist/primitives/atoms/shadow/index.d.ts +1 -0
- package/dist/primitives/atoms/shadow/root.cjs +1 -0
- package/dist/primitives/atoms/shadow/root.d.ts +5 -0
- package/dist/primitives/atoms/shadow/root.js +22 -0
- package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.cjs +1 -0
- package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.d.ts +2 -0
- package/dist/primitives/atoms/shadow/use-ensured-forwarded-ref.js +11 -0
- package/dist/primitives/atoms/shadow/utils.cjs +1 -0
- package/dist/primitives/atoms/shadow/utils.d.ts +9 -0
- package/dist/primitives/atoms/shadow/utils.js +16 -0
- package/dist/primitives/components/chat-bubble/index.cjs +1 -0
- package/dist/primitives/components/chat-bubble/index.d.ts +10 -0
- package/dist/primitives/components/chat-bubble/index.js +38 -0
- package/dist/primitives/components/chat-button.cjs +1 -0
- package/dist/primitives/components/chat-button.d.ts +20 -0
- package/dist/primitives/components/chat-button.js +51 -0
- package/dist/primitives/components/chat-history/index.cjs +1 -0
- package/dist/primitives/components/chat-history/index.d.ts +27 -0
- package/dist/primitives/components/chat-history/index.js +105 -0
- package/dist/primitives/components/data-summaries.cjs +1 -0
- package/dist/primitives/components/data-summaries.d.ts +14 -0
- package/dist/primitives/components/data-summaries.js +38 -0
- package/dist/primitives/components/embedded-chat/chat-provider.cjs +1 -0
- package/dist/primitives/components/embedded-chat/chat-provider.d.ts +19 -0
- package/dist/primitives/components/embedded-chat/chat-provider.js +20 -0
- package/dist/primitives/components/embedded-chat/use-captcha.cjs +1 -0
- package/dist/primitives/components/embedded-chat/use-captcha.d.ts +30 -0
- package/dist/primitives/components/embedded-chat/use-captcha.js +64 -0
- package/dist/primitives/components/embedded-chat/use-chat-action.cjs +1 -0
- package/dist/primitives/components/embedded-chat/use-chat-action.d.ts +9 -0
- package/dist/primitives/components/embedded-chat/use-chat-action.js +41 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +3 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +51 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +275 -0
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -0
- package/dist/primitives/components/embedded-chat/use-stream-processor.d.ts +30 -0
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +159 -0
- package/dist/primitives/components/embedded-chat.cjs +11 -0
- package/dist/primitives/components/embedded-chat.d.ts +461 -0
- package/dist/primitives/components/embedded-chat.js +2051 -0
- package/dist/primitives/components/embedded-search/search-provider.cjs +1 -0
- package/dist/primitives/components/embedded-search/search-provider.d.ts +21 -0
- package/dist/primitives/components/embedded-search/search-provider.js +26 -0
- package/dist/primitives/components/embedded-search/transform-results.cjs +1 -0
- package/dist/primitives/components/embedded-search/transform-results.d.ts +3 -0
- package/dist/primitives/components/embedded-search/transform-results.js +47 -0
- package/dist/primitives/components/embedded-search/url-query.cjs +1 -0
- package/dist/primitives/components/embedded-search/url-query.d.ts +4 -0
- package/dist/primitives/components/embedded-search/url-query.js +12 -0
- package/dist/primitives/components/embedded-search/use-inkeep-search.cjs +1 -0
- package/dist/primitives/components/embedded-search/use-inkeep-search.d.ts +19 -0
- package/dist/primitives/components/embedded-search/use-inkeep-search.js +35 -0
- package/dist/primitives/components/embedded-search/use-search-filter.cjs +1 -0
- package/dist/primitives/components/embedded-search/use-search-filter.d.ts +1 -0
- package/dist/primitives/components/embedded-search/use-search-filter.js +77 -0
- package/dist/primitives/components/embedded-search.cjs +1 -0
- package/dist/primitives/components/embedded-search.d.ts +249 -0
- package/dist/primitives/components/embedded-search.js +628 -0
- package/dist/primitives/components/factory.cjs +1 -0
- package/dist/primitives/components/factory.d.ts +19 -0
- package/dist/primitives/components/factory.js +39 -0
- package/dist/primitives/components/index.cjs +1 -0
- package/dist/primitives/components/index.d.ts +13 -0
- package/dist/primitives/components/index.js +33 -0
- package/dist/primitives/components/modal/modal-provider.cjs +1 -0
- package/dist/primitives/components/modal/modal-provider.d.ts +12 -0
- package/dist/primitives/components/modal/modal-provider.js +8 -0
- package/dist/primitives/components/modal/use-inkeep-modal.cjs +1 -0
- package/dist/primitives/components/modal/use-inkeep-modal.d.ts +7 -0
- package/dist/primitives/components/modal/use-inkeep-modal.js +9 -0
- package/dist/primitives/components/modal/widget-auto-focus.cjs +1 -0
- package/dist/primitives/components/modal/widget-auto-focus.d.ts +2 -0
- package/dist/primitives/components/modal/widget-auto-focus.js +25 -0
- package/dist/primitives/components/modal.cjs +1 -0
- package/dist/primitives/components/modal.d.ts +18 -0
- package/dist/primitives/components/modal.js +40 -0
- package/dist/primitives/components/presence.cjs +1 -0
- package/dist/primitives/components/presence.d.ts +8 -0
- package/dist/primitives/components/presence.js +26 -0
- package/dist/primitives/components/searchbar.cjs +1 -0
- package/dist/primitives/components/searchbar.d.ts +23 -0
- package/dist/primitives/components/searchbar.js +54 -0
- package/dist/primitives/components/sidebar-chat/index.cjs +1 -0
- package/dist/primitives/components/sidebar-chat/index.d.ts +9 -0
- package/dist/primitives/components/sidebar-chat/index.js +67 -0
- package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.cjs +1 -0
- package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.d.ts +5 -0
- package/dist/primitives/components/sidebar-chat/use-sidebar-chat-resizer.js +34 -0
- package/dist/primitives/components/tagline-logo-icon.cjs +1 -0
- package/dist/primitives/components/tagline-logo-icon.d.ts +1 -0
- package/dist/primitives/components/tagline-logo-icon.js +26 -0
- package/dist/primitives/components/use-component-trigger.cjs +1 -0
- package/dist/primitives/components/use-component-trigger.d.ts +5 -0
- package/dist/primitives/components/use-component-trigger.js +17 -0
- package/dist/primitives/constants/search.cjs +1 -0
- package/dist/primitives/constants/search.d.ts +1 -0
- package/dist/primitives/constants/search.js +5 -0
- package/dist/primitives/hooks/index.cjs +1 -0
- package/dist/primitives/hooks/index.d.ts +12 -0
- package/dist/primitives/hooks/index.js +26 -0
- package/dist/primitives/hooks/use-anonymous-session.cjs +1 -0
- package/dist/primitives/hooks/use-anonymous-session.d.ts +9 -0
- package/dist/primitives/hooks/use-anonymous-session.js +45 -0
- package/dist/primitives/hooks/use-boolean.cjs +1 -0
- package/dist/primitives/hooks/use-boolean.d.ts +10 -0
- package/dist/primitives/hooks/use-boolean.js +17 -0
- package/dist/primitives/hooks/use-component-classnames.cjs +1 -0
- package/dist/primitives/hooks/use-component-classnames.d.ts +6 -0
- package/dist/primitives/hooks/use-component-classnames.js +14 -0
- package/dist/primitives/hooks/use-container-size.cjs +1 -0
- package/dist/primitives/hooks/use-container-size.d.ts +5 -0
- package/dist/primitives/hooks/use-container-size.js +18 -0
- package/dist/primitives/hooks/use-conversation-loader.cjs +1 -0
- package/dist/primitives/hooks/use-conversation-loader.d.ts +12 -0
- package/dist/primitives/hooks/use-conversation-loader.js +41 -0
- package/dist/primitives/hooks/use-copy-to-clipboard.cjs +1 -0
- package/dist/primitives/hooks/use-copy-to-clipboard.d.ts +3 -0
- package/dist/primitives/hooks/use-copy-to-clipboard.js +24 -0
- package/dist/primitives/hooks/use-debounce.cjs +1 -0
- package/dist/primitives/hooks/use-debounce.d.ts +1 -0
- package/dist/primitives/hooks/use-debounce.js +16 -0
- package/dist/primitives/hooks/use-inkeep-open-state.cjs +1 -0
- package/dist/primitives/hooks/use-inkeep-open-state.d.ts +18 -0
- package/dist/primitives/hooks/use-inkeep-open-state.js +47 -0
- package/dist/primitives/hooks/use-instant-update.cjs +1 -0
- package/dist/primitives/hooks/use-instant-update.d.ts +16 -0
- package/dist/primitives/hooks/use-instant-update.js +16 -0
- package/dist/primitives/hooks/use-is-mounted.cjs +1 -0
- package/dist/primitives/hooks/use-is-mounted.d.ts +1 -0
- package/dist/primitives/hooks/use-is-mounted.js +11 -0
- package/dist/primitives/hooks/use-local-storage.cjs +1 -0
- package/dist/primitives/hooks/use-local-storage.d.ts +8 -0
- package/dist/primitives/hooks/use-local-storage.js +26 -0
- package/dist/primitives/hooks/use-media-query.cjs +1 -0
- package/dist/primitives/hooks/use-media-query.d.ts +1 -0
- package/dist/primitives/hooks/use-media-query.js +14 -0
- package/dist/primitives/hooks/use-resize-observer.cjs +1 -0
- package/dist/primitives/hooks/use-resize-observer.d.ts +12 -0
- package/dist/primitives/hooks/use-resize-observer.js +32 -0
- package/dist/primitives/hooks/use-scrolling-fades.cjs +1 -0
- package/dist/primitives/hooks/use-scrolling-fades.d.ts +2 -0
- package/dist/primitives/hooks/use-scrolling-fades.js +18 -0
- package/dist/primitives/hooks/use-settle-action.cjs +1 -0
- package/dist/primitives/hooks/use-settle-action.d.ts +3 -0
- package/dist/primitives/hooks/use-settle-action.js +11 -0
- package/dist/primitives/hooks/use-simple-scroll.cjs +1 -0
- package/dist/primitives/hooks/use-simple-scroll.d.ts +16 -0
- package/dist/primitives/hooks/use-simple-scroll.js +51 -0
- package/dist/primitives/hooks/use-streaming-events.cjs +1 -0
- package/dist/primitives/hooks/use-streaming-events.d.ts +8 -0
- package/dist/primitives/hooks/use-streaming-events.js +33 -0
- package/dist/primitives/index.cjs +1 -0
- package/dist/primitives/index.d.ts +13 -0
- package/dist/primitives/index.js +174 -0
- package/dist/primitives/providers/attachment-item-provider.cjs +1 -0
- package/dist/primitives/providers/attachment-item-provider.d.ts +9 -0
- package/dist/primitives/providers/attachment-item-provider.js +13 -0
- package/dist/primitives/providers/attachments-bar-provider.cjs +1 -0
- package/dist/primitives/providers/attachments-bar-provider.d.ts +30 -0
- package/dist/primitives/providers/attachments-bar-provider.js +57 -0
- package/dist/primitives/providers/base-events-provider.cjs +1 -0
- package/dist/primitives/providers/base-events-provider.d.ts +8 -0
- package/dist/primitives/providers/base-events-provider.js +37 -0
- package/dist/primitives/providers/chat-bubble-provider.cjs +1 -0
- package/dist/primitives/providers/chat-bubble-provider.d.ts +22 -0
- package/dist/primitives/providers/chat-bubble-provider.js +19 -0
- package/dist/primitives/providers/chat-form-provider.cjs +1 -0
- package/dist/primitives/providers/chat-form-provider.d.ts +26 -0
- package/dist/primitives/providers/chat-form-provider.js +109 -0
- package/dist/primitives/providers/chat-history-provider.cjs +1 -0
- package/dist/primitives/providers/chat-history-provider.d.ts +30 -0
- package/dist/primitives/providers/chat-history-provider.js +105 -0
- package/dist/primitives/providers/config-provider.cjs +1 -0
- package/dist/primitives/providers/config-provider.d.ts +24 -0
- package/dist/primitives/providers/config-provider.js +37 -0
- package/dist/primitives/providers/feedback-item-provider.cjs +1 -0
- package/dist/primitives/providers/feedback-item-provider.d.ts +10 -0
- package/dist/primitives/providers/feedback-item-provider.js +16 -0
- package/dist/primitives/providers/feedback-provider.cjs +1 -0
- package/dist/primitives/providers/feedback-provider.d.ts +16 -0
- package/dist/primitives/providers/feedback-provider.js +83 -0
- package/dist/primitives/providers/form-field-provider.cjs +1 -0
- package/dist/primitives/providers/form-field-provider.d.ts +15 -0
- package/dist/primitives/providers/form-field-provider.js +17 -0
- package/dist/primitives/providers/help-menu-provider.cjs +1 -0
- package/dist/primitives/providers/help-menu-provider.d.ts +11 -0
- package/dist/primitives/providers/help-menu-provider.js +19 -0
- package/dist/primitives/providers/hover-popover-provider.cjs +1 -0
- package/dist/primitives/providers/hover-popover-provider.d.ts +10 -0
- package/dist/primitives/providers/hover-popover-provider.js +13 -0
- package/dist/primitives/providers/index.cjs +1 -0
- package/dist/primitives/providers/index.d.ts +19 -0
- package/dist/primitives/providers/index.js +65 -0
- package/dist/primitives/providers/markdown-provider.cjs +1 -0
- package/dist/primitives/providers/markdown-provider.d.ts +9 -0
- package/dist/primitives/providers/markdown-provider.js +8 -0
- package/dist/primitives/providers/message-attachments-provider.cjs +1 -0
- package/dist/primitives/providers/message-attachments-provider.d.ts +13 -0
- package/dist/primitives/providers/message-attachments-provider.js +27 -0
- package/dist/primitives/providers/message-provider.cjs +1 -0
- package/dist/primitives/providers/message-provider.d.ts +10 -0
- package/dist/primitives/providers/message-provider.js +14 -0
- package/dist/primitives/providers/root-provider.cjs +1 -0
- package/dist/primitives/providers/root-provider.d.ts +8 -0
- package/dist/primitives/providers/root-provider.js +21 -0
- package/dist/primitives/providers/search-events-provider.cjs +1 -0
- package/dist/primitives/providers/search-events-provider.d.ts +8 -0
- package/dist/primitives/providers/search-events-provider.js +17 -0
- package/dist/primitives/providers/sidebar-chat-provider.cjs +1 -0
- package/dist/primitives/providers/sidebar-chat-provider.d.ts +61 -0
- package/dist/primitives/providers/sidebar-chat-provider.js +37 -0
- package/dist/primitives/providers/source-item-provider.cjs +1 -0
- package/dist/primitives/providers/source-item-provider.d.ts +12 -0
- package/dist/primitives/providers/source-item-provider.js +13 -0
- package/dist/primitives/providers/theme-provider.cjs +3 -0
- package/dist/primitives/providers/theme-provider.d.ts +3 -0
- package/dist/primitives/providers/theme-provider.js +79 -0
- package/dist/primitives/providers/widget-provider.cjs +1 -0
- package/dist/primitives/providers/widget-provider.d.ts +10 -0
- package/dist/primitives/providers/widget-provider.js +8 -0
- package/dist/primitives/utils/component-ids.cjs +1 -0
- package/dist/primitives/utils/component-ids.d.ts +662 -0
- package/dist/primitives/utils/component-ids.js +361 -0
- package/dist/primitives/utils/compose-event-handlers.cjs +1 -0
- package/dist/primitives/utils/compose-event-handlers.d.ts +3 -0
- package/dist/primitives/utils/compose-event-handlers.js +10 -0
- package/dist/primitives/utils/compose-refs.cjs +1 -0
- package/dist/primitives/utils/compose-refs.d.ts +5 -0
- package/dist/primitives/utils/compose-refs.js +30 -0
- package/dist/primitives/utils/default-settings.cjs +1 -0
- package/dist/primitives/utils/default-settings.d.ts +169 -0
- package/dist/primitives/utils/default-settings.js +52 -0
- package/dist/primitives/utils/form.cjs +1 -0
- package/dist/primitives/utils/form.d.ts +3 -0
- package/dist/primitives/utils/form.js +19 -0
- package/dist/primitives/utils/generate-uid.cjs +1 -0
- package/dist/primitives/utils/generate-uid.d.ts +2 -0
- package/dist/primitives/utils/generate-uid.js +14 -0
- package/dist/primitives/utils/get-message-metadata.d.ts +8 -0
- package/dist/primitives/utils/get-source-icon.cjs +1 -0
- package/dist/primitives/utils/get-source-icon.d.ts +2 -0
- package/dist/primitives/utils/get-source-icon.js +11 -0
- package/dist/primitives/utils/highlight-emphasis.cjs +1 -0
- package/dist/primitives/utils/highlight-emphasis.d.ts +4 -0
- package/dist/primitives/utils/highlight-emphasis.js +15 -0
- package/dist/primitives/utils/merge-props.cjs +1 -0
- package/dist/primitives/utils/merge-props.d.ts +7 -0
- package/dist/primitives/utils/merge-props.js +41 -0
- package/dist/primitives/utils/misc.cjs +1 -0
- package/dist/primitives/utils/misc.d.ts +12 -0
- package/dist/primitives/utils/misc.js +31 -0
- package/dist/primitives/utils/split-props.cjs +1 -0
- package/dist/primitives/utils/split-props.d.ts +14 -0
- package/dist/primitives/utils/split-props.js +10 -0
- package/dist/react/chat-button-modal.cjs +1 -0
- package/dist/react/chat-button-modal.d.ts +22 -0
- package/dist/react/chat-button-modal.js +41 -0
- package/dist/react/chat-button.cjs +1 -0
- package/dist/react/chat-button.d.ts +28 -0
- package/dist/react/chat-button.js +73 -0
- package/dist/react/embedded-chat.cjs +1 -0
- package/dist/react/embedded-chat.d.ts +15 -0
- package/dist/react/embedded-chat.js +428 -0
- package/dist/react/embedded-search-and-chat.cjs +1 -0
- package/dist/react/embedded-search-and-chat.d.ts +40 -0
- package/dist/react/embedded-search-and-chat.impl.cjs +1 -0
- package/dist/react/embedded-search-and-chat.impl.d.ts +9 -0
- package/dist/react/embedded-search-and-chat.impl.js +43 -0
- package/dist/react/embedded-search-and-chat.js +66 -0
- package/dist/react/embedded-search.cjs +1 -0
- package/dist/react/embedded-search.d.ts +17 -0
- package/dist/react/embedded-search.js +181 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +238 -0
- package/dist/react/modal.chat.cjs +1 -0
- package/dist/react/modal.chat.d.ts +9 -0
- package/dist/react/modal.chat.js +21 -0
- package/dist/react/modal.cjs +1 -0
- package/dist/react/modal.d.ts +23 -0
- package/dist/react/modal.js +27 -0
- package/dist/react/modal.search-and-chat.cjs +1 -0
- package/dist/react/modal.search-and-chat.d.ts +6 -0
- package/dist/react/modal.search-and-chat.js +27 -0
- package/dist/react/modal.search.cjs +1 -0
- package/dist/react/modal.search.d.ts +6 -0
- package/dist/react/modal.search.js +21 -0
- package/dist/react/searchbar.cjs +1 -0
- package/dist/react/searchbar.d.ts +13 -0
- package/dist/react/searchbar.js +68 -0
- package/dist/react/sidebar-chat.cjs +1 -0
- package/dist/react/sidebar-chat.d.ts +4 -0
- package/dist/react/sidebar-chat.js +53 -0
- package/dist/react/utils.cjs +1 -0
- package/dist/react/utils.d.ts +6 -0
- package/dist/react/utils.js +20 -0
- package/dist/react/widget-toggle.cjs +1 -0
- package/dist/react/widget-toggle.d.ts +14 -0
- package/dist/react/widget-toggle.js +65 -0
- package/dist/styled/components/chat-bubble.cjs +1 -0
- package/dist/styled/components/chat-bubble.d.ts +5 -0
- package/dist/styled/components/chat-bubble.js +70 -0
- package/dist/styled/components/chat-button.cjs +1 -0
- package/dist/styled/components/chat-button.d.ts +9 -0
- package/dist/styled/components/chat-button.js +60 -0
- package/dist/styled/components/chat-history.cjs +1 -0
- package/dist/styled/components/chat-history.d.ts +15 -0
- package/dist/styled/components/chat-history.js +197 -0
- package/dist/styled/components/data-summary-group.cjs +1 -0
- package/dist/styled/components/data-summary-group.d.ts +11 -0
- package/dist/styled/components/data-summary-group.js +96 -0
- package/dist/styled/components/embedded-chat/session-loading.cjs +1 -0
- package/dist/styled/components/embedded-chat/session-loading.d.ts +1 -0
- package/dist/styled/components/embedded-chat/session-loading.js +26 -0
- package/dist/styled/components/embedded-chat.cjs +1 -0
- package/dist/styled/components/embedded-chat.d.ts +211 -0
- package/dist/styled/components/embedded-chat.js +1997 -0
- package/dist/styled/components/embedded-search/results-loading.cjs +1 -0
- package/dist/styled/components/embedded-search/results-loading.d.ts +1 -0
- package/dist/styled/components/embedded-search/results-loading.js +39 -0
- package/dist/styled/components/embedded-search.cjs +1 -0
- package/dist/styled/components/embedded-search.d.ts +73 -0
- package/dist/styled/components/embedded-search.js +680 -0
- package/dist/styled/components/index.cjs +1 -0
- package/dist/styled/components/index.d.ts +13 -0
- package/dist/styled/components/index.js +28 -0
- package/dist/styled/components/loading-indicator.cjs +1 -0
- package/dist/styled/components/loading-indicator.d.ts +1 -0
- package/dist/styled/components/loading-indicator.js +36 -0
- package/dist/styled/components/message.cjs +1 -0
- package/dist/styled/components/message.d.ts +4 -0
- package/dist/styled/components/message.js +333 -0
- package/dist/styled/components/modal.cjs +1 -0
- package/dist/styled/components/modal.d.ts +6 -0
- package/dist/styled/components/modal.js +46 -0
- package/dist/styled/components/searchbar.cjs +1 -0
- package/dist/styled/components/searchbar.d.ts +11 -0
- package/dist/styled/components/searchbar.js +81 -0
- package/dist/styled/components/shadow.cjs +1 -0
- package/dist/styled/components/shadow.d.ts +3 -0
- package/dist/styled/components/shadow.js +8 -0
- package/dist/styled/components/sidebar-chat.cjs +1 -0
- package/dist/styled/components/sidebar-chat.d.ts +6 -0
- package/dist/styled/components/sidebar-chat.js +90 -0
- package/dist/styled/components/ui/markdown-styles.cjs +1 -0
- package/dist/styled/components/ui/markdown-styles.d.ts +23 -0
- package/dist/styled/components/ui/markdown-styles.js +39 -0
- package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.cjs +1 -0
- package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.d.ts +7 -0
- package/dist/styled/components/ui/recipes/ai-chat-page-wrapper.js +33 -0
- package/dist/styled/components/ui/recipes/attachment.cjs +1 -0
- package/dist/styled/components/ui/recipes/attachment.d.ts +4 -0
- package/dist/styled/components/ui/recipes/attachment.js +28 -0
- package/dist/styled/components/ui/recipes/button.cjs +1 -0
- package/dist/styled/components/ui/recipes/button.d.ts +6 -0
- package/dist/styled/components/ui/recipes/button.js +87 -0
- package/dist/styled/components/ui/recipes/checkbox.cjs +1 -0
- package/dist/styled/components/ui/recipes/checkbox.d.ts +4 -0
- package/dist/styled/components/ui/recipes/checkbox.js +23 -0
- package/dist/styled/components/ui/recipes/citation.cjs +1 -0
- package/dist/styled/components/ui/recipes/citation.d.ts +4 -0
- package/dist/styled/components/ui/recipes/citation.js +75 -0
- package/dist/styled/components/ui/recipes/combobox.cjs +1 -0
- package/dist/styled/components/ui/recipes/combobox.d.ts +4 -0
- package/dist/styled/components/ui/recipes/combobox.js +57 -0
- package/dist/styled/components/ui/recipes/icon.cjs +1 -0
- package/dist/styled/components/ui/recipes/icon.d.ts +2 -0
- package/dist/styled/components/ui/recipes/icon.js +6 -0
- package/dist/styled/components/ui/recipes/index.cjs +1 -0
- package/dist/styled/components/ui/recipes/index.d.ts +16 -0
- package/dist/styled/components/ui/recipes/index.js +39 -0
- package/dist/styled/components/ui/recipes/input.cjs +1 -0
- package/dist/styled/components/ui/recipes/input.d.ts +5 -0
- package/dist/styled/components/ui/recipes/input.js +34 -0
- package/dist/styled/components/ui/recipes/link.cjs +1 -0
- package/dist/styled/components/ui/recipes/link.d.ts +2 -0
- package/dist/styled/components/ui/recipes/link.js +13 -0
- package/dist/styled/components/ui/recipes/markdown.cjs +1 -0
- package/dist/styled/components/ui/recipes/markdown.d.ts +16 -0
- package/dist/styled/components/ui/recipes/markdown.js +103 -0
- package/dist/styled/components/ui/recipes/modal.cjs +1 -0
- package/dist/styled/components/ui/recipes/modal.d.ts +4 -0
- package/dist/styled/components/ui/recipes/modal.js +59 -0
- package/dist/styled/components/ui/recipes/popover.cjs +1 -0
- package/dist/styled/components/ui/recipes/popover.d.ts +4 -0
- package/dist/styled/components/ui/recipes/popover.js +20 -0
- package/dist/styled/components/ui/recipes/scrollable.cjs +1 -0
- package/dist/styled/components/ui/recipes/scrollable.d.ts +4 -0
- package/dist/styled/components/ui/recipes/scrollable.js +15 -0
- package/dist/styled/components/ui/recipes/select.cjs +1 -0
- package/dist/styled/components/ui/recipes/select.d.ts +4 -0
- package/dist/styled/components/ui/recipes/select.js +38 -0
- package/dist/styled/components/ui/recipes/skeleton.cjs +1 -0
- package/dist/styled/components/ui/recipes/skeleton.d.ts +2 -0
- package/dist/styled/components/ui/recipes/skeleton.js +16 -0
- package/dist/styled/components/ui/recipes/widget-toggle.cjs +1 -0
- package/dist/styled/components/ui/recipes/widget-toggle.d.ts +4 -0
- package/dist/styled/components/ui/recipes/widget-toggle.js +35 -0
- package/dist/styled/index.cjs +1 -0
- package/dist/styled/index.d.ts +2 -0
- package/dist/styled/index.js +200 -0
- package/dist/styled/inkeep.css.cjs +4565 -0
- package/dist/styled/inkeep.css.js +4569 -0
- package/dist/styled/utils.cjs +1 -0
- package/dist/styled/utils.d.ts +4 -0
- package/dist/styled/utils.js +11 -0
- package/dist/theme/color-utils.cjs +1 -0
- package/dist/theme/color-utils.d.ts +1 -0
- package/dist/theme/color-utils.js +21 -0
- package/dist/theme/colors.cjs +1 -0
- package/dist/theme/colors.d.ts +104 -0
- package/dist/theme/colors.js +143 -0
- package/dist/theme/index.cjs +1 -0
- package/dist/theme/index.d.ts +125 -0
- package/dist/theme/index.js +58 -0
- package/dist/theme/utils/create-css-variables.cjs +1 -0
- package/dist/theme/utils/create-css-variables.d.ts +2 -0
- package/dist/theme/utils/create-css-variables.js +24 -0
- package/dist/theme/utils/generate-theme-variables.cjs +1 -0
- package/dist/theme/utils/generate-theme-variables.d.ts +3 -0
- package/dist/theme/utils/generate-theme-variables.js +34 -0
- package/dist/types/color-mode.d.ts +44 -0
- package/dist/types/config/ai.d.ts +269 -0
- package/dist/types/config/base.d.ts +358 -0
- package/dist/types/config/components.d.ts +16 -0
- package/dist/types/config/filters.d.ts +17 -0
- package/dist/types/config/index.d.ts +36 -0
- package/dist/types/config/open-settings.d.ts +70 -0
- package/dist/types/config/search.d.ts +95 -0
- package/dist/types/config/settings/actions.d.ts +112 -0
- package/dist/types/config/settings/form.d.ts +83 -0
- package/dist/types/config/settings/jsonschema.d.ts +105 -0
- package/dist/types/config/settings/workflow.d.ts +86 -0
- package/dist/types/events.d.ts +188 -0
- package/dist/types/icons/built-in.d.ts +1 -0
- package/dist/types/icons/custom.d.ts +33 -0
- package/dist/types/icons/index.d.ts +2 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/js/index.d.ts +55 -0
- package/dist/types/message.d.ts +43 -0
- package/dist/types/shadow.d.ts +15 -0
- package/dist/types/sources.d.ts +100 -0
- package/dist/types/theme.d.ts +25 -0
- package/dist/types/widget.d.ts +27 -0
- 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 p=require("altcha-lib"),c=require("react"),x=30*1e3;function m(o){const e=/[?&]expires=(\d+)/.exec(o);return e?Number.parseInt(e[1],10)*1e3:null}const h=async o=>{try{const e=await fetch(o,{method:"GET"});if(!e.ok)throw new Error(`Failed to fetch challenge: ${e.statusText}`);const i=await e.json(),{challenge:r,algorithm:l,salt:t,maxnumber:u}=i,{promise:f}=await p.solveChallenge(r,t,l,u),n=await f||void 0;if(!n)throw new Error("Challenge not solved");return{payload:{number:n.number,...i},expiresAt:m(t)}}catch(e){console.warn("[captcha] Error fetching/solving challenge:",e);return}},w=({fetchUrl:o,shouldBypassCaptcha:e=!1,shouldMakeInitialRequest:i=!0})=>{const r=c.useRef(null),l=c.useRef(null),t=c.useCallback(()=>{const n=h(o);r.current=n,n.then(a=>{a&&(l.current=a.expiresAt)})},[o]),u=c.useCallback(async()=>{if(e)return{};r.current||t();const n=r.current;r.current=null,t();const a=r.current,s=await n;if(!s)return{};if(s.expiresAt!==null&&Date.now()>=s.expiresAt){const g=await a;return g?{"x-inkeep-challenge-solution":btoa(JSON.stringify(g.payload))}:{}}return{"x-inkeep-challenge-solution":btoa(JSON.stringify(s.payload))}},[e,t]),f=c.useCallback(()=>{e||t()},[e,t]);return c.useEffect(()=>{if(!i||e)return;const n=l.current!==null&&Date.now()>=l.current-x;(!r.current||n)&&t()},[i,e,t]),{getCaptchaHeader:u,invalidate:f}};exports.fetchAndSolveChallenge=h;exports.useCaptcha=w;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Payload } from 'altcha-lib/types';
|
|
2
|
+
interface UseCaptchaOptions {
|
|
3
|
+
fetchUrl: 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: ({ fetchUrl, shouldBypassCaptcha, shouldMakeInitialRequest, }: UseCaptchaOptions) => {
|
|
27
|
+
getCaptchaHeader: () => Promise<Record<string, string>>;
|
|
28
|
+
invalidate: () => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { solveChallenge as p } from "altcha-lib";
|
|
3
|
+
import { useRef as m, useCallback as f, useEffect as x } from "react";
|
|
4
|
+
const h = 30 * 1e3;
|
|
5
|
+
function w(o) {
|
|
6
|
+
const e = /[?&]expires=(\d+)/.exec(o);
|
|
7
|
+
return e ? Number.parseInt(e[1], 10) * 1e3 : null;
|
|
8
|
+
}
|
|
9
|
+
const E = async (o) => {
|
|
10
|
+
try {
|
|
11
|
+
const e = await fetch(o, { method: "GET" });
|
|
12
|
+
if (!e.ok)
|
|
13
|
+
throw new Error(`Failed to fetch challenge: ${e.statusText}`);
|
|
14
|
+
const i = await e.json(), { challenge: r, algorithm: c, salt: n, maxnumber: a } = i, { promise: u } = await p(
|
|
15
|
+
r,
|
|
16
|
+
n,
|
|
17
|
+
c,
|
|
18
|
+
a
|
|
19
|
+
), t = await u || void 0;
|
|
20
|
+
if (!t)
|
|
21
|
+
throw new Error("Challenge not solved");
|
|
22
|
+
return {
|
|
23
|
+
payload: { number: t.number, ...i },
|
|
24
|
+
expiresAt: w(n)
|
|
25
|
+
};
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.warn("[captcha] Error fetching/solving challenge:", e);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}, b = ({
|
|
31
|
+
fetchUrl: o,
|
|
32
|
+
shouldBypassCaptcha: e = !1,
|
|
33
|
+
shouldMakeInitialRequest: i = !0
|
|
34
|
+
}) => {
|
|
35
|
+
const r = m(null), c = m(null), n = f(() => {
|
|
36
|
+
const t = E(o);
|
|
37
|
+
r.current = t, t.then((l) => {
|
|
38
|
+
l && (c.current = l.expiresAt);
|
|
39
|
+
});
|
|
40
|
+
}, [o]), a = f(async () => {
|
|
41
|
+
if (e) return {};
|
|
42
|
+
r.current || n();
|
|
43
|
+
const t = r.current;
|
|
44
|
+
r.current = null, n();
|
|
45
|
+
const l = r.current, s = await t;
|
|
46
|
+
if (!s) return {};
|
|
47
|
+
if (s.expiresAt !== null && Date.now() >= s.expiresAt) {
|
|
48
|
+
const g = await l;
|
|
49
|
+
return g ? { "x-inkeep-challenge-solution": btoa(JSON.stringify(g.payload)) } : {};
|
|
50
|
+
}
|
|
51
|
+
return { "x-inkeep-challenge-solution": btoa(JSON.stringify(s.payload)) };
|
|
52
|
+
}, [e, n]), u = f(() => {
|
|
53
|
+
e || n();
|
|
54
|
+
}, [e, n]);
|
|
55
|
+
return x(() => {
|
|
56
|
+
if (!i || e) return;
|
|
57
|
+
const t = c.current !== null && Date.now() >= c.current - h;
|
|
58
|
+
(!r.current || t) && n();
|
|
59
|
+
}, [i, e, n]), { getCaptchaHeader: a, invalidate: u };
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
E as fetchAndSolveChallenge,
|
|
63
|
+
b as useCaptcha
|
|
64
|
+
};
|
|
@@ -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 Re=require("@ai-sdk/react"),Me=require("ai"),s=require("react"),we=require("../modal/modal-provider.cjs"),Ae=require("../../providers/chat-bubble-provider.cjs"),ke=require("../../providers/sidebar-chat-provider.cjs"),xe=require("../../providers/config-provider.cjs"),Pe=require("./use-captcha.cjs"),_e=require("../../hooks/use-media-query.cjs"),Oe=require("../../hooks/use-anonymous-session.cjs"),Fe=require("../../hooks/use-conversation-loader.cjs"),Y=require("../../utils/generate-uid.cjs"),Te=require("../../providers/base-events-provider.cjs"),Be=require("../../providers/chat-form-provider.cjs"),De=require("../../providers/widget-provider.cjs"),Ue=require("@radix-ui/react-use-controllable-state"),He=require("../../hooks/use-streaming-events.cjs"),ee=`Hmm..
|
|
2
|
+
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`,Ne=()=>{const{baseSettings:T,aiChatSettings:m}=xe.useInkeepConfig(),[o="",f]=Ue.useControllableState({prop:m.conversationId,defaultProp:m.conversationId??""}),te=we.useModal(),se=Ae.useOptionalChatBubble(),ne=ke.useOptionalSidebarChat(),{logEvent:l}=Te.useBaseEvents(),{setConversationId:ae,emitToParent:v}=He.useStreamingEvents(),[d,R]=s.useState(""),re=e=>R(e.target.value),{shouldBypassCaptcha:B,filters:D,privacyPreferences:oe}=T,{onInputMessageChange:ie,filters:U,baseUrl:C,agentUrl:ce,context:b,headers:M,appId:p,apiKey:u}=m,ue=te?.isOpen??se?.isOpen??ne?.isOpen??!0,{getCaptchaHeader:y,invalidate:c}=Pe.useCaptcha({fetchUrl:`${C}/run/auth/pow/challenge`,shouldBypassCaptcha:B||!!u,shouldMakeInitialRequest:ue}),H=ce||`${C}/run/api/chat`,N=Oe.useAnonymousSession({baseUrl:C,appId:p,getCaptchaHeader:y,invalidateCaptcha:c,optOutAllAnalytics:oe?.optOutAllAnalytics}),{loadConversation:L}=Fe.useConversationLoader({baseUrl:C,appId:p,authToken:u??N,getCaptchaHeader:y,invalidateCaptcha:c}),[le,$]=s.useState(!1),w=s.useRef(null);w.current=N;const S=s.useRef(0),z=s.useRef(null),W=s.useRef(M);W.current=M;const de=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${T.organizationDisplayName??"Administrator"}`;default:return ee}},[pe,E]=s.useState([]),[he,A]=s.useState(null),K=()=>({"x-inkeep-client-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone,"x-inkeep-client-timestamp":new Date().toISOString()}),ge=s.useMemo(()=>new Me.DefaultChatTransport({api:H,headers:()=>({...p?{"x-inkeep-app-id":p}:{},...w.current?{Authorization:`Bearer ${w.current}`}:{},...u?{Authorization:`Bearer ${u}`}:{},...W.current}),body:{requestContext:b}}),[H,b,p,u]),{messages:h,sendMessage:k,addToolApprovalResponse:me,status:j,setMessages:g,stop:G,error:x}=Re.useChat({transport:ge,onData(e){v(e.type,e.data)},async onFinish(){v("completion",{conversationId:o}),await l({eventName:"assistant_message_received",properties:{conversationId:o}}),l({eventName:"assistant_answer_displayed",properties:{conversationId:o}})},onError(e){if(console.log("onError",e.message),e.code===401&&!(B||u)&&S.current<1){S.current++,c();const n=z.current;if(n){y().then(a=>{g(r=>{let t=[...r];return t.at(-1)?.role==="assistant"&&(t=t.slice(0,-1)),t.at(-1)?.role==="user"&&(t=t.slice(0,-1)),t}),k({text:n.content},{headers:{...K(),...n.nonCaptchaHeaders,...a},body:n.body})});return}}S.current=0,c(),l({eventName:"chat_error",properties:{conversationId:o,error:e.message}}),g(n=>{const a=[...n],r=a[a.length-1];if(r){const t=de(e);r.role==="user"?a.push({id:Y.generateUid(16),role:"assistant",parts:[{type:"text",text:t}]}):r.parts=[{type:"text",text:t}]}return a})}}),Q=j==="submitted",P=j==="streaming",fe=s.useMemo(()=>{const e=r=>{if(!r||typeof r!="object")return!1;const t=r;return typeof t.type=="string"&&t.type.startsWith("tool-")},n=[...h??[]].reverse().find(r=>r.role==="assistant");if(!n)return!1;const a=n.parts?.at(-1);return!(!e(a)||a.state!=="output-available"||!a.approval?.id||P)},[h,P]),J=P||fe,V=Q||J,ve=h.length===0,_=!d.trim()||V,Ce=_e.useMediaQuery("(max-width: 768px)"),[be,I]=s.useState(null);s.useEffect(()=>{x&&I(x)},[x]);const ye=()=>I(null),Z=s.useRef(null);s.useEffect(()=>{ie?.(d)},[d]);const Se=e=>{e.key==="Enter"&&!e.shiftKey&&!_&&!e.nativeEvent.isComposing&&(e.preventDefault(),O())},O=async(e=d)=>{if(_&&(!e||e.trim().length===0))return;E([]),R(""),S.current=0,await l({eventName:"user_message_submitted",properties:{conversationId:o}});const i=await y(),n=D||U?JSON.stringify({...D,...U}):void 0,a={...M};n&&(a["inkeep-filters"]=n);const r={...a,...i};let t=o;t||(t=`conv_${Y.generateUid(16)}`,f(t)),ae(t),z.current={content:e,nonCaptchaHeaders:a,body:{conversationId:t,requestContext:b}},k({text:e},{headers:{...K(),...r},body:{conversationId:t,requestContext:b}})},F=s.useCallback(()=>{G().then(()=>{v("aborted",{conversationId:o})})},[G,o,v]),X=()=>{ye(),g([]),f(""),E([]),A(null),c(),l({eventName:"chat_clear_button_clicked",properties:{conversationId:o}})},q=s.useCallback((e,i)=>{I(null),g(i),f(e),E([]),A(null),c()},[g,f,c]),Ee=s.useCallback(async(e,i)=>{F(),q(e,[]),$(!0);const n=await L(e,i);n!==null&&q(e,n),i?.aborted||$(!1)},[q,L,F]),{openForm:Ie}=Be.useChatForm(),qe=De.useWidget();return s.useImperativeHandle(m.chatFunctionsRef,()=>({submitMessage:O,updateInputMessage(e){R(e)},clearChat:X,openForm:e=>{qe?.setView("chat"),Ie(e,void 0)},focusInput:()=>{Z.current?.focus()}})),{messages:h,sendMessage:k,addToolApprovalResponse:me,isLoading:Q,isStreaming:J,isBusy:V,error:be,setError:I,isSubmitDisabled:_,input:d,handleInputChange:re,handleInputKeyDown:Se,handleSubmit:O,stop:F,clear:X,isEmpty:h.length===0,inputRef:Z,isMobile:Ce,messageAttachments:pe,setMessageAttachments:E,selectedWorkflow:he,setSelectedWorkflow:A,isNewChat:ve,conversationId:o,restoreSession:q,loadAndRestoreSession:Ee,isSessionLoading:le}};exports.DEFAULT_ERROR_MESSAGE=ee;exports.useInkeepChat=Ne;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { KeyboardEvent, Dispatch, SetStateAction, RefObject } from 'react';
|
|
2
|
+
import { Message, MessageAttachment, Workflow } from '../../../types/index.ts';
|
|
3
|
+
import { FileUIPart, ChatRequestOptions, ChatAddToolApproveResponseFunction } 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: ChatAddToolApproveResponseFunction;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
isStreaming: boolean;
|
|
29
|
+
isBusy: boolean;
|
|
30
|
+
error: Error | null;
|
|
31
|
+
setError: Dispatch<SetStateAction<Error | null>>;
|
|
32
|
+
isSubmitDisabled: boolean;
|
|
33
|
+
input: string;
|
|
34
|
+
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
35
|
+
handleInputKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
36
|
+
handleSubmit: (content?: string) => Promise<void>;
|
|
37
|
+
stop: () => void;
|
|
38
|
+
clear: () => void;
|
|
39
|
+
isEmpty: boolean;
|
|
40
|
+
inputRef: RefObject<HTMLTextAreaElement | null>;
|
|
41
|
+
isMobile: boolean;
|
|
42
|
+
messageAttachments: MessageAttachment[];
|
|
43
|
+
setMessageAttachments: Dispatch<SetStateAction<MessageAttachment[]>>;
|
|
44
|
+
selectedWorkflow: Workflow | null;
|
|
45
|
+
setSelectedWorkflow: Dispatch<SetStateAction<Workflow | null>>;
|
|
46
|
+
isNewChat: boolean;
|
|
47
|
+
conversationId: string;
|
|
48
|
+
restoreSession: (sessionId: string, loadedMessages: Message[]) => void;
|
|
49
|
+
loadAndRestoreSession: (sessionId: string, signal?: AbortSignal) => Promise<void>;
|
|
50
|
+
isSessionLoading: boolean;
|
|
51
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useChat as ke } from "@ai-sdk/react";
|
|
3
|
+
import { DefaultChatTransport as Re } from "ai";
|
|
4
|
+
import { useState as f, useRef as h, useMemo as te, useEffect as se, useCallback as H, useImperativeHandle as _e } from "react";
|
|
5
|
+
import { useModal as Oe } from "../modal/modal-provider.js";
|
|
6
|
+
import { useOptionalChatBubble as Fe } from "../../providers/chat-bubble-provider.js";
|
|
7
|
+
import { useOptionalSidebarChat as Te } from "../../providers/sidebar-chat-provider.js";
|
|
8
|
+
import { useInkeepConfig as Be } from "../../providers/config-provider.js";
|
|
9
|
+
import { useCaptcha as De } from "./use-captcha.js";
|
|
10
|
+
import { useMediaQuery as He } from "../../hooks/use-media-query.js";
|
|
11
|
+
import { useAnonymousSession as Ne } from "../../hooks/use-anonymous-session.js";
|
|
12
|
+
import { useConversationLoader as Pe } from "../../hooks/use-conversation-loader.js";
|
|
13
|
+
import { generateUid as ne } from "../../utils/generate-uid.js";
|
|
14
|
+
import { useBaseEvents as Ue } from "../../providers/base-events-provider.js";
|
|
15
|
+
import { useChatForm as $e } from "../../providers/chat-form-provider.js";
|
|
16
|
+
import { useWidget as qe } from "../../providers/widget-provider.js";
|
|
17
|
+
import { useControllableState as Le } from "@radix-ui/react-use-controllable-state";
|
|
18
|
+
import { useStreamingEvents as ze } from "../../hooks/use-streaming-events.js";
|
|
19
|
+
const We = `Hmm..
|
|
20
|
+
|
|
21
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, ct = () => {
|
|
22
|
+
const { baseSettings: N, aiChatSettings: g } = Be(), [r = "", C] = Le({
|
|
23
|
+
prop: g.conversationId,
|
|
24
|
+
defaultProp: g.conversationId ?? ""
|
|
25
|
+
}), oe = Oe(), re = Fe(), ae = Te(), { logEvent: l } = Ue(), { setConversationId: ie, emitToParent: v } = ze(), [u, x] = f(""), ce = (e) => x(e.target.value), { shouldBypassCaptcha: P, filters: U, privacyPreferences: le } = N, {
|
|
26
|
+
onInputMessageChange: ue,
|
|
27
|
+
filters: $,
|
|
28
|
+
baseUrl: y,
|
|
29
|
+
agentUrl: pe,
|
|
30
|
+
context: b,
|
|
31
|
+
headers: A,
|
|
32
|
+
appId: p,
|
|
33
|
+
apiKey: c
|
|
34
|
+
} = g, me = oe?.isOpen ?? re?.isOpen ?? ae?.isOpen ?? !0, { getCaptchaHeader: S, invalidate: i } = De({
|
|
35
|
+
fetchUrl: `${y}/run/auth/pow/challenge`,
|
|
36
|
+
shouldBypassCaptcha: P || !!c,
|
|
37
|
+
shouldMakeInitialRequest: me
|
|
38
|
+
}), q = pe || `${y}/run/api/chat`, L = Ne({
|
|
39
|
+
baseUrl: y,
|
|
40
|
+
appId: p,
|
|
41
|
+
getCaptchaHeader: S,
|
|
42
|
+
invalidateCaptcha: i,
|
|
43
|
+
optOutAllAnalytics: le?.optOutAllAnalytics
|
|
44
|
+
}), { loadConversation: z } = Pe({
|
|
45
|
+
baseUrl: y,
|
|
46
|
+
appId: p,
|
|
47
|
+
authToken: c ?? L,
|
|
48
|
+
getCaptchaHeader: S,
|
|
49
|
+
invalidateCaptcha: i
|
|
50
|
+
}), [de, W] = f(!1), k = h(null);
|
|
51
|
+
k.current = L;
|
|
52
|
+
const I = h(0), K = h(null), j = h(A);
|
|
53
|
+
j.current = A;
|
|
54
|
+
const fe = (e) => {
|
|
55
|
+
switch (e.code) {
|
|
56
|
+
case 400:
|
|
57
|
+
return e.message;
|
|
58
|
+
case 403:
|
|
59
|
+
return `There seems to be a configuration error. Please contact ${N.organizationDisplayName ?? "Administrator"}`;
|
|
60
|
+
default:
|
|
61
|
+
return We;
|
|
62
|
+
}
|
|
63
|
+
}, [he, w] = f([]), [ge, R] = f(null), G = () => ({
|
|
64
|
+
"x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
65
|
+
"x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
66
|
+
}), Ce = te(
|
|
67
|
+
() => new Re({
|
|
68
|
+
api: q,
|
|
69
|
+
headers: () => ({
|
|
70
|
+
...p ? { "x-inkeep-app-id": p } : {},
|
|
71
|
+
...k.current ? { Authorization: `Bearer ${k.current}` } : {},
|
|
72
|
+
...c ? { Authorization: `Bearer ${c}` } : {},
|
|
73
|
+
...j.current
|
|
74
|
+
}),
|
|
75
|
+
body: {
|
|
76
|
+
requestContext: b
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
[q, b, p, c]
|
|
80
|
+
), {
|
|
81
|
+
messages: m,
|
|
82
|
+
sendMessage: _,
|
|
83
|
+
addToolApprovalResponse: ve,
|
|
84
|
+
status: J,
|
|
85
|
+
setMessages: d,
|
|
86
|
+
stop: Q,
|
|
87
|
+
error: O
|
|
88
|
+
} = ke({
|
|
89
|
+
transport: Ce,
|
|
90
|
+
onData(e) {
|
|
91
|
+
v(e.type, e.data);
|
|
92
|
+
},
|
|
93
|
+
async onFinish() {
|
|
94
|
+
v("completion", { conversationId: r }), await l({
|
|
95
|
+
eventName: "assistant_message_received",
|
|
96
|
+
properties: {
|
|
97
|
+
conversationId: r
|
|
98
|
+
}
|
|
99
|
+
}), l({
|
|
100
|
+
eventName: "assistant_answer_displayed",
|
|
101
|
+
properties: {
|
|
102
|
+
conversationId: r
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
onError(e) {
|
|
107
|
+
if (console.log("onError", e.message), e.code === 401 && !(P || c) && I.current < 1) {
|
|
108
|
+
I.current++, i();
|
|
109
|
+
const s = K.current;
|
|
110
|
+
if (s) {
|
|
111
|
+
S().then((n) => {
|
|
112
|
+
d((o) => {
|
|
113
|
+
let t = [...o];
|
|
114
|
+
return t.at(-1)?.role === "assistant" && (t = t.slice(0, -1)), t.at(-1)?.role === "user" && (t = t.slice(0, -1)), t;
|
|
115
|
+
}), _(
|
|
116
|
+
{ text: s.content },
|
|
117
|
+
{
|
|
118
|
+
headers: {
|
|
119
|
+
...G(),
|
|
120
|
+
...s.nonCaptchaHeaders,
|
|
121
|
+
...n
|
|
122
|
+
},
|
|
123
|
+
body: s.body
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
I.current = 0, i(), l({
|
|
131
|
+
eventName: "chat_error",
|
|
132
|
+
properties: {
|
|
133
|
+
conversationId: r,
|
|
134
|
+
error: e.message
|
|
135
|
+
}
|
|
136
|
+
}), d((s) => {
|
|
137
|
+
const n = [...s], o = n[n.length - 1];
|
|
138
|
+
if (o) {
|
|
139
|
+
const t = fe(e);
|
|
140
|
+
o.role === "user" ? n.push({
|
|
141
|
+
id: ne(16),
|
|
142
|
+
role: "assistant",
|
|
143
|
+
parts: [{ type: "text", text: t }]
|
|
144
|
+
}) : o.parts = [{ type: "text", text: t }];
|
|
145
|
+
}
|
|
146
|
+
return n;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}), V = J === "submitted", F = J === "streaming", ye = te(() => {
|
|
150
|
+
const e = (o) => {
|
|
151
|
+
if (!o || typeof o != "object") return !1;
|
|
152
|
+
const t = o;
|
|
153
|
+
return typeof t.type == "string" && t.type.startsWith("tool-");
|
|
154
|
+
}, s = [...m ?? []].reverse().find((o) => o.role === "assistant");
|
|
155
|
+
if (!s) return !1;
|
|
156
|
+
const n = s.parts?.at(-1);
|
|
157
|
+
return !(!e(n) || n.state !== "output-available" || !n.approval?.id || F);
|
|
158
|
+
}, [m, F]), Z = F || ye, X = V || Z, be = m.length === 0, T = !u.trim() || X, Se = He("(max-width: 768px)"), [Ie, E] = f(null);
|
|
159
|
+
se(() => {
|
|
160
|
+
O && E(O);
|
|
161
|
+
}, [O]);
|
|
162
|
+
const we = () => E(null), Y = h(null);
|
|
163
|
+
se(() => {
|
|
164
|
+
ue?.(u);
|
|
165
|
+
}, [u]);
|
|
166
|
+
const Ee = (e) => {
|
|
167
|
+
e.key === "Enter" && !e.shiftKey && !T && !e.nativeEvent.isComposing && (e.preventDefault(), B());
|
|
168
|
+
}, B = async (e = u) => {
|
|
169
|
+
if (T && (!e || e.trim().length === 0)) return;
|
|
170
|
+
w([]), x(""), I.current = 0, await l({
|
|
171
|
+
eventName: "user_message_submitted",
|
|
172
|
+
properties: {
|
|
173
|
+
conversationId: r
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const a = await S(), s = U || $ ? JSON.stringify({
|
|
177
|
+
...U,
|
|
178
|
+
...$
|
|
179
|
+
}) : void 0, n = { ...A };
|
|
180
|
+
s && (n["inkeep-filters"] = s);
|
|
181
|
+
const o = {
|
|
182
|
+
...n,
|
|
183
|
+
...a
|
|
184
|
+
};
|
|
185
|
+
let t = r;
|
|
186
|
+
t || (t = `conv_${ne(16)}`, C(t)), ie(t), K.current = {
|
|
187
|
+
content: e,
|
|
188
|
+
nonCaptchaHeaders: n,
|
|
189
|
+
body: { conversationId: t, requestContext: b }
|
|
190
|
+
}, _(
|
|
191
|
+
{
|
|
192
|
+
text: e
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
headers: {
|
|
196
|
+
...G(),
|
|
197
|
+
...o
|
|
198
|
+
},
|
|
199
|
+
body: {
|
|
200
|
+
conversationId: t,
|
|
201
|
+
requestContext: b
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
}, D = H(() => {
|
|
206
|
+
Q().then(() => {
|
|
207
|
+
v("aborted", { conversationId: r });
|
|
208
|
+
});
|
|
209
|
+
}, [Q, r, v]), ee = () => {
|
|
210
|
+
we(), d([]), C(""), w([]), R(null), i(), l({
|
|
211
|
+
eventName: "chat_clear_button_clicked",
|
|
212
|
+
properties: {
|
|
213
|
+
conversationId: r
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}, M = H(
|
|
217
|
+
(e, a) => {
|
|
218
|
+
E(null), d(a), C(e), w([]), R(null), i();
|
|
219
|
+
},
|
|
220
|
+
[d, C, i]
|
|
221
|
+
), Me = H(
|
|
222
|
+
async (e, a) => {
|
|
223
|
+
D(), M(e, []), W(!0);
|
|
224
|
+
const s = await z(e, a);
|
|
225
|
+
s !== null && M(e, s), a?.aborted || W(!1);
|
|
226
|
+
},
|
|
227
|
+
[M, z, D]
|
|
228
|
+
), { openForm: xe } = $e(), Ae = qe();
|
|
229
|
+
return _e(g.chatFunctionsRef, () => ({
|
|
230
|
+
submitMessage: B,
|
|
231
|
+
updateInputMessage(e) {
|
|
232
|
+
x(e);
|
|
233
|
+
},
|
|
234
|
+
clearChat: ee,
|
|
235
|
+
openForm: (e) => {
|
|
236
|
+
Ae?.setView("chat"), xe(e, void 0);
|
|
237
|
+
},
|
|
238
|
+
focusInput: () => {
|
|
239
|
+
Y.current?.focus();
|
|
240
|
+
}
|
|
241
|
+
})), {
|
|
242
|
+
messages: m,
|
|
243
|
+
sendMessage: _,
|
|
244
|
+
addToolApprovalResponse: ve,
|
|
245
|
+
isLoading: V,
|
|
246
|
+
isStreaming: Z,
|
|
247
|
+
isBusy: X,
|
|
248
|
+
error: Ie,
|
|
249
|
+
setError: E,
|
|
250
|
+
isSubmitDisabled: T,
|
|
251
|
+
input: u,
|
|
252
|
+
handleInputChange: ce,
|
|
253
|
+
handleInputKeyDown: Ee,
|
|
254
|
+
handleSubmit: B,
|
|
255
|
+
stop: D,
|
|
256
|
+
clear: ee,
|
|
257
|
+
isEmpty: m.length === 0,
|
|
258
|
+
inputRef: Y,
|
|
259
|
+
isMobile: Se,
|
|
260
|
+
// Additional state for attachments and workflow
|
|
261
|
+
messageAttachments: he,
|
|
262
|
+
setMessageAttachments: w,
|
|
263
|
+
selectedWorkflow: ge,
|
|
264
|
+
setSelectedWorkflow: R,
|
|
265
|
+
isNewChat: be,
|
|
266
|
+
conversationId: r,
|
|
267
|
+
restoreSession: M,
|
|
268
|
+
loadAndRestoreSession: Me,
|
|
269
|
+
isSessionLoading: de
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
export {
|
|
273
|
+
We as DEFAULT_ERROR_MESSAGE,
|
|
274
|
+
ct as useInkeepChat
|
|
275
|
+
};
|
|
@@ -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 {};
|