@chatsdk-dev/elements 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-CIYPz72L.d.ts → api-BP4g92-0.d.ts} +1 -1
- package/dist/{api-CIYPz72L.d.ts.map → api-BP4g92-0.d.ts.map} +1 -1
- package/dist/approval-BODP4NVA.d.ts +5 -0
- package/dist/approval-BODP4NVA.d.ts.map +1 -0
- package/dist/avatar-CK5WGu6N.d.ts +5 -0
- package/dist/avatar-CK5WGu6N.d.ts.map +1 -0
- package/dist/{callbacks-PIvHXeEI.d.ts → callbacks-CQelTSwD.d.ts} +1 -1
- package/dist/{callbacks-PIvHXeEI.d.ts.map → callbacks-CQelTSwD.d.ts.map} +1 -1
- package/dist/chat-element-BbBl5CDM.d.ts +131 -0
- package/dist/chat-element-BbBl5CDM.d.ts.map +1 -0
- package/dist/chat-error-CST-PRdq.d.ts +15 -0
- package/dist/chat-error-CST-PRdq.d.ts.map +1 -0
- package/dist/{chatsdk-provider-BhlChLFd.d.ts → chatsdk-provider-t1GEgRPY.d.ts} +2 -2
- package/dist/chatsdk-provider-t1GEgRPY.d.ts.map +1 -0
- package/dist/{config-CqihvSgz.d.ts → config-BGIY5Hkg.d.ts} +20 -19
- package/dist/config-BGIY5Hkg.d.ts.map +1 -0
- package/dist/config-Wk7C7AJs.js +95 -0
- package/dist/config-Wk7C7AJs.js.map +1 -0
- package/dist/config-f4Go--5s.d.ts +194 -0
- package/dist/config-f4Go--5s.d.ts.map +1 -0
- package/dist/content-BoiPVwgM.d.ts +10 -0
- package/dist/content-BoiPVwgM.d.ts.map +1 -0
- package/dist/{context-aSaHw-ac.d.ts → context-D4dOffYT.d.ts} +1 -1
- package/dist/context-D4dOffYT.d.ts.map +1 -0
- package/dist/conversation-CtpcctHL.d.ts +8 -0
- package/dist/conversation-CtpcctHL.d.ts.map +1 -0
- package/dist/copy-BPB94kUd.d.ts +5 -0
- package/dist/copy-BPB94kUd.d.ts.map +1 -0
- package/dist/{element-provider-C_nBsftD.d.ts → element-provider-C95jVJV9.d.ts} +4 -5
- package/dist/element-provider-C95jVJV9.d.ts.map +1 -0
- package/dist/features/chat/chat-element.d.ts +2 -2
- package/dist/features/chat/chat-element.js +2 -2
- package/dist/features/chat/conversation/conversation.d.ts +2 -0
- package/dist/features/chat/conversation/conversation.js +73 -0
- package/dist/features/chat/conversation/conversation.js.map +1 -0
- package/dist/features/chat/conversation/message/activity.d.ts +12 -0
- package/dist/features/chat/conversation/message/activity.d.ts.map +1 -0
- package/dist/features/chat/conversation/message/activity.js +48 -0
- package/dist/features/chat/conversation/message/activity.js.map +1 -0
- package/dist/features/chat/conversation/message/approval.d.ts +2 -0
- package/dist/features/chat/conversation/message/approval.js +62 -0
- package/dist/features/chat/conversation/message/approval.js.map +1 -0
- package/dist/features/chat/conversation/message/avatar.d.ts +2 -0
- package/dist/features/chat/conversation/message/avatar.js +18 -0
- package/dist/features/chat/conversation/message/avatar.js.map +1 -0
- package/dist/features/chat/conversation/message/content.d.ts +2 -0
- package/dist/features/chat/conversation/message/content.js +11 -0
- package/dist/features/chat/conversation/message/content.js.map +1 -0
- package/dist/features/chat/conversation/message/copy.d.ts +2 -0
- package/dist/features/chat/conversation/message/copy.js +30 -0
- package/dist/features/chat/conversation/message/copy.js.map +1 -0
- package/dist/features/chat/conversation/message/feedback.d.ts +2 -0
- package/dist/features/chat/conversation/message/feedback.js +36 -0
- package/dist/features/chat/conversation/message/feedback.js.map +1 -0
- package/dist/features/chat/conversation/message/footer.d.ts +2 -0
- package/dist/features/chat/conversation/message/footer.js +20 -0
- package/dist/features/chat/conversation/message/footer.js.map +1 -0
- package/dist/features/chat/conversation/message/frame.d.ts +2 -0
- package/dist/features/chat/conversation/message/frame.js +18 -0
- package/dist/features/chat/conversation/message/frame.js.map +1 -0
- package/dist/features/chat/conversation/message/index.d.ts +2 -0
- package/dist/features/chat/conversation/message/index.js +2 -0
- package/dist/features/chat/conversation/message/index.parts.d.ts +22 -0
- package/dist/features/chat/conversation/message/index.parts.d.ts.map +1 -0
- package/dist/features/chat/conversation/message/index.parts.js +36 -0
- package/dist/features/chat/conversation/message/index.parts.js.map +1 -0
- package/dist/features/chat/conversation/message/message.d.ts +1 -0
- package/dist/features/chat/conversation/message/message.js +1 -0
- package/dist/features/chat/conversation/message/part.d.ts +2 -0
- package/dist/features/chat/conversation/message/part.js +35 -0
- package/dist/features/chat/conversation/message/part.js.map +1 -0
- package/dist/features/chat/conversation/message/provider.d.ts +2 -0
- package/dist/features/chat/conversation/message/provider.js +26 -0
- package/dist/features/chat/conversation/message/provider.js.map +1 -0
- package/dist/features/chat/conversation/message/reasoning.d.ts +2 -0
- package/dist/features/chat/conversation/message/reasoning.js +33 -0
- package/dist/features/chat/conversation/message/reasoning.js.map +1 -0
- package/dist/features/chat/conversation/message/sources.d.ts +2 -0
- package/dist/features/chat/conversation/message/sources.js +20 -0
- package/dist/features/chat/conversation/message/sources.js.map +1 -0
- package/dist/features/chat/conversation/message/text.d.ts +2 -0
- package/dist/features/chat/conversation/message/text.js +29 -0
- package/dist/features/chat/conversation/message/text.js.map +1 -0
- package/dist/features/chat/conversation/message/timestamp.d.ts +2 -0
- package/dist/features/chat/conversation/message/timestamp.js +36 -0
- package/dist/features/chat/conversation/message/timestamp.js.map +1 -0
- package/dist/features/chat/conversation/message/tool.d.ts +2 -0
- package/dist/features/chat/conversation/message/tool.js +56 -0
- package/dist/features/chat/conversation/message/tool.js.map +1 -0
- package/dist/features/chat/error/chat-error.d.ts +2 -0
- package/dist/features/chat/error/chat-error.js +46 -0
- package/dist/features/chat/error/chat-error.js.map +1 -0
- package/dist/features/chat/frame/frame.d.ts +2 -0
- package/dist/features/chat/frame/frame.js +52 -0
- package/dist/features/chat/frame/frame.js.map +1 -0
- package/dist/features/chat/frame/header-menu.d.ts +8 -0
- package/dist/features/chat/frame/header-menu.d.ts.map +1 -0
- package/dist/features/chat/{chat-header/chat-menu.js → frame/header-menu.js} +12 -13
- package/dist/features/chat/frame/header-menu.js.map +1 -0
- package/dist/features/chat/frame/header.d.ts +2 -0
- package/dist/features/chat/frame/header.js +50 -0
- package/dist/features/chat/frame/header.js.map +1 -0
- package/dist/features/chat/history/history-empty.d.ts +8 -0
- package/dist/features/chat/history/history-empty.d.ts.map +1 -0
- package/dist/features/chat/{chat-history/chat-history-empty.js → history/history-empty.js} +9 -8
- package/dist/features/chat/history/history-empty.js.map +1 -0
- package/dist/features/chat/history/history.d.ts +2 -0
- package/dist/features/chat/history/history.js +65 -0
- package/dist/features/chat/history/history.js.map +1 -0
- package/dist/features/chat/history/use-history.d.ts +2 -0
- package/dist/features/chat/history/use-history.js +30 -0
- package/dist/features/chat/history/use-history.js.map +1 -0
- package/dist/features/chat/index.d.ts +2 -2
- package/dist/features/chat/index.js +29 -2
- package/dist/features/chat/index.js.map +1 -0
- package/dist/features/chat/index.parts.d.ts +9 -0
- package/dist/features/chat/index.parts.js +24 -0
- package/dist/features/chat/index.parts.js.map +1 -0
- package/dist/features/chat/main/main.d.ts +2 -0
- package/dist/features/chat/main/main.js +40 -0
- package/dist/features/chat/main/main.js.map +1 -0
- package/dist/features/chat/main/prompt-input.d.ts +2 -0
- package/dist/features/chat/main/prompt-input.js +70 -0
- package/dist/features/chat/main/prompt-input.js.map +1 -0
- package/dist/features/chat/main/use-create-new-chat.d.ts +2 -0
- package/dist/features/chat/main/use-create-new-chat.js +24 -0
- package/dist/features/chat/main/use-create-new-chat.js.map +1 -0
- package/dist/features/chat/main/use-prompt-input.d.ts +2 -0
- package/dist/features/chat/main/use-prompt-input.js +27 -0
- package/dist/features/chat/main/use-prompt-input.js.map +1 -0
- package/dist/features/chat/provider/provider.d.ts +2 -0
- package/dist/features/chat/provider/provider.js +3 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.d.ts +26 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.d.ts.map +1 -0
- package/dist/features/chat/provider/use-ai-sdk-chat.js +3 -0
- package/dist/features/chat/provider/use-create-chat-store.d.ts +2 -0
- package/dist/features/chat/provider/use-create-chat-store.js +42 -0
- package/dist/features/chat/provider/use-create-chat-store.js.map +1 -0
- package/dist/features/chat/provider/use-visible-messages.d.ts +13 -0
- package/dist/features/chat/provider/use-visible-messages.d.ts.map +1 -0
- package/dist/features/chat/provider/use-visible-messages.js +23 -0
- package/dist/features/chat/provider/use-visible-messages.js.map +1 -0
- package/dist/features/chat/queries/query-keys.d.ts +3 -3
- package/dist/features/chat/queries/query-keys.d.ts.map +1 -1
- package/dist/features/chat/queries/query-keys.js +5 -5
- package/dist/features/chat/queries/query-keys.js.map +1 -1
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts +13 -14
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts.map +1 -1
- package/dist/features/chat/queries/use-create-conversation-mutation.js +4 -4
- package/dist/features/chat/queries/use-create-conversation-mutation.js.map +1 -1
- package/dist/features/chat/queries/use-get-agent-query.d.ts +2 -0
- package/dist/features/chat/queries/use-get-agent-query.js +2 -0
- package/dist/features/chat/queries/use-get-conversation-query.d.ts +2 -72
- package/dist/features/chat/queries/use-get-conversation-query.js +1 -1
- package/dist/features/chat/queries/use-list-conversations-query.d.ts +2 -33
- package/dist/features/chat/queries/use-list-conversations-query.js +23 -1
- package/dist/features/chat/queries/use-list-conversations-query.js.map +1 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.d.ts +26 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.d.ts.map +1 -0
- package/dist/features/chat/queries/use-record-feedback-mutation.js +2 -0
- package/dist/features/chat/utils.d.ts +7 -2
- package/dist/features/chat/utils.d.ts.map +1 -1
- package/dist/features/chat/utils.js +12 -1
- package/dist/features/chat/utils.js.map +1 -1
- package/dist/features/data-fetching/use-api-client.d.ts +1 -3
- package/dist/features/data-fetching/use-api-client.d.ts.map +1 -1
- package/dist/features/data-fetching/use-api-client.js +1 -1
- package/dist/features/element/chatsdk-provider.d.ts +1 -1
- package/dist/features/element/chatsdk-provider.js +5 -5
- package/dist/features/element/chatsdk-provider.js.map +1 -1
- package/dist/features/element/element-provider.d.ts +1 -1
- package/dist/features/element/element-provider.js +12 -8
- package/dist/features/element/element-provider.js.map +1 -1
- package/dist/features/element/store.d.ts +1 -1
- package/dist/features/element/store.js.map +1 -1
- package/dist/features/element/types/api.d.ts +1 -1
- package/dist/features/element/types/callbacks.d.ts +1 -1
- package/dist/features/element/types/config.d.ts +1 -1
- package/dist/features/element/types/context.d.ts +1 -1
- package/dist/features/element/types/locale.d.ts +1 -1
- package/dist/features/element/types/theme.d.ts +1 -1
- package/dist/features/element/types/translations.d.ts +1 -1
- package/dist/features/element/use-element-config.d.ts +14 -33
- package/dist/features/element/use-element-config.d.ts.map +1 -1
- package/dist/features/element/use-element-config.js +7 -15
- package/dist/features/element/use-element-config.js.map +1 -1
- package/dist/features/element/use-merge-global-config.d.ts +6 -7
- package/dist/features/element/use-merge-global-config.d.ts.map +1 -1
- package/dist/features/element/use-merge-global-config.js +2 -2
- package/dist/features/element/use-merge-global-config.js.map +1 -1
- package/dist/features/element/utils.d.ts +1 -1
- package/dist/features/element/utils.js.map +1 -1
- package/dist/features/errors/use-app-error-message.d.ts +2 -0
- package/dist/features/errors/use-app-error-message.js +25 -0
- package/dist/features/errors/use-app-error-message.js.map +1 -0
- package/dist/features/logging/logger-provider.d.ts +2 -0
- package/dist/features/logging/logger-provider.js +20 -0
- package/dist/features/logging/logger-provider.js.map +1 -0
- package/dist/feedback-hofC2MHC.d.ts +5 -0
- package/dist/feedback-hofC2MHC.d.ts.map +1 -0
- package/dist/footer-BdcVsDmw.d.ts +11 -0
- package/dist/footer-BdcVsDmw.d.ts.map +1 -0
- package/dist/frame-BCN71hMj.d.ts +17 -0
- package/dist/frame-BCN71hMj.d.ts.map +1 -0
- package/dist/frame-D_ce2ErP.d.ts +10 -0
- package/dist/frame-D_ce2ErP.d.ts.map +1 -0
- package/dist/header-BDGB3zKD.d.ts +8 -0
- package/dist/header-BDGB3zKD.d.ts.map +1 -0
- package/dist/history-DDUj4LMJ.d.ts +8 -0
- package/dist/history-DDUj4LMJ.d.ts.map +1 -0
- package/dist/i18n/config.d.ts +1 -1
- package/dist/i18n/config.js +1 -1
- package/dist/i18n/i18next.d.ts +1 -1377
- package/dist/i18n/i18next.d.ts.map +1 -1
- package/dist/i18n/i18next.js +1 -2
- package/dist/i18n/i18next.js.map +1 -1
- package/dist/i18n/utils.d.ts +1 -1
- package/dist/i18n/utils.d.ts.map +1 -1
- package/dist/i18n/utils.js.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.js +12 -59
- package/dist/index.js.map +1 -1
- package/dist/{locale-W5Kyyi4X.d.ts → locale-v_zPGRhE.d.ts} +2 -2
- package/dist/locale-v_zPGRhE.d.ts.map +1 -0
- package/dist/logger-provider-whBIV3Gt.d.ts +16 -0
- package/dist/logger-provider-whBIV3Gt.d.ts.map +1 -0
- package/dist/main-D8VgMjmL.d.ts +15 -0
- package/dist/main-D8VgMjmL.d.ts.map +1 -0
- package/dist/part-C8ZA6iZn.d.ts +25 -0
- package/dist/part-C8ZA6iZn.d.ts.map +1 -0
- package/dist/prompt-input-bclKhGu3.d.ts +15 -0
- package/dist/prompt-input-bclKhGu3.d.ts.map +1 -0
- package/dist/provider-CkkKc2aq.d.ts +21 -0
- package/dist/provider-CkkKc2aq.d.ts.map +1 -0
- package/dist/provider-Cps0PPXa.js +383 -0
- package/dist/provider-Cps0PPXa.js.map +1 -0
- package/dist/reasoning-BRNu_n6T.d.ts +5 -0
- package/dist/reasoning-BRNu_n6T.d.ts.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/sources-BXoSxNYc.d.ts +5 -0
- package/dist/sources-BXoSxNYc.d.ts.map +1 -0
- package/dist/{store-CGX9oRlE.d.ts → store-CkswgmIQ.d.ts} +8 -10
- package/dist/store-CkswgmIQ.d.ts.map +1 -0
- package/dist/styles.css +1677 -948
- package/dist/text-Cio_Hj_h.d.ts +5 -0
- package/dist/text-Cio_Hj_h.d.ts.map +1 -0
- package/dist/{theme-Cb-RBWbR.d.ts → theme-K7rbPHc1.d.ts} +1 -1
- package/dist/{theme-Cb-RBWbR.d.ts.map → theme-K7rbPHc1.d.ts.map} +1 -1
- package/dist/timestamp-CbU3bLa3.d.ts +5 -0
- package/dist/timestamp-CbU3bLa3.d.ts.map +1 -0
- package/dist/tool-DskTWxZb.d.ts +5 -0
- package/dist/tool-DskTWxZb.d.ts.map +1 -0
- package/dist/use-app-error-message-DAHQ4oR_.d.ts +12 -0
- package/dist/use-app-error-message-DAHQ4oR_.d.ts.map +1 -0
- package/dist/use-create-chat-store-Ccd5tvho.d.ts +26 -0
- package/dist/use-create-chat-store-Ccd5tvho.d.ts.map +1 -0
- package/dist/use-create-new-chat-H4kM3hPt.d.ts +7 -0
- package/dist/use-create-new-chat-H4kM3hPt.d.ts.map +1 -0
- package/dist/use-get-agent-query-hQ4uOjfL.d.ts +10 -0
- package/dist/use-get-agent-query-hQ4uOjfL.d.ts.map +1 -0
- package/dist/use-get-conversation-query-D5bRlewH.d.ts +73 -0
- package/dist/use-get-conversation-query-D5bRlewH.d.ts.map +1 -0
- package/dist/use-history-DH2KkVDP.d.ts +30 -0
- package/dist/use-history-DH2KkVDP.d.ts.map +1 -0
- package/dist/use-list-conversations-query-Ny-nP5cZ.d.ts +29 -0
- package/dist/use-list-conversations-query-Ny-nP5cZ.d.ts.map +1 -0
- package/package.json +27 -24
- package/dist/chat-element-CCsDDFif.js +0 -441
- package/dist/chat-element-CCsDDFif.js.map +0 -1
- package/dist/chat-element-CSpa62Te.d.ts +0 -53
- package/dist/chat-element-CSpa62Te.d.ts.map +0 -1
- package/dist/chatsdk-provider-BhlChLFd.d.ts.map +0 -1
- package/dist/common/utils.d.ts +0 -14
- package/dist/common/utils.d.ts.map +0 -1
- package/dist/common/utils.js +0 -26
- package/dist/common/utils.js.map +0 -1
- package/dist/components/info-card.d.ts +0 -23
- package/dist/components/info-card.d.ts.map +0 -1
- package/dist/components/info-card.js +0 -38
- package/dist/components/info-card.js.map +0 -1
- package/dist/config-BigIL6TQ.js +0 -29
- package/dist/config-BigIL6TQ.js.map +0 -1
- package/dist/config-CqihvSgz.d.ts.map +0 -1
- package/dist/config-D_jVTH_D.d.ts +0 -58
- package/dist/config-D_jVTH_D.d.ts.map +0 -1
- package/dist/context-aSaHw-ac.d.ts.map +0 -1
- package/dist/element-provider-C_nBsftD.d.ts.map +0 -1
- package/dist/features/chat/chat-card.d.ts +0 -7
- package/dist/features/chat/chat-card.d.ts.map +0 -1
- package/dist/features/chat/chat-card.js +0 -2
- package/dist/features/chat/chat-header/chat-header.d.ts +0 -12
- package/dist/features/chat/chat-header/chat-header.d.ts.map +0 -1
- package/dist/features/chat/chat-header/chat-header.js +0 -2
- package/dist/features/chat/chat-header/chat-menu.d.ts +0 -7
- package/dist/features/chat/chat-header/chat-menu.d.ts.map +0 -1
- package/dist/features/chat/chat-header/chat-menu.js.map +0 -1
- package/dist/features/chat/chat-history/chat-history-empty.d.ts +0 -7
- package/dist/features/chat/chat-history/chat-history-empty.d.ts.map +0 -1
- package/dist/features/chat/chat-history/chat-history-empty.js.map +0 -1
- package/dist/features/chat/chat-history/chat-history.d.ts +0 -7
- package/dist/features/chat/chat-history/chat-history.d.ts.map +0 -1
- package/dist/features/chat/chat-history/chat-history.js +0 -2
- package/dist/features/chat/chat-main/chat-main.d.ts +0 -10
- package/dist/features/chat/chat-main/chat-main.d.ts.map +0 -1
- package/dist/features/chat/chat-main/chat-main.js +0 -3
- package/dist/features/chat/chat-main/use-chat.d.ts +0 -23
- package/dist/features/chat/chat-main/use-chat.d.ts.map +0 -1
- package/dist/features/chat/chat-main/use-chat.js +0 -3
- package/dist/features/chat/chat-main/use-initial-messages.d.ts +0 -22
- package/dist/features/chat/chat-main/use-initial-messages.d.ts.map +0 -1
- package/dist/features/chat/chat-main/use-initial-messages.js +0 -2
- package/dist/features/chat/chat-prompt-input.d.ts +0 -24
- package/dist/features/chat/chat-prompt-input.d.ts.map +0 -1
- package/dist/features/chat/chat-prompt-input.js +0 -3
- package/dist/features/chat/chat.context.d.ts +0 -28
- package/dist/features/chat/chat.context.d.ts.map +0 -1
- package/dist/features/chat/chat.context.js +0 -10
- package/dist/features/chat/chat.context.js.map +0 -1
- package/dist/features/chat/queries/use-get-chat-query.d.ts +0 -13
- package/dist/features/chat/queries/use-get-chat-query.d.ts.map +0 -1
- package/dist/features/chat/queries/use-get-chat-query.js +0 -2
- package/dist/features/chat/queries/use-get-conversation-query.d.ts.map +0 -1
- package/dist/features/chat/queries/use-list-conversations-query.d.ts.map +0 -1
- package/dist/features/chat/store.d.ts +0 -15
- package/dist/features/chat/store.d.ts.map +0 -1
- package/dist/features/chat/store.js +0 -15
- package/dist/features/chat/store.js.map +0 -1
- package/dist/features/logger/logger.d.ts +0 -2
- package/dist/features/logger/logger.js +0 -15
- package/dist/features/logger/logger.js.map +0 -1
- package/dist/locale-W5Kyyi4X.d.ts.map +0 -1
- package/dist/logger-BvmhODdq.d.ts +0 -11
- package/dist/logger-BvmhODdq.d.ts.map +0 -1
- package/dist/store-CGX9oRlE.d.ts.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { FolderCode } from "lucide-react";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
1
|
import { useTranslation } from "react-i18next";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { FolderCode } from "lucide-react";
|
|
4
4
|
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@chatsdk-dev/ui/atoms/empty";
|
|
5
|
-
//#region src/features/chat/
|
|
6
|
-
function
|
|
7
|
-
const { t } = useTranslation("
|
|
5
|
+
//#region src/features/chat/history/history-empty.tsx
|
|
6
|
+
function HistoryEmpty() {
|
|
7
|
+
const { t } = useTranslation("chatsdk_elements", { keyPrefix: "history.empty" });
|
|
8
8
|
return /* @__PURE__ */ jsx(Empty, {
|
|
9
|
-
className: "w-full h-full hover:bg-blue
|
|
9
|
+
className: "w-full h-full hover:bg-blue",
|
|
10
10
|
children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
11
11
|
/* @__PURE__ */ jsx(EmptyMedia, {
|
|
12
12
|
className: "size-8",
|
|
@@ -18,7 +18,8 @@ function ChatHistoryEmpty() {
|
|
|
18
18
|
] })
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
HistoryEmpty.displayName = "ChatHistoryEmpty";
|
|
21
22
|
//#endregion
|
|
22
|
-
export {
|
|
23
|
+
export { HistoryEmpty };
|
|
23
24
|
|
|
24
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=history-empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-empty.js","names":[],"sources":["../../../../src/features/chat/history/history-empty.tsx"],"sourcesContent":["import { FolderCode } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n Empty,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from \"@chatsdk-dev/ui/atoms/empty\";\n\nexport function HistoryEmpty() {\n const { t } = useTranslation(\"chatsdk_elements\", {\n keyPrefix: \"history.empty\",\n });\n\n return (\n <Empty className=\"w-full h-full hover:bg-blue\">\n <EmptyHeader>\n <EmptyMedia className=\"size-8\" variant=\"icon\">\n <FolderCode className=\"size-4.5\" />\n </EmptyMedia>\n <EmptyTitle>{t(\"title\")}</EmptyTitle>\n <EmptyDescription>{t(\"description\")}</EmptyDescription>\n </EmptyHeader>\n </Empty>\n );\n}\n\nHistoryEmpty.displayName = \"ChatHistoryEmpty\";\n"],"mappings":";;;;;AAWA,SAAgB,eAAe;CAC7B,MAAM,EAAE,MAAM,eAAe,oBAAoB,EAC/C,WAAW,gBACb,CAAC;CAED,OACE,oBAAC,OAAD;EAAO,WAAU;YACf,qBAAC,aAAD,EAAA,UAAA;GACE,oBAAC,YAAD;IAAY,WAAU;IAAS,SAAQ;cACrC,oBAAC,YAAD,EAAY,WAAU,WAAY,CAAA;GACxB,CAAA;GACZ,oBAAC,YAAD,EAAA,UAAa,EAAE,OAAO,EAAc,CAAA;GACpC,oBAAC,kBAAD,EAAA,UAAmB,EAAE,aAAa,EAAoB,CAAA;EAC3C,EAAA,CAAA;CACR,CAAA;AAEX;AAEA,aAAa,cAAc"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { a as useChatStore } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useHistory } from "./use-history.js";
|
|
3
|
+
import { useCreateNewChat } from "../main/use-create-new-chat.js";
|
|
4
|
+
import { HistoryEmpty } from "./history-empty.js";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Plus } from "lucide-react";
|
|
8
|
+
import { Button } from "@chatsdk-dev/ui/atoms/button";
|
|
9
|
+
import { DotsLoader } from "@chatsdk-dev/ui/atoms/dots-loader";
|
|
10
|
+
import { Text } from "@chatsdk-dev/ui/atoms/typography/text";
|
|
11
|
+
import { renderRelativeTime } from "@chatsdk-dev/ui/lib/utils";
|
|
12
|
+
//#region src/features/chat/history/history.tsx
|
|
13
|
+
function History() {
|
|
14
|
+
const { t, i18n } = useTranslation("chatsdk_elements");
|
|
15
|
+
const tab = useChatStore((s) => s.tab);
|
|
16
|
+
const { onSelectConversation, history, isLoading } = useHistory();
|
|
17
|
+
const { createNewChat } = useCreateNewChat();
|
|
18
|
+
if (tab !== "history") return null;
|
|
19
|
+
if (isLoading) return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "flex-1 flex items-center justify-center",
|
|
21
|
+
children: /* @__PURE__ */ jsx(DotsLoader, {})
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: "flex-1 min-h-0 flex flex-col gap-1 overflow-y-auto p-2",
|
|
25
|
+
children: [history?.length === 0 ? /* @__PURE__ */ jsx(HistoryEmpty, {}) : history?.map((conversation, index) => /* @__PURE__ */ jsxs(Button, {
|
|
26
|
+
variant: "ghost",
|
|
27
|
+
className: "flex flex-col items-start justify-center gap-2 px-3 py-2 h-auto text-left",
|
|
28
|
+
onClick: () => onSelectConversation(conversation._id),
|
|
29
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
30
|
+
className: "self-stretch flex justify-between gap-1",
|
|
31
|
+
children: [/* @__PURE__ */ jsxs(Text, {
|
|
32
|
+
className: "truncate text-sm",
|
|
33
|
+
children: [
|
|
34
|
+
history.length - index,
|
|
35
|
+
":",
|
|
36
|
+
" ",
|
|
37
|
+
conversation.title ?? t("history.unitled-conversation")
|
|
38
|
+
]
|
|
39
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
40
|
+
variant: "tiny",
|
|
41
|
+
color: "muted",
|
|
42
|
+
children: renderRelativeTime({
|
|
43
|
+
date: new Date(conversation._creationTime),
|
|
44
|
+
nowLabel: t("just-now"),
|
|
45
|
+
locale: i18n.language
|
|
46
|
+
})
|
|
47
|
+
})]
|
|
48
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
49
|
+
className: "flex-1 min-w-0 max-w-full truncate",
|
|
50
|
+
variant: "paragraph2",
|
|
51
|
+
color: "muted",
|
|
52
|
+
children: conversation.summary
|
|
53
|
+
})]
|
|
54
|
+
}, conversation._id)), /* @__PURE__ */ jsxs(Button, {
|
|
55
|
+
className: "absolute bottom-6 left-1/2 -translate-x-1/2",
|
|
56
|
+
onClick: createNewChat,
|
|
57
|
+
children: [/* @__PURE__ */ jsx(Plus, { className: "size-4" }), t("history.new-conversation")]
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
History.displayName = "ChatHistory";
|
|
62
|
+
//#endregion
|
|
63
|
+
export { History };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","names":[],"sources":["../../../../src/features/chat/history/history.tsx"],"sourcesContent":["import { Plus } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"@chatsdk-dev/ui/atoms/button\";\nimport { DotsLoader } from \"@chatsdk-dev/ui/atoms/dots-loader\";\nimport { Text } from \"@chatsdk-dev/ui/atoms/typography/text\";\nimport { renderRelativeTime } from \"@chatsdk-dev/ui/lib/utils\";\n\nimport { useCreateNewChat } from \"../main/use-create-new-chat\";\nimport { useChatStore } from \"../provider/provider\";\nimport { HistoryEmpty } from \"./history-empty\";\nimport { useHistory } from \"./use-history\";\n\nexport function History() {\n const { t, i18n } = useTranslation(\"chatsdk_elements\");\n const tab = useChatStore((s) => s.tab);\n const { onSelectConversation, history, isLoading } = useHistory();\n const { createNewChat } = useCreateNewChat();\n\n if (tab !== \"history\") return null;\n\n if (isLoading) {\n return (\n <div className=\"flex-1 flex items-center justify-center\">\n <DotsLoader />\n </div>\n );\n }\n\n return (\n <div className=\"flex-1 min-h-0 flex flex-col gap-1 overflow-y-auto p-2\">\n {history?.length === 0 ? (\n <HistoryEmpty />\n ) : (\n history?.map((conversation, index) => (\n <Button\n key={conversation._id}\n variant=\"ghost\"\n className=\"flex flex-col items-start justify-center gap-2 px-3 py-2 h-auto text-left\"\n onClick={() => onSelectConversation(conversation._id)}\n >\n <div className=\"self-stretch flex justify-between gap-1\">\n <Text className=\"truncate text-sm\">\n {history.length - index}:{\" \"}\n {conversation.title ?? t(\"history.unitled-conversation\")}\n </Text>\n <Text variant=\"tiny\" color=\"muted\">\n {renderRelativeTime({\n date: new Date(conversation._creationTime),\n nowLabel: t(\"just-now\"),\n locale: i18n.language,\n })}\n </Text>\n </div>\n <Text\n className=\"flex-1 min-w-0 max-w-full truncate\"\n variant=\"paragraph2\"\n color=\"muted\"\n >\n {conversation.summary}\n </Text>\n </Button>\n ))\n )}\n <Button\n className=\"absolute bottom-6 left-1/2 -translate-x-1/2\"\n onClick={createNewChat}\n >\n <Plus className=\"size-4\" />\n {t(\"history.new-conversation\")}\n </Button>\n </div>\n );\n}\n\nHistory.displayName = \"ChatHistory\";\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,UAAU;CACxB,MAAM,EAAE,GAAG,SAAS,eAAe,kBAAkB;CACrD,MAAM,MAAM,cAAc,MAAM,EAAE,GAAG;CACrC,MAAM,EAAE,sBAAsB,SAAS,cAAc,WAAW;CAChE,MAAM,EAAE,kBAAkB,iBAAiB;CAE3C,IAAI,QAAQ,WAAW,OAAO;CAE9B,IAAI,WACF,OACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,YAAD,CAAa,CAAA;CACV,CAAA;CAIT,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,SAAS,WAAW,IACnB,oBAAC,cAAD,CAAe,CAAA,IAEf,SAAS,KAAK,cAAc,UAC1B,qBAAC,QAAD;GAEE,SAAQ;GACR,WAAU;GACV,eAAe,qBAAqB,aAAa,GAAG;aAJtD,CAME,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,qBAAC,MAAD;KAAM,WAAU;eAAhB;MACG,QAAQ,SAAS;MAAM;MAAE;MACzB,aAAa,SAAS,EAAE,8BAA8B;KACnD;QACN,oBAAC,MAAD;KAAM,SAAQ;KAAO,OAAM;eACxB,mBAAmB;MAClB,MAAM,IAAI,KAAK,aAAa,aAAa;MACzC,UAAU,EAAE,UAAU;MACtB,QAAQ,KAAK;KACf,CAAC;IACG,CAAA,CACH;OACL,oBAAC,MAAD;IACE,WAAU;IACV,SAAQ;IACR,OAAM;cAEL,aAAa;GACV,CAAA,CACA;KAzBD,aAAa,GAyBZ,CACT,GAEH,qBAAC,QAAD;GACE,WAAU;GACV,SAAS;aAFX,CAIE,oBAAC,MAAD,EAAM,WAAU,SAAU,CAAA,GACzB,EAAE,0BAA0B,CACvB;IACL;;AAET;AAEA,QAAQ,cAAc"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { chatQueryKeys } from "../queries/query-keys.js";
|
|
2
|
+
import { a as useChatStore, c as useElementComponent } from "../../../provider-Cps0PPXa.js";
|
|
3
|
+
import { useListConversationsQuery } from "../queries/use-list-conversations-query.js";
|
|
4
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
//#region src/features/chat/history/use-history.tsx
|
|
6
|
+
function useHistory() {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
const { agentId } = useElementComponent();
|
|
9
|
+
const { data, isLoading } = useListConversationsQuery({ agentId });
|
|
10
|
+
const setSelectedConversationId = useChatStore((s) => s.setSelectedConversationId);
|
|
11
|
+
const setTab = useChatStore((s) => s.setTab);
|
|
12
|
+
const setConversationType = useChatStore((s) => s.setConversationType);
|
|
13
|
+
const onSelectConversation = (conversationId) => {
|
|
14
|
+
queryClient.invalidateQueries({ queryKey: chatQueryKeys.conversation(agentId, conversationId) });
|
|
15
|
+
setSelectedConversationId(conversationId);
|
|
16
|
+
setTab("chat");
|
|
17
|
+
setConversationType("history");
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
agentId,
|
|
21
|
+
history: data,
|
|
22
|
+
isLoading,
|
|
23
|
+
onSelectConversation,
|
|
24
|
+
setSelectedConversationId
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { useHistory };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=use-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-history.js","names":[],"sources":["../../../../src/features/chat/history/use-history.tsx"],"sourcesContent":["import { useQueryClient } from \"@tanstack/react-query\";\nimport { useChatStore, useElementComponent } from \"../provider/provider\";\nimport { chatQueryKeys } from \"../queries/query-keys\";\nimport { useListConversationsQuery } from \"../queries/use-list-conversations-query\";\n\nexport function useHistory() {\n const queryClient = useQueryClient();\n const { agentId } = useElementComponent();\n const { data, isLoading } = useListConversationsQuery({ agentId });\n const setSelectedConversationId = useChatStore(\n (s) => s.setSelectedConversationId,\n );\n const setTab = useChatStore((s) => s.setTab);\n const setConversationType = useChatStore((s) => s.setConversationType);\n\n const onSelectConversation = (conversationId: string) => {\n // invalidate the conversation query to make sure last conversation messages are loaded\n queryClient.invalidateQueries({\n queryKey: chatQueryKeys.conversation(agentId, conversationId),\n });\n setSelectedConversationId(conversationId);\n setTab(\"chat\");\n setConversationType(\"history\");\n };\n\n return {\n agentId,\n\n history: data,\n isLoading,\n\n onSelectConversation,\n setSelectedConversationId,\n };\n}\n"],"mappings":";;;;;AAKA,SAAgB,aAAa;CAC3B,MAAM,cAAc,eAAe;CACnC,MAAM,EAAE,YAAY,oBAAoB;CACxC,MAAM,EAAE,MAAM,cAAc,0BAA0B,EAAE,QAAQ,CAAC;CACjE,MAAM,4BAA4B,cAC/B,MAAM,EAAE,yBACX;CACA,MAAM,SAAS,cAAc,MAAM,EAAE,MAAM;CAC3C,MAAM,sBAAsB,cAAc,MAAM,EAAE,mBAAmB;CAErE,MAAM,wBAAwB,mBAA2B;EAEvD,YAAY,kBAAkB,EAC5B,UAAU,cAAc,aAAa,SAAS,cAAc,EAC9D,CAAC;EACD,0BAA0B,cAAc;EACxC,OAAO,MAAM;EACb,oBAAoB,SAAS;CAC/B;CAEA,OAAO;EACL;EAEA,SAAS;EACT;EAEA;EACA;CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { S as index_parts_d_exports, r as ChatElementProps, t as ChatElement } from "../../chat-element-BbBl5CDM.js";
|
|
2
|
+
export { index_parts_d_exports as Chat, ChatElement, type ChatElementProps };
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { n as Provider } from "../../provider-Cps0PPXa.js";
|
|
2
|
+
import { Frame } from "./frame/frame.js";
|
|
3
|
+
import { Header } from "./frame/header.js";
|
|
4
|
+
import { History } from "./history/history.js";
|
|
5
|
+
import { Main } from "./main/main.js";
|
|
6
|
+
import { PromptInput } from "./main/prompt-input.js";
|
|
7
|
+
import { Conversation } from "./conversation/conversation.js";
|
|
8
|
+
import { Error } from "./error/chat-error.js";
|
|
9
|
+
import { t as index_parts_exports } from "./index.parts.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/features/chat/chat-element.tsx
|
|
12
|
+
function ChatElement(props) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Provider, {
|
|
14
|
+
...props,
|
|
15
|
+
children: /* @__PURE__ */ jsxs(Frame, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
17
|
+
/* @__PURE__ */ jsxs(Main, { children: [
|
|
18
|
+
/* @__PURE__ */ jsx(Conversation, {}),
|
|
19
|
+
/* @__PURE__ */ jsx(Error, {}),
|
|
20
|
+
/* @__PURE__ */ jsx(PromptInput, {})
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ jsx(History, {})
|
|
23
|
+
] })
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { index_parts_exports as Chat, ChatElement };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Chat.Provider","Chat.Frame","Chat.Header","Chat.Main","Chat.Conversation","Chat.Error","Chat.PromptInput","Chat.History"],"sources":["../../../src/features/chat/chat-element.tsx"],"sourcesContent":["import { Chat } from \"./index\";\nimport { ChatElementProps } from \"./provider/provider\";\n\nexport function ChatElement(props: ChatElementProps) {\n return (\n <Chat.Provider {...props}>\n <Chat.Frame>\n <Chat.Header />\n <Chat.Main>\n <Chat.Conversation />\n <Chat.Error />\n <Chat.PromptInput />\n </Chat.Main>\n <Chat.History />\n </Chat.Frame>\n </Chat.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;AAGA,SAAgB,YAAY,OAAyB;CACnD,OACE,oBAACA,UAAD;EAAe,GAAI;YACjB,qBAACC,OAAD,EAAA,UAAA;GACE,oBAACC,QAAD,CAAc,CAAA;GACd,qBAACC,MAAD,EAAA,UAAA;IACE,oBAACC,cAAD,CAAoB,CAAA;IACpB,oBAACC,OAAD,CAAa,CAAA;IACb,oBAACC,aAAD,CAAmB,CAAA;GACV,EAAA,CAAA;GACX,oBAACC,SAAD,CAAe,CAAA;EACL,EAAA,CAAA;CACC,CAAA;AAEnB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { s as Provider } from "../../chat-element-BbBl5CDM.js";
|
|
2
|
+
import { t as Frame } from "../../frame-BCN71hMj.js";
|
|
3
|
+
import { t as Header } from "../../header-BDGB3zKD.js";
|
|
4
|
+
import { t as History } from "../../history-DDUj4LMJ.js";
|
|
5
|
+
import { t as Main } from "../../main-D8VgMjmL.js";
|
|
6
|
+
import { t as PromptInput } from "../../prompt-input-bclKhGu3.js";
|
|
7
|
+
import { t as Conversation } from "../../conversation-CtpcctHL.js";
|
|
8
|
+
import { t as Error } from "../../chat-error-CST-PRdq.js";
|
|
9
|
+
export { Conversation, Error, Frame, Header, History, Main, PromptInput, Provider };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { n as Provider } from "../../provider-Cps0PPXa.js";
|
|
3
|
+
import { Frame } from "./frame/frame.js";
|
|
4
|
+
import { Header } from "./frame/header.js";
|
|
5
|
+
import { History } from "./history/history.js";
|
|
6
|
+
import { Main } from "./main/main.js";
|
|
7
|
+
import { PromptInput } from "./main/prompt-input.js";
|
|
8
|
+
import { Conversation } from "./conversation/conversation.js";
|
|
9
|
+
import { Error } from "./error/chat-error.js";
|
|
10
|
+
//#region src/features/chat/index.parts.ts
|
|
11
|
+
var index_parts_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
Conversation: () => Conversation,
|
|
13
|
+
Error: () => Error,
|
|
14
|
+
Frame: () => Frame,
|
|
15
|
+
Header: () => Header,
|
|
16
|
+
History: () => History,
|
|
17
|
+
Main: () => Main,
|
|
18
|
+
PromptInput: () => PromptInput,
|
|
19
|
+
Provider: () => Provider
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Conversation, Error, Frame, Header, History, Main, PromptInput, Provider, index_parts_exports as t };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.parts.js","names":[],"sources":["../../../src/features/chat/index.parts.ts"],"sourcesContent":["export { Frame } from \"./frame/frame\";\nexport { Header } from \"./frame/header\";\nexport { History } from \"./history/history\";\nexport { Main } from \"./main/main\";\nexport { PromptInput } from \"./main/prompt-input\";\nexport { Provider } from \"./provider/provider\";\nexport { Conversation } from \"./conversation/conversation\";\nexport { Error } from \"./error/chat-error\";\n"],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { a as useChatStore, c as useElementComponent, f as useGetAgentQuery, g as useGetConversationQuery } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { DotsLoader } from "@chatsdk-dev/ui/atoms/dots-loader";
|
|
5
|
+
import { Text } from "@chatsdk-dev/ui/atoms/typography/text";
|
|
6
|
+
//#region src/features/chat/main/main.tsx
|
|
7
|
+
function Main({ children, fallback }) {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const { agentId } = useElementComponent();
|
|
10
|
+
const tab = useChatStore((s) => s.tab);
|
|
11
|
+
const conversationType = useChatStore((s) => s.conversationType);
|
|
12
|
+
const selectedConversationId = useChatStore((s) => s.selectedConversationId);
|
|
13
|
+
const { data: chat } = useGetAgentQuery({ agentId });
|
|
14
|
+
const { isLoading: isConversationLoading } = useGetConversationQuery({
|
|
15
|
+
agentId,
|
|
16
|
+
conversationId: selectedConversationId
|
|
17
|
+
});
|
|
18
|
+
const canCreateMessage = (chat?.agentSettingsCore?.allowedModels?.length ?? 0) > 0;
|
|
19
|
+
if (conversationType === "history" && isConversationLoading) return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "flex-1 flex items-center justify-center z-10 bg-card rounded-lg",
|
|
21
|
+
children: /* @__PURE__ */ jsx(DotsLoader, {})
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx("div", {
|
|
24
|
+
className: tab !== "chat" ? "hidden" : "flex flex-col flex-1 min-h-0",
|
|
25
|
+
children: canCreateMessage ? children : fallback ?? /* @__PURE__ */ jsx("div", {
|
|
26
|
+
className: "m-4 h-full flex items-center justify-center",
|
|
27
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
28
|
+
variant: "paragraph1",
|
|
29
|
+
color: "muted",
|
|
30
|
+
className: "text-center font-light italic",
|
|
31
|
+
children: t("chat-card.insufficient-credits-error")
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
Main.displayName = "ChatMain";
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Main };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":[],"sources":["../../../../src/features/chat/main/main.tsx"],"sourcesContent":["import { useTranslation } from \"react-i18next\";\n\nimport { DotsLoader } from \"@chatsdk-dev/ui/atoms/dots-loader\";\nimport { Text } from \"@chatsdk-dev/ui/atoms/typography/text\";\n\nimport { useElementComponent } from \"../provider/provider\";\nimport { useGetAgentQuery } from \"../queries/use-get-agent-query\";\nimport { useGetConversationQuery } from \"../queries/use-get-conversation-query\";\nimport { useChatStore } from \"../provider/provider\";\n\ninterface MainProps {\n children: React.ReactNode;\n fallback?: React.ReactNode;\n}\n\nexport function Main({ children, fallback }: MainProps) {\n const { t } = useTranslation();\n const { agentId } = useElementComponent();\n const tab = useChatStore((s) => s.tab);\n const conversationType = useChatStore((s) => s.conversationType);\n const selectedConversationId = useChatStore((s) => s.selectedConversationId);\n\n const { data: chat } = useGetAgentQuery({ agentId });\n const { isLoading: isConversationLoading } = useGetConversationQuery({\n agentId,\n conversationId: selectedConversationId,\n });\n\n const canCreateMessage =\n (chat?.agentSettingsCore?.allowedModels?.length ?? 0) > 0;\n\n if (conversationType === \"history\" && isConversationLoading) {\n return (\n <div className=\"flex-1 flex items-center justify-center z-10 bg-card rounded-lg\">\n <DotsLoader />\n </div>\n );\n }\n\n return (\n <div className={tab !== \"chat\" ? \"hidden\" : \"flex flex-col flex-1 min-h-0\"}>\n {canCreateMessage\n ? children\n : (fallback ?? (\n <div className=\"m-4 h-full flex items-center justify-center\">\n <Text\n variant=\"paragraph1\"\n color=\"muted\"\n className=\"text-center font-light italic\"\n >\n {t(\"chat-card.insufficient-credits-error\")}\n </Text>\n </div>\n ))}\n </div>\n );\n}\n\nMain.displayName = \"ChatMain\";\n"],"mappings":";;;;;;AAeA,SAAgB,KAAK,EAAE,UAAU,YAAuB;CACtD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,YAAY,oBAAoB;CACxC,MAAM,MAAM,cAAc,MAAM,EAAE,GAAG;CACrC,MAAM,mBAAmB,cAAc,MAAM,EAAE,gBAAgB;CAC/D,MAAM,yBAAyB,cAAc,MAAM,EAAE,sBAAsB;CAE3E,MAAM,EAAE,MAAM,SAAS,iBAAiB,EAAE,QAAQ,CAAC;CACnD,MAAM,EAAE,WAAW,0BAA0B,wBAAwB;EACnE;EACA,gBAAgB;CAClB,CAAC;CAED,MAAM,oBACH,MAAM,mBAAmB,eAAe,UAAU,KAAK;CAE1D,IAAI,qBAAqB,aAAa,uBACpC,OACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,YAAD,CAAa,CAAA;CACV,CAAA;CAIT,OACE,oBAAC,OAAD;EAAK,WAAW,QAAQ,SAAS,WAAW;YACzC,mBACG,WACC,YACC,oBAAC,OAAD;GAAK,WAAU;aACb,oBAAC,MAAD;IACE,SAAQ;IACR,OAAM;IACN,WAAU;cAET,EAAE,sCAAsC;GACrC,CAAA;EACH,CAAA;CAER,CAAA;AAET;AAEA,KAAK,cAAc"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePromptInput } from "./use-prompt-input.js";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { CheckIcon, GlobeIcon } from "lucide-react";
|
|
7
|
+
import { ModelSelector, ModelSelectorContent, ModelSelectorEmpty, ModelSelectorGroup, ModelSelectorInput, ModelSelectorItem, ModelSelectorList, ModelSelectorLogo, ModelSelectorLogoGroup, ModelSelectorName, ModelSelectorTrigger } from "@chatsdk-dev/ui/molecules/ai/model-selector";
|
|
8
|
+
import { PromptInput as PromptInput$1, PromptInputButton, PromptInputSubmit, PromptInputTextarea, PromptInputTools } from "@chatsdk-dev/ui/molecules/ai/prompt-input";
|
|
9
|
+
//#region src/features/chat/main/prompt-input.tsx
|
|
10
|
+
function PromptInput({ onModelChange }) {
|
|
11
|
+
const { t } = useTranslation("chatsdk_elements");
|
|
12
|
+
const { agent, promptInputRef, status, onStop, onSubmit, defaultModel, allowedModels, modelGroups, hasMultipleModels, hasActions } = usePromptInput();
|
|
13
|
+
const [input, setInput] = useState("");
|
|
14
|
+
const [model, setModel] = useState(defaultModel?.name);
|
|
15
|
+
const [modelSelectorOpen, setModelSelectorOpen] = useState(false);
|
|
16
|
+
const [webSearch, setWebSearch] = useState(false);
|
|
17
|
+
const selectedModel = allowedModels?.find((m) => m.name === model);
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "flex flex-col gap-1 mx-4 mb-3",
|
|
20
|
+
children: [/* @__PURE__ */ jsxs(PromptInput$1, {
|
|
21
|
+
onSubmit: (message, event) => {
|
|
22
|
+
onSubmit(message, event);
|
|
23
|
+
setInput("");
|
|
24
|
+
},
|
|
25
|
+
children: [/* @__PURE__ */ jsx(PromptInputTextarea, {
|
|
26
|
+
ref: promptInputRef,
|
|
27
|
+
placeholder: agent?.agentSettingsSurface?.inputPlaceholder,
|
|
28
|
+
onChange: (e) => setInput(e.target.value),
|
|
29
|
+
value: input
|
|
30
|
+
}), /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
31
|
+
className: "m-1.5 self-end",
|
|
32
|
+
disabled: !input || status !== "ready",
|
|
33
|
+
status,
|
|
34
|
+
onStop
|
|
35
|
+
})]
|
|
36
|
+
}), hasActions && /* @__PURE__ */ jsxs(PromptInputTools, { children: [/* @__PURE__ */ jsxs(PromptInputButton, {
|
|
37
|
+
variant: webSearch ? "primary" : "ghost",
|
|
38
|
+
onClick: () => setWebSearch(!webSearch),
|
|
39
|
+
children: [/* @__PURE__ */ jsx(GlobeIcon, { size: 16 }), /* @__PURE__ */ jsx("span", { children: t("conversation.web-search") })]
|
|
40
|
+
}), hasMultipleModels && /* @__PURE__ */ jsxs(ModelSelector, {
|
|
41
|
+
onOpenChange: setModelSelectorOpen,
|
|
42
|
+
open: modelSelectorOpen,
|
|
43
|
+
children: [/* @__PURE__ */ jsx(ModelSelectorTrigger, { children: /* @__PURE__ */ jsxs(PromptInputButton, { children: [selectedModel?.chefSlug && /* @__PURE__ */ jsx(ModelSelectorLogo, { provider: selectedModel.chefSlug }), /* @__PURE__ */ jsx(ModelSelectorName, { children: selectedModel?.name })] }) }), /* @__PURE__ */ jsxs(ModelSelectorContent, {
|
|
44
|
+
title: t("conversation.model-selector.title"),
|
|
45
|
+
children: [/* @__PURE__ */ jsx(ModelSelectorInput, { placeholder: t("conversation.model-selector.search-placeholder") }), /* @__PURE__ */ jsxs(ModelSelectorList, { children: [/* @__PURE__ */ jsx(ModelSelectorEmpty, { children: t("conversation.model-selector.empty") }), modelGroups?.map((chef) => /* @__PURE__ */ jsx(ModelSelectorGroup, {
|
|
46
|
+
heading: chef,
|
|
47
|
+
children: allowedModels.filter((m) => m.chef === chef).map((m) => /* @__PURE__ */ jsxs(ModelSelectorItem, {
|
|
48
|
+
onSelect: () => {
|
|
49
|
+
setModel(m.name);
|
|
50
|
+
onModelChange?.(m);
|
|
51
|
+
setModelSelectorOpen(false);
|
|
52
|
+
},
|
|
53
|
+
value: m.name,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx(ModelSelectorLogo, { provider: m.chefSlug }),
|
|
56
|
+
/* @__PURE__ */ jsx(ModelSelectorName, { children: m.name }),
|
|
57
|
+
/* @__PURE__ */ jsx(ModelSelectorLogoGroup, { children: /* @__PURE__ */ jsx(ModelSelectorLogo, { provider: m.provider }, m.provider) }),
|
|
58
|
+
selectedModel?.name === m.name ? /* @__PURE__ */ jsx(CheckIcon, { className: "ml-auto size-4" }) : /* @__PURE__ */ jsx("div", { className: "ml-auto size-4" })
|
|
59
|
+
]
|
|
60
|
+
}, m.name))
|
|
61
|
+
}, chef))] })]
|
|
62
|
+
})]
|
|
63
|
+
})] })]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
PromptInput.displayName = "ChatPromptInput";
|
|
67
|
+
//#endregion
|
|
68
|
+
export { PromptInput };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=prompt-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-input.js","names":["PromptInputUI"],"sources":["../../../../src/features/chat/main/prompt-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { CheckIcon, GlobeIcon } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport type { AgentSettingsCore } from \"@chatsdk-dev/api-client\";\nimport {\n ModelSelector,\n ModelSelectorContent,\n ModelSelectorEmpty,\n ModelSelectorGroup,\n ModelSelectorInput,\n ModelSelectorItem,\n ModelSelectorList,\n ModelSelectorLogo,\n ModelSelectorLogoGroup,\n ModelSelectorName,\n ModelSelectorTrigger,\n} from \"@chatsdk-dev/ui/molecules/ai/model-selector\";\nimport {\n PromptInputButton,\n PromptInputSubmit,\n PromptInputTextarea,\n PromptInputTools,\n PromptInput as PromptInputUI,\n} from \"@chatsdk-dev/ui/molecules/ai/prompt-input\";\n\nimport { usePromptInput } from \"./use-prompt-input\";\n\ninterface ChatPromptInputProps {\n onModelChange?: (model: AgentSettingsCore[\"defaultModel\"]) => void;\n}\n\nexport function PromptInput({ onModelChange }: ChatPromptInputProps) {\n const { t } = useTranslation(\"chatsdk_elements\");\n const {\n agent,\n promptInputRef,\n status,\n onStop,\n onSubmit,\n defaultModel,\n allowedModels,\n modelGroups,\n hasMultipleModels,\n hasActions,\n } = usePromptInput();\n\n const [input, setInput] = useState(\"\");\n const [model, setModel] = useState<string | undefined>(defaultModel?.name);\n const [modelSelectorOpen, setModelSelectorOpen] = useState(false);\n const [webSearch, setWebSearch] = useState(false);\n const selectedModel = allowedModels?.find((m) => m.name === model);\n\n return (\n <div className=\"flex flex-col gap-1 mx-4 mb-3\">\n <PromptInputUI\n onSubmit={(message, event) => {\n onSubmit(message, event as React.SubmitEvent<HTMLFormElement>);\n setInput(\"\");\n }}\n >\n <PromptInputTextarea\n ref={promptInputRef}\n placeholder={agent?.agentSettingsSurface?.inputPlaceholder}\n onChange={(e) => setInput(e.target.value)}\n value={input}\n />\n <PromptInputSubmit\n className=\"m-1.5 self-end\"\n disabled={!input || status !== \"ready\"}\n status={status}\n onStop={onStop}\n />\n </PromptInputUI>\n\n {/* Actions row below the border */}\n {hasActions && (\n <PromptInputTools>\n <PromptInputButton\n variant={webSearch ? \"primary\" : \"ghost\"}\n onClick={() => setWebSearch(!webSearch)}\n >\n <GlobeIcon size={16} />\n <span>{t(\"conversation.web-search\")}</span>\n </PromptInputButton>\n {hasMultipleModels && (\n <ModelSelector\n onOpenChange={setModelSelectorOpen}\n open={modelSelectorOpen}\n >\n <ModelSelectorTrigger>\n <PromptInputButton>\n {selectedModel?.chefSlug && (\n <ModelSelectorLogo provider={selectedModel.chefSlug} />\n )}\n <ModelSelectorName>{selectedModel?.name}</ModelSelectorName>\n </PromptInputButton>\n </ModelSelectorTrigger>\n <ModelSelectorContent\n title={t(\"conversation.model-selector.title\")}\n >\n <ModelSelectorInput\n placeholder={t(\n \"conversation.model-selector.search-placeholder\",\n )}\n />\n <ModelSelectorList>\n <ModelSelectorEmpty>\n {t(\"conversation.model-selector.empty\")}\n </ModelSelectorEmpty>\n {modelGroups?.map((chef) => (\n <ModelSelectorGroup key={chef} heading={chef}>\n {allowedModels\n .filter((m) => m.chef === chef)\n .map((m) => (\n <ModelSelectorItem\n key={m.name}\n onSelect={() => {\n setModel(m.name);\n onModelChange?.(m);\n setModelSelectorOpen(false);\n }}\n value={m.name}\n >\n <ModelSelectorLogo provider={m.chefSlug} />\n <ModelSelectorName>{m.name}</ModelSelectorName>\n <ModelSelectorLogoGroup>\n <ModelSelectorLogo\n key={m.provider}\n provider={m.provider}\n />\n </ModelSelectorLogoGroup>\n {selectedModel?.name === m.name ? (\n <CheckIcon className=\"ml-auto size-4\" />\n ) : (\n <div className=\"ml-auto size-4\" />\n )}\n </ModelSelectorItem>\n ))}\n </ModelSelectorGroup>\n ))}\n </ModelSelectorList>\n </ModelSelectorContent>\n </ModelSelector>\n )}\n </PromptInputTools>\n )}\n </div>\n );\n}\n\nPromptInput.displayName = \"ChatPromptInput\";\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,YAAY,EAAE,iBAAuC;CACnE,MAAM,EAAE,MAAM,eAAe,kBAAkB;CAC/C,MAAM,EACJ,OACA,gBACA,QACA,QACA,UACA,cACA,eACA,aACA,mBACA,eACE,eAAe;CAEnB,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,OAAO,YAAY,SAA6B,cAAc,IAAI;CACzE,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,KAAK;CAChE,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,gBAAgB,eAAe,MAAM,MAAM,EAAE,SAAS,KAAK;CAEjE,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAACA,eAAD;GACE,WAAW,SAAS,UAAU;IAC5B,SAAS,SAAS,KAA2C;IAC7D,SAAS,EAAE;GACb;aAJF,CAME,oBAAC,qBAAD;IACE,KAAK;IACL,aAAa,OAAO,sBAAsB;IAC1C,WAAW,MAAM,SAAS,EAAE,OAAO,KAAK;IACxC,OAAO;GACR,CAAA,GACD,oBAAC,mBAAD;IACE,WAAU;IACV,UAAU,CAAC,SAAS,WAAW;IACvB;IACA;GACT,CAAA,CACY;MAGd,cACC,qBAAC,kBAAD,EAAA,UAAA,CACE,qBAAC,mBAAD;GACE,SAAS,YAAY,YAAY;GACjC,eAAe,aAAa,CAAC,SAAS;aAFxC,CAIE,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACtB,oBAAC,QAAD,EAAA,UAAO,EAAE,yBAAyB,EAAQ,CAAA,CACzB;MAClB,qBACC,qBAAC,eAAD;GACE,cAAc;GACd,MAAM;aAFR,CAIE,oBAAC,sBAAD,EAAA,UACE,qBAAC,mBAAD,EAAA,UAAA,CACG,eAAe,YACd,oBAAC,mBAAD,EAAmB,UAAU,cAAc,SAAW,CAAA,GAExD,oBAAC,mBAAD,EAAA,UAAoB,eAAe,KAAwB,CAAA,CAC1C,EAAA,CAAA,EACC,CAAA,GACtB,qBAAC,sBAAD;IACE,OAAO,EAAE,mCAAmC;cAD9C,CAGE,oBAAC,oBAAD,EACE,aAAa,EACX,gDACF,EACD,CAAA,GACD,qBAAC,mBAAD,EAAA,UAAA,CACE,oBAAC,oBAAD,EAAA,UACG,EAAE,mCAAmC,EACpB,CAAA,GACnB,aAAa,KAAK,SACjB,oBAAC,oBAAD;KAA+B,SAAS;eACrC,cACE,QAAQ,MAAM,EAAE,SAAS,IAAI,CAAC,CAC9B,KAAK,MACJ,qBAAC,mBAAD;MAEE,gBAAgB;OACd,SAAS,EAAE,IAAI;OACf,gBAAgB,CAAC;OACjB,qBAAqB,KAAK;MAC5B;MACA,OAAO,EAAE;gBAPX;OASE,oBAAC,mBAAD,EAAmB,UAAU,EAAE,SAAW,CAAA;OAC1C,oBAAC,mBAAD,EAAA,UAAoB,EAAE,KAAwB,CAAA;OAC9C,oBAAC,wBAAD,EAAA,UACE,oBAAC,mBAAD,EAEE,UAAU,EAAE,SACb,GAFM,EAAE,QAER,EACqB,CAAA;OACvB,eAAe,SAAS,EAAE,OACzB,oBAAC,WAAD,EAAW,WAAU,iBAAkB,CAAA,IAEvC,oBAAC,OAAD,EAAK,WAAU,iBAAkB,CAAA;MAElB;QArBZ,EAAE,IAqBU,CACpB;IACe,GA5BK,IA4BL,CACrB,CACgB,EAAA,CAAA,CACC;KACT;IAED,EAAA,CAAA,CAEjB;;AAET;AAEA,YAAY,cAAc"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { a as useChatStore, i as useChat } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
//#region src/features/chat/main/use-create-new-chat.tsx
|
|
4
|
+
function useCreateNewChat() {
|
|
5
|
+
const setTab = useChatStore((s) => s.setTab);
|
|
6
|
+
const setConversationType = useChatStore((s) => s.setConversationType);
|
|
7
|
+
const setSelectedConversationId = useChatStore((s) => s.setSelectedConversationId);
|
|
8
|
+
const { resetChat } = useChat();
|
|
9
|
+
return { createNewChat: useCallback(() => {
|
|
10
|
+
setConversationType("new");
|
|
11
|
+
setSelectedConversationId();
|
|
12
|
+
setTab("chat");
|
|
13
|
+
resetChat();
|
|
14
|
+
}, [
|
|
15
|
+
setConversationType,
|
|
16
|
+
setSelectedConversationId,
|
|
17
|
+
setTab,
|
|
18
|
+
resetChat
|
|
19
|
+
]) };
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useCreateNewChat };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=use-create-new-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-create-new-chat.js","names":[],"sources":["../../../../src/features/chat/main/use-create-new-chat.tsx"],"sourcesContent":["import { useCallback } from \"react\";\n\nimport { useChat, useChatStore } from \"../provider/provider\";\n\nexport function useCreateNewChat() {\n const setTab = useChatStore((s) => s.setTab);\n const setConversationType = useChatStore((s) => s.setConversationType);\n const setSelectedConversationId = useChatStore(\n (s) => s.setSelectedConversationId,\n );\n const { resetChat } = useChat();\n\n const createNewChat = useCallback(() => {\n setConversationType(\"new\");\n setSelectedConversationId();\n setTab(\"chat\");\n resetChat();\n }, [setConversationType, setSelectedConversationId, setTab, resetChat]);\n\n return { createNewChat };\n}\n"],"mappings":";;;AAIA,SAAgB,mBAAmB;CACjC,MAAM,SAAS,cAAc,MAAM,EAAE,MAAM;CAC3C,MAAM,sBAAsB,cAAc,MAAM,EAAE,mBAAmB;CACrE,MAAM,4BAA4B,cAC/B,MAAM,EAAE,yBACX;CACA,MAAM,EAAE,cAAc,QAAQ;CAS9B,OAAO,EAAE,eAPa,kBAAkB;EACtC,oBAAoB,KAAK;EACzB,0BAA0B;EAC1B,OAAO,MAAM;EACb,UAAU;CACZ,GAAG;EAAC;EAAqB;EAA2B;EAAQ;CAAS,CAEhD,EAAE;AACzB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { c as useElementComponent, f as useGetAgentQuery, i as useChat } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
//#region src/features/chat/main/use-prompt-input.tsx
|
|
3
|
+
function usePromptInput() {
|
|
4
|
+
const { agentId } = useElementComponent();
|
|
5
|
+
const { promptInputRef: ref, status, stop: onStop, handleSubmit: onSubmit } = useChat();
|
|
6
|
+
const { data: agent } = useGetAgentQuery({ agentId });
|
|
7
|
+
const defaultModel = agent?.agentSettingsCore?.defaultModel;
|
|
8
|
+
const allowedModels = agent?.agentSettingsCore?.allowedModels;
|
|
9
|
+
const modelGroups = allowedModels?.map((m) => m.chef);
|
|
10
|
+
const hasMultipleModels = allowedModels && allowedModels.length > 1;
|
|
11
|
+
return {
|
|
12
|
+
status,
|
|
13
|
+
agent,
|
|
14
|
+
allowedModels: allowedModels || [],
|
|
15
|
+
defaultModel,
|
|
16
|
+
modelGroups,
|
|
17
|
+
hasMultipleModels,
|
|
18
|
+
hasActions: hasMultipleModels || false,
|
|
19
|
+
promptInputRef: ref,
|
|
20
|
+
onSubmit,
|
|
21
|
+
onStop
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { usePromptInput };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-prompt-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-prompt-input.js","names":[],"sources":["../../../../src/features/chat/main/use-prompt-input.tsx"],"sourcesContent":["import type { ChatStatus } from \"ai\";\n\nimport type { Agent, AgentSettingsCore } from \"@chatsdk-dev/api-client\";\nimport { useChat, useElementComponent } from \"../provider/provider\";\nimport { useGetAgentQuery } from \"../queries/use-get-agent-query\";\n\nexport type UsePromptInputResult = {\n status: ChatStatus;\n agent: Agent | undefined;\n allowedModels: AgentSettingsCore[\"allowedModels\"];\n defaultModel?: AgentSettingsCore[\"defaultModel\"];\n modelGroups?: AgentSettingsCore[\"allowedModels\"][number][\"chef\"][];\n hasMultipleModels: boolean | undefined;\n hasActions: boolean;\n promptInputRef: ReturnType<typeof useChat>[\"promptInputRef\"];\n onSubmit: ReturnType<typeof useChat>[\"handleSubmit\"];\n onStop: ReturnType<typeof useChat>[\"stop\"];\n};\n\nexport function usePromptInput(): UsePromptInputResult {\n const { agentId } = useElementComponent();\n const {\n promptInputRef: ref,\n status,\n stop: onStop,\n handleSubmit: onSubmit,\n } = useChat();\n const { data: agent } = useGetAgentQuery({ agentId });\n const defaultModel = agent?.agentSettingsCore?.defaultModel;\n const allowedModels = agent?.agentSettingsCore?.allowedModels;\n\n const modelGroups = allowedModels?.map((m) => m.chef);\n\n const hasMultipleModels = allowedModels && allowedModels.length > 1;\n const hasActions = hasMultipleModels || false;\n\n return {\n status,\n\n agent,\n allowedModels: allowedModels || [],\n defaultModel,\n modelGroups,\n hasMultipleModels,\n hasActions,\n\n promptInputRef: ref,\n onSubmit,\n onStop,\n };\n}\n"],"mappings":";;AAmBA,SAAgB,iBAAuC;CACrD,MAAM,EAAE,YAAY,oBAAoB;CACxC,MAAM,EACJ,gBAAgB,KAChB,QACA,MAAM,QACN,cAAc,aACZ,QAAQ;CACZ,MAAM,EAAE,MAAM,UAAU,iBAAiB,EAAE,QAAQ,CAAC;CACpD,MAAM,eAAe,OAAO,mBAAmB;CAC/C,MAAM,gBAAgB,OAAO,mBAAmB;CAEhD,MAAM,cAAc,eAAe,KAAK,MAAM,EAAE,IAAI;CAEpD,MAAM,oBAAoB,iBAAiB,cAAc,SAAS;CAGlE,OAAO;EACL;EAEA;EACA,eAAe,iBAAiB,CAAC;EACjC;EACA;EACA;EACA,YAViB,qBAAqB;EAYtC,gBAAgB;EAChB;EACA;CACF;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as ClientToolDefinition, c as defaultChatProps, d as useElement, f as useElementCallbacks, i as ChatProps, l as useChat, m as useElementConfig, n as ChatData, o as ElementProvider, p as useElementComponent, r as ChatElementProps, s as Provider, u as useChatStore } from "../../../chat-element-BbBl5CDM.js";
|
|
2
|
+
export { ChatData, ChatElementProps, ChatProps, ClientToolDefinition, ElementProvider, Provider, defaultChatProps, useChat, useChatStore, useElement, useElementCallbacks, useElementComponent, useElementConfig };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as useChatStore, c as useElementComponent, i as useChat, l as useElementConfig, n as Provider, o as useElement, r as defaultChatProps, s as useElementCallbacks, t as ElementProvider } from "../../../provider-Cps0PPXa.js";
|
|
3
|
+
export { ElementProvider, Provider, defaultChatProps, useChat, useChatStore, useElement, useElementCallbacks, useElementComponent, useElementConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UseChatHelpers } from "@ai-sdk/react";
|
|
2
|
+
import { AppError, ConversationMessage, Session } from "@chatsdk-dev/agent";
|
|
3
|
+
|
|
4
|
+
//#region src/features/chat/provider/use-ai-sdk-chat.d.ts
|
|
5
|
+
interface UseInitialMessagesProps {
|
|
6
|
+
selectedConversationId?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function useInitialMessages({
|
|
9
|
+
selectedConversationId
|
|
10
|
+
}: UseInitialMessagesProps): ConversationMessage[];
|
|
11
|
+
interface UseAiSdkChatProps {
|
|
12
|
+
selectedConversationId?: string;
|
|
13
|
+
conversationType: "new" | "history";
|
|
14
|
+
}
|
|
15
|
+
type UseAiSdkChatResult = UseChatHelpers<ConversationMessage> & {
|
|
16
|
+
resetChat: () => void; /** The bound agent session (the chat instance behind useChat). */
|
|
17
|
+
session: Session; /** Stream error reconstructed as a typed `AppError` (undefined when none). */
|
|
18
|
+
appError?: AppError;
|
|
19
|
+
};
|
|
20
|
+
declare function useAiSdkChat({
|
|
21
|
+
selectedConversationId,
|
|
22
|
+
conversationType
|
|
23
|
+
}: UseAiSdkChatProps): UseAiSdkChatResult;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useAiSdkChat, useInitialMessages };
|
|
26
|
+
//# sourceMappingURL=use-ai-sdk-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-ai-sdk-chat.d.ts","names":[],"sources":["../../../../src/features/chat/provider/use-ai-sdk-chat.tsx"],"mappings":";;;;UAsCU,uBAAA;EACR,sBAAsB;AAAA;AAAA,iBAGR,kBAAA;EACd;AAAA,GACC,uBAAA,GAAuB,mBAAA;AAAA,UAmChB,iBAAA;EACR,sBAAA;EACA,gBAAgB;AAAA;AAAA,KAGb,kBAAA,GAAqB,cAAA,CAAe,mBAAA;EACvC,SAAA,cA1CA;EA4CA,OAAA,EAAS,OAAA,EA3Ce;EA6CxB,QAAA,GAAW,QAAA;AAAA;AAAA,iBAGG,YAAA;EACd,sBAAA;EACA;AAAA,GACC,iBAAA,GAAoB,kBAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
//#region src/features/chat/provider/use-create-chat-store.ts
|
|
5
|
+
const noopStorage = {
|
|
6
|
+
getItem: () => null,
|
|
7
|
+
setItem: () => {},
|
|
8
|
+
removeItem: () => {}
|
|
9
|
+
};
|
|
10
|
+
const DEFAULT_STATE = {
|
|
11
|
+
tab: "chat",
|
|
12
|
+
conversationType: "new",
|
|
13
|
+
selectedConversationId: void 0
|
|
14
|
+
};
|
|
15
|
+
const createChatStore = (agentId, persistConversation) => create()(persist((set) => ({
|
|
16
|
+
...DEFAULT_STATE,
|
|
17
|
+
setTab: (tab) => set({ tab }),
|
|
18
|
+
setSelectedConversationId: (id) => set({ selectedConversationId: id }),
|
|
19
|
+
setConversationType: (type) => set({ conversationType: type }),
|
|
20
|
+
reset: () => set({ ...DEFAULT_STATE })
|
|
21
|
+
}), {
|
|
22
|
+
name: `chatsdk:chat:${agentId}`,
|
|
23
|
+
skipHydration: true,
|
|
24
|
+
storage: createJSONStorage(() => persistConversation && typeof window !== "undefined" ? window.localStorage : noopStorage),
|
|
25
|
+
partialize: (s) => ({ selectedConversationId: s.selectedConversationId }),
|
|
26
|
+
merge: (persisted, current) => {
|
|
27
|
+
const id = persisted?.selectedConversationId;
|
|
28
|
+
return {
|
|
29
|
+
...current,
|
|
30
|
+
selectedConversationId: id,
|
|
31
|
+
conversationType: id ? "history" : current.conversationType
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
function useCreateChatStore(agentId, persistConversation = true) {
|
|
36
|
+
const [store] = useState(() => createChatStore(agentId, persistConversation));
|
|
37
|
+
return store;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useCreateChatStore };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=use-create-chat-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-create-chat-store.js","names":[],"sources":["../../../../src/features/chat/provider/use-create-chat-store.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n createJSONStorage,\n persist,\n type StateStorage,\n} from \"zustand/middleware\";\n\n// No-op storage for SSR / when persistence is disabled (createJSONStorage's\n// getter must return a storage, not undefined).\nconst noopStorage: StateStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n};\n\nconst DEFAULT_STATE = {\n tab: \"chat\",\n conversationType: \"new\",\n selectedConversationId: undefined,\n} as const;\n\nexport interface ChatStore {\n tab: \"chat\" | \"history\";\n selectedConversationId?: string;\n conversationType: \"new\" | \"history\";\n setTab: (tab: \"chat\" | \"history\") => void;\n setSelectedConversationId: (id?: string) => void;\n setConversationType: (type: \"new\" | \"history\") => void;\n reset: () => void;\n}\n\n// Persists the active conversation per chat so a reload reopens it (and resume\n// reconnects). Only `selectedConversationId` is stored; a restored id is treated\n// as an existing conversation. skipHydration + a post-mount rehydrate (in the\n// provider) keeps SSR markup stable.\nconst createChatStore = (agentId: string, persistConversation: boolean) =>\n create<ChatStore>()(\n persist(\n (set) => ({\n ...DEFAULT_STATE,\n setTab: (tab) => set({ tab }),\n setSelectedConversationId: (id) => set({ selectedConversationId: id }),\n setConversationType: (type) => set({ conversationType: type }),\n reset: () => set({ ...DEFAULT_STATE }),\n }),\n {\n name: `chatsdk:chat:${agentId}`,\n skipHydration: true,\n storage: createJSONStorage(() =>\n persistConversation && typeof window !== \"undefined\"\n ? window.localStorage\n : noopStorage,\n ),\n partialize: (s) => ({\n selectedConversationId: s.selectedConversationId,\n }),\n merge: (persisted, current) => {\n const id = (\n persisted as { selectedConversationId?: string } | undefined\n )?.selectedConversationId;\n return {\n ...current,\n selectedConversationId: id,\n conversationType: id ? \"history\" : current.conversationType,\n };\n },\n },\n ),\n );\n\nexport function useCreateChatStore(\n agentId: string,\n persistConversation = true,\n) {\n const [store] = useState(() => createChatStore(agentId, persistConversation));\n return store;\n}\n"],"mappings":";;;;AAUA,MAAM,cAA4B;CAChC,eAAe;CACf,eAAe,CAAC;CAChB,kBAAkB,CAAC;AACrB;AAEA,MAAM,gBAAgB;CACpB,KAAK;CACL,kBAAkB;CAClB,wBAAwB,KAAA;AAC1B;AAgBA,MAAM,mBAAmB,SAAiB,wBACxC,OAAkB,CAAC,CACjB,SACG,SAAS;CACR,GAAG;CACH,SAAS,QAAQ,IAAI,EAAE,IAAI,CAAC;CAC5B,4BAA4B,OAAO,IAAI,EAAE,wBAAwB,GAAG,CAAC;CACrE,sBAAsB,SAAS,IAAI,EAAE,kBAAkB,KAAK,CAAC;CAC7D,aAAa,IAAI,EAAE,GAAG,cAAc,CAAC;AACvC,IACA;CACE,MAAM,gBAAgB;CACtB,eAAe;CACf,SAAS,wBACP,uBAAuB,OAAO,WAAW,cACrC,OAAO,eACP,WACN;CACA,aAAa,OAAO,EAClB,wBAAwB,EAAE,uBAC5B;CACA,QAAQ,WAAW,YAAY;EAC7B,MAAM,KACJ,WACC;EACH,OAAO;GACL,GAAG;GACH,wBAAwB;GACxB,kBAAkB,KAAK,YAAY,QAAQ;EAC7C;CACF;AACF,CACF,CACF;AAEF,SAAgB,mBACd,SACA,sBAAsB,MACtB;CACA,MAAM,CAAC,SAAS,eAAe,gBAAgB,SAAS,mBAAmB,CAAC;CAC5E,OAAO;AACT"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIMessage } from "ai";
|
|
2
|
+
|
|
3
|
+
//#region src/features/chat/provider/use-visible-messages.d.ts
|
|
4
|
+
declare function messageHasVisibleContent(message: UIMessage, opts: {
|
|
5
|
+
withTools?: boolean;
|
|
6
|
+
withReasoning?: boolean;
|
|
7
|
+
}): boolean;
|
|
8
|
+
declare function useVisibleMessages(): {
|
|
9
|
+
visibleMessages: import("@chatsdk-dev/api-client").ConversationMessage[];
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { messageHasVisibleContent, useVisibleMessages };
|
|
13
|
+
//# sourceMappingURL=use-visible-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-visible-messages.d.ts","names":[],"sources":["../../../../src/features/chat/provider/use-visible-messages.ts"],"mappings":";;;iBAMgB,wBAAA,CACd,OAAA,EAAS,SAAS,EAClB,IAAA;EAAQ,SAAA;EAAqB,aAAA;AAAA;AAAA,iBAOf,kBAAA;EAAkB,eAAA,oCAAA,mBAAA;AAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { c as useElementComponent, i as useChat } from "../../../provider-Cps0PPXa.js";
|
|
2
|
+
import { isMessagePartVisible } from "../utils.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
//#region src/features/chat/provider/use-visible-messages.ts
|
|
5
|
+
function messageHasVisibleContent(message, opts) {
|
|
6
|
+
return message.parts.some((part) => isMessagePartVisible(part, opts));
|
|
7
|
+
}
|
|
8
|
+
function useVisibleMessages() {
|
|
9
|
+
const { messages } = useChat();
|
|
10
|
+
const { withTools, withReasoning } = useElementComponent();
|
|
11
|
+
return useMemo(() => ({ visibleMessages: messages.filter((message) => messageHasVisibleContent(message, {
|
|
12
|
+
withTools,
|
|
13
|
+
withReasoning
|
|
14
|
+
})) }), [
|
|
15
|
+
messages,
|
|
16
|
+
withTools,
|
|
17
|
+
withReasoning
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { messageHasVisibleContent, useVisibleMessages };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=use-visible-messages.js.map
|