@btst/stack 1.3.0 → 1.4.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/README.md +85 -37
- package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +4 -4
- package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs +4 -4
- package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs +282 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs +247 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +3 -3
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.mjs +3 -3
- package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.cjs +845 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.mjs +799 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.cjs +7 -7
- package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.mjs +7 -7
- package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.cjs +2 -2
- package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.mjs +2 -2
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.cjs +147 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.mjs +131 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.cjs +244 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.mjs +224 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.cjs +742 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.mjs +719 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.cjs +17 -17
- package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.mjs +17 -17
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +1 -1
- package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.cjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.mjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.mjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.cjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.mjs +2 -2
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.cjs +1 -1
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.mjs +1 -1
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +9 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/sidecar.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.cjs +610 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.mjs +608 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.cjs +221 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.mjs +219 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.cjs +315 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.mjs +313 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.cjs +122 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.mjs +120 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.cjs +397 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs +391 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +227 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +225 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.cjs +31 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.mjs +29 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.cjs +11 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.mjs +8 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +18 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +16 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +39 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +22 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +20 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +37 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +18 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +16 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.cjs +26 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.mjs +24 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +199 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +191 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.cjs +63 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.mjs +61 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.cjs +14 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.mjs +11 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.cjs +241 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.mjs +239 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/db.cjs +65 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/db.mjs +63 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/schemas.cjs +42 -0
- package/dist/packages/better-stack/src/plugins/ai-chat/schemas.mjs +38 -0
- package/dist/packages/better-stack/src/plugins/blog/api/plugin.cjs +8 -2
- package/dist/packages/better-stack/src/plugins/blog/api/plugin.mjs +8 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.cjs +12 -309
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.mjs +13 -303
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/on-this-page.cjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/on-this-page.mjs +1 -1
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -2
- package/dist/packages/better-stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -2
- package/dist/packages/ui/src/components/alert-dialog.cjs +1 -1
- package/dist/packages/ui/src/components/alert-dialog.mjs +1 -1
- package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.cjs → ui/src/components/better-stack-attribution.cjs} +3 -3
- package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.mjs → ui/src/components/better-stack-attribution.mjs} +3 -3
- package/dist/packages/ui/src/components/dialog.cjs +14 -0
- package/dist/packages/ui/src/components/dialog.mjs +14 -1
- package/dist/packages/ui/src/components/dropdown-menu.cjs +67 -0
- package/dist/packages/ui/src/components/dropdown-menu.mjs +62 -0
- package/dist/packages/ui/src/components/markdown-content.cjs +306 -0
- package/dist/packages/ui/src/components/markdown-content.mjs +297 -0
- package/dist/packages/ui/src/components/scroll-area.cjs +63 -0
- package/dist/packages/ui/src/components/scroll-area.mjs +60 -0
- package/dist/packages/ui/src/components/select.cjs +1 -1
- package/dist/packages/ui/src/components/select.mjs +1 -1
- package/dist/packages/ui/src/components/sheet.cjs +87 -0
- package/dist/packages/ui/src/components/sheet.mjs +69 -0
- package/dist/plugins/ai-chat/api/index.cjs +9 -0
- package/dist/plugins/ai-chat/api/index.d.cts +9 -0
- package/dist/plugins/ai-chat/api/index.d.mts +9 -0
- package/dist/plugins/ai-chat/api/index.d.ts +9 -0
- package/dist/plugins/ai-chat/api/index.mjs +2 -0
- package/dist/plugins/ai-chat/client/components/index.cjs +27 -0
- package/dist/plugins/ai-chat/client/components/index.d.cts +30 -0
- package/dist/plugins/ai-chat/client/components/index.d.mts +30 -0
- package/dist/plugins/ai-chat/client/components/index.d.ts +30 -0
- package/dist/plugins/ai-chat/client/components/index.mjs +11 -0
- package/dist/plugins/ai-chat/client/hooks/index.cjs +13 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +98 -0
- package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/index.cjs +19 -0
- package/dist/plugins/ai-chat/client/index.d.cts +327 -0
- package/dist/plugins/ai-chat/client/index.d.mts +327 -0
- package/dist/plugins/ai-chat/client/index.d.ts +327 -0
- package/dist/plugins/ai-chat/client/index.mjs +7 -0
- package/dist/plugins/ai-chat/client.css +6 -0
- package/dist/plugins/ai-chat/query-keys.cjs +60 -0
- package/dist/plugins/ai-chat/query-keys.d.cts +478 -0
- package/dist/plugins/ai-chat/query-keys.d.mts +478 -0
- package/dist/plugins/ai-chat/query-keys.d.ts +478 -0
- package/dist/plugins/ai-chat/query-keys.mjs +58 -0
- package/dist/plugins/ai-chat/style.css +19 -0
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +85 -62
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/shared/stack.Be1QIHEn.d.cts +23 -0
- package/dist/shared/stack.Be1QIHEn.d.mts +23 -0
- package/dist/shared/stack.Be1QIHEn.d.ts +23 -0
- package/dist/shared/stack.DorMi9CZ.d.cts +80 -0
- package/dist/shared/stack.DorMi9CZ.d.mts +80 -0
- package/dist/shared/stack.DorMi9CZ.d.ts +80 -0
- package/package.json +61 -3
- package/src/plugins/ai-chat/api/index.ts +2 -0
- package/src/plugins/ai-chat/api/plugin.ts +1083 -0
- package/src/plugins/ai-chat/client/components/chat-input.tsx +295 -0
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +455 -0
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +160 -0
- package/src/plugins/ai-chat/client/components/chat-message.tsx +505 -0
- package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +296 -0
- package/src/plugins/ai-chat/client/components/index.ts +16 -0
- package/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.tsx +57 -0
- package/src/plugins/ai-chat/client/components/loading/index.tsx +11 -0
- package/src/plugins/ai-chat/client/components/pages/404-page.tsx +27 -0
- package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +31 -0
- package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +46 -0
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +28 -0
- package/src/plugins/ai-chat/client/components/shared/error-placeholder.tsx +22 -0
- package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +349 -0
- package/src/plugins/ai-chat/client/hooks/index.tsx +1 -0
- package/src/plugins/ai-chat/client/index.ts +14 -0
- package/src/plugins/ai-chat/client/localization/index.ts +156 -0
- package/src/plugins/ai-chat/client/overrides.ts +170 -0
- package/src/plugins/ai-chat/client/plugin.tsx +449 -0
- package/src/plugins/ai-chat/client.css +6 -0
- package/src/plugins/ai-chat/db.ts +65 -0
- package/src/plugins/ai-chat/query-keys.ts +87 -0
- package/src/plugins/ai-chat/schemas.ts +40 -0
- package/src/plugins/ai-chat/style.css +19 -0
- package/src/plugins/ai-chat/types.ts +29 -0
- package/src/plugins/blog/api/plugin.ts +10 -4
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +1 -1
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +85 -62
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +19 -427
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +1 -1
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -2
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -2
- package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +0 -9
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +0 -19
- package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.cjs +0 -0
- package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.mjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.cjs +0 -0
- package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.mjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.cjs +0 -0
- package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.mjs +0 -0
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
const client = require('@btst/stack/plugins/client');
|
|
5
|
+
const yar = require('@btst/yar');
|
|
6
|
+
const plugins_aiChat_queryKeys = require('../../../../../../plugins/ai-chat/query-keys.cjs');
|
|
7
|
+
const chatLayout = require('./components/chat-layout.cjs');
|
|
8
|
+
|
|
9
|
+
function createConversationsLoader(config) {
|
|
10
|
+
return async () => {
|
|
11
|
+
if (config.mode === "public") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (typeof window === "undefined") {
|
|
15
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
16
|
+
const context = {
|
|
17
|
+
path: "/chat",
|
|
18
|
+
isSSR: true,
|
|
19
|
+
apiBaseURL,
|
|
20
|
+
apiBasePath,
|
|
21
|
+
headers
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
if (hooks?.beforeLoadConversations) {
|
|
25
|
+
const canLoad = await hooks.beforeLoadConversations(context);
|
|
26
|
+
if (!canLoad) {
|
|
27
|
+
throw new Error("Load prevented by beforeLoadConversations hook");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const client$1 = client.createApiClient({
|
|
31
|
+
baseURL: apiBaseURL,
|
|
32
|
+
basePath: apiBasePath
|
|
33
|
+
});
|
|
34
|
+
const queries = plugins_aiChat_queryKeys.createAiChatQueryKeys(client$1, headers);
|
|
35
|
+
const listQuery = queries.conversations.list();
|
|
36
|
+
await queryClient.prefetchQuery(listQuery);
|
|
37
|
+
if (hooks?.afterLoadConversations) {
|
|
38
|
+
const conversations = queryClient.getQueryData(
|
|
39
|
+
listQuery.queryKey
|
|
40
|
+
) || null;
|
|
41
|
+
const canContinue = await hooks.afterLoadConversations(
|
|
42
|
+
conversations,
|
|
43
|
+
context
|
|
44
|
+
);
|
|
45
|
+
if (canContinue === false) {
|
|
46
|
+
throw new Error("Load prevented by afterLoadConversations hook");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const queryState = queryClient.getQueryState(listQuery.queryKey);
|
|
50
|
+
if (queryState?.error && hooks?.onLoadError) {
|
|
51
|
+
const error = queryState.error instanceof Error ? queryState.error : new Error(String(queryState.error));
|
|
52
|
+
await hooks.onLoadError(error, context);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (hooks?.onLoadError) {
|
|
56
|
+
await hooks.onLoadError(error, context);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createConversationLoader(id, config) {
|
|
63
|
+
return async () => {
|
|
64
|
+
if (typeof window === "undefined") {
|
|
65
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
66
|
+
const context = {
|
|
67
|
+
path: `/chat/${id}`,
|
|
68
|
+
params: { id },
|
|
69
|
+
isSSR: true,
|
|
70
|
+
apiBaseURL,
|
|
71
|
+
apiBasePath,
|
|
72
|
+
headers
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
if (hooks?.beforeLoadConversation) {
|
|
76
|
+
const canLoad = await hooks.beforeLoadConversation(id, context);
|
|
77
|
+
if (!canLoad) {
|
|
78
|
+
throw new Error("Load prevented by beforeLoadConversation hook");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const client$1 = client.createApiClient({
|
|
82
|
+
baseURL: apiBaseURL,
|
|
83
|
+
basePath: apiBasePath
|
|
84
|
+
});
|
|
85
|
+
const queries = plugins_aiChat_queryKeys.createAiChatQueryKeys(client$1, headers);
|
|
86
|
+
const conversationQuery = queries.conversations.detail(id);
|
|
87
|
+
const listQuery = queries.conversations.list();
|
|
88
|
+
await Promise.all([
|
|
89
|
+
queryClient.prefetchQuery(conversationQuery),
|
|
90
|
+
queryClient.prefetchQuery(listQuery)
|
|
91
|
+
]);
|
|
92
|
+
if (hooks?.afterLoadConversation) {
|
|
93
|
+
const conversation = queryClient.getQueryData(conversationQuery.queryKey) || null;
|
|
94
|
+
const canContinue = await hooks.afterLoadConversation(
|
|
95
|
+
conversation,
|
|
96
|
+
id,
|
|
97
|
+
context
|
|
98
|
+
);
|
|
99
|
+
if (canContinue === false) {
|
|
100
|
+
throw new Error("Load prevented by afterLoadConversation hook");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const queryState = queryClient.getQueryState(
|
|
104
|
+
conversationQuery.queryKey
|
|
105
|
+
);
|
|
106
|
+
if (queryState?.error && hooks?.onLoadError) {
|
|
107
|
+
const error = queryState.error instanceof Error ? queryState.error : new Error(String(queryState.error));
|
|
108
|
+
await hooks.onLoadError(error, context);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (hooks?.onLoadError) {
|
|
112
|
+
await hooks.onLoadError(error, context);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function createChatHomeMeta(config) {
|
|
119
|
+
return () => {
|
|
120
|
+
const { siteBaseURL, siteBasePath, seo } = config;
|
|
121
|
+
const fullUrl = `${siteBaseURL}${siteBasePath}/chat`;
|
|
122
|
+
const title = "Chat";
|
|
123
|
+
const description = seo?.description || "Start a conversation with AI";
|
|
124
|
+
return [
|
|
125
|
+
{ title },
|
|
126
|
+
{ name: "title", content: title },
|
|
127
|
+
{ name: "description", content: description },
|
|
128
|
+
{ name: "robots", content: "noindex, nofollow" },
|
|
129
|
+
// Chat pages typically shouldn't be indexed
|
|
130
|
+
// Open Graph
|
|
131
|
+
{ property: "og:type", content: "website" },
|
|
132
|
+
{ property: "og:title", content: title },
|
|
133
|
+
{ property: "og:description", content: description },
|
|
134
|
+
{ property: "og:url", content: fullUrl },
|
|
135
|
+
...seo?.siteName ? [{ property: "og:site_name", content: seo.siteName }] : [],
|
|
136
|
+
...seo?.locale ? [{ property: "og:locale", content: seo.locale }] : [],
|
|
137
|
+
...seo?.defaultImage ? [{ property: "og:image", content: seo.defaultImage }] : [],
|
|
138
|
+
// Twitter
|
|
139
|
+
{ name: "twitter:card", content: "summary" },
|
|
140
|
+
{ name: "twitter:title", content: title },
|
|
141
|
+
{ name: "twitter:description", content: description }
|
|
142
|
+
];
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function createConversationMeta(id, config) {
|
|
146
|
+
return () => {
|
|
147
|
+
const {
|
|
148
|
+
queryClient,
|
|
149
|
+
apiBaseURL,
|
|
150
|
+
apiBasePath,
|
|
151
|
+
siteBaseURL,
|
|
152
|
+
siteBasePath,
|
|
153
|
+
seo
|
|
154
|
+
} = config;
|
|
155
|
+
const queries = plugins_aiChat_queryKeys.createAiChatQueryKeys(
|
|
156
|
+
client.createApiClient({
|
|
157
|
+
baseURL: apiBaseURL,
|
|
158
|
+
basePath: apiBasePath
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
const conversation = queryClient.getQueryData(queries.conversations.detail(id).queryKey);
|
|
162
|
+
const fullUrl = `${siteBaseURL}${siteBasePath}/chat/${id}`;
|
|
163
|
+
const title = conversation?.title || "Chat";
|
|
164
|
+
const description = seo?.description || "AI conversation";
|
|
165
|
+
return [
|
|
166
|
+
{ title },
|
|
167
|
+
{ name: "title", content: title },
|
|
168
|
+
{ name: "description", content: description },
|
|
169
|
+
{ name: "robots", content: "noindex, nofollow" },
|
|
170
|
+
// Open Graph
|
|
171
|
+
{ property: "og:type", content: "website" },
|
|
172
|
+
{ property: "og:title", content: title },
|
|
173
|
+
{ property: "og:description", content: description },
|
|
174
|
+
{ property: "og:url", content: fullUrl },
|
|
175
|
+
...seo?.siteName ? [{ property: "og:site_name", content: seo.siteName }] : [],
|
|
176
|
+
// Twitter
|
|
177
|
+
{ name: "twitter:card", content: "summary" },
|
|
178
|
+
{ name: "twitter:title", content: title }
|
|
179
|
+
];
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const aiChatClientPlugin = (config) => {
|
|
183
|
+
const isPublicMode = config.mode === "public";
|
|
184
|
+
if (isPublicMode) {
|
|
185
|
+
return client.defineClientPlugin({
|
|
186
|
+
name: "ai-chat",
|
|
187
|
+
routes: () => ({
|
|
188
|
+
// Chat home - simple chat interface without history
|
|
189
|
+
chat: yar.createRoute("/chat", () => ({
|
|
190
|
+
PageComponent: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
191
|
+
chatLayout.ChatLayout,
|
|
192
|
+
{
|
|
193
|
+
apiBaseURL: config.apiBaseURL,
|
|
194
|
+
apiBasePath: config.apiBasePath,
|
|
195
|
+
showSidebar: false
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
loader: createConversationsLoader(config),
|
|
199
|
+
meta: createChatHomeMeta(config)
|
|
200
|
+
}))
|
|
201
|
+
}),
|
|
202
|
+
sitemap: async () => []
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return client.defineClientPlugin({
|
|
206
|
+
name: "ai-chat",
|
|
207
|
+
routes: () => ({
|
|
208
|
+
// Chat home - new conversation or list
|
|
209
|
+
chat: yar.createRoute("/chat", () => ({
|
|
210
|
+
PageComponent: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
chatLayout.ChatLayout,
|
|
212
|
+
{
|
|
213
|
+
apiBaseURL: config.apiBaseURL,
|
|
214
|
+
apiBasePath: config.apiBasePath
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
loader: createConversationsLoader(config),
|
|
218
|
+
meta: createChatHomeMeta(config)
|
|
219
|
+
})),
|
|
220
|
+
// Existing conversation
|
|
221
|
+
chatConversation: yar.createRoute("/chat/:id", ({ params }) => ({
|
|
222
|
+
PageComponent: () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
223
|
+
chatLayout.ChatLayout,
|
|
224
|
+
{
|
|
225
|
+
apiBaseURL: config.apiBaseURL,
|
|
226
|
+
apiBasePath: config.apiBasePath,
|
|
227
|
+
conversationId: params.id
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
loader: createConversationLoader(params.id, config),
|
|
231
|
+
meta: createConversationMeta(params.id, config)
|
|
232
|
+
}))
|
|
233
|
+
}),
|
|
234
|
+
// Chat pages typically shouldn't be in sitemap, but we provide the option
|
|
235
|
+
sitemap: async () => {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
exports.aiChatClientPlugin = aiChatClientPlugin;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { defineClientPlugin, createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { createRoute } from '@btst/yar';
|
|
4
|
+
import { createAiChatQueryKeys } from '../../../../../../plugins/ai-chat/query-keys.mjs';
|
|
5
|
+
import { ChatLayout } from './components/chat-layout.mjs';
|
|
6
|
+
|
|
7
|
+
function createConversationsLoader(config) {
|
|
8
|
+
return async () => {
|
|
9
|
+
if (config.mode === "public") {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (typeof window === "undefined") {
|
|
13
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
14
|
+
const context = {
|
|
15
|
+
path: "/chat",
|
|
16
|
+
isSSR: true,
|
|
17
|
+
apiBaseURL,
|
|
18
|
+
apiBasePath,
|
|
19
|
+
headers
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
if (hooks?.beforeLoadConversations) {
|
|
23
|
+
const canLoad = await hooks.beforeLoadConversations(context);
|
|
24
|
+
if (!canLoad) {
|
|
25
|
+
throw new Error("Load prevented by beforeLoadConversations hook");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const client = createApiClient({
|
|
29
|
+
baseURL: apiBaseURL,
|
|
30
|
+
basePath: apiBasePath
|
|
31
|
+
});
|
|
32
|
+
const queries = createAiChatQueryKeys(client, headers);
|
|
33
|
+
const listQuery = queries.conversations.list();
|
|
34
|
+
await queryClient.prefetchQuery(listQuery);
|
|
35
|
+
if (hooks?.afterLoadConversations) {
|
|
36
|
+
const conversations = queryClient.getQueryData(
|
|
37
|
+
listQuery.queryKey
|
|
38
|
+
) || null;
|
|
39
|
+
const canContinue = await hooks.afterLoadConversations(
|
|
40
|
+
conversations,
|
|
41
|
+
context
|
|
42
|
+
);
|
|
43
|
+
if (canContinue === false) {
|
|
44
|
+
throw new Error("Load prevented by afterLoadConversations hook");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const queryState = queryClient.getQueryState(listQuery.queryKey);
|
|
48
|
+
if (queryState?.error && hooks?.onLoadError) {
|
|
49
|
+
const error = queryState.error instanceof Error ? queryState.error : new Error(String(queryState.error));
|
|
50
|
+
await hooks.onLoadError(error, context);
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (hooks?.onLoadError) {
|
|
54
|
+
await hooks.onLoadError(error, context);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createConversationLoader(id, config) {
|
|
61
|
+
return async () => {
|
|
62
|
+
if (typeof window === "undefined") {
|
|
63
|
+
const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
|
|
64
|
+
const context = {
|
|
65
|
+
path: `/chat/${id}`,
|
|
66
|
+
params: { id },
|
|
67
|
+
isSSR: true,
|
|
68
|
+
apiBaseURL,
|
|
69
|
+
apiBasePath,
|
|
70
|
+
headers
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
if (hooks?.beforeLoadConversation) {
|
|
74
|
+
const canLoad = await hooks.beforeLoadConversation(id, context);
|
|
75
|
+
if (!canLoad) {
|
|
76
|
+
throw new Error("Load prevented by beforeLoadConversation hook");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const client = createApiClient({
|
|
80
|
+
baseURL: apiBaseURL,
|
|
81
|
+
basePath: apiBasePath
|
|
82
|
+
});
|
|
83
|
+
const queries = createAiChatQueryKeys(client, headers);
|
|
84
|
+
const conversationQuery = queries.conversations.detail(id);
|
|
85
|
+
const listQuery = queries.conversations.list();
|
|
86
|
+
await Promise.all([
|
|
87
|
+
queryClient.prefetchQuery(conversationQuery),
|
|
88
|
+
queryClient.prefetchQuery(listQuery)
|
|
89
|
+
]);
|
|
90
|
+
if (hooks?.afterLoadConversation) {
|
|
91
|
+
const conversation = queryClient.getQueryData(conversationQuery.queryKey) || null;
|
|
92
|
+
const canContinue = await hooks.afterLoadConversation(
|
|
93
|
+
conversation,
|
|
94
|
+
id,
|
|
95
|
+
context
|
|
96
|
+
);
|
|
97
|
+
if (canContinue === false) {
|
|
98
|
+
throw new Error("Load prevented by afterLoadConversation hook");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const queryState = queryClient.getQueryState(
|
|
102
|
+
conversationQuery.queryKey
|
|
103
|
+
);
|
|
104
|
+
if (queryState?.error && hooks?.onLoadError) {
|
|
105
|
+
const error = queryState.error instanceof Error ? queryState.error : new Error(String(queryState.error));
|
|
106
|
+
await hooks.onLoadError(error, context);
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (hooks?.onLoadError) {
|
|
110
|
+
await hooks.onLoadError(error, context);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function createChatHomeMeta(config) {
|
|
117
|
+
return () => {
|
|
118
|
+
const { siteBaseURL, siteBasePath, seo } = config;
|
|
119
|
+
const fullUrl = `${siteBaseURL}${siteBasePath}/chat`;
|
|
120
|
+
const title = "Chat";
|
|
121
|
+
const description = seo?.description || "Start a conversation with AI";
|
|
122
|
+
return [
|
|
123
|
+
{ title },
|
|
124
|
+
{ name: "title", content: title },
|
|
125
|
+
{ name: "description", content: description },
|
|
126
|
+
{ name: "robots", content: "noindex, nofollow" },
|
|
127
|
+
// Chat pages typically shouldn't be indexed
|
|
128
|
+
// Open Graph
|
|
129
|
+
{ property: "og:type", content: "website" },
|
|
130
|
+
{ property: "og:title", content: title },
|
|
131
|
+
{ property: "og:description", content: description },
|
|
132
|
+
{ property: "og:url", content: fullUrl },
|
|
133
|
+
...seo?.siteName ? [{ property: "og:site_name", content: seo.siteName }] : [],
|
|
134
|
+
...seo?.locale ? [{ property: "og:locale", content: seo.locale }] : [],
|
|
135
|
+
...seo?.defaultImage ? [{ property: "og:image", content: seo.defaultImage }] : [],
|
|
136
|
+
// Twitter
|
|
137
|
+
{ name: "twitter:card", content: "summary" },
|
|
138
|
+
{ name: "twitter:title", content: title },
|
|
139
|
+
{ name: "twitter:description", content: description }
|
|
140
|
+
];
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function createConversationMeta(id, config) {
|
|
144
|
+
return () => {
|
|
145
|
+
const {
|
|
146
|
+
queryClient,
|
|
147
|
+
apiBaseURL,
|
|
148
|
+
apiBasePath,
|
|
149
|
+
siteBaseURL,
|
|
150
|
+
siteBasePath,
|
|
151
|
+
seo
|
|
152
|
+
} = config;
|
|
153
|
+
const queries = createAiChatQueryKeys(
|
|
154
|
+
createApiClient({
|
|
155
|
+
baseURL: apiBaseURL,
|
|
156
|
+
basePath: apiBasePath
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
const conversation = queryClient.getQueryData(queries.conversations.detail(id).queryKey);
|
|
160
|
+
const fullUrl = `${siteBaseURL}${siteBasePath}/chat/${id}`;
|
|
161
|
+
const title = conversation?.title || "Chat";
|
|
162
|
+
const description = seo?.description || "AI conversation";
|
|
163
|
+
return [
|
|
164
|
+
{ title },
|
|
165
|
+
{ name: "title", content: title },
|
|
166
|
+
{ name: "description", content: description },
|
|
167
|
+
{ name: "robots", content: "noindex, nofollow" },
|
|
168
|
+
// Open Graph
|
|
169
|
+
{ property: "og:type", content: "website" },
|
|
170
|
+
{ property: "og:title", content: title },
|
|
171
|
+
{ property: "og:description", content: description },
|
|
172
|
+
{ property: "og:url", content: fullUrl },
|
|
173
|
+
...seo?.siteName ? [{ property: "og:site_name", content: seo.siteName }] : [],
|
|
174
|
+
// Twitter
|
|
175
|
+
{ name: "twitter:card", content: "summary" },
|
|
176
|
+
{ name: "twitter:title", content: title }
|
|
177
|
+
];
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const aiChatClientPlugin = (config) => {
|
|
181
|
+
const isPublicMode = config.mode === "public";
|
|
182
|
+
if (isPublicMode) {
|
|
183
|
+
return defineClientPlugin({
|
|
184
|
+
name: "ai-chat",
|
|
185
|
+
routes: () => ({
|
|
186
|
+
// Chat home - simple chat interface without history
|
|
187
|
+
chat: createRoute("/chat", () => ({
|
|
188
|
+
PageComponent: () => /* @__PURE__ */ jsx(
|
|
189
|
+
ChatLayout,
|
|
190
|
+
{
|
|
191
|
+
apiBaseURL: config.apiBaseURL,
|
|
192
|
+
apiBasePath: config.apiBasePath,
|
|
193
|
+
showSidebar: false
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
loader: createConversationsLoader(config),
|
|
197
|
+
meta: createChatHomeMeta(config)
|
|
198
|
+
}))
|
|
199
|
+
}),
|
|
200
|
+
sitemap: async () => []
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return defineClientPlugin({
|
|
204
|
+
name: "ai-chat",
|
|
205
|
+
routes: () => ({
|
|
206
|
+
// Chat home - new conversation or list
|
|
207
|
+
chat: createRoute("/chat", () => ({
|
|
208
|
+
PageComponent: () => /* @__PURE__ */ jsx(
|
|
209
|
+
ChatLayout,
|
|
210
|
+
{
|
|
211
|
+
apiBaseURL: config.apiBaseURL,
|
|
212
|
+
apiBasePath: config.apiBasePath
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
loader: createConversationsLoader(config),
|
|
216
|
+
meta: createChatHomeMeta(config)
|
|
217
|
+
})),
|
|
218
|
+
// Existing conversation
|
|
219
|
+
chatConversation: createRoute("/chat/:id", ({ params }) => ({
|
|
220
|
+
PageComponent: () => /* @__PURE__ */ jsx(
|
|
221
|
+
ChatLayout,
|
|
222
|
+
{
|
|
223
|
+
apiBaseURL: config.apiBaseURL,
|
|
224
|
+
apiBasePath: config.apiBasePath,
|
|
225
|
+
conversationId: params.id
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
loader: createConversationLoader(params.id, config),
|
|
229
|
+
meta: createConversationMeta(params.id, config)
|
|
230
|
+
}))
|
|
231
|
+
}),
|
|
232
|
+
// Chat pages typically shouldn't be in sitemap, but we provide the option
|
|
233
|
+
sitemap: async () => {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export { aiChatClientPlugin };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const db = require('@btst/db');
|
|
4
|
+
|
|
5
|
+
const aiChatSchema = db.createDbPlugin("aiChat", {
|
|
6
|
+
conversation: {
|
|
7
|
+
modelName: "conversation",
|
|
8
|
+
fields: {
|
|
9
|
+
id: {
|
|
10
|
+
type: "string",
|
|
11
|
+
required: true,
|
|
12
|
+
unique: true
|
|
13
|
+
},
|
|
14
|
+
userId: {
|
|
15
|
+
type: "string",
|
|
16
|
+
required: false
|
|
17
|
+
},
|
|
18
|
+
title: {
|
|
19
|
+
type: "string",
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
createdAt: {
|
|
23
|
+
type: "date",
|
|
24
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
25
|
+
},
|
|
26
|
+
updatedAt: {
|
|
27
|
+
type: "date",
|
|
28
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
message: {
|
|
33
|
+
modelName: "message",
|
|
34
|
+
fields: {
|
|
35
|
+
id: {
|
|
36
|
+
type: "string",
|
|
37
|
+
required: true,
|
|
38
|
+
unique: true
|
|
39
|
+
},
|
|
40
|
+
conversationId: {
|
|
41
|
+
type: "string",
|
|
42
|
+
required: true,
|
|
43
|
+
references: {
|
|
44
|
+
model: "conversation",
|
|
45
|
+
field: "id",
|
|
46
|
+
onDelete: "cascade"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
role: {
|
|
50
|
+
type: "string",
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
53
|
+
content: {
|
|
54
|
+
type: "string",
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
createdAt: {
|
|
58
|
+
type: "date",
|
|
59
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
exports.aiChatSchema = aiChatSchema;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createDbPlugin } from '@btst/db';
|
|
2
|
+
|
|
3
|
+
const aiChatSchema = createDbPlugin("aiChat", {
|
|
4
|
+
conversation: {
|
|
5
|
+
modelName: "conversation",
|
|
6
|
+
fields: {
|
|
7
|
+
id: {
|
|
8
|
+
type: "string",
|
|
9
|
+
required: true,
|
|
10
|
+
unique: true
|
|
11
|
+
},
|
|
12
|
+
userId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
required: false
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
type: "string",
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
createdAt: {
|
|
21
|
+
type: "date",
|
|
22
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
23
|
+
},
|
|
24
|
+
updatedAt: {
|
|
25
|
+
type: "date",
|
|
26
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
message: {
|
|
31
|
+
modelName: "message",
|
|
32
|
+
fields: {
|
|
33
|
+
id: {
|
|
34
|
+
type: "string",
|
|
35
|
+
required: true,
|
|
36
|
+
unique: true
|
|
37
|
+
},
|
|
38
|
+
conversationId: {
|
|
39
|
+
type: "string",
|
|
40
|
+
required: true,
|
|
41
|
+
references: {
|
|
42
|
+
model: "conversation",
|
|
43
|
+
field: "id",
|
|
44
|
+
onDelete: "cascade"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
role: {
|
|
48
|
+
type: "string",
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
content: {
|
|
52
|
+
type: "string",
|
|
53
|
+
required: true
|
|
54
|
+
},
|
|
55
|
+
createdAt: {
|
|
56
|
+
type: "date",
|
|
57
|
+
defaultValue: () => /* @__PURE__ */ new Date()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export { aiChatSchema };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const zod = require('zod');
|
|
4
|
+
|
|
5
|
+
const createConversationSchema = zod.z.object({
|
|
6
|
+
id: zod.z.string().optional(),
|
|
7
|
+
title: zod.z.string().optional()
|
|
8
|
+
});
|
|
9
|
+
const updateConversationSchema = zod.z.object({
|
|
10
|
+
title: zod.z.string().optional()
|
|
11
|
+
});
|
|
12
|
+
const chatRequestSchema = zod.z.object({
|
|
13
|
+
messages: zod.z.array(
|
|
14
|
+
zod.z.union([
|
|
15
|
+
// Format with content string
|
|
16
|
+
zod.z.object({
|
|
17
|
+
role: zod.z.enum(["system", "user", "assistant", "data"]),
|
|
18
|
+
content: zod.z.string(),
|
|
19
|
+
id: zod.z.string().optional()
|
|
20
|
+
}),
|
|
21
|
+
// Format with parts array (from UIMessage)
|
|
22
|
+
zod.z.object({
|
|
23
|
+
role: zod.z.enum(["system", "user", "assistant", "data"]),
|
|
24
|
+
parts: zod.z.array(
|
|
25
|
+
zod.z.object({
|
|
26
|
+
type: zod.z.string(),
|
|
27
|
+
text: zod.z.string().optional()
|
|
28
|
+
// Allow other properties that might be present
|
|
29
|
+
}).loose()
|
|
30
|
+
),
|
|
31
|
+
id: zod.z.string().optional(),
|
|
32
|
+
metadata: zod.z.any().optional()
|
|
33
|
+
})
|
|
34
|
+
])
|
|
35
|
+
),
|
|
36
|
+
conversationId: zod.z.string().optional(),
|
|
37
|
+
model: zod.z.string().optional()
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
exports.chatRequestSchema = chatRequestSchema;
|
|
41
|
+
exports.createConversationSchema = createConversationSchema;
|
|
42
|
+
exports.updateConversationSchema = updateConversationSchema;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const createConversationSchema = z.object({
|
|
4
|
+
id: z.string().optional(),
|
|
5
|
+
title: z.string().optional()
|
|
6
|
+
});
|
|
7
|
+
const updateConversationSchema = z.object({
|
|
8
|
+
title: z.string().optional()
|
|
9
|
+
});
|
|
10
|
+
const chatRequestSchema = z.object({
|
|
11
|
+
messages: z.array(
|
|
12
|
+
z.union([
|
|
13
|
+
// Format with content string
|
|
14
|
+
z.object({
|
|
15
|
+
role: z.enum(["system", "user", "assistant", "data"]),
|
|
16
|
+
content: z.string(),
|
|
17
|
+
id: z.string().optional()
|
|
18
|
+
}),
|
|
19
|
+
// Format with parts array (from UIMessage)
|
|
20
|
+
z.object({
|
|
21
|
+
role: z.enum(["system", "user", "assistant", "data"]),
|
|
22
|
+
parts: z.array(
|
|
23
|
+
z.object({
|
|
24
|
+
type: z.string(),
|
|
25
|
+
text: z.string().optional()
|
|
26
|
+
// Allow other properties that might be present
|
|
27
|
+
}).loose()
|
|
28
|
+
),
|
|
29
|
+
id: z.string().optional(),
|
|
30
|
+
metadata: z.any().optional()
|
|
31
|
+
})
|
|
32
|
+
])
|
|
33
|
+
),
|
|
34
|
+
conversationId: z.string().optional(),
|
|
35
|
+
model: z.string().optional()
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export { chatRequestSchema, createConversationSchema, updateConversationSchema };
|